Module Name:    src
Committed By:   riastradh
Date:           Sun Sep  8 16:00:22 UTC 2013

Modified Files:
        src/sys/external/bsd/drm2/dist/drm/i915 [riastradh-drm2]: i915_dma.c
            i915_drv.h i915_gem.c i915_gem_stolen.c intel_pm.c
        src/sys/external/bsd/drm2/i915drm [riastradh-drm2]: i915_gem_gtt.c

Log Message:
Fix a bunch of i915 error branches.

Some of these fixes are necessary only on NetBSD because we require
mutex_destroy, while Linux doesn't.


To generate a diff of this commit:
cvs rdiff -u -r1.1.1.1.2.25 -r1.1.1.1.2.26 \
    src/sys/external/bsd/drm2/dist/drm/i915/i915_dma.c
cvs rdiff -u -r1.1.1.1.2.15 -r1.1.1.1.2.16 \
    src/sys/external/bsd/drm2/dist/drm/i915/i915_drv.h
cvs rdiff -u -r1.1.1.1.2.10 -r1.1.1.1.2.11 \
    src/sys/external/bsd/drm2/dist/drm/i915/i915_gem.c
cvs rdiff -u -r1.1.1.1.2.2 -r1.1.1.1.2.3 \
    src/sys/external/bsd/drm2/dist/drm/i915/i915_gem_stolen.c
cvs rdiff -u -r1.1.1.1.2.5 -r1.1.1.1.2.6 \
    src/sys/external/bsd/drm2/dist/drm/i915/intel_pm.c
cvs rdiff -u -r1.1.2.2 -r1.1.2.3 \
    src/sys/external/bsd/drm2/i915drm/i915_gem_gtt.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/drm2/dist/drm/i915/i915_dma.c
diff -u src/sys/external/bsd/drm2/dist/drm/i915/i915_dma.c:1.1.1.1.2.25 src/sys/external/bsd/drm2/dist/drm/i915/i915_dma.c:1.1.1.1.2.26
--- src/sys/external/bsd/drm2/dist/drm/i915/i915_dma.c:1.1.1.1.2.25	Sun Sep  8 15:54:20 2013
+++ src/sys/external/bsd/drm2/dist/drm/i915/i915_dma.c	Sun Sep  8 16:00:22 2013
@@ -1396,6 +1396,7 @@ cleanup_gem:
 	mutex_unlock(&dev->struct_mutex);
 	i915_gem_cleanup_aliasing_ppgtt(dev);
 cleanup_gem_stolen:
+	intel_modeset_cleanup(dev);
 	i915_gem_cleanup_stolen(dev);
 cleanup_vga_switcheroo:
 #ifndef __NetBSD__		/* XXX vga */
@@ -1725,7 +1726,7 @@ int i915_driver_load(struct drm_device *
 		ret = i915_load_modeset_init(dev);
 		if (ret < 0) {
 			DRM_ERROR("failed to init modeset\n");
-			goto out_gem_unload;
+			goto out_vblank_cleanup;
 		}
 	}
 
@@ -1743,6 +1744,9 @@ int i915_driver_load(struct drm_device *
 
 	return 0;
 
+out_vblank_cleanup:
+	drm_vblank_cleanup(dev);
+
 out_gem_unload:
 	if (dev_priv->mm.inactive_shrinker.shrink)
 		unregister_shrinker(&dev_priv->mm.inactive_shrinker);
@@ -1760,6 +1764,9 @@ out_gem_unload:
 
 	intel_teardown_gmbus(dev);
 	intel_teardown_mchbar(dev);
+#ifdef __NetBSD__		/* XXX gt fini */
+	intel_gt_fini(dev);
+#endif
 	destroy_workqueue(dev_priv->wq);
 out_mtrrfree:
 #ifndef __NetBSD__		/* XXX gtt */

Index: src/sys/external/bsd/drm2/dist/drm/i915/i915_drv.h
diff -u src/sys/external/bsd/drm2/dist/drm/i915/i915_drv.h:1.1.1.1.2.15 src/sys/external/bsd/drm2/dist/drm/i915/i915_drv.h:1.1.1.1.2.16
--- src/sys/external/bsd/drm2/dist/drm/i915/i915_drv.h:1.1.1.1.2.15	Sun Sep  8 15:52:20 2013
+++ src/sys/external/bsd/drm2/dist/drm/i915/i915_drv.h	Sun Sep  8 16:00:22 2013
@@ -1360,6 +1360,9 @@ void i915_handle_error(struct drm_device
 
 extern void intel_irq_init(struct drm_device *dev);
 extern void intel_gt_init(struct drm_device *dev);
+#ifdef __NetBSD__		/* XXX gt fini */
+extern void intel_gt_fini(struct drm_device *dev);
+#endif
 extern void intel_gt_reset(struct drm_device *dev);
 
 void i915_error_state_free(struct kref *error_ref);
@@ -1625,6 +1628,9 @@ void i915_gem_init_global_gtt(struct drm
 			      unsigned long start,
 			      unsigned long mappable_end,
 			      unsigned long end);
+#ifdef __NetBSD__		/* XXX fini global gtt */
+void i915_gem_fini_global_gtt(struct drm_device *dev);
+#endif
 int i915_gem_gtt_init(struct drm_device *dev);
 void i915_gem_gtt_fini(struct drm_device *dev);
 static inline void i915_gem_chipset_flush(struct drm_device *dev)

Index: src/sys/external/bsd/drm2/dist/drm/i915/i915_gem.c
diff -u src/sys/external/bsd/drm2/dist/drm/i915/i915_gem.c:1.1.1.1.2.10 src/sys/external/bsd/drm2/dist/drm/i915/i915_gem.c:1.1.1.1.2.11
--- src/sys/external/bsd/drm2/dist/drm/i915/i915_gem.c:1.1.1.1.2.10	Sun Sep  8 15:56:02 2013
+++ src/sys/external/bsd/drm2/dist/drm/i915/i915_gem.c	Sun Sep  8 16:00:22 2013
@@ -4462,6 +4462,9 @@ int i915_gem_init(struct drm_device *dev
 
 		ret = i915_gem_init_aliasing_ppgtt(dev);
 		if (ret) {
+#ifdef __NetBSD__		/* XXX fini global gtt */
+			i915_gem_fini_global_gtt(dev);
+#endif
 			mutex_unlock(&dev->struct_mutex);
 			return ret;
 		}
@@ -4481,6 +4484,10 @@ int i915_gem_init(struct drm_device *dev
 	}
 
 	ret = i915_gem_init_hw(dev);
+#ifdef __NetBSD__		/* XXX fini global gtt */
+	if (ret)
+		i915_gem_fini_global_gtt(dev);
+#endif
 	mutex_unlock(&dev->struct_mutex);
 	if (ret) {
 		i915_gem_cleanup_aliasing_ppgtt(dev);

Index: src/sys/external/bsd/drm2/dist/drm/i915/i915_gem_stolen.c
diff -u src/sys/external/bsd/drm2/dist/drm/i915/i915_gem_stolen.c:1.1.1.1.2.2 src/sys/external/bsd/drm2/dist/drm/i915/i915_gem_stolen.c:1.1.1.1.2.3
--- src/sys/external/bsd/drm2/dist/drm/i915/i915_gem_stolen.c:1.1.1.1.2.2	Tue Jul 23 21:28:22 2013
+++ src/sys/external/bsd/drm2/dist/drm/i915/i915_gem_stolen.c	Sun Sep  8 16:00:22 2013
@@ -171,8 +171,11 @@ static void i915_cleanup_compression(str
 
 void i915_gem_cleanup_stolen(struct drm_device *dev)
 {
+	struct drm_i915_private *dev_priv = dev->dev_private;
+
 	if (I915_HAS_FBC(dev) && i915_powersave)
 		i915_cleanup_compression(dev);
+	drm_mm_takedown(&dev_priv->mm.stolen);
 }
 
 int i915_gem_init_stolen(struct drm_device *dev)

Index: src/sys/external/bsd/drm2/dist/drm/i915/intel_pm.c
diff -u src/sys/external/bsd/drm2/dist/drm/i915/intel_pm.c:1.1.1.1.2.5 src/sys/external/bsd/drm2/dist/drm/i915/intel_pm.c:1.1.1.1.2.6
--- src/sys/external/bsd/drm2/dist/drm/i915/intel_pm.c:1.1.1.1.2.5	Sun Sep  8 15:59:47 2013
+++ src/sys/external/bsd/drm2/dist/drm/i915/intel_pm.c	Sun Sep  8 16:00:22 2013
@@ -3386,6 +3386,10 @@ void intel_gpu_ips_init(struct drm_i915_
 
 void intel_gpu_ips_teardown(void)
 {
+#ifdef __NetBSD__
+	if (i915_mch_dev == NULL)
+		return;
+#endif
 	spin_lock_irq(&mchdev_lock);
 	i915_mch_dev = NULL;
 	spin_unlock_irq(&mchdev_lock);
@@ -4450,6 +4454,16 @@ void intel_gt_init(struct drm_device *de
 			  intel_gen6_powersave_work);
 }
 
+#ifdef __NetBSD__		/* XXX gt fini */
+void
+intel_gt_fini(struct drm_device *dev)
+{
+	struct drm_i915_private *dev_priv = dev->dev_private;
+
+	spin_lock_destroy(&dev_priv->gt_lock);
+}
+#endif
+
 int sandybridge_pcode_read(struct drm_i915_private *dev_priv, u8 mbox, u32 *val)
 {
 	WARN_ON(!mutex_is_locked(&dev_priv->rps.hw_lock));

Index: src/sys/external/bsd/drm2/i915drm/i915_gem_gtt.c
diff -u src/sys/external/bsd/drm2/i915drm/i915_gem_gtt.c:1.1.2.2 src/sys/external/bsd/drm2/i915drm/i915_gem_gtt.c:1.1.2.3
--- src/sys/external/bsd/drm2/i915drm/i915_gem_gtt.c:1.1.2.2	Sun Sep  8 15:57:01 2013
+++ src/sys/external/bsd/drm2/i915drm/i915_gem_gtt.c	Sun Sep  8 16:00:22 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: i915_gem_gtt.c,v 1.1.2.2 2013/09/08 15:57:01 riastradh Exp $	*/
+/*	$NetBSD: i915_gem_gtt.c,v 1.1.2.3 2013/09/08 16:00:22 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: i915_gem_gtt.c,v 1.1.2.2 2013/09/08 15:57:01 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: i915_gem_gtt.c,v 1.1.2.3 2013/09/08 16:00:22 riastradh Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -240,6 +240,14 @@ i915_gem_init_global_gtt(struct drm_devi
 	    ((end - start) >> PAGE_SHIFT));
 }
 
+void
+i915_gem_fini_global_gtt(struct drm_device *dev)
+{
+	struct drm_i915_private *const dev_priv = dev->dev_private;
+
+	drm_mm_takedown(&dev_priv->mm.gtt_space);
+}
+
 static void
 i915_gtt_color_adjust(struct drm_mm_node *node, unsigned long color,
     unsigned long *start, unsigned long *end)

Reply via email to