From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796384251; b=YwCDRuLRgF+2p5hcL4ggta0ww642Q/fAWim41ggEpCG5x3QSmGpTv9HIAZkkc/44EtYw MzRIsWuqdNXNt2xMcz3mjKWE/nuUcHuG7JfiAE3VXIe8Oh/FEZCBQS/i8+l+ZrHT00PEw QilBW+X0/hC2Y9HmiF2p9c0VgJn1DSa7i0LNcU4BJcPee8DRdd7A0Z7oZ0U3qyQyN/Qth 27L2D06hE9HJ8cSWC+kpAb8LDAS0yoGO66yUv2uiNRDK+YHFQH9fRZCRBPQJ6qtuRxPYe EaF5eJMIn9g29/m9ig0G1CZM0lCLmH3Csw0YfkzFduGWWtb6GTQLyCuUa2lRllQkdag== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796384251; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=+3j4+oKVhqb0u4mbkc8kH3/ntuzYUVHZTCJhQwLiU6Q=; b=nU2VW11jCkAFbIMfKc+1xfjQYGq6qiX98uhbKfS445Cr0fNkFmWVnrdmQFdwseGk8XnO 6MQ9xKQFpf1R8URci4QE/TJRmnvin8Ma3tSI/7cGAtSqHiHDdJXxowW1D3frAg+asbX4I rSl0QPj3t4RvfT4OtIhp+zGCl2fvDkTT9resbwNNyJAxWbmBly6W9IPVlQqWygnf0MHLt px6Q5rJ6erRZwAMI8jNAW2goc8w7+njeaGCIJIQapUCKX7cyr+WTf7el843DjEE+BZGgG /6EaIpyQCPfDj8AnfmqIfYNXWXBANaoc60I+X3TV5Xw1IBV22miSnTkYa8pFyh1/Tjw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=YyXF43h7; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AFD74606A322; Fri, 4 Dec 2026 11:37:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=YyXF43h7 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2DA0E1F000C2; Fri, 4 Dec 2026 11:37:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796384251; bh=+3j4+oKVhqb0u4mbkc8kH3/ntuzYUVHZTCJhQwLiU6Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=YyXF43h72hLXC1R+DFBFBvVyAdqm0AaHKP5Mm71rqXs1555Ug3HYfHlU04KxrcjVf 1cHNfQfAJ9o7K0bD61h6OKsYfmZKi6HT/4unfpJcmc18O0cg+In77+yA1WThvIM3W7 1YRgSxbEo2TyZpcr9UNaEQhpXfhTVWVIjw9jaKMY= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, "Paul E. McKenney" , Andy Shevchenko , Yi Lai , Adrian Ambrozewicz , Bartosz Golaszewski , Sasha Levin Subject: [PATCH 6.12 552/555] gpiolib: wait for pending label frees before cleaning up desc_srcu Date: Fri, 4 Dec 2026 19:09:55 +0900 Message-ID: <20261204100629.557035674@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100603.988357525@linuxfoundation.org> References: <20261204100603.988357525@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Adrian Ambrozewicz [ Upstream commit c901e8fddd3a23353bb12c9d93b9a5fc482ac8f5 ] desc_set_label() frees the old label with call_srcu() on gdev->desc_srcu, and gpiodev_release() calls synchronize_srcu() before cleanup_srcu_struct(). synchronize_srcu() waits for a grace period, not for queued callbacks. Once the srcu_struct uses per-CPU callback lists, a label freed by gpiochip_free_hogs() can still be pending, and cleanup_srcu_struct() warns: WARNING: kernel/rcu/srcutree.c:706 at cleanup_srcu_struct+0x239/0x330, CPU#0: init/1 Call Trace: gpiodev_release device_release kobject_put devres_release_all device_release_driver_internal platform_device_unregister gpio_sim_device_deactivate Use srcu_barrier(), which waits for them. Reproduced with a hogged gpio-sim line, setting the chip live and back on a 4-CPU guest with srcutree.convert_to_big=1: it warns within 60 cycles; with this change, 1000 cycles pass. Fixes: a86d27693066 ("gpiolib: fix the speed of descriptor label setting with SRCU") Cc: stable@vger.kernel.org Reviewed-by: Paul E. McKenney Reviewed-by: Andy Shevchenko Tested-by: Yi Lai Signed-off-by: Adrian Ambrozewicz Link: https://patch.msgid.link/20261124-gpiolib-chip-removal-v8-1-aambrozewicz@nvidia.com Signed-off-by: Bartosz Golaszewski Signed-off-by: Sasha Levin --- drivers/gpio/gpiolib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 81436cb78a476..86ab8bc142ca1 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -757,7 +757,7 @@ static void gpiodev_release(struct device *dev) struct gpio_device *gdev = to_gpio_device(dev); /* Call pending kfree()s for descriptor labels. */ - synchronize_srcu(&gdev->desc_srcu); + srcu_barrier(&gdev->desc_srcu); cleanup_srcu_struct(&gdev->desc_srcu); ida_free(&gpio_ida, gdev->id); -- 2.53.0