From patchwork Thu Oct 23 17:27:23 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Stabellini X-Patchwork-Id: 39388 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f197.google.com (mail-wi0-f197.google.com [209.85.212.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 89DCD20341 for ; Thu, 23 Oct 2014 17:35:18 +0000 (UTC) Received: by mail-wi0-f197.google.com with SMTP id ex7sf1044583wid.4 for ; Thu, 23 Oct 2014 10:35:17 -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=6AXyXP0zyWChDif/cjbTJHf8n5+CfRf5nfjrC5UgbK0=; b=NSNffEEh7QsOAm2xmr2/lcle0f5PxoNrdZ86Xv1BKZR+zWjuiYXzrFplQLAsS7rqeG big6nfHUFnNiWVICqBZy70IUgGjX9AJzhO8eHUwT0nEXK7K6VbCDJDIqP+tP2xhc/9E8 xMMHR07K6d0cId3KR3i0tNlUfBxHidLbDSh54uMwf3FNjMLXMu0N2FfnABDuMeF4An7J qQbR4RbMgSQOq5nJlr3GNXjCNF05lIB2TwO/OrvUHiZ+nTH4WgW8I8EZg2T64+Y74j+w Z21m+bSEJ2M3nTKQMOwd3cHjXz6iFBuAqmV6CMnAEMJOOEcqu0UHN/t7GU7ACco7Hx7q iJ9g== X-Gm-Message-State: ALoCoQl7lrgIUV8rvyOMbQsRDW8dhMdvmBLn6IV5mbopi8TpK2qAciZeXJpto/uI/2iaf5KABRm0 X-Received: by 10.180.90.115 with SMTP id bv19mr6487228wib.1.1414085717794; Thu, 23 Oct 2014 10:35:17 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.197.100 with SMTP id it4ls346558lac.7.gmail; Thu, 23 Oct 2014 10:35:17 -0700 (PDT) X-Received: by 10.112.234.201 with SMTP id ug9mr6889952lbc.14.1414085717286; Thu, 23 Oct 2014 10:35:17 -0700 (PDT) Received: from mail-la0-f48.google.com (mail-la0-f48.google.com. [209.85.215.48]) by mx.google.com with ESMTPS id lj3si3602065lab.112.2014.10.23.10.35.17 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 23 Oct 2014 10:35:17 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.48 as permitted sender) client-ip=209.85.215.48; Received: by mail-la0-f48.google.com with SMTP id gi9so1295924lab.35 for ; Thu, 23 Oct 2014 10:35:17 -0700 (PDT) X-Received: by 10.112.97.135 with SMTP id ea7mr6802715lbb.46.1414085717079; Thu, 23 Oct 2014 10:35:17 -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.84.229 with SMTP id c5csp295968lbz; Thu, 23 Oct 2014 10:35:16 -0700 (PDT) X-Received: by 10.70.1.34 with SMTP id 2mr6359049pdj.15.1414085715446; Thu, 23 Oct 2014 10:35:15 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ur9si2125559pbc.125.2014.10.23.10.35.14 for ; Thu, 23 Oct 2014 10:35:15 -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 S1755353AbaJWRfI (ORCPT + 28 others); Thu, 23 Oct 2014 13:35:08 -0400 Received: from smtp.citrix.com ([66.165.176.89]:28822 "EHLO SMTP.CITRIX.COM" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752690AbaJWRfC (ORCPT ); Thu, 23 Oct 2014 13:35:02 -0400 X-IronPort-AV: E=Sophos;i="5.04,776,1406592000"; d="scan'208";a="184362046" Received: from ukmail1.uk.xensource.com (10.80.16.128) by smtprelay.citrix.com (10.13.107.80) with Microsoft SMTP Server id 14.3.181.6; Thu, 23 Oct 2014 13:30:06 -0400 Received: from kaball.uk.xensource.com ([10.80.2.59]) by ukmail1.uk.xensource.com with esmtp (Exim 4.69) (envelope-from ) id 1XhMD2-00085f-Jj; Thu, 23 Oct 2014 18:30:00 +0100 From: Stefano Stabellini To: CC: , , , , , , , Stefano Stabellini Subject: [PATCH v5 3/6] xen/arm: introduce xen_is_dma_coherent Date: Thu, 23 Oct 2014 18:27:23 +0100 Message-ID: <1414085246-16160-3-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: MIA1 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.215.48 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 a utility function to check whether a device is dma coherent. The current implementation is suboptimal. Let's rework it later in common arch/arm code. Use it to figure out whether we need to issue cache maintenance operations instead of checking on the existence of a particular dma_ops function for the device. Signed-off-by: Stefano Stabellini Acked-by: Ian Campbell --- Changes in v5: - introduce xen_is_dma_coherent as a xen specific function; - call xen_is_dma_coherent instead of is_dma_coherent. --- arch/arm/include/asm/xen/page-coherent.h | 5 +++++ arch/arm/xen/mm32.c | 6 +++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/arch/arm/include/asm/xen/page-coherent.h b/arch/arm/include/asm/xen/page-coherent.h index e8275ea..6f0f882 100644 --- a/arch/arm/include/asm/xen/page-coherent.h +++ b/arch/arm/include/asm/xen/page-coherent.h @@ -5,6 +5,11 @@ #include #include +static inline bool xen_is_dma_coherent(struct device *dev) +{ + return (__generic_dma_ops(dev) == &arm_coherent_dma_ops); +} + static inline void *xen_alloc_coherent_pages(struct device *hwdev, size_t size, dma_addr_t *dma_handle, gfp_t flags, struct dma_attrs *attrs) diff --git a/arch/arm/xen/mm32.c b/arch/arm/xen/mm32.c index 6153d61..6c0224e 100644 --- a/arch/arm/xen/mm32.c +++ b/arch/arm/xen/mm32.c @@ -76,7 +76,7 @@ void xen_dma_unmap_page(struct device *hwdev, dma_addr_t handle, struct dma_attrs *attrs) { - if (!__generic_dma_ops(hwdev)->unmap_page) + if (xen_is_dma_coherent(hwdev)) return; if (dma_get_attr(DMA_ATTR_SKIP_CPU_SYNC, attrs)) return; @@ -87,7 +87,7 @@ void xen_dma_unmap_page(struct device *hwdev, dma_addr_t handle, void xen_dma_sync_single_for_cpu(struct device *hwdev, dma_addr_t handle, size_t size, enum dma_data_direction dir) { - if (!__generic_dma_ops(hwdev)->sync_single_for_cpu) + if (xen_is_dma_coherent(hwdev)) return; __xen_dma_page_dev_to_cpu(hwdev, handle, size, dir); } @@ -95,7 +95,7 @@ void xen_dma_sync_single_for_cpu(struct device *hwdev, void xen_dma_sync_single_for_device(struct device *hwdev, dma_addr_t handle, size_t size, enum dma_data_direction dir) { - if (!__generic_dma_ops(hwdev)->sync_single_for_device) + if (xen_is_dma_coherent(hwdev)) return; __xen_dma_page_cpu_to_dev(hwdev, handle, size, dir); }