summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm
diff options
context:
space:
mode:
authorBen Skeggs <bskeggs@redhat.com>2017-11-01 03:56:19 +1000
committerBen Skeggs <bskeggs@redhat.com>2017-11-02 13:32:18 +1000
commit49814f62a26bd5b8f2ad5a16ccb1340ede30ee1a (patch)
treebb6cb52a79e562c67dfb78e264efeb5538243f5c /drivers/gpu/drm
parent07bbc1c5f49b64323d9e5c1e0d5d7d201e1f2627 (diff)
downloadlinux-49814f62a26bd5b8f2ad5a16ccb1340ede30ee1a.tar.bz2
drm/nouveau/imem: allow nvkm_instobj to be directly embedded in backend object
This will eliminate a step through the call chain, and give backends more flexibility. Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
Diffstat (limited to 'drivers/gpu/drm')
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/subdev/instmem/base.c36
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/subdev/instmem/priv.h15
2 files changed, 38 insertions, 13 deletions
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/instmem/base.c b/drivers/gpu/drm/nouveau/nvkm/subdev/instmem/base.c
index a15125ed455d..78f9c2332edd 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/instmem/base.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/instmem/base.c
@@ -23,7 +23,6 @@
*/
#include "priv.h"
-#include <core/memory.h>
#include <subdev/bar.h>
/******************************************************************************
@@ -31,15 +30,6 @@
*****************************************************************************/
#define nvkm_instobj(p) container_of((p), struct nvkm_instobj, memory)
-struct nvkm_instobj {
- struct nvkm_memory memory;
- struct nvkm_memory *parent;
- struct nvkm_instmem *imem;
- struct list_head head;
- u32 *suspend;
- void __iomem *map;
-};
-
static enum nvkm_memory_target
nvkm_instobj_target(struct nvkm_memory *memory)
{
@@ -94,7 +84,7 @@ nvkm_instobj_map(struct nvkm_memory *memory, struct nvkm_vma *vma, u64 offset)
}
static void *
-nvkm_instobj_dtor(struct nvkm_memory *memory)
+nvkm_instobj_dtor_old(struct nvkm_memory *memory)
{
struct nvkm_instobj *iobj = nvkm_instobj(memory);
spin_lock(&iobj->imem->lock);
@@ -106,7 +96,7 @@ nvkm_instobj_dtor(struct nvkm_memory *memory)
static const struct nvkm_memory_func
nvkm_instobj_func = {
- .dtor = nvkm_instobj_dtor,
+ .dtor = nvkm_instobj_dtor_old,
.target = nvkm_instobj_target,
.addr = nvkm_instobj_addr,
.size = nvkm_instobj_size,
@@ -164,7 +154,7 @@ nvkm_instobj_wr32_slow(struct nvkm_memory *memory, u64 offset, u32 data)
static const struct nvkm_memory_func
nvkm_instobj_func_slow = {
- .dtor = nvkm_instobj_dtor,
+ .dtor = nvkm_instobj_dtor_old,
.target = nvkm_instobj_target,
.addr = nvkm_instobj_addr,
.size = nvkm_instobj_size,
@@ -180,6 +170,26 @@ nvkm_instobj_ptrs_slow = {
.wr32 = nvkm_instobj_wr32_slow,
};
+void
+nvkm_instobj_dtor(struct nvkm_instmem *imem, struct nvkm_instobj *iobj)
+{
+ spin_lock(&imem->lock);
+ list_del(&iobj->head);
+ spin_unlock(&imem->lock);
+}
+
+void
+nvkm_instobj_ctor(const struct nvkm_memory_func *func,
+ struct nvkm_instmem *imem, struct nvkm_instobj *iobj)
+{
+ nvkm_memory_ctor(func, &iobj->memory);
+ iobj->parent = &iobj->memory;
+ iobj->suspend = NULL;
+ spin_lock(&imem->lock);
+ list_add_tail(&iobj->head, &imem->list);
+ spin_unlock(&imem->lock);
+}
+
int
nvkm_instobj_new(struct nvkm_instmem *imem, u32 size, u32 align, bool zero,
struct nvkm_memory **pmemory)
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/instmem/priv.h b/drivers/gpu/drm/nouveau/nvkm/subdev/instmem/priv.h
index ace4471864a3..e0c7f13cfd08 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/instmem/priv.h
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/instmem/priv.h
@@ -17,4 +17,19 @@ struct nvkm_instmem_func {
void nvkm_instmem_ctor(const struct nvkm_instmem_func *, struct nvkm_device *,
int index, struct nvkm_instmem *);
+
+#include <core/memory.h>
+
+struct nvkm_instobj {
+ struct nvkm_memory memory;
+ struct nvkm_memory *parent;
+ struct nvkm_instmem *imem;
+ struct list_head head;
+ u32 *suspend;
+ void __iomem *map;
+};
+
+void nvkm_instobj_ctor(const struct nvkm_memory_func *func,
+ struct nvkm_instmem *, struct nvkm_instobj *);
+void nvkm_instobj_dtor(struct nvkm_instmem *, struct nvkm_instobj *);
#endif