22/11/2021 19:24, eagost...@nvidia.com:
> From: Elena Agostini <eagost...@nvidia.com>
> 
> gpudev free and unregister functions return gracefully if input pointer is 
> NULL

We could add that the API doc was indicating NULL as a no-op accepted value.

Another explanation to add: cuda driver checks are removed because redundant
with the checks added in gpudev library.

> Fixes: 818a067baf90 ("gpudev: manage NULL pointer")

It should be:
Fixes: e818c4e2bf50 ("gpudev: add memory API")

> 
> Signed-off-by: Elena Agostini <eagost...@nvidia.com>
> ---
>  drivers/gpu/cuda/cuda.c | 6 ------
>  lib/gpudev/gpudev.c     | 6 ++++++
>  2 files changed, 6 insertions(+), 6 deletions(-)
[...]
> --- a/lib/gpudev/gpudev.c
> +++ b/lib/gpudev/gpudev.c
> @@ -569,6 +569,9 @@ rte_gpu_mem_free(int16_t dev_id, void *ptr)
>  {
>       struct rte_gpu *dev;
>  
> +     if (ptr == NULL)
> +             return 0;
> +
>       dev = gpu_get_by_id(dev_id);
>       if (dev == NULL) {
>               GPU_LOG(ERR, "free mem for invalid device ID %d", dev_id);

I think we should keep this check first.

> @@ -612,6 +615,9 @@ rte_gpu_mem_unregister(int16_t dev_id, void *ptr)
>  {
>       struct rte_gpu *dev;
>  
> +     if (ptr == NULL)
> +             return 0;
> +
>       dev = gpu_get_by_id(dev_id);
>       if (dev == NULL) {
>               GPU_LOG(ERR, "unregister mem for invalid device ID %d", dev_id);

Same here.

There is third function where NULL should be accepted: rte_gpu_mem_register




Reply via email to