diff options
Diffstat (limited to 'drivers/net/ethernet/stmicro/stmmac')
-rw-r--r-- | drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 52 | ||||
-rw-r--r-- | drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c | 13 |
2 files changed, 36 insertions, 29 deletions
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index 6f77a46c7e2c..18c46bb0f3bf 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | |||
@@ -276,6 +276,7 @@ static void stmmac_eee_ctrl_timer(unsigned long arg) | |||
276 | bool stmmac_eee_init(struct stmmac_priv *priv) | 276 | bool stmmac_eee_init(struct stmmac_priv *priv) |
277 | { | 277 | { |
278 | char *phy_bus_name = priv->plat->phy_bus_name; | 278 | char *phy_bus_name = priv->plat->phy_bus_name; |
279 | unsigned long flags; | ||
279 | bool ret = false; | 280 | bool ret = false; |
280 | 281 | ||
281 | /* Using PCS we cannot dial with the phy registers at this stage | 282 | /* Using PCS we cannot dial with the phy registers at this stage |
@@ -300,6 +301,7 @@ bool stmmac_eee_init(struct stmmac_priv *priv) | |||
300 | * changed). | 301 | * changed). |
301 | * In that case the driver disable own timers. | 302 | * In that case the driver disable own timers. |
302 | */ | 303 | */ |
304 | spin_lock_irqsave(&priv->lock, flags); | ||
303 | if (priv->eee_active) { | 305 | if (priv->eee_active) { |
304 | pr_debug("stmmac: disable EEE\n"); | 306 | pr_debug("stmmac: disable EEE\n"); |
305 | del_timer_sync(&priv->eee_ctrl_timer); | 307 | del_timer_sync(&priv->eee_ctrl_timer); |
@@ -307,9 +309,11 @@ bool stmmac_eee_init(struct stmmac_priv *priv) | |||
307 | tx_lpi_timer); | 309 | tx_lpi_timer); |
308 | } | 310 | } |
309 | priv->eee_active = 0; | 311 | priv->eee_active = 0; |
312 | spin_unlock_irqrestore(&priv->lock, flags); | ||
310 | goto out; | 313 | goto out; |
311 | } | 314 | } |
312 | /* Activate the EEE and start timers */ | 315 | /* Activate the EEE and start timers */ |
316 | spin_lock_irqsave(&priv->lock, flags); | ||
313 | if (!priv->eee_active) { | 317 | if (!priv->eee_active) { |
314 | priv->eee_active = 1; | 318 | priv->eee_active = 1; |
315 | init_timer(&priv->eee_ctrl_timer); | 319 | init_timer(&priv->eee_ctrl_timer); |
@@ -325,9 +329,10 @@ bool stmmac_eee_init(struct stmmac_priv *priv) | |||
325 | /* Set HW EEE according to the speed */ | 329 | /* Set HW EEE according to the speed */ |
326 | priv->hw->mac->set_eee_pls(priv->hw, priv->phydev->link); | 330 | priv->hw->mac->set_eee_pls(priv->hw, priv->phydev->link); |
327 | 331 | ||
328 | pr_debug("stmmac: Energy-Efficient Ethernet initialized\n"); | ||
329 | |||
330 | ret = true; | 332 | ret = true; |
333 | spin_unlock_irqrestore(&priv->lock, flags); | ||
334 | |||
335 | pr_debug("stmmac: Energy-Efficient Ethernet initialized\n"); | ||
331 | } | 336 | } |
332 | out: | 337 | out: |
333 | return ret; | 338 | return ret; |
@@ -760,12 +765,12 @@ static void stmmac_adjust_link(struct net_device *dev) | |||
760 | if (new_state && netif_msg_link(priv)) | 765 | if (new_state && netif_msg_link(priv)) |
761 | phy_print_status(phydev); | 766 | phy_print_status(phydev); |
762 | 767 | ||
768 | spin_unlock_irqrestore(&priv->lock, flags); | ||
769 | |||
763 | /* At this stage, it could be needed to setup the EEE or adjust some | 770 | /* At this stage, it could be needed to setup the EEE or adjust some |
764 | * MAC related HW registers. | 771 | * MAC related HW registers. |
765 | */ | 772 | */ |
766 | priv->eee_enabled = stmmac_eee_init(priv); | 773 | priv->eee_enabled = stmmac_eee_init(priv); |
767 | |||
768 | spin_unlock_irqrestore(&priv->lock, flags); | ||
769 | } | 774 | } |
770 | 775 | ||
771 | /** | 776 | /** |
@@ -959,12 +964,12 @@ static void stmmac_clear_descriptors(struct stmmac_priv *priv) | |||
959 | } | 964 | } |
960 | 965 | ||
961 | static int stmmac_init_rx_buffers(struct stmmac_priv *priv, struct dma_desc *p, | 966 | static int stmmac_init_rx_buffers(struct stmmac_priv *priv, struct dma_desc *p, |
962 | int i) | 967 | int i, gfp_t flags) |
963 | { | 968 | { |
964 | struct sk_buff *skb; | 969 | struct sk_buff *skb; |
965 | 970 | ||
966 | skb = __netdev_alloc_skb(priv->dev, priv->dma_buf_sz + NET_IP_ALIGN, | 971 | skb = __netdev_alloc_skb(priv->dev, priv->dma_buf_sz + NET_IP_ALIGN, |
967 | GFP_KERNEL); | 972 | flags); |
968 | if (!skb) { | 973 | if (!skb) { |
969 | pr_err("%s: Rx init fails; skb is NULL\n", __func__); | 974 | pr_err("%s: Rx init fails; skb is NULL\n", __func__); |
970 | return -ENOMEM; | 975 | return -ENOMEM; |
@@ -1006,7 +1011,7 @@ static void stmmac_free_rx_buffers(struct stmmac_priv *priv, int i) | |||
1006 | * and allocates the socket buffers. It suppors the chained and ring | 1011 | * and allocates the socket buffers. It suppors the chained and ring |
1007 | * modes. | 1012 | * modes. |
1008 | */ | 1013 | */ |
1009 | static int init_dma_desc_rings(struct net_device *dev) | 1014 | static int init_dma_desc_rings(struct net_device *dev, gfp_t flags) |
1010 | { | 1015 | { |
1011 | int i; | 1016 | int i; |
1012 | struct stmmac_priv *priv = netdev_priv(dev); | 1017 | struct stmmac_priv *priv = netdev_priv(dev); |
@@ -1041,7 +1046,7 @@ static int init_dma_desc_rings(struct net_device *dev) | |||
1041 | else | 1046 | else |
1042 | p = priv->dma_rx + i; | 1047 | p = priv->dma_rx + i; |
1043 | 1048 | ||
1044 | ret = stmmac_init_rx_buffers(priv, p, i); | 1049 | ret = stmmac_init_rx_buffers(priv, p, i, flags); |
1045 | if (ret) | 1050 | if (ret) |
1046 | goto err_init_rx_buffers; | 1051 | goto err_init_rx_buffers; |
1047 | 1052 | ||
@@ -1647,11 +1652,6 @@ static int stmmac_hw_setup(struct net_device *dev) | |||
1647 | struct stmmac_priv *priv = netdev_priv(dev); | 1652 | struct stmmac_priv *priv = netdev_priv(dev); |
1648 | int ret; | 1653 | int ret; |
1649 | 1654 | ||
1650 | ret = init_dma_desc_rings(dev); | ||
1651 | if (ret < 0) { | ||
1652 | pr_err("%s: DMA descriptors initialization failed\n", __func__); | ||
1653 | return ret; | ||
1654 | } | ||
1655 | /* DMA initialization and SW reset */ | 1655 | /* DMA initialization and SW reset */ |
1656 | ret = stmmac_init_dma_engine(priv); | 1656 | ret = stmmac_init_dma_engine(priv); |
1657 | if (ret < 0) { | 1657 | if (ret < 0) { |
@@ -1705,10 +1705,6 @@ static int stmmac_hw_setup(struct net_device *dev) | |||
1705 | } | 1705 | } |
1706 | priv->tx_lpi_timer = STMMAC_DEFAULT_TWT_LS; | 1706 | priv->tx_lpi_timer = STMMAC_DEFAULT_TWT_LS; |
1707 | 1707 | ||
1708 | priv->eee_enabled = stmmac_eee_init(priv); | ||
1709 | |||
1710 | stmmac_init_tx_coalesce(priv); | ||
1711 | |||
1712 | if ((priv->use_riwt) && (priv->hw->dma->rx_watchdog)) { | 1708 | if ((priv->use_riwt) && (priv->hw->dma->rx_watchdog)) { |
1713 | priv->rx_riwt = MAX_DMA_RIWT; | 1709 | priv->rx_riwt = MAX_DMA_RIWT; |
1714 | priv->hw->dma->rx_watchdog(priv->ioaddr, MAX_DMA_RIWT); | 1710 | priv->hw->dma->rx_watchdog(priv->ioaddr, MAX_DMA_RIWT); |
@@ -1761,12 +1757,20 @@ static int stmmac_open(struct net_device *dev) | |||
1761 | goto dma_desc_error; | 1757 | goto dma_desc_error; |
1762 | } | 1758 | } |
1763 | 1759 | ||
1760 | ret = init_dma_desc_rings(dev, GFP_KERNEL); | ||
1761 | if (ret < 0) { | ||
1762 | pr_err("%s: DMA descriptors initialization failed\n", __func__); | ||
1763 | goto init_error; | ||
1764 | } | ||
1765 | |||
1764 | ret = stmmac_hw_setup(dev); | 1766 | ret = stmmac_hw_setup(dev); |
1765 | if (ret < 0) { | 1767 | if (ret < 0) { |
1766 | pr_err("%s: Hw setup failed\n", __func__); | 1768 | pr_err("%s: Hw setup failed\n", __func__); |
1767 | goto init_error; | 1769 | goto init_error; |
1768 | } | 1770 | } |
1769 | 1771 | ||
1772 | stmmac_init_tx_coalesce(priv); | ||
1773 | |||
1770 | if (priv->phydev) | 1774 | if (priv->phydev) |
1771 | phy_start(priv->phydev); | 1775 | phy_start(priv->phydev); |
1772 | 1776 | ||
@@ -1894,7 +1898,10 @@ static netdev_tx_t stmmac_xmit(struct sk_buff *skb, struct net_device *dev) | |||
1894 | unsigned int nopaged_len = skb_headlen(skb); | 1898 | unsigned int nopaged_len = skb_headlen(skb); |
1895 | unsigned int enh_desc = priv->plat->enh_desc; | 1899 | unsigned int enh_desc = priv->plat->enh_desc; |
1896 | 1900 | ||
1901 | spin_lock(&priv->tx_lock); | ||
1902 | |||
1897 | if (unlikely(stmmac_tx_avail(priv) < nfrags + 1)) { | 1903 | if (unlikely(stmmac_tx_avail(priv) < nfrags + 1)) { |
1904 | spin_unlock(&priv->tx_lock); | ||
1898 | if (!netif_queue_stopped(dev)) { | 1905 | if (!netif_queue_stopped(dev)) { |
1899 | netif_stop_queue(dev); | 1906 | netif_stop_queue(dev); |
1900 | /* This is a hard error, log it. */ | 1907 | /* This is a hard error, log it. */ |
@@ -1903,8 +1910,6 @@ static netdev_tx_t stmmac_xmit(struct sk_buff *skb, struct net_device *dev) | |||
1903 | return NETDEV_TX_BUSY; | 1910 | return NETDEV_TX_BUSY; |
1904 | } | 1911 | } |
1905 | 1912 | ||
1906 | spin_lock(&priv->tx_lock); | ||
1907 | |||
1908 | if (priv->tx_path_in_lpi_mode) | 1913 | if (priv->tx_path_in_lpi_mode) |
1909 | stmmac_disable_eee_mode(priv); | 1914 | stmmac_disable_eee_mode(priv); |
1910 | 1915 | ||
@@ -2025,6 +2030,7 @@ static netdev_tx_t stmmac_xmit(struct sk_buff *skb, struct net_device *dev) | |||
2025 | return NETDEV_TX_OK; | 2030 | return NETDEV_TX_OK; |
2026 | 2031 | ||
2027 | dma_map_err: | 2032 | dma_map_err: |
2033 | spin_unlock(&priv->tx_lock); | ||
2028 | dev_err(priv->device, "Tx dma map failed\n"); | 2034 | dev_err(priv->device, "Tx dma map failed\n"); |
2029 | dev_kfree_skb(skb); | 2035 | dev_kfree_skb(skb); |
2030 | priv->dev->stats.tx_dropped++; | 2036 | priv->dev->stats.tx_dropped++; |
@@ -2281,9 +2287,7 @@ static void stmmac_set_rx_mode(struct net_device *dev) | |||
2281 | { | 2287 | { |
2282 | struct stmmac_priv *priv = netdev_priv(dev); | 2288 | struct stmmac_priv *priv = netdev_priv(dev); |
2283 | 2289 | ||
2284 | spin_lock(&priv->lock); | ||
2285 | priv->hw->mac->set_filter(priv->hw, dev); | 2290 | priv->hw->mac->set_filter(priv->hw, dev); |
2286 | spin_unlock(&priv->lock); | ||
2287 | } | 2291 | } |
2288 | 2292 | ||
2289 | /** | 2293 | /** |
@@ -2950,7 +2954,7 @@ int stmmac_suspend(struct net_device *ndev) | |||
2950 | stmmac_set_mac(priv->ioaddr, false); | 2954 | stmmac_set_mac(priv->ioaddr, false); |
2951 | pinctrl_pm_select_sleep_state(priv->device); | 2955 | pinctrl_pm_select_sleep_state(priv->device); |
2952 | /* Disable clock in case of PWM is off */ | 2956 | /* Disable clock in case of PWM is off */ |
2953 | clk_disable_unprepare(priv->stmmac_clk); | 2957 | clk_disable(priv->stmmac_clk); |
2954 | } | 2958 | } |
2955 | spin_unlock_irqrestore(&priv->lock, flags); | 2959 | spin_unlock_irqrestore(&priv->lock, flags); |
2956 | 2960 | ||
@@ -2982,7 +2986,7 @@ int stmmac_resume(struct net_device *ndev) | |||
2982 | } else { | 2986 | } else { |
2983 | pinctrl_pm_select_default_state(priv->device); | 2987 | pinctrl_pm_select_default_state(priv->device); |
2984 | /* enable the clk prevously disabled */ | 2988 | /* enable the clk prevously disabled */ |
2985 | clk_prepare_enable(priv->stmmac_clk); | 2989 | clk_enable(priv->stmmac_clk); |
2986 | /* reset the phy so that it's ready */ | 2990 | /* reset the phy so that it's ready */ |
2987 | if (priv->mii) | 2991 | if (priv->mii) |
2988 | stmmac_mdio_reset(priv->mii); | 2992 | stmmac_mdio_reset(priv->mii); |
@@ -2990,7 +2994,9 @@ int stmmac_resume(struct net_device *ndev) | |||
2990 | 2994 | ||
2991 | netif_device_attach(ndev); | 2995 | netif_device_attach(ndev); |
2992 | 2996 | ||
2997 | init_dma_desc_rings(ndev, GFP_ATOMIC); | ||
2993 | stmmac_hw_setup(ndev); | 2998 | stmmac_hw_setup(ndev); |
2999 | stmmac_init_tx_coalesce(priv); | ||
2994 | 3000 | ||
2995 | napi_enable(&priv->napi); | 3001 | napi_enable(&priv->napi); |
2996 | 3002 | ||
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c index db56fa7ce8f9..5b0da3986216 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c | |||
@@ -177,12 +177,6 @@ static int stmmac_probe_config_dt(struct platform_device *pdev, | |||
177 | */ | 177 | */ |
178 | plat->maxmtu = JUMBO_LEN; | 178 | plat->maxmtu = JUMBO_LEN; |
179 | 179 | ||
180 | /* Set default value for multicast hash bins */ | ||
181 | plat->multicast_filter_bins = HASH_TABLE_SIZE; | ||
182 | |||
183 | /* Set default value for unicast filter entries */ | ||
184 | plat->unicast_filter_entries = 1; | ||
185 | |||
186 | /* | 180 | /* |
187 | * Currently only the properties needed on SPEAr600 | 181 | * Currently only the properties needed on SPEAr600 |
188 | * are provided. All other properties should be added | 182 | * are provided. All other properties should be added |
@@ -270,6 +264,13 @@ static int stmmac_pltfr_probe(struct platform_device *pdev) | |||
270 | return PTR_ERR(addr); | 264 | return PTR_ERR(addr); |
271 | 265 | ||
272 | plat_dat = dev_get_platdata(&pdev->dev); | 266 | plat_dat = dev_get_platdata(&pdev->dev); |
267 | |||
268 | /* Set default value for multicast hash bins */ | ||
269 | plat_dat->multicast_filter_bins = HASH_TABLE_SIZE; | ||
270 | |||
271 | /* Set default value for unicast filter entries */ | ||
272 | plat_dat->unicast_filter_entries = 1; | ||
273 | |||
273 | if (pdev->dev.of_node) { | 274 | if (pdev->dev.of_node) { |
274 | if (!plat_dat) | 275 | if (!plat_dat) |
275 | plat_dat = devm_kzalloc(&pdev->dev, | 276 | plat_dat = devm_kzalloc(&pdev->dev, |