From patchwork Sun Feb 9 10:46:02 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pauli Virtanen X-Patchwork-Id: 863641 Received: from lahtoruutu.iki.fi (lahtoruutu.iki.fi [185.185.170.37]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3306133987 for ; Sun, 9 Feb 2025 10:46:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=185.185.170.37 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739097974; cv=pass; b=Qe/21MePooBm9+JtCui+zL+FbbSY8Hy2xA8OPxKS/itYg5dQ1L+IGzVkAnP6h9m6G3qAkov6YyubohjTse7d9lI1vfQmy4dnwiHxcekLqqCzZq4ucEb2ZJ3maP0CYESrcCV3cdidTCHOuOnlo57hmcYjtgl5BTz8xPIKdW3Ksz8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739097974; c=relaxed/simple; bh=zfnrHnzEH31QmdtvEvfQ+LgtmxMxIJRhG1R51i45Tts=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=vDb/A9ZLv6UIbJtnNsCNIImtlgTzb92IjD6yXqwHcZT4HTRrXYqWMOgELQK3wrSMyvBuMSpw9jJrQ2AxcA8qnlck5hHOQ7+Q2xcuaFrLwI2QYuKAd6pD24xuRZtMN5CJiO9g79MktKsneQt30kHGYsUw0f2oING8EGtFiF9W8vY= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=iki.fi; spf=pass smtp.mailfrom=iki.fi; dkim=pass (2048-bit key) header.d=iki.fi header.i=@iki.fi header.b=EFJT9xNY; arc=pass smtp.client-ip=185.185.170.37 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=iki.fi Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=iki.fi Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=iki.fi header.i=@iki.fi header.b="EFJT9xNY" Received: from monolith.lan (unknown [193.138.7.198]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: pav) by lahtoruutu.iki.fi (Postfix) with ESMTPSA id 4YrPWj4c5hz49Q6m; Sun, 9 Feb 2025 12:46:09 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=lahtoruutu; t=1739097970; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WgInILH+4cVunQ/Q//WnoTJ0PsKf5QKOareIUfpMNjs=; b=EFJT9xNYd0AIn9HsZnd46qGTaEC3aOgj913DeTHDL8+TkCXiOrOxG0uij5jbZHWHtY6ZjT Sygwi/tiFlxjdC3upbkXeozd/cDxelLaErqiu8SAfRHSlNeyeonkOc/YsOunQKDvlDutsj ooobWYK0z4amwK5Y1hCoHiPwng+ny7R7y/K15ThRcqZgtiG2ik/314O3EGvI/5AjmeWcfs 3lKuzKepVkyrI4chEPUx1/vjw5QPN9xt6MAWJguF+SFWTVB0UJG8QdkTQ1dAigJDXZ8ZIJ vnW52QTOc0UZzFoSuEEd5wA9HCofmF573n5BA15fQEWWRoRAaDiR9/8a6K2zUQ== ARC-Seal: i=1; s=lahtoruutu; d=iki.fi; t=1739097970; a=rsa-sha256; cv=none; b=DB6OgZ9RybKlG50nMg+1lWsijkcJbPSRpzXCKI7OcHIRjchFRPgA2eB2t1Q8xwWWAKSiJR yizXp1byOyoTjXHZx4rfN0gktgIfUtkVtVDu3QTgYpIWPteQT5VqeQxJt367kY6tDzH5Uq jixjWq2epVFzskWmn1XKN/+ULXGYcb12KIvN4cMRX2zaYFAPKPTsbSYBxyi+vk+lu3lGPR SS5K2uG3X+lyUSlHBxMFWQP9ZOcsRUsqtbd5AHYNQjOblUFfLQtDq7iUAh+GSiEbBTtgms wuGGoY8KLm3WDFOXJXZBJP/yZ/BKjM53V7KohdD1oaJA+VOXvdMGO14Fm1L4SA== ARC-Authentication-Results: i=1; ORIGINATING; auth=pass smtp.auth=pav smtp.mailfrom=pav@iki.fi ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=lahtoruutu; t=1739097970; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WgInILH+4cVunQ/Q//WnoTJ0PsKf5QKOareIUfpMNjs=; b=XQBiaWisESrwFpp2Q0USyHYFta34+AXb9Mi9jVst6ZhKabQFqUSnsXIxpkdRnd/cFzEuGK 5piEiYC37UCU1zV5j9R0jQxGQW6KUWJo+FVEwlYi9CFh6IN6rIzaIGEj/0Ulltagib5C8i 62BDwqeQ92hh95lja1Jl2/Z65IG15yJjFapPn4lMdCtXdtWLvP6lG3nUUmtkTBHtDlg+PO /H/ki+m2g9l8hARcSUK/7wpP0RWZtMJCTw/GYMdGEnjf4XUsu7arr9pJneoMPIKrk26WQ+ 7F1peVH+JggilrR4L9Qyk4dzKy89FIuVCqCesZVSeArRIYlOgR267jLE/Csdvw== From: Pauli Virtanen To: linux-bluetooth@vger.kernel.org Cc: Pauli Virtanen Subject: [PATCH BlueZ 1/3] shared/io-glib: add watcher to be used with TX timestamping Date: Sun, 9 Feb 2025 12:46:02 +0200 Message-ID: <3938636ceaafc589f6d12fa6fe50e1c6a1c76bef.1739097949.git.pav@iki.fi> X-Mailer: git-send-email 2.48.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Add special implementation of fd watcher GSource for audio use. For audio use cases, sound server may turn on TX timestamping on a socket that we are watching. In this case, we shall not consider the TX timestamping POLLERR as a socket error condition, nor read the TX timestamps. When TX timestamps appear in errqueue, switch from fd poll wait to polling the fd at regular intervals. This is because unread errqueue causes poll() to wake up immediately, so the mainloop cannot block on that, and we have to use a timer instead with some reasonable timeout for the use case. This rate limits wakeups on new TX timestamps we aren't going to read, and also avoids the busy looping if timestamping was left on but errqueue is not flushed. Implement this only for io-glib; it is only needed for audio use cases that anyway are using glib. Uses features from GLib 2.36 (from 2013) so update configure.ac also. --- Makefile.am | 1 + acinclude.m4 | 3 +- configure.ac | 2 +- src/shared/io-glib.c | 157 ++++++++++++++++++++++++++++++++++++++++++- src/shared/io-glib.h | 20 ++++++ 5 files changed, 179 insertions(+), 4 deletions(-) create mode 100644 src/shared/io-glib.h diff --git a/Makefile.am b/Makefile.am index 0821530e6..f958e2b99 100644 --- a/Makefile.am +++ b/Makefile.am @@ -253,6 +253,7 @@ shared_sources += src/shared/shell.c src/shared/shell.h endif src_libshared_glib_la_SOURCES = $(shared_sources) \ + src/shared/io-glib.h \ src/shared/io-glib.c \ src/shared/timeout-glib.c \ src/shared/mainloop-glib.c \ diff --git a/acinclude.m4 b/acinclude.m4 index 168117840..598986d6e 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -63,8 +63,7 @@ AC_DEFUN([COMPILER_FLAGS], [ with_cflags="$with_cflags -Wformat -Wformat-security" with_cflags="$with_cflags -Wstringop-overflow" with_cflags="$with_cflags -DG_DISABLE_DEPRECATED" - with_cflags="$with_cflags -DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_28" - with_cflags="$with_cflags -DGLIB_VERSION_MAX_ALLOWED=GLIB_VERSION_2_32" + with_cflags="$with_cflags -DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_36" fi AC_SUBST([WARNING_CFLAGS], $with_cflags) ]) diff --git a/configure.ac b/configure.ac index 75841e4c9..d2b0bab2f 100644 --- a/configure.ac +++ b/configure.ac @@ -81,7 +81,7 @@ AC_CHECK_DECLS([basename], [], ]) -PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.28) +PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.36) if (test "${enable_threads}" = "yes"); then AC_DEFINE(NEED_THREADS, 1, [Define if threading support is required]) diff --git a/src/shared/io-glib.c b/src/shared/io-glib.c index 754043db1..bea9b2c32 100644 --- a/src/shared/io-glib.c +++ b/src/shared/io-glib.c @@ -13,10 +13,14 @@ #endif #include +#include #include #include "src/shared/io.h" +#include "src/shared/io-glib.h" + +#define IO_ERR_WATCH_RATELIMIT (500 * G_TIME_SPAN_MILLISECOND) struct io_watch { struct io *io; @@ -29,11 +33,19 @@ struct io_watch { struct io { int ref_count; GIOChannel *channel; + bool err_watch; struct io_watch *read_watch; struct io_watch *write_watch; struct io_watch *disconnect_watch; }; +struct io_err_watch { + GSource source; + GIOChannel *io; + GIOCondition events; + gpointer tag; +}; + static struct io *io_ref(struct io *io) { if (!io) @@ -179,10 +191,17 @@ static struct io_watch *watch_new(struct io *io, GIOCondition cond, prio = cond == G_IO_HUP ? G_PRIORITY_DEFAULT_IDLE : G_PRIORITY_DEFAULT; - watch->id = g_io_add_watch_full(io->channel, prio, + if (!io->err_watch) + watch->id = g_io_add_watch_full(io->channel, prio, + cond | G_IO_ERR | G_IO_NVAL, + watch_callback, watch, + watch_destroy); + else + watch->id = io_glib_add_err_watch_full(io->channel, prio, cond | G_IO_ERR | G_IO_NVAL, watch_callback, watch, watch_destroy); + if (watch->id == 0) { watch_destroy(watch); return NULL; @@ -250,6 +269,15 @@ bool io_set_disconnect_handler(struct io *io, io_callback_func_t callback, return io_set_handler(io, G_IO_HUP, callback, user_data, destroy); } +bool io_set_use_err_watch(struct io *io, bool err_watch) +{ + if (!io) + return false; + + io->err_watch = err_watch; + return true; +} + ssize_t io_send(struct io *io, const struct iovec *iov, int iovcnt) { int fd; @@ -278,3 +306,130 @@ bool io_shutdown(struct io *io) return g_io_channel_shutdown(io->channel, TRUE, NULL) == G_IO_STATUS_NORMAL; } + +/* + * GSource implementation that tolerates non-empty MSG_ERRQUEUE, without + * attempting to flush it. This is intended for use with TX timestamping in + * cases where someone else is reading the timestamps and we are only interested + * in POLLHUP or socket errors. + */ + +static gint64 io_err_watch_wakeup; + +static gboolean io_err_watch_dispatch(GSource *source, + GSourceFunc callback, gpointer user_data) +{ + struct io_err_watch *watch = (void *)source; + const GIOFunc func = (void *)callback; + const gint64 timeout = IO_ERR_WATCH_RATELIMIT; + GIOCondition cond; + int fd; + + if (!func) + return FALSE; + + fd = g_io_channel_unix_get_fd(watch->io); + + /* + * If woken up by POLLERR only, and SO_ERROR is not set, ignore this + * event. Also disable polling for some time so that we don't consume + * too much CPU on events we are not interested in, or busy loop if + * nobody is flushing the errqueue. + */ + + if (watch->tag) + cond = g_source_query_unix_fd(&watch->source, watch->tag); + else + cond = 0; + + if (cond == G_IO_ERR) { + int err, ret; + socklen_t len = sizeof(err); + + ret = getsockopt(fd, SOL_SOCKET, SO_ERROR, &err, &len); + if (ret == 0 && err == 0) { + g_source_remove_unix_fd(&watch->source, watch->tag); + watch->tag = NULL; + + /* io_err watches all wake up at the same time */ + if (!io_err_watch_wakeup) + io_err_watch_wakeup = g_get_monotonic_time() + + timeout; + + g_source_set_ready_time(&watch->source, + io_err_watch_wakeup); + return TRUE; + } + } + + if (g_source_get_ready_time(&watch->source) != -1) { + g_assert(!watch->tag); + io_err_watch_wakeup = 0; + watch->tag = g_source_add_unix_fd(&watch->source, fd, + watch->events); + g_source_set_ready_time(&watch->source, -1); + } + + cond &= watch->events; + + if (cond) + return func(watch->io, cond, user_data); + else + return TRUE; +} + +static void io_err_watch_finalize(GSource *source) +{ + struct io_err_watch *watch = (void *)source; + + if (watch->tag) + g_source_remove_unix_fd(&watch->source, watch->tag); + + g_io_channel_unref(watch->io); +} + +guint io_glib_add_err_watch_full(GIOChannel *io, gint priority, + GIOCondition events, + GIOFunc func, gpointer user_data, + GDestroyNotify notify) +{ + static GSourceFuncs source_funcs = { + .dispatch = io_err_watch_dispatch, + .finalize = io_err_watch_finalize, + }; + GSourceFunc callback = (void *)func; + struct io_err_watch *watch; + gint fd; + guint id; + + g_return_val_if_fail(!(events & (G_IO_IN | G_IO_OUT)), 0); + g_return_val_if_fail(events, 0); + g_return_val_if_fail(func, 0); + + fd = g_io_channel_unix_get_fd(io); + + watch = (void *)g_source_new(&source_funcs, + sizeof(struct io_err_watch)); + + watch->io = g_io_channel_ref(io); + watch->events = events; + watch->tag = g_source_add_unix_fd(&watch->source, fd, events); + + g_source_set_name((void *)watch, "io_glib_err_watch"); + g_source_set_callback(&watch->source, callback, user_data, notify); + + if (priority != G_PRIORITY_DEFAULT) + g_source_set_priority(&watch->source, priority); + + id = g_source_attach(&watch->source, NULL); + g_source_unref(&watch->source); + + return id; +} + +guint io_glib_add_err_watch(GIOChannel *io, GIOCondition events, GIOFunc func, + gpointer user_data) +{ + return io_glib_add_err_watch_full(io, G_PRIORITY_DEFAULT, events, + func, user_data, NULL); +} diff --git a/src/shared/io-glib.h b/src/shared/io-glib.h new file mode 100644 index 000000000..1db6fd468 --- /dev/null +++ b/src/shared/io-glib.h @@ -0,0 +1,20 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * + * BlueZ - Bluetooth protocol stack for Linux + * + * Copyright (C) 2012-2014 Intel Corporation. All rights reserved. + * + * + */ + +#include + +guint io_glib_add_err_watch(GIOChannel *io, GIOCondition events, + GIOFunc func, gpointer user_data); +guint io_glib_add_err_watch_full(GIOChannel *io, gint priority, + GIOCondition events, GIOFunc func, + gpointer user_data, + GDestroyNotify notify); + +bool io_set_use_err_watch(struct io *io, bool err_watch); From patchwork Sun Feb 9 10:46:03 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pauli Virtanen X-Patchwork-Id: 863913 Received: from lahtoruutu.iki.fi (lahtoruutu.iki.fi [185.185.170.37]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0FD6B14A629 for ; Sun, 9 Feb 2025 10:46:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=185.185.170.37 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739097974; cv=pass; b=CUBbI0s7cWKKmjjzFTi3vp16mRpAWTADwvuzFeeM0KiaQOoY+Qh58vSLW9/NHr6kSrI5O7g7RXToKajXzQE2GtWSKE9Jk/kqtqtTnCn6OaUkiMxuYkYjCLC/zduP/zZKPtfLDuslk4hWc5Bz8fhdXe078mazx7N15WVQUWzaBi0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739097974; c=relaxed/simple; bh=mvja9cXuX/DndPeaRfYyBZzgApovluAXI+mIGSOfxZ4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ge2k9nbg9l+5NIvJBxQlGH4mxAAnLgY1VV7OPB3LJOMHm4R2cCyCPW0tKsLHaW3XDf28tr16jmhoKHG8ViEWPTbLr4ZLdJeq3guPDmZXPQuDdDu7ZnD3WQVcOGddjrjvAwdnmu1hae8sWQdGwS7dQjJNKb0a9YZKddpPb+xDPzQ= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=iki.fi; spf=pass smtp.mailfrom=iki.fi; dkim=pass (2048-bit key) header.d=iki.fi header.i=@iki.fi header.b=rVtn1Tzi; arc=pass smtp.client-ip=185.185.170.37 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=iki.fi Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=iki.fi Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=iki.fi header.i=@iki.fi header.b="rVtn1Tzi" Received: from monolith.lan (unknown [193.138.7.198]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: pav) by lahtoruutu.iki.fi (Postfix) with ESMTPSA id 4YrPWk4tBKz49Q9m; Sun, 9 Feb 2025 12:46:10 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=lahtoruutu; t=1739097971; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=87ZuCSiXMTkyJTWaEge2LKjcBHAYx3Qm6zdpXOXf4NA=; b=rVtn1Tzi7Y+H8XSlaU4NgkpcJGJmWLW7furTE8/5YIxVzoFwMljAf5v5wZK4WE9v1qHaqA n77GfgZVtNMg8IZovyzNaLT2Gav00D1lBmBWbBzPkOQ8uiKAIlVf4212tWsykrvcXFXogB 0+VQEh0MBvG8nANkqjyZaPjIiALVrlMtTsWaEnpvkGj8IkKH1cZjeEy+pmwRZ0sRAV7P5T RWfSEL8LzodMCEMqJ1jlAqThq0WZGYguuyoUobOv4bhWhfS9tGBA++blj04oyClXDLBt2L +03sV7b4XpDRtbkFd9wP7BCHMUB2cAm5chYkSgEiluj4QwmNLQCkCMFHE7xSiA== ARC-Seal: i=1; s=lahtoruutu; d=iki.fi; t=1739097971; a=rsa-sha256; cv=none; b=Oa5OntCimhLEHVtoybLI7+EZt4MKhdGSkuv+4AeV5s1neyqBrSd+VLmTBuy+g6V5WC8mDs 0iAj8U/QilluW0QKXmnYYWTY6iUsaW9gfSFURge3h+0P8orVl1BLQNntjmLZU9sjBkBAXr BF9Kqf3pDjzIJnwpZYt3AopPBcceGLfhV8YmUzfaQ2FJV6g3gqdKcarmetALWYBNMnFBFu wSvnwYhFJNbUly3ThRqGPAO1wMgaL1aKH+NDAjkB/JJNmeeUfGzHbKxFXjM7Udo4eDsrAm LJk7WHVFFCgNe+QP1JFBBM2euzEQYl4M5H4jx+NjTH4ub/y+cJcRUijMzpZovw== ARC-Authentication-Results: i=1; ORIGINATING; auth=pass smtp.auth=pav smtp.mailfrom=pav@iki.fi ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=lahtoruutu; t=1739097971; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=87ZuCSiXMTkyJTWaEge2LKjcBHAYx3Qm6zdpXOXf4NA=; b=rGoQOqUDPVlpXHo90LR0HWMTBWUqDJWiZ7rl5KhLyX5r3iH+iWm6DBjsckirAnPpdtTRwC UINFHzo8OISVJtcVlmwztdkW37wSxxcgZHXyJ7DROf/wl9HfTIf3po+q34/ms2EetZCLlZ vh54NemDqUhQRBgeYFXNr1aHlXPYqT3OW9nJl2OijL5LE5UngTPsnCVV9o3jKo4pR1TH4P kysPawT/yJ0ESUyBgaYqd1IyKj8aK31cvnZZmMy4DTPhVRS+10/Rt9mwSieisFRDPmomT5 vTCFZy8CfNUtojyAeH83+iWEl/3eldoVcMK8qQAaTwnJN1HQNKKnsSczB4HWAA== From: Pauli Virtanen To: linux-bluetooth@vger.kernel.org Cc: Pauli Virtanen Subject: [PATCH BlueZ 2/3] avdtp: don't consider TX timestamps as errors Date: Sun, 9 Feb 2025 12:46:03 +0200 Message-ID: X-Mailer: git-send-email 2.48.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Use io_add_err_watch to avoid considering TX timestamps as errors in the transport io channel. --- profiles/audio/avdtp.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/profiles/audio/avdtp.c b/profiles/audio/avdtp.c index 80fbe847e..94abe311b 100644 --- a/profiles/audio/avdtp.c +++ b/profiles/audio/avdtp.c @@ -31,6 +31,8 @@ #include "btio/btio.h" #include "src/btd.h" #include "src/log.h" +#include "src/shared/io.h" +#include "src/shared/io-glib.h" #include "src/shared/timeout.h" #include "src/shared/util.h" #include "src/shared/queue.h" @@ -866,7 +868,8 @@ proceed: avdtp_sep_set_state(session, sep, AVDTP_STATE_OPEN); - stream->io_id = g_io_add_watch(io, G_IO_ERR | G_IO_HUP | G_IO_NVAL, + stream->io_id = io_glib_add_err_watch(io, + G_IO_ERR | G_IO_HUP | G_IO_NVAL, (GIOFunc) transport_cb, stream); /* Release pending IO */ From patchwork Sun Feb 9 10:46:04 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pauli Virtanen X-Patchwork-Id: 863640 Received: from lahtoruutu.iki.fi (lahtoruutu.iki.fi [185.185.170.37]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 370123FD4 for ; Sun, 9 Feb 2025 10:46:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=185.185.170.37 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739097975; cv=pass; b=nVkfe9lWDwHHnBeYD4TkbFu+GDGYyIkCum4WzqTuHsWgecgH9K1jGOyib06q+GL+D+NpFVJLPAhDHnNx10gYeFK3JAccKgphC4ELacT1PdF+LyD52pqvg7ev6wiQ01cW214OuPJhCkCPtHOZkFb2jbnlW4M9Y4NAiGIUCtjhYlY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739097975; c=relaxed/simple; bh=UKERzn7VqxK7mUEkXhWD3RABhZzsc+GIC8M4m8E97nQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ij43WSqXzv+vyG7vYzjlsbXF3Ddj2JvCLdo9nhbbTflB1pSDk/MOh/WbnT2AKbpE7I4AE03v/89NhBuuIkaDFSh94npm895/qtc1wXI3sY6yhlvoUgo97om+7v62hQ1iw1mrNUy/RD4ABMBA0HpufufAgo3IbTrZPnFjKFEmrog= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=iki.fi; spf=pass smtp.mailfrom=iki.fi; dkim=pass (2048-bit key) header.d=iki.fi header.i=@iki.fi header.b=oBTDxL0X; arc=pass smtp.client-ip=185.185.170.37 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=iki.fi Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=iki.fi Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=iki.fi header.i=@iki.fi header.b="oBTDxL0X" Received: from monolith.lan (unknown [193.138.7.198]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: pav) by lahtoruutu.iki.fi (Postfix) with ESMTPSA id 4YrPWl52pKz49QC9; Sun, 9 Feb 2025 12:46:11 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=lahtoruutu; t=1739097972; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=nEGU5/W8/XopXtFn6EtYW0PWvNEV0XTXVX09PRQkiSU=; b=oBTDxL0XqJKVG1qMpGT5fOVS69O33DVlGievlC4udB1hA99MEwygl2hJxv/lUHlrn7FKd0 7vE3i+NCBX2DTqhQ1mp9n0bQW1WNNDMNVCNJiRBudNFOXoGX2BGKFGz2Uuvjm3my8mzN7p xcKRieUTUzRWi+1QO97AWnma9aEltd7QzACCpQxxi4gIBlh7jauFVZm5asZ6guQSDxvqFy 70z4owRYbceagjUN8yHVYv3mOP/IEhBoSu6ClandG21Q3F760IQYKX5ZusDxBGD5CRbAqx XszNc8JYc0oj0koq0VSk5KWcXDv7TskFJh9MSCam2e5rXcJF04yVsyXoS+eSAQ== ARC-Seal: i=1; s=lahtoruutu; d=iki.fi; t=1739097972; a=rsa-sha256; cv=none; b=oDexGiWS1JPAut8IKwG6r4hu7pTi48o+rtlH2ZZ9ibOWWz2C37FWq0aYnS980rQkra/mAn mF/FNWLGJyvGSYYjnaEyqHj/TsTPVCYd0PZKghFGgVpUnCZAjO7tIYRd4SEvbz8ASNK3nf hIVUNO1ZNx42TotJEntGlwyFfnSgEsAtURckuTVVb8NObhq0qhzE7gdUjTd4JNZQmTNK4L inzPXTY7nZfS/QIs4siZDVxdRjMUPVdMA86CjTc7hu+/1HxcwzHlsvn5xiBRuTXrjGP/t3 AhvMOpWTdm03P4UDzPY3z3/4gOrek1QWaVpHVdVwiR47so78k2PHZCOJmYcwcQ== ARC-Authentication-Results: i=1; ORIGINATING; auth=pass smtp.auth=pav smtp.mailfrom=pav@iki.fi ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=lahtoruutu; t=1739097972; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=nEGU5/W8/XopXtFn6EtYW0PWvNEV0XTXVX09PRQkiSU=; b=leUb4b6TIrTeoVa1532uERqmHaHFHIVwJ6FOYZWJp924rNGDyrPYlU6/yVawZ8aZybyKpD vIMrIjEegpLO/pTrZZp2HYOrpzPFBhxIRxZmeHQWnnHQ5G1PRuR6SWf/HBlriioe32ssMT Uo+Qd+PlGiA/0U/NqJVDMKrIztj+LupJjTKYS2fvBQNlr8w8/tnPTbrQVIpzuVU97qhGrG n1FnpTy2o6zic4K2XLO2rTXjpEDhbtE+Sk0Htlb6vaKYTKujHbQ9YSUVGdVnN9xo9mIcGi 2pZj/8CsMVtS7TWiwNW7l9HyX9+hIqYUotMQxv8FQtYX36fpiWfULU8Ou7+gWQ== From: Pauli Virtanen To: linux-bluetooth@vger.kernel.org Cc: Pauli Virtanen Subject: [PATCH BlueZ 3/3] bap: don't consider TX timestamps as errors Date: Sun, 9 Feb 2025 12:46:04 +0200 Message-ID: <002a6059d976c202ca7da648025bb4ada7388313.1739097949.git.pav@iki.fi> X-Mailer: git-send-email 2.48.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Use io_add_err_watch to avoid considering TX timestamps as errors in the transport io channel. --- profiles/audio/bap.c | 14 +++++++++----- src/shared/bap.c | 3 +++ 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/profiles/audio/bap.c b/profiles/audio/bap.c index 77df9455a..a1947f9cd 100644 --- a/profiles/audio/bap.c +++ b/profiles/audio/bap.c @@ -39,6 +39,8 @@ #include "src/btd.h" #include "src/dbus-common.h" #include "src/shared/util.h" +#include "src/shared/io.h" +#include "src/shared/io-glib.h" #include "src/shared/att.h" #include "src/shared/queue.h" #include "src/shared/gatt-db.h" @@ -2059,8 +2061,9 @@ static void setup_connect_io(struct bap_data *data, struct bap_setup *setup, return; } - setup->io_id = g_io_add_watch(io, G_IO_HUP | G_IO_ERR | G_IO_NVAL, - setup_io_disconnected, setup); + setup->io_id = io_glib_add_err_watch(io, + G_IO_HUP | G_IO_ERR | G_IO_NVAL, + setup_io_disconnected, setup); setup->io = io; setup->cig_active = !defer; @@ -2119,7 +2122,8 @@ static void setup_connect_io_broadcast(struct bap_data *data, return; } - setup->io_id = g_io_add_watch(io, G_IO_HUP | G_IO_ERR | G_IO_NVAL, + setup->io_id = io_glib_add_err_watch(io, + G_IO_HUP | G_IO_ERR | G_IO_NVAL, setup_io_disconnected, setup); setup->io = io; @@ -2797,7 +2801,7 @@ static void bap_connecting(struct bt_bap_stream *stream, bool state, int fd, if (!setup->io) { io = g_io_channel_unix_new(fd); - setup->io_id = g_io_add_watch(io, + setup->io_id = io_glib_add_err_watch(io, G_IO_HUP | G_IO_ERR | G_IO_NVAL, setup_io_disconnected, setup); setup->io = io; @@ -2842,7 +2846,7 @@ static void bap_connecting_bcast(struct bt_bap_stream *stream, bool state, if (!setup->io) { io = g_io_channel_unix_new(fd); - setup->io_id = g_io_add_watch(io, + setup->io_id = io_glib_add_err_watch(io, G_IO_HUP | G_IO_ERR | G_IO_NVAL, setup_io_disconnected, setup); setup->io = io; diff --git a/src/shared/bap.c b/src/shared/bap.c index 6ffeefa41..b24566c88 100644 --- a/src/shared/bap.c +++ b/src/shared/bap.c @@ -20,6 +20,7 @@ #include "lib/uuid.h" #include "src/shared/io.h" +#include "src/shared/io-glib.h" #include "src/shared/queue.h" #include "src/shared/util.h" #include "src/shared/timeout.h" @@ -2652,6 +2653,8 @@ static struct bt_bap_stream_io *stream_io_new(struct bt_bap *bap, int fd) DBG(bap, "fd %d", fd); + io_set_use_err_watch(io, true); + sio = new0(struct bt_bap_stream_io, 1); sio->bap = bap; sio->io = io;