Received: by 2002:a05:7412:6592:b0:d7:7d3a:4fe2 with SMTP id m18csp2405160rdg; Mon, 14 Aug 2023 01:03:11 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFd5OBbOMgunpTrRhF018+oi0RWK2+LWpDsE8I68LGpxy+uXTE+ZdmXXhWF7PmZ1tap2I2z X-Received: by 2002:a05:6a00:14d2:b0:686:6fa8:2b0d with SMTP id w18-20020a056a0014d200b006866fa82b0dmr9451809pfu.4.1692000191233; Mon, 14 Aug 2023 01:03:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692000191; cv=none; d=google.com; s=arc-20160816; b=W1emKEdAdzImgSz2litp4cJn+P7Bp/SaTDcKDZTUP25yKzm41jf1TY3teQewdzDipt y1CbHsT1Y7b/EXpQIwXEBZqP6zjZ2czCGfpqN+rFSP9tJ7GSH5F+41vf1ZmIvdtUw0jG AV6mMujAzFizAEDe8JkaQk70xOTxKXoBCkP7Fjb9grBBegc6wUAidu610CZWKj9yU95U 8YWqAo89oagwnF1G2m91ml6mW8/F1sboENneENAsHVLhOJfKbG2t82HDxW45wKHkCgO+ eIcNDKWtajjYu23CceXzWTmOsu/TsU6751ucqG3PbZ/62tkufrs2cnZ6h7jz3lES2hpv vq+w== 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 :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=Mjyxfv82nCd9cZWgdiA9PwS47Guh1+R33scbn11FPSg=; fh=G5HcacRZ5Zoyzo+DOV1dpcKhrXw2EL+/vyTfASy7NJQ=; b=NgMccNXl+QFPKrHUJoNE1pmjKbleHvnDtdpQZWK1Kc0UcdXkHhKhPe54ioCJJOXOP4 I6g4o8Quou7XEOwRior6KyN+7AM4ZSiSxfeh1CkWjO7ViqbDZtRyn20MMKiCDNRuGDtA 5vEdZbAPICacbl8nAwdfpveSaVxDN2gS+XRFXQp3tlrcAVmgVnNmgT5C/DBaXd7vPJnG jenVlJ4oh/x1hz8GeknfW03iOIADkxjK7Z1IodgxmKimeY8ytkQzZ+AuBQq7AegRheZj 3f/VaxNsGIHWwiu9DV30nU/6QBtO74jgAmJ4szkcK0fLpZvablCHUrH0j7+jouT41W3h JY7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=izUbETfq; 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 h127-20020a636c85000000b005655f9903desi7138152pgc.655.2023.08.14.01.02.48; Mon, 14 Aug 2023 01:03:11 -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=izUbETfq; 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 S234081AbjHNHkB (ORCPT + 99 others); Mon, 14 Aug 2023 03:40:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48158 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233924AbjHNHjk (ORCPT ); Mon, 14 Aug 2023 03:39:40 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A7427E73; Mon, 14 Aug 2023 00:39:39 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 433266423C; Mon, 14 Aug 2023 07:39:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 92BB7C433C8; Mon, 14 Aug 2023 07:39:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1691998778; bh=K1ssrh1C1cpCotV7bPzZb/F45LVd+6cD8e6wcK+CSJw=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=izUbETfq2qR8HA7QrMmE0buc+2edVKxmaYiBT6A9GUJ+LaDdUT3n6S1XYn+nliXs9 WXezkm++0vB3TpwcHcYn+xe/B4E3PdWnUsnne0lNb3BDwpfrRJDAfWbj6KaMV0wwbJ qwH+57cIaMQPHGkb1UcnSX/IbLXZVtxo2mrTN54Zggq/3r5H7G5OW6+ZZTZ9b+4BP1 epkjlJrNY1+KyfUzmtXu/RjerZWhM5dgZmDouwbggRXhfNv9wG3pkbO/3DXoLfZuhS y7nocbmFRjQ4bfe9nzwB1FQkDwVp4FnAJ0JHobIKdGF6KIXdvbD38PFkwzrjyBuyAG Zj+w6XwRJBEXw== Date: Mon, 14 Aug 2023 09:39:34 +0200 From: Marek =?UTF-8?B?QmVow7pu?= To: Andy Shevchenko 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: <20230814093934.1793961e@dellmb> In-Reply-To: References: <20230808102828.4a9eac09@dellmb> X-Mailer: Claws Mail 4.1.1 (GTK 3.24.38; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS 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, 11 Aug 2023 13:16:46 +0300 Andy Shevchenko wrote: > On Tue, Aug 08, 2023 at 10:28:28AM +0200, Marek Beh=C3=BAn wrote: > > Hi, > >=20 > > the commit b0ce9ce408b6 ("gpiolib: Do not unexport GPIO on freeing") > >=20 > > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/co= mmit/?id=3Db0ce9ce408b6 > >=20 > > 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. > >=20 > > $ 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 =20 >=20 > Can you test the following change (I'll submit a formal patch if it works= )? >=20 > 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 *cla= ss, > * they may be undone on its behalf too. > */ > if (test_and_clear_bit(FLAG_SYSFS, &desc->flags)) { > + gpiod_unexport(desc); > + gpiod_free(desc); > status =3D 0; > - gpiod_free(desc); > } > done: > if (status) >=20 tested, works. Please add Fixes tag when sending the patch