diff options
author | Jerome Glisse <jglisse@redhat.com> | 2009-09-14 12:29:49 -0400 |
---|---|---|
committer | Dave Airlie <airlied@redhat.com> | 2009-09-14 18:53:14 -0400 |
commit | 4aac047323e3082d0866b8ad3784236632105af4 (patch) | |
tree | af4c118e42b9ea55c961c4f5bbb02998dc2cc4fe /drivers/gpu/drm/radeon/rs400.c | |
parent | 21f9a437222e92adb3abc68584a5f04801b92739 (diff) |
drm/radeon/kms: clear confusion in GART init/deinit path
GART static one time initialization was mixed up with GART
enabling/disabling which could happen several time for instance
during suspend/resume cycles. This patch splits all GART
handling into 4 differents function. gart_init is for one
time initialization, gart_deinit is called upon module unload
to free resources allocated by gart_init, gart_enable enable
the GART and is intented to be call after first initialization
and at each resume cycle or reset cycle. Finaly gart_disable
stop the GART and is intended to be call at suspend time or
when unloading the module.
Signed-off-by: Jerome Glisse <jglisse@redhat.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'drivers/gpu/drm/radeon/rs400.c')
-rw-r--r-- | drivers/gpu/drm/radeon/rs400.c | 53 |
1 files changed, 36 insertions, 17 deletions
diff --git a/drivers/gpu/drm/radeon/rs400.c b/drivers/gpu/drm/radeon/rs400.c index e1e4ce427828..a3fbdad938c7 100644 --- a/drivers/gpu/drm/radeon/rs400.c +++ b/drivers/gpu/drm/radeon/rs400.c | |||
@@ -92,20 +92,41 @@ void rs400_gart_tlb_flush(struct radeon_device *rdev) | |||
92 | WREG32_MC(RS480_GART_CACHE_CNTRL, 0); | 92 | WREG32_MC(RS480_GART_CACHE_CNTRL, 0); |
93 | } | 93 | } |
94 | 94 | ||
95 | int rs400_gart_enable(struct radeon_device *rdev) | 95 | int rs400_gart_init(struct radeon_device *rdev) |
96 | { | 96 | { |
97 | uint32_t size_reg; | ||
98 | uint32_t tmp; | ||
99 | int r; | 97 | int r; |
100 | 98 | ||
99 | if (rdev->gart.table.ram.ptr) { | ||
100 | WARN(1, "RS400 GART already initialized.\n"); | ||
101 | return 0; | ||
102 | } | ||
103 | /* Check gart size */ | ||
104 | switch(rdev->mc.gtt_size / (1024 * 1024)) { | ||
105 | case 32: | ||
106 | case 64: | ||
107 | case 128: | ||
108 | case 256: | ||
109 | case 512: | ||
110 | case 1024: | ||
111 | case 2048: | ||
112 | break; | ||
113 | default: | ||
114 | return -EINVAL; | ||
115 | } | ||
101 | /* Initialize common gart structure */ | 116 | /* Initialize common gart structure */ |
102 | r = radeon_gart_init(rdev); | 117 | r = radeon_gart_init(rdev); |
103 | if (r) { | 118 | if (r) |
104 | return r; | 119 | return r; |
105 | } | 120 | if (rs400_debugfs_pcie_gart_info_init(rdev)) |
106 | if (rs400_debugfs_pcie_gart_info_init(rdev)) { | ||
107 | DRM_ERROR("Failed to register debugfs file for RS400 GART !\n"); | 121 | DRM_ERROR("Failed to register debugfs file for RS400 GART !\n"); |
108 | } | 122 | rdev->gart.table_size = rdev->gart.num_gpu_pages * 4; |
123 | return radeon_gart_table_ram_alloc(rdev); | ||
124 | } | ||
125 | |||
126 | int rs400_gart_enable(struct radeon_device *rdev) | ||
127 | { | ||
128 | uint32_t size_reg; | ||
129 | uint32_t tmp; | ||
109 | 130 | ||
110 | tmp = RREG32_MC(RS690_AIC_CTRL_SCRATCH); | 131 | tmp = RREG32_MC(RS690_AIC_CTRL_SCRATCH); |
111 | tmp |= RS690_DIS_OUT_OF_PCI_GART_ACCESS; | 132 | tmp |= RS690_DIS_OUT_OF_PCI_GART_ACCESS; |
@@ -136,13 +157,6 @@ int rs400_gart_enable(struct radeon_device *rdev) | |||
136 | default: | 157 | default: |
137 | return -EINVAL; | 158 | return -EINVAL; |
138 | } | 159 | } |
139 | if (rdev->gart.table.ram.ptr == NULL) { | ||
140 | rdev->gart.table_size = rdev->gart.num_gpu_pages * 4; | ||
141 | r = radeon_gart_table_ram_alloc(rdev); | ||
142 | if (r) { | ||
143 | return r; | ||
144 | } | ||
145 | } | ||
146 | /* It should be fine to program it to max value */ | 160 | /* It should be fine to program it to max value */ |
147 | if (rdev->family == CHIP_RS690 || (rdev->family == CHIP_RS740)) { | 161 | if (rdev->family == CHIP_RS690 || (rdev->family == CHIP_RS740)) { |
148 | WREG32_MC(RS690_MCCFG_AGP_BASE, 0xFFFFFFFF); | 162 | WREG32_MC(RS690_MCCFG_AGP_BASE, 0xFFFFFFFF); |
@@ -201,6 +215,13 @@ void rs400_gart_disable(struct radeon_device *rdev) | |||
201 | WREG32_MC(RS480_AGP_ADDRESS_SPACE_SIZE, 0); | 215 | WREG32_MC(RS480_AGP_ADDRESS_SPACE_SIZE, 0); |
202 | } | 216 | } |
203 | 217 | ||
218 | void rs400_gart_fini(struct radeon_device *rdev) | ||
219 | { | ||
220 | rs400_gart_disable(rdev); | ||
221 | radeon_gart_table_ram_free(rdev); | ||
222 | radeon_gart_fini(rdev); | ||
223 | } | ||
224 | |||
204 | int rs400_gart_set_page(struct radeon_device *rdev, int i, uint64_t addr) | 225 | int rs400_gart_set_page(struct radeon_device *rdev, int i, uint64_t addr) |
205 | { | 226 | { |
206 | uint32_t entry; | 227 | uint32_t entry; |
@@ -255,14 +276,12 @@ int rs400_mc_init(struct radeon_device *rdev) | |||
255 | (void)RREG32(RADEON_HOST_PATH_CNTL); | 276 | (void)RREG32(RADEON_HOST_PATH_CNTL); |
256 | WREG32(RADEON_HOST_PATH_CNTL, tmp); | 277 | WREG32(RADEON_HOST_PATH_CNTL, tmp); |
257 | (void)RREG32(RADEON_HOST_PATH_CNTL); | 278 | (void)RREG32(RADEON_HOST_PATH_CNTL); |
279 | |||
258 | return 0; | 280 | return 0; |
259 | } | 281 | } |
260 | 282 | ||
261 | void rs400_mc_fini(struct radeon_device *rdev) | 283 | void rs400_mc_fini(struct radeon_device *rdev) |
262 | { | 284 | { |
263 | rs400_gart_disable(rdev); | ||
264 | radeon_gart_table_ram_free(rdev); | ||
265 | radeon_gart_fini(rdev); | ||
266 | } | 285 | } |
267 | 286 | ||
268 | 287 | ||