Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp490785pxu; Thu, 3 Dec 2020 05:39:21 -0800 (PST) X-Google-Smtp-Source: ABdhPJw5Deo0l3Lg5P0xijtg6dcYpGITOFtbDCwY0njJvuxYEGeJ1H4SJPrXHfjVAMzSX7neRfN0 X-Received: by 2002:a17:906:a2d0:: with SMTP id by16mr2467114ejb.207.1607002761276; Thu, 03 Dec 2020 05:39:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607002761; cv=none; d=google.com; s=arc-20160816; b=WOO3JCMXzkvi79QhNh1AUcdWNybZ6KWT5RQ+d8nH2yOzWLExrXuU96I80zxEZYPioX N2b1t25RmcSNj50Hm/mxmtNXE9dFcMbFoGhqHzhvinZQA2Q4FHCkLNbobFUtHKZ/EFn2 reAnjqUk/jArhuwUfAo8ZeB4nfYSLWlA2Dg6GhbPe1AVl7zEJjhjF4yTyp0V3XAXiT7B /2O0g28JTVyp8u5KtRjynMYM1Xd/8xybVCgJED2QoVLQDDo0HuW9aB/2FBdWBbviG6GM J8dDJ+5zK8nYnt+m60kpJMOoD8jxxER0MUZaQF8Weu45iQAGb7vOXyWPrbMiuuErOrvN ibjw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=bsmULpypLQxfqbStgq9g6SixxKI4++vvpPJkDAOyQ1M=; b=wMp5PbGfEGEAQDaldOC6oL9tMNbsNPrklWwd/cEhkpEVJl+w2uxcgCg/nh02O9swJN 3f3EipFrboKWg2pZisTK+IjAJlDmAa00qB69LJE86tKnjvVjkHtbE/QKV926tHQH0PeM Vtyz3lyjm5mOAnqAxyoUDbsIFTea5U5s1SCVGMedAmyKwhk83NKc/MEUV25fs76m8/yN 3Q9NEQDqkzsUuWp4i0if420z+MXgHXzgnXIyKf6lKi+3urJTRNlqqDvgskprEtIgRZ0o kYVZwqBBTfGsmGM/NCYbl0ZA9Rf79nsQ1wj1XPo85ppJ9VSNxPwdYtdR3PVilZIhRtyk 3ooA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m7si1056623edq.548.2020.12.03.05.38.53; Thu, 03 Dec 2020 05:39:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2437080AbgLCNgq (ORCPT + 99 others); Thu, 3 Dec 2020 08:36:46 -0500 Received: from mail.kernel.org ([198.145.29.99]:48820 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2436656AbgLCNaj (ORCPT ); Thu, 3 Dec 2020 08:30:39 -0500 From: Sasha Levin Authentication-Results: mail.kernel.org; dkim=permerror (bad message/signature format) To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Xu Qiang , Marc Zyngier , Sasha Levin Subject: [PATCH AUTOSEL 5.9 19/39] irqchip/gic-v3-its: Unconditionally save/restore the ITS state on suspend Date: Thu, 3 Dec 2020 08:28:13 -0500 Message-Id: <20201203132834.930999-19-sashal@kernel.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20201203132834.930999-1-sashal@kernel.org> References: <20201203132834.930999-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Xu Qiang [ 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 [maz: added warning on resume, rewrote commit message] Signed-off-by: Marc Zyngier Link: https://lore.kernel.org/r/20201107104226.14282-1-xuqiang36@huawei.com Signed-off-by: Sasha Levin --- 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 548de7538632a..51b8743fdda03 100644 --- a/drivers/irqchip/irq-gic-v3-its.c +++ b/drivers/irqchip/irq-gic-v3-its.c @@ -42,7 +42,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) @@ -4735,9 +4734,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); @@ -4756,9 +4752,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); } @@ -4778,9 +4771,6 @@ static void its_restore_enable(void) void __iomem *base; int i; - if (!(its->flags & ITS_FLAGS_SAVE_SUSPEND_STATE)) - continue; - base = its->base; /* @@ -4788,7 +4778,10 @@ static void its_restore_enable(void) * don't restore it since writing to CBASER or BASER * 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", @@ -5068,9 +5061,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