linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/1] tpm_tis: handle -EPROBE_DEFER in tpm_tis_plat_probe()
@ 2021-02-05 20:20 Dirk Gouders
  2021-02-05 20:20 ` [PATCH 1/1] " Dirk Gouders
  0 siblings, 1 reply; 3+ messages in thread
From: Dirk Gouders @ 2021-02-05 20:20 UTC (permalink / raw)
  To: Peter Huewe, Jarkko Sakkinen, Jason Gunthorpe
  Cc: Dirk Gouders, James Bottomley, linux-integrity, linux-kernel

Hello,

I noticed that the tpm_tis driver behaves different depending on
wether it was compiled builtin or as a module.

At least on my hardware, if builtin it always falls back to polling mode
without notification which I do not understand considering the current
efforts to fix interrupt probing[1].

The builtin case could be fixed by handling -EPROBE_DEFER.  With a
temporary dev_dbg() call added and James Bottomley's
"[PATCH v2 4/5] tpm_tis: fix IRQ probing [1]" applied my kernel log
looks like this:

[    2.671629] tpm_tis STM0125:00: Waiting for interrupt...
[    2.851920] tpm_tis STM0125:00: Waiting for interrupt...
[    2.852627] tpm_tis STM0125:00: Waiting for interrupt...
[    2.908286] tpm_tis STM0125:00: Waiting for interrupt...
[    3.340223] tpm_tis STM0125:00: Waiting for interrupt...
[    3.407238] tpm_tis STM0125:00: Waiting for interrupt...
[    3.408178] tpm_tis STM0125:00: Waiting for interrupt...
[    3.408994] tpm_tis STM0125:00: Waiting for interrupt...
[    3.487694] tpm_tis STM0125:00: Waiting for interrupt...
[    3.773769] tpm_tis STM0125:00: Waiting for interrupt...
[    3.868590] tpm_tis STM0125:00: Waiting for interrupt...
[    3.923855] tpm_tis STM0125:00: Waiting for interrupt...
[    4.235670] tpm_tis STM0125:00: Waiting for interrupt...
[    4.852556] tpm_tis STM0125:00: Waiting for interrupt...
[    6.767544] tpm_tis STM0125:00: 2.0 TPM (device-id 0x0, rev-id 78)
[    6.767567] tpm_tis STM0125:00: TPM interface capabilities (0x30000415):
[    6.767569] tpm_tis STM0125:00: 	Interrupt Level Low
[    6.767570] tpm_tis STM0125:00: 	Locality Change Int Support
[    6.767570] tpm_tis STM0125:00: 	Data Avail Int Support


Of course, this patch should not be added before Jarkko's fix [2], because
builtin drivers would then hit the WARN_ONCE(), as well.

Dirk


[1] https://lore.kernel.org/linux-integrity/20201001180925.13808-5-James.Bottomley@HansenPartnership.com/
[2] https://lore.kernel.org/linux-integrity/3936843b-c0da-dd8c-8aa9-90aa3b49d525@linux.ibm.com/T/#t

Dirk Gouders (1):
  tpm_tis: handle -EPROBE_DEFER in tpm_tis_plat_probe()

 drivers/char/tpm/tpm_tis.c | 3 +++
 1 file changed, 3 insertions(+)

-- 
2.26.2


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 1/1] tpm_tis: handle -EPROBE_DEFER in tpm_tis_plat_probe()
  2021-02-05 20:20 [PATCH 0/1] tpm_tis: handle -EPROBE_DEFER in tpm_tis_plat_probe() Dirk Gouders
@ 2021-02-05 20:20 ` Dirk Gouders
  2021-02-08  0:41   ` Jarkko Sakkinen
  0 siblings, 1 reply; 3+ messages in thread
From: Dirk Gouders @ 2021-02-05 20:20 UTC (permalink / raw)
  To: Peter Huewe, Jarkko Sakkinen, Jason Gunthorpe
  Cc: Dirk Gouders, James Bottomley, linux-integrity, linux-kernel

tpm_tis does not consider -EPROBE_DEFER in tpm_tis_plat_probe().
Instead, without notification it falls back to polling mode if
platform_get_irq_optional() returns a negative value.

This could lead to different behavior depending on wether tpm_tis was
compiled builtin or as a module; in the latter case
platform_get_irq_optional() often if not always returns a valid IRQ
number on the first attempt.

Harmonize builtin and module behavior by returning -EPROBE_DEFER,
effectively putting the device on the deferred probe list for later
probe attempts.

Signed-off-by: Dirk Gouders <dirk@gouders.net>
---
 drivers/char/tpm/tpm_tis.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/char/tpm/tpm_tis.c b/drivers/char/tpm/tpm_tis.c
index 4ed6e660273a..4cf863704aa1 100644
--- a/drivers/char/tpm/tpm_tis.c
+++ b/drivers/char/tpm/tpm_tis.c
@@ -320,6 +320,9 @@ static int tpm_tis_plat_probe(struct platform_device *pdev)
 
 	tpm_info.irq = platform_get_irq_optional(pdev, 0);
 	if (tpm_info.irq <= 0) {
+                if (tpm_info.irq == -EPROBE_DEFER)
+                        /* Enter deferred probe list and try again, later. */
+                        return -EPROBE_DEFER;
 		if (pdev != force_pdev)
 			tpm_info.irq = -1;
 		else
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/1] tpm_tis: handle -EPROBE_DEFER in tpm_tis_plat_probe()
  2021-02-05 20:20 ` [PATCH 1/1] " Dirk Gouders
@ 2021-02-08  0:41   ` Jarkko Sakkinen
  0 siblings, 0 replies; 3+ messages in thread
From: Jarkko Sakkinen @ 2021-02-08  0:41 UTC (permalink / raw)
  To: Dirk Gouders
  Cc: Peter Huewe, Jason Gunthorpe, James Bottomley, linux-integrity,
	linux-kernel

On Fri, Feb 05, 2021 at 09:20:22PM +0100, Dirk Gouders wrote:
> tpm_tis does not consider -EPROBE_DEFER in tpm_tis_plat_probe().
> Instead, without notification it falls back to polling mode if
> platform_get_irq_optional() returns a negative value.
> 
> This could lead to different behavior depending on wether tpm_tis was
> compiled builtin or as a module; in the latter case
> platform_get_irq_optional() often if not always returns a valid IRQ
> number on the first attempt.
> 
> Harmonize builtin and module behavior by returning -EPROBE_DEFER,
> effectively putting the device on the deferred probe list for later
> probe attempts.
> 
> Signed-off-by: Dirk Gouders <dirk@gouders.net>

This would be best picked to James' patch set.

> ---
>  drivers/char/tpm/tpm_tis.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/char/tpm/tpm_tis.c b/drivers/char/tpm/tpm_tis.c
> index 4ed6e660273a..4cf863704aa1 100644
> --- a/drivers/char/tpm/tpm_tis.c
> +++ b/drivers/char/tpm/tpm_tis.c
> @@ -320,6 +320,9 @@ static int tpm_tis_plat_probe(struct platform_device *pdev)
>  
>  	tpm_info.irq = platform_get_irq_optional(pdev, 0);
>  	if (tpm_info.irq <= 0) {
> +                if (tpm_info.irq == -EPROBE_DEFER)
> +                        /* Enter deferred probe list and try again, later. */
> +                        return -EPROBE_DEFER;
>  		if (pdev != force_pdev)
>  			tpm_info.irq = -1;
>  		else
> -- 
> 2.26.2
> 
> 

/Jarkko

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-02-08  0:42 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-05 20:20 [PATCH 0/1] tpm_tis: handle -EPROBE_DEFER in tpm_tis_plat_probe() Dirk Gouders
2021-02-05 20:20 ` [PATCH 1/1] " Dirk Gouders
2021-02-08  0:41   ` Jarkko Sakkinen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).