mirror of
https://github.com/openwrt/openwrt.git
synced 2024-12-22 23:12:32 +00:00
521efb62eb
6c256218e59e wifi: mt76: dma: use napi_build_skb 679254c50f27 mt7915: add CONFIG_MT76_LEDS to cflags 15b9dd6b1b6a wifi: mt76: mt7915: call mt7915_mcu_set_thermal_throttling() only after init_work 8e5c21fe7c5c wifi: mt76: mt7915: rework mt7915_mcu_set_thermal_throttling 87cb74fe42d9 wifi: mt76: mt7915: rework mt7915_thermal_temp_store() c6f24b83eba5 wifi: mt76: mt7915: add error message in mt7915_thermal_set_cur_throttle_state() 99e96b89ee4d wifi: mt76: mt7915: add chip id condition in mt7915_check_eeprom() 833cd420480f wifi: mt76: mt7921: fix channel switch fail in monitor mode f1f8bae6092d wifi: mt76: mt7921: add ack signal support f47087a6dd62 wifi: mt76: mt7996: fix chainmask calculation in mt7996_set_antenna() 2f3b0acc1588 wifi: mt76: mt7996: update register for CFEND_RATE 7e9540dcbd70 wifi: mt76: mt7996: do not hardcode vht beamform cap a37e427d0959 wifi: mt76: connac: fix POWER_CTRL command name typo 98aa346042bd wifi: mt76: mt7915: remove BW160 and BW80+80 support 94fed6a43541 wifi: mt76: mt7921: fix invalid remain_on_channel duration 3c162384d80a wifi: mt76: introduce mt76_queue_is_wed_rx utility routine a409a9454587 wifi: mt76: mt7915: fix memory leak in mt7915_mcu_exit 8b27ecd3a684 wifi: mt76: mt7996: fix memory leak in mt7996_mcu_exit 683760461dd0 wifi: mt76: dma: free rx_head in mt76_dma_rx_cleanup 0c750cf08f85 wifi: mt76: dma: fix memory leak running mt76_dma_tx_cleanup 5de9ae29bea2 wifi: mt76: mt7915: avoid mcu_restart function pointer dad96dd3e62d wifi: mt76: mt7603: avoid mcu_restart function pointer 19d36dd9c8ea wifi: mt76: mt7615: avoid mcu_restart function pointer 6fe2c2383d3d wifi: mt76: mt7921: avoid mcu_restart function pointer 9df89143bf71 wifi: mt76: mt7915: get rid of wed rx_buf_ring page_frag_cache 8d51d11760cb wifi: mt76: fix switch default case in mt7996_reverse_frag0_hdr_trans 0d8057dbd51c wifi: mt76: mt7921u: add support for Comfast CF-952AX ddbf4e933d54 wifi: mt76: mt7915: set sku initial value to zero 06a8904e954e wifi: mt76: mt7915: wed: enable red per-band token drop 724a337caef9 wifi: mt76: mt7915: fix WED TxS reporting 747ca943a5bb wifi: mt76: add flexible polling wait-interval support 133d7859977a wifi: mt76: mt7921: reduce polling time in pmctrl 5fe319a0550e wifi: mt76: add memory barrier to SDIO queue kick 822f060b9d19 wifi: mt76: mt7921: fix rx filter incorrect by drv/fw inconsistent c6794954a723 wifi: mt76: mt7915: fix memory leak in mt7915_mmio_wed_init_rx_buf 9686cd7cc65c wifi: mt76: switch to page_pool allocator 04da4eaa8235 wifi: mt76: enable page_pool stats 1af4a911ebcb wifi: mt76: mt7915: release rxwi in mt7915_wed_release_rx_buf e8c10835cf06 wifi: mt76: fix compile error without CONFIG_PAGE_POOL_STATS 0cf0ede7cc42 net: ethernet: mtk_wed: add reset to rx_ring_setup callback 715b3ed9708a net: ethernet: mtk_wed: add reset to tx_ring_setup callback 9107381d0ff3 wifi: mt76: mt7921: fix error code of return in mt7921_acpi_read 36d2a5bf7802 wifi: mt76: mt7996: rely on mt76_connac2_mac_tx_rate_val c67f57d2cda2 wifi: mt76: dma: add reset to mt76_dma_wed_setup signature 3dace36e2941 wifi: mt76: dma: reset wed queues in mt76_dma_rx_reset 4b229d2da562 wifi: mt76: mt7915: add mt7915 wed reset callbacks f83958376085 wifi: mt76: mt7915: complete wed reset support 321edbb414dc wifi: mt76: mt7996: rely on mt76_connac_txp_common structure bdb7dc38a6d1 wifi: mt76: mt7996: rely on mt76_connac_txp_skb_unmap 8688756305c6 wifi: mt76: mt7996: rely on mt76_connac_tx_complete_skb fbf986dbd4c0 wifi: mt76: mt7996: rely on mt76_connac2_mac_decode_he_radiotap adc556cbce37 wifi: mt76: mt7996: avoid mcu_restart function pointer 5eb4e2303be4 wifi: mt76: remove __mt76_mcu_restart macro e7a61c5f70f5 wifi: mt76: add EHT phy type b375845abc10 wifi: mt76: connac: add CMD_CBW_320MHZ 68b17a243332 wifi: mt76: connac: add helpers for EHT capability 02ec1f61b3a2 wifi: mt76: connac: add cmd id related to EHT support 9209294cd81b wifi: mt76: increase wcid size to 1088 5e85136c9b2f wifi: mt76: add EHT rate stats for ethtool a171f672fdeb wifi: mt76: mt7996: add variants support eda8fd62c105 wifi: mt76: mt7996: add helpers for wtbl and interface limit 4a5a9f4cdc3b wifi: mt76: mt7996: rework capability init 06b73c155680 wifi: mt76: mt7996: add EHT capability init ae71a1b8294f wifi: mt76: mt7996: add support for EHT rate report 65bdfae2991d wifi: mt76: mt7996: enable EHT support in firmware b2360d59747c wifi: mt76: mt7996: add EHT beamforming support Signed-off-by: Felix Fietkau <nbd@nbd.name>
263 lines
7.5 KiB
Diff
263 lines
7.5 KiB
Diff
From: Lorenzo Bianconi <lorenzo@kernel.org>
|
|
Date: Sat, 14 Jan 2023 18:01:30 +0100
|
|
Subject: [PATCH] net: ethernet: mtk_eth_soc: align reset procedure to vendor
|
|
sdk
|
|
|
|
Avoid to power-down the ethernet chip during hw reset and align reset
|
|
procedure to vendor sdk.
|
|
|
|
Reviewed-by: Leon Romanovsky <leonro@nvidia.com>
|
|
Tested-by: Daniel Golle <daniel@makrotopia.org>
|
|
Co-developed-by: Sujuan Chen <sujuan.chen@mediatek.com>
|
|
Signed-off-by: Sujuan Chen <sujuan.chen@mediatek.com>
|
|
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
|
|
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
|
---
|
|
|
|
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
|
|
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
|
|
@@ -2785,14 +2785,29 @@ static void mtk_dma_free(struct mtk_eth
|
|
kfree(eth->scratch_head);
|
|
}
|
|
|
|
+static bool mtk_hw_reset_check(struct mtk_eth *eth)
|
|
+{
|
|
+ u32 val = mtk_r32(eth, MTK_INT_STATUS2);
|
|
+
|
|
+ return (val & MTK_FE_INT_FQ_EMPTY) || (val & MTK_FE_INT_RFIFO_UF) ||
|
|
+ (val & MTK_FE_INT_RFIFO_OV) || (val & MTK_FE_INT_TSO_FAIL) ||
|
|
+ (val & MTK_FE_INT_TSO_ALIGN) || (val & MTK_FE_INT_TSO_ILLEGAL);
|
|
+}
|
|
+
|
|
static void mtk_tx_timeout(struct net_device *dev, unsigned int txqueue)
|
|
{
|
|
struct mtk_mac *mac = netdev_priv(dev);
|
|
struct mtk_eth *eth = mac->hw;
|
|
|
|
+ if (test_bit(MTK_RESETTING, ð->state))
|
|
+ return;
|
|
+
|
|
+ if (!mtk_hw_reset_check(eth))
|
|
+ return;
|
|
+
|
|
eth->netdev[mac->id]->stats.tx_errors++;
|
|
- netif_err(eth, tx_err, dev,
|
|
- "transmit timed out\n");
|
|
+ netif_err(eth, tx_err, dev, "transmit timed out\n");
|
|
+
|
|
schedule_work(ð->pending_work);
|
|
}
|
|
|
|
@@ -3274,15 +3289,17 @@ static int mtk_hw_init(struct mtk_eth *e
|
|
const struct mtk_reg_map *reg_map = eth->soc->reg_map;
|
|
int i, val, ret;
|
|
|
|
- if (test_and_set_bit(MTK_HW_INIT, ð->state))
|
|
+ if (!reset && test_and_set_bit(MTK_HW_INIT, ð->state))
|
|
return 0;
|
|
|
|
- pm_runtime_enable(eth->dev);
|
|
- pm_runtime_get_sync(eth->dev);
|
|
+ if (!reset) {
|
|
+ pm_runtime_enable(eth->dev);
|
|
+ pm_runtime_get_sync(eth->dev);
|
|
|
|
- ret = mtk_clk_enable(eth);
|
|
- if (ret)
|
|
- goto err_disable_pm;
|
|
+ ret = mtk_clk_enable(eth);
|
|
+ if (ret)
|
|
+ goto err_disable_pm;
|
|
+ }
|
|
|
|
if (eth->ethsys)
|
|
regmap_update_bits(eth->ethsys, ETHSYS_DMA_AG_MAP, dma_mask,
|
|
@@ -3408,8 +3425,10 @@ static int mtk_hw_init(struct mtk_eth *e
|
|
return 0;
|
|
|
|
err_disable_pm:
|
|
- pm_runtime_put_sync(eth->dev);
|
|
- pm_runtime_disable(eth->dev);
|
|
+ if (!reset) {
|
|
+ pm_runtime_put_sync(eth->dev);
|
|
+ pm_runtime_disable(eth->dev);
|
|
+ }
|
|
|
|
return ret;
|
|
}
|
|
@@ -3488,30 +3507,53 @@ static int mtk_do_ioctl(struct net_devic
|
|
return -EOPNOTSUPP;
|
|
}
|
|
|
|
+static void mtk_prepare_for_reset(struct mtk_eth *eth)
|
|
+{
|
|
+ u32 val;
|
|
+ int i;
|
|
+
|
|
+ /* disabe FE P3 and P4 */
|
|
+ val = mtk_r32(eth, MTK_FE_GLO_CFG) | MTK_FE_LINK_DOWN_P3;
|
|
+ if (MTK_HAS_CAPS(eth->soc->caps, MTK_RSTCTRL_PPE1))
|
|
+ val |= MTK_FE_LINK_DOWN_P4;
|
|
+ mtk_w32(eth, val, MTK_FE_GLO_CFG);
|
|
+
|
|
+ /* adjust PPE configurations to prepare for reset */
|
|
+ for (i = 0; i < ARRAY_SIZE(eth->ppe); i++)
|
|
+ mtk_ppe_prepare_reset(eth->ppe[i]);
|
|
+
|
|
+ /* disable NETSYS interrupts */
|
|
+ mtk_w32(eth, 0, MTK_FE_INT_ENABLE);
|
|
+
|
|
+ /* force link down GMAC */
|
|
+ for (i = 0; i < 2; i++) {
|
|
+ val = mtk_r32(eth, MTK_MAC_MCR(i)) & ~MAC_MCR_FORCE_LINK;
|
|
+ mtk_w32(eth, val, MTK_MAC_MCR(i));
|
|
+ }
|
|
+}
|
|
+
|
|
static void mtk_pending_work(struct work_struct *work)
|
|
{
|
|
struct mtk_eth *eth = container_of(work, struct mtk_eth, pending_work);
|
|
- int err, i;
|
|
unsigned long restart = 0;
|
|
+ u32 val;
|
|
+ int i;
|
|
|
|
rtnl_lock();
|
|
-
|
|
- dev_dbg(eth->dev, "[%s][%d] reset\n", __func__, __LINE__);
|
|
set_bit(MTK_RESETTING, ð->state);
|
|
|
|
+ mtk_prepare_for_reset(eth);
|
|
+
|
|
/* stop all devices to make sure that dma is properly shut down */
|
|
for (i = 0; i < MTK_MAC_COUNT; i++) {
|
|
- if (!eth->netdev[i])
|
|
+ if (!eth->netdev[i] || !netif_running(eth->netdev[i]))
|
|
continue;
|
|
+
|
|
mtk_stop(eth->netdev[i]);
|
|
__set_bit(i, &restart);
|
|
}
|
|
- dev_dbg(eth->dev, "[%s][%d] mtk_stop ends\n", __func__, __LINE__);
|
|
|
|
- /* restart underlying hardware such as power, clock, pin mux
|
|
- * and the connected phy
|
|
- */
|
|
- mtk_hw_deinit(eth);
|
|
+ usleep_range(15000, 16000);
|
|
|
|
if (eth->dev->pins)
|
|
pinctrl_select_state(eth->dev->pins->p,
|
|
@@ -3522,15 +3564,19 @@ static void mtk_pending_work(struct work
|
|
for (i = 0; i < MTK_MAC_COUNT; i++) {
|
|
if (!test_bit(i, &restart))
|
|
continue;
|
|
- err = mtk_open(eth->netdev[i]);
|
|
- if (err) {
|
|
+
|
|
+ if (mtk_open(eth->netdev[i])) {
|
|
netif_alert(eth, ifup, eth->netdev[i],
|
|
- "Driver up/down cycle failed, closing device.\n");
|
|
+ "Driver up/down cycle failed\n");
|
|
dev_close(eth->netdev[i]);
|
|
}
|
|
}
|
|
|
|
- dev_dbg(eth->dev, "[%s][%d] reset done\n", __func__, __LINE__);
|
|
+ /* enabe FE P3 and P4 */
|
|
+ val = mtk_r32(eth, MTK_FE_GLO_CFG) & ~MTK_FE_LINK_DOWN_P3;
|
|
+ if (MTK_HAS_CAPS(eth->soc->caps, MTK_RSTCTRL_PPE1))
|
|
+ val &= ~MTK_FE_LINK_DOWN_P4;
|
|
+ mtk_w32(eth, val, MTK_FE_GLO_CFG);
|
|
|
|
clear_bit(MTK_RESETTING, ð->state);
|
|
|
|
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.h
|
|
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.h
|
|
@@ -72,12 +72,24 @@
|
|
#define MTK_HW_LRO_REPLACE_DELTA 1000
|
|
#define MTK_HW_LRO_SDL_REMAIN_ROOM 1522
|
|
|
|
+/* Frame Engine Global Configuration */
|
|
+#define MTK_FE_GLO_CFG 0x00
|
|
+#define MTK_FE_LINK_DOWN_P3 BIT(11)
|
|
+#define MTK_FE_LINK_DOWN_P4 BIT(12)
|
|
+
|
|
/* Frame Engine Global Reset Register */
|
|
#define MTK_RST_GL 0x04
|
|
#define RST_GL_PSE BIT(0)
|
|
|
|
/* Frame Engine Interrupt Status Register */
|
|
#define MTK_INT_STATUS2 0x08
|
|
+#define MTK_FE_INT_ENABLE 0x0c
|
|
+#define MTK_FE_INT_FQ_EMPTY BIT(8)
|
|
+#define MTK_FE_INT_TSO_FAIL BIT(12)
|
|
+#define MTK_FE_INT_TSO_ILLEGAL BIT(13)
|
|
+#define MTK_FE_INT_TSO_ALIGN BIT(14)
|
|
+#define MTK_FE_INT_RFIFO_OV BIT(18)
|
|
+#define MTK_FE_INT_RFIFO_UF BIT(19)
|
|
#define MTK_GDM1_AF BIT(28)
|
|
#define MTK_GDM2_AF BIT(29)
|
|
|
|
--- a/drivers/net/ethernet/mediatek/mtk_ppe.c
|
|
+++ b/drivers/net/ethernet/mediatek/mtk_ppe.c
|
|
@@ -716,6 +716,33 @@ int mtk_foe_entry_idle_time(struct mtk_p
|
|
return __mtk_foe_entry_idle_time(ppe, entry->data.ib1);
|
|
}
|
|
|
|
+int mtk_ppe_prepare_reset(struct mtk_ppe *ppe)
|
|
+{
|
|
+ if (!ppe)
|
|
+ return -EINVAL;
|
|
+
|
|
+ /* disable KA */
|
|
+ ppe_clear(ppe, MTK_PPE_TB_CFG, MTK_PPE_TB_CFG_KEEPALIVE);
|
|
+ ppe_clear(ppe, MTK_PPE_BIND_LMT1, MTK_PPE_NTU_KEEPALIVE);
|
|
+ ppe_w32(ppe, MTK_PPE_KEEPALIVE, 0);
|
|
+ usleep_range(10000, 11000);
|
|
+
|
|
+ /* set KA timer to maximum */
|
|
+ ppe_set(ppe, MTK_PPE_BIND_LMT1, MTK_PPE_NTU_KEEPALIVE);
|
|
+ ppe_w32(ppe, MTK_PPE_KEEPALIVE, 0xffffffff);
|
|
+
|
|
+ /* set KA tick select */
|
|
+ ppe_set(ppe, MTK_PPE_TB_CFG, MTK_PPE_TB_TICK_SEL);
|
|
+ ppe_set(ppe, MTK_PPE_TB_CFG, MTK_PPE_TB_CFG_KEEPALIVE);
|
|
+ usleep_range(10000, 11000);
|
|
+
|
|
+ /* disable scan mode */
|
|
+ ppe_clear(ppe, MTK_PPE_TB_CFG, MTK_PPE_TB_CFG_SCAN_MODE);
|
|
+ usleep_range(10000, 11000);
|
|
+
|
|
+ return mtk_ppe_wait_busy(ppe);
|
|
+}
|
|
+
|
|
struct mtk_ppe *mtk_ppe_init(struct mtk_eth *eth, void __iomem *base,
|
|
int version, int index)
|
|
{
|
|
--- a/drivers/net/ethernet/mediatek/mtk_ppe.h
|
|
+++ b/drivers/net/ethernet/mediatek/mtk_ppe.h
|
|
@@ -306,6 +306,7 @@ struct mtk_ppe *mtk_ppe_init(struct mtk_
|
|
int version, int index);
|
|
void mtk_ppe_start(struct mtk_ppe *ppe);
|
|
int mtk_ppe_stop(struct mtk_ppe *ppe);
|
|
+int mtk_ppe_prepare_reset(struct mtk_ppe *ppe);
|
|
|
|
void __mtk_ppe_check_skb(struct mtk_ppe *ppe, struct sk_buff *skb, u16 hash);
|
|
|
|
--- a/drivers/net/ethernet/mediatek/mtk_ppe_regs.h
|
|
+++ b/drivers/net/ethernet/mediatek/mtk_ppe_regs.h
|
|
@@ -58,6 +58,12 @@
|
|
#define MTK_PPE_TB_CFG_SCAN_MODE GENMASK(17, 16)
|
|
#define MTK_PPE_TB_CFG_HASH_DEBUG GENMASK(19, 18)
|
|
#define MTK_PPE_TB_CFG_INFO_SEL BIT(20)
|
|
+#define MTK_PPE_TB_TICK_SEL BIT(24)
|
|
+
|
|
+#define MTK_PPE_BIND_LMT1 0x230
|
|
+#define MTK_PPE_NTU_KEEPALIVE GENMASK(23, 16)
|
|
+
|
|
+#define MTK_PPE_KEEPALIVE 0x234
|
|
|
|
enum {
|
|
MTK_PPE_SCAN_MODE_DISABLED,
|