Roy Spliet
2012-Aug-09 22:03 UTC
[Nouveau] [PATCH] drm/nouveau/nv50: Reclock when memory was stolen
Here's a quick-but-I-guess-tidy-fix for faulty behaviour someone reported in NVAF. I'm just not sure if the check for nvaa/nvac should still be in nv50_pm_clocks_pre... I believe this is wrong as they can reclock perfectly well (except the non-existing memory). Anyone has a definite answer to that?
Roy Spliet
2012-Aug-09 22:03 UTC
[Nouveau] [PATCH] drm/nouveau/nv50: Reclock when memory was stolen
Signed-off-by: Roy Spliet <r.spliet at student.tudelft.nl> --- drivers/gpu/drm/nouveau/core/subdev/fb/nv50.c | 2 +- drivers/gpu/drm/nouveau/nv50_pm.c | 3 ++- drivers/gpu/drm/nouveau/nva3_pm.c | 11 ++++++++--- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/nouveau/core/subdev/fb/nv50.c b/drivers/gpu/drm/nouveau/core/subdev/fb/nv50.c index eaf18fb..0c43d74 100644 --- a/drivers/gpu/drm/nouveau/core/subdev/fb/nv50.c +++ b/drivers/gpu/drm/nouveau/core/subdev/fb/nv50.c @@ -235,7 +235,7 @@ nv50_fb_ctor(struct nouveau_object *parent, struct nouveau_object *engine, ret = nouveau_mm_init(&priv->base.vram, rsvd_head, size, 1); if (ret) return ret; - + priv->base.ram.type = NV_MEM_TYPE_STOLEN; priv->base.ram.stolen = (u64)nv_rd32(priv, 0x100e10) << 12; break; default: diff --git a/drivers/gpu/drm/nouveau/nv50_pm.c b/drivers/gpu/drm/nouveau/nv50_pm.c index 0036c8c..3a41829 100644 --- a/drivers/gpu/drm/nouveau/nv50_pm.c +++ b/drivers/gpu/drm/nouveau/nv50_pm.c @@ -608,6 +608,7 @@ nv50_pm_clocks_pre(struct drm_device *dev, struct nouveau_pm_level *perflvl) { struct nouveau_device *device = nouveau_dev(dev); struct nouveau_drm *drm = nouveau_drm(dev); + struct nouveau_fb *pfb = nouveau_fb(device); struct nv50_pm_state *info; struct hwsq_ucode *hwsq; struct nvbios_pll pll; @@ -627,7 +628,7 @@ nv50_pm_clocks_pre(struct drm_device *dev, struct nouveau_pm_level *perflvl) /* memory: build hwsq ucode which we'll use to reclock memory. * use pcie refclock if possible, otherwise use mpll */ info->mclk_hwsq.len = 0; - if (perflvl->memory) { + if (perflvl->memory && pfb->ram.type > NV_MEM_TYPE_STOLEN) { ret = calc_mclk(dev, perflvl, info); if (ret) goto error; diff --git a/drivers/gpu/drm/nouveau/nva3_pm.c b/drivers/gpu/drm/nouveau/nva3_pm.c index 3f69e46..8906e98c 100644 --- a/drivers/gpu/drm/nouveau/nva3_pm.c +++ b/drivers/gpu/drm/nouveau/nva3_pm.c @@ -274,9 +274,12 @@ void * nva3_pm_clocks_pre(struct drm_device *dev, struct nouveau_pm_level *perflvl) { struct nva3_pm_state *info; + struct nouveau_device *device = nouveau_dev(dev); + struct nouveau_fb *pfb = nouveau_fb(device); u8 ramcfg_cnt; int ret; + info = kzalloc(sizeof(*info), GFP_KERNEL); if (!info) return ERR_PTR(-ENOMEM); @@ -289,9 +292,11 @@ nva3_pm_clocks_pre(struct drm_device *dev, struct nouveau_pm_level *perflvl) if (ret < 0) goto out; - ret = calc_clk(dev, 0x12, 0x4000, perflvl->memory, &info->mclk); - if (ret < 0) - goto out; + if(pfb->ram.type > NV_MEM_TYPE_STOLEN) { + ret = calc_clk(dev, 0x12, 0x4000, perflvl->memory, &info->mclk); + if (ret < 0) + goto out; + } ret = calc_clk(dev, 0x20, 0x0000, perflvl->unka0, &info->unka0); if (ret < 0) -- 1.7.11.2