From patchwork Fri Jan 30 07:46:49 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abel Wu X-Patchwork-Id: 5747451 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 0EE899F358 for ; Fri, 30 Jan 2015 07:51:09 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 41B54200DB for ; Fri, 30 Jan 2015 07:51:08 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 75D862024D for ; Fri, 30 Jan 2015 07:51:07 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1YH6KN-0000hj-KD; Fri, 30 Jan 2015 07:49:19 +0000 Received: from szxga03-in.huawei.com ([119.145.14.66]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1YH6Jl-0000FZ-2i for linux-arm-kernel@lists.infradead.org; Fri, 30 Jan 2015 07:48:44 +0000 Received: from 172.24.2.119 (EHLO szxeml428-hub.china.huawei.com) ([172.24.2.119]) by szxrg03-dlp.huawei.com (MOS 4.4.3-GA FastPath queued) with ESMTP id BBD63041; Fri, 30 Jan 2015 15:48:01 +0800 (CST) Received: from localhost (10.177.24.136) by szxeml428-hub.china.huawei.com (10.82.67.183) with Microsoft SMTP Server id 14.3.158.1; Fri, 30 Jan 2015 15:47:52 +0800 From: Yun Wu To: , , Subject: [PATCH 5/5] irqchip: gicv3-its: add support for power down Date: Fri, 30 Jan 2015 15:46:49 +0800 Message-ID: <1422604009-9248-6-git-send-email-wuyun.wu@huawei.com> X-Mailer: git-send-email 1.9.4.msysgit.1 In-Reply-To: <1422604009-9248-1-git-send-email-wuyun.wu@huawei.com> References: <1422604009-9248-1-git-send-email-wuyun.wu@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.177.24.136] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020203.54CB3732.0090, ss=1, re=0.001, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=0.0.0.0, so=2013-05-26 15:14:31, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 5936080031964999c607a37875d8698a X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150129_234841_917255_CE539152 X-CRM114-Status: GOOD ( 12.94 ) X-Spam-Score: -2.3 (--) Cc: Yun Wu , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Configurations of an ITS cannot be changed if the ITS is in an active status, so it might not be safe to perform a soft reboot with all the active ITSes un-disabled, etc. kexec. This patch will make sure all the active ITSes disabled before enabling them again without resetting ITS hardware. Signed-off-by: Yun Wu --- drivers/irqchip/irq-gic-v3-its.c | 59 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) -- 1.8.0 diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c index facf6d6..1d85471 100644 --- a/drivers/irqchip/irq-gic-v3-its.c +++ b/drivers/irqchip/irq-gic-v3-its.c @@ -29,6 +29,7 @@ #include #include #include +#include #include @@ -1410,6 +1411,63 @@ int its_cpu_init(void) return 0; } +static void its_disable(struct its_node *its) +{ + u32 count = 1000000; /* 1s */ + u32 val; + + /* Disable the generation of all interrupts to this ITS */ + val = readl_relaxed(its->base + GITS_CTLR); + val &= ~GITS_CTLR_ENABLE; + writel_relaxed(val, its->base + GITS_CTLR); + + /* Poll GITS_CTLR and wait until ITS becomes quiescent */ + while (count--) { + val = readl_relaxed(its->base + GITS_CTLR); + if (val & GITS_CTLR_QUIESCENT) + break; + cpu_relax(); + udelay(1); + } + + if (!count) + pr_err("%s: failed to shutdown!\n", + its->msi_chip.of_node->full_name); + + /* + * Release all resources of this ITS node to completely put + * an end to it. Note that this step may not be necessary + * in some cases, but leaving it here does no harm. + */ + irq_domain_remove(its->msi_chip.domain); + irq_domain_remove(its->domain); + its_free_tables(its); + kfree(its->cmd_base); + iounmap(its->base); + + spin_lock(&its_lock); + list_del(&its->entry); + spin_unlock(&its_lock); + kfree(its); +} + +static int its_shutdown(struct notifier_block *nfb, unsigned long val, void *v) +{ + struct its_node *its, *tmp; + + list_for_each_entry_safe(its, tmp, &its_nodes, entry) + its_disable(its); + + kfree(gic_rdists->prop_page); + kfree(lpi_bitmap); + + return NOTIFY_OK; +} + +static struct notifier_block its_reboot_notifier = { + .notifier_call = its_shutdown, +}; + static struct of_device_id its_device_id[] = { { .compatible = "arm,gic-v3-its", }, {}, @@ -1435,6 +1493,7 @@ int its_init(struct device_node *node, struct rdists *rdists, its_alloc_lpi_tables(); its_lpi_init(rdists->id_bits); + register_reboot_notifier(&its_reboot_notifier); return 0; }