Re: [PATCH] usb/gadget: f_midi: Replace tasklet with work

From: Takashi Iwai
Date: Mon Jan 11 2021 - 03:29:13 EST


On Mon, 11 Jan 2021 05:28:55 +0100,
Davidlohr Bueso wrote:
>
> Currently a tasklet is used to transmit input substream buffer
> data. However, tasklets have long been deprecated as being too
> heavy on the system by running in irq context - and this is not
> a performance critical path. If a higher priority process wants
> to run, it must wait for the tasklet to finish before doing so.
>
> Deferring work to a workqueue and executing in process context
> should be fine considering the callback already does
> f_midi_do_transmit() under the transmit_lock and thus changes in
> semantics are ok regarding concurrency - tasklets being serialized
> against itself.
>
> Cc: Takashi Iwai <tiwai@xxxxxxx>
> Signed-off-by: Davidlohr Bueso <dbueso@xxxxxxx>

The patch looks good to me.
Reviewed-by: Takashi Iwai <tiwai@xxxxxxx>


BTW, now I found that the driver doesn't have the cancel call for
tasklet or work at the unbind. Practically seen it's no big problem,
but its lack is a bait for syzbot. We may need to just call
cancel_work_sync() somewhere, probably at f_midi_drop_out_substreams()
or f_midi_disable(), but it can be in another patch.


thanks,

Takashi