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=1796387937; b=b+yZf1LYR/mqbshecVx//r7GVwF9+hbK+55RnnYa4Kxf+RKJ9qU2T+xMALZd7x7cJlqb g8Y4d3GCRyMx4z1+9ECcYuuI/VMFYS5q2cGk5zZBEVQFCa3jB9x0pP/94dQp+wXeTnOV5 YZft5HYOBkusia/cW8ozxrsrOFeuLlj0KFuPgQgc4CfKdqtN5XLyikR6NR2qtdiU3ebE7 9IvoF9s+ABVfJCygTAATmyE10vDe6ES608VrRP+pUBBEmBvFEC8ajNdvhU9B01pV3SP4S YwAjFto3YWubD42XOUI00VjkFFObTewCVVWjdXJ0BieBRX2TnipIBjElm5mYWCrpsVA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796387937; 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=5KBiEqsKFSqWP6pjz0SbqMjtJZ1Ut4M/0tRq0ckGyfk=; b=R0NzRGzXcI7dmKH7Ytghxze1EjR+4bDgSFtQ4KvE7xechCknS+W7mXClVYS2PVnLocNR 2yIl0yCWPzAAPT9uAMiQTjp+kbdjEHug2vvkvigBIgML4YdFp+mn9+9a+cm2ohHxxDdVX a6PLmcbSizs38JVmYepMQaJ3V+WMJjzM/HOUSLoj8i+wBxO9BR34q2XqonTHCFmGgNIWw l8dqRYtTkbPZOI424ah+Mv6x0YzBuomQQwYM28g36k9W7oWabxq/svYr+KPvBQHdz3on/ tqdWgQd52HdX+8tyqMlh+Q28kSp/xnR7KxO+dmv7w0hhygj8cRJycFcXO0t2u3zUYVg== 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=Y751yFhX; 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 736DE606A32C; Fri, 4 Dec 2026 12:38:57 +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=Y751yFhX Received: by smtp.kernel.org (Postfix) with ESMTPSA id DE1841F000C2; Fri, 4 Dec 2026 12:38:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796387937; bh=5KBiEqsKFSqWP6pjz0SbqMjtJZ1Ut4M/0tRq0ckGyfk=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Y751yFhXjyi/gg5jb069G8wnD1jaOaVdjZh5UwtsrX2ztAvneuR42Fm+8H8OpAdQu 8k7jJyKNsDMOn9+twaIy8txasZM9OMgiu2RgXcTOhbJTF93YMHt6ZykIiokDmoZgc+ yMukYdeJ0hJoLFhlNuIB6INJWuMoJzcltf54wGiM= 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.1 0420/1059] gpiolib: clear the event clock flags when a line is released Date: Fri, 4 Dec 2026 18:59:11 +0900 Message-ID: <20261204100655.213095367@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100643.980430235@linuxfoundation.org> References: <20261204100643.980430235@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-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: Replaced the upstream GPIOD_FLAG_* clears on a local flags word with FLAG_* clears directly on desc->flags, since the older function has no local flags variable. ] 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 a0c1dabd29398..8e7cc12c55471 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -2064,6 +2064,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