All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
To: cip-dev@lists.cip-project.org,
	Nobuhiro Iwamatsu <nobuhiro1.iwamatsu@toshiba.co.jp>,
	Pavel Machek <pavel@denx.de>
Cc: Biju Das <biju.das.jz@bp.renesas.com>
Subject: [RFC PATCH 5.10.y-cip 06/39] dma-mapping: add a dma_init_global_coherent helper
Date: Tue, 30 Jan 2024 20:33:13 +0000	[thread overview]
Message-ID: <20240130203346.94488-7-prabhakar.mahadev-lad.rj@bp.renesas.com> (raw)
In-Reply-To: <20240130203346.94488-1-prabhakar.mahadev-lad.rj@bp.renesas.com>

From: Christoph Hellwig <hch@lst.de>

commit 39a2d3506b2d53c569a6db13d65b2f3728c4feec upstream.

Add a new helper to initialize the global coherent pool.  This both
cleans up the existing initialization which indirects through the
reserved_mem_ops that are normally only used for struct device, and
also allows using the global pool for non-devicetree architectures.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Tested-by: Dillon Min <dillon.minfei@gmail.com>
Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
---
 include/linux/dma-map-ops.h |  2 +-
 kernel/dma/coherent.c       | 32 ++++++++++++++------------------
 2 files changed, 15 insertions(+), 19 deletions(-)

diff --git a/include/linux/dma-map-ops.h b/include/linux/dma-map-ops.h
index a5f89fc4d6df1..ac3c9f2bc975f 100644
--- a/include/linux/dma-map-ops.h
+++ b/include/linux/dma-map-ops.h
@@ -176,7 +176,7 @@ void *dma_alloc_from_global_coherent(struct device *dev, ssize_t size,
 int dma_release_from_global_coherent(int order, void *vaddr);
 int dma_mmap_from_global_coherent(struct vm_area_struct *vma, void *cpu_addr,
 		size_t size, int *ret);
-
+int dma_init_global_coherent(phys_addr_t phys_addr, size_t size);
 #else
 static inline int dma_declare_coherent_memory(struct device *dev,
 		phys_addr_t phys_addr, dma_addr_t device_addr, size_t size)
diff --git a/kernel/dma/coherent.c b/kernel/dma/coherent.c
index 9610ed291f297..78a951f6e2c78 100644
--- a/kernel/dma/coherent.c
+++ b/kernel/dma/coherent.c
@@ -300,6 +300,18 @@ int dma_mmap_from_global_coherent(struct vm_area_struct *vma, void *vaddr,
 					vaddr, size, ret);
 }
 
+int dma_init_global_coherent(phys_addr_t phys_addr, size_t size)
+{
+	struct dma_coherent_mem *mem;
+
+	mem = dma_init_coherent_memory(phys_addr, phys_addr, size, true);
+	if (IS_ERR(mem))
+		return PTR_ERR(mem);
+	dma_coherent_default_memory = mem;
+	pr_info("DMA: default coherent area is set\n");
+	return 0;
+}
+
 /*
  * Support for reserved memory regions defined in device tree
  */
@@ -367,26 +379,10 @@ static int __init rmem_dma_setup(struct reserved_mem *rmem)
 
 static int __init dma_init_reserved_memory(void)
 {
-	const struct reserved_mem_ops *ops;
-	int ret;
-
 	if (!dma_reserved_default_memory)
 		return -ENOMEM;
-
-	ops = dma_reserved_default_memory->ops;
-
-	/*
-	 * We rely on rmem_dma_device_init() does not propagate error of
-	 * dma_assign_coherent_memory() for "NULL" device.
-	 */
-	ret = ops->device_init(dma_reserved_default_memory, NULL);
-
-	if (!ret) {
-		dma_coherent_default_memory = dma_reserved_default_memory->priv;
-		pr_info("DMA: default coherent area is set\n");
-	}
-
-	return ret;
+	return dma_init_global_coherent(dma_reserved_default_memory->base,
+					dma_reserved_default_memory->size);
 }
 
 core_initcall(dma_init_reserved_memory);
-- 
2.34.1



  parent reply	other threads:[~2024-01-30 20:34 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-30 20:33 [RFC PATCH 5.10.y-cip 00/39] Add support for Renesas RZ/Five RISC-V SoC Lad Prabhakar
2024-01-30 20:33 ` [RFC PATCH 5.10.y-cip 01/39] cacheinfo: clear cache_leaves(cpu) in free_cache_attributes() Lad Prabhakar
2024-01-30 20:33 ` [RFC PATCH 5.10.y-cip 02/39] riscv: Kconfig: Enable cpufreq kconfig menu Lad Prabhakar
2024-01-30 20:33 ` [RFC PATCH 5.10.y-cip 03/39] dma-direct: add support for dma_coherent_default_memory Lad Prabhakar
2024-01-30 20:33 ` [RFC PATCH 5.10.y-cip 04/39] dma-mapping: allow using the global coherent pool for !ARM Lad Prabhakar
2024-01-30 20:33 ` [RFC PATCH 5.10.y-cip 05/39] dma-mapping: simplify dma_init_coherent_memory Lad Prabhakar
2024-01-30 20:33 ` Lad Prabhakar [this message]
2024-01-30 20:33 ` [RFC PATCH 5.10.y-cip 07/39] dma-mapping: make the global coherent pool conditional Lad Prabhakar
2024-01-30 20:33 ` [RFC PATCH 5.10.y-cip 08/39] of: also handle dma-noncoherent in of_dma_is_coherent() Lad Prabhakar
2024-01-30 20:33 ` [RFC PATCH 5.10.y-cip 09/39] of/irq: Use interrupts-extended to find parent Lad Prabhakar
2024-01-30 20:33 ` [RFC PATCH 5.10.y-cip 10/39] irqchip/sifive-plic: Improve naming scheme for per context offsets Lad Prabhakar
2024-01-30 20:33 ` [RFC PATCH 5.10.y-cip 11/39] irqchip/sifive-plic: Disable S-mode IRQs if running in M-mode Lad Prabhakar
2024-01-30 20:33 ` [RFC PATCH 5.10.y-cip 12/39] irqchip/sifive-plic: Add support for Renesas RZ/Five SoC Lad Prabhakar
2024-01-30 20:33 ` [RFC PATCH 5.10.y-cip 13/39] irqchip/sifive-plic: Make better use of the effective affinity mask Lad Prabhakar
2024-01-30 20:33 ` [RFC PATCH 5.10.y-cip 14/39] irqchip/sifive-plic: Separate the enable and mask operations Lad Prabhakar
2024-01-30 20:33 ` [RFC PATCH 5.10.y-cip 15/39] clocksource/drivers/renesas-ostm: Add support for RZ/V2L SoC Lad Prabhakar
2024-01-30 20:33 ` [RFC PATCH 5.10.y-cip 16/39] clocksource/drivers/riscv: Increase the clock source rating Lad Prabhakar
2024-01-30 20:33 ` [RFC PATCH 5.10.y-cip 17/39] clocksource/drivers/riscv: Get rid of clocksource_arch_init() callback Lad Prabhakar
2024-01-30 20:33 ` [RFC PATCH 5.10.y-cip 18/39] mmc: host: Kconfig: Make MMC_SDHI_INTERNAL_DMAC config option dependant on ARCH_RENESAS Lad Prabhakar
2024-01-30 20:33 ` [RFC PATCH 5.10.y-cip 19/39] dt-bindings: riscv: Sort the CPU core list alphabetically Lad Prabhakar
2024-01-30 20:33 ` [RFC PATCH 5.10.y-cip 20/39] dt-bindings: riscv: Add Andes AX45MP core to the list Lad Prabhakar
2024-01-30 20:33 ` [RFC PATCH 5.10.y-cip 21/39] dt-bindings: clock: r9a07g043-cpg: Add Renesas RZ/Five CPG Clock and Reset Definitions Lad Prabhakar
2024-01-30 20:33 ` [RFC PATCH 5.10.y-cip 22/39] dt-bindings: cache: andestech,ax45mp-cache: Add DT binding documentation for L2 cache controller Lad Prabhakar
2024-01-30 20:33 ` [RFC PATCH 5.10.y-cip 23/39] soc: renesas: Identify RZ/Five SoC Lad Prabhakar
2024-01-30 20:33 ` [RFC PATCH 5.10.y-cip 24/39] clk: renesas: r9a07g043: Add support for " Lad Prabhakar
2024-01-30 20:33 ` [RFC PATCH 5.10.y-cip 25/39] cache: Add L2 cache management for Andes AX45MP RISC-V core Lad Prabhakar
2024-01-30 20:33 ` [RFC PATCH 5.10.y-cip 26/39] cache: ax45mp_cache: Add non coherent support Lad Prabhakar
2024-01-30 20:33 ` [RFC PATCH 5.10.y-cip 27/39] soc: renesas: Kconfig: Select the required configs for RZ/Five SoC Lad Prabhakar
2024-01-30 20:33 ` [RFC PATCH 5.10.y-cip 28/39] riscv: Kconfig.socs: Add ARCH_RENESAS kconfig option Lad Prabhakar
2024-01-30 20:33 ` [RFC PATCH 5.10.y-cip 29/39] riscv: dts: renesas: Add initial devicetree for Renesas RZ/Five SoC Lad Prabhakar
2024-01-30 20:33 ` [RFC PATCH 5.10.y-cip 30/39] riscv: dts: renesas: Add minimal DTS for Renesas RZ/Five SMARC EVK Lad Prabhakar
2024-01-30 20:33 ` [RFC PATCH 5.10.y-cip 31/39] riscv: dts: renesas: r9a07g043f/rzfive-smarc-som: Enable ADC/OPP/Thermal Zones/TSU Lad Prabhakar
2024-01-30 20:33 ` [RFC PATCH 5.10.y-cip 32/39] riscv: dts: renesas: rzfive-smarc: Enable CANFD/I2C Lad Prabhakar
2024-01-30 20:33 ` [RFC PATCH 5.10.y-cip 33/39] riscv: dts: renesas: rzfive-smarc-som: Enable WDT Lad Prabhakar
2024-01-30 20:33 ` [RFC PATCH 5.10.y-cip 34/39] riscv: dts: renesas: rzfive-smarc-som: Enable OSTM nodes Lad Prabhakar
2024-01-30 20:33 ` [RFC PATCH 5.10.y-cip 35/39] riscv: dts: renesas: rzfive-smarc-som: Drop PHY interrupt support for ETH{0,1} Lad Prabhakar
2024-01-30 20:33 ` [RFC PATCH 5.10.y-cip 36/39] riscv: dts: renesas: Clean up dtbs_check W=1 warning due to empty phy node Lad Prabhakar
2024-01-30 20:33 ` [RFC PATCH 5.10.y-cip 37/39] riscv: dts: renesas: r9a07g043f: Add L2 cache node Lad Prabhakar
2024-01-30 20:33 ` [RFC PATCH 5.10.y-cip 38/39] riscv: dts: renesas: r9a07g043f: Add dma-noncoherent property Lad Prabhakar
2024-01-30 20:33 ` [RFC PATCH 5.10.y-cip 39/39] riscv: dts: renesas: rzfive-smarc: Enable the blocks which were explicitly disabled Lad Prabhakar
2024-01-31 11:33 ` [RFC PATCH 5.10.y-cip 00/39] Add support for Renesas RZ/Five RISC-V SoC Pavel Machek
2024-02-01 12:09   ` [cip-dev] " Chris Paterson
2024-02-05  9:45   ` Prabhakar Mahadev Lad
2024-02-05 10:14     ` Pavel Machek
2024-02-05 10:26       ` Prabhakar Mahadev Lad
2024-02-05 10:29         ` Pavel Machek
2024-02-05 10:31           ` Prabhakar Mahadev Lad

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=20240130203346.94488-7-prabhakar.mahadev-lad.rj@bp.renesas.com \
    --to=prabhakar.mahadev-lad.rj@bp.renesas.com \
    --cc=biju.das.jz@bp.renesas.com \
    --cc=cip-dev@lists.cip-project.org \
    --cc=nobuhiro1.iwamatsu@toshiba.co.jp \
    --cc=pavel@denx.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.