Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unspecified interactions between HSM and other extensions #98

Closed
smaeul opened this issue Jun 23, 2022 · 25 comments
Closed

Unspecified interactions between HSM and other extensions #98

smaeul opened this issue Jun 23, 2022 · 25 comments

Comments

@smaeul
Copy link

smaeul commented Jun 23, 2022

The SBI spec should clarify how stopping/suspending one or all harts is allowed to affect the behavior of other extensions, as well as other architectural state.

For example, the timer extension:

  • Is a timer event required to fire while all harts are suspended?
  • Is a future timer event required to remain armed across hart suspend?

Some further discussion (correct me if I'm wrong): https://lore.kernel.org/linux-riscv/bca6d76d-1708-fede-8008-d2588a14b656@mail.ru/T/

What about the PMU extension? Is hart suspend allowed to reset the PMU state?

@avpatel
Copy link
Contributor

avpatel commented Oct 24, 2022

Whether the timer interrupt will fire during non-retentive suspend or not is a platform/implementation-specific detail which needs to be discovered from DT/ACPI (similar to what ARM has done). The SBI specification only defines mechanism to enter suspend states.

I had sent out a Linux patch to add HART DT property for this. Maybe we can move in that direction?
(Refer, https://lore.kernel.org/all/20220727114302.302201-1-apatel@ventanamicro.com/)

Regards,
Anup

@smaeul
Copy link
Author

smaeul commented Oct 29, 2022

Not making any guarantees is fine with me, as long as everyone is okay with the implications. Namely, that in the absence of DT/ACPI properties, S-mode software must be able to work with the worst-case platform/implementation.

I assume then that it's okay to lose PMU counter and interrupt state in suspend as well. Who is responsible for saving/restoring that state, S-mode or M-mode?

@palmer-dabbelt
Copy link
Contributor

this came up on IRC and LKML, but just to reflect things here: IMO it's fine if this is the desired behavior in the spec, we'll just need some DT properties so hardware can Ack into using non-retentive suspend from Linux.

@smaeul
Copy link
Author

smaeul commented Nov 7, 2022

The non-retentive suspend states already need to be added to the DT by the firmware at runtime. So the presence of the idle-states nodes is already the hardware/firmware acking in to non-retentive suspend. (The availability of specific state encodings, and their latency properties, will vary between SBI implementations, so it would be inappropriate to include them in the static devicetree.)

Consider these three scenarios:

  1. S-mode software does not use the SBI timer extension at all. It has a native driver for timer hardware that can wake the CPU from idle states.
  2. S-mode software uses the SBI timer extension for its tick timer. The SBI implementation has a driver for hardware timer that can wake the CPU from idle states.
  3. S-mode software uses the SBI timer extension for its tick timer. The SBI implementation has a driver for hardware timer that can not wake the CPU from idle states.

Given the existence of scenario 1, it would be wrong to omit the CPU idle states based on the behavior of the SBI timer extension. The property must allow S-mode software to distinguish between scenarios 2 and 3, so the OS can decide whether or not to use the CPU idle states advertised to it.

I just want to be clear that "does non-retentive suspend work?" is a very different question from "can the SBI timer extension be used in conjunction with non-retentive suspend?".

@palmer-dabbelt
Copy link
Contributor

palmer-dabbelt commented Nov 8, 2022 via email

@avpatel
Copy link
Contributor

avpatel commented Nov 8, 2022

@palmer-dabbelt Yes, for retentive suspend the SBI spec is very clear that HART state must be preserved by HW so interrupt will be observed by HART correctly in retentive suspend state.

Only the non-retentive suspend state gives HW flexibility to discard certain portions of HART state which in-turn allows more power saving.

In addition to timer (SBI timer or Sstc or platform specific), some platform might also lose state of per-HART IMSICs so this property also needs to be discovered from DT or ACPI (just like ARM world).

@ConchuOD
Copy link
Contributor

ConchuOD commented Nov 8, 2022

I'm a little behind on this, so I am gonna do a little recap to make sure that I am on the right track... Things being split over different places hasn't helped.

The way the D1 is implemented, it does not get timer events during suspend. Samuel submitted a patch for Linux so that the clocksource driver would not assume that events are received during suspend.
That then broke things for existing, SiFive based stuff where the implementation does actually receive events during suspend - eg the RCU stall detection not kicking in that I reported.
The proposed solution to keep both parties happy functioning is a dt property.
In the absence of this property, we fall back to covering for the worst case - that being events do not arrive during suspend.
That would make the property "riscv,timer-can-wake-cpu" or whatever that gets bike-shedded to.

Anup made the point on his proposal:

This is a one-of-case with RISC-V DeviceTree where we are living with
the fact that there is no timer DT node. If we add a timer DT node now
then we have to deal with compatibility for existing platforms.

I think that this is a bit moot though, since surely we are already dealing with a compatibility issue for existing platforms?
There are existing platforms, without this "riscv,timer-can-wake-cpu" property in their DT that are affected as is.
Those users are going to have to add the property to continue functioning as-is (or more accurately, as-was) right?
Have I missed something there?

That's all a long-winded way of asking what to do with the revert that I posted.
It seems to me, although I am obviously biased, that we should actually apply the revert since it seems like every upstream user was okay with how things were prior to 32ccac1bd9b ("clocksource/drivers/riscv: Events are stopped during CPU suspend").
When Anup's resolved the concerns of the dt folks and the property has been added, then we can add back in CLOCK_EVT_FEAT_ONESHOT as a default.

Is that a fair summary/proposal?

@palmer-dabbelt
Copy link
Contributor

I'm a little behind on this, so I am gonna do a little recap to make sure that I am on the right track... Things being split over different places hasn't helped.

The way the D1 is implemented, it does not get timer events during suspend. Samuel submitted a patch for Linux so that the clocksource driver would not assume that events are received during suspend. That then broke things for existing, SiFive based stuff where the implementation does actually receive events during suspend - eg the RCU stall detection not kicking in that I reported. The proposed solution to keep both parties happy functioning is a dt property. In the absence of this property, we fall back to covering for the worst case - that being events do not arrive during suspend. That would make the property "riscv,timer-can-wake-cpu" or whatever that gets bike-shedded to.

Anup made the point on his proposal:

This is a one-of-case with RISC-V DeviceTree where we are living with
the fact that there is no timer DT node. If we add a timer DT node now
then we have to deal with compatibility for existing platforms.

I think that this is a bit moot though, since surely we are already dealing with a compatibility issue for existing platforms? There are existing platforms, without this "riscv,timer-can-wake-cpu" property in their DT that are affected as is. Those users are going to have to add the property to continue functioning as-is (or more accurately, as-was) right? Have I missed something there?

That's all a long-winded way of asking what to do with the revert that I posted. It seems to me, although I am obviously biased, that we should actually apply the revert since it seems like every upstream user was okay with how things were prior to 32ccac1bd9b ("clocksource/drivers/riscv: Events are stopped during CPU suspend"). When Anup's resolved the concerns of the dt folks and the property has been added, then we can add back in CLOCK_EVT_FEAT_ONESHOT as a default.

Is that a fair summary/proposal?

That's really a Linux question. It's kind of independent to the spec discussions: we'd need to deal with the breakage either way, the question here is just what the spec requires and thus how we describe this in the code/dt (ie, do we say this is a D1 errata or do we say everyone else has custom extensions to make it work).

@ConchuOD
Copy link
Contributor

ConchuOD commented Nov 8, 2022

ie, do we say this is a D1 errata or do we say everyone else has custom extensions to make it work

Right. In a roundabout way I was pretty much trying to make sure that that was the dividing line. Linux is just my frame of reference for it.

All other things being equal, I'd say that assuming you do not get events in suspend is the "safer" route given we have implementations out there that do both?

@palmer-dabbelt
Copy link
Contributor

ie, do we say this is a D1 errata or do we say everyone else has custom extensions to make it work

Right. In a roundabout way I was pretty much trying to make sure that that was the dividing line. Linux is just my frame of reference for it.

All other things being equal, I'd say that assuming you do not get events in suspend is the "safer" route given we have implementations out there that do both?

I'd argue we should default to what the specs say, but it's the same conclusion here.

@ConchuOD
Copy link
Contributor

I'd argue we should default to what the specs say, but it's the same conclusion here.

Aye, although from the earlier comments here & from my quick read of this repo there does not seem to be anything more specific than: "The hart will automatically come out of suspended state and resume normal execution when it receives an interrupt or platform specific hardware event" (emphasis mine).

Are there other, related, spec docs that may cover whether interrupts must arrive during suspend? Nothing in the PLIC spec from my cursory check.

@ConchuOD
Copy link
Contributor

So, uh.. For this to actually go anywhere what needs to happen? As I said above, I don't see anything covering this "problem" in the specs & I've had reports come in about stuff like clock_nanosleep() being reduced to jiffy accuracy etc.

A v2 of Anup's stuff might make things work kernel-side, but this should really be clarified, right?

@palmer-dabbelt
Copy link
Contributor

I don't think we need to do anything here, we just need to revert that patch in Linux. IIRC it's targeted at the clock folks and I already Ack'd it, but LMK I missed something.

@ConchuOD
Copy link
Contributor

I don't think we need to do anything here, we just need to revert that patch in Linux. IIRC it's targeted at the clock folks and I already Ack'd it, but LMK I missed something.

Riiight - but restoring the old behaviour doesn't do Samuel & other D1 users any favours?
Whether that's reverted or not, we still need a way to differentiate between those who do get clock events in suspend and those who do not, since the spec doesn't seem to describe whether or not an interrupt actually makes it to the hart?

@palmer-dabbelt
Copy link
Contributor

I don't think we need to do anything here, we just need to revert that patch in Linux. IIRC it's targeted at the clock folks and I already Ack'd it, but LMK I missed something.

Riiight - but restoring the old behaviour doesn't do Samuel & other D1 users any favours? Whether that's reverted or not, we still need a way to differentiate between those who do get clock events in suspend and those who do not, since the spec doesn't seem to describe whether or not an interrupt actually makes it to the hart?

I think this should do it: https://lore.kernel.org/r/20221121205647.23343-1-palmer@rivosinc.com/

intel-lab-lkp pushed a commit to intel-lab-lkp/linux that referenced this issue Nov 21, 2022
As per [1], whether or not the core can wake up from non-retentive
suspend is a platform-specific detail.  We don't have any way to encode
that, so just stop using them until we've sorted that out.

Link: riscv-non-isa/riscv-sbi-doc#98 (comment)
Fixes: 6abf32f ("cpuidle: Add RISC-V SBI CPU idle driver")
Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
@smaeul
Copy link
Author

smaeul commented Nov 22, 2022

I don't think we need to do anything here, we just need to revert that patch in Linux. IIRC it's targeted at the clock folks and I already Ack'd it, but LMK I missed something.

What? This directly contradicts your previous suggestion. If we "default to what the specs say", then 232ccac1bd9b is correct, and the DT/ACPI property goes on top of that to remove the flag.

Riiight - but restoring the old behaviour doesn't do Samuel & other D1 users any favours? Whether that's reverted or not, we still need a way to differentiate between those who do get clock events in suspend and those who do not, since the spec doesn't seem to describe whether or not an interrupt actually makes it to the hart?

I think restoring the old behavior is wrong, because it makes assumptions that the spec does not support, but it doesn't actually break suspend on the D1. Linux on D1 uses drivers/clocksource/timer-sun4i.c in preference to SBI timers for clock events, so it falls under "scenario 1" as described above.

I think this should do it: https://lore.kernel.org/r/20221121205647.23343-1-palmer@rivosinc.com/

That patch completely breaks a feature which currently works on "scenario 1" platforms, including D1, and would continue to work regardless of how we changed the RISC-V timer driver (modulo changing the rating such that it started being chosen over other drivers).

@palmer-dabbelt
Copy link
Contributor

I don't think we need to do anything here, we just need to revert that patch in Linux. IIRC it's targeted at the clock folks and I already Ack'd it, but LMK I missed something.

What? This directly contradicts your previous suggestion. If we "default to what the specs say", then 232ccac1bd9b is correct, and the DT/ACPI property goes on top of that to remove the flag.

Sorry, I think I'd gotten lost in which patch was which. We can't just revert the patch, we need some other way of disabling non-retentive suspend until we can sort out how to support it. That's what I was trying to do with the patch.

Riiight - but restoring the old behaviour doesn't do Samuel & other D1 users any favours? Whether that's reverted or not, we still need a way to differentiate between those who do get clock events in suspend and those who do not, since the spec doesn't seem to describe whether or not an interrupt actually makes it to the hart?

I think restoring the old behavior is wrong, because it makes assumptions that the spec does not support, but it doesn't actually break suspend on the D1. Linux on D1 uses drivers/clocksource/timer-sun4i.c in preference to SBI timers for clock events, so it falls under "scenario 1" as described above.

I guess I don't understand what's actually broken, then? If the D1 (which I thought was what broke here?) isn't using the SBI timer driver then why is it breaking things? Having C3STOP unconditionally enabled breaks other platforms and doesn't seem like a sane way to go in general, given that it's aimed at a legacy x86 feature.

Maybe it's better to talk about this on LKML? IMO it's not really a spec question any more.

I think this should do it: https://lore.kernel.org/r/20221121205647.23343-1-palmer@rivosinc.com/

That patch completely breaks a feature which currently works on "scenario 1" platforms, including D1, and would continue to work regardless of how we changed the RISC-V timer driver (modulo changing the rating such that it started being chosen over other drivers).

The feature it breaks is retentive suspend? I agree with that, the patch just disables it until we have some way to make sure it works. If non-retentive suspend works on the D1 when not using the SBI timer then we can always add some sort of hook to check what platform we're on, but we shouldn't be triggering non-retentive suspend without knowing some platform specifics.

@avpatel
Copy link
Contributor

avpatel commented Nov 22, 2022

Better to disable/remove non-retentive suspend states from DT on the platform where it is broken instead of disabling non-retentive suspend for all RISC-V platforms.

@palmer-dabbelt
Copy link
Contributor

Better to disable/remove non-retentive suspend states from DT on the platform where it is broken instead of disabling non-retentive suspend for all RISC-V platforms.

Sorry, but what do you mean by "broken" here?

@avpatel
Copy link
Contributor

avpatel commented Nov 22, 2022

I meant the remove suspend state DT entry for the platform where non-retentive suspend does not work currently.

@palmer-dabbelt
Copy link
Contributor

I meant the remove suspend state DT entry for the platform where non-retentive suspend does not work currently.

In what way does non-retentive suspend not work on these systems? IIUC the spec says that interrupts might not arrive, so the platform is correct here. It's just Linux that's doing the wrong thing by expecting interrupts to be delivered, the C3STOP patch handles that for the timer interrupts (but breaks other stuff in timer land and IMO should still be reverted) but we don't have anything to tell Linux that other interrupts might not arrive.

So IMO it's really the Linux suspend driver that's broken here, not the platform.

@avpatel
Copy link
Contributor

avpatel commented Nov 22, 2022

I agree, Linux suspend flow is broken but it is not the Linux suspend driver but the Linux timer driver which is broken so we need to fix the Linux timer driver.

The non-retentive suspend works fine on Allwinner D1 and QEMU virt machine but does not work on Microchip platform due to C3STOP flag in the RISC-V timer driver.

@avpatel
Copy link
Contributor

avpatel commented Nov 22, 2022

BTW, the Linux suspend flow involves various drivers (timer, interrupt controller, cpuidle, etc) and various subsystems to collectively work. The Linux suspend flow can break if one of the things in Linux suspend flow does not work a particular platform but that does not mean the entire Linux suspend flow is broken for all platforms.

In our case, the RISC-V timer driver does not do the right thing for Microchip platform so we need to fix the RISC-V timer driver. The solution happens to be updating the DT bindings for discovering platform specific behavior of timer interrupts.

@ConchuOD
Copy link
Contributor

The non-retentive suspend works fine on Allwinner D1 and QEMU virt machine but does not work on Microchip platform due to C3STOP flag in the RISC-V timer driver.

Better to disable/remove non-retentive suspend states from DT on the platform where it is broken instead of disabling non-retentive suspend for all RISC-V platforms.

FWIW, our DT has nothing in it related to cpu-idle, we're seeing problems with the timers working properly during normal operation.

Maybe it's better to talk about this on LKML? IMO it's not really a spec question any more.

Good idea.

intel-lab-lkp pushed a commit to intel-lab-lkp/linux that referenced this issue Nov 22, 2022
…end"

This reverts commit 232ccac.

On the subject of suspend, the RISC-V SBI spec states:
> Request the SBI implementation to put the calling hart in a platform
> specific suspend (or low power) state specified by the suspend_type
> parameter. The hart will automatically come out of suspended state and
> resume normal execution when it receives an interrupt or platform
> specific hardware event.

This does not cover whether any given events actually reach the hart or
not, just what the hart will do if it receives an event. On PolarFire
SoC, and potentially other SiFive based implementations, events from the
RISC-V timer do reach a hart during suspend. This is not the case for
the implementation on the Allwinner D1 - there timer events are not
received during suspend.

To fix this, the x86 C3STOP feature was enabled for the timer driver -
but this has broken both RCU stall detection and timers generally on
PolarFire SoC (and potentially other SiFive based implementations).

If an AXI read to the PCIe controller on PolarFire SoC times out, the
system will stall, however, with this patch applied, the system just
locks up without RCU stalling:
	io scheduler mq-deadline registered
	io scheduler kyber registered
	microchip-pcie 2000000000.pcie: host bridge /soc/pcie@2000000000 ranges:
	microchip-pcie 2000000000.pcie:      MEM 0x2008000000..0x2087ffffff -> 0x0008000000
	microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: axi read request error
	microchip-pcie 2000000000.pcie: axi read timeout
	microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer
	Freeing initrd memory: 7332K

Similarly issues were reported with clock_nanosleep() - with a test app
that sleeps each cpu for 6, 5, 4, 3 ms respectively, HZ=250 & the blamed
commit in place, the sleep times are rounded up to the next jiffy:

== CPU: 1 ==      == CPU: 2 ==      == CPU: 3 ==      == CPU: 4 ==
Mean: 7.974992    Mean: 7.976534    Mean: 7.962591    Mean: 3.952179
Std Dev: 0.154374 Std Dev: 0.156082 Std Dev: 0.171018 Std Dev: 0.076193
Hi: 9.472000      Hi: 10.495000     Hi: 8.864000      Hi: 4.736000
Lo: 6.087000      Lo: 6.380000      Lo: 4.872000      Lo: 3.403000
Samples: 521      Samples: 521      Samples: 521      Samples: 521

Fortunately, the D1 has a second timer, which is "currently used in
preference to the RISC-V/SBI timer driver" so a revert here does not
hurt operation of D1 in it's current form.

Ultimately, a DeviceTree property (or node) will be added to encode the
behaviour of the timers, but until then revert the addition of
CLOCK_EVT_FEAT_C3STOP.

Link: https://lore.kernel.org/linux-riscv/YzYTNQRxLr7Q9JR0@spud/
Link: riscv-non-isa/riscv-sbi-doc#98
Link: https://lore.kernel.org/linux-riscv/bf6d3b1f-f703-4a25-833e-972a44a04114@sholland.org/
Fixes: 232ccac ("clocksource/drivers/riscv: Events are stopped during CPU suspend")
CC: Samuel Holland <samuel@sholland.org>
CC: Anup Patel <anup@brainfault.org>
CC: Palmer Dabbelt <palmer@dabbelt.com>
Reviewed-by: Palmer Dabbelt <palmer@rivosinc.com>
Acked-by: Palmer Dabbelt <palmer@rivosinc.com>
Signed-off-by: Conor Dooley <conor.dooley@microchip.com>
avpatel pushed a commit to avpatel/linux that referenced this issue Nov 25, 2022
…end"

This reverts commit 232ccac.

On the subject of suspend, the RISC-V SBI spec states:
> Request the SBI implementation to put the calling hart in a platform
> specific suspend (or low power) state specified by the suspend_type
> parameter. The hart will automatically come out of suspended state and
> resume normal execution when it receives an interrupt or platform
> specific hardware event.

This does not cover whether any given events actually reach the hart or
not, just what the hart will do if it receives an event. On PolarFire
SoC, and potentially other SiFive based implementations, events from the
RISC-V timer do reach a hart during suspend. This is not the case for
the implementation on the Allwinner D1 - there timer events are not
received during suspend.

To fix this, the C3STOP feature was enabled for the timer driver -
but this has broken both RCU stall detection and timers generally on
PolarFire SoC (and potentially other SiFive based implementations).

If an AXI read to the PCIe controller on PolarFire SoC times out, the
system will stall, however, with this patch applied, the system just
locks up without RCU stalling:
	io scheduler mq-deadline registered
	io scheduler kyber registered
	microchip-pcie 2000000000.pcie: host bridge /soc/pcie@2000000000 ranges:
	microchip-pcie 2000000000.pcie:      MEM 0x2008000000..0x2087ffffff -> 0x0008000000
	microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: axi read request error
	microchip-pcie 2000000000.pcie: axi read timeout
	microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer
	Freeing initrd memory: 7332K

Similarly issues were reported with clock_nanosleep() - with a test app
that sleeps each cpu for 6, 5, 4, 3 ms respectively, HZ=250 & the blamed
commit in place, the sleep times are rounded up to the next jiffy:

== CPU: 1 ==      == CPU: 2 ==      == CPU: 3 ==      == CPU: 4 ==
Mean: 7.974992    Mean: 7.976534    Mean: 7.962591    Mean: 3.952179
Std Dev: 0.154374 Std Dev: 0.156082 Std Dev: 0.171018 Std Dev: 0.076193
Hi: 9.472000      Hi: 10.495000     Hi: 8.864000      Hi: 4.736000
Lo: 6.087000      Lo: 6.380000      Lo: 4.872000      Lo: 3.403000
Samples: 521      Samples: 521      Samples: 521      Samples: 521

Fortunately, the D1 has a second timer, which is "currently used in
preference to the RISC-V/SBI timer driver" so a revert here does not
hurt operation of D1 in its current form.

Ultimately, a DeviceTree property (or node) will be added to encode the
behaviour of the timers, but until then revert the addition of
CLOCK_EVT_FEAT_C3STOP.

Link: https://lore.kernel.org/linux-riscv/YzYTNQRxLr7Q9JR0@spud/
Link: riscv-non-isa/riscv-sbi-doc#98
Link: https://lore.kernel.org/linux-riscv/bf6d3b1f-f703-4a25-833e-972a44a04114@sholland.org/
Fixes: 232ccac ("clocksource/drivers/riscv: Events are stopped during CPU suspend")
CC: Samuel Holland <samuel@sholland.org>
CC: Anup Patel <anup@brainfault.org>
CC: Palmer Dabbelt <palmer@dabbelt.com>
Reviewed-by: Palmer Dabbelt <palmer@rivosinc.com>
Acked-by: Palmer Dabbelt <palmer@rivosinc.com>
Acked-by: Samuel Holland <samuel@sholland.org>
Signed-off-by: Conor Dooley <conor.dooley@microchip.com>
Signed-off-by: Anup Patel <apatel@ventanamicro.com>
intel-lab-lkp pushed a commit to intel-lab-lkp/linux that referenced this issue Nov 25, 2022
…end"

This reverts commit 232ccac.

On the subject of suspend, the RISC-V SBI spec states:
> Request the SBI implementation to put the calling hart in a platform
> specific suspend (or low power) state specified by the suspend_type
> parameter. The hart will automatically come out of suspended state and
> resume normal execution when it receives an interrupt or platform
> specific hardware event.

This does not cover whether any given events actually reach the hart or
not, just what the hart will do if it receives an event. On PolarFire
SoC, and potentially other SiFive based implementations, events from the
RISC-V timer do reach a hart during suspend. This is not the case for
the implementation on the Allwinner D1 - there timer events are not
received during suspend.

To fix this, the C3STOP feature was enabled for the timer driver -
but this has broken both RCU stall detection and timers generally on
PolarFire SoC (and potentially other SiFive based implementations).

If an AXI read to the PCIe controller on PolarFire SoC times out, the
system will stall, however, with this patch applied, the system just
locks up without RCU stalling:
	io scheduler mq-deadline registered
	io scheduler kyber registered
	microchip-pcie 2000000000.pcie: host bridge /soc/pcie@2000000000 ranges:
	microchip-pcie 2000000000.pcie:      MEM 0x2008000000..0x2087ffffff -> 0x0008000000
	microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: axi read request error
	microchip-pcie 2000000000.pcie: axi read timeout
	microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer
	Freeing initrd memory: 7332K

Similarly issues were reported with clock_nanosleep() - with a test app
that sleeps each cpu for 6, 5, 4, 3 ms respectively, HZ=250 & the blamed
commit in place, the sleep times are rounded up to the next jiffy:

== CPU: 1 ==      == CPU: 2 ==      == CPU: 3 ==      == CPU: 4 ==
Mean: 7.974992    Mean: 7.976534    Mean: 7.962591    Mean: 3.952179
Std Dev: 0.154374 Std Dev: 0.156082 Std Dev: 0.171018 Std Dev: 0.076193
Hi: 9.472000      Hi: 10.495000     Hi: 8.864000      Hi: 4.736000
Lo: 6.087000      Lo: 6.380000      Lo: 4.872000      Lo: 3.403000
Samples: 521      Samples: 521      Samples: 521      Samples: 521

Fortunately, the D1 has a second timer, which is "currently used in
preference to the RISC-V/SBI timer driver" so a revert here does not
hurt operation of D1 in its current form.

Ultimately, a DeviceTree property (or node) will be added to encode the
behaviour of the timers, but until then revert the addition of
CLOCK_EVT_FEAT_C3STOP.

Link: https://lore.kernel.org/linux-riscv/YzYTNQRxLr7Q9JR0@spud/
Link: riscv-non-isa/riscv-sbi-doc#98
Link: https://lore.kernel.org/linux-riscv/bf6d3b1f-f703-4a25-833e-972a44a04114@sholland.org/
Fixes: 232ccac ("clocksource/drivers/riscv: Events are stopped during CPU suspend")
CC: Samuel Holland <samuel@sholland.org>
CC: Anup Patel <anup@brainfault.org>
CC: Palmer Dabbelt <palmer@dabbelt.com>
Reviewed-by: Palmer Dabbelt <palmer@rivosinc.com>
Acked-by: Palmer Dabbelt <palmer@rivosinc.com>
Acked-by: Samuel Holland <samuel@sholland.org>
Signed-off-by: Conor Dooley <conor.dooley@microchip.com>
Signed-off-by: Anup Patel <apatel@ventanamicro.com>
ammarfaizi2 pushed a commit to ammarfaizi2/linux-block that referenced this issue Dec 1, 2022
…end"

This reverts commit 232ccac.

On the subject of suspend, the RISC-V SBI spec states:

  This does not cover whether any given events actually reach the hart or
  not, just what the hart will do if it receives an event. On PolarFire
  SoC, and potentially other SiFive based implementations, events from the
  RISC-V timer do reach a hart during suspend. This is not the case for the
  implementation on the Allwinner D1 - there timer events are not received
  during suspend.

To fix this, the CLOCK_EVT_FEAT_C3STOP (mis)feature was enabled for the
timer driver - but this has broken both RCU stall detection and timers
generally on PolarFire SoC and potentially other SiFive based
implementations.

If an AXI read to the PCIe controller on PolarFire SoC times out, the
system will stall, however, with CLOCK_EVT_FEAT_C3STOP active, the system
just locks up without RCU stalling:

	io scheduler mq-deadline registered
	io scheduler kyber registered
	microchip-pcie 2000000000.pcie: host bridge /soc/pcie@2000000000 ranges:
	microchip-pcie 2000000000.pcie:      MEM 0x2008000000..0x2087ffffff -> 0x0008000000
	microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: axi read request error
	microchip-pcie 2000000000.pcie: axi read timeout
	microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer
	Freeing initrd memory: 7332K

Similarly issues were reported with clock_nanosleep() - with a test app
that sleeps each cpu for 6, 5, 4, 3 ms respectively, HZ=250 & the blamed
commit in place, the sleep times are rounded up to the next jiffy:

== CPU: 1 ==      == CPU: 2 ==      == CPU: 3 ==      == CPU: 4 ==
Mean: 7.974992    Mean: 7.976534    Mean: 7.962591    Mean: 3.952179
Std Dev: 0.154374 Std Dev: 0.156082 Std Dev: 0.171018 Std Dev: 0.076193
Hi: 9.472000      Hi: 10.495000     Hi: 8.864000      Hi: 4.736000
Lo: 6.087000      Lo: 6.380000      Lo: 4.872000      Lo: 3.403000
Samples: 521      Samples: 521      Samples: 521      Samples: 521

Fortunately, the D1 has a second timer, which is "currently used in
preference to the RISC-V/SBI timer driver" so a revert here does not
hurt operation of D1 in its current form.

Ultimately, a DeviceTree property (or node) will be added to encode the
behaviour of the timers, but until then revert the addition of
CLOCK_EVT_FEAT_C3STOP.

Fixes: 232ccac ("clocksource/drivers/riscv: Events are stopped during CPU suspend")
Signed-off-by: Conor Dooley <conor.dooley@microchip.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Palmer Dabbelt <palmer@rivosinc.com>
Acked-by: Palmer Dabbelt <palmer@rivosinc.com>
Acked-by: Samuel Holland <samuel@sholland.org>
Link: https://lore.kernel.org/linux-riscv/YzYTNQRxLr7Q9JR0@spud/
Link: riscv-non-isa/riscv-sbi-doc#98
Link: https://lore.kernel.org/linux-riscv/bf6d3b1f-f703-4a25-833e-972a44a04114@sholland.org/
Link: https://lore.kernel.org/r/20221122121620.3522431-1-conor.dooley@microchip.com
ammarfaizi2 pushed a commit to ammarfaizi2/linux-block that referenced this issue Dec 5, 2022
…end"

[ Upstream commit d9f15a9 ]

This reverts commit 232ccac.

On the subject of suspend, the RISC-V SBI spec states:

  This does not cover whether any given events actually reach the hart or
  not, just what the hart will do if it receives an event. On PolarFire
  SoC, and potentially other SiFive based implementations, events from the
  RISC-V timer do reach a hart during suspend. This is not the case for the
  implementation on the Allwinner D1 - there timer events are not received
  during suspend.

To fix this, the CLOCK_EVT_FEAT_C3STOP (mis)feature was enabled for the
timer driver - but this has broken both RCU stall detection and timers
generally on PolarFire SoC and potentially other SiFive based
implementations.

If an AXI read to the PCIe controller on PolarFire SoC times out, the
system will stall, however, with CLOCK_EVT_FEAT_C3STOP active, the system
just locks up without RCU stalling:

	io scheduler mq-deadline registered
	io scheduler kyber registered
	microchip-pcie 2000000000.pcie: host bridge /soc/pcie@2000000000 ranges:
	microchip-pcie 2000000000.pcie:      MEM 0x2008000000..0x2087ffffff -> 0x0008000000
	microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: axi read request error
	microchip-pcie 2000000000.pcie: axi read timeout
	microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer
	Freeing initrd memory: 7332K

Similarly issues were reported with clock_nanosleep() - with a test app
that sleeps each cpu for 6, 5, 4, 3 ms respectively, HZ=250 & the blamed
commit in place, the sleep times are rounded up to the next jiffy:

== CPU: 1 ==      == CPU: 2 ==      == CPU: 3 ==      == CPU: 4 ==
Mean: 7.974992    Mean: 7.976534    Mean: 7.962591    Mean: 3.952179
Std Dev: 0.154374 Std Dev: 0.156082 Std Dev: 0.171018 Std Dev: 0.076193
Hi: 9.472000      Hi: 10.495000     Hi: 8.864000      Hi: 4.736000
Lo: 6.087000      Lo: 6.380000      Lo: 4.872000      Lo: 3.403000
Samples: 521      Samples: 521      Samples: 521      Samples: 521

Fortunately, the D1 has a second timer, which is "currently used in
preference to the RISC-V/SBI timer driver" so a revert here does not
hurt operation of D1 in its current form.

Ultimately, a DeviceTree property (or node) will be added to encode the
behaviour of the timers, but until then revert the addition of
CLOCK_EVT_FEAT_C3STOP.

Fixes: 232ccac ("clocksource/drivers/riscv: Events are stopped during CPU suspend")
Signed-off-by: Conor Dooley <conor.dooley@microchip.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Palmer Dabbelt <palmer@rivosinc.com>
Acked-by: Palmer Dabbelt <palmer@rivosinc.com>
Acked-by: Samuel Holland <samuel@sholland.org>
Link: https://lore.kernel.org/linux-riscv/YzYTNQRxLr7Q9JR0@spud/
Link: riscv-non-isa/riscv-sbi-doc#98
Link: https://lore.kernel.org/linux-riscv/bf6d3b1f-f703-4a25-833e-972a44a04114@sholland.org/
Link: https://lore.kernel.org/r/20221122121620.3522431-1-conor.dooley@microchip.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
ammarfaizi2 pushed a commit to ammarfaizi2/linux-fork that referenced this issue Dec 8, 2022
…end"

[ Upstream commit d9f15a9 ]

This reverts commit 232ccac.

On the subject of suspend, the RISC-V SBI spec states:

  This does not cover whether any given events actually reach the hart or
  not, just what the hart will do if it receives an event. On PolarFire
  SoC, and potentially other SiFive based implementations, events from the
  RISC-V timer do reach a hart during suspend. This is not the case for the
  implementation on the Allwinner D1 - there timer events are not received
  during suspend.

To fix this, the CLOCK_EVT_FEAT_C3STOP (mis)feature was enabled for the
timer driver - but this has broken both RCU stall detection and timers
generally on PolarFire SoC and potentially other SiFive based
implementations.

If an AXI read to the PCIe controller on PolarFire SoC times out, the
system will stall, however, with CLOCK_EVT_FEAT_C3STOP active, the system
just locks up without RCU stalling:

	io scheduler mq-deadline registered
	io scheduler kyber registered
	microchip-pcie 2000000000.pcie: host bridge /soc/pcie@2000000000 ranges:
	microchip-pcie 2000000000.pcie:      MEM 0x2008000000..0x2087ffffff -> 0x0008000000
	microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: axi read request error
	microchip-pcie 2000000000.pcie: axi read timeout
	microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer
	Freeing initrd memory: 7332K

Similarly issues were reported with clock_nanosleep() - with a test app
that sleeps each cpu for 6, 5, 4, 3 ms respectively, HZ=250 & the blamed
commit in place, the sleep times are rounded up to the next jiffy:

== CPU: 1 ==      == CPU: 2 ==      == CPU: 3 ==      == CPU: 4 ==
Mean: 7.974992    Mean: 7.976534    Mean: 7.962591    Mean: 3.952179
Std Dev: 0.154374 Std Dev: 0.156082 Std Dev: 0.171018 Std Dev: 0.076193
Hi: 9.472000      Hi: 10.495000     Hi: 8.864000      Hi: 4.736000
Lo: 6.087000      Lo: 6.380000      Lo: 4.872000      Lo: 3.403000
Samples: 521      Samples: 521      Samples: 521      Samples: 521

Fortunately, the D1 has a second timer, which is "currently used in
preference to the RISC-V/SBI timer driver" so a revert here does not
hurt operation of D1 in its current form.

Ultimately, a DeviceTree property (or node) will be added to encode the
behaviour of the timers, but until then revert the addition of
CLOCK_EVT_FEAT_C3STOP.

Fixes: 232ccac ("clocksource/drivers/riscv: Events are stopped during CPU suspend")
Signed-off-by: Conor Dooley <conor.dooley@microchip.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Palmer Dabbelt <palmer@rivosinc.com>
Acked-by: Palmer Dabbelt <palmer@rivosinc.com>
Acked-by: Samuel Holland <samuel@sholland.org>
Link: https://lore.kernel.org/linux-riscv/YzYTNQRxLr7Q9JR0@spud/
Link: riscv-non-isa/riscv-sbi-doc#98
Link: https://lore.kernel.org/linux-riscv/bf6d3b1f-f703-4a25-833e-972a44a04114@sholland.org/
Link: https://lore.kernel.org/r/20221122121620.3522431-1-conor.dooley@microchip.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
ammarfaizi2 pushed a commit to ammarfaizi2/linux-fork that referenced this issue Dec 8, 2022
…end"

[ Upstream commit d9f15a9 ]

This reverts commit 232ccac.

On the subject of suspend, the RISC-V SBI spec states:

  This does not cover whether any given events actually reach the hart or
  not, just what the hart will do if it receives an event. On PolarFire
  SoC, and potentially other SiFive based implementations, events from the
  RISC-V timer do reach a hart during suspend. This is not the case for the
  implementation on the Allwinner D1 - there timer events are not received
  during suspend.

To fix this, the CLOCK_EVT_FEAT_C3STOP (mis)feature was enabled for the
timer driver - but this has broken both RCU stall detection and timers
generally on PolarFire SoC and potentially other SiFive based
implementations.

If an AXI read to the PCIe controller on PolarFire SoC times out, the
system will stall, however, with CLOCK_EVT_FEAT_C3STOP active, the system
just locks up without RCU stalling:

	io scheduler mq-deadline registered
	io scheduler kyber registered
	microchip-pcie 2000000000.pcie: host bridge /soc/pcie@2000000000 ranges:
	microchip-pcie 2000000000.pcie:      MEM 0x2008000000..0x2087ffffff -> 0x0008000000
	microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: axi read request error
	microchip-pcie 2000000000.pcie: axi read timeout
	microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer
	Freeing initrd memory: 7332K

Similarly issues were reported with clock_nanosleep() - with a test app
that sleeps each cpu for 6, 5, 4, 3 ms respectively, HZ=250 & the blamed
commit in place, the sleep times are rounded up to the next jiffy:

== CPU: 1 ==      == CPU: 2 ==      == CPU: 3 ==      == CPU: 4 ==
Mean: 7.974992    Mean: 7.976534    Mean: 7.962591    Mean: 3.952179
Std Dev: 0.154374 Std Dev: 0.156082 Std Dev: 0.171018 Std Dev: 0.076193
Hi: 9.472000      Hi: 10.495000     Hi: 8.864000      Hi: 4.736000
Lo: 6.087000      Lo: 6.380000      Lo: 4.872000      Lo: 3.403000
Samples: 521      Samples: 521      Samples: 521      Samples: 521

Fortunately, the D1 has a second timer, which is "currently used in
preference to the RISC-V/SBI timer driver" so a revert here does not
hurt operation of D1 in its current form.

Ultimately, a DeviceTree property (or node) will be added to encode the
behaviour of the timers, but until then revert the addition of
CLOCK_EVT_FEAT_C3STOP.

Fixes: 232ccac ("clocksource/drivers/riscv: Events are stopped during CPU suspend")
Signed-off-by: Conor Dooley <conor.dooley@microchip.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Palmer Dabbelt <palmer@rivosinc.com>
Acked-by: Palmer Dabbelt <palmer@rivosinc.com>
Acked-by: Samuel Holland <samuel@sholland.org>
Link: https://lore.kernel.org/linux-riscv/YzYTNQRxLr7Q9JR0@spud/
Link: riscv-non-isa/riscv-sbi-doc#98
Link: https://lore.kernel.org/linux-riscv/bf6d3b1f-f703-4a25-833e-972a44a04114@sholland.org/
Link: https://lore.kernel.org/r/20221122121620.3522431-1-conor.dooley@microchip.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
ammarfaizi2 pushed a commit to ammarfaizi2/linux-fork that referenced this issue Dec 8, 2022
…end"

[ Upstream commit d9f15a9 ]

This reverts commit 232ccac.

On the subject of suspend, the RISC-V SBI spec states:

  This does not cover whether any given events actually reach the hart or
  not, just what the hart will do if it receives an event. On PolarFire
  SoC, and potentially other SiFive based implementations, events from the
  RISC-V timer do reach a hart during suspend. This is not the case for the
  implementation on the Allwinner D1 - there timer events are not received
  during suspend.

To fix this, the CLOCK_EVT_FEAT_C3STOP (mis)feature was enabled for the
timer driver - but this has broken both RCU stall detection and timers
generally on PolarFire SoC and potentially other SiFive based
implementations.

If an AXI read to the PCIe controller on PolarFire SoC times out, the
system will stall, however, with CLOCK_EVT_FEAT_C3STOP active, the system
just locks up without RCU stalling:

	io scheduler mq-deadline registered
	io scheduler kyber registered
	microchip-pcie 2000000000.pcie: host bridge /soc/pcie@2000000000 ranges:
	microchip-pcie 2000000000.pcie:      MEM 0x2008000000..0x2087ffffff -> 0x0008000000
	microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: axi read request error
	microchip-pcie 2000000000.pcie: axi read timeout
	microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer
	Freeing initrd memory: 7332K

Similarly issues were reported with clock_nanosleep() - with a test app
that sleeps each cpu for 6, 5, 4, 3 ms respectively, HZ=250 & the blamed
commit in place, the sleep times are rounded up to the next jiffy:

== CPU: 1 ==      == CPU: 2 ==      == CPU: 3 ==      == CPU: 4 ==
Mean: 7.974992    Mean: 7.976534    Mean: 7.962591    Mean: 3.952179
Std Dev: 0.154374 Std Dev: 0.156082 Std Dev: 0.171018 Std Dev: 0.076193
Hi: 9.472000      Hi: 10.495000     Hi: 8.864000      Hi: 4.736000
Lo: 6.087000      Lo: 6.380000      Lo: 4.872000      Lo: 3.403000
Samples: 521      Samples: 521      Samples: 521      Samples: 521

Fortunately, the D1 has a second timer, which is "currently used in
preference to the RISC-V/SBI timer driver" so a revert here does not
hurt operation of D1 in its current form.

Ultimately, a DeviceTree property (or node) will be added to encode the
behaviour of the timers, but until then revert the addition of
CLOCK_EVT_FEAT_C3STOP.

Fixes: 232ccac ("clocksource/drivers/riscv: Events are stopped during CPU suspend")
Signed-off-by: Conor Dooley <conor.dooley@microchip.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Palmer Dabbelt <palmer@rivosinc.com>
Acked-by: Palmer Dabbelt <palmer@rivosinc.com>
Acked-by: Samuel Holland <samuel@sholland.org>
Link: https://lore.kernel.org/linux-riscv/YzYTNQRxLr7Q9JR0@spud/
Link: riscv-non-isa/riscv-sbi-doc#98
Link: https://lore.kernel.org/linux-riscv/bf6d3b1f-f703-4a25-833e-972a44a04114@sholland.org/
Link: https://lore.kernel.org/r/20221122121620.3522431-1-conor.dooley@microchip.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
ammarfaizi2 pushed a commit to ammarfaizi2/linux-fork that referenced this issue Dec 8, 2022
…end"

[ Upstream commit d9f15a9 ]

This reverts commit 232ccac.

On the subject of suspend, the RISC-V SBI spec states:

  This does not cover whether any given events actually reach the hart or
  not, just what the hart will do if it receives an event. On PolarFire
  SoC, and potentially other SiFive based implementations, events from the
  RISC-V timer do reach a hart during suspend. This is not the case for the
  implementation on the Allwinner D1 - there timer events are not received
  during suspend.

To fix this, the CLOCK_EVT_FEAT_C3STOP (mis)feature was enabled for the
timer driver - but this has broken both RCU stall detection and timers
generally on PolarFire SoC and potentially other SiFive based
implementations.

If an AXI read to the PCIe controller on PolarFire SoC times out, the
system will stall, however, with CLOCK_EVT_FEAT_C3STOP active, the system
just locks up without RCU stalling:

	io scheduler mq-deadline registered
	io scheduler kyber registered
	microchip-pcie 2000000000.pcie: host bridge /soc/pcie@2000000000 ranges:
	microchip-pcie 2000000000.pcie:      MEM 0x2008000000..0x2087ffffff -> 0x0008000000
	microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: axi read request error
	microchip-pcie 2000000000.pcie: axi read timeout
	microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer
	Freeing initrd memory: 7332K

Similarly issues were reported with clock_nanosleep() - with a test app
that sleeps each cpu for 6, 5, 4, 3 ms respectively, HZ=250 & the blamed
commit in place, the sleep times are rounded up to the next jiffy:

== CPU: 1 ==      == CPU: 2 ==      == CPU: 3 ==      == CPU: 4 ==
Mean: 7.974992    Mean: 7.976534    Mean: 7.962591    Mean: 3.952179
Std Dev: 0.154374 Std Dev: 0.156082 Std Dev: 0.171018 Std Dev: 0.076193
Hi: 9.472000      Hi: 10.495000     Hi: 8.864000      Hi: 4.736000
Lo: 6.087000      Lo: 6.380000      Lo: 4.872000      Lo: 3.403000
Samples: 521      Samples: 521      Samples: 521      Samples: 521

Fortunately, the D1 has a second timer, which is "currently used in
preference to the RISC-V/SBI timer driver" so a revert here does not
hurt operation of D1 in its current form.

Ultimately, a DeviceTree property (or node) will be added to encode the
behaviour of the timers, but until then revert the addition of
CLOCK_EVT_FEAT_C3STOP.

Fixes: 232ccac ("clocksource/drivers/riscv: Events are stopped during CPU suspend")
Signed-off-by: Conor Dooley <conor.dooley@microchip.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Palmer Dabbelt <palmer@rivosinc.com>
Acked-by: Palmer Dabbelt <palmer@rivosinc.com>
Acked-by: Samuel Holland <samuel@sholland.org>
Link: https://lore.kernel.org/linux-riscv/YzYTNQRxLr7Q9JR0@spud/
Link: riscv-non-isa/riscv-sbi-doc#98
Link: https://lore.kernel.org/linux-riscv/bf6d3b1f-f703-4a25-833e-972a44a04114@sholland.org/
Link: https://lore.kernel.org/r/20221122121620.3522431-1-conor.dooley@microchip.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
Whissi pushed a commit to Whissi/linux-stable that referenced this issue Dec 8, 2022
…end"

[ Upstream commit d9f15a9 ]

This reverts commit 232ccac.

On the subject of suspend, the RISC-V SBI spec states:

  This does not cover whether any given events actually reach the hart or
  not, just what the hart will do if it receives an event. On PolarFire
  SoC, and potentially other SiFive based implementations, events from the
  RISC-V timer do reach a hart during suspend. This is not the case for the
  implementation on the Allwinner D1 - there timer events are not received
  during suspend.

To fix this, the CLOCK_EVT_FEAT_C3STOP (mis)feature was enabled for the
timer driver - but this has broken both RCU stall detection and timers
generally on PolarFire SoC and potentially other SiFive based
implementations.

If an AXI read to the PCIe controller on PolarFire SoC times out, the
system will stall, however, with CLOCK_EVT_FEAT_C3STOP active, the system
just locks up without RCU stalling:

	io scheduler mq-deadline registered
	io scheduler kyber registered
	microchip-pcie 2000000000.pcie: host bridge /soc/pcie@2000000000 ranges:
	microchip-pcie 2000000000.pcie:      MEM 0x2008000000..0x2087ffffff -> 0x0008000000
	microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: axi read request error
	microchip-pcie 2000000000.pcie: axi read timeout
	microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer
	Freeing initrd memory: 7332K

Similarly issues were reported with clock_nanosleep() - with a test app
that sleeps each cpu for 6, 5, 4, 3 ms respectively, HZ=250 & the blamed
commit in place, the sleep times are rounded up to the next jiffy:

== CPU: 1 ==      == CPU: 2 ==      == CPU: 3 ==      == CPU: 4 ==
Mean: 7.974992    Mean: 7.976534    Mean: 7.962591    Mean: 3.952179
Std Dev: 0.154374 Std Dev: 0.156082 Std Dev: 0.171018 Std Dev: 0.076193
Hi: 9.472000      Hi: 10.495000     Hi: 8.864000      Hi: 4.736000
Lo: 6.087000      Lo: 6.380000      Lo: 4.872000      Lo: 3.403000
Samples: 521      Samples: 521      Samples: 521      Samples: 521

Fortunately, the D1 has a second timer, which is "currently used in
preference to the RISC-V/SBI timer driver" so a revert here does not
hurt operation of D1 in its current form.

Ultimately, a DeviceTree property (or node) will be added to encode the
behaviour of the timers, but until then revert the addition of
CLOCK_EVT_FEAT_C3STOP.

Fixes: 232ccac ("clocksource/drivers/riscv: Events are stopped during CPU suspend")
Signed-off-by: Conor Dooley <conor.dooley@microchip.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Palmer Dabbelt <palmer@rivosinc.com>
Acked-by: Palmer Dabbelt <palmer@rivosinc.com>
Acked-by: Samuel Holland <samuel@sholland.org>
Link: https://lore.kernel.org/linux-riscv/YzYTNQRxLr7Q9JR0@spud/
Link: riscv-non-isa/riscv-sbi-doc#98
Link: https://lore.kernel.org/linux-riscv/bf6d3b1f-f703-4a25-833e-972a44a04114@sholland.org/
Link: https://lore.kernel.org/r/20221122121620.3522431-1-conor.dooley@microchip.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
Whissi pushed a commit to Whissi/linux-stable that referenced this issue Dec 8, 2022
…end"

[ Upstream commit d9f15a9 ]

This reverts commit 232ccac.

On the subject of suspend, the RISC-V SBI spec states:

  This does not cover whether any given events actually reach the hart or
  not, just what the hart will do if it receives an event. On PolarFire
  SoC, and potentially other SiFive based implementations, events from the
  RISC-V timer do reach a hart during suspend. This is not the case for the
  implementation on the Allwinner D1 - there timer events are not received
  during suspend.

To fix this, the CLOCK_EVT_FEAT_C3STOP (mis)feature was enabled for the
timer driver - but this has broken both RCU stall detection and timers
generally on PolarFire SoC and potentially other SiFive based
implementations.

If an AXI read to the PCIe controller on PolarFire SoC times out, the
system will stall, however, with CLOCK_EVT_FEAT_C3STOP active, the system
just locks up without RCU stalling:

	io scheduler mq-deadline registered
	io scheduler kyber registered
	microchip-pcie 2000000000.pcie: host bridge /soc/pcie@2000000000 ranges:
	microchip-pcie 2000000000.pcie:      MEM 0x2008000000..0x2087ffffff -> 0x0008000000
	microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: axi read request error
	microchip-pcie 2000000000.pcie: axi read timeout
	microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer
	Freeing initrd memory: 7332K

Similarly issues were reported with clock_nanosleep() - with a test app
that sleeps each cpu for 6, 5, 4, 3 ms respectively, HZ=250 & the blamed
commit in place, the sleep times are rounded up to the next jiffy:

== CPU: 1 ==      == CPU: 2 ==      == CPU: 3 ==      == CPU: 4 ==
Mean: 7.974992    Mean: 7.976534    Mean: 7.962591    Mean: 3.952179
Std Dev: 0.154374 Std Dev: 0.156082 Std Dev: 0.171018 Std Dev: 0.076193
Hi: 9.472000      Hi: 10.495000     Hi: 8.864000      Hi: 4.736000
Lo: 6.087000      Lo: 6.380000      Lo: 4.872000      Lo: 3.403000
Samples: 521      Samples: 521      Samples: 521      Samples: 521

Fortunately, the D1 has a second timer, which is "currently used in
preference to the RISC-V/SBI timer driver" so a revert here does not
hurt operation of D1 in its current form.

Ultimately, a DeviceTree property (or node) will be added to encode the
behaviour of the timers, but until then revert the addition of
CLOCK_EVT_FEAT_C3STOP.

Fixes: 232ccac ("clocksource/drivers/riscv: Events are stopped during CPU suspend")
Signed-off-by: Conor Dooley <conor.dooley@microchip.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Palmer Dabbelt <palmer@rivosinc.com>
Acked-by: Palmer Dabbelt <palmer@rivosinc.com>
Acked-by: Samuel Holland <samuel@sholland.org>
Link: https://lore.kernel.org/linux-riscv/YzYTNQRxLr7Q9JR0@spud/
Link: riscv-non-isa/riscv-sbi-doc#98
Link: https://lore.kernel.org/linux-riscv/bf6d3b1f-f703-4a25-833e-972a44a04114@sholland.org/
Link: https://lore.kernel.org/r/20221122121620.3522431-1-conor.dooley@microchip.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
ammarfaizi2 pushed a commit to ammarfaizi2/linux-fork that referenced this issue Dec 8, 2022
…end"

[ Upstream commit d9f15a9 ]

This reverts commit 232ccac.

On the subject of suspend, the RISC-V SBI spec states:

  This does not cover whether any given events actually reach the hart or
  not, just what the hart will do if it receives an event. On PolarFire
  SoC, and potentially other SiFive based implementations, events from the
  RISC-V timer do reach a hart during suspend. This is not the case for the
  implementation on the Allwinner D1 - there timer events are not received
  during suspend.

To fix this, the CLOCK_EVT_FEAT_C3STOP (mis)feature was enabled for the
timer driver - but this has broken both RCU stall detection and timers
generally on PolarFire SoC and potentially other SiFive based
implementations.

If an AXI read to the PCIe controller on PolarFire SoC times out, the
system will stall, however, with CLOCK_EVT_FEAT_C3STOP active, the system
just locks up without RCU stalling:

	io scheduler mq-deadline registered
	io scheduler kyber registered
	microchip-pcie 2000000000.pcie: host bridge /soc/pcie@2000000000 ranges:
	microchip-pcie 2000000000.pcie:      MEM 0x2008000000..0x2087ffffff -> 0x0008000000
	microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: axi read request error
	microchip-pcie 2000000000.pcie: axi read timeout
	microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer
	Freeing initrd memory: 7332K

Similarly issues were reported with clock_nanosleep() - with a test app
that sleeps each cpu for 6, 5, 4, 3 ms respectively, HZ=250 & the blamed
commit in place, the sleep times are rounded up to the next jiffy:

== CPU: 1 ==      == CPU: 2 ==      == CPU: 3 ==      == CPU: 4 ==
Mean: 7.974992    Mean: 7.976534    Mean: 7.962591    Mean: 3.952179
Std Dev: 0.154374 Std Dev: 0.156082 Std Dev: 0.171018 Std Dev: 0.076193
Hi: 9.472000      Hi: 10.495000     Hi: 8.864000      Hi: 4.736000
Lo: 6.087000      Lo: 6.380000      Lo: 4.872000      Lo: 3.403000
Samples: 521      Samples: 521      Samples: 521      Samples: 521

Fortunately, the D1 has a second timer, which is "currently used in
preference to the RISC-V/SBI timer driver" so a revert here does not
hurt operation of D1 in its current form.

Ultimately, a DeviceTree property (or node) will be added to encode the
behaviour of the timers, but until then revert the addition of
CLOCK_EVT_FEAT_C3STOP.

Fixes: 232ccac ("clocksource/drivers/riscv: Events are stopped during CPU suspend")
Signed-off-by: Conor Dooley <conor.dooley@microchip.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Palmer Dabbelt <palmer@rivosinc.com>
Acked-by: Palmer Dabbelt <palmer@rivosinc.com>
Acked-by: Samuel Holland <samuel@sholland.org>
Link: https://lore.kernel.org/linux-riscv/YzYTNQRxLr7Q9JR0@spud/
Link: riscv-non-isa/riscv-sbi-doc#98
Link: https://lore.kernel.org/linux-riscv/bf6d3b1f-f703-4a25-833e-972a44a04114@sholland.org/
Link: https://lore.kernel.org/r/20221122121620.3522431-1-conor.dooley@microchip.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
ammarfaizi2 pushed a commit to ammarfaizi2/linux-fork that referenced this issue Dec 8, 2022
…end"

[ Upstream commit d9f15a9 ]

This reverts commit 232ccac.

On the subject of suspend, the RISC-V SBI spec states:

  This does not cover whether any given events actually reach the hart or
  not, just what the hart will do if it receives an event. On PolarFire
  SoC, and potentially other SiFive based implementations, events from the
  RISC-V timer do reach a hart during suspend. This is not the case for the
  implementation on the Allwinner D1 - there timer events are not received
  during suspend.

To fix this, the CLOCK_EVT_FEAT_C3STOP (mis)feature was enabled for the
timer driver - but this has broken both RCU stall detection and timers
generally on PolarFire SoC and potentially other SiFive based
implementations.

If an AXI read to the PCIe controller on PolarFire SoC times out, the
system will stall, however, with CLOCK_EVT_FEAT_C3STOP active, the system
just locks up without RCU stalling:

	io scheduler mq-deadline registered
	io scheduler kyber registered
	microchip-pcie 2000000000.pcie: host bridge /soc/pcie@2000000000 ranges:
	microchip-pcie 2000000000.pcie:      MEM 0x2008000000..0x2087ffffff -> 0x0008000000
	microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: axi read request error
	microchip-pcie 2000000000.pcie: axi read timeout
	microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer
	Freeing initrd memory: 7332K

Similarly issues were reported with clock_nanosleep() - with a test app
that sleeps each cpu for 6, 5, 4, 3 ms respectively, HZ=250 & the blamed
commit in place, the sleep times are rounded up to the next jiffy:

== CPU: 1 ==      == CPU: 2 ==      == CPU: 3 ==      == CPU: 4 ==
Mean: 7.974992    Mean: 7.976534    Mean: 7.962591    Mean: 3.952179
Std Dev: 0.154374 Std Dev: 0.156082 Std Dev: 0.171018 Std Dev: 0.076193
Hi: 9.472000      Hi: 10.495000     Hi: 8.864000      Hi: 4.736000
Lo: 6.087000      Lo: 6.380000      Lo: 4.872000      Lo: 3.403000
Samples: 521      Samples: 521      Samples: 521      Samples: 521

Fortunately, the D1 has a second timer, which is "currently used in
preference to the RISC-V/SBI timer driver" so a revert here does not
hurt operation of D1 in its current form.

Ultimately, a DeviceTree property (or node) will be added to encode the
behaviour of the timers, but until then revert the addition of
CLOCK_EVT_FEAT_C3STOP.

Fixes: 232ccac ("clocksource/drivers/riscv: Events are stopped during CPU suspend")
Signed-off-by: Conor Dooley <conor.dooley@microchip.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Palmer Dabbelt <palmer@rivosinc.com>
Acked-by: Palmer Dabbelt <palmer@rivosinc.com>
Acked-by: Samuel Holland <samuel@sholland.org>
Link: https://lore.kernel.org/linux-riscv/YzYTNQRxLr7Q9JR0@spud/
Link: riscv-non-isa/riscv-sbi-doc#98
Link: https://lore.kernel.org/linux-riscv/bf6d3b1f-f703-4a25-833e-972a44a04114@sholland.org/
Link: https://lore.kernel.org/r/20221122121620.3522431-1-conor.dooley@microchip.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
ammarfaizi2 pushed a commit to ammarfaizi2/linux-fork that referenced this issue Dec 8, 2022
…end"

[ Upstream commit d9f15a9 ]

This reverts commit 232ccac.

On the subject of suspend, the RISC-V SBI spec states:

  This does not cover whether any given events actually reach the hart or
  not, just what the hart will do if it receives an event. On PolarFire
  SoC, and potentially other SiFive based implementations, events from the
  RISC-V timer do reach a hart during suspend. This is not the case for the
  implementation on the Allwinner D1 - there timer events are not received
  during suspend.

To fix this, the CLOCK_EVT_FEAT_C3STOP (mis)feature was enabled for the
timer driver - but this has broken both RCU stall detection and timers
generally on PolarFire SoC and potentially other SiFive based
implementations.

If an AXI read to the PCIe controller on PolarFire SoC times out, the
system will stall, however, with CLOCK_EVT_FEAT_C3STOP active, the system
just locks up without RCU stalling:

	io scheduler mq-deadline registered
	io scheduler kyber registered
	microchip-pcie 2000000000.pcie: host bridge /soc/pcie@2000000000 ranges:
	microchip-pcie 2000000000.pcie:      MEM 0x2008000000..0x2087ffffff -> 0x0008000000
	microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: axi read request error
	microchip-pcie 2000000000.pcie: axi read timeout
	microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer
	Freeing initrd memory: 7332K

Similarly issues were reported with clock_nanosleep() - with a test app
that sleeps each cpu for 6, 5, 4, 3 ms respectively, HZ=250 & the blamed
commit in place, the sleep times are rounded up to the next jiffy:

== CPU: 1 ==      == CPU: 2 ==      == CPU: 3 ==      == CPU: 4 ==
Mean: 7.974992    Mean: 7.976534    Mean: 7.962591    Mean: 3.952179
Std Dev: 0.154374 Std Dev: 0.156082 Std Dev: 0.171018 Std Dev: 0.076193
Hi: 9.472000      Hi: 10.495000     Hi: 8.864000      Hi: 4.736000
Lo: 6.087000      Lo: 6.380000      Lo: 4.872000      Lo: 3.403000
Samples: 521      Samples: 521      Samples: 521      Samples: 521

Fortunately, the D1 has a second timer, which is "currently used in
preference to the RISC-V/SBI timer driver" so a revert here does not
hurt operation of D1 in its current form.

Ultimately, a DeviceTree property (or node) will be added to encode the
behaviour of the timers, but until then revert the addition of
CLOCK_EVT_FEAT_C3STOP.

Fixes: 232ccac ("clocksource/drivers/riscv: Events are stopped during CPU suspend")
Signed-off-by: Conor Dooley <conor.dooley@microchip.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Palmer Dabbelt <palmer@rivosinc.com>
Acked-by: Palmer Dabbelt <palmer@rivosinc.com>
Acked-by: Samuel Holland <samuel@sholland.org>
Link: https://lore.kernel.org/linux-riscv/YzYTNQRxLr7Q9JR0@spud/
Link: riscv-non-isa/riscv-sbi-doc#98
Link: https://lore.kernel.org/linux-riscv/bf6d3b1f-f703-4a25-833e-972a44a04114@sholland.org/
Link: https://lore.kernel.org/r/20221122121620.3522431-1-conor.dooley@microchip.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
jpuhlman pushed a commit to MontaVista-OpenSourceTechnology/linux-mvista that referenced this issue Dec 14, 2022
…end"

Source: Kernel.org
MR: 124165
Type: Integration
Disposition: Backport from git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable linux-5.4.y
ChangeID: 9decec2993374ab04554a83ca11e70c41e516bb5
Description:

[ Upstream commit d9f15a9 ]

This reverts commit 232ccac.

On the subject of suspend, the RISC-V SBI spec states:

  This does not cover whether any given events actually reach the hart or
  not, just what the hart will do if it receives an event. On PolarFire
  SoC, and potentially other SiFive based implementations, events from the
  RISC-V timer do reach a hart during suspend. This is not the case for the
  implementation on the Allwinner D1 - there timer events are not received
  during suspend.

To fix this, the CLOCK_EVT_FEAT_C3STOP (mis)feature was enabled for the
timer driver - but this has broken both RCU stall detection and timers
generally on PolarFire SoC and potentially other SiFive based
implementations.

If an AXI read to the PCIe controller on PolarFire SoC times out, the
system will stall, however, with CLOCK_EVT_FEAT_C3STOP active, the system
just locks up without RCU stalling:

	io scheduler mq-deadline registered
	io scheduler kyber registered
	microchip-pcie 2000000000.pcie: host bridge /soc/pcie@2000000000 ranges:
	microchip-pcie 2000000000.pcie:      MEM 0x2008000000..0x2087ffffff -> 0x0008000000
	microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: axi read request error
	microchip-pcie 2000000000.pcie: axi read timeout
	microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer
	Freeing initrd memory: 7332K

Similarly issues were reported with clock_nanosleep() - with a test app
that sleeps each cpu for 6, 5, 4, 3 ms respectively, HZ=250 & the blamed
commit in place, the sleep times are rounded up to the next jiffy:

== CPU: 1 ==      == CPU: 2 ==      == CPU: 3 ==      == CPU: 4 ==
Mean: 7.974992    Mean: 7.976534    Mean: 7.962591    Mean: 3.952179
Std Dev: 0.154374 Std Dev: 0.156082 Std Dev: 0.171018 Std Dev: 0.076193
Hi: 9.472000      Hi: 10.495000     Hi: 8.864000      Hi: 4.736000
Lo: 6.087000      Lo: 6.380000      Lo: 4.872000      Lo: 3.403000
Samples: 521      Samples: 521      Samples: 521      Samples: 521

Fortunately, the D1 has a second timer, which is "currently used in
preference to the RISC-V/SBI timer driver" so a revert here does not
hurt operation of D1 in its current form.

Ultimately, a DeviceTree property (or node) will be added to encode the
behaviour of the timers, but until then revert the addition of
CLOCK_EVT_FEAT_C3STOP.

Fixes: 232ccac ("clocksource/drivers/riscv: Events are stopped during CPU suspend")
Signed-off-by: Conor Dooley <conor.dooley@microchip.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Palmer Dabbelt <palmer@rivosinc.com>
Acked-by: Palmer Dabbelt <palmer@rivosinc.com>
Acked-by: Samuel Holland <samuel@sholland.org>
Link: https://lore.kernel.org/linux-riscv/YzYTNQRxLr7Q9JR0@spud/
Link: riscv-non-isa/riscv-sbi-doc#98
Link: https://lore.kernel.org/linux-riscv/bf6d3b1f-f703-4a25-833e-972a44a04114@sholland.org/
Link: https://lore.kernel.org/r/20221122121620.3522431-1-conor.dooley@microchip.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Armin Kuster <akuster@mvista.com>
jpuhlman pushed a commit to MontaVista-OpenSourceTechnology/linux-mvista that referenced this issue Dec 14, 2022
…end"

Source: Kernel.org
MR: 124161
Type: Integration
Disposition: Backport from git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable linux-5.10.y
ChangeID: 5a6f935ef34e900a97064b070df4c945de631c2e
Description:

[ Upstream commit d9f15a9 ]

This reverts commit 232ccac.

On the subject of suspend, the RISC-V SBI spec states:

  This does not cover whether any given events actually reach the hart or
  not, just what the hart will do if it receives an event. On PolarFire
  SoC, and potentially other SiFive based implementations, events from the
  RISC-V timer do reach a hart during suspend. This is not the case for the
  implementation on the Allwinner D1 - there timer events are not received
  during suspend.

To fix this, the CLOCK_EVT_FEAT_C3STOP (mis)feature was enabled for the
timer driver - but this has broken both RCU stall detection and timers
generally on PolarFire SoC and potentially other SiFive based
implementations.

If an AXI read to the PCIe controller on PolarFire SoC times out, the
system will stall, however, with CLOCK_EVT_FEAT_C3STOP active, the system
just locks up without RCU stalling:

	io scheduler mq-deadline registered
	io scheduler kyber registered
	microchip-pcie 2000000000.pcie: host bridge /soc/pcie@2000000000 ranges:
	microchip-pcie 2000000000.pcie:      MEM 0x2008000000..0x2087ffffff -> 0x0008000000
	microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: axi read request error
	microchip-pcie 2000000000.pcie: axi read timeout
	microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer
	Freeing initrd memory: 7332K

Similarly issues were reported with clock_nanosleep() - with a test app
that sleeps each cpu for 6, 5, 4, 3 ms respectively, HZ=250 & the blamed
commit in place, the sleep times are rounded up to the next jiffy:

== CPU: 1 ==      == CPU: 2 ==      == CPU: 3 ==      == CPU: 4 ==
Mean: 7.974992    Mean: 7.976534    Mean: 7.962591    Mean: 3.952179
Std Dev: 0.154374 Std Dev: 0.156082 Std Dev: 0.171018 Std Dev: 0.076193
Hi: 9.472000      Hi: 10.495000     Hi: 8.864000      Hi: 4.736000
Lo: 6.087000      Lo: 6.380000      Lo: 4.872000      Lo: 3.403000
Samples: 521      Samples: 521      Samples: 521      Samples: 521

Fortunately, the D1 has a second timer, which is "currently used in
preference to the RISC-V/SBI timer driver" so a revert here does not
hurt operation of D1 in its current form.

Ultimately, a DeviceTree property (or node) will be added to encode the
behaviour of the timers, but until then revert the addition of
CLOCK_EVT_FEAT_C3STOP.

Fixes: 232ccac ("clocksource/drivers/riscv: Events are stopped during CPU suspend")
Signed-off-by: Conor Dooley <conor.dooley@microchip.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Palmer Dabbelt <palmer@rivosinc.com>
Acked-by: Palmer Dabbelt <palmer@rivosinc.com>
Acked-by: Samuel Holland <samuel@sholland.org>
Link: https://lore.kernel.org/linux-riscv/YzYTNQRxLr7Q9JR0@spud/
Link: riscv-non-isa/riscv-sbi-doc#98
Link: https://lore.kernel.org/linux-riscv/bf6d3b1f-f703-4a25-833e-972a44a04114@sholland.org/
Link: https://lore.kernel.org/r/20221122121620.3522431-1-conor.dooley@microchip.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Armin Kuster <akuster@mvista.com>
jpuhlman pushed a commit to MontaVista-OpenSourceTechnology/linux-mvista that referenced this issue Dec 14, 2022
…end"

Source: Kernel.org
MR: 124161
Type: Integration
Disposition: Backport from git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable linux-5.10.y
ChangeID: 5a6f935ef34e900a97064b070df4c945de631c2e
Description:

[ Upstream commit d9f15a9 ]

This reverts commit 232ccac.

On the subject of suspend, the RISC-V SBI spec states:

  This does not cover whether any given events actually reach the hart or
  not, just what the hart will do if it receives an event. On PolarFire
  SoC, and potentially other SiFive based implementations, events from the
  RISC-V timer do reach a hart during suspend. This is not the case for the
  implementation on the Allwinner D1 - there timer events are not received
  during suspend.

To fix this, the CLOCK_EVT_FEAT_C3STOP (mis)feature was enabled for the
timer driver - but this has broken both RCU stall detection and timers
generally on PolarFire SoC and potentially other SiFive based
implementations.

If an AXI read to the PCIe controller on PolarFire SoC times out, the
system will stall, however, with CLOCK_EVT_FEAT_C3STOP active, the system
just locks up without RCU stalling:

	io scheduler mq-deadline registered
	io scheduler kyber registered
	microchip-pcie 2000000000.pcie: host bridge /soc/pcie@2000000000 ranges:
	microchip-pcie 2000000000.pcie:      MEM 0x2008000000..0x2087ffffff -> 0x0008000000
	microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: axi read request error
	microchip-pcie 2000000000.pcie: axi read timeout
	microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer
	Freeing initrd memory: 7332K

Similarly issues were reported with clock_nanosleep() - with a test app
that sleeps each cpu for 6, 5, 4, 3 ms respectively, HZ=250 & the blamed
commit in place, the sleep times are rounded up to the next jiffy:

== CPU: 1 ==      == CPU: 2 ==      == CPU: 3 ==      == CPU: 4 ==
Mean: 7.974992    Mean: 7.976534    Mean: 7.962591    Mean: 3.952179
Std Dev: 0.154374 Std Dev: 0.156082 Std Dev: 0.171018 Std Dev: 0.076193
Hi: 9.472000      Hi: 10.495000     Hi: 8.864000      Hi: 4.736000
Lo: 6.087000      Lo: 6.380000      Lo: 4.872000      Lo: 3.403000
Samples: 521      Samples: 521      Samples: 521      Samples: 521

Fortunately, the D1 has a second timer, which is "currently used in
preference to the RISC-V/SBI timer driver" so a revert here does not
hurt operation of D1 in its current form.

Ultimately, a DeviceTree property (or node) will be added to encode the
behaviour of the timers, but until then revert the addition of
CLOCK_EVT_FEAT_C3STOP.

Fixes: 232ccac ("clocksource/drivers/riscv: Events are stopped during CPU suspend")
Signed-off-by: Conor Dooley <conor.dooley@microchip.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Palmer Dabbelt <palmer@rivosinc.com>
Acked-by: Palmer Dabbelt <palmer@rivosinc.com>
Acked-by: Samuel Holland <samuel@sholland.org>
Link: https://lore.kernel.org/linux-riscv/YzYTNQRxLr7Q9JR0@spud/
Link: riscv-non-isa/riscv-sbi-doc#98
Link: https://lore.kernel.org/linux-riscv/bf6d3b1f-f703-4a25-833e-972a44a04114@sholland.org/
Link: https://lore.kernel.org/r/20221122121620.3522431-1-conor.dooley@microchip.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Armin Kuster <akuster@mvista.com>
jpuhlman pushed a commit to MontaVista-OpenSourceTechnology/linux-mvista that referenced this issue Dec 14, 2022
…end"

Source: Kernel.org
MR: 124161
Type: Integration
Disposition: Backport from git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable linux-5.10.y
ChangeID: 5a6f935ef34e900a97064b070df4c945de631c2e
Description:

[ Upstream commit d9f15a9 ]

This reverts commit 232ccac.

On the subject of suspend, the RISC-V SBI spec states:

  This does not cover whether any given events actually reach the hart or
  not, just what the hart will do if it receives an event. On PolarFire
  SoC, and potentially other SiFive based implementations, events from the
  RISC-V timer do reach a hart during suspend. This is not the case for the
  implementation on the Allwinner D1 - there timer events are not received
  during suspend.

To fix this, the CLOCK_EVT_FEAT_C3STOP (mis)feature was enabled for the
timer driver - but this has broken both RCU stall detection and timers
generally on PolarFire SoC and potentially other SiFive based
implementations.

If an AXI read to the PCIe controller on PolarFire SoC times out, the
system will stall, however, with CLOCK_EVT_FEAT_C3STOP active, the system
just locks up without RCU stalling:

	io scheduler mq-deadline registered
	io scheduler kyber registered
	microchip-pcie 2000000000.pcie: host bridge /soc/pcie@2000000000 ranges:
	microchip-pcie 2000000000.pcie:      MEM 0x2008000000..0x2087ffffff -> 0x0008000000
	microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: axi read request error
	microchip-pcie 2000000000.pcie: axi read timeout
	microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer
	Freeing initrd memory: 7332K

Similarly issues were reported with clock_nanosleep() - with a test app
that sleeps each cpu for 6, 5, 4, 3 ms respectively, HZ=250 & the blamed
commit in place, the sleep times are rounded up to the next jiffy:

== CPU: 1 ==      == CPU: 2 ==      == CPU: 3 ==      == CPU: 4 ==
Mean: 7.974992    Mean: 7.976534    Mean: 7.962591    Mean: 3.952179
Std Dev: 0.154374 Std Dev: 0.156082 Std Dev: 0.171018 Std Dev: 0.076193
Hi: 9.472000      Hi: 10.495000     Hi: 8.864000      Hi: 4.736000
Lo: 6.087000      Lo: 6.380000      Lo: 4.872000      Lo: 3.403000
Samples: 521      Samples: 521      Samples: 521      Samples: 521

Fortunately, the D1 has a second timer, which is "currently used in
preference to the RISC-V/SBI timer driver" so a revert here does not
hurt operation of D1 in its current form.

Ultimately, a DeviceTree property (or node) will be added to encode the
behaviour of the timers, but until then revert the addition of
CLOCK_EVT_FEAT_C3STOP.

Fixes: 232ccac ("clocksource/drivers/riscv: Events are stopped during CPU suspend")
Signed-off-by: Conor Dooley <conor.dooley@microchip.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Palmer Dabbelt <palmer@rivosinc.com>
Acked-by: Palmer Dabbelt <palmer@rivosinc.com>
Acked-by: Samuel Holland <samuel@sholland.org>
Link: https://lore.kernel.org/linux-riscv/YzYTNQRxLr7Q9JR0@spud/
Link: riscv-non-isa/riscv-sbi-doc#98
Link: https://lore.kernel.org/linux-riscv/bf6d3b1f-f703-4a25-833e-972a44a04114@sholland.org/
Link: https://lore.kernel.org/r/20221122121620.3522431-1-conor.dooley@microchip.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Armin Kuster <akuster@mvista.com>
oraclelinuxkernel pushed a commit to oracle/linux-uek that referenced this issue Jan 6, 2023
…end"

[ Upstream commit d9f15a9 ]

This reverts commit 232ccac.

On the subject of suspend, the RISC-V SBI spec states:

  This does not cover whether any given events actually reach the hart or
  not, just what the hart will do if it receives an event. On PolarFire
  SoC, and potentially other SiFive based implementations, events from the
  RISC-V timer do reach a hart during suspend. This is not the case for the
  implementation on the Allwinner D1 - there timer events are not received
  during suspend.

To fix this, the CLOCK_EVT_FEAT_C3STOP (mis)feature was enabled for the
timer driver - but this has broken both RCU stall detection and timers
generally on PolarFire SoC and potentially other SiFive based
implementations.

If an AXI read to the PCIe controller on PolarFire SoC times out, the
system will stall, however, with CLOCK_EVT_FEAT_C3STOP active, the system
just locks up without RCU stalling:

	io scheduler mq-deadline registered
	io scheduler kyber registered
	microchip-pcie 2000000000.pcie: host bridge /soc/pcie@2000000000 ranges:
	microchip-pcie 2000000000.pcie:      MEM 0x2008000000..0x2087ffffff -> 0x0008000000
	microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: axi read request error
	microchip-pcie 2000000000.pcie: axi read timeout
	microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer
	Freeing initrd memory: 7332K

Similarly issues were reported with clock_nanosleep() - with a test app
that sleeps each cpu for 6, 5, 4, 3 ms respectively, HZ=250 & the blamed
commit in place, the sleep times are rounded up to the next jiffy:

== CPU: 1 ==      == CPU: 2 ==      == CPU: 3 ==      == CPU: 4 ==
Mean: 7.974992    Mean: 7.976534    Mean: 7.962591    Mean: 3.952179
Std Dev: 0.154374 Std Dev: 0.156082 Std Dev: 0.171018 Std Dev: 0.076193
Hi: 9.472000      Hi: 10.495000     Hi: 8.864000      Hi: 4.736000
Lo: 6.087000      Lo: 6.380000      Lo: 4.872000      Lo: 3.403000
Samples: 521      Samples: 521      Samples: 521      Samples: 521

Fortunately, the D1 has a second timer, which is "currently used in
preference to the RISC-V/SBI timer driver" so a revert here does not
hurt operation of D1 in its current form.

Ultimately, a DeviceTree property (or node) will be added to encode the
behaviour of the timers, but until then revert the addition of
CLOCK_EVT_FEAT_C3STOP.

Fixes: 232ccac ("clocksource/drivers/riscv: Events are stopped during CPU suspend")
Signed-off-by: Conor Dooley <conor.dooley@microchip.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Palmer Dabbelt <palmer@rivosinc.com>
Acked-by: Palmer Dabbelt <palmer@rivosinc.com>
Acked-by: Samuel Holland <samuel@sholland.org>
Link: https://lore.kernel.org/linux-riscv/YzYTNQRxLr7Q9JR0@spud/
Link: riscv-non-isa/riscv-sbi-doc#98
Link: https://lore.kernel.org/linux-riscv/bf6d3b1f-f703-4a25-833e-972a44a04114@sholland.org/
Link: https://lore.kernel.org/r/20221122121620.3522431-1-conor.dooley@microchip.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
(cherry picked from commit f39891cfe79b0d55096b43f0d051bb5126e9b010)
Signed-off-by: Jack Vogel <jack.vogel@oracle.com>
oraclelinuxkernel pushed a commit to oracle/linux-uek that referenced this issue Jan 20, 2023
…end"

[ Upstream commit d9f15a9 ]

This reverts commit 232ccac.

On the subject of suspend, the RISC-V SBI spec states:

  This does not cover whether any given events actually reach the hart or
  not, just what the hart will do if it receives an event. On PolarFire
  SoC, and potentially other SiFive based implementations, events from the
  RISC-V timer do reach a hart during suspend. This is not the case for the
  implementation on the Allwinner D1 - there timer events are not received
  during suspend.

To fix this, the CLOCK_EVT_FEAT_C3STOP (mis)feature was enabled for the
timer driver - but this has broken both RCU stall detection and timers
generally on PolarFire SoC and potentially other SiFive based
implementations.

If an AXI read to the PCIe controller on PolarFire SoC times out, the
system will stall, however, with CLOCK_EVT_FEAT_C3STOP active, the system
just locks up without RCU stalling:

	io scheduler mq-deadline registered
	io scheduler kyber registered
	microchip-pcie 2000000000.pcie: host bridge /soc/pcie@2000000000 ranges:
	microchip-pcie 2000000000.pcie:      MEM 0x2008000000..0x2087ffffff -> 0x0008000000
	microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: axi read request error
	microchip-pcie 2000000000.pcie: axi read timeout
	microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer
	Freeing initrd memory: 7332K

Similarly issues were reported with clock_nanosleep() - with a test app
that sleeps each cpu for 6, 5, 4, 3 ms respectively, HZ=250 & the blamed
commit in place, the sleep times are rounded up to the next jiffy:

== CPU: 1 ==      == CPU: 2 ==      == CPU: 3 ==      == CPU: 4 ==
Mean: 7.974992    Mean: 7.976534    Mean: 7.962591    Mean: 3.952179
Std Dev: 0.154374 Std Dev: 0.156082 Std Dev: 0.171018 Std Dev: 0.076193
Hi: 9.472000      Hi: 10.495000     Hi: 8.864000      Hi: 4.736000
Lo: 6.087000      Lo: 6.380000      Lo: 4.872000      Lo: 3.403000
Samples: 521      Samples: 521      Samples: 521      Samples: 521

Fortunately, the D1 has a second timer, which is "currently used in
preference to the RISC-V/SBI timer driver" so a revert here does not
hurt operation of D1 in its current form.

Ultimately, a DeviceTree property (or node) will be added to encode the
behaviour of the timers, but until then revert the addition of
CLOCK_EVT_FEAT_C3STOP.

Fixes: 232ccac ("clocksource/drivers/riscv: Events are stopped during CPU suspend")
Signed-off-by: Conor Dooley <conor.dooley@microchip.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Palmer Dabbelt <palmer@rivosinc.com>
Acked-by: Palmer Dabbelt <palmer@rivosinc.com>
Acked-by: Samuel Holland <samuel@sholland.org>
Link: https://lore.kernel.org/linux-riscv/YzYTNQRxLr7Q9JR0@spud/
Link: riscv-non-isa/riscv-sbi-doc#98
Link: https://lore.kernel.org/linux-riscv/bf6d3b1f-f703-4a25-833e-972a44a04114@sholland.org/
Link: https://lore.kernel.org/r/20221122121620.3522431-1-conor.dooley@microchip.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
(cherry picked from commit 9decec2993374ab04554a83ca11e70c41e516bb5)
Signed-off-by: Sherry Yang <sherry.yang@oracle.com>
tuxedo-bot pushed a commit to tuxedocomputers/linux that referenced this issue Feb 2, 2023
…end"

BugLink: https://bugs.launchpad.net/bugs/2003132

[ Upstream commit d9f15a9 ]

This reverts commit 232ccac.

On the subject of suspend, the RISC-V SBI spec states:

  This does not cover whether any given events actually reach the hart or
  not, just what the hart will do if it receives an event. On PolarFire
  SoC, and potentially other SiFive based implementations, events from the
  RISC-V timer do reach a hart during suspend. This is not the case for the
  implementation on the Allwinner D1 - there timer events are not received
  during suspend.

To fix this, the CLOCK_EVT_FEAT_C3STOP (mis)feature was enabled for the
timer driver - but this has broken both RCU stall detection and timers
generally on PolarFire SoC and potentially other SiFive based
implementations.

If an AXI read to the PCIe controller on PolarFire SoC times out, the
system will stall, however, with CLOCK_EVT_FEAT_C3STOP active, the system
just locks up without RCU stalling:

	io scheduler mq-deadline registered
	io scheduler kyber registered
	microchip-pcie 2000000000.pcie: host bridge /soc/pcie@2000000000 ranges:
	microchip-pcie 2000000000.pcie:      MEM 0x2008000000..0x2087ffffff -> 0x0008000000
	microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: axi read request error
	microchip-pcie 2000000000.pcie: axi read timeout
	microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer
	Freeing initrd memory: 7332K

Similarly issues were reported with clock_nanosleep() - with a test app
that sleeps each cpu for 6, 5, 4, 3 ms respectively, HZ=250 & the blamed
commit in place, the sleep times are rounded up to the next jiffy:

== CPU: 1 ==      == CPU: 2 ==      == CPU: 3 ==      == CPU: 4 ==
Mean: 7.974992    Mean: 7.976534    Mean: 7.962591    Mean: 3.952179
Std Dev: 0.154374 Std Dev: 0.156082 Std Dev: 0.171018 Std Dev: 0.076193
Hi: 9.472000      Hi: 10.495000     Hi: 8.864000      Hi: 4.736000
Lo: 6.087000      Lo: 6.380000      Lo: 4.872000      Lo: 3.403000
Samples: 521      Samples: 521      Samples: 521      Samples: 521

Fortunately, the D1 has a second timer, which is "currently used in
preference to the RISC-V/SBI timer driver" so a revert here does not
hurt operation of D1 in its current form.

Ultimately, a DeviceTree property (or node) will be added to encode the
behaviour of the timers, but until then revert the addition of
CLOCK_EVT_FEAT_C3STOP.

Fixes: 232ccac ("clocksource/drivers/riscv: Events are stopped during CPU suspend")
Signed-off-by: Conor Dooley <conor.dooley@microchip.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Palmer Dabbelt <palmer@rivosinc.com>
Acked-by: Palmer Dabbelt <palmer@rivosinc.com>
Acked-by: Samuel Holland <samuel@sholland.org>
Link: https://lore.kernel.org/linux-riscv/YzYTNQRxLr7Q9JR0@spud/
Link: riscv-non-isa/riscv-sbi-doc#98
Link: https://lore.kernel.org/linux-riscv/bf6d3b1f-f703-4a25-833e-972a44a04114@sholland.org/
Link: https://lore.kernel.org/r/20221122121620.3522431-1-conor.dooley@microchip.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
delphix-devops-bot pushed a commit to delphix/linux-kernel-generic that referenced this issue Mar 4, 2023
…end"

BugLink: https://bugs.launchpad.net/bugs/2003896

[ Upstream commit d9f15a9 ]

This reverts commit 232ccac.

On the subject of suspend, the RISC-V SBI spec states:

  This does not cover whether any given events actually reach the hart or
  not, just what the hart will do if it receives an event. On PolarFire
  SoC, and potentially other SiFive based implementations, events from the
  RISC-V timer do reach a hart during suspend. This is not the case for the
  implementation on the Allwinner D1 - there timer events are not received
  during suspend.

To fix this, the CLOCK_EVT_FEAT_C3STOP (mis)feature was enabled for the
timer driver - but this has broken both RCU stall detection and timers
generally on PolarFire SoC and potentially other SiFive based
implementations.

If an AXI read to the PCIe controller on PolarFire SoC times out, the
system will stall, however, with CLOCK_EVT_FEAT_C3STOP active, the system
just locks up without RCU stalling:

	io scheduler mq-deadline registered
	io scheduler kyber registered
	microchip-pcie 2000000000.pcie: host bridge /soc/pcie@2000000000 ranges:
	microchip-pcie 2000000000.pcie:      MEM 0x2008000000..0x2087ffffff -> 0x0008000000
	microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: axi read request error
	microchip-pcie 2000000000.pcie: axi read timeout
	microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer
	Freeing initrd memory: 7332K

Similarly issues were reported with clock_nanosleep() - with a test app
that sleeps each cpu for 6, 5, 4, 3 ms respectively, HZ=250 & the blamed
commit in place, the sleep times are rounded up to the next jiffy:

== CPU: 1 ==      == CPU: 2 ==      == CPU: 3 ==      == CPU: 4 ==
Mean: 7.974992    Mean: 7.976534    Mean: 7.962591    Mean: 3.952179
Std Dev: 0.154374 Std Dev: 0.156082 Std Dev: 0.171018 Std Dev: 0.076193
Hi: 9.472000      Hi: 10.495000     Hi: 8.864000      Hi: 4.736000
Lo: 6.087000      Lo: 6.380000      Lo: 4.872000      Lo: 3.403000
Samples: 521      Samples: 521      Samples: 521      Samples: 521

Fortunately, the D1 has a second timer, which is "currently used in
preference to the RISC-V/SBI timer driver" so a revert here does not
hurt operation of D1 in its current form.

Ultimately, a DeviceTree property (or node) will be added to encode the
behaviour of the timers, but until then revert the addition of
CLOCK_EVT_FEAT_C3STOP.

Fixes: 232ccac ("clocksource/drivers/riscv: Events are stopped during CPU suspend")
Signed-off-by: Conor Dooley <conor.dooley@microchip.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Palmer Dabbelt <palmer@rivosinc.com>
Acked-by: Palmer Dabbelt <palmer@rivosinc.com>
Acked-by: Samuel Holland <samuel@sholland.org>
Link: https://lore.kernel.org/linux-riscv/YzYTNQRxLr7Q9JR0@spud/
Link: riscv-non-isa/riscv-sbi-doc#98
Link: https://lore.kernel.org/linux-riscv/bf6d3b1f-f703-4a25-833e-972a44a04114@sholland.org/
Link: https://lore.kernel.org/r/20221122121620.3522431-1-conor.dooley@microchip.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
@atishp04
Copy link
Collaborator

atishp04 commented Apr 3, 2023

AFAIK, this was resolved in lkml discussions resulting a dt property. Closing this issue.

@atishp04 atishp04 closed this as completed Apr 3, 2023
fahhem added a commit to Reviewable/linux that referenced this issue Apr 19, 2023
commit 76dcd734eca23168cb008912c0f69ff408905235
Author: Linus Torvalds <torvalds@linux-foundation.org>
Date:   Sun Dec 4 14:48:12 2022 -0800

    Linux 6.1-rc8

commit 0ba09b1733878afe838fe35c310715fda3d46428
Author: Linus Torvalds <torvalds@linux-foundation.org>
Date:   Sun Dec 4 12:51:59 2022 -0800

    Revert "mm: align larger anonymous mappings on THP boundaries"

    This reverts commit f35b5d7d676e59e401690b678cd3cfec5e785c23.

    It has been reported to cause huge performance regressions on some loads
    (will-it-scale.per_process_ops, but also building the kernel with
    clang).

    The commit did speed up gcc builds by a small amount, so it's not an
    unambiguous regression, but until the big regressions are understood,
    let's revert it.

    Reported-by: kernel test robot <yujie.liu@intel.com>
    Link: https://lore.kernel.org/r/202210181535.7144dd15-yujie.liu@intel.com
    Reported-by: Nathan Chancellor <nathan@kernel.org>
    Link: https://lore.kernel.org/lkml/Y1DNQaoPWxE%2BrGce@dev-arch.thelio-3990X/
    Cc: Huang, Ying <ying.huang@intel.com>
    Cc: Rik van Riel <riel@surriel.com>
    Cc: Andrew Morton <akpm@linux-foundation.org>
    Cc: Yang Shi <shy828301@gmail.com>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

commit 23393c6461422df5bf8084a086ada9a7e17dc2ba
Author: Jan Dabros <jsd@semihalf.com>
Date:   Mon Nov 28 20:56:51 2022 +0100

    char: tpm: Protect tpm_pm_suspend with locks

    Currently tpm transactions are executed unconditionally in
    tpm_pm_suspend() function, which may lead to races with other tpm
    accessors in the system.

    Specifically, the hw_random tpm driver makes use of tpm_get_random(),
    and this function is called in a loop from a kthread, which means it's
    not frozen alongside userspace, and so can race with the work done
    during system suspend:

      tpm tpm0: tpm_transmit: tpm_recv: error -52
      tpm tpm0: invalid TPM_STS.x 0xff, dumping stack for forensics
      CPU: 0 PID: 1 Comm: init Not tainted 6.1.0-rc5+ #135
      Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.0-20220807_005459-localhost 04/01/2014
      Call Trace:
       tpm_tis_status.cold+0x19/0x20
       tpm_transmit+0x13b/0x390
       tpm_transmit_cmd+0x20/0x80
       tpm1_pm_suspend+0xa6/0x110
       tpm_pm_suspend+0x53/0x80
       __pnp_bus_suspend+0x35/0xe0
       __device_suspend+0x10f/0x350

    Fix this by calling tpm_try_get_ops(), which itself is a wrapper around
    tpm_chip_start(), but takes the appropriate mutex.

    Signed-off-by: Jan Dabros <jsd@semihalf.com>
    Reported-by: Vlastimil Babka <vbabka@suse.cz>
    Tested-by: Jason A. Donenfeld <Jason@zx2c4.com>
    Tested-by: Vlastimil Babka <vbabka@suse.cz>
    Link: https://lore.kernel.org/all/c5ba47ef-393f-1fba-30bd-1230d1b4b592@suse.cz/
    Cc: stable@vger.kernel.org
    Fixes: e891db1a18bf ("tpm: turn on TPM on suspend for TPM 1.x")
    [Jason: reworked commit message, added metadata]
    Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
    Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

commit 0c3b5bcb484a659dd14466f92a073b57b2d3c1a5
Merge: eea8bebd5173 517e6a301f34
Author: Linus Torvalds <torvalds@linux-foundation.org>
Date:   Sun Dec 4 12:36:23 2022 -0800

    Merge tag 'perf_urgent_for_v6.1_rc8' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

    Pull perf fix from Borislav Petkov:

     - Fix a use-after-free case where the perf pending task callback would
       see an already freed event

    * tag 'perf_urgent_for_v6.1_rc8' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
      perf: Fix perf_pending_task() UaF

commit eea8bebd51739cc7a3bb501032ee877b4aada553
Merge: ae6bb7171171 d9f15a9de44a
Author: Linus Torvalds <torvalds@linux-foundation.org>
Date:   Sun Dec 4 12:33:44 2022 -0800

    Merge tag 'timers_urgent_for_v6.1_rc8' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

    Pull timer fix from Borislav Petkov:

     - Revert a fix to RISC-V timers supposed to address an uncertainty
       whether clock events are received during S3 or not which locks up
       other RISC-V platforms. The issue will be fixed differently later.

    * tag 'timers_urgent_for_v6.1_rc8' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
      Revert "clocksource/drivers/riscv: Events are stopped during CPU suspend"

commit ae6bb71711713e7b6b2d9ed2af7318dc8ae5cfb2
Merge: 50f36c5aa12c 2e7ec190a0e3
Author: Linus Torvalds <torvalds@linux-foundation.org>
Date:   Sun Dec 4 12:24:58 2022 -0800

    Merge tag 'powerpc-6.1-6' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux

    Pull powerpc fixes from Michael Ellerman:

     - Fix oops in 32-bit BPF tail call tests

     - Add missing declaration for machine_check_early_boot()

    Thanks to Christophe Leroy and Naveen N. Rao.

    * tag 'powerpc-6.1-6' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux:
      powerpc/64s: Add missing declaration for machine_check_early_boot()
      powerpc/bpf/32: Fix Oops on tail call tests

commit 50f36c5aa12c8d0f2adca662e0c106212ea897a8
Merge: c2bf05db6c78 8c9a59939deb
Author: Linus Torvalds <torvalds@linux-foundation.org>
Date:   Sun Dec 4 12:18:37 2022 -0800

    Merge tag 'input-for-v6.1-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input

    Pull input fix from Dmitry Torokhov:

     - a fix for Raydium touchscreen driver to stop leaking memory when
       sending commands to the chip

    * tag 'input-for-v6.1-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input:
      Input: raydium_ts_i2c - fix memory leak in raydium_i2c_send()

commit c2bf05db6c78f53ca5cd4b48f3b9b71f78d215f1
Merge: 6085bc95797c d36678f7905c
Author: Linus Torvalds <torvalds@linux-foundation.org>
Date:   Sat Dec 3 13:51:37 2022 -0800

    Merge tag 'i2c-for-6.1-rc8' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux

    Pull i2c fixes from Wolfram Sang:
     "A power state fix in the core for ACPI devices, a regression fix
      regarding bus recovery for the cadence driver, a DMA handling fix for
      the imx driver, and two error path fixes (npcm7xx and qcom-geni)"

    * tag 'i2c-for-6.1-rc8' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux:
      i2c: imx: Only DMA messages with I2C_M_DMA_SAFE flag set
      i2c: qcom-geni: fix error return code in geni_i2c_gpi_xfer
      i2c: cadence: Fix regression with bus recovery
      i2c: Restore initial power state if probe fails
      i2c: npcm7xx: Fix error handling in npcm_i2c_init()

commit 6085bc95797caa55a68bc0f7dd73e8c33e91037f
Merge: 97ee9d1c1696 472faf72b33d
Author: Linus Torvalds <torvalds@linux-foundation.org>
Date:   Sat Dec 3 13:43:38 2022 -0800

    Merge tag 'dax-fixes-6.1-rc8' of git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm

    Pull dax fixes from Dan Williams:
     "A few bug fixes around the handling of "Soft Reserved" memory and
      memory tiering information.

      Linux is starting to enounter more real world systems that deploy an
      ACPI HMAT to describe different performance classes of memory, as well
      the "special purpose" (Linux "Soft Reserved") designation from EFI.

      These fixes result from that testing.

      It has all appeared in -next for a while with no known issues.

       - Fix duplicate overlapping device-dax instances for HMAT described
         "Soft Reserved" Memory

       - Fix missing node targets in the sysfs representation of memory
         tiers

       - Remove a confusing variable initialization"

    * tag 'dax-fixes-6.1-rc8' of git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm:
      device-dax: Fix duplicate 'hmem' device registration
      ACPI: HMAT: Fix initiator registration for single-initiator systems
      ACPI: HMAT: remove unnecessary variable initialization

commit 97ee9d1c16963375eefdf964c429897d27e28956
Merge: 63050a5ca130 d0f411c0b9bd
Author: Linus Torvalds <torvalds@linux-foundation.org>
Date:   Fri Dec 2 16:27:15 2022 -0800

    Merge tag 'block-6.1-2022-12-02' of git://git.kernel.dk/linux

    Pull block fixes from Jens Axboe:
     "Just a small NVMe merge for this week, fixing protection of the name
      space list, and a missing clear of a reserved field when unused"

    * tag 'block-6.1-2022-12-02' of git://git.kernel.dk/linux:
      nvme: fix SRCU protection of nvme_ns_head list
      nvme-pci: clear the prp2 field when not used

commit 63050a5ca130e76af7199c9a3fba1d175f3a1102
Merge: 0e15c3c75a28 6989ea4881c8
Author: Linus Torvalds <torvalds@linux-foundation.org>
Date:   Fri Dec 2 16:22:17 2022 -0800

    Merge tag 'pinctrl-v6.1-5' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-pinctrl

    Pull pin control fixes from Linus Walleij:
     "Three driver fixes. The Intel fix looks like the most important.

       - Fix a potential divide by zero in pinctrl-singe (OMAP and
         HiSilicon)

       - Disable IRQs on startup in the Mediatek driver. This is a classic,
         we should be looking out for this more.

       - Save and restore pins in 'direct IRQ' mode in the Intel driver,
         this works around firmware bugs"

    * tag 'pinctrl-v6.1-5' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-pinctrl:
      pinctrl: intel: Save and restore pins in "direct IRQ" mode
      pinctrl: meditatek: Startup with the IRQs disabled
      pinctrl: single: Fix potential division by zero

commit 0e15c3c75a28b10bac7b3ad7627fd6b458623283
Merge: 2df2adc3e69d 39cefc5f6cd2
Author: Linus Torvalds <torvalds@linux-foundation.org>
Date:   Fri Dec 2 16:04:53 2022 -0800

    Merge tag 'riscv-for-linus-6.1-rc8' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux

    Pull RISC-V fixes from Palmer Dabbelt:

     - build fix for the NR_CPUS Kconfig SBI version dependency

     - fixes to early memory initialization, to fix page permissions in EFI
       and post-initmem-free

     - build fix for the VDSO, to avoid trying to profile the VDSO functions

     - fixes for kexec crash handling, to fix multi-core and interrupt
       related initialization inside the crash kernel

     - fix for a race condition when handling multiple concurrect kernel
       stack overflows

    * tag 'riscv-for-linus-6.1-rc8' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux:
      riscv: kexec: Fixup crash_smp_send_stop without multi cores
      riscv: kexec: Fixup irq controller broken in kexec crash path
      riscv: mm: Proper page permissions after initmem free
      riscv: vdso: fix section overlapping under some conditions
      riscv: fix race when vmap stack overflow
      riscv: Sync efi page table's kernel mappings before switching
      riscv: Fix NR_CPUS range conditions

commit 2df2adc3e69d32751eb534ed55c591854260c4a3
Merge: f66f62f83dba dd30dcfa7a74
Author: Linus Torvalds <torvalds@linux-foundation.org>
Date:   Fri Dec 2 15:58:07 2022 -0800

    Merge tag 'mmc-v6.1-rc5-2' of git://git.kernel.org/pub/scm/linux/kernel/git/ulfh/mmc

    Pull MMC fixes from Ulf Hansson:
     "MMC core:
       - Fix ambiguous TRIM and DISCARD args
       - Fix removal of debugfs file for mmc_test

      MMC host:
       - mtk-sd: Add missing clk_disable_unprepare() in an error path
       - sdhci: Fix I/O voltage switch delay for UHS-I SD cards
       - sdhci-esdhc-imx: Fix CQHCI exit halt state check
       - sdhci-sprd: Fix voltage switch"

    * tag 'mmc-v6.1-rc5-2' of git://git.kernel.org/pub/scm/linux/kernel/git/ulfh/mmc:
      mmc: sdhci-sprd: Fix no reset data and command after voltage switch
      mmc: sdhci: Fix voltage switch delay
      mmc: mtk-sd: Fix missing clk_disable_unprepare in msdc_of_clock_parse()
      mmc: mmc_test: Fix removal of debugfs file
      mmc: sdhci-esdhc-imx: correct CQHCI exit halt state check
      mmc: core: Fix ambiguous TRIM and DISCARD arg

commit f66f62f83dba3ec4237c3dd7a95b776824ac91a0
Merge: 66065157420c 4bedbbd782eb
Author: Linus Torvalds <torvalds@linux-foundation.org>
Date:   Fri Dec 2 15:54:12 2022 -0800

    Merge tag 'iommu-fixes-v6.1-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu

    Pull iommu fixes from Joerg Roedel:
     "Intel VT-d fixes:

       - IO/TLB flush fix

       - Various pci_dev refcount fixes"

    * tag 'iommu-fixes-v6.1-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu:
      iommu/vt-d: Fix PCI device refcount leak in dmar_dev_scope_init()
      iommu/vt-d: Fix PCI device refcount leak in has_external_pci()
      iommu/vt-d: Fix PCI device refcount leak in prq_event_thread()
      iommu/vt-d: Add a fix for devices need extra dtlb flush

commit 66065157420c5b9b3f078f43d313c153e1ff7f83
Author: Pawan Gupta <pawan.kumar.gupta@linux.intel.com>
Date:   Wed Nov 30 07:25:51 2022 -0800

    x86/bugs: Make sure MSR_SPEC_CTRL is updated properly upon resume from S3

    The "force" argument to write_spec_ctrl_current() is currently ambiguous
    as it does not guarantee the MSR write. This is due to the optimization
    that writes to the MSR happen only when the new value differs from the
    cached value.

    This is fine in most cases, but breaks for S3 resume when the cached MSR
    value gets out of sync with the hardware MSR value due to S3 resetting
    it.

    When x86_spec_ctrl_current is same as x86_spec_ctrl_base, the MSR write
    is skipped. Which results in SPEC_CTRL mitigations not getting restored.

    Move the MSR write from write_spec_ctrl_current() to a new function that
    unconditionally writes to the MSR. Update the callers accordingly and
    rename functions.

      [ bp: Rework a bit. ]

    Fixes: caa0ff24d5d0 ("x86/bugs: Keep a per-CPU IA32_SPEC_CTRL value")
    Suggested-by: Borislav Petkov <bp@alien8.de>
    Signed-off-by: Pawan Gupta <pawan.kumar.gupta@linux.intel.com>
    Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
    Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
    Cc: <stable@kernel.org>
    Link: https://lore.kernel.org/r/806d39b0bfec2fe8f50dc5446dff20f5bb24a959.1669821572.git.pawan.kumar.gupta@linux.intel.com
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

commit 8c9a59939deb4bfafdc451100c03d1e848b4169b
Author: Zhang Xiaoxu <zhangxiaoxu5@huawei.com>
Date:   Fri Dec 2 15:37:46 2022 -0800

    Input: raydium_ts_i2c - fix memory leak in raydium_i2c_send()

    There is a kmemleak when test the raydium_i2c_ts with bpf mock device:

      unreferenced object 0xffff88812d3675a0 (size 8):
        comm "python3", pid 349, jiffies 4294741067 (age 95.695s)
        hex dump (first 8 bytes):
          11 0e 10 c0 01 00 04 00                          ........
        backtrace:
          [<0000000068427125>] __kmalloc+0x46/0x1b0
          [<0000000090180f91>] raydium_i2c_send+0xd4/0x2bf [raydium_i2c_ts]
          [<000000006e631aee>] raydium_i2c_initialize.cold+0xbc/0x3e4 [raydium_i2c_ts]
          [<00000000dc6fcf38>] raydium_i2c_probe+0x3cd/0x6bc [raydium_i2c_ts]
          [<00000000a310de16>] i2c_device_probe+0x651/0x680
          [<00000000f5a96bf3>] really_probe+0x17c/0x3f0
          [<00000000096ba499>] __driver_probe_device+0xe3/0x170
          [<00000000c5acb4d9>] driver_probe_device+0x49/0x120
          [<00000000264fe082>] __device_attach_driver+0xf7/0x150
          [<00000000f919423c>] bus_for_each_drv+0x114/0x180
          [<00000000e067feca>] __device_attach+0x1e5/0x2d0
          [<0000000054301fc2>] bus_probe_device+0x126/0x140
          [<00000000aad93b22>] device_add+0x810/0x1130
          [<00000000c086a53f>] i2c_new_client_device+0x352/0x4e0
          [<000000003c2c248c>] of_i2c_register_device+0xf1/0x110
          [<00000000ffec4177>] of_i2c_notify+0x100/0x160
      unreferenced object 0xffff88812d3675c8 (size 8):
        comm "python3", pid 349, jiffies 4294741070 (age 95.692s)
        hex dump (first 8 bytes):
          22 00 36 2d 81 88 ff ff                          ".6-....
        backtrace:
          [<0000000068427125>] __kmalloc+0x46/0x1b0
          [<0000000090180f91>] raydium_i2c_send+0xd4/0x2bf [raydium_i2c_ts]
          [<000000001d5c9620>] raydium_i2c_initialize.cold+0x223/0x3e4 [raydium_i2c_ts]
          [<00000000dc6fcf38>] raydium_i2c_probe+0x3cd/0x6bc [raydium_i2c_ts]
          [<00000000a310de16>] i2c_device_probe+0x651/0x680
          [<00000000f5a96bf3>] really_probe+0x17c/0x3f0
          [<00000000096ba499>] __driver_probe_device+0xe3/0x170
          [<00000000c5acb4d9>] driver_probe_device+0x49/0x120
          [<00000000264fe082>] __device_attach_driver+0xf7/0x150
          [<00000000f919423c>] bus_for_each_drv+0x114/0x180
          [<00000000e067feca>] __device_attach+0x1e5/0x2d0
          [<0000000054301fc2>] bus_probe_device+0x126/0x140
          [<00000000aad93b22>] device_add+0x810/0x1130
          [<00000000c086a53f>] i2c_new_client_device+0x352/0x4e0
          [<000000003c2c248c>] of_i2c_register_device+0xf1/0x110
          [<00000000ffec4177>] of_i2c_notify+0x100/0x160

    After BANK_SWITCH command from i2c BUS, no matter success or error
    happened, the tx_buf should be freed.

    Fixes: 3b384bd6c3f2 ("Input: raydium_ts_i2c - do not split tx transactions")
    Signed-off-by: Zhang Xiaoxu <zhangxiaoxu5@huawei.com>
    Link: https://lore.kernel.org/r/20221202103412.2120169-1-zhangxiaoxu5@huawei.com
    Cc: stable@vger.kernel.org
    Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

commit a1e9185d20b56af04022d2e656802254f4ea47eb
Merge: c290db013742 b47068b4aa53
Author: Linus Torvalds <torvalds@linux-foundation.org>
Date:   Fri Dec 2 15:40:35 2022 -0800

    Merge tag 'sound-6.1-rc8' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound

    Pull sound fixes from Takashi Iwai:
     "Likely the last piece for 6.1; the only significant fixes are ASoC
      core ops fixes, while others are device-specific (rather minor) fixes
      in ASoC and FireWire drivers.

      All appear safe enough to take as a late stage material"

    * tag 'sound-6.1-rc8' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound:
      ALSA: dice: fix regression for Lexicon I-ONIX FW810S
      ASoC: cs42l51: Correct PGA Volume minimum value
      ASoC: ops: Correct bounds check for second channel on SX controls
      ASoC: tlv320adc3xxx: Fix build error for implicit function declaration
      ASoC: ops: Check bounds for second channel in snd_soc_put_volsw_sx()
      ASoC: ops: Fix bounds check for _sx controls
      ASoC: fsl_micfil: explicitly clear CHnF flags
      ASoC: fsl_micfil: explicitly clear software reset bit

commit c290db013742e98fe5b64073bc2dd8c8a2ac9e4c
Merge: bdaa78c6aa86 c082fbd687ad
Author: Linus Torvalds <torvalds@linux-foundation.org>
Date:   Fri Dec 2 15:35:21 2022 -0800

    Merge tag 'drm-fixes-2022-12-02' of git://anongit.freedesktop.org/drm/drm

    Pull drm fixes from Dave Airlie:
     "Things do seem to have finally settled down, just four i915 and one
      amdgpu this week. Probably won't have much for next week if you do
      push rc8 out.

      i915:
       - Fix dram info readout
       - Remove non-existent pipes from bigjoiner pipe mask
       - Fix negative value passed as remaining time
       - Never return 0 if not all requests retired

      amdgpu:
       - VCN fix for vangogh"

    * tag 'drm-fixes-2022-12-02' of git://anongit.freedesktop.org/drm/drm:
      drm/amdgpu: enable Vangogh VCN indirect sram mode
      drm/i915: Never return 0 if not all requests retired
      drm/i915: Fix negative value passed as remaining time
      drm/i915: Remove non-existent pipes from bigjoiner pipe mask
      drm/i915/mtl: Fix dram info readout

commit bdaa78c6aa861f0e8c612a0b2272423d92f0071c
Merge: 6647e76ab623 1d351f189434
Author: Linus Torvalds <torvalds@linux-foundation.org>
Date:   Fri Dec 2 13:39:38 2022 -0800

    Merge tag 'mm-hotfixes-stable-2022-12-02' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm

    Pull misc hotfixes from Andrew Morton:
     "15 hotfixes,  11 marked cc:stable.

      Only three or four of the latter address post-6.0 issues, which is
      hopefully a sign that things are converging"

    * tag 'mm-hotfixes-stable-2022-12-02' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm:
      revert "kbuild: fix -Wimplicit-function-declaration in license_is_gpl_compatible"
      Kconfig.debug: provide a little extra FRAME_WARN leeway when KASAN is enabled
      drm/amdgpu: temporarily disable broken Clang builds due to blown stack-frame
      mm/khugepaged: invoke MMU notifiers in shmem/file collapse paths
      mm/khugepaged: fix GUP-fast interaction by sending IPI
      mm/khugepaged: take the right locks for page table retraction
      mm: migrate: fix THP's mapcount on isolation
      mm: introduce arch_has_hw_nonleaf_pmd_young()
      mm: add dummy pmd_young() for architectures not having it
      mm/damon/sysfs: fix wrong empty schemes assumption under online tuning in damon_sysfs_set_schemes()
      tools/vm/slabinfo-gnuplot: use "grep -E" instead of "egrep"
      nilfs2: fix NULL pointer dereference in nilfs_palloc_commit_free_entry()
      hugetlb: don't delete vma_lock in hugetlb MADV_DONTNEED processing
      madvise: use zap_page_range_single for madvise dontneed
      mm: replace VM_WARN_ON to pr_warn if the node is offline with __GFP_THISNODE

commit 6647e76ab623b2b3fb2efe03a86e9c9046c52c33
Author: Linus Torvalds <torvalds@linux-foundation.org>
Date:   Wed Nov 30 16:10:52 2022 -0800

    v4l2: don't fall back to follow_pfn() if pin_user_pages_fast() fails

    The V4L2_MEMORY_USERPTR interface is long deprecated and shouldn't be
    used (and is discouraged for any modern v4l drivers).  And Seth Jenkins
    points out that the fallback to VM_PFNMAP/VM_IO is fundamentally racy
    and dangerous.

    Note that it's not even a case that should trigger, since any normal
    user pointer logic ends up just using the pin_user_pages_fast() call
    that does the proper page reference counting.  That's not the problem
    case, only if you try to use special device mappings do you have any
    issues.

    Normally I'd just remove this during the merge window, but since Seth
    pointed out the problem cases, we really want to know as soon as
    possible if there are actually any users of this odd special case of a
    legacy interface.  Neither Hans nor Mauro seem to think that such
    mis-uses of the old legacy interface should exist.  As Mauro says:

     "See, V4L2 has actually 4 streaming APIs:
            - Kernel-allocated mmap (usually referred simply as just mmap);
            - USERPTR mmap;
            - read();
            - dmabuf;

      The USERPTR is one of the oldest way to use it, coming from V4L
      version 1 times, and by far the least used one"

    And Hans chimed in on the USERPTR interface:

     "To be honest, I wouldn't mind if it goes away completely, but that's a
      bit of a pipe dream right now"

    but while removing this legacy interface entirely may be a pipe dream we
    can at least try to remove the unlikely (and actively broken) case of
    using special device mappings for USERPTR accesses.

    This replaces it with a WARN_ONCE() that we can remove once we've
    hopefully confirmed that no actual users exist.

    NOTE! Longer term, this means that a 'struct frame_vector' only ever
    contains proper page pointers, and all the games we have with converting
    them to pages can go away (grep for 'frame_vector_to_pages()' and the
    uses of 'vec->is_pfns').  But this is just the first step, to verify
    that this code really is all dead, and do so as quickly as possible.

    Reported-by: Seth Jenkins <sethjenkins@google.com>
    Acked-by: Hans Verkuil <hverkuil@xs4all.nl>
    Acked-by: Mauro Carvalho Chehab <mchehab@kernel.org>
    Cc: David Hildenbrand <david@redhat.com>
    Cc: Jan Kara <jack@suse.cz>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

commit d0f411c0b9bdef85f647e15a2fcc790b29891f2c
Merge: 7d4a93176e01 899d2a05dc14
Author: Jens Axboe <axboe@kernel.dk>
Date:   Fri Dec 2 08:01:06 2022 -0700

    Merge tag 'nvme-6.1-2022-01-02' of git://git.infradead.org/nvme into block-6.1

    Pull NVMe fixes from Christoph:

    "nvme fixes for Linux 6.1

     - fix SRCU protection of nvme_ns_head list (Caleb Sander)
     - clear the prp2 field when not used (Lei Rao)"

    * tag 'nvme-6.1-2022-01-02' of git://git.infradead.org/nvme:
      nvme: fix SRCU protection of nvme_ns_head list
      nvme-pci: clear the prp2 field when not used

commit 4bedbbd782ebbe7287231fea862c158d4f08a9e3
Author: Xiongfeng Wang <wangxiongfeng2@huawei.com>
Date:   Thu Dec 1 12:01:27 2022 +0800

    iommu/vt-d: Fix PCI device refcount leak in dmar_dev_scope_init()

    for_each_pci_dev() is implemented by pci_get_device(). The comment of
    pci_get_device() says that it will increase the reference count for the
    returned pci_dev and also decrease the reference count for the input
    pci_dev @from if it is not NULL.

    If we break for_each_pci_dev() loop with pdev not NULL, we need to call
    pci_dev_put() to decrease the reference count. Add the missing
    pci_dev_put() for the error path to avoid reference count leak.

    Fixes: 2e4552893038 ("iommu/vt-d: Unify the way to process DMAR device scope array")
    Signed-off-by: Xiongfeng Wang <wangxiongfeng2@huawei.com>
    Link: https://lore.kernel.org/r/20221121113649.190393-3-wangxiongfeng2@huawei.com
    Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
    Signed-off-by: Joerg Roedel <jroedel@suse.de>

commit afca9e19cc720bfafc75dc5ce429c185ca93f31d
Author: Xiongfeng Wang <wangxiongfeng2@huawei.com>
Date:   Thu Dec 1 12:01:26 2022 +0800

    iommu/vt-d: Fix PCI device refcount leak in has_external_pci()

    for_each_pci_dev() is implemented by pci_get_device(). The comment of
    pci_get_device() says that it will increase the reference count for the
    returned pci_dev and also decrease the reference count for the input
    pci_dev @from if it is not NULL.

    If we break for_each_pci_dev() loop with pdev not NULL, we need to call
    pci_dev_put() to decrease the reference count. Add the missing
    pci_dev_put() before 'return true' to avoid reference count leak.

    Fixes: 89a6079df791 ("iommu/vt-d: Force IOMMU on for platform opt in hint")
    Signed-off-by: Xiongfeng Wang <wangxiongfeng2@huawei.com>
    Link: https://lore.kernel.org/r/20221121113649.190393-2-wangxiongfeng2@huawei.com
    Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
    Signed-off-by: Joerg Roedel <jroedel@suse.de>

commit 6927d352380797ddbee18631491ec428741696e2
Author: Yang Yingliang <yangyingliang@huawei.com>
Date:   Thu Dec 1 12:01:25 2022 +0800

    iommu/vt-d: Fix PCI device refcount leak in prq_event_thread()

    As comment of pci_get_domain_bus_and_slot() says, it returns a pci device
    with refcount increment, when finish using it, the caller must decrease
    the reference count by calling pci_dev_put(). So call pci_dev_put() after
    using the 'pdev' to avoid refcount leak.

    Besides, if the 'pdev' is null or intel_svm_prq_report() returns error,
    there is no need to trace this fault.

    Fixes: 06f4b8d09dba ("iommu/vt-d: Remove unnecessary SVA data accesses in page fault path")
    Suggested-by: Lu Baolu <baolu.lu@linux.intel.com>
    Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
    Link: https://lore.kernel.org/r/20221119144028.2452731-1-yangyingliang@huawei.com
    Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
    Signed-off-by: Joerg Roedel <jroedel@suse.de>

commit e65a6897be5e4939d477c4969a05e12d90b08409
Author: Jacob Pan <jacob.jun.pan@linux.intel.com>
Date:   Thu Dec 1 12:01:24 2022 +0800

    iommu/vt-d: Add a fix for devices need extra dtlb flush

    QAT devices on Intel Sapphire Rapids and Emerald Rapids have a defect in
    address translation service (ATS). These devices may inadvertently issue
    ATS invalidation completion before posted writes initiated with
    translated address that utilized translations matching the invalidation
    address range, violating the invalidation completion ordering.

    This patch adds an extra device TLB invalidation for the affected devices,
    it is needed to ensure no more posted writes with translated address
    following the invalidation completion. Therefore, the ordering is
    preserved and data-corruption is prevented.

    Device TLBs are invalidated under the following six conditions:
    1. Device driver does DMA API unmap IOVA
    2. Device driver unbind a PASID from a process, sva_unbind_device()
    3. PASID is torn down, after PASID cache is flushed. e.g. process
    exit_mmap() due to crash
    4. Under SVA usage, called by mmu_notifier.invalidate_range() where
    VM has to free pages that were unmapped
    5. userspace driver unmaps a DMA buffer
    6. Cache invalidation in vSVA usage (upcoming)

    For #1 and #2, device drivers are responsible for stopping DMA traffic
    before unmap/unbind. For #3, iommu driver gets mmu_notifier to
    invalidate TLB the same way as normal user unmap which will do an extra
    invalidation. The dTLB invalidation after PASID cache flush does not
    need an extra invalidation.

    Therefore, we only need to deal with #4 and #5 in this patch. #1 is also
    covered by this patch due to common code path with #5.

    Tested-by: Yuzhang Luo <yuzhang.luo@intel.com>
    Reviewed-by: Ashok Raj <ashok.raj@intel.com>
    Reviewed-by: Kevin Tian <kevin.tian@intel.com>
    Signed-off-by: Jacob Pan <jacob.jun.pan@linux.intel.com>
    Link: https://lore.kernel.org/r/20221130062449.1360063-1-jacob.jun.pan@linux.intel.com
    Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
    Signed-off-by: Joerg Roedel <jroedel@suse.de>

commit c082fbd687ad70a92e0a8be486a7555a66f03079
Merge: 65a388250e39 9a8cc8cabc1e
Author: Dave Airlie <airlied@redhat.com>
Date:   Fri Dec 2 09:12:46 2022 +1000

    Merge tag 'amd-drm-fixes-6.1-2022-12-01' of https://gitlab.freedesktop.org/agd5f/linux into drm-fixes

    amd-drm-fixes-6.1-2022-12-01:

    amdgpu:
    - VCN fix for vangogh

    Signed-off-by: Dave Airlie <airlied@redhat.com>
    From: Alex Deucher <alexander.deucher@amd.com>
    Link: https://patchwork.freedesktop.org/patch/msgid/20221201202015.5931-1-alexander.deucher@amd.com

commit d36678f7905cbd1dc55a8a96e066dafd749d4600
Author: Andrew Lunn <andrew@lunn.ch>
Date:   Thu Nov 10 00:59:02 2022 +0100

    i2c: imx: Only DMA messages with I2C_M_DMA_SAFE flag set

    Recent changes to the DMA code has resulting in the IMX driver failing
    I2C transfers when the buffer has been vmalloc. Only perform DMA
    transfers if the message has the I2C_M_DMA_SAFE flag set, indicating
    the client is providing a buffer which is DMA safe.

    This is a minimal fix for stable. The I2C core provides helpers to
    allocate a bounce buffer. For a fuller fix the master should make use
    of these helpers.

    Fixes: 4544b9f25e70 ("dma-mapping: Add vmap checks to dma_map_single()")
    Signed-off-by: Andrew Lunn <andrew@lunn.ch>
    Acked-by: Oleksij Rempel <o.rempel@pengutronix.de>
    Signed-off-by: Wolfram Sang <wsa@kernel.org>

commit 7d8ccf4f117d082156e842d959f634efcf203cef
Author: Wang Yufen <wangyufen@huawei.com>
Date:   Mon Nov 21 18:17:52 2022 +0800

    i2c: qcom-geni: fix error return code in geni_i2c_gpi_xfer

    Fix to return a negative error code from the gi2c->err instead of
    0.

    Fixes: d8703554f4de ("i2c: qcom-geni: Add support for GPI DMA")
    Signed-off-by: Wang Yufen <wangyufen@huawei.com>
    Reviewed-by: Tommaso Merciai <tommaso.merciai@amarulasoluitons.com>
    Signed-off-by: Wolfram Sang <wsa@kernel.org>

commit 8bfd4ec726945cec35ee5cafebc1c55b83d5a9fb
Author: Carsten Haitzler <carsten.haitzler@arm.com>
Date:   Mon Nov 28 10:51:58 2022 +0000

    i2c: cadence: Fix regression with bus recovery

    Commit "i2c: cadence: Add standard bus recovery support" breaks for i2c
    devices that have no pinctrl defined. There is no requirement for this
    to exist in the DT. This has worked perfectly well without this before in
    at least 1 real usage case on hardware (Mali Komeda DPU, Cadence i2c to
    talk to a tda99xx phy). Adding the requirement to have pinctrl set up in
    the device tree (or otherwise be found) is a regression where the whole
    i2c device is lost entirely (in this case dropping entire devices which
    then leads to the drm display stack unable to find the phy for display
    output, thus having no drm display device and so on down the chain).

    This converts the above commit to an enhancement if pinctrl can be found
    for the i2c device, providing a timeout on read with recovery, but if not,
    do what used to be done rather than a fatal loss of a device.

    This restores the mentioned display devices to their working state again.

    Fixes: 58b924241d0a ("i2c: cadence: Add standard bus recovery support")
    Signed-off-by: Carsten Haitzler <carsten.haitzler@arm.com>
    Reviewed-by: Shubhrajyoti Datta <shubhrajyoti.datta@amd.com>
    Reviewed-by: Michael Grzeschik <m.grzeschik@pengutronix.de>
    Acked-by: Michal Simek <michal.simek@amd.com>
    [wsa: added braces to else-branch]
    Signed-off-by: Wolfram Sang <wsa@kernel.org>

commit 65a388250e391b7127efd6751f64f3e4955e43a0
Merge: b7b275e60bcd 12b8b046e4c9
Author: Dave Airlie <airlied@redhat.com>
Date:   Fri Dec 2 07:34:27 2022 +1000

    Merge tag 'drm-intel-fixes-2022-12-01' of git://anongit.freedesktop.org/drm/drm-intel into drm-fixes

    - Fix dram info readout (Radhakrishna Sripada)
    - Remove non-existent pipes from bigjoiner pipe mask (Ville Syrjälä)
    - Fix negative value passed as remaining time (Janusz Krzysztofik)
    - Never return 0 if not all requests retired (Janusz Krzysztofik)

    Signed-off-by: Dave Airlie <airlied@redhat.com>
    From: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
    Link: https://patchwork.freedesktop.org/patch/msgid/Y4hp+a3TJ13t2ZA1@tursulin-desk

commit a4412fdd49dc011bcc2c0d81ac4cab7457092650
Author: Steven Rostedt (Google) <rostedt@goodmis.org>
Date:   Mon Nov 21 10:44:03 2022 -0500

    error-injection: Add prompt for function error injection

    The config to be able to inject error codes into any function annotated
    with ALLOW_ERROR_INJECTION() is enabled when FUNCTION_ERROR_INJECTION is
    enabled.  But unfortunately, this is always enabled on x86 when KPROBES
    is enabled, and there's no way to turn it off.

    As kprobes is useful for observability of the kernel, it is useful to
    have it enabled in production environments.  But error injection should
    be avoided.  Add a prompt to the config to allow it to be disabled even
    when kprobes is enabled, and get rid of the "def_bool y".

    This is a kernel debug feature (it's in Kconfig.debug), and should have
    never been something enabled by default.

    Cc: stable@vger.kernel.org
    Fixes: 540adea3809f6 ("error-injection: Separate error-injection from kprobe")
    Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

commit 9a8cc8cabc1e351614fd7f9e774757a5143b6fe8
Author: Leo Liu <leo.liu@amd.com>
Date:   Tue Nov 29 18:53:18 2022 -0500

    drm/amdgpu: enable Vangogh VCN indirect sram mode

    So that uses PSP to initialize HW.

    Fixes: 0c2c02b66c672e ("drm/amdgpu/vcn: add firmware support for dimgrey_cavefish")
    Signed-off-by: Leo Liu <leo.liu@amd.com>
    Reviewed-by: James Zhu <James.Zhu@amd.com>
    Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
    Cc: stable@vger.kernel.org

commit 39cefc5f6cd25d555e0455b24810e9aff365b8d6
Merge: d556a9aeb62a 7e1864332fbc
Author: Palmer Dabbelt <palmer@rivosinc.com>
Date:   Thu Dec 1 11:38:39 2022 -0800

    RISC-V: Fix a race condition during kernel stack overflow

    This fixes a concrete bug but is also the basis for some cleanup work,
    so I'm merging it based on the offending commit in order to minimize
    future conflicts.

    * commit '7e1864332fbc1b993659eab7974da9fe8bf8c128':
      riscv: fix race when vmap stack overflow

commit 355479c70a489415ef6e2624e514f8f15a40861b
Merge: e214dd935bf1 7572ac3c979d
Author: Linus Torvalds <torvalds@linux-foundation.org>
Date:   Thu Dec 1 11:25:11 2022 -0800

    Merge tag 'efi-fixes-for-v6.1-4' of git://git.kernel.org/pub/scm/linux/kernel/git/efi/efi

    Pull EFI fix from Ard Biesheuvel:
     "A single revert for some code that I added during this cycle. The code
      is not wrong, but it should be a bit more careful about how to handle
      the shadow call stack pointer, so it is better to revert it for now
      and bring it back later in improved form.

      Summary:

       - Revert runtime service sync exception recovery on arm64"

    * tag 'efi-fixes-for-v6.1-4' of git://git.kernel.org/pub/scm/linux/kernel/git/efi/efi:
      arm64: efi: Revert "Recover from synchronous exceptions ..."

commit e214dd935bf154af4c2d5013b16a283d592ccea5
Merge: 063c0e773ab3 9bdc112be727
Author: Linus Torvalds <torvalds@linux-foundation.org>
Date:   Thu Dec 1 11:10:25 2022 -0800

    Merge tag 'hwmon-for-v6.1-rc8' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging

    Pull hwmon fixes from Guenter Roeck:

     - Fix refcount leak and NULL pointer access in coretemp driver

     - Fix UAF in ibmpex driver

     - Add missing pci_disable_device() to i5500_temp driver

     - Fix calculation in ina3221 driver

     - Fix temperature scaling in ltc2947 driver

     - Check result of devm_kcalloc call in asus-ec-sensors driver

    * tag 'hwmon-for-v6.1-rc8' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging:
      hwmon: (asus-ec-sensors) Add checks for devm_kcalloc
      hwmon: (coretemp) fix pci device refcount leak in nv1a_ram_new()
      hwmon: (coretemp) Check for null before removing sysfs attrs
      hwmon: (ibmpex) Fix possible UAF when ibmpex_register_bmc() fails
      hwmon: (i5500_temp) fix missing pci_disable_device()
      hwmon: (ina3221) Fix shunt sum critical calculation
      hwmon: (ltc2947) fix temperature scaling

commit 9bdc112be727cf1ba65be79541147f960c3349d8
Author: Yuan Can <yuancan@huawei.com>
Date:   Fri Nov 25 01:43:29 2022 +0000

    hwmon: (asus-ec-sensors) Add checks for devm_kcalloc

    As the devm_kcalloc may return NULL, the return value needs to be checked
    to avoid NULL poineter dereference.

    Fixes: d0ddfd241e57 ("hwmon: (asus-ec-sensors) add driver for ASUS EC")
    Signed-off-by: Yuan Can <yuancan@huawei.com>
    Link: https://lore.kernel.org/r/20221125014329.121560-1-yuancan@huawei.com
    Signed-off-by: Guenter Roeck <linux@roeck-us.net>

commit 7dec14537c5906b8bf40fd6fd6d9c3850f8df11d
Author: Yang Yingliang <yangyingliang@huawei.com>
Date:   Fri Nov 18 17:33:03 2022 +0800

    hwmon: (coretemp) fix pci device refcount leak in nv1a_ram_new()

    As comment of pci_get_domain_bus_and_slot() says, it returns
    a pci device with refcount increment, when finish using it,
    the caller must decrement the reference count by calling
    pci_dev_put(). So call it after using to avoid refcount leak.

    Fixes: 14513ee696a0 ("hwmon: (coretemp) Use PCI host bridge ID to identify CPU if necessary")
    Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
    Link: https://lore.kernel.org/r/20221118093303.214163-1-yangyingliang@huawei.com
    Signed-off-by: Guenter Roeck <linux@roeck-us.net>

commit a89ff5f5cc64b9fe7a992cf56988fd36f56ca82a
Author: Phil Auld <pauld@redhat.com>
Date:   Thu Nov 17 11:23:13 2022 -0500

    hwmon: (coretemp) Check for null before removing sysfs attrs

    If coretemp_add_core() gets an error then pdata->core_data[indx]
    is already NULL and has been kfreed. Don't pass that to
    sysfs_remove_group() as that will crash in sysfs_remove_group().

    [Shortened for readability]
    [91854.020159] sysfs: cannot create duplicate filename '/devices/platform/coretemp.0/hwmon/hwmon2/temp20_label'
    <cpu offline>
    [91855.126115] BUG: kernel NULL pointer dereference, address: 0000000000000188
    [91855.165103] #PF: supervisor read access in kernel mode
    [91855.194506] #PF: error_code(0x0000) - not-present page
    [91855.224445] PGD 0 P4D 0
    [91855.238508] Oops: 0000 [#1] PREEMPT SMP PTI
    ...
    [91855.342716] RIP: 0010:sysfs_remove_group+0xc/0x80
    ...
    [91855.796571] Call Trace:
    [91855.810524]  coretemp_cpu_offline+0x12b/0x1dd [coretemp]
    [91855.841738]  ? coretemp_cpu_online+0x180/0x180 [coretemp]
    [91855.871107]  cpuhp_invoke_callback+0x105/0x4b0
    [91855.893432]  cpuhp_thread_fun+0x8e/0x150
    ...

    Fix this by checking for NULL first.

    Signed-off-by: Phil Auld <pauld@redhat.com>
    Cc: linux-hwmon@vger.kernel.org
    Cc: Fenghua Yu <fenghua.yu@intel.com>
    Cc: Jean Delvare <jdelvare@suse.com>
    Cc: Guenter Roeck <linux@roeck-us.net>
    Link: https://lore.kernel.org/r/20221117162313.3164803-1-pauld@redhat.com
    Fixes: 199e0de7f5df3 ("hwmon: (coretemp) Merge pkgtemp with coretemp")
    Signed-off-by: Guenter Roeck <linux@roeck-us.net>

commit 7572ac3c979d4d0fb42d73a72d2608656516ff4f
Author: Ard Biesheuvel <ardb@kernel.org>
Date:   Wed Nov 30 17:37:17 2022 +0100

    arm64: efi: Revert "Recover from synchronous exceptions ..."

    This reverts commit 23715a26c8d81291, which introduced some code in
    assembler that manipulates both the ordinary and the shadow call stack
    pointer in a way that could potentially be taken advantage of. So let's
    revert it, and do a better job the next time around.

    Signed-off-by: Ard Biesheuvel <ardb@kernel.org>

commit d9f15a9de44affe733e34f93bc184945ba277e6d
Author: Conor Dooley <conor.dooley@microchip.com>
Date:   Tue Nov 22 12:16:21 2022 +0000

    Revert "clocksource/drivers/riscv: Events are stopped during CPU suspend"

    This reverts commit 232ccac1bd9b5bfe73895f527c08623e7fa0752d.

    On the subject of suspend, the RISC-V SBI spec states:

      This does not cover whether any given events actually reach the hart or
      not, just what the hart will do if it receives an event. On PolarFire
      SoC, and potentially other SiFive based implementations, events from the
      RISC-V timer do reach a hart during suspend. This is not the case for the
      implementation on the Allwinner D1 - there timer events are not received
      during suspend.

    To fix this, the CLOCK_EVT_FEAT_C3STOP (mis)feature was enabled for the
    timer driver - but this has broken both RCU stall detection and timers
    generally on PolarFire SoC and potentially other SiFive based
    implementations.

    If an AXI read to the PCIe controller on PolarFire SoC times out, the
    system will stall, however, with CLOCK_EVT_FEAT_C3STOP active, the system
    just locks up without RCU stalling:

    	io scheduler mq-deadline registered
    	io scheduler kyber registered
    	microchip-pcie 2000000000.pcie: host bridge /soc/pcie@2000000000 ranges:
    	microchip-pcie 2000000000.pcie:      MEM 0x2008000000..0x2087ffffff -> 0x0008000000
    	microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer
    	microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer
    	microchip-pcie 2000000000.pcie: axi read request error
    	microchip-pcie 2000000000.pcie: axi read timeout
    	microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer
    	microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer
    	microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer
    	microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer
    	microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer
    	microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer
    	Freeing initrd memory: 7332K

    Similarly issues were reported with clock_nanosleep() - with a test app
    that sleeps each cpu for 6, 5, 4, 3 ms respectively, HZ=250 & the blamed
    commit in place, the sleep times are rounded up to the next jiffy:

    == CPU: 1 ==      == CPU: 2 ==      == CPU: 3 ==      == CPU: 4 ==
    Mean: 7.974992    Mean: 7.976534    Mean: 7.962591    Mean: 3.952179
    Std Dev: 0.154374 Std Dev: 0.156082 Std Dev: 0.171018 Std Dev: 0.076193
    Hi: 9.472000      Hi: 10.495000     Hi: 8.864000      Hi: 4.736000
    Lo: 6.087000      Lo: 6.380000      Lo: 4.872000      Lo: 3.403000
    Samples: 521      Samples: 521      Samples: 521      Samples: 521

    Fortunately, the D1 has a second timer, which is "currently used in
    preference to the RISC-V/SBI timer driver" so a revert here does not
    hurt operation of D1 in its current form.

    Ultimately, a DeviceTree property (or node) will be added to encode the
    behaviour of the timers, but until then revert the addition of
    CLOCK_EVT_FEAT_C3STOP.

    Fixes: 232ccac1bd9b ("clocksource/drivers/riscv: Events are stopped during CPU suspend")
    Signed-off-by: Conor Dooley <conor.dooley@microchip.com>
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Reviewed-by: Palmer Dabbelt <palmer@rivosinc.com>
    Acked-by: Palmer Dabbelt <palmer@rivosinc.com>
    Acked-by: Samuel Holland <samuel@sholland.org>
    Link: https://lore.kernel.org/linux-riscv/YzYTNQRxLr7Q9JR0@spud/
    Link: https://github.com/riscv-non-isa/riscv-sbi-doc/issues/98/
    Link: https://lore.kernel.org/linux-riscv/bf6d3b1f-f703-4a25-833e-972a44a04114@sholland.org/
    Link: https://lore.kernel.org/r/20221122121620.3522431-1-conor.dooley@microchip.com

commit dd30dcfa7a74a06f8dcdab260d8d5adf32f17333
Author: Wenchao Chen <wenchao.chen@unisoc.com>
Date:   Wed Nov 30 20:13:28 2022 +0800

    mmc: sdhci-sprd: Fix no reset data and command after voltage switch

    After switching the voltage, no reset data and command will cause
    CMD2 timeout.

    Fixes: 29ca763fc26f ("mmc: sdhci-sprd: Add pin control support for voltage switch")
    Signed-off-by: Wenchao Chen <wenchao.chen@unisoc.com>
    Acked-by: Adrian Hunter <adrian.hunter@intel.com>
    Reviewed-by: Baolin Wang <baolin.wang@linux.alibaba.com>
    Cc: stable@vger.kernel.org
    Link: https://lore.kernel.org/r/20221130121328.25553-1-wenchao.chen@unisoc.com
    Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>

commit 063c0e773ab33103407a76051821777014b756fe
Merge: ef4d3ea40565 f6abcc21d943
Author: Linus Torvalds <torvalds@linux-foundation.org>
Date:   Wed Nov 30 15:46:46 2022 -0800

    Merge tag 'clk-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/clk/linux

    Pull clk fixes from Stephen Boyd:
     "A set of clk driver fixes that resolve issues for various SoCs.

      Most of these are incorrect clk data, like bad parent descriptions.
      When the clk tree is improperly described things don't work, like USB
      and UFS controllers, because clk frequencies are wonky. Here are the
      extra details:

       - Fix the parent of UFS reference clks on Qualcomm SC8280XP so that
         UFS works properly

       - Fix the clk ID for USB on AT91 RM9200 so the USB driver continues
         to probe

       - Stop using of_device_get_match_data() on the wrong device for a
         Samsung Exynos driver so it gets the proper clk data

       - Fix ExynosAutov9 binding

       - Fix the parent of the div4 clk on Exynos7885

       - Stop calling runtime PM APIs from the Qualcomm GDSC driver directly
         as it leads to a lockdep splat and is just plain wrong because it
         violates runtime PM semantics by calling runtime PM APIs when the
         device has been runtime PM disabled"

    * tag 'clk-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/clk/linux:
      clk: qcom: gcc-sc8280xp: add cxo as parent for three ufs ref clks
      ARM: at91: rm9200: fix usb device clock id
      clk: samsung: Revert "clk: samsung: exynos-clkout: Use of_device_get_match_data()"
      dt-bindings: clock: exynosautov9: fix reference to CMU_FSYS1
      clk: qcom: gdsc: Remove direct runtime PM calls
      clk: samsung: exynos7885: Correct "div4" clock parents

commit 1d351f1894342c378b96bb9ed89f8debb1e24e9f
Author: Andrew Morton <akpm@linux-foundation.org>
Date:   Mon Nov 28 13:21:40 2022 -0800

    revert "kbuild: fix -Wimplicit-function-declaration in license_is_gpl_compatible"

    It causes build failures with unusual CC/HOSTCC combinations.

    Quoting
    https://lkml.kernel.org/r/A222B1E6-69B8-4085-AD1B-27BDB72CA971@goldelico.com:

      HOSTCC  scripts/mod/modpost.o - due to target missing
    In file included from include/linux/string.h:5,
                     from scripts/mod/../../include/linux/license.h:5,
                     from scripts/mod/modpost.c:24:
    include/linux/compiler.h:246:10: fatal error: asm/rwonce.h: No such file or directory
      246 | #include <asm/rwonce.h>
          |          ^~~~~~~~~~~~~~
    compilation terminated.

    ...

    The problem is that HOSTCC is not necessarily the same compiler or even
    architecture as CC and pulling in <linux/compiler.h> or <asm/rwonce.h>
    files indirectly isn't a good idea then.

    My toolchain is providing HOSTCC = gcc (MacPorts) and CC = arm-linux-gnueabihf
    (built from gcc source) and all running on Darwin.

    If I change the include to <string.h> I can then "HOSTCC scripts/mod/modpost.c"
    but then it fails for "CC kernel/module/main.c" not finding <string.h>:

      CC      kernel/module/main.o - due to target missing
    In file included from kernel/module/main.c:43:0:
    ./include/linux/license.h:5:20: fatal error: string.h: No such file or directory
     #include <string.h>
                        ^
    compilation terminated.

    Reported-by: "H. Nikolaus Schaller" <hns@goldelico.com>
    Cc: Sam James <sam@gentoo.org>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

commit 152fe65f300e1819d59b80477d3e0999b4d5d7d2
Author: Lee Jones <lee@kernel.org>
Date:   Fri Nov 25 12:07:50 2022 +0000

    Kconfig.debug: provide a little extra FRAME_WARN leeway when KASAN is enabled

    When enabled, KASAN enlarges function's stack-frames.  Pushing quite a few
    over the current threshold.  This can mainly be seen on 32-bit
    architectures where the present limit (when !GCC) is a lowly 1024-Bytes.

    Link: https://lkml.kernel.org/r/20221125120750.3537134-3-lee@kernel.org
    Signed-off-by: Lee Jones <lee@kernel.org>
    Acked-by: Arnd Bergmann <arnd@arndb.de>
    Cc: Alex Deucher <alexander.deucher@amd.com>
    Cc: "Christian König" <christian.koenig@amd.com>
    Cc: Daniel Vetter <daniel@ffwll.ch>
    Cc: David Airlie <airlied@gmail.com>
    Cc: Harry Wentland <harry.wentland@amd.com>
    Cc: Leo Li <sunpeng.li@amd.com>
    Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
    Cc: Maxime Ripard <mripard@kernel.org>
    Cc: Nathan Chancellor <nathan@kernel.org>
    Cc: Nick Desaulniers <ndesaulniers@google.com>
    Cc: "Pan, Xinhui" <Xinhui.Pan@amd.com>
    Cc: Rodrigo Siqueira <Rodrigo.Siqueira@amd.com>
    Cc: Thomas Zimmermann <tzimmermann@suse.de>
    Cc: Tom Rix <trix@redhat.com>
    Cc: <stable@vger.kernel.org>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

commit 6f6cb1714365a07dbc66851879538df9f6969288
Author: Lee Jones <lee@kernel.org>
Date:   Fri Nov 25 12:07:49 2022 +0000

    drm/amdgpu: temporarily disable broken Clang builds due to blown stack-frame

    Patch series "Fix a bunch of allmodconfig errors", v2.

    Since b339ec9c229aa ("kbuild: Only default to -Werror if COMPILE_TEST")
    WERROR now defaults to COMPILE_TEST meaning that it's enabled for
    allmodconfig builds.  This leads to some interesting build failures when
    using Clang, each resolved in this set.

    With this set applied, I am able to obtain a successful allmodconfig Arm
    build.

    This patch (of 2):

    calculate_bandwidth() is presently broken on all !(X86_64 || SPARC64 ||
    ARM64) architectures built with Clang (all released versions), whereby the
    stack frame gets blown up to well over 5k.  This would cause an immediate
    kernel panic on most architectures.  We'll revert this when the following
    bug report has been resolved:
    https://github.com/llvm/llvm-project/issues/41896.

    Link: https://lkml.kernel.org/r/20221125120750.3537134-1-lee@kernel.org
    Link: https://lkml.kernel.org/r/20221125120750.3537134-2-lee@kernel.org
    Signed-off-by: Lee Jones <lee@kernel.org>
    Suggested-by: Arnd Bergmann <arnd@arndb.de>
    Acked-by: Arnd Bergmann <arnd@arndb.de>
    Cc: Alex Deucher <alexander.deucher@amd.com>
    Cc: "Christian König" <christian.koenig@amd.com>
    Cc: Daniel Vetter <daniel@ffwll.ch>
    Cc: David Airlie <airlied@gmail.com>
    Cc: Harry Wentland <harry.wentland@amd.com>
    Cc: Lee Jones <lee@kernel.org>
    Cc: Leo Li <sunpeng.li@amd.com>
    Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
    Cc: Maxime Ripard <mripard@kernel.org>
    Cc: Nathan Chancellor <nathan@kernel.org>
    Cc: Nick Desaulniers <ndesaulniers@google.com>
    Cc: "Pan, Xinhui" <Xinhui.Pan@amd.com>
    Cc: Rodrigo Siqueira <Rodrigo.Siqueira@amd.com>
    Cc: Thomas Zimmermann <tzimmermann@suse.de>
    Cc: Tom Rix <trix@redhat.com>
    Cc: <stable@vger.kernel.org>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

commit f268f6cf875f3220afc77bdd0bf1bb136eb54db9
Author: Jann Horn <jannh@google.com>
Date:   Fri Nov 25 22:37:14 2022 +0100

    mm/khugepaged: invoke MMU notifiers in shmem/file collapse paths

    Any codepath that zaps page table entries must invoke MMU notifiers to
    ensure that secondary MMUs (like KVM) don't keep accessing pages which
    aren't mapped anymore.  Secondary MMUs don't hold their own references to
    pages that are mirrored over, so failing to notify them can lead to page
    use-after-free.

    I'm marking this as addressing an issue introduced in commit f3f0e1d2150b
    ("khugepaged: add support of collapse for tmpfs/shmem pages"), but most of
    the security impact of this only came in commit 27e1f8273113 ("khugepaged:
    enable collapse pmd for pte-mapped THP"), which actually omitted flushes
    for the removal of present PTEs, not just for the removal of empty page
    tables.

    Link: https://lkml.kernel.org/r/20221129154730.2274278-3-jannh@google.com
    Link: https://lkml.kernel.org/r/20221128180252.1684965-3-jannh@google.com
    Link: https://lkml.kernel.org/r/20221125213714.4115729-3-jannh@google.com
    Fixes: f3f0e1d2150b ("khugepaged: add support of collapse for tmpfs/shmem pages")
    Signed-off-by: Jann Horn <jannh@google.com>
    Acked-by: David Hildenbrand <david@redhat.com>
    Reviewed-by: Yang Shi <shy828301@gmail.com>
    Cc: John Hubbard <jhubbard@nvidia.com>
    Cc: Peter Xu <peterx@redhat.com>
    Cc: <stable@vger.kernel.org>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

commit 2ba99c5e08812494bc57f319fb562f527d9bacd8
Author: Jann Horn <jannh@google.com>
Date:   Fri Nov 25 22:37:13 2022 +0100

    mm/khugepaged: fix GUP-fast interaction by sending IPI

    Since commit 70cbc3cc78a99 ("mm: gup: fix the fast GUP race against THP
    collapse"), the lockless_pages_from_mm() fastpath rechecks the pmd_t to
    ensure that the page table was not removed by khugepaged in between.

    However, lockless_pages_from_mm() still requires that the page table is
    not concurrently freed.  Fix it by sending IPIs (if the architecture uses
    semi-RCU-style page table freeing) before freeing/reusing page tables.

    Link: https://lkml.kernel.org/r/20221129154730.2274278-2-jannh@google.com
    Link: https://lkml.kernel.org/r/20221128180252.1684965-2-jannh@google.com
    Link: https://lkml.kernel.org/r/20221125213714.4115729-2-jannh@google.com
    Fixes: ba76149f47d8 ("thp: khugepaged")
    Signed-off-by: Jann Horn <jannh@google.com>
    Reviewed-by: Yang Shi <shy828301@gmail.com>
    Acked-by: David Hildenbrand <david@redhat.com>
    Cc: John Hubbard <jhubbard@nvidia.com>
    Cc: Peter Xu <peterx@redhat.com>
    Cc: <stable@vger.kernel.org>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

commit 8d3c106e19e8d251da31ff4cc7462e4565d65084
Author: Jann Horn <jannh@google.com>
Date:   Fri Nov 25 22:37:12 2022 +0100

    mm/khugepaged: take the right locks for page table retraction

    pagetable walks on address ranges mapped by VMAs can be done under the
    mmap lock, the lock of an anon_vma attached to the VMA, or the lock of the
    VMA's address_space.  Only one of these needs to be held, and it does not
    need to be held in exclusive mode.

    Under those circumstances, the rules for concurrent access to page table
    entries are:

     - Terminal page table entries (entries that don't point to another page
       table) can be arbitrarily changed under the page table lock, with the
       exception that they always need to be consistent for
       hardware page table walks and lockless_pages_from_mm().
       This includes that they can be changed into non-terminal entries.
     - Non-terminal page table entries (which point to another page table)
       can not be modified; readers are allowed to READ_ONCE() an entry, verify
       that it is non-terminal, and then assume that its value will stay as-is.

    Retracting a page table involves modifying a non-terminal entry, so
    page-table-level locks are insufficient to protect against concurrent page
    table traversal; it requires taking all the higher-level locks under which
    it is possible to start a page walk in the relevant range in exclusive
    mode.

    The collapse_huge_page() path for anonymous THP already follows this rule,
    but the shmem/file THP path was getting it wrong, making it possible for
    concurrent rmap-based operations to cause corruption.

    Link: https://lkml.kernel.org/r/20221129154730.2274278-1-jannh@google.com
    Link: https://lkml.kernel.org/r/20221128180252.1684965-1-jannh@google.com
    Link: https://lkml.kernel.org/r/20221125213714.4115729-1-jannh@google.com
    Fixes: 27e1f8273113 ("khugepaged: enable collapse pmd for pte-mapped THP")
    Signed-off-by: Jann Horn <jannh@google.com>
    Reviewed-by: Yang Shi <shy828301@gmail.com>
    Acked-by: David Hildenbrand <david@redhat.com>
    Cc: John Hubbard <jhubbard@nvidia.com>
    Cc: Peter Xu <peterx@redhat.com>
    Cc: <stable@vger.kernel.org>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

commit 829ae0f81ce093d674ff2256f66a714753e9ce32
Author: Gavin Shan <gshan@redhat.com>
Date:   Thu Nov 24 17:55:23 2022 +0800

    mm: migrate: fix THP's mapcount on isolation

    The issue is reported when removing memory through virtio_mem device.  The
    transparent huge page, experienced copy-on-write fault, is wrongly
    regarded as pinned.  The transparent huge page is escaped from being
    isolated in isolate_migratepages_block().  The transparent huge page can't
    be migrated and the corresponding memory block can't be put into offline
    state.

    Fix it by replacing page_mapcount() with total_mapcount().  With this, the
    transparent huge page can be isolated and migrated, and the memory block
    can be put into offline state.  Besides, The page's refcount is increased
    a bit earlier to avoid the page is released when the check is executed.

    Link: https://lkml.kernel.org/r/20221124095523.31061-1-gshan@redhat.com
    Fixes: 1da2f328fa64 ("mm,thp,compaction,cma: allow THP migration for CMA allocations")
    Signed-off-by: Gavin Shan <gshan@redhat.com>
    Reported-by: Zhenyu Zhang <zhenyzha@redhat.com>
    Tested-by: Zhenyu Zhang <zhenyzha@redhat.com>
    Suggested-by: David Hildenbrand <david@redhat.com>
    Acked-by: David Hildenbrand <david@redhat.com>
    Cc: Alistair Popple <apopple@nvidia.com>
    Cc: Hugh Dickins <hughd@google.com>
    Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
    Cc: Matthew Wilcox <willy@infradead.org>
    Cc: William Kucharski <william.kucharski@oracle.com>
    Cc: Zi Yan <ziy@nvidia.com>
    Cc: <stable@vger.kernel.org>	[5.7+]
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

commit 4aaf269c768dbacd6268af73fda2ffccaa3f1d88
Author: Juergen Gross <jgross@suse.com>
Date:   Wed Nov 23 07:45:10 2022 +0100

    mm: introduce arch_has_hw_nonleaf_pmd_young()

    When running as a Xen PV guests commit eed9a328aa1a ("mm: x86: add
    CONFIG_ARCH_HAS_NONLEAF_PMD_YOUNG") can cause a protection violation in
    pmdp_test_and_clear_young():

     BUG: unable to handle page fault for address: ffff8880083374d0
     #PF: supervisor write access in kernel mode
     #PF: error_code(0x0003) - permissions violation
     PGD 3026067 P4D 3026067 PUD 3027067 PMD 7fee5067 PTE 8010000008337065
     Oops: 0003 [#1] PREEMPT SMP NOPTI
     CPU: 7 PID: 158 Comm: kswapd0 Not tainted 6.1.0-rc5-20221118-doflr+ #1
     RIP: e030:pmdp_test_and_clear_young+0x25/0x40

    This happens because the Xen hypervisor can't emulate direct writes to
    page table entries other than PTEs.

    This can easily be fixed by introducing arch_has_hw_nonleaf_pmd_young()
    similar to arch_has_hw_pte_young() and test that instead of
    CONFIG_ARCH_HAS_NONLEAF_PMD_YOUNG.

    Link: https://lkml.kernel.org/r/20221123064510.16225-1-jgross@suse.com
    Fixes: eed9a328aa1a ("mm: x86: add CONFIG_ARCH_HAS_NONLEAF_PMD_YOUNG")
    Signed-off-by: Juergen Gross <jgross@suse.com>
    Reported-by: Sander Eikelenboom <linux@eikelenboom.it>
    Acked-by: Yu Zhao <yuzhao@google.com>
    Tested-by: Sander Eikelenboom <linux@eikelenboom.it>
    Acked-by: David Hildenbrand <david@redhat.com>	[core changes]
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

commit 6617da8fb565445e0be4a4885443006374943d09
Author: Juergen Gross <jgross@suse.com>
Date:   Wed Nov 30 14:49:41 2022 -0800

    mm: add dummy pmd_young() for architectures not having it

    In order to avoid #ifdeffery add a dummy pmd_young() implementation as a
    fallback.  This is required for the later patch "mm: introduce
    arch_has_hw_nonleaf_pmd_young()".

    Link: https://lkml.kernel.org/r/fd3ac3cd-7349-6bbd-890a-71a9454ca0b3@suse.com
    Signed-off-by: Juergen Gross <jgross@suse.com>
    Acked-by: Yu Zhao <yuzhao@google.com>
    Cc: Borislav Petkov <bp@alien8.de>
    Cc: Dave Hansen <dave.hansen@linux.intel.com>
    Cc: Geert Uytterhoeven <geert@linux-m68k.org>
    Cc: "H. Peter Anvin" <hpa@zytor.com>
    Cc: Ingo Molnar <mingo@redhat.com>
    Cc: Sander Eikelenboom <linux@eikelenboom.it>
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

commit 95bc35f9bee5220dad4e8567654ab3288a181639
Author: SeongJae Park <sj@kernel.org>
Date:   Tue Nov 22 19:48:31 2022 +0000

    mm/damon/sysfs: fix wrong empty schemes assumption under online tuning in damon_sysfs_set_schemes()

    Commit da87878010e5 ("mm/damon/sysfs: support online inputs update") made
    'damon_sysfs_set_schemes()' to be called for running DAMON context, which
    could have schemes.  In the case, DAMON sysfs interface is supposed to
    update, remove, or add schemes to reflect the sysfs files.  However, the
    code is assuming the DAMON context wouldn't have schemes at all, and
    therefore creates and adds new schemes.  As a result, the code doesn't
    work as intended for online schemes tuning and could have more than
    expected memory footprint.  The schemes are all in the DAMON context, so
    it doesn't leak the memory, though.

    Remove the wrong asssumption (the DAMON context wouldn't have schemes) in
    'damon_sysfs_set_schemes()' to fix the bug.

    Link: https://lkml.kernel.org/r/20221122194831.3472-1-sj@kernel.org
    Fixes: da87878010e5 ("mm/damon/sysfs: support online inputs update")
    Signed-off-by: SeongJae Park <sj@kernel.org>
    Cc: <stable@vger.kernel.org>	[5.19+]
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

commit a435874bf626f55d7147026b059008c8de89fbb8
Author: Tiezhu Yang <yangtiezhu@loongson.cn>
Date:   Sat Nov 19 10:36:59 2022 +0800

    tools/vm/slabinfo-gnuplot: use "grep -E" instead of "egrep"

    The latest version of grep claims the egrep is now obsolete so the build
    now contains warnings that look like:

    	egrep: warning: egrep is obsolescent; using grep -E

    fix this up by moving the related file to use "grep -E" instead.

      sed -i "s/egrep/grep -E/g" `grep egrep -rwl tools/vm`

    Here are the steps to install the latest grep:

      wget http://ftp.gnu.org/gnu/grep/grep-3.8.tar.gz
      tar xf grep-3.8.tar.gz
      cd grep-3.8 && ./configure && make
      sudo make install
      export PATH=/usr/local/bin:$PATH

    Link: https://lkml.kernel.org/r/1668825419-30584-1-git-send-email-yangtiezhu@loongson.cn
    Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
    Reviewed-by: Sergey Senozhatsky <senozhatsky@chromium.org>
    Cc: Vlastimil Babka <vbabka@suse.cz>
    Cc: <stable@vger.kernel.org>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

commit f0a0ccda18d6fd826d7c7e7ad48a6ed61c20f8b4
Author: ZhangPeng <zhangpeng362@huawei.com>
Date:   Sat Nov 19 21:05:42 2022 +0900

    nilfs2: fix NULL pointer dereference in nilfs_palloc_commit_free_entry()

    Syzbot reported a null-ptr-deref bug:

     NILFS (loop0): segctord starting. Construction interval = 5 seconds, CP
     frequency < 30 seconds
     general protection fault, probably for non-canonical address
     0xdffffc0000000002: 0000 [#1] PREEMPT SMP KASAN
     KASAN: null-ptr-deref in range [0x0000000000000010-0x0000000000000017]
     CPU: 1…
laiyoufafa pushed a commit to laiyoufafa/kernel_linux_5.10 that referenced this issue Apr 24, 2023
…end"

stable inclusion
from stable-5.10.158
commit 5a6f935ef34e900a97064b070df4c945de631c2e
category: bugfix
issue: #I6WKGU
CVE: NA

Signed-off-by: Ywenrui44091 <yaowenrui2@huawei.com>
---------------------------------------

[ Upstream commit d9f15a9de44affe733e34f93bc184945ba277e6d ]

This reverts commit 232ccac1bd9b5bfe73895f527c08623e7fa0752d.

On the subject of suspend, the RISC-V SBI spec states:

  This does not cover whether any given events actually reach the hart or
  not, just what the hart will do if it receives an event. On PolarFire
  SoC, and potentially other SiFive based implementations, events from the
  RISC-V timer do reach a hart during suspend. This is not the case for the
  implementation on the Allwinner D1 - there timer events are not received
  during suspend.

To fix this, the CLOCK_EVT_FEAT_C3STOP (mis)feature was enabled for the
timer driver - but this has broken both RCU stall detection and timers
generally on PolarFire SoC and potentially other SiFive based
implementations.

If an AXI read to the PCIe controller on PolarFire SoC times out, the
system will stall, however, with CLOCK_EVT_FEAT_C3STOP active, the system
just locks up without RCU stalling:

        io scheduler mq-deadline registered
        io scheduler kyber registered
        microchip-pcie 2000000000.pcie: host bridge /soc/pcie@2000000000 ranges:
        microchip-pcie 2000000000.pcie:      MEM 0x2008000000..0x2087ffffff -> 0x0008000000
        microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer
        microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer
        microchip-pcie 2000000000.pcie: axi read request error
        microchip-pcie 2000000000.pcie: axi read timeout
        microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer
        microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer
        microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer
        microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer
        microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer
        microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer
        Freeing initrd memory: 7332K

Similarly issues were reported with clock_nanosleep() - with a test app
that sleeps each cpu for 6, 5, 4, 3 ms respectively, HZ=250 & the blamed
commit in place, the sleep times are rounded up to the next jiffy:

== CPU: 1 ==      == CPU: 2 ==      == CPU: 3 ==      == CPU: 4 ==
Mean: 7.974992    Mean: 7.976534    Mean: 7.962591    Mean: 3.952179
Std Dev: 0.154374 Std Dev: 0.156082 Std Dev: 0.171018 Std Dev: 0.076193
Hi: 9.472000      Hi: 10.495000     Hi: 8.864000      Hi: 4.736000
Lo: 6.087000      Lo: 6.380000      Lo: 4.872000      Lo: 3.403000
Samples: 521      Samples: 521      Samples: 521      Samples: 521

Fortunately, the D1 has a second timer, which is "currently used in
preference to the RISC-V/SBI timer driver" so a revert here does not
hurt operation of D1 in its current form.

Ultimately, a DeviceTree property (or node) will be added to encode the
behaviour of the timers, but until then revert the addition of
CLOCK_EVT_FEAT_C3STOP.

Fixes: 232ccac1bd9b ("clocksource/drivers/riscv: Events are stopped during CPU suspend")
Signed-off-by: Conor Dooley <conor.dooley@microchip.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Palmer Dabbelt <palmer@rivosinc.com>
Acked-by: Palmer Dabbelt <palmer@rivosinc.com>
Acked-by: Samuel Holland <samuel@sholland.org>
Link: https://lore.kernel.org/linux-riscv/YzYTNQRxLr7Q9JR0@spud/
Link: riscv-non-isa/riscv-sbi-doc#98
Link: https://lore.kernel.org/linux-riscv/bf6d3b1f-f703-4a25-833e-972a44a04114@sholland.org/
Link: https://lore.kernel.org/r/20221122121620.3522431-1-conor.dooley@microchip.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Ywenrui44091 <yaowenrui2@huawei.com>
jgudec pushed a commit to jgudec/android_kernel_samsung_exynos2200 that referenced this issue Jul 3, 2023
…end"

[ Upstream commit d9f15a9de44affe733e34f93bc184945ba277e6d ]

This reverts commit 232ccac1bd9b5bfe73895f527c08623e7fa0752d.

On the subject of suspend, the RISC-V SBI spec states:

  This does not cover whether any given events actually reach the hart or
  not, just what the hart will do if it receives an event. On PolarFire
  SoC, and potentially other SiFive based implementations, events from the
  RISC-V timer do reach a hart during suspend. This is not the case for the
  implementation on the Allwinner D1 - there timer events are not received
  during suspend.

To fix this, the CLOCK_EVT_FEAT_C3STOP (mis)feature was enabled for the
timer driver - but this has broken both RCU stall detection and timers
generally on PolarFire SoC and potentially other SiFive based
implementations.

If an AXI read to the PCIe controller on PolarFire SoC times out, the
system will stall, however, with CLOCK_EVT_FEAT_C3STOP active, the system
just locks up without RCU stalling:

	io scheduler mq-deadline registered
	io scheduler kyber registered
	microchip-pcie 2000000000.pcie: host bridge /soc/pcie@2000000000 ranges:
	microchip-pcie 2000000000.pcie:      MEM 0x2008000000..0x2087ffffff -> 0x0008000000
	microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: axi read request error
	microchip-pcie 2000000000.pcie: axi read timeout
	microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer
	Freeing initrd memory: 7332K

Similarly issues were reported with clock_nanosleep() - with a test app
that sleeps each cpu for 6, 5, 4, 3 ms respectively, HZ=250 & the blamed
commit in place, the sleep times are rounded up to the next jiffy:

== CPU: 1 ==      == CPU: 2 ==      == CPU: 3 ==      == CPU: 4 ==
Mean: 7.974992    Mean: 7.976534    Mean: 7.962591    Mean: 3.952179
Std Dev: 0.154374 Std Dev: 0.156082 Std Dev: 0.171018 Std Dev: 0.076193
Hi: 9.472000      Hi: 10.495000     Hi: 8.864000      Hi: 4.736000
Lo: 6.087000      Lo: 6.380000      Lo: 4.872000      Lo: 3.403000
Samples: 521      Samples: 521      Samples: 521      Samples: 521

Fortunately, the D1 has a second timer, which is "currently used in
preference to the RISC-V/SBI timer driver" so a revert here does not
hurt operation of D1 in its current form.

Ultimately, a DeviceTree property (or node) will be added to encode the
behaviour of the timers, but until then revert the addition of
CLOCK_EVT_FEAT_C3STOP.

Fixes: 232ccac1bd9b ("clocksource/drivers/riscv: Events are stopped during CPU suspend")
Signed-off-by: Conor Dooley <conor.dooley@microchip.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Palmer Dabbelt <palmer@rivosinc.com>
Acked-by: Palmer Dabbelt <palmer@rivosinc.com>
Acked-by: Samuel Holland <samuel@sholland.org>
Link: https://lore.kernel.org/linux-riscv/YzYTNQRxLr7Q9JR0@spud/
Link: riscv-non-isa/riscv-sbi-doc#98
Link: https://lore.kernel.org/linux-riscv/bf6d3b1f-f703-4a25-833e-972a44a04114@sholland.org/
Link: https://lore.kernel.org/r/20221122121620.3522431-1-conor.dooley@microchip.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
jgudec pushed a commit to jgudec/android_kernel_samsung_exynos2200 that referenced this issue Jul 3, 2023
…end"

[ Upstream commit d9f15a9de44affe733e34f93bc184945ba277e6d ]

This reverts commit 232ccac1bd9b5bfe73895f527c08623e7fa0752d.

On the subject of suspend, the RISC-V SBI spec states:

  This does not cover whether any given events actually reach the hart or
  not, just what the hart will do if it receives an event. On PolarFire
  SoC, and potentially other SiFive based implementations, events from the
  RISC-V timer do reach a hart during suspend. This is not the case for the
  implementation on the Allwinner D1 - there timer events are not received
  during suspend.

To fix this, the CLOCK_EVT_FEAT_C3STOP (mis)feature was enabled for the
timer driver - but this has broken both RCU stall detection and timers
generally on PolarFire SoC and potentially other SiFive based
implementations.

If an AXI read to the PCIe controller on PolarFire SoC times out, the
system will stall, however, with CLOCK_EVT_FEAT_C3STOP active, the system
just locks up without RCU stalling:

	io scheduler mq-deadline registered
	io scheduler kyber registered
	microchip-pcie 2000000000.pcie: host bridge /soc/pcie@2000000000 ranges:
	microchip-pcie 2000000000.pcie:      MEM 0x2008000000..0x2087ffffff -> 0x0008000000
	microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: axi read request error
	microchip-pcie 2000000000.pcie: axi read timeout
	microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer
	Freeing initrd memory: 7332K

Similarly issues were reported with clock_nanosleep() - with a test app
that sleeps each cpu for 6, 5, 4, 3 ms respectively, HZ=250 & the blamed
commit in place, the sleep times are rounded up to the next jiffy:

== CPU: 1 ==      == CPU: 2 ==      == CPU: 3 ==      == CPU: 4 ==
Mean: 7.974992    Mean: 7.976534    Mean: 7.962591    Mean: 3.952179
Std Dev: 0.154374 Std Dev: 0.156082 Std Dev: 0.171018 Std Dev: 0.076193
Hi: 9.472000      Hi: 10.495000     Hi: 8.864000      Hi: 4.736000
Lo: 6.087000      Lo: 6.380000      Lo: 4.872000      Lo: 3.403000
Samples: 521      Samples: 521      Samples: 521      Samples: 521

Fortunately, the D1 has a second timer, which is "currently used in
preference to the RISC-V/SBI timer driver" so a revert here does not
hurt operation of D1 in its current form.

Ultimately, a DeviceTree property (or node) will be added to encode the
behaviour of the timers, but until then revert the addition of
CLOCK_EVT_FEAT_C3STOP.

Fixes: 232ccac1bd9b ("clocksource/drivers/riscv: Events are stopped during CPU suspend")
Signed-off-by: Conor Dooley <conor.dooley@microchip.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Palmer Dabbelt <palmer@rivosinc.com>
Acked-by: Palmer Dabbelt <palmer@rivosinc.com>
Acked-by: Samuel Holland <samuel@sholland.org>
Link: https://lore.kernel.org/linux-riscv/YzYTNQRxLr7Q9JR0@spud/
Link: riscv-non-isa/riscv-sbi-doc#98
Link: https://lore.kernel.org/linux-riscv/bf6d3b1f-f703-4a25-833e-972a44a04114@sholland.org/
Link: https://lore.kernel.org/r/20221122121620.3522431-1-conor.dooley@microchip.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
jgudec pushed a commit to jgudec/android_kernel_samsung_exynos2200 that referenced this issue Jul 3, 2023
…end"

[ Upstream commit d9f15a9de44affe733e34f93bc184945ba277e6d ]

This reverts commit 232ccac1bd9b5bfe73895f527c08623e7fa0752d.

On the subject of suspend, the RISC-V SBI spec states:

  This does not cover whether any given events actually reach the hart or
  not, just what the hart will do if it receives an event. On PolarFire
  SoC, and potentially other SiFive based implementations, events from the
  RISC-V timer do reach a hart during suspend. This is not the case for the
  implementation on the Allwinner D1 - there timer events are not received
  during suspend.

To fix this, the CLOCK_EVT_FEAT_C3STOP (mis)feature was enabled for the
timer driver - but this has broken both RCU stall detection and timers
generally on PolarFire SoC and potentially other SiFive based
implementations.

If an AXI read to the PCIe controller on PolarFire SoC times out, the
system will stall, however, with CLOCK_EVT_FEAT_C3STOP active, the system
just locks up without RCU stalling:

	io scheduler mq-deadline registered
	io scheduler kyber registered
	microchip-pcie 2000000000.pcie: host bridge /soc/pcie@2000000000 ranges:
	microchip-pcie 2000000000.pcie:      MEM 0x2008000000..0x2087ffffff -> 0x0008000000
	microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: axi read request error
	microchip-pcie 2000000000.pcie: axi read timeout
	microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer
	Freeing initrd memory: 7332K

Similarly issues were reported with clock_nanosleep() - with a test app
that sleeps each cpu for 6, 5, 4, 3 ms respectively, HZ=250 & the blamed
commit in place, the sleep times are rounded up to the next jiffy:

== CPU: 1 ==      == CPU: 2 ==      == CPU: 3 ==      == CPU: 4 ==
Mean: 7.974992    Mean: 7.976534    Mean: 7.962591    Mean: 3.952179
Std Dev: 0.154374 Std Dev: 0.156082 Std Dev: 0.171018 Std Dev: 0.076193
Hi: 9.472000      Hi: 10.495000     Hi: 8.864000      Hi: 4.736000
Lo: 6.087000      Lo: 6.380000      Lo: 4.872000      Lo: 3.403000
Samples: 521      Samples: 521      Samples: 521      Samples: 521

Fortunately, the D1 has a second timer, which is "currently used in
preference to the RISC-V/SBI timer driver" so a revert here does not
hurt operation of D1 in its current form.

Ultimately, a DeviceTree property (or node) will be added to encode the
behaviour of the timers, but until then revert the addition of
CLOCK_EVT_FEAT_C3STOP.

Fixes: 232ccac1bd9b ("clocksource/drivers/riscv: Events are stopped during CPU suspend")
Signed-off-by: Conor Dooley <conor.dooley@microchip.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Palmer Dabbelt <palmer@rivosinc.com>
Acked-by: Palmer Dabbelt <palmer@rivosinc.com>
Acked-by: Samuel Holland <samuel@sholland.org>
Link: https://lore.kernel.org/linux-riscv/YzYTNQRxLr7Q9JR0@spud/
Link: riscv-non-isa/riscv-sbi-doc#98
Link: https://lore.kernel.org/linux-riscv/bf6d3b1f-f703-4a25-833e-972a44a04114@sholland.org/
Link: https://lore.kernel.org/r/20221122121620.3522431-1-conor.dooley@microchip.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
jgudec pushed a commit to jgudec/android_kernel_samsung_exynos2200 that referenced this issue Jul 3, 2023
…end"

[ Upstream commit d9f15a9de44affe733e34f93bc184945ba277e6d ]

This reverts commit 232ccac1bd9b5bfe73895f527c08623e7fa0752d.

On the subject of suspend, the RISC-V SBI spec states:

  This does not cover whether any given events actually reach the hart or
  not, just what the hart will do if it receives an event. On PolarFire
  SoC, and potentially other SiFive based implementations, events from the
  RISC-V timer do reach a hart during suspend. This is not the case for the
  implementation on the Allwinner D1 - there timer events are not received
  during suspend.

To fix this, the CLOCK_EVT_FEAT_C3STOP (mis)feature was enabled for the
timer driver - but this has broken both RCU stall detection and timers
generally on PolarFire SoC and potentially other SiFive based
implementations.

If an AXI read to the PCIe controller on PolarFire SoC times out, the
system will stall, however, with CLOCK_EVT_FEAT_C3STOP active, the system
just locks up without RCU stalling:

	io scheduler mq-deadline registered
	io scheduler kyber registered
	microchip-pcie 2000000000.pcie: host bridge /soc/pcie@2000000000 ranges:
	microchip-pcie 2000000000.pcie:      MEM 0x2008000000..0x2087ffffff -> 0x0008000000
	microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: axi read request error
	microchip-pcie 2000000000.pcie: axi read timeout
	microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer
	Freeing initrd memory: 7332K

Similarly issues were reported with clock_nanosleep() - with a test app
that sleeps each cpu for 6, 5, 4, 3 ms respectively, HZ=250 & the blamed
commit in place, the sleep times are rounded up to the next jiffy:

== CPU: 1 ==      == CPU: 2 ==      == CPU: 3 ==      == CPU: 4 ==
Mean: 7.974992    Mean: 7.976534    Mean: 7.962591    Mean: 3.952179
Std Dev: 0.154374 Std Dev: 0.156082 Std Dev: 0.171018 Std Dev: 0.076193
Hi: 9.472000      Hi: 10.495000     Hi: 8.864000      Hi: 4.736000
Lo: 6.087000      Lo: 6.380000      Lo: 4.872000      Lo: 3.403000
Samples: 521      Samples: 521      Samples: 521      Samples: 521

Fortunately, the D1 has a second timer, which is "currently used in
preference to the RISC-V/SBI timer driver" so a revert here does not
hurt operation of D1 in its current form.

Ultimately, a DeviceTree property (or node) will be added to encode the
behaviour of the timers, but until then revert the addition of
CLOCK_EVT_FEAT_C3STOP.

Fixes: 232ccac1bd9b ("clocksource/drivers/riscv: Events are stopped during CPU suspend")
Signed-off-by: Conor Dooley <conor.dooley@microchip.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Palmer Dabbelt <palmer@rivosinc.com>
Acked-by: Palmer Dabbelt <palmer@rivosinc.com>
Acked-by: Samuel Holland <samuel@sholland.org>
Link: https://lore.kernel.org/linux-riscv/YzYTNQRxLr7Q9JR0@spud/
Link: riscv-non-isa/riscv-sbi-doc#98
Link: https://lore.kernel.org/linux-riscv/bf6d3b1f-f703-4a25-833e-972a44a04114@sholland.org/
Link: https://lore.kernel.org/r/20221122121620.3522431-1-conor.dooley@microchip.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
jgudec pushed a commit to jgudec/android_kernel_samsung_exynos2200 that referenced this issue Jul 3, 2023
…end"

[ Upstream commit d9f15a9de44affe733e34f93bc184945ba277e6d ]

This reverts commit 232ccac1bd9b5bfe73895f527c08623e7fa0752d.

On the subject of suspend, the RISC-V SBI spec states:

  This does not cover whether any given events actually reach the hart or
  not, just what the hart will do if it receives an event. On PolarFire
  SoC, and potentially other SiFive based implementations, events from the
  RISC-V timer do reach a hart during suspend. This is not the case for the
  implementation on the Allwinner D1 - there timer events are not received
  during suspend.

To fix this, the CLOCK_EVT_FEAT_C3STOP (mis)feature was enabled for the
timer driver - but this has broken both RCU stall detection and timers
generally on PolarFire SoC and potentially other SiFive based
implementations.

If an AXI read to the PCIe controller on PolarFire SoC times out, the
system will stall, however, with CLOCK_EVT_FEAT_C3STOP active, the system
just locks up without RCU stalling:

	io scheduler mq-deadline registered
	io scheduler kyber registered
	microchip-pcie 2000000000.pcie: host bridge /soc/pcie@2000000000 ranges:
	microchip-pcie 2000000000.pcie:      MEM 0x2008000000..0x2087ffffff -> 0x0008000000
	microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: axi read request error
	microchip-pcie 2000000000.pcie: axi read timeout
	microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer
	Freeing initrd memory: 7332K

Similarly issues were reported with clock_nanosleep() - with a test app
that sleeps each cpu for 6, 5, 4, 3 ms respectively, HZ=250 & the blamed
commit in place, the sleep times are rounded up to the next jiffy:

== CPU: 1 ==      == CPU: 2 ==      == CPU: 3 ==      == CPU: 4 ==
Mean: 7.974992    Mean: 7.976534    Mean: 7.962591    Mean: 3.952179
Std Dev: 0.154374 Std Dev: 0.156082 Std Dev: 0.171018 Std Dev: 0.076193
Hi: 9.472000      Hi: 10.495000     Hi: 8.864000      Hi: 4.736000
Lo: 6.087000      Lo: 6.380000      Lo: 4.872000      Lo: 3.403000
Samples: 521      Samples: 521      Samples: 521      Samples: 521

Fortunately, the D1 has a second timer, which is "currently used in
preference to the RISC-V/SBI timer driver" so a revert here does not
hurt operation of D1 in its current form.

Ultimately, a DeviceTree property (or node) will be added to encode the
behaviour of the timers, but until then revert the addition of
CLOCK_EVT_FEAT_C3STOP.

Fixes: 232ccac1bd9b ("clocksource/drivers/riscv: Events are stopped during CPU suspend")
Signed-off-by: Conor Dooley <conor.dooley@microchip.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Palmer Dabbelt <palmer@rivosinc.com>
Acked-by: Palmer Dabbelt <palmer@rivosinc.com>
Acked-by: Samuel Holland <samuel@sholland.org>
Link: https://lore.kernel.org/linux-riscv/YzYTNQRxLr7Q9JR0@spud/
Link: riscv-non-isa/riscv-sbi-doc#98
Link: https://lore.kernel.org/linux-riscv/bf6d3b1f-f703-4a25-833e-972a44a04114@sholland.org/
Link: https://lore.kernel.org/r/20221122121620.3522431-1-conor.dooley@microchip.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
jgudec pushed a commit to jgudec/android_kernel_samsung_exynos2200 that referenced this issue Jul 4, 2023
…end"

[ Upstream commit d9f15a9de44affe733e34f93bc184945ba277e6d ]

This reverts commit 232ccac1bd9b5bfe73895f527c08623e7fa0752d.

On the subject of suspend, the RISC-V SBI spec states:

  This does not cover whether any given events actually reach the hart or
  not, just what the hart will do if it receives an event. On PolarFire
  SoC, and potentially other SiFive based implementations, events from the
  RISC-V timer do reach a hart during suspend. This is not the case for the
  implementation on the Allwinner D1 - there timer events are not received
  during suspend.

To fix this, the CLOCK_EVT_FEAT_C3STOP (mis)feature was enabled for the
timer driver - but this has broken both RCU stall detection and timers
generally on PolarFire SoC and potentially other SiFive based
implementations.

If an AXI read to the PCIe controller on PolarFire SoC times out, the
system will stall, however, with CLOCK_EVT_FEAT_C3STOP active, the system
just locks up without RCU stalling:

	io scheduler mq-deadline registered
	io scheduler kyber registered
	microchip-pcie 2000000000.pcie: host bridge /soc/pcie@2000000000 ranges:
	microchip-pcie 2000000000.pcie:      MEM 0x2008000000..0x2087ffffff -> 0x0008000000
	microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: axi read request error
	microchip-pcie 2000000000.pcie: axi read timeout
	microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer
	Freeing initrd memory: 7332K

Similarly issues were reported with clock_nanosleep() - with a test app
that sleeps each cpu for 6, 5, 4, 3 ms respectively, HZ=250 & the blamed
commit in place, the sleep times are rounded up to the next jiffy:

== CPU: 1 ==      == CPU: 2 ==      == CPU: 3 ==      == CPU: 4 ==
Mean: 7.974992    Mean: 7.976534    Mean: 7.962591    Mean: 3.952179
Std Dev: 0.154374 Std Dev: 0.156082 Std Dev: 0.171018 Std Dev: 0.076193
Hi: 9.472000      Hi: 10.495000     Hi: 8.864000      Hi: 4.736000
Lo: 6.087000      Lo: 6.380000      Lo: 4.872000      Lo: 3.403000
Samples: 521      Samples: 521      Samples: 521      Samples: 521

Fortunately, the D1 has a second timer, which is "currently used in
preference to the RISC-V/SBI timer driver" so a revert here does not
hurt operation of D1 in its current form.

Ultimately, a DeviceTree property (or node) will be added to encode the
behaviour of the timers, but until then revert the addition of
CLOCK_EVT_FEAT_C3STOP.

Fixes: 232ccac1bd9b ("clocksource/drivers/riscv: Events are stopped during CPU suspend")
Signed-off-by: Conor Dooley <conor.dooley@microchip.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Palmer Dabbelt <palmer@rivosinc.com>
Acked-by: Palmer Dabbelt <palmer@rivosinc.com>
Acked-by: Samuel Holland <samuel@sholland.org>
Link: https://lore.kernel.org/linux-riscv/YzYTNQRxLr7Q9JR0@spud/
Link: riscv-non-isa/riscv-sbi-doc#98
Link: https://lore.kernel.org/linux-riscv/bf6d3b1f-f703-4a25-833e-972a44a04114@sholland.org/
Link: https://lore.kernel.org/r/20221122121620.3522431-1-conor.dooley@microchip.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
wanghao75 pushed a commit to openeuler-mirror/kernel that referenced this issue Jul 27, 2023
…end"

stable inclusion
from stable-v5.10.158
commit 5a6f935ef34e900a97064b070df4c945de631c2e
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I7NTXH

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=5a6f935ef34e900a97064b070df4c945de631c2e

--------------------------------

[ Upstream commit d9f15a9 ]

This reverts commit 232ccac.

On the subject of suspend, the RISC-V SBI spec states:

  This does not cover whether any given events actually reach the hart or
  not, just what the hart will do if it receives an event. On PolarFire
  SoC, and potentially other SiFive based implementations, events from the
  RISC-V timer do reach a hart during suspend. This is not the case for the
  implementation on the Allwinner D1 - there timer events are not received
  during suspend.

To fix this, the CLOCK_EVT_FEAT_C3STOP (mis)feature was enabled for the
timer driver - but this has broken both RCU stall detection and timers
generally on PolarFire SoC and potentially other SiFive based
implementations.

If an AXI read to the PCIe controller on PolarFire SoC times out, the
system will stall, however, with CLOCK_EVT_FEAT_C3STOP active, the system
just locks up without RCU stalling:

	io scheduler mq-deadline registered
	io scheduler kyber registered
	microchip-pcie 2000000000.pcie: host bridge /soc/pcie@2000000000 ranges:
	microchip-pcie 2000000000.pcie:      MEM 0x2008000000..0x2087ffffff -> 0x0008000000
	microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: axi read request error
	microchip-pcie 2000000000.pcie: axi read timeout
	microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer
	Freeing initrd memory: 7332K

Similarly issues were reported with clock_nanosleep() - with a test app
that sleeps each cpu for 6, 5, 4, 3 ms respectively, HZ=250 & the blamed
commit in place, the sleep times are rounded up to the next jiffy:

== CPU: 1 ==      == CPU: 2 ==      == CPU: 3 ==      == CPU: 4 ==
Mean: 7.974992    Mean: 7.976534    Mean: 7.962591    Mean: 3.952179
Std Dev: 0.154374 Std Dev: 0.156082 Std Dev: 0.171018 Std Dev: 0.076193
Hi: 9.472000      Hi: 10.495000     Hi: 8.864000      Hi: 4.736000
Lo: 6.087000      Lo: 6.380000      Lo: 4.872000      Lo: 3.403000
Samples: 521      Samples: 521      Samples: 521      Samples: 521

Fortunately, the D1 has a second timer, which is "currently used in
preference to the RISC-V/SBI timer driver" so a revert here does not
hurt operation of D1 in its current form.

Ultimately, a DeviceTree property (or node) will be added to encode the
behaviour of the timers, but until then revert the addition of
CLOCK_EVT_FEAT_C3STOP.

Fixes: 232ccac ("clocksource/drivers/riscv: Events are stopped during CPU suspend")
Signed-off-by: Conor Dooley <conor.dooley@microchip.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Palmer Dabbelt <palmer@rivosinc.com>
Acked-by: Palmer Dabbelt <palmer@rivosinc.com>
Acked-by: Samuel Holland <samuel@sholland.org>
Link: https://lore.kernel.org/linux-riscv/YzYTNQRxLr7Q9JR0@spud/
Link: riscv-non-isa/riscv-sbi-doc#98
Link: https://lore.kernel.org/linux-riscv/bf6d3b1f-f703-4a25-833e-972a44a04114@sholland.org/
Link: https://lore.kernel.org/r/20221122121620.3522431-1-conor.dooley@microchip.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: sanglipeng <sanglipeng1@jd.com>
wanghao75 pushed a commit to openeuler-mirror/kernel that referenced this issue Aug 2, 2023
…end"

stable inclusion
from stable-v5.10.158
commit 5a6f935ef34e900a97064b070df4c945de631c2e
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I7NTXH

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=5a6f935ef34e900a97064b070df4c945de631c2e

--------------------------------

[ Upstream commit d9f15a9 ]

This reverts commit 232ccac.

On the subject of suspend, the RISC-V SBI spec states:

  This does not cover whether any given events actually reach the hart or
  not, just what the hart will do if it receives an event. On PolarFire
  SoC, and potentially other SiFive based implementations, events from the
  RISC-V timer do reach a hart during suspend. This is not the case for the
  implementation on the Allwinner D1 - there timer events are not received
  during suspend.

To fix this, the CLOCK_EVT_FEAT_C3STOP (mis)feature was enabled for the
timer driver - but this has broken both RCU stall detection and timers
generally on PolarFire SoC and potentially other SiFive based
implementations.

If an AXI read to the PCIe controller on PolarFire SoC times out, the
system will stall, however, with CLOCK_EVT_FEAT_C3STOP active, the system
just locks up without RCU stalling:

	io scheduler mq-deadline registered
	io scheduler kyber registered
	microchip-pcie 2000000000.pcie: host bridge /soc/pcie@2000000000 ranges:
	microchip-pcie 2000000000.pcie:      MEM 0x2008000000..0x2087ffffff -> 0x0008000000
	microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: axi read request error
	microchip-pcie 2000000000.pcie: axi read timeout
	microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer
	Freeing initrd memory: 7332K

Similarly issues were reported with clock_nanosleep() - with a test app
that sleeps each cpu for 6, 5, 4, 3 ms respectively, HZ=250 & the blamed
commit in place, the sleep times are rounded up to the next jiffy:

== CPU: 1 ==      == CPU: 2 ==      == CPU: 3 ==      == CPU: 4 ==
Mean: 7.974992    Mean: 7.976534    Mean: 7.962591    Mean: 3.952179
Std Dev: 0.154374 Std Dev: 0.156082 Std Dev: 0.171018 Std Dev: 0.076193
Hi: 9.472000      Hi: 10.495000     Hi: 8.864000      Hi: 4.736000
Lo: 6.087000      Lo: 6.380000      Lo: 4.872000      Lo: 3.403000
Samples: 521      Samples: 521      Samples: 521      Samples: 521

Fortunately, the D1 has a second timer, which is "currently used in
preference to the RISC-V/SBI timer driver" so a revert here does not
hurt operation of D1 in its current form.

Ultimately, a DeviceTree property (or node) will be added to encode the
behaviour of the timers, but until then revert the addition of
CLOCK_EVT_FEAT_C3STOP.

Fixes: 232ccac ("clocksource/drivers/riscv: Events are stopped during CPU suspend")
Signed-off-by: Conor Dooley <conor.dooley@microchip.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Palmer Dabbelt <palmer@rivosinc.com>
Acked-by: Palmer Dabbelt <palmer@rivosinc.com>
Acked-by: Samuel Holland <samuel@sholland.org>
Link: https://lore.kernel.org/linux-riscv/YzYTNQRxLr7Q9JR0@spud/
Link: riscv-non-isa/riscv-sbi-doc#98
Link: https://lore.kernel.org/linux-riscv/bf6d3b1f-f703-4a25-833e-972a44a04114@sholland.org/
Link: https://lore.kernel.org/r/20221122121620.3522431-1-conor.dooley@microchip.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: sanglipeng <sanglipeng1@jd.com>
(cherry picked from commit c651d65)
Dheeraj3031A pushed a commit to Dheeraj3031A/kernel_oplus_RMX3461 that referenced this issue Apr 3, 2024
…end"

[ Upstream commit d9f15a9de44affe733e34f93bc184945ba277e6d ]

This reverts commit 232ccac1bd9b5bfe73895f527c08623e7fa0752d.

On the subject of suspend, the RISC-V SBI spec states:

  This does not cover whether any given events actually reach the hart or
  not, just what the hart will do if it receives an event. On PolarFire
  SoC, and potentially other SiFive based implementations, events from the
  RISC-V timer do reach a hart during suspend. This is not the case for the
  implementation on the Allwinner D1 - there timer events are not received
  during suspend.

To fix this, the CLOCK_EVT_FEAT_C3STOP (mis)feature was enabled for the
timer driver - but this has broken both RCU stall detection and timers
generally on PolarFire SoC and potentially other SiFive based
implementations.

If an AXI read to the PCIe controller on PolarFire SoC times out, the
system will stall, however, with CLOCK_EVT_FEAT_C3STOP active, the system
just locks up without RCU stalling:

	io scheduler mq-deadline registered
	io scheduler kyber registered
	microchip-pcie 2000000000.pcie: host bridge /soc/pcie@2000000000 ranges:
	microchip-pcie 2000000000.pcie:      MEM 0x2008000000..0x2087ffffff -> 0x0008000000
	microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: axi read request error
	microchip-pcie 2000000000.pcie: axi read timeout
	microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: sec error in pcie2axi buffer
	microchip-pcie 2000000000.pcie: ded error in pcie2axi buffer
	Freeing initrd memory: 7332K

Similarly issues were reported with clock_nanosleep() - with a test app
that sleeps each cpu for 6, 5, 4, 3 ms respectively, HZ=250 & the blamed
commit in place, the sleep times are rounded up to the next jiffy:

== CPU: 1 ==      == CPU: 2 ==      == CPU: 3 ==      == CPU: 4 ==
Mean: 7.974992    Mean: 7.976534    Mean: 7.962591    Mean: 3.952179
Std Dev: 0.154374 Std Dev: 0.156082 Std Dev: 0.171018 Std Dev: 0.076193
Hi: 9.472000      Hi: 10.495000     Hi: 8.864000      Hi: 4.736000
Lo: 6.087000      Lo: 6.380000      Lo: 4.872000      Lo: 3.403000
Samples: 521      Samples: 521      Samples: 521      Samples: 521

Fortunately, the D1 has a second timer, which is "currently used in
preference to the RISC-V/SBI timer driver" so a revert here does not
hurt operation of D1 in its current form.

Ultimately, a DeviceTree property (or node) will be added to encode the
behaviour of the timers, but until then revert the addition of
CLOCK_EVT_FEAT_C3STOP.

Fixes: 232ccac1bd9b ("clocksource/drivers/riscv: Events are stopped during CPU suspend")
Signed-off-by: Conor Dooley <conor.dooley@microchip.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Palmer Dabbelt <palmer@rivosinc.com>
Acked-by: Palmer Dabbelt <palmer@rivosinc.com>
Acked-by: Samuel Holland <samuel@sholland.org>
Link: https://lore.kernel.org/linux-riscv/YzYTNQRxLr7Q9JR0@spud/
Link: riscv-non-isa/riscv-sbi-doc#98
Link: https://lore.kernel.org/linux-riscv/bf6d3b1f-f703-4a25-833e-972a44a04114@sholland.org/
Link: https://lore.kernel.org/r/20221122121620.3522431-1-conor.dooley@microchip.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants