Received: by 10.223.176.5 with SMTP id f5csp93103wra; Fri, 2 Feb 2018 17:33:01 -0800 (PST) X-Google-Smtp-Source: AH8x225BYl/7CiUpycvIsX1YyJVMyBS/R6ZCgFgfYsoq/0mv/cJjRd4Hob/0mcsPVC0lR5y5tdM3 X-Received: by 2002:a17:902:e83:: with SMTP id 3-v6mr30851157plx.274.1517621581863; Fri, 02 Feb 2018 17:33:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517621581; cv=none; d=google.com; s=arc-20160816; b=B1Fn6qMoG0flSZRG1pSpL+YxdgxdNWNcYjiz5c9FfgPUfchKFi4qMvpxqOMf+12u6w xZCmTK5pbrZ4j8jYyrsnFWwcTT9cDuTc6q85eZG8h8aNTV0eYqfoy0FuddhjFOqjGQXf XLdoMXU+nlRpwgv7prO7Qa4P41VhkXMbpJmgpIBGRhLYsp5X8xDHXqq1Wb0LQskvClJW CTl9YP4xLe58CrVqyIzZtylMqUx8X09kDqPLkXbKtKm8mzdUDskOIOSPGhPhYESFF2VV xlx2d4LIn32iubeJCeNcsVbibket6I2lj8cRt5yqXmH6tWrzQI3JsFm4xad0RdesYrW/ mH/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=TgKuQio5vaCX+XiLgsu0GCVHobPEdTc/jPrTD507AWw=; b=dX7z6BcXvd16QbpwldWeH7y3ic2MeVQaeoDe6w6XTnVVOXbTMQdG8lvmwPHYE+7Th4 WyQfxiabO0lNb/MuOZAHq4vphH+zdLFZXBpHZYL4u86X99A5IrSvF3p5nyUqBkK07M3t 7x9R/OXPjgN3tbSVrB9HnzJYLurT0psDbLBW0SGBMUinhU5CtRfSwjQchpsm5NmcwcU8 8+3VkMLw8cG8pJfHOgQN9wbX0ltnA9WpY2CMhw4gUHK0Q+KCVZUN7+9sj54xXei6re+O lAL1f165+cVtmqBb7aoH1VpoRRoxnFcvByTphuCHDYTz3XH4rdV7/R3xGmzwxsxiUcgX 5fag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=ID09U5mY; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o32-v6si2753960pld.52.2018.02.02.17.32.46; Fri, 02 Feb 2018 17:33:01 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=ID09U5mY; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751822AbeBCB0z (ORCPT + 99 others); Fri, 2 Feb 2018 20:26:55 -0500 Received: from mail-pl0-f68.google.com ([209.85.160.68]:37591 "EHLO mail-pl0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752520AbeBCBZB (ORCPT ); Fri, 2 Feb 2018 20:25:01 -0500 Received: by mail-pl0-f68.google.com with SMTP id ay8so7484187plb.4 for ; Fri, 02 Feb 2018 17:25:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=TgKuQio5vaCX+XiLgsu0GCVHobPEdTc/jPrTD507AWw=; b=ID09U5mYM2hbLDCqyzlnssOszKw+Q5LS6JjtDv5GuOr6gUli7e6l1a41zQcfIWx6Ly 4QEEXm9nu7hsDytCu3YpXafTcTe5XAyJNmUXvosxJ0pbSVEW59hdSvOpxjQN9Sq4T/lI ZPwZndSGpyn4OU8bu0YwWItyG0ylBWaKTTnv0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=TgKuQio5vaCX+XiLgsu0GCVHobPEdTc/jPrTD507AWw=; b=K7XTGP4ZrbiQ3m5GbSG9EVgLpD567WKJ728DO0tQxqfp4skf24YjzvfcjFKFjTT6oz VtyZNKd+V0w1vQtDBuatERR3FHPhQ5J5lOqkazERpWpEqbWlckbqXBq/iX71cGIVUczX V0Izsc/75W2+xwPCItx7xZBcbmeaUCECVdM21/+INbqdgSamuZOojNrBFTbZTX222uq+ PUxXfvH6ZLNhUSYMrwhL6QGbsqwPYnMWcpqUK0oFNSTmkD7Wv+3raDmORne65fYqIJYq gCs13OGb9w0ll/0T34nSu9VZrlA/Z+NTtKsEh9fUVXGtlWg3mhJolM7S/KtdPHm07zqf JF6Q== X-Gm-Message-State: AKwxytcLxcRi7oLK5RrjX8QLL9yG3ASNJR2mcqd+WowdfxSyJnAZ3d4K 2Sob191ZCx3xYFE+vR8VuUZnCdK+Ekg= X-Received: by 2002:a17:902:1e5:: with SMTP id b92-v6mr37296893plb.144.1517621100721; Fri, 02 Feb 2018 17:25:00 -0800 (PST) Received: from exogeni.mtv.corp.google.com ([2620:0:1000:1600:211e:5908:95bc:4888]) by smtp.gmail.com with ESMTPSA id x124sm5332917pfx.105.2018.02.02.17.24.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 02 Feb 2018 17:24:59 -0800 (PST) From: Derek Basehore To: linux-kernel@vger.kernel.org Cc: Soby.Mathew@arm.com, sudeep.holla@arm.com, devicetree@vger.kernel.org, robh+dt@kernel.org, mark.rutland@arm.com, linux-pm@vger.kernel.org, rafael.j.wysocki@intel.com, tglx@linutronix.de, briannorris@chromium.org, marc.zyngier@arm.com, Derek Basehore Subject: [PATCH v4 4/5] irqchip/gic-v3-its: add ability to resend MAPC on resume Date: Fri, 2 Feb 2018 17:24:49 -0800 Message-Id: <20180203012450.18378-5-dbasehore@chromium.org> X-Mailer: git-send-email 2.16.0.rc1.238.g530d649a79-goog In-Reply-To: <20180203012450.18378-1-dbasehore@chromium.org> References: <20180203012450.18378-1-dbasehore@chromium.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This adds functionality to resend the MAPC command to an ITS node on resume. If the ITS is powered down during suspend and the collections are not backed by memory, the ITS will lose that state. This just sets up the known state for the collections after the ITS is restored. This feature is enabled via Kconfig and a device tree entry. Signed-off-by: Derek Basehore --- arch/arm64/Kconfig | 10 ++++ drivers/irqchip/irq-gic-v3-its.c | 101 ++++++++++++++++++++++++--------------- 2 files changed, 73 insertions(+), 38 deletions(-) diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index 53612879fe56..f38f1a7b4266 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -571,6 +571,16 @@ config HISILICON_ERRATUM_161600802 If unsure, say Y. +config ARM_GIC500_COLLECTIONS_RESET + bool "GIC-500 Collections: Workaround for GIC-500 Collections on suspend reset" + default y + help + The GIC-500 can store Collections state internally for the ITS. If + the ITS is reset on suspend (ie from power getting disabled), the + collections need to be reconfigured on resume. + + If unsure, say Y. + config QCOM_FALKOR_ERRATUM_E1041 bool "Falkor E1041: Speculative instruction fetches might cause errant memory access" default y diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c index e13515cdb68f..63764efa4dcc 100644 --- a/drivers/irqchip/irq-gic-v3-its.c +++ b/drivers/irqchip/irq-gic-v3-its.c @@ -48,6 +48,7 @@ #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 ITS_FLAGS_WORKAROUND_GIC500_MAPC (1ULL << 4) #define RDIST_FLAGS_PROPBASE_NEEDS_FLUSHING (1 << 0) @@ -1950,52 +1951,53 @@ static void its_cpu_init_lpis(void) dsb(sy); } -static void its_cpu_init_collection(void) +static void its_cpu_init_collection(struct its_node *its) { - struct its_node *its; - int cpu; - - spin_lock(&its_lock); - cpu = smp_processor_id(); - - list_for_each_entry(its, &its_nodes, entry) { - u64 target; + int cpu = smp_processor_id(); + u64 target; - /* avoid cross node collections and its mapping */ - if (its->flags & ITS_FLAGS_WORKAROUND_CAVIUM_23144) { - struct device_node *cpu_node; + /* avoid cross node collections and its mapping */ + if (its->flags & ITS_FLAGS_WORKAROUND_CAVIUM_23144) { + struct device_node *cpu_node; - cpu_node = of_get_cpu_node(cpu, NULL); - if (its->numa_node != NUMA_NO_NODE && - its->numa_node != of_node_to_nid(cpu_node)) - continue; - } + cpu_node = of_get_cpu_node(cpu, NULL); + if (its->numa_node != NUMA_NO_NODE && + its->numa_node != of_node_to_nid(cpu_node)) + return; + } + /* + * We now have to bind each collection to its target + * redistributor. + */ + if (gic_read_typer(its->base + GITS_TYPER) & GITS_TYPER_PTA) { /* - * We now have to bind each collection to its target + * This ITS wants the physical address of the * redistributor. */ - if (gic_read_typer(its->base + GITS_TYPER) & GITS_TYPER_PTA) { - /* - * This ITS wants the physical address of the - * redistributor. - */ - target = gic_data_rdist()->phys_base; - } else { - /* - * This ITS wants a linear CPU number. - */ - target = gic_read_typer(gic_data_rdist_rd_base() + GICR_TYPER); - target = GICR_TYPER_CPU_NUMBER(target) << 16; - } + target = gic_data_rdist()->phys_base; + } else { + /* This ITS wants a linear CPU number. */ + target = gic_read_typer(gic_data_rdist_rd_base() + GICR_TYPER); + target = GICR_TYPER_CPU_NUMBER(target) << 16; + } - /* Perform collection mapping */ - its->collections[cpu].target_address = target; - its->collections[cpu].col_id = cpu; + /* Perform collection mapping */ + its->collections[cpu].target_address = target; + its->collections[cpu].col_id = cpu; - its_send_mapc(its, &its->collections[cpu], 1); - its_send_invall(its, &its->collections[cpu]); - } + its_send_mapc(its, &its->collections[cpu], 1); + its_send_invall(its, &its->collections[cpu]); +} + +static void its_cpu_init_collections(void) +{ + struct its_node *its; + + spin_lock(&its_lock); + + list_for_each_entry(its, &its_nodes, entry) + its_cpu_init_collection(its); spin_unlock(&its_lock); } @@ -2997,6 +2999,18 @@ static bool __maybe_unused its_enable_quirk_hip07_161600802(void *data) return true; } +static bool __maybe_unused its_enable_quirk_gic500_collections(void *data) +{ + struct its_node *its = data; + + if (fwnode_property_present(its->fwnode_handle, + "collections-reset-on-suspend")) { + its->flags |= ITS_FLAGS_WORKAROUND_GIC500_MAPC; + return true; + } + return false; +} + static const struct gic_quirk its_quirks[] = { #ifdef CONFIG_CAVIUM_ERRATUM_22375 { @@ -3042,6 +3056,14 @@ static const struct gic_quirk its_quirks[] = { .mask = 0xffffffff, .init = its_enable_quirk_hip07_161600802, }, +#endif +#ifdef CONFIG_ARM_GIC500_COLLECTIONS_RESET + { + .desc = "ITS: GIC-500 Collections Reset on Resume", + .iidr = 0x00000000, + .mask = 0xff000000, + .init = its_enable_quirk_gic500_collections, + }, #endif { } @@ -3129,6 +3151,9 @@ static void its_restore_enable(void) } writel_relaxed(ctx->ctlr, base + GITS_CTLR); } + + if (its->flags & ITS_FLAGS_WORKAROUND_GIC500_MAPC) + its_cpu_init_collection(its); } spin_unlock(&its_lock); } @@ -3395,7 +3420,7 @@ int its_cpu_init(void) return -ENXIO; } its_cpu_init_lpis(); - its_cpu_init_collection(); + its_cpu_init_collections(); } return 0; -- 2.16.0.rc1.238.g530d649a79-goog