From: Denis Orlov <denorl2009@gmail.com>
To: barebox@lists.infradead.org
Cc: Denis Orlov <denorl2009@gmail.com>
Subject: [PATCH 3/3] MIPS: dma-default: do not flush caches in dma_sync_single_* excessively
Date: Mon, 13 Mar 2023 13:53:08 +0300 [thread overview]
Message-ID: <20230313105308.3108127-4-denorl2009@gmail.com> (raw)
In-Reply-To: <20230313105308.3108127-1-denorl2009@gmail.com>
Change the logic to be different depending on whether we are doing
synchronization for a cpu or a device. This gets rid of unnecessary
cache flushing in some cases. While at it, also simplify code a bit,
collapsing two cases with the same code in a switch statement in
dma_sync_single_for_device().
The functional change itself is taken from Linux commit
'MIPS: make dma_sync_*_for_cpu a little less overzealous'
(hash: cbf1449ba5aec9cf4c68b69f899391a8d42e9b8f).
Signed-off-by: Denis Orlov <denorl2009@gmail.com>
---
arch/mips/lib/dma-default.c | 36 +++++++++++++++++-------------------
1 file changed, 17 insertions(+), 19 deletions(-)
diff --git a/arch/mips/lib/dma-default.c b/arch/mips/lib/dma-default.c
index f6c750b8ac..0347d7a7db 100644
--- a/arch/mips/lib/dma-default.c
+++ b/arch/mips/lib/dma-default.c
@@ -6,39 +6,37 @@
#include <dma.h>
#include <asm/io.h>
-static inline void __dma_sync_mips(unsigned long addr, size_t size,
- enum dma_data_direction direction)
+void dma_sync_single_for_cpu(dma_addr_t address, size_t size,
+ enum dma_data_direction dir)
{
- switch (direction) {
+ unsigned long virt = (unsigned long)phys_to_virt(address);
+
+ switch (dir) {
case DMA_TO_DEVICE:
- dma_flush_range(addr, addr + size);
break;
-
case DMA_FROM_DEVICE:
- dma_inv_range(addr, addr + size);
- break;
-
case DMA_BIDIRECTIONAL:
- dma_flush_range(addr, addr + size);
+ dma_inv_range(virt, virt + size);
break;
-
default:
BUG();
}
}
-void dma_sync_single_for_cpu(dma_addr_t address, size_t size,
- enum dma_data_direction dir)
-{
- unsigned long virt = (unsigned long)phys_to_virt(address);
-
- __dma_sync_mips(virt, size, dir);
-}
-
void dma_sync_single_for_device(dma_addr_t address, size_t size,
enum dma_data_direction dir)
{
unsigned long virt = (unsigned long)phys_to_virt(address);
- __dma_sync_mips(virt, size, dir);
+ switch (dir) {
+ case DMA_FROM_DEVICE:
+ dma_inv_range(virt, virt + size);
+ break;
+ case DMA_TO_DEVICE:
+ case DMA_BIDIRECTIONAL:
+ dma_flush_range(virt, virt + size);
+ break;
+ default:
+ BUG();
+ }
}
--
2.30.2
prev parent reply other threads:[~2023-03-13 10:55 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-13 10:53 [PATCH 0/3] MIPS: dma-default: fix dma_sync_single_for_* Denis Orlov
2023-03-13 10:53 ` [PATCH 1/3] dma: use dma/cpu conversions correctly in dma_map/unmap_single Denis Orlov
2023-03-13 10:53 ` [PATCH 2/3] MIPS: dma-default: use virtual addresses when flushing caches Denis Orlov
2023-03-13 10:53 ` Denis Orlov [this message]
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=20230313105308.3108127-4-denorl2009@gmail.com \
--to=denorl2009@gmail.com \
--cc=barebox@lists.infradead.org \
/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