Received: by 10.223.176.5 with SMTP id f5csp83351wra; Tue, 6 Feb 2018 17:42:51 -0800 (PST) X-Google-Smtp-Source: AH8x227IcCJ3gZ7mPkIB8jFTUvlPWWnhrTKglojzzTY9eyPvhLOUjibGguLACXEhlRmNWay4xGR2 X-Received: by 2002:a17:902:61:: with SMTP id 88-v6mr4373233pla.428.1517967771660; Tue, 06 Feb 2018 17:42:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517967771; cv=none; d=google.com; s=arc-20160816; b=e4Nt1hzlOJW/TgOEKmxDhePyDqWto5d0RJOZYtBG7SqxXzdZ5S8h20Seqwg/bKu+T+ P9CNy8QXpFykssP95f2lHwB8ztYn0Xgiz1YF1aGH2edAZilcwHaW/2J4OxiKHzuqFhX2 AQq+YvjHpkhg3ZJqvdmoj4R2P+yvxT4f9KJB9Chju2xWWAT6z6gPxYbbKIAetHNWb5Wf PuqphIL9N9it0yBqwLBEHiCzFG7NU9z3425ZT2KrCFYDj/WgLisJp95nSCeROW9NwlNX yhhec0dtdf2jkH2oeMtD6X/SSkwZ96qPY7vtSyVMOWsLmEaFU4uy/Hehca4pd39fhBkX iVgw== 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=2xgtUaa2k+KwF9dxx2VhCEHTg9Rq69cek44jk2/ug3Q=; b=vkdMHseemLn10B0qw4Zonr0ng59YfcyoXy4RUD2xzJkswSsb6T2q+0WIwA//L64V0f WNyX/pMq5NakCR59cgytYk8D00yv1Ohp/jWK2xU3ShoiWpYjM50j6jzAD7mjXmie5lV7 PXCLsc/FX/nxdBTvJuD2mq2bU92uDmcpx3p2CRndgDBO1JeMpKOvUm/er8IgPa0pjaqa DGgUvNpL0InB9Mx1dm5Df/nOQFkTdaIsFLi4KRWfXA9NDAo2FDWBIac/jK6y7R/yrX/A kH18tYQalHWE0kRIV5z0X+S56ET2flUSqMuLRrI2x/fuI9/mQQNMxY1E5w3AH4EqAhEk cPeA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=ZTDikZjD; 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 w1si225744pgr.637.2018.02.06.17.42.33; Tue, 06 Feb 2018 17:42:51 -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=ZTDikZjD; 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 S932354AbeBGBle (ORCPT + 99 others); Tue, 6 Feb 2018 20:41:34 -0500 Received: from mail-pl0-f65.google.com ([209.85.160.65]:35183 "EHLO mail-pl0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932342AbeBGBlb (ORCPT ); Tue, 6 Feb 2018 20:41:31 -0500 Received: by mail-pl0-f65.google.com with SMTP id j19so2488839pll.2 for ; Tue, 06 Feb 2018 17:41:31 -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=2xgtUaa2k+KwF9dxx2VhCEHTg9Rq69cek44jk2/ug3Q=; b=ZTDikZjDR7wDsNBQu9ZIqjx+KqxIpbgmpgycAluyPIyYIM3Fo2XIsBE7laHmkvqTgA 1NVXRoWPU/PHwaXNlsxLJ4zGtUq+RioXm7ZPCAcavx38zjETTiPn3UOQIIhcoGaCpMSC yvrCNQjn1xLRSEI1zXOP1s+2eyzsZOjQoquEw= 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=2xgtUaa2k+KwF9dxx2VhCEHTg9Rq69cek44jk2/ug3Q=; b=J6Bx0m/uxlW5DY9ZnCI9upyy3IRKx4bgnewwyvTnDnP4MqUQg2Smx06o7KR7r8Rnbq dXCHHa6RfGh6v53ZKJJ/DmlAnvN6/xa1Doml49KtyeAZ96l/v7kt//XthcyIphB3hoeA qC2Ja0mQD0svVv7L55TYLvB547SJZPdgBMyWJZQwSEF2oGiWv5hybPfONdOL6/+EiNx4 muCZma8nodQCfTwp31q7N0VT+A1o6ugBvHq+siQPXEPXR9trkX3OZUe0SgWXzxKebBN7 KQV8MaxBIS0re8XxHH1fBG8kAewK83ot2tRL7JetbUmzK3Sjb9fVOCNY/1zRriDSGovw NfNg== X-Gm-Message-State: APf1xPBEzzY1a79J5RDJPYCHTe4pyDwBuESs7XBIUtQjs177W+QYix/m wSaXexJz/6fIdo+WgfHCGO5+RU8xx8U= X-Received: by 2002:a17:902:aa0b:: with SMTP id be11-v6mr4175786plb.250.1517967690502; Tue, 06 Feb 2018 17:41:30 -0800 (PST) Received: from exogeni.mtv.corp.google.com ([2620:0:1000:1600:211e:5908:95bc:4888]) by smtp.gmail.com with ESMTPSA id k71sm573529pfg.52.2018.02.06.17.41.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 06 Feb 2018 17:41:29 -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 v5 4/4] irqchip/gic-v3-its: add ability to resend MAPC on resume Date: Tue, 6 Feb 2018 17:41:17 -0800 Message-Id: <20180207014117.62611-5-dbasehore@chromium.org> X-Mailer: git-send-email 2.16.0.rc1.238.g530d649a79-goog In-Reply-To: <20180207014117.62611-1-dbasehore@chromium.org> References: <20180207014117.62611-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 is enabled via the reset-on-suspend flag in the DTS for an ITS that has a non-zero number of collections stored in it. Signed-off-by: Derek Basehore --- drivers/irqchip/irq-gic-v3-its.c | 80 ++++++++++++++++++++------------------ include/linux/irqchip/arm-gic-v3.h | 1 + 2 files changed, 43 insertions(+), 38 deletions(-) diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c index 5e63635e2a7b..dd6cd6e68ed0 100644 --- a/drivers/irqchip/irq-gic-v3-its.c +++ b/drivers/irqchip/irq-gic-v3-its.c @@ -1942,52 +1942,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); } @@ -3127,6 +3128,9 @@ static void its_restore_enable(void) its_write_baser(its, baser, baser->val); } writel_relaxed(its->ctlr_save, base + GITS_CTLR); + + if (GITS_TYPER_HWCOLLCNT(gic_read_typer(base + GITS_TYPER)) > 0) + its_cpu_init_collection(its); } spin_unlock(&its_lock); } @@ -3393,7 +3397,7 @@ int its_cpu_init(void) return -ENXIO; } its_cpu_init_lpis(); - its_cpu_init_collection(); + its_cpu_init_collections(); } return 0; diff --git a/include/linux/irqchip/arm-gic-v3.h b/include/linux/irqchip/arm-gic-v3.h index c00c4c33e432..c9c33b91a1f1 100644 --- a/include/linux/irqchip/arm-gic-v3.h +++ b/include/linux/irqchip/arm-gic-v3.h @@ -313,6 +313,7 @@ #define GITS_TYPER_DEVBITS(r) ((((r) >> GITS_TYPER_DEVBITS_SHIFT) & 0x1f) + 1) #define GITS_TYPER_PTA (1UL << 19) #define GITS_TYPER_HWCOLLCNT_SHIFT 24 +#define GITS_TYPER_HWCOLLCNT(r) (((r) >> GITS_TYPER_HWCOLLCNT_SHIFT) & 0xff) #define GITS_TYPER_VMOVP (1ULL << 37) #define GITS_IIDR_REV_SHIFT 12 -- 2.16.0.rc1.238.g530d649a79-goog