net: gianfar: use alloc_ethdev_mqs
PATCH 1/1 net: gianfar: use alloc_ethdev_mqs
From looking at git history, mqs was introduced after mq and after this code was written. Having said that, mqs can be used as there is already an RX queue variable in place. Not only that, mqs already sets the num_xx_queues members. No need to open code this.
--- drivers/net/ethernet/freescale/gianfar.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/net/ethernet/freescale/gianfar.c +1 -5
@@ -669,7 +669,7 @@ static int gfar_of_init(struct platform_device *ofdev, struct net_device **pdev)return -EINVAL ; } - *pdev =alloc_etherdev_mq (sizeof (*priv), num_tx_qs); + *pdev =alloc_etherdev_mqs (sizeof (*priv), num_tx_qs, num_rx_qs); dev = *pdev;if (NULL == dev)return -ENOMEM ;
@@ -679,10 +679,6 @@ static int gfar_of_init(struct platform_device *ofdev, struct net_device **pdev) priv->mode = mode; - priv->num_tx_queues = num_tx_qs; -netif_set_real_num_rx_queues (dev, num_rx_qs); - priv->num_rx_queues = num_rx_qs; - err =gfar_alloc_tx_queues (priv);if (err) goto tx_alloc_failed;
Signature · 1 line
2.54.0
Quoted 24 lines · Rosen Penev
Quoted 1 line
From looking at git history, mqs was introduced after mq and after this
code was written. Having said that, mqs can be used as there is already an RX queue variable in place. Not only that, mqs already sets the
num_xx_queuesmembers. No need to open code this.Signed-off-by Rosen Penev <[email protected]>--- drivers/net/ethernet/freescale/gianfar.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)drivers/net/ethernet/freescale/gianfar.c +1
-1@@ -669,7 +669,7 @@ static int gfar_of_init(struct platform_device *ofdev, struct net_device **pdev)return -EINVAL ; } - *pdev =alloc_etherdev_mq (sizeof (*priv), num_tx_qs); + *pdev =alloc_etherdev_mqs (sizeof (*priv), num_tx_qs, num_rx_qs); dev = *pdev;if (NULL == dev)return -ENOMEM ;
drivers/net/ethernet/freescale/gianfar.c static int gfar_of_init(struct platform_device *ofdev, struct net_device **pdev) · line 684
Quoted 6 lines
drivers/net/ethernet/freescale/gianfar.c +0
-3@@ -679,10 +679,6 @@ static int gfar_of_init(struct platform_device *ofdev, struct net_device **pdev) priv->mode = mode; - priv->num_tx_queues = num_tx_qs; -netif_set_real_num_rx_queues (dev, num_rx_qs); - priv->num_rx_queues = num_rx_qs;
Please add to the commit message an explanation of why these two assignments can be removed, because it is not obvious.
Andrew
---
pw-bot: cr
Quoted 27 lines · Andrew Lunn
Quoted 25 lines · Rosen Penev
Quoted 1 line
From looking at git history, mqs was introduced after mq and after this
code was written. Having said that, mqs can be used as there is already an RX queue variable in place. Not only that, mqs already sets the
num_xx_queuesmembers. No need to open code this.Signed-off-by Rosen Penev <[email protected]>--- drivers/net/ethernet/freescale/gianfar.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)drivers/net/ethernet/freescale/gianfar.c +1
-1@@ -669,7 +669,7 @@ static int gfar_of_init(struct platform_device *ofdev, struct net_device **pdev)return -EINVAL ; } - *pdev =alloc_etherdev_mq (sizeof (*priv), num_tx_qs); + *pdev =alloc_etherdev_mqs (sizeof (*priv), num_tx_qs, num_rx_qs); dev = *pdev;if (NULL == dev)return -ENOMEM ;@@ -679,10 +679,6 @@ static int gfar_of_init(struct platform_device *ofdev, struct net_device **pdev)
Quoted 8 lines
drivers/net/ethernet/freescale/gianfar.c static int gfar_of_init(struct platform_device *ofdev, struct net_device **pdev) · line 684
Quoted 5 lines
drivers/net/ethernet/freescale/gianfar.c +0
-3priv->mode = mode; - priv->num_tx_queues = num_tx_qs; -netif_set_real_num_rx_queues (dev, num_rx_qs); - priv->num_rx_queues = num_rx_qs;Please add to the commit message an explanation of why these two assignments can be removed, because it is not obvious.
I didn't explain that _mqs sets them?
Quoted 5 lines
Andrew
---
pw-bot: cr
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
drivers/net/ethernet/freescale/gianfar.c +1
-0+ *pdev =alloc_etherdev_mqs (sizeof (*priv), num_tx_qs, num_rx_qs); dev = *pdev;if (NULL == dev)return -ENOMEM ;@@ -679,10 +679,6 @@ static int gfar_of_init(struct platform_device *ofdev, struct net_device **pdev) priv->mode = mode;
Quoted 7 lines
Quoted 6 lines
drivers/net/ethernet/freescale/gianfar.c static int gfar_of_init(struct platform_device *ofdev, struct net_device **pdev) · line 684
Quoted 3 lines
drivers/net/ethernet/freescale/gianfar.c +0
-3- priv->num_tx_queues = num_tx_qs; -netif_set_real_num_rx_queues (dev, num_rx_qs); - priv->num_rx_queues = num_rx_qs;Please add to the commit message an explanation of why these two assignments can be removed, because it is not obvious.
I didn't explain that
_mqssets them?
How can alloc_etherdev_mqs() set them? priv is opaque to the core. All the core knows is the size of struct gfar_private, but nothing about its layout, where num_tx_queues and num_rx_queues are within priv.
Andrew
Quoted 15 lines · Andrew Lunn
Quoted 15 lines
Quoted 15 lines
drivers/net/ethernet/freescale/gianfar.c static int gfar_of_init(struct platform_device *ofdev, struct net_device **pdev) · line 684
Quoted 12 lines
drivers/net/ethernet/freescale/gianfar.c +1
-3+ *pdev =alloc_etherdev_mqs (sizeof (*priv), num_tx_qs, num_rx_qs); dev = *pdev;if (NULL == dev)return -ENOMEM ;@@ -679,10 +679,6 @@ static int gfar_of_init(struct platform_device *ofdev, struct net_device **pdev) priv->mode = mode; - priv->num_tx_queues = num_tx_qs; -netif_set_real_num_rx_queues (dev, num_rx_qs); - priv->num_rx_queues = num_rx_qs;Please add to the commit message an explanation of why these two assignments can be removed, because it is not obvious.
Quoted 5 lines
Quoted 1 line
I didn't explain that
_mqssets them?How can
alloc_etherdev_mqs()set them? priv is opaque to the core. All the core knows is the size of structgfar_private, but nothing about its layout, wherenum_tx_queuesandnum_rx_queuesare within priv.
I see what you mean. Will respin this.
Quoted 2 lines
Andrew
Quoted 1 line
I see what you mean. Will respin this.
This is why the netdev FAQ says:
Netdev discourages patches which perform simple clean-ups, which are not in the context of other work.
...
This is because it is felt that the churn that such changes produce comes at a greater cost than the value of such clean-ups.
Does changing alloc_netdev_mq() to alloc_netdev_mqs() bring enough gain to offset the work needed to find the new bugs added at the same time?
I know i would prefer looking at patches adding new drivers, new infrastructure, new features, than broken cleanups for very old drivers with very few users.
Andrew