This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

AM6442: Linux console locks when USB cable is disconnected

Part Number: AM6442
Other Parts Discussed in Thread: TMDS64EVM,

Hi,

My customer is reported an issue with USB.
SW: Linux SDK 8.6
HW: AM64x SR2 EVM

Test procedure.
Step#1: After Linux boot-up, connect EVM with Host PC.
Step#2: executes below commands in Linux console on EVM.
# chmod 755 Set_Composite_USBD_new_mod.sh
# ./Set_Composite_USBD_new_mod.sh
(Set_Compose_USBD_new_mod.sh is below)

#!/bin/sh
#
# Script: USBD composite device setting for A-BRID(BX400/600)
# Author:  Shinji Koizumi
#


#### 1 : Load composite driver
	echo "*** 1 : Load composite driver">/dev/console0
	modprobe libcomposite
	sleep 1
#### 2 : Create composite device
	echo "*** 2 : Create composite device">/dev/console0
	mkdir -p /sys/kernel/config/usb_gadget/g1

#### 2-1 : Set value to device descriptor
#      [Notes] Refer to the self-diagnosis code for "idVendor" and "idProduct"
	echo "*** 2-1 : Set value to device descriptor">/dev/console0
	echo 0x0001 > /sys/kernel/config/usb_gadget/g1/idVendor
	echo 0x0002 > /sys/kernel/config/usb_gadget/g1/idProduct
	echo 0x0010 > /sys/kernel/config/usb_gadget/g1/bcdDevice
	echo 0x0020 > /sys/kernel/config/usb_gadget/g1/bcdUSB
	echo 0x40 > /sys/kernel/config/usb_gadget/g1/bMaxPacketSize0
	echo 0xEF > /sys/kernel/config/usb_gadget/g1/bDeviceClass
	echo 0x02 > /sys/kernel/config/usb_gadget/g1/bDeviceSubClass
	echo 0x01 > /sys/kernel/config/usb_gadget/g1/bDeviceProtocol

#### 2-2 : Set string to string descriptor
#      [Notes] Refer to DOM for below strings
	echo "*** 2-2 : Set string to string descriptor">/dev/console0
	mkdir -p /sys/kernel/config/usb_gadget/g1/strings/0x409
	echo '123456' > /sys/kernel/config/usb_gadget/g1/strings/0x409/serialnumber
	echo 'Test Corp' > /sys/kernel/config/usb_gadget/g1/strings/0x409/manufacturer
	echo 'abcdef'> /sys/kernel/config/usb_gadget/g1/strings/0x409/product

#### 3 : Create config descriptor
	echo "*** 3 : Create config descriptor">/dev/console0
	mkdir -p /sys/kernel/config/usb_gadget/g1/configs/c.1/strings/0x409
	echo 0xc0 > /sys/kernel/config/usb_gadget/g1/configs/c.1/bmAttributes
	echo "CDC RNDIS + PRINTER" > /sys/kernel/config/usb_gadget/g1/configs/c.1/strings/0x409/configuration

#### 4 : Load function drivers
	echo "*** 4 : Load function drivers">/dev/console0
	mkdir -p /sys/kernel/config/usb_gadget/g1/functions/rndis.usb0
	mkdir -p /sys/kernel/config/usb_gadget/g1/functions/printer.usb0
	sleep 1

#### 5 : Set each functions
#      [Notes] Refer to DOM for below strings
	echo "*** 5 : Set each functions">/dev/console0
	# PRINTER
	echo 'MFG:TOSHIBA;CMD:TPCL;MDL:BX400/600;CLS:PRINTER;DES:TOSHIBA BX400/600;' > /sys/kernel/config/usb_gadget/g1/functions/printer.usb0/pnp_string
	echo 10 > /sys/kernel/config/usb_gadget/g1/functions/printer.usb0/q_len 

#### 6 : Associate function and config
	echo "*** 6 : Associate function and config">/dev/console0
	ln -s /sys/kernel/config/usb_gadget/g1/functions/rndis.usb0 /sys/kernel/config/usb_gadget/g1/configs/c.1/rndis.usb0
	ln -s /sys/kernel/config/usb_gadget/g1/functions/printer.usb0 /sys/kernel/config/usb_gadget/g1/configs/c.1/printer.usb0

#### 7 : Activate UDC
#      [Notes] If you deactivate the UDC, execute 'echo "" > /sys/kernel/config/usb_gadget/g1/UDC'
	echo "Wait for UDC">/dev/console0
	while [ -z "$(ls /sys/class/udc)" ]; do sleep 1; done
	echo "*** 7 : Activate UDC">/dev/console0
	ls /sys/class/udc > /sys/kernel/config/usb_gadget/g1/UDC


#### 8 : Link-up usb0 port
	echo "*** 8 : Link-up usb0 port">/dev/console0
	ifconfig usb0 10.10.10.10 up
	sleep 1
	ifconfig usb0 10.10.10.10 up
	sleep 1
	ifconfig


Now the EVM is recognized as printer.
Step#3: executes below command in Linux console on EVM.
# > while true; do cat /boot/Image.gz > /dev/g_printer0 ; sleep 1; done
Step#4: Disconnect USB cable. Then console is locked.

Console log is attached.
am64xevmsdk0806usbcableoutcalltrace.txt

Could you try to reproduce it on your side and provide solution?

Thanks and regards,
Koichiro Tashiro

  • Hi Tashiro-san,

    I will try this on my EVM and get back to you next week.

  • Hi Bin,

    Did you have a chance to try it on your side?

    Thanks and regards,
    Koichiro Tashiro

  • Hi Tashiro-san,

    Sorry, I am working on another customer escalation this week, and likely will get back on this issue early next week.

  • Hi Tashiro-san,

    I am able to reproduce the issue on my AM64x GPEVM. I will debug into it and keep you posted.

  • Bin : does the newer TMDS64EVM likewise have this USB cable disconnect problem?

  • Jim,

    I use board PROC101C, I believe it is the latest version of TMDS64EVM.

  • Hi Bin,

    Could you update the status of your investigation?

    Thanks and regards,
    Koichiro Tashiro

  • Hi Tashiro-san,

    I am still working on it. No much of progress to share yet.

  • Hi Bin,

    Any updates for this item?

    Thanks and regards,
    Koichiro Tashiro

  • Hi Tashiro-san,

    Sorry for my late response.

    the issue is that when the usb cable is removed, the kernel driver cdns3/gadget.c line 2461-2466 becomes a busy loop which causes the CPU is unable to handle other tasks such as the serial console.

    https://git.ti.com/cgit/ti-linux-kernel/ti-linux-kernel/tree/drivers/usb/cdns3/gadget.c?h=08.06.00.007#n2461

    I am working on finding the fix.

  • Bin: please also check if this USB interruption also happens with AM64X Linux SDK v9.2 that was recently released (compatible with CCS 12.7) - if so, Nick might need to mention something in the AM64X academy update.

    thanks

    Jim Mrowca 

  • Hi Jim,

    Can you please provide the context of the USB interruption? I am not sure what it is and how it is related to Tashiro-san's USB lockup problem.

  • My application should have powerdown of the AM6442 (which will be on a SOM) before anyone should disconnect any USB 3.1 cables for maintenance. This system could run a 24 hr loop. Given there would be an FMEA done on my system application, we will need to account for what may happen with such a similar USB interruption (and if so, procedurally document any remediation required). If there is any SDK remediation, that would be good (I suspect such a remediation may be contingent on what version of the USB spec is applied).

    thanks,

    Jim Mrowca

  • Hi Jim,

    I am still unable to understand if your issue is the same as this e2e thread. Tashiro-san's customer issue is specifically to USB g_printer driver running on AM64x USB in device mode. This issue won't happen with any other kernel USB gadget drivers.

    I recommend you create a new e2e thread if you need assistance. Supporting both you and Tashiro-san on the single thread would make the communication difficult to understand. Thanks.

  • Hi Tashiro-san,

    The following kernel patch should prevent kernel to hang when the USB cable is removed.

    diff --git a/drivers/usb/cdns3/gadget.c b/drivers/usb/cdns3/gadget.c
    index e3a8b6c71aa1..6ecaec399064 100644
    --- a/drivers/usb/cdns3/gadget.c
    +++ b/drivers/usb/cdns3/gadget.c
    @@ -2461,6 +2461,10 @@ static int cdns3_gadget_ep_disable(struct usb_ep *ep)
            while (!list_empty(&priv_ep->pending_req_list)) {
                    request = cdns3_next_request(&priv_ep->pending_req_list);
     
    +               priv_ep->pending_req_list.next = request->list.next;
    +               request->list.next->prev = &priv_ep->pending_req_list;
    +               INIT_LIST_HEAD(&request->list);
    +
                    cdns3_gadget_giveback(priv_ep, to_cdns3_request(request),
                                          -ESHUTDOWN);

  • Hi Tashiro-san,

    The previous patch was just to workaround the Linux system lockup. The kernel patch attached below is the proper fix of the USB lockup issue. Please ask the customer to ignore the previous patch and test this patch with SDK8.6 kernel to see if there is any issue in the USB function.

    diff --git a/drivers/usb/cdns3/ep0.c b/drivers/usb/cdns3/ep0.c
    index 30d3516c7f98..0e783e4f8ed7 100644
    --- a/drivers/usb/cdns3/ep0.c
    +++ b/drivers/usb/cdns3/ep0.c
    @@ -105,11 +105,11 @@ static void cdns3_ep0_complete_setup(struct cdns3_device *priv_dev,
     				     u8 send_stall, u8 send_erdy)
     {
     	struct cdns3_endpoint *priv_ep = priv_dev->eps[0];
    -	struct usb_request *request;
    +	struct cdns3_request *request;
     
     	request = cdns3_next_request(&priv_ep->pending_req_list);
     	if (request)
    -		list_del_init(&request->list);
    +		list_del_init(&request->tlist);
     
     	if (send_stall) {
     		trace_cdns3_halt(priv_ep, send_stall, 0);
    @@ -539,12 +539,11 @@ static void cdns3_ep0_setup_phase(struct cdns3_device *priv_dev)
     	trace_cdns3_ctrl_req(ctrl);
     
     	if (!list_empty(&priv_ep->pending_req_list)) {
    -		struct usb_request *request;
    +		struct cdns3_request *request;
     
     		request = cdns3_next_request(&priv_ep->pending_req_list);
     		priv_ep->dir = priv_dev->ep0_data_dir;
    -		cdns3_gadget_giveback(priv_ep, to_cdns3_request(request),
    -				      -ECONNRESET);
    +		cdns3_gadget_giveback(priv_ep, request, -ECONNRESET);
     	}
     
     	if (le16_to_cpu(ctrl->wLength))
    @@ -571,16 +570,16 @@ static void cdns3_transfer_completed(struct cdns3_device *priv_dev)
     	struct cdns3_endpoint *priv_ep = priv_dev->eps[0];
     
     	if (!list_empty(&priv_ep->pending_req_list)) {
    -		struct usb_request *request;
    +		struct cdns3_request *request;
     
     		trace_cdns3_complete_trb(priv_ep, priv_ep->trb_pool);
     		request = cdns3_next_request(&priv_ep->pending_req_list);
     
    -		request->actual =
    +		request->request.actual =
     			TRB_LEN(le32_to_cpu(priv_ep->trb_pool->length));
     
     		priv_ep->dir = priv_dev->ep0_data_dir;
    -		cdns3_gadget_giveback(priv_ep, to_cdns3_request(request), 0);
    +		cdns3_gadget_giveback(priv_ep, request, 0);
     	}
     
     	cdns3_ep0_complete_setup(priv_dev, 0, 0);
    @@ -690,6 +689,7 @@ static int cdns3_gadget_ep0_queue(struct usb_ep *ep,
     {
     	struct cdns3_endpoint *priv_ep = ep_to_cdns3_ep(ep);
     	struct cdns3_device *priv_dev = priv_ep->cdns3_dev;
    +	struct cdns3_request *priv_req;
     	unsigned long flags;
     	int ret = 0;
     	u8 zlp = 0;
    @@ -759,7 +759,8 @@ static int cdns3_gadget_ep0_queue(struct usb_ep *ep,
     	}
     
     	request->status = -EINPROGRESS;
    -	list_add_tail(&request->list, &priv_ep->pending_req_list);
    +	priv_req = to_cdns3_request(request);
    +	list_add_tail(&priv_req->tlist, &priv_ep->pending_req_list);
     
     	if (request->zero && request->length &&
     	    (request->length % ep->maxpacket == 0))
    @@ -822,10 +823,10 @@ void cdns3_ep0_config(struct cdns3_device *priv_dev)
     	priv_ep = priv_dev->eps[0];
     
     	if (!list_empty(&priv_ep->pending_req_list)) {
    -		struct usb_request *request;
    +		struct cdns3_request *request;
     
     		request = cdns3_next_request(&priv_ep->pending_req_list);
    -		list_del_init(&request->list);
    +		list_del_init(&request->tlist);
     	}
     
     	priv_dev->u1_allowed = 0;
    diff --git a/drivers/usb/cdns3/gadget.c b/drivers/usb/cdns3/gadget.c
    index e3a8b6c71aa1..aa909e27bfe3 100644
    --- a/drivers/usb/cdns3/gadget.c
    +++ b/drivers/usb/cdns3/gadget.c
    @@ -126,9 +126,9 @@ static int cdns3_get_dma_pos(struct cdns3_device *priv_dev,
      *
      * Returns request or NULL if no requests in list
      */
    -struct usb_request *cdns3_next_request(struct list_head *list)
    +struct cdns3_request *cdns3_next_request(struct list_head *list)
     {
    -	return list_first_entry_or_null(list, struct usb_request, list);
    +	return list_first_entry_or_null(list, struct cdns3_request, tlist);
     }
     
     /**
    @@ -398,7 +398,7 @@ enum usb_device_speed cdns3_get_speed(struct cdns3_device *priv_dev)
     static int cdns3_start_all_request(struct cdns3_device *priv_dev,
     				   struct cdns3_endpoint *priv_ep)
     {
    -	struct usb_request *request;
    +	struct cdns3_request *priv_req;
     	int ret = 0;
     	u8 pending_empty = list_empty(&priv_ep->pending_req_list);
     
    @@ -408,10 +408,7 @@ static int cdns3_start_all_request(struct cdns3_device *priv_dev,
     	 * do NOT start new transfer till the last one is pending
     	 */
     	if (!pending_empty) {
    -		struct cdns3_request *priv_req;
    -
    -		request = cdns3_next_request(&priv_ep->pending_req_list);
    -		priv_req = to_cdns3_request(request);
    +		priv_req = cdns3_next_request(&priv_ep->pending_req_list);
     		if ((priv_req->flags & REQUEST_INTERNAL) ||
     		    (priv_ep->flags & EP_TDLCHK_EN) ||
     			priv_ep->use_streams) {
    @@ -421,21 +418,23 @@ static int cdns3_start_all_request(struct cdns3_device *priv_dev,
     	}
     
     	while (!list_empty(&priv_ep->deferred_req_list)) {
    -		request = cdns3_next_request(&priv_ep->deferred_req_list);
    +		priv_req = cdns3_next_request(&priv_ep->deferred_req_list);
     
     		if (!priv_ep->use_streams) {
    -			ret = cdns3_ep_run_transfer(priv_ep, request);
    +			ret = cdns3_ep_run_transfer(priv_ep, &priv_req->request);
     		} else {
     			priv_ep->stream_sg_idx = 0;
    -			ret = cdns3_ep_run_stream_transfer(priv_ep, request);
    +			ret = cdns3_ep_run_stream_transfer(priv_ep,
    +					&priv_req->request);
     		}
     		if (ret)
     			return ret;
     
    -		list_del(&request->list);
    -		list_add_tail(&request->list,
    +		list_del_init(&priv_req->tlist);
    +		list_add_tail(&priv_req->tlist,
     			      &priv_ep->pending_req_list);
    -		if (request->stream_id != 0 || (priv_ep->flags & EP_TDLCHK_EN))
    +		if (priv_req->request.stream_id != 0 ||
    +				(priv_ep->flags & EP_TDLCHK_EN))
     			break;
     	}
     
    @@ -527,9 +526,11 @@ static struct usb_request *cdns3_wa2_gadget_giveback(struct cdns3_device *priv_d
     {
     	if (priv_ep->flags & EP_QUIRK_EXTRA_BUF_EN &&
     	    priv_req->flags & REQUEST_INTERNAL) {
    +		struct cdns3_request *priv;
     		struct usb_request *req;
     
    -		req = cdns3_next_request(&priv_ep->deferred_req_list);
    +		priv = cdns3_next_request(&priv_ep->deferred_req_list);
    +		req = &priv->request;
     
     		priv_ep->descmis_req = NULL;
     
    @@ -553,7 +554,7 @@ static struct usb_request *cdns3_wa2_gadget_giveback(struct cdns3_device *priv_d
     		if (req->status == -EINPROGRESS)
     			req->status = 0;
     
    -		list_del_init(&req->list);
    +		list_del_init(&priv->tlist);
     		cdns3_start_all_request(priv_dev, priv_ep);
     		return req;
     	}
    @@ -599,7 +600,8 @@ static int cdns3_wa2_gadget_ep_queue(struct cdns3_device *priv_dev,
     
     			trace_cdns3_wa2(priv_ep, "get internal stored data");
     
    -			list_add_tail(&priv_req->request.list,
    +			dev_info(NULL, ">>> in cdns3_start_all_request\n");
    +			list_add_tail(&priv_req->tlist,
     				      &priv_ep->pending_req_list);
     			cdns3_gadget_giveback(priv_ep, priv_req,
     					      priv_req->request.status);
    @@ -812,7 +814,7 @@ void cdns3_gadget_giveback(struct cdns3_endpoint *priv_ep,
     	struct cdns3_device *priv_dev = priv_ep->cdns3_dev;
     	struct usb_request *request = &priv_req->request;
     
    -	list_del_init(&request->list);
    +	list_del_init(&priv_req->tlist);
     
     	if (request->status == -EINPROGRESS)
     		request->status = status;
    @@ -1500,8 +1502,8 @@ static void cdns3_transfer_completed(struct cdns3_device *priv_dev,
     	bool transfer_end = false;
     
     	while (!list_empty(&priv_ep->pending_req_list)) {
    -		request = cdns3_next_request(&priv_ep->pending_req_list);
    -		priv_req = to_cdns3_request(request);
    +		priv_req = cdns3_next_request(&priv_ep->pending_req_list);
    +		request = &priv_req->request;
     
     		trb = priv_ep->trb_pool + priv_ep->dequeue;
     
    @@ -1629,8 +1631,8 @@ static int cdns3_check_ep_interrupt_proceed(struct cdns3_endpoint *priv_ep)
     {
     	struct cdns3_device *priv_dev = priv_ep->cdns3_dev;
     	u32 ep_sts_reg;
    -	struct usb_request *deferred_request;
    -	struct usb_request *pending_request;
    +	struct cdns3_request *deferred_request;
    +	struct cdns3_request *pending_request;
     	u32 tdl = 0;
     
     	cdns3_select_ep(priv_dev, priv_ep->endpoint.address);
    @@ -2414,7 +2416,6 @@ static int cdns3_gadget_ep_disable(struct usb_ep *ep)
     	struct cdns3_endpoint *priv_ep;
     	struct cdns3_request *priv_req;
     	struct cdns3_device *priv_dev;
    -	struct usb_request *request;
     	unsigned long flags;
     	int ret = 0;
     	u32 ep_cfg;
    @@ -2459,10 +2460,9 @@ static int cdns3_gadget_ep_disable(struct usb_ep *ep)
     			priv_ep->name);
     
     	while (!list_empty(&priv_ep->pending_req_list)) {
    -		request = cdns3_next_request(&priv_ep->pending_req_list);
    +		priv_req = cdns3_next_request(&priv_ep->pending_req_list);
     
    -		cdns3_gadget_giveback(priv_ep, to_cdns3_request(request),
    -				      -ESHUTDOWN);
    +		cdns3_gadget_giveback(priv_ep, priv_req, -ESHUTDOWN);
     	}
     
     	while (!list_empty(&priv_ep->wa2_descmiss_req_list)) {
    @@ -2476,10 +2476,9 @@ static int cdns3_gadget_ep_disable(struct usb_ep *ep)
     	}
     
     	while (!list_empty(&priv_ep->deferred_req_list)) {
    -		request = cdns3_next_request(&priv_ep->deferred_req_list);
    +		priv_req = cdns3_next_request(&priv_ep->deferred_req_list);
     
    -		cdns3_gadget_giveback(priv_ep, to_cdns3_request(request),
    -				      -ESHUTDOWN);
    +		cdns3_gadget_giveback(priv_ep, priv_req, -ESHUTDOWN);
     	}
     
     	priv_ep->descmis_req = NULL;
    @@ -2527,12 +2526,16 @@ static int __cdns3_gadget_ep_queue(struct usb_ep *ep,
     	if (ret < 0)
     		return ret;
     
    +	/* ep->desc could be NULL if teardown happens in parallel */
    +	if (!ep->desc)
    +		return -ENOENT;
    +
     	ret = usb_gadget_map_request_by_dev(priv_dev->sysdev, request,
     					    usb_endpoint_dir_in(ep->desc));
     	if (ret)
     		return ret;
     
    -	list_add_tail(&request->list, &priv_ep->deferred_req_list);
    +	list_add_tail(&priv_req->tlist, &priv_ep->deferred_req_list);
     
     	/*
     	 * For stream capable endpoint if prime irq flag is set then only start
    @@ -2605,7 +2608,7 @@ int cdns3_gadget_ep_dequeue(struct usb_ep *ep,
     {
     	struct cdns3_endpoint *priv_ep = ep_to_cdns3_ep(ep);
     	struct cdns3_device *priv_dev;
    -	struct usb_request *req, *req_temp;
    +	struct cdns3_request *req, *req_temp;
     	struct cdns3_request *priv_req;
     	struct cdns3_trb *link_trb;
     	u8 req_on_hw_ring = 0;
    @@ -2627,7 +2630,7 @@ int cdns3_gadget_ep_dequeue(struct usb_ep *ep,
     
     	list_for_each_entry_safe(req, req_temp, &priv_ep->pending_req_list,
     				 list) {
    -		if (request == req) {
    +		if (priv_req == req) {
     			req_on_hw_ring = 1;
     			goto found;
     		}
    @@ -2635,7 +2638,7 @@ int cdns3_gadget_ep_dequeue(struct usb_ep *ep,
     
     	list_for_each_entry_safe(req, req_temp, &priv_ep->deferred_req_list,
     				 list) {
    -		if (request == req)
    +		if (priv_req == req)
     			goto found;
     	}
     
    @@ -2691,7 +2694,6 @@ void __cdns3_gadget_ep_set_halt(struct cdns3_endpoint *priv_ep)
     int __cdns3_gadget_ep_clear_halt(struct cdns3_endpoint *priv_ep)
     {
     	struct cdns3_device *priv_dev = priv_ep->cdns3_dev;
    -	struct usb_request *request;
     	struct cdns3_request *priv_req;
     	struct cdns3_trb *trb = NULL;
     	struct cdns3_trb trb_tmp;
    @@ -2700,9 +2702,8 @@ int __cdns3_gadget_ep_clear_halt(struct cdns3_endpoint *priv_ep)
     
     	trace_cdns3_halt(priv_ep, 0, 0);
     
    -	request = cdns3_next_request(&priv_ep->pending_req_list);
    -	if (request) {
    -		priv_req = to_cdns3_request(request);
    +	priv_req = cdns3_next_request(&priv_ep->pending_req_list);
    +	if (priv_req) {
     		trb = priv_req->trb;
     		if (trb) {
     			trb_tmp = *trb;
    @@ -2720,7 +2721,7 @@ int __cdns3_gadget_ep_clear_halt(struct cdns3_endpoint *priv_ep)
     
     	priv_ep->flags &= ~(EP_STALLED | EP_STALL_PENDING);
     
    -	if (request) {
    +	if (priv_req) {
     		if (trb)
     			*trb = trb_tmp;
     
    diff --git a/drivers/usb/cdns3/gadget.h b/drivers/usb/cdns3/gadget.h
    index 21fa461c518e..cf84da1ad516 100644
    --- a/drivers/usb/cdns3/gadget.h
    +++ b/drivers/usb/cdns3/gadget.h
    @@ -1220,6 +1220,7 @@ struct cdns3_aligned_buf {
      * @aligned_buf: object holds information about aligned buffer associated whit
      *               this endpoint
      * @flags: flag specifying special usage of request
    + * @tlist: used by request queueing to pending_req_list or deferred_req_list.
      * @list: used by internally allocated request to add to wa2_descmiss_req_list.
      * @finished_trb: number of trb has already finished per request
      * @num_of_trb: how many trbs in this request
    @@ -1237,6 +1238,7 @@ struct cdns3_request {
     #define REQUEST_ZLP			BIT(3)
     #define REQUEST_UNALIGNED		BIT(4)
     	u32				flags;
    +	struct list_head		tlist;
     	struct list_head		list;
     	int				finished_trb;
     	int				num_of_trb;
    @@ -1341,7 +1343,7 @@ void cdns3_hw_reset_eps_config(struct cdns3_device *priv_dev);
     void cdns3_set_hw_configuration(struct cdns3_device *priv_dev);
     void cdns3_select_ep(struct cdns3_device *priv_dev, u32 ep);
     void cdns3_allow_enable_l1(struct cdns3_device *priv_dev, int enable);
    -struct usb_request *cdns3_next_request(struct list_head *list);
    +struct cdns3_request *cdns3_next_request(struct list_head *list);
     void cdns3_rearm_transfer(struct cdns3_endpoint *priv_ep, u8 rearm);
     int cdns3_allocate_trb_pool(struct cdns3_endpoint *priv_ep);
     u8 cdns3_ep_addr_to_index(u8 ep_addr);
    

  • Hi Bin,

    The customer tried the patch, but below error happens.

    root@am64xx-evm:~# [  133.273991] Initializing XFRM netlink socket
    [  135.356707] bridge: filtering via arp/ip/ip6tables is no longer available by default. Update your scripts to load br_netfilter if you need this.
    [  135.378089] Bridge firewalling registered
    [  137.105273] process 'docker/tmp/qemu-check144201394/check' started with executable stack
    [  138.845520] configfs-gadget gadget: Using interface 2
    [  138.851117] IPv6: ADDRCONF(NETDEV_CHANGE): usb0: link becomes ready
    [  138.859624] configfs-gadget gadget: Using interface 2
    
    root@am64xx-evm:~# cat /boot/Image > /dev/g_printer0
    [  147.419786] ------------[ cut here ]------------
    [  147.420075] ------------[ cut here ]------------
    [  147.424444] WARNING: CPU: 1 PID: 1059 at drivers/usb/gadget/udc/core.c:276 usb_ep_queue+0x10/0x40 [udc_core]
    [  147.429031] WARNING: CPU: 0 PID: 561 at drivers/usb/gadget/function/f_printer.c:1422 printer_func_unbind+0x1f0/0x210 [usb_f_printer]
    [  147.438820] Modules linked in:
    [  147.450698] Modules linked in:
    [  147.450704]  xt_conntrack
    [  147.453742]  xt_conntrack
    [  147.456781]  xt_MASQUERADE
    [  147.459387]  xt_MASQUERADE
    [  147.461993]  xt_addrtype
    [  147.464687]  xt_addrtype
    [  147.467380]  iptable_filter
    [  147.469899]  iptable_filter
    [  147.472419]  iptable_nat
    [  147.475198]  iptable_nat
    [  147.477978]  nf_nat
    [  147.480498]  nf_nat
    [  147.483018]  nf_conntrack
    [  147.485104]  nf_conntrack
    [  147.487191]  nf_defrag_ipv6
    [  147.489797]  nf_defrag_ipv6
    [  147.492403]  nf_defrag_ipv4
    [  147.495184]  nf_defrag_ipv4
    [  147.497963]  libcrc32c
    [  147.500742]  libcrc32c
    [  147.503521]  ip_tables
    [  147.505868]  ip_tables
    [  147.508213]  x_tables
    [  147.510560]  x_tables
    [  147.512906]  br_netfilter
    [  147.515165]  br_netfilter
    [  147.517424]  bridge
    [  147.520030]  bridge
    [  147.522637]  stp
    [  147.524723]  stp
    [  147.526809]  llc
    [  147.528636]  llc
    [  147.530461]  overlay
    [  147.532287]  overlay
    [  147.534113]  xfrm_user
    [  147.536287]  xfrm_user
    [  147.538459]  xfrm_algo
    [  147.540805]  xfrm_algo
    [  147.543151]  usb_f_printer
    [  147.545498]  usb_f_printer
    [  147.547843]  usb_f_rndis
    [  147.550536]  usb_f_rndis
    [  147.553230]  u_ether
    [  147.555750]  u_ether
    [  147.558268]  libcomposite
    [  147.560441]  libcomposite
    [  147.562614]  wlcore_sdio
    [  147.565220]  wlcore_sdio
    [  147.567826]  wl18xx
    [  147.570345]  wl18xx
    [  147.572864]  wlcore
    [  147.574951]  wlcore
    [  147.577038]  mac80211
    [  147.579124]  mac80211
    [  147.581210]  cfg80211
    [  147.583469]  cfg80211
    [  147.585728]  rfkill
    [  147.587988]  rfkill
    [  147.590247]  libarc4
    [  147.592333]  libarc4
    [  147.594419]  cdns3
    [  147.596592]  cdns3
    [  147.598765]  udc_core
    [  147.600764]  udc_core
    [  147.602762]  roles
    [  147.605022]  roles
    [  147.607282]  usbcore
    [  147.609282]  usbcore
    [  147.611281]  usb_common
    [  147.613454]  usb_common
    [  147.615627]  rpmsg_char
    [  147.618059]  rpmsg_char
    [  147.620492]  irq_pruss_intc
    [  147.622926]  irq_pruss_intc
    [  147.625359]  icssg_prueth
    [  147.628138]  icssg_prueth
    [  147.630917]  crct10dif_ce
    [  147.633524]  crct10dif_ce
    [  147.636130]  pru_rproc
    [  147.638736]  pru_rproc
    [  147.641342]  icss_iep
    [  147.643688]  icss_iep
    [  147.646033]  pci_endpoint_test
    [  147.648293]  pci_endpoint_test
    [  147.650553]  phy_can_transceiver
    [  147.653592]  phy_can_transceiver
    [  147.656631]  cdns3_ti
    [  147.659845]  cdns3_ti
    [  147.663058]  rti_wdt
    [  147.665318]  rti_wdt
    [  147.667577]  ti_k3_r5_remoteproc
    [  147.669751]  ti_k3_r5_remoteproc
    [  147.671924]  virtio_rpmsg_bus
    [  147.675136]  virtio_rpmsg_bus
    [  147.678349]  ti_k3_m4_remoteproc
    [  147.681302]  ti_k3_m4_remoteproc
    [  147.684256]  sa2ul
    [  147.687469]  sa2ul
    [  147.690682]  sha512_generic
    [  147.692682]  sha512_generic
    [  147.694682]  m_can_platform
    [  147.697462]  m_can_platform
    [  147.700241]  m_can
    [  147.703021]  m_can
    [  147.705800]  authenc
    [  147.707800]  authenc
    [  147.709799]  pruss
    [  147.711973]  pruss
    [  147.714146]  can_dev
    [  147.716146]  can_dev
    [  147.718145]  eeprom_93xx46
    [  147.720318]  eeprom_93xx46
    [  147.722491]  optee_rng
    [  147.725183]  optee_rng
    [  147.727876]  rng_core
    [  147.730222]  rng_core
    [  147.732568]  sch_fq_codel
    [  147.734827]  sch_fq_codel
    [  147.737087]  ipv6
    [  147.739693]  ipv6
    [  147.742299]
    [  147.744211]
    [  147.746130] CPU: 1 PID: 1059 Comm: cat Not tainted 5.10.168-g2c23e6c538 #1
    [  147.747606] CPU: 0 PID: 561 Comm: irq/543-f400000 Not tainted 5.10.168-g2c23e6c538 #1
    [  147.749084] Hardware name: Texas Instruments AM642 EVM (DT)
    [  147.755936] Hardware name: Texas Instruments AM642 EVM (DT)
    [  147.763746] pstate: 40000085 (nZcv daIf -PAN -UAO -TCO BTYPE=--)
    [  147.769299] pstate: 20000005 (nzCv daif -PAN -UAO -TCO BTYPE=--)
    [  147.774859] pc : usb_ep_queue+0x10/0x40 [udc_core]
    [  147.780841] pc : printer_func_unbind+0x1f0/0x210 [usb_f_printer]
    [  147.786826] lr : printer_write+0x1e8/0x3b4 [usb_f_printer]
    [  147.791600] lr : printer_func_unbind+0x48/0x210 [usb_f_printer]
    [  147.797581] sp : ffff800012783d20
    [  147.803047] sp : ffff800011ed3b90
    [  147.808946] x29: ffff800012783d20
    [  147.812246] x29: ffff800011ed3b90
    [  147.815545] x28: 0000000000000000
    [  147.818930] x28: 0000000000000000
    [  147.822317]
    [  147.825704]
    [  147.829090] x27: ffff000003f9b000
    [  147.830569] x27: ffff000006029348
    [  147.832049] x26: 0000000000002000
    [  147.835436] x26: ffff8000111d7208
    [  147.838820]
    [  147.842207]
    [  147.845595] x25: ffff000003f9b098
    [  147.847075] x25: ffff8000100bdda0
    [  147.848554] x24: ffff00000efc4740
    [  147.851941] x24: ffff800008ce6000
    [  147.855325]
    [  147.858711]
    [  147.862099] x23: 0000000000002000
    [  147.863577] x23: ffff00000875d490
    [  147.865057] x22: ffff00000efcc900
    [  147.868442] x22: ffff000003e2b600
    [  147.871828]
    [  147.875215]
    [  147.878602] x21: 0000ffff86bb5000
    [  147.880081] x21: ffff000003f9b1a0
    [  147.881560] x20: 000000000000a000
    [  147.884947] x20: ffff000003e2b520
    [  147.888332]
    [  147.891718]
    [  147.895106] x19: ffff00000efcc940
    [  147.896585] x19: ffff000003f9b000
    [  147.898064] x18: 0000000000000000
    [  147.901451] x18: 00000000fffffffb
    [  147.904836]
    [  147.908222]
    [  147.911609] x17: 0000000000000000
    [  147.913088] x17: 0000000000000000
    [  147.914568] x16: 0000000000000000
    [  147.917954] x16: 0000000000000000
    [  147.921339]
    [  147.924725]
    [  147.928112] x15: 0000ffff86bb3000
    [  147.929591] x15: 0000000000000020
    [  147.931071] x14: d503201fb9400041
    [  147.934457] x14: 0000000000000000
    [  147.937843]
    [  147.941229]
    [  147.944616] x13: 52800000d503201f
    [  147.946095] x13: 0000000000000001
    [  147.947574] x12: d503229f9a9f0022
    [  147.950960] x12: 0000000000000040
    [  147.954345]
    [  147.957732]
    [  147.961119] x11: ea23001ff9400443
    [  147.962599] x11: 0000000000000000
    [  147.964078] x10: 8a010000d5384102
    [  147.967464] x10: 0000000000000000
    [  147.970848]
    [  147.974234]
    [  147.977620] x9 : 9340dc20b4fffe20
    [  147.979099] x9 : 0000000000000000
    [  147.980578] x8 : 9a9f87e0fa02001f
    [  147.983964] x8 : 0000000000000000
    [  147.987349]
    [  147.990735]
    [  147.994122] x7 : da9f30009a8283e2
    [  147.995602] x7 : ffff000003c65348
    [  147.997082] x6 : ffff00000859e000
    [  148.000468] x6 : ffff000000e6c740
    [  148.003853]
    [  148.007239]
    [  148.010626] x5 : ffff00000859e000
    [  148.012105] x5 : ffff000003f9b140
    [  148.013584] x4 : 0000000000000000
    [  148.016970] x4 : 0000000000000000
    [  148.020356]
    [  148.023742]
    [  148.027128] x3 : 0000000000000083
    [  148.028607] x3 : 0000000000000001
    [  148.030087] x2 : 0000000000000a20
    [  148.033473] x2 : 0000000000000001
    [  148.036857]
    [  148.040243]
    [  148.043630] x1 : ffff00000efcc900
    [  148.045110] x1 : ffff00000efcc940
    [  148.046590] x0 : ffff000003d46e80
    [  148.049977] x0 : ffff000003f9b0a8
    [  148.053362]
    [  148.056748]
    [  148.060134] Call trace:
    [  148.061613] Call trace:
    [  148.063103]  usb_ep_queue+0x10/0x40 [udc_core]
    [  148.065530]  printer_func_unbind+0x1f0/0x210 [usb_f_printer]
    [  148.067968]  vfs_write+0xf0/0x284
    [  148.072405]  purge_configs_funcs+0x7c/0xf0 [libcomposite]
    [  148.078029]  ksys_write+0x68/0xf4
    [  148.081337]  configfs_composite_unbind+0x5c/0xb0 [libcomposite]
    [  148.086709]  __arm64_sys_write+0x1c/0x2c
    [  148.090014]  usb_gadget_remove_driver+0x40/0x80 [udc_core]
    [  148.095911]  el0_svc_common.constprop.0+0x78/0x1c4
    [  148.099819]  usb_del_gadget+0x68/0xc4 [udc_core]
    [  148.105279]  do_el0_svc+0x24/0x9c
    [  148.110059]  cdns3_gadget_exit+0x48/0x140 [cdns3]
    [  148.114655]  el0_svc+0x14/0x20
    [  148.117956]  cdns3_role_stop+0x60/0xa0 [cdns3]
    [  148.122639]  el0_sync_handler+0xb0/0xb4
    [  148.125682]  cdns3_hw_role_switch.part.0+0x60/0x140 [cdns3]
    [  148.130105]  el0_sync+0x180/0x1c0
    [  148.133927]  cdns3_hw_role_switch+0x20/0x2c [cdns3]
    [  148.139475] ---[ end trace a8bc6a7415f3b1d0 ]---
    [  148.142780]  cdns3_drd_thread_irq+0x14/0x24 [cdns3]
    [  148.157153]  irq_thread_fn+0x2c/0xb0
    [  148.157162]  irq_thread+0x1b8/0x300
    [  148.157170]  kthread+0x154/0x160
    cat: write error: Resource temporarily unavailable
    [  148.157177]  ret_from_fork+0x10/0x38
    root@am64xx-evm:~# [  148.157184] ---[ end trace a8bc6a7415f3b1d1 ]---
    [  151.041335] configfs-gadget gadget: Using interface 2
    [  151.048548] configfs-gadget gadget: Using interface 2
    


    Here are patches the customer applied to their SDK8.6.
    https://e2e.ti.com/cfs-file/__key/communityserver-discussions-components-files/791/linux_5F00_cdns3_5F00_fix_5F00_v3.patch
    https://e2e.ti.com/cfs-file/__key/communityserver-discussions-components-files/791/linux_5F00_usb_5F00_ep_5F00_queue_5F00_warning_5F00_testing_5F00_fix.patch

    Thanks and regards,
    Koichiro Tashiro

  • Hi Tashiro-san,


    The customer tried the patch, but below error happens.

    This is a one-time warning printed by the USB printer gadget driver, it shouldn't affect any functionality. The message can be ignored.

    Can you please ask the customer to check if they see any USB issues except this WARNING message?

  • Hi Tashiro-san,

    Does the customer have any update on the test result?

  • Hi Bin,

    There is no USB functional issue excepts this WARNING at customer side.
    So it can be closed for now. If they see functional issue, they will let us know.

    Thanks and regards,
    Koichiro Tashiro

  • Hi Tashiro-san,

    Thanks for the update. I am closing this thread.