From patchwork Mon Jul 4 09:41:10 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wolfram Sang X-Patchwork-Id: 941992 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by demeter2.kernel.org (8.14.4/8.14.4) with ESMTP id p649fgFl024793 for ; Mon, 4 Jul 2011 09:42:02 GMT Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id DA17D9F038 for ; Mon, 4 Jul 2011 02:41:35 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [92.198.50.35]) by gabe.freedesktop.org (Postfix) with ESMTP id C65D69F02A for ; Mon, 4 Jul 2011 02:41:21 -0700 (PDT) Received: from katana.hi.pengutronix.de ([2001:6f8:1178:2:221:70ff:fe71:1890] helo=pengutronix.de) by metis.ext.pengutronix.de with esmtp (Exim 4.72) (envelope-from ) id 1Qdfea-0002LD-Tc; Mon, 04 Jul 2011 11:41:20 +0200 From: Wolfram Sang To: dri-devel@lists.freedesktop.org Subject: [PATCH V2 RESEND] drm/i915: gracefully bail out when init_clock_gating-pointer is not set Date: Mon, 4 Jul 2011 11:41:10 +0200 Message-Id: <1309772470-2618-1-git-send-email-w.sang@pengutronix.de> X-Mailer: git-send-email 1.7.5.4 X-SA-Exim-Connect-IP: 2001:6f8:1178:2:221:70ff:fe71:1890 X-SA-Exim-Mail-From: w.sang@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: dri-devel@lists.freedesktop.org Cc: Wolfram Sang X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 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 X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Mon, 04 Jul 2011 09:42:02 +0000 (UTC) Commit 6067aa (drm/i915: split clock gating init into per-chipset functions) introduces an init_clock_gating-pointer. There is one case, however, where it does not get set, so that caused an OOPS. Change the code to return -ENODEV in this case and propagate it to the upper layers. Signed-off-by: Wolfram Sang Reviewed-by: Jesse Barnes Cc: Keith Packard --- Based on v3.0-rc5. Change since V1: changed error-message per Chris' suggestion. Note: used %04x instead of %lx to fix compile warning. drivers/gpu/drm/i915/i915_dma.c | 4 +++- drivers/gpu/drm/i915/i915_drv.h | 2 +- drivers/gpu/drm/i915/intel_display.c | 20 ++++++++++++++------ 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c index 2b79588..2ada4e7 100644 --- a/drivers/gpu/drm/i915/i915_dma.c +++ b/drivers/gpu/drm/i915/i915_dma.c @@ -1258,7 +1258,9 @@ static int i915_load_modeset_init(struct drm_device *dev) if (IS_GEN3(dev) && (I915_READ(ECOSKPD) & ECO_FLIP_DONE)) dev_priv->flip_pending_is_done = true; - intel_modeset_init(dev); + ret = intel_modeset_init(dev); + if (ret) + goto cleanup_vga_switcheroo; ret = i915_load_gem_init(dev); if (ret) diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h index f63ee16..90ce405 100644 --- a/drivers/gpu/drm/i915/i915_drv.h +++ b/drivers/gpu/drm/i915/i915_drv.h @@ -1303,7 +1303,7 @@ static inline void intel_unregister_dsm_handler(void) { return; } #endif /* CONFIG_ACPI */ /* modesetting */ -extern void intel_modeset_init(struct drm_device *dev); +extern int intel_modeset_init(struct drm_device *dev); extern void intel_modeset_gem_init(struct drm_device *dev); extern void intel_modeset_cleanup(struct drm_device *dev); extern int intel_modeset_vga_set_state(struct drm_device *dev, bool state); diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c index aa43e7b..98b9180 100644 --- a/drivers/gpu/drm/i915/intel_display.c +++ b/drivers/gpu/drm/i915/intel_display.c @@ -7517,7 +7517,7 @@ void intel_init_clock_gating(struct drm_device *dev) } /* Set up chip specific display functions */ -static void intel_init_display(struct drm_device *dev) +static int intel_init_display(struct drm_device *dev) { struct drm_i915_private *dev_priv = dev->dev_private; @@ -7609,8 +7609,10 @@ static void intel_init_display(struct drm_device *dev) } dev_priv->display.init_clock_gating = ivybridge_init_clock_gating; - } else - dev_priv->display.update_wm = NULL; + } else { + DRM_ERROR("Unknown chipset: %04x\n", dev->pci_device); + return -ENODEV; + } } else if (IS_PINEVIEW(dev)) { if (!intel_get_cxsr_latency(IS_PINEVIEW_G(dev), dev_priv->is_ddr3, @@ -7656,6 +7658,8 @@ static void intel_init_display(struct drm_device *dev) else dev_priv->display.get_fifo_size = i830_get_fifo_size; } + + return 0; } /* @@ -7741,10 +7745,10 @@ static void i915_disable_vga(struct drm_device *dev) POSTING_READ(vga_reg); } -void intel_modeset_init(struct drm_device *dev) +int intel_modeset_init(struct drm_device *dev) { struct drm_i915_private *dev_priv = dev->dev_private; - int i; + int i, ret; drm_mode_config_init(dev); @@ -7755,7 +7759,9 @@ void intel_modeset_init(struct drm_device *dev) intel_init_quirks(dev); - intel_init_display(dev); + ret = intel_init_display(dev); + if (ret) + return ret; if (IS_GEN2(dev)) { dev->mode_config.max_width = 2048; @@ -7793,6 +7799,8 @@ void intel_modeset_init(struct drm_device *dev) INIT_WORK(&dev_priv->idle_work, intel_idle_update); setup_timer(&dev_priv->idle_timer, intel_gpu_idle_timer, (unsigned long)dev); + + return 0; } void intel_modeset_gem_init(struct drm_device *dev)