Re: [PATCH v2 5/6] tpm: add driver for cr50 on SPI

From: Stephen Boyd
Date: Thu Jul 18 2019 - 14:07:39 EST


Quoting Alexander Steffen (2019-07-18 09:47:14)
> On 17.07.2019 21:57, Stephen Boyd wrote:
> >
> > I think the idea is to let users override the quality if they decide
> > that they don't want to use the default value specified in the driver.
>
> But isn't this something that applies to all TPMs, not only cr50? So
> shouldn't this parameter be added to one of the global modules (tpm?
> tpm_tis_core?) instead? Or do all low-level drivers (tpm_tis,
> tpm_tis_spi, ...) need this parameter to provide a consistent interface
> for the user?

Looking at commit 7a64c5597aa4 ("tpm: Allow tpm_tis drivers to set hwrng
quality.") I think all low-level drivers need to set the hwrng quality
somehow. I'm not sure how tpm_tis_spi will do that in general, but at
least for cr50 we have derived this quality number.

I can move this module parameter to tpm_tis_core.c, but then it will be
a global hwrng quality override for whatever tpm is registered through
tpm_tis_core instead of per-tpm driver. This is sort of a problem right
now too if we have two tpm_tis_spi devices. I can drop this parameter if
you want.

>
> >
> > Do you want me to describe something further?
> >
> >> For example, struct
> >> cr50_spi_phy contains both tx_buf and rx_buf, whereas tpm_tis_spi uses a
> >> single iobuf, that is allocated via devm_kmalloc instead of being part
> >> of the struct. Maybe the difference matters, maybe not, who knows?
> >
> > Ok. Are you asking if this is a full-duplex SPI device?
>
> No, this was meant as an example for the previous question. As far as I
> understood it, cr50 is basically compliant to the spec implemented by
> tpm_tis_spi, but needs special handling in some cases. Therefore, I'd
> expect a driver for cr50 to look exactly like tpm_tis_spi except for the
> special bits here and there. The way buffers are allocated within the
> driver is probably not something that should differ because of the TPM chip.
>

Ok.