From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 173FC41A8F; Fri, 6 Sep 2024 09:47:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725616076; cv=none; b=hLN//DwYO7qg3lg4bo1DWHy9S6RWeOaCXmweyukif4L3RJafFhf4GLKve2EHRSfQaz2+lMGPALzAcXJ/pqUQ2Nlw/9/RBZnGSWq728uy4euNpJCDL44gS4HSLNWwLMw3sEG+mr39ImopjOYDQgGpu/6Zq90o7WXHG1Ljul8T8gE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725616076; c=relaxed/simple; bh=t9WXDI7C8MEWM9cGLSJKb0IC5/+Pqc2jbnUhHiU9H6w=; h=Mime-Version:Content-Type:Date:Message-Id:Cc:Subject:From:To: References:In-Reply-To; b=bEAX0XWv9NkVrZn90ojkm0/bVQcOUimgKkBPcotyVa4hy2qqGDPEmJHhV0Z5iu9xrC5AsWFwoBlKIK55GJjQNf9yJgTkVV1UxGprS7J3iKUZkqfWtbgWdZWV56wdePKrALLpHqmtFx2+/X94LVFFHu7yHIrPunmuuvLIi332H0w= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=UKWUHgCG; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="UKWUHgCG" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 10134C4CEC4; Fri, 6 Sep 2024 09:47:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1725616075; bh=t9WXDI7C8MEWM9cGLSJKb0IC5/+Pqc2jbnUhHiU9H6w=; h=Date:Cc:Subject:From:To:References:In-Reply-To:From; b=UKWUHgCG8Vo5woHikdETAfFMbJBCI9KKfz4Yco1Y3ppfYpiTF7wCeqPTKQq4449HA XGpDwuycHRKwINBOzccFgRmAbu+Jcsv2mxAQaS76P553VWzZzGpB0UCIPWpuAkEoLh RYTkf+cy5tRp495ZKP77qkgx0HdUHi7zxfCjr7A7WCfY2JIwF9Z4UnQUEhk/pVsmRx WKDlGg6jrxdknh1PhlmWoPiAfAQ4VhfQ2TvdeZUJ9j9TCIgokjYj5LvN7xD3TNIgnS AHQ4mFIqr1INC5v9QmbSpWYl9374JXhdvk28Rf1UZ/GRyAENG7x6obPqLuerctNhDk AbxZuePqYpo3w== Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Fri, 06 Sep 2024 12:47:51 +0300 Message-Id: Cc: , , "Stefan Berger" Subject: Re: [PATCH RFC 1/2] tpm: tpm_tis_spi: Ensure SPI mode 0 From: "Jarkko Sakkinen" To: "Stefan Wahren" , "Peter Huewe" , "Jason Gunthorpe" X-Mailer: aerc 0.18.2 References: <20240906060947.4844-1-wahrenst@gmx.net> <20240906060947.4844-2-wahrenst@gmx.net> In-Reply-To: <20240906060947.4844-2-wahrenst@gmx.net> On Fri Sep 6, 2024 at 9:09 AM EEST, Stefan Wahren wrote: > According to TCG PC Client Platform TPM Profile (PTP) Specification > only SPI mode 0 is supported. In order to ensure the SPI controller > supports the necessary settings, call spi_setup() and bail out > as soon as possible in error case. > > This change should affect all supported TPM SPI devices, because > tpm_tis_spi_probe is either called direct or indirectly. > > Signed-off-by: Stefan Wahren > --- > drivers/char/tpm/tpm_tis_spi_main.c | 11 +++++++++++ > 1 file changed, 11 insertions(+) > > diff --git a/drivers/char/tpm/tpm_tis_spi_main.c b/drivers/char/tpm/tpm_t= is_spi_main.c > index 61b42c83ced8..e62d297b040e 100644 > --- a/drivers/char/tpm/tpm_tis_spi_main.c > +++ b/drivers/char/tpm/tpm_tis_spi_main.c > @@ -248,6 +248,17 @@ static int tpm_tis_spi_write_bytes(struct tpm_tis_da= ta *data, u32 addr, > int tpm_tis_spi_init(struct spi_device *spi, struct tpm_tis_spi_phy *phy= , > int irq, const struct tpm_tis_phy_ops *phy_ops) > { > + int ret; > + > + spi->mode &=3D ~SPI_MODE_X_MASK; > + spi->mode |=3D SPI_MODE_0; > + > + ret =3D spi_setup(spi); > + if (ret < 0) { > + dev_err(&spi->dev, "SPI setup failed: %d\n", ret); > + return ret; > + } > + > phy->iobuf =3D devm_kmalloc(&spi->dev, SPI_HDRSIZE + MAX_SPI_FRAMESIZE,= GFP_KERNEL); > if (!phy->iobuf) > return -ENOMEM; > -- > 2.34.1 Why? BR, Jarkko