Received: by 2002:a05:7208:13ce:b0:7f:395a:35b6 with SMTP id r14csp85855rbe; Wed, 28 Feb 2024 13:03:09 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUmxU13RtvA1bDbnYpSCCAO9uj1Kl1MNVw19EOL8Pbu/lF2wrBFHTls+jYyPsJsSB8kUK3M+jL2fmke8AssYV3XCnbbLQqD3zdygVHo1w== X-Google-Smtp-Source: AGHT+IHsGSoJOuhcI/H5jeQPUJ5urKsq31PuQrc6e7pvdNhUWyBHxiVtgq/0aE7ADEonOZHnaoXo X-Received: by 2002:a0c:ef0e:0:b0:690:3c85:c5c with SMTP id t14-20020a0cef0e000000b006903c850c5cmr247168qvr.46.1709154189022; Wed, 28 Feb 2024 13:03:09 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709154189; cv=pass; d=google.com; s=arc-20160816; b=LrEAgnBV+zY8ACKeiXJd3qOcQG/EBSgir0j55asJTwOgcnAk/PjsbIr8qiv/ouVoqG v5EJX9AqobdvKlt4zi4eUAEIVfFU+GyA6AoS/49jCbxEniLgH0mOO0L7rJ1H6fF18Goc P57N0HC/AY1x5ejD+jnDgmUNtY+lt504PYpzTpG3pfOZs8y+0SRsEWfAe5Nt0qhMUV/K Fq52rgckZAlUXz2FZ7CTW9wZvDxJ8K9TOpua7rpNRlxTaiG48/6rk4S7xMCquu83/4TH 6MIjDItUxOZcBEq0+5w4yg76HVwuBxoLEMk52c8+Cq6KgPylJqZUulvLEM7vWeDKfqwb KEuw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=ocIaTqiPEIodc+sa8cxXdGWBmxIASc/bN1F+xgQreZg=; fh=fAVvqa29TMCSLQ1BWo+IkeTh9vOt2h2EvlnFWIq0DOI=; b=hkQmQXf544zgEbipHVgrORJn54pfZCe7XjwUERoW80nZLOPb5o0K+pDZkhQpoy5qiV Wp1SsvmZuRcI3oLjQCyYFzGoFnT4yz5TpGmPoGUekRa8OfFHyZodX4FdfGClcWMdSEWi ZzZMpJc6jV+xBexg4t69/6T/TOCCjXQl23NWJGZ4NanYIRWjWB8BIzMfC7B2e10W5EL0 6FWIRbE2TJ5DL898+poZAP3XmnRqJltBfLrLnpcJXnDHO3TGHEYN8lCT0nsul/aihbSd cetOFCBYe1hOS0P0gM9fVQDPCo3P6DRjtqgWrAgJJ2Y/VfhKDXmQB3ROVTVa6PUxtKBE C/Ag==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=PMc8sGQj; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-bluetooth+bounces-2201-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-bluetooth+bounces-2201-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id 11-20020a0562140d6b00b0068fd2ee2b00si372813qvs.19.2024.02.28.13.03.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 13:03:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-bluetooth+bounces-2201-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=PMc8sGQj; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-bluetooth+bounces-2201-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-bluetooth+bounces-2201-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 97D021C273CB for ; Wed, 28 Feb 2024 21:01:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8DFE086258; Wed, 28 Feb 2024 21:01:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="PMc8sGQj" X-Original-To: linux-bluetooth@vger.kernel.org Received: from mail-lj1-f181.google.com (mail-lj1-f181.google.com [209.85.208.181]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 339398624A for ; Wed, 28 Feb 2024 21:01:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.181 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709154096; cv=none; b=YoFVjQ3lUfA5T2iCyVsuRBuazdJhkHZNXAb1OymwOmDn9EDyoTNiRE65RKHiWvSk1dNcfbNZBN2U9C5gWYY7ci7G7V4Zqi3Bw3K8s+DRSTQilsJqrkI2ObzxEQ3t5n3fsK93vX7nftEE+OAT8DHv5BucZvUXnUWosmepZj+czpE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709154096; c=relaxed/simple; bh=oGyxVTyJeFeGaaCfU5DG/l5Y15GiqrS3cjAPgEoTMXU=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=WhR1fcvevO42XdelRwt7xYVtFSA/Too95O/yvfHZ4FS9xsDY//DhoaPyV2EzvIKX3yLLu9qTL27Z0UzpigMYpcSGjEMPaTdCjx32vH14J5I5CNyUBcBUB7Z2maw7w++mJJGlNakHKPdOI29rhIZa3od6kKhxnF8KM6tBjDaN6CM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=PMc8sGQj; arc=none smtp.client-ip=209.85.208.181 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-lj1-f181.google.com with SMTP id 38308e7fff4ca-2d28464c554so1966201fa.3 for ; Wed, 28 Feb 2024 13:01:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709154092; x=1709758892; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=ocIaTqiPEIodc+sa8cxXdGWBmxIASc/bN1F+xgQreZg=; b=PMc8sGQjAYSCTHLIunobOUngkFDCQ8EgGiFSfkvHAD2TlEvun6RhwvI7DplhoL7JMf wvJWElchbG5gDpHIGgV3ci2+YUZrbYBvFXH0brdfaZH8FsYWe8Mwa+37uYOXoelQEKcZ JyzPmh25mzCnDDSvM64wHJzpYq2dB76JT2o0TOw9sH5W0OAvuOuh7tkiJVmtuQa9hzzN 35B5MPjNsypI8Yc0Ht65aZ0e4o9JAMwZO/eawLlV/VeB4aPz/4hypQRoiG2zPG0NGM7/ TNSjwLO8dkfBgmwNpouF/HDDYW9yYFofnkvv6JaF+xk/m8LzfPSkjEqHJjqNnUPEOvEE 6FJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709154092; x=1709758892; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ocIaTqiPEIodc+sa8cxXdGWBmxIASc/bN1F+xgQreZg=; b=NV9MY7n++gUwGY3fQOeStBkQatb07HcSGXzoTCvQwR6nmBbneZvJju0W5kZAo0/M9L luoQAZB6smsDZElqjYsX7zgrjZCn5X5kHRK0oatDVQcwO1NSg4YQKAVTCgc5GINX2QZw edaSSKOctGY8ZlbTFE0PFw8/biWG0yVpr/RwV+NvOQDmw9ORr5xqE2MYt87erWQC/CQK kv9GKkjH6tlElPUpb6sIwhmimT1RNknpiyEzfHqcSnJVkOm77ZyWQdStW4H1j3+Eme3z gg0RdIhEqGV4iMxLSvQ/wfI5gloXm9azb2KCw02d1AFrtx117vWfXsXhVN0e22//WRRn r1aA== X-Gm-Message-State: AOJu0Yx0X/e+4tjvZ6OX69+R6i6vDOJQfQIBRMpQFsw5/YyU+vX5HZcM CaPMhjlfn4c+Ik7VrF9IR9r2QKMD1Q9aXTLKGWLIfH3o8ZMXlpce9oQLB60cbK3ejKhJppGlW4Y jL698M5N4XeVXc8oqCQZQTQoMMp8= X-Received: by 2002:a05:651c:140d:b0:2d2:a19a:8625 with SMTP id u13-20020a05651c140d00b002d2a19a8625mr24383lje.40.1709154091974; Wed, 28 Feb 2024 13:01:31 -0800 (PST) Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: In-Reply-To: From: Luiz Augusto von Dentz Date: Wed, 28 Feb 2024 16:01:18 -0500 Message-ID: Subject: Re: [RFC PATCH 0/3] Bluetooth: add transmission latency tracking for ISO & L2CAP To: Pauli Virtanen Cc: linux-bluetooth@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi Pauli, On Wed, Feb 28, 2024 at 3:31=E2=80=AFPM Luiz Augusto von Dentz wrote: > > Hi Pauli, > > On Wed, Feb 28, 2024 at 3:11=E2=80=AFPM Pauli Virtanen wrote= : > > > > Add ISO/L2CAP socket ioctl() BTGETTXINFO which informs the user how lon= g > > it took the kernel and controller to complete their sendmsg(), and how > > many sendmsg() are in socket and controller queues. > > > > This currently provides information of the latest packet only, in > > principle there could be a ringbuffer containing few latest packets, no= t > > clear if that would be useful. > > > > These patches allow fixing / working around controller(?) issue where > > two ISO streams in same group get desynchronized. Having accurate > > knowledge of the packet queue lengths, user application can drop packet= s > > if it detects the ISO streams are not in sync. > > > > Pipewire side: > > https://gitlab.freedesktop.org/pvir/pipewire/-/commits/iso-ts-test > > > > With this change, https://github.com/bluez/bluez/issues/515 is more or > > less fixed, and the sound server can figure out the total latency to > > audio rendering (tx latency + transport latency + presentation delay). > > > > For ISO, this can be changed to use LE Read ISO TX Sync, when the clock > > and sequence number synchronization issues there are figured out, and a > > quirk is added for controllers with nonfunctional implementation. > > > > For the L2CAP latency, I'll need to think a bit more what is the audio > > use case. Motivation was that AVDTP delay report values appear to be of= f > > by ~0..40 ms compared to observed audio latency and this amount can var= y > > per connection and time, so not explained by unaccounted code > > algorithmic delays etc. Currently it's not clear if there is relation t= o > > TX side latency, so it may be down to receiver side implementation. > > > > This needs a bit more work to figure out, but the L2CAP patch is anyway > > here. Due to the possible fragmentation in ISO sendmsg(), it seems we > > anyway need the tx_info_queue thing and can't easily do it by counting > > packets, and L2CAP required part is small addition on top of that. > > That is not how it is normally done with sockets, normally this is > done with use of SO_TIMESTAMPING which is then reported using the > socket error queue: > > https://www.kernel.org/doc/html/latest/networking/timestamping.html > > Sorry to tell you just now, you might have lost a lot of time doing > all of the changes, next time just drop and RFC early on with the > general design so you don't spend too much time before getting any > feedback. There are some samples in the linux tree if you want to take a look: https://kernel.googlesource.com/pub/scm/linux/kernel/git/torvalds/linux/+/r= efs/tags/v4.6/Documentation/networking/timestamping/txtimestamp.c The nice thing with that is that it is not a new API and it has a little bit more finer control since we can add support for the likes of SCM_TSTAMP_SCHED, SCM_TSTAMP_SND and SCM_TSTAMP_ACK, so we have the possible to instead the timing at different layers. > > TBD: iso-tester / l2cap-tester tests > > > > Pauli Virtanen (3): > > Bluetooth: add transmission latency tracking for ISO and ACL > > Bluetooth: ISO: add new ioctl() for reading tx latency > > Bluetooth: L2CAP: add new ioctl() for reading tx latency > > > > include/net/bluetooth/bluetooth.h | 39 +++++++++++ > > include/net/bluetooth/hci_core.h | 30 ++++++++ > > net/bluetooth/hci_conn.c | 110 +++++++++++++++++++++++++++++- > > net/bluetooth/hci_core.c | 14 ++++ > > net/bluetooth/hci_event.c | 66 ++++++++++++++++++ > > net/bluetooth/iso.c | 58 ++++++++++++++-- > > net/bluetooth/l2cap_core.c | 12 ++++ > > net/bluetooth/l2cap_sock.c | 50 +++++++++++++- > > 8 files changed, 372 insertions(+), 7 deletions(-) > > > > -- > > 2.44.0 > > > > > > > -- > Luiz Augusto von Dentz --=20 Luiz Augusto von Dentz