netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 0/8] net: ethernet: marvell: Assorted fixes
@ 2014-05-22 23:06 Ezequiel Garcia
  2014-05-22 23:06 ` [PATCH v3 1/8] net: mv643xx_eth: Simplify mv643xx_eth_adjust_link() Ezequiel Garcia
                   ` (8 more replies)
  0 siblings, 9 replies; 11+ messages in thread
From: Ezequiel Garcia @ 2014-05-22 23:06 UTC (permalink / raw)
  To: netdev, David Miller
  Cc: Thomas Petazzoni, Sebastian Hesselbarth, Gregory Clement,
	Lior Amsalem, Tawfik Bayouk, Andrew Lunn, Ezequiel Garcia

New round for this assorted fixes and clean-up series. There is more room for
clean-ups, and I'll start preparing more patches once these are accepted.

This series consists of cleanups and minor improvements on mvneta, mv643xx_eth
and mvmdio drivers. None of the patches imply any functionality change, except
for the patch six "Change the number of default rx queues to one".

This patch reduces the driver's allocated resources and makes the multiqueue
path in the poll function not get taken. The previous patchset contains more
details:

  http://permalink.gmane.org/gmane.linux.network/315015

As usual, any feedback on this will be well received!

Changes from v2:

  * Rebased on today's net-next and dropped patch 
    "net: mvneta: Factorize feature setting", merged in the recent
    TSO series.

  * As per Sergei suggestion, used devm_kcalloc or devm_kmalloc_array
    when suitable.

Changes from v1:

  * Added two more clean-up patches to the series.

  * Added Sebastian's Acked-by's.

  * Fixed extra empty line in "net: mv643xx_eth: Simplify
    mv643xx_eth_adjust_link()" as pointed out by David Miller.

Ezequiel Garcia (8):
  net: mv643xx_eth: Simplify mv643xx_eth_adjust_link()
  net: mvneta: Clean-up mvneta_tx_frag_process()
  net: mvneta: Check tx queue setup error in mvneta_change_mtu()
  net: mvneta: Clean-up mvneta_init()
  net: mvneta: Use prepare/commit API to simplify MAC address setting
  net: mvneta: Change the number of default rx queues to one
  net: mvmdio: Use devm_* API to simplify the code
  net: mvneta: Remove unneeded 'weigth' field

 drivers/net/ethernet/marvell/mv643xx_eth.c | 14 ++---
 drivers/net/ethernet/marvell/mvmdio.c      | 18 ++----
 drivers/net/ethernet/marvell/mvneta.c      | 91 ++++++++++++------------------
 3 files changed, 45 insertions(+), 78 deletions(-)

-- 
1.9.1

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

* [PATCH v3 1/8] net: mv643xx_eth: Simplify mv643xx_eth_adjust_link()
  2014-05-22 23:06 [PATCH v3 0/8] net: ethernet: marvell: Assorted fixes Ezequiel Garcia
@ 2014-05-22 23:06 ` Ezequiel Garcia
  2014-05-22 23:06 ` [PATCH v3 2/8] net: mvneta: Clean-up mvneta_tx_frag_process() Ezequiel Garcia
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 11+ messages in thread
From: Ezequiel Garcia @ 2014-05-22 23:06 UTC (permalink / raw)
  To: netdev, David Miller
  Cc: Thomas Petazzoni, Sebastian Hesselbarth, Gregory Clement,
	Lior Amsalem, Tawfik Bayouk, Andrew Lunn, Ezequiel Garcia

Currently, mv643xx_eth_adjust_link() is only used to call mv643xx_adjust_pscr().
This commit renames the latter to the former, and therefore removes the extra
and useless function.

Acked-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
---
 drivers/net/ethernet/marvell/mv643xx_eth.c | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)

diff --git a/drivers/net/ethernet/marvell/mv643xx_eth.c b/drivers/net/ethernet/marvell/mv643xx_eth.c
index 3b0f818..c68ff5d 100644
--- a/drivers/net/ethernet/marvell/mv643xx_eth.c
+++ b/drivers/net/ethernet/marvell/mv643xx_eth.c
@@ -1167,8 +1167,9 @@ static void txq_set_fixed_prio_mode(struct tx_queue *txq)
 
 
 /* mii management interface *************************************************/
-static void mv643xx_adjust_pscr(struct mv643xx_eth_private *mp)
+static void mv643xx_eth_adjust_link(struct net_device *dev)
 {
+	struct mv643xx_eth_private *mp = netdev_priv(dev);
 	u32 pscr = rdlp(mp, PORT_SERIAL_CONTROL);
 	u32 autoneg_disable = FORCE_LINK_PASS |
 	             DISABLE_AUTO_NEG_SPEED_GMII |
@@ -1544,7 +1545,7 @@ mv643xx_eth_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
 
 	ret = phy_ethtool_sset(mp->phy, cmd);
 	if (!ret)
-		mv643xx_adjust_pscr(mp);
+		mv643xx_eth_adjust_link(dev);
 	return ret;
 }
 
@@ -2473,7 +2474,7 @@ static int mv643xx_eth_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
 
 	ret = phy_mii_ioctl(mp->phy, ifr, cmd);
 	if (!ret)
-		mv643xx_adjust_pscr(mp);
+		mv643xx_eth_adjust_link(dev);
 	return ret;
 }
 
@@ -2871,13 +2872,6 @@ static void set_params(struct mv643xx_eth_private *mp,
 	mp->txq_count = pd->tx_queue_count ? : 1;
 }
 
-static void mv643xx_eth_adjust_link(struct net_device *dev)
-{
-	struct mv643xx_eth_private *mp = netdev_priv(dev);
-
-	mv643xx_adjust_pscr(mp);
-}
-
 static struct phy_device *phy_scan(struct mv643xx_eth_private *mp,
 				   int phy_addr)
 {
-- 
1.9.1

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

* [PATCH v3 2/8] net: mvneta: Clean-up mvneta_tx_frag_process()
  2014-05-22 23:06 [PATCH v3 0/8] net: ethernet: marvell: Assorted fixes Ezequiel Garcia
  2014-05-22 23:06 ` [PATCH v3 1/8] net: mv643xx_eth: Simplify mv643xx_eth_adjust_link() Ezequiel Garcia
@ 2014-05-22 23:06 ` Ezequiel Garcia
  2014-05-22 23:06 ` [PATCH v3 3/8] net: mvneta: Check tx queue setup error in mvneta_change_mtu() Ezequiel Garcia
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 11+ messages in thread
From: Ezequiel Garcia @ 2014-05-22 23:06 UTC (permalink / raw)
  To: netdev, David Miller
  Cc: Thomas Petazzoni, Sebastian Hesselbarth, Gregory Clement,
	Lior Amsalem, Tawfik Bayouk, Andrew Lunn, Ezequiel Garcia

A tiny clean-up to improve readability. This commit makes no functionality
change.

Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
---
 drivers/net/ethernet/marvell/mvneta.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/net/ethernet/marvell/mvneta.c b/drivers/net/ethernet/marvell/mvneta.c
index 18c698d..3034601 100644
--- a/drivers/net/ethernet/marvell/mvneta.c
+++ b/drivers/net/ethernet/marvell/mvneta.c
@@ -1654,9 +1654,9 @@ static int mvneta_tx_frag_process(struct mvneta_port *pp, struct sk_buff *skb,
 				  struct mvneta_tx_queue *txq)
 {
 	struct mvneta_tx_desc *tx_desc;
-	int i;
+	int i, nr_frags = skb_shinfo(skb)->nr_frags;
 
-	for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) {
+	for (i = 0; i < nr_frags; i++) {
 		skb_frag_t *frag = &skb_shinfo(skb)->frags[i];
 		void *addr = page_address(frag->page.p) + frag->page_offset;
 
@@ -1673,20 +1673,16 @@ static int mvneta_tx_frag_process(struct mvneta_port *pp, struct sk_buff *skb,
 			goto error;
 		}
 
-		if (i == (skb_shinfo(skb)->nr_frags - 1)) {
+		if (i == nr_frags - 1) {
 			/* Last descriptor */
 			tx_desc->command = MVNETA_TXD_L_DESC | MVNETA_TXD_Z_PAD;
-
 			txq->tx_skb[txq->txq_put_index] = skb;
-
-			mvneta_txq_inc_put(txq);
 		} else {
 			/* Descriptor in the middle: Not First, Not Last */
 			tx_desc->command = 0;
-
 			txq->tx_skb[txq->txq_put_index] = NULL;
-			mvneta_txq_inc_put(txq);
 		}
+		mvneta_txq_inc_put(txq);
 	}
 
 	return 0;
-- 
1.9.1

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

* [PATCH v3 3/8] net: mvneta: Check tx queue setup error in mvneta_change_mtu()
  2014-05-22 23:06 [PATCH v3 0/8] net: ethernet: marvell: Assorted fixes Ezequiel Garcia
  2014-05-22 23:06 ` [PATCH v3 1/8] net: mv643xx_eth: Simplify mv643xx_eth_adjust_link() Ezequiel Garcia
  2014-05-22 23:06 ` [PATCH v3 2/8] net: mvneta: Clean-up mvneta_tx_frag_process() Ezequiel Garcia
@ 2014-05-22 23:06 ` Ezequiel Garcia
  2014-05-22 23:06 ` [PATCH v3 4/8] net: mvneta: Clean-up mvneta_init() Ezequiel Garcia
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 11+ messages in thread
From: Ezequiel Garcia @ 2014-05-22 23:06 UTC (permalink / raw)
  To: netdev, David Miller
  Cc: Thomas Petazzoni, Sebastian Hesselbarth, Gregory Clement,
	Lior Amsalem, Tawfik Bayouk, Andrew Lunn, Ezequiel Garcia

This commit checks the return code of mvneta_setup_txq() call
in mvneta_change_mtu(). Also, use the netdevice pointer directly
instead of dereferencing the port structure. While here, let's
fix a tiny comment typo.

Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
---
 drivers/net/ethernet/marvell/mvneta.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/marvell/mvneta.c b/drivers/net/ethernet/marvell/mvneta.c
index 3034601..d28327d 100644
--- a/drivers/net/ethernet/marvell/mvneta.c
+++ b/drivers/net/ethernet/marvell/mvneta.c
@@ -2425,24 +2425,28 @@ static int mvneta_change_mtu(struct net_device *dev, int mtu)
 		return 0;
 
 	/* The interface is running, so we have to force a
-	 * reallocation of the RXQs
+	 * reallocation of the queues
 	 */
 	mvneta_stop_dev(pp);
 
 	mvneta_cleanup_txqs(pp);
 	mvneta_cleanup_rxqs(pp);
 
-	pp->pkt_size = MVNETA_RX_PKT_SIZE(pp->dev->mtu);
+	pp->pkt_size = MVNETA_RX_PKT_SIZE(dev->mtu);
 	pp->frag_size = SKB_DATA_ALIGN(MVNETA_RX_BUF_SIZE(pp->pkt_size)) +
 	                SKB_DATA_ALIGN(sizeof(struct skb_shared_info));
 
 	ret = mvneta_setup_rxqs(pp);
 	if (ret) {
-		netdev_err(pp->dev, "unable to setup rxqs after MTU change\n");
+		netdev_err(dev, "unable to setup rxqs after MTU change\n");
 		return ret;
 	}
 
-	mvneta_setup_txqs(pp);
+	ret = mvneta_setup_txqs(pp);
+	if (ret) {
+		netdev_err(dev, "unable to setup txqs after MTU change\n");
+		return ret;
+	}
 
 	mvneta_start_dev(pp);
 	mvneta_port_up(pp);
-- 
1.9.1

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

* [PATCH v3 4/8] net: mvneta: Clean-up mvneta_init()
  2014-05-22 23:06 [PATCH v3 0/8] net: ethernet: marvell: Assorted fixes Ezequiel Garcia
                   ` (2 preceding siblings ...)
  2014-05-22 23:06 ` [PATCH v3 3/8] net: mvneta: Check tx queue setup error in mvneta_change_mtu() Ezequiel Garcia
@ 2014-05-22 23:06 ` Ezequiel Garcia
  2014-05-22 23:07 ` [PATCH v3 5/8] net: mvneta: Use prepare/commit API to simplify MAC address setting Ezequiel Garcia
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 11+ messages in thread
From: Ezequiel Garcia @ 2014-05-22 23:06 UTC (permalink / raw)
  To: netdev, David Miller
  Cc: Thomas Petazzoni, Sebastian Hesselbarth, Gregory Clement,
	Lior Amsalem, Tawfik Bayouk, Andrew Lunn, Ezequiel Garcia

This commit cleans-up mvneta_init(), which initializes the hardware
and allocates the rx/qx queues. The queue allocation is simplified
by using devm_kcalloc instead of kzalloc. The unused phy_addr parameter
is removed. While here, the 'hal' references in the comments are removed.
This commit makes no functionality change.

Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
---
 drivers/net/ethernet/marvell/mvneta.c | 36 +++++++++++------------------------
 1 file changed, 11 insertions(+), 25 deletions(-)

diff --git a/drivers/net/ethernet/marvell/mvneta.c b/drivers/net/ethernet/marvell/mvneta.c
index d28327d..66e4631 100644
--- a/drivers/net/ethernet/marvell/mvneta.c
+++ b/drivers/net/ethernet/marvell/mvneta.c
@@ -2133,7 +2133,7 @@ static void mvneta_tx_reset(struct mvneta_port *pp)
 {
 	int queue;
 
-	/* free the skb's in the hal tx ring */
+	/* free the skb's in the tx ring */
 	for (queue = 0; queue < txq_number; queue++)
 		mvneta_txq_done_force(pp, &pp->txqs[queue]);
 
@@ -2788,7 +2788,7 @@ const struct ethtool_ops mvneta_eth_tool_ops = {
 };
 
 /* Initialize hw */
-static int mvneta_init(struct mvneta_port *pp, int phy_addr)
+static int mvneta_init(struct device *dev, struct mvneta_port *pp)
 {
 	int queue;
 
@@ -2798,8 +2798,8 @@ static int mvneta_init(struct mvneta_port *pp, int phy_addr)
 	/* Set port default values */
 	mvneta_defaults_set(pp);
 
-	pp->txqs = kzalloc(txq_number * sizeof(struct mvneta_tx_queue),
-			   GFP_KERNEL);
+	pp->txqs = devm_kcalloc(dev, txq_number, sizeof(struct mvneta_tx_queue),
+				GFP_KERNEL);
 	if (!pp->txqs)
 		return -ENOMEM;
 
@@ -2811,12 +2811,10 @@ static int mvneta_init(struct mvneta_port *pp, int phy_addr)
 		txq->done_pkts_coal = MVNETA_TXDONE_COAL_PKTS;
 	}
 
-	pp->rxqs = kzalloc(rxq_number * sizeof(struct mvneta_rx_queue),
-			   GFP_KERNEL);
-	if (!pp->rxqs) {
-		kfree(pp->txqs);
+	pp->rxqs = devm_kcalloc(dev, rxq_number, sizeof(struct mvneta_rx_queue),
+				GFP_KERNEL);
+	if (!pp->rxqs)
 		return -ENOMEM;
-	}
 
 	/* Create Rx descriptor rings */
 	for (queue = 0; queue < rxq_number; queue++) {
@@ -2830,12 +2828,6 @@ static int mvneta_init(struct mvneta_port *pp, int phy_addr)
 	return 0;
 }
 
-static void mvneta_deinit(struct mvneta_port *pp)
-{
-	kfree(pp->txqs);
-	kfree(pp->rxqs);
-}
-
 /* platform glue : initialize decoding windows */
 static void mvneta_conf_mbus_windows(struct mvneta_port *pp,
 				     const struct mbus_dram_target_info *dram)
@@ -2918,7 +2910,6 @@ static int mvneta_probe(struct platform_device *pdev)
 	struct resource *res;
 	struct device_node *dn = pdev->dev.of_node;
 	struct device_node *phy_node;
-	u32 phy_addr;
 	struct mvneta_port *pp;
 	struct net_device *dev;
 	const char *dt_mac_addr;
@@ -3027,16 +3018,14 @@ static int mvneta_probe(struct platform_device *pdev)
 	pp->dev = dev;
 	SET_NETDEV_DEV(dev, &pdev->dev);
 
-	err = mvneta_init(pp, phy_addr);
-	if (err < 0) {
-		dev_err(&pdev->dev, "can't init eth hal\n");
+	err = mvneta_init(&pdev->dev, pp);
+	if (err < 0)
 		goto err_free_stats;
-	}
 
 	err = mvneta_port_power_up(pp, phy_mode);
 	if (err < 0) {
 		dev_err(&pdev->dev, "can't power up port\n");
-		goto err_deinit;
+		goto err_free_stats;
 	}
 
 	dram_target_info = mv_mbus_dram_info();
@@ -3053,7 +3042,7 @@ static int mvneta_probe(struct platform_device *pdev)
 	err = register_netdev(dev);
 	if (err < 0) {
 		dev_err(&pdev->dev, "failed to register\n");
-		goto err_deinit;
+		goto err_free_stats;
 	}
 
 	netdev_info(dev, "Using %s mac address %pM\n", mac_from,
@@ -3063,8 +3052,6 @@ static int mvneta_probe(struct platform_device *pdev)
 
 	return 0;
 
-err_deinit:
-	mvneta_deinit(pp);
 err_free_stats:
 	free_percpu(pp->stats);
 err_clk:
@@ -3083,7 +3070,6 @@ static int mvneta_remove(struct platform_device *pdev)
 	struct mvneta_port *pp = netdev_priv(dev);
 
 	unregister_netdev(dev);
-	mvneta_deinit(pp);
 	clk_disable_unprepare(pp->clk);
 	free_percpu(pp->stats);
 	irq_dispose_mapping(dev->irq);
-- 
1.9.1

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

* [PATCH v3 5/8] net: mvneta: Use prepare/commit API to simplify MAC address setting
  2014-05-22 23:06 [PATCH v3 0/8] net: ethernet: marvell: Assorted fixes Ezequiel Garcia
                   ` (3 preceding siblings ...)
  2014-05-22 23:06 ` [PATCH v3 4/8] net: mvneta: Clean-up mvneta_init() Ezequiel Garcia
@ 2014-05-22 23:07 ` Ezequiel Garcia
  2014-05-22 23:07 ` [PATCH v3 6/8] net: mvneta: Change the number of default rx queues to one Ezequiel Garcia
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 11+ messages in thread
From: Ezequiel Garcia @ 2014-05-22 23:07 UTC (permalink / raw)
  To: netdev, David Miller
  Cc: Thomas Petazzoni, Sebastian Hesselbarth, Gregory Clement,
	Lior Amsalem, Tawfik Bayouk, Andrew Lunn, Ezequiel Garcia

Use eth_prepare_mac_addr_change and eth_commit_mac_addr_change, instead
of manually checking and storing the MAC address, which makes the
code slightly more robust. This fixes the lack of valid MAC address check
in the driver's .ndo_set_mac_address hook.

Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
---
 drivers/net/ethernet/marvell/mvneta.c | 19 +++++++------------
 1 file changed, 7 insertions(+), 12 deletions(-)

diff --git a/drivers/net/ethernet/marvell/mvneta.c b/drivers/net/ethernet/marvell/mvneta.c
index 66e4631..dd84b6a 100644
--- a/drivers/net/ethernet/marvell/mvneta.c
+++ b/drivers/net/ethernet/marvell/mvneta.c
@@ -2473,22 +2473,19 @@ static void mvneta_get_mac_addr(struct mvneta_port *pp, unsigned char *addr)
 static int mvneta_set_mac_addr(struct net_device *dev, void *addr)
 {
 	struct mvneta_port *pp = netdev_priv(dev);
-	u8 *mac = addr + 2;
-	int i;
-
-	if (netif_running(dev))
-		return -EBUSY;
+	struct sockaddr *sockaddr = addr;
+	int ret;
 
+	ret = eth_prepare_mac_addr_change(dev, addr);
+	if (ret < 0)
+		return ret;
 	/* Remove previous address table entry */
 	mvneta_mac_addr_set(pp, dev->dev_addr, -1);
 
 	/* Set new addr in hw */
-	mvneta_mac_addr_set(pp, mac, rxq_def);
-
-	/* Set addr in the device */
-	for (i = 0; i < ETH_ALEN; i++)
-		dev->dev_addr[i] = mac[i];
+	mvneta_mac_addr_set(pp, sockaddr->sa_data, rxq_def);
 
+	eth_commit_mac_addr_change(dev, addr);
 	return 0;
 }
 
@@ -2583,8 +2580,6 @@ static int mvneta_open(struct net_device *dev)
 	struct mvneta_port *pp = netdev_priv(dev);
 	int ret;
 
-	mvneta_mac_addr_set(pp, dev->dev_addr, rxq_def);
-
 	pp->pkt_size = MVNETA_RX_PKT_SIZE(pp->dev->mtu);
 	pp->frag_size = SKB_DATA_ALIGN(MVNETA_RX_BUF_SIZE(pp->pkt_size)) +
 	                SKB_DATA_ALIGN(sizeof(struct skb_shared_info));
-- 
1.9.1

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

* [PATCH v3 6/8] net: mvneta: Change the number of default rx queues to one
  2014-05-22 23:06 [PATCH v3 0/8] net: ethernet: marvell: Assorted fixes Ezequiel Garcia
                   ` (4 preceding siblings ...)
  2014-05-22 23:07 ` [PATCH v3 5/8] net: mvneta: Use prepare/commit API to simplify MAC address setting Ezequiel Garcia
@ 2014-05-22 23:07 ` Ezequiel Garcia
  2014-05-22 23:07 ` [PATCH v3 7/8] net: mvmdio: Use devm_* API to simplify the code Ezequiel Garcia
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 11+ messages in thread
From: Ezequiel Garcia @ 2014-05-22 23:07 UTC (permalink / raw)
  To: netdev, David Miller
  Cc: Thomas Petazzoni, Sebastian Hesselbarth, Gregory Clement,
	Lior Amsalem, Tawfik Bayouk, Andrew Lunn, Ezequiel Garcia

The driver does not support multiple rx queues, and so it's a waste
of resources to have a default number larger than one (1).

Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
---
 drivers/net/ethernet/marvell/mvneta.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/marvell/mvneta.c b/drivers/net/ethernet/marvell/mvneta.c
index dd84b6a..02dd075 100644
--- a/drivers/net/ethernet/marvell/mvneta.c
+++ b/drivers/net/ethernet/marvell/mvneta.c
@@ -451,7 +451,10 @@ struct mvneta_rx_queue {
 	int next_desc_to_proc;
 };
 
-static int rxq_number = 8;
+/* The hardware supports eight (8) rx queues, but we are only allowing
+ * the first one to be used. Therefore, let's just allocate one queue.
+ */
+static int rxq_number = 1;
 static int txq_number = 8;
 
 static int rxq_def;
-- 
1.9.1

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

* [PATCH v3 7/8] net: mvmdio: Use devm_* API to simplify the code
  2014-05-22 23:06 [PATCH v3 0/8] net: ethernet: marvell: Assorted fixes Ezequiel Garcia
                   ` (5 preceding siblings ...)
  2014-05-22 23:07 ` [PATCH v3 6/8] net: mvneta: Change the number of default rx queues to one Ezequiel Garcia
@ 2014-05-22 23:07 ` Ezequiel Garcia
  2014-05-22 23:07 ` [PATCH v3 8/8] net: mvneta: Remove unneeded 'weigth' field Ezequiel Garcia
  2014-05-23 19:36 ` [PATCH v3 0/8] net: ethernet: marvell: Assorted fixes David Miller
  8 siblings, 0 replies; 11+ messages in thread
From: Ezequiel Garcia @ 2014-05-22 23:07 UTC (permalink / raw)
  To: netdev, David Miller
  Cc: Thomas Petazzoni, Sebastian Hesselbarth, Gregory Clement,
	Lior Amsalem, Tawfik Bayouk, Andrew Lunn, Ezequiel Garcia

This commit makes use of devm_kmalloc_array() for memory allocation and the
recently introduced devm_mdiobus_alloc() API to simplify driver's code.
While here, remove a redundant out of memory error message.

Acked-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
---
 drivers/net/ethernet/marvell/mvmdio.c | 18 ++++++------------
 1 file changed, 6 insertions(+), 12 deletions(-)

diff --git a/drivers/net/ethernet/marvell/mvmdio.c b/drivers/net/ethernet/marvell/mvmdio.c
index 9d5ced2..fc2fb25 100644
--- a/drivers/net/ethernet/marvell/mvmdio.c
+++ b/drivers/net/ethernet/marvell/mvmdio.c
@@ -195,11 +195,10 @@ static int orion_mdio_probe(struct platform_device *pdev)
 		return -ENODEV;
 	}
 
-	bus = mdiobus_alloc_size(sizeof(struct orion_mdio_dev));
-	if (!bus) {
-		dev_err(&pdev->dev, "Cannot allocate MDIO bus\n");
+	bus = devm_mdiobus_alloc_size(&pdev->dev,
+				      sizeof(struct orion_mdio_dev));
+	if (!bus)
 		return -ENOMEM;
-	}
 
 	bus->name = "orion_mdio_bus";
 	bus->read = orion_mdio_read;
@@ -208,11 +207,10 @@ static int orion_mdio_probe(struct platform_device *pdev)
 		 dev_name(&pdev->dev));
 	bus->parent = &pdev->dev;
 
-	bus->irq = kmalloc(sizeof(int) * PHY_MAX_ADDR, GFP_KERNEL);
-	if (!bus->irq) {
-		mdiobus_free(bus);
+	bus->irq = devm_kmalloc_array(&pdev->dev, PHY_MAX_ADDR, sizeof(int),
+				      GFP_KERNEL);
+	if (!bus->irq)
 		return -ENOMEM;
-	}
 
 	for (i = 0; i < PHY_MAX_ADDR; i++)
 		bus->irq[i] = PHY_POLL;
@@ -264,8 +262,6 @@ static int orion_mdio_probe(struct platform_device *pdev)
 out_mdio:
 	if (!IS_ERR(dev->clk))
 		clk_disable_unprepare(dev->clk);
-	kfree(bus->irq);
-	mdiobus_free(bus);
 	return ret;
 }
 
@@ -276,8 +272,6 @@ static int orion_mdio_remove(struct platform_device *pdev)
 
 	writel(0, dev->regs + MVMDIO_ERR_INT_MASK);
 	mdiobus_unregister(bus);
-	kfree(bus->irq);
-	mdiobus_free(bus);
 	if (!IS_ERR(dev->clk))
 		clk_disable_unprepare(dev->clk);
 
-- 
1.9.1

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

* [PATCH v3 8/8] net: mvneta: Remove unneeded 'weigth' field
  2014-05-22 23:06 [PATCH v3 0/8] net: ethernet: marvell: Assorted fixes Ezequiel Garcia
                   ` (6 preceding siblings ...)
  2014-05-22 23:07 ` [PATCH v3 7/8] net: mvmdio: Use devm_* API to simplify the code Ezequiel Garcia
@ 2014-05-22 23:07 ` Ezequiel Garcia
  2014-05-23 19:36 ` [PATCH v3 0/8] net: ethernet: marvell: Assorted fixes David Miller
  8 siblings, 0 replies; 11+ messages in thread
From: Ezequiel Garcia @ 2014-05-22 23:07 UTC (permalink / raw)
  To: netdev, David Miller
  Cc: Thomas Petazzoni, Sebastian Hesselbarth, Gregory Clement,
	Lior Amsalem, Tawfik Bayouk, Andrew Lunn, Ezequiel Garcia

The 'weight' field is only used to pass the weigth to napi initialization
function. This commit removes the field, and instead uses a fixed value to
initialize the napi context.

Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
---
 drivers/net/ethernet/marvell/mvneta.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/drivers/net/ethernet/marvell/mvneta.c b/drivers/net/ethernet/marvell/mvneta.c
index 02dd075..b8919fa 100644
--- a/drivers/net/ethernet/marvell/mvneta.c
+++ b/drivers/net/ethernet/marvell/mvneta.c
@@ -283,9 +283,6 @@ struct mvneta_port {
 	u32 cause_rx_tx;
 	struct napi_struct napi;
 
-	/* Napi weight */
-	int weight;
-
 	/* Core clock */
 	struct clk *clk;
 	u8 mcast_count[256];
@@ -2968,8 +2965,6 @@ static int mvneta_probe(struct platform_device *pdev)
 	dev->ethtool_ops = &mvneta_eth_tool_ops;
 
 	pp = netdev_priv(dev);
-
-	pp->weight = MVNETA_RX_POLL_WEIGHT;
 	pp->phy_node = phy_node;
 	pp->phy_interface = phy_mode;
 
@@ -3030,7 +3025,7 @@ static int mvneta_probe(struct platform_device *pdev)
 	if (dram_target_info)
 		mvneta_conf_mbus_windows(pp, dram_target_info);
 
-	netif_napi_add(dev, &pp->napi, mvneta_poll, pp->weight);
+	netif_napi_add(dev, &pp->napi, mvneta_poll, MVNETA_RX_POLL_WEIGHT);
 
 	dev->features = NETIF_F_SG | NETIF_F_IP_CSUM | NETIF_F_TSO;
 	dev->hw_features |= dev->features;
-- 
1.9.1

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

* Re: [PATCH v3 0/8] net: ethernet: marvell: Assorted fixes
  2014-05-22 23:06 [PATCH v3 0/8] net: ethernet: marvell: Assorted fixes Ezequiel Garcia
                   ` (7 preceding siblings ...)
  2014-05-22 23:07 ` [PATCH v3 8/8] net: mvneta: Remove unneeded 'weigth' field Ezequiel Garcia
@ 2014-05-23 19:36 ` David Miller
  2014-05-23 20:01   ` Ezequiel Garcia
  8 siblings, 1 reply; 11+ messages in thread
From: David Miller @ 2014-05-23 19:36 UTC (permalink / raw)
  To: ezequiel.garcia
  Cc: netdev, thomas.petazzoni, sebastian.hesselbarth, gregory.clement,
	alior, tawfik, andrew

From: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
Date: Thu, 22 May 2014 20:06:55 -0300

> New round for this assorted fixes and clean-up series. There is more room for
> clean-ups, and I'll start preparing more patches once these are accepted.
> 
> This series consists of cleanups and minor improvements on mvneta, mv643xx_eth
> and mvmdio drivers. None of the patches imply any functionality change, except
> for the patch six "Change the number of default rx queues to one".
> 
> This patch reduces the driver's allocated resources and makes the multiqueue
> path in the poll function not get taken. The previous patchset contains more
> details:
> 
>   http://permalink.gmane.org/gmane.linux.network/315015
> 
> As usual, any feedback on this will be well received!

Series applied to net-next, but some comments:

1) Never use web sites to reference informative material, instead put it
   all explicitly into the commit message in your posting.

   Web sites and archives come and go, the commit message is forever and
   readily available to someone studying your changes.

2) Just get rid of that MVNETA_RX_POLL_WEIGHT and simply use the
   generic default NAPI_POLL_WEIGHT which has the same value.

   Any local NAPI weight selection must be done for a good reason and
   be fully documented with performance metrics et al.

3) I know you inherited this, but the MTU change failure behavior is
   not so great.  If the system is low on memory it could fail and losing
   an interface completely during an MTU change is extremely poor behavior.

   I would suggest holding onto the old allocated TXQ resources, and
   restoring them if the allocation of the new ones fail.

   That way the MTU change itself would fail, but the interface would
   remain up with the original MTU.

   Please make sure that you properly revert the MTU adjustment in
   this failure path.

Thanks.

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

* Re: [PATCH v3 0/8] net: ethernet: marvell: Assorted fixes
  2014-05-23 19:36 ` [PATCH v3 0/8] net: ethernet: marvell: Assorted fixes David Miller
@ 2014-05-23 20:01   ` Ezequiel Garcia
  0 siblings, 0 replies; 11+ messages in thread
From: Ezequiel Garcia @ 2014-05-23 20:01 UTC (permalink / raw)
  To: David Miller
  Cc: netdev, thomas.petazzoni, sebastian.hesselbarth, gregory.clement,
	alior, tawfik, andrew

On 23 May 03:36 PM, David Miller wrote:
> From: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
> Date: Thu, 22 May 2014 20:06:55 -0300
> 
> > New round for this assorted fixes and clean-up series. There is more room for
> > clean-ups, and I'll start preparing more patches once these are accepted.
> > 
> > This series consists of cleanups and minor improvements on mvneta, mv643xx_eth
> > and mvmdio drivers. None of the patches imply any functionality change, except
> > for the patch six "Change the number of default rx queues to one".
> > 
> > This patch reduces the driver's allocated resources and makes the multiqueue
> > path in the poll function not get taken. The previous patchset contains more
> > details:
> > 
> >   http://permalink.gmane.org/gmane.linux.network/315015
> > 
> > As usual, any feedback on this will be well received!
> 
> Series applied to net-next, but some comments:
> 
> 1) Never use web sites to reference informative material, instead put it
>    all explicitly into the commit message in your posting.
> 
>    Web sites and archives come and go, the commit message is forever and
>    readily available to someone studying your changes.
> 

OK, I'll keep this in mind.

> 2) Just get rid of that MVNETA_RX_POLL_WEIGHT and simply use the
>    generic default NAPI_POLL_WEIGHT which has the same value.
> 
>    Any local NAPI weight selection must be done for a good reason and
>    be fully documented with performance metrics et al.
> 

OK.

> 3) I know you inherited this, but the MTU change failure behavior is
>    not so great.  If the system is low on memory it could fail and losing
>    an interface completely during an MTU change is extremely poor behavior.
> 
>    I would suggest holding onto the old allocated TXQ resources, and
>    restoring them if the allocation of the new ones fail.
> 
>    That way the MTU change itself would fail, but the interface would
>    remain up with the original MTU.
> 
>    Please make sure that you properly revert the MTU adjustment in
>    this failure path.
> 

Oh, I see. Thanks for the feedback, I'll take a look at this next week.
-- 
Ezequiel García, Free Electrons
Embedded Linux, Kernel and Android Engineering
http://free-electrons.com

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

end of thread, other threads:[~2014-05-23 20:02 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-22 23:06 [PATCH v3 0/8] net: ethernet: marvell: Assorted fixes Ezequiel Garcia
2014-05-22 23:06 ` [PATCH v3 1/8] net: mv643xx_eth: Simplify mv643xx_eth_adjust_link() Ezequiel Garcia
2014-05-22 23:06 ` [PATCH v3 2/8] net: mvneta: Clean-up mvneta_tx_frag_process() Ezequiel Garcia
2014-05-22 23:06 ` [PATCH v3 3/8] net: mvneta: Check tx queue setup error in mvneta_change_mtu() Ezequiel Garcia
2014-05-22 23:06 ` [PATCH v3 4/8] net: mvneta: Clean-up mvneta_init() Ezequiel Garcia
2014-05-22 23:07 ` [PATCH v3 5/8] net: mvneta: Use prepare/commit API to simplify MAC address setting Ezequiel Garcia
2014-05-22 23:07 ` [PATCH v3 6/8] net: mvneta: Change the number of default rx queues to one Ezequiel Garcia
2014-05-22 23:07 ` [PATCH v3 7/8] net: mvmdio: Use devm_* API to simplify the code Ezequiel Garcia
2014-05-22 23:07 ` [PATCH v3 8/8] net: mvneta: Remove unneeded 'weigth' field Ezequiel Garcia
2014-05-23 19:36 ` [PATCH v3 0/8] net: ethernet: marvell: Assorted fixes David Miller
2014-05-23 20:01   ` Ezequiel Garcia

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