drm/nouveau/disp/nv50-: add channel interfaces to determine the user area
authorBen Skeggs <bskeggs@redhat.com>
Tue, 8 May 2018 10:39:46 +0000 (20:39 +1000)
committerBen Skeggs <bskeggs@redhat.com>
Fri, 18 May 2018 05:01:21 +0000 (15:01 +1000)
This will be required to support Volta.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
drivers/gpu/drm/nouveau/nvkm/engine/disp/channv50.c
drivers/gpu/drm/nouveau/nvkm/engine/disp/channv50.h
drivers/gpu/drm/nouveau/nvkm/engine/disp/coregf119.c
drivers/gpu/drm/nouveau/nvkm/engine/disp/coregp102.c
drivers/gpu/drm/nouveau/nvkm/engine/disp/corenv50.c
drivers/gpu/drm/nouveau/nvkm/engine/disp/dmacgf119.c
drivers/gpu/drm/nouveau/nvkm/engine/disp/dmacgp102.c
drivers/gpu/drm/nouveau/nvkm/engine/disp/dmacnv50.c
drivers/gpu/drm/nouveau/nvkm/engine/disp/piocgf119.c
drivers/gpu/drm/nouveau/nvkm/engine/disp/piocnv50.c

index 91a2f0c64731e7ea3b8d3b5eba74f9baa0d31f97..8e79aa5f52e696c64660abc85789b11d9e0e0e6f 100644 (file)
@@ -155,13 +155,20 @@ nv50_disp_chan_uevent = {
        .fini = nv50_disp_chan_uevent_fini,
 };
 
+u64
+nv50_disp_chan_user(struct nv50_disp_chan *chan, u64 *psize)
+{
+       *psize = 0x1000;
+       return 0x640000 + (chan->chid.user * 0x1000);
+}
+
 static int
 nv50_disp_chan_rd32(struct nvkm_object *object, u64 addr, u32 *data)
 {
        struct nv50_disp_chan *chan = nv50_disp_chan(object);
-       struct nv50_disp *disp = chan->disp;
-       struct nvkm_device *device = disp->base.engine.subdev.device;
-       *data = nvkm_rd32(device, 0x640000 + (chan->chid.user * 0x1000) + addr);
+       struct nvkm_device *device = chan->disp->base.engine.subdev.device;
+       u64 size, base = chan->func->user(chan, &size);
+       *data = nvkm_rd32(device, base + addr);
        return 0;
 }
 
@@ -169,9 +176,9 @@ static int
 nv50_disp_chan_wr32(struct nvkm_object *object, u64 addr, u32 data)
 {
        struct nv50_disp_chan *chan = nv50_disp_chan(object);
-       struct nv50_disp *disp = chan->disp;
-       struct nvkm_device *device = disp->base.engine.subdev.device;
-       nvkm_wr32(device, 0x640000 + (chan->chid.user * 0x1000) + addr, data);
+       struct nvkm_device *device = chan->disp->base.engine.subdev.device;
+       u64 size, base = chan->func->user(chan, &size);
+       nvkm_wr32(device, base + addr, data);
        return 0;
 }
 
@@ -196,12 +203,10 @@ nv50_disp_chan_map(struct nvkm_object *object, void *argv, u32 argc,
                   enum nvkm_object_map *type, u64 *addr, u64 *size)
 {
        struct nv50_disp_chan *chan = nv50_disp_chan(object);
-       struct nv50_disp *disp = chan->disp;
-       struct nvkm_device *device = disp->base.engine.subdev.device;
+       struct nvkm_device *device = chan->disp->base.engine.subdev.device;
+       const u64 base = device->func->resource_addr(device, 0);
        *type = NVKM_OBJECT_MAP_IO;
-       *addr = device->func->resource_addr(device, 0) +
-               0x640000 + (chan->chid.user * 0x1000);
-       *size = 0x001000;
+       *addr = base + chan->func->user(chan, size);
        return 0;
 }
 
index feb8a56fcc858c55b14785c16a10af5dd0bc4567..75ae181da0e813affd3532019e9e558fc42a97a3 100644 (file)
@@ -25,6 +25,7 @@ struct nv50_disp_chan {
 struct nv50_disp_chan_func {
        int (*init)(struct nv50_disp_chan *);
        void (*fini)(struct nv50_disp_chan *);
+       u64 (*user)(struct nv50_disp_chan *, u64 *size);
        int (*bind)(struct nv50_disp_chan *, struct nvkm_object *, u32 handle);
 };
 
@@ -37,6 +38,7 @@ int nv50_disp_dmac_new_(const struct nv50_disp_chan_func *,
                        struct nv50_disp *, int chid, int head, u64 push,
                        const struct nvkm_oclass *, struct nvkm_object **);
 
+u64 nv50_disp_chan_user(struct nv50_disp_chan *, u64 *);
 extern const struct nv50_disp_chan_func nv50_disp_pioc_func;
 extern const struct nv50_disp_chan_func nv50_disp_dmac_func;
 int nv50_disp_dmac_bind(struct nv50_disp_chan *, struct nvkm_object *, u32);
index 17c66162417bd285887c3506a0a375fd8aca46c6..9ba4a8cd3dba2aceae766d7ecb3cc1a780582c1b 100644 (file)
@@ -222,6 +222,7 @@ const struct nv50_disp_chan_func
 gf119_disp_core_func = {
        .init = gf119_disp_core_init,
        .fini = gf119_disp_core_fini,
+       .user = nv50_disp_chan_user,
        .bind = gf119_disp_dmac_bind,
 };
 
index 57d26051bc95b3d83db365ebd8a9a423dbd603e0..aae5db4dc622e2d7c74b65622a334d25aca7ae5e 100644 (file)
@@ -59,6 +59,7 @@ static const struct nv50_disp_chan_func
 gp102_disp_core_func = {
        .init = gp102_disp_core_init,
        .fini = gf119_disp_core_fini,
+       .user = nv50_disp_chan_user,
        .bind = gf119_disp_dmac_bind,
 };
 
index d648c4d7b55c595b1aa6f2b2b7cf5574a6ebd73b..5fd449d32109dd2f04afef6d5f17a1cd2a3ade32 100644 (file)
@@ -224,6 +224,7 @@ const struct nv50_disp_chan_func
 nv50_disp_core_func = {
        .init = nv50_disp_core_init,
        .fini = nv50_disp_core_fini,
+       .user = nv50_disp_chan_user,
        .bind = nv50_disp_dmac_bind,
 };
 
index f69749a29df8653d510358a1db82ffa653440a8c..2a6d0728dd2e2140083c88ebbfd83d459007a4e9 100644 (file)
@@ -95,5 +95,6 @@ const struct nv50_disp_chan_func
 gf119_disp_dmac_func = {
        .init = gf119_disp_dmac_init,
        .fini = gf119_disp_dmac_fini,
+       .user = nv50_disp_chan_user,
        .bind = gf119_disp_dmac_bind,
 };
index 22fa5925644a0c7c59f40c4e22dca26f15d3599a..7e6b308eb596a00e4859bd597b65bf5c6e91e9d2 100644 (file)
@@ -61,5 +61,6 @@ const struct nv50_disp_chan_func
 gp102_disp_dmac_func = {
        .init = gp102_disp_dmac_init,
        .fini = gf119_disp_dmac_fini,
+       .user = nv50_disp_chan_user,
        .bind = gf119_disp_dmac_bind,
 };
index 5cd08cad2c2698715556af576f42def4d47f3071..5db26e31a799af35e01ee92faa88305eef40f320 100644 (file)
@@ -137,5 +137,6 @@ const struct nv50_disp_chan_func
 nv50_disp_dmac_func = {
        .init = nv50_disp_dmac_init,
        .fini = nv50_disp_dmac_fini,
+       .user = nv50_disp_chan_user,
        .bind = nv50_disp_dmac_bind,
 };
index 7b1e9bf75abdebe46f3763d93a463eb8ff2a83dd..5970e40f4d69c3a9366ef882a3d0544fa45cad89 100644 (file)
@@ -80,4 +80,5 @@ const struct nv50_disp_chan_func
 gf119_disp_pioc_func = {
        .init = gf119_disp_pioc_init,
        .fini = gf119_disp_pioc_fini,
+       .user = nv50_disp_chan_user,
 };
index 60c20123d84fcb889452978870fb79c5baf7174c..0a76bda4ef2a51d54effa94163f3c03d704cb6a9 100644 (file)
@@ -82,4 +82,5 @@ const struct nv50_disp_chan_func
 nv50_disp_pioc_func = {
        .init = nv50_disp_pioc_init,
        .fini = nv50_disp_pioc_fini,
+       .user = nv50_disp_chan_user,
 };