Commit Graph

2890 Commits

Author SHA1 Message Date
Ajay Nandakumar
5190a1db72 nvadsp: change chip_id type in shared struct
The chip_id type in shared struct is u8 where as across the adsp firmwares
the chip_id type is of type uint32_t. This causes shared structure sizes
to be different causing firmwares and causes different address of the shared
struct variables when accessed from the Host and the adsp firmware.

Bug 200692666

Change-Id: I6ad23f021f64458d87596b9d6c47c9df38e3689b
Signed-off-by: Ajay Nandakumar <anandakumarm@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2524414
Reviewed-by: Sachin Nikam <snikam@nvidia.com>
Reviewed-by: Nikesh Oswal <noswal@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
GVS: Gerrit_Virtual_Submit
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2023-06-20 15:13:15 +00:00
Bitan Biswas
56135207fa platform: tegra: nvadsp: fix external build
Fix build errors in external build due to unavailable headers

bug 200705253

Change-Id: Ic4627681a9dee0e47d2da57d4247274b150928f5
Signed-off-by: Bitan Biswas <bbiswas@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2503918
Reviewed-by: svcacv <svcacv@nvidia.com>
Reviewed-by: Sameer Pujar <spujar@nvidia.com>
Reviewed-by: Ajay Nandakumar M <anandakumarm@nvidia.com>
Reviewed-by: Manish Bhardwaj <mbhardwaj@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
GVS: Gerrit_Virtual_Submit
2023-06-20 15:13:15 +00:00
Mohan Kumar
4464d26007 nvadsp: Add Interconnect support for ADSP
Add Interconnect API support for ADSP Memory bandwidth requirement
handling.

From Kernel 4.14 and beyond
- On T23X and newer platforms, the interconnects driver will be initialized
  and calls to BWMGR will be stubbed out.
- On T194 and earlier platforms, BWMGR driver will be initialized and calls
  to interconnect framework will be stubbed out.

Added code check with K5.9 as mc_utils.h header is present from K5.9 build

For Kernel 4.9 and earlier

- T23x will not be supported.
- T194 and earlier platforms will use BWMGR. Interconnect framework is not
  available.

JIRA TAS-1060

Change-Id: Ie0b4040f374a3c6102cb7aff2506d8cf2f0eab69
Signed-off-by: Mohan Kumar <mkumard@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2414369
Reviewed-by: Viswanath L <viswanathl@nvidia.com>
Reviewed-by: Sameer Pujar <spujar@nvidia.com>
Reviewed-by: Sharad Gupta <sharadg@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
GVS: Gerrit_Virtual_Submit
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2023-06-20 15:13:15 +00:00
Sameer Pujar
3b69d4961c nvadsp: Convert to set_sched_fifo*() for v5.9
While enabling 'CONFIG_TEGRA_ADSP_FILEIO' following build error
is seen with v5.9-rc4 build.

 ERROR: modpost: "sched_setscheduler" [drivers/platform/tegra/
   nvadsp/nvadsp.ko] undefined!

This happens because sched_setscheduler() export is removed with
commit 616d91b68cd5 ("sched: Remove sched_setscheduler*() EXPORTs")
in upstream. The reason for removal is below.

Upstream commit 7318d4cc14c8 ("sched: Provide sched_set_fifo()")
provides sched_set_*() functions and suggests to convert existing
sched_setscheduler_*() calls to sched_set_*(). As per this
following updates are made for ADSP driver to work for v5.9.

  - Use sched_set_fifo() whenever a high priority is required.
    (However by default priority is set to MAX_RT/2)
  - Use sched_set_fifo_low() whenever priority needs to be above
    SCHED_NORMAL.

Since it is a recent change in upstream kernel above changes are
not applicable for previous kernels (v4.14 and v4.9). Hence these
can continue to use existing calls. Thus above changes are protected
under kernel version checks.

Bug 200657500

Change-Id: I763fb7d1461e23e1eeb26d7c49a295172450e54d
Signed-off-by: Sameer Pujar <spujar@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2417919
Reviewed-by: automaticguardword <automaticguardword@nvidia.com>
Reviewed-by: Uday Gupta <udayg@nvidia.com>
Reviewed-by: Mohan Kumar D <mkumard@nvidia.com>
Reviewed-by: Bitan Biswas <bbiswas@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
GVS: Gerrit_Virtual_Submit
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2023-06-20 15:13:15 +00:00
Sameer Pujar
86b6ccfd04 nvadsp: fix v5.9-rc4 build error
After v5.9-rc4 merge in dev-main-5.9 many build errors are seen with
ADSP config CONFIG_TEGRA_ADSP_LPTHREAD. Some of these build errors
are listed below.

* kernel/nvidia/drivers/platform/tegra/nvadsp/adsp_lpthread.c:15:0:
  kernel-5.9/include/linux/uaccess.h: In function ‘force_uaccess_begin’:
  kernel-5.9/include/linux/uaccess.h:20:2: error: implicit declaration
      of function ‘set_fs’; did you mean ‘get_fs’?
      [-Werror=implicit-function-declaration]
      set_fs(USER_DS);
      ^~~~~~

* kernel-5.9/arch/arm64/include/asm/uaccess.h: In function
      ‘__uaccess_mask_ptr’:
  kernel-5.9/arch/arm64/include/asm/uaccess.h:240:41: error: invalid type
      argument of ‘->’ (have ‘int’) : "r" (ptr), "r"
      (current_thread_info()->addr_limit),
                            ^~

  ...

The errors appear to be related to 'uaccess.h' header and following
inclusion order is causing build failures for some reason. Checked with
other source files with below and same behavior is seen.

  #include <asm/uaccess.h>
  #include <linux/uaccess.h>
  ...

Issue goes away after replacing 'asm/uaccess.h' with 'linux/uaccess.h'.
It should be noted that latter header by default includes the former one.
For consistency this is done for other relevant ADSP files too.

Bug 200657500

Change-Id: I7ce98c46327a825711c4fa9ab791afc65b1cbf1b
Signed-off-by: Sameer Pujar <spujar@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2417265
Reviewed-by: automaticguardword <automaticguardword@nvidia.com>
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Mohan Kumar D <mkumard@nvidia.com>
Reviewed-by: Sachin Nikam <snikam@nvidia.com>
Reviewed-by: Uday Gupta <udayg@nvidia.com>
Reviewed-by: Sharad Gupta <sharadg@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
GVS: Gerrit_Virtual_Submit
2023-06-20 15:13:15 +00:00
Sameer Pujar
4614098993 nvadsp: fix build errors on v5.9
Following build errors are seen when ADSP configs CONFIG_TEGRA_ADSP_FILEIO
and CONFIG_TEGRA_ADSP_LPTHREAD are enabled.

* Error due to "segment.h"

  adsp_lpthread.c:14:10: fatal error: asm/segment.h: No such file or
    directory
  adspff.c:17:10: fatal error: asm/segment.h: No such file or directory

  (asm/segment.h inclusion is removed as asm/uaccess.h already takes care
   of required dependencies)

* Error due to unavailable structure "sched_param"

  adspff.c:517:21: error: variable ‘param’ has initializer but incomplete
    type
  adspff.c:518:3: error: ‘const struct sched_param’ has no member named
    ‘sched_priority’

  (Replace <linux/sched/types.h> with <uapi/linux/sched/types.h> to fix
   this build issue)

* Error due to unavailable "get_ds()"

  adspff.c:63:9: error: implicit declaration of function ‘get_ds’; did you
    mean ‘get_fs’? [-Werror=implicit-function-declaration]

  (Fixed by replacing get_ds() with KERNEL_DS. The get_ds() support is
   removed from upstream kernel)

Bug 200593718
Bug 200657500

Change-Id: I8b9cbed5ee42f34cf3731ea2d2f06aa760c28358
Signed-off-by: Sameer Pujar <spujar@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2412299
Reviewed-by: automaticguardword <automaticguardword@nvidia.com>
Reviewed-by: Mohan Kumar D <mkumard@nvidia.com>
Reviewed-by: Dipesh Gandhi <dipeshg@nvidia.com>
Reviewed-by: Sharad Gupta <sharadg@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
GVS: Gerrit_Virtual_Submit
2023-06-20 15:13:15 +00:00
Sameer Pujar
08391815ee Revert "[TEMP] nvadsp: request clk_round_rate() for 600 MHz"
This reverts commit 9786bb772a32456102f4de622c9ce3ee35784920.

The original commit earlier was done to avoid a clock issue in BPMP as a
temporary fix. Since now the root cause is addressed in BPMP it can be
reverted.

Bug 200617376

Change-Id: I64df2f33e1fd294c151ae4f7b39e2d9ea321b5c6
Signed-off-by: Sameer Pujar <spujar@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2354898
Reviewed-by: automaticguardword <automaticguardword@nvidia.com>
Reviewed-by: Mohan Kumar D <mkumard@nvidia.com>
Reviewed-by: Uday Gupta <udayg@nvidia.com>
Reviewed-by: Sivaram Nair <sivaramn@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
GVS: Gerrit_Virtual_Submit
2023-06-20 15:13:15 +00:00
Bitan Biswas
c880772741 nvidia: drivers: fix linux-5.7-rc5 build
Fix build linux-5.7-rc5 errors including following:
	- change timespec to timespec64. replace getnstimeofday
	  with ktime_get_ts64
	- replace usage of macro FIELD_SIZEOF with sizeof_field in ethtool.c
	  nvethernet and eqos files.
	- support 2 arguments for of_get_phy_mode call

bug 200617764

Change-Id: I46067d7d36d08ee9556b2722e9ccec707b8853d4
Signed-off-by: Bitan Biswas <bbiswas@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2347244
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
2023-06-20 15:13:15 +00:00
Sameer Pujar
134ade9bf2 nvadsp: request clk_round_rate() for 600 MHz
On 5.4 kernel clk_round_rate(), for ACLK with ULONG_MAX request, is
returning minimum possible value for ACLK and this is causing a
failure with ADSP OS load. The issue is found in BPMP where there
is a problem with data mis-alignment. Till this gets addressed a TEMP
change is provided here to unblock ADSP audio related work.

This can be reverted once original BPMP fix is merged.

Bug 200593718

Change-Id: I1965986770424f2a8560e011ca892b700cdc0258
Signed-off-by: Sameer Pujar <spujar@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2345133
Reviewed-by: automaticguardword <automaticguardword@nvidia.com>
Reviewed-by: Dipesh Gandhi <dipeshg@nvidia.com>
Reviewed-by: Uday Gupta <udayg@nvidia.com>
Reviewed-by: Mohan Kumar D <mkumard@nvidia.com>
Reviewed-by: Sharad Gupta <sharadg@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
GVS: Gerrit_Virtual_Submit
2023-06-20 15:13:15 +00:00
Sameer Pujar
68ea0dc35b nvadsp: fix build error due to elf_hwcap
Build error is seen on 5.4 kernel due to 'elf_hwcap' not being available.
Commit aec0bff757c9 ("arm64: HWCAP: encapsulate elf_hwcap") in upstream
removes direct expose of 'elf_hwcap' and instead provides a helper function
cpu_get_elf_hwcap() for it.

To fix build error this patch includes 'asm/hwcap.h' which works well for
all supported kernel versions in downstream. The macro ELF_HWCAP, from this
header, can be used for this purpose.
 * For kernel < 5.4  : ELF_HWCAP --> elf_hwcap
 * For kernel >= 5.4 : ELF_HWCAP --> cpu_get_elf_hwcap()

Bug 200593718

Change-Id: I3ef3527be5972d6f6ba6ab6ef6dc50936dff73fd
Signed-off-by: Sameer Pujar <spujar@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2341654
Reviewed-by: automaticguardword <automaticguardword@nvidia.com>
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Mohan Kumar D <mkumard@nvidia.com>
Reviewed-by: Sharad Gupta <sharadg@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
GVS: Gerrit_Virtual_Submit
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2023-06-20 15:13:15 +00:00
Sameer Pujar
bff1871f76 nvadsp: fix build error related to counter
On 5.4 kernel, function arch_counter_get_cntvct() is not available
in arch_timer.h and this causes build error. This patch fixes the
issue by using __arch_counter_get_cntvct_stable() which provides
similar functionality.

Bug 200593718

Change-Id: I64732dc3a11effba0f05afb3f9cbd50351047ee8
Signed-off-by: Sameer Pujar <spujar@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2341653
Reviewed-by: automaticguardword <automaticguardword@nvidia.com>
Reviewed-by: Mohan Kumar D <mkumard@nvidia.com>
Reviewed-by: Sharad Gupta <sharadg@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
GVS: Gerrit_Virtual_Submit
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2023-06-20 15:13:15 +00:00
Sameer Pujar
29efd1bd1b nvadsp: fix build errors due to chip-id.h
5.4 kernel no longer uses chip-id.h and instead fuse.h is used.
Currently this causes build issues in ADSP driver code and hence
related drivers are updated to make use of references as per
fuse.h for 5.4 kernel.

The issue is not seen on TOT because ADSP is not yet enabled.

Bug 200593718

Change-Id: I82af6a4f02ce64da4b20875a28f8ef9488b92e54
Signed-off-by: Sameer Pujar <spujar@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2341652
Reviewed-by: automaticguardword <automaticguardword@nvidia.com>
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Bitan Biswas <bbiswas@nvidia.com>
Reviewed-by: Mohan Kumar D <mkumard@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
GVS: Gerrit_Virtual_Submit
2023-06-20 15:13:15 +00:00
Bitan Biswas
ceb4b9f02e kernel: nvidia: use fuse.h instead of chip-id.h in k5.4
bug 200591811

Change-Id: If72122efdeda154f435f79da8f2cd9cad644d380
Signed-off-by: Bitan Biswas <bbiswas@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2337930
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
2023-06-20 15:13:15 +00:00
Sameer Pujar
6cd83e4d26 nvadsp: don't use tegra-pd for kernel 5.4 onwards
The usage of Tegra power-domains is deprecated from kernel-5.4 and
instead generic power-domains should be used. Current driver code
is common across multiple kernel versions and to maintain backward
compatibility kernel version checks are added.

Bug 200593718

Change-Id: Ia49c0bab0d320de2d4a3a23e7e675242f56dbff7
Signed-off-by: Sameer Pujar <spujar@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2334795
Reviewed-by: automaticguardword <automaticguardword@nvidia.com>
Reviewed-by: Mohan Kumar D <mkumard@nvidia.com>
Reviewed-by: Dipesh Gandhi <dipeshg@nvidia.com>
Reviewed-by: Sharad Gupta <sharadg@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
GVS: Gerrit_Virtual_Submit
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2023-06-20 15:13:15 +00:00
Sameer Pujar
003fec905d nvadsp: fix 5.4 build error related to access_ok()
access_ok() macro has changed in 5.4 kernel and it does not accept
the same number of arguments any more. To fix the build error and
to make it work for all the supported kernels, a new local macro
ACCESS_OK() is introduced which can further make kernel specific
calls.

Bug 200593718

Change-Id: I71f766401ec185859b4185f2e4b4f2bb914965fc
Signed-off-by: Sameer Pujar <spujar@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2323014
Reviewed-by: automaticguardword <automaticguardword@nvidia.com>
Reviewed-by: Mohan Kumar D <mkumard@nvidia.com>
Reviewed-by: Sharad Gupta <sharadg@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
GVS: Gerrit_Virtual_Submit
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2023-06-20 15:13:15 +00:00
Sameer Pujar
a617e73405 nvadsp: build dependency on HSP driver
ADSP driver has build dependency over HSP driver. Currently on
5.4 CONFIG_TEGRA_HSP is not yet enabled and it is causing build
break. This can be addressed by including corresponding driver
calls under above config check.

Bug 200593718

Change-Id: I4847f8ac251c9cb2bd96fbdecbf29b4200aca371
Signed-off-by: Sameer Pujar <spujar@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2323013
Reviewed-by: automaticguardword <automaticguardword@nvidia.com>
Reviewed-by: Mohan Kumar D <mkumard@nvidia.com>
Reviewed-by: Dipesh Gandhi <dipeshg@nvidia.com>
Reviewed-by: Sharad Gupta <sharadg@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
GVS: Gerrit_Virtual_Submit
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2023-06-20 15:13:15 +00:00
Asha Talambedu
b24ad07d95 nvadsp: Remove symbol table creation for l4t
Removed symbol table for L4T platform that has symbol stripped
adsp-fw

Bug 200536088

Change-Id: I18187479c796c98ce2dcc5865e1175dd9d7c9f5e
Signed-off-by: Asha Talambedu <atalambedu@nvidia.com>
(cherry picked from commit 4089e712d554081a69f34e60a01459cb19e1978c)
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2308814
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: automaticguardword <automaticguardword@nvidia.com>
Reviewed-by: Mohan Kumar D <mkumard@nvidia.com>
Reviewed-by: Sharad Gupta <sharadg@nvidia.com>
Reviewed-by: Viswanath L <viswanathl@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
GVS: Gerrit_Virtual_Submit
2023-06-20 15:13:15 +00:00
Swati Sachdeva
0f6dc52655 nvadsp: Fixing adsp_ff_exit function
- ADSP thread was waiting on a sempaphore to wake up
- In case of shutdown when kthread_stop is called, kthread_should_stop
- will not be called if thread is not woken up

- Solution: Replace semaphore with wait_queue and use
- wait_event_interruptible
- wake up the thread if either there is a message in the list or
- kthread_should_stop is true

Bug 2739934
Bug 200560194
Bug 200463529

Change-Id: Iea04e0100248f554076aaed8627d40f5b96df2bf
Signed-off-by: Uday Gupta <udayg@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2232868
(cherry picked from commit a3a81a984a933a8f580154b76098119427f5e19e)
Signed-off-by: Dipesh Gandhi <dipeshg@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2238825
Reviewed-by: Automatic_Commit_Validation_User
GVS: Gerrit_Virtual_Submit
Reviewed-by: Swati Sachdeva <ssachdeva@nvidia.com>
Reviewed-by: Nitin Pai <npai@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2023-06-20 15:13:15 +00:00
Dipesh Gandhi
b72af873f4 ASoC: tegra-virt-alt: lpthread init via amixer
Change exposes lpthread/adsp usage trigger via
amixer. This is needed to make sound card aware
of lpthread state. Without this STR adsp feature
breaks as currently lpthread is written in such
a manner which does not allow adsp to suspend.

Bug 200552183

Change-Id: I2cc1e0fd805a982686bbd034b2c6e094b56df23b
Signed-off-by: Dipesh Gandhi <dipeshg@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2198693
(cherry picked from commit e9bd14fd6eb0305cc583092752e6bdccc9c5e76a)
Reviewed-on: https://git-master.nvidia.com/r/2250202
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Swati Sachdeva <ssachdeva@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Uday Gupta <udayg@nvidia.com>
Reviewed-by: Nitin Pai <npai@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2023-06-20 15:13:15 +00:00
Asha Talambedu
dddab770de platform: tegra: Make ADSP CPU driver a LKM
-Made necessary Kconfig and makefile changes
 required to make ADSP CPU driver a loadable kernel
 module.
-Had to replace nsec_to_clock_t api with functions that are
 available as exported symbols as nsec_to_clock_t is not an
 exported symbol

Bug 200560561

Change-Id: Ia2fa069d9bb234b57f19cbf919c9e6d7567f3d7b
Signed-off-by: Asha Talambedu <atalambedu@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2215613
(cherry picked from commit 519a4618c452e3a62550d4fdf3ec5b52acf8b9c8)
Reviewed-on: https://git-master.nvidia.com/r/2228337
Reviewed-by: Automatic_Commit_Validation_User
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-06-20 15:13:15 +00:00
Dipesh Gandhi
1dd46a95c7 ASoC: tegra-alt: remove redundant drivers
- remove unused code
- update hypervisor check condition

Bug 200552920

Change-Id: Ie2ca3542d8dc50191f402c9d4c96d56e4c89db7a
Signed-off-by: Dipesh Gandhi <dipeshg@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2200432
Reviewed-by: Uday Gupta <udayg@nvidia.com>
Tested-by: Uday Gupta <udayg@nvidia.com>
Reviewed-by: Mohan Kumar D <mkumard@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Nitin Pai <npai@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2023-06-20 15:13:15 +00:00
Niranjan Dighe
a1a7e31c61 Revert "adsp: add dma_set_mask parse"
This reverts commit 4c531e24d2a08eaef19ea5e366374d0aab6b58bd.

Jira EMA-1251

Change-Id: I3de386b442ecf3beca938db0725bbe3e673d15c1
Signed-off-by: Niranjan Dighe <ndighe@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2166541
Reviewed-by: Uday Gupta <udayg@nvidia.com>
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Dipesh Gandhi <dipeshg@nvidia.com>
Reviewed-by: Mohan Kumar D <mkumard@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Nitin Pai <npai@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2023-06-20 15:13:15 +00:00
Niranjan Dighe
15961fe4f8 nvadsp: logger: reset is_opened flag on file close
adsp_logger file could not be re-opened after closing and open call
always returned -EBUSY. This was because logger->is_opened was never
reset in the file close path. Setting it to 0 in .release callback
solves the problem.

Jira EMA-1321

Change-Id: I42834fa7af19bacc4326cd32745996b6f4e47686
Signed-off-by: Niranjan Dighe <ndighe@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2153912
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2023-06-20 15:13:15 +00:00
Niranjan Dighe
8916271137 nvadsp: adspff: fix issues with kthread impl
- Implement file list rather than fixed length array
- Fix issues related to file mode handling
- Change file not found validation with respect to commit c136844cd414
  ("nvadsp: adspff: use kthread to schedule file io")

Bug 2538512

Change-Id: I1cd8fa065887effa6073d963df62f6e1bb877a1d
Signed-off-by: Niranjan Dighe <ndighe@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2102696
(cherry picked from commit ea7d4ea78a22b7d8675966f2b2f85343c488d059)
Reviewed-on: https://git-master.nvidia.com/r/2150780
Tested-by: Hariharan Sivaraman <hariharans@nvidia.com>
Reviewed-by: Automatic_Commit_Validation_User
GVS: Gerrit_Virtual_Submit
Reviewed-by: Nitin Pai <npai@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2023-06-20 15:13:15 +00:00
Shashank Verma
b82520e6d3 nvadsp: adspff: add spinlock across list_del
Added spinlock across list_del to prevent
race between itself and list_add_tail.

Bug 1846449
Jira EMA-847

Change-Id: Icc27b0d4926659a04bff3ddb02ec0c11ed1e0a70
Signed-off-by: Shashank Verma <shashankv@nvidia.com>
Reviewed-on: http://git-master/r/1326930
(cherry picked from commit f097894d0382f79c100bf7bd75c7f923eb20085c)
Signed-off-by: Hariharan Sivaraman <hariharans@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2029205
(cherry picked from commit a7ca3766153a0c5068fbc0dff7391426a948e79a)
Reviewed-on: https://git-master.nvidia.com/r/2030553
(cherry picked from commit 2806ac36bc24af1796e875edc4a6678e2db86f97)
Reviewed-on: https://git-master.nvidia.com/r/2150779
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Niranjan Dighe <ndighe@nvidia.com>
Reviewed-by: Dipesh Gandhi <dipeshg@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Nitin Pai <npai@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2023-06-20 15:13:15 +00:00
Gaurav Tendolkar
857731124c nvadsp: adspff: use kthread to schedule file io
- Workqueue scheduling latency causes issues for
  adsp apps requiring real time behaviour. Hence
  use RT kthread to schedule the file io functions
- file open with O_TRUNC flag may take long time
  Hence we open the file just once and just reset
  the read/write pointers in a file close call
- Expose sysfs entry to actually close all files
  opened by kernel

Bug 1846449
Jira EMA-847

Change-Id: I3c130b36e5f5f5a0e65ddb4c44efc8754fb006d2
Signed-off-by: Gaurav Tendolkar <gtendolkar@nvidia.com>
Reviewed-on: http://git-master/r/1314984
(cherry picked from commit 00f5d0b48aa0df9a720c6fd15b4cffd827408375)
Signed-off-by: Hariharan Sivaraman <hariharans@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2029203
(cherry picked from commit 6760f7d61a589b90a8c156a38e4453b518a20b05)
Reviewed-on: https://git-master.nvidia.com/r/2030551
(cherry picked from commit c136844cd4147c25478fe39a15122a1f43553079)
Reviewed-on: https://git-master.nvidia.com/r/2150778
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Niranjan Dighe <ndighe@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Nitin Pai <npai@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2023-06-20 15:13:15 +00:00
Hariharan Sivaraman
cb8fd9beb2 nvadsp: allocate adsp shared memory dynamically
NVADSP driver tries to allocate shared memory for ADSP
by requesting the DMA APIs to allocate at address hardcoded
in DT. This poses an issue where if kernel has already allocated
that memory to a different driver in same iommu group, this
memory becomes unavailable and ADSP does not boot

Adding support to allocate shared memory for ADSP dynamically
to avoid dependencies on other drivers

Jira EMA-1213

Change-Id: I1bc8d49f17ec8226d34f3c943cccabef97b2afb6
Signed-off-by: Hariharan Sivaraman <hariharans@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2134341
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Uday Gupta <udayg@nvidia.com>
GVS: Gerrit_Virtual_Submit
Tested-by: Niranjan Dighe <ndighe@nvidia.com>
Reviewed-by: Nitin Pai <npai@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2023-06-20 15:13:15 +00:00
Hariharan Sivaraman
dfc3347d28 adsp: add support for ivc based adsp reset control
For virtualized configurations, ADSP reset will be owned
only by Audio server.

- Moving tegra-virt-alt-ivc to drivers/.../nvaudio_ivc/
to enable Audio IVC to be built as part of Image

- Adding support in nvadsp driver to communicate with
Audio server for asserting or deasserting ADSP.

Jira EMA-1208

Change-Id: I6773c35edf2c646aa9fd7ec0aa5eceb992dffa35
Signed-off-by: Hariharan Sivaraman <hariharans@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2113661
Reviewed-by: Uday Gupta <udayg@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Mohan Kumar D <mkumard@nvidia.com>
Reviewed-by: Nitin Pai <npai@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2023-06-20 15:13:15 +00:00
Nicolin Chen
767700e13d platform: nvadsp: Fix iova reservation
There is no point in managing iovad that's not binded to
device's IOMMU domain. So this patch just removes iovad
managing code and does a correct iommu_dma_alloc_iova()
to reserve the iova.

A difficulty of using iommu_dma_alloc_iova() is that we
mostly do not use aligned addresses for the target iova,
but IOMMU core aligns the iova address with the size by
power of two due to cache friendly. So the trick here is
to align the start address and to allocate a larger iova
region that would cover the target iova -- the excessive
part will be freed during iommu_dma_free_iova() by IOMMU
core.

Note that the dma_free_coherent() does both iommu_unmap
and iommu_dma_free_iova, so there's no need of an extra
free_iova() in the exit routine. However, for the remap
part, the tmp_iova is allocated and mapped, so it should
be unmapped and freed. So this patch also adds a free()
of tmp_iova in the nvadsp_dma_alloc_at_map() function.

Bug 200444660

Change-Id: I54126c2bd9ff3dd688aaa5c6f9befaad620ab548
Signed-off-by: Nicolin Chen <nicolinc@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2096704
Reviewed-by: Automatic_Commit_Validation_User
GVS: Gerrit_Virtual_Submit
Reviewed-by: Krishna Reddy <vdumpa@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2023-06-20 15:13:15 +00:00
Nicolin Chen
d059cdbc44 platform: nvadsp: Remove iova lucky check
The logic of the nvadsp_dma_alloc_and_map_at() function is to
firstly reserve the target iova and secondly allocate a memory
with another dynamical iova.

Since the target iova is reserved, the dynamical iova won't be
possible to be identical. And this lucky check lacks of an exit
routine either.

So this patch just drops it.

Bug 200444660

Change-Id: I5c45e72b1e7315dacd8708fc8facf6bda41c51e5
Signed-off-by: Nicolin Chen <nicolinc@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2098219
Reviewed-by: Automatic_Commit_Validation_User
GVS: Gerrit_Virtual_Submit
Reviewed-by: Krishna Reddy <vdumpa@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2023-06-20 15:13:15 +00:00
Nicolin Chen
65f4df1dc4 platform: nvadsp: Drop KERNEL_VERSION check
The dma-mask could be applied to an older kernel as well.
And this is essential for nvadsp driver to use the newer
nvadsp_dma_alloc_and_map_at() function. Though downstream
kernel 4.9 still has dma_alloc_at_coherent() support, it
would be cleaner to have nvadsp code using a unified way
instead of adding older dma_alloc_at_coherent() back with
another KERNEL_VERSION check.

Bug 200444660

Change-Id: I3968155c7439789a398ca499e70598ce1385737a
Signed-off-by: Nicolin Chen <nicolinc@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2096705
Reviewed-by: Automatic_Commit_Validation_User
GVS: Gerrit_Virtual_Submit
Reviewed-by: Krishna Reddy <vdumpa@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2023-06-20 15:13:15 +00:00
Nicolin Chen
5759b9d6d4 platform: nvadsp: Fix dma_free_coherent() call
The parameters of dma_free_coherent() should be in order of:
1) Device pointer 2) Size 3) CPU virtual address 4) Device address

However, the dma_free_coherent() here mixes with the size with the
device address which will trigger kernel bugs. So this patch fixes
the bug by exchanging those two.

Bug 200444660

Change-Id: Ib0b7855be3868908a4fd59beb938f8bec9e6daee
Signed-off-by: Nicolin Chen <nicolinc@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2098218
Reviewed-by: Automatic_Commit_Validation_User
GVS: Gerrit_Virtual_Submit
Reviewed-by: Krishna Reddy <vdumpa@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2023-06-20 15:13:15 +00:00
Nicolin Chen
df7a7fb5ab platform: nvadsp: Fix mismatched mutex lock/unlock
The function hasn't grabbed the mutex_lock yet at first
condition check. So this patch changes the exit path to
return directly instead of jumping to the mutex_unlock.

Bug 200444660

Change-Id: I122fc9cd145a5de932b4ae55d88c878231926072
Signed-off-by: Nicolin Chen <nicolinc@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2098217
Reviewed-by: Automatic_Commit_Validation_User
GVS: Gerrit_Virtual_Submit
Reviewed-by: Krishna Reddy <vdumpa@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2023-06-20 15:13:15 +00:00
Nicolin Chen
9b6d089a5e platform: nvadsp: Deprecate dma_alloc_at_coherent
The dma_alloc_at_coherent is implemented with a hack in the
iommu core code, which is unlikely able to get upstream. So
this patch removes its callers in the nvadsp code, and then
adds an alternative helper function to do something similar.

The dma_alloc_at_coherent was used to allocate a DMA buffer
and to map it to a specified iova address. And this can be
done by remapping a normal DMA buffer to the iova address.

Bug 200444660

Change-Id: Ic90aec550daa29df69d97c4b230c8f9cc1519166
Signed-off-by: Nicolin Chen <nicolinc@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2083356
Reviewed-by: Krishna Reddy <vdumpa@nvidia.com>
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2023-06-20 15:13:15 +00:00
Niranjan Dighe
27c5e1cba3 adsp: fix tlv read write issues
Change fixes problems caused in tlv read and write
synchronization with other messages
- Add separate spinlock completions for tlv read
- Add separate spinlock completions for tlv write
- Add separate ack for raw (tlv) messages
- Print msgq indexes when queue or dequeue fails

Bug 2420196

Change-Id: I405e3a9939ec804dc65875d900ba635d2dc15ee3
Signed-off-by: Hariharan Sivaraman <hariharans@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1975072
(cherry picked from commit 1df184d908c84c8f4e15b48cdd9ada90da313169)
Signed-off-by: Niranjan Dighe <ndighe@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1986443
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Uday Gupta <udayg@nvidia.com>
Reviewed-by: Nitin Pai <npai@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2023-06-20 15:13:15 +00:00
Anuj Gangwar
99fa48e09c include: uapi: move adsp user-interface header
Move the driver adsp_console_ioctl.h user-interface headers from
drivers/platform/tegra/nvadsp/adsp_console_ioctl.h to
include/uapi/misc/

Change the path for above headers in the dependent files.

Bug 2062672

Change-Id: I7337c0fc03a75101b4276773368a7c4eccd25960
Signed-off-by: Anuj Gangwar <anujg@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1956612
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
Reviewed-by: svc-mobile-misra <svc-mobile-misra@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Stephen Warren <swarren@nvidia.com>
Reviewed-by: Bibek Basu <bbasu@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2023-06-20 15:13:15 +00:00
Hariharan Sivaraman
ee8de73c70 nvadsp: Clear HWBOX0 for ADSP guest reset handling
During ADSP playback, if HWMBOX0 is high and guest reset is
done, after reset ADSP is unable to communicate with kernel
driver since the interrupt line remains High thereby not
generating interrupt (edge triggered).

Jira EMA-1178

Change-Id: Ifb1283c7286ed944f243e7d92dfe4db40bcd0ba2
Signed-off-by: Hariharan Sivaraman <hariharans@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1978017
Reviewed-by: Uday Gupta <udayg@nvidia.com>
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
Reviewed-by: svc-mobile-misra <svc-mobile-misra@nvidia.com>
Reviewed-by: Automatic_Commit_Validation_User
GVS: Gerrit_Virtual_Submit
Reviewed-by: Dipesh Gandhi <dipeshg@nvidia.com>
Reviewed-by: Sachin Nikam <snikam@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2023-06-20 15:13:15 +00:00
Niranjan Dighe
989d49990e nvadsp: adspff: Fix kernel crash if file not found
Check file->fp for NULL before returning the file handle to
ADSP in adspff_fopen, which otherwise results in a kernel crash
on successive file operations using the same file handle if the
requested file does not exist.

Jira: EMA-1152

Change-Id: I307cc82dd3a2135039b819d1f746ee8164568110
Signed-off-by: Niranjan Dighe <ndighe@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1929809
Reviewed-by: Automatic_Commit_Validation_User
GVS: Gerrit_Virtual_Submit
Reviewed-by: Uday Gupta <udayg@nvidia.com>
Reviewed-by: Hariharan Sivaraman <hariharans@nvidia.com>
Reviewed-by: Nitin Pai <npai@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2023-06-20 15:13:15 +00:00
Dipesh Gandhi
e23ed464ef nvadsp: adsp suspend/resume handling
Change adds pm ops in nvadsp driver to support suspend/resume
functionality. Without the change, if playback/capture is active when
system suspend occurs, the nvadsp driver is never suspended and hence
the clocks are not disabled.

In terms of power sequence device driver registered as late_suspend are
suspended first followed by noirq pm ops registred devices.
adsp_audio device node is registered for late suspend. To make sure
adsp_audio suspend is called first nvadsp is registered under noirq pm
ops

Jira EMA-641

Change-Id: I3a6c3d75cbafc9e25771c4207113db1cd8066d09
Signed-off-by: Dipesh Gandhi <dipeshg@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1689900
Reviewed-by: Ajay Nandakumar M <anandakumarm@nvidia.com>
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
Reviewed-by: Uday Gupta <udayg@nvidia.com>
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Jinyoung Park <jinyoungp@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Ravindra Lokhande <rlokhande@nvidia.com>
Reviewed-by: Sachin Nikam <snikam@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2023-06-20 15:13:15 +00:00
Dipesh Gandhi
6a3e481f36 nvadsp: prevent race in os_queue for app
Change add spinlock to nvadsp app start and init
functions for os_queue write protection. It make
sure only one app from different context can update
queue at given time.
Also added some debug info to adsp driver for providing
extra info for debugging purpose.

Bug 2060866

Signed-off-by: Dipesh Gandhi <dipeshg@nvidia.com>
Change-Id: If1bbfdb233d2af984f62bb02ed515eec1ab8a492
Reviewed-on: https://git-master.nvidia.com/r/1655974
(cherry picked from commit 7edeb242aba4cabc517b6e270b254777e3ea66ea)
Reviewed-on: https://git-master.nvidia.com/r/1775133
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
Reviewed-by: Hariharan Sivaraman <hariharans@nvidia.com>
Reviewed-by: Viraj Karandikar <vkarandikar@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Nitin Pai <npai@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2023-06-20 15:13:15 +00:00
Uday Gupta
7d7819bcb2 nvadsp: Add get file size support to adspff APP
Add adsp_fsize support

Bug 2060675

Change-Id: I288d09c290eab940547c76654fa5708efc40724d
Signed-off-by: Hariharan Sivaraman <hariharans@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1775909
GVS: Gerrit_Virtual_Submit
Tested-by: Uday Gupta <udayg@nvidia.com>
Reviewed-by: Swati Sachdeva <ssachdeva@nvidia.com>
Reviewed-by: Viraj Karandikar <vkarandikar@nvidia.com>
Reviewed-by: Nitin Pai <npai@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2023-06-20 15:13:15 +00:00
Mika Andersson
0d5e6bc927 platform: nvadsp: Check input buf-size in adsp logger
Adsp logger's read incorrectly expected the (remaining)
size of the user-buf to be at least ADSP_TAG - 1 chars.
That has been corrected.

For simplicity there is no state machine introduced to
make sure the ADSP_TAG is always complete in the log.
In the case the tag needs to be added to user-buf without
sufficient size it gets simply truncated.

Bug: 2108805

Change-Id: Ifd137980be521ca3c0932248353f10ea0e92692a
Signed-off-by: Mika Andersson <mikaa@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1770559
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
Reviewed-by: Uday Gupta <udayg@nvidia.com>
Reviewed-by: Viraj Karandikar <vkarandikar@nvidia.com>
Reviewed-by: Ajay Nandakumar M <anandakumarm@nvidia.com>
Reviewed-by: Sandeep Trasi <strasi@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2023-06-20 15:13:15 +00:00
Hariharan Sivaraman
385dc63275 nvadsp: Add ADMA page info in hwmbox
For virtualized configurations, add DMA page info
for ADSP to read via HWMBOX. Remaining DMA pages will be
unmapped by ADSP OS

Jira EMA-414
Jira EMA-415

Change-Id: I67b7b2069aca07948e63436367d80a2baeaaf6ae
Signed-off-by: Hariharan Sivaraman <hariharans@nvidia.com>
Reviewed-on: https://git-master/r/1477304
(cherry picked from commit 93f338df31af5894935754aac23bb003168f9ea0)
Signed-off-by: Hariharan Sivaraman <hariharans@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1567625
Reviewed-by: Viraj Karandikar <vkarandikar@nvidia.com>
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Nitin Pai <npai@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2023-06-20 15:13:15 +00:00
Dara Ramesh
6b338bab49 adsp: add dma_set_mask parse
Add dma-mask parsing in device tree for adsp
driver to start allocations start from the
specified address and downwards.

This will allows adsp binaries are placed
at top of the IOVA space

Bug 200385990
Bug 200406253

Change-Id: Id37579a78e6d788cfd722505a23e90f249cee5eb
Signed-off-by: Dara Ramesh <dramesh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1755675
Reviewed-by: Ajay Nandakumar M <anandakumarm@nvidia.com>
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
Reviewed-by: Dipesh Gandhi <dipeshg@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Ravindra Lokhande <rlokhande@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2023-06-20 15:13:15 +00:00
Dara Ramesh
beddbe937e adsp: updated standard include path & clock_t api
cputime64_to_clock_t is deprecated on kernel 4.14
as it is an architecture defined type
so changing cputime64 to nsecs.

Bug 200406253

Change-Id: I16bac09da698ca1b15130be69fb7c58c70d3ce94
Signed-off-by: Dara Ramesh <dramesh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1742429
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Ajay Nandakumar M <anandakumarm@nvidia.com>
Reviewed-by: Sachin Nikam <snikam@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2023-06-20 15:13:15 +00:00
Uday Gupta
159d4e9e34 nvadsp: Increase static app queue size
Increase static app init queue size between ADSP
and CCPLEX to handle more APPs.

Bug 2131818

Change-Id: Id8b376f312c3a3f04ec82abe69ec62994fcc0254
Signed-off-by: Uday Gupta <udayg@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1726937
Tested-by: Hariharan Sivaraman <hariharans@nvidia.com>
Reviewed-by: Ajay Nandakumar M <anandakumarm@nvidia.com>
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Dipesh Gandhi <dipeshg@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Nitin Pai <npai@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2023-06-20 15:13:15 +00:00
Dipesh Gandhi
ca09364356 nvadsp: clock cleanup for audio devices
Change cleans up ape, apb2ape clocks from nvadsp device.
These clocks will be controlled by parent aconnect bus device
as for any audio use case to work we need these clocks.

PM_RUNTIME on nvadsp will call runtime for aconnect which
will enable these minimal required clocks.

Jira EMA-641

Change-Id: I2f452ed1f28fc2ee79bd0f7eac686aeccd8d9513
Signed-off-by: Dipesh Gandhi <dipeshg@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1688359
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Uday Gupta <udayg@nvidia.com>
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Ajay Nandakumar M <anandakumarm@nvidia.com>
Reviewed-by: Sachin Nikam <snikam@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2023-06-20 15:13:15 +00:00
David Gilhooley
d56b0972b0 platform: nvadsp: prevent speculative load related leak
Data can be speculatively loaded from memory and stay in cache even
when bound check fails. This can lead to unintended information
disclosure via side-channel analysis.

To mitigate this problem, use array_index_nospec.

Bug 2060857
CVE-2017-5753

Change-Id: I3b79ab2df0cff5eb7f94f8056cfdfb98ac69037a
Signed-off-by: David Gilhooley <dgilhooley@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1684649
Reviewed-by: Bo Yan <byan@nvidia.com>
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2023-06-20 15:13:15 +00:00
Dipesh Gandhi
c844c3a973 nvadsp: false trigger for adsp boot
Change add spinlock protection for message enqueue to avoid possible
race condition between enqueue and dequeue of ADSP OS message.

Bug 2031075

Change-Id: Iad243fdf034db89a61e32411a8b03c817c19d81e
Signed-off-by: Dipesh Gandhi <dipeshg@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1613124
(cherry picked from commit 3d146a3ba4dbe4c1375d64d425ff0b9be7f7c272)
Reviewed-on: https://git-master.nvidia.com/r/1669402
Reviewed-by: Bharat Nihalani <bnihalani@nvidia.com>
Tested-by: Bharat Nihalani <bnihalani@nvidia.com>
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
Reviewed-by: Automatic_Commit_Validation_User
GVS: Gerrit_Virtual_Submit
Tested-by: Ajay Nandakumar M <anandakumarm@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2023-06-20 15:13:15 +00:00
Ajay Nandakumar
c8f7a26db7 platform: nvadsp: Reduce blocking time of logger
The logger currently blocks in open for finding SOH within the
circular buffer. This blocking is infinite. However, the SOH
is written in buffer for sure when adsp boots.

Hence, added a check to see if in the past if adsp has been
started and then search for SOH else return an error.

Also, the blocking takes place in the read path where the logger
waits in the position where it gets EOT and loops back. This is
not desirable due to recent changes in debugfs and hence now the
read path returns back with an ASCII value of BELL which will not
effect `cat` from writing anything on the console.

Bug 1997011

Change-Id: Ia6e990bcdc1af5c328c24f350af941126beda07a
Signed-off-by: Ajay Nandakumar <anandakumarm@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1662918
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Sachin Nikam <snikam@nvidia.com>
Reviewed-by: Timo Alho <talho@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2023-06-20 15:13:15 +00:00