From patchwork Fri May 12 04:28:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Packham X-Patchwork-Id: 92938 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp4847713vqo; Thu, 11 May 2023 21:42:16 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6/WqxFmvE+AvFcAKBlh8Xip+hhwSz/oe4jBqaJU12VDxXL+Mz5hAB8evcPf+9wNfuQ7E81 X-Received: by 2002:a05:6a00:2408:b0:63f:18ae:1d5f with SMTP id z8-20020a056a00240800b0063f18ae1d5fmr29854389pfh.29.1683866535943; Thu, 11 May 2023 21:42:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683866535; cv=none; d=google.com; s=arc-20160816; b=LS3GoM5eRV8yybBmaX5FHlTGNzUUYkafqrU/GdeMnZK4FvSLALodiE83lP/5Cbio7P P0ru9tX4aW/qrbR1dvO9poRG2RVRTc2tEmQHWk1xLkXD5iwU2VXB5IuAI0fFWXkuSutE lIVxgmK2deznPiyh+PLBuoIyrvHNB76p9Bdo1E9IwGFtBqDo9WHh6AspRXT3SzXCLrUe B6Wc7/y0kCP6/a8xjJc+3BMKEqVxONkI4H/kfMhYC8c3TQC3ujyJZDXnotPfDGPHzPok dCQCoCxIoeF0b3bvhSlQGRutPOQLIbBrpTg3MOv9F8SNutM4eE236F81XcOtJT4qM2OZ YoSQ== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=GagT8hvc6P+NCio8S5NQPhJe5E1qdikT/egb1xEX7Sk=; b=wPrKvpMxCoQdZP3yzes+OaDSgElKCZKx5RYjo8ocmhYUDQOkaAJeG+b74Za+cuhVqW hW9ffUfEPGtvxxTSLPXUi9ZRc/TbAdPdlfctoE0WMCO0Nm5kIyTIcmwP791pTOg43wrd tDGceVChl3DPvyj+Kl8C1ODck9A5ppHrYNK7n/XANNujja/r96erX9Bkwd2/4rdWZNGI yZs5QoQjxOnhKZ+RR+Sf6cCQYK5i88KVVLTtLJWHrZh35ctuHmOwTYlkP3bt9fmkrSmk EMsncG+ByvLvojYMQob1jRfUPz41HNVawlLphiQA4iVeF0t62GpRRRqrSx4z2qIZKRnW 6Uag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alliedtelesis.co.nz header.s=mail181024 header.b=iehmeGg+; 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=QUARANTINE sp=REJECT dis=NONE) header.from=alliedtelesis.co.nz Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b11-20020a63714b000000b00525064abb76si8344343pgn.495.2023.05.11.21.42.02; Thu, 11 May 2023 21:42:15 -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=@alliedtelesis.co.nz header.s=mail181024 header.b=iehmeGg+; 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=QUARANTINE sp=REJECT dis=NONE) header.from=alliedtelesis.co.nz Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239664AbjELE2V (ORCPT + 99 others); Fri, 12 May 2023 00:28:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43902 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229994AbjELE2T (ORCPT ); Fri, 12 May 2023 00:28:19 -0400 Received: from gate2.alliedtelesis.co.nz (gate2.alliedtelesis.co.nz [IPv6:2001:df5:b000:5::4]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 83BB449DA for ; Thu, 11 May 2023 21:28:17 -0700 (PDT) Received: from svr-chch-seg1.atlnz.lc (mmarshal3.atlnz.lc [10.32.18.43]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by gate2.alliedtelesis.co.nz (Postfix) with ESMTPS id 55A4C2C011D; Fri, 12 May 2023 16:28:10 +1200 (NZST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alliedtelesis.co.nz; s=mail181024; t=1683865690; bh=GagT8hvc6P+NCio8S5NQPhJe5E1qdikT/egb1xEX7Sk=; h=From:To:Cc:Subject:Date:From; b=iehmeGg+iFi+wZL1fXyiIkGnqAASLqWP88gDMMd6xXVOPJH0zWZXsjyUiij/jToF0 DR4rtOGrd6YIUqTqn1GJ/23h9JVBEnCvfns3jFpn/hCxx1jZ/Q5EGoHFwjy0eqq4hb Dp40EgewMLMfyc2IOlhDfItqpJaYVxHzH/f2QxqwYIo06rJACovWCrVeMtRxiodZO+ FIEuJeUC3C45mN0hOztXTUtJ8fWTiVg6Z9Tc0hu7FVVIFpJGNvM2IrHDwi7f7pGqMS KwQPqNyFeij49xYPxr2z/93GK/H+t9YGvrq214lyfzRFvaNapvu6AsdMdntzNXusAe bCPa4A2PYJ58w== Received: from pat.atlnz.lc (Not Verified[10.32.16.33]) by svr-chch-seg1.atlnz.lc with Trustwave SEG (v8,2,6,11305) id ; Fri, 12 May 2023 16:28:09 +1200 Received: from chrisp-dl.ws.atlnz.lc (chrisp-dl.ws.atlnz.lc [10.33.22.30]) by pat.atlnz.lc (Postfix) with ESMTP id F01DF13ED95; Fri, 12 May 2023 16:28:09 +1200 (NZST) Received: by chrisp-dl.ws.atlnz.lc (Postfix, from userid 1030) id EB5B3283899; Fri, 12 May 2023 16:28:09 +1200 (NZST) From: Chris Packham To: linus.walleij@linaro.org, brgl@bgdev.pl, johan@kernel.org, andy.shevchenko@gmail.com, maz@kernel.org, Ben Brown Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, Chris Packham Subject: [PATCH] gpiolib: Avoid side effects in gpio_is_visible() Date: Fri, 12 May 2023 16:28:06 +1200 Message-Id: <20230512042806.3438373-1-chris.packham@alliedtelesis.co.nz> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 X-SEG-SpamProfiler-Analysis: v=2.3 cv=cLieTWWN c=1 sm=1 tr=0 a=KLBiSEs5mFS1a/PbTCJxuA==:117 a=P0xRbXHiH_UA:10 a=VwQbUJbxAAAA:8 a=Op8SjpqLE0gF3w78xgEA:9 a=AjGcO6oz07-iQ99wixmX:22 X-SEG-SpamProfiler-Score: 0 x-atlnz-ls: pat X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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?1765662036703061932?= X-GMAIL-MSGID: =?utf-8?q?1765662036703061932?= 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. 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. Fixes: ebbeba120ab2 ("gpio: sysfs: fix gpio attribute-creation race") 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; }