All of lore.kernel.org
 help / color / mirror / Atom feed
* [2/8] usb: dwc3: gadget: combine unaligned and zero flags
@ 2018-11-06  7:30 Felipe Balbi
  0 siblings, 0 replies; 3+ messages in thread
From: Felipe Balbi @ 2018-11-06  7:30 UTC (permalink / raw)
  To: Thinh Nguyen, Linux USB; +Cc: Laurent Pinchart

Hi,

Thinh Nguyen <thinh.nguyen@synopsys.com> writes:
> @@ -2250,7 +2250,7 @@ static int dwc3_gadget_ep_reclaim_completed_trb(struct dwc3_ep *dep,
>>  	 * with one TRB pending in the ring. We need to manually clear HWO bit
>>  	 * from that TRB.
>>  	 */
>> -	if ((req->zero || req->unaligned) && !(trb->ctrl & DWC3_TRB_CTRL_CHN)) {
>> +	if (req->needs_extra_trb && !(trb->ctrl & DWC3_TRB_CTRL_CNH)) {
>
> DWC3_TRB_CTRL_CNH -> DWC3_TRB_CTRL_CHN

right, fixed locally.

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

* [2/8] usb: dwc3: gadget: combine unaligned and zero flags
@ 2018-11-05 19:34 Thinh Nguyen
  0 siblings, 0 replies; 3+ messages in thread
From: Thinh Nguyen @ 2018-11-05 19:34 UTC (permalink / raw)
  To: Felipe Balbi, Linux USB; +Cc: Laurent Pinchart

On 11/4/2018 11:11 PM, Felipe Balbi wrote:
> Both flags are used for the same purpose in dwc3: appending an extra
> TRB at the end to deal with controller requirements. By combining both
> flags into one, we make it clear that the situation is the same and
> that they should be treated equally.
>
> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
> ---
>  drivers/usb/dwc3/core.h   |  7 +++----
>  drivers/usb/dwc3/gadget.c | 17 ++++++++---------
>  2 files changed, 11 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h
> index 5bfb62533e0f..4872cba8699b 100644
> --- a/drivers/usb/dwc3/core.h
> +++ b/drivers/usb/dwc3/core.h
> @@ -847,11 +847,11 @@ struct dwc3_hwparams {
>   * @epnum: endpoint number to which this request refers
>   * @trb: pointer to struct dwc3_trb
>   * @trb_dma: DMA address of @trb
> - * @unaligned: true for OUT endpoints with length not divisible by maxp
> + * @needs_extra_trb: true when request needs one extra TRB (either due to ZLP
> + *	or unaligned OUT)
>   * @direction: IN or OUT direction flag
>   * @mapped: true when request has been dma-mapped
>   * @started: request is started
> - * @zero: wants a ZLP
>   */
>  struct dwc3_request {
>  	struct usb_request	request;
> @@ -867,11 +867,10 @@ struct dwc3_request {
>  	struct dwc3_trb		*trb;
>  	dma_addr_t		trb_dma;
>  
> -	unsigned		unaligned:1;
> +	unsigned		needs_extra_trb:1;
>  	unsigned		direction:1;
>  	unsigned		mapped:1;
>  	unsigned		started:1;
> -	unsigned		zero:1;
>  };
>  
>  /*
> diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
> index 2de1a3971a26..502a85707e65 100644
> --- a/drivers/usb/dwc3/gadget.c
> +++ b/drivers/usb/dwc3/gadget.c
> @@ -1064,7 +1064,7 @@ static void dwc3_prepare_one_trb_sg(struct dwc3_ep *dep,
>  			struct dwc3	*dwc = dep->dwc;
>  			struct dwc3_trb	*trb;
>  
> -			req->unaligned = true;
> +			req->needs_extra_trb = true;
>  
>  			/* prepare normal TRB */
>  			dwc3_prepare_one_trb(dep, req, true, i);
> @@ -1108,7 +1108,7 @@ static void dwc3_prepare_one_trb_linear(struct dwc3_ep *dep,
>  		struct dwc3	*dwc = dep->dwc;
>  		struct dwc3_trb	*trb;
>  
> -		req->unaligned = true;
> +		req->needs_extra_trb = true;
>  
>  		/* prepare normal TRB */
>  		dwc3_prepare_one_trb(dep, req, true, 0);
> @@ -1124,7 +1124,7 @@ static void dwc3_prepare_one_trb_linear(struct dwc3_ep *dep,
>  		struct dwc3	*dwc = dep->dwc;
>  		struct dwc3_trb	*trb;
>  
> -		req->zero = true;
> +		req->needs_extra_trb = true;
>  
>  		/* prepare normal TRB */
>  		dwc3_prepare_one_trb(dep, req, true, 0);
> @@ -1406,7 +1406,7 @@ static int dwc3_gadget_ep_dequeue(struct usb_ep *ep,
>  					dwc3_ep_inc_deq(dep);
>  				}
>  
> -				if (r->unaligned || r->zero) {
> +				if (r->needs_extra_trb) {
>  					trb = r->trb + r->num_pending_sgs + 1;
>  					trb->ctrl &= ~DWC3_TRB_CTRL_HWO;
>  					dwc3_ep_inc_deq(dep);
> @@ -1417,7 +1417,7 @@ static int dwc3_gadget_ep_dequeue(struct usb_ep *ep,
>  				trb->ctrl &= ~DWC3_TRB_CTRL_HWO;
>  				dwc3_ep_inc_deq(dep);
>  
> -				if (r->unaligned || r->zero) {
> +				if (r->needs_extra_trb) {
>  					trb = r->trb + 1;
>  					trb->ctrl &= ~DWC3_TRB_CTRL_HWO;
>  					dwc3_ep_inc_deq(dep);
> @@ -2250,7 +2250,7 @@ static int dwc3_gadget_ep_reclaim_completed_trb(struct dwc3_ep *dep,
>  	 * with one TRB pending in the ring. We need to manually clear HWO bit
>  	 * from that TRB.
>  	 */
> -	if ((req->zero || req->unaligned) && !(trb->ctrl & DWC3_TRB_CTRL_CHN)) {
> +	if (req->needs_extra_trb && !(trb->ctrl & DWC3_TRB_CTRL_CNH)) {

DWC3_TRB_CTRL_CNH -> DWC3_TRB_CTRL_CHN

Thinh

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

* [2/8] usb: dwc3: gadget: combine unaligned and zero flags
@ 2018-11-05  7:11 Felipe Balbi
  0 siblings, 0 replies; 3+ messages in thread
From: Felipe Balbi @ 2018-11-05  7:11 UTC (permalink / raw)
  To: Linux USB; +Cc: Laurent Pinchart, Felipe Balbi

Both flags are used for the same purpose in dwc3: appending an extra
TRB at the end to deal with controller requirements. By combining both
flags into one, we make it clear that the situation is the same and
that they should be treated equally.

Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
---
 drivers/usb/dwc3/core.h   |  7 +++----
 drivers/usb/dwc3/gadget.c | 17 ++++++++---------
 2 files changed, 11 insertions(+), 13 deletions(-)

diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h
index 5bfb62533e0f..4872cba8699b 100644
--- a/drivers/usb/dwc3/core.h
+++ b/drivers/usb/dwc3/core.h
@@ -847,11 +847,11 @@ struct dwc3_hwparams {
  * @epnum: endpoint number to which this request refers
  * @trb: pointer to struct dwc3_trb
  * @trb_dma: DMA address of @trb
- * @unaligned: true for OUT endpoints with length not divisible by maxp
+ * @needs_extra_trb: true when request needs one extra TRB (either due to ZLP
+ *	or unaligned OUT)
  * @direction: IN or OUT direction flag
  * @mapped: true when request has been dma-mapped
  * @started: request is started
- * @zero: wants a ZLP
  */
 struct dwc3_request {
 	struct usb_request	request;
@@ -867,11 +867,10 @@ struct dwc3_request {
 	struct dwc3_trb		*trb;
 	dma_addr_t		trb_dma;
 
-	unsigned		unaligned:1;
+	unsigned		needs_extra_trb:1;
 	unsigned		direction:1;
 	unsigned		mapped:1;
 	unsigned		started:1;
-	unsigned		zero:1;
 };
 
 /*
diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index 2de1a3971a26..502a85707e65 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -1064,7 +1064,7 @@ static void dwc3_prepare_one_trb_sg(struct dwc3_ep *dep,
 			struct dwc3	*dwc = dep->dwc;
 			struct dwc3_trb	*trb;
 
-			req->unaligned = true;
+			req->needs_extra_trb = true;
 
 			/* prepare normal TRB */
 			dwc3_prepare_one_trb(dep, req, true, i);
@@ -1108,7 +1108,7 @@ static void dwc3_prepare_one_trb_linear(struct dwc3_ep *dep,
 		struct dwc3	*dwc = dep->dwc;
 		struct dwc3_trb	*trb;
 
-		req->unaligned = true;
+		req->needs_extra_trb = true;
 
 		/* prepare normal TRB */
 		dwc3_prepare_one_trb(dep, req, true, 0);
@@ -1124,7 +1124,7 @@ static void dwc3_prepare_one_trb_linear(struct dwc3_ep *dep,
 		struct dwc3	*dwc = dep->dwc;
 		struct dwc3_trb	*trb;
 
-		req->zero = true;
+		req->needs_extra_trb = true;
 
 		/* prepare normal TRB */
 		dwc3_prepare_one_trb(dep, req, true, 0);
@@ -1406,7 +1406,7 @@ static int dwc3_gadget_ep_dequeue(struct usb_ep *ep,
 					dwc3_ep_inc_deq(dep);
 				}
 
-				if (r->unaligned || r->zero) {
+				if (r->needs_extra_trb) {
 					trb = r->trb + r->num_pending_sgs + 1;
 					trb->ctrl &= ~DWC3_TRB_CTRL_HWO;
 					dwc3_ep_inc_deq(dep);
@@ -1417,7 +1417,7 @@ static int dwc3_gadget_ep_dequeue(struct usb_ep *ep,
 				trb->ctrl &= ~DWC3_TRB_CTRL_HWO;
 				dwc3_ep_inc_deq(dep);
 
-				if (r->unaligned || r->zero) {
+				if (r->needs_extra_trb) {
 					trb = r->trb + 1;
 					trb->ctrl &= ~DWC3_TRB_CTRL_HWO;
 					dwc3_ep_inc_deq(dep);
@@ -2250,7 +2250,7 @@ static int dwc3_gadget_ep_reclaim_completed_trb(struct dwc3_ep *dep,
 	 * with one TRB pending in the ring. We need to manually clear HWO bit
 	 * from that TRB.
 	 */
-	if ((req->zero || req->unaligned) && !(trb->ctrl & DWC3_TRB_CTRL_CHN)) {
+	if (req->needs_extra_trb && !(trb->ctrl & DWC3_TRB_CTRL_CNH)) {
 		trb->ctrl &= ~DWC3_TRB_CTRL_HWO;
 		return 1;
 	}
@@ -2327,11 +2327,10 @@ static int dwc3_gadget_ep_cleanup_completed_request(struct dwc3_ep *dep,
 		ret = dwc3_gadget_ep_reclaim_trb_linear(dep, req, event,
 				status);
 
-	if (req->unaligned || req->zero) {
+	if (req->needs_extra_trb) {
 		ret = dwc3_gadget_ep_reclaim_trb_linear(dep, req, event,
 				status);
-		req->unaligned = false;
-		req->zero = false;
+		req->needs_extra_trb = false;
 	}
 
 	req->request.actual = req->request.length - req->remaining;

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

end of thread, other threads:[~2018-11-06  7:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-06  7:30 [2/8] usb: dwc3: gadget: combine unaligned and zero flags Felipe Balbi
  -- strict thread matches above, loose matches on Subject: below --
2018-11-05 19:34 Thinh Nguyen
2018-11-05  7:11 Felipe Balbi

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.