mirror of
https://github.com/lkl/linux.git
synced 2025-12-19 16:13:19 +09:00
iommu/vt-d: Consolidate irq domain getter
The irq domain request mode is now indicated in irq_alloc_info::type. Consolidate the two getter functions into one. Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Acked-by: Joerg Roedel <jroedel@suse.de> Link: https://lore.kernel.org/r/20200826112331.530546013@linutronix.de
This commit is contained in:
@@ -204,35 +204,40 @@ static int modify_irte(struct irq_2_iommu *irq_iommu,
|
|||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct intel_iommu *map_hpet_to_ir(u8 hpet_id)
|
static struct irq_domain *map_hpet_to_ir(u8 hpet_id)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < MAX_HPET_TBS; i++)
|
for (i = 0; i < MAX_HPET_TBS; i++) {
|
||||||
if (ir_hpet[i].id == hpet_id && ir_hpet[i].iommu)
|
if (ir_hpet[i].id == hpet_id && ir_hpet[i].iommu)
|
||||||
return ir_hpet[i].iommu;
|
return ir_hpet[i].iommu->ir_domain;
|
||||||
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct intel_iommu *map_ioapic_to_ir(int apic)
|
static struct intel_iommu *map_ioapic_to_iommu(int apic)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < MAX_IO_APICS; i++)
|
for (i = 0; i < MAX_IO_APICS; i++) {
|
||||||
if (ir_ioapic[i].id == apic && ir_ioapic[i].iommu)
|
if (ir_ioapic[i].id == apic && ir_ioapic[i].iommu)
|
||||||
return ir_ioapic[i].iommu;
|
return ir_ioapic[i].iommu;
|
||||||
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct intel_iommu *map_dev_to_ir(struct pci_dev *dev)
|
static struct irq_domain *map_ioapic_to_ir(int apic)
|
||||||
{
|
{
|
||||||
struct dmar_drhd_unit *drhd;
|
struct intel_iommu *iommu = map_ioapic_to_iommu(apic);
|
||||||
|
|
||||||
drhd = dmar_find_matched_drhd_unit(dev);
|
return iommu ? iommu->ir_domain : NULL;
|
||||||
if (!drhd)
|
}
|
||||||
return NULL;
|
|
||||||
|
|
||||||
return drhd->iommu;
|
static struct irq_domain *map_dev_to_ir(struct pci_dev *dev)
|
||||||
|
{
|
||||||
|
struct dmar_drhd_unit *drhd = dmar_find_matched_drhd_unit(dev);
|
||||||
|
|
||||||
|
return drhd ? drhd->iommu->ir_msi_domain : NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int clear_entries(struct irq_2_iommu *irq_iommu)
|
static int clear_entries(struct irq_2_iommu *irq_iommu)
|
||||||
@@ -1002,7 +1007,7 @@ static int __init parse_ioapics_under_ir(void)
|
|||||||
|
|
||||||
for (ioapic_idx = 0; ioapic_idx < nr_ioapics; ioapic_idx++) {
|
for (ioapic_idx = 0; ioapic_idx < nr_ioapics; ioapic_idx++) {
|
||||||
int ioapic_id = mpc_ioapic_id(ioapic_idx);
|
int ioapic_id = mpc_ioapic_id(ioapic_idx);
|
||||||
if (!map_ioapic_to_ir(ioapic_id)) {
|
if (!map_ioapic_to_iommu(ioapic_id)) {
|
||||||
pr_err(FW_BUG "ioapic %d has no mapping iommu, "
|
pr_err(FW_BUG "ioapic %d has no mapping iommu, "
|
||||||
"interrupt remapping will be disabled\n",
|
"interrupt remapping will be disabled\n",
|
||||||
ioapic_id);
|
ioapic_id);
|
||||||
@@ -1107,47 +1112,23 @@ static void prepare_irte(struct irte *irte, int vector, unsigned int dest)
|
|||||||
irte->redir_hint = 1;
|
irte->redir_hint = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct irq_domain *intel_get_ir_irq_domain(struct irq_alloc_info *info)
|
static struct irq_domain *intel_get_irq_domain(struct irq_alloc_info *info)
|
||||||
{
|
{
|
||||||
struct intel_iommu *iommu = NULL;
|
|
||||||
|
|
||||||
if (!info)
|
if (!info)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
switch (info->type) {
|
switch (info->type) {
|
||||||
case X86_IRQ_ALLOC_TYPE_IOAPIC_GET_PARENT:
|
case X86_IRQ_ALLOC_TYPE_IOAPIC_GET_PARENT:
|
||||||
iommu = map_ioapic_to_ir(info->ioapic_id);
|
return map_ioapic_to_ir(info->ioapic_id);
|
||||||
break;
|
|
||||||
case X86_IRQ_ALLOC_TYPE_HPET_GET_PARENT:
|
case X86_IRQ_ALLOC_TYPE_HPET_GET_PARENT:
|
||||||
iommu = map_hpet_to_ir(info->hpet_id);
|
return map_hpet_to_ir(info->hpet_id);
|
||||||
break;
|
|
||||||
default:
|
|
||||||
BUG_ON(1);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return iommu ? iommu->ir_domain : NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static struct irq_domain *intel_get_irq_domain(struct irq_alloc_info *info)
|
|
||||||
{
|
|
||||||
struct intel_iommu *iommu;
|
|
||||||
|
|
||||||
if (!info)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
switch (info->type) {
|
|
||||||
case X86_IRQ_ALLOC_TYPE_PCI_MSI:
|
case X86_IRQ_ALLOC_TYPE_PCI_MSI:
|
||||||
case X86_IRQ_ALLOC_TYPE_PCI_MSIX:
|
case X86_IRQ_ALLOC_TYPE_PCI_MSIX:
|
||||||
iommu = map_dev_to_ir(info->msi_dev);
|
return map_dev_to_ir(info->msi_dev);
|
||||||
if (iommu)
|
|
||||||
return iommu->ir_msi_domain;
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
break;
|
WARN_ON_ONCE(1);
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct irq_remap_ops intel_irq_remap_ops = {
|
struct irq_remap_ops intel_irq_remap_ops = {
|
||||||
@@ -1156,7 +1137,7 @@ struct irq_remap_ops intel_irq_remap_ops = {
|
|||||||
.disable = disable_irq_remapping,
|
.disable = disable_irq_remapping,
|
||||||
.reenable = reenable_irq_remapping,
|
.reenable = reenable_irq_remapping,
|
||||||
.enable_faulting = enable_drhd_fault_handling,
|
.enable_faulting = enable_drhd_fault_handling,
|
||||||
.get_ir_irq_domain = intel_get_ir_irq_domain,
|
.get_ir_irq_domain = intel_get_irq_domain,
|
||||||
.get_irq_domain = intel_get_irq_domain,
|
.get_irq_domain = intel_get_irq_domain,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user