From patchwork Wed Sep 28 18:24:37 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Przywara X-Patchwork-Id: 9354603 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 6680E60757 for ; Wed, 28 Sep 2016 18:27:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5A81D297A4 for ; Wed, 28 Sep 2016 18:27:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4F17F297A8; Wed, 28 Sep 2016 18:27:43 +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.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED 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 8E10A297A4 for ; Wed, 28 Sep 2016 18:27:42 +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 1bpJXY-0001zt-3r; Wed, 28 Sep 2016 18:25:08 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bpJXW-0001xB-AS for xen-devel@lists.xenproject.org; Wed, 28 Sep 2016 18:25:06 +0000 Received: from [85.158.137.68] by server-6.bemta-3.messagelabs.com id 11/7D-28813-10B0CE75; Wed, 28 Sep 2016 18:25:05 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrGLMWRWlGSWpSXmKPExsVysyfVTfcf15t wg6kN3Bbft0xmcmD0OPzhCksAYxRrZl5SfkUCa0Zv23+2gvOCFZ0985kaGHfwdTFycQgJbGKU uHlzAxOEs5xR4u3T26xdjJwcbAK6EjtuvmYGsUUEQiWeLvgOZjMLKEnsP3uNEcQWFnCUmLX2F lg9i4CqxN4Ti1lAbF4Ba4nv65eB1UsIyEk0nL8PZnMK2EisbullB7GFgGqWLp3POoGRewEjwy pG9eLUorLUIl0jvaSizPSMktzEzBxdQwNjvdzU4uLE9NScxKRiveT83E2MQP/WMzAw7mA81ex 8iFGSg0lJlLfj9utwIb6k/JTKjMTijPii0pzU4kOMMhwcShK8rZxvwoUEi1LTUyvSMnOAgQaT luDgURLhFQQGmxBvcUFibnFmOkTqFKOilDhvF0ifAEgiozQPrg0W3JcYZaWEeRkZGBiEeApSi 3IzS1DlXzGKczAqCfOeBpnCk5lXAjf9FdBiJqDFS0+8AFlckoiQkmpgnK758fSV7LnHw68z26 i/+zejfZdA2wtLRxeP5Fjb5j8LVxk4f3rY1fTPbtMa826ZPR8Pp9w/0yPhGbIoZf4eVxs1lgs vJsgeaNyjY/W4x15r3nEHjebIxmmHT9i1W6p2aHP5L3ibZ3u6rTnV77GKpWopB6v3PoF16tHb bmapy4Zo17uau7IosRRnJBpqMRcVJwIAbSLn2mkCAAA= X-Env-Sender: andre.przywara@arm.com X-Msg-Ref: server-9.tower-31.messagelabs.com!1475087101!7808729!1 X-Originating-IP: [217.140.101.70] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 8.84; banners=-,-,- X-VirusChecked: Checked Received: (qmail 37039 invoked from network); 28 Sep 2016 18:25:02 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-9.tower-31.messagelabs.com with SMTP; 28 Sep 2016 18:25:02 -0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 644F8687; Wed, 28 Sep 2016 11:25:01 -0700 (PDT) Received: from e104803-lin.lan (unknown [10.1.207.46]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id A5BAD3F21A; Wed, 28 Sep 2016 11:25:00 -0700 (PDT) From: Andre Przywara To: Julien Grall , Stefano Stabellini Date: Wed, 28 Sep 2016 19:24:37 +0100 Message-Id: <20160928182457.12433-5-andre.przywara@arm.com> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20160928182457.12433-1-andre.przywara@arm.com> References: <20160928182457.12433-1-andre.przywara@arm.com> Cc: xen-devel@lists.xenproject.org Subject: [Xen-devel] [RFC PATCH 04/24] ARM: GICv3 ITS: map ITS command buffer 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: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP Instead of directly manipulating the tables in memory, an ITS driver sends commands via a ring buffer to the ITS h/w to create or alter the LPI mappings. Allocate memory for that buffer and tell the ITS about it to be able to send ITS commands. Signed-off-by: Andre Przywara --- xen/arch/arm/gic-its.c | 25 +++++++++++++++++++++++++ xen/include/asm-arm/gic-its.h | 1 + 2 files changed, 26 insertions(+) diff --git a/xen/arch/arm/gic-its.c b/xen/arch/arm/gic-its.c index 40238a2..c8a7a7e 100644 --- a/xen/arch/arm/gic-its.c +++ b/xen/arch/arm/gic-its.c @@ -18,6 +18,7 @@ #include #include +#include #include #include #include @@ -56,6 +57,26 @@ static uint64_t encode_phys_addr(paddr_t addr, int page_bits) return ret | (addr & GENMASK(51, 48)) >> (48 - 12); } +static void *gicv3_map_cbaser(void __iomem *cbasereg) +{ + uint64_t attr, reg; + void *buffer; + + attr = GIC_BASER_InnerShareable << GITS_BASER_SHAREABILITY_SHIFT; + attr |= GIC_BASER_CACHE_SameAsInner << GITS_BASER_OUTER_CACHEABILITY_SHIFT; + attr |= GIC_BASER_CACHE_RaWaWb << GITS_BASER_INNER_CACHEABILITY_SHIFT; + + buffer = alloc_xenheap_pages(0, 0); + if ( !buffer ) + return ERR_PTR(-ENOMEM); + + /* We use exactly one 4K page, so the "Size" field is 0. */ + reg = attr | BIT(63) | (virt_to_maddr(buffer) & GENMASK(51, 12)); + writeq_relaxed(reg, cbasereg); + + return buffer; +} + static int gicv3_map_baser(void __iomem *basereg, uint64_t regc, int nr_items) { uint64_t attr; @@ -149,6 +170,10 @@ int gicv3_its_init(struct host_its *hw_its) } } + hw_its->cmd_buf = gicv3_map_cbaser(hw_its->its_base + GITS_CBASER); + if ( IS_ERR(hw_its->cmd_buf) ) + return PTR_ERR(hw_its->cmd_buf); + return 0; } diff --git a/xen/include/asm-arm/gic-its.h b/xen/include/asm-arm/gic-its.h index 589b889..b2a003f 100644 --- a/xen/include/asm-arm/gic-its.h +++ b/xen/include/asm-arm/gic-its.h @@ -69,6 +69,7 @@ struct host_its { paddr_t addr; paddr_t size; void __iomem *its_base; + void *cmd_buf; }; extern struct list_head host_its_list;