Commit Graph

126 Commits

Author SHA1 Message Date
Vedashree Vidwans
4f1e352286 tegra: hwpm: rename source files
Shorten source file names by removing "tegra_hwpm" prefix. This will
make understanding the code more legible.

Jira THWPM-58

Change-Id: I39aac11c9f2a763a254b0605f9d96a7b0f372992
Signed-off-by: Vedashree Vidwans <vvidwans@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2729469
Reviewed-by: svc_kernel_abi <svc_kernel_abi@nvidia.com>
Reviewed-by: Vasuki Shankar <vasukis@nvidia.com>
Reviewed-by: Seema Khowala <seemaj@nvidia.com>
GVS: Gerrit_Virtual_Submit
2022-08-12 15:50:20 -07:00
Vedashree Vidwans
4ba1394149 tegra: hwpm: t234: fix floorsweep info computation
Floorsweep info ioctl shares flattened IP element mask. LSB of flattened
mask is expected to correspond to IP instance 0 element index mask.
Currently, HWPM driver incorrectly shifts instance 0 floorsweep mask to
higher bits.
Fix the floorsweep info calculation logic to compute floorsweep mask
correctly.

Use is_ip_active and is_resource_active hals instead of chip specific
functions.

Bug 3737440

Change-Id: I01c1b430cf7fdc2159198770f8b34056dda5ccca
Signed-off-by: Vedashree Vidwans <vvidwans@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2754282
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
Reviewed-by: svc-mobile-cert <svc-mobile-cert@nvidia.com>
Reviewed-by: svcacv <svcacv@nvidia.com>
Reviewed-by: svc_kernel_abi <svc_kernel_abi@nvidia.com>
Reviewed-by: Vasuki Shankar <vasukis@nvidia.com>
Reviewed-by: Seema Khowala <seemaj@nvidia.com>
GVS: Gerrit_Virtual_Submit
2022-08-03 07:33:22 -07:00
Vedashree Vidwans
a106a27456 tegra: hwpm: handle enginestatus = quiesce case
The device sampler test doesn't consume all PMA records and initiates
device close. This results in PMA engine status to be set to quiesce
state and tegra_hwpm_release() returning with error.
In such case, HWPM driver should close device completely and return any
resultant error.
Closing HWPM device completely ensures that sw state is reset and ready
for next session. And HWPM reset assert during device close resets HWPM
hardware.

Bug 3714516

Change-Id: I9d800bfb7a38f82a295f45a674d14808975a863e
Signed-off-by: Vedashree Vidwans <vvidwans@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2744657
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
Reviewed-by: svc-mobile-cert <svc-mobile-cert@nvidia.com>
Reviewed-by: svc_kernel_abi <svc_kernel_abi@nvidia.com>
Reviewed-by: Vasuki Shankar <vasukis@nvidia.com>
Reviewed-by: Adeel Raza <araza@nvidia.com>
2022-07-29 00:04:32 -07:00
Vedashree Vidwans
e28906ad68 tegra: hwpm: t234: update nvlink perfmux allowlist
Add NVLINK internal perfmux filter registers used for HWPM profiling.

Jira THWPM-68

Change-Id: I6269f31bdc56a330e5140ef7301eb5eb7bb61353
Signed-off-by: Vedashree Vidwans <vvidwans@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2744698
Reviewed-by: svcacv <svcacv@nvidia.com>
Reviewed-by: svc_kernel_abi <svc_kernel_abi@nvidia.com>
Reviewed-by: Vasuki Shankar <vasukis@nvidia.com>
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
Reviewed-by: svc-mobile-cert <svc-mobile-cert@nvidia.com>
Reviewed-by: Adeel Raza <araza@nvidia.com>
2022-07-29 00:04:10 -07:00
Vedashree Vidwans
539a7cd9a9 tegra: hwpm: fix bug while computing PMA fs mask
HWPM driver verifies available IP instance elements and updates
corresponding element floorsweep mask in the IP structures. Availability
of the elements is done by reading one perfmux register corresponding to
the element. Since PMA and RTR perfmuxes belong to the HWPM device,
these apertures need to be MMIO mapped to be accessed. Since PMA/RTR
perfmuxes are MMIO mapped at reservation, the availabilty verification
fails to read perfmux registers. This triggers incorrect updates for PMA
element fs mask.
PMA/RTR have pre-defined/pre-initialized element_fs_masks. Hence,
verifying element availabilty for PMA/RTR should be skipped. This change
fixes the issue of PMA marked as invalid.

Bug 3682605

Change-Id: Ib78fde73a1321095315b735b987fe8e2a9aaf474
Signed-off-by: Vedashree Vidwans <vvidwans@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2743130
Reviewed-by: svcacv <svcacv@nvidia.com>
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
Reviewed-by: svc-mobile-cert <svc-mobile-cert@nvidia.com>
Reviewed-by: svc_kernel_abi <svc_kernel_abi@nvidia.com>
Reviewed-by: Vasuki Shankar <vasukis@nvidia.com>
Reviewed-by: Adeel Raza <araza@nvidia.com>
GVS: Gerrit_Virtual_Submit
2022-07-13 16:42:23 -07:00
Vedashree Vidwans
db4f24026e tegra: hwpm: Rename slcg HAls to cg HALs
There are different clock gating types. Currently, t234 HWPM only
supports SLCG, however it is possible that future chips will include
more CG features.
Rename disable_slcg() and enable_slcg() HALs to disable_cg() and
enable_cg() respectively.
Setting CG features to enabled mode is a PROD value. Hence, call
enable_cg() from init_prod_values().
To make sure that the CG features are disabled during profiling session,
rearrange init_prod_value() function call before disable_cg().

Bug 3682605

Change-Id: I3426603de14a14bce37880a8c47833ae3203665e
Signed-off-by: Vedashree Vidwans <vvidwans@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2734039
(cherry picked from commit eb5cacc67a551714d453465d4ef070971718375a)
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2737531
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
2022-07-13 16:32:41 -07:00
Manish Bhardwaj
f9d82f5bb7 nvidia: destroy device on probe failure
Using this patch we are destroying the device if
clock API gets failed and handling the failure
case gracefully otherwise we are are going to get
below warning if the probe gets deferred.

[    9.383997] sysfs: cannot create duplicate
               filename '/devices/virtual/tegra-soc-hwpm'
[    9.384000] CPU: 1 PID: 92 Comm: kworker/1:1
               Tainted: G  W  5.10.104-rt63-tegra #8
[    9.384002] Hardware name: p3710-0010 (DT)
[    9.384004] Workqueue: events deferred_probe_work_func
[    9.384010] Call trace:
[    9.384011]  dump_backtrace+0x0/0x1d0
[    9.384016]  show_stack+0x30/0x50
[    9.384019]  dump_stack+0xd8/0x140
[    9.384022]  sysfs_warn_dup+0x6c/0x90
[    9.384026]  sysfs_create_dir_ns+0xf0/0x110
[    9.384028]  kobject_add_internal+0x94/0x2a0
[    9.384032]  kobject_add+0x90/0x110
[    9.384033]  get_device_parent.isra.0+0x184/0x1b0
[    9.384036]  device_add+0xcc/0x760
[    9.384039]  device_create_groups_vargs+0xec/0x110
[    9.384041]  device_create+0x94/0xd0
[    9.384043]  tegra_hwpm_probe+0x114/0x4c0
[    9.384048]  platform_drv_probe+0x5c/0xd0
[    9.384050]  really_probe+0xf8/0x3e0
[    9.384051]  driver_probe_device+0x60/0xd0
[    9.384053]  __device_attach_driver+0x8c/0xf0
[    9.384054]  bus_for_each_drv+0x8c/0x100
[    9.384057]  __device_attach+0x100/0x160
[    9.384058]  device_initial_probe+0x28/0x40
[    9.384060]  bus_probe_device+0xac/0xd0
[    9.384061]  deferred_probe_work_func+0x90/0xd0
[    9.384062]  process_one_work+0x1c4/0x4f0
[    9.384064]  worker_thread+0x200/0x430
[    9.384065]  kthread+0x180/0x1c0
[    9.384068]  ret_from_fork+0x10/0x24
[    9.384070] kobject_add_internal failed for tegra-soc-hwpm
               with -EEXIST, don't try to register things with
               the same name in the same directory.
[    9.384073] tegra-soc-hwpm: tegra_hwpm_probe: 127: ERROR:
               Failed to create device
[    9.384080] tegra-soc-hwpm: tegra_hwpm_probe: 208: ERROR:
               Probe failed!

JIRA ESLC-6775

Signed-off-by: Manish Bhardwaj <mbhardwaj@nvidia.com>
Change-Id: Ide0d16f420a1c52eadf1b6166859c02906c2ac2f
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2737713
Reviewed-by: Vedashree Vidwans <vvidwans@nvidia.com>
Reviewed-by: Vipin Kumar <vipink@nvidia.com>
GVS: Gerrit_Virtual_Submit
2022-07-05 05:40:06 -07:00
Karthik Ramamoorthy
a90a599fe0 tegra: hwpm: t234: correct ip fs_info status
fix bug where ip status is set as valid even if no instances are
available.
Update floorsweep info computation to left shift calculated floorsweep
mask by number of elements for every instance.

JIRA THWPM-63

Change-Id: I1a51586c44626857e6fae7f46128bedd60fe3c5c
Signed-off-by: Karthik Ramamoorthy <kramamoorthy@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2735968
Reviewed-by: svcacv <svcacv@nvidia.com>
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
Reviewed-by: svc-mobile-cert <svc-mobile-cert@nvidia.com>
Reviewed-by: Vedashree Vidwans <vvidwans@nvidia.com>
Reviewed-by: svc_kernel_abi <svc_kernel_abi@nvidia.com>
Reviewed-by: Seema Khowala <seemaj@nvidia.com>
Reviewed-by: Vasuki Shankar <vasukis@nvidia.com>
GVS: Gerrit_Virtual_Submit
Tested-by: Vedashree Vidwans <vvidwans@nvidia.com>
2022-06-30 16:43:26 -07:00
Vedashree Vidwans
56007741bc tegra: hwpm: update element fs mask at open
IPs supported for performance management register themselves with
required funtion pointers. The HWPM driver processes the request and
marks the given IP instance valid.
To mark elements of the registered IP instance valid, HWPM reads one of
the allowlist registers. Register read is essential to confirm
availability of the element. Register reads for floorswept elements
should return with error.

Currently, HWPM driver marks all elements of an IP instance as available
at registration time. The process to update element mask considering
floorswept elements is performed during IP reservation.
Users querying floorsweeping info before reservation ioctls would
receive incorrect fs_info masks.

To fix this issue, move updating of IP instance element fs_info at
device open. If device is already opened, update element mask during
registration.
- Implement TEGRA_HWPM_UPDATE_IP_INST_MASK case to update element fs
mask for given IP.

Bug 3685203
Bug 3584061

Change-Id: If992204e6f7debf24b36a94f2b752b5077333cda
Signed-off-by: Vedashree Vidwans <vvidwans@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2734732
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
Reviewed-by: svc-mobile-cert <svc-mobile-cert@nvidia.com>
Reviewed-by: svc_kernel_abi <svc_kernel_abi@nvidia.com>
Reviewed-by: Seema Khowala <seemaj@nvidia.com>
GVS: Gerrit_Virtual_Submit
2022-06-30 16:43:18 -07:00
Vedashree Vidwans
1563712b77 tegra: hwpm: add multiple chip config
- Add support for HWPM on next chip. Update tegra_hwpm_init_chip_info to
include next chip init.
- Rename CONFIG_SOC_HWPM_IP_* flags defined in Makefile to use chip name

Jira THWPM-41

Change-Id: I6b1556eb8775fa795699241d5efb2d3370f93531
Signed-off-by: Vedashree Vidwans <vvidwans@nvidia.com>
(cherry picked from commit 17bb2b25bcd147a15862b62f47d29d89fa5162df)
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2671797
Reviewed-by: svcacv <svcacv@nvidia.com>
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: Vasuki Shankar <vasukis@nvidia.com>
Reviewed-by: Seema Khowala <seemaj@nvidia.com>
GVS: Gerrit_Virtual_Submit
2022-06-17 07:13:24 -07:00
Vedashree Vidwans
43e7c9c0ae video: tegra: nvdla: add HWPM support
Register IP instance and required function pointers with HWPM driver.
Remove force enable of NVDLA in HWPM driver.

Bug 3333035

Change-Id: I001d5838a886d12756b9810edadc2d54e1871f99
Signed-off-by: Vedashree Vidwans <vvidwans@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2672510
Reviewed-by: svcacv <svcacv@nvidia.com>
Reviewed-by: svc_kernel_abi <svc_kernel_abi@nvidia.com>
Reviewed-by: Praveen K <kpraveen@nvidia.com>
Tested-by: Praveen K <kpraveen@nvidia.com>
Tested-by: Vasuki Shankar <vasukis@nvidia.com>
GVS: Gerrit_Virtual_Submit
2022-06-14 07:58:54 -07:00
Vedashree Vidwans
46e2ea58f1 tegra: hwpm: fix sparse semantic violations
Fix following violations reported by sparse tool
- warning: symbol 'tegra_hwpm_debugfs_*' was not declared. Should it
be static?
  Add missing header in tegra_hwpm_debugfs.c file to fix this issue

- warning: no newline at end of file
  Add new end line in tegra_hwpm_alist_utils.c to fix this issue.

- warning: symbol 't234_chip_info' was not declared. Should it be
static?
  Modify t234_chip_info structure to be static to fix this issue.

- warning: symbol '*_perfmon_element_static_array' was not declared.
Should it be static?
- warning: symbol '*_perfmux_element_static_array' was not declared.
Should it be static?
- warning: symbol '*_inst_static_array' was not declared. Should it
be static?
  Modify each *_perfmon_element_static_array,
*_perfmux_element_static_array and *_inst_static_array in all IPs to be
static to fix this issue.

Bug 3528414

Change-Id: I58e7a1c6e14988d7315fb8d160aa7f89a2eb4cf5
Signed-off-by: Vedashree Vidwans <vvidwans@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2725821
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
2022-06-09 14:24:48 -07:00
vasukis
d1de75a664 tegra: hwpm: Enable PVA, DLA, MSS_Channel in HWPM
- Enable PVA, NVDLA and MSS_Channel IPs for HWPM
profiling.
- Force enable MSS_Channel in Hypervisor config,
NVDLA by default.
- Remove hypervisor checks in ip_readl and ip_writel
functions.
- Replace PCIE config enable flag from CONFIG_PCIE_TEGRA to
CONFIG_PCIE_TEGRA194.
- Add missing resource status init value for MSS channel IP.

Bug 3632111

Change-Id: I6b36a3a3b3179b99542d8ed03027c8849fe9f712
Signed-off-by: vasukis <vasukis@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2725087
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
Reviewed-by: svc-mobile-cert <svc-mobile-cert@nvidia.com>
Reviewed-by: svcacv <svcacv@nvidia.com>
Reviewed-by: Vedashree Vidwans <vvidwans@nvidia.com>
Reviewed-by: svc_kernel_abi <svc_kernel_abi@nvidia.com>
Reviewed-by: Seema Khowala <seemaj@nvidia.com>
GVS: Gerrit_Virtual_Submit
2022-06-09 05:36:54 -07:00
Vedashree Vidwans
5c94e7dad3 tegra: hwpm: fix global disable expected value
HWPM_GLOBAL_DISABLE sticky bit is expected to have value 0 indicating
that HWPM profiling is allowed and value 1 indicates that HWPM perfmons
should be disabled.

Bug 3665263

Change-Id: Idfa77592e2a8a8307490f9265e4713741db6c1f4
Signed-off-by: Vedashree Vidwans <vvidwans@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2723370
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>
Reviewed-by: svcacv <svcacv@nvidia.com>
GVS: Gerrit_Virtual_Submit
2022-06-03 20:10:54 -07:00
Vedashree Vidwans
97c0f1da08 tegra: hwpm: fix coverity defects
Correct order of arguments passed to log function. This will fix
reported coverity defects.

Jira THWPM-41

Change-Id: Ida2558d651f70bbc436f5640f531f6b5596b5081
Signed-off-by: Vedashree Vidwans <vvidwans@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2723369
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>
Reviewed-by: svcacv <svcacv@nvidia.com>
GVS: Gerrit_Virtual_Submit
2022-06-03 20:10:49 -07:00
Vedashree Vidwans
72aa834670 tegra: hwpm: add fa mode fuse condition
If FA mode fuse is set, allow all IPs to be enabled irrespective of
build config.

Bug 3435123

Change-Id: I937d8f9fa79706167102daadd9c3a04a80180cfb
Signed-off-by: Vedashree Vidwans <vvidwans@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2720737
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
2022-06-03 20:10:43 -07:00
Vedashree Vidwans
5c8a07022f 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
2022-06-03 20:10:38 -07:00
Vedashree Vidwans
6d0e0ee04d tegra: hwpm: add force enable IP flag
Implement flag to enable IP force_enable. IP force_enable expects full
chip config of the IP. Hence, this macro should be enabled only for
full chip configs.

Jira THWPM-41
Bug 3435091

Change-Id: Ic2f669fee4e58a22ae20cc435bf627cd37d46e7e
Signed-off-by: Vedashree Vidwans <vvidwans@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2717980
Reviewed-by: svcacv <svcacv@nvidia.com>
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
2022-06-03 20:10:33 -07:00
Vedashree Vidwans
bd8ca72dc2 tegra: hwpm: expand debug log masks
Add more debug masks to better manage debug prints.

Jira THWPM-41

Change-Id: Ibfa41f0aeb0e630e264a12d9e15df363eb4774dc
Signed-off-by: Vedashree Vidwans <vvidwans@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2715619
Reviewed-by: svc_kernel_abi <svc_kernel_abi@nvidia.com>
Reviewed-by: Seema Khowala <seemaj@nvidia.com>
Reviewed-by: Vasuki Shankar <vasukis@nvidia.com>
GVS: Gerrit_Virtual_Submit
2022-05-25 11:41:15 -07:00
Vedashree Vidwans
5518c6ea4c tegra: hwpm: set IP config as per fuse setting
Performance monitoring of IPs is dependent on the build config.
Read SOC fuses and set IP override_enable accordingly.

Jira THWPM-41

Change-Id: Id289a3e6763d3f3a7852e098b8a12be2eeec8e62
Signed-off-by: Vedashree Vidwans <vvidwans@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2677058
Reviewed-by: svc_kernel_abi <svc_kernel_abi@nvidia.com>
Reviewed-by: Vasuki Shankar <vasukis@nvidia.com>
Reviewed-by: Seema Khowala <seemaj@nvidia.com>
GVS: Gerrit_Virtual_Submit
2022-05-25 11:41:10 -07:00
Vedashree Vidwans
146211284c tegra: hwpm: Update IP config flags
Add IP config flag conditions missing from ip util functions.
Re-arrange config flags in Makefile along with ip object files.
Add Kconfig file to define chip specific configs.

Jira THWPM-8

Change-Id: Iebe4a6e5e3927a00deb4e2611bbc731eeb526f82
Signed-off-by: Vedashree Vidwans <vvidwans@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2707317
Reviewed-by: Vasuki Shankar <vasukis@nvidia.com>
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
2022-05-18 22:57:23 -07:00
Vedashree Vidwans
f992d78140 tegra: hwpm: remove force enable of MSS IPs
MC <-> HWPM interface is merged.
Remove force enable of MSS IPs in HWPM driver.

Bug 3333049

Change-Id: I473f02729d805836fe683f25112b26aab7166050
Signed-off-by: Vedashree Vidwans <vvidwans@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2710513
Reviewed-by: svcacv <svcacv@nvidia.com>
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
Reviewed-by: svc-mobile-cert <svc-mobile-cert@nvidia.com>
Reviewed-by: Vasuki Shankar <vasukis@nvidia.com>
Reviewed-by: Seema Khowala <seemaj@nvidia.com>
Reviewed-by: svc_kernel_abi <svc_kernel_abi@nvidia.com>
GVS: Gerrit_Virtual_Submit
2022-05-18 22:57:18 -07:00
Vedashree Vidwans
6fa5d10ca0 tegra: hwpm: update floorsweep info IOCTL
- Update tegra_soc_hwpm_ip enum to hold only IPs which can be
floorswept.
- Update floorsweep_info IOCTL to return floorsweepable component
details of tegra_soc_hwpm_ip IPs.

Bug 3573882

Change-Id: Ia62222ba8afdf60b25d0f3701bfd2be215bb6071
Signed-off-by: Vedashree Vidwans <vvidwans@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2713363
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
Reviewed-by: svc-mobile-cert <svc-mobile-cert@nvidia.com>
Reviewed-by: Vasuki Shankar <vasukis@nvidia.com>
Reviewed-by: svc_kernel_abi <svc_kernel_abi@nvidia.com>
Reviewed-by: Seema Khowala <seemaj@nvidia.com>
GVS: Gerrit_Virtual_Submit
2022-05-18 22:57:12 -07:00
Vedashree Vidwans
dd86a4afb2 tegra: hwpm: update and add IOCTLs in UAPI header
- Add resource_info IOCTL to return status of HWPM resources.
- Remove TEGRA_SOC_HWPM_RESOURCE_MSS_NVLINK which is duplicate of
MSS_GPU_HUB.
- Add logic for resource_info IOCTL in the driver code.
- Ptimer and TSC timer have 1:1 relation. Hence timer relation IOCTLs
are not required.

Bug 3573882

Change-Id: I937c6c72636f0c786391a74785673060038d385e
Signed-off-by: Vedashree Vidwans <vvidwans@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2707447
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
Reviewed-by: svc-mobile-cert <svc-mobile-cert@nvidia.com>
Reviewed-by: Vasuki Shankar <vasukis@nvidia.com>
Reviewed-by: Seema Khowala <seemaj@nvidia.com>
Reviewed-by: svc_kernel_abi <svc_kernel_abi@nvidia.com>
GVS: Gerrit_Virtual_Submit
2022-05-18 22:57:07 -07:00
Vedashree Vidwans
fe7a4734a2 tegra: hwpm: update IP registration interface
Enum tegra_soc_hwpm_ip is defined to query IP information. To untangle
its use from HWPM related functionality, enum tegra_soc_hwpm_resource
should be used by IP drivers to register with HWPM.

An IP can have multiple instances with multiple IP core elements in
each instance. Currently, the IP <-> HWPM register access API passes
register offset only. However, it is not possible to figure out
requested specific register access only with register offset. For
example, MC device has one instance with 16 duplicate channels. To
access channel x perfmux register, HWPM driver should pass perfmux
register offset alongwith channel number (index).
Add instance element index as an argument to the register access API,
tegra_soc_hwpm_ip_ops.hwpm_ip_reg_op().
-Update internal copy of tegra_soc_hwpm_ip_ops.
-Update hwpm_ip_reg_op() implemented in flcn driver.
-Update hwpm_ip_reg_op() implemented in pva driver.

Update hwpm_ip_pm() in flcn driver to use nvhost power management APIs.

Bug 3573882
Jira THWPM-8

Change-Id: I0138927f383e9a67085816132ce33538bd609560
Signed-off-by: Vedashree Vidwans <vvidwans@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2713274
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
Reviewed-by: svc-mobile-cert <svc-mobile-cert@nvidia.com>
Reviewed-by: Vasuki Shankar <vasukis@nvidia.com>
Reviewed-by: svc_kernel_abi <svc_kernel_abi@nvidia.com>
Reviewed-by: Seema Khowala <seemaj@nvidia.com>
GVS: Gerrit_Virtual_Submit
2022-05-18 22:56:56 -07:00
Vedashree Vidwans
787831388d tegra: hwpm: fix bugs on ToT
- With latest changes, disable PMA triggers contained a bug related to
timeout checks. Reading register value in while loop was removed
accidentally.
Replace HWPM_TIMEOUT macro with do-while loop to check condition.
- Correct func enum used to release router.
- Correct MSS MCF IP and instance address stride.

Jira THWPM-41

Change-Id: I28b4b223c33992599332de39471fd80215e0c98b
Signed-off-by: Vedashree Vidwans <vvidwans@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2713365
Reviewed-by: Vasuki Shankar <vasukis@nvidia.com>
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
2022-05-18 22:56:50 -07:00
Vedashree Vidwans
c220f9f46f tegra: hwpm: return error from read/write function
Currently, read/write functions validate aperture and mmio address
pointers. However, the error cannot be returned to the parent resulting
into undetected errors.
Modify all read write functions to return error on failure. This will
also allow HWPM driver to know about unavailable IP perfmuxes.

Jira THWPM-41

Change-Id: I6cc4ba7a831d5058657d4f2536b1ce3ab20b30c6
Signed-off-by: Vedashree Vidwans <vvidwans@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2707446
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
Reviewed-by: svc-mobile-cert <svc-mobile-cert@nvidia.com>
Reviewed-by: svc_kernel_abi <svc_kernel_abi@nvidia.com>
Reviewed-by: Vasuki Shankar <vasukis@nvidia.com>
Reviewed-by: Seema Khowala <seemaj@nvidia.com>
GVS: Gerrit_Virtual_Submit
2022-05-17 08:43:13 -07:00
Vedashree Vidwans
8e27814e39 tegra: hwpm: return error for nested open
Currently, nested open for hwpm device node is not allowed. Return
error value of EAGAIN if hwpm device is already open.

Bug 3584058

Change-Id: I2e940620d8da5ddc432628569f839ead6ed490a7
Signed-off-by: Vedashree Vidwans <vvidwans@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2707445
Reviewed-by: svcacv <svcacv@nvidia.com>
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
Reviewed-by: svc-mobile-cert <svc-mobile-cert@nvidia.com>
Reviewed-by: svc_kernel_abi <svc_kernel_abi@nvidia.com>
Reviewed-by: Vasuki Shankar <vasukis@nvidia.com>
Reviewed-by: Seema Khowala <seemaj@nvidia.com>
GVS: Gerrit_Virtual_Submit
2022-05-17 08:43:07 -07:00
Vedashree Vidwans
3b6a1b35b7 tegra: hwpm: update basic structure layout
Introduced macros to define HWPM aperture types perfmon, perfmux and
broadcast.
Added new enum to define element type.
IP perfmux and IP broadcast are handled in similar way. Whereas, HWPM
perfmux should use HWPM perfmon functions.

Updated hwpm structures are as below
Parent HWPM structure
  -> Active chip structure
     -> Array of IPs
     -> HALs

IP structure
  -> Array of instances
  -> Array of instance info with respect to perfmon, perfmux, broadcast
  -> Instance mask : indicates available instances
  -> reserved status

Instance structure
  -> Array of element info with respect to perfmon, perfmux, broadcast
      -> Array of corresponding element structures
  -> Element mask : indicates available elements in the instance

Element structure
  -> Aperture address details
  -> DT node / MMIO details

Update all functions to use new HWPM structures.

Update hwpm_probe to include force IP enable step.

Jira THWPM-41

Change-Id: I9461063d2136b34e841322c4ddd77a20486424c6
Signed-off-by: Vedashree Vidwans <vvidwans@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2706489
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
Reviewed-by: svc-mobile-cert <svc-mobile-cert@nvidia.com>
Reviewed-by: svc_kernel_abi <svc_kernel_abi@nvidia.com>
Reviewed-by: Vasuki Shankar <vasukis@nvidia.com>
Reviewed-by: Seema Khowala <seemaj@nvidia.com>
GVS: Gerrit_Virtual_Submit
2022-05-17 08:43:01 -07:00
Vedashree Vidwans
7dd5b5c956 tegra: hwpm: consider PMA as regular IP
PMA and RTR perfmuxes contain registers required to configure HWPM.
So currently, PMA and RTR IPs are treated as special case and
initialized - released along with the driver.
However, as RTR IP includes both router and pma apertures, only treat
RTR as special IP. Change RTR config to have router and pma apertures
as separate instances. Define macros for router and pma instance index.
This will be allow to retrieve router and pma aperture structures.

Remove PMA IP reservation during driver init and PMA IP release at
driver close. As PMA IP is not treated special now,
remove get_pma_ip_idx() HAL.

Modify HWPM configuration functions to use router and pma apertures
initialized as part of RTR IP.

Jira THWPM-41

Change-Id: Ic82b2d07769c1b5c4601e07776be06087468657d
Signed-off-by: Vedashree Vidwans <vvidwans@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2706488
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
Reviewed-by: svc-mobile-cert <svc-mobile-cert@nvidia.com>
Reviewed-by: svc_kernel_abi <svc_kernel_abi@nvidia.com>
Reviewed-by: Vasuki Shankar <vasukis@nvidia.com>
Reviewed-by: Seema Khowala <seemaj@nvidia.com>
GVS: Gerrit_Virtual_Submit
2022-05-17 08:42:56 -07:00
Vedashree Vidwans
25f0737897 tegra: hwpm: combine common functionality
- Many HWPM functions are performed on all apertures of all instances of
all IPs. Define below resource utility functions to perform a task on
all IPs, instances and apertures:
  - tegra_hwpm_func_all_IPs
  - tegra_hwpm_func_single_ip
  - tegra_hwpm_func_all_instance
  - tegra_hwpm_func_single_instance
  - tegra_hwpm_func_all_perfmuxes
  - tegra_hwpm_func_all_perfmons
  - tegra_hwpm_func_single_aperture
- Modify below functions to use above mentioned utility functions:
  - get allowlist size
  - combine allowlist
  - reserve resources
  - bind resources
  - release resources

This will make code more legible and maintainable.

This patch also defines new function that validates all HAL
initializations for the chip.

Jira THWPM-41

Change-Id: Icaeba4d94187b97022c0a6626584e7d61ab6d0e4
Signed-off-by: Vedashree Vidwans <vvidwans@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2705524
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
Reviewed-by: svc-mobile-cert <svc-mobile-cert@nvidia.com>
Reviewed-by: svc_kernel_abi <svc_kernel_abi@nvidia.com>
Reviewed-by: Vasuki Shankar <vasukis@nvidia.com>
Reviewed-by: Seema Khowala <seemaj@nvidia.com>
GVS: Gerrit_Virtual_Submit
2022-05-17 08:42:51 -07:00
Vedashree Vidwans
c5b3d09518 tegra: hwpm: remove force enable of PVA
PVA <-> HWPM interface is ready to be merged.
Remove force enable of PVA in HWPM driver.

Bug 3333034

Change-Id: Ide331e654ac0beaf0bcbdb987b726938927c6d54
Signed-off-by: Vedashree Vidwans <vvidwans@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2710503
Reviewed-by: svcacv <svcacv@nvidia.com>
Reviewed-by: Omar Nemri <onemri@nvidia.com>
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>
GVS: Gerrit_Virtual_Submit
2022-05-11 04:17:13 -07:00
Vedashree Vidwans
ea5e4e406b tegra: hwpm: add HALs to support multiple chip
Add below HALs to make code chip agnostic. This will allow us to use
t234 specific HALs for next chips.
- get_pma_int_idx: get PMA's internal index corresponding to active chip
- get_rtr_int_idx: get RTR's internal index corresponding to active chip
- get_ip_max_idx: get MAX IP index corresponding to active chip

Move chip agnostic code to common files.

Jira THWPM-41

Change-Id: I5518469b1473fe7f66b6517cee729cf46520bbac
Signed-off-by: Vedashree Vidwans <vvidwans@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2675515
Reviewed-by: svc_kernel_abi <svc_kernel_abi@nvidia.com>
Reviewed-by: Vasuki Shankar <vasukis@nvidia.com>
Reviewed-by: Seema Khowala <seemaj@nvidia.com>
GVS: Gerrit_Virtual_Submit
2022-04-20 13:26:32 -07:00
Vedashree Vidwans
53f8d0799c tegra: hwpm: update IP registration logic
HWPM supports various IPs which initialize at different times in boot
flow. Some IPs such as MSS, NVLINK initialize before HWPM device and
some IPs (VIC, OFA, NVDEC, NVDLA) are initialized after HWPM device.
Modify IP register function to store registration requests in a
linked list for IPs initialized before HWPM device is probed.
The linked list will be traversed to complete pending IP register
requests after HWPM device is initialized.
- Add struct tegra_hwpm_ip_ops internal to HWPM driver to include only
required ip_ops details.
- Replace init_fs_info HAL with finalize_chip_info to register ip_ops,
force enable IPs (if any).

Jira THWPM-41

Change-Id: I916b4fa50679e79025a941a9c1fc113bdfe92b41
Signed-off-by: Vedashree Vidwans <vvidwans@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2675472
Reviewed-by: svc_kernel_abi <svc_kernel_abi@nvidia.com>
Reviewed-by: Vasuki Shankar <vasukis@nvidia.com>
Reviewed-by: Seema Khowala <seemaj@nvidia.com>
GVS: Gerrit_Virtual_Submit
2022-04-20 13:26:26 -07:00
vasukis
09ca7098e4 hwpm: Disable setting fs_info for hypervisor
Set the floorsweeping information for IPs only
if the configuration is non Hypervisor. Force
enable IPs are only valid for native-Linux config.
On hypervisor config, a driver is allowed to only
remap addresses owned by the device node.
Thus, ioremap of perfmux addresses is not allowed
in hypervisor configuration. Add check to prevent
force enable IPs and ioremap in hypervisor
configuration.

JIRA THWPM-45

Change-Id: I8fe6d3c4984c66be5a117e0cc2164ea20a5374cb
Signed-off-by: vasukis <vasukis@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2674003
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: Seema Khowala <seemaj@nvidia.com>
GVS: Gerrit_Virtual_Submit
2022-04-10 00:08:16 -07:00
Vedashree Vidwans
778356e12d tegra: hwpm: add device_opened flag
Add device_opened flag to indicate device node open success.
Use device_opened flag to allow execution of IOCTL and device teardown
functionality.

Jira THWPM-41

Change-Id: I218a45abed1de9f314cba696fd86c9bd8596cacc
Signed-off-by: Vedashree Vidwans <vvidwans@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2675514
Reviewed-by: svcacv <svcacv@nvidia.com>
Reviewed-by: svc_kernel_abi <svc_kernel_abi@nvidia.com>
Reviewed-by: Seema Khowala <seemaj@nvidia.com>
Reviewed-by: Vasuki Shankar <vasukis@nvidia.com>
GVS: Gerrit_Virtual_Submit
2022-03-17 19:45:12 -07:00
Vedashree Vidwans
9f2a83a828 tegra: hwpm: fix bugs in force enable IP
Use t234 specific enums to force enable MSS IPs supported by HWPM.
Correct logic to calculate MSS channel fs_info.

Jira THWPM-41

Change-Id: I343cec6f2c9aac78925b1eb441a119d4d6415c38
Signed-off-by: Vedashree Vidwans <vvidwans@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2678497
Reviewed-by: svcacv <svcacv@nvidia.com>
Reviewed-by: svc_kernel_abi <svc_kernel_abi@nvidia.com>
Reviewed-by: Seema Khowala <seemaj@nvidia.com>
Reviewed-by: Vasuki Shankar <vasukis@nvidia.com>
GVS: Gerrit_Virtual_Submit
2022-03-15 17:33:06 -07:00
Vedashree Vidwans
bc59377a8f tegra: hwpm: rewrite active ip enum macros
- Update active ip enum flag macros to make it more legible.

Jira THWPM-41

Change-Id: Ic23f39c85080a931128592fef173c2257aa6cf9c
Signed-off-by: Vedashree Vidwans <vvidwans@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2675470
Reviewed-by: svc_kernel_abi <svc_kernel_abi@nvidia.com>
Reviewed-by: Vasuki Shankar <vasukis@nvidia.com>
Reviewed-by: Seema Khowala <seemaj@nvidia.com>
GVS: Gerrit_Virtual_Submit
2022-03-15 17:33:00 -07:00
Vedashree Vidwans
9adf6a080d tegra: hwpm: use consistent function names
- Update common function names to tegra_hwpm_* instead of
tegra_soc_hwpm_*.
- Update header guards to follow similar naming guidelines.

Jira THWPM-41

Change-Id: If5ca4f136f5cb6659a99bae42030817142bd242c
Signed-off-by: Vedashree Vidwans <vvidwans@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2675469
Reviewed-by: svcacv <svcacv@nvidia.com>
Reviewed-by: svc_kernel_abi <svc_kernel_abi@nvidia.com>
Reviewed-by: Seema Khowala <seemaj@nvidia.com>
Reviewed-by: Vasuki Shankar <vasukis@nvidia.com>
GVS: Gerrit_Virtual_Submit
2022-03-15 17:32:54 -07:00
Vedashree Vidwans
edb9e2c245 tegra: hwpm: fix cert-c errors
Fix coding standard cert-c violations because of unsafe calculations.
Introduce safe subtract, add, multiply and cast APIs and use throughout
the hwpm driver.

Bug 3512545

Change-Id: If374629ac75b48a8bc08b1b7a9a41ea5ef0526b1
Signed-off-by: Vedashree Vidwans <vvidwans@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2677160
Reviewed-by: svc_kernel_abi <svc_kernel_abi@nvidia.com>
Reviewed-by: Vasuki Shankar <vasukis@nvidia.com>
Reviewed-by: Seema Khowala <seemaj@nvidia.com>
Reviewed-by: Prateek Patel <prpatel@nvidia.com>
GVS: Gerrit_Virtual_Submit
2022-03-15 17:32:48 -07:00
Vedashree Vidwans
aaf8e7f5e1 tegra: hwpm: modify floorsweep info for MSS
For MSS channel, hwpm client expects floorsweep info mask to indicate
available MSS chanenel perfmuxes.
HWPM driver would prefer to follow common fs_mask logic for IPs and is
being discussed.
Temporarily update floorsweep info logic for MSS channel, until
floorsweep info IOCTL modifications are finalized.

Bug 3477617

Change-Id: I75b51ccc60151e801dec50fa32b15b951db6e47e
Signed-off-by: Vedashree Vidwans <vvidwans@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2672291
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
2022-03-02 09:50:37 -08:00
Vedashree Vidwans
afc8321841 tegra: hwpm: fix bugs in ip_register function
- MSS IPs share combination of MC instances. In other words, not all MC
instances base addresses are available in each MSS IP. Handle this
difference while registering IP instances.

Jira THWPM-41

Change-Id: I82f7c0a3640ebd9af5599c258cb0e8f45dd7eedf
Signed-off-by: Vedashree Vidwans <vvidwans@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2675471
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
Reviewed-by: svc-mobile-cert <svc-mobile-cert@nvidia.com>
Reviewed-by: svc_kernel_abi <svc_kernel_abi@nvidia.com>
Reviewed-by: Vasuki Shankar <vasukis@nvidia.com>
Reviewed-by: Seema Khowala <seemaj@nvidia.com>
GVS: Gerrit_Virtual_Submit
2022-03-02 09:50:22 -08:00
Vedashree Vidwans
7f5bfd3176 tegra: hwpm: resolve coverity defects
Resolve coverity violations:
- Correct invalid arguments in debug prints
- Modify if statement to compare similar data types
- Update tegra_hwpm_map_stream_buffer() return statements.

Bug 3461002

Change-Id: Ic299a594bc371bac4a96a035f31961a586486083
Signed-off-by: Vedashree Vidwans <vvidwans@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2675433
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: Seema Khowala <seemaj@nvidia.com>
Reviewed-by: Vasuki Shankar <vasukis@nvidia.com>
GVS: Gerrit_Virtual_Submit
2022-03-01 00:10:40 -08:00
Vedashree Vidwans
92be6f7a00 tegra: hwpm: restructure HWPM driver
- Update HWPM driver to add HAL layer. This will allow support for multiple chips.
- Add below data structure hierarchy for HWPM driver
HWPM driver structure -> chip info struct -> ip info array -> perfmux/perfmon info array
NOTE: To make commit message more legible, using "aperture" instead of "perfmux and/or perfmon"
- Chip info structure contains
  - Array of IP info
  - HAL function pointers
- IP info structure contains IP specific info
  - Number of instances
  - Number of apertures per instance
  - Aperture ranges, strides, static info array
  - Aperture dynamic arrays
- Aperture info structure contains
  - Hw index
  - Physical address info
  - MMIO address info
- Add separate IP info files
- Create separate files that include logic for allowlist, memory buffer, resources, ip, regops to make functions more legible.
- Move probe, ioctl and io functions to os/linux path.
- Add fn, info, register and verbose debug log levels to controls debug messages
  - add debugfs node to update dbg_mask
- Correct MGBE perfmux base address

Jira THWPM-41

Change-Id: I8ffdaa657789e2a187cbb98502d0359bb57f9c54
Signed-off-by: Vedashree Vidwans <vvidwans@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2651377
Reviewed-by: svc_kernel_abi <svc_kernel_abi@nvidia.com>
Reviewed-by: Seema Khowala <seemaj@nvidia.com>
GVS: Gerrit_Virtual_Submit
2022-02-09 09:46:25 -08:00
Prateek Patel
96db4ef5ab tegra: hwpm: fix null check Coverity defect
Null-checking inode suggests that it may be null, but it has already
been dereferenced on path leading to the check. Fix it by adding the
null check in correct sequence.

CID 10127947

Bug 3461002

Change-Id: Ib9135bdb67c489fa52f5dda6725d3cbd1faddd1e
Signed-off-by: Prateek Patel <prpatel@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2645543
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
2022-01-05 17:25:53 -08:00
Prateek Patel
28bcbc77d2 tegra: hwpm: fix invalid_type Coverity defect
Fix invalid type in argument to printf format specifier.

CID 10127836
CID 10127935

Bug 3461002

Change-Id: Icbc2c55d739c206f0107eff6b9ce4fade07e3755
Signed-off-by: Prateek Patel <prpatel@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2643090
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
2022-01-05 17:25:37 -08:00
Prateek Patel
90a328b59a tegra: hwpm: fix Out-of-bounds read
Overrunning array ioctls of 9 24-byte elements at element index 9 OR
less than 0 by using index ioctl_num. Fix it by returning on failure.

CID 10127854

Bug 3461002

Change-Id: If1774967e28f7042f903027b1a18ce89139306e4
Signed-off-by: Prateek Patel <prpatel@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2645564
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
2022-01-04 16:56:20 -08:00
Vedashree Vidwans
fbfb46dc21 tegra: t234: soc hwpm: add ip reg read/write support
If IP driver supports register read/write mechanism
then call register call back for register offset read/write.

Bug 3333031
Bug 3333042

Change-Id: I37e0726edadac9b03d2a5368d0ec7b404cb6dfd3
Signed-off-by: Vedashree Vidwans <vvidwans@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2628129
Reviewed-by: svc_kernel_abi <svc_kernel_abi@nvidia.com>
Reviewed-by: Seema Khowala <seemaj@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
GVS: Gerrit_Virtual_Submit
2021-12-10 19:18:02 -08:00
Vedashree Vidwans
3edf3f6034 tegra: soc_hwpm: t234: move chip specific files
Move chip specific code to chip specific folder. This will allow
multiple chip support in the future.
Create new specific functions
- Initialize hwpm structures
- Reserve and release PMA and RTR apertures
- Zero, update and check allowlists
- Set and get fake registers for MC aperture on simulation
- perfmon dt aperture enums

Jira THWPM-41

Change-Id: Ib80f324283c8d29b5c6f7bb6345a6df2410954e6
Signed-off-by: Vedashree Vidwans <vvidwans@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2620234
Reviewed-by: svc_kernel_abi <svc_kernel_abi@nvidia.com>
Reviewed-by: Seema Khowala <seemaj@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
GVS: Gerrit_Virtual_Submit
2021-12-10 19:17:55 -08:00
Seshendra Gadagottu
1dd2527129 tegra: t234: soc hwpm: NULL check for ip dev registration
Add "NULL" check for ip_dev in tegra_soc_hwpm_ip_register
and tegra_soc_hwpm_ip_unregister function.

Also reduced log level to dbg to avoid kernel warning message
for legacy chips to indicate soc_hwpm driver is not available.

Bug 3333031
Bug 3333042

Change-Id: If3a82fdc3ceb0f935750c1fee661828a04c306e9
Signed-off-by: Seshendra Gadagottu <sgadagottu@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2627691
Reviewed-by: svc_kernel_abi <svc_kernel_abi@nvidia.com>
Reviewed-by: Seema Khowala <seemaj@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
GVS: Gerrit_Virtual_Submit
Tested-by: Seema Khowala <seemaj@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2021-11-24 15:59:36 -08:00