{"id":2234948,"url":"http://patchwork.ozlabs.org/api/1.2/patches/2234948/?format=json","web_url":"http://patchwork.ozlabs.org/project/linux-gpio/patch/20260508105448.31799-4-tzungbi@kernel.org/","project":{"id":42,"url":"http://patchwork.ozlabs.org/api/1.2/projects/42/?format=json","name":"Linux GPIO development","link_name":"linux-gpio","list_id":"linux-gpio.vger.kernel.org","list_email":"linux-gpio@vger.kernel.org","web_url":"","scm_url":"","webscm_url":"","list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<20260508105448.31799-4-tzungbi@kernel.org>","list_archive_url":null,"date":"2026-05-08T10:54:42","name":"[v10,3/9] gpio: Add revocable provider handle for struct gpio_chip","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"9f9cd4f32c0410e5b6eabf03ab30550b31cef8a0","submitter":{"id":83557,"url":"http://patchwork.ozlabs.org/api/1.2/people/83557/?format=json","name":"Tzung-Bi Shih","email":"tzungbi@kernel.org"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/linux-gpio/patch/20260508105448.31799-4-tzungbi@kernel.org/mbox/","series":[{"id":503368,"url":"http://patchwork.ozlabs.org/api/1.2/series/503368/?format=json","web_url":"http://patchwork.ozlabs.org/project/linux-gpio/list/?series=503368","date":"2026-05-08T10:54:39","name":"drivers/base: Introduce revocable","version":10,"mbox":"http://patchwork.ozlabs.org/series/503368/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2234948/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2234948/checks/","tags":{},"related":[],"headers":{"Return-Path":"\n <linux-gpio+bounces-36447-incoming=patchwork.ozlabs.org@vger.kernel.org>","X-Original-To":["incoming@patchwork.ozlabs.org","linux-gpio@vger.kernel.org"],"Delivered-To":"patchwork-incoming@legolas.ozlabs.org","Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256\n header.s=k20201202 header.b=iBeBOMHD;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org\n (client-ip=172.234.253.10; helo=sea.lore.kernel.org;\n envelope-from=linux-gpio+bounces-36447-incoming=patchwork.ozlabs.org@vger.kernel.org;\n receiver=patchwork.ozlabs.org)","smtp.subspace.kernel.org;\n\tdkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org\n header.b=\"iBeBOMHD\"","smtp.subspace.kernel.org;\n arc=none smtp.client-ip=10.30.226.201"],"Received":["from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4gBmMy1x9Xz1yCg\n\tfor <incoming@patchwork.ozlabs.org>; Fri, 08 May 2026 20:59:26 +1000 (AEST)","from smtp.subspace.kernel.org (conduit.subspace.kernel.org\n [100.90.174.1])\n\tby sea.lore.kernel.org (Postfix) with ESMTP id 3561D308D40C\n\tfor <incoming@patchwork.ozlabs.org>; Fri,  8 May 2026 10:55:33 +0000 (UTC)","from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id D54403290C3;\n\tFri,  8 May 2026 10:55:32 +0000 (UTC)","from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org\n [10.30.226.201])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby smtp.subspace.kernel.org (Postfix) with ESMTPS id 9362932ABCA;\n\tFri,  8 May 2026 10:55:32 +0000 (UTC)","by smtp.kernel.org (Postfix) with ESMTPSA id 043D5C2BCF5;\n\tFri,  8 May 2026 10:55:28 +0000 (UTC)"],"ARC-Seal":"i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1778237732; cv=none;\n b=D/6xFtkq9vj3lUo/aY4N5BmK8oIY2NfE7dOBCG6+Nth4idGeOLiE7le1zcX6WK5ZrtsBf2Nfcv2NZc4t7j7mwxagfLA8VvT2/Ba3+RCyocXSpFJ1/Y8IaZ+96GZkGmvulCk0nd61Zw/PCSYZ7cCPQ1y0eZZZJDXESSJ8AO65khM=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1778237732; c=relaxed/simple;\n\tbh=FHk+uD2OdcZc+L/NkfqKJ7/JmGmIeRX0VaOttO0Q4cw=;\n\th=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:\n\t MIME-Version;\n b=MJ6Yc119/3hhJ6kCzO+OyG3DocM5DDY4SNpFTxcczaxV05jgL6Ln3boW/s52FiH2qQhVLf+7/iNlOhdwikLXZPdUFhFWSksbUQC/y5zxSkt4dbfAwbi5gpO/nvjng9ZuFnv2m/wygxKtY7KTXpWWtx8dFfLw6T5Rtdrz3j7E5S0=","ARC-Authentication-Results":"i=1; smtp.subspace.kernel.org;\n dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org\n header.b=iBeBOMHD; arc=none smtp.client-ip=10.30.226.201","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org;\n\ts=k20201202; t=1778237732;\n\tbh=FHk+uD2OdcZc+L/NkfqKJ7/JmGmIeRX0VaOttO0Q4cw=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=iBeBOMHDOXGbylbk9Wc+KQEn10O0qrTVGUWbS5ExD2HNHu/W1zEssPOzj4jAu3CP1\n\t 2SZ7Qdvc19dkrrDlm6CtAPdM5F+m01FSZ/XEhddBMUb51EGxIcksVgyOuTT14QuobX\n\t acTZkXmtQJcBHKk/v0j/rdXKm4c13pQXeARrd3qvzp+R0t5fBFi/ZsctVZ1lQZbd9V\n\t EO2KRFG1juBYoYX20JW1LPiMN/ITJSDiEs+Vz+9+ERf/FnxKnk3C2u46gCpuXDP6St\n\t VtRkQHJb+HwnoZEzNAD/JzF58wgTzkQV50TfdX//a19HzUXh8eWJM2qKZiAms3Rh5r\n\t u0rwRenr3B2OQ==","From":"Tzung-Bi Shih <tzungbi@kernel.org>","To":"Arnd Bergmann <arnd@arndb.de>,\n\tGreg Kroah-Hartman <gregkh@linuxfoundation.org>,\n\tBartosz Golaszewski <brgl@kernel.org>,\n\tLinus Walleij <linusw@kernel.org>","Cc":"Benson Leung <bleung@chromium.org>,\n\ttzungbi@kernel.org,\n\tlinux-kernel@vger.kernel.org,\n\tchrome-platform@lists.linux.dev,\n\tdriver-core@lists.linux.dev,\n\tlinux-doc@vger.kernel.org,\n\tlinux-gpio@vger.kernel.org,\n\t\"Rafael J. Wysocki\" <rafael@kernel.org>,\n\tDanilo Krummrich <dakr@kernel.org>,\n\tJonathan Corbet <corbet@lwn.net>,\n\tShuah Khan <shuah@kernel.org>,\n\tLaurent Pinchart <laurent.pinchart@ideasonboard.com>,\n\tWolfram Sang <wsa+renesas@sang-engineering.com>,\n\tJason Gunthorpe <jgg@nvidia.com>,\n\tJohan Hovold <johan@kernel.org>,\n\t\"Paul E . McKenney\" <paulmck@kernel.org>","Subject":"[PATCH v10 3/9] gpio: Add revocable provider handle for struct\n gpio_chip","Date":"Fri,  8 May 2026 18:54:42 +0800","Message-ID":"<20260508105448.31799-4-tzungbi@kernel.org>","X-Mailer":"git-send-email 2.51.0","In-Reply-To":"<20260508105448.31799-1-tzungbi@kernel.org>","References":"<20260508105448.31799-1-tzungbi@kernel.org>","Precedence":"bulk","X-Mailing-List":"linux-gpio@vger.kernel.org","List-Id":"<linux-gpio.vger.kernel.org>","List-Subscribe":"<mailto:linux-gpio+subscribe@vger.kernel.org>","List-Unsubscribe":"<mailto:linux-gpio+unsubscribe@vger.kernel.org>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit"},"content":"The underlying chip can be removed asynchronously.  `gdev->srcu` is used\nto ensure the synchronization before accessing `gdev->chip`.\n\nRevocable encapsulates the details.  Add revocable provider handle for\nthe corresponding struct gpio_chip in struct gpio_device so that it can\nstart to hide the synchronization details.\n\nSigned-off-by: Tzung-Bi Shih <tzungbi@kernel.org>\n---\nv10:\n- Change revocable API usages accordingly.\n\nv9: https://lore.kernel.org/all/20260427135841.96266-4-tzungbi@kernel.org\n- New to the series.\n- Use static allocated resource provider.\n- Rename \"chip_rp\" -> \"chip_rev\".\n\nv4 - v8:\n- Doesn't exist.\n\nv3: https://lore.kernel.org/all/20260213092958.864411-8-tzungbi@kernel.org\n- Change revocable API usages accordingly.\n\nv2: https://lore.kernel.org/all/20260203061059.975605-8-tzungbi@kernel.org\n- Change usages accordingly after applying\n  https://lore.kernel.org/all/20260129143733.45618-2-tzungbi@kernel.org.\n  - Add __rcu for `chip_rp`.\n  - Pass pointer of pointer to revocable_provider_revoke().\n- Rebase accordingly after applying\n  https://lore.kernel.org/all/20260203060210.972243-1-tzungbi@kernel.org.\n\nv1: https://lore.kernel.org/all/20260116081036.352286-13-tzungbi@kernel.org\n\n---\n drivers/gpio/gpiolib.c | 13 +++++++++++--\n drivers/gpio/gpiolib.h |  3 +++\n 2 files changed, 14 insertions(+), 2 deletions(-)","diff":"diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c\nindex 1e6dce430dca..9046fd923af0 100644\n--- a/drivers/gpio/gpiolib.c\n+++ b/drivers/gpio/gpiolib.c\n@@ -23,6 +23,7 @@\n #include <linux/nospec.h>\n #include <linux/of.h>\n #include <linux/pinctrl/consumer.h>\n+#include <linux/revocable.h>\n #include <linux/seq_file.h>\n #include <linux/slab.h>\n #include <linux/srcu.h>\n@@ -874,6 +875,7 @@ static void gpiodev_release(struct device *dev)\n \tsynchronize_srcu(&gdev->desc_srcu);\n \tcleanup_srcu_struct(&gdev->desc_srcu);\n \n+\trevocable_put(&gdev->chip_rev);\n \tida_free(&gpio_ida, gdev->id);\n \tkfree_const(gdev->label);\n \tkfree(gdev->descs);\n@@ -1210,6 +1212,10 @@ int gpiochip_add_data_with_key(struct gpio_chip *gc, void *data,\n \telse\n \t\tgdev->owner = THIS_MODULE;\n \n+\tret = revocable_init(&gdev->chip_rev, gc);\n+\tif (ret)\n+\t\tgoto err_put_device;\n+\n \tscoped_guard(mutex, &gpio_devices_lock) {\n \t\t/*\n \t\t * TODO: this allocates a Linux GPIO number base in the global\n@@ -1224,7 +1230,7 @@ int gpiochip_add_data_with_key(struct gpio_chip *gc, void *data,\n \t\t\tif (base < 0) {\n \t\t\t\tret = base;\n \t\t\t\tbase = 0;\n-\t\t\t\tgoto err_put_device;\n+\t\t\t\tgoto err_revoke_chip_rev;\n \t\t\t}\n \n \t\t\t/*\n@@ -1244,7 +1250,7 @@ int gpiochip_add_data_with_key(struct gpio_chip *gc, void *data,\n \t\tret = gpiodev_add_to_list_unlocked(gdev);\n \t\tif (ret) {\n \t\t\tgpiochip_err(gc, \"GPIO integer space overlap, cannot add chip\\n\");\n-\t\t\tgoto err_put_device;\n+\t\t\tgoto err_revoke_chip_rev;\n \t\t}\n \t}\n \n@@ -1343,6 +1349,8 @@ int gpiochip_add_data_with_key(struct gpio_chip *gc, void *data,\n \tscoped_guard(mutex, &gpio_devices_lock)\n \t\tlist_del_rcu(&gdev->list);\n \tsynchronize_srcu(&gpio_devices_srcu);\n+err_revoke_chip_rev:\n+\trevocable_revoke(&gdev->chip_rev);\n err_put_device:\n \tgpio_device_put(gdev);\n \tgoto err_print_message;\n@@ -1389,6 +1397,7 @@ void gpiochip_remove(struct gpio_chip *gc)\n \t/* Numb the device, cancelling all outstanding operations */\n \trcu_assign_pointer(gdev->chip, NULL);\n \tsynchronize_srcu(&gdev->srcu);\n+\trevocable_revoke(&gdev->chip_rev);\n \tgpio_device_teardown_shared(gdev);\n \tgpiochip_irqchip_remove(gc);\n \tacpi_gpiochip_remove(gc);\ndiff --git a/drivers/gpio/gpiolib.h b/drivers/gpio/gpiolib.h\nindex dc4cb61a9318..4e2e98f61f5a 100644\n--- a/drivers/gpio/gpiolib.h\n+++ b/drivers/gpio/gpiolib.h\n@@ -16,6 +16,7 @@\n #include <linux/gpio/driver.h>\n #include <linux/module.h>\n #include <linux/notifier.h>\n+#include <linux/revocable.h>\n #include <linux/spinlock.h>\n #include <linux/string.h>\n #include <linux/srcu.h>\n@@ -55,6 +56,7 @@ struct fwnode_handle;\n  * @device_notifier: used to notify character device wait queues about the GPIO\n  *                   device being unregistered\n  * @srcu: protects the pointer to the underlying GPIO chip\n+ * @chip_rev: revocable provider handle for the corresponding struct gpio_chip.\n  * @pin_ranges: range of pins served by the GPIO driver\n  *\n  * This state container holds most of the runtime variable data\n@@ -82,6 +84,7 @@ struct gpio_device {\n \tstruct workqueue_struct\t*line_state_wq;\n \tstruct blocking_notifier_head device_notifier;\n \tstruct srcu_struct\tsrcu;\n+\tstruct revocable\tchip_rev;\n \n #ifdef CONFIG_PINCTRL\n \t/*\n","prefixes":["v10","3/9"]}