Received: by 10.223.176.46 with SMTP id f43csp1176323wra; Fri, 26 Jan 2018 13:13:54 -0800 (PST) X-Google-Smtp-Source: AH8x224AFGgvxrgcA8VqzE2sDwLa2wMxw1NfUkogt48DIzn9R0suzfPG1pIM2Pf2Gzuj1pyDItPh X-Received: by 10.101.83.76 with SMTP id w12mr15947305pgr.95.1517001234036; Fri, 26 Jan 2018 13:13:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517001234; cv=none; d=google.com; s=arc-20160816; b=whK678nWZiH5ssxGmowLJ3fnqlgGKW3LdOAPU/3EE8os6OljDQOC+0geKxYfNHNg5u u4iFRVvmLwMJd5AWsHOb09KrNTaFpvncidoBUzZ/Mu0IR9s7kbmNejx/pX2cxT8m7OSZ a0QGvS261vBoU5IBqNjZlqejcJ3uaSn/eOxFPA5/WOZRcDtxc8XqhOBgSmr0vstM0e0U CPgX9RamX8ACEhUZq5yz+5WTNXaBpnVChxVYwsdy799yiX61cxZyVsI9XG0ZGWoKqwiV bUKEg9DLstB8/ah/m+TGpvE4utsOyEiBFDyTzY3WbF0jXSg1RJb4+/icxwLfBNfB1Edg n9VQ== 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=57YEYo3R1Ha6jQBxzmCx7A621Vf8E0Qld622+Edr43E=; b=drMXI1mvdl5ppLALpXqntlT/+j45RqATQNyXyN5frWeO2LxmSrstVD1ggpg3qNNI4A Mld6W0VtMlb/Tru7dwYG4k1yWES/IVU++lEm7W6Z6t21jdaJGScfsPcE2lXVZa7ovF1l 8Kd3TcJzLMxJHaEEikza3BfWG5KCc0KWB3a3iL5XQHy3X/GMncZP8OeQnLLmd4rSYg85 l5NbVTGZnXJ1Z1u326cXHEH+Hy2f9gZagC+iTafiwfQoOZ7EvJoWo0fcRb9XoXXShAJV nwrXkKbFF5GXdGtOrz4yHoCjEGXR+ThWvrBvCigXKIkvsry2T0WRgPFOGU8GCVC+WbjY QCxQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@google.com header.s=20161025 header.b=sgCfLJzJ; dkim=fail header.i=@chromium.org header.s=google header.b=YZyC5W/f; 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 x25si6968098pfj.295.2018.01.26.13.13.39; Fri, 26 Jan 2018 13:13:53 -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=sgCfLJzJ; dkim=fail header.i=@chromium.org header.s=google header.b=YZyC5W/f; 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 S1751885AbeAZVNF (ORCPT + 99 others); Fri, 26 Jan 2018 16:13:05 -0500 Received: from mail-wm0-f67.google.com ([74.125.82.67]:34979 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751273AbeAZVND (ORCPT ); Fri, 26 Jan 2018 16:13:03 -0500 Received: by mail-wm0-f67.google.com with SMTP id r78so23694716wme.0 for ; Fri, 26 Jan 2018 13:13:02 -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=57YEYo3R1Ha6jQBxzmCx7A621Vf8E0Qld622+Edr43E=; b=sgCfLJzJaDIFKz0G4Yu+wQT6sC3GeqP/oxov5CvA/5PmDt2FcF2mOxw1GBTGJXIXyQ XdSJT/yON1GHcLdpoX1H9ZguaPLv4vvdVCZpKkPRLR5cIpVP737IhUZU21KAlN5K229G 566UuYsZFjoJy12RyJr16cR/yNJQu5ok1F4ObC/hQfR2+zvYWKCQKXNvueJsavxlQ4SC jEfJbL4+kH+PUht0ZDH5TnfBlOh+NpyvBi4TENRe8OpkgTPLrSkvmD1mR7PLz8M15r33 +89Pz6UjfOHEFXreb7HO9LK+Tu5TAhGtlydtUQrFyEn1TJlAIPbv8wH4nVx5uJYIhLM3 UTCw== 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=57YEYo3R1Ha6jQBxzmCx7A621Vf8E0Qld622+Edr43E=; b=YZyC5W/fCkzNIGCcLBQHKSl7OqF3TlbLCvwZZ4ih+lqivdLGzSUk9AyJD/sN+tSUNF f1hSPiamlWTb+A0epIGzi8mkv8aNmNJzE3UZiCWhAwXIL51PD+EqYDt69amjpIfjWVoO ukb8BqKFYda414zfZNcfA/8eryXZW/1kLaciM= 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=57YEYo3R1Ha6jQBxzmCx7A621Vf8E0Qld622+Edr43E=; b=K1Zo4ZI5D05gMahcfQN/Or6zYh9uapWj6l7xKwLcW3dK+lmKiqYzd5AqtOx3p02gU9 +3YNJIUX1Lt4L2S/T7e2+vijW9UTCzCYzdXigW2dICZytgbEan5Uv2NMwwo7L7sWBXJa zsZD5qmcfHwUdNp9CmHO3X59+kgWiFtRGjI1oYSbDZ9df0/re1ILKJ/wm5XnDQ5oYGMj LTcIWdmnqyAG3VDUsWmyDLWhg/x9uyKTj98B2PQ0C51EzujnV+FuHmZ0EUiKxun+klXl OvqDmOZxjO+hw/PZEitMOfSOy5BZmFZyi0nyopduSvnuQnXpRvEvrBxCyK9lkY4Th72h pSSg== X-Gm-Message-State: AKwxytfR8Z+FuKu88Ie1Aj4rSYFkFco8bZe+XH03FM8ZwJe+KYlEDBVD O4U+wMrkSG2JVxvzupOuSCEa3JXLnJ/NbkhJ6mAcCjWV X-Received: by 10.28.218.207 with SMTP id r198mr11550769wmg.138.1517001181823; Fri, 26 Jan 2018 13:13:01 -0800 (PST) MIME-Version: 1.0 Received: by 10.28.124.6 with HTTP; Fri, 26 Jan 2018 13:13:00 -0800 (PST) In-Reply-To: <20180126205954.cikwitw7sgdt2yn3@ban.mtv.corp.google.com> References: <20180126073835.16575-1-dbasehore@chromium.org> <20180126073835.16575-3-dbasehore@chromium.org> <20180126205954.cikwitw7sgdt2yn3@ban.mtv.corp.google.com> From: "dbasehore ." Date: Fri, 26 Jan 2018 13:13:00 -0800 X-Google-Sender-Auth: fDdhf7bxR0QI-an9phehxK_9bmY Message-ID: Subject: Re: [PATCH v2 2/5] irqchip/gic-v3-its: add ability to save/restore ITS state To: Brian Norris Cc: linux-kernel , Soby Mathew , Sudeep Holla , devicetree@vger.kernel.org, robh+dt@kernel.org, Mark Rutland , Linux-pm mailing list , "Wysocki, Rafael J" , Thomas Gleixner , Marc Zyngier 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 Fri, Jan 26, 2018 at 12:59 PM, Brian Norris wrote: > 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. Oops. I'll change that and add a pr_err in the its_force_quiescent error case in the next patch set. > > 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;