diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 99ef2774b9d05ff46c3ca9a80727fdf3e18af3b3..09b03cfba8894955ffc24bc08ea3244d44a0ac6b 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -3603,7 +3603,14 @@ u32 pci_rebar_get_possible_sizes(struct pci_dev *pdev, int bar)
 		return 0;
 
 	pci_read_config_dword(pdev, pos + PCI_REBAR_CAP, &cap);
-	return (cap & PCI_REBAR_CAP_SIZES) >> 4;
+	cap &= PCI_REBAR_CAP_SIZES;
+
+	/* Sapphire RX 5600 XT Pulse has an invalid cap dword for BAR 0 */
+	if (pdev->vendor == PCI_VENDOR_ID_ATI && pdev->device == 0x731f &&
+	    bar == 0 && cap == 0x7000)
+		cap = 0x3f000;
+
+	return cap >> 4;
 }
 EXPORT_SYMBOL(pci_rebar_get_possible_sizes);