From: Jon Hunter <jonathanh@nvidia.com>
To: Shawn N <shawnn@chromium.org>
Cc: Olof Johansson <olof@lixom.net>,
Benson Leung <bleung@chromium.org>,
"Lee Jones" <lee.jones@linaro.org>,
<linux-kernel@vger.kernel.org>,
Doug Anderson <dianders@chromium.org>,
Brian Norris <computersforpeace@gmail.com>,
"Brian Norris" <briannorris@chromium.org>,
Gwendal Grignou <gwendal@chromium.org>,
Enric Balletbo <enric.balletbo@collabora.co.uk>,
Tomeu Vizoso <tomeu.vizoso@collabora.com>,
"linux-tegra@vger.kernel.org" <linux-tegra@vger.kernel.org>
Subject: Re: [PATCH v3] platform/chrome: Use proper protocol transfer function
Date: Tue, 10 Oct 2017 14:35:55 +0100 [thread overview]
Message-ID: <6beb7b8c-f602-112b-73b2-22188dcea28e@nvidia.com> (raw)
In-Reply-To: <CALaWCOM87ikjzK-zFJ7WT37L_w58AwZwC_nq0hNXuzh5x87n5w@mail.gmail.com>
On 26/09/17 00:15, Shawn N wrote:
> On Wed, Sep 20, 2017 at 1:22 PM, Shawn N <shawnn@google.com> wrote:
>> On Tue, Sep 19, 2017 at 11:13 PM, Brian Norris <briannorris@chromium.org> wrote:
>>> Hi,
>>>
>>> On Tue, Sep 19, 2017 at 11:05:38PM -0700, Shawn N wrote:
>>>> This is failing because our EC_CMD_GET_PROTOCOL_INFO host command is
>>>> getting messed up, or the reply buffer is getting corrupted somehow.
>>>>
>>>> ec_dev->proto_version =
>>>> min(EC_HOST_REQUEST_VERSION,
>>>> fls(proto_info->protocol_versions) - 1);
>>>>
>>
>> Checking this closer, the first host command we send after we boot the
>> kernel (EC_CMD_GET_PROTOCOL_INFO) is failing due to protocol error
>> (see 'SPI rx bad data' / 'SPI not ready' on the EC console). Since
>> this doesn't seem to happen on the Chromium OS nyan_big release
>> kernel, I suggest to hook up a logic analyzer and see if the SPI
>> master is doing something bad.
>>
>> The error handling in cros_ec_cmd_xfer_spi() is completely wrong and
>> we return -EAGAIN / EC_RES_IN_PROGRESS, which the caller interprets
>> "the host command was received by the EC and is currently being
>> handled, poll status until completion". So the caller polls status
>> with EC_CMD_GET_COMMS_STATUS, sees no host command is in progress
>> (which is interpreted to mean "the host command I sent previously has
>> now successfully completed"), and returns success. The problem here is
>> that the initial host command was never received at all, and no reply
>> was ever received, so our reply data is all zero.
>>
>> Two things need to be fixed here:
>>
>> 1) Find out why the first host command after boot is failing. Probe
>> SPI pins and see what's going on.
>> 2) Fix error handling so we properly return an error (or properly
>> retry the entire command) when a protocol error occurs (I made some
>> attempt in https://chromium-review.googlesource.com/385080/, probably
>> I should revisit that).
>
> The below patch will fix error handling and will make things mostly
> work on nyan_big, because we'll fall back to V2 protocol after the
> initial failure. But we should still investigate why we're getting
> errors on the first host command. We aren't seeing these errors when
> we send commands from firmware, so I suspect something is wrong in
> kernel SPI HW initialization that causes the first command to fail.
I have been looking into this a bit more and it appears to be timing
related. I found that enabling some debug in the Tegra SPI driver the
problem would go away and seems that adding a delay before sending the
SPI message would also workaround the problem.
Looking back at the Tegra Linux test history [0], it appears that after
v4.10-rc5 [1] I start to see the following message which is the first
indication of some SPI issues ...
cros-ec-spi spi32766.0: packet too long (249 bytes, expected 4)
I attempted to bisect this, but I was not successful because each time
I would ended up somewhere different. I found that even with v4.9 I may
see the issue 1 in 20 times and so I realised that I am not even sure
when the problem really started or if has always been there. It seems
that for older kernels it is harder to reproduce. I am wondering now if
some timing has changed somewhere causing us to see the problem more
frequently with newer kernels?
I see the the cros-ec binding defines the following ...
"google,cros-ec-spi-pre-delay: Some implementations of the EC need a
little time to wake up from sleep before they can receive SPI transfers
at a high clock rate. This property specifies the delay, in usecs,
between the assertion of the CS to the start of the first clock pulse."
I found that adding the following also worked around the problem ...
diff --git a/arch/arm/boot/dts/tegra124-nyan.dtsi b/arch/arm/boot/dts/tegra124-nyan.dtsi
index 5cf987b5401e..0baa6bfc0f36 100644
--- a/arch/arm/boot/dts/tegra124-nyan.dtsi
+++ b/arch/arm/boot/dts/tegra124-nyan.dtsi
@@ -317,6 +317,7 @@
interrupts = <TEGRA_GPIO(C, 7) IRQ_TYPE_LEVEL_LOW>;
reg = <0>;
+ google,cros-ec-spi-pre-delay = <10>;
google,cros-ec-spi-msg-delay = <2000>;
i2c-tunnel {
I have tried 50 boots with the above and I have seen no SPI failures
on boot.
I did look to see if it is possible to probe the SPI signals with a
scope but from the schematics I am not sure if they are accessible or
buried in the PCB.
Is it possible that Tegra is sending the SPI message too soon for the
EC?
Cheers
Jon
[0] https://nvtb.github.io/linux/
[1] https://nvtb.github.io/linux/test_v4.10-rc5/20170123023102/boot/tegra124-nyan-big/tegra124-nyan-big/tegra_defconfig_log.txt
--
nvpublic
next prev parent reply other threads:[~2017-10-10 13:39 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-08 20:50 Brian Norris
2017-09-11 19:48 ` Benson Leung
2017-09-19 13:44 ` Jon Hunter
2017-09-19 14:09 ` Shawn N
2017-09-19 16:39 ` Jon Hunter
2017-09-19 17:03 ` Shawn N
2017-09-19 17:14 ` Brian Norris
2017-09-20 6:05 ` Shawn N
2017-09-20 6:13 ` Brian Norris
2017-09-20 20:22 ` Shawn N
2017-09-25 23:15 ` Shawn N
2017-09-26 15:40 ` Jon Hunter
2017-11-14 15:56 ` Jon Hunter
2017-11-14 15:59 ` Shawn N
2017-10-10 13:35 ` Jon Hunter [this message]
2017-10-10 15:33 ` Shawn N
2017-10-10 16:52 ` Doug Anderson
2017-11-07 11:28 ` Jon Hunter
2017-11-07 17:22 ` Doug Anderson
2017-11-08 10:20 ` Jon Hunter
2017-11-08 16:45 ` Doug Anderson
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=6beb7b8c-f602-112b-73b2-22188dcea28e@nvidia.com \
--to=jonathanh@nvidia.com \
--cc=bleung@chromium.org \
--cc=briannorris@chromium.org \
--cc=computersforpeace@gmail.com \
--cc=dianders@chromium.org \
--cc=enric.balletbo@collabora.co.uk \
--cc=gwendal@chromium.org \
--cc=lee.jones@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tegra@vger.kernel.org \
--cc=olof@lixom.net \
--cc=shawnn@chromium.org \
--cc=tomeu.vizoso@collabora.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®