| .. | .. |
|---|
| 31 | 31 | #include <linux/module.h> |
|---|
| 32 | 32 | #include <linux/moduleparam.h> |
|---|
| 33 | 33 | #include <linux/mount.h> |
|---|
| 34 | +#include <linux/pseudo_fs.h> |
|---|
| 34 | 35 | #include <linux/slab.h> |
|---|
| 35 | 36 | #include <linux/srcu.h> |
|---|
| 36 | 37 | |
|---|
| 37 | 38 | #include <drm/drm_client.h> |
|---|
| 39 | +#include <drm/drm_color_mgmt.h> |
|---|
| 38 | 40 | #include <drm/drm_drv.h> |
|---|
| 39 | | -#include <drm/drmP.h> |
|---|
| 41 | +#include <drm/drm_file.h> |
|---|
| 42 | +#include <drm/drm_managed.h> |
|---|
| 43 | +#include <drm/drm_mode_object.h> |
|---|
| 44 | +#include <drm/drm_print.h> |
|---|
| 40 | 45 | |
|---|
| 41 | 46 | #include "drm_crtc_internal.h" |
|---|
| 42 | | -#include "drm_legacy.h" |
|---|
| 43 | 47 | #include "drm_internal.h" |
|---|
| 44 | | -#include "drm_crtc_internal.h" |
|---|
| 45 | | - |
|---|
| 46 | | -/* |
|---|
| 47 | | - * drm_debug: Enable debug output. |
|---|
| 48 | | - * Bitmask of DRM_UT_x. See include/drm/drmP.h for details. |
|---|
| 49 | | - */ |
|---|
| 50 | | -unsigned int drm_debug = 0; |
|---|
| 51 | | -EXPORT_SYMBOL(drm_debug); |
|---|
| 48 | +#include "drm_legacy.h" |
|---|
| 52 | 49 | |
|---|
| 53 | 50 | MODULE_AUTHOR("Gareth Hughes, Leif Delgass, José Fonseca, Jon Smirl"); |
|---|
| 54 | 51 | MODULE_DESCRIPTION("DRM shared core routines"); |
|---|
| 55 | 52 | MODULE_LICENSE("GPL and additional rights"); |
|---|
| 56 | | -MODULE_PARM_DESC(debug, "Enable debug output, where each bit enables a debug category.\n" |
|---|
| 57 | | -"\t\tBit 0 (0x01) will enable CORE messages (drm core code)\n" |
|---|
| 58 | | -"\t\tBit 1 (0x02) will enable DRIVER messages (drm controller code)\n" |
|---|
| 59 | | -"\t\tBit 2 (0x04) will enable KMS messages (modesetting code)\n" |
|---|
| 60 | | -"\t\tBit 3 (0x08) will enable PRIME messages (prime code)\n" |
|---|
| 61 | | -"\t\tBit 4 (0x10) will enable ATOMIC messages (atomic code)\n" |
|---|
| 62 | | -"\t\tBit 5 (0x20) will enable VBL messages (vblank code)\n" |
|---|
| 63 | | -"\t\tBit 7 (0x80) will enable LEASE messages (leasing code)\n" |
|---|
| 64 | | -"\t\tBit 8 (0x100) will enable DP messages (displayport code)"); |
|---|
| 65 | | -module_param_named(debug, drm_debug, int, 0600); |
|---|
| 66 | 53 | |
|---|
| 67 | 54 | static DEFINE_SPINLOCK(drm_minor_lock); |
|---|
| 68 | 55 | static struct idr drm_minors_idr; |
|---|
| .. | .. |
|---|
| 106 | 93 | } |
|---|
| 107 | 94 | } |
|---|
| 108 | 95 | |
|---|
| 96 | +static void drm_minor_alloc_release(struct drm_device *dev, void *data) |
|---|
| 97 | +{ |
|---|
| 98 | + struct drm_minor *minor = data; |
|---|
| 99 | + unsigned long flags; |
|---|
| 100 | + |
|---|
| 101 | + WARN_ON(dev != minor->dev); |
|---|
| 102 | + |
|---|
| 103 | + put_device(minor->kdev); |
|---|
| 104 | + |
|---|
| 105 | + spin_lock_irqsave(&drm_minor_lock, flags); |
|---|
| 106 | + idr_remove(&drm_minors_idr, minor->index); |
|---|
| 107 | + spin_unlock_irqrestore(&drm_minor_lock, flags); |
|---|
| 108 | +} |
|---|
| 109 | + |
|---|
| 109 | 110 | static int drm_minor_alloc(struct drm_device *dev, unsigned int type) |
|---|
| 110 | 111 | { |
|---|
| 111 | 112 | struct drm_minor *minor; |
|---|
| 112 | 113 | unsigned long flags; |
|---|
| 113 | 114 | int r; |
|---|
| 114 | 115 | |
|---|
| 115 | | - minor = kzalloc(sizeof(*minor), GFP_KERNEL); |
|---|
| 116 | + minor = drmm_kzalloc(dev, sizeof(*minor), GFP_KERNEL); |
|---|
| 116 | 117 | if (!minor) |
|---|
| 117 | 118 | return -ENOMEM; |
|---|
| 118 | 119 | |
|---|
| .. | .. |
|---|
| 130 | 131 | idr_preload_end(); |
|---|
| 131 | 132 | |
|---|
| 132 | 133 | if (r < 0) |
|---|
| 133 | | - goto err_free; |
|---|
| 134 | + return r; |
|---|
| 134 | 135 | |
|---|
| 135 | 136 | minor->index = r; |
|---|
| 136 | 137 | |
|---|
| 138 | + r = drmm_add_action_or_reset(dev, drm_minor_alloc_release, minor); |
|---|
| 139 | + if (r) |
|---|
| 140 | + return r; |
|---|
| 141 | + |
|---|
| 137 | 142 | minor->kdev = drm_sysfs_minor_alloc(minor); |
|---|
| 138 | | - if (IS_ERR(minor->kdev)) { |
|---|
| 139 | | - r = PTR_ERR(minor->kdev); |
|---|
| 140 | | - goto err_index; |
|---|
| 141 | | - } |
|---|
| 143 | + if (IS_ERR(minor->kdev)) |
|---|
| 144 | + return PTR_ERR(minor->kdev); |
|---|
| 142 | 145 | |
|---|
| 143 | 146 | *drm_minor_get_slot(dev, type) = minor; |
|---|
| 144 | 147 | return 0; |
|---|
| 145 | | - |
|---|
| 146 | | -err_index: |
|---|
| 147 | | - spin_lock_irqsave(&drm_minor_lock, flags); |
|---|
| 148 | | - idr_remove(&drm_minors_idr, minor->index); |
|---|
| 149 | | - spin_unlock_irqrestore(&drm_minor_lock, flags); |
|---|
| 150 | | -err_free: |
|---|
| 151 | | - kfree(minor); |
|---|
| 152 | | - return r; |
|---|
| 153 | | -} |
|---|
| 154 | | - |
|---|
| 155 | | -static void drm_minor_free(struct drm_device *dev, unsigned int type) |
|---|
| 156 | | -{ |
|---|
| 157 | | - struct drm_minor **slot, *minor; |
|---|
| 158 | | - unsigned long flags; |
|---|
| 159 | | - |
|---|
| 160 | | - slot = drm_minor_get_slot(dev, type); |
|---|
| 161 | | - minor = *slot; |
|---|
| 162 | | - if (!minor) |
|---|
| 163 | | - return; |
|---|
| 164 | | - |
|---|
| 165 | | - put_device(minor->kdev); |
|---|
| 166 | | - |
|---|
| 167 | | - spin_lock_irqsave(&drm_minor_lock, flags); |
|---|
| 168 | | - idr_remove(&drm_minors_idr, minor->index); |
|---|
| 169 | | - spin_unlock_irqrestore(&drm_minor_lock, flags); |
|---|
| 170 | | - |
|---|
| 171 | | - kfree(minor); |
|---|
| 172 | | - *slot = NULL; |
|---|
| 173 | 148 | } |
|---|
| 174 | 149 | |
|---|
| 175 | 150 | static int drm_minor_register(struct drm_device *dev, unsigned int type) |
|---|
| .. | .. |
|---|
| 261 | 236 | drm_dev_put(minor->dev); |
|---|
| 262 | 237 | } |
|---|
| 263 | 238 | |
|---|
| 264 | | -struct drm_device *drm_device_get_by_name(const char *name) |
|---|
| 265 | | -{ |
|---|
| 266 | | - int i; |
|---|
| 267 | | - |
|---|
| 268 | | - for (i = 0; i < 64; i++) { |
|---|
| 269 | | - struct drm_minor *minor; |
|---|
| 270 | | - |
|---|
| 271 | | - minor = drm_minor_acquire(i + DRM_MINOR_PRIMARY); |
|---|
| 272 | | - if (IS_ERR(minor)) |
|---|
| 273 | | - continue; |
|---|
| 274 | | - if (!minor->dev || !minor->dev->driver || |
|---|
| 275 | | - !minor->dev->driver->name) |
|---|
| 276 | | - continue; |
|---|
| 277 | | - if (!name) |
|---|
| 278 | | - return minor->dev; |
|---|
| 279 | | - if (!strcmp(name, minor->dev->driver->name)) |
|---|
| 280 | | - return minor->dev; |
|---|
| 281 | | - } |
|---|
| 282 | | - |
|---|
| 283 | | - return NULL; |
|---|
| 284 | | -} |
|---|
| 285 | | - |
|---|
| 286 | 239 | /** |
|---|
| 287 | 240 | * DOC: driver instance overview |
|---|
| 288 | 241 | * |
|---|
| 289 | 242 | * A device instance for a drm driver is represented by &struct drm_device. This |
|---|
| 290 | | - * is allocated with drm_dev_alloc(), usually from bus-specific ->probe() |
|---|
| 291 | | - * callbacks implemented by the driver. The driver then needs to initialize all |
|---|
| 292 | | - * the various subsystems for the drm device like memory management, vblank |
|---|
| 293 | | - * handling, modesetting support and intial output configuration plus obviously |
|---|
| 294 | | - * initialize all the corresponding hardware bits. An important part of this is |
|---|
| 295 | | - * also calling drm_dev_set_unique() to set the userspace-visible unique name of |
|---|
| 296 | | - * this device instance. Finally when everything is up and running and ready for |
|---|
| 297 | | - * userspace the device instance can be published using drm_dev_register(). |
|---|
| 243 | + * is allocated and initialized with devm_drm_dev_alloc(), usually from |
|---|
| 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 |
|---|
| 246 | + * management, vblank handling, modesetting support and initial output |
|---|
| 247 | + * configuration plus obviously initialize all the corresponding hardware bits. |
|---|
| 248 | + * Finally when everything is up and running and ready for userspace the device |
|---|
| 249 | + * instance can be published using drm_dev_register(). |
|---|
| 298 | 250 | * |
|---|
| 299 | 251 | * There is also deprecated support for initalizing device instances using |
|---|
| 300 | 252 | * bus-specific helpers and the &drm_driver.load callback. But due to |
|---|
| .. | .. |
|---|
| 307 | 259 | * any other resources allocated at device initialization and drop the driver's |
|---|
| 308 | 260 | * reference to &drm_device using drm_dev_put(). |
|---|
| 309 | 261 | * |
|---|
| 310 | | - * Note that the lifetime rules for &drm_device instance has still a lot of |
|---|
| 311 | | - * historical baggage. Hence use the reference counting provided by |
|---|
| 312 | | - * drm_dev_get() and drm_dev_put() only carefully. |
|---|
| 262 | + * Note that any allocation or resource which is visible to userspace must be |
|---|
| 263 | + * released only when the final drm_dev_put() is called, and not when the |
|---|
| 264 | + * driver is unbound from the underlying physical struct &device. Best to use |
|---|
| 265 | + * &drm_device managed resources with drmm_add_action(), drmm_kmalloc() and |
|---|
| 266 | + * related functions. |
|---|
| 313 | 267 | * |
|---|
| 314 | | - * It is recommended that drivers embed &struct drm_device into their own device |
|---|
| 315 | | - * structure, which is supported through drm_dev_init(). |
|---|
| 268 | + * devres managed resources like devm_kmalloc() can only be used for resources |
|---|
| 269 | + * directly related to the underlying hardware device, and only used in code |
|---|
| 270 | + * paths fully protected by drm_dev_enter() and drm_dev_exit(). |
|---|
| 271 | + * |
|---|
| 272 | + * Display driver example |
|---|
| 273 | + * ~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 274 | + * |
|---|
| 275 | + * The following example shows a typical structure of a DRM display driver. |
|---|
| 276 | + * The example focus on the probe() function and the other functions that is |
|---|
| 277 | + * almost always present and serves as a demonstration of devm_drm_dev_alloc(). |
|---|
| 278 | + * |
|---|
| 279 | + * .. code-block:: c |
|---|
| 280 | + * |
|---|
| 281 | + * struct driver_device { |
|---|
| 282 | + * struct drm_device drm; |
|---|
| 283 | + * void *userspace_facing; |
|---|
| 284 | + * struct clk *pclk; |
|---|
| 285 | + * }; |
|---|
| 286 | + * |
|---|
| 287 | + * static struct drm_driver driver_drm_driver = { |
|---|
| 288 | + * [...] |
|---|
| 289 | + * }; |
|---|
| 290 | + * |
|---|
| 291 | + * static int driver_probe(struct platform_device *pdev) |
|---|
| 292 | + * { |
|---|
| 293 | + * struct driver_device *priv; |
|---|
| 294 | + * struct drm_device *drm; |
|---|
| 295 | + * int ret; |
|---|
| 296 | + * |
|---|
| 297 | + * priv = devm_drm_dev_alloc(&pdev->dev, &driver_drm_driver, |
|---|
| 298 | + * struct driver_device, drm); |
|---|
| 299 | + * if (IS_ERR(priv)) |
|---|
| 300 | + * return PTR_ERR(priv); |
|---|
| 301 | + * drm = &priv->drm; |
|---|
| 302 | + * |
|---|
| 303 | + * ret = drmm_mode_config_init(drm); |
|---|
| 304 | + * if (ret) |
|---|
| 305 | + * return ret; |
|---|
| 306 | + * |
|---|
| 307 | + * priv->userspace_facing = drmm_kzalloc(..., GFP_KERNEL); |
|---|
| 308 | + * if (!priv->userspace_facing) |
|---|
| 309 | + * return -ENOMEM; |
|---|
| 310 | + * |
|---|
| 311 | + * priv->pclk = devm_clk_get(dev, "PCLK"); |
|---|
| 312 | + * if (IS_ERR(priv->pclk)) |
|---|
| 313 | + * return PTR_ERR(priv->pclk); |
|---|
| 314 | + * |
|---|
| 315 | + * // Further setup, display pipeline etc |
|---|
| 316 | + * |
|---|
| 317 | + * platform_set_drvdata(pdev, drm); |
|---|
| 318 | + * |
|---|
| 319 | + * drm_mode_config_reset(drm); |
|---|
| 320 | + * |
|---|
| 321 | + * ret = drm_dev_register(drm); |
|---|
| 322 | + * if (ret) |
|---|
| 323 | + * return ret; |
|---|
| 324 | + * |
|---|
| 325 | + * drm_fbdev_generic_setup(drm, 32); |
|---|
| 326 | + * |
|---|
| 327 | + * return 0; |
|---|
| 328 | + * } |
|---|
| 329 | + * |
|---|
| 330 | + * // This function is called before the devm_ resources are released |
|---|
| 331 | + * static int driver_remove(struct platform_device *pdev) |
|---|
| 332 | + * { |
|---|
| 333 | + * struct drm_device *drm = platform_get_drvdata(pdev); |
|---|
| 334 | + * |
|---|
| 335 | + * drm_dev_unregister(drm); |
|---|
| 336 | + * drm_atomic_helper_shutdown(drm) |
|---|
| 337 | + * |
|---|
| 338 | + * return 0; |
|---|
| 339 | + * } |
|---|
| 340 | + * |
|---|
| 341 | + * // This function is called on kernel restart and shutdown |
|---|
| 342 | + * static void driver_shutdown(struct platform_device *pdev) |
|---|
| 343 | + * { |
|---|
| 344 | + * drm_atomic_helper_shutdown(platform_get_drvdata(pdev)); |
|---|
| 345 | + * } |
|---|
| 346 | + * |
|---|
| 347 | + * static int __maybe_unused driver_pm_suspend(struct device *dev) |
|---|
| 348 | + * { |
|---|
| 349 | + * return drm_mode_config_helper_suspend(dev_get_drvdata(dev)); |
|---|
| 350 | + * } |
|---|
| 351 | + * |
|---|
| 352 | + * static int __maybe_unused driver_pm_resume(struct device *dev) |
|---|
| 353 | + * { |
|---|
| 354 | + * drm_mode_config_helper_resume(dev_get_drvdata(dev)); |
|---|
| 355 | + * |
|---|
| 356 | + * return 0; |
|---|
| 357 | + * } |
|---|
| 358 | + * |
|---|
| 359 | + * static const struct dev_pm_ops driver_pm_ops = { |
|---|
| 360 | + * SET_SYSTEM_SLEEP_PM_OPS(driver_pm_suspend, driver_pm_resume) |
|---|
| 361 | + * }; |
|---|
| 362 | + * |
|---|
| 363 | + * static struct platform_driver driver_driver = { |
|---|
| 364 | + * .driver = { |
|---|
| 365 | + * [...] |
|---|
| 366 | + * .pm = &driver_pm_ops, |
|---|
| 367 | + * }, |
|---|
| 368 | + * .probe = driver_probe, |
|---|
| 369 | + * .remove = driver_remove, |
|---|
| 370 | + * .shutdown = driver_shutdown, |
|---|
| 371 | + * }; |
|---|
| 372 | + * module_platform_driver(driver_driver); |
|---|
| 373 | + * |
|---|
| 374 | + * Drivers that want to support device unplugging (USB, DT overlay unload) should |
|---|
| 375 | + * use drm_dev_unplug() instead of drm_dev_unregister(). The driver must protect |
|---|
| 376 | + * regions that is accessing device resources to prevent use after they're |
|---|
| 377 | + * released. This is done using drm_dev_enter() and drm_dev_exit(). There is one |
|---|
| 378 | + * shortcoming however, drm_dev_unplug() marks the drm_device as unplugged before |
|---|
| 379 | + * drm_atomic_helper_shutdown() is called. This means that if the disable code |
|---|
| 380 | + * paths are protected, they will not run on regular driver module unload, |
|---|
| 381 | + * possibily leaving the hardware enabled. |
|---|
| 316 | 382 | */ |
|---|
| 317 | 383 | |
|---|
| 318 | 384 | /** |
|---|
| .. | .. |
|---|
| 403 | 469 | synchronize_srcu(&drm_unplug_srcu); |
|---|
| 404 | 470 | |
|---|
| 405 | 471 | drm_dev_unregister(dev); |
|---|
| 406 | | - drm_dev_put(dev); |
|---|
| 407 | 472 | } |
|---|
| 408 | 473 | EXPORT_SYMBOL(drm_dev_unplug); |
|---|
| 409 | 474 | |
|---|
| .. | .. |
|---|
| 428 | 493 | static int drm_fs_cnt; |
|---|
| 429 | 494 | static struct vfsmount *drm_fs_mnt; |
|---|
| 430 | 495 | |
|---|
| 431 | | -static const struct dentry_operations drm_fs_dops = { |
|---|
| 432 | | - .d_dname = simple_dname, |
|---|
| 433 | | -}; |
|---|
| 434 | | - |
|---|
| 435 | | -static const struct super_operations drm_fs_sops = { |
|---|
| 436 | | - .statfs = simple_statfs, |
|---|
| 437 | | -}; |
|---|
| 438 | | - |
|---|
| 439 | | -static struct dentry *drm_fs_mount(struct file_system_type *fs_type, int flags, |
|---|
| 440 | | - const char *dev_name, void *data) |
|---|
| 496 | +static int drm_fs_init_fs_context(struct fs_context *fc) |
|---|
| 441 | 497 | { |
|---|
| 442 | | - return mount_pseudo(fs_type, |
|---|
| 443 | | - "drm:", |
|---|
| 444 | | - &drm_fs_sops, |
|---|
| 445 | | - &drm_fs_dops, |
|---|
| 446 | | - 0x010203ff); |
|---|
| 498 | + return init_pseudo(fc, 0x010203ff) ? 0 : -ENOMEM; |
|---|
| 447 | 499 | } |
|---|
| 448 | 500 | |
|---|
| 449 | 501 | static struct file_system_type drm_fs_type = { |
|---|
| 450 | 502 | .name = "drm", |
|---|
| 451 | 503 | .owner = THIS_MODULE, |
|---|
| 452 | | - .mount = drm_fs_mount, |
|---|
| 504 | + .init_fs_context = drm_fs_init_fs_context, |
|---|
| 453 | 505 | .kill_sb = kill_anon_super, |
|---|
| 454 | 506 | }; |
|---|
| 455 | 507 | |
|---|
| .. | .. |
|---|
| 480 | 532 | } |
|---|
| 481 | 533 | |
|---|
| 482 | 534 | /** |
|---|
| 483 | | - * drm_dev_init - Initialise new DRM device |
|---|
| 484 | | - * @dev: DRM device |
|---|
| 485 | | - * @driver: DRM driver |
|---|
| 486 | | - * @parent: Parent device object |
|---|
| 535 | + * DOC: component helper usage recommendations |
|---|
| 487 | 536 | * |
|---|
| 488 | | - * Initialize a new DRM device. No device registration is done. |
|---|
| 489 | | - * Call drm_dev_register() to advertice the device to user space and register it |
|---|
| 490 | | - * with other core subsystems. This should be done last in the device |
|---|
| 491 | | - * initialization sequence to make sure userspace can't access an inconsistent |
|---|
| 492 | | - * state. |
|---|
| 537 | + * DRM drivers that drive hardware where a logical device consists of a pile of |
|---|
| 538 | + * independent hardware blocks are recommended to use the :ref:`component helper |
|---|
| 539 | + * library<component>`. For consistency and better options for code reuse the |
|---|
| 540 | + * following guidelines apply: |
|---|
| 493 | 541 | * |
|---|
| 494 | | - * The initial ref-count of the object is 1. Use drm_dev_get() and |
|---|
| 495 | | - * drm_dev_put() to take and drop further ref-counts. |
|---|
| 542 | + * - The entire device initialization procedure should be run from the |
|---|
| 543 | + * &component_master_ops.master_bind callback, starting with |
|---|
| 544 | + * devm_drm_dev_alloc(), then binding all components with |
|---|
| 545 | + * component_bind_all() and finishing with drm_dev_register(). |
|---|
| 496 | 546 | * |
|---|
| 497 | | - * Note that for purely virtual devices @parent can be NULL. |
|---|
| 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 |
|---|
| 549 | + * specific private structure. |
|---|
| 498 | 550 | * |
|---|
| 499 | | - * Drivers that do not want to allocate their own device struct |
|---|
| 500 | | - * embedding &struct drm_device can call drm_dev_alloc() instead. For drivers |
|---|
| 501 | | - * that do embed &struct drm_device it must be placed first in the overall |
|---|
| 502 | | - * structure, and the overall structure must be allocated using kmalloc(): The |
|---|
| 503 | | - * drm core's release function unconditionally calls kfree() on the @dev pointer |
|---|
| 504 | | - * when the final reference is released. To override this behaviour, and so |
|---|
| 505 | | - * allow embedding of the drm_device inside the driver's device struct at an |
|---|
| 506 | | - * arbitrary offset, you must supply a &drm_driver.release callback and control |
|---|
| 507 | | - * the finalization explicitly. |
|---|
| 508 | | - * |
|---|
| 509 | | - * RETURNS: |
|---|
| 510 | | - * 0 on success, or error code on failure. |
|---|
| 551 | + * - The component helper fills the niche where further standardization of |
|---|
| 552 | + * interfaces is not practical. When there already is, or will be, a |
|---|
| 553 | + * standardized interface like &drm_bridge or &drm_panel, providing its own |
|---|
| 554 | + * functions to find such components at driver load time, like |
|---|
| 555 | + * drm_of_find_panel_or_bridge(), then the component helper should not be |
|---|
| 556 | + * used. |
|---|
| 511 | 557 | */ |
|---|
| 512 | | -int drm_dev_init(struct drm_device *dev, |
|---|
| 513 | | - struct drm_driver *driver, |
|---|
| 514 | | - struct device *parent) |
|---|
| 558 | + |
|---|
| 559 | +static void drm_dev_init_release(struct drm_device *dev, void *res) |
|---|
| 515 | 560 | { |
|---|
| 561 | + drm_legacy_ctxbitmap_cleanup(dev); |
|---|
| 562 | + drm_legacy_remove_map_hash(dev); |
|---|
| 563 | + drm_fs_inode_free(dev->anon_inode); |
|---|
| 564 | + |
|---|
| 565 | + put_device(dev->dev); |
|---|
| 566 | + /* Prevent use-after-free in drm_managed_release when debugging is |
|---|
| 567 | + * enabled. Slightly awkward, but can't really be helped. */ |
|---|
| 568 | + dev->dev = NULL; |
|---|
| 569 | + mutex_destroy(&dev->master_mutex); |
|---|
| 570 | + mutex_destroy(&dev->clientlist_mutex); |
|---|
| 571 | + mutex_destroy(&dev->filelist_mutex); |
|---|
| 572 | + mutex_destroy(&dev->struct_mutex); |
|---|
| 573 | + drm_legacy_destroy_members(dev); |
|---|
| 574 | +} |
|---|
| 575 | + |
|---|
| 576 | +static int drm_dev_init(struct drm_device *dev, |
|---|
| 577 | + struct drm_driver *driver, |
|---|
| 578 | + struct device *parent) |
|---|
| 579 | +{ |
|---|
| 580 | + struct inode *inode; |
|---|
| 516 | 581 | int ret; |
|---|
| 517 | 582 | |
|---|
| 518 | 583 | if (!drm_core_init_complete) { |
|---|
| .. | .. |
|---|
| 520 | 585 | return -ENODEV; |
|---|
| 521 | 586 | } |
|---|
| 522 | 587 | |
|---|
| 588 | + if (WARN_ON(!parent)) |
|---|
| 589 | + return -EINVAL; |
|---|
| 590 | + |
|---|
| 523 | 591 | kref_init(&dev->ref); |
|---|
| 524 | 592 | dev->dev = get_device(parent); |
|---|
| 525 | 593 | dev->driver = driver; |
|---|
| 526 | 594 | |
|---|
| 595 | + INIT_LIST_HEAD(&dev->managed.resources); |
|---|
| 596 | + spin_lock_init(&dev->managed.lock); |
|---|
| 597 | + |
|---|
| 598 | + /* no per-device feature limits by default */ |
|---|
| 599 | + dev->driver_features = ~0u; |
|---|
| 600 | + |
|---|
| 601 | + drm_legacy_init_members(dev); |
|---|
| 527 | 602 | INIT_LIST_HEAD(&dev->filelist); |
|---|
| 528 | 603 | INIT_LIST_HEAD(&dev->filelist_internal); |
|---|
| 529 | 604 | INIT_LIST_HEAD(&dev->clientlist); |
|---|
| 530 | | - INIT_LIST_HEAD(&dev->ctxlist); |
|---|
| 531 | | - INIT_LIST_HEAD(&dev->vmalist); |
|---|
| 532 | | - INIT_LIST_HEAD(&dev->maplist); |
|---|
| 533 | 605 | INIT_LIST_HEAD(&dev->vblank_event_list); |
|---|
| 534 | 606 | |
|---|
| 535 | | - spin_lock_init(&dev->buf_lock); |
|---|
| 536 | 607 | spin_lock_init(&dev->event_lock); |
|---|
| 537 | 608 | mutex_init(&dev->struct_mutex); |
|---|
| 538 | 609 | mutex_init(&dev->filelist_mutex); |
|---|
| 539 | 610 | mutex_init(&dev->clientlist_mutex); |
|---|
| 540 | | - mutex_init(&dev->ctxlist_mutex); |
|---|
| 541 | 611 | mutex_init(&dev->master_mutex); |
|---|
| 542 | 612 | |
|---|
| 543 | | - dev->anon_inode = drm_fs_inode_new(); |
|---|
| 544 | | - if (IS_ERR(dev->anon_inode)) { |
|---|
| 545 | | - ret = PTR_ERR(dev->anon_inode); |
|---|
| 613 | + ret = drmm_add_action_or_reset(dev, drm_dev_init_release, NULL); |
|---|
| 614 | + if (ret) |
|---|
| 615 | + return ret; |
|---|
| 616 | + |
|---|
| 617 | + inode = drm_fs_inode_new(); |
|---|
| 618 | + if (IS_ERR(inode)) { |
|---|
| 619 | + ret = PTR_ERR(inode); |
|---|
| 546 | 620 | DRM_ERROR("Cannot allocate anonymous inode: %d\n", ret); |
|---|
| 547 | | - goto err_free; |
|---|
| 621 | + goto err; |
|---|
| 548 | 622 | } |
|---|
| 623 | + |
|---|
| 624 | + dev->anon_inode = inode; |
|---|
| 549 | 625 | |
|---|
| 550 | 626 | if (drm_core_check_feature(dev, DRIVER_RENDER)) { |
|---|
| 551 | 627 | ret = drm_minor_alloc(dev, DRM_MINOR_RENDER); |
|---|
| 552 | 628 | if (ret) |
|---|
| 553 | | - goto err_minors; |
|---|
| 629 | + goto err; |
|---|
| 554 | 630 | } |
|---|
| 555 | 631 | |
|---|
| 556 | 632 | ret = drm_minor_alloc(dev, DRM_MINOR_PRIMARY); |
|---|
| 557 | 633 | if (ret) |
|---|
| 558 | | - goto err_minors; |
|---|
| 634 | + goto err; |
|---|
| 559 | 635 | |
|---|
| 560 | | - ret = drm_ht_create(&dev->map_hash, 12); |
|---|
| 636 | + ret = drm_legacy_create_map_hash(dev); |
|---|
| 561 | 637 | if (ret) |
|---|
| 562 | | - goto err_minors; |
|---|
| 638 | + goto err; |
|---|
| 563 | 639 | |
|---|
| 564 | 640 | drm_legacy_ctxbitmap_init(dev); |
|---|
| 565 | 641 | |
|---|
| .. | .. |
|---|
| 567 | 643 | ret = drm_gem_init(dev); |
|---|
| 568 | 644 | if (ret) { |
|---|
| 569 | 645 | DRM_ERROR("Cannot initialize graphics execution manager (GEM)\n"); |
|---|
| 570 | | - goto err_ctxbitmap; |
|---|
| 646 | + goto err; |
|---|
| 571 | 647 | } |
|---|
| 572 | 648 | } |
|---|
| 573 | 649 | |
|---|
| 574 | | - /* Use the parent device name as DRM device unique identifier, but fall |
|---|
| 575 | | - * back to the driver name for virtual devices like vgem. */ |
|---|
| 576 | | - ret = drm_dev_set_unique(dev, parent ? dev_name(parent) : driver->name); |
|---|
| 650 | + ret = drm_dev_set_unique(dev, dev_name(parent)); |
|---|
| 577 | 651 | if (ret) |
|---|
| 578 | | - goto err_setunique; |
|---|
| 652 | + goto err; |
|---|
| 579 | 653 | |
|---|
| 580 | 654 | return 0; |
|---|
| 581 | 655 | |
|---|
| 582 | | -err_setunique: |
|---|
| 583 | | - if (drm_core_check_feature(dev, DRIVER_GEM)) |
|---|
| 584 | | - drm_gem_destroy(dev); |
|---|
| 585 | | -err_ctxbitmap: |
|---|
| 586 | | - drm_legacy_ctxbitmap_cleanup(dev); |
|---|
| 587 | | - drm_ht_remove(&dev->map_hash); |
|---|
| 588 | | -err_minors: |
|---|
| 589 | | - drm_minor_free(dev, DRM_MINOR_PRIMARY); |
|---|
| 590 | | - drm_minor_free(dev, DRM_MINOR_RENDER); |
|---|
| 591 | | - drm_fs_inode_free(dev->anon_inode); |
|---|
| 592 | | -err_free: |
|---|
| 593 | | - put_device(dev->dev); |
|---|
| 594 | | - mutex_destroy(&dev->master_mutex); |
|---|
| 595 | | - mutex_destroy(&dev->ctxlist_mutex); |
|---|
| 596 | | - mutex_destroy(&dev->clientlist_mutex); |
|---|
| 597 | | - mutex_destroy(&dev->filelist_mutex); |
|---|
| 598 | | - mutex_destroy(&dev->struct_mutex); |
|---|
| 656 | +err: |
|---|
| 657 | + drm_managed_release(dev); |
|---|
| 658 | + |
|---|
| 599 | 659 | return ret; |
|---|
| 600 | 660 | } |
|---|
| 601 | | -EXPORT_SYMBOL(drm_dev_init); |
|---|
| 602 | 661 | |
|---|
| 603 | | -/** |
|---|
| 604 | | - * drm_dev_fini - Finalize a dead DRM device |
|---|
| 605 | | - * @dev: DRM device |
|---|
| 606 | | - * |
|---|
| 607 | | - * Finalize a dead DRM device. This is the converse to drm_dev_init() and |
|---|
| 608 | | - * frees up all data allocated by it. All driver private data should be |
|---|
| 609 | | - * finalized first. Note that this function does not free the @dev, that is |
|---|
| 610 | | - * left to the caller. |
|---|
| 611 | | - * |
|---|
| 612 | | - * The ref-count of @dev must be zero, and drm_dev_fini() should only be called |
|---|
| 613 | | - * from a &drm_driver.release callback. |
|---|
| 614 | | - */ |
|---|
| 615 | | -void drm_dev_fini(struct drm_device *dev) |
|---|
| 662 | +static void devm_drm_dev_init_release(void *data) |
|---|
| 616 | 663 | { |
|---|
| 617 | | - drm_vblank_cleanup(dev); |
|---|
| 618 | | - |
|---|
| 619 | | - if (drm_core_check_feature(dev, DRIVER_GEM)) |
|---|
| 620 | | - drm_gem_destroy(dev); |
|---|
| 621 | | - |
|---|
| 622 | | - drm_legacy_ctxbitmap_cleanup(dev); |
|---|
| 623 | | - drm_ht_remove(&dev->map_hash); |
|---|
| 624 | | - drm_fs_inode_free(dev->anon_inode); |
|---|
| 625 | | - |
|---|
| 626 | | - drm_minor_free(dev, DRM_MINOR_PRIMARY); |
|---|
| 627 | | - drm_minor_free(dev, DRM_MINOR_RENDER); |
|---|
| 628 | | - |
|---|
| 629 | | - put_device(dev->dev); |
|---|
| 630 | | - |
|---|
| 631 | | - mutex_destroy(&dev->master_mutex); |
|---|
| 632 | | - mutex_destroy(&dev->ctxlist_mutex); |
|---|
| 633 | | - mutex_destroy(&dev->clientlist_mutex); |
|---|
| 634 | | - mutex_destroy(&dev->filelist_mutex); |
|---|
| 635 | | - mutex_destroy(&dev->struct_mutex); |
|---|
| 636 | | - kfree(dev->unique); |
|---|
| 664 | + drm_dev_put(data); |
|---|
| 637 | 665 | } |
|---|
| 638 | | -EXPORT_SYMBOL(drm_dev_fini); |
|---|
| 666 | + |
|---|
| 667 | +static int devm_drm_dev_init(struct device *parent, |
|---|
| 668 | + struct drm_device *dev, |
|---|
| 669 | + struct drm_driver *driver) |
|---|
| 670 | +{ |
|---|
| 671 | + int ret; |
|---|
| 672 | + |
|---|
| 673 | + ret = drm_dev_init(dev, driver, parent); |
|---|
| 674 | + if (ret) |
|---|
| 675 | + return ret; |
|---|
| 676 | + |
|---|
| 677 | + ret = devm_add_action(parent, devm_drm_dev_init_release, dev); |
|---|
| 678 | + if (ret) |
|---|
| 679 | + devm_drm_dev_init_release(dev); |
|---|
| 680 | + |
|---|
| 681 | + return ret; |
|---|
| 682 | +} |
|---|
| 683 | + |
|---|
| 684 | +void *__devm_drm_dev_alloc(struct device *parent, struct drm_driver *driver, |
|---|
| 685 | + size_t size, size_t offset) |
|---|
| 686 | +{ |
|---|
| 687 | + void *container; |
|---|
| 688 | + struct drm_device *drm; |
|---|
| 689 | + int ret; |
|---|
| 690 | + |
|---|
| 691 | + container = kzalloc(size, GFP_KERNEL); |
|---|
| 692 | + if (!container) |
|---|
| 693 | + return ERR_PTR(-ENOMEM); |
|---|
| 694 | + |
|---|
| 695 | + drm = container + offset; |
|---|
| 696 | + ret = devm_drm_dev_init(parent, drm, driver); |
|---|
| 697 | + if (ret) { |
|---|
| 698 | + kfree(container); |
|---|
| 699 | + return ERR_PTR(ret); |
|---|
| 700 | + } |
|---|
| 701 | + drmm_add_final_kfree(drm, container); |
|---|
| 702 | + |
|---|
| 703 | + return container; |
|---|
| 704 | +} |
|---|
| 705 | +EXPORT_SYMBOL(__devm_drm_dev_alloc); |
|---|
| 639 | 706 | |
|---|
| 640 | 707 | /** |
|---|
| 641 | 708 | * drm_dev_alloc - Allocate new DRM device |
|---|
| 642 | 709 | * @driver: DRM driver to allocate device for |
|---|
| 643 | 710 | * @parent: Parent device object |
|---|
| 644 | 711 | * |
|---|
| 645 | | - * Allocate and initialize a new DRM device. No device registration is done. |
|---|
| 646 | | - * Call drm_dev_register() to advertice the device to user space and register it |
|---|
| 647 | | - * with other core subsystems. This should be done last in the device |
|---|
| 648 | | - * initialization sequence to make sure userspace can't access an inconsistent |
|---|
| 649 | | - * state. |
|---|
| 650 | | - * |
|---|
| 651 | | - * The initial ref-count of the object is 1. Use drm_dev_get() and |
|---|
| 652 | | - * drm_dev_put() to take and drop further ref-counts. |
|---|
| 653 | | - * |
|---|
| 654 | | - * Note that for purely virtual devices @parent can be NULL. |
|---|
| 655 | | - * |
|---|
| 656 | | - * Drivers that wish to subclass or embed &struct drm_device into their |
|---|
| 657 | | - * own struct should look at using drm_dev_init() instead. |
|---|
| 712 | + * This is the deprecated version of devm_drm_dev_alloc(), which does not support |
|---|
| 713 | + * subclassing through embedding the struct &drm_device in a driver private |
|---|
| 714 | + * structure, and which does not support automatic cleanup through devres. |
|---|
| 658 | 715 | * |
|---|
| 659 | 716 | * RETURNS: |
|---|
| 660 | 717 | * Pointer to new DRM device, or ERR_PTR on failure. |
|---|
| .. | .. |
|---|
| 675 | 732 | return ERR_PTR(ret); |
|---|
| 676 | 733 | } |
|---|
| 677 | 734 | |
|---|
| 735 | + drmm_add_final_kfree(dev, dev); |
|---|
| 736 | + |
|---|
| 678 | 737 | return dev; |
|---|
| 679 | 738 | } |
|---|
| 680 | 739 | EXPORT_SYMBOL(drm_dev_alloc); |
|---|
| .. | .. |
|---|
| 683 | 742 | { |
|---|
| 684 | 743 | struct drm_device *dev = container_of(ref, struct drm_device, ref); |
|---|
| 685 | 744 | |
|---|
| 686 | | - if (dev->driver->release) { |
|---|
| 745 | + if (dev->driver->release) |
|---|
| 687 | 746 | dev->driver->release(dev); |
|---|
| 688 | | - } else { |
|---|
| 689 | | - drm_dev_fini(dev); |
|---|
| 690 | | - kfree(dev); |
|---|
| 691 | | - } |
|---|
| 747 | + |
|---|
| 748 | + drm_managed_release(dev); |
|---|
| 749 | + |
|---|
| 750 | + kfree(dev->managed.final_kfree); |
|---|
| 692 | 751 | } |
|---|
| 693 | 752 | |
|---|
| 694 | 753 | /** |
|---|
| .. | .. |
|---|
| 723 | 782 | kref_put(&dev->ref, drm_dev_release); |
|---|
| 724 | 783 | } |
|---|
| 725 | 784 | EXPORT_SYMBOL(drm_dev_put); |
|---|
| 726 | | - |
|---|
| 727 | | -/** |
|---|
| 728 | | - * drm_dev_unref - Drop reference of a DRM device |
|---|
| 729 | | - * @dev: device to drop reference of or NULL |
|---|
| 730 | | - * |
|---|
| 731 | | - * This is a compatibility alias for drm_dev_put() and should not be used by new |
|---|
| 732 | | - * code. |
|---|
| 733 | | - */ |
|---|
| 734 | | -void drm_dev_unref(struct drm_device *dev) |
|---|
| 735 | | -{ |
|---|
| 736 | | - drm_dev_put(dev); |
|---|
| 737 | | -} |
|---|
| 738 | | -EXPORT_SYMBOL(drm_dev_unref); |
|---|
| 739 | 785 | |
|---|
| 740 | 786 | static int create_compat_control_link(struct drm_device *dev) |
|---|
| 741 | 787 | { |
|---|
| .. | .. |
|---|
| 799 | 845 | * @flags: Flags passed to the driver's .load() function |
|---|
| 800 | 846 | * |
|---|
| 801 | 847 | * Register the DRM device @dev with the system, advertise device to user-space |
|---|
| 802 | | - * and start normal device operation. @dev must be allocated via drm_dev_alloc() |
|---|
| 848 | + * and start normal device operation. @dev must be initialized via drm_dev_init() |
|---|
| 803 | 849 | * previously. |
|---|
| 804 | 850 | * |
|---|
| 805 | 851 | * Never call this twice on any device! |
|---|
| .. | .. |
|---|
| 818 | 864 | struct drm_driver *driver = dev->driver; |
|---|
| 819 | 865 | int ret; |
|---|
| 820 | 866 | |
|---|
| 821 | | - mutex_lock(&drm_global_mutex); |
|---|
| 867 | + if (!driver->load) |
|---|
| 868 | + drm_mode_config_validate(dev); |
|---|
| 869 | + |
|---|
| 870 | + WARN_ON(!dev->managed.final_kfree); |
|---|
| 871 | + |
|---|
| 872 | + if (drm_dev_needs_global_mutex(dev)) |
|---|
| 873 | + mutex_lock(&drm_global_mutex); |
|---|
| 822 | 874 | |
|---|
| 823 | 875 | ret = drm_minor_register(dev, DRM_MINOR_RENDER); |
|---|
| 824 | 876 | if (ret) |
|---|
| .. | .. |
|---|
| 858 | 910 | drm_minor_unregister(dev, DRM_MINOR_PRIMARY); |
|---|
| 859 | 911 | drm_minor_unregister(dev, DRM_MINOR_RENDER); |
|---|
| 860 | 912 | out_unlock: |
|---|
| 861 | | - mutex_unlock(&drm_global_mutex); |
|---|
| 913 | + if (drm_dev_needs_global_mutex(dev)) |
|---|
| 914 | + mutex_unlock(&drm_global_mutex); |
|---|
| 862 | 915 | return ret; |
|---|
| 863 | 916 | } |
|---|
| 864 | 917 | EXPORT_SYMBOL(drm_dev_register); |
|---|
| .. | .. |
|---|
| 879 | 932 | */ |
|---|
| 880 | 933 | void drm_dev_unregister(struct drm_device *dev) |
|---|
| 881 | 934 | { |
|---|
| 882 | | - struct drm_map_list *r_list, *list_temp; |
|---|
| 883 | | - |
|---|
| 884 | 935 | if (drm_core_check_feature(dev, DRIVER_LEGACY)) |
|---|
| 885 | 936 | drm_lastclose(dev); |
|---|
| 886 | 937 | |
|---|
| .. | .. |
|---|
| 897 | 948 | if (dev->agp) |
|---|
| 898 | 949 | drm_pci_agp_destroy(dev); |
|---|
| 899 | 950 | |
|---|
| 900 | | - list_for_each_entry_safe(r_list, list_temp, &dev->maplist, head) |
|---|
| 901 | | - drm_legacy_rmmap(dev, r_list->map); |
|---|
| 951 | + drm_legacy_rmmaps(dev); |
|---|
| 902 | 952 | |
|---|
| 903 | 953 | remove_compat_control_link(dev); |
|---|
| 904 | 954 | drm_minor_unregister(dev, DRM_MINOR_PRIMARY); |
|---|
| .. | .. |
|---|
| 911 | 961 | * @dev: device of which to set the unique name |
|---|
| 912 | 962 | * @name: unique name |
|---|
| 913 | 963 | * |
|---|
| 914 | | - * Sets the unique name of a DRM device using the specified string. Drivers |
|---|
| 915 | | - * can use this at driver probe time if the unique name of the devices they |
|---|
| 916 | | - * drive is static. |
|---|
| 964 | + * Sets the unique name of a DRM device using the specified string. This is |
|---|
| 965 | + * already done by drm_dev_init(), drivers should only override the default |
|---|
| 966 | + * unique name for backwards compatibility reasons. |
|---|
| 917 | 967 | * |
|---|
| 918 | 968 | * Return: 0 on success or a negative error code on failure. |
|---|
| 919 | 969 | */ |
|---|
| 920 | 970 | int drm_dev_set_unique(struct drm_device *dev, const char *name) |
|---|
| 921 | 971 | { |
|---|
| 922 | | - kfree(dev->unique); |
|---|
| 923 | | - dev->unique = kstrdup(name, GFP_KERNEL); |
|---|
| 972 | + drmm_kfree(dev, dev->unique); |
|---|
| 973 | + dev->unique = drmm_kstrdup(dev, name, GFP_KERNEL); |
|---|
| 924 | 974 | |
|---|
| 925 | 975 | return dev->unique ? 0 : -ENOMEM; |
|---|
| 926 | 976 | } |
|---|
| .. | .. |
|---|
| 954 | 1004 | |
|---|
| 955 | 1005 | DRM_DEBUG("\n"); |
|---|
| 956 | 1006 | |
|---|
| 957 | | - mutex_lock(&drm_global_mutex); |
|---|
| 958 | 1007 | minor = drm_minor_acquire(iminor(inode)); |
|---|
| 959 | | - if (IS_ERR(minor)) { |
|---|
| 960 | | - err = PTR_ERR(minor); |
|---|
| 961 | | - goto out_unlock; |
|---|
| 962 | | - } |
|---|
| 1008 | + if (IS_ERR(minor)) |
|---|
| 1009 | + return PTR_ERR(minor); |
|---|
| 963 | 1010 | |
|---|
| 964 | 1011 | new_fops = fops_get(minor->dev->driver->fops); |
|---|
| 965 | 1012 | if (!new_fops) { |
|---|
| 966 | 1013 | err = -ENODEV; |
|---|
| 967 | | - goto out_release; |
|---|
| 1014 | + goto out; |
|---|
| 968 | 1015 | } |
|---|
| 969 | 1016 | |
|---|
| 970 | 1017 | replace_fops(filp, new_fops); |
|---|
| .. | .. |
|---|
| 973 | 1020 | else |
|---|
| 974 | 1021 | err = 0; |
|---|
| 975 | 1022 | |
|---|
| 976 | | -out_release: |
|---|
| 1023 | +out: |
|---|
| 977 | 1024 | drm_minor_release(minor); |
|---|
| 978 | | -out_unlock: |
|---|
| 979 | | - mutex_unlock(&drm_global_mutex); |
|---|
| 1025 | + |
|---|
| 980 | 1026 | return err; |
|---|
| 981 | 1027 | } |
|---|
| 982 | 1028 | |
|---|
| .. | .. |
|---|
| 993 | 1039 | drm_sysfs_destroy(); |
|---|
| 994 | 1040 | idr_destroy(&drm_minors_idr); |
|---|
| 995 | 1041 | drm_connector_ida_destroy(); |
|---|
| 996 | | - drm_global_release(); |
|---|
| 997 | 1042 | } |
|---|
| 998 | 1043 | |
|---|
| 999 | 1044 | static int __init drm_core_init(void) |
|---|
| 1000 | 1045 | { |
|---|
| 1001 | 1046 | int ret; |
|---|
| 1002 | 1047 | |
|---|
| 1003 | | - drm_global_init(); |
|---|
| 1004 | 1048 | drm_connector_ida_init(); |
|---|
| 1005 | 1049 | idr_init(&drm_minors_idr); |
|---|
| 1006 | 1050 | |
|---|
| .. | .. |
|---|
| 1011 | 1055 | } |
|---|
| 1012 | 1056 | |
|---|
| 1013 | 1057 | drm_debugfs_root = debugfs_create_dir("dri", NULL); |
|---|
| 1014 | | - if (!drm_debugfs_root) { |
|---|
| 1015 | | - ret = -ENOMEM; |
|---|
| 1016 | | - DRM_ERROR("Cannot create debugfs-root: %d\n", ret); |
|---|
| 1017 | | - goto error; |
|---|
| 1018 | | - } |
|---|
| 1019 | 1058 | |
|---|
| 1020 | 1059 | ret = register_chrdev(DRM_MAJOR, "drm", &drm_stub_fops); |
|---|
| 1021 | 1060 | if (ret < 0) |
|---|
| .. | .. |
|---|
| 1031 | 1070 | return ret; |
|---|
| 1032 | 1071 | } |
|---|
| 1033 | 1072 | |
|---|
| 1034 | | -#ifdef CONFIG_ROCKCHIP_THUNDER_BOOT |
|---|
| 1035 | | -subsys_initcall(drm_core_init); |
|---|
| 1073 | +#ifdef CONFIG_VIDEO_REVERSE_IMAGE |
|---|
| 1074 | +fs_initcall(drm_core_init); |
|---|
| 1036 | 1075 | #else |
|---|
| 1037 | 1076 | module_init(drm_core_init); |
|---|
| 1038 | 1077 | #endif |
|---|