From patchwork Tue Jun 21 10:15:51 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dirk Behme X-Patchwork-Id: 9190195 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 D3AF76075E for ; Tue, 21 Jun 2016 10:18:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BFCED28156 for ; Tue, 21 Jun 2016 10:18:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B417F2815E; Tue, 21 Jun 2016 10:18:26 +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=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 33AC728156 for ; Tue, 21 Jun 2016 10:18:26 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bFIjZ-0004s6-GL; Tue, 21 Jun 2016 10:16:41 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bFIjY-0004rR-88 for xen-devel@lists.xenproject.org; Tue, 21 Jun 2016 10:16:40 +0000 Received: from [85.158.139.211] by server-3.bemta-5.messagelabs.com id 2C/51-10364-70419675; Tue, 21 Jun 2016 10:16:39 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrOIsWRWlGSWpSXmKPExsXSzf+WW5ddJDP c4PJ+VovvWyYzOTB6HP5whSWAMYo1My8pvyKBNWPx3Hb2gg9SFbvX/WRqYHwj0sXIySEkcJZR Yu5D7S5GLg4WgbdMEvM+/mEDcYQEnjNKXFmwmgnCWcMosfzScRYIZyWjxIdlS1hB+tkEtCR2T uhgB7FFBMolVu17BBTn4GAW0JDYsA0sLCwQJLG2px8szCKgKjHxhgZImFfATaJ/7xGwKRICch LrJn9nh4gLSpyc+YQFxGYWkJA4+OIFM0SNiMTEv+/ZIGxLifaVJ8FukxDYxyxx5lsT8wRGwVl I+mch6V/AyLSKUb04tagstUjXUC+pKDM9oyQ3MTNH19DAVC83tbg4MT01JzGpWC85P3cTIzBA 6xkYGHcwNvU6H2KU5GBSEuVlVs4IF+JLyk+pzEgszogvKs1JLT7EKMPBoSTBW8WfGS4kWJSan lqRlpkDjBWYtAQHj5II7wKQNG9xQWJucWY6ROoUo6KUOG8MSEIAJJFRmgfXBovPS4yyUsK8jA wMDEI8BalFuZklqPKvGMU5GJWEeVeBTOHJzCuBm/4KaDET0OJl/ekgi0sSEVJSDYwcQttnh89 XC7jU7vfYOErnJnOMzb2wKznqy54nWSmpRZy78vWDOcPa31OnLf1wYPqiVRKrfpZk+LLsObq2 rHrbNSmWo3uvmCu+e/fBI9NT4aL0kj7xR/tWebXuqG3Y9E7oqmLt1VNTlX526f9b1XhowZoLs +xeKBgU5x0/ffKJR//lozuXPJz5QomlOCPRUIu5qDgRAEOhTEDKAgAA X-Env-Sender: Dirk.Behme@de.bosch.com X-Msg-Ref: server-4.tower-206.messagelabs.com!1466504198!45961910!1 X-Originating-IP: [139.15.237.11] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogMTM5LjE1LjIzNy4xMSA9PiAxNTMwMzA=\n X-StarScan-Received: X-StarScan-Version: 8.46; banners=-,-,- X-VirusChecked: Checked Received: (qmail 60804 invoked from network); 21 Jun 2016 10:16:39 -0000 Received: from smtp6-v.fe.bosch.de (HELO smtp6-v.fe.bosch.de) (139.15.237.11) by server-4.tower-206.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 21 Jun 2016 10:16:39 -0000 Received: from vsmta12.fe.internet.bosch.com (unknown [10.4.98.52]) by imta23.fe.bosch.de (Postfix) with ESMTP id 8A244158020A for ; Tue, 21 Jun 2016 12:16:38 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=de.bosch.com; s=2015-01-21; t=1466504198; bh=AT89OkS/M8CnSqWEp8Uik5paM/V20y+qQ1Ez5h3EMBI=; l=10; h=From:From:Reply-To:Sender; b=IwUSoo8wog9JJe++f76uIKwctE+nYp2TcVp+/QExN6/6ND6ockcbp+KRBgDJRAYz8 MRoWoQuCQfK5B0AqP+Cao0rpaYqBJzM19cE+HTZtymbmYyDnmCEpPvcamL+5an1Zxb m3nd4o7tV7X9bZb8SuHXjmK+rm3JaVIiZTvJhKtY= Received: from FE-HUB1000.de.bosch.com (vsgw24.fe.internet.bosch.com [10.4.98.24]) by vsmta12.fe.internet.bosch.com (Postfix) with ESMTP id 0DB9E1B80216 for ; Tue, 21 Jun 2016 12:16:38 +0200 (CEST) Received: from hi-z08if.hi.de.bosch.com (10.34.209.31) by FE-HUB1000.de.bosch.com (10.4.103.107) with Microsoft SMTP Server id 14.3.195.1; Tue, 21 Jun 2016 12:16:37 +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 0A1CF625F14; Tue, 21 Jun 2016 12:15:54 +0200 (CEST) From: Dirk Behme To: , Julien Grall , Stefano Stabellini Date: Tue, 21 Jun 2016 12:15:51 +0200 Message-ID: <1466504151-9163-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-22404.006 X-TMASE-MatchedRID: 5aJpZVhWVXPqouWR3W5zBhlckvO1m+JcsjXBCUyiRiZPL4NRV2o9aPbF CxAQ6srCwNZPp7AoN3cQzi0udqzS8ccbIktDN1VLU+OjsPhIWDhQCOsAlaxN704K0IMk2m3GW5I ZSmTamxQa+2oJMpMUCWORSLQc05sjbu8QqMQjwvIve6W+IORwrb4X/8yfdrbDBHll6E388aDf/T epSvSh+k4W7yyyPEbzV1M/l3DgYRERJRCz3HVEJ6IBnfMCFBiC6GrWC/wEypgwxiS02+dfZnjJ+ AmVpW5c0jz1EI6B2Jt5ILz8QQa833tnPxQhmlj7ngIgpj8eDcAZ1CdBJOsoY8RB0bsfrpPIfiAq rjYtFiQyx8FCct4ZxgBTuiJNCZvAdBrdP6pIK+H2cyhngkdVkn7cGd19dSFd Cc: Dirk Behme Subject: [Xen-devel] [PATCH] xen/arm: domain_build: DT: add clocks node to the hypervisor node X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP Some clocks might be used by Xen (drivers) and not by the Linux kernel. If these are not registered by the Linux kernel, they might be disabled by the Linux kernel's clk_disable_unused() as the kernel doesn't know that they are used (by Xen drivers). 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, add the clocks used by Xen to the hypervisor node. The Linux kernel has to register the clocks from the hypervisor node, then. Therefore, collect all clocks from nodes used by Xen. These are marked with DOMID_XEN. Afterwards, add a 'clocks' node to the hypervisor node containing all these clocks. The Linux kernel can register all these clocks, preventing them from being disabled, then. Signed-off-by: Dirk Behme --- xen/arch/arm/domain_build.c | 20 ++++++++++++++++++++ xen/arch/arm/kernel.h | 7 +++++++ 2 files changed, 27 insertions(+) diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index 2e4c295..fccf87e 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -657,6 +657,10 @@ static int make_hypervisor_node(const struct kernel_info *kinfo, if ( res ) return res; + res = fdt_property(fdt, "clocks", kinfo->clk.dtclocks, kinfo->clk.cnt); + if ( res ) + return res; + res = fdt_end_node(fdt); return res; @@ -1213,9 +1217,11 @@ static int handle_node(struct domain *d, struct kernel_info *kinfo, { /* sentinel */ }, }; struct dt_device_node *child; + unsigned int len; int res; const char *name; const char *path; + const char *clocks; path = dt_node_full_name(node); @@ -1246,6 +1252,20 @@ static int handle_node(struct domain *d, struct kernel_info *kinfo, if ( dt_device_used_by(node) == DOMID_XEN ) { DPRINT(" Skip it (used by Xen)\n"); + + /* + * Remember the clock used by the skipped node + * We add it later to the hypervisor node to make the + * Linux kernel aware of its usage + */ + clocks = dt_get_property(node, "clocks", &len); + if ( kinfo->clk.cnt + len >= MAX_DT_CLOCKS ) { + printk("Failed to remember the clock node of %s\n", path); + printk("Use the Linux kernel command 'clk_ignore_unused'\n"); + return 0; + } + memcpy(&kinfo->clk.dtclocks[kinfo->clk.cnt], clocks, len); + kinfo->clk.cnt += len; return 0; } diff --git a/xen/arch/arm/kernel.h b/xen/arch/arm/kernel.h index c1b07d4..527b279 100644 --- a/xen/arch/arm/kernel.h +++ b/xen/arch/arm/kernel.h @@ -10,6 +10,12 @@ #include #include +#define MAX_DT_CLOCKS 256 +struct dtclk { + unsigned char dtclocks[MAX_DT_CLOCKS]; + unsigned int cnt; +}; + struct kernel_info { #ifdef CONFIG_ARM_64 enum domain_type type; @@ -18,6 +24,7 @@ struct kernel_info { void *fdt; /* flat device tree */ paddr_t unassigned_mem; /* RAM not (yet) assigned to a bank */ struct meminfo mem; + struct dtclk clk; /* kernel entry point */ paddr_t entry;