From patchwork Thu Sep 17 17:32:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 11783161 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 20881746 for ; Thu, 17 Sep 2020 17:39:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EDD0720872 for ; Thu, 17 Sep 2020 17:39:05 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="jJ5sl2B4" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726506AbgIQRjC (ORCPT ); Thu, 17 Sep 2020 13:39:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60058 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726565AbgIQRi7 (ORCPT ); Thu, 17 Sep 2020 13:38:59 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 84453C06178A; Thu, 17 Sep 2020 10:36:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=xTwmx2yvm3/8GxzEt2o6zYRVX1Gm2w1vvRxX22ySD8g=; b=jJ5sl2B4Y1iarDEtcZbARx6pnL KxXxurqGhLYZZJTIFUdPMLuCDsrfm+Q4e7XlIzImdAnJAgezEgIV+yTFZsY6GkgIbNzilu4ZdOL7n JT5lGpnhobxg63vdqU5BzaDFXlauSKLqGp9GKWGSaNRVHyPX9c1+67YALrTXFi5tDdYj5A0z1PMKc 9ygpWvgwX/KXvwbDnWHR0ACkDxoslXUU0rMYozQGWld6y05aNEQUiy8OoMuNscWgca1OwlSGzxmzh BVVeyu+B9xdXlMVhyltVEoYr+R65+Gz+9TDPnCvmR8lmA0IvXQNhrHpIUAeMp8tGZROnOc8USFYNg 4CjaQz/A==; Received: from 089144214092.atnat0023.highway.a1.net ([89.144.214.92] helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1kIxpz-00034I-9S; Thu, 17 Sep 2020 17:36:51 +0000 From: Christoph Hellwig To: Russell King Cc: Aaro Koskinen , Tony Lindgren , Robin Murphy , iommu@lists.linux-foundation.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-omap@vger.kernel.org, linux-usb@vger.kernel.org Subject: [PATCH 1/4] ARM/omap1: switch to use dma_direct_set_offset for lbus DMA offsets Date: Thu, 17 Sep 2020 19:32:26 +0200 Message-Id: <20200917173229.3311382-2-hch@lst.de> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200917173229.3311382-1-hch@lst.de> References: <20200917173229.3311382-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org Switch the omap1510 platform ohci device to use dma_direct_set_offset to set the DMA offset instead of using direct hooks into the DMA mapping code and remove the now unused hooks. Signed-off-by: Christoph Hellwig Tested-by: Janusz Krzysztofik Acked-by: Tony Lindgren --- arch/arm/include/asm/dma-direct.h | 18 ------------- arch/arm/mach-omap1/include/mach/memory.h | 31 ----------------------- arch/arm/mach-omap1/usb.c | 22 ++++++++++++++++ 3 files changed, 22 insertions(+), 49 deletions(-) diff --git a/arch/arm/include/asm/dma-direct.h b/arch/arm/include/asm/dma-direct.h index 436544aeb83405..77fcb7ee5ec907 100644 --- a/arch/arm/include/asm/dma-direct.h +++ b/arch/arm/include/asm/dma-direct.h @@ -9,7 +9,6 @@ * functions used internally by the DMA-mapping API to provide DMA * addresses. They must not be used by drivers. */ -#ifndef __arch_pfn_to_dma static inline dma_addr_t pfn_to_dma(struct device *dev, unsigned long pfn) { if (dev && dev->dma_range_map) @@ -34,23 +33,6 @@ static inline dma_addr_t virt_to_dma(struct device *dev, void *addr) return (dma_addr_t)__virt_to_bus((unsigned long)(addr)); } -#else -static inline dma_addr_t pfn_to_dma(struct device *dev, unsigned long pfn) -{ - return __arch_pfn_to_dma(dev, pfn); -} - -static inline unsigned long dma_to_pfn(struct device *dev, dma_addr_t addr) -{ - return __arch_dma_to_pfn(dev, addr); -} - -static inline dma_addr_t virt_to_dma(struct device *dev, void *addr) -{ - return __arch_virt_to_dma(dev, addr); -} -#endif - static inline dma_addr_t phys_to_dma(struct device *dev, phys_addr_t paddr) { unsigned int offset = paddr & ~PAGE_MASK; diff --git a/arch/arm/mach-omap1/include/mach/memory.h b/arch/arm/mach-omap1/include/mach/memory.h index 1142560e0078f5..36bc0000cb6ab8 100644 --- a/arch/arm/mach-omap1/include/mach/memory.h +++ b/arch/arm/mach-omap1/include/mach/memory.h @@ -14,42 +14,11 @@ * OMAP-1510 bus address is translated into a Local Bus address if the * OMAP bus type is lbus. We do the address translation based on the * device overriding the defaults used in the dma-mapping API. - * Note that the is_lbus_device() test is not very efficient on 1510 - * because of the strncmp(). */ -#if defined(CONFIG_ARCH_OMAP15XX) && !defined(__ASSEMBLER__) /* * OMAP-1510 Local Bus address offset */ #define OMAP1510_LB_OFFSET UL(0x30000000) -#define virt_to_lbus(x) ((x) - PAGE_OFFSET + OMAP1510_LB_OFFSET) -#define lbus_to_virt(x) ((x) - OMAP1510_LB_OFFSET + PAGE_OFFSET) -#define is_lbus_device(dev) (cpu_is_omap15xx() && dev && (strncmp(dev_name(dev), "ohci", 4) == 0)) - -#define __arch_pfn_to_dma(dev, pfn) \ - ({ dma_addr_t __dma = __pfn_to_phys(pfn); \ - if (is_lbus_device(dev)) \ - __dma = __dma - PHYS_OFFSET + OMAP1510_LB_OFFSET; \ - __dma; }) - -#define __arch_dma_to_pfn(dev, addr) \ - ({ dma_addr_t __dma = addr; \ - if (is_lbus_device(dev)) \ - __dma += PHYS_OFFSET - OMAP1510_LB_OFFSET; \ - __phys_to_pfn(__dma); \ - }) - -#define __arch_dma_to_virt(dev, addr) ({ (void *) (is_lbus_device(dev) ? \ - lbus_to_virt(addr) : \ - __phys_to_virt(addr)); }) - -#define __arch_virt_to_dma(dev, addr) ({ unsigned long __addr = (unsigned long)(addr); \ - (dma_addr_t) (is_lbus_device(dev) ? \ - virt_to_lbus(__addr) : \ - __virt_to_phys(__addr)); }) - -#endif /* CONFIG_ARCH_OMAP15XX */ - #endif diff --git a/arch/arm/mach-omap1/usb.c b/arch/arm/mach-omap1/usb.c index d8e9bbda8f7bdd..ba8566204ea9f4 100644 --- a/arch/arm/mach-omap1/usb.c +++ b/arch/arm/mach-omap1/usb.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include @@ -542,6 +543,25 @@ static u32 __init omap1_usb2_init(unsigned nwires, unsigned alt_pingroup) /* ULPD_APLL_CTRL */ #define APLL_NDPLL_SWITCH (1 << 0) +static int omap_1510_usb_ohci_notifier(struct notifier_block *nb, + unsigned long event, void *data) +{ + struct device *dev = data; + + if (event != BUS_NOTIFY_ADD_DEVICE) + return NOTIFY_DONE; + + if (strncmp(dev_name(dev), "ohci", 4) == 0 && + dma_direct_set_offset(dev, PHYS_OFFSET, OMAP1510_LB_OFFSET, + (u64)-1)) + WARN_ONCE(1, "failed to set DMA offset\n"); + return NOTIFY_OK; +} + +static struct notifier_block omap_1510_usb_ohci_nb = { + .notifier_call = omap_1510_usb_ohci_notifier, +}; + static void __init omap_1510_usb_init(struct omap_usb_config *config) { unsigned int val; @@ -600,6 +620,8 @@ static void __init omap_1510_usb_init(struct omap_usb_config *config) if (config->register_host) { int status; + bus_register_notifier(&platform_bus_type, + &omap_1510_usb_ohci_nb); ohci_device.dev.platform_data = config; status = platform_device_register(&ohci_device); if (status) From patchwork Thu Sep 17 17:32:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 11783203 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6AA6B139A for ; Thu, 17 Sep 2020 17:57:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3919F20707 for ; Thu, 17 Sep 2020 17:57:52 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="ph3uLJKZ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726579AbgIQRjm (ORCPT ); Thu, 17 Sep 2020 13:39:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60390 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726533AbgIQRjJ (ORCPT ); Thu, 17 Sep 2020 13:39:09 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 546C5C06174A; Thu, 17 Sep 2020 10:39:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=VYUzAIxzefItAIMc2bAxCCwS4TSxDuuY0l1BQz5HsqM=; b=ph3uLJKZ1SEIYRoNExzFzxbNX8 lA3e4IsBsmRH7GSKbLajZdCqiPlICxMl83Ius2GubVRyJ6+8ndYHPBHPKTq59HVM6I9u+OtRYdQly bhQ535OV0TkCxvrLtvNFzSx61cEueXeap4y29JbU95oarup6bq+RYJC1zQrJwko09yiZLZxQXycZm AoXi4BcbYGt9LSDVBXEup+EqaNHwaLj5MoHP06siCL3nmUCR/LMxzRiIVsTw5/UoBIxGGSPEDaOxK jH8QV7CNC3jCdDNmcZTMDDYdRI9A8Zoj17YkwE6s1nGRHnm8oJgXN4PDUQk/mYXdxSlAPstbRXNDN u1AbPGOg==; Received: from 089144214092.atnat0023.highway.a1.net ([89.144.214.92] helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1kIxs6-0003B9-91; Thu, 17 Sep 2020 17:39:02 +0000 From: Christoph Hellwig To: Russell King Cc: Aaro Koskinen , Tony Lindgren , Robin Murphy , iommu@lists.linux-foundation.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-omap@vger.kernel.org, linux-usb@vger.kernel.org Subject: [PATCH 2/4] ARM/footbridge: switch to use dma_direct_set_offset for lbus DMA offsets Date: Thu, 17 Sep 2020 19:32:27 +0200 Message-Id: <20200917173229.3311382-3-hch@lst.de> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200917173229.3311382-1-hch@lst.de> References: <20200917173229.3311382-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org Switch the footbridge PCI devices to use dma_direct_set_offset to set the DMA offset instead of using direct hooks into the DMA mapping code and remove the now unused hooks. Signed-off-by: Christoph Hellwig --- arch/arm/include/asm/dma-direct.h | 4 +- arch/arm/include/asm/memory.h | 2 - arch/arm/mach-footbridge/cats-pci.c | 7 +++- arch/arm/mach-footbridge/common.c | 40 ++++++++++++++----- arch/arm/mach-footbridge/common.h | 3 ++ arch/arm/mach-footbridge/ebsa285-pci.c | 7 +++- .../arm/mach-footbridge/include/mach/memory.h | 4 -- arch/arm/mach-footbridge/netwinder-pci.c | 7 +++- arch/arm/mach-footbridge/personal-pci.c | 7 +++- 9 files changed, 54 insertions(+), 27 deletions(-) diff --git a/arch/arm/include/asm/dma-direct.h b/arch/arm/include/asm/dma-direct.h index 77fcb7ee5ec907..1f04a5e1c615de 100644 --- a/arch/arm/include/asm/dma-direct.h +++ b/arch/arm/include/asm/dma-direct.h @@ -13,12 +13,12 @@ static inline dma_addr_t pfn_to_dma(struct device *dev, unsigned long pfn) { if (dev && dev->dma_range_map) pfn = PFN_DOWN(translate_phys_to_dma(dev, PFN_PHYS(pfn))); - return (dma_addr_t)__pfn_to_bus(pfn); + return (dma_addr_t)__pfn_to_phys(pfn); } static inline unsigned long dma_to_pfn(struct device *dev, dma_addr_t addr) { - unsigned long pfn = __bus_to_pfn(addr); + unsigned long pfn = __phys_to_pfn(addr); if (dev && dev->dma_range_map) pfn = PFN_DOWN(translate_dma_to_phys(dev, PFN_PHYS(pfn))); diff --git a/arch/arm/include/asm/memory.h b/arch/arm/include/asm/memory.h index 99035b5891ef44..af612606136ff2 100644 --- a/arch/arm/include/asm/memory.h +++ b/arch/arm/include/asm/memory.h @@ -346,8 +346,6 @@ static inline unsigned long __virt_to_idmap(unsigned long x) #ifndef __virt_to_bus #define __virt_to_bus __virt_to_phys #define __bus_to_virt __phys_to_virt -#define __pfn_to_bus(x) __pfn_to_phys(x) -#define __bus_to_pfn(x) __phys_to_pfn(x) #endif /* diff --git a/arch/arm/mach-footbridge/cats-pci.c b/arch/arm/mach-footbridge/cats-pci.c index 0b2fd7e2e9b429..257cb068ac0c5b 100644 --- a/arch/arm/mach-footbridge/cats-pci.c +++ b/arch/arm/mach-footbridge/cats-pci.c @@ -13,6 +13,7 @@ #include #include #include +#include "common.h" /* cats host-specific stuff */ static int irqmap_cats[] __initdata = { IRQ_PCI, IRQ_IN0, IRQ_IN1, IRQ_IN3 }; @@ -56,8 +57,10 @@ static struct hw_pci cats_pci __initdata = { static int __init cats_pci_init(void) { - if (machine_is_cats()) - pci_common_init(&cats_pci); + if (!machine_is_cats()) + return 0; + bus_register_notifier(&pci_bus_type, &footbridge_pci_dma_nb); + pci_common_init(&cats_pci); return 0; } diff --git a/arch/arm/mach-footbridge/common.c b/arch/arm/mach-footbridge/common.c index eee095f0e2f6c2..dc14d72ca7bb3f 100644 --- a/arch/arm/mach-footbridge/common.c +++ b/arch/arm/mach-footbridge/common.c @@ -12,6 +12,8 @@ #include #include #include +#include +#include #include