From 47b2505efb2d951f16c3a229d93450b463d925e5 Mon Sep 17 00:00:00 2001 From: Ben Skeggs Date: Thu, 20 Aug 2015 14:54:15 +1000 Subject: [PATCH] drm/nouveau/platform: remove subclassing of nvkm_device Signed-off-by: Ben Skeggs --- drivers/gpu/drm/nouveau/include/nvkm/core/device.h | 2 ++ drivers/gpu/drm/nouveau/nouveau_drm.c | 14 +++++++------- drivers/gpu/drm/nouveau/nouveau_drm.h | 5 +---- drivers/gpu/drm/nouveau/nouveau_platform.c | 6 +++--- drivers/gpu/drm/nouveau/nouveau_platform.h | 10 ---------- drivers/gpu/drm/nouveau/nvkm/subdev/clk/gk20a.c | 5 ++--- .../gpu/drm/nouveau/nvkm/subdev/instmem/gk20a.c | 13 ++++++------- drivers/gpu/drm/nouveau/nvkm/subdev/volt/gk20a.c | 10 ++++------ 8 files changed, 25 insertions(+), 40 deletions(-) diff --git a/drivers/gpu/drm/nouveau/include/nvkm/core/device.h b/drivers/gpu/drm/nouveau/include/nvkm/core/device.h index ffff6fd5a348..d48e5006e14e 100644 --- a/drivers/gpu/drm/nouveau/include/nvkm/core/device.h +++ b/drivers/gpu/drm/nouveau/include/nvkm/core/device.h @@ -144,6 +144,8 @@ struct nvkm_device { struct nvkm_sw *sw; struct nvkm_engine *vic; struct nvkm_engine *vp; + + struct nouveau_platform_gpu *gpu; }; struct nvkm_device *nvkm_device_find(u64 name); diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c index 4e6c1803fd37..9e420f6c1a74 100644 --- a/drivers/gpu/drm/nouveau/nouveau_drm.c +++ b/drivers/gpu/drm/nouveau/nouveau_drm.c @@ -1056,16 +1056,16 @@ nouveau_drm_pci_driver = { }; struct drm_device * -nouveau_platform_device_create_(struct platform_device *pdev, int size, - void **pobject) +nouveau_platform_device_create(struct platform_device *pdev, + struct nvkm_device **pdevice) { struct drm_device *drm; int err; - err = nvkm_device_create_(pdev, NVKM_BUS_PLATFORM, - nouveau_platform_name(pdev), - dev_name(&pdev->dev), nouveau_config, - nouveau_debug, size, pobject); + err = nvkm_device_create(pdev, NVKM_BUS_PLATFORM, + nouveau_platform_name(pdev), + dev_name(&pdev->dev), nouveau_config, + nouveau_debug, pdevice); if (err) return ERR_PTR(err); @@ -1085,7 +1085,7 @@ nouveau_platform_device_create_(struct platform_device *pdev, int size, return drm; err_free: - nvkm_object_ref(NULL, (struct nvkm_object **)pobject); + nvkm_object_ref(NULL, (struct nvkm_object **)pdevice); return ERR_PTR(err); } diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.h b/drivers/gpu/drm/nouveau/nouveau_drm.h index 81ef59272ed2..d1a4c120b71b 100644 --- a/drivers/gpu/drm/nouveau/nouveau_drm.h +++ b/drivers/gpu/drm/nouveau/nouveau_drm.h @@ -182,11 +182,8 @@ nouveau_drm(struct drm_device *dev) int nouveau_pmops_suspend(struct device *); int nouveau_pmops_resume(struct device *); -#define nouveau_platform_device_create(p, u) \ - nouveau_platform_device_create_(p, sizeof(**u), (void **)u) struct drm_device * -nouveau_platform_device_create_(struct platform_device *pdev, - int size, void **pobject); +nouveau_platform_device_create(struct platform_device *, struct nvkm_device **); void nouveau_drm_device_remove(struct drm_device *dev); #define NV_PRINTK(l,c,f,a...) do { \ diff --git a/drivers/gpu/drm/nouveau/nouveau_platform.c b/drivers/gpu/drm/nouveau/nouveau_platform.c index 7a39d449fefa..c03736bce953 100644 --- a/drivers/gpu/drm/nouveau/nouveau_platform.c +++ b/drivers/gpu/drm/nouveau/nouveau_platform.c @@ -177,7 +177,7 @@ static void nouveau_platform_remove_iommu(struct device *dev, static int nouveau_platform_probe(struct platform_device *pdev) { struct nouveau_platform_gpu *gpu; - struct nouveau_platform_device *device; + struct nvkm_device *device; struct drm_device *drm; int err; @@ -214,7 +214,7 @@ static int nouveau_platform_probe(struct platform_device *pdev) } device->gpu = gpu; - device->gpu_speedo = tegra_sku_info.gpu_speedo_value; + gpu->gpu_speedo = tegra_sku_info.gpu_speedo_value; err = drm_dev_register(drm, 0); if (err < 0) @@ -237,7 +237,7 @@ static int nouveau_platform_remove(struct platform_device *pdev) struct drm_device *drm_dev = platform_get_drvdata(pdev); struct nouveau_drm *drm = nouveau_drm(drm_dev); struct nvkm_device *device = nvxx_device(&drm->device); - struct nouveau_platform_gpu *gpu = nv_device_to_platform(device)->gpu; + struct nouveau_platform_gpu *gpu = device->gpu; int err; nouveau_drm_device_remove(drm_dev); diff --git a/drivers/gpu/drm/nouveau/nouveau_platform.h b/drivers/gpu/drm/nouveau/nouveau_platform.h index 392874cf4725..7a4020f31cc5 100644 --- a/drivers/gpu/drm/nouveau/nouveau_platform.h +++ b/drivers/gpu/drm/nouveau/nouveau_platform.h @@ -54,19 +54,9 @@ struct nouveau_platform_gpu { struct iommu_domain *domain; unsigned long pgshift; } iommu; -}; - -struct nouveau_platform_device { - struct nvkm_device device; - - struct nouveau_platform_gpu *gpu; int gpu_speedo; }; -#define nv_device_to_platform(d) \ - container_of(d, struct nouveau_platform_device, device) - extern struct platform_driver nouveau_platform_driver; - #endif diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/clk/gk20a.c b/drivers/gpu/drm/nouveau/nvkm/subdev/clk/gk20a.c index 2d10dc17238d..ce89955ff8f9 100644 --- a/drivers/gpu/drm/nouveau/nvkm/subdev/clk/gk20a.c +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/clk/gk20a.c @@ -650,8 +650,8 @@ gk20a_clk_ctor(struct nvkm_object *parent, struct nvkm_object *engine, struct nvkm_oclass *oclass, void *data, u32 size, struct nvkm_object **pobject) { + struct nvkm_device *device = (void *)parent; struct gk20a_clk *clk; - struct nouveau_platform_device *plat; int ret; int i; @@ -670,8 +670,7 @@ gk20a_clk_ctor(struct nvkm_object *parent, struct nvkm_object *engine, clk->params = &gk20a_pllg_params; - plat = nv_device_to_platform(nv_device(parent)); - clk->parent_rate = clk_get_rate(plat->gpu->clk); + clk->parent_rate = clk_get_rate(device->gpu->clk); nvkm_info(&clk->base.subdev, "parent clock rate: %d Mhz\n", clk->parent_rate / MHZ); diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/instmem/gk20a.c b/drivers/gpu/drm/nouveau/nvkm/subdev/instmem/gk20a.c index f5642698406a..e6370382109b 100644 --- a/drivers/gpu/drm/nouveau/nvkm/subdev/instmem/gk20a.c +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/instmem/gk20a.c @@ -396,8 +396,8 @@ gk20a_instmem_ctor(struct nvkm_object *parent, struct nvkm_object *engine, struct nvkm_oclass *oclass, void *data, u32 size, struct nvkm_object **pobject) { + struct nvkm_device *device = (void *)parent; struct gk20a_instmem *imem; - struct nouveau_platform_device *plat; int ret; ret = nvkm_instmem_create(parent, engine, oclass, &imem); @@ -407,12 +407,11 @@ gk20a_instmem_ctor(struct nvkm_object *parent, struct nvkm_object *engine, spin_lock_init(&imem->lock); - plat = nv_device_to_platform(nv_device(parent)); - if (plat->gpu->iommu.domain) { - imem->domain = plat->gpu->iommu.domain; - imem->mm = plat->gpu->iommu.mm; - imem->iommu_pgshift = plat->gpu->iommu.pgshift; - imem->mm_mutex = &plat->gpu->iommu.mutex; + if (device->gpu->iommu.domain) { + imem->domain = device->gpu->iommu.domain; + imem->mm = device->gpu->iommu.mm; + imem->iommu_pgshift = device->gpu->iommu.pgshift; + imem->mm_mutex = &device->gpu->iommu.mutex; nvkm_info(&imem->base.subdev, "using IOMMU\n"); } else { diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/volt/gk20a.c b/drivers/gpu/drm/nouveau/nvkm/subdev/volt/gk20a.c index d86f4eaba04c..59fa2cf898d2 100644 --- a/drivers/gpu/drm/nouveau/nvkm/subdev/volt/gk20a.c +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/volt/gk20a.c @@ -152,8 +152,8 @@ gk20a_volt_ctor(struct nvkm_object *parent, struct nvkm_object *engine, struct nvkm_oclass *oclass, void *data, u32 size, struct nvkm_object **pobject) { + struct nvkm_device *device = (void *)parent; struct gk20a_volt *volt; - struct nouveau_platform_device *plat; int i, ret, uv; ret = nvkm_volt_create(parent, engine, oclass, &volt); @@ -161,12 +161,10 @@ gk20a_volt_ctor(struct nvkm_object *parent, struct nvkm_object *engine, if (ret) return ret; - plat = nv_device_to_platform(nv_device(parent)); - - uv = regulator_get_voltage(plat->gpu->vdd); + uv = regulator_get_voltage(device->gpu->vdd); nvkm_info(&volt->base.subdev, "The default voltage is %duV\n", uv); - volt->vdd = plat->gpu->vdd; + volt->vdd = device->gpu->vdd; volt->base.vid_get = gk20a_volt_vid_get; volt->base.vid_set = gk20a_volt_vid_set; volt->base.set_id = gk20a_volt_set_id; @@ -178,7 +176,7 @@ gk20a_volt_ctor(struct nvkm_object *parent, struct nvkm_object *engine, volt->base.vid[i].vid = i; volt->base.vid[i].uv = gk20a_volt_calc_voltage(&gk20a_cvb_coef[i], - plat->gpu_speedo); + device->gpu->gpu_speedo); nvkm_debug(&volt->base.subdev, "%2d: vid=%d, uv=%d\n", i, volt->base.vid[i].vid, volt->base.vid[i].uv); } -- 2.39.5