Skip to contentSkip to conversation

dm: pci: Check board information pointer in decode_regions()

PATCH New Bin Meng 2 participants 6 messages Mar 27, 2018 – Mar 30, 2018 PCI

lore
Share & tools
lore

Bin Meng

author
#0 lore raw

PATCH 1/2 dm: pci: Check board information pointer in decode_regions()

PCI enumeration may happen very early on an x86 board. The board information pointer should have been checked in decode_regions() as its space may not be allocated yet.

With this commit, Intel Galileo board boots again.

Fixes 664758c ("pci: Fix decode regions for memory banks")

---

 drivers/pci/pci-uclass.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/pci/pci-uclass.c +3 -0
index ad43e8a..9d51236 100644
@@ -876,6 +876,9 @@ static int decode_regions(struct pci_controller *hose, ofnode parent_node,
 #ifdef CONFIG_NR_DRAM_BANKS
 	bd_t *bd = gd->bd;
 
+	if (!bd)
+		return 0;
+
 	for (i = 0; i < CONFIG_NR_DRAM_BANKS; ++i) {
 		if (bd->bi_dram[i].size) {
 			pci_set_region(hose->regions + hose->region_count++,
Signature · 1 line
2.7.4
author
#1 lore raw

PATCH 2/2 dm: pci: Avoid setting a PCI region that has 0 size

It makes no sense to set a PCI region that has 0 size.

---

 drivers/pci/pci-uclass.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/pci/pci-uclass.c +3 -2
index 9d51236..a2e8296 100644
@@ -897,8 +897,9 @@ static int decode_regions(struct pci_controller *hose, ofnode parent_node,
 #endif
 	if (gd->pci_ram_top && gd->pci_ram_top < base + size)
 		size = gd->pci_ram_top - base;
-	pci_set_region(hose->regions + hose->region_count++, base, base,
-		       size, PCI_REGION_MEM | PCI_REGION_SYS_MEMORY);
+	if (size)
+		pci_set_region(hose->regions + hose->region_count++, base,
+			base, size, PCI_REGION_MEM | PCI_REGION_SYS_MEMORY);
 #endif
 
 	return 0;
Signature · 1 line
2.7.4
author
#3 lore raw

PATCH 2/2 dm: pci: Avoid setting a PCI region that has 0 size

Quoted 10 lines · Simon Glass
Quoted 7 lines · Bin Meng

It makes no sense to set a PCI region that has 0 size.

---

 drivers/pci/pci-uclass.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

applied to u-boot-x86, thanks!

#4 lore raw

PATCH 1/2 dm: pci: Check board information pointer in decode_regions()

In reply to Bin Meng
Quoted 4 lines · Bin Meng

PCI enumeration may happen very early on an x86 board. The board information pointer should have been checked in decode_regions() as its space may not be allocated yet.

Quoted 8 lines

With this commit, Intel Galileo board boots again.

Fixes 664758c ("pci: Fix decode regions for memory banks")

---

 drivers/pci/pci-uclass.c | 3 +++
 1 file changed, 3 insertions(+)
author
#5 lore raw

PATCH 1/2 dm: pci: Check board information pointer in decode_regions()

Quoted 7 lines · Simon Glass
Quoted 6 lines · Bin Meng

PCI enumeration may happen very early on an x86 board. The board information pointer should have been checked in decode_regions() as its space may not be allocated yet.

With this commit, Intel Galileo board boots again.

Quoted 8 lines
Quoted 6 lines
Fixes 664758c ("pci: Fix decode regions for memory banks")

---

 drivers/pci/pci-uclass.c | 3 +++
 1 file changed, 3 insertions(+)

applied to u-boot-x86, thanks!