Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'stmmac-multi-queue-fixes-and-cleanups'

Niklas Cassel says:

====================
stmmac multi-queue fixes and cleanups
====================

Reviewed-by: Jose Abreu <joabreu@synopsys.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

+42 -23
+3 -3
drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
··· 120 120 writel(value, ioaddr + base_register); 121 121 } 122 122 123 - static void dwmac4_tx_queue_routing(struct mac_device_info *hw, 123 + static void dwmac4_rx_queue_routing(struct mac_device_info *hw, 124 124 u8 packet, u32 queue) 125 125 { 126 126 void __iomem *ioaddr = hw->pcsr; ··· 713 713 .rx_queue_enable = dwmac4_rx_queue_enable, 714 714 .rx_queue_prio = dwmac4_rx_queue_priority, 715 715 .tx_queue_prio = dwmac4_tx_queue_priority, 716 - .rx_queue_routing = dwmac4_tx_queue_routing, 716 + .rx_queue_routing = dwmac4_rx_queue_routing, 717 717 .prog_mtl_rx_algorithms = dwmac4_prog_mtl_rx_algorithms, 718 718 .prog_mtl_tx_algorithms = dwmac4_prog_mtl_tx_algorithms, 719 719 .set_mtl_tx_queue_weight = dwmac4_set_mtl_tx_queue_weight, ··· 744 744 .rx_queue_enable = dwmac4_rx_queue_enable, 745 745 .rx_queue_prio = dwmac4_rx_queue_priority, 746 746 .tx_queue_prio = dwmac4_tx_queue_priority, 747 - .rx_queue_routing = dwmac4_tx_queue_routing, 747 + .rx_queue_routing = dwmac4_rx_queue_routing, 748 748 .prog_mtl_rx_algorithms = dwmac4_prog_mtl_rx_algorithms, 749 749 .prog_mtl_tx_algorithms = dwmac4_prog_mtl_tx_algorithms, 750 750 .set_mtl_tx_queue_weight = dwmac4_set_mtl_tx_queue_weight,
+1 -1
drivers/net/ethernet/stmicro/stmmac/stmmac.h
··· 58 58 unsigned int dirty_tx; 59 59 dma_addr_t dma_tx_phy; 60 60 u32 tx_tail_addr; 61 + u32 mss; 61 62 }; 62 63 63 64 struct stmmac_rx_queue { ··· 139 138 spinlock_t ptp_lock; 140 139 void __iomem *mmcaddr; 141 140 void __iomem *ptpaddr; 142 - u32 mss; 143 141 144 142 #ifdef CONFIG_DEBUG_FS 145 143 struct dentry *dbgfs_dir;
+11 -12
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
··· 1355 1355 1356 1356 tx_q->dirty_tx = 0; 1357 1357 tx_q->cur_tx = 0; 1358 + tx_q->mss = 0; 1358 1359 1359 1360 netdev_tx_reset_queue(netdev_get_tx_queue(priv->dev, queue)); 1360 1361 } ··· 1947 1946 (i == DMA_TX_SIZE - 1)); 1948 1947 tx_q->dirty_tx = 0; 1949 1948 tx_q->cur_tx = 0; 1949 + tx_q->mss = 0; 1950 1950 netdev_tx_reset_queue(netdev_get_tx_queue(priv->dev, chan)); 1951 1951 stmmac_start_tx_dma(priv, chan); 1952 1952 ··· 2432 2430 continue; 2433 2431 2434 2432 packet = priv->plat->rx_queues_cfg[queue].pkt_route; 2435 - priv->hw->mac->rx_queue_prio(priv->hw, packet, queue); 2433 + priv->hw->mac->rx_queue_routing(priv->hw, packet, queue); 2436 2434 } 2437 2435 } 2438 2436 ··· 2634 2632 2635 2633 priv->dma_buf_sz = STMMAC_ALIGN(buf_sz); 2636 2634 priv->rx_copybreak = STMMAC_RX_COPYBREAK; 2637 - priv->mss = 0; 2638 2635 2639 2636 ret = alloc_dma_desc_resources(priv); 2640 2637 if (ret < 0) { ··· 2794 2793 2795 2794 while (tmp_len > 0) { 2796 2795 tx_q->cur_tx = STMMAC_GET_ENTRY(tx_q->cur_tx, DMA_TX_SIZE); 2796 + WARN_ON(tx_q->tx_skbuff[tx_q->cur_tx]); 2797 2797 desc = tx_q->dma_tx + tx_q->cur_tx; 2798 2798 2799 2799 desc->des0 = cpu_to_le32(des + (total_len - tmp_len)); ··· 2874 2872 mss = skb_shinfo(skb)->gso_size; 2875 2873 2876 2874 /* set new MSS value if needed */ 2877 - if (mss != priv->mss) { 2875 + if (mss != tx_q->mss) { 2878 2876 mss_desc = tx_q->dma_tx + tx_q->cur_tx; 2879 2877 priv->hw->desc->set_mss(mss_desc, mss); 2880 - priv->mss = mss; 2878 + tx_q->mss = mss; 2881 2879 tx_q->cur_tx = STMMAC_GET_ENTRY(tx_q->cur_tx, DMA_TX_SIZE); 2880 + WARN_ON(tx_q->tx_skbuff[tx_q->cur_tx]); 2882 2881 } 2883 2882 2884 2883 if (netif_msg_tx_queued(priv)) { ··· 2890 2887 } 2891 2888 2892 2889 first_entry = tx_q->cur_tx; 2890 + WARN_ON(tx_q->tx_skbuff[first_entry]); 2893 2891 2894 2892 desc = tx_q->dma_tx + first_entry; 2895 2893 first = desc; ··· 2930 2926 2931 2927 tx_q->tx_skbuff_dma[tx_q->cur_tx].buf = des; 2932 2928 tx_q->tx_skbuff_dma[tx_q->cur_tx].len = skb_frag_size(frag); 2933 - tx_q->tx_skbuff[tx_q->cur_tx] = NULL; 2934 2929 tx_q->tx_skbuff_dma[tx_q->cur_tx].map_as_page = true; 2935 2930 } 2936 2931 ··· 3065 3062 3066 3063 entry = tx_q->cur_tx; 3067 3064 first_entry = entry; 3065 + WARN_ON(tx_q->tx_skbuff[first_entry]); 3068 3066 3069 3067 csum_insertion = (skb->ip_summed == CHECKSUM_PARTIAL); 3070 3068 ··· 3094 3090 bool last_segment = (i == (nfrags - 1)); 3095 3091 3096 3092 entry = STMMAC_GET_ENTRY(entry, DMA_TX_SIZE); 3093 + WARN_ON(tx_q->tx_skbuff[entry]); 3097 3094 3098 3095 if (likely(priv->extend_desc)) 3099 3096 desc = (struct dma_desc *)(tx_q->dma_etx + entry); ··· 3105 3100 DMA_TO_DEVICE); 3106 3101 if (dma_mapping_error(priv->device, des)) 3107 3102 goto dma_map_err; /* should reuse desc w/o issues */ 3108 - 3109 - tx_q->tx_skbuff[entry] = NULL; 3110 3103 3111 3104 tx_q->tx_skbuff_dma[entry].buf = des; 3112 3105 if (unlikely(priv->synopsys_id >= DWMAC_CORE_4_00)) ··· 4439 4436 4440 4437 tx_q->cur_tx = 0; 4441 4438 tx_q->dirty_tx = 0; 4439 + tx_q->mss = 0; 4442 4440 } 4443 4441 } 4444 4442 ··· 4484 4480 spin_lock_irqsave(&priv->lock, flags); 4485 4481 4486 4482 stmmac_reset_queues_param(priv); 4487 - 4488 - /* reset private mss value to force mss context settings at 4489 - * next tso xmit (only used for gmac4). 4490 - */ 4491 - priv->mss = 0; 4492 4483 4493 4484 stmmac_clear_descriptors(priv); 4494 4485
+27 -7
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
··· 135 135 * stmmac_mtl_setup - parse DT parameters for multiple queues configuration 136 136 * @pdev: platform device 137 137 */ 138 - static void stmmac_mtl_setup(struct platform_device *pdev, 139 - struct plat_stmmacenet_data *plat) 138 + static int stmmac_mtl_setup(struct platform_device *pdev, 139 + struct plat_stmmacenet_data *plat) 140 140 { 141 141 struct device_node *q_node; 142 142 struct device_node *rx_node; 143 143 struct device_node *tx_node; 144 144 u8 queue = 0; 145 + int ret = 0; 145 146 146 147 /* For backwards-compatibility with device trees that don't have any 147 148 * snps,mtl-rx-config or snps,mtl-tx-config properties, we fall back ··· 160 159 161 160 rx_node = of_parse_phandle(pdev->dev.of_node, "snps,mtl-rx-config", 0); 162 161 if (!rx_node) 163 - return; 162 + return ret; 164 163 165 164 tx_node = of_parse_phandle(pdev->dev.of_node, "snps,mtl-tx-config", 0); 166 165 if (!tx_node) { 167 166 of_node_put(rx_node); 168 - return; 167 + return ret; 169 168 } 170 169 171 170 /* Processing RX queues common config */ ··· 220 219 plat->rx_queues_cfg[queue].pkt_route = 0x0; 221 220 222 221 queue++; 222 + } 223 + if (queue != plat->rx_queues_to_use) { 224 + ret = -EINVAL; 225 + dev_err(&pdev->dev, "Not all RX queues were configured\n"); 226 + goto out; 223 227 } 224 228 225 229 /* Processing TX queues common config */ ··· 287 281 288 282 queue++; 289 283 } 284 + if (queue != plat->tx_queues_to_use) { 285 + ret = -EINVAL; 286 + dev_err(&pdev->dev, "Not all TX queues were configured\n"); 287 + goto out; 288 + } 290 289 290 + out: 291 291 of_node_put(rx_node); 292 292 of_node_put(tx_node); 293 293 of_node_put(q_node); 294 + 295 + return ret; 294 296 } 295 297 296 298 /** ··· 390 376 struct device_node *np = pdev->dev.of_node; 391 377 struct plat_stmmacenet_data *plat; 392 378 struct stmmac_dma_cfg *dma_cfg; 379 + int rc; 393 380 394 381 plat = devm_kzalloc(&pdev->dev, sizeof(*plat), GFP_KERNEL); 395 382 if (!plat) ··· 417 402 dev_warn(&pdev->dev, "snps,phy-addr property is deprecated\n"); 418 403 419 404 /* To Configure PHY by using all device-tree supported properties */ 420 - if (stmmac_dt_phy(plat, np, &pdev->dev)) 421 - return ERR_PTR(-ENODEV); 405 + rc = stmmac_dt_phy(plat, np, &pdev->dev); 406 + if (rc) 407 + return ERR_PTR(rc); 422 408 423 409 of_property_read_u32(np, "tx-fifo-depth", &plat->tx_fifo_size); 424 410 ··· 515 499 516 500 plat->axi = stmmac_axi_setup(pdev); 517 501 518 - stmmac_mtl_setup(pdev, plat); 502 + rc = stmmac_mtl_setup(pdev, plat); 503 + if (rc) { 504 + stmmac_remove_config_dt(pdev, plat); 505 + return ERR_PTR(rc); 506 + } 519 507 520 508 /* clock setup */ 521 509 plat->stmmac_clk = devm_clk_get(&pdev->dev,