Files
linux-nv-oot/drivers/platform/tegra/nvadsp/aram_manager.c
Bharat Nihalani d40e2df1b2 drivers: Use runtime debugfs check
When kernel command line debugfs=off is specified instead of
disabling CONFIG_DEBUG_FS in defconfig to disable Debug-FS,
debugfs functions like debugfs_create_dir will fail.

Use function debugfs_initialized() to check if debugfs
functionality is enabled before calling any debugfs functions.

This allows us to by-pass debugfs initialization if debugfs
is not enabled.

Also, there is no need to protect debugfs related code under
CONFIG_DEBUG_FS, as stub functions for all debugfs APIs are
defined when CONFIG_DEBUG_FS is disabled.

Bug 3752450

Change-Id: I1aa2c46bc822da54fdc87504ac75c91845e02c12
Signed-off-by: Bharat Nihalani <bnihalani@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2820666
Reviewed-by: svc_kernel_abi <svc_kernel_abi@nvidia.com>
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
Reviewed-by: svc-mobile-cert <svc-mobile-cert@nvidia.com>
Reviewed-by: Suresh Venkatachalam <skathirampat@nvidia.com>
Reviewed-by: Dara Ramesh <dramesh@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
2023-06-20 15:13:15 +00:00

97 lines
2.2 KiB
C

/*
* aram_managerc
*
* ARAM manager
*
* Copyright (C) 2014-2022, NVIDIA Corporation. All rights reserved.
*
* This software is licensed under the terms of the GNU General Public
* License version 2, as published by the Free Software Foundation, and
* may be copied, distributed, and modified under those terms.
*
* This program is distributed in the hope that 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.
*
*/
#define pr_fmt(fmt) "%s : %d, " fmt, __func__, __LINE__
#include <linux/debugfs.h>
#include <linux/tegra_nvadsp.h>
#include "aram_manager.h"
static void *aram_handle;
static LIST_HEAD(aram_alloc_list);
static LIST_HEAD(aram_free_list);
void nvadsp_aram_print(void)
{
mem_print(aram_handle);
}
void *nvadsp_aram_request(const char *name, size_t size)
{
return mem_request(aram_handle, name, size);
}
bool nvadsp_aram_release(void *handle)
{
return mem_release(aram_handle, handle);
}
unsigned long nvadsp_aram_get_address(void *handle)
{
return mem_get_address(handle);
}
static struct dentry *aram_dump_debugfs_file;
static int nvadsp_aram_dump(struct seq_file *s, void *data)
{
mem_dump(aram_handle, s);
return 0;
}
static int nvadsp_aram_dump_open(struct inode *inode, struct file *file)
{
return single_open(file, nvadsp_aram_dump, inode->i_private);
}
static const struct file_operations aram_dump_fops = {
.open = nvadsp_aram_dump_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};
int nvadsp_aram_init(unsigned long addr, unsigned long size)
{
aram_handle = create_mem_manager("ARAM", addr, size);
if (IS_ERR(aram_handle)) {
pr_err("ERROR: failed to create aram memory_manager");
return PTR_ERR(aram_handle);
}
if (debugfs_initialized()) {
aram_dump_debugfs_file = debugfs_create_file("aram_dump",
S_IRUSR, NULL, NULL, &aram_dump_fops);
if (!aram_dump_debugfs_file) {
pr_err("ERROR: failed to create aram_dump debugfs");
destroy_mem_manager(aram_handle);
return -ENOMEM;
}
}
return 0;
}
void nvadsp_aram_exit(void)
{
debugfs_remove(aram_dump_debugfs_file);
destroy_mem_manager(aram_handle);
}