From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtpout-02.galae.net (smtpout-02.galae.net [185.246.84.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D953938D; Mon, 10 Aug 2026 14:26:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.246.84.56 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786371964; cv=none; b=YzmxqjeEsAy9wJF2P5L4WEC04MyZ+pmWJg4SJlDS36I4xGsLmmkUgKWG8OAYZT+16MvFyCc791XLvrRcj1ipwAHClDiJgKxbV1fM7/aqFWXlomTMYbAILTNYswj+9H/ZOsk/sCHVnHzTN16NrpnrNlSp418rOpzwkz8b/Ea3Us0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786371964; c=relaxed/simple; bh=192a+g3Lk5EobTsbKaqEOhatpCAtWFbKjPR8U9VciAU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=koarXXAdXaYWkrf0fgHO8KMItMTLt1AYGxvGuN7kEnvWmxSQrpYxH1DBJ112bYoKVVMaoU2xTfq8MgRns/fCp7muhm1Rd7KUuUHC2kkjOJiYCxD2RHjLRheMAqnEIAVE5XcyDWZSzCWAmAo608WTWoAYclG53TAHLmIhBBbZceU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=pZ20vcTJ; arc=none smtp.client-ip=185.246.84.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="pZ20vcTJ" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-02.galae.net (Postfix) with ESMTPS id 764FE1A1540; Mon, 10 Aug 2026 14:26:01 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 4AD826033B; Mon, 10 Aug 2026 14:26:01 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 8A05811C4A8B7; Mon, 10 Aug 2026 16:25:58 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1786371960; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=cYLeKozbpmiKqKGEp7Foxa6em3HQlD7wzvGKwnQbhwA=; b=pZ20vcTJqvFjwgJjuO8QF6asRdcG3w2vagbobt51bex154hbN9C2KSit86pJ8HhbBL4Ux5 mvxwR1+1B+vj5IvgM4MqWreLqt3MwYR7yhzaMOwCWy2KBYdYbXINUI2b/dbPTQekor3DpC Qqep8F/7EEDWzdfmtORYKcl+wlLNLmHLTpFgrMlMfO11KGVqr6UX6ocjd9bExNz/256fmQ 87r5PYrdFFzH4G9AELDtGyvhWW1rZPFFGvSUat/NtqEyLvEJpBwfISgudUcDjhHiUhHK68 QyVXvNJB7dGvC59LjTq95Yh9g5qgnb9Dp6HWCrh+mPJqb+4LpdeJgF5+GH/tyA== From: =?utf-8?q?Beno=C3=AEt_Monin?= Date: Mon, 10 Aug 2026 16:25:39 +0200 Subject: [PATCH v2 2/5] irqchip/mips-gic: Fix recursive acquisition of gic_lock in gic_set_affinity() Precedence: bulk X-Mailing-List: linux-mips@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Message-Id: <20260810-sync-gic-counters-v2-2-dfe8b2c376b0@bootlin.com> References: <20260810-sync-gic-counters-v2-0-dfe8b2c376b0@bootlin.com> In-Reply-To: <20260810-sync-gic-counters-v2-0-dfe8b2c376b0@bootlin.com> To: Thomas Bogendoerfer , Daniel Lezcano , Thomas Gleixner , Dragan Mladjenovic , Chao-ying Fu , Aleksandar Rikalo , Paul Burton Cc: Vladimir Kondratiev , Tawfik Bayouk , Gregory CLEMENT , =?utf-8?q?Th=C3=A9o_Lebrun?= , Thomas Petazzoni , linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, =?utf-8?q?Beno=C3=AEt_Monin?= X-Mailer: b4 0.15.2 X-Last-TLS-Session-Version: TLSv1.3 Commit 322a90638768 ("irqchip/mips-gic: Multi-cluster support") made gic_set_affinity() call gic_set_type() when an interrupt's affinity is moved between clusters. gic_set_type() takes gic_lock with raw_spin_lock_irqsave(), but gic_set_affinity() holds gic_lock at that point, so the same raw spinlock is acquired twice, triggering a deadlock. Split gic_set_type() into a gic_set_type_locked() helper that assumes gic_lock is already held. gic_set_type() takes gic_lock and calls the helper, and gic_set_affinity() calls gic_set_type_locked() directly, since it already holds gic_lock. Fixes: 322a90638768 ("irqchip/mips-gic: Multi-cluster support") Signed-off-by: BenoƮt Monin --- drivers/irqchip/irq-mips-gic.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/drivers/irqchip/irq-mips-gic.c b/drivers/irqchip/irq-mips-gic.c index 3b31cbcbed6f..f2ae60d39d66 100644 --- a/drivers/irqchip/irq-mips-gic.c +++ b/drivers/irqchip/irq-mips-gic.c @@ -297,14 +297,14 @@ static void gic_ack_irq(struct irq_data *d) } } -static int gic_set_type(struct irq_data *d, unsigned int type) +static int gic_set_type_locked(struct irq_data *d, unsigned int type) { unsigned int irq, pol, trig, dual; - unsigned long flags; + + lockdep_assert_held(&gic_lock); irq = GIC_HWIRQ_TO_SHARED(d->hwirq); - raw_spin_lock_irqsave(&gic_lock, flags); switch (type & IRQ_TYPE_SENSE_MASK) { case IRQ_TYPE_EDGE_FALLING: pol = GIC_POL_FALLING_EDGE; @@ -351,11 +351,16 @@ static int gic_set_type(struct irq_data *d, unsigned int type) else irq_set_chip_handler_name_locked(d, &gic_level_irq_controller, handle_level_irq, NULL); - raw_spin_unlock_irqrestore(&gic_lock, flags); return 0; } +static int gic_set_type(struct irq_data *d, unsigned int type) +{ + guard(raw_spinlock_irqsave)(&gic_lock); + return gic_set_type_locked(d, type); +} + #ifdef CONFIG_SMP static int gic_set_affinity(struct irq_data *d, const struct cpumask *cpumask, bool force) @@ -407,7 +412,7 @@ static int gic_set_affinity(struct irq_data *d, const struct cpumask *cpumask, * trigger type in the new cluster. */ if (cl != old_cl) - gic_set_type(d, irqd_get_trigger_type(d)); + gic_set_type_locked(d, irqd_get_trigger_type(d)); /* Route the interrupt to its new VP(E) */ if (gic_irq_lock_cluster(d)) { -- 2.55.0