1. 03 6月, 2013 1 次提交
    • H
      drm: fix a use-after-free when GPU acceleration disabled · b7ea85a4
      Huacai Chen 提交于
      When GPU acceleration is disabled, drm_vblank_cleanup() will free the
      vblank-related data, such as vblank_refcount, vblank_inmodeset, etc.
      But we found that drm_vblank_post_modeset() may be called after the
      cleanup, which use vblank_refcount and vblank_inmodeset. And this will
      cause a kernel panic.
      
      Fix this by return immediately if dev->num_crtcs is zero. This is the
      same thing that drm_vblank_pre_modeset() does.
      
      Call trace of a drm_vblank_post_modeset() after drm_vblank_cleanup():
      [   62.628906] [<ffffffff804868d0>] drm_vblank_post_modeset+0x34/0xb4
      [   62.628906] [<ffffffff804c7008>] atombios_crtc_dpms+0xb4/0x174
      [   62.628906] [<ffffffff804c70e0>] atombios_crtc_commit+0x18/0x38
      [   62.628906] [<ffffffff8047f038>] drm_crtc_helper_set_mode+0x304/0x3cc
      [   62.628906] [<ffffffff8047f92c>] drm_crtc_helper_set_config+0x6d8/0x988
      [   62.628906] [<ffffffff8047dd40>] drm_fb_helper_set_par+0x94/0x104
      [   62.628906] [<ffffffff80439d14>] fbcon_init+0x424/0x57c
      [   62.628906] [<ffffffff8046a638>] visual_init+0xb8/0x118
      [   62.628906] [<ffffffff8046b9f8>] take_over_console+0x238/0x384
      [   62.628906] [<ffffffff80436df8>] fbcon_takeover+0x7c/0xdc
      [   62.628906] [<ffffffff8024fa20>] notifier_call_chain+0x44/0x94
      [   62.628906] [<ffffffff8024fcbc>] __blocking_notifier_call_chain+0x48/0x68
      [   62.628906] [<ffffffff8042d990>] register_framebuffer+0x228/0x260
      [   62.628906] [<ffffffff8047e010>] drm_fb_helper_single_fb_probe+0x260/0x314
      [   62.628906] [<ffffffff8047e2c4>] drm_fb_helper_initial_config+0x200/0x234
      [   62.628906] [<ffffffff804e5560>] radeon_fbdev_init+0xd4/0xf4
      [   62.628906] [<ffffffff804e0e08>] radeon_modeset_init+0x9bc/0xa18
      [   62.628906] [<ffffffff804bfc14>] radeon_driver_load_kms+0xdc/0x12c
      [   62.628906] [<ffffffff8048b548>] drm_get_pci_dev+0x148/0x238
      [   62.628906] [<ffffffff80423564>] local_pci_probe+0x5c/0xd0
      [   62.628906] [<ffffffff80241ac4>] work_for_cpu_fn+0x1c/0x30
      [   62.628906] [<ffffffff802427c8>] process_one_work+0x274/0x3bc
      [   62.628906] [<ffffffff80242934>] process_scheduled_works+0x24/0x44
      [   62.628906] [<ffffffff8024515c>] worker_thread+0x31c/0x3f4
      [   62.628906] [<ffffffff802497a8>] kthread+0x88/0x90
      [   62.628906] [<ffffffff80206794>] kernel_thread_helper+0x10/0x18
      Signed-off-by: NHuacai Chen <chenhc@lemote.com>
      Signed-off-by: NBinbin Zhou <zhoubb@lemote.com>
      Cc: <stable@vger.kernel.org>
      Reviewed-by: NMichel Dänzer <michel.daenzer@amd.com>
      Acked-by: NPaul Menzel <paulepanter@users.sourceforge.net>
      Signed-off-by: NDave Airlie <airlied@gmail.com>
      b7ea85a4
  2. 18 2月, 2013 1 次提交
  3. 08 2月, 2013 2 次提交
  4. 29 11月, 2012 1 次提交
  5. 20 11月, 2012 4 次提交
    • E
      DRM/KMS: Add Bail-Out Conditions for Loop. · 0355cf3a
      Egbert Eich 提交于
      When trying to obtain an accurate timestamp for the last vsync interrupt
      in vblank_disable_and_save() we loop until the vsync counter after reading
      the time stamp is identical to the one before.
      In the case where no hardware timestamp can be obtained there is probably
      no point in trying to make sure we remain within the same vsync during
      the time we obtain the counter.
      Furthermore we should make sure there's an 'emergency exit' so that we
      don't end up in an endless loop when the driver get_vblank_timestamp()
      function doesn't manage to return within the same vsync.
      This may happen when this function prints out debugging information over
      a slow (ie serial) line.
      Signed-off-by: NEgbert Eich <eich@suse.de>
      Signed-off-by: NDave Airlie <airlied@redhat.com>
      0355cf3a
    • I
      drm: add support for monotonic vblank timestamps · c61eef72
      Imre Deak 提交于
      Jumps in the vblank and page flip event timestamps cause trouble for
      clients, so we should avoid them. The timestamp we get currently with
      gettimeofday can jump, so use instead monotonic timestamps.
      
      For backward compatibility use a module flag to revert back to using
      gettimeofday timestamps. Add also a DRM_CAP_TIMESTAMP_MONOTONIC flag
      that is simply a read only version of the module flag, so that clients
      can query this without depending on sysfs.
      Signed-off-by: NImre Deak <imre.deak@intel.com>
      Signed-off-by: NDave Airlie <airlied@redhat.com>
      c61eef72
    • I
      drm: use monotonic time in drm_calc_vbltimestamp_from_scanoutpos · e62f2f5a
      Imre Deak 提交于
      For measuring duration we want to avoid that our start/end timestamps
      jump, so use monotonic instead of real time for that.
      Signed-off-by: NImre Deak <imre.deak@intel.com>
      Reviewed-by: mario.kleiner
      Signed-off-by: NDave Airlie <airlied@redhat.com>
      e62f2f5a
    • R
      drm: add drm_send_vblank_event() helper (v5) · c6eefa17
      Rob Clark 提交于
      A helper that drivers can use to send vblank event after a pageflip.
      If the driver doesn't support proper vblank irq based time/seqn then
      just pass -1 for the pipe # to get do_gettimestamp() behavior (since
      there are a lot of drivers that don't use drm_vblank_count_and_time())
      
      Also an internal send_vblank_event() helper for the various other code
      paths within drm_irq that also need to send vblank events.
      
      v1: original
      v2: add back 'vblwait->reply.sequence = seq' which should not have
          been deleted
      v3: add WARN_ON() in case lock is not held and comments
      v4: use WARN_ON_SMP() instead to fix issue with !SMP && !DEBUG_SPINLOCK
          as pointed out by Marcin Slusarz
      v5: update docbook
      Signed-off-by: NRob Clark <rob@ti.com>
      Signed-off-by: NDave Airlie <airlied@redhat.com>
      c6eefa17
  6. 03 10月, 2012 1 次提交
  7. 24 8月, 2012 1 次提交
  8. 18 7月, 2012 1 次提交
  9. 22 5月, 2012 2 次提交
  10. 29 2月, 2012 1 次提交
  11. 14 11月, 2011 1 次提交
    • T
      drm: Remove utterly bogus preempt_disable() sections · d53dab3a
      Thomas Gleixner 提交于
      commit 27641c3f (drm/vblank: Add support for precise vblank
      timestamping) adds preempt_disable()/enable() around a spin locked
      section with the comments:
      
       * Disable preemption, so vblank_time_lock is held as short as
       * possible, even under a kernel with PREEMPT_RT patches.
      
      /* Disable preemption while holding vblank_time_lock. Do
       * it explicitely to guard against PREEMPT_RT kernel.
      
      Just that this has never been tested on a RT kernel which would have
      granted that nonsense with a might_sleep() warning because
      dev->vblank_time_lock is converted to a "sleeping" spinlock on RT.
      
      So this is activly wrong on RT and superflous on mainline. Remove it.
      Signed-off-by: NThomas Gleixner <tglx@linutronix.de>
      Acked-by: NMario Kleiner <mario.kleiner@tuebingen.mpg.de>
      Signed-off-by: NDave Airlie <airlied@redhat.com>
      d53dab3a
  12. 11 11月, 2011 1 次提交
  13. 10 11月, 2011 1 次提交
  14. 01 11月, 2011 1 次提交
  15. 04 8月, 2011 2 次提交
  16. 04 5月, 2011 1 次提交
  17. 28 4月, 2011 1 次提交
  18. 21 3月, 2011 1 次提交
  19. 28 2月, 2011 1 次提交
  20. 23 2月, 2011 3 次提交
  21. 07 2月, 2011 1 次提交
  22. 31 1月, 2011 1 次提交
    • C
      drm/i915: Suppress spurious vblank interrupts · 78c6e170
      Chris Wilson 提交于
      Hugh Dickins found that characters in xterm were going missing and oft
      delayed. Being the curious type, he managed to associate this with the
      new high-precision vblank patches; disabling these he found, restored
      the orderliness of his characters.
      
      The oddness begins when one realised that Hugh was not using vblanks at
      all on his system (fvwm and some xterms). Instead, all he had to go on
      were warning of a pipe underrun, curiously enough at around 60Hz. He
      poked and found that in addition to the underrun warning, the hardware
      was flagging the start of a new frame, a vblank, which in turn was
      kicking off the pending vblank processing code.
      
      There is little we can do for the underruns on Hugh's machine, a
      Crestline [965GM], which must have its FIFO watermarks set to 8.
      However, we do not need to process the vblank if we know that they are
      disabled...
      Reported-by: NHugh Dickins <hughd@google.com>
      Signed-off-by: NChris Wilson <chris@chris-wilson.co.uk>
      78c6e170
  23. 21 12月, 2010 1 次提交
  24. 09 12月, 2010 1 次提交
  25. 08 12月, 2010 1 次提交
  26. 22 11月, 2010 1 次提交
    • M
      drm/vblank: Add support for precise vblank timestamping. · 27641c3f
      Mario Kleiner 提交于
      The DRI2 swap & sync implementation needs precise
      vblank counts and precise timestamps corresponding
      to those vblank counts. For conformance to the OpenML
      OML_sync_control extension specification the DRM
      timestamp associated with a vblank count should
      correspond to the start of video scanout of the first
      scanline of the video frame following the vblank
      interval for that vblank count.
      
      Therefore we need to carry around precise timestamps
      for vblanks. Currently the DRM and KMS drivers generate
      timestamps ad-hoc via do_gettimeofday() in some
      places. The resulting timestamps are sometimes not
      very precise due to interrupt handling delays, they
      don't conform to OML_sync_control and some are wrong,
      as they aren't taken synchronized to the vblank.
      
      This patch implements support inside the drm core
      for precise and robust timestamping. It consists
      of the following interrelated pieces.
      
      1. Vblank timestamp caching:
      
      A per-crtc ringbuffer stores the most recent vblank
      timestamps corresponding to vblank counts.
      
      The ringbuffer can be read out lock-free via the
      accessor function:
      
      struct timeval timestamp;
      vblankcount = drm_vblank_count_and_time(dev, crtcid, &timestamp).
      
      The function returns the current vblank count and
      the corresponding timestamp for start of video
      scanout following the vblank interval. It can be
      used anywhere between enclosing drm_vblank_get(dev, crtcid)
      and drm_vblank_put(dev,crtcid) statements. It is used
      inside the drmWaitVblank ioctl and in the vblank event
      queueing and handling. It should be used by kms drivers for
      timestamping of bufferswap completion.
      
      The timestamp ringbuffer is reinitialized each time
      vblank irq's get reenabled in drm_vblank_get()/
      drm_update_vblank_count(). It is invalidated when
      vblank irq's get disabled.
      
      The ringbuffer is updated inside drm_handle_vblank()
      at each vblank irq.
      
      2. Calculation of precise vblank timestamps:
      
      drm_get_last_vbltimestamp() is used to compute the
      timestamp for the end of the most recent vblank (if
      inside active scanout), or the expected end of the
      current vblank interval (if called inside a vblank
      interval). The function calls into a new optional kms
      driver entry point dev->driver->get_vblank_timestamp()
      which is supposed to provide the precise timestamp.
      If a kms driver doesn't implement the entry point or
      if the call fails, a simple do_gettimeofday() timestamp
      is returned as crude approximation of the true vblank time.
      
      A new drm module parameter drm.timestamp_precision_usec
      allows to disable high precision timestamps (if set to
      zero) or to specify the maximum acceptable error in
      the timestamps in microseconds.
      
      Kms drivers could implement their get_vblank_timestamp()
      function in a gpu specific way, as long as returned
      timestamps conform to OML_sync_control, e.g., by use
      of gpu specific hardware timestamps.
      
      Optionally, kms drivers can simply wrap and use the new
      utility function drm_calc_vbltimestamp_from_scanoutpos().
      This function calls a new optional kms driver function
      dev->driver->get_scanout_position() which returns the
      current horizontal and vertical video scanout position
      of the crtc. The scanout position together with the
      drm_display_timing of the current video mode is used
      to calculate elapsed time relative to start of active scanout
      for the current video frame. This elapsed time is subtracted
      from the current do_gettimeofday() time to get the timestamp
      corresponding to start of video scanout. Currently
      non-interlaced, non-doublescan video modes, with or
      without panel scaling are handled correctly. Interlaced/
      doublescan modes are tbd in a future patch.
      
      3. Filtering of redundant vblank irq's and removal of
      some race-conditions in the vblank irq enable/disable path:
      
      Some gpu's (e.g., Radeon R500/R600) send spurious vblank
      irq's outside the vblank if vblank irq's get reenabled.
      These get detected by use of the vblank timestamps and
      filtered out to avoid miscounting of vblanks.
      
      Some race-conditions between the vblank irq enable/disable
      functions, the vblank irq handler and the gpu itself (updating
      its hardware vblank counter in the "wrong" moment) are
      fixed inside vblank_disable_and_save() and
      drm_update_vblank_count() by use of the vblank timestamps and
      a new spinlock dev->vblank_time_lock.
      
      The time until vblank irq disable is now configurable via
      a new drm module parameter drm.vblankoffdelay to allow
      experimentation with timeouts that are much shorter than
      the current 5 seconds and should allow longer vblank off
      periods for better power savings.
      
      Followup patches will use these new functions to
      implement precise timestamping for the intel and radeon
      kms drivers.
      Signed-off-by: NMario Kleiner <mario.kleiner@tuebingen.mpg.de>
      Signed-off-by: NDave Airlie <airlied@redhat.com>
      27641c3f
  27. 02 7月, 2010 2 次提交
  28. 01 6月, 2010 1 次提交
  29. 27 4月, 2010 1 次提交
  30. 30 3月, 2010 1 次提交
    • T
      include cleanup: Update gfp.h and slab.h includes to prepare for breaking... · 5a0e3ad6
      Tejun Heo 提交于
      include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
      
      percpu.h is included by sched.h and module.h and thus ends up being
      included when building most .c files.  percpu.h includes slab.h which
      in turn includes gfp.h making everything defined by the two files
      universally available and complicating inclusion dependencies.
      
      percpu.h -> slab.h dependency is about to be removed.  Prepare for
      this change by updating users of gfp and slab facilities include those
      headers directly instead of assuming availability.  As this conversion
      needs to touch large number of source files, the following script is
      used as the basis of conversion.
      
        http://userweb.kernel.org/~tj/misc/slabh-sweep.py
      
      The script does the followings.
      
      * Scan files for gfp and slab usages and update includes such that
        only the necessary includes are there.  ie. if only gfp is used,
        gfp.h, if slab is used, slab.h.
      
      * When the script inserts a new include, it looks at the include
        blocks and try to put the new include such that its order conforms
        to its surrounding.  It's put in the include block which contains
        core kernel includes, in the same order that the rest are ordered -
        alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
        doesn't seem to be any matching order.
      
      * If the script can't find a place to put a new include (mostly
        because the file doesn't have fitting include block), it prints out
        an error message indicating which .h file needs to be added to the
        file.
      
      The conversion was done in the following steps.
      
      1. The initial automatic conversion of all .c files updated slightly
         over 4000 files, deleting around 700 includes and adding ~480 gfp.h
         and ~3000 slab.h inclusions.  The script emitted errors for ~400
         files.
      
      2. Each error was manually checked.  Some didn't need the inclusion,
         some needed manual addition while adding it to implementation .h or
         embedding .c file was more appropriate for others.  This step added
         inclusions to around 150 files.
      
      3. The script was run again and the output was compared to the edits
         from #2 to make sure no file was left behind.
      
      4. Several build tests were done and a couple of problems were fixed.
         e.g. lib/decompress_*.c used malloc/free() wrappers around slab
         APIs requiring slab.h to be added manually.
      
      5. The script was run on all .h files but without automatically
         editing them as sprinkling gfp.h and slab.h inclusions around .h
         files could easily lead to inclusion dependency hell.  Most gfp.h
         inclusion directives were ignored as stuff from gfp.h was usually
         wildly available and often used in preprocessor macros.  Each
         slab.h inclusion directive was examined and added manually as
         necessary.
      
      6. percpu.h was updated not to include slab.h.
      
      7. Build test were done on the following configurations and failures
         were fixed.  CONFIG_GCOV_KERNEL was turned off for all tests (as my
         distributed build env didn't work with gcov compiles) and a few
         more options had to be turned off depending on archs to make things
         build (like ipr on powerpc/64 which failed due to missing writeq).
      
         * x86 and x86_64 UP and SMP allmodconfig and a custom test config.
         * powerpc and powerpc64 SMP allmodconfig
         * sparc and sparc64 SMP allmodconfig
         * ia64 SMP allmodconfig
         * s390 SMP allmodconfig
         * alpha SMP allmodconfig
         * um on x86_64 SMP allmodconfig
      
      8. percpu.h modifications were reverted so that it could be applied as
         a separate patch and serve as bisection point.
      
      Given the fact that I had only a couple of failures from tests on step
      6, I'm fairly confident about the coverage of this conversion patch.
      If there is a breakage, it's likely to be something in one of the arch
      headers which should be easily discoverable easily on most builds of
      the specific arch.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Guess-its-ok-by: NChristoph Lameter <cl@linux-foundation.org>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
      5a0e3ad6
  31. 08 1月, 2010 1 次提交