[PATCH 1/3] drm: Allow drivers to change the interval of output poll work in runtime

José Roberto de Souza jose.souza at intel.com
Tue Feb 5 23:21:59 UTC 2019


In some circumstances drivers that uses the output polling work may
want a different period interval for the output poll work. Also the
current value may be to big for some cases, so let's add a hook and
let driver device interval in runtime.

Cc: Imre Deak <imre.deak at intel.com>
Signed-off-by: José Roberto de Souza <jose.souza at intel.com>
---
 drivers/gpu/drm/drm_probe_helper.c | 16 ++++++++++++----
 include/drm/drm_mode_config.h      |  9 +++++++++
 2 files changed, 21 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/drm_probe_helper.c b/drivers/gpu/drm/drm_probe_helper.c
index 6fd08e04b323..0dc940f4f08e 100644
--- a/drivers/gpu/drm/drm_probe_helper.c
+++ b/drivers/gpu/drm/drm_probe_helper.c
@@ -203,7 +203,14 @@ enum drm_mode_status drm_connector_mode_valid(struct drm_connector *connector,
 	return connector_funcs->mode_valid(connector, mode);
 }
 
-#define DRM_OUTPUT_POLL_PERIOD (10*HZ)
+static unsigned long output_poll_period_get(struct drm_device *dev)
+{
+	if (dev->mode_config.funcs->output_poll_period_get)
+		return dev->mode_config.funcs->output_poll_period_get(dev);
+
+	return 10 * HZ;
+}
+
 /**
  * drm_kms_helper_poll_enable - re-enable output polling.
  * @dev: drm_device
@@ -224,7 +231,7 @@ void drm_kms_helper_poll_enable(struct drm_device *dev)
 	bool poll = false;
 	struct drm_connector *connector;
 	struct drm_connector_list_iter conn_iter;
-	unsigned long delay = DRM_OUTPUT_POLL_PERIOD;
+	unsigned long delay = output_poll_period_get(dev);
 
 	if (!dev->mode_config.poll_enabled || !drm_kms_helper_poll)
 		return;
@@ -249,7 +256,8 @@ void drm_kms_helper_poll_enable(struct drm_device *dev)
 		 * was enabled before.
 		 */
 		poll = true;
-		delay = HZ;
+		if (delay > HZ)
+			delay = HZ;
 	}
 
 	if (poll)
@@ -649,7 +657,7 @@ static void output_poll_execute(struct work_struct *work)
 		drm_kms_helper_hotplug_event(dev);
 
 	if (repoll)
-		schedule_delayed_work(delayed_work, DRM_OUTPUT_POLL_PERIOD);
+		schedule_delayed_work(delayed_work, output_poll_period_get(dev));
 }
 
 /**
diff --git a/include/drm/drm_mode_config.h b/include/drm/drm_mode_config.h
index 7f60e8eb269a..90b089527e23 100644
--- a/include/drm/drm_mode_config.h
+++ b/include/drm/drm_mode_config.h
@@ -108,6 +108,15 @@ struct drm_mode_config_funcs {
 	 */
 	void (*output_poll_changed)(struct drm_device *dev);
 
+	/**
+	 * @output_poll_period_get:
+	 *
+	 * Return the interval period in jiffies between each execution of
+	 * output polling work. If no hook is provided the default period of
+	 * 10sec will be used.
+	 */
+	unsigned long (*output_poll_period_get)(struct drm_device *dev);
+
 	/**
 	 * @mode_valid:
 	 *
-- 
2.20.1



More information about the Intel-gfx-trybot mailing list