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=1796385149; b=ohzmUBabnQxr7521/rrAc27mvIcH5JgoKxcDIxydINB3O9dTsiTgp0jzzTNTNFMfINhv Jy7eEQBWYncLLA3wQtV79KKReYqexpJ3HeR0eCUDTuS1FijgOyoaL9gEwFwnkXCuqG1/i zt/Cl1eVHOq2oJSwluri6vyojQ7cTWj/tklWktXEHAuIycBGd0hKJtX2NMLtM3p22/XEW fz7gvSKlWtOPgq9dIvaG2MVOMPqx1ysJgR6MkXl9rLRuFPCiygv3juIXRatLhzuawAA5I 9dr94yK5DjcJsfp40tAfyNuAFyBaWz/g5djASNDWNxgsV5pvUbPmPw00iOFufwDiAQA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796385149; 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=PAHaemv3+3Kvih5Ur+AEk/aMKObtkVc4Q1EixKUz/4o=; b=Q/tozn/6r5gGoGG5K8udblNhhhWWC7Brtnfplx0g/gt+kT8lMVVx2MYCMqVn4JQHDjTS X//YhI3GPfLP1lDTAUPh0Km29lNuBKbOPKNc4W9hF6wh/WmluXBzhNXfNXTpi6yYCulnl JQzWH2p8SBDMGlOPb4REAqv4AB3kUmxfHOA3yBJmHyR8M3VkNK8O0adn4RUlcwcjftVw0 ph8B4RZ4bFSauoNpCBUOOhkVvas0YHciqIhnYYF/Kcyo2Zu/ZUlDqq4kJeDXWRuziBN+b IWg12t6OjcBeqPlJMZdzL+wMFtjF6w7xsbWOIIWC8Y1tJowA73k819WqR5lx3yLrWxA== 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="iqWb/wQx"; 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 228CA606A322; Fri, 4 Dec 2026 11:52:29 +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=iqWb/wQx Received: by smtp.kernel.org (Postfix) with ESMTPSA id 87D631F000CE; Fri, 4 Dec 2026 11:52:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796385149; bh=PAHaemv3+3Kvih5Ur+AEk/aMKObtkVc4Q1EixKUz/4o=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=iqWb/wQxLmScwC/eN+f5eq6LwDdF3doYnmIfOUhwNkyTS4inmZXaFixvd5RtohCYP P+YzLDLBbVrDQDI9xJQBpwsnG+tIGLPaoRL3Cq2W55FsmGfFHD/kIlOr70ygVgkFDg 7UjzomrLLrPG2pmY38DUbBWl79fssY30L8CM+o7k= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Adrian Ambrozewicz , Bartosz Golaszewski , Sasha Levin Subject: [PATCH 6.6 0438/1167] gpiolib: clear the event clock flags when a line is released Date: Fri, 4 Dec 2026 18:57:45 +0900 Message-ID: <20261204100713.424315418@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100702.047403948@linuxfoundation.org> References: <20261204100702.047403948@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.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Adrian Ambrozewicz [ Upstream commit d35f61581ee67f8d4d58c325bac813cea528b6b9 ] gpiod_free_commit() clears the flags that a request sets on a line, but not GPIOD_FLAG_EVENT_CLOCK_REALTIME and GPIOD_FLAG_EVENT_CLOCK_HTE, which gpio_v2_line_config_flags_to_desc_flags() sets from the uAPI v2 line config. Once a line requested with GPIO_V2_LINE_FLAG_EVENT_CLOCK_REALTIME or GPIO_V2_LINE_FLAG_EVENT_CLOCK_HTE is released, GPIO_V2_GET_LINEINFO_IOCTL and the line info changed events, the "released" one included, keep reporting that event clock for the free line: GPIO_V2_GET_LINE_IOCTL, line 1, input, event clock realtime: ok close() GPIO_V2_GET_LINEINFO_IOCTL, line 1: input, event clock realtime The flags are set before edge detection is set up, so a request that fails in hte_ts_get(), for instance because no HTE provider handles the line, leaves GPIOD_FLAG_EVENT_CLOCK_HTE behind as well. The next uAPI v2 request rewrites both flags, but requests through uAPI v1, sysfs exports and in-kernel consumers do not, and the line info then shows the event clock of an earlier user for them too. Clear both flags together with the other flags of the request. Reproduced under QEMU with a test GPIO chip: after a released request with the realtime event clock, and on a kernel with CONFIG_HTE=y but no HTE provider after a failed request with the HTE event clock, the line info of the free line still reports that event clock. With this change it reports none. Fixes: 26d060e47e25 ("gpiolib: cdev: allow edge event timestamps to be configured as REALTIME") Fixes: 2068339a6c35 ("gpiolib: cdev: Add hardware timestamp clock type") Signed-off-by: Adrian Ambrozewicz Link: https://patch.msgid.link/20261012-gpiolib-event-clock-v1-1-aambrozewicz@nvidia.com Signed-off-by: Bartosz Golaszewski [ sashal: Renamed the GPIOD_FLAG_* flags to FLAG_* and changed the &flags clears to &desc->flags, to match this tree's older gpiod_free_commit(). ] Signed-off-by: Sasha Levin --- drivers/gpio/gpiolib.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 9b8a200423858..3a3025287dc13 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -2227,6 +2227,8 @@ static bool gpiod_free_commit(struct gpio_desc *desc) clear_bit(FLAG_BIAS_DISABLE, &desc->flags); clear_bit(FLAG_EDGE_RISING, &desc->flags); clear_bit(FLAG_EDGE_FALLING, &desc->flags); + clear_bit(FLAG_EVENT_CLOCK_REALTIME, &desc->flags); + clear_bit(FLAG_EVENT_CLOCK_HTE, &desc->flags); clear_bit(FLAG_IS_HOGGED, &desc->flags); #ifdef CONFIG_OF_DYNAMIC desc->hog = NULL; -- 2.53.0