diff options
author | Daniel Vetter <daniel.vetter@ffwll.ch> | 2010-08-24 17:06:19 -0400 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2010-09-08 16:20:07 -0400 |
commit | d7cca2f7000243ac43a389110c3d8474f582ae3f (patch) | |
tree | e2e5df744aa066591201aa365c6e24c687b574b8 /drivers/char/agp/intel-gtt.c | |
parent | 0ade638655f0ef4d807295c14a4c97544bd6b9ca (diff) |
intel-gtt: store a local pointer to the bridge pci dev
When the intel-gtt code now longer depends on agp, we cannot rely
on this. So store a local reference in intel-gtt.c.
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'drivers/char/agp/intel-gtt.c')
-rw-r--r-- | drivers/char/agp/intel-gtt.c | 61 |
1 files changed, 34 insertions, 27 deletions
diff --git a/drivers/char/agp/intel-gtt.c b/drivers/char/agp/intel-gtt.c index 0a3e91ba0f2b..96e5fd1aa554 100644 --- a/drivers/char/agp/intel-gtt.c +++ b/drivers/char/agp/intel-gtt.c | |||
@@ -84,6 +84,7 @@ static struct gatt_mask intel_gen6_masks[] = | |||
84 | static struct _intel_private { | 84 | static struct _intel_private { |
85 | struct intel_gtt base; | 85 | struct intel_gtt base; |
86 | struct pci_dev *pcidev; /* device one */ | 86 | struct pci_dev *pcidev; /* device one */ |
87 | struct pci_dev *bridge_dev; | ||
87 | u8 __iomem *registers; | 88 | u8 __iomem *registers; |
88 | u32 __iomem *gtt; /* I915G */ | 89 | u32 __iomem *gtt; /* I915G */ |
89 | int num_dcache_entries; | 90 | int num_dcache_entries; |
@@ -221,11 +222,12 @@ static int intel_i810_fetch_size(void) | |||
221 | u32 smram_miscc; | 222 | u32 smram_miscc; |
222 | struct aper_size_info_fixed *values; | 223 | struct aper_size_info_fixed *values; |
223 | 224 | ||
224 | pci_read_config_dword(agp_bridge->dev, I810_SMRAM_MISCC, &smram_miscc); | 225 | pci_read_config_dword(intel_private.bridge_dev, |
226 | I810_SMRAM_MISCC, &smram_miscc); | ||
225 | values = A_SIZE_FIX(agp_bridge->driver->aperture_sizes); | 227 | values = A_SIZE_FIX(agp_bridge->driver->aperture_sizes); |
226 | 228 | ||
227 | if ((smram_miscc & I810_GMS) == I810_GMS_DISABLE) { | 229 | if ((smram_miscc & I810_GMS) == I810_GMS_DISABLE) { |
228 | dev_warn(&agp_bridge->dev->dev, "i810 is disabled\n"); | 230 | dev_warn(&intel_private.bridge_dev->dev, "i810 is disabled\n"); |
229 | return 0; | 231 | return 0; |
230 | } | 232 | } |
231 | if ((smram_miscc & I810_GFX_MEM_WIN_SIZE) == I810_GFX_MEM_WIN_32M) { | 233 | if ((smram_miscc & I810_GFX_MEM_WIN_SIZE) == I810_GFX_MEM_WIN_32M) { |
@@ -538,7 +540,8 @@ static void intel_i830_init_gtt_entries(void) | |||
538 | static const int ddt[4] = { 0, 16, 32, 64 }; | 540 | static const int ddt[4] = { 0, 16, 32, 64 }; |
539 | int size; /* reserved space (in kb) at the top of stolen memory */ | 541 | int size; /* reserved space (in kb) at the top of stolen memory */ |
540 | 542 | ||
541 | pci_read_config_word(agp_bridge->dev, I830_GMCH_CTRL, &gmch_ctrl); | 543 | pci_read_config_word(intel_private.bridge_dev, |
544 | I830_GMCH_CTRL, &gmch_ctrl); | ||
542 | 545 | ||
543 | if (IS_I965) { | 546 | if (IS_I965) { |
544 | u32 pgetbl_ctl; | 547 | u32 pgetbl_ctl; |
@@ -583,7 +586,7 @@ static void intel_i830_init_gtt_entries(void) | |||
583 | size = 2048; | 586 | size = 2048; |
584 | break; | 587 | break; |
585 | default: | 588 | default: |
586 | dev_info(&agp_bridge->dev->dev, | 589 | dev_info(&intel_private.bridge_dev->dev, |
587 | "unknown page table size 0x%x, assuming 512KB\n", | 590 | "unknown page table size 0x%x, assuming 512KB\n", |
588 | (gmch_ctrl & G33_PGETBL_SIZE_MASK)); | 591 | (gmch_ctrl & G33_PGETBL_SIZE_MASK)); |
589 | size = 512; | 592 | size = 512; |
@@ -602,8 +605,8 @@ static void intel_i830_init_gtt_entries(void) | |||
602 | size = agp_bridge->driver->fetch_size() + 4; | 605 | size = agp_bridge->driver->fetch_size() + 4; |
603 | } | 606 | } |
604 | 607 | ||
605 | if (agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82830_HB || | 608 | if (intel_private.bridge_dev->device == PCI_DEVICE_ID_INTEL_82830_HB || |
606 | agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82845G_HB) { | 609 | intel_private.bridge_dev->device == PCI_DEVICE_ID_INTEL_82845G_HB) { |
607 | switch (gmch_ctrl & I830_GMCH_GMS_MASK) { | 610 | switch (gmch_ctrl & I830_GMCH_GMS_MASK) { |
608 | case I830_GMCH_GMS_STOLEN_512: | 611 | case I830_GMCH_GMS_STOLEN_512: |
609 | gtt_entries = KB(512) - KB(size); | 612 | gtt_entries = KB(512) - KB(size); |
@@ -753,16 +756,16 @@ static void intel_i830_init_gtt_entries(void) | |||
753 | } | 756 | } |
754 | } | 757 | } |
755 | if (!local && gtt_entries > intel_max_stolen) { | 758 | if (!local && gtt_entries > intel_max_stolen) { |
756 | dev_info(&agp_bridge->dev->dev, | 759 | dev_info(&intel_private.bridge_dev->dev, |
757 | "detected %dK stolen memory, trimming to %dK\n", | 760 | "detected %dK stolen memory, trimming to %dK\n", |
758 | gtt_entries / KB(1), intel_max_stolen / KB(1)); | 761 | gtt_entries / KB(1), intel_max_stolen / KB(1)); |
759 | gtt_entries = intel_max_stolen / KB(4); | 762 | gtt_entries = intel_max_stolen / KB(4); |
760 | } else if (gtt_entries > 0) { | 763 | } else if (gtt_entries > 0) { |
761 | dev_info(&agp_bridge->dev->dev, "detected %dK %s memory\n", | 764 | dev_info(&intel_private.bridge_dev->dev, "detected %dK %s memory\n", |
762 | gtt_entries / KB(1), local ? "local" : "stolen"); | 765 | gtt_entries / KB(1), local ? "local" : "stolen"); |
763 | gtt_entries /= KB(4); | 766 | gtt_entries /= KB(4); |
764 | } else { | 767 | } else { |
765 | dev_info(&agp_bridge->dev->dev, | 768 | dev_info(&intel_private.bridge_dev->dev, |
766 | "no pre-allocated video memory detected\n"); | 769 | "no pre-allocated video memory detected\n"); |
767 | gtt_entries = 0; | 770 | gtt_entries = 0; |
768 | } | 771 | } |
@@ -871,15 +874,15 @@ static int intel_i830_fetch_size(void) | |||
871 | 874 | ||
872 | values = A_SIZE_FIX(agp_bridge->driver->aperture_sizes); | 875 | values = A_SIZE_FIX(agp_bridge->driver->aperture_sizes); |
873 | 876 | ||
874 | if (agp_bridge->dev->device != PCI_DEVICE_ID_INTEL_82830_HB && | 877 | if (intel_private.bridge_dev->device != PCI_DEVICE_ID_INTEL_82830_HB && |
875 | agp_bridge->dev->device != PCI_DEVICE_ID_INTEL_82845G_HB) { | 878 | intel_private.bridge_dev->device != PCI_DEVICE_ID_INTEL_82845G_HB) { |
876 | /* 855GM/852GM/865G has 128MB aperture size */ | 879 | /* 855GM/852GM/865G has 128MB aperture size */ |
877 | agp_bridge->current_size = (void *) values; | 880 | agp_bridge->current_size = (void *) values; |
878 | agp_bridge->aperture_size_idx = 0; | 881 | agp_bridge->aperture_size_idx = 0; |
879 | return values[0].size; | 882 | return values[0].size; |
880 | } | 883 | } |
881 | 884 | ||
882 | pci_read_config_word(agp_bridge->dev, I830_GMCH_CTRL, &gmch_ctrl); | 885 | pci_read_config_word(intel_private.bridge_dev, I830_GMCH_CTRL, &gmch_ctrl); |
883 | 886 | ||
884 | if ((gmch_ctrl & I830_GMCH_MEM_MASK) == I830_GMCH_MEM_128M) { | 887 | if ((gmch_ctrl & I830_GMCH_MEM_MASK) == I830_GMCH_MEM_128M) { |
885 | agp_bridge->current_size = (void *) values; | 888 | agp_bridge->current_size = (void *) values; |
@@ -906,9 +909,9 @@ static int intel_i830_configure(void) | |||
906 | pci_read_config_dword(intel_private.pcidev, I810_GMADDR, &temp); | 909 | pci_read_config_dword(intel_private.pcidev, I810_GMADDR, &temp); |
907 | agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK); | 910 | agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK); |
908 | 911 | ||
909 | pci_read_config_word(agp_bridge->dev, I830_GMCH_CTRL, &gmch_ctrl); | 912 | pci_read_config_word(intel_private.bridge_dev, I830_GMCH_CTRL, &gmch_ctrl); |
910 | gmch_ctrl |= I830_GMCH_ENABLED; | 913 | gmch_ctrl |= I830_GMCH_ENABLED; |
911 | pci_write_config_word(agp_bridge->dev, I830_GMCH_CTRL, gmch_ctrl); | 914 | pci_write_config_word(intel_private.bridge_dev, I830_GMCH_CTRL, gmch_ctrl); |
912 | 915 | ||
913 | writel(agp_bridge->gatt_bus_addr|I810_PGETBL_ENABLED, intel_private.registers+I810_PGETBL_CTL); | 916 | writel(agp_bridge->gatt_bus_addr|I810_PGETBL_ENABLED, intel_private.registers+I810_PGETBL_CTL); |
914 | readl(intel_private.registers+I810_PGETBL_CTL); /* PCI Posting. */ | 917 | readl(intel_private.registers+I810_PGETBL_CTL); /* PCI Posting. */ |
@@ -1021,9 +1024,9 @@ static struct agp_memory *intel_i830_alloc_by_type(size_t pg_count, int type) | |||
1021 | static int intel_alloc_chipset_flush_resource(void) | 1024 | static int intel_alloc_chipset_flush_resource(void) |
1022 | { | 1025 | { |
1023 | int ret; | 1026 | int ret; |
1024 | ret = pci_bus_alloc_resource(agp_bridge->dev->bus, &intel_private.ifp_resource, PAGE_SIZE, | 1027 | ret = pci_bus_alloc_resource(intel_private.bridge_dev->bus, &intel_private.ifp_resource, PAGE_SIZE, |
1025 | PAGE_SIZE, PCIBIOS_MIN_MEM, 0, | 1028 | PAGE_SIZE, PCIBIOS_MIN_MEM, 0, |
1026 | pcibios_align_resource, agp_bridge->dev); | 1029 | pcibios_align_resource, intel_private.bridge_dev); |
1027 | 1030 | ||
1028 | return ret; | 1031 | return ret; |
1029 | } | 1032 | } |
@@ -1033,11 +1036,11 @@ static void intel_i915_setup_chipset_flush(void) | |||
1033 | int ret; | 1036 | int ret; |
1034 | u32 temp; | 1037 | u32 temp; |
1035 | 1038 | ||
1036 | pci_read_config_dword(agp_bridge->dev, I915_IFPADDR, &temp); | 1039 | pci_read_config_dword(intel_private.bridge_dev, I915_IFPADDR, &temp); |
1037 | if (!(temp & 0x1)) { | 1040 | if (!(temp & 0x1)) { |
1038 | intel_alloc_chipset_flush_resource(); | 1041 | intel_alloc_chipset_flush_resource(); |
1039 | intel_private.resource_valid = 1; | 1042 | intel_private.resource_valid = 1; |
1040 | pci_write_config_dword(agp_bridge->dev, I915_IFPADDR, (intel_private.ifp_resource.start & 0xffffffff) | 0x1); | 1043 | pci_write_config_dword(intel_private.bridge_dev, I915_IFPADDR, (intel_private.ifp_resource.start & 0xffffffff) | 0x1); |
1041 | } else { | 1044 | } else { |
1042 | temp &= ~1; | 1045 | temp &= ~1; |
1043 | 1046 | ||
@@ -1056,17 +1059,17 @@ static void intel_i965_g33_setup_chipset_flush(void) | |||
1056 | u32 temp_hi, temp_lo; | 1059 | u32 temp_hi, temp_lo; |
1057 | int ret; | 1060 | int ret; |
1058 | 1061 | ||
1059 | pci_read_config_dword(agp_bridge->dev, I965_IFPADDR + 4, &temp_hi); | 1062 | pci_read_config_dword(intel_private.bridge_dev, I965_IFPADDR + 4, &temp_hi); |
1060 | pci_read_config_dword(agp_bridge->dev, I965_IFPADDR, &temp_lo); | 1063 | pci_read_config_dword(intel_private.bridge_dev, I965_IFPADDR, &temp_lo); |
1061 | 1064 | ||
1062 | if (!(temp_lo & 0x1)) { | 1065 | if (!(temp_lo & 0x1)) { |
1063 | 1066 | ||
1064 | intel_alloc_chipset_flush_resource(); | 1067 | intel_alloc_chipset_flush_resource(); |
1065 | 1068 | ||
1066 | intel_private.resource_valid = 1; | 1069 | intel_private.resource_valid = 1; |
1067 | pci_write_config_dword(agp_bridge->dev, I965_IFPADDR + 4, | 1070 | pci_write_config_dword(intel_private.bridge_dev, I965_IFPADDR + 4, |
1068 | upper_32_bits(intel_private.ifp_resource.start)); | 1071 | upper_32_bits(intel_private.ifp_resource.start)); |
1069 | pci_write_config_dword(agp_bridge->dev, I965_IFPADDR, (intel_private.ifp_resource.start & 0xffffffff) | 0x1); | 1072 | pci_write_config_dword(intel_private.bridge_dev, I965_IFPADDR, (intel_private.ifp_resource.start & 0xffffffff) | 0x1); |
1070 | } else { | 1073 | } else { |
1071 | u64 l64; | 1074 | u64 l64; |
1072 | 1075 | ||
@@ -1123,9 +1126,9 @@ static int intel_i9xx_configure(void) | |||
1123 | 1126 | ||
1124 | agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK); | 1127 | agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK); |
1125 | 1128 | ||
1126 | pci_read_config_word(agp_bridge->dev, I830_GMCH_CTRL, &gmch_ctrl); | 1129 | pci_read_config_word(intel_private.bridge_dev, I830_GMCH_CTRL, &gmch_ctrl); |
1127 | gmch_ctrl |= I830_GMCH_ENABLED; | 1130 | gmch_ctrl |= I830_GMCH_ENABLED; |
1128 | pci_write_config_word(agp_bridge->dev, I830_GMCH_CTRL, gmch_ctrl); | 1131 | pci_write_config_word(intel_private.bridge_dev, I830_GMCH_CTRL, gmch_ctrl); |
1129 | 1132 | ||
1130 | writel(agp_bridge->gatt_bus_addr|I810_PGETBL_ENABLED, intel_private.registers+I810_PGETBL_CTL); | 1133 | writel(agp_bridge->gatt_bus_addr|I810_PGETBL_ENABLED, intel_private.registers+I810_PGETBL_CTL); |
1131 | readl(intel_private.registers+I810_PGETBL_CTL); /* PCI Posting. */ | 1134 | readl(intel_private.registers+I810_PGETBL_CTL); /* PCI Posting. */ |
@@ -1267,7 +1270,7 @@ static int intel_i915_get_gtt_size(void) | |||
1267 | u16 gmch_ctrl; | 1270 | u16 gmch_ctrl; |
1268 | 1271 | ||
1269 | /* G33's GTT size defined in gmch_ctrl */ | 1272 | /* G33's GTT size defined in gmch_ctrl */ |
1270 | pci_read_config_word(agp_bridge->dev, I830_GMCH_CTRL, &gmch_ctrl); | 1273 | pci_read_config_word(intel_private.bridge_dev, I830_GMCH_CTRL, &gmch_ctrl); |
1271 | switch (gmch_ctrl & I830_GMCH_GMS_MASK) { | 1274 | switch (gmch_ctrl & I830_GMCH_GMS_MASK) { |
1272 | case I830_GMCH_GMS_STOLEN_512: | 1275 | case I830_GMCH_GMS_STOLEN_512: |
1273 | size = 512; | 1276 | size = 512; |
@@ -1279,7 +1282,7 @@ static int intel_i915_get_gtt_size(void) | |||
1279 | size = 8*1024; | 1282 | size = 8*1024; |
1280 | break; | 1283 | break; |
1281 | default: | 1284 | default: |
1282 | dev_info(&agp_bridge->dev->dev, | 1285 | dev_info(&intel_private.bridge_dev->dev, |
1283 | "unknown page table size 0x%x, assuming 512KB\n", | 1286 | "unknown page table size 0x%x, assuming 512KB\n", |
1284 | (gmch_ctrl & I830_GMCH_GMS_MASK)); | 1287 | (gmch_ctrl & I830_GMCH_GMS_MASK)); |
1285 | size = 512; | 1288 | size = 512; |
@@ -1380,7 +1383,7 @@ static void intel_i965_get_gtt_range(int *gtt_offset, int *gtt_size) | |||
1380 | { | 1383 | { |
1381 | u16 snb_gmch_ctl; | 1384 | u16 snb_gmch_ctl; |
1382 | 1385 | ||
1383 | switch (agp_bridge->dev->device) { | 1386 | switch (intel_private.bridge_dev->device) { |
1384 | case PCI_DEVICE_ID_INTEL_GM45_HB: | 1387 | case PCI_DEVICE_ID_INTEL_GM45_HB: |
1385 | case PCI_DEVICE_ID_INTEL_EAGLELAKE_HB: | 1388 | case PCI_DEVICE_ID_INTEL_EAGLELAKE_HB: |
1386 | case PCI_DEVICE_ID_INTEL_Q45_HB: | 1389 | case PCI_DEVICE_ID_INTEL_Q45_HB: |
@@ -1755,6 +1758,8 @@ int intel_gmch_probe(struct pci_dev *pdev, | |||
1755 | bridge->dev_private_data = &intel_private; | 1758 | bridge->dev_private_data = &intel_private; |
1756 | bridge->dev = pdev; | 1759 | bridge->dev = pdev; |
1757 | 1760 | ||
1761 | intel_private.bridge_dev = pci_dev_get(pdev); | ||
1762 | |||
1758 | dev_info(&pdev->dev, "Intel %s Chipset\n", intel_gtt_chipsets[i].name); | 1763 | dev_info(&pdev->dev, "Intel %s Chipset\n", intel_gtt_chipsets[i].name); |
1759 | 1764 | ||
1760 | if (bridge->driver->mask_memory == intel_gen6_mask_memory) | 1765 | if (bridge->driver->mask_memory == intel_gen6_mask_memory) |
@@ -1779,6 +1784,8 @@ void intel_gmch_remove(struct pci_dev *pdev) | |||
1779 | { | 1784 | { |
1780 | if (intel_private.pcidev) | 1785 | if (intel_private.pcidev) |
1781 | pci_dev_put(intel_private.pcidev); | 1786 | pci_dev_put(intel_private.pcidev); |
1787 | if (intel_private.bridge_dev) | ||
1788 | pci_dev_put(intel_private.bridge_dev); | ||
1782 | } | 1789 | } |
1783 | EXPORT_SYMBOL(intel_gmch_remove); | 1790 | EXPORT_SYMBOL(intel_gmch_remove); |
1784 | 1791 | ||