mirror of
git://nv-tegra.nvidia.com/linux-nvgpu.git
synced 2025-12-22 17:36:20 +03:00
On all chips except ga10b, the number of ROP, L2 units per FBP were in sync, hence, their FS masks could be represented by a single fuse register NV_FUSE_STATUS_OPT_ROP_L2_FBP. However, on ga10b, the ROP unit was moved out from FBP to GPC and it no longer matches the number of L2 units, so the previous fuse register was broken into two - NV_FUSE_CTRL_OPT_LTC_FBP, NV_FUSE_CTRL_OPT_ROP_GPC. At present, the driver reads the NV_FUSE_CTRL_OPT_ROP_GPC register and reports incorrect L2 mask. Introduce HAL function ga10b_fuse_status_opt_l2_fbp to fix this. In addition, rename fields and functions to exclusively fetch L2 masks, this should help accommadate ga10b and future chips in which L2 and ROP units are not in same. As part of this, the following functions and fields have been renamed. - nvgpu_fbp_get_rop_l2_en_mask => nvgpu_fbp_get_l2_en_mask - fuse.fuse_status_opt_rop_l2_fbp => fuse.fuse_status_opt_l2_fbp - nvgpu_fbp.fbp_rop_l2_en_mask => nvgpu_fbp.fbp_l2_en_mask The HAL ga10b_fuse_status_opt_rop_gpc is removed as rop mask is not used anywhere in the driver nor exposed to userspace. Bug 200737717 Bug 200747149 Change-Id: If40fe7ecd1f47c23f7683369a60d8dd686590ca4 Signed-off-by: Antony Clince Alex <aalex@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2551998 Tested-by: mobile promotions <svcmobile_promotions@nvidia.com> Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
131 lines
3.4 KiB
C
131 lines
3.4 KiB
C
/*
|
|
* Copyright (c) 2019-2021, 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/kmem.h>
|
|
#include <nvgpu/log.h>
|
|
#include <nvgpu/fbp.h>
|
|
#include <nvgpu/static_analysis.h>
|
|
|
|
#include "fbp_priv.h"
|
|
|
|
int nvgpu_fbp_init_support(struct gk20a *g)
|
|
{
|
|
struct nvgpu_fbp *fbp;
|
|
u32 fbp_en_mask;
|
|
#ifdef CONFIG_NVGPU_NON_FUSA
|
|
u32 max_ltc_per_fbp;
|
|
u32 l2_all_en_mask;
|
|
unsigned long i;
|
|
unsigned long fbp_en_mask_tmp;
|
|
u32 tmp;
|
|
#endif
|
|
|
|
if (g->fbp != NULL) {
|
|
return 0;
|
|
}
|
|
|
|
fbp = nvgpu_kzalloc(g, sizeof(*fbp));
|
|
if (fbp == NULL) {
|
|
return -ENOMEM;
|
|
}
|
|
|
|
#ifdef CONFIG_NVGPU_NON_FUSA
|
|
fbp->num_fbps = g->ops.priv_ring.get_fbp_count(g);
|
|
nvgpu_log_info(g, "fbps: %d", fbp->num_fbps);
|
|
#endif
|
|
|
|
fbp->max_fbps_count = g->ops.top.get_max_fbps_count(g);
|
|
nvgpu_log_info(g, "max_fbps_count: %d", fbp->max_fbps_count);
|
|
|
|
/*
|
|
* Read active fbp mask from fuse
|
|
* Note that 0:enable and 1:disable in value read from fuse so we've to
|
|
* flip the bits.
|
|
* Also set unused bits to zero
|
|
*/
|
|
fbp_en_mask = g->ops.fuse.fuse_status_opt_fbp(g);
|
|
fbp_en_mask = ~fbp_en_mask;
|
|
fbp_en_mask = fbp_en_mask &
|
|
nvgpu_safe_sub_u32(BIT32(fbp->max_fbps_count), 1U);
|
|
fbp->fbp_en_mask = fbp_en_mask;
|
|
|
|
#ifdef CONFIG_NVGPU_NON_FUSA
|
|
fbp->fbp_l2_en_mask =
|
|
nvgpu_kzalloc(g,
|
|
nvgpu_safe_mult_u64(fbp->max_fbps_count, sizeof(u32)));
|
|
if (fbp->fbp_l2_en_mask == NULL) {
|
|
nvgpu_kfree(g, fbp);
|
|
return -ENOMEM;
|
|
}
|
|
|
|
fbp_en_mask_tmp = fbp_en_mask;
|
|
max_ltc_per_fbp = g->ops.top.get_max_ltc_per_fbp(g);
|
|
l2_all_en_mask = nvgpu_safe_sub_u32(BIT32(max_ltc_per_fbp), 1U);
|
|
|
|
/* get active L2 mask per FBP */
|
|
for_each_set_bit(i, &fbp_en_mask_tmp, fbp->max_fbps_count) {
|
|
tmp = g->ops.fuse.fuse_status_opt_l2_fbp(g, i);
|
|
fbp->fbp_l2_en_mask[i] = l2_all_en_mask ^ tmp;
|
|
}
|
|
#endif
|
|
|
|
g->fbp = fbp;
|
|
|
|
return 0;
|
|
}
|
|
|
|
void nvgpu_fbp_remove_support(struct gk20a *g)
|
|
{
|
|
struct nvgpu_fbp *fbp = g->fbp;
|
|
|
|
if (fbp != NULL) {
|
|
nvgpu_kfree(g, fbp->fbp_l2_en_mask);
|
|
nvgpu_kfree(g, fbp);
|
|
}
|
|
|
|
g->fbp = NULL;
|
|
}
|
|
|
|
u32 nvgpu_fbp_get_max_fbps_count(struct nvgpu_fbp *fbp)
|
|
{
|
|
return fbp->max_fbps_count;
|
|
}
|
|
|
|
u32 nvgpu_fbp_get_fbp_en_mask(struct nvgpu_fbp *fbp)
|
|
{
|
|
return fbp->fbp_en_mask;
|
|
}
|
|
|
|
#ifdef CONFIG_NVGPU_NON_FUSA
|
|
u32 nvgpu_fbp_get_num_fbps(struct nvgpu_fbp *fbp)
|
|
{
|
|
return fbp->num_fbps;
|
|
}
|
|
|
|
u32 *nvgpu_fbp_get_l2_en_mask(struct nvgpu_fbp *fbp)
|
|
{
|
|
return fbp->fbp_l2_en_mask;
|
|
}
|
|
#endif
|
|
|