From: Lee Jones <lee.jones@linaro.org>
To: Brian Norris <briannorris@chromium.org>
Cc: Benson Leung <bleung@chromium.org>,
Olof Johansson <olof@lixom.net>,
linux-kernel@vger.kernel.org,
Shawn Nematbakhsh <shawnn@chromium.org>,
Jon Hunter <jonathanh@nvidia.com>,
Alexandru Stan <amstan@chromium.org>,
Matthias Kaehlcke <mka@chromium.org>
Subject: Re: [PATCH] mfd: cros_ec: retry commands when EC is known to be busy
Date: Wed, 23 May 2018 06:57:17 +0100 [thread overview]
Message-ID: <20180523055717.GR5130@dell> (raw)
In-Reply-To: <20180523002310.87011-1-briannorris@chromium.org>
On Tue, 22 May 2018, Brian Norris wrote:
> Commit 001dde9400d5 ("mfd: cros ec: spi: Fix "in progress" error
> signaling") pointed out some bad code, but its analysis and conclusion
> was not 100% correct.
>
> It *is* correct that we should not propagate result==EC_RES_IN_PROGRESS
> for transport errors, because this has a special meaning -- that we
> should follow up with EC_CMD_GET_COMMS_STATUS until the EC is no longer
> busy. This is definitely the wrong thing for many commands, because
> among other problems, EC_CMD_GET_COMMS_STATUS doesn't actually retrieve
> any RX data from the EC, so commands that expected some data back will
> instead start processing junk.
>
> For such commands, the right answer is to either propagate the error
> (and return that error to the caller) or resend the original command
> (*not* EC_CMD_GET_COMMS_STATUS).
>
> Unfortunately, commit 001dde9400d5 forgets a crucial point: that for
> some long-running operations, the EC physically cannot respond to
> commands any more. For example, with EC_CMD_FLASH_ERASE, the EC may be
> re-flashing its own code regions, so it can't respond to SPI interrupts.
> Instead, the EC prepares us ahead of time for being busy for a "long"
> time, and fills its hardware buffer with EC_SPI_PAST_END. Thus, we
> expect to see several "transport" errors (or, messages filled with
> EC_SPI_PAST_END). So we should really translate that to a retryable
> error (-EAGAIN) and continue sending EC_CMD_GET_COMMS_STATUS until we
> get a ready status.
>
> IOW, it is actually important to treat some of these "junk" values as
> retryable errors.
>
> Together with commit 001dde9400d5, this resolves bugs like the
> following:
>
> 1. EC_CMD_FLASH_ERASE now works again (with commit 001dde9400d5, we
> would abort the first time we saw EC_SPI_PAST_END)
> 2. Before commit 001dde9400d5, transport errors (e.g.,
> EC_SPI_RX_BAD_DATA) seen in other commands (e.g.,
> EC_CMD_RTC_GET_VALUE) used to yield junk data in the RX buffer; they
> will now yield -EAGAIN return values, and tools like 'hwclock' will
> simply fail instead of retrieving and re-programming undefined time
> values
>
> Fixes: 001dde9400d5 ("mfd: cros ec: spi: Fix "in progress" error signaling")
> Signed-off-by: Brian Norris <briannorris@chromium.org>
> ---
> drivers/mfd/cros_ec_spi.c | 24 ++++++++++++++++++++----
> drivers/platform/chrome/cros_ec_proto.c | 2 ++
> 2 files changed, 22 insertions(+), 4 deletions(-)
I'm convinced.
Applied, thanks.
--
Lee Jones [李琼斯]
Linaro Services Technical Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
prev parent reply other threads:[~2018-05-23 5:57 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-23 0:23 [PATCH] mfd: cros_ec: retry commands when EC is known to be busy Brian Norris
2018-05-23 5:57 ` Lee Jones [this message]
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=20180523055717.GR5130@dell \
--to=lee.jones@linaro.org \
--cc=amstan@chromium.org \
--cc=bleung@chromium.org \
--cc=briannorris@chromium.org \
--cc=jonathanh@nvidia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mka@chromium.org \
--cc=olof@lixom.net \
--cc=shawnn@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;
as well as URLs for NNTP newsgroup(s).