mirror of
git://nv-tegra.nvidia.com/linux-nvgpu.git
synced 2025-12-22 09:12:24 +03:00
On ga10b+ platforms, more VM space is needed to map various buffers
to bar2 vm. Engine method buffer is mapped for each pbdma and for
maximum supported TSGs this requires more than 32MB of space.
Also we need to consider fault buffer space and vab buffer
space requirement.
Bug 3958581
Change-Id: I9ee87119f762352ee12859b71c08a5f75b3554e0
Signed-off-by: Sagar Kamble <skamble@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2872811
(cherry picked from commit 53dc53a8b4)
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2881179
Reviewed-by: Ankur Kishore <ankkishore@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
73 lines
2.6 KiB
C
73 lines
2.6 KiB
C
/*
|
|
* Copyright (c) 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"),
|
|
* to deal in the Software without restriction, including without limitation
|
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
* and/or sell copies of the Software, and to permit persons to whom the
|
|
* Software is furnished to do so, subject to the following conditions:
|
|
*
|
|
* The above copyright notice and this permission notice shall be included in
|
|
* all copies or substantial portions of the Software.
|
|
*
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
* DEALINGS IN THE SOFTWARE.
|
|
*/
|
|
|
|
#include <nvgpu/gk20a.h>
|
|
#include <nvgpu/static_analysis.h>
|
|
|
|
#include <nvgpu/hw/ga10b/hw_gmmu_ga10b.h>
|
|
|
|
#include "mm_ga10b.h"
|
|
|
|
u32 ga10b_mm_bar2_vm_size(struct gk20a *g)
|
|
{
|
|
u32 num_pbdma = nvgpu_get_litter_value(g, GPU_LIT_HOST_NUM_PBDMA);
|
|
u32 buffer_size;
|
|
u32 fb_size;
|
|
|
|
/* Calculate engine method buffer size */
|
|
buffer_size = nvgpu_safe_add_u32(nvgpu_safe_mult_u32((9U + 1U + 3U),
|
|
g->ops.ce.get_num_pce(g)), 2U);
|
|
buffer_size = nvgpu_safe_mult_u32((27U * 5U), buffer_size);
|
|
buffer_size = PAGE_ALIGN(buffer_size);
|
|
nvgpu_log_info(g, "method buffer size in bytes %u", buffer_size);
|
|
|
|
buffer_size = nvgpu_safe_mult_u32(num_pbdma, buffer_size);
|
|
|
|
buffer_size = nvgpu_safe_mult_u32(buffer_size, g->ops.channel.count(g));
|
|
|
|
nvgpu_log_info(g, "method buffer size in bytes for max TSGs %u",
|
|
buffer_size);
|
|
|
|
/*
|
|
* Calculate fault buffers size.
|
|
* Max entries take care of 1 entry used for full detection.
|
|
*/
|
|
fb_size = nvgpu_safe_add_u32(g->ops.channel.count(g), 1U);
|
|
fb_size = nvgpu_safe_mult_u32(fb_size, gmmu_fault_buf_size_v());
|
|
|
|
/* Consider replayable and non replayable faults */
|
|
fb_size = nvgpu_safe_mult_u32(fb_size, 2U);
|
|
|
|
nvgpu_log_info(g, "fault buffers size in bytes %u", fb_size);
|
|
|
|
buffer_size = nvgpu_safe_add_u32(buffer_size, fb_size);
|
|
|
|
/* Add PAGE_SIZE for vab buffer size */
|
|
buffer_size = nvgpu_safe_add_u32(buffer_size, PAGE_SIZE);
|
|
|
|
buffer_size = PAGE_ALIGN(buffer_size);
|
|
|
|
nvgpu_log_info(g, "bar2 vm size in bytes %u", buffer_size);
|
|
|
|
return buffer_size;
|
|
}
|