iommu/amd: Add PPR overflow support
Subsystems (2)
Vasant Hegde
maintainercover iommu/amd: Add PPR overflow support
Current IOMMU driver is lacking PPR log overflow handling. Add logic to restart PPR log after an overflow has occurred.
This patch applies on top of cleanup series:
https://lore.kernel.org/linux-iommu/[email protected]/T/#t
Vasant Hegde (2):
iommu/amd: Generalize log overflow handling
iommu/amd: Handle PPR log overflow
drivers/iommu/amd/amd_iommu.h | 1 + drivers/iommu/amd/amd_iommu_types.h | 5 ++- drivers/iommu/amd/init.c | 60 ++++++++++++++++++++--------- drivers/iommu/amd/iommu.c | 13 +++++-- 4 files changed, 57 insertions(+), 22 deletions(-)
Signature · 1 line
2.31.1
Vasant Hegde
maintainerPATCH 1/2 iommu/amd: Generalize log overflow handling
IOMMU has three different logs (Event, GA and PPR log) and each uses different buffer for logging. Once buffer becomes full IOMMU generates overflow interrupt and we have to restart the logs. Log restart procedure is same for all three logs except it uses different bits in 'MMIO Offset 2020h IOMMU Status Register'. Hence lets move common code to generic function and individual log overflow handler will call generic function with appropriate parameters.
Also rename MMIO_STATUS_EVT_OVERFLOW_INT_MASK asMMIO_STATUS_EVT_OVERFLOW_MASK.
--- drivers/iommu/amd/amd_iommu_types.h | 3 +- drivers/iommu/amd/init.c | 51 ++++++++++++++++++----------- drivers/iommu/amd/iommu.c | 4 +-- 3 files changed, 36 insertions(+), 22 deletions(-)
drivers/iommu/amd/amd_iommu_types.h +2 -1
@@ -120,9 +120,10 @@#define PASID_MASK 0x0000ffff/* MMIO status bits */ -#define MMIO_STATUS_EVT_OVERFLOW_INT_MASK BIT(0) +#define MMIO_STATUS_EVT_OVERFLOW_MASK BIT(0)#define MMIO_STATUS_EVT_INT_MASK BIT(1)#define MMIO_STATUS_COM_WAIT_INT_MASK BIT(2) +#define MMIO_STATUS_EVT_RUN_MASK BIT(3)#define MMIO_STATUS_PPR_INT_MASK BIT(6)#define MMIO_STATUS_GALOG_RUN_MASK BIT(8)#define MMIO_STATUS_GALOG_OVERFLOW_MASK BIT(9)
drivers/iommu/amd/init.c +32 -19
70 lines not on this page · raw message
drivers/iommu/amd/iommu.c +2 -2
@@ -842,7 +842,7 @@ amd_iommu_set_pci_msi_domain(struct device *dev, struct amd_iommu *iommu) { }#endif /* !CONFIG_IRQ_REMAP */ #define AMD_IOMMU_INT_MASK \ - (MMIO_STATUS_EVT_OVERFLOW_INT_MASK | \ + (MMIO_STATUS_EVT_OVERFLOW_MASK | \ MMIO_STATUS_EVT_INT_MASK | \ MMIO_STATUS_PPR_INT_MASK | \ MMIO_STATUS_GALOG_OVERFLOW_MASK | \
@@ -881,7 +881,7 @@ irqreturn_t amd_iommu_int_thread(int irq, void *data) }#endif -if (status &MMIO_STATUS_EVT_OVERFLOW_INT_MASK ) { +if (status &MMIO_STATUS_EVT_OVERFLOW_MASK ) {pr_info_ratelimited ("IOMMU event log overflow\n" );amd_iommu_restart_event_logging (iommu); }
Signature · 1 line
2.31.1
Re: [PATCH 1/2] iommu/amd: Generalize log overflow handling
Quoted 8 lines · Vasant Hegde
IOMMU has three different logs (Event, GA and PPR log) and each uses different buffer for logging. Once buffer becomes full IOMMU generates overflow interrupt and we have to restart the logs. Log restart procedure is same for all three logs except it uses different bits in 'MMIO Offset 2020h IOMMU Status Register'. Hence lets move common code to generic function and individual log overflow handler will call generic function with appropriate parameters.
Quoted 4 lines
Also rename
MMIO_STATUS_EVT_OVERFLOW_INT_MASKasMMIO_STATUS_EVT_OVERFLOW_MASK.Signed-off-by Vasant Hegde <[email protected]>
Quoted 122 lines
--- drivers/iommu/amd/amd_iommu_types.h | 3 +- drivers/iommu/amd/init.c | 51 ++++++++++++++++++----------- drivers/iommu/amd/iommu.c | 4 +-- 3 files changed, 36 insertions(+), 22 deletions(-)drivers/iommu/amd/amd_iommu_types.h +2
-1@@ -120,9 +120,10 @@#define PASID_MASK 0x0000ffff/* MMIO status bits */ -#define MMIO_STATUS_EVT_OVERFLOW_INT_MASK BIT(0) +#define MMIO_STATUS_EVT_OVERFLOW_MASK BIT(0)#define MMIO_STATUS_EVT_INT_MASK BIT(1)#define MMIO_STATUS_COM_WAIT_INT_MASK BIT(2) +#define MMIO_STATUS_EVT_RUN_MASK BIT(3)#define MMIO_STATUS_PPR_INT_MASK BIT(6)#define MMIO_STATUS_GALOG_RUN_MASK BIT(8)#define MMIO_STATUS_GALOG_OVERFLOW_MASK BIT(9)drivers/iommu/amd/init.c +32
-19@@ -748,38 +748,51 @@ static int __init alloc_command_buffer(struct amd_iommu *iommu)return iommu->cmd_buf ?0 : -ENOMEM ; } +/* +* Interrupt handler has processed all pending events and adjusted head +* and tail pointer. Reset overflow mask and restart logging again. +*/ +static void amd_iommu_restart_log (struct amd_iommu *iommu,const char *evt_type, +u8 cntrl_intr,u8 cntrl_log, +u32 status_run_mask,u32 status_overflow_mask) +{ +u32 status; + + status =readl (iommu->mmio_base +MMIO_STATUS_OFFSET ); +if (status & status_run_mask) +return ; + +pr_info_ratelimited ("IOMMU %s log restarting\n" , evt_type); + +iommu_feature_disable (iommu, cntrl_log); +iommu_feature_disable (iommu, cntrl_intr); + +writel (status_overflow_mask, iommu->mmio_base +MMIO_STATUS_OFFSET ); + +iommu_feature_enable (iommu, cntrl_intr); +iommu_feature_enable (iommu, cntrl_log); +} +/* * This function restarts event logging in case the IOMMU experienced * an event log buffer overflow. */ void amd_iommu_restart_event_logging (struct amd_iommu *iommu) { -iommu_feature_disable (iommu,CONTROL_EVT_LOG_EN ); -iommu_feature_enable (iommu,CONTROL_EVT_LOG_EN ); +amd_iommu_restart_log (iommu,"Event" ,CONTROL_EVT_INT_EN , +CONTROL_EVT_LOG_EN ,MMIO_STATUS_EVT_RUN_MASK , +MMIO_STATUS_EVT_OVERFLOW_MASK ); }/* * This function restarts event logging in case the IOMMU experienced -* an GA log overflow. +* GA log overflow. */ void amd_iommu_restart_ga_log (struct amd_iommu *iommu) { -u32 status; - - status =readl (iommu->mmio_base +MMIO_STATUS_OFFSET ); -if (status &MMIO_STATUS_GALOG_RUN_MASK ) -return ; - -pr_info_ratelimited ("IOMMU GA Log restarting\n" ); - -iommu_feature_disable (iommu,CONTROL_GALOG_EN ); -iommu_feature_disable (iommu,CONTROL_GAINT_EN ); - -writel (MMIO_STATUS_GALOG_OVERFLOW_MASK , - iommu->mmio_base +MMIO_STATUS_OFFSET ); - -iommu_feature_enable (iommu,CONTROL_GAINT_EN ); -iommu_feature_enable (iommu,CONTROL_GALOG_EN ); +amd_iommu_restart_log (iommu,"GA" ,CONTROL_GAINT_EN , +CONTROL_GALOG_EN ,MMIO_STATUS_GALOG_RUN_MASK , +MMIO_STATUS_GALOG_OVERFLOW_MASK ); }/* drivers/iommu/amd/iommu.c +2
-2@@ -842,7 +842,7 @@ amd_iommu_set_pci_msi_domain(struct device *dev, struct amd_iommu *iommu) { }#endif /* !CONFIG_IRQ_REMAP */ #define AMD_IOMMU_INT_MASK \ - (MMIO_STATUS_EVT_OVERFLOW_INT_MASK | \ + (MMIO_STATUS_EVT_OVERFLOW_MASK | \ MMIO_STATUS_EVT_INT_MASK | \ MMIO_STATUS_PPR_INT_MASK | \ MMIO_STATUS_GALOG_OVERFLOW_MASK | \@@ -881,7 +881,7 @@ irqreturn_t amd_iommu_int_thread(int irq, void *data) }#endif -if (status &MMIO_STATUS_EVT_OVERFLOW_INT_MASK ) { +if (status &MMIO_STATUS_EVT_OVERFLOW_MASK ) {pr_info_ratelimited ("IOMMU event log overflow\n" );amd_iommu_restart_event_logging (iommu); }Signature · 1 line
2.31.1
Re: [PATCH 1/2] iommu/amd: Generalize log overflow handling
In reply to Vasant HegdeQuoted 8 lines · Vasant Hegde
IOMMU has three different logs (Event, GA and PPR log) and each uses different buffer for logging. Once buffer becomes full IOMMU generates overflow interrupt and we have to restart the logs. Log restart procedure is same for all three logs except it uses different bits in 'MMIO Offset 2020h IOMMU Status Register'. Hence lets move common code to generic function and individual log overflow handler will call generic function with appropriate parameters.
Quoted 4 lines
Also rename
MMIO_STATUS_EVT_OVERFLOW_INT_MASKasMMIO_STATUS_EVT_OVERFLOW_MASK.Signed-off-by Vasant Hegde <[email protected]>
Really nice rework, fwiw:
Just a though below (you don't need to address it, just an idea)
Quoted 58 lines
--- drivers/iommu/amd/amd_iommu_types.h | 3 +- drivers/iommu/amd/init.c | 51 ++++++++++++++++++----------- drivers/iommu/amd/iommu.c | 4 +-- 3 files changed, 36 insertions(+), 22 deletions(-)drivers/iommu/amd/amd_iommu_types.h +2
-1@@ -120,9 +120,10 @@#define PASID_MASK 0x0000ffff/* MMIO status bits */ -#define MMIO_STATUS_EVT_OVERFLOW_INT_MASK BIT(0) +#define MMIO_STATUS_EVT_OVERFLOW_MASK BIT(0)#define MMIO_STATUS_EVT_INT_MASK BIT(1)#define MMIO_STATUS_COM_WAIT_INT_MASK BIT(2) +#define MMIO_STATUS_EVT_RUN_MASK BIT(3)#define MMIO_STATUS_PPR_INT_MASK BIT(6)#define MMIO_STATUS_GALOG_RUN_MASK BIT(8)#define MMIO_STATUS_GALOG_OVERFLOW_MASK BIT(9)drivers/iommu/amd/init.c +25
-0@@ -748,38 +748,51 @@ static int __init alloc_command_buffer(struct amd_iommu *iommu)return iommu->cmd_buf ?0 : -ENOMEM ; } +/* +* Interrupt handler has processed all pending events and adjusted head +* and tail pointer. Reset overflow mask and restart logging again. +*/ +static void amd_iommu_restart_log (struct amd_iommu *iommu,const char *evt_type, +u8 cntrl_intr,u8 cntrl_log, +u32 status_run_mask,u32 status_overflow_mask) +{ +u32 status; + + status =readl (iommu->mmio_base +MMIO_STATUS_OFFSET ); +if (status & status_run_mask) +return ; + +pr_info_ratelimited ("IOMMU %s log restarting\n" , evt_type); + +iommu_feature_disable (iommu, cntrl_log); +iommu_feature_disable (iommu, cntrl_intr); + +writel (status_overflow_mask, iommu->mmio_base +MMIO_STATUS_OFFSET ); + +iommu_feature_enable (iommu, cntrl_intr); +iommu_feature_enable (iommu, cntrl_log); +} +/* * This function restarts event logging in case the IOMMU experienced * an event log buffer overflow.
drivers/iommu/amd/init.c static int __init alloc_command_buffer(struct amd_iommu *iommu) · line 786
Quoted 10 lines
drivers/iommu/amd/init.c +3
-2*/ void amd_iommu_restart_event_logging (struct amd_iommu *iommu) { -iommu_feature_disable (iommu,CONTROL_EVT_LOG_EN ); -iommu_feature_enable (iommu,CONTROL_EVT_LOG_EN ); +amd_iommu_restart_log (iommu,"Event" ,CONTROL_EVT_INT_EN , +CONTROL_EVT_LOG_EN ,MMIO_STATUS_EVT_RUN_MASK , +MMIO_STATUS_EVT_OVERFLOW_MASK ); }
If CONTROL_EVT_{INT,LOG} was instead EVT{INT,LOG} (like it's PPR and GA counterparts), I do wonder if a macro is better placed here considering that the only think that changes is the string name and whether it's EVT, PPR or GA is used. But perhaps that might be too obscure.
Quoted 51 lines
drivers/iommu/amd/init.c +4
-17/* * This function restarts event logging in case the IOMMU experienced -* an GA log overflow. +* GA log overflow. */ void amd_iommu_restart_ga_log (struct amd_iommu *iommu) { -u32 status; - - status =readl (iommu->mmio_base +MMIO_STATUS_OFFSET ); -if (status &MMIO_STATUS_GALOG_RUN_MASK ) -return ; - -pr_info_ratelimited ("IOMMU GA Log restarting\n" ); - -iommu_feature_disable (iommu,CONTROL_GALOG_EN ); -iommu_feature_disable (iommu,CONTROL_GAINT_EN ); - -writel (MMIO_STATUS_GALOG_OVERFLOW_MASK , - iommu->mmio_base +MMIO_STATUS_OFFSET ); - -iommu_feature_enable (iommu,CONTROL_GAINT_EN ); -iommu_feature_enable (iommu,CONTROL_GALOG_EN ); +amd_iommu_restart_log (iommu,"GA" ,CONTROL_GAINT_EN , +CONTROL_GALOG_EN ,MMIO_STATUS_GALOG_RUN_MASK , +MMIO_STATUS_GALOG_OVERFLOW_MASK ); }/* drivers/iommu/amd/iommu.c +2
-2@@ -842,7 +842,7 @@ amd_iommu_set_pci_msi_domain(struct device *dev, struct amd_iommu *iommu) { }#endif /* !CONFIG_IRQ_REMAP */ #define AMD_IOMMU_INT_MASK \ - (MMIO_STATUS_EVT_OVERFLOW_INT_MASK | \ + (MMIO_STATUS_EVT_OVERFLOW_MASK | \ MMIO_STATUS_EVT_INT_MASK | \ MMIO_STATUS_PPR_INT_MASK | \ MMIO_STATUS_GALOG_OVERFLOW_MASK | \@@ -881,7 +881,7 @@ irqreturn_t amd_iommu_int_thread(int irq, void *data) }#endif -if (status &MMIO_STATUS_EVT_OVERFLOW_INT_MASK ) { +if (status &MMIO_STATUS_EVT_OVERFLOW_MASK ) {pr_info_ratelimited ("IOMMU event log overflow\n" );amd_iommu_restart_event_logging (iommu); }
Vasant Hegde
maintainerRe: [PATCH 1/2] iommu/amd: Generalize log overflow handling
Hi Joao,
Quoted 11 lines · Joao Martins
Quoted 8 lines · Vasant Hegde
IOMMU has three different logs (Event, GA and PPR log) and each uses different buffer for logging. Once buffer becomes full IOMMU generates overflow interrupt and we have to restart the logs. Log restart procedure is same for all three logs except it uses different bits in 'MMIO Offset 2020h IOMMU Status Register'. Hence lets move common code to generic function and individual log overflow handler will call generic function with appropriate parameters.
Quoted 8 lines
Quoted 4 lines
Also rename
MMIO_STATUS_EVT_OVERFLOW_INT_MASKasMMIO_STATUS_EVT_OVERFLOW_MASK.Signed-off-by Vasant Hegde <[email protected]>Really nice rework, fwiw:
Reviewed-by Joao Martins <[email protected]>
I did post V2 version, but forgot to CC you. Sorry for that. Can you please look into V2?
V2 ->
https://lore.kernel.org/linux-iommu/[email protected]/
Quoted 67 lines
Just a though below (you don't need to address it, just an idea)
Quoted 65 lines
--- drivers/iommu/amd/amd_iommu_types.h | 3 +- drivers/iommu/amd/init.c | 51 ++++++++++++++++++----------- drivers/iommu/amd/iommu.c | 4 +-- 3 files changed, 36 insertions(+), 22 deletions(-)drivers/iommu/amd/amd_iommu_types.h +2
-1@@ -120,9 +120,10 @@#define PASID_MASK 0x0000ffff/* MMIO status bits */ -#define MMIO_STATUS_EVT_OVERFLOW_INT_MASK BIT(0) +#define MMIO_STATUS_EVT_OVERFLOW_MASK BIT(0)#define MMIO_STATUS_EVT_INT_MASK BIT(1)#define MMIO_STATUS_COM_WAIT_INT_MASK BIT(2) +#define MMIO_STATUS_EVT_RUN_MASK BIT(3)#define MMIO_STATUS_PPR_INT_MASK BIT(6)#define MMIO_STATUS_GALOG_RUN_MASK BIT(8)#define MMIO_STATUS_GALOG_OVERFLOW_MASK BIT(9)drivers/iommu/amd/init.c +27
-2@@ -748,38 +748,51 @@ static int __init alloc_command_buffer(struct amd_iommu *iommu)return iommu->cmd_buf ?0 : -ENOMEM ; } +/* +* Interrupt handler has processed all pending events and adjusted head +* and tail pointer. Reset overflow mask and restart logging again. +*/ +static void amd_iommu_restart_log (struct amd_iommu *iommu,const char *evt_type, +u8 cntrl_intr,u8 cntrl_log, +u32 status_run_mask,u32 status_overflow_mask) +{ +u32 status; + + status =readl (iommu->mmio_base +MMIO_STATUS_OFFSET ); +if (status & status_run_mask) +return ; + +pr_info_ratelimited ("IOMMU %s log restarting\n" , evt_type); + +iommu_feature_disable (iommu, cntrl_log); +iommu_feature_disable (iommu, cntrl_intr); + +writel (status_overflow_mask, iommu->mmio_base +MMIO_STATUS_OFFSET ); + +iommu_feature_enable (iommu, cntrl_intr); +iommu_feature_enable (iommu, cntrl_log); +} +/* * This function restarts event logging in case the IOMMU experienced * an event log buffer overflow. */ void amd_iommu_restart_event_logging (struct amd_iommu *iommu) { -iommu_feature_disable (iommu,CONTROL_EVT_LOG_EN ); -iommu_feature_enable (iommu,CONTROL_EVT_LOG_EN ); + amd_iommu_restart_log(iommu, "Event", CONTROL_EVT_INT_EN, + CONTROL_EVT_LOG_EN, MMIO_STATUS_EVT_RUN_MASK,
Quoted 8 lines
drivers/iommu/amd/init.c static int __init alloc_command_buffer(struct amd_iommu *iommu) · line 786
Quoted 3 lines
drivers/iommu/amd/init.c +1
-0+ MMIO_STATUS_EVT_OVERFLOW_MASK); }If CONTROL_EVT_{INT,LOG} was instead EVT{INT,LOG} (like it's PPR and GA counterparts), I do wonder if a macro is better placed here considering that the only think that changes is the string name and whether it's EVT, PPR or GA is used. But perhaps that might be too obscure.
Sure. I am touching some of the init code in next series. I will try to fix it as part of that.
-Vasant
Vasant Hegde
maintainerPATCH 2/2 iommu/amd: Handle PPR log overflow
In reply to Vasant HegdeSome ATS-capable peripherals can issue requests to the processor to service peripheral page requests using PCIe PRI (the Page Request Interface). IOMMU supports PRI using PPR log buffer. IOMMU writes PRI request to PPR log buffer and sends PPR interrupt to host. When there is no space in the PPR log buffer (PPR log overflow) it will set PprOverflow bit in 'MMIO Offset 2020h IOMMU Status Register'. When this happens PPR log needs to be restarted as specified in IOMMU spec [1] section 2.6.2.
When handling the event it just resumes the PPR log without resizing (similar to the way event and GA log overflow is handled).
Failing to handle PPR overflow means device may not work properly as IOMMU stops processing new PPR events from device.
[1] https://www.amd.com/system/files/TechDocs/48882_3.07_PUB.pdf
--- drivers/iommu/amd/amd_iommu.h | 1 + drivers/iommu/amd/amd_iommu_types.h | 2 ++ drivers/iommu/amd/init.c | 11 +++++++++++ drivers/iommu/amd/iommu.c | 9 ++++++++- 4 files changed, 22 insertions(+), 1 deletion(-)
drivers/iommu/amd/amd_iommu.h +1 -0
@@ -16,6 +16,7 @@ irqreturn_t amd_iommu_int_handler(int irq, void *data);void amd_iommu_apply_erratum_63 (struct amd_iommu *iommu,u16 devid);void amd_iommu_restart_event_logging (struct amd_iommu *iommu);void amd_iommu_restart_ga_log (struct amd_iommu *iommu); +void amd_iommu_restart_ppr_log (struct amd_iommu *iommu);void amd_iommu_set_rlookup_table (struct amd_iommu *iommu,u16 devid);#ifdef CONFIG_AMD_IOMMU_DEBUGFS
drivers/iommu/amd/amd_iommu_types.h +2 -0
@@ -124,7 +124,9 @@#define MMIO_STATUS_EVT_INT_MASK BIT(1)#define MMIO_STATUS_COM_WAIT_INT_MASK BIT(2)#define MMIO_STATUS_EVT_RUN_MASK BIT(3) +#define MMIO_STATUS_PPR_OVERFLOW_MASK BIT(5)#define MMIO_STATUS_PPR_INT_MASK BIT(6) +#define MMIO_STATUS_PPR_RUN_MASK BIT(7)#define MMIO_STATUS_GALOG_RUN_MASK BIT(8)#define MMIO_STATUS_GALOG_OVERFLOW_MASK BIT(9)#define MMIO_STATUS_GALOG_INT_MASK BIT(10)
drivers/iommu/amd/init.c +11 -0
@@ -795,6 +795,17 @@ void amd_iommu_restart_ga_log(struct amd_iommu *iommu) MMIO_STATUS_GALOG_OVERFLOW_MASK); } +/* +* This function restarts ppr logging in case the IOMMU experienced +* PPR log overflow. +*/ +void amd_iommu_restart_ppr_log (struct amd_iommu *iommu) +{ +amd_iommu_restart_log (iommu,"PPR" ,CONTROL_PPRINT_EN , +CONTROL_PPRLOG_EN ,MMIO_STATUS_PPR_RUN_MASK , +MMIO_STATUS_PPR_OVERFLOW_MASK ); +} +/* * This function resets the command buffer if the IOMMU stopped fetching * commands from it.
drivers/iommu/amd/iommu.c +8 -1
@@ -844,6 +844,7 @@ amd_iommu_set_pci_msi_domain(struct device *dev, struct amd_iommu *iommu) { }#define AMD_IOMMU_INT_MASK \ (MMIO_STATUS_EVT_OVERFLOW_MASK | \ MMIO_STATUS_EVT_INT_MASK | \ + MMIO_STATUS_PPR_OVERFLOW_MASK | \ MMIO_STATUS_PPR_INT_MASK | \ MMIO_STATUS_GALOG_OVERFLOW_MASK | \ MMIO_STATUS_GALOG_INT_MASK)
@@ -863,11 +864,17 @@ irqreturn_t amd_iommu_int_thread(int irq, void *data)iommu_poll_events (iommu); } -if (status &MMIO_STATUS_PPR_INT_MASK ) { +if (status & (MMIO_STATUS_PPR_INT_MASK | +MMIO_STATUS_PPR_OVERFLOW_MASK )) {pr_devel ("Processing IOMMU PPR Log\n" );iommu_poll_ppr_log (iommu); } +if (status &MMIO_STATUS_PPR_OVERFLOW_MASK ) { +pr_info_ratelimited ("IOMMU PPR log overflow\n" ); +amd_iommu_restart_ppr_log (iommu); + } +#ifdef CONFIG_IRQ_REMAP if (status & (MMIO_STATUS_GALOG_INT_MASK |MMIO_STATUS_GALOG_OVERFLOW_MASK )) {
Signature · 1 line
2.31.1
Re: [PATCH 2/2] iommu/amd: Handle PPR log overflow
Quoted 11 lines · Vasant Hegde
Some ATS-capable peripherals can issue requests to the processor to service peripheral page requests using PCIe PRI (the Page Request Interface). IOMMU supports PRI using PPR log buffer. IOMMU writes PRI request to PPR log buffer and sends PPR interrupt to host. When there is no space in the PPR log buffer (PPR log overflow) it will set PprOverflow bit in 'MMIO Offset 2020h IOMMU Status Register'. When this happens PPR log needs to be restarted as specified in IOMMU spec [1] section 2.6.2.
When handling the event it just resumes the PPR log without resizing (similar to the way event and GA log overflow is handled).
Quoted 6 lines
Failing to handle PPR overflow means device may not work properly as IOMMU stops processing new PPR events from device.
[1] https://www.amd.com/system/files/TechDocs/48882_3.07_PUB.pdf
Signed-off-by Vasant Hegde <[email protected]>
Will the code re-org you are doing move the event log overflow check next to the event log processing check, like is done with the ga log and ppr log?
Regards,
Jerry
Quoted 89 lines
--- drivers/iommu/amd/amd_iommu.h | 1 + drivers/iommu/amd/amd_iommu_types.h | 2 ++ drivers/iommu/amd/init.c | 11 +++++++++++ drivers/iommu/amd/iommu.c | 9 ++++++++- 4 files changed, 22 insertions(+), 1 deletion(-)drivers/iommu/amd/amd_iommu.h +1
-0@@ -16,6 +16,7 @@ irqreturn_t amd_iommu_int_handler(int irq, void *data);void amd_iommu_apply_erratum_63 (struct amd_iommu *iommu,u16 devid);void amd_iommu_restart_event_logging (struct amd_iommu *iommu);void amd_iommu_restart_ga_log (struct amd_iommu *iommu); +void amd_iommu_restart_ppr_log (struct amd_iommu *iommu);void amd_iommu_set_rlookup_table (struct amd_iommu *iommu,u16 devid);#ifdef CONFIG_AMD_IOMMU_DEBUGFS drivers/iommu/amd/amd_iommu_types.h +2
-0@@ -124,7 +124,9 @@#define MMIO_STATUS_EVT_INT_MASK BIT(1)#define MMIO_STATUS_COM_WAIT_INT_MASK BIT(2)#define MMIO_STATUS_EVT_RUN_MASK BIT(3) +#define MMIO_STATUS_PPR_OVERFLOW_MASK BIT(5)#define MMIO_STATUS_PPR_INT_MASK BIT(6) +#define MMIO_STATUS_PPR_RUN_MASK BIT(7)#define MMIO_STATUS_GALOG_RUN_MASK BIT(8)#define MMIO_STATUS_GALOG_OVERFLOW_MASK BIT(9)#define MMIO_STATUS_GALOG_INT_MASK BIT(10)drivers/iommu/amd/init.c +11
-0@@ -795,6 +795,17 @@ void amd_iommu_restart_ga_log(struct amd_iommu *iommu) MMIO_STATUS_GALOG_OVERFLOW_MASK); } +/* +* This function restarts ppr logging in case the IOMMU experienced +* PPR log overflow. +*/ +void amd_iommu_restart_ppr_log (struct amd_iommu *iommu) +{ +amd_iommu_restart_log (iommu,"PPR" ,CONTROL_PPRINT_EN , +CONTROL_PPRLOG_EN ,MMIO_STATUS_PPR_RUN_MASK , +MMIO_STATUS_PPR_OVERFLOW_MASK ); +} +/* * This function resets the command buffer if the IOMMU stopped fetching * commands from it. drivers/iommu/amd/iommu.c +8
-1@@ -844,6 +844,7 @@ amd_iommu_set_pci_msi_domain(struct device *dev, struct amd_iommu *iommu) { }#define AMD_IOMMU_INT_MASK \ (MMIO_STATUS_EVT_OVERFLOW_MASK | \ MMIO_STATUS_EVT_INT_MASK | \ + MMIO_STATUS_PPR_OVERFLOW_MASK | \ MMIO_STATUS_PPR_INT_MASK | \ MMIO_STATUS_GALOG_OVERFLOW_MASK | \ MMIO_STATUS_GALOG_INT_MASK)@@ -863,11 +864,17 @@ irqreturn_t amd_iommu_int_thread(int irq, void *data)iommu_poll_events (iommu); } -if (status &MMIO_STATUS_PPR_INT_MASK ) { +if (status & (MMIO_STATUS_PPR_INT_MASK | +MMIO_STATUS_PPR_OVERFLOW_MASK )) {pr_devel ("Processing IOMMU PPR Log\n" );iommu_poll_ppr_log (iommu); } +if (status &MMIO_STATUS_PPR_OVERFLOW_MASK ) { +pr_info_ratelimited ("IOMMU PPR log overflow\n" ); +amd_iommu_restart_ppr_log (iommu); + } +#ifdef CONFIG_IRQ_REMAP if (status & (MMIO_STATUS_GALOG_INT_MASK |MMIO_STATUS_GALOG_OVERFLOW_MASK )) {Signature · 1 line
2.31.1
Vasant Hegde
maintainerRe: [PATCH 2/2] iommu/amd: Handle PPR log overflow
Hi Jerry,
Quoted 12 lines · Jerry Snitselaar
Quoted 11 lines · Vasant Hegde
Some ATS-capable peripherals can issue requests to the processor to service peripheral page requests using PCIe PRI (the Page Request Interface). IOMMU supports PRI using PPR log buffer. IOMMU writes PRI request to PPR log buffer and sends PPR interrupt to host. When there is no space in the PPR log buffer (PPR log overflow) it will set PprOverflow bit in 'MMIO Offset 2020h IOMMU Status Register'. When this happens PPR log needs to be restarted as specified in IOMMU spec [1] section 2.6.2.
When handling the event it just resumes the PPR log without resizing (similar to the way event and GA log overflow is handled).
Quoted 8 lines
Quoted 6 lines
Failing to handle PPR overflow means device may not work properly as IOMMU stops processing new PPR events from device.
[1] https://www.amd.com/system/files/TechDocs/48882_3.07_PUB.pdf
Signed-off-by Vasant Hegde <[email protected]>Reviewed-by Jerry Snitselaar <[email protected]>
Thanks for the review.
Quoted 4 lines
Will the code re-org you are doing move the event log overflow check next to the event log processing check, like is done with the ga log and ppr log?
Yes. Its handled as part of IOMMU interrupt split series.
-Vasant
Re: [PATCH 2/2] iommu/amd: Handle PPR log overflow
In reply to Vasant HegdeQuoted 11 lines · Vasant Hegde
Some ATS-capable peripherals can issue requests to the processor to service peripheral page requests using PCIe PRI (the Page Request Interface). IOMMU supports PRI using PPR log buffer. IOMMU writes PRI request to PPR log buffer and sends PPR interrupt to host. When there is no space in the PPR log buffer (PPR log overflow) it will set PprOverflow bit in 'MMIO Offset 2020h IOMMU Status Register'. When this happens PPR log needs to be restarted as specified in IOMMU spec [1] section 2.6.2.
When handling the event it just resumes the PPR log without resizing (similar to the way event and GA log overflow is handled).
Quoted 6 lines
Failing to handle PPR overflow means device may not work properly as IOMMU stops processing new PPR events from device.
[1] https://www.amd.com/system/files/TechDocs/48882_3.07_PUB.pdf
Signed-off-by Vasant Hegde <[email protected]>
Quoted 86 lines
--- drivers/iommu/amd/amd_iommu.h | 1 + drivers/iommu/amd/amd_iommu_types.h | 2 ++ drivers/iommu/amd/init.c | 11 +++++++++++ drivers/iommu/amd/iommu.c | 9 ++++++++- 4 files changed, 22 insertions(+), 1 deletion(-)drivers/iommu/amd/amd_iommu.h +1
-0@@ -16,6 +16,7 @@ irqreturn_t amd_iommu_int_handler(int irq, void *data);void amd_iommu_apply_erratum_63 (struct amd_iommu *iommu,u16 devid);void amd_iommu_restart_event_logging (struct amd_iommu *iommu);void amd_iommu_restart_ga_log (struct amd_iommu *iommu); +void amd_iommu_restart_ppr_log (struct amd_iommu *iommu);void amd_iommu_set_rlookup_table (struct amd_iommu *iommu,u16 devid);#ifdef CONFIG_AMD_IOMMU_DEBUGFS drivers/iommu/amd/amd_iommu_types.h +2
-0@@ -124,7 +124,9 @@#define MMIO_STATUS_EVT_INT_MASK BIT(1)#define MMIO_STATUS_COM_WAIT_INT_MASK BIT(2)#define MMIO_STATUS_EVT_RUN_MASK BIT(3) +#define MMIO_STATUS_PPR_OVERFLOW_MASK BIT(5)#define MMIO_STATUS_PPR_INT_MASK BIT(6) +#define MMIO_STATUS_PPR_RUN_MASK BIT(7)#define MMIO_STATUS_GALOG_RUN_MASK BIT(8)#define MMIO_STATUS_GALOG_OVERFLOW_MASK BIT(9)#define MMIO_STATUS_GALOG_INT_MASK BIT(10)drivers/iommu/amd/init.c +11
-0@@ -795,6 +795,17 @@ void amd_iommu_restart_ga_log(struct amd_iommu *iommu) MMIO_STATUS_GALOG_OVERFLOW_MASK); } +/* +* This function restarts ppr logging in case the IOMMU experienced +* PPR log overflow. +*/ +void amd_iommu_restart_ppr_log (struct amd_iommu *iommu) +{ +amd_iommu_restart_log (iommu,"PPR" ,CONTROL_PPRINT_EN , +CONTROL_PPRLOG_EN ,MMIO_STATUS_PPR_RUN_MASK , +MMIO_STATUS_PPR_OVERFLOW_MASK ); +} +/* * This function resets the command buffer if the IOMMU stopped fetching * commands from it. drivers/iommu/amd/iommu.c +8
-1@@ -844,6 +844,7 @@ amd_iommu_set_pci_msi_domain(struct device *dev, struct amd_iommu *iommu) { }#define AMD_IOMMU_INT_MASK \ (MMIO_STATUS_EVT_OVERFLOW_MASK | \ MMIO_STATUS_EVT_INT_MASK | \ + MMIO_STATUS_PPR_OVERFLOW_MASK | \ MMIO_STATUS_PPR_INT_MASK | \ MMIO_STATUS_GALOG_OVERFLOW_MASK | \ MMIO_STATUS_GALOG_INT_MASK)@@ -863,11 +864,17 @@ irqreturn_t amd_iommu_int_thread(int irq, void *data)iommu_poll_events (iommu); } -if (status &MMIO_STATUS_PPR_INT_MASK ) { +if (status & (MMIO_STATUS_PPR_INT_MASK | +MMIO_STATUS_PPR_OVERFLOW_MASK )) {pr_devel ("Processing IOMMU PPR Log\n" );iommu_poll_ppr_log (iommu); } +if (status &MMIO_STATUS_PPR_OVERFLOW_MASK ) { +pr_info_ratelimited ("IOMMU PPR log overflow\n" ); +amd_iommu_restart_ppr_log (iommu); + } +#ifdef CONFIG_IRQ_REMAP if (status & (MMIO_STATUS_GALOG_INT_MASK |MMIO_STATUS_GALOG_OVERFLOW_MASK )) {