Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3520041pxf; Mon, 15 Mar 2021 11:22:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy5oD1mO9F2oLjQFuvTH02Mrn22sFHgtEfDvqv/4zvhKmRFM8PMW7DKpxdwPDgwTRsonHSG X-Received: by 2002:a17:906:c402:: with SMTP id u2mr25070171ejz.546.1615832542240; Mon, 15 Mar 2021 11:22:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615832542; cv=none; d=google.com; s=arc-20160816; b=0z0EhgPp3UdTFUHqMZEzvn4idUR8q+50UZPxkd990rEc0rnCEUX8GBuupuVXDWwOKN AYWAYYf29b88xpjo0Dl4TgWmm0PSyqMOPgiYt4tbsOAuHSInm23eis+hFmhmaXjfrlE0 Mla8mXxYLz5XsRpdtn6mO6xY19MbFwaVz4Ge1SlnYJYjEHWWrn1X6T58ou/TCgkEXDHx qSC5hKTBJxu2SgeCQDremM+42XrDxc0LwL1UFePK+tEE/2D+mnh168TW8CR+Y6QrBg/Y uUxpGLqTZ6rhium2zvtTX9ZrtP/b+12PyTo06tHmQ80FjZ+l4JPGruhijXGeHJL+7uOp U1KA== 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=uhAlOisb3R+dqpr4FRxqUmJZYu6TKwFVo4JdDyxF01OX+Sdx7lee4E7HdWriRDuXI4 OCFRA1pYsGpDbBbzM3EAZXyqK4BM8ebSnjTugNyh8JXd6kWYifD3/OBrNaDKF3/4ONIc r+ZQUNNPmeUgjCUkL97pBFVwKUT1H8hJXUmKM90eSMfalYblxVMz829q7COvVlJn4ln4 KL6w1Lh3i+2NmhkhQSXcPJgeNIRA5bMBegnlx2xOfTs+KQlspoXA7C1MD2nmu9CF3opS Vk1JjO9fbEWogN9wpgJsKD71o6gat+1ofHHKf9G/RdGOwGbCAXPMq5bE53p5lwMJ9pEs LgSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=KqLyLFHN; 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 u13si11224873ejc.243.2021.03.15.11.21.59; Mon, 15 Mar 2021 11:22:22 -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=KqLyLFHN; 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 S233765AbhCOOVd (ORCPT + 99 others); Mon, 15 Mar 2021 10:21:33 -0400 Received: from mail.kernel.org ([198.145.29.99]:37632 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232834AbhCOOAB (ORCPT ); Mon, 15 Mar 2021 10:00:01 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 9EFA764F31; Mon, 15 Mar 2021 13:59:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615816781; bh=rmC7IlEqG/sf97jfBeF9COqnucpg5NZszwxabt3aGbU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KqLyLFHNv+0DF8B6NiIRfEkg69Ha5xvGF+iSrXaEVfSLvhfSfvN0Uuj5WyNMbQD9e ARJuiuWaiFjOTjy2fcni8fvpVjuizOtFrEzDcoxEckDZ5PYB5jauLujVDb7w/SC8Kk OGdhpp5NsyvjCAZ44PvXtyy163kX5uualtKiVyGg= 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.4 105/168] usb: gadget: f_uac2: always increase endpoint max_packet_size by one audio slot Date: Mon, 15 Mar 2021 14:55:37 +0100 Message-Id: <20210315135553.817987765@linuxfoundation.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210315135550.333963635@linuxfoundation.org> References: <20210315135550.333963635@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));