From patchwork Sun Dec 8 15:23:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Selvarasu Ganesan X-Patchwork-Id: 848438 Received: from mailout4.samsung.com (mailout4.samsung.com [203.254.224.34]) (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 8243614B946 for ; Sun, 8 Dec 2024 15:23:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=203.254.224.34 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733671426; cv=none; b=YPSZ7bfQ9yh+mc+7oiCySZ+AXUHozHwKSwW8cbCiNwgIWeI0RIgOOEeciAV+1bq7GZ2qF2pm7ydSW+JRlN3N9TGvK2rB7Zs43Qh3Ys/YSSnpTizMib4M+s11PB+rJ1VrFJN6n8BLKNlStqywQ03Ef9m4zPWn44lViNUDClC3mV0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733671426; c=relaxed/simple; bh=KA0vAU8DTDx3H/wl4aFnQ1yYDnMCnHQfCNIMY1kw10I=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type: References; b=fJtgAnVY2zfDzPCDkD2+9oH4re8lsUiyerE8BtjuN2MN7lHW9IK3XlPP5igtz3jGRfah82kRJK9hxIyuq4RxgN+ooUWaCkTYaqcXOA0iAVMKI8zRVM1WtAc+euYMU30TvT/Zgu8DMfCMUma1km4K+mV6SkGrYuyYtF9JL5FCzkw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com; spf=pass smtp.mailfrom=samsung.com; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b=Uz4+OS9B; arc=none smtp.client-ip=203.254.224.34 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=samsung.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="Uz4+OS9B" Received: from epcas5p2.samsung.com (unknown [182.195.41.40]) by mailout4.samsung.com (KnoxPortal) with ESMTP id 20241208152341epoutp04094db3ce07b4720350faeeefc4e6234c~PPPj4nHJs1255312553epoutp04f for ; Sun, 8 Dec 2024 15:23:41 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout4.samsung.com 20241208152341epoutp04094db3ce07b4720350faeeefc4e6234c~PPPj4nHJs1255312553epoutp04f DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1733671421; bh=U9qdsKOaCjfcMTnbwTLkPFo4E5Z9Ybaq/tHD+FUaP+g=; h=From:To:Cc:Subject:Date:References:From; b=Uz4+OS9B7EuvzmL0IZR+PFH13RQo0xR+aaIDOGyPrdVm2P/hf7vcspfqmw3njkDzc Ijia3CC+B6vO7qgbPHHCNOuds4mZqEfUkp/O6nWfOV8qeUKajsX596URCqgDwkYrqa ONRPgMwb3VQPP0yK7i0W0wYcZk63JnQpBnbISDFo= Received: from epsnrtp2.localdomain (unknown [182.195.42.163]) by epcas5p1.samsung.com (KnoxPortal) with ESMTP id 20241208152340epcas5p175fbbf749b8d418f8df3d5ebfa14e730~PPPiri99J1686816868epcas5p1N; Sun, 8 Dec 2024 15:23:40 +0000 (GMT) Received: from epsmges5p3new.samsung.com (unknown [182.195.38.183]) by epsnrtp2.localdomain (Postfix) with ESMTP id 4Y5pfz1Q64z4x9Pt; Sun, 8 Dec 2024 15:23:39 +0000 (GMT) Received: from epcas5p1.samsung.com ( [182.195.41.39]) by epsmges5p3new.samsung.com (Symantec Messaging Gateway) with SMTP id 86.65.19956.AF9B5576; Mon, 9 Dec 2024 00:23:39 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas5p4.samsung.com (KnoxPortal) with ESMTPA id 20241208152338epcas5p4fde427bb4467414417083221067ac7ab~PPPhMDJJ50061500615epcas5p40; Sun, 8 Dec 2024 15:23:38 +0000 (GMT) Received: from epsmgms1p2new.samsung.com (unknown [182.195.42.42]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20241208152338epsmtrp11d9743579f6d837188082af81474b114~PPPhKgA3_1210012100epsmtrp1S; Sun, 8 Dec 2024 15:23:38 +0000 (GMT) X-AuditID: b6c32a4b-fd1f170000004df4-c9-6755b9faef4c Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p2new.samsung.com (Symantec Messaging Gateway) with SMTP id FC.BC.18949.AF9B5576; Mon, 9 Dec 2024 00:23:38 +0900 (KST) Received: from INBRO002811.samsungds.net (unknown [107.122.5.126]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20241208152335epsmtip143d565445f23f40887fd6abf32357895~PPPelHNbz2790327903epsmtip1U; Sun, 8 Dec 2024 15:23:35 +0000 (GMT) From: Selvarasu Ganesan To: gregkh@linuxfoundation.org, quic_jjohnson@quicinc.com, kees@kernel.org, abdul.rahim@myyahoo.com, m.grzeschik@pengutronix.de, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Cc: jh0801.jung@samsung.com, dh10.jung@samsung.com, naushad@samsung.com, akash.m5@samsung.com, rc93.raju@samsung.com, taehyun.cho@samsung.com, hongpooh.kim@samsung.com, eomji.oh@samsung.com, shijie.cai@samsung.com, alim.akhtar@samsung.com, Selvarasu Ganesan , stable@vger.kernel.org Subject: [PATCH] usb: gadget: f_midi: Fixing wMaxPacketSize exceeded issue during MIDI bind retries Date: Sun, 8 Dec 2024 20:53:20 +0530 Message-ID: <20241208152322.1653-1-selvarasu.g@samsung.com> X-Mailer: git-send-email 2.46.0.windows.1 Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-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6zSmo6bMS4otlgRxFZ9/ sdL/+d63uye/Ovu3sMRf9dqdS1OV17M4C206cZbdyerqm5iF/eJCRyyslq4Rndspcl/+YWXv su7IEEUHsRPRT+YY6x+LvFrm+zPxbtDhY5cfm1/+19ux4Ez+qrnrIjrX7NnAZuZe/ILv0Fnm rAbmn0suXjnpXmTU+tLo7787msu/7mLhmp4kV1bme/2+uJBHpdLRv+VKLMUZiYZazEXFiQB0 rI0SBgMAAA== X-CMS-MailID: 20241208152338epcas5p4fde427bb4467414417083221067ac7ab X-Msg-Generator: CA CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20241208152338epcas5p4fde427bb4467414417083221067ac7ab References: The current implementation sets the wMaxPacketSize of bulk in/out endpoints to 1024 bytes at the end of the f_midi_bind function. However, in cases where there is a failure in the first midi bind attempt, consider rebinding. This scenario may encounter an f_midi_bind issue due to the previous bind setting the bulk endpoint's wMaxPacketSize to 1024 bytes, which exceeds the ep->maxpacket_limit where configured TX/RX FIFO's maxpacket size of 512 bytes for IN/OUT endpoints in support HS speed only. This commit addresses this issue by resetting the wMaxPacketSize before endpoint claim. Fixes: 46decc82ffd5 ("usb: gadget: unconditionally allocate hs/ss descriptor in bind operation") Cc: stable@vger.kernel.org Signed-off-by: Selvarasu Ganesan --- drivers/usb/gadget/function/f_midi.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/usb/gadget/function/f_midi.c b/drivers/usb/gadget/function/f_midi.c index 837fcdfa3840..5caa0e4eb07e 100644 --- a/drivers/usb/gadget/function/f_midi.c +++ b/drivers/usb/gadget/function/f_midi.c @@ -907,6 +907,15 @@ static int f_midi_bind(struct usb_configuration *c, struct usb_function *f) status = -ENODEV; + /* + * Reset wMaxPacketSize with maximum packet size of FS bulk transfer before + * endpoint claim. This ensures that the wMaxPacketSize does not exceed the + * limit during bind retries where configured TX/RX FIFO's maxpacket size + * of 512 bytes for IN/OUT endpoints in support HS speed only. + */ + bulk_in_desc.wMaxPacketSize = cpu_to_le16(64); + bulk_out_desc.wMaxPacketSize = cpu_to_le16(64); + /* allocate instance-specific endpoints */ midi->in_ep = usb_ep_autoconfig(cdev->gadget, &bulk_in_desc); if (!midi->in_ep)