Commit Graph

9 Commits

Author SHA1 Message Date
Vedashree Vidwans
170c9552c8 tegra: hwpm: update dma buf pointer as per oot def
OOT definition of dma_buf_vmap() is changed to accept 2 arguments. The
second argumentt is used to return the dma mapping of the user buffer.
However, this output pointer is expected to point to an allocated
sma_buf_map structure. Add dma_buf_map structure as a member of struct
tegra_hwpm_mem_mgmt.

Bug 3768922

Change-Id: Ie776b7b7d0e364e6391212b9df87acbb4c43f1fa
Signed-off-by: Vedashree Vidwans <vvidwans@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2778946
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
Reviewed-by: svcacv <svcacv@nvidia.com>
Reviewed-by: Seema Khowala <seemaj@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
2022-09-26 16:02:19 -07:00
Jon Hunter
ef085231d2 tegra: hwpm: Fix build for Linux v5.18
Upstream commit 7938f4218168 ("dma-buf-map: Rename to iosys-map")
renames 'struct dma_buf_map' to 'struct iosys_map' and this causes the
HWPM driver build to fail for Linux v5.18 and greater. Fix this by using
the appropriate structure name depending on kernel version.

Bug 3767126

Change-Id: I2f2b3839b27e3ac665180f45c811ffbef82199cc
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2778803
Tested-by: Rohit Khanna <rokhanna@nvidia.com>
Reviewed-by: Vedashree Vidwans <vvidwans@nvidia.com>
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
Reviewed-by: Seema Khowala <seemaj@nvidia.com>
Reviewed-by: Rohit Khanna <rokhanna@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
2022-09-21 15:27:18 -07:00
Vedashree Vidwans
4cacfb709c tegra: hwpm: fix bugs and rearrange functions
Fix bugs for accessing uninitialized mem_mgmt and alist_map structures.
- Not initializing memory management functionality in HWPM is a valid
situation. Currently, tegra_hwpm_clear_mem_pipeline dereferences the
mem_mgmt pointer without validation, which can lead to failures. Check
if mem_mgmt struct pointer is valid before dereferencing.
- Alist_map structure is only required if user requests allowlist size
or list of allowlist registers. Currently, tegra_hwpm_sw_setup
dereferences alist_map pointer to set full_alist_size to 0. Add
alist_map allocation function and set full_alist_size to 0.
- Add PMA and CMD_ROUTER as valid cases for
tegra_hwpm_translate_soc_hwpm_resource() translation.
- Move logic to record IP function pointers to separate function. This
way changes to IP ops registration will be in single location.

Jira THWPM-41

Change-Id: I2c221bb13b6875b76a6fabee4c224d77ac72a6fc
Signed-off-by: Vedashree Vidwans <vvidwans@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2770418
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
Reviewed-by: Vasuki Shankar <vasukis@nvidia.com>
Reviewed-by: Seema Khowala <seemaj@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
2022-09-16 07:51:45 -07:00
Vedashree Vidwans
10cd01aa1a tegra: hwpm: use kstable available APIS
- Some of the APIs are not available on stable kernel. Use kstable
specific APIs with LINUX_KERNEL macro condition.
- Temporarily comment functions that are not available on Kstable.
- Next chip headers are renamed to accommodate more than one next chip.
Update next chip includes in init.c and driver.c files.
- Rename TEGRA_SOC_HWPM_IP_INACTIVE to TEGRA_HWPM_IP_INACTIVE to follow
other macro/enum naming convention.
- Use is_resource_active() HAL instead of chip specific function.
- Create clock reset functions that will allow us to handle change in
APIs on kstable.

Jira THWPM-41

Change-Id: I55f58fa51cf9ae96ee9a9565942e68b3b2bb76ee
Signed-off-by: Vedashree Vidwans <vvidwans@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2764840
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
Reviewed-by: Seema Khowala <seemaj@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
2022-09-16 07:51:39 -07:00
Vedashree Vidwans
14d527e97a tegra: hwpm: fix reported coverity violations
- Declare and initialize timeout and mem_bytes_kernel_u32 variables.
- alist_map NULL pointer check is done after alist_map structure
references. Modify update_allowlist ioctl and release alist_map
functions to check alist_map NULL pointer before it's use.
- Checking if unsigned _IOC_NR(cmd) is less than zero has no effect.
Remove this check.
- Correct printf format specifier for mem_bytes_addr.

Bug 3461002

Change-Id: I79a97942e667c173d112bcaafb14ddcb8dd7d47f
Signed-off-by: Vedashree Vidwans <vvidwans@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2765676
Reviewed-by: Vasuki Shankar <vasukis@nvidia.com>
Reviewed-by: Seema Khowala <seemaj@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
2022-08-29 05:16:22 -07:00
Vedashree Vidwans
738361e0e2 tegra: hwpm: add wrapper linux os structure
Currently, HWPM parent structure contains linux specific device
variables. In an effort to make HWPM driver OS agnostic, create Linux
specific wrapper HWPM structure tegra_hwpm_os_linux. Move linux specific
variables from tegra_soc_hwpm structure to tegra_hwpm_os_linux
structure.

Jira THWPM-60

Change-Id: I189cde92c5b83b327ccb467c72dee5756f16481d
Signed-off-by: Vedashree Vidwans <vvidwans@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2729700
Reviewed-by: Seema Khowala <seemaj@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
2022-08-20 23:29:47 -07:00
Vedashree Vidwans
74dee85a03 tegra: hwpm: add wrapper for timeout functions
Move timeout related code using Linux APIs to os/linux path. Add OS
agnostic wrappers for timeout functions.

Jira THWPM-59

Change-Id: I8e6aa8dabd3a54ecc8a946090d11d036c97a104b
Signed-off-by: Vedashree Vidwans <vvidwans@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2735074
Reviewed-by: Seema Khowala <seemaj@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
2022-08-20 23:29:30 -07:00
Vedashree Vidwans
486ec4a24c tegra: hwpm: create memory buffer structures
Stream and allowlist buffers are allocated by the user as dma buffers
and mapped in virtual address space by the driver. The DMA and mapping
functions are linux specific. Hence create memory management and
allowlist linux structures. Add these linux memory structure pointers in
the tegra_hwpm parent structure.

Jira THWPM-60

Change-Id: I2526f2bab835df4c5a922b0b375c22a6247aad30
Signed-off-by: Vedashree Vidwans <vvidwans@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2729664
Reviewed-by: Seema Khowala <seemaj@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
2022-08-20 23:29:24 -07:00
Vedashree Vidwans
221e73d921 tegra: hwpm: move mem_buf functions to os folder
PMA memory buffer functions use linux specific APIs for dma management.
In an effort to make HWPM driver OS agnostic, move the memory buffer
functions to os/linux path.

Jira THWPM-59

Change-Id: I3dbf577921faed579bbd9de3231b26a9acad28ba
Signed-off-by: Vedashree Vidwans <vvidwans@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2738154
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:40 -07:00