dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] gpu: host1x: Detach driver on unregister
@ 2020-04-08 17:38 Thierry Reding
  2020-04-09 16:02 ` Sowjanya Komatineni
  0 siblings, 1 reply; 2+ messages in thread
From: Thierry Reding @ 2020-04-08 17:38 UTC (permalink / raw)
  To: Thierry Reding; +Cc: linux-tegra, Sowjanya Komatineni, dri-devel

From: Thierry Reding <treding@nvidia.com>

Currently when a host1x device driver is unregistered, it is not
detached from the host1x controller, which means that the device
will stay around and when the driver is registered again, it may
bind to the old, stale device rather than the new one that was
created from scratch upon driver registration. This in turn can
cause various weird crashes within the driver core because it is
confronted with a device that was already deleted.

Fix this by detaching the driver from the host1x controller when
it is unregistered. This ensures that the deleted device also is
no longer present in the device list that drivers will bind to.

Reported-by: Sowjanya Komatineni <skomatineni@nvidia.com>
Signed-off-by: Thierry Reding <treding@nvidia.com>
---
 drivers/gpu/host1x/bus.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/gpu/host1x/bus.c b/drivers/gpu/host1x/bus.c
index 6a995db51d6d..e201f62d62c0 100644
--- a/drivers/gpu/host1x/bus.c
+++ b/drivers/gpu/host1x/bus.c
@@ -686,8 +686,17 @@ EXPORT_SYMBOL(host1x_driver_register_full);
  */
 void host1x_driver_unregister(struct host1x_driver *driver)
 {
+	struct host1x *host1x;
+
 	driver_unregister(&driver->driver);
 
+	mutex_lock(&devices_lock);
+
+	list_for_each_entry(host1x, &devices, list)
+		host1x_detach_driver(host1x, driver);
+
+	mutex_unlock(&devices_lock);
+
 	mutex_lock(&drivers_lock);
 	list_del_init(&driver->list);
 	mutex_unlock(&drivers_lock);
-- 
2.24.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] gpu: host1x: Detach driver on unregister
  2020-04-08 17:38 [PATCH] gpu: host1x: Detach driver on unregister Thierry Reding
@ 2020-04-09 16:02 ` Sowjanya Komatineni
  0 siblings, 0 replies; 2+ messages in thread
From: Sowjanya Komatineni @ 2020-04-09 16:02 UTC (permalink / raw)
  To: Thierry Reding; +Cc: linux-tegra, dri-devel


On 4/8/20 10:38 AM, Thierry Reding wrote:
> From: Thierry Reding<treding@nvidia.com>
>
> Currently when a host1x device driver is unregistered, it is not
> detached from the host1x controller, which means that the device
> will stay around and when the driver is registered again, it may
> bind to the old, stale device rather than the new one that was
> created from scratch upon driver registration. This in turn can
> cause various weird crashes within the driver core because it is
> confronted with a device that was already deleted.
>
> Fix this by detaching the driver from the host1x controller when
> it is unregistered. This ensures that the deleted device also is
> no longer present in the device list that drivers will bind to.
>
> Reported-by: Sowjanya Komatineni<skomatineni@nvidia.com>
> Signed-off-by: Thierry Reding<treding@nvidia.com>
> ---

Tested-by: Sowjanya Komatineni <skomatineni@nvidia.com>


_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-04-10  9:45 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-08 17:38 [PATCH] gpu: host1x: Detach driver on unregister Thierry Reding
2020-04-09 16:02 ` Sowjanya Komatineni

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).