@@ -469,7 +469,7 @@ static int tpm_tis_send_data(struct tpm_chip *chip, const u8 *buf, size_t len)
469469 return rc ;
470470}
471471
472- static void disable_interrupts (struct tpm_chip * chip )
472+ static void disable_interrupts (struct tpm_chip * chip , bool delayed )
473473{
474474 struct tpm_tis_data * priv = dev_get_drvdata (& chip -> dev );
475475 u32 intmask ;
@@ -478,16 +478,24 @@ static void disable_interrupts(struct tpm_chip *chip)
478478 if (priv -> irq == 0 )
479479 return ;
480480
481+ chip -> flags &= ~TPM_CHIP_FLAG_IRQ ;
482+
481483 rc = tpm_tis_read32 (priv , TPM_INT_ENABLE (priv -> locality ), & intmask );
482484 if (rc < 0 )
483485 intmask = 0 ;
484486
485487 intmask &= ~TPM_GLOBAL_INT_ENABLE ;
488+
489+ tpm_tis_request_locality (chip , 0 );
486490 rc = tpm_tis_write32 (priv , TPM_INT_ENABLE (priv -> locality ), intmask );
491+ tpm_tis_relinquish_locality (chip , 0 );
487492
488- devm_free_irq (chip -> dev .parent , priv -> irq , chip );
489- priv -> irq = 0 ;
490- chip -> flags &= ~TPM_CHIP_FLAG_IRQ ;
493+ if (delayed ) {
494+ schedule_work (& priv -> free_irq_work );
495+ } else {
496+ devm_free_irq (chip -> dev .parent , priv -> irq , chip );
497+ priv -> irq = 0 ;
498+ }
491499}
492500
493501/*
@@ -553,7 +561,7 @@ static int tpm_tis_send(struct tpm_chip *chip, u8 *buf, size_t len)
553561 if (!test_bit (TPM_TIS_IRQ_TESTED , & priv -> flags ))
554562 tpm_msleep (1 );
555563 if (!test_bit (TPM_TIS_IRQ_TESTED , & priv -> flags ))
556- disable_interrupts (chip );
564+ disable_interrupts (chip , false );
557565 set_bit (TPM_TIS_IRQ_TESTED , & priv -> flags );
558566 return rc ;
559567}
@@ -796,22 +804,9 @@ static irqreturn_t tis_int_handler(int dummy, void *dev_id)
796804 priv -> last_unhandled_irq = jiffies ;
797805
798806 if ((priv -> unhandled_irqs > MAX_UNHANDLED_IRQS ) &&
799- (chip -> flags & TPM_CHIP_FLAG_IRQ )) {
800- int intmask ;
801-
802- tpm_tis_request_locality (chip , 0 );
803- rc = tpm_tis_read32 (priv , TPM_INT_ENABLE (priv -> locality ), & intmask );
804- if (rc < 0 )
805- intmask = 0 ;
806-
807- intmask &= ~TPM_GLOBAL_INT_ENABLE ;
808- rc = tpm_tis_write32 (priv , TPM_INT_ENABLE (priv -> locality ), intmask );
809- tpm_tis_relinquish_locality (chip , 0 );
807+ (chip -> flags & TPM_CHIP_FLAG_IRQ ))
808+ disable_interrupts (chip , true);
810809
811- chip -> flags &= ~TPM_CHIP_FLAG_IRQ ;
812-
813- schedule_work (& priv -> free_irq_work );
814- }
815810 return IRQ_HANDLED ;
816811}
817812
@@ -1235,7 +1230,7 @@ int tpm_tis_core_init(struct device *dev, struct tpm_tis_data *priv, int irq,
12351230 rc = tpm_tis_request_locality (chip , 0 );
12361231 if (rc < 0 )
12371232 goto out_err ;
1238- disable_interrupts (chip );
1233+ disable_interrupts (chip , false );
12391234 tpm_tis_relinquish_locality (chip , 0 );
12401235 }
12411236 }
0 commit comments