Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp17044768rwd; Mon, 26 Jun 2023 19:57:18 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7To71h4OYG1XPiCJxao0NptYZBjc+Xq9F1CNHUMQPBouKgyQQjH2QNlXrYG9+Pme9wiywe X-Received: by 2002:a17:907:2da6:b0:988:99e:9798 with SMTP id gt38-20020a1709072da600b00988099e9798mr26572266ejc.43.1687834638476; Mon, 26 Jun 2023 19:57:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687834638; cv=none; d=google.com; s=arc-20160816; b=Ji8Sc4L9ivoURpPlVUhARG+yEab5gCMJ+f5e0HObRwzpYd/5GTiy3OaW4V/+StvsR6 UnKA82Hi8932/U7pvHyng8OOuvHZZk905VH5DIMlgtnHeInk9N2DLje3VfuHZvv/Bat3 aLFihgAfuny5z8tIBO1u1DFuPhqGJKdrsAXRmcsmEkwgdu4vLbdbP1UKE29GTjXz5EI6 RrZrrRwFok+1/k3QUqppIEaOrwYA2uYijF9zu1fSoldVxfuKQ8nP9Wh+aXKUIbfbByEp CJnGJ7G/d73DmaWBnQz3gjxPkjKzFXZVCkbmpGaUM8DROE+afHff81EXP6stj8+L9Y1p U+hg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=kuS+J2WqbCreeIe7PYXRfOV5ugfO30G3d5LDVodX73g=; fh=qTi87Ndq2kRqanzdbGFDYpLKVbINCHXhMt+579slEUE=; b=sFUUkvkt8xCGzjMGIE0lBzYdnkOboTBzFT7zxZ1rkYRR4WzGiLj3ZDmOdvab+5TI9w nLOEtXYFXmR8pSU3XkaOVfeqUS8o2b39+3jlpQckwLX1VhRadZ3bjxO1OdEuIQ9ensBq EErif6lYVK+7cW0arVoODNe+WE+FxMaufGlitJHGVHe4BCKurnsxQomG7tzHoqyrL/v0 z/8rPZMgckGgzRsshzKs6WZ+o08Z/HkVZpKOvq8QSE7/+9V8W1AQPuNmVZuvqK5hyDdP Ph5ys8MG8HIs+oyVgWqHXfLcxuKvocw7c4qTbgi1AlBZiHJnlm1dCBw6PbWcvs1BjCym YG+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=jNeKvWkj; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b10-20020a170906490a00b00988d4fb5eb9si3527431ejq.567.2023.06.26.19.56.53; Mon, 26 Jun 2023 19:57:18 -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=@gmail.com header.s=20221208 header.b=jNeKvWkj; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229710AbjF0Bnj (ORCPT + 99 others); Mon, 26 Jun 2023 21:43:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43286 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229495AbjF0Bnh (ORCPT ); Mon, 26 Jun 2023 21:43:37 -0400 Received: from mail-pl1-x633.google.com (mail-pl1-x633.google.com [IPv6:2607:f8b0:4864:20::633]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 18A26D9; Mon, 26 Jun 2023 18:43:35 -0700 (PDT) Received: by mail-pl1-x633.google.com with SMTP id d9443c01a7336-1b5018cb4dcso19154675ad.2; Mon, 26 Jun 2023 18:43:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1687830214; x=1690422214; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=kuS+J2WqbCreeIe7PYXRfOV5ugfO30G3d5LDVodX73g=; b=jNeKvWkjvZrD2HKxULxSpne41OyLKWSbpDHFlEXuBq/OFmHg1wTo1wHPd1/P4zXVIC 5zlgoBG9IIuIntfOL30xtjgSDbRfIdT0zS9WK+6qYlOVnHKCHNiy2pOc5i96S2pGzkvv /TzwKsq7eJSTxZktr48AT2Cpw6GMbWGn+oWrHxjktRocveMjkBeCuX2DIRVhvidzx0QB V3vwRtGZAZYYFQhNuSh1WSYBTn1crHytAnwjNxIawqRFZMnWqzxJlHIsPgUwvhbNpI9k QrbIX5hbhhhirnbA3W29tY/fPh4uXh4BMc5sC3cmWDbg9BfzlH6SHCVLd6uzNzgHHDzb sHkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687830214; x=1690422214; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=kuS+J2WqbCreeIe7PYXRfOV5ugfO30G3d5LDVodX73g=; b=XJ+7ppoZxhP6+knD94iwy76IykrUGHRRhbW0p1A+XlAiVqvv1km4MYEweuGXVECo/T kxW8jcpkQdYobWa7t76Q92m/YToc61ZftezgUMixBnGPF/dnA8CPtliGkXqd6p95+hMs zNaNJMLBe0A0GN9X0OZvK+yC7+UpmhhTy7hfGoa9bjEQPQMNWmzOnWc5KysCJZFu7sWT ASaV8ik8DeIKWp4+CdzfRf2jgPh/kFW9f2d71aitPHoy2bSbr+6adISK/rl00YVbuoJJ 1fsH8vZ20MeA9YBLvFBT25WziaBBXOrzyuUj3CBBXiZCIx94Z4SnIgSrAPVGl4p8gARP j2Gw== X-Gm-Message-State: AC+VfDw60Y3xYSxtsrjGVYrJiJgiWuy9PtdZ9a2tyR46uEiH/0oN5NBW EpXClE/IXGwKHyAkbXeNJmc= X-Received: by 2002:a17:902:dace:b0:1b6:7b75:60f with SMTP id q14-20020a170902dace00b001b67b75060fmr5585355plx.41.1687830214408; Mon, 26 Jun 2023 18:43:34 -0700 (PDT) Received: from sol (194-223-178-180.tpgi.com.au. [194.223.178.180]) by smtp.gmail.com with ESMTPSA id a4-20020a1709027d8400b001ae0a4b1d3fsm4783498plm.153.2023.06.26.18.43.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Jun 2023 18:43:33 -0700 (PDT) Date: Tue, 27 Jun 2023 09:43:28 +0800 From: Kent Gibson To: Bartosz Golaszewski Cc: YE Chengfeng , "linus.walleij@linaro.org" , "andy@kernel.org" , "linux-gpio@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH] gpio: gpiolib-cdev: Fix potential &lr->wait.lock deadlock issue Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,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 Mon, Jun 26, 2023 at 05:50:47PM +0200, Bartosz Golaszewski wrote: > On Mon, Jun 26, 2023 at 9:23 AM Kent Gibson wrote: > > > > > > spin_lock_bh() should be sufficient, given that edge_irq_thread() is run > > in a softirq? That is faster and would allow the hard irq handlers to > > still run, and timestamp the event, but inhibit the edge_irq_thread() > > from being called on that CPU until the lock is released. > > (hmmm, gpio_desc_to_lineinfo() also uses spin_lock_irqsave() but it is > > never called from hard irq context, so there is a good chance I'm missing > > something here??) > > More on spin_lock choice below. > > Again: this is incorrect - edge_irq_thread() doesn't execute in > softirq context which can be verified by calling in_softirq() from it. > Ok, that matches what I had initially thought. Wading through the kernel doc got me thinking the secondary handler was run as a softirq. But it is a threaded irq used here, so the thread handler runs in a kernel thread, as does the debounce_work_func() and hte thread handler process_hw_ts_thread(). That's a relief. While we are on the subject of spin_locks, why does gpio_desc_to_lineinfo() use spin_lock_irqsave()? I assume the _irq is necessary as the desc could be updated at interrupt level, but AFAICT gpio_desc_to_lineinfo() is only ever called from process context, so why not just spin_lock_irq()? Cheers, Kent.