From: Chris Wilson <chris@chris-wilson.co.uk>
To: Daniel Kurtz <djkurtz@chromium.org>,
Daniel Vetter <daniel@ffwll.ch>,
Keith Packard <keithp@keithp.com>,
David Airlie <airlied@linux.ie>,
dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org
Cc: Benson Leung <bleung@chromium.org>,
Yufeng Shen <miletus@chromium.org>,
Daniel Kurtz <djkurtz@chromium.org>
Subject: Re: [PATCH 13/13 v4] drm/i915/intel_i2c: reuse GMBUS2 value read in polling loop
Date: Tue, 27 Mar 2012 20:02:59 +0100 [thread overview]
Message-ID: <1332874994_117123@CP5-2952> (raw)
In-Reply-To: <1332873382-29373-14-git-send-email-djkurtz@chromium.org>
On Wed, 28 Mar 2012 02:36:22 +0800, Daniel Kurtz <djkurtz@chromium.org> wrote:
> Save the GMBUS2 value read while polling for state changes, and then
> reuse this value when determining for which reason the loops were exited.
> This is a small optimization which saves a couple of bus accesses for
> memory mapped IO registers.
>
> To avoid "assigning in if clause" checkpatch errors", use a ret variable
> to store the wait_for macro return value.
>
> Signed-off-by: Daniel Kurtz <djkurtz@chromium.org>
> ---
> drivers/gpu/drm/i915/intel_i2c.c | 32 ++++++++++++++++++++------------
> 1 files changed, 20 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/intel_i2c.c b/drivers/gpu/drm/i915/intel_i2c.c
> index c71f3dc..174fc71 100644
> --- a/drivers/gpu/drm/i915/intel_i2c.c
> +++ b/drivers/gpu/drm/i915/intel_i2c.c
> @@ -210,6 +210,7 @@ gmbus_xfer_read(struct drm_i915_private *dev_priv, struct i2c_msg *msg,
> int reg_offset = dev_priv->gpio_mmio_base;
> u16 len = msg->len;
> u8 *buf = msg->buf;
> + u32 gmbus2;
Does the temporary really need such broad scoping?
> I915_WRITE(GMBUS1 + reg_offset,
> gmbus1 |
> @@ -219,13 +220,15 @@ gmbus_xfer_read(struct drm_i915_private *dev_priv, struct i2c_msg *msg,
> GMBUS_SLAVE_READ | GMBUS_SW_RDY);
> POSTING_READ(GMBUS2 + reg_offset);
Might as well shave this read as well.
> do {
> + int ret;
> u32 val, loop = 0;
>
> - if (wait_for(I915_READ(GMBUS2 + reg_offset) &
> - (GMBUS_SATOER | GMBUS_HW_RDY),
> - 50))
> + ret = wait_for((gmbus2 = I915_READ(GMBUS2 + reg_offset)) &
> + (GMBUS_SATOER | GMBUS_HW_RDY),
> + 50);
> + if (ret)
> return -ETIMEDOUT;
> - if (I915_READ(GMBUS2 + reg_offset) & GMBUS_SATOER)
> + if (gmbus2 & GMBUS_SATOER)
> return -ENXIO;
>
> val = I915_READ(GMBUS3 + reg_offset);
> @@ -245,6 +248,7 @@ gmbus_xfer_write(struct drm_i915_private *dev_priv, struct i2c_msg *msg)
> u16 len = msg->len;
> u8 *buf = msg->buf;
> u32 val, loop;
> + u32 gmbus2;
>
> val = loop = 0;
> while (len && loop < 4) {
> @@ -260,6 +264,7 @@ gmbus_xfer_write(struct drm_i915_private *dev_priv, struct i2c_msg *msg)
> GMBUS_SLAVE_WRITE | GMBUS_SW_RDY);
> POSTING_READ(GMBUS2 + reg_offset);
> while (len) {
> + int ret;
> val = loop = 0;
> do {
> val |= *buf++ << (8 * loop);
> @@ -268,11 +273,12 @@ gmbus_xfer_write(struct drm_i915_private *dev_priv, struct i2c_msg *msg)
> I915_WRITE(GMBUS3 + reg_offset, val);
> POSTING_READ(GMBUS2 + reg_offset);
And here.
--
Chris Wilson, Intel Open Source Technology Centre
next prev parent reply other threads:[~2012-03-27 19:03 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-27 18:36 [PATCH 00/13 v4] fix gmbus writes and related issues Daniel Kurtz
2012-03-27 18:36 ` [PATCH 01/13 v4] drm/i915/intel_i2c: refactor gmbus_xfer Daniel Kurtz
2012-03-27 19:09 ` Chris Wilson
2012-03-27 18:36 ` [PATCH 02/13 v4] drm/i915/intel_i2c: cleanup error messages and comments Daniel Kurtz
2012-03-27 18:46 ` Chris Wilson
2012-03-27 18:36 ` [PATCH 03/13 v4] drm/i915/intel_i2c: assign HDMI port D to pin pair 6 Daniel Kurtz
2012-03-27 18:36 ` [PATCH 04/13 v4] drm/i915/intel_i2c: use i2c pre/post_xfer functions to setup gpio xfers Daniel Kurtz
2012-03-27 18:57 ` Chris Wilson
2012-03-27 18:36 ` [PATCH 05/13 v4] drm/i915/intel_i2c: refactor using intel_gmbus_get_adapter Daniel Kurtz
2012-03-27 18:36 ` [PATCH 06/13 v4] drm/i915/intel_i2c: gmbus disabled and reserved ports are invalid Daniel Kurtz
2012-03-27 18:36 ` [PATCH 07/13 v4] drm/i915/intel_i2c: allocate gmbus array as part of drm_i915_private Daniel Kurtz
2012-03-28 13:05 ` Daniel Vetter
2012-03-27 18:36 ` [PATCH 08/13 v4] drm/i915/intel_i2c: handle zero-length writes Daniel Kurtz
2012-03-27 19:14 ` Chris Wilson
2012-03-28 11:32 ` Daniel Kurtz
2012-03-28 11:39 ` Chris Wilson
2012-03-27 18:36 ` [PATCH 09/13 v4] drm/i915/intel_i2c: use double-buffered writes Daniel Kurtz
2012-03-27 18:45 ` Chris Wilson
2012-03-27 18:36 ` [PATCH 10/13 v4] drm/i915/intel_i2c: always wait for IDLE before clearing NAK Daniel Kurtz
2012-03-27 19:17 ` Chris Wilson
2012-03-27 18:36 ` [PATCH 11/13 v4] drm/i915/intel_i2c: use WAIT cycle, not STOP Daniel Kurtz
2012-03-27 18:36 ` [PATCH 12/13 v4] drm/i915/intel_i2c: use INDEX cycles for i2c read transactions Daniel Kurtz
2012-03-28 13:21 ` Daniel Vetter
2012-03-27 18:36 ` [PATCH 13/13 v4] drm/i915/intel_i2c: reuse GMBUS2 value read in polling loop Daniel Kurtz
2012-03-27 19:02 ` Chris Wilson [this message]
2012-03-28 11:39 ` Daniel Kurtz
2012-03-28 11:44 ` Chris Wilson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1332874994_117123@CP5-2952 \
--to=chris@chris-wilson.co.uk \
--cc=airlied@linux.ie \
--cc=bleung@chromium.org \
--cc=daniel@ffwll.ch \
--cc=djkurtz@chromium.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=keithp@keithp.com \
--cc=linux-kernel@vger.kernel.org \
--cc=miletus@chromium.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox