Skip to content

Commit 4691f79

Browse files
Maxim Levitskyjoergroedel
authored andcommitted
iommu/amd: X2apic mode: setup the INTX registers on mask/unmask
This is more logically correct and will also allow us to to use mask/unmask logic to restore INTX setttings after the resume from s3/s4. Fixes: 6692981 ("iommu/amd: Add support for X2APIC IOMMU interrupts") Signed-off-by: Maxim Levitsky <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Joerg Roedel <[email protected]>
1 parent 01b297a commit 4691f79

File tree

1 file changed

+33
-32
lines changed

1 file changed

+33
-32
lines changed

drivers/iommu/amd/init.c

Lines changed: 33 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2015,48 +2015,18 @@ union intcapxt {
20152015
};
20162016
} __attribute__ ((packed));
20172017

2018-
/*
2019-
* There isn't really any need to mask/unmask at the irqchip level because
2020-
* the 64-bit INTCAPXT registers can be updated atomically without tearing
2021-
* when the affinity is being updated.
2022-
*/
2023-
static void intcapxt_unmask_irq(struct irq_data *data)
2024-
{
2025-
}
2026-
2027-
static void intcapxt_mask_irq(struct irq_data *data)
2028-
{
2029-
}
20302018

20312019
static struct irq_chip intcapxt_controller;
20322020

20332021
static int intcapxt_irqdomain_activate(struct irq_domain *domain,
20342022
struct irq_data *irqd, bool reserve)
20352023
{
2036-
struct amd_iommu *iommu = irqd->chip_data;
2037-
struct irq_cfg *cfg = irqd_cfg(irqd);
2038-
union intcapxt xt;
2039-
2040-
xt.capxt = 0ULL;
2041-
xt.dest_mode_logical = apic->dest_mode_logical;
2042-
xt.vector = cfg->vector;
2043-
xt.destid_0_23 = cfg->dest_apicid & GENMASK(23, 0);
2044-
xt.destid_24_31 = cfg->dest_apicid >> 24;
2045-
2046-
/**
2047-
* Current IOMMU implemtation uses the same IRQ for all
2048-
* 3 IOMMU interrupts.
2049-
*/
2050-
writeq(xt.capxt, iommu->mmio_base + MMIO_INTCAPXT_EVT_OFFSET);
2051-
writeq(xt.capxt, iommu->mmio_base + MMIO_INTCAPXT_PPR_OFFSET);
2052-
writeq(xt.capxt, iommu->mmio_base + MMIO_INTCAPXT_GALOG_OFFSET);
20532024
return 0;
20542025
}
20552026

20562027
static void intcapxt_irqdomain_deactivate(struct irq_domain *domain,
20572028
struct irq_data *irqd)
20582029
{
2059-
intcapxt_mask_irq(irqd);
20602030
}
20612031

20622032

@@ -2090,6 +2060,38 @@ static void intcapxt_irqdomain_free(struct irq_domain *domain, unsigned int virq
20902060
irq_domain_free_irqs_top(domain, virq, nr_irqs);
20912061
}
20922062

2063+
2064+
static void intcapxt_unmask_irq(struct irq_data *irqd)
2065+
{
2066+
struct amd_iommu *iommu = irqd->chip_data;
2067+
struct irq_cfg *cfg = irqd_cfg(irqd);
2068+
union intcapxt xt;
2069+
2070+
xt.capxt = 0ULL;
2071+
xt.dest_mode_logical = apic->dest_mode_logical;
2072+
xt.vector = cfg->vector;
2073+
xt.destid_0_23 = cfg->dest_apicid & GENMASK(23, 0);
2074+
xt.destid_24_31 = cfg->dest_apicid >> 24;
2075+
2076+
/**
2077+
* Current IOMMU implementation uses the same IRQ for all
2078+
* 3 IOMMU interrupts.
2079+
*/
2080+
writeq(xt.capxt, iommu->mmio_base + MMIO_INTCAPXT_EVT_OFFSET);
2081+
writeq(xt.capxt, iommu->mmio_base + MMIO_INTCAPXT_PPR_OFFSET);
2082+
writeq(xt.capxt, iommu->mmio_base + MMIO_INTCAPXT_GALOG_OFFSET);
2083+
}
2084+
2085+
static void intcapxt_mask_irq(struct irq_data *irqd)
2086+
{
2087+
struct amd_iommu *iommu = irqd->chip_data;
2088+
2089+
writeq(0, iommu->mmio_base + MMIO_INTCAPXT_EVT_OFFSET);
2090+
writeq(0, iommu->mmio_base + MMIO_INTCAPXT_PPR_OFFSET);
2091+
writeq(0, iommu->mmio_base + MMIO_INTCAPXT_GALOG_OFFSET);
2092+
}
2093+
2094+
20932095
static int intcapxt_set_affinity(struct irq_data *irqd,
20942096
const struct cpumask *mask, bool force)
20952097
{
@@ -2099,8 +2101,7 @@ static int intcapxt_set_affinity(struct irq_data *irqd,
20992101
ret = parent->chip->irq_set_affinity(parent, mask, force);
21002102
if (ret < 0 || ret == IRQ_SET_MASK_OK_DONE)
21012103
return ret;
2102-
2103-
return intcapxt_irqdomain_activate(irqd->domain, irqd, false);
2104+
return 0;
21042105
}
21052106

21062107
static struct irq_chip intcapxt_controller = {

0 commit comments

Comments
 (0)