lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250103125926.54203-1-luxu.kernel@bytedance.com>
Date: Fri,  3 Jan 2025 20:59:26 +0800
From: Xu Lu <luxu.kernel@...edance.com>
To: anup@...infault.org,
	tglx@...utronix.de,
	paul.walmsley@...ive.com
Cc: lihangjing@...edance.com,
	xieyongji@...edance.com,
	guojinhui.liam@...edance.com,
	linux-riscv@...ts.infradead.org,
	linux-kernel@...r.kernel.org,
	Xu Lu <luxu.kernel@...edance.com>
Subject: [PATCH] irqchip/riscv-imsic: Support allocating multiple msi-x vectors

This commit modifies alloc and free callback of imsic_base_domain to
support allocating and freeing multiple msi-x vectors at once.

Signed-off-by: Xu Lu <luxu.kernel@...edance.com>
---
 drivers/irqchip/irq-riscv-imsic-platform.c | 54 +++++++++++++---------
 1 file changed, 32 insertions(+), 22 deletions(-)

diff --git a/drivers/irqchip/irq-riscv-imsic-platform.c b/drivers/irqchip/irq-riscv-imsic-platform.c
index c708780e8760..d0ea0eb22e2e 100644
--- a/drivers/irqchip/irq-riscv-imsic-platform.c
+++ b/drivers/irqchip/irq-riscv-imsic-platform.c
@@ -141,35 +141,45 @@ static struct irq_chip imsic_irq_base_chip = {
 				  IRQCHIP_MASK_ON_SUSPEND,
 };
 
+static void imsic_irq_domain_free(struct irq_domain *domain, unsigned int virq,
+				  unsigned int nr_irqs)
+{
+	struct irq_data *d;
+	int i;
+
+	for (i = 0; i < nr_irqs; i++) {
+		d = irq_domain_get_irq_data(domain, virq + i);
+		imsic_vector_free(irq_data_get_irq_chip_data(d));
+	}
+	irq_domain_free_irqs_top(domain, virq, nr_irqs);
+}
+
 static int imsic_irq_domain_alloc(struct irq_domain *domain, unsigned int virq,
 				  unsigned int nr_irqs, void *args)
 {
 	struct imsic_vector *vec;
-
-	/* Multi-MSI is not supported yet. */
-	if (nr_irqs > 1)
-		return -EOPNOTSUPP;
-
-	vec = imsic_vector_alloc(virq, cpu_online_mask);
-	if (!vec)
-		return -ENOSPC;
-
-	irq_domain_set_info(domain, virq, virq, &imsic_irq_base_chip, vec,
-			    handle_simple_irq, NULL, NULL);
-	irq_set_noprobe(virq);
-	irq_set_affinity(virq, cpu_online_mask);
-	irq_data_update_effective_affinity(irq_get_irq_data(virq), cpumask_of(vec->cpu));
+	int i, err;
+
+	for (i = 0; i < nr_irqs; i++) {
+		vec = imsic_vector_alloc(virq + i, cpu_online_mask);
+		if (!vec) {
+			err = -ENOSPC;
+			goto error;
+		}
+
+		irq_domain_set_info(domain, virq + i, virq + i, &imsic_irq_base_chip,
+				    vec, handle_simple_irq, NULL, NULL);
+		irq_set_noprobe(virq + i);
+		irq_set_affinity(virq + i, cpu_online_mask);
+		irq_data_update_effective_affinity(irq_get_irq_data(virq + i),
+						   cpumask_of(vec->cpu));
+	}
 
 	return 0;
-}
-
-static void imsic_irq_domain_free(struct irq_domain *domain, unsigned int virq,
-				  unsigned int nr_irqs)
-{
-	struct irq_data *d = irq_domain_get_irq_data(domain, virq);
 
-	imsic_vector_free(irq_data_get_irq_chip_data(d));
-	irq_domain_free_irqs_parent(domain, virq, nr_irqs);
+error:
+	imsic_irq_domain_free(domain, virq, i);
+	return err;
 }
 
 static int imsic_irq_domain_select(struct irq_domain *domain, struct irq_fwspec *fwspec,
-- 
2.20.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ