Received: by 10.223.176.5 with SMTP id f5csp1176213wra; Tue, 6 Feb 2018 14:11:13 -0800 (PST) X-Google-Smtp-Source: AH8x227HgSTIQf5dcYF0SrC5HD+TCPmInnAGRt2R13n38vWFnb8rvRzysBqDUWGSz60g8wcy+flW X-Received: by 10.99.43.13 with SMTP id r13mr3037486pgr.338.1517955073250; Tue, 06 Feb 2018 14:11:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517955073; cv=none; d=google.com; s=arc-20160816; b=a4ZLEi/r5Id1gMQDdVuYzsKiMdLC/SU1TnbTMSEkVtu61KG77BqinT3K0KeuPOSw1/ +jH4m5HxCQ23vgAp5rNTk7WnzGc+e5K88tkoGqP/TxOTUgVYjdtnPfQAmmwOLpENUrTh Wgqs/Ypacdkp+fQXTJ0UYTTL+nYzwD9xQyuWluvsRm+/h43k+3MtupnGJT8BhIlAjv8X W9Hoz1HniegGdTU/dJ6sJFBhPeACIcnddyYgW0AdYVJK/refpuZjWR77MtkxSJLJYjaB UjYrA0YpAe6DRqTngvDaGr7BHmwVZWX42tKb2BoZXRU80MUiazyZYDIGSElM1XH9etBp RSkw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature:dkim-signature :arc-authentication-results; bh=Pj+D7cZ+0Bp2nd+8ScVblLN5F+QfrrIVx9OhRmuTIoI=; b=F73fuRVqXqzfsWbzfDLW+HBMyG3anKUXyGz+7qLnBURP/nhTtNvBPPRh1BPZfa5YE5 tRXshbyMwtA+t6fDy/vBnSFKokvIS+E9UP2AKDmu0i66/1/71tu//CyR66HK86aCodSq F8ZGFqAcT0+z/JjXOIgszAaaTiUaMbY87i4TBjjZVsZRyRohrb2NCaN6ul0UTA1UsBFD TO5tNrzWr7vilxNbUXMGdaFO6dVec0D7LIzcDESQum0G3I/b9JFybhqbz8ZHBA7ul0qP BMqK5JfQsm07PS6SZ/Uri/LuG86iI/8V5ImXbtp4RWehMgBQUuOnh0nElxo1uC9gKeeU 558Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@google.com header.s=20161025 header.b=m4026nZ5; dkim=fail header.i=@chromium.org header.s=google header.b=YVZ+t4bD; 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=fail (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 q11si12428pgp.400.2018.02.06.14.10.58; Tue, 06 Feb 2018 14:11:13 -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=fail header.i=@google.com header.s=20161025 header.b=m4026nZ5; dkim=fail header.i=@chromium.org header.s=google header.b=YVZ+t4bD; 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=fail (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753482AbeBFWKM (ORCPT + 99 others); Tue, 6 Feb 2018 17:10:12 -0500 Received: from mail-wr0-f193.google.com ([209.85.128.193]:33584 "EHLO mail-wr0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753329AbeBFWKI (ORCPT ); Tue, 6 Feb 2018 17:10:08 -0500 Received: by mail-wr0-f193.google.com with SMTP id s5so3593399wra.0 for ; Tue, 06 Feb 2018 14:10:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=Pj+D7cZ+0Bp2nd+8ScVblLN5F+QfrrIVx9OhRmuTIoI=; b=m4026nZ5xgjdn9/nMZBCFClIe7jy6QzQUCnIqGuXn/1L+HwxRzc8VmPSsMLeeN139r XYQnyBkhb1KPFvoVVARc5Jmd1cEDfujPnFUaUkzZG9V5RKN+PRHcIMGv55zRyiWcbaz2 myJUlZY4ejn1uVMtqTLQUMEpO1hj7JdgwCGDDrzula16cdsRSZx7/P/rgVEGmtWaXxnu 4ZJ8S8G5jO46R8WjOan+NmYc/x55Sy1tEVdXkDYunF6/PHZbTHF2iSCRXJ8/KjtpzHLe 4WLOOtTNYwTDNkQBzGh6RfMjbgBQHcD9y+ccWZzml2VpMRik5Et63f+BSDQgFy/EJz7+ X08Q== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=Pj+D7cZ+0Bp2nd+8ScVblLN5F+QfrrIVx9OhRmuTIoI=; b=YVZ+t4bD1V0qkUsYhWOeQ9OwZHtWbA8cVL72zgW7dG65dBGOAwzM6ttzkUJbHagO9C SWjbT/twxkh1jYlYnCd4Rw2NA3taE0yVYaRvn+6yoX0bhkV9elJYd7zAk1VL8l4tm/Oe IbrvjIXj4QbSfXpHcRhj6MDf4CF+uCnMuY//k= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=Pj+D7cZ+0Bp2nd+8ScVblLN5F+QfrrIVx9OhRmuTIoI=; b=pGb2T5geTnJOwV7emPibDlCDF7e7i2MWGpelLo4EouBOpHGjvkV3XCgv62k60liWgJ Fav1uGVtbXV/sIZatbGTmqkHngbcjbQ/Pf58Pw/wz3F/T0aL3ZNlR+LNz2dbAAcX4Sao d2Pa0ha8DXpfO3jGGhMMoKYAvRTLNHw6XswnnVuHw9NGMo7SW1HvwoCg8WcBwWRwGlJ/ zEDQDS72livMDrrLADGABetlByCkgGXpI4mQ+peCKJZCGBBhUvDTq3AiHFOzu3t+wu+R fuYzO+lNR6MssmH+GbG0/8fvjAJDvsNSTKuVpmA61QimuL9hB7zv9AWaLXRkyINy3K37 RTEQ== X-Gm-Message-State: APf1xPDW8TcEz+PY70lx8+LjTqo8DCWOiD6+5ZWY9zM4KuRauhbQAVsv QE1voTZwi1lsNOPm/14hjN/2a3zBsYJQ+sbHJyhg3w== X-Received: by 10.223.150.208 with SMTP id u74mr3512640wrb.193.1517955007088; Tue, 06 Feb 2018 14:10:07 -0800 (PST) MIME-Version: 1.0 Received: by 10.28.124.6 with HTTP; Tue, 6 Feb 2018 14:10:06 -0800 (PST) In-Reply-To: <34fea40b-4943-e8a8-6bf5-ca200122123d@arm.com> References: <20180203012450.18378-1-dbasehore@chromium.org> <20180203012450.18378-5-dbasehore@chromium.org> <34fea40b-4943-e8a8-6bf5-ca200122123d@arm.com> From: "dbasehore ." Date: Tue, 6 Feb 2018 14:10:06 -0800 X-Google-Sender-Auth: u7WUbl4X6Ihs4gdMdaEdCkL1Q2s Message-ID: Subject: Re: [PATCH v4 4/5] irqchip/gic-v3-its: add ability to resend MAPC on resume To: Marc Zyngier Cc: linux-kernel , Soby Mathew , Sudeep Holla , devicetree@vger.kernel.org, robh+dt@kernel.org, Mark Rutland , Linux-pm mailing list , "Wysocki, Rafael J" , Thomas Gleixner , Brian Norris Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Feb 6, 2018 at 8:40 AM, Marc Zyngier wrote: > 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. So this would just be under the generic reset-on-suspend flag that I added in patch 2/5? > > Thanks, > > M. > -- > Jazz is not dead. It just smells funny...