Skip to contentSkip to conversation

USB: gadget: Fix unused variable warning in ci13xxx_udc

PATCH In review Pavankumar Kondeti 5 participants 27 messages Apr 28, 2011 – May 2, 2011 5 messages not in the archive

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/5 USB: gadget: Fix unused variable warning in ci13xxx_udc

---
 drivers/usb/gadget/ci13xxx_udc.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/usb/gadget/ci13xxx_udc.c +1 -1
index e09178b..6a9ad59 100644
@@ -1843,7 +1843,7 @@ __releases(mEp->lock)
 __acquires(mEp->lock)
 {
 	struct ci13xxx_req *mReq, *mReqTemp;
-	int retval;
+	int uninitialized_var(retval);
 
 	trace("%p", mEp);
 
Signature · 2 lines
Sent by a consultant of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.

A message that is not in the archive (sent off-list or not yet received): 1303977501-17115-1-git-send-email-pkondeti-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org

#2 lore raw

PATCH 3/5 USB: gadget: Use ep0out for control OUT data phase in ci13xxx_udc

The current code queue the control OUT data request to ep0in instead of ep0out. Check ep0_dir and use the correct control endpoint.

---
 drivers/usb/gadget/ci13xxx_udc.c |   20 ++++++++++++++------
 1 files changed, 14 insertions(+), 6 deletions(-)
drivers/usb/gadget/ci13xxx_udc.c +14 -6
index 0e6d649..0076db2 100644
@@ -1843,6 +1843,7 @@ __releases(mEp->lock)
 __acquires(mEp->lock)
 {
 	struct ci13xxx_req *mReq, *mReqTemp;
+	struct ci13xxx_ep *mEpTemp = mEp;
 	int uninitialized_var(retval);
 
 	trace("%p", mEp);
@@ -1859,7 +1860,10 @@ __acquires(mEp->lock)
 		dbg_done(_usb_addr(mEp), mReq->ptr->token, retval);
 		if (mReq->req.complete != NULL) {
 			spin_unlock(mEp->lock);
-			mReq->req.complete(&mEp->ep, &mReq->req);
+			if ((mEp->type == USB_ENDPOINT_XFER_CONTROL) &&
+					mReq->req.length)
+				mEpTemp = &_udc->ep0in;
+			mReq->req.complete(&mEpTemp->ep, &mReq->req);
 			spin_lock(mEp->lock);
 		}
 	}
@@ -2248,11 +2252,15 @@ static int ep_queue(struct usb_ep *ep, struct usb_request *req,
 
 	spin_lock_irqsave(mEp->lock, flags);
 
-	if (mEp->type == USB_ENDPOINT_XFER_CONTROL &&
-	    !list_empty(&mEp->qh.queue)) {
-		_ep_nuke(mEp);
-		retval = -EOVERFLOW;
-		warn("endpoint ctrl %X nuked", _usb_addr(mEp));
+	if (mEp->type == USB_ENDPOINT_XFER_CONTROL) {
+		if (req->length)
+			mEp = (_udc->ep0_dir == RX) ?
+				&_udc->ep0out : &_udc->ep0in;
+		if (!list_empty(&mEp->qh.queue)) {
+			_ep_nuke(mEp);
+			retval = -EOVERFLOW;
+			warn("endpoint ctrl %X nuked", _usb_addr(mEp));
+		}
 	}
 
 	/* first nuke then test link, e.g. previous status has not sent */
Signature · 7 lines
Sent by a consultant of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#3 lore raw

PATCH 2/5 USB: gadget: Fix bug in endpoint feature request processing in ci13xxx_udc

In reply to Pavankumar Kondeti

The OUT endpoints are stored in 0 - hw_ep_max/2 and IN endpoints are stored from hw_ep_max/2 - hw_ep_max in ci13xxx_ep array. Retrieve the IN endpoint correctly while processing endpoint feature requests.

---
 drivers/usb/gadget/ci13xxx_udc.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)
drivers/usb/gadget/ci13xxx_udc.c +7 -1
index 6a9ad59..0e6d649 100644
@@ -1894,7 +1894,7 @@ __acquires(udc->lock)
 
 	for (i = 0; i < hw_ep_max; i++) {
 		struct ci13xxx_ep *mEp  = &udc->ci13xxx_ep[i];
-		int type, num, err = -EINVAL;
+		int type, num, dir, err = -EINVAL;
 		struct usb_ctrlrequest req;
 
 		if (mEp->desc == NULL)
@@ -1952,7 +1952,10 @@ __acquires(udc->lock)
 				if (req.wLength != 0)
 					break;
 				num  = le16_to_cpu(req.wIndex);
+				dir = num & USB_ENDPOINT_DIR_MASK;
 				num &= USB_ENDPOINT_NUMBER_MASK;
+				if (dir) /* TX */
+					num += hw_ep_max/2;
 				if (!udc->ci13xxx_ep[num].wedge) {
 					spin_unlock(udc->lock);
 					err = usb_ep_clear_halt(
@@ -2001,7 +2004,10 @@ __acquires(udc->lock)
 				if (req.wLength != 0)
 					break;
 				num  = le16_to_cpu(req.wIndex);
+				dir = num & USB_ENDPOINT_DIR_MASK;
 				num &= USB_ENDPOINT_NUMBER_MASK;
+				if (dir) /* TX */
+					num += hw_ep_max/2;
 
 				spin_unlock(udc->lock);
 				err = usb_ep_set_halt(&udc->ci13xxx_ep[num].ep);
Signature · 2 lines
Sent by a consultant of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
#4 lore raw

PATCH 4/5 USB: gadget: Initialize ep0 once while registering gadget in ci13xxx_udc

In reply to Pavankumar Kondeti

From: Anji jonnala <[email protected]>

Some of the simulators may cache the ep0 maxpacket size to zero if the ep0 dQh is not setup before enabling the pullup. Hence Setup ep0 and initialize the dQh fields once while registering the gadget(before enabling the pullup).

HSUSB Chipidea link controller spec says ep0 is enabled always in the HW. Hence disabling and enabling the ep0 as a part of reset interrupt is unneccesary.
Remove the disable/enable ep0 logic from reset interrupt handling.

---
 drivers/usb/gadget/ci13xxx_udc.c |   31 +++++++++++++++++--------------
 1 files changed, 17 insertions(+), 14 deletions(-)
drivers/usb/gadget/ci13xxx_udc.c +17 -14
index 0076db2..5fdc12d 100644
@@ -1634,8 +1634,6 @@ static int _gadget_stop_activity(struct usb_gadget *gadget)
 	gadget_for_each_ep(ep, gadget) {
 		usb_ep_disable(ep);
 	}
-	usb_ep_disable(&udc->ep0out.ep);
-	usb_ep_disable(&udc->ep0in.ep);
 
 	if (udc->status != NULL) {
 		usb_ep_free_request(&udc->ep0in.ep, udc->status);
@@ -1678,18 +1676,10 @@ __acquires(udc->lock)
 	if (retval)
 		goto done;
 
-	retval = usb_ep_enable(&udc->ep0out.ep, &ctrl_endpt_out_desc);
-	if (retval)
-		goto done;
+	udc->status = usb_ep_alloc_request(&udc->ep0in.ep, GFP_ATOMIC);
+	if (udc->status == NULL)
+		retval = -ENOMEM;
 
-	retval = usb_ep_enable(&udc->ep0in.ep, &ctrl_endpt_in_desc);
-	if (!retval) {
-		udc->status = usb_ep_alloc_request(&udc->ep0in.ep, GFP_ATOMIC);
-		if (udc->status == NULL) {
-			usb_ep_disable(&udc->ep0out.ep);
-			retval = -ENOMEM;
-		}
-	}
 	spin_lock(udc->lock);
 
  done:
@@ -2120,7 +2110,12 @@ static int ep_enable(struct usb_ep *ep,
 		(mEp->ep.maxpacket << ffs_nr(QH_MAX_PKT)) & QH_MAX_PKT;
 	mEp->qh.ptr->td.next |= TD_TERMINATE;   /* needed? */
 
-	retval |= hw_ep_enable(mEp->num, mEp->dir, mEp->type);
+	/*
+	 * Enable endpoints in the HW other than ep0 as ep0
+	 * is always enabled
+	 */
+	if (mEp->num)
+		retval |= hw_ep_enable(mEp->num, mEp->dir, mEp->type);
 
 	spin_unlock_irqrestore(mEp->lock, flags);
 	return retval;
@@ -2609,6 +2604,14 @@ int usb_gadget_probe_driver(struct usb_gadget_driver *driver,
 	}
 	if (retval)
 		goto done;
+	spin_unlock_irqrestore(udc->lock, flags);
+	retval = usb_ep_enable(&udc->ep0out.ep, &ctrl_endpt_out_desc);
+	if (retval)
+		return retval;
+	retval = usb_ep_enable(&udc->ep0in.ep, &ctrl_endpt_in_desc);
+	if (retval)
+		return retval;
+	spin_lock_irqsave(udc->lock, flags);
 
 	udc->gadget.ep0 = &udc->ep0in.ep;
 	/* bind gadget */
Signature · 2 lines
Sent by a consultant of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
#5 lore raw

PATCH 5/5 USB: OTG: msm: Clear in_lpm flag before enabling the IRQ in resume

In reply to Pavankumar Kondeti

The current code is clearing in_lpm flag after enabling the IRQ. If IRQ comes immediately before in_lpm flag is set, it thinks that hardware is in low power mode and disables the IRQ. Fix this by clearing in_lpm flag before enabling the IRQ.

---
 drivers/usb/otg/msm_otg.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/usb/otg/msm_otg.c +2 -2
index 2965986..f58b7da 100644
@@ -389,14 +389,14 @@ skip_phy_resume:
 	if (bus)
 		set_bit(HCD_FLAG_HW_ACCESSIBLE, &(bus_to_hcd(bus))->flags);
 
+	atomic_set(&motg->in_lpm, 0);
+
 	if (motg->async_int) {
 		motg->async_int = 0;
 		pm_runtime_put(otg->dev);
 		enable_irq(motg->irq);
 	}
 
-	atomic_set(&motg->in_lpm, 0);
-
 	dev_info(otg->dev, "USB exited from low power mode\n");
 
 	return 0;
Signature · 2 lines
Sent by a consultant of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
#6 lore raw
In reply to Pavankumar Kondeti
Quoted 10 lines · Pavankumar Kondeti
---
 drivers/usb/gadget/ci13xxx_udc.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/usb/gadget/ci13xxx_udc.c +0 -0
index e09178b..6a9ad59 100644

drivers/usb/gadget/ci13xxx_udc.c __releases(mEp->lock) · line 1847

Quoted 6 lines
drivers/usb/gadget/ci13xxx_udc.c +1 -1
@@ -1843,7 +1843,7 @@ __releases(mEp->lock)
 __acquires(mEp->lock)
 {
 	struct ci13xxx_req *mReq, *mReqTemp;
-	int retval;
+	int uninitialized_var(retval);
 	trace("%p", mEp);

Could we instead set it to 0?

Also, it seems this function has a bug where it compares retval with EBUSY instead of -EBUSY:

	if (retval == EBUSY)
		retval = 0;

Just saying in case anyone wants to take care of it.

Signature · 4 lines
Best regards,                                         _     _
.o. | Liege of Serenely Enlightened Majesty of      o' \,=./ `o
..o | Computer Science,  Michal "mina86" Nazarewicz    (o o)
ooo +-----<email/xmpp: [email protected]>-----ooO--(_)--Ooo--
#7 lore raw
Quoted 8 lines · Michal Nazarewicz
Quoted 5 lines · Pavankumar Kondeti
---
 drivers/usb/gadget/ci13xxx_udc.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
Quoted 15 lines

drivers/usb/gadget/ci13xxx_udc.c __releases(mEp->lock) · line 1847

Quoted 12 lines
drivers/usb/gadget/ci13xxx_udc.c +1 -1
index e09178b..6a9ad59 100644
@@ -1843,7 +1843,7 @@ __releases(mEp->lock)
 __acquires(mEp->lock)
 {
 	struct ci13xxx_req *mReq, *mReqTemp;
-	int retval;
+	int uninitialized_var(retval);
 	trace("%p", mEp);

Could we instead set it to 0?

would it matter anyway? we return -EINVAL if the queue is empty. Otherwise we assign retval = _hardware_dequeue().

Quoted 8 lines

Also, it seems this function has a bug where it compares retval with EBUSY instead of -EBUSY:

	if (retval == EBUSY)
		retval = 0;

Just saying in case anyone wants to take care of it.

Thanks for pointing this out. I will send out a patch to fix this.

As of now isr_tr_complete_low() return value is simply ignored for non-control endpoints. We never hit this case for control endpoint.

Signature · 2 lines
Sent by a consultant of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.

A message that is not in the archive (sent off-list or not yet received): [email protected]

#9 lore raw
Quoted 25 lines · Pavan Kondeti
Quoted 8 lines · Michal Nazarewicz
Quoted 5 lines · Pavankumar Kondeti
---
 drivers/usb/gadget/ci13xxx_udc.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
Quoted 15 lines

drivers/usb/gadget/ci13xxx_udc.c __releases(mEp->lock) · line 1847

Quoted 12 lines
drivers/usb/gadget/ci13xxx_udc.c +1 -1
index e09178b..6a9ad59 100644
@@ -1843,7 +1843,7 @@ __releases(mEp->lock)
 __acquires(mEp->lock)
 {
 	struct ci13xxx_req *mReq, *mReqTemp;
-	int retval;
+	int uninitialized_var(retval);
 	trace("%p", mEp);

Could we instead set it to 0?

Quoted 2 lines

would it matter anyway? we return -EINVAL if the queue is empty. Otherwise we assign retval = _hardware_dequeue().

It is indeed a legitimate mistake on gcc's part. Using uninitialized_var() avoids generating unnecessary code to initialize the value. On the other hand, initializing to zero would keep future possible changes from missing the warning.

Anyone know of a concensus on this kind of case?

David

Signature · 6 lines
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#10 lore raw

PATCH v2 1/7 USB: gadget: Fix typo (s/EBUSY/-EBUSY) in ci13xxx_udc

In reply to Pavankumar Kondeti
---
 drivers/usb/gadget/ci13xxx_udc.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/usb/gadget/ci13xxx_udc.c +1 -1
index e09178b..348d8a0 100644
@@ -1864,7 +1864,7 @@ __acquires(mEp->lock)
 		}
 	}
 
-	if (retval == EBUSY)
+	if (retval == -EBUSY)
 		retval = 0;
 	if (retval < 0)
 		dbg_event(_usb_addr(mEp), "DONE", retval);
Signature · 2 lines
Sent by a consultant of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.

A message that is not in the archive (sent off-list or not yet received): 1304053975-1960-1-git-send-email-pkondeti-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org

#12 lore raw

PATCH 5/7 USB: gadget: Use ep0out for control OUT data phase in ci13xxx_udc

The current code queue the control OUT data request to ep0in instead of ep0out. Check ep0_dir and use the correct control endpoint.

---
 drivers/usb/gadget/ci13xxx_udc.c |   20 ++++++++++++++------
 1 files changed, 14 insertions(+), 6 deletions(-)
drivers/usb/gadget/ci13xxx_udc.c +14 -6
index 1b095cb..09c76a1 100644
@@ -1843,6 +1843,7 @@ __releases(mEp->lock)
 __acquires(mEp->lock)
 {
 	struct ci13xxx_req *mReq, *mReqTemp;
+	struct ci13xxx_ep *mEpTemp = mEp;
 	int uninitialized_var(retval);
 
 	trace("%p", mEp);
@@ -1859,7 +1860,10 @@ __acquires(mEp->lock)
 		dbg_done(_usb_addr(mEp), mReq->ptr->token, retval);
 		if (mReq->req.complete != NULL) {
 			spin_unlock(mEp->lock);
-			mReq->req.complete(&mEp->ep, &mReq->req);
+			if ((mEp->type == USB_ENDPOINT_XFER_CONTROL) &&
+					mReq->req.length)
+				mEpTemp = &_udc->ep0in;
+			mReq->req.complete(&mEpTemp->ep, &mReq->req);
 			spin_lock(mEp->lock);
 		}
 	}
@@ -2248,11 +2252,15 @@ static int ep_queue(struct usb_ep *ep, struct usb_request *req,
 
 	spin_lock_irqsave(mEp->lock, flags);
 
-	if (mEp->type == USB_ENDPOINT_XFER_CONTROL &&
-	    !list_empty(&mEp->qh.queue)) {
-		_ep_nuke(mEp);
-		retval = -EOVERFLOW;
-		warn("endpoint ctrl %X nuked", _usb_addr(mEp));
+	if (mEp->type == USB_ENDPOINT_XFER_CONTROL) {
+		if (req->length)
+			mEp = (_udc->ep0_dir == RX) ?
+				&_udc->ep0out : &_udc->ep0in;
+		if (!list_empty(&mEp->qh.queue)) {
+			_ep_nuke(mEp);
+			retval = -EOVERFLOW;
+			warn("endpoint ctrl %X nuked", _usb_addr(mEp));
+		}
 	}
 
 	/* first nuke then test link, e.g. previous status has not sent */
Signature · 7 lines
Sent by a consultant of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#13 lore raw

Re: [PATCH 1/7] USB: gadget: Fix typo (s/EBUSY/-EBUSY) in ci13xxx_udc

In reply to a message not in the archive
Quoted 1 line · Pavankumar Kondeti

It is helpful to maintains to describe second revisions of patches in the subject, something like: [PATCH v2 1/7] ...

Also, for something this size, it would be helpful to have a coverletter explaining the what the series does. It is also useful to put a small history in the coverletter stating what is fixed in each update of the patch series. For example, this update fixes some small mistakes that were addressed on the list.

Oh, and you should CC the people that mentioned things that need to be fixed so that they see the updates.

David

Signature · 6 lines
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 8yay62txcwc.fsf-AOX6H5vLt3Uj8izMo0bVsAC/[email protected]

#15 lore raw

Re: [PATCH 1/7] USB: gadget: Fix typo (s/EBUSY/-EBUSY) in ci13xxx_udc

Quoted 6 lines · David Brown
Quoted 1 line · Pavankumar Kondeti

It is helpful to maintains to describe second revisions of patches in the subject, something like: [PATCH v2 1/7] ...

Yes, I'm totally confused now as to what patches you want applied...

So I'm just deleting all patches from you all from my patch queue. Pavankumar, please fix this up and resend.

thanks,

greg k-h
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#16 lore raw

Re: [PATCH 1/7] USB: gadget: Fix typo (s/EBUSY/-EBUSY) in ci13xxx_udc

Quoted 5 lines · Greg KH
Quoted 4 lines · David Brown
Quoted 1 line · Pavankumar Kondeti
Quoted 8 lines
Quoted 2 lines

It is helpful to maintains to describe second revisions of patches in the subject, something like: [PATCH v2 1/7] ...

Yes, I'm totally confused now as to what patches you want applied...

So I'm just deleting all patches from you all from my patch queue. Pavankumar, please fix this up and resend.

Sorry for the confusion. I will re-send the patch series.

Thanks,
Pavan

Signature · 2 lines
Sent by a consultant of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
#17 lore raw

Re: [PATCH 1/7] USB: gadget: Fix typo (s/EBUSY/-EBUSY) in ci13xxx_udc

In reply to David Brown

Hi David,

Thanks for your feedback. I will re-send the patch series.

Thanks,
Pavan

Quoted 18 lines · David Brown
Quoted 1 line · Pavankumar Kondeti

It is helpful to maintains to describe second revisions of patches in the subject, something like: [PATCH v2 1/7] ...

Also, for something this size, it would be helpful to have a coverletter explaining the what the series does. It is also useful to put a small history in the coverletter stating what is fixed in each update of the patch series. For example, this update fixes some small mistakes that were addressed on the list.

Oh, and you should CC the people that mentioned things that need to be fixed so that they see the updates.

David

Signature · 2 lines
Sent by a consultant of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
#18 lore raw

PATCH v2 2/7 USB: gadget: Use bitwise AND operator to test flags in ci13xxx_udc

In reply to Pavankumar Kondeti
---
 drivers/usb/gadget/ci13xxx_udc.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/usb/gadget/ci13xxx_udc.c +1 -1
index 348d8a0..03dff95 100644
@@ -310,7 +310,7 @@ static int hw_device_reset(struct ci13xxx *udc)
 		udc->udc_driver->notify_event(udc,
 			CI13XXX_CONTROLLER_RESET_EVENT);
 
-	if (udc->udc_driver->flags && CI13XXX_DISABLE_STREAMING)
+	if (udc->udc_driver->flags & CI13XXX_DISABLE_STREAMING)
 		hw_cwrite(CAP_USBMODE, USBMODE_SDIS, USBMODE_SDIS);
 
 	/* USBMODE should be configured step by step */
Signature · 2 lines
Sent by a consultant of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
#19 lore raw

PATCH v2 3/7 USB: gadget: Fix unused variable warning in ci13xxx_udc

In reply to Pavankumar Kondeti
---
 drivers/usb/gadget/ci13xxx_udc.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/usb/gadget/ci13xxx_udc.c +1 -1
index 03dff95..92498ae 100644
@@ -1843,7 +1843,7 @@ __releases(mEp->lock)
 __acquires(mEp->lock)
 {
 	struct ci13xxx_req *mReq, *mReqTemp;
-	int retval;
+	int uninitialized_var(retval);
 
 	trace("%p", mEp);
 
Signature · 2 lines
Sent by a consultant of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
#20 lore raw

PATCH v2 4/7 USB: gadget: Fix bug in endpoint feature request processing in ci13xxx_udc

In reply to Pavankumar Kondeti

The OUT endpoints are stored in 0 - hw_ep_max/2 and IN endpoints are stored from hw_ep_max/2 - hw_ep_max in ci13xxx_ep array. Retrieve the IN endpoint correctly while processing endpoint feature requests.

---
 drivers/usb/gadget/ci13xxx_udc.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)
drivers/usb/gadget/ci13xxx_udc.c +7 -1
index 92498ae..1b095cb 100644
@@ -1894,7 +1894,7 @@ __acquires(udc->lock)
 
 	for (i = 0; i < hw_ep_max; i++) {
 		struct ci13xxx_ep *mEp  = &udc->ci13xxx_ep[i];
-		int type, num, err = -EINVAL;
+		int type, num, dir, err = -EINVAL;
 		struct usb_ctrlrequest req;
 
 		if (mEp->desc == NULL)
@@ -1952,7 +1952,10 @@ __acquires(udc->lock)
 				if (req.wLength != 0)
 					break;
 				num  = le16_to_cpu(req.wIndex);
+				dir = num & USB_ENDPOINT_DIR_MASK;
 				num &= USB_ENDPOINT_NUMBER_MASK;
+				if (dir) /* TX */
+					num += hw_ep_max/2;
 				if (!udc->ci13xxx_ep[num].wedge) {
 					spin_unlock(udc->lock);
 					err = usb_ep_clear_halt(
@@ -2001,7 +2004,10 @@ __acquires(udc->lock)
 				if (req.wLength != 0)
 					break;
 				num  = le16_to_cpu(req.wIndex);
+				dir = num & USB_ENDPOINT_DIR_MASK;
 				num &= USB_ENDPOINT_NUMBER_MASK;
+				if (dir) /* TX */
+					num += hw_ep_max/2;
 
 				spin_unlock(udc->lock);
 				err = usb_ep_set_halt(&udc->ci13xxx_ep[num].ep);
Signature · 2 lines
Sent by a consultant of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
#21 lore raw

PATCH v2 6/7 USB: gadget: Initialize ep0 once while registering gadget in ci13xxx_udc

In reply to Pavankumar Kondeti

From: Anji jonnala <[email protected]>

Some of the simulators may cache the ep0 maxpacket size to zero if the ep0 dQh is not setup before enabling the pullup. Hence Setup ep0 and initialize the dQh fields once while registering the gadget(before enabling the pullup).

HSUSB Chipidea link controller spec says ep0 is enabled always in the HW. Hence disabling and enabling the ep0 as a part of reset interrupt is unneccesary.
Remove the disable/enable ep0 logic from reset interrupt handling.

---
 drivers/usb/gadget/ci13xxx_udc.c |   31 +++++++++++++++++--------------
 1 files changed, 17 insertions(+), 14 deletions(-)
drivers/usb/gadget/ci13xxx_udc.c +17 -14
index 09c76a1..68123ee 100644
@@ -1634,8 +1634,6 @@ static int _gadget_stop_activity(struct usb_gadget *gadget)
 	gadget_for_each_ep(ep, gadget) {
 		usb_ep_disable(ep);
 	}
-	usb_ep_disable(&udc->ep0out.ep);
-	usb_ep_disable(&udc->ep0in.ep);
 
 	if (udc->status != NULL) {
 		usb_ep_free_request(&udc->ep0in.ep, udc->status);
@@ -1678,18 +1676,10 @@ __acquires(udc->lock)
 	if (retval)
 		goto done;
 
-	retval = usb_ep_enable(&udc->ep0out.ep, &ctrl_endpt_out_desc);
-	if (retval)
-		goto done;
+	udc->status = usb_ep_alloc_request(&udc->ep0in.ep, GFP_ATOMIC);
+	if (udc->status == NULL)
+		retval = -ENOMEM;
 
-	retval = usb_ep_enable(&udc->ep0in.ep, &ctrl_endpt_in_desc);
-	if (!retval) {
-		udc->status = usb_ep_alloc_request(&udc->ep0in.ep, GFP_ATOMIC);
-		if (udc->status == NULL) {
-			usb_ep_disable(&udc->ep0out.ep);
-			retval = -ENOMEM;
-		}
-	}
 	spin_lock(udc->lock);
 
  done:
@@ -2120,7 +2110,12 @@ static int ep_enable(struct usb_ep *ep,
 		(mEp->ep.maxpacket << ffs_nr(QH_MAX_PKT)) & QH_MAX_PKT;
 	mEp->qh.ptr->td.next |= TD_TERMINATE;   /* needed? */
 
-	retval |= hw_ep_enable(mEp->num, mEp->dir, mEp->type);
+	/*
+	 * Enable endpoints in the HW other than ep0 as ep0
+	 * is always enabled
+	 */
+	if (mEp->num)
+		retval |= hw_ep_enable(mEp->num, mEp->dir, mEp->type);
 
 	spin_unlock_irqrestore(mEp->lock, flags);
 	return retval;
@@ -2609,6 +2604,14 @@ int usb_gadget_probe_driver(struct usb_gadget_driver *driver,
 	}
 	if (retval)
 		goto done;
+	spin_unlock_irqrestore(udc->lock, flags);
+	retval = usb_ep_enable(&udc->ep0out.ep, &ctrl_endpt_out_desc);
+	if (retval)
+		return retval;
+	retval = usb_ep_enable(&udc->ep0in.ep, &ctrl_endpt_in_desc);
+	if (retval)
+		return retval;
+	spin_lock_irqsave(udc->lock, flags);
 
 	udc->gadget.ep0 = &udc->ep0in.ep;
 	/* bind gadget */
Signature · 2 lines
Sent by a consultant of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
#22 lore raw

PATCH v2 7/7 USB: OTG: msm: Clear in_lpm flag before enabling the IRQ in resume

In reply to Pavankumar Kondeti

The current code is clearing in_lpm flag after enabling the IRQ. If IRQ comes immediately before in_lpm flag is set, it thinks that hardware is in low power mode and disables the IRQ. Fix this by clearing in_lpm flag before enabling the IRQ.

---
 drivers/usb/otg/msm_otg.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/usb/otg/msm_otg.c +2 -2
index 2965986..f58b7da 100644
@@ -389,14 +389,14 @@ skip_phy_resume:
 	if (bus)
 		set_bit(HCD_FLAG_HW_ACCESSIBLE, &(bus_to_hcd(bus))->flags);
 
+	atomic_set(&motg->in_lpm, 0);
+
 	if (motg->async_int) {
 		motg->async_int = 0;
 		pm_runtime_put(otg->dev);
 		enable_irq(motg->irq);
 	}
 
-	atomic_set(&motg->in_lpm, 0);
-
 	dev_info(otg->dev, "USB exited from low power mode\n");
 
 	return 0;
Signature · 2 lines
Sent by a consultant of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
#23 lore raw

v2 cover Typo & BUG fixes for MSM USB drivers

In reply to Pavankumar Kondeti

This patch series addresses the following issues.

1. EP0 is enabled after enabling pull-up in ci13xxx_udc. But some simulators are caching the ep0 max packet size at the time of pull-up enable due to which USB is not working. Fix this by initializing ep0 at gadget driver registration.
2. Retrieve the IN endpoint correctly from ep array while processing endpoint feature requests.
3. Data phase on control OUT is not working.
4. USB does not work some times after resume due to a race condition involved in clearing in_lpm flag.

Other than above issues, a couple typo mistakes are corrected in this patch series.

Changelog:

- v2
- Resending patches with V2 tag :-)
- logical AND operator is used instead of bitwiese AND for testing flags.
- Fixes a typo error (s/EBUSY/-EBUSY) pointed out by Michal.

Anji jonnala (1):
USB: gadget: Initialize ep0 once while registering gadget in

    ci13xxx_udc

Pavankumar Kondeti (6):
USB: gadget: Fix typo (s/EBUSY/-EBUSY) in ci13xxx_udc
USB: gadget: Use bitwise AND operator to test flags in ci13xxx_udc
USB: gadget: Fix unused variable warning in ci13xxx_udc
USB: gadget: Fix bug in endpoint feature request processing in

    ci13xxx_udc

USB: gadget: Use ep0out for control OUT data phase in ci13xxx_udc
USB: OTG: msm: Clear in_lpm flag before enabling the IRQ in resume

 drivers/usb/gadget/ci13xxx_udc.c |   65 ++++++++++++++++++++++++--------------
 drivers/usb/otg/msm_otg.c        |    4 +-
 2 files changed, 43 insertions(+), 26 deletions(-)
Signature · 2 lines
Sent by a consultant of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.

A message that is not in the archive (sent off-list or not yet received): 1304317593-21808-1-git-send-email-pkondeti-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org

#25 lore raw

PATCH v2 1/7 USB: gadget: Fix typo (s/EBUSY/-EBUSY) in ci13xxx_udc

---
 drivers/usb/gadget/ci13xxx_udc.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/usb/gadget/ci13xxx_udc.c +1 -1
index e09178b..348d8a0 100644
@@ -1864,7 +1864,7 @@ __acquires(mEp->lock)
 		}
 	}
 
-	if (retval == EBUSY)
+	if (retval == -EBUSY)
 		retval = 0;
 	if (retval < 0)
 		dbg_event(_usb_addr(mEp), "DONE", retval);
Signature · 7 lines
Sent by a consultant of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#26 lore raw

PATCH v2 3/7 USB: gadget: Fix unused variable warning in ci13xxx_udc

In reply to a message not in the archive
---
 drivers/usb/gadget/ci13xxx_udc.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/usb/gadget/ci13xxx_udc.c +1 -1
index 03dff95..92498ae 100644
@@ -1843,7 +1843,7 @@ __releases(mEp->lock)
 __acquires(mEp->lock)
 {
 	struct ci13xxx_req *mReq, *mReqTemp;
-	int retval;
+	int uninitialized_var(retval);
 
 	trace("%p", mEp);
 
Signature · 7 lines
Sent by a consultant of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#27 lore raw

PATCH v2 2/7 USB: gadget: Use bitwise AND operator to test flags in ci13xxx_udc

In reply to Pavankumar Kondeti
---
 drivers/usb/gadget/ci13xxx_udc.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/usb/gadget/ci13xxx_udc.c +1 -1
index 348d8a0..03dff95 100644
@@ -310,7 +310,7 @@ static int hw_device_reset(struct ci13xxx *udc)
 		udc->udc_driver->notify_event(udc,
 			CI13XXX_CONTROLLER_RESET_EVENT);
 
-	if (udc->udc_driver->flags && CI13XXX_DISABLE_STREAMING)
+	if (udc->udc_driver->flags & CI13XXX_DISABLE_STREAMING)
 		hw_cwrite(CAP_USBMODE, USBMODE_SDIS, USBMODE_SDIS);
 
 	/* USBMODE should be configured step by step */
Signature · 2 lines
Sent by a consultant of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
#28 lore raw

PATCH v2 4/7 USB: gadget: Fix bug in endpoint feature request processing in ci13xxx_udc

In reply to Pavankumar Kondeti

The OUT endpoints are stored in 0 - hw_ep_max/2 and IN endpoints are stored from hw_ep_max/2 - hw_ep_max in ci13xxx_ep array. Retrieve the IN endpoint correctly while processing endpoint feature requests.

---
 drivers/usb/gadget/ci13xxx_udc.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)
drivers/usb/gadget/ci13xxx_udc.c +7 -1
index 92498ae..1b095cb 100644
@@ -1894,7 +1894,7 @@ __acquires(udc->lock)
 
 	for (i = 0; i < hw_ep_max; i++) {
 		struct ci13xxx_ep *mEp  = &udc->ci13xxx_ep[i];
-		int type, num, err = -EINVAL;
+		int type, num, dir, err = -EINVAL;
 		struct usb_ctrlrequest req;
 
 		if (mEp->desc == NULL)
@@ -1952,7 +1952,10 @@ __acquires(udc->lock)
 				if (req.wLength != 0)
 					break;
 				num  = le16_to_cpu(req.wIndex);
+				dir = num & USB_ENDPOINT_DIR_MASK;
 				num &= USB_ENDPOINT_NUMBER_MASK;
+				if (dir) /* TX */
+					num += hw_ep_max/2;
 				if (!udc->ci13xxx_ep[num].wedge) {
 					spin_unlock(udc->lock);
 					err = usb_ep_clear_halt(
@@ -2001,7 +2004,10 @@ __acquires(udc->lock)
 				if (req.wLength != 0)
 					break;
 				num  = le16_to_cpu(req.wIndex);
+				dir = num & USB_ENDPOINT_DIR_MASK;
 				num &= USB_ENDPOINT_NUMBER_MASK;
+				if (dir) /* TX */
+					num += hw_ep_max/2;
 
 				spin_unlock(udc->lock);
 				err = usb_ep_set_halt(&udc->ci13xxx_ep[num].ep);
Signature · 2 lines
Sent by a consultant of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
#29 lore raw

PATCH v2 5/7 USB: gadget: Use ep0out for control OUT data phase in ci13xxx_udc

In reply to Pavankumar Kondeti

The current code queue the control OUT data request to ep0in instead of ep0out. Check ep0_dir and use the correct control endpoint.

---
 drivers/usb/gadget/ci13xxx_udc.c |   20 ++++++++++++++------
 1 files changed, 14 insertions(+), 6 deletions(-)
drivers/usb/gadget/ci13xxx_udc.c +14 -6
index 1b095cb..09c76a1 100644
@@ -1843,6 +1843,7 @@ __releases(mEp->lock)
 __acquires(mEp->lock)
 {
 	struct ci13xxx_req *mReq, *mReqTemp;
+	struct ci13xxx_ep *mEpTemp = mEp;
 	int uninitialized_var(retval);
 
 	trace("%p", mEp);
@@ -1859,7 +1860,10 @@ __acquires(mEp->lock)
 		dbg_done(_usb_addr(mEp), mReq->ptr->token, retval);
 		if (mReq->req.complete != NULL) {
 			spin_unlock(mEp->lock);
-			mReq->req.complete(&mEp->ep, &mReq->req);
+			if ((mEp->type == USB_ENDPOINT_XFER_CONTROL) &&
+					mReq->req.length)
+				mEpTemp = &_udc->ep0in;
+			mReq->req.complete(&mEpTemp->ep, &mReq->req);
 			spin_lock(mEp->lock);
 		}
 	}
@@ -2248,11 +2252,15 @@ static int ep_queue(struct usb_ep *ep, struct usb_request *req,
 
 	spin_lock_irqsave(mEp->lock, flags);
 
-	if (mEp->type == USB_ENDPOINT_XFER_CONTROL &&
-	    !list_empty(&mEp->qh.queue)) {
-		_ep_nuke(mEp);
-		retval = -EOVERFLOW;
-		warn("endpoint ctrl %X nuked", _usb_addr(mEp));
+	if (mEp->type == USB_ENDPOINT_XFER_CONTROL) {
+		if (req->length)
+			mEp = (_udc->ep0_dir == RX) ?
+				&_udc->ep0out : &_udc->ep0in;
+		if (!list_empty(&mEp->qh.queue)) {
+			_ep_nuke(mEp);
+			retval = -EOVERFLOW;
+			warn("endpoint ctrl %X nuked", _usb_addr(mEp));
+		}
 	}
 
 	/* first nuke then test link, e.g. previous status has not sent */
Signature · 2 lines
Sent by a consultant of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
#30 lore raw

PATCH v2 6/7 USB: gadget: Initialize ep0 once while registering gadget in ci13xxx_udc

In reply to Pavankumar Kondeti

From: Anji jonnala <[email protected]>

Some of the simulators may cache the ep0 maxpacket size to zero if the ep0 dQh is not setup before enabling the pullup. Hence Setup ep0 and initialize the dQh fields once while registering the gadget(before enabling the pullup).

HSUSB Chipidea link controller spec says ep0 is enabled always in the HW. Hence disabling and enabling the ep0 as a part of reset interrupt is unneccesary.
Remove the disable/enable ep0 logic from reset interrupt handling.

---
 drivers/usb/gadget/ci13xxx_udc.c |   31 +++++++++++++++++--------------
 1 files changed, 17 insertions(+), 14 deletions(-)
drivers/usb/gadget/ci13xxx_udc.c +17 -14
index 09c76a1..68123ee 100644
@@ -1634,8 +1634,6 @@ static int _gadget_stop_activity(struct usb_gadget *gadget)
 	gadget_for_each_ep(ep, gadget) {
 		usb_ep_disable(ep);
 	}
-	usb_ep_disable(&udc->ep0out.ep);
-	usb_ep_disable(&udc->ep0in.ep);
 
 	if (udc->status != NULL) {
 		usb_ep_free_request(&udc->ep0in.ep, udc->status);
@@ -1678,18 +1676,10 @@ __acquires(udc->lock)
 	if (retval)
 		goto done;
 
-	retval = usb_ep_enable(&udc->ep0out.ep, &ctrl_endpt_out_desc);
-	if (retval)
-		goto done;
+	udc->status = usb_ep_alloc_request(&udc->ep0in.ep, GFP_ATOMIC);
+	if (udc->status == NULL)
+		retval = -ENOMEM;
 
-	retval = usb_ep_enable(&udc->ep0in.ep, &ctrl_endpt_in_desc);
-	if (!retval) {
-		udc->status = usb_ep_alloc_request(&udc->ep0in.ep, GFP_ATOMIC);
-		if (udc->status == NULL) {
-			usb_ep_disable(&udc->ep0out.ep);
-			retval = -ENOMEM;
-		}
-	}
 	spin_lock(udc->lock);
 
  done:
@@ -2120,7 +2110,12 @@ static int ep_enable(struct usb_ep *ep,
 		(mEp->ep.maxpacket << ffs_nr(QH_MAX_PKT)) & QH_MAX_PKT;
 	mEp->qh.ptr->td.next |= TD_TERMINATE;   /* needed? */
 
-	retval |= hw_ep_enable(mEp->num, mEp->dir, mEp->type);
+	/*
+	 * Enable endpoints in the HW other than ep0 as ep0
+	 * is always enabled
+	 */
+	if (mEp->num)
+		retval |= hw_ep_enable(mEp->num, mEp->dir, mEp->type);
 
 	spin_unlock_irqrestore(mEp->lock, flags);
 	return retval;
@@ -2609,6 +2604,14 @@ int usb_gadget_probe_driver(struct usb_gadget_driver *driver,
 	}
 	if (retval)
 		goto done;
+	spin_unlock_irqrestore(udc->lock, flags);
+	retval = usb_ep_enable(&udc->ep0out.ep, &ctrl_endpt_out_desc);
+	if (retval)
+		return retval;
+	retval = usb_ep_enable(&udc->ep0in.ep, &ctrl_endpt_in_desc);
+	if (retval)
+		return retval;
+	spin_lock_irqsave(udc->lock, flags);
 
 	udc->gadget.ep0 = &udc->ep0in.ep;
 	/* bind gadget */
Signature · 2 lines
Sent by a consultant of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
#31 lore raw

PATCH v2 7/7 USB: OTG: msm: Clear in_lpm flag before enabling the IRQ in resume

In reply to Pavankumar Kondeti

The current code is clearing in_lpm flag after enabling the IRQ. If IRQ comes immediately before in_lpm flag is set, it thinks that hardware is in low power mode and disables the IRQ. Fix this by clearing in_lpm flag before enabling the IRQ.

---
 drivers/usb/otg/msm_otg.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/usb/otg/msm_otg.c +2 -2
index 2965986..f58b7da 100644
@@ -389,14 +389,14 @@ skip_phy_resume:
 	if (bus)
 		set_bit(HCD_FLAG_HW_ACCESSIBLE, &(bus_to_hcd(bus))->flags);
 
+	atomic_set(&motg->in_lpm, 0);
+
 	if (motg->async_int) {
 		motg->async_int = 0;
 		pm_runtime_put(otg->dev);
 		enable_irq(motg->irq);
 	}
 
-	atomic_set(&motg->in_lpm, 0);
-
 	dev_info(otg->dev, "USB exited from low power mode\n");
 
 	return 0;
Signature · 2 lines
Sent by a consultant of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.