Skip to content

Commit bb68660

Browse files
Hideo Saitopmundt
authored andcommitted
sh: Fix PCI BAR address-space wraparound.
When a SH7751R system includes a card that has wide range space like a graphics card, the pci-pci bridge controller can't set the correct address range. For example, when *lower_limit is 0xfd000000 and bar_size is 0x4000000, in the following code at arch/sh/drivers/pci/pci-auto.c, 0x0 is set in bar_value. pciauto_setup_bars() { ... bar_value = ((*lower_limit - 1) & ~(bar_size - 1)) + bar_size; ... *lower_limit = bar_value + bar_size; } As a result, 0x4000000 is set in *lower_limit, but this value is wrong. The following patch avoids this problem by checking the range of the value and refusing to update the BAR if the calculated value ends up being bogus. Signed-off-by: Hideo Saito <saito@densan.co.jp> Signed-off-by: Paul Mundt <lethal@linux-sh.org>
1 parent be52146 commit bb68660

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

‎arch/sh/drivers/pci/pci-auto.c‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,12 @@ pciauto_setup_bars(struct pci_channel *hose,
214214
continue;
215215
}
216216

217+
if (bar_value < *lower_limit || (bar_value + bar_size) >= *upper_limit) {
218+
DBG(" unavailable -- skipping, value %x size %x\n",
219+
bar_value, bar_size);
220+
continue;
221+
}
222+
217223
#ifdef CONFIG_PCI_AUTO_UPDATE_RESOURCES
218224
/* Write it out and update our limit */
219225
early_write_config_dword(hose, top_bus, current_bus, pci_devfn,

0 commit comments

Comments
 (0)