Commit d62f8e98 authored by Ben Skeggs's avatar Ben Skeggs
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: default avatarBen Skeggs <bskeggs@redhat.com>
Reviewed-by: default avatarLyude Paul <lyude@redhat.com>
parent a62b7493
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -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
+6 −7
Original line number Diff line number Diff line
@@ -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);
}

+1 −1
Original line number Diff line number Diff line
@@ -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;