From: Greg Kroah-Hartman Date: Mon, 22 Aug 2022 13:07:18 +0000 (+0200) Subject: 5.4-stable patches X-Git-Tag: v4.9.326~36 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=5247a96f0fe271d779d2e3e93fc31659d4a2460e;p=thirdparty%2Fkernel%2Fstable-queue.git 5.4-stable patches added patches: fec-fix-timer-capture-timing-in-fec_ptp_enable_pps.patch gcc-plugins-undefine-latent_entropy_plugin-when-plugin-disabled-for-a-file.patch i40e-fix-to-stop-tx_timeout-recovery-if-globr-fails.patch ice-ignore-eexist-when-setting-promisc-mode.patch igb-add-lock-to-avoid-data-race.patch net-dsa-microchip-ksz9477-fix-fdb_dump-last-invalid-entry.patch net-dsa-mv88e6060-prevent-crash-on-an-unused-port.patch net-moxa-pass-pdev-instead-of-ndev-to-dma-functions.patch netfilter-nf_tables-really-skip-inactive-sets-when-allocating-name.patch powerpc-pci-fix-get_phb_number-locking.patch --- diff --git a/queue-5.4/fec-fix-timer-capture-timing-in-fec_ptp_enable_pps.patch b/queue-5.4/fec-fix-timer-capture-timing-in-fec_ptp_enable_pps.patch new file mode 100644 index 00000000000..d0dd4e21022 --- /dev/null +++ b/queue-5.4/fec-fix-timer-capture-timing-in-fec_ptp_enable_pps.patch @@ -0,0 +1,39 @@ +From 61d5e2a251fb20c2c5e998c3f1d52ed6d5360319 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Cs=C3=B3k=C3=A1s=20Bence?= +Date: Thu, 11 Aug 2022 12:13:49 +0200 +Subject: fec: Fix timer capture timing in `fec_ptp_enable_pps()` +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +From: Csókás Bence + +commit 61d5e2a251fb20c2c5e998c3f1d52ed6d5360319 upstream. + +Code reimplements functionality already in `fec_ptp_read()`, +but misses check for FEC_QUIRK_BUG_CAPTURE. Replace with function call. + +Fixes: 28b5f058cf1d ("net: fec: ptp: fix convergence issue to support LinuxPTP stack") +Signed-off-by: Csókás Bence +Link: https://lore.kernel.org/r/20220811101348.13755-1-csokas.bence@prolan.hu +Signed-off-by: Jakub Kicinski +Signed-off-by: Greg Kroah-Hartman +--- + drivers/net/ethernet/freescale/fec_ptp.c | 6 +----- + 1 file changed, 1 insertion(+), 5 deletions(-) + +--- a/drivers/net/ethernet/freescale/fec_ptp.c ++++ b/drivers/net/ethernet/freescale/fec_ptp.c +@@ -141,11 +141,7 @@ static int fec_ptp_enable_pps(struct fec + * NSEC_PER_SEC - ts.tv_nsec. Add the remaining nanoseconds + * to current timer would be next second. + */ +- tempval = readl(fep->hwp + FEC_ATIME_CTRL); +- tempval |= FEC_T_CTRL_CAPTURE; +- writel(tempval, fep->hwp + FEC_ATIME_CTRL); +- +- tempval = readl(fep->hwp + FEC_ATIME); ++ tempval = fep->cc.read(&fep->cc); + /* Convert the ptp local counter to 1588 timestamp */ + ns = timecounter_cyc2time(&fep->tc, tempval); + ts = ns_to_timespec64(ns); diff --git a/queue-5.4/gcc-plugins-undefine-latent_entropy_plugin-when-plugin-disabled-for-a-file.patch b/queue-5.4/gcc-plugins-undefine-latent_entropy_plugin-when-plugin-disabled-for-a-file.patch new file mode 100644 index 00000000000..3f059392b3e --- /dev/null +++ b/queue-5.4/gcc-plugins-undefine-latent_entropy_plugin-when-plugin-disabled-for-a-file.patch @@ -0,0 +1,73 @@ +From 012e8d2034f1bda8863435cd589636e618d6a659 Mon Sep 17 00:00:00 2001 +From: Andrew Donnellan +Date: Tue, 16 Aug 2022 15:17:20 +1000 +Subject: gcc-plugins: Undefine LATENT_ENTROPY_PLUGIN when plugin disabled for a file + +From: Andrew Donnellan + +commit 012e8d2034f1bda8863435cd589636e618d6a659 upstream. + +Commit 36d4b36b6959 ("lib/nodemask: inline next_node_in() and +node_random()") refactored some code by moving node_random() from +lib/nodemask.c to include/linux/nodemask.h, thus requiring nodemask.h to +include random.h, which conditionally defines add_latent_entropy() +depending on whether the macro LATENT_ENTROPY_PLUGIN is defined. + +This broke the build on powerpc, where nodemask.h is indirectly included +in arch/powerpc/kernel/prom_init.c, part of the early boot machinery that +is excluded from the latent entropy plugin using +DISABLE_LATENT_ENTROPY_PLUGIN. It turns out that while we add a gcc flag +to disable the actual plugin, we don't undefine LATENT_ENTROPY_PLUGIN. + +This leads to the following: + + CC arch/powerpc/kernel/prom_init.o + In file included from ./include/linux/nodemask.h:97, + from ./include/linux/mmzone.h:17, + from ./include/linux/gfp.h:7, + from ./include/linux/xarray.h:15, + from ./include/linux/radix-tree.h:21, + from ./include/linux/idr.h:15, + from ./include/linux/kernfs.h:12, + from ./include/linux/sysfs.h:16, + from ./include/linux/kobject.h:20, + from ./include/linux/pci.h:35, + from arch/powerpc/kernel/prom_init.c:24: + ./include/linux/random.h: In function 'add_latent_entropy': + ./include/linux/random.h:25:46: error: 'latent_entropy' undeclared (first use in this function); did you mean 'add_latent_entropy'? + 25 | add_device_randomness((const void *)&latent_entropy, sizeof(latent_entropy)); + | ^~~~~~~~~~~~~~ + | add_latent_entropy + ./include/linux/random.h:25:46: note: each undeclared identifier is reported only once for each function it appears in + make[2]: *** [scripts/Makefile.build:249: arch/powerpc/kernel/prom_init.o] Fehler 1 + make[1]: *** [scripts/Makefile.build:465: arch/powerpc/kernel] Fehler 2 + make: *** [Makefile:1855: arch/powerpc] Error 2 + +Change the DISABLE_LATENT_ENTROPY_PLUGIN flags to undefine +LATENT_ENTROPY_PLUGIN for files where the plugin is disabled. + +Cc: Yury Norov +Fixes: 38addce8b600 ("gcc-plugins: Add latent_entropy plugin") +Link: https://bugzilla.kernel.org/show_bug.cgi?id=216367 +Link: https://lore.kernel.org/linuxppc-dev/alpine.DEB.2.22.394.2208152006320.289321@ramsan.of.borg/ +Reported-by: Erhard Furtner +Signed-off-by: Andrew Donnellan +Reviewed-by: Yury Norov +Signed-off-by: Kees Cook +Link: https://lore.kernel.org/r/20220816051720.44108-1-ajd@linux.ibm.com +Signed-off-by: Greg Kroah-Hartman +--- + scripts/Makefile.gcc-plugins | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/scripts/Makefile.gcc-plugins ++++ b/scripts/Makefile.gcc-plugins +@@ -6,7 +6,7 @@ gcc-plugin-$(CONFIG_GCC_PLUGIN_LATENT_EN + gcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_LATENT_ENTROPY) \ + += -DLATENT_ENTROPY_PLUGIN + ifdef CONFIG_GCC_PLUGIN_LATENT_ENTROPY +- DISABLE_LATENT_ENTROPY_PLUGIN += -fplugin-arg-latent_entropy_plugin-disable ++ DISABLE_LATENT_ENTROPY_PLUGIN += -fplugin-arg-latent_entropy_plugin-disable -ULATENT_ENTROPY_PLUGIN + endif + export DISABLE_LATENT_ENTROPY_PLUGIN + diff --git a/queue-5.4/i40e-fix-to-stop-tx_timeout-recovery-if-globr-fails.patch b/queue-5.4/i40e-fix-to-stop-tx_timeout-recovery-if-globr-fails.patch new file mode 100644 index 00000000000..ec142d47cd7 --- /dev/null +++ b/queue-5.4/i40e-fix-to-stop-tx_timeout-recovery-if-globr-fails.patch @@ -0,0 +1,42 @@ +From 57c942bc3bef0970f0b21f8e0998e76a900ea80d Mon Sep 17 00:00:00 2001 +From: Alan Brady +Date: Tue, 2 Aug 2022 10:19:17 +0200 +Subject: i40e: Fix to stop tx_timeout recovery if GLOBR fails + +From: Alan Brady + +commit 57c942bc3bef0970f0b21f8e0998e76a900ea80d upstream. + +When a tx_timeout fires, the PF attempts to recover by incrementally +resetting. First we try a PFR, then CORER and finally a GLOBR. If the +GLOBR fails, then we keep hitting the tx_timeout and incrementing the +recovery level and issuing dmesgs, which is both annoying to the user +and accomplishes nothing. + +If the GLOBR fails, then we're pretty much totally hosed, and there's +not much else we can do to recover, so this makes it such that we just +kill the VSI and stop hitting the tx_timeout in such a case. + +Fixes: 41c445ff0f48 ("i40e: main driver core") +Signed-off-by: Alan Brady +Signed-off-by: Mateusz Palczewski +Tested-by: Gurucharan (A Contingent worker at Intel) +Signed-off-by: Tony Nguyen +Signed-off-by: Greg Kroah-Hartman +--- + drivers/net/ethernet/intel/i40e/i40e_main.c | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +--- a/drivers/net/ethernet/intel/i40e/i40e_main.c ++++ b/drivers/net/ethernet/intel/i40e/i40e_main.c +@@ -409,7 +409,9 @@ static void i40e_tx_timeout(struct net_d + set_bit(__I40E_GLOBAL_RESET_REQUESTED, pf->state); + break; + default: +- netdev_err(netdev, "tx_timeout recovery unsuccessful\n"); ++ netdev_err(netdev, "tx_timeout recovery unsuccessful, device is in non-recoverable state.\n"); ++ set_bit(__I40E_DOWN_REQUESTED, pf->state); ++ set_bit(__I40E_VSI_DOWN_REQUESTED, vsi->state); + break; + } + diff --git a/queue-5.4/ice-ignore-eexist-when-setting-promisc-mode.patch b/queue-5.4/ice-ignore-eexist-when-setting-promisc-mode.patch new file mode 100644 index 00000000000..6b07a848417 --- /dev/null +++ b/queue-5.4/ice-ignore-eexist-when-setting-promisc-mode.patch @@ -0,0 +1,38 @@ +From 11e551a2efa4481bd4f616ab75374a2710b480e9 Mon Sep 17 00:00:00 2001 +From: Grzegorz Siwik +Date: Fri, 12 Aug 2022 15:25:48 +0200 +Subject: ice: Ignore EEXIST when setting promisc mode + +From: Grzegorz Siwik + +commit 11e551a2efa4481bd4f616ab75374a2710b480e9 upstream. + +Ignore EEXIST error when setting promiscuous mode. +This fix is needed because the driver could set promiscuous mode +when it still has not cleared properly. +Promiscuous mode could be set only once, so setting it second +time will be rejected. + +Fixes: 5eda8afd6bcc ("ice: Add support for PF/VF promiscuous mode") +Signed-off-by: Grzegorz Siwik +Link: https://lore.kernel.org/all/CAK8fFZ7m-KR57M_rYX6xZN39K89O=LGooYkKsu6HKt0Bs+x6xQ@mail.gmail.com/ +Tested-by: Jaroslav Pulchart +Tested-by: Igor Raits +Tested-by: Gurucharan (A Contingent worker at Intel) +Signed-off-by: Tony Nguyen +Signed-off-by: Greg Kroah-Hartman +--- + drivers/net/ethernet/intel/ice/ice_switch.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/drivers/net/ethernet/intel/ice/ice_switch.c ++++ b/drivers/net/ethernet/intel/ice/ice_switch.c +@@ -2627,7 +2627,7 @@ ice_set_vlan_vsi_promisc(struct ice_hw * + else + status = ice_set_vsi_promisc(hw, vsi_handle, + promisc_mask, vlan_id); +- if (status) ++ if (status && status != -EEXIST) + break; + } + diff --git a/queue-5.4/igb-add-lock-to-avoid-data-race.patch b/queue-5.4/igb-add-lock-to-avoid-data-race.patch new file mode 100644 index 00000000000..f63464307a3 --- /dev/null +++ b/queue-5.4/igb-add-lock-to-avoid-data-race.patch @@ -0,0 +1,126 @@ +From 6faee3d4ee8be0f0367d0c3d826afb3571b7a5e0 Mon Sep 17 00:00:00 2001 +From: Lin Ma +Date: Wed, 17 Aug 2022 11:49:21 -0700 +Subject: igb: Add lock to avoid data race + +From: Lin Ma + +commit 6faee3d4ee8be0f0367d0c3d826afb3571b7a5e0 upstream. + +The commit c23d92b80e0b ("igb: Teardown SR-IOV before +unregister_netdev()") places the unregister_netdev() call after the +igb_disable_sriov() call to avoid functionality issue. + +However, it introduces several race conditions when detaching a device. +For example, when .remove() is called, the below interleaving leads to +use-after-free. + + (FREE from device detaching) | (USE from netdev core) +igb_remove | igb_ndo_get_vf_config + igb_disable_sriov | vf >= adapter->vfs_allocated_count? + kfree(adapter->vf_data) | + adapter->vfs_allocated_count = 0 | + | memcpy(... adapter->vf_data[vf] + +Moreover, the igb_disable_sriov() also suffers from data race with the +requests from VF driver. + + (FREE from device detaching) | (USE from requests) +igb_remove | igb_msix_other + igb_disable_sriov | igb_msg_task + kfree(adapter->vf_data) | vf < adapter->vfs_allocated_count + adapter->vfs_allocated_count = 0 | + +To this end, this commit first eliminates the data races from netdev +core by using rtnl_lock (similar to commit 719479230893 ("dpaa2-eth: add +MAC/PHY support through phylink")). And then adds a spinlock to +eliminate races from driver requests. (similar to commit 1e53834ce541 +("ixgbe: Add locking to prevent panic when setting sriov_numvfs to zero") + +Fixes: c23d92b80e0b ("igb: Teardown SR-IOV before unregister_netdev()") +Signed-off-by: Lin Ma +Tested-by: Konrad Jankowski +Signed-off-by: Tony Nguyen +Link: https://lore.kernel.org/r/20220817184921.735244-1-anthony.l.nguyen@intel.com +Signed-off-by: Jakub Kicinski +Signed-off-by: Greg Kroah-Hartman +--- + drivers/net/ethernet/intel/igb/igb.h | 2 ++ + drivers/net/ethernet/intel/igb/igb_main.c | 12 +++++++++++- + 2 files changed, 13 insertions(+), 1 deletion(-) + +--- a/drivers/net/ethernet/intel/igb/igb.h ++++ b/drivers/net/ethernet/intel/igb/igb.h +@@ -594,6 +594,8 @@ struct igb_adapter { + struct igb_mac_addr *mac_table; + struct vf_mac_filter vf_macs; + struct vf_mac_filter *vf_mac_list; ++ /* lock for VF resources */ ++ spinlock_t vfs_lock; + }; + + /* flags controlling PTP/1588 function */ +--- a/drivers/net/ethernet/intel/igb/igb_main.c ++++ b/drivers/net/ethernet/intel/igb/igb_main.c +@@ -3491,6 +3491,7 @@ static int igb_disable_sriov(struct pci_ + struct net_device *netdev = pci_get_drvdata(pdev); + struct igb_adapter *adapter = netdev_priv(netdev); + struct e1000_hw *hw = &adapter->hw; ++ unsigned long flags; + + /* reclaim resources allocated to VFs */ + if (adapter->vf_data) { +@@ -3503,12 +3504,13 @@ static int igb_disable_sriov(struct pci_ + pci_disable_sriov(pdev); + msleep(500); + } +- ++ spin_lock_irqsave(&adapter->vfs_lock, flags); + kfree(adapter->vf_mac_list); + adapter->vf_mac_list = NULL; + kfree(adapter->vf_data); + adapter->vf_data = NULL; + adapter->vfs_allocated_count = 0; ++ spin_unlock_irqrestore(&adapter->vfs_lock, flags); + wr32(E1000_IOVCTL, E1000_IOVCTL_REUSE_VFQ); + wrfl(); + msleep(100); +@@ -3668,7 +3670,9 @@ static void igb_remove(struct pci_dev *p + igb_release_hw_control(adapter); + + #ifdef CONFIG_PCI_IOV ++ rtnl_lock(); + igb_disable_sriov(pdev); ++ rtnl_unlock(); + #endif + + unregister_netdev(netdev); +@@ -3829,6 +3833,9 @@ static int igb_sw_init(struct igb_adapte + + spin_lock_init(&adapter->nfc_lock); + spin_lock_init(&adapter->stats64_lock); ++ ++ /* init spinlock to avoid concurrency of VF resources */ ++ spin_lock_init(&adapter->vfs_lock); + #ifdef CONFIG_PCI_IOV + switch (hw->mac.type) { + case e1000_82576: +@@ -7569,8 +7576,10 @@ unlock: + static void igb_msg_task(struct igb_adapter *adapter) + { + struct e1000_hw *hw = &adapter->hw; ++ unsigned long flags; + u32 vf; + ++ spin_lock_irqsave(&adapter->vfs_lock, flags); + for (vf = 0; vf < adapter->vfs_allocated_count; vf++) { + /* process any reset requests */ + if (!igb_check_for_rst(hw, vf)) +@@ -7584,6 +7593,7 @@ static void igb_msg_task(struct igb_adap + if (!igb_check_for_ack(hw, vf)) + igb_rcv_ack_from_vf(adapter, vf); + } ++ spin_unlock_irqrestore(&adapter->vfs_lock, flags); + } + + /** diff --git a/queue-5.4/net-dsa-microchip-ksz9477-fix-fdb_dump-last-invalid-entry.patch b/queue-5.4/net-dsa-microchip-ksz9477-fix-fdb_dump-last-invalid-entry.patch new file mode 100644 index 00000000000..e0f315f0532 --- /dev/null +++ b/queue-5.4/net-dsa-microchip-ksz9477-fix-fdb_dump-last-invalid-entry.patch @@ -0,0 +1,41 @@ +From 36c0d935015766bf20d621c18313f17691bda5e3 Mon Sep 17 00:00:00 2001 +From: Arun Ramadoss +Date: Tue, 16 Aug 2022 16:25:16 +0530 +Subject: net: dsa: microchip: ksz9477: fix fdb_dump last invalid entry + +From: Arun Ramadoss + +commit 36c0d935015766bf20d621c18313f17691bda5e3 upstream. + +In the ksz9477_fdb_dump function it reads the ALU control register and +exit from the timeout loop if there is valid entry or search is +complete. After exiting the loop, it reads the alu entry and report to +the user space irrespective of entry is valid. It works till the valid +entry. If the loop exited when search is complete, it reads the alu +table. The table returns all ones and it is reported to user space. So +bridge fdb show gives ff:ff:ff:ff:ff:ff as last entry for every port. +To fix it, after exiting the loop the entry is reported only if it is +valid one. + +Fixes: b987e98e50ab ("dsa: add DSA switch driver for Microchip KSZ9477") +Signed-off-by: Arun Ramadoss +Reviewed-by: Vladimir Oltean +Link: https://lore.kernel.org/r/20220816105516.18350-1-arun.ramadoss@microchip.com +Signed-off-by: Jakub Kicinski +Signed-off-by: Greg Kroah-Hartman +--- + drivers/net/dsa/microchip/ksz9477.c | 3 +++ + 1 file changed, 3 insertions(+) + +--- a/drivers/net/dsa/microchip/ksz9477.c ++++ b/drivers/net/dsa/microchip/ksz9477.c +@@ -766,6 +766,9 @@ static int ksz9477_port_fdb_dump(struct + goto exit; + } + ++ if (!(ksz_data & ALU_VALID)) ++ continue; ++ + /* read ALU table */ + ksz9477_read_table(dev, alu_table); + diff --git a/queue-5.4/net-dsa-mv88e6060-prevent-crash-on-an-unused-port.patch b/queue-5.4/net-dsa-mv88e6060-prevent-crash-on-an-unused-port.patch new file mode 100644 index 00000000000..2b8e0dd4038 --- /dev/null +++ b/queue-5.4/net-dsa-mv88e6060-prevent-crash-on-an-unused-port.patch @@ -0,0 +1,53 @@ +From 246bbf2f977ea36aaf41f5d24370fef433250728 Mon Sep 17 00:00:00 2001 +From: Sergei Antonov +Date: Thu, 11 Aug 2022 10:09:39 +0300 +Subject: net: dsa: mv88e6060: prevent crash on an unused port + +From: Sergei Antonov + +commit 246bbf2f977ea36aaf41f5d24370fef433250728 upstream. + +If the port isn't a CPU port nor a user port, 'cpu_dp' +is a null pointer and a crash happened on dereferencing +it in mv88e6060_setup_port(): + +[ 9.575872] Unable to handle kernel NULL pointer dereference at virtual address 00000014 +... +[ 9.942216] mv88e6060_setup from dsa_register_switch+0x814/0xe84 +[ 9.948616] dsa_register_switch from mdio_probe+0x2c/0x54 +[ 9.954433] mdio_probe from really_probe.part.0+0x98/0x2a0 +[ 9.960375] really_probe.part.0 from driver_probe_device+0x30/0x10c +[ 9.967029] driver_probe_device from __device_attach_driver+0xb8/0x13c +[ 9.973946] __device_attach_driver from bus_for_each_drv+0x90/0xe0 +[ 9.980509] bus_for_each_drv from __device_attach+0x110/0x184 +[ 9.986632] __device_attach from bus_probe_device+0x8c/0x94 +[ 9.992577] bus_probe_device from deferred_probe_work_func+0x78/0xa8 +[ 9.999311] deferred_probe_work_func from process_one_work+0x290/0x73c +[ 10.006292] process_one_work from worker_thread+0x30/0x4b8 +[ 10.012155] worker_thread from kthread+0xd4/0x10c +[ 10.017238] kthread from ret_from_fork+0x14/0x3c + +Fixes: 0abfd494deef ("net: dsa: use dedicated CPU port") +CC: Vivien Didelot +CC: Florian Fainelli +Signed-off-by: Sergei Antonov +Signed-off-by: Vladimir Oltean +Link: https://lore.kernel.org/r/20220811070939.1717146-1-saproj@gmail.com +Signed-off-by: Jakub Kicinski +Signed-off-by: Greg Kroah-Hartman +--- + drivers/net/dsa/mv88e6060.c | 3 +++ + 1 file changed, 3 insertions(+) + +--- a/drivers/net/dsa/mv88e6060.c ++++ b/drivers/net/dsa/mv88e6060.c +@@ -117,6 +117,9 @@ static int mv88e6060_setup_port(struct m + int addr = REG_PORT(p); + int ret; + ++ if (dsa_is_unused_port(priv->ds, p)) ++ return 0; ++ + /* Do not force flow control, disable Ingress and Egress + * Header tagging, disable VLAN tunneling, and set the port + * state to Forwarding. Additionally, if this is the CPU diff --git a/queue-5.4/net-moxa-pass-pdev-instead-of-ndev-to-dma-functions.patch b/queue-5.4/net-moxa-pass-pdev-instead-of-ndev-to-dma-functions.patch new file mode 100644 index 00000000000..b74066fe24d --- /dev/null +++ b/queue-5.4/net-moxa-pass-pdev-instead-of-ndev-to-dma-functions.patch @@ -0,0 +1,111 @@ +From 3a12df22a8f68954a4ba48435c06b3d1791c87c4 Mon Sep 17 00:00:00 2001 +From: Sergei Antonov +Date: Fri, 12 Aug 2022 20:13:39 +0300 +Subject: net: moxa: pass pdev instead of ndev to DMA functions + +From: Sergei Antonov + +commit 3a12df22a8f68954a4ba48435c06b3d1791c87c4 upstream. + +dma_map_single() calls fail in moxart_mac_setup_desc_ring() and +moxart_mac_start_xmit() which leads to an incessant output of this: + +[ 16.043925] moxart-ethernet 92000000.mac eth0: DMA mapping error +[ 16.050957] moxart-ethernet 92000000.mac eth0: DMA mapping error +[ 16.058229] moxart-ethernet 92000000.mac eth0: DMA mapping error + +Passing pdev to DMA is a common approach among net drivers. + +Fixes: 6c821bd9edc9 ("net: Add MOXA ART SoCs ethernet driver") +Signed-off-by: Sergei Antonov +Suggested-by: Andrew Lunn +Reviewed-by: Andrew Lunn +Link: https://lore.kernel.org/r/20220812171339.2271788-1-saproj@gmail.com +Signed-off-by: Jakub Kicinski +Signed-off-by: Greg Kroah-Hartman +--- + drivers/net/ethernet/moxa/moxart_ether.c | 20 ++++++++++---------- + 1 file changed, 10 insertions(+), 10 deletions(-) + +--- a/drivers/net/ethernet/moxa/moxart_ether.c ++++ b/drivers/net/ethernet/moxa/moxart_ether.c +@@ -77,7 +77,7 @@ static void moxart_mac_free_memory(struc + int i; + + for (i = 0; i < RX_DESC_NUM; i++) +- dma_unmap_single(&ndev->dev, priv->rx_mapping[i], ++ dma_unmap_single(&priv->pdev->dev, priv->rx_mapping[i], + priv->rx_buf_size, DMA_FROM_DEVICE); + + if (priv->tx_desc_base) +@@ -147,11 +147,11 @@ static void moxart_mac_setup_desc_ring(s + desc + RX_REG_OFFSET_DESC1); + + priv->rx_buf[i] = priv->rx_buf_base + priv->rx_buf_size * i; +- priv->rx_mapping[i] = dma_map_single(&ndev->dev, ++ priv->rx_mapping[i] = dma_map_single(&priv->pdev->dev, + priv->rx_buf[i], + priv->rx_buf_size, + DMA_FROM_DEVICE); +- if (dma_mapping_error(&ndev->dev, priv->rx_mapping[i])) ++ if (dma_mapping_error(&priv->pdev->dev, priv->rx_mapping[i])) + netdev_err(ndev, "DMA mapping error\n"); + + moxart_desc_write(priv->rx_mapping[i], +@@ -240,7 +240,7 @@ static int moxart_rx_poll(struct napi_st + if (len > RX_BUF_SIZE) + len = RX_BUF_SIZE; + +- dma_sync_single_for_cpu(&ndev->dev, ++ dma_sync_single_for_cpu(&priv->pdev->dev, + priv->rx_mapping[rx_head], + priv->rx_buf_size, DMA_FROM_DEVICE); + skb = netdev_alloc_skb_ip_align(ndev, len); +@@ -294,7 +294,7 @@ static void moxart_tx_finished(struct ne + unsigned int tx_tail = priv->tx_tail; + + while (tx_tail != tx_head) { +- dma_unmap_single(&ndev->dev, priv->tx_mapping[tx_tail], ++ dma_unmap_single(&priv->pdev->dev, priv->tx_mapping[tx_tail], + priv->tx_len[tx_tail], DMA_TO_DEVICE); + + ndev->stats.tx_packets++; +@@ -357,9 +357,9 @@ static int moxart_mac_start_xmit(struct + + len = skb->len > TX_BUF_SIZE ? TX_BUF_SIZE : skb->len; + +- priv->tx_mapping[tx_head] = dma_map_single(&ndev->dev, skb->data, ++ priv->tx_mapping[tx_head] = dma_map_single(&priv->pdev->dev, skb->data, + len, DMA_TO_DEVICE); +- if (dma_mapping_error(&ndev->dev, priv->tx_mapping[tx_head])) { ++ if (dma_mapping_error(&priv->pdev->dev, priv->tx_mapping[tx_head])) { + netdev_err(ndev, "DMA mapping error\n"); + goto out_unlock; + } +@@ -378,7 +378,7 @@ static int moxart_mac_start_xmit(struct + len = ETH_ZLEN; + } + +- dma_sync_single_for_device(&ndev->dev, priv->tx_mapping[tx_head], ++ dma_sync_single_for_device(&priv->pdev->dev, priv->tx_mapping[tx_head], + priv->tx_buf_size, DMA_TO_DEVICE); + + txdes1 = TX_DESC1_LTS | TX_DESC1_FTS | (len & TX_DESC1_BUF_SIZE_MASK); +@@ -498,7 +498,7 @@ static int moxart_mac_probe(struct platf + priv->tx_buf_size = TX_BUF_SIZE; + priv->rx_buf_size = RX_BUF_SIZE; + +- priv->tx_desc_base = dma_alloc_coherent(&pdev->dev, TX_REG_DESC_SIZE * ++ priv->tx_desc_base = dma_alloc_coherent(p_dev, TX_REG_DESC_SIZE * + TX_DESC_NUM, &priv->tx_base, + GFP_DMA | GFP_KERNEL); + if (!priv->tx_desc_base) { +@@ -506,7 +506,7 @@ static int moxart_mac_probe(struct platf + goto init_fail; + } + +- priv->rx_desc_base = dma_alloc_coherent(&pdev->dev, RX_REG_DESC_SIZE * ++ priv->rx_desc_base = dma_alloc_coherent(p_dev, RX_REG_DESC_SIZE * + RX_DESC_NUM, &priv->rx_base, + GFP_DMA | GFP_KERNEL); + if (!priv->rx_desc_base) { diff --git a/queue-5.4/netfilter-nf_tables-really-skip-inactive-sets-when-allocating-name.patch b/queue-5.4/netfilter-nf_tables-really-skip-inactive-sets-when-allocating-name.patch new file mode 100644 index 00000000000..05cc9f8f970 --- /dev/null +++ b/queue-5.4/netfilter-nf_tables-really-skip-inactive-sets-when-allocating-name.patch @@ -0,0 +1,30 @@ +From 271c5ca826e0c3c53e0eb4032f8eaedea1ee391c Mon Sep 17 00:00:00 2001 +From: Pablo Neira Ayuso +Date: Tue, 9 Aug 2022 17:23:53 +0200 +Subject: netfilter: nf_tables: really skip inactive sets when allocating name + +From: Pablo Neira Ayuso + +commit 271c5ca826e0c3c53e0eb4032f8eaedea1ee391c upstream. + +While looping to build the bitmap of used anonymous set names, check the +current set in the iteration, instead of the one that is being created. + +Fixes: 37a9cc525525 ("netfilter: nf_tables: add generation mask to sets") +Signed-off-by: Pablo Neira Ayuso +Signed-off-by: Greg Kroah-Hartman +--- + net/netfilter/nf_tables_api.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/net/netfilter/nf_tables_api.c ++++ b/net/netfilter/nf_tables_api.c +@@ -3253,7 +3253,7 @@ cont: + list_for_each_entry(i, &ctx->table->sets, list) { + int tmp; + +- if (!nft_is_active_next(ctx->net, set)) ++ if (!nft_is_active_next(ctx->net, i)) + continue; + if (!sscanf(i->name, name, &tmp)) + continue; diff --git a/queue-5.4/powerpc-pci-fix-get_phb_number-locking.patch b/queue-5.4/powerpc-pci-fix-get_phb_number-locking.patch new file mode 100644 index 00000000000..21c325e9e33 --- /dev/null +++ b/queue-5.4/powerpc-pci-fix-get_phb_number-locking.patch @@ -0,0 +1,105 @@ +From 8d48562a2729742f767b0fdd994d6b2a56a49c63 Mon Sep 17 00:00:00 2001 +From: Michael Ellerman +Date: Mon, 15 Aug 2022 16:55:23 +1000 +Subject: powerpc/pci: Fix get_phb_number() locking + +From: Michael Ellerman + +commit 8d48562a2729742f767b0fdd994d6b2a56a49c63 upstream. + +The recent change to get_phb_number() causes a DEBUG_ATOMIC_SLEEP +warning on some systems: + + BUG: sleeping function called from invalid context at kernel/locking/mutex.c:580 + in_atomic(): 1, irqs_disabled(): 0, non_block: 0, pid: 1, name: swapper + preempt_count: 1, expected: 0 + RCU nest depth: 0, expected: 0 + 1 lock held by swapper/1: + #0: c157efb0 (hose_spinlock){+.+.}-{2:2}, at: pcibios_alloc_controller+0x64/0x220 + Preemption disabled at: + [<00000000>] 0x0 + CPU: 0 PID: 1 Comm: swapper Not tainted 5.19.0-yocto-standard+ #1 + Call Trace: + [d101dc90] [c073b264] dump_stack_lvl+0x50/0x8c (unreliable) + [d101dcb0] [c0093b70] __might_resched+0x258/0x2a8 + [d101dcd0] [c0d3e634] __mutex_lock+0x6c/0x6ec + [d101dd50] [c0a84174] of_alias_get_id+0x50/0xf4 + [d101dd80] [c002ec78] pcibios_alloc_controller+0x1b8/0x220 + [d101ddd0] [c140c9dc] pmac_pci_init+0x198/0x784 + [d101de50] [c140852c] discover_phbs+0x30/0x4c + [d101de60] [c0007fd4] do_one_initcall+0x94/0x344 + [d101ded0] [c1403b40] kernel_init_freeable+0x1a8/0x22c + [d101df10] [c00086e0] kernel_init+0x34/0x160 + [d101df30] [c001b334] ret_from_kernel_thread+0x5c/0x64 + +This is because pcibios_alloc_controller() holds hose_spinlock but +of_alias_get_id() takes of_mutex which can sleep. + +The hose_spinlock protects the phb_bitmap, and also the hose_list, but +it doesn't need to be held while get_phb_number() calls the OF routines, +because those are only looking up information in the device tree. + +So fix it by having get_phb_number() take the hose_spinlock itself, only +where required, and then dropping the lock before returning. +pcibios_alloc_controller() then needs to take the lock again before the +list_add() but that's safe, the order of the list is not important. + +Fixes: 0fe1e96fef0a ("powerpc/pci: Prefer PCI domain assignment via DT 'linux,pci-domain' and alias") +Reported-by: Guenter Roeck +Signed-off-by: Michael Ellerman +Link: https://lore.kernel.org/r/20220815065550.1303620-1-mpe@ellerman.id.au +Signed-off-by: Greg Kroah-Hartman +--- + arch/powerpc/kernel/pci-common.c | 16 ++++++++++------ + 1 file changed, 10 insertions(+), 6 deletions(-) + +--- a/arch/powerpc/kernel/pci-common.c ++++ b/arch/powerpc/kernel/pci-common.c +@@ -66,10 +66,6 @@ void set_pci_dma_ops(const struct dma_ma + pci_dma_ops = dma_ops; + } + +-/* +- * This function should run under locking protection, specifically +- * hose_spinlock. +- */ + static int get_phb_number(struct device_node *dn) + { + int ret, phb_id = -1; +@@ -106,15 +102,20 @@ static int get_phb_number(struct device_ + if (!ret) + phb_id = (int)(prop & (MAX_PHBS - 1)); + ++ spin_lock(&hose_spinlock); ++ + /* We need to be sure to not use the same PHB number twice. */ + if ((phb_id >= 0) && !test_and_set_bit(phb_id, phb_bitmap)) +- return phb_id; ++ goto out_unlock; + + /* If everything fails then fallback to dynamic PHB numbering. */ + phb_id = find_first_zero_bit(phb_bitmap, MAX_PHBS); + BUG_ON(phb_id >= MAX_PHBS); + set_bit(phb_id, phb_bitmap); + ++out_unlock: ++ spin_unlock(&hose_spinlock); ++ + return phb_id; + } + +@@ -125,10 +126,13 @@ struct pci_controller *pcibios_alloc_con + phb = zalloc_maybe_bootmem(sizeof(struct pci_controller), GFP_KERNEL); + if (phb == NULL) + return NULL; +- spin_lock(&hose_spinlock); ++ + phb->global_number = get_phb_number(dev); ++ ++ spin_lock(&hose_spinlock); + list_add_tail(&phb->list_node, &hose_list); + spin_unlock(&hose_spinlock); ++ + phb->dn = dev; + phb->is_dynamic = slab_is_available(); + #ifdef CONFIG_PPC64 diff --git a/queue-5.4/series b/queue-5.4/series index 61b3604fc4c..41883a7348b 100644 --- a/queue-5.4/series +++ b/queue-5.4/series @@ -334,3 +334,13 @@ nios2-restarts-apply-only-to-the-first-sigframe-we-build.patch nios2-add-force_successful_syscall_return.patch iavf-fix-adminq-error-handling.patch clk-rockchip-add-sclk_mac_lbtest-to-rk3188_critical_clocks.patch +netfilter-nf_tables-really-skip-inactive-sets-when-allocating-name.patch +powerpc-pci-fix-get_phb_number-locking.patch +net-dsa-mv88e6060-prevent-crash-on-an-unused-port.patch +net-moxa-pass-pdev-instead-of-ndev-to-dma-functions.patch +net-dsa-microchip-ksz9477-fix-fdb_dump-last-invalid-entry.patch +ice-ignore-eexist-when-setting-promisc-mode.patch +i40e-fix-to-stop-tx_timeout-recovery-if-globr-fails.patch +fec-fix-timer-capture-timing-in-fec_ptp_enable_pps.patch +igb-add-lock-to-avoid-data-race.patch +gcc-plugins-undefine-latent_entropy_plugin-when-plugin-disabled-for-a-file.patch