• Home
  • Raw
  • Download

Lines Matching +full:device +full:- +full:unique

74  * prefer to embed struct drm_device into their own device
85 * A DRM device can provide several char-dev interfaces on the DRM-Major. Each
87 * of the device-driver, different interfaces are registered.
89 * Minors can be accessed via dev->$minor_name. This pointer is either
90 * NULL or a valid drm_minor pointer and stays valid as long as the device is
91 * valid. This means, DRM minors have the same life-time as the underlying
92 * device. However, this doesn't mean that the minor is active. Minors are
93 * registered and unregistered dynamically according to device-state.
101 return &dev->primary; in drm_minor_get_slot()
103 return &dev->render; in drm_minor_get_slot()
117 return -ENOMEM; in drm_minor_alloc()
119 minor->type = type; in drm_minor_alloc()
120 minor->dev = dev; in drm_minor_alloc()
135 minor->index = r; in drm_minor_alloc()
137 minor->kdev = drm_sysfs_minor_alloc(minor); in drm_minor_alloc()
138 if (IS_ERR(minor->kdev)) { in drm_minor_alloc()
139 r = PTR_ERR(minor->kdev); in drm_minor_alloc()
148 idr_remove(&drm_minors_idr, minor->index); in drm_minor_alloc()
165 put_device(minor->kdev); in drm_minor_free()
168 idr_remove(&drm_minors_idr, minor->index); in drm_minor_free()
187 ret = drm_debugfs_init(minor, minor->index, drm_debugfs_root); in drm_minor_register()
193 ret = device_add(minor->kdev); in drm_minor_register()
199 idr_replace(&drm_minors_idr, minor, minor->index); in drm_minor_register()
202 DRM_DEBUG("new minor registered %d\n", minor->index); in drm_minor_register()
216 if (!minor || !device_is_registered(minor->kdev)) in drm_minor_unregister()
221 idr_replace(&drm_minors_idr, NULL, minor->index); in drm_minor_unregister()
224 device_del(minor->kdev); in drm_minor_unregister()
225 dev_set_drvdata(minor->kdev, NULL); /* safety belt */ in drm_minor_unregister()
230 * Looks up the given minor-ID and returns the respective DRM-minor object. The
231 * refence-count of the underlying device is increased so you must release this
235 * minor->dev pointer will stay valid! However, the device may get unplugged and
246 drm_dev_get(minor->dev); in drm_minor_acquire()
250 return ERR_PTR(-ENODEV); in drm_minor_acquire()
251 } else if (drm_dev_is_unplugged(minor->dev)) { in drm_minor_acquire()
252 drm_dev_put(minor->dev); in drm_minor_acquire()
253 return ERR_PTR(-ENODEV); in drm_minor_acquire()
261 drm_dev_put(minor->dev); in drm_minor_release()
267 * A device instance for a drm driver is represented by &struct drm_device. This
268 * is allocated with drm_dev_alloc(), usually from bus-specific ->probe()
270 * the various subsystems for the drm device like memory management, vblank
273 * also calling drm_dev_set_unique() to set the userspace-visible unique name of
274 * this device instance. Finally when everything is up and running and ready for
275 * userspace the device instance can be published using drm_dev_register().
277 * There is also deprecated support for initalizing device instances using
278 * bus-specific helpers and the &drm_driver.load callback. But due to
279 * backwards-compatibility needs the device instance have to be published too
283 * When cleaning up a device instance everything needs to be done in reverse:
284 * First unpublish the device instance with drm_dev_unregister(). Then clean up
285 * any other resources allocated at device initialization and drop the driver's
292 * It is recommended that drivers embed &struct drm_device into their own device
297 * drm_put_dev - Unregister and release a DRM device
298 * @dev: DRM device
300 * Called at module unload time or when a PCI device is unplugged.
302 * Cleans up all DRM device, calling drm_lastclose().
306 * instead to make sure that the device isn't userspace accessible any more
325 * drm_dev_enter - Enter device critical section
326 * @dev: DRM device
330 * be entered after the device has been unplugged. The section end is marked
340 if (dev->unplugged) { in drm_dev_enter()
350 * drm_dev_exit - Exit device critical section
354 * the device has been unplugged.
363 * drm_dev_unplug - unplug a DRM device
364 * @dev: DRM device
366 * This unplugs a hotpluggable DRM device, which makes it inaccessible to
367 * userspace operations. Entry-points can use drm_dev_enter() and
368 * drm_dev_exit() to protect device resources in a race free manner. This
369 * essentially unregisters the device like drm_dev_unregister(), but can be
376 * the new value of ->unplugged, and any critical section which might in drm_dev_unplug()
377 * still have seen the old value of ->unplugged is guaranteed to have in drm_dev_unplug()
380 dev->unplugged = true; in drm_dev_unplug()
391 * memory-mappings in VRAM (or stolen RAM, ...). However, core MM does not allow
392 * stand-alone address_space objects, so we need an underlying inode. As there
394 * VFS mount-point.
400 * We use drm_fs_inode_*() to manage our internal VFS mount-point and share it
401 * between multiple inode-users. You could, technically, call
445 inode = alloc_anon_inode(drm_fs_mnt->mnt_sb); in drm_fs_inode_new()
461 * drm_dev_init - Initialise new DRM device
462 * @dev: DRM device
464 * @parent: Parent device object
466 * Initialize a new DRM device. No device registration is done.
467 * Call drm_dev_register() to advertice the device to user space and register it
468 * with other core subsystems. This should be done last in the device
472 * The initial ref-count of the object is 1. Use drm_dev_get() and
473 * drm_dev_put() to take and drop further ref-counts.
477 * Drivers that do not want to allocate their own device struct
483 * allow embedding of the drm_device inside the driver's device struct at an
492 struct device *parent) in drm_dev_init()
498 return -ENODEV; in drm_dev_init()
501 kref_init(&dev->ref); in drm_dev_init()
502 dev->dev = get_device(parent); in drm_dev_init()
503 dev->driver = driver; in drm_dev_init()
505 INIT_LIST_HEAD(&dev->filelist); in drm_dev_init()
506 INIT_LIST_HEAD(&dev->filelist_internal); in drm_dev_init()
507 INIT_LIST_HEAD(&dev->clientlist); in drm_dev_init()
508 INIT_LIST_HEAD(&dev->ctxlist); in drm_dev_init()
509 INIT_LIST_HEAD(&dev->vmalist); in drm_dev_init()
510 INIT_LIST_HEAD(&dev->maplist); in drm_dev_init()
511 INIT_LIST_HEAD(&dev->vblank_event_list); in drm_dev_init()
513 spin_lock_init(&dev->buf_lock); in drm_dev_init()
514 spin_lock_init(&dev->event_lock); in drm_dev_init()
515 mutex_init(&dev->struct_mutex); in drm_dev_init()
516 mutex_init(&dev->filelist_mutex); in drm_dev_init()
517 mutex_init(&dev->clientlist_mutex); in drm_dev_init()
518 mutex_init(&dev->ctxlist_mutex); in drm_dev_init()
519 mutex_init(&dev->master_mutex); in drm_dev_init()
521 dev->anon_inode = drm_fs_inode_new(); in drm_dev_init()
522 if (IS_ERR(dev->anon_inode)) { in drm_dev_init()
523 ret = PTR_ERR(dev->anon_inode); in drm_dev_init()
538 ret = drm_ht_create(&dev->map_hash, 12); in drm_dev_init()
552 /* Use the parent device name as DRM device unique identifier, but fall in drm_dev_init()
554 ret = drm_dev_set_unique(dev, parent ? dev_name(parent) : driver->name); in drm_dev_init()
565 drm_ht_remove(&dev->map_hash); in drm_dev_init()
569 drm_fs_inode_free(dev->anon_inode); in drm_dev_init()
571 put_device(dev->dev); in drm_dev_init()
572 mutex_destroy(&dev->master_mutex); in drm_dev_init()
573 mutex_destroy(&dev->ctxlist_mutex); in drm_dev_init()
574 mutex_destroy(&dev->clientlist_mutex); in drm_dev_init()
575 mutex_destroy(&dev->filelist_mutex); in drm_dev_init()
576 mutex_destroy(&dev->struct_mutex); in drm_dev_init()
582 * drm_dev_fini - Finalize a dead DRM device
583 * @dev: DRM device
585 * Finalize a dead DRM device. This is the converse to drm_dev_init() and
590 * The ref-count of @dev must be zero, and drm_dev_fini() should only be called
601 drm_ht_remove(&dev->map_hash); in drm_dev_fini()
602 drm_fs_inode_free(dev->anon_inode); in drm_dev_fini()
607 put_device(dev->dev); in drm_dev_fini()
609 mutex_destroy(&dev->master_mutex); in drm_dev_fini()
610 mutex_destroy(&dev->ctxlist_mutex); in drm_dev_fini()
611 mutex_destroy(&dev->clientlist_mutex); in drm_dev_fini()
612 mutex_destroy(&dev->filelist_mutex); in drm_dev_fini()
613 mutex_destroy(&dev->struct_mutex); in drm_dev_fini()
614 kfree(dev->unique); in drm_dev_fini()
619 * drm_dev_alloc - Allocate new DRM device
620 * @driver: DRM driver to allocate device for
621 * @parent: Parent device object
623 * Allocate and initialize a new DRM device. No device registration is done.
624 * Call drm_dev_register() to advertice the device to user space and register it
625 * with other core subsystems. This should be done last in the device
629 * The initial ref-count of the object is 1. Use drm_dev_get() and
630 * drm_dev_put() to take and drop further ref-counts.
638 * Pointer to new DRM device, or ERR_PTR on failure.
641 struct device *parent) in drm_dev_alloc()
648 return ERR_PTR(-ENOMEM); in drm_dev_alloc()
664 if (dev->driver->release) { in drm_dev_release()
665 dev->driver->release(dev); in drm_dev_release()
673 * drm_dev_get - Take reference of a DRM device
674 * @dev: device to take reference of or NULL
676 * This increases the ref-count of @dev by one. You *must* already own a
681 * guarantee whether the device is alive or running. It only provides a
687 kref_get(&dev->ref); in drm_dev_get()
692 * drm_dev_put - Drop reference of a DRM device
693 * @dev: device to drop reference of or NULL
695 * This decreases the ref-count of @dev by one. The device is destroyed if the
696 * ref-count drops to zero.
701 kref_put(&dev->ref, drm_dev_release); in drm_dev_put()
706 * drm_dev_unref - Drop reference of a DRM device
707 * @dev: device to drop reference of or NULL
738 * 64-127. in create_compat_control_link()
740 name = kasprintf(GFP_KERNEL, "controlD%d", minor->index + 64); in create_compat_control_link()
742 return -ENOMEM; in create_compat_control_link()
744 ret = sysfs_create_link(minor->kdev->kobj.parent, in create_compat_control_link()
745 &minor->kdev->kobj, in create_compat_control_link()
765 name = kasprintf(GFP_KERNEL, "controlD%d", minor->index + 64); in remove_compat_control_link()
769 sysfs_remove_link(minor->kdev->kobj.parent, name); in remove_compat_control_link()
775 * drm_dev_register - Register DRM device
776 * @dev: Device to register
779 * Register the DRM device @dev with the system, advertise device to user-space
780 * and start normal device operation. @dev must be allocated via drm_dev_alloc()
783 * Never call this twice on any device!
786 * function calls the &drm_driver.load method after registering the device
796 struct drm_driver *driver = dev->driver; in drm_dev_register()
813 dev->registered = true; in drm_dev_register()
815 if (dev->driver->load) { in drm_dev_register()
816 ret = dev->driver->load(dev, flags); in drm_dev_register()
827 driver->name, driver->major, driver->minor, in drm_dev_register()
828 driver->patchlevel, driver->date, in drm_dev_register()
829 dev->dev ? dev_name(dev->dev) : "virtual device", in drm_dev_register()
830 dev->primary->index); in drm_dev_register()
845 * drm_dev_unregister - Unregister DRM device
846 * @dev: Device to unregister
848 * Unregister the DRM device from the system. This does the reverse of
849 * drm_dev_register() but does not deallocate the device. The caller must call
855 * This should be called first in the device teardown code to make sure
856 * userspace can't access the device instance any more.
865 dev->registered = false; in drm_dev_unregister()
872 if (dev->driver->unload) in drm_dev_unregister()
873 dev->driver->unload(dev); in drm_dev_unregister()
875 if (dev->agp) in drm_dev_unregister()
878 list_for_each_entry_safe(r_list, list_temp, &dev->maplist, head) in drm_dev_unregister()
879 drm_legacy_rmmap(dev, r_list->map); in drm_dev_unregister()
888 * drm_dev_set_unique - Set the unique name of a DRM device
889 * @dev: device of which to set the unique name
890 * @name: unique name
892 * Sets the unique name of a DRM device using the specified string. Drivers
893 * can use this at driver probe time if the unique name of the devices they
900 kfree(dev->unique); in drm_dev_set_unique()
901 dev->unique = kstrdup(name, GFP_KERNEL); in drm_dev_set_unique()
903 return dev->unique ? 0 : -ENOMEM; in drm_dev_set_unique()
913 * - The "DRM-Global" key/value database
914 * - Global ID management for connectors
915 * - DRM major number allocation
916 * - DRM minor management
917 * - DRM sysfs class
918 * - DRM debugfs root
920 * Furthermore, the DRM core provides dynamic char-dev lookups. For each
921 * interface registered on a DRM device, you can request minor numbers from DRM
922 * core. DRM core takes care of major-number management and char-dev
923 * registration. A stub ->open() callback forwards any open() requests to the
942 new_fops = fops_get(minor->dev->driver->fops); in drm_stub_open()
944 err = -ENODEV; in drm_stub_open()
949 if (filp->f_op->open) in drm_stub_open()
950 err = filp->f_op->open(inode, filp); in drm_stub_open()
993 ret = -ENOMEM; in drm_core_init()
994 DRM_ERROR("Cannot create debugfs-root: %d\n", ret); in drm_core_init()