Commit Graph

294 Commits

Author SHA1 Message Date
Thierry Reding
d802ae96a7 drm/tegra: Implement correct DMA-BUF semantics
DMA-BUF requires that each device that accesses a DMA-BUF attaches to it
separately. To do so the host1x_bo_pin() and host1x_bo_unpin() functions
need to be reimplemented so that they can return a mapping, which either
represents an attachment or a map of the driver's own GEM object.

Bug 200768479

Signed-off-by: Thierry Reding <treding@nvidia.com>
Change-Id: Ia380b7dcc371ce47f5f35d44a60fbd6b4ab9d636
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2596398
(cherry picked from commit 28960586000fca025689edfd45645ab28e497bca)
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2620137
Tested-by: Jonathan Hunter <jonathanh@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Reviewed-by: Jonathan Hunter <jonathanh@nvidia.com>
Reviewed-by: svc_kernel_abi <svc_kernel_abi@nvidia.com>
Reviewed-by: Mikko Perttunen <mperttunen@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
GVS: Gerrit_Virtual_Submit
2023-04-03 12:36:25 +00:00
Thierry Reding
d42946f160 gpu: host1x: Plug potential memory leak
The memory allocated for a DMA fence could be leaked if the code failed
to allocate the waiter object. Make sure to release the fence allocation
on failure.

Change-Id: Ie5608246225f17883d005b7975bed1ca4742b321
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Thierry Reding <treding@nvidia.com>
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2604935
(cherry picked from commit 3142088147c0a8b69cd692405c98a9cdb96b6006)
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2605432
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Reviewed-by: svc_kernel_abi <svc_kernel_abi@nvidia.com>
Reviewed-by: Mikko Perttunen <mperttunen@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
GVS: Gerrit_Virtual_Submit
2023-04-03 12:36:25 +00:00
Thierry Reding
f6e4773a0d UPSTREAM: gpu:host1x: Split up client initalization and registration
In some cases we may need to initialize the host1x client first before
registering it. This commit adds a new helper that will do nothing but
the initialization of the data structure.

At the same time, the initialization is removed from the registration
function. Note, however, that for simplicity we explicitly initialize
the client when the host1x_client_register() function is called, as
opposed to the low-level __host1x_client_register() function. This
allows existing callers to remain unchanged.

Change-Id: I504462a1749d8f9602f6b4075f1aec56eefb14e5
Signed-off-by: Thierry Reding <treding@nvidia.com>
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2545957
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Reviewed-by: svc_kernel_abi <svc_kernel_abi@nvidia.com>
Reviewed-by: Mikko Perttunen <mperttunen@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
GVS: Gerrit_Virtual_Submit
2023-04-03 12:36:25 +00:00
Thierry Reding
f6a7adab82 UPSTREAM: gpu:host1x: Add early init and late exit callbacks
These callbacks can be used by client drivers to run code during early
init and during late exit. Early init callbacks are run prior to the
regular init callbacks while late exit callbacks run after the regular
exit callbacks.

Change-Id: Ic89babe0dc343459ac1e7e7fb705d4091b74a6af
Signed-off-by: Thierry Reding <treding@nvidia.com>
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2545956
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Reviewed-by: svc_kernel_abi <svc_kernel_abi@nvidia.com>
Reviewed-by: Mikko Perttunen <mperttunen@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
GVS: Gerrit_Virtual_Submit
2023-04-03 12:36:25 +00:00
Mikko Perttunen
44c9f6b676 UPSTREAM: gpu:host1x: Use different lock classes for each client
To avoid false lockdep warnings, give each client lock a different
lock class, passed from the initialization site by macro.

Change-Id: Iacfb5683a0ed975911459f43258c4704d8e7fd9c
Signed-off-by: Mikko Perttunen <mperttunen@nvidia.com>
Signed-off-by: Thierry Reding <treding@nvidia.com>
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2545955
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Reviewed-by: svc_kernel_abi <svc_kernel_abi@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
GVS: Gerrit_Virtual_Submit
2023-04-03 12:36:25 +00:00
Mikko Perttunen
558557ab02 drm/tegra: Add NVDEC support
Support NVDEC (both instances on Tegra194).

Signed-off-by: Mikko Perttunen <mperttunen@nvidia.com>
Change-Id: I8f6c841a16103fbf37bff3a3440d69059f2644f0
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2532426
Reviewed-by: Jonathan Hunter <jonathanh@nvidia.com>
Reviewed-by: svc_kernel_abi <svc_kernel_abi@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
GVS: Gerrit_Virtual_Submit
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2023-04-03 12:36:25 +00:00
Jon Hunter
7171a758d3 UPSTREAM: gpu: host1x: Fix Tegra194 syncpt interrupt threshold
Syncpoint interrupts are not working as expected on Tegra194. The
problem is that the syncpoint interrupt threshold being used is the
global interrupt threshold and not the virtual interrupt threshold.
Fix this by using the virtual interrupt threshold which aligns with
downstream.

JIRA LS-34

Change-Id: I4a3191c12298d4f0af264fd1f89754171a3829e9
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Signed-off-by: Mikko Perttunen <mperttunen@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2498820
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
GVS: Gerrit_Virtual_Submit
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2023-04-03 12:36:25 +00:00
Jon Hunter
54584c92ca gpu: host1x: Clean-up build for Host1x
Trivial clean-up for building Host1x by ...

1. Removing the Kconfig file because this is not needed for building
   as an external module and we only plan to build this as an external
   module.
2. Moving both 'host1x-next.h' header files under the Host1x source
   directory so that we don't need to pass the path for finding the
   header when building Host1x as an external module.
3. Remove the 'CONFIG_TEGRA_HOST1X_NEXT' variable because we always
   build Host1x as a module.

Bug 200687525

Change-Id: Ica5534f92a3a2ee6f6500ec419fa05f03993b90b
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2485760
Reviewed-by: Mikko Perttunen <mperttunen@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 12:36:25 +00:00
Mikko Perttunen
b06375f360 gpu: host1x: Set waiter output reference within lock
With the new fence implementation, we need to assign the reference
within the lock. Otherwise, it can happen that the waiter may get
signaled before the pointer has been set, and the fence implementation
will try to call intr_put_ref with a NULL pointer.

Bug 3237754

Change-Id: I465ec3ecf63c4f179ba8ef9cc5af0892a93f20af
Signed-off-by: Mikko Perttunen <mperttunen@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2474949
Tested-by: Jonathan Hunter <jonathanh@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Reviewed-by: Jonathan Hunter <jonathanh@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
GVS: Gerrit_Virtual_Submit
2023-04-03 12:36:25 +00:00
Jon Hunter
27ced8b315 gpu: host1x: Update to UAPI series v5
Update the host1x driver to the 'Host1x/Tegra UAPI v5' series [0]. This
fixes a few minor bugs found in the previous series.

[0] https://patchwork.ozlabs.org/project/linux-tegra/list/?series=223684

Bug 200687525

Change-Id: I680bfb9e8db73b9e2571551f22fadca1f2974498
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2469983
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Reviewed-by: Mikko Perttunen <mperttunen@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
GVS: Gerrit_Virtual_Submit
2023-04-03 12:36:25 +00:00
Jon Hunter
9f0b4d74ea gpu: host1x: Update host1x to align with v5.10
Update the host1x driver to Linux v5.10 with the 'Host1x/Tegra UAPI'
series [0] applied. This driver is built as an external module for
testing and development with upstream Linux kernels.

[0] https://patchwork.ozlabs.org/project/linux-tegra/list/?series=215770

Bug 3205478

Change-Id: I32c1a492293ca30dd47d1edf75aa53aa9e74b400
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2460074
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Reviewed-by: Shanker Donthineni <sdonthineni@nvidia.com>
Reviewed-by: Mikko Perttunen <mperttunen@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
GVS: Gerrit_Virtual_Submit
2023-04-03 12:36:25 +00:00
Jon Hunter
cc5bcef3f6 gpu: host1x: Add upstream host1x driver
Add the upstream host1x driver with the 'Host1x/Tegra UAPI' series [0]
applied. This driver will be built as an external module for use with
the NVGPU driver on upstream Linux kernels.

The following modifications have been made to the series posted upstream
1. Update the Makefile to always build the driver as a module
2. Remove the tests to see if CONFIG_DRM_TEGRA_STAGING is enabled
3. Rename the include/linux/host1x.h to include/linux/host1x-next.h to
   avoid conflicts with upstream headers when building as an external
   module.
4. Rename the include/uapi/linux/host1x.h to
   include/uapi/linux/host1x-next.h to avoid conflicts with upstream
   headers when building as an external module.
5. Rename the module that is built to be host1x-next.ko instead of
   host1x.ko to avoid any depmod conflicts with the upstream driver.

[0] https://patchwork.ozlabs.org/project/linux-tegra/list/?series=215770

Bug 3156385

Change-Id: Ic60299546809097dd0e4a9a7157bce1491d9f794
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2435801
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Reviewed-by: automaticguardword <automaticguardword@nvidia.com>
Reviewed-by: Mikko Perttunen <mperttunen@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
GVS: Gerrit_Virtual_Submit
2023-04-03 12:36:25 +00:00
Jon Hunter
9953593c5f gpu: Remove unused host1x and tegra-drm drivers
The host1x and tegra-drm drivers located in the linux-nvidia repository
are not referenced by any upper level Makefile and so are never
compiled. Therefore, remove the unused host1x and tegra-drm drivers
from the linux-nvidia repository.

Bug 3156385

Change-Id: I770844f1255541628eb4fc962f1c19866cbae31b
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2435652
Reviewed-by: automaticguardword <automaticguardword@nvidia.com>
Reviewed-by: Mikko Perttunen <mperttunen@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 12:36:25 +00:00
Bitan Biswas
5e5de808d9 iommu: k5.9: remove archdata.iommu accesses
k5.9 build needs below changes:
read archdata.iommu replaced by iommu_get_domain_for_dev
write archdata.iommu removed as alternative implementation used.

k5.9 build error fixed by explicit include of header <linux/iommu.h>

Change-Id: I464fd4144e4317b10aaa5460482f35e46527339a
Signed-off-by: Bitan Biswas <bbiswas@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2400862
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
2023-04-03 12:36:25 +00:00
Stephen Warren
40abcf46b7 nvidia: use $(srctree.$(overlay))
Update all Makefiles to make use of the new srctree.$(overlay) variables
to remove hard-coding the path to any overlays. One direct reference
remains in a hard-coded include statement in drivers/misc/tegra-cec/.

Bug 1978395

Change-Id: I5cdce04e019567a9bbfffaf0e92a61bd16806e99
Signed-off-by: Stephen Warren <swarren@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1593800
Reviewed-by: Alexander Van Brunt <avanbrunt@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Bitan Biswas <bbiswas@nvidia.com>
Reviewed-by: Timo Alho <talho@nvidia.com>
Tested-by: Timo Alho <talho@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2023-04-03 12:36:25 +00:00
Stephen Warren
2b60a9ec66 nvidia: use kernel overlay features
Update all Kconfig files and Makefiles to rely on the kernel overlay
feature. In particular, don't include any Kconfig files or Makefiles
from other overlays. -I directives in CFLAGS are not yet cleaned up.

Bug 1978395

Change-Id: I425d37d55f8ea61fb3a082a1504f994ff30cec03
Signed-off-by: Stephen Warren <swarren@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1561187
Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2023-04-03 12:36:25 +00:00
Ishan Mittal
b9a1518110 nvidia: Replace t18x/ in relative path with nvidia/
t18x repo will be discontinued and all code that
resides there is moved into nvidia/.
So, every reference to t18x/ should be corrected
to nvidia/

Bug 200295104

Change-Id: I01ca1118de043511edca829e1cb2b8b52fb398df
Signed-off-by: Vandana Salve <vsalve@nvidia.com>
2023-04-03 12:36:25 +00:00
Ishan Mittal
2f242453cd nvidia: Setting proper names to Makefiles & Kconfig
Makefiles and Kconfig files are picked up based
on project name being the extension.

Makefiles and Kconfig files brought over from
t18x have .t18x suffix.

Changed to .nvidia

Bug 200295104

Change-Id: Idade26f293c1faaf74f53b2ab20798c47652bdb9
Signed-off-by: Ishan Mittal <imittal@nvidia.com>
2023-04-03 12:36:25 +00:00
dmitry pervushin
440739938d t18x: renaming KConfigs & Makefiles to add suffix
Bug 1783210

Signed-off-by: dmitry pervushin <dpervushin@nvidia.com>
Change-Id: I20c29b4dd5947d296a6ab1e83d47e569e386855b
Reviewed-on: http://git-master/r/1176347
Reviewed-on: http://git-master/r/1177303
GVS: Gerrit_Virtual_Submit
Reviewed-by: Alexander Van Brunt <avanbrunt@nvidia.com>
Tested-by: Alexander Van Brunt <avanbrunt@nvidia.com>
Reviewed-on: http://git-master/r/1183017
2023-04-03 12:36:25 +00:00
Pritesh Raithatha
c7871478e1 kernel: t18x: change kernel path
All kernel versions are getting moved inside $TOP/kernel folder.
Changing kernel paths accordingly.

Bug 200190733

Change-Id: Ia0353dd4be3fb3d76bbfc82609be99546a217f92
Signed-off-by: Pritesh Raithatha <praithatha@nvidia.com>
Reviewed-on: http://git-master/r/1143409
Reviewed-by: Bharat Nihalani <bnihalani@nvidia.com>
Tested-by: Bharat Nihalani <bnihalani@nvidia.com>
2023-04-03 12:36:25 +00:00
Deepak Nibade
6d83772d00 gpu: host1x: enable gather filter for T186
Bug 1704301

Change-Id: Id783a06f353ae4627103ac48ab903eefd9b2ec7b
Signed-off-by: Deepak Nibade <dnibade@nvidia.com>
Reviewed-on: http://git-master/r/1029502
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Arto Merilainen <amerilainen@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Shridhar Rasal <srasal@nvidia.com>
2023-04-03 12:36:25 +00:00
Deepak Nibade
6bd4b830bf gpu: host1x: keep device powered on during submit
Get pm_runtime reference on device to keep device
powered on during submit

Bug 1704301

Change-Id: I71d4b4dc6317445bc3d1832ffd3bd4c7afadc654
Signed-off-by: Deepak Nibade <dnibade@nvidia.com>
Reviewed-on: http://git-master/r/1029500
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Arto Merilainen <amerilainen@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Shridhar Rasal <srasal@nvidia.com>
2023-04-03 12:36:25 +00:00
Deepak Nibade
1859542c94 gpu: host1x: API to load streamid registers
Define host1x_dev_ops for T186

Add API load_streamid_regs() to load streamid registers
Set this API to host1x_dev_ops.load_regs so that we
set streamid registers during host1x_probe()

Add a static table which includes streamid mappings
for all the clients

Bug 1704301

Change-Id: I7aeefc43776472a7ccf868bfa18c810f3b80b52b
Signed-off-by: Deepak Nibade <dnibade@nvidia.com>
Reviewed-on: http://git-master/r/1023438
Reviewed-by: Arto Merilainen <amerilainen@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Shridhar Rasal <srasal@nvidia.com>
2023-04-03 12:36:25 +00:00
Deepak Nibade
685eb2c8d2 gpu: host1x: add T186 support
Add host1x05 version and fill in the h/w details
in host1x05_info

Add all the hardware accessors for T186
(channel, sync, uclass accessors)

Add hardware support files for host1x channel,
syncpoints, cdma, pushbuffer, interrupt, and debug support

Keep gather filter disabled

Things working with this :
- cdma operations
- basic channel job submit path
- syncpoint support
- syncpoint interrupt mechanism
- debug dump

With this support, below tests pass for VIC client
$nvrm_channel channel_Basic
$nvrm_channel --module=vic

Bug 1704301

Change-Id: I7d97560cb1e3a57733fa0853936b0783c71b7060
Signed-off-by: Deepak Nibade <dnibade@nvidia.com>
Reviewed-on: http://git-master/r/1021434
GVS: Gerrit_Virtual_Submit
Reviewed-by: Arto Merilainen <amerilainen@nvidia.com>
Reviewed-by: Shridhar Rasal <srasal@nvidia.com>
2023-04-03 12:36:25 +00:00
Laxman Dewangan
7c1da7c4a9 host1x: Remove Makefile to prepare for host1x integration
host1x driver is available in the kernel/nvidia and to
integrate with git history, it is required to remove the
dummy Makefile.

Remove the dummy Makefile.

Bug 4038415

Change-Id: I335c298a235d1e7843bbee7aeb643a1120dfc714
Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
2023-04-03 12:34:31 +00:00
Laxman Dewangan
6251021c80 drm: tegra: virt: Fix compilation warning
Fix following compilation warning when build as OOT module:
  virt.c:270:2: warning: ISO C90 forbids mixed declarations and
                code [-Wdeclaration-after-statement]
  virt.c:345:16: warning: format ‘%d’ expects argument of type
                ‘int’, but argument 3 has type ‘long int’ [-Wformat=]

Bug 4052299

Change-Id: I8eb33d9c8b0e9847ca76b812ce2ebcf6e65adf96
Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
2023-04-03 09:18:59 +00:00
Mikko Perttunen
5ad064a2bb drm/tegra: Enable runtime PM during probe for internal engines
Currently, engine drivers only enable runtime PM during the host1x
init callback. This can happen slightly later than the probe, which
can cause the power domain to intermittently not be turned off after
probe.

My hypothesis is that there is a race condition between the post-probe
power domain poweroff that is done from a queued work, and the
pm_runtime_enable call happening in the host1x init callback.
If the pm_runtime_enable call happens first, everything is OK and
the power off work can disable the power domain as PM runtime is
enabled and the device is runtime suspended. If power off work runs
first, PM runtime is still disabled for the device and the domain
must be kept powered.

Resolve the issue by moving the runtime PM enablement to the
probe function.

Bug 3982357

Signed-off-by: Mikko Perttunen <mperttunen@nvidia.com>
Change-Id: I9a10e1dff580affebe05d9cc9ab3e24d1d3ca547
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2859476
Reviewed-by: Santosh BS <santoshb@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
2023-04-03 09:18:59 +00:00
Mikko Perttunen
63901a1066 drm/tegra: Enable runtime PM during probe
Currently, engine drivers only enable runtime PM during the host1x
init callback. This can happen slightly later than the probe, which
can cause the power domain to intermittently not be turned off after
probe.

My hypothesis is that there is a race condition between the post-probe
power domain poweroff that is done from a queued work, and the
pm_runtime_enable call happening in the host1x init callback.
If the pm_runtime_enable call happens first, everything is OK and
the power off work can disable the power domain as PM runtime is
enabled and the device is runtime suspended. If power off work runs
first, PM runtime is still disabled for the device and the domain
must be kept powered.

Resolve the issue by moving the runtime PM enablement to the
probe function.

Bug 3982357

Signed-off-by: Mikko Perttunen <mperttunen@nvidia.com>
Change-Id: I3e028bc03c8ff05d18e63039ac9e590c4557e268
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2859475
Reviewed-by: Santosh BS <santoshb@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
2023-04-03 09:18:59 +00:00
Ashish Mhetre
3fdc3313ae drm/fusa-capture: Zero out dma_buf_map struct
UBSAN is reporting "invalid-load include/linux/dma-buf-map.h".
This is because non-boolean value loaded to bool variable is_iomem
of dma_buf_map struct. Zeroing out this struct at declaration time
make sure that there is no garbage value which will be non-boolean.

Bug 3994163

Change-Id: Ia3f0c738fa248d3096d945f08813b7bdbad233f7
Signed-off-by: Ashish Mhetre <amhetre@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2869258
Tested-by: Bitan Biswas <bbiswas@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: Bitan Biswas <bbiswas@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
2023-04-03 09:18:59 +00:00
Jon Hunter
572d5395cc drm/tegra: Fix build for Linux v6.3
Building the Tegra DRM driver is failing due to changes made by the
following upstream commits:

1. Commit 650f2dc97053 ("gpiolib: of: remove
   [devm_]gpiod_get_from_of_node() APIs")
2. Commit 6c80a93be62d ("drm/fb-helper: Initialize fb-helper's preferred
   BPP in prepare function")
3. Commit bc292ab00f6c ("(HEAD) mm: introduce vma->vm_flags wrapper
   functions")

Address the above to fix building the driver for Linux v6.3.

Bug 4014315

Change-Id: Ic5242291295b84dd13e8ef651533077444ac62d2
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2867137
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 09:18:59 +00:00
Jon Hunter
5dad8295a6 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 09:18:59 +00:00
Mikko Perttunen
4af997528e drm/tegra: virt: Expose engine load in debugfs
Add a debugfs file (in a poor location) that shows the engine load
based on actmon information.

Bug 3973633

Signed-off-by: Mikko Perttunen <mperttunen@nvidia.com>
Change-Id: I60e18aa064c89a89e62099a1e468f2e5b2beb265
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2864720
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 09:18:59 +00:00
Mikko Perttunen
0c4db82587 drm/tegra: Fix check for undefined submit flags
Fix the downstream-specific check for undefined submit flags to use
bitwise negation instead of logical. The author appears to have
written enough Rust to forget about bitwise negation using a different
operator.

Signed-off-by: Mikko Perttunen <mperttunen@nvidia.com>
Change-Id: I2093ea78450ea7ef9173df41a6cd242061f3fe93
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2861969
Reviewed-by: Santosh BS <santoshb@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
2023-04-03 09:18:59 +00:00
Jon Hunter
e837f4e112 drm/tegra: Fix build for Linux v6.2
Linux v6.2 makes the following changes in the DRM subsystem ...

1. Commit 7c99616e3fe7 ("drm: Remove drm_mode_config::fb_base") removes
   the fb_base member from the drm_mode_config structure.
2. Commit 9877d8f6bc37 ("drm/fb_helper: Rename field fbdev to info in
   struct drm_fb_helper") renames the 'fbdev' field of the drm_fb_helper
   structure to 'info'.
3. Commit 7fd50bc39d12 ("drm/fb-helper: Rename drm_fb_helper_alloc_fbi()
   to use _info postfix") renames the function drm_fb_helper_alloc_fbi()
   to drm_fb_helper_alloc_info().
4. Commit afb0ff78c13c ("drm/fb-helper: Rename drm_fb_helper_unregister_fbi() to
   use _info postfix") renames the function
   drm_fb_helper_unregister_fbi() to drm_fb_helper_unregister_info().

Update the Tegra DRM out-of-tree module as necessary to fix the build
for Linux v6.2.

Bug 3936429

Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Change-Id: I501cb1d5dc772bc86b357f536431b76427e4888e
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2841023
Reviewed-by: svc_kernel_abi <svc_kernel_abi@nvidia.com>
Reviewed-by: Laxman Dewangan <ldewangan@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
2023-04-03 09:18:59 +00:00
Mikko Perttunen
2c5610780d drm/tegra: virt: Make IVC channel global
Only one instance of the IVC channel with NvHost Server can exist
at once. As such, to allow instantiating the driver for multiple
engines, make the IVC channel global.

Signed-off-by: Mikko Perttunen <mperttunen@nvidia.com>
Change-Id: I611158dd4aa92216870a66e4aa5fe15c37984ea8
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2828565
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 09:18:59 +00:00
Mikko Perttunen
f6df3cee62 drm/tegra: Add function for accessing user syncpoints from kernel
Add a kernel API allowing other drivers to convert syncpoints
allocated by userspace to respective kernel 'struct host1x_syncpt'
objects while verifying the syncpoint's ownership.

Signed-off-by: Mikko Perttunen <mperttunen@nvidia.com>
Change-Id: I4368e7405d401bfe57bbd8315f69465effb16330
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2817764
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
2023-04-03 09:18:59 +00:00
Mikko Perttunen
e1b1afaab1 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 09:18:59 +00:00
Mikko Perttunen
93006031b9 drm/tegra: Support virtualized engines
Support engines that are not owned by NvHost Server.

Signed-off-by: Mikko Perttunen <mperttunen@nvidia.com>
Change-Id: I3d3c8b153e1e5c92bcf6d9e1439c20fba3b9767f
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2811838
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 09:18:59 +00:00
Mikko Perttunen
09c1b1e9da 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 09:18:59 +00:00
Mikko Perttunen
35730e5e7b 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 09:18:59 +00:00
Jon Hunter
ef6b32711f drm/tegra: Fix OFA support
When the OFA driver was added for Tegra234, the driver was not added to
the list of drivers registered by the Tegra DRM driver. This is breaking
support for Tegra DRM. Add the OFA driver to the lists of driver to fix
Tegra DRM support.

Bug 3819719
Bug 3845104

Change-Id: I023f2abe38f9249680358170e0bdd85547e0c4ba
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2797758
Reviewed-by: Mikko Perttunen <mperttunen@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
2023-04-03 09:18:59 +00:00
Jon Hunter
5bd1c2ca5c drm/tegra: Fix warnings in OFA driver
When buildig the OFA driver the following warnings are observed ...

 nvidia-oot/drivers/gpu/drm/tegra/ofa.c:172:20:
 warning: unused variable ‘tegra’ [-Wunused-variable]
   struct tegra_drm *tegra = ofa->client.drm;
 nvidia-oot/drivers/gpu/drm/tegra/ofa.c:171:24:
 warning: unused variable ‘client’ [-Wunused-variable]
    struct host1x_client *client = &ofa->client.base;

Fix these warnings by removing these unused variables.

Bug 3778105

Change-Id: I3b3959b29075b06e4b23ab4bd7edea2c6d05d38c
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2791969
Reviewed-by: Mikko Perttunen <mperttunen@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
2023-04-03 09:18:59 +00:00
Mikko Perttunen
a9bb2f825b 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 09:18:59 +00:00
Mikko Perttunen
8f676020f2 drm/tegra: Add isolation related callbacks for NVENC/NVJPG
Add context isolation related engine callbacks to NVENC and NVJPG
drivers. These are now required on Tegra234 for things to work at
all.

Bug 3778105

Signed-off-by: Mikko Perttunen <mperttunen@nvidia.com>
Change-Id: I4208965a70941ebcd68d6acd7f4db29635d741d5
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2772957
(cherry picked from commit 777f40bfb4f008f82bd2901b849a254d8a5c40a8)
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2772921
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
2023-04-03 09:18:59 +00:00
Mikko Perttunen
6dc646d619 drm/tegra: Use iommu regs helper in nvenc/nvjpg engines
As TRANSCFG regs move into util.c, we must now adapt these engines'
drivers to use the iommu regs helper as well.

Bug 3778105

Signed-off-by: Mikko Perttunen <mperttunen@nvidia.com>
Change-Id: I2f2cc92c013eff50ab3aab1a4a8e49ba82e91dbf
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2771767
(cherry picked from commit d24bd9b4aa44b31a1053c559b0f58c3bd62a696d)
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2759059
Tested-by: Jonathan Hunter <jonathanh@nvidia.com>
Reviewed-by: Jonathan Hunter <jonathanh@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
2023-04-03 09:18:59 +00:00
Mikko Perttunen
59a24174d4 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 09:18:59 +00:00
Mikko Perttunen
2e8de96526 drm/tegra: Add code for booting RISC-V based engines
Add helper code for booting RISC-V based engines where firmware is
located in a carveout.

Bug 3778105

Signed-off-by: Mikko Perttunen <mperttunen@nvidia.com>
Change-Id: I36eda4774838fc73098bcf2eff8c3f1983c82465
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2771768
(cherry picked from commit cc6935ec1dc1e6557f5e0a7d53ef9f0c3ff12fb3)
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2759060
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 09:18:59 +00:00
Mikko Perttunen
e1ae7a73d5 drm/tegra: HACK: Avoid core kernel changes for NVDEC boot
To allow NVDEC boot on T234 before core kernel changes are upstreamed,
apply hacks to directly read MC registers and hardcode firmware
descriptor information.

Bug 3778105

Signed-off-by: Mikko Perttunen <mperttunen@nvidia.com>
Change-Id: I5a26e33f656dfababc17a3443c721ba0d327defb
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2771771
(cherry picked from commit e404fef7d0824b7620dd6307755e57cc6cdd40d7)
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2768897
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 09:18:59 +00:00
Mikko Perttunen
79282354d0 drm/tegra: Add Tegra234 support to NVDEC driver
Add support for the Tegra234 version of NVDEC to the NVDEC driver.
This version sports a RISC-V controller and requires a few additional
clocks. After firmware has been loaded, the behavior is, however,
backwards compatible.

Bug 3778105

Signed-off-by: Mikko Perttunen <mperttunen@nvidia.com>
Change-Id: I87f851875253efbc1768a87e7ee241f64ba681a5
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2771769
(cherry picked from commit 55200e3b3a4f7a3b6e2d6b1adbfd28ba26b9372d)
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2759061
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 09:18:59 +00:00
Mikko Perttunen
f535883c6a drm/tegra: Introduce program_iommu_regs helper
The VIC and NVDEC drivers contain some duplicated code. Start chipping
away at that by introducing a helper for programming the TRANSCFG
and STREAMID registers.

Bug 3778105

Signed-off-by: Mikko Perttunen <mperttunen@nvidia.com>
Change-Id: I30f9cf3fb8fb89fa5abf5f5e17ba41649a42097e
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2771766
(cherry picked from commit 27872b2f90d66d8706594f5903cff4d2b1e88be4)
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2759058
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 09:18:59 +00:00