public inbox for linux-aspeed@lists.ozlabs.org
 help / color / mirror / Atom feed
From: Tao Ren <taoren@fb.com>
To: linux-aspeed@lists.ozlabs.org
Subject: [PATCH] i2c: aspeed: fix master pending state handling
Date: Thu, 10 Oct 2019 23:11:36 +0000	[thread overview]
Message-ID: <5ce20a28-21ed-ff0c-9e31-bcac3cd7a5fb@fb.com> (raw)
In-Reply-To: <637d4b8b-5113-b07b-f99f-ce66dbe6948c@linux.intel.com>

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.


Cheers,

Tao

  reply	other threads:[~2019-10-10 23:11 UTC|newest]

Thread overview: 15+ 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 [this message]
2019-10-10 23:16       ` Jae Hyun Yoo
2019-10-10 23:24         ` Tao Ren
2019-10-10 23:29 ` Tao Ren
2019-10-10 23:52   ` Jae Hyun Yoo
2019-10-16 19:20     ` Brendan Higgins
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=5ce20a28-21ed-ff0c-9e31-bcac3cd7a5fb@fb.com \
    --to=taoren@fb.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox