usb: core: return -EAGAIN on usb_* functions reentrance
Subsystems (2)
cover usb: core: return -EAGAIN on usb_* functions reentrance
The second patch of this patch set adds reentrance detection to the the following functions: usb_submit_int_msg, usb_control_msg and usb_bulk_msg. These functions will return -EAGAIN if reentered. Other public usb_* functions call one of these three functions. This patch enables one to use regular *delay() functions throughout the ehci-hcd.c.
The first patch adds check for -EAGAIN return value to the usb keyboard driver. The driver will skip keyboard poll upon getting this error value from either usb_submit_int_msg() or usb_get_report() functions.
Peter Mamonov (2):
input: usb_kbd: skip poll on -EAGAIN error
usb: core: return -EAGAIN on usb_* functions reentrance
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
PATCH 1/2 input: usb_kbd: skip poll on -EAGAIN error
Skip poll if either usb_submit_int_msg() or usb_get_report() returned -EAGAIN.
--- drivers/input/usb_kbd.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/input/usb_kbd.c +5 -2
@@ -274,7 +274,7 @@ static void usb_kbd_poll(struct poller_struct *poller)struct usb_kbd_pdata *data =container_of (poller, struct usb_kbd_pdata, poller);struct usb_device *usbdev = data->usbdev; -int diff, tout; +int diff, tout, ret;if (data->lock)return ;
@@ -284,7 +284,10 @@ static void usb_kbd_poll(struct poller_struct *poller) goto exit; data->last_poll =get_time_ns (); -if (0 > data->do_poll (data)) { + ret = data->do_poll (data); +if (ret == -EAGAIN ) + goto exit; +if (ret <0 ) {/* exit and lock forever */ dev_err (&usbdev->dev,"usb_submit_int_msg() failed. Keyboard disconnect?\n" );
Signature · 7 lines
2.1.4 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH 2/2 usb: core: return -EAGAIN on usb_* functions reentrance
In reply to Peter Mamonov--- drivers/usb/core/usb.c | 40 +++++++++++++++++++++++++++++++++++++++- include/usb/usb.h | 1 + 2 files changed, 40 insertions(+), 1 deletion(-)
drivers/usb/core/usb.c +39 -1
@@ -84,10 +84,25 @@ static void print_usb_device(struct usb_device *dev)static int host_busnum =1 ; +static inline int usb_host_acquire (struct usb_host *host) +{ +if (host->sem) +return -EAGAIN ; + host->sem++; +return 0 ; +} + +static inline void usb_host_release (struct usb_host *host) +{ +if (host->sem >0 ) + host->sem--; +} +int usb_register_host (struct usb_host *host) {list_add_tail (&host->list, &host_list); host->busnum = host_busnum++; + host->sem =0 ; asynch_allowed =1 ;return 0 ; }
@@ -563,8 +578,17 @@ int usb_submit_int_msg(struct usb_device *dev, unsigned long pipe, void *buffer, int transfer_len, int interval) { struct usb_host *host = dev->host; +int ret; + + ret =usb_host_acquire (host); +if (ret) +return ret; + + ret = host->submit_int_msg (dev, pipe, buffer, transfer_len, interval); -return host->submit_int_msg (dev, pipe, buffer, transfer_len, interval); +usb_host_release (host); + +return ret; }/*
@@ -590,6 +614,10 @@ int usb_control_msg(struct usb_device *dev, unsigned int pipe,return -1 ; } + ret =usb_host_acquire (host); +if (ret) +return ret; +/* set setup command */ setup_packet->requesttype = requesttype; setup_packet->request = request;
@@ -603,6 +631,9 @@ int usb_control_msg(struct usb_device *dev, unsigned int pipe, ret = host->submit_control_msg (dev, pipe, data, size, setup_packet, timeout); + +usb_host_release (host); +if (ret)return ret;
@@ -623,8 +654,15 @@ int usb_bulk_msg(struct usb_device *dev, unsigned int pipe,if (len <0 )return -1 ; + ret =usb_host_acquire (host); +if (ret) +return ret; + dev->status =USB_ST_NOT_PROC ;/* not yet processed */ ret = host->submit_bulk_msg (dev, pipe, data, len, timeout); + +usb_host_release (host); +if (ret)return ret;
include/usb/usb.h +1 -0
@@ -152,6 +152,7 @@ struct usb_host {struct device_d *hw_dev;int busnum;struct usb_device *root_dev; +int sem; };int usb_register_host (struct usb_host *);
Signature · 7 lines
2.1.4 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Hi Peter,
Quoted 7 lines · Peter Mamonov
The second patch of this patch set adds reentrance detection to the the following functions:
usb_submit_int_msg,usb_control_msgandusb_bulk_msg. These functions will return-EAGAINif reentered. Other public usb_* functions call one of these three functions. This patch enables one to use regular*delay()functions throughout theehci-hcd.c.
Quoted 7 lines
The first patch adds check for
-EAGAINreturn value to the usb keyboard driver. The driver will skip keyboard poll upon getting this error value from eitherusb_submit_int_msg()orusb_get_report()functions.Peter Mamonov (2):
input:usb_kbd: skip poll on-EAGAINerror
usb: core: return-EAGAINon usb_* functions reentrance
Applied on -next. I believe we no longer need mdelay_non_interruptible in the ehci-hcd driver, right? Also we don't have to detect re-entrancy in the ehci driver anymore. I have applied some patches removing that to -next. Could you check the result?
Sascha
Signature · 9 lines
Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Quoted 15 lines · On Wed, 14 Oct 2015 16:09:08 +0200 Sascha Hauer <[email protected]> wrote:
Hi Peter,
Quoted 12 lines · Peter Mamonov
The second patch of this patch set adds reentrance detection to the the following functions:
usb_submit_int_msg,usb_control_msgandusb_bulk_msg. These functions will return-EAGAINif reentered. Other public usb_* functions call one of these three functions. This patch enables one to use regular*delay()functions throughout theehci-hcd.c.The first patch adds check for
-EAGAINreturn value to the usb keyboard driver. The driver will skip keyboard poll upon getting this error value from eitherusb_submit_int_msg()orusb_get_report()functions.
Quoted 8 lines
Quoted 3 lines
Peter Mamonov (2):
input:usb_kbd: skip poll on-EAGAINerror
usb: core: return-EAGAINon usb_* functions reentranceApplied on -next. I believe we no longer need
mdelay_non_interruptiblein the ehci-hcd driver, right? Also we don't have to detect re-entrancy in the ehci driver anymore. I have applied some patches removing that to -next. Could you check the result?
Yes.
Yes.
I've tested the current "next" branch - the usb stuff works fine.
Quoted 4 lines
Sascha
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox