[PATCH v2] gpu/drm/bridge/cadence: avoid flush_scheduled_work() usage

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Use local wq in order to avoid flush_scheduled_work() usage.

Signed-off-by: Tetsuo Handa <penguin-kernel@xxxxxxxxxxxxxxxxxxx>
---
Changes in v2:
  Replace flush_scheduled_work() with flush_workqueue().

Please see commit c4f135d643823a86 ("workqueue: Wrap flush_workqueue()
using a macro") for background.

This is a blind conversion, and is only compile tested.

 .../drm/bridge/cadence/cdns-mhdp8546-core.c   | 32 ++++++++++++++++---
 .../drm/bridge/cadence/cdns-mhdp8546-core.h   |  2 ++
 .../drm/bridge/cadence/cdns-mhdp8546-hdcp.c   | 16 +++++-----
 3 files changed, 37 insertions(+), 13 deletions(-)

diff --git a/drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c b/drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c
index 67f0f444b4e8..f29c9484d4bb 100644
--- a/drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c
+++ b/drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c
@@ -53,6 +53,8 @@
 #include "cdns-mhdp8546-hdcp.h"
 #include "cdns-mhdp8546-j721e.h"
 
+struct workqueue_struct *cadence_mhdp_wq;
+
 static int cdns_mhdp_mailbox_read(struct cdns_mhdp_device *mhdp)
 {
 	int ret, empty;
@@ -2049,7 +2051,7 @@ static void cdns_mhdp_atomic_enable(struct drm_bridge *bridge,
 out:
 	mutex_unlock(&mhdp->link_mutex);
 	if (ret < 0)
-		schedule_work(&mhdp->modeset_retry_work);
+		queue_work(cadence_mhdp_wq, &mhdp->modeset_retry_work);
 }
 
 static void cdns_mhdp_atomic_disable(struct drm_bridge *bridge,
@@ -2373,7 +2375,7 @@ static irqreturn_t cdns_mhdp_irq_handler(int irq, void *data)
 	spin_unlock(&mhdp->start_lock);
 
 	if (bridge_attached && (sw_ev0 & CDNS_DPTX_HPD)) {
-		schedule_work(&mhdp->hpd_work);
+		queue_work(cadence_mhdp_wq, &mhdp->hpd_work);
 	}
 
 	if (sw_ev0 & ~CDNS_DPTX_HPD) {
@@ -2413,7 +2415,7 @@ static void cdns_mhdp_hpd_work(struct work_struct *work)
 	ret = cdns_mhdp_update_link_status(mhdp);
 	if (mhdp->connector.dev) {
 		if (ret < 0)
-			schedule_work(&mhdp->modeset_retry_work);
+			queue_work(cadence_mhdp_wq, &mhdp->modeset_retry_work);
 		else
 			drm_kms_helper_hotplug_event(mhdp->bridge.dev);
 	} else {
@@ -2603,7 +2605,7 @@ static int cdns_mhdp_remove(struct platform_device *pdev)
 	pm_runtime_disable(&pdev->dev);
 
 	cancel_work_sync(&mhdp->modeset_retry_work);
-	flush_scheduled_work();
+	flush_workqueue(cadence_mhdp_wq);
 
 	clk_disable_unprepare(mhdp->clk);
 
@@ -2632,7 +2634,27 @@ static struct platform_driver mhdp_driver = {
 	.probe	= cdns_mhdp_probe,
 	.remove	= cdns_mhdp_remove,
 };
-module_platform_driver(mhdp_driver);
+
+static int __init mhdp_init(void)
+{
+	int ret;
+
+	cadence_mhdp_wq = alloc_workqueue("cadence_mhdp_wq", 0, 0);
+	if (!cadence_mhdp_wq)
+		return -ENOMEM;
+	ret = platform_driver_register(&mhdp_driver);
+	if (ret)
+		destroy_workqueue(cadence_mhdp_wq);
+	return ret;
+}
+module_init(mhdp_init);
+
+static void __exit mhdp_exit(void)
+{
+	platform_driver_unregister(&mhdp_driver);
+	destroy_workqueue(cadence_mhdp_wq);
+}
+module_exit(mhdp_exit);
 
 MODULE_FIRMWARE(FW_NAME);
 
diff --git a/drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.h b/drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.h
index bedddd510d17..e6c475612480 100644
--- a/drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.h
+++ b/drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.h
@@ -419,4 +419,6 @@ struct cdns_mhdp_device {
 
 u32 cdns_mhdp_wait_for_sw_event(struct cdns_mhdp_device *mhdp, uint32_t event);
 
+extern struct workqueue_struct *cadence_mhdp_wq;
+
 #endif
diff --git a/drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-hdcp.c b/drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-hdcp.c
index 946212a95598..09f9e3d42f11 100644
--- a/drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-hdcp.c
+++ b/drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-hdcp.c
@@ -449,14 +449,14 @@ static int cdns_mhdp_hdcp_check_link(struct cdns_mhdp_device *mhdp)
 	ret = _cdns_mhdp_hdcp_disable(mhdp);
 	if (ret) {
 		mhdp->hdcp.value = DRM_MODE_CONTENT_PROTECTION_DESIRED;
-		schedule_work(&mhdp->hdcp.prop_work);
+		queue_work(cadence_mhdp_wq, &mhdp->hdcp.prop_work);
 		goto out;
 	}
 
 	ret = _cdns_mhdp_hdcp_enable(mhdp, mhdp->hdcp.hdcp_content_type);
 	if (ret) {
 		mhdp->hdcp.value = DRM_MODE_CONTENT_PROTECTION_DESIRED;
-		schedule_work(&mhdp->hdcp.prop_work);
+		queue_work(cadence_mhdp_wq, &mhdp->hdcp.prop_work);
 	}
 out:
 	mutex_unlock(&mhdp->hdcp.mutex);
@@ -474,8 +474,8 @@ static void cdns_mhdp_hdcp_check_work(struct work_struct *work)
 						     hdcp);
 
 	if (!cdns_mhdp_hdcp_check_link(mhdp))
-		schedule_delayed_work(&hdcp->check_work,
-				      DRM_HDCP_CHECK_PERIOD_MS);
+		queue_delayed_work(cadence_mhdp_wq, &hdcp->check_work,
+				   DRM_HDCP_CHECK_PERIOD_MS);
 }
 
 static void cdns_mhdp_hdcp_prop_work(struct work_struct *work)
@@ -538,9 +538,9 @@ int cdns_mhdp_hdcp_enable(struct cdns_mhdp_device *mhdp, u8 content_type)
 
 	mhdp->hdcp.hdcp_content_type = content_type;
 	mhdp->hdcp.value = DRM_MODE_CONTENT_PROTECTION_ENABLED;
-	schedule_work(&mhdp->hdcp.prop_work);
-	schedule_delayed_work(&mhdp->hdcp.check_work,
-			      DRM_HDCP_CHECK_PERIOD_MS);
+	queue_work(cadence_mhdp_wq, &mhdp->hdcp.prop_work);
+	queue_delayed_work(cadence_mhdp_wq, &mhdp->hdcp.check_work,
+			   DRM_HDCP_CHECK_PERIOD_MS);
 out:
 	mutex_unlock(&mhdp->hdcp.mutex);
 	return ret;
@@ -553,7 +553,7 @@ int cdns_mhdp_hdcp_disable(struct cdns_mhdp_device *mhdp)
 	mutex_lock(&mhdp->hdcp.mutex);
 	if (mhdp->hdcp.value != DRM_MODE_CONTENT_PROTECTION_UNDESIRED) {
 		mhdp->hdcp.value = DRM_MODE_CONTENT_PROTECTION_UNDESIRED;
-		schedule_work(&mhdp->hdcp.prop_work);
+		queue_work(cadence_mhdp_wq, &mhdp->hdcp.prop_work);
 		ret = _cdns_mhdp_hdcp_disable(mhdp);
 	}
 	mutex_unlock(&mhdp->hdcp.mutex);
-- 
2.18.4





[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux