From patchwork Mon Apr 24 10:31:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiaxun Yang X-Patchwork-Id: 86985 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2646517vqo; Mon, 24 Apr 2023 03:43:33 -0700 (PDT) X-Google-Smtp-Source: AKy350Y1WLTOsX+wlgsoaJsoEvGg9pzFzT+KG30cDFXBseZVOjiDpEaghBL2QEvQ0eDVbn4M1da/ X-Received: by 2002:a17:90a:ea07:b0:240:d3b7:e850 with SMTP id w7-20020a17090aea0700b00240d3b7e850mr11569493pjy.49.1682333012947; Mon, 24 Apr 2023 03:43:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682333012; cv=none; d=google.com; s=arc-20160816; b=vcGiYXafnX3N6FNZs8JPYmxlix7YIEH24AGeIXb7KtyH8ygIdAtAvYq4LdJrONjQkB CoHRfIhglq7o7o4FxKtp0J/iM7PFSj/wwmahq+u9f279OO+CDeyf5XYiObekyi+vCRlM a9SjR5Pza2bsNHDuZhSybTb0/Hz+rDvpaVC6zSC1VIr3KPEv4f3TKuP1GjmHKBBZqMvj kDcrhxULyiZecvDtMRacCIVrv3GcbVl6JMrGj5634OKhOZYKhb0RB/hPvOfqda+Tlc3t A3KEk2k8Evjc6PpPD3resPP24Pnmx8jQcNKY4pDYHVGFi9lubQFdLFR2pfhV1i3LiAIj 5h1Q== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j17-20020a17090a7e9100b0024bcddfd241si414790pjl.156.2023.04.24.03.43.20; Mon, 24 Apr 2023 03:43:32 -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 S231536AbjDXKck (ORCPT + 99 others); Mon, 24 Apr 2023 06:32:40 -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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1764054021319190171?= X-GMAIL-MSGID: =?utf-8?q?1764054021319190171?= 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 Reviewed-by: Serge Semin --- 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; }