[Bug 201753] AMD-Vi: Unable to write to IOMMU perf counter

bugzilla-daemon
2021-03-05T10:27:11Z

--- Comment #20 from David Coe (david.coe@live.co.uk) ---
More results and some progress!!

A. Alex Hung (Ubuntu) has cherry-picked the kernel-commit [1} of Suravee's
version 3 patch and placed test-builds on [2]. It works for his Ryzen 2500U.
Bravo for a quick take-up!

I've checked it out and (alas, as expected with the original 5 x 20 msec delay)
it is isn't enough for my Ryzen 2400G which needs ~120 msecs to respond :-(.

B. I've done a couple more rebuilds for the current kernels on Ubuntu 20.10 and
21.04 using Suravee's patch updated both with Pauls' retry-logging and with
increasing the maximum delay to 25 x 20 msec.

Grepp'ing dmesg for IOMMU (on my 2400g) gives:

[ 1.018329] pci 0000:00:00.2: AMD-Vi: IOMMU performance counters supported
(retry = 19)
[ 1.022185] pci 0000:00:00.2: AMD-Vi: Found IOMMU cap 0x40
[ 1.023669] perf/amd_iommu: Detected AMD IOMMU #0 (2 banks, 4
counters/bank).
[ 1.283218] AMD-Vi: AMD IOMMUv2 driver by Joerg Roedel <jroedel@suse.de>

The retrys count backwards so that confirms the Ryzen 2500G still needs 120
msecs to respond.

My (very strong) proposal is that we increase Suravee's retry-count to
something large enough to cover the numerous entry-level Ryzen's out there.
Only the absolutely necessary boot-up delay is introduced (and checked, if
required, by Paul's logging statement). Most purchasers of Ryzen CPUs are then
covered! Only the dyed-in-the-wool speed-merchants have to make a choice
between boot-up time and IOMMU capability - at least until the underlying
problem can be corrected in firmware or silicon.

Thanks again, good people.

David

[1].
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=6778ff5b21bd8e78c8bd547fd66437cf2657fd9b
[2]. https://people.canonical.com/~alexhung/LP1917203/