mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Antony Pavlov <antonynpavlov@gmail.com>
To: barebox@lists.infradead.org
Cc: Oleksij Rempel <o.rempel@pengutronix.de>,
	Peter Mamonov <pmamonov@gmail.com>
Subject: [RFC 2/5] WIP: MIPS: implement dma mapping functions
Date: Thu,  9 Jan 2020 10:28:52 +0300	[thread overview]
Message-ID: <20200109072855.14154-3-antonynpavlov@gmail.com> (raw)
In-Reply-To: <20200109072855.14154-1-antonynpavlov@gmail.com>

TODO: fix warnings

arch/mips/include/asm/dma-mapping.h: In function ‘dma_free_coherent’:
arch/mips/include/asm/dma-mapping.h:31:21: warning: passing argument 1 of ‘phys_to_virt’
makes integer from pointer without a cast [-Wint-conversion]
   free(phys_to_virt(vaddr));
                     ^~~~~
In file included from include/common.h:33:0,
                 from drivers/net/e1000/main.c:32:
arch/mips/include/asm/io.h:40:21: note: expected ‘long unsigned int’ but argument is of type ‘void *’
 static inline void *phys_to_virt(unsigned long address)
                     ^~~~~~~~~~~~

Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
Signed-off-by: Peter Mamonov <pmamonov@gmail.com>
---
 arch/mips/include/asm/dma-mapping.h |  2 +-
 arch/mips/lib/dma-default.c         | 22 ++++++++++++++++++++--
 2 files changed, 21 insertions(+), 3 deletions(-)

diff --git a/arch/mips/include/asm/dma-mapping.h b/arch/mips/include/asm/dma-mapping.h
index c71a087038..5013e7b369 100644
--- a/arch/mips/include/asm/dma-mapping.h
+++ b/arch/mips/include/asm/dma-mapping.h
@@ -28,7 +28,7 @@ static inline void dma_free_coherent(void *vaddr, dma_addr_t dma_handle,
 				     size_t size)
 {
 	if (IS_ENABLED(CONFIG_MMU))
-		free((void *)CKSEG0ADDR(vaddr));
+		free(phys_to_virt(vaddr));
 	else
 		free(vaddr);
 }
diff --git a/arch/mips/lib/dma-default.c b/arch/mips/lib/dma-default.c
index fbe627c24c..40caf6f91b 100644
--- a/arch/mips/lib/dma-default.c
+++ b/arch/mips/lib/dma-default.c
@@ -8,9 +8,11 @@
 
 #if defined(CONFIG_CPU_MIPS32) || \
 	defined(CONFIG_CPU_MIPS64)
-static inline void __dma_sync_mips(unsigned long addr, size_t size,
+static inline void __dma_sync_mips(dma_addr_t _addr, size_t size,
 				   enum dma_data_direction direction)
 {
+	void *addr = phys_to_virt(_addr);
+
 	switch (direction) {
 	case DMA_TO_DEVICE:
 		dma_flush_range(addr, addr + size);
@@ -29,7 +31,7 @@ static inline void __dma_sync_mips(unsigned long addr, size_t size,
 	}
 }
 #else
-static inline void __dma_sync_mips(void *addr, size_t size,
+static inline void __dma_sync_mips(dma_addr_t addr, size_t size,
 	enum dma_data_direction direction)
 {
 }
@@ -46,3 +48,19 @@ void dma_sync_single_for_device(dma_addr_t address, size_t size,
 {
 	__dma_sync_mips(address, size, dir);
 }
+
+dma_addr_t dma_map_single(struct device_d *dev, void *ptr, size_t size,
+			  enum dma_data_direction dir)
+{
+	unsigned long addr = virt_to_phys(ptr);
+
+	dma_sync_single_for_device(addr, size, dir);
+
+	return addr;
+}
+
+void dma_unmap_single(struct device_d *dev, dma_addr_t addr, size_t size,
+		      enum dma_data_direction dir)
+{
+	dma_sync_single_for_cpu(addr, size, dir);
+}
-- 
2.24.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  parent reply	other threads:[~2020-01-09  7:29 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-09  7:28 [RFC 0/5] " Antony Pavlov
2020-01-09  7:28 ` [RFC 1/5] WIP: MIPS: configure ebase according CONFIG_MMU Antony Pavlov
2020-01-13  6:48   ` Oleksij Rempel
2020-01-09  7:28 ` Antony Pavlov [this message]
2020-01-13  8:26   ` [RFC 2/5] WIP: MIPS: implement dma mapping functions Oleksij Rempel
2020-01-14 21:03     ` Antony Pavlov
2020-01-09  7:28 ` [RFC 3/5] net: e1000: make it work on MIPS Antony Pavlov
2020-01-13  7:29   ` Oleksij Rempel
2020-01-13 19:06     ` Lucas Stach
2020-01-09  7:28 ` [RFC 4/5] net: rtl8169: make it work on big-endian system Antony Pavlov
2020-01-13  7:21   ` Oleksij Rempel
2020-02-04 14:03   ` Oleksij Rempel
2020-02-09  6:30     ` Antony Pavlov
2020-02-09  8:17       ` Oleksij Rempel
2020-02-28  5:38     ` Antony Pavlov
2020-01-09  7:28 ` [RFC 5/5] MIPS: qemu-malta_defconfig: enable e1000 network driver Antony Pavlov

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=20200109072855.14154-3-antonynpavlov@gmail.com \
    --to=antonynpavlov@gmail.com \
    --cc=barebox@lists.infradead.org \
    --cc=o.rempel@pengutronix.de \
    --cc=pmamonov@gmail.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox