From patchwork Thu Oct 2 10:06:57 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Stabellini X-Patchwork-Id: 5017511 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id E41F7BEEA7 for ; Thu, 2 Oct 2014 10:11:43 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 136FA20279 for ; Thu, 2 Oct 2014 10:11:43 +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 4142220272 for ; Thu, 2 Oct 2014 10:11:42 +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 1XZdKS-0003Uv-MR; Thu, 02 Oct 2014 10:09:44 +0000 Received: from smtp.citrix.com ([66.165.176.89]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XZdKH-0003MG-UX for linux-arm-kernel@lists.infradead.org; Thu, 02 Oct 2014 10:09:34 +0000 X-IronPort-AV: E=Sophos;i="5.04,638,1406592000"; d="scan'208";a="177413608" Received: from ukmail1.uk.xensource.com (10.80.16.128) by smtprelay.citrix.com (10.13.107.79) with Microsoft SMTP Server id 14.3.181.6; Thu, 2 Oct 2014 06:09:10 -0400 Received: from kaball.uk.xensource.com ([10.80.2.59]) by ukmail1.uk.xensource.com with esmtp (Exim 4.69) (envelope-from ) id 1XZdJp-00021J-6v; Thu, 02 Oct 2014 11:09:05 +0100 From: Stefano Stabellini To: Subject: [PATCH 2/2] xen/arm: introduce XENMEM_cache_flush Date: Thu, 2 Oct 2014 11:06:57 +0100 Message-ID: <1412244417-12251-2-git-send-email-stefano.stabellini@eu.citrix.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: References: MIME-Version: 1.0 X-DLP: MIA2 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20141002_030934_180702_AD6C597F X-CRM114-Status: GOOD ( 13.66 ) X-Spam-Score: -5.6 (-----) Cc: Ian.Campbell@citrix.com, Stefano Stabellini , konrad.wilk@oracle.com, linux-kernel@vger.kernel.org, david.vrabel@citrix.com, 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=-2.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, 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 Introduce support for new hypercall XENMEM_cache_flush. Use it to perform cache flashing on pages used for dma when necessary. Signed-off-by: Stefano Stabellini --- arch/arm/xen/mm32.c | 19 ++++++++++++++++++- include/xen/interface/memory.h | 16 ++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/arch/arm/xen/mm32.c b/arch/arm/xen/mm32.c index a5a93fc..aa45332 100644 --- a/arch/arm/xen/mm32.c +++ b/arch/arm/xen/mm32.c @@ -4,6 +4,9 @@ #include #include +#include + +#include /* functions called by SWIOTLB */ @@ -24,7 +27,21 @@ static void dma_cache_maint(dma_addr_t handle, unsigned long offset, if (!pfn_valid(pfn)) { - /* TODO: cache flush */ + struct xen_cache_flush cflush; + + cflush.op = 0; + cflush.addr = handle + offset; + cflush.size = size; + + if (op == dmac_unmap_area && dir != DMA_TO_DEVICE) + cflush.op = XENMEM_CACHE_INVAL; + if (op == dmac_map_area) { + cflush.op = XENMEM_CACHE_CLEAN; + if (dir == DMA_FROM_DEVICE) + cflush.op |= XENMEM_CACHE_INVAL; + } + if (cflush.op) + HYPERVISOR_memory_op(XENMEM_cache_flush, &cflush); } else { struct page *page = pfn_to_page(pfn); diff --git a/include/xen/interface/memory.h b/include/xen/interface/memory.h index 2ecfe4f..7d7e039 100644 --- a/include/xen/interface/memory.h +++ b/include/xen/interface/memory.h @@ -263,4 +263,20 @@ struct xen_remove_from_physmap { }; DEFINE_GUEST_HANDLE_STRUCT(xen_remove_from_physmap); +/* + * Issue one or more cache maintenance operations on a memory range + * owned by the calling domain or granted to the calling domain by a + * foreign domain. + */ +#define XENMEM_cache_flush 27 +struct xen_cache_flush { +/* addr is the machine address at the start of the memory range */ +uint64_t addr; +uint64_t size; +#define XENMEM_CACHE_CLEAN (1<<0) +#define XENMEM_CACHE_INVAL (1<<1) +uint32_t op; +}; +DEFINE_GUEST_HANDLE_STRUCT(xen_cache_flush); + #endif /* __XEN_PUBLIC_MEMORY_H__ */