mirror of
git://nv-tegra.nvidia.com/linux-nv-oot.git
synced 2025-12-25 02:32:08 +03:00
Copy the driver and header sources of the nvmap to kernel/nvidia-oot from kernel/nvidia as part of removing the dependency of kernel/nvidia for OOT drivers. The latest (few) git history of the files copied are b7a355916 video: tegra: nvmap: Fix type casting issue 2128c5433 video: tegra: nvmap: Fix type casting issues 0cd082559 video: tegra: nvmap: Change peer vm id data type 4bd7ece67 tegra: nvmap: mark ivm carveout pages occupied e86f3630a video: tegra: nvmap: Fix type casting issue c43a23e58 video: tegra: nvmap: Fix type casting issue ca1dda22e video: tegra: nvmap: Fix type casting issue 1f567abfe video: tegra: nvmap: Fix wrap up condition 29db4d31c video: tegra: nvmap: Remove unnecessary debugfs fe72f1413 video: tegra: nvmap: Remove get_drv_data() call 3b0fc79e7 video: tegra: nvmap: Fix coverity defect 3cc0ce41b video: tegra: nvmap: Fix coverity defect 6da39e966 video: tegra: nvmap: Fix WARN_ON condition a16351ff1 video: tegra: nvmap: Remove dead code 9993f2d2d video: tegra: nvmap: Update print level 6066a2077 video: tegra: nvmap: Remove nvmap_debug_lru_allocations_show 3cdf2b7ba video: tegra: nvmap: Add kernel version check 716ded4fc video: tegra: nvmap: Initialize the return value 9b6c1b4ab video: tegra: nvmap: Correct debugfs code 33e70118b video: tegra: nvmap: Fix Cert-C error handling bug 7b960ed79 video: tegra: nvmap: Fix Cert-C error handling bug 945dc1471 video: tegra: nvmap: Fix Cert-C error handling bug 31e572de2 video: tegra: nvmap: Fix Cert-C error handling bug 1f25cbf68 video: tegra: nvmap: Fix Cert-C error handling bug fa5428107 video: tegra: nvmap: Remove nvmap_handle_get_from_fd df73f2208 video: tegra: nvmap: Protect kmap/kunmap code 9842e7c6a video: tegra: nvmap: Remove t19x dma_buf map/unmap 06dff1a8d video: tegra: nvmap: Remove unnecessary export symbols 6f097f86b video: tegra: nvmap: Fix Cert-C error handling bug f14171608 video: tegra: nvmap: load nvmap for T23x compatible platforms 266812814 video: tegra: nvmap: Get rid of NVMAP_CONFIG_KSTABLE_KERNEL 1b38c0887 nvmap: Don't use NV_BUILD_KERNEL_OPTIONS 0ab8dc032 video: tegra: nvmap: Reintroduce NVMAP_CONFIG_VPR_RESIZE cc8db9797 driver: platform: tegra: Separate out vpr code 28955d95c video/tegra: nvmap: Enable build as OOT module 876d1fbb8 video: tegra: nvmap: Remove IS_ENABLED check 5ea30867a nvmap: Add support to build as module from OOT kernel a71ad020e video: tegra: nvmap: Protect tegra_vpr args under config e70061cc1 video: tegra: nvmap: Do not export cvnas_dev d2a26ff36 video: tegra: nvmap: Include missing header 692e4f682 video: tegra: nvmap: Update page coloring algo 2b9dbb911 video: tegra: nvmap: Check for return value de8de12b6 video: tegra: nvmap: Enable legacy init support 65d478158 video: tegra: nvmap: Remove dependency of cvnas 38bdd6f05 video: tegra: nvmap: Make nvmap as loadable module 9668e410b video: tegra: nvmap: Enable handle as ID 11c6cbd23 tegra: nvmap: Fix build for Linux v5.18 fbd95c3ab linux: nvmap: change ivm_handle to u32 eb1e2c302 video: tegra: nvmap: Fix NVSCIIPC support 022689b29 tegra: nvmap: return error if handle as ID enabled but id is fd 19e5106ed video: tegra: nvmap: Don't treat ivm as reserved mem carveouts Bug 4038415 Change-Id: I7108aec3b8532fe79c9423c2835744b1213719e8 Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
107 lines
2.9 KiB
C
107 lines
2.9 KiB
C
/*
|
|
* drivers/video/tegra/nvmap/nvmap_stats.c
|
|
*
|
|
* Nvmap Stats keeping
|
|
*
|
|
* Copyright (c) 2011-2018, NVIDIA CORPORATION. All rights reserved.
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
* under the terms and conditions of the GNU General Public License,
|
|
* version 2, as published by the Free Software Foundation.
|
|
*
|
|
* This program is distributed in the hope it will be useful, but WITHOUT
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
* more details.
|
|
*/
|
|
|
|
#include <linux/debugfs.h>
|
|
|
|
#include "nvmap_priv.h"
|
|
|
|
struct nvmap_stats nvmap_stats;
|
|
|
|
static int nvmap_stats_reset(void *data, u64 val)
|
|
{
|
|
int i;
|
|
|
|
if (val) {
|
|
atomic64_set(&nvmap_stats.collect, 0);
|
|
for (i = 0; i < NS_NUM; i++) {
|
|
if (i == NS_TOTAL)
|
|
continue;
|
|
atomic64_set(&nvmap_stats.stats[i], 0);
|
|
}
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
static int nvmap_stats_get(void *data, u64 *val)
|
|
{
|
|
atomic64_t *ptr = data;
|
|
|
|
*val = atomic64_read(ptr);
|
|
return 0;
|
|
}
|
|
|
|
static int nvmap_stats_set(void *data, u64 val)
|
|
{
|
|
atomic64_t *ptr = data;
|
|
|
|
atomic64_set(ptr, val);
|
|
return 0;
|
|
}
|
|
|
|
DEFINE_SIMPLE_ATTRIBUTE(reset_stats_fops, NULL, nvmap_stats_reset, "%llu\n");
|
|
DEFINE_SIMPLE_ATTRIBUTE(stats_fops, nvmap_stats_get, nvmap_stats_set, "%llu\n");
|
|
|
|
void nvmap_stats_init(struct dentry *nvmap_debug_root)
|
|
{
|
|
struct dentry *stats_root;
|
|
|
|
#define CREATE_DF(x, y) \
|
|
debugfs_create_file(#x, S_IRUGO, stats_root, &y, &stats_fops);
|
|
|
|
stats_root = debugfs_create_dir("stats", nvmap_debug_root);
|
|
if (!IS_ERR_OR_NULL(stats_root)) {
|
|
CREATE_DF(alloc, nvmap_stats.stats[NS_ALLOC]);
|
|
CREATE_DF(release, nvmap_stats.stats[NS_RELEASE]);
|
|
CREATE_DF(ualloc, nvmap_stats.stats[NS_UALLOC]);
|
|
CREATE_DF(urelease, nvmap_stats.stats[NS_URELEASE]);
|
|
CREATE_DF(kalloc, nvmap_stats.stats[NS_KALLOC]);
|
|
CREATE_DF(krelease, nvmap_stats.stats[NS_KRELEASE]);
|
|
CREATE_DF(cflush_rq, nvmap_stats.stats[NS_CFLUSH_RQ]);
|
|
CREATE_DF(cflush_done, nvmap_stats.stats[NS_CFLUSH_DONE]);
|
|
CREATE_DF(ucflush_rq, nvmap_stats.stats[NS_UCFLUSH_RQ]);
|
|
CREATE_DF(ucflush_done, nvmap_stats.stats[NS_UCFLUSH_DONE]);
|
|
CREATE_DF(kcflush_rq, nvmap_stats.stats[NS_KCFLUSH_RQ]);
|
|
CREATE_DF(kcflush_done, nvmap_stats.stats[NS_KCFLUSH_DONE]);
|
|
CREATE_DF(total_memory, nvmap_stats.stats[NS_TOTAL]);
|
|
|
|
debugfs_create_file("collect", S_IRUGO | S_IWUSR,
|
|
stats_root, &nvmap_stats.collect, &stats_fops);
|
|
debugfs_create_file("reset", S_IWUSR,
|
|
stats_root, NULL, &reset_stats_fops);
|
|
}
|
|
|
|
#undef CREATE_DF
|
|
}
|
|
|
|
void nvmap_stats_inc(enum nvmap_stats_t stat, size_t size)
|
|
{
|
|
if (atomic64_read(&nvmap_stats.collect) || stat == NS_TOTAL)
|
|
atomic64_add(size, &nvmap_stats.stats[stat]);
|
|
}
|
|
|
|
void nvmap_stats_dec(enum nvmap_stats_t stat, size_t size)
|
|
{
|
|
if (atomic64_read(&nvmap_stats.collect) || stat == NS_TOTAL)
|
|
atomic64_sub(size, &nvmap_stats.stats[stat]);
|
|
}
|
|
|
|
u64 nvmap_stats_read(enum nvmap_stats_t stat)
|
|
{
|
|
return atomic64_read(&nvmap_stats.stats[stat]);
|
|
}
|
|
|