diff mbox

[2/9] drm: Introduce EAGAIN handling for immediatelly aux retries

Message ID 1448496245-1495-3-git-send-email-rodrigo.vivi@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Rodrigo Vivi Nov. 26, 2015, 12:03 a.m. UTC
The goal here is to offload aux retries handling from the
drivers to drm.

However there are 2 differents cases for retry:
1. Immediately retry - Hardware already took care of needed timeouts
   	       	       before answering that a retry is possible.
2. Busy - Wait some time and retry.

This driver introduce the support for EAGAIN that can handle the
first case and a following patch will introduce EBUSY waits,
after all drivers counting on immediately retries are changed.

v2: Rebased on top of drm_dp_helper docbook changes.
    Also this version add EAGAIN documentation and as suggested by
    Jani it inserts a comment at drm_dp_i2c_do_msg explaining EAGAIN
    timeout is already handled at i2c level.

Cc: Jani Nikula <jani.nikula@intel.com>
Cc: Dave Airlie <airlied@redhat.com>
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Tested-by: Daniel Stone <daniels@collabora.com>
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
---
 drivers/gpu/drm/drm_dp_helper.c | 10 ++++++++++
 include/drm/drm_dp_helper.h     |  4 ++++
 2 files changed, 14 insertions(+)
diff mbox

Patch

diff --git a/drivers/gpu/drm/drm_dp_helper.c b/drivers/gpu/drm/drm_dp_helper.c
index 9535c5b..2e26097 100644
--- a/drivers/gpu/drm/drm_dp_helper.c
+++ b/drivers/gpu/drm/drm_dp_helper.c
@@ -198,6 +198,11 @@  static int drm_dp_dpcd_access(struct drm_dp_aux *aux, u8 request,
 		err = aux->transfer(aux, &msg);
 		mutex_unlock(&aux->hw_mutex);
 		if (err < 0) {
+			/* Immediately retry */
+			if (err == -EAGAIN)
+				continue;
+
+			/* FIXME: On BUSY we could wait before retrying */
 			if (err == -EBUSY)
 				continue;
 
@@ -547,6 +552,11 @@  static int drm_dp_i2c_do_msg(struct drm_dp_aux *aux, struct drm_dp_aux_msg *msg)
 		ret = aux->transfer(aux, msg);
 		mutex_unlock(&aux->hw_mutex);
 		if (ret < 0) {
+
+			/*
+			 * -EAGAIN retries are handled by i2c layer with
+			 * timeouts for repeated -EAGAINs
+			 */
 			if (ret == -EBUSY)
 				continue;
 
diff --git a/include/drm/drm_dp_helper.h b/include/drm/drm_dp_helper.h
index ed7dbdc..518fc1b 100644
--- a/include/drm/drm_dp_helper.h
+++ b/include/drm/drm_dp_helper.h
@@ -758,6 +758,10 @@  struct drm_dp_aux {
 	 *   to check for failure.
 	 * - -EBUSY: When BUSY helpers will attempt retries before propagating
 	 *   this error.
+	 * - -EAGAIN: DPCD helper will attempt immediatelly retries before
+	 *   propagating this error. i2c helper will only propagate directly
+	 *   since i2c layer already perform retries with timeouts for repeated
+	 *   -EAGAINs.
 	 *
 	 * Note that the aux helper code assumes that the .transfer() function
 	 * only modifies the reply field of the drm_dp_aux_msg structure.  The