Received: by 10.223.176.5 with SMTP id f5csp869980wra; Tue, 6 Feb 2018 08:42:45 -0800 (PST) X-Google-Smtp-Source: AH8x2259u/Gr1AnXtxvkyVhjQCpT1+CHkTeIXqI0zfLPydyiSn8/M821TVACqjGk7H4aVHvKD7L8 X-Received: by 10.99.120.134 with SMTP id t128mr2461908pgc.313.1517935365317; Tue, 06 Feb 2018 08:42:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517935365; cv=none; d=google.com; s=arc-20160816; b=tCgMZzXaB4VyFJZGxeJhh1VA5tzOoOYD5o8m6Hib5EbHJY1BmMghuaxQ5/LMziYCKw KlnK14qbnpPl1Iwg557T+Uzj4hb/AylMk/kwf+acfWgyRNymIyVR5B8YPFmIboBELokX 5dDXydGKnNiqoe4n5qYsl1nXCEIBF5q9uHfBB4/Z4nAdFvSXthaHTUO//xc6pt2Kn8Cq IznSzeU5nuucLp1hC61/wVpbs1GFHeuz+PN+iZjL0yHf/tHEy1O/h5gto4PxDzHCRpNI 8po3HAUJD6FHvr0r1imcwlUHlwPBG3a30kGe4urqfD+l3d2JegIyN7CjR3rPtt50Cexm 2vkw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:organization:from:references:cc:to:subject :arc-authentication-results; bh=PLbJxUjgBHK6xKxSmeMDiYs+N2rVHQv2xWAuOFxXmiE=; b=w5YUlFumB9TfB9t5VA6IdoJ/sYzEO4LcCFbhfmHZVnGfz3rZYpOmbAcmy6++QBtJ/e n8QUBM00n4DwzZ+A2WEtYjhA1qNXcqmTt/y8lHCpUw6ZCsYksXIlQNj58EI+ihKLT14h gx5HTl/3ffmeO/cN/Aj0QLKICqN/cNUDZuZ9R2EiPZz1KavzfPdvtIVSpCe2mnoqQjzt Uw7oMBfV2hgUszplwVvONHuKJ2qqMxf2MYW4Azkq71MfxI/1xNHmcp27wfvL6SIXVtQw lu+YUslzBEO2cjTITi5543J1jbYd5HPlL4Vx4fqKqJ5jKvzRA+5rHynsJcLhjCQCX0bj iaDA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q7si1606524pgs.345.2018.02.06.08.42.30; Tue, 06 Feb 2018 08:42:45 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752574AbeBFQkn (ORCPT + 99 others); Tue, 6 Feb 2018 11:40:43 -0500 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:39690 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752236AbeBFQkg (ORCPT ); Tue, 6 Feb 2018 11:40:36 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 30D661435; Tue, 6 Feb 2018 08:40:36 -0800 (PST) Received: from [10.1.207.62] (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id C4C753F53D; Tue, 6 Feb 2018 08:40:33 -0800 (PST) Subject: Re: [PATCH v4 4/5] irqchip/gic-v3-its: add ability to resend MAPC on resume To: Derek Basehore , 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 References: <20180203012450.18378-1-dbasehore@chromium.org> <20180203012450.18378-5-dbasehore@chromium.org> From: Marc Zyngier Organization: ARM Ltd Message-ID: <34fea40b-4943-e8a8-6bf5-ca200122123d@arm.com> Date: Tue, 6 Feb 2018 16:40:32 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <20180203012450.18378-5-dbasehore@chromium.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 03/02/18 01:24, Derek Basehore wrote: > 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; > I wonder if a better way to implement this is simply to bite the bullet and implement the letter of the architecture: If GITS_TYPER.HCC != 0, then collections 0...HCC-1 are held in HW, and the rest in a SW-managed table. That would allow us to deal with this without a quirk (which I asked for initially, apologies for changing my mind). We still the same DT flag to tell us we're going to be reset on suspend. Thanks, M. -- Jazz is not dead. It just smells funny...