All of lore.kernel.org
 help / color / mirror / Atom feed
From: thomas.petazzoni@free-electrons.com (Thomas Petazzoni)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2 5/6] irqchip: irq-armada-370-xp: allow allocation of multiple MSIs
Date: Wed, 27 Jan 2016 13:56:34 +0100	[thread overview]
Message-ID: <1453899395-3532-6-git-send-email-thomas.petazzoni@free-electrons.com> (raw)
In-Reply-To: <1453899395-3532-1-git-send-email-thomas.petazzoni@free-electrons.com>

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

  parent reply	other threads:[~2016-01-27 12:56 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-27 12:56 [PATCH v2 0/6] irqchip: irq-armada-370-xp: generic MSI infrastructure and assorted fixes Thomas Petazzoni
2016-01-27 12:56 ` [PATCH v2 1/6] irqchip: irq-armada-370-xp: add Kconfig option for the driver Thomas Petazzoni
2016-01-27 12:56 ` [PATCH v2 2/6] irqchip: irq-armada-370-xp: use the generic MSI infrastructure Thomas Petazzoni
2016-01-28 16:24   ` Marc Zyngier
2016-01-27 12:56 ` [PATCH v2 3/6] irqchip: irq-armada-370-xp: use PCI_MSI_DOORBELL_START where appropriate Thomas Petazzoni
2016-01-27 13:39   ` Gregory CLEMENT
2016-01-27 12:56 ` [PATCH v2 4/6] irqchip: irq-armada-370-xp: use shorter names for irq_chip Thomas Petazzoni
2016-01-27 13:20   ` Gregory CLEMENT
2016-01-27 12:56 ` Thomas Petazzoni [this message]
2016-01-27 13:40   ` [PATCH v2 5/6] irqchip: irq-armada-370-xp: allow allocation of multiple MSIs Gregory CLEMENT
2016-01-27 12:56 ` [PATCH v2 6/6] ARM: mvebu: use the ARMADA_370_XP_IRQ option Thomas Petazzoni
2016-01-27 13:28   ` Gregory CLEMENT
2016-02-10 14:00 ` [PATCH v2 0/6] irqchip: irq-armada-370-xp: generic MSI infrastructure and assorted fixes Thomas Petazzoni
2016-02-10 14:08   ` Marc Zyngier
2016-02-10 14:10     ` Thomas Petazzoni
2016-02-10 15:38     ` Jason Cooper
2016-02-10 18:09       ` Gregory CLEMENT
2016-02-10 18:13         ` Jason Cooper

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1453899395-3532-6-git-send-email-thomas.petazzoni@free-electrons.com \
    --to=thomas.petazzoni@free-electrons.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.