2012-10-03 01:01:07 +08:00
|
|
|
#include <drm/drmP.h>
|
2014-01-06 22:28:28 +08:00
|
|
|
#include <drm/drm_usb.h>
|
2010-12-15 05:13:55 +08:00
|
|
|
#include <linux/usb.h>
|
2012-04-19 16:33:32 +08:00
|
|
|
#include <linux/module.h>
|
2010-12-15 05:13:55 +08:00
|
|
|
|
|
|
|
int drm_get_usb_dev(struct usb_interface *interface,
|
|
|
|
const struct usb_device_id *id,
|
|
|
|
struct drm_driver *driver)
|
|
|
|
{
|
|
|
|
struct drm_device *dev;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
DRM_DEBUG("\n");
|
|
|
|
|
2013-10-02 17:23:34 +08:00
|
|
|
dev = drm_dev_alloc(driver, &interface->dev);
|
2010-12-15 05:13:55 +08:00
|
|
|
if (!dev)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
2013-10-02 17:23:34 +08:00
|
|
|
dev->usbdev = interface_to_usbdev(interface);
|
2010-12-15 05:13:55 +08:00
|
|
|
usb_set_intfdata(interface, dev);
|
drm: implement experimental render nodes
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: David Herrmann <dh.herrmann@gmail.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
2013-08-26 00:29:00 +08:00
|
|
|
|
2013-10-02 17:23:35 +08:00
|
|
|
ret = drm_dev_register(dev, 0);
|
2010-12-15 05:13:55 +08:00
|
|
|
if (ret)
|
2013-10-02 17:23:35 +08:00
|
|
|
goto err_free;
|
2010-12-15 05:13:55 +08:00
|
|
|
|
|
|
|
DRM_INFO("Initialized %s %d.%d.%d %s on minor %d\n",
|
|
|
|
driver->name, driver->major, driver->minor, driver->patchlevel,
|
|
|
|
driver->date, dev->primary->index);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
2013-10-02 17:23:35 +08:00
|
|
|
err_free:
|
drm: provide device-refcount
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: David Herrmann <dh.herrmann@gmail.com>
2014-01-29 17:21:36 +08:00
|
|
|
drm_dev_unref(dev);
|
2010-12-15 05:13:55 +08:00
|
|
|
return ret;
|
|
|
|
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(drm_get_usb_dev);
|
|
|
|
|
|
|
|
static int drm_usb_set_busid(struct drm_device *dev,
|
|
|
|
struct drm_master *master)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct drm_bus drm_usb_bus = {
|
|
|
|
.set_busid = drm_usb_set_busid,
|
|
|
|
};
|
2014-05-19 19:39:07 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* drm_usb_init - Register matching USB devices with the DRM subsystem
|
|
|
|
* @driver: DRM device driver
|
|
|
|
* @udriver: USB device driver
|
|
|
|
*
|
|
|
|
* Registers one or more devices matched by a USB driver with the DRM
|
|
|
|
* subsystem.
|
|
|
|
*
|
|
|
|
* Return: 0 on success or a negative error code on failure.
|
|
|
|
*/
|
2010-12-15 05:13:55 +08:00
|
|
|
int drm_usb_init(struct drm_driver *driver, struct usb_driver *udriver)
|
|
|
|
{
|
|
|
|
int res;
|
|
|
|
DRM_DEBUG("\n");
|
|
|
|
|
|
|
|
driver->bus = &drm_usb_bus;
|
|
|
|
|
|
|
|
res = usb_register(udriver);
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(drm_usb_init);
|
|
|
|
|
2014-05-19 19:39:07 +08:00
|
|
|
/**
|
|
|
|
* drm_usb_exit - Unregister matching USB devices from the DRM subsystem
|
|
|
|
* @driver: DRM device driver
|
|
|
|
* @udriver: USB device driver
|
|
|
|
*
|
|
|
|
* Unregisters one or more devices matched by a USB driver from the DRM
|
|
|
|
* subsystem.
|
|
|
|
*/
|
2010-12-15 05:13:55 +08:00
|
|
|
void drm_usb_exit(struct drm_driver *driver,
|
|
|
|
struct usb_driver *udriver)
|
|
|
|
{
|
|
|
|
usb_deregister(udriver);
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(drm_usb_exit);
|
2012-04-19 16:33:32 +08:00
|
|
|
|
|
|
|
MODULE_AUTHOR("David Airlie");
|
|
|
|
MODULE_DESCRIPTION("USB DRM support");
|
|
|
|
MODULE_LICENSE("GPL and additional rights");
|