From 6ceeba47d874eb02fec221c7c60bf5ad53379bd2 Mon Sep 17 00:00:00 2001 From: Huangjie Date: Thu, 17 Oct 2024 17:18:03 +0800 Subject: [PATCH 01/26] pci: ep: phytium epc driver compatible with pd2008 Signed-off-by: Huangjie --- drivers/pci/controller/pcie-phytium-ep.c | 35 +++++++++++++++++++----- drivers/pci/controller/pcie-phytium-ep.h | 7 +++++ 2 files changed, 35 insertions(+), 7 deletions(-) diff --git a/drivers/pci/controller/pcie-phytium-ep.c b/drivers/pci/controller/pcie-phytium-ep.c index 816ed10a66b..70944cb0db7 100644 --- a/drivers/pci/controller/pcie-phytium-ep.c +++ b/drivers/pci/controller/pcie-phytium-ep.c @@ -341,12 +341,31 @@ static const struct pci_epc_ops phytium_pcie_epc_ops = { .start = phytium_pcie_ep_start, }; +static const struct phytium_pcie_ep_config pd2008_pcie_ep_config = +{ + .hpb_perf_base_limit_offs = 0xA30, +}; +static const struct phytium_pcie_ep_config pe2204_pcie_ep_config = +{ + .hpb_perf_base_limit_offs = 0xA40, +}; + +static const struct of_device_id phytium_pcie_ep_of_match[] = { + { .compatible = "phytium,pd2008-pcie-ep", + .data = &pd2008_pcie_ep_config }, + { .compatible = "phytium,pe2204-pcie-ep", + .data = &pe2204_pcie_ep_config }, + { }, +}; static int phytium_pcie_ep_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; + const struct of_device_id *match = NULL; struct phytium_pcie_ep *priv = NULL; + const struct phytium_pcie_ep_config *pcie_ep_config = + &pe2204_pcie_ep_config; struct resource *res; struct device_node *np = dev->of_node; struct pci_epc *epc; @@ -357,6 +376,13 @@ static int phytium_pcie_ep_probe(struct platform_device *pdev) if (!priv) return -ENOMEM; + match = of_match_node(phytium_pcie_ep_of_match, pdev->dev.of_node); + if (match && match->data) { + pcie_ep_config = match->data; + } + priv->hpb_perf_base_limit_offs = + pcie_ep_config->hpb_perf_base_limit_offs; + res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "reg"); priv->reg_base = devm_ioremap_resource(dev, res); if (IS_ERR(priv->reg_base)) { @@ -428,13 +454,13 @@ static int phytium_pcie_ep_probe(struct platform_device *pdev) & C0_PREF_BASE_MASK) << C0_PREF_BASE_SHIFT; value |= (((lower_32_bits(priv->mem_res->end) >> C0_PREF_VALUE_SHIFT) & C0_PREF_LIMIT_MASK) << C0_PREF_LIMIT_SHIFT); - phytium_hpb_writel(priv, PHYTIUM_HPB_C0_PREF_BASE_LIMIT, value); + phytium_hpb_writel(priv, priv->hpb_perf_base_limit_offs, value); value = ((upper_32_bits(priv->mem_res->start) >> C0_PREF_UP32_VALUE_SHIFT) & C0_PREF_BASE_UP32_MASK) << C0_PREF_BASE_UP32_SHIFT; value |= (((upper_32_bits(priv->mem_res->end) >> C0_PREF_UP32_VALUE_SHIFT) & C0_PREF_LIMIT_UP32_MASK) << C0_PREF_LIMIT_UP32_SHIFT); - phytium_hpb_writel(priv, PHYTIUM_HPB_C0_PREF_BASE_LIMIT_UP32, value); + phytium_hpb_writel(priv, priv->hpb_perf_base_limit_offs + 0x04, value); dev_dbg(dev, "exit %s successful\n", __func__); return 0; @@ -455,11 +481,6 @@ static int phytium_pcie_ep_remove(struct platform_device *pdev) return 0; } -static const struct of_device_id phytium_pcie_ep_of_match[] = { - { .compatible = "phytium,pd2008-pcie-ep" }, - { }, -}; - static struct platform_driver phytium_pcie_ep_driver = { .driver = { .name = "phytium-pcie-ep", diff --git a/drivers/pci/controller/pcie-phytium-ep.h b/drivers/pci/controller/pcie-phytium-ep.h index d53cc010585..025b049f29f 100644 --- a/drivers/pci/controller/pcie-phytium-ep.h +++ b/drivers/pci/controller/pcie-phytium-ep.h @@ -15,13 +15,20 @@ #ifndef __PCIE_PHYTIUM_EP_H__ #define __PCIE_PHYTIUM_EP_H__ +#include #include "pcie-phytium-register.h" #define IRQ_MAPPING_SIZE 0x1000 + +struct phytium_pcie_ep_config { + u32 hpb_perf_base_limit_offs; +}; + struct phytium_pcie_ep { void __iomem *reg_base; struct resource *mem_res; void __iomem *hpb_base; + u32 hpb_perf_base_limit_offs; unsigned int max_regions; unsigned long ob_region_map; phys_addr_t *ob_addr; -- Gitee From 869959e81552ec7b8ab872f09bec3a21766b99da Mon Sep 17 00:00:00 2001 From: Huangjie Date: Thu, 17 Oct 2024 17:30:03 +0800 Subject: [PATCH 02/26] pci: ep: add get_features() interface for phytium epc driver Signed-off-by: Huangjie --- drivers/pci/controller/pcie-phytium-ep.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/drivers/pci/controller/pcie-phytium-ep.c b/drivers/pci/controller/pcie-phytium-ep.c index 70944cb0db7..ce975771f7e 100644 --- a/drivers/pci/controller/pcie-phytium-ep.c +++ b/drivers/pci/controller/pcie-phytium-ep.c @@ -329,6 +329,18 @@ static int phytium_pcie_ep_start(struct pci_epc *epc) return 0; } +static const struct pci_epc_features phytium_pcie_epc_features = { + .linkup_notifier = false, + .msi_capable = true, + .msix_capable = false, +}; + +static const struct pci_epc_features* +phytium_pcie_ep_get_features(struct pci_epc *epc, u8 func_no) +{ + return &phytium_pcie_epc_features; +} + static const struct pci_epc_ops phytium_pcie_epc_ops = { .write_header = phytium_pcie_ep_write_header, .set_bar = phytium_pcie_ep_set_bar, @@ -339,6 +351,7 @@ static const struct pci_epc_ops phytium_pcie_epc_ops = { .get_msi = phytium_pcie_ep_get_msi, .raise_irq = phytium_pcie_ep_raise_irq, .start = phytium_pcie_ep_start, + .get_features = phytium_pcie_ep_get_features, }; static const struct phytium_pcie_ep_config pd2008_pcie_ep_config = -- Gitee From af5d225217270fa9b9be59d102d1e49961b5817a Mon Sep 17 00:00:00 2001 From: Huangjie Date: Fri, 25 Oct 2024 15:02:44 +0800 Subject: [PATCH 03/26] pci: ep: modify phytium epc driver compatible value Signed-off-by: Huangjie --- drivers/pci/controller/pcie-phytium-ep.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/pci/controller/pcie-phytium-ep.c b/drivers/pci/controller/pcie-phytium-ep.c index ce975771f7e..609418a5a3c 100644 --- a/drivers/pci/controller/pcie-phytium-ep.c +++ b/drivers/pci/controller/pcie-phytium-ep.c @@ -354,21 +354,21 @@ static const struct pci_epc_ops phytium_pcie_epc_ops = { .get_features = phytium_pcie_ep_get_features, }; -static const struct phytium_pcie_ep_config pd2008_pcie_ep_config = +static const struct phytium_pcie_ep_config pcie_ep_1p0_config = { .hpb_perf_base_limit_offs = 0xA30, }; -static const struct phytium_pcie_ep_config pe2204_pcie_ep_config = +static const struct phytium_pcie_ep_config pcie_ep_2p0_config = { .hpb_perf_base_limit_offs = 0xA40, }; static const struct of_device_id phytium_pcie_ep_of_match[] = { - { .compatible = "phytium,pd2008-pcie-ep", - .data = &pd2008_pcie_ep_config }, - { .compatible = "phytium,pe2204-pcie-ep", - .data = &pe2204_pcie_ep_config }, + { .compatible = "phytium,pcie-ep-1.0", + .data = &pcie_ep_1p0_config }, + { .compatible = "phytium,pcie-ep-2.0", + .data = &pcie_ep_2p0_config }, { }, }; @@ -378,7 +378,7 @@ static int phytium_pcie_ep_probe(struct platform_device *pdev) const struct of_device_id *match = NULL; struct phytium_pcie_ep *priv = NULL; const struct phytium_pcie_ep_config *pcie_ep_config = - &pe2204_pcie_ep_config; + &pcie_ep_2p0_config; struct resource *res; struct device_node *np = dev->of_node; struct pci_epc *epc; -- Gitee From 3520f97fa87e888627967714636a4434d4b2a6e4 Mon Sep 17 00:00:00 2001 From: Xiao Cong Date: Fri, 26 Jul 2024 14:08:50 +0800 Subject: [PATCH 04/26] PCI: ep: Add phytium pcie ep driver version information This patch add driver version information, which will be used to synchronize and manage driver patches in the future. Signed-off-by: Xiao Cong Signed-off-by: Wang Yinfeng Change-Id: Iadfa10ef57cfa0ee7d1970d82afae11c00f96680 --- drivers/pci/controller/pcie-phytium-ep.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/pci/controller/pcie-phytium-ep.c b/drivers/pci/controller/pcie-phytium-ep.c index 609418a5a3c..8ebcecb2125 100644 --- a/drivers/pci/controller/pcie-phytium-ep.c +++ b/drivers/pci/controller/pcie-phytium-ep.c @@ -25,6 +25,8 @@ #include "pcie-phytium-ep.h" #include "pcie-phytium-register.h" +#define PHYTIUM_PCIE_RP_DRIVER_VERSION "1.1.1" + #define PHYTIUM_PCIE_EP_IRQ_PCI_ADDR_NONE 0x0 #define PHYTIUM_PCIE_EP_IRQ_PCI_ADDR_LEGACY 0x1 @@ -502,9 +504,10 @@ static struct platform_driver phytium_pcie_ep_driver = { .probe = phytium_pcie_ep_probe, .remove = phytium_pcie_ep_remove, }; - +MODULE_DEVICE_TABLE(of, phytium_pcie_ep_of_match); module_platform_driver(phytium_pcie_ep_driver); MODULE_LICENSE("GPL"); +MODULE_VERSION(PHYTIUM_PCIE_RP_DRIVER_VERSION); MODULE_AUTHOR("Yang Xun "); MODULE_DESCRIPTION("Phytium Pcie Controller Endpoint driver"); -- Gitee From 90dc7442be674a25a839637056daeec6372527af Mon Sep 17 00:00:00 2001 From: Huangjie Date: Fri, 25 Oct 2024 15:30:55 +0800 Subject: [PATCH 05/26] pci: ep: modify phytium epc driver version to v1.1.2 Signed-off-by: Huangjie --- drivers/pci/controller/pcie-phytium-ep.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/pci/controller/pcie-phytium-ep.c b/drivers/pci/controller/pcie-phytium-ep.c index 8ebcecb2125..6373c875ad8 100644 --- a/drivers/pci/controller/pcie-phytium-ep.c +++ b/drivers/pci/controller/pcie-phytium-ep.c @@ -25,7 +25,7 @@ #include "pcie-phytium-ep.h" #include "pcie-phytium-register.h" -#define PHYTIUM_PCIE_RP_DRIVER_VERSION "1.1.1" +#define PHYTIUM_PCIE_EP_DRIVER_VERSION "1.1.2" #define PHYTIUM_PCIE_EP_IRQ_PCI_ADDR_NONE 0x0 #define PHYTIUM_PCIE_EP_IRQ_PCI_ADDR_LEGACY 0x1 @@ -508,6 +508,6 @@ MODULE_DEVICE_TABLE(of, phytium_pcie_ep_of_match); module_platform_driver(phytium_pcie_ep_driver); MODULE_LICENSE("GPL"); -MODULE_VERSION(PHYTIUM_PCIE_RP_DRIVER_VERSION); +MODULE_VERSION(PHYTIUM_PCIE_EP_DRIVER_VERSION); MODULE_AUTHOR("Yang Xun "); MODULE_DESCRIPTION("Phytium Pcie Controller Endpoint driver"); -- Gitee From b69f2cdaf749e70d74e1ef648cf2e9424e835bbd Mon Sep 17 00:00:00 2001 From: Huangjie Date: Fri, 25 Oct 2024 15:35:25 +0800 Subject: [PATCH 06/26] dt-bindings: pci: add phytium pcie epc driver bindings Signed-off-by: Huangjie --- .../bindings/pci/phytium,phytium-pcie-ep.txt | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 Documentation/devicetree/bindings/pci/phytium,phytium-pcie-ep.txt diff --git a/Documentation/devicetree/bindings/pci/phytium,phytium-pcie-ep.txt b/Documentation/devicetree/bindings/pci/phytium,phytium-pcie-ep.txt new file mode 100644 index 00000000000..0067be87b18 --- /dev/null +++ b/Documentation/devicetree/bindings/pci/phytium,phytium-pcie-ep.txt @@ -0,0 +1,22 @@ +* Phytium PCIe endpoint controller + +Required properties: +- compatible: Should contain "phytium,pcie-ep-1.0" or + "phytium,pcie-ep-2.0" +- reg: Should contain the controller register base address, AXI interface + region base address and hpb register base address respectively. +- reg-names: Must be "reg", "mem" and "hpb" respectively. +- max-outbound-regions: Set to maximum number of outbound regions. +- max-functions: Maximum number of functions that can be configured (default 1). + +Example: + +ep0: ep@0x29030000 { + compatible = "phytium,pcie-ep-1.0"; + reg = <0x0 0x29030000 0x0 0x10000>, + <0x11 0x00000000 0x1 0x00000000>, + <0x0 0x29101000 0x0 0x1000>; + reg-names = "reg", "mem", "hpb"; + max-outbound-regions = <3>; + max-functions = /bits/ 8 <1>; +}; -- Gitee From 7b1aff348ab44c9a4db9582c719e012f9833d526 Mon Sep 17 00:00:00 2001 From: Huangjie Date: Fri, 8 Nov 2024 16:31:24 +0800 Subject: [PATCH 07/26] net:macb: Support 10G mac ethtool settings Signed-off-by: Huangjie --- drivers/net/ethernet/cadence/macb_main.c | 55 +++++++++++++++++++++++- 1 file changed, 53 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c index 22f3b25a351..dff2b139c01 100644 --- a/drivers/net/ethernet/cadence/macb_main.c +++ b/drivers/net/ethernet/cadence/macb_main.c @@ -3533,17 +3533,68 @@ static int macb_set_wol(struct net_device *netdev, struct ethtool_wolinfo *wol) static int macb_get_link_ksettings(struct net_device *netdev, struct ethtool_link_ksettings *kset) { + int ret = 0; struct macb *bp = netdev_priv(netdev); + u32 supported = 0; + u32 advertising = 0; + + if (!phylink_expects_phy(bp->phylink)) { + if (bp->phy_interface == PHY_INTERFACE_MODE_USXGMII || + bp->phy_interface == PHY_INTERFACE_MODE_XGMII) { + supported = SUPPORTED_10000baseT_Full + | SUPPORTED_FIBRE | SUPPORTED_Pause; + advertising = ADVERTISED_10000baseT_Full + | ADVERTISED_FIBRE | ADVERTISED_Pause; + kset->base.port = PORT_FIBRE; + kset->base.transceiver = XCVR_INTERNAL; + } else if (bp->phy_interface == PHY_INTERFACE_MODE_SGMII) { + supported = SUPPORTED_2500baseX_Full | SUPPORTED_1000baseT_Full + | SUPPORTED_100baseT_Full | SUPPORTED_10baseT_Full + | SUPPORTED_FIBRE | SUPPORTED_Pause; + advertising = ADVERTISED_2500baseX_Full | ADVERTISED_1000baseT_Full + | ADVERTISED_100baseT_Full | ADVERTISED_10baseT_Full + | ADVERTISED_FIBRE | ADVERTISED_Pause; + kset->base.port = PORT_FIBRE; + kset->base.transceiver = XCVR_INTERNAL; + } else if (bp->phy_interface == PHY_INTERFACE_MODE_RGMII) { + supported = SUPPORTED_1000baseT_Full | SUPPORTED_100baseT_Full + | SUPPORTED_10baseT_Full | SUPPORTED_TP; + advertising = ADVERTISED_1000baseT_Full | ADVERTISED_100baseT_Full + | ADVERTISED_10baseT_Full | ADVERTISED_TP; + } else if (bp->phy_interface == PHY_INTERFACE_MODE_RMII) { + supported = SUPPORTED_100baseT_Full + | SUPPORTED_10baseT_Full | SUPPORTED_TP; + advertising = ADVERTISED_100baseT_Full + | ADVERTISED_10baseT_Full | ADVERTISED_TP; + } + + ethtool_convert_legacy_u32_to_link_mode(kset->link_modes.supported, + supported); + ethtool_convert_legacy_u32_to_link_mode(kset->link_modes.advertising, + advertising); + kset->base.speed = bp->speed; + kset->base.duplex = bp->duplex; + } else { + phylink_ethtool_ksettings_get(bp->phylink, kset); + } - return phylink_ethtool_ksettings_get(bp->phylink, kset); + return ret; } static int macb_set_link_ksettings(struct net_device *netdev, const struct ethtool_link_ksettings *kset) { struct macb *bp = netdev_priv(netdev); + int ret = 0; + + if (!phylink_expects_phy(bp->phylink)) { + netdev_err(netdev, "fixed link interface not supported set link\n"); + ret = -EOPNOTSUPP; + } else { + ret = phylink_ethtool_ksettings_set(bp->phylink, kset); + } - return phylink_ethtool_ksettings_set(bp->phylink, kset); + return ret; } static void macb_get_ringparam(struct net_device *netdev, -- Gitee From 711b299757718174f4132b5d55998c5f6de1219d Mon Sep 17 00:00:00 2001 From: Huangjie Date: Wed, 13 Nov 2024 14:21:38 +0800 Subject: [PATCH 08/26] sound: pdmk_dp: add kcontrol for jack alsa ucm need a control event for jack detection Signed-off-by: Huangjie --- sound/soc/phytium/pmdk_dp.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/sound/soc/phytium/pmdk_dp.c b/sound/soc/phytium/pmdk_dp.c index ce56634aef2..38c977d66ab 100755 --- a/sound/soc/phytium/pmdk_dp.c +++ b/sound/soc/phytium/pmdk_dp.c @@ -48,6 +48,11 @@ static int pmdk_dp0_init(struct snd_soc_pcm_runtime *runtime) dev_err(card->dev, "Jack creation failed %d\n", ret); return ret; } + ret = snd_jack_add_new_kctl(priv->jack0.jack, "HDMI/DP,pcm=0", + SND_JACK_LINEOUT); + if (ret) + dev_warn(card->dev, "failed creating Jack kctl %d\n", ret); + snd_soc_component_set_jack(component, &priv->jack0, NULL); return ret; } @@ -66,6 +71,10 @@ static int pmdk_dp1_init(struct snd_soc_pcm_runtime *runtime) dev_err(card->dev, "Jack creation failed %d\n", ret); return ret; } + ret = snd_jack_add_new_kctl(priv->jack1.jack, "HDMI/DP,pcm=1", + SND_JACK_LINEOUT); + if (ret) + dev_warn(card->dev, "failed creating Jack kctl %d\n", ret); snd_soc_component_set_jack(component, &priv->jack1, NULL); return ret; } @@ -84,6 +93,10 @@ static int pmdk_dp2_init(struct snd_soc_pcm_runtime *runtime) dev_err(card->dev, "Jack creation failed %d\n", ret); return ret; } + ret = snd_jack_add_new_kctl(priv->jack2.jack, "HDMI/DP,pcm=2", + SND_JACK_LINEOUT); + if (ret) + dev_warn(card->dev, "failed creating Jack kctl %d\n", ret); snd_soc_component_set_jack(component, &priv->jack2, NULL); return ret; } -- Gitee From dbd3c415f12b2b145e0d4e617046935be682ea32 Mon Sep 17 00:00:00 2001 From: liutianyu1250 Date: Fri, 27 Sep 2024 10:29:46 +0800 Subject: [PATCH 09/26] arm64: phytium_defconfig: enable NUMA Signed-off-by: liutianyu1250 --- arch/arm64/configs/phytium_defconfig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/arm64/configs/phytium_defconfig b/arch/arm64/configs/phytium_defconfig index d46443ff043..653742e63f7 100644 --- a/arch/arm64/configs/phytium_defconfig +++ b/arch/arm64/configs/phytium_defconfig @@ -13,6 +13,7 @@ CONFIG_TASK_XACCT=y CONFIG_TASK_IO_ACCOUNTING=y CONFIG_IKCONFIG=y CONFIG_IKCONFIG_PROC=y +CONFIG_NUMA_BALANCING=y CONFIG_MEMCG=y CONFIG_BLK_CGROUP=y CONFIG_CGROUP_PIDS=y @@ -31,6 +32,7 @@ CONFIG_ARCH_PHYTIUM=y CONFIG_ARM64_VA_BITS_48=y CONFIG_SCHED_MC=y CONFIG_SCHED_SMT=y +CONFIG_NUMA=y CONFIG_KEXEC=y CONFIG_KEXEC_FILE=y CONFIG_CRASH_DUMP=y @@ -94,7 +96,6 @@ CONFIG_KSM=y CONFIG_MEMORY_FAILURE=y CONFIG_TRANSPARENT_HUGEPAGE=y CONFIG_CMA=y -CONFIG_CMA_AREAS=19 CONFIG_ZSMALLOC=m CONFIG_NET=y CONFIG_PACKET=y @@ -771,7 +772,6 @@ CONFIG_CRYPTO_DEV_HISI_HPRE=m CONFIG_CRYPTO_DEV_AMLOGIC_GXL=m CONFIG_INDIRECT_PIO=y CONFIG_DMA_CMA=y -CONFIG_DMA_PERNUMA_CMA=y CONFIG_CMA_SIZE_MBYTES=32 CONFIG_PRINTK_TIME=y CONFIG_DEBUG_INFO=y -- Gitee From 4d6cc47578389ad311debfae69897e839b737edd Mon Sep 17 00:00:00 2001 From: liutianyu1250 Date: Fri, 20 Dec 2024 09:37:40 +0800 Subject: [PATCH 10/26] arm64: phytium_debug.cfg: select IKHEADERS Signed-off-by: liutianyu1250 --- arch/arm64/configs/phytium_debug.config | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/arm64/configs/phytium_debug.config b/arch/arm64/configs/phytium_debug.config index 9e254d7662b..368df7d1602 100644 --- a/arch/arm64/configs/phytium_debug.config +++ b/arch/arm64/configs/phytium_debug.config @@ -1,3 +1,4 @@ +CONFIG_IKHEADERS=y CONFIG_PRINTK_CALLER=y CONFIG_DYNAMIC_DEBUG=y # CONFIG_DEBUG_INFO_REDUCED is not set -- Gitee From e5c41b0431a53c29c2edfe56e4d77c4ebac3e598 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexis=20Lothor=C3=A9?= Date: Fri, 5 Jan 2024 08:57:32 +0100 Subject: [PATCH 11/26] wifi: wilc1000: fix declarations ordering MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [ Upstream commit 535733e90e5d8912ebeccebb05b354a2d06ff459 ] Reorder parameters declaration in wilc_parse_join_bss_param to enforce reverse christmas tree Signed-off-by: Alexis Lothoré Signed-off-by: Kalle Valo Link: https://msgid.link/20240105075733.36331-2-alexis.lothore@bootlin.com Stable-dep-of: 205c50306acf ("wifi: wilc1000: fix RCU usage in connect path") Signed-off-by: Sasha Levin --- drivers/net/wireless/microchip/wilc1000/hif.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/net/wireless/microchip/wilc1000/hif.c b/drivers/net/wireless/microchip/wilc1000/hif.c index 884f45e627a..bff33f39605 100644 --- a/drivers/net/wireless/microchip/wilc1000/hif.c +++ b/drivers/net/wireless/microchip/wilc1000/hif.c @@ -359,13 +359,13 @@ static void handle_connect_timeout(struct work_struct *work) void *wilc_parse_join_bss_param(struct cfg80211_bss *bss, struct cfg80211_crypto_settings *crypto) { - struct wilc_join_bss_param *param; - struct ieee80211_p2p_noa_attr noa_attr; - u8 rates_len = 0; + const struct cfg80211_bss_ies *ies = rcu_dereference(bss->ies); const u8 *tim_elm, *ssid_elm, *rates_ie, *supp_rates_ie; const u8 *ht_ie, *wpa_ie, *wmm_ie, *rsn_ie; + struct ieee80211_p2p_noa_attr noa_attr; + struct wilc_join_bss_param *param; + u8 rates_len = 0; int ret; - const struct cfg80211_bss_ies *ies = rcu_dereference(bss->ies); param = kzalloc(sizeof(*param), GFP_KERNEL); if (!param) -- Gitee From a982db80c006e7f4a0ff7d34d1e69127eebb1b47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexis=20Lothor=C3=A9?= Date: Fri, 5 Jan 2024 08:57:33 +0100 Subject: [PATCH 12/26] wifi: wilc1000: fix RCU usage in connect path MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [ Upstream commit 205c50306acf58a335eb19fa84e40140f4fe814f ] With lockdep enabled, calls to the connect function from cfg802.11 layer lead to the following warning: ============================= WARNING: suspicious RCU usage 6.7.0-rc1-wt+ #333 Not tainted ----------------------------- drivers/net/wireless/microchip/wilc1000/hif.c:386 suspicious rcu_dereference_check() usage! [...] stack backtrace: CPU: 0 PID: 100 Comm: wpa_supplicant Not tainted 6.7.0-rc1-wt+ #333 Hardware name: Atmel SAMA5 unwind_backtrace from show_stack+0x18/0x1c show_stack from dump_stack_lvl+0x34/0x48 dump_stack_lvl from wilc_parse_join_bss_param+0x7dc/0x7f4 wilc_parse_join_bss_param from connect+0x2c4/0x648 connect from cfg80211_connect+0x30c/0xb74 cfg80211_connect from nl80211_connect+0x860/0xa94 nl80211_connect from genl_rcv_msg+0x3fc/0x59c genl_rcv_msg from netlink_rcv_skb+0xd0/0x1f8 netlink_rcv_skb from genl_rcv+0x2c/0x3c genl_rcv from netlink_unicast+0x3b0/0x550 netlink_unicast from netlink_sendmsg+0x368/0x688 netlink_sendmsg from ____sys_sendmsg+0x190/0x430 ____sys_sendmsg from ___sys_sendmsg+0x110/0x158 ___sys_sendmsg from sys_sendmsg+0xe8/0x150 sys_sendmsg from ret_fast_syscall+0x0/0x1c This warning is emitted because in the connect path, when trying to parse target BSS parameters, we dereference a RCU pointer whithout being in RCU critical section. Fix RCU dereference usage by moving it to a RCU read critical section. To avoid wrapping the whole wilc_parse_join_bss_param under the critical section, just use the critical section to copy ies data Fixes: c460495ee072 ("staging: wilc1000: fix incorrent type in initializer") Signed-off-by: Alexis Lothoré Signed-off-by: Kalle Valo Link: https://msgid.link/20240105075733.36331-3-alexis.lothore@bootlin.com Signed-off-by: Sasha Levin --- drivers/net/wireless/microchip/wilc1000/hif.c | 36 ++++++++++++------- 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/drivers/net/wireless/microchip/wilc1000/hif.c b/drivers/net/wireless/microchip/wilc1000/hif.c index bff33f39605..457386f9de9 100644 --- a/drivers/net/wireless/microchip/wilc1000/hif.c +++ b/drivers/net/wireless/microchip/wilc1000/hif.c @@ -359,38 +359,49 @@ static void handle_connect_timeout(struct work_struct *work) void *wilc_parse_join_bss_param(struct cfg80211_bss *bss, struct cfg80211_crypto_settings *crypto) { - const struct cfg80211_bss_ies *ies = rcu_dereference(bss->ies); - const u8 *tim_elm, *ssid_elm, *rates_ie, *supp_rates_ie; + const u8 *ies_data, *tim_elm, *ssid_elm, *rates_ie, *supp_rates_ie; const u8 *ht_ie, *wpa_ie, *wmm_ie, *rsn_ie; struct ieee80211_p2p_noa_attr noa_attr; + const struct cfg80211_bss_ies *ies; struct wilc_join_bss_param *param; - u8 rates_len = 0; + u8 rates_len = 0, ies_len; int ret; param = kzalloc(sizeof(*param), GFP_KERNEL); if (!param) return NULL; + rcu_read_lock(); + ies = rcu_dereference(bss->ies); + ies_data = kmemdup(ies->data, ies->len, GFP_ATOMIC); + if (!ies_data) { + rcu_read_unlock(); + kfree(param); + return NULL; + } + ies_len = ies->len; + rcu_read_unlock(); + param->beacon_period = cpu_to_le16(bss->beacon_interval); param->cap_info = cpu_to_le16(bss->capability); param->bss_type = WILC_FW_BSS_TYPE_INFRA; param->ch = ieee80211_frequency_to_channel(bss->channel->center_freq); ether_addr_copy(param->bssid, bss->bssid); - ssid_elm = cfg80211_find_ie(WLAN_EID_SSID, ies->data, ies->len); + ssid_elm = cfg80211_find_ie(WLAN_EID_SSID, ies_data, ies_len); if (ssid_elm) { if (ssid_elm[1] <= IEEE80211_MAX_SSID_LEN) memcpy(param->ssid, ssid_elm + 2, ssid_elm[1]); } - tim_elm = cfg80211_find_ie(WLAN_EID_TIM, ies->data, ies->len); + tim_elm = cfg80211_find_ie(WLAN_EID_TIM, ies_data, ies_len); if (tim_elm && tim_elm[1] >= 2) param->dtim_period = tim_elm[3]; memset(param->p_suites, 0xFF, 3); memset(param->akm_suites, 0xFF, 3); - rates_ie = cfg80211_find_ie(WLAN_EID_SUPP_RATES, ies->data, ies->len); + rates_ie = cfg80211_find_ie(WLAN_EID_SUPP_RATES, ies_data, ies_len); if (rates_ie) { rates_len = rates_ie[1]; if (rates_len > WILC_MAX_RATES_SUPPORTED) @@ -401,7 +412,7 @@ void *wilc_parse_join_bss_param(struct cfg80211_bss *bss, if (rates_len < WILC_MAX_RATES_SUPPORTED) { supp_rates_ie = cfg80211_find_ie(WLAN_EID_EXT_SUPP_RATES, - ies->data, ies->len); + ies_data, ies_len); if (supp_rates_ie) { u8 ext_rates = supp_rates_ie[1]; @@ -416,11 +427,11 @@ void *wilc_parse_join_bss_param(struct cfg80211_bss *bss, } } - ht_ie = cfg80211_find_ie(WLAN_EID_HT_CAPABILITY, ies->data, ies->len); + ht_ie = cfg80211_find_ie(WLAN_EID_HT_CAPABILITY, ies_data, ies_len); if (ht_ie) param->ht_capable = true; - ret = cfg80211_get_p2p_attr(ies->data, ies->len, + ret = cfg80211_get_p2p_attr(ies_data, ies_len, IEEE80211_P2P_ATTR_ABSENCE_NOTICE, (u8 *)&noa_attr, sizeof(noa_attr)); if (ret > 0) { @@ -444,7 +455,7 @@ void *wilc_parse_join_bss_param(struct cfg80211_bss *bss, } wmm_ie = cfg80211_find_vendor_ie(WLAN_OUI_MICROSOFT, WLAN_OUI_TYPE_MICROSOFT_WMM, - ies->data, ies->len); + ies_data, ies_len); if (wmm_ie) { struct ieee80211_wmm_param_ie *ie; @@ -459,13 +470,13 @@ void *wilc_parse_join_bss_param(struct cfg80211_bss *bss, wpa_ie = cfg80211_find_vendor_ie(WLAN_OUI_MICROSOFT, WLAN_OUI_TYPE_MICROSOFT_WPA, - ies->data, ies->len); + ies_data, ies_len); if (wpa_ie) { param->mode_802_11i = 1; param->rsn_found = true; } - rsn_ie = cfg80211_find_ie(WLAN_EID_RSN, ies->data, ies->len); + rsn_ie = cfg80211_find_ie(WLAN_EID_RSN, ies_data, ies_len); if (rsn_ie) { int rsn_ie_len = sizeof(struct element) + rsn_ie[1]; int offset = 8; @@ -499,6 +510,7 @@ void *wilc_parse_join_bss_param(struct cfg80211_bss *bss, param->akm_suites[i] = crypto->akm_suites[i] & 0xFF; } + kfree(ies_data); return (void *)param; } -- Gitee From cbd737cc00c6f2032bb6d77e9d482c7c74fe4100 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Sun, 28 Jan 2024 08:53:53 +0200 Subject: [PATCH 13/26] wifi: iwlwifi: dbg-tlv: ensure NUL termination [ Upstream commit ea1d166fae14e05d49ffb0ea9fcd4658f8d3dcea ] The iwl_fw_ini_debug_info_tlv is used as a string, so we must ensure the string is terminated correctly before using it. Fixes: a9248de42464 ("iwlwifi: dbg_ini: add TLV allocation new API support") Signed-off-by: Johannes Berg Reviewed-by: Gregory Greenman Signed-off-by: Miri Korenblit Link: https://msgid.link/20240128084842.be15e858ee89.Ibff93429cf999eafc7b26f3eef4c055dc84984a0@changeid Signed-off-by: Johannes Berg Signed-off-by: Sasha Levin --- drivers/net/wireless/intel/iwlwifi/iwl-dbg-tlv.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/net/wireless/intel/iwlwifi/iwl-dbg-tlv.c b/drivers/net/wireless/intel/iwlwifi/iwl-dbg-tlv.c index fdf2c6ea41d..d3964cd6d4e 100644 --- a/drivers/net/wireless/intel/iwlwifi/iwl-dbg-tlv.c +++ b/drivers/net/wireless/intel/iwlwifi/iwl-dbg-tlv.c @@ -155,6 +155,12 @@ static int iwl_dbg_tlv_alloc_debug_info(struct iwl_trans *trans, if (le32_to_cpu(tlv->length) != sizeof(*debug_info)) return -EINVAL; + /* we use this as a string, ensure input was NUL terminated */ + if (strnlen(debug_info->debug_cfg_name, + sizeof(debug_info->debug_cfg_name)) == + sizeof(debug_info->debug_cfg_name)) + return -EINVAL; + IWL_DEBUG_FW(trans, "WRT: Loading debug cfg: %s\n", debug_info->debug_cfg_name); -- Gitee From ea50f06d1d9a8518d97ffd6d888ba7c4765752c2 Mon Sep 17 00:00:00 2001 From: Silvio Gissi Date: Fri, 15 Mar 2024 15:05:39 -0400 Subject: [PATCH 14/26] keys: Fix overwrite of key expiration on instantiation commit 9da27fb65a14c18efd4473e2e82b76b53ba60252 upstream. The expiry time of a key is unconditionally overwritten during instantiation, defaulting to turn it permanent. This causes a problem for DNS resolution as the expiration set by user-space is overwritten to TIME64_MAX, disabling further DNS updates. Fix this by restoring the condition that key_set_expiry is only called when the pre-parser sets a specific expiry. Fixes: 39299bdd2546 ("keys, dns: Allow key types (eg. DNS) to be reclaimed immediately on expiry") Signed-off-by: Silvio Gissi cc: David Howells cc: Hazem Mohamed Abuelfotoh cc: linux-afs@lists.infradead.org cc: linux-cifs@vger.kernel.org cc: keyrings@vger.kernel.org cc: netdev@vger.kernel.org cc: stable@vger.kernel.org Reviewed-by: Jarkko Sakkinen Signed-off-by: Jarkko Sakkinen Signed-off-by: Greg Kroah-Hartman --- security/keys/key.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/security/keys/key.c b/security/keys/key.c index 67ad0826e38..e5111ce17e2 100644 --- a/security/keys/key.c +++ b/security/keys/key.c @@ -464,7 +464,8 @@ static int __key_instantiate_and_link(struct key *key, if (authkey) key_invalidate(authkey); - key_set_expiry(key, prep->expiry); + if (prep->expiry != TIME64_MAX) + key_set_expiry(key, prep->expiry); } } -- Gitee From 565d2ef66c17b3e596ef60fe05f0806af0a1e7c4 Mon Sep 17 00:00:00 2001 From: Cosmin Ratiu Date: Tue, 9 Apr 2024 22:08:12 +0300 Subject: [PATCH 15/26] net/mlx5: Properly link new fs rules into the tree [ Upstream commit 7c6782ad4911cbee874e85630226ed389ff2e453 ] Previously, add_rule_fg would only add newly created rules from the handle into the tree when they had a refcount of 1. On the other hand, create_flow_handle tries hard to find and reference already existing identical rules instead of creating new ones. These two behaviors can result in a situation where create_flow_handle 1) creates a new rule and references it, then 2) in a subsequent step during the same handle creation references it again, resulting in a rule with a refcount of 2 that is not linked into the tree, will have a NULL parent and root and will result in a crash when the flow group is deleted because del_sw_hw_rule, invoked on rule deletion, assumes node->parent is != NULL. This happened in the wild, due to another bug related to incorrect handling of duplicate pkt_reformat ids, which lead to the code in create_flow_handle incorrectly referencing a just-added rule in the same flow handle, resulting in the problem described above. Full details are at [1]. This patch changes add_rule_fg to add new rules without parents into the tree, properly initializing them and avoiding the crash. This makes it more consistent with how rules are added to an FTE in create_flow_handle. Fixes: 74491de93712 ("net/mlx5: Add multi dest support") Link: https://lore.kernel.org/netdev/ea5264d6-6b55-4449-a602-214c6f509c1e@163.com/T/#u [1] Signed-off-by: Cosmin Ratiu Reviewed-by: Tariq Toukan Reviewed-by: Mark Bloch Signed-off-by: Saeed Mahameed Signed-off-by: Tariq Toukan Link: https://lore.kernel.org/r/20240409190820.227554-5-tariqt@nvidia.com Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- drivers/net/ethernet/mellanox/mlx5/core/fs_core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c b/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c index 4e8e3797aed..074c9eb44ab 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c @@ -1675,8 +1675,9 @@ static struct mlx5_flow_handle *add_rule_fg(struct mlx5_flow_group *fg, } trace_mlx5_fs_set_fte(fte, false); + /* Link newly added rules into the tree. */ for (i = 0; i < handle->num_rules; i++) { - if (refcount_read(&handle->rule[i]->node.refcount) == 1) { + if (!handle->rule[i]->node.parent) { tree_add_node(&handle->rule[i]->node, &fte->node); trace_mlx5_fs_add_rule(handle->rule[i]); } -- Gitee From 0887012bba8c0b387b90130d1fb80c90d5fff6dd Mon Sep 17 00:00:00 2001 From: Vasiliy Kovalev Date: Thu, 15 Feb 2024 23:27:17 +0300 Subject: [PATCH 16/26] ipv6: sr: fix possible use-after-free and null-ptr-deref [ Upstream commit 5559cea2d5aa3018a5f00dd2aca3427ba09b386b ] The pernet operations structure for the subsystem must be registered before registering the generic netlink family. Fixes: 915d7e5e5930 ("ipv6: sr: add code base for control plane support of SR-IPv6") Signed-off-by: Vasiliy Kovalev Link: https://lore.kernel.org/r/20240215202717.29815-1-kovalev@altlinux.org Signed-off-by: Paolo Abeni Signed-off-by: Sasha Levin --- net/ipv6/seg6.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/net/ipv6/seg6.c b/net/ipv6/seg6.c index 2278c0234c4..a8439fded12 100644 --- a/net/ipv6/seg6.c +++ b/net/ipv6/seg6.c @@ -451,22 +451,24 @@ int __init seg6_init(void) { int err; - err = genl_register_family(&seg6_genl_family); + err = register_pernet_subsys(&ip6_segments_ops); if (err) goto out; - err = register_pernet_subsys(&ip6_segments_ops); + err = genl_register_family(&seg6_genl_family); if (err) - goto out_unregister_genl; + goto out_unregister_pernet; #ifdef CONFIG_IPV6_SEG6_LWTUNNEL err = seg6_iptunnel_init(); if (err) - goto out_unregister_pernet; + goto out_unregister_genl; err = seg6_local_init(); - if (err) - goto out_unregister_pernet; + if (err) { + seg6_iptunnel_exit(); + goto out_unregister_genl; + } #endif #ifdef CONFIG_IPV6_SEG6_HMAC @@ -487,11 +489,11 @@ int __init seg6_init(void) #endif #endif #ifdef CONFIG_IPV6_SEG6_LWTUNNEL -out_unregister_pernet: - unregister_pernet_subsys(&ip6_segments_ops); -#endif out_unregister_genl: genl_unregister_family(&seg6_genl_family); +#endif +out_unregister_pernet: + unregister_pernet_subsys(&ip6_segments_ops); goto out; } -- Gitee From 831bed324593b93bad670a039b1fd44539fd594d Mon Sep 17 00:00:00 2001 From: Hangbin Liu Date: Thu, 9 May 2024 21:18:12 +0800 Subject: [PATCH 17/26] ipv6: sr: fix invalid unregister error path [ Upstream commit 160e9d2752181fcf18c662e74022d77d3164cd45 ] The error path of seg6_init() is wrong in case CONFIG_IPV6_SEG6_LWTUNNEL is not defined. In that case if seg6_hmac_init() fails, the genl_unregister_family() isn't called. This issue exist since commit 46738b1317e1 ("ipv6: sr: add option to control lwtunnel support"), and commit 5559cea2d5aa ("ipv6: sr: fix possible use-after-free and null-ptr-deref") replaced unregister_pernet_subsys() with genl_unregister_family() in this error path. Fixes: 46738b1317e1 ("ipv6: sr: add option to control lwtunnel support") Reported-by: Guillaume Nault Signed-off-by: Hangbin Liu Reviewed-by: Sabrina Dubroca Reviewed-by: David Ahern Link: https://lore.kernel.org/r/20240509131812.1662197-4-liuhangbin@gmail.com Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- net/ipv6/seg6.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/net/ipv6/seg6.c b/net/ipv6/seg6.c index a8439fded12..786d05c74ca 100644 --- a/net/ipv6/seg6.c +++ b/net/ipv6/seg6.c @@ -490,6 +490,8 @@ int __init seg6_init(void) #endif #ifdef CONFIG_IPV6_SEG6_LWTUNNEL out_unregister_genl: +#endif +#if IS_ENABLED(CONFIG_IPV6_SEG6_LWTUNNEL) || IS_ENABLED(CONFIG_IPV6_SEG6_HMAC) genl_unregister_family(&seg6_genl_family); #endif out_unregister_pernet: -- Gitee From 11ab6bffe24306f28d0619164491bd53d2477fce Mon Sep 17 00:00:00 2001 From: Eric Dumazet Date: Fri, 13 Sep 2024 17:06:15 +0000 Subject: [PATCH 18/26] netfilter: nf_reject_ipv6: fix nf_reject_ip6_tcphdr_put() [ Upstream commit 9c778fe48d20ef362047e3376dee56d77f8500d4 ] syzbot reported that nf_reject_ip6_tcphdr_put() was possibly sending garbage on the four reserved tcp bits (th->res1) Use skb_put_zero() to clear the whole TCP header, as done in nf_reject_ip_tcphdr_put() BUG: KMSAN: uninit-value in nf_reject_ip6_tcphdr_put+0x688/0x6c0 net/ipv6/netfilter/nf_reject_ipv6.c:255 nf_reject_ip6_tcphdr_put+0x688/0x6c0 net/ipv6/netfilter/nf_reject_ipv6.c:255 nf_send_reset6+0xd84/0x15b0 net/ipv6/netfilter/nf_reject_ipv6.c:344 nft_reject_inet_eval+0x3c1/0x880 net/netfilter/nft_reject_inet.c:48 expr_call_ops_eval net/netfilter/nf_tables_core.c:240 [inline] nft_do_chain+0x438/0x22a0 net/netfilter/nf_tables_core.c:288 nft_do_chain_inet+0x41a/0x4f0 net/netfilter/nft_chain_filter.c:161 nf_hook_entry_hookfn include/linux/netfilter.h:154 [inline] nf_hook_slow+0xf4/0x400 net/netfilter/core.c:626 nf_hook include/linux/netfilter.h:269 [inline] NF_HOOK include/linux/netfilter.h:312 [inline] ipv6_rcv+0x29b/0x390 net/ipv6/ip6_input.c:310 __netif_receive_skb_one_core net/core/dev.c:5661 [inline] __netif_receive_skb+0x1da/0xa00 net/core/dev.c:5775 process_backlog+0x4ad/0xa50 net/core/dev.c:6108 __napi_poll+0xe7/0x980 net/core/dev.c:6772 napi_poll net/core/dev.c:6841 [inline] net_rx_action+0xa5a/0x19b0 net/core/dev.c:6963 handle_softirqs+0x1ce/0x800 kernel/softirq.c:554 __do_softirq+0x14/0x1a kernel/softirq.c:588 do_softirq+0x9a/0x100 kernel/softirq.c:455 __local_bh_enable_ip+0x9f/0xb0 kernel/softirq.c:382 local_bh_enable include/linux/bottom_half.h:33 [inline] rcu_read_unlock_bh include/linux/rcupdate.h:908 [inline] __dev_queue_xmit+0x2692/0x5610 net/core/dev.c:4450 dev_queue_xmit include/linux/netdevice.h:3105 [inline] neigh_resolve_output+0x9ca/0xae0 net/core/neighbour.c:1565 neigh_output include/net/neighbour.h:542 [inline] ip6_finish_output2+0x2347/0x2ba0 net/ipv6/ip6_output.c:141 __ip6_finish_output net/ipv6/ip6_output.c:215 [inline] ip6_finish_output+0xbb8/0x14b0 net/ipv6/ip6_output.c:226 NF_HOOK_COND include/linux/netfilter.h:303 [inline] ip6_output+0x356/0x620 net/ipv6/ip6_output.c:247 dst_output include/net/dst.h:450 [inline] NF_HOOK include/linux/netfilter.h:314 [inline] ip6_xmit+0x1ba6/0x25d0 net/ipv6/ip6_output.c:366 inet6_csk_xmit+0x442/0x530 net/ipv6/inet6_connection_sock.c:135 __tcp_transmit_skb+0x3b07/0x4880 net/ipv4/tcp_output.c:1466 tcp_transmit_skb net/ipv4/tcp_output.c:1484 [inline] tcp_connect+0x35b6/0x7130 net/ipv4/tcp_output.c:4143 tcp_v6_connect+0x1bcc/0x1e40 net/ipv6/tcp_ipv6.c:333 __inet_stream_connect+0x2ef/0x1730 net/ipv4/af_inet.c:679 inet_stream_connect+0x6a/0xd0 net/ipv4/af_inet.c:750 __sys_connect_file net/socket.c:2061 [inline] __sys_connect+0x606/0x690 net/socket.c:2078 __do_sys_connect net/socket.c:2088 [inline] __se_sys_connect net/socket.c:2085 [inline] __x64_sys_connect+0x91/0xe0 net/socket.c:2085 x64_sys_call+0x27a5/0x3ba0 arch/x86/include/generated/asm/syscalls_64.h:43 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0xcd/0x1e0 arch/x86/entry/common.c:83 entry_SYSCALL_64_after_hwframe+0x77/0x7f Uninit was stored to memory at: nf_reject_ip6_tcphdr_put+0x60c/0x6c0 net/ipv6/netfilter/nf_reject_ipv6.c:249 nf_send_reset6+0xd84/0x15b0 net/ipv6/netfilter/nf_reject_ipv6.c:344 nft_reject_inet_eval+0x3c1/0x880 net/netfilter/nft_reject_inet.c:48 expr_call_ops_eval net/netfilter/nf_tables_core.c:240 [inline] nft_do_chain+0x438/0x22a0 net/netfilter/nf_tables_core.c:288 nft_do_chain_inet+0x41a/0x4f0 net/netfilter/nft_chain_filter.c:161 nf_hook_entry_hookfn include/linux/netfilter.h:154 [inline] nf_hook_slow+0xf4/0x400 net/netfilter/core.c:626 nf_hook include/linux/netfilter.h:269 [inline] NF_HOOK include/linux/netfilter.h:312 [inline] ipv6_rcv+0x29b/0x390 net/ipv6/ip6_input.c:310 __netif_receive_skb_one_core net/core/dev.c:5661 [inline] __netif_receive_skb+0x1da/0xa00 net/core/dev.c:5775 process_backlog+0x4ad/0xa50 net/core/dev.c:6108 __napi_poll+0xe7/0x980 net/core/dev.c:6772 napi_poll net/core/dev.c:6841 [inline] net_rx_action+0xa5a/0x19b0 net/core/dev.c:6963 handle_softirqs+0x1ce/0x800 kernel/softirq.c:554 __do_softirq+0x14/0x1a kernel/softirq.c:588 Uninit was stored to memory at: nf_reject_ip6_tcphdr_put+0x2ca/0x6c0 net/ipv6/netfilter/nf_reject_ipv6.c:231 nf_send_reset6+0xd84/0x15b0 net/ipv6/netfilter/nf_reject_ipv6.c:344 nft_reject_inet_eval+0x3c1/0x880 net/netfilter/nft_reject_inet.c:48 expr_call_ops_eval net/netfilter/nf_tables_core.c:240 [inline] nft_do_chain+0x438/0x22a0 net/netfilter/nf_tables_core.c:288 nft_do_chain_inet+0x41a/0x4f0 net/netfilter/nft_chain_filter.c:161 nf_hook_entry_hookfn include/linux/netfilter.h:154 [inline] nf_hook_slow+0xf4/0x400 net/netfilter/core.c:626 nf_hook include/linux/netfilter.h:269 [inline] NF_HOOK include/linux/netfilter.h:312 [inline] ipv6_rcv+0x29b/0x390 net/ipv6/ip6_input.c:310 __netif_receive_skb_one_core net/core/dev.c:5661 [inline] __netif_receive_skb+0x1da/0xa00 net/core/dev.c:5775 process_backlog+0x4ad/0xa50 net/core/dev.c:6108 __napi_poll+0xe7/0x980 net/core/dev.c:6772 napi_poll net/core/dev.c:6841 [inline] net_rx_action+0xa5a/0x19b0 net/core/dev.c:6963 handle_softirqs+0x1ce/0x800 kernel/softirq.c:554 __do_softirq+0x14/0x1a kernel/softirq.c:588 Uninit was created at: slab_post_alloc_hook mm/slub.c:3998 [inline] slab_alloc_node mm/slub.c:4041 [inline] kmem_cache_alloc_node_noprof+0x6bf/0xb80 mm/slub.c:4084 kmalloc_reserve+0x13d/0x4a0 net/core/skbuff.c:583 __alloc_skb+0x363/0x7b0 net/core/skbuff.c:674 alloc_skb include/linux/skbuff.h:1320 [inline] nf_send_reset6+0x98d/0x15b0 net/ipv6/netfilter/nf_reject_ipv6.c:327 nft_reject_inet_eval+0x3c1/0x880 net/netfilter/nft_reject_inet.c:48 expr_call_ops_eval net/netfilter/nf_tables_core.c:240 [inline] nft_do_chain+0x438/0x22a0 net/netfilter/nf_tables_core.c:288 nft_do_chain_inet+0x41a/0x4f0 net/netfilter/nft_chain_filter.c:161 nf_hook_entry_hookfn include/linux/netfilter.h:154 [inline] nf_hook_slow+0xf4/0x400 net/netfilter/core.c:626 nf_hook include/linux/netfilter.h:269 [inline] NF_HOOK include/linux/netfilter.h:312 [inline] ipv6_rcv+0x29b/0x390 net/ipv6/ip6_input.c:310 __netif_receive_skb_one_core net/core/dev.c:5661 [inline] __netif_receive_skb+0x1da/0xa00 net/core/dev.c:5775 process_backlog+0x4ad/0xa50 net/core/dev.c:6108 __napi_poll+0xe7/0x980 net/core/dev.c:6772 napi_poll net/core/dev.c:6841 [inline] net_rx_action+0xa5a/0x19b0 net/core/dev.c:6963 handle_softirqs+0x1ce/0x800 kernel/softirq.c:554 __do_softirq+0x14/0x1a kernel/softirq.c:588 Fixes: c8d7b98bec43 ("netfilter: move nf_send_resetX() code to nf_reject_ipvX modules") Reported-by: syzbot Signed-off-by: Eric Dumazet Reviewed-by: Simon Horman Reviewed-by: Pablo Neira Ayuso Link: https://patch.msgid.link/20240913170615.3670897-1-edumazet@google.com Signed-off-by: Paolo Abeni Signed-off-by: Sasha Levin --- net/ipv6/netfilter/nf_reject_ipv6.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/net/ipv6/netfilter/nf_reject_ipv6.c b/net/ipv6/netfilter/nf_reject_ipv6.c index 832d9f9cd10..df572724f25 100644 --- a/net/ipv6/netfilter/nf_reject_ipv6.c +++ b/net/ipv6/netfilter/nf_reject_ipv6.c @@ -89,33 +89,23 @@ void nf_reject_ip6_tcphdr_put(struct sk_buff *nskb, const struct tcphdr *oth, unsigned int otcplen) { struct tcphdr *tcph; - int needs_ack; skb_reset_transport_header(nskb); - tcph = skb_put(nskb, sizeof(struct tcphdr)); + tcph = skb_put_zero(nskb, sizeof(struct tcphdr)); /* Truncate to length (no data) */ tcph->doff = sizeof(struct tcphdr)/4; tcph->source = oth->dest; tcph->dest = oth->source; if (oth->ack) { - needs_ack = 0; tcph->seq = oth->ack_seq; - tcph->ack_seq = 0; } else { - needs_ack = 1; tcph->ack_seq = htonl(ntohl(oth->seq) + oth->syn + oth->fin + otcplen - (oth->doff<<2)); - tcph->seq = 0; + tcph->ack = 1; } - /* Reset flags */ - ((u_int8_t *)tcph)[13] = 0; tcph->rst = 1; - tcph->ack = needs_ack; - tcph->window = 0; - tcph->urg_ptr = 0; - tcph->check = 0; /* Adjust TCP checksum */ tcph->check = csum_ipv6_magic(&ipv6_hdr(nskb)->saddr, -- Gitee From e088973dfbac3eab4fc2e2755940b608aae5fd5f Mon Sep 17 00:00:00 2001 From: Huangjie Date: Tue, 31 Dec 2024 09:16:53 +0800 Subject: [PATCH 19/26] drivers: dma: not disable channel after each transfer Signed-off-by: Huangjie --- drivers/dma/phytium/phytium-gdmac.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/dma/phytium/phytium-gdmac.c b/drivers/dma/phytium/phytium-gdmac.c index 3fdf572196b..fe4354cb1a5 100644 --- a/drivers/dma/phytium/phytium-gdmac.c +++ b/drivers/dma/phytium/phytium-gdmac.c @@ -753,8 +753,6 @@ static irqreturn_t phytium_dma_interrupt(int irq, void *dev_id) if (gdma->chan[i].desc) { phytium_chan_irq_handler(gdma_chan); - phytium_chan_disable(gdma_chan); - phytium_chan_clk_disable(gdma_chan); } } } -- Gitee From 04218d9cbc58316ab7ae166c7a5beaa79e36e981 Mon Sep 17 00:00:00 2001 From: Huangjie Date: Tue, 31 Dec 2024 09:22:20 +0800 Subject: [PATCH 20/26] drivers: dma: not wait dma state in terminate_all() callback Signed-off-by: Huangjie --- drivers/dma/phytium/phytium-gdmac.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/drivers/dma/phytium/phytium-gdmac.c b/drivers/dma/phytium/phytium-gdmac.c index fe4354cb1a5..a39ea6c8ad7 100644 --- a/drivers/dma/phytium/phytium-gdmac.c +++ b/drivers/dma/phytium/phytium-gdmac.c @@ -475,8 +475,6 @@ static int phytium_gdma_terminate_all(struct dma_chan *chan) { struct phytium_gdma_chan *gdma_chan = to_gdma_chan(chan); unsigned long flags = 0; - u32 val = 0; - int ret = 0; LIST_HEAD(head); spin_lock_irqsave(&gdma_chan->vchan.lock, flags); @@ -487,12 +485,9 @@ static int phytium_gdma_terminate_all(struct dma_chan *chan) vchan_terminate_vdesc(&gdma_chan->desc->vdesc); gdma_chan->desc = NULL; phytium_chan_disable(gdma_chan); - ret = readl_poll_timeout(gdma_chan->base + DMA_CX_STATE, val, - ~(val & BIT(4)), 10, 10000); - if (ret) - dev_err(chan_to_dev(gdma_chan), - "failed to complete writes\n"); phytium_chan_reset(gdma_chan); + phytium_chan_irq_disable(gdma_chan); + phytium_chan_clk_disable(gdma_chan); } vchan_get_all_descriptors(&gdma_chan->vchan, &head); -- Gitee From 7c27aea93a3243ca57779c1fa6248b6b6414e530 Mon Sep 17 00:00:00 2001 From: Huangjie Date: Tue, 31 Dec 2024 09:25:39 +0800 Subject: [PATCH 21/26] drivers: dma: disable channel clock when free channel Signed-off-by: Huangjie --- drivers/dma/phytium/phytium-gdmac.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/dma/phytium/phytium-gdmac.c b/drivers/dma/phytium/phytium-gdmac.c index a39ea6c8ad7..27c4a6d6c8d 100644 --- a/drivers/dma/phytium/phytium-gdmac.c +++ b/drivers/dma/phytium/phytium-gdmac.c @@ -519,10 +519,11 @@ static void phytium_gdma_free_chan_resources(struct dma_chan *chan) phytium_chan_disable(gdma_chan); phytium_chan_irq_disable(gdma_chan); + phytium_chan_clk_disable(gdma_chan); vchan_free_chan_resources(&gdma_chan->vchan); - dev_dbg(gdma->dev, "free channel %d\n", gdma_chan->id); + dev_info(gdma->dev, "free channel %d\n", gdma_chan->id); } static int phytium_gdma_slave_config(struct dma_chan *chan, -- Gitee From 9c0ae6f583e2881fe30bd29cd2f5b4a45bb6b0e4 Mon Sep 17 00:00:00 2001 From: Huangjie Date: Tue, 31 Dec 2024 09:48:55 +0800 Subject: [PATCH 22/26] drivers: dma: modify phytium gdma driver version to 1.0.3 Signed-off-by: Huangjie --- drivers/dma/phytium/phytium-gdmac.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/dma/phytium/phytium-gdmac.c b/drivers/dma/phytium/phytium-gdmac.c index 27c4a6d6c8d..0154d6151e5 100644 --- a/drivers/dma/phytium/phytium-gdmac.c +++ b/drivers/dma/phytium/phytium-gdmac.c @@ -29,7 +29,7 @@ #include #include "phytium-gdmac.h" -#define PHYTIUM_GDMA_DRIVER_VERSION "1.0.2" +#define PHYTIUM_GDMA_DRIVER_VERSION "1.0.3" static inline struct phytium_gdma_device *to_gdma_device(struct dma_chan *chan) { -- Gitee From 5f81259fb3ec440aa058a54adfa8be4b2ade2b2b Mon Sep 17 00:00:00 2001 From: Huangjie Date: Mon, 13 Jan 2025 14:01:33 +0800 Subject: [PATCH 23/26] Revert "driver: arm_scmi: fix scmi transfer timeout in preemption kernel" This reverts commit 92890cdb4b97e5d16aea67725584bcac4a94ceff. --- drivers/firmware/arm_scmi/driver.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/drivers/firmware/arm_scmi/driver.c b/drivers/firmware/arm_scmi/driver.c index e1681bba333..9b2dbd01367 100644 --- a/drivers/firmware/arm_scmi/driver.c +++ b/drivers/firmware/arm_scmi/driver.c @@ -51,8 +51,6 @@ static LIST_HEAD(scmi_list); static DEFINE_MUTEX(scmi_list_mutex); /* Track the unique id for the transfers for debug & profiling purpose */ static atomic_t transfer_last_id; -/* Protection for scmi xfer, prevent transmission timeout */ -static DEFINE_MUTEX(scmi_xfer_mutex); /** * struct scmi_xfers_info - Structure to manage transfer information @@ -370,9 +368,6 @@ int scmi_do_xfer(const struct scmi_handle *handle, struct scmi_xfer *xfer) xfer->hdr.poll_completion = true; #endif - /* lock scmi xfer, too many scmi xfers may cause timeout */ - mutex_lock(&scmi_xfer_mutex); - trace_scmi_xfer_begin(xfer->transfer_id, xfer->hdr.id, xfer->hdr.protocol_id, xfer->hdr.seq, xfer->hdr.poll_completion); @@ -380,7 +375,6 @@ int scmi_do_xfer(const struct scmi_handle *handle, struct scmi_xfer *xfer) ret = info->desc->ops->send_message(cinfo, xfer); if (ret < 0) { dev_dbg(dev, "Failed to send message %d\n", ret); - mutex_unlock(&scmi_xfer_mutex); return ret; } @@ -390,8 +384,7 @@ int scmi_do_xfer(const struct scmi_handle *handle, struct scmi_xfer *xfer) spin_until_cond(scmi_xfer_done_no_timeout(cinfo, xfer, stop)); - if (ktime_before(ktime_get(), stop) || - info->desc->ops->poll_done(cinfo, xfer)) + if (ktime_before(ktime_get(), stop)) info->desc->ops->fetch_response(cinfo, xfer); else ret = -ETIMEDOUT; @@ -413,7 +406,6 @@ int scmi_do_xfer(const struct scmi_handle *handle, struct scmi_xfer *xfer) trace_scmi_xfer_end(xfer->transfer_id, xfer->hdr.id, xfer->hdr.protocol_id, xfer->hdr.seq, ret); - mutex_unlock(&scmi_xfer_mutex); return ret; } -- Gitee From f5cf2b5a0354fe0486c289a3e73c0f36217cfc51 Mon Sep 17 00:00:00 2001 From: Justin Chen Date: Mon, 14 Oct 2024 09:07:17 -0700 Subject: [PATCH 24/26] firmware: arm_scmi: Queue in scmi layer for mailbox implementation [ Upstream commit da1642bc97c4ef67f347edcd493bd0a52f88777b ] send_message() does not block in the MBOX implementation. This is because the mailbox layer has its own queue. However, this confuses the per xfer timeouts as they all start their timeout ticks in parallel. Consider a case where the xfer timeout is 30ms and a SCMI transaction takes 25ms: | 0ms: Message #0 is queued in mailbox layer and sent out, then sits | at scmi_wait_for_message_response() with a timeout of 30ms | 1ms: Message #1 is queued in mailbox layer but not sent out yet. | Since send_message() doesn't block, it also sits at | scmi_wait_for_message_response() with a timeout of 30ms | ... | 25ms: Message #0 is completed, txdone is called and message #1 is sent | 31ms: Message #1 times out since the count started at 1ms. Even though | it has only been inflight for 6ms. Fixes: 5c8a47a5a91d ("firmware: arm_scmi: Make scmi core independent of the transport type") Signed-off-by: Justin Chen Message-Id: <20241014160717.1678953-1-justin.chen@broadcom.com> Reviewed-by: Cristian Marussi Tested-by: Cristian Marussi Signed-off-by: Sudeep Holla Signed-off-by: Sasha Levin --- drivers/firmware/arm_scmi/mailbox.c | 32 +++++++++++++++++++---------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/drivers/firmware/arm_scmi/mailbox.c b/drivers/firmware/arm_scmi/mailbox.c index ad773a657ed..2d370788cca 100644 --- a/drivers/firmware/arm_scmi/mailbox.c +++ b/drivers/firmware/arm_scmi/mailbox.c @@ -22,12 +22,14 @@ * @chan: Transmit/Receive mailbox channel * @cinfo: SCMI channel info * @shmem: Transmit/Receive shared memory area + * @chan_lock: Lock that prevents multiple xfers from being queued */ struct scmi_mailbox { struct mbox_client cl; struct mbox_chan *chan; struct scmi_chan_info *cinfo; struct scmi_shared_mem __iomem *shmem; + struct mutex chan_lock; }; #define client_to_scmi_mailbox(c) container_of(c, struct scmi_mailbox, cl) @@ -138,6 +140,7 @@ static int mailbox_chan_setup(struct scmi_chan_info *cinfo, struct device *dev, cinfo->transport_info = smbox; smbox->cinfo = cinfo; + mutex_init(&smbox->chan_lock); return 0; } @@ -165,26 +168,33 @@ static int mailbox_send_message(struct scmi_chan_info *cinfo, struct scmi_mailbox *smbox = cinfo->transport_info; int ret; - ret = mbox_send_message(smbox->chan, xfer); + /* + * The mailbox layer has its own queue. However the mailbox queue + * confuses the per message SCMI timeouts since the clock starts when + * the message is submitted into the mailbox queue. So when multiple + * messages are queued up the clock starts on all messages instead of + * only the one inflight. + */ + mutex_lock(&smbox->chan_lock); - /* mbox_send_message returns non-negative value on success, so reset */ - if (ret > 0) - ret = 0; + ret = mbox_send_message(smbox->chan, xfer); + /* mbox_send_message returns non-negative value on success */ + if (ret < 0) { + mutex_unlock(&smbox->chan_lock); + return ret; + } - return ret; + return 0; } static void mailbox_mark_txdone(struct scmi_chan_info *cinfo, int ret) { struct scmi_mailbox *smbox = cinfo->transport_info; - /* - * NOTE: we might prefer not to need the mailbox ticker to manage the - * transfer queueing since the protocol layer queues things by itself. - * Unfortunately, we have to kick the mailbox framework after we have - * received our message. - */ mbox_client_txdone(smbox->chan, ret); + + /* Release channel */ + mutex_unlock(&smbox->chan_lock); } static void mailbox_fetch_response(struct scmi_chan_info *cinfo, -- Gitee From 3951c1184c989ccc33268e36159aa8761506068f Mon Sep 17 00:00:00 2001 From: Huangjie Date: Mon, 20 Jan 2025 14:08:57 +0800 Subject: [PATCH 25/26] dirvers: scmi: poll again when transfer reach timeout to prevent transfer timeout caused by preemption Signed-off-by: Huangjie --- drivers/firmware/arm_scmi/driver.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/firmware/arm_scmi/driver.c b/drivers/firmware/arm_scmi/driver.c index 9b2dbd01367..6a25d71b3c7 100644 --- a/drivers/firmware/arm_scmi/driver.c +++ b/drivers/firmware/arm_scmi/driver.c @@ -384,7 +384,8 @@ int scmi_do_xfer(const struct scmi_handle *handle, struct scmi_xfer *xfer) spin_until_cond(scmi_xfer_done_no_timeout(cinfo, xfer, stop)); - if (ktime_before(ktime_get(), stop)) + if (ktime_before(ktime_get(), stop) || + info->desc->ops->poll_done(cinfo, xfer)) info->desc->ops->fetch_response(cinfo, xfer); else ret = -ETIMEDOUT; -- Gitee From 7b787a8c53e522e122d35912c830849321aa9ae4 Mon Sep 17 00:00:00 2001 From: Huangjie Date: Wed, 15 Jan 2025 15:59:47 +0800 Subject: [PATCH 26/26] dirver: qspi: clear wr_cfg reg only during suspend Signed-off-by: Huangjie --- drivers/spi/spi-phytium-qspi.c | 37 ++++++++-------------------------- 1 file changed, 8 insertions(+), 29 deletions(-) diff --git a/drivers/spi/spi-phytium-qspi.c b/drivers/spi/spi-phytium-qspi.c index 8695b627c85..d044ff6082f 100755 --- a/drivers/spi/spi-phytium-qspi.c +++ b/drivers/spi/spi-phytium-qspi.c @@ -286,29 +286,6 @@ static int phytium_qspi_flash_capacity_encode(u32 size, u32 *cap) return ret; } -static void phytium_qspi_clear_wr(struct phytium_qspi *qspi, - struct phytium_qspi_flash *flash) -{ - u32 cmd = 0; - u32 state = 0; - int ret = 0; - - cmd |= 0x05 << QSPI_CMD_PORT_CMD_SHIFT; - cmd |= BIT(QSPI_CMD_PORT_TRANSFER_SHIFT); - cmd |= flash->cs << QSPI_CMD_PORT_CS_SHIFT; - - writel_relaxed(cmd, qspi->io_base + QSPI_CMD_PORT_REG); - readl_relaxed(qspi->io_base + QSPI_LD_PORT_REG); - - ret = readl_poll_timeout(qspi->io_base + QSPI_LD_PORT_REG, - state, !(state & 0x01), 10, 100000); - if (ret) - dev_err(qspi->dev, "wait device timeout\n"); - - /* clear wr_cfg */ - writel_relaxed(0x0, qspi->io_base + QSPI_WR_CFG_REG); -} - static int phytium_qspi_write_port(struct phytium_qspi *qspi, const u8 *buf, const size_t len) { @@ -513,6 +490,7 @@ static int phytium_qspi_dirmap_create(struct spi_mem_dirmap_desc *desc) cmd |= QSPI_WR_CFG_WR_MODE_MASK; cmd |= flash->clk_div & QSPI_WR_CFG_WR_SCK_SEL_MASK; + writel_relaxed(cmd, qspi->io_base + QSPI_WR_CFG_REG); qspi->wr_cfg_reg = cmd; } else { ret = -EINVAL; @@ -550,9 +528,6 @@ static ssize_t phytium_qspi_dirmap_write(struct spi_mem_dirmap_desc *desc, size_t mask = 0x03; u_char tmp[4] = {0}; - /* set wr_cfg for drimap write */ - writel_relaxed(qspi->wr_cfg_reg, qspi->io_base + QSPI_WR_CFG_REG); - if (offs & 0x03) { dev_err(qspi->dev, "Addr not four-byte aligned!\n"); return -EINVAL; @@ -570,8 +545,6 @@ static ssize_t phytium_qspi_dirmap_write(struct spi_mem_dirmap_desc *desc, //write cache data to flash writel_relaxed(QSPI_FLUSH_EN, qspi->io_base + QSPI_FLUSH_REG); - phytium_qspi_clear_wr(qspi, flash); - return len; } @@ -796,6 +769,11 @@ static int phytium_qspi_remove(struct platform_device *pdev) static int __maybe_unused phytium_qspi_suspend(struct device *dev) { + struct phytium_qspi *qspi = dev_get_drvdata(dev); + + /* clear rd_cfg reg and wr_cfg reg when suspend */ + writel_relaxed(0, qspi->io_base + QSPI_RD_CFG_REG); + writel_relaxed(0, qspi->io_base + QSPI_WR_CFG_REG); return pm_runtime_force_suspend(dev); } @@ -803,8 +781,9 @@ static int __maybe_unused phytium_qspi_resume(struct device *dev) { struct phytium_qspi *qspi = dev_get_drvdata(dev); - /* set rd_cfg reg and flash_capacity reg after resume */ + /* set rd_cfg reg, wr_cfg reg and flash_capacity reg after resume */ writel_relaxed(qspi->rd_cfg_reg, qspi->io_base + QSPI_RD_CFG_REG); + writel_relaxed(qspi->wr_cfg_reg, qspi->io_base + QSPI_WR_CFG_REG); writel_relaxed(qspi->flash_cap, qspi->io_base + QSPI_FLASH_CAP_REG); return pm_runtime_force_resume(dev); } -- Gitee