From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Xu Yang <xu.yang_2@nxp.com>, Peter Chen <peter.chen@kernel.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Sasha Levin <sashal@kernel.org>,
linux-usb@vger.kernel.org
Subject: [PATCH AUTOSEL 6.12 02/15] usb: chipidea: udc: limit usb request length to max 16KB
Date: Wed, 4 Dec 2024 17:15:56 -0500 [thread overview]
Message-ID: <20241204221627.2247598-2-sashal@kernel.org> (raw)
In-Reply-To: <20241204221627.2247598-1-sashal@kernel.org>
From: Xu Yang <xu.yang_2@nxp.com>
[ Upstream commit ca8d18aa7b0f22d66a3ca9a90d8f73431b8eca89 ]
To let the device controller work properly on short packet limitations,
one usb request should only correspond to one dTD. Then every dTD will
set IOC. In theory, each dTD support up to 20KB data transfer if the
offset is 0. Due to we cannot predetermine the offset, this will limit
the usb request length to max 16KB. This should be fine since most of
the user transfer data based on this size policy.
Signed-off-by: Xu Yang <xu.yang_2@nxp.com>
Acked-by: Peter Chen <peter.chen@kernel.org>
Link: https://lore.kernel.org/r/20240923081203.2851768-2-xu.yang_2@nxp.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/usb/chipidea/ci.h | 1 +
drivers/usb/chipidea/udc.c | 6 ++++++
2 files changed, 7 insertions(+)
diff --git a/drivers/usb/chipidea/ci.h b/drivers/usb/chipidea/ci.h
index e4b003d060c26..97437de52ef68 100644
--- a/drivers/usb/chipidea/ci.h
+++ b/drivers/usb/chipidea/ci.h
@@ -25,6 +25,7 @@
#define TD_PAGE_COUNT 5
#define CI_HDRC_PAGE_SIZE 4096ul /* page size for TD's */
#define ENDPT_MAX 32
+#define CI_MAX_REQ_SIZE (4 * CI_HDRC_PAGE_SIZE)
#define CI_MAX_BUF_SIZE (TD_PAGE_COUNT * CI_HDRC_PAGE_SIZE)
/******************************************************************************
diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c
index 69ef3cd8d4f83..d3556416dae4f 100644
--- a/drivers/usb/chipidea/udc.c
+++ b/drivers/usb/chipidea/udc.c
@@ -960,6 +960,12 @@ static int _ep_queue(struct usb_ep *ep, struct usb_request *req,
return -EMSGSIZE;
}
+ if (ci->has_short_pkt_limit &&
+ hwreq->req.length > CI_MAX_REQ_SIZE) {
+ dev_err(hwep->ci->dev, "request length too big (max 16KB)\n");
+ return -EMSGSIZE;
+ }
+
/* first nuke then test link, e.g. previous status has not sent */
if (!list_empty(&hwreq->queue)) {
dev_err(hwep->ci->dev, "request already in queue\n");
--
2.43.0
next prev parent reply other threads:[~2024-12-04 23:27 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-04 22:15 [PATCH AUTOSEL 6.12 01/15] usb: chipidea: add CI_HDRC_HAS_SHORT_PKT_LIMIT flag Sasha Levin
2024-12-04 22:15 ` Sasha Levin [this message]
2024-12-04 22:15 ` [PATCH AUTOSEL 6.12 03/15] usb: chipidea: udc: create bounce buffer for problem sglist entries if possible Sasha Levin
2024-12-04 22:15 ` [PATCH AUTOSEL 6.12 04/15] usb: chipidea: udc: handle USB Error Interrupt if IOC not set Sasha Levin
2024-12-04 22:15 ` [PATCH AUTOSEL 6.12 05/15] usb: typec: ucsi: Do not call ACPI _DSM method for UCSI read operations Sasha Levin
2024-12-04 22:16 ` [PATCH AUTOSEL 6.12 06/15] iio: adc: ad7192: properly check spi_get_device_match_data() Sasha Levin
2024-12-04 22:16 ` [PATCH AUTOSEL 6.12 07/15] iio: light: ltr501: Add LTER0303 to the supported devices Sasha Levin
2024-12-04 22:16 ` [PATCH AUTOSEL 6.12 08/15] drm: display: Set fwnode for aux bus devices Sasha Levin
2024-12-06 0:06 ` Saravana Kannan
2024-12-04 22:16 ` [PATCH AUTOSEL 6.12 09/15] phy: tegra: xusb: Set fwnode for xusb port devices Sasha Levin
2024-12-06 0:06 ` Saravana Kannan
2024-12-04 22:16 ` [PATCH AUTOSEL 6.12 10/15] usb: typec: ucsi: glink: be more precise on orientation-aware ports Sasha Levin
2024-12-04 22:16 ` [PATCH AUTOSEL 6.12 11/15] ASoC: amd: yc: fix internal mic on Redmi G 2022 Sasha Levin
2024-12-04 22:16 ` [PATCH AUTOSEL 6.12 12/15] drm/amdgpu/vcn: reset fw_shared when VCPU buffers corrupted on vcn v4.0.3 Sasha Levin
2024-12-04 22:16 ` [PATCH AUTOSEL 6.12 13/15] MIPS: Loongson64: DTS: Really fix PCIe port nodes for ls7a Sasha Levin
2024-12-04 22:16 ` [PATCH AUTOSEL 6.12 14/15] ASoC: amd: yc: Add quirk for microphone on Lenovo Thinkpad T14s Gen 6 21M1CTO1WW Sasha Levin
2024-12-04 22:16 ` [PATCH AUTOSEL 6.12 15/15] powerpc/prom_init: Fixup missing powermac #size-cells Sasha Levin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241204221627.2247598-2-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=peter.chen@kernel.org \
--cc=stable@vger.kernel.org \
--cc=xu.yang_2@nxp.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox