Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp3879834rdh; Tue, 28 Nov 2023 06:22:03 -0800 (PST) X-Google-Smtp-Source: AGHT+IGGzSj7h35RNVt/wY8s0lumvd03VFNmaGNPxcDbhp+E/IhlM+FQ/KTKS14hPmVFUm2BUI1+ X-Received: by 2002:a05:6808:3943:b0:3b8:8db4:744d with SMTP id en3-20020a056808394300b003b88db4744dmr932052oib.15.1701181323224; Tue, 28 Nov 2023 06:22:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701181323; cv=none; d=google.com; s=arc-20160816; b=xaIDjYVfY+Pdc5ElMhpN2qtt2gtJr+eTVH/icJsgOWpYX5UhtgCl/3OypOf4/VUGJZ r6Vu3mpkRWiy/ejXShqmJceilfhMvOwofrct+lU5I4YvVors3jEMfclZ1OJjT16XAiuq DMXcaqe9l5jfr2EVr1/N+zKdHfQubkisSqlTZAuYI76+urieyYsso17OPpf1+rcOLnix 8yooeRjluFruTZvAb8rzwrdj7SAkyYTvR8FR0vo9qe0kwkl9yA7gFs8Wjrl7L6pRWOQi 4/BiQQmOw6ZXMd/RWgxQQsrHYqjbfaYxxxdlHFqZHyC1Dfw+9aKlfqXbtcIlF6pKfNFs UftA== 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=C+UG3eivAjAm0i+X6/FSUZzwGX02Fl0BzHgHDeFoqqU=; fh=io6VJuNrc9fIDhLXdVzSvtdNVOhxmUrv8yUeXx2PatA=; b=lRPFhbggVCtyD9K2R20vsu9WEBXkWnr/YVdeH3FVI1qaY0vDBnVCesgEHFBECtsI1e ZjE7R78n+1YOKwH+m76g47w1Dekqm6CvTeDDTyPW5SA481nGxbLOb/b1Jya05ps7z5qV TZ1k/VZ5b0Zv8YKPxwQ6y9I/p3UaVDwS46epUzBBOg1LJrRCrv8L+AshUlvVmJXOqCc1 TWb1J09iVRIPD3YvGNMdw3jeStxxAooHQJ5Ybw++uh6K0U6GS5vq0t8IAgLqov0vbAMA QhEgEWXhU5+rcXqxZU2/0eg1UO0FITe9fCR2HFKraiecRczPsAD1CUeD2FdSwibEgXiC 77FA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jZZs0Gbz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id w189-20020a6362c6000000b005893c5bd119si11983961pgb.425.2023.11.28.06.22.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Nov 2023 06:22:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jZZs0Gbz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 5820C80532C4; Tue, 28 Nov 2023 06:22:00 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346166AbjK1OVs (ORCPT + 99 others); Tue, 28 Nov 2023 09:21:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35858 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346155AbjK1OVr (ORCPT ); Tue, 28 Nov 2023 09:21:47 -0500 Received: from mail-yw1-x1129.google.com (mail-yw1-x1129.google.com [IPv6:2607:f8b0:4864:20::1129]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 645ADD53 for ; Tue, 28 Nov 2023 06:21:53 -0800 (PST) Received: by mail-yw1-x1129.google.com with SMTP id 00721157ae682-5cc55b82ee5so51978417b3.2 for ; Tue, 28 Nov 2023 06:21:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1701181312; x=1701786112; darn=vger.kernel.org; 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=C+UG3eivAjAm0i+X6/FSUZzwGX02Fl0BzHgHDeFoqqU=; b=jZZs0GbzNn+sz7MrBuzHP8HBxsQui+JiZa+plNf5Q5NjxvnUikDNTjHvFoqLvZgns0 WY+6/HYPprNvDDA+aKo7tjC7sQ7gL+rSKOLXtPjmmKN1GnXJuKvvv8hgyzwXvwsNB8Hn JuCpq6zPQJuKuoyn1qHPCMix398JiF4oTf3u/ZYOZ2ObbXYJoZw1qrUfn+teLF9aITV0 ZNQ59fYtNstKStrazOyhEFW+EKJytlY7RRnWH4eNKS/5XNQ3Nczi8He4JoQxBI1bsrJS UWUvi0n7igED3NuWzaGudyzzZyTg6jp8+RzVUBhww63enFCfpyuGKcRMh3KBarZ5bUfb QcFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701181312; x=1701786112; 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=C+UG3eivAjAm0i+X6/FSUZzwGX02Fl0BzHgHDeFoqqU=; b=HTFZw7acLc4gA57cDdr+J5Af3ILNUrra/DXo8E4ZAEuLLE7GpGAQl4/MA+1Cqvro19 eBxSpXhcH+dssPxgzcKbHoYXOqbQf3TiFmWXkU4URkZ+CgwXfb0c8x3gYr1/OScygYg0 Vdvsij210lAnKF3oi5QQgcTRYa5qgFBK7OKjzb6nuu45z2DQQd0ljTx2bnlnWdO2jyud h4hU2dgSe5kOlsMxkxWFKhFhMbPn3Jf0OxHyhRft/3BA3mq/b+9oIl0SB5cvYvvKyVa0 I6jFxjW0mo/jCEWMuWAxKnGbz81UvJWnQLJDX3JMzuw/qDxKyaad//kqgQQKU0Lmmh9n tFkg== X-Gm-Message-State: AOJu0YzdGPLPZxsDFyWtTWYz+1DItcEW6DP3jXYjhCggTEFg3h0XckUG kr4jbmAa+9TFDpLzXdng58A9je4Pe6OwccAtBlmHJ68E5aZNcxEWsbY= X-Received: by 2002:a81:ac28:0:b0:5d0:4947:63c3 with SMTP id k40-20020a81ac28000000b005d0494763c3mr7234365ywh.14.1701181312555; Tue, 28 Nov 2023 06:21:52 -0800 (PST) MIME-Version: 1.0 References: <20231127193716.63143-1-brgl@bgdev.pl> <20231127193716.63143-2-brgl@bgdev.pl> In-Reply-To: <20231127193716.63143-2-brgl@bgdev.pl> From: Linus Walleij Date: Tue, 28 Nov 2023 15:21:40 +0100 Message-ID: Subject: Re: [PATCH 2/2] gpio: use a mutex to protect the list of GPIO devices To: Bartosz Golaszewski Cc: Andy Shevchenko , Kent Gibson , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,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 agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Tue, 28 Nov 2023 06:22:00 -0800 (PST) On Mon, Nov 27, 2023 at 8:37=E2=80=AFPM Bartosz Golaszewski = wrote: > From: Bartosz Golaszewski > > The global list of GPIO devices is never modified or accessed from > atomic context so it's fine to protect it using a mutex. Add a new > global lock dedicated to the gpio_devices list and use it whenever > accessing or modifying it. > > While at it: fold the sysfs registering of existing devices into > gpiolib.c and make gpio_devices static within its compilation unit. > > Signed-off-by: Bartosz Golaszewski Nice! I might have found some snag: gpio_device_find() still does guard(spinlock_irqsave)(&gpio_lock); shouldn't that be switched to the mutex? On top of this I can update my patch to the delete the comment for gpio_lock to just rename that thing to gpio_descriptor_lock and document it as such. But when I think about it: gpio[_decriptor]_lock can now (after this patch) be moved into struct gpio_chip as it is really just protecting the descriptors on the same chip from simultaneous modification, especially desc->flags. This is a BIG WIN because it makes it a local lock not a global one, do you wanna try it or should I? (On top of these two patches, then.) Yours, Linus Walleij