From: Tao Ren <taoren@fb.com>
To: Jae Hyun Yoo <jae.hyun.yoo@linux.intel.com>,
Brendan Higgins <brendanhiggins@google.com>,
Wolfram Sang <wsa@the-dreams.de>,
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>, Cedric Le Goater <clg@kaod.org>
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] i2c: aspeed: fix master pending state handling
Date: Thu, 10 Oct 2019 23:24:45 +0000 [thread overview]
Message-ID: <dd0c44f7-4e90-998b-e8c7-d272c593f55c@fb.com> (raw)
In-Reply-To: <69296b93-8fc6-c056-ab9b-ae190dc5eea1@linux.intel.com>
On 10/10/19 4:16 PM, Jae Hyun Yoo wrote:
> On 10/10/2019 4:11 PM, Tao Ren wrote:
>> On 10/10/19 3:04 PM, Jae Hyun Yoo wrote:
>>> On 10/10/2019 2:20 PM, Tao Ren wrote:
>>>> On 10/9/19 2:20 PM, Jae Hyun Yoo wrote:
>>> [...]
>>>>> /*
>>>>> * If a peer master starts a xfer immediately after it queues a
>>>>> - * master command, change its state to 'pending' then H/W will
>>>>> - * continue the queued master xfer just after completing the
>>>>> - * slave mode session.
>>>>> + * master command, clear the queued master command and change
>>>>> + * its state to 'pending'. To simplify handling of pending
>>>>> + * cases, it uses S/W solution instead of H/W command queue
>>>>> + * handling.
>>>>> */
>>>>> if (unlikely(irq_status & ASPEED_I2CD_INTR_SLAVE_MATCH)) {
>>>>> + writel(readl(bus->base + ASPEED_I2C_CMD_REG) &
>>>>> + ~ASPEED_I2CD_MASTER_CMDS_MASK,
>>>>> + bus->base + ASPEED_I2C_CMD_REG);
>>>>
>>>> Sorry for the late comments (just noticed this line while testing the patch):
>>>>
>>>> I assume this line is aimed at stopping the running master commands, but as per
>>>> AST2500 datasheet, it's NOP to write 0 to MASTER_STOP/MASTER_RX/MASTER_TX bits.
>>>> Maybe all we need is writing 1 to MASTER_STOP field?
>>>
>>> There could be two pending cases:
>>> 1. Master goes to pending before it triggers a command if a slave
>>> operation is already initiated.
>>> 2. Master goes to pending after it triggered a command if a peer
>>> master immediately sends something just after the master command
>>> triggering.
>>>
>>> Above code is for the latter case. H/W handles the case priority based
>>> so the slave event will be handled first, and then the master command
>>> will be handled when the slave operation is completed. Problem is,
>>> this H/W shares the same buffer for master and slave operations so
>>> it's unreliable. Above code just removes the master command from the
>>> command register to prevent this H/W command handling of pending events.
>>> Instead, it restarts the master command using a call of aspeed_i2c_do_start when the slave operation is completed.
>>
>> Thanks for the clarify, Jae. I mean clearing these bits has no effect to
>> hardware according to aspeed datasheet; in other word, master command cannot
>> be removed from command register by this statement.
>>
>> For example, below is the description for MASTER_STOP_CMD(I2CD14, bit 5):
>>
>> 0: NOP
>> 1: Issue Master Stop Command
>> This register will be automatically cleared by H/W when Stop Command has
>> been issues.
>
> It's removing before H/W fetches the the command so the pending command
> isn't cleared by H/W at the timing. If we send a stop command at here, the bus will be messed up.
I see. I didn't know we could clear the bits before hardware fetches them.
Cheers,
Tao
_______________________________________________
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-10 23:24 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-09 21:20 [PATCH] i2c: aspeed: fix master pending state handling Jae Hyun Yoo
2019-10-10 0:32 ` Brendan Higgins
2019-10-10 1:26 ` Tao Ren
2019-10-10 6:37 ` Wolfram Sang
2019-10-10 6:48 ` Joel Stanley
2019-10-10 18:22 ` Jae Hyun Yoo
2019-10-10 21:20 ` Tao Ren
2019-10-10 22:04 ` Jae Hyun Yoo
2019-10-10 23:11 ` Tao Ren
2019-10-10 23:16 ` Jae Hyun Yoo
2019-10-10 23:24 ` Tao Ren [this message]
2019-10-10 23:29 ` Tao Ren
2019-10-10 23:52 ` Jae Hyun Yoo
2019-10-21 12:09 ` Wolfram Sang
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=dd0c44f7-4e90-998b-e8c7-d272c593f55c@fb.com \
--to=taoren@fb.com \
--cc=andrew@aj.id.au \
--cc=benh@kernel.crashing.org \
--cc=brendanhiggins@google.com \
--cc=clg@kaod.org \
--cc=devicetree@vger.kernel.org \
--cc=jae.hyun.yoo@linux.intel.com \
--cc=joel@jms.id.au \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-aspeed@lists.ozlabs.org \
--cc=linux-i2c@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=openbmc@lists.ozlabs.org \
--cc=robh+dt@kernel.org \
--cc=wsa@the-dreams.de \
/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;
as well as URLs for NNTP newsgroup(s).