1. 28 3月, 2014 6 次提交
  2. 16 3月, 2014 12 次提交
    • D
      drm: make minors independent of global lock · 0d639883
      David Herrmann 提交于
      We used to protect minor-lookup and setup by the global drm lock. To
      continue our attempts of dropping drm_global_mutex, this patch makes the
      minor management independent of it. Furthermore, we make it all atomic and
      switch to spin-locks instead of a mutex.
      
      Now that minor-lookup is independent, we also move the
      "drm_is_unplugged()" test into the minor-lookup path. There is no reason
      to ever return a minor for unplugged objects, so keep that logic internal.
      Signed-off-by: NDavid Herrmann <dh.herrmann@gmail.com>
      0d639883
    • D
      drm: inline drm_minor_get_id() · 7d86cf1a
      David Herrmann 提交于
      We can significantly simplify this helper by using plain multiplication.
      Note that we converted the minor-type to an enum earlier so this didn't
      work before.
      
      We also fix a minor range-bug here: the limit argument of idr_alloc() is
      *exclusive*, not inclusive, so we should use 64 instead of 63 as offset.
      Signed-off-by: NDavid Herrmann <dh.herrmann@gmail.com>
      7d86cf1a
    • D
      drm: coding-style fixes in minor handling · 1abbc437
      David Herrmann 提交于
      Properly name goto-labels, remove empty lines and use DRM_ERROR if
      possible.
      Signed-off-by: NDavid Herrmann <dh.herrmann@gmail.com>
      1abbc437
    • D
      drm: remove redundant minor->device field · 5817878c
      David Herrmann 提交于
      Whenever we access minor->device, we are in a minor->kdev->...->fops
      callback so the minor->kdev pointer *must* be valid. Thus, simply use
      minor->kdev->devt instead of minor->device and remove the redundant field.
      Signed-off-by: NDavid Herrmann <dh.herrmann@gmail.com>
      Reviewed-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      5817878c
    • D
      drm: remove unneeded #ifdef CONFIG_DEBUGFS · cb0f9323
      David Herrmann 提交于
      No need to check for DEBUGFS, we already have dummy-fallbacks in our
      headers.
      Signed-off-by: NDavid Herrmann <dh.herrmann@gmail.com>
      Reviewed-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      cb0f9323
    • D
      drm: rename drm_unplug/get_minor() to drm_minor_register/unregister() · afcdbc86
      David Herrmann 提交于
      drm_get_minor() no longer allocates objects, and drm_unplug_minor() is now
      the exact reverse of it. Rename it to _register/unregister() so their
      name actually says what they do.
      
      Furthermore, remove the direct minor-ptr and instead pass the minor-type.
      This way we know the actual slot of the minor and can reset it if
      required.
      Signed-off-by: NDavid Herrmann <dh.herrmann@gmail.com>
      Reviewed-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      afcdbc86
    • D
      drm: move drm_put_minor() to drm_minor_free() · bd9dfa98
      David Herrmann 提交于
      _put/get() are used for ref-counting, which we clearly don't do here.
      Rename it to _free() and also use the common drm_minor_* prefix.
      Furthermore, avoid passing the minor directly but instead use the type
      like the other functions do, this allows us to reset the slot.
      
      We also drop the redundant call to drm_unplug_minor() as drm_minor_free()
      is only used from paths were that has already be called.
      Signed-off-by: NDavid Herrmann <dh.herrmann@gmail.com>
      Reviewed-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      bd9dfa98
    • D
      drm: allocate minors early · 05b701f6
      David Herrmann 提交于
      Instead of waiting for device-registration, we now allocate minor-objects
      during device allocation. The minors are not registered or assigned an ID.
      This is still postponed to device-registration.
      
      While at it, remove the superfluous output-parameter in drm_get_minor().
      
      The reason for this early allocation is to make
      dev->primary/control/render available atomically. So once the device is
      alive, all of them are already set and we never have the situation where
      one of them is set after another (they're either NULL or set, but never
      changed). This will eventually allow us to reduce minor-ID allocation to
      one base-ID instead of a single ID for each.
      Signed-off-by: NDavid Herrmann <dh.herrmann@gmail.com>
      Reviewed-by: NDaniel Vetter <daniel.vetter@ffwll.ch>
      05b701f6
    • 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
    • D
      drm: use anon-inode instead of relying on cdevs · 6796cb16
      David Herrmann 提交于
      DRM drivers share a common address_space across all character-devices of a
      single DRM device. This allows simple buffer eviction and mapping-control.
      However, DRM core currently waits for the first ->open() on any char-dev
      to mark the underlying inode as backing inode of the device. This delayed
      initialization causes ugly conditions all over the place:
        if (dev->dev_mapping)
          do_sth();
      
      To avoid delayed initialization and to stop reusing the inode of the
      char-dev, we allocate an anonymous inode for each DRM device and reset
      filp->f_mapping to it on ->open().
      Signed-off-by: NDavid Herrmann <dh.herrmann@gmail.com>
      6796cb16
    • D
      drm: add pseudo filesystem for shared inodes · 31bbe16f
      David Herrmann 提交于
      Our current DRM design uses a single address_space for all users of the
      same DRM device. However, there is no way to create an anonymous
      address_space without an underlying inode. Therefore, we wait for the
      first ->open() callback on a registered char-dev and take-over the inode
      of the char-dev. This worked well so far, but has several drawbacks:
       - We screw with FS internals and rely on some non-obvious invariants like
         inode->i_mapping being the same as inode->i_data for char-devs.
       - We don't have any address_space prior to the first ->open() from
         user-space. This leads to ugly fallback code and we cannot allocate
         global objects early.
      
      As pointed out by Al-Viro, fs/anon_inode.c is *not* supposed to be used by
      drivers for anonymous inode-allocation. Therefore, this patch follows the
      proposed alternative solution and adds a pseudo filesystem mount-point to
      DRM. We can then allocate private inodes including a private address_space
      for each DRM device at initialization time.
      
      Note that we could use:
        sysfs_get_inode(sysfs_mnt->mnt_sb, drm_device->dev->kobj.sd);
      to get access to the underlying sysfs-inode of a "struct device" object.
      However, most of this information is currently hidden and it's not clear
      whether this address_space is suitable for driver access. Thus, unless
      linux allows anonymous address_space objects or driver-core provides a
      public inode per device, we're left with our own private internal mount
      point.
      
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Signed-off-by: NDavid Herrmann <dh.herrmann@gmail.com>
      31bbe16f
  3. 18 12月, 2013 5 次提交
  4. 13 12月, 2013 1 次提交
  5. 15 11月, 2013 1 次提交
  6. 06 11月, 2013 6 次提交
  7. 09 10月, 2013 5 次提交
  8. 20 9月, 2013 1 次提交
  9. 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
  10. 19 8月, 2013 2 次提交
    • 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