mbox series

[v5,0/2] Remove useless param of devcoredump functions and fix bugs

Message ID cover.1654229964.git.duoming@zju.edu.cn
Headers show
Series Remove useless param of devcoredump functions and fix bugs | expand

Message

Duoming Zhou June 3, 2022, 5:09 a.m. UTC
The first patch removes the extra gfp_t param of dev_coredumpv()
and dev_coredumpm().

The second patch fix sleep in atomic context bugs of mwifiex
caused by dev_coredumpv().

Duoming Zhou (2):
  devcoredump: remove the useless gfp_t parameter in dev_coredumpv and
    dev_coredumpm
  mwifiex: fix sleep in atomic context bugs caused by dev_coredumpv

 drivers/base/devcoredump.c                       | 16 ++++++----------
 drivers/bluetooth/btmrvl_sdio.c                  |  2 +-
 drivers/bluetooth/hci_qca.c                      |  2 +-
 drivers/gpu/drm/etnaviv/etnaviv_dump.c           |  2 +-
 drivers/gpu/drm/msm/disp/msm_disp_snapshot.c     |  4 ++--
 drivers/gpu/drm/msm/msm_gpu.c                    |  4 ++--
 drivers/media/platform/qcom/venus/core.c         |  2 +-
 drivers/net/can/spi/mcp251xfd/mcp251xfd-dump.c   |  2 +-
 drivers/net/wireless/ath/ath10k/coredump.c       |  2 +-
 .../net/wireless/ath/wil6210/wil_crash_dump.c    |  2 +-
 .../wireless/broadcom/brcm80211/brcmfmac/debug.c |  2 +-
 drivers/net/wireless/intel/iwlwifi/fw/dbg.c      |  6 ++----
 drivers/net/wireless/marvell/mwifiex/init.c      | 10 ++++++----
 drivers/net/wireless/marvell/mwifiex/main.c      |  3 +--
 drivers/net/wireless/marvell/mwifiex/main.h      |  2 +-
 drivers/net/wireless/marvell/mwifiex/sta_event.c |  6 +++---
 drivers/net/wireless/mediatek/mt76/mt7615/mac.c  |  3 +--
 drivers/net/wireless/mediatek/mt76/mt7921/mac.c  |  3 +--
 drivers/net/wireless/realtek/rtw88/main.c        |  2 +-
 drivers/net/wireless/realtek/rtw89/ser.c         |  2 +-
 drivers/remoteproc/qcom_q6v5_mss.c               |  2 +-
 drivers/remoteproc/remoteproc_coredump.c         |  8 ++++----
 include/drm/drm_print.h                          |  2 +-
 include/linux/devcoredump.h                      | 13 ++++++-------
 sound/soc/intel/avs/apl.c                        |  2 +-
 sound/soc/intel/avs/skl.c                        |  2 +-
 sound/soc/intel/catpt/dsp.c                      |  2 +-
 27 files changed, 50 insertions(+), 58 deletions(-)

Comments

Brian Norris June 6, 2022, 6:14 p.m. UTC | #1
On Fri, Jun 03, 2022 at 01:09:35PM +0800, Duoming Zhou wrote:
> There are sleep in atomic context bugs when uploading device dump
> data in mwifiex. The root cause is that dev_coredumpv could not
> be used in atomic contexts, because it calls dev_set_name which
> include operations that may sleep. The call tree shows execution
> paths that could lead to bugs:
...
> Fixes: f5ecd02a8b20 ("mwifiex: device dump support for usb interface")
> Signed-off-by: Duoming Zhou <duoming@zju.edu.cn>
> ---
> Changes in v5:
>   - Use delayed work to replace timer.
> 
>  drivers/net/wireless/marvell/mwifiex/init.c      | 10 ++++++----
>  drivers/net/wireless/marvell/mwifiex/main.h      |  2 +-
>  drivers/net/wireless/marvell/mwifiex/sta_event.c |  6 +++---
>  3 files changed, 10 insertions(+), 8 deletions(-)

Looks great! Thanks for working on this.

Reviewed-by: Brian Norris <briannorris@chromium.org>

Some small nitpicks below, but they're definitely not critical.

> diff --git a/drivers/net/wireless/marvell/mwifiex/init.c b/drivers/net/wireless/marvell/mwifiex/init.c
> index 88c72d1827a..3713f3e323f 100644
> --- a/drivers/net/wireless/marvell/mwifiex/init.c
> +++ b/drivers/net/wireless/marvell/mwifiex/init.c
> @@ -63,9 +63,11 @@ static void wakeup_timer_fn(struct timer_list *t)
>  		adapter->if_ops.card_reset(adapter);
>  }
>  
> -static void fw_dump_timer_fn(struct timer_list *t)
> +static void fw_dump_work(struct work_struct *work)
>  {
> -	struct mwifiex_adapter *adapter = from_timer(adapter, t, devdump_timer);
> +	struct mwifiex_adapter *adapter = container_of(work,
> +					struct mwifiex_adapter,
> +					devdump_work.work);

Super nitpicky: the hanging indent style seems a bit off. I typically
see people try to align to the first character after the parenthesis,
like:

	struct mwifiex_adapter *adapter = container_of(work,
						       struct mwifiex_adapter,
						       devdump_work.work);

It's not a clearly-specified style rule I think, so I definitely
wouldn't insist.

On the bright side: I think the clang-format rules (in .clang-format)
are getting better, so one can make some formatting decisions via tools
instead of opinion and close reading! Unfortunately, we probably can't
do that extensively and automatically, because I doubt people will love
all the reformatting because of all the existing inconsistent style.

Anyway, to cut to the chase: clang-format chooses moving to a new line:

	struct mwifiex_adapter *adapter =
		container_of(work, struct mwifiex_adapter, devdump_work.work);

More info if you're interested:
https://www.kernel.org/doc/html/latest/process/clang-format.html

>  
>  	mwifiex_upload_device_dump(adapter);
>  }

...

> diff --git a/drivers/net/wireless/marvell/mwifiex/main.h b/drivers/net/wireless/marvell/mwifiex/main.h
> index 332dd1c8db3..6530c6ee308 100644
> --- a/drivers/net/wireless/marvell/mwifiex/main.h
> +++ b/drivers/net/wireless/marvell/mwifiex/main.h
> @@ -1055,7 +1055,7 @@ struct mwifiex_adapter {

Nitpick: main.h is probably missing a lot of #includes, but you could
probably add <linux/workqueue.h> while you're at it.

Brian

>  	/* Device dump data/length */
>  	void *devdump_data;
>  	int devdump_len;
> -	struct timer_list devdump_timer;
> +	struct delayed_work devdump_work;
>  
>  	bool ignore_btcoex_events;
>  };
Duoming Zhou June 7, 2022, 12:22 a.m. UTC | #2
Hello,

On Mon, 6 Jun 2022 11:14:05 -0700 Brian wrote:

> On Fri, Jun 03, 2022 at 01:09:35PM +0800, Duoming Zhou wrote:
> > There are sleep in atomic context bugs when uploading device dump
> > data in mwifiex. The root cause is that dev_coredumpv could not
> > be used in atomic contexts, because it calls dev_set_name which
> > include operations that may sleep. The call tree shows execution
> > paths that could lead to bugs:
> ...
> > Fixes: f5ecd02a8b20 ("mwifiex: device dump support for usb interface")
> > Signed-off-by: Duoming Zhou <duoming@zju.edu.cn>
> > ---
> > Changes in v5:
> >   - Use delayed work to replace timer.
> > 
> >  drivers/net/wireless/marvell/mwifiex/init.c      | 10 ++++++----
> >  drivers/net/wireless/marvell/mwifiex/main.h      |  2 +-
> >  drivers/net/wireless/marvell/mwifiex/sta_event.c |  6 +++---
> >  3 files changed, 10 insertions(+), 8 deletions(-)
> 
> Looks great! Thanks for working on this.
> 
> Reviewed-by: Brian Norris <briannorris@chromium.org>
> 
> Some small nitpicks below, but they're definitely not critical.

Thank you for your time and approval!

> > diff --git a/drivers/net/wireless/marvell/mwifiex/init.c b/drivers/net/wireless/marvell/mwifiex/init.c
> > index 88c72d1827a..3713f3e323f 100644
> > --- a/drivers/net/wireless/marvell/mwifiex/init.c
> > +++ b/drivers/net/wireless/marvell/mwifiex/init.c
> > @@ -63,9 +63,11 @@ static void wakeup_timer_fn(struct timer_list *t)
> >  		adapter->if_ops.card_reset(adapter);
> >  }
> >  
> > -static void fw_dump_timer_fn(struct timer_list *t)
> > +static void fw_dump_work(struct work_struct *work)
> >  {
> > -	struct mwifiex_adapter *adapter = from_timer(adapter, t, devdump_timer);
> > +	struct mwifiex_adapter *adapter = container_of(work,
> > +					struct mwifiex_adapter,
> > +					devdump_work.work);
> 
> Super nitpicky: the hanging indent style seems a bit off. I typically
> see people try to align to the first character after the parenthesis,
> like:
> 
> 	struct mwifiex_adapter *adapter = container_of(work,
> 						       struct mwifiex_adapter,
> 						       devdump_work.work);
> 
> It's not a clearly-specified style rule I think, so I definitely
> wouldn't insist.
> 
> On the bright side: I think the clang-format rules (in .clang-format)
> are getting better, so one can make some formatting decisions via tools
> instead of opinion and close reading! Unfortunately, we probably can't
> do that extensively and automatically, because I doubt people will love
> all the reformatting because of all the existing inconsistent style.
> 
> Anyway, to cut to the chase: clang-format chooses moving to a new line:
> 
> 	struct mwifiex_adapter *adapter =
> 		container_of(work, struct mwifiex_adapter, devdump_work.work);
> 
> More info if you're interested:
> https://www.kernel.org/doc/html/latest/process/clang-format.html
> 
> >  
> >  	mwifiex_upload_device_dump(adapter);
> >  }

Thanks for your suggestions! I will use clang-format to adjust the format.

> > diff --git a/drivers/net/wireless/marvell/mwifiex/main.h b/drivers/net/wireless/marvell/mwifiex/main.h
> > index 332dd1c8db3..6530c6ee308 100644
> > --- a/drivers/net/wireless/marvell/mwifiex/main.h
> > +++ b/drivers/net/wireless/marvell/mwifiex/main.h
> > @@ -1055,7 +1055,7 @@ struct mwifiex_adapter {
> 
> Nitpick: main.h is probably missing a lot of #includes, but you could
> probably add <linux/workqueue.h> while you're at it.

I will add <linux/workqueue.h> in main.h.

> 
> >  	/* Device dump data/length */
> >  	void *devdump_data;
> >  	int devdump_len;
> > -	struct timer_list devdump_timer;
> > +	struct delayed_work devdump_work;
> >  
> >  	bool ignore_btcoex_events;
> >  };

Best regards,
Duoming Zhou