Re: [PATCH 006/149] USB: m66592-udc: peripheral controller driver for M66592

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: David Brownell
Date: Friday, July 13, 2007 - 10:56 am

On Friday 13 July 2007, Yoshihiro Shimoda wrote:

I think I see what's going on.  Since requests passed into
usb_ep_queue() must have a completion handler, I thought your
original code -- testing for a null handler -- was wrong.

But I didn't notice that your internal GET_STATUS request
didn't have a completion handler.  Good thing I didn't add
a test for non-null completion in  m66592_queue()!

A better fix would be to supply a NOP completion handler
for that internal request.  That way there would be less risk
of code working on m66592-udc which would not work with other
controllers.

When looking at this, I observed a glitch in the locking
I added ... I'm assuming you still didn't run with locking
checks enabled, or you would have seen that issue.

Does the following patch behave, with all the locking test
options in the kernel debug menu enabled?

- Dave


======	CUT HERE
Fix more glitches in how status requests are handled.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
---
 drivers/usb/gadget/m66592-udc.c |   11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

--- g26.orig/drivers/usb/gadget/m66592-udc.c	2007-07-13 10:44:10.000000000 -0700
+++ g26/drivers/usb/gadget/m66592-udc.c	2007-07-13 10:55:13.000000000 -0700
@@ -916,8 +916,10 @@ static void irq_pipe_empty(struct m66592
 }
 
 static void get_status(struct m66592 *m66592, struct usb_ctrlrequest *ctrl)
+__releases(m66592->lock)
+__acquires(m66592->lock)
 {
-	struct m66592_ep *ep;
+	struct m66592_ep *ep = NULL;
 	u16 pid;
 	u16 status = 0;
 
@@ -944,7 +946,9 @@ static void get_status(struct m66592 *m6
 	*m66592->ep0_buf = status;
 	m66592->ep0_req->buf = m66592->ep0_buf;
 	m66592->ep0_req->length = 2;
+	spin_unlock(&ep->m66592->lock);
 	m66592_queue(m66592->gadget.ep0, m66592->ep0_req, GFP_KERNEL);
+	spin_lock(&ep->m66592->lock);
 }
 
 static void clear_feature(struct m66592 *m66592, struct usb_ctrlrequest *ctrl)
@@ -1480,6 +1484,10 @@ static int __exit m66592_remove(struct p
 	return 0;
 }
 
+static void nop_completion(struct usb_ep *ep, struct usb_request *r)
+{
+}
+
 #define resource_len(r) (((r)->end - (r)->start) + 1)
 
 static int __init m66592_probe(struct platform_device *pdev)
@@ -1578,6 +1586,7 @@ static int __init m66592_probe(struct pl
 	m66592->ep0_req = m66592_alloc_request(&m66592->ep[0].ep, GFP_KERNEL);
 	if (m66592->ep0_req == NULL)
 		goto clean_up;
+	m66592->ep0_req->complete = nop_completion;
 	m66592->ep0_buf = kmalloc(2, GFP_KERNEL);
 	if (m66592->ep0_buf == NULL)
 		goto clean_up;

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
linux-usb-devel@lists.sourceforge.net
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH 001/149] USB: suspend support for usb serial, Greg Kroah-Hartman, (Thu Jul 12, 4:40 pm)
[PATCH 002/149] USB: EHCI cpufreq fix, Greg Kroah-Hartman, (Thu Jul 12, 4:40 pm)
[PATCH 003/149] USB: EHCI support for big-endian descriptors, Greg Kroah-Hartman, (Thu Jul 12, 4:40 pm)
[PATCH 004/149] USB: cxacru: Cleanup sysfs attribute code, Greg Kroah-Hartman, (Thu Jul 12, 4:40 pm)
[PATCH 005/149] USB Serial Keyspan: add support for USA-49 ..., Greg Kroah-Hartman, (Thu Jul 12, 4:40 pm)
[PATCH 006/149] USB: m66592-udc: peripheral controller dri ..., Greg Kroah-Hartman, (Thu Jul 12, 4:40 pm)
[PATCH 007/149] USB: m66592-udc: fix use old interrupt flags, Greg Kroah-Hartman, (Thu Jul 12, 4:40 pm)
[PATCH 008/149] USB: r8a66597-hcd: host controller driver ..., Greg Kroah-Hartman, (Thu Jul 12, 4:40 pm)
[PATCH 009/149] USB: r8a66597-hcd: fix NULL access, Greg Kroah-Hartman, (Thu Jul 12, 4:40 pm)
[PATCH 010/149] USB: interface PM state, Greg Kroah-Hartman, (Thu Jul 12, 4:40 pm)
[PATCH 011/149] USB: Implement PM FREEZE and PRETHAW, Greg Kroah-Hartman, (Thu Jul 12, 4:40 pm)
[PATCH 012/149] USB: move bus_suspend and bus_resume metho ..., Greg Kroah-Hartman, (Thu Jul 12, 4:40 pm)
[PATCH 013/149] USB: don't unsuspend for a new connection, Greg Kroah-Hartman, (Thu Jul 12, 4:40 pm)
[PATCH 014/149] USB: remove references to dev.power.power_ ..., Greg Kroah-Hartman, (Thu Jul 12, 4:40 pm)
[PATCH 016/149] USB: make hub driver's release more robust, Greg Kroah-Hartman, (Thu Jul 12, 4:40 pm)
[PATCH 017/149] USB: Use menuconfig objects, Greg Kroah-Hartman, (Thu Jul 12, 4:40 pm)
[PATCH 018/149] USB: ehci refcounts work on ppc7448, Greg Kroah-Hartman, (Thu Jul 12, 4:40 pm)
[PATCH 019/149] USB: oti6858 usb-serial driver (in Nokia C ..., Greg Kroah-Hartman, (Thu Jul 12, 4:40 pm)
[GIT PATCH] USB patches for 2.6.22, Greg KH, (Thu Jul 12, 4:42 pm)
Re: [GIT PATCH] USB patches for 2.6.22, Linus Torvalds, (Thu Jul 12, 5:03 pm)
Re: [GIT PATCH] USB patches for 2.6.22, Greg KH, (Thu Jul 12, 5:19 pm)
Re: [GIT PATCH] USB patches for 2.6.22, Andrew Morton, (Thu Jul 12, 5:20 pm)
Re: , David Brownell, (Thu Jul 12, 6:48 pm)
Re: [PATCH 006/149] USB: m66592-udc: peripheral controller ..., Yoshihiro Shimoda, (Fri Jul 13, 6:56 am)
Re: [PATCH 006/149] USB: m66592-udc: peripheral controller ..., David Brownell, (Fri Jul 13, 10:56 am)
Re: [PATCH 006/149] USB: m66592-udc: peripheral controller ..., Yoshihiro Shimoda, (Sat Jul 14, 4:32 am)
Re: [PATCH 006/149] USB: m66592-udc: peripheral controller ..., Yoshihiro Shimoda, (Sun Jul 15, 10:26 pm)
Re: [PATCH 006/149] USB: m66592-udc: peripheral controller ..., Yoshihiro Shimoda, (Mon Jul 16, 7:21 pm)
Re: [PATCH 006/149] USB: m66592-udc: peripheral controller ..., Yoshihiro Shimoda, (Tue Jul 17, 12:11 am)