Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6e6f498b authored by Bjorn Helgaas's avatar Bjorn Helgaas
Browse files

Merge branch 'pci/resource' into next

* pci/resource:
  PCI: Simplify pci_create_attr() control flow
  PCI: Don't leak memory if sysfs_create_bin_file() fails
  PCI: Simplify sysfs ROM cleanup
  PCI: Remove unused IORESOURCE_ROM_COPY and IORESOURCE_ROM_BIOS_COPY
  MIPS: Loongson 3: Keep CPU physical (not virtual) addresses in shadow ROM resource
  MIPS: Loongson 3: Use temporary struct resource * to avoid repetition
  ia64/PCI: Keep CPU physical (not virtual) addresses in shadow ROM resource
  ia64/PCI: Use ioremap() instead of open-coded equivalent
  ia64/PCI: Use temporary struct resource * to avoid repetition
  PCI: Clean up pci_map_rom() whitespace
  PCI: Remove arch-specific IORESOURCE_ROM_SHADOW size from sysfs
  PCI: Set ROM shadow location in arch code, not in PCI core
  PCI: Don't enable/disable ROM BAR if we're using a RAM shadow copy
  PCI: Don't assign or reassign immutable resources
  PCI: Mark shadow copy of VGA ROM as IORESOURCE_PCI_FIXED
  x86/PCI: Mark Broadwell-EP Home Agent & PCU as having non-compliant BARs
  PCI: Disable IO/MEM decoding for devices with non-compliant BARs
parents cfeb8139 bd5174df
Loading
Loading
Loading
Loading
+16 −5
Original line number Original line Diff line number Diff line
@@ -17,14 +17,14 @@
 *
 *
 * The standard boot ROM sequence for an x86 machine uses the BIOS
 * The standard boot ROM sequence for an x86 machine uses the BIOS
 * to select an initial video card for boot display. This boot video
 * to select an initial video card for boot display. This boot video
 * card will have it's BIOS copied to C0000 in system RAM.
 * card will have its BIOS copied to 0xC0000 in system RAM.
 * IORESOURCE_ROM_SHADOW is used to associate the boot video
 * IORESOURCE_ROM_SHADOW is used to associate the boot video
 * card with this copy. On laptops this copy has to be used since
 * card with this copy. On laptops this copy has to be used since
 * the main ROM may be compressed or combined with another image.
 * the main ROM may be compressed or combined with another image.
 * See pci_map_rom() for use of this flag. Before marking the device
 * See pci_map_rom() for use of this flag. Before marking the device
 * with IORESOURCE_ROM_SHADOW check if a vga_default_device is already set
 * with IORESOURCE_ROM_SHADOW check if a vga_default_device is already set
 * by either arch cde or vga-arbitration, if so only apply the fixup to this
 * by either arch code or vga-arbitration; if so only apply the fixup to this
 * already determined primary video card.
 * already-determined primary video card.
 */
 */


static void pci_fixup_video(struct pci_dev *pdev)
static void pci_fixup_video(struct pci_dev *pdev)
@@ -32,6 +32,7 @@ static void pci_fixup_video(struct pci_dev *pdev)
	struct pci_dev *bridge;
	struct pci_dev *bridge;
	struct pci_bus *bus;
	struct pci_bus *bus;
	u16 config;
	u16 config;
	struct resource *res;


	if ((strcmp(ia64_platform_name, "dig") != 0)
	if ((strcmp(ia64_platform_name, "dig") != 0)
	    && (strcmp(ia64_platform_name, "hpzx1")  != 0))
	    && (strcmp(ia64_platform_name, "hpzx1")  != 0))
@@ -61,8 +62,18 @@ static void pci_fixup_video(struct pci_dev *pdev)
	if (!vga_default_device() || pdev == vga_default_device()) {
	if (!vga_default_device() || pdev == vga_default_device()) {
		pci_read_config_word(pdev, PCI_COMMAND, &config);
		pci_read_config_word(pdev, PCI_COMMAND, &config);
		if (config & (PCI_COMMAND_IO | PCI_COMMAND_MEMORY)) {
		if (config & (PCI_COMMAND_IO | PCI_COMMAND_MEMORY)) {
			pdev->resource[PCI_ROM_RESOURCE].flags |= IORESOURCE_ROM_SHADOW;
			res = &pdev->resource[PCI_ROM_RESOURCE];
			dev_printk(KERN_DEBUG, &pdev->dev, "Video device with shadowed ROM\n");

			pci_disable_rom(pdev);
			if (res->parent)
				release_resource(res);

			res->start = 0xC0000;
			res->end = res->start + 0x20000 - 1;
			res->flags = IORESOURCE_MEM | IORESOURCE_ROM_SHADOW |
				     IORESOURCE_PCI_FIXED;
			dev_info(&pdev->dev, "Video device with shadowed ROM at %pR\n",
				 res);
		}
		}
	}
	}
}
}
+13 −9
Original line number Original line Diff line number Diff line
@@ -429,7 +429,8 @@ sn_acpi_slot_fixup(struct pci_dev *dev)
	void __iomem *addr;
	void __iomem *addr;
	struct pcidev_info *pcidev_info = NULL;
	struct pcidev_info *pcidev_info = NULL;
	struct sn_irq_info *sn_irq_info = NULL;
	struct sn_irq_info *sn_irq_info = NULL;
	size_t image_size, size;
	struct resource *res;
	size_t size;


	if (sn_acpi_get_pcidev_info(dev, &pcidev_info, &sn_irq_info)) {
	if (sn_acpi_get_pcidev_info(dev, &pcidev_info, &sn_irq_info)) {
		panic("%s:  Failure obtaining pcidev_info for %s\n",
		panic("%s:  Failure obtaining pcidev_info for %s\n",
@@ -443,17 +444,20 @@ sn_acpi_slot_fixup(struct pci_dev *dev)
		 * of the shadowed copy, and the actual length of the ROM image.
		 * of the shadowed copy, and the actual length of the ROM image.
		 */
		 */
		size = pci_resource_len(dev, PCI_ROM_RESOURCE);
		size = pci_resource_len(dev, PCI_ROM_RESOURCE);
		addr = ioremap(pcidev_info->pdi_pio_mapped_addr[PCI_ROM_RESOURCE],

			       size);
		res = &dev->resource[PCI_ROM_RESOURCE];
		image_size = pci_get_rom_size(dev, addr, size);

		dev->resource[PCI_ROM_RESOURCE].start = (unsigned long) addr;
		pci_disable_rom(dev);
		dev->resource[PCI_ROM_RESOURCE].end =
		if (res->parent)
					(unsigned long) addr + image_size - 1;
			release_resource(res);
		dev->resource[PCI_ROM_RESOURCE].flags |= IORESOURCE_ROM_BIOS_COPY;

		res->start = pcidev_info->pdi_pio_mapped_addr[PCI_ROM_RESOURCE];
		res->end = res->start + size - 1;
		res->flags = IORESOURCE_MEM | IORESOURCE_ROM_SHADOW |
			     IORESOURCE_PCI_FIXED;
	}
	}
	sn_pci_fixup_slot(dev, pcidev_info, sn_irq_info);
	sn_pci_fixup_slot(dev, pcidev_info, sn_irq_info);
}
}

EXPORT_SYMBOL(sn_acpi_slot_fixup);
EXPORT_SYMBOL(sn_acpi_slot_fixup);




+19 −32
Original line number Original line Diff line number Diff line
@@ -150,7 +150,8 @@ void
sn_io_slot_fixup(struct pci_dev *dev)
sn_io_slot_fixup(struct pci_dev *dev)
{
{
	int idx;
	int idx;
	unsigned long addr, end, size, start;
	struct resource *res;
	unsigned long addr, size;
	struct pcidev_info *pcidev_info;
	struct pcidev_info *pcidev_info;
	struct sn_irq_info *sn_irq_info;
	struct sn_irq_info *sn_irq_info;
	int status;
	int status;
@@ -175,55 +176,41 @@ sn_io_slot_fixup(struct pci_dev *dev)


	/* Copy over PIO Mapped Addresses */
	/* Copy over PIO Mapped Addresses */
	for (idx = 0; idx <= PCI_ROM_RESOURCE; idx++) {
	for (idx = 0; idx <= PCI_ROM_RESOURCE; idx++) {

		if (!pcidev_info->pdi_pio_mapped_addr[idx])
		if (!pcidev_info->pdi_pio_mapped_addr[idx]) {
			continue;
			continue;
		}


		start = dev->resource[idx].start;
		res = &dev->resource[idx];
		end = dev->resource[idx].end;

		size = end - start;
		size = res->end - res->start;
		if (size == 0) {
		if (size == 0)
			continue;
			continue;
		}

		addr = pcidev_info->pdi_pio_mapped_addr[idx];
		res->start = pcidev_info->pdi_pio_mapped_addr[idx];
		addr = ((addr << 4) >> 4) | __IA64_UNCACHED_OFFSET;
		res->end = addr + size;
		dev->resource[idx].start = addr;
		dev->resource[idx].end = addr + size;


		/*
		/*
		 * if it's already in the device structure, remove it before
		 * if it's already in the device structure, remove it before
		 * inserting
		 * inserting
		 */
		 */
		if (dev->resource[idx].parent && dev->resource[idx].parent->child)
		if (res->parent && res->parent->child)
			release_resource(&dev->resource[idx]);
			release_resource(res);


		if (dev->resource[idx].flags & IORESOURCE_IO)
		if (res->flags & IORESOURCE_IO)
			insert_resource(&ioport_resource, &dev->resource[idx]);
			insert_resource(&ioport_resource, res);
		else
		else
			insert_resource(&iomem_resource, &dev->resource[idx]);
			insert_resource(&iomem_resource, res);
		/*
		/*
		 * If ROM, set the actual ROM image size, and mark as
		 * If ROM, mark as shadowed in PROM.
		 * shadowed in PROM.
		 */
		 */
		if (idx == PCI_ROM_RESOURCE) {
		if (idx == PCI_ROM_RESOURCE) {
			size_t image_size;
			pci_disable_rom(dev);
			void __iomem *rom;
			res->flags = IORESOURCE_MEM | IORESOURCE_ROM_SHADOW |

				     IORESOURCE_PCI_FIXED;
			rom = ioremap(pci_resource_start(dev, PCI_ROM_RESOURCE),
				      size + 1);
			image_size = pci_get_rom_size(dev, rom, size + 1);
			dev->resource[PCI_ROM_RESOURCE].end =
				dev->resource[PCI_ROM_RESOURCE].start +
				image_size - 1;
			dev->resource[PCI_ROM_RESOURCE].flags |=
						 IORESOURCE_ROM_BIOS_COPY;
		}
		}
	}
	}


	sn_pci_fixup_slot(dev, pcidev_info, sn_irq_info);
	sn_pci_fixup_slot(dev, pcidev_info, sn_irq_info);
}
}

EXPORT_SYMBOL(sn_io_slot_fixup);
EXPORT_SYMBOL(sn_io_slot_fixup);


/*
/*
+12 −7
Original line number Original line Diff line number Diff line
@@ -40,20 +40,25 @@ int __init pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)


static void pci_fixup_radeon(struct pci_dev *pdev)
static void pci_fixup_radeon(struct pci_dev *pdev)
{
{
	if (pdev->resource[PCI_ROM_RESOURCE].start)
	struct resource *res = &pdev->resource[PCI_ROM_RESOURCE];

	if (res->start)
		return;
		return;


	if (!loongson_sysconf.vgabios_addr)
	if (!loongson_sysconf.vgabios_addr)
		return;
		return;


	pdev->resource[PCI_ROM_RESOURCE].start =
	pci_disable_rom(pdev);
		loongson_sysconf.vgabios_addr;
	if (res->parent)
	pdev->resource[PCI_ROM_RESOURCE].end   =
		release_resource(res);
		loongson_sysconf.vgabios_addr + 256*1024 - 1;

	pdev->resource[PCI_ROM_RESOURCE].flags |= IORESOURCE_ROM_COPY;
	res->start = virt_to_phys((void *) loongson_sysconf.vgabios_addr);
	res->end   = res->start + 256*1024 - 1;
	res->flags = IORESOURCE_MEM | IORESOURCE_ROM_SHADOW |
		     IORESOURCE_PCI_FIXED;


	dev_info(&pdev->dev, "BAR %d: assigned %pR for Radeon ROM\n",
	dev_info(&pdev->dev, "BAR %d: assigned %pR for Radeon ROM\n",
			PCI_ROM_RESOURCE, &pdev->resource[PCI_ROM_RESOURCE]);
		 PCI_ROM_RESOURCE, res);
}
}


DECLARE_PCI_FIXUP_CLASS_FINAL(PCI_VENDOR_ID_ATI, PCI_ANY_ID,
DECLARE_PCI_FIXUP_CLASS_FINAL(PCI_VENDOR_ID_ATI, PCI_ANY_ID,
+23 −5
Original line number Original line Diff line number Diff line
@@ -297,14 +297,14 @@ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_MCH_PC1, pcie_r
 *
 *
 * The standard boot ROM sequence for an x86 machine uses the BIOS
 * The standard boot ROM sequence for an x86 machine uses the BIOS
 * to select an initial video card for boot display. This boot video
 * to select an initial video card for boot display. This boot video
 * card will have it's BIOS copied to C0000 in system RAM.
 * card will have its BIOS copied to 0xC0000 in system RAM.
 * IORESOURCE_ROM_SHADOW is used to associate the boot video
 * IORESOURCE_ROM_SHADOW is used to associate the boot video
 * card with this copy. On laptops this copy has to be used since
 * card with this copy. On laptops this copy has to be used since
 * the main ROM may be compressed or combined with another image.
 * the main ROM may be compressed or combined with another image.
 * See pci_map_rom() for use of this flag. Before marking the device
 * See pci_map_rom() for use of this flag. Before marking the device
 * with IORESOURCE_ROM_SHADOW check if a vga_default_device is already set
 * with IORESOURCE_ROM_SHADOW check if a vga_default_device is already set
 * by either arch cde or vga-arbitration, if so only apply the fixup to this
 * by either arch code or vga-arbitration; if so only apply the fixup to this
 * already determined primary video card.
 * already-determined primary video card.
 */
 */


static void pci_fixup_video(struct pci_dev *pdev)
static void pci_fixup_video(struct pci_dev *pdev)
@@ -312,6 +312,7 @@ static void pci_fixup_video(struct pci_dev *pdev)
	struct pci_dev *bridge;
	struct pci_dev *bridge;
	struct pci_bus *bus;
	struct pci_bus *bus;
	u16 config;
	u16 config;
	struct resource *res;


	/* Is VGA routed to us? */
	/* Is VGA routed to us? */
	bus = pdev->bus;
	bus = pdev->bus;
@@ -336,8 +337,18 @@ static void pci_fixup_video(struct pci_dev *pdev)
	if (!vga_default_device() || pdev == vga_default_device()) {
	if (!vga_default_device() || pdev == vga_default_device()) {
		pci_read_config_word(pdev, PCI_COMMAND, &config);
		pci_read_config_word(pdev, PCI_COMMAND, &config);
		if (config & (PCI_COMMAND_IO | PCI_COMMAND_MEMORY)) {
		if (config & (PCI_COMMAND_IO | PCI_COMMAND_MEMORY)) {
			pdev->resource[PCI_ROM_RESOURCE].flags |= IORESOURCE_ROM_SHADOW;
			res = &pdev->resource[PCI_ROM_RESOURCE];
			dev_printk(KERN_DEBUG, &pdev->dev, "Video device with shadowed ROM\n");

			pci_disable_rom(pdev);
			if (res->parent)
				release_resource(res);

			res->start = 0xC0000;
			res->end = res->start + 0x20000 - 1;
			res->flags = IORESOURCE_MEM | IORESOURCE_ROM_SHADOW |
				     IORESOURCE_PCI_FIXED;
			dev_info(&pdev->dev, "Video device with shadowed ROM at %pR\n",
				 res);
		}
		}
	}
	}
}
}
@@ -540,3 +551,10 @@ static void twinhead_reserve_killing_zone(struct pci_dev *dev)
        }
        }
}
}
DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x27B9, twinhead_reserve_killing_zone);
DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x27B9, twinhead_reserve_killing_zone);

static void pci_bdwep_bar(struct pci_dev *dev)
{
	dev->non_compliant_bars = 1;
}
DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, 0x6fa0, pci_bdwep_bar);
DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, 0x6fc0, pci_bdwep_bar);
Loading