From: Peter Chen <peter.chen@kernel.org>
To: Xu Yang <xu.yang_2@nxp.com>
Cc: gregkh@linuxfoundation.org, linux-usb@vger.kernel.org,
imx@lists.linux.dev, jun.li@nxp.com
Subject: Re: [PATCH 1/2] usb: chipidea: udc: limit usb request length to max 16KB
Date: Fri, 13 Sep 2024 09:20:45 +0800 [thread overview]
Message-ID: <20240913012045.GA320526@nchen-desktop> (raw)
In-Reply-To: <20240912045150.915573-1-xu.yang_2@nxp.com>
On 24-09-12 12:51:49, Xu Yang wrote:
> Currently, the deivice controller has below limitations:
> 1. can't generate short packet interrupt if IOC not set in dTD. So if one
> request span more than one dTDs and only the last dTD set IOC, the usb
> request will pending there if no more data comes.
> 2. the controller can't accurately deliver data to differtent usb requests
> in some cases due to short packet. For example: one usb request span 3
> dTDs, then if the controller received a short packet the next packet
> will go to 2nd dTD of current request rather than the first dTD of next
> request.
>
Are there any IP errata for it?
> To let the device controller work properly, 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.
>
> Although these limitations found on OUT eps, we can put the request to IN
> eps too, this will benefit the following patches.
Since IN endpoints have not found the problem, please limit the changes
only for OUT endpoints.
>
> Signed-off-by: Xu Yang <xu.yang_2@nxp.com>
> ---
> drivers/usb/chipidea/ci.h | 1 +
> drivers/usb/chipidea/udc.c | 5 +++++
> 2 files changed, 6 insertions(+)
>
> diff --git a/drivers/usb/chipidea/ci.h b/drivers/usb/chipidea/ci.h
> index 2a38e1eb6546..f8deccfc8713 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 b1a1be6439b6..5d9369d01065 100644
> --- a/drivers/usb/chipidea/udc.c
> +++ b/drivers/usb/chipidea/udc.c
> @@ -969,6 +969,11 @@ static int _ep_queue(struct usb_ep *ep, struct usb_request *req,
> return -EMSGSIZE;
> }
>
> + if (hwreq->req.length > CI_MAX_REQ_SIZE) {
> + dev_err(hwep->ci->dev, "request length too big (max 16KB)\n");
> + return -EMSGSIZE;
> + }
> +
Since this IP is used by many vendors, it may fix by others.
I prefer add flag like CI_HDRC_SHORT_PACKET_NOT_SUPPORT,
and set in imx platform file.
Peter
next prev parent reply other threads:[~2024-09-13 1:20 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-12 4:51 [PATCH 1/2] usb: chipidea: udc: limit usb request length to max 16KB Xu Yang
2024-09-12 4:51 ` [PATCH 2/2] usb: chipidea: udc: create bounce buffer for problem sglist entries if possible Xu Yang
2024-09-13 1:34 ` Peter Chen
2024-10-09 14:47 ` Dan Carpenter
2024-09-13 1:20 ` Peter Chen [this message]
2024-09-13 7:11 ` [PATCH 1/2] usb: chipidea: udc: limit usb request length to max 16KB Xu Yang
2024-09-13 9:53 ` Peter Chen
2024-09-13 15:25 ` Xu Yang
2024-09-14 2:04 ` Peter Chen
2024-09-20 4:50 ` Xu Yang
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=20240913012045.GA320526@nchen-desktop \
--to=peter.chen@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=imx@lists.linux.dev \
--cc=jun.li@nxp.com \
--cc=linux-usb@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.