Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp956837ybm; Wed, 27 May 2020 12:08:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzSY/Y4utmwZ6DJdhVHy6V0wNbkIkCObBYe+Ysk3WEmR03kwcubBJAqMbQrMXlPX+l0BPk/ X-Received: by 2002:a05:6402:2c3:: with SMTP id b3mr26442169edx.66.1590606522400; Wed, 27 May 2020 12:08:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590606522; cv=none; d=google.com; s=arc-20160816; b=aiib5OZW34GXLPAcgpb6UI0TMV5vytcE7+ribaWwbuwjz/0V+PxsQ1wZtXrN6Q2yE+ 1LClBeAxy7z0znIpPHJMC72fplyfN4R5fOkkPxOxl2B2noSMEAv6j8WR8AKLj+D7Qd91 JMWgxSCcFzt12b1SwwgKUjto0ROGvuMhBvID+YrMHpMOPUzPmG4j0VM6IkbTadL/WvkQ PBoV5jQm5CjsAS4lVgjf5wo+VtWcm5BuqzutI4e/uURXDZkQaWmcpHE/unDP+4TPtKnc Ug3F9uxBoElsR5IXuh9dn3Ou35Ghh1WERk8/7eoljt2FHKIqpmPgFhrSzR+9Z0A0IWye fKqw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=qSgUFPU/lmBJj5c376kcW/aHDA5eHqQfL3OqaeYjnYo=; b=J0YrVHYTZEWgT/6hNq/iaAEKaOgpBMoZIS8uFA430MFTx44vI7J1eAlsoHUtSZwaEv 1ykmZqT3uXwMnuo5Ut91MbpIRNp2N93sWommdBP03C4ZWxxciSPmDWDEoofMcHllywrc SklHPJAIvtsCJoCznbZ3K5CTuB+1MsPymJHMk88GpiIi3uzSDp84RQaY1DAAsPPf+A9r R8eenO0gA4w/sQMQ6fhRppzIl/NOw8iPUqqlMK7pGOGvXxoczBik6MPgorpAq6rHCgs1 Kj797KebTwMjRjaizjxaDXONtmnyL2SyRzZmfRR4/uibAfLhT3J4vpKrKA57V1ragysy VvFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bgdev-pl.20150623.gappssmtp.com header.s=20150623 header.b=ptX7rsY0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a15si2240848edl.138.2020.05.27.12.08.20; Wed, 27 May 2020 12:08:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@bgdev-pl.20150623.gappssmtp.com header.s=20150623 header.b=ptX7rsY0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730654AbgE0QRy (ORCPT + 98 others); Wed, 27 May 2020 12:17:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33100 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727801AbgE0QRx (ORCPT ); Wed, 27 May 2020 12:17:53 -0400 Received: from mail-wr1-x441.google.com (mail-wr1-x441.google.com [IPv6:2a00:1450:4864:20::441]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8BD6BC05BD1E for ; Wed, 27 May 2020 09:17:52 -0700 (PDT) Received: by mail-wr1-x441.google.com with SMTP id t18so10540672wru.6 for ; Wed, 27 May 2020 09:17:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=qSgUFPU/lmBJj5c376kcW/aHDA5eHqQfL3OqaeYjnYo=; b=ptX7rsY0ZtKBP9iNOKmKbnieslpshoIG/AuK/vjmExfbtz91dlVxapurUhIt8TSL2m HToH7PGQncAnPCXVB22Wt5lTZpNNph3feLKP7ck5Hlsc3UkBkIjPa9ik8UcCQqzUbJ+/ 9rLZ+0kpIxzsVKEkFdZGSFY8PWDa0fEm5/nUjbSrO9CCHUYyzjBzFpPrYv4Fedkfg9sf p55JFi3GQ9zxbfrNcP0trL1zs+e7Fk5JpTrCGS3yt/tc4gONsA1umQxkFTirQM9YNDg2 dmgNSyiytQQCRM4GcZhEM+6u74vyWbyZ0VnrSZ8+iN6AJ33YV/9sD8BiZecdK1u1ceNy OOCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=qSgUFPU/lmBJj5c376kcW/aHDA5eHqQfL3OqaeYjnYo=; b=GN6RYmWCB2HFNU/uTKlljUeCt4wI2VGmPHhLUufzU+ydKy8no96jN8bKGRWXhluinA 83+V8hjXy2tHFdbs3xbvFzS07d6XGLYxLO0WzVk0S3amLolPVisFlh0qiSkMBTwM09mD D692rOq/tbvaKYRBrIsQM4gmBkiFGlH/l+HhIIpmR+kOTA0FWn82Sd8+flBls1aJsu5R e04OsshTCd/37zq3dIF68iT9N3XKoUgB7J+rFbE7+E4EW7wvirFHn2NwH7XM2vkBX+Bc VMpM40AEa/SQq0rCqZGmfn0Tz+KjB2AYpaXZ+hzIbO3k9BpzGlilKMbQUMqwFifNa0HA Wb6g== X-Gm-Message-State: AOAM531yMceLrOffvy8s6nX/BP1Tuuai/aX8+Af81JXUupXI6rs+guL3 O6qrYe0VvoSJMqb1R2rDYJK6yw== X-Received: by 2002:adf:e751:: with SMTP id c17mr10340714wrn.134.1590596271251; Wed, 27 May 2020 09:17:51 -0700 (PDT) Received: from localhost.localdomain (lfbn-nic-1-65-232.w2-15.abo.wanadoo.fr. [2.15.156.232]) by smtp.gmail.com with ESMTPSA id w12sm3364038wmk.12.2020.05.27.09.17.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 May 2020 09:17:50 -0700 (PDT) From: Bartosz Golaszewski To: Thomas Gleixner , Jason Cooper , Marc Zyngier , Matthias Brugger Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, Fabien Parent , Stephane Le Provost , Pedro Tsai , Andrew Perepech , Bartosz Golaszewski Subject: [PATCH] irqchip/irq-mtk-sysirq: drop unnecessary spinlock Date: Wed, 27 May 2020 18:17:43 +0200 Message-Id: <20200527161743.15972-1-brgl@bgdev.pl> X-Mailer: git-send-email 2.25.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Bartosz Golaszewski This driver takes a regular spinlock when a raw spinlock is already taken which results in the following lockdep splat: ============================= [ BUG: Invalid wait context ] 5.7.0-rc6-02446-gb9827c0a9fe7-dirty #1 Not tainted ----------------------------- swapper/0/0 is trying to lock: ffffff800303b798 (&chip_data->lock){....}-{3:3}, at: mtk_sysirq_set_type+0x48/0xc0 other info that might help us debug this: context-{5:5} 2 locks held by swapper/0/0: #0: ffffff800302ee68 (&desc->request_mutex){....}-{4:4}, at: __setup_irq+0xc4/0x8a0 #1: ffffff800302ecf0 (&irq_desc_lock_class){....}-{2:2}, at: __setup_irq+0xe4/0x8a0 stack backtrace: CPU: 0 PID: 0 Comm: swapper/0 Not tainted 5.7.0-rc6-02446-gb9827c0a9fe7-dirty #1 Hardware name: Pumpkin MT8516 (DT) Call trace: dump_backtrace+0x0/0x180 show_stack+0x14/0x20 dump_stack+0xd0/0x118 __lock_acquire+0x8c8/0x2270 lock_acquire+0xf8/0x470 _raw_spin_lock_irqsave+0x50/0x78 mtk_sysirq_set_type+0x48/0xc0 __irq_set_trigger+0x58/0x170 __setup_irq+0x420/0x8a0 request_threaded_irq+0xd8/0x190 timer_of_init+0x1e8/0x2c4 mtk_gpt_init+0x5c/0x1dc timer_probe+0x74/0xf4 time_init+0x14/0x44 start_kernel+0x394/0x4f0 We don't need the spinlock here - the irq_set_type() callback is always called with the irq_desc->lock taken. This removes the spinlock entirely. Signed-off-by: Bartosz Golaszewski --- drivers/irqchip/irq-mtk-sysirq.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/drivers/irqchip/irq-mtk-sysirq.c b/drivers/irqchip/irq-mtk-sysirq.c index 73eae5966a40..da2fc4809222 100644 --- a/drivers/irqchip/irq-mtk-sysirq.c +++ b/drivers/irqchip/irq-mtk-sysirq.c @@ -12,10 +12,8 @@ #include #include #include -#include struct mtk_sysirq_chip_data { - spinlock_t lock; u32 nr_intpol_bases; void __iomem **intpol_bases; u32 *intpol_words; @@ -30,14 +28,12 @@ static int mtk_sysirq_set_type(struct irq_data *data, unsigned int type) u8 intpol_idx = chip_data->intpol_idx[hwirq]; void __iomem *base; u32 offset, reg_index, value; - unsigned long flags; int ret; base = chip_data->intpol_bases[intpol_idx]; reg_index = chip_data->which_word[hwirq]; offset = hwirq & 0x1f; - spin_lock_irqsave(&chip_data->lock, flags); value = readl_relaxed(base + reg_index * 4); if (type == IRQ_TYPE_LEVEL_LOW || type == IRQ_TYPE_EDGE_FALLING) { if (type == IRQ_TYPE_LEVEL_LOW) @@ -53,7 +49,6 @@ static int mtk_sysirq_set_type(struct irq_data *data, unsigned int type) data = data->parent_data; ret = data->chip->irq_set_type(data, type); - spin_unlock_irqrestore(&chip_data->lock, flags); return ret; } @@ -212,7 +207,6 @@ static int __init mtk_sysirq_of_init(struct device_node *node, ret = -ENOMEM; goto out_free_which_word; } - spin_lock_init(&chip_data->lock); return 0; -- 2.25.0