[v3 08/26] iommu, x86: Add intel_irq_remapping_capability() for Intel

From: Feng Wu
Date: Fri Dec 12 2014 - 10:25:37 EST


Add the Intel side implementation for capability in
struct irq_remap_ops.

Signed-off-by: Feng Wu <feng.wu@xxxxxxxxx>
Reviewed-by: Jiang Liu <jiang.liu@xxxxxxxxxxxxxxx>
---
drivers/iommu/intel_irq_remapping.c | 27 +++++++++++++++++++++++++++
drivers/iommu/irq_remapping.c | 2 ++
drivers/iommu/irq_remapping.h | 4 ++++
3 files changed, 33 insertions(+)

diff --git a/drivers/iommu/intel_irq_remapping.c b/drivers/iommu/intel_irq_remapping.c
index ab9057a..08a7c39 100644
--- a/drivers/iommu/intel_irq_remapping.c
+++ b/drivers/iommu/intel_irq_remapping.c
@@ -652,6 +652,32 @@ error:
return -1;
}

+static bool intel_irq_remapping_capability(enum irq_remap_cap cap)
+{
+ struct dmar_drhd_unit *drhd;
+ struct intel_iommu *iommu;
+
+ switch (cap) {
+ case IRQ_POSTING_CAP:
+ /*
+ * If 1) posted-interrupts is disabled by user
+ * or 2) irq remapping is disabled, posted-interrupts
+ * is not supported.
+ */
+ if (disable_irq_post || !irq_remapping_enabled)
+ return 0;
+
+ for_each_iommu(iommu, drhd)
+ if (!cap_pi_support(iommu->cap))
+ return 0;
+
+ return 1;
+ default:
+ pr_warn("Unknown irq remapping capability.\n");
+ return 0;
+ }
+}
+
static int ir_parse_one_hpet_scope(struct acpi_dmar_device_scope *scope,
struct intel_iommu *iommu,
struct acpi_dmar_hardware_unit *drhd)
@@ -948,6 +974,7 @@ static struct irq_domain *intel_get_irq_domain(struct irq_alloc_info *info)

struct irq_remap_ops intel_irq_remap_ops = {
.supported = intel_irq_remapping_supported,
+ .capability = intel_irq_remapping_capability,
.prepare = dmar_table_init,
.enable = intel_enable_irq_remapping,
.disable = disable_irq_remapping,
diff --git a/drivers/iommu/irq_remapping.c b/drivers/iommu/irq_remapping.c
index 3c3da04d..e63e969 100644
--- a/drivers/iommu/irq_remapping.c
+++ b/drivers/iommu/irq_remapping.c
@@ -24,6 +24,8 @@ int irq_remap_broken;
int disable_sourceid_checking;
int no_x2apic_optout;

+int disable_irq_post = 1;
+
static struct irq_remap_ops *remap_ops;

static void irq_remapping_disable_io_apic(void)
diff --git a/drivers/iommu/irq_remapping.h b/drivers/iommu/irq_remapping.h
index 2d991b2..cb1f46d 100644
--- a/drivers/iommu/irq_remapping.h
+++ b/drivers/iommu/irq_remapping.h
@@ -36,6 +36,8 @@ extern int disable_sourceid_checking;
extern int no_x2apic_optout;
extern int irq_remapping_enabled;

+extern int disable_irq_post;
+
struct irq_remap_ops {
/* Check whether Interrupt Remapping is supported */
int (*supported)(void);
@@ -76,6 +78,8 @@ extern void ir_ack_apic_edge(struct irq_data *data);
#define disable_irq_remap 1
#define irq_remap_broken 0

+#define disable_irq_post 1
+
#endif /* CONFIG_IRQ_REMAP */

#endif /* __IRQ_REMAPPING_H */
--
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/