All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: [PATCH 2/2] usb: chipidea: udc: create bounce buffer for problem sglist entries if possible
@ 2024-09-14  9:57 kernel test robot
  0 siblings, 0 replies; 4+ messages in thread
From: kernel test robot @ 2024-09-14  9:57 UTC (permalink / raw)
  To: oe-kbuild; +Cc: lkp, Dan Carpenter

BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
In-Reply-To: <20240912045150.915573-2-xu.yang_2@nxp.com>
References: <20240912045150.915573-2-xu.yang_2@nxp.com>
TO: Xu Yang <xu.yang_2@nxp.com>
TO: peter.chen@kernel.org
TO: gregkh@linuxfoundation.org
CC: linux-usb@vger.kernel.org
CC: imx@lists.linux.dev
CC: jun.li@nxp.com

Hi Xu,

kernel test robot noticed the following build warnings:

[auto build test WARNING on usb/usb-testing]
[also build test WARNING on usb/usb-next usb/usb-linus linus/master v6.11-rc7 next-20240913]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Xu-Yang/usb-chipidea-udc-create-bounce-buffer-for-problem-sglist-entries-if-possible/20240912-125251
base:   https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-testing
patch link:    https://lore.kernel.org/r/20240912045150.915573-2-xu.yang_2%40nxp.com
patch subject: [PATCH 2/2] usb: chipidea: udc: create bounce buffer for problem sglist entries if possible
:::::: branch date: 2 days ago
:::::: commit date: 2 days ago
config: i386-randconfig-141-20240914 (https://download.01.org/0day-ci/archive/20240914/202409141707.TOsGfePE-lkp@intel.com/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Reported-by: Dan Carpenter <error27@gmail.com>
| Closes: https://lore.kernel.org/r/202409141707.TOsGfePE-lkp@intel.com/

New smatch warnings:
drivers/usb/chipidea/udc.c:704 _hardware_enqueue() error: uninitialized symbol 'bounced_size'.

Old smatch warnings:
drivers/usb/chipidea/udc.c:2112 ci_udc_start() warn: missing error code? 'retval'

vim +/bounced_size +704 drivers/usb/chipidea/udc.c

91db40933ca942 drivers/usb/chipidea/udc.c       Xu Yang            2024-09-12  663  
aa69a8093ff985 drivers/usb/gadget/ci13xxx_udc.c David Lopo         2008-11-17  664  /**
e46fed9fb3a12b drivers/usb/chipidea/udc.c       Felipe F. Tonello  2015-09-18  665   * _hardware_enqueue: configures a request at hardware level
2dbc5c4c831418 drivers/usb/chipidea/udc.c       Alexander Shishkin 2013-06-13  666   * @hwep:   endpoint
e46fed9fb3a12b drivers/usb/chipidea/udc.c       Felipe F. Tonello  2015-09-18  667   * @hwreq:  request
aa69a8093ff985 drivers/usb/gadget/ci13xxx_udc.c David Lopo         2008-11-17  668   *
aa69a8093ff985 drivers/usb/gadget/ci13xxx_udc.c David Lopo         2008-11-17  669   * This function returns an error code
aa69a8093ff985 drivers/usb/gadget/ci13xxx_udc.c David Lopo         2008-11-17  670   */
8e22978c57087a drivers/usb/chipidea/udc.c       Alexander Shishkin 2013-06-24  671  static int _hardware_enqueue(struct ci_hw_ep *hwep, struct ci_hw_req *hwreq)
aa69a8093ff985 drivers/usb/gadget/ci13xxx_udc.c David Lopo         2008-11-17  672  {
8e22978c57087a drivers/usb/chipidea/udc.c       Alexander Shishkin 2013-06-24  673  	struct ci_hdrc *ci = hwep->ci;
0e6ca1998e4c80 drivers/usb/gadget/ci13xxx_udc.c Pavankumar Kondeti 2011-02-18  674  	int ret = 0;
cc9e6c495b0a37 drivers/usb/chipidea/udc.c       Michael Grzeschik  2013-06-13  675  	struct td_node *firstnode, *lastnode;
91db40933ca942 drivers/usb/chipidea/udc.c       Xu Yang            2024-09-12  676  	unsigned int bounced_size;
91db40933ca942 drivers/usb/chipidea/udc.c       Xu Yang            2024-09-12  677  	struct scatterlist *sg;
aa69a8093ff985 drivers/usb/gadget/ci13xxx_udc.c David Lopo         2008-11-17  678  
aa69a8093ff985 drivers/usb/gadget/ci13xxx_udc.c David Lopo         2008-11-17  679  	/* don't queue twice */
2dbc5c4c831418 drivers/usb/chipidea/udc.c       Alexander Shishkin 2013-06-13  680  	if (hwreq->req.status == -EALREADY)
aa69a8093ff985 drivers/usb/gadget/ci13xxx_udc.c David Lopo         2008-11-17  681  		return -EALREADY;
aa69a8093ff985 drivers/usb/gadget/ci13xxx_udc.c David Lopo         2008-11-17  682  
2dbc5c4c831418 drivers/usb/chipidea/udc.c       Alexander Shishkin 2013-06-13  683  	hwreq->req.status = -EALREADY;
aa69a8093ff985 drivers/usb/gadget/ci13xxx_udc.c David Lopo         2008-11-17  684  
91db40933ca942 drivers/usb/chipidea/udc.c       Xu Yang            2024-09-12  685  	if (hwreq->req.num_sgs && hwreq->req.length) {
91db40933ca942 drivers/usb/chipidea/udc.c       Xu Yang            2024-09-12  686  		ret = sglist_get_invalid_entry(ci->dev->parent, hwep->dir,
91db40933ca942 drivers/usb/chipidea/udc.c       Xu Yang            2024-09-12  687  					&hwreq->req);
91db40933ca942 drivers/usb/chipidea/udc.c       Xu Yang            2024-09-12  688  		if (ret < hwreq->req.num_sgs) {
91db40933ca942 drivers/usb/chipidea/udc.c       Xu Yang            2024-09-12  689  			ret = sglist_do_bounce(hwreq, ret, hwep->dir == TX,
91db40933ca942 drivers/usb/chipidea/udc.c       Xu Yang            2024-09-12  690  					&bounced_size);
91db40933ca942 drivers/usb/chipidea/udc.c       Xu Yang            2024-09-12  691  			if (ret)
91db40933ca942 drivers/usb/chipidea/udc.c       Xu Yang            2024-09-12  692  				return ret;
91db40933ca942 drivers/usb/chipidea/udc.c       Xu Yang            2024-09-12  693  		}
91db40933ca942 drivers/usb/chipidea/udc.c       Xu Yang            2024-09-12  694  	}
91db40933ca942 drivers/usb/chipidea/udc.c       Xu Yang            2024-09-12  695  
aeb78cda51005f drivers/usb/chipidea/udc.c       Arnd Bergmann      2017-03-13  696  	ret = usb_gadget_map_request_by_dev(ci->dev->parent,
aeb78cda51005f drivers/usb/chipidea/udc.c       Arnd Bergmann      2017-03-13  697  					    &hwreq->req, hwep->dir);
5e0aa49ec61e88 drivers/usb/chipidea/udc.c       Alexander Shishkin 2012-05-11  698  	if (ret)
5e0aa49ec61e88 drivers/usb/chipidea/udc.c       Alexander Shishkin 2012-05-11  699  		return ret;
5e0aa49ec61e88 drivers/usb/chipidea/udc.c       Alexander Shishkin 2012-05-11  700  
91db40933ca942 drivers/usb/chipidea/udc.c       Xu Yang            2024-09-12  701  	if (hwreq->sgt.sgl) {
91db40933ca942 drivers/usb/chipidea/udc.c       Xu Yang            2024-09-12  702  		/* We've mapped a bigger buffer, now recover the actual size */
91db40933ca942 drivers/usb/chipidea/udc.c       Xu Yang            2024-09-12  703  		sg = sg_last(hwreq->req.sg, hwreq->req.num_sgs);
91db40933ca942 drivers/usb/chipidea/udc.c       Xu Yang            2024-09-12 @704  		sg_dma_len(sg) = min(sg_dma_len(sg), bounced_size);
91db40933ca942 drivers/usb/chipidea/udc.c       Xu Yang            2024-09-12  705  	}
91db40933ca942 drivers/usb/chipidea/udc.c       Xu Yang            2024-09-12  706  
e48aa1eb443f80 drivers/usb/chipidea/udc.c       Peter Chen         2020-02-21  707  	if (hwreq->req.num_mapped_sgs)
e48aa1eb443f80 drivers/usb/chipidea/udc.c       Peter Chen         2020-02-21  708  		ret = prepare_td_for_sg(hwep, hwreq);
e48aa1eb443f80 drivers/usb/chipidea/udc.c       Peter Chen         2020-02-21  709  	else
e48aa1eb443f80 drivers/usb/chipidea/udc.c       Peter Chen         2020-02-21  710  		ret = prepare_td_for_non_sg(hwep, hwreq);
aa69a8093ff985 drivers/usb/gadget/ci13xxx_udc.c David Lopo         2008-11-17  711  
e48aa1eb443f80 drivers/usb/chipidea/udc.c       Peter Chen         2020-02-21  712  	if (ret)
e48aa1eb443f80 drivers/usb/chipidea/udc.c       Peter Chen         2020-02-21  713  		return ret;
cc9e6c495b0a37 drivers/usb/chipidea/udc.c       Michael Grzeschik  2013-06-13  714  
2dbc5c4c831418 drivers/usb/chipidea/udc.c       Alexander Shishkin 2013-06-13  715  	lastnode = list_entry(hwreq->tds.prev,
cc9e6c495b0a37 drivers/usb/chipidea/udc.c       Michael Grzeschik  2013-06-13  716  		struct td_node, td);
cc9e6c495b0a37 drivers/usb/chipidea/udc.c       Michael Grzeschik  2013-06-13  717  
cc9e6c495b0a37 drivers/usb/chipidea/udc.c       Michael Grzeschik  2013-06-13  718  	lastnode->ptr->next = cpu_to_le32(TD_TERMINATE);
2dbc5c4c831418 drivers/usb/chipidea/udc.c       Alexander Shishkin 2013-06-13  719  	if (!hwreq->req.no_interrupt)
cc9e6c495b0a37 drivers/usb/chipidea/udc.c       Michael Grzeschik  2013-06-13  720  		lastnode->ptr->token |= cpu_to_le32(TD_IOC);
b4c5d446a65566 drivers/usb/chipidea/udc.c       Peter Chen         2020-03-25  721  
b4c5d446a65566 drivers/usb/chipidea/udc.c       Peter Chen         2020-03-25  722  	list_for_each_entry_safe(firstnode, lastnode, &hwreq->tds, td)
b4c5d446a65566 drivers/usb/chipidea/udc.c       Peter Chen         2020-03-25  723  		trace_ci_prepare_td(hwep, hwreq, firstnode);
b4c5d446a65566 drivers/usb/chipidea/udc.c       Peter Chen         2020-03-25  724  
b4c5d446a65566 drivers/usb/chipidea/udc.c       Peter Chen         2020-03-25  725  	firstnode = list_first_entry(&hwreq->tds, struct td_node, td);
b4c5d446a65566 drivers/usb/chipidea/udc.c       Peter Chen         2020-03-25  726  
a9c174302b1590 drivers/usb/chipidea/udc.c       Michael Grzeschik  2013-04-04  727  	wmb();
a9c174302b1590 drivers/usb/chipidea/udc.c       Michael Grzeschik  2013-04-04  728  
2dbc5c4c831418 drivers/usb/chipidea/udc.c       Alexander Shishkin 2013-06-13  729  	hwreq->req.actual = 0;
2dbc5c4c831418 drivers/usb/chipidea/udc.c       Alexander Shishkin 2013-06-13  730  	if (!list_empty(&hwep->qh.queue)) {
8e22978c57087a drivers/usb/chipidea/udc.c       Alexander Shishkin 2013-06-24  731  		struct ci_hw_req *hwreqprev;
2dbc5c4c831418 drivers/usb/chipidea/udc.c       Alexander Shishkin 2013-06-13  732  		int n = hw_ep_bit(hwep->num, hwep->dir);
0e6ca1998e4c80 drivers/usb/gadget/ci13xxx_udc.c Pavankumar Kondeti 2011-02-18  733  		int tmp_stat;
cc9e6c495b0a37 drivers/usb/chipidea/udc.c       Michael Grzeschik  2013-06-13  734  		struct td_node *prevlastnode;
cc9e6c495b0a37 drivers/usb/chipidea/udc.c       Michael Grzeschik  2013-06-13  735  		u32 next = firstnode->dma & TD_ADDR_MASK;
0e6ca1998e4c80 drivers/usb/gadget/ci13xxx_udc.c Pavankumar Kondeti 2011-02-18  736  
2dbc5c4c831418 drivers/usb/chipidea/udc.c       Alexander Shishkin 2013-06-13  737  		hwreqprev = list_entry(hwep->qh.queue.prev,
8e22978c57087a drivers/usb/chipidea/udc.c       Alexander Shishkin 2013-06-24  738  				struct ci_hw_req, queue);
2dbc5c4c831418 drivers/usb/chipidea/udc.c       Alexander Shishkin 2013-06-13  739  		prevlastnode = list_entry(hwreqprev->tds.prev,
cc9e6c495b0a37 drivers/usb/chipidea/udc.c       Michael Grzeschik  2013-06-13  740  				struct td_node, td);
cc9e6c495b0a37 drivers/usb/chipidea/udc.c       Michael Grzeschik  2013-06-13  741  
cc9e6c495b0a37 drivers/usb/chipidea/udc.c       Michael Grzeschik  2013-06-13  742  		prevlastnode->ptr->next = cpu_to_le32(next);
0e6ca1998e4c80 drivers/usb/gadget/ci13xxx_udc.c Pavankumar Kondeti 2011-02-18  743  		wmb();
05735f0854e1e2 drivers/usb/chipidea/udc.c       Piyush Mehta       2021-09-13  744  
05735f0854e1e2 drivers/usb/chipidea/udc.c       Piyush Mehta       2021-09-13  745  		if (ci->rev == CI_REVISION_22) {
05735f0854e1e2 drivers/usb/chipidea/udc.c       Piyush Mehta       2021-09-13  746  			if (!hw_read(ci, OP_ENDPTSTAT, BIT(n)))
05735f0854e1e2 drivers/usb/chipidea/udc.c       Piyush Mehta       2021-09-13  747  				reprime_dtd(ci, hwep, prevlastnode);
05735f0854e1e2 drivers/usb/chipidea/udc.c       Piyush Mehta       2021-09-13  748  		}
05735f0854e1e2 drivers/usb/chipidea/udc.c       Piyush Mehta       2021-09-13  749  
26c696c678c4ce drivers/usb/chipidea/udc.c       Richard Zhao       2012-07-07  750  		if (hw_read(ci, OP_ENDPTPRIME, BIT(n)))
0e6ca1998e4c80 drivers/usb/gadget/ci13xxx_udc.c Pavankumar Kondeti 2011-02-18  751  			goto done;
0e6ca1998e4c80 drivers/usb/gadget/ci13xxx_udc.c Pavankumar Kondeti 2011-02-18  752  		do {
26c696c678c4ce drivers/usb/chipidea/udc.c       Richard Zhao       2012-07-07  753  			hw_write(ci, OP_USBCMD, USBCMD_ATDTW, USBCMD_ATDTW);
26c696c678c4ce drivers/usb/chipidea/udc.c       Richard Zhao       2012-07-07  754  			tmp_stat = hw_read(ci, OP_ENDPTSTAT, BIT(n));
26c696c678c4ce drivers/usb/chipidea/udc.c       Richard Zhao       2012-07-07  755  		} while (!hw_read(ci, OP_USBCMD, USBCMD_ATDTW));
26c696c678c4ce drivers/usb/chipidea/udc.c       Richard Zhao       2012-07-07  756  		hw_write(ci, OP_USBCMD, USBCMD_ATDTW, 0);
0e6ca1998e4c80 drivers/usb/gadget/ci13xxx_udc.c Pavankumar Kondeti 2011-02-18  757  		if (tmp_stat)
0e6ca1998e4c80 drivers/usb/gadget/ci13xxx_udc.c Pavankumar Kondeti 2011-02-18  758  			goto done;
0e6ca1998e4c80 drivers/usb/gadget/ci13xxx_udc.c Pavankumar Kondeti 2011-02-18  759  	}
0e6ca1998e4c80 drivers/usb/gadget/ci13xxx_udc.c Pavankumar Kondeti 2011-02-18  760  
0e6ca1998e4c80 drivers/usb/gadget/ci13xxx_udc.c Pavankumar Kondeti 2011-02-18  761  	/*  QH configuration */
2dbc5c4c831418 drivers/usb/chipidea/udc.c       Alexander Shishkin 2013-06-13  762  	hwep->qh.ptr->td.next = cpu_to_le32(firstnode->dma);
2dbc5c4c831418 drivers/usb/chipidea/udc.c       Alexander Shishkin 2013-06-13  763  	hwep->qh.ptr->td.token &=
080ff5f4719e21 drivers/usb/chipidea/udc.c       Michael Grzeschik  2013-03-30  764  		cpu_to_le32(~(TD_STATUS_HALTED|TD_STATUS_ACTIVE));
aa69a8093ff985 drivers/usb/gadget/ci13xxx_udc.c David Lopo         2008-11-17  765  
2fc5a7dace3c43 drivers/usb/chipidea/udc.c       Peter Chen         2014-01-10  766  	if (hwep->type == USB_ENDPOINT_XFER_ISOC && hwep->dir == RX) {
2dbc5c4c831418 drivers/usb/chipidea/udc.c       Alexander Shishkin 2013-06-13  767  		u32 mul = hwreq->req.length / hwep->ep.maxpacket;
e4ce4ecd962e17 drivers/usb/chipidea/udc.c       Michael Grzeschik  2013-06-13  768  
2fc5a7dace3c43 drivers/usb/chipidea/udc.c       Peter Chen         2014-01-10  769  		if (hwreq->req.length == 0
2fc5a7dace3c43 drivers/usb/chipidea/udc.c       Peter Chen         2014-01-10  770  				|| hwreq->req.length % hwep->ep.maxpacket)
e4ce4ecd962e17 drivers/usb/chipidea/udc.c       Michael Grzeschik  2013-06-13  771  			mul++;
34445fb4333f47 drivers/usb/chipidea/udc.c       Stephen Boyd       2016-09-13  772  		hwep->qh.ptr->cap |= cpu_to_le32(mul << __ffs(QH_MULT));
e4ce4ecd962e17 drivers/usb/chipidea/udc.c       Michael Grzeschik  2013-06-13  773  	}
e4ce4ecd962e17 drivers/usb/chipidea/udc.c       Michael Grzeschik  2013-06-13  774  
2dbc5c4c831418 drivers/usb/chipidea/udc.c       Alexander Shishkin 2013-06-13  775  	ret = hw_ep_prime(ci, hwep->num, hwep->dir,
2dbc5c4c831418 drivers/usb/chipidea/udc.c       Alexander Shishkin 2013-06-13  776  			   hwep->type == USB_ENDPOINT_XFER_CONTROL);
0e6ca1998e4c80 drivers/usb/gadget/ci13xxx_udc.c Pavankumar Kondeti 2011-02-18  777  done:
0e6ca1998e4c80 drivers/usb/gadget/ci13xxx_udc.c Pavankumar Kondeti 2011-02-18  778  	return ret;
aa69a8093ff985 drivers/usb/gadget/ci13xxx_udc.c David Lopo         2008-11-17  779  }
aa69a8093ff985 drivers/usb/gadget/ci13xxx_udc.c David Lopo         2008-11-17  780  

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply	[flat|nested] 4+ messages in thread
* [PATCH 1/2] usb: chipidea: udc: limit usb request length to max 16KB
@ 2024-09-12  4:51 Xu Yang
  2024-09-12  4:51 ` [PATCH 2/2] usb: chipidea: udc: create bounce buffer for problem sglist entries if possible Xu Yang
  0 siblings, 1 reply; 4+ messages in thread
From: Xu Yang @ 2024-09-12  4:51 UTC (permalink / raw)
  To: peter.chen, gregkh; +Cc: linux-usb, imx, jun.li

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.

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.

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;
+	}
+
 	/* first nuke then test link, e.g. previous status has not sent */
 	if (!list_empty(&hwreq->queue)) {
 		dev_err(hwep->ci->dev, "request already in queue\n");
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-10-09 14:47 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-14  9:57 [PATCH 2/2] usb: chipidea: udc: create bounce buffer for problem sglist entries if possible kernel test robot
  -- strict thread matches above, loose matches on Subject: below --
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

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.