From: <eagostini@nvidia.com>
To: <dev@dpdk.org>
Cc: Elena Agostini <eagostini@nvidia.com>
Subject: [PATCH v7] gpudev: manage NULL pointer
Date: Tue, 23 Nov 2021 00:42:07 +0000 [thread overview]
Message-ID: <20211123004207.24733-1-eagostini@nvidia.com> (raw)
In-Reply-To: <20211118192802.23955-1-eagostini@nvidia.com>
From: Elena Agostini <eagostini@nvidia.com>
gpudev free and unregister functions return
gracefully if input pointer is NULL because
API doc was indicating NULL as a no-op
accepted value.
cuda driver checks are removed because
redundant with the checks added
in gpudev library.
Fixes: e818c4e2bf50 ("gpudev: add memory API")
Signed-off-by: Elena Agostini <eagostini@nvidia.com>
---
drivers/gpu/cuda/cuda.c | 11 -----------
lib/gpudev/gpudev.c | 12 ++++++++++--
2 files changed, 10 insertions(+), 13 deletions(-)
diff --git a/drivers/gpu/cuda/cuda.c b/drivers/gpu/cuda/cuda.c
index 24ae630d04..a4869da186 100644
--- a/drivers/gpu/cuda/cuda.c
+++ b/drivers/gpu/cuda/cuda.c
@@ -569,8 +569,6 @@ cuda_mem_alloc(struct rte_gpu *dev, size_t size, void **ptr)
if (dev == NULL)
return -ENODEV;
- if (size == 0)
- return -EINVAL;
/* Store current ctx */
res = pfn_cuCtxGetCurrent(¤t_ctx);
@@ -652,9 +650,6 @@ cuda_mem_register(struct rte_gpu *dev, size_t size, void *ptr)
if (dev == NULL)
return -ENODEV;
- if (size == 0 || ptr == NULL)
- return -EINVAL;
-
/* Store current ctx */
res = pfn_cuCtxGetCurrent(¤t_ctx);
if (res != 0) {
@@ -764,9 +759,6 @@ cuda_mem_free(struct rte_gpu *dev, void *ptr)
if (dev == NULL)
return -ENODEV;
- if (ptr == NULL)
- return -EINVAL;
-
hk = get_hash_from_ptr((void *)ptr);
mem_item = mem_list_find_item(hk);
@@ -803,9 +795,6 @@ cuda_mem_unregister(struct rte_gpu *dev, void *ptr)
if (dev == NULL)
return -ENODEV;
- if (ptr == NULL)
- return -EINVAL;
-
hk = get_hash_from_ptr((void *)ptr);
mem_item = mem_list_find_item(hk);
diff --git a/lib/gpudev/gpudev.c b/lib/gpudev/gpudev.c
index 2b174d8bd5..1d8200e71b 100644
--- a/lib/gpudev/gpudev.c
+++ b/lib/gpudev/gpudev.c
@@ -580,6 +580,10 @@ rte_gpu_mem_free(int16_t dev_id, void *ptr)
rte_errno = ENOTSUP;
return -rte_errno;
}
+
+ if (ptr == NULL) /* dry-run */
+ return 0;
+
return GPU_DRV_RET(dev->ops.mem_free(dev, ptr));
}
@@ -601,8 +605,8 @@ rte_gpu_mem_register(int16_t dev_id, size_t size, void *ptr)
return -rte_errno;
}
- if (size == 0 || ptr == NULL) /* dry-run */
- return -EINVAL;
+ if (ptr == NULL || size == 0) /* dry-run */
+ return 0;
return GPU_DRV_RET(dev->ops.mem_register(dev, size, ptr));
}
@@ -623,6 +627,10 @@ rte_gpu_mem_unregister(int16_t dev_id, void *ptr)
rte_errno = ENOTSUP;
return -rte_errno;
}
+
+ if (ptr == NULL) /* dry-run */
+ return 0;
+
return GPU_DRV_RET(dev->ops.mem_unregister(dev, ptr));
}
--
2.17.1
next prev parent reply other threads:[~2021-11-22 16:31 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-18 19:28 [PATCH v1] gpudev: return EINVAL if invalid input pointer for free and unregister eagostini
2021-11-18 16:20 ` Stephen Hemminger
2021-11-18 16:22 ` Elena Agostini
2021-11-18 20:19 ` Tyler Retzlaff
2021-11-19 9:34 ` Ferruh Yigit
2021-11-19 9:56 ` Thomas Monjalon
2021-11-24 17:24 ` Tyler Retzlaff
2021-11-24 18:04 ` Bruce Richardson
2021-12-01 21:37 ` Tyler Retzlaff
2021-12-02 7:18 ` Thomas Monjalon
2021-12-02 12:33 ` Morten Brørup
2021-12-02 13:01 ` Ananyev, Konstantin
2021-12-02 13:56 ` Morten Brørup
2021-12-03 10:37 ` Morten Brørup
2021-12-08 17:34 ` Tyler Retzlaff
2021-12-08 18:40 ` Morten Brørup
2021-12-09 19:43 ` Tyler Retzlaff
2021-12-08 17:27 ` Tyler Retzlaff
2021-11-19 10:15 ` Bruce Richardson
2021-11-18 20:33 ` [PATCH v2] gpudev: free and unregister return gracefully if input pointer is NULL eagostini
2021-11-22 18:24 ` [PATCH v3] gpudev: manage NULL pointer eagostini
2021-11-22 11:23 ` Thomas Monjalon
2021-11-22 11:34 ` Elena Agostini
2021-11-22 11:51 ` Thomas Monjalon
2021-11-22 23:52 ` [PATCH v4] " eagostini
2021-11-22 23:55 ` [PATCH v5] " eagostini
2021-11-22 16:01 ` Thomas Monjalon
2021-11-23 0:15 ` [PATCH v6] " eagostini
2021-11-23 0:42 ` eagostini [this message]
2021-11-24 8:40 ` [PATCH v7] " Thomas Monjalon
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20211123004207.24733-1-eagostini@nvidia.com \
--to=eagostini@nvidia.com \
--cc=dev@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.