1. 13 6月, 2014 3 次提交
    • 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
  2. 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
  3. 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
  4. 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
  5. 30 5月, 2014 3 次提交
  6. 16 5月, 2014 1 次提交
  7. 24 4月, 2014 2 次提交
    • D
      drm: Handle ->disable_plane failures correctly · 731cce48
      Daniel Vetter 提交于
      The ->disable_plane hook always had a return value, but only since the
      introduction of primary planes was there any implementation that
      actually failed.
      
      So handle such failures correctly.
      
      Note that drm_plane_force_disable is special: In the modeset cleanup
      case we first disable all crtc, so primary planes should all be freed
      already. And in the fb helper we only reset non-primary planes. Still
      better be paranoid and add an early return.
      
      I don't see how this could happen, but it might fix the fb refcount
      underrun Thierry is seeing. Matt Roper spotted this issue.
      
      Cc: Thierry Reding <treding@nvidia.com>
      Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
      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>
      731cce48
    • D
      drm: Simplify fb refcounting rules around ->update_plane · 0fe27f06
      Daniel Vetter 提交于
      The introduction of primary planes has apparently caused a bit of fb
      refcounting fun for people. That makes it a good time to clean up the
      arcane rules and slight differences between ->update_plane and
      ->set_config. The new rules are:
      
      - The core holds a reference for both the new and the old fb (if
        they're non-NULL of course) while calling into the driver through
        either ->update_plane or ->set_config.
      
      - Drivers may not clobber plane->fb if their callback fails. If they
        do that, they need to store a pointer to the old fb in it again.
        When calling into the driver plane->fb still points at the current
        (old) framebuffer.
      
      - The core will update the plane->fb pointer on success. Drivers can
        do that themselves too, but aren't required to any more for the
        primary plane.
      
      - The core will update fb refcounts for the plane->fb pointer,
        presuming the drivers hold up their end of the bargain.
      
      v2: Remove now unused tmpfb (Thierry)
      
      v3: Drop broken changes from drm_mode_setplane (Ville). Also polish
      the commit message a bit.
      
      v4: Also fix up the handling of ->disable_plane in
      drm_plane_force_disable. The issue was that we didn't save plane->fb
      over the ->disable_plane call. Just paranoia, nothing relies on this.
      
      v5: Keep still useful comments about directly calling ->set_config,
      which I should have done for v4 already. Requested by Matt.
      
      Cc: Thierry Reding <treding@nvidia.com>
      Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
      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>
      0fe27f06
  8. 02 4月, 2014 7 次提交
  9. 28 3月, 2014 2 次提交
  10. 16 3月, 2014 1 次提交
    • D
      drm/crtc: add sanity checks to create_dumb() · b28cd41f
      David Herrmann 提交于
      Lets make sure some basic expressions are always true:
        bpp != NULL
        width != NULL
        height != NULL
        stride = bpp * width < 2^32
        size = stride * height < 2^32
        PAGE_ALIGN(size) < 2^32
      
      At least the udl driver doesn't check for multiplication-overflows, so
      lets just make sure it will never happen. These checks allow drivers to do
      any 32bit math without having to test for mult-overflows themselves.
      
      The two divisions might hurt performance a bit, but dumb_create() is only
      used for scanout-buffers, so that should be fine. We could use 64bit math
      to avoid the divisions, but that may be slow on 32bit machines.. Or maybe
      there should just be a "safe_mult32()" helper, which currently doesn't
      exist (I think?).
      Reviewed-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      Signed-off-by: NDavid Herrmann <dh.herrmann@gmail.com>
      b28cd41f
  11. 13 3月, 2014 4 次提交
    • D
      drm: kerneldoc polish for drm_crtc.c · c8e32cc1
      Daniel Vetter 提交于
      - Standardized on "Returns:" Block.
      - Sprinkle missing kerneldoc over all exported functions and all
        ioctls.
      - Add a stern warning that driver's really shouldn't use
        drm_mode_group_init_legacy_group.
      - Usual attempt at more consistency.
      - Add warnings that drm_mode_object_get/put don't do refcounting,
        despite what the names might lead to believe.
      - Try to clarify the framebuffer setup/cleanup functions wrt driver
        private framebuffers - I've fallen recently over this when reviewing
        i915 fbdev patches.
      - Align function parameters where the kerneldoc has been updated.
      - Most of the drm_get_*_name functions aren't thread safe. Add stern
        warnings where this is the case.
      
      Since a lot of the functions in drm_crtc.c are boilerplate to handle
      properties and create default sets of them it might be useful to
      extract all that code into a new file drm_property.c. Especially since
      properties will be used a lot more in the future.
      Reviewed-by: NAlex Deucher <alexander.deucher@amd.com>
      Signed-off-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      c8e32cc1
    • D
      drm: move drm_mode related functions into drm_modes.c · 8bd441b2
      Daniel Vetter 提交于
      Makes more sense and gives better grouping in the DocBook function
      reference sections. To make this possible we need to expose two
      functions from drm_crtc.c though. To avoid further namespace pollution
      in the system wide headers create a new internal header for such drm
      internal symbols.
      
      I expect that longer-term we'll add tons more, but since my goal here
      is to polish the kerneldoc that's for another day.
      Reviewed-by: NAlex Deucher <alexander.deucher@amd.com>
      Signed-off-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      8bd441b2
    • D
      drm/doc: Repleace LOCKING kerneldoc sections in drm_modes.c · 63951385
      Daniel Vetter 提交于
      There's not really any value in stating that no locking is needed. And
      even if the comment is useful, a check for the right mutex at the
      beginning of the function is better since that can't be ingored as
      easily as a bit of documentation.
      
      Note that drm_mode_probed_add in drm_crtc.c is also changed, the next
      patch will move this into drm_modes.c
      
      v2: Don't add locking WARN_ONs where it is not strictly required (i.e.
      the two functions to validate/prune mode lists).
      Reviewed-by: NAlex Deucher <alexander.deucher@amd.com>
      Signed-off-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      63951385
    • D
      drm/kms: rip out drm_mode_connector_detach_encoder · 69fa5293
      Daniel Vetter 提交于
      It's only used by imx, and that one gets it wrong - there's no need
      to deteach the encoder before removing it.
      
      And really, neither current drm modesetting code nor all the userspace
      we have can handle dynamic changes in the set of possible encoders for
      a given connector. So let's just remove this before someone starts
      doing something really nasty with it.
      
      As a plus, one less kerneldoc comment to write.
      
      Cc: Sascha Hauer <s.hauer@pengutronix.de>
      Cc: Russell King <rmk+kernel@arm.linux.org.uk>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Reviewed-by: NAlex Deucher <alexander.deucher@amd.com>
      Signed-off-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      69fa5293
  12. 13 2月, 2014 1 次提交
  13. 14 1月, 2014 1 次提交
  14. 18 12月, 2013 1 次提交
  15. 06 11月, 2013 1 次提交