Received: by 2002:ab2:6a05:0:b0:1f8:1780:a4ed with SMTP id w5csp1134866lqo; Sat, 11 May 2024 08:46:14 -0700 (PDT) X-Forwarded-Encrypted: i=4; AJvYcCXec6RKHOdmWMxpVSuYMdy+wtP0NjoJ9cdnkRdQnD4CgjS2mtJ6VrYJ0trToi0FGkvDp6PUYK8/fDrn3USVeY6p98c3YwlzTF5cmCjAcg== X-Google-Smtp-Source: AGHT+IFiEA/f0/3Erkr4Hkyyxb4Fseb9Y+qzqrWZWmZO0Dh7A48y/+ZGAv26+YJcoXeTnARMamkx X-Received: by 2002:a05:620a:280b:b0:792:ca33:586e with SMTP id af79cd13be357-792ca335ac9mr535098985a.12.1715442374630; Sat, 11 May 2024 08:46:14 -0700 (PDT) ARC-Seal: i=3; a=rsa-sha256; t=1715442374; cv=pass; d=google.com; s=arc-20160816; b=s3bRANw7GeQOmOLAY4/HaighPQ+maEzxPcoIA94tB/a8o/Y/knIzgRF7NKYS74x9Kn MJkt6YXF924QXYB0ZPSpiwU7Zh8hTKurQ7/f0ow5yqgz/5BVPj0CDQtg2V9mtg9XdeHB pyV1tZgLkBAWxQpwzZAEV8BGAI9yfyNQlWIVIwwPbmGvANhM2vuNePLICUG09f44nKYT joFMuMko9r24iHxgoceMfhYUSqIdRKaNqVjSwLtTFswETHQLPxxj7agdhKgGAHbWEQyi Ld7uuNUtoCmIEuoGCrTTBFZqgCPrd7HM/Grdw49Fu+76+E9hzFn9yJSQs3q62vC+gFtg 7hjw== ARC-Message-Signature: i=3; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=63hYYxxOXAj5pGWQjGOgvxg1+q5FqcuGoXtKoPNJmXg=; fh=ExGhjNQEFJgRqHmYATVc5UXZbS7abAmaHDitrfHKOuE=; b=foSTU/O5r9lGC57oxwU99m+pCLhuE7+K3DDjelRpD/pUh87lnjbnNokwWuNkqOTnol zlV0UAzt/8LlBvSmAXrIdnQ4x3zy+E7pznwjcxmx1N1qqK1wDu/UH19MPAcg8rXKubmW c93C2eEOCfWXAF/zTNt9ofJABNKDA0N72gyW8OIqSwCuYbDmWIntdIHlQLsLQsx0YUMQ wYC3gKBmh041UJeAQTvoePXWLm2WWO17CZQiXx0rglrL2FHlq6a03LRw3O33CIEeo9yr nJlD0D8NOLTkPmIdl8n7IF+fuOnpcoLQu1Q5rylgGZJVBOrH1S2WxtD9qA++hkVA5YRN HIYg==; dara=google.com ARC-Authentication-Results: i=3; mx.google.com; dkim=pass header.i=@iki.fi header.s=meesny header.b=NxyM6k4Z; arc=pass (i=2 spf=pass spfdomain=iki.fi dkim=pass dkdomain=iki.fi); spf=pass (google.com: domain of linux-bluetooth+bounces-4536-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-bluetooth+bounces-4536-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id af79cd13be357-792bf2783d1si569600385a.115.2024.05.11.08.46.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 11 May 2024 08:46:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth+bounces-4536-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=@iki.fi header.s=meesny header.b=NxyM6k4Z; arc=pass (i=2 spf=pass spfdomain=iki.fi dkim=pass dkdomain=iki.fi); spf=pass (google.com: domain of linux-bluetooth+bounces-4536-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-bluetooth+bounces-4536-linux.lists.archive=gmail.com@vger.kernel.org" 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 3C9761C2093D for ; Sat, 11 May 2024 15:46:14 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0B0D95674A; Sat, 11 May 2024 15:46:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=iki.fi header.i=@iki.fi header.b="NxyM6k4Z" X-Original-To: linux-bluetooth@vger.kernel.org Received: from meesny.iki.fi (meesny.iki.fi [195.140.195.201]) (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 12BC65646D for ; Sat, 11 May 2024 15:46:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=195.140.195.201 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715442368; cv=pass; b=O9D0Oz9Eanrg716X7wxHdLa0BVWOMTpx52plcHXPneGxXkYX+xojMLNxPLRdImyTZdhPVops4qJ9XkAQ78V19NsnaegNSAjda44+rJ96ffazKiVvGMIUoXMeSpI9PQrcLveTPma8HGnTzttlswmhRGbMbQFwQ0Qn08Bz/E270Y0= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715442368; c=relaxed/simple; bh=DNDdV6qEDdc+jSB+VvzTITXFustcYNvjxqZRUv6iPwM=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=oUicf+d/r52yKy4KfCYXi6eGUqGsx07A/ucy3UGVHtaJR36sRCFhK1TyGfYGsZD4xWz8K+q5d4d9AxR1TgG8/J9HqDdDY5bOcHc7+UWhOrWe8WB4kwE/+eKGXzrhdzCR9Rv4SMdOmw6cIIVPSAohHsjAYnIolFGPURRpccXXucs= 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 (1024-bit key) header.d=iki.fi header.i=@iki.fi header.b=NxyM6k4Z; arc=pass smtp.client-ip=195.140.195.201 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 Received: from monolith.lan (unknown [193.138.7.158]) (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 meesny.iki.fi (Postfix) with ESMTPSA id 4Vc9835wJYzyNX; Sat, 11 May 2024 18:45:55 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=meesny; t=1715442356; 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=63hYYxxOXAj5pGWQjGOgvxg1+q5FqcuGoXtKoPNJmXg=; b=NxyM6k4ZUefGZPIIetEXoatG2MboRlIqVY5cfcUPgB+v5jc5rrKIZ8pAfq8daAr+HNaway RTBSXZGguR945txSxc96GrKNzJPxg8z2jOZ5FgYqxvjd2B7bZvC6K4CPdPupCo5AYmK7/2 vcZE3kooOxtk+HqXWCNGX6E+2mYKLfM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=meesny; t=1715442356; 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=63hYYxxOXAj5pGWQjGOgvxg1+q5FqcuGoXtKoPNJmXg=; b=Hv+n04Mjmvrg8hWWLvd3vkbZrGJ9Gd3VVetBXm19WOyS3esceQDwaM6LZFrxLbgxkS29Xd ghWqwPm/CbeKHq1k2mkOLqO/ZYXprm2ILJNYc+AauX3RfCM0Rq31aWRQzcr0+NyydvV+1T 1itwUq3I24MtQiPOOC5R/9l856V8A5I= ARC-Authentication-Results: i=1; ORIGINATING; auth=pass smtp.auth=pav smtp.mailfrom=pav@iki.fi ARC-Seal: i=1; s=meesny; d=iki.fi; t=1715442356; a=rsa-sha256; cv=none; b=YXna0DM2yOTMikJQdQKV78psI6J7SrqQoKEnIwc2dMYxENTpfsaMKMyJNAy/Ad75p+XO2c j0DeVVqD3mc7NDuV1YzADG65jrVfzqtsRPVDmZNQN2RfqA8oKjSoEp0guv5LpDHvrTbrON 7scCbn6U7Tgmk+lLuVuF92vpiLXIzoc= From: Pauli Virtanen To: linux-bluetooth@vger.kernel.org Cc: Pauli Virtanen Subject: [PATCH BlueZ v2] client: fix ISO send data rate Date: Sat, 11 May 2024 18:45:46 +0300 Message-ID: <30fd803be62f762706486698821e9e5fff2d0b63.1715442270.git.pav@iki.fi> X-Mailer: git-send-email 2.45.0 Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit We are sending data to controller at wrong average rate not equal to 1 packet / SDU interval, if Transport_Latency is not an integer multiple of SDU_Interval. The calculation currently may also give zero, so no data gets sent. We are sending data in bursts of num ~= Transport_Latency/SDU_Interval packets, in hopes that possibly larger timer interval makes things more efficient. Fix the data rate by sending num packets every num*SDU_Interval, so that the average data rate is correct. Also fix use of itimerspect.it_value with TFD_TIMER_ABSTIME. The value set previously is going to always be in the past in CLOCK_MONOTONIC so just set it to 1. --- Notes: v2: Buffer one interval immediately as before. This assumes kernel shall set qos.interval to SDU_Interval and not ISO_Interval. client/player.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/client/player.c b/client/player.c index 7f67425aa..df5cb8924 100644 --- a/client/player.c +++ b/client/player.c @@ -5066,21 +5066,30 @@ static int transport_send(struct transport *transport, int fd, if (timer_fd < 0) return -errno; + /* Send data in bursts of + * num = ROUND_CLOSEST(Transport_Latency (ms) / SDU_Interval (us)) + * with average data rate = 1 packet / SDU_Interval + */ + transport->num = ROUND_CLOSEST(qos->latency * 1000, qos->interval); + if (!transport->num) + transport->num = 1; + memset(&ts, 0, sizeof(ts)); - ts.it_value.tv_nsec = qos->latency * 1000000; - ts.it_interval.tv_nsec = qos->latency * 1000000; + ts.it_value.tv_nsec = 1; + ts.it_interval.tv_nsec = transport->num * qos->interval * 1000; - if (timerfd_settime(timer_fd, TFD_TIMER_ABSTIME, &ts, NULL) < 0) + if (timerfd_settime(timer_fd, TFD_TIMER_ABSTIME, &ts, NULL) < 0) { + close(timer_fd); return -errno; + } transport->fd = fd; - /* num of packets = ROUND_CLOSEST(latency (ms) / interval (us)) */ - transport->num = ROUND_CLOSEST(qos->latency * 1000, qos->interval); transport->timer_io = io_new(timer_fd); io_set_read_handler(transport->timer_io, transport_timer_read, transport, NULL); + /* One extra packet to buffers immediately */ return transport_send_seq(transport, fd, 1); } -- 2.45.0