public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] drm/i915/intel_i2c: handle zero-length reads
@ 2012-04-13 11:47 Daniel Kurtz
  2012-04-13 11:47 ` [PATCH 2/2] drm/i915/intel_i2c: reduce verbosity of some messages Daniel Kurtz
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Daniel Kurtz @ 2012-04-13 11:47 UTC (permalink / raw)
  To: Keith Packard, David Airlie, dri-devel, linux-kernel,
	Daniel Vetter, Chris Wilson
  Cc: Daniel Kurtz

A common method of probing an i2c bus is trying to do a zero-length read.
Handle this case by checking the length first waiting for data to be read.

This is actually important, since attempting a zero-length read is one
of the ways that i2cdetect and i2c_new_probed_device detect whether
there is device present on the bus with a given address.

Signed-off-by: Daniel Kurtz <djkurtz@chromium.org>
---
 drivers/gpu/drm/i915/intel_i2c.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_i2c.c b/drivers/gpu/drm/i915/intel_i2c.c
index cab879f..e249160 100644
--- a/drivers/gpu/drm/i915/intel_i2c.c
+++ b/drivers/gpu/drm/i915/intel_i2c.c
@@ -217,7 +217,7 @@ gmbus_xfer_read(struct drm_i915_private *dev_priv, struct i2c_msg *msg,
 		   (len << GMBUS_BYTE_COUNT_SHIFT) |
 		   (msg->addr << GMBUS_SLAVE_ADDR_SHIFT) |
 		   GMBUS_SLAVE_READ | GMBUS_SW_RDY);
-	do {
+	while (len) {
 		int ret;
 		u32 val, loop = 0;
 		u32 gmbus2;
@@ -235,7 +235,7 @@ gmbus_xfer_read(struct drm_i915_private *dev_priv, struct i2c_msg *msg,
 			*buf++ = val & 0xff;
 			val >>= 8;
 		} while (--len && ++loop < 4);
-	} while (len);
+	}
 
 	return 0;
 }
-- 
1.7.7.3


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/2] drm/i915/intel_i2c: reduce verbosity of some messages
  2012-04-13 11:47 [PATCH 1/2] drm/i915/intel_i2c: handle zero-length reads Daniel Kurtz
@ 2012-04-13 11:47 ` Daniel Kurtz
  2012-04-13 13:04   ` Daniel Vetter
  2012-04-13 12:25 ` [PATCH 1/2] drm/i915/intel_i2c: handle zero-length reads Chris Wilson
  2012-04-13 12:26 ` Chris Wilson
  2 siblings, 1 reply; 5+ messages in thread
From: Daniel Kurtz @ 2012-04-13 11:47 UTC (permalink / raw)
  To: Keith Packard, David Airlie, dri-devel, linux-kernel,
	Daniel Vetter, Chris Wilson
  Cc: Daniel Kurtz

Some of these messages can be hit when userspace tries to probe the i2c
with nothing connected or if the driver code tries to do the same. See:
https://bugs.freedesktop.org/show_bug.cgi?id=48248

Signed-off-by: Daniel Kurtz <djkurtz@chromium.org>
---
 drivers/gpu/drm/i915/intel_i2c.c |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_i2c.c b/drivers/gpu/drm/i915/intel_i2c.c
index e249160..e04255e 100644
--- a/drivers/gpu/drm/i915/intel_i2c.c
+++ b/drivers/gpu/drm/i915/intel_i2c.c
@@ -383,7 +383,7 @@ gmbus_xfer(struct i2c_adapter *adapter,
 	 */
 	if (wait_for((I915_READ(GMBUS2 + reg_offset) & GMBUS_ACTIVE) == 0,
 		     10)) {
-		DRM_INFO("GMBUS [%s] timed out waiting for idle\n",
+		DRM_DEBUG_KMS("GMBUS [%s] timed out waiting for idle\n",
 			 adapter->name);
 		ret = -ETIMEDOUT;
 	}
@@ -399,7 +399,8 @@ clear_err:
 	 */
 	if (wait_for((I915_READ(GMBUS2 + reg_offset) & GMBUS_ACTIVE) == 0,
 		     10))
-		DRM_INFO("GMBUS [%s] timed out after NAK\n", adapter->name);
+		DRM_DEBUG_KMS("GMBUS [%s] timed out after NAK\n",
+			      adapter->name);
 
 	/* Toggle the Software Clear Interrupt bit. This has the effect
 	 * of resetting the GMBUS controller and so clearing the
@@ -409,7 +410,7 @@ clear_err:
 	I915_WRITE(GMBUS1 + reg_offset, 0);
 	I915_WRITE(GMBUS0 + reg_offset, 0);
 
-	DRM_DEBUG_DRIVER("GMBUS [%s] NAK for addr: %04x %c(%d)\n",
+	DRM_DEBUG_KMS("GMBUS [%s] NAK for addr: %04x %c(%d)\n",
 			 adapter->name, msgs[i].addr,
 			 (msgs[i].flags & I2C_M_RD) ? 'r' : 'w', msgs[i].len);
 
-- 
1.7.7.3


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/2] drm/i915/intel_i2c: handle zero-length reads
  2012-04-13 11:47 [PATCH 1/2] drm/i915/intel_i2c: handle zero-length reads Daniel Kurtz
  2012-04-13 11:47 ` [PATCH 2/2] drm/i915/intel_i2c: reduce verbosity of some messages Daniel Kurtz
@ 2012-04-13 12:25 ` Chris Wilson
  2012-04-13 12:26 ` Chris Wilson
  2 siblings, 0 replies; 5+ messages in thread
From: Chris Wilson @ 2012-04-13 12:25 UTC (permalink / raw)
  To: Daniel Kurtz, Keith Packard, David Airlie, dri-devel,
	linux-kernel, Daniel Vetter
  Cc: Daniel Kurtz

On Fri, 13 Apr 2012 19:47:53 +0800, Daniel Kurtz <djkurtz@chromium.org> wrote:
> A common method of probing an i2c bus is trying to do a zero-length read.
> Handle this case by checking the length first waiting for data to be read.
> 
> This is actually important, since attempting a zero-length read is one
> of the ways that i2cdetect and i2c_new_probed_device detect whether
> there is device present on the bus with a given address.
> 
> Signed-off-by: Daniel Kurtz <djkurtz@chromium.org>

You earlier assuaged my fears that setting SW_READY without waiting
would anger the hw, so

Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/2] drm/i915/intel_i2c: handle zero-length reads
  2012-04-13 11:47 [PATCH 1/2] drm/i915/intel_i2c: handle zero-length reads Daniel Kurtz
  2012-04-13 11:47 ` [PATCH 2/2] drm/i915/intel_i2c: reduce verbosity of some messages Daniel Kurtz
  2012-04-13 12:25 ` [PATCH 1/2] drm/i915/intel_i2c: handle zero-length reads Chris Wilson
@ 2012-04-13 12:26 ` Chris Wilson
  2 siblings, 0 replies; 5+ messages in thread
From: Chris Wilson @ 2012-04-13 12:26 UTC (permalink / raw)
  To: Daniel Kurtz, Keith Packard, David Airlie, dri-devel,
	linux-kernel, Daniel Vetter
  Cc: Daniel Kurtz

Also,

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=48269
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/2] drm/i915/intel_i2c: reduce verbosity of some messages
  2012-04-13 11:47 ` [PATCH 2/2] drm/i915/intel_i2c: reduce verbosity of some messages Daniel Kurtz
@ 2012-04-13 13:04   ` Daniel Vetter
  0 siblings, 0 replies; 5+ messages in thread
From: Daniel Vetter @ 2012-04-13 13:04 UTC (permalink / raw)
  To: Daniel Kurtz
  Cc: Keith Packard, David Airlie, dri-devel, linux-kernel,
	Daniel Vetter, Chris Wilson

On Fri, Apr 13, 2012 at 07:47:54PM +0800, Daniel Kurtz wrote:
> Some of these messages can be hit when userspace tries to probe the i2c
> with nothing connected or if the driver code tries to do the same. See:
> https://bugs.freedesktop.org/show_bug.cgi?id=48248
> 
> Signed-off-by: Daniel Kurtz <djkurtz@chromium.org>
Both patches queued for -next, thanks a lot for all the work you've put
into beating gmbus into shape.
- Daniel
-- 
Daniel Vetter
Mail: daniel@ffwll.ch
Mobile: +41 (0)79 365 57 48

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2012-04-13 13:03 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-04-13 11:47 [PATCH 1/2] drm/i915/intel_i2c: handle zero-length reads Daniel Kurtz
2012-04-13 11:47 ` [PATCH 2/2] drm/i915/intel_i2c: reduce verbosity of some messages Daniel Kurtz
2012-04-13 13:04   ` Daniel Vetter
2012-04-13 12:25 ` [PATCH 1/2] drm/i915/intel_i2c: handle zero-length reads Chris Wilson
2012-04-13 12:26 ` Chris Wilson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox