U-Boot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Roger Quadros <rogerq@kernel.org>
To: Siddharth Vadapalli <s-vadapalli@ti.com>,
	trini@konsulko.com, lukma@denx.de, mkorpershoek@baylibre.com,
	marex@denx.de, vigneshr@ti.com
Cc: u-boot@lists.denx.de, srk@ti.com
Subject: Re: [PATCH] usb: gadget: cdns3: Fix cdns3_ep_config() by setting ep.maxpacket
Date: Mon, 7 Oct 2024 15:02:34 +0300	[thread overview]
Message-ID: <edcf5ebf-d0d1-4722-b61e-016cadb12e63@kernel.org> (raw)
In-Reply-To: <20241007104239.1624430-1-s-vadapalli@ti.com>



On 07/10/2024 13:42, Siddharth Vadapalli wrote:
> The function cdns3_ep_config() calculates the maximum packet size based
> on the Endpoint Type and the Gadget Speed and stores it in the variable
> "max_packet_size". This value is then programmed in the USB Controller
> for the corresponding Endpoint. This may result in a mismatch between
> the maximum packet size programmed in the USB controller and the maximum
> packet size seen by the UDC Core via "maxpacket" member of "struct usb_ep".
> Additionally, since TD_SIZE is calculated in cdns3_ep_run_transfer() on the
> basis of the maximum packet size stored in the "maxpacket" member of
> "struct usb_ep", it may lead to an incorrect value of TD_SIZE when compared
> with what the USB controller actually expects (max_packet_size).
> 
> Fix this by using usb_ep_set_maxpacket_limit().
> 
> Fixes: 7e91f6ccdc84 ("usb: Add Cadence USB3 host and gadget driver")
> Signed-off-by: Siddharth Vadapalli <s-vadapalli@ti.com>
> ---
> 
> Hello,
> 
> This patch is based on commit
> dd4d130c8e clk: renesas: rcar-gen3: Fix SSCG caching replacement with MDSEL/PE caching
> of the master branch of U-Boot.
> 
> Patch has been tested on AM642-EVM.
> 
> Regards,
> Siddharth.
> 
>  drivers/usb/cdns3/gadget.c | 8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/drivers/usb/cdns3/gadget.c b/drivers/usb/cdns3/gadget.c
> index ac7e469469..b0b08768d9 100644
> --- a/drivers/usb/cdns3/gadget.c
> +++ b/drivers/usb/cdns3/gadget.c
> @@ -1637,6 +1637,14 @@ void cdns3_ep_config(struct cdns3_endpoint *priv_ep)
>  	else
>  		priv_ep->trb_burst_size = 16;
>  
> +	/*
> +	 * The Endpoint is configured to handle a maximum packet size of
> +	 * max_packet_size. Hence, set priv_ep->endpoint.maxpacket to
> +	 * max_packet_size. This is necessary to ensure that the TD_SIZE
> +	 * is calculated correctly in cdns3_ep_run_transfer().
> +	 */
> +	usb_ep_set_maxpacket_limit(&priv_ep->endpoint, max_packet_size);
> +

from include/linux/usb/gadget.h

 * struct usb_ep - device side representation of USB endpoint
...
 * @maxpacket:The maximum packet size used on this endpoint.  The initial
 *      value can sometimes be reduced (hardware allowing), according to
 *      the endpoint descriptor used to configure the endpoint.
 * @maxpacket_limit:The maximum packet size value which can be handled by this
 *      endpoint. It's set once by UDC driver when endpoint is initialized, and
 *      should not be changed. Should not be confused with maxpacket.

What you want to change is ep->maxpacket and not ep->maxpacket_limit as that is
fixed for a particular UDC.

how about?
	priv-ep->endpoint.maxpacket = max_packet_size;


>  	ret = cdns3_ep_onchip_buffer_reserve(priv_dev, buffering + 1,
>  					     !!priv_ep->dir);
>  	if (ret) {

-- 
cheers,
-roger

  reply	other threads:[~2024-10-07 12:02 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-07 10:42 [PATCH] usb: gadget: cdns3: Fix cdns3_ep_config() by setting ep.maxpacket Siddharth Vadapalli
2024-10-07 12:02 ` Roger Quadros [this message]
2024-10-07 12:07   ` Siddharth Vadapalli
2024-10-07 12:21     ` Siddharth Vadapalli

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=edcf5ebf-d0d1-4722-b61e-016cadb12e63@kernel.org \
    --to=rogerq@kernel.org \
    --cc=lukma@denx.de \
    --cc=marex@denx.de \
    --cc=mkorpershoek@baylibre.com \
    --cc=s-vadapalli@ti.com \
    --cc=srk@ti.com \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.denx.de \
    --cc=vigneshr@ti.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