linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1 1/5] carl9170: replace GFP_ATOMIC in ampdu_action, it can sleep
@ 2022-03-02 19:51 Christian Lamparter
  2022-03-02 19:51 ` [PATCH v1 2/5] carl9170: devres-ing hwrng_register usage Christian Lamparter
  2022-03-10 15:55 ` [PATCH v1 1/5] carl9170: replace GFP_ATOMIC in ampdu_action, it can sleep Kalle Valo
  0 siblings, 2 replies; 6+ messages in thread
From: Christian Lamparter @ 2022-03-02 19:51 UTC (permalink / raw)
  To: linux-wireless; +Cc: Kalle Valo

Since ~2010, the driver is allowed to sleep in the ampdu_action
callback thanks to:
commit 85ad181ea788 ("mac80211: allow drivers to sleep in ampdu_action")

Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
---
 drivers/net/wireless/ath/carl9170/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/wireless/ath/carl9170/main.c b/drivers/net/wireless/ath/carl9170/main.c
index 2208ec800482..f6974aff0c59 100644
--- a/drivers/net/wireless/ath/carl9170/main.c
+++ b/drivers/net/wireless/ath/carl9170/main.c
@@ -1412,7 +1412,7 @@ static int carl9170_op_ampdu_action(struct ieee80211_hw *hw,
 			return -EOPNOTSUPP;
 
 		tid_info = kzalloc(sizeof(struct carl9170_sta_tid),
-				   GFP_ATOMIC);
+				   GFP_KERNEL);
 		if (!tid_info)
 			return -ENOMEM;
 
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v1 2/5] carl9170: devres-ing hwrng_register usage
  2022-03-02 19:51 [PATCH v1 1/5] carl9170: replace GFP_ATOMIC in ampdu_action, it can sleep Christian Lamparter
@ 2022-03-02 19:51 ` Christian Lamparter
  2022-03-02 19:51   ` [PATCH v1 3/5] carl9170: devres-ing input_allocate_device Christian Lamparter
  2022-03-10 15:55 ` [PATCH v1 1/5] carl9170: replace GFP_ATOMIC in ampdu_action, it can sleep Kalle Valo
  1 sibling, 1 reply; 6+ messages in thread
From: Christian Lamparter @ 2022-03-02 19:51 UTC (permalink / raw)
  To: linux-wireless; +Cc: Kalle Valo

devres will take care of freeing the hwrng once it is no longer needed.

Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
---
 drivers/net/wireless/ath/carl9170/carl9170.h |  1 -
 drivers/net/wireless/ath/carl9170/main.c     | 29 ++------------------
 2 files changed, 3 insertions(+), 27 deletions(-)

diff --git a/drivers/net/wireless/ath/carl9170/carl9170.h b/drivers/net/wireless/ath/carl9170/carl9170.h
index 84a8ce0784b1..ba29b4aebe9f 100644
--- a/drivers/net/wireless/ath/carl9170/carl9170.h
+++ b/drivers/net/wireless/ath/carl9170/carl9170.h
@@ -458,7 +458,6 @@ struct ar9170 {
 # define CARL9170_HWRNG_CACHE_SIZE	CARL9170_MAX_CMD_PAYLOAD_LEN
 	struct {
 		struct hwrng rng;
-		bool initialized;
 		char name[30 + 1];
 		u16 cache[CARL9170_HWRNG_CACHE_SIZE / sizeof(u16)];
 		unsigned int cache_idx;
diff --git a/drivers/net/wireless/ath/carl9170/main.c b/drivers/net/wireless/ath/carl9170/main.c
index f6974aff0c59..9495b3da1978 100644
--- a/drivers/net/wireless/ath/carl9170/main.c
+++ b/drivers/net/wireless/ath/carl9170/main.c
@@ -1539,7 +1539,7 @@ static int carl9170_rng_get(struct ar9170 *ar)
 
 	BUILD_BUG_ON(RB > CARL9170_MAX_CMD_PAYLOAD_LEN);
 
-	if (!IS_ACCEPTING_CMD(ar) || !ar->rng.initialized)
+	if (!IS_ACCEPTING_CMD(ar))
 		return -EAGAIN;
 
 	count = ARRAY_SIZE(ar->rng.cache);
@@ -1585,14 +1585,6 @@ static int carl9170_rng_read(struct hwrng *rng, u32 *data)
 	return sizeof(u16);
 }
 
-static void carl9170_unregister_hwrng(struct ar9170 *ar)
-{
-	if (ar->rng.initialized) {
-		hwrng_unregister(&ar->rng.rng);
-		ar->rng.initialized = false;
-	}
-}
-
 static int carl9170_register_hwrng(struct ar9170 *ar)
 {
 	int err;
@@ -1603,25 +1595,14 @@ static int carl9170_register_hwrng(struct ar9170 *ar)
 	ar->rng.rng.data_read = carl9170_rng_read;
 	ar->rng.rng.priv = (unsigned long)ar;
 
-	if (WARN_ON(ar->rng.initialized))
-		return -EALREADY;
-
-	err = hwrng_register(&ar->rng.rng);
+	err = devm_hwrng_register(&ar->udev->dev, &ar->rng.rng);
 	if (err) {
 		dev_err(&ar->udev->dev, "Failed to register the random "
 			"number generator (%d)\n", err);
 		return err;
 	}
 
-	ar->rng.initialized = true;
-
-	err = carl9170_rng_get(ar);
-	if (err) {
-		carl9170_unregister_hwrng(ar);
-		return err;
-	}
-
-	return 0;
+	return carl9170_rng_get(ar);
 }
 #endif /* CONFIG_CARL9170_HWRNG */
 
@@ -2064,10 +2045,6 @@ void carl9170_unregister(struct ar9170 *ar)
 	}
 #endif /* CONFIG_CARL9170_WPC */
 
-#ifdef CONFIG_CARL9170_HWRNG
-	carl9170_unregister_hwrng(ar);
-#endif /* CONFIG_CARL9170_HWRNG */
-
 	carl9170_cancel_worker(ar);
 	cancel_work_sync(&ar->restart_work);
 
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v1 3/5] carl9170: devres-ing input_allocate_device
  2022-03-02 19:51 ` [PATCH v1 2/5] carl9170: devres-ing hwrng_register usage Christian Lamparter
@ 2022-03-02 19:51   ` Christian Lamparter
  2022-03-02 19:51     ` [PATCH v1 4/5] carl9170: replace bitmap_zalloc with devm_bitmap_zalloc Christian Lamparter
  0 siblings, 1 reply; 6+ messages in thread
From: Christian Lamparter @ 2022-03-02 19:51 UTC (permalink / raw)
  To: linux-wireless; +Cc: Kalle Valo

devres will take care of freeing the input_device once
it is no longer needed.

Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
---
 drivers/net/wireless/ath/carl9170/main.c | 13 ++-----------
 1 file changed, 2 insertions(+), 11 deletions(-)

diff --git a/drivers/net/wireless/ath/carl9170/main.c b/drivers/net/wireless/ath/carl9170/main.c
index 9495b3da1978..e833052e9056 100644
--- a/drivers/net/wireless/ath/carl9170/main.c
+++ b/drivers/net/wireless/ath/carl9170/main.c
@@ -1494,7 +1494,7 @@ static int carl9170_register_wps_button(struct ar9170 *ar)
 	if (!(ar->features & CARL9170_WPS_BUTTON))
 		return 0;
 
-	input = input_allocate_device();
+	input = devm_input_allocate_device(&ar->udev->dev);
 	if (!input)
 		return -ENOMEM;
 
@@ -1512,10 +1512,8 @@ static int carl9170_register_wps_button(struct ar9170 *ar)
 	input_set_capability(input, EV_KEY, KEY_WPS_BUTTON);
 
 	err = input_register_device(input);
-	if (err) {
-		input_free_device(input);
+	if (err)
 		return err;
-	}
 
 	ar->wps.pbc = input;
 	return 0;
@@ -2038,13 +2036,6 @@ void carl9170_unregister(struct ar9170 *ar)
 	carl9170_debugfs_unregister(ar);
 #endif /* CONFIG_CARL9170_DEBUGFS */
 
-#ifdef CONFIG_CARL9170_WPC
-	if (ar->wps.pbc) {
-		input_unregister_device(ar->wps.pbc);
-		ar->wps.pbc = NULL;
-	}
-#endif /* CONFIG_CARL9170_WPC */
-
 	carl9170_cancel_worker(ar);
 	cancel_work_sync(&ar->restart_work);
 
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v1 4/5] carl9170: replace bitmap_zalloc with devm_bitmap_zalloc
  2022-03-02 19:51   ` [PATCH v1 3/5] carl9170: devres-ing input_allocate_device Christian Lamparter
@ 2022-03-02 19:51     ` Christian Lamparter
  2022-03-02 19:51       ` [PATCH v1 5/5] carl9170: devres ar->survey_info Christian Lamparter
  0 siblings, 1 reply; 6+ messages in thread
From: Christian Lamparter @ 2022-03-02 19:51 UTC (permalink / raw)
  To: linux-wireless; +Cc: Kalle Valo

the mem_bitmap is kept around for the lifetime of the
driver device. This is a perfect candidate for devm.

Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
---
 drivers/net/wireless/ath/carl9170/main.c | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)

diff --git a/drivers/net/wireless/ath/carl9170/main.c b/drivers/net/wireless/ath/carl9170/main.c
index e833052e9056..fae927ca4863 100644
--- a/drivers/net/wireless/ath/carl9170/main.c
+++ b/drivers/net/wireless/ath/carl9170/main.c
@@ -1943,11 +1943,7 @@ int carl9170_register(struct ar9170 *ar)
 	struct ath_regulatory *regulatory = &ar->common.regulatory;
 	int err = 0, i;
 
-	if (WARN_ON(ar->mem_bitmap))
-		return -EINVAL;
-
-	ar->mem_bitmap = bitmap_zalloc(ar->fw.mem_blocks, GFP_KERNEL);
-
+	ar->mem_bitmap = devm_bitmap_zalloc(&ar->udev->dev, ar->fw.mem_blocks, GFP_KERNEL);
 	if (!ar->mem_bitmap)
 		return -ENOMEM;
 
@@ -2050,9 +2046,6 @@ void carl9170_free(struct ar9170 *ar)
 	kfree_skb(ar->rx_failover);
 	ar->rx_failover = NULL;
 
-	bitmap_free(ar->mem_bitmap);
-	ar->mem_bitmap = NULL;
-
 	kfree(ar->survey);
 	ar->survey = NULL;
 
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v1 5/5] carl9170: devres ar->survey_info
  2022-03-02 19:51     ` [PATCH v1 4/5] carl9170: replace bitmap_zalloc with devm_bitmap_zalloc Christian Lamparter
@ 2022-03-02 19:51       ` Christian Lamparter
  0 siblings, 0 replies; 6+ messages in thread
From: Christian Lamparter @ 2022-03-02 19:51 UTC (permalink / raw)
  To: linux-wireless; +Cc: Kalle Valo

driver keeps the same survey_info struct for its lifetime around.
This is used because while firmware does help by providing accounting
information of the current channel, it doesn't keep track on the
remaining channels.

Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
---
 drivers/net/wireless/ath/carl9170/main.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/net/wireless/ath/carl9170/main.c b/drivers/net/wireless/ath/carl9170/main.c
index fae927ca4863..76e84adf57c1 100644
--- a/drivers/net/wireless/ath/carl9170/main.c
+++ b/drivers/net/wireless/ath/carl9170/main.c
@@ -1916,7 +1916,8 @@ static int carl9170_parse_eeprom(struct ar9170 *ar)
 	if (!bands)
 		return -EINVAL;
 
-	ar->survey = kcalloc(chans, sizeof(struct survey_info), GFP_KERNEL);
+	ar->survey = devm_kcalloc(&ar->udev->dev, chans,
+				  sizeof(struct survey_info), GFP_KERNEL);
 	if (!ar->survey)
 		return -ENOMEM;
 	ar->num_channels = chans;
@@ -2046,9 +2047,6 @@ void carl9170_free(struct ar9170 *ar)
 	kfree_skb(ar->rx_failover);
 	ar->rx_failover = NULL;
 
-	kfree(ar->survey);
-	ar->survey = NULL;
-
 	mutex_destroy(&ar->mutex);
 
 	ieee80211_free_hw(ar->hw);
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH v1 1/5] carl9170: replace GFP_ATOMIC in ampdu_action, it can sleep
  2022-03-02 19:51 [PATCH v1 1/5] carl9170: replace GFP_ATOMIC in ampdu_action, it can sleep Christian Lamparter
  2022-03-02 19:51 ` [PATCH v1 2/5] carl9170: devres-ing hwrng_register usage Christian Lamparter
@ 2022-03-10 15:55 ` Kalle Valo
  1 sibling, 0 replies; 6+ messages in thread
From: Kalle Valo @ 2022-03-10 15:55 UTC (permalink / raw)
  To: Christian Lamparter; +Cc: linux-wireless

Christian Lamparter <chunkeey@gmail.com> wrote:

> Since ~2010, the driver is allowed to sleep in the ampdu_action
> callback thanks to:
> commit 85ad181ea788 ("mac80211: allow drivers to sleep in ampdu_action")
> 
> Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
> Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>

5 patches applied to ath-next branch of ath.git, thanks.

e42fe43a216c carl9170: replace GFP_ATOMIC in ampdu_action, it can sleep
23de0fa0d2a0 carl9170: devres-ing hwrng_register usage
87ddb2fc29f1 carl9170: devres-ing input_allocate_device
a8da65f901fa carl9170: replace bitmap_zalloc with devm_bitmap_zalloc
83fe43abdacf carl9170: devres ar->survey_info

-- 
https://patchwork.kernel.org/project/linux-wireless/patch/0036538d0933626a1a5eb2c2c3935cf173028926.1646250537.git.chunkeey@gmail.com/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-03-10 15:55 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-02 19:51 [PATCH v1 1/5] carl9170: replace GFP_ATOMIC in ampdu_action, it can sleep Christian Lamparter
2022-03-02 19:51 ` [PATCH v1 2/5] carl9170: devres-ing hwrng_register usage Christian Lamparter
2022-03-02 19:51   ` [PATCH v1 3/5] carl9170: devres-ing input_allocate_device Christian Lamparter
2022-03-02 19:51     ` [PATCH v1 4/5] carl9170: replace bitmap_zalloc with devm_bitmap_zalloc Christian Lamparter
2022-03-02 19:51       ` [PATCH v1 5/5] carl9170: devres ar->survey_info Christian Lamparter
2022-03-10 15:55 ` [PATCH v1 1/5] carl9170: replace GFP_ATOMIC in ampdu_action, it can sleep Kalle Valo

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).