All of lore.kernel.org
 help / color / mirror / Atom feed
* FAILED: patch "[PATCH] irqdomain: Refactor __irq_domain_alloc_irqs()" failed to apply to 5.15-stable tree
@ 2023-03-06 18:48 gregkh
  2023-03-13 11:19 ` Johan Hovold
  0 siblings, 1 reply; 4+ messages in thread
From: gregkh @ 2023-03-06 18:48 UTC (permalink / raw)
  To: johan+linaro, hsinyi, mark-pk.tsai, maz; +Cc: stable


The patch below does not apply to the 5.15-stable tree.
If someone wants it applied there, or to any other stable or longterm
tree, then please email the backport, including the original git commit
id to <stable@vger.kernel.org>.

To reproduce the conflict and resubmit, you may use the following commands:

git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-5.15.y
git checkout FETCH_HEAD
git cherry-pick -x d55f7f4c58c07beb5050a834bf57ae2ede599c7e
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<stable@vger.kernel.org>' --in-reply-to '1678128515101149@kroah.com' --subject-prefix 'PATCH 5.15.y' HEAD^..

Possible dependencies:

d55f7f4c58c0 ("irqdomain: Refactor __irq_domain_alloc_irqs()")

thanks,

greg k-h

------------------ original commit in Linus's tree ------------------

From d55f7f4c58c07beb5050a834bf57ae2ede599c7e Mon Sep 17 00:00:00 2001
From: Johan Hovold <johan+linaro@kernel.org>
Date: Mon, 13 Feb 2023 11:42:47 +0100
Subject: [PATCH] irqdomain: Refactor __irq_domain_alloc_irqs()

Refactor __irq_domain_alloc_irqs() so that it can be called internally
while holding the irq_domain_mutex.

This will be used to fix a shared-interrupt mapping race, hence the
Fixes tag.

Fixes: b62b2cf5759b ("irqdomain: Fix handling of type settings for existing mappings")
Cc: stable@vger.kernel.org      # 4.8
Tested-by: Hsin-Yi Wang <hsinyi@chromium.org>
Tested-by: Mark-PK Tsai <mark-pk.tsai@mediatek.com>
Signed-off-by: Johan Hovold <johan+linaro@kernel.org>
Signed-off-by: Marc Zyngier <maz@kernel.org>
Link: https://lore.kernel.org/r/20230213104302.17307-6-johan+linaro@kernel.org

diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c
index 9f95047e4bc7..78fb4800c0d2 100644
--- a/kernel/irq/irqdomain.c
+++ b/kernel/irq/irqdomain.c
@@ -1441,40 +1441,12 @@ int irq_domain_alloc_irqs_hierarchy(struct irq_domain *domain,
 	return domain->ops->alloc(domain, irq_base, nr_irqs, arg);
 }
 
-/**
- * __irq_domain_alloc_irqs - Allocate IRQs from domain
- * @domain:	domain to allocate from
- * @irq_base:	allocate specified IRQ number if irq_base >= 0
- * @nr_irqs:	number of IRQs to allocate
- * @node:	NUMA node id for memory allocation
- * @arg:	domain specific argument
- * @realloc:	IRQ descriptors have already been allocated if true
- * @affinity:	Optional irq affinity mask for multiqueue devices
- *
- * Allocate IRQ numbers and initialized all data structures to support
- * hierarchy IRQ domains.
- * Parameter @realloc is mainly to support legacy IRQs.
- * Returns error code or allocated IRQ number
- *
- * The whole process to setup an IRQ has been split into two steps.
- * The first step, __irq_domain_alloc_irqs(), is to allocate IRQ
- * descriptor and required hardware resources. The second step,
- * irq_domain_activate_irq(), is to program the hardware with preallocated
- * resources. In this way, it's easier to rollback when failing to
- * allocate resources.
- */
-int __irq_domain_alloc_irqs(struct irq_domain *domain, int irq_base,
-			    unsigned int nr_irqs, int node, void *arg,
-			    bool realloc, const struct irq_affinity_desc *affinity)
+static int irq_domain_alloc_irqs_locked(struct irq_domain *domain, int irq_base,
+					unsigned int nr_irqs, int node, void *arg,
+					bool realloc, const struct irq_affinity_desc *affinity)
 {
 	int i, ret, virq;
 
-	if (domain == NULL) {
-		domain = irq_default_domain;
-		if (WARN(!domain, "domain is NULL; cannot allocate IRQ\n"))
-			return -EINVAL;
-	}
-
 	if (realloc && irq_base >= 0) {
 		virq = irq_base;
 	} else {
@@ -1493,24 +1465,18 @@ int __irq_domain_alloc_irqs(struct irq_domain *domain, int irq_base,
 		goto out_free_desc;
 	}
 
-	mutex_lock(&irq_domain_mutex);
 	ret = irq_domain_alloc_irqs_hierarchy(domain, virq, nr_irqs, arg);
-	if (ret < 0) {
-		mutex_unlock(&irq_domain_mutex);
+	if (ret < 0)
 		goto out_free_irq_data;
-	}
 
 	for (i = 0; i < nr_irqs; i++) {
 		ret = irq_domain_trim_hierarchy(virq + i);
-		if (ret) {
-			mutex_unlock(&irq_domain_mutex);
+		if (ret)
 			goto out_free_irq_data;
-		}
 	}
-	
+
 	for (i = 0; i < nr_irqs; i++)
 		irq_domain_insert_irq(virq + i);
-	mutex_unlock(&irq_domain_mutex);
 
 	return virq;
 
@@ -1520,6 +1486,48 @@ int __irq_domain_alloc_irqs(struct irq_domain *domain, int irq_base,
 	irq_free_descs(virq, nr_irqs);
 	return ret;
 }
+
+/**
+ * __irq_domain_alloc_irqs - Allocate IRQs from domain
+ * @domain:	domain to allocate from
+ * @irq_base:	allocate specified IRQ number if irq_base >= 0
+ * @nr_irqs:	number of IRQs to allocate
+ * @node:	NUMA node id for memory allocation
+ * @arg:	domain specific argument
+ * @realloc:	IRQ descriptors have already been allocated if true
+ * @affinity:	Optional irq affinity mask for multiqueue devices
+ *
+ * Allocate IRQ numbers and initialized all data structures to support
+ * hierarchy IRQ domains.
+ * Parameter @realloc is mainly to support legacy IRQs.
+ * Returns error code or allocated IRQ number
+ *
+ * The whole process to setup an IRQ has been split into two steps.
+ * The first step, __irq_domain_alloc_irqs(), is to allocate IRQ
+ * descriptor and required hardware resources. The second step,
+ * irq_domain_activate_irq(), is to program the hardware with preallocated
+ * resources. In this way, it's easier to rollback when failing to
+ * allocate resources.
+ */
+int __irq_domain_alloc_irqs(struct irq_domain *domain, int irq_base,
+			    unsigned int nr_irqs, int node, void *arg,
+			    bool realloc, const struct irq_affinity_desc *affinity)
+{
+	int ret;
+
+	if (domain == NULL) {
+		domain = irq_default_domain;
+		if (WARN(!domain, "domain is NULL; cannot allocate IRQ\n"))
+			return -EINVAL;
+	}
+
+	mutex_lock(&irq_domain_mutex);
+	ret = irq_domain_alloc_irqs_locked(domain, irq_base, nr_irqs, node, arg,
+					   realloc, affinity);
+	mutex_unlock(&irq_domain_mutex);
+
+	return ret;
+}
 EXPORT_SYMBOL_GPL(__irq_domain_alloc_irqs);
 
 /* The irq_data was moved, fix the revmap to refer to the new location */


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: FAILED: patch "[PATCH] irqdomain: Refactor __irq_domain_alloc_irqs()" failed to apply to 5.15-stable tree
  2023-03-06 18:48 FAILED: patch "[PATCH] irqdomain: Refactor __irq_domain_alloc_irqs()" failed to apply to 5.15-stable tree gregkh
@ 2023-03-13 11:19 ` Johan Hovold
  2023-03-13 11:23   ` Greg KH
  0 siblings, 1 reply; 4+ messages in thread
From: Johan Hovold @ 2023-03-13 11:19 UTC (permalink / raw)
  To: gregkh; +Cc: johan+linaro, hsinyi, mark-pk.tsai, maz, stable

On Mon, Mar 06, 2023 at 07:48:35PM +0100, Greg Kroah-Hartman wrote:
> 
> The patch below does not apply to the 5.15-stable tree.
> If someone wants it applied there, or to any other stable or longterm
> tree, then please email the backport, including the original git commit
> id to <stable@vger.kernel.org>.
> 
> To reproduce the conflict and resubmit, you may use the following commands:
> 
> git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-5.15.y
> git checkout FETCH_HEAD
> git cherry-pick -x d55f7f4c58c07beb5050a834bf57ae2ede599c7e
> # <resolve conflicts, build, test, etc.>
> git commit -s
> git send-email --to '<stable@vger.kernel.org>' --in-reply-to '1678128515101149@kroah.com' --subject-prefix 'PATCH 5.15.y' HEAD^..
> 
> Possible dependencies:
> 
> d55f7f4c58c0 ("irqdomain: Refactor __irq_domain_alloc_irqs()")

The below commit applies fine to 5.15.y. Could you try cherry-picking it
again?

Johan
 
> ------------------ original commit in Linus's tree ------------------
> 
> From d55f7f4c58c07beb5050a834bf57ae2ede599c7e Mon Sep 17 00:00:00 2001
> From: Johan Hovold <johan+linaro@kernel.org>
> Date: Mon, 13 Feb 2023 11:42:47 +0100
> Subject: [PATCH] irqdomain: Refactor __irq_domain_alloc_irqs()
> 
> Refactor __irq_domain_alloc_irqs() so that it can be called internally
> while holding the irq_domain_mutex.
> 
> This will be used to fix a shared-interrupt mapping race, hence the
> Fixes tag.
> 
> Fixes: b62b2cf5759b ("irqdomain: Fix handling of type settings for existing mappings")
> Cc: stable@vger.kernel.org      # 4.8
> Tested-by: Hsin-Yi Wang <hsinyi@chromium.org>
> Tested-by: Mark-PK Tsai <mark-pk.tsai@mediatek.com>
> Signed-off-by: Johan Hovold <johan+linaro@kernel.org>
> Signed-off-by: Marc Zyngier <maz@kernel.org>
> Link: https://lore.kernel.org/r/20230213104302.17307-6-johan+linaro@kernel.org

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: FAILED: patch "[PATCH] irqdomain: Refactor __irq_domain_alloc_irqs()" failed to apply to 5.15-stable tree
  2023-03-13 11:19 ` Johan Hovold
@ 2023-03-13 11:23   ` Greg KH
  2023-03-13 12:03     ` Johan Hovold
  0 siblings, 1 reply; 4+ messages in thread
From: Greg KH @ 2023-03-13 11:23 UTC (permalink / raw)
  To: Johan Hovold; +Cc: johan+linaro, hsinyi, mark-pk.tsai, maz, stable

On Mon, Mar 13, 2023 at 12:19:59PM +0100, Johan Hovold wrote:
> On Mon, Mar 06, 2023 at 07:48:35PM +0100, Greg Kroah-Hartman wrote:
> > 
> > The patch below does not apply to the 5.15-stable tree.
> > If someone wants it applied there, or to any other stable or longterm
> > tree, then please email the backport, including the original git commit
> > id to <stable@vger.kernel.org>.
> > 
> > To reproduce the conflict and resubmit, you may use the following commands:
> > 
> > git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-5.15.y
> > git checkout FETCH_HEAD
> > git cherry-pick -x d55f7f4c58c07beb5050a834bf57ae2ede599c7e
> > # <resolve conflicts, build, test, etc.>
> > git commit -s
> > git send-email --to '<stable@vger.kernel.org>' --in-reply-to '1678128515101149@kroah.com' --subject-prefix 'PATCH 5.15.y' HEAD^..
> > 
> > Possible dependencies:
> > 
> > d55f7f4c58c0 ("irqdomain: Refactor __irq_domain_alloc_irqs()")
> 
> The below commit applies fine to 5.15.y. Could you try cherry-picking it
> again?

patching file kernel/irq/irqdomain.c
Hunk #1 succeeded at 1464 (offset 23 lines).
Hunk #2 succeeded at 1488 (offset 23 lines).
Hunk #3 FAILED at 1486.
1 out of 3 hunks FAILED -- rejects in file kernel/irq/irqdomain.c

And doesn't look to apply properly as the EXPORT_SYMBOL_GPL(... line is
not in 5.15.y

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: FAILED: patch "[PATCH] irqdomain: Refactor __irq_domain_alloc_irqs()" failed to apply to 5.15-stable tree
  2023-03-13 11:23   ` Greg KH
@ 2023-03-13 12:03     ` Johan Hovold
  0 siblings, 0 replies; 4+ messages in thread
From: Johan Hovold @ 2023-03-13 12:03 UTC (permalink / raw)
  To: Greg KH; +Cc: johan+linaro, hsinyi, mark-pk.tsai, maz, stable

On Mon, Mar 13, 2023 at 12:23:42PM +0100, Greg Kroah-Hartman wrote:
> On Mon, Mar 13, 2023 at 12:19:59PM +0100, Johan Hovold wrote:
> > On Mon, Mar 06, 2023 at 07:48:35PM +0100, Greg Kroah-Hartman wrote:
> > > 
> > > The patch below does not apply to the 5.15-stable tree.
> > > If someone wants it applied there, or to any other stable or longterm
> > > tree, then please email the backport, including the original git commit
> > > id to <stable@vger.kernel.org>.
> > > 
> > > To reproduce the conflict and resubmit, you may use the following commands:
> > > 
> > > git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-5.15.y
> > > git checkout FETCH_HEAD
> > > git cherry-pick -x d55f7f4c58c07beb5050a834bf57ae2ede599c7e
> > > # <resolve conflicts, build, test, etc.>
> > > git commit -s
> > > git send-email --to '<stable@vger.kernel.org>' --in-reply-to '1678128515101149@kroah.com' --subject-prefix 'PATCH 5.15.y' HEAD^..
> > > 
> > > Possible dependencies:
> > > 
> > > d55f7f4c58c0 ("irqdomain: Refactor __irq_domain_alloc_irqs()")
> > 
> > The below commit applies fine to 5.15.y. Could you try cherry-picking it
> > again?
> 
> patching file kernel/irq/irqdomain.c
> Hunk #1 succeeded at 1464 (offset 23 lines).
> Hunk #2 succeeded at 1488 (offset 23 lines).
> Hunk #3 FAILED at 1486.
> 1 out of 3 hunks FAILED -- rejects in file kernel/irq/irqdomain.c
> 
> And doesn't look to apply properly as the EXPORT_SYMBOL_GPL(... line is
> not in 5.15.y

Ok, I only tried cherry picking which worked fine. I've posted a
backport of this one and the follow-on fix now.

They should be applied in order to avoid a build failure so you should
drop the second patch which you already applied ("irqdomain: Fix
mapping-creation race") in favour of that series.

Johan

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-03-13 12:02 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-03-06 18:48 FAILED: patch "[PATCH] irqdomain: Refactor __irq_domain_alloc_irqs()" failed to apply to 5.15-stable tree gregkh
2023-03-13 11:19 ` Johan Hovold
2023-03-13 11:23   ` Greg KH
2023-03-13 12:03     ` Johan Hovold

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.