sync with OpenBSD -current
This commit is contained in:
parent
ee68147dcd
commit
1cefe29c7e
1651 changed files with 283292 additions and 68089 deletions
|
@ -48,6 +48,7 @@
|
|||
#include <linux/slab.h>
|
||||
#include <linux/srcu.h>
|
||||
|
||||
#include <drm/drm_accel.h>
|
||||
#include <drm/drm_cache.h>
|
||||
#include <drm/drm_client.h>
|
||||
#include <drm/drm_color_mgmt.h>
|
||||
|
@ -143,13 +144,15 @@ SPLAY_PROTOTYPE(drm_file_tree, drm_file, link, drm_file_cmp);
|
|||
*/
|
||||
|
||||
static struct drm_minor **drm_minor_get_slot(struct drm_device *dev,
|
||||
unsigned int type)
|
||||
enum drm_minor_type type)
|
||||
{
|
||||
switch (type) {
|
||||
case DRM_MINOR_PRIMARY:
|
||||
return &dev->primary;
|
||||
case DRM_MINOR_RENDER:
|
||||
return &dev->render;
|
||||
case DRM_MINOR_ACCEL:
|
||||
return &dev->accel;
|
||||
default:
|
||||
BUG();
|
||||
}
|
||||
|
@ -166,12 +169,16 @@ static void drm_minor_alloc_release(struct drm_device *dev, void *data)
|
|||
put_device(minor->kdev);
|
||||
#endif
|
||||
|
||||
spin_lock_irqsave(&drm_minor_lock, flags);
|
||||
idr_remove(&drm_minors_idr, minor->index);
|
||||
spin_unlock_irqrestore(&drm_minor_lock, flags);
|
||||
if (minor->type == DRM_MINOR_ACCEL) {
|
||||
accel_minor_remove(minor->index);
|
||||
} else {
|
||||
spin_lock_irqsave(&drm_minor_lock, flags);
|
||||
idr_remove(&drm_minors_idr, minor->index);
|
||||
spin_unlock_irqrestore(&drm_minor_lock, flags);
|
||||
}
|
||||
}
|
||||
|
||||
static int drm_minor_alloc(struct drm_device *dev, unsigned int type)
|
||||
static int drm_minor_alloc(struct drm_device *dev, enum drm_minor_type type)
|
||||
{
|
||||
struct drm_minor *minor;
|
||||
unsigned long flags;
|
||||
|
@ -185,13 +192,17 @@ static int drm_minor_alloc(struct drm_device *dev, unsigned int type)
|
|||
minor->dev = dev;
|
||||
|
||||
idr_preload(GFP_KERNEL);
|
||||
spin_lock_irqsave(&drm_minor_lock, flags);
|
||||
r = idr_alloc(&drm_minors_idr,
|
||||
NULL,
|
||||
64 * type,
|
||||
64 * (type + 1),
|
||||
GFP_NOWAIT);
|
||||
spin_unlock_irqrestore(&drm_minor_lock, flags);
|
||||
if (type == DRM_MINOR_ACCEL) {
|
||||
r = accel_minor_alloc();
|
||||
} else {
|
||||
spin_lock_irqsave(&drm_minor_lock, flags);
|
||||
r = idr_alloc(&drm_minors_idr,
|
||||
NULL,
|
||||
64 * type,
|
||||
64 * (type + 1),
|
||||
GFP_NOWAIT);
|
||||
spin_unlock_irqrestore(&drm_minor_lock, flags);
|
||||
}
|
||||
idr_preload_end();
|
||||
|
||||
if (r < 0)
|
||||
|
@ -213,7 +224,7 @@ static int drm_minor_alloc(struct drm_device *dev, unsigned int type)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int drm_minor_register(struct drm_device *dev, unsigned int type)
|
||||
static int drm_minor_register(struct drm_device *dev, enum drm_minor_type type)
|
||||
{
|
||||
struct drm_minor *minor;
|
||||
unsigned long flags;
|
||||
|
@ -228,10 +239,14 @@ static int drm_minor_register(struct drm_device *dev, unsigned int type)
|
|||
return 0;
|
||||
|
||||
#ifdef __linux__
|
||||
ret = drm_debugfs_init(minor, minor->index, drm_debugfs_root);
|
||||
if (ret) {
|
||||
DRM_ERROR("DRM: Failed to initialize /sys/kernel/debug/dri.\n");
|
||||
goto err_debugfs;
|
||||
if (minor->type == DRM_MINOR_ACCEL) {
|
||||
accel_debugfs_init(minor, minor->index);
|
||||
} else {
|
||||
ret = drm_debugfs_init(minor, minor->index, drm_debugfs_root);
|
||||
if (ret) {
|
||||
DRM_ERROR("DRM: Failed to initialize /sys/kernel/debug/dri.\n");
|
||||
goto err_debugfs;
|
||||
}
|
||||
}
|
||||
|
||||
ret = device_add(minor->kdev);
|
||||
|
@ -242,9 +257,13 @@ static int drm_minor_register(struct drm_device *dev, unsigned int type)
|
|||
#endif
|
||||
|
||||
/* replace NULL with @minor so lookups will succeed from now on */
|
||||
spin_lock_irqsave(&drm_minor_lock, flags);
|
||||
idr_replace(&drm_minors_idr, minor, minor->index);
|
||||
spin_unlock_irqrestore(&drm_minor_lock, flags);
|
||||
if (minor->type == DRM_MINOR_ACCEL) {
|
||||
accel_minor_replace(minor, minor->index);
|
||||
} else {
|
||||
spin_lock_irqsave(&drm_minor_lock, flags);
|
||||
idr_replace(&drm_minors_idr, minor, minor->index);
|
||||
spin_unlock_irqrestore(&drm_minor_lock, flags);
|
||||
}
|
||||
|
||||
DRM_DEBUG("new minor registered %d\n", minor->index);
|
||||
return 0;
|
||||
|
@ -256,7 +275,7 @@ err_debugfs:
|
|||
#endif
|
||||
}
|
||||
|
||||
static void drm_minor_unregister(struct drm_device *dev, unsigned int type)
|
||||
static void drm_minor_unregister(struct drm_device *dev, enum drm_minor_type type)
|
||||
{
|
||||
struct drm_minor *minor;
|
||||
unsigned long flags;
|
||||
|
@ -270,9 +289,13 @@ static void drm_minor_unregister(struct drm_device *dev, unsigned int type)
|
|||
return;
|
||||
|
||||
/* replace @minor with NULL so lookups will fail from now on */
|
||||
spin_lock_irqsave(&drm_minor_lock, flags);
|
||||
idr_replace(&drm_minors_idr, NULL, minor->index);
|
||||
spin_unlock_irqrestore(&drm_minor_lock, flags);
|
||||
if (minor->type == DRM_MINOR_ACCEL) {
|
||||
accel_minor_replace(NULL, minor->index);
|
||||
} else {
|
||||
spin_lock_irqsave(&drm_minor_lock, flags);
|
||||
idr_replace(&drm_minors_idr, NULL, minor->index);
|
||||
spin_unlock_irqrestore(&drm_minor_lock, flags);
|
||||
}
|
||||
|
||||
#ifdef __linux__
|
||||
device_del(minor->kdev);
|
||||
|
@ -665,6 +688,7 @@ static void drm_dev_init_release(struct drm_device *dev, void *res)
|
|||
mutex_destroy(&dev->clientlist_mutex);
|
||||
mutex_destroy(&dev->filelist_mutex);
|
||||
mutex_destroy(&dev->struct_mutex);
|
||||
mutex_destroy(&dev->debugfs_mutex);
|
||||
drm_legacy_destroy_members(dev);
|
||||
}
|
||||
|
||||
|
@ -695,17 +719,26 @@ static int drm_dev_init(struct drm_device *dev,
|
|||
/* no per-device feature limits by default */
|
||||
dev->driver_features = ~0u;
|
||||
|
||||
if (drm_core_check_feature(dev, DRIVER_COMPUTE_ACCEL) &&
|
||||
(drm_core_check_feature(dev, DRIVER_RENDER) ||
|
||||
drm_core_check_feature(dev, DRIVER_MODESET))) {
|
||||
DRM_ERROR("DRM driver can't be both a compute acceleration and graphics driver\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
drm_legacy_init_members(dev);
|
||||
INIT_LIST_HEAD(&dev->filelist);
|
||||
INIT_LIST_HEAD(&dev->filelist_internal);
|
||||
INIT_LIST_HEAD(&dev->clientlist);
|
||||
INIT_LIST_HEAD(&dev->vblank_event_list);
|
||||
INIT_LIST_HEAD(&dev->debugfs_list);
|
||||
|
||||
spin_lock_init(&dev->event_lock);
|
||||
mutex_init(&dev->struct_mutex);
|
||||
mutex_init(&dev->filelist_mutex);
|
||||
mutex_init(&dev->clientlist_mutex);
|
||||
mutex_init(&dev->master_mutex);
|
||||
mutex_init(&dev->debugfs_mutex);
|
||||
|
||||
ret = drmm_add_action_or_reset(dev, drm_dev_init_release, NULL);
|
||||
if (ret)
|
||||
|
@ -720,16 +753,22 @@ static int drm_dev_init(struct drm_device *dev,
|
|||
|
||||
dev->anon_inode = inode;
|
||||
|
||||
if (drm_core_check_feature(dev, DRIVER_RENDER)) {
|
||||
ret = drm_minor_alloc(dev, DRM_MINOR_RENDER);
|
||||
if (drm_core_check_feature(dev, DRIVER_COMPUTE_ACCEL)) {
|
||||
ret = drm_minor_alloc(dev, DRM_MINOR_ACCEL);
|
||||
if (ret)
|
||||
goto err;
|
||||
} else {
|
||||
if (drm_core_check_feature(dev, DRIVER_RENDER)) {
|
||||
ret = drm_minor_alloc(dev, DRM_MINOR_RENDER);
|
||||
if (ret)
|
||||
goto err;
|
||||
}
|
||||
|
||||
ret = drm_minor_alloc(dev, DRM_MINOR_PRIMARY);
|
||||
if (ret)
|
||||
goto err;
|
||||
}
|
||||
|
||||
ret = drm_minor_alloc(dev, DRM_MINOR_PRIMARY);
|
||||
if (ret)
|
||||
goto err;
|
||||
|
||||
ret = drm_legacy_create_map_hash(dev);
|
||||
if (ret)
|
||||
goto err;
|
||||
|
@ -744,9 +783,11 @@ static int drm_dev_init(struct drm_device *dev,
|
|||
}
|
||||
}
|
||||
|
||||
ret = drm_dev_set_unique(dev, dev_name(parent));
|
||||
if (ret)
|
||||
dev->unique = drmm_kstrdup(dev, dev_name(parent), GFP_KERNEL);
|
||||
if (!dev->unique) {
|
||||
ret = -ENOMEM;
|
||||
goto err;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
|
@ -985,14 +1026,18 @@ int drm_dev_register(struct drm_device *dev, unsigned long flags)
|
|||
if (ret)
|
||||
goto err_minors;
|
||||
|
||||
ret = drm_minor_register(dev, DRM_MINOR_ACCEL);
|
||||
if (ret)
|
||||
goto err_minors;
|
||||
|
||||
ret = create_compat_control_link(dev);
|
||||
if (ret)
|
||||
goto err_minors;
|
||||
|
||||
dev->registered = true;
|
||||
|
||||
if (dev->driver->load) {
|
||||
ret = dev->driver->load(dev, flags);
|
||||
if (driver->load) {
|
||||
ret = driver->load(dev, flags);
|
||||
if (ret)
|
||||
goto err_minors;
|
||||
}
|
||||
|
@ -1004,12 +1049,13 @@ int drm_dev_register(struct drm_device *dev, unsigned long flags)
|
|||
driver->name, driver->major, driver->minor,
|
||||
driver->patchlevel, driver->date,
|
||||
dev->dev ? dev_name(dev->dev) : "virtual device",
|
||||
dev->primary->index);
|
||||
dev->primary ? dev->primary->index : dev->accel->index);
|
||||
|
||||
goto out_unlock;
|
||||
|
||||
err_minors:
|
||||
remove_compat_control_link(dev);
|
||||
drm_minor_unregister(dev, DRM_MINOR_ACCEL);
|
||||
drm_minor_unregister(dev, DRM_MINOR_PRIMARY);
|
||||
drm_minor_unregister(dev, DRM_MINOR_RENDER);
|
||||
out_unlock:
|
||||
|
@ -1025,7 +1071,9 @@ EXPORT_SYMBOL(drm_dev_register);
|
|||
*
|
||||
* Unregister the DRM device from the system. This does the reverse of
|
||||
* drm_dev_register() but does not deallocate the device. The caller must call
|
||||
* drm_dev_put() to drop their final reference.
|
||||
* drm_dev_put() to drop their final reference, unless it is managed with devres
|
||||
* (as devices allocated with devm_drm_dev_alloc() are), in which case there is
|
||||
* already an unwind action registered.
|
||||
*
|
||||
* A special form of unregistering for hotpluggable devices is drm_dev_unplug(),
|
||||
* which can be called while there are still open users of @dev.
|
||||
|
@ -1052,31 +1100,12 @@ void drm_dev_unregister(struct drm_device *dev)
|
|||
drm_legacy_rmmaps(dev);
|
||||
|
||||
remove_compat_control_link(dev);
|
||||
drm_minor_unregister(dev, DRM_MINOR_ACCEL);
|
||||
drm_minor_unregister(dev, DRM_MINOR_PRIMARY);
|
||||
drm_minor_unregister(dev, DRM_MINOR_RENDER);
|
||||
}
|
||||
EXPORT_SYMBOL(drm_dev_unregister);
|
||||
|
||||
/**
|
||||
* drm_dev_set_unique - Set the unique name of a DRM device
|
||||
* @dev: device of which to set the unique name
|
||||
* @name: unique name
|
||||
*
|
||||
* Sets the unique name of a DRM device using the specified string. This is
|
||||
* already done by drm_dev_init(), drivers should only override the default
|
||||
* unique name for backwards compatibility reasons.
|
||||
*
|
||||
* Return: 0 on success or a negative error code on failure.
|
||||
*/
|
||||
int drm_dev_set_unique(struct drm_device *dev, const char *name)
|
||||
{
|
||||
drmm_kfree(dev, dev->unique);
|
||||
dev->unique = drmm_kstrdup(dev, name, GFP_KERNEL);
|
||||
|
||||
return dev->unique ? 0 : -ENOMEM;
|
||||
}
|
||||
EXPORT_SYMBOL(drm_dev_set_unique);
|
||||
|
||||
/*
|
||||
* DRM Core
|
||||
* The DRM core module initializes all global DRM objects and makes them
|
||||
|
@ -1138,6 +1167,7 @@ static const struct file_operations drm_stub_fops = {
|
|||
static void drm_core_exit(void)
|
||||
{
|
||||
drm_privacy_screen_lookup_exit();
|
||||
accel_core_exit();
|
||||
#ifdef __linux__
|
||||
unregister_chrdev(DRM_MAJOR, "drm");
|
||||
debugfs_remove(drm_debugfs_root);
|
||||
|
@ -1169,6 +1199,10 @@ static int __init drm_core_init(void)
|
|||
ret = register_chrdev(DRM_MAJOR, "drm", &drm_stub_fops);
|
||||
if (ret < 0)
|
||||
goto error;
|
||||
|
||||
ret = accel_core_init();
|
||||
if (ret < 0)
|
||||
goto error;
|
||||
#endif
|
||||
|
||||
drm_privacy_screen_lookup_init();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue