All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Xu Qiang <xuqiang36@huawei.com>, Marc Zyngier <maz@kernel.org>,
	Sasha Levin <sashal@kernel.org>
Subject: [PATCH AUTOSEL 5.4 13/23] irqchip/gic-v3-its: Unconditionally save/restore the ITS state on suspend
Date: Thu,  3 Dec 2020 08:29:25 -0500	[thread overview]
Message-ID: <20201203132935.931362-13-sashal@kernel.org> (raw)
In-Reply-To: <20201203132935.931362-1-sashal@kernel.org>

From: Xu Qiang <xuqiang36@huawei.com>

[ Upstream commit 74cde1a53368aed4f2b4b54bf7030437f64a534b ]

On systems without HW-based collections (i.e. anything except GIC-500),
we rely on firmware to perform the ITS save/restore. This doesn't
really work, as although FW can properly save everything, it cannot
fully restore the state of the command queue (the read-side is reset
to the head of the queue). This results in the ITS consuming previously
processed commands, potentially corrupting the state.

Instead, let's always save the ITS state on suspend, disabling it in the
process, and restore the full state on resume. This saves us from broken
FW as long as it doesn't enable the ITS by itself (for which we can't do
anything).

This amounts to simply dropping the ITS_FLAGS_SAVE_SUSPEND_STATE.

Signed-off-by: Xu Qiang <xuqiang36@huawei.com>
[maz: added warning on resume, rewrote commit message]
Signed-off-by: Marc Zyngier <maz@kernel.org>
Link: https://lore.kernel.org/r/20201107104226.14282-1-xuqiang36@huawei.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/irqchip/irq-gic-v3-its.c | 16 +++-------------
 1 file changed, 3 insertions(+), 13 deletions(-)

diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c
index 7966b19ceba79..f298313b87ac7 100644
--- a/drivers/irqchip/irq-gic-v3-its.c
+++ b/drivers/irqchip/irq-gic-v3-its.c
@@ -40,7 +40,6 @@
 #define ITS_FLAGS_CMDQ_NEEDS_FLUSHING		(1ULL << 0)
 #define ITS_FLAGS_WORKAROUND_CAVIUM_22375	(1ULL << 1)
 #define ITS_FLAGS_WORKAROUND_CAVIUM_23144	(1ULL << 2)
-#define ITS_FLAGS_SAVE_SUSPEND_STATE		(1ULL << 3)
 
 #define RDIST_FLAGS_PROPBASE_NEEDS_FLUSHING	(1 << 0)
 #define RDIST_FLAGS_RD_TABLES_PREALLOCATED	(1 << 1)
@@ -3367,9 +3366,6 @@ static int its_save_disable(void)
 	list_for_each_entry(its, &its_nodes, entry) {
 		void __iomem *base;
 
-		if (!(its->flags & ITS_FLAGS_SAVE_SUSPEND_STATE))
-			continue;
-
 		base = its->base;
 		its->ctlr_save = readl_relaxed(base + GITS_CTLR);
 		err = its_force_quiescent(base);
@@ -3388,9 +3384,6 @@ static int its_save_disable(void)
 		list_for_each_entry_continue_reverse(its, &its_nodes, entry) {
 			void __iomem *base;
 
-			if (!(its->flags & ITS_FLAGS_SAVE_SUSPEND_STATE))
-				continue;
-
 			base = its->base;
 			writel_relaxed(its->ctlr_save, base + GITS_CTLR);
 		}
@@ -3410,9 +3403,6 @@ static void its_restore_enable(void)
 		void __iomem *base;
 		int i;
 
-		if (!(its->flags & ITS_FLAGS_SAVE_SUSPEND_STATE))
-			continue;
-
 		base = its->base;
 
 		/*
@@ -3420,7 +3410,10 @@ static void its_restore_enable(void)
 		 * don't restore it since writing to CBASER or BASER<n>
 		 * registers is undefined according to the GIC v3 ITS
 		 * Specification.
+		 *
+		 * Firmware resuming with the ITS enabled is terminally broken.
 		 */
+		WARN_ON(readl_relaxed(base + GITS_CTLR) & GITS_CTLR_ENABLE);
 		ret = its_force_quiescent(base);
 		if (ret) {
 			pr_err("ITS@%pa: failed to quiesce on resume: %d\n",
@@ -3687,9 +3680,6 @@ static int __init its_probe_one(struct resource *res,
 		ctlr |= GITS_CTLR_ImDe;
 	writel_relaxed(ctlr, its->base + GITS_CTLR);
 
-	if (GITS_TYPER_HCC(typer))
-		its->flags |= ITS_FLAGS_SAVE_SUSPEND_STATE;
-
 	err = its_init_domain(handle, its);
 	if (err)
 		goto out_free_tables;
-- 
2.27.0


  parent reply	other threads:[~2020-12-03 13:33 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-03 13:29 [PATCH AUTOSEL 5.4 01/23] iwlwifi: pcie: limit memory read spin time Sasha Levin
2020-12-03 13:29 ` [PATCH AUTOSEL 5.4 02/23] arm64: dts: rockchip: Assign a fixed index to mmc devices on rk3399 boards Sasha Levin
2020-12-03 13:29   ` Sasha Levin
2020-12-03 13:29   ` Sasha Levin
2020-12-03 13:29 ` [PATCH AUTOSEL 5.4 03/23] iwlwifi: pcie: set LTR to avoid completion timeout Sasha Levin
2020-12-03 13:29 ` [PATCH AUTOSEL 5.4 04/23] iwlwifi: mvm: fix kernel panic in case of assert during CSA Sasha Levin
2020-12-03 13:29 ` [PATCH AUTOSEL 5.4 05/23] powerpc: Drop -me200 addition to build flags Sasha Levin
2020-12-03 13:29   ` Sasha Levin
2020-12-03 13:29 ` [PATCH AUTOSEL 5.4 06/23] arm64: dts: broadcom: clear the warnings caused by empty dma-ranges Sasha Levin
2020-12-03 13:29   ` Sasha Levin
2020-12-03 13:29 ` [PATCH AUTOSEL 5.4 07/23] ARC: stack unwinding: don't assume non-current task is sleeping Sasha Levin
2020-12-03 13:29   ` Sasha Levin
2020-12-03 13:29 ` [PATCH AUTOSEL 5.4 08/23] scsi: ufs: Make sure clk scaling happens only when HBA is runtime ACTIVE Sasha Levin
2020-12-03 13:29   ` Sasha Levin
2020-12-03 13:29   ` Sasha Levin
2020-12-03 13:29 ` [PATCH AUTOSEL 5.4 09/23] interconnect: qcom: qcs404: Remove GPU and display RPM IDs Sasha Levin
2020-12-03 13:29 ` [PATCH AUTOSEL 5.4 10/23] usbnet: ipheth: fix connectivity with iOS 14 Sasha Levin
2020-12-03 13:29 ` [PATCH AUTOSEL 5.4 11/23] tun: honor IOCB_NOWAIT flag Sasha Levin
2020-12-03 13:29 ` [PATCH AUTOSEL 5.4 12/23] ibmvnic: skip tx timeout reset while in resetting Sasha Levin
2020-12-03 13:29   ` Sasha Levin
2020-12-03 13:29 ` Sasha Levin [this message]
2020-12-03 13:29 ` [PATCH AUTOSEL 5.4 14/23] spi: spi-nxp-fspi: fix fspi panic by unexpected interrupts Sasha Levin
2020-12-03 13:29 ` [PATCH AUTOSEL 5.4 15/23] soc: fsl: dpio: Get the cpumask through cpumask_of(cpu) Sasha Levin
2020-12-03 13:29   ` Sasha Levin
2020-12-03 13:29   ` Sasha Levin
2020-12-03 13:29 ` [PATCH AUTOSEL 5.4 16/23] arm64: tegra: Disable the ACONNECT for Jetson TX2 Sasha Levin
2020-12-03 13:29 ` [PATCH AUTOSEL 5.4 17/23] platform/x86: thinkpad_acpi: Do not report SW_TABLET_MODE on Yoga 11e Sasha Levin
2020-12-03 13:29 ` [PATCH AUTOSEL 5.4 18/23] platform/x86: thinkpad_acpi: Add BAT1 is primary battery quirk for Thinkpad Yoga 11e 4th gen Sasha Levin
2020-12-03 13:29 ` [PATCH AUTOSEL 5.4 19/23] platform/x86: acer-wmi: add automatic keyboard background light toggle key as KEY_LIGHTS_TOGGLE Sasha Levin
2020-12-03 13:29 ` [PATCH AUTOSEL 5.4 20/23] platform/x86: intel-vbtn: Support for tablet mode on HP Pavilion 13 x360 PC Sasha Levin
2020-12-03 13:29 ` [PATCH AUTOSEL 5.4 21/23] platform/x86: touchscreen_dmi: Add info for the Irbis TW118 tablet Sasha Levin
2020-12-03 13:29 ` [PATCH AUTOSEL 5.4 22/23] can: m_can: m_can_dev_setup(): add support for bosch mcan version 3.3.0 Sasha Levin
2020-12-03 13:29 ` [PATCH AUTOSEL 5.4 23/23] can: af_can: can_rx_unregister(): remove WARN() statement from list operation sanity check Sasha Levin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201203132935.931362-13-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maz@kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=xuqiang36@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.