Commit Graph

2890 Commits

Author SHA1 Message Date
Mahesh Kumar
4730a3c30c platform: tegra: dce: Add debugfs for echo cmd
This patch adds a debug node to send ADMIN_ECHO commands to the DCE.
node takes number of echo commands to be sent as input.

JIRA TDS-5692

Change-Id: If3cfcef3b0ac703754ee9a4146ab417978cdbe46
Signed-off-by: Mahesh Kumar <mahkumar@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-t23x/+/2487659
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Reviewed-by: svcacv <svcacv@nvidia.com>
Reviewed-by: svc_kernel_abi <svc_kernel_abi@nvidia.com>
Reviewed-by: Adeel Raza <araza@nvidia.com>
Reviewed-by: Arun Swain <arswain@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
GVS: Gerrit_Virtual_Submit
2023-04-14 19:23:43 +00:00
Mahesh Kumar
4653b0d74e platform: tegra: dce: Admin rpc post boot support
Current code assumes no RPC message on Admin-channel post boot. So
 - Admin RPC reply post-boot are not passed to the process issuing the
RPC instead expect dce_worker to handle the reply.
 - dce_worker doesn't wait for > 1 RPC reply from DCE-Core post boot.

This patch Adds support to send RPC over Admin channel post boot and
also adds support to wake-up the process issued RPC and waiting for
reply.

JIRA TDS-6381

Change-Id: Ifa85f8686c4aee86eb8efc69f85e552ca6f605c5
Signed-off-by: Mahesh Kumar <mahkumar@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-t23x/+/2500788
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
2023-04-14 19:23:43 +00:00
Mahesh Kumar
35242999ff platform: tegra: dce: Add WQ to handle async IPC
In current code RPC ack events are handled by thread issuing RPC but
Async-IPC events are handled in the bottom-half with interrupt disabled.
This may delay delivery of RPC ack if async-IPC handling is hogging the
CPU. It can also lead to a race condition where the RPC caller takes
the lock, issues a RPC and waits for a reply. And in-between KMD receives
an Async IPC and wants to take the same lock.
As IPC code is running with interrupt disabled, RPC-reply interrupt will
not be notified and will result in a deadlock.

This patch creates a Workqueue to handle Async IPC events.

JIRA TDS-6381

Change-Id: If7d69ef50298ad9364e9e494a32cf483ecfb744e
Signed-off-by: Mahesh Kumar <mahkumar@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-t23x/+/2485764
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Reviewed-by: svcacv <svcacv@nvidia.com>
Reviewed-by: Santosh Galma <galmar@nvidia.com>
Reviewed-by: Adeel Raza <araza@nvidia.com>
Reviewed-by: Arun Swain <arswain@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
GVS: Gerrit_Virtual_Submit
2023-04-14 19:23:43 +00:00
Manish Bhardwaj
42e6775484 tegra: platform: dce: use mutex_lock API properly
Improper use of mutex_lock API is leading to below crash with
rt kernel, this patch fixes the below crash.

dce: dce_req_boot_irq_sync:70   Waiting on dce fw to boot...
------------[ cut here ]------------
DEBUG_LOCKS_WARN_ON(rt_mutex_owner(lock) != current)
WARNING: CPU: 0 PID: 126 at /dvs/git/dirty/git-master_modular/out/
aarch64-arm64-tegra_defconfig-rt_patches-debug-extmod_ubuntu18.04_aarch64
-extmod_linux_x86_64/kernel/src-rt/kernel-5.10/kernel/locking/
rtmutex-debug.c:47 debug_rt_mutex_unlock+0x5c/0x68
 Modules linked in:
 CPU: 0 PID: 126 Comm: dce_worker_thre Not tainted 5.10.17-rt32-tegra #2
 Hardware name: t234pre_si (DT)
 pstate: 00800089 (nzcv daIf -PAN +UAO -TCO BTYPE=--)
 pc : debug_rt_mutex_unlock+0x5c/0x68
 lr : debug_rt_mutex_unlock+0x5c/0x68
 sp : ffff8000137fbc90
 x29: ffff8000137fbc90 x28: 0000000000000000
 x27: 0000000000000000 x26: ffff800012241180
 x25: ffff000082b7e090 x24: ffff800010e781d0
 x23: 0000000000000000 x22: ffff8000137fbd18
 x21: ffff8000137fbd08 x20: 0000000000000000
 x19: ffff000082b7e0b8 x18: ffffffffffffffff
 x17: 00000000000000c0 x16: fffffe0001eadf40
 x15: ffff800011e6f988 x14: ffff8000937fb817
 x13: ffff8000137fb825 x12: 2065756c61562020
 x11: 0000000005f5e0ff x10: ffff8000137fb770
 x9 : ffff8000137fbc90 x8 : 4e5241575f534b43
 x7 : 000000000000001f x6 : ffff80001224a65c
 x5 : 00000000ffffe163 x4 : 00000000ffffe163
 x3 : ffff800011f3ba50 x2 : 0000000100000001
 x1 : 0e62cf1b356d1e00 x0 : 0000000000000000
 Call trace:
  debug_rt_mutex_unlock+0x5c/0x68
  rt_mutex_slowunlock+0x38/0x98
  rt_mutex_unlock+0x5c/0x98
  __rt_mutex_unlock+0x20/0x30
  _mutex_unlock+0x20/0x30
  dce_worker_thread_wait+0x88/0x300
  dce_wait_boot_complete+0x74/0x118
  dce_worker+0x24/0x1c8
  dce_thread_proxy+0x20/0x30
  kthread+0x194/0x1a0
  ret_from_fork+0x10/0x18
 ---[ end trace 0000000000000001 ]---

JIRA ESLC-5710

Signed-off-by: Manish Bhardwaj <mbhardwaj@nvidia.com>
Change-Id: I0a67b4792515ca8212dc4a3b34ead5bde9f94f49
Reviewed-on: https://git-master.nvidia.com/r/c/linux-t23x/+/2499983
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Reviewed-by: Arun Swain <arswain@nvidia.com>
Reviewed-by: svcacv <svcacv@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
GVS: Gerrit_Virtual_Submit
2023-04-14 19:23:43 +00:00
Arun Swain
a1eeff5716 tegra: platform: dce: Update smmu stream id
Use the new stream id for memory requests
originating from DCE.

Bug 200692073

Change-Id: Ied2abc20a7aefd49e5bbb8845692ec0adfc74b40
Signed-off-by: Arun Swain <arswain@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-t23x/+/2476823
Tested-by: Pritesh Raithatha <praithatha@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Pritesh Raithatha <praithatha@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
2023-04-14 19:23:43 +00:00
Mahesh Kumar
098e247960 tegra: platform: dce: Fix IPC race condition
Re-organize IPC channel reset and mailbox interrupt handling code to
fix race condition where KMD was receiving new msg from DCE while
processing previous msg and clearing mailbox interrupt as part of it.
which was causing wait_for_ipc to get stuck.

JIRA TDS-6381

Change-Id: Ibd6ab1758d9b5b2e3709a03dadbc84f2585653a4
Signed-off-by: Mahesh Kumar <mahkumar@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-t23x/+/2460641
Reviewed-by: Santosh Galma <galmar@nvidia.com>
Reviewed-by: Arun Swain <arswain@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 19:23:43 +00:00
Arun Swain
6f353f4c77 tegra: platform: dce: Pass msg length info to DCE
Convey DCE FW about the actual length of the IVC
payload. This is needed since dce clients like RM
can transfer a wide range of variable sized
messages.

JIRA TDS-6381

Change-Id: Idd3b8bfe2419095de27fdc050caf4ed75154a2c3
Signed-off-by: Arun Swain <arswain@nvidia.com>
Signed-off-by: Mahesh Kumar <mahkumar@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-t23x/+/2422599
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Reviewed-by: automaticguardword <automaticguardword@nvidia.com>
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Santosh Galma <galmar@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
GVS: Gerrit_Virtual_Submit
2023-04-14 19:23:43 +00:00
Mahesh Kumar
9764cf5370 tegra: dce: Add IPC event notification support
- This change adds support for new IPC type
DCE_IPC_TYPE_RM_NOTIFY wrt event notification from
DCE RM

JIRA TDS-6643

Change-Id: I54b22e3fa86a1dab552f78d609c374d14ce619ad
Signed-off-by: Mahesh Kumar <mahkumar@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-t23x/+/2409904
Reviewed-by: automaticguardword <automaticguardword@nvidia.com>
Reviewed-by: Santosh Galma <galmar@nvidia.com>
Reviewed-by: Arun Swain <arswain@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
GVS: Gerrit_Virtual_Submit
Tested-by: Santosh Galma <galmar@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2023-04-14 19:23:43 +00:00
Santosh Reddy Galma
f452d16f44 tegra: dce: use wait queue instead of completions
- completions uses spin lock and disables irq
resulting in processor getting blocked to receive
mailbox interrupts during IPC synchronization.
- current change uses wait queues instead of
completions for IPC synchronization to overcome
above possibility of IPC blocked on DCE.

JIRA TDS-5691

Change-Id: I12e06ff4d31cf47d87e7a9d76d9915e5e2210de6
Signed-off-by: Santosh Reddy Galma <galmar@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-t23x/+/2428661
Reviewed-by: automaticguardword <automaticguardword@nvidia.com>
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Arun Swain <arswain@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 19:23:43 +00:00
Arun Swain
25954c13e6 drivers: platform: tegra: dce: Clean up ivc notify
Revisit ivc signaling during handshake and clean
it up to reduce spurious signals.

JIRA TDS-6381
Bug 200666838

Change-Id: I1698220b968d0aa8d1b6d1d36d551118be283c02
Signed-off-by: Arun Swain <arswain@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-t23x/+/2417049
Reviewed-by: automaticguardword <automaticguardword@nvidia.com>
Reviewed-by: Santosh Galma <galmar@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: Santosh Galma <galmar@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
GVS: Gerrit_Virtual_Submit
2023-04-14 19:23:43 +00:00
Arun Swain
ea84c95dbf tegra: platform: dce: Fix race condition on fgpa
Resolve race condition where DCE Firmware could
potentially send an IVC signal before even CPU
driver starts listening for it.

This fix makes sure that the driver need not wait
if it has been signalled already by Firmware.

Jira TDS-6381

Change-Id: I3d6dd1f93ce36f9e44b7157f70c0aad099f2d561
Signed-off-by: Arun Swain <arswain@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-t23x/+/2394468
Tested-by: Santosh Galma <galmar@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Reviewed-by: Santosh Galma <galmar@nvidia.com>
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Mahesh Kumar <mahkumar@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
GVS: Gerrit_Virtual_Submit
2023-04-14 19:23:43 +00:00
Mahesh Kumar
ef3f18c398 tegra: dce: suppress unnecessary info logs
This patch removes unnecessary dce_info prints to avoid flooding of uart
logs.

JIRA TDS-5691

Change-Id: I9c9a32815e685504b443f24483502fe019ac0eaf
Signed-off-by: Mahesh Kumar <mahkumar@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-t23x/+/2375553
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Santosh Galma <galmar@nvidia.com>
Reviewed-by: Arun Swain <arswain@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 19:23:43 +00:00
Mahesh Kumar
dc3e980731 tegra: dce: Add debugfs node to show boot status
This patch adds a debugfs node to show DCE boot status.

It also adds following dce boot marker in logs
  - DCE_BOOT_DONE
  - DCE_BOOT_FAILED

JIRA TDS-5691

Change-Id: Iada5c1234e5e5f1a5e7afd88dcb94c2da6a3fe1c
Signed-off-by: Mahesh Kumar <mahkumar@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-t23x/+/2361287
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Santosh Galma <galmar@nvidia.com>
Reviewed-by: Arun Swain <arswain@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: Santosh Galma <galmar@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
GVS: Gerrit_Virtual_Submit
2023-04-14 19:23:43 +00:00
Mahesh Kumar
91c35f09be dce: avoid kmsg flooding with info print.
If dce is not initialized dce-driver prints a print every second.
This patch removes the print as we already have debug node
to check the dce-boot status.

Change-Id: I25a8830dce6a61eef122b58fc211b53c2bb04cd4
Signed-off-by: Mahesh Kumar <mahkumar@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-t23x/+/2352003
Reviewed-by: automaticguardword <automaticguardword@nvidia.com>
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Santosh Galma <galmar@nvidia.com>
Reviewed-by: Arun Swain <arswain@nvidia.com>
Reviewed-by: Mitch Luban <mluban@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 19:23:43 +00:00
Arun Swain
606f03fbf2 platform: tegra: dce: add dce kernel driver
For T23x, we have a separate R5 based cluster
named as Display Controller Engine(DCE) to run
our Display RM code. This driver will run on CPU
with the following functionality:

Via debugfs for test and bring-up purposes:
1. Reads the DCE firmware image into DRAM.
2. Sets up DCE AST to cover the DCE firmware image.
3. Sets up R5 reset vector to point to DCE firmware
entry point
4. Brings DCE out of reset
5. Dumps various regsiters for debug

In production env:
1. Manages interrupts to CPU from DCE
2. Uses bootstrap command interface to define Admin
IPC
3. Locks down bootstrap command interface
4. Uses Admin IPC to define message IPC
5. Uses Admin IPC to define message IPC payload area
6. Uses Admin IPC to set IPC channels
6. Uses Admin IPC to define crashdump area
(optional)
7. Provides IPC interfaces for any DCE Client running
on CCPLEX including Display RM.
8. Uses Admin IPC to set logging level (optional)

This patch puts a framework in place with the
following features :
1. Firmware Loading
2. AST Configuration
3. DCE Reset with EVP Programming
4. Logging Infra
5. Debugfs Support
6. Interrupt Handling
7. Mailbox Programming
8. IPC Programming
9. DCE Client Interface
10. Ftrace Support for debug purposes

Change-Id: Idd28cd9254706c7313f531fcadaa7024a5b344e7
Signed-off-by: Arun Swain <arswain@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-t23x/+/2289865
Reviewed-by: automaticguardword <automaticguardword@nvidia.com>
Reviewed-by: Mahesh Kumar <mahkumar@nvidia.com>
Reviewed-by: Santosh Galma <galmar@nvidia.com>
Reviewed-by: Mitch Luban <mluban@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
GVS: Gerrit_Virtual_Submit
Tested-by: Mahesh Kumar <mahkumar@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2023-04-14 19:23:43 +00:00
Manish Bhardwaj
fe2085dcef crypto: fix compilation warning
local variables size is more then recommended values leading
to compilation warning. So usign this patch we are fixing
below compilation warnigs:-
nvidia-oot/drivers/crypto/tegra-nvvse-cryptodev.c:
In function ‘tnvvse_crypto_dev_ioctl’:
nvidia-oot/drivers/crypto/tegra-nvvse-cryptodev.c:2103:1:
warning: the frame size of 2224 bytes is larger than 2048 bytes
[-Wframe-larger-than=]

Bug 4064812

Change-Id: Ie5f0489c9733451f9a132e146790a18d3dd4d6f9
Signed-off-by: Manish Bhardwaj <mbhardwaj@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2887287
Reviewed-by: Ashutosh Patel <ashutoshp@nvidia.com>
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
Reviewed-by: svc-mobile-cert <svc-mobile-cert@nvidia.com>
Reviewed-by: Sandeep Trasi <strasi@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
2023-04-14 08:21:59 -07:00
Manish Bhardwaj
1d627f6a49 nvidia: add PM ops support in oops driver
Using this patch we are adding PM ops support in oops
driver so that we can store the crash logs after
SC7 cycle also.

Bug 3585622

Change-Id: Id82252ac869cc8d3b7e09e2faec8289ab4f3859f
Signed-off-by: Manish Bhardwaj <mbhardwaj@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2886489
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: Sandeep Trasi <strasi@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
2023-04-14 08:19:24 -07:00
Dipen Patel
2f21871b13 drivers: staging: gte: fix warnings
The gte driver has multiple sparse warnings when kernel is compiled
with tmp kernel C=2. This CL corrects those warnings.

Bug 3954363

Change-Id: If7a112c1bf1e491118b3d4119e0e09f7673a553a
Signed-off-by: Dipen Patel <dipenp@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2886127
Reviewed-by: Ketan Patil <ketanp@nvidia.com>
Reviewed-by: Laxman Dewangan <ldewangan@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
2023-04-14 08:18:47 -07:00
Ankur Pawar
c10d814337 media: i2c: Fix camera driver Coverity defects
Fix the below Coverity defects for IMX318 sensor driver

Copy paste error
CID: 10171759

Null return check
CID: 10171758

Unchecked return value
CID: 10171760

Bug 3952896

Change-Id: I9da2c14911dc119853fa5c96c9c4dcc9f1827c7e
Signed-off-by: Ankur Pawar <ankurp@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2885966
Reviewed-by: Chinmay Mahajan <cmahajan@nvidia.com>
Reviewed-by: Frank Chen <frankc@nvidia.com>
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
Reviewed-by: svc-mobile-cert <svc-mobile-cert@nvidia.com>
Reviewed-by: Laxman Dewangan <ldewangan@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
2023-04-14 08:18:38 -07:00
Ankur Pawar
9a9e8f8cdf camera: csi: fix coverity defect
Out-of-bounds read
CID: 10132982

Bug 3952896

Change-Id: Iefcdeaf46e46a1e27feb4ab13e0f76d8ee4b5b10
Signed-off-by: Ankur Pawar <ankurp@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2885123
Reviewed-by: svcacv <svcacv@nvidia.com>
Reviewed-by: Frank Chen <frankc@nvidia.com>
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
Reviewed-by: svc-mobile-cert <svc-mobile-cert@nvidia.com>
Reviewed-by: Praveen AC <pac@nvidia.com>
Reviewed-by: Laxman Dewangan <ldewangan@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
2023-04-14 08:18:12 -07:00
Jon Hunter
27a989988e nvdla: kmd: Don't read DLA fuses for upstream Linux
The DLA fuses are not exposed via nvmem for upstream Linux kernels and
so when booting upstream Linux kernels the following warnings are seen
for DLA:

 nvdla 158c0000.nvdla1: nvmem_cell_get error -2. Assuming DLA instances
  are available
 nvdla 15880000.nvdla0: nvmem_cell_get error -2. Assuming DLA instances
  are available

Disabling DLA instances for devices that don't support DLA is handled by
the bootloader and so for Linux kernel's greater than v5.10, it is not
necessary for the kernel driver to check this.

Bug 3795915

Change-Id: Icbd5e7c522a66a827fe1ed58ed2271a98497bbcd
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2870158
Reviewed-by: Amit Sharma (SW-TEGRA) <amisharma@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: Ken Adams <kadams@nvidia.com>
Reviewed-by: Mitch Harwell <mharwell@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
2023-04-14 11:47:58 +00:00
Arvind M
60c893bc80 nvdla: kmd: revive SC7 support for OOT
[1] For the OOT, there are no implementations for the prepare_suspend,
    suspend, resume and complete_resume from the nvhost.
[2] This commit decouples the DLA dependency on the nvhost for the
    suspend and the resume operations.

Bug 3977752
Bug 3978072

Change-Id: Ie8ae9d29873559e1c76331294e4c7dfd0ccf0237
Signed-off-by: Arvind M <am@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2857153
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
84556afbef nvdla: kmd: put pm reference with task completion.
[1] With the current design, the DLA is leaning on the nvhost callback
    notifier for putting the pm reference.
[2] This commit decouples that dependency by putting the pm reference
    for every task completion.

Jira DLA-6649
Jira LS-477

Change-Id: I84ea948b7f717f7f3e28ac1f58f17f07c53e822b
Signed-off-by: Arvind M <am@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2857162
Reviewed-by: svcacv <svcacv@nvidia.com>
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
Reviewed-by: svc_kernel_abi <svc_kernel_abi@nvidia.com>
Reviewed-by: Amit Sharma (SW-TEGRA) <amisharma@nvidia.com>
Reviewed-by: Ayush Kumar <ayushk@nvidia.com>
Reviewed-by: Ken Adams <kadams@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
Tested-by: Amit Sharma (SW-TEGRA) <amisharma@nvidia.com>
2023-04-14 11:47:58 +00:00
Arvind M
5720a7534d nvdla: kmd: support HSI corrected error injection
Jira DLA-6136
Jira DLA-6595

Change-Id: I4ca1b5f1e07566638951bc1d0c64613195779aa2
Signed-off-by: Arvind M <am@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2856422
Reviewed-by: svcacv <svcacv@nvidia.com>
Reviewed-by: svc_kernel_abi <svc_kernel_abi@nvidia.com>
Reviewed-by: Amit Sharma (SW-TEGRA) <amisharma@nvidia.com>
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
Reviewed-by: svc-mobile-cert <svc-mobile-cert@nvidia.com>
Reviewed-by: Ken Adams <kadams@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
2023-04-14 11:47:58 +00:00
Arvind M
42486b184d nvdla: kmd: add error report injection utility
Jira DLA-6136
Jira DLA-6595

Change-Id: I7013836607f138cfd2f4a2dfbe3a993244c546ac
Signed-off-by: Arvind M <am@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2847796
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: Ken Adams <kadams@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
2023-04-14 11:47:58 +00:00
Ken Adams
aeed9dba62 Merge remote-tracking branch 'origin/dev/dev-main-dla3.13.0' into dev-main
Jira DLA-6481
see https://git-master.nvidia.com/r/c/linux-nvidia/+/2845208
for merge info

Signed-off-by: Ken Adams <kadams@nvidia.com>
Change-Id: I5be460a545291bb63c1185aab4638c012368b1a1
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2845341
Reviewed-by: svc_kernel_abi <svc_kernel_abi@nvidia.com>
Reviewed-by: Maxim Grigoriev (SW-GPU) <maximg@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
Tested-by: Maxim Grigoriev (SW-GPU) <maximg@nvidia.com>
2023-04-14 11:47:58 +00:00
Jon Hunter
49361a4f9a nvdla: Fix memory leak for syncpts
Call the nvhost_syncpt_unit_interface_deinit() function on failure
and driver removal to free any memory allocated for syncpts.

Bug 3800349

Change-Id: I6612fd2ca39ebd2230fb06638cef2e28d6aa20d4
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2801282
(cherry picked from commit bb098a3920e28d321ba7d3e51d04317b99d8c650)
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2802440
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
2023-04-14 11:47:58 +00:00
Akshata Bhat
5641042df8 nvdla: kmd: Update max output status count
+ Update needed to enable NvSciSync based task
status support for NvMediaDla
+ Updated all macro definitions of
MAX_NVDLA_OUT_STATUS_PER_TASK for consistency

JIRA DLA-6305

Signed-off-by: Akshata Bhat <akshatab@nvidia.com>
Change-Id: Ieacba82905e7ad19729856be32f022a13a1c37de
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2813577
Reviewed-by: Maxim Grigoriev (SW-GPU) <maximg@nvidia.com>
Reviewed-by: Amit Sharma (SW-TEGRA) <amisharma@nvidia.com>
Reviewed-by: Arvind M <am@nvidia.com>
Tested-by: Arvind M <am@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
2023-04-14 11:47:58 +00:00
Akshata Bhat
0c6ea4efe2 nvdla: kmd: Debugfs nodes for resource utilization
+ Added a debugfs node to input window size
+ Added a debugfs node to output utilization rate

Commands to input window size:
* echo [unsigned_value_in_us] >
	/sys/kernel/debug/nvdla0/firmware/window_size
* echo [unsigned_value_in_us] >
	/sys/kernel/debug/nvdla1/firmware/window_size

Commands to output utilization rate:
* cat /sys/kernel/debug/nvdla0/firmware/utilization_rate
* cat /sys/kernel/debug/nvdla1/firmware/utilization_rate

JIRA DLA-6318

Signed-off-by: Akshata Bhat <akshatab@nvidia.com>
Change-Id: I17b0a5bb9a3e632d992c7b38cf84d472a99d28ed
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2794433
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>
Tested-by: Arvind M <am@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
2023-04-14 11:47:58 +00:00
Arvind M
103da69059 nvdla: kmd: synchronize PING across many clients
[1] When the multiple clients try to ping at the same time, the
    KMD errors out for all clients except one. This behavior
    is expected since there is only one command memory and the
    KMD errors out when that memory is busy.
[2] This commit fixes the issue by synchronizing the ping operations
    across all the clients by introducing a lock.
[3] Alternatively Increasing MAX_COMMANDS_PER_DEVICE will work but
    not optimal since,
    - the ping is an INIT mode operation.
    - the ping operation is inexpensive => the memory is immediately
      available even if locked.
    - the overall memory allocation will increase.

Considering the use case is rare, the synchronization of ping across
multiple clients is preferred.

Change-Id: I012efd18554a85bb31b79b98bf83386b37251d32
Signed-off-by: Arvind M <am@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2813197
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: Amit Sharma (SW-TEGRA) <amisharma@nvidia.com>
Reviewed-by: Ken Adams <kadams@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
2023-04-14 11:47:58 +00:00
Arvind M
c7726fd7d3 nvdla: kmd: fix upper bound check on fence limit
1. In Linux, MAX_NVDLA_*FENCES_PER_TASK is not same as that
   of MAX_NVDLA_EMU_*FENCES_PER_TASK. So there is an issue of
   buffer overflow during copy_from_user.
2. This commit fixes the issue by making use of EMU limits as
   the upper bound.

Bug 3613311

Change-Id: Ibfcc7e871aea0b44576a690c60491777a4752003
Signed-off-by: Arvind M <am@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2758528
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: Gunjan Mehta <gmehta@nvidia.com>
Reviewed-by: Amit Sharma (SW-TEGRA) <amisharma@nvidia.com>
Reviewed-by: Praveen K <kpraveen@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
2023-04-14 11:47:58 +00:00
Arvind M
f8f9637506 nvdla: kmd: check fence limit in emu submit
[1] With no bound check on prefences and postfences, there is a
    possibility of copying more data from the user than intended.
    This results in buffer overflow and leads to security threats.
[2] This commit adds the fence check during emu submission and
    prevents the cause of buffer overflow.

Bug 3613311

Change-Id: Ifdba184b34e54be0146f080e5383b8430a0b1bcd
Signed-off-by: Arvind M <am@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2723823
Reviewed-by: Martin Radev <mradev@nvidia.com>
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: Gunjan Mehta <gmehta@nvidia.com>
Reviewed-by: Praveen K <kpraveen@nvidia.com>
Tested-by: Martin Radev <mradev@nvidia.com>
GVS: Gerrit_Virtual_Submit
2023-04-14 11:47:58 +00:00
Vedashree Vidwans
cff8e145ab 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
2023-04-14 11:47:58 +00:00
Laxman Dewangan
cf0a902252 nvdla: Set config variable when build as OOT module
When nvdla driver is build as OOT module, it is required
to set the following config.
	CONFIG_TEGRA_GRHOST_NVDLA := m
	CONFIG_TEGRA_HOST1X_NEXT := m
	CONFIG_TEGRA_FUSE_UPSTREAM := y

Set these config when CONFIG_TEGRA_OOT_MODULE is set.

Bug 3583604

Change-Id: I309db8493a90572e58dcf9f95d1fc1b9ccc47d18
Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2715740
Reviewed-by: svc_kernel_abi <svc_kernel_abi@nvidia.com>
Reviewed-by: Bitan Biswas <bbiswas@nvidia.com>
GVS: Gerrit_Virtual_Submit
2023-04-14 11:47:58 +00:00
Jon Hunter
04ac05407c nvdla: Fix driver unloading
The NVDLA driver is a missing a call to nvhost_module_deinit() on
removal and so is not releasing resources as expected on removal which
prevents the driver from being unloaded and reloaded correctly. Fix this
by add a call to nvhost_module_deinit() in the driver remove callback.

Bug 3641820

Change-Id: I675bb7b2b31c3194ae30c4162f7f72caf4844243
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2710547
Reviewed-by: svcacv <svcacv@nvidia.com>
Reviewed-by: Amit Sharma (SW-TEGRA) <amisharma@nvidia.com>
Reviewed-by: Arvind M <am@nvidia.com>
Reviewed-by: Praveen K <kpraveen@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
2023-04-14 11:47:58 +00:00
Prateek Patel
956c7dea31 drivers: dla: fix cert_c defect
Add check for return value of snprintf().

CID 343144
CID 441285

Bug 3512545

Change-Id: I2039b3a71e821d70d47bb42b993d0267e5faaffd
Signed-off-by: Prateek Patel <prpatel@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2709584
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: Sachin Nikam <snikam@nvidia.com>
GVS: Gerrit_Virtual_Submit
2023-04-14 11:47:58 +00:00
Jon Hunter
b67df49181 nvdla: Fix build for CONFIG_FRAME_WARN=1024
Some 3rd party Linux distributions, set the kernel configuration option
"CONFIG_FRAME_WARN=1024" which will causes the compiler to generate
compilation errors when a functions stack frame size exceeds 1024 bytes.
When compiling the DLA driver on Fedora the compilation fails with the
following errors.

 drivers/video/tegra/host/nvdla/nvdla.o] Error 1
 drivers/video/tegra/host/nvdla/nvdla_ioctl.c: In function ‘nvdla_emu_task_submit’:
 build/drivers/video/tegra/host/nvdla/nvdla_ioctl.c:918:1: error: the frame size of
 	1456 bytes is larger than 1024 bytes [-Werror=frame-larger-than=]

 drivers/video/tegra/host/nvdla/nvdla_ioctl.c: In function ‘nvdla_submit’:
 drivers/video/tegra/host/nvdla/nvdla_ioctl.c:1118:1: error: the frame size of 1440
 	bytes is larger than 1024 bytes [-Werror=frame-larger-than=]

Fix this by copying the user tasks from userspace one at a time and
allocating the structure nvdla_emu_task dynamically so that is it not
allocated on the stack.

Bug 3524939

Change-Id: If752423a170c46efd9b6cffc458a7c1db1984afe
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2694097
Tested-by: Amit Sharma (SW-TEGRA) <amisharma@nvidia.com>
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
Reviewed-by: svc-mobile-cert <svc-mobile-cert@nvidia.com>
Reviewed-by: Amit Sharma (SW-TEGRA) <amisharma@nvidia.com>
Reviewed-by: svc_kernel_abi <svc_kernel_abi@nvidia.com>
Reviewed-by: Arvind M <am@nvidia.com>
Reviewed-by: Praveen K <kpraveen@nvidia.com>
GVS: Gerrit_Virtual_Submit
2023-04-14 11:47:58 +00:00
Rajkumar Kasirajan
0b7fd59dca nvhost: register nafll parent clocks for dla & pva
The T194 BPMP does not support clock rate propagation from child
to parent clock for DLA & PVA. Register the DLA/PVA NAFLL clocks
in order to set correct clock rate to both parent and child clocks.

Bug 3510538

Change-Id: I3587e70ec44c1f025d5dfa53fd04afb731dd1eb6
Signed-off-by: Rajkumar Kasirajan <rkasirajan@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2664506
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: Ninad Malwade <nmalwade@nvidia.com>
GVS: Gerrit_Virtual_Submit
Tested-by: Ninad Malwade <nmalwade@nvidia.com>
2023-04-14 11:47:58 +00:00
Praveen K
acc29a8f3a nvdla: kmd: Add Soft SKU support
- Read Soft sku to identify if any of
  the DLA instances are disabled and
  not initialize that instance

Bug 3545642

Change-Id: Iefcd0616672fe1d2c7448ae571befa3ebe729d1f
Signed-off-by: Praveen K <kpraveen@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2675805
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: Arvind M <am@nvidia.com>
GVS: Gerrit_Virtual_Submit
2023-04-14 11:47:58 +00: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
Arvind M
3349513ab1 nvdla: kmd: set DMA direction based on access type
Based on access permission requested through pin, DMA direction
is set. This allows setting a reduced access permission for DLA
firmware and/or hardware.

Jira DLA-5775

Change-Id: Ie28e9da87325f36de12269eab1487407f6272053
Signed-off-by: Arvind M <am@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2682040
Reviewed-by: Amit Sharma (SW-TEGRA) <amisharma@nvidia.com>
Reviewed-by: Praveen K <kpraveen@nvidia.com>
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
Reviewed-by: svc-mobile-cert <svc-mobile-cert@nvidia.com>
Reviewed-by: Ken Adams <kadams@nvidia.com>
GVS: Gerrit_Virtual_Submit
2023-04-14 11:47:58 +00:00
Jon Hunter
1c9a3507d5 nvdla: Clean-up local header include paths
The local DLA header files are located in the same directory as the
source files and so it is not necessary to append the 'nvdla' directory
to the header file path.

It is important to remove the 'nvdla' directory from the header path
because then when building NVDLA as an external module, we can disable
the Makefile search path "$(srctree.nvidia)/drivers/video/tegra/host"
and ensure that headers that are outside of NVDLA directory are not
being included.

Bug 3530486

Change-Id: I44ee3e515bd604f91d40ee4479a56ead022ba05f
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2665591
Reviewed-by: svcacv <svcacv@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: Amit Sharma (SW-TEGRA) <amisharma@nvidia.com>
Reviewed-by: Praveen K <kpraveen@nvidia.com>
GVS: Gerrit_Virtual_Submit
2023-04-14 11:47:58 +00:00
Arvind M
13b677a0b5 nvdla: kmd: fix coverity defects
[1] Prevents potential use of uninitialized buffer.
[2] Removes unnecessary non-null task check during submission
    failure.
[3] Fixes logic that is identified as dead code.

CID 10074657 Uninitialized scalar variable
CID 10112959 Dereference before null check
CID 10132208 Logically dead code

Bug 3461002

Change-Id: I68520b018bcad53559c306a5faeed85af5fb6ea2
Signed-off-by: Arvind M <am@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2668778
Reviewed-by: svc_kernel_abi <svc_kernel_abi@nvidia.com>
Reviewed-by: svcacv <svcacv@nvidia.com>
Reviewed-by: Sachin Nikam <snikam@nvidia.com>
Reviewed-by: Bharat Nihalani <bnihalani@nvidia.com>
Reviewed-by: Amit Sharma (SW-TEGRA) <amisharma@nvidia.com>
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
Reviewed-by: svc-mobile-cert <svc-mobile-cert@nvidia.com>
Reviewed-by: Praveen K <kpraveen@nvidia.com>
Reviewed-by: Ken Adams <kadams@nvidia.com>
GVS: Gerrit_Virtual_Submit
2023-04-14 11:47:58 +00:00
Jon Hunter
2a496cad4b nvdla: Fix build for Linux v5.16
Building the NVDLA against the upstream kernel v5.16 is failing and
errors such as the following are seen.

 ERROR: modpost: module nvhost-nvdla uses symbol dma_buf_detach from
        namespace DMA_BUF, but does not import it.
 ERROR: modpost: module nvhost-nvdla uses symbol dma_buf_put from
        namespace DMA_BUF, but does not import it.
 ERROR: modpost: module nvhost-nvdla uses symbol dma_buf_get from
        namespace DMA_BUF, but does not import it.

Following upstream commit 16b0314aa746 ("dma-buf: move dma-buf symbols
into the DMA_BUF module namespace"), it is now necessary to import the
DMA_BUF module namespace into the Tegra DRM driver to fix this.

JIRA LS-410

Change-Id: I31f43fd4425ce80c975651d902b66f56464b0465
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2661773
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
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
Jon Hunter
870c17eed9 nvdla: Prepare for supporting upstream Linux
The referencing of syncpts in the upstream host1x Linux driver is
different to the downstream nvhost driver. By migrating the DLA driver
to use the '_ext' implementations of the various nvhost functions, we
can implement a use a common nvhost interface for both the upstream and
downstream kernels.

JIRA LS-410

Change-Id: Ibd16dfed53edf7173d44fdfaacb4080788f3ba2c
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2653102
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
722d0f22b3 nvdla: Move DLA device data into driver
To build the NVDLA driver as a standalone driver for supporting upstream
Linux kernels, it is simpler to move the DLA device data into the
driver. This greatly simplifies the process of building the driver as an
external module, because we only need the single Makefile that resides
within the 'nvdla' directory.

JIRA LS-410

Change-Id: I235008188e1c1ebda2fcb25fd58b868ff67f0352
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2653101
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
63c25f91b6 nvdla: Add definitions for Falcon registers
To support NVDLA with upstream kernels where the NVHOST driver does not
exist, add a copy of the Falcon register definitions in a local NVDLA
header file. There is no functional change by adding these definitions
and this aligns with how the register definitions are defined for QNX.

JIRA LS-410

Change-Id: I83751671ec78c2df60e59fafe9be1c1612cb44d2
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2656680
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
bf51097601 nvdla: kmd: add debugfs support for testing SC7
[1] Add suspend debugfs node to control suspend and resume operations.
    - /sys/kernel/debug/nvdla0/suspend
    - /sys/kernel/debug/nvdla1/suspend
[2] Any requests to DLA between suspend and resume shall fail.

Command to trigger suspend
    echo 1 > /sys/kernel/debug/nvdla0/suspend
    echo 1 > /sys/kernel/debug/nvdla1/suspend

Command to trigger resume
    echo 0 > /sys/kernel/debug/nvdla0/suspend
    echo 0 > /sys/kernel/debug/nvdla1/suspend

Jira DLA-5365

Change-Id: I5f30b57fce70a2904c2ac4cfeba413f86c6263a6
Signed-off-by: Arvind M <am@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2660805
Reviewed-by: svcacv <svcacv@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>
GVS: Gerrit_Virtual_Submit
2023-04-14 11:47:58 +00:00