1. 11 8月, 2014 1 次提交
    • D
      drm: Add a plane->reset hook · 2a0d7cfd
      Daniel Vetter 提交于
      In general having this can't hurt, and the atomic helpers will need
      it to be able to reset the state objects properly. The overall idea
      is to reset in the order pixels flow, so planes -> crtcs ->
      encoders -> connectors.
      
      v2: Squash in fixup from Ville to correctly deference struct drm_plane
      instead of drm_crtc when walking the plane list. Fixes an oops in
      driver init and resume.
      Reviewed-by: NMatt Roper <matthew.d.roper@intel.com>
      Signed-off-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      2a0d7cfd
  2. 08 8月, 2014 4 次提交
    • D
      drm: Move ->old_fb from crtc to plane · 3d30a59b
      Daniel Vetter 提交于
      Atomic implemenations for legacy ioctls must be able to drop locks.
      Which doesn't cause havoc since we only do that while constructing
      the new state, so no driver or hardware state change has happened.
      
      The only troubling bit is the fb refcounting the core does - if
      someone else has snuck in then it might potentially unref an
      outdated framebuffer. To fix that move the old_fb temporary storage
      into struct drm_plane for all ioctls, so that the atomic helpers can
      update it.
      
      v2: Fix up the error case handling as suggested by Matt Roper and just
      grab locks uncoditionally - there's no point in optimizing the locking
      for when userspace gets it wrong.
      
      Cc: Matt Roper <matthew.d.roper@intel.com>
      Cc: Dave Airlie <airlied@redhat.com>
      Reviewed-by: NMatt Roper <matthew.d.roper@intel.com>
      Signed-off-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      3d30a59b
    • D
      drm: Handle legacy per-crtc locking with full acquire ctx · d059f652
      Daniel Vetter 提交于
      So drivers using the atomic interfaces expect that they can acquire
      additional locks internal to the driver as-needed. Examples would be
      locks to protect shared state like shared display PLLs.
      
      Unfortunately the legacy ioctls assume that all locking is fully done
      by the drm core. Now for those paths which grab all locks we already
      have to keep around an acquire context in dev->mode_config. Helper
      functions that implement legacy interfaces in terms of atomic support
      can therefore grab this acquire contexts and reuse it.
      
      The only interfaces left are the cursor and pageflip ioctls. So add
      functions to grab the crtc lock these need using an acquire context
      and preserve it for atomic drivers to reuse.
      
      v2:
      - Fixup comments&kerneldoc.
      - Drop the WARNING from modeset_lock_all_crtcs since that can be used
        in legacy paths with crtc locking.
      
      v3: Fix a type on the kerneldoc Dave spotted.
      
      Cc: Dave Airlie <airlied@redhat.com>
      Reviewed-by: NDave Airlie <airlied@redhat.com>
      Reviewed-by: NMatt Roper <matthew.d.roper@intel.com>
      Signed-off-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      d059f652
    • D
      drm: Move modeset_lock_all helpers to drm_modeset_lock.[hc] · a6a8bb84
      Daniel Vetter 提交于
      Somehow we've forgotten about this little bit of OCD.
      Reviewed-by: NDave Airlie <airlied@redhat.com>
      Reviewed-by: NMatt Roper <matthew.d.roper@intel.com>
      Signed-off-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      a6a8bb84
    • D
      drm: Add drm_plane/connector_index · 10f637bf
      Daniel Vetter 提交于
      In the atomic state we'll have an array of states for crtcs, planes
      and connectors and need to be able to at them by their index. We
      already have a drm_crtc_index function so add the missing ones for
      planes and connectors.
      
      If it later on turns out that the list walking is too expensive we can
      add the index to the relevant modeset objects.
      
      Rob Clark doesn't like the loops too much, but we can always add an
      obj->idx parameter later on. And for now reiterating is actually safer
      since nowadays we have hotpluggable connectors (thanks to DP MST).
      
      v2: Fix embarrassing copypasta fail in kerneldoc and header
      declarations, spotted by Matt Roper.
      
      Cc: Matt Roper <matthew.d.roper@intel.com>
      Reviewed-by: NMatt Roper <matthew.d.roper@intel.com>
      Signed-off-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      10f637bf
  3. 06 8月, 2014 2 次提交
    • C
      drm: Perform cmdline mode parsing during connector initialisation · eaf99c74
      Chris Wilson 提交于
      i915.ko has a custom fbdev initialisation routine that aims to preserve
      the current mode set by the BIOS, unless overruled by the user. The
      user's wishes are determined by what, if any, mode is specified on the
      command line (via the video= parameter). However, that command line mode
      is first parsed by drm_fb_helper_initial_config() which is called after
      i915.ko's custom initial_config() as a fallback method. So in order for
      us to honour it, we need to move the cmdline parser earlier. If we
      perform the connector cmdline parsing as soon as we initialise the
      connector, that cmdline mode and forced status is then available even if
      the fbdev helper is not compiled in or never called.
      
      We also then expose the cmdline user mode in the connector mode lists.
      
      v2: Rebase after connector->name upheaval.
      
      v3: Adapt mga200 to look for the cmdline mode in the new place. Nicely
      simplifies things while at that.
      
      v4: Fix checkpatch.
      
      v5: Select FB_CMDLINE to adapt to the changed fbdev patch.
      
      Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=73154
      Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> (v2)
      Cc: Jesse Barnes <jbarnes@virtuousgeek.org>
      Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
      Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
      Reviewed-by: Jesse Barnes <jbarnes@virtuousgeek.org> (v2)
      Cc: dri-devel@lists.freedesktop.org
      Cc: Julia Lemire <jlemire@matrox.com>
      Cc: Dave Airlie <airlied@redhat.com>
      Signed-off-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      eaf99c74
    • D
      drm: Don't grab an fb reference for the idr · 83f45fc3
      Daniel Vetter 提交于
      The current refcounting scheme is that the fb lookup idr also holds a
      reference. This works out nicely bacause thus far we've always
      explicitly cleaned up idr entries for framebuffers:
      - Userspace fbs get removed in the rmfb ioctl or when the drm file
        gets closed.
      - Kernel fbs (for fbdev emulation) get cleaned up by the driver code
        at module unload time.
      
      But now i915 also reconstructs the bios fbs for a smooth transition.
      And that fb is purely transitional and should get removed immmediately
      once all crtcs stop using it. Of course if the i915 fbdev code decides
      to reuse it as the main fbdev fb then it shouldn't be cleaned up, but
      in that case the fbdev code will grab it's own reference.
      
      The problem is now that we also want to register that takeover fb in
      the idr, so that userspace can do a smooth transition (animated maybe
      even!) itself. But currently we have no one who will clean up the idr
      reference once that fb isn't useful any more, and so essentially leak
      it.
      
      Fix this by no longer holding a full fb reference for the idr, but
      instead just have a weak reference using kref_get_unless_zero. But
      that requires us to synchronize and clean up with the idr and fb_lock
      in drm_framebuffer_free, so add that. It's a bit ugly that we have to
      unconditionally grab the fb_lock, but without that someone might creep
      through a race.
      
      This leak was caught by the fb leak check in drm_mode_config_cleanup.
      Originally the leak was introduced in
      
      commit 46f297fb
      Author: Jesse Barnes <jbarnes@virtuousgeek.org>
      Date:   Fri Mar 7 08:57:48 2014 -0800
      
          drm/i915: add plane_config fetching infrastructure v2
      
      Cc:  Jesse Barnes <jbarnes@virtuousgeek.org>
      Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=77511Signed-off-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      83f45fc3
  4. 05 8月, 2014 1 次提交
  5. 04 8月, 2014 1 次提交
    • D
      drm: close race in connector registration (v2) · 2ee39452
      Dave Airlie 提交于
      Daniel pointed out with hotplug that userspace could be trying to oops us
      as root for lols, and that to be correct we shouldn't register the object
      with the idr before we have fully set the connector object up.
      
      His proposed solution was a lot more life changing, this seemed like a simpler
      proposition to me, get the connector object id from the idr, but don't
      register the object until the drm_connector_register callback.
      
      The open question is whether the drm_mode_object_register needs a bigger lock
      than just the idr one, but I can't see why it would, but I can be locking
      challenged.
      
      v2: fix bool noreg into sane - add comment.
      Reviewed-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      Reviewed-by: NDavid Herrmann <dh.herrmann@gmail.com>
      Signed-off-by: NDave Airlie <airlied@redhat.com>
      2ee39452
  6. 23 7月, 2014 1 次提交
  7. 18 7月, 2014 1 次提交
  8. 12 7月, 2014 3 次提交
  9. 08 7月, 2014 2 次提交
  10. 19 6月, 2014 3 次提交
  11. 13 6月, 2014 5 次提交
    • M
      drm: Allow drivers to register cursor planes with crtc · fc1d3e44
      Matt Roper 提交于
      Universal plane support had placeholders for cursor planes, but didn't
      actually do anything with them.  Save the cursor plane reference inside
      the crtc and update the cursor plane parameter from void* to drm_plane.
      Reviewed-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      Signed-off-by: NMatt Roper <matthew.d.roper@intel.com>
      Reviewed-by: Pallavi G<pallavi.g@intel.com>
      Acked-by: NDave Airlie <airlied@linux.ie>
      Signed-off-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      fc1d3e44
    • C
      drm: Avoid NULL deference when disabling a plane from userspace · 17cfd91f
      Chris Wilson 提交于
      To disable a plane, userspace passes in an framebuffer id of 0. This
      causes us to pass CRTC == NULL to setplane_internal, who promptly
      deferences it to grab the struct drm_device. Oops.
      
      [ 1296.467327] BUG: unable to handle kernel NULL pointer dereference at   (null)
      [ 1296.467332] IP: [<c134dc51>] setplane_internal+0x11/0x280
      [ 1296.467338] *pde = 00000000
      [ 1296.467341] Oops: 0000 [#1] SMP
      [ 1296.467344] Modules linked in: ccm bnep bluetooth snd_hda_codec_hdmi snd_hda_codec_idt snd_hda_codec_generic snd_hda_intel arc4 iwldvm snd_hda_controller snd_hda_codec mac80211 snd_hwdep snd_seq snd_seq_device snd_pcm snd_timer iwlwifi sdhci_pci snd cfg80211 x86_pkg_temp_thermal hp_wmi sdhci sparse_keymap mmc_core crc32c_intel rfkill microcode hp_accel lpc_ich lis3lv02d wmi mfd_core serio_raw input_polldev soundcore e1000e ptp pps_core
      [ 1296.467367] CPU: 1 PID: 672 Comm: Xorg Tainted: G        W     3.15.0-rc8+ #351
      [ 1296.467369] Hardware name: Hewlett-Packard HP ProBook 6360b/1620, BIOS 68SCF Ver. B.42 12/29/2010
      [ 1296.467371] task: f423b5c0 ti: c2332000 task.ti: c2332000
      [ 1296.467374] EIP: 0060:[<c134dc51>] EFLAGS: 00013286 CPU: 1
      [ 1296.467376] EIP is at setplane_internal+0x11/0x280
      [ 1296.467378] EAX: 00000000 EBX: c2333e90 ECX: 00000000 EDX: f3165600
      [ 1296.467380] ESI: f430f400 EDI: 00000000 EBP: c2333e14 ESP: c2333dd4
      [ 1296.467382]  DS: 007b ES: 007b FS: 00d8 GS: 0033 SS: 0068
      [ 1296.467384] CR0: 80050033 CR2: 00000000 CR3: 00159000 CR4: 000407d0
      [ 1296.467385] Stack:
      [ 1296.467387]  000200da 00000002 c2333de8 c15dc4a0 f430f400 c2333e00 c134c54f eeeeeeee
      [ 1296.467391]  f430f400 00000007 f416b480 c2333e14 00000000 c2333e90 f430f400 00000000
      [ 1296.467396]  c2333e4c c1350aed 00000000 00000000 00000000 00000000 00000000 00000000
      [ 1296.467400] Call Trace:
      [ 1296.467406]  [<c15dc4a0>] ? mutex_lock+0x10/0x28
      [ 1296.467408]  [<c134c54f>] ? _object_find+0x5f/0x90
      [ 1296.467413]  [<c1350aed>] drm_mode_setplane+0x10d/0x1f0
      [ 1296.467416]  [<c13509e0>] ? drm_mode_getplane+0x100/0x100
      [ 1296.467420]  [<c1342e4d>] drm_ioctl+0x1bd/0x4f0
      [ 1296.467423]  [<c13509e0>] ? drm_mode_getplane+0x100/0x100
      [ 1296.467427]  [<c111c023>] ? handle_mm_fault+0x5d3/0xb30
      [ 1296.467431]  [<c1118f31>] ? tlb_finish_mmu+0x11/0x40
      [ 1296.467435]  [<c1342c90>] ? drm_ioctl_flags+0x40/0x40
      [ 1296.467438]  [<c11593d2>] do_vfs_ioctl+0x2f2/0x4d0
      [ 1296.467443]  [<c1226512>] ? inode_has_perm.isra.32+0x32/0x40
      [ 1296.467446]  [<c122662f>] ? file_has_perm+0x7f/0x90
      [ 1296.467449]  [<c1226fec>] ? selinux_file_ioctl+0x4c/0xf0
      [ 1296.467452]  [<c1159610>] SyS_ioctl+0x60/0x90
      [ 1296.467456]  [<c15e578c>] sysenter_do_call+0x12/0x22
      [ 1296.467457] Code: 3f cf ff eb dd ba 3f 00 00 00 b8 d9 c9 7f c1 e8 e6 3f cf ff eb d9 8d 74 26 00 55 89 e5 57 56 53 83 ec 34 66 66 66 66 90 89 45 f0 <8b> 00 85 c9 89 d6 89 cb 89 45 ec 0f 84 16 01 00 00 8b 45 f0 e8
      [ 1296.467485] EIP: [<c134dc51>] setplane_internal+0x11/0x280 SS:ESP 0068:c2
      
      Fixes regression from
      commit b02fd7fd8a541c3d590bfdda23365a927b507ceb
      Author: Matt Roper <matthew.d.roper@intel.com>
      Date:   Tue Jun 10 08:28:10 2014 -0700
      
          drm: Support legacy cursor ioctls via universal planes when possible (v4)
      
      While at it move the plane parameter to the first position in
      setplane_internal since that's the main object we're manipulating.
      Signed-off-by: NChris Wilson <chris@chris-wilson.co.uk>
      Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
      Cc: Pallavi G<pallavi.g@intel.com>
      Cc: Matt Roper <matthew.d.roper@intel.com>
      Reviewed-by: NMatt Roper <matthew.d.roper@intel.com>
      [danvet: Add note about parameter reordering.]
      Signed-off-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      17cfd91f
    • M
      drm: Support legacy cursor ioctls via universal planes when possible (v4) · 161d0dc1
      Matt Roper 提交于
      If drivers support universal planes and have registered a cursor plane
      with the DRM core, we should use that universal plane support when
      handling legacy cursor ioctls.  Drivers that transition to universal
      planes won't have to maintain separate legacy ioctl handling; drivers
      that don't transition to universal planes will continue to operate
      without any change to behavior.
      
      Note that there's a bit of a mismatch between the legacy cursor ioctls
      and the universal plane API's --- legacy ioctl's use driver buffer
      handles directly whereas the universal plane API takes drm_framebuffers.
      Since there's no way to recover the driver handle from a
      drm_framebuffer, we can implement legacy ioctl's in terms of universal
      plane interfaces, but cannot implement universal plane interfaces in
      terms of legacy ioctls.  Specifically, there's no way to create a
      general cursor helper in the way we previously created a primary plane
      helper.
      
      It's important to land this patch before any patches that add universal
      cursor support to individual drivers so that drivers don't have to worry
      about juggling two different styles of reference counting for cursor
      buffers when userspace mixes and matches legacy and universal cursor
      calls.  With this patch, a driver that switches to universal cursor
      support may assume that all cursor buffers are wrapped in a
      drm_framebuffer and can rely on framebuffer reference counting for all
      cursor operations.
      
      v4:
       - Add comments pointing out setplane_internal's reference-eating
         semantics.
      v3:
       - Drop drm_mode_rmfb() call that is no longer needed now that we're
         using setplane_internal(), which takes care of deref'ing the
         appropriate framebuffer.
      v2:
       - Use new add_framebuffer_internal() function to create framebuffer
         rather than trying to call directly into the ioctl interface and
         look up the handle returned.
       - Use new setplane_internal() function to update the cursor plane
         rather than calling through the ioctl interface.  Note that since
         we're no longer looking up an fb_id, no extra reference will be
         taken here.
       - Grab extra reference to fb under lock in !BO case to avoid issues
         where racing userspace could cause the fb to be destroyed out from
         under us after we grab the fb pointer.
      Reviewed-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      Signed-off-by: NMatt Roper <matthew.d.roper@intel.com>
      Reviewed-by: Pallavi G<pallavi.g@intel.com>
      Acked-by: NDave Airlie <airlied@linux.ie>
      Signed-off-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      161d0dc1
    • M
      drm: Refactor setplane to allow internal use (v3) · b36552b3
      Matt Roper 提交于
      Refactor DRM setplane code into a new setplane_internal() function that
      takes DRM objects directly as parameters rather than looking them up by
      ID.  We'll use this in a future patch when we implement legacy cursor
      ioctls on top of the universal plane interface.
      
      v3:
       - Move integer overflow checking from setplane_internal to setplane
         ioctl.  The upcoming legacy cursor support via universal planes needs
         to maintain current cursor ioctl semantics and not return error for
         these extreme values (found via intel-gpu-tools kms_cursor_crc test).
      v2:
       - Allow planes to be disabled without a valid crtc again (and add
         mention of this to setplane's kerneldoc, since it doesn't seem to be
         mentioned anywhere else).
       - Reformat some parameter line wrap
      Reviewed-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      Signed-off-by: NMatt Roper <matthew.d.roper@intel.com>
      Reviewed-by: Pallavi G<pallavi.g@intel.com>
      Acked-by: NDave Airlie <airlied@linux.ie>
      Signed-off-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      b36552b3
    • M
      drm: Refactor framebuffer creation to allow internal use (v2) · c394c2b0
      Matt Roper 提交于
      Refactor DRM framebuffer creation into a new function that returns a
      struct drm_framebuffer directly.  The upcoming universal cursor support
      will want to create framebuffers internally to wrap cursor buffers, so
      we want to be able to share that framebuffer creation with the
      drm_mode_addfb2 ioctl handler.
      
      v2: Take struct drm_mode_fb_cmd2 parameter directly rather than void*
      Reviewed-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      Signed-off-by: NMatt Roper <matthew.d.roper@intel.com>
      Reviewed-by: Pallavi G<pallavi.g@intel.com>
      Acked-by: NDave Airlie <airlied@linux.ie>
      Signed-off-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      c394c2b0
  12. 06 6月, 2014 1 次提交
    • D
      drm: Fix getconnector connection_mutex locking · c7560f12
      Daniel Vetter 提交于
      I've fumbled my own idea and enthusiastically wrapped all the
      getconnector code with the connection_mutex. But we only need it to
      chase the connector->encoder link. Even there it's not really needed
      since races with userspace won't matter, but better paranoid and
      consistent about this stuff.
      
      If we grap it everywhere connector probe callbacks can't grab it
      themselves, which means they'll deadlock. i915 does that for the load
      detect pipe. Furthermore i915 needs to do a ww dance since we also
      need to grab the mutex of the load detect crtc.
      
      This is a regression from
      
      commit 6e9f798d
      Author: Daniel Vetter <daniel.vetter@ffwll.ch>
      Date:   Thu May 29 23:54:47 2014 +0200
      
          drm: Split connection_mutex out of mode_config.mutex (v3)
      
      Cc: Rob Clark <robdclark@gmail.com>
      Cc: Dave Airlie <airlied@redhat.com>
      Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
      Reported-by: NVille Syrjälä <ville.syrjala@linux.intel.com>
      Signed-off-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      Reviewed-by: NRob Clark <robdclark@gmail.com>
      Signed-off-by: NDave Airlie <airlied@redhat.com>
      c7560f12
  13. 05 6月, 2014 3 次提交
    • D
      drm: Fix getconnector connection_mutex locking · 832fd395
      Daniel Vetter 提交于
      I've fumbled my own idea and enthusiastically wrapped all the
      getconnector code with the connection_mutex. But we only need it to
      chase the connector->encoder link. Even there it's not really needed
      since races with userspace won't matter, but better paranoid and
      consistent about this stuff.
      
      If we grap it everywhere connector probe callbacks can't grab it
      themselves, which means they'll deadlock. i915 does that for the load
      detect pipe. Furthermore i915 needs to do a ww dance since we also
      need to grab the mutex of the load detect crtc.
      
      This is a regression from
      
      commit 6e9f798d
      Author: Daniel Vetter <daniel.vetter@ffwll.ch>
      Date:   Thu May 29 23:54:47 2014 +0200
      
          drm: Split connection_mutex out of mode_config.mutex (v3)
      
      Cc: Rob Clark <robdclark@gmail.com>
      Cc: Dave Airlie <airlied@redhat.com>
      Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
      Reported-by: NVille Syrjälä <ville.syrjala@linux.intel.com>
      Reviewed-by: NRob Clark <robdclark@gmail.com>
      Signed-off-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      832fd395
    • M
      drm: Check CRTC compatibility in setplane · 7f994f3f
      Matt Roper 提交于
      The DRM core setplane code should check that the plane is usable on the
      specified CRTC before calling into the driver.
      
      Prior to this patch, a plane's possible_crtcs field was purely
      informational for userspace and was never actually verified at the
      kernel level (aside from the primary plane helper).
      
      Cc: dri-devel@lists.freedesktop.org
      Reviewed-by: NChon Ming Lee <chon.ming.lee@intel.com>
      Signed-off-by: NMatt Roper <matthew.d.roper@intel.com>
      Acked-by: NDave Airlie <airlied@gmail.com>
      Signed-off-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      7f994f3f
    • R
      drm: convert crtc and connection_mutex to ww_mutex (v5) · 51fd371b
      Rob Clark 提交于
      For atomic, it will be quite necessary to not need to care so much
      about locking order.  And 'state' gives us a convenient place to stash a
      ww_ctx for any sort of update that needs to grab multiple crtc locks.
      
      Because we will want to eventually make locking even more fine grained
      (giving locks to planes, connectors, etc), split out drm_modeset_lock
      and drm_modeset_acquire_ctx to track acquired locks.
      
      Atomic will use this to keep track of which locks have been acquired
      in a transaction.
      
      v1: original
      v2: remove a few things not needed until atomic, for now
      v3: update for v3 of connection_mutex patch..
      v4: squash in docbook
      v5: doc tweaks/fixes
      Signed-off-by: NRob Clark <robdclark@gmail.com>
      Reviewed-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      Signed-off-by: NDave Airlie <airlied@redhat.com>
      51fd371b
  14. 04 6月, 2014 9 次提交
    • D
      drm: Split connection_mutex out of mode_config.mutex (v3) · 6e9f798d
      Daniel Vetter 提交于
      After the split-out of crtc locks from the big mode_config.mutex
      there's still two major areas it protects:
      - Various connector probe states, like connector->status, EDID
        properties, probed mode lists and similar information.
      - The links from connector->encoder and encoder->crtc and other
        modeset-relevant connector state (e.g. properties which control the
        panel fitter).
      
      The later is used by modeset operations. But they don't really care
      about the former since it's allowed to e.g. enable a disconnected VGA
      output or with a mode not in the probed list.
      
      Thus far this hasn't been a problem, but for the atomic modeset
      conversion Rob Clark needs to convert all modeset relevant locks into
      w/w locks. This is required because the order of acquisition is
      determined by how userspace supplies the atomic modeset data. This has
      run into troubles in the detect path since the i915 load detect code
      needs _both_ protections offered by the mode_config.mutex: It updates
      probe state and it needs to change the modeset configuration to enable
      the temporary load detect pipe.
      
      The big deal here is that for the probe/detect users of this lock a
      plain mutex fits best, but for atomic modesets we really want a w/w
      mutex. To fix this lets split out a new connection_mutex lock for the
      modeset relevant parts.
      
      For simplicity I've decided to only add one additional lock for all
      connector/encoder links and modeset configuration states. We have
      piles of different modeset objects in addition to those (like bridges
      or panels), so adding per-object locks would be much more effort.
      
      Also, we're guaranteed (at least for now) to do a full modeset if we
      need to acquire this lock. Which means that fine-grained locking is
      fairly irrelevant compared to the amount of time the full modeset will
      take.
      
      I've done a full audit, and there's just a few things that justify
      special focus:
      - Locking in drm_sysfs.c is almost completely absent. We should
        sprinkle mode_config.connection_mutex over this file a bit, but
        since it already lacks mode_config.mutex this patch wont make the
        situation any worse. This is material for a follow-up patch.
      
      - omap has a omap_framebuffer_flush function which walks the
        connector->encoder->crtc links and is called from many contexts.
        Some look like they don't acquire mode_config.mutex, so this is
        already racy. Again fixing this is material for a separate patch.
      
      - The radeon hot_plug function to retrain DP links looks at
        connector->dpms. Currently this happens without any locking, so is
        already racy. I think radeon_hotplug_work_func should gain
        mutex_lock/unlock calls for the mode_config.connection_mutex.
      
      - Same applies to i915's intel_dp_hot_plug. But again, this is already
        racy.
      
      - i915 load_detect code needs to acquire this lock. Which means the
        w/w dance due to Rob's work will be nicely contained to _just_ this
        function.
      
      I've added fixme comments everywhere where it looks suspicious but in
      the sysfs code. After a quick irc discussion with Dave Airlie it
      sounds like the lack of locking in there is due to sysfs cleanup fun
      at module unload.
      
      v1: original (only compile tested)
      
      v2: missing mutex_init(), etc (from Rob Clark)
      
      v3: i915 needs more care in the conversion:
      - Protect the edp pp logic with the connection_mutex.
      - Use connection_mutex in the backlight code due to
        get_pipe_from_connector.
      - Use drm_modeset_lock_all in suspend/resume paths.
      - Update lock checks in the overlay code.
      
      Cc: Alex Deucher <alexdeucher@gmail.com>
      Cc: Rob Clark <robdclark@gmail.com>
      Signed-off-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      Reviewed-by: NRob Clark <robdclark@gmail.com>
      6e9f798d
    • R
      drm: spiff out FB refcnting traces · 8291272a
      Rob Clark 提交于
      I find myself making this change locally whenever debugging FB reference
      counting.  Which seems a bit silly.
      Signed-off-by: NRob Clark <robdclark@gmail.com>
      Reviewed-by: NDavid Herrmann <dh.herrmann@gmail.com>
      8291272a
    • R
      drm: add signed-range property type · ebc44cf3
      Rob Clark 提交于
      Like range, but values are signed.
      Signed-off-by: NRob Clark <robdclark@gmail.com>
      Reviewed-by: NDavid Herrmann <dh.herrmann@gmail.com>
      ebc44cf3
    • R
      drm: add object property type · 98f75de4
      Rob Clark 提交于
      An object property is an id (idr) for a drm mode object.  This
      will allow a property to be used set/get a framebuffer, CRTC, etc.
      Signed-off-by: NRob Clark <robdclark@gmail.com>
      Reviewed-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      98f75de4
    • R
      drm: add extended property types · 5ea22f24
      Rob Clark 提交于
      If we continue to use bitmask for type, we will quickly run out of room
      to add new types.  Split this up so existing part of bitmask range
      continues to function as before, but reserve a chunk of the remaining
      space for an integer type-id.  Wrap this all up in some type-check
      helpers to keep the backwards-compat uglyness contained.
      Signed-off-by: NRob Clark <robdclark@gmail.com>
      Reviewed-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      5ea22f24
    • R
      drm: helpers to find mode objects · a2b34e22
      Rob Clark 提交于
      Add a few more useful helpers to find mode objects.
      Signed-off-by: NRob Clark <robdclark@gmail.com>
      Reviewed-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      a2b34e22
    • J
      drm: drop drm_get_connector_name() and drm_get_encoder_name() · d5ab2b43
      Jani Nikula 提交于
      No longer used or needed as the structs have a name field.
      Acked-by: NDavid Herrmann <dh.herrmann@gmail.com>
      Signed-off-by: NJani Nikula <jani.nikula@intel.com>
      Signed-off-by: NDave Airlie <airlied@redhat.com>
      d5ab2b43
    • J
      drm: replace drm_get_encoder_name() with direct name field use · 83a8cfd3
      Jani Nikula 提交于
      Generated using semantic patch:
      
      @@
      expression E;
      @@
      
      - drm_get_encoder_name(E)
      + E->name
      Acked-by: NDavid Herrmann <dh.herrmann@gmail.com>
      Signed-off-by: NJani Nikula <jani.nikula@intel.com>
      Signed-off-by: NDave Airlie <airlied@redhat.com>
      83a8cfd3
    • J
      drm: replace drm_get_connector_name() with direct name field use · 25933820
      Jani Nikula 提交于
      Generated using semantic patch:
      
      @@
      expression E;
      @@
      
      - drm_get_connector_name(E)
      + E->name
      
      [airlied: regenerated]
      Acked-by: NDavid Herrmann <dh.herrmann@gmail.com>
      Signed-off-by: NJani Nikula <jani.nikula@intel.com>
      Signed-off-by: NDave Airlie <airlied@redhat.com>
      25933820
  15. 30 5月, 2014 3 次提交