Re: [Patch V5 2/3] tpm_tis-spi: Support hardware wait polling

Jason Gunthorpe
2023-02-28T12:28:16Z

On Tue, Feb 28, 2023 at 04:36:26AM +0200, Jarkko Sakkinen wrote:
> On Mon, Feb 27, 2023 at 05:37:01PM +0530, Krishna Yarlagadda wrote:
> > TPM devices raise wait signal on last addr cycle. This can be detected
> > by software driver by reading MISO line on same clock which requires
> > full duplex support. In case of half duplex controllers wait detection
> > has to be implemented in HW.
> > Support hardware wait state detection by sending entire message and let
> > controller handle flow control.
>
> When a is started sentence with the word "support" it translates to "I'm
> too lazy to write a proper and verbose description of the implementation"
> :-)
>
> It has some abstract ideas of the implementation, I give you that, but do
> you think anyone ever will get any value of reading that honestly? A bit
> more concrette description of the change helps e.g. when bisecting bugs.

I would expect SPI_TPM_HW_FLOW to be documented in the kdocs to a
level that any other HW could implement it as well.

> > +int tpm_tis_spi_transfer(struct tpm_tis_data *data, u32 addr, u16 len,
> > + u8 *in, const u8 *out)
> > +{
> > + struct tpm_tis_spi_phy *phy = to_tpm_tis_spi_phy(data);
> > + struct spi_controller *ctlr = phy->spi_device->controller;
> > +
> > + /*
> > + * TPM flow control over SPI requires full duplex support.
> > + * Send entire message to a half duplex controller to handle
> > + * wait polling in controller.
> > + * Set TPM HW flow control flag..
> > + */
> > + if (ctlr->flags & SPI_CONTROLLER_HALF_DUPLEX) {
> > + phy->spi_device->mode |= SPI_TPM_HW_FLOW;

Shouldn't we check that this special flow is supported when the SPI
device is bound to the tpm in the first place?

Jason