From patchwork Tue Jul 5 06:50:23 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dirk Behme X-Patchwork-Id: 9213713 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 315646048B for ; Tue, 5 Jul 2016 06:52:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2055F288EE for ; Tue, 5 Jul 2016 06:52:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1231E288F9; Tue, 5 Jul 2016 06:52:39 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 81E41288EE for ; Tue, 5 Jul 2016 06:52:38 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1bKKC8-0000W4-Sc; Tue, 05 Jul 2016 06:50:56 +0000 Received: from smtp6-v.fe.bosch.de ([2a03:cc00:ff0:100::2]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bKKC5-0000VT-Cr for linux-arm-kernel@lists.infradead.org; Tue, 05 Jul 2016 06:50:55 +0000 Received: from vsmta11.fe.internet.bosch.com (unknown [10.4.98.51]) by imta24.fe.bosch.de (Postfix) with ESMTP id 430F4D8022D for ; Tue, 5 Jul 2016 08:50:29 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=de.bosch.com; s=2015-01-21; t=1467701429; bh=AT89OkS/M8CnSqWEp8Uik5paM/V20y+qQ1Ez5h3EMBI=; l=10; h=From:From:Reply-To:Sender; b=FcVUWkixIRl8+e4PvN9UcbehLaC8cWkfwi2tNqjNIMmWTcbvH0bUuwhGTpIIVBB6B mPDyJWQpqP+ytIcVUp7dlKLPN8PIw5mrU/8mhPKN+z8zzoTTTUKB/PlnWU3q5Vsq9w 8ZIQK0kSeO4DII4jQ9MyhFoteggsyfi3Sq1sryl8= Received: from SI-HUB1000.de.bosch.com (vsgw24.fe.internet.bosch.com [10.4.98.24]) by vsmta11.fe.internet.bosch.com (Postfix) with ESMTP id 02D4023804D2 for ; Tue, 5 Jul 2016 08:50:29 +0200 (CEST) Received: from hi-z08if.hi.de.bosch.com (10.34.209.31) by SI-HUB1000.de.bosch.com (10.4.103.106) with Microsoft SMTP Server id 14.3.195.1; Tue, 5 Jul 2016 08:50:27 +0200 Received: from hi-z08if.hi.de.bosch.com (localhost [127.0.0.1]) by hi-z08if.hi.de.bosch.com (Postfix) with ESMTP id E0050625EB1; Tue, 5 Jul 2016 08:50:25 +0200 (CEST) From: Dirk Behme To: , Julien Grall , Mark Rutland , Subject: [PATCH v2] xen/arm: register clocks used by the hypervisor Date: Tue, 5 Jul 2016 08:50:23 +0200 Message-ID: <1467701423-31138-1-git-send-email-dirk.behme@de.bosch.com> X-Mailer: git-send-email 2.8.0 MIME-Version: 1.0 X-TM-AS-MML: disable X-TM-AS-Product-Ver: IMSS-7.1.0.1679-8.0.0.1202-22430.006 X-TMASE-MatchedRID: YYRiR3G8nDE3AywPeXaPs4SvKOGqLLPKKFFZAe4nyZ6l4EP+dy+wBI5U t/GFUgZN1l/Ke7HS1Fvuuh2i/F0Zm/I8dAH2k/lEZr2eAUSCHjuHxi2fvkKUM/gnJH5vm2+gwbD ngUleUcJVbmUBto85MLXJ7NiG0ChHD0VXqQ1iI8fJ1E/nrJFEDyolbMkvkyYH33Nl3elSfsrqVD pbtVZ/ECROVbws38B0ftRpysGxPQaPs2LHyC7VZQPZZctd3P4BmyqQJWNsukkLCC+rIG9+ZTUi2 rTIOxGG0OOjUkZ7h+rBFypIQ33lJNazy5m6fkXW4pdq9sdj8LW2+OflY2YjKeC/VgAwsKszO+IR wN/eBaJX6UIPOG+iLdVuPsZd+OOaZ28ZQS4q9Jyjjjbs8MoLRhv1UCk/2TUEmyiLZetSf8mfop0 ytGwvXiq2rl3dzGQ1RtCVJiW8rLQjc6NPlpIS4Dq5ds+vVWx/MhNIzkbD2kA1Z/I2pbMohQ== X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160704_235054_115931_6B9FB1FA X-CRM114-Status: GOOD ( 17.99 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Stefano Stabellini , Michael Turquette , Stephen Boyd , Dirk Behme , xen-devel@lists.xenproject.org, linux-clk@vger.kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Some clocks might be used by the Xen hypervisor and not by the Linux kernel. If these are not registered by the Linux kernel, they might be disabled by clk_disable_unused() as the kernel doesn't know that they are used. The clock of the serial console handled by Xen is one example for this. It might be disabled by clk_disable_unused() which stops the whole serial output, even from Xen, then. Up to now, the workaround for this has been to use the Linux kernel command line parameter 'clk_ignore_unused'. See Xen bug http://bugs.xenproject.org/xen/bug/45 too. To fix this, we will add the "unused" clocks in Xen to the hypervisor node. The Linux kernel has to register the clocks from the hypervisor node, then. Therefore, check if there is a "clocks" entry in the hypervisor node and if so register the given clocks to the Linux kernel clock framework and with this mark them as used. This prevents the clocks from being disabled. Signed-off-by: Dirk Behme --- Changes in v2: Drop the Linux implementation details like clk_disable_unused in xen.txt. Documentation/devicetree/bindings/arm/xen.txt | 13 ++++++++ arch/arm/xen/enlighten.c | 47 +++++++++++++++++++++++++++ 2 files changed, 60 insertions(+) diff --git a/Documentation/devicetree/bindings/arm/xen.txt b/Documentation/devicetree/bindings/arm/xen.txt index c9b9321..21fd469 100644 --- a/Documentation/devicetree/bindings/arm/xen.txt +++ b/Documentation/devicetree/bindings/arm/xen.txt @@ -17,6 +17,19 @@ the following properties: A GIC node is also required. This property is unnecessary when booting Dom0 using ACPI. +Optional properties: + +- clocks: one or more clocks to be registered. + Xen hypervisor drivers might replace native drivers, resulting in + clocks not registered by these native drivers. To avoid that these + unregistered clocks are disabled by the Linux kernel initialization + register them in the hypervisor node. + An example for this are the clocks of a serial driver already enabled + by the firmware. If the clocks used by the serial hardware interface + are not registered by the serial driver itself the serial output + might stop once the Linux kernel initialization disables the 'unused' + clocks. + To support UEFI on Xen ARM virtual platforms, Xen populates the FDT "uefi" node under /hypervisor with following parameters: diff --git a/arch/arm/xen/enlighten.c b/arch/arm/xen/enlighten.c index 47acb36..5c546d0 100644 --- a/arch/arm/xen/enlighten.c +++ b/arch/arm/xen/enlighten.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -444,6 +445,52 @@ static int __init xen_pm_init(void) } late_initcall(xen_pm_init); +/* + * Check if we want to register some clocks, that they + * are not freed because unused by clk_disable_unused(). + * E.g. the serial console clock. + */ +static int __init xen_arm_register_clks(void) +{ + struct clk *clk; + struct device_node *xen_node; + unsigned int i, count; + int ret = 0; + + xen_node = of_find_compatible_node(NULL, NULL, "xen,xen"); + if (!xen_node) { + pr_err("Xen support was detected before, but it has disappeared\n"); + return -EINVAL; + } + + count = of_clk_get_parent_count(xen_node); + if (!count) + goto out; + + for (i = 0; i < count; i++) { + clk = of_clk_get(xen_node, i); + if (IS_ERR(clk)) { + pr_err("Xen failed to register clock %i. Error: %li\n", + i, PTR_ERR(clk)); + ret = PTR_ERR(clk); + goto out; + } + + ret = clk_prepare_enable(clk); + if (ret < 0) { + pr_err("Xen failed to enable clock %i. Error: %i\n", + i, ret); + goto out; + } + } + + ret = 0; + +out: + of_node_put(xen_node); + return ret; +} +late_initcall(xen_arm_register_clks); /* empty stubs */ void xen_arch_pre_suspend(void) { }