All of lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Kurtz <djkurtz@chromium.org>
To: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: Liguo Zhang <liguo.zhang@mediatek.com>,
	Wolfram Sang <wsa@the-dreams.de>,
	srv_heupstream <srv_heupstream@mediatek.com>,
	Matthias Brugger <matthias.bgg@gmail.com>,
	Eddie Huang <eddie.huang@mediatek.com>,
	Xudong Chen <xudong.chen@mediatek.com>,
	Sascha Hauer <s.hauer@pengutronix.de>,
	Linux I2C <linux-i2c@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	linux-arm Mailing List <linux-arm-kernel@lists.infradead.org>,
	linux-mediatek@lists.infradead.org
Subject: Re: [PATCH v2 1/2] i2c: mediatek: add i2c first write then read optimization
Date: Tue, 10 Nov 2015 08:34:16 +0800	[thread overview]
Message-ID: <CAGS+omD08HPGz1-zRWArLWrrN0AMmh2T2dnoTfpZfo+s4u9P=Q@mail.gmail.com> (raw)
In-Reply-To: <CAHp75VfutRR0N0bGDYMjFr+nQGFnmuoiA2afvYfuZ2aOy=2qbQ@mail.gmail.com>

On Mon, Nov 9, 2015 at 10:25 PM, Andy Shevchenko
<andy.shevchenko@gmail.com> wrote:
> On Mon, Nov 9, 2015 at 7:43 AM, Liguo Zhang <liguo.zhang@mediatek.com> wrote:
>> For platform with auto restart support, between every transfer,
>> i2c controller will trigger an interrupt and SW need to handle
>> it to start new transfer. When doing write-then-read transfer,
>> instead of restart mechanism, using WRRD mode to have controller
>> send both transfer in one request to reduce latency.
>
>
>> @@ -518,6 +529,16 @@ static int mtk_i2c_transfer(struct i2c_adapter *adap,
>>         if (ret)
>>                 return ret;
>>
>> +       i2c->auto_restart = i2c->dev_comp->auto_restart;
>> +
>> +       /* checking if we can skip restart and optimize using WRRD mode */
>> +       if (i2c->auto_restart && num == 2) {
>> +               if (!(msgs[0].flags & I2C_M_RD) && (msgs[1].flags & I2C_M_RD) &&
>> +                   msgs[0].addr == msgs[1].addr) {
>
> Nitpick (optional):
>
> ((msgs[0].flags & msgs[1].flags) & I2C_M_RD)
> ?

IMHO, this makes the code less readable.
Leave this to the compiler's optimizer.

-Dan

>
>> +                       i2c->auto_restart = 0;
>> +               }
>> +       }
>
> --
> With Best Regards,
> Andy Shevchenko
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/

WARNING: multiple messages have this Message-ID (diff)
From: djkurtz@chromium.org (Daniel Kurtz)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2 1/2] i2c: mediatek: add i2c first write then read optimization
Date: Tue, 10 Nov 2015 08:34:16 +0800	[thread overview]
Message-ID: <CAGS+omD08HPGz1-zRWArLWrrN0AMmh2T2dnoTfpZfo+s4u9P=Q@mail.gmail.com> (raw)
In-Reply-To: <CAHp75VfutRR0N0bGDYMjFr+nQGFnmuoiA2afvYfuZ2aOy=2qbQ@mail.gmail.com>

On Mon, Nov 9, 2015 at 10:25 PM, Andy Shevchenko
<andy.shevchenko@gmail.com> wrote:
> On Mon, Nov 9, 2015 at 7:43 AM, Liguo Zhang <liguo.zhang@mediatek.com> wrote:
>> For platform with auto restart support, between every transfer,
>> i2c controller will trigger an interrupt and SW need to handle
>> it to start new transfer. When doing write-then-read transfer,
>> instead of restart mechanism, using WRRD mode to have controller
>> send both transfer in one request to reduce latency.
>
>
>> @@ -518,6 +529,16 @@ static int mtk_i2c_transfer(struct i2c_adapter *adap,
>>         if (ret)
>>                 return ret;
>>
>> +       i2c->auto_restart = i2c->dev_comp->auto_restart;
>> +
>> +       /* checking if we can skip restart and optimize using WRRD mode */
>> +       if (i2c->auto_restart && num == 2) {
>> +               if (!(msgs[0].flags & I2C_M_RD) && (msgs[1].flags & I2C_M_RD) &&
>> +                   msgs[0].addr == msgs[1].addr) {
>
> Nitpick (optional):
>
> ((msgs[0].flags & msgs[1].flags) & I2C_M_RD)
> ?

IMHO, this makes the code less readable.
Leave this to the compiler's optimizer.

-Dan

>
>> +                       i2c->auto_restart = 0;
>> +               }
>> +       }
>
> --
> With Best Regards,
> Andy Shevchenko
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo at vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/

  reply	other threads:[~2015-11-10  0:34 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-09  5:43 [PATCH v2 0/2] Mediatek I2C Fixup Liguo Zhang
2015-11-09  5:43 ` Liguo Zhang
2015-11-09  5:43 ` Liguo Zhang
2015-11-09  5:43 ` [PATCH v2 1/2] i2c: mediatek: add i2c first write then read optimization Liguo Zhang
2015-11-09  5:43   ` Liguo Zhang
2015-11-09  5:43   ` Liguo Zhang
2015-11-09 14:25   ` Andy Shevchenko
2015-11-09 14:25     ` Andy Shevchenko
2015-11-10  0:34     ` Daniel Kurtz [this message]
2015-11-10  0:34       ` Daniel Kurtz
2015-11-10  0:50     ` Yingjoe Chen
2015-11-10  0:50       ` Yingjoe Chen
2015-11-10  0:50       ` Yingjoe Chen
2015-12-01  0:56   ` Wolfram Sang
2015-12-01  0:56     ` Wolfram Sang
2015-11-09  5:43 ` [PATCH v2 2/2] i2c: mediatek: fix i2c multi transfer issue in high speed mode Liguo Zhang
2015-11-09  5:43   ` Liguo Zhang
2015-11-09  5:43   ` Liguo Zhang
2015-11-14 14:38   ` Daniel Kurtz
2015-11-14 14:38     ` Daniel Kurtz
2015-11-14 14:38     ` Daniel Kurtz
2015-12-01  0:54     ` Wolfram Sang
2015-12-01  0:54       ` Wolfram Sang
2015-12-01  0:54       ` Wolfram Sang
2015-12-01 11:24     ` Liguo Zhang (张立国)
2015-12-01 11:24       ` Liguo Zhang (张立国)
2015-12-01 11:24       ` Liguo Zhang (张立国)
2015-12-02  2:51     ` liguo zhang
2015-12-02  2:51       ` liguo zhang
2015-12-02  2:51       ` liguo zhang

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='CAGS+omD08HPGz1-zRWArLWrrN0AMmh2T2dnoTfpZfo+s4u9P=Q@mail.gmail.com' \
    --to=djkurtz@chromium.org \
    --cc=andy.shevchenko@gmail.com \
    --cc=eddie.huang@mediatek.com \
    --cc=liguo.zhang@mediatek.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=matthias.bgg@gmail.com \
    --cc=s.hauer@pengutronix.de \
    --cc=srv_heupstream@mediatek.com \
    --cc=wsa@the-dreams.de \
    --cc=xudong.chen@mediatek.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.