Hi, On Mon, Mar 2, 2015 at 2:38 AM, Andrzej Pietrasiewicz <andrzej.p@xxxxxxxxxxx> wrote: > W dniu 27.02.2015 o 21:58, Felipe Balbi pisze: >> >> Hi, >> >> On Fri, Feb 27, 2015 at 02:55:25PM -0600, Felipe Balbi wrote: >>> >>> On Mon, Feb 23, 2015 at 04:02:09PM +0100, Andrzej Pietrasiewicz wrote: >>>> >>>> Non-standard requests can encode the actual interface number in a >>>> non-standard way. For example composite_setup() assumes >>>> that it is w_index && 0xFF, but the printer function encodes the >>>> interface >>>> number in a context-dependet way (either w_index or w_index >> 8). >>>> This can lead to such requests being directed to wrong functions. >>>> >>>> This patch adds req_match() method to usb_function. Its purpose is to >>>> verify that a given request can be handled by a given function. >>>> If any function within a configuration provides the method and it >>>> returns >>>> true, then it is assumed that the right function is found. >>>> >>>> If a function uses req_match(), it should try as hard as possible to >>>> determine if the request is meant for it. >>>> >>>> If no functions in a configuration provide req_match or none of them >>>> returns true, then fall back to the usual approach. >>>> >>>> Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@xxxxxxxxxxx> >>> >>> >>> this regresses testusb at least on am335x: >>> > > I don't have this particular hardware but will try looking into the issue. > As soon as I have some results I will let you know. I am unable to explain what I found below. Toolchain related? I added the following change to the driver. diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c index 07cee80..3b0e5da 100644 --- a/drivers/usb/gadget/composite.c +++ b/drivers/usb/gadget/composite.c @@ -1781,6 +1781,7 @@ unknown: break; } try_fun_setup: + dev_err(NULL, "f %p, ->setup %p\n", f, f->setup); if (f && f->setup) value = f->setup(f, ctrl); else { Then, got the following kernel crash log. [ 59.365832] (NULL device *): f bf0116ac, ->setup 00400403 [ 59.371515] Unable to handle kernel paging request at virtual address 00400402 So the problem is f->setup pointer is not word aligned. The following patch seems make the issue disappeared. diff --git a/include/linux/usb/composite.h b/include/linux/usb/composite.h index 51f477a..dde3184 100644 --- a/include/linux/usb/composite.h +++ b/include/linux/usb/composite.h @@ -212,10 +212,10 @@ struct usb_function { int (*get_alt)(struct usb_function *, unsigned interface); void (*disable)(struct usb_function *); - bool (*req_match)(struct usb_function *, - const struct usb_ctrlrequest *); int (*setup)(struct usb_function *, const struct usb_ctrlrequest *); + bool (*req_match)(struct usb_function *, + const struct usb_ctrlrequest *); void (*suspend)(struct usb_function *); void (*resume)(struct usb_function *); Regards, -Bin. > > AP > > > -- > 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 -- 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