You've already forked linux-rockchip
mirror of
https://github.com/armbian/linux-rockchip.git
synced 2026-01-06 11:08:10 -08:00
drm/nouveau: Add a dedicated mutex for the clients list
commit abae9164a4 upstream.
Rather than protecting the nouveau_drm clients list with the lock within
the "client" nouveau_cli, add a dedicated lock to serialize access to
the list. This is both clearer and necessary to avoid lockdep being
upset with us when we need to iterate through all the clients in the
list and potentially lock their mutex, which is the same class as the
lock protecting the entire list.
Cc: stable@vger.kernel.org # 5.4+
Signed-off-by: Jeremy Cline <jcline@redhat.com>
Reviewed-by: Lyude Paul <lyude@redhat.com>
Reviewed-by: Ben Skeggs <bskeggs@redhat.com>
Tested-by: Karol Herbst <kherbst@redhat.com>
Signed-off-by: Karol Herbst <kherbst@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20201125202648.5220-3-jcline@redhat.com
Link: https://gitlab.freedesktop.org/drm/nouveau/-/merge_requests/14
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
65517975cb
commit
9221aff33e
@@ -557,6 +557,7 @@ nouveau_drm_device_init(struct drm_device *dev)
|
||||
nvkm_dbgopt(nouveau_debug, "DRM");
|
||||
|
||||
INIT_LIST_HEAD(&drm->clients);
|
||||
mutex_init(&drm->clients_lock);
|
||||
spin_lock_init(&drm->tile.lock);
|
||||
|
||||
/* workaround an odd issue on nvc1 by disabling the device's
|
||||
@@ -654,6 +655,7 @@ nouveau_drm_device_fini(struct drm_device *dev)
|
||||
nouveau_cli_fini(&drm->client);
|
||||
nouveau_cli_fini(&drm->master);
|
||||
nvif_parent_dtor(&drm->parent);
|
||||
mutex_destroy(&drm->clients_lock);
|
||||
kfree(drm);
|
||||
}
|
||||
|
||||
@@ -1086,9 +1088,9 @@ nouveau_drm_open(struct drm_device *dev, struct drm_file *fpriv)
|
||||
|
||||
fpriv->driver_priv = cli;
|
||||
|
||||
mutex_lock(&drm->client.mutex);
|
||||
mutex_lock(&drm->clients_lock);
|
||||
list_add(&cli->head, &drm->clients);
|
||||
mutex_unlock(&drm->client.mutex);
|
||||
mutex_unlock(&drm->clients_lock);
|
||||
|
||||
done:
|
||||
if (ret && cli) {
|
||||
@@ -1114,9 +1116,9 @@ nouveau_drm_postclose(struct drm_device *dev, struct drm_file *fpriv)
|
||||
nouveau_abi16_fini(cli->abi16);
|
||||
mutex_unlock(&cli->mutex);
|
||||
|
||||
mutex_lock(&drm->client.mutex);
|
||||
mutex_lock(&drm->clients_lock);
|
||||
list_del(&cli->head);
|
||||
mutex_unlock(&drm->client.mutex);
|
||||
mutex_unlock(&drm->clients_lock);
|
||||
|
||||
nouveau_cli_fini(cli);
|
||||
kfree(cli);
|
||||
|
||||
@@ -142,6 +142,11 @@ struct nouveau_drm {
|
||||
|
||||
struct list_head clients;
|
||||
|
||||
/**
|
||||
* @clients_lock: Protects access to the @clients list of &struct nouveau_cli.
|
||||
*/
|
||||
struct mutex clients_lock;
|
||||
|
||||
u8 old_pm_cap;
|
||||
|
||||
struct {
|
||||
|
||||
Reference in New Issue
Block a user