PCI: Increase Resizable BAR support from 512 GB to 128 TB
authorZhiyuan Dai <daizhiyuan@phytium.com.cn>
Fri, 7 Mar 2025 05:35:29 +0000 (13:35 +0800)
committerBjorn Helgaas <bhelgaas@google.com>
Fri, 7 Mar 2025 17:23:34 +0000 (11:23 -0600)
Per PCIe r6.0, sec 7.8.6.2, devices can advertise Resizable BAR sizes up to
128 TB in the Resizable BAR Capability register.  Larger sizes can be
advertised via the Capability register, but that requires an API change.

Update pci_rebar_get_possible_sizes() and pbus_size_mem() to increase the
sizes we currently support from 512 GB to 128 TB.

Link: https://lore.kernel.org/r/20250307053535.44918-1-daizhiyuan@phytium.com.cn
Signed-off-by: Zhiyuan Dai <daizhiyuan@phytium.com.cn>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
drivers/pci/pci.c
drivers/pci/setup-bus.c
include/uapi/linux/pci_regs.h

index c4f710f782f6ab7d6ef058ed17e1a3ae872a721e..72ac91e359aafa42f1ee91f393bf9b25a9b166e9 100644 (file)
@@ -3757,7 +3757,7 @@ static int pci_rebar_find_pos(struct pci_dev *pdev, int bar)
  * @bar: BAR to query
  *
  * Get the possible sizes of a resizable BAR as bitmask defined in the spec
- * (bit 0=1MB, bit 19=512GB). Returns 0 if BAR isn't resizable.
+ * (bit 0=1MB, bit 31=128TB). Returns 0 if BAR isn't resizable.
  */
 u32 pci_rebar_get_possible_sizes(struct pci_dev *pdev, int bar)
 {
@@ -3805,7 +3805,7 @@ int pci_rebar_get_current_size(struct pci_dev *pdev, int bar)
  * pci_rebar_set_size - set a new size for a BAR
  * @pdev: PCI device
  * @bar: BAR to set size to
- * @size: new size as defined in the spec (0=1MB, 19=512GB)
+ * @size: new size as defined in the spec (0=1MB, 31=128TB)
  *
  * Set the new size of a BAR as defined in the spec.
  * Returns zero if resizing was successful, error code otherwise.
index aa36e2d15f3287cb1f1e96fc07d4de16355dfba7..58f28e4e24b31745b1afbfa726e444fd42e67e4f 100644 (file)
@@ -1159,7 +1159,7 @@ static int pbus_size_mem(struct pci_bus *bus, unsigned long mask,
 {
        struct pci_dev *dev;
        resource_size_t min_align, win_align, align, size, size0, size1 = 0;
-       resource_size_t aligns[24]; /* Alignments from 1MB to 8TB */
+       resource_size_t aligns[28]; /* Alignments from 1MB to 128TB */
        int order, max_order;
        struct resource *b_res = find_bus_resource_of_type(bus,
                                        mask | IORESOURCE_PREFETCH, type);
index 3445c4970e4d8e72f426071032adf82799aedbf7..3c2558b98d22571fa44e93be2495eb82034a4acc 100644 (file)
 
 /* Resizable BARs */
 #define PCI_REBAR_CAP          4       /* capability register */
-#define  PCI_REBAR_CAP_SIZES           0x00FFFFF0  /* supported BAR sizes */
+#define  PCI_REBAR_CAP_SIZES           0xFFFFFFF0  /* supported BAR sizes */
 #define PCI_REBAR_CTRL         8       /* control register */
 #define  PCI_REBAR_CTRL_BAR_IDX                0x00000007  /* BAR index */
 #define  PCI_REBAR_CTRL_NBAR_MASK      0x000000E0  /* # of resizable BARs */