From patchwork Sun Dec 8 15:13:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Faraz Ata X-Patchwork-Id: 13898597 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 3B17D17BA5 for ; Sun, 8 Dec 2024 15:13:54 +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=1733670837; cv=none; b=ihd7ELw9hLfwf84M6sfTDJtdf8QPli+Aok/ZG9FNO2PIIb1kfmXcPnF/cVGcI9PwPAxaHudw8Tp8AcwNM7hELvB06xWdedB2F0dSEEtCjdCG01QwpZtVyXLdfwPOZJz48r+XLtIF4mWJkHjxrrfDK1lsJdT/LkQsceYZdwg6Ucc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733670837; c=relaxed/simple; bh=CkJQvnReDSLSTn4ch3u3NkQYpbvbS77PpbeAHCkAxKA=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type: References; b=rWhwPsDvC6UpOGUZ+njqjSKai0nR8tHg4LYkXy5FFHjgZ1tNmtuLRyqj/hz8MEFM+oHLy8uYvO66YsuczfeztIjewSh3LiEDvn65DCTjmnGgMm6ni3eL1DC+2DMMERU8PdPabmjkPo3B2p466XB1YyOF6SabUvLanVGNJYnNdX4= 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=tA5gxY/b; 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="tA5gxY/b" Received: from epcas5p3.samsung.com (unknown [182.195.41.41]) by mailout4.samsung.com (KnoxPortal) with ESMTP id 20241208151352epoutp0429376009f0299b855062c81b74d61b7e~PPG-n__zQ0550205502epoutp04X for ; Sun, 8 Dec 2024 15:13:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout4.samsung.com 20241208151352epoutp0429376009f0299b855062c81b74d61b7e~PPG-n__zQ0550205502epoutp04X DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1733670832; bh=235I6kPicedHwlRboGp2aBJ4my88rhMe2fIVTNmR7fU=; h=From:To:Cc:Subject:Date:References:From; b=tA5gxY/baTXrDHFkxAZNst2UD6IC/D/vj4Dg46NPje51w6JzSdPiKUXE28aSosWyo Z0zfmvAnyeiiSKAulnJ/f4HCkmQy+wYgpzSmZmZfM4oD+SoZ5Sf3BbSzY1XWeGMvdN tLBpqMyaIHJRIj+moBaUJ2pw19NNOrQBp9r84Z2I= Received: from epsnrtp4.localdomain (unknown [182.195.42.165]) by epcas5p2.samsung.com (KnoxPortal) with ESMTP id 20241208151351epcas5p2746bfdf04c23d10219830ce6d069781c~PPG_iT4VI2463624636epcas5p2K; Sun, 8 Dec 2024 15:13:51 +0000 (GMT) Received: from epsmgec5p1-new.samsung.com (unknown [182.195.38.178]) by epsnrtp4.localdomain (Postfix) with ESMTP id 4Y5pRf3qLdz4x9Pq; Sun, 8 Dec 2024 15:13:50 +0000 (GMT) Received: from epcas5p1.samsung.com ( [182.195.41.39]) by epsmgec5p1-new.samsung.com (Symantec Messaging Gateway) with SMTP id B4.F0.29212.EA7B5576; Mon, 9 Dec 2024 00:13:50 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas5p1.samsung.com (KnoxPortal) with ESMTPA id 20241208151349epcas5p1a94ca45020318f54885072d4987160b3~PPG8Mbjce3020230202epcas5p1x; Sun, 8 Dec 2024 15:13:49 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20241208151349epsmtrp2cd3e7a68dab94fd191db992fe8c0d65a~PPG8LlnV23147231472epsmtrp2W; Sun, 8 Dec 2024 15:13:49 +0000 (GMT) X-AuditID: b6c32a50-7ebff7000000721c-b6-6755b7ae32da Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 67.DB.18729.DA7B5576; Mon, 9 Dec 2024 00:13:49 +0900 (KST) Received: from INBRO002811.samsungds.net (unknown [107.122.5.126]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20241208151346epsmtip1b0991e1038d8971f7e54e5d946d91236~PPG5qH4TH3235832358epsmtip1Y; Sun, 8 Dec 2024 15:13:46 +0000 (GMT) From: Faraz Ata 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:43:13 +0530 Message-ID: <20241208151314.1625-1-faraz.ata@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-Brightmail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R9LnrNXL8y5e2gqQ0T2 CSnd7etvt6nHeguaSLy456Y4obexd2WeBa+asKimbMtH/dbTAp43ZswpYZ3M1CtpFFpbXsU/ 6cJz32ZprpyX5qbrmf6YcU74sdiraGuyrcqMa10NGibPjm5PfH1BTLlSZW+t0I+VNd1NfHob Nm0/E3liy5azLpfTKvh0ejY0v2usnBMmVbPe28qzT+WUVO4055YpSizFGYmGWsxFxYkAqr4/ ewYDAAA= X-CMS-MailID: 20241208151349epcas5p1a94ca45020318f54885072d4987160b3 X-Msg-Generator: CA CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20241208151349epcas5p1a94ca45020318f54885072d4987160b3 References: From: Selvarasu Ganesan 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)