diff mbox series

[v3] PCI: Increase maximum PCIe physical function number to 7 for non-ARI devices

Message ID 20240219112422.54657-1-beanhuo@iokpp.de
State New
Headers show
Series [v3] PCI: Increase maximum PCIe physical function number to 7 for non-ARI devices | expand

Commit Message

Bean Huo Feb. 19, 2024, 11:24 a.m. UTC
From: Bean Huo <beanhuo@micron.com>

As per PCIe r6.2, sec 6.13 titled "Alternative Routing-ID Interpretation
(ARI)", up to 8 [fn # 0..7] Physical Functions(PFs) are allowed in an
non-ARI capable device. Previously, our implementation erroneously limited
the maximum number of PFs to 7 for endpoints without ARI support.

This patch corrects the maximum PF count to adhere to the PCIe specification
by allowing up to 8 PFs on non-ARI capable devices. This change ensures better
compliance with the standard and improves compatibility with devices relying
on this specification.

Fixes: c3df83e01a96 ("PCI: Clean up pci_scan_slot()")
Cc: stable@vger.kernel.org
Signed-off-by: Bean Huo <beanhuo@micron.com>
---
Changelog:
	v2--v3:
		1. Update commit messag 
	v1--v2:
		1. Add Fixes tag
		2. Modify commit message
---
 drivers/pci/probe.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Siddharth Vadapalli Feb. 19, 2024, noon UTC | #1
On 24/02/19 12:24PM, Bean Huo wrote:
> From: Bean Huo <beanhuo@micron.com>
> 
> As per PCIe r6.2, sec 6.13 titled "Alternative Routing-ID Interpretation
> (ARI)", up to 8 [fn # 0..7] Physical Functions(PFs) are allowed in an
> non-ARI capable device. Previously, our implementation erroneously limited
> the maximum number of PFs to 7 for endpoints without ARI support.
> 
> This patch corrects the maximum PF count to adhere to the PCIe specification
> by allowing up to 8 PFs on non-ARI capable devices. This change ensures better
> compliance with the standard and improves compatibility with devices relying
> on this specification.

The function "next_fn()" seems to provide the next valid function.
Therefore, if the current function is 0 (fn = 0), then the next valid
function will be 1 which is returned by next_fn(). It extends similarly
until the case where current function is 6 (fn = 6) which shall return
the next valid function as 7. So all 8 PFs are still treated as valid
and there doesn't seem to be any limitation. Only in the case where the
EP doesn't support ARI (there is no function 8 (fn = 8)), the call to
next_fn() with the fn parameter set to 7, will return -ENODEV which
seems to be the expected behavior.

Regards,
Siddharth.

> 
> Fixes: c3df83e01a96 ("PCI: Clean up pci_scan_slot()")
> Cc: stable@vger.kernel.org
> Signed-off-by: Bean Huo <beanhuo@micron.com>
> ---
> Changelog:
> 	v2--v3:
> 		1. Update commit messag 
> 	v1--v2:
> 		1. Add Fixes tag
> 		2. Modify commit message
> ---
>  drivers/pci/probe.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
> index ed6b7f48736a..8c3d0f63bc13 100644
> --- a/drivers/pci/probe.c
> +++ b/drivers/pci/probe.c
> @@ -2630,7 +2630,8 @@ static int next_fn(struct pci_bus *bus, struct pci_dev *dev, int fn)
>  	if (pci_ari_enabled(bus))
>  		return next_ari_fn(bus, dev, fn);
>  
> -	if (fn >= 7)
> +	/* If EP does not support ARI, the maximum number of functions should be 7 */
> +	if (fn > 7)
>  		return -ENODEV;
>  	/* only multifunction devices may have more functions */
>  	if (dev && !dev->multifunction)
> -- 
> 2.34.1
> 
>
Bean Huo Feb. 19, 2024, 12:09 p.m. UTC | #2
On Mon, 2024-02-19 at 17:30 +0530, Siddharth Vadapalli wrote:
> The function "next_fn()" seems to provide the next valid function.
> Therefore, if the current function is 0 (fn = 0), then the next valid
> function will be 1 which is returned by next_fn(). It extends
> similarly
> until the case where current function is 6 (fn = 6) which shall
> return
> the next valid function as 7. So all 8 PFs are still treated as valid
> and there doesn't seem to be any limitation. Only in the case where
> the
> EP doesn't support ARI (there is no function 8 (fn = 8)), the call to
> next_fn() with the fn parameter set to 7, will return -ENODEV which
> seems to be the expected behavior.
> 
> Regards,
> Siddharth.

yes, you are right, the fn 7 has no next_fn, hence should return -
ENODEV. 

ignore this patch!

kind regards,
Bean
diff mbox series

Patch

diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index ed6b7f48736a..8c3d0f63bc13 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -2630,7 +2630,8 @@  static int next_fn(struct pci_bus *bus, struct pci_dev *dev, int fn)
 	if (pci_ari_enabled(bus))
 		return next_ari_fn(bus, dev, fn);
 
-	if (fn >= 7)
+	/* If EP does not support ARI, the maximum number of functions should be 7 */
+	if (fn > 7)
 		return -ENODEV;
 	/* only multifunction devices may have more functions */
 	if (dev && !dev->multifunction)