Intel Wired LAN Driver Updates 2018-12-20
Subsystems (4)
This series contains updates to e100, igb, ixgbe, i40e and ice drivers.
I replaced spinlocks for mutex locks to reduce the latency on CPU0 for igb when updating the statistics. This work was based off a patch provided by Jan Jablonsky, which was against an older version of the igb driver.
Jesus adjusts the receive packet buffer size from 32K to 30K when running in QAV mode, to stay within 60K for total packet buffer size for igb.
Vinicius adds igb kernel documentation regarding the CBS algorithm and its implementation in the i210 family of NICs.
YueHaibing from Huawei fixed the e100 driver that was potentially passing a NULL pointer, so use the kernel macro IS_ERR_OR_NULL() instead.
Konstantin Khorenko fixes i40e where we were not setting up the neigh_priv_len in our net_device, which caused the driver to read beyond the neighbor entry allocated memory.
Miroslav Lichvar extends the PTP gettime() to read the system clock by adding support for PTP_SYS_OFFSET_EXTENDED ioctl in i40e.
Young Xiao fixed the ice driver to only enable NAPI on q_vectors that actually have transmit and receive rings.
Kai-Heng Feng fixes an igb issue that when placed in suspend mode, the NIC does not wake up when a cable is plugged in. This was due to the driver not setting PME during runtime suspend.
Stephen Douthit enables the ixgbe driver allow DSA devices to use the MII interface to talk to switches.
The following are changes since commit 44a7b3b6e3a458f9549c2cc28e74ecdc470e42f1:
Merge branch 'bnxt_en-next'
and are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/jkirsher/next-queue 1GbE
Jeff Kirsher (1):
igb: reduce CPU0 latency when updating statistics
Jesus Sanchez-Palencia (1):
igb: Change RXPBSIZE size when setting Qav mode
Kai-Heng Feng (1):
igb: Fix an issue that PME is not enabled during runtime suspend
Konstantin Khorenko (1):
i40e: define proper net_device::neigh_priv_len
Miroslav Lichvar (1):
i40e: extend PTP gettime function to read system clock
Steve Douthit (2):
ixgbe: register a mdiobus
ixgbe: use mii_bus to handle MII related ioctls
Vinicius Costa Gomes (1):
Documentation: igb: Add a section about CBS
Young Xiao (1):
ice: Do not enable NAPI on q_vectors that have no rings
YueHaibing (1):
e100: Fix passing zero to 'PTR_ERR' warning in e100_load_ucode_wait
.../networking/device_drivers/intel/igb.rst | 19 ++ drivers/net/ethernet/intel/Kconfig | 1 + drivers/net/ethernet/intel/e100.c | 4 +- drivers/net/ethernet/intel/i40e/i40e_main.c | 3 + drivers/net/ethernet/intel/i40e/i40e_ptp.c | 18 +- drivers/net/ethernet/intel/ice/ice_main.c | 16 +- .../net/ethernet/intel/igb/e1000_defines.h | 1 + drivers/net/ethernet/intel/igb/igb.h | 2 +- drivers/net/ethernet/intel/igb/igb_ethtool.c | 4 +- drivers/net/ethernet/intel/igb/igb_main.c | 24 +- drivers/net/ethernet/intel/ixgbe/ixgbe.h | 2 + drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 23 ++ drivers/net/ethernet/intel/ixgbe/ixgbe_phy.c | 299 ++++++++++++++++++ drivers/net/ethernet/intel/ixgbe/ixgbe_phy.h | 2 + 14 files changed, 392 insertions(+), 26 deletions(-)
Signature · 1 line
2.19.2
PATCH 1/10 igb: reduce CPU0 latency when updating statistics
This change is based off of the work and suggestion of Jan Jablonsky <[email protected]>.
The Watchdog workqueue in igb driver is scheduled every 2s for each network interface. That includes updating a statistics protected by spinlock. Function igb_update_stats in this case will be protected against preemption. According to number of a statistics registers (cca 60), processing this function might cause additional cpu load
on CPU0.
In case of statistics spinlock may be replaced with mutex, which reduce latency on CPU0.
--- drivers/net/ethernet/intel/igb/igb.h | 2 +- drivers/net/ethernet/intel/igb/igb_ethtool.c | 4 ++-- drivers/net/ethernet/intel/igb/igb_main.c | 14 +++++++------- 3 files changed, 10 insertions(+), 10 deletions(-)
drivers/net/ethernet/intel/igb/igb.h +1 -1
@@ -515,7 +515,7 @@ struct igb_adapter {/* OS defined structs */ struct pci_dev *pdev; -spinlock_t stats64_lock; +struct mutex stats64_lock;struct rtnl_link_stats64 stats64;/* structs defined in e1000_hw.h */
drivers/net/ethernet/intel/igb/igb_ethtool.c +2 -2
@@ -2295,7 +2295,7 @@ static void igb_get_ethtool_stats(struct net_device *netdev,int i, j;char *p; -spin_lock (&adapter->stats64_lock); +mutex_lock (&adapter->stats64_lock);igb_update_stats (adapter);for (i =0 ; i <IGB_GLOBAL_STATS_LEN ; i++) {
@@ -2338,7 +2338,7 @@ static void igb_get_ethtool_stats(struct net_device *netdev, }while (u64_stats_fetch_retry_irq (&ring->rx_syncp, start)); i +=IGB_RX_QUEUE_STATS_LEN ; } -spin_unlock (&adapter->stats64_lock); +mutex_unlock (&adapter->stats64_lock); }static void igb_get_strings (struct net_device *netdev,u32 stringset,u8 *data)
drivers/net/ethernet/intel/igb/igb_main.c +7 -7
@@ -2203,9 +2203,9 @@ void igb_down(struct igb_adapter *adapter)del_timer_sync (&adapter->phy_info_timer);/* record the stats before reset*/ -spin_lock (&adapter->stats64_lock); +mutex_lock (&adapter->stats64_lock);igb_update_stats (adapter); -spin_unlock (&adapter->stats64_lock); +mutex_unlock (&adapter->stats64_lock); adapter->link_speed =0 ; adapter->link_duplex =0 ;
@@ -3840,7 +3840,7 @@ static int igb_sw_init(struct igb_adapter *adapter) adapter->min_frame_size =ETH_ZLEN +ETH_FCS_LEN ;spin_lock_init (&adapter->nfc_lock); -spin_lock_init (&adapter->stats64_lock); +mutex_init (&adapter->stats64_lock);#ifdef CONFIG_PCI_IOV switch (hw->mac.type) {case e1000_82576:
@@ -5406,9 +5406,9 @@ static void igb_watchdog_task(struct work_struct *work) } } -spin_lock (&adapter->stats64_lock); +mutex_lock (&adapter->stats64_lock);igb_update_stats (adapter); -spin_unlock (&adapter->stats64_lock); +mutex_unlock (&adapter->stats64_lock);for (i =0 ; i < adapter->num_tx_queues; i++) {struct igb_ring *tx_ring = adapter->tx_ring[i];
@@ -6235,10 +6235,10 @@ static void igb_get_stats64(struct net_device *netdev, {struct igb_adapter *adapter =netdev_priv (netdev); -spin_lock (&adapter->stats64_lock); +mutex_lock (&adapter->stats64_lock);igb_update_stats (adapter);memcpy (stats, &adapter->stats64,sizeof (*stats)); -spin_unlock (&adapter->stats64_lock); +mutex_unlock (&adapter->stats64_lock); }/**
Signature · 1 line
2.19.2
PATCH 2/10 igb: Change RXPBSIZE size when setting Qav mode
In reply to Jeff KirsherFrom: Jesus Sanchez-Palencia <[email protected]>
Section 4.5.9 of the datasheet says that the total size of all packet buffers combined (TxPB 0 + 1 + 2 + 3 + RxPB + BMC2OS + OS2BMC) must not exceed 60KB. Today we are configuring a total of 62KB, so reduce the RxPB from 32KB to 30KB in order to respect that.
The choice of changing RxPBSIZE here is mainly because it seems more correct to give more priority to the transmit packet buffers over the receiver ones when running in Qav mode. Also, the BMC2OS and OS2BMC sizes are already too short.
--- drivers/net/ethernet/intel/igb/e1000_defines.h | 1 + drivers/net/ethernet/intel/igb/igb_main.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-)
drivers/net/ethernet/intel/igb/e1000_defines.h +1 -0
@@ -334,6 +334,7 @@#define I210_RXPBSIZE_DEFAULT 0x000000A2/* RXPBSIZE default */ #define I210_RXPBSIZE_MASK 0x0000003F +#define I210_RXPBSIZE_PB_30KB 0x0000001E#define I210_RXPBSIZE_PB_32KB 0x00000020#define I210_TXPBSIZE_DEFAULT 0x04000014/* TXPBSIZE default */ #define I210_TXPBSIZE_MASK 0xC0FFFFFF
drivers/net/ethernet/intel/igb/igb_main.c +1 -1
@@ -1934,7 +1934,7 @@ static void igb_setup_tx_mode(struct igb_adapter *adapter) val =rd32 (E1000_RXPBS ); val &= ~I210_RXPBSIZE_MASK ; - val |=I210_RXPBSIZE_PB_32KB ; + val |=I210_RXPBSIZE_PB_30KB ;wr32 (E1000_RXPBS , val);/* Section 8.12.9 states that MAX_TPKT_SIZE from DTXMXPKTSZ
Signature · 1 line
2.19.2
PATCH 3/10 Documentation: igb: Add a section about CBS
In reply to Jeff KirsherFrom: Vinicius Costa Gomes <[email protected]>
Add some pointers to the definition of the CBS algorithm, and some notes about the limits of its implementation in the i210 family of controllers.
--- .../networking/device_drivers/intel/igb.rst | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
Documentation/networking/device_drivers/intel/igb.rst +19 -0
@@ -177,6 +177,25 @@ rate limit using the IProute2 tool. Download the latest version of the IProute2 tool from Sourceforge if your version does not have all the features you require. +Credit Based Shaper (Qav Mode) +------------------------------ +When enabling the CBS qdisc in the hardware offload mode, traffic shaping using +the CBS (described in the IEEE 802.1Q-2018 Section 8.6.8.2 and discussed in the +Annex L) algorithm will run in the i210 controller, so it's more accurate and +uses less CPU. + +When using offloaded CBS, and the traffic rate obeys the configured rate +(doesn't go above it), CBS should have little to no effect in the latency. + +The offloaded version of the algorithm has some limits, caused by how the idle +slope is expressed in the adapter's registers. It can only represent idle slopes +in 16.38431 kbps units, which means that if a idle slope of 2576kbps is +requested, the controller will be configured to use a idle slope of ~2589 kbps, +because the driver rounds the value up. For more details, see the comments on +:c:func:`igb_config_tx_modes()`. + +NOTE: This feature is exclusive to i210 models. + Support =======
Signature · 1 line
2.19.2
PATCH 4/10 e100: Fix passing zero to 'PTR_ERR' warning in e100_load_ucode_wait
In reply to Jeff KirsherFrom: YueHaibing <[email protected]>
Fix a static code checker warning:drivers/net/ethernet/intel/e100.c:1349
e100_load_ucode_wait() warn: passing zero to 'PTR_ERR'
--- drivers/net/ethernet/intel/e100.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/intel/e100.c +2 -2
@@ -1345,8 +1345,8 @@ static inline int e100_load_ucode_wait(struct nic *nic) fw =e100_request_firmware (nic);/* If it's NULL, then no ucode is required */ -if (!fw ||IS_ERR (fw)) -return PTR_ERR (fw); +if (IS_ERR_OR_NULL (fw)) +return PTR_ERR_OR_ZERO (fw);if ((err =e100_exec_cb (nic, (void *)fw, e100_setup_ucode))) netif_err(nic, probe, nic->netdev,
Signature · 1 line
2.19.2
PATCH 5/10 i40e: define proper net_device::neigh_priv_len
In reply to Jeff KirsherFrom: Konstantin Khorenko <[email protected]>
Out of bound read reported by KASan.
i40iw_net_event() reads unconditionally 16 bytes from neigh->primary_key while the memory allocated for "neighbour" struct is evaluated in neigh_alloc() as
tbl->entry_size + dev->neigh_priv_len
where "dev" is a net_device.
But the driver does not setup dev->neigh_priv_len and we read beyond the neigh entry allocated memory, so the patch in the next mail fixes this.
--- drivers/net/ethernet/intel/i40e/i40e_main.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/ethernet/intel/i40e/i40e_main.c +3 -0
@@ -12339,6 +12339,9 @@ static int i40e_config_netdev(struct i40e_vsi *vsi)ether_addr_copy (netdev->dev_addr, mac_addr);ether_addr_copy (netdev->perm_addr, mac_addr); +/* i40iw_net_event() reads 16 bytes from neigh->primary_key */ + netdev->neigh_priv_len =sizeof (u32) *4 ; + netdev->priv_flags |=IFF_UNICAST_FLT ; netdev->priv_flags |=IFF_SUPP_NOFCS ;/* Setup netdev TC information */
Signature · 1 line
2.19.2
PATCH 7/10 ice: Do not enable NAPI on q_vectors that have no rings
In reply to Jeff KirsherFrom: Young Xiao <[email protected]>
If ice driver has q_vectors w/ active NAPI that has no rings, then this will result in a divide by zero error. To correct it I am updating the driver code so that we only support NAPI on q_vectors that have 1 or more rings allocated to them.
See commit 13a8cd191a2b ("i40e: Do not enable NAPI on q_vectors that have no rings") for detail.
--- drivers/net/ethernet/intel/ice/ice_main.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-)
drivers/net/ethernet/intel/ice/ice_main.c +12 -4
@@ -2564,8 +2564,12 @@ static void ice_napi_enable_all(struct ice_vsi *vsi)if (!vsi->netdev)return ; -for (q_idx =0 ; q_idx < vsi->num_q_vectors; q_idx++) -napi_enable (&vsi->q_vectors[q_idx]->napi); +for (q_idx =0 ; q_idx < vsi->num_q_vectors; q_idx++) { +struct ice_q_vector *q_vector = vsi->q_vectors[q_idx]; + +if (q_vector->rx.ring || q_vector->tx.ring) +napi_enable (&q_vector->napi); + } }/**
@@ -2932,8 +2936,12 @@ static void ice_napi_disable_all(struct ice_vsi *vsi)if (!vsi->netdev)return ; -for (q_idx =0 ; q_idx < vsi->num_q_vectors; q_idx++) -napi_disable (&vsi->q_vectors[q_idx]->napi); +for (q_idx =0 ; q_idx < vsi->num_q_vectors; q_idx++) { +struct ice_q_vector *q_vector = vsi->q_vectors[q_idx]; + +if (q_vector->rx.ring || q_vector->tx.ring) +napi_disable (&q_vector->napi); + } }/**
Signature · 1 line
2.19.2
PATCH 6/10 i40e: extend PTP gettime function to read system clock
In reply to Jeff KirsherFrom: Miroslav Lichvar <[email protected]>
This adds support for the PTP_SYS_OFFSET_EXTENDED ioctl.
--- drivers/net/ethernet/intel/i40e/i40e_ptp.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-)
drivers/net/ethernet/intel/i40e/i40e_ptp.c +12 -6
@@ -28,19 +28,23 @@* i40e_ptp_read - Read the PHC time from the device * @pf: Board private structure * @ts: timespec structure to hold the current time value +* @sts: structure to hold the system time before and after reading the PHC * * This function reads the PRTTSYN_TIME registers and stores them in a * timespec. However, since the registers are 64 bits of nanoseconds, we must * convert the result to a timespec before we can return. **/ -static void i40e_ptp_read (struct i40e_pf *pf,struct timespec64 *ts) +static void i40e_ptp_read (struct i40e_pf *pf,struct timespec64 *ts, +struct ptp_system_timestamp *sts) {struct i40e_hw *hw = &pf->hw;u32 hi, lo;u64 ns;/* The timer latches on the lowest register read. */ +ptp_read_system_prets (sts); lo =rd32 (hw,I40E_PRTTSYN_TIME_L ); +ptp_read_system_postts (sts); hi =rd32 (hw,I40E_PRTTSYN_TIME_H ); ns = (((u64 )hi) <<32 ) | lo;
@@ -146,7 +150,7 @@ static int i40e_ptp_adjtime(struct ptp_clock_info *ptp, s64 delta)mutex_lock (&pf->tmreg_lock); -i40e_ptp_read (pf, &now); +i40e_ptp_read (pf, &now,NULL );timespec64_add_ns (&now, delta);i40e_ptp_write (pf, (const struct timespec64 *)&now);
@@ -156,19 +160,21 @@ static int i40e_ptp_adjtime(struct ptp_clock_info *ptp, s64 delta) }/** -* i40e_ptp_gettime - Get the time of the PHC +* i40e_ptp_gettimex - Get the time of the PHC * @ptp: The PTP clock structure * @ts: timespec structure to hold the current time value +* @sts: structure to hold the system time before and after reading the PHC * * Read the device clock and return the correct value on ns, after converting it * into a timespec struct. **/ -static int i40e_ptp_gettime (struct ptp_clock_info *ptp,struct timespec64 *ts) +static int i40e_ptp_gettimex (struct ptp_clock_info *ptp,struct timespec64 *ts, +struct ptp_system_timestamp *sts) { struct i40e_pf *pf = container_of(ptp, struct i40e_pf, ptp_caps);mutex_lock (&pf->tmreg_lock); -i40e_ptp_read (pf, ts); +i40e_ptp_read (pf, ts, sts);mutex_unlock (&pf->tmreg_lock);return 0 ;
@@ -702,7 +708,7 @@ static long i40e_ptp_create_clock(struct i40e_pf *pf) pf->ptp_caps.pps =0 ; pf->ptp_caps.adjfreq = i40e_ptp_adjfreq; pf->ptp_caps.adjtime = i40e_ptp_adjtime; - pf->ptp_caps.gettime64 = i40e_ptp_gettime; + pf->ptp_caps.gettimex64 = i40e_ptp_gettimex; pf->ptp_caps.settime64 = i40e_ptp_settime; pf->ptp_caps.enable = i40e_ptp_feature_enable;
Signature · 1 line
2.19.2
PATCH 8/10 igb: Fix an issue that PME is not enabled during runtime suspend
In reply to Jeff KirsherFrom: Kai-Heng Feng <[email protected]>
I210 ethernet card doesn't wakeup when a cable gets plugged. It's because its PME is not set.
Since commit 42eca2302146 ("PCI: Don't touch card regs after runtime suspend D3"), if the PCI state is saved, pci_pm_runtime_suspend() stops calling pci_finish_runtime_suspend(), which enables the PCI PME.
To fix the issue, let's not to save PCI states when it's runtime suspend, to let the PCI subsystem enables PME.
--- drivers/net/ethernet/intel/igb/igb_main.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/net/ethernet/intel/igb/igb_main.c +5 -3
@@ -8771,9 +8771,11 @@ static int __igb_shutdown(struct pci_dev *pdev, bool *enable_wake,rtnl_unlock ();#ifdef CONFIG_PM - retval =pci_save_state (pdev); -if (retval) -return retval; +if (!runtime) { + retval =pci_save_state (pdev); +if (retval) +return retval; + }#endif status =rd32 (E1000_STATUS );
Signature · 1 line
2.19.2
PATCH 9/10 ixgbe: register a mdiobus
In reply to Jeff KirsherFrom: Steve Douthit <[email protected]>
Most dsa devices expect a 'struct mii_bus' pointer to talk to switches via the MII interface.
While this works for dsa devices, it will not work safely with Linux PHYs in all configurations since the firmware of the ixgbe device may be polling some PHY addresses in the background.
--- drivers/net/ethernet/intel/Kconfig | 1 + drivers/net/ethernet/intel/ixgbe/ixgbe.h | 2 + drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 5 + drivers/net/ethernet/intel/ixgbe/ixgbe_phy.c | 299 ++++++++++++++++++ drivers/net/ethernet/intel/ixgbe/ixgbe_phy.h | 2 + 5 files changed, 309 insertions(+)
drivers/net/ethernet/intel/Kconfig +1 -0
@@ -159,6 +159,7 @@ config IXGBE tristate "Intel(R) 10GbE PCI Express adapters support" depends on PCI select MDIO + select MDIO_DEVICE imply PTP_1588_CLOCK ---help--- This driver supports Intel(R) 10GbE PCI Express family of
drivers/net/ethernet/intel/ixgbe/ixgbe.h +2 -0
@@ -12,6 +12,7 @@#include <linux/aer.h> #include <linux/if_vlan.h> #include <linux/jiffies.h> +#include <linux/phy.h> #include <linux/timecounter.h> #include <linux/net_tstamp.h>
@@ -561,6 +562,7 @@ struct ixgbe_adapter {struct net_device *netdev;struct bpf_prog *xdp_prog;struct pci_dev *pdev; +struct mii_bus *mii_bus;unsigned long state;
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +5 -0
@@ -39,6 +39,7 @@#include "ixgbe.h" #include "ixgbe_common.h" #include "ixgbe_dcb_82599.h" +#include "ixgbe_phy.h" #include "ixgbe_sriov.h" #include "ixgbe_model.h" #include "ixgbe_txrx_common.h"
@@ -11122,6 +11123,8 @@ static int ixgbe_probe(struct pci_dev *pdev, const struct pci_device_id *ent)IXGBE_LINK_SPEED_10GB_FULL |IXGBE_LINK_SPEED_1GB_FULL , true); +ixgbe_mii_bus_init (hw); +return 0 ; err_register:
@@ -11172,6 +11175,8 @@ static void ixgbe_remove(struct pci_dev *pdev)set_bit (__IXGBE_REMOVING, &adapter->state);cancel_work_sync (&adapter->service_task); +if (adapter->mii_bus) +mdiobus_unregister (adapter->mii_bus);#ifdef CONFIG_IXGBE_DCA if (adapter->flags &IXGBE_FLAG_DCA_ENABLED ) {
drivers/net/ethernet/intel/ixgbe/ixgbe_phy.c +299 -0
311 lines not on this page · raw message
drivers/net/ethernet/intel/ixgbe/ixgbe_phy.h +2 -0
@@ -120,6 +120,8 @@/* SFP+ SFF-8472 Compliance code */ #define IXGBE_SFF_SFF_8472_UNSUP 0x00 +s32 ixgbe_mii_bus_init (struct ixgbe_hw *hw); +s32 ixgbe_identify_phy_generic (struct ixgbe_hw *hw);s32 ixgbe_reset_phy_generic (struct ixgbe_hw *hw); s32 ixgbe_read_phy_reg_generic(struct ixgbe_hw *hw, u32 reg_addr,
Signature · 1 line
2.19.2
PATCH 10/10 ixgbe: use mii_bus to handle MII related ioctls
In reply to Jeff KirsherFrom: Steve Douthit <[email protected]>
Use the mii_bus callbacks to address the entire clause 22/45 address space. Enables userspace to poke switch registers instead of a single PHY address.
The ixgbe firmware may be polling PHYs in a way that is not protected by the mii_bus lock. This isn't new behavior, but as Andrew Lunn pointed out there are more addresses available for conflicts.
--- drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +18 -0
@@ -8791,6 +8791,15 @@ ixgbe_mdio_read(struct net_device *netdev, int prtad, int devad, u16 addr)u16 value;int rc; +if (adapter->mii_bus) { +int regnum = addr; + +if (devad !=MDIO_DEVAD_NONE ) + regnum |= (devad <<16 ) |MII_ADDR_C45 ; + +return mdiobus_read (adapter->mii_bus, prtad, regnum); + } +if (prtad != hw->phy.mdio.prtad)return -EINVAL ; rc = hw->phy.ops.read_reg (hw, addr, devad, &value);
@@ -8805,6 +8814,15 @@ static int ixgbe_mdio_write(struct net_device *netdev, int prtad, int devad,struct ixgbe_adapter *adapter =netdev_priv (netdev);struct ixgbe_hw *hw = &adapter->hw; +if (adapter->mii_bus) { +int regnum = addr; + +if (devad !=MDIO_DEVAD_NONE ) + regnum |= (devad <<16 ) |MII_ADDR_C45 ; + +return mdiobus_write (adapter->mii_bus, prtad, regnum, value); + } +if (prtad != hw->phy.mdio.prtad)return -EINVAL ;return hw->phy.ops.write_reg (hw, addr, devad, value);
Signature · 1 line
2.19.2
David Miller
maintainerFrom: Jeff Kirsher <[email protected]>
Date: Thu, 20 Dec 2018 12:56:24 -0800
Quoted 1 line
This series contains updates to e100, igb, ixgbe, i40e and ice drivers.
Pulled, thanks Jeff.
Re: [net-next 01/10] igb: reduce CPU0 latency when updating statistics
In reply to Jeff KirsherQuoted 10 lines · Jeff Kirsher
This change is based off of the work and suggestion of Jan Jablonsky <[email protected]>.
The Watchdog workqueue in igb driver is scheduled every 2s for each network interface. That includes updating a statistics protected by spinlock. Function
igb_update_statsin this case will be protected against preemption. According to number of a statistics registers (cca 60), processing this function might cause additional cpu load
on CPU0.
Quoted 8 lines
In case of statistics spinlock may be replaced with mutex, which reduce latency on CPU0.
CC Bernhard Kaindl <[email protected]>CC Jan Jablonsky <[email protected]>Signed-off-by Jeff Kirsher <[email protected]>Tested-by Aaron Brown <[email protected]>Signed-off-by Jeff Kirsher <[email protected]>
Hi,
I'm hitting following issue with this commit:
https://lists.01.org/pipermail/lkp/2018-September/009139.html
Re: [net-next 01/10] igb: reduce CPU0 latency when updating statistics
Quoted 20 lines · Ido Schimmel
Quoted 10 lines · Jeff Kirsher
This change is based off of the work and suggestion of Jan Jablonsky <[email protected]>.
The Watchdog workqueue in igb driver is scheduled every 2s for each network interface. That includes updating a statistics protected by spinlock. Function
igb_update_statsin this case will be protected against preemption. According to number of a statistics registers (cca 60), processing this function might cause additional cpu load
on CPU0.Quoted 8 lines
In case of statistics spinlock may be replaced with mutex, which reduce latency on CPU0.
CC Bernhard Kaindl <[email protected]>CC Jan Jablonsky <[email protected]>Signed-off-by Jeff Kirsher <[email protected]>Tested-by Aaron Brown <[email protected]>Signed-off-by Jeff Kirsher <[email protected]>
Quoted 4 lines
Hi,
I'm hitting following issue with this commit:
https://lists.01.org/pipermail/lkp/2018-September/009139.html
Hitting what looks like the same thing with linus tip from today and fedora rawhide config. There is some rcu splat that might help.. (ignore the drm,it87 bits)
.....
[ 17.150603] WARNING: suspicious RCU usage
[ 17.150605] 5.0.0-rc1+ #3 Not tainted
[ 17.150606] -----------------------------
[ 17.150607] include/linux/rcupdate.h:281 Illegal context switch in RCU read-side critical section!
[ 17.150608]
other info that might help us debug this:[ 17.150609]
rcu_scheduler_active = 2, debug_locks = 1
[ 17.150610] 2 locks held by sadc/819:
[ 17.150610] #0: 000000006764297e (&p->lock){+.+.}, at: seq_read+0x41/0x430
[ 17.150616] #1: 00000000488cf3bc (rcu_read_lock){....}, at: dev_seq_start+0x5/0x120
[ 17.150621]
stack backtrace:
[ 17.150623] CPU: 3 PID: 819 Comm: sadc Not tainted 5.0.0-rc1+ #3
[ 17.150624] Hardware name: Gigabyte Technology Co., Ltd. X470 AORUS ULTRA GAMING/X470 AORUS ULTRA GAMING-CF, BIOS F4 12/24/2018
[ 17.150624] Call Trace:
[ 17.150628] dump_stack+0x85/0xc0
[ 17.150632] ___might_sleep+0x100/0x180
[ 17.150635] __mutex_lock+0x55/0x9a0
[ 17.241240] [drm] VCE initialized successfully.
[ 17.244179] ? seq_vprintf+0x30/0x50
[ 17.244181] ? seq_printf+0x53/0x70
[ 17.244185] ? __lock_acquire+0x279/0x1650
[ 17.244193] ? igb_get_stats64+0x29/0x80 [igb]
[ 17.287914] igb_get_stats64+0x29/0x80 [igb]
[ 17.287920] dev_get_stats+0x5b/0xc0
[ 17.298714] dev_seq_printf_stats+0x32/0xe0
[ 17.298721] dev_seq_show+0x10/0x30
[ 17.307934] seq_read+0x2fd/0x430
[ 17.307940] proc_reg_read+0x39/0x60
[ 17.317677] __vfs_read+0x36/0x1a0
[ 17.317683] vfs_read+0x9f/0x160
[ 17.317686] ksys_read+0x52/0xc0
[ 17.330601] do_syscall_64+0x60/0x1f0
[ 17.330604] entry_SYSCALL_64_after_hwframe+0x49/0xbe
[ 17.330606] RIP: 0033:0x7fcce3c5e1b5
[ 17.330608] Code: fe ff ff 50 48 8d 3d 9a d3 09 00 e8 75 00 02 00 0f 1f 44 00 00 f3 0f 1e fa 48 8d 05 65 55 0d 00 8b 00 85 c0 75 0f 31 c0 0f 05 <48> 3d 00 f0 ff ff 77 53 c3 66 90 41 54 49 89 d4 55 48 89 f5 53 89
[ 17.330609] RSP: 002b:00007ffdd6d957e8 EFLAGS: 00000246 ORIG_RAX: 0000000000000000
[ 17.375503] RAX: ffffffffffffffda RBX: 00000000012dd2a0 RCX: 00007fcce3c5e1b5
[ 17.375504] RDX: 0000000000000400 RSI: 00000000012d89e0 RDI: 0000000000000003
[ 17.375505] RBP: 0000000000000d68 R08: 0000000000000001 R09: 0000000000000000
[ 17.375506] R10: 00007fcce3a29740 R11: 0000000000000246 R12: 00007fcce3d2a740
[ 17.375507] R13: 00007fcce3d2b340 R14: 000000000000007f R15: 00000000012dd2a0
[ 17.375577] BUG: sleeping function called from invalid context at kernel/locking/mutex.c:908
[ 17.428833] in_atomic(): 1, irqs_disabled(): 0, pid: 819, name: sadc
[ 17.428834] 2 locks held by sadc/819:
[ 17.428835] #0: 000000006764297e (&p->lock){+.+.}, at: seq_read+0x41/0x430
[ 17.428841] #1: 00000000488cf3bc (rcu_read_lock){....}, at: dev_seq_start+0x5/0x120
[ 17.428847] CPU: 3 PID: 819 Comm: sadc Not tainted 5.0.0-rc1+ #3
[ 17.428848] Hardware name: Gigabyte Technology Co., Ltd. X470 AORUS ULTRA GAMING/X470 AORUS ULTRA GAMING-CF, BIOS F4 12/24/2018
[ 17.428849] Call Trace:
[ 17.428853] dump_stack+0x85/0xc0
[ 17.428857] ___might_sleep.cold.73+0xac/0xbc
[ 17.429616] it87: Found IT8733E chip at 0xa60, revision 3
[ 17.429704] it87: Beeping is supported
[ 17.506837] __mutex_lock+0x55/0x9a0
[ 17.506842] ? seq_vprintf+0x30/0x50
[ 17.516925] ? seq_printf+0x53/0x70
[ 17.516929] ? __lock_acquire+0x279/0x1650
[ 17.516937] ? igb_get_stats64+0x29/0x80 [igb]
[ 17.533393] igb_get_stats64+0x29/0x80 [igb]
[ 17.533397] dev_get_stats+0x5b/0xc0
[ 17.533401] dev_seq_printf_stats+0x32/0xe0
[ 17.549848] dev_seq_show+0x10/0x30
[ 17.549850] seq_read+0x2fd/0x430
[ 17.559502] proc_reg_read+0x39/0x60
[ 17.559505] __vfs_read+0x36/0x1a0
[ 17.559510] vfs_read+0x9f/0x160
[ 17.559513] ksys_read+0x52/0xc0
[ 17.559517] do_syscall_64+0x60/0x1f0
[ 17.559519] entry_SYSCALL_64_after_hwframe+0x49/0xbe
[ 17.559521] RIP: 0033:0x7fcce3c5e1b5
[ 17.559523] Code: fe ff ff 50 48 8d 3d 9a d3 09 00 e8 75 00 02 00 0f 1f 44 00 00 f3 0f 1e fa 48 8d 05 65 55 0d 00 8b 00 85 c0 75 0f 31 c0 0f 05 <48> 3d 00 f0 ff ff 77 53 c3 66 90 41 54 49 89 d4 55 48 89 f5 53 89
[ 17.559524] RSP: 002b:00007ffdd6d957e8 EFLAGS: 00000246 ORIG_RAX: 0000000000000000
[ 17.559526] RAX: ffffffffffffffda RBX: 00000000012dd2a0 RCX: 00007fcce3c5e1b5
[ 17.559527] RDX: 0000000000000400 RSI: 00000000012d89e0 RDI: 0000000000000003
[ 17.559528] RBP: 0000000000000d68 R08: 0000000000000001 R09: 0000000000000000
[ 17.559528] R10: 00007fcce3a29740 R11: 0000000000000246 R12: 00007fcce3d2a740
[ 17.559529] R13: 00007fcce3d2b340 R14: 000000000000007f R15: 00000000012dd2a0.....
Re: [net-next 01/10] igb: reduce CPU0 latency when updating statistics
In reply to Ido SchimmelQuoted 20 lines · Ido Schimmel
Quoted 10 lines · Jeff Kirsher
This change is based off of the work and suggestion of Jan Jablonsky <[email protected]>.
The Watchdog workqueue in igb driver is scheduled every 2s for each network interface. That includes updating a statistics protected by spinlock. Function
igb_update_statsin this case will be protected against preemption. According to number of a statistics registers (cca 60), processing this function might cause additional cpu load
on CPU0.Quoted 8 lines
In case of statistics spinlock may be replaced with mutex, which reduce latency on CPU0.
CC Bernhard Kaindl <[email protected]>CC Jan Jablonsky <[email protected]>Signed-off-by Jeff Kirsher <[email protected]>Tested-by Aaron Brown <[email protected]>Signed-off-by Jeff Kirsher <[email protected]>
Quoted 4 lines
Hi,
I'm hitting following issue with this commit:
https://lists.01.org/pipermail/lkp/2018-September/009139.html
Sorry for late answer,
Thanks for input
I didnt have much time to take a look.
Right, using mutex_lock is not the best solution for igb_get_stats64 with not activated CONFIG_DEBUG_ATOMIC_SLEEP
Anyway spinlocks dont solve latency problem (mostly when you use CONFIG_PREEMPT)
I was just consider solution to avoid "blocking" in igb_get_stats64
- Main idea is to immediately return "the last valid data" in igb_get_stats64
Experiment from today:
struct mutex stats64_lock;
struct rtnl_link_stats64 stats64;
struct rtnl_link_stats64 stats64_backup;static struct rtnl_link_stats64 *igb_get_stats64(struct net_device *netdev,
struct rtnl_link_stats64 *stats)
{
struct igb_adapter *adapter = netdev_priv(netdev);
if (! mutex_trylock(&adapter->stats64_lock)) {
memcpy(stats, &adapter->stats64_backup, sizeof(*stats));
goto out;
}
igb_update_stats(adapter, &adapter->stats64);
memcpy(&adapter->stats64_backup, &adapter->stats64, sizeof(*stats));
memcpy(stats, &adapter->stats64, sizeof(*stats));
mutex_unlock(&adapter->stats64_lock);
out:
return stats;
}Easy example:
while true; do ifconfig > /dev/null; done &
CNT_ETH=6; while true; do for i in seq 0 $(($CNT_ETH - 1)); do ethtool -S eth$i > /dev/null; done; done & cyclictest -SMmp 90
CONFIG_DEBUG_ATOMIC_SLEEP=yCONFIG_PREEMPT=y
Default spinlock implementation:
T: 0 ( 3779) P:90 I:1000 C: 90614 Min: 2 Act: 5 Avg: 8 Max: 239
T: 1 ( 3781) P:90 I:1500 C: 60406 Min: 2 Act: 3 Avg: 10 Max: 210
T: 2 ( 3784) P:90 I:2000 C: 45303 Min: 2 Act: 213 Avg: 14 Max: 213
T: 3 ( 3787) P:90 I:2500 C: 36240 Min: 2 Act: 10 Avg: 12 Max: 221
(No BUG messages)
Modified igb_get_stats64 with mutex_trylock + backup:
T: 0 (13138) P:90 I:1000 C: 138238 Min: 2 Act: 8 Avg: 8 Max: 64
T: 1 (13140) P:90 I:1500 C: 92156 Min: 2 Act: 38 Avg: 8 Max: 38
T: 2 (13143) P:90 I:2000 C: 69115 Min: 2 Act: 11 Avg: 12 Max: 43
T: 3 (13146) P:90 I:2500 C: 55290 Min: 2 Act: 13 Avg: 11 Max: 43
But its just a experiment
Anyway mentioned patch was already reverted
Sorry for the inconveniences
Regards
Jan