Received: by 10.223.176.46 with SMTP id f43csp1163384wra; Fri, 26 Jan 2018 13:00:44 -0800 (PST) X-Google-Smtp-Source: AH8x227wbAONyEN0ZS7QJedP00n/HWE2lfSxZlYHeIy0G2Clg5l/x6TUmdUnu5r8iLiVUTgDWMBL X-Received: by 10.99.174.69 with SMTP id e5mr16739294pgp.263.1517000444714; Fri, 26 Jan 2018 13:00:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517000444; cv=none; d=google.com; s=arc-20160816; b=HK2JhyCcA3dC4QTqC1K526X/Es6g5bJp7aDl5Ana3PKw6duWh1UdOvDwUG9IROf9uw 0sfZxaEdTHTaoEgGuzkMYlox9142i/u8uwea1xdOkzXdlvRXijIIQNGauBwMPIX/BGQO 4LAFdvRtq6aIw4iZYL2u0Gc70gA4F49/h1EIXryVCr+uN9zXHXFfCFsG/V/bXoP3g1ku bl5zclAsGhhptUnuyFGWnQBOSQJAJglBmKwGrZ1lB6kqkViS4yIlYt3W6V5abBX6Iuqd n9ap2WBcGVAE9CzaLNiLn58+ngMAECD/WgXfxKag7SQnKsFNV1EB+HS1P/oTezhelQZI jpmg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=sprlhWm1VvRJk3x9VLjDPOnha5aIpev64lwWKW+JvEg=; b=k58wszGxKs9qrJNT0cSaGZ1h7xJ9uU+H2G1t333X9flVhAQvYVk/nICa9ECjutLgJZ 21wrW0PVC6TkfWu5H8/q0dIJWPMnoLHo5sldofk1KCHvQodLOpzKb41kiEMjbO4kZh3v bHHPmGw1UBMurjfJHn7Bk7tO4UnWXEO42YyzWZqLHbEEUQv3p+Nn+hEnTMBEssBF6MlK YRLCXui6xZonXgeMQqCwu/uywOEwi0wHyYyQTb/xA5YeAJr+AAJls3NwatNI/bsJL8h8 opJW9SZYy14YbwTyZp771OWegOkxAhbt+KnExLaZjr9HihiWxp6GAO80VXPcsz3su206 RpFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=RS4AoptD; 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 t3si3397234pgp.498.2018.01.26.13.00.30; Fri, 26 Jan 2018 13:00:44 -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=RS4AoptD; 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 S1751835AbeAZVAB (ORCPT + 99 others); Fri, 26 Jan 2018 16:00:01 -0500 Received: from mail-pf0-f195.google.com ([209.85.192.195]:38539 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751534AbeAZU77 (ORCPT ); Fri, 26 Jan 2018 15:59:59 -0500 Received: by mail-pf0-f195.google.com with SMTP id k19so1046634pfj.5 for ; Fri, 26 Jan 2018 12:59:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=sprlhWm1VvRJk3x9VLjDPOnha5aIpev64lwWKW+JvEg=; b=RS4AoptDQY/2TnzUAXRVmBqsTSEnwSXeyICK2RM7UjGlaIQKOC048TAimXCqN/naaK cttYasYP6X6h79F7GIMp3Ikw7iNYAeACvKDtY3/poVvbGQb021dxLi8FsbLL1EEMyUN7 dRA/N1kEj3qCjp6jlMV6d4+pFge8GWjAwtvmk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=sprlhWm1VvRJk3x9VLjDPOnha5aIpev64lwWKW+JvEg=; b=cN380fzIYdmNjPfynRT4ld6o+08aRy0R1YBPKCORdNizqie7C1CKUKKjxytTbdSIO6 xaAzai6juMaFmGQzVAdbTgnkIlL/VHW4QFIlQbm/gbHRdHy/OHhSq1XX9PiBuENbT5SH vqdMRPfo07kuQR0S8P4bFX36DxDqB5JN66P8SW1rzr+0L/WQAA3Ryb9O/xaL/OQog/zw aQbXup6KrpMspbc/VdGjafDT1TFBwUcJAFkoQb3bQZ6OZoj8m52Ks9/zKoxBtj7G1mXC IObBAt/yYHY/kLg2lWxSgf6wcUVFMF0+VRThiUeaarXpU0+8MRYbTCLmX86Txsn4GAD1 qKWA== X-Gm-Message-State: AKwxytemIqkuyfTfOGd7R+ew+Ri5+OQ+jdMVWp/W8/RsN5dzEsqetPqA 5LkJrq4CcxRbV8w+k64APASRXOZCWug= X-Received: by 10.101.90.202 with SMTP id d10mr16231128pgt.366.1517000398728; Fri, 26 Jan 2018 12:59:58 -0800 (PST) Received: from ban.mtv.corp.google.com ([172.22.113.17]) by smtp.gmail.com with ESMTPSA id h11sm8394946pgq.91.2018.01.26.12.59.57 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 26 Jan 2018 12:59:57 -0800 (PST) Date: Fri, 26 Jan 2018 12:59:56 -0800 From: Brian Norris To: Derek Basehore Cc: linux-kernel@vger.kernel.org, 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, marc.zyngier@arm.com Subject: Re: [PATCH v2 2/5] irqchip/gic-v3-its: add ability to save/restore ITS state Message-ID: <20180126205954.cikwitw7sgdt2yn3@ban.mtv.corp.google.com> References: <20180126073835.16575-1-dbasehore@chromium.org> <20180126073835.16575-3-dbasehore@chromium.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180126073835.16575-3-dbasehore@chromium.org> User-Agent: NeoMutt/20170609 (1.8.3) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org One trivial comment: On Thu, Jan 25, 2018 at 11:38:32PM -0800, Derek Basehore wrote: > Some platforms power off GIC logic in suspend, so we need to > save/restore state. The distributor and redistributor registers need > to be handled in platform code due to access permissions on those > registers, but the ITS registers can be restored in the kernel. > > Signed-off-by: Derek Basehore > --- > drivers/irqchip/irq-gic-v3-its.c | 86 ++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 86 insertions(+) > > diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c > index 06f025fd5726..4727b447610f 100644 > --- a/drivers/irqchip/irq-gic-v3-its.c > +++ b/drivers/irqchip/irq-gic-v3-its.c ... > @@ -3042,6 +3054,75 @@ static void its_enable_quirks(struct its_node *its) > gic_enable_quirks(iidr, its_quirks, its); > } > > +int its_save_disable(void) This (and its_restore_enable()) should be static, now that you're only using them in this file. Brian > +{ > + struct its_node *its; > + int err = 0; > + > + spin_lock(&its_lock); > + list_for_each_entry(its, &its_nodes, entry) { > + if (its->flags & ITS_FLAGS_SAVE_SUSPEND_STATE) { > + struct its_ctx *ctx = &its->its_ctx; > + void __iomem *base = its->base; > + > + ctx->ctlr = readl_relaxed(base + GITS_CTLR); > + err = its_force_quiescent(base); > + if (err) { > + writel_relaxed(ctx->ctlr, base + GITS_CTLR); > + goto err; > + } > + > + ctx->cbaser = gits_read_cbaser(base + GITS_CBASER); > + } > + } > + > +err: > + if (err) { > + list_for_each_entry_continue_reverse(its, &its_nodes, entry) { > + if (its->flags & ITS_FLAGS_SAVE_SUSPEND_STATE) { > + struct its_ctx *ctx = &its->its_ctx; > + void __iomem *base = its->base; > + > + writel_relaxed(ctx->ctlr, base + GITS_CTLR); > + } > + } > + } > + > + spin_unlock(&its_lock); > + > + return err; > +} > + > +void its_restore_enable(void) > +{ > + struct its_node *its; > + > + spin_lock(&its_lock); > + list_for_each_entry(its, &its_nodes, entry) { > + struct its_ctx *ctx = &its->its_ctx; > + struct its_baser *baser; > + void __iomem *base; > + int i; > + > + if (its->flags & ITS_FLAGS_SAVE_SUSPEND_STATE) { > + base = its->base; > + gits_write_cbaser(ctx->cbaser, base + GITS_CBASER); > + /* Restore GITS_BASER from the value cache. */ > + for (i = 0; i < GITS_BASER_NR_REGS; i++) { > + baser = &its->tables[i]; > + its_write_baser(its, baser, baser->val); > + } > + writel_relaxed(ctx->ctlr, base + GITS_CTLR); > + } > + } > + spin_unlock(&its_lock); > +} > + > +static struct syscore_ops its_syscore_ops = { > + .suspend = its_save_disable, > + .resume = its_restore_enable, > +}; > + > static int its_init_domain(struct fwnode_handle *handle, struct its_node *its) > { > struct irq_domain *inner_domain;