diff options
author | Ben Skeggs <bskeggs@redhat.com> | 2014-08-10 04:10:24 +1000 |
---|---|---|
committer | Ben Skeggs <bskeggs@redhat.com> | 2014-08-10 04:43:31 +1000 |
commit | 0d59b365576847ea6d89b8dbc7dd9c51aca9a593 (patch) | |
tree | dfbc216a647818e270f09b7e4eb2647811aa2031 | |
parent | b444ec0997bfdda01be65f26e831c1724a6dd9f4 (diff) | |
download | nouveau-0d59b365576847ea6d89b8dbc7dd9c51aca9a593.tar.gz |
device: audit and version NV_DEVICE class
The full object interfaces are about to be exposed to userspace, so we
need to check for any security-related issues and version the structs
to make it easier to handle any changes we may need in the future.
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
-rw-r--r-- | bin/nv_aux.c | 14 | ||||
-rw-r--r-- | bin/nv_disp.c | 2 | ||||
-rw-r--r-- | bin/nv_i2c.c | 14 | ||||
-rw-r--r-- | bin/nv_init.c | 6 | ||||
-rw-r--r-- | bin/nv_perfmon.c | 12 | ||||
-rw-r--r-- | bin/nv_rdfuc.c | 8 | ||||
-rw-r--r-- | bin/nv_rdfunc.h | 6 | ||||
-rw-r--r-- | bin/nv_rffunc.h | 2 | ||||
-rw-r--r-- | bin/nv_rifunc.h | 2 | ||||
-rw-r--r-- | bin/nv_rsfunc.h | 2 | ||||
-rw-r--r-- | bin/nv_rvfunc.h | 2 | ||||
-rw-r--r-- | bin/nv_wffunc.h | 2 | ||||
-rw-r--r-- | bin/nv_wifunc.h | 2 | ||||
-rw-r--r-- | bin/nv_wrfunc.h | 6 | ||||
-rw-r--r-- | bin/nv_wsfunc.h | 2 | ||||
-rw-r--r-- | bin/nv_wvfunc.h | 2 | ||||
-rw-r--r-- | drm/nouveau_abi16.c | 8 | ||||
-rw-r--r-- | drm/nouveau_drm.c | 18 | ||||
-rw-r--r-- | nvif/class.h | 25 | ||||
-rw-r--r-- | nvkm/engine/device/base.c | 155 | ||||
-rw-r--r-- | nvkm/engine/disp/nv50.c | 2 | ||||
-rw-r--r-- | nvkm/engine/dmaobj/base.c | 2 | ||||
-rw-r--r-- | nvkm/include/core/class.h | 30 |
23 files changed, 177 insertions, 147 deletions
diff --git a/bin/nv_aux.c b/bin/nv_aux.c index 00da6b305..4abc45cb5 100644 --- a/bin/nv_aux.c +++ b/bin/nv_aux.c @@ -68,16 +68,16 @@ main(int argc, char **argv) if (ret) return ret; - ret = nvif_device_new(nvif_object(client), 0x00000000, NV_DEVICE_CLASS, - &(struct nv_device_class) { + ret = nvif_device_new(nvif_object(client), 0x00000000, NV_DEVICE, + &(struct nv_device_v0) { .device = ~0ULL, - .disable = ~(NV_DEVICE_DISABLE_MMIO | - NV_DEVICE_DISABLE_IDENTIFY| - NV_DEVICE_DISABLE_VBIOS | - NV_DEVICE_DISABLE_CORE), + .disable = ~(NV_DEVICE_V0_DISABLE_MMIO | + NV_DEVICE_V0_DISABLE_IDENTIFY| + NV_DEVICE_V0_DISABLE_VBIOS | + NV_DEVICE_V0_DISABLE_CORE), .debug0 = ~((1 << NVDEV_SUBDEV_VBIOS) | (1 << NVDEV_SUBDEV_I2C)), - }, sizeof(struct nv_device_class), &device); + }, sizeof(struct nv_device_v0), &device); nvif_client_ref(NULL, &client); if (ret) return ret; diff --git a/bin/nv_disp.c b/bin/nv_disp.c index 7cf5a2c51..9a6c481f8 100644 --- a/bin/nv_disp.c +++ b/bin/nv_disp.c @@ -34,7 +34,7 @@ nv_disp(struct nvif_device *device, u16 mthd, u32 data) #define CAST u32 #define WRITE(o,v) nv_disp(device, (o), (v)) #define MAIN main_ -#define ENABLE (NV_DEVICE_DISABLE_MMIO | NV_DEVICE_DISABLE_IDENTIFY) +#define ENABLE (NV_DEVICE_V0_DISABLE_MMIO | NV_DEVICE_V0_DISABLE_IDENTIFY) #include "nv_wrfunc.h" int diff --git a/bin/nv_i2c.c b/bin/nv_i2c.c index 7b1c87952..b098fb113 100644 --- a/bin/nv_i2c.c +++ b/bin/nv_i2c.c @@ -74,16 +74,16 @@ main(int argc, char **argv) if (ret) return ret; - ret = nvif_device_new(nvif_object(client), 0, NV_DEVICE_CLASS, - &(struct nv_device_class) { + ret = nvif_device_new(nvif_object(client), 0, NV_DEVICE, + &(struct nv_device_v0) { .device = ~0ULL, - .disable = ~(NV_DEVICE_DISABLE_MMIO | - NV_DEVICE_DISABLE_IDENTIFY| - NV_DEVICE_DISABLE_VBIOS | - NV_DEVICE_DISABLE_CORE), + .disable = ~(NV_DEVICE_V0_DISABLE_MMIO | + NV_DEVICE_V0_DISABLE_IDENTIFY| + NV_DEVICE_V0_DISABLE_VBIOS | + NV_DEVICE_V0_DISABLE_CORE), .debug0 = ~((1 << NVDEV_SUBDEV_VBIOS) | (1 << NVDEV_SUBDEV_I2C)), - }, sizeof(struct nv_device_class), &device); + }, sizeof(struct nv_device_v0), &device); nvif_client_ref(NULL, &client); if (ret) return ret; diff --git a/bin/nv_init.c b/bin/nv_init.c index d012aa79e..8354f970c 100644 --- a/bin/nv_init.c +++ b/bin/nv_init.c @@ -41,12 +41,12 @@ main(int argc, char **argv) if (ret) return ret; - ret = nvif_device_new(nvif_object(client), 0, NV_DEVICE_CLASS, - &(struct nv_device_class) { + ret = nvif_device_new(nvif_object(client), 0, NV_DEVICE, + &(struct nv_device_v0) { .device = ~0ULL, .disable = 0ULL, .debug0 = 0ULL, - }, sizeof(struct nv_device_class), &device); + }, sizeof(struct nv_device_v0), &device); nvif_client_ref(NULL, &client); if (ret) return ret; diff --git a/bin/nv_perfmon.c b/bin/nv_perfmon.c index 611a327a0..2cb594879 100644 --- a/bin/nv_perfmon.c +++ b/bin/nv_perfmon.c @@ -627,15 +627,15 @@ main(int argc, char **argv) return ret; ret = nvif_device_new(nvif_object(client), 0x00000000, - NV_DEVICE_CLASS, &(struct nv_device_class) { + NV_DEVICE, &(struct nv_device_v0) { .device = ~0ULL, - .disable = ~(NV_DEVICE_DISABLE_MMIO | - NV_DEVICE_DISABLE_VBIOS | - NV_DEVICE_DISABLE_CORE | - NV_DEVICE_DISABLE_IDENTIFY), + .disable = ~(NV_DEVICE_V0_DISABLE_MMIO | + NV_DEVICE_V0_DISABLE_VBIOS | + NV_DEVICE_V0_DISABLE_CORE | + NV_DEVICE_V0_DISABLE_IDENTIFY), .debug0 = ~((1ULL << NVDEV_SUBDEV_TIMER) | (1ULL << NVDEV_ENGINE_PERFMON)), - }, sizeof(struct nv_device_class), &device); + }, sizeof(struct nv_device_v0), &device); nvif_client_ref(NULL, &client); if (ret) return ret; diff --git a/bin/nv_rdfuc.c b/bin/nv_rdfuc.c index 1478eb13d..27d4cb2ed 100644 --- a/bin/nv_rdfuc.c +++ b/bin/nv_rdfuc.c @@ -43,12 +43,12 @@ main(int argc, char **argv) if (ret) return ret; - ret = nvif_device_new(nvif_object(client), 0x00000000, NV_DEVICE_CLASS, - &(struct nv_device_class) { + ret = nvif_device_new(nvif_object(client), 0x00000000, NV_DEVICE, + &(struct nv_device_v0) { .device = ~0ULL, - .disable = ~NV_DEVICE_DISABLE_MMIO, + .disable = ~NV_DEVICE_V0_DISABLE_MMIO, .debug0 = 0, - }, sizeof(struct nv_device_class), &device); + }, sizeof(struct nv_device_v0), &device); nvif_client_ref(NULL, &client); if (ret) return ret; diff --git a/bin/nv_rdfunc.h b/bin/nv_rdfunc.h index fef29de7a..4dc77243e 100644 --- a/bin/nv_rdfunc.h +++ b/bin/nv_rdfunc.h @@ -8,7 +8,7 @@ #include <core/class.h> #ifndef ENABLE -#define ENABLE NV_DEVICE_DISABLE_MMIO +#define ENABLE NV_DEVICE_V0_DISABLE_MMIO #endif #ifndef DEBUG0 #define DEBUG0 0ULL @@ -23,7 +23,7 @@ main(int argc, char **argv) u64 dev = ~0ULL; struct nvif_client *client; struct nvif_device *device; - struct nv_device_class args; + struct nv_device_v0 args = {}; char *rstr = NULL; enum { NORMAL, @@ -64,7 +64,7 @@ main(int argc, char **argv) args.disable = ~ENABLE; args.debug0 = ~DEBUG0; - ret = nvif_device_new(nvif_object(client), 0x00000000, NV_DEVICE_CLASS, + ret = nvif_device_new(nvif_object(client), 0x00000000, NV_DEVICE, &args, sizeof(args), &device); nvif_client_ref(NULL, &client); if (ret) diff --git a/bin/nv_rffunc.h b/bin/nv_rffunc.h index 31dc5c88e..caf973dc3 100644 --- a/bin/nv_rffunc.h +++ b/bin/nv_rffunc.h @@ -35,5 +35,5 @@ nv_rfb(struct nvif_device *device, u64 offset) } #define READ(o) nv_rfb(device, (o)) -#define ENABLE (NV_DEVICE_DISABLE_MMIO | NV_DEVICE_DISABLE_IDENTIFY) +#define ENABLE (NV_DEVICE_V0_DISABLE_MMIO | NV_DEVICE_V0_DISABLE_IDENTIFY) #include "nv_rdfunc.h" diff --git a/bin/nv_rifunc.h b/bin/nv_rifunc.h index 8041ea1b4..be9578ca8 100644 --- a/bin/nv_rifunc.h +++ b/bin/nv_rifunc.h @@ -42,5 +42,5 @@ nv_rfb(struct nvif_device *device, u64 offset) } #define READ(o) nv_rfb(device, (o)) -#define ENABLE (NV_DEVICE_DISABLE_MMIO | NV_DEVICE_DISABLE_IDENTIFY) +#define ENABLE (NV_DEVICE_V0_DISABLE_MMIO | NV_DEVICE_V0_DISABLE_IDENTIFY) #include "nv_rdfunc.h" diff --git a/bin/nv_rsfunc.h b/bin/nv_rsfunc.h index 47b53fee8..e5cff49e1 100644 --- a/bin/nv_rsfunc.h +++ b/bin/nv_rsfunc.h @@ -20,5 +20,5 @@ nv_rsys(struct nvif_device *device, u64 addr) } #define READ(o) nv_rsys(device, (o)) -#define ENABLE (NV_DEVICE_DISABLE_MMIO | NV_DEVICE_DISABLE_IDENTIFY) +#define ENABLE (NV_DEVICE_V0_DISABLE_MMIO | NV_DEVICE_V0_DISABLE_IDENTIFY) #include "nv_rdfunc.h" diff --git a/bin/nv_rvfunc.h b/bin/nv_rvfunc.h index 590e959b2..7ab2db9a7 100644 --- a/bin/nv_rvfunc.h +++ b/bin/nv_rvfunc.h @@ -20,5 +20,5 @@ nv_rvram(struct nvif_device *device, u64 addr) } #define READ(o) nv_rvram(device, (o)) -#define ENABLE (NV_DEVICE_DISABLE_MMIO | NV_DEVICE_DISABLE_IDENTIFY) +#define ENABLE (NV_DEVICE_V0_DISABLE_MMIO | NV_DEVICE_V0_DISABLE_IDENTIFY) #include "nv_rdfunc.h" diff --git a/bin/nv_wffunc.h b/bin/nv_wffunc.h index 6aaf13176..fde5bc027 100644 --- a/bin/nv_wffunc.h +++ b/bin/nv_wffunc.h @@ -35,5 +35,5 @@ nv_wfb(struct nvif_device *device, u64 offset, CAST data) } #define WRITE(o,v) nv_wfb(device, (o), (v)) -#define ENABLE (NV_DEVICE_DISABLE_MMIO | NV_DEVICE_DISABLE_IDENTIFY) +#define ENABLE (NV_DEVICE_V0_DISABLE_MMIO | NV_DEVICE_V0_DISABLE_IDENTIFY) #include "nv_wrfunc.h" diff --git a/bin/nv_wifunc.h b/bin/nv_wifunc.h index 2ae519228..19df090d8 100644 --- a/bin/nv_wifunc.h +++ b/bin/nv_wifunc.h @@ -42,5 +42,5 @@ nv_wfb(struct nvif_device *device, u64 offset, CAST data) } #define WRITE(o,v) nv_wfb(device, (o), (v)) -#define ENABLE (NV_DEVICE_DISABLE_MMIO | NV_DEVICE_DISABLE_IDENTIFY) +#define ENABLE (NV_DEVICE_V0_DISABLE_MMIO | NV_DEVICE_V0_DISABLE_IDENTIFY) #include "nv_wrfunc.h" diff --git a/bin/nv_wrfunc.h b/bin/nv_wrfunc.h index c0e24efd1..88d2b629e 100644 --- a/bin/nv_wrfunc.h +++ b/bin/nv_wrfunc.h @@ -8,7 +8,7 @@ #include <core/class.h> #ifndef ENABLE -#define ENABLE NV_DEVICE_DISABLE_MMIO +#define ENABLE NV_DEVICE_V0_DISABLE_MMIO #endif #ifndef DEBUG0 #define DEBUG0 0ULL @@ -23,7 +23,7 @@ MAIN(int argc, char **argv) u64 dev = ~0ULL; struct nvif_client *client; struct nvif_device *device; - struct nv_device_class args; + struct nv_device_v0 args = {}; char *rstr = NULL; char *vstr = NULL; int quiet = 0; @@ -58,7 +58,7 @@ MAIN(int argc, char **argv) args.disable = ~ENABLE; args.debug0 = ~DEBUG0; - ret = nvif_device_new(nvif_object(client), 0, NV_DEVICE_CLASS, + ret = nvif_device_new(nvif_object(client), 0, NV_DEVICE, &args, sizeof(args), &device); nvif_client_ref(NULL, &client); if (ret) diff --git a/bin/nv_wsfunc.h b/bin/nv_wsfunc.h index 70feefb10..9472fc9b1 100644 --- a/bin/nv_wsfunc.h +++ b/bin/nv_wsfunc.h @@ -18,5 +18,5 @@ nv_wsys(struct nvif_device *device, u64 addr, CAST data) } #define WRITE(o,v) nv_wsys(device, (o), (v)) -#define ENABLE (NV_DEVICE_DISABLE_MMIO | NV_DEVICE_DISABLE_IDENTIFY) +#define ENABLE (NV_DEVICE_V0_DISABLE_MMIO | NV_DEVICE_V0_DISABLE_IDENTIFY) #include "nv_wrfunc.h" diff --git a/bin/nv_wvfunc.h b/bin/nv_wvfunc.h index 2832f168d..668278ace 100644 --- a/bin/nv_wvfunc.h +++ b/bin/nv_wvfunc.h @@ -18,5 +18,5 @@ nv_wvram(struct nvif_device *device, u64 addr, CAST data) } #define WRITE(o,v) nv_wvram(device, (o), (v)) -#define ENABLE (NV_DEVICE_DISABLE_MMIO | NV_DEVICE_DISABLE_IDENTIFY) +#define ENABLE (NV_DEVICE_V0_DISABLE_MMIO | NV_DEVICE_V0_DISABLE_IDENTIFY) #include "nv_wrfunc.h" diff --git a/drm/nouveau_abi16.c b/drm/nouveau_abi16.c index 3192bbaf3..1e312feb1 100644 --- a/drm/nouveau_abi16.c +++ b/drm/nouveau_abi16.c @@ -41,6 +41,10 @@ nouveau_abi16_get(struct drm_file *file_priv, struct drm_device *dev) struct nouveau_abi16 *abi16; cli->abi16 = abi16 = kzalloc(sizeof(*abi16), GFP_KERNEL); if (cli->abi16) { + struct nv_device_v0 args = { + .device = ~0ULL, + }; + INIT_LIST_HEAD(&abi16->channels); /* allocate device object targeting client's default @@ -49,9 +53,7 @@ nouveau_abi16_get(struct drm_file *file_priv, struct drm_device *dev) */ if (nvif_device_init(&cli->base.base, NULL, NOUVEAU_ABI16_DEVICE, NV_DEVICE, - &(struct nv_device_class) { - .device = ~0ULL, - }, sizeof(struct nv_device_class), + &args, sizeof(args), &abi16->device) == 0) return cli->abi16; diff --git a/drm/nouveau_drm.c b/drm/nouveau_drm.c index 9d0ad53b9..f9f2e0efd 100644 --- a/drm/nouveau_drm.c +++ b/drm/nouveau_drm.c @@ -383,18 +383,18 @@ nouveau_drm_load(struct drm_device *dev, unsigned long flags) * (possibly) execute vbios init tables (see nouveau_agp.h) */ if (pdev && drm_pci_device_is_agp(dev) && dev->agp) { + const u64 enables = NV_DEVICE_V0_DISABLE_IDENTIFY | + NV_DEVICE_V0_DISABLE_MMIO; /* dummy device object, doesn't init anything, but allows * agp code access to registers */ ret = nvif_device_init(&drm->client.base.base, NULL, - NVDRM_DEVICE, NV_DEVICE_CLASS, - &(struct nv_device_class) { + NVDRM_DEVICE, NV_DEVICE, + &(struct nv_device_v0) { .device = ~0, - .disable = - ~(NV_DEVICE_DISABLE_MMIO | - NV_DEVICE_DISABLE_IDENTIFY), + .disable = ~enables, .debug0 = ~0, - }, sizeof(struct nv_device_class), + }, sizeof(struct nv_device_v0), &drm->device); if (ret) goto fail_device; @@ -404,12 +404,12 @@ nouveau_drm_load(struct drm_device *dev, unsigned long flags) } ret = nvif_device_init(&drm->client.base.base, NULL, NVDRM_DEVICE, - NV_DEVICE_CLASS, - &(struct nv_device_class) { + NV_DEVICE, + &(struct nv_device_v0) { .device = ~0, .disable = 0, .debug0 = 0, - }, sizeof(struct nv_device_class), + }, sizeof(struct nv_device_v0), &drm->device); if (ret) goto fail_device; diff --git a/nvif/class.h b/nvif/class.h index 3013656bd..0aa6272b9 100644 --- a/nvif/class.h +++ b/nvif/class.h @@ -27,6 +27,31 @@ struct nv_client_devlist_v0 { * device ******************************************************************************/ +struct nv_device_v0 { + __u8 version; + __u8 pad01[7]; + __u64 device; /* device identifier, ~0 for client default */ +#define NV_DEVICE_V0_DISABLE_IDENTIFY 0x0000000000000001ULL +#define NV_DEVICE_V0_DISABLE_MMIO 0x0000000000000002ULL +#define NV_DEVICE_V0_DISABLE_VBIOS 0x0000000000000004ULL +#define NV_DEVICE_V0_DISABLE_CORE 0x0000000000000008ULL +#define NV_DEVICE_V0_DISABLE_DISP 0x0000000000010000ULL +#define NV_DEVICE_V0_DISABLE_FIFO 0x0000000000020000ULL +#define NV_DEVICE_V0_DISABLE_GRAPH 0x0000000100000000ULL +#define NV_DEVICE_V0_DISABLE_MPEG 0x0000000200000000ULL +#define NV_DEVICE_V0_DISABLE_ME 0x0000000400000000ULL +#define NV_DEVICE_V0_DISABLE_VP 0x0000000800000000ULL +#define NV_DEVICE_V0_DISABLE_CRYPT 0x0000001000000000ULL +#define NV_DEVICE_V0_DISABLE_BSP 0x0000002000000000ULL +#define NV_DEVICE_V0_DISABLE_PPP 0x0000004000000000ULL +#define NV_DEVICE_V0_DISABLE_COPY0 0x0000008000000000ULL +#define NV_DEVICE_V0_DISABLE_COPY1 0x0000010000000000ULL +#define NV_DEVICE_V0_DISABLE_VIC 0x0000020000000000ULL +#define NV_DEVICE_V0_DISABLE_VENC 0x0000040000000000ULL + __u64 disable; /* disable particular subsystems */ + __u64 debug0; /* as above, but *internal* ids, and *NOT* ABI */ +}; + #define NV_DEVICE_V0_INFO 0x00 struct nv_device_info_v0 { diff --git a/nvkm/engine/device/base.c b/nvkm/engine/device/base.c index 8d74a3163..c7e9794a3 100644 --- a/nvkm/engine/device/base.c +++ b/nvkm/engine/device/base.c @@ -195,66 +195,117 @@ nouveau_devobj_wr32(struct nouveau_object *object, u64 addr, u32 data) nv_wr32(object->engine, addr, data); } +static int +nouveau_devobj_map(struct nouveau_object *object, u64 *addr, u32 *size) +{ + struct nouveau_device *device = nv_device(object); + *addr = nv_device_resource_start(device, 0); + *size = nv_device_resource_len(device, 0); + return 0; +} + static const u64 disable_map[] = { - [NVDEV_SUBDEV_VBIOS] = NV_DEVICE_DISABLE_VBIOS, - [NVDEV_SUBDEV_DEVINIT] = NV_DEVICE_DISABLE_CORE, - [NVDEV_SUBDEV_GPIO] = NV_DEVICE_DISABLE_CORE, - [NVDEV_SUBDEV_I2C] = NV_DEVICE_DISABLE_CORE, - [NVDEV_SUBDEV_CLOCK] = NV_DEVICE_DISABLE_CORE, - [NVDEV_SUBDEV_MXM] = NV_DEVICE_DISABLE_CORE, - [NVDEV_SUBDEV_MC] = NV_DEVICE_DISABLE_CORE, - [NVDEV_SUBDEV_BUS] = NV_DEVICE_DISABLE_CORE, - [NVDEV_SUBDEV_TIMER] = NV_DEVICE_DISABLE_CORE, - [NVDEV_SUBDEV_FB] = NV_DEVICE_DISABLE_CORE, - [NVDEV_SUBDEV_LTCG] = NV_DEVICE_DISABLE_CORE, - [NVDEV_SUBDEV_IBUS] = NV_DEVICE_DISABLE_CORE, - [NVDEV_SUBDEV_INSTMEM] = NV_DEVICE_DISABLE_CORE, - [NVDEV_SUBDEV_VM] = NV_DEVICE_DISABLE_CORE, - [NVDEV_SUBDEV_BAR] = NV_DEVICE_DISABLE_CORE, - [NVDEV_SUBDEV_VOLT] = NV_DEVICE_DISABLE_CORE, - [NVDEV_SUBDEV_THERM] = NV_DEVICE_DISABLE_CORE, - [NVDEV_SUBDEV_PWR] = NV_DEVICE_DISABLE_CORE, - [NVDEV_ENGINE_DMAOBJ] = NV_DEVICE_DISABLE_CORE, - [NVDEV_ENGINE_PERFMON] = NV_DEVICE_DISABLE_CORE, - [NVDEV_ENGINE_FIFO] = NV_DEVICE_DISABLE_FIFO, - [NVDEV_ENGINE_SW] = NV_DEVICE_DISABLE_FIFO, - [NVDEV_ENGINE_GR] = NV_DEVICE_DISABLE_GRAPH, - [NVDEV_ENGINE_MPEG] = NV_DEVICE_DISABLE_MPEG, - [NVDEV_ENGINE_ME] = NV_DEVICE_DISABLE_ME, - [NVDEV_ENGINE_VP] = NV_DEVICE_DISABLE_VP, - [NVDEV_ENGINE_CRYPT] = NV_DEVICE_DISABLE_CRYPT, - [NVDEV_ENGINE_BSP] = NV_DEVICE_DISABLE_BSP, - [NVDEV_ENGINE_PPP] = NV_DEVICE_DISABLE_PPP, - [NVDEV_ENGINE_COPY0] = NV_DEVICE_DISABLE_COPY0, - [NVDEV_ENGINE_COPY1] = NV_DEVICE_DISABLE_COPY1, - [NVDEV_ENGINE_VIC] = NV_DEVICE_DISABLE_VIC, - [NVDEV_ENGINE_VENC] = NV_DEVICE_DISABLE_VENC, - [NVDEV_ENGINE_DISP] = NV_DEVICE_DISABLE_DISP, + [NVDEV_SUBDEV_VBIOS] = NV_DEVICE_V0_DISABLE_VBIOS, + [NVDEV_SUBDEV_DEVINIT] = NV_DEVICE_V0_DISABLE_CORE, + [NVDEV_SUBDEV_GPIO] = NV_DEVICE_V0_DISABLE_CORE, + [NVDEV_SUBDEV_I2C] = NV_DEVICE_V0_DISABLE_CORE, + [NVDEV_SUBDEV_CLOCK] = NV_DEVICE_V0_DISABLE_CORE, + [NVDEV_SUBDEV_MXM] = NV_DEVICE_V0_DISABLE_CORE, + [NVDEV_SUBDEV_MC] = NV_DEVICE_V0_DISABLE_CORE, + [NVDEV_SUBDEV_BUS] = NV_DEVICE_V0_DISABLE_CORE, + [NVDEV_SUBDEV_TIMER] = NV_DEVICE_V0_DISABLE_CORE, + [NVDEV_SUBDEV_FB] = NV_DEVICE_V0_DISABLE_CORE, + [NVDEV_SUBDEV_LTCG] = NV_DEVICE_V0_DISABLE_CORE, + [NVDEV_SUBDEV_IBUS] = NV_DEVICE_V0_DISABLE_CORE, + [NVDEV_SUBDEV_INSTMEM] = NV_DEVICE_V0_DISABLE_CORE, + [NVDEV_SUBDEV_VM] = NV_DEVICE_V0_DISABLE_CORE, + [NVDEV_SUBDEV_BAR] = NV_DEVICE_V0_DISABLE_CORE, + [NVDEV_SUBDEV_VOLT] = NV_DEVICE_V0_DISABLE_CORE, + [NVDEV_SUBDEV_THERM] = NV_DEVICE_V0_DISABLE_CORE, + [NVDEV_SUBDEV_PWR] = NV_DEVICE_V0_DISABLE_CORE, + [NVDEV_ENGINE_DMAOBJ] = NV_DEVICE_V0_DISABLE_CORE, + [NVDEV_ENGINE_PERFMON] = NV_DEVICE_V0_DISABLE_CORE, + [NVDEV_ENGINE_FIFO] = NV_DEVICE_V0_DISABLE_FIFO, + [NVDEV_ENGINE_SW] = NV_DEVICE_V0_DISABLE_FIFO, + [NVDEV_ENGINE_GR] = NV_DEVICE_V0_DISABLE_GRAPH, + [NVDEV_ENGINE_MPEG] = NV_DEVICE_V0_DISABLE_MPEG, + [NVDEV_ENGINE_ME] = NV_DEVICE_V0_DISABLE_ME, + [NVDEV_ENGINE_VP] = NV_DEVICE_V0_DISABLE_VP, + [NVDEV_ENGINE_CRYPT] = NV_DEVICE_V0_DISABLE_CRYPT, + [NVDEV_ENGINE_BSP] = NV_DEVICE_V0_DISABLE_BSP, + [NVDEV_ENGINE_PPP] = NV_DEVICE_V0_DISABLE_PPP, + [NVDEV_ENGINE_COPY0] = NV_DEVICE_V0_DISABLE_COPY0, + [NVDEV_ENGINE_COPY1] = NV_DEVICE_V0_DISABLE_COPY1, + [NVDEV_ENGINE_VIC] = NV_DEVICE_V0_DISABLE_VIC, + [NVDEV_ENGINE_VENC] = NV_DEVICE_V0_DISABLE_VENC, + [NVDEV_ENGINE_DISP] = NV_DEVICE_V0_DISABLE_DISP, [NVDEV_SUBDEV_NR] = 0, }; +static void +nouveau_devobj_dtor(struct nouveau_object *object) +{ + struct nouveau_devobj *devobj = (void *)object; + int i; + + for (i = NVDEV_SUBDEV_NR - 1; i >= 0; i--) + nouveau_object_ref(NULL, &devobj->subdev[i]); + + nouveau_parent_destroy(&devobj->base); +} + +static struct nouveau_oclass +nouveau_devobj_oclass_super = { + .handle = NV_DEVICE, + .ofuncs = &(struct nouveau_ofuncs) { + .dtor = nouveau_devobj_dtor, + .init = _nouveau_parent_init, + .fini = _nouveau_parent_fini, + .mthd = nouveau_devobj_mthd, + .map = nouveau_devobj_map, + .rd08 = nouveau_devobj_rd08, + .rd16 = nouveau_devobj_rd16, + .rd32 = nouveau_devobj_rd32, + .wr08 = nouveau_devobj_wr08, + .wr16 = nouveau_devobj_wr16, + .wr32 = nouveau_devobj_wr32, + } +}; + static int nouveau_devobj_ctor(struct nouveau_object *parent, struct nouveau_object *engine, struct nouveau_oclass *oclass, void *data, u32 size, struct nouveau_object **pobject) { + union { + struct nv_device_v0 v0; + } *args = data; struct nouveau_client *client = nv_client(parent); struct nouveau_device *device; struct nouveau_devobj *devobj; - struct nv_device_class *args = data; u32 boot0, strap; u64 disable, mmio_base, mmio_size; void __iomem *map; int ret, i, c; - if (size < sizeof(struct nv_device_class)) - return -EINVAL; + nv_ioctl(parent, "create device size %d\n", size); + if (nvif_unpack(args->v0, 0, 0, false)) { + nv_ioctl(parent, "create device v%d device %016llx " + "disable %016llx debug0 %016llx\n", + args->v0.version, args->v0.device, + args->v0.disable, args->v0.debug0); + } else + return ret; + + /* give priviledged clients register access */ + if (client->super) + oclass = &nouveau_devobj_oclass_super; /* find the device subdev that matches what the client requested */ device = nv_device(client->device); - if (args->device != ~0) { - device = nouveau_device_find(args->device); + if (args->v0.device != ~0) { + device = nouveau_device_find(args->v0.device); if (!device) return -ENODEV; } @@ -273,14 +324,14 @@ nouveau_devobj_ctor(struct nouveau_object *parent, mmio_size = nv_device_resource_len(device, 0); /* translate api disable mask into internal mapping */ - disable = args->debug0; + disable = args->v0.debug0; for (i = 0; i < NVDEV_SUBDEV_NR; i++) { - if (args->disable & disable_map[i]) + if (args->v0.disable & disable_map[i]) disable |= (1ULL << i); } /* identify the chipset, and determine classes of subdev/engines */ - if (!(args->disable & NV_DEVICE_DISABLE_IDENTIFY) && + if (!(args->v0.disable & NV_DEVICE_V0_DISABLE_IDENTIFY) && !device->card_type) { map = ioremap(mmio_base, 0x102000); if (map == NULL) @@ -379,7 +430,7 @@ nouveau_devobj_ctor(struct nouveau_object *parent, nv_debug(device, "crystal freq: %dKHz\n", device->crystal); } - if (!(args->disable & NV_DEVICE_DISABLE_MMIO) && + if (!(args->v0.disable & NV_DEVICE_V0_DISABLE_MMIO) && !nv_subdev(device)->mmio) { nv_subdev(device)->mmio = ioremap(mmio_base, mmio_size); if (!nv_subdev(device)->mmio) { @@ -435,18 +486,6 @@ nouveau_devobj_ctor(struct nouveau_object *parent, return 0; } -static void -nouveau_devobj_dtor(struct nouveau_object *object) -{ - struct nouveau_devobj *devobj = (void *)object; - int i; - - for (i = NVDEV_SUBDEV_NR - 1; i >= 0; i--) - nouveau_object_ref(NULL, &devobj->subdev[i]); - - nouveau_parent_destroy(&devobj->base); -} - static struct nouveau_ofuncs nouveau_devobj_ofuncs = { .ctor = nouveau_devobj_ctor, @@ -454,12 +493,6 @@ nouveau_devobj_ofuncs = { .init = _nouveau_parent_init, .fini = _nouveau_parent_fini, .mthd = nouveau_devobj_mthd, - .rd08 = nouveau_devobj_rd08, - .rd16 = nouveau_devobj_rd16, - .rd32 = nouveau_devobj_rd32, - .wr08 = nouveau_devobj_wr08, - .wr16 = nouveau_devobj_wr16, - .wr32 = nouveau_devobj_wr32, }; /****************************************************************************** diff --git a/nvkm/engine/disp/nv50.c b/nvkm/engine/disp/nv50.c index 5311f0fcd..ca8ce9cac 100644 --- a/nvkm/engine/disp/nv50.c +++ b/nvkm/engine/disp/nv50.c @@ -990,7 +990,7 @@ nv50_disp_data_ctor(struct nouveau_object *parent, int ret = -EBUSY; /* no context needed for channel objects... */ - if (nv_mclass(parent) != NV_DEVICE_CLASS) { + if (nv_mclass(parent) != NV_DEVICE) { atomic_inc(&parent->refcount); *pobject = parent; return 1; diff --git a/nvkm/engine/dmaobj/base.c b/nvkm/engine/dmaobj/base.c index 5103e88d1..a11b83d50 100644 --- a/nvkm/engine/dmaobj/base.c +++ b/nvkm/engine/dmaobj/base.c @@ -88,7 +88,7 @@ nouveau_dmaobj_ctor(struct nouveau_object *parent, dmaobj->conf0 = args->conf0; switch (nv_mclass(parent)) { - case NV_DEVICE_CLASS: + case NV_DEVICE: /* delayed, or no, binding */ break; default: diff --git a/nvkm/include/core/class.h b/nvkm/include/core/class.h index 37d47cb44..fa35f0041 100644 --- a/nvkm/include/core/class.h +++ b/nvkm/include/core/class.h @@ -3,36 +3,6 @@ #include <nvif/class.h> -/* Device class - * - * 0080: NV_DEVICE - */ -#define NV_DEVICE_CLASS 0x00000080 - -#define NV_DEVICE_DISABLE_IDENTIFY 0x0000000000000001ULL -#define NV_DEVICE_DISABLE_MMIO 0x0000000000000002ULL -#define NV_DEVICE_DISABLE_VBIOS 0x0000000000000004ULL -#define NV_DEVICE_DISABLE_CORE 0x0000000000000008ULL -#define NV_DEVICE_DISABLE_DISP 0x0000000000010000ULL -#define NV_DEVICE_DISABLE_FIFO 0x0000000000020000ULL -#define NV_DEVICE_DISABLE_GRAPH 0x0000000100000000ULL -#define NV_DEVICE_DISABLE_MPEG 0x0000000200000000ULL -#define NV_DEVICE_DISABLE_ME 0x0000000400000000ULL -#define NV_DEVICE_DISABLE_VP 0x0000000800000000ULL -#define NV_DEVICE_DISABLE_CRYPT 0x0000001000000000ULL -#define NV_DEVICE_DISABLE_BSP 0x0000002000000000ULL -#define NV_DEVICE_DISABLE_PPP 0x0000004000000000ULL -#define NV_DEVICE_DISABLE_COPY0 0x0000008000000000ULL -#define NV_DEVICE_DISABLE_COPY1 0x0000010000000000ULL -#define NV_DEVICE_DISABLE_VIC 0x0000020000000000ULL -#define NV_DEVICE_DISABLE_VENC 0x0000040000000000ULL - -struct nv_device_class { - u64 device; /* device identifier, ~0 for client default */ - u64 disable; /* disable particular subsystems */ - u64 debug0; /* as above, but *internal* ids, and *NOT* ABI */ -}; - /* DMA object classes * * 0002: NV_DMA_FROM_MEMORY |