Commit cf0fe4566dcc0c5bd9b7da8c9a53e712593db118
Committed by
Dave Airlie
1 parent
eaa5fd1a66
Exists in
master
and in
7 other branches
drm/radeon/kms: cleanup structure and module if initialization fails
This would allow us to properly unload others module like TTM if initialization fails after we initiliazed TTM structure. Signed-off-by: Jerome Glisse <jglisse@redhat.com> Signed-off-by: Dave Airlie <airlied@linux.ie>
Showing 1 changed file with 20 additions and 22 deletions Side-by-side Diff
drivers/gpu/drm/radeon/radeon_kms.c
... | ... | @@ -30,10 +30,19 @@ |
30 | 30 | #include "radeon.h" |
31 | 31 | #include "radeon_drm.h" |
32 | 32 | |
33 | +int radeon_driver_unload_kms(struct drm_device *dev) | |
34 | +{ | |
35 | + struct radeon_device *rdev = dev->dev_private; | |
33 | 36 | |
34 | -/* | |
35 | - * Driver load/unload | |
36 | - */ | |
37 | + if (rdev == NULL) | |
38 | + return 0; | |
39 | + radeon_modeset_fini(rdev); | |
40 | + radeon_device_fini(rdev); | |
41 | + kfree(rdev); | |
42 | + dev->dev_private = NULL; | |
43 | + return 0; | |
44 | +} | |
45 | + | |
37 | 46 | int radeon_driver_load_kms(struct drm_device *dev, unsigned long flags) |
38 | 47 | { |
39 | 48 | struct radeon_device *rdev; |
40 | 49 | |
... | ... | @@ -62,31 +71,20 @@ |
62 | 71 | */ |
63 | 72 | r = radeon_device_init(rdev, dev, dev->pdev, flags); |
64 | 73 | if (r) { |
65 | - DRM_ERROR("Fatal error while trying to initialize radeon.\n"); | |
66 | - return r; | |
74 | + dev_err(&dev->pdev->dev, "Fatal error during GPU init\n"); | |
75 | + goto out; | |
67 | 76 | } |
68 | 77 | /* Again modeset_init should fail only on fatal error |
69 | 78 | * otherwise it should provide enough functionalities |
70 | 79 | * for shadowfb to run |
71 | 80 | */ |
72 | 81 | r = radeon_modeset_init(rdev); |
73 | - if (r) { | |
74 | - return r; | |
75 | - } | |
76 | - return 0; | |
77 | -} | |
78 | - | |
79 | -int radeon_driver_unload_kms(struct drm_device *dev) | |
80 | -{ | |
81 | - struct radeon_device *rdev = dev->dev_private; | |
82 | - | |
83 | - if (rdev == NULL) | |
84 | - return 0; | |
85 | - radeon_modeset_fini(rdev); | |
86 | - radeon_device_fini(rdev); | |
87 | - kfree(rdev); | |
88 | - dev->dev_private = NULL; | |
89 | - return 0; | |
82 | + if (r) | |
83 | + dev_err(&dev->pdev->dev, "Fatal error during modeset init\n"); | |
84 | +out: | |
85 | + if (r) | |
86 | + radeon_driver_unload_kms(dev); | |
87 | + return r; | |
90 | 88 | } |
91 | 89 | |
92 | 90 |