tpm: Add driver for cr50
Subsystems (3)
v7 cover tpm: Add driver for cr50
This patch series adds support for the H1 secure microcontroller running cr50 firmware found on various recent Chromebooks. This driver is necessary to boot into a ChromeOS userspace environment. It implements support for several functions, including TPM-like functionality over a SPI interface.
The last time this was series sent looks to be [1]. I've looked over the patches and review comments and tried to address any feedback that Andrey didn't address (really minor things like newlines). I've reworked the patches from the last version to layer on top of the existing TPM TIS SPI implementation in tpm_tis_spi.c. Hopefully this is more palatable than combining the two drivers together into one file.
Please review so we can get the approach to supporting this device sorted out.
[1] https://lkml.kernel.org/r/[email protected]
TODO:
* Add a patch to spit out WARN_ON() when TPM is suspended and some kernel code attempts to use it
* Rework the i2c driver per Alexander's comments on v2
Changes from v6 (https://lkml.kernel.org/r/[email protected]):
* Two new patches to cleanup includes and module usage
* Moved cr50 C file to tpm_tis_spi_cr50.c
* Used the tpm_tis_spi_mod target approach to make the module work
* Brought back Kconfig option to allow user to disable cr50 code
* Rebased to v5.3
Changes from v5 (https://lkml.kernel.org/r/[email protected]):
* Picked up Jarkko's ack/review tags
* Fixed bug with irqs happening before completion is initialized
* Dropped is_cr50 bool
* Moved wake_after to tpm_tis_spi struct
* Changed authorship of main cr50 patch to Andrey as I'm just shuffling code here
Changes from v4 (https://lkml.kernel.org/r/[email protected]):
* Dropped the 'pre-transfer' hook patch and added a 'ready' member instead
* Combined cr50_spi and tpm_tis_spi into one kernel module
* Introduced a swizzle in tpm_tis_spi probe routine to jump to cr50 probe path
* Moved binding to start of the thread
* Picked up Jarkko reviewed-by tag on new flag for suspend/resume
* Added a comment to flow control patch indicating what it's all about
Changes from v3:
* Split out hooks into separate patches
* Update commit text to not say "libify"
* Collapse if statement into one for first patch
* Update commit text on first patch to mention flag
* Drop TIS_IS_CR50 as it's unused
Changes from v2:
* Sent khwrng thread patch separately
* New patch to expose TPM SPI functionality from tpm_tis_spi.c
* Usage of that new patch in cr50 SPI driver
* Drop i2c version of cr50 SPI driver for now (will resend later)
* New patch to add a TPM chip flag indicating TPM shouldn't be reset over suspend. Allows us to get rid of the cr50 suspend/resume functions that are mostly generic
Changes from v1:
* Dropped symlink and sysfs patches
* Removed 'is_suspended' bits
* Added new patch to freeze khwrng thread
* Moved binding to google,cr50.txt and added Reviewed-by tag from Rob
Andrey Pronin (2):
dt-bindings: tpm: document properties for cr50
tpm: tpm_tis_spi: Support cr50 devices
Stephen Boyd (4):
tpm: Add a flag to indicate TPM power is managed by firmware
tpm: tpm_tis_spi: Introduce a flow control callback
tpm: tpm_tis_spi: Cleanup includes
tpm: tpm_tis_spi: Drop THIS_MODULE usage from driver struct
.../bindings/security/tpm/google,cr50.txt | 19 ++ drivers/char/tpm/Kconfig | 7 + drivers/char/tpm/Makefile | 4 +- drivers/char/tpm/tpm-interface.c | 8 +- drivers/char/tpm/tpm.h | 1 + drivers/char/tpm/tpm_tis_spi.c | 143 +++++--- drivers/char/tpm/tpm_tis_spi.h | 53 +++ drivers/char/tpm/tpm_tis_spi_cr50.c | 321 ++++++++++++++++++ 8 files changed, 498 insertions(+), 58 deletions(-) create mode 100644 Documentation/devicetree/bindings/security/tpm/google,cr50.txt create mode 100644 drivers/char/tpm/tpm_tis_spi.h create mode 100644 drivers/char/tpm/tpm_tis_spi_cr50.c
base-commit: 4d856f72c10ecb060868ed10ff1b1453943fc6c8
Signature · 1 line
Sent by a computer through tubes
PATCH v7 1/6 dt-bindings: tpm: document properties for cr50
From: Andrey Pronin <[email protected]>
Add TPM2.0 PTP FIFO compatible SPI interface for chips with Cr50 firmware.
--- .../bindings/security/tpm/google,cr50.txt | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 Documentation/devicetree/bindings/security/tpm/google,cr50.txt
Documentation/devicetree/bindings/security/tpm/google,cr50.txt new file +19 -0
@@ -0,0 +1,19 @@ +* H1 Secure Microcontroller with Cr50 Firmware on SPI Bus. + +H1 Secure Microcontroller running Cr50 firmware provides several +functions, including TPM-like functionality. It communicates over +SPI using the FIFO protocol described in the PTP Spec, section 6. + +Required properties: +- compatible: Should be "google,cr50". +- spi-max-frequency: Maximum SPI frequency. + +Example: + +&spi0 { + tpm@0 { + compatible = "google,cr50"; + reg = <0>; + spi-max-frequency = <800000>; + }; +};
Signature · 1 line
Sent by a computer through tubes
PATCH v7 2/6 tpm: Add a flag to indicate TPM power is managed by firmware
In reply to Stephen BoydOn some platforms, the TPM power is managed by firmware and therefore we don't need to stop the TPM on suspend when going to a light version of suspend such as S0ix ("freeze" suspend state). Add a chip flag, TPM_CHIP_FLAG_FIRMWARE_POWER_MANAGED, to indicate this so that certain platforms can probe for the usage of this light suspend and avoid touching the TPM state across suspend/resume.
--- drivers/char/tpm/tpm-interface.c | 8 +++++++- drivers/char/tpm/tpm.h | 1 + 2 files changed, 8 insertions(+), 1 deletion(-)
drivers/char/tpm/tpm-interface.c +7 -1
@@ -23,6 +23,7 @@#include <linux/slab.h> #include <linux/mutex.h> #include <linux/spinlock.h> +#include <linux/suspend.h> #include <linux/freezer.h> #include <linux/tpm_eventlog.h>
@@ -395,7 +396,11 @@ int tpm_pm_suspend(struct device *dev)return -ENODEV ;if (chip->flags &TPM_CHIP_FLAG_ALWAYS_POWERED ) -return 0 ; + goto suspended; + +if ((chip->flags &TPM_CHIP_FLAG_FIRMWARE_POWER_MANAGED ) && + !pm_suspend_via_firmware ()) + goto suspended;if (!tpm_chip_start (chip)) {if (chip->flags &TPM_CHIP_FLAG_TPM2 )
@@ -406,6 +411,7 @@ int tpm_pm_suspend(struct device *dev)tpm_chip_stop (chip); } +suspended:return rc; }EXPORT_SYMBOL_GPL (tpm_pm_suspend);
drivers/char/tpm/tpm.h +1 -0
@@ -162,6 +162,7 @@ enum tpm_chip_flags {TPM_CHIP_FLAG_VIRTUAL =BIT (3 ),TPM_CHIP_FLAG_HAVE_TIMEOUTS =BIT (4 ),TPM_CHIP_FLAG_ALWAYS_POWERED =BIT (5 ), + TPM_CHIP_FLAG_FIRMWARE_POWER_MANAGED = BIT(6), };#define to_tpm_chip (d) container_of(d, struct tpm_chip, dev)
Signature · 1 line
Sent by a computer through tubes
PATCH v7 3/6 tpm: tpm_tis_spi: Introduce a flow control callback
In reply to Stephen BoydCr50 firmware has a different flow control protocol than the one used by this TPM PTP SPI driver. Introduce a flow control callback so we can override the standard sequence with the custom one that Cr50 uses.
--- drivers/char/tpm/tpm_tis_spi.c | 62 ++++++++++++++++++++++------------ 1 file changed, 41 insertions(+), 21 deletions(-)
drivers/char/tpm/tpm_tis_spi.c +41 -21
@@ -42,6 +42,8 @@struct tpm_tis_spi_phy {struct tpm_tis_data priv;struct spi_device *spi_device; +int (*flow_control)(struct tpm_tis_spi_phy *phy, +struct spi_transfer *xfer);u8 *iobuf; };
@@ -50,12 +52,46 @@ static inline struct tpm_tis_spi_phy *to_tpm_tis_spi_phy(struct tpm_tis_data *da return container_of(data, struct tpm_tis_spi_phy, priv); } +/* +* TCG SPI flow control is documented in section 6.4 of the spec[1]. In short, +* keep trying to read from the device until MISO goes high indicating the +* wait state has ended. +* +* [1] https://trustedcomputinggroup.org/resource/pc-client-platform-tpm-profile-ptp-specification/ +*/ +static int tpm_tis_spi_flow_control (struct tpm_tis_spi_phy *phy, +struct spi_transfer *spi_xfer) +{ +struct spi_message m; +int ret, i; + +if ((phy->iobuf[3 ] &0x01 ) ==0 ) { +// handle SPI wait states + phy->iobuf[0 ] =0 ; + +for (i =0 ; i <TPM_RETRY ; i++) { + spi_xfer->len =1 ; +spi_message_init (&m); +spi_message_add_tail (spi_xfer, &m); + ret =spi_sync_locked (phy->spi_device, &m); +if (ret <0 ) +return ret; +if (phy->iobuf[0 ] &0x01 ) +break ; + } + +if (i ==TPM_RETRY ) +return -ETIMEDOUT ; + } + +return 0 ; +} +static int tpm_tis_spi_transfer (struct tpm_tis_data *data,u32 addr,u16 len,u8 *in,const u8 *out) {struct tpm_tis_spi_phy *phy =to_tpm_tis_spi_phy (data);int ret =0 ; -int i;struct spi_message m;struct spi_transfer spi_xfer;u8 transfer_len;
@@ -82,26 +118,9 @@ static int tpm_tis_spi_transfer(struct tpm_tis_data *data, u32 addr, u16 len,if (ret <0 ) goto exit; -if ((phy->iobuf[3 ] &0x01 ) ==0 ) { -// handle SPI wait states - phy->iobuf[0 ] =0 ; - -for (i =0 ; i <TPM_RETRY ; i++) { - spi_xfer.len =1 ; -spi_message_init (&m); -spi_message_add_tail (&spi_xfer, &m); - ret =spi_sync_locked (phy->spi_device, &m); -if (ret <0 ) - goto exit; -if (phy->iobuf[0 ] &0x01 ) -break ; - } - -if (i ==TPM_RETRY ) { - ret = -ETIMEDOUT ; - goto exit; - } - } + ret = phy->flow_control (phy, &spi_xfer); +if (ret <0 ) + goto exit; spi_xfer.cs_change =0 ; spi_xfer.len = transfer_len;
@@ -207,6 +226,7 @@ static int tpm_tis_spi_probe(struct spi_device *dev) phy->iobuf =devm_kmalloc (&dev->dev,MAX_SPI_FRAMESIZE ,GFP_KERNEL );if (!phy->iobuf)return -ENOMEM ; + phy->flow_control = tpm_tis_spi_flow_control;/* If the SPI device has an IRQ then use that */ if (dev->irq >0 )
Signature · 1 line
Sent by a computer through tubes
PATCH v7 4/6 tpm: tpm_tis_spi: Support cr50 devices
In reply to Stephen BoydFrom: Andrey Pronin <[email protected]>
Add TPM2.0 PTP FIFO compatible SPI interface for chips with Cr50 firmware. The firmware running on the currently supported H1 Secure Microcontroller requires a special driver to handle its specifics:
- need to ensure a certain delay between SPI transactions, or else the chip may miss some part of the next transaction
- if there is no SPI activity for some time, it may go to sleep, and needs to be waken up before sending further commands
- access to vendor-specific registers
Cr50 firmware has a requirement to wait for the TPM to wakeup before sending commands over the SPI bus. Otherwise, the firmware could be in deep sleep and not respond. The method to wait for the device to wakeup is slightly different than the usual flow control mechanism described in the TCG SPI spec. Add a completion to tpm_tis_spi_transfer() before we start a SPI transfer so we can keep track of the last time the TPM driver accessed the SPI bus to support the flow control mechanism.
Split the cr50 logic off into a different file to keep it out of the normal code flow of the existing SPI driver while making it all part of the same module when the code is optionally compiled into the same module. Export a new function, tpm_tis_spi_init(), and the associated read/write/transfer APIs so that we can do this. Make the cr50 code wrap the tpm_tis_spi_phy struct with its own struct to override the behavior of tpm_tis_spi_transfer() by supplying a custom flow control hook. This shares the most code between the core driver and the cr50 support without combining everything into the core driver or exporting module symbols.
[[email protected]: Replace boilerplate with SPDX tag, drop suspended bit and remove ifdef checks in cr50.h, migrate to functions exported in tpm_tis_spi.h, combine into one module instead of two]
--- drivers/char/tpm/Kconfig | 7 + drivers/char/tpm/Makefile | 4 +- drivers/char/tpm/tpm_tis_spi.c | 78 ++++--- drivers/char/tpm/tpm_tis_spi.h | 53 +++++ drivers/char/tpm/tpm_tis_spi_cr50.c | 321 ++++++++++++++++++++++++++++ 5 files changed, 431 insertions(+), 32 deletions(-) create mode 100644 drivers/char/tpm/tpm_tis_spi.h create mode 100644 drivers/char/tpm/tpm_tis_spi_cr50.c
drivers/char/tpm/Kconfig +7 -0
@@ -67,6 +67,13 @@ config TCG_TIS_SPI within Linux. To compile this driver as a module, choose M here; the module will be called tpm_tis_spi. +config TCG_TIS_SPI_CR50 + bool "Cr50 SPI Interface" + depends on TCG_TIS_SPI + ---help--- + If you have a H1 secure module running Cr50 firmware on SPI bus, + say Yes and it will be accessible from within Linux. + config TCG_TIS_I2C_ATMEL tristate "TPM Interface Specification 1.2 Interface (I2C - Atmel)" depends on I2C
drivers/char/tpm/Makefile +3 -1
@@ -21,7 +21,9 @@ tpm-$(CONFIG_EFI) += eventlog/efi.o tpm-$(CONFIG_OF) += eventlog/of.o obj-$(CONFIG_TCG_TIS_CORE) += tpm_tis_core.o obj-$(CONFIG_TCG_TIS) += tpm_tis.o -obj-$(CONFIG_TCG_TIS_SPI) += tpm_tis_spi.o +obj-$(CONFIG_TCG_TIS_SPI) += tpm_tis_spi_mod.o +tpm_tis_spi_mod-y := tpm_tis_spi.o +tpm_tis_spi_mod-$(CONFIG_TCG_TIS_SPI_CR50) += tpm_tis_spi_cr50.o obj-$(CONFIG_TCG_TIS_I2C_ATMEL) += tpm_i2c_atmel.o obj-$(CONFIG_TCG_TIS_I2C_INFINEON) += tpm_i2c_infineon.o obj-$(CONFIG_TCG_TIS_I2C_NUVOTON) += tpm_i2c_nuvoton.o
drivers/char/tpm/tpm_tis_spi.c +47 -31
165 lines not on this page · raw message
drivers/char/tpm/tpm_tis_spi.h new file +53 -0
53 lines not on this page · raw message
drivers/char/tpm/tpm_tis_spi_cr50.c new file +321 -0
321 lines not on this page · raw message
Signature · 1 line
Sent by a computer through tubes
Re: [PATCH v7 4/6] tpm: tpm_tis_spi: Support cr50 devices
Quoted 31 lines · Stephen Boyd
From: Andrey Pronin <[email protected]>
Add TPM2.0 PTP FIFO compatible SPI interface for chips with Cr50 firmware. The firmware running on the currently supported H1 Secure Microcontroller requires a special driver to handle its specifics:
- need to ensure a certain delay between SPI transactions, or else the chip may miss some part of the next transaction
- if there is no SPI activity for some time, it may go to sleep, and needs to be waken up before sending further commands
- access to vendor-specific registersCr50 firmware has a requirement to wait for the TPM to wakeup before sending commands over the SPI bus. Otherwise, the firmware could be in deep sleep and not respond. The method to wait for the device to wakeup is slightly different than the usual flow control mechanism described in the TCG SPI spec. Add a completion to
tpm_tis_spi_transfer()before we start a SPI transfer so we can keep track of the last time the TPM driver accessed the SPI bus to support the flow control mechanism.Split the cr50 logic off into a different file to keep it out of the normal code flow of the existing SPI driver while making it all part of the same module when the code is optionally compiled into the same module. Export a new function,
tpm_tis_spi_init(), and the associated read/write/transfer APIs so that we can do this. Make the cr50 code wrap thetpm_tis_spi_phystruct with its own struct to override the behavior oftpm_tis_spi_transfer()by supplying a custom flow control hook. This shares the most code between the core driver and the cr50 support without combining everything into the core driver or exporting module symbols.
Quoted 9 lines
Signed-off-by Andrey Pronin <[email protected]>Cc Andrey Pronin <[email protected]>Cc Duncan Laurie <[email protected]>Cc Jason Gunthorpe <[email protected]>Cc Arnd Bergmann <[email protected]>Cc Greg Kroah-Hartman <[email protected]>Cc Guenter Roeck <[email protected]>Cc Alexander Steffen <[email protected]>Cc Heiko Stuebner <[email protected]>
First, I apologize for such a long latency (two weeks).
I think this looks legit now.
/Jarkko
Re: [PATCH v7 4/6] tpm: tpm_tis_spi: Support cr50 devices
In reply to Stephen BoydQuoted 5 lines · Stephen Boyd
drivers/char/tpm/Makefile +0
-0
drivers/char/tpm/Makefile tpm-$(CONFIG_EFI) += eventlog/efi.o · line 29
Quoted 10 lines
drivers/char/tpm/Makefile +3
-1@@ -21,7 +21,9 @@ tpm-$(CONFIG_EFI) += eventlog/efi.o tpm-$(CONFIG_OF) += eventlog/of.o obj-$(CONFIG_TCG_TIS_CORE) += tpm_tis_core.o obj-$(CONFIG_TCG_TIS) += tpm_tis.o -obj-$(CONFIG_TCG_TIS_SPI) += tpm_tis_spi.o +obj-$(CONFIG_TCG_TIS_SPI) += tpm_tis_spi_mod.o +tpm_tis_spi_mod-y := tpm_tis_spi.o +tpm_tis_spi_mod-$(CONFIG_TCG_TIS_SPI_CR50) += tpm_tis_spi_cr50.o obj-$(CONFIG_TCG_TIS_I2C_ATMEL) += tpm_i2c_atmel.o obj-$(CONFIG_TCG_TIS_I2C_INFINEON) += tpm_i2c_infineon.o obj-$(CONFIG_TCG_TIS_I2C_NUVOTON) += tpm_i2c_nuvoton.o
This renames the driver module from tpm_tis_spi to tpm_tis_spi_mod, was this done intentionally? When trying to upgrade the kernel, this just broke my test system, since all scripts expect to be able to load tpm_tis_spi, which does not exist anymore with that change.
Alexander
Re: [PATCH v7 4/6] tpm: tpm_tis_spi: Support cr50 devices
Quoting Alexander Steffen (2020-02-03 01:13:29)
Quoted 13 lines · Stephen Boyd
Quoted 12 lines
drivers/char/tpm/Makefile +3
-1@@ -21,7 +21,9 @@ tpm-$(CONFIG_EFI) += eventlog/efi.o tpm-$(CONFIG_OF) += eventlog/of.o obj-$(CONFIG_TCG_TIS_CORE) += tpm_tis_core.o obj-$(CONFIG_TCG_TIS) += tpm_tis.o -obj-$(CONFIG_TCG_TIS_SPI) += tpm_tis_spi.o +obj-$(CONFIG_TCG_TIS_SPI) += tpm_tis_spi_mod.o +tpm_tis_spi_mod-y := tpm_tis_spi.o +tpm_tis_spi_mod-$(CONFIG_TCG_TIS_SPI_CR50) += tpm_tis_spi_cr50.o
Quoted 9 lines
drivers/char/tpm/Makefile tpm-$(CONFIG_EFI) += eventlog/efi.o · line 29
Quoted 3 lines
drivers/char/tpm/Makefile +0
-0obj-$(CONFIG_TCG_TIS_I2C_ATMEL) += tpm_i2c_atmel.o obj-$(CONFIG_TCG_TIS_I2C_INFINEON) += tpm_i2c_infineon.o obj-$(CONFIG_TCG_TIS_I2C_NUVOTON) += tpm_i2c_nuvoton.oThis renames the driver module from
tpm_tis_spitotpm_tis_spi_mod, was this done intentionally? When trying to upgrade the kernel, this just broke my test system, since all scripts expect to be able to loadtpm_tis_spi, which does not exist anymore with that change.
I mentioned this during the review of this patch set. I thought nobody would care, given that it's just a module name.
Can your scripts load the module based on something besides the module name? Perhaps by using device attributes instead?
Re: [PATCH v7 4/6] tpm: tpm_tis_spi: Support cr50 devices
Quoted 24 lines · Stephen Boyd
Quoting Alexander Steffen (2020-02-03 01:13:29)
Quoted 13 lines · Stephen Boyd
Quoted 12 lines
drivers/char/tpm/Makefile +3
-1@@ -21,7 +21,9 @@ tpm-$(CONFIG_EFI) += eventlog/efi.o tpm-$(CONFIG_OF) += eventlog/of.o obj-$(CONFIG_TCG_TIS_CORE) += tpm_tis_core.o obj-$(CONFIG_TCG_TIS) += tpm_tis.o -obj-$(CONFIG_TCG_TIS_SPI) += tpm_tis_spi.o +obj-$(CONFIG_TCG_TIS_SPI) += tpm_tis_spi_mod.o +tpm_tis_spi_mod-y := tpm_tis_spi.o +tpm_tis_spi_mod-$(CONFIG_TCG_TIS_SPI_CR50) += tpm_tis_spi_cr50.oQuoted 9 lines
drivers/char/tpm/Makefile tpm-$(CONFIG_EFI) += eventlog/efi.o · line 29
Quoted 3 lines
drivers/char/tpm/Makefile +0
-0obj-$(CONFIG_TCG_TIS_I2C_ATMEL) += tpm_i2c_atmel.o obj-$(CONFIG_TCG_TIS_I2C_INFINEON) += tpm_i2c_infineon.o obj-$(CONFIG_TCG_TIS_I2C_NUVOTON) += tpm_i2c_nuvoton.oThis renames the driver module from
tpm_tis_spitotpm_tis_spi_mod, was this done intentionally? When trying to upgrade the kernel, this just broke my test system, since all scripts expect to be able to loadtpm_tis_spi, which does not exist anymore with that change.
Quoted 5 lines
I mentioned this during the review of this patch set. I thought nobody would care, given that it's just a module name.
Can your scripts load the module based on something besides the module name? Perhaps by using device attributes instead?
The scripts are effectively using modprobe/rmmod/etc. and those need the name. modprobe can be fixed by defining an alias, but this does not work for rmmod. Many other things also depend on the name, e.g. module blacklisting or the output of lsmod, where people might now get confused by the difference between "tpm_tis_spi_mod" and "tpm_tis_i2c". Also, there are many tutorials out there, that explicitly tell users to run something like "modprobe tpm_tis_spi", which won't work anymore now.
So, if there is a good reason to break compatibility, I'm fine with that. But in this case, isn't there some way to achieve the desired functionality without changing the name? Even if it is a little more complex than the three-line change above, that would probably be worth it.
Alexander
Re: [PATCH v7 4/6] tpm: tpm_tis_spi: Support cr50 devices
Quoted 8 lines · Alexander Steffen
The scripts are effectively using modprobe/rmmod/etc. and those need the name. modprobe can be fixed by defining an alias, but this does not work for rmmod. Many other things also depend on the name, e.g. module blacklisting or the output of lsmod, where people might now get confused by the difference between "
tpm_tis_spi_mod" and "tpm_tis_i2c". Also, there are many tutorials out there, that explicitly tell users to run something like "modprobetpm_tis_spi", which won't work anymore now.
Quoted 4 lines
So, if there is a good reason to break compatibility, I'm fine with that. But in this case, isn't there some way to achieve the desired functionality without changing the name? Even if it is a little more complex than the three-line change above, that would probably be worth it.
Nope, you're right. I'll work out a fix for this and add you as reported-by.
/Jarkko
PATCH v7 5/6 tpm: tpm_tis_spi: Cleanup includes
In reply to Stephen BoydSome of these includes aren't used, for example of_gpio.h and freezer.h, or they are missing, for example kernel.h for min_t() usage. Add missing headers and remove unused ones so that we don't have to expand all these headers into this file when they're not actually necessary.
--- drivers/char/tpm/tpm_tis_spi.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-)
drivers/char/tpm/tpm_tis_spi.c +5 -9
@@ -20,22 +20,18 @@* Dorn and Kyleen Hall and Jarko Sakkinnen. */ +#include <linux/acpi.h> #include <linux/completion.h> #include <linux/init.h> +#include <linux/interrupt.h> +#include <linux/kernel.h> #include <linux/module.h> -#include <linux/moduleparam.h> #include <linux/slab.h> -#include <linux/interrupt.h> -#include <linux/wait.h> -#include <linux/acpi.h> -#include <linux/freezer.h> -#include <linux/spi/spi.h> -#include <linux/gpio.h> #include <linux/of_device.h> -#include <linux/of_irq.h> -#include <linux/of_gpio.h> +#include <linux/spi/spi.h> #include <linux/tpm.h> +#include "tpm.h" #include "tpm_tis_core.h" #include "tpm_tis_spi.h"
Signature · 1 line
Sent by a computer through tubes
Re: [PATCH v7 5/6] tpm: tpm_tis_spi: Cleanup includes
Quoted 5 lines · Stephen Boyd
Some of these includes aren't used, for example
of_gpio.handfreezer.h, or they are missing, for examplekernel.hformin_t()usage. Add missing headers and remove unused ones so that we don't have to expand all these headers into this file when they're not actually necessary.
Quoted 9 lines
Cc Andrey Pronin <[email protected]>Cc Duncan Laurie <[email protected]>Cc Jason Gunthorpe <[email protected]>Cc Arnd Bergmann <[email protected]>Cc Greg Kroah-Hartman <[email protected]>Cc Guenter Roeck <[email protected]>Cc Alexander Steffen <[email protected]>Cc Heiko Stuebner <[email protected]>Signed-off-by Stephen Boyd <[email protected]>
/Jarkko
PATCH v7 6/6 tpm: tpm_tis_spi: Drop THIS_MODULE usage from driver struct
In reply to Stephen BoydThe module_spi_driver() macro already inserts THIS_MODULE into the driver .owner field. Remove it to save a line.
--- drivers/char/tpm/tpm_tis_spi.c | 1 - 1 file changed, 1 deletion(-)
drivers/char/tpm/tpm_tis_spi.c +0 -1
@@ -283,7 +283,6 @@ MODULE_DEVICE_TABLE(acpi, acpi_tis_spi_match);static struct spi_driver tpm_tis_spi_driver = { .driver = { - .owner =THIS_MODULE , .name ="tpm_tis_spi" , .pm = &tpm_tis_pm, .of_match_table =of_match_ptr (of_tis_spi_match),
Signature · 1 line
Sent by a computer through tubes
Re: [PATCH v7 6/6] tpm: tpm_tis_spi: Drop THIS_MODULE usage from driver struct
Quoted 12 lines · Stephen Boyd
The
module_spi_driver()macro already insertsTHIS_MODULEinto the driver .owner field. Remove it to save a line.Cc Andrey Pronin <[email protected]>Cc Duncan Laurie <[email protected]>Cc Jason Gunthorpe <[email protected]>Cc Arnd Bergmann <[email protected]>Cc Greg Kroah-Hartman <[email protected]>Cc Guenter Roeck <[email protected]>Cc Alexander Steffen <[email protected]>Cc Heiko Stuebner <[email protected]>Signed-off-by Stephen Boyd <[email protected]>
/Jarkko
Quoted 69 lines · Stephen Boyd
This patch series adds support for the H1 secure microcontroller running cr50 firmware found on various recent Chromebooks. This driver is necessary to boot into a ChromeOS userspace environment. It implements support for several functions, including TPM-like functionality over a SPI interface.
The last time this was series sent looks to be [1]. I've looked over the patches and review comments and tried to address any feedback that Andrey didn't address (really minor things like newlines). I've reworked the patches from the last version to layer on top of the existing TPM TIS SPI implementation in
tpm_tis_spi.c. Hopefully this is more palatable than combining the two drivers together into one file.Please review so we can get the approach to supporting this device sorted out.
[1] https://lkml.kernel.org/r/[email protected]
TODO:
* Add a patch to spit outWARN_ON()when TPM is suspended and some kernel code attempts to use it
* Rework the i2c driver per Alexander's comments on v2Changes from v6 (https://lkml.kernel.org/r/[email protected]):
* Two new patches to cleanup includes and module usage
* Moved cr50 C file totpm_tis_spi_cr50.c
* Used thetpm_tis_spi_modtarget approach to make the module work
* Brought backKconfigoption to allow user to disable cr50 code
* Rebased to v5.3Changes from v5 (https://lkml.kernel.org/r/[email protected]):
* Picked up Jarkko's ack/review tags
* Fixed bug with irqs happening before completion is initialized
* Droppedis_cr50bool
* Movedwake_aftertotpm_tis_spistruct
* Changed authorship of main cr50 patch to Andrey as I'm just shuffling code hereChanges from v4 (https://lkml.kernel.org/r/[email protected]):
* Dropped the 'pre-transfer' hook patch and added a 'ready' member instead
* Combinedcr50_spiandtpm_tis_spiinto one kernel module
* Introduced a swizzle intpm_tis_spiprobe routine to jump to cr50 probe path
* Moved binding to start of the thread
* Picked up Jarkko reviewed-by tag on new flag for suspend/resume
* Added a comment to flow control patch indicating what it's all aboutChanges from v3:
* Split out hooks into separate patches
* Update commit text to not say "libify"
* Collapse if statement into one for first patch
* Update commit text on first patch to mention flag
* DropTIS_IS_CR50as it's unusedChanges from v2:
* Sent khwrng thread patch separately
* New patch to expose TPM SPI functionality fromtpm_tis_spi.c
* Usage of that new patch in cr50 SPI driver
* Drop i2c version of cr50 SPI driver for now (will resend later)
* New patch to add a TPM chip flag indicating TPM shouldn't be reset over suspend. Allows us to get rid of the cr50 suspend/resume functions that are mostly genericChanges from v1:
* Dropped symlink and sysfs patches
* Removed 'is_suspended' bits
* Added new patch to freeze khwrng thread
* Moved binding to google,cr50.txt and added Reviewed-by tag from Rob
Quoted 8 lines
Cc Andrey Pronin <[email protected]>Cc Duncan Laurie <[email protected]>Cc Jason Gunthorpe <[email protected]>Cc Arnd Bergmann <[email protected]>Cc Greg Kroah-Hartman <[email protected]>Cc Guenter Roeck <[email protected]>Cc Alexander Steffen <[email protected]>Cc Heiko Stuebner <[email protected]>
OK, so, I put these to my master in hopes to get testing exposure. I think the changes are in great shape now. Thank you.
/Jarkko
Heiko Stübner
Tested-byAm Montag, 7. Oktober 2019, 00:39:00 CEST schrieb Jarkko Sakkinen:
Quoted 18 lines · Stephen Boyd
Quoted 17 lines
This patch series adds support for the H1 secure microcontroller running cr50 firmware found on various recent Chromebooks. This driver is necessary to boot into a ChromeOS userspace environment. It implements support for several functions, including TPM-like functionality over a SPI interface.
The last time this was series sent looks to be [1]. I've looked over the patches and review comments and tried to address any feedback that Andrey didn't address (really minor things like newlines). I've reworked the patches from the last version to layer on top of the existing TPM TIS SPI implementation in
tpm_tis_spi.c. Hopefully this is more palatable than combining the two drivers together into one file.Please review so we can get the approach to supporting this device sorted out.
[...]
Quoted 2 lines
OK, so, I put these to my master in hopes to get testing exposure. I think the changes are in great shape now. Thank you.
on a rk3399-gru-bob it works nicely for me, so
Thanks
Heiko
Quoted 20 lines · Heiko Stübner
Am Montag, 7. Oktober 2019, 00:39:00 CEST schrieb Jarkko Sakkinen:
Quoted 14 lines · Stephen Boyd
Quoted 13 lines
This patch series adds support for the H1 secure microcontroller running cr50 firmware found on various recent Chromebooks. This driver is necessary to boot into a ChromeOS userspace environment. It implements support for several functions, including TPM-like functionality over a SPI interface.
The last time this was series sent looks to be [1]. I've looked over the patches and review comments and tried to address any feedback that Andrey didn't address (really minor things like newlines). I've reworked the patches from the last version to layer on top of the existing TPM TIS SPI implementation in
tpm_tis_spi.c. Hopefully this is more palatable than combining the two drivers together into one file.Quoted 4 lines
Quoted 4 lines
Please review so we can get the approach to supporting this device sorted out.
Quoted 7 lines
[...]
Quoted 2 lines
OK, so, I put these to my master in hopes to get testing exposure. I think the changes are in great shape now. Thank you.
on a rk3399-gru-bob it works nicely for me, so
Tested-by Heiko Stuebner <[email protected]>
Thank you! I updated my tree with your tag. Mind if I also add reviewed-by's?
/Jarkko
Heiko Stuebner
Reviewed-byHi,
Am Montag, 14. Oktober 2019, 21:56:30 CEST schrieb Jarkko Sakkinen:
Quoted 23 lines · Heiko Stübner
Quoted 22 lines
Am Montag, 7. Oktober 2019, 00:39:00 CEST schrieb Jarkko Sakkinen:
Quoted 18 lines · Stephen Boyd
Quoted 17 lines
This patch series adds support for the H1 secure microcontroller running cr50 firmware found on various recent Chromebooks. This driver is necessary to boot into a ChromeOS userspace environment. It implements support for several functions, including TPM-like functionality over a SPI interface.
The last time this was series sent looks to be [1]. I've looked over the patches and review comments and tried to address any feedback that Andrey didn't address (really minor things like newlines). I've reworked the patches from the last version to layer on top of the existing TPM TIS SPI implementation in
tpm_tis_spi.c. Hopefully this is more palatable than combining the two drivers together into one file.Please review so we can get the approach to supporting this device sorted out.
[...]
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
OK, so, I put these to my master in hopes to get testing exposure. I think the changes are in great shape now. Thank you.
on a rk3399-gru-bob it works nicely for me, so
Tested-by Heiko Stuebner <[email protected]>Thank you! I updated my tree with your tag. Mind if I also add reviewed-by's?
I think I did spent enough time with the patches to warrant that, so
Heiko
Quoted 29 lines · Heiko Stuebner
Hi,
Am Montag, 14. Oktober 2019, 21:56:30 CEST schrieb Jarkko Sakkinen:
Quoted 26 lines · Heiko Stübner
Quoted 25 lines
Am Montag, 7. Oktober 2019, 00:39:00 CEST schrieb Jarkko Sakkinen:
Quoted 18 lines · Stephen Boyd
Quoted 17 lines
This patch series adds support for the H1 secure microcontroller running cr50 firmware found on various recent Chromebooks. This driver is necessary to boot into a ChromeOS userspace environment. It implements support for several functions, including TPM-like functionality over a SPI interface.
The last time this was series sent looks to be [1]. I've looked over the patches and review comments and tried to address any feedback that Andrey didn't address (really minor things like newlines). I've reworked the patches from the last version to layer on top of the existing TPM TIS SPI implementation in
tpm_tis_spi.c. Hopefully this is more palatable than combining the two drivers together into one file.Please review so we can get the approach to supporting this device sorted out.
[...]
Quoted 2 lines
OK, so, I put these to my master in hopes to get testing exposure. I think the changes are in great shape now. Thank you.
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
on a rk3399-gru-bob it works nicely for me, so
Tested-by Heiko Stuebner <[email protected]>Thank you! I updated my tree with your tag. Mind if I also add reviewed-by's?
I think I did spent enough time with the patches to warrant that, so
Reviewed-by Heiko Stuebner <[email protected]>
Thank you!
/Jarkko