Received: by 10.223.176.5 with SMTP id f5csp1379506wra; Wed, 7 Feb 2018 18:37:58 -0800 (PST) X-Google-Smtp-Source: AH8x225Kp6VkgQ033CyW9UyJpL6C1DA39oQuv8O8kExf0fvpu2YdFIahANVVjF1UI85wvsTnwjJ6 X-Received: by 10.98.35.211 with SMTP id q80mr7851227pfj.64.1518057478162; Wed, 07 Feb 2018 18:37:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518057478; cv=none; d=google.com; s=arc-20160816; b=c3AAdEPvH5udnJzpPACZJDoFIbji2lNAbqMOySdjsWTRLfRx0nfpAP4AZRJNR+7Hj1 FLP6CUdBFSruRioaCvvrcmPXn0HzizdQfalqtbOJ24fjJIw4oz2gEysOegRfve3VYS/L xhoXaMviPLWr4q6pz+7dWxY4ucVx3dOnVlGwlhDNUV7fM4+OUp2aR2HWQve+mCxrg9gs VUtbe9iMGYwSiEO9htbUApmF/flAAz5k1s62tkibA0cLhNmnj+8Jj2+2Zoa6OjG7e5N3 iFtQHrA/DDTGUA4jUnOrKPhDk42UGpXsOFCnQhEA29kM2U8rPC4ECT1CRPDhq7U2fXZe oo9w== 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=sdlg+llrxKknRxaVBS5rvCKrJkekNWGUPCbpLWSjREQ=; b=hnRFE45MVGeNV+6u4z91gb3gHJDtfuHKPbaj3DgKqD/L2/cYlxeGEsDa2FSGImjfPx ja5uwwZNqOj4CghVw+b2I1xI5CvPV96EpOfJGTIp5nivECr+4oiCl/xEZ3NeLKDnYKeG +ak044mj/GxKEO5bZbm+iInh47Vk2wXibmmxm/tOX5X6H9qvzx0bmD2kiYGvN48dqge5 ow+WrTEqzQm2l2Y2FKjRTV1mztJ6kRZ5pVnSHgw2OhTdsnz6i22suh2ZDnOULQQjetj4 OKJMU2D2akWhg5WEH7/V1cbXxTg77jrcc4y6jpGGDyyehPFeN7M1m17IoAoBwp4FYa/M ELJA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=Rud2LE/3; 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 l185si118549pgd.706.2018.02.07.18.37.43; Wed, 07 Feb 2018 18:37:58 -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=Rud2LE/3; 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 S1752159AbeBHChB (ORCPT + 99 others); Wed, 7 Feb 2018 21:37:01 -0500 Received: from mail-pf0-f195.google.com ([209.85.192.195]:35750 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752021AbeBHCg6 (ORCPT ); Wed, 7 Feb 2018 21:36:58 -0500 Received: by mail-pf0-f195.google.com with SMTP id y9so1209488pfl.2 for ; Wed, 07 Feb 2018 18:36:58 -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=sdlg+llrxKknRxaVBS5rvCKrJkekNWGUPCbpLWSjREQ=; b=Rud2LE/3DhWoBTwfhw7fo/ixOp5rwtb5ds6+fh6mBVL47Ze3HwRFxZrSQR188IJKJ6 z+EiHjjWjIr+Xswk0I9+weUUrUUsElL92KFw8ezo2+7PpcYFWWjmgKsczPYFTq9qrwwY IA0HjZ8RT7zvRoOpXnLJOlkrQtitzpwDKIMh4= 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=sdlg+llrxKknRxaVBS5rvCKrJkekNWGUPCbpLWSjREQ=; b=iddw4nmTjkMCPpgqZbm9s4CQQ81wskzr/1ugijdkye9uSafjqOirNy2Bm2W1t8uJLj 4NGKytgAt8HzjSfeq4xLz5gqxh8rJz0gebaDPXr5IgbzpLDkt6og/6LE0h43WNCN8bqc sXnOJc91m9FWFMkx0Z8OIfFA/LeBuelW18LVyXDbn2HPaMDZzJFrx/HE9ihKyeMlrSHA +IK+A4GshzNi1wWmZDnbxdUvlXz2xDitdj2P7thUaQalkwv/XOW3hli07zp2e4d3FDsF l6WQkcaIcVQgAm98la0t2BCkqfzc0fWZjyccsFIepnZ3Atd82Nut3WuhU/dYVcrPjMwo pTYw== X-Gm-Message-State: APf1xPCVsM8Z4yANiOzUOjsbVh6u18yGZ094elrXDb0NcgI1so3XRbKe tBRrYlo0azcAw5wgxYPZB8sVnaZPDys= X-Received: by 10.99.105.74 with SMTP id e71mr6648470pgc.342.1518057417872; Wed, 07 Feb 2018 18:36:57 -0800 (PST) Received: from exogeni.mtv.corp.google.com ([2620:0:1000:1600:211e:5908:95bc:4888]) by smtp.gmail.com with ESMTPSA id 203sm6901941pfa.110.2018.02.07.18.36.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 07 Feb 2018 18:36:57 -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 v6 3/3] irqchip/gic-v3-its: add ability to resend MAPC on resume Date: Wed, 7 Feb 2018 18:36:48 -0800 Message-Id: <20180208023648.89124-4-dbasehore@chromium.org> X-Mailer: git-send-email 2.16.0.rc1.238.g530d649a79-goog In-Reply-To: <20180208023648.89124-1-dbasehore@chromium.org> References: <20180208023648.89124-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. It only runs for collections stored in the ITS itself. Signed-off-by: Derek Basehore --- drivers/irqchip/irq-gic-v3-its.c | 86 +++++++++++++++++++++----------------- include/linux/irqchip/arm-gic-v3.h | 1 + 2 files changed, 49 insertions(+), 38 deletions(-) diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c index 35ad48f51dfa..a564a92ab169 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); } @@ -3131,6 +3132,15 @@ static void its_restore_enable(void) its_write_baser(its, baser, baser->val); } writel_relaxed(its->ctlr_save, base + GITS_CTLR); + + /* + * Reinit the collection if it's stored in the ITS. This is + * indicated by the col_id being less than the HWCOLLCNT. + * CID < HCC as specified in the GIC v3 Documentation. + */ + if (its->collections[smp_processor_id()].col_id < + GITS_TYPER_HWCOLLCNT(gic_read_typer(base + GITS_TYPER))) + its_cpu_init_collection(its); } spin_unlock(&its_lock); } @@ -3397,7 +3407,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