Nvidia-oot: tegra23x_perf_uncore fixes and related improvements

This patch set contains a number of fixes and improvements for the Tegra23x uncore performance driver, along with one unrelated fix for nvvrs-pseq-rtc in the NVIDIA out-of-tree kernel modules (nvidia-oot) repository.

I became interested in the tegra23x_perf_uncore driver while working on pKVM support for Tegra SoCs with a Linux 6.6–based kernel.
Although none of the issues are directly related to pKVM itself, the problems in the out-of-tree driver manifested as the ARM core PMU ceasing to function correctly when both drivers were active.

All the bugs and design flaws addressed here are intrinsic to the nvidia-oot code and would be observable on other kernels as well.

The patches can be grouped as follows:

Patches 1–3 – Correctness and safety fixes

  • Fix a double-free when unloading the module.

  • Stop claiming PERF_TYPE_HARDWARE.

  • Limit claimed events strictly to those explicitly supported.

Patches 4–5 – CPU association improvements

  • Enforce CPU0 as the default owner and expose a cpumask attribute.

  • Dynamically pick a designated CPU at runtime instead of relying on static binding.
    These changes resolve several subtle bugs and make the driver more robust and portable across CPU topologies.

Patch 6 – Validation improvement

  • Reject NV_INT_* pseudo-IDs to avoid ambiguous or incorrect behavior.

Patch 7 – Independent cleanup

  • Fix an unbalanced mutex_unlock() in nvvrs-pseq-rtc, originally found while running the LTP test suite with debug options enabled on my pKVM setup.

All patches apply cleanly to the nvidia-oot tree shipped with Jetson 36.4.4.
They are provided as an attached tarball for convenience.

patches-nvidia-oot.tar.gz (7.4 KB)

Feedback, testing, and review are most welcome.

Hi,
Thanks for sharing the patch. Will check it with our teams. One query, does the patch have dependency to the patch in
Fix for pKVM / nVHE boot hang on Jetson AGX Orin

No, there is no dependency between this patch series and the other patch that I posted. The only thing they have in common is that they are both related to issues that I personally have run into while trying to make pKVM working on the Jetson AGX Orin.

The bugs addressed by this patch series are more generic in nature, and would also happen when not using pKVM. I think I triggered them because I used a Linux 6.6.x based kernel. At least one of the bugs addressed by this series also happen on the Jetson 36.4.4 stock kernel, e.g. if you try to unload the driver with the stock kernel:
sudo rmmod tegra23x_perf_uncore

…then in my experience the device will freeze a little while later, especially if you do something with the device, e.g. compiling something. This happens because of the double free bug.