Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp629919pxb; Thu, 21 Apr 2022 07:11:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzj1/ryBelmuR8rKkmA2ncOIZLrGJUuz56976OElWBQv1h6rILcTM6UH7f3A/VcqPqz1GHS X-Received: by 2002:a17:90a:a58c:b0:1c9:bc35:6ed9 with SMTP id b12-20020a17090aa58c00b001c9bc356ed9mr10489703pjq.146.1650550309206; Thu, 21 Apr 2022 07:11:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650550309; cv=none; d=google.com; s=arc-20160816; b=Jdd1Nzozyy7E94Cvd5CtoZtFSOPuS7mAEf//SIMWfL6jx4kSKXW4f6QdJOlISffr5A Y2xyk1qKLEFwEx/p3HrRvb5pGHNvce3qe5Jiry+MG91fff3RLSLlVQWqY5GQOvDDirVD HhTkLxMh+b2iQocfDULMTFVNvtxhkgF0lrHR5JEwTo2MyY94k0LV5jB6Ri+qcCwy+aNI Mcfb3kQifGLK38tT5NcSsD50UIztRAz2jErSGCU2KKWdiLlDnxhYSQHa6Z45ouR2LeX6 ZZNKdakzGJLsi9LQ5Xuda4i5A2lsi2srFB4c0vsZYcCO0pWTkG9QQdbpyB2UPcYgwQJA zFqQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=b0FdhFvoto3cfbTufYpeHPpDSicSfoYk0f7qMia8Bdg=; b=apN5ZFrj56Vn+EnBT+7/4WO9Wzfz/sIE5DIDIiXfhDj6IypkQ3CeQzGQxm0S/X3DHY VjUxpfxI0GhBtKZtlmdsArit5TxGucI4hMnCDR+9FSvckK0MTI2EdP9V1xvDUn6tsjTA Cq8w0iiUiv3du8RdHCeig1J2bkXET7bUPIMRmL3PpvTv15Aiu9kVvi6tcjLegKb0//IV XmIuKAiUxAyuKB12h/9Ptdu0XgXR3jHZubJ9GFnlkGf5cWYuqpnO3BOnm78hJm9sB1Pt jckwfBdx/O/VozGOASgWQ1dLaLv9xj6e5iQv40SJ0ItGq7scfjC7d4KcbNaluiGyAgzu 1jxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=zBnm4d3b; 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=linaro.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i16-20020a17090332d000b001569d19531fsi1249555plr.588.2022.04.21.07.11.26; Thu, 21 Apr 2022 07:11:49 -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=@linaro.org header.s=google header.b=zBnm4d3b; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1357680AbiDSWAx (ORCPT + 99 others); Tue, 19 Apr 2022 18:00:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49630 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232898AbiDSWAv (ORCPT ); Tue, 19 Apr 2022 18:00:51 -0400 Received: from mail-yw1-x112d.google.com (mail-yw1-x112d.google.com [IPv6:2607:f8b0:4864:20::112d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D040B40A35 for ; Tue, 19 Apr 2022 14:58:07 -0700 (PDT) Received: by mail-yw1-x112d.google.com with SMTP id 00721157ae682-2eba37104a2so188313157b3.0 for ; Tue, 19 Apr 2022 14:58:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=b0FdhFvoto3cfbTufYpeHPpDSicSfoYk0f7qMia8Bdg=; b=zBnm4d3bVKW2b5jnvekPM/eQx3z9hsp5xqRTJPjXSKoWx8tWLqOEJh6KYbJG2wb69H p4hmQrXPrxhENGRIm+ntF1+pxpZ4NKRG2Fixd6R6prRK2orJSD+9XNUKjFrlgtrRdebx MgnhSvb97qdcRwKYnD3JSdQDYXIPNWyT3PuMkmXZq2eSGoECCqUdBAzywbMwK6WD7kpD 2iUevzz1mkSflSKQ7deupPU/mMDZ5MvOVa40AFsNnnUc0TznAVIg593TmguN3uGP2GMa zzkIEa7e/ZwnUMSQDi0i8hNBkDxnDI1MWnBumLEwD3hQC9a8H7pRkM2HnrkA5lHgsn/n 9HIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=b0FdhFvoto3cfbTufYpeHPpDSicSfoYk0f7qMia8Bdg=; b=CwQaFeNEO2hIhKfI0HPLbE9OSfFN79HubycjS0S0wu6yQKLocdI70QRQc4ZnNtbwu/ 8CnKDwbgRQ9HEHO4+0Z+R5jsxwHS/echBCu4gakYHPB/W4+Y3HMeNeAIK3JmNGG4nIZT 9W6cu7RVoWhRHCD/h24E2erbY4yWHz1TDT2MQ4lxYC9TE3IQkaIzjjesaiB7/qr2QCcM R9CiKo/KXl9yEQ2gASpvRdBjS8CcLOZ71uul6sVuVYce34SJaS/Fe+3wvjWR2tdP/kYp cJEcoS2WH8casRo206dE16PTB02k/y9ur2L6tfAd/yCJBya/Qvwc1myHydapK2WjShI0 EWDg== X-Gm-Message-State: AOAM533fW2anNPDb6ESg9+zdDm9PQJRDQT6pn3BymP2ixf3W7RdLyY4O lbvUhtuArFiUtjP+3P0dQWjUfhkZIUqUFYqGTJE8hg== X-Received: by 2002:a0d:ea46:0:b0:2ed:62f4:e23c with SMTP id t67-20020a0dea46000000b002ed62f4e23cmr17960656ywe.437.1650405487130; Tue, 19 Apr 2022 14:58:07 -0700 (PDT) MIME-Version: 1.0 References: <20220419012810.88417-1-schspa@gmail.com> In-Reply-To: <20220419012810.88417-1-schspa@gmail.com> From: Linus Walleij Date: Tue, 19 Apr 2022 23:57:56 +0200 Message-ID: Subject: Re: [PATCH v3] gpio: use raw spinlock for gpio chip shadowed data To: Schspa Shi Cc: brgl@bgdev.pl, andy.shevchenko@gmail.com, f.fainelli@gmail.com, fancer.lancer@gmail.com, hoan@os.amperecomputing.com, linux-arm-kernel@lists.infradead.org, linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, opendmb@gmail.com Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,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 On Tue, Apr 19, 2022 at 3:28 AM Schspa Shi wrote: > In case of PREEMPT_RT, there is a raw_spinlock -> spinlock dependency > as the lockdep report shows. > > __irq_set_handler > irq_get_desc_buslock > __irq_get_desc_lock > raw_spin_lock_irqsave(&desc->lock, *flags); // raw spinlock get here > __irq_do_set_handler > mask_ack_irq > dwapb_irq_ack > spin_lock_irqsave(&gc->bgpio_lock, flags); // sleep able spinlock > irq_put_desc_busunlock > > Replace with a raw lock to avoid BUGs. This lock is only used to access > registers, and It's safe to replace with the raw lock without bad > influence. > > [ 15.090359][ T1] ============================= > [ 15.090365][ T1] [ BUG: Invalid wait context ] > [ 15.090373][ T1] 5.10.59-rt52-00983-g186a6841c682-dirty #3 Not tainted > [ 15.090386][ T1] ----------------------------- > [ 15.090392][ T1] swapper/0/1 is trying to lock: > [ 15.090402][ T1] 70ff00018507c188 (&gc->bgpio_lock){....}-{3:3}, at: _raw_spin_lock_irqsave+0x1c/0x28 > [ 15.090470][ T1] other info that might help us debug this: > [ 15.090477][ T1] context-{5:5} > [ 15.090485][ T1] 3 locks held by swapper/0/1: > [ 15.090497][ T1] #0: c2ff0001816de1a0 (&dev->mutex){....}-{4:4}, at: __device_driver_lock+0x98/0x104 > [ 15.090553][ T1] #1: ffff90001485b4b8 (irq_domain_mutex){+.+.}-{4:4}, at: irq_domain_associate+0xbc/0x6d4 > [ 15.090606][ T1] #2: 4bff000185d7a8e0 (lock_class){....}-{2:2}, at: _raw_spin_lock_irqsave+0x1c/0x28 > [ 15.090654][ T1] stack backtrace: > [ 15.090661][ T1] CPU: 4 PID: 1 Comm: swapper/0 Not tainted 5.10.59-rt52-00983-g186a6841c682-dirty #3 > [ 15.090682][ T1] Hardware name: Horizon Robotics Journey 5 DVB (DT) > [ 15.090692][ T1] Call trace: > ...... > [ 15.090811][ T1] _raw_spin_lock_irqsave+0x1c/0x28 > [ 15.090828][ T1] dwapb_irq_ack+0xb4/0x300 > [ 15.090846][ T1] __irq_do_set_handler+0x494/0xb2c > [ 15.090864][ T1] __irq_set_handler+0x74/0x114 > [ 15.090881][ T1] irq_set_chip_and_handler_name+0x44/0x58 > [ 15.090900][ T1] gpiochip_irq_map+0x210/0x644 > > Signed-off-by: Schspa Shi LGTM Acked-by: Linus Walleij Mostly hits drivers/gpio so this seems like something Bartosz should merge. Yours, Linus Walleij