git: 95bf70a4bf79 - main - mlx5: Don't give zero number of pages to the firmware.

From: Hans Petter Selasky <hselasky_at_FreeBSD.org>
Date: Tue, 18 Apr 2023 13:02:06 UTC
The branch main has been updated by hselasky:

URL: https://cgit.FreeBSD.org/src/commit/?id=95bf70a4bf7982091bb59200bc2db2cb5cd840d7

commit 95bf70a4bf7982091bb59200bc2db2cb5cd840d7
Author:     Hans Petter Selasky <hselasky@FreeBSD.org>
AuthorDate: 2023-04-18 11:22:41 +0000
Commit:     Hans Petter Selasky <hselasky@FreeBSD.org>
CommitDate: 2023-04-18 13:01:06 +0000

    mlx5: Don't give zero number of pages to the firmware.
    
    Can happen when using virtual mlx5_core<N> functions, VFs.
    
    MFC after:      1 week
    Sponsored by:   NVIDIA Networking
---
 sys/dev/mlx5/mlx5_core/mlx5_pagealloc.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/sys/dev/mlx5/mlx5_core/mlx5_pagealloc.c b/sys/dev/mlx5/mlx5_core/mlx5_pagealloc.c
index d298da67057a..730c7ee8bee9 100644
--- a/sys/dev/mlx5/mlx5_core/mlx5_pagealloc.c
+++ b/sys/dev/mlx5/mlx5_core/mlx5_pagealloc.c
@@ -509,7 +509,10 @@ int mlx5_satisfy_startup_pages(struct mlx5_core_dev *dev, int boot)
 	mlx5_core_dbg(dev, "requested %d %s pages for func_id 0x%x\n",
 		      npages, boot ? "boot" : "init", func_id);
 
-	return give_pages(dev, func_id, npages, 0);
+	if (npages > 0)
+		return give_pages(dev, func_id, npages, 0);
+	else
+		return 0;
 }
 
 enum {