diff mbox

[5/5] drm:drm_stub: rewrite error handle code for drm_fill_in_dev

Message ID 20131030231228.GC5719@udknight (mailing list archive)
State New, archived
Headers show

Commit Message

wang yanqing Oct. 30, 2013, 11:12 p.m. UTC
Rewrite error handle code in a more rational and
normal way, it bring us benefit that we could drop
call to drm_lastclose which do "too much" cleanup work
for drm_fill_in_dev.

Signed-off-by: Wang YanQing <udknight@gmail.com>
---
 drivers/gpu/drm/drm_stub.c | 26 +++++++++++++++++++++-----
 1 file changed, 21 insertions(+), 5 deletions(-)
diff mbox

Patch

diff --git a/drivers/gpu/drm/drm_stub.c b/drivers/gpu/drm/drm_stub.c
index 3f3b167..6c5f65f 100644
--- a/drivers/gpu/drm/drm_stub.c
+++ b/drivers/gpu/drm/drm_stub.c
@@ -316,7 +316,7 @@  int drm_fill_in_dev(struct drm_device *dev,
 	if (dev->driver->bus->agp_init) {
 		retcode = dev->driver->bus->agp_init(dev);
 		if (retcode)
-			goto error_out_unreg;
+			goto err_g1;
 	}
 
 
@@ -324,7 +324,7 @@  int drm_fill_in_dev(struct drm_device *dev,
 	retcode = drm_ctxbitmap_init(dev);
 	if (retcode) {
 		DRM_ERROR("Cannot allocate memory for context bitmap.\n");
-		goto error_out_unreg;
+		goto err_g2;
 	}
 
 	if (driver->driver_features & DRIVER_GEM) {
@@ -332,14 +332,30 @@  int drm_fill_in_dev(struct drm_device *dev,
 		if (retcode) {
 			DRM_ERROR("Cannot initialize graphics execution "
 				  "manager (GEM)\n");
-			goto error_out_unreg;
+			goto err_g3;
 		}
 	}
 
 	return 0;
 
-      error_out_unreg:
-	drm_lastclose(dev);
+err_g3:
+	drm_ctxbitmap_cleanup(dev);
+err_g2:
+	if (drm_core_has_MTRR(dev) && drm_core_has_AGP(dev) &&
+		dev->agp && dev->agp->agp_mtrr >= 0) {
+		int retval;
+		retval = mtrr_del(dev->agp->agp_mtrr,
+				dev->agp->agp_info.aper_base,
+				dev->agp->agp_info.aper_size * 1024 * 1024);
+		DRM_DEBUG("mtrr_del=%d\n", retval);
+	}
+
+	if (drm_core_has_AGP(dev) && dev->agp) {
+		kfree(dev->agp);
+		dev->agp = NULL;
+	}
+err_g1:
+	drm_ht_remove(&dev->map_hash);
 	return retcode;
 }
 EXPORT_SYMBOL(drm_fill_in_dev);