mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-01-22 06:23:50 -05:00
iommu/amd: Enable separate interrupt for PPR and GA log
AMD IOMMU has three log buffers (i.e. Event, PPR, and GA). These logs can be configured to generate different interrupts when an entry is inserted into a log buffer. However, current implementation share single interrupt to handle all three logs. With increasing usages of the GA (for IOMMU AVIC) and PPR logs (for IOMMUv2 APIs and SVA), interrupt sharing could potentially become performance bottleneck. Hence, separate IOMMU interrupt into use three separate vectors and irq threads with corresponding name, which will be displayed in the /proc/interrupts as "AMD-Vi<x>-[Evt/PPR/GA]", where "x" is an IOMMU id. Note that this patch changes interrupt handling only in IOMMU x2apic mode (MMIO 0x18[IntCapXTEn]=1). In legacy mode it will continue to use single MSI interrupt. Signed-off-by: Vasant Hegde<vasant.hegde@amd.com> Reviewed-by: Alexey Kardashevskiy<aik@amd.com> Reviewed-by: Jerry Snitselaar <jsnitsel@redhat.com> Link: https://lore.kernel.org/r/20230628053222.5962-3-vasant.hegde@amd.com Signed-off-by: Joerg Roedel <jroedel@suse.de>
This commit is contained in:
committed by
Joerg Roedel
parent
2379f34852
commit
e5ebd90d1b
@@ -705,12 +705,21 @@ struct amd_iommu {
|
||||
/* event buffer virtual address */
|
||||
u8 *evt_buf;
|
||||
|
||||
/* Name for event log interrupt */
|
||||
unsigned char evt_irq_name[16];
|
||||
|
||||
/* Base of the PPR log, if present */
|
||||
u8 *ppr_log;
|
||||
|
||||
/* Name for PPR log interrupt */
|
||||
unsigned char ppr_irq_name[16];
|
||||
|
||||
/* Base of the GA log, if present */
|
||||
u8 *ga_log;
|
||||
|
||||
/* Name for GA log interrupt */
|
||||
unsigned char ga_irq_name[16];
|
||||
|
||||
/* Tail of the GA log, if present */
|
||||
u8 *ga_log_tail;
|
||||
|
||||
|
||||
@@ -2335,6 +2335,7 @@ static int intcapxt_irqdomain_alloc(struct irq_domain *domain, unsigned int virq
|
||||
struct irq_data *irqd = irq_domain_get_irq_data(domain, i);
|
||||
|
||||
irqd->chip = &intcapxt_controller;
|
||||
irqd->hwirq = info->hwirq;
|
||||
irqd->chip_data = info->data;
|
||||
__irq_set_handler(i, handle_edge_irq, 0, "edge");
|
||||
}
|
||||
@@ -2361,22 +2362,14 @@ static void intcapxt_unmask_irq(struct irq_data *irqd)
|
||||
xt.destid_0_23 = cfg->dest_apicid & GENMASK(23, 0);
|
||||
xt.destid_24_31 = cfg->dest_apicid >> 24;
|
||||
|
||||
/**
|
||||
* Current IOMMU implementation uses the same IRQ for all
|
||||
* 3 IOMMU interrupts.
|
||||
*/
|
||||
writeq(xt.capxt, iommu->mmio_base + MMIO_INTCAPXT_EVT_OFFSET);
|
||||
writeq(xt.capxt, iommu->mmio_base + MMIO_INTCAPXT_PPR_OFFSET);
|
||||
writeq(xt.capxt, iommu->mmio_base + MMIO_INTCAPXT_GALOG_OFFSET);
|
||||
writeq(xt.capxt, iommu->mmio_base + irqd->hwirq);
|
||||
}
|
||||
|
||||
static void intcapxt_mask_irq(struct irq_data *irqd)
|
||||
{
|
||||
struct amd_iommu *iommu = irqd->chip_data;
|
||||
|
||||
writeq(0, iommu->mmio_base + MMIO_INTCAPXT_EVT_OFFSET);
|
||||
writeq(0, iommu->mmio_base + MMIO_INTCAPXT_PPR_OFFSET);
|
||||
writeq(0, iommu->mmio_base + MMIO_INTCAPXT_GALOG_OFFSET);
|
||||
writeq(0, iommu->mmio_base + irqd->hwirq);
|
||||
}
|
||||
|
||||
|
||||
@@ -2439,7 +2432,8 @@ static struct irq_domain *iommu_get_irqdomain(void)
|
||||
return iommu_irqdomain;
|
||||
}
|
||||
|
||||
static int iommu_setup_intcapxt(struct amd_iommu *iommu)
|
||||
static int __iommu_setup_intcapxt(struct amd_iommu *iommu, const char *devname,
|
||||
int hwirq, irq_handler_t thread_fn)
|
||||
{
|
||||
struct irq_domain *domain;
|
||||
struct irq_alloc_info info;
|
||||
@@ -2453,6 +2447,7 @@ static int iommu_setup_intcapxt(struct amd_iommu *iommu)
|
||||
init_irq_alloc_info(&info, NULL);
|
||||
info.type = X86_IRQ_ALLOC_TYPE_AMDVI;
|
||||
info.data = iommu;
|
||||
info.hwirq = hwirq;
|
||||
|
||||
irq = irq_domain_alloc_irqs(domain, 1, node, &info);
|
||||
if (irq < 0) {
|
||||
@@ -2461,7 +2456,7 @@ static int iommu_setup_intcapxt(struct amd_iommu *iommu)
|
||||
}
|
||||
|
||||
ret = request_threaded_irq(irq, amd_iommu_int_handler,
|
||||
amd_iommu_int_thread, 0, "AMD-Vi", iommu);
|
||||
thread_fn, 0, devname, iommu);
|
||||
if (ret) {
|
||||
irq_domain_free_irqs(irq, 1);
|
||||
irq_domain_remove(domain);
|
||||
@@ -2471,6 +2466,37 @@ static int iommu_setup_intcapxt(struct amd_iommu *iommu)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int iommu_setup_intcapxt(struct amd_iommu *iommu)
|
||||
{
|
||||
int ret;
|
||||
|
||||
snprintf(iommu->evt_irq_name, sizeof(iommu->evt_irq_name),
|
||||
"AMD-Vi%d-Evt", iommu->index);
|
||||
ret = __iommu_setup_intcapxt(iommu, iommu->evt_irq_name,
|
||||
MMIO_INTCAPXT_EVT_OFFSET,
|
||||
amd_iommu_int_thread_evtlog);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
snprintf(iommu->ppr_irq_name, sizeof(iommu->ppr_irq_name),
|
||||
"AMD-Vi%d-PPR", iommu->index);
|
||||
ret = __iommu_setup_intcapxt(iommu, iommu->ppr_irq_name,
|
||||
MMIO_INTCAPXT_PPR_OFFSET,
|
||||
amd_iommu_int_thread_pprlog);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
#ifdef CONFIG_IRQ_REMAP
|
||||
snprintf(iommu->ga_irq_name, sizeof(iommu->ga_irq_name),
|
||||
"AMD-Vi%d-GA", iommu->index);
|
||||
ret = __iommu_setup_intcapxt(iommu, iommu->ga_irq_name,
|
||||
MMIO_INTCAPXT_GALOG_OFFSET,
|
||||
amd_iommu_int_thread_galog);
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int iommu_init_irq(struct amd_iommu *iommu)
|
||||
{
|
||||
int ret;
|
||||
|
||||
Reference in New Issue
Block a user