1. 16 3月, 2014 2 次提交
    • D
      drm: add minor-lookup/release helpers · 1616c525
      David Herrmann 提交于
      Instead of accessing drm_minors_idr directly, this adds a small helper to
      hide the internals. This will help us later to remove the drm_global_mutex
      requirement for minor-lookup.
      
      Furthermore, this also makes sure that minor->dev is always valid and
      takes a reference-count to the device as long as the minor is used in an
      open-file. This way, "struct file*"->private_data->dev is guaranteed to be
      valid (which it has to, as we cannot reset it).
      Signed-off-by: NDavid Herrmann <dh.herrmann@gmail.com>
      Reviewed-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      1616c525
    • D
      drm: provide device-refcount · 099d1c29
      David Herrmann 提交于
      Lets not trick ourselves into thinking "drm_device" objects are not
      ref-counted. That's just utterly stupid. We manage "drm_minor" objects on
      each drm-device and each minor can have an unlimited number of open
      handles. Each of these handles has the drm_minor (and thus the drm_device)
      as private-data in the file-handle. Therefore, we may not destroy
      "drm_device" until all these handles are closed.
      
      It is *not* possible to reset all these pointers atomically and restrict
      access to them, and this is *not* how this is done! Instead, we use
      ref-counts to make sure the object is valid and not freed.
      
      Note that we currently use "dev->open_count" for that, which is *exactly*
      the same as a reference-count, just open coded. So this patch doesn't
      change any semantics on DRM devices (well, this patch just introduces the
      ref-count, anyway. Follow-up patches will replace open_count by it).
      
      Also note that generic VFS revoke support could allow us to drop this
      ref-count again. We could then just synchronously disable any fops->xy()
      calls. However, this is not the case, yet, and no such patches are
      in sight (and I seriously question the idea of dropping the ref-cnt
      again).
      Signed-off-by: NDavid Herrmann <dh.herrmann@gmail.com>
      099d1c29
  2. 18 12月, 2013 5 次提交
  3. 13 12月, 2013 1 次提交
  4. 15 11月, 2013 1 次提交
  5. 06 11月, 2013 6 次提交
  6. 09 10月, 2013 5 次提交
  7. 20 9月, 2013 1 次提交
  8. 30 8月, 2013 1 次提交
    • D
      drm: implement experimental render nodes · 1793126f
      David Herrmann 提交于
      Render nodes provide an API for userspace to use non-privileged GPU
      commands without any running DRM-Master. It is useful for offscreen
      rendering, GPGPU clients, and normal render clients which do not perform
      modesetting.
      
      Compared to legacy clients, render clients no longer need any
      authentication to perform client ioctls. Instead, user-space controls
      render/client access to GPUs via filesystem access-modes on the
      render-node. Once a render-node was opened, a client has full access to
      the client/render operations on the GPU. However, no modesetting or ioctls
      that affect global state are allowed on render nodes.
      
      To prevent privilege-escalation, drivers must explicitly state that they
      support render nodes. They must mark their render-only ioctls as
      DRM_RENDER_ALLOW so render clients can use them. Furthermore, they must
      support clients without any attached master.
      
      If filesystem access-modes are not enough for fine-grained access control
      to render nodes (very unlikely, considering the versaitlity of FS-ACLs),
      you may still fall-back to fd-passing from server to client (which allows
      arbitrary access-control). However, note that revoking access is
      currently impossible and unlikely to get implemented.
      
      Note: Render clients no longer have any associated DRM-Master as they are
      supposed to be independent of any server state. DRM core highly depends on
      file_priv->master to be non-NULL for modesetting/ctx/etc. commands.
      Therefore, drivers must be very careful to not require DRM-Master if they
      support DRIVER_RENDER.
      
      So far render-nodes are protected by "drm_rnodes". As long as this
      module-parameter is not set to 1, a driver will not create render nodes.
      This allows us to experiment with the API a bit before we stabilize it.
      
      v2: drop insecure GEM_FLINK to force use of dmabuf
      Signed-off-by: NDavid Herrmann <dh.herrmann@gmail.com>
      Signed-off-by: NDave Airlie <airlied@redhat.com>
      1793126f
  9. 19 8月, 2013 3 次提交
    • D
      drm: remove procfs code, take 2 · cb6458f9
      Daniel Vetter 提交于
      So almost two years ago I've tried to nuke the procfs code already
      once before:
      
      http://lists.freedesktop.org/archives/dri-devel/2011-October/015707.html
      
      The conclusion was that userspace drivers (specifically libdrm device
      node detection) stopped relying on procfs in 2001. But after some
      digging it turned out that the drmstat tool in libdrm is still using
      those files (but only when certain options are set). So we've decided
      to keep profcs.
      
      But I when I've started to dig around again what exactly this tool
      does I've noticed that it tries to read the "mem", "vm", and "vma"
      files from procfs. Now as far my git history digging shows "mem" never
      did anything useful (at least in the version that first showed up in
      upstream history in 2004) and the file was remove in
      
      commit 955b12de
      Author: Ben Gamari <bgamari@gmail.com>
      Date:   Tue Feb 17 20:08:49 2009 -0500
      
          drm: Convert proc files to seq_file and introduce debugfs
      
      Which means that for over 4 years drmstat has been broken, and no one
      cared. In my opinion that's proof enough that no one is actually using
      drmstat, and so that we can savely nuke the procfs support from drm.
      
      While at it fix up the error case cleanup for debugfs in drm_get_minor.
      
      v2: Fix dates, libdrm stopped relying on procfs for drm node detection
      in 2001.
      
      v3: fixup compilation warning for !CONFIG_DEBUG_FS, reported by
      Fengguang Wu.
      
      Cc: kbuild test robot <fengguang.wu@intel.com>
      Cc: Dave Airlie <airlied@linux.ie>
      Signed-off-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      Signed-off-by: NDave Airlie <airlied@redhat.com>
      cb6458f9
    • K
      drm: fix minor number range calculation · 24f40032
      Kristian Høgsberg 提交于
      Currently, both ranges overlap. Fix the limits so both ranges are mutually
      exclusive. Also use the occasion to convert whitespaces to tabs.
      Signed-off-by: NKristian Høgsberg <krh@bitplanet.net>
      (fixed up tabs and adjust commit-msg accordingly)
      Signed-off-by: NDavid Herrmann <dh.herrmann@gmail.com>
      Signed-off-by: NDave Airlie <airlied@redhat.com>
      24f40032
    • D
      drm: mark context support as a legacy subsystem · 7c510133
      Daniel Vetter 提交于
      So after a lot of digging around in git histories it looks like this
      has only ever be used by dri1 render clients. Hence we can fully
      disable the entire thing for modesetting drivers and so greatly reduce
      the attack surface for potential exploits (or at least tools like
      trinity ...).
      
      Also add the drm_legacy prefix for functions which are called from
      common code. To further reduce the impact on common code also extract
      all the ctx release handling into a function (instead of only
      releasing individual handles) and make ctxbitmap_cleanup return void -
      it can never fail.
      Reviewed-by: NEric Anholt <eric@anholt.net>
      Signed-off-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      Signed-off-by: NDave Airlie <airlied@redhat.com>
      7c510133
  10. 07 8月, 2013 1 次提交
  11. 27 6月, 2013 1 次提交
  12. 31 5月, 2013 1 次提交
    • A
      drm, agpgart: Use pgprot_writecombine for AGP maps and make the MTRR optional · f435046d
      Andy Lutomirski 提交于
      I'm not sure I understand the intent of the previous behavior.  mmap
      on /dev/agpgart and DRM_AGP maps had no cache flags set, so they
      would be fully cacheable.  But the DRM code (most of the time) would
      add a write-combining MTRR that would change the effective memory
      type to WC.
      
      The new behavior just requests WC explicitly for all AGP maps.
      
      If there is any code out there that expects cacheable access to the
      AGP aperture (because the drm driver doesn't request an MTRR or
      because it's using /dev/agpgart directly), then it will now end up
      with a UC or WC mapping, depending on the architecture and PAT
      availability.  But cacheable access to the aperture seems like it's
      asking for trouble, because, AIUI, the aperture is an alias of RAM.
      Reviewed-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      Signed-off-by: NAndy Lutomirski <luto@amacapital.net>
      Signed-off-by: NDave Airlie <airlied@redhat.com>
      f435046d
  13. 02 5月, 2013 1 次提交
  14. 28 2月, 2013 1 次提交
  15. 20 11月, 2012 3 次提交
    • 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
    • S
      drm/drm_stub: Remove unnecessary null check before kfree. · 66141d3d
      Sachin Kamat 提交于
      kfree on a null argument is a no-op.
      Silences the following smatch warning:
      drivers/gpu/drm/drm_stub.c:496 drm_put_dev() info:
      redundant null check on dev->devname calling kfree()
      Signed-off-by: NSachin Kamat <sachin.kamat@linaro.org>
      Signed-off-by: NDave Airlie <airlied@redhat.com>
      66141d3d
    • D
      drm: fix returning -EINVAL on setmaster if another master is active · 08bec5b4
      David Herrmann 提交于
      We link every DRM "file_priv" to a "drm_master" structure. Currently, the
      drmSetMaster() call returns 0 when there is _any_ active master associated
      with the "drm_master" structure of the calling "file_priv". This means,
      that after drmSetMaster() we are not guaranteed to be DRM-Master and might
      not be able to perform mode-setting.
      
      A way to reproduce this is by starting weston with the DRM backend from
      within an X-console (eg., xterm). Because the xserver's "drm_master" is
      currently active, weston is assigned to the same master but is inactive
      because its VT is inactive and the xserver is still active. But when
      "fake-activating" weston, it calls drmSetMaster(). With current behavior
      this returns "0/success" and weston thinks that it is DRM-Master, even
      though it is not (as the xserver is still DRM-Master).
      Expected behavior would be drmSetMaster() to return -EINVAL, because the
      xserver is still DRM-Master. This patch changes exactly that.
      
      The only way this bogus behavior would be useful is for clients to check
      whether their associated "drm_master" is currently the active DRM-Master.
      But this logic fails if no DRM-Master is currently active at all. Because
      then the client itself would become DRM-Master (if it is root) and this
      makes this whole thing useles.
      
      Also note that the second "if-condition":
        file_priv->minor->master != file_priv->master
      is always true and can be skipped.
      Signed-off-by: NDavid Herrmann <dh.herrmann@googlemail.com>
      Signed-off-by: NDave Airlie <airlied@redhat.com>
      08bec5b4
  16. 03 10月, 2012 1 次提交
  17. 22 5月, 2012 1 次提交
  18. 24 4月, 2012 1 次提交
  19. 20 3月, 2012 1 次提交
  20. 15 3月, 2012 1 次提交
    • D
      drm: add core support for unplugging a device (v2) · 2c07a21d
      Dave Airlie 提交于
      Two parts to this, one is simple unplug from sysfs for the device node.
      
      The second adds an unplugged state, if we have device opens, we
      just set the unplugged state and return, if we have no device
      opens we drop the drm device.
      
      If after a lastclose we discover we are unplugged we then
      drop the drm device.
      
      v2: use an atomic for unplugged and wrap it for users,
      add checks on open + mmap + ioctl entry points.
      Signed-off-by: NDave Airlie <airlied@redhat.com>
      2c07a21d
  21. 28 4月, 2011 1 次提交
    • J
      drm: Create and use drm_err · 5ad3d883
      Joe Perches 提交于
      Reduce drm text size ~1% by using drm_err and
      printf extension %pV to emit error messages.
      
      Remove unused macro DRM_MEM_ERROR.
      
      $ size drivers/gpu/drm/built-in.o*
         text	   data	    bss	    dec	    hex	filename
       361159	   9663	    256	 371078	  5a986	drivers/gpu/drm/built-in.o.new
       365416	   9663	    256	 375335	  5ba27	drivers/gpu/drm/built-in.o.old
      Signed-off-by: NJoe Perches <joe@perches.com>
      Signed-off-by: NDave Airlie <airlied@redhat.com>
      5ad3d883
  22. 07 2月, 2011 1 次提交