* [PATCH v3 1/2] mwifiex: initiate card-specific work atomically
@ 2017-05-01 19:36 Brian Norris
2017-05-01 19:37 ` [PATCH v3 2/2] mwifiex: pcie: add card_reset() support Brian Norris
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Brian Norris @ 2017-05-01 19:36 UTC (permalink / raw)
To: Ganapathi Bhat, Nishant Sarmukadam
Cc: linux-kernel, Dmitry Torokhov, Kalle Valo, linux-wireless, Brian Norris
The non-atomic test + set is a little awkward here, and it technically
means we might double-schedule work unnecessarily. AFAICT, this is not
really a problem, since the extra "work" will be a no-op (the flag(s)
will be cleared by then), but it's still an anti-pattern.
Rewrite this to use the atomic test_and_set_bit() helper instead.
Signed-off-by: Brian Norris <briannorris@chromium.org>
---
v3: fix bisectability (unused code warning) -- some code from patch 2
crept in here
v2: new
---
drivers/net/wireless/marvell/mwifiex/pcie.c | 9 +++------
drivers/net/wireless/marvell/mwifiex/sdio.c | 16 +++++-----------
2 files changed, 8 insertions(+), 17 deletions(-)
diff --git a/drivers/net/wireless/marvell/mwifiex/pcie.c b/drivers/net/wireless/marvell/mwifiex/pcie.c
index ac62bce50e96..5f56e8e6d612 100644
--- a/drivers/net/wireless/marvell/mwifiex/pcie.c
+++ b/drivers/net/wireless/marvell/mwifiex/pcie.c
@@ -2837,12 +2837,9 @@ static void mwifiex_pcie_device_dump(struct mwifiex_adapter *adapter)
{
struct pcie_service_card *card = adapter->card;
- if (test_bit(MWIFIEX_IFACE_WORK_DEVICE_DUMP, &card->work_flags))
- return;
-
- set_bit(MWIFIEX_IFACE_WORK_DEVICE_DUMP, &card->work_flags);
-
- schedule_work(&card->work);
+ if (!test_and_set_bit(MWIFIEX_IFACE_WORK_DEVICE_DUMP,
+ &card->work_flags))
+ schedule_work(&card->work);
}
static void mwifiex_pcie_free_buffers(struct mwifiex_adapter *adapter)
diff --git a/drivers/net/wireless/marvell/mwifiex/sdio.c b/drivers/net/wireless/marvell/mwifiex/sdio.c
index 0af1c6733c92..d38d31bb9b79 100644
--- a/drivers/net/wireless/marvell/mwifiex/sdio.c
+++ b/drivers/net/wireless/marvell/mwifiex/sdio.c
@@ -2533,12 +2533,8 @@ static void mwifiex_sdio_card_reset(struct mwifiex_adapter *adapter)
{
struct sdio_mmc_card *card = adapter->card;
- if (test_bit(MWIFIEX_IFACE_WORK_CARD_RESET, &card->work_flags))
- return;
-
- set_bit(MWIFIEX_IFACE_WORK_CARD_RESET, &card->work_flags);
-
- schedule_work(&card->work);
+ if (!test_and_set_bit(MWIFIEX_IFACE_WORK_CARD_RESET, &card->work_flags))
+ schedule_work(&card->work);
}
/* This function dumps FW information */
@@ -2546,11 +2542,9 @@ static void mwifiex_sdio_device_dump(struct mwifiex_adapter *adapter)
{
struct sdio_mmc_card *card = adapter->card;
- if (test_bit(MWIFIEX_IFACE_WORK_DEVICE_DUMP, &card->work_flags))
- return;
-
- set_bit(MWIFIEX_IFACE_WORK_DEVICE_DUMP, &card->work_flags);
- schedule_work(&card->work);
+ if (!test_and_set_bit(MWIFIEX_IFACE_WORK_DEVICE_DUMP,
+ &card->work_flags))
+ schedule_work(&card->work);
}
/* Function to dump SDIO function registers and SDIO scratch registers in case
--
2.13.0.rc0.306.g87b477812d-goog
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v3 2/2] mwifiex: pcie: add card_reset() support
2017-05-01 19:36 [PATCH v3 1/2] mwifiex: initiate card-specific work atomically Brian Norris
@ 2017-05-01 19:37 ` Brian Norris
2017-05-01 19:38 ` Dmitry Torokhov
2017-05-01 19:38 ` [PATCH v3 1/2] mwifiex: initiate card-specific work atomically Dmitry Torokhov
2017-05-18 13:40 ` [v3,1/2] " Kalle Valo
2 siblings, 1 reply; 5+ messages in thread
From: Brian Norris @ 2017-05-01 19:37 UTC (permalink / raw)
To: Ganapathi Bhat, Nishant Sarmukadam
Cc: linux-kernel, Dmitry Torokhov, Kalle Valo, linux-wireless, Brian Norris
Similar to the SDIO driver, we should implement this so that we will
automatically reset the device whenever there's a command timeout or
similar.
Signed-off-by: Brian Norris <briannorris@chromium.org>
---
v3: keep all the new reset code in patch 2, not patch 1
v2: use atomic test/set, based on Dmitry's suggestion
---
drivers/net/wireless/marvell/mwifiex/pcie.c | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/drivers/net/wireless/marvell/mwifiex/pcie.c b/drivers/net/wireless/marvell/mwifiex/pcie.c
index 5f56e8e6d612..78688ff6ecd0 100644
--- a/drivers/net/wireless/marvell/mwifiex/pcie.c
+++ b/drivers/net/wireless/marvell/mwifiex/pcie.c
@@ -2822,6 +2822,13 @@ static void mwifiex_pcie_device_dump_work(struct mwifiex_adapter *adapter)
mwifiex_upload_device_dump(adapter, drv_info, drv_info_size);
}
+static void mwifiex_pcie_card_reset_work(struct mwifiex_adapter *adapter)
+{
+ struct pcie_service_card *card = adapter->card;
+
+ pci_reset_function(card->dev);
+}
+
static void mwifiex_pcie_work(struct work_struct *work)
{
struct pcie_service_card *card =
@@ -2830,6 +2837,9 @@ static void mwifiex_pcie_work(struct work_struct *work)
if (test_and_clear_bit(MWIFIEX_IFACE_WORK_DEVICE_DUMP,
&card->work_flags))
mwifiex_pcie_device_dump_work(card->adapter);
+ if (test_and_clear_bit(MWIFIEX_IFACE_WORK_CARD_RESET,
+ &card->work_flags))
+ mwifiex_pcie_card_reset_work(card->adapter);
}
/* This function dumps FW information */
@@ -2842,6 +2852,14 @@ static void mwifiex_pcie_device_dump(struct mwifiex_adapter *adapter)
schedule_work(&card->work);
}
+static void mwifiex_pcie_card_reset(struct mwifiex_adapter *adapter)
+{
+ struct pcie_service_card *card = adapter->card;
+
+ if (!test_and_set_bit(MWIFIEX_IFACE_WORK_CARD_RESET, &card->work_flags))
+ schedule_work(&card->work);
+}
+
static void mwifiex_pcie_free_buffers(struct mwifiex_adapter *adapter)
{
struct pcie_service_card *card = adapter->card;
@@ -3271,6 +3289,7 @@ static struct mwifiex_if_ops pcie_ops = {
.cleanup_mpa_buf = NULL,
.init_fw_port = mwifiex_pcie_init_fw_port,
.clean_pcie_ring = mwifiex_clean_pcie_ring_buf,
+ .card_reset = mwifiex_pcie_card_reset,
.reg_dump = mwifiex_pcie_reg_dump,
.device_dump = mwifiex_pcie_device_dump,
.down_dev = mwifiex_pcie_down_dev,
--
2.13.0.rc0.306.g87b477812d-goog
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v3 2/2] mwifiex: pcie: add card_reset() support
2017-05-01 19:37 ` [PATCH v3 2/2] mwifiex: pcie: add card_reset() support Brian Norris
@ 2017-05-01 19:38 ` Dmitry Torokhov
0 siblings, 0 replies; 5+ messages in thread
From: Dmitry Torokhov @ 2017-05-01 19:38 UTC (permalink / raw)
To: Brian Norris
Cc: Ganapathi Bhat, Nishant Sarmukadam, linux-kernel, Kalle Valo,
linux-wireless
On Mon, May 01, 2017 at 12:37:00PM -0700, Brian Norris wrote:
> Similar to the SDIO driver, we should implement this so that we will
> automatically reset the device whenever there's a command timeout or
> similar.
>
> Signed-off-by: Brian Norris <briannorris@chromium.org>
Reviewed-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> ---
> v3: keep all the new reset code in patch 2, not patch 1
>
> v2: use atomic test/set, based on Dmitry's suggestion
> ---
> drivers/net/wireless/marvell/mwifiex/pcie.c | 19 +++++++++++++++++++
> 1 file changed, 19 insertions(+)
>
> diff --git a/drivers/net/wireless/marvell/mwifiex/pcie.c b/drivers/net/wireless/marvell/mwifiex/pcie.c
> index 5f56e8e6d612..78688ff6ecd0 100644
> --- a/drivers/net/wireless/marvell/mwifiex/pcie.c
> +++ b/drivers/net/wireless/marvell/mwifiex/pcie.c
> @@ -2822,6 +2822,13 @@ static void mwifiex_pcie_device_dump_work(struct mwifiex_adapter *adapter)
> mwifiex_upload_device_dump(adapter, drv_info, drv_info_size);
> }
>
> +static void mwifiex_pcie_card_reset_work(struct mwifiex_adapter *adapter)
> +{
> + struct pcie_service_card *card = adapter->card;
> +
> + pci_reset_function(card->dev);
> +}
> +
> static void mwifiex_pcie_work(struct work_struct *work)
> {
> struct pcie_service_card *card =
> @@ -2830,6 +2837,9 @@ static void mwifiex_pcie_work(struct work_struct *work)
> if (test_and_clear_bit(MWIFIEX_IFACE_WORK_DEVICE_DUMP,
> &card->work_flags))
> mwifiex_pcie_device_dump_work(card->adapter);
> + if (test_and_clear_bit(MWIFIEX_IFACE_WORK_CARD_RESET,
> + &card->work_flags))
> + mwifiex_pcie_card_reset_work(card->adapter);
> }
>
> /* This function dumps FW information */
> @@ -2842,6 +2852,14 @@ static void mwifiex_pcie_device_dump(struct mwifiex_adapter *adapter)
> schedule_work(&card->work);
> }
>
> +static void mwifiex_pcie_card_reset(struct mwifiex_adapter *adapter)
> +{
> + struct pcie_service_card *card = adapter->card;
> +
> + if (!test_and_set_bit(MWIFIEX_IFACE_WORK_CARD_RESET, &card->work_flags))
> + schedule_work(&card->work);
> +}
> +
> static void mwifiex_pcie_free_buffers(struct mwifiex_adapter *adapter)
> {
> struct pcie_service_card *card = adapter->card;
> @@ -3271,6 +3289,7 @@ static struct mwifiex_if_ops pcie_ops = {
> .cleanup_mpa_buf = NULL,
> .init_fw_port = mwifiex_pcie_init_fw_port,
> .clean_pcie_ring = mwifiex_clean_pcie_ring_buf,
> + .card_reset = mwifiex_pcie_card_reset,
> .reg_dump = mwifiex_pcie_reg_dump,
> .device_dump = mwifiex_pcie_device_dump,
> .down_dev = mwifiex_pcie_down_dev,
> --
> 2.13.0.rc0.306.g87b477812d-goog
>
--
Dmitry
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v3 1/2] mwifiex: initiate card-specific work atomically
2017-05-01 19:36 [PATCH v3 1/2] mwifiex: initiate card-specific work atomically Brian Norris
2017-05-01 19:37 ` [PATCH v3 2/2] mwifiex: pcie: add card_reset() support Brian Norris
@ 2017-05-01 19:38 ` Dmitry Torokhov
2017-05-18 13:40 ` [v3,1/2] " Kalle Valo
2 siblings, 0 replies; 5+ messages in thread
From: Dmitry Torokhov @ 2017-05-01 19:38 UTC (permalink / raw)
To: Brian Norris
Cc: Ganapathi Bhat, Nishant Sarmukadam, linux-kernel, Kalle Valo,
linux-wireless
On Mon, May 01, 2017 at 12:36:59PM -0700, Brian Norris wrote:
> The non-atomic test + set is a little awkward here, and it technically
> means we might double-schedule work unnecessarily. AFAICT, this is not
> really a problem, since the extra "work" will be a no-op (the flag(s)
> will be cleared by then), but it's still an anti-pattern.
>
> Rewrite this to use the atomic test_and_set_bit() helper instead.
>
> Signed-off-by: Brian Norris <briannorris@chromium.org>
Reviewed-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> ---
> v3: fix bisectability (unused code warning) -- some code from patch 2
> crept in here
>
> v2: new
> ---
> drivers/net/wireless/marvell/mwifiex/pcie.c | 9 +++------
> drivers/net/wireless/marvell/mwifiex/sdio.c | 16 +++++-----------
> 2 files changed, 8 insertions(+), 17 deletions(-)
>
> diff --git a/drivers/net/wireless/marvell/mwifiex/pcie.c b/drivers/net/wireless/marvell/mwifiex/pcie.c
> index ac62bce50e96..5f56e8e6d612 100644
> --- a/drivers/net/wireless/marvell/mwifiex/pcie.c
> +++ b/drivers/net/wireless/marvell/mwifiex/pcie.c
> @@ -2837,12 +2837,9 @@ static void mwifiex_pcie_device_dump(struct mwifiex_adapter *adapter)
> {
> struct pcie_service_card *card = adapter->card;
>
> - if (test_bit(MWIFIEX_IFACE_WORK_DEVICE_DUMP, &card->work_flags))
> - return;
> -
> - set_bit(MWIFIEX_IFACE_WORK_DEVICE_DUMP, &card->work_flags);
> -
> - schedule_work(&card->work);
> + if (!test_and_set_bit(MWIFIEX_IFACE_WORK_DEVICE_DUMP,
> + &card->work_flags))
> + schedule_work(&card->work);
> }
>
> static void mwifiex_pcie_free_buffers(struct mwifiex_adapter *adapter)
> diff --git a/drivers/net/wireless/marvell/mwifiex/sdio.c b/drivers/net/wireless/marvell/mwifiex/sdio.c
> index 0af1c6733c92..d38d31bb9b79 100644
> --- a/drivers/net/wireless/marvell/mwifiex/sdio.c
> +++ b/drivers/net/wireless/marvell/mwifiex/sdio.c
> @@ -2533,12 +2533,8 @@ static void mwifiex_sdio_card_reset(struct mwifiex_adapter *adapter)
> {
> struct sdio_mmc_card *card = adapter->card;
>
> - if (test_bit(MWIFIEX_IFACE_WORK_CARD_RESET, &card->work_flags))
> - return;
> -
> - set_bit(MWIFIEX_IFACE_WORK_CARD_RESET, &card->work_flags);
> -
> - schedule_work(&card->work);
> + if (!test_and_set_bit(MWIFIEX_IFACE_WORK_CARD_RESET, &card->work_flags))
> + schedule_work(&card->work);
> }
>
> /* This function dumps FW information */
> @@ -2546,11 +2542,9 @@ static void mwifiex_sdio_device_dump(struct mwifiex_adapter *adapter)
> {
> struct sdio_mmc_card *card = adapter->card;
>
> - if (test_bit(MWIFIEX_IFACE_WORK_DEVICE_DUMP, &card->work_flags))
> - return;
> -
> - set_bit(MWIFIEX_IFACE_WORK_DEVICE_DUMP, &card->work_flags);
> - schedule_work(&card->work);
> + if (!test_and_set_bit(MWIFIEX_IFACE_WORK_DEVICE_DUMP,
> + &card->work_flags))
> + schedule_work(&card->work);
> }
>
> /* Function to dump SDIO function registers and SDIO scratch registers in case
> --
> 2.13.0.rc0.306.g87b477812d-goog
>
--
Dmitry
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [v3,1/2] mwifiex: initiate card-specific work atomically
2017-05-01 19:36 [PATCH v3 1/2] mwifiex: initiate card-specific work atomically Brian Norris
2017-05-01 19:37 ` [PATCH v3 2/2] mwifiex: pcie: add card_reset() support Brian Norris
2017-05-01 19:38 ` [PATCH v3 1/2] mwifiex: initiate card-specific work atomically Dmitry Torokhov
@ 2017-05-18 13:40 ` Kalle Valo
2 siblings, 0 replies; 5+ messages in thread
From: Kalle Valo @ 2017-05-18 13:40 UTC (permalink / raw)
To: Brian Norris
Cc: Ganapathi Bhat, Nishant Sarmukadam, linux-kernel,
Dmitry Torokhov, linux-wireless, Brian Norris
Brian Norris <briannorris@chromium.org> wrote:
> The non-atomic test + set is a little awkward here, and it technically
> means we might double-schedule work unnecessarily. AFAICT, this is not
> really a problem, since the extra "work" will be a no-op (the flag(s)
> will be cleared by then), but it's still an anti-pattern.
>
> Rewrite this to use the atomic test_and_set_bit() helper instead.
>
> Signed-off-by: Brian Norris <briannorris@chromium.org>
> Reviewed-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
2 patches applied to wireless-drivers-next.git, thanks.
21f569af9ab3 mwifiex: initiate card-specific work atomically
6d7d579a8243 mwifiex: pcie: add card_reset() support
--
https://patchwork.kernel.org/patch/9706851/
https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2017-05-18 13:40 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-01 19:36 [PATCH v3 1/2] mwifiex: initiate card-specific work atomically Brian Norris
2017-05-01 19:37 ` [PATCH v3 2/2] mwifiex: pcie: add card_reset() support Brian Norris
2017-05-01 19:38 ` Dmitry Torokhov
2017-05-01 19:38 ` [PATCH v3 1/2] mwifiex: initiate card-specific work atomically Dmitry Torokhov
2017-05-18 13:40 ` [v3,1/2] " Kalle Valo
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.