Received: by 10.223.176.5 with SMTP id f5csp2197152wra; Thu, 8 Feb 2018 09:57:40 -0800 (PST) X-Google-Smtp-Source: AH8x226UIi7EGRWp6GZbcHZ++Tiknz+Ix4am4BAW2QKXDuXWc0kCcqtDb+aWkIt5OAD9np7rS6TG X-Received: by 2002:a17:902:7887:: with SMTP id q7-v6mr1374213pll.385.1518112660358; Thu, 08 Feb 2018 09:57:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518112660; cv=none; d=google.com; s=arc-20160816; b=pFdqUgFpScn9NyPNdP45OXnp73gw3otIvbHYgiiyK+EKdUPb17KCpqFcK01z8Sf60A e1BQh2mgJd4122dejeYF04naD4WvSBK+McPw3i8ceWmNhzXw8rSc96Gd0Z9SUurU3aiT k2q2ccpHJl06lyi4aLsnatR6227B9dFln4f4tQucpP6gySuPSrN7eTGwEssN7WqvBaen TbdbywZAkhs45fJH94eMc9C2pCktQydi4k9YGFf2f50sRjzUkCpD1gha2pivBSHrdOVw gBf7XLh1ZDLXWIfOivvyLSPZ6EKPMTRkzP+GqCc5ZcBVMOsAKT22rkE9XwLgHRdBdnKK b10A== 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=L5kHFI1CvOBUFHPwXMA+wyHe4jzblaSc+kd1Cq9kiKU=; b=yMBlfYR7o98n6wCuInJAC7LfCSy8cfmxwZ0zod7EcvIw5n2ETyYRQlIE53Yh8K8Zon +0+gsxfOe2bLPM5yYTaR0yQldJxUZTV+wOCs3kAMEFRYai/7t3CS4SBBWoKLbBqXkOOl DScmfcnA3uY5qRbErys3YDew0eFi1piND1Fqeey6+tUx17hnEBHphmwSV7Sj/C/5NZcG owZjgRd5qka0x/W28DSPhj+vWK0i8pkQmdHLDgUDSJiU3kiQhzyV1Ehnm0gGUMTTg3ya 6szfDL0gG1KLqYtpTRdx9jCpHC0aJPlfRyg0dHuoMnOWRngE2xuuOz7cO2bY0eDc2s9R EuzQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=YmdsnKfE; 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 z23-v6si289440pll.4.2018.02.08.09.57.24; Thu, 08 Feb 2018 09:57:40 -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=YmdsnKfE; 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 S1752392AbeBHRzS (ORCPT + 99 others); Thu, 8 Feb 2018 12:55:18 -0500 Received: from mail-pl0-f66.google.com ([209.85.160.66]:43116 "EHLO mail-pl0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752192AbeBHRzQ (ORCPT ); Thu, 8 Feb 2018 12:55:16 -0500 Received: by mail-pl0-f66.google.com with SMTP id f4so191184plr.10 for ; Thu, 08 Feb 2018 09:55:15 -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=L5kHFI1CvOBUFHPwXMA+wyHe4jzblaSc+kd1Cq9kiKU=; b=YmdsnKfEeABBIEYd+csEZ2vGen0yiOWdOJwqLcD3hogU+eCkJSOW6vy2A9B9aC81lD tmxkHP5AZ4DasqriDkRK6OiBXqfBkbcRI0hkFplaJwH2PdfHWFm4SgQHI3kOqvX5ytER VeEP92QNh1nlXxufwEQ3GbjU97hN5SGw5+wR4= 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=L5kHFI1CvOBUFHPwXMA+wyHe4jzblaSc+kd1Cq9kiKU=; b=hSo4xcchYXoXMN1vNYk09ADBvu/96/6yipmq2hcFvjoorhrfTEv7usd+ObbCso/B7h +LPD1aHriPH1Zdw37Nl0k+wTU/ciJ3SVv07c+UoXLyIxGM8WwCdWl0u66cGb63TX5fH/ vYL9gQFDt4DqiOHtsS1g9C69yUpOO6rb4oi/4/V4sNDFWCCBKUJ1ohjNJTl+5NTYchrT ooQeJ9Tkt7/zzC8iCTatJPAKOPmInXVqH7rnDd814v6bnrhe1noGVqR31pt6UxL+kYOl wj0SCa306hCgrS0w6IlOCTNG21/DRH+ktIR8rrr/tjnTZ+BgnOv0B6pgeVmKDa5i8DmI DCUg== X-Gm-Message-State: APf1xPAoXHX27HA3luq8ppSOO85U68f/S/1BuyvEfAL3gzIGK7nAM0xa C6BbEu2wsSR1y3HbDdHCQkZXNA== X-Received: by 2002:a17:902:2803:: with SMTP id e3-v6mr1338105plb.447.1518112515638; Thu, 08 Feb 2018 09:55:15 -0800 (PST) Received: from ban.mtv.corp.google.com ([172.22.113.17]) by smtp.gmail.com with ESMTPSA id f80sm957553pfa.176.2018.02.08.09.55.14 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 08 Feb 2018 09:55:15 -0800 (PST) Date: Thu, 8 Feb 2018 09:55:12 -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 v6 1/3] irqchip/gic-v3-its: add ability to save/restore ITS state Message-ID: <20180208175511.GC106856@ban.mtv.corp.google.com> References: <20180208023648.89124-1-dbasehore@chromium.org> <20180208023648.89124-2-dbasehore@chromium.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180208023648.89124-2-dbasehore@chromium.org> User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Derek, On Wed, Feb 07, 2018 at 06:36:46PM -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 | 103 +++++++++++++++++++++++++++++++++++++++ > 1 file changed, 103 insertions(+) > > diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c > index 06f025fd5726..35ad48f51dfa 100644 > --- a/drivers/irqchip/irq-gic-v3-its.c > +++ b/drivers/irqchip/irq-gic-v3-its.c > @@ -33,6 +33,7 @@ > #include > #include > #include > +#include > > #include > #include > @@ -46,6 +47,7 @@ > #define ITS_FLAGS_CMDQ_NEEDS_FLUSHING (1ULL << 0) > #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 RDIST_FLAGS_PROPBASE_NEEDS_FLUSHING (1 << 0) > > @@ -101,6 +103,8 @@ struct its_node { > struct its_collection *collections; > struct fwnode_handle *fwnode_handle; > u64 (*get_msi_base)(struct its_device *its_dev); > + u64 cbaser_save; > + u32 ctlr_save; > struct list_head its_device_list; > u64 flags; > unsigned long list_nr; > @@ -3042,6 +3046,100 @@ static void its_enable_quirks(struct its_node *its) > gic_enable_quirks(iidr, its_quirks, its); > } > > +static int its_save_disable(void) > +{ > + struct its_node *its; > + int err = 0; > + > + spin_lock(&its_lock); > + list_for_each_entry(its, &its_nodes, entry) { > + void __iomem *base; > + > + if (!(its->flags & ITS_FLAGS_SAVE_SUSPEND_STATE)) > + continue; > + > + base = its->base; > + its->ctlr_save = readl_relaxed(base + GITS_CTLR); > + err = its_force_quiescent(base); > + if (err) { > + pr_err("ITS failed to quiesce\n"); Isn't this a case where it was suggested to print the PA? Also, printing the error code never hurts. Like: pr_err("ITS@%pa: failed to quiesce: %d\n", &its->phys_base, err); > + writel_relaxed(its->ctlr_save, base + GITS_CTLR); > + goto err; > + } > + > + its->cbaser_save = gits_read_cbaser(base + GITS_CBASER); > + } > + > +err: > + if (err) { > + list_for_each_entry_continue_reverse(its, &its_nodes, entry) { > + void __iomem *base; > + > + if (!(its->flags & ITS_FLAGS_SAVE_SUSPEND_STATE)) > + continue; > + > + base = its->base; > + writel_relaxed(its->ctlr_save, base + GITS_CTLR); > + } > + } > + spin_unlock(&its_lock); > + > + return err; > +} > + > +static void its_restore_enable(void) > +{ > + struct its_node *its; > + > + spin_lock(&its_lock); > + list_for_each_entry(its, &its_nodes, entry) { > + void __iomem *base; > + int i; > + > + if (!(its->flags & ITS_FLAGS_SAVE_SUSPEND_STATE)) > + continue; > + > + base = its->base; > + > + /* > + * Make sure that the ITS is disabled. If it fails to quiesce, > + * don't restore it since writing to CBASER or BASER > + * registers is undefined according to the GIC v3 ITS > + * Specification. > + */ > + if (its_force_quiescent(base)) { > + pr_err("ITS(%p): failed to quiesce on resume\n", base); I think Marc was requesting the PA, not the VA. The VA isn't really very useful. Also, might as well log with similar style to the existing logs (ITS@xxx), and log the error code: pr_err("ITS@%pa: failed to quiesce on resume: %d\n", &its->phys_base, ret); Brian > + continue; > + } > + > + gits_write_cbaser(its->cbaser_save, base + GITS_CBASER); > + > + /* > + * Writing CBASER resets CREADR to 0, so make CWRITER and > + * cmd_write line up with it. > + */ > + its->cmd_write = its->cmd_base; > + gits_write_cwriter(0, base + GITS_CWRITER); > + > + /* Restore GITS_BASER from the value cache. */ > + for (i = 0; i < GITS_BASER_NR_REGS; i++) { > + struct its_baser *baser = &its->tables[i]; > + > + if (!(baser->val & GITS_BASER_VALID)) > + continue; > + > + its_write_baser(its, baser, baser->val); > + } > + writel_relaxed(its->ctlr_save, 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; > @@ -3261,6 +3359,9 @@ static int __init its_probe_one(struct resource *res, > ctlr |= GITS_CTLR_ImDe; > writel_relaxed(ctlr, its->base + GITS_CTLR); > > + if (fwnode_property_present(handle, "reset-on-suspend")) > + its->flags |= ITS_FLAGS_SAVE_SUSPEND_STATE; > + > err = its_init_domain(handle, its); > if (err) > goto out_free_tables; > @@ -3515,5 +3616,7 @@ int __init its_init(struct fwnode_handle *handle, struct rdists *rdists, > } > } > > + register_syscore_ops(&its_syscore_ops); > + > return 0; > } > -- > 2.16.0.rc1.238.g530d649a79-goog >