All of lore.kernel.org
 help / color / mirror / Atom feed
From: Simon Glass <sjg@chromium.org>
To: Heinrich Schuchardt <xypron.glpk@gmx.de>
Cc: Ilias Apalodimas <ilias.apalodimas@linaro.org>,
	 Johannes Holland <johannes.holland@infineon.com>,
	 Masahisa Kojima <masahisa.kojima@linaro.org>,
	Dhananjay Phadke <dphadke@linux.microsoft.com>,
	 U-Boot Mailing List <u-boot@lists.denx.de>
Subject: Re: [PATCH 2/2] tpm2: Add a TPMv2 MMIO TIS driver
Date: Mon, 12 Jul 2021 13:43:53 -0600	[thread overview]
Message-ID: <CAPnjgZ1NNxbAdZaww=eBSHDZ-kgzQ2EC=n8Dkqr-Mq605Gi11Q@mail.gmail.com> (raw)
In-Reply-To: <ba03c1a6-1802-f08c-1fdc-0301ad23949e@gmx.de>

Hi Heinrich,

On Mon, 12 Jul 2021 at 13:19, Heinrich Schuchardt <xypron.glpk@gmx.de> wrote:
>
> On 7/12/21 8:22 PM, Ilias Apalodimas wrote:
> > Hi Simon,
> > On Sat, Jul 10, 2021 at 06:00:59PM -0600, Simon Glass wrote:
> >> Hi Ilias,
> >>
> >> On Wed, 7 Jul 2021 at 10:26, Ilias Apalodimas
> >> <ilias.apalodimas@linaro.org> wrote:
> >>>
> >>> Add support for devices that expose a TPMv2 though MMIO.
> >>> Apart from those devices, we can use the driver in our QEMU setups and
> >>> test TPM related code which is difficult to achieve using the sandbox
> >>> driver (e.g test the EFI TCG2 protocol).
> >>>
> >>> It's worth noting that a previous patch added TPMv2 TIS core functions,
> >>> which the current driver is consuming.
> >>>
> >>> Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
> >>> ---
> >>> Changes since v1:
> >>> - split off the tis core code into a different file
> >>>   drivers/tpm/Kconfig         |   9 +++
> >>>   drivers/tpm/Makefile        |   1 +
> >>>   drivers/tpm/tpm2_tis_mmio.c | 156 ++++++++++++++++++++++++++++++++++++
> >>>   3 files changed, 166 insertions(+)
> >>>   create mode 100644 drivers/tpm/tpm2_tis_mmio.c
> >>
> >> Looks good to me
> >
> > Thanks!
> >
> >>>
> >>> +struct tpm_tis_chip_data {
> >>> +       unsigned int pcr_count;
> >>> +       unsigned int pcr_select_min;
> >>> +       unsigned int time_before_first_cmd_ms;
> >>> +       void __iomem *iobase;
> >>> +};
> >>
> >> comments
> >>
> >
> > You mean on all the internal functions?
> > Sure I can add them
> >
> >>> +
> >>> +static int mmio_read_bytes(struct udevice *udev, u32 addr, u16 len,
> >>> +                          u8 *result)
> >>> +{
> >>> +       struct tpm_tis_chip_data *drv_data = (void *)dev_get_driver_data(udev);
> >>> +
> >>> +       while (len--)
> >>> +               *result++ = ioread8(drv_data->iobase + addr);
> >>
> >> We normally put a blank line before the final return
> >>
> >
> > sure
> >
> >>> +       return 0;
> >>> +}
> >>> +
> >>> +static int mmio_write_bytes(struct udevice *udev, u32 addr, u16 len,
> >>> +                           const u8 *value)
> >>> +{
> >>> +       struct tpm_tis_chip_data *drv_data = (void *)dev_get_driver_data(udev);
> >>> +
> >>> +       while (len--)
> >>> +               iowrite8(*value++, drv_data->iobase + addr);
> >>> +       return 0;
> >>> +}
> >>> +
> >>> +static int mmio_read16(struct udevice *udev, u32 addr, u16 *result)
> >>> +{
> >>> +       struct tpm_tis_chip_data *drv_data = (void *)dev_get_driver_data(udev);
> >>> +
> >>> +       *result = ioread16(drv_data->iobase + addr);
> >>> +       return 0;
> >>> +}
> >>> +
> >>> +static int mmio_read32(struct udevice *udev, u32 addr, u32 *result)
> >>> +{
> >>> +       struct tpm_tis_chip_data *drv_data = (void *)dev_get_driver_data(udev);
> >>> +
> >>> +       *result = ioread32(drv_data->iobase + addr);
> >>> +       return 0;
> >>> +}
> >>> +
> >>> +static int mmio_write32(struct udevice *udev, u32 addr, u32 value)
> >>> +{
> >>> +       struct tpm_tis_chip_data *drv_data = (void *)dev_get_driver_data(udev);
> >>> +
> >>> +       iowrite32(value, drv_data->iobase + addr);
> >>> +       return 0;
> >>> +}
> >>> +
> >>> +static struct tpm_tis_phy_ops phy_ops = {
> >>
> >> Should be a uclass interface.
> >>
> >
> > Why? A uclass is supposed to describe and abstract hardware.  This is just
> > a specific implementation of a TPM, not all TPMs are TIS compliant. We already
> > have a uclass for those.
>
> The design proposed by Ilias matches what we find in Linux for TPM.
> Keeping the same structure should render porting of drivers for
> additional devices easier.

Can you please be more specific in your comment? What change are you asking for?

Regards,
Simon

  reply	other threads:[~2021-07-12 19:44 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-07 16:25 [PATCH 1/2 v2] tpm2: Introduce TIS tpm core Ilias Apalodimas
2021-07-07 16:25 ` [PATCH 2/2] tpm2: Add a TPMv2 MMIO TIS driver Ilias Apalodimas
2021-07-11  0:00   ` Simon Glass
2021-07-12 18:22     ` Ilias Apalodimas
2021-07-12 19:13       ` Heinrich Schuchardt
2021-07-12 19:43         ` Simon Glass [this message]
2021-07-12 22:46           ` Heinrich Schuchardt
2021-07-13 16:52             ` Simon Glass
2021-07-12 19:38       ` Simon Glass
2021-07-13 20:11         ` Ilias Apalodimas
2021-07-14  2:49           ` Simon Glass
2021-07-14  5:23             ` Ilias Apalodimas
2021-07-14 19:50               ` Simon Glass
2021-07-11  0:00 ` [PATCH 1/2 v2] tpm2: Introduce TIS tpm core Simon Glass
2021-07-12  6:24   ` Ilias Apalodimas
2021-07-12 11:42     ` Simon Glass
2021-07-12 14:03       ` Ilias Apalodimas
2021-07-12 19:43         ` Simon Glass
2021-07-13  5:51           ` Ilias Apalodimas
2021-07-13 20:17             ` Simon Glass

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='CAPnjgZ1NNxbAdZaww=eBSHDZ-kgzQ2EC=n8Dkqr-Mq605Gi11Q@mail.gmail.com' \
    --to=sjg@chromium.org \
    --cc=dphadke@linux.microsoft.com \
    --cc=ilias.apalodimas@linaro.org \
    --cc=johannes.holland@infineon.com \
    --cc=masahisa.kojima@linaro.org \
    --cc=u-boot@lists.denx.de \
    --cc=xypron.glpk@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.