Comment 330 for bug 1958019

Revision history for this message
In , cam (cam-linux-kernel-bugs) wrote :

I posted some instructions, but I've lost them in the thread too. :p

I used this document to setup the PCI passthrough:
https://wiki.archlinux.org/title/PCI_passthrough_via_OVMF

PCIE devices are in groups, and ALL of the devices in a group must be
setup for passthrough together. However, I found I only needed to tell
qemu about the sound card.

On my 2020 Legion 7i, the sound card is in a group with 3 other devices.
Fortunately, it didn't cause me any issues to set them all up for
passthrough as none were vital to running the system. This will probably
be the case for you, but we'll see.

The article provides a script that lists all the PCI groups and their
associated devices that is really helpful:
https://wiki.archlinux.org/title/PCI_passthrough_via_OVMF#Ensuring_that_the_groups_are_valid

Here's part of the output of the script showing the sound card and the
group that it's in as well as the other devices in that group:
IOMMU Group 14:
         00:1f.0 ISA bridge [0601]: Intel Corporation Comet Lake LPC
Controller [8086:068d]
         00:1f.3 Audio device [0403]: Intel Corporation Comet Lake PCH
cAVS [8086:06c8]
         00:1f.4 SMBus [0c05]: Intel Corporation Comet Lake PCH SMBus
Controller [8086:06a3]
         00:1f.5 Serial bus controller [0c80]: Intel Corporation Comet
Lake PCH SPI Controller [8086:06a4]

Here's JCS's Qemu. JCS just made some changes that added logging to pick
out HDA verbs.
https://github.com/jcs/qemu

You'll need to make sure you have the build dependencies for qemu.

Here's what I used for configure:
./configure --prefix=/opt/qemu/jcs --enable-kvm
--enable-trace-backends=log --target-list=x86_64-softmmu

You can change the prefix to whatever you personally prefer of course.

 From there follow up with the usual "make && make install"

If you get this far, I can provide more guidance on where to go. Vincent
Morel has started working on the same thing, but with an entirely
different model of Lenovo laptop.

If you have trouble, also feel free to reach out for help.

Here's one my last posts to Vincent. It has some instructions on how I
got the correct driver working with the passed through sound card in the
Windows 10 vm:
https://bugzilla.kernel.org/show_bug.cgi?id=208555#c301

Of course those driver instructions are for my Intel based 2020 Legion
7. You may have different paths and you may need to try several
different drivers in the archive before one works. In my case, it was
the very last driver that ended up working for me.

A heads up that I'm going to have poor availability this weekend. I'll
be able to still to respond to emails at least, but my responses will be
slower and less frequent.

On 6/25/21 8:04 PM, <email address hidden> wrote:
> https://bugzilla.kernel.org/show_bug.cgi?id=208555
>
> --- Comment #316 from Pablitar (<email address hidden>) ---
> I'll see if I have the time. And if I can hahaha.
>
> Is there a clear list of instructions in this thread? I'm lost in all the
> messages.
>
> I can read the thread trying to compile what to do. But if someone could
> point
> me where to look, maybe that can save me an hour or two.
>
> (In reply to Cameron Berkenpas from comment #315)
>> That is a resounding yes! Unsurprisingly for AMD, PCI passthrough is
>> available.
>>
>> Is there anyone with a Legion 7 16ACHg6 who's up to setting up pci
>> passthrough for their sound card and compiling JCS's Qemu all to run a
>> Windows 10 VM? Someone can either try to do that for themselves or wait
>> for me and hope there's sufficient availability.
>>
>> On 6/25/2021 7:45 PM, <email address hidden> wrote:
>>> https://bugzilla.kernel.org/show_bug.cgi?id=208555
>>>
>>> --- Comment #314 from Pablitar (<email address hidden>) ---
>>> Here it is:
>>> [ 0.293604] iommu: Default domain type: Translated
>>> [ 0.487357] pci 0000:00:00.2: AMD-Vi: IOMMU performance counters
>> supported
>>> [ 0.487484] pci 0000:00:01.0: Adding to iommu group 0
>>> [ 0.487493] pci 0000:00:01.1: Adding to iommu group 1
>>> [ 0.487500] pci 0000:00:01.2: Adding to iommu group 2
>>> [ 0.487511] pci 0000:00:02.0: Adding to iommu group 3
>>> [ 0.487518] pci 0000:00:02.1: Adding to iommu group 4
>>> [ 0.487526] pci 0000:00:02.2: Adding to iommu group 5
>>> [ 0.487538] pci 0000:00:08.0: Adding to iommu group 6
>>> [ 0.487544] pci 0000:00:08.1: Adding to iommu group 6
>>> [ 0.487550] pci 0000:00:08.2: Adding to iommu group 6
>>> [ 0.487560] pci 0000:00:14.0: Adding to iommu group 7
>>> [ 0.487566] pci 0000:00:14.3: Adding to iommu group 7
>>> [ 0.487587] pci 0000:00:18.0: Adding to iommu group 8
>>> [ 0.487593] pci 0000:00:18.1: Adding to iommu group 8
>>> [ 0.487599] pci 0000:00:18.2: Adding to iommu group 8
>>> [ 0.487606] pci 0000:00:18.3: Adding to iommu group 8
>>> [ 0.487612] pci 0000:00:18.4: Adding to iommu group 8
>>> [ 0.487618] pci 0000:00:18.5: Adding to iommu group 8
>>> [ 0.487624] pci 0000:00:18.6: Adding to iommu group 8
>>> [ 0.487629] pci 0000:00:18.7: Adding to iommu group 8
>>> [ 0.487640] pci 0000:01:00.0: Adding to iommu group 9
>>> [ 0.487648] pci 0000:01:00.1: Adding to iommu group 9
>>> [ 0.487656] pci 0000:02:00.0: Adding to iommu group 10
>>> [ 0.487664] pci 0000:03:00.0: Adding to iommu group 11
>>> [ 0.487671] pci 0000:04:00.0: Adding to iommu group 12
>>> [ 0.487685] pci 0000:05:00.0: Adding to iommu group 6
>>> [ 0.487688] pci 0000:05:00.2: Adding to iommu group 6
>>> [ 0.487693] pci 0000:05:00.3: Adding to iommu group 6
>>> [ 0.487696] pci 0000:05:00.4: Adding to iommu group 6
>>> [ 0.487700] pci 0000:05:00.6: Adding to iommu group 6
>>> [ 0.487703] pci 0000:06:00.0: Adding to iommu group 6
>>> [ 0.487707] pci 0000:06:00.1: Adding to iommu group 6
>>> [ 0.489073] pci 0000:00:00.2: AMD-Vi: Found IOMMU cap 0x40
>>> [ 0.490935] perf/amd_iommu: Detected AMD IOMMU #0 (2 banks, 4
>>> counters/bank).
>>> [ 0.535396] AMD-Vi: AMD IOMMUv2 driver by Joerg Roedel <email address hidden>
>>>
>>> Seems it is supported?
>>>
>>> (In reply to Cameron Berkenpas from comment #312)
>>>> Maybe try:
>>>>
>>>> dmesg | grep -i iommu
>>>>
>>>> On 6/25/2021 6:24 PM, Cameron Berkenpas wrote:
>>>>> You're welcome. I understand the frustration!
>>>>>
>>>>> Can you or anyone else with a Legion 7 16ACHg6 check if your CPU has
>>>>> IOMMU support? I'm not able to find an answer to this one way or
>>>>> another. If so, likely the same trick can be used to find the codec
>>>>> initialization verb sequence.
>>>>>
>>>>>
>>>>> On 6/25/21 5:06 PM, <email address hidden> wrote:
>>>>>> https://bugzilla.kernel.org/show_bug.cgi?id=208555
>>>>>>
>>>>>> --- Comment #307 from Pablitar (<email address hidden>) ---
>>>>>> And thank you so much for what you are doing Cameron!
>>>>>>
>>>>>> (In reply to Cameron Berkenpas from comment #305)
>>>>>>> You're not the first person to report that these fixes don't work for
>>>>>>> the 2021 Legion.
>>>>>>>
>>>>>>> Can you post your alsa-info?
>>>>>>>
>>>>>>> I'd like to order one as soon as they become available here in the USA,
>>>>>>> but I'm unsure what the availability will be. If I managed to snag one,
>>>>>>> I'll work on getting sound working there too.
>>>>>>>
>>>>>>> On 6/25/21 4:52 PM, <email address hidden> wrote:
>>>>>>>> https://bugzilla.kernel.org/show_bug.cgi?id=208555
>>>>>>>>
>>>>>>>> Pablitar (<email address hidden>) changed:
>>>>>>>>
>>>>>>>>              What    |Removed                     |Added
>>>>>>>>
>> ----------------------------------------------------------------------------
>>>>>>>> CC|                            |<email address hidden>
>>>>>>>>
>>>>>>>> --- Comment #304 from Pablitar (<email address hidden>) ---
>>>>>>>> Hey!
>>>>>>>>
>>>>>>>> I've tested some of these fixes on my Lenovo 16ACHg6 and had no luck.
>>>>>>>>
>>>>>>>> What I've tested:
>>>>>>>> - Using the applyverbs.py with verbs-working.txt
>>>>>>>> - Applying the legion-alc287-0.0.4.patch as per instructions
>>>>>>>> - Applying the legion-alc287-0.0.5.patch as per instructions
>>>>>>>>
>>>>>>>> Something that may be important is that this new model is running
>>>>>>>> an AMD
>>>>>>>> processor and the sound controller appears as:
>>>>>>>>
>>>>>>>> 'Audio device: Advanced Micro Devices, Inc. [AMD] Family 17h (Models
>>>>>>> 10h-1fh)
>>>>>>>> HD Audio Controller'
>>>>>>>>
>>>>>>>> On Alsa Mixer, it says the "Chip" is ALC287 but the "Card" is HD-Audio
>>>>>>>> Generic.
>>>>>>>>
>>>>>>>> Is that important? I'm bringing this up because the instructions say:
>>>>>>>>
>>>>>>>> # Patch file to enable output on speakers.
>>>>>>>> options snd-hda-intel patch=legion-alc287-0.0.4.patch
>>>>>>>>
>>>>>>>> And the intel part there may be something to change?
>>>>>>>>
>>>>>>>> But honestly I'm clueless so this may be waaay off.
>>>>>>>>
>>>>>>>> Thanks in advance!
>>>>>>>>