Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2397963rwd; Fri, 26 May 2023 06:10:44 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5mlWGVQGG9rzExANdbSYt7CEbci8b5sl68yiXctUgXqWrYpokOA/QAQd1zp/FTmy8dDhfu X-Received: by 2002:a17:902:c40f:b0:1ae:622c:e745 with SMTP id k15-20020a170902c40f00b001ae622ce745mr3222060plk.1.1685106644558; Fri, 26 May 2023 06:10:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685106644; cv=none; d=google.com; s=arc-20160816; b=acPo17IZB8vbbxMGTq/zztAz/1myhKLHJjCk5Gvb1DjKx33cUh2YD1tCL0L4M6UI3E WOt5hw6A6M4SfCXx62qOw1tpY2TyJ7QROJUJcMRjCrSbddVVa10fjqplSvT/6BL6+UI8 ESCRJrdyMLJJbtkMLCQc7CViCZUfxlioVH6T+SXyytXepAQZkaoMfNbTUmkvCqy9GX3q aPHyXGUljogT+cRfyA2BltOzDjf8Hjxd923eyzr+/C9nhlPVeOSgmH/sas+0tLcIfbWz WPhKwmgap/IvF8+Wf2kMoaxYODHYRrfu56n0/7XqWmDEgB5kfSb7oBRcoq0qIpoZv2kW vSBw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=s01y3S+iaFhb6QhGbpp78rHEfgIg+a6LGYlDvW3YBZs=; b=B8eXedJxRvE86ia7zKwjwq5W4vDUHiHrPujzax4hXwJxkRiFoMIy92WbSzoFls+J3p eEB+D9xhPEFPpmUUnQ2qB7WDNKQ2eBGSv6C3PRmqNtQTGJ1FbggdEuUK3ORv7Uf1X2hS K8f3Qb+eQTP5EU/z8g9sD+1HVzHysf2c1rva6SFc7oQRMBwALF3oYZaihZ4kjlJnh8z4 iJAjzKzp3bhopu11mfVW3mgKrIInqqAn0S9bh7ds3I51zdQ970xV7qjoDiqpjFkUAgQm jXLV0uNcNruD24yOPu0tdl98aAMnAvnEQV2ife6YOQcZqdiUoUaF7oeLHgOEIOaFoSL7 RWHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bgdev-pl.20221208.gappssmtp.com header.s=20221208 header.b=CqYvIK8S; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x16-20020a1709027c1000b001a94429df88si988847pll.123.2023.05.26.06.10.29; Fri, 26 May 2023 06:10:44 -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=@bgdev-pl.20221208.gappssmtp.com header.s=20221208 header.b=CqYvIK8S; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242803AbjEZNBQ (ORCPT + 99 others); Fri, 26 May 2023 09:01:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47642 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231603AbjEZNBO (ORCPT ); Fri, 26 May 2023 09:01:14 -0400 Received: from mail-ua1-x936.google.com (mail-ua1-x936.google.com [IPv6:2607:f8b0:4864:20::936]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3CF56114 for ; Fri, 26 May 2023 06:01:13 -0700 (PDT) Received: by mail-ua1-x936.google.com with SMTP id a1e0cc1a2514c-783ec566cb9so216016241.3 for ; Fri, 26 May 2023 06:01:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20221208.gappssmtp.com; s=20221208; t=1685106072; x=1687698072; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=s01y3S+iaFhb6QhGbpp78rHEfgIg+a6LGYlDvW3YBZs=; b=CqYvIK8S4YikC+xy01uu/g+VxtXZBIiIgwDWqByuToj/Yrz78SRY927926g7/Hqhsa 1YVpPAIVPggHxtEGdoliT69PMCtLRoMvkdkKT1loMfNdJKPi98it8HUnTVJxb09j28dG VV38WHFiQiP2FTIZkE8ro4PFlqoIyVXBBUv/3yGVb8MbmeX7D5xVbT5QggCI3yXpTibG Qx+KkmZSgjVl4tA2tYx1Aug5ASDnctV5OHGqPTsgG1L0ZvO1XPXxYv+NGyjmt9AcZyJj FD8N3wfNKBOUMuJ2Rpl9Q+Z1ly/f0fIUqDlCtzBBtowiuGSlkRwTSyHPIflQJo3ZSy3I u2Lg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685106072; x=1687698072; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=s01y3S+iaFhb6QhGbpp78rHEfgIg+a6LGYlDvW3YBZs=; b=Ts2e2CwC78tfJfOOY7EmpCVFvZVDUQW1fRxxB1r8KoKZPjgZFSCcJxNHn0qD+up2X8 Gcrvr6IdO1G/Qe0RW0TbtwGIS93yZg3vmNe/EvvN7RtCEPvaeJGXp4tgmEZZhx2Tklvw OTTYJ5gN3HMtV0W/hOC+pOkAjxQhOdWMrdx35btEivT44eIJORWCc0UBxwd53G5AE1nU KsHBND0AJQeOBJMCk0Ds4xAn8fuY3AtnY75XVcSQ0SwV5HlDIqEsb/AzYbhK9xW5dLC6 hw0CENzRabpfCSNQF4KoYxWUZyEyKGV8Gmwc8crxW0gAzIzkSHRvfrQ/QChh0CyswD1f Ilnw== X-Gm-Message-State: AC+VfDyT6zL+VIkv5rgoeVj5qsUC5K7LaSfsEIA0lTcTxPK9Gqqo+2jX +eBfyiaJRs65ajOzHhcB2BPRSAOLQ3cPFgcge6I1/Q== X-Received: by 2002:a67:ec51:0:b0:434:82d1:c84 with SMTP id z17-20020a67ec51000000b0043482d10c84mr420032vso.15.1685106072307; Fri, 26 May 2023 06:01:12 -0700 (PDT) MIME-Version: 1.0 References: <20230519050702.3681791-1-chris.packham@alliedtelesis.co.nz> In-Reply-To: From: Bartosz Golaszewski Date: Fri, 26 May 2023 15:01:01 +0200 Message-ID: Subject: Re: [PATCH v2] gpiolib: Avoid side effects in gpio_is_visible() To: Andy Shevchenko Cc: Chris Packham , linus.walleij@linaro.org, johan@kernel.org, maz@kernel.org, warthog618@gmail.com, linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 19, 2023 at 12:09=E2=80=AFPM Andy Shevchenko wrote: > > On Fri, May 19, 2023 at 8:07=E2=80=AFAM Chris Packham > wrote: > > > > On a system with pca9555 GPIOs that have been exported via sysfs the > > following warning could be triggered on kexec(). > > > > WARNING: CPU: 0 PID: 265 at drivers/gpio/gpiolib.c:3411 gpiochip_disa= ble_irq > > Call trace: > > gpiochip_disable_irq > > machine_crash_shutdown > > __crash_kexec > > panic > > sysrq_reset_seq_param_set > > __handle_sysrq > > write_sysrq_trigger > > > > The warning is triggered because there is an irq_desc for the GPIO but > > it does not have the FLAG_USED_AS_IRQ set. This is because when the GPI= O > > is exported via gpiod_export(), gpio_is_visible() is used to determine > > if the "edge" attribute should be provided but in doing so it ends up > > calling gpiochip_to_irq() which creates the irq_desc. > > > > 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. > > To me it still sounds like a hack and the real solution should be done > differently/elsewhere. > > Also I'm worrying that not having this file visible or not may affect > existing user space custom scripts we will never hear about. > > P.S. TBH, I don't care much about sysfs, so if this patch finds its > way upstream, I won't be unhappy. > Same. Which is why - if there'll be no more objections, I will apply it. Bart