diff --git a/drivers/thunderbolt/nhi.c b/drivers/thunderbolt/nhi.c index 0f795ea58756..71ce48b644f2 100644 --- a/drivers/thunderbolt/nhi.c +++ b/drivers/thunderbolt/nhi.c @@ -1185,6 +1185,7 @@ static struct tb *nhi_select_cm(struct tb_nhi *nhi) int nhi_probe(struct tb_nhi *nhi) { + struct pci_dev *pdev = to_pci_dev(nhi->dev); struct device *dev = nhi->dev; struct tb *tb; int res; @@ -1195,6 +1196,9 @@ int nhi_probe(struct tb_nhi *nhi) if (!nhi->ops->init_interrupts) return dev_err_probe(dev, -EINVAL, "missing required NHI ops\n"); + /* QEMU PCI emulation glitch? */ + BUG_ON(pci_resource_len(pdev, 0) < REG_CAPS); + nhi->hop_count = ioread32(nhi->iobase + REG_CAPS) & 0x3ff; dev_dbg(dev, "total paths: %d\n", nhi->hop_count);