aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu
diff options
context:
space:
mode:
authorJerome Glisse <jglisse@redhat.com>2012-02-20 17:57:20 -0500
committerDave Airlie <airlied@redhat.com>2012-02-22 05:30:02 -0500
commit6b7746e8768e1c550b320d5af761f73e5aa37f76 (patch)
treead04aeca4bbc904418d21717f17689f1c0aa5bf7 /drivers/gpu
parentf0d14daa6906070ca044b86f483fdde7d81f5294 (diff)
drm/radeon/kms: properly set accel working flag and bailout when false
If accel is not working many subsystem such as the ib pool might not be initialized properly that can lead to segfault inside kernel when cs ioctl is call with non working acceleration. To avoid this make sure the accel working flag is false when an error in GPU startup happen and return EBUSY from cs ioctl if accel is not working. Signed-off-by: Jerome Glisse <jglisse@redhat.com> Reviewed-by: Alex Deucher <alexander.deucher@amd.com> Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'drivers/gpu')
-rw-r--r--drivers/gpu/drm/radeon/evergreen.c1
-rw-r--r--drivers/gpu/drm/radeon/ni.c1
-rw-r--r--drivers/gpu/drm/radeon/r100.c8
-rw-r--r--drivers/gpu/drm/radeon/r300.c8
-rw-r--r--drivers/gpu/drm/radeon/r420.c8
-rw-r--r--drivers/gpu/drm/radeon/r520.c8
-rw-r--r--drivers/gpu/drm/radeon/r600.c1
-rw-r--r--drivers/gpu/drm/radeon/radeon_cs.c4
-rw-r--r--drivers/gpu/drm/radeon/rs400.c8
-rw-r--r--drivers/gpu/drm/radeon/rs600.c8
-rw-r--r--drivers/gpu/drm/radeon/rs690.c8
-rw-r--r--drivers/gpu/drm/radeon/rv515.c8
-rw-r--r--drivers/gpu/drm/radeon/rv770.c1
13 files changed, 64 insertions, 8 deletions
diff --git a/drivers/gpu/drm/radeon/evergreen.c b/drivers/gpu/drm/radeon/evergreen.c
index 9be353b894c..f58254a3fb0 100644
--- a/drivers/gpu/drm/radeon/evergreen.c
+++ b/drivers/gpu/drm/radeon/evergreen.c
@@ -3223,6 +3223,7 @@ int evergreen_resume(struct radeon_device *rdev)
3223 r = evergreen_startup(rdev); 3223 r = evergreen_startup(rdev);
3224 if (r) { 3224 if (r) {
3225 DRM_ERROR("evergreen startup failed on resume\n"); 3225 DRM_ERROR("evergreen startup failed on resume\n");
3226 rdev->accel_working = false;
3226 return r; 3227 return r;
3227 } 3228 }
3228 3229
diff --git a/drivers/gpu/drm/radeon/ni.c b/drivers/gpu/drm/radeon/ni.c
index db09065e68f..2509c505acb 100644
--- a/drivers/gpu/drm/radeon/ni.c
+++ b/drivers/gpu/drm/radeon/ni.c
@@ -1547,6 +1547,7 @@ int cayman_resume(struct radeon_device *rdev)
1547 r = cayman_startup(rdev); 1547 r = cayman_startup(rdev);
1548 if (r) { 1548 if (r) {
1549 DRM_ERROR("cayman startup failed on resume\n"); 1549 DRM_ERROR("cayman startup failed on resume\n");
1550 rdev->accel_working = false;
1550 return r; 1551 return r;
1551 } 1552 }
1552 return r; 1553 return r;
diff --git a/drivers/gpu/drm/radeon/r100.c b/drivers/gpu/drm/radeon/r100.c
index 18cd84fae99..333cde9d4e7 100644
--- a/drivers/gpu/drm/radeon/r100.c
+++ b/drivers/gpu/drm/radeon/r100.c
@@ -3928,6 +3928,8 @@ static int r100_startup(struct radeon_device *rdev)
3928 3928
3929int r100_resume(struct radeon_device *rdev) 3929int r100_resume(struct radeon_device *rdev)
3930{ 3930{
3931 int r;
3932
3931 /* Make sur GART are not working */ 3933 /* Make sur GART are not working */
3932 if (rdev->flags & RADEON_IS_PCI) 3934 if (rdev->flags & RADEON_IS_PCI)
3933 r100_pci_gart_disable(rdev); 3935 r100_pci_gart_disable(rdev);
@@ -3947,7 +3949,11 @@ int r100_resume(struct radeon_device *rdev)
3947 radeon_surface_init(rdev); 3949 radeon_surface_init(rdev);
3948 3950
3949 rdev->accel_working = true; 3951 rdev->accel_working = true;
3950 return r100_startup(rdev); 3952 r = r100_startup(rdev);
3953 if (r) {
3954 rdev->accel_working = false;
3955 }
3956 return r;
3951} 3957}
3952 3958
3953int r100_suspend(struct radeon_device *rdev) 3959int r100_suspend(struct radeon_device *rdev)
diff --git a/drivers/gpu/drm/radeon/r300.c b/drivers/gpu/drm/radeon/r300.c
index 3fc0d29a5f3..6829638cca4 100644
--- a/drivers/gpu/drm/radeon/r300.c
+++ b/drivers/gpu/drm/radeon/r300.c
@@ -1431,6 +1431,8 @@ static int r300_startup(struct radeon_device *rdev)
1431 1431
1432int r300_resume(struct radeon_device *rdev) 1432int r300_resume(struct radeon_device *rdev)
1433{ 1433{
1434 int r;
1435
1434 /* Make sur GART are not working */ 1436 /* Make sur GART are not working */
1435 if (rdev->flags & RADEON_IS_PCIE) 1437 if (rdev->flags & RADEON_IS_PCIE)
1436 rv370_pcie_gart_disable(rdev); 1438 rv370_pcie_gart_disable(rdev);
@@ -1452,7 +1454,11 @@ int r300_resume(struct radeon_device *rdev)
1452 radeon_surface_init(rdev); 1454 radeon_surface_init(rdev);
1453 1455
1454 rdev->accel_working = true; 1456 rdev->accel_working = true;
1455 return r300_startup(rdev); 1457 r = r300_startup(rdev);
1458 if (r) {
1459 rdev->accel_working = false;
1460 }
1461 return r;
1456} 1462}
1457 1463
1458int r300_suspend(struct radeon_device *rdev) 1464int r300_suspend(struct radeon_device *rdev)
diff --git a/drivers/gpu/drm/radeon/r420.c b/drivers/gpu/drm/radeon/r420.c
index 666e28fe509..b14323053ba 100644
--- a/drivers/gpu/drm/radeon/r420.c
+++ b/drivers/gpu/drm/radeon/r420.c
@@ -291,6 +291,8 @@ static int r420_startup(struct radeon_device *rdev)
291 291
292int r420_resume(struct radeon_device *rdev) 292int r420_resume(struct radeon_device *rdev)
293{ 293{
294 int r;
295
294 /* Make sur GART are not working */ 296 /* Make sur GART are not working */
295 if (rdev->flags & RADEON_IS_PCIE) 297 if (rdev->flags & RADEON_IS_PCIE)
296 rv370_pcie_gart_disable(rdev); 298 rv370_pcie_gart_disable(rdev);
@@ -316,7 +318,11 @@ int r420_resume(struct radeon_device *rdev)
316 radeon_surface_init(rdev); 318 radeon_surface_init(rdev);
317 319
318 rdev->accel_working = true; 320 rdev->accel_working = true;
319 return r420_startup(rdev); 321 r = r420_startup(rdev);
322 if (r) {
323 rdev->accel_working = false;
324 }
325 return r;
320} 326}
321 327
322int r420_suspend(struct radeon_device *rdev) 328int r420_suspend(struct radeon_device *rdev)
diff --git a/drivers/gpu/drm/radeon/r520.c b/drivers/gpu/drm/radeon/r520.c
index 4ae1615e752..25084e824db 100644
--- a/drivers/gpu/drm/radeon/r520.c
+++ b/drivers/gpu/drm/radeon/r520.c
@@ -218,6 +218,8 @@ static int r520_startup(struct radeon_device *rdev)
218 218
219int r520_resume(struct radeon_device *rdev) 219int r520_resume(struct radeon_device *rdev)
220{ 220{
221 int r;
222
221 /* Make sur GART are not working */ 223 /* Make sur GART are not working */
222 if (rdev->flags & RADEON_IS_PCIE) 224 if (rdev->flags & RADEON_IS_PCIE)
223 rv370_pcie_gart_disable(rdev); 225 rv370_pcie_gart_disable(rdev);
@@ -237,7 +239,11 @@ int r520_resume(struct radeon_device *rdev)
237 radeon_surface_init(rdev); 239 radeon_surface_init(rdev);
238 240
239 rdev->accel_working = true; 241 rdev->accel_working = true;
240 return r520_startup(rdev); 242 r = r520_startup(rdev);
243 if (r) {
244 rdev->accel_working = false;
245 }
246 return r;
241} 247}
242 248
243int r520_init(struct radeon_device *rdev) 249int r520_init(struct radeon_device *rdev)
diff --git a/drivers/gpu/drm/radeon/r600.c b/drivers/gpu/drm/radeon/r600.c
index 4f08e5e6ee9..fbcd84803b6 100644
--- a/drivers/gpu/drm/radeon/r600.c
+++ b/drivers/gpu/drm/radeon/r600.c
@@ -2529,6 +2529,7 @@ int r600_resume(struct radeon_device *rdev)
2529 r = r600_startup(rdev); 2529 r = r600_startup(rdev);
2530 if (r) { 2530 if (r) {
2531 DRM_ERROR("r600 startup failed on resume\n"); 2531 DRM_ERROR("r600 startup failed on resume\n");
2532 rdev->accel_working = false;
2532 return r; 2533 return r;
2533 } 2534 }
2534 2535
diff --git a/drivers/gpu/drm/radeon/radeon_cs.c b/drivers/gpu/drm/radeon/radeon_cs.c
index 435a3d970ab..e64bec488ed 100644
--- a/drivers/gpu/drm/radeon/radeon_cs.c
+++ b/drivers/gpu/drm/radeon/radeon_cs.c
@@ -453,6 +453,10 @@ int radeon_cs_ioctl(struct drm_device *dev, void *data, struct drm_file *filp)
453 int r; 453 int r;
454 454
455 radeon_mutex_lock(&rdev->cs_mutex); 455 radeon_mutex_lock(&rdev->cs_mutex);
456 if (!rdev->accel_working) {
457 radeon_mutex_unlock(&rdev->cs_mutex);
458 return -EBUSY;
459 }
456 /* initialize parser */ 460 /* initialize parser */
457 memset(&parser, 0, sizeof(struct radeon_cs_parser)); 461 memset(&parser, 0, sizeof(struct radeon_cs_parser));
458 parser.filp = filp; 462 parser.filp = filp;
diff --git a/drivers/gpu/drm/radeon/rs400.c b/drivers/gpu/drm/radeon/rs400.c
index b0ce84a20a6..866a05be75f 100644
--- a/drivers/gpu/drm/radeon/rs400.c
+++ b/drivers/gpu/drm/radeon/rs400.c
@@ -442,6 +442,8 @@ static int rs400_startup(struct radeon_device *rdev)
442 442
443int rs400_resume(struct radeon_device *rdev) 443int rs400_resume(struct radeon_device *rdev)
444{ 444{
445 int r;
446
445 /* Make sur GART are not working */ 447 /* Make sur GART are not working */
446 rs400_gart_disable(rdev); 448 rs400_gart_disable(rdev);
447 /* Resume clock before doing reset */ 449 /* Resume clock before doing reset */
@@ -462,7 +464,11 @@ int rs400_resume(struct radeon_device *rdev)
462 radeon_surface_init(rdev); 464 radeon_surface_init(rdev);
463 465
464 rdev->accel_working = true; 466 rdev->accel_working = true;
465 return rs400_startup(rdev); 467 r = rs400_startup(rdev);
468 if (r) {
469 rdev->accel_working = false;
470 }
471 return r;
466} 472}
467 473
468int rs400_suspend(struct radeon_device *rdev) 474int rs400_suspend(struct radeon_device *rdev)
diff --git a/drivers/gpu/drm/radeon/rs600.c b/drivers/gpu/drm/radeon/rs600.c
index c05865e5521..4fc700684dc 100644
--- a/drivers/gpu/drm/radeon/rs600.c
+++ b/drivers/gpu/drm/radeon/rs600.c
@@ -876,6 +876,8 @@ static int rs600_startup(struct radeon_device *rdev)
876 876
877int rs600_resume(struct radeon_device *rdev) 877int rs600_resume(struct radeon_device *rdev)
878{ 878{
879 int r;
880
879 /* Make sur GART are not working */ 881 /* Make sur GART are not working */
880 rs600_gart_disable(rdev); 882 rs600_gart_disable(rdev);
881 /* Resume clock before doing reset */ 883 /* Resume clock before doing reset */
@@ -894,7 +896,11 @@ int rs600_resume(struct radeon_device *rdev)
894 radeon_surface_init(rdev); 896 radeon_surface_init(rdev);
895 897
896 rdev->accel_working = true; 898 rdev->accel_working = true;
897 return rs600_startup(rdev); 899 r = rs600_startup(rdev);
900 if (r) {
901 rdev->accel_working = false;
902 }
903 return r;
898} 904}
899 905
900int rs600_suspend(struct radeon_device *rdev) 906int rs600_suspend(struct radeon_device *rdev)
diff --git a/drivers/gpu/drm/radeon/rs690.c b/drivers/gpu/drm/radeon/rs690.c
index 4f24a0fa8c8..f68dff2fadc 100644
--- a/drivers/gpu/drm/radeon/rs690.c
+++ b/drivers/gpu/drm/radeon/rs690.c
@@ -659,6 +659,8 @@ static int rs690_startup(struct radeon_device *rdev)
659 659
660int rs690_resume(struct radeon_device *rdev) 660int rs690_resume(struct radeon_device *rdev)
661{ 661{
662 int r;
663
662 /* Make sur GART are not working */ 664 /* Make sur GART are not working */
663 rs400_gart_disable(rdev); 665 rs400_gart_disable(rdev);
664 /* Resume clock before doing reset */ 666 /* Resume clock before doing reset */
@@ -677,7 +679,11 @@ int rs690_resume(struct radeon_device *rdev)
677 radeon_surface_init(rdev); 679 radeon_surface_init(rdev);
678 680
679 rdev->accel_working = true; 681 rdev->accel_working = true;
680 return rs690_startup(rdev); 682 r = rs690_startup(rdev);
683 if (r) {
684 rdev->accel_working = false;
685 }
686 return r;
681} 687}
682 688
683int rs690_suspend(struct radeon_device *rdev) 689int rs690_suspend(struct radeon_device *rdev)
diff --git a/drivers/gpu/drm/radeon/rv515.c b/drivers/gpu/drm/radeon/rv515.c
index 880637fd194..959bf4483be 100644
--- a/drivers/gpu/drm/radeon/rv515.c
+++ b/drivers/gpu/drm/radeon/rv515.c
@@ -424,6 +424,8 @@ static int rv515_startup(struct radeon_device *rdev)
424 424
425int rv515_resume(struct radeon_device *rdev) 425int rv515_resume(struct radeon_device *rdev)
426{ 426{
427 int r;
428
427 /* Make sur GART are not working */ 429 /* Make sur GART are not working */
428 if (rdev->flags & RADEON_IS_PCIE) 430 if (rdev->flags & RADEON_IS_PCIE)
429 rv370_pcie_gart_disable(rdev); 431 rv370_pcie_gart_disable(rdev);
@@ -443,7 +445,11 @@ int rv515_resume(struct radeon_device *rdev)
443 radeon_surface_init(rdev); 445 radeon_surface_init(rdev);
444 446
445 rdev->accel_working = true; 447 rdev->accel_working = true;
446 return rv515_startup(rdev); 448 r = rv515_startup(rdev);
449 if (r) {
450 rdev->accel_working = false;
451 }
452 return r;
447} 453}
448 454
449int rv515_suspend(struct radeon_device *rdev) 455int rv515_suspend(struct radeon_device *rdev)
diff --git a/drivers/gpu/drm/radeon/rv770.c b/drivers/gpu/drm/radeon/rv770.c
index a1668b659dd..c049c0c5184 100644
--- a/drivers/gpu/drm/radeon/rv770.c
+++ b/drivers/gpu/drm/radeon/rv770.c
@@ -1139,6 +1139,7 @@ int rv770_resume(struct radeon_device *rdev)
1139 r = rv770_startup(rdev); 1139 r = rv770_startup(rdev);
1140 if (r) { 1140 if (r) {
1141 DRM_ERROR("r600 startup failed on resume\n"); 1141 DRM_ERROR("r600 startup failed on resume\n");
1142 rdev->accel_working = false;
1142 return r; 1143 return r;
1143 } 1144 }
1144 1145