tpm: tpm_tis: Add optional delay after relinquish
Subsystems (3)
PATCH 1/1 tpm: tpm_tis: Add optional delay after relinquish
Some TPMs fail to grant locality when requested immediately after being relinquished. In this case, the TPM_ACCESS_REQUEST_USE bit of the TPM_ACCESS register is cleared immediately without setting TPM_ACCESS_ACTIVE_LOCALITY.
This issue can be seen at boot since tpm_chip_start, called right after locality is relinquished, fails. This causes the probe to fail:
tpm_tis MSFT0101:00: probe with driver tpm_tis failed with error -1
This occurs on some older Dell Latitudes and maybe others. To work around this, add a "settle" boolean param to tpm_tis. When this is enabled, a delay is added after locality is relinquished.
--- Documentation/admin-guide/kernel-parameters.txt | 7 +++++++ drivers/char/tpm/tpm_tis.c | 7 +++++++ drivers/char/tpm/tpm_tis_core.c | 3 +++ drivers/char/tpm/tpm_tis_core.h | 1 + 4 files changed, 18 insertions(+)
Documentation/admin-guide/kernel-parameters.txt +7 -0
@@ -7651,6 +7651,13 @@ Kernel parameters defined by Trusted Computing Group (TCG) see https://trustedcomputinggroup.org/resource/pc-client-platform-tpm-profile-ptp-specification/ + tpm_tis.settle= [HW,TPM] + Format: <bool> + When enabled, this adds a delay after locality is + relinquished. Some TPMs will fail to grant locality if + requested immediately after being relinquished. This + causes the probe to fail. + tp_printk [FTRACE] Have the tracepoints sent to printk as well as the tracing ring buffer. This is useful for early boot up
drivers/char/tpm/tpm_tis.c +7 -0
@@ -101,6 +101,10 @@ module_param(force, bool, 0444);MODULE_PARM_DESC (force,"Force device probe rather than using ACPI entry" );#endif +static bool settle; +module_param (settle, bool,0444 ); +MODULE_PARM_DESC (settle,"Add settle time after relinquish" ); +#if defined(CONFIG_PNP ) && defined(CONFIG_ACPI )static int has_hid (struct acpi_device *dev,const char *hid) {
@@ -242,6 +246,9 @@ static int tpm_tis_init(struct device *dev, struct tpm_info *tpm_info)if (itpm ||is_itpm (ACPI_COMPANION (dev)))set_bit (TPM_TIS_ITPM_WORKAROUND , &phy->priv.flags); +if (settle) +set_bit (TPM_TIS_SETTLE_AFTER_RELINQUISH , &phy->priv.flags); +return tpm_tis_core_init (dev, &phy->priv, irq, &tpm_tcg,ACPI_HANDLE (dev)); }
drivers/char/tpm/tpm_tis_core.c +3 -0
@@ -184,6 +184,9 @@ static int tpm_tis_relinquish_locality(struct tpm_chip *chip, int l)__tpm_tis_relinquish_locality (priv, l);mutex_unlock (&priv->locality_count_mutex); +if (test_bit (TPM_TIS_SETTLE_AFTER_RELINQUISH , &priv->flags)) +tpm_msleep (TPM_TIMEOUT ); +return 0 ; }
drivers/char/tpm/tpm_tis_core.h +1 -0
@@ -90,6 +90,7 @@ enum tpm_tis_flags {TPM_TIS_DEFAULT_CANCELLATION =2 ,TPM_TIS_IRQ_TESTED =3 ,TPM_TIS_STATUS_VALID_RETRY =4 , + TPM_TIS_SETTLE_AFTER_RELINQUISH = 5, }; struct tpm_tis_data {
Signature · 1 line
2.54.0
I realize the delay should be moved to __tpm_tis_relinquish_locality. I'll change that in a v2 patch.
Quoted 95 lines · Jim Broadus
Some TPMs fail to grant locality when requested immediately after being relinquished. In this case, the
TPM_ACCESS_REQUEST_USEbit of theTPM_ACCESSregister is cleared immediately without settingTPM_ACCESS_ACTIVE_LOCALITY.This issue can be seen at boot since
tpm_chip_start, called right after locality is relinquished, fails. This causes the probe to fail:
tpm_tisMSFT0101:00: probe with drivertpm_tisfailed with error -1This occurs on some older Dell Latitudes and maybe others. To work around this, add a "settle" boolean param to
tpm_tis. When this is enabled, a delay is added after locality is relinquished.Signed-off-by Jim Broadus <[email protected]>--- Documentation/admin-guide/kernel-parameters.txt | 7 +++++++ drivers/char/tpm/tpm_tis.c | 7 +++++++ drivers/char/tpm/tpm_tis_core.c | 3 +++ drivers/char/tpm/tpm_tis_core.h | 1 + 4 files changed, 18 insertions(+)Documentation/admin-guide/kernel-parameters.txt +7
-0@@ -7651,6 +7651,13 @@ Kernel parameters defined by Trusted Computing Group (TCG) see https://trustedcomputinggroup.org/resource/pc-client-platform-tpm-profile-ptp-specification/ + tpm_tis.settle= [HW,TPM] + Format: <bool> + When enabled, this adds a delay after locality is + relinquished. Some TPMs will fail to grant locality if + requested immediately after being relinquished. This + causes the probe to fail. + tp_printk [FTRACE] Have the tracepoints sent to printk as well as the tracing ring buffer. This is useful for early boot updrivers/char/tpm/tpm_tis.c +7
-0@@ -101,6 +101,10 @@ module_param(force, bool, 0444);MODULE_PARM_DESC (force,"Force device probe rather than using ACPI entry" );#endif +static bool settle; +module_param (settle, bool,0444 ); +MODULE_PARM_DESC (settle,"Add settle time after relinquish" ); +#if defined(CONFIG_PNP ) && defined(CONFIG_ACPI )static int has_hid (struct acpi_device *dev,const char *hid) {@@ -242,6 +246,9 @@ static int tpm_tis_init(struct device *dev, struct tpm_info *tpm_info)if (itpm ||is_itpm (ACPI_COMPANION (dev)))set_bit (TPM_TIS_ITPM_WORKAROUND , &phy->priv.flags); +if (settle) +set_bit (TPM_TIS_SETTLE_AFTER_RELINQUISH , &phy->priv.flags); +return tpm_tis_core_init (dev, &phy->priv, irq, &tpm_tcg,ACPI_HANDLE (dev)); }drivers/char/tpm/tpm_tis_core.c +3
-0@@ -184,6 +184,9 @@ static int tpm_tis_relinquish_locality(struct tpm_chip *chip, int l)__tpm_tis_relinquish_locality (priv, l);mutex_unlock (&priv->locality_count_mutex); +if (test_bit (TPM_TIS_SETTLE_AFTER_RELINQUISH , &priv->flags)) +tpm_msleep (TPM_TIMEOUT ); +return 0 ; }drivers/char/tpm/tpm_tis_core.h +1
-1@@ -90,6 +90,7 @@ enum tpm_tis_flags {TPM_TIS_DEFAULT_CANCELLATION =2 ,TPM_TIS_IRQ_TESTED =3 ,TPM_TIS_STATUS_VALID_RETRY =4 , + TPM_TIS_SETTLE_AFTER_RELINQUISH = 5, }; struct tpm_tis_data { --2.54.0
Jarkko Sakkinen
maintainerQuoted 8 lines · Jim Broadus
Some TPMs fail to grant locality when requested immediately after being relinquished. In this case, the
TPM_ACCESS_REQUEST_USEbit of theTPM_ACCESSregister is cleared immediately without settingTPM_ACCESS_ACTIVE_LOCALITY.This issue can be seen at boot since
tpm_chip_start, called right after locality is relinquished, fails. This causes the probe to fail:
Quoted 7 lines
tpm_tisMSFT0101:00: probe with drivertpm_tisfailed with error -1This occurs on some older Dell Latitudes and maybe others. To work around this, add a "settle" boolean param to
tpm_tis. When this is enabled, a delay is added after locality is relinquished.Signed-off-by Jim Broadus <[email protected]>
It would be better idea first to replace priv->manufacturer_id with priv->did_vid, and make necessary changes to sites where it is used.
Then in the if-statement compare DID/VID of the device to priv->did_vid and apply quirk only if it matches.
Quoted 79 lines
--- Documentation/admin-guide/kernel-parameters.txt | 7 +++++++ drivers/char/tpm/tpm_tis.c | 7 +++++++ drivers/char/tpm/tpm_tis_core.c | 3 +++ drivers/char/tpm/tpm_tis_core.h | 1 + 4 files changed, 18 insertions(+)Documentation/admin-guide/kernel-parameters.txt +7
-0@@ -7651,6 +7651,13 @@ Kernel parameters defined by Trusted Computing Group (TCG) see https://trustedcomputinggroup.org/resource/pc-client-platform-tpm-profile-ptp-specification/ + tpm_tis.settle= [HW,TPM] + Format: <bool> + When enabled, this adds a delay after locality is + relinquished. Some TPMs will fail to grant locality if + requested immediately after being relinquished. This + causes the probe to fail. + tp_printk [FTRACE] Have the tracepoints sent to printk as well as the tracing ring buffer. This is useful for early boot updrivers/char/tpm/tpm_tis.c +7
-0@@ -101,6 +101,10 @@ module_param(force, bool, 0444);MODULE_PARM_DESC (force,"Force device probe rather than using ACPI entry" );#endif +static bool settle; +module_param (settle, bool,0444 ); +MODULE_PARM_DESC (settle,"Add settle time after relinquish" ); +#if defined(CONFIG_PNP ) && defined(CONFIG_ACPI )static int has_hid (struct acpi_device *dev,const char *hid) {@@ -242,6 +246,9 @@ static int tpm_tis_init(struct device *dev, struct tpm_info *tpm_info)if (itpm ||is_itpm (ACPI_COMPANION (dev)))set_bit (TPM_TIS_ITPM_WORKAROUND , &phy->priv.flags); +if (settle) +set_bit (TPM_TIS_SETTLE_AFTER_RELINQUISH , &phy->priv.flags); +return tpm_tis_core_init (dev, &phy->priv, irq, &tpm_tcg,ACPI_HANDLE (dev)); }drivers/char/tpm/tpm_tis_core.c +3
-0@@ -184,6 +184,9 @@ static int tpm_tis_relinquish_locality(struct tpm_chip *chip, int l)__tpm_tis_relinquish_locality (priv, l);mutex_unlock (&priv->locality_count_mutex); +if (test_bit (TPM_TIS_SETTLE_AFTER_RELINQUISH , &priv->flags)) +tpm_msleep (TPM_TIMEOUT ); +return 0 ; }drivers/char/tpm/tpm_tis_core.h +1
-0@@ -90,6 +90,7 @@ enum tpm_tis_flags {TPM_TIS_DEFAULT_CANCELLATION =2 ,TPM_TIS_IRQ_TESTED =3 ,TPM_TIS_STATUS_VALID_RETRY =4 , + TPM_TIS_SETTLE_AFTER_RELINQUISH = 5, }; struct tpm_tis_data {Signature · 1 line
2.54.0
BR, Jarkko
Thank you Jarkko. I'll do that.
Jim
Quoted 105 lines · Jarkko Sakkinen
Quoted 8 lines · Jim Broadus
Some TPMs fail to grant locality when requested immediately after being relinquished. In this case, the
TPM_ACCESS_REQUEST_USEbit of theTPM_ACCESSregister is cleared immediately without settingTPM_ACCESS_ACTIVE_LOCALITY.This issue can be seen at boot since
tpm_chip_start, called right after locality is relinquished, fails. This causes the probe to fail:Quoted 7 lines
tpm_tisMSFT0101:00: probe with drivertpm_tisfailed with error -1This occurs on some older Dell Latitudes and maybe others. To work around this, add a "settle" boolean param to
tpm_tis. When this is enabled, a delay is added after locality is relinquished.Signed-off-by Jim Broadus <[email protected]>It would be better idea first to replace
priv->manufacturer_idwithpriv->did_vid, and make necessary changes to sites where it is used.Then in the if-statement compare DID/VID of the device to
priv->did_vidand apply quirk only if it matches.Quoted 77 lines
--- Documentation/admin-guide/kernel-parameters.txt | 7 +++++++ drivers/char/tpm/tpm_tis.c | 7 +++++++ drivers/char/tpm/tpm_tis_core.c | 3 +++ drivers/char/tpm/tpm_tis_core.h | 1 + 4 files changed, 18 insertions(+)Documentation/admin-guide/kernel-parameters.txt +7
-0@@ -7651,6 +7651,13 @@ Kernel parameters defined by Trusted Computing Group (TCG) see https://trustedcomputinggroup.org/resource/pc-client-platform-tpm-profile-ptp-specification/ + tpm_tis.settle= [HW,TPM] + Format: <bool> + When enabled, this adds a delay after locality is + relinquished. Some TPMs will fail to grant locality if + requested immediately after being relinquished. This + causes the probe to fail. + tp_printk [FTRACE] Have the tracepoints sent to printk as well as the tracing ring buffer. This is useful for early boot updrivers/char/tpm/tpm_tis.c +7
-0@@ -101,6 +101,10 @@ module_param(force, bool, 0444);MODULE_PARM_DESC (force,"Force device probe rather than using ACPI entry" );#endif +static bool settle; +module_param (settle, bool,0444 ); +MODULE_PARM_DESC (settle,"Add settle time after relinquish" ); +#if defined(CONFIG_PNP ) && defined(CONFIG_ACPI )static int has_hid (struct acpi_device *dev,const char *hid) {@@ -242,6 +246,9 @@ static int tpm_tis_init(struct device *dev, struct tpm_info *tpm_info)if (itpm ||is_itpm (ACPI_COMPANION (dev)))set_bit (TPM_TIS_ITPM_WORKAROUND , &phy->priv.flags); +if (settle) +set_bit (TPM_TIS_SETTLE_AFTER_RELINQUISH , &phy->priv.flags); +return tpm_tis_core_init (dev, &phy->priv, irq, &tpm_tcg,ACPI_HANDLE (dev)); }drivers/char/tpm/tpm_tis_core.c +3
-0@@ -184,6 +184,9 @@ static int tpm_tis_relinquish_locality(struct tpm_chip *chip, int l)__tpm_tis_relinquish_locality (priv, l);mutex_unlock (&priv->locality_count_mutex); +if (test_bit (TPM_TIS_SETTLE_AFTER_RELINQUISH , &priv->flags)) +tpm_msleep (TPM_TIMEOUT ); +return 0 ; }drivers/char/tpm/tpm_tis_core.h +1
-1@@ -90,6 +90,7 @@ enum tpm_tis_flags {TPM_TIS_DEFAULT_CANCELLATION =2 ,TPM_TIS_IRQ_TESTED =3 ,TPM_TIS_STATUS_VALID_RETRY =4 , + TPM_TIS_SETTLE_AFTER_RELINQUISH = 5, }; struct tpm_tis_data { --Quoted 2 lines
2.54.0
BR, Jarkko
Jarkko Sakkinen
maintainerQuoted 3 lines · Jim Broadus
Thank you Jarkko. I'll do that.
Jim
Yeah, in this form it is quite unsable e.g., for any Linux distribution, and somewhat involved for the user :-)
Conditionally on is much better with appropriate detection. Also, this way the change improves the code base a bit given that chip->did_vid is much more applicable than chip->manufaturer_id.
BR, Jarkko
Hi Jarkko. The current manufacturer_id is in tpm_tis_data, not tpm_chip. I think it makes sense to move the new did_vid to tpm_chip so it can be used in tpm-sysfs, but it would only be set (at least initially) for the tpm_tis driver. What do you think?
Thank you,
Jim
Quoted 12 lines · Jarkko Sakkinen
Quoted 3 lines · Jim Broadus
Thank you Jarkko. I'll do that.
Jim
Yeah, in this form it is quite unsable e.g., for any Linux distribution, and somewhat involved for the user :-)
Conditionally on is much better with appropriate detection. Also, this way the change improves the code base a bit given that
chip->did_vidis much more applicable thanchip->manufaturer_id.BR, Jarkko
Jarkko Sakkinen
maintainerQuoted 4 lines · Jim Broadus
Hi Jarkko. The current
manufacturer_idis intpm_tis_data, nottpm_chip. I think it makes sense to move the newdid_vidtotpm_chipso it can be used in tpm-sysfs, but it would only be set (at least initially) for thetpm_tisdriver. What do you think?
Oops. Sorry, I just described myself incorrectly.
What I actually meant was adding priv->did_vid.
Thanks for paying attention!
Quoted 17 lines
Thank you,
JimQuoted 12 lines · Jarkko Sakkinen
Quoted 3 lines · Jim Broadus
Thank you Jarkko. I'll do that.
Jim
Yeah, in this form it is quite unsable e.g., for any Linux distribution, and somewhat involved for the user :-)
Conditionally on is much better with appropriate detection. Also, this way the change improves the code base a bit given that
chip->did_vidis much more applicable thanchip->manufaturer_id.BR, Jarkko
BR, Jarkko