[U-Boot] [PATCH 08/14] usb: xhci: Fix max packet size for full speed device endpoint 0

Stefan Roese sr at denx.de
Fri Sep 22 05:02:45 UTC 2017


On 18.09.2017 15:40, Bin Meng wrote:
> In xhci_check_maxpacket(), the control endpoint 0 max packet size
> is wrongly taken from the interface's endpoint descriptor. However
> the default endpoint 0 does not come with an endpoint descriptor
> hence is not included in the interface structure. Change to use
> epmaxpacketin[0] instead.
> 
> The other bug in this routine is that when setting max packet size
> to the xHC endpoint 0 context, it does not clear its previous value
> at all before programming a new one.
> 
> Signed-off-by: Bin Meng <bmeng.cn at gmail.com>
> ---
> 
>   drivers/usb/host/xhci.c | 8 +++-----
>   1 file changed, 3 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
> index 4b3d58d..ec82fa6 100644
> --- a/drivers/usb/host/xhci.c
> +++ b/drivers/usb/host/xhci.c
> @@ -546,16 +546,13 @@ int xhci_check_maxpacket(struct usb_device *udev)
>   	int max_packet_size;
>   	int hw_max_packet_size;
>   	int ret = 0;
> -	struct usb_interface *ifdesc;
> -
> -	ifdesc = &udev->config.if_desc[0];
>   
>   	out_ctx = ctrl->devs[slot_id]->out_ctx;
>   	xhci_inval_cache((uintptr_t)out_ctx->bytes, out_ctx->size);
>   
>   	ep_ctx = xhci_get_ep_ctx(ctrl, out_ctx, ep_index);
>   	hw_max_packet_size = MAX_PACKET_DECODED(le32_to_cpu(ep_ctx->ep_info2));
> -	max_packet_size = usb_endpoint_maxp(&ifdesc->ep_desc[0]);
> +	max_packet_size = udev->epmaxpacketin[0];
>   	if (hw_max_packet_size != max_packet_size) {
>   		debug("Max Packet Size for ep 0 changed.\n");
>   		debug("Max packet size in usb_device = %d\n", max_packet_size);
> @@ -567,7 +564,8 @@ int xhci_check_maxpacket(struct usb_device *udev)
>   				ctrl->devs[slot_id]->out_ctx, ep_index);
>   		in_ctx = ctrl->devs[slot_id]->in_ctx;
>   		ep_ctx = xhci_get_ep_ctx(ctrl, in_ctx, ep_index);
> -		ep_ctx->ep_info2 &= cpu_to_le32(~MAX_PACKET_MASK);
> +		ep_ctx->ep_info2 &= cpu_to_le32(~((0xffff & MAX_PACKET_MASK)
> +						<< MAX_PACKET_SHIFT));
>   		ep_ctx->ep_info2 |= cpu_to_le32(MAX_PACKET(max_packet_size));
>   
>   		/*
> 

Reviewed-by: Stefan Roese <sr at denx.de>
Tested-by: Stefan Roese <sr at denx.de>

Thanks,
Stefan


More information about the U-Boot mailing list