Commit Graph

315 Commits

Author SHA1 Message Date
Gerrit Code Review
0260612296 Merge "drm: Integrate drm drivers from kernel/nvidia to kernel/nvidia-oot" into dev-main 2023-04-05 06:05:18 -07:00
Laxman Dewangan
7f8cad749d gpu: nvgpu: Remove dummy Makefile of nvgpu
nvgpu is getting build from kernel/nvgpu and it is
not required to copy in nvidia-oot.

Remove the dummy makefile which was added as placeholder
for the nvgpu makefile.

Bug 4038415

Change-Id: I3fa6945a94c0f2233b55ec19d21ec4a92f715fde
Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2882139
Reviewed-by: Jonathan Hunter <jonathanh@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
2023-04-04 21:58:16 -07:00
Gerrit Code Review
197d2ed9eb Merge "host1x-nvhost: Integrate host1x-nvhost drivers from kernel/nvidia" into dev-main 2023-04-04 21:56:39 -07:00
Mikko Perttunen
10c73be4bf gpu: host1x-nvhost: Fix invalid NULL check
NULL check in is_valid_pt_ext was negated, making this function
useless. Fix the check.

Signed-off-by: Mikko Perttunen <mperttunen@nvidia.com>
Change-Id: I8764bcfceb457bf26ef79ebffdf17526d4174849
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2861958
Reviewed-by: svcacv <svcacv@nvidia.com>
Reviewed-by: Jonathan Hunter <jonathanh@nvidia.com>
Reviewed-by: Santosh BS <santoshb@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
2023-04-03 14:06:51 +00:00
Arvind M
8942623b15 gpu: host1x-nvhost: avoid setting flcn irq at boot
[1] The DLA firmware configures the DEST and MASK registers during
    the initialization.
[2] In OOT, the DLA KMD is accidentally setting the interrupts. This
    will result in enabling additional interrupts that the firmware
    does not handle (like NVDLA_GENERIC_INTR_FAULT_CRITICAL).
[3] This commit fixes the issue by avoiding the interrupt settings
    at the DLA KMD.

Bug 3960841

Change-Id: Ied77ac7564ae3b3202b9cceaf08ad3c7da9f947c
Signed-off-by: Arvind M <am@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2861253
Reviewed-by: Mikko Perttunen <mperttunen@nvidia.com>
Reviewed-by: Amit Sharma (SW-TEGRA) <amisharma@nvidia.com>
Reviewed-by: Jonathan Hunter <jonathanh@nvidia.com>
Reviewed-by: svcacv <svcacv@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
2023-04-03 14:06:51 +00:00
Arvind M
bc86b17fa2 host1x: kmd: enable irq on poweron
[1] Since the irq is not enabled during the power-on, the firmware
    is not communicable state upon module reset.
[2] This commit fixes the issue by enabling irq on power-on.

Bug 3979666
Bug 3975703

Change-Id: I746a9236b390ab2d429df1f4a3f6243745147b65
Signed-off-by: Arvind M <am@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2858111
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: Ayush Kumar <ayushk@nvidia.com>
Reviewed-by: Jonathan Hunter <jonathanh@nvidia.com>
Reviewed-by: Mikko Perttunen <mperttunen@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
Tested-by: Amit Sharma (SW-TEGRA) <amisharma@nvidia.com>
2023-04-03 14:06:51 +00:00
Sanif Veeras
b394e81a9e video:tegra:host: add gpu specific syncpt pool
- Support allocation from the GPU specific syncpoint pool
  after reading from the Device Tree
- Expose an interface for the NvGPU driver to allocate
  the syncpoint from the GPU pool

Jira HOSTX-4515

Change-Id: Ie5cc9ec22c039b958b0c0a1750f959ebbf6c6bee
Signed-off-by: Sanif Veeras <sveeras@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2820453
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
Reviewed-by: svc_kernel_abi <svc_kernel_abi@nvidia.com>
Reviewed-by: Arto Merilainen <amerilainen@nvidia.com>
Reviewed-by: Raghavendra Vishnu Kumar <rvk@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
2023-04-03 14:06:51 +00:00
Mahesh Kumar
88028eda4b gpu: host1x-nvhost: Align syncpt interface APIs
The syncpt interface APIs in the host1x-nvhost driver slightly differ
from those in the legacy nvhost driver because instead of passing the
platform device structure for the host1x device, the platform device
structure for the host1x client device is passed.

By aligning the APIs so that we pass the platform device structure for
the host1x in all implementations, we can simplify the PVA driver and
directly use the APIs in the NVIDIA display driver.

The NVIDIA display driver requires some additional syncpt interface APIs
and so implement these as well.

Bug 3713048

Change-Id: I507e6fd066e6e22c0c47c20ba0dd3be5fa033c59
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2813827
Reviewed-by: Bibek Basu <bbasu@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>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
2023-04-03 14:06:51 +00:00
Jon Hunter
7d40c3953e gpu: host1x-nvhost: Fix mapping of syncpt shim
With Linux v6.1, if CONFIG_PCI_P2PDMA is enabled, then mapping the
syncpt shim causes a kernel paging request fault. The fault occurs when
dma_map_sg_attrs() is called in by nvhost_syncpt_unit_interface_init(),
which is attempting to map the syncpt shim MMIO space.

The function dma_map_sg_attrs() calls iomm_dma_map_sg() and since
upstream Linux commit 30280eee2db1 ("iommu/dma: support PCI P2PDMA pages
in dma-iommu map_sg") was added this now calls is_pci_p2pdma_page(). The
function is_pci_p2pdma_page() requires that there is a 'struct page'
associated with the sg, but this is not the case and so deferencing the
'struct page' pointer returned by sg_page() results in a paging fault.

Using dma_map_sg_attrs() to map MMIO that is not associated with valid
page structures is not guaranteed to work. Therefore, fix this by using
dma_map_resource() to map the syncpt shim instead.

Bug 3871422

Change-Id: I2b08a3b78be0850bff44e62bfc93c8d095eb82a2
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2818417
(cherry picked from commit 97f1282f2959c208effebf93cc5061d6e7fa6c55)
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2819086
Reviewed-by: Mikko Perttunen <mperttunen@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
2023-04-03 14:06:51 +00:00
Jon Hunter
6cd2f00c46 nvhost: Add clean up function for syncpt interface
Drivers, such as the PVA and DLA driver, that call
nvhost_syncpt_unit_interface_init() during probe are missing a call to
clean-up the DMA mappings this function may create if the driver probe
fails or if the driver is removed. The function
nvhost_syncpt_unit_interface_init() may make a call to
dma_map_sg_attrs() and we need to ensure that dma_unmap_sg_attrs() is
called if the probe of the driver fails or if the driver is unloaded.
Add a new function, nvhost_syncpt_unit_interface_deinit(), that calls
dma_unmap_sg_attrs() if needed for drivers to call.

Bug 3800349

Change-Id: I62a4e19cd42878dac54fa623509440596ffdf17f
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2801280
(cherry picked from commit cee12fb989186611aa9deb5ada45831ab5f783aa)
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2801934
Reviewed-by: svcacv <svcacv@nvidia.com>
Reviewed-by: svc_kernel_abi <svc_kernel_abi@nvidia.com>
Reviewed-by: Mikko Perttunen <mperttunen@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
2023-04-03 14:06:51 +00:00
Mikko Perttunen
968b6f758f gpu: host1x-nvhost: Adapt for change in host1x_fence_create
Add 'true' parameter to enable internal timeout since there is no
external cancellation mechanism.

Also change kfree to kfree_rcu to ensure workqueue is not freed
during callback.

Signed-off-by: Mikko Perttunen <mperttunen@nvidia.com>
Change-Id: Ib0ef9a211bafbdd911dc90175a18680880e3e2f8
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2786638
Reviewed-by: Jonathan Hunter <jonathanh@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
2023-04-03 14:06:51 +00:00
Jon Hunter
9d0dda14ae gpu: host1x-nvhost: Update include path
When building the host1x-nvhost driver as an external module, the driver
source is now copied into a common location with all the other external
modules. Therefore, we can now use the 'srctree.nvidia' path for finding
the necessary header files for Host1x. Update the include search paths
to use 'srctree.nvidia' when building the driver.

Bug 3817518

Change-Id: I443dd4cb6d01c4e9be8f3c02550b1050d0bcfd28
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2785956
Reviewed-by: svcacv <svcacv@nvidia.com>
Reviewed-by: Mikko Perttunen <mperttunen@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
2023-04-03 14:06:51 +00:00
Jon Hunter
2e94a90e1d gpu: host1x-nvhost: Update syncpt helper functions
- add get aperture API
- add get syncpt offset api

Bug 3768126

Change-Id: I95ae6a149e8a362317f4f1c89e7a1eac3c596fe4
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2782259
Tested-by: Omar Nemri <onemri@nvidia.com>
Reviewed-by: Omar Nemri <onemri@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
2023-04-03 14:06:51 +00:00
Jon Hunter
b5c5a485da gpu: host1x-nvhost: Add support for Tegra234
Add support for Tegra234 in the host1x-nvhost driver.

Bug 3724727

Change-Id: I3e42d066ce22a461d71f26c120f08aed96f30430
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2759200
Reviewed-by: svcacv <svcacv@nvidia.com>
Reviewed-by: svc_kernel_abi <svc_kernel_abi@nvidia.com>
Reviewed-by: Mikko Perttunen <mperttunen@nvidia.com>
2023-04-03 14:06:51 +00:00
Nan Wang
96d0bbd387 pva: support both upstream and downstream kernel
1. Replace nvhost print functions with PVA driver's private
implementation with similar functionalities.

2. Change syncpoint from host managed to client managed so that
syncpoint max value is tracked inside PVA driver. This change is needed
because upstream host1x driver doesn't allow decrement of max value.

3. Various minor changes for adapting to upstream kernel APIs.

Bug 3662478

Change-Id: I16eff6c06c51afe0f274598e1273404924d18684
Signed-off-by: Nan Wang <nanwa@nvidia.com>
Signed-off-by: Abhinaya Agrawal <abhinayaa@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2710684
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
2023-04-03 14:06:51 +00:00
Abhinaya Agrawal
c87eb8b8d9 drivers: Fix host1x and nvhost debugfs cleanup
Both host1x and nvhost expose APIs that deinitialize the debugfs
and remove debugfs files/directories that were created. At present,
debugfs_remove() is inovked to do this. However,
debugfs_remove_recursive() should instead be used to ensure that
all files within a debugfs are recursively removed before the
directory is removed.

Bug 3662478

Change-Id: Idb7d1458c02f57f6d656a7bfe1df3adf5e0497aa
Signed-off-by: Abhinaya Agrawal <abhinayaa@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2714042
Reviewed-by: svcacv <svcacv@nvidia.com>
Reviewed-by: svc_kernel_abi <svc_kernel_abi@nvidia.com>
Reviewed-by: Omar Nemri <onemri@nvidia.com>
GVS: Gerrit_Virtual_Submit
2023-04-03 14:06:51 +00:00
Jon Hunter
58159f3b83 gpu: host1x-nvhost: Move falcon initialisation
Some host1x clients, such as PVA, do not have a falcon microprocessor
and currently the host1x-nvhost shim driver assumes that all clients do.
Fix this by moving the falcon initialisation code from the
nvhost_module_init() function and into the
nvhost_flcn_finalize_poweron() function. This aligns with the
implementation in the downstream nvhost driver.

JIRA LS-493

Change-Id: Ic94c3489cefa6fd256f111d8e6c7afb539b5bc8a
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2710548
Reviewed-by: Nan Wang <nanwa@nvidia.com>
Reviewed-by: svcacv <svcacv@nvidia.com>
Reviewed-by: Mikko Perttunen <mperttunen@nvidia.com>
GVS: Gerrit_Virtual_Submit
2023-04-03 14:06:51 +00:00
Jon Hunter
ad8058fce9 gpu: host1x-nvhost: Fix client unloading
After unloading the NVDLA driver and then reloading the NVDLA, the
kernel is crashing. The host1x-nvhost driver is missing a call to
class_destroy() in nvhost_client_device_release() which gets called when
removing the DLA driver and this is preventing the DLA driver from
creating the class again when reloading. The crash then occurs because
when the driver is reloaded, creating the class for the DLA driver
fails and then the host1x-nvhost driver incorrectly calls
device_destroy() even though the device has not been created yet. Fix
this by ensuring the class_destroy() is called by
nvhost_client_device_release() and in the necessary error paths and then
remove the call to device_destroy().

Finally, replace request_irq() with devm_request_irq() to ensure that
the interrupts are also released as necessary on removal.

Bug 3641820

Change-Id: Ia328bf63d528e8c31bff1d7b3ac0d5dddc22f1f5
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2710546
Reviewed-by: svcacv <svcacv@nvidia.com>
Reviewed-by: Mikko Perttunen <mperttunen@nvidia.com>
GVS: Gerrit_Virtual_Submit
2023-04-03 14:06:51 +00:00
Jon Hunter
c103925414 gpu: host1x-nvhost: Fix casting and functions declarations
Sparse reports the following warnings for the host1x-nvhost driver ...

 drivers/gpu/host1x-nvhost/falcon.c:65:27: warning: cast to restricted __le32
 drivers/gpu/host1x-nvhost/nvhost.c:205:22: warning: symbol
	'nvhost_syncpt_get_by_id' was not declared. Should it be static?
 drivers/gpu/host1x-nvhost/nvhost.c:768:5: warning: symbol
 	'nvhost_module_runtime_resume' was not declared. Should it be static?
 drivers/gpu/host1x-nvhost/nvhost.c:796:5: warning: symbol
 	'nvhost_module_runtime_suspend' was not declared. Should it be static?

Fix the above by correcting the cast in falcon_copy_firmware_image(), remove
the function nvhost_syncpt_get_by_id() because it is not used, and make the
nvhost_module_runtime_resume/suspend functions static.

JIRA LS-410

Change-Id: I2c923fccd0b6e53d17198617b90905c6cd06eb5c
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2670180
Reviewed-by: Sachin Nikam <snikam@nvidia.com>
Reviewed-by: Mikko Perttunen <mperttunen@nvidia.com>
GVS: Gerrit_Virtual_Submit
2023-04-03 14:06:51 +00:00
Jon Hunter
9ecd6942b9 gpu: host1x-nvhost: Fix build for Linux v5.10
When compiling the host1x-nvhost driver for Linux v5.10 it is currently
failing and the following errors are seen ...

 host1x-nvhost/nvhost.c: In function ‘nvhost_intr_do_work’:
 nvhost.c:554:2: error: implicit declaration of function ‘kfree’
 [-Werror=implicit-function-declaration]
  kfree(host1x_cb);
    ^~~~~
 host1x-nvhost/nvhost.c: In function ‘nvhost_intr_register_notifier’:
 nvhost.c:579:7: error: implicit declaration of function ‘kzalloc’
 [-Werror=implicit-function-declaration]
      cb = kzalloc(sizeof(*cb), GFP_KERNEL);
             ^~~~~~~

Fix this by including slab.h.

JIRA LS-410

Change-Id: I8a56d33933d3e57c04b011e2c6da03d5f2bbc707
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2667882
Reviewed-by: svcacv <svcacv@nvidia.com>
Reviewed-by: Sachin Nikam <snikam@nvidia.com>
Reviewed-by: Mikko Perttunen <mperttunen@nvidia.com>
GVS: Gerrit_Virtual_Submit
2023-04-03 14:06:51 +00:00
Jon Hunter
9f0425f9c1 gpu: host1x-nvhost: Fix clock rate setup
The host1x-nvhost driver by default configures the clock rates for
the host1x client devices to the maximum supported rate because
there is runtime clock scaling support yet. However, currently the
host1x-nvhost driver is only setting the rate for the client's first
clock and not the others. Fix this by correcting the index used when
iterating through the list of clocks.

JIRA LS-410

Change-Id: If410ee25548c0dddecc5b0de9d8b6f4f687fd73c
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2657897
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Reviewed-by: svcacv <svcacv@nvidia.com>
Reviewed-by: Mikko Perttunen <mperttunen@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
GVS: Gerrit_Virtual_Submit
2023-04-03 14:06:51 +00:00
Jon Hunter
7343e4379b gpu: host1x-nvhost: Add host1x-nvhost driver
Add a new host1x-nvhost driver that provides an nvhost interface for
the upstream Linux host1x driver so that downstream drivers that use
this interface can be supported on upstream.

Note that some of the nvhost function prototypes are moved from their
default header file to the include/linux/nvhost.h header file so
simplify building with upstream and downstream kernels.

JIRA LS-410

Change-Id: Icdbb34e879dcd91f6e3dd093b7fb400d1be4d561
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2653097
Reviewed-by: Mikko Perttunen <mperttunen@nvidia.com>
Reviewed-by: svc_kernel_abi <svc_kernel_abi@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
GVS: Gerrit_Virtual_Submit
2023-04-03 14:06:51 +00:00
Laxman Dewangan
a9a13406dd host1x-nvhost: Remove Makefile to prepare integration
The host1x-nvhost drivers are available in kernel/nvidia
and to integrate the drivers to the kernel/nvidia-oot,
remove the dummy Makefile.

Bug 4038415

Change-Id: I2179a9e4cc096bf9b8534b3415b595d185785e06
Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
2023-04-03 14:06:21 +00:00
Jon Hunter
ee3c149b7f gpu: host1x: Fix build for Linux v6.3
Upstream Linux commit ("1369459b2e21 iommu: Add a gfp parameter to
iommu_map()") adds a new parameter to the iommu_map function and this
breaks building the host1x driver with Linux v6.3.

Upstream Linux commit 2a81ada32f0e ("driver core: make struct
bus_type.uevent() take a const *") updates the uevent function pointer
type to make the device structure const which also breaks building the
host1x driver with Linux v6.3.

Address both of these issues to fix building the host1x driver with
Linux v6.3.

Bug 4014315

Change-Id: Ibd27f5e8442cc6970bcaac0dcfb9fc262860aee9
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2867136
Reviewed-by: Mikko Perttunen <mperttunen@nvidia.com>
Reviewed-by: svc_kernel_abi <svc_kernel_abi@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
2023-04-03 12:36:26 +00:00
Mikko Perttunen
41a9f72f78 gpu: host1x: Add API for reading actmon count
Add API for reading the activity monitor average count for VIC,
NVENC, and NVDEC. There is currently no support for initializing
actmon, so this relies on someone else on a virtualized system
having initialized it (and mapped the actmon region read-only).

Bug 3973633

Signed-off-by: Mikko Perttunen <mperttunen@nvidia.com>
Change-Id: Ia1bfec6a090d4effb288b17cbac4d42bf5d0b4e5
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2864719
Reviewed-by: svc_kernel_abi <svc_kernel_abi@nvidia.com>
Reviewed-by: Jonathan Hunter <jonathanh@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
2023-04-03 12:36:26 +00:00
Mikko Perttunen
4207a59049 gpu: host1x: Don't rely on dma_fence_wait_timeout return value
dma_fence_wait_timeout (along with a host of other jiffies-based
timeouting functions) returns zero both in case of timeout and when
the wait completes during the last jiffy before timeout. As such,
we can't rely on it to distinguish between success and timeout.

To prevent confusing callers by returning -EAGAIN before the timeout
period has elapsed, check if the fence got signaled again after
the wait.

Bug 3955201

Signed-off-by: Mikko Perttunen <mperttunen@nvidia.com>
Change-Id: Ib90cbd3d78bac773a724a523925ae5d1b70107c8
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2857405
Reviewed-by: Jonathan Hunter <jonathanh@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
2023-04-03 12:36:26 +00:00
Arnd Bergmann
3d26b00c17 UPSTREAM: gpu: host1x: Fix uninitialized variable use
The error handling for platform_get_irq() failing no longer works after
a recent change, clang now points this out with a warning:

drivers/gpu/host1x/dev.c:520:6: error: variable 'syncpt_irq' is uninitialized when used here [-Werror,-Wuninitialized]
        if (syncpt_irq < 0)
            ^~~~~~~~~~

Fix this by removing the variable and checking the correct error status.

Fixes: 625d4ffb438c ("gpu: host1x: Rewrite syncpoint interrupt handling")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Nathan Chancellor <nathan@kernel.org>
Reviewed-by: Mikko Perttunen <mperttunen@nvidia.com>
Reported-by: "kernelci.org bot" <bot@kernelci.org>
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Thierry Reding <treding@nvidia.com>
Signed-off-by: Mikko Perttunen <mperttunen@nvidia.com>
Change-Id: I780c935101b8c65070eeba3552f96a1bfb109592
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2853776
Reviewed-by: Santosh BS <santoshb@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
2023-04-03 12:36:26 +00:00
Mikko Perttunen
ff2271fec3 gpu: host1x: Assign syncpoints to channels on virtualized systems
The code to write the syncpoint channel assignment register
incorrectly skips the write if hypervisor registers are not available.

The register, however, is within the guest aperture so remove the
check and assign syncpoints properly on virtualized systems.

Signed-off-by: Mikko Perttunen <mperttunen@nvidia.com>
Change-Id: I9a0c8ed42a56c445d392e1ed2b670091be6654fb
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2833919
Reviewed-by: svc_kernel_abi <svc_kernel_abi@nvidia.com>
Reviewed-by: Santosh BS <santoshb@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
2023-04-03 12:36:26 +00:00
Mikko Perttunen
684ae650bf gpu: host1x: Fix mask for syncpoint increment register
On Tegra186+, the syncpoint ID has 10 bits of space. To allow
using more than 256 syncpoints, fix the mask.

Signed-off-by: Mikko Perttunen <mperttunen@nvidia.com>
Change-Id: I30a220432e6299a91ad667ad4289c444293c1e63
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2833918
Reviewed-by: svc_kernel_abi <svc_kernel_abi@nvidia.com>
Reviewed-by: Santosh BS <santoshb@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
2023-04-03 12:36:26 +00:00
Mikko Perttunen
de0a5c2c11 gpu: host1x: Support for syncpoint pools
Add support for syncpoint pools. These are configuration-dependent
subsets of syncpoints that can only be allocated by specifying
an allocation specifically from that pool.

In this patch, we add support for the GPU pool. On certain systems,
the GPU is for safety purposes limited to accessing a specific set
of syncpoints. Therefore, syncpoints allocated for GPU use need to
come from this pool.

Signed-off-by: Mikko Perttunen <mperttunen@nvidia.com>
Change-Id: I385b8bdfdac8573b26f0b1a0feaf05de071148a1
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2826198
Reviewed-by: svc_kernel_abi <svc_kernel_abi@nvidia.com>
Reviewed-by: Arto Merilainen <amerilainen@nvidia.com>
Reviewed-by: Sanif Veeras <sveeras@nvidia.com>
Reviewed-by: Raghavendra Vishnu Kumar <rvk@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
Tested-by: Sanif Veeras <sveeras@nvidia.com>
2023-04-03 12:36:26 +00:00
Mikko Perttunen
e0a90be04b gpu: host1x: Support for running as guest
Add support for running as a guest system under a hypervisor, using
Host1x HW's virtualization capabilities.

In effect this involves not touching apertures other than the 'vm'
aperture, and channels and syncpoints other than those that are
assigned to the VM.

Signed-off-by: Mikko Perttunen <mperttunen@nvidia.com>
Change-Id: Ideec5b0b9a692aa3ee6b4a0240c5755c983cb7bd
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2811837
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
2023-04-03 12:36:26 +00:00
Mikko Perttunen
fb56e97a0f gpu: host1x: Select context device based on attached IOMMU
On Tegra234, engines that are programmed through Host1x channels can
be attached to either the NISO0 or NISO1 SMMU. Because of that, when
selecting a context device to use with an engine, we need to select
one that is also attached to the same SMMU.

Add a parameter to host1x_memory_context_alloc to specify which device
we are allocating a context for, and use it to pick an appropriate
context device.

Signed-off-by: Mikko Perttunen <mperttunen@nvidia.com>
Signed-off-by: Thierry Reding <treding@nvidia.com>
Change-Id: I32af312c85164b72c14409d816d3b50ad5c7bfe5
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2811836
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
2023-04-03 12:36:25 +00:00
Mikko Perttunen
283b2ed68b gpu: host1x: Add stream ID protection table entries for camera engines
Add entries for camera engines (VI,VI2,VI_THI,VI2_THI,ISP_THI) in
the stream ID protection table.

Signed-off-by: Mikko Perttunen <mperttunen@nvidia.com>
Change-Id: If65fbbd63f2b4eb2bf56b3a696e570f87c010d87
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2807581
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
2023-04-03 12:36:25 +00:00
Mikko Perttunen
a351c7681e gpu: host1x: Timestamp syncpoint wait completions
Collect CLOCK_MONOTONIC timestamps in the interrupt handler when
a syncpoint wait completes, and report it back in dma_fences and
syncpoint wait UAPI.

Signed-off-by: Mikko Perttunen <mperttunen@nvidia.com>
Change-Id: I9f783833698df7d96c99c9ffef3205aa82adceb5
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2801167
Reviewed-by: Jonathan Hunter <jonathanh@nvidia.com>
Reviewed-by: svc_kernel_abi <svc_kernel_abi@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
2023-04-03 12:36:25 +00:00
Nikesh Oswal
f6865a3c2d gpu: host1x: allow tsec streamid reg access via MMIO
Set Host1X registers to allow both the TSEC StreamID
registers to be programmed via MMIO from the TSEC driver

Bug 3817626

Change-Id: Ic344ecbca557d4c058accc8db1a9f874945e8280
Signed-off-by: Nikesh Oswal <noswal@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2801852
Reviewed-by: Mikko Perttunen <mperttunen@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
2023-04-03 12:36:25 +00:00
Mikko Perttunen
25f41bc212 gpu: host1x: External timeout/cancellation for fences
Currently all fences have a 30 second timeout to ensure they are
cleaned up if the fence never completes otherwise. However, this
one size fits all solution doesn't actually fit in every case,
such as syncpoint waiting where we want to be able to have timeouts
longer than 30 seconds. As such, we want to be able to give control
over fence cancellation to the caller (and maybe eventually get rid
of the internal timeout altogether).

Here we add this cancellation mechanism by essentially adding a
function for entering the timeout path by function call, and changing
the syncpoint wait function to use it.

Signed-off-by: Mikko Perttunen <mperttunen@nvidia.com>
Change-Id: I4600544afe21efdd3f7d06362bd124130ddec3db
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2786637
Reviewed-by: Jonathan Hunter <jonathanh@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
2023-04-03 12:36:25 +00:00
Mikko Perttunen
33a40367c0 gpu: host1x: Rewrite syncpoint interrupt handling
Move from the old, complex intr handling code to a new implementation
based on dma_fences. While there is a fair bit of churn to get there,
the new implementation is much simpler and likely faster as well due
to allowing signaling directly from interrupt context.

Signed-off-by: Mikko Perttunen <mperttunen@nvidia.com>
Change-Id: I81c47fa1946679813f90e3fd8e1d1e9d6342143e
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2786635
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
2023-04-03 12:36:25 +00:00
Mikko Perttunen
303267d828 gpu: host1x: Implement job tracking using DMA fences
In anticipation of removal of the intr API, implement job tracking
using DMA fences instead. The main two things about this are
making cdma_update schedule the work since fence completion can
now be called from interrupt context, and some complication in
ensuring the callback is not running when we free the fence.

Signed-off-by: Mikko Perttunen <mperttunen@nvidia.com>
Change-Id: I25f7f5a6cad24a00563eed79e0e17b1df1eadcdc
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2786636
Reviewed-by: Jonathan Hunter <jonathanh@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
2023-04-03 12:36:25 +00:00
Mikko Perttunen
242251a0e1 gpu: host1x: Implement syncpoint wait using DMA fences
In anticipation of removal of the intr API, move host1x_syncpt_wait
to use DMA fences instead. As of this patch, this means that waits
have a 30 second maximum timeout because of the implicit timeout
we have with fences, but that will be lifted in a follow-up patch.

Signed-off-by: Mikko Perttunen <mperttunen@nvidia.com>
Change-Id: I82a262b73861b35c4031983f4134d4b4006e3b16
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2786634
Reviewed-by: Jonathan Hunter <jonathanh@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
2023-04-03 12:36:25 +00:00
Akhil R
128385051a gpu: host1x: Add SE SID entries for Tegra234.
Add Security Engine Stream ID  entries in host1x SID table for
Tegra234.

Bug 3583641

Signed-off-by: Akhil R <akhilrajeev@nvidia.com>
Change-Id: I5d96478aad8d24208bad92e61942a57c0fd5df1a
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2782822
Reviewed-by: svcacv <svcacv@nvidia.com>
Reviewed-by: Mikko Perttunen <mperttunen@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
2023-04-03 12:36:25 +00:00
Mikko Perttunen
f374e1804e drm/tegra: Add OFA support
Add support for the optical flow accelerator. Implementation is the
same as for other Falcons except that we omit some legacy things
since the engine only exists from T234 onwards, and the addition
of having to initialize the OFA's safety RAM before boot.

Signed-off-by: Mikko Perttunen <mperttunen@nvidia.com>
Change-Id: I9612e82a116cc76be492a0c533afce67c42f6a2c
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2784964
Reviewed-by: Jonathan Hunter <jonathanh@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
2023-04-03 12:36:25 +00:00
Mikko Perttunen
a31d614845 gpu: host1x: Add mlock release code for NVENC/NVJPG
Add definitions to allow mlock releasing on recovery for NVENC/NVJPG
on Tegra234.

Bug 3778105

Signed-off-by: Mikko Perttunen <mperttunen@nvidia.com>
Change-Id: Iea33063b0d71add9fe816d93c96401087a12a657
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2772958
(cherry picked from commit e5f17c5842af24bde32e74d6eb2a61b0d90cae3d)
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2772920
Reviewed-by: Jonathan Hunter <jonathanh@nvidia.com>
Tested-by: Jonathan Hunter <jonathanh@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
2023-04-03 12:36:25 +00:00
Mikko Perttunen
5de571fe8d drm/tegra: Add NVENC/NVJPG support on Tegra234
Add NVENC/NVJPG support on Tegra234. These work similarly to the
ones on Tegra194, so no big changes.

Bug 3778105

Signed-off-by: Mikko Perttunen <mperttunen@nvidia.com>
Change-Id: I4a4b12d5625f927c69a6dc1c6b6bade1bca7b171
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2771770
(cherry picked from commit ee6576a1493dae1ddc5c8dc3b415d0987f670390)
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2759062
Reviewed-by: Jonathan Hunter <jonathanh@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
Tested-by: Jonathan Hunter <jonathanh@nvidia.com>
2023-04-03 12:36:25 +00:00
Mikko Perttunen
9cfe33dc68 gpu: host1x: Add stream ID register data for NVDEC on Tegra234
Add entries for NVDEC to the Tegra234 SID table.

Bug 3778105

Signed-off-by: Mikko Perttunen <mperttunen@nvidia.com>
Change-Id: Iff6c33795b74faf5e0aea72751ad6c4b43cf6bb2
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2771764
(cherry picked from commit 3e501a18ff2392292d19bc513db6f19d31f38227)
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2768895
Reviewed-by: Jonathan Hunter <jonathanh@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
Tested-by: Jonathan Hunter <jonathanh@nvidia.com>
2023-04-03 12:36:25 +00:00
Jon Hunter
e1c4c53a86 gpu: host1x: Update to Linux v6.0-rc5
Update the host1x driver to align with the latest upstream driver from
Linux v6.0-rc5. Please note that the context bus support is not
included, because this needs to be built into the kernel.

Bug 3767126

Change-Id: Ib962db616e9c1d72e46adf6c678ec26089e4b610
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2776689
Reviewed-by: Mikko Perttunen <mperttunen@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
2023-04-03 12:36:25 +00:00
Brad Griffis
ea0f4f6a26 gpu: host1x: ADD SID information for Tegra234 DLA
Add the SMMU SID information for the Tegra234 DLA devices to the
upstream host1x driver to ensure the SMMU is configured correctly.

Bug 3724727

Change-Id: I01edf2bc36f2b8a4b83077fc71f42463f9958a3d
Signed-off-by: Brad Griffis <bgriffis@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2754962
Reviewed-by: Mikko Perttunen <mperttunen@nvidia.com>
Reviewed-by: Jonathan Hunter <jonathanh@nvidia.com>
Tested-by: Jonathan Hunter <jonathanh@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
2023-04-03 12:36:25 +00:00
Mikko Perttunen
cc7156e561 gpu: host1x: Generalize host1x_cdma_push_wide
host1x_cdma_push_wide had the assumptions that the last parameter word
was a NOP opcode, and that NOP opcodes could be used in all situations.

Neither are true with the new job opcode sequence, so adjust the
function to not have these assumptions, and instead place an early
RESTART opcode when necessary to jump back to the beginning of the
pushbuffer.

Bug 3724727

Signed-off-by: Mikko Perttunen <mperttunen@nvidia.com>
Change-Id: I88074e838e4f1471471f0848aca9d8d73c7b5f8c
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2745959
Reviewed-by: svc_kernel_abi <svc_kernel_abi@nvidia.com>
Reviewed-by: Brad Griffis <bgriffis@nvidia.com>
Reviewed-by: Jonathan Hunter <jonathanh@nvidia.com>
Reviewed-by: Bibek Basu <bbasu@nvidia.com>
GVS: Gerrit_Virtual_Submit
Tested-by: Brad Griffis <bgriffis@nvidia.com>
2023-04-03 12:36:25 +00:00
Mikko Perttunen
7ef97475c0 gpu: host1x: Initialize syncval in channel_submit
During the refactoring of channel_submit, assignment of syncval
was moved but it is also used in channel_submit. Add this assignment
back to channel_submit as well.

Bug 3724727

Signed-off-by: Mikko Perttunen <mperttunen@nvidia.com>
Change-Id: I11acff0a5d28ddaf35648cdb3be0e638b996d5c1
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2745958
Reviewed-by: svc_kernel_abi <svc_kernel_abi@nvidia.com>
Reviewed-by: Brad Griffis <bgriffis@nvidia.com>
Reviewed-by: Jonathan Hunter <jonathanh@nvidia.com>
Reviewed-by: Bibek Basu <bbasu@nvidia.com>
GVS: Gerrit_Virtual_Submit
Tested-by: Brad Griffis <bgriffis@nvidia.com>
2023-04-03 12:36:25 +00:00
Mikko Perttunen
da180e1e8b gpu: host1x: Use RESTART_W to skip timed out jobs on Tegra186+
When MLOCK enforcement is enabled, the 0-word write currently done
is rejected by the hardware outside of an MLOCK region. As such,
on these chips, which also have the newer, more convenient RESTART_W
opcode, use that instead to skip over the timed out job.

Bug 3724727

Signed-off-by: Mikko Perttunen <mperttunen@nvidia.com>
Change-Id: I9e22eb7ccd17127ca517a034f5dbd32326412f9d
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2745957
Reviewed-by: svc_kernel_abi <svc_kernel_abi@nvidia.com>
Reviewed-by: Brad Griffis <bgriffis@nvidia.com>
Reviewed-by: Jonathan Hunter <jonathanh@nvidia.com>
Reviewed-by: Bibek Basu <bbasu@nvidia.com>
GVS: Gerrit_Virtual_Submit
Tested-by: Brad Griffis <bgriffis@nvidia.com>
2023-04-03 12:36:25 +00:00
Mikko Perttunen
951a3d1efa gpu: host1x: Add MLOCK release code on Tegra234
With the full-featured opcode sequence using MLOCKs, we need to also
unlock those MLOCKs in the event of a timeout. However, it turns out
that on Tegra186/Tegra194, by default, we don't need to do this;
furthermore, on Tegra234 it is much simpler to do; so only implement
this on Tegra234 for the time being.

Bug 3724727

Signed-off-by: Mikko Perttunen <mperttunen@nvidia.com>
Change-Id: Icc15ae705844cd26ae3f1d1146ff20f1d9b7a14d
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2745956
Reviewed-by: svc_kernel_abi <svc_kernel_abi@nvidia.com>
Reviewed-by: Brad Griffis <bgriffis@nvidia.com>
Reviewed-by: Jonathan Hunter <jonathanh@nvidia.com>
Reviewed-by: Bibek Basu <bbasu@nvidia.com>
GVS: Gerrit_Virtual_Submit
Tested-by: Brad Griffis <bgriffis@nvidia.com>
2023-04-03 12:36:25 +00:00