From patchwork Mon Sep 22 10:55:18 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Catalin Marinas X-Patchwork-Id: 4947201 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 EF2F4BEEA5 for ; Mon, 22 Sep 2014 10:58:22 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D5D672016C for ; Mon, 22 Sep 2014 10:58:21 +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 A739A2015A for ; Mon, 22 Sep 2014 10:58:20 +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 1XW1Hf-0008Lx-Lu; Mon, 22 Sep 2014 10:55:55 +0000 Received: from foss-mx-na.foss.arm.com ([217.140.108.86]) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1XW1Hd-0008KJ-KZ for linux-arm-kernel@lists.infradead.org; Mon, 22 Sep 2014 10:55:54 +0000 Received: from foss-smtp-na-1.foss.arm.com (unknown [10.80.61.8]) by foss-mx-na.foss.arm.com (Postfix) with ESMTP id 74F0E104; Mon, 22 Sep 2014 05:55:24 -0500 (CDT) Received: from collaborate-mta1.arm.com (highbank-bc01-b06.austin.arm.com [10.112.81.134]) by foss-smtp-na-1.foss.arm.com (Postfix) with ESMTP id 249005FADE; Mon, 22 Sep 2014 05:55:22 -0500 (CDT) Received: from e104818-lin.cambridge.arm.com (e104818-lin.cambridge.arm.com [10.1.203.37]) by collaborate-mta1.arm.com (Postfix) with ESMTPS id 79F1013F6EE; Mon, 22 Sep 2014 05:55:20 -0500 (CDT) Date: Mon, 22 Sep 2014 11:55:18 +0100 From: Catalin Marinas To: Robin Murphy Subject: Re: [PATCH] of: amba: use of_dma_configure for AMBA devices Message-ID: <20140922105515.GI30085@e104818-lin.cambridge.arm.com> References: <90bd1ff3c93b827c12e1b3dc9ad3f227632d0f6e.1410954967.git.robin.murphy@arm.com> <20140917170338.GC18532@arm.com> <20140917180524.GG18532@arm.com> <541AC384.8010806@arm.com> <20140918125535.GB17701@e104818-lin.cambridge.arm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20140918125535.GB17701@e104818-lin.cambridge.arm.com> Thread-Topic: [PATCH] of: amba: use of_dma_configure for AMBA devices Accept-Language: en-GB, en-US Content-Language: en-US User-Agent: Mutt/1.5.23 (2014-03-12) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140922_035553_681494_62C0FB2A X-CRM114-Status: GOOD ( 24.13 ) X-Spam-Score: -0.8 (/) Cc: "devicetree@vger.kernel.org" , "linux@arm.linux.org.uk" , "arm@kernel.org" , Will Deacon , "robh+dt@kernel.org" , Mark Salter , "grant.likely@linaro.org" , "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 On Thu, Sep 18, 2014 at 01:55:36PM +0100, Catalin Marinas wrote: > On Thu, Sep 18, 2014 at 12:35:32PM +0100, Robin Murphy wrote: > > On 17/09/14 19:05, Will Deacon wrote: > > > On Wed, Sep 17, 2014 at 06:47:19PM +0100, Rob Herring wrote: > > >> On Wed, Sep 17, 2014 at 12:03 PM, Will Deacon wrote: > > >>> On Wed, Sep 17, 2014 at 12:56:07PM +0100, Robin Murphy wrote: > > >>>> Commit 591c1e ("of: configure the platform device dma parameters) > > >>>> introduced a common mechanism to configure DMA from DT properties. > > >>>> AMBA devices created from DT can take advantage of this, too. > > >>>> > > >>>> Signed-off-by: Robin Murphy > > >>> > > >>> Acked-by: Will Deacon > > >>> > > >>> It would be great if the arm-soc guys can pick this up. > > >> > > >> Is this a dependency for something else? If so, > > >> > > >> Acked-by: Rob Herring > > > > > > Yeah, it's going to be needed by my IOMMU init rework so that AMBA devices > > > get registered with their IOMMUs. > > > > Noob question: Does that mean I should resend (with ACKs) to > > arm@kernel.org? (I wasn't entirely sure where this should go, hence just > > throwing at the list with CCs) > > If it is not part of a larger series you want to merge, Rob could pick > it up (he could add the acks as well). > > Alternatively, I can get it via the arm64 tree together with an > additional patch removing the bus hooks in dma-mapping.c (maybe that's a > better option if no-one objects). So I plan to take this patch via the arm64 tree together with the patch below (after some more testing): ----8<---------------------------- From 2189064795dc3fb4101e5c34d28c6b62b8a3bfd9 Mon Sep 17 00:00:00 2001 From: Catalin Marinas Date: Mon, 22 Sep 2014 11:48:31 +0100 Subject: [PATCH] arm64: Implement set_arch_dma_coherent_ops() to replace bus notifiers Commit 6ecba8eb51b7 (arm64: Use bus notifiers to set per-device coherent DMA ops) introduced bus notifiers to set the coherent dma ops based on the 'dma-coherent' DT property. Since the generic of_dma_configure() handles this property for platform and AMBA devices, replace the notifiers with set_arch_dma_coherent_ops(). Signed-off-by: Catalin Marinas Acked-by: Arnd Bergmann --- arch/arm64/include/asm/dma-mapping.h | 7 +++++++ arch/arm64/mm/dma-mapping.c | 31 ------------------------------- 2 files changed, 7 insertions(+), 31 deletions(-) diff --git a/arch/arm64/include/asm/dma-mapping.h b/arch/arm64/include/asm/dma-mapping.h index dc82e52acdb3..adeae3f6f0fc 100644 --- a/arch/arm64/include/asm/dma-mapping.h +++ b/arch/arm64/include/asm/dma-mapping.h @@ -52,6 +52,13 @@ static inline void set_dma_ops(struct device *dev, struct dma_map_ops *ops) dev->archdata.dma_ops = ops; } +static inline int set_arch_dma_coherent_ops(struct device *dev) +{ + set_dma_ops(dev, &coherent_swiotlb_dma_ops); + return 0; +} +#define set_arch_dma_coherent_ops set_arch_dma_coherent_ops + #include static inline dma_addr_t phys_to_dma(struct device *dev, phys_addr_t paddr) diff --git a/arch/arm64/mm/dma-mapping.c b/arch/arm64/mm/dma-mapping.c index 4164c5ace9f8..d6ceb3df0047 100644 --- a/arch/arm64/mm/dma-mapping.c +++ b/arch/arm64/mm/dma-mapping.c @@ -22,11 +22,8 @@ #include #include #include -#include -#include #include #include -#include #include @@ -308,40 +305,12 @@ struct dma_map_ops coherent_swiotlb_dma_ops = { }; EXPORT_SYMBOL(coherent_swiotlb_dma_ops); -static int dma_bus_notifier(struct notifier_block *nb, - unsigned long event, void *_dev) -{ - struct device *dev = _dev; - - if (event != BUS_NOTIFY_ADD_DEVICE) - return NOTIFY_DONE; - - if (of_property_read_bool(dev->of_node, "dma-coherent")) - set_dma_ops(dev, &coherent_swiotlb_dma_ops); - - return NOTIFY_OK; -} - -static struct notifier_block platform_bus_nb = { - .notifier_call = dma_bus_notifier, -}; - -static struct notifier_block amba_bus_nb = { - .notifier_call = dma_bus_notifier, -}; - extern int swiotlb_late_init_with_default_size(size_t default_size); static int __init swiotlb_late_init(void) { size_t swiotlb_size = min(SZ_64M, MAX_ORDER_NR_PAGES << PAGE_SHIFT); - /* - * These must be registered before of_platform_populate(). - */ - bus_register_notifier(&platform_bus_type, &platform_bus_nb); - bus_register_notifier(&amba_bustype, &amba_bus_nb); - dma_ops = &noncoherent_swiotlb_dma_ops; return swiotlb_late_init_with_default_size(swiotlb_size);