Replace struct hack pattern with flexible array members in msgq_t
and msgq_message_t to resolve UBSAN warnings.
The message queue implementation was using the old "struct hack"
pattern with single-element arrays (int32_t queue[1] and
int32_t payload[1]) to create variable-length structures. While
functionally correct, this triggers UBSAN array-index-out-of-bounds
errors when accessing elements beyond index 0, even though the
memory is properly allocated.
UBSAN errors observed:
- msgq.c:64: index 2045 out of range for type 'int32_t [1]'
- msgq.c:69: index 153 out of range for type 'int32_t [1]'
- msgq.c:124: index 53 out of range for type 'int32_t [1]'
- msgq.c:148: index 53 out of range for type 'int32_t [1]'
- msgq.c:149: index 2045 out of range for type 'int32_t [1]'
Changes:
1. Convert queue[1] to queue[] in msgq_t structure
2. Convert payload[1] to payload[] in msgq_message_t structure
3. Update MSGQ_HEADER_SIZE and MSGQ_MESSAGE_HEADER_SIZE macros
to use sizeof() directly, as flexible array members have zero
size and cannot be used with sizeof()
The flexible array member (FAM) approach is:
- C99 standard compliant
- Linux kernel best practice for variable-length structures
- Binary compatible with the previous implementation
- Eliminates UBSAN false positives without functional changes
Bug 4831393
Change-Id: I243d4a1b1f091bf17cfc10337e75dbd1b878042f
Signed-off-by: Asha Talambedu <atalambedu@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3464624
Reviewed-by: Mohan kumar <mkumard@nvidia.com>
Reviewed-by: Viswanath L <viswanathl@nvidia.com>
GVS: buildbot_gerritrpt <buildbot_gerritrpt@nvidia.com>
Modify CoE capture logic a bit to make it more robust and error-proof:
- RCE Rx queue limit size is 16, no point to have 32 elements long queue
in kernel.
- Pass kernel's queue length to RCE when opening a channel so it can be
validated (to not exceed RCE max depth)
- validate image buffers IOVA addresses and buffer length before queuing
to RCE
Jira CT26X-1892
Change-Id: I199143fe726ebab05a1236d4b14b59f0528d65a8
Signed-off-by: Igor Mitsyanko <imitsyanko@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3419638
Reviewed-by: svcacv <svcacv@nvidia.com>
Tested-by: Raki Hassan <rakibulh@nvidia.com>
GVS: buildbot_gerritrpt <buildbot_gerritrpt@nvidia.com>
Reviewed-by: Narendra Kondapalli <nkondapalli@nvidia.com>
Change licensing of include/soc/tegra/camrtc-diag-messages.h and
include/soc/tegra/camrtc-diag.h from NVIDIA Proprietary to GPL-2.0-only,
as these files are used by GPL code. The license incompatibility is
resolved by ensuring all files maintain consistent licensing terms.
Bug 5278776
Change-Id: Ia42d64339458eb6f3320aea142f0360350614b8b
Signed-off-by: Mohit Ingale <mohiti@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3365826
GVS: buildbot_gerritrpt <buildbot_gerritrpt@nvidia.com>
Reviewed-by: Frank Chen <frankc@nvidia.com>
Reviewed-by: Semi Malinen <smalinen@nvidia.com>
Reviewed-by: Ganesh Ram Savithri Sreenivas Murthy <ganeshrams@nvidia.com>
default DriveOS inter-process endpoint count is about 1300 for now.
DriveAV requirement needs 8192 inter-process channels
(=16384 endpoints) except for DriveOS system usage.
Hence increased the number of inter-process endpoints by 2048
more in considering margin.
Bug 5224327
Change-Id: I47f5a67f9ece917ed5fe873be2e188f128d63961
Signed-off-by: Joshua Cha <joshuac@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3361956
GVS: buildbot_gerritrpt <buildbot_gerritrpt@nvidia.com>
Reviewed-by: Simon Je <sje@nvidia.com>
In android ATV build, userspace is 32 bit while kernel is 64 bit. Hence
value of NVMAP_IOC_CACHE differs on userspace and kernel space side,
as we are using unsigned long data type for addr field. The unsigned
long resolves to 32 bit in userspace while 64 bit in kernel space. Use
u64 data type which will always resolves to 64 bit.
Bug 5111364
Change-Id: I392146e71f7d65ba047ee2dda0d69dd202370968
Signed-off-by: Ketan Patil <ketanp@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3348602
GVS: buildbot_gerritrpt <buildbot_gerritrpt@nvidia.com>
Reviewed-by: Pritesh Raithatha <praithatha@nvidia.com>
Depending on kernel version the Tegra UFS driver includes different
headers to build the driver. Now that Linux v5.x kernels are no longer
supported, we can simplify this. Simplify the headers for the Tegra UFS
driver as follows ...
1. For Linux v6.x kernels only the ufshcd-priv.h and ufshcd-pltfrm.h
headers are required. These headers are copied from the Linux kernel.
However, only the prototypes for the functions 'ufshcd_query_attr',
'ufshcd_query_descriptor_retry' and 'ufshcd_pltfrm_init' are needed.
The functions 'ufshcd_query_attr' and 'ufshcd_query_descriptor_retry'
have not been change since they were introduced in Linux v4.17 and
the function 'ufshcd_pltfrm_init' was last updated in Linux v6.1
(making the ufs_hba_variant_ops argument const). Although redefining
the prototypes outside the kernel is fragile and does not protect the
Tegra UFS driver from updates to these functions, this problem
already exists.
2. Move the files ufshcd-pltfrm.h and ufshcd-priv.h into the Tegra UFS
driver directory because these are not needed outside of the driver.
JIRA LINQPJ14-47
Change-Id: I3891bf756723f730f036637891c55090b5d2a384
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3349825
GVS: buildbot_gerritrpt <buildbot_gerritrpt@nvidia.com>
Reviewed-by: Brad Griffis <bgriffis@nvidia.com>
This commit expands the camera-diagnostics driver to add
support for ISP PFSD tests. The implementation:
- Adds diagnostics IVC communication between kernel and RCE firmware
- Implements ISP SDL test vector loading, verification, and execution
- Provides proper memory allocation and IOMMU mapping across devices
- Supports multiple ISP instances with chip-specific configurations
(T234/ISP6 and T264/ISP7)
- Creates sysfs interface for diagnostic status reporting
- Adds proper error handling and resources cleanup
- Implements CRC validation for test vectors
The driver enables hardware safety diagnostics for camera subsystems
to ensure reliability and functional safety of the camera pipeline.
New header files:
- camrtc-diag-messages.h: Defines messages for IVC communication
- camrtc-diag.h: Contains common diagnostic data structures
Jira CAMERASW-32042
Change-Id: I9a892b40891cffc3d460723d9fdc92854c6cda85
Signed-off-by: Mohit Ingale <mohiti@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3313001
Reviewed-by: Vincent Chung <vincentc@nvidia.com>
GVS: buildbot_gerritrpt <buildbot_gerritrpt@nvidia.com>
Reviewed-by: Semi Malinen <smalinen@nvidia.com>
Reviewed-by: Frank Chen <frankc@nvidia.com>
Reviewed-by: Bhushan Rayrikar <brayrikar@nvidia.com>
Previous implementation lacks of documentation and it's hard to
understand the effect of changing specific tunable parameter.
Revise the implementation so that the scaling behavior is somehow
aligned with the tegra_wmark governor supported by the actmon. The
only different is that nvhost_podgov governor is polling-based DFS
algorithm and it maintaines the moving average load in the governor
instead of hardware itself.
Bug 4892068
Change-Id: I033cb1359a484d4c9433fa4f2e7a99c42cb636b3
Signed-off-by: Johnny Liu <johnliu@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3315446
GVS: buildbot_gerritrpt <buildbot_gerritrpt@nvidia.com>
Reviewed-by: Rajesh Devaraj <rdevaraj@nvidia.com>
The Tegra264 PCIe drivers don't build for kernels that don't have:
1. The structure mrq_pcie_request_req defined
2. The function pci_epc_deinit_notify() present
This is currently being handling by building a dummy driver for kernels
that don't have these. To simplify this, use conftest to detect if the
above are present and modify the Tegra264 PCIe driver accordingly if
they are not present. By using conftest we can remove the Makefile
variable 'NV_OOT_PCIE_T264_SOC_SKIP_BUILD' and ccflag
'DNV_CONFIG_PCIE_TEGRA_DMA_DISABLE'.
Finally, the PCIe drivers are always built as modules so simplify the
Makefile and remove the usage of 'CONFIG_TEGRA_OOT_MODULE'.
Bug 4911768
Change-Id: Id282497b8607a732b5e6c90e1e7c1436589a0b5f
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3245592
GVS: buildbot_gerritrpt <buildbot_gerritrpt@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit deprecates the falcon hardware interface implementation from the host1x-nvhost driver.
falcon_exit() function will be deprecated once usage of
nvhost_module_deinit API is removed from PVA/DLA/Camera elements.
Jira HOSTX-5933
Bug 4918838
Change-Id: I268836c8c8fc2f1ab060412bb4446c7080f846c4
Signed-off-by: Mainak Sen <msen@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3311319
Reviewed-by: Mikko Perttunen <mperttunen@nvidia.com>
Reviewed-by: Sanif Veeras <sveeras@nvidia.com>
GVS: buildbot_gerritrpt <buildbot_gerritrpt@nvidia.com>
Adding debugfs support for the coordinated wake state.
This will allow for the end-user to select a number of destination CPUs,
and then force them into idle together. A chosen "src" cpu will then
trigger a simultaneous wake request on all of the cores to create the
worst-case idle-exit scenario.
We also have an alternate state to support only coordinated sleep.
This can be useful for cases where select cores coordinated together can
have deeper power modes available to them.
TPS-671
Change-Id: I901f86000d36a86f9549f713ba698b58896d55b7
Signed-off-by: Ishan Shah <ishah@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3242284
Reviewed-by: Nathan Hartman <nhartman@nvidia.com>
GVS: buildbot_gerritrpt <buildbot_gerritrpt@nvidia.com>
Reviewed-by: Sanjay Chandrashekara <sanjayc@nvidia.com>
This change adds conditional compilation blocks to disable L4T-specific
camera and multimedia drivers when building for embedded Linux platforms.
Key changes include:
- Add ifneq ($(NV_BUILD_SYSTEM_TYPE),embedded-linux) checks in multiple
Makefiles to exclude L4T-specific components
- Introduce NV_IS_L4T define to conditionally include L4T functionality
- Reorganize header includes to support both L4T and embedded Linux builds
- Conditionally wrap L4T-specific struct members and function calls
- Update module dependencies (cdi_mgr now depends on cdi_dev instead of cdi_pwm)
Jira CAMERASW-32251
Change-Id: I934fdd0188e914c07b456c0f6ad379d2a08555ca
Signed-off-by: Mohit Ingale <mohiti@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3294869
GVS: buildbot_gerritrpt <buildbot_gerritrpt@nvidia.com>
Reviewed-by: Anubhav Rai <arai@nvidia.com>
Reviewed-by: Jagadeesh Kinni <jkinni@nvidia.com>
Reviewed-by: Vincent Chung <vincentc@nvidia.com>
Reviewed-by: Frank Chen <frankc@nvidia.com>
using this patch fixing below cert & misra errors:-
- misra_c_2012_rule_21_2_violation: "__UAPI_NVHVIVC_MEMPOOL_IOCTL_H__", an identifier or macro name beginning with an underscore, shall not be declared.
- misra_c_2012_rule_21_1_violation: Defining or undefining a reserved name "__UAPI_NVHVIVC_MEMPOOL_IOCTL_H__", which is an identifier or macro name beginning with an underscore.
- cert_dcl37_c_violation: The reserved identifier "__UAPI_NVHVIVC_MEMPOOL_IOCTL_H__", which is reserved for use as identifiers with file scope in both the ordinary and tag name spaces, is defined.
JIRA ESLC-8398
Change-Id: I82aca2a1c87ee4d2a145671ea0284fe739cb9b16
Signed-off-by: Manish Bhardwaj <mbhardwaj@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3297795
Reviewed-by: Suresh Venkatachalam <skathirampat@nvidia.com>
GVS: buildbot_gerritrpt <buildbot_gerritrpt@nvidia.com>
Reviewed-by: Sumeet Gupta <sumeetg@nvidia.com>
using this patch fixing below cert & misra errors:-
- cert_dcl37_c_violation: The reserved identifier
"_UAPI_TEGRA_HV_VCPU_YIELD_IOCTL_H_", which is reserved for use as
identifiers with file scope in both the ordinary and tag name spaces,
is defined.
- misra_c_2012_rule_21_1_violation: Defining or undefining a reserved
name "_UAPI_TEGRA_HV_VCPU_YIELD_IOCTL_H_", which is an identifier or
macro name beginning with an underscore.
- misra_c_2012_rule_21_2_violation: "_UAPI_TEGRA_HV_VCPU_YIELD_IOCTL_H_",
an identifier or macro name beginning with an underscore, shall not be
declared.
JIRA ESLC-8378
Change-Id: I1d8d5f437793a0b964b1ed195f70ab84c6104895
Signed-off-by: Manish Bhardwaj <mbhardwaj@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3301267
Reviewed-by: Sumeet Gupta <sumeetg@nvidia.com>
Reviewed-by: Suresh Venkatachalam <skathirampat@nvidia.com>
GVS: buildbot_gerritrpt <buildbot_gerritrpt@nvidia.com>
using this patch fixing below cert & misra errors:-
- cert_dcl37_c_violation: The reserved identifier "_TEGRA_HV_PM_CTL_H",
which is reserved for use as identifiers with file scope in both the
ordinary and tag name spaces, is defined.
- misra_c_2012_rule_21_1_violation: Defining or undefining a reserved
name "_TEGRA_HV_PM_CTL_H", which is an identifier or macro name
beginning with an underscore.
- misra_c_2012_rule_21_2_violation: "_TEGRA_HV_PM_CTL_H", an identifier
or macro name beginning with an underscore, shall not be declared.
JIRA ESLC-8381
Change-Id: Ib944855e143c34b3019f1f93ad9f6894ebf89085
Signed-off-by: Manish Bhardwaj <mbhardwaj@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3301268
Reviewed-by: Suresh Venkatachalam <skathirampat@nvidia.com>
Reviewed-by: Sumeet Gupta <sumeetg@nvidia.com>
GVS: buildbot_gerritrpt <buildbot_gerritrpt@nvidia.com>
- add support for zero copy SHA/GMAC operations
- add support to read zero copy nodes in DT
- support memory buf map/unmap ioctl interfaces
- unmap all memory buffers when FD corresponding
to device node is closed.
- support only one open call at a time for zero
copy nodes.
Bug 4999798
Change-Id: If110108a73b24ca9f523a8c67a47c02b922c3fd8
Signed-off-by: Nagaraj P N <nagarajp@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3292084
GVS: buildbot_gerritrpt <buildbot_gerritrpt@nvidia.com>
Reviewed-by: Leo Chiu <lchiu@nvidia.com>
Reviewed-by: Sandeep Trasi <strasi@nvidia.com>
- Added UID member to nvsciipc_config_entry data
structure. this is needed for implementing
test_nvsciipc_cfgblob in linux.
- removed static from ioctl function to attach eBPF program
- add error-injection.h and ALLOW_ERROR_INJECTION macro to ioctl
to use bpf_override_return()
JIRA NVIPC-2817
Change-Id: Ic27156e321368041f41fbabff9e6375140fe1d0e
Signed-off-by: Suneel Kumar Pemmineti <spemmineti@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3301786
Tested-by: Joshua Cha <joshuac@nvidia.com>
GVS: buildbot_gerritrpt <buildbot_gerritrpt@nvidia.com>
Reviewed-by: Simon Je <sje@nvidia.com>