diff mbox

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

Message ID 1418397300-10870-9-git-send-email-feng.wu@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Wu, Feng Dec. 12, 2014, 3:14 p.m. UTC
Add the Intel side implementation for capability in
struct irq_remap_ops.

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

Comments

David Woodhouse Jan. 28, 2015, 3:37 p.m. UTC | #1
On Fri, 2014-12-12 at 23:14 +0800, Feng Wu wrote:
> Add the Intel side implementation for capability in
> struct irq_remap_ops.
> 
> Signed-off-by: Feng Wu <feng.wu@intel.com>
> Reviewed-by: Jiang Liu <jiang.liu@linux.intel.com>

> +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;
> +

If a new IOMMU is hotplugged now which doesn't support posted
interrupts, what happens?
Wu, Feng Jan. 29, 2015, 8:57 a.m. UTC | #2
> -----Original Message-----

> From: David Woodhouse [mailto:dwmw2@infradead.org]

> Sent: Wednesday, January 28, 2015 11:38 PM

> To: Wu, Feng

> Cc: tglx@linutronix.de; mingo@redhat.com; hpa@zytor.com; x86@kernel.org;

> gleb@kernel.org; pbonzini@redhat.com; joro@8bytes.org;

> alex.williamson@redhat.com; jiang.liu@linux.intel.com; eric.auger@linaro.org;

> linux-kernel@vger.kernel.org; iommu@lists.linux-foundation.org;

> kvm@vger.kernel.org

> Subject: Re: [v3 08/26] iommu, x86: Add intel_irq_remapping_capability() for

> Intel

> 

> On Fri, 2014-12-12 at 23:14 +0800, Feng Wu wrote:

> > Add the Intel side implementation for capability in

> > struct irq_remap_ops.

> >

> > Signed-off-by: Feng Wu <feng.wu@intel.com>

> > Reviewed-by: Jiang Liu <jiang.liu@linux.intel.com>

> 

> > +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;

> > +

> 

> If a new IOMMU is hotplugged now which doesn't support posted

> interrupts, what happens?


Good question, Just had a offline discussion with Jiang Liu, actually, there
is the same question for IR. In the current implementation, If IR is in use
and a new IOMMU without IR capability is hotplugged, it will reject this
hotplugging. I think I can simple follow the same policy for PI.

Thanks,
Feng

> 

> --

> David Woodhouse                            Open Source Technology

> Centre

> David.Woodhouse@intel.com                              Intel

> Corporation
diff mbox

Patch

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 */