linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Jérôme Pouiller" <jerome.pouiller@silabs.com>
To: Kalle Valo <kvalo@kernel.org>,
	Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>
Cc: linux-wireless <linux-wireless@vger.kernel.org>
Subject: Re: [PATCH v2] wfx: avoid flush_workqueue(system_highpri_wq) usage
Date: Mon, 02 May 2022 10:38:43 +0200	[thread overview]
Message-ID: <3828648.MHq7AAxBmi@pc-42> (raw)
In-Reply-To: <f15574a6-aba4-72bc-73af-26fdcdf9fb63@I-love.SAKURA.ne.jp>

On Monday 2 May 2022 10:16:06 CEST Tetsuo Handa wrote:
> CAUTION: This email originated from outside of the organization. Do not click links or open attachments unless you recognize the sender and know the content is safe.
> 
> 
> Flushing system-wide workqueues is dangerous and will be forbidden.
> Replace system_highpri_wq with per "struct wfx_dev" bh_wq.
> 
> Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
> ---
> Note: This patch is only compile tested.
> 
> Changes in v2:
>   Use per "struct wfx_dev" workqueue.
> 
>  drivers/net/wireless/silabs/wfx/bh.c     | 6 +++---
>  drivers/net/wireless/silabs/wfx/hif_tx.c | 2 +-
>  drivers/net/wireless/silabs/wfx/main.c   | 6 ++++++
>  drivers/net/wireless/silabs/wfx/wfx.h    | 1 +
>  4 files changed, 11 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/net/wireless/silabs/wfx/bh.c b/drivers/net/wireless/silabs/wfx/bh.c
> index bcea9d5b119c..21dfdcf9cc27 100644
> --- a/drivers/net/wireless/silabs/wfx/bh.c
> +++ b/drivers/net/wireless/silabs/wfx/bh.c
> @@ -267,7 +267,7 @@ void wfx_bh_request_rx(struct wfx_dev *wdev)
>         wfx_control_reg_read(wdev, &cur);
>         prev = atomic_xchg(&wdev->hif.ctrl_reg, cur);
>         complete(&wdev->hif.ctrl_ready);
> -       queue_work(system_highpri_wq, &wdev->hif.bh);
> +       queue_work(wdev->bh_wq, &wdev->hif.bh);
> 
>         if (!(cur & CTRL_NEXT_LEN_MASK))
>                 dev_err(wdev->dev, "unexpected control register value: length field is 0: %04x\n",
> @@ -280,7 +280,7 @@ void wfx_bh_request_rx(struct wfx_dev *wdev)
>  /* Driver want to send data */
>  void wfx_bh_request_tx(struct wfx_dev *wdev)
>  {
> -       queue_work(system_highpri_wq, &wdev->hif.bh);
> +       queue_work(wdev->bh_wq, &wdev->hif.bh);
>  }
> 
>  /* If IRQ is not available, this function allow to manually poll the control register and simulate
> @@ -295,7 +295,7 @@ void wfx_bh_poll_irq(struct wfx_dev *wdev)
>         u32 reg;
> 
>         WARN(!wdev->poll_irq, "unexpected IRQ polling can mask IRQ");
> -       flush_workqueue(system_highpri_wq);
> +       flush_workqueue(wdev->bh_wq);
>         start = ktime_get();
>         for (;;) {
>                 wfx_control_reg_read(wdev, &reg);
> diff --git a/drivers/net/wireless/silabs/wfx/hif_tx.c b/drivers/net/wireless/silabs/wfx/hif_tx.c
> index 9c653d0e9034..d35dd940d968 100644
> --- a/drivers/net/wireless/silabs/wfx/hif_tx.c
> +++ b/drivers/net/wireless/silabs/wfx/hif_tx.c
> @@ -73,7 +73,7 @@ int wfx_cmd_send(struct wfx_dev *wdev, struct wfx_hif_msg *request,
> 
>         if (no_reply) {
>                 /* Chip won't reply. Ensure the wq has send the buffer before to continue. */
> -               flush_workqueue(system_highpri_wq);
> +               flush_workqueue(wdev->bh_wq);
>                 ret = 0;
>                 goto end;
>         }
> diff --git a/drivers/net/wireless/silabs/wfx/main.c b/drivers/net/wireless/silabs/wfx/main.c
> index e575a81ca2ca..e015bfb8d221 100644
> --- a/drivers/net/wireless/silabs/wfx/main.c
> +++ b/drivers/net/wireless/silabs/wfx/main.c
> @@ -345,6 +345,10 @@ int wfx_probe(struct wfx_dev *wdev)
>         wdev->pdata.gpio_wakeup = NULL;
>         wdev->poll_irq = true;
> 
> +       wdev->bh_wq = alloc_workqueue("wfx_bh_wq", WQ_HIGHPRI, 0);
> +       if (!wdev->bh_wq)
> +               return -ENOMEM;
> +
>         wfx_bh_register(wdev);
> 
>         err = wfx_init_device(wdev);
> @@ -458,6 +462,7 @@ int wfx_probe(struct wfx_dev *wdev)
>         wdev->hwbus_ops->irq_unsubscribe(wdev->hwbus_priv);
>  bh_unregister:
>         wfx_bh_unregister(wdev);
> +       destroy_workqueue(wdev->bh_wq);
>         return err;
>  }
> 
> @@ -467,6 +472,7 @@ void wfx_release(struct wfx_dev *wdev)
>         wfx_hif_shutdown(wdev);
>         wdev->hwbus_ops->irq_unsubscribe(wdev->hwbus_priv);
>         wfx_bh_unregister(wdev);
> +       destroy_workqueue(wdev->bh_wq);
>  }
> 
>  static int __init wfx_core_init(void)
> diff --git a/drivers/net/wireless/silabs/wfx/wfx.h b/drivers/net/wireless/silabs/wfx/wfx.h
> index 6594cc647c2f..6f5e95dae21f 100644
> --- a/drivers/net/wireless/silabs/wfx/wfx.h
> +++ b/drivers/net/wireless/silabs/wfx/wfx.h
> @@ -57,6 +57,7 @@ struct wfx_dev {
>         struct mutex               rx_stats_lock;
>         struct wfx_hif_tx_power_loop_info tx_power_loop_info;
>         struct mutex               tx_power_loop_info_lock;
> +       struct workqueue_struct    *bh_wq;
>  };
> 
>  struct wfx_vif {
> --
> 2.34.1
> 
> 
> 

It's right for me.

Signed-off-by: Jérôme Pouiller <jerome.pouiller@silabs.com>

-- 
Jérôme Pouiller



  reply	other threads:[~2022-05-02  8:39 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-25 11:23 [PATCH 00/10] staging: wfx: usual maintenance Jerome Pouiller
2022-02-25 11:23 ` [PATCH 01/10] staging: wfx: sta.o was linked twice Jerome Pouiller
2022-02-25 11:23 ` [PATCH 02/10] staging: wfx: fix struct alignment Jerome Pouiller
2022-02-25 11:23 ` [PATCH 03/10] staging: wfx: format comments on 100 columns Jerome Pouiller
2022-03-01  1:12   ` Joe Perches
2022-03-01 17:13     ` Jeff Johnson
2022-02-25 11:23 ` [PATCH 04/10] staging: wfx: format code " Jerome Pouiller
2022-02-25 11:24 ` [PATCH 05/10] staging: wfx: remove useless variable Jerome Pouiller
2022-02-25 11:24 ` [PATCH 06/10] staging: wfx: drop useless include Jerome Pouiller
2022-02-25 11:24 ` [PATCH 07/10] staging: wfx: remove duplicated code in wfx_cmd_send() Jerome Pouiller
2022-02-25 11:24 ` [PATCH 08/10] staging: wfx: prefer to wait for an event instead to sleep Jerome Pouiller
2022-02-25 11:24 ` [PATCH 09/10] staging: wfx: ensure HIF request has been sent before polling Jerome Pouiller
2022-04-12 13:11   ` Tetsuo Handa
2022-04-13 15:18     ` Jérôme Pouiller
2022-05-01  6:01       ` [PATCH] wfx: avoid flush_workqueue(system_highpri_wq) usage Tetsuo Handa
2022-05-01  8:53         ` Kalle Valo
2022-05-01 10:23           ` Tetsuo Handa
2022-05-02  6:25             ` Kalle Valo
2022-05-02  8:16               ` [PATCH v2] " Tetsuo Handa
2022-05-02  8:38                 ` Jérôme Pouiller [this message]
2022-05-02  9:02                   ` Kalle Valo
2022-05-04  5:29                 ` [v2] " Kalle Valo
2022-05-02  8:48           ` [PATCH] " Jérôme Pouiller
2022-02-25 11:24 ` [PATCH 10/10] staging: wfx: flags for SPI IRQ were ignored Jerome Pouiller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3828648.MHq7AAxBmi@pc-42 \
    --to=jerome.pouiller@silabs.com \
    --cc=kvalo@kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=penguin-kernel@i-love.sakura.ne.jp \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).