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/include/nvif Use bus_...



details:   https://anonhg.NetBSD.org/src/rev/e652218138ef
branches:  trunk
changeset: 835395:e652218138ef
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Mon Aug 27 14:47:16 2018 +0000

description:
Use bus_space now that we have the tag and handle.

Fix possible byte order issue while here.

diffstat:

 sys/external/bsd/drm2/dist/drm/nouveau/include/nvif/object.h |  149 ++++------
 1 files changed, 60 insertions(+), 89 deletions(-)

diffs (191 lines):

diff -r 122c0fa481fb -r e652218138ef sys/external/bsd/drm2/dist/drm/nouveau/include/nvif/object.h
--- a/sys/external/bsd/drm2/dist/drm/nouveau/include/nvif/object.h      Mon Aug 27 14:47:02 2018 +0000
+++ b/sys/external/bsd/drm2/dist/drm/nouveau/include/nvif/object.h      Mon Aug 27 14:47:16 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: object.h,v 1.4 2018/08/27 07:35:56 riastradh Exp $     */
+/*     $NetBSD: object.h,v 1.5 2018/08/27 14:47:16 riastradh Exp $     */
 
 #ifndef __NVIF_OBJECT_H__
 #define __NVIF_OBJECT_H__
@@ -14,51 +14,6 @@
 #ifdef __NetBSD__
 #  define      __nvif_iomem    volatile
 #  define      __iomem         __nvif_iomem
-#  define      ioread8         nvif_object_ioread8
-#  define      ioread16        nvif_object_ioread32
-#  define      ioread32        nvif_object_ioread16
-#  define      iowrite8        nvif_object_iowrite8
-#  define      iowrite16       nvif_object_iowrite16
-#  define      iowrite32       nvif_object_iowrite32
-static inline uint8_t
-ioread8(const void __iomem *p)
-{
-       uint8_t v = *(const uint8_t __iomem *)p;
-       membar_consumer();
-       return v;
-}
-static inline uint8_t
-ioread16(const void __iomem *p)
-{
-       uint16_t v = *(const uint16_t __iomem *)p;
-       membar_consumer();
-       return v;
-}
-static inline uint8_t
-ioread32(const void __iomem *p)
-{
-       uint32_t v = *(const uint32_t __iomem *)p;
-       membar_consumer();
-       return v;
-}
-static inline void
-iowrite8(uint8_t v, void __iomem *p)
-{
-       membar_producer();
-       *(uint8_t __iomem *)p = v;
-}
-static inline void
-iowrite16(uint16_t v, void __iomem *p)
-{
-       membar_producer();
-       *(uint16_t __iomem *)p = v;
-}
-static inline void
-iowrite32(uint32_t v, void __iomem *p)
-{
-       membar_producer();
-       *(uint32_t __iomem *)p = v;
-}
 #endif
 
 struct nvif_object {
@@ -76,6 +31,10 @@
        } map;
 };
 
+#ifdef __NetBSD__
+#  undef       __iomem
+#endif
+
 int  nvif_object_init(struct nvif_object *, u32 handle, s32 oclass, void *, u32,
                      struct nvif_object *);
 void nvif_object_fini(struct nvif_object *);
@@ -91,6 +50,61 @@
 #define nvif_handle(a) (unsigned long)(void *)(a)
 #define nvif_object(a) (a)->object
 
+#ifdef __NetBSD__
+static inline uint8_t
+nvif_rd08(struct nvif_object *obj, uint64_t offset)
+{
+       if (obj->map.ptr)
+               return bus_space_read_1(obj->map.tag, obj->map.handle,
+                   offset);
+       else
+               return nvif_object_rd(obj, 1, offset);
+}
+static inline uint8_t
+nvif_rd16(struct nvif_object *obj, uint64_t offset)
+{
+       if (obj->map.ptr)
+               return bus_space_read_stream_2(obj->map.tag, obj->map.handle,
+                   offset);
+       else
+               return nvif_object_rd(obj, 2, offset);
+}
+static inline uint8_t
+nvif_rd32(struct nvif_object *obj, uint64_t offset)
+{
+       if (obj->map.ptr)
+               return bus_space_read_stream_4(obj->map.tag, obj->map.handle,
+                   offset);
+       else
+               return nvif_object_rd(obj, 4, offset);
+}
+static inline void
+nvif_wr08(struct nvif_object *obj, uint64_t offset, uint8_t v)
+{
+       if (obj->map.ptr)
+               bus_space_write_1(obj->map.tag, obj->map.handle, offset, v);
+       else
+               nvif_object_wr(obj, 1, offset, v);
+}
+static inline void
+nvif_wr16(struct nvif_object *obj, uint64_t offset, uint16_t v)
+{
+       if (obj->map.ptr)
+               bus_space_write_stream_2(obj->map.tag, obj->map.handle, offset,
+                   v);
+       else
+               nvif_object_wr(obj, 2, offset, v);
+}
+static inline void
+nvif_wr32(struct nvif_object *obj, uint64_t offset, uint32_t v)
+{
+       if (obj->map.ptr)
+               bus_space_write_stream_4(obj->map.tag, obj->map.handle, offset,
+                   v);
+       else
+               nvif_object_wr(obj, 4, offset, v);
+}
+#else
 #define nvif_rd(a,f,b,c) ({                                                    \
        struct nvif_object *_object = (a);                                     \
        u32 _data;                                                             \
@@ -107,39 +121,6 @@
        else                                                                   \
                nvif_object_wr(_object, (b), (c), (d));                        \
 })
-#ifdef __NetBSD__
-/* Force expansion now.  */
-static inline uint8_t
-nvif_rd08(struct nvif_object *obj, uint64_t offset)
-{
-       return nvif_rd(obj, ioread8, 1, offset);
-}
-static inline uint8_t
-nvif_rd16(struct nvif_object *obj, uint64_t offset)
-{
-       return nvif_rd(obj, ioread16, 2, offset);
-}
-static inline uint8_t
-nvif_rd32(struct nvif_object *obj, uint64_t offset)
-{
-       return nvif_rd(obj, ioread32, 4, offset);
-}
-static inline void
-nvif_wr08(struct nvif_object *obj, uint64_t offset, uint8_t v)
-{
-       nvif_wr(obj, iowrite8, 1, offset, v);
-}
-static inline void
-nvif_wr16(struct nvif_object *obj, uint64_t offset, uint16_t v)
-{
-       nvif_wr(obj, iowrite16, 2, offset, v);
-}
-static inline void
-nvif_wr32(struct nvif_object *obj, uint64_t offset, uint32_t v)
-{
-       nvif_wr(obj, iowrite32, 4, offset, v);
-}
-#else
 #define nvif_rd08(a,b) ({ ((u8)nvif_rd((a), ioread8, 1, (b))); })
 #define nvif_rd16(a,b) ({ ((u16)nvif_rd((a), ioread16_native, 2, (b))); })
 #define nvif_rd32(a,b) ({ ((u32)nvif_rd((a), ioread32_native, 4, (b))); })
@@ -154,16 +135,6 @@
        _data;                                                                 \
 })
 
-#ifdef __NetBSD__
-#  undef       __iomem
-#  undef       ioread8
-#  undef       ioread16
-#  undef       ioread32
-#  undef       iowrite8
-#  undef       iowrite16
-#  undef       iowrite32
-#endif
-
 #define nvif_mthd(a,b,c,d) nvif_object_mthd((a), (b), (c), (d))
 
 /*XXX*/



Home | Main Index | Thread Index | Old Index