aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorJerome Glisse <jglisse@redhat.com>2009-12-11 15:18:34 -0500
committerDave Airlie <airlied@redhat.com>2009-12-22 20:14:05 -0500
commit3642133816f9f25065e3ca310f0720574bcdcc52 (patch)
tree08c9bcec6592d8a8cfe194c5c32bf392c18f7848 /drivers
parent0a0c7596c643239e8d4c3eaaba43b74a96f2411e (diff)
drm/radeon/kms: Check module arguments to be valid V2
This patch add a function which check module argument to be valid. On invalid argument it prints a warning and setback the default value. V2: Allow 0 for vram limit & agp mode which are the default value Signed-off-by: Jerome Glisse <jglisse@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/gpu/drm/radeon/radeon_device.c73
1 files changed, 68 insertions, 5 deletions
diff --git a/drivers/gpu/drm/radeon/radeon_device.c b/drivers/gpu/drm/radeon/radeon_device.c
index 14df3ad64f94..7c6848096bcd 100644
--- a/drivers/gpu/drm/radeon/radeon_device.c
+++ b/drivers/gpu/drm/radeon/radeon_device.c
@@ -546,9 +546,72 @@ void radeon_agp_disable(struct radeon_device *rdev)
546 } 546 }
547} 547}
548 548
549/* 549void radeon_check_arguments(struct radeon_device *rdev)
550 * Radeon device. 550{
551 */ 551 /* vramlimit must be a power of two */
552 switch (radeon_vram_limit) {
553 case 0:
554 case 4:
555 case 8:
556 case 16:
557 case 32:
558 case 64:
559 case 128:
560 case 256:
561 case 512:
562 case 1024:
563 case 2048:
564 case 4096:
565 break;
566 default:
567 dev_warn(rdev->dev, "vram limit (%d) must be a power of 2\n",
568 radeon_vram_limit);
569 radeon_vram_limit = 0;
570 break;
571 }
572 radeon_vram_limit = radeon_vram_limit << 20;
573 /* gtt size must be power of two and greater or equal to 32M */
574 switch (radeon_gart_size) {
575 case 4:
576 case 8:
577 case 16:
578 dev_warn(rdev->dev, "gart size (%d) too small forcing to 512M\n",
579 radeon_gart_size);
580 radeon_gart_size = 512;
581 break;
582 case 32:
583 case 64:
584 case 128:
585 case 256:
586 case 512:
587 case 1024:
588 case 2048:
589 case 4096:
590 break;
591 default:
592 dev_warn(rdev->dev, "gart size (%d) must be a power of 2\n",
593 radeon_gart_size);
594 radeon_gart_size = 512;
595 break;
596 }
597 rdev->mc.gtt_size = radeon_gart_size * 1024 * 1024;
598 /* AGP mode can only be -1, 1, 2, 4, 8 */
599 switch (radeon_agpmode) {
600 case -1:
601 case 0:
602 case 1:
603 case 2:
604 case 4:
605 case 8:
606 break;
607 default:
608 dev_warn(rdev->dev, "invalid AGP mode %d (valid mode: "
609 "-1, 0, 1, 2, 4, 8)\n", radeon_agpmode);
610 radeon_agpmode = 0;
611 break;
612 }
613}
614
552int radeon_device_init(struct radeon_device *rdev, 615int radeon_device_init(struct radeon_device *rdev,
553 struct drm_device *ddev, 616 struct drm_device *ddev,
554 struct pci_dev *pdev, 617 struct pci_dev *pdev,
@@ -587,9 +650,9 @@ int radeon_device_init(struct radeon_device *rdev,
587 650
588 /* Set asic functions */ 651 /* Set asic functions */
589 r = radeon_asic_init(rdev); 652 r = radeon_asic_init(rdev);
590 if (r) { 653 if (r)
591 return r; 654 return r;
592 } 655 radeon_check_arguments(rdev);
593 656
594 if (rdev->flags & RADEON_IS_AGP && radeon_agpmode == -1) { 657 if (rdev->flags & RADEON_IS_AGP && radeon_agpmode == -1) {
595 radeon_agp_disable(rdev); 658 radeon_agp_disable(rdev);