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

61  * prefer to embed struct drm_device into their own device
72 * A DRM device can provide several char-dev interfaces on the DRM-Major. Each
74 * of the device-driver, different interfaces are registered.
76 * Minors can be accessed via dev->$minor_name. This pointer is either
77 * NULL or a valid drm_minor pointer and stays valid as long as the device is
78 * valid. This means, DRM minors have the same life-time as the underlying
79 * device. However, this doesn't mean that the minor is active. Minors are
80 * registered and unregistered dynamically according to device-state.
88 return &dev->primary; in drm_minor_get_slot()
90 return &dev->render; in drm_minor_get_slot()
101 WARN_ON(dev != minor->dev); in drm_minor_alloc_release()
103 put_device(minor->kdev); in drm_minor_alloc_release()
106 idr_remove(&drm_minors_idr, minor->index); in drm_minor_alloc_release()
118 return -ENOMEM; in drm_minor_alloc()
120 minor->type = type; in drm_minor_alloc()
121 minor->dev = dev; in drm_minor_alloc()
136 minor->index = r; in drm_minor_alloc()
142 minor->kdev = drm_sysfs_minor_alloc(minor); in drm_minor_alloc()
143 if (IS_ERR(minor->kdev)) in drm_minor_alloc()
144 return PTR_ERR(minor->kdev); in drm_minor_alloc()
162 ret = drm_debugfs_init(minor, minor->index, drm_debugfs_root); in drm_minor_register()
168 ret = device_add(minor->kdev); in drm_minor_register()
174 idr_replace(&drm_minors_idr, minor, minor->index); in drm_minor_register()
177 DRM_DEBUG("new minor registered %d\n", minor->index); in drm_minor_register()
191 if (!minor || !device_is_registered(minor->kdev)) in drm_minor_unregister()
196 idr_replace(&drm_minors_idr, NULL, minor->index); in drm_minor_unregister()
199 device_del(minor->kdev); in drm_minor_unregister()
200 dev_set_drvdata(minor->kdev, NULL); /* safety belt */ in drm_minor_unregister()
205 * Looks up the given minor-ID and returns the respective DRM-minor object. The
206 * refence-count of the underlying device is increased so you must release this
210 * minor->dev pointer will stay valid! However, the device may get unplugged and
221 drm_dev_get(minor->dev); in drm_minor_acquire()
225 return ERR_PTR(-ENODEV); in drm_minor_acquire()
226 } else if (drm_dev_is_unplugged(minor->dev)) { in drm_minor_acquire()
227 drm_dev_put(minor->dev); in drm_minor_acquire()
228 return ERR_PTR(-ENODEV); in drm_minor_acquire()
236 drm_dev_put(minor->dev); in drm_minor_release()
242 * A device instance for a drm driver is represented by &struct drm_device. This
244 * bus-specific ->probe() callbacks implemented by the driver. The driver then
245 * needs to initialize all the various subsystems for the drm device like memory
248 * Finally when everything is up and running and ready for userspace the device
251 * There is also deprecated support for initalizing device instances using
252 * bus-specific helpers and the &drm_driver.load callback. But due to
253 * backwards-compatibility needs the device instance have to be published too
257 * When cleaning up a device instance everything needs to be done in reverse:
258 * First unpublish the device instance with drm_dev_unregister(). Then clean up
259 * any other resources allocated at device initialization and drop the driver's
264 * driver is unbound from the underlying physical struct &device. Best to use
269 * directly related to the underlying hardware device, and only used in code
279 * .. code-block:: c
297 * priv = devm_drm_dev_alloc(&pdev->dev, &driver_drm_driver,
301 * drm = &priv->drm;
307 * priv->userspace_facing = drmm_kzalloc(..., GFP_KERNEL);
308 * if (!priv->userspace_facing)
309 * return -ENOMEM;
311 * priv->pclk = devm_clk_get(dev, "PCLK");
312 * if (IS_ERR(priv->pclk))
313 * return PTR_ERR(priv->pclk);
347 * static int __maybe_unused driver_pm_suspend(struct device *dev)
352 * static int __maybe_unused driver_pm_resume(struct device *dev)
374 * Drivers that want to support device unplugging (USB, DT overlay unload) should
376 * regions that is accessing device resources to prevent use after they're
385 * drm_put_dev - Unregister and release a DRM device
386 * @dev: DRM device
388 * Called at module unload time or when a PCI device is unplugged.
390 * Cleans up all DRM device, calling drm_lastclose().
394 * instead to make sure that the device isn't userspace accessible any more
413 * drm_dev_enter - Enter device critical section
414 * @dev: DRM device
418 * be entered after the device has been unplugged. The section end is marked
428 if (dev->unplugged) { in drm_dev_enter()
438 * drm_dev_exit - Exit device critical section
442 * the device has been unplugged.
451 * drm_dev_unplug - unplug a DRM device
452 * @dev: DRM device
454 * This unplugs a hotpluggable DRM device, which makes it inaccessible to
455 * userspace operations. Entry-points can use drm_dev_enter() and
456 * drm_dev_exit() to protect device resources in a race free manner. This
457 * essentially unregisters the device like drm_dev_unregister(), but can be
464 * the new value of ->unplugged, and any critical section which might in drm_dev_unplug()
465 * still have seen the old value of ->unplugged is guaranteed to have in drm_dev_unplug()
468 dev->unplugged = true; in drm_dev_unplug()
478 * memory-mappings in VRAM (or stolen RAM, ...). However, core MM does not allow
479 * stand-alone address_space objects, so we need an underlying inode. As there
481 * VFS mount-point.
487 * We use drm_fs_inode_*() to manage our internal VFS mount-point and share it
488 * between multiple inode-users. You could, technically, call
498 return init_pseudo(fc, 0x010203ff) ? 0 : -ENOMEM; in drm_fs_init_fs_context()
519 inode = alloc_anon_inode(drm_fs_mnt->mnt_sb); in drm_fs_inode_new()
537 * DRM drivers that drive hardware where a logical device consists of a pile of
542 * - The entire device initialization procedure should be run from the
547 * - The opaque pointer passed to all components through component_bind_all()
548 * should point at &struct drm_device of the device instance, not some driver
551 * - The component helper fills the niche where further standardization of
563 drm_fs_inode_free(dev->anon_inode); in drm_dev_init_release()
565 put_device(dev->dev); in drm_dev_init_release()
566 /* Prevent use-after-free in drm_managed_release when debugging is in drm_dev_init_release()
568 dev->dev = NULL; in drm_dev_init_release()
569 mutex_destroy(&dev->master_mutex); in drm_dev_init_release()
570 mutex_destroy(&dev->clientlist_mutex); in drm_dev_init_release()
571 mutex_destroy(&dev->filelist_mutex); in drm_dev_init_release()
572 mutex_destroy(&dev->struct_mutex); in drm_dev_init_release()
578 struct device *parent) in drm_dev_init()
585 return -ENODEV; in drm_dev_init()
589 return -EINVAL; in drm_dev_init()
591 kref_init(&dev->ref); in drm_dev_init()
592 dev->dev = get_device(parent); in drm_dev_init()
593 dev->driver = driver; in drm_dev_init()
595 INIT_LIST_HEAD(&dev->managed.resources); in drm_dev_init()
596 spin_lock_init(&dev->managed.lock); in drm_dev_init()
598 /* no per-device feature limits by default */ in drm_dev_init()
599 dev->driver_features = ~0u; in drm_dev_init()
602 INIT_LIST_HEAD(&dev->filelist); in drm_dev_init()
603 INIT_LIST_HEAD(&dev->filelist_internal); in drm_dev_init()
604 INIT_LIST_HEAD(&dev->clientlist); in drm_dev_init()
605 INIT_LIST_HEAD(&dev->vblank_event_list); in drm_dev_init()
607 spin_lock_init(&dev->event_lock); in drm_dev_init()
608 mutex_init(&dev->struct_mutex); in drm_dev_init()
609 mutex_init(&dev->filelist_mutex); in drm_dev_init()
610 mutex_init(&dev->clientlist_mutex); in drm_dev_init()
611 mutex_init(&dev->master_mutex); in drm_dev_init()
624 dev->anon_inode = inode; in drm_dev_init()
667 static int devm_drm_dev_init(struct device *parent, in devm_drm_dev_init()
684 void *__devm_drm_dev_alloc(struct device *parent, struct drm_driver *driver, in __devm_drm_dev_alloc()
693 return ERR_PTR(-ENOMEM); in __devm_drm_dev_alloc()
708 * drm_dev_alloc - Allocate new DRM device
709 * @driver: DRM driver to allocate device for
710 * @parent: Parent device object
717 * Pointer to new DRM device, or ERR_PTR on failure.
720 struct device *parent) in drm_dev_alloc()
727 return ERR_PTR(-ENOMEM); in drm_dev_alloc()
745 if (dev->driver->release) in drm_dev_release()
746 dev->driver->release(dev); in drm_dev_release()
750 kfree(dev->managed.final_kfree); in drm_dev_release()
754 * drm_dev_get - Take reference of a DRM device
755 * @dev: device to take reference of or NULL
757 * This increases the ref-count of @dev by one. You *must* already own a
762 * guarantee whether the device is alive or running. It only provides a
768 kref_get(&dev->ref); in drm_dev_get()
773 * drm_dev_put - Drop reference of a DRM device
774 * @dev: device to drop reference of or NULL
776 * This decreases the ref-count of @dev by one. The device is destroyed if the
777 * ref-count drops to zero.
782 kref_put(&dev->ref, drm_dev_release); in drm_dev_put()
806 * 64-127. in create_compat_control_link()
808 name = kasprintf(GFP_KERNEL, "controlD%d", minor->index + 64); in create_compat_control_link()
810 return -ENOMEM; in create_compat_control_link()
812 ret = sysfs_create_link(minor->kdev->kobj.parent, in create_compat_control_link()
813 &minor->kdev->kobj, in create_compat_control_link()
833 name = kasprintf(GFP_KERNEL, "controlD%d", minor->index + 64); in remove_compat_control_link()
837 sysfs_remove_link(minor->kdev->kobj.parent, name); in remove_compat_control_link()
843 * drm_dev_register - Register DRM device
844 * @dev: Device to register
847 * Register the DRM device @dev with the system, advertise device to user-space
848 * and start normal device operation. @dev must be initialized via drm_dev_init()
851 * Never call this twice on any device!
854 * function calls the &drm_driver.load method after registering the device
864 struct drm_driver *driver = dev->driver; in drm_dev_register()
867 if (!driver->load) in drm_dev_register()
870 WARN_ON(!dev->managed.final_kfree); in drm_dev_register()
887 dev->registered = true; in drm_dev_register()
889 if (dev->driver->load) { in drm_dev_register()
890 ret = dev->driver->load(dev, flags); in drm_dev_register()
901 driver->name, driver->major, driver->minor, in drm_dev_register()
902 driver->patchlevel, driver->date, in drm_dev_register()
903 dev->dev ? dev_name(dev->dev) : "virtual device", in drm_dev_register()
904 dev->primary->index); in drm_dev_register()
920 * drm_dev_unregister - Unregister DRM device
921 * @dev: Device to unregister
923 * Unregister the DRM device from the system. This does the reverse of
924 * drm_dev_register() but does not deallocate the device. The caller must call
930 * This should be called first in the device teardown code to make sure
931 * userspace can't access the device instance any more.
938 dev->registered = false; in drm_dev_unregister()
945 if (dev->driver->unload) in drm_dev_unregister()
946 dev->driver->unload(dev); in drm_dev_unregister()
948 if (dev->agp) in drm_dev_unregister()
960 * drm_dev_set_unique - Set the unique name of a DRM device
961 * @dev: device of which to set the unique name
962 * @name: unique name
964 * Sets the unique name of a DRM device using the specified string. This is
966 * unique name for backwards compatibility reasons.
972 drmm_kfree(dev, dev->unique); in drm_dev_set_unique()
973 dev->unique = drmm_kstrdup(dev, name, GFP_KERNEL); in drm_dev_set_unique()
975 return dev->unique ? 0 : -ENOMEM; in drm_dev_set_unique()
985 * - The "DRM-Global" key/value database
986 * - Global ID management for connectors
987 * - DRM major number allocation
988 * - DRM minor management
989 * - DRM sysfs class
990 * - DRM debugfs root
992 * Furthermore, the DRM core provides dynamic char-dev lookups. For each
993 * interface registered on a DRM device, you can request minor numbers from DRM
994 * core. DRM core takes care of major-number management and char-dev
995 * registration. A stub ->open() callback forwards any open() requests to the
1011 new_fops = fops_get(minor->dev->driver->fops); in drm_stub_open()
1013 err = -ENODEV; in drm_stub_open()
1018 if (filp->f_op->open) in drm_stub_open()
1019 err = filp->f_op->open(inode, filp); in drm_stub_open()