mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Roger Quadros <rogerq@kernel.org>
To: Siddharth Vadapalli <s-vadapalli@ti.com>,
	peter.chen@kernel.org, pawell@cadence.com,
	gregkh@linuxfoundation.org, felipe.balbi@linux.intel.com
Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, srk@ti.com
Subject: Re: [PATCH] usb: cdns3: cdns3-gadget: Fix cdns3_ep_config() by setting ep.maxpacket
Date: Fri, 11 Oct 2024 13:38:58 +0300	[thread overview]
Message-ID: <1fdc891a-431b-45ac-bae0-c1c026dbb3aa@kernel.org> (raw)
In-Reply-To: <20241011054506.2810565-1-s-vadapalli@ti.com>

Hi Siddharth,

On 11/10/2024 08:45, 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 as well as TOTAL_TDL are 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 incorrect values
> of TD_SIZE and TOTAL_TDL when compared with what the USB controller
> actually expects (max_packet_size). This also applies to the calculation of
> TDL in cdns3_ep_run_stream_transfer().

Could you please mention here what use case was broken due to this?

> 
> Fix this.
> 
> Fixes: 7733f6c32e36 ("usb: cdns3: Add Cadence USB3 DRD Driver")
> Signed-off-by: Siddharth Vadapalli <s-vadapalli@ti.com>
> ---
> 
> Hello,
> 
> This patch is based on commit
> 1d227fcc7222 Merge tag 'net-6.12-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net
> of Mainline Linux.
> 
> Regards,
> Siddharth.
> 
>  drivers/usb/cdns3/cdns3-gadget.c | 10 ++++++++++
>  1 file changed, 10 insertions(+)
> 
> diff --git a/drivers/usb/cdns3/cdns3-gadget.c b/drivers/usb/cdns3/cdns3-gadget.c
> index fd1beb10bba7..e89bd248e81d 100644
> --- a/drivers/usb/cdns3/cdns3-gadget.c
> +++ b/drivers/usb/cdns3/cdns3-gadget.c
> @@ -2145,6 +2145,16 @@ int cdns3_ep_config(struct cdns3_endpoint *priv_ep, bool enable)
>  		return -EINVAL;
>  	}
>  
> +	/*
> +	 * 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 TD_SIZE and
> +	 * TOTAL_TDL are calculated correctly in cdns3_ep_run_transfer(),
> +	 * and also to ensure that TDL is calculated correctly in
> +	 * cdns3_ep_run_stream_transfer().
> +	 */
> +	priv_ep->endpoint.maxpacket = max_packet_size;
> +
>  	if (max_packet_size == 1024)
>  		priv_ep->trb_burst_size = 128;
>  	else if (max_packet_size >= 512)

-- 
cheers,
-roger

      reply	other threads:[~2024-10-11 10:39 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-11  5:45 Siddharth Vadapalli
2024-10-11 10:38 ` Roger Quadros [this message]

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=1fdc891a-431b-45ac-bae0-c1c026dbb3aa@kernel.org \
    --to=rogerq@kernel.org \
    --cc=felipe.balbi@linux.intel.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=pawell@cadence.com \
    --cc=peter.chen@kernel.org \
    --cc=s-vadapalli@ti.com \
    --cc=srk@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

all inboxes | Powered by JetHome®