From: Jarkko Sakkinen <jarkko@kernel.org>
To: Joel Stanley <joel@jms.id.au>
Cc: Eddie James <eajames@linux.ibm.com>,
linux-integrity@vger.kernel.org, linux-kernel@vger.kernel.org,
peterhuewe@gmx.de, jarkko@kernel.or, jgg@ziepe.ca,
Alexander.Steffen@infineon.com
Subject: Re: [PATCH] tpm: Add flag to use default cancellation policy
Date: Sat, 1 Oct 2022 00:49:42 +0300 [thread overview]
Message-ID: <Yzdkdj7Ma3/RnCCs@kernel.org> (raw)
In-Reply-To: <CACPK8XfRC==6CmFV3LoTW9oF_KLxMXH2KZQD0WFfnYpgnBERXQ@mail.gmail.com>
On Wed, Sep 28, 2022 at 05:10:25AM +0000, Joel Stanley wrote:
> On Thu, 8 Sept 2022 at 13:53, Eddie James <eajames@linux.ibm.com> wrote:
> >
> >
> > On 9/8/22 00:22, Jarkko Sakkinen wrote:
> > > On Wed, Sep 07, 2022 at 11:43:17AM -0500, Eddie James wrote:
> > >> The check for cancelled request depends on the VID of the chip, but
> > >> some chips share VID which shouldn't share their cancellation
> > >> behavior. This is the case for the Nuvoton NPCT75X, which should use
> > >> the default cancellation check, not the Winbond one.
> > >> To avoid changing the existing behavior, add a new flag to indicate
> > >> that the chip should use the default cancellation check and set it
> > >> for the I2C TPM2 TIS driver.
> > >>
> > >> Signed-off-by: Eddie James <eajames@linux.ibm.com>
> > >> ---
> > >> drivers/char/tpm/tpm_tis_core.c | 18 ++++++++++--------
> > >> drivers/char/tpm/tpm_tis_core.h | 1 +
> > >> drivers/char/tpm/tpm_tis_i2c.c | 1 +
> > >> 3 files changed, 12 insertions(+), 8 deletions(-)
> > >>
> > >> diff --git a/drivers/char/tpm/tpm_tis_core.c b/drivers/char/tpm/tpm_tis_core.c
> > >> index 757623bacfd5..175e75337395 100644
> > >> --- a/drivers/char/tpm/tpm_tis_core.c
> > >> +++ b/drivers/char/tpm/tpm_tis_core.c
> > >> @@ -682,15 +682,17 @@ static bool tpm_tis_req_canceled(struct tpm_chip *chip, u8 status)
> > >> {
> > >> struct tpm_tis_data *priv = dev_get_drvdata(&chip->dev);
> > >>
> > >> - switch (priv->manufacturer_id) {
> > >> - case TPM_VID_WINBOND:
> > >> - return ((status == TPM_STS_VALID) ||
> > >> - (status == (TPM_STS_VALID | TPM_STS_COMMAND_READY)));
> > >> - case TPM_VID_STM:
> > >> - return (status == (TPM_STS_VALID | TPM_STS_COMMAND_READY));
> > >> - default:
> > >> - return (status == TPM_STS_COMMAND_READY);
> > >> + if (!test_bit(TPM_TIS_DEFAULT_CANCELLATION, &priv->flags)) {
> > >> + switch (priv->manufacturer_id) {
> > >> + case TPM_VID_WINBOND:
> > >> + return ((status == TPM_STS_VALID) ||
> > >> + (status == (TPM_STS_VALID | TPM_STS_COMMAND_READY)));
> > >> + case TPM_VID_STM:
> > >> + return (status == (TPM_STS_VALID | TPM_STS_COMMAND_READY));
> > >> + }
> > > Why there is no default: ?
> >
> >
> > Well I didn't want to duplicate the line "status ==
> > TPM_STS_COMMAND_READY" in the default case and for the flagged case. So
> > now the switch just falls through for default. I can add default: break
> > instead
>
> This code was in the original patch series submitted by Nuvoton:
>
> https://lore.kernel.org/r/20211104140211.6258-3-amirmizi6@gmail.com
>
> Perhaps something like that would be better?
The current patch could have
default:
/* fall-through */
break;
BR, Jarkko
prev parent reply other threads:[~2022-09-30 21:49 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-07 16:43 [PATCH] tpm: Add flag to use default cancellation policy Eddie James
2022-09-08 5:22 ` Jarkko Sakkinen
2022-09-08 13:53 ` Eddie James
2022-09-28 5:10 ` Joel Stanley
2022-09-30 21:49 ` Jarkko Sakkinen [this message]
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=Yzdkdj7Ma3/RnCCs@kernel.org \
--to=jarkko@kernel.org \
--cc=Alexander.Steffen@infineon.com \
--cc=eajames@linux.ibm.com \
--cc=jarkko@kernel.or \
--cc=jgg@ziepe.ca \
--cc=joel@jms.id.au \
--cc=linux-integrity@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--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;
as well as URLs for NNTP newsgroup(s).