Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3526805pxf; Mon, 15 Mar 2021 11:31:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzGvLJ1AS8uI/TyZRWgRZQdZtVkqU02Nm3pBONEEC3Nyo2Pqpdj+nGZhSshhlbolvwaNHwc X-Received: by 2002:a17:907:2b03:: with SMTP id gc3mr25425899ejc.448.1615833109105; Mon, 15 Mar 2021 11:31:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615833109; cv=none; d=google.com; s=arc-20160816; b=kYpMGv+cdZbZ7+7RDjb3+ZIAomvwbdXwL6VilaUDKZJQB3YIc7JrHrt24u+gm40Q8P bNkClQqA6Lke9qJPLLBD53DNC3dMjiKDNb9imvcD04DxwGFyht0i4ZSt4zsrMLkt6qOe X386HB+YgZAKZ7IUJ9mGBT/UnQefV8STR4M02uRWdaEif3nauHF0R/dPVbbsLe8eMVtE qBsaq7tHQagjxzSIZXjgx+3fP+fnIeM08NwV6rbmuicnNyZ272lWuk9yE2xttyhFYCux nreHpmL1rC+xlCCDVQ3zsMBoqjKE/LHUcNHgYSruAlyJeu57bn96m0BzUn+b4vCvNOuw m+Eg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=unqrNGgWu/2bLVWO8jpHW11WfzBB9FstBiHRwRz8NiI=; b=hi3OvFwWrDVTDpdwkKejRMiIu2i8tYDdUAX8h2O0mAbq0f5/iPo/WLkGhyHffCgBrP ikeUaDWh7m7zNSKaUUbYSbNrny8ghyjoWNRWYVcxdmv5pbhwNl0+YQ3JNRAcpkJl9oNM TfGjWflvZo5jxb6o3tijmpWHbtz5cOfgHebKgUEHWs5+7o/vCFPZXYpwUJJ3Ar/mZYeS +KN6qkCBecZgC1AiSTcnmemwpOq6qh5Jyo0B4h49o0/NCwDA54iPQvGVFGCLHMEUjH5m eT5Pm2LLUrnimxhjaaQTSnWuYV4U+PGqg9cKgIvM3mp8MavJjrFplXl5UKLt+nDZr2Rp dLLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=n4toczZm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r11si11016597eja.563.2021.03.15.11.31.26; Mon, 15 Mar 2021 11:31:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=n4toczZm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236990AbhCOOjw (ORCPT + 99 others); Mon, 15 Mar 2021 10:39:52 -0400 Received: from mail.kernel.org ([198.145.29.99]:48992 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233712AbhCOOCV (ORCPT ); Mon, 15 Mar 2021 10:02:21 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 8AD3964EF0; Mon, 15 Mar 2021 14:02:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615816940; bh=rmC7IlEqG/sf97jfBeF9COqnucpg5NZszwxabt3aGbU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=n4toczZmzThCgtFoDzqb1yUYkm7kcbdfy3iegvVDfY7pQBn8NgjNSR8HCZmT0tofo GuLbhp0ny5zAQ1bg/MmglTqV0/I4+BpT014P4Jav06BHR8CHctR6Pw9ffudVdl1SDL YcNCqZhjC1wLmqIumoc8DJxyAzI98+2PHP82YuQ8= From: gregkh@linuxfoundation.org To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Peter Chen , Ruslan Bilovol Subject: [PATCH 5.10 200/290] usb: gadget: f_uac2: always increase endpoint max_packet_size by one audio slot Date: Mon, 15 Mar 2021 14:54:53 +0100 Message-Id: <20210315135548.676247745@linuxfoundation.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210315135541.921894249@linuxfoundation.org> References: <20210315135541.921894249@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Greg Kroah-Hartman From: Ruslan Bilovol commit 789ea77310f0200c84002884ffd628e2baf3ad8a upstream. As per UAC2 Audio Data Formats spec (2.3.1.1 USB Packets), if the sampling rate is a constant, the allowable variation of number of audio slots per virtual frame is +/- 1 audio slot. It means that endpoint should be able to accept/send +1 audio slot. Previous endpoint max_packet_size calculation code was adding sometimes +1 audio slot due to DIV_ROUND_UP behaviour which was rounding up to closest integer. However this doesn't work if the numbers are divisible. It had no any impact with Linux hosts which ignore this issue, but in case of more strict Windows it caused rejected enumeration Thus always add +1 audio slot to endpoint's max packet size Fixes: 913e4a90b6f9 ("usb: gadget: f_uac2: finalize wMaxPacketSize according to bandwidth") Cc: Peter Chen Cc: #v4.3+ Signed-off-by: Ruslan Bilovol Link: https://lore.kernel.org/r/1614599375-8803-2-git-send-email-ruslan.bilovol@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/gadget/function/f_uac2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/usb/gadget/function/f_uac2.c +++ b/drivers/usb/gadget/function/f_uac2.c @@ -478,7 +478,7 @@ static int set_ep_max_packet_size(const } max_size_bw = num_channels(chmask) * ssize * - DIV_ROUND_UP(srate, factor / (1 << (ep_desc->bInterval - 1))); + ((srate / (factor / (1 << (ep_desc->bInterval - 1)))) + 1); ep_desc->wMaxPacketSize = cpu_to_le16(min_t(u16, max_size_bw, max_size_ep));