Received: by 10.223.176.5 with SMTP id f5csp24670wra; Thu, 1 Feb 2018 14:55:34 -0800 (PST) X-Google-Smtp-Source: AH8x225uWxD2JzMyNVr9lv4WYXR3Q99ZVI54T+BghCnd76+y5tn4FMJc5x3JKdniV01EJlKsaPkE X-Received: by 10.98.66.67 with SMTP id p64mr38186893pfa.227.1517525734337; Thu, 01 Feb 2018 14:55:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517525734; cv=none; d=google.com; s=arc-20160816; b=Pj9aXxdymF5uUITSZPZsE+TPTt1uYRP1HP/Hc9efEedn85oln7k99FvWSsnu1pnp8R 7raltdqJaB2FW1VfkLn0VuNjShBC4boBSKUIzW38OHG4ln0aq9H0pK2ZeJSJY2j6ca5E oqvVr4PPpUs1Fd0pzT82KJMZRSosdz5olXfPBg99b7GeL93Jr6ypFwUs/QIsQimC/u7N RHUhFEFohpoawWzAtcHBtDWJUKDHrw8Fz5gUY9gsyrBy/SOSQbSU0sMpDinALfObqKTY qT3CHHhfKerefEg+m+f4+hngDFO7Z3MDGpd1pEao/OYTZU6CaLBbonChtGaXs2NJ8A+N lUVA== 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=RJ/JsswDo6kuLK9vGJRs3yutTp445wteqVBNOMxdJFs=; b=zo3aOAqomf82iJ45M5Hg2XmE+P9kfCiD6DVtZlz7Hbdh/R1cqog22Ml8fwbnWLOoNX p8AgEzMSWPW/UGcXo3mgLcsfBPWh/CQZcCkE47Unc8sZMysMqlWEnxYZUoUxRCXaKPLn nlDxlBDDmRe8a254pkueawNYKaxHIZ3xHlYq3uFedUlaQXHBElNlk2YO0QjKkZhU8grC TCRWb8hsJ0sj5VkQ7mMJUXx0wAVq4NpiPX3bD05dswkbQBjUxEyQuV/1jvpXOVVtYf4F Ja2f5K+LMBQ2+Dvs41/zOfoWtCip+x0+0Y40x25EBqoEyWCaoALYD+18A+DlfZzoRXm9 2ofA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@google.com header.s=20161025 header.b=ntRPIYL4; dkim=fail header.i=@chromium.org header.s=google header.b=j+YmFVdH; 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 p17si402428pgc.311.2018.02.01.14.55.19; Thu, 01 Feb 2018 14:55:34 -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=ntRPIYL4; dkim=fail header.i=@chromium.org header.s=google header.b=j+YmFVdH; 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 S1752159AbeBAWyl (ORCPT + 99 others); Thu, 1 Feb 2018 17:54:41 -0500 Received: from mail-wr0-f196.google.com ([209.85.128.196]:40161 "EHLO mail-wr0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752027AbeBAWyf (ORCPT ); Thu, 1 Feb 2018 17:54:35 -0500 Received: by mail-wr0-f196.google.com with SMTP id i56so20729413wra.7 for ; Thu, 01 Feb 2018 14:54:35 -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=RJ/JsswDo6kuLK9vGJRs3yutTp445wteqVBNOMxdJFs=; b=ntRPIYL4227a4Yy7dmmgQaa+kPO8nASaYJxs3bwZzNjwnxkTRNyAVtHL10XxfwKBhI itEpPhyoDRd4Y/vmZzJXrwIkQp2GgRCed7QP+MR6WOd9IDyVpqOp6Uln5uPy+FVQHWKJ bFhPPX9KsSL2tcFYhc9d2YwKWGa0cv0kCR7+egElgR+qgpiina51iuYq2Mk4CU1XsdSE F+Wnx5e2F6FUADrfk1OAjndfG+Trjfsz6Ez2JIZHH1EfJJJam8INiaHxk9BCORpkBqz5 dRywWdQAKkbvVsPCeJT7mmFcfQ6ZKB3i0h0ULsHvpx3QGSB3oq6fYp5jPq+B4vBOa6XQ x7rw== 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=RJ/JsswDo6kuLK9vGJRs3yutTp445wteqVBNOMxdJFs=; b=j+YmFVdH3NUc1rxDdNrb9la3Y7XX0En2yZURhkYBW+7dw3fK+Pm6PCWqGX4SmB7ysT n2PysLRfqM2fWEp+FvzhRU5TOp97gn7FnnsHZEqoucpsqK/fwRNdLIK0+M7OyDPR79h9 o2A0jr0eT3A5Qgb/uvpXF8gmXGf8/lHJvT2EY= 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=RJ/JsswDo6kuLK9vGJRs3yutTp445wteqVBNOMxdJFs=; b=hiXowLGE7rBKlGRmLw+dZ3FbA15304taG7Cdexja7YZeLyDJagOsY7hc98Z0xRtzou YdQ8MIzfWqmoX/i5M90f0Klq+/PXbjox109lSEVrkpyEgfsqQiTfT8U5IaTO2/PQyx4w cZDkqVPZgwUJQcHgBKgED5bykRqEbK7WxKM4RxYOEvcNV/KuUcWdDOvs2+s1poWCs83E 50XZg8/AZIo29HABu8mVMqUKNV+7xpuga+zC5+YeJmV9D0WZuMsipOXN9y4+JIb1hj9T oF0KNPs4f93aEgWIYnBzh/meUv1FtZFdKrqAN5klS9E6nqKbUWB3XvqgE48NAJ9IiDPb 8wBg== X-Gm-Message-State: AKwxytf4Pj2ALT3s3jqWkQFT8pGhMjpNEyOu6nOvG72HkYQVh3AOqXUG Wt3i2tNLE3R/BKC9lDyVY7nVRwIjuIbkpJ6Apc/nhOIS X-Received: by 10.223.157.1 with SMTP id k1mr20006090wre.275.1517525674178; Thu, 01 Feb 2018 14:54:34 -0800 (PST) MIME-Version: 1.0 Received: by 10.28.124.6 with HTTP; Thu, 1 Feb 2018 14:54:33 -0800 (PST) In-Reply-To: <20180130010007.256564-3-dbasehore@chromium.org> References: <20180130010007.256564-1-dbasehore@chromium.org> <20180130010007.256564-3-dbasehore@chromium.org> From: "dbasehore ." Date: Thu, 1 Feb 2018 14:54:33 -0800 X-Google-Sender-Auth: GoF_SKA_xWgl2nl-MBrVAqDoY_U Message-ID: Subject: Re: [PATCH v3 2/5] irqchip/gic-v3-its: add ability to save/restore ITS state To: linux-kernel Cc: 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 , Marc Zyngier , Derek Basehore 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 Mon, Jan 29, 2018 at 5:00 PM, 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..759ede7048ed 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) > > @@ -83,6 +85,15 @@ struct its_baser { > u32 psz; > }; > > +/* > + * Saved ITS state - this is where saved state for the ITS is stored > + * when it's disabled during system suspend. > + */ > +struct its_ctx { > + u64 cbaser; > + u32 ctlr; > +}; > + > struct its_device; > > /* > @@ -101,6 +112,7 @@ struct its_node { > struct its_collection *collections; > struct fwnode_handle *fwnode_handle; > u64 (*get_msi_base)(struct its_device *its_dev); > + struct its_ctx its_ctx; > struct list_head its_device_list; > u64 flags; > unsigned long list_nr; > @@ -3042,6 +3054,75 @@ 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) { > + 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) { > + pr_err("ITS failed to quiesce\n"); > + 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; > +} > + > +static void its_restore_enable(void) > +{ > + struct its_node *its; > + > + 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; > + struct its_baser *baser; > + int i; > + > + 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); > + } It seems that we need to resolve its->cmd_write with the current state of GITS_CREADR and GITS_CWRITER. Otherwise, the code that detects the ITS getting wedged will trigger. > + 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; > @@ -3261,6 +3342,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 +3599,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 >