Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/external/bsd/drm2/include/drm Implement BUS_DMA_TO_PHYS/...
details: https://anonhg.NetBSD.org/src/rev/e64eea2e8158
branches: trunk
changeset: 366427:e64eea2e8158
user: riastradh <riastradh%NetBSD.org@localhost>
date: Mon Aug 27 15:32:20 2018 +0000
description:
Implement BUS_DMA_TO_PHYS/PHYS_TO_BUS_DMA on arm respecting ranges.
diffstat:
sys/external/bsd/drm2/include/drm/bus_dma_hacks.h | 31 ++++++++++++++++++++--
1 files changed, 28 insertions(+), 3 deletions(-)
diffs (45 lines):
diff -r 328eceb6dc4b -r e64eea2e8158 sys/external/bsd/drm2/include/drm/bus_dma_hacks.h
--- a/sys/external/bsd/drm2/include/drm/bus_dma_hacks.h Mon Aug 27 15:32:06 2018 +0000
+++ b/sys/external/bsd/drm2/include/drm/bus_dma_hacks.h Mon Aug 27 15:32:20 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: bus_dma_hacks.h,v 1.15 2018/08/27 15:29:31 riastradh Exp $ */
+/* $NetBSD: bus_dma_hacks.h,v 1.16 2018/08/27 15:32:20 riastradh Exp $ */
/*-
* Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -46,8 +46,33 @@
# define PHYS_TO_BUS_MEM(dmat, paddr) ((bus_addr_t)(paddr))
# define BUS_MEM_TO_PHYS(dmat, baddr) ((paddr_t)(baddr))
#elif defined(__arm__) || defined(__aarch64__)
-# define PHYS_TO_BUS_MEM(dmat, paddr) ((bus_addr_t)(paddr))
-# define BUS_MEM_TO_PHYS(dmat, baddr) ((paddr_t)(baddr))
+static inline bus_addr_t
+PHYS_TO_BUS_MEM(bus_dma_tag_t dmat, paddr_t pa)
+{
+ unsigned i;
+
+ for (i = 0; i < dmat->_nranges; i++) {
+ const struct arm32_dma_range *dr = &dmat->_ranges[i];
+
+ if (dr->dr_sysbase <= pa && pa - dr->dr_sysbase <= dr->dr_len)
+ return dr->dr_busbase + (dr->dr_sysbase - pa);
+ }
+ panic("paddr has no bus address in dma tag %p: %"PRIxPADDR, dmat, pa);
+}
+static inline paddr_t
+BUS_MEM_TO_PHYS(bus_dma_tag_t dmat, bus_addr_t ba)
+{
+ unsigned i;
+
+ for (i = 0; i < dmat->_nranges; i++) {
+ const struct arm32_dma_range *dr = &dmat->_ranges[i];
+
+ if (dr->dr_busbase <= ba && ba - dr->dr_busbase <= dr->dr_len)
+ return dr->dr_sysbase + (dr->dr_busbase - ba);
+ }
+ panic("bus addr has no bus address in dma tag %p: %"PRIxPADDR, dmat,
+ ba);
+}
#elif defined(__sparc__) || defined(__sparc64__)
# define PHYS_TO_BUS_MEM(dmat, paddr) ((bus_addr_t)(paddr))
# define BUS_MEM_TO_PHYS(dmat, baddr) ((paddr_t)(baddr))
Home |
Main Index |
Thread Index |
Old Index