* [PATCH] tpm_tis: Re-enable interrupts upon resume
@ 2011-02-22 19:49 Stefan Berger
2011-02-26 11:46 ` Jiri Slaby
2011-03-01 7:45 ` [PATCH v2] " Stefan Berger
0 siblings, 2 replies; 4+ messages in thread
From: Stefan Berger @ 2011-02-22 19:49 UTC (permalink / raw)
To: Jiri Slaby, preining, Linux kernel mailing list, Rajiv Andrade,
debora@linux.vnet.ibm.com
Below patch applies to the tip of the git tree.
This patch makes sure that if the TPM TIS interface is run in interrupt
mode (rather than polling mode) that the interrupts are enabled in the
TPM's interrupt enable register which may either have been cleared by
the TPM's TIS loosing its state during device sleep in ACPI S3 (suspend)
or by the BIOS, which upon resume sends a TPM_Startup() command to the
TPM, and may run the TPM in polling mode and leave the TIS interrupts
disabled once it transfers control to the OS again.
Problem is, I don't currently have a machine running the TPM in
interrupt mode. I found this through a self-built TPM device model for
Qemu and SeaBIOS patches, where this does resolve a problem upon resume.
You may want to check if your TPM runs with interrupts by doing
cat /proc/interrupts | grep -i tpm
and see whether there is an entry.
Signed-off-by: Stefan Berger <stefanb@us.ibm.com>
Index: linux-2.6/drivers/char/tpm/tpm_tis.c
===================================================================
--- linux-2.6.orig/drivers/char/tpm/tpm_tis.c
+++ linux-2.6/drivers/char/tpm/tpm_tis.c
@@ -651,6 +651,23 @@ static int tpm_tis_pnp_resume(struct pnp
{
struct tpm_chip *chip = pnp_get_drvdata(dev);
int ret;
+ u32 intmask;
+
+ if (chip->vendor.irq) {
+ /* reenable interrupts that device may have lost or
+ BIOS/firmware may have disabled */
+ intmask =
+ ioread32(chip->vendor.iobase +
+ TPM_INT_ENABLE(chip->vendor.locality));
+
+ intmask |= TPM_INTF_CMD_READY_INT
+ | TPM_INTF_LOCALITY_CHANGE_INT | TPM_INTF_DATA_AVAIL_INT
+ | TPM_INTF_STS_VALID_INT | TPM_GLOBAL_INT_ENABLE;
+
+ iowrite32(intmask,
+ chip->vendor.iobase +
+ TPM_INT_ENABLE(chip->vendor.locality));
+ }
ret = tpm_pm_resume(&dev->dev);
if (!ret)
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] tpm_tis: Re-enable interrupts upon resume
2011-02-22 19:49 [PATCH] tpm_tis: Re-enable interrupts upon resume Stefan Berger
@ 2011-02-26 11:46 ` Jiri Slaby
2011-02-26 13:50 ` Stefan Berger
2011-03-01 7:45 ` [PATCH v2] " Stefan Berger
1 sibling, 1 reply; 4+ messages in thread
From: Jiri Slaby @ 2011-02-26 11:46 UTC (permalink / raw)
To: Stefan Berger
Cc: preining, Linux kernel mailing list, Rajiv Andrade,
debora@linux.vnet.ibm.com
On 02/22/2011 08:49 PM, Stefan Berger wrote:
> Below patch applies to the tip of the git tree.
>
> This patch makes sure that if the TPM TIS interface is run in interrupt
> mode (rather than polling mode) that the interrupts are enabled in the
> TPM's interrupt enable register which may either have been cleared by
> the TPM's TIS loosing its state during device sleep in ACPI S3 (suspend)
> or by the BIOS, which upon resume sends a TPM_Startup() command to the
> TPM, and may run the TPM in polling mode and leave the TIS interrupts
> disabled once it transfers control to the OS again.
>
> Problem is, I don't currently have a machine running the TPM in
> interrupt mode. I found this through a self-built TPM device model for
> Qemu and SeaBIOS patches, where this does resolve a problem upon resume.
>
> You may want to check if your TPM runs with interrupts by doing
>
> cat /proc/interrupts | grep -i tpm
No, this is empty output.
regards,
--
js
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] tpm_tis: Re-enable interrupts upon resume
2011-02-26 11:46 ` Jiri Slaby
@ 2011-02-26 13:50 ` Stefan Berger
0 siblings, 0 replies; 4+ messages in thread
From: Stefan Berger @ 2011-02-26 13:50 UTC (permalink / raw)
To: Jiri Slaby
Cc: preining, Linux kernel mailing list, Rajiv Andrade,
debora@linux.vnet.ibm.com
On 02/26/2011 06:46 AM, Jiri Slaby wrote:
> On 02/22/2011 08:49 PM, Stefan Berger wrote:
>> Below patch applies to the tip of the git tree.
>>
>> This patch makes sure that if the TPM TIS interface is run in interrupt
>> mode (rather than polling mode) that the interrupts are enabled in the
>> TPM's interrupt enable register which may either have been cleared by
>> the TPM's TIS loosing its state during device sleep in ACPI S3 (suspend)
>> or by the BIOS, which upon resume sends a TPM_Startup() command to the
>> TPM, and may run the TPM in polling mode and leave the TIS interrupts
>> disabled once it transfers control to the OS again.
>>
>> Problem is, I don't currently have a machine running the TPM in
>> interrupt mode. I found this through a self-built TPM device model for
>> Qemu and SeaBIOS patches, where this does resolve a problem upon resume.
>>
>> You may want to check if your TPM runs with interrupts by doing
>>
>> cat /proc/interrupts | grep -i tpm
> No, this is empty output.
Ok. That's what most TPM seem to do now -- they run in polling mode.
Stefan
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v2] tpm_tis: Re-enable interrupts upon resume
2011-02-22 19:49 [PATCH] tpm_tis: Re-enable interrupts upon resume Stefan Berger
2011-02-26 11:46 ` Jiri Slaby
@ 2011-03-01 7:45 ` Stefan Berger
1 sibling, 0 replies; 4+ messages in thread
From: Stefan Berger @ 2011-03-01 7:45 UTC (permalink / raw)
To: Jiri Slaby
Cc: preining, Linux kernel mailing list, Rajiv Andrade,
debora@linux.vnet.ibm.com
v2:
- the patch was adapted to also work with a machine with a Intel TPM
Below patch applies to the tip of the git tree.
This patch makes sure that if the TPM TIS interface is run in interrupt
mode (rather than polling mode) that the interrupts are enabled in the
TPM's interrupt enable register which may either have been cleared by
the TPM's TIS loosing its state during device sleep in ACPI S3 (suspend)
or by the BIOS, which upon resume sends a TPM_Startup() command to the
TPM, and may run the TPM in polling mode and leave the TIS interrupts
disabled once it transfers control to the OS again.
You may want to check if your TPM runs with interrupts by doing
cat /proc/interrupts | grep -i tpm
and see whether there is an entry or otherwise for it to use interrupts:
modprobe tpm_tis interrupts=1 [add 'itpm=1' for Intel TPM ]
Signed-off-by: Stefan Berger <stefanb@us.ibm.com>
---
drivers/char/tpm/tpm_tis.c | 31 +++++++++++++++++++++++++++++++
1 file changed, 31 insertions(+)
Index: linux-2.6/drivers/char/tpm/tpm_tis.c
===================================================================
--- linux-2.6.orig/drivers/char/tpm/tpm_tis.c
+++ linux-2.6/drivers/char/tpm/tpm_tis.c
@@ -647,11 +647,37 @@ static int tpm_tis_pnp_suspend(struct pn
return tpm_pm_suspend(&dev->dev, msg);
}
+static void tpm_tis_reenable_interrupts(struct tpm_chip *chip)
+{
+ u32 intmask;
+
+ /* reenable interrupts that device may have lost or
+ BIOS/firmware may have disabled */
+ iowrite8(chip->vendor.irq, chip->vendor.iobase +
+ TPM_INT_VECTOR(chip->vendor.locality));
+
+ intmask =
+ ioread32(chip->vendor.iobase +
+ TPM_INT_ENABLE(chip->vendor.locality));
+
+ intmask |= TPM_INTF_CMD_READY_INT
+ | TPM_INTF_LOCALITY_CHANGE_INT | TPM_INTF_DATA_AVAIL_INT
+ | TPM_INTF_STS_VALID_INT | TPM_GLOBAL_INT_ENABLE;
+
+ iowrite32(intmask,
+ chip->vendor.iobase +
+ TPM_INT_ENABLE(chip->vendor.locality));
+}
+
+
static int tpm_tis_pnp_resume(struct pnp_dev *dev)
{
struct tpm_chip *chip = pnp_get_drvdata(dev);
int ret;
+ if (chip->vendor.irq)
+ tpm_tis_reenable_interrupts(chip);
+
ret = tpm_pm_resume(&dev->dev);
if (!ret)
tpm_continue_selftest(chip);
@@ -704,6 +730,11 @@ static int tpm_tis_suspend(struct platfo
static int tpm_tis_resume(struct platform_device *dev)
{
+ struct tpm_chip *chip = dev_get_drvdata(&dev->dev);
+
+ if (chip->vendor.irq)
+ tpm_tis_reenable_interrupts(chip);
+
return tpm_pm_resume(&dev->dev);
}
static struct platform_driver tis_drv = {
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2011-03-01 7:45 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-02-22 19:49 [PATCH] tpm_tis: Re-enable interrupts upon resume Stefan Berger
2011-02-26 11:46 ` Jiri Slaby
2011-02-26 13:50 ` Stefan Berger
2011-03-01 7:45 ` [PATCH v2] " Stefan Berger
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox