From patchwork Fri Nov 16 16:46:04 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maarten Lankhorst X-Patchwork-Id: 1756481 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by patchwork2.kernel.org (Postfix) with ESMTP id 65E20DF288 for ; Fri, 16 Nov 2012 16:46:17 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4310BE5DF1 for ; Fri, 16 Nov 2012 08:46:17 -0800 (PST) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from youngberry.canonical.com (youngberry.canonical.com [91.189.89.112]) by gabe.freedesktop.org (Postfix) with ESMTP id 82512E5D27; Fri, 16 Nov 2012 08:46:05 -0800 (PST) Received: from 5ed48cef.cm-7-5c.dynamic.ziggo.nl ([94.212.140.239] helo=[192.168.1.128]) by youngberry.canonical.com with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1TZP3M-0000zo-MH; Fri, 16 Nov 2012 16:46:04 +0000 Message-ID: <50A66DCC.9020809@canonical.com> Date: Fri, 16 Nov 2012 17:46:04 +0100 From: Maarten Lankhorst User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:16.0) Gecko/20121028 Thunderbird/16.0.2 MIME-Version: 1.0 To: nouveau@lists.freedesktop.org Subject: [PATCH] drm/nouveau: add voltage workaround for buggy vbioses Cc: dri-devel@lists.freedesktop.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org Errors-To: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org Required to find all performance levels on my nvc0. Signed-off-by: Maarten Lankhorst diff --git a/drivers/gpu/drm/nouveau/nouveau_perf.c b/drivers/gpu/drm/nouveau/nouveau_perf.c index 4fe883c..624cbd1 100644 --- a/drivers/gpu/drm/nouveau/nouveau_perf.c +++ b/drivers/gpu/drm/nouveau/nouveau_perf.c @@ -251,6 +251,7 @@ static void nouveau_perf_voltage(struct drm_device *dev, struct nouveau_pm_level *perflvl) { struct nouveau_drm *drm = nouveau_drm(dev); + struct nouveau_pm_voltage *volt = &nouveau_pm(dev)->voltage; struct bit_entry P; u8 *vmap; int id; @@ -287,6 +288,20 @@ nouveau_perf_voltage(struct drm_device *dev, struct nouveau_pm_level *perflvl) perflvl->volt_min = ROM32(vmap[0]); perflvl->volt_max = ROM32(vmap[4]); } + + /* Adjust for buggy bioses */ + if (!volt->step_uv || !volt->step_ofs) + return; + + if (perflvl->volt_min % volt->step_uv != volt->step_ofs) { + perflvl->volt_min -= perflvl->volt_min % volt->step_uv; + perflvl->volt_min += volt->step_ofs; + } + + if (perflvl->volt_max % volt->step_uv != volt->step_ofs) { + perflvl->volt_max -= perflvl->volt_max % volt->step_uv; + perflvl->volt_max += volt->step_ofs; + } } void diff --git a/drivers/gpu/drm/nouveau/nouveau_pm.h b/drivers/gpu/drm/nouveau/nouveau_pm.h index 73b789c..967c27c 100644 --- a/drivers/gpu/drm/nouveau/nouveau_pm.h +++ b/drivers/gpu/drm/nouveau/nouveau_pm.h @@ -40,6 +40,7 @@ struct nouveau_pm_voltage { struct nouveau_pm_voltage_level *level; int nr_level; + u16 step_uv, step_ofs; }; /* Exclusive upper limits */ diff --git a/drivers/gpu/drm/nouveau/nouveau_volt.c b/drivers/gpu/drm/nouveau/nouveau_volt.c index 9976414..c8d0c00 100644 --- a/drivers/gpu/drm/nouveau/nouveau_volt.c +++ b/drivers/gpu/drm/nouveau/nouveau_volt.c @@ -236,6 +236,9 @@ nouveau_volt_init(struct drm_device *dev) voltage->level[vid].vid = vid; volt_uv += step_uv; } + voltage->step_uv = step_uv >= 0 ? step_uv : -step_uv; + if (step_uv) + voltage->step_ofs = volt_uv % voltage->step_uv; } voltage->supported = true;