From patchwork Thu Feb 20 16:21:21 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 25071 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ie0-f198.google.com (mail-ie0-f198.google.com [209.85.223.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 67CAA203C6 for ; Thu, 20 Feb 2014 16:22:54 +0000 (UTC) Received: by mail-ie0-f198.google.com with SMTP id at1sf8055703iec.9 for ; Thu, 20 Feb 2014 08:22:53 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=53bC5sEVUSFZo3dxn15RkLo9kZBwLjrJH0pf77lV/0g=; b=D9znkwblz66nK09TcZtWCk05aUEjoHC/h/u+Ot7NBTgN9AkoSaoymvMg8bERoxZsVL yvcm+TpJ3s1wVd187CN5otG+rFVsegis24P8P3tAJAx4Tn03OK2bqoVCYdSyj6hlLPEq 5AEVu7hIEDYWPi9DBWRq4iT91csTlyJ0HkJBwwDA6ZIAJI87gAUn46y6eDM4z7AOGkCB Us2c37nKTg+J0wlB7YdZ8gVV/PVnWBzJORUhefqaD9/srBKm8MjlkUujNIXAiMw6go4T AaW5HeD0nBbJdAvr48DB5M5b82JIV/xP3KgAsXtf/+kB1a2gTu2009/dbz9JBzfG/hjt extg== X-Gm-Message-State: ALoCoQnsypLIjZDuWWxmA3bUTfzO2+jkWMnBiTwSjSis75SDvl+e+dLtCrwpShKWbZUzgJCuZdlg X-Received: by 10.182.17.69 with SMTP id m5mr1096208obd.6.1392913373485; Thu, 20 Feb 2014 08:22:53 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.47.227 with SMTP id m90ls623617qga.38.gmail; Thu, 20 Feb 2014 08:22:53 -0800 (PST) X-Received: by 10.52.117.115 with SMTP id kd19mr1239925vdb.15.1392913373331; Thu, 20 Feb 2014 08:22:53 -0800 (PST) Received: from mail-ve0-f182.google.com (mail-ve0-f182.google.com [209.85.128.182]) by mx.google.com with ESMTPS id rx9si1655742vcb.63.2014.02.20.08.22.53 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 20 Feb 2014 08:22:53 -0800 (PST) Received-SPF: neutral (google.com: 209.85.128.182 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.182; Received: by mail-ve0-f182.google.com with SMTP id jy13so2049443veb.41 for ; Thu, 20 Feb 2014 08:22:53 -0800 (PST) X-Received: by 10.221.26.10 with SMTP id rk10mr1554190vcb.0.1392913373251; Thu, 20 Feb 2014 08:22:53 -0800 (PST) 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.220.174.196 with SMTP id u4csp70703vcz; Thu, 20 Feb 2014 08:22:52 -0800 (PST) X-Received: by 10.66.159.233 with SMTP id xf9mr2978705pab.139.1392913372380; Thu, 20 Feb 2014 08:22:52 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id zt8si4019347pbc.345.2014.02.20.08.22.51; Thu, 20 Feb 2014 08:22:51 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755310AbaBTQVa (ORCPT + 26 others); Thu, 20 Feb 2014 11:21:30 -0500 Received: from mail-ea0-f180.google.com ([209.85.215.180]:50713 "EHLO mail-ea0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754132AbaBTQV3 (ORCPT ); Thu, 20 Feb 2014 11:21:29 -0500 Received: by mail-ea0-f180.google.com with SMTP id o10so999857eaj.25 for ; Thu, 20 Feb 2014 08:21:28 -0800 (PST) X-Received: by 10.14.22.5 with SMTP id s5mr2720867ees.85.1392913288717; Thu, 20 Feb 2014 08:21:28 -0800 (PST) Received: from belegaer.uk.xensource.com. ([185.25.64.249]) by mx.google.com with ESMTPSA id m9sm15530834eeh.3.2014.02.20.08.21.25 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 20 Feb 2014 08:21:27 -0800 (PST) From: Julien Grall To: linux-kernel@vger.kernel.org, stefano.stabellini@eu.citrix.com Cc: linux-arm-kernel@lists.infradead.org, ian.campbell@citrix.com, xen-devel@lists.xenproject.org, Julien Grall , Russell King Subject: [PATCH 1/2] arm/xen: Introduce need_xen_dma_ops and use it in get_dma_ops Date: Thu, 20 Feb 2014 16:21:21 +0000 Message-Id: <1392913281-25483-1-git-send-email-julien.grall@linaro.org> X-Mailer: git-send-email 1.7.10.4 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: julien.grall@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.128.182 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) 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: , If Xen programs the IOMMU to protect a device, it can safely use it's own DMA ops. Some devices may use DMA but are not protected by an IOMMU. A such device still need to use xen-swiotlb. This patch introduces need_xen_dma_ops which will check if a device needs to use xen DMA ops. For now, it's only check if Linux is running as DOM0. Signed-off-by: Julien Grall Cc: Russell King --- arch/arm/include/asm/dma-mapping.h | 5 ++--- arch/arm/include/asm/xen/dma-mapping.h | 13 +++++++++++++ arch/arm/include/asm/xen/hypervisor.h | 2 -- 3 files changed, 15 insertions(+), 5 deletions(-) create mode 100644 arch/arm/include/asm/xen/dma-mapping.h diff --git a/arch/arm/include/asm/dma-mapping.h b/arch/arm/include/asm/dma-mapping.h index e701a4d..a40d077 100644 --- a/arch/arm/include/asm/dma-mapping.h +++ b/arch/arm/include/asm/dma-mapping.h @@ -11,8 +11,7 @@ #include #include -#include -#include +#include #define DMA_ERROR_CODE (~0) extern struct dma_map_ops arm_dma_ops; @@ -27,7 +26,7 @@ static inline struct dma_map_ops *__generic_dma_ops(struct device *dev) static inline struct dma_map_ops *get_dma_ops(struct device *dev) { - if (xen_initial_domain()) + if (need_xen_dma_ops(dev)) return xen_dma_ops; else return __generic_dma_ops(dev); diff --git a/arch/arm/include/asm/xen/dma-mapping.h b/arch/arm/include/asm/xen/dma-mapping.h new file mode 100644 index 0000000..002fc57 --- /dev/null +++ b/arch/arm/include/asm/xen/dma-mapping.h @@ -0,0 +1,13 @@ +#ifndef _ASM_ARM_XEN_DMA_MAPPING_H +#define _ASM_ARM_XEN_DMA_MAPPING_H + +#include + +extern struct dma_map_ops *xen_dma_ops; + +static inline bool need_xen_dma_ops(struct device *dev) +{ + return xen_initial_domain(); +} + +#endif /* _ASM_ARM_XEN_DMA_MAPPING_H */ diff --git a/arch/arm/include/asm/xen/hypervisor.h b/arch/arm/include/asm/xen/hypervisor.h index 1317ee4..d7ab99a 100644 --- a/arch/arm/include/asm/xen/hypervisor.h +++ b/arch/arm/include/asm/xen/hypervisor.h @@ -16,6 +16,4 @@ static inline enum paravirt_lazy_mode paravirt_get_lazy_mode(void) return PARAVIRT_LAZY_NONE; } -extern struct dma_map_ops *xen_dma_ops; - #endif /* _ASM_ARM_XEN_HYPERVISOR_H */