Linux Integrity Measurement development
 help / color / mirror / Atom feed
From: Surendran Kanagaraj <surenkj@amazon.com>
To: <jarkko@kernel.org>
Cc: <corbet@lwn.net>, <graf@amazon.de>, <gunnarku@amazon.com>,
	<jgg@ziepe.ca>, <joshlev@amazon.com>, <leitao@debian.org>,
	<linux-doc@vger.kernel.org>, <linux-integrity@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>, <nh-open-source@amazon.com>,
	<noodles@earth.li>, <peterhuewe@gmx.de>, <surenkj@amazon.com>
Subject: Re: [RFC PATCH v3 1/8] tpm: Add a single table for all TPM wait limits
Date: Sat, 14 Nov 2026 09:12:22 +0000	[thread overview]
Message-ID: <20261114091222.32721-1-surenkj@amazon.com> (raw)
In-Reply-To: <avdoybHEoRd0Fhie@kernel.org>

Hi Jarkko,
Thanks for the review.

On Fri, Nov 13, 2026 at 09:45:13PM +0200, Jarkko Sakkinen wrote:
> On Thu, Nov 12, 2026 at 04:38:39PM +0000, Surendran Kanagaraj wrote:
> > The hook sets values with tpm_limits_driver_set() or from a quirk
> > table through tpm_limits_apply_quirks(). tpm_poll_timeout() waits on
>
> OK, but ...
>
> I.e. I'm not fully following what is the diffence between these call
> paths.

They are used from the same place. tpm_limits_update(), which is called
from tpm*_get_timeouts(), builds the table. The driver hook
->adjust_limits() runs from tpm_limits_update() and uses
tpm_limits_apply_quirks() to apply the quirks. tpm_limits_apply_quirks()
finds the matching quirk entry and calls tpm_limits_driver_set() to
update the limit.

tpm_limits_update(...)
{
    tpm_limits_stage_defaults(&p, family);
    if (reported)
        tpm_limits_stage_reported(&p, reported);
    if (chip->ops->adjust_limits)
        chip->ops->adjust_limits(chip, &p);
    tpm_limits_stage_validate(&p);
    tpm_limits_commit(chip, &p);
}

Hope this clarifies.

> > +/*
> > + * Handles time limits for a TPM chip.
>
> I'd extend this to just have brief description how this works. Just a
> high-level overview.

Ack. I will add a short overview in the next rev.

> > +static int tpm_poll(struct tpm_chip *chip, u32 timeout_us,
> > +		    enum tpm_limit limit,
> > +		    bool (*cond)(struct tpm_chip *chip, void *arg), void *arg)
> > [...]
> > +int tpm_poll_timeout(struct tpm_chip *chip, enum tpm_limit limit,
> > +		     bool (*cond)(struct tpm_chip *chip, void *arg), void *arg)
> > +{
> > +	if (WARN_ON_ONCE(limit >= TPM_NR_LIMITS))
> > +		return -EINVAL;
> > +
> > +	return tpm_poll(chip, tpm_limits_us(chip, limit), limit, cond, arg);
> > +}
> > +EXPORT_SYMBOL_GPL(tpm_poll_timeout);
> > [...]
> > +int tpm_poll_timeout_us(struct tpm_chip *chip, u32 timeout_us,
> > +			bool (*cond)(struct tpm_chip *chip, void *arg),
> > +			void *arg)
> > +{
> > +	return tpm_poll(chip, timeout_us, TPM_NR_LIMITS, cond, arg);
> > +}
>
> I did not check all the details but could this be reorganized into:
>
> 1. __tpm_poll(): the same as tpm_poll() but exported and defined in
>    drivers/char/tpm.h.
> 2. tpm_poll(): a single static inline function declared fully at
>    drivers/char/tpm.h
>
> __tpm_poll() would e.g., make a nicer trace point for a kprobe or
> kretprobe.

Good point. __tpm_poll() then becomes the single kprobe point. Will do
this in the next rev.

> > +/* per-device overrides based on id the driver defines e.g. DID/VID */
> > +struct tpm_limits_quirk {
> > +	u32 id;				/* driver-defined device identity */
> > +	u32 time_us[TPM_NR_LIMITS];	/* 0 leaves the limit alone */
> > +};
>
> I think it would make more sense to fully initialize the database per
> device, if that is possible.
>
> It is a non-concern if two TPM drivers do some redundant work, as it
> is not a real-world production use case :-)
>
> I'm just wondering if this quirk/entry division.
>
> I.e. in my world view chip owns its limits (not e.g., tpm2_space).

Makes sense. The quirk table is just a convenience, a common table fmt
for drivers, and the chip still owns the table. Without it the driver
calls tpm_limits_driver_set() for each limit it changes. I am happy to
drop it in the next rev.

Thanks,
Surendran

  parent reply	other threads:[~2026-11-14  9:12 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-12 16:38 [RFC PATCH v3 0/8] tpm: Rework timeout and duration handling Surendran Kanagaraj
2026-11-12 16:38 ` [RFC PATCH v3 1/8] tpm: Add a single table for all TPM wait limits Surendran Kanagaraj
2026-11-13 19:45   ` Jarkko Sakkinen
2026-11-13 20:05     ` Jarkko Sakkinen
2026-11-14  9:12     ` Surendran Kanagaraj [this message]
2026-11-14 13:29       ` Jarkko Sakkinen
2026-11-12 16:38 ` [RFC PATCH v3 2/8] tpm: Wire the timing setup to the limits table Surendran Kanagaraj
2026-11-12 16:38 ` [RFC PATCH v3 3/8] tpm: Take command durations from " Surendran Kanagaraj
2026-11-12 16:38 ` [RFC PATCH v3 4/8] tpm: Bound core and CRB waits by " Surendran Kanagaraj
2026-11-12 16:42 ` [RFC PATCH v3 5/8] tpm: Drop the jiffies timing fields from struct tpm_chip Surendran Kanagaraj
2026-11-12 16:43 ` [RFC PATCH v3 6/8] tpm: Add the tpm.limits= parameter Surendran Kanagaraj
2026-11-12 16:45 ` [RFC PATCH v3 7/8] tpm: Show timeouts and durations for TPM 2.0 chips Surendran Kanagaraj
2026-11-12 16:46 ` [RFC PATCH v3 8/8] tpm_crb: Raise the limits for Amazon NitroTPM Surendran Kanagaraj
2026-11-12 18:39 ` [RFC PATCH v3 0/8] tpm: Rework timeout and duration handling Jarkko Sakkinen

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=20261114091222.32721-1-surenkj@amazon.com \
    --to=surenkj@amazon.com \
    --cc=corbet@lwn.net \
    --cc=graf@amazon.de \
    --cc=gunnarku@amazon.com \
    --cc=jarkko@kernel.org \
    --cc=jgg@ziepe.ca \
    --cc=joshlev@amazon.com \
    --cc=leitao@debian.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-integrity@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nh-open-source@amazon.com \
    --cc=noodles@earth.li \
    --cc=peterhuewe@gmx.de \
    /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