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: 38288 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f200.google.com (mail-wi0-f200.google.com [209.85.212.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 48F5B20549 for ; Thu, 2 Oct 2014 10:09:23 +0000 (UTC) Received: by mail-wi0-f200.google.com with SMTP id cc10sf973277wib.3 for ; Thu, 02 Oct 2014 03:09:22 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe:content-type; bh=n0BLMlFZQDcBWK7ZBTk+8FSYDSVO/MPE965+pBa1M+8=; b=dDQpOmVYpFdDSDtxRe+vcc8ZqGpSOvVlMtjBy6ZKcKVaxGBFq60+pr+IGuNQBCudAl 4v86wOn1Bva/HXnlyez3tJvRTiLpVe2kHw6iVeVvaEtqFEGv0vvgqlaCO6PgjuZlOKmJ FBgrOGQ1POL8uPwuEiLuZjs07CS/uocVesRyKrckSdLL9jThffWLpgYtm9b76Op+lvKw O1HmDtR4X2dW2NUTp2rXpfNdWr9R6TpKqadFttT5U74351u14tylA3QMHnJT2flGXHUP odAoPjy+p09QF5mTpmbQALvWDUtXrQMlMf0DIODSVSl8gW14w4IifE+AhruOvoVM50Gn AV8Q== X-Gm-Message-State: ALoCoQnYcGZ61Y+2QrQqsf+GzgSkbenur/rlcy3xeOoLtHHjajyaZcOQ1IYHSjnCwi7ncohx7Vn4 X-Received: by 10.112.6.138 with SMTP id b10mr338205lba.18.1412244562481; Thu, 02 Oct 2014 03:09:22 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.37.194 with SMTP id a2ls263268lak.41.gmail; Thu, 02 Oct 2014 03:09:22 -0700 (PDT) X-Received: by 10.112.9.234 with SMTP id d10mr23824083lbb.98.1412244562274; Thu, 02 Oct 2014 03:09:22 -0700 (PDT) Received: from mail-lb0-f179.google.com (mail-lb0-f179.google.com [209.85.217.179]) by mx.google.com with ESMTPS id iy9si4846694lbc.73.2014.10.02.03.09.22 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 02 Oct 2014 03:09:22 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.179 as permitted sender) client-ip=209.85.217.179; Received: by mail-lb0-f179.google.com with SMTP id l4so1942419lbv.10 for ; Thu, 02 Oct 2014 03:09:22 -0700 (PDT) X-Received: by 10.152.22.137 with SMTP id d9mr62663670laf.29.1412244562139; Thu, 02 Oct 2014 03:09:22 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.130.169 with SMTP id of9csp26003lbb; Thu, 2 Oct 2014 03:09:21 -0700 (PDT) X-Received: by 10.66.222.97 with SMTP id ql1mr85637021pac.119.1412244560601; Thu, 02 Oct 2014 03:09:20 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id cy1si3245890pdb.248.2014.10.02.03.09.19 for ; Thu, 02 Oct 2014 03:09:20 -0700 (PDT) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751972AbaJBKJQ (ORCPT + 27 others); Thu, 2 Oct 2014 06:09:16 -0400 Received: from smtp.citrix.com ([66.165.176.89]:19603 "EHLO SMTP.CITRIX.COM" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751797AbaJBKJN (ORCPT ); Thu, 2 Oct 2014 06:09:13 -0400 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: CC: , , , , , , Stefano Stabellini 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 Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: stefano.stabellini@eu.citrix.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.179 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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__ */