* [PATCH 1/3] sound: usb: line6: Replace mdelay with msleep in line6_read_data
@ 2018-03-18 14:51 Jia-Ju Bai
2018-03-18 15:23 ` [alsa-devel] " Ladislav Michl
0 siblings, 1 reply; 2+ messages in thread
From: Jia-Ju Bai @ 2018-03-18 14:51 UTC (permalink / raw)
To: perex, tiwai; +Cc: alsa-devel, linux-kernel, Jia-Ju Bai
line6_read_data() is never called in atomic context.
The call chains ending up at line6_read_data() are:
[1] line6_read_data() <- line6_read_serial_number() -> pod_startup4()
[2] line6_read_data() <- line6_read_serial_number() <-
podhd_startup_workqueue()
[3] line6_read_data() <- podhd_dev_start() <- podhd_startup_workqueue()
[4] line6_read_data() <- line6_read_serial_number() <- toneport_init()
<- line6_probe()
[5] line6_read_data() <- toneport_init() <- line6_probe()
pod_startup4() and podhd_startup_workqueue() are set in INIT_WORK().
line6_probe() is called in toneport_probe(), pod_probe(), podhd_probe()
and variax_probe(), which are set as ".probe" in usb_driver structure.
These functions are not called in atomic context.
Despite never getting called from atomic context, line6_read_data()
calls mdelay for busy wait.
That is not necessary and can be replaced with msleep to
avoid busy waiting.
This is found by a static analysis tool named DCNS written by myself.
Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>
---
sound/usb/line6/driver.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sound/usb/line6/driver.c b/sound/usb/line6/driver.c
index 0ff5a7d..af99e73 100644
--- a/sound/usb/line6/driver.c
+++ b/sound/usb/line6/driver.c
@@ -356,7 +356,7 @@ int line6_read_data(struct usb_line6 *line6, unsigned address, void *data,
/* Wait for data length. We'll get 0xff until length arrives. */
for (count = 0; count < LINE6_READ_WRITE_MAX_RETRIES; count++) {
- mdelay(LINE6_READ_WRITE_STATUS_DELAY);
+ msleep(LINE6_READ_WRITE_STATUS_DELAY);
ret = usb_control_msg(usbdev, usb_rcvctrlpipe(usbdev, 0), 0x67,
USB_TYPE_VENDOR | USB_RECIP_DEVICE |
--
1.9.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [alsa-devel] [PATCH 1/3] sound: usb: line6: Replace mdelay with msleep in line6_read_data
2018-03-18 14:51 [PATCH 1/3] sound: usb: line6: Replace mdelay with msleep in line6_read_data Jia-Ju Bai
@ 2018-03-18 15:23 ` Ladislav Michl
0 siblings, 0 replies; 2+ messages in thread
From: Ladislav Michl @ 2018-03-18 15:23 UTC (permalink / raw)
To: Jia-Ju Bai
Cc: perex, tiwai, alsa-devel, linux-kernel, Markus Grabner,
Stefan Hajnoczi, Chris Rorvick, Andrej Krutak
On Sun, Mar 18, 2018 at 10:51:33PM +0800, Jia-Ju Bai wrote:
> line6_read_data() is never called in atomic context.
>
> The call chains ending up at line6_read_data() are:
> [1] line6_read_data() <- line6_read_serial_number() -> pod_startup4()
> [2] line6_read_data() <- line6_read_serial_number() <-
> podhd_startup_workqueue()
> [3] line6_read_data() <- podhd_dev_start() <- podhd_startup_workqueue()
> [4] line6_read_data() <- line6_read_serial_number() <- toneport_init()
> <- line6_probe()
> [5] line6_read_data() <- toneport_init() <- line6_probe()
>
> pod_startup4() and podhd_startup_workqueue() are set in INIT_WORK().
> line6_probe() is called in toneport_probe(), pod_probe(), podhd_probe()
> and variax_probe(), which are set as ".probe" in usb_driver structure.
> These functions are not called in atomic context.
>
> Despite never getting called from atomic context, line6_read_data()
> calls mdelay for busy wait.
> That is not necessary and can be replaced with msleep to
> avoid busy waiting.
Can we have usleep_range here? Please see Documentation/timers/timers-howto.txt
for rationale and range settings.
> This is found by a static analysis tool named DCNS written by myself.
Here I'm assuming you do not have hardware and do not know how it works,
therefore few more people from 'git log --follow sound/usb/line6/driver.c'
were added to Cc list. Hopefully they can clarify the right range value.
Thank you.
> Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>
> ---
> sound/usb/line6/driver.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/sound/usb/line6/driver.c b/sound/usb/line6/driver.c
> index 0ff5a7d..af99e73 100644
> --- a/sound/usb/line6/driver.c
> +++ b/sound/usb/line6/driver.c
> @@ -356,7 +356,7 @@ int line6_read_data(struct usb_line6 *line6, unsigned address, void *data,
>
> /* Wait for data length. We'll get 0xff until length arrives. */
> for (count = 0; count < LINE6_READ_WRITE_MAX_RETRIES; count++) {
> - mdelay(LINE6_READ_WRITE_STATUS_DELAY);
> + msleep(LINE6_READ_WRITE_STATUS_DELAY);
>
> ret = usb_control_msg(usbdev, usb_rcvctrlpipe(usbdev, 0), 0x67,
> USB_TYPE_VENDOR | USB_RECIP_DEVICE |
> --
> 1.9.1
>
> _______________________________________________
> Alsa-devel mailing list
> Alsa-devel@alsa-project.org
> http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-03-18 15:23 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-18 14:51 [PATCH 1/3] sound: usb: line6: Replace mdelay with msleep in line6_read_data Jia-Ju Bai
2018-03-18 15:23 ` [alsa-devel] " Ladislav Michl
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).