From patchwork Wed Jan 20 08:31:22 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng Fan X-Patchwork-Id: 8069981 Return-Path: X-Original-To: patchwork-xen-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 9F29FBEEE5 for ; Wed, 20 Jan 2016 08:50:10 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7A94A20390 for ; Wed, 20 Jan 2016 08:50:09 +0000 (UTC) Received: from lists.xen.org (lists.xenproject.org [50.57.142.19]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 538542038A for ; Wed, 20 Jan 2016 08:50:08 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aLoQN-0008M1-JQ; Wed, 20 Jan 2016 08:47:31 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aLoQM-0008Ld-7F for xen-devel@lists.xenproject.org; Wed, 20 Jan 2016 08:47:30 +0000 Received: from [193.109.254.147] by server-6.bemta-14.messagelabs.com id EA/E5-16618-1A94F965; Wed, 20 Jan 2016 08:47:29 +0000 X-Env-Sender: van.freenix@gmail.com X-Msg-Ref: server-12.tower-27.messagelabs.com!1453279646!17976194!1 X-Originating-IP: [209.85.220.50] X-SpamReason: No, hits=0.5 required=7.0 tests=BODY_RANDOM_LONG X-StarScan-Received: X-StarScan-Version: 7.35.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 18860 invoked from network); 20 Jan 2016 08:47:28 -0000 Received: from mail-pa0-f50.google.com (HELO mail-pa0-f50.google.com) (209.85.220.50) by server-12.tower-27.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 20 Jan 2016 08:47:28 -0000 Received: by mail-pa0-f50.google.com with SMTP id uo6so1399232pac.1 for ; Wed, 20 Jan 2016 00:47:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=pIXCOTktdXpDfbs136e2wEJbT4F5PLRjW5TKPEy8PtY=; b=CsiN5yoe2ylM4/WjCQ8T/wKnwDOcTnfx3dlrs+7ngdCAIfktUYkZorFStVxUaDQxMO FlgF64s4U5eec2fNUlsUCKvK7OTxabZHeIyZUL4BLf8NzbOC7/nTI8jDs+DQY1Df4lGQ W4QZ008B0s0IWUVg8lQnjfsS2f35VuQO/znMfIh6pIpzSmWTRfzEFp6tVoHQMFL3Nu/o LsJf2qP42BNCtZXciEEP3kHMdp0sH8tbx0FsEpUYsZL5DU5lrDIs95k6+3hUn/S8Li97 kRH4vMHIcpU2g7vrQ1ugPbqNj+ckly4KQsZrcNFCBriVIBb4KzOZDfRu6oggq2Bcgcp1 6SSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=pIXCOTktdXpDfbs136e2wEJbT4F5PLRjW5TKPEy8PtY=; b=Sc8FKAo2fmQd8k9asFr7J6fvhu9kJmLJHotdlx4h9vo57tx6olOzaFZYXUXfEXeGSp 2l4ytqtuwvNp/XhM/6XtsrSyfkV92zXVBlpA8yvdoiuaK9eJAWZxIOthYGfCsdzA8siM 5vUClJ5F7YyoBNhdC8SeLCDytn8LJTAWYqf+/AAGkgcsutkA7rRAAEwdHi9vhkDnBVIb ivrb4jAu4xjh4L3nIN4bZ+Kt9jrOc9J2H3WJ7HshdMqugkOSt2J+vAijpAOum7mjGzSL dAKW6eWrf5t1P/T06wo9c9za32sAzeiov5wCl1WaO6NX26QomVO5klAMrnOUnV+rMzWB FVCQ== X-Gm-Message-State: ALoCoQn3BwxZqUzJKv1aL6BA4MYSy/imvbKkvyHGdq0PdKfFb3dD4qhkCOYIhixZwj09d6pCxBEO3r3zNgayJCbq3OAXdngdww== X-Received: by 10.66.234.200 with SMTP id ug8mr51110983pac.129.1453279646369; Wed, 20 Jan 2016 00:47:26 -0800 (PST) Received: from linux-7smt.suse (gate-zmy3.freescale.com. [192.88.167.1]) by smtp.gmail.com with ESMTPSA id 72sm46935259pfk.28.2016.01.20.00.47.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 20 Jan 2016 00:47:25 -0800 (PST) From: Peng Fan To: xen-devel@lists.xenproject.org Date: Wed, 20 Jan 2016 16:31:22 +0800 Message-Id: <1453278682-8750-1-git-send-email-van.freenix@gmail.com> X-Mailer: git-send-email 2.6.2 Cc: Ian Campbell , Stefano Stabellini , George Dunlap , Julien Grall , David Vrabel , van.freenix@gmail.com Subject: [Xen-devel] [RFC V2] xen: interface: introduce pvclk interface X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID, 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 Introduce pvclk interface which is useful when doing device passthrough on ARM platform. To ARM platform, saying embedded SoCs, clock management hardware IP is controlled by Dom0, DomU does not have clocksource. So we need a paravirtualized clock source to let DomU can handle device that are passed through from Dom0. Signed-off-by: Peng Fan Cc: George Dunlap Cc: Konrad Rzeszutek Wilk Cc: David Vrabel Cc: Julien Grall Cc: Stefano Stabellini Cc: Ian Campbell --- V2: The V1 thread: http://lists.xen.org/archives/html/xen-devel/2016-01/msg01860.html The V1 thread binds the interface part to the implementation for linux kernel. This V2 only contains the pvclk interface part. In this patch: Backend, /local/domain//backend/vclk//nr-clks /local/domain//backend/vclk///name Y is frontend domid, Z is clk id, name is the clk name. Frontend, /local/domain//device/vclk/clk-ring-ref /local/domain//device/vclk/event-channel /local/domain//device/vclk//name Y is the clk id. My original idea is to pass clk name which is parsed from dts. And not expose clk name to xenstore. DomU pass the name to Dom0, Dom0 use the name to find correct clk and operate on the clk. Not sure whether I am right or not, please advise. I have no knowledge of ACPI, just following Ian's comment on V1, I add the clk id and expose the info to xenstore, but discard the devid/bus. If devid/bus is needed, I think we can encoded it into the clk id part in future. Exposing the info to xenstore means we need to add entry in xl configuration file like this: vclks = ["id:clkname", "id:clkname"] --> vclks = ["1:uart2-root-clk", "3:gpu-root-clk"]. And the libxl pvclk should parse the vclks entry and fill the contents to xenstore backend nodes. The frontend xenstore node will be created, by driver probe function when DomU booting or by libxl pvclk before DomU boots. To my use case, Dom0 and DomU both use device tree, I need to build the mapping table between id and name, since I use name to lookup the clk in backend, like this: "clk = __clk_loopkup(clkname); clk_prepare_enable(clk)". Maybe ACPI is another different case. xen/include/public/io/clkif.h | 129 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 129 insertions(+) create mode 100644 xen/include/public/io/clkif.h diff --git a/xen/include/public/io/clkif.h b/xen/include/public/io/clkif.h new file mode 100644 index 0000000..f6f9f20 --- /dev/null +++ b/xen/include/public/io/clkif.h @@ -0,0 +1,129 @@ +/* + * clkif.h + * + * CLK I/O interface for Xen guest OSes. + * + * Copyright (C) 2016, Peng Fan + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#ifndef __XEN_PUBLIC_IO_CLKIF_H__ +#define __XEN_PUBLIC_IO_CLKIF_H__ + +#include "ring.h" +#include "../grant_table.h" + +/* + * The two halves of an Xen pvclk driver utilize nodes within the + * XenStore to communicate and negotiate operating parameters. + * + * Backend: + * /local/domain//backend/vclk//nr-clks + * /local/domain//backend/vclk///name + * + * X - The backend domid + * Y - The frontend domid + * Z - The clk id + * name - The clk name + * + * Backend example: + * /local/domain/0/backend/vclk/1/nr-clks --> value 2 + * /local/domain/0/backend/vclk/1/0/name --> uart2-root-clk + * /local/domain/0/backend/vclk/1/1/name --> gpu-root-clk + * + * /local/domain/0/backend/vclk/2/nr-clks --> value 1 + * /local/domain/0/backend/vclk/2/0/name --> lcdif-per-clk + * + * Frontend: + * /local/domain//device/vclk/clk-ring-ref + * /local/domain//device/vclk/event-channel + * /local/domain//device/vclk//name + * + * Frontend example: + * /local/domain/1/device/vclk/0/name --> uart2-root-clk + * /local/domain/1/device/vclk/1/name --> gpu-root-clk + * + * /local/domain/2/device/vclk/0/name -->lcdif-per-clk + */ + +/* + * Define the CMDs for communication between frontend and backend + * + * If the Guest OSes want to ask the privileged OS to operate on + * a specific clk, the Guest OSes should pass the CMD to the privileged + * OS.The privileged OS will do corresponding clk operation for the + * specific clk, according to the CMD from the Guest OSes. + * + * XEN_CLK_ENABLE: enable clock + * XEN_CLK_DISABLE: disable clock + * XEN_CLK_PREPARE: prepare a clock source + * XEN_CLK_UNPREPARE: undo preparation for a clock souce + * XEN_CLK_GET_RATE: get rate of clock + * XEN_CLK_SET_RATE: set rate of clock + */ +enum { + XEN_CLK_ENABLE, + XEN_CLK_DISABLE, + XEN_CLK_PREPARE, + XEN_CLK_UNPREPARE, + XEN_CLK_GET_RATE, + XEN_CLK_SET_RATE, + XEN_CLK_END, +}; + +/* + * Frontend request + * + * cmd: command for operation on clk, should be XEN_CLK_[xx], + * excluding XEN_CLK_END. id is the + * id: clk id + * rate: clock rate. Used for set rate. + */ +struct xen_clkif_request { + uint32_t cmd; + uint32_t id; + uint64_t rate; +}; +typedef struct xen_clkif_request xen_clkif_request_t; + +/* + * Backend response + * + * cmd: command for operation on clk, same with the cmd in request. + * id: clk id, same with the id in request. + * success: indicate failure or success for the cmd. + * rate: clock rate. Used for get rate. + * + * cmd and id are filled by backend and passed to frontend to + * let frontend check whether the response is for the current + * request or not. + */ +struct xen_clkif_response { + uint32_t cmd; + uint32_t id; + uint32_t success; + uint64_t rate; +}; +typedef struct xen_clkif_response xen_clkif_response_t; + +DEFINE_RING_TYPES(xen_clkif, struct xen_clkif_request, struct xen_clkif_response); +#define XEN_CLK_RING_SIZE __CONST_RING_SIZE(xen_clkif, PAGE_SIZE) + +#endif /* __XEN_PUBLIC_IO_CLKIF_H__ */