drivers: pci: initialise class to 0 before reading
PATCH 1/1 drivers: pci: initialise class to 0 before reading
Otherwise, uninitialised memory from the upper 32 bits can end up in find_id.class, and this causes bugs later when looking for a driver for the class.
--- drivers/pci/pci-uclass.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pci/pci-uclass.c +1 -1
@@ -773,7 +773,7 @@ int pci_bind_bus_devices(struct udevice *bus) bdf += PCI_BDF(0, 0, 1)) {struct pci_child_platdata *pplat;struct udevice *dev; -ulong class; +ulong class =0 ;if (!PCI_FUNC (bdf)) found_multi = false;
Signature · 1 line
2.17.2 (Apple Git-113)
PATCH 1/1 drivers: pci: initialise class to 0 before reading
Quoted 15 lines · Hugh Cole-Baker
Otherwise, uninitialised memory from the upper 32 bits can end up in find_id.class, and this causes bugs later when looking for a driver for the class.
Signed-off-by Hugh Cole-Baker <[email protected]>--- drivers/pci/pci-uclass.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/pci/pci-uclass.c +0
-0
drivers/pci/pci-uclass.c int pci_bind_bus_devices(struct udevice *bus)
Quoted 9 lines
drivers/pci/pci-uclass.c +1
-2@@ -773,7 +773,7 @@ int pci_bind_bus_devices(struct udevice *bus) bdf += PCI_BDF(0, 0, 1)) {struct pci_child_platdata *pplat;struct udevice *dev; -ulong class; +ulong class =0 ;if (!PCI_FUNC (bdf)) found_multi = false; --
I see class is initialized in the call to:
pci_bus_read_config(bus, bdf, PCI_CLASS_REVISION, &class,
PCI_SIZE_32);
class >>= 8;
Regards,
Bin
PATCH 1/1 drivers: pci: initialise class to 0 before reading
Hi Bin,
Quoted 30 lines · Bin Meng
Quoted 15 lines · Hugh Cole-Baker
Otherwise, uninitialised memory from the upper 32 bits can end up in find_id.class, and this causes bugs later when looking for a driver for the class.
Signed-off-by Hugh Cole-Baker <[email protected]>---
drivers/pci/pci-uclass.c| 2 +-1 file changed, 1 insertion(+), 1 deletion(-)drivers/pci/pci-uclass.c +0
-0drivers/pci/pci-uclass.c int pci_bind_bus_devices(struct udevice *bus)
Quoted 9 lines
drivers/pci/pci-uclass.c +1
-2@@ -773,7 +773,7 @@ int pci_bind_bus_devices(struct udevice *bus) bdf += PCI_BDF(0, 0, 1)) {struct pci_child_platdata *pplat;struct udevice *dev; -ulong class; +ulong class =0 ;if (!PCI_FUNC (bdf)) found_multi = false; --I see class is initialized in the call to:
Quoted 4 lines
pci_bus_read_config(bus, bdf,
PCI_CLASS_REVISION, &class,
PCI_SIZE_32);
class >>= 8;
Maybe the driver I'm working with is doing its read_config wrongly? I'm trying to use this Rockchip PCIe driver [1] with upstream u-boot. The driver casts &class to u32*, uses readl() and only sets the lower 32 bits. I was assuming that this was normal for a read of PCI_SIZE_32. However, looking at some of the other drivers, it seems like it should be using pci_conv_32_to_size() instead?
Thanks,
Hugh
Quoted 2 lines
Regards,
Bin
PATCH 1/1 drivers: pci: initialise class to 0 before reading
Hi Hugh,
Quoted 38 lines · Hugh Cole-Baker
Hi Bin,
Quoted 30 lines · Bin Meng
Quoted 15 lines · Hugh Cole-Baker
Otherwise, uninitialised memory from the upper 32 bits can end up in find_id.class, and this causes bugs later when looking for a driver for the class.
Signed-off-by Hugh Cole-Baker <[email protected]>---
drivers/pci/pci-uclass.c| 2 +-1 file changed, 1 insertion(+), 1 deletion(-)drivers/pci/pci-uclass.c +0
-0drivers/pci/pci-uclass.c int pci_bind_bus_devices(struct udevice *bus)
Quoted 9 lines
drivers/pci/pci-uclass.c +1
-2@@ -773,7 +773,7 @@ int pci_bind_bus_devices(struct udevice *bus) bdf += PCI_BDF(0, 0, 1)) {struct pci_child_platdata *pplat;struct udevice *dev; -ulong class; +ulong class =0 ;if (!PCI_FUNC (bdf)) found_multi = false; --I see class is initialized in the call to:
Quoted 4 lines
pci_bus_read_config(bus, bdf,
PCI_CLASS_REVISION, &class,
PCI_SIZE_32);
class >>= 8;
Quoted 7 lines
Maybe the driver I'm working with is doing its
read_configwrongly? I'm trying to use this Rockchip PCIe driver [1] with upstream u-boot. The driver casts &class to u32*, usesreadl()and only sets the lower 32 bits. I was assuming that this was normal for a read ofPCI_SIZE_32. However, looking at some of the other drivers, it seems like it should be usingpci_conv_32_to_size()instead?
The bug should be that
u32 *val should be declared as ulong *val.
Quoted 2 lines
Regards,
Bin