Commit Graph

27 Commits

Author SHA1 Message Date
Johnny Liu
21c6a3b3e8 drm/tegra: Send ICC requests with peak_bw
When BPMP BWMGR receives ICC avg_bw requests from different memory
clients, it will sum up all avg_bw values together and use it to
determine the final EMC frequency.

Transitioning to ICC peak_bw requests will cause BPMP to evaluate
the bandwidth requirements of each memory client individually,
selecting the maximum bandwidth request from among all the clients
to determine the final EMC frequency.

This modification prevents excessive memory bandwidth allocation
when multiple host1x clients collaborate for data processing.
Currently, host1x clients request the full theoretical 100% data
bandwidth, even though the system typically doesn't fully utilize
that amount during runtime.

To address the issue of insufficient memory bandwidth when multiple
host1x clients are used together, we can reduce the boost_up_threshold
value of cactmon DFS. This adjustment ensures that when actual memory
bandwidth utilization surpasses the specified boost-up bandwidth
threshold, EMC frequency will be further scaled by one step further
to alleviate the problem.

Bug 4328471

Signed-off-by: Johnny Liu <johnliu@nvidia.com>
Change-Id: I826a374666f38718652c5cae449c0aadeabfbdb5
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2996561
Reviewed-by: Mikko Perttunen <mperttunen@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
2023-11-11 02:28:29 -08:00
Vedashree Vidwans
cbf177852b drm/tegra: add hwpm support in video ip driver
Add IP-HWPM interface in NVENC, OFA and VIC drivers. This code will
- register with HWPM driver during probe
- expose power management and register read/write function.

Bug 4158030

Change-Id: I9311c9fc31cffadf11c36b6e4516f0da84dcbdf4
Signed-off-by: Vedashree Vidwans <vvidwans@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2954070
Reviewed-by: Santosh BS <santoshb@nvidia.com>
Reviewed-by: Mikko Perttunen <mperttunen@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
2023-10-03 18:57:48 -07:00
Jon Hunter
fc7367debb drm/tegra: Fix crash when engine probe fails
If probing of the VIC engine fails then the following crash is observed
...

 tegra-vic 15340000.vic: devfreq_add_device: Unable to find governor for
  the device
 tegra-vic 15340000.vic: failed to init devfreq: -22
 tegra-vic: probe of 15340000.vic failed with error -22
 tegra-nvdec 15480000.nvdec: Adding to iommu group 45
 list_add corruption. prev->next should be next
  (ffff000094505f80), but was 0000000000000000. (prev=ffff000095245cf0).
 ------------[ cut here ]------------
 kernel BUG at lib/list_debug.c:26!
 Internal error: Oops - BUG: 00000000f2000800 [#1] SMP
 ...

 pc : __list_add_valid+0x80/0x84
 lr : __list_add_valid+0x80/0x84
 ...

 Call trace:
 __list_add_valid+0x80/0x84
 host1x_subdev_register+0x80/0x170 [host1x_next]
 __host1x_client_register+0xac/0x160 [host1x_next]
 nvdec_probe+0x1c8/0x58c [tegra_drm_next]
 platform_probe+0x6c/0xe0
 really_probe+0xc4/0x3dc
 __driver_probe_device+0x114/0x190
 driver_probe_device+0x44/0x114
 __driver_attach+0xcc/0x1f0
 bus_for_each_dev+0x78/0xd0
 driver_attach+0x28/0x30
 bus_add_driver+0xbc/0x220
 driver_register+0x70/0x120
 __platform_register_drivers+0x70/0x140
 host1x_drm_init+0x58/0x1000 [tegra_drm_next]
 do_one_initcall+0x48/0x2d0
 do_init_module+0x5c/0x270
 load_module+0xb08/0xc70
 __do_sys_init_module+0x1dc/0x214
 __arm64_sys_init_module+0x20/0x2c
 invoke_syscall.constprop.0+0x7c/0xd0
 el0_svc_common.constprop.0+0x140/0x150
 do_el0_svc+0x38/0xa0
 el0_svc+0x38/0x18c
 el0t_64_sync_handler+0xb4/0x130
 el0t_64_sync+0x17c/0x180
 Code: aa0103e2 910fa000 aa0403e1 941b9509 (d4210000)
 ---[ end trace f8f20f933fe03c7e ]---

The problem is that some of the engines are not cleaning up correctly on
probe failure and so fix this by adding the necessary calls clean up if
probe fails.

Bug 4303860

Change-Id: Ife1e0ce7429458d187422162a298cc140f0e3bc4
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2986790
Reviewed-by: Mikko Perttunen <mperttunen@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
2023-09-28 22:00:56 -07:00
Jon Hunter
07dbfa8de1 gpu: host1x: Make host1x_actmon_unregister() return void
The function host1x_actmon_unregister() never fails and so never returns
an error. Make this function return void to simplify the code.

Bug 4303860

Change-Id: I9e1cd403bd6db8e2d4ac6831ed26e1436638456f
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2986789
Reviewed-by: Mikko Perttunen <mperttunen@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
2023-09-28 22:00:51 -07:00
Uwe Kleine-König
ee866593b7 UPSTREAM: gpu: host1x: Make host1x_client_unregister() return void
This function returned zero unconditionally. Make it return no value and
simplify all callers accordingly.

Bug 4303860

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Acked-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Thierry Reding <treding@nvidia.com>
Change-Id: I07bf696e8af7c3472355b52549fb43ff3987c108
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2986788
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
2023-09-28 22:00:46 -07:00
Johnny Liu
837b275df5 drm/tegra: Resume device frequency with Fmax
Avoid using suspend_freq to set the Fmax for the device, since it will
re-enable the actmon watermark interrupts again if the suspend_freq is
not zero in the devfreq_suspend_device call.

Since we want to make sure device is running at Fmax but avoid using
suspend_freq, we can forcelly override the resume_freq with the
scaling_max_freq to reach the same effect.

Bug 4271562

Signed-off-by: Johnny Liu <johnliu@nvidia.com>
Change-Id: Ia19a7ef9de14643abf1b174b6180e40a847de132
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2974074
Reviewed-by: Mikko Perttunen <mperttunen@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
2023-09-06 12:05:33 -07:00
Johnny Liu
8b99f1f5b8 drm/tegra: Set static Fmax for suspend frequency
The suspend_freq is a fixed value for devfreq core, while the
resume_freq will be changed dynamically based on the last previous
updated frequency value of the device.

When device is put into suspend mode, devfreq core will update the
resume frequency with the suspend frequency. Therefore, when the device
is resumed back again, it will run at suspend_freq.

Forcelly set the suspend_freq as Fmax so that device will run at Fmax
when it is resumed back.

Bug 4269900

Signed-off-by: Johnny Liu <johnliu@nvidia.com>
Change-Id: Ic6511613ae5d02831a66dd1c2a93f21c142bf3a7
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2973229
Reviewed-by: Mikko Perttunen <mperttunen@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
2023-09-05 03:46:11 -07:00
Johnny Liu
a588ad882d drm/tegra: Derive count weight from max freq
The original resume_freq will be overridden when the device is put
into suspend mode. Therefore, the resume cycle won't always use the
max frequency of the device to set the actmon count weight.

Change the implementation to use scaling_max_freq to always use the
max frequency of the device to set the actmon count weight.

Bug 4252125

Signed-off-by: Johnny Liu <johnliu@nvidia.com>
Change-Id: Iaaae8ada989cd1ed7dd728fb526ad4391a2f192c
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2967098
Reviewed-by: Mikko Perttunen <mperttunen@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
2023-08-24 09:24:42 -07:00
Johnny Liu
d6a45460a5 drm/tegra: Set nvenc actmon count weight once
Change the implementation to set count weight values for both actmon and
the engine once in runtime resume cycle to align the implementation as
nvdec for kernel upstream.

Bug 4251915

Signed-off-by: Johnny Liu <johnliu@nvidia.com>
Change-Id: Ie2df685e990a4ebcd5a83db23db3c3bc8ab2af37
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2965502
Reviewed-by: svcacv <svcacv@nvidia.com>
Reviewed-by: Mikko Perttunen <mperttunen@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
2023-08-23 02:34:04 -07:00
Johnny Liu
69d9f479a4 drm/tegra: Unify logic for suspend and resume
Two main changes for the suspend and resume:
1. Set clock to Fmin/Fmax in suspend/resume cycles
2. Reorder the code in suspend and resume functions and add recovering
   logic when error happens in between

Bug 4224081

Signed-off-by: Johnny Liu <johnliu@nvidia.com>
Change-Id: Iadb0b1f960ca8b9c80094d1769a2d90496263124
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2948452
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
2023-08-09 10:40:23 -07:00
Johnny Liu
d171c817ec drm/tegra: Correct icc cleanup logic
Since devm_of_icc_get is used, no need to call icc_put when device probe
fails or device driver is removed.

Bug 4222919

Signed-off-by: Johnny Liu <johnliu@nvidia.com>
Change-Id: Ide313c6f56e1bef83ffe3718cd434abbdaeec869
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2947933
Reviewed-by: svcacv <svcacv@nvidia.com>
Reviewed-by: Mikko Perttunen <mperttunen@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
2023-08-04 14:09:18 -07:00
Jon Hunter
9f2ed528c8 drm/tegra: Fix interconnect support for Linux v6.2+
Interconnect support for multimedia engines is disable for Linux v6.2
kernels. Rather than always disabling interconnect support for these
kernels, we just need to ensure the necessary upstream kernel patches
are in place for Linux v6.2 kernels. Therefore, enable interconnect
support for all kernels.

Bug 4097374

Change-Id: Ibceb866ba239454a131543cdff90e68007b28942
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2937758
Reviewed-by: Johnny Liu <johnliu@nvidia.com>
Reviewed-by: Sumit Gupta <sumitg@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
2023-07-20 01:16:09 -07:00
Johnny Liu
ff572997a3 drm/tegra: Wrap register init code in function
Put the actmon-related register initialization code in the function for
readability.

Bug 4183393

Signed-off-by: Johnny Liu <johnliu@nvidia.com>
Change-Id: Id68d128ae330105da0d3f76270fe38d57c12c740
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2931793
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
2023-07-10 10:05:47 -07:00
Johnny Liu
3264c9dfca drm/tegra: Skip non-clock update in suspend mode
When the device is in suspend mode, There is no point to update
actmon count weight and send ICC request for the device.

If ICC request is sent for the device in suspend mode, in osidle state,
the default EMC frequency will be affected due to the accumulated ICC
bandwidth QoS constraint, and affect the overall osidle power.

Bug 4168788

Signed-off-by: Johnny Liu <johnliu@nvidia.com>
Change-Id: I8700b131b5f914d93feed9f8a9d792c2fdaa9b53
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2931905
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
2023-07-07 07:01:02 -07:00
Johnny Liu
da7cd1c546 drm/tegra: Enable disable actmon in RPM callbacks
Actmon should be enabled only when engines are active.

Bug 4168788

Signed-off-by: Johnny Liu <johnliu@nvidia.com>
Change-Id: Ifb4bfe67357402266080331ea18ae2a9af2d85ee
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2931890
Reviewed-by: Santosh BS <santoshb@nvidia.com>
Reviewed-by: Bibek Basu <bbasu@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
2023-07-07 07:00:52 -07:00
Johnny Liu
4241a7c976 drm/tegra: Export active signal to actmon
As long as the subcomponents in the engine are active, we consider the
engine as active and the engine should export active signal to the
actmon.

Bug 4179140

Signed-off-by: Johnny Liu <johnliu@nvidia.com>
Change-Id: Ic4cccf29e8ac87da24f6fe3bf1f1e93a11511762
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2930445
Reviewed-by: svcacv <svcacv@nvidia.com>
Reviewed-by: Rajkumar Kasirajan <rkasirajan@nvidia.com>
Reviewed-by: Bibek Basu <bbasu@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
2023-07-05 14:55:49 -07:00
Johnny Liu
97c41a6222 drm/tegra: Enabling ICC for NVENC
In order to avoid the NVENC performance bottleneck from EMC,
NVENC needs to ask for the required memory bandwidth for itself
according to its current frequency and load.

Bug 4097374

Signed-off-by: Johnny Liu <johnliu@nvidia.com>
Change-Id: I504a741126d52c3ae847918b4c4ab6e6a27823e7
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2914622
Reviewed-by: Mikko Perttunen <mperttunen@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
2023-06-10 19:35:33 -07:00
Johnny Liu
bd6fc54120 drm/tegra: Bridge tegra_wmark devfreq with host1x
To support actmon DFS for nvenc with tegra_wmark govenor, the nvenc
driver needs to provide interrupt handling callback function for host1x,
and watermark update callback for tegra_wmark govenor.

Bug 4077910

Signed-off-by: Johnny Liu <johnliu@nvidia.com>
Change-Id: Ibe1e2aa220e534f095261b609adca851a075fc09
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2900048
Reviewed-by: svcacv <svcacv@nvidia.com>
Reviewed-by: Mikko Perttunen <mperttunen@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
2023-05-09 22:27:32 -07:00
Johnny Liu
a61d58efd6 drm/tegra: Enable devfreq for the nvenc client
Enable devfreq for the nvenc client with userspace governor by default.

Bug 4077910

Signed-off-by: Johnny Liu <johnliu@nvidia.com>
Change-Id: I2a7f3c047f3d7a6ba8d9219fcd0af85eeeaf7e99
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2895731
Reviewed-by: svcacv <svcacv@nvidia.com>
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
Reviewed-by: svc-mobile-cert <svc-mobile-cert@nvidia.com>
Reviewed-by: Mikko Perttunen <mperttunen@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
2023-05-02 09:19:56 -07:00
Johnny Liu
16620428cd drm/tegra: Register actmon for the nvenc client
Register nvenc actmon to export the engine utilization information in
the debugfs.

Bug 4077910
Bug 3923137

Signed-off-by: Johnny Liu <johnliu@nvidia.com>
Change-Id: I70800bbc2ad37d69e9697a47a161e64c60dcb383
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2891911
Reviewed-by: svcacv <svcacv@nvidia.com>
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
Reviewed-by: svc-mobile-cert <svc-mobile-cert@nvidia.com>
Reviewed-by: Mikko Perttunen <mperttunen@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
2023-04-27 08:12:32 -07:00
Mikko Perttunen
5395e466bf drm/tegra: Job hardware timestamping support
Add support for emitting ftrace events for job submissions with
hardware timestamps, including configuring engines to capture
timestamps when execution starts and ends.

Bug 3829397

Signed-off-by: Mikko Perttunen <mperttunen@nvidia.com>
Change-Id: I3a3f6fcf931d7f8fb337f029af7729ffc2cbb972
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2891349
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
2023-04-26 20:08:33 -07: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
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
Jon Hunter
57b7756289 drm/tegra: Update to Linux v5.19-rc1
Update the Tegra DRM driver to align with the latest upstream Tegra DRM
driver from Linux v5.19-rc1.

Bug 3724727

Change-Id: I5dc54eee6cd2c5c62832e1844cd3df59fcabe976
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2739541
Reviewed-by: svc_kernel_abi <svc_kernel_abi@nvidia.com>
Reviewed-by: Bibek Basu <bbasu@nvidia.com>
2023-04-03 09:18:59 +00:00
Jon Hunter
96b2a8c5ea drm/tegra: Add support for NVENC and NVJPG
Add support for the Host1x NVENC and NVJPG engines.

JIRA LS-411

Change-Id: Ied1c64c17d337e571512c053ef9552642faa430c
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2490297
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
2023-04-03 09:18:59 +00:00