chengshan / rpms / kernel

Forked from rpms/kernel 2 years ago
Clone
e8384c
From 88f3beae583682a992de2429992256666d70a40a Mon Sep 17 00:00:00 2001
e8384c
From: Miroslav Lichvar <mlichvar@redhat.com>
e8384c
Date: Tue, 23 Oct 2018 14:37:39 +0200
e8384c
Subject: e1000e: allow non-monotonic SYSTIM readings
e8384c
e8384c
[ Upstream commit e1f65b0d70e9e5c80e15105cd96fa00174d7c436 ]
e8384c
e8384c
It seems with some NICs supported by the e1000e driver a SYSTIM reading
e8384c
may occasionally be few microseconds before the previous reading and if
e8384c
enabled also pass e1000e_sanitize_systim() without reaching the maximum
e8384c
number of rereads, even if the function is modified to check three
e8384c
consecutive readings (i.e. it doesn't look like a double read error).
e8384c
This causes an underflow in the timecounter and the PHC time jumps hours
e8384c
ahead.
e8384c
e8384c
This was observed on 82574, I217 and I219. The fastest way to reproduce
e8384c
it is to run a program that continuously calls the PTP_SYS_OFFSET ioctl
e8384c
on the PHC.
e8384c
e8384c
Modify e1000e_phc_gettime() to use timecounter_cyc2time() instead of
e8384c
timecounter_read() in order to allow non-monotonic SYSTIM readings and
e8384c
prevent the PHC from jumping.
e8384c
e8384c
Cc: Richard Cochran <richardcochran@gmail.com>
e8384c
Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
e8384c
Acked-by: Jacob Keller <jacob.e.keller@intel.com>
e8384c
Tested-by: Aaron Brown <aaron.f.brown@intel.com>
e8384c
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
e8384c
Signed-off-by: Sasha Levin <sashal@kernel.org>
e8384c
---
e8384c
 drivers/net/ethernet/intel/e1000e/ptp.c | 13 ++++++++++---
e8384c
 1 file changed, 10 insertions(+), 3 deletions(-)
e8384c
e8384c
diff --git a/drivers/net/ethernet/intel/e1000e/ptp.c b/drivers/net/ethernet/intel/e1000e/ptp.c
e8384c
index 37c76945ad9b..e1f821edbc21 100644
e8384c
--- a/drivers/net/ethernet/intel/e1000e/ptp.c
e8384c
+++ b/drivers/net/ethernet/intel/e1000e/ptp.c
e8384c
@@ -173,10 +173,14 @@ static int e1000e_phc_gettime(struct ptp_clock_info *ptp, struct timespec64 *ts)
e8384c
 	struct e1000_adapter *adapter = container_of(ptp, struct e1000_adapter,
e8384c
 						     ptp_clock_info);
e8384c
 	unsigned long flags;
e8384c
-	u64 ns;
e8384c
+	u64 cycles, ns;
e8384c
 
e8384c
 	spin_lock_irqsave(&adapter->systim_lock, flags);
e8384c
-	ns = timecounter_read(&adapter->tc);
e8384c
+
e8384c
+	/* Use timecounter_cyc2time() to allow non-monotonic SYSTIM readings */
e8384c
+	cycles = adapter->cc.read(&adapter->cc);
e8384c
+	ns = timecounter_cyc2time(&adapter->tc, cycles);
e8384c
+
e8384c
 	spin_unlock_irqrestore(&adapter->systim_lock, flags);
e8384c
 
e8384c
 	*ts = ns_to_timespec64(ns);
e8384c
@@ -232,9 +236,12 @@ static void e1000e_systim_overflow_work(struct work_struct *work)
e8384c
 						     systim_overflow_work.work);
e8384c
 	struct e1000_hw *hw = &adapter->hw;
e8384c
 	struct timespec64 ts;
e8384c
+	u64 ns;
e8384c
 
e8384c
-	adapter->ptp_clock_info.gettime64(&adapter->ptp_clock_info, &ts);
e8384c
+	/* Update the timecounter */
e8384c
+	ns = timecounter_read(&adapter->tc);
e8384c
 
e8384c
+	ts = ns_to_timespec64(ns);
e8384c
 	e_dbg("SYSTIM overflow check at %lld.%09lu\n",
e8384c
 	      (long long) ts.tv_sec, ts.tv_nsec);
e8384c
 
e8384c
-- 
e8384c
cgit 1.2-0.3.lf.el7
e8384c
e8384c
From 49dd86f0f5ece4e7addc0f8db5e75a2fb404ede6 Mon Sep 17 00:00:00 2001
e8384c
From: Florian Fainelli <f.fainelli@gmail.com>
e8384c
Date: Thu, 21 Feb 2019 20:09:28 -0800
e8384c
Subject: e1000e: Fix -Wformat-truncation warnings
e8384c
e8384c
[ Upstream commit 135e7245479addc6b1f5d031e3d7e2ddb3d2b109 ]
e8384c
e8384c
Provide precision hints to snprintf() since we know the destination
e8384c
buffer size of the RX/TX ring names are IFNAMSIZ + 5 - 1. This fixes the
e8384c
following warnings:
e8384c
e8384c
drivers/net/ethernet/intel/e1000e/netdev.c: In function
e8384c
'e1000_request_msix':
e8384c
drivers/net/ethernet/intel/e1000e/netdev.c:2109:13: warning: 'snprintf'
e8384c
output may be truncated before the last format character
e8384c
[-Wformat-truncation=]
e8384c
     "%s-rx-0", netdev->name);
e8384c
             ^
e8384c
drivers/net/ethernet/intel/e1000e/netdev.c:2107:3: note: 'snprintf'
e8384c
output between 6 and 21 bytes into a destination of size 20
e8384c
   snprintf(adapter->rx_ring->name,
e8384c
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
e8384c
     sizeof(adapter->rx_ring->name) - 1,
e8384c
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
e8384c
     "%s-rx-0", netdev->name);
e8384c
     ~~~~~~~~~~~~~~~~~~~~~~~~
e8384c
drivers/net/ethernet/intel/e1000e/netdev.c:2125:13: warning: 'snprintf'
e8384c
output may be truncated before the last format character
e8384c
[-Wformat-truncation=]
e8384c
     "%s-tx-0", netdev->name);
e8384c
             ^
e8384c
drivers/net/ethernet/intel/e1000e/netdev.c:2123:3: note: 'snprintf'
e8384c
output between 6 and 21 bytes into a destination of size 20
e8384c
   snprintf(adapter->tx_ring->name,
e8384c
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
e8384c
     sizeof(adapter->tx_ring->name) - 1,
e8384c
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
e8384c
     "%s-tx-0", netdev->name);
e8384c
     ~~~~~~~~~~~~~~~~~~~~~~~~
e8384c
e8384c
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
e8384c
Signed-off-by: David S. Miller <davem@davemloft.net>
e8384c
Signed-off-by: Sasha Levin <sashal@kernel.org>
e8384c
---
e8384c
 drivers/net/ethernet/intel/e1000e/netdev.c | 4 ++--
e8384c
 1 file changed, 2 insertions(+), 2 deletions(-)
e8384c
e8384c
diff --git a/drivers/net/ethernet/intel/e1000e/netdev.c b/drivers/net/ethernet/intel/e1000e/netdev.c
e8384c
index 3ba0c90e7055..e3945469b5c8 100644
e8384c
--- a/drivers/net/ethernet/intel/e1000e/netdev.c
e8384c
+++ b/drivers/net/ethernet/intel/e1000e/netdev.c
e8384c
@@ -2106,7 +2106,7 @@ static int e1000_request_msix(struct e1000_adapter *adapter)
e8384c
 	if (strlen(netdev->name) < (IFNAMSIZ - 5))
e8384c
 		snprintf(adapter->rx_ring->name,
e8384c
 			 sizeof(adapter->rx_ring->name) - 1,
e8384c
-			 "%s-rx-0", netdev->name);
e8384c
+			 "%.14s-rx-0", netdev->name);
e8384c
 	else
e8384c
 		memcpy(adapter->rx_ring->name, netdev->name, IFNAMSIZ);
e8384c
 	err = request_irq(adapter->msix_entries[vector].vector,
e8384c
@@ -2122,7 +2122,7 @@ static int e1000_request_msix(struct e1000_adapter *adapter)
e8384c
 	if (strlen(netdev->name) < (IFNAMSIZ - 5))
e8384c
 		snprintf(adapter->tx_ring->name,
e8384c
 			 sizeof(adapter->tx_ring->name) - 1,
e8384c
-			 "%s-tx-0", netdev->name);
e8384c
+			 "%.14s-tx-0", netdev->name);
e8384c
 	else
e8384c
 		memcpy(adapter->tx_ring->name, netdev->name, IFNAMSIZ);
e8384c
 	err = request_irq(adapter->msix_entries[vector].vector,
e8384c
-- 
e8384c
cgit 1.2-0.3.lf.el7
e8384c
e8384c
From b9f257e27890c462cc07c3e6d4fa7509730ea396 Mon Sep 17 00:00:00 2001
e8384c
From: Kai-Heng Feng <kai.heng.feng@canonical.com>
e8384c
Date: Tue, 11 Dec 2018 15:59:37 +0800
e8384c
Subject: e1000e: Exclude device from suspend direct complete optimization
e8384c
e8384c
[ Upstream commit 59f58708c5047289589cbf6ee95146b76cf57d1e ]
e8384c
e8384c
e1000e sets different WoL settings in system suspend callback and
e8384c
runtime suspend callback.
e8384c
e8384c
The suspend direct complete optimization leaves e1000e in runtime
e8384c
suspended state with wrong WoL setting during system suspend.
e8384c
e8384c
To fix this, we need to disable suspend direct complete optimization to
e8384c
let e1000e always use suspend callback to set correct WoL during system
e8384c
suspend.
e8384c
e8384c
Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
e8384c
Tested-by: Aaron Brown <aaron.f.brown@intel.com>
e8384c
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
e8384c
Signed-off-by: Sasha Levin <sashal@kernel.org>
e8384c
---
e8384c
 drivers/net/ethernet/intel/e1000e/netdev.c | 2 ++
e8384c
 1 file changed, 2 insertions(+)
e8384c
e8384c
diff --git a/drivers/net/ethernet/intel/e1000e/netdev.c b/drivers/net/ethernet/intel/e1000e/netdev.c
e8384c
index 23edc1364487..8b11682ebba2 100644
e8384c
--- a/drivers/net/ethernet/intel/e1000e/netdev.c
e8384c
+++ b/drivers/net/ethernet/intel/e1000e/netdev.c
e8384c
@@ -7327,6 +7327,8 @@ static int e1000_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
e8384c
 
e8384c
 	e1000_print_device_info(adapter);
e8384c
 
e8384c
+	dev_pm_set_driver_flags(&pdev->dev, DPM_FLAG_NEVER_SKIP);
e8384c
+
e8384c
 	if (pci_dev_run_wake(pdev))
e8384c
 		pm_runtime_put_noidle(&pdev->dev);
e8384c
 
e8384c
-- 
e8384c
cgit 1.2-0.3.lf.el7
e8384c
e8384c
From 5ec9ba494db252d8a5baaed4fdaf5b4bbbc201dd Mon Sep 17 00:00:00 2001
e8384c
From: Kai-Heng Feng <kai.heng.feng@canonical.com>
e8384c
Date: Sun, 3 Feb 2019 01:40:16 +0800
e8384c
Subject: e1000e: Disable runtime PM on CNP+
e8384c
e8384c
[ Upstream commit 459d69c407f9ba122f12216555c3012284dc9fd7 ]
e8384c
e8384c
There are some new e1000e devices can only be woken up from D3 one time,
e8384c
by plugging Ethernet cable. Subsequent cable plugging does set PME bit
e8384c
correctly, but it still doesn't get woken up.
e8384c
e8384c
Since e1000e connects to the root complex directly, we rely on ACPI to
e8384c
wake it up. In this case, the GPE from _PRW only works once and stops
e8384c
working after that. Though it appears to be a platform bug, e1000e
e8384c
maintainers confirmed that I219 does not support D3.
e8384c
e8384c
So disable runtime PM on CNP+ chips. We may need to disable earlier
e8384c
generations if this bug also hit older platforms.
e8384c
e8384c
Bugzilla: https://bugzilla.kernel.org/attachment.cgi?id=280819
e8384c
Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
e8384c
Tested-by: Aaron Brown <aaron.f.brown@intel.com>
e8384c
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
e8384c
Signed-off-by: Sasha Levin <sashal@kernel.org>
e8384c
---
e8384c
 drivers/net/ethernet/intel/e1000e/netdev.c | 2 +-
e8384c
 1 file changed, 1 insertion(+), 1 deletion(-)
e8384c
e8384c
diff --git a/drivers/net/ethernet/intel/e1000e/netdev.c b/drivers/net/ethernet/intel/e1000e/netdev.c
e8384c
index 8b11682ebba2..8cd339c92c1a 100644
e8384c
--- a/drivers/net/ethernet/intel/e1000e/netdev.c
e8384c
+++ b/drivers/net/ethernet/intel/e1000e/netdev.c
e8384c
@@ -7329,7 +7329,7 @@ static int e1000_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
e8384c
 
e8384c
 	dev_pm_set_driver_flags(&pdev->dev, DPM_FLAG_NEVER_SKIP);
e8384c
 
e8384c
-	if (pci_dev_run_wake(pdev))
e8384c
+	if (pci_dev_run_wake(pdev) && hw->mac.type < e1000_pch_cnp)
e8384c
 		pm_runtime_put_noidle(&pdev->dev);
e8384c
 
e8384c
 	return 0;
e8384c
-- 
e8384c
cgit 1.2-0.3.lf.el7
e8384c
e8384c
From 8cff6598b3c03936022dc3998274dba43567cc05 Mon Sep 17 00:00:00 2001
e8384c
From: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
e8384c
Date: Wed, 17 Apr 2019 11:13:20 +0300
e8384c
Subject: e1000e: start network tx queue only when link is up
e8384c
e8384c
commit d17ba0f616a08f597d9348c372d89b8c0405ccf3 upstream.
e8384c
e8384c
Driver does not want to keep packets in Tx queue when link is lost.
e8384c
But present code only reset NIC to flush them, but does not prevent
e8384c
queuing new packets. Moreover reset sequence itself could generate
e8384c
new packets via netconsole and NIC falls into endless reset loop.
e8384c
e8384c
This patch wakes Tx queue only when NIC is ready to send packets.
e8384c
e8384c
This is proper fix for problem addressed by commit 0f9e980bf5ee
e8384c
("e1000e: fix cyclic resets at link up with active tx").
e8384c
e8384c
Signed-off-by: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
e8384c
Suggested-by: Alexander Duyck <alexander.duyck@gmail.com>
e8384c
Tested-by: Joseph Yasi <joe.yasi@gmail.com>
e8384c
Tested-by: Aaron Brown <aaron.f.brown@intel.com>
e8384c
Tested-by: Oleksandr Natalenko <oleksandr@redhat.com>
e8384c
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
e8384c
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
e8384c
---
e8384c
 drivers/net/ethernet/intel/e1000e/netdev.c | 6 ++++--
e8384c
 1 file changed, 4 insertions(+), 2 deletions(-)
e8384c
e8384c
diff --git a/drivers/net/ethernet/intel/e1000e/netdev.c b/drivers/net/ethernet/intel/e1000e/netdev.c
e8384c
index 31ef42a031f2..a7b5a47ab83d 100644
e8384c
--- a/drivers/net/ethernet/intel/e1000e/netdev.c
e8384c
+++ b/drivers/net/ethernet/intel/e1000e/netdev.c
e8384c
@@ -4208,7 +4208,7 @@ void e1000e_up(struct e1000_adapter *adapter)
e8384c
 		e1000_configure_msix(adapter);
e8384c
 	e1000_irq_enable(adapter);
e8384c
 
e8384c
-	netif_start_queue(adapter->netdev);
e8384c
+	/* Tx queue started by watchdog timer when link is up */
e8384c
 
e8384c
 	e1000e_trigger_lsc(adapter);
e8384c
 }
e8384c
@@ -4584,6 +4584,7 @@ int e1000e_open(struct net_device *netdev)
e8384c
 	pm_runtime_get_sync(&pdev->dev);
e8384c
 
e8384c
 	netif_carrier_off(netdev);
e8384c
+	netif_stop_queue(netdev);
e8384c
 
e8384c
 	/* allocate transmit descriptors */
e8384c
 	err = e1000e_setup_tx_resources(adapter->tx_ring);
e8384c
@@ -4644,7 +4645,6 @@ int e1000e_open(struct net_device *netdev)
e8384c
 	e1000_irq_enable(adapter);
e8384c
 
e8384c
 	adapter->tx_hang_recheck = false;
e8384c
-	netif_start_queue(netdev);
e8384c
 
e8384c
 	hw->mac.get_link_status = true;
e8384c
 	pm_runtime_put(&pdev->dev);
e8384c
@@ -5266,6 +5266,7 @@ static void e1000_watchdog_task(struct work_struct *work)
e8384c
 			if (phy->ops.cfg_on_link_up)
e8384c
 				phy->ops.cfg_on_link_up(hw);
e8384c
 
e8384c
+			netif_wake_queue(netdev);
e8384c
 			netif_carrier_on(netdev);
e8384c
 
e8384c
 			if (!test_bit(__E1000_DOWN, &adapter->state))
e8384c
@@ -5279,6 +5280,7 @@ static void e1000_watchdog_task(struct work_struct *work)
e8384c
 			/* Link status message must follow this format */
e8384c
 			pr_info("%s NIC Link is Down\n", adapter->netdev->name);
e8384c
 			netif_carrier_off(netdev);
e8384c
+			netif_stop_queue(netdev);
e8384c
 			if (!test_bit(__E1000_DOWN, &adapter->state))
e8384c
 				mod_timer(&adapter->phy_info_timer,
e8384c
 					  round_jiffies(jiffies + 2 * HZ));
e8384c
-- 
e8384c
cgit 1.2-0.3.lf.el7
e8384c