From patchwork Thu Mar 7 21:05:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pauli Virtanen X-Patchwork-Id: 778628 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 90FE024B33 for ; Thu, 7 Mar 2024 21:05:36 +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=1709845539; cv=pass; b=uc9dv8zFLybQQXPpcOTPnHcj+KFLx6PRdCetydusx9DZU95bTcyQRlRG9TQf2/3EHNY0z9f9QU5bbAySS+hpriVyIuEFy+W2IFPfwlp4t7/bOJqVkkNGahfoD2ObqkAAxogfYXsLE18nneNVXVCWXYJCGYqGukMbHtT2n42uOEs= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709845539; c=relaxed/simple; bh=OFh5/kqYpFbcslc126LjT/xNLyVqeEinMMXZRKve3Qc=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=eDVOmeEjcB1ioOjG4LnoJuaiaHrY6EabhePmI7pBWZ4PgbkmKV2ONEfWNBGYxl/yJOzthXVDPYyoUScpuV0Hq3n8foGPYVK+fApvl6nUDWiZjbJHnzOw2Oeb14F6QIwd0lV6HdAo6cUt/GmhWlt9qW0h/xVzv2fLRKRtMJUNjek= 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=ZNz+qx2o; 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="ZNz+qx2o" Received: from monolith.lan (unknown [193.138.7.138]) (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 4TrMJk0854z49Pyq; Thu, 7 Mar 2024 23:05:25 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=lahtoruutu; t=1709845528; 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; bh=bVbqdx4P1TCo/RfWrMvaMxcyABmEXbfExsJ7iknfHKM=; b=ZNz+qx2oI/dOBUSDOjqAJ87tCsA1bGNN6VCum/toiD83aI3LxwK/4E4uKc/hkGK2Yp7jlB vTcPhqm7mztogHmFjHUJNnUakzx2WPiaoYDk0fX932JnQtyFYOl8ovT7HKpgCd9lybG7Wz sCedr5YB8KOLv4ZMYk3UQRHXNtAGxgZN0jHB2OPuvfvkAhCexxVkujHig8ZT1Cemr0ghfl rqNSKoQ7phOQHi0JV74+QIaAFDumX1wRN8zm8jMNX1JcpM6SmuuP0JBj5VPRX/UU3mVC3B ZMGu5F4taXorTCFMlD/HGSWzqG6ju4Egn3A+dEftd5jJ3aRdsNIqX5zlwq+a2w== ARC-Seal: i=1; s=lahtoruutu; d=iki.fi; t=1709845528; a=rsa-sha256; cv=none; b=suuS/ZHrXrwkgvRvwCdZ8kR8B/eUpykhqywl3NvuNuYJUTMlhuv98IGzWNFytCex9LiLgJ wGItvEPCeL8lOIsuDcm9sUdXble5VSpkh6vAV1pS4d6i84evXRuNGN1Bp371rm/1schW4G E1R/7nZVMfN4Xisfd1D2vnUVUj/PozmUoGcM8i+JQwGfbku/EQrUd5V1axFdb/3KyHsfrB YFRgqXVbnv4ESlG8nxx+J3+t/Yc8QQaNMxrXh+bCa+10gJiNtt+57LBq8pTMhMZQbCYz+r 6nhbkv036BV2IiMvKta1f8xC6j/0uXpI0PMJabRCzN0JF3J7wKvJgmqphLHkTg== 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=1709845528; 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; bh=bVbqdx4P1TCo/RfWrMvaMxcyABmEXbfExsJ7iknfHKM=; b=G3jAi79WKF4sG1y9St/yQj9esnzBG52RbwLcL5oxNRfhjGqc8bbQMl7oTt9CQ9XCY70GOG 9Fe2BaprVnXQhjc97Pt3qTLog9waqNZ67WgbAFIrh1Y7uKeEJvQY2nBgrNC6fpHv510Igq uFNfX07UtKXmuWWtYbWWknvu8EGmDtw+SrYa6ZPNgt+1wab0Mv3taj3aszKCdj9cLylzQg DrdZZIvOkMR3D1E3fH+TGmtHTVm77Xajo5frWtsgyh9x2YFG9ME5nyw8MZCVcvkbPrvOWF SukcZzoG//1jRHszjxUeeKEtSyBZos/fGd5WGCakv9df8uh5KCtJUun8Q7zhyA== 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: Thu, 7 Mar 2024 23:05:17 +0200 Message-ID: <31e0a8235e5c04ad6ae171024e1127c2e7387e28.1709845195.git.pav@iki.fi> X-Mailer: git-send-email 2.44.0 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 avoids consuming CPU waking up on timestamps we aren't going to read, and also avoids 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. --- Notes: This was the remaining BlueZ part of the TX timestamping additions. Couldn't find a better way to do it, but it has to be done, so that the TX timestamping can be used for the purpose it would be added. I'll probably send v2 for the others in a few days. acinclude.m4 | 3 +- configure.ac | 2 +- src/shared/io-glib.c | 153 ++++++++++++++++++++++++++++++++++++++++++- src/shared/io-glib.h | 20 ++++++ 4 files changed, 174 insertions(+), 4 deletions(-) create mode 100644 src/shared/io-glib.h diff --git a/acinclude.m4 b/acinclude.m4 index 4b73a5bfc..6c36c177e 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -62,8 +62,7 @@ AC_DEFUN([COMPILER_FLAGS], [ with_cflags="$with_cflags -Wswitch-enum" with_cflags="$with_cflags -Wformat -Wformat-security" 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 9ebc250cf..959a27b4d 100644 --- a/configure.ac +++ b/configure.ac @@ -72,7 +72,7 @@ AC_CHECK_LIB(dl, dlopen, dummy=yes, AC_CHECK_HEADERS(linux/types.h linux/if_alg.h linux/uinput.h linux/uhid.h sys/random.h) -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..8b76348dd 100644 --- a/src/shared/io-glib.c +++ b/src/shared/io-glib.c @@ -13,10 +13,12 @@ #endif #include +#include #include #include "src/shared/io.h" +#include "src/shared/io-glib.h" struct io_watch { struct io *io; @@ -29,11 +31,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 +189,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 +267,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 +304,128 @@ 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; + GIOFunc func = (void *)callback; + gint64 timeout = 500 * G_TIME_SPAN_MILLISECOND; + 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 busy loop + * if nobody is reading from 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(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_static_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 Thu Mar 7 21:05:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pauli Virtanen X-Patchwork-Id: 778922 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 9E668139593 for ; Thu, 7 Mar 2024 21:05:38 +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=1709845540; cv=pass; b=LdIsFIvIFhHEB7Kpt9Kvdab1NY6YkYRLbwzvIm6WZigsJ2AtxvGbcSNJKj2tQKCWbnrKz2KZhyQ/v4NPl5YkG/Ms7W/bhqJrO5CxP64JuWxZQqRlL3eDIlALQuEtwy49aqZHMx4IsHKpjH6tMEqaSKAiFnrd7te6HnEPdLSM+g8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709845540; c=relaxed/simple; bh=IAsHYV/LYTKzBaMwwd5+A9Lzg8buy4fTj9sQ+ouZR1M=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Si1/vwD5Hkm+aFXXediYYiT4eDqKj8CnWinEj2pxFpqibr0wBCf5j5COGDKjeiovOKgIQY8vUk8YeP9Oa+msHVr74Fy33N4ShlnRtnLHvNOqlu7bOw8bQiY9XlfxmRuD3O/Ow+gCZRFleHL9b42lGsTNHzg8nDKJDOXAovxvmG4= 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=pfjSK7ef; 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="pfjSK7ef" Received: from monolith.lan (unknown [193.138.7.138]) (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 4TrMJn0cYmz49Q5W; Thu, 7 Mar 2024 23:05:28 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=lahtoruutu; t=1709845530; 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=JOIgGDjdtARv1sonRymvnJtC1V7OjFeJnLElmSYoZaU=; b=pfjSK7efGjO0iSWHqCEW2rLYoBfxzW8bp/TYkVxodz37t5uCtuaqiHCPNiPFKwxxYR8d+f bJn48Tzh+eYLAZhEYbSoibmT+ZQ9ViI294bplz3IxIZISMpv48F/TlIar0fR/CvNEHy/nI qn/e9x9YpQ4aAc/qcV3T9u24Q3m1U6n5+9Iab1ZPoV2hHopj2NvIYknr1FuTiuR6YoUwM4 U6wHbOPOzcYNyppv7SQp6ty6ifTGT0oByWfE/eHOF8eCq5liMuiFhZG/YcIK2JScH3FiYc md7p+CWfhZ+m9y5fgIPrxPN9xuksCTCDwYfXk6Jl0zvHmhLgrfIJubMOWI2CCQ== ARC-Seal: i=1; s=lahtoruutu; d=iki.fi; t=1709845530; a=rsa-sha256; cv=none; b=rJl8Uxghp4+Tcn2ZZwUGmU7qH1FCbHgF9zgr9WXlgpFuJZBXa8xa1LZluMcVtk6/UqIg4d BrLgmwd5MQgVWoQhEBlRODTxSb14siT2WMJzXl2/reRB3njwtu9Gk6g7zX7vwhgHYcblMV mh40fxu4csjzpay6pn9xnwHyr5nW9ZCrT978Oj3j72/v3l85UL0jhFzwzUE10vQNf8Pa5C mWSEDeP+X6LFKPS/GMqJsDd4kTU/Hw4w8WjDfPtYyEliBISEoNqUTXYIb3Pk/USt9wGUiq XyGSnIC73Sff7UYlpGRetEyQ/tyD9Db+wk4IGq+eC7Z5lX2eAAf9zvUmzXUYug== 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=1709845529; 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=JOIgGDjdtARv1sonRymvnJtC1V7OjFeJnLElmSYoZaU=; b=PhTJXURFlBm0PQ9EasTA9UmtdHqt7dutbVc9zSVuRHF1x6ecFrKxQgavXhmASY1NQyRZvd ++6kQ/VJn0sCubjTgDnBCROIhpWp+n5CCmY14etjIiTURiBWrIJZS2o/OzNGn0BWEf9zx9 UJ6azo+AnW6YKAn4HQcN24doUoaCvjXDyMwDlCPHPnsWfn2jSdbgmtlYlg5XJx2gGz1Dro d1j8/BrBPtqWFXIaS/91mphww3UU89TZK1OzXTRM3AeDtvqwXLoQy7MY0dRzNa6BQHhF0r Nlr/Oc9o5QAc8JXITONOGBDVxMIbYKWW8VyxlndmCdUvjVbUlyNqCgl0bTXM4Q== 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: Thu, 7 Mar 2024 23:05:18 +0200 Message-ID: X-Mailer: git-send-email 2.44.0 In-Reply-To: <31e0a8235e5c04ad6ae171024e1127c2e7387e28.1709845195.git.pav@iki.fi> References: <31e0a8235e5c04ad6ae171024e1127c2e7387e28.1709845195.git.pav@iki.fi> 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 3667e0840..16d7f7385 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" @@ -862,7 +864,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 Thu Mar 7 21:05:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pauli Virtanen X-Patchwork-Id: 778627 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 EAB0C13A241 for ; Thu, 7 Mar 2024 21:05:38 +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=1709845540; cv=pass; b=buM69iw5Ba9HOxabUCL4igA68hdOEckj/l4dmMcUxSIr2WuFM8AlZTVp+F07mggrScfXc8TkfeY5Ft/Xg65NaH1E8ZhjLjOXMs3nzGD7FilNS/CpjdiyUSZAsbiGsVSirkYoncF4eyMPmrjhynSAbKFZsBHmE5QuhHyzahBg0Ps= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709845540; c=relaxed/simple; bh=kIYYQGLmNPp2WNpWvzPG4CtlthVNTYHGmm6CF6qIPno=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SrKW1xkre7m1yhVENskNFyPiMrZ1xb9Crsapr2LfCCuuR31oxKofOyCrTkZBlNtmYz8KgrpUTW5R0PuGLU2WF1dE/PvHnJ7N5IGCi0fa7NTFgDJtVWG8j0ok2fdmVfSEF8R0rpQSLlgjLFKNe0iiFndzK6Mz0ungbYRSe43sInk= 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=bCPbRWKB; 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="bCPbRWKB" Received: from monolith.lan (unknown [193.138.7.138]) (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 4TrMJp3QsDz49Q9c; Thu, 7 Mar 2024 23:05:30 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=lahtoruutu; t=1709845531; 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=29R2t663xB73jCCUaDJoPS+ed3MKJ/TFk0HB3rSXttw=; b=bCPbRWKBiurFsClbGQPtZKz0KGeqpNJpiSgtCwRFn4ks94DL48mhSXGbgdSfY8zXPCZbxc szjOGK5iOvV6MjqS7DZNw5M3vO3RRNxxaFZfm74l/gf4/YpDJUTiRFneovgylTri6quhkS LVkKlrWJo/IhLASFyTzDhP1BIuC3w7WigdM3NJ07mezJGxs1sGCuaaq/zhCOgsdu4b8OGq Kjbky7PhlixxwdcQo3hBdqSuXpMlfz9r1W2em/ZS/FyrBntxQj5Nv3zY9NqfMnd6Aff4q6 RioTAjKkjiGN8fOgqHCCntstA+931QyZWdtkhUq6L/c1+b/Epin8ziDixq3ezw== ARC-Seal: i=1; s=lahtoruutu; d=iki.fi; t=1709845531; a=rsa-sha256; cv=none; b=qbrT+2bWZOCbyJfNkIWXo3DPWzZuw4GcyV7aqDmJX6tzCRCYnjriQm7eieTvjCisd18Go6 wUoZx2EBBUAqDeKXqU64ytTIoihnywXuDCY4Sf4tVo+7XIynzerCDq92xvMMNjYlRvkTUo UekFdeFjWLJff+O0RJ+Yv9VH8MQB2Y8k6vnxsRKDCwceSBHKBAf1UunoNI6iWsLZO9+EKh 6lvMT0usJYPMevQPlJ6U/AuX/BaBrtTayo4EpE7xVE2vsFUWEMEYZty7DSyJz3IU6wiw0H kaiDNhJuGTDIQqeWCVl44db0d9lz7ZuGWt4FD5m+wQk/ZnhRCBZQBQM8Iqyz4Q== 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=1709845531; 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=29R2t663xB73jCCUaDJoPS+ed3MKJ/TFk0HB3rSXttw=; b=Nl3BIVgJJ+e/tbPlBphXbvK3XfDY+w6LNlYs1nSJL7Ps5fr+Z9pstbAQBz9uH5ftSUrhQ7 DaXxyP0cXwSSVkBJbXwT8mQJgj2YCn8trt+5fRzOnZnIydKGQ0HBVFjkP6oqeIJrs+Il9w xe/3sxrpISotJM/KP6sQteXN2llLf5nDr73ihyZ7obOgyiGYbebr1++szyPEdRS322PCFD +JV6EieYKfHJKwDuHId8wx0vt0rsprnkfLspCtqz+M7QxIWFK2eSnDJrhgmu0UaoLQpd9S Mvcnz2X+QqQs+QXtyluzDfs5b5oTk29fFuJDs4F4cRwqL9+YzAEd2ZELjrBuYA== 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: Thu, 7 Mar 2024 23:05:19 +0200 Message-ID: X-Mailer: git-send-email 2.44.0 In-Reply-To: <31e0a8235e5c04ad6ae171024e1127c2e7387e28.1709845195.git.pav@iki.fi> References: <31e0a8235e5c04ad6ae171024e1127c2e7387e28.1709845195.git.pav@iki.fi> 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 1b8a47c52..3ed1ed750 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" @@ -1867,8 +1869,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; @@ -1925,7 +1928,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; @@ -2558,7 +2562,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; @@ -2603,7 +2607,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 37fc1de4e..128d98b6a 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" @@ -2130,6 +2131,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;