diff mbox series

[net-next,v3] net: wwan: t7xx: fix GFP_KERNEL usage in spin_lock context

Message ID 20220519074351.829774-1-william.xuanziyang@huawei.com (mailing list archive)
State Not Applicable
Delegated to: Netdev Maintainers
Headers show
Series [net-next,v3] net: wwan: t7xx: fix GFP_KERNEL usage in spin_lock context | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix success Link
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers fail 1 blamed authors not CCed: ilpo.jarvinen@linux.intel.com; 4 maintainers not CCed: ilpo.jarvinen@linux.intel.com linux-arm-kernel@lists.infradead.org matthias.bgg@gmail.com linux-mediatek@lists.infradead.org
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 20 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Ziyang Xuan (William) May 19, 2022, 7:43 a.m. UTC
t7xx_cldma_clear_rxq() call t7xx_cldma_alloc_and_map_skb() in spin_lock
context, But __dev_alloc_skb() in t7xx_cldma_alloc_and_map_skb() uses
GFP_KERNEL, that will introduce scheduling factor in spin_lock context.

Because t7xx_cldma_clear_rxq() is called after stopping CLDMA, so we can
remove the spin_lock from t7xx_cldma_clear_rxq().

Fixes: 39d439047f1d ("net: wwan: t7xx: Add control DMA interface")
Suggested-by: Ricardo Martinez <ricardo.martinez@linux.intel.com>
Signed-off-by: Ziyang Xuan <william.xuanziyang@huawei.com>
---
 drivers/net/wwan/t7xx/t7xx_hif_cldma.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
---
v3:
  - Add Suggested-by and simplify comments
v2:
  - Remove spin_lock instead of using GFP_ATOMIC

Comments

Loic Poulain May 19, 2022, 7:29 a.m. UTC | #1
On Thu, 19 May 2022 at 09:26, Ziyang Xuan <william.xuanziyang@huawei.com> wrote:
>
> t7xx_cldma_clear_rxq() call t7xx_cldma_alloc_and_map_skb() in spin_lock
> context, But __dev_alloc_skb() in t7xx_cldma_alloc_and_map_skb() uses
> GFP_KERNEL, that will introduce scheduling factor in spin_lock context.
>
> Because t7xx_cldma_clear_rxq() is called after stopping CLDMA, so we can
> remove the spin_lock from t7xx_cldma_clear_rxq().
>
> Fixes: 39d439047f1d ("net: wwan: t7xx: Add control DMA interface")
> Suggested-by: Ricardo Martinez <ricardo.martinez@linux.intel.com>
> Signed-off-by: Ziyang Xuan <william.xuanziyang@huawei.com>

Reviewed-by: Loic Poulain <loic.poulain@linaro.org>

> ---
>  drivers/net/wwan/t7xx/t7xx_hif_cldma.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> ---
> v3:
>   - Add Suggested-by and simplify comments
> v2:
>   - Remove spin_lock instead of using GFP_ATOMIC
>
> diff --git a/drivers/net/wwan/t7xx/t7xx_hif_cldma.c b/drivers/net/wwan/t7xx/t7xx_hif_cldma.c
> index 46066dcd2607..3a46a5bea24f 100644
> --- a/drivers/net/wwan/t7xx/t7xx_hif_cldma.c
> +++ b/drivers/net/wwan/t7xx/t7xx_hif_cldma.c
> @@ -782,10 +782,11 @@ static int t7xx_cldma_clear_rxq(struct cldma_ctrl *md_ctrl, int qnum)
>         struct cldma_queue *rxq = &md_ctrl->rxq[qnum];
>         struct cldma_request *req;
>         struct cldma_gpd *gpd;
> -       unsigned long flags;
>         int ret = 0;
>
> -       spin_lock_irqsave(&rxq->ring_lock, flags);
> +       /* CLDMA has been stopped. There is not any CLDMA IRQ, holding
> +        * ring_lock is not needed.
> +        */
>         t7xx_cldma_q_reset(rxq);
>         list_for_each_entry(req, &rxq->tr_ring->gpd_ring, entry) {
>                 gpd = req->gpd;
> @@ -808,7 +809,6 @@ static int t7xx_cldma_clear_rxq(struct cldma_ctrl *md_ctrl, int qnum)
>
>                 t7xx_cldma_gpd_set_data_ptr(req->gpd, req->mapped_buff);
>         }
> -       spin_unlock_irqrestore(&rxq->ring_lock, flags);
>
>         return ret;
>  }
> --
> 2.25.1
>
Jakub Kicinski May 21, 2022, 12:25 a.m. UTC | #2
On Thu, 19 May 2022 09:29:12 +0200 Loic Poulain wrote:
> On Thu, 19 May 2022 at 09:26, Ziyang Xuan <william.xuanziyang@huawei.com> wrote:
> >
> > t7xx_cldma_clear_rxq() call t7xx_cldma_alloc_and_map_skb() in spin_lock
> > context, But __dev_alloc_skb() in t7xx_cldma_alloc_and_map_skb() uses
> > GFP_KERNEL, that will introduce scheduling factor in spin_lock context.
> >
> > Because t7xx_cldma_clear_rxq() is called after stopping CLDMA, so we can
> > remove the spin_lock from t7xx_cldma_clear_rxq().
> >
> > Fixes: 39d439047f1d ("net: wwan: t7xx: Add control DMA interface")
> > Suggested-by: Ricardo Martinez <ricardo.martinez@linux.intel.com>
> > Signed-off-by: Ziyang Xuan <william.xuanziyang@huawei.com>  
> 
> Reviewed-by: Loic Poulain <loic.poulain@linaro.org>

Wait, you reviewed two different fixes for the same issue?
Please say something when that happens I thought both are needed :/
Jakub Kicinski May 21, 2022, 1:01 a.m. UTC | #3
On Fri, 20 May 2022 17:25:56 -0700 Jakub Kicinski wrote:
> On Thu, 19 May 2022 09:29:12 +0200 Loic Poulain wrote:
> > On Thu, 19 May 2022 at 09:26, Ziyang Xuan <william.xuanziyang@huawei.com> wrote:  
> > >
> > > t7xx_cldma_clear_rxq() call t7xx_cldma_alloc_and_map_skb() in spin_lock
> > > context, But __dev_alloc_skb() in t7xx_cldma_alloc_and_map_skb() uses
> > > GFP_KERNEL, that will introduce scheduling factor in spin_lock context.
> > >
> > > Because t7xx_cldma_clear_rxq() is called after stopping CLDMA, so we can
> > > remove the spin_lock from t7xx_cldma_clear_rxq().
> > >
> > > Fixes: 39d439047f1d ("net: wwan: t7xx: Add control DMA interface")
> > > Suggested-by: Ricardo Martinez <ricardo.martinez@linux.intel.com>
> > > Signed-off-by: Ziyang Xuan <william.xuanziyang@huawei.com>    
> > 
> > Reviewed-by: Loic Poulain <loic.poulain@linaro.org>  
> 
> Wait, you reviewed two different fixes for the same issue?
> Please say something when that happens I thought both are needed :/

FWIW I pushed out the other one before I realized (they both apply
without conflicts so I thought they fixed different issues)
If this one is preferred please respin and squash a revert of
9ee152ee3ee3 into it.
Loic Poulain May 21, 2022, 5:26 p.m. UTC | #4
Le sam. 21 mai 2022 à 03:01, Jakub Kicinski <kuba@kernel.org> a écrit :
>
> On Fri, 20 May 2022 17:25:56 -0700 Jakub Kicinski wrote:
> > On Thu, 19 May 2022 09:29:12 +0200 Loic Poulain wrote:
> > > On Thu, 19 May 2022 at 09:26, Ziyang Xuan <william.xuanziyang@huawei.com> wrote:
> > > >
> > > > t7xx_cldma_clear_rxq() call t7xx_cldma_alloc_and_map_skb() in spin_lock
> > > > context, But __dev_alloc_skb() in t7xx_cldma_alloc_and_map_skb() uses
> > > > GFP_KERNEL, that will introduce scheduling factor in spin_lock context.
> > > >
> > > > Because t7xx_cldma_clear_rxq() is called after stopping CLDMA, so we can
> > > > remove the spin_lock from t7xx_cldma_clear_rxq().
> > > >
> > > > Fixes: 39d439047f1d ("net: wwan: t7xx: Add control DMA interface")
> > > > Suggested-by: Ricardo Martinez <ricardo.martinez@linux.intel.com>
> > > > Signed-off-by: Ziyang Xuan <william.xuanziyang@huawei.com>
> > >
> > > Reviewed-by: Loic Poulain <loic.poulain@linaro.org>
> >
> > Wait, you reviewed two different fixes for the same issue?
> > Please say something when that happens I thought both are needed :/


Right, I've actually overlooked that the other patch has only one
atomic user, which becomes useless with this change.

>
>
> FWIW I pushed out the other one before I realized (they both apply
> without conflicts so I thought they fixed different issues)
> If this one is preferred please respin and squash a revert of
>
>
> 9ee152ee3ee3 into it.

Yes this one is preferred, I'll respin it. Sorry for this.

Thanks,
Loic
diff mbox series

Patch

diff --git a/drivers/net/wwan/t7xx/t7xx_hif_cldma.c b/drivers/net/wwan/t7xx/t7xx_hif_cldma.c
index 46066dcd2607..3a46a5bea24f 100644
--- a/drivers/net/wwan/t7xx/t7xx_hif_cldma.c
+++ b/drivers/net/wwan/t7xx/t7xx_hif_cldma.c
@@ -782,10 +782,11 @@  static int t7xx_cldma_clear_rxq(struct cldma_ctrl *md_ctrl, int qnum)
 	struct cldma_queue *rxq = &md_ctrl->rxq[qnum];
 	struct cldma_request *req;
 	struct cldma_gpd *gpd;
-	unsigned long flags;
 	int ret = 0;
 
-	spin_lock_irqsave(&rxq->ring_lock, flags);
+	/* CLDMA has been stopped. There is not any CLDMA IRQ, holding
+	 * ring_lock is not needed.
+	 */
 	t7xx_cldma_q_reset(rxq);
 	list_for_each_entry(req, &rxq->tr_ring->gpd_ring, entry) {
 		gpd = req->gpd;
@@ -808,7 +809,6 @@  static int t7xx_cldma_clear_rxq(struct cldma_ctrl *md_ctrl, int qnum)
 
 		t7xx_cldma_gpd_set_data_ptr(req->gpd, req->mapped_buff);
 	}
-	spin_unlock_irqrestore(&rxq->ring_lock, flags);
 
 	return ret;
 }