From nobody Tue Dec 16 19:42:42 2025 Received: from zg8tmtyylji0my4xnjqumte4.icoremail.net (zg8tmtyylji0my4xnjqumte4.icoremail.net [162.243.164.118]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3F186EEC8; Fri, 21 Feb 2025 01:10:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=162.243.164.118 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740100250; cv=none; b=L4oeFtoyRQIzWKbqpVRKLzWakoRCai/8EFlGAoNTNtb7zH6aTkU2YD89RZygTjoje6VDZchen8bLueIC19Aa+fAqfLGGQ0aFq7p/mhFVAtWSGkUMX3xlTITnMHGfY+w3a8vl0aLSzbjigTZIOfJO8l6sgsHXJk3EyaQ/s2GIlWI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740100250; c=relaxed/simple; bh=yskr+PmFMuRPFwrqPgixSoheIXchw7FPee0esHDRGTU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=h4bnywoxbsYJ8vuq7oifWmYWBl0UnMXbLFgUrHBTipUaYGzYv2CgF5JakoW32fTmNUJzBWMTkE+QnXbGYunNDn7rNw7DA9Mo4FQhWL9HkagK8V8QcqKrK7KApx3hrouC83HWhuRy1AYMfr14Crw79BNzXlnuylQ5jjlW+A/sUWI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=phytium.com.cn; spf=pass smtp.mailfrom=phytium.com.cn; arc=none smtp.client-ip=162.243.164.118 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=phytium.com.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=phytium.com.cn Received: from prodtpl.icoremail.net (unknown [10.12.1.20]) by hzbj-icmmx-7 (Coremail) with SMTP id AQAAfwA3xsiD0rdnhFxEBA--.57122S2; Fri, 21 Feb 2025 09:10:28 +0800 (CST) Received: from localhost.localdomain (unknown [219.142.137.151]) by mail (Coremail) with SMTP id AQAAfwAXGYV_0rdnkdYtAA--.966S2; Fri, 21 Feb 2025 09:10:25 +0800 (CST) From: Zhiyuan Dai To: cassel@kernel.org Cc: bhelgaas@google.com, christian.koenig@amd.com, daizhiyuan@phytium.com.cn, helgaas@kernel.org, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org Subject: [PATCH v3] PCI: Update Resizable BAR Capability Register fields Date: Fri, 21 Feb 2025 09:09:21 +0800 Message-ID: <20250221010951.361570-1-daizhiyuan@phytium.com.cn> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: AQAAfwAXGYV_0rdnkdYtAA--.966S2 X-CM-SenderInfo: hgdl6xpl1xt0o6sk53xlxphulrpou0/ Authentication-Results: hzbj-icmmx-7; spf=neutral smtp.mail=daizhiyuan @phytium.com.cn; X-Coremail-Antispam: 1Uk129KBjvJXoW7ArWkArWDGF1kWw48Gr47XFb_yoW8Kry5pr 4DCa97Kr4rKFW29w1kZ3W0yw45K39rZFy5CrWI93sruFnIk3Z2qF4DKay5ta47Jrs7ZF4Y qFnFv345u3s8JaUanT9S1TB71UUUUUDqnTZGkaVYY2UrUUUUj1kv1TuYvTs0mT0YCTnIWj DUYxn0WfASr-VFAU7a7-sFnT9fnUUIcSsGvfJ3UbIYCTnIWIevJa73UjIFyTuYvj4RJUUU UUUUU PCI Express Base Spec r6.0 defines BAR size up to 8 EB (2^63 bytes), but supporting anything bigger than 128TB requires changes to=20 pci_rebar_get_possible_sizes() to read the additional Capability bits=20 from the Control register. If 8EB support is required, callers will need to be updated to handle u64=20 instead of u32. For now, support is limited to 128TB, and support for=20 sizes greater than 128TB can be deferred to a later time. Signed-off-by: Zhiyuan Dai Reviewed-by: Christian K=C3=B6nig Reviewed-by: Niklas Cassel --- drivers/pci/pci.c | 4 ++-- include/uapi/linux/pci_regs.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 661f98c6c63a..77b9ceefb4e1 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -3752,7 +3752,7 @@ static int pci_rebar_find_pos(struct pci_dev *pdev, i= nt bar) * @bar: BAR to query * * Get the possible sizes of a resizable BAR as bitmask defined in the spec - * (bit 0=3D1MB, bit 19=3D512GB). Returns 0 if BAR isn't resizable. + * (bit 0=3D1MB, bit 31=3D128TB). Returns 0 if BAR isn't resizable. */ u32 pci_rebar_get_possible_sizes(struct pci_dev *pdev, int bar) { @@ -3800,7 +3800,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=3D1MB, 19=3D512GB) + * @size: new size as defined in the spec (0=3D1MB, 31=3D128TB) * * Set the new size of a BAR as defined in the spec. * Returns zero if resizing was successful, error code otherwise. diff --git a/include/uapi/linux/pci_regs.h b/include/uapi/linux/pci_regs.h index 1601c7ed5fab..ce99d4f34ce5 100644 --- a/include/uapi/linux/pci_regs.h +++ b/include/uapi/linux/pci_regs.h @@ -1013,7 +1013,7 @@ =20 /* 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 */ --=20 2.43.0