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

bugzilla-daemon
2021-02-25T17:56:24Z

David Coe (david.coe@live.co.uk) changed:

What |Removed |Added
----------------------------------------------------------------------------
CC| |david.coe@live.co.uk

--- Comment #10 from David Coe (david.coe@live.co.uk) ---
Hi Suravee!

This bug has been bothering Ryzen users for some while now and work-arounds
adding various linux boot parameters have had patchy success. It's good to see
an informed and more forensic approach. Bravo!

I've been exercising your RFCv3 patch over the last few days (AMD Ryzen 5
2400G, Asus Prime B350-Plus, Ubuntu 20.10, Linux 5.8.0-43). With the original
20 msec delay I still get:

[ 0.703538] Trying to unpack rootfs image as initramfs...
[ 0.859160] Freeing initrd memory: 83748K
[ 0.859256] pci 0000:00:00.2: AMD-Vi: Unable to read/write to IOMMU perf
counter.
[ 0.859265] fbcon: Taking over console
[ 0.859367] pci 0000:00:00.2: can't derive routing for PCI INT A
[ 0.859368] pci 0000:00:00.2: PCI INT A: not connected
[ 0.859413] pci 0000:00:01.0: Adding to iommu group 0
...
...
[ 0.859959] pci 0000:0b:00.0: Adding to iommu group 12
[ 0.863140] pci 0000:00:00.2: AMD-Vi: Found IOMMU cap 0x40
[ 0.863142] pci 0000:00:00.2: AMD-Vi: Extended features (0x4f77ef22294ada):
[ 0.863143] PPR NX GT IA GA PC GA_vAPIC
[ 0.863144] AMD-Vi: Interrupt remapping enabled
[ 0.863145] AMD-Vi: Virtual APIC enabled
[ 0.863375] AMD-Vi: Lazy IO/TLB flushing enabled
[ 0.864261] amd_uncore: AMD NB counters detected
[ 0.864273] amd_uncore: AMD LLC counters detected
[ 0.864696] check: Scanning for low memory corruption every 60 seconds

Increasing the delay to msleep(40) gives:

[ 0.212761] Trying to unpack rootfs image as initramfs...
[ 0.366407] Freeing initrd memory: 83304K
[ 0.509105] pci 0000:00:00.2: AMD-Vi: IOMMU performance counters supported
[ 0.509199] pci 0000:00:00.2: can't derive routing for PCI INT A
[ 0.509200] pci 0000:00:00.2: PCI INT A: not connected
[ 0.509244] pci 0000:00:01.0: Adding to iommu group 0
...
...
[ 0.509802] pci 0000:0b:00.0: Adding to iommu group 12
[ 0.512997] pci 0000:00:00.2: AMD-Vi: Found IOMMU cap 0x40
[ 0.512999] pci 0000:00:00.2: AMD-Vi: Extended features (0x4f77ef22294ada):
[ 0.512999] PPR NX GT IA GA PC GA_vAPIC
[ 0.513001] AMD-Vi: Interrupt remapping enabled
[ 0.513001] AMD-Vi: Virtual APIC enabled
[ 0.513181] AMD-Vi: Lazy IO/TLB flushing enabled
[ 0.514116] amd_uncore: AMD NB counters detected
[ 0.514128] amd_uncore: AMD LLC counters detected
[ 0.514482] perf/amd_iommu: Detected AMD IOMMU #0 (2 banks, 4
counters/bank).
[ 0.514534] check: Scanning for low memory corruption every 60 seconds

If Linus is taking up the patch (hurrah), is 40 msec too large over the Ryzen
range? I would quite like the good Ubuntu people to merge your patch into their
current and upcoming distributions (I think SuSE are already doing so) but
don't want to jump-the-gun or tread-on-any-toes :-).

Over the next few days, I'll try my 2400G on delays between 20 and 40 msec and
maybe even test the patch on the still rather unstable Ubuntu 21.04. Any
guidance
much appreciated and, once again, many thanks.

David