PCI: Create device links for AMD integrated USB xHCI and UCSI controllers
Subsystems (2)
PATCH 1/1 PCI: Create device links for AMD integrated USB xHCI and UCSI controllers
Latest AMD GPUs have built-in USB xHCI and UCSI controllers. Add device link support for them.
--- drivers/pci/quirks.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/pci/quirks.c +7 -2
@@ -5338,7 +5338,7 @@ DECLARE_PCI_FIXUP_CLASS_FINAL(PCI_VENDOR_ID_NVIDIA, PCI_ANY_ID, PCI_CLASS_MULTIMEDIA_HD_AUDIO, 8, quirk_gpu_hda);/* -* Create device link for NVIDIA GPU with integrated USB xHCI Host +* Create device link for GPUs with integrated USB xHCI Host * controller to VGA. */ static void quirk_gpu_usb (struct pci_dev *usb)
@@ -5347,9 +5347,11 @@ static void quirk_gpu_usb(struct pci_dev *usb) }DECLARE_PCI_FIXUP_CLASS_FINAL (PCI_VENDOR_ID_NVIDIA ,PCI_ANY_ID ,PCI_CLASS_SERIAL_USB ,8 , quirk_gpu_usb); +DECLARE_PCI_FIXUP_CLASS_FINAL (PCI_VENDOR_ID_ATI ,PCI_ANY_ID , +PCI_CLASS_SERIAL_USB ,8 , quirk_gpu_usb);/* -* Create device link for NVIDIA GPU with integrated Type-C UCSI controller +* Create device link for GPUs with integrated Type-C UCSI controller * to VGA. Currently there is no class code defined for UCSI device over PCI * so using UNKNOWN class for now and it will be updated when UCSI * over PCI gets a class code.
@@ -5362,6 +5364,9 @@ static void quirk_gpu_usb_typec_ucsi(struct pci_dev *ucsi)DECLARE_PCI_FIXUP_CLASS_FINAL (PCI_VENDOR_ID_NVIDIA ,PCI_ANY_ID ,PCI_CLASS_SERIAL_UNKNOWN ,8 , quirk_gpu_usb_typec_ucsi); +DECLARE_PCI_FIXUP_CLASS_FINAL (PCI_VENDOR_ID_ATI ,PCI_ANY_ID , +PCI_CLASS_SERIAL_UNKNOWN ,8 , + quirk_gpu_usb_typec_ucsi);/* * Enable the NVIDIA GPU integrated HDA controller if the BIOS left it
Signature · 1 line
2.29.0
Quoted 2 lines · Evan Quan
Latest AMD GPUs have built-in USB xHCI and UCSI controllers. Add device link support for them.
Please comment on https://git.kernel.org/linus/6d2e369f0d4c .
Is there something the PCI core is missing here? Or is there something that needs to be added to ACPI or the PCI firmware spec?
We want a generic way to discover dependencies like this.
A quirk should not be necessary for spec-compliant devices. Quirks are an ongoing maintenance burden, and they mean that new hardware won't work correctly until the OS is patched to know about it. That's not what we want.
I expect we'll still need *this* quirk, but first I'd like to know whether there's a plan to handle this more generically in the future.
When you repost this, please follow the subject line style of 6d2e369f0d4c ("PCI: Add NVIDIA GPU multi-function power dependencies") so similar patches look similar.
Quoted 45 lines
Signed-off-by Evan Quan <[email protected]>--- drivers/pci/quirks.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)drivers/pci/quirks.c +7
-2@@ -5338,7 +5338,7 @@ DECLARE_PCI_FIXUP_CLASS_FINAL(PCI_VENDOR_ID_NVIDIA, PCI_ANY_ID, PCI_CLASS_MULTIMEDIA_HD_AUDIO, 8, quirk_gpu_hda);/* -* Create device link for NVIDIA GPU with integrated USB xHCI Host +* Create device link for GPUs with integrated USB xHCI Host * controller to VGA. */ static void quirk_gpu_usb (struct pci_dev *usb)@@ -5347,9 +5347,11 @@ static void quirk_gpu_usb(struct pci_dev *usb) }DECLARE_PCI_FIXUP_CLASS_FINAL (PCI_VENDOR_ID_NVIDIA ,PCI_ANY_ID ,PCI_CLASS_SERIAL_USB ,8 , quirk_gpu_usb); +DECLARE_PCI_FIXUP_CLASS_FINAL (PCI_VENDOR_ID_ATI ,PCI_ANY_ID , +PCI_CLASS_SERIAL_USB ,8 , quirk_gpu_usb);/* -* Create device link for NVIDIA GPU with integrated Type-C UCSI controller +* Create device link for GPUs with integrated Type-C UCSI controller * to VGA. Currently there is no class code defined for UCSI device over PCI * so using UNKNOWN class for now and it will be updated when UCSI * over PCI gets a class code. @@ -5362,6 +5364,9 @@ static void quirk_gpu_usb_typec_ucsi(struct pci_dev *ucsi)DECLARE_PCI_FIXUP_CLASS_FINAL (PCI_VENDOR_ID_NVIDIA ,PCI_ANY_ID ,PCI_CLASS_SERIAL_UNKNOWN ,8 , quirk_gpu_usb_typec_ucsi); +DECLARE_PCI_FIXUP_CLASS_FINAL (PCI_VENDOR_ID_ATI ,PCI_ANY_ID , +PCI_CLASS_SERIAL_UNKNOWN ,8 , + quirk_gpu_usb_typec_ucsi);/* * Enable the NVIDIA GPU integrated HDA controller if the BIOS left it Signature · 1 line
2.29.0
[Public]
Quoted 27 lines
-----Original Message-----
From: Bjorn Helgaas <[email protected]>
Sent: Friday, September 3, 2021 3:55 PM
To: Quan, Evan <[email protected]>
Cc: [email protected]; [email protected]; Deucher, Alexander <[email protected]>; [email protected]
Subject: Re: [PATCH] PCI: Create device links for AMD integrated USB xHCI and UCSI controllersQuoted 2 lines · Evan Quan
Latest AMD GPUs have built-in USB xHCI and UCSI controllers. Add device link support for them.
Please comment on
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgit.k
ernel.org%2Flinus%2F6d2e369f0d4c&data=04%7C01%7CAlexander.Deu cher%40amd.com%7C9fa0d66e5f29424df36b08d96f14c710%7C3dd8961fe488 4e608e11a82d994e183d%7C0%7C0%7C637662957313172831%7CUnknown%7 CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwi LCJXVCI6Mn0%3D%7C1000&sdata=6IlPLWlcO7iptbTqfh71fe5wmHN7RN 13OvScyYaWyI8%3D&reserved=0 .Is there something the PCI core is missing here? Or is there something that needs to be added to ACPI or the PCI firmware spec?
We want a generic way to discover dependencies like this.
Quoted 7 lines
A quirk should not be necessary for spec-compliant devices. Quirks are an ongoing maintenance burden, and they mean that new hardware won't work correctly until the OS is patched to know about it. That's not what we want.
I expect we'll still need *this* quirk, but first I'd like to know whether there's a plan to handle this more generically in the future.
The requirement here is that all of the additional endpoints are dependencies for powering down the GPU. E.g., the audio controller and USB endpoints need to be in d3 before you put the GPU into d3, otherwise the non-GPU endpoints will be powered down as well behind their drivers' backs. On newer AMD hardware there is logic in the hardware to wait for all dependent devices to go into d3 before powering down everything or power up everything if anything enters d0, but this requires additional software setup in the GPU driver as well and older versions of the driver didn't set this up correctly, instead relying on software logic via dependencies. Earlier hardware didn't have that logic and needed software help. That said, I think all of the relevant drivers expect the hardware state to be powered down when d3 is entered and they may not handle a wake up properly if not all devices entered d3 and hence all of the devices never entered a powered down state.
Alex
Quoted 55 lines
When you repost this, please follow the subject line style of
6d2e369f0d4c("PCI: Add NVIDIA GPU multi-function power
dependencies") so similar patches look similar.drivers/pci/quirks.c
Quoted 11 lines
Signed-off-by Evan Quan <[email protected]>--- drivers/pci/quirks.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)drivers/pci/quirks.c index renamed from drivers/pci/quirks.c +0
-0
dea10d62d5b9..f0c5dd3406a1100644drivers/pci/quirks.c +0
-0@@ -5338,7 +5338,7 @@DECLARE_PCI_FIXUP_CLASS_FINAL(PCI_VENDOR_ID_NVIDIA,
PCI_ANY_ID,drivers/pci/quirks.c line 5338
Quoted 1 line
drivers/pci/quirks.c +0
-0PCI_CLASS_MULTIMEDIA_HD_AUDIO, 8,
quirk_gpu_hda);Quoted 9 lines
drivers/pci/quirks.c +1
-1/* -* Create device link for NVIDIA GPU with integrated USB xHCI Host +* Create device link for GPUs with integrated USB xHCI Host * controller to VGA. */ static void quirk_gpu_usb(struct pci_dev *usb) @@ -5347,9 +5347,11 @@ static void quirk_gpu_usb(struct pci_dev *usb) }DECLARE_PCI_FIXUP_CLASS_FINAL(PCI_VENDOR_ID_NVIDIA,
PCI_ANY_ID,drivers/pci/quirks.c static void quirk_gpu_usb_typec_ucsi(struct · line 5364
Quoted 13 lines
drivers/pci/quirks.c +2
-1PCI_CLASS_SERIAL_USB, 8, quirk_gpu_usb); +DECLARE_PCI_FIXUP_CLASS_FINAL (PCI_VENDOR_ID_ATI ,PCI_ANY_ID , +PCI_CLASS_SERIAL_USB ,8 , quirk_gpu_usb);/* -* Create device link for NVIDIA GPU with integrated Type-C UCSI controller
+ * Create device link for GPUs with integrated Type-C UCSI controller
* to VGA. Currently there is no class code defined for UCSI device over PCI
* so using UNKNOWN class for now and it will be updated when UCSI
* over PCI gets a class code.drivers/pci/quirks.c +0
-0@@ -5362,6 +5364,9 @@ static void quirk_gpu_usb_typec_ucsi(struct pci_dev *ucsi)DECLARE_PCI_FIXUP_CLASS_FINAL(PCI_VENDOR_ID_NVIDIA,
PCI_ANY_ID,Quoted 12 lines
drivers/pci/quirks.c +3
-0PCI_CLASS_SERIAL_UNKNOWN ,8 , quirk_gpu_usb_typec_ucsi); +DECLARE_PCI_FIXUP_CLASS_FINAL (PCI_VENDOR_ID_ATI ,PCI_ANY_ID , +PCI_CLASS_SERIAL_UNKNOWN ,8 , + quirk_gpu_usb_typec_ucsi);/* * Enable the NVIDIA GPU integrated HDA controller if the BIOS left it
--
2.29.0
[+cc Rafael, beginning of thread:
https://lore.kernel.org/all/[email protected]/]
Quoted 36 lines · Alexander
Quoted 27 lines
-----Original Message-----
From: Bjorn Helgaas <[email protected]>
Sent: Friday, September 3, 2021 3:55 PM
To: Quan, Evan <[email protected]>
Cc: [email protected]; [email protected]; Deucher, Alexander <[email protected]>; [email protected]
Subject: Re: [PATCH] PCI: Create device links for AMD integrated USB xHCI and UCSI controllersQuoted 2 lines · Evan Quan
Latest AMD GPUs have built-in USB xHCI and UCSI controllers. Add device link support for them.
Please comment on
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgit.k
ernel.org%2Flinus%2F6d2e369f0d4c&data=04%7C01%7CAlexander.Deu cher%40amd.com%7C9fa0d66e5f29424df36b08d96f14c710%7C3dd8961fe488 4e608e11a82d994e183d%7C0%7C0%7C637662957313172831%7CUnknown%7 CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwi LCJXVCI6Mn0%3D%7C1000&sdata=6IlPLWlcO7iptbTqfh71fe5wmHN7RN 13OvScyYaWyI8%3D&reserved=0 .Is there something the PCI core is missing here? Or is there something that needs to be added to ACPI or the PCI firmware spec?
We want a generic way to discover dependencies like this.
Quoted 8 lines
A quirk should not be necessary for spec-compliant devices. Quirks are an ongoing maintenance burden, and they mean that new hardware won't work correctly until the OS is patched to know about it. That's not what we want.
I expect we'll still need *this* quirk, but first I'd like to know whether there's a plan to handle this more generically in the future.
Quoted 15 lines
The requirement here is that all of the additional endpoints are dependencies for powering down the GPU. E.g., the audio controller and USB endpoints need to be in d3 before you put the GPU into d3, otherwise the non-GPU endpoints will be powered down as well behind their drivers' backs. On newer AMD hardware there is logic in the hardware to wait for all dependent devices to go into d3 before powering down everything or power up everything if anything enters d0, but this requires additional software setup in the GPU driver as well and older versions of the driver didn't set this up correctly, instead relying on software logic via dependencies. Earlier hardware didn't have that logic and needed software help. That said, I think all of the relevant drivers expect the hardware state to be powered down when d3 is entered and they may not handle a wake up properly if not all devices entered d3 and hence all of the devices never entered a powered down state.
I'm not sure whether this answered my question. Will we need more quirks for future devices?
You said "On newer AMD hardware there is logic to wait for all dependent devices to go to d3 ...," which sounds promising, but then it "requires additional setup in the GPU driver."
So maybe PM works as per PCIe spec, but only after the driver sets things up? I'm not sure what, if any, PM we do before a driver claims the device.
The above suggests that if we put some (but not all) functions, in D3, the new logic will keep them from entering D3 until later. That doesn't really *sound* spec-compliant -- if we write D3 to a function's PCI_PM_CTRL and then read it back, the function will remain in D0 indefinitely, until we put that last function in D3?
pci_raw_set_power_state() does this read then write, and it expects PCI_PM_CTRL to change to the new state after the delay prescribed by the spec, which of course has nothing to do with sibling functions.
And if all the functions are in D3, and we write D0 to one function's PCI_PM_CTRL, *all* the functions magically go to D0? That sounds potentially confusing.
Bjorn
[Public]
Quoted 92 lines
-----Original Message-----
From: Bjorn Helgaas <[email protected]>
Sent: Tuesday, September 7, 2021 1:35 PM
To: Deucher, Alexander <[email protected]>
Cc: Quan, Evan <[email protected]>; [email protected]; [email protected]; [email protected]; Rafael J. Wysocki <[email protected]>
Subject: Re: [PATCH] PCI: Create device links for AMD integrated USB xHCI and UCSI controllers[+cc Rafael, beginning of thread:
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flore.
kernel.org%2Fall%2F20210903063311.3606226-1- evan.quan%40amd.com%2F&data=04%7C01%7CAlexander.Deucher%4 0amd.com%7C48f3a6f7639343fcad6208d97225da95%7C3dd8961fe4884e608e 11a82d994e183d%7C0%7C0%7C637666329177869121%7CUnknown%7CTWFp bGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVC I6Mn0%3D%7C1000&sdata=k%2FgSHhtLiS8xS5hNkaP%2BOWWMWqiM 4tgQk4bybfumvfM%3D&reserved=0]Quoted 9 lines · Alexander
Quoted 9 lines
-----Original Message-----
From: Bjorn Helgaas <[email protected]>
Sent: Friday, September 3, 2021 3:55 PM
To: Quan, Evan <[email protected]>
Cc: [email protected]; [email protected]; Deucher, Alexander <[email protected]>; [email protected]
Subject: Re: [PATCH] PCI: Create device links for AMD integrated USB xHCI and UCSI controllersQuoted 6 lines
Quoted 6 lines · Evan Quan
Quoted 2 lines
Latest AMD GPUs have built-in USB xHCI and UCSI controllers. Add device link support for them.
Please comment on
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgi
Quoted 1 line
Quoted 1 line
t.k%2F&data=04%7C01%7CAlexander.Deucher%40amd.com%7C48f3a6f 76393
Quoted 1 line
Quoted 1 line
43fcad6208d97225da95%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0 %7C63
Quoted 1 line
Quoted 1 line
7666329177869121%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMD AiLCJQIjo
Quoted 1 line
Quoted 1 line
iV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=0yxZbS6o P56
Quoted 2 lines
Quoted 2 lines
rXpA5j1wvlMpkp9Ern%2FcSRCPELtv47lM%3D&reserved=0
ernel.org%2Flinus%2F6d2e369f0d4c&data=04%7C01%7CAlexander.Deu
Quoted 1 line
Quoted 1 line
cher%40amd.com%7C9fa0d66e5f29424df36b08d96f14c710%7C3dd8961fe488
Quoted 1 line
Quoted 1 line
4e608e11a82d994e183d%7C0%7C0%7C637662957313172831%7CUnknown%7
Quoted 1 line
Quoted 1 line
CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwi
Quoted 1 line
Quoted 1 line
LCJXVCI6Mn0%3D%7C1000&sdata=6IlPLWlcO7iptbTqfh71fe5wmHN7RN
Quoted 16 lines
Quoted 7 lines
13OvScyYaWyI8%3D&reserved=0 .
Is there something the PCI core is missing here? Or is there something that needs to be added to ACPI or the PCI firmware spec?
We want a generic way to discover dependencies like this.
Quoted 8 lines
A quirk should not be necessary for spec-compliant devices. Quirks are an ongoing maintenance burden, and they mean that new hardware won't work correctly until the OS is patched to know about it. That's not what we want.
I expect we'll still need *this* quirk, but first I'd like to know whether there's a plan to handle this more generically in the future.
Quoted 15 lines
The requirement here is that all of the additional endpoints are dependencies for powering down the GPU. E.g., the audio controller and USB endpoints need to be in d3 before you put the GPU into d3, otherwise the non-GPU endpoints will be powered down as well behind their drivers' backs. On newer AMD hardware there is logic in the hardware to wait for all dependent devices to go into d3 before powering down everything or power up everything if anything enters d0, but this requires additional software setup in the GPU driver as well and older versions of the driver didn't set this up correctly, instead relying on software logic via dependencies. Earlier hardware didn't have that logic and needed software help. That said, I think all of the relevant drivers expect the hardware state to be powered down when d3 is entered and they may not handle a wake up properly if not all devices entered d3 and hence all of the devices never entered a powered down state.
Quoted 2 lines
I'm not sure whether this answered my question. Will we need more quirks for future devices?
The existing quirks should cover all devices unless we add some new endpoint to the GPUs in the future. The quirk for the audio dependency was added years ago and hasn't needed to be extended since. The USB stuff was added more recently and requires adding a similar quirk.
Quoted 8 lines
You said "On newer AMD hardware there is logic to wait for all dependent devices to go to d3 ...," which sounds promising, but then it "requires additional setup in the GPU driver."
So maybe PM works as per PCIe spec, but only after the driver sets things up? I'm not sure what, if any, PM we do before a driver claims the device.
I'm not exactly sure what the expectation is with regards to the spec. There is a single power rail that controls all of the endpoints so all have to be in d3 before the power can be cut.
Quoted 6 lines
The above suggests that if we put some (but not all) functions, in D3, the new logic will keep them from entering D3 until later. That doesn't really *sound* spec-compliant -- if we write D3 to a function's
PCI_PM_CTRLand then read it back, the function will remain in D0 indefinitely, until we put that last function in D3?
It will read back as if the card is in D3, but the power rail stays on until all devices have been put into D3.
Quoted 7 lines
pci_raw_set_power_state()does this read then write, and it expectsPCI_PM_CTRLto change to the new state after the delay prescribed by the spec, which of course has nothing to do with sibling functions.And if all the functions are in D3, and we write D0 to one function's
PCI_PM_CTRL, *all* the functions magically go to D0? That sounds potentially confusing.
The will all individually report the correct D state, it's just that they will be using more power than if they were all in D3.
Alex
Quoted 2 lines
Bjorn
Quoted 94 lines · Alexander
[Public]
Quoted 92 lines
-----Original Message-----
From: Bjorn Helgaas <[email protected]>
Sent: Tuesday, September 7, 2021 1:35 PM
To: Deucher, Alexander <[email protected]>
Cc: Quan, Evan <[email protected]>; [email protected]; [email protected]; [email protected]; Rafael J. Wysocki <[email protected]>
Subject: Re: [PATCH] PCI: Create device links for AMD integrated USB xHCI and UCSI controllers[+cc Rafael, beginning of thread:
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flore.
kernel.org%2Fall%2F20210903063311.3606226-1- evan.quan%40amd.com%2F&data=04%7C01%7CAlexander.Deucher%4 0amd.com%7C48f3a6f7639343fcad6208d97225da95%7C3dd8961fe4884e608e 11a82d994e183d%7C0%7C0%7C637666329177869121%7CUnknown%7CTWFp bGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVC I6Mn0%3D%7C1000&sdata=k%2FgSHhtLiS8xS5hNkaP%2BOWWMWqiM 4tgQk4bybfumvfM%3D&reserved=0]Quoted 9 lines · Alexander
Quoted 9 lines
-----Original Message-----
From: Bjorn Helgaas <[email protected]>
Sent: Friday, September 3, 2021 3:55 PM
To: Quan, Evan <[email protected]>
Cc: [email protected]; [email protected]; Deucher, Alexander <[email protected]>; [email protected]
Subject: Re: [PATCH] PCI: Create device links for AMD integrated USB xHCI and UCSI controllersQuoted 6 lines
Quoted 6 lines · Evan Quan
Quoted 2 lines
Latest AMD GPUs have built-in USB xHCI and UCSI controllers. Add device link support for them.
Please comment on
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgi
Quoted 1 line
Quoted 1 line
t.k%2F&data=04%7C01%7CAlexander.Deucher%40amd.com%7C48f3a6f 76393
Quoted 1 line
Quoted 1 line
43fcad6208d97225da95%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0 %7C63
Quoted 1 line
Quoted 1 line
7666329177869121%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMD AiLCJQIjo
Quoted 1 line
Quoted 1 line
iV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=0yxZbS6o P56
Quoted 2 lines
Quoted 2 lines
rXpA5j1wvlMpkp9Ern%2FcSRCPELtv47lM%3D&reserved=0
ernel.org%2Flinus%2F6d2e369f0d4c&data=04%7C01%7CAlexander.Deu
Quoted 1 line
Quoted 1 line
cher%40amd.com%7C9fa0d66e5f29424df36b08d96f14c710%7C3dd8961fe488
Quoted 1 line
Quoted 1 line
4e608e11a82d994e183d%7C0%7C0%7C637662957313172831%7CUnknown%7
Quoted 1 line
Quoted 1 line
CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwi
Quoted 1 line
Quoted 1 line
LCJXVCI6Mn0%3D%7C1000&sdata=6IlPLWlcO7iptbTqfh71fe5wmHN7RN
Quoted 31 lines
Quoted 7 lines
13OvScyYaWyI8%3D&reserved=0 .
Is there something the PCI core is missing here? Or is there something that needs to be added to ACPI or the PCI firmware spec?
We want a generic way to discover dependencies like this.
Quoted 8 lines
A quirk should not be necessary for spec-compliant devices. Quirks are an ongoing maintenance burden, and they mean that new hardware won't work correctly until the OS is patched to know about it. That's not what we want.
I expect we'll still need *this* quirk, but first I'd like to know whether there's a plan to handle this more generically in the future.
The requirement here is that all of the additional endpoints are dependencies for powering down the GPU. E.g., the audio controller and USB endpoints need to be in d3 before you put the GPU into d3, otherwise the non-GPU endpoints will be powered down as well behind their drivers' backs. On newer AMD hardware there is logic in the hardware to wait for all dependent devices to go into d3 before powering down everything or power up everything if anything enters d0, but this requires additional software setup in the GPU driver as well and older versions of the driver didn't set this up correctly, instead relying on software logic via dependencies. Earlier hardware didn't have that logic and needed software help. That said, I think all of the relevant drivers expect the hardware state to be powered down when d3 is entered and they may not handle a wake up properly if not all devices entered d3 and hence all of the devices never entered a powered down state.
Quoted 8 lines
Quoted 2 lines
I'm not sure whether this answered my question. Will we need more quirks for future devices?
The existing quirks should cover all devices unless we add some new endpoint to the GPUs in the future. The quirk for the audio dependency was added years ago and hasn't needed to be extended since. The USB stuff was added more recently and requires adding a similar quirk.
Oh, I see, these quirks don't actually have specific Device IDs in them; they are generic for *all* PCI_VENDOR_ID_ATI USB devices (and pci_create_device_link() checks for a PCI_BASE_CLASS_DISPLAY function in the same device. So it's only when you add a new *class* of device dependency. Thanks for clearing that up!
Quoted 28 lines
Quoted 8 lines
You said "On newer AMD hardware there is logic to wait for all dependent devices to go to d3 ...," which sounds promising, but then it "requires additional setup in the GPU driver."
So maybe PM works as per PCIe spec, but only after the driver sets things up? I'm not sure what, if any, PM we do before a driver claims the device.
I'm not exactly sure what the expectation is with regards to the spec. There is a single power rail that controls all of the endpoints so all have to be in d3 before the power can be cut.
Quoted 6 lines
The above suggests that if we put some (but not all) functions, in D3, the new logic will keep them from entering D3 until later. That doesn't really *sound* spec-compliant -- if we write D3 to a function's
PCI_PM_CTRLand then read it back, the function will remain in D0 indefinitely, until we put that last function in D3?It will read back as if the card is in D3, but the power rail stays on until all devices have been put into D3.
Quoted 5 lines
pci_raw_set_power_state()does this read then write, and it expectsPCI_PM_CTRLto change to the new state after the delay prescribed by the spec, which of course has nothing to do with sibling functions.
Quoted 6 lines
Quoted 3 lines
And if all the functions are in D3, and we write D0 to one function's
PCI_PM_CTRL, *all* the functions magically go to D0? That sounds potentially confusing.The will all individually report the correct D state, it's just that they will be using more power than if they were all in D3.
OK, that all sounds fine, I think. Thanks!
Bjorn
Bjorn Helgaas
AppliedQuoted 5 lines · Evan Quan
Latest AMD GPUs have built-in USB xHCI and UCSI controllers. Add device link support for them.
Signed-off-by Evan Quan <[email protected]>
Applied to pci/pm for v5.16, thanks!
Quoted 43 lines
--- drivers/pci/quirks.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)drivers/pci/quirks.c +7
-2@@ -5338,7 +5338,7 @@ DECLARE_PCI_FIXUP_CLASS_FINAL(PCI_VENDOR_ID_NVIDIA, PCI_ANY_ID, PCI_CLASS_MULTIMEDIA_HD_AUDIO, 8, quirk_gpu_hda);/* -* Create device link for NVIDIA GPU with integrated USB xHCI Host +* Create device link for GPUs with integrated USB xHCI Host * controller to VGA. */ static void quirk_gpu_usb (struct pci_dev *usb)@@ -5347,9 +5347,11 @@ static void quirk_gpu_usb(struct pci_dev *usb) }DECLARE_PCI_FIXUP_CLASS_FINAL (PCI_VENDOR_ID_NVIDIA ,PCI_ANY_ID ,PCI_CLASS_SERIAL_USB ,8 , quirk_gpu_usb); +DECLARE_PCI_FIXUP_CLASS_FINAL (PCI_VENDOR_ID_ATI ,PCI_ANY_ID , +PCI_CLASS_SERIAL_USB ,8 , quirk_gpu_usb);/* -* Create device link for NVIDIA GPU with integrated Type-C UCSI controller +* Create device link for GPUs with integrated Type-C UCSI controller * to VGA. Currently there is no class code defined for UCSI device over PCI * so using UNKNOWN class for now and it will be updated when UCSI * over PCI gets a class code. @@ -5362,6 +5364,9 @@ static void quirk_gpu_usb_typec_ucsi(struct pci_dev *ucsi)DECLARE_PCI_FIXUP_CLASS_FINAL (PCI_VENDOR_ID_NVIDIA ,PCI_ANY_ID ,PCI_CLASS_SERIAL_UNKNOWN ,8 , quirk_gpu_usb_typec_ucsi); +DECLARE_PCI_FIXUP_CLASS_FINAL (PCI_VENDOR_ID_ATI ,PCI_ANY_ID , +PCI_CLASS_SERIAL_UNKNOWN ,8 , + quirk_gpu_usb_typec_ucsi);/* * Enable the NVIDIA GPU integrated HDA controller if the BIOS left it Signature · 1 line
2.29.0
[Public]
Quoted 9 lines
-----Original Message-----
From: Bjorn Helgaas <[email protected]>
Sent: Tuesday, September 14, 2021 11:29 AM
To: Quan, Evan <[email protected]>
Cc: [email protected]; [email protected]; Deucher, Alexander <[email protected]>; [email protected]
Subject: Re: [PATCH] PCI: Create device links for AMD integrated USB xHCI and UCSI controllers
Quoted 8 lines
Quoted 5 lines · Evan Quan
Latest AMD GPUs have built-in USB xHCI and UCSI controllers. Add device link support for them.
Signed-off-by Evan Quan <[email protected]>Applied to pci/pm for v5.16, thanks!
Any chance we can get this applied for 5.15/stable? This fixes runtime pm problems on GPU boards with integrated USB.
https://gitlab.freedesktop.org/drm/amd/-/issues/1704
Thanks,
Alex
Quoted 49 lines
drivers/pci/quirks.c
Quoted 10 lines
--- drivers/pci/quirks.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)drivers/pci/quirks.c index renamed from drivers/pci/quirks.c +0
-0
dea10d62d5b9..f0c5dd3406a1100644drivers/pci/quirks.c +0
-0@@ -5338,7 +5338,7 @@DECLARE_PCI_FIXUP_CLASS_FINAL(PCI_VENDOR_ID_NVIDIA,
PCI_ANY_ID,drivers/pci/quirks.c line 5338
Quoted 1 line
drivers/pci/quirks.c +0
-0PCI_CLASS_MULTIMEDIA_HD_AUDIO, 8,
quirk_gpu_hda);Quoted 9 lines
drivers/pci/quirks.c +1
-1/* -* Create device link for NVIDIA GPU with integrated USB xHCI Host +* Create device link for GPUs with integrated USB xHCI Host * controller to VGA. */ static void quirk_gpu_usb(struct pci_dev *usb) @@ -5347,9 +5347,11 @@ static void quirk_gpu_usb(struct pci_dev *usb) }DECLARE_PCI_FIXUP_CLASS_FINAL(PCI_VENDOR_ID_NVIDIA,
PCI_ANY_ID,drivers/pci/quirks.c static void quirk_gpu_usb_typec_ucsi(struct · line 5364
Quoted 13 lines
drivers/pci/quirks.c +2
-1PCI_CLASS_SERIAL_USB, 8, quirk_gpu_usb); +DECLARE_PCI_FIXUP_CLASS_FINAL (PCI_VENDOR_ID_ATI ,PCI_ANY_ID , +PCI_CLASS_SERIAL_USB ,8 , quirk_gpu_usb);/* -* Create device link for NVIDIA GPU with integrated Type-C UCSI controller
+ * Create device link for GPUs with integrated Type-C UCSI controller
* to VGA. Currently there is no class code defined for UCSI device over PCI
* so using UNKNOWN class for now and it will be updated when UCSI
* over PCI gets a class code.drivers/pci/quirks.c +0
-0@@ -5362,6 +5364,9 @@ static void quirk_gpu_usb_typec_ucsi(struct pci_dev *ucsi)DECLARE_PCI_FIXUP_CLASS_FINAL(PCI_VENDOR_ID_NVIDIA,
PCI_ANY_ID,Quoted 12 lines
drivers/pci/quirks.c +3
-0PCI_CLASS_SERIAL_UNKNOWN ,8 , quirk_gpu_usb_typec_ucsi); +DECLARE_PCI_FIXUP_CLASS_FINAL (PCI_VENDOR_ID_ATI ,PCI_ANY_ID , +PCI_CLASS_SERIAL_UNKNOWN ,8 , + quirk_gpu_usb_typec_ucsi);/* * Enable the NVIDIA GPU integrated HDA controller if the BIOS left it
--
2.29.0
Quoted 15 lines · Alexander
[Public]
Quoted 13 lines
-----Original Message-----
From: Bjorn Helgaas <[email protected]>
Sent: Tuesday, September 14, 2021 11:29 AM
To: Quan, Evan <[email protected]>
Cc: [email protected]; [email protected]; Deucher, Alexander <[email protected]>; [email protected]
Subject: Re: [PATCH] PCI: Create device links for AMD integrated USB xHCI and UCSI controllersQuoted 3 lines · Evan Quan
Latest AMD GPUs have built-in USB xHCI and UCSI controllers. Add device link support for them.
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
Signed-off-by Evan Quan <[email protected]>Applied to pci/pm for v5.16, thanks!
Any chance we can get this applied for 5.15/stable? This fixes runtime pm problems on GPU boards with integrated USB.
https://gitlab.freedesktop.org/drm/amd/-/issues/1704
Thanks for the link. It's always nice to have a clue about what problems a quirk fixes.
I added the link to the commit log and moved the whole thing to for-linus for v5.15.
Quoted 53 lines
Thanks,
Alex
Quoted 49 lines
drivers/pci/quirks.c
Quoted 10 lines
--- drivers/pci/quirks.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)drivers/pci/quirks.c index renamed from drivers/pci/quirks.c +0
-0
dea10d62d5b9..f0c5dd3406a1100644drivers/pci/quirks.c +0
-0@@ -5338,7 +5338,7 @@DECLARE_PCI_FIXUP_CLASS_FINAL(PCI_VENDOR_ID_NVIDIA,
PCI_ANY_ID,drivers/pci/quirks.c line 5338
Quoted 1 line
drivers/pci/quirks.c +0
-0PCI_CLASS_MULTIMEDIA_HD_AUDIO, 8,
quirk_gpu_hda);Quoted 9 lines
drivers/pci/quirks.c +1
-1/* -* Create device link for NVIDIA GPU with integrated USB xHCI Host +* Create device link for GPUs with integrated USB xHCI Host * controller to VGA. */ static void quirk_gpu_usb(struct pci_dev *usb) @@ -5347,9 +5347,11 @@ static void quirk_gpu_usb(struct pci_dev *usb) }DECLARE_PCI_FIXUP_CLASS_FINAL(PCI_VENDOR_ID_NVIDIA,
PCI_ANY_ID,drivers/pci/quirks.c static void quirk_gpu_usb_typec_ucsi(struct · line 5364
Quoted 13 lines
drivers/pci/quirks.c +2
-1PCI_CLASS_SERIAL_USB, 8, quirk_gpu_usb); +DECLARE_PCI_FIXUP_CLASS_FINAL (PCI_VENDOR_ID_ATI ,PCI_ANY_ID , +PCI_CLASS_SERIAL_USB ,8 , quirk_gpu_usb);/* -* Create device link for NVIDIA GPU with integrated Type-C UCSI controller
+ * Create device link for GPUs with integrated Type-C UCSI controller
* to VGA. Currently there is no class code defined for UCSI device over PCI
* so using UNKNOWN class for now and it will be updated when UCSI
* over PCI gets a class code.drivers/pci/quirks.c +0
-0@@ -5362,6 +5364,9 @@ static void quirk_gpu_usb_typec_ucsi(struct pci_dev *ucsi)DECLARE_PCI_FIXUP_CLASS_FINAL(PCI_VENDOR_ID_NVIDIA,
PCI_ANY_ID,Quoted 12 lines
drivers/pci/quirks.c +3
-0PCI_CLASS_SERIAL_UNKNOWN ,8 , quirk_gpu_usb_typec_ucsi); +DECLARE_PCI_FIXUP_CLASS_FINAL (PCI_VENDOR_ID_ATI ,PCI_ANY_ID , +PCI_CLASS_SERIAL_UNKNOWN ,8 , + quirk_gpu_usb_typec_ucsi);/* * Enable the NVIDIA GPU integrated HDA controller if the BIOS left it
--
2.29.0