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/dist/drm/nouveau Use bogus ioread32/io...



details:   https://anonhg.NetBSD.org/src/rev/62b67230d00f
branches:  trunk
changeset: 835105:62b67230d00f
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Mon Aug 27 07:36:18 2018 +0000

description:
Use bogus ioread32/iowrite32 wrappers for gpuobj memory.

Not clear how to turn this into bus_space, or whether it's worthwhile
at all.

diffstat:

 sys/external/bsd/drm2/dist/drm/nouveau/include/nvkm/core/gpuobj.h           |  11 ++-
 sys/external/bsd/drm2/dist/drm/nouveau/nvkm/core/nouveau_nvkm_core_gpuobj.c |  46 +++++++++-
 2 files changed, 52 insertions(+), 5 deletions(-)

diffs (110 lines):

diff -r aa6378d3f1ca -r 62b67230d00f sys/external/bsd/drm2/dist/drm/nouveau/include/nvkm/core/gpuobj.h
--- a/sys/external/bsd/drm2/dist/drm/nouveau/include/nvkm/core/gpuobj.h Mon Aug 27 07:36:07 2018 +0000
+++ b/sys/external/bsd/drm2/dist/drm/nouveau/include/nvkm/core/gpuobj.h Mon Aug 27 07:36:18 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: gpuobj.h,v 1.2 2018/08/27 04:58:30 riastradh Exp $     */
+/*     $NetBSD: gpuobj.h,v 1.3 2018/08/27 07:36:18 riastradh Exp $     */
 
 #ifndef __NVKM_GPUOBJ_H__
 #define __NVKM_GPUOBJ_H__
@@ -11,6 +11,11 @@
 #define NVOBJ_FLAG_ZERO_ALLOC 0x00000001
 #define NVOBJ_FLAG_HEAP       0x00000004
 
+#ifdef __NetBSD__
+#  define      __nvkm_gpuobj_iomem
+#  define      __iomem                 __nvkm_gpuobj_iomem
+#endif
+
 struct nvkm_gpuobj {
        struct nvkm_object object;
        const struct nvkm_gpuobj_func *func;
@@ -25,6 +30,10 @@
        void __iomem *map;
 };
 
+#ifdef __NetBSD__
+#  undef       __iomem
+#endif
+
 struct nvkm_gpuobj_func {
        void *(*acquire)(struct nvkm_gpuobj *);
        void (*release)(struct nvkm_gpuobj *);
diff -r aa6378d3f1ca -r 62b67230d00f sys/external/bsd/drm2/dist/drm/nouveau/nvkm/core/nouveau_nvkm_core_gpuobj.c
--- a/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/core/nouveau_nvkm_core_gpuobj.c       Mon Aug 27 07:36:07 2018 +0000
+++ b/sys/external/bsd/drm2/dist/drm/nouveau/nvkm/core/nouveau_nvkm_core_gpuobj.c       Mon Aug 27 07:36:18 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: nouveau_nvkm_core_gpuobj.c,v 1.2 2018/08/27 04:58:30 riastradh Exp $   */
+/*     $NetBSD: nouveau_nvkm_core_gpuobj.c,v 1.3 2018/08/27 07:36:18 riastradh Exp $   */
 
 /*
  * Copyright 2012 Red Hat Inc.
@@ -24,7 +24,7 @@
  * Authors: Ben Skeggs
  */
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: nouveau_nvkm_core_gpuobj.c,v 1.2 2018/08/27 04:58:30 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nouveau_nvkm_core_gpuobj.c,v 1.3 2018/08/27 07:36:18 riastradh Exp $");
 
 #include <core/gpuobj.h>
 #include <core/engine.h>
@@ -33,19 +33,57 @@
 #include <subdev/bar.h>
 #include <subdev/mmu.h>
 
+#ifdef __NetBSD__
+
+/*
+ * XXX I think this should be done with bus_space, but the depth of
+ * abstractions is dizzying and I'm not actually sure where these
+ * pointers come from.
+ */
+
+#  define      __iomem                 __nvkm_gpuobj_iomem
+#  define      ioread32_native         fake_ioread32_native
+#  define      iowrite32_native        fake_iowrite32_native
+
+static inline uint32_t
+fake_ioread32_native(const void __iomem *ptr)
+{
+       uint32_t v;
+
+       v = *(const uint32_t __iomem *)ptr;
+       membar_consumer();
+
+       return v;
+}
+
+static inline void
+fake_iowrite32_native(uint32_t v, void __iomem *ptr)
+{
+
+       membar_producer();
+       *(uint32_t __iomem *)ptr = v;
+}
+
+#endif
+
 /* fast-path, where backend is able to provide direct pointer to memory */
 static u32
 nvkm_gpuobj_rd32_fast(struct nvkm_gpuobj *gpuobj, u32 offset)
 {
-       return ioread32_native(gpuobj->map + offset);
+       return ioread32_native((const char __iomem *)gpuobj->map + offset);
 }
 
 static void
 nvkm_gpuobj_wr32_fast(struct nvkm_gpuobj *gpuobj, u32 offset, u32 data)
 {
-       iowrite32_native(data, gpuobj->map + offset);
+       iowrite32_native(data, (char __iomem *)gpuobj->map + offset);
 }
 
+#ifdef __NetBSD__
+#  undef       ioread32_native
+#  undef       iowrite32_native
+#endif
+
 /* accessor functions for gpuobjs allocated directly from instmem */
 static u32
 nvkm_gpuobj_heap_rd32(struct nvkm_gpuobj *gpuobj, u32 offset)



Home | Main Index | Thread Index | Old Index