|
@@ -114,6 +114,9 @@ static bool pcie_ari_disabled;
|
|
/* If set, the PCIe ATS capability will not be used. */
|
|
/* If set, the PCIe ATS capability will not be used. */
|
|
static bool pcie_ats_disabled;
|
|
static bool pcie_ats_disabled;
|
|
|
|
|
|
|
|
+/* If set, the PCI config space of each device is printed during boot. */
|
|
|
|
+bool pci_early_dump;
|
|
|
|
+
|
|
bool pci_ats_disabled(void)
|
|
bool pci_ats_disabled(void)
|
|
{
|
|
{
|
|
return pcie_ats_disabled;
|
|
return pcie_ats_disabled;
|
|
@@ -1332,6 +1335,33 @@ static void pci_restore_config_space(struct pci_dev *pdev)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+static void pci_restore_rebar_state(struct pci_dev *pdev)
|
|
|
|
+{
|
|
|
|
+ unsigned int pos, nbars, i;
|
|
|
|
+ u32 ctrl;
|
|
|
|
+
|
|
|
|
+ pos = pci_find_ext_capability(pdev, PCI_EXT_CAP_ID_REBAR);
|
|
|
|
+ if (!pos)
|
|
|
|
+ return;
|
|
|
|
+
|
|
|
|
+ pci_read_config_dword(pdev, pos + PCI_REBAR_CTRL, &ctrl);
|
|
|
|
+ nbars = (ctrl & PCI_REBAR_CTRL_NBAR_MASK) >>
|
|
|
|
+ PCI_REBAR_CTRL_NBAR_SHIFT;
|
|
|
|
+
|
|
|
|
+ for (i = 0; i < nbars; i++, pos += 8) {
|
|
|
|
+ struct resource *res;
|
|
|
|
+ int bar_idx, size;
|
|
|
|
+
|
|
|
|
+ pci_read_config_dword(pdev, pos + PCI_REBAR_CTRL, &ctrl);
|
|
|
|
+ bar_idx = ctrl & PCI_REBAR_CTRL_BAR_IDX;
|
|
|
|
+ res = pdev->resource + bar_idx;
|
|
|
|
+ size = order_base_2((resource_size(res) >> 20) | 1) - 1;
|
|
|
|
+ ctrl &= ~PCI_REBAR_CTRL_BAR_SIZE;
|
|
|
|
+ ctrl |= size << PCI_REBAR_CTRL_BAR_SHIFT;
|
|
|
|
+ pci_write_config_dword(pdev, pos + PCI_REBAR_CTRL, ctrl);
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* pci_restore_state - Restore the saved state of a PCI device
|
|
* pci_restore_state - Restore the saved state of a PCI device
|
|
* @dev: - PCI device that we're dealing with
|
|
* @dev: - PCI device that we're dealing with
|
|
@@ -1347,6 +1377,7 @@ void pci_restore_state(struct pci_dev *dev)
|
|
pci_restore_pri_state(dev);
|
|
pci_restore_pri_state(dev);
|
|
pci_restore_ats_state(dev);
|
|
pci_restore_ats_state(dev);
|
|
pci_restore_vc_state(dev);
|
|
pci_restore_vc_state(dev);
|
|
|
|
+ pci_restore_rebar_state(dev);
|
|
|
|
|
|
pci_cleanup_aer_error_status_regs(dev);
|
|
pci_cleanup_aer_error_status_regs(dev);
|
|
|
|
|
|
@@ -3311,7 +3342,7 @@ int pci_rebar_get_current_size(struct pci_dev *pdev, int bar)
|
|
return pos;
|
|
return pos;
|
|
|
|
|
|
pci_read_config_dword(pdev, pos + PCI_REBAR_CTRL, &ctrl);
|
|
pci_read_config_dword(pdev, pos + PCI_REBAR_CTRL, &ctrl);
|
|
- return (ctrl & PCI_REBAR_CTRL_BAR_SIZE) >> 8;
|
|
|
|
|
|
+ return (ctrl & PCI_REBAR_CTRL_BAR_SIZE) >> PCI_REBAR_CTRL_BAR_SHIFT;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -3334,7 +3365,7 @@ int pci_rebar_set_size(struct pci_dev *pdev, int bar, int size)
|
|
|
|
|
|
pci_read_config_dword(pdev, pos + PCI_REBAR_CTRL, &ctrl);
|
|
pci_read_config_dword(pdev, pos + PCI_REBAR_CTRL, &ctrl);
|
|
ctrl &= ~PCI_REBAR_CTRL_BAR_SIZE;
|
|
ctrl &= ~PCI_REBAR_CTRL_BAR_SIZE;
|
|
- ctrl |= size << 8;
|
|
|
|
|
|
+ ctrl |= size << PCI_REBAR_CTRL_BAR_SHIFT;
|
|
pci_write_config_dword(pdev, pos + PCI_REBAR_CTRL, ctrl);
|
|
pci_write_config_dword(pdev, pos + PCI_REBAR_CTRL, ctrl);
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
@@ -6060,6 +6091,8 @@ static int __init pci_setup(char *str)
|
|
pcie_ats_disabled = true;
|
|
pcie_ats_disabled = true;
|
|
} else if (!strcmp(str, "noaer")) {
|
|
} else if (!strcmp(str, "noaer")) {
|
|
pci_no_aer();
|
|
pci_no_aer();
|
|
|
|
+ } else if (!strcmp(str, "earlydump")) {
|
|
|
|
+ pci_early_dump = true;
|
|
} else if (!strncmp(str, "realloc=", 8)) {
|
|
} else if (!strncmp(str, "realloc=", 8)) {
|
|
pci_realloc_get_opt(str + 8);
|
|
pci_realloc_get_opt(str + 8);
|
|
} else if (!strncmp(str, "realloc", 7)) {
|
|
} else if (!strncmp(str, "realloc", 7)) {
|