From: "Jarkko Sakkinen" <jarkko@kernel.org>
To: "Niklas Schnelle" <schnelle@linux.ibm.com>,
"Arnd Bergmann" <arnd@arndb.de>,
"Peter Huewe" <peterhuewe@gmx.de>,
"Jason Gunthorpe" <jgg@ziepe.ca>
Cc: "Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
"Bjorn Helgaas" <bhelgaas@google.com>,
"Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>,
"Mauro Carvalho Chehab" <mchehab@kernel.org>,
"Alan Stern" <stern@rowland.harvard.edu>,
"Rafael J. Wysocki" <rafael@kernel.org>,
"Geert Uytterhoeven" <geert@linux-m68k.org>,
"Paul Walmsley" <paul.walmsley@sifive.com>,
"Palmer Dabbelt" <palmer@dabbelt.com>,
"Albert Ou" <aou@eecs.berkeley.edu>,
linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org,
linux-pci@vger.kernel.org, "Arnd Bergmann" <arnd@kernel.org>,
linux-integrity@vger.kernel.org
Subject: Re: [PATCH v5 05/44] char: tpm: handle HAS_IOPORT dependencies
Date: Wed, 24 May 2023 06:13:21 +0300 [thread overview]
Message-ID: <CSU6HS37JN7M.11R5RM34EADW@suppilovahvero> (raw)
In-Reply-To: <20230522105049.1467313-6-schnelle@linux.ibm.com>
On Mon May 22, 2023 at 1:50 PM EEST, Niklas Schnelle wrote:
> In a future patch HAS_IOPORT=n will result in inb()/outb() and friends
> not being declared. We thus need to add this dependency and ifdef
> sections of code using inb()/outb() as alternative access methods.
>
> Co-developed-by: Arnd Bergmann <arnd@kernel.org>
> Signed-off-by: Arnd Bergmann <arnd@kernel.org>
> Signed-off-by: Niklas Schnelle <schnelle@linux.ibm.com>
> ---
> drivers/char/tpm/Kconfig | 1 +
> drivers/char/tpm/tpm_infineon.c | 16 ++++++++++++----
> drivers/char/tpm/tpm_tis_core.c | 19 ++++++++-----------
> 3 files changed, 21 insertions(+), 15 deletions(-)
>
> diff --git a/drivers/char/tpm/Kconfig b/drivers/char/tpm/Kconfig
> index 927088b2c3d3..418c9ed59ffd 100644
> --- a/drivers/char/tpm/Kconfig
> +++ b/drivers/char/tpm/Kconfig
> @@ -149,6 +149,7 @@ config TCG_NSC
> config TCG_ATMEL
> tristate "Atmel TPM Interface"
> depends on PPC64 || HAS_IOPORT_MAP
> + depends on HAS_IOPORT
> help
> If you have a TPM security chip from Atmel say Yes and it
> will be accessible from within Linux. To compile this driver
> diff --git a/drivers/char/tpm/tpm_infineon.c b/drivers/char/tpm/tpm_infineon.c
> index 9c924a1440a9..99c6e565ec8d 100644
> --- a/drivers/char/tpm/tpm_infineon.c
> +++ b/drivers/char/tpm/tpm_infineon.c
> @@ -26,7 +26,9 @@
> #define TPM_MAX_TRIES 5000
> #define TPM_INFINEON_DEV_VEN_VALUE 0x15D1
>
> +#ifdef CONFIG_HAS_IOPORT
> #define TPM_INF_IO_PORT 0x0
> +#endif
> #define TPM_INF_IO_MEM 0x1
>
> #define TPM_INF_ADDR 0x0
> @@ -51,34 +53,40 @@ static struct tpm_inf_dev tpm_dev;
>
> static inline void tpm_data_out(unsigned char data, unsigned char offset)
> {
> +#ifdef CONFIG_HAS_IOPORT
> if (tpm_dev.iotype == TPM_INF_IO_PORT)
> outb(data, tpm_dev.data_regs + offset);
> else
> +#endif
> writeb(data, tpm_dev.mem_base + tpm_dev.data_regs + offset);
> }
>
> static inline unsigned char tpm_data_in(unsigned char offset)
> {
> +#ifdef CONFIG_HAS_IOPORT
> if (tpm_dev.iotype == TPM_INF_IO_PORT)
> return inb(tpm_dev.data_regs + offset);
> - else
> - return readb(tpm_dev.mem_base + tpm_dev.data_regs + offset);
> +#endif
> + return readb(tpm_dev.mem_base + tpm_dev.data_regs + offset);
> }
>
> static inline void tpm_config_out(unsigned char data, unsigned char offset)
> {
> +#ifdef CONFIG_HAS_IOPORT
> if (tpm_dev.iotype == TPM_INF_IO_PORT)
> outb(data, tpm_dev.config_port + offset);
> else
> +#endif
> writeb(data, tpm_dev.mem_base + tpm_dev.index_off + offset);
> }
>
> static inline unsigned char tpm_config_in(unsigned char offset)
> {
> +#ifdef CONFIG_HAS_IOPORT
> if (tpm_dev.iotype == TPM_INF_IO_PORT)
> return inb(tpm_dev.config_port + offset);
> - else
> - return readb(tpm_dev.mem_base + tpm_dev.index_off + offset);
> +#endif
> + return readb(tpm_dev.mem_base + tpm_dev.index_off + offset);
> }
>
> /* TPM header definitions */
> diff --git a/drivers/char/tpm/tpm_tis_core.c b/drivers/char/tpm/tpm_tis_core.c
> index 558144fa707a..0ee5a83e35a8 100644
> --- a/drivers/char/tpm/tpm_tis_core.c
> +++ b/drivers/char/tpm/tpm_tis_core.c
> @@ -954,11 +954,6 @@ static void tpm_tis_clkrun_enable(struct tpm_chip *chip, bool value)
> clkrun_val &= ~LPC_CLKRUN_EN;
> iowrite32(clkrun_val, data->ilb_base_addr + LPC_CNTRL_OFFSET);
>
> - /*
> - * Write any random value on port 0x80 which is on LPC, to make
> - * sure LPC clock is running before sending any TPM command.
> - */
> - outb(0xCC, 0x80);
> } else {
> data->clkrun_enabled--;
> if (data->clkrun_enabled)
> @@ -969,13 +964,15 @@ static void tpm_tis_clkrun_enable(struct tpm_chip *chip, bool value)
> /* Enable LPC CLKRUN# */
> clkrun_val |= LPC_CLKRUN_EN;
> iowrite32(clkrun_val, data->ilb_base_addr + LPC_CNTRL_OFFSET);
> -
> - /*
> - * Write any random value on port 0x80 which is on LPC, to make
> - * sure LPC clock is running before sending any TPM command.
> - */
> - outb(0xCC, 0x80);
> }
> +
> +#ifdef CONFIG_HAS_IOPORT
> + /*
> + * Write any random value on port 0x80 which is on LPC, to make
> + * sure LPC clock is running before sending any TPM command.
> + */
> + outb(0xCC, 0x80);
> +#endif
> }
>
> static const struct tpm_class_ops tpm_tis = {
> --
> 2.39.2
Acked-by: Jarkko Sakkinen <jarkko@kernel.org>
BR, Jarkko
prev parent reply other threads:[~2023-05-24 3:13 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20230522105049.1467313-1-schnelle@linux.ibm.com>
2023-05-22 10:50 ` [PATCH v5 05/44] char: tpm: handle HAS_IOPORT dependencies Niklas Schnelle
2023-05-24 1:09 ` Jarkko Sakkinen
2023-05-24 3:13 ` 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=CSU6HS37JN7M.11R5RM34EADW@suppilovahvero \
--to=jarkko@kernel.org \
--cc=aou@eecs.berkeley.edu \
--cc=arnd@arndb.de \
--cc=arnd@kernel.org \
--cc=bhelgaas@google.com \
--cc=geert@linux-m68k.org \
--cc=gregkh@linuxfoundation.org \
--cc=jgg@ziepe.ca \
--cc=linux-arch@vger.kernel.org \
--cc=linux-integrity@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=palmer@dabbelt.com \
--cc=paul.walmsley@sifive.com \
--cc=peterhuewe@gmx.de \
--cc=rafael@kernel.org \
--cc=schnelle@linux.ibm.com \
--cc=stern@rowland.harvard.edu \
--cc=u.kleine-koenig@pengutronix.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