Commit c09597f0 authored by Ben Skeggs's avatar Ben Skeggs

drm/nouveau/core/memory: add some useful accessor macros

Adds support for 64-bit writes, and optimised filling of buffers with
fixed 32/64-bit values.

These will all be used by the upcoming MMU changes.
Signed-off-by: default avatarBen Skeggs <bskeggs@redhat.com>
parent 997a8900
...@@ -33,18 +33,4 @@ ...@@ -33,18 +33,4 @@
#include <soc/tegra/fuse.h> #include <soc/tegra/fuse.h>
#include <soc/tegra/pmc.h> #include <soc/tegra/pmc.h>
#ifndef ioread32_native
#ifdef __BIG_ENDIAN
#define ioread16_native ioread16be
#define iowrite16_native iowrite16be
#define ioread32_native ioread32be
#define iowrite32_native iowrite32be
#else /* def __BIG_ENDIAN */
#define ioread16_native ioread16
#define iowrite16_native iowrite16
#define ioread32_native ioread32
#define iowrite32_native iowrite32
#endif /* def __BIG_ENDIAN else */
#endif /* !ioread32_native */
#endif #endif
...@@ -65,6 +65,8 @@ void nvkm_memory_tags_put(struct nvkm_memory *, struct nvkm_device *, ...@@ -65,6 +65,8 @@ void nvkm_memory_tags_put(struct nvkm_memory *, struct nvkm_device *,
* macros to guarantee correct behaviour across all chipsets * macros to guarantee correct behaviour across all chipsets
*/ */
#define nvkm_kmap(o) (o)->func->acquire(o) #define nvkm_kmap(o) (o)->func->acquire(o)
#define nvkm_done(o) (o)->func->release(o)
#define nvkm_ro32(o,a) (o)->ptrs->rd32((o), (a)) #define nvkm_ro32(o,a) (o)->ptrs->rd32((o), (a))
#define nvkm_wo32(o,a,d) (o)->ptrs->wr32((o), (a), (d)) #define nvkm_wo32(o,a,d) (o)->ptrs->wr32((o), (a), (d))
#define nvkm_mo32(o,a,m,d) ({ \ #define nvkm_mo32(o,a,m,d) ({ \
...@@ -72,5 +74,29 @@ void nvkm_memory_tags_put(struct nvkm_memory *, struct nvkm_device *, ...@@ -72,5 +74,29 @@ void nvkm_memory_tags_put(struct nvkm_memory *, struct nvkm_device *,
nvkm_wo32((o), _addr, (_data & ~(m)) | (d)); \ nvkm_wo32((o), _addr, (_data & ~(m)) | (d)); \
_data; \ _data; \
}) })
#define nvkm_done(o) (o)->func->release(o)
#define nvkm_wo64(o,a,d) do { \
u64 __a = (a), __d = (d); \
nvkm_wo32((o), __a + 0, lower_32_bits(__d)); \
nvkm_wo32((o), __a + 4, upper_32_bits(__d)); \
} while(0)
#define nvkm_fill(t,s,o,a,d,c) do { \
u64 _a = (a), _c = (c), _d = (d), _o = _a >> s, _s = _c << s; \
u##t __iomem *_m = nvkm_kmap(o); \
if (likely(_m)) { \
if (_d) { \
while (_c--) \
iowrite##t##_native(_d, &_m[_o++]); \
} else { \
memset_io(&_m[_o], _d, _s); \
} \
} else { \
for (; _c; _c--, _a += BIT(s)) \
nvkm_wo##t((o), _a, _d); \
} \
nvkm_done(o); \
} while(0)
#define nvkm_fo32(o,a,d,c) nvkm_fill(32, 2, (o), (a), (d), (c))
#define nvkm_fo64(o,a,d,c) nvkm_fill(64, 3, (o), (a), (d), (c))
#endif #endif
...@@ -2,4 +2,24 @@ ...@@ -2,4 +2,24 @@
#define __NVKM_OS_H__ #define __NVKM_OS_H__
#include <nvif/os.h> #include <nvif/os.h>
#define nvkm_vmm nvkm_vm #define nvkm_vmm nvkm_vm
#ifdef __BIG_ENDIAN
#define ioread16_native ioread16be
#define iowrite16_native iowrite16be
#define ioread32_native ioread32be
#define iowrite32_native iowrite32be
#else
#define ioread16_native ioread16
#define iowrite16_native iowrite16
#define ioread32_native ioread32
#define iowrite32_native iowrite32
#endif
#define iowrite64_native(v,p) do { \
u32 __iomem *_p = (u32 __iomem *)(p); \
u64 _v = (v); \
iowrite32_native(lower_32_bits(_v), &_p[0]); \
iowrite32_native(upper_32_bits(_v), &_p[1]); \
} while(0)
#endif #endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment