Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp3741128rwd; Mon, 22 May 2023 20:01:04 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5SLw0LKOJG0wuu8q0/GIsn4iQSAHTzIh+4Zssx/jkVxrXWEWIVmGeSoRXJX92Vr2Z1vSIM X-Received: by 2002:a17:902:f551:b0:1ae:5c72:d63c with SMTP id h17-20020a170902f55100b001ae5c72d63cmr15980228plf.11.1684810864104; Mon, 22 May 2023 20:01:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684810864; cv=none; d=google.com; s=arc-20160816; b=YLo2cEfaIncxf/8LToe00v8nprDlSeBz4qwbiVS416UGBiGYxu3QQpCuBciez0xvCX U85PYewrse5D03doI43A+1LPub0EYRDCaShapw7Z1pTa/qWvr91qpYNudyrnz6QCdT9C 02q+SDBXIzApWR2pT1kWLQO4X68Cc+o62o49SY6G8V30pxwRCGrLbSOxuC/tqtaBMi4p Hy9cIrOYN01iELrwJ5IUr/OGIGrd4EQWs3mjki/uW7gByEH9pOH+GfezBBWBTwF4hhs1 6+kROdcY+wAAiIF7Icol2d0kHqxM3gisoXH/AxUak9RgmfCVItljd9MwWab5ZXL4A+aT Ek9A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=KbqQ+demneKBOyMJB9R268nPrGCu+xjcRnpIk9L/22Q=; b=RorDYKUuvChPiBHKHqDmQ6X7eoRzbiuMaGvVc2hPsyf8WZALkNj8RiolDWQa5S82tW Rg6ionlzgFxFwwM775QEnhZaDowXA1fO3RaSnMrBzKiMPfltRsTyzB3Jql51dYy9XxW/ Y60p1cd6joMgmuAt8y+WeM018Btt9/vrxcZ5hm3m8KU9HziPvjl8xHikYjpXEq6y0cTR bDBBhe8JOU6Jj3xj+FQlZ15u0Q/4gJYO8N68M44qMMYnPDReQ1faXRATIHI9v/ex7Ogf b50wA2X/PAnD7NcwalApEyC7/isxGUMBLADyIeLxHYLYuMu9sV4qbQuCOSeW52KCInrI 1h0g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h11-20020a170902b94b00b001afb057c053si1567147pls.64.2023.05.22.20.00.51; Mon, 22 May 2023 20:01:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234659AbjEWCyX (ORCPT + 99 others); Mon, 22 May 2023 22:54:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57766 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229605AbjEWCyV (ORCPT ); Mon, 22 May 2023 22:54:21 -0400 Received: from smtp.cecloud.com (unknown [1.203.97.240]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 7F78ECA; Mon, 22 May 2023 19:54:20 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by smtp.cecloud.com (Postfix) with ESMTP id A3FFB900114; Tue, 23 May 2023 10:54:19 +0800 (CST) X-MAIL-GRAY: 0 X-MAIL-DELIVERY: 1 X-ANTISPAM-LEVEL: 2 X-ABS-CHECKED: 0 Received: from localhost.localdomain (unknown [111.48.58.11]) by smtp.cecloud.com (postfix) whith ESMTP id P2917246T281457863946608S1684810458725600_; Tue, 23 May 2023 10:54:19 +0800 (CST) X-IP-DOMAINF: 1 X-UNIQUE-TAG: X-RL-SENDER: shaopeijie@cestc.cn X-SENDER: shaopeijie@cestc.cn X-LOGIN-NAME: shaopeijie@cestc.cn X-FST-TO: pmenzel@molgen.mpg.de X-RCPT-COUNT: 6 X-SENDER-IP: 111.48.58.11 X-ATTACHMENT-NUM: 0 X-System-Flag: 0 From: shaopeijie@cestc.cn To: pmenzel@molgen.mpg.de Cc: jarkko@kernel.org, peterhuewe@gmx.de, jgg@ziepe.ca, linux-integrity@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: Re: [PATCH v2] tpm_tis_spi: fix:release chip select when flow control fails Date: Tue, 23 May 2023 10:54:08 +0800 Message-Id: <20230523025408.4319-1-shaopeijie@cestc.cn> X-Mailer: git-send-email 2.39.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Thank you, Paul. >Dear Peijie, > > >Thank you for your patch. > >The fix: tag in your commit message summary is uncommon. I suggest: > >> tpm_tis_spi: Release chip select when flow control fails > I will change it in v3 version. > >Am 22.05.23 um 09:01 schrieb shaopeijie@cestc.cn: >> From: Peijie Shao >> >> The failure paths in tpm_tis_spi_transfer() do not deactivate >> chip select. Send an empty message (cs_select == 0) to overcome >> this. > >Does the standard require to deactivate it? Yes. , section 6.4.2 Electrical Specification, Figure 4 Timing Diagram, describes the timing. Moreover, when multi devices are sharing with the same SPI bus, only one cs can be activated simultaneously. If two or more cs are activated, corresponding devices may response at same time, cause bus conflicts. > >A note on your test setup would be nice to have in the commit message. > >> Signed-off-by: Peijie Shao >> --- >> Changes since v1: >> 1. Deactive cs all of the failure path, not only flow control. > >Deactivate Sorry, will be fixed in v3 version. > > >Kind regards, > >Paul > > >> 2. change and update comments. >> --- >> drivers/char/tpm/tpm_tis_spi_main.c | 8 ++++++++ >> 1 file changed, 8 insertions(+) >> >> diff --git a/drivers/char/tpm/tpm_tis_spi_main.c b/drivers/char/tpm/tpm_tis_spi_main.c >> index 1f5207974..9bfaba092 100644 >> --- a/drivers/char/tpm/tpm_tis_spi_main.c >> +++ b/drivers/char/tpm/tpm_tis_spi_main.c >> @@ -136,6 +136,14 @@ int tpm_tis_spi_transfer(struct tpm_tis_data *data, u32 addr, u16 len, >> } >> >> exit: >> + if (ret < 0) { >> + /* Deactivate chip select */ >> + memset(&spi_xfer, 0, sizeof(spi_xfer)); >> + spi_message_init(&m); >> + spi_message_add_tail(&spi_xfer, &m); >> + spi_sync_locked(phy->spi_device, &m); >> + } >> + >> spi_bus_unlock(phy->spi_device->master); >> return ret; >> } Peijie, Shao