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.tui...@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

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

Reply via email to