Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3527282pxf; Mon, 15 Mar 2021 11:32:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxv/M/1GUxtxHqLU9pw4+v+Gt8H6acTas+wWoZC64pjVmrDzpQKf3Gl4ZcLS0EILxOKKtaY X-Received: by 2002:a05:6402:1545:: with SMTP id p5mr31286390edx.155.1615833148098; Mon, 15 Mar 2021 11:32:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615833148; cv=none; d=google.com; s=arc-20160816; b=uFUwwmjUQ4e8mpEeQJF7dygV0QxqkWsJwrONDGlmq+dOXZPYq+HgeeXdrAZmj2ODwu Z4DCdzGKJ0iPH0VWBQSlx69AtPkOhz2CYDYYdkFqUdJ6Ba8z0XmrqK34ByhQXSgCEXHU cwUfVjlXogkcYQ9OyNqg3QcCZ/xMrOpFXY1oV3tuVXLPYYdDg5fLNMuXIxGAcWqO2Pzn 6wWC6E1mbO/ASBDsp5sPSdeis6Nc07cvJFfTEZQq3T/30dPxzFDjxuJozlNPkRL/kJdu hS9baQ9oBipET8W+NW8pm/ZkhFZLnKOCNhXmDU3g7zCwCYfAPJ47iY/o+jtYAy9W7m8n NfNg== 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=Kh/sldbx6XigfRgn78yZAhKT22ITyxyXjSW33o1/Isv6Lp/IsaNNAKjN1VDPzdrjZF se3RLxLhMjQPWxRlIPGHM33KXiJHLrwEnad8oUZEOhim3LIhqyqZ7bpArpGH6t+RMFU9 ynk0Jh8hdhT4UjoJzydQ1Z6fOAcWn0BQPQj4nXRExk5qVTPnzvN3ET1e09BxTBPyssOg y8eFG0EhvOXQ9aeTBpoU8jVabAdxhS7FbnWg4mPdcZKwHu/N3ktKxCYwbGy7BSIFgZsB o3HcoLDRMxsC6BCl6G0LCop0rWe8X2VVWRQPPVKy0XghVE+ElyEXB4tsKdn8XzLw5BYT AUlQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=wEIj9Oin; 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 z17si11109428ejc.207.2021.03.15.11.32.05; Mon, 15 Mar 2021 11:32:28 -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=wEIj9Oin; 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 S240410AbhCOOhx (ORCPT + 99 others); Mon, 15 Mar 2021 10:37:53 -0400 Received: from mail.kernel.org ([198.145.29.99]:48086 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231311AbhCOOBv (ORCPT ); Mon, 15 Mar 2021 10:01:51 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id BF6BA64EEA; Mon, 15 Mar 2021 14:01:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615816910; bh=rmC7IlEqG/sf97jfBeF9COqnucpg5NZszwxabt3aGbU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wEIj9Oin60iazzstnqXYUA5wu+qLqd74PEsLxy7ulrRAWVIepIG8e5waRaqhrWL2o iz2ZFW80ylG4LasthA7Hn6D9KjjhCu2inrabAzx/Ol3S9pCRcbuQymF9zyKeFXy3Uu pB+7KZHjMNaxhd0NqpDugIW/9WfHt+FruO7Q+0uo= 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.11 196/306] usb: gadget: f_uac2: always increase endpoint max_packet_size by one audio slot Date: Mon, 15 Mar 2021 14:54:19 +0100 Message-Id: <20210315135514.253818881@linuxfoundation.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210315135507.611436477@linuxfoundation.org> References: <20210315135507.611436477@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));