Message ID | 20240422153607.963672-1-saproj@gmail.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | mmc: moxart: fix handling of sgm->consumed, otherwise WARN_ON triggers | expand |
On Mon, Apr 22, 2024 at 5:36 PM Sergei Antonov <saproj@gmail.com> wrote: > When e.g. 8 bytes are to be read, sgm->consumed equals 8 immediately after > sg_miter_next() call. The driver then increments it as bytes are read, > so sgm->consumed becomes 16 and this warning triggers in sg_miter_stop(): > WARN_ON(miter->consumed > miter->length); > > WARNING: CPU: 0 PID: 28 at lib/scatterlist.c:925 sg_miter_stop+0x2c/0x10c > CPU: 0 PID: 28 Comm: kworker/0:2 Tainted: G W 6.9.0-rc5-dirty #249 > Hardware name: Generic DT based system > Workqueue: events_freezable mmc_rescan > Call trace:. > unwind_backtrace from show_stack+0x10/0x14 > show_stack from dump_stack_lvl+0x44/0x5c > dump_stack_lvl from __warn+0x78/0x16c > __warn from warn_slowpath_fmt+0xb0/0x160 > warn_slowpath_fmt from sg_miter_stop+0x2c/0x10c > sg_miter_stop from moxart_request+0xb0/0x468 > moxart_request from mmc_start_request+0x94/0xa8 > mmc_start_request from mmc_wait_for_req+0x60/0xa8 > mmc_wait_for_req from mmc_app_send_scr+0xf8/0x150 > mmc_app_send_scr from mmc_sd_setup_card+0x1c/0x420 > mmc_sd_setup_card from mmc_sd_init_card+0x12c/0x4dc > mmc_sd_init_card from mmc_attach_sd+0xf0/0x16c > mmc_attach_sd from mmc_rescan+0x1e0/0x298 > mmc_rescan from process_scheduled_works+0x2e4/0x4ec > process_scheduled_works from worker_thread+0x1ec/0x24c > worker_thread from kthread+0xd4/0xe0 > kthread from ret_from_fork+0x14/0x38 > > This patch adds initial zeroing of sgm->consumed. It is then incremented > as bytes are read or written. > > Signed-off-by: Sergei Antonov <saproj@gmail.com> > Cc: Linus Walleij <linus.walleij@linaro.org> > Fixes: 3ee0e7c3e67c ("mmc: moxart-mmc: Use sg_miter for PIO") Oh it was that simple. Thanks for fixing this Sergei! Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Yours, Linus Walleij
On Mon, 22 Apr 2024 at 20:56, Linus Walleij <linus.walleij@linaro.org> wrote: > Oh it was that simple. > > Thanks for fixing this Sergei! > Reviewed-by: Linus Walleij <linus.walleij@linaro.org> To fix this WARN_ON was indeed simple. But the "BUG: scheduling while atomic" problem I reported in the other thread is a separate problem. So I'll respond there.
On Mon, 22 Apr 2024 at 17:36, Sergei Antonov <saproj@gmail.com> wrote: > > When e.g. 8 bytes are to be read, sgm->consumed equals 8 immediately after > sg_miter_next() call. The driver then increments it as bytes are read, > so sgm->consumed becomes 16 and this warning triggers in sg_miter_stop(): > WARN_ON(miter->consumed > miter->length); > > WARNING: CPU: 0 PID: 28 at lib/scatterlist.c:925 sg_miter_stop+0x2c/0x10c > CPU: 0 PID: 28 Comm: kworker/0:2 Tainted: G W 6.9.0-rc5-dirty #249 > Hardware name: Generic DT based system > Workqueue: events_freezable mmc_rescan > Call trace:. > unwind_backtrace from show_stack+0x10/0x14 > show_stack from dump_stack_lvl+0x44/0x5c > dump_stack_lvl from __warn+0x78/0x16c > __warn from warn_slowpath_fmt+0xb0/0x160 > warn_slowpath_fmt from sg_miter_stop+0x2c/0x10c > sg_miter_stop from moxart_request+0xb0/0x468 > moxart_request from mmc_start_request+0x94/0xa8 > mmc_start_request from mmc_wait_for_req+0x60/0xa8 > mmc_wait_for_req from mmc_app_send_scr+0xf8/0x150 > mmc_app_send_scr from mmc_sd_setup_card+0x1c/0x420 > mmc_sd_setup_card from mmc_sd_init_card+0x12c/0x4dc > mmc_sd_init_card from mmc_attach_sd+0xf0/0x16c > mmc_attach_sd from mmc_rescan+0x1e0/0x298 > mmc_rescan from process_scheduled_works+0x2e4/0x4ec > process_scheduled_works from worker_thread+0x1ec/0x24c > worker_thread from kthread+0xd4/0xe0 > kthread from ret_from_fork+0x14/0x38 > > This patch adds initial zeroing of sgm->consumed. It is then incremented > as bytes are read or written. > > Signed-off-by: Sergei Antonov <saproj@gmail.com> > Cc: Linus Walleij <linus.walleij@linaro.org> > Fixes: 3ee0e7c3e67c ("mmc: moxart-mmc: Use sg_miter for PIO") Applied for fixes, thanks! Kind regards Uffe > --- > drivers/mmc/host/moxart-mmc.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/drivers/mmc/host/moxart-mmc.c b/drivers/mmc/host/moxart-mmc.c > index b88d6dec209f..9a5f75163aca 100644 > --- a/drivers/mmc/host/moxart-mmc.c > +++ b/drivers/mmc/host/moxart-mmc.c > @@ -300,6 +300,7 @@ static void moxart_transfer_pio(struct moxart_host *host) > remain = sgm->length; > if (remain > host->data_len) > remain = host->data_len; > + sgm->consumed = 0; > > if (data->flags & MMC_DATA_WRITE) { > while (remain > 0) { > -- > 2.40.1 > >
diff --git a/drivers/mmc/host/moxart-mmc.c b/drivers/mmc/host/moxart-mmc.c index b88d6dec209f..9a5f75163aca 100644 --- a/drivers/mmc/host/moxart-mmc.c +++ b/drivers/mmc/host/moxart-mmc.c @@ -300,6 +300,7 @@ static void moxart_transfer_pio(struct moxart_host *host) remain = sgm->length; if (remain > host->data_len) remain = host->data_len; + sgm->consumed = 0; if (data->flags & MMC_DATA_WRITE) { while (remain > 0) {
When e.g. 8 bytes are to be read, sgm->consumed equals 8 immediately after sg_miter_next() call. The driver then increments it as bytes are read, so sgm->consumed becomes 16 and this warning triggers in sg_miter_stop(): WARN_ON(miter->consumed > miter->length); WARNING: CPU: 0 PID: 28 at lib/scatterlist.c:925 sg_miter_stop+0x2c/0x10c CPU: 0 PID: 28 Comm: kworker/0:2 Tainted: G W 6.9.0-rc5-dirty #249 Hardware name: Generic DT based system Workqueue: events_freezable mmc_rescan Call trace:. unwind_backtrace from show_stack+0x10/0x14 show_stack from dump_stack_lvl+0x44/0x5c dump_stack_lvl from __warn+0x78/0x16c __warn from warn_slowpath_fmt+0xb0/0x160 warn_slowpath_fmt from sg_miter_stop+0x2c/0x10c sg_miter_stop from moxart_request+0xb0/0x468 moxart_request from mmc_start_request+0x94/0xa8 mmc_start_request from mmc_wait_for_req+0x60/0xa8 mmc_wait_for_req from mmc_app_send_scr+0xf8/0x150 mmc_app_send_scr from mmc_sd_setup_card+0x1c/0x420 mmc_sd_setup_card from mmc_sd_init_card+0x12c/0x4dc mmc_sd_init_card from mmc_attach_sd+0xf0/0x16c mmc_attach_sd from mmc_rescan+0x1e0/0x298 mmc_rescan from process_scheduled_works+0x2e4/0x4ec process_scheduled_works from worker_thread+0x1ec/0x24c worker_thread from kthread+0xd4/0xe0 kthread from ret_from_fork+0x14/0x38 This patch adds initial zeroing of sgm->consumed. It is then incremented as bytes are read or written. Signed-off-by: Sergei Antonov <saproj@gmail.com> Cc: Linus Walleij <linus.walleij@linaro.org> Fixes: 3ee0e7c3e67c ("mmc: moxart-mmc: Use sg_miter for PIO") --- drivers/mmc/host/moxart-mmc.c | 1 + 1 file changed, 1 insertion(+)