Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1665991pxj; Wed, 19 May 2021 11:00:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzZ9jcxZW1JVt5cESXI76teU+ulYOtzk/G/TAGp2NhKXEDpbePDI5tDMC1onVDFyjSRxpnX X-Received: by 2002:a17:906:6ace:: with SMTP id q14mr378781ejs.79.1621447226007; Wed, 19 May 2021 11:00:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621447225; cv=none; d=google.com; s=arc-20160816; b=kl7/P5v5enYjGnUh4od3e0I6tAqhYdR99zOkjkzvCWDx06PtISgGwhSTlWnKOiuaW+ dGXWarua+Oiw/rmOFMnOWWuZ2QlqeeDdkrqqonR6GlJWks+tH/BkbkxqnxE/vtaPs138 RnNqOjpb51gywlQPd/nUYE4LD0ovQ2NufRtKvG1fu8/qP3QyAbnatyBE5JVReliaISbO tpT4fF5NQU4cDET9DiUfu8vtqyMyCEd3faQmWopGmsC3q2Ugbcij6KW5vZDUkgRer2Pt dhhi+9X5Fv53aU4xJLg7OK5xR99/kR67cb1tSanq0aOBUkJEJZmeCNvM30M0N4uY0KM7 +Pww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:dkim-signature; bh=pkdRjnuTG13nf47V64EPvbETtZfVwRqN7wdxtyB5N0Q=; b=oJb3MiMzxXhppn3fv+Gu3gNmSuXgo9KxAXEa7aOpjWuhz9uj1pktFnE/Uan6ncqSdq 7lBBd4vrhj/6shoTzNRuLP2JET8nuEfx4fOrWtMlI+uZVXJL8kDHqS2xOxQ5pGWQDeDh HT6ipfxzMGhBXY7LyE4jqzW7VNCSoeqhqbqCPFRHBDQjzhwjgyh3JJi1bSfNf/F8Osf9 bE2hf8B3JfECaXH2lKsKDAEAF5h/y5WE3a75qXILiOkUBn87cGi1lg+W1nNSGOW9HRs9 KVL2jIT/xM0m3aWgnjeUitx1ezVi9zS/lbp4JwoH7XWIQVydWdpR0MNtfUWxZGgp1pDh 7SCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kroah.com header.s=fm3 header.b=M3Aexoq+; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b="SFj3Sa/2"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d7si307455ejb.347.2021.05.19.11.00.01; Wed, 19 May 2021 11:00:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kroah.com header.s=fm3 header.b=M3Aexoq+; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b="SFj3Sa/2"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240582AbhERLfW (ORCPT + 99 others); Tue, 18 May 2021 07:35:22 -0400 Received: from new1-smtp.messagingengine.com ([66.111.4.221]:57629 "EHLO new1-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240092AbhERLfV (ORCPT ); Tue, 18 May 2021 07:35:21 -0400 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailnew.nyi.internal (Postfix) with ESMTP id F1C8058055C; Tue, 18 May 2021 07:34:02 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Tue, 18 May 2021 07:34:02 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kroah.com; h= date:from:to:cc:subject:message-id:references:mime-version :content-type:content-transfer-encoding:in-reply-to; s=fm3; bh=p kdRjnuTG13nf47V64EPvbETtZfVwRqN7wdxtyB5N0Q=; b=M3Aexoq+CbUhkC5ZF Af12ClcqnfZWRaJScOAYfoTczY0k4niWVrzvsqydFuM6rMLgZujxx9xZHrN0aZmp RoVw7gkcpajphzjK7yil4A9Tg1ylXqGLUbub8+s6JgQaY19Y0V271EG8ZWbgrHPv jhGmIiMawkfodkDZKopB8+Y4aRIK9Vg0eaWNAnPARjrO/zMVg5cjCkBLLFpiHib3 HtnhM11cT4O94w/1Cu9mkOKBy1BnKRWZbvSkFEIdbrc4EYWPROurbTS3Cn4U+ttb YT+TRXRtZrqxytPZxZul573A2d8jUKMzGG6bRI8DjyYNcnjNg3a9VzpdAbBLWw8p nJHJQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm2; bh=pkdRjnuTG13nf47V64EPvbETtZfVwRqN7wdxtyB5N 0Q=; b=SFj3Sa/2f2Jo7n2qiKHa0Q6HHvzywB/ZYqlsiCIgCjJ6r6HOgqvLYl+jA k8RPdlEXZKkg26/geQvILAO4NBEU2Ngxdv5fC6eAa5d7ToB8spQZpkhdhxg89hDe 0DEWtrSlBZISYoTawE31aDpLle7BzHQvS5Jv8H6JfwikCuGEFBQZlBkwsHntUOOK 7SOO298wOi4t0kufTMQrvJsa4LDQK5Op2fvPb5OvsmQHmeyOl9lsli6uhjZLH0Fx rMGXUSplo3XOyHyBhXeygCkZ4sgbQcdinpSsk16Z2I0mr5jZsUPaODEPMIGx7ve6 etpgDIAidB/8FdyC+PgvKGlHJZeaw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrvdeijedggedtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvffukfhfgggtugfgjgesthekredttddtjeenucfhrhhomhepifhrvghg ucfmjfcuoehgrhgvgheskhhrohgrhhdrtghomheqnecuggftrfgrthhtvghrnhepueehke ehlefffeeiudetfeekjeffvdeuheejjeffheeludfgteekvdelkeduuddvnecukfhppeek fedrkeeirdejgedrieegnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrg hilhhfrhhomhepghhrvghgsehkrhhorghhrdgtohhm X-ME-Proxy: Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 18 May 2021 07:34:02 -0400 (EDT) Date: Tue, 18 May 2021 13:34:00 +0200 From: Greg KH To: Patryk Duda Cc: Benson Leung , Guenter Roeck , linux-kernel@vger.kernel.org, upstream@semihalf.com, stable@vger.kernel.org Subject: Re: [PATCH] platform/chrome: cros_ec_proto: Send command again when timeout occurs Message-ID: References: <20210518090925.15480-1-pdk@semihalf.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, May 18, 2021 at 01:22:30PM +0200, Patryk Duda wrote: > wt., 18 maj 2021 o 11:29 Greg KH napisaƂ(a): > > > > On Tue, May 18, 2021 at 11:09:25AM +0200, Patryk Duda wrote: > > > Sometimes kernel is trying to probe Fingerprint MCU (FPMCU) when it > > > hasn't initialized SPI yet. This can happen because FPMCU is restarted > > > during system boot and kernel can send message in short window > > > eg. between sysjump to RW and SPI initialization. > > > > > > Cc: # 4.4+ > > > Signed-off-by: Patryk Duda > > > --- > > > Fingerprint MCU is rebooted during system startup by AP firmware (coreboot). > > > During cold boot kernel can query FPMCU in a window just after jump to RW > > > section of firmware but before SPI is initialized. The window was > > > shortened to <1ms, but it can't be eliminated completly. > > > > > > Communication with FPMCU (and all devices based on EC) is bi-directional. > > > When kernel sends message, EC will send EC_SPI* status codes. When EC is > > > not able to process command one of bytes will be eg. EC_SPI_NOT_READY. > > > This mechanism won't work when SPI is not initailized on EC side. In fact, > > > buffer is filled with 0xFF bytes, so from kernel perspective device is not > > > responding. To avoid this problem, we can query device once again. We are > > > already waiting EC_MSG_DEADLINE_MS for response, so we can send command > > > immediately. > > > > > > Best regards, > > > Patryk > > > drivers/platform/chrome/cros_ec_proto.c | 12 ++++++++++++ > > > 1 file changed, 12 insertions(+) > > > > > > diff --git a/drivers/platform/chrome/cros_ec_proto.c b/drivers/platform/chrome/cros_ec_proto.c > > > index aa7f7aa77297..3384631d21e2 100644 > > > --- a/drivers/platform/chrome/cros_ec_proto.c > > > +++ b/drivers/platform/chrome/cros_ec_proto.c > > > @@ -279,6 +279,18 @@ static int cros_ec_host_command_proto_query(struct cros_ec_device *ec_dev, > > > msg->insize = sizeof(struct ec_response_get_protocol_info); > > > > > > ret = send_command(ec_dev, msg); > > > + /* > > > + * Send command once again when timeout occurred. > > > + * Fingerprint MCU (FPMCU) is restarted during system boot which > > > + * introduces small window in which FPMCU won't respond for any > > > + * messages sent by kernel. There is no need to wait before next > > > + * attempt because we waited at least EC_MSG_DEADLINE_MS. > > > + */ > > > + if (ret == -ETIMEDOUT) { > > > + dev_warn(ec_dev->dev, > > > + "Timeout to get response from EC. Retrying.\n"); > > > > If a user sees this, what can they do? No need to spam the kernel logs, > > just retry. > User can do nothing about it. I will remove this in next version of patch. > > > > > + ret = send_command(ec_dev, msg); > > > > But wait, why just retry once? Why not 10 times? 100? 1000? How > > about a simple loop here instead, with a "sane" number of retries as a > > max. > EC based devices are designed to respond always or return appropriate > status code > when they can't process command. But this assumes that SPI is always > ready to work. > It's true for Embedded Controller, but not for Fingerprint MCU. So we > can retry once, > in case of sending message, when FPMCU is in narrow window (~1ms) when SPI is > not initialized. > > Every send_command() call can take about 200ms when device is not responding, > so next retry will happen after 200ms, at least. If 200ms is not > enough for FPMCU > to initialize SPI, it's definitely something wrong with FPMCU Ok, then just loop for 2 for this, should make it more obvious. thanks, greg k-h