intel-agp: introduce IS_I915 and do some cleanups..

Add a new IS_I915 and also do some checkpatch whitespace cleanups.

Signed-off-by: Dave Airlie <airlied@linux.ie>

+57 -61
+57 -61
drivers/char/agp/intel-agp.c
··· 35 #define PCI_DEVICE_ID_INTEL_IGD_HB 0x2A40 36 #define PCI_DEVICE_ID_INTEL_IGD_IG 0x2A42 37 38 #define IS_I965 (agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82946GZ_HB || \ 39 - agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82G35_HB || \ 40 - agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82965Q_HB || \ 41 - agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82965G_HB || \ 42 - agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82965GM_HB || \ 43 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82965GME_HB || \ 44 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_IGD_HB) 45 ··· 224 /* Exists to support ARGB cursors */ 225 static void *i8xx_alloc_pages(void) 226 { 227 - struct page * page; 228 229 page = alloc_pages(GFP_KERNEL | GFP_DMA32, 2); 230 if (page == NULL) ··· 453 static const int ddt[4] = { 0, 16, 32, 64 }; 454 int size; /* reserved space (in kb) at the top of stolen memory */ 455 456 - pci_read_config_word(agp_bridge->dev,I830_GMCH_CTRL,&gmch_ctrl); 457 458 if (IS_I965) { 459 u32 pgetbl_ctl; ··· 552 break; 553 case I915_GMCH_GMS_STOLEN_48M: 554 /* Check it's really I915G */ 555 - if (agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_E7221_HB || 556 - agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82915G_HB || 557 - agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82915GM_HB || 558 - agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82945G_HB || 559 - agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82945GM_HB || 560 - agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82945GME_HB || 561 - IS_I965 || IS_G33) 562 gtt_entries = MB(48) - KB(size); 563 else 564 gtt_entries = 0; 565 break; 566 case I915_GMCH_GMS_STOLEN_64M: 567 /* Check it's really I915G */ 568 - if (agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_E7221_HB || 569 - agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82915G_HB || 570 - agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82915GM_HB || 571 - agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82945G_HB || 572 - agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82945GM_HB || 573 - agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82945GME_HB || 574 - IS_I965 || IS_G33) 575 gtt_entries = MB(64) - KB(size); 576 else 577 gtt_entries = 0; ··· 610 return; 611 612 intel_private.i8xx_page = alloc_page(GFP_KERNEL | __GFP_ZERO | GFP_DMA32); 613 - if (!intel_private.i8xx_page) { 614 return; 615 - } 616 617 /* make page uncached */ 618 map_page_into_agp(intel_private.i8xx_page); ··· 627 unsigned int *pg = intel_private.i8xx_flush_page; 628 int i; 629 630 - for (i = 0; i < 256; i+=2) 631 *(pg + i) = i; 632 - 633 wmb(); 634 } 635 ··· 648 num_entries = size->num_entries; 649 agp_bridge->gatt_table_real = NULL; 650 651 - pci_read_config_dword(intel_private.pcidev,I810_MMADDR,&temp); 652 temp &= 0xfff80000; 653 654 - intel_private.registers = ioremap(temp,128 * 4096); 655 if (!intel_private.registers) 656 return -ENOMEM; 657 ··· 691 return values[0].size; 692 } 693 694 - pci_read_config_word(agp_bridge->dev,I830_GMCH_CTRL,&gmch_ctrl); 695 696 if ((gmch_ctrl & I830_GMCH_MEM_MASK) == I830_GMCH_MEM_128M) { 697 agp_bridge->previous_size = agp_bridge->current_size = (void *) values; ··· 715 716 current_size = A_SIZE_FIX(agp_bridge->current_size); 717 718 - pci_read_config_dword(intel_private.pcidev,I810_GMADDR,&temp); 719 agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK); 720 721 - pci_read_config_word(agp_bridge->dev,I830_GMCH_CTRL,&gmch_ctrl); 722 gmch_ctrl |= I830_GMCH_ENABLED; 723 - pci_write_config_word(agp_bridge->dev,I830_GMCH_CTRL,gmch_ctrl); 724 725 writel(agp_bridge->gatt_bus_addr|I810_PGETBL_ENABLED, intel_private.registers+I810_PGETBL_CTL); 726 readl(intel_private.registers+I810_PGETBL_CTL); /* PCI Posting. */ ··· 743 iounmap(intel_private.registers); 744 } 745 746 - static int intel_i830_insert_entries(struct agp_memory *mem,off_t pg_start, int type) 747 { 748 - int i,j,num_entries; 749 void *temp; 750 int ret = -EINVAL; 751 int mask_type; ··· 758 num_entries = A_SIZE_FIX(temp)->num_entries; 759 760 if (pg_start < intel_private.gtt_entries) { 761 - printk (KERN_DEBUG PFX "pg_start == 0x%.8lx,intel_private.gtt_entries == 0x%.8x\n", 762 - pg_start,intel_private.gtt_entries); 763 764 - printk (KERN_INFO PFX "Trying to insert into local/stolen memory\n"); 765 goto out_err; 766 } 767 ··· 799 return ret; 800 } 801 802 - static int intel_i830_remove_entries(struct agp_memory *mem,off_t pg_start, 803 - int type) 804 { 805 int i; 806 ··· 808 return 0; 809 810 if (pg_start < intel_private.gtt_entries) { 811 - printk (KERN_INFO PFX "Trying to disable local/stolen memory\n"); 812 return -EINVAL; 813 } 814 ··· 821 return 0; 822 } 823 824 - static struct agp_memory *intel_i830_alloc_by_type(size_t pg_count,int type) 825 { 826 if (type == AGP_PHYS_MEMORY) 827 return alloc_agpphysmem_i8xx(pg_count, type); ··· 880 pci_write_config_dword(agp_bridge->dev, I965_IFPADDR, (intel_private.ifp_resource.start & 0xffffffff) | 0x1); 881 } else { 882 u64 l64; 883 - 884 temp_lo &= ~0x1; 885 l64 = ((u64)temp_hi << 32) | temp_lo; 886 ··· 914 if (intel_private.ifp_resource.start) { 915 intel_private.i9xx_flush_page = ioremap_nocache(intel_private.ifp_resource.start, PAGE_SIZE); 916 if (!intel_private.i9xx_flush_page) 917 - printk("unable to ioremap flush page - no chipset flushing"); 918 } 919 } 920 ··· 931 932 agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK); 933 934 - pci_read_config_word(agp_bridge->dev,I830_GMCH_CTRL,&gmch_ctrl); 935 gmch_ctrl |= I830_GMCH_ENABLED; 936 - pci_write_config_word(agp_bridge->dev,I830_GMCH_CTRL,gmch_ctrl); 937 938 writel(agp_bridge->gatt_bus_addr|I810_PGETBL_ENABLED, intel_private.registers+I810_PGETBL_CTL); 939 readl(intel_private.registers+I810_PGETBL_CTL); /* PCI Posting. */ ··· 948 global_cache_flush(); 949 950 intel_i9xx_setup_flush(); 951 - 952 return 0; 953 } 954 ··· 970 writel(1, intel_private.i9xx_flush_page); 971 } 972 973 - static int intel_i915_insert_entries(struct agp_memory *mem,off_t pg_start, 974 - int type) 975 { 976 - int i,j,num_entries; 977 void *temp; 978 int ret = -EINVAL; 979 int mask_type; ··· 985 num_entries = A_SIZE_FIX(temp)->num_entries; 986 987 if (pg_start < intel_private.gtt_entries) { 988 - printk (KERN_DEBUG PFX "pg_start == 0x%.8lx,intel_private.gtt_entries == 0x%.8x\n", 989 - pg_start,intel_private.gtt_entries); 990 991 - printk (KERN_INFO PFX "Trying to insert into local/stolen memory\n"); 992 goto out_err; 993 } 994 ··· 1026 return ret; 1027 } 1028 1029 - static int intel_i915_remove_entries(struct agp_memory *mem,off_t pg_start, 1030 - int type) 1031 { 1032 int i; 1033 ··· 1035 return 0; 1036 1037 if (pg_start < intel_private.gtt_entries) { 1038 - printk (KERN_INFO PFX "Trying to disable local/stolen memory\n"); 1039 return -EINVAL; 1040 } 1041 1042 - for (i = pg_start; i < (mem->page_count + pg_start); i++) { 1043 writel(agp_bridge->scratch_page, intel_private.gtt+i); 1044 - } 1045 readl(intel_private.gtt+i-1); 1046 1047 agp_bridge->driver->tlb_flush(mem); ··· 1088 agp_bridge->gatt_table_real = NULL; 1089 1090 pci_read_config_dword(intel_private.pcidev, I915_MMADDR, &temp); 1091 - pci_read_config_dword(intel_private.pcidev, I915_PTEADDR,&temp2); 1092 1093 if (IS_G33) 1094 gtt_map_size = 1024 * 1024; /* 1M on G33 */ ··· 1098 1099 temp &= 0xfff80000; 1100 1101 - intel_private.registers = ioremap(temp,128 * 4096); 1102 if (!intel_private.registers) { 1103 iounmap(intel_private.gtt); 1104 return -ENOMEM; ··· 1325 /* the Intel 815 chipset spec. says that bits 29-31 in the 1326 * ATTBASE register are reserved -> try not to write them */ 1327 if (agp_bridge->gatt_bus_addr & INTEL_815_ATTBASE_MASK) { 1328 - printk (KERN_EMERG PFX "gatt bus addr too high"); 1329 return -EINVAL; 1330 } 1331 ··· 1982 gmch_device = pci_get_device(PCI_VENDOR_ID_INTEL, device, NULL); 1983 if (gmch_device && PCI_FUNC(gmch_device->devfn) != 0) { 1984 gmch_device = pci_get_device(PCI_VENDOR_ID_INTEL, 1985 - device, gmch_device); 1986 } 1987 1988 if (!gmch_device) ··· 2104 if (intel_agp_chipsets[i].name == NULL) { 2105 if (cap_ptr) 2106 printk(KERN_WARNING PFX "Unsupported Intel chipset" 2107 - "(device id: %04x)\n", pdev->device); 2108 agp_put_bridge(bridge); 2109 return -ENODEV; 2110 } ··· 2117 intel_agp_chipsets[i].gmch_chip_id); 2118 agp_put_bridge(bridge); 2119 return -ENODEV; 2120 - } 2121 2122 bridge->dev = pdev; 2123 bridge->capndx = cap_ptr;
··· 35 #define PCI_DEVICE_ID_INTEL_IGD_HB 0x2A40 36 #define PCI_DEVICE_ID_INTEL_IGD_IG 0x2A42 37 38 + /* cover 915 and 945 variants */ 39 + #define IS_I915 (agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_E7221_HB || \ 40 + agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82915G_HB || \ 41 + agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82915GM_HB || \ 42 + agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82945G_HB || \ 43 + agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82945GM_HB || \ 44 + agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82945GME_HB) 45 + 46 #define IS_I965 (agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82946GZ_HB || \ 47 + agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82G35_HB || \ 48 + agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82965Q_HB || \ 49 + agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82965G_HB || \ 50 + agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82965GM_HB || \ 51 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82965GME_HB || \ 52 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_IGD_HB) 53 ··· 216 /* Exists to support ARGB cursors */ 217 static void *i8xx_alloc_pages(void) 218 { 219 + struct page *page; 220 221 page = alloc_pages(GFP_KERNEL | GFP_DMA32, 2); 222 if (page == NULL) ··· 445 static const int ddt[4] = { 0, 16, 32, 64 }; 446 int size; /* reserved space (in kb) at the top of stolen memory */ 447 448 + pci_read_config_word(agp_bridge->dev, I830_GMCH_CTRL, &gmch_ctrl); 449 450 if (IS_I965) { 451 u32 pgetbl_ctl; ··· 544 break; 545 case I915_GMCH_GMS_STOLEN_48M: 546 /* Check it's really I915G */ 547 + if (IS_I915 || IS_I965 || IS_G33) 548 gtt_entries = MB(48) - KB(size); 549 else 550 gtt_entries = 0; 551 break; 552 case I915_GMCH_GMS_STOLEN_64M: 553 /* Check it's really I915G */ 554 + if (IS_I915 || IS_I965 || IS_G33) 555 gtt_entries = MB(64) - KB(size); 556 else 557 gtt_entries = 0; ··· 614 return; 615 616 intel_private.i8xx_page = alloc_page(GFP_KERNEL | __GFP_ZERO | GFP_DMA32); 617 + if (!intel_private.i8xx_page) 618 return; 619 620 /* make page uncached */ 621 map_page_into_agp(intel_private.i8xx_page); ··· 632 unsigned int *pg = intel_private.i8xx_flush_page; 633 int i; 634 635 + for (i = 0; i < 256; i += 2) 636 *(pg + i) = i; 637 + 638 wmb(); 639 } 640 ··· 653 num_entries = size->num_entries; 654 agp_bridge->gatt_table_real = NULL; 655 656 + pci_read_config_dword(intel_private.pcidev, I810_MMADDR, &temp); 657 temp &= 0xfff80000; 658 659 + intel_private.registers = ioremap(temp, 128 * 4096); 660 if (!intel_private.registers) 661 return -ENOMEM; 662 ··· 696 return values[0].size; 697 } 698 699 + pci_read_config_word(agp_bridge->dev, I830_GMCH_CTRL, &gmch_ctrl); 700 701 if ((gmch_ctrl & I830_GMCH_MEM_MASK) == I830_GMCH_MEM_128M) { 702 agp_bridge->previous_size = agp_bridge->current_size = (void *) values; ··· 720 721 current_size = A_SIZE_FIX(agp_bridge->current_size); 722 723 + pci_read_config_dword(intel_private.pcidev, I810_GMADDR, &temp); 724 agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK); 725 726 + pci_read_config_word(agp_bridge->dev, I830_GMCH_CTRL, &gmch_ctrl); 727 gmch_ctrl |= I830_GMCH_ENABLED; 728 + pci_write_config_word(agp_bridge->dev, I830_GMCH_CTRL, gmch_ctrl); 729 730 writel(agp_bridge->gatt_bus_addr|I810_PGETBL_ENABLED, intel_private.registers+I810_PGETBL_CTL); 731 readl(intel_private.registers+I810_PGETBL_CTL); /* PCI Posting. */ ··· 748 iounmap(intel_private.registers); 749 } 750 751 + static int intel_i830_insert_entries(struct agp_memory *mem, off_t pg_start, 752 + int type) 753 { 754 + int i, j, num_entries; 755 void *temp; 756 int ret = -EINVAL; 757 int mask_type; ··· 762 num_entries = A_SIZE_FIX(temp)->num_entries; 763 764 if (pg_start < intel_private.gtt_entries) { 765 + printk(KERN_DEBUG PFX "pg_start == 0x%.8lx,intel_private.gtt_entries == 0x%.8x\n", 766 + pg_start, intel_private.gtt_entries); 767 768 + printk(KERN_INFO PFX "Trying to insert into local/stolen memory\n"); 769 goto out_err; 770 } 771 ··· 803 return ret; 804 } 805 806 + static int intel_i830_remove_entries(struct agp_memory *mem, off_t pg_start, 807 + int type) 808 { 809 int i; 810 ··· 812 return 0; 813 814 if (pg_start < intel_private.gtt_entries) { 815 + printk(KERN_INFO PFX "Trying to disable local/stolen memory\n"); 816 return -EINVAL; 817 } 818 ··· 825 return 0; 826 } 827 828 + static struct agp_memory *intel_i830_alloc_by_type(size_t pg_count, int type) 829 { 830 if (type == AGP_PHYS_MEMORY) 831 return alloc_agpphysmem_i8xx(pg_count, type); ··· 884 pci_write_config_dword(agp_bridge->dev, I965_IFPADDR, (intel_private.ifp_resource.start & 0xffffffff) | 0x1); 885 } else { 886 u64 l64; 887 + 888 temp_lo &= ~0x1; 889 l64 = ((u64)temp_hi << 32) | temp_lo; 890 ··· 918 if (intel_private.ifp_resource.start) { 919 intel_private.i9xx_flush_page = ioremap_nocache(intel_private.ifp_resource.start, PAGE_SIZE); 920 if (!intel_private.i9xx_flush_page) 921 + printk(KERN_INFO "unable to ioremap flush page - no chipset flushing"); 922 } 923 } 924 ··· 935 936 agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK); 937 938 + pci_read_config_word(agp_bridge->dev, I830_GMCH_CTRL, &gmch_ctrl); 939 gmch_ctrl |= I830_GMCH_ENABLED; 940 + pci_write_config_word(agp_bridge->dev, I830_GMCH_CTRL, gmch_ctrl); 941 942 writel(agp_bridge->gatt_bus_addr|I810_PGETBL_ENABLED, intel_private.registers+I810_PGETBL_CTL); 943 readl(intel_private.registers+I810_PGETBL_CTL); /* PCI Posting. */ ··· 952 global_cache_flush(); 953 954 intel_i9xx_setup_flush(); 955 + 956 return 0; 957 } 958 ··· 974 writel(1, intel_private.i9xx_flush_page); 975 } 976 977 + static int intel_i915_insert_entries(struct agp_memory *mem, off_t pg_start, 978 + int type) 979 { 980 + int i, j, num_entries; 981 void *temp; 982 int ret = -EINVAL; 983 int mask_type; ··· 989 num_entries = A_SIZE_FIX(temp)->num_entries; 990 991 if (pg_start < intel_private.gtt_entries) { 992 + printk(KERN_DEBUG PFX "pg_start == 0x%.8lx,intel_private.gtt_entries == 0x%.8x\n", 993 + pg_start, intel_private.gtt_entries); 994 995 + printk(KERN_INFO PFX "Trying to insert into local/stolen memory\n"); 996 goto out_err; 997 } 998 ··· 1030 return ret; 1031 } 1032 1033 + static int intel_i915_remove_entries(struct agp_memory *mem, off_t pg_start, 1034 + int type) 1035 { 1036 int i; 1037 ··· 1039 return 0; 1040 1041 if (pg_start < intel_private.gtt_entries) { 1042 + printk(KERN_INFO PFX "Trying to disable local/stolen memory\n"); 1043 return -EINVAL; 1044 } 1045 1046 + for (i = pg_start; i < (mem->page_count + pg_start); i++) 1047 writel(agp_bridge->scratch_page, intel_private.gtt+i); 1048 + 1049 readl(intel_private.gtt+i-1); 1050 1051 agp_bridge->driver->tlb_flush(mem); ··· 1092 agp_bridge->gatt_table_real = NULL; 1093 1094 pci_read_config_dword(intel_private.pcidev, I915_MMADDR, &temp); 1095 + pci_read_config_dword(intel_private.pcidev, I915_PTEADDR, &temp2); 1096 1097 if (IS_G33) 1098 gtt_map_size = 1024 * 1024; /* 1M on G33 */ ··· 1102 1103 temp &= 0xfff80000; 1104 1105 + intel_private.registers = ioremap(temp, 128 * 4096); 1106 if (!intel_private.registers) { 1107 iounmap(intel_private.gtt); 1108 return -ENOMEM; ··· 1329 /* the Intel 815 chipset spec. says that bits 29-31 in the 1330 * ATTBASE register are reserved -> try not to write them */ 1331 if (agp_bridge->gatt_bus_addr & INTEL_815_ATTBASE_MASK) { 1332 + printk(KERN_EMERG PFX "gatt bus addr too high"); 1333 return -EINVAL; 1334 } 1335 ··· 1986 gmch_device = pci_get_device(PCI_VENDOR_ID_INTEL, device, NULL); 1987 if (gmch_device && PCI_FUNC(gmch_device->devfn) != 0) { 1988 gmch_device = pci_get_device(PCI_VENDOR_ID_INTEL, 1989 + device, gmch_device); 1990 } 1991 1992 if (!gmch_device) ··· 2108 if (intel_agp_chipsets[i].name == NULL) { 2109 if (cap_ptr) 2110 printk(KERN_WARNING PFX "Unsupported Intel chipset" 2111 + "(device id: %04x)\n", pdev->device); 2112 agp_put_bridge(bridge); 2113 return -ENODEV; 2114 } ··· 2121 intel_agp_chipsets[i].gmch_chip_id); 2122 agp_put_bridge(bridge); 2123 return -ENODEV; 2124 + } 2125 2126 bridge->dev = pdev; 2127 bridge->capndx = cap_ptr;