tegra: hwpm: add dt property, update devnode perm

HWPM is a profiling device. Device node property support-soc-tools
indicates if soc profiling tools should be enabled or disabled.
Add logic to HWPM probe to read device node and probe HWPM device only
if support-soc-tools property is present.

Implement devnode API to disclose device node permissions for HWPM.
Set HWPM device node permissions to allow access for root and group.

Bug 3435136
Bug 3583956

Change-Id: I988de3b21cd00ef9402ca03408d2b0141e7155d8
Signed-off-by: Vedashree Vidwans <vvidwans@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2717982
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
Reviewed-by: svc-mobile-cert <svc-mobile-cert@nvidia.com>
Reviewed-by: Seema Khowala <seemaj@nvidia.com>
Reviewed-by: svc_kernel_abi <svc_kernel_abi@nvidia.com>
GVS: Gerrit_Virtual_Submit
This commit is contained in:
Vedashree Vidwans
2022-05-24 22:37:47 -07:00
committed by mobile promotions
parent 6d0e0ee04d
commit 5c8a07022f

View File

@@ -36,6 +36,30 @@ static const struct of_device_id tegra_soc_hwpm_of_match[] = {
};
MODULE_DEVICE_TABLE(of, tegra_soc_hwpm_of_match);
static char *tegra_hwpm_get_devnode(struct device *dev, umode_t *mode)
{
if (!mode) {
return NULL;
}
/* Allow root:debug ownership */
*mode = 0660;
return NULL;
}
static bool tegra_hwpm_read_support_soc_tools_prop(struct platform_device *pdev)
{
struct device_node *np = pdev->dev.of_node;
bool allow_node = of_property_read_bool(np, "support-soc-tools");
if (!allow_node) {
tegra_hwpm_err(NULL, "support-soc-tools is absent");
}
return allow_node;
}
static int tegra_hwpm_probe(struct platform_device *pdev)
{
int ret = 0;
@@ -48,6 +72,12 @@ static int tegra_hwpm_probe(struct platform_device *pdev)
goto fail;
}
if (!tegra_hwpm_read_support_soc_tools_prop(pdev)) {
tegra_hwpm_err(NULL, "SOC HWPM not supported in this config");
ret = -ENODEV;
goto fail;
}
hwpm = kzalloc(sizeof(struct tegra_soc_hwpm), GFP_KERNEL);
if (!hwpm) {
tegra_hwpm_err(hwpm, "Couldn't allocate memory for hwpm struct");
@@ -67,6 +97,9 @@ static int tegra_hwpm_probe(struct platform_device *pdev)
goto class_register;
}
/* Set devnode to retrieve device permissions */
hwpm->class.devnode = tegra_hwpm_get_devnode;
ret = alloc_chrdev_region(&hwpm->dev_t, 0, 1, dev_name(hwpm->dev));
if (ret) {
tegra_hwpm_err(hwpm, "Failed to allocate device region");