All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jim Quinlan <jim2101024@gmail.com>
To: linux-pci@vger.kernel.org, linux-mips@vger.kernel.org,
	Nicolas Saenz Julienne <nsaenz@kernel.org>,
	Bjorn Helgaas <bhelgaas@google.com>,
	Kevin Cernekee <cernekee@gmail.com>,
	bcm-kernel-feedback-list@broadcom.com, jim2101024@gmail.com,
	james.quinlan@broadcom.com
Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>,
	Florian Fainelli <f.fainelli@gmail.com>,
	linux-kernel@vger.kernel.org (open list)
Subject: [PATCH v1 3/4] MIPS: bmips: Remove obsolete DMA mapping support
Date: Thu,  9 Dec 2021 15:47:24 -0500	[thread overview]
Message-ID: <20211209204726.6676-4-jim2101024@gmail.com> (raw)
In-Reply-To: <20211209204726.6676-1-jim2101024@gmail.com>

The code in 'arch/mips/bmips/dma.c' performed DMA mapping for inbound
regions.  This mapping was and is required for the Broadcom STB PCIe
controller HW.  This code is removed as the current 'struct device' has a
@dma_range_map field which performs the same functionality by processing
the "dma-ranges" DT property.

Subsequently, ARCH_HAS_PHYS_TO_DMA is now unset since the dma_to_phys()
and phys_to_dma() functions are removed.

Signed-off-by: Jim Quinlan <jim2101024@gmail.com>
---
 arch/mips/Kconfig     |   1 -
 arch/mips/bmips/dma.c | 106 +-----------------------------------------
 2 files changed, 2 insertions(+), 105 deletions(-)

diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index 0215dc1529e9..eb1184a7254b 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -264,7 +264,6 @@ config BMIPS_GENERIC
 	bool "Broadcom Generic BMIPS kernel"
 	select ARCH_HAS_RESET_CONTROLLER
 	select ARCH_HAS_SYNC_DMA_FOR_CPU_ALL
-	select ARCH_HAS_PHYS_TO_DMA
 	select BOOT_RAW
 	select NO_EXCEPT_FILL
 	select USE_OF
diff --git a/arch/mips/bmips/dma.c b/arch/mips/bmips/dma.c
index 915ce4b189c1..c535f9cb75ec 100644
--- a/arch/mips/bmips/dma.c
+++ b/arch/mips/bmips/dma.c
@@ -1,68 +1,8 @@
-/*
- * This file is subject to the terms and conditions of the GNU General Public
- * License.  See the file "COPYING" in the main directory of this archive
- * for more details.
- *
- * Copyright (C) 2014 Kevin Cernekee <cernekee@gmail.com>
- */
+// SPDX-License-Identifier: GPL-2.0+
 
-#define pr_fmt(fmt)		"bmips-dma: " fmt
-
-#include <linux/device.h>
-#include <linux/dma-direction.h>
-#include <linux/dma-direct.h>
-#include <linux/init.h>
-#include <linux/io.h>
-#include <linux/of.h>
-#include <linux/printk.h>
-#include <linux/slab.h>
 #include <linux/types.h>
 #include <asm/bmips.h>
-
-/*
- * BCM338x has configurable address translation windows which allow the
- * peripherals' DMA addresses to be different from the Zephyr-visible
- * physical addresses.  e.g. usb_dma_addr = zephyr_pa ^ 0x08000000
- *
- * If the "brcm,ubus" node has a "dma-ranges" property we will enable this
- * translation globally using the provided information.  This implements a
- * very limited subset of "dma-ranges" support and it will probably be
- * replaced by a more generic version later.
- */
-
-struct bmips_dma_range {
-	u32			child_addr;
-	u32			parent_addr;
-	u32			size;
-};
-
-static struct bmips_dma_range *bmips_dma_ranges;
-
-#define FLUSH_RAC		0x100
-
-dma_addr_t phys_to_dma(struct device *dev, phys_addr_t pa)
-{
-	struct bmips_dma_range *r;
-
-	for (r = bmips_dma_ranges; r && r->size; r++) {
-		if (pa >= r->child_addr &&
-		    pa < (r->child_addr + r->size))
-			return pa - r->child_addr + r->parent_addr;
-	}
-	return pa;
-}
-
-phys_addr_t dma_to_phys(struct device *dev, dma_addr_t dma_addr)
-{
-	struct bmips_dma_range *r;
-
-	for (r = bmips_dma_ranges; r && r->size; r++) {
-		if (dma_addr >= r->parent_addr &&
-		    dma_addr < (r->parent_addr + r->size))
-			return dma_addr - r->parent_addr + r->child_addr;
-	}
-	return dma_addr;
-}
+#include <asm/io.h>
 
 void arch_sync_dma_for_cpu_all(void)
 {
@@ -79,45 +19,3 @@ void arch_sync_dma_for_cpu_all(void)
 	__raw_writel(cfg | 0x100, cbr + BMIPS_RAC_CONFIG);
 	__raw_readl(cbr + BMIPS_RAC_CONFIG);
 }
-
-static int __init bmips_init_dma_ranges(void)
-{
-	struct device_node *np =
-		of_find_compatible_node(NULL, NULL, "brcm,ubus");
-	const __be32 *data;
-	struct bmips_dma_range *r;
-	int len;
-
-	if (!np)
-		return 0;
-
-	data = of_get_property(np, "dma-ranges", &len);
-	if (!data)
-		goto out_good;
-
-	len /= sizeof(*data) * 3;
-	if (!len)
-		goto out_bad;
-
-	/* add a dummy (zero) entry at the end as a sentinel */
-	bmips_dma_ranges = kcalloc(len + 1, sizeof(struct bmips_dma_range),
-				   GFP_KERNEL);
-	if (!bmips_dma_ranges)
-		goto out_bad;
-
-	for (r = bmips_dma_ranges; len; len--, r++) {
-		r->child_addr = be32_to_cpup(data++);
-		r->parent_addr = be32_to_cpup(data++);
-		r->size = be32_to_cpup(data++);
-	}
-
-out_good:
-	of_node_put(np);
-	return 0;
-
-out_bad:
-	pr_err("error parsing dma-ranges property\n");
-	of_node_put(np);
-	return -EINVAL;
-}
-arch_initcall(bmips_init_dma_ranges);
-- 
2.17.1


  parent reply	other threads:[~2021-12-09 20:47 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-09 20:47 [PATCH v1 0/4] PCI: brcmstb: Augment driver for MIPs SOCs Jim Quinlan
2021-12-09 20:47 ` Jim Quinlan
2021-12-09 20:47 ` [PATCH v1 1/4] dt-bindings: PCI: Add compatible string for Brcmstb 74[23]5 " Jim Quinlan
2021-12-09 20:47   ` Jim Quinlan
2021-12-09 21:29   ` Florian Fainelli
2021-12-09 21:29     ` Florian Fainelli
2021-12-15 19:50   ` Rob Herring
2021-12-15 19:50     ` Rob Herring
2021-12-09 20:47 ` [PATCH v1 2/4] MIPS: bmips: Add support PCIe controller device nodes Jim Quinlan
2021-12-09 21:30   ` Florian Fainelli
2021-12-09 20:47 ` Jim Quinlan [this message]
2021-12-09 21:31   ` [PATCH v1 3/4] MIPS: bmips: Remove obsolete DMA mapping support Florian Fainelli
2021-12-13  8:28     ` Christoph Hellwig
2022-02-08 10:34   ` nicolas saenz julienne
2021-12-09 20:47 ` [PATCH v1 4/4] PCI: brcmstb: Augment driver for MIPs SOCs Jim Quinlan
2021-12-09 20:47   ` Jim Quinlan
2021-12-09 21:32   ` Florian Fainelli
2021-12-09 21:32     ` Florian Fainelli
2022-07-06 21:42   ` Bjorn Helgaas
2022-07-06 21:42     ` Bjorn Helgaas
2022-07-08 13:37     ` Jim Quinlan
2022-07-08 13:37       ` Jim Quinlan
2022-01-05 10:42 ` [PATCH v1 0/4] " Thomas Bogendoerfer
2022-01-05 10:42   ` Thomas Bogendoerfer
2022-01-07 22:36   ` Jim Quinlan
2022-01-07 22:36     ` Jim Quinlan
2022-01-11 15:18 ` Thomas Bogendoerfer
2022-01-11 15:18   ` Thomas Bogendoerfer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211209204726.6676-4-jim2101024@gmail.com \
    --to=jim2101024@gmail.com \
    --cc=bcm-kernel-feedback-list@broadcom.com \
    --cc=bhelgaas@google.com \
    --cc=cernekee@gmail.com \
    --cc=f.fainelli@gmail.com \
    --cc=james.quinlan@broadcom.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mips@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=nsaenz@kernel.org \
    --cc=tsbogend@alpha.franken.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.