[PATCH v2] powerpc/pseries/pci: Fix misleading VF limit error message

Jiangshan Yi posted 1 patch 1 month, 2 weeks ago
arch/powerpc/platforms/pseries/pci.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
[PATCH v2] powerpc/pseries/pci: Fix misleading VF limit error message
Posted by Jiangshan Yi 1 month, 2 weeks ago
When the number of requested VFs exceeds MAX_VFS_FOR_MAP_PE, the
message prints that limit but labels it "Configurable VFs". Report
the configurable VF limit and the PE mapping limit with separate
error messages.

Suggested-by: Christophe Leroy <chleroy@kernel.org>
Signed-off-by: Jiangshan Yi <yijiangshan@kylinos.cn>
---
v2:
- rework as suggested by Christophe Leroy: split the two limit checks
  into separate blocks, each with its own dev_err and error return

 arch/powerpc/platforms/pseries/pci.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/arch/powerpc/platforms/pseries/pci.c b/arch/powerpc/platforms/pseries/pci.c
index d11a64a086c1..6fc13f4a79a3 100644
--- a/arch/powerpc/platforms/pseries/pci.c
+++ b/arch/powerpc/platforms/pseries/pci.c
@@ -132,11 +132,14 @@ static int pseries_pci_sriov_enable(struct pci_dev *pdev, u16 num_vfs)
 
 	/* First integer stores max config */
 	max_config_vfs = of_read_number(&max_vfs[0], 1);
-	if (max_config_vfs < num_vfs || num_vfs > MAX_VFS_FOR_MAP_PE) {
-		dev_err(&pdev->dev,
-			"Num VFs %x > %x Configurable VFs\n",
-			num_vfs, (num_vfs > MAX_VFS_FOR_MAP_PE) ?
-			MAX_VFS_FOR_MAP_PE : max_config_vfs);
+	if (max_config_vfs < num_vfs) {
+		dev_err(&pdev->dev, "Num VFs %x > %x Configurable VFs\n",
+			num_vfs, max_config_vfs);
+		return -EINVAL;
+	}
+	if (num_vfs > MAX_VFS_FOR_MAP_PE) {
+		dev_err(&pdev->dev, "Num VFs %x > %x PE mapping limit\n",
+			num_vfs, MAX_VFS_FOR_MAP_PE);
 		return -EINVAL;
 	}
 
-- 
2.25.1
Re: [PATCH v2] powerpc/pseries/pci: Fix misleading VF limit error message
Posted by Madhavan Srinivasan 2 weeks, 5 days ago
On Thu, 13 Aug 2026 14:37:31 +0800, Jiangshan Yi wrote:
> When the number of requested VFs exceeds MAX_VFS_FOR_MAP_PE, the
> message prints that limit but labels it "Configurable VFs". Report
> the configurable VF limit and the PE mapping limit with separate
> error messages.
> 
> 

Applied to powerpc/fixes.

[1/1] powerpc/pseries/pci: Fix misleading VF limit error message
      https://git.kernel.org/powerpc/c/b1824233b19c1dffdb5e81283805a9e52e763caa

cheers
Re: [PATCH v2] powerpc/pseries/pci: Fix misleading VF limit error message
Posted by Christophe Leroy (CS GROUP) 1 month, 2 weeks ago

Le 13/08/2026 à 08:37, Jiangshan Yi a écrit :
> When the number of requested VFs exceeds MAX_VFS_FOR_MAP_PE, the
> message prints that limit but labels it "Configurable VFs". Report
> the configurable VF limit and the PE mapping limit with separate
> error messages.
> 
> Suggested-by: Christophe Leroy <chleroy@kernel.org>
> Signed-off-by: Jiangshan Yi <yijiangshan@kylinos.cn>

reviewed-by: Christophe Leroy <chleroy@kernel.org>

> ---
> v2:
> - rework as suggested by Christophe Leroy: split the two limit checks
>    into separate blocks, each with its own dev_err and error return
> 
>   arch/powerpc/platforms/pseries/pci.c | 13 ++++++++-----
>   1 file changed, 8 insertions(+), 5 deletions(-)
> 
> diff --git a/arch/powerpc/platforms/pseries/pci.c b/arch/powerpc/platforms/pseries/pci.c
> index d11a64a086c1..6fc13f4a79a3 100644
> --- a/arch/powerpc/platforms/pseries/pci.c
> +++ b/arch/powerpc/platforms/pseries/pci.c
> @@ -132,11 +132,14 @@ static int pseries_pci_sriov_enable(struct pci_dev *pdev, u16 num_vfs)
>   
>   	/* First integer stores max config */
>   	max_config_vfs = of_read_number(&max_vfs[0], 1);
> -	if (max_config_vfs < num_vfs || num_vfs > MAX_VFS_FOR_MAP_PE) {
> -		dev_err(&pdev->dev,
> -			"Num VFs %x > %x Configurable VFs\n",
> -			num_vfs, (num_vfs > MAX_VFS_FOR_MAP_PE) ?
> -			MAX_VFS_FOR_MAP_PE : max_config_vfs);
> +	if (max_config_vfs < num_vfs) {
> +		dev_err(&pdev->dev, "Num VFs %x > %x Configurable VFs\n",
> +			num_vfs, max_config_vfs);
> +		return -EINVAL;
> +	}
> +	if (num_vfs > MAX_VFS_FOR_MAP_PE) {
> +		dev_err(&pdev->dev, "Num VFs %x > %x PE mapping limit\n",
> +			num_vfs, MAX_VFS_FOR_MAP_PE);
>   		return -EINVAL;
>   	}
>