* [PATCH v2 0/9] net: ethernet: marvell: Assorted fixes
@ 2014-05-06 17:20 Ezequiel Garcia
2014-05-06 17:20 ` [PATCH v2 1/9] net: mv643xx_eth: Simplify mv643xx_eth_adjust_link() Ezequiel Garcia
` (8 more replies)
0 siblings, 9 replies; 12+ messages in thread
From: Ezequiel Garcia @ 2014-05-06 17:20 UTC (permalink / raw)
To: netdev, David S. Miller, Willy Tarreau, Thomas Petazzoni
Cc: Gregory Clement, Lior Amsalem, Tawfik Bayouk,
Sebastian Hesselbarth, Ezequiel Garcia
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. In other words, in the poll():
static int mvneta_poll(struct napi_struct *napi, int budget)
{
/* .. */
if (rxq_number > 1) {
/* .. */
} else {
rx_done = mvneta_rx(pp, budget, &pp->rxqs[rxq_def]);
budget -= rx_done;
}
}
the first block of the 'if' won't be taken. This should be completely harmless,
as the driver only supports the first queue, by requiring 'rxq_def' to be '0'.
This is explained by a comment in the code:
/* Our multiqueue support is not complete, so for now, only
* allow the usage of the first RX queue
*/
if (rxq_def != 0) {
dev_err(&pdev->dev, "Invalid rxq_def argument: %d\n", rxq_def);
return -EINVAL;
}
Willy, Thomas: given you've done some work on these drivers, could you review
the series and comment?
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 (9):
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: Factorize feature setting
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 | 97 ++++++++++++------------------
3 files changed, 49 insertions(+), 80 deletions(-)
--
1.9.1
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH v2 1/9] net: mv643xx_eth: Simplify mv643xx_eth_adjust_link()
2014-05-06 17:20 [PATCH v2 0/9] net: ethernet: marvell: Assorted fixes Ezequiel Garcia
@ 2014-05-06 17:20 ` Ezequiel Garcia
2014-05-06 17:20 ` [PATCH v2 2/9] net: mvneta: Clean-up mvneta_tx_frag_process() Ezequiel Garcia
` (7 subsequent siblings)
8 siblings, 0 replies; 12+ messages in thread
From: Ezequiel Garcia @ 2014-05-06 17:20 UTC (permalink / raw)
To: netdev, David S. Miller, Willy Tarreau, Thomas Petazzoni
Cc: Gregory Clement, Lior Amsalem, Tawfik Bayouk,
Sebastian Hesselbarth, 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 b7b8d74..b75965f3 100644
--- a/drivers/net/ethernet/marvell/mv643xx_eth.c
+++ b/drivers/net/ethernet/marvell/mv643xx_eth.c
@@ -1010,8 +1010,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 |
@@ -1387,7 +1388,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;
}
@@ -2303,7 +2304,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;
}
@@ -2701,13 +2702,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] 12+ messages in thread
* [PATCH v2 2/9] net: mvneta: Clean-up mvneta_tx_frag_process()
2014-05-06 17:20 [PATCH v2 0/9] net: ethernet: marvell: Assorted fixes Ezequiel Garcia
2014-05-06 17:20 ` [PATCH v2 1/9] net: mv643xx_eth: Simplify mv643xx_eth_adjust_link() Ezequiel Garcia
@ 2014-05-06 17:20 ` Ezequiel Garcia
2014-05-06 17:20 ` [PATCH v2 3/9] net: mvneta: Check tx queue setup error in mvneta_change_mtu() Ezequiel Garcia
` (6 subsequent siblings)
8 siblings, 0 replies; 12+ messages in thread
From: Ezequiel Garcia @ 2014-05-06 17:20 UTC (permalink / raw)
To: netdev, David S. Miller, Willy Tarreau, Thomas Petazzoni
Cc: Gregory Clement, Lior Amsalem, Tawfik Bayouk,
Sebastian Hesselbarth, 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 14786c8..d73ed91 100644
--- a/drivers/net/ethernet/marvell/mvneta.c
+++ b/drivers/net/ethernet/marvell/mvneta.c
@@ -1524,9 +1524,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;
@@ -1543,20 +1543,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] 12+ messages in thread
* [PATCH v2 3/9] net: mvneta: Check tx queue setup error in mvneta_change_mtu()
2014-05-06 17:20 [PATCH v2 0/9] net: ethernet: marvell: Assorted fixes Ezequiel Garcia
2014-05-06 17:20 ` [PATCH v2 1/9] net: mv643xx_eth: Simplify mv643xx_eth_adjust_link() Ezequiel Garcia
2014-05-06 17:20 ` [PATCH v2 2/9] net: mvneta: Clean-up mvneta_tx_frag_process() Ezequiel Garcia
@ 2014-05-06 17:20 ` Ezequiel Garcia
2014-05-06 17:20 ` [PATCH v2 4/9] net: mvneta: Clean-up mvneta_init() Ezequiel Garcia
` (5 subsequent siblings)
8 siblings, 0 replies; 12+ messages in thread
From: Ezequiel Garcia @ 2014-05-06 17:20 UTC (permalink / raw)
To: netdev, David S. Miller, Willy Tarreau, Thomas Petazzoni
Cc: Gregory Clement, Lior Amsalem, Tawfik Bayouk,
Sebastian Hesselbarth, 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 d73ed91..743503a 100644
--- a/drivers/net/ethernet/marvell/mvneta.c
+++ b/drivers/net/ethernet/marvell/mvneta.c
@@ -2275,24 +2275,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] 12+ messages in thread
* [PATCH v2 4/9] net: mvneta: Clean-up mvneta_init()
2014-05-06 17:20 [PATCH v2 0/9] net: ethernet: marvell: Assorted fixes Ezequiel Garcia
` (2 preceding siblings ...)
2014-05-06 17:20 ` [PATCH v2 3/9] net: mvneta: Check tx queue setup error in mvneta_change_mtu() Ezequiel Garcia
@ 2014-05-06 17:20 ` Ezequiel Garcia
2014-05-06 17:20 ` [PATCH v2 5/9] net: mvneta: Use prepare/commit API to simplify MAC address setting Ezequiel Garcia
` (4 subsequent siblings)
8 siblings, 0 replies; 12+ messages in thread
From: Ezequiel Garcia @ 2014-05-06 17:20 UTC (permalink / raw)
To: netdev, David S. Miller, Willy Tarreau, Thomas Petazzoni
Cc: Gregory Clement, Lior Amsalem, Tawfik Bayouk,
Sebastian Hesselbarth, 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_kzalloc 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 | 38 ++++++++++++-----------------------
1 file changed, 13 insertions(+), 25 deletions(-)
diff --git a/drivers/net/ethernet/marvell/mvneta.c b/drivers/net/ethernet/marvell/mvneta.c
index 743503a..9a444a0 100644
--- a/drivers/net/ethernet/marvell/mvneta.c
+++ b/drivers/net/ethernet/marvell/mvneta.c
@@ -1999,7 +1999,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]);
@@ -2638,7 +2638,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;
@@ -2648,8 +2648,9 @@ 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_kzalloc(dev,
+ txq_number * sizeof(struct mvneta_tx_queue),
+ GFP_KERNEL);
if (!pp->txqs)
return -ENOMEM;
@@ -2661,12 +2662,11 @@ 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_kzalloc(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++) {
@@ -2680,12 +2680,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)
@@ -2768,7 +2762,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;
@@ -2864,16 +2857,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();
@@ -2890,7 +2881,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,
@@ -2900,8 +2891,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:
@@ -2920,7 +2909,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] 12+ messages in thread
* [PATCH v2 5/9] net: mvneta: Use prepare/commit API to simplify MAC address setting
2014-05-06 17:20 [PATCH v2 0/9] net: ethernet: marvell: Assorted fixes Ezequiel Garcia
` (3 preceding siblings ...)
2014-05-06 17:20 ` [PATCH v2 4/9] net: mvneta: Clean-up mvneta_init() Ezequiel Garcia
@ 2014-05-06 17:20 ` Ezequiel Garcia
2014-05-06 17:20 ` [PATCH v2 6/9] net: mvneta: Change the number of default rx queues to one Ezequiel Garcia
` (3 subsequent siblings)
8 siblings, 0 replies; 12+ messages in thread
From: Ezequiel Garcia @ 2014-05-06 17:20 UTC (permalink / raw)
To: netdev, David S. Miller, Willy Tarreau, Thomas Petazzoni
Cc: Gregory Clement, Lior Amsalem, Tawfik Bayouk,
Sebastian Hesselbarth, 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 9a444a0..0dcce29 100644
--- a/drivers/net/ethernet/marvell/mvneta.c
+++ b/drivers/net/ethernet/marvell/mvneta.c
@@ -2323,22 +2323,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;
}
@@ -2433,8 +2430,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] 12+ messages in thread
* [PATCH v2 6/9] net: mvneta: Change the number of default rx queues to one
2014-05-06 17:20 [PATCH v2 0/9] net: ethernet: marvell: Assorted fixes Ezequiel Garcia
` (4 preceding siblings ...)
2014-05-06 17:20 ` [PATCH v2 5/9] net: mvneta: Use prepare/commit API to simplify MAC address setting Ezequiel Garcia
@ 2014-05-06 17:20 ` Ezequiel Garcia
2014-05-06 17:20 ` [PATCH v2 7/9] net: mvmdio: Use devm_* API to simplify the code Ezequiel Garcia
` (2 subsequent siblings)
8 siblings, 0 replies; 12+ messages in thread
From: Ezequiel Garcia @ 2014-05-06 17:20 UTC (permalink / raw)
To: netdev, David S. Miller, Willy Tarreau, Thomas Petazzoni
Cc: Gregory Clement, Lior Amsalem, Tawfik Bayouk,
Sebastian Hesselbarth, 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 0dcce29..ec4f67a 100644
--- a/drivers/net/ethernet/marvell/mvneta.c
+++ b/drivers/net/ethernet/marvell/mvneta.c
@@ -441,7 +441,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] 12+ messages in thread
* [PATCH v2 7/9] net: mvmdio: Use devm_* API to simplify the code
2014-05-06 17:20 [PATCH v2 0/9] net: ethernet: marvell: Assorted fixes Ezequiel Garcia
` (5 preceding siblings ...)
2014-05-06 17:20 ` [PATCH v2 6/9] net: mvneta: Change the number of default rx queues to one Ezequiel Garcia
@ 2014-05-06 17:20 ` Ezequiel Garcia
2014-05-06 18:01 ` Sergei Shtylyov
2014-05-06 17:20 ` [PATCH v2 8/9] net: mvneta: Factorize feature setting Ezequiel Garcia
2014-05-06 17:20 ` [PATCH v2 9/9] net: mvneta: Remove unneeded 'weigth' field Ezequiel Garcia
8 siblings, 1 reply; 12+ messages in thread
From: Ezequiel Garcia @ 2014-05-06 17:20 UTC (permalink / raw)
To: netdev, David S. Miller, Willy Tarreau, Thomas Petazzoni
Cc: Gregory Clement, Lior Amsalem, Tawfik Bayouk,
Sebastian Hesselbarth, Ezequiel Garcia
This commit makes use of devm_kmalloc() 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 b161a52..995e182 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(&pdev->dev,
+ sizeof(int) * PHY_MAX_ADDR, GFP_KERNEL);
+ if (!bus->irq)
return -ENOMEM;
- }
for (i = 0; i < PHY_MAX_ADDR; i++)
bus->irq[i] = PHY_POLL;
@@ -261,8 +259,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;
}
@@ -273,8 +269,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] 12+ messages in thread
* [PATCH v2 8/9] net: mvneta: Factorize feature setting
2014-05-06 17:20 [PATCH v2 0/9] net: ethernet: marvell: Assorted fixes Ezequiel Garcia
` (6 preceding siblings ...)
2014-05-06 17:20 ` [PATCH v2 7/9] net: mvmdio: Use devm_* API to simplify the code Ezequiel Garcia
@ 2014-05-06 17:20 ` Ezequiel Garcia
2014-05-06 17:20 ` [PATCH v2 9/9] net: mvneta: Remove unneeded 'weigth' field Ezequiel Garcia
8 siblings, 0 replies; 12+ messages in thread
From: Ezequiel Garcia @ 2014-05-06 17:20 UTC (permalink / raw)
To: netdev, David S. Miller, Willy Tarreau, Thomas Petazzoni
Cc: Gregory Clement, Lior Amsalem, Tawfik Bayouk,
Sebastian Hesselbarth, Ezequiel Garcia
In order to ease the addition of new features, let's factorize the
feature list.
Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
---
drivers/net/ethernet/marvell/mvneta.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/marvell/mvneta.c b/drivers/net/ethernet/marvell/mvneta.c
index ec4f67a..28b0536 100644
--- a/drivers/net/ethernet/marvell/mvneta.c
+++ b/drivers/net/ethernet/marvell/mvneta.c
@@ -2872,8 +2872,8 @@ static int mvneta_probe(struct platform_device *pdev)
netif_napi_add(dev, &pp->napi, mvneta_poll, pp->weight);
dev->features = NETIF_F_SG | NETIF_F_IP_CSUM;
- dev->hw_features |= NETIF_F_SG | NETIF_F_IP_CSUM;
- dev->vlan_features |= NETIF_F_SG | NETIF_F_IP_CSUM;
+ dev->hw_features |= dev->features;
+ dev->vlan_features |= dev->features;
dev->priv_flags |= IFF_UNICAST_FLT;
err = register_netdev(dev);
--
1.9.1
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH v2 9/9] net: mvneta: Remove unneeded 'weigth' field
2014-05-06 17:20 [PATCH v2 0/9] net: ethernet: marvell: Assorted fixes Ezequiel Garcia
` (7 preceding siblings ...)
2014-05-06 17:20 ` [PATCH v2 8/9] net: mvneta: Factorize feature setting Ezequiel Garcia
@ 2014-05-06 17:20 ` Ezequiel Garcia
8 siblings, 0 replies; 12+ messages in thread
From: Ezequiel Garcia @ 2014-05-06 17:20 UTC (permalink / raw)
To: netdev, David S. Miller, Willy Tarreau, Thomas Petazzoni
Cc: Gregory Clement, Lior Amsalem, Tawfik Bayouk,
Sebastian Hesselbarth, 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 28b0536..36fd90e 100644
--- a/drivers/net/ethernet/marvell/mvneta.c
+++ b/drivers/net/ethernet/marvell/mvneta.c
@@ -279,9 +279,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];
@@ -2807,8 +2804,6 @@ static int mvneta_probe(struct platform_device *pdev)
SET_ETHTOOL_OPS(dev, &mvneta_eth_tool_ops);
pp = netdev_priv(dev);
-
- pp->weight = MVNETA_RX_POLL_WEIGHT;
pp->phy_node = phy_node;
pp->phy_interface = phy_mode;
@@ -2869,7 +2864,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;
dev->hw_features |= dev->features;
--
1.9.1
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH v2 7/9] net: mvmdio: Use devm_* API to simplify the code
2014-05-06 17:20 ` [PATCH v2 7/9] net: mvmdio: Use devm_* API to simplify the code Ezequiel Garcia
@ 2014-05-06 18:01 ` Sergei Shtylyov
2014-05-16 23:48 ` Ezequiel Garcia
0 siblings, 1 reply; 12+ messages in thread
From: Sergei Shtylyov @ 2014-05-06 18:01 UTC (permalink / raw)
To: Ezequiel Garcia, netdev, David S. Miller, Willy Tarreau,
Thomas Petazzoni
Cc: Gregory Clement, Lior Amsalem, Tawfik Bayouk,
Sebastian Hesselbarth
Hello.
On 05/06/2014 09:20 PM, Ezequiel Garcia wrote:
> This commit makes use of devm_kmalloc() 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 b161a52..995e182 100644
> --- a/drivers/net/ethernet/marvell/mvmdio.c
> +++ b/drivers/net/ethernet/marvell/mvmdio.c
[...]
> @@ -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(&pdev->dev,
> + sizeof(int) * PHY_MAX_ADDR, GFP_KERNEL);
I'd rather use devm_kmalloc_array().
WBR, Sergei
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v2 7/9] net: mvmdio: Use devm_* API to simplify the code
2014-05-06 18:01 ` Sergei Shtylyov
@ 2014-05-16 23:48 ` Ezequiel Garcia
0 siblings, 0 replies; 12+ messages in thread
From: Ezequiel Garcia @ 2014-05-16 23:48 UTC (permalink / raw)
To: Sergei Shtylyov
Cc: netdev, David S. Miller, Willy Tarreau, Thomas Petazzoni,
Gregory Clement, Lior Amsalem, Tawfik Bayouk,
Sebastian Hesselbarth
On 06 May 10:01 PM, Sergei Shtylyov wrote:
> On 05/06/2014 09:20 PM, Ezequiel Garcia wrote:
>
> >This commit makes use of devm_kmalloc() 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 b161a52..995e182 100644
> >--- a/drivers/net/ethernet/marvell/mvmdio.c
> >+++ b/drivers/net/ethernet/marvell/mvmdio.c
> [...]
> >@@ -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(&pdev->dev,
> >+ sizeof(int) * PHY_MAX_ADDR, GFP_KERNEL);
>
> I'd rather use devm_kmalloc_array().
>
Sure. I'll prepare another version.
Thanks,
--
Ezequiel García, Free Electrons
Embedded Linux, Kernel and Android Engineering
http://free-electrons.com
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2014-05-16 23:49 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-06 17:20 [PATCH v2 0/9] net: ethernet: marvell: Assorted fixes Ezequiel Garcia
2014-05-06 17:20 ` [PATCH v2 1/9] net: mv643xx_eth: Simplify mv643xx_eth_adjust_link() Ezequiel Garcia
2014-05-06 17:20 ` [PATCH v2 2/9] net: mvneta: Clean-up mvneta_tx_frag_process() Ezequiel Garcia
2014-05-06 17:20 ` [PATCH v2 3/9] net: mvneta: Check tx queue setup error in mvneta_change_mtu() Ezequiel Garcia
2014-05-06 17:20 ` [PATCH v2 4/9] net: mvneta: Clean-up mvneta_init() Ezequiel Garcia
2014-05-06 17:20 ` [PATCH v2 5/9] net: mvneta: Use prepare/commit API to simplify MAC address setting Ezequiel Garcia
2014-05-06 17:20 ` [PATCH v2 6/9] net: mvneta: Change the number of default rx queues to one Ezequiel Garcia
2014-05-06 17:20 ` [PATCH v2 7/9] net: mvmdio: Use devm_* API to simplify the code Ezequiel Garcia
2014-05-06 18:01 ` Sergei Shtylyov
2014-05-16 23:48 ` Ezequiel Garcia
2014-05-06 17:20 ` [PATCH v2 8/9] net: mvneta: Factorize feature setting Ezequiel Garcia
2014-05-06 17:20 ` [PATCH v2 9/9] net: mvneta: Remove unneeded 'weigth' field 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).