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 at gmail.com>
---
 drivers/gpu/drm/drm_stub.c | 26 +++++++++++++++++++++-----
 1 file changed, 21 insertions(+), 5 deletions(-)

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);
-- 
1.7.12.4.dirty

Reply via email to