Skip to contentSkip to conversation

tpm,tpm_tis: Avoid warning splat at shutdown

PATCH In review Lino Sanfilippo 4 participants 8 messages Feb 1, 2024 – Mar 7, 2024

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tpm,tpm_tis: Avoid warning splat at shutdown

If interrupts are not activated the work struct 'free_irq_work' is not initialized. This results in a warning splat at module shutdown.

Fix this by always initializing the work regardless of whether interrupts are activated or not.

Fixes 481c2d14627d ("tpm,tpm_tis: Disable interrupts after 1000 unhandled IRQs")
---
 drivers/char/tpm/tpm_tis_core.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/char/tpm/tpm_tis_core.c +1 -2
index 1b350412d8a6..64c875657687 100644
@@ -919,8 +919,6 @@ static int tpm_tis_probe_irq_single(struct tpm_chip *chip, u32 intmask,
 	int rc;
 	u32 int_status;
 
-	INIT_WORK(&priv->free_irq_work, tpm_tis_free_irq_func);
-
 	rc = devm_request_threaded_irq(chip->dev.parent, irq, NULL,
 				       tis_int_handler, IRQF_ONESHOT | flags,
 				       dev_name(&chip->dev), chip);
@@ -1132,6 +1130,7 @@ int tpm_tis_core_init(struct device *dev, struct tpm_tis_data *priv, int irq,
 	priv->phy_ops = phy_ops;
 	priv->locality_count = 0;
 	mutex_init(&priv->locality_count_mutex);
+	INIT_WORK(&priv->free_irq_work, tpm_tis_free_irq_func);
 
 	dev_set_drvdata(&chip->dev, priv);
 

base-commit: 41bccc98fb7931d63d03f326a746ac4d429c1dd3

Signature · 1 line
2.43.0
#1 lore raw
Quoted 9 lines

From: Lino Sanfilippo <[email protected]>
Sent: Thursday, February 1, 2024 5:37 AM
Subject: [PATCH] tpm,tpm_tis: Avoid warning splat at shutdown

If interrupts are not activated the work struct 'free_irq_work' is not initialized. This results in a warning splat at module shutdown.

Fix this by always initializing the work regardless of whether interrupts are activated or not.

That's using flush_work(), which just waits for one to complete. Is there any case where multiple work entries could be queued, and cancel_work_sync() would be necessary?

tpm_tis_probe_irq() has a loop calling tpm_tis_probe_irq_single() for 3 to 15. Could each of those could trigger an interrupt storm and call tpm_tis_revert_interrupts(), which calls schedule_work()?

maintainer
#2 lore raw
Quoted 7 lines · Robert (Servers)
Quoted 7 lines

From: Lino Sanfilippo <[email protected]>
Sent: Thursday, February 1, 2024 5:37 AM
Subject: [PATCH] tpm,tpm_tis: Avoid warning splat at shutdown

If interrupts are not activated the work struct 'free_irq_work' is not initialized. This results in a warning splat at module shutdown.

Quoted 6 lines
Quoted 2 lines

Fix this by always initializing the work regardless of whether interrupts are activated or not.

That's using flush_work(), which just waits for one to complete. Is there any case where multiple work entries could be queued, and cancel_work_sync() would be necessary?

Questions are cool but please explain how this aligns with the patch review because I already accepted the patch.

Should I drop it based on this question, and if so, why?

Quoted 3 lines

tpm_tis_probe_irq() has a loop calling tpm_tis_probe_irq_single() for 3 to 15. Could each of those could trigger an interrupt storm and call tpm_tis_revert_interrupts(), which calls schedule_work()?

AFAIK no based on that TPM_CHIP_FLAG_IRQ should take care of this.

BR, Jarkko

#3 lore raw
In reply to Elliott, Robert (Servers)
Quoted 10 lines · Robert (Servers)

ATTENTION: This e-mail is from an external sender. Please check attachments and links before opening e.g. with mouseover.

Quoted 7 lines

From: Lino Sanfilippo <[email protected]>
Sent: Thursday, February 1, 2024 5:37 AM
Subject: [PATCH] tpm,tpm_tis: Avoid warning splat at shutdown

If interrupts are not activated the work struct 'free_irq_work' is not initialized. This results in a warning splat at module shutdown.

Quoted 7 lines
Quoted 2 lines

Fix this by always initializing the work regardless of whether interrupts are activated or not.

That's using flush_work(), which just waits for one to complete. Is there any case where multiple work entries could be queued, and cancel_work_sync() would be necessary?

No. There is only one work struct (namely free_irq_work) and it can only be queued once at a time (note that schedule_work() does not queue the same work again if it is already queued).

Quoted 5 lines

tpm_tis_probe_irq() has a loop calling tpm_tis_probe_irq_single() for 3 to 15. Could each of those could trigger an interrupt storm and call tpm_tis_revert_interrupts(), which calls schedule_work()?

The iteration stops as soon as there is an interrupt found that "works" (i.e. as soon as one interrupt fires, see the "irq test" in tpm_tis_send()). If this irq starts a storm it is handled by the implemented irq storm handling and deactivated. No other interrupts are activated afterwards. So no, I do not see that multiple interrupt storms are possible at the same time.

Regards,
Lino

maintainer Reviewed-by on v1 1/1
#4 lore raw
In reply to Lino Sanfilippo
Quoted 37 lines · Lino Sanfilippo

If interrupts are not activated the work struct 'free_irq_work' is not initialized. This results in a warning splat at module shutdown.

Fix this by always initializing the work regardless of whether interrupts are activated or not.

Fixes 481c2d14627d ("tpm,tpm_tis: Disable interrupts after 1000 unhandled IRQs")
---
 drivers/char/tpm/tpm_tis_core.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/char/tpm/tpm_tis_core.c +1 -2
index 1b350412d8a6..64c875657687 100644
@@ -919,8 +919,6 @@ static int tpm_tis_probe_irq_single(struct tpm_chip *chip, u32 intmask,
 	int rc;
 	u32 int_status;
 
-	INIT_WORK(&priv->free_irq_work, tpm_tis_free_irq_func);
-
 	rc = devm_request_threaded_irq(chip->dev.parent, irq, NULL,
 				       tis_int_handler, IRQF_ONESHOT | flags,
 				       dev_name(&chip->dev), chip);
@@ -1132,6 +1130,7 @@ int tpm_tis_core_init(struct device *dev, struct tpm_tis_data *priv, int irq,
 	priv->phy_ops = phy_ops;
 	priv->locality_count = 0;
 	mutex_init(&priv->locality_count_mutex);
+	INIT_WORK(&priv->free_irq_work, tpm_tis_free_irq_func);
 
 	dev_set_drvdata(&chip->dev, priv);
 
Quoted 1 line

base-commit: 41bccc98fb7931d63d03f326a746ac4d429c1dd3

Thank you had forgotten about this.

BR, Jarkko

#5 lore raw
In reply to Lino Sanfilippo

Dear Lino,

Thank you for the patch.

Am 01.02.24 um 12:36 schrieb Lino Sanfilippo:

Quoted 29 lines

If interrupts are not activated the work struct 'free_irq_work' is not initialized. This results in a warning splat at module shutdown.

Fix this by always initializing the work regardless of whether interrupts are activated or not.

Fixes 481c2d14627d ("tpm,tpm_tis: Disable interrupts after 1000 unhandled IRQs")
---
  drivers/char/tpm/tpm_tis_core.c | 3 +--
  1 file changed, 1 insertion(+), 2 deletions(-)
drivers/char/tpm/tpm_tis_core.c +0 -2
index 1b350412d8a6..64c875657687 100644
@@ -919,8 +919,6 @@ static int tpm_tis_probe_irq_single(struct tpm_chip *chip, u32 intmask,
  	int rc;
  	u32 int_status;
 
-	INIT_WORK(&priv->free_irq_work, tpm_tis_free_irq_func);
-
  	rc = devm_request_threaded_irq(chip->dev.parent, irq, NULL,
  				       tis_int_handler, IRQF_ONESHOT | flags,
  				       dev_name(&chip->dev), chip);

drivers/char/tpm/tpm_tis_core.c int tpm_tis_core_init(struct device *dev, struct tpm_tis_data *priv, int irq, · line 1135

Quoted 6 lines
drivers/char/tpm/tpm_tis_core.c +1 -0
@@ -1132,6 +1130,7 @@ int tpm_tis_core_init(struct device *dev, struct tpm_tis_data *priv, int irq,
  	priv->phy_ops = phy_ops;
  	priv->locality_count = 0;
  	mutex_init(&priv->locality_count_mutex);
+	INIT_WORK(&priv->free_irq_work, tpm_tis_free_irq_func);
 
  	dev_set_drvdata(&chip->dev, priv);

This is commit d6fb14208e22 in jarkko/next.

I tested this patch on top of Linux 6.8-rc7 on a Dell OptiPlex 5055 [1] and it fixes the issue there too.

Kind regards,

Paul

[1]: https://lore.kernel.org/all/CYJ163J3I09U.2XMVZ0BLWV1Y1@seitikki/

maintainer
#6 lore raw
Quoted 40 lines · Paul Menzel

Dear Lino,

Thank you for the patch.

Am 01.02.24 um 12:36 schrieb Lino Sanfilippo:

Quoted 34 lines

If interrupts are not activated the work struct 'free_irq_work' is not initialized. This results in a warning splat at module shutdown.

Fix this by always initializing the work regardless of whether interrupts are activated or not.

Fixes 481c2d14627d ("tpm,tpm_tis: Disable interrupts after 1000 unhandled IRQs")
---
  drivers/char/tpm/tpm_tis_core.c | 3 +--
  1 file changed, 1 insertion(+), 2 deletions(-)
drivers/char/tpm/tpm_tis_core.c +1 -2
index 1b350412d8a6..64c875657687 100644
@@ -919,8 +919,6 @@ static int tpm_tis_probe_irq_single(struct tpm_chip *chip, u32 intmask,
  	int rc;
  	u32 int_status;
 
-	INIT_WORK(&priv->free_irq_work, tpm_tis_free_irq_func);
-
  	rc = devm_request_threaded_irq(chip->dev.parent, irq, NULL,
  				       tis_int_handler, IRQF_ONESHOT | flags,
  				       dev_name(&chip->dev), chip);
@@ -1132,6 +1130,7 @@ int tpm_tis_core_init(struct device *dev, struct tpm_tis_data *priv, int irq,
  	priv->phy_ops = phy_ops;
  	priv->locality_count = 0;
  	mutex_init(&priv->locality_count_mutex);
+	INIT_WORK(&priv->free_irq_work, tpm_tis_free_irq_func);
 
Quoted 6 lines

drivers/char/tpm/tpm_tis_core.c int tpm_tis_core_init(struct device *dev, struct tpm_tis_data *priv, int irq, · line 1135

Quoted 1 line
drivers/char/tpm/tpm_tis_core.c +0 -0
  	dev_set_drvdata(&chip->dev, priv);

This is commit d6fb14208e22 in jarkko/next.

I tested this patch on top of Linux 6.8-rc7 on a Dell OptiPlex 5055 [1] and it fixes the issue there too.

Thanks!

If you don't mind I'll add your tested-by to the commit before I send my next pull request to Linus?

BR, Jarkko

Tested-by
#7 lore raw

Dear Jarkko,

Am 07.03.24 um 21:05 schrieb Jarkko Sakkinen:

Quoted 41 lines · Paul Menzel
Quoted 40 lines

Am 01.02.24 um 12:36 schrieb Lino Sanfilippo:

Quoted 29 lines

If interrupts are not activated the work struct 'free_irq_work' is not initialized. This results in a warning splat at module shutdown.

Fix this by always initializing the work regardless of whether interrupts are activated or not.

Fixes 481c2d14627d ("tpm,tpm_tis: Disable interrupts after 1000 unhandled IRQs")
---
   drivers/char/tpm/tpm_tis_core.c | 3 +--
   1 file changed, 1 insertion(+), 2 deletions(-)
drivers/char/tpm/tpm_tis_core.c +0 -2
index 1b350412d8a6..64c875657687 100644
@@ -919,8 +919,6 @@ static int tpm_tis_probe_irq_single(struct tpm_chip *chip, u32 intmask,
   	int rc;
   	u32 int_status;
 
-	INIT_WORK(&priv->free_irq_work, tpm_tis_free_irq_func);
-
   	rc = devm_request_threaded_irq(chip->dev.parent, irq, NULL,
   				       tis_int_handler, IRQF_ONESHOT | flags,
   				       dev_name(&chip->dev), chip);

drivers/char/tpm/tpm_tis_core.c int tpm_tis_core_init(struct device *dev, struct tpm_tis_data *priv, int irq, · line 1135

Quoted 6 lines
drivers/char/tpm/tpm_tis_core.c +1 -0
@@ -1132,6 +1130,7 @@ int tpm_tis_core_init(struct device *dev, struct tpm_tis_data *priv, int irq,
   	priv->phy_ops = phy_ops;
   	priv->locality_count = 0;
   	mutex_init(&priv->locality_count_mutex);
+	INIT_WORK(&priv->free_irq_work, tpm_tis_free_irq_func);
 
   	dev_set_drvdata(&chip->dev, priv);

This is commit d6fb14208e22 in jarkko/next.

Quoted 7 lines
Quoted 2 lines

I tested this patch on top of Linux 6.8-rc7 on a Dell OptiPlex 5055 [1] and it fixes the issue there too.

Thanks!

If you don't mind I'll add your tested-by to the commit before I send my next pull request to Linus?

Sure, go ahead. I thought, it’s not going to be amended, and therefore didn’t add the tag.

Kind regards,

Paul