From: Ben Skeggs Date: Thu, 20 Aug 2015 04:54:05 +0000 (+1000) Subject: drm/nouveau/subdev: add direct pointer to nvkm_device X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=d351b8569e3c57bf5dc3dd5a1295974a9e04316e;p=linux-beck.git drm/nouveau/subdev: add direct pointer to nvkm_device Will be utilised in upcoming commits to remove the need for heuristics to lookup the device a subdev belongs to. Signed-off-by: Ben Skeggs --- diff --git a/drivers/gpu/drm/nouveau/dispnv04/tvnv17.c b/drivers/gpu/drm/nouveau/dispnv04/tvnv17.c index d9720dda8385..792bf5428f35 100644 --- a/drivers/gpu/drm/nouveau/dispnv04/tvnv17.c +++ b/drivers/gpu/drm/nouveau/dispnv04/tvnv17.c @@ -130,17 +130,17 @@ static bool get_tv_detect_quirks(struct drm_device *dev, uint32_t *pin_mask) { struct nouveau_drm *drm = nouveau_drm(dev); - struct nvif_device *device = &drm->device; + struct nvkm_device *device = nvxx_device(&drm->device); /* Zotac FX5200 */ - if (nv_device_match(nvxx_object(device), 0x0322, 0x19da, 0x1035) || - nv_device_match(nvxx_object(device), 0x0322, 0x19da, 0x2035)) { + if (nv_device_match(device, 0x0322, 0x19da, 0x1035) || + nv_device_match(device, 0x0322, 0x19da, 0x2035)) { *pin_mask = 0xc; return false; } /* MSI nForce2 IGP */ - if (nv_device_match(nvxx_object(device), 0x01f0, 0x1462, 0x5710)) { + if (nv_device_match(device, 0x01f0, 0x1462, 0x5710)) { *pin_mask = 0xc; return false; } diff --git a/drivers/gpu/drm/nouveau/include/nvkm/core/device.h b/drivers/gpu/drm/nouveau/include/nvkm/core/device.h index 333db33a162c..5983b307e127 100644 --- a/drivers/gpu/drm/nouveau/include/nvkm/core/device.h +++ b/drivers/gpu/drm/nouveau/include/nvkm/core/device.h @@ -49,9 +49,8 @@ int nvkm_device_list(u64 *name, int size); struct nvkm_device *nv_device(void *obj); static inline bool -nv_device_match(struct nvkm_object *object, u16 dev, u16 ven, u16 sub) +nv_device_match(struct nvkm_device *device, u16 dev, u16 ven, u16 sub) { - struct nvkm_device *device = nv_device(object); return device->pdev->device == dev && device->pdev->subsystem_vendor == ven && device->pdev->subsystem_device == sub; diff --git a/drivers/gpu/drm/nouveau/include/nvkm/core/subdev.h b/drivers/gpu/drm/nouveau/include/nvkm/core/subdev.h index 6fdc39116aac..8357319f5a14 100644 --- a/drivers/gpu/drm/nouveau/include/nvkm/core/subdev.h +++ b/drivers/gpu/drm/nouveau/include/nvkm/core/subdev.h @@ -8,6 +8,9 @@ struct nvkm_subdev { struct nvkm_object object; + + struct nvkm_device *device; + struct mutex mutex; const char *name; void __iomem *mmio; diff --git a/drivers/gpu/drm/nouveau/nvkm/core/subdev.c b/drivers/gpu/drm/nouveau/nvkm/core/subdev.c index c5fb3a793174..b96cb2cca55e 100644 --- a/drivers/gpu/drm/nouveau/nvkm/core/subdev.c +++ b/drivers/gpu/drm/nouveau/nvkm/core/subdev.c @@ -114,6 +114,9 @@ nvkm_subdev_create_(struct nvkm_object *parent, struct nvkm_object *engine, struct nvkm_device *device = nv_device(parent); subdev->debug = nvkm_dbgopt(device->dbgopt, subname); subdev->mmio = nv_subdev(device)->mmio; + subdev->device = device; + } else { + subdev->device = nv_device(subdev); } return 0; diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/gpio/base.c b/drivers/gpu/drm/nouveau/nvkm/subdev/gpio/base.c index dea58161ba46..980822d6d645 100644 --- a/drivers/gpu/drm/nouveau/nvkm/subdev/gpio/base.c +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/gpio/base.c @@ -44,6 +44,7 @@ static int nvkm_gpio_find(struct nvkm_gpio *gpio, int idx, u8 tag, u8 line, struct dcb_gpio_func *func) { + struct nvkm_device *device = gpio->base.device; struct nvkm_bios *bios = nvkm_bios(gpio); u8 ver, len; u16 data; @@ -56,7 +57,7 @@ nvkm_gpio_find(struct nvkm_gpio *gpio, int idx, u8 tag, u8 line, return 0; /* Apple iMac G4 NV18 */ - if (nv_device_match(nv_object(gpio), 0x0189, 0x10de, 0x0010)) { + if (nv_device_match(device, 0x0189, 0x10de, 0x0010)) { if (tag == DCB_GPIO_TVDAC0) { *func = (struct dcb_gpio_func) { .func = DCB_GPIO_TVDAC0, diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/pmu/gk104.c b/drivers/gpu/drm/nouveau/nvkm/subdev/pmu/gk104.c index b744136f5526..1e9f1d0f7a7d 100644 --- a/drivers/gpu/drm/nouveau/nvkm/subdev/pmu/gk104.c +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/pmu/gk104.c @@ -54,7 +54,6 @@ static void gk104_pmu_pgob(struct nvkm_pmu *pmu, bool enable) { struct nvkm_device *device = nv_device(pmu); - struct nvkm_object *dev = nv_object(device); nv_mask(pmu, 0x000200, 0x00001000, 0x00000000); nv_rd32(pmu, 0x000200); @@ -76,8 +75,8 @@ gk104_pmu_pgob(struct nvkm_pmu *pmu, bool enable) nv_mask(pmu, 0x000200, 0x00001000, 0x00001000); nv_rd32(pmu, 0x000200); - if (nv_device_match(dev, 0x11fc, 0x17aa, 0x2211) /* Lenovo W541 */ - || nv_device_match(dev, 0x11fc, 0x17aa, 0x221e) /* Lenovo W541 */ + if (nv_device_match(device, 0x11fc, 0x17aa, 0x2211) /* Lenovo W541 */ + || nv_device_match(device, 0x11fc, 0x17aa, 0x221e) /* Lenovo W541 */ || nvkm_boolopt(device->cfgopt, "War00C800_0", false)) { nv_info(pmu, "hw bug workaround enabled\n"); switch (device->chipset) {