On Wed, Nov 25, 2026 at 11:00:34PM +0000, Surendran Kanagaraj wrote:
> Hi Jarkko,
>
> On Wed, Nov 18, 2026 at 07:38:45AM +0000, Surendran Kanagaraj wrote:
> > +static const u32 tpm2_defaults[TPM_NR_LIMITS] = {
> > + [TPM_LIMIT_A] = TPM2_TIMEOUT_A * USEC_PER_MSEC,
> > + [TPM_LIMIT_B] = TPM2_TIMEOUT_B * USEC_PER_MSEC,
> > + [TPM_LIMIT_C] = TPM2_TIMEOUT_C * USEC_PER_MSEC,
> > + [TPM_LIMIT_D] = TPM2_TIMEOUT_D * USEC_PER_MSEC,
> > +
> > + [TPM_LIMIT_SHORT] = 750 * USEC_PER_MSEC,
> > + [TPM_LIMIT_MEDIUM] = 2000 * USEC_PER_MSEC,
> > + [TPM_LIMIT_LONG] = 3000 * USEC_PER_MSEC,
> > + [TPM_LIMIT_LONG_LONG] = TPM2_DURATION_LONG_LONG * USEC_PER_MSEC,
> > + [TPM_LIMIT_DEFAULT] = TPM2_DURATION_DEFAULT * USEC_PER_MSEC,
> > +};
>
> The TPM2_SelfTest duration bump [1] made me realize that mapping the
> TPM 2.0 durations into these TPM 1.x style classes may not hold up long
> term. A spec update to a single command turns into a change that
> affects all commands under the class. I think it is better to keep the
> existing maps as they are and let the driver modify the map if needed.
> This is also what you suggested in commit 207696b17f38 ("tpm: use a
> map for tpm2_calc_ordinal_duration()"): keep a per-chip copy of the
> map and let the leaf driver patch it.
>
> At a high level, the series would become:
>
> 1) Set default interface timeouts and duration at chip allocation.
> 2) Keep the chip durations in a union of TPM1.x and TPM2.0 durations.
>
> union tpm_durations {
> unsigned long tpm1[TPM1_NUM_DURATIONS];
> struct tpm2_ordinal_duration tpm2[TPM2_NUM_DURATIONS];
> };
>
> struct tpm_chip holds the union tpm_durations in place of
> chip->duration[]
It isn't possible to have single struct tpm duration that is partially
used by TPM1?
> 3) update_durations() now gets the union which TPM1.x and TPM2
> drivers can adjust.
> 4) Show the durations sysfs file for TPM 2.0 chips.
>
> With this, I would drop the limits table, poll APIs and tpm.limits=
> parameter for now and keep the series focused on duration handling.
>
> Does this sound reasonable to you?
>
> [1]
> https://lore.kernel.org/linux-integrity/[email protected]/
>
> Thanks,
> Surendran
Br, Jarkko