Commit 31e9dd25 authored by Bjorn Helgaas's avatar Bjorn Helgaas

PCI: Don't set BAR to zero if dma_addr_t is too small

If a BAR is above 4GB and our dma_addr_t is too small, don't clear the BAR
to zero: that doesn't disable the BAR, and it makes it more likely that the
BAR will conflict with things if we turn on the memory enable bit (as we
will at "out:" if the device was already enabled at the handoff).

We should also print the BAR info and its original size so we can follow
the process when we try to assign space to it.
Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
parent 72dc5601
...@@ -174,7 +174,7 @@ int __pci_read_base(struct pci_dev *dev, enum pci_bar_type type, ...@@ -174,7 +174,7 @@ int __pci_read_base(struct pci_dev *dev, enum pci_bar_type type,
u64 l64, sz64, mask64; u64 l64, sz64, mask64;
u16 orig_cmd; u16 orig_cmd;
struct pci_bus_region region, inverted_region; struct pci_bus_region region, inverted_region;
bool bar_too_big = false, bar_disabled = false; bool bar_too_big = false, bar_too_high = false;
mask = type ? PCI_ROM_ADDRESS_MASK : ~0; mask = type ? PCI_ROM_ADDRESS_MASK : ~0;
...@@ -254,13 +254,11 @@ int __pci_read_base(struct pci_dev *dev, enum pci_bar_type type, ...@@ -254,13 +254,11 @@ int __pci_read_base(struct pci_dev *dev, enum pci_bar_type type,
} }
if ((sizeof(dma_addr_t) < 8) && l) { if ((sizeof(dma_addr_t) < 8) && l) {
/* Address above 32-bit boundary; disable the BAR */ /* Above 32-bit boundary; try to reallocate */
pci_write_config_dword(dev, pos, 0);
pci_write_config_dword(dev, pos + 4, 0);
res->flags |= IORESOURCE_UNSET; res->flags |= IORESOURCE_UNSET;
res->start = 0; res->start = 0;
res->end = sz64; res->end = sz64;
bar_disabled = true; bar_too_high = true;
goto out; goto out;
} else { } else {
region.start = l64; region.start = l64;
...@@ -311,7 +309,10 @@ int __pci_read_base(struct pci_dev *dev, enum pci_bar_type type, ...@@ -311,7 +309,10 @@ int __pci_read_base(struct pci_dev *dev, enum pci_bar_type type,
if (bar_too_big) if (bar_too_big)
dev_err(&dev->dev, "reg 0x%x: can't handle BAR larger than 4GB (size %#010llx)\n", dev_err(&dev->dev, "reg 0x%x: can't handle BAR larger than 4GB (size %#010llx)\n",
pos, (unsigned long long) sz64); pos, (unsigned long long) sz64);
if (res->flags && !bar_disabled) if (bar_too_high)
dev_info(&dev->dev, "reg 0x%x: can't handle BAR above 4G (bus address %#010llx)\n",
pos, (unsigned long long) l64);
if (res->flags)
dev_printk(KERN_DEBUG, &dev->dev, "reg 0x%x: %pR\n", pos, res); dev_printk(KERN_DEBUG, &dev->dev, "reg 0x%x: %pR\n", pos, res);
return (res->flags & IORESOURCE_MEM_64) ? 1 : 0; return (res->flags & IORESOURCE_MEM_64) ? 1 : 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment