* [PATCH v3 0/6] irqchip: irq-armada-370-xp: generic MSI infrastructure and assorted fixes
@ 2016-02-10 14:46 ` Thomas Petazzoni
0 siblings, 0 replies; 18+ messages in thread
From: Thomas Petazzoni @ 2016-02-10 14:46 UTC (permalink / raw)
To: Thomas Gleixner, Marc Zyngier, Jason Cooper
Cc: linux-arm-kernel, linux-kernel, Andrew Lunn,
Sebastian Hesselbarth, Gregory Clement, Thomas Petazzoni
Hello,
This patch series converts the Armada 370/XP irqchip driver (also used
on Armada 375, 38x and 39x) to the new MSI infrastructure put in place
by Marc. It doesn't bring any functional difference other than using
the right, modern, MSI mechanism, which might ultimately allow Marc to
remove the old way of implementing MSI support.
It has been tested on Armada 38x and Armada XP with an Intel e1000e
NIC and an Intel IGB NIC, both of which use MSI interrupts.
Note that this patch series depends on the patch series from Marc
Zyngier for proper operation, which have already been merged in
tip.git by Thomas Gleixner:
http://git.kernel.org/cgit/linux/kernel/git/tip/tip.git/commit/?id=530cbe100ef7587aa5b5ac3a4b670cda4d50e598
http://git.kernel.org/cgit/linux/kernel/git/tip/tip.git/commit/?id=14a0db3cdd114da757197193f66786e63649c91e
Changes since v2:
- No code changes.
- Added Reviewed-by from Marc Zyngier on patches:
irqchip: irq-armada-370-xp: use the generic MSI infrastructure
- Added Acked-by from Gregory Clement on patches:
irqchip: irq-armada-370-xp: use PCI_MSI_DOORBELL_START where appropriate
irqchip: irq-armada-370-xp: use shorter names for irq_chip
ARM: mvebu: use the ARMADA_370_XP_IRQ option
- Added Reviewed-by from Gregory Clement on patches:
irqchip: irq-armada-370-xp: allow allocation of multiple MSIs
- Posted to a wider audience, including lkml.
Changes since v1:
- Rebased on top of v4.5-rc1, and the latest version of Marc Zyngier
irqchip core fixes, which are needed for this series to work.
- Added Acked-by from Gregory Clement on patch "irqchip:
irq-armada-370-xp: add Kconfig option for the driver"
- Add a new patch that changes hardcoded "16" values by the
appropriate PCI_MSI_DOORBELL_START definition. Noticed by Gregory
Clement.
- Drop the ->irq_enable() and ->irq_disable() callbacks from struct
irq_chip armada_370_xp_msi_irq_chip, as they are not needed, since
we already provide the same callbacks for ->irq_mask() and
->irq_unmask(). Noticed by Marc Zyngier.
- Drop the MSI_FLAG_MULTI_PCI_MSI, since we don't (yet) support
allocating multiple MSIs as once. Noticed by Marc Zyngier.
- Added a separate commit actually implementing the allocation of
multiple MSIs at once, and therefore adds the
MSI_FLAG_MULTI_PCI_MSI.
- Reorder code in armada_370_xp_mpic_of_init() to make a BUG_ON()
really useful. Noticed by Marc Zyngier.
Thanks!
Thomas
Thomas Petazzoni (6):
irqchip: irq-armada-370-xp: add Kconfig option for the driver
irqchip: irq-armada-370-xp: use the generic MSI infrastructure
irqchip: irq-armada-370-xp: use PCI_MSI_DOORBELL_START where
appropriate
irqchip: irq-armada-370-xp: use shorter names for irq_chip
irqchip: irq-armada-370-xp: allow allocation of multiple MSIs
ARM: mvebu: use the ARMADA_370_XP_IRQ option
arch/arm/mach-mvebu/Kconfig | 6 +-
drivers/irqchip/Kconfig | 6 ++
drivers/irqchip/Makefile | 2 +-
drivers/irqchip/irq-armada-370-xp.c | 156 +++++++++++++++---------------------
4 files changed, 78 insertions(+), 92 deletions(-)
--
2.6.4
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH v3 0/6] irqchip: irq-armada-370-xp: generic MSI infrastructure and assorted fixes
@ 2016-02-10 14:46 ` Thomas Petazzoni
0 siblings, 0 replies; 18+ messages in thread
From: Thomas Petazzoni @ 2016-02-10 14:46 UTC (permalink / raw)
To: linux-arm-kernel
Hello,
This patch series converts the Armada 370/XP irqchip driver (also used
on Armada 375, 38x and 39x) to the new MSI infrastructure put in place
by Marc. It doesn't bring any functional difference other than using
the right, modern, MSI mechanism, which might ultimately allow Marc to
remove the old way of implementing MSI support.
It has been tested on Armada 38x and Armada XP with an Intel e1000e
NIC and an Intel IGB NIC, both of which use MSI interrupts.
Note that this patch series depends on the patch series from Marc
Zyngier for proper operation, which have already been merged in
tip.git by Thomas Gleixner:
http://git.kernel.org/cgit/linux/kernel/git/tip/tip.git/commit/?id=530cbe100ef7587aa5b5ac3a4b670cda4d50e598
http://git.kernel.org/cgit/linux/kernel/git/tip/tip.git/commit/?id=14a0db3cdd114da757197193f66786e63649c91e
Changes since v2:
- No code changes.
- Added Reviewed-by from Marc Zyngier on patches:
irqchip: irq-armada-370-xp: use the generic MSI infrastructure
- Added Acked-by from Gregory Clement on patches:
irqchip: irq-armada-370-xp: use PCI_MSI_DOORBELL_START where appropriate
irqchip: irq-armada-370-xp: use shorter names for irq_chip
ARM: mvebu: use the ARMADA_370_XP_IRQ option
- Added Reviewed-by from Gregory Clement on patches:
irqchip: irq-armada-370-xp: allow allocation of multiple MSIs
- Posted to a wider audience, including lkml.
Changes since v1:
- Rebased on top of v4.5-rc1, and the latest version of Marc Zyngier
irqchip core fixes, which are needed for this series to work.
- Added Acked-by from Gregory Clement on patch "irqchip:
irq-armada-370-xp: add Kconfig option for the driver"
- Add a new patch that changes hardcoded "16" values by the
appropriate PCI_MSI_DOORBELL_START definition. Noticed by Gregory
Clement.
- Drop the ->irq_enable() and ->irq_disable() callbacks from struct
irq_chip armada_370_xp_msi_irq_chip, as they are not needed, since
we already provide the same callbacks for ->irq_mask() and
->irq_unmask(). Noticed by Marc Zyngier.
- Drop the MSI_FLAG_MULTI_PCI_MSI, since we don't (yet) support
allocating multiple MSIs as once. Noticed by Marc Zyngier.
- Added a separate commit actually implementing the allocation of
multiple MSIs at once, and therefore adds the
MSI_FLAG_MULTI_PCI_MSI.
- Reorder code in armada_370_xp_mpic_of_init() to make a BUG_ON()
really useful. Noticed by Marc Zyngier.
Thanks!
Thomas
Thomas Petazzoni (6):
irqchip: irq-armada-370-xp: add Kconfig option for the driver
irqchip: irq-armada-370-xp: use the generic MSI infrastructure
irqchip: irq-armada-370-xp: use PCI_MSI_DOORBELL_START where
appropriate
irqchip: irq-armada-370-xp: use shorter names for irq_chip
irqchip: irq-armada-370-xp: allow allocation of multiple MSIs
ARM: mvebu: use the ARMADA_370_XP_IRQ option
arch/arm/mach-mvebu/Kconfig | 6 +-
drivers/irqchip/Kconfig | 6 ++
drivers/irqchip/Makefile | 2 +-
drivers/irqchip/irq-armada-370-xp.c | 156 +++++++++++++++---------------------
4 files changed, 78 insertions(+), 92 deletions(-)
--
2.6.4
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH v3 1/6] irqchip: irq-armada-370-xp: add Kconfig option for the driver
2016-02-10 14:46 ` Thomas Petazzoni
@ 2016-02-10 14:46 ` Thomas Petazzoni
-1 siblings, 0 replies; 18+ messages in thread
From: Thomas Petazzoni @ 2016-02-10 14:46 UTC (permalink / raw)
To: Thomas Gleixner, Marc Zyngier, Jason Cooper
Cc: linux-arm-kernel, linux-kernel, Andrew Lunn,
Sebastian Hesselbarth, Gregory Clement, Thomas Petazzoni
Instead of building the irq-armada-370-xp driver directly when
CONFIG_ARCH_MVEBU is enabled, this commit introduces an intermediate
CONFIG_ARMADA_370_XP_IRQ hidden Kconfig option.
This allows this option to select other interrupt-related Kconfig
options (which will be needed in follow-up commits) rather than having
such selects done from arch/arm/mach-<foo>/.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Acked-by: Gregory CLEMENT <gregory.clement@free-electrons.com>
---
drivers/irqchip/Kconfig | 5 +++++
drivers/irqchip/Makefile | 2 +-
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/irqchip/Kconfig b/drivers/irqchip/Kconfig
index 715923d..e2cab87 100644
--- a/drivers/irqchip/Kconfig
+++ b/drivers/irqchip/Kconfig
@@ -60,6 +60,11 @@ config ARM_VIC_NR
The maximum number of VICs available in the system, for
power management.
+config ARMADA_370_XP_IRQ
+ bool
+ default y if ARCH_MVEBU
+ select GENERIC_IRQ_CHIP
+
config ATMEL_AIC_IRQ
bool
select GENERIC_IRQ_CHIP
diff --git a/drivers/irqchip/Makefile b/drivers/irqchip/Makefile
index 18caacb..30dba04 100644
--- a/drivers/irqchip/Makefile
+++ b/drivers/irqchip/Makefile
@@ -5,7 +5,6 @@ obj-$(CONFIG_ARCH_BCM2835) += irq-bcm2836.o
obj-$(CONFIG_ARCH_EXYNOS) += exynos-combiner.o
obj-$(CONFIG_ARCH_HIP04) += irq-hip04.o
obj-$(CONFIG_ARCH_MMP) += irq-mmp.o
-obj-$(CONFIG_ARCH_MVEBU) += irq-armada-370-xp.o
obj-$(CONFIG_IRQ_MXS) += irq-mxs.o
obj-$(CONFIG_ARCH_TEGRA) += irq-tegra.o
obj-$(CONFIG_ARCH_S3C24XX) += irq-s3c24xx.o
@@ -28,6 +27,7 @@ obj-$(CONFIG_ARM_GIC_V3_ITS) += irq-gic-v3-its.o irq-gic-v3-its-pci-msi.o irq-g
obj-$(CONFIG_HISILICON_IRQ_MBIGEN) += irq-mbigen.o
obj-$(CONFIG_ARM_NVIC) += irq-nvic.o
obj-$(CONFIG_ARM_VIC) += irq-vic.o
+obj-$(CONFIG_ARMADA_370_XP_IRQ) += irq-armada-370-xp.o
obj-$(CONFIG_ATMEL_AIC_IRQ) += irq-atmel-aic-common.o irq-atmel-aic.o
obj-$(CONFIG_ATMEL_AIC5_IRQ) += irq-atmel-aic-common.o irq-atmel-aic5.o
obj-$(CONFIG_I8259) += irq-i8259.o
--
2.6.4
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH v3 1/6] irqchip: irq-armada-370-xp: add Kconfig option for the driver
@ 2016-02-10 14:46 ` Thomas Petazzoni
0 siblings, 0 replies; 18+ messages in thread
From: Thomas Petazzoni @ 2016-02-10 14:46 UTC (permalink / raw)
To: linux-arm-kernel
Instead of building the irq-armada-370-xp driver directly when
CONFIG_ARCH_MVEBU is enabled, this commit introduces an intermediate
CONFIG_ARMADA_370_XP_IRQ hidden Kconfig option.
This allows this option to select other interrupt-related Kconfig
options (which will be needed in follow-up commits) rather than having
such selects done from arch/arm/mach-<foo>/.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Acked-by: Gregory CLEMENT <gregory.clement@free-electrons.com>
---
drivers/irqchip/Kconfig | 5 +++++
drivers/irqchip/Makefile | 2 +-
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/irqchip/Kconfig b/drivers/irqchip/Kconfig
index 715923d..e2cab87 100644
--- a/drivers/irqchip/Kconfig
+++ b/drivers/irqchip/Kconfig
@@ -60,6 +60,11 @@ config ARM_VIC_NR
The maximum number of VICs available in the system, for
power management.
+config ARMADA_370_XP_IRQ
+ bool
+ default y if ARCH_MVEBU
+ select GENERIC_IRQ_CHIP
+
config ATMEL_AIC_IRQ
bool
select GENERIC_IRQ_CHIP
diff --git a/drivers/irqchip/Makefile b/drivers/irqchip/Makefile
index 18caacb..30dba04 100644
--- a/drivers/irqchip/Makefile
+++ b/drivers/irqchip/Makefile
@@ -5,7 +5,6 @@ obj-$(CONFIG_ARCH_BCM2835) += irq-bcm2836.o
obj-$(CONFIG_ARCH_EXYNOS) += exynos-combiner.o
obj-$(CONFIG_ARCH_HIP04) += irq-hip04.o
obj-$(CONFIG_ARCH_MMP) += irq-mmp.o
-obj-$(CONFIG_ARCH_MVEBU) += irq-armada-370-xp.o
obj-$(CONFIG_IRQ_MXS) += irq-mxs.o
obj-$(CONFIG_ARCH_TEGRA) += irq-tegra.o
obj-$(CONFIG_ARCH_S3C24XX) += irq-s3c24xx.o
@@ -28,6 +27,7 @@ obj-$(CONFIG_ARM_GIC_V3_ITS) += irq-gic-v3-its.o irq-gic-v3-its-pci-msi.o irq-g
obj-$(CONFIG_HISILICON_IRQ_MBIGEN) += irq-mbigen.o
obj-$(CONFIG_ARM_NVIC) += irq-nvic.o
obj-$(CONFIG_ARM_VIC) += irq-vic.o
+obj-$(CONFIG_ARMADA_370_XP_IRQ) += irq-armada-370-xp.o
obj-$(CONFIG_ATMEL_AIC_IRQ) += irq-atmel-aic-common.o irq-atmel-aic.o
obj-$(CONFIG_ATMEL_AIC5_IRQ) += irq-atmel-aic-common.o irq-atmel-aic5.o
obj-$(CONFIG_I8259) += irq-i8259.o
--
2.6.4
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH v3 2/6] irqchip: irq-armada-370-xp: use the generic MSI infrastructure
2016-02-10 14:46 ` Thomas Petazzoni
@ 2016-02-10 14:46 ` Thomas Petazzoni
-1 siblings, 0 replies; 18+ messages in thread
From: Thomas Petazzoni @ 2016-02-10 14:46 UTC (permalink / raw)
To: Thomas Gleixner, Marc Zyngier, Jason Cooper
Cc: linux-arm-kernel, linux-kernel, Andrew Lunn,
Sebastian Hesselbarth, Gregory Clement, Thomas Petazzoni
This commit moves the irq-armada-370-xp driver from using the
PCI-specific MSI infrastructure to the generic MSI infrastructure, to
which drivers are progressively converted.
In this hardware, the MSI controller is directly bundled inside the
interrupt controller, so we have a single Device Tree node to which
multiple IRQ domaines are attached: the wired interrupt domain and the
MSI interrupt domain. In order to ensure that they can be
differentiated, we have to force the bus_token of the wired interrupt
domain to be DOMAIN_BUS_WIRED. The MSI domain bus_token is
automatically set to the appropriate value by
pci_msi_create_irq_domain().
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Suggested-by: Marc Zyngier <marc.zyngier@arm.com>
Reviewed-by: Marc Zyngier <marc.zyngier@arm.com>
---
drivers/irqchip/Kconfig | 1 +
drivers/irqchip/irq-armada-370-xp.c | 149 +++++++++++++++---------------------
2 files changed, 62 insertions(+), 88 deletions(-)
diff --git a/drivers/irqchip/Kconfig b/drivers/irqchip/Kconfig
index e2cab87..d233a80 100644
--- a/drivers/irqchip/Kconfig
+++ b/drivers/irqchip/Kconfig
@@ -64,6 +64,7 @@ config ARMADA_370_XP_IRQ
bool
default y if ARCH_MVEBU
select GENERIC_IRQ_CHIP
+ select PCI_MSI_IRQ_DOMAIN if PCI_MSI
config ATMEL_AIC_IRQ
bool
diff --git a/drivers/irqchip/irq-armada-370-xp.c b/drivers/irqchip/irq-armada-370-xp.c
index 3f3a8c3..e5738c5 100644
--- a/drivers/irqchip/irq-armada-370-xp.c
+++ b/drivers/irqchip/irq-armada-370-xp.c
@@ -71,6 +71,7 @@ static u32 doorbell_mask_reg;
static int parent_irq;
#ifdef CONFIG_PCI_MSI
static struct irq_domain *armada_370_xp_msi_domain;
+static struct irq_domain *armada_370_xp_msi_inner_domain;
static DECLARE_BITMAP(msi_used, PCI_MSI_DOORBELL_NR);
static DEFINE_MUTEX(msi_used_lock);
static phys_addr_t msi_doorbell_addr;
@@ -115,127 +116,99 @@ static void armada_370_xp_irq_unmask(struct irq_data *d)
#ifdef CONFIG_PCI_MSI
-static int armada_370_xp_alloc_msi(void)
-{
- int hwirq;
-
- mutex_lock(&msi_used_lock);
- hwirq = find_first_zero_bit(&msi_used, PCI_MSI_DOORBELL_NR);
- if (hwirq >= PCI_MSI_DOORBELL_NR)
- hwirq = -ENOSPC;
- else
- set_bit(hwirq, msi_used);
- mutex_unlock(&msi_used_lock);
+static struct irq_chip armada_370_xp_msi_irq_chip = {
+ .name = "armada_370_xp_msi_irq",
+ .irq_mask = pci_msi_mask_irq,
+ .irq_unmask = pci_msi_unmask_irq,
+};
- return hwirq;
-}
+static struct msi_domain_info armada_370_xp_msi_domain_info = {
+ .flags = (MSI_FLAG_USE_DEF_DOM_OPS | MSI_FLAG_USE_DEF_CHIP_OPS),
+ .chip = &armada_370_xp_msi_irq_chip,
+};
-static void armada_370_xp_free_msi(int hwirq)
+static void armada_370_xp_compose_msi_msg(struct irq_data *data, struct msi_msg *msg)
{
- mutex_lock(&msi_used_lock);
- if (!test_bit(hwirq, msi_used))
- pr_err("trying to free unused MSI#%d\n", hwirq);
- else
- clear_bit(hwirq, msi_used);
- mutex_unlock(&msi_used_lock);
+ msg->address_lo = lower_32_bits(msi_doorbell_addr);
+ msg->address_hi = upper_32_bits(msi_doorbell_addr);
+ msg->data = 0xf00 | (data->hwirq + PCI_MSI_DOORBELL_START);
}
-static int armada_370_xp_setup_msi_irq(struct msi_controller *chip,
- struct pci_dev *pdev,
- struct msi_desc *desc)
+static int armada_370_xp_msi_set_affinity(struct irq_data *irq_data,
+ const struct cpumask *mask, bool force)
{
- struct msi_msg msg;
- int virq, hwirq;
+ return -EINVAL;
+}
- /* We support MSI, but not MSI-X */
- if (desc->msi_attrib.is_msix)
- return -EINVAL;
+static struct irq_chip armada_370_xp_msi_bottom_irq_chip = {
+ .name = "armada_370_xp_msi_irq",
+ .irq_compose_msi_msg = armada_370_xp_compose_msi_msg,
+ .irq_set_affinity = armada_370_xp_msi_set_affinity,
+};
- hwirq = armada_370_xp_alloc_msi();
- if (hwirq < 0)
- return hwirq;
+static int armada_370_xp_msi_alloc(struct irq_domain *domain, unsigned int virq,
+ unsigned int nr_irqs, void *args)
+{
+ int hwirq;
- virq = irq_create_mapping(armada_370_xp_msi_domain, hwirq);
- if (!virq) {
- armada_370_xp_free_msi(hwirq);
- return -EINVAL;
+ mutex_lock(&msi_used_lock);
+ hwirq = find_first_zero_bit(&msi_used, PCI_MSI_DOORBELL_NR);
+ if (hwirq >= PCI_MSI_DOORBELL_NR) {
+ mutex_unlock(&msi_used_lock);
+ return -ENOSPC;
}
- irq_set_msi_desc(virq, desc);
+ set_bit(hwirq, msi_used);
+ mutex_unlock(&msi_used_lock);
- msg.address_lo = msi_doorbell_addr;
- msg.address_hi = 0;
- msg.data = 0xf00 | (hwirq + 16);
+ irq_domain_set_info(domain, virq, hwirq, &armada_370_xp_msi_bottom_irq_chip,
+ domain->host_data, handle_simple_irq,
+ NULL, NULL);
- pci_write_msi_msg(virq, &msg);
- return 0;
+ return hwirq;
}
-static void armada_370_xp_teardown_msi_irq(struct msi_controller *chip,
- unsigned int irq)
+static void armada_370_xp_msi_free(struct irq_domain *domain,
+ unsigned int virq, unsigned int nr_irqs)
{
- struct irq_data *d = irq_get_irq_data(irq);
- unsigned long hwirq = d->hwirq;
-
- irq_dispose_mapping(irq);
- armada_370_xp_free_msi(hwirq);
-}
-
-static struct irq_chip armada_370_xp_msi_irq_chip = {
- .name = "armada_370_xp_msi_irq",
- .irq_enable = pci_msi_unmask_irq,
- .irq_disable = pci_msi_mask_irq,
- .irq_mask = pci_msi_mask_irq,
- .irq_unmask = pci_msi_unmask_irq,
-};
+ struct irq_data *d = irq_domain_get_irq_data(domain, virq);
-static int armada_370_xp_msi_map(struct irq_domain *domain, unsigned int virq,
- irq_hw_number_t hw)
-{
- irq_set_chip_and_handler(virq, &armada_370_xp_msi_irq_chip,
- handle_simple_irq);
-
- return 0;
+ mutex_lock(&msi_used_lock);
+ if (!test_bit(d->hwirq, msi_used))
+ pr_err("trying to free unused MSI#%lu\n", d->hwirq);
+ else
+ clear_bit(d->hwirq, msi_used);
+ mutex_unlock(&msi_used_lock);
}
-static const struct irq_domain_ops armada_370_xp_msi_irq_ops = {
- .map = armada_370_xp_msi_map,
+static const struct irq_domain_ops armada_370_xp_msi_domain_ops = {
+ .alloc = armada_370_xp_msi_alloc,
+ .free = armada_370_xp_msi_free,
};
static int armada_370_xp_msi_init(struct device_node *node,
phys_addr_t main_int_phys_base)
{
- struct msi_controller *msi_chip;
u32 reg;
- int ret;
msi_doorbell_addr = main_int_phys_base +
ARMADA_370_XP_SW_TRIG_INT_OFFS;
- msi_chip = kzalloc(sizeof(*msi_chip), GFP_KERNEL);
- if (!msi_chip)
+ armada_370_xp_msi_inner_domain =
+ irq_domain_add_linear(NULL, PCI_MSI_DOORBELL_NR,
+ &armada_370_xp_msi_domain_ops, NULL);
+ if (!armada_370_xp_msi_inner_domain)
return -ENOMEM;
- msi_chip->setup_irq = armada_370_xp_setup_msi_irq;
- msi_chip->teardown_irq = armada_370_xp_teardown_msi_irq;
- msi_chip->of_node = node;
-
armada_370_xp_msi_domain =
- irq_domain_add_linear(NULL, PCI_MSI_DOORBELL_NR,
- &armada_370_xp_msi_irq_ops,
- NULL);
+ pci_msi_create_irq_domain(of_node_to_fwnode(node),
+ &armada_370_xp_msi_domain_info,
+ armada_370_xp_msi_inner_domain);
if (!armada_370_xp_msi_domain) {
- kfree(msi_chip);
+ irq_domain_remove(armada_370_xp_msi_inner_domain);
return -ENOMEM;
}
- ret = of_pci_msi_chip_add(msi_chip);
- if (ret < 0) {
- irq_domain_remove(armada_370_xp_msi_domain);
- kfree(msi_chip);
- return ret;
- }
-
reg = readl(per_cpu_int_base + ARMADA_370_XP_IN_DRBEL_MSK_OFFS)
| PCI_MSI_DOORBELL_MASK;
@@ -427,12 +400,12 @@ static void armada_370_xp_handle_msi_irq(struct pt_regs *regs, bool is_chained)
continue;
if (is_chained) {
- irq = irq_find_mapping(armada_370_xp_msi_domain,
+ irq = irq_find_mapping(armada_370_xp_msi_inner_domain,
msinr - 16);
generic_handle_irq(irq);
} else {
irq = msinr - 16;
- handle_domain_irq(armada_370_xp_msi_domain,
+ handle_domain_irq(armada_370_xp_msi_inner_domain,
irq, regs);
}
}
@@ -604,8 +577,8 @@ static int __init armada_370_xp_mpic_of_init(struct device_node *node,
armada_370_xp_mpic_domain =
irq_domain_add_linear(node, nr_irqs,
&armada_370_xp_mpic_irq_ops, NULL);
-
BUG_ON(!armada_370_xp_mpic_domain);
+ armada_370_xp_mpic_domain->bus_token = DOMAIN_BUS_WIRED;
/* Setup for the boot CPU */
armada_xp_mpic_perf_init();
--
2.6.4
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH v3 2/6] irqchip: irq-armada-370-xp: use the generic MSI infrastructure
@ 2016-02-10 14:46 ` Thomas Petazzoni
0 siblings, 0 replies; 18+ messages in thread
From: Thomas Petazzoni @ 2016-02-10 14:46 UTC (permalink / raw)
To: linux-arm-kernel
This commit moves the irq-armada-370-xp driver from using the
PCI-specific MSI infrastructure to the generic MSI infrastructure, to
which drivers are progressively converted.
In this hardware, the MSI controller is directly bundled inside the
interrupt controller, so we have a single Device Tree node to which
multiple IRQ domaines are attached: the wired interrupt domain and the
MSI interrupt domain. In order to ensure that they can be
differentiated, we have to force the bus_token of the wired interrupt
domain to be DOMAIN_BUS_WIRED. The MSI domain bus_token is
automatically set to the appropriate value by
pci_msi_create_irq_domain().
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Suggested-by: Marc Zyngier <marc.zyngier@arm.com>
Reviewed-by: Marc Zyngier <marc.zyngier@arm.com>
---
drivers/irqchip/Kconfig | 1 +
drivers/irqchip/irq-armada-370-xp.c | 149 +++++++++++++++---------------------
2 files changed, 62 insertions(+), 88 deletions(-)
diff --git a/drivers/irqchip/Kconfig b/drivers/irqchip/Kconfig
index e2cab87..d233a80 100644
--- a/drivers/irqchip/Kconfig
+++ b/drivers/irqchip/Kconfig
@@ -64,6 +64,7 @@ config ARMADA_370_XP_IRQ
bool
default y if ARCH_MVEBU
select GENERIC_IRQ_CHIP
+ select PCI_MSI_IRQ_DOMAIN if PCI_MSI
config ATMEL_AIC_IRQ
bool
diff --git a/drivers/irqchip/irq-armada-370-xp.c b/drivers/irqchip/irq-armada-370-xp.c
index 3f3a8c3..e5738c5 100644
--- a/drivers/irqchip/irq-armada-370-xp.c
+++ b/drivers/irqchip/irq-armada-370-xp.c
@@ -71,6 +71,7 @@ static u32 doorbell_mask_reg;
static int parent_irq;
#ifdef CONFIG_PCI_MSI
static struct irq_domain *armada_370_xp_msi_domain;
+static struct irq_domain *armada_370_xp_msi_inner_domain;
static DECLARE_BITMAP(msi_used, PCI_MSI_DOORBELL_NR);
static DEFINE_MUTEX(msi_used_lock);
static phys_addr_t msi_doorbell_addr;
@@ -115,127 +116,99 @@ static void armada_370_xp_irq_unmask(struct irq_data *d)
#ifdef CONFIG_PCI_MSI
-static int armada_370_xp_alloc_msi(void)
-{
- int hwirq;
-
- mutex_lock(&msi_used_lock);
- hwirq = find_first_zero_bit(&msi_used, PCI_MSI_DOORBELL_NR);
- if (hwirq >= PCI_MSI_DOORBELL_NR)
- hwirq = -ENOSPC;
- else
- set_bit(hwirq, msi_used);
- mutex_unlock(&msi_used_lock);
+static struct irq_chip armada_370_xp_msi_irq_chip = {
+ .name = "armada_370_xp_msi_irq",
+ .irq_mask = pci_msi_mask_irq,
+ .irq_unmask = pci_msi_unmask_irq,
+};
- return hwirq;
-}
+static struct msi_domain_info armada_370_xp_msi_domain_info = {
+ .flags = (MSI_FLAG_USE_DEF_DOM_OPS | MSI_FLAG_USE_DEF_CHIP_OPS),
+ .chip = &armada_370_xp_msi_irq_chip,
+};
-static void armada_370_xp_free_msi(int hwirq)
+static void armada_370_xp_compose_msi_msg(struct irq_data *data, struct msi_msg *msg)
{
- mutex_lock(&msi_used_lock);
- if (!test_bit(hwirq, msi_used))
- pr_err("trying to free unused MSI#%d\n", hwirq);
- else
- clear_bit(hwirq, msi_used);
- mutex_unlock(&msi_used_lock);
+ msg->address_lo = lower_32_bits(msi_doorbell_addr);
+ msg->address_hi = upper_32_bits(msi_doorbell_addr);
+ msg->data = 0xf00 | (data->hwirq + PCI_MSI_DOORBELL_START);
}
-static int armada_370_xp_setup_msi_irq(struct msi_controller *chip,
- struct pci_dev *pdev,
- struct msi_desc *desc)
+static int armada_370_xp_msi_set_affinity(struct irq_data *irq_data,
+ const struct cpumask *mask, bool force)
{
- struct msi_msg msg;
- int virq, hwirq;
+ return -EINVAL;
+}
- /* We support MSI, but not MSI-X */
- if (desc->msi_attrib.is_msix)
- return -EINVAL;
+static struct irq_chip armada_370_xp_msi_bottom_irq_chip = {
+ .name = "armada_370_xp_msi_irq",
+ .irq_compose_msi_msg = armada_370_xp_compose_msi_msg,
+ .irq_set_affinity = armada_370_xp_msi_set_affinity,
+};
- hwirq = armada_370_xp_alloc_msi();
- if (hwirq < 0)
- return hwirq;
+static int armada_370_xp_msi_alloc(struct irq_domain *domain, unsigned int virq,
+ unsigned int nr_irqs, void *args)
+{
+ int hwirq;
- virq = irq_create_mapping(armada_370_xp_msi_domain, hwirq);
- if (!virq) {
- armada_370_xp_free_msi(hwirq);
- return -EINVAL;
+ mutex_lock(&msi_used_lock);
+ hwirq = find_first_zero_bit(&msi_used, PCI_MSI_DOORBELL_NR);
+ if (hwirq >= PCI_MSI_DOORBELL_NR) {
+ mutex_unlock(&msi_used_lock);
+ return -ENOSPC;
}
- irq_set_msi_desc(virq, desc);
+ set_bit(hwirq, msi_used);
+ mutex_unlock(&msi_used_lock);
- msg.address_lo = msi_doorbell_addr;
- msg.address_hi = 0;
- msg.data = 0xf00 | (hwirq + 16);
+ irq_domain_set_info(domain, virq, hwirq, &armada_370_xp_msi_bottom_irq_chip,
+ domain->host_data, handle_simple_irq,
+ NULL, NULL);
- pci_write_msi_msg(virq, &msg);
- return 0;
+ return hwirq;
}
-static void armada_370_xp_teardown_msi_irq(struct msi_controller *chip,
- unsigned int irq)
+static void armada_370_xp_msi_free(struct irq_domain *domain,
+ unsigned int virq, unsigned int nr_irqs)
{
- struct irq_data *d = irq_get_irq_data(irq);
- unsigned long hwirq = d->hwirq;
-
- irq_dispose_mapping(irq);
- armada_370_xp_free_msi(hwirq);
-}
-
-static struct irq_chip armada_370_xp_msi_irq_chip = {
- .name = "armada_370_xp_msi_irq",
- .irq_enable = pci_msi_unmask_irq,
- .irq_disable = pci_msi_mask_irq,
- .irq_mask = pci_msi_mask_irq,
- .irq_unmask = pci_msi_unmask_irq,
-};
+ struct irq_data *d = irq_domain_get_irq_data(domain, virq);
-static int armada_370_xp_msi_map(struct irq_domain *domain, unsigned int virq,
- irq_hw_number_t hw)
-{
- irq_set_chip_and_handler(virq, &armada_370_xp_msi_irq_chip,
- handle_simple_irq);
-
- return 0;
+ mutex_lock(&msi_used_lock);
+ if (!test_bit(d->hwirq, msi_used))
+ pr_err("trying to free unused MSI#%lu\n", d->hwirq);
+ else
+ clear_bit(d->hwirq, msi_used);
+ mutex_unlock(&msi_used_lock);
}
-static const struct irq_domain_ops armada_370_xp_msi_irq_ops = {
- .map = armada_370_xp_msi_map,
+static const struct irq_domain_ops armada_370_xp_msi_domain_ops = {
+ .alloc = armada_370_xp_msi_alloc,
+ .free = armada_370_xp_msi_free,
};
static int armada_370_xp_msi_init(struct device_node *node,
phys_addr_t main_int_phys_base)
{
- struct msi_controller *msi_chip;
u32 reg;
- int ret;
msi_doorbell_addr = main_int_phys_base +
ARMADA_370_XP_SW_TRIG_INT_OFFS;
- msi_chip = kzalloc(sizeof(*msi_chip), GFP_KERNEL);
- if (!msi_chip)
+ armada_370_xp_msi_inner_domain =
+ irq_domain_add_linear(NULL, PCI_MSI_DOORBELL_NR,
+ &armada_370_xp_msi_domain_ops, NULL);
+ if (!armada_370_xp_msi_inner_domain)
return -ENOMEM;
- msi_chip->setup_irq = armada_370_xp_setup_msi_irq;
- msi_chip->teardown_irq = armada_370_xp_teardown_msi_irq;
- msi_chip->of_node = node;
-
armada_370_xp_msi_domain =
- irq_domain_add_linear(NULL, PCI_MSI_DOORBELL_NR,
- &armada_370_xp_msi_irq_ops,
- NULL);
+ pci_msi_create_irq_domain(of_node_to_fwnode(node),
+ &armada_370_xp_msi_domain_info,
+ armada_370_xp_msi_inner_domain);
if (!armada_370_xp_msi_domain) {
- kfree(msi_chip);
+ irq_domain_remove(armada_370_xp_msi_inner_domain);
return -ENOMEM;
}
- ret = of_pci_msi_chip_add(msi_chip);
- if (ret < 0) {
- irq_domain_remove(armada_370_xp_msi_domain);
- kfree(msi_chip);
- return ret;
- }
-
reg = readl(per_cpu_int_base + ARMADA_370_XP_IN_DRBEL_MSK_OFFS)
| PCI_MSI_DOORBELL_MASK;
@@ -427,12 +400,12 @@ static void armada_370_xp_handle_msi_irq(struct pt_regs *regs, bool is_chained)
continue;
if (is_chained) {
- irq = irq_find_mapping(armada_370_xp_msi_domain,
+ irq = irq_find_mapping(armada_370_xp_msi_inner_domain,
msinr - 16);
generic_handle_irq(irq);
} else {
irq = msinr - 16;
- handle_domain_irq(armada_370_xp_msi_domain,
+ handle_domain_irq(armada_370_xp_msi_inner_domain,
irq, regs);
}
}
@@ -604,8 +577,8 @@ static int __init armada_370_xp_mpic_of_init(struct device_node *node,
armada_370_xp_mpic_domain =
irq_domain_add_linear(node, nr_irqs,
&armada_370_xp_mpic_irq_ops, NULL);
-
BUG_ON(!armada_370_xp_mpic_domain);
+ armada_370_xp_mpic_domain->bus_token = DOMAIN_BUS_WIRED;
/* Setup for the boot CPU */
armada_xp_mpic_perf_init();
--
2.6.4
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH v3 3/6] irqchip: irq-armada-370-xp: use PCI_MSI_DOORBELL_START where appropriate
2016-02-10 14:46 ` Thomas Petazzoni
@ 2016-02-10 14:46 ` Thomas Petazzoni
-1 siblings, 0 replies; 18+ messages in thread
From: Thomas Petazzoni @ 2016-02-10 14:46 UTC (permalink / raw)
To: Thomas Gleixner, Marc Zyngier, Jason Cooper
Cc: linux-arm-kernel, linux-kernel, Andrew Lunn,
Sebastian Hesselbarth, Gregory Clement, Thomas Petazzoni
As suggested by Gregory Clement, this commit adjusts the
irq-armada-370-xp driver to use the PCI_MSI_DOORBELL_START define in
the armada_370_xp_handle_msi_irq() function, rather than hardcoding
its value.
Suggested-by: Gregory CLEMENT <gregory.clement@free-electrons.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Acked-by: Gregory CLEMENT <gregory.clement@free-electrons.com>
---
drivers/irqchip/irq-armada-370-xp.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/irqchip/irq-armada-370-xp.c b/drivers/irqchip/irq-armada-370-xp.c
index e5738c5..f53eb71 100644
--- a/drivers/irqchip/irq-armada-370-xp.c
+++ b/drivers/irqchip/irq-armada-370-xp.c
@@ -401,10 +401,10 @@ static void armada_370_xp_handle_msi_irq(struct pt_regs *regs, bool is_chained)
if (is_chained) {
irq = irq_find_mapping(armada_370_xp_msi_inner_domain,
- msinr - 16);
+ msinr - PCI_MSI_DOORBELL_START);
generic_handle_irq(irq);
} else {
- irq = msinr - 16;
+ irq = msinr - PCI_MSI_DOORBELL_START;
handle_domain_irq(armada_370_xp_msi_inner_domain,
irq, regs);
}
--
2.6.4
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH v3 3/6] irqchip: irq-armada-370-xp: use PCI_MSI_DOORBELL_START where appropriate
@ 2016-02-10 14:46 ` Thomas Petazzoni
0 siblings, 0 replies; 18+ messages in thread
From: Thomas Petazzoni @ 2016-02-10 14:46 UTC (permalink / raw)
To: linux-arm-kernel
As suggested by Gregory Clement, this commit adjusts the
irq-armada-370-xp driver to use the PCI_MSI_DOORBELL_START define in
the armada_370_xp_handle_msi_irq() function, rather than hardcoding
its value.
Suggested-by: Gregory CLEMENT <gregory.clement@free-electrons.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Acked-by: Gregory CLEMENT <gregory.clement@free-electrons.com>
---
drivers/irqchip/irq-armada-370-xp.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/irqchip/irq-armada-370-xp.c b/drivers/irqchip/irq-armada-370-xp.c
index e5738c5..f53eb71 100644
--- a/drivers/irqchip/irq-armada-370-xp.c
+++ b/drivers/irqchip/irq-armada-370-xp.c
@@ -401,10 +401,10 @@ static void armada_370_xp_handle_msi_irq(struct pt_regs *regs, bool is_chained)
if (is_chained) {
irq = irq_find_mapping(armada_370_xp_msi_inner_domain,
- msinr - 16);
+ msinr - PCI_MSI_DOORBELL_START);
generic_handle_irq(irq);
} else {
- irq = msinr - 16;
+ irq = msinr - PCI_MSI_DOORBELL_START;
handle_domain_irq(armada_370_xp_msi_inner_domain,
irq, regs);
}
--
2.6.4
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH v3 4/6] irqchip: irq-armada-370-xp: use shorter names for irq_chip
2016-02-10 14:46 ` Thomas Petazzoni
@ 2016-02-10 14:46 ` Thomas Petazzoni
-1 siblings, 0 replies; 18+ messages in thread
From: Thomas Petazzoni @ 2016-02-10 14:46 UTC (permalink / raw)
To: Thomas Gleixner, Marc Zyngier, Jason Cooper
Cc: linux-arm-kernel, linux-kernel, Andrew Lunn,
Sebastian Hesselbarth, Gregory Clement, Thomas Petazzoni
In order to make the output of /proc/interrupts, use shorter names for
the irq_chip registered by the irq-armada-370-xp driver. Using capital
letters also matches better what is done for the GIC driver, which
uses just "GIC" as the irq_chip->name.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Acked-by: Gregory CLEMENT <gregory.clement@free-electrons.com>
---
drivers/irqchip/irq-armada-370-xp.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/irqchip/irq-armada-370-xp.c b/drivers/irqchip/irq-armada-370-xp.c
index f53eb71..c99ae5f 100644
--- a/drivers/irqchip/irq-armada-370-xp.c
+++ b/drivers/irqchip/irq-armada-370-xp.c
@@ -117,7 +117,7 @@ static void armada_370_xp_irq_unmask(struct irq_data *d)
#ifdef CONFIG_PCI_MSI
static struct irq_chip armada_370_xp_msi_irq_chip = {
- .name = "armada_370_xp_msi_irq",
+ .name = "MPIC MSI",
.irq_mask = pci_msi_mask_irq,
.irq_unmask = pci_msi_unmask_irq,
};
@@ -141,7 +141,7 @@ static int armada_370_xp_msi_set_affinity(struct irq_data *irq_data,
}
static struct irq_chip armada_370_xp_msi_bottom_irq_chip = {
- .name = "armada_370_xp_msi_irq",
+ .name = "MPIC MSI",
.irq_compose_msi_msg = armada_370_xp_compose_msi_msg,
.irq_set_affinity = armada_370_xp_msi_set_affinity,
};
@@ -253,7 +253,7 @@ static int armada_xp_set_affinity(struct irq_data *d,
#endif
static struct irq_chip armada_370_xp_irq_chip = {
- .name = "armada_370_xp_irq",
+ .name = "MPIC",
.irq_mask = armada_370_xp_irq_mask,
.irq_mask_ack = armada_370_xp_irq_mask,
.irq_unmask = armada_370_xp_irq_unmask,
--
2.6.4
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH v3 4/6] irqchip: irq-armada-370-xp: use shorter names for irq_chip
@ 2016-02-10 14:46 ` Thomas Petazzoni
0 siblings, 0 replies; 18+ messages in thread
From: Thomas Petazzoni @ 2016-02-10 14:46 UTC (permalink / raw)
To: linux-arm-kernel
In order to make the output of /proc/interrupts, use shorter names for
the irq_chip registered by the irq-armada-370-xp driver. Using capital
letters also matches better what is done for the GIC driver, which
uses just "GIC" as the irq_chip->name.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Acked-by: Gregory CLEMENT <gregory.clement@free-electrons.com>
---
drivers/irqchip/irq-armada-370-xp.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/irqchip/irq-armada-370-xp.c b/drivers/irqchip/irq-armada-370-xp.c
index f53eb71..c99ae5f 100644
--- a/drivers/irqchip/irq-armada-370-xp.c
+++ b/drivers/irqchip/irq-armada-370-xp.c
@@ -117,7 +117,7 @@ static void armada_370_xp_irq_unmask(struct irq_data *d)
#ifdef CONFIG_PCI_MSI
static struct irq_chip armada_370_xp_msi_irq_chip = {
- .name = "armada_370_xp_msi_irq",
+ .name = "MPIC MSI",
.irq_mask = pci_msi_mask_irq,
.irq_unmask = pci_msi_unmask_irq,
};
@@ -141,7 +141,7 @@ static int armada_370_xp_msi_set_affinity(struct irq_data *irq_data,
}
static struct irq_chip armada_370_xp_msi_bottom_irq_chip = {
- .name = "armada_370_xp_msi_irq",
+ .name = "MPIC MSI",
.irq_compose_msi_msg = armada_370_xp_compose_msi_msg,
.irq_set_affinity = armada_370_xp_msi_set_affinity,
};
@@ -253,7 +253,7 @@ static int armada_xp_set_affinity(struct irq_data *d,
#endif
static struct irq_chip armada_370_xp_irq_chip = {
- .name = "armada_370_xp_irq",
+ .name = "MPIC",
.irq_mask = armada_370_xp_irq_mask,
.irq_mask_ack = armada_370_xp_irq_mask,
.irq_unmask = armada_370_xp_irq_unmask,
--
2.6.4
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH v3 5/6] irqchip: irq-armada-370-xp: allow allocation of multiple MSIs
2016-02-10 14:46 ` Thomas Petazzoni
@ 2016-02-10 14:47 ` Thomas Petazzoni
-1 siblings, 0 replies; 18+ messages in thread
From: Thomas Petazzoni @ 2016-02-10 14:47 UTC (permalink / raw)
To: Thomas Gleixner, Marc Zyngier, Jason Cooper
Cc: linux-arm-kernel, linux-kernel, Andrew Lunn,
Sebastian Hesselbarth, Gregory Clement, Thomas Petazzoni
Add support for allocating multiple MSIs at the same time, so that the
MSI_FLAG_MULTI_PCI_MSI flag can be added to the msi_domain_info
structure.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Reviewed-by: Gregory CLEMENT <gregory.clement@free-electrons.com>
---
drivers/irqchip/irq-armada-370-xp.c | 25 ++++++++++++++-----------
1 file changed, 14 insertions(+), 11 deletions(-)
diff --git a/drivers/irqchip/irq-armada-370-xp.c b/drivers/irqchip/irq-armada-370-xp.c
index c99ae5f..e7dc6cb 100644
--- a/drivers/irqchip/irq-armada-370-xp.c
+++ b/drivers/irqchip/irq-armada-370-xp.c
@@ -123,7 +123,8 @@ static struct irq_chip armada_370_xp_msi_irq_chip = {
};
static struct msi_domain_info armada_370_xp_msi_domain_info = {
- .flags = (MSI_FLAG_USE_DEF_DOM_OPS | MSI_FLAG_USE_DEF_CHIP_OPS),
+ .flags = (MSI_FLAG_USE_DEF_DOM_OPS | MSI_FLAG_USE_DEF_CHIP_OPS |
+ MSI_FLAG_MULTI_PCI_MSI),
.chip = &armada_370_xp_msi_irq_chip,
};
@@ -149,21 +150,26 @@ static struct irq_chip armada_370_xp_msi_bottom_irq_chip = {
static int armada_370_xp_msi_alloc(struct irq_domain *domain, unsigned int virq,
unsigned int nr_irqs, void *args)
{
- int hwirq;
+ int hwirq, i;
mutex_lock(&msi_used_lock);
- hwirq = find_first_zero_bit(&msi_used, PCI_MSI_DOORBELL_NR);
+
+ hwirq = bitmap_find_next_zero_area(msi_used, PCI_MSI_DOORBELL_NR,
+ 0, nr_irqs, 0);
if (hwirq >= PCI_MSI_DOORBELL_NR) {
mutex_unlock(&msi_used_lock);
return -ENOSPC;
}
- set_bit(hwirq, msi_used);
+ bitmap_set(msi_used, hwirq, nr_irqs);
mutex_unlock(&msi_used_lock);
- irq_domain_set_info(domain, virq, hwirq, &armada_370_xp_msi_bottom_irq_chip,
- domain->host_data, handle_simple_irq,
- NULL, NULL);
+ for (i = 0; i < nr_irqs; i++) {
+ irq_domain_set_info(domain, virq + i, hwirq + i,
+ &armada_370_xp_msi_bottom_irq_chip,
+ domain->host_data, handle_simple_irq,
+ NULL, NULL);
+ }
return hwirq;
}
@@ -174,10 +180,7 @@ static void armada_370_xp_msi_free(struct irq_domain *domain,
struct irq_data *d = irq_domain_get_irq_data(domain, virq);
mutex_lock(&msi_used_lock);
- if (!test_bit(d->hwirq, msi_used))
- pr_err("trying to free unused MSI#%lu\n", d->hwirq);
- else
- clear_bit(d->hwirq, msi_used);
+ bitmap_clear(msi_used, d->hwirq, nr_irqs);
mutex_unlock(&msi_used_lock);
}
--
2.6.4
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH v3 5/6] irqchip: irq-armada-370-xp: allow allocation of multiple MSIs
@ 2016-02-10 14:47 ` Thomas Petazzoni
0 siblings, 0 replies; 18+ messages in thread
From: Thomas Petazzoni @ 2016-02-10 14:47 UTC (permalink / raw)
To: linux-arm-kernel
Add support for allocating multiple MSIs at the same time, so that the
MSI_FLAG_MULTI_PCI_MSI flag can be added to the msi_domain_info
structure.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Reviewed-by: Gregory CLEMENT <gregory.clement@free-electrons.com>
---
drivers/irqchip/irq-armada-370-xp.c | 25 ++++++++++++++-----------
1 file changed, 14 insertions(+), 11 deletions(-)
diff --git a/drivers/irqchip/irq-armada-370-xp.c b/drivers/irqchip/irq-armada-370-xp.c
index c99ae5f..e7dc6cb 100644
--- a/drivers/irqchip/irq-armada-370-xp.c
+++ b/drivers/irqchip/irq-armada-370-xp.c
@@ -123,7 +123,8 @@ static struct irq_chip armada_370_xp_msi_irq_chip = {
};
static struct msi_domain_info armada_370_xp_msi_domain_info = {
- .flags = (MSI_FLAG_USE_DEF_DOM_OPS | MSI_FLAG_USE_DEF_CHIP_OPS),
+ .flags = (MSI_FLAG_USE_DEF_DOM_OPS | MSI_FLAG_USE_DEF_CHIP_OPS |
+ MSI_FLAG_MULTI_PCI_MSI),
.chip = &armada_370_xp_msi_irq_chip,
};
@@ -149,21 +150,26 @@ static struct irq_chip armada_370_xp_msi_bottom_irq_chip = {
static int armada_370_xp_msi_alloc(struct irq_domain *domain, unsigned int virq,
unsigned int nr_irqs, void *args)
{
- int hwirq;
+ int hwirq, i;
mutex_lock(&msi_used_lock);
- hwirq = find_first_zero_bit(&msi_used, PCI_MSI_DOORBELL_NR);
+
+ hwirq = bitmap_find_next_zero_area(msi_used, PCI_MSI_DOORBELL_NR,
+ 0, nr_irqs, 0);
if (hwirq >= PCI_MSI_DOORBELL_NR) {
mutex_unlock(&msi_used_lock);
return -ENOSPC;
}
- set_bit(hwirq, msi_used);
+ bitmap_set(msi_used, hwirq, nr_irqs);
mutex_unlock(&msi_used_lock);
- irq_domain_set_info(domain, virq, hwirq, &armada_370_xp_msi_bottom_irq_chip,
- domain->host_data, handle_simple_irq,
- NULL, NULL);
+ for (i = 0; i < nr_irqs; i++) {
+ irq_domain_set_info(domain, virq + i, hwirq + i,
+ &armada_370_xp_msi_bottom_irq_chip,
+ domain->host_data, handle_simple_irq,
+ NULL, NULL);
+ }
return hwirq;
}
@@ -174,10 +180,7 @@ static void armada_370_xp_msi_free(struct irq_domain *domain,
struct irq_data *d = irq_domain_get_irq_data(domain, virq);
mutex_lock(&msi_used_lock);
- if (!test_bit(d->hwirq, msi_used))
- pr_err("trying to free unused MSI#%lu\n", d->hwirq);
- else
- clear_bit(d->hwirq, msi_used);
+ bitmap_clear(msi_used, d->hwirq, nr_irqs);
mutex_unlock(&msi_used_lock);
}
--
2.6.4
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH v3 6/6] ARM: mvebu: use the ARMADA_370_XP_IRQ option
2016-02-10 14:46 ` Thomas Petazzoni
@ 2016-02-10 14:47 ` Thomas Petazzoni
-1 siblings, 0 replies; 18+ messages in thread
From: Thomas Petazzoni @ 2016-02-10 14:47 UTC (permalink / raw)
To: Thomas Gleixner, Marc Zyngier, Jason Cooper
Cc: linux-arm-kernel, linux-kernel, Andrew Lunn,
Sebastian Hesselbarth, Gregory Clement, Thomas Petazzoni
Now that there is a ARMADA_370_XP_IRQ option to enable the irqchip
driver for Armada 370, XP, 375, 38x and 39x, let's select this option
when needed. Note that this selection is currently not mandatory
because ARMADA_370_XP_IRQ is for now always enabled when ARCH_MVEBU=y,
but this is something that we will change in the future, and therefore
we should make the relevant platforms select ARMADA_370_XP_IRQ when
needed.
Due to this, selecting GENERIC_IRQ_CHIP is no longer needed.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Acked-by: Gregory CLEMENT <gregory.clement@free-electrons.com>
---
arch/arm/mach-mvebu/Kconfig | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/arch/arm/mach-mvebu/Kconfig b/arch/arm/mach-mvebu/Kconfig
index 64e3d2c..b003e3a 100644
--- a/arch/arm/mach-mvebu/Kconfig
+++ b/arch/arm/mach-mvebu/Kconfig
@@ -3,7 +3,6 @@ menuconfig ARCH_MVEBU
depends on ARCH_MULTI_V7 || ARCH_MULTI_V5
select ARCH_SUPPORTS_BIG_ENDIAN
select CLKSRC_MMIO
- select GENERIC_IRQ_CHIP
select PINCTRL
select PLAT_ORION
select SOC_BUS
@@ -29,6 +28,7 @@ config MACH_ARMADA_370
bool "Marvell Armada 370 boards"
depends on ARCH_MULTI_V7
select ARMADA_370_CLK
+ select ARMADA_370_XP_IRQ
select CPU_PJ4B
select MACH_MVEBU_V7
select PINCTRL_ARMADA_370
@@ -39,6 +39,7 @@ config MACH_ARMADA_370
config MACH_ARMADA_375
bool "Marvell Armada 375 boards"
depends on ARCH_MULTI_V7
+ select ARMADA_370_XP_IRQ
select ARM_ERRATA_720789
select ARM_ERRATA_753970
select ARM_GIC
@@ -58,6 +59,7 @@ config MACH_ARMADA_38X
select ARM_ERRATA_720789
select ARM_ERRATA_753970
select ARM_GIC
+ select ARMADA_370_XP_IRQ
select ARMADA_38X_CLK
select HAVE_ARM_SCU
select HAVE_ARM_TWD if SMP
@@ -72,6 +74,7 @@ config MACH_ARMADA_39X
bool "Marvell Armada 39x boards"
depends on ARCH_MULTI_V7
select ARM_GIC
+ select ARMADA_370_XP_IRQ
select ARMADA_39X_CLK
select CACHE_L2X0
select HAVE_ARM_SCU
@@ -86,6 +89,7 @@ config MACH_ARMADA_39X
config MACH_ARMADA_XP
bool "Marvell Armada XP boards"
depends on ARCH_MULTI_V7
+ select ARMADA_370_XP_IRQ
select ARMADA_XP_CLK
select CPU_PJ4B
select MACH_MVEBU_V7
--
2.6.4
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH v3 6/6] ARM: mvebu: use the ARMADA_370_XP_IRQ option
@ 2016-02-10 14:47 ` Thomas Petazzoni
0 siblings, 0 replies; 18+ messages in thread
From: Thomas Petazzoni @ 2016-02-10 14:47 UTC (permalink / raw)
To: linux-arm-kernel
Now that there is a ARMADA_370_XP_IRQ option to enable the irqchip
driver for Armada 370, XP, 375, 38x and 39x, let's select this option
when needed. Note that this selection is currently not mandatory
because ARMADA_370_XP_IRQ is for now always enabled when ARCH_MVEBU=y,
but this is something that we will change in the future, and therefore
we should make the relevant platforms select ARMADA_370_XP_IRQ when
needed.
Due to this, selecting GENERIC_IRQ_CHIP is no longer needed.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Acked-by: Gregory CLEMENT <gregory.clement@free-electrons.com>
---
arch/arm/mach-mvebu/Kconfig | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/arch/arm/mach-mvebu/Kconfig b/arch/arm/mach-mvebu/Kconfig
index 64e3d2c..b003e3a 100644
--- a/arch/arm/mach-mvebu/Kconfig
+++ b/arch/arm/mach-mvebu/Kconfig
@@ -3,7 +3,6 @@ menuconfig ARCH_MVEBU
depends on ARCH_MULTI_V7 || ARCH_MULTI_V5
select ARCH_SUPPORTS_BIG_ENDIAN
select CLKSRC_MMIO
- select GENERIC_IRQ_CHIP
select PINCTRL
select PLAT_ORION
select SOC_BUS
@@ -29,6 +28,7 @@ config MACH_ARMADA_370
bool "Marvell Armada 370 boards"
depends on ARCH_MULTI_V7
select ARMADA_370_CLK
+ select ARMADA_370_XP_IRQ
select CPU_PJ4B
select MACH_MVEBU_V7
select PINCTRL_ARMADA_370
@@ -39,6 +39,7 @@ config MACH_ARMADA_370
config MACH_ARMADA_375
bool "Marvell Armada 375 boards"
depends on ARCH_MULTI_V7
+ select ARMADA_370_XP_IRQ
select ARM_ERRATA_720789
select ARM_ERRATA_753970
select ARM_GIC
@@ -58,6 +59,7 @@ config MACH_ARMADA_38X
select ARM_ERRATA_720789
select ARM_ERRATA_753970
select ARM_GIC
+ select ARMADA_370_XP_IRQ
select ARMADA_38X_CLK
select HAVE_ARM_SCU
select HAVE_ARM_TWD if SMP
@@ -72,6 +74,7 @@ config MACH_ARMADA_39X
bool "Marvell Armada 39x boards"
depends on ARCH_MULTI_V7
select ARM_GIC
+ select ARMADA_370_XP_IRQ
select ARMADA_39X_CLK
select CACHE_L2X0
select HAVE_ARM_SCU
@@ -86,6 +89,7 @@ config MACH_ARMADA_39X
config MACH_ARMADA_XP
bool "Marvell Armada XP boards"
depends on ARCH_MULTI_V7
+ select ARMADA_370_XP_IRQ
select ARMADA_XP_CLK
select CPU_PJ4B
select MACH_MVEBU_V7
--
2.6.4
^ permalink raw reply related [flat|nested] 18+ messages in thread
* Re: [PATCH v3 0/6] irqchip: irq-armada-370-xp: generic MSI infrastructure and assorted fixes
2016-02-10 14:46 ` Thomas Petazzoni
@ 2016-02-16 17:49 ` Jason Cooper
-1 siblings, 0 replies; 18+ messages in thread
From: Jason Cooper @ 2016-02-16 17:49 UTC (permalink / raw)
To: Thomas Petazzoni
Cc: Thomas Gleixner, Marc Zyngier, linux-arm-kernel, linux-kernel,
Andrew Lunn, Sebastian Hesselbarth, Gregory Clement
Hey Thomas,
On Wed, Feb 10, 2016 at 03:46:55PM +0100, Thomas Petazzoni wrote:
> This patch series converts the Armada 370/XP irqchip driver (also used
> on Armada 375, 38x and 39x) to the new MSI infrastructure put in place
> by Marc. It doesn't bring any functional difference other than using
> the right, modern, MSI mechanism, which might ultimately allow Marc to
> remove the old way of implementing MSI support.
>
> It has been tested on Armada 38x and Armada XP with an Intel e1000e
> NIC and an Intel IGB NIC, both of which use MSI interrupts.
>
> Note that this patch series depends on the patch series from Marc
> Zyngier for proper operation, which have already been merged in
> tip.git by Thomas Gleixner:
>
> http://git.kernel.org/cgit/linux/kernel/git/tip/tip.git/commit/?id=530cbe100ef7587aa5b5ac3a4b670cda4d50e598
> http://git.kernel.org/cgit/linux/kernel/git/tip/tip.git/commit/?id=14a0db3cdd114da757197193f66786e63649c91e
When based against v4.5-rc1, I encountered:
drivers/irqchip/irq-armada-370-xp.c:584:41: error: 'DOMAIN_BUS_WIRED' undeclared (first use in this function)
Rebased the branch against v4.5-rc2 to pick up:
530cbe100ef7 irqdomain: Allow domain lookup with DOMAIN_BUS_WIRED token
Which builds without warning.
> Thomas Petazzoni (6):
> irqchip: irq-armada-370-xp: add Kconfig option for the driver
> irqchip: irq-armada-370-xp: use the generic MSI infrastructure
> irqchip: irq-armada-370-xp: use PCI_MSI_DOORBELL_START where
> appropriate
> irqchip: irq-armada-370-xp: use shorter names for irq_chip
> irqchip: irq-armada-370-xp: allow allocation of multiple MSIs
> ARM: mvebu: use the ARMADA_370_XP_IRQ option
>
> arch/arm/mach-mvebu/Kconfig | 6 +-
> drivers/irqchip/Kconfig | 6 ++
> drivers/irqchip/Makefile | 2 +-
> drivers/irqchip/irq-armada-370-xp.c | 156 +++++++++++++++---------------------
> 4 files changed, 78 insertions(+), 92 deletions(-)
Whole series applied to irqchip/mvebu which will not be rebased. I'll
only append to it if you send me a patch to add. ;-)
thx,
Jason.
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH v3 0/6] irqchip: irq-armada-370-xp: generic MSI infrastructure and assorted fixes
@ 2016-02-16 17:49 ` Jason Cooper
0 siblings, 0 replies; 18+ messages in thread
From: Jason Cooper @ 2016-02-16 17:49 UTC (permalink / raw)
To: linux-arm-kernel
Hey Thomas,
On Wed, Feb 10, 2016 at 03:46:55PM +0100, Thomas Petazzoni wrote:
> This patch series converts the Armada 370/XP irqchip driver (also used
> on Armada 375, 38x and 39x) to the new MSI infrastructure put in place
> by Marc. It doesn't bring any functional difference other than using
> the right, modern, MSI mechanism, which might ultimately allow Marc to
> remove the old way of implementing MSI support.
>
> It has been tested on Armada 38x and Armada XP with an Intel e1000e
> NIC and an Intel IGB NIC, both of which use MSI interrupts.
>
> Note that this patch series depends on the patch series from Marc
> Zyngier for proper operation, which have already been merged in
> tip.git by Thomas Gleixner:
>
> http://git.kernel.org/cgit/linux/kernel/git/tip/tip.git/commit/?id=530cbe100ef7587aa5b5ac3a4b670cda4d50e598
> http://git.kernel.org/cgit/linux/kernel/git/tip/tip.git/commit/?id=14a0db3cdd114da757197193f66786e63649c91e
When based against v4.5-rc1, I encountered:
drivers/irqchip/irq-armada-370-xp.c:584:41: error: 'DOMAIN_BUS_WIRED' undeclared (first use in this function)
Rebased the branch against v4.5-rc2 to pick up:
530cbe100ef7 irqdomain: Allow domain lookup with DOMAIN_BUS_WIRED token
Which builds without warning.
> Thomas Petazzoni (6):
> irqchip: irq-armada-370-xp: add Kconfig option for the driver
> irqchip: irq-armada-370-xp: use the generic MSI infrastructure
> irqchip: irq-armada-370-xp: use PCI_MSI_DOORBELL_START where
> appropriate
> irqchip: irq-armada-370-xp: use shorter names for irq_chip
> irqchip: irq-armada-370-xp: allow allocation of multiple MSIs
> ARM: mvebu: use the ARMADA_370_XP_IRQ option
>
> arch/arm/mach-mvebu/Kconfig | 6 +-
> drivers/irqchip/Kconfig | 6 ++
> drivers/irqchip/Makefile | 2 +-
> drivers/irqchip/irq-armada-370-xp.c | 156 +++++++++++++++---------------------
> 4 files changed, 78 insertions(+), 92 deletions(-)
Whole series applied to irqchip/mvebu which will not be rebased. I'll
only append to it if you send me a patch to add. ;-)
thx,
Jason.
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH v3 0/6] irqchip: irq-armada-370-xp: generic MSI infrastructure and assorted fixes
2016-02-16 17:49 ` Jason Cooper
@ 2016-02-16 20:09 ` Thomas Petazzoni
-1 siblings, 0 replies; 18+ messages in thread
From: Thomas Petazzoni @ 2016-02-16 20:09 UTC (permalink / raw)
To: Jason Cooper
Cc: Thomas Gleixner, Marc Zyngier, linux-arm-kernel, linux-kernel,
Andrew Lunn, Sebastian Hesselbarth, Gregory Clement
Hello,
On Tue, 16 Feb 2016 17:49:37 +0000, Jason Cooper wrote:
> > Note that this patch series depends on the patch series from Marc
> > Zyngier for proper operation, which have already been merged in
> > tip.git by Thomas Gleixner:
> >
> > http://git.kernel.org/cgit/linux/kernel/git/tip/tip.git/commit/?id=530cbe100ef7587aa5b5ac3a4b670cda4d50e598
> > http://git.kernel.org/cgit/linux/kernel/git/tip/tip.git/commit/?id=14a0db3cdd114da757197193f66786e63649c91e
>
> When based against v4.5-rc1, I encountered:
>
> drivers/irqchip/irq-armada-370-xp.c:584:41: error: 'DOMAIN_BUS_WIRED' undeclared (first use in this function)
>
> Rebased the branch against v4.5-rc2 to pick up:
>
> 530cbe100ef7 irqdomain: Allow domain lookup with DOMAIN_BUS_WIRED token
>
> Which builds without warning.
Indeed. See above where I was mentioning which commits I was depending
on.
> > arch/arm/mach-mvebu/Kconfig | 6 +-
> > drivers/irqchip/Kconfig | 6 ++
> > drivers/irqchip/Makefile | 2 +-
> > drivers/irqchip/irq-armada-370-xp.c | 156 +++++++++++++++---------------------
> > 4 files changed, 78 insertions(+), 92 deletions(-)
>
> Whole series applied to irqchip/mvebu which will not be rebased. I'll
> only append to it if you send me a patch to add. ;-)
Thanks for the merge!
Thomas
--
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH v3 0/6] irqchip: irq-armada-370-xp: generic MSI infrastructure and assorted fixes
@ 2016-02-16 20:09 ` Thomas Petazzoni
0 siblings, 0 replies; 18+ messages in thread
From: Thomas Petazzoni @ 2016-02-16 20:09 UTC (permalink / raw)
To: linux-arm-kernel
Hello,
On Tue, 16 Feb 2016 17:49:37 +0000, Jason Cooper wrote:
> > Note that this patch series depends on the patch series from Marc
> > Zyngier for proper operation, which have already been merged in
> > tip.git by Thomas Gleixner:
> >
> > http://git.kernel.org/cgit/linux/kernel/git/tip/tip.git/commit/?id=530cbe100ef7587aa5b5ac3a4b670cda4d50e598
> > http://git.kernel.org/cgit/linux/kernel/git/tip/tip.git/commit/?id=14a0db3cdd114da757197193f66786e63649c91e
>
> When based against v4.5-rc1, I encountered:
>
> drivers/irqchip/irq-armada-370-xp.c:584:41: error: 'DOMAIN_BUS_WIRED' undeclared (first use in this function)
>
> Rebased the branch against v4.5-rc2 to pick up:
>
> 530cbe100ef7 irqdomain: Allow domain lookup with DOMAIN_BUS_WIRED token
>
> Which builds without warning.
Indeed. See above where I was mentioning which commits I was depending
on.
> > arch/arm/mach-mvebu/Kconfig | 6 +-
> > drivers/irqchip/Kconfig | 6 ++
> > drivers/irqchip/Makefile | 2 +-
> > drivers/irqchip/irq-armada-370-xp.c | 156 +++++++++++++++---------------------
> > 4 files changed, 78 insertions(+), 92 deletions(-)
>
> Whole series applied to irqchip/mvebu which will not be rebased. I'll
> only append to it if you send me a patch to add. ;-)
Thanks for the merge!
Thomas
--
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
^ permalink raw reply [flat|nested] 18+ messages in thread
end of thread, other threads:[~2016-02-16 20:09 UTC | newest]
Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-02-10 14:46 [PATCH v3 0/6] irqchip: irq-armada-370-xp: generic MSI infrastructure and assorted fixes Thomas Petazzoni
2016-02-10 14:46 ` Thomas Petazzoni
2016-02-10 14:46 ` [PATCH v3 1/6] irqchip: irq-armada-370-xp: add Kconfig option for the driver Thomas Petazzoni
2016-02-10 14:46 ` Thomas Petazzoni
2016-02-10 14:46 ` [PATCH v3 2/6] irqchip: irq-armada-370-xp: use the generic MSI infrastructure Thomas Petazzoni
2016-02-10 14:46 ` Thomas Petazzoni
2016-02-10 14:46 ` [PATCH v3 3/6] irqchip: irq-armada-370-xp: use PCI_MSI_DOORBELL_START where appropriate Thomas Petazzoni
2016-02-10 14:46 ` Thomas Petazzoni
2016-02-10 14:46 ` [PATCH v3 4/6] irqchip: irq-armada-370-xp: use shorter names for irq_chip Thomas Petazzoni
2016-02-10 14:46 ` Thomas Petazzoni
2016-02-10 14:47 ` [PATCH v3 5/6] irqchip: irq-armada-370-xp: allow allocation of multiple MSIs Thomas Petazzoni
2016-02-10 14:47 ` Thomas Petazzoni
2016-02-10 14:47 ` [PATCH v3 6/6] ARM: mvebu: use the ARMADA_370_XP_IRQ option Thomas Petazzoni
2016-02-10 14:47 ` Thomas Petazzoni
2016-02-16 17:49 ` [PATCH v3 0/6] irqchip: irq-armada-370-xp: generic MSI infrastructure and assorted fixes Jason Cooper
2016-02-16 17:49 ` Jason Cooper
2016-02-16 20:09 ` Thomas Petazzoni
2016-02-16 20:09 ` Thomas Petazzoni
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.