From 002fb2431d8200efb5a9f124f67e574d8bf04625 Mon Sep 17 00:00:00 2001 From: Seshendra Gadagottu Date: Mon, 23 Mar 2020 18:43:21 -0700 Subject: [PATCH] gpu: nvgpu: nvgpu-next changes for fifo pbdma - Include nvgpu_next_pbdma.h in pbdma.h - NULL check for fifo.init_pbdma_map hal before allocating memory for f->pbdma_map - NULL check for f->pbdma_map before freeing memory for f->pbdma_map JIRA NVGPU-4979 Signed-off-by: Seshendra Gadagottu Change-Id: I5eacc671b924c947620b2c49c8f82577c30ba1a3 Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2317804 Reviewed-by: Vinod Gopalakrishnakurup Reviewed-by: mobile promotions Reviewed-by: automaticguardword Reviewed-by: svc-mobile-coverity Reviewed-by: svc-mobile-misra Reviewed-by: svc-mobile-cert Reviewed-by: Seema Khowala Tested-by: mobile promotions GVS: Gerrit_Virtual_Submit --- drivers/gpu/nvgpu/common/fifo/pbdma.c | 22 ++++++++++++------- .../gpu/nvgpu/include/nvgpu/gops_runlist.h | 1 + drivers/gpu/nvgpu/include/nvgpu/pbdma.h | 8 ++++++- 3 files changed, 22 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/nvgpu/common/fifo/pbdma.c b/drivers/gpu/nvgpu/common/fifo/pbdma.c index b1d5915e5..1e6f99b43 100644 --- a/drivers/gpu/nvgpu/common/fifo/pbdma.c +++ b/drivers/gpu/nvgpu/common/fifo/pbdma.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011-2019, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2011-2020, NVIDIA CORPORATION. All rights reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -68,14 +68,18 @@ int nvgpu_pbdma_setup_sw(struct gk20a *g) struct nvgpu_fifo *f = &g->fifo; f->num_pbdma = nvgpu_get_litter_value(g, GPU_LIT_HOST_NUM_PBDMA); + f->pbdma_map = NULL; - f->pbdma_map = nvgpu_kzalloc(g, f->num_pbdma * sizeof(*f->pbdma_map)); - if (f->pbdma_map == NULL) { - return -ENOMEM; + if (g->ops.fifo.init_pbdma_map != NULL) { + f->pbdma_map = nvgpu_kzalloc(g, + f->num_pbdma * sizeof(*f->pbdma_map)); + if (f->pbdma_map == NULL) { + return -ENOMEM; + } + + g->ops.fifo.init_pbdma_map(g, f->pbdma_map, f->num_pbdma); } - g->ops.fifo.init_pbdma_map(g, f->pbdma_map, f->num_pbdma); - nvgpu_pbdma_init_intr_descs(g); return 0; @@ -85,6 +89,8 @@ void nvgpu_pbdma_cleanup_sw(struct gk20a *g) { struct nvgpu_fifo *f = &g->fifo; - nvgpu_kfree(g, f->pbdma_map); - f->pbdma_map = NULL; + if (f->pbdma_map != NULL) { + nvgpu_kfree(g, f->pbdma_map); + f->pbdma_map = NULL; + } } diff --git a/drivers/gpu/nvgpu/include/nvgpu/gops_runlist.h b/drivers/gpu/nvgpu/include/nvgpu/gops_runlist.h index 41e858734..f3efaaa3b 100644 --- a/drivers/gpu/nvgpu/include/nvgpu/gops_runlist.h +++ b/drivers/gpu/nvgpu/include/nvgpu/gops_runlist.h @@ -23,6 +23,7 @@ #define NVGPU_GOPS_RUNLIST_H #include +#include /** * @file diff --git a/drivers/gpu/nvgpu/include/nvgpu/pbdma.h b/drivers/gpu/nvgpu/include/nvgpu/pbdma.h index e5b1f5247..43df72513 100644 --- a/drivers/gpu/nvgpu/include/nvgpu/pbdma.h +++ b/drivers/gpu/nvgpu/include/nvgpu/pbdma.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011-2019, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2011-2020, NVIDIA CORPORATION. All rights reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -34,6 +34,12 @@ */ struct gk20a; +/** @cond DOXYGEN_SHOULD_SKIP_THIS */ +#if defined(CONFIG_NVGPU_NON_FUSA) && defined(CONFIG_NVGPU_NEXT) +#include "include/nvgpu/nvgpu_next_pbdma.h" +#endif +/** @endcond DOXYGEN_SHOULD_SKIP_THIS */ + /** * @brief Initialize PBDMA software context *