Commit Graph

18 Commits

Author SHA1 Message Date
Arvind M
29ec18d2bc nvdla: kmd: fix copyright header license to GPL v2
Bug 5065840

Change-Id: I2012645108457974e24d3c8799ee9412393408e1
Signed-off-by: Arvind M <am@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3291589
Reviewed-by: Jon Hunter <jonathanh@nvidia.com>
Reviewed-by: svcacv <svcacv@nvidia.com>
GVS: buildbot_gerritrpt <buildbot_gerritrpt@nvidia.com>
Reviewed-by: Vishal Thoke <vthoke@nvidia.com>
Reviewed-by: Amit Sharma (SW-TEGRA) <amisharma@nvidia.com>
Reviewed-by: Ken Adams <kadams@nvidia.com>
2025-07-24 10:19:14 +00:00
Arvind M
47b40e9b56 nvdla: kmd: enable syncpoint emulator dependency
- Adds syncpt emulator wrapper class for axi-nvdla.ko module
- Fixes minor bugs
    - The behavior of SHIM write differs between the nvhost
      syncpoint and nvhost-emu. The DLA KMD accommodates the
      same.
    - For the simulator, there is no proper management for loading
      and unloading the firmware. This will lead to a undefined
      behavior. This commit fixes the issue through use of refcnt.
    - The RISCV will be in halted state and will continue from where
      it left off. Due to a security configuration, the DLA cannot
      reload the firmware again and again after booting the system.
      As a WAR, the simulator avoids reloading the IMEM and DMEM.
      Raised a Bug 4960393 to provide a proper fix and work around
      is protected using macro BUG_4960393=1
    - The FPGA is always considered on. Raised a Bug 4972382 to
      enable power management and work around to skip the power
      operation through macro BUG_4972382=1

Bug 4942853

Change-Id: I0bf0262d6fde3b3da47f040c493d915ae6a1f98a
Signed-off-by: Arvind M <am@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3248734
Reviewed-by: Vishal Thoke <vthoke@nvidia.com>
Reviewed-by: Ken Adams <kadams@nvidia.com>
GVS: buildbot_gerritrpt <buildbot_gerritrpt@nvidia.com>
Reviewed-by: Mitch Harwell <mharwell@nvidia.com>
Reviewed-by: Amit Sharma (SW-TEGRA) <amisharma@nvidia.com>
2025-07-24 10:19:11 +00:00
Arvind M
48a651f8b4 nvdla: kmd: switch to using portability layer
- Revamp the core logic to use the portability layer.
- Introduce ping debugfs node.

Bug:
- Update the abort retry logic for -EAGAIN error code. In
  the absence of this logic, the queue becomes unavailable
  due to race between the reset and the flush command.

Jira DLA-7294
Jira DLA-7310

Change-Id: I9f54f14334736189a00d2236f374188c2bac6155
Signed-off-by: Arvind M <am@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3196673
Reviewed-by: Akshata Bhat <akshatab@nvidia.com>
Reviewed-by: Ken Adams <kadams@nvidia.com>
GVS: buildbot_gerritrpt <buildbot_gerritrpt@nvidia.com>
2025-07-24 10:19:08 +00:00
Akshata
a917df5927 nvdla: kmd: switch to on-demand cleanup tasklist
[1] In the event of busy CPU, the delayed interrupt or the
    delayed callback from nvhost will result in the submission
    failure.
[2] This commit fixes the issue by performing mandatory and controlled
    cleanups.
        - Atmost 2 slots are cleaned up prior to the submission.
        - Complete queue cleanup during the suspend preparation.
        - Complete queue cleanup after successful abort operation.
[3] Additionally, the commit fixes some potential leaks in the error
    path.

Bug 4503438
Bug 4414867

Change-Id: Ic40f0c4b1f3c653d5d5e613adab01d3cbc3b9722
Signed-off-by: Arvind M <am@nvidia.com>
Signed-off-by: Akshata Bhat <akshatab@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3105861
(cherry picked from commit 438e8f8e96483971798e2d9014ed4a999143d082)
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3120798
(cherry picked from commit 5668f6439643d44b3384bcd750a645d8db6ee0c9)
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3196672
GVS: buildbot_gerritrpt <buildbot_gerritrpt@nvidia.com>
Reviewed-by: Ken Adams <kadams@nvidia.com>
2025-07-24 10:19:08 +00:00
Jon Hunter
cb8b9f5a53 drivers: Fix missing vmalloc.h for Linux v6.10
Upstream commit 690da22dbfa8 ("asm-generic/io.h: kill vmalloc.h
dependency") removed the vmalloc.h header file from io.h and this breaks
building various drivers with the latest -next kernels. Fix this
by ensuring vmalloc.h is included and in most cases slab is not actually
needed and so remove this where possible. Note that it is fine to make
this change for all current supported kernels.

Bug 4593750

Change-Id: I003d1302bda226d356467e6ede99949b2716940a
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3141984
Reviewed-by: Brad Griffis <bgriffis@nvidia.com>
GVS: buildbot_gerritrpt <buildbot_gerritrpt@nvidia.com>
2024-05-22 09:19:24 -07:00
Laxman Dewangan
c526d32af3 nvdla: Use SPDX license GPL 2.0 format
Use SPDX license GPL-V2.0 format and change Nvidia
copyright year to include 2023.

Bug 4078035

Change-Id: Ie5d525f06dde5b3e3d332caff3d135198059d325
Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2890634
Reviewed-by: Amit Sharma (SW-TEGRA) <amisharma@nvidia.com>
Reviewed-by: Ken Adams <kadams@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
2023-04-21 11:40:49 -07:00
Jon Hunter
726a34aac5 nvdla: Add option for enabling channel submit
Channel submit mode is not supported for upstream Linux kernels and
so add a compile time option to enable channel submit mode. For upstream
kernels this is disabled by default and an error is returned if
userspace uses channel submit mode.

Bug 3530486

Change-Id: Ie0de954ac6ac3bffd4b4776097286d2ace338995
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2665592
Reviewed-by: Mikko Perttunen <mperttunen@nvidia.com>
Reviewed-by: Arvind M <am@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: Praveen K <kpraveen@nvidia.com>
GVS: Gerrit_Virtual_Submit
2023-04-14 11:47:58 +00:00
Jon Hunter
ecdf991f7d nvdla: Use upstream speculation barrier
The Linux v5.10 kernel defines a 'spec_bar()' macro to inhibit
speculation for ARM64 and so if we use this macro, then we can
remove the downstream speculation_barrier(). Please note that
it is important to remove such downstream macros because these
prevent us getting the various NVIDIA kernel drivers from
working with upstream Linux kernels.

Bug 3409896
Bug 3477445

Change-Id: Ie8d44f219d2dded2fc7bd36f24980b91c92395d9
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2643778
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
2023-04-14 11:47:58 +00:00
Jon Hunter
d241e32f53 nvdla: Add support for upstream host1x driver
Update the DLA driver to add support for the upstream host1x driver.
The driver is built for upstream kernels only when the configuration
option CONFIG_TEGRA_HOST1X_NEXT is defined.

For the supporting the upstream host1x driver, the DLA driver is
registered with the upstream host1x driver by calling
host1x_driver_register().

Please note that for upstream Linux, the firmware naming conventions
used for upstream are preferred. So that although the same firmware
is used with both upstream and downstream, it is simply the filename
that is changed.

The 'spec_bar()' macro was removed from Linux v5.13 because there were
no upstream users. Include the downstream header arm64-barrier.h that
adds the spec_bar() from upstream so that we can build NVDLA for Linux
v5.13+ kernels.

Finally, add the necessary stub functions to the nvhost.h header file
to allow the driver to build. Please note that these functions are
not used and so stub functions are sufficient.

Bug 3409896
JIRA LS-410

Change-Id: Ifb8f269b260056da0fba6e5e2f88aa813178bff3
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2653103
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
2023-04-14 11:47:58 +00:00
Arvind M
a8e71d52d5 nvdla: kmd: add suspend-resume ops for SC7 support
[1] SC7 power state switches off all modules except for RAM and
    AON regions.
[2] DLA suspend operation is responsible for the following.
    - Readiness: Checks if there are no outstanding tasks in queues.
    - Suspend: Initiates power-off sequence.
[3] DLA resume operation is responsible for the following.
    - Resume: Initiates power-on sequence.
[4] In addition, each module maintains is_suspended flag to
    communicate the state of suspension.

Jira DLA-5365

Change-Id: I594a1a2731a4f28f552e4be06338fca2fa4e7ca1
Signed-off-by: Arvind M <am@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2659248
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
2023-04-14 11:47:58 +00:00
Jon Hunter
16b7d0418a video: tegra: nvdla: Don't use nvhost print macros
The NVDLA driver uses the nvhost_err() and nvhost_dbg_fn() macros which
simply call dev_err() and dev_info(), respectively. When compiling the
NVDLA driver against an upstream Linux kernel, nvhost_err() and
nvhost_dbg_fn() are not found and compilation fails. Fix this by
replacing nvhost_err() with either dev_err() or pr_err() and replace
nvhost_dbg_fn() with nvdla_dbg_fn().

JIRA LS-410

Change-Id: Ib89a187f330a4a80bd0b0329171a02f6336565ff
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2643161
Reviewed-by: Arvind M <am@nvidia.com>
Reviewed-by: svc_kernel_abi <svc_kernel_abi@nvidia.com>
Reviewed-by: Amit Sharma (SW-TEGRA) <amisharma@nvidia.com>
Reviewed-by: Praveen K <kpraveen@nvidia.com>
Reviewed-by: Bharat Nihalani <bnihalani@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
GVS: Gerrit_Virtual_Submit
2023-04-14 11:47:58 +00:00
Ashish Mhetre
6905c6d0dd video: tegra: host: Remove dma-attrs
dma-attrs.h is a downstream header and it's getting removed.
So remove it's usage from drivers.

Bug 3415117

Change-Id: I0e8c0f44a42fcdd28032f44ee2ab8ceb884955bc
Signed-off-by: Ashish Mhetre <amhetre@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2627420
Reviewed-by: svcacv <svcacv@nvidia.com>
Reviewed-by: svc_kernel_abi <svc_kernel_abi@nvidia.com>
Reviewed-by: Sachin Nikam <snikam@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
GVS: Gerrit_Virtual_Submit
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2023-04-14 11:47:58 +00:00
Arvind M
c5b179e99d nvdla: kmd: synchronize access to task pool memory
[1] In the absence of synchronization to access task pool, submission may
    happen at faster rate than cleanups. This shall lead to frequent
    out-of-memory error.
[2] This commit fixes the issues through retries before throwing OOM.
    a. Sets up a communication between cleanup & submit.
    b. Retries for allocating task memory
        - Retry period:   1 ms
        - Total timeout: 10 ms

Bug 200680501

Change-Id: Iea25fbe6e7891938f6318285d4824bc1c54ddb05
Signed-off-by: Arvind M <am@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2518193
Reviewed-by: svcacv <svcacv@nvidia.com>
Reviewed-by: Ken Adams <kadams@nvidia.com>
Reviewed-by: Anup Mahindre <amahindre@nvidia.com>
Reviewed-by: Bharat Nihalani <bnihalani@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
GVS: Gerrit_Virtual_Submit
2023-04-14 11:46:41 +00:00
Anup Mahindre
86fbda4e99 video: tegra: host: nvdla: Use vfree for v*alloced memory
A previous change shifted from k*alloc to v*alloc as physically
contiguos memory was not really required. A kfree was left out in error
paths. Fix this problem by using vfree instead.

Bug 200621525

Change-Id: I1074d84a2366cc52d172b5817de2d7df60a23028
Signed-off-by: Anup Mahindre <amahindre@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2373692
Reviewed-by: automaticguardword <automaticguardword@nvidia.com>
Reviewed-by: Ken Adams <kadams@nvidia.com>
Reviewed-by: Bharat Nihalani <bnihalani@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
GVS: Gerrit_Virtual_Submit
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2023-04-14 11:46:41 +00:00
Ankit Patel
68df82f0f7 video: tegra: host: free channel on job completion
This issue mostly seen in T210 when resource policy for modules are set to
RESOURCE_PER_DEVICE and test with kernel_submit regression, Then it generally
leads to a crash in second or forthcoming iteration of kernel_submit.

Observation:

After completion of channel's job, module gets suspended without freeing the
channel, And when module resume, it's start submiting job on the channel's
syncpoint which is already freed by others.

This scenario occurs in two cases with VIC module,

   1 A user application(Ex: nvgpu) freed the syncpoint and VIC module is
     in suspend, Now when module will resume it will expect same syncpt
     active and belongs to it.

   2 In between of 1st possibility If other module(Ex: nvenc) gets the
     syncpoint from free list when the first module(VIC) is suspended,
     Now when first module(VIC) resume and start submiting job on the same
     syncpoint which is already acquired by other module.

Changes made :
	o Now, Channel will be freed on channel dma completion
	o Channel will be re-acquire on every submit
	o Syncpoint will not be freed when channel gets free.
	o Syncpoint will be acquire once by user space and will be
	freed when use space release the device
	o Now, Syncpoints gets mark used and unused using chid
	o Set resource policy to RESOURCE_PER_DEVICE for msenc, nvdec,
	nvjpg and vic

Bug 200582662

Change-Id: Ief7658974cbd958f883e7b83add5902f766826df
Signed-off-by: Ankit Patel <anpatel@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2352726
(cherry picked from commit 745c3c8d46c23353a81e5e6035af3ed3848b02eb)
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2366098
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
2023-04-14 11:46:41 +00:00
Anup Mahindre
ebbbba1533 video: tegra: host: nvdla: Avoid contiguos alloc
Avoid requesting physically contiguos allocation where it is not
required since this can fail in case of fragementation.

Bug 200621525

Change-Id: Icdf5f88b5336950212c62f8a7f0469b7b16e0ac5
Signed-off-by: Anup Mahindre <amahindre@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2360778
Tested-by: Bharat Nihalani <bnihalani@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Reviewed-by: Bharat Nihalani <bnihalani@nvidia.com>
Reviewed-by: Ken Adams <kadams@nvidia.com>
Reviewed-by: Mitch Harwell <mharwell@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
GVS: Gerrit_Virtual_Submit
2023-04-14 11:46:41 +00:00
Gunjan Mehta
59fe8f5aef dla: linux: add speculation barrieir in linux driver
Bug 200483495

Add speculation barriers for if and for loops to prevent spectre variant
1-S type attacks

Change-Id: If44a2c96047899accecf9604f3893daf681656c7
Signed-off-by: Gunjan Mehta <gmehta@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2230039
Reviewed-by: Arvind M <am@nvidia.com>
Tested-by: Arvind M <am@nvidia.com>
Reviewed-by: Bharat Nihalani <bnihalani@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2023-04-14 11:46:41 +00:00
Ken Adams
32b8fe3ec7 video: tegra: host: dla: factor out nvhost queue
Jira DLA-1536

Change-Id: I843e8d86916ebf2e48a820f2e6d1b12a624ccce3
Signed-off-by: Ken Adams <kadams@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2127556
GVS: Gerrit_Virtual_Submit
Reviewed-by: Bharat Nihalani <bnihalani@nvidia.com>
Tested-by: Bharat Nihalani <bnihalani@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2023-04-14 11:46:41 +00:00