Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp117279ybg; Sun, 31 May 2020 18:50:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzIudpbYbqtLWCUG/EhdMXDhTpDdl9C/0uhNrskEKNavypfdMjccuFBI29AxTx8nCQYB3ZV X-Received: by 2002:a05:6402:14d3:: with SMTP id f19mr18572003edx.135.1590976222871; Sun, 31 May 2020 18:50:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590976222; cv=none; d=google.com; s=arc-20160816; b=DHo9yJxNQkFrMNbHXypOL4n0PBchNaYNws5tOHiPA5daa/Hp5Qis+Wg0ApN1xdsbKx V+dcj2i8fnVZsDn9DJI/3lPlpypX+KJ+wZccYQqWOUhi7RMcRQn1Z8JAeoEHFUyc1vqd 9pT/7zIveoQ04trUU0mgDsWltm+hvuNjCZAUnhvG7tmiQL6S3RGSU05Dxv3WA3URKVz/ Lm39olXVVROLS+aZ4dpvkmaUQK1HfIunqM0zX0309dUFAkbn+d+m/exDIj7p/cQr7xEV 1MKoFdDGjf1O9UtLTq33MUruO3MUOplJ5XHYJ7KHE1dPfpranj0uLoHpoJdhaj+/pMrp TkkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:organization:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:ironport-sdr:ironport-sdr; bh=OOLHw+/ERrZVa+IDvnVvkbnpVj3r9QveBU46mmRZ/MU=; b=CisFLSV2LLxSfCq6SN87mag1BCaqjS16VG568QRY5J4fjelgqxzbHd0isUXVhwKOe4 ZZv2ONlg0aXvGl1IA5c4w42Dh4ZvVn+UrWjGqgYjD0lAC4Vcm0kM9G3aZa8wiMDytgPZ jkMuWLm0yoMXP5kCioFAjLx74PKvsJgT1ibTYz84g/vnxi3Ng5oW9Y7s3WGNzlUpbFAv KoZQK3qFG2PnrJZuCgk/d4HCQl5xYQeEiRMLGKZYkoq7AmvkUrPmKiYVbPY/B3Mkn6p8 U2VeM0+Kil1osnkol0AfV2YuJosYjY7bjabQHxVEyfQdWLu/ZHlGWhtvjlLw3+Qo4cya mRDw== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a99si10765505edf.381.2020.05.31.18.50.00; Sun, 31 May 2020 18:50:22 -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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726968AbgFABrM (ORCPT + 99 others); Sun, 31 May 2020 21:47:12 -0400 Received: from mga12.intel.com ([192.55.52.136]:49961 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726555AbgFABrL (ORCPT ); Sun, 31 May 2020 21:47:11 -0400 IronPort-SDR: bnwIKUdM3zFGyjUmHo6alrAQeLildxFQCybqlrLXRd95/AvGmsgfE9vMd6FaLteF1+C9e+xzru 7GbgEgV0XqJA== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 May 2020 18:47:11 -0700 IronPort-SDR: yY+ReLDEh0PbAWeRxdaZMOTuz4lwLRP3yWWA+ziY3HY4jQzQ+eN9wrh0WcZuqOkkUE5afipicH kj+VzC5AOQEQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,459,1583222400"; d="scan'208";a="444115094" Received: from dytagah-mobl.amr.corp.intel.com (HELO localhost) ([10.252.58.236]) by orsmga005.jf.intel.com with ESMTP; 31 May 2020 18:47:08 -0700 Date: Mon, 1 Jun 2020 04:47:07 +0300 From: Jarkko Sakkinen To: Douglas Anderson Cc: Peter Huewe , Andrey Pronin , Stephen Boyd , Arnd Bergmann , Greg Kroah-Hartman , Jason Gunthorpe , linux-integrity@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] tpm_tis_spi: Don't send anything during flow control Message-ID: <20200601014646.GA794847@linux.intel.com> References: <20200528151912.1.Id689a39ce8d1ec6f29f4287277ad977ff4f57d7d@changeid> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200528151912.1.Id689a39ce8d1ec6f29f4287277ad977ff4f57d7d@changeid> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, May 28, 2020 at 03:19:30PM -0700, Douglas Anderson wrote: > During flow control we are just reading from the TPM, yet our spi_xfer > has the tx_buf and rx_buf both non-NULL which means we're requesting a > full duplex transfer. > > SPI is always somewhat of a full duplex protocol anyway and in theory > the other side shouldn't really be looking at what we're sending it > during flow control, but it's still a bit ugly to be sending some > "random" data when we shouldn't. > > The default tpm_tis_spi_flow_control() tries to address this by > setting 'phy->iobuf[0] = 0'. This partially avoids the problem of > sending "random" data, but since our tx_buf and rx_buf both point to > the same place I believe there is the potential of us sending the > TPM's previous byte back to it if we hit the retry loop. > > Another flow control implementation, cr50_spi_flow_control(), doesn't > address this at all. > > Let's clean this up and just make the tx_buf NULL before we call > flow_control(). Not only does this ensure that we're not sending any > "random" bytes but it also possibly could make the SPI controller > behave in a slightly more optimal way. > > NOTE: no actual observed problems are fixed by this patch--it's was > just made based on code inspection. > > Signed-off-by: Douglas Anderson > --- > > drivers/char/tpm/tpm_tis_spi_main.c | 9 ++++----- > 1 file changed, 4 insertions(+), 5 deletions(-) > > diff --git a/drivers/char/tpm/tpm_tis_spi_main.c b/drivers/char/tpm/tpm_tis_spi_main.c > index d96755935529..8d2c581a93c6 100644 > --- a/drivers/char/tpm/tpm_tis_spi_main.c > +++ b/drivers/char/tpm/tpm_tis_spi_main.c > @@ -53,8 +53,6 @@ static int tpm_tis_spi_flow_control(struct tpm_tis_spi_phy *phy, > > if ((phy->iobuf[3] & 0x01) == 0) { > // handle SPI wait states > - phy->iobuf[0] = 0; > - Why this should be removed? /Jarkko