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=1796382922; b=5Gbrp/hCmTO3j8ZfEkmQUu4xvNWud4uvrubldGMLH75xU3ldgiDRt+kxkhAM7xIgGFyL 3kv/nlCvnjKsGm8Z2H+Kc7whDLa53yMjQ7/eF8uxSEJj0syb5nka3OzpwW8TbKnEv70Gd JYYx+/FRjHf684UmS+/PhmT6uJq/3SIQskJ0kT596i50ovOTCZAx8JZtrNtm2BgWWGzaC IwbIClpB4HdOwXaTHf2bbzi6EIR6jVjZYeZ/ylQuDtoTBqKYSL7Sz8xHoj9ZxzjQbbLF7 5HTEmJRl0mB+p9b/OkA4aEuykUwL4OEuTIZDATiUIMNRVtzfG1a0FeTq1UBzPK7fYQQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796382922; 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=lpMXIFEowJKfPFqNxh2tvR068AeJUSha/duWj81bTso=; b=vnpzWX4FQhzqK3E6xD8sseSyjii1QYkPPjmQLXN30b24bQjVHjAmPxV+7jbv1lO9fWni i41PwFBUQtZJ/SvkJyd3RWTlo5LSWujehnj1H52BtO3Ty/2LK2z/lk57Jcn6W0/bMh6Uh uE3v+3uvaNW5nlSvoAFnstfdCChRy36xUza1vGATyDm8lmAe2LxWG8+W9FDq35H8uPWcK vY2zdR5Jor3MN6bVlb2I6iDDCLXywO5Q/4Ox0DMQMqJtz+29gGAaDRszT4xwjyah8UdEM vloayDOtYvAaOfJNdsJrcOtmQ4jQRb3xb91+lIi/eL5WZ1tbQQVcQDpqamOFrrrbdkQ== 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=MO74kZ93; 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 ECABD606A322; Fri, 4 Dec 2026 11:15:21 +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=MO74kZ93 Received: by smtp.kernel.org (Postfix) with ESMTPSA id CBF121F0092C; Fri, 4 Dec 2026 11:15:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796382921; bh=lpMXIFEowJKfPFqNxh2tvR068AeJUSha/duWj81bTso=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=MO74kZ934J36Ged9kZC5n2i03srwiDZlOzc1nk3y7lQHt8hGjBGfh0WqxrXoC3qxV 1uVc0Iboq2qDV2afjosIRczRGYj0DfQxVpp8TuLnokgXz6p/ArJDaA5K6lpbQykWIy aCrDiNF8WCNFPsw+3PdhQgLpC57CSmGwaosnIi4c= 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.18 651/703] gpiolib: wait for pending label frees before cleaning up desc_srcu Date: Fri, 4 Dec 2026 19:09:10 +0900 Message-ID: <20261204100645.100358710@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100627.522266145@linuxfoundation.org> References: <20261204100627.522266145@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.18-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 d0e73cdb7e121..1ea1adde96c5b 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -855,7 +855,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); if (gdev->line_state_wq) -- 2.53.0