Skip to content

Commit 96702be

Browse files
committed
Merge branch 'pci/resource' into next
* pci/resource: PCI: Allocate 64-bit BARs above 4G when possible PCI: Enforce bus address limits in resource allocation PCI: Split out bridge window override of minimum allocation address agp/ati: Use PCI_COMMAND instead of hard-coded 4 agp/intel: Use CPU physical address, not bus address, for ioremap() agp/intel: Use pci_bus_address() to get GTTADR bus address agp/intel: Use pci_bus_address() to get MMADR bus address agp/intel: Support 64-bit GMADR agp/intel: Rename gtt_bus_addr to gtt_phys_addr drm/i915: Rename gtt_bus_addr to gtt_phys_addr agp: Use pci_resource_start() to get CPU physical address for BAR agp: Support 64-bit APBASE PCI: Add pci_bus_address() to get bus address of a BAR PCI: Convert pcibios_resource_to_bus() to take a pci_bus, not a pci_dev PCI: Change pci_bus_region addresses to dma_addr_t
2 parents 04f982b + d56dbf5 commit 96702be

33 files changed

Lines changed: 244 additions & 195 deletions

‎arch/alpha/kernel/pci-sysfs.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ static int pci_mmap_resource(struct kobject *kobj,
8383
if (iomem_is_exclusive(res->start))
8484
return -EINVAL;
8585

86-
pcibios_resource_to_bus(pdev, &bar, res);
86+
pcibios_resource_to_bus(pdev->bus, &bar, res);
8787
vma->vm_pgoff += bar.start >> (PAGE_SHIFT - (sparse ? 5 : 0));
8888
mmap_type = res->flags & IORESOURCE_MEM ? pci_mmap_mem : pci_mmap_io;
8989

@@ -139,7 +139,7 @@ static int sparse_mem_mmap_fits(struct pci_dev *pdev, int num)
139139
long dense_offset;
140140
unsigned long sparse_size;
141141

142-
pcibios_resource_to_bus(pdev, &bar, &pdev->resource[num]);
142+
pcibios_resource_to_bus(pdev->bus, &bar, &pdev->resource[num]);
143143

144144
/* All core logic chips have 4G sparse address space, except
145145
CIA which has 16G (see xxx_SPARSE_MEM and xxx_DENSE_MEM

‎arch/powerpc/kernel/pci-common.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -835,7 +835,7 @@ static void pcibios_fixup_resources(struct pci_dev *dev)
835835
* at 0 as unset as well, except if PCI_PROBE_ONLY is also set
836836
* since in that case, we don't want to re-assign anything
837837
*/
838-
pcibios_resource_to_bus(dev, &reg, res);
838+
pcibios_resource_to_bus(dev->bus, &reg, res);
839839
if (pci_has_flag(PCI_REASSIGN_ALL_RSRC) ||
840840
(reg.start == 0 && !pci_has_flag(PCI_PROBE_ONLY))) {
841841
/* Only print message if not re-assigning */
@@ -886,7 +886,7 @@ static int pcibios_uninitialized_bridge_resource(struct pci_bus *bus,
886886

887887
/* Job is a bit different between memory and IO */
888888
if (res->flags & IORESOURCE_MEM) {
889-
pcibios_resource_to_bus(dev, &region, res);
889+
pcibios_resource_to_bus(dev->bus, &region, res);
890890

891891
/* If the BAR is non-0 then it's probably been initialized */
892892
if (region.start != 0)

‎arch/powerpc/kernel/pci_of_scan.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ static void of_pci_parse_addrs(struct device_node *node, struct pci_dev *dev)
111111
res->name = pci_name(dev);
112112
region.start = base;
113113
region.end = base + size - 1;
114-
pcibios_bus_to_resource(dev, res, &region);
114+
pcibios_bus_to_resource(dev->bus, res, &region);
115115
}
116116
}
117117

@@ -280,7 +280,7 @@ void of_scan_pci_bridge(struct pci_dev *dev)
280280
res->flags = flags;
281281
region.start = of_read_number(&ranges[1], 2);
282282
region.end = region.start + size - 1;
283-
pcibios_bus_to_resource(dev, res, &region);
283+
pcibios_bus_to_resource(dev->bus, res, &region);
284284
}
285285
sprintf(bus->name, "PCI Bus %04x:%02x", pci_domain_nr(bus),
286286
bus->number);

‎arch/sparc/kernel/pci.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -392,15 +392,15 @@ static void apb_fake_ranges(struct pci_dev *dev,
392392
res->flags = IORESOURCE_IO;
393393
region.start = (first << 21);
394394
region.end = (last << 21) + ((1 << 21) - 1);
395-
pcibios_bus_to_resource(dev, res, &region);
395+
pcibios_bus_to_resource(dev->bus, res, &region);
396396

397397
pci_read_config_byte(dev, APB_MEM_ADDRESS_MAP, &map);
398398
apb_calc_first_last(map, &first, &last);
399399
res = bus->resource[1];
400400
res->flags = IORESOURCE_MEM;
401401
region.start = (first << 29);
402402
region.end = (last << 29) + ((1 << 29) - 1);
403-
pcibios_bus_to_resource(dev, res, &region);
403+
pcibios_bus_to_resource(dev->bus, res, &region);
404404
}
405405

406406
static void pci_of_scan_bus(struct pci_pbm_info *pbm,
@@ -491,7 +491,7 @@ static void of_scan_pci_bridge(struct pci_pbm_info *pbm,
491491
res->flags = flags;
492492
region.start = GET_64BIT(ranges, 1);
493493
region.end = region.start + size - 1;
494-
pcibios_bus_to_resource(dev, res, &region);
494+
pcibios_bus_to_resource(dev->bus, res, &region);
495495
}
496496
after_ranges:
497497
sprintf(bus->name, "PCI Bus %04x:%02x", pci_domain_nr(bus),

‎arch/x86/include/asm/pci.h‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,6 @@ int setup_msi_irq(struct pci_dev *dev, struct msi_desc *msidesc,
125125

126126
/* generic pci stuff */
127127
#include <asm-generic/pci.h>
128-
#define PCIBIOS_MAX_MEM_32 0xffffffff
129128

130129
#ifdef CONFIG_NUMA
131130
/* Returns the node based on pci bus */

‎drivers/char/agp/agp.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,7 @@ long compat_agp_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
239239

240240
/* Chipset independent registers (from AGP Spec) */
241241
#define AGP_APBASE 0x10
242+
#define AGP_APERTURE_BAR 0
242243

243244
#define AGPSTAT 0x4
244245
#define AGPCMD 0x8

‎drivers/char/agp/ali-agp.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@ static int ali_configure(void)
8585
pci_write_config_dword(agp_bridge->dev, ALI_TLBCTRL, ((temp & 0xffffff00) | 0x00000010));
8686

8787
/* address to map to */
88-
pci_read_config_dword(agp_bridge->dev, AGP_APBASE, &temp);
89-
agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK);
88+
agp_bridge->gart_bus_addr = pci_bus_address(agp_bridge->dev,
89+
AGP_APERTURE_BAR);
9090

9191
#if 0
9292
if (agp_bridge->type == ALI_M1541) {

‎drivers/char/agp/amd-k7-agp.c‎

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#include <linux/slab.h>
1212
#include "agp.h"
1313

14-
#define AMD_MMBASE 0x14
14+
#define AMD_MMBASE_BAR 1
1515
#define AMD_APSIZE 0xac
1616
#define AMD_MODECNTL 0xb0
1717
#define AMD_MODECNTL2 0xb2
@@ -126,7 +126,6 @@ static int amd_create_gatt_table(struct agp_bridge_data *bridge)
126126
unsigned long __iomem *cur_gatt;
127127
unsigned long addr;
128128
int retval;
129-
u32 temp;
130129
int i;
131130

132131
value = A_SIZE_LVL2(agp_bridge->current_size);
@@ -149,8 +148,7 @@ static int amd_create_gatt_table(struct agp_bridge_data *bridge)
149148
* used to program the agp master not the cpu
150149
*/
151150

152-
pci_read_config_dword(agp_bridge->dev, AGP_APBASE, &temp);
153-
addr = (temp & PCI_BASE_ADDRESS_MEM_MASK);
151+
addr = pci_bus_address(agp_bridge->dev, AGP_APERTURE_BAR);
154152
agp_bridge->gart_bus_addr = addr;
155153

156154
/* Calculate the agp offset */
@@ -207,16 +205,16 @@ static int amd_irongate_fetch_size(void)
207205
static int amd_irongate_configure(void)
208206
{
209207
struct aper_size_info_lvl2 *current_size;
208+
phys_addr_t reg;
210209
u32 temp;
211210
u16 enable_reg;
212211

213212
current_size = A_SIZE_LVL2(agp_bridge->current_size);
214213

215214
if (!amd_irongate_private.registers) {
216215
/* Get the memory mapped registers */
217-
pci_read_config_dword(agp_bridge->dev, AMD_MMBASE, &temp);
218-
temp = (temp & PCI_BASE_ADDRESS_MEM_MASK);
219-
amd_irongate_private.registers = (volatile u8 __iomem *) ioremap(temp, 4096);
216+
reg = pci_resource_start(agp_bridge->dev, AMD_MMBASE_BAR);
217+
amd_irongate_private.registers = (volatile u8 __iomem *) ioremap(reg, 4096);
220218
if (!amd_irongate_private.registers)
221219
return -ENOMEM;
222220
}

‎drivers/char/agp/amd64-agp.c‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,6 @@ static int agp_aperture_valid(u64 aper, u32 size)
269269
*/
270270
static int fix_northbridge(struct pci_dev *nb, struct pci_dev *agp, u16 cap)
271271
{
272-
u32 aper_low, aper_hi;
273272
u64 aper, nb_aper;
274273
int order = 0;
275274
u32 nb_order, nb_base;
@@ -295,9 +294,7 @@ static int fix_northbridge(struct pci_dev *nb, struct pci_dev *agp, u16 cap)
295294
apsize |= 0xf00;
296295
order = 7 - hweight16(apsize);
297296

298-
pci_read_config_dword(agp, 0x10, &aper_low);
299-
pci_read_config_dword(agp, 0x14, &aper_hi);
300-
aper = (aper_low & ~((1<<22)-1)) | ((u64)aper_hi << 32);
297+
aper = pci_bus_address(agp, AGP_APERTURE_BAR);
301298

302299
/*
303300
* On some sick chips APSIZE is 0. This means it wants 4G

‎drivers/char/agp/ati-agp.c‎

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#include <asm/agp.h>
1313
#include "agp.h"
1414

15-
#define ATI_GART_MMBASE_ADDR 0x14
15+
#define ATI_GART_MMBASE_BAR 1
1616
#define ATI_RS100_APSIZE 0xac
1717
#define ATI_RS100_IG_AGPMODE 0xb0
1818
#define ATI_RS300_APSIZE 0xf8
@@ -196,12 +196,12 @@ static void ati_cleanup(void)
196196

197197
static int ati_configure(void)
198198
{
199+
phys_addr_t reg;
199200
u32 temp;
200201

201202
/* Get the memory mapped registers */
202-
pci_read_config_dword(agp_bridge->dev, ATI_GART_MMBASE_ADDR, &temp);
203-
temp = (temp & 0xfffff000);
204-
ati_generic_private.registers = (volatile u8 __iomem *) ioremap(temp, 4096);
203+
reg = pci_resource_start(agp_bridge->dev, ATI_GART_MMBASE_BAR);
204+
ati_generic_private.registers = (volatile u8 __iomem *) ioremap(reg, 4096);
205205

206206
if (!ati_generic_private.registers)
207207
return -ENOMEM;
@@ -211,18 +211,18 @@ static int ati_configure(void)
211211
else
212212
pci_write_config_dword(agp_bridge->dev, ATI_RS300_IG_AGPMODE, 0x20000);
213213

214-
/* address to map too */
214+
/* address to map to */
215215
/*
216-
pci_read_config_dword(agp_bridge.dev, AGP_APBASE, &temp);
217-
agp_bridge.gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK);
216+
agp_bridge.gart_bus_addr = pci_bus_address(agp_bridge.dev,
217+
AGP_APERTURE_BAR);
218218
printk(KERN_INFO PFX "IGP320 gart_bus_addr: %x\n", agp_bridge.gart_bus_addr);
219219
*/
220220
writel(0x60000, ati_generic_private.registers+ATI_GART_FEATURE_ID);
221221
readl(ati_generic_private.registers+ATI_GART_FEATURE_ID); /* PCI Posting.*/
222222

223223
/* SIGNALED_SYSTEM_ERROR @ NB_STATUS */
224-
pci_read_config_dword(agp_bridge->dev, 4, &temp);
225-
pci_write_config_dword(agp_bridge->dev, 4, temp | (1<<14));
224+
pci_read_config_dword(agp_bridge->dev, PCI_COMMAND, &temp);
225+
pci_write_config_dword(agp_bridge->dev, PCI_COMMAND, temp | (1<<14));
226226

227227
/* Write out the address of the gatt table */
228228
writel(agp_bridge->gatt_bus_addr, ati_generic_private.registers+ATI_GART_BASE);
@@ -385,8 +385,7 @@ static int ati_create_gatt_table(struct agp_bridge_data *bridge)
385385
* This is a bus address even on the alpha, b/c its
386386
* used to program the agp master not the cpu
387387
*/
388-
pci_read_config_dword(agp_bridge->dev, AGP_APBASE, &temp);
389-
addr = (temp & PCI_BASE_ADDRESS_MEM_MASK);
388+
addr = pci_bus_address(agp_bridge->dev, AGP_APERTURE_BAR);
390389
agp_bridge->gart_bus_addr = addr;
391390

392391
/* Calculate the agp offset */

0 commit comments

Comments
 (0)