Module Name: src Committed By: riastradh Date: Mon Aug 27 14:47:16 UTC 2018
Modified Files: src/sys/external/bsd/drm2/dist/drm/nouveau/include/nvif: object.h Log Message: Use bus_space now that we have the tag and handle. Fix possible byte order issue while here. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 \ src/sys/external/bsd/drm2/dist/drm/nouveau/include/nvif/object.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/external/bsd/drm2/dist/drm/nouveau/include/nvif/object.h diff -u src/sys/external/bsd/drm2/dist/drm/nouveau/include/nvif/object.h:1.4 src/sys/external/bsd/drm2/dist/drm/nouveau/include/nvif/object.h:1.5 --- src/sys/external/bsd/drm2/dist/drm/nouveau/include/nvif/object.h:1.4 Mon Aug 27 07:35:56 2018 +++ src/sys/external/bsd/drm2/dist/drm/nouveau/include/nvif/object.h Mon Aug 27 14:47:16 2018 @@ -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 @@ struct nvif_sclass { #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 @@ struct nvif_object { } 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,55 +50,77 @@ void nvif_object_unmap(struct nvif_objec #define nvif_handle(a) (unsigned long)(void *)(a) #define nvif_object(a) (a)->object -#define nvif_rd(a,f,b,c) ({ \ - struct nvif_object *_object = (a); \ - u32 _data; \ - if (likely(_object->map.ptr)) \ - _data = f((u8 __iomem *)_object->map.ptr + (c)); \ - else \ - _data = nvif_object_rd(_object, (b), (c)); \ - _data; \ -}) -#define nvif_wr(a,f,b,c,d) ({ \ - struct nvif_object *_object = (a); \ - if (likely(_object->map.ptr)) \ - f((d), (u8 __iomem *)_object->map.ptr + (c)); \ - 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); + 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) { - return nvif_rd(obj, ioread16, 2, 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) { - return nvif_rd(obj, ioread32, 4, 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) { - nvif_wr(obj, iowrite8, 1, offset, 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) { - nvif_wr(obj, iowrite16, 2, offset, 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) { - nvif_wr(obj, iowrite32, 4, offset, 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; \ + if (likely(_object->map.ptr)) \ + _data = f((u8 __iomem *)_object->map.ptr + (c)); \ + else \ + _data = nvif_object_rd(_object, (b), (c)); \ + _data; \ +}) +#define nvif_wr(a,f,b,c,d) ({ \ + struct nvif_object *_object = (a); \ + if (likely(_object->map.ptr)) \ + f((d), (u8 __iomem *)_object->map.ptr + (c)); \ + else \ + nvif_object_wr(_object, (b), (c), (d)); \ +}) #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 @@ nvif_wr32(struct nvif_object *obj, uint6 _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*/