linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] wcn36xx: allocate skbs with GFP_KERNEL during init
@ 2018-03-19  6:30 Daniel Mack
  2018-03-29 18:04 ` Daniel Mack
  2018-04-10 15:00 ` Kalle Valo
  0 siblings, 2 replies; 4+ messages in thread
From: Daniel Mack @ 2018-03-19  6:30 UTC (permalink / raw)
  To: linux-wireless; +Cc: wcn36xx, kvalo, rfried, bjorn.andersson, Daniel Mack

GFP_ATOMIC should only be used when the allocation is done from atomic
context. Introduce a new flag to wcn36xx_dxe_fill_skb() and use GFP_KERNEL
when pre-allocating buffers during init.

This doesn't fix an issue that was observed in the wild, but it reduces
the chance of failed allocations under memory pressure.

Signed-off-by: Daniel Mack <daniel@zonque.org>
---
 drivers/net/wireless/ath/wcn36xx/dxe.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/net/wireless/ath/wcn36xx/dxe.c b/drivers/net/wireless/ath/wcn36xx/dxe.c
index 5672154948c3..3e180828fbfa 100644
--- a/drivers/net/wireless/ath/wcn36xx/dxe.c
+++ b/drivers/net/wireless/ath/wcn36xx/dxe.c
@@ -275,12 +275,14 @@ static int wcn36xx_dxe_enable_ch_int(struct wcn36xx *wcn, u16 wcn_ch)
 	return 0;
 }
 
-static int wcn36xx_dxe_fill_skb(struct device *dev, struct wcn36xx_dxe_ctl *ctl)
+static int wcn36xx_dxe_fill_skb(struct device *dev,
+				struct wcn36xx_dxe_ctl *ctl,
+				gfp_t gfp)
 {
 	struct wcn36xx_dxe_desc *dxe = ctl->desc;
 	struct sk_buff *skb;
 
-	skb = alloc_skb(WCN36XX_PKT_SIZE, GFP_ATOMIC);
+	skb = alloc_skb(WCN36XX_PKT_SIZE, gfp);
 	if (skb == NULL)
 		return -ENOMEM;
 
@@ -307,7 +309,7 @@ static int wcn36xx_dxe_ch_alloc_skb(struct wcn36xx *wcn,
 	cur_ctl = wcn_ch->head_blk_ctl;
 
 	for (i = 0; i < wcn_ch->desc_num; i++) {
-		wcn36xx_dxe_fill_skb(wcn->dev, cur_ctl);
+		wcn36xx_dxe_fill_skb(wcn->dev, cur_ctl, GFP_KERNEL);
 		cur_ctl = cur_ctl->next;
 	}
 
@@ -533,7 +535,7 @@ static int wcn36xx_rx_handle_packets(struct wcn36xx *wcn,
 	while (!(dxe->ctrl & WCN36XX_DXE_CTRL_VALID_MASK)) {
 		skb = ctl->skb;
 		dma_addr = dxe->dst_addr_l;
-		ret = wcn36xx_dxe_fill_skb(wcn->dev, ctl);
+		ret = wcn36xx_dxe_fill_skb(wcn->dev, ctl, GFP_ATOMIC);
 		if (0 == ret) {
 			/* new skb allocation ok. Use the new one and queue
 			 * the old one to network system.
-- 
2.14.3

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

* Re: [PATCH] wcn36xx: allocate skbs with GFP_KERNEL during init
  2018-03-19  6:30 [PATCH] wcn36xx: allocate skbs with GFP_KERNEL during init Daniel Mack
@ 2018-03-29 18:04 ` Daniel Mack
  2018-04-03  9:58   ` Kalle Valo
  2018-04-10 15:00 ` Kalle Valo
  1 sibling, 1 reply; 4+ messages in thread
From: Daniel Mack @ 2018-03-29 18:04 UTC (permalink / raw)
  To: linux-wireless; +Cc: wcn36xx, rfried, kvalo, bjorn.andersson

On Monday, March 19, 2018 07:30 AM, Daniel Mack wrote:
> GFP_ATOMIC should only be used when the allocation is done from atomic
> context. Introduce a new flag to wcn36xx_dxe_fill_skb() and use GFP_KERNEL
> when pre-allocating buffers during init.
> 
> This doesn't fix an issue that was observed in the wild, but it reduces
> the chance of failed allocations under memory pressure.
> 
> Signed-off-by: Daniel Mack <daniel@zonque.org>

Any opinion about this one?


Thanks,
Daniel

> ---
>  drivers/net/wireless/ath/wcn36xx/dxe.c | 10 ++++++----
>  1 file changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/net/wireless/ath/wcn36xx/dxe.c b/drivers/net/wireless/ath/wcn36xx/dxe.c
> index 5672154948c3..3e180828fbfa 100644
> --- a/drivers/net/wireless/ath/wcn36xx/dxe.c
> +++ b/drivers/net/wireless/ath/wcn36xx/dxe.c
> @@ -275,12 +275,14 @@ static int wcn36xx_dxe_enable_ch_int(struct wcn36xx *wcn, u16 wcn_ch)
>  	return 0;
>  }
>  
> -static int wcn36xx_dxe_fill_skb(struct device *dev, struct wcn36xx_dxe_ctl *ctl)
> +static int wcn36xx_dxe_fill_skb(struct device *dev,
> +				struct wcn36xx_dxe_ctl *ctl,
> +				gfp_t gfp)
>  {
>  	struct wcn36xx_dxe_desc *dxe = ctl->desc;
>  	struct sk_buff *skb;
>  
> -	skb = alloc_skb(WCN36XX_PKT_SIZE, GFP_ATOMIC);
> +	skb = alloc_skb(WCN36XX_PKT_SIZE, gfp);
>  	if (skb == NULL)
>  		return -ENOMEM;
>  
> @@ -307,7 +309,7 @@ static int wcn36xx_dxe_ch_alloc_skb(struct wcn36xx *wcn,
>  	cur_ctl = wcn_ch->head_blk_ctl;
>  
>  	for (i = 0; i < wcn_ch->desc_num; i++) {
> -		wcn36xx_dxe_fill_skb(wcn->dev, cur_ctl);
> +		wcn36xx_dxe_fill_skb(wcn->dev, cur_ctl, GFP_KERNEL);
>  		cur_ctl = cur_ctl->next;
>  	}
>  
> @@ -533,7 +535,7 @@ static int wcn36xx_rx_handle_packets(struct wcn36xx *wcn,
>  	while (!(dxe->ctrl & WCN36XX_DXE_CTRL_VALID_MASK)) {
>  		skb = ctl->skb;
>  		dma_addr = dxe->dst_addr_l;
> -		ret = wcn36xx_dxe_fill_skb(wcn->dev, ctl);
> +		ret = wcn36xx_dxe_fill_skb(wcn->dev, ctl, GFP_ATOMIC);
>  		if (0 == ret) {
>  			/* new skb allocation ok. Use the new one and queue
>  			 * the old one to network system.
> 

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

* Re: [PATCH] wcn36xx: allocate skbs with GFP_KERNEL during init
  2018-03-29 18:04 ` Daniel Mack
@ 2018-04-03  9:58   ` Kalle Valo
  0 siblings, 0 replies; 4+ messages in thread
From: Kalle Valo @ 2018-04-03  9:58 UTC (permalink / raw)
  To: Daniel Mack; +Cc: linux-wireless, wcn36xx, rfried, bjorn.andersson

Daniel Mack <daniel@zonque.org> writes:

> On Monday, March 19, 2018 07:30 AM, Daniel Mack wrote:
>> GFP_ATOMIC should only be used when the allocation is done from atomic
>> context. Introduce a new flag to wcn36xx_dxe_fill_skb() and use GFP_KERNEL
>> when pre-allocating buffers during init.
>> 
>> This doesn't fix an issue that was observed in the wild, but it reduces
>> the chance of failed allocations under memory pressure.
>> 
>> Signed-off-by: Daniel Mack <daniel@zonque.org>
>
> Any opinion about this one?

It's better that you check the state from patchwork, less mail to the
maintainers:

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

-- 
Kalle Valo

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

* Re: wcn36xx: allocate skbs with GFP_KERNEL during init
  2018-03-19  6:30 [PATCH] wcn36xx: allocate skbs with GFP_KERNEL during init Daniel Mack
  2018-03-29 18:04 ` Daniel Mack
@ 2018-04-10 15:00 ` Kalle Valo
  1 sibling, 0 replies; 4+ messages in thread
From: Kalle Valo @ 2018-04-10 15:00 UTC (permalink / raw)
  To: Daniel Mack; +Cc: linux-wireless, wcn36xx, rfried, bjorn.andersson, Daniel Mack

Daniel Mack <daniel@zonque.org> wrote:

> GFP_ATOMIC should only be used when the allocation is done from atomic
> context. Introduce a new flag to wcn36xx_dxe_fill_skb() and use GFP_KERNEL
> when pre-allocating buffers during init.
> 
> This doesn't fix an issue that was observed in the wild, but it reduces
> the chance of failed allocations under memory pressure.
> 
> Signed-off-by: Daniel Mack <daniel@zonque.org>
> Signed-off-by: Kalle Valo <kvalo@codeaurora.org>

Patch applied to ath-next branch of ath.git, thanks.

5151a673da43 wcn36xx: allocate skbs with GFP_KERNEL during init

-- 
https://patchwork.kernel.org/patch/10291685/

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

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

end of thread, other threads:[~2018-04-10 15:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-03-19  6:30 [PATCH] wcn36xx: allocate skbs with GFP_KERNEL during init Daniel Mack
2018-03-29 18:04 ` Daniel Mack
2018-04-03  9:58   ` Kalle Valo
2018-04-10 15:00 ` 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).