summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorBen Skeggs <bskeggs@redhat.com>2015-08-20 07:54:14 +0300
committerBen Skeggs <bskeggs@redhat.com>2015-08-28 05:40:27 +0300
commit384af9aceaf8ee1e2d3791cc89a32c161d67bb57 (patch)
tree3d0133a598f561bf8e16f5c8b26b904942ce0cc6 /drivers
parent9ccdc76006e3b6ca46c8dbc446bc2e3f6d8d95cb (diff)
downloadlinux-384af9aceaf8ee1e2d3791cc89a32c161d67bb57.tar.xz
drm/nouveau/gpuobj: type-safe accessor macros
These require an explicit struct nvkm_gpuobj pointer, unlike the previous macros which take a void *, and work with any nvkm_object. New semantics require acquiring/releasing a gpuobj before accessing them, which will be made use of in later patches to greatly reduce the overhead of accesses, particularly when a direct mmio mapping of the object is not available (suspend/resume, out of ioremap() space, and on GK20A). Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/gpu/drm/nouveau/include/nvkm/core/gpuobj.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/drivers/gpu/drm/nouveau/include/nvkm/core/gpuobj.h b/drivers/gpu/drm/nouveau/include/nvkm/core/gpuobj.h
index aa98520fa265..0dd216c055f6 100644
--- a/drivers/gpu/drm/nouveau/include/nvkm/core/gpuobj.h
+++ b/drivers/gpu/drm/nouveau/include/nvkm/core/gpuobj.h
@@ -60,4 +60,20 @@ int _nvkm_gpuobj_init(struct nvkm_object *);
int _nvkm_gpuobj_fini(struct nvkm_object *, bool);
u32 _nvkm_gpuobj_rd32(struct nvkm_object *, u64);
void _nvkm_gpuobj_wr32(struct nvkm_object *, u64, u32);
+
+/* accessor macros - kmap()/done() must bracket use of the other accessor
+ * macros to guarantee correct behaviour across all chipsets
+ */
+#define nvkm_kmap(o) do { \
+ struct nvkm_gpuobj *_gpuobj = (o); \
+ (void)_gpuobj; \
+} while(0)
+#define nvkm_ro32(o,a) nv_ofuncs(o)->rd32(&(o)->object, (a))
+#define nvkm_wo32(o,a,d) nv_ofuncs(o)->wr32(&(o)->object, (a), (d))
+#define nvkm_mo32(o,a,m,d) ({ \
+ u32 _addr = (a), _data = nvkm_ro32((o), _addr); \
+ nvkm_wo32((o), _addr, (_data & ~(m)) | (d)); \
+ _data; \
+})
+#define nvkm_done(o) nvkm_kmap(o)
#endif