OSDN Git Service

drm/nouveau/kms: switch hpd_lock from mutex to spinlock
authorBen Skeggs <bskeggs@redhat.com>
Wed, 1 Jun 2022 10:46:34 +0000 (20:46 +1000)
committerBen Skeggs <bskeggs@redhat.com>
Wed, 9 Nov 2022 00:43:09 +0000 (10:43 +1000)
There's no good reason for this to be a mutex, and once the layers of
workqueues have been untangled, nouveau_connector_hpd() can be called
from IRQ context and won't be able to take a mutex.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
Reviewed-by: Lyude Paul <lyude@redhat.com>
drivers/gpu/drm/nouveau/nouveau_connector.c
drivers/gpu/drm/nouveau/nouveau_display.c
drivers/gpu/drm/nouveau/nouveau_drv.h

index 1991bbb..c2ff8e9 100644 (file)
@@ -1166,13 +1166,14 @@ nouveau_connector_hpd(struct drm_connector *connector)
 {
        struct nouveau_drm *drm = nouveau_drm(connector->dev);
        u32 mask = drm_connector_mask(connector);
+       unsigned long flags;
 
-       mutex_lock(&drm->hpd_lock);
+       spin_lock_irqsave(&drm->hpd_lock, flags);
        if (!(drm->hpd_pending & mask)) {
                drm->hpd_pending |= mask;
                schedule_work(&drm->hpd_work);
        }
-       mutex_unlock(&drm->hpd_lock);
+       spin_unlock_irqrestore(&drm->hpd_lock, flags);
 }
 
 static int
index 2e97186..fb22ebe 100644 (file)
@@ -456,9 +456,9 @@ nouveau_display_hpd_resume(struct drm_device *dev)
 {
        struct nouveau_drm *drm = nouveau_drm(dev);
 
-       mutex_lock(&drm->hpd_lock);
+       spin_lock_irq(&drm->hpd_lock);
        drm->hpd_pending = ~0;
-       mutex_unlock(&drm->hpd_lock);
+       spin_unlock_irq(&drm->hpd_lock);
 
        schedule_work(&drm->hpd_work);
 }
@@ -475,10 +475,10 @@ nouveau_display_hpd_work(struct work_struct *work)
 
        pm_runtime_get_sync(dev->dev);
 
-       mutex_lock(&drm->hpd_lock);
+       spin_lock_irq(&drm->hpd_lock);
        pending = drm->hpd_pending;
        drm->hpd_pending = 0;
-       mutex_unlock(&drm->hpd_lock);
+       spin_unlock_irq(&drm->hpd_lock);
 
        /* Nothing to do, exit early without updating the last busy counter */
        if (!pending)
@@ -732,7 +732,7 @@ nouveau_display_create(struct drm_device *dev)
        }
 
        INIT_WORK(&drm->hpd_work, nouveau_display_hpd_work);
-       mutex_init(&drm->hpd_lock);
+       spin_lock_init(&drm->hpd_lock);
 #ifdef CONFIG_ACPI
        drm->acpi_nb.notifier_call = nouveau_display_acpi_ntfy;
        register_acpi_notifier(&drm->acpi_nb);
@@ -766,8 +766,7 @@ nouveau_display_destroy(struct drm_device *dev)
 
        nvif_disp_dtor(&disp->disp);
 
-       nouveau_drm(dev)->display = NULL;
-       mutex_destroy(&drm->hpd_lock);
+       drm->display = NULL;
        kfree(disp);
 }
 
index 84df5dd..1a92c98 100644 (file)
@@ -201,7 +201,7 @@ struct nouveau_drm {
        struct nvbios vbios;
        struct nouveau_display *display;
        struct work_struct hpd_work;
-       struct mutex hpd_lock;
+       spinlock_t hpd_lock;
        u32 hpd_pending;
        struct work_struct fbcon_work;
        int fbcon_new_state;