From 7cd377568f89d1471f027a48885c73c856ffa8a9 Mon Sep 17 00:00:00 2001 From: Richard Zhao Date: Tue, 31 Jan 2023 17:41:33 -0800 Subject: [PATCH] gpu: nvgpu: vgpu: init ctx buffers for vf driver VF needs to allocate gr ctx buffers on gr init, since VF will manage the gr ctx. Jira GVSCI-15769 Change-Id: Ifd09e6b09306c0fd36bddc60caa3d0d56f2b29cb Signed-off-by: Richard Zhao Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2863434 Reviewed-by: svc-mobile-coverity Reviewed-by: svc-mobile-cert Reviewed-by: Dinesh T GVS: Gerrit_Virtual_Submit --- drivers/gpu/nvgpu/common/gr/gr.c | 6 +++--- drivers/gpu/nvgpu/common/vgpu/gr/gr_vgpu.c | 23 ++++++++++++++-------- drivers/gpu/nvgpu/include/nvgpu/gr/gr.h | 4 +++- 3 files changed, 21 insertions(+), 12 deletions(-) diff --git a/drivers/gpu/nvgpu/common/gr/gr.c b/drivers/gpu/nvgpu/common/gr/gr.c index 696db7faf..4affb519b 100644 --- a/drivers/gpu/nvgpu/common/gr/gr.c +++ b/drivers/gpu/nvgpu/common/gr/gr.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2022, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2019-2023, 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"), @@ -425,7 +425,7 @@ static int nvgpu_gr_init_ctx_state(struct gk20a *g, struct nvgpu_gr *gr) return err; } -static int gr_init_ctx_bufs(struct gk20a *g, struct nvgpu_gr *gr) +int nvgpu_gr_init_ctx_bufs(struct gk20a *g, struct nvgpu_gr *gr) { int err = 0; @@ -509,7 +509,7 @@ static int gr_init_setup_sw(struct gk20a *g, struct nvgpu_gr *gr) } #endif - err = gr_init_ctx_bufs(g, gr); + err = nvgpu_gr_init_ctx_bufs(g, gr); if (err != 0) { goto clean_up; } diff --git a/drivers/gpu/nvgpu/common/vgpu/gr/gr_vgpu.c b/drivers/gpu/nvgpu/common/vgpu/gr/gr_vgpu.c index 7d5d127f7..0d449f2dc 100644 --- a/drivers/gpu/nvgpu/common/vgpu/gr/gr_vgpu.c +++ b/drivers/gpu/nvgpu/common/vgpu/gr/gr_vgpu.c @@ -1,7 +1,7 @@ /* * Virtualized GPU Graphics * - * Copyright (c) 2014-2022, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2014-2023, 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"), @@ -674,14 +674,21 @@ static int vgpu_gr_init_gr_setup_sw(struct gk20a *g) } #endif - err = vgpu_gr_alloc_global_ctx_buffers(g); - if (err) { - goto clean_up; - } + if (nvgpu_is_vf(g)) { + err = nvgpu_gr_init_ctx_bufs(g, gr); + if (err) { + goto clean_up; + } + } else { + err = vgpu_gr_alloc_global_ctx_buffers(g); + if (err) { + goto clean_up; + } - gr->gr_ctx_desc = nvgpu_gr_ctx_desc_alloc(g); - if (gr->gr_ctx_desc == NULL) { - goto clean_up; + gr->gr_ctx_desc = nvgpu_gr_ctx_desc_alloc(g); + if (gr->gr_ctx_desc == NULL) { + goto clean_up; + } } #ifdef CONFIG_NVGPU_GRAPHICS diff --git a/drivers/gpu/nvgpu/include/nvgpu/gr/gr.h b/drivers/gpu/nvgpu/include/nvgpu/gr/gr.h index 1333db43c..a1933a5a2 100644 --- a/drivers/gpu/nvgpu/include/nvgpu/gr/gr.h +++ b/drivers/gpu/nvgpu/include/nvgpu/gr/gr.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2021, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2019-2023, 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"), @@ -156,6 +156,8 @@ int nvgpu_gr_alloc(struct gk20a *g); */ void nvgpu_gr_free(struct gk20a *g); +int nvgpu_gr_init_ctx_bufs(struct gk20a *g, struct nvgpu_gr *gr); + /** * @brief Reset and enable GR engine HW as phase 2 of GR engine * initialization.