Skip to content
Permalink
Browse files
drm/nouveau/kms: switch hpd_lock from mutex to spinlock
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>
  • Loading branch information
skeggsb committed Oct 12, 2021
1 parent 82883eb commit 9ab6dbfd169dd7c2329b2d8aeee09926c49d3280
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
@@ -1151,13 +1151,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
@@ -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);
@@ -767,7 +767,6 @@ nouveau_display_destroy(struct drm_device *dev)
nvif_disp_dtor(&disp->disp);

nouveau_drm(dev)->display = NULL;
mutex_destroy(&drm->hpd_lock);
kfree(disp);
}

@@ -196,7 +196,7 @@ struct nouveau_drm {
struct nvbios vbios;
struct nouveau_display *display;
struct work_struct hpd_work;
struct mutex hpd_lock;
struct spinlock hpd_lock;
u32 hpd_pending;
struct work_struct fbcon_work;
int fbcon_new_state;

0 comments on commit 9ab6dbf

Please sign in to comment.