[PATCH 1/3] drm: No warn for drivers who provide release

Luben Tuikov luben.tuikov at amd.com
Wed Sep 2 01:06:43 UTC 2020


Drivers usually allocate their container
struct at PCI probe time, then call drm_dev_init(),
which initializes the contained DRM dev kref to 1.

A DRM driver may provide their own kref
release method, which frees the container
object, the container of the DRM device,
on the last "put" which usually comes
after the PCI device has been freed
with PCI and with DRM.

If a driver has provided their own "release"
method in the drm_driver structure, then
do not check "managed.final_kfree", and thus
do not splat a WARN_ON in the kernel log
when a driver which implements "release"
is loaded.

This patch adds this one-line check.

Signed-off-by: Luben Tuikov <luben.tuikov at amd.com>
---
 drivers/gpu/drm/drm_drv.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
index 13068fdf4331..952455dedb8c 100644
--- a/drivers/gpu/drm/drm_drv.c
+++ b/drivers/gpu/drm/drm_drv.c
@@ -935,7 +935,8 @@ int drm_dev_register(struct drm_device *dev, unsigned long flags)
 	if (!driver->load)
 		drm_mode_config_validate(dev);
 
-	WARN_ON(!dev->managed.final_kfree);
+	if (!driver->release)
+		WARN_ON(!dev->managed.final_kfree);
 
 	if (drm_dev_needs_global_mutex(dev))
 		mutex_lock(&drm_global_mutex);
-- 
2.28.0.394.ge197136389



More information about the dri-devel mailing list