Received: by 10.223.164.221 with SMTP id h29csp3893355wrb; Tue, 10 Oct 2017 09:55:09 -0700 (PDT) X-Received: by 10.98.32.212 with SMTP id m81mr14367241pfj.227.1507654509633; Tue, 10 Oct 2017 09:55:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507654509; cv=none; d=google.com; s=arc-20160816; b=uHMl1dajfS8+lGJgwtbsl3+KS8iSRA4SaYAo/7cdqGQm3KimP1CXq8UGK6+jX9Jb3+ Ic2KYna6wtbR0LuEx+J5oB/KoP23k+V8XR/n2q+KeIPSlnHgW5fEcfdVUEK/7XlzPwV1 knu7nk6+GxsGfSyM1wX02Ngi6JnRgnaEHeQLyhik8/DA3lVXNf4trDUB6rwv4j+x/QI4 qqWarLf01z16d8i7EfvUUf4KPgTAzk3OWPy81530a7Rpd1Aa5GYKmiz3ruUgfyAA2XJK MeqCd35nyKTY++Ygz7eDz2pRHqj2Z4pK1/AQpcRF2TyzYKwuUPnv6OA3JnjHXF5GOkb6 bl6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature:dkim-signature :arc-authentication-results; bh=ikR/rs75tUF21awjT5akvtGvp0w2lh/t6WuX/foCPWI=; b=cjk9dh2EZqyh/7V57AzoYh1jDu0Th4Pxv6AQN1swV8+Ikwt/3hELRD2fDXOVEbVvzf iyNYfMN8VBrdeaXIF62fRSNPpuk1WP3B/5aZiIOSWaEFolNLtB+ZgjjmrQdAdsWA2rL6 lbDYuJ5gBxx1HBMbqNTwMnRqDDTuz4s5/RRgRIl+uxH/72fQE9oRTEvkRA96f23a5Ayi 0VWzVyC4pMV8b0iXukGsQdb1uXAGl5Sawt79qZrujGEKpllTb68wIklHLOfeuFkp9O8t U3WX+ttJUfs7hQOa6sYumGR6M8TTtaSvQNPT2BH327ApLyH6xBxypOcIYRvDFC7JlrXv KNww== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@google.com header.s=20161025 header.b=ZU8GIsFC; dkim=fail header.i=@chromium.org header.s=google header.b=FJCsMirD; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l5si6308689plt.544.2017.10.10.09.54.55; Tue, 10 Oct 2017 09:55:09 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@google.com header.s=20161025 header.b=ZU8GIsFC; dkim=fail header.i=@chromium.org header.s=google header.b=FJCsMirD; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932472AbdJJQxD (ORCPT + 99 others); Tue, 10 Oct 2017 12:53:03 -0400 Received: from mail-qt0-f170.google.com ([209.85.216.170]:47054 "EHLO mail-qt0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932075AbdJJQxB (ORCPT ); Tue, 10 Oct 2017 12:53:01 -0400 Received: by mail-qt0-f170.google.com with SMTP id 1so13032995qtn.3 for ; Tue, 10 Oct 2017 09:53:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=ikR/rs75tUF21awjT5akvtGvp0w2lh/t6WuX/foCPWI=; b=ZU8GIsFC4j7r/IJ6TuMCmuy7YZzCy1LZL1BqkRKaPXvV4Ydeooew5KToAAs5jzzsh7 KIxOCXlHYyOy7A17udxIJ0iRFhSAuv7uIF1neV5QCU9SxDcCNRDBXuj9/coDALbeJBOp ILC7t8sSaes8plCPWAYYzSuBuypg38vq2WisF118kw3G5qhFLESahCJFqENHGF//i0Wl wy2EPkc/jtNLEpTWnW4/V1kyrpnXhGKeXhXj5yq74rb38P5tucho1cNWtiKqGfm4r+lq uPGTm4ZMlW3Ocu8zVyRQ2vAMQWXfVilL8IvMrus0PbvLKgLA8XT4UqMLdwVRes0zvJm9 3U2Q== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=ikR/rs75tUF21awjT5akvtGvp0w2lh/t6WuX/foCPWI=; b=FJCsMirDzzBvZz1XE2HHG3CCV5brx/glEiyM+KmNpfzl2GdO6xLRzX97HuWxVJ1o4h bTUd6RM+4csyDq8UDqE7atMvBCBsQbRwPpqhqPJnjDnRpR+UpxYUmHKaF38O0Ekm92L4 CyEsZbXmcU5m8UNwLMSippDXcIEjZ70P3d5AU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=ikR/rs75tUF21awjT5akvtGvp0w2lh/t6WuX/foCPWI=; b=BslXHN7mqfFpBwh5WpNvk5dK78U0rDior00YHLZ7PW20g8bIbTLw0GY59N0yik8/Jc r74FnggjR7++aBEjV2ErYEnxCkFFoLhnXgib5R4TQkHyfUpZxpt4pyX/7XJD4bZ8jy3T jsd0modmxZvjPI8F1cBW5Gk0qULt+0Nbazv7htFBdffsfXUi9mZoN1UdIeJZyp9iUlGV rmELssQoTm7MgXelO7H7qckXXeE+ui3D296me4JJUyovRDqq2/PjmVKRaXD3XTWJO8Nb AhG66MUw834TPL50TepCc6Erww1tw9NK4IDsL1tZmQPBuxXOZ31uNhYvQj2op9nTTB/s 7Csg== X-Gm-Message-State: AMCzsaWoGMfAvL4pWufYsWHFm2MrjAJvPEfM9BXClGIjT6zAMEiLmI7E em7QKkOOExhlZWjB4DzOVpKuIDn4qhX1D0jrLcpPeQ== X-Google-Smtp-Source: AOwi7QDsfku3WSbNV+4+e3ss94Ddn4twxCLa5y9XmOYisUzNckIuLO0j+a4XICjRp58bysEJIvXghYIfu6EeC5gp7Vg= X-Received: by 10.37.189.134 with SMTP id f6mr2495045ybh.262.1507654379966; Tue, 10 Oct 2017 09:52:59 -0700 (PDT) MIME-Version: 1.0 Received: by 10.37.219.129 with HTTP; Tue, 10 Oct 2017 09:52:59 -0700 (PDT) In-Reply-To: References: <20170908205011.77986-1-briannorris@chromium.org> <02aa65e7-e967-055b-2af3-2e9b6ef77935@nvidia.com> <20170919171401.GA10968@google.com> <20170920061317.GB13616@google.com> <6beb7b8c-f602-112b-73b2-22188dcea28e@nvidia.com> From: Doug Anderson Date: Tue, 10 Oct 2017 09:52:59 -0700 X-Google-Sender-Auth: WcNW1Ip_Umz8irgAL2L_pYsMfFA Message-ID: Subject: Re: [PATCH v3] platform/chrome: Use proper protocol transfer function To: Shawn N Cc: Jon Hunter , Olof Johansson , Benson Leung , Lee Jones , "linux-kernel@vger.kernel.org" , Brian Norris , Brian Norris , Gwendal Grignou , Enric Balletbo , Tomeu Vizoso , "linux-tegra@vger.kernel.org" , Alexandru M Stan Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On Tue, Oct 10, 2017 at 8:33 AM, Shawn N wrote: >> 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 = ; >> 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? > > I have not worked much with the cros_ec stm32 SPI host interface, but > I think it's possible. Also note that we define > "google,cros-ec-spi-pre-delay = <30>;" for the veyron family of > devices, which also use an stm32-family embedded controller. Some of > the folks on cc worked more on veyron and may have more insight. Alex is the expert here, but basically we enabled hibernation on the EC for veyron so it needed a bunch of extra time to wakeup. Before hibernation there was no known case where the delay was needed as far as I understand. I don't think we had hibernation on tegra. It's _possible_ that we sometimes need a delay even on tegra, but I'm not sure. It's also possible that the extra delay just shifts things around a little bit and changes the timing. Possibly at boot the system is always extra busy and adding the 10 us delay is enough to "reliably" get your transfer to happen at a non-busy time. It would be interesting to see of a 10us delay _before_ asserting chip select fixed things just as well. If a delay before asserting chip select fixes things as well as a delay after asserting chip select then you're probably just pushing things around and not doing a real fix. One issue I _know_ we have is that we sometimes drop EC packets on the floor because we get interrupted midway through the transfer and the EC gives up on us before we get context switched back in. I think this is more common at suspend/resume and at boot when the system is typically very busy. That case can actually be made _worse_ by the "cros-ec-spi-pre-delay", as described in . Even when we removed delay on rk3399-gru-* we could still sometimes see transfer errors and the agreed upon "fix" for this is to do the transfer in a higher priority context. Some details are in the (unfortunately private) , but to copy the important bits from the bug:: >From Mark Brown (upstream SPI maintainer) as long as there is no contention on this SPI bus (there isn't for us) the transfer will happen in the context of the calling process. That means "bumping" the priority would work. ...but as per Brian bumping the priority is ugly and we need to make sure we don't conflict with userspace. One solution (inspired by Guenter) is to just _always_ use a high priority worker to do the transfer and just block waiting for the worker to finish. This should be easy, reliable, and clean even if it is slightly awkward. This also shouldn't be too hard to do, we think. NOTE: a really truly long term fix for this is to change the protocol to have reliably retries. That's planned but (as far as I can tell) stalled. Details in the bug > I'm still not clear on why we see an error only on the first > transaction after boot. In this case, the embedded controller > previously handled host commands from firmware just fine, and the > handoff between firmware and the kernel shouldn't be significant, from > the EC point of view. If host command timing is consistent from the > master, I would expect to see some constant error rate, eg. some > chance any host command will fail, rather than the first host command > always failing. The AP itself is often quite busy at boot and so the timings for everything change. That could easily explain the problems. -Doug From 1580885207736108229@xxx Tue Oct 10 15:33:39 +0000 2017 X-GM-THRID: 1578006392712496529 X-Gmail-Labels: Inbox,Category Forums