Linux SPI subsystem development
 help / color / mirror / Atom feed
From: Mark Brown <broonie@kernel.org>
To: Krishna Yarlagadda <kyarlagadda@nvidia.com>
Cc: robh+dt@kernel.org, peterhuewe@gmx.de, jgg@ziepe.ca,
	jarkko@kernel.org, krzysztof.kozlowski+dt@linaro.org,
	linux-spi@vger.kernel.org, linux-tegra@vger.kernel.org,
	linux-integrity@vger.kernel.org, linux-kernel@vger.kernel.org,
	thierry.reding@gmail.com, jonathanh@nvidia.com,
	skomatineni@nvidia.com, ldewangan@nvidia.com
Subject: Re: [Patch V3 1/3] tpm_tis-spi: Support hardware wait polling
Date: Thu, 23 Feb 2023 17:18:56 +0000	[thread overview]
Message-ID: <Y/egACRAp6nKZWdN@sirena.org.uk> (raw)
In-Reply-To: <20230223162635.19747-2-kyarlagadda@nvidia.com>

[-- Attachment #1: Type: text/plain, Size: 1449 bytes --]

On Thu, Feb 23, 2023 at 09:56:33PM +0530, Krishna Yarlagadda wrote:

> +       spi_bus_lock(phy->spi_device->master);
> +
> +       while (len) {

Why?

> +		spi_xfer[0].tx_buf = phy->iobuf;
> +		spi_xfer[0].len = 1;
> +		spi_message_add_tail(&spi_xfer[0], &m);
> +
> +		spi_xfer[1].tx_buf = phy->iobuf + 1;
> +		spi_xfer[1].len = 3;
> +		spi_message_add_tail(&spi_xfer[1], &m);

Why would we make these two separate transfers?

> +		if (out) {
> +			spi_xfer[2].tx_buf = &phy->iobuf[4];
> +			spi_xfer[2].rx_buf = NULL;
> +			memcpy(&phy->iobuf[4], out, transfer_len);
> +			out += transfer_len;
> +		}
> +
> +		if (in) {
> +			spi_xfer[2].tx_buf = NULL;
> +			spi_xfer[2].rx_buf = &phy->iobuf[4];
> +		}

This will use the same buffer for rx and tx if some bug manages to leave
them both set.  That shouldn't be an issue but it's an alarm bell
reading the code.

> index 988aabc31871..b88494e31239 100644
> --- a/include/linux/spi/spi.h
> +++ b/include/linux/spi/spi.h
> @@ -184,8 +184,9 @@ struct spi_device {
>  	u8			chip_select;
>  	u8			bits_per_word;
>  	bool			rt;
> -#define SPI_NO_TX	BIT(31)		/* No transmit wire */
> -#define SPI_NO_RX	BIT(30)		/* No receive wire */
> +#define SPI_NO_TX		BIT(31)		/* No transmit wire */
> +#define SPI_NO_RX		BIT(30)		/* No receive wire */
> +#define SPI_TPM_HW_FLOW		BIT(29)		/* TPM flow control */

Additions to the SPI API should be a separate commit for SPI rather than
merged into a driver change.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

  reply	other threads:[~2023-02-23 17:19 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-23 16:26 [Patch V3 0/3] Tegra TPM driver with HW flow control Krishna Yarlagadda
2023-02-23 16:26 ` [Patch V3 1/3] tpm_tis-spi: Support hardware wait polling Krishna Yarlagadda
2023-02-23 17:18   ` Mark Brown [this message]
2023-02-23 18:41     ` Krishna Yarlagadda
2023-02-23 18:43       ` Mark Brown
2023-02-24 14:16         ` Krishna Yarlagadda
2023-02-24 15:51           ` Mark Brown
2023-02-24 16:21             ` Krishna Yarlagadda
2023-02-23 16:26 ` [Patch V3 2/3] spi: tegra210-quad: set half duplex flag Krishna Yarlagadda
2023-02-23 16:26 ` [Patch V3 3/3] spi: tegra210-quad: Enable TPM wait polling Krishna Yarlagadda
2023-02-23 17:28   ` Mark Brown
2023-02-23 18:46     ` Krishna Yarlagadda
2023-02-23 18:31 ` (subset) [Patch V3 0/3] Tegra TPM driver with HW flow control Mark Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Y/egACRAp6nKZWdN@sirena.org.uk \
    --to=broonie@kernel.org \
    --cc=jarkko@kernel.org \
    --cc=jgg@ziepe.ca \
    --cc=jonathanh@nvidia.com \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=kyarlagadda@nvidia.com \
    --cc=ldewangan@nvidia.com \
    --cc=linux-integrity@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-spi@vger.kernel.org \
    --cc=linux-tegra@vger.kernel.org \
    --cc=peterhuewe@gmx.de \
    --cc=robh+dt@kernel.org \
    --cc=skomatineni@nvidia.com \
    --cc=thierry.reding@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox