On 4/12/19 4:16 PM, Sasha Levin wrote:
> On Fri, Apr 12, 2019 at 01:17:05PM +0200, Lars Persson wrote:
>> This was fixed in upstream by commit 7d9e6c5afab6 ("net: stmmac: Integrate
>> XGMAC into main driver flow") that is a new feature commit.
>>
>> We found a race condition in the DMA init sequence that hits if the
>> PHY already has link up during stmmac_hw_setup. Since the ring length
>> was programmed after enabling the RX path, we might receive a packet
>> before the correct ring length is programmed. When that happened we
>> could not get reliable interrupts for DMA RX and the MTL complained
>> about RX FIFO overrun.
>>
>> The correct init sequence according to the data book for DWC Ethernet
>> QoS 4.10 is:
>> 1. Write Ring length
>> 2. Write Descriptor list base address
>> 3. Start the DMA.
>>
>> Signed-off-by: Lars Persson <larper(a)axis.com>
>> Cc: stable(a)vger.kernel.org # 4.9.x
>> Cc: Giuseppe Cavallaro <peppe.cavallaro(a)st.com>
>> Cc: Alexandre Torgue <alexandre.torgue(a)st.com>
>> Cc: Jose Abreu <joabreu(a)synopsys.com>
>
> What about 4.14? 7d9e6c5afab6 isn't in it either.
>
I will send a separate patch for 4.14 in some days.
-Lars
From: "Lendacky, Thomas" <Thomas.Lendacky(a)amd.com>
Spurious interrupt support was adding to perf in:
commit 63e6be6d98e1 ("perf, x86: Catch spurious interrupts after disabling counters")
The two previous patches (resolving the race condition when disabling a
PMC and NMI latency mitigation) allow for the removal of this older
spurious interrupt support.
Currently in x86_pmu_stop(), the bit for the PMC in the active_mask bitmap
is cleared before disabling the PMC, which sets up a race condition. This
race condition was mitigated by introducing the running bitmap. That race
condition can be eliminated by first disabling the PMC, waiting for PMC
reset on overflow and then clearing the bit for the PMC in the active_mask
bitmap. The NMI handler will not re-enable a disabled counter.
If x86_pmu_stop() is called from the perf NMI handler, the NMI latency
mitigation support will guard against any unhandled NMI messages.
Signed-off-by: Tom Lendacky <thomas.lendacky(a)amd.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz(a)infradead.org>
Cc: <stable(a)vger.kernel.org> # 4.14.x-
Cc: Alexander Shishkin <alexander.shishkin(a)linux.intel.com>
Cc: Arnaldo Carvalho de Melo <acme(a)kernel.org>
Cc: Arnaldo Carvalho de Melo <acme(a)redhat.com>
Cc: Borislav Petkov <bp(a)alien8.de>
Cc: Jiri Olsa <jolsa(a)redhat.com>
Cc: Linus Torvalds <torvalds(a)linux-foundation.org>
Cc: Namhyung Kim <namhyung(a)kernel.org>
Cc: Peter Zijlstra <peterz(a)infradead.org>
Cc: Stephane Eranian <eranian(a)google.com>
Cc: Thomas Gleixner <tglx(a)linutronix.de>
Cc: Vince Weaver <vincent.weaver(a)maine.edu>
Link: https://lkml.kernel.org/r/Message-ID:
Signed-off-by: Ingo Molnar <mingo(a)kernel.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme(a)redhat.com>
---
arch/x86/events/amd/core.c | 19 ++++++++++++++++++-
arch/x86/events/core.c | 13 +++----------
2 files changed, 21 insertions(+), 11 deletions(-)
diff --git a/arch/x86/events/amd/core.c b/arch/x86/events/amd/core.c
index 34c191453ce3..5d423653f744 100644
--- a/arch/x86/events/amd/core.c
+++ b/arch/x86/events/amd/core.c
@@ -491,6 +491,23 @@ static void amd_pmu_disable_all(void)
}
}
+static void amd_pmu_disable_event(struct perf_event *event)
+{
+ x86_pmu_disable_event(event);
+
+ /*
+ * This can be called from NMI context (via x86_pmu_stop). The counter
+ * may have overflowed, but either way, we'll never see it get reset
+ * by the NMI if we're already in the NMI. And the NMI latency support
+ * below will take care of any pending NMI that might have been
+ * generated by the overflow.
+ */
+ if (in_nmi())
+ return;
+
+ amd_pmu_wait_on_overflow(event->hw.idx);
+}
+
/*
* Because of NMI latency, if multiple PMC counters are active or other sources
* of NMIs are received, the perf NMI handler can handle one or more overflowed
@@ -738,7 +755,7 @@ static __initconst const struct x86_pmu amd_pmu = {
.disable_all = amd_pmu_disable_all,
.enable_all = x86_pmu_enable_all,
.enable = x86_pmu_enable_event,
- .disable = x86_pmu_disable_event,
+ .disable = amd_pmu_disable_event,
.hw_config = amd_pmu_hw_config,
.schedule_events = x86_schedule_events,
.eventsel = MSR_K7_EVNTSEL0,
diff --git a/arch/x86/events/core.c b/arch/x86/events/core.c
index e2b1447192a8..81911e11a15d 100644
--- a/arch/x86/events/core.c
+++ b/arch/x86/events/core.c
@@ -1349,8 +1349,9 @@ void x86_pmu_stop(struct perf_event *event, int flags)
struct cpu_hw_events *cpuc = this_cpu_ptr(&cpu_hw_events);
struct hw_perf_event *hwc = &event->hw;
- if (__test_and_clear_bit(hwc->idx, cpuc->active_mask)) {
+ if (test_bit(hwc->idx, cpuc->active_mask)) {
x86_pmu.disable(event);
+ __clear_bit(hwc->idx, cpuc->active_mask);
cpuc->events[hwc->idx] = NULL;
WARN_ON_ONCE(hwc->state & PERF_HES_STOPPED);
hwc->state |= PERF_HES_STOPPED;
@@ -1447,16 +1448,8 @@ int x86_pmu_handle_irq(struct pt_regs *regs)
apic_write(APIC_LVTPC, APIC_DM_NMI);
for (idx = 0; idx < x86_pmu.num_counters; idx++) {
- if (!test_bit(idx, cpuc->active_mask)) {
- /*
- * Though we deactivated the counter some cpus
- * might still deliver spurious interrupts still
- * in flight. Catch them:
- */
- if (__test_and_clear_bit(idx, cpuc->running))
- handled++;
+ if (!test_bit(idx, cpuc->active_mask))
continue;
- }
event = cpuc->events[idx];
--
2.20.1
This was fixed in upstream by commit 7d9e6c5afab6 ("net: stmmac: Integrate
XGMAC into main driver flow") that is a new feature commit.
We found a race condition in the DMA init sequence that hits if the
PHY already has link up during stmmac_hw_setup. Since the ring length
was programmed after enabling the RX path, we might receive a packet
before the correct ring length is programmed. When that happened we
could not get reliable interrupts for DMA RX and the MTL complained
about RX FIFO overrun.
The correct init sequence according to the data book for DWC Ethernet
QoS 4.10 is:
1. Write Ring length
2. Write Descriptor list base address
3. Start the DMA.
Signed-off-by: Lars Persson <larper(a)axis.com>
Cc: stable(a)vger.kernel.org # 4.9.x
Cc: Giuseppe Cavallaro <peppe.cavallaro(a)st.com>
Cc: Alexandre Torgue <alexandre.torgue(a)st.com>
Cc: Jose Abreu <joabreu(a)synopsys.com>
---
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index fc437d75ac76..561e095511d6 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -1618,6 +1618,15 @@ static int stmmac_init_dma_engine(struct stmmac_priv *priv)
return ret;
}
+ /* set TX ring length */
+ if (priv->hw->dma->set_tx_ring_len)
+ priv->hw->dma->set_tx_ring_len(priv->ioaddr,
+ (DMA_TX_SIZE - 1));
+ /* set RX ring length */
+ if (priv->hw->dma->set_rx_ring_len)
+ priv->hw->dma->set_rx_ring_len(priv->ioaddr,
+ (DMA_RX_SIZE - 1));
+
priv->hw->dma->init(priv->ioaddr, pbl, fixed_burst, mixed_burst,
aal, priv->dma_tx_phy, priv->dma_rx_phy, atds);
@@ -1767,14 +1776,6 @@ static int stmmac_hw_setup(struct net_device *dev, bool init_ptp)
if (priv->hw->pcs && priv->hw->mac->pcs_ctrl_ane)
priv->hw->mac->pcs_ctrl_ane(priv->hw, 1, priv->hw->ps, 0);
- /* set TX ring length */
- if (priv->hw->dma->set_tx_ring_len)
- priv->hw->dma->set_tx_ring_len(priv->ioaddr,
- (DMA_TX_SIZE - 1));
- /* set RX ring length */
- if (priv->hw->dma->set_rx_ring_len)
- priv->hw->dma->set_rx_ring_len(priv->ioaddr,
- (DMA_RX_SIZE - 1));
/* Enable TSO */
if (priv->tso)
priv->hw->dma->enable_tso(priv->ioaddr, 1, STMMAC_CHAN0);
--
2.11.0
12.04.2019 4:34, Sasha Levin пишет:
> Hi,
>
> [This is an automated email]
>
> This commit has been processed because it contains a -stable tag.
> The stable tag indicates that it's relevant for the following trees: all
>
> The bot has tested the following trees: v5.0.7, v4.19.34, v4.14.111, v4.9.168, v4.4.178, v3.18.138.
>
> v5.0.7: Build OK!
> v4.19.34: Build OK!
> v4.14.111: Build OK!
> v4.9.168: Failed to apply! Possible dependencies:
> 0f0fe7e01327 ("PM / OPP: Manage supply's voltage/current in a separate structure")
> 37a73ec0c9bb ("PM / OPP: Add per OPP table mutex")
> 63a69ea4b88f ("PM / OPP: Rename _allocate_opp() to _opp_allocate()")
> 7034764a1e4a ("PM / OPP: Add 'struct kref' to struct dev_pm_opp")
> 8a31d9d94297 ("PM / OPP: Update OPP users to put reference")
> 947355850fcb ("PM / OPP: Separate out _generic_set_opp()")
> 969fceb3c7e6 ("PM / OPP: Add light weight _opp_free() routine")
> ce31781a7574 ("PM / OPP: Pass struct dev_pm_opp_supply to _set_opp_voltage()")
> dfbe4678d709 ("PM / OPP: Add infrastructure to manage multiple regulators")
>
> v4.4.178: Failed to apply! Possible dependencies:
> 01fb4d3c39d3 ("PM / OPP: Parse 'opp-<prop>-<name>' bindings")
> 0c717d0f9cb4 ("PM / OPP: Initialize regulator pointer to an error value")
> 2c2709dc6921 ("PM / OPP: Rename structures for clarity")
> 50f8cfbd5897 ("PM / OPP: Parse clock-latency and voltage-tolerance for v1 bindings")
> 655c9df96175 ("PM / OPP: Introduce dev_pm_opp_get_max_volt_latency()")
> 7de36b0aa51a ("PM / OPP: Parse 'opp-supported-hw' binding")
> 8a31d9d94297 ("PM / OPP: Update OPP users to put reference")
> 9f8ea969d5cf ("PM / OPP: get/put regulators from OPP core")
> d54974c2513f ("PM / OPP: Manage device clk")
> dc4e7b1fa20a ("PM / OPP: Add missing doc comments")
> deaa51465105 ("PM / OPP: Add debugfs support")
>
> v3.18.138: Failed to apply! Possible dependencies:
> 07cce74a7b25 ("PM / OPP: handle allocation of device_opp in a separate routine")
> 0fe30da2cb43 ("PM / OPP: fix warning in of_free_opp_table()")
> 11573e9132ae ("PM / devfreq: tegra: Update to v5 of the submitted patches")
> 129eec55df6a ("PM / OPP Introduce APIs to remove OPPs")
> 29df0ee1b14a ("PM / OPP: reuse find_device_opp() instead of duplicating code")
> 2c2709dc6921 ("PM / OPP: Rename structures for clarity")
> 327854c87117 ("PM / OPP: Ensure consistent naming of static functions")
> 38393409da34 ("PM / OPP mark OPPs as 'static' or 'dynamic'")
> 6234f38016ad ("PM / devfreq: tegra: add devfreq driver for Tegra Activity Monitor")
> 737002b5de3d ("PM / OPP: Relocate few routines")
> 86453b473b1f ("PM / OPP: Staticize __dev_pm_opp_remove()")
> 87b4115db023 ("PM / OPP: Protect updates to list_dev with mutex")
> 8a31d9d94297 ("PM / OPP: Update OPP users to put reference")
> 8d4d4e98acd6 ("PM / OPP: Add helpers for initializing CPU OPPs")
> 984f16c8490c ("PM / OPP: Update kernel documentation")
> a7470db6fec4 ("PM / OPP don't match for existing OPPs when list is empty")
> b02ded246d01 ("PM / OPP: add some lockdep annotations")
> b4037aaa584b ("PM / OPP replace kfree_rcu() with call_srcu() in opp_set_availability()")
> cd1a068a52ee ("PM / OPP rename 'head' as 'rcu_head' or 'srcu_head' based on its type")
> f59d3ee8480d ("PM / OPP: Move cpu specific code to opp/cpu.c")
>
>
> How should we proceed with this patch?
Don't backport to v4.9 and older, it's not a critical fix at all.
Resend clock patches from v4 based on v5.0-rc1.
The whole series now is composed of
a fix for PLL tuner (PATCH 1),
clock common changes for both MT8183 & MT6765 (PATCH 2-3),
clock support of MT8183 (PATCH 4-8) and
resend a clock patch long time ago(PTACH 9).
changes since v4:
- refine for the fix of PLL tuner(PATCH 1).
- add configurable pcw_chg_reg for MT8183 and the following IC(PATCH 7).
changes sinve v3:
- add fix tag.
- small change of mtk_clk_mux data structure.
- use of_property_for_each_string to iterate dependent subsys clock of power domain.
- document critical clocks.
- reduce some clock register error log.
- few coding style fix.
changes sinve v2:
- refine for implementation consistency of mtk clk mux.
- separate the onoff API into enable/disable API for mtk scpsys.
- resend a patch about PLL rate changing.
changes since v1:
- refine for better code quality.
- some minor bug fix of clock part, like incorrect control address
and missing clocks.