netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net v3 0/3] net: rswitch: Fix issues in rswitch_start_xmit()
@ 2023-11-22  5:11 Yoshihiro Shimoda
  2023-11-22  5:11 ` [PATCH net v3 1/3] net: rswitch: Fix type of ret " Yoshihiro Shimoda
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Yoshihiro Shimoda @ 2023-11-22  5:11 UTC (permalink / raw)
  To: s.shtylyov, davem, edumazet, kuba, pabeni
  Cc: netdev, linux-renesas-soc, Yoshihiro Shimoda

This patch series is based on the latest net.git / main branch.

Changes from v2:
https://lore.kernel.org/all/20231122012556.3645840-1-yoshihiro.shimoda.uh@renesas.com/
- Keep reverse christmas tree of local variable declarations in patch 1/3.

Changes from v1:
https://lore.kernel.org/all/20231121055255.3627949-1-yoshihiro.shimoda.uh@renesas.com/
- Separate a patch because fixing 2 issues.
- Add fixing wrong type of return value.
- Use goto for improving code readability.

Yoshihiro Shimoda (3):
  net: rswitch: Fix type of ret in rswitch_start_xmit()
  net: rswitch: Fix return value in rswitch_start_xmit()
  net: rswitch: Fix missing dev_kfree_skb_any() in error path

 drivers/net/ethernet/renesas/rswitch.c | 22 +++++++++++++---------
 1 file changed, 13 insertions(+), 9 deletions(-)

-- 
2.25.1


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

* [PATCH net v3 1/3] net: rswitch: Fix type of ret in rswitch_start_xmit()
  2023-11-22  5:11 [PATCH net v3 0/3] net: rswitch: Fix issues in rswitch_start_xmit() Yoshihiro Shimoda
@ 2023-11-22  5:11 ` Yoshihiro Shimoda
  2023-11-22 10:04   ` Wojciech Drewek
  2023-11-22  5:11 ` [PATCH net v3 2/3] net: rswitch: Fix return value " Yoshihiro Shimoda
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 8+ messages in thread
From: Yoshihiro Shimoda @ 2023-11-22  5:11 UTC (permalink / raw)
  To: s.shtylyov, davem, edumazet, kuba, pabeni
  Cc: netdev, linux-renesas-soc, Yoshihiro Shimoda

The type of ret in rswitch_start_xmit() should be netdev_tx_t. So,
fix it.

Fixes: 3590918b5d07 ("net: ethernet: renesas: Add support for "Ethernet Switch"")
Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
---
 drivers/net/ethernet/renesas/rswitch.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/renesas/rswitch.c b/drivers/net/ethernet/renesas/rswitch.c
index 43a7795d6591..d53d90020904 100644
--- a/drivers/net/ethernet/renesas/rswitch.c
+++ b/drivers/net/ethernet/renesas/rswitch.c
@@ -1504,8 +1504,8 @@ static netdev_tx_t rswitch_start_xmit(struct sk_buff *skb, struct net_device *nd
 {
 	struct rswitch_device *rdev = netdev_priv(ndev);
 	struct rswitch_gwca_queue *gq = rdev->tx_queue;
+	netdev_tx_t ret = NETDEV_TX_OK;
 	struct rswitch_ext_desc *desc;
-	int ret = NETDEV_TX_OK;
 	dma_addr_t dma_addr;
 
 	if (rswitch_get_num_cur_queues(gq) >= gq->ring_size - 1) {
-- 
2.25.1


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

* [PATCH net v3 2/3] net: rswitch: Fix return value in rswitch_start_xmit()
  2023-11-22  5:11 [PATCH net v3 0/3] net: rswitch: Fix issues in rswitch_start_xmit() Yoshihiro Shimoda
  2023-11-22  5:11 ` [PATCH net v3 1/3] net: rswitch: Fix type of ret " Yoshihiro Shimoda
@ 2023-11-22  5:11 ` Yoshihiro Shimoda
  2023-11-22 10:13   ` Wojciech Drewek
  2023-11-22  5:11 ` [PATCH net v3 3/3] net: rswitch: Fix missing dev_kfree_skb_any() in error path Yoshihiro Shimoda
  2023-11-24  2:00 ` [PATCH net v3 0/3] net: rswitch: Fix issues in rswitch_start_xmit() patchwork-bot+netdevbpf
  3 siblings, 1 reply; 8+ messages in thread
From: Yoshihiro Shimoda @ 2023-11-22  5:11 UTC (permalink / raw)
  To: s.shtylyov, davem, edumazet, kuba, pabeni
  Cc: netdev, linux-renesas-soc, Yoshihiro Shimoda

This .ndo_start_xmit() function should return netdev_tx_t value,
not -ENOMEM. So, fix it.

Fixes: 33f5d733b589 ("net: renesas: rswitch: Improve TX timestamp accuracy")
Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
---
 drivers/net/ethernet/renesas/rswitch.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/renesas/rswitch.c b/drivers/net/ethernet/renesas/rswitch.c
index d53d90020904..45bf9808c143 100644
--- a/drivers/net/ethernet/renesas/rswitch.c
+++ b/drivers/net/ethernet/renesas/rswitch.c
@@ -1535,7 +1535,7 @@ static netdev_tx_t rswitch_start_xmit(struct sk_buff *skb, struct net_device *nd
 		ts_info = kzalloc(sizeof(*ts_info), GFP_ATOMIC);
 		if (!ts_info) {
 			dma_unmap_single(ndev->dev.parent, dma_addr, skb->len, DMA_TO_DEVICE);
-			return -ENOMEM;
+			return ret;
 		}
 
 		skb_shinfo(skb)->tx_flags |= SKBTX_IN_PROGRESS;
-- 
2.25.1


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

* [PATCH net v3 3/3] net: rswitch: Fix missing dev_kfree_skb_any() in error path
  2023-11-22  5:11 [PATCH net v3 0/3] net: rswitch: Fix issues in rswitch_start_xmit() Yoshihiro Shimoda
  2023-11-22  5:11 ` [PATCH net v3 1/3] net: rswitch: Fix type of ret " Yoshihiro Shimoda
  2023-11-22  5:11 ` [PATCH net v3 2/3] net: rswitch: Fix return value " Yoshihiro Shimoda
@ 2023-11-22  5:11 ` Yoshihiro Shimoda
  2023-11-22 10:17   ` Wojciech Drewek
  2023-11-24  2:00 ` [PATCH net v3 0/3] net: rswitch: Fix issues in rswitch_start_xmit() patchwork-bot+netdevbpf
  3 siblings, 1 reply; 8+ messages in thread
From: Yoshihiro Shimoda @ 2023-11-22  5:11 UTC (permalink / raw)
  To: s.shtylyov, davem, edumazet, kuba, pabeni
  Cc: netdev, linux-renesas-soc, Yoshihiro Shimoda

Before returning the rswitch_start_xmit() in the error path,
dev_kfree_skb_any() should be called. So, fix it.

Fixes: 33f5d733b589 ("net: renesas: rswitch: Improve TX timestamp accuracy")
Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
---
 drivers/net/ethernet/renesas/rswitch.c | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/drivers/net/ethernet/renesas/rswitch.c b/drivers/net/ethernet/renesas/rswitch.c
index 45bf9808c143..e77c6ff93d81 100644
--- a/drivers/net/ethernet/renesas/rswitch.c
+++ b/drivers/net/ethernet/renesas/rswitch.c
@@ -1517,10 +1517,8 @@ static netdev_tx_t rswitch_start_xmit(struct sk_buff *skb, struct net_device *nd
 		return ret;
 
 	dma_addr = dma_map_single(ndev->dev.parent, skb->data, skb->len, DMA_TO_DEVICE);
-	if (dma_mapping_error(ndev->dev.parent, dma_addr)) {
-		dev_kfree_skb_any(skb);
-		return ret;
-	}
+	if (dma_mapping_error(ndev->dev.parent, dma_addr))
+		goto err_kfree;
 
 	gq->skbs[gq->cur] = skb;
 	desc = &gq->tx_ring[gq->cur];
@@ -1533,10 +1531,8 @@ static netdev_tx_t rswitch_start_xmit(struct sk_buff *skb, struct net_device *nd
 		struct rswitch_gwca_ts_info *ts_info;
 
 		ts_info = kzalloc(sizeof(*ts_info), GFP_ATOMIC);
-		if (!ts_info) {
-			dma_unmap_single(ndev->dev.parent, dma_addr, skb->len, DMA_TO_DEVICE);
-			return ret;
-		}
+		if (!ts_info)
+			goto err_unmap;
 
 		skb_shinfo(skb)->tx_flags |= SKBTX_IN_PROGRESS;
 		rdev->ts_tag++;
@@ -1558,6 +1554,14 @@ static netdev_tx_t rswitch_start_xmit(struct sk_buff *skb, struct net_device *nd
 	gq->cur = rswitch_next_queue_index(gq, true, 1);
 	rswitch_modify(rdev->addr, GWTRC(gq->index), 0, BIT(gq->index % 32));
 
+	return ret;
+
+err_unmap:
+	dma_unmap_single(ndev->dev.parent, dma_addr, skb->len, DMA_TO_DEVICE);
+
+err_kfree:
+	dev_kfree_skb_any(skb);
+
 	return ret;
 }
 
-- 
2.25.1


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

* Re: [PATCH net v3 1/3] net: rswitch: Fix type of ret in rswitch_start_xmit()
  2023-11-22  5:11 ` [PATCH net v3 1/3] net: rswitch: Fix type of ret " Yoshihiro Shimoda
@ 2023-11-22 10:04   ` Wojciech Drewek
  0 siblings, 0 replies; 8+ messages in thread
From: Wojciech Drewek @ 2023-11-22 10:04 UTC (permalink / raw)
  To: Yoshihiro Shimoda, s.shtylyov, davem, edumazet, kuba, pabeni
  Cc: netdev, linux-renesas-soc



On 22.11.2023 06:11, Yoshihiro Shimoda wrote:
> The type of ret in rswitch_start_xmit() should be netdev_tx_t. So,
> fix it.
> 
> Fixes: 3590918b5d07 ("net: ethernet: renesas: Add support for "Ethernet Switch"")
> Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
> ---

Hi,
Thanks for your patches!
Reviewed-by: Wojciech Drewek <wojciech.drewek@intel.com>

>  drivers/net/ethernet/renesas/rswitch.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/renesas/rswitch.c b/drivers/net/ethernet/renesas/rswitch.c
> index 43a7795d6591..d53d90020904 100644
> --- a/drivers/net/ethernet/renesas/rswitch.c
> +++ b/drivers/net/ethernet/renesas/rswitch.c
> @@ -1504,8 +1504,8 @@ static netdev_tx_t rswitch_start_xmit(struct sk_buff *skb, struct net_device *nd
>  {
>  	struct rswitch_device *rdev = netdev_priv(ndev);
>  	struct rswitch_gwca_queue *gq = rdev->tx_queue;
> +	netdev_tx_t ret = NETDEV_TX_OK;
>  	struct rswitch_ext_desc *desc;
> -	int ret = NETDEV_TX_OK;
>  	dma_addr_t dma_addr;
>  
>  	if (rswitch_get_num_cur_queues(gq) >= gq->ring_size - 1) {

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

* Re: [PATCH net v3 2/3] net: rswitch: Fix return value in rswitch_start_xmit()
  2023-11-22  5:11 ` [PATCH net v3 2/3] net: rswitch: Fix return value " Yoshihiro Shimoda
@ 2023-11-22 10:13   ` Wojciech Drewek
  0 siblings, 0 replies; 8+ messages in thread
From: Wojciech Drewek @ 2023-11-22 10:13 UTC (permalink / raw)
  To: Yoshihiro Shimoda, s.shtylyov, davem, edumazet, kuba, pabeni
  Cc: netdev, linux-renesas-soc



On 22.11.2023 06:11, Yoshihiro Shimoda wrote:
> This .ndo_start_xmit() function should return netdev_tx_t value,
> not -ENOMEM. So, fix it.
> 
> Fixes: 33f5d733b589 ("net: renesas: rswitch: Improve TX timestamp accuracy")
> Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
> ---

Reviewed-by: Wojciech Drewek <wojciech.drewek@intel.com>

>  drivers/net/ethernet/renesas/rswitch.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/renesas/rswitch.c b/drivers/net/ethernet/renesas/rswitch.c
> index d53d90020904..45bf9808c143 100644
> --- a/drivers/net/ethernet/renesas/rswitch.c
> +++ b/drivers/net/ethernet/renesas/rswitch.c
> @@ -1535,7 +1535,7 @@ static netdev_tx_t rswitch_start_xmit(struct sk_buff *skb, struct net_device *nd
>  		ts_info = kzalloc(sizeof(*ts_info), GFP_ATOMIC);
>  		if (!ts_info) {
>  			dma_unmap_single(ndev->dev.parent, dma_addr, skb->len, DMA_TO_DEVICE);
> -			return -ENOMEM;
> +			return ret;
>  		}
>  
>  		skb_shinfo(skb)->tx_flags |= SKBTX_IN_PROGRESS;

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

* Re: [PATCH net v3 3/3] net: rswitch: Fix missing dev_kfree_skb_any() in error path
  2023-11-22  5:11 ` [PATCH net v3 3/3] net: rswitch: Fix missing dev_kfree_skb_any() in error path Yoshihiro Shimoda
@ 2023-11-22 10:17   ` Wojciech Drewek
  0 siblings, 0 replies; 8+ messages in thread
From: Wojciech Drewek @ 2023-11-22 10:17 UTC (permalink / raw)
  To: Yoshihiro Shimoda, s.shtylyov, davem, edumazet, kuba, pabeni
  Cc: netdev, linux-renesas-soc



On 22.11.2023 06:11, Yoshihiro Shimoda wrote:
> Before returning the rswitch_start_xmit() in the error path,
> dev_kfree_skb_any() should be called. So, fix it.
> 
> Fixes: 33f5d733b589 ("net: renesas: rswitch: Improve TX timestamp accuracy")
> Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
> ---

Nice cleanup
Reviewed-by: Wojciech Drewek <wojciech.drewek@intel.com>

>  drivers/net/ethernet/renesas/rswitch.c | 20 ++++++++++++--------
>  1 file changed, 12 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/net/ethernet/renesas/rswitch.c b/drivers/net/ethernet/renesas/rswitch.c
> index 45bf9808c143..e77c6ff93d81 100644
> --- a/drivers/net/ethernet/renesas/rswitch.c
> +++ b/drivers/net/ethernet/renesas/rswitch.c
> @@ -1517,10 +1517,8 @@ static netdev_tx_t rswitch_start_xmit(struct sk_buff *skb, struct net_device *nd
>  		return ret;
>  
>  	dma_addr = dma_map_single(ndev->dev.parent, skb->data, skb->len, DMA_TO_DEVICE);
> -	if (dma_mapping_error(ndev->dev.parent, dma_addr)) {
> -		dev_kfree_skb_any(skb);
> -		return ret;
> -	}
> +	if (dma_mapping_error(ndev->dev.parent, dma_addr))
> +		goto err_kfree;
>  
>  	gq->skbs[gq->cur] = skb;
>  	desc = &gq->tx_ring[gq->cur];
> @@ -1533,10 +1531,8 @@ static netdev_tx_t rswitch_start_xmit(struct sk_buff *skb, struct net_device *nd
>  		struct rswitch_gwca_ts_info *ts_info;
>  
>  		ts_info = kzalloc(sizeof(*ts_info), GFP_ATOMIC);
> -		if (!ts_info) {
> -			dma_unmap_single(ndev->dev.parent, dma_addr, skb->len, DMA_TO_DEVICE);
> -			return ret;
> -		}
> +		if (!ts_info)
> +			goto err_unmap;
>  
>  		skb_shinfo(skb)->tx_flags |= SKBTX_IN_PROGRESS;
>  		rdev->ts_tag++;
> @@ -1558,6 +1554,14 @@ static netdev_tx_t rswitch_start_xmit(struct sk_buff *skb, struct net_device *nd
>  	gq->cur = rswitch_next_queue_index(gq, true, 1);
>  	rswitch_modify(rdev->addr, GWTRC(gq->index), 0, BIT(gq->index % 32));
>  
> +	return ret;
> +
> +err_unmap:
> +	dma_unmap_single(ndev->dev.parent, dma_addr, skb->len, DMA_TO_DEVICE);
> +
> +err_kfree:
> +	dev_kfree_skb_any(skb);
> +
>  	return ret;
>  }
>  

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

* Re: [PATCH net v3 0/3] net: rswitch: Fix issues in rswitch_start_xmit()
  2023-11-22  5:11 [PATCH net v3 0/3] net: rswitch: Fix issues in rswitch_start_xmit() Yoshihiro Shimoda
                   ` (2 preceding siblings ...)
  2023-11-22  5:11 ` [PATCH net v3 3/3] net: rswitch: Fix missing dev_kfree_skb_any() in error path Yoshihiro Shimoda
@ 2023-11-24  2:00 ` patchwork-bot+netdevbpf
  3 siblings, 0 replies; 8+ messages in thread
From: patchwork-bot+netdevbpf @ 2023-11-24  2:00 UTC (permalink / raw)
  To: Yoshihiro Shimoda
  Cc: s.shtylyov, davem, edumazet, kuba, pabeni, netdev, linux-renesas-soc

Hello:

This series was applied to netdev/net.git (main)
by David S. Miller <davem@davemloft.net>:

On Wed, 22 Nov 2023 14:11:40 +0900 you wrote:
> This patch series is based on the latest net.git / main branch.
> 
> Changes from v2:
> https://lore.kernel.org/all/20231122012556.3645840-1-yoshihiro.shimoda.uh@renesas.com/
> - Keep reverse christmas tree of local variable declarations in patch 1/3.
> 
> Changes from v1:
> https://lore.kernel.org/all/20231121055255.3627949-1-yoshihiro.shimoda.uh@renesas.com/
> - Separate a patch because fixing 2 issues.
> - Add fixing wrong type of return value.
> - Use goto for improving code readability.
> 
> [...]

Here is the summary with links:
  - [net,v3,1/3] net: rswitch: Fix type of ret in rswitch_start_xmit()
    https://git.kernel.org/netdev/net/c/109b25d13e00
  - [net,v3,2/3] net: rswitch: Fix return value in rswitch_start_xmit()
    https://git.kernel.org/netdev/net/c/1aaef8634a20
  - [net,v3,3/3] net: rswitch: Fix missing dev_kfree_skb_any() in error path
    https://git.kernel.org/netdev/net/c/782486af9b5b

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

end of thread, other threads:[~2023-11-24  2:00 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-22  5:11 [PATCH net v3 0/3] net: rswitch: Fix issues in rswitch_start_xmit() Yoshihiro Shimoda
2023-11-22  5:11 ` [PATCH net v3 1/3] net: rswitch: Fix type of ret " Yoshihiro Shimoda
2023-11-22 10:04   ` Wojciech Drewek
2023-11-22  5:11 ` [PATCH net v3 2/3] net: rswitch: Fix return value " Yoshihiro Shimoda
2023-11-22 10:13   ` Wojciech Drewek
2023-11-22  5:11 ` [PATCH net v3 3/3] net: rswitch: Fix missing dev_kfree_skb_any() in error path Yoshihiro Shimoda
2023-11-22 10:17   ` Wojciech Drewek
2023-11-24  2:00 ` [PATCH net v3 0/3] net: rswitch: Fix issues in rswitch_start_xmit() patchwork-bot+netdevbpf

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