From 78cb2532be3115ceffb7b842509a0eb79206ec82 Mon Sep 17 00:00:00 2001
From: Mark Kettenis <kettenis@cvs.openbsd.org>
Date: Fri, 5 Jul 2019 12:10:11 +0000
Subject: Use multi-threaded task queues to prevent deadlocks in the case where
 a tasks sleeps and expects to be woken up by a task that will be submitted to
 the same task queue.  That scenario happens in the output hotplug code.

We probably should spend some time on tuning the number of threads but
let's make things work correctly first.

Based on some serious debugging done by Sven M. Hallberg.

ok jsg@
---
 sys/dev/pci/drm/drm_linux.c          | 8 ++++----
 sys/dev/pci/drm/i915/intel_hotplug.c | 1 -
 2 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/sys/dev/pci/drm/drm_linux.c b/sys/dev/pci/drm/drm_linux.c
index 0b86912cb72..1c5405071ca 100644
--- a/sys/dev/pci/drm/drm_linux.c
+++ b/sys/dev/pci/drm/drm_linux.c
@@ -1,4 +1,4 @@
-/*	$OpenBSD: drm_linux.c,v 1.38 2019/06/09 12:58:30 kettenis Exp $	*/
+/*	$OpenBSD: drm_linux.c,v 1.39 2019/07/05 12:10:10 kettenis Exp $	*/
 /*
  * Copyright (c) 2013 Jonathan Gray <jsg@openbsd.org>
  * Copyright (c) 2015, 2016 Mark Kettenis <kettenis@openbsd.org>
@@ -1399,15 +1399,15 @@ drm_linux_init(void)
 {
 	if (system_wq == NULL) {
 		system_wq = (struct workqueue_struct *)
-		    taskq_create("drmwq", 1, IPL_HIGH, 0);
+		    taskq_create("drmwq", 4, IPL_HIGH, 0);
 	}
 	if (system_unbound_wq == NULL) {
 		system_unbound_wq = (struct workqueue_struct *)
-		    taskq_create("drmubwq", 1, IPL_HIGH, 0);
+		    taskq_create("drmubwq", 4, IPL_HIGH, 0);
 	}
 	if (system_long_wq == NULL) {
 		system_long_wq = (struct workqueue_struct *)
-		    taskq_create("drmlwq", 1, IPL_HIGH, 0);
+		    taskq_create("drmlwq", 4, IPL_HIGH, 0);
 	}
 
 	if (taskletq == NULL)
diff --git a/sys/dev/pci/drm/i915/intel_hotplug.c b/sys/dev/pci/drm/i915/intel_hotplug.c
index 0ed2bad1348..9a801813023 100644
--- a/sys/dev/pci/drm/i915/intel_hotplug.c
+++ b/sys/dev/pci/drm/i915/intel_hotplug.c
@@ -619,7 +619,6 @@ void intel_hpd_init_work(struct drm_i915_private *dev_priv)
 	INIT_WORK(&dev_priv->hotplug.hotplug_work, i915_hotplug_work_func);
 	INIT_WORK(&dev_priv->hotplug.dig_port_work, i915_digport_work_func);
 	INIT_WORK(&dev_priv->hotplug.poll_init_work, i915_hpd_poll_init_work);
-	dev_priv->hotplug.poll_init_work.tq = systq;
 	INIT_DELAYED_WORK(&dev_priv->hotplug.reenable_work,
 			  intel_hpd_irq_storm_reenable_work);
 }
-- 
cgit v1.2.3