Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp9922959rwr; Fri, 12 May 2023 00:53:43 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ46n8/GVcN11BjtGH4OLiS9qtJi9M/AtLWpks1tvJrbl4nH7CvxTKc+JKwsO1ZqLb8F7+Zl X-Received: by 2002:a05:6a20:7d99:b0:104:a096:6ac7 with SMTP id v25-20020a056a207d9900b00104a0966ac7mr673092pzj.34.1683878023524; Fri, 12 May 2023 00:53:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683878023; cv=none; d=google.com; s=arc-20160816; b=ds3Q4qKBE8bJ+39CYQWZOeKkTMW9hDc+1aGPzaXtd8QU8v5mCsGqFBYunryjN/lFNU aEUJmgssvK6lqkbIcO9SSNtCm/25MAvoRwWSH7YR9cxpiAAUXvlTVL3xZcBPH+gVgzKf R49+eweIYlWlgzawgpUEhIm5Z9Ib+OpLHhAFAzGvY9ZLcXLpobgzV0zynY1mFc/tVUud hjFzM/yBfayt63Y44tVedtvf46dvv8Bbr5UpOcx87ceL35LmkWj/f4agEirFeKSYKBRB RPOWZXpYDYZuoHVPo7HH+83oZ98QwjrDllmvzD9ingV73yH155nOxKy9jplTYsyURwjY ipWA== 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-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=dBEX32R9ZwDJnww1JSPR3crHngWVvcvd7iRzr8or/4Y=; b=G88z2M1MFJ1y1Pu6jJ4mBKRc7ohZ4G5vzBDQ9Q3s0FrqoOAcaiavVMPwHK6sQt8uRW p/wakqFvqS28NmNJ0JgtCduRyog0nMhl3CpG7cFuPRHuQ77wF1X1KemluCqs61XhBrwa ZFqdn757Pk9V36IRvFCqlDQ3H5HyVGZjJ/jIYWCf92TveMZ9yrNVgaBA8SP0jDwm/PNM a2C1VFUsKgYn3VcJTaTWvtBLpOPXIPEpi8soIjk9a3yFuCL8aplKk5ForSeQILofhT7F /yESSRPr6bDk9W+niFCUsU8CO/ZjzBvIzyfxQ7F9bgbznmHHiBBHnF9xdXRCyb5YPU4G wm8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=PoS6M9j6; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f126-20020a623884000000b00624eb57b45dsi9169121pfa.74.2023.05.12.00.53.31; Fri, 12 May 2023 00:53:43 -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=@kernel.org header.s=k20201202 header.b=PoS6M9j6; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240171AbjELHYF (ORCPT + 99 others); Fri, 12 May 2023 03:24:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37692 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240109AbjELHYC (ORCPT ); Fri, 12 May 2023 03:24:02 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D7DDC10DF; Fri, 12 May 2023 00:24:00 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 755A765358; Fri, 12 May 2023 07:24:00 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D5535C4339B; Fri, 12 May 2023 07:23:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1683876239; bh=HfUj4/s95uvz7Tk19IO4GOkQ3Gb/dTDAKkge/PI7650=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=PoS6M9j6GwJZ1fGGcuJ9aBlIkZjBIoigcpC8senelnx9LAnakyrGNBJrx5rHZ1MfW DufeI6ryHogGxT+C51Lv47GclZasRDxkv9L7GHPPGJOMFg9jv+DS6vR2Z8KfwxBsXt 5q8XCTLAoPYyA4JwApx5jAfQ4FYlPbUkQ3dK4CfHHl9CkvkhMPThHkwsjst0oxi9Di 21uAuf5HcSQIcXVVxL7FTY+f4+vKdWtUTosPSHEJPhIhm6rS/BevKytGiS7NcqUvuk uqI81+07qGFhboi0/QcA7oDEeY4Ay20B/k59lBQtBRbsCbqjj/kuH/YMxevnZDiC08 4843IJbPnp5UA== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pxN8c-0002Co-QC; Fri, 12 May 2023 09:24:27 +0200 Date: Fri, 12 May 2023 09:24:26 +0200 From: Johan Hovold To: Chris Packham Cc: linus.walleij@linaro.org, brgl@bgdev.pl, andy.shevchenko@gmail.com, maz@kernel.org, Ben Brown , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] gpiolib: Avoid side effects in gpio_is_visible() Message-ID: References: <20230512042806.3438373-1-chris.packham@alliedtelesis.co.nz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230512042806.3438373-1-chris.packham@alliedtelesis.co.nz> X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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 Fri, May 12, 2023 at 04:28:06PM +1200, Chris Packham wrote: > Calling gpiod_to_irq() creates an irq_desc for the GPIO. This is not > something that should happen when just exporting the GPIO via sysfs. The > effect of this was observed as triggering a warning in > gpiochip_disable_irq() when kexec()ing after exporting a GPIO. You need a better explanation as to why this is an issue. What does the warning look like for example? > Remove the call to gpiod_to_irq() from gpio_is_visible(). The actual > intended creation of the irq_desc comes via edge_store() when requested > by the user. And why does that avoid whatever problem you're seeing? > Fixes: ebbeba120ab2 ("gpio: sysfs: fix gpio attribute-creation race") This is clearly not the right Fixes tag. The above commit only moved the creation of the attribute to before registering the sysfs device and specifically gpiod_to_irq() was used also prior to that commit. As a matter of fact, back then there was no call to irq_create_mapping() in gpiod_to_irq() either. That was added years later by commit dc749a09ea5e ("gpiolib: allow gpio irqchip to map irqs dynamically") > Signed-off-by: Chris Packham > --- > > Notes: > This is technically a v2 of > https://lore.kernel.org/lkml/20230510001151.3946931-1-chris.packham@alliedtelesis.co.nz/ > but the solution is so different it's probably best to treat it as a new > patch. > > drivers/gpio/gpiolib-sysfs.c | 2 -- > 1 file changed, 2 deletions(-) > > diff --git a/drivers/gpio/gpiolib-sysfs.c b/drivers/gpio/gpiolib-sysfs.c > index 530dfd19d7b5..f859dcd1cbf3 100644 > --- a/drivers/gpio/gpiolib-sysfs.c > +++ b/drivers/gpio/gpiolib-sysfs.c > @@ -362,8 +362,6 @@ static umode_t gpio_is_visible(struct kobject *kobj, struct attribute *attr, > if (!show_direction) > mode = 0; > } else if (attr == &dev_attr_edge.attr) { > - if (gpiod_to_irq(desc) < 0) > - mode = 0; > if (!show_direction && test_bit(FLAG_IS_OUT, &desc->flags)) > mode = 0; > } Johan