From: Jae Hyun Yoo <jae.hyun.yoo@linux.intel.com>
To: linux-aspeed@lists.ozlabs.org
Subject: [PATCH 3/5] i2c: aspeed: fix master pending state handling
Date: Tue, 8 Oct 2019 15:45:33 -0700 [thread overview]
Message-ID: <6f280195-eef7-1fe7-ac42-ad6879ca9838@linux.intel.com> (raw)
In-Reply-To: <422eea61-7cb9-e471-83fb-3f554ff5e079@fb.com>
Hi Tao,
On 10/8/2019 3:00 PM, Tao Ren wrote:
> On 10/7/19 4:13 PM, Jae Hyun Yoo wrote:
>> In case of master pending state, it should not trigger the master
>> command because this H/W is sharing the same data buffer for slave
>> and master operations, so this commit fixes the issue with making
>> the master command triggering happen when the state goes to active
>> state.
>>
>> Signed-off-by: Jae Hyun Yoo <jae.hyun.yoo@linux.intel.com>
>> ---
>> drivers/i2c/busses/i2c-aspeed.c | 9 +++++----
>> 1 file changed, 5 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/i2c/busses/i2c-aspeed.c b/drivers/i2c/busses/i2c-aspeed.c
>> index fa66951b05d0..40f6cf98d32e 100644
>> --- a/drivers/i2c/busses/i2c-aspeed.c
>> +++ b/drivers/i2c/busses/i2c-aspeed.c
>> @@ -336,18 +336,19 @@ static void aspeed_i2c_do_start(struct aspeed_i2c_bus *bus)
>> struct i2c_msg *msg = &bus->msgs[bus->msgs_index];
>> u8 slave_addr = i2c_8bit_addr_from_msg(msg);
>>
>> - bus->master_state = ASPEED_I2C_MASTER_START;
>> -
>> #if IS_ENABLED(CONFIG_I2C_SLAVE)
>> /*
>> * If it's requested in the middle of a slave session, set the master
>> * state to 'pending' then H/W will continue handling this master
>> * command when the bus comes back to the idle state.
>> */
>> - if (bus->slave_state != ASPEED_I2C_SLAVE_INACTIVE)
>> + if (bus->slave_state != ASPEED_I2C_SLAVE_INACTIVE) {
>> bus->master_state = ASPEED_I2C_MASTER_PENDING;
>> + return;
>> + }
>> #endif /* CONFIG_I2C_SLAVE */
>>
>> + bus->master_state = ASPEED_I2C_MASTER_START;
>> bus->buf_index = 0;
>>
>> if (msg->flags & I2C_M_RD) {
>> @@ -432,7 +433,7 @@ static u32 aspeed_i2c_master_irq(struct aspeed_i2c_bus *bus, u32 irq_status)
>> if (bus->slave_state != ASPEED_I2C_SLAVE_INACTIVE)
>> goto out_no_complete;
>>
>> - bus->master_state = ASPEED_I2C_MASTER_START;
>> + aspeed_i2c_do_start(bus);
>> }
>
> Shall we move the restart-master logic from master_irq to bus_irq? The reason being:
> master transaction cannot be restarted when aspeed-i2c is running in slave state and
> receives STOP interrupt, because aspeed_i2c_master_irq won't be called in this case.
Even in that case, master can be restarted properly because slave_irq
will be called first because master is in MASTER_PENDING state, so the
slave_irq handles the STOP interrupt as well, and then master_irq will
be called with SLAVE_INACTIVE state so the aspeed_i2c_do_start can be
called eventually.
Also, this is right point to call the aspeed_i2c_do_start
because master state will be changed to MASTER_START by the
aspeed_i2c_do_start and we have to do remaining handling for the
MASTER_START in the master_irq by falling through after the call.
Thanks,
Jae
WARNING: multiple messages have this Message-ID (diff)
From: Jae Hyun Yoo <jae.hyun.yoo@linux.intel.com>
To: Tao Ren <taoren@fb.com>,
Brendan Higgins <brendanhiggins@google.com>,
Benjamin Herrenschmidt <benh@kernel.crashing.org>,
Joel Stanley <joel@jms.id.au>, Rob Herring <robh+dt@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Andrew Jeffery <andrew@aj.id.au>
Cc: "devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
"linux-aspeed@lists.ozlabs.org" <linux-aspeed@lists.ozlabs.org>,
"linux-i2c@vger.kernel.org" <linux-i2c@vger.kernel.org>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>,
"openbmc@lists.ozlabs.org" <openbmc@lists.ozlabs.org>
Subject: Re: [PATCH 3/5] i2c: aspeed: fix master pending state handling
Date: Tue, 8 Oct 2019 15:45:33 -0700 [thread overview]
Message-ID: <6f280195-eef7-1fe7-ac42-ad6879ca9838@linux.intel.com> (raw)
In-Reply-To: <422eea61-7cb9-e471-83fb-3f554ff5e079@fb.com>
Hi Tao,
On 10/8/2019 3:00 PM, Tao Ren wrote:
> On 10/7/19 4:13 PM, Jae Hyun Yoo wrote:
>> In case of master pending state, it should not trigger the master
>> command because this H/W is sharing the same data buffer for slave
>> and master operations, so this commit fixes the issue with making
>> the master command triggering happen when the state goes to active
>> state.
>>
>> Signed-off-by: Jae Hyun Yoo <jae.hyun.yoo@linux.intel.com>
>> ---
>> drivers/i2c/busses/i2c-aspeed.c | 9 +++++----
>> 1 file changed, 5 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/i2c/busses/i2c-aspeed.c b/drivers/i2c/busses/i2c-aspeed.c
>> index fa66951b05d0..40f6cf98d32e 100644
>> --- a/drivers/i2c/busses/i2c-aspeed.c
>> +++ b/drivers/i2c/busses/i2c-aspeed.c
>> @@ -336,18 +336,19 @@ static void aspeed_i2c_do_start(struct aspeed_i2c_bus *bus)
>> struct i2c_msg *msg = &bus->msgs[bus->msgs_index];
>> u8 slave_addr = i2c_8bit_addr_from_msg(msg);
>>
>> - bus->master_state = ASPEED_I2C_MASTER_START;
>> -
>> #if IS_ENABLED(CONFIG_I2C_SLAVE)
>> /*
>> * If it's requested in the middle of a slave session, set the master
>> * state to 'pending' then H/W will continue handling this master
>> * command when the bus comes back to the idle state.
>> */
>> - if (bus->slave_state != ASPEED_I2C_SLAVE_INACTIVE)
>> + if (bus->slave_state != ASPEED_I2C_SLAVE_INACTIVE) {
>> bus->master_state = ASPEED_I2C_MASTER_PENDING;
>> + return;
>> + }
>> #endif /* CONFIG_I2C_SLAVE */
>>
>> + bus->master_state = ASPEED_I2C_MASTER_START;
>> bus->buf_index = 0;
>>
>> if (msg->flags & I2C_M_RD) {
>> @@ -432,7 +433,7 @@ static u32 aspeed_i2c_master_irq(struct aspeed_i2c_bus *bus, u32 irq_status)
>> if (bus->slave_state != ASPEED_I2C_SLAVE_INACTIVE)
>> goto out_no_complete;
>>
>> - bus->master_state = ASPEED_I2C_MASTER_START;
>> + aspeed_i2c_do_start(bus);
>> }
>
> Shall we move the restart-master logic from master_irq to bus_irq? The reason being:
> master transaction cannot be restarted when aspeed-i2c is running in slave state and
> receives STOP interrupt, because aspeed_i2c_master_irq won't be called in this case.
Even in that case, master can be restarted properly because slave_irq
will be called first because master is in MASTER_PENDING state, so the
slave_irq handles the STOP interrupt as well, and then master_irq will
be called with SLAVE_INACTIVE state so the aspeed_i2c_do_start can be
called eventually.
Also, this is right point to call the aspeed_i2c_do_start
because master state will be changed to MASTER_START by the
aspeed_i2c_do_start and we have to do remaining handling for the
MASTER_START in the master_irq by falling through after the call.
Thanks,
Jae
WARNING: multiple messages have this Message-ID (diff)
From: Jae Hyun Yoo <jae.hyun.yoo@linux.intel.com>
To: Tao Ren <taoren@fb.com>,
Brendan Higgins <brendanhiggins@google.com>,
Benjamin Herrenschmidt <benh@kernel.crashing.org>,
Joel Stanley <joel@jms.id.au>, Rob Herring <robh+dt@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Andrew Jeffery <andrew@aj.id.au>
Cc: "linux-i2c@vger.kernel.org" <linux-i2c@vger.kernel.org>,
"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>,
"linux-aspeed@lists.ozlabs.org" <linux-aspeed@lists.ozlabs.org>,
"openbmc@lists.ozlabs.org" <openbmc@lists.ozlabs.org>
Subject: Re: [PATCH 3/5] i2c: aspeed: fix master pending state handling
Date: Tue, 8 Oct 2019 15:45:33 -0700 [thread overview]
Message-ID: <6f280195-eef7-1fe7-ac42-ad6879ca9838@linux.intel.com> (raw)
In-Reply-To: <422eea61-7cb9-e471-83fb-3f554ff5e079@fb.com>
Hi Tao,
On 10/8/2019 3:00 PM, Tao Ren wrote:
> On 10/7/19 4:13 PM, Jae Hyun Yoo wrote:
>> In case of master pending state, it should not trigger the master
>> command because this H/W is sharing the same data buffer for slave
>> and master operations, so this commit fixes the issue with making
>> the master command triggering happen when the state goes to active
>> state.
>>
>> Signed-off-by: Jae Hyun Yoo <jae.hyun.yoo@linux.intel.com>
>> ---
>> drivers/i2c/busses/i2c-aspeed.c | 9 +++++----
>> 1 file changed, 5 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/i2c/busses/i2c-aspeed.c b/drivers/i2c/busses/i2c-aspeed.c
>> index fa66951b05d0..40f6cf98d32e 100644
>> --- a/drivers/i2c/busses/i2c-aspeed.c
>> +++ b/drivers/i2c/busses/i2c-aspeed.c
>> @@ -336,18 +336,19 @@ static void aspeed_i2c_do_start(struct aspeed_i2c_bus *bus)
>> struct i2c_msg *msg = &bus->msgs[bus->msgs_index];
>> u8 slave_addr = i2c_8bit_addr_from_msg(msg);
>>
>> - bus->master_state = ASPEED_I2C_MASTER_START;
>> -
>> #if IS_ENABLED(CONFIG_I2C_SLAVE)
>> /*
>> * If it's requested in the middle of a slave session, set the master
>> * state to 'pending' then H/W will continue handling this master
>> * command when the bus comes back to the idle state.
>> */
>> - if (bus->slave_state != ASPEED_I2C_SLAVE_INACTIVE)
>> + if (bus->slave_state != ASPEED_I2C_SLAVE_INACTIVE) {
>> bus->master_state = ASPEED_I2C_MASTER_PENDING;
>> + return;
>> + }
>> #endif /* CONFIG_I2C_SLAVE */
>>
>> + bus->master_state = ASPEED_I2C_MASTER_START;
>> bus->buf_index = 0;
>>
>> if (msg->flags & I2C_M_RD) {
>> @@ -432,7 +433,7 @@ static u32 aspeed_i2c_master_irq(struct aspeed_i2c_bus *bus, u32 irq_status)
>> if (bus->slave_state != ASPEED_I2C_SLAVE_INACTIVE)
>> goto out_no_complete;
>>
>> - bus->master_state = ASPEED_I2C_MASTER_START;
>> + aspeed_i2c_do_start(bus);
>> }
>
> Shall we move the restart-master logic from master_irq to bus_irq? The reason being:
> master transaction cannot be restarted when aspeed-i2c is running in slave state and
> receives STOP interrupt, because aspeed_i2c_master_irq won't be called in this case.
Even in that case, master can be restarted properly because slave_irq
will be called first because master is in MASTER_PENDING state, so the
slave_irq handles the STOP interrupt as well, and then master_irq will
be called with SLAVE_INACTIVE state so the aspeed_i2c_do_start can be
called eventually.
Also, this is right point to call the aspeed_i2c_do_start
because master state will be changed to MASTER_START by the
aspeed_i2c_do_start and we have to do remaining handling for the
MASTER_START in the master_irq by falling through after the call.
Thanks,
Jae
WARNING: multiple messages have this Message-ID (diff)
From: Jae Hyun Yoo <jae.hyun.yoo@linux.intel.com>
To: Tao Ren <taoren@fb.com>,
Brendan Higgins <brendanhiggins@google.com>,
Benjamin Herrenschmidt <benh@kernel.crashing.org>,
Joel Stanley <joel@jms.id.au>, Rob Herring <robh+dt@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Andrew Jeffery <andrew@aj.id.au>
Cc: "devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
"linux-aspeed@lists.ozlabs.org" <linux-aspeed@lists.ozlabs.org>,
"linux-i2c@vger.kernel.org" <linux-i2c@vger.kernel.org>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>,
"openbmc@lists.ozlabs.org" <openbmc@lists.ozlabs.org>
Subject: Re: [PATCH 3/5] i2c: aspeed: fix master pending state handling
Date: Tue, 8 Oct 2019 15:45:33 -0700 [thread overview]
Message-ID: <6f280195-eef7-1fe7-ac42-ad6879ca9838@linux.intel.com> (raw)
In-Reply-To: <422eea61-7cb9-e471-83fb-3f554ff5e079@fb.com>
Hi Tao,
On 10/8/2019 3:00 PM, Tao Ren wrote:
> On 10/7/19 4:13 PM, Jae Hyun Yoo wrote:
>> In case of master pending state, it should not trigger the master
>> command because this H/W is sharing the same data buffer for slave
>> and master operations, so this commit fixes the issue with making
>> the master command triggering happen when the state goes to active
>> state.
>>
>> Signed-off-by: Jae Hyun Yoo <jae.hyun.yoo@linux.intel.com>
>> ---
>> drivers/i2c/busses/i2c-aspeed.c | 9 +++++----
>> 1 file changed, 5 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/i2c/busses/i2c-aspeed.c b/drivers/i2c/busses/i2c-aspeed.c
>> index fa66951b05d0..40f6cf98d32e 100644
>> --- a/drivers/i2c/busses/i2c-aspeed.c
>> +++ b/drivers/i2c/busses/i2c-aspeed.c
>> @@ -336,18 +336,19 @@ static void aspeed_i2c_do_start(struct aspeed_i2c_bus *bus)
>> struct i2c_msg *msg = &bus->msgs[bus->msgs_index];
>> u8 slave_addr = i2c_8bit_addr_from_msg(msg);
>>
>> - bus->master_state = ASPEED_I2C_MASTER_START;
>> -
>> #if IS_ENABLED(CONFIG_I2C_SLAVE)
>> /*
>> * If it's requested in the middle of a slave session, set the master
>> * state to 'pending' then H/W will continue handling this master
>> * command when the bus comes back to the idle state.
>> */
>> - if (bus->slave_state != ASPEED_I2C_SLAVE_INACTIVE)
>> + if (bus->slave_state != ASPEED_I2C_SLAVE_INACTIVE) {
>> bus->master_state = ASPEED_I2C_MASTER_PENDING;
>> + return;
>> + }
>> #endif /* CONFIG_I2C_SLAVE */
>>
>> + bus->master_state = ASPEED_I2C_MASTER_START;
>> bus->buf_index = 0;
>>
>> if (msg->flags & I2C_M_RD) {
>> @@ -432,7 +433,7 @@ static u32 aspeed_i2c_master_irq(struct aspeed_i2c_bus *bus, u32 irq_status)
>> if (bus->slave_state != ASPEED_I2C_SLAVE_INACTIVE)
>> goto out_no_complete;
>>
>> - bus->master_state = ASPEED_I2C_MASTER_START;
>> + aspeed_i2c_do_start(bus);
>> }
>
> Shall we move the restart-master logic from master_irq to bus_irq? The reason being:
> master transaction cannot be restarted when aspeed-i2c is running in slave state and
> receives STOP interrupt, because aspeed_i2c_master_irq won't be called in this case.
Even in that case, master can be restarted properly because slave_irq
will be called first because master is in MASTER_PENDING state, so the
slave_irq handles the STOP interrupt as well, and then master_irq will
be called with SLAVE_INACTIVE state so the aspeed_i2c_do_start can be
called eventually.
Also, this is right point to call the aspeed_i2c_do_start
because master state will be changed to MASTER_START by the
aspeed_i2c_do_start and we have to do remaining handling for the
MASTER_START in the master_irq by falling through after the call.
Thanks,
Jae
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2019-10-08 22:45 UTC|newest]
Thread overview: 87+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-07 23:13 [PATCH 0/5] i2c: aspeed: Add buffer and DMA modes support Jae Hyun Yoo
2019-10-07 23:13 ` Jae Hyun Yoo
2019-10-07 23:13 ` Jae Hyun Yoo
2019-10-07 23:13 ` Jae Hyun Yoo
2019-10-07 23:13 ` [PATCH 1/5] dt-bindings: i2c: aspeed: add buffer and DMA mode transfer support Jae Hyun Yoo
2019-10-07 23:13 ` Jae Hyun Yoo
2019-10-07 23:13 ` Jae Hyun Yoo
2019-10-07 23:13 ` Jae Hyun Yoo
2019-10-08 18:12 ` Brendan Higgins
2019-10-08 18:12 ` Brendan Higgins
2019-10-08 18:12 ` Brendan Higgins
2019-10-08 18:12 ` Brendan Higgins
2019-10-08 18:47 ` Jae Hyun Yoo
2019-10-08 18:47 ` Jae Hyun Yoo
2019-10-08 18:47 ` Jae Hyun Yoo
2019-10-08 18:47 ` Jae Hyun Yoo
2019-10-07 23:13 ` [PATCH 2/5] ARM: dts: aspeed: add I2C buffer mode support Jae Hyun Yoo
2019-10-07 23:13 ` Jae Hyun Yoo
2019-10-07 23:13 ` Jae Hyun Yoo
2019-10-07 23:13 ` Jae Hyun Yoo
2019-10-09 13:32 ` Cédric Le Goater
2019-10-09 13:32 ` Cédric Le Goater
2019-10-09 13:32 ` Cédric Le Goater
2019-10-07 23:13 ` [PATCH 3/5] i2c: aspeed: fix master pending state handling Jae Hyun Yoo
2019-10-07 23:13 ` Jae Hyun Yoo
2019-10-07 23:13 ` Jae Hyun Yoo
2019-10-07 23:13 ` Jae Hyun Yoo
2019-10-08 20:31 ` Brendan Higgins
2019-10-08 20:31 ` Brendan Higgins
2019-10-08 20:31 ` Brendan Higgins
2019-10-08 20:31 ` Brendan Higgins
2019-10-08 21:13 ` Jae Hyun Yoo
2019-10-08 21:13 ` Jae Hyun Yoo
2019-10-08 21:13 ` Jae Hyun Yoo
2019-10-08 21:13 ` Jae Hyun Yoo
2019-10-08 21:54 ` Brendan Higgins
2019-10-08 21:54 ` Brendan Higgins
2019-10-08 21:54 ` Brendan Higgins
2019-10-08 21:54 ` Brendan Higgins
2019-10-08 22:55 ` Jae Hyun Yoo
2019-10-08 22:55 ` Jae Hyun Yoo
2019-10-08 22:55 ` Jae Hyun Yoo
2019-10-08 22:55 ` Jae Hyun Yoo
2019-10-10 5:28 ` Joel Stanley
2019-10-10 5:28 ` Joel Stanley
2019-10-10 5:28 ` Joel Stanley
2019-10-10 5:28 ` Joel Stanley
2019-10-08 22:00 ` Tao Ren
2019-10-08 22:00 ` Tao Ren
2019-10-08 22:00 ` Tao Ren
2019-10-08 22:00 ` Tao Ren
2019-10-08 22:45 ` Jae Hyun Yoo [this message]
2019-10-08 22:45 ` Jae Hyun Yoo
2019-10-08 22:45 ` Jae Hyun Yoo
2019-10-08 22:45 ` Jae Hyun Yoo
2019-10-08 23:15 ` Tao Ren
2019-10-08 23:15 ` Tao Ren
2019-10-08 23:15 ` Tao Ren
2019-10-08 23:28 ` Jae Hyun Yoo
2019-10-08 23:28 ` Jae Hyun Yoo
2019-10-08 23:28 ` Jae Hyun Yoo
2019-10-07 23:13 ` [PATCH 4/5] i2c: aspeed: add buffer mode transfer support Jae Hyun Yoo
2019-10-07 23:13 ` Jae Hyun Yoo
2019-10-07 23:13 ` Jae Hyun Yoo
2019-10-07 23:13 ` Jae Hyun Yoo
2019-10-08 20:12 ` Brendan Higgins
2019-10-08 20:12 ` Brendan Higgins
2019-10-08 20:12 ` Brendan Higgins
2019-10-08 20:12 ` Brendan Higgins
2019-10-08 21:10 ` Jae Hyun Yoo
2019-10-08 21:10 ` Jae Hyun Yoo
2019-10-08 21:10 ` Jae Hyun Yoo
2019-10-08 21:10 ` Jae Hyun Yoo
2019-10-08 23:15 ` Brendan Higgins
2019-10-08 23:15 ` Brendan Higgins
2019-10-08 23:15 ` Brendan Higgins
2019-10-08 23:15 ` Brendan Higgins
2019-10-09 0:08 ` Jae Hyun Yoo
2019-10-09 0:08 ` Jae Hyun Yoo
2019-10-09 0:08 ` Jae Hyun Yoo
2019-10-09 0:08 ` Jae Hyun Yoo
2019-10-07 23:13 ` [PATCH 5/5] i2c: aspeed: add DMA " Jae Hyun Yoo
2019-10-07 23:13 ` Jae Hyun Yoo
2019-10-07 23:13 ` Jae Hyun Yoo
2019-10-07 23:13 ` Jae Hyun Yoo
2019-10-10 8:20 ` [PATCH 0/5] i2c: aspeed: Add buffer and DMA modes support Cédric Le Goater
2019-10-10 18:14 ` Jae Hyun Yoo
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=6f280195-eef7-1fe7-ac42-ad6879ca9838@linux.intel.com \
--to=jae.hyun.yoo@linux.intel.com \
--cc=linux-aspeed@lists.ozlabs.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 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.