iommu/amd: Consolidate PPR log handling
Subsystems (2)
Vasant Hegde
maintainercover iommu/amd: Consolidate PPR log handling
Consolidate PPR log enablement related code and also enable PPR/GA interrupt after setting up the interrupt handler.
This patch series applies on of "Interrupt handling improvements"
series.
[1] https://lore.kernel.org/linux-iommu/[email protected]/T/#t
Vasant Hegde (3):
iommu/amd: Disable PPR log/interrupt in iommu_disable() iommu/amd: Consolidate PPR log enablement
iommu/amd: Enable PPR/GA interrupt after interrupt handler setup
drivers/iommu/amd/init.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-)
Signature · 1 line
2.31.1
Vasant Hegde
maintainerPATCH 1/3 iommu/amd: Disable PPR log/interrupt in iommu_disable()
Similar to other logs, disable PPR log/interrupt in iommu_disable() path.
--- drivers/iommu/amd/init.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/iommu/amd/init.c +4 -0
@@ -483,6 +483,10 @@ static void iommu_disable(struct amd_iommu *iommu)iommu_feature_disable (iommu,CONTROL_GALOG_EN );iommu_feature_disable (iommu,CONTROL_GAINT_EN ); +/* Disable IOMMU PPR logging */ +iommu_feature_disable (iommu,CONTROL_PPRLOG_EN ); +iommu_feature_disable (iommu,CONTROL_PPRINT_EN ); +/* Disable IOMMU hardware itself */ iommu_feature_disable (iommu,CONTROL_IOMMU_EN );
Signature · 1 line
2.31.1
Re: [PATCH 1/3] iommu/amd: Disable PPR log/interrupt in iommu_disable()
Quoted 5 lines · Vasant Hegde
Similar to other logs, disable PPR log/interrupt in
iommu_disable()path.Reviewed-by Suravee Suthikulpanit <[email protected]>Signed-off-by Vasant Hegde <[email protected]>
Quoted 22 lines
--- drivers/iommu/amd/init.c | 4 ++++ 1 file changed, 4 insertions(+)drivers/iommu/amd/init.c +4
-0@@ -483,6 +483,10 @@ static void iommu_disable(struct amd_iommu *iommu)iommu_feature_disable (iommu,CONTROL_GALOG_EN );iommu_feature_disable (iommu,CONTROL_GAINT_EN ); +/* Disable IOMMU PPR logging */ +iommu_feature_disable (iommu,CONTROL_PPRLOG_EN ); +iommu_feature_disable (iommu,CONTROL_PPRINT_EN ); +/* Disable IOMMU hardware itself */ iommu_feature_disable (iommu,CONTROL_IOMMU_EN );Signature · 1 line
2.31.1
Vasant Hegde
maintainerPATCH 2/3 iommu/amd: Consolidate PPR log enablement
In reply to Vasant HegdeMove PPR log interrupt bit setting to iommu_enable_ppr_log(). Also rearrange iommu_enable_ppr_log() such that PPREn bit is enabled before enabling PPRLog and PPRInt bits. So that when PPRLog bit is set it will clear the PPRLogOverflow bit and sets the PPRLogRun bit in the IOMMU Status Register [MMIO Offset 2020h].
--- drivers/iommu/amd/init.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/iommu/amd/init.c +3 -3
@@ -934,6 +934,8 @@ static void iommu_enable_ppr_log(struct amd_iommu *iommu)if (iommu->ppr_log ==NULL )return ; +iommu_feature_enable (iommu,CONTROL_PPR_EN ); + entry =iommu_virt_to_phys (iommu->ppr_log) |PPR_LOG_SIZE_512 ; memcpy_toio(iommu->mmio_base + MMIO_PPR_LOG_OFFSET,
@@ -944,7 +946,7 @@ static void iommu_enable_ppr_log(struct amd_iommu *iommu)writel (0x00 , iommu->mmio_base +MMIO_PPR_TAIL_OFFSET );iommu_feature_enable (iommu,CONTROL_PPRLOG_EN ); -iommu_feature_enable (iommu,CONTROL_PPR_EN ); +iommu_feature_enable (iommu,CONTROL_PPRINT_EN ); }static void __init free_ppr_log (struct amd_iommu *iommu)
@@ -2526,8 +2528,6 @@ static int iommu_init_irq(struct amd_iommu *iommu)iommu_feature_enable (iommu,CONTROL_EVT_INT_EN ); -if (iommu->ppr_log !=NULL ) -iommu_feature_enable (iommu,CONTROL_PPRINT_EN );return 0 ; }
Signature · 1 line
2.31.1
Re: [PATCH 2/3] iommu/amd: Consolidate PPR log enablement
Quoted 8 lines · Vasant Hegde
Move PPR log interrupt bit setting to
iommu_enable_ppr_log(). Also rearrangeiommu_enable_ppr_log()such that PPREn bit is enabled before enabling PPRLog and PPRInt bits. So that when PPRLog bit is set it will clear the PPRLogOverflow bit and sets the PPRLogRun bit in the IOMMU Status Register [MMIO Offset 2020h].Reviewed-by Suravee Suthikulpanit <[email protected]>Signed-off-by Vasant Hegde <[email protected]>
Quoted 38 lines
--- drivers/iommu/amd/init.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)drivers/iommu/amd/init.c +3
-3@@ -934,6 +934,8 @@ static void iommu_enable_ppr_log(struct amd_iommu *iommu)if (iommu->ppr_log ==NULL )return ; +iommu_feature_enable (iommu,CONTROL_PPR_EN ); + entry =iommu_virt_to_phys (iommu->ppr_log) |PPR_LOG_SIZE_512 ; memcpy_toio(iommu->mmio_base + MMIO_PPR_LOG_OFFSET,@@ -944,7 +946,7 @@ static void iommu_enable_ppr_log(struct amd_iommu *iommu)writel (0x00 , iommu->mmio_base +MMIO_PPR_TAIL_OFFSET );iommu_feature_enable (iommu,CONTROL_PPRLOG_EN ); -iommu_feature_enable (iommu,CONTROL_PPR_EN ); +iommu_feature_enable (iommu,CONTROL_PPRINT_EN ); }static void __init free_ppr_log (struct amd_iommu *iommu)@@ -2526,8 +2528,6 @@ static int iommu_init_irq(struct amd_iommu *iommu)iommu_feature_enable (iommu,CONTROL_EVT_INT_EN ); -if (iommu->ppr_log !=NULL ) -iommu_feature_enable (iommu,CONTROL_PPRINT_EN );return 0 ; }Signature · 1 line
2.31.1
Vasant Hegde
maintainerPATCH 3/3 iommu/amd: Enable PPR/GA interrupt after interrupt handler setup
In reply to Vasant HegdeCurrent code enables PPR and GA interrupts before setting up the interrupt handler (in state_next()). Make sure interrupt handler is in place before enabling these interrupt.
amd_iommu_enable_interrupts() gets called in normal boot, kdump as well as in suspend/resume path. Hence moving interrupt enablement to this function works fine.
--- drivers/iommu/amd/init.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
drivers/iommu/amd/init.c +7 -4
@@ -2943,8 +2943,6 @@ static void enable_iommus_vapic(void)static void enable_iommus (void ) {early_enable_iommus (); -enable_iommus_vapic (); -enable_iommus_v2 (); }static void disable_iommus (void )
@@ -3208,6 +3206,13 @@ static int amd_iommu_enable_interrupts(void) goto out; } +/* +* Interrupt handler is ready to process interrupts. Enable +* PPR and GA log interrupt for all IOMMUs. +*/ +enable_iommus_vapic (); +enable_iommus_v2 (); + out:return ret; }
@@ -3287,8 +3292,6 @@ static int __init state_next(void)register_syscore_ops (&amd_iommu_syscore_ops); ret =amd_iommu_init_pci (); init_state = ret ?IOMMU_INIT_ERROR :IOMMU_PCI_INIT ; -enable_iommus_vapic (); -enable_iommus_v2 ();break ;case IOMMU_PCI_INIT : ret =amd_iommu_enable_interrupts ();
Signature · 1 line
2.31.1
Re: [PATCH 3/3] iommu/amd: Enable PPR/GA interrupt after interrupt handler setup
Quoted 10 lines · Vasant Hegde
Current code enables PPR and GA interrupts before setting up the interrupt handler (in
state_next()). Make sure interrupt handler is in place before enabling these interrupt.
amd_iommu_enable_interrupts()gets called in normal boot, kdump as well as in suspend/resume path. Hence moving interrupt enablement to this function works fine.Reviewed-by Suravee Suthikulpanit <[email protected]>Signed-off-by Vasant Hegde <[email protected]>
Quoted 43 lines
--- drivers/iommu/amd/init.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)drivers/iommu/amd/init.c +7
-4@@ -2943,8 +2943,6 @@ static void enable_iommus_vapic(void)static void enable_iommus (void ) {early_enable_iommus (); -enable_iommus_vapic (); -enable_iommus_v2 (); }static void disable_iommus (void )@@ -3208,6 +3206,13 @@ static int amd_iommu_enable_interrupts(void) goto out; } +/* +* Interrupt handler is ready to process interrupts. Enable +* PPR and GA log interrupt for all IOMMUs. +*/ +enable_iommus_vapic (); +enable_iommus_v2 (); + out:return ret; }@@ -3287,8 +3292,6 @@ static int __init state_next(void)register_syscore_ops (&amd_iommu_syscore_ops); ret =amd_iommu_init_pci (); init_state = ret ?IOMMU_INIT_ERROR :IOMMU_PCI_INIT ; -enable_iommus_vapic (); -enable_iommus_v2 ();break ;case IOMMU_PCI_INIT : ret =amd_iommu_enable_interrupts ();Signature · 1 line
2.31.1
Quoted 7 lines · Vasant Hegde
Vasant Hegde (3):
iommu/amd: Disable PPR log/interrupt iniommu_disable()iommu/amd: Consolidate PPR log enablement
iommu/amd: Enable PPR/GA interrupt after interrupt handler setupdrivers/iommu/amd/init.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-)
Applied, thanks.