[PATCH] PCI: Fix calculation of bridge window's size

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



There are some 0 resource size pci devices, and it leads to the
accumulator fails to maintain the correct value.
It results in a strange issue on my machine that xhci_hcd failed to init.
   [    2.437278] xhci_hcd 0000:05:00.0: init 0000:05:00.0 fail, -16
   [    2.437300] xhci_hcd: probe of 0000:05:00.0 failed with error -16

To fix this, check if the resource size equals to 0, doesn't increase size.

Fixes: c9c75143a596 ("PCI: Fix calculation of bridge window's size and alignment")
CC: stable@xxxxxxxxxxxxxxx # 4.14+

Signed-off-by: AceLan Kao <acelan.kao@xxxxxxxxxxxxx>
---
 drivers/pci/setup-bus.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c
index 79b1824e83b4..ae05dde8c6e3 100644
--- a/drivers/pci/setup-bus.c
+++ b/drivers/pci/setup-bus.c
@@ -1061,7 +1061,8 @@ static int pbus_size_mem(struct pci_bus *bus, unsigned long mask,
 				r->flags = 0;
 				continue;
 			}
-			size += max(r_size, align);
+			if (r_size != 0)
+				size += max(r_size, align);
 			/* Exclude ranges with size > align from
 			   calculation of the alignment. */
 			if (r_size <= align)
-- 
2.17.1




[Index of Archives]     [DMA Engine]     [Linux Coverity]     [Linux USB]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Greybus]

  Powered by Linux