Commit ef7e64c8 authored by Tianli Xiong's avatar Tianli Xiong Committed by Hongchen Zhang
Browse files

LoongArch: Fixed some pcie card not scanning properly

LoongArch inclusion
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/I6BWFP



--------------------------------

Fix some pcie card not scanning properly when
bus number is inconsistent during firmware and
kernel scan phases.

Signed-off-by: default avatarliuyun <liuyun@loongson.cn>
Signed-off-by: default avatarTianli Xiong <xiongtianli@loongson.cn>
Change-Id: Iac9c07463569ca08da93ab0fa279b1880206e816
parent 60c8da76
Loading
Loading
Loading
Loading
+32 −2
Original line number Diff line number Diff line
@@ -216,6 +216,36 @@ static void __iomem *pci_loongson_map_bus(struct pci_bus *bus,
	return NULL;
}

static int pci_loongson_config_read(struct pci_bus *bus, unsigned int devfn,
			    int where, int size, u32 *val)
{
	void __iomem *addr;

	addr = bus->ops->map_bus(bus, devfn, where);
	if (!addr) {
		*val = ~0;
		return PCIBIOS_DEVICE_NOT_FOUND;
	}

	if (size == 1)
		*val = readb(addr);
	else if (size == 2)
		*val = readw(addr);
	else
		*val = readl(addr);
	/*
	 * fix some pcie card not scanning properly when bus number is
	 * inconsistent during firmware and kernel scan phases.
	 */
	if (*val == 0x0 && where == PCI_VENDOR_ID) {
		writel(*val, addr);
		*val = readl(addr);
	}


	return PCIBIOS_SUCCESSFUL;
}

#ifdef CONFIG_OF

static int loongson_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
@@ -239,7 +269,7 @@ static int loongson_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
/* LS2K/LS7A accept 8/16/32-bit PCI config operations */
static struct pci_ops loongson_pci_ops = {
	.map_bus = pci_loongson_map_bus,
	.read	= pci_generic_config_read,
	.read	= pci_loongson_config_read,
	.write	= pci_generic_config_write,
};

@@ -366,7 +396,7 @@ const struct pci_ecam_ops loongson_pci_ecam_ops = {
	.init	   = loongson_pci_ecam_init,
	.pci_ops   = {
		.map_bus = pci_loongson_map_bus,
		.read	 = pci_generic_config_read,
		.read	 = pci_loongson_config_read,
		.write	 = pci_generic_config_write,
	}
};