From patchwork Sat Oct 25 13:29:07 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Stabellini X-Patchwork-Id: 39523 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f198.google.com (mail-wi0-f198.google.com [209.85.212.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 28B1624026 for ; Sat, 25 Oct 2014 13:33:32 +0000 (UTC) Received: by mail-wi0-f198.google.com with SMTP id n3sf1487895wiv.9 for ; Sat, 25 Oct 2014 06:33:31 -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:date:from:to:in-reply-to:message-id :references:user-agent:mime-version:cc:subject:precedence:list-id :list-unsubscribe:list-post:list-help:list-subscribe:sender :errors-to:x-original-sender:x-original-authentication-results :mailing-list:list-archive:content-type:content-transfer-encoding; bh=E5ymcTRxpCZ1viBF/Kw082P5P10dsLNr8O3p1Ole0WQ=; b=Z7IBiFhi3+PgoTV47CAS9PPNl29BRaJq0eMPM6Ig2CHDwN+6ptlcpoT0xkKjBwNzz8 sh6fOLesJFqqQaASgy+/QkMkYcjbXlakHZlYeOGjKUvOapFlCjXZy25j/s7Fnmz7cMfO uMCVO5rBpgQRS6zudIIPBdtEFaujqP6VCc6SoFYFTpJQaE57Cz97gCWHXSF2QO/0KET8 N/yoLTZzneUomcVkMAElZRI5vexV9WzjupJsS4IC18Tp0VhqVZvp8bCmRtpnjzNOC9pK Sc3BayXgnY+h2bt6/Rvvoekn2TIecZB0A2OCrTY0jikZ/CUhPgfPp3M+ukMKF3cW2+u1 06UA== X-Gm-Message-State: ALoCoQmxHu9Jrce3MJgCxPxvK6uv7KjJ+WJPLzpE2e/5HmypSlhJKXYEZCTv6KQAXN7sqDHaKSnL X-Received: by 10.180.182.164 with SMTP id ef4mr1955440wic.0.1414244011285; Sat, 25 Oct 2014 06:33:31 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.28.39 with SMTP id y7ls567263lag.0.gmail; Sat, 25 Oct 2014 06:33:30 -0700 (PDT) X-Received: by 10.152.43.97 with SMTP id v1mr671069lal.3.1414244010728; Sat, 25 Oct 2014 06:33:30 -0700 (PDT) Received: from mail-la0-f53.google.com (mail-la0-f53.google.com. [209.85.215.53]) by mx.google.com with ESMTPS id tn9si11338987lbb.72.2014.10.25.06.33.30 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 25 Oct 2014 06:33:30 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.53 as permitted sender) client-ip=209.85.215.53; Received: by mail-la0-f53.google.com with SMTP id gq15so3959021lab.12 for ; Sat, 25 Oct 2014 06:33:30 -0700 (PDT) X-Received: by 10.152.87.98 with SMTP id w2mr10826252laz.27.1414244009743; Sat, 25 Oct 2014 06:33:29 -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 c5csp39557lbz; Sat, 25 Oct 2014 06:33:28 -0700 (PDT) X-Received: by 10.140.29.134 with SMTP id b6mr14675941qgb.23.1414244008209; Sat, 25 Oct 2014 06:33:28 -0700 (PDT) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id n69si12587368qge.21.2014.10.25.06.33.27 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Sat, 25 Oct 2014 06:33:28 -0700 (PDT) Received-SPF: none (google.com: xen-devel-bounces@lists.xen.org does not designate permitted sender hosts) client-ip=50.57.142.19; Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1Xi1RX-000856-AR; Sat, 25 Oct 2014 13:31:43 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1Xi1RV-000851-Qo for xen-devel@lists.xensource.com; Sat, 25 Oct 2014 13:31:42 +0000 Received: from [193.109.254.147:49579] by server-15.bemta-14.messagelabs.com id 55/24-30948-D36AB445; Sat, 25 Oct 2014 13:31:41 +0000 X-Env-Sender: Stefano.Stabellini@citrix.com X-Msg-Ref: server-16.tower-27.messagelabs.com!1414243897!7043956!1 X-Originating-IP: [66.165.176.63] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni42MyA9PiAzMDYwNDg=\n X-StarScan-Received: X-StarScan-Version: 6.12.3; banners=-,-,- X-VirusChecked: Checked Received: (qmail 8947 invoked from network); 25 Oct 2014 13:31:38 -0000 Received: from smtp02.citrix.com (HELO SMTP02.CITRIX.COM) (66.165.176.63) by server-16.tower-27.messagelabs.com with RC4-SHA encrypted SMTP; 25 Oct 2014 13:31:38 -0000 X-IronPort-AV: E=Sophos;i="5.04,786,1406592000"; d="scan'208";a="186159032" Received: from ukmail1.uk.xensource.com (10.80.16.128) by smtprelay.citrix.com (10.13.107.78) with Microsoft SMTP Server id 14.3.181.6; Sat, 25 Oct 2014 09:31:37 -0400 Received: from kaball.uk.xensource.com ([10.80.2.59]) by ukmail1.uk.xensource.com with esmtp (Exim 4.69) (envelope-from ) id 1Xi1RQ-0008Jj-Lp; Sat, 25 Oct 2014 14:31:36 +0100 Date: Sat, 25 Oct 2014 14:29:07 +0100 From: Stefano Stabellini X-X-Sender: sstabellini@kaball.uk.xensource.com To: Stefano Stabellini In-Reply-To: Message-ID: References: <1412941908-5850-3-git-send-email-stefano.stabellini@eu.citrix.com> <20141010120702.GI7755@arm.com> <20141013125725.GA19156@arm.com> <20141024104746.GC1955@localhost> <20141024154353.GE20534@e104818-lin.cambridge.arm.com> User-Agent: Alpine 2.02 (DEB 1266 2009-07-14) MIME-Version: 1.0 X-DLP: MIA1 Cc: "xen-devel@lists.xensource.com" , "linux@arm.linux.org.uk" , "Ian.Campbell@citrix.com" , Catalin Marinas , Will Deacon , "linux-kernel@vger.kernel.org" , "david.vrabel@citrix.com" , "linux-arm-kernel@lists.infradead.org" Subject: Re: [Xen-devel] [PATCH v4 3/7] [RFC] arm/arm64: introduce is_dma_coherent X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Post: , List-Help: , List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.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.53 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-Archive: On Fri, 24 Oct 2014, Stefano Stabellini wrote: > On Fri, 24 Oct 2014, Stefano Stabellini wrote: > > On Fri, 24 Oct 2014, Catalin Marinas wrote: > > > > However given the timing constraints I hope you would be OK with the > > > > suboptimal solution for now and create a common is_dma_coherent function > > > > in 3.19? > > > > > > If you want to push something for 3.18, you could have a temporary > > > solution but I would prefer a bool or something in the dev_archdata > > > structure. Another untested patch: > > > > > > diff --git a/arch/arm64/include/asm/device.h b/arch/arm64/include/asm/device.h > > > index cf98b362094b..243ef256b8c9 100644 > > > --- a/arch/arm64/include/asm/device.h > > > +++ b/arch/arm64/include/asm/device.h > > > @@ -21,6 +21,7 @@ struct dev_archdata { > > > #ifdef CONFIG_IOMMU_API > > > void *iommu; /* private IOMMU data */ > > > #endif > > > + bool dma_coherent; > > > }; > > > > > > struct pdev_archdata { > > > diff --git a/arch/arm64/include/asm/dma-mapping.h b/arch/arm64/include/asm/dma-mapping.h > > > index adeae3f6f0fc..b6bc4c268878 100644 > > > --- a/arch/arm64/include/asm/dma-mapping.h > > > +++ b/arch/arm64/include/asm/dma-mapping.h > > > @@ -54,11 +54,17 @@ static inline void set_dma_ops(struct device *dev, struct dma_map_ops *ops) > > > > > > static inline int set_arch_dma_coherent_ops(struct device *dev) > > > { > > > + dev->dev_archdata.dma_coherent = true; > > > set_dma_ops(dev, &coherent_swiotlb_dma_ops); > > > return 0; > > > } > > > #define set_arch_dma_coherent_ops set_arch_dma_coherent_ops > > > > > > +static inline int is_device_dma_coherent(struct device *dev) > > > +{ > > > + return dev->dev_archdata.dma_coherent; > > > +} > > > + > > > #include > > > > > > static inline dma_addr_t phys_to_dma(struct device *dev, phys_addr_t paddr) > > > > > > > > > This way you don't have to test for swiotlb vs iommu ops (we don't have > > > the latter yet on arm64 but they are coming). Your suggestions and looking more at the code gave me another idea, that I think is clean and at the same time suitable for 3.18. What do you think of the following? It is simple, self-contained and doesn't need a new flag in struct device. diff --git a/arch/arm/xen/mm32.c b/arch/arm/xen/mm32.c index 6153d61..2b259f1 100644 --- a/arch/arm/xen/mm32.c +++ b/arch/arm/xen/mm32.c @@ -2,10 +2,16 @@ #include #include #include +#include #include +static inline bool is_dma_coherent(struct device *dev) +{ + return of_dma_is_coherent(dev->of_node); +} + /* functions called by SWIOTLB */ static void dma_cache_maint(dma_addr_t handle, unsigned long offset,