Re: [PATCH v1 3/3] usb: dwc2: Add High Bandwidth ISOC OUT support

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Minas,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on next-20180309]
[cannot apply to v4.16-rc4 v4.16-rc3 v4.16-rc2 v4.16-rc6]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Minas-Harutyunyan/usb-dwc2-gadget-Update-ISOC-DDMA-flow/20180318-134649

smatch warnings:
drivers/usb/dwc2/gadget.c:2250 dwc2_gadget_complete_isoc_request_ddma() warn: signed overflow undefined. 'index - (index / dpi) * dpi + 1 < dpi'
drivers/usb/dwc2/gadget.c:2270 dwc2_gadget_complete_isoc_request_ddma() warn: should this be a bitwise op?
drivers/usb/dwc2/gadget.c:2270 dwc2_gadget_complete_isoc_request_ddma() warn: should this be a bitwise op?

# https://github.com/0day-ci/linux/commit/ffb8a411a9d55bf8c15292a6ded7c8663a8ac290
git remote add linux-review https://github.com/0day-ci/linux
git remote update linux-review
git checkout ffb8a411a9d55bf8c15292a6ded7c8663a8ac290
vim +2250 drivers/usb/dwc2/gadget.c

5b7d70c6 drivers/usb/gadget/s3c-hsotg.c Ben Dooks         2009-06-02  2066  
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2067  static void dwc2_hsotg_ep_stop_xfr(struct dwc2_hsotg *hsotg,
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2068  				   struct dwc2_hsotg_ep *hs_ep);
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2069  
540ccba0 drivers/usb/dwc2/gadget.c      Vahram Aharonyan  2016-11-14  2070  /*
540ccba0 drivers/usb/dwc2/gadget.c      Vahram Aharonyan  2016-11-14  2071   * dwc2_gadget_complete_isoc_request_ddma - complete an isoc request in DDMA
540ccba0 drivers/usb/dwc2/gadget.c      Vahram Aharonyan  2016-11-14  2072   * @hs_ep: The endpoint the request was on.
540ccba0 drivers/usb/dwc2/gadget.c      Vahram Aharonyan  2016-11-14  2073   *
540ccba0 drivers/usb/dwc2/gadget.c      Vahram Aharonyan  2016-11-14  2074   * Get first request from the ep queue, determine descriptor on which complete
a19205da drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2075   * happened. SW discovers which descriptor currently in use by HW, adjusts
a19205da drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2076   * dma_address and calculates index of completed descriptor based on the value
a19205da drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2077   * of DEPDMA register. Update actual length of request, giveback to gadget.
540ccba0 drivers/usb/dwc2/gadget.c      Vahram Aharonyan  2016-11-14  2078   */
540ccba0 drivers/usb/dwc2/gadget.c      Vahram Aharonyan  2016-11-14  2079  static void dwc2_gadget_complete_isoc_request_ddma(struct dwc2_hsotg_ep *hs_ep)
540ccba0 drivers/usb/dwc2/gadget.c      Vahram Aharonyan  2016-11-14  2080  {
540ccba0 drivers/usb/dwc2/gadget.c      Vahram Aharonyan  2016-11-14  2081  	struct dwc2_hsotg *hsotg = hs_ep->parent;
540ccba0 drivers/usb/dwc2/gadget.c      Vahram Aharonyan  2016-11-14  2082  	struct dwc2_hsotg_req *hs_req;
540ccba0 drivers/usb/dwc2/gadget.c      Vahram Aharonyan  2016-11-14  2083  	struct usb_request *ureq;
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2084  	int index, idx;
540ccba0 drivers/usb/dwc2/gadget.c      Vahram Aharonyan  2016-11-14  2085  	dma_addr_t dma_addr;
540ccba0 drivers/usb/dwc2/gadget.c      Vahram Aharonyan  2016-11-14  2086  	u32 dma_reg;
540ccba0 drivers/usb/dwc2/gadget.c      Vahram Aharonyan  2016-11-14  2087  	u32 depdma;
540ccba0 drivers/usb/dwc2/gadget.c      Vahram Aharonyan  2016-11-14  2088  	u32 desc_sts;
540ccba0 drivers/usb/dwc2/gadget.c      Vahram Aharonyan  2016-11-14  2089  	u32 mask;
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2090  	int dpi;
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2091  	int ret;
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2092  	int sumofpid;
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2093  
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2094  	dpi = 1;
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2095  	if (!hs_ep->dir_in)
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2096  		dpi = hs_ep->mc;
540ccba0 drivers/usb/dwc2/gadget.c      Vahram Aharonyan  2016-11-14  2097  
540ccba0 drivers/usb/dwc2/gadget.c      Vahram Aharonyan  2016-11-14  2098  	hs_req = get_ep_head(hs_ep);
540ccba0 drivers/usb/dwc2/gadget.c      Vahram Aharonyan  2016-11-14  2099  	if (!hs_req) {
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2100  		hs_ep->target_frame = TARGET_FRAME_INITIAL;
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2101  		dwc2_hsotg_ep_stop_xfr(hsotg, hs_ep);
540ccba0 drivers/usb/dwc2/gadget.c      Vahram Aharonyan  2016-11-14  2102  		dev_warn(hsotg->dev, "%s: ISOC EP queue empty\n", __func__);
540ccba0 drivers/usb/dwc2/gadget.c      Vahram Aharonyan  2016-11-14  2103  		return;
540ccba0 drivers/usb/dwc2/gadget.c      Vahram Aharonyan  2016-11-14  2104  	}
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2105  
540ccba0 drivers/usb/dwc2/gadget.c      Vahram Aharonyan  2016-11-14  2106  	ureq = &hs_req->req;
540ccba0 drivers/usb/dwc2/gadget.c      Vahram Aharonyan  2016-11-14  2107  
540ccba0 drivers/usb/dwc2/gadget.c      Vahram Aharonyan  2016-11-14  2108  	dma_addr = hs_ep->desc_list_dma;
540ccba0 drivers/usb/dwc2/gadget.c      Vahram Aharonyan  2016-11-14  2109  
540ccba0 drivers/usb/dwc2/gadget.c      Vahram Aharonyan  2016-11-14  2110  	dma_reg = hs_ep->dir_in ? DIEPDMA(hs_ep->index) : DOEPDMA(hs_ep->index);
540ccba0 drivers/usb/dwc2/gadget.c      Vahram Aharonyan  2016-11-14  2111  	depdma = dwc2_readl(hsotg->regs + dma_reg);
540ccba0 drivers/usb/dwc2/gadget.c      Vahram Aharonyan  2016-11-14  2112  
540ccba0 drivers/usb/dwc2/gadget.c      Vahram Aharonyan  2016-11-14  2113  	index = (depdma - dma_addr) / sizeof(struct dwc2_dma_desc) - 1;
a19205da drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2114  	/* Check descriptor chain rollover */
a19205da drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2115  	if (index < 0)
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2116  		index = dpi * MAX_DMA_DESC_NUM_GENERIC - 1;
540ccba0 drivers/usb/dwc2/gadget.c      Vahram Aharonyan  2016-11-14  2117  
a19205da drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2118  	desc_sts = hs_ep->desc_list[index].status;
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2119  
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2120  	if (dpi == 1) {
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2121  		/* Check completion status for not High Bandwidth ISOC Out */
a19205da drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2122  		if ((desc_sts & DEV_DMA_STS_MASK) >> DEV_DMA_STS_SHIFT ==
a19205da drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2123  		    DEV_DMA_STS_SUCC) {
540ccba0 drivers/usb/dwc2/gadget.c      Vahram Aharonyan  2016-11-14  2124  			mask = hs_ep->dir_in ? DEV_DMA_ISOC_TX_NBYTES_MASK :
540ccba0 drivers/usb/dwc2/gadget.c      Vahram Aharonyan  2016-11-14  2125  			       DEV_DMA_ISOC_RX_NBYTES_MASK;
540ccba0 drivers/usb/dwc2/gadget.c      Vahram Aharonyan  2016-11-14  2126  			ureq->actual = ureq->length -
a19205da drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2127  				       ((desc_sts & mask) >>
a19205da drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2128  					DEV_DMA_ISOC_NBYTES_SHIFT);
540ccba0 drivers/usb/dwc2/gadget.c      Vahram Aharonyan  2016-11-14  2129  
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2130  			/* Adjust actual len for ISOC Out if len is
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2131  			 * not align of 4.
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2132  			 */
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2133  			if (!hs_ep->dir_in && dpi == 1 && ureq->length & 0x3)
95d2b037 drivers/usb/dwc2/gadget.c      Vahram Aharonyan  2016-11-14  2134  				ureq->actual += 4 - (ureq->length & 0x3);
95d2b037 drivers/usb/dwc2/gadget.c      Vahram Aharonyan  2016-11-14  2135  
540ccba0 drivers/usb/dwc2/gadget.c      Vahram Aharonyan  2016-11-14  2136  			dwc2_hsotg_complete_request(hsotg, hs_ep, hs_req, 0);
a19205da drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2137  		} else {
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2138  			dwc2_hsotg_complete_request(hsotg, hs_ep, hs_req,
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2139  						    -ETIMEDOUT);
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2140  		}
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2141  	} else {
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2142  		/* Check completion status for High Bandwidth ISOC Out. */
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2143  		ret = 0;
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2144  		/* Ignore interrupt if it not last in uframe. */
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2145  		if (((desc_sts & DEV_DMA_ISOC_PID_MASK) >>
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2146  		      DEV_DMA_ISOC_PID_SHIFT) == DEV_DMA_ISOC_PID_MDATA)
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2147  			return;
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2148  
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2149  		idx = 0;
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2150  		/* Complete requests with NODATA if some uframes are skiped */
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2151  		while (hs_ep->target_frame !=
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2152  		       (desc_sts & DEV_DMA_ISOC_FRNUM_MASK)
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2153  			>> DEV_DMA_ISOC_FRNUM_SHIFT) {
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2154  			idx++;
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2155  			dwc2_hsotg_complete_request(hsotg, hs_ep,
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2156  						    hs_req, -ENODATA);
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2157  			hs_req = get_ep_head(hs_ep);
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2158  			if (!hs_req) {
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2159  				hs_ep->target_frame = TARGET_FRAME_INITIAL;
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2160  				dwc2_hsotg_ep_stop_xfr(hsotg, hs_ep);
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2161  				dev_warn(hsotg->dev, "%s: ISOC EP queue empty\n",
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2162  					 __func__);
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2163  				/* Clear late XFERCOMPL interrupts if any */
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2164  				dwc2_writel(DXEPINT_XFERCOMPL, hsotg->regs +
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2165  					DOEPINT(hs_ep->index));
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2166  				return;
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2167  			}
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2168  
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2169  			ureq = &hs_req->req;
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2170  
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2171  			dwc2_gadget_incr_frame_num(hs_ep);
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2172  			hs_ep->target_frame &= (DEV_DMA_ISOC_FRNUM_MASK >>
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2173  				DEV_DMA_ISOC_FRNUM_SHIFT);
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2174  		}
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2175  		/* Increment 1 more to set target to next uframe */
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2176  		hs_ep->target_frame = (desc_sts & DEV_DMA_ISOC_FRNUM_MASK) >>
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2177  			DEV_DMA_ISOC_FRNUM_SHIFT;
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2178  		dwc2_gadget_incr_frame_num(hs_ep);
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2179  		hs_ep->target_frame &= (DEV_DMA_ISOC_FRNUM_MASK >>
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2180  			DEV_DMA_ISOC_FRNUM_SHIFT);
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2181  
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2182  		/* Need to restart if any request completed in above loop */
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2183  		if (idx) {
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2184  			dwc2_hsotg_complete_request(hsotg, hs_ep,
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2185  						    hs_req, -ENODATA);
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2186  			hs_req = get_ep_head(hs_ep);
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2187  			if (!hs_req) {
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2188  				hs_ep->target_frame = TARGET_FRAME_INITIAL;
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2189  				dwc2_hsotg_ep_stop_xfr(hsotg, hs_ep);
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2190  				dev_warn(hsotg->dev, "%s: ISOC EP queue empty\n",
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2191  					 __func__);
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2192  				/* Clear any late XFERCOMPL interrupts if any */
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2193  				dwc2_writel(DXEPINT_XFERCOMPL, hsotg->regs +
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2194  					DOEPINT(hs_ep->index));
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2195  				return;
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2196  			}
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2197  			goto out;
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2198  		}
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2199  		ureq = &hs_req->req;
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2200  
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2201  		/* Because of interrupt latency after receiving interrupt
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2202  		 * for 1st descriptor and when start handling the descriptor
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2203  		 * index can be shifted to second or third descriptor.
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2204  		 * On last descriptor (for uframe) completion process all
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2205  		 * descritors for current uframe.
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2206  		 */
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2207  		sumofpid = 0;
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2208  
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2209  		for (idx = (index / dpi) * dpi; idx <= index; idx++) {
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2210  			desc_sts = hs_ep->desc_list[idx].status;
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2211  
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2212  			if ((desc_sts & DEV_DMA_STS_MASK) >> DEV_DMA_STS_SHIFT
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2213  			     == DEV_DMA_STS_SUCC) {
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2214  				ureq->actual += hs_ep->ep.maxpacket -
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2215  						((desc_sts &
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2216  						  DEV_DMA_ISOC_RX_NBYTES_MASK) >>
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2217  						  DEV_DMA_ISOC_NBYTES_SHIFT);
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2218  				sumofpid += (desc_sts & DEV_DMA_ISOC_PID_MASK)
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2219  					     >> DEV_DMA_ISOC_PID_SHIFT;
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2220  				} else {
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2221  					ret = -ETIMEDOUT;
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2222  					break;
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2223  				}
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2224  		}
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2225  
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2226  		/* Safety check packets PID sequence based on sumofpids:
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2227  		 * if packet count = 1 then sumofpid should be 0
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2228  		 * if packet count = 2 then sumofpid should be 3+2=5
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2229  		 * if packet count = 3 then sumofpid should be 3+3+1=7
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2230  		 */
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2231  		switch (index - (index / dpi) * dpi + 1) {
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2232  		case 1:
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2233  			if (sumofpid != 0)
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2234  				ret = -ETIMEDOUT;
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2235  			break;
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2236  		case 2:
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2237  			if (sumofpid != 5)
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2238  				ret = -ETIMEDOUT;
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2239  			break;
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2240  		case 3:
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2241  			if (sumofpid != 7)
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2242  				ret = -ETIMEDOUT;
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2243  			break;
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2244  		default:
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2245  			dev_dbg(hsotg->dev, "%s: wrong sum of PID's %d\n",
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2246  				__func__, sumofpid);
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2247  		}
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2248  
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2249  		/* Clear EOPF intr for frame if some descs should be skiped */
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17 @2250  		if ((index - (index / dpi) * dpi + 1) < dpi)
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2251  			dwc2_writel(GINTSTS_EOPF, hsotg->regs + GINTSTS);
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2252  
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2253  		/* Safety check */
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2254  		if (ureq->actual > ureq->length)
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2255  			ureq->actual = ureq->length;
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2256  
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2257  		dwc2_hsotg_complete_request(hsotg, hs_ep, hs_req, ret);
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2258  
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2259  		/* If packet count in current uframe less than mult then need
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2260  		 * to skip unused for uframe descrioptors by restarting xfers
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2261  		 */
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2262  		idx = dpi - (index % dpi) - 1;
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2263  out:
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2264  		if (idx > 0) {
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2265  			dwc2_hsotg_ep_stop_xfr(hsotg, hs_ep);
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2266  			dwc2_gadget_start_isoc_ddma(hs_ep);
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2267  		}
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2268  
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2269  		/* Clear late XFERCOMPL and OUTTKNEPDIS interrupts if any */
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17 @2270  		dwc2_writel(DXEPINT_XFERCOMPL || DXEPINT_OUTTKNEPDIS,
ffb8a411 drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2271  			    hsotg->regs + DOEPINT(hs_ep->index));
a19205da drivers/usb/dwc2/gadget.c      Minas Harutyunyan 2018-03-17  2272  	}
540ccba0 drivers/usb/dwc2/gadget.c      Vahram Aharonyan  2016-11-14  2273  }
540ccba0 drivers/usb/dwc2/gadget.c      Vahram Aharonyan  2016-11-14  2274  

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux