Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp5391521rwr; Mon, 24 Apr 2023 03:33:55 -0700 (PDT) X-Google-Smtp-Source: AKy350aIjKXMRy0Xmhi9kfLGb5ZacN/ZUlF0m7WRtd/dyVn0Dh5zcoTXgVEE3/neVh95ZNdpM65R X-Received: by 2002:a17:903:22ce:b0:1a6:74ce:9bed with SMTP id y14-20020a17090322ce00b001a674ce9bedmr17713934plg.46.1682332434951; Mon, 24 Apr 2023 03:33:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682332434; cv=none; d=google.com; s=arc-20160816; b=LINa8Vi0T4s793BYf7eAuvshV0xDX0sFYyxtxkkN3YP6sTiZAYt/ZNdqEOLOoQVo04 lxN1XRCRdRklH9SW5ZjAdt5OjlTNqKRKrLQxemBnTG+568Pa8uiFAIac/xw9vO45wNXg xcHPC+LNV+TF/0dbZurhLCjidtrjMr7XqBugPoRI9LCBm1K0uUFMcWmatWIScD9Vr+yD WQ0mArIcDAC7yMBc9GoyxaxeNNRQsX1cZN/VHLHMnBol6syfQannfur+2lq2JGDbYZuu Xcpkn3MC0XhqdXpN6b2qKBkSSgSKk81a7a8OoS/+niKHX+yLDhkWkMbs62JybYej9ufb OnOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :feedback-id:dkim-signature:dkim-signature; bh=EPSLnlfkuPGroG+yuKCSOFSwJ5aB9Wh0nx281+ahLCM=; b=m3yLa1XBt8Q/zfiyjPbyKq6tEpPp/rwcBBwVjehElOAOaza8PK+dddbgqAqFIlhfM1 txRSqFlec6ydNzeKJGnJU/KVnaN6VSzWSPEB4elQO+uzfHggEPcyenTbrVaGwbGtvk6q 18B+OGME6ocOEys7SkVK7JAN70BwEt8fbB/DOvao17cG0d4Vib0ofClbhFUEsP1HCMw6 +UMQK/RbmSv64MpCXhiEyAtqvapgxPobPCZ3Z8SqH9Zpp2B1Ri1RRnihdMpdfTORMkri XqoZuk4sCG5exlZdq5g0yydMgbC/hOKN3n7DAj3AEFNgsYxL4bJfyTJLpMU7FwjZG/ky W1RQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@flygoat.com header.s=fm1 header.b=OBF4z2lA; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=AiWEEi8z; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=flygoat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i7-20020a170902c94700b001a96467aa63si4846546pla.559.2023.04.24.03.33.41; Mon, 24 Apr 2023 03:33:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@flygoat.com header.s=fm1 header.b=OBF4z2lA; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=AiWEEi8z; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=flygoat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231504AbjDXKcj (ORCPT + 99 others); Mon, 24 Apr 2023 06:32:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55192 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230152AbjDXKc2 (ORCPT ); Mon, 24 Apr 2023 06:32:28 -0400 Received: from wout3-smtp.messagingengine.com (wout3-smtp.messagingengine.com [64.147.123.19]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D5B3818C; Mon, 24 Apr 2023 03:32:26 -0700 (PDT) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.west.internal (Postfix) with ESMTP id D9E7532000D7; Mon, 24 Apr 2023 06:32:25 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Mon, 24 Apr 2023 06:32:26 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=flygoat.com; h= cc:cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm1; t=1682332345; x= 1682418745; bh=EPSLnlfkuPGroG+yuKCSOFSwJ5aB9Wh0nx281+ahLCM=; b=O BF4z2lAFMtSb37GAWIwTr//OaFyy/pwpaLh5ROUi2VCthMCGRnEBn4jiFuIgR3Gp bFXTyajAlwM8UZkj8vSBb/8PqmegusMYWCy7c9OyU2vsF9WUaURPH54bvz88Hhkk xbvbdgvUcmmJ431RZ+NDSG+18MkXhSIclomQt+/gjL5W+dgBywMRpPg5Yesn3pZy C+n66Od8qCv4t8uhh7qv9Ge+KdW/P4RvnJPk+353AhbT9PlSc1a2lPTupxn0xvXi wHaJOntTXI8pSDOGRmXjax3/2ILwfAs8ZBuI/nAUUGeV0vKU1EBAczI/6SwtucB4 vFPtF9NzdBbpo5f06kwXQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1682332345; x= 1682418745; bh=EPSLnlfkuPGroG+yuKCSOFSwJ5aB9Wh0nx281+ahLCM=; b=A iWEEi8zcR7RM4XGa2JJVYQHxnml6vZ2A9h+5ZI9GTp+K0mtNL6eJOSZBIVL8o86G BurzmHR4xFNROXkXAh9BXjNuqTwoVcrpjxADMEleYsDIhTz95Klg8nczVmDxx1eP lpX56APR9r9eppBGKbdfXJAvuodSMwOSWiUF+UoA1OapV6UtTaRteZPGWHGjBFHp d9644qkXKxhTiN3DSfQqpwMeF/UTfAMaqGfS1x3rXuuCgdscrCpH7cngn8rBc8TZ R3AHwg6bZa5szESeoVf9HkWjLZHzWZiUbx3cYANjtvOmyhKOj9UPXiCg5+L9YduP kKRRytXIGsDdHo80yVM7Q== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrfedutddgvdelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvfevufffkffojghfggfgsedtke ertdertddtnecuhfhrohhmpeflihgrgihunhcujggrnhhguceojhhirgiguhhnrdihrghn ghesfhhlhihgohgrthdrtghomheqnecuggftrfgrthhtvghrnhepfeeludefheegvdeuvd dvgeekgfdvtdettdelieeihfegtedugeekhfdvhfejfedtnecuvehluhhsthgvrhfuihii vgeptdenucfrrghrrghmpehmrghilhhfrhhomhepjhhirgiguhhnrdihrghnghesfhhlhi hgohgrthdrtghomh X-ME-Proxy: Feedback-ID: ifd894703:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 24 Apr 2023 06:32:24 -0400 (EDT) From: Jiaxun Yang To: maz@kernel.org Cc: tsbogend@alpha.franken.de, fancer.lancer@gmail.com, tglx@linutronix.de, linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, Jiaxun Yang , stable@vger.kernel.org Subject: [PATCH 2/2] irqchip/mips-gic: Use raw spinlock for gic_lock Date: Mon, 24 Apr 2023 11:31:56 +0100 Message-Id: <20230424103156.66753-3-jiaxun.yang@flygoat.com> X-Mailer: git-send-email 2.39.2 (Apple Git-143) In-Reply-To: <20230424103156.66753-1-jiaxun.yang@flygoat.com> References: <20230424103156.66753-1-jiaxun.yang@flygoat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Since we may hold gic_lock in hardirq context, use raw spinlock makes more sense given that it is for low-level interrupt handling routine and the critical section is small. Fixes BUG: [ 0.426106] ============================= [ 0.426257] [ BUG: Invalid wait context ] [ 0.426422] 6.3.0-rc7-next-20230421-dirty #54 Not tainted [ 0.426638] ----------------------------- [ 0.426766] swapper/0/1 is trying to lock: [ 0.426954] ffffffff8104e7b8 (gic_lock){....}-{3:3}, at: gic_set_type+0x30/08 Fixes: 95150ae8b330 ("irqchip: mips-gic: Implement irq_set_type callback") Cc: stable@vger.kernel.org Signed-off-by: Jiaxun Yang --- drivers/irqchip/irq-mips-gic.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/drivers/irqchip/irq-mips-gic.c b/drivers/irqchip/irq-mips-gic.c index b568d55ef7c5..6d5ecc10a870 100644 --- a/drivers/irqchip/irq-mips-gic.c +++ b/drivers/irqchip/irq-mips-gic.c @@ -50,7 +50,7 @@ void __iomem *mips_gic_base; static DEFINE_PER_CPU_READ_MOSTLY(unsigned long[GIC_MAX_LONGS], pcpu_masks); -static DEFINE_SPINLOCK(gic_lock); +static DEFINE_RAW_SPINLOCK(gic_lock); static struct irq_domain *gic_irq_domain; static int gic_shared_intrs; static unsigned int gic_cpu_pin; @@ -210,7 +210,7 @@ static int gic_set_type(struct irq_data *d, unsigned int type) irq = GIC_HWIRQ_TO_SHARED(d->hwirq); - spin_lock_irqsave(&gic_lock, flags); + raw_spin_lock_irqsave(&gic_lock, flags); switch (type & IRQ_TYPE_SENSE_MASK) { case IRQ_TYPE_EDGE_FALLING: pol = GIC_POL_FALLING_EDGE; @@ -250,7 +250,7 @@ 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); - spin_unlock_irqrestore(&gic_lock, flags); + raw_spin_unlock_irqrestore(&gic_lock, flags); return 0; } @@ -268,7 +268,7 @@ static int gic_set_affinity(struct irq_data *d, const struct cpumask *cpumask, return -EINVAL; /* Assumption : cpumask refers to a single CPU */ - spin_lock_irqsave(&gic_lock, flags); + raw_spin_lock_irqsave(&gic_lock, flags); /* Re-route this IRQ */ write_gic_map_vp(irq, BIT(mips_cm_vp_id(cpu))); @@ -279,7 +279,7 @@ static int gic_set_affinity(struct irq_data *d, const struct cpumask *cpumask, set_bit(irq, per_cpu_ptr(pcpu_masks, cpu)); irq_data_update_effective_affinity(d, cpumask_of(cpu)); - spin_unlock_irqrestore(&gic_lock, flags); + raw_spin_unlock_irqrestore(&gic_lock, flags); return IRQ_SET_MASK_OK; } @@ -357,12 +357,12 @@ static void gic_mask_local_irq_all_vpes(struct irq_data *d) cd = irq_data_get_irq_chip_data(d); cd->mask = false; - spin_lock_irqsave(&gic_lock, flags); + raw_spin_lock_irqsave(&gic_lock, flags); for_each_online_cpu(cpu) { write_gic_vl_other(mips_cm_vp_id(cpu)); write_gic_vo_rmask(BIT(intr)); } - spin_unlock_irqrestore(&gic_lock, flags); + raw_spin_unlock_irqrestore(&gic_lock, flags); } static void gic_unmask_local_irq_all_vpes(struct irq_data *d) @@ -375,12 +375,12 @@ static void gic_unmask_local_irq_all_vpes(struct irq_data *d) cd = irq_data_get_irq_chip_data(d); cd->mask = true; - spin_lock_irqsave(&gic_lock, flags); + raw_spin_lock_irqsave(&gic_lock, flags); for_each_online_cpu(cpu) { write_gic_vl_other(mips_cm_vp_id(cpu)); write_gic_vo_smask(BIT(intr)); } - spin_unlock_irqrestore(&gic_lock, flags); + raw_spin_unlock_irqrestore(&gic_lock, flags); } static void gic_all_vpes_irq_cpu_online(void) @@ -393,7 +393,7 @@ static void gic_all_vpes_irq_cpu_online(void) unsigned long flags; int i; - spin_lock_irqsave(&gic_lock, flags); + raw_spin_lock_irqsave(&gic_lock, flags); for (i = 0; i < ARRAY_SIZE(local_intrs); i++) { unsigned int intr = local_intrs[i]; @@ -407,7 +407,7 @@ static void gic_all_vpes_irq_cpu_online(void) write_gic_vl_smask(BIT(intr)); } - spin_unlock_irqrestore(&gic_lock, flags); + raw_spin_unlock_irqrestore(&gic_lock, flags); } static struct irq_chip gic_all_vpes_local_irq_controller = { @@ -437,11 +437,11 @@ static int gic_shared_irq_domain_map(struct irq_domain *d, unsigned int virq, data = irq_get_irq_data(virq); - spin_lock_irqsave(&gic_lock, flags); + raw_spin_lock_irqsave(&gic_lock, flags); write_gic_map_pin(intr, GIC_MAP_PIN_MAP_TO_PIN | gic_cpu_pin); write_gic_map_vp(intr, BIT(mips_cm_vp_id(cpu))); irq_data_update_effective_affinity(data, cpumask_of(cpu)); - spin_unlock_irqrestore(&gic_lock, flags); + raw_spin_unlock_irqrestore(&gic_lock, flags); return 0; } @@ -533,12 +533,12 @@ static int gic_irq_domain_map(struct irq_domain *d, unsigned int virq, if (!gic_local_irq_is_routable(intr)) return -EPERM; - spin_lock_irqsave(&gic_lock, flags); + raw_spin_lock_irqsave(&gic_lock, flags); for_each_online_cpu(cpu) { write_gic_vl_other(mips_cm_vp_id(cpu)); write_gic_vo_map(mips_gic_vx_map_reg(intr), map); } - spin_unlock_irqrestore(&gic_lock, flags); + raw_spin_unlock_irqrestore(&gic_lock, flags); return 0; } -- 2.34.1