Received: by 2002:a05:7412:6592:b0:d7:7d3a:4fe2 with SMTP id m18csp909294rdg; Fri, 11 Aug 2023 04:06:48 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF9xckk4iFKJhqu2D238qOJ+Vy6zxbcZIQr9HdYB2gaOR4wBsVNqXn2WMMbfl1jrDIWUNUw X-Received: by 2002:a05:6a21:62a:b0:132:ce27:d29e with SMTP id ll42-20020a056a21062a00b00132ce27d29emr1462928pzb.10.1691752008055; Fri, 11 Aug 2023 04:06:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691752008; cv=none; d=google.com; s=arc-20160816; b=KTRFbgULYZfPtdaEvCXXinpJ75FdeYwlBFdmL9oUu4cR7Jwr1RwNgdFuQjbxNInxvX qaiRTlzBj3AJekLqsYA4A8PG1PbV8FWG3RaVWuV4unQ5lWQxjq3aqViexXT/TfhmRsQ0 RHMZxWdLLRrLl5yuZVuWG5NgVVIn1hs2AhSCirJC1P1VCRRFlix/q2XQ4gz7aOgajwRy atMXYxHui3G3L3f9mnkn0PT2k54jFpgT0OZBBPQrqlDyM7urVcdU6XVGuAuv5FDyWlCl FY/hyfUILPK+5hIoeFWkjqCY+496TDaekyFQOx42Kgx/0z0frNqVmgQll+LMfkpxCgkW uf0Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:organization:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=JEbhe5Z/VkcTnpr3rOCdRJyjVPpYJuqv5SrGOF63Tzs=; fh=xp78Ar08qHZpilsbzFhEpyM/TXFcJFxLxGAlf+gRFRY=; b=WFrajRvJ5AJgg+DuAS4f5FSaZL6KhD1JX7SitKnPbH8sFttxt+jfB0uXFSmQf/+JNt NhlNfn9GmooMpu46aexgRwOSTcx+OiuyTS9+I1EZPc2cCyampa31wZOjiOJRVG+tt26G mDXjC9F9HE4+up4JstdPJF9xME4rb9t8i7ySQKbV8USBUB83t4UZQ2Z4Aa8ZIux3uPJ5 u7FG4oeQlxDEj4kUfV8RhWvXrNZ/u7JHQh6FGj31ps19IEwDFMU45HovPLzCUrw975Gz q7wSFV8ZooKScoulT26M0pKkk7A5iUuaukTkYj3TFb7jRbS+jJI1zA+8V0SO7gvAzbd0 1g9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Zr4y6MHo; 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=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y72-20020a638a4b000000b00564362fe306si3229493pgd.282.2023.08.11.04.06.35; Fri, 11 Aug 2023 04:06:48 -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=@intel.com header.s=Intel header.b=Zr4y6MHo; 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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234492AbjHKKQz (ORCPT + 99 others); Fri, 11 Aug 2023 06:16:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52040 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234380AbjHKKQv (ORCPT ); Fri, 11 Aug 2023 06:16:51 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 73866120; Fri, 11 Aug 2023 03:16:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1691749010; x=1723285010; h=date:from:to:cc:subject:message-id:references: mime-version:content-transfer-encoding:in-reply-to; bh=tVPd6gUd2vGL79XhejO82av1TVq9COxvYKVND28mf4o=; b=Zr4y6MHorEu6IF8qKP2rtxWZQxuJWyNjhMyfqxLpAq+/XkMywBO1nW0P 3hO+lCnwc0fzPT8ZTYW0ypAE75OyCmwaAp8nrKtdvl+WEw7GcwBvgdEEg BhrfvbvybQkrEA1ymMhqdGnvvDxixDOAtK4YzQmN06bV4oN8m7SM31JQ0 Ekmosck+yPMjBHtKu91sZqKSSukT+nj+4vDiN2ru5dpnNNAu5mmJR+bb0 ByZifc1AtcKVhBWOepeLmn4FNaB2FpA5sRiuzzjnP6wqZBb2OeSAjM81Z 5iLaePssKrcCPZi/peNqN+5OXlykOvkMnjHafVX8wzJdhwoTe0ZMNTe8M A==; X-IronPort-AV: E=McAfee;i="6600,9927,10798"; a="375359578" X-IronPort-AV: E=Sophos;i="6.01,165,1684825200"; d="scan'208";a="375359578" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Aug 2023 03:16:49 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10798"; a="709486859" X-IronPort-AV: E=Sophos;i="6.01,165,1684825200"; d="scan'208";a="709486859" Received: from smile.fi.intel.com ([10.237.72.54]) by orsmga006.jf.intel.com with ESMTP; 11 Aug 2023 03:16:48 -0700 Received: from andy by smile.fi.intel.com with local (Exim 4.96) (envelope-from ) id 1qUPCI-00ACFD-2p; Fri, 11 Aug 2023 13:16:46 +0300 Date: Fri, 11 Aug 2023 13:16:46 +0300 From: Andy Shevchenko To: Marek =?iso-8859-1?Q?Beh=FAn?= Cc: Bartosz Golaszewski , linux-gpio@vger.kernel.org, Linus Walleij , linux-kernel@vger.kernel.org Subject: Re: regression from commit b0ce9ce408b6 ("gpiolib: Do not unexport GPIO on freeing") Message-ID: References: <20230808102828.4a9eac09@dellmb> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20230808102828.4a9eac09@dellmb> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_NONE,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 On Tue, Aug 08, 2023 at 10:28:28AM +0200, Marek Beh?n wrote: > Hi, > > the commit b0ce9ce408b6 ("gpiolib: Do not unexport GPIO on freeing") > > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=b0ce9ce408b6 > > causes a regression on my mvebu arm board (haven't tested on other > systems), wherein if I export a GPIO to sysfs and then unexport it, it > does not disasppear from the /sys/class/gpio directory, and subsequent > writes to the export and unexport files for the gpio fail. > > $ cd /sys/class/gpio > $ ls > export gpiochip0 gpiochip32 gpiochip512 unexport > $ echo 43 >export > $ ls > export gpio43 gpiochip0 gpiochip32 gpiochip512 > unexport > $ cat gpio43/value > 1 > $ echo 43 >unexport > $ ls > export gpio43 gpiochip0 gpiochip32 gpiochip512 > unexport > $ echo 43 >unexport > ash: write error: Invalid argument > $ echo 43 >export > ash: write error: Operation not permitted Can you test the following change (I'll submit a formal patch if it works)? diff --git a/drivers/gpio/gpiolib-sysfs.c b/drivers/gpio/gpiolib-sysfs.c index 530dfd19d7b5..b10a9b5598b2 100644 --- a/drivers/gpio/gpiolib-sysfs.c +++ b/drivers/gpio/gpiolib-sysfs.c @@ -515,8 +515,9 @@ static ssize_t unexport_store(const struct class *class, * they may be undone on its behalf too. */ if (test_and_clear_bit(FLAG_SYSFS, &desc->flags)) { + gpiod_unexport(desc); + gpiod_free(desc); status = 0; - gpiod_free(desc); } done: if (status) -- With Best Regards, Andy Shevchenko