* ASPM after Hotplug Question @ 2017-01-22 1:35 Sinan Kaya 2017-01-22 14:48 ` Bjorn Helgaas 0 siblings, 1 reply; 5+ messages in thread From: Sinan Kaya @ 2017-01-22 1:35 UTC (permalink / raw) To: Linux PCI When I boot the system, I see the ASPM is working fine. After hotplug removal and insertion, I see that the ASPM is disabled. I do not have any ASPM related kernel command line parameter and the policy is default. ASPM gets configured by the firmware before the OS boots by default unless powersave policy is passed to the kernel command line. Is there a particular reason why we are not re-configuring ASPM after hotplug insertion? I think default policy applies to power-up values but not for the hotplug case. With similar reasoning, maximum payload size gets configured by the firmware before boot. I see that the OS is re-configuring the MPS settings following hotplug. I feel like ASPM should have followed a similar policy. -- Sinan Kaya Qualcomm Datacenter Technologies, Inc. as an affiliate of Qualcomm Technologies, Inc. Qualcomm Technologies, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project. ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: ASPM after Hotplug Question 2017-01-22 1:35 ASPM after Hotplug Question Sinan Kaya @ 2017-01-22 14:48 ` Bjorn Helgaas 2017-01-22 19:06 ` Sinan Kaya 0 siblings, 1 reply; 5+ messages in thread From: Bjorn Helgaas @ 2017-01-22 14:48 UTC (permalink / raw) To: Sinan Kaya; +Cc: Linux PCI Hi Sinan, On Sat, Jan 21, 2017 at 08:35:30PM -0500, Sinan Kaya wrote: > When I boot the system, I see the ASPM is working fine. After hotplug removal > and insertion, I see that the ASPM is disabled. > > I do not have any ASPM related kernel command line parameter and > the policy is default. > > ASPM gets configured by the firmware before the OS boots by default > unless powersave policy is passed to the kernel command line. > > Is there a particular reason why we are not re-configuring ASPM after > hotplug insertion? > > I think default policy applies to power-up values but not for > the hotplug case. > > With similar reasoning, maximum payload size gets configured by > the firmware before boot. I see that the OS is re-configuring the > MPS settings following hotplug. > > I feel like ASPM should have followed a similar policy. Huh, I was just wondering whether ASPM would work on hot-added devices. I think the ASPM enumeration path is ugly because we only call it for bridges, not for endpoints (pci_scan_slot() calls pcie_aspm_init_link_state() for "bus->self"). I'd like it better if we called it for *every* device from pci_configure_device() and let ASPM internally figure out whether this is a bridge or endpoint. It looks like the intent is that pcie_aspm_init_link_state() allocates dev->link_state and configures ASPM on the link. The hotplug remove *should* call pcie_aspm_exit_link_state() on the bridge to free dev->link_state, and the hotplug add should call pcie_aspm_init_link_state() again to reallocate dev->link_state and configure ASPM again. But I'm not sure the remove path is correct. It looks like pci_stop_dev() calls pcie_aspm_exit_link_state(dev) on the device we're removing, not on the bridge. If that's the case, we won't free the dev->link_state, and when we call pcie_aspm_init_link_state() after the hotplug add, it will see that dev->link_state is already set and won't do anything. You could add some instrumentation to pcie_aspm_init_link_state() and pcie_aspm_exit_link_state() to see what devices we call them for, and whether they actually do what they should. Bjorn ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: ASPM after Hotplug Question 2017-01-22 14:48 ` Bjorn Helgaas @ 2017-01-22 19:06 ` Sinan Kaya 2017-01-22 19:08 ` Sinan Kaya 0 siblings, 1 reply; 5+ messages in thread From: Sinan Kaya @ 2017-01-22 19:06 UTC (permalink / raw) To: Bjorn Helgaas; +Cc: Linux PCI On 1/22/2017 9:48 AM, Bjorn Helgaas wrote: > Hi Sinan, > > On Sat, Jan 21, 2017 at 08:35:30PM -0500, Sinan Kaya wrote: >> When I boot the system, I see the ASPM is working fine. After hotplug removal >> and insertion, I see that the ASPM is disabled. >> >> I do not have any ASPM related kernel command line parameter and >> the policy is default. >> >> ASPM gets configured by the firmware before the OS boots by default >> unless powersave policy is passed to the kernel command line. >> >> Is there a particular reason why we are not re-configuring ASPM after >> hotplug insertion? >> >> I think default policy applies to power-up values but not for >> the hotplug case. >> >> With similar reasoning, maximum payload size gets configured by >> the firmware before boot. I see that the OS is re-configuring the >> MPS settings following hotplug. >> >> I feel like ASPM should have followed a similar policy. > > Huh, I was just wondering whether ASPM would work on hot-added devices. > > I think the ASPM enumeration path is ugly because we only call it for > bridges, not for endpoints (pci_scan_slot() calls > pcie_aspm_init_link_state() for "bus->self"). I'd like it better if > we called it for *every* device from pci_configure_device() and let > ASPM internally figure out whether this is a bridge or endpoint. > > It looks like the intent is that pcie_aspm_init_link_state() allocates > dev->link_state and configures ASPM on the link. The hotplug remove > *should* call pcie_aspm_exit_link_state() on the bridge to free > dev->link_state, and the hotplug add should call > pcie_aspm_init_link_state() again to reallocate dev->link_state and > configure ASPM again. > > But I'm not sure the remove path is correct. It looks like > pci_stop_dev() calls pcie_aspm_exit_link_state(dev) on the device > we're removing, not on the bridge. If that's the case, we won't free > the dev->link_state, and when we call pcie_aspm_init_link_state() > after the hotplug add, it will see that dev->link_state is already set > and won't do anything. > > You could add some instrumentation to pcie_aspm_init_link_state() and > pcie_aspm_exit_link_state() to see what devices we call them for, and > whether they actually do what they should. > > Bjorn > / # lspci 03:00:00.0 Class 0604: 17cb:0401 03:01:00.0 Class 0200: 8086:1572 03:01:00.1 Class 0200: 8086:1572 It looks like ASPM is only getting configured for the root port following insertion. Removal: [ 32.142474] pci 0003:01:00.1: pcie_aspm_exit_link_state:662 [ 34.142378] pci 0003:01:00.0: pcie_aspm_exit_link_state:659 Insertion: [ 35.910342] pcieport 0003:00:00.0: pcie_aspm_init_link_state:565 [ 35.931227] pcieport 0003:00:00.0: pcie_aspm_init_link_state:617 551 void pcie_aspm_init_link_state(struct pci_dev *pdev) 552 { 553 struct pcie_link_state *link; 554 int blacklist = !!pcie_aspm_sanity_check(pdev); 555 556 if (!aspm_support_enabled) { 557 dev_info(&pdev->dev, "%s:%d\n", __func__, __LINE__); 558 return; 559 } 560 561 if (pdev->link_state) { 562 dev_info(&pdev->dev, "%s:%d\n", __func__, __LINE__); 563 return; 564 } 565 dev_info(&pdev->dev, "%s:%d\n", __func__, __LINE__); 551 void pcie_aspm_init_link_state(struct pci_dev *pdev) 552 { ... 607 * At this stage drivers haven't had an opportunity to change the 608 * link policy setting. Enabling ASPM on broken hardware can cripple 609 * it even before the driver has had a chance to disable ASPM, so 610 * default to a safe level right now. If we're enabling ASPM beyond 611 * the BIOS's expectation, we'll do so once pci_enable_device() is 612 * called. 613 */ 614 if (aspm_policy != POLICY_POWERSAVE) { 615 pcie_config_aspm_path(link); 616 pcie_set_clkpm(link, policy_to_clkpm_state(link)); 617 dev_info(&pdev->dev, "%s:%d\n", __func__, __LINE__); 618 } else { 619 dev_info(&pdev->dev, "%s:%d\n", __func__, __LINE__); 620 } -- Sinan Kaya Qualcomm Datacenter Technologies, Inc. as an affiliate of Qualcomm Technologies, Inc. Qualcomm Technologies, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project. ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: ASPM after Hotplug Question 2017-01-22 19:06 ` Sinan Kaya @ 2017-01-22 19:08 ` Sinan Kaya 2017-01-23 15:35 ` Sinan Kaya 0 siblings, 1 reply; 5+ messages in thread From: Sinan Kaya @ 2017-01-22 19:08 UTC (permalink / raw) To: Bjorn Helgaas; +Cc: Linux PCI [snip] >> >> Bjorn >> > > / # lspci > 03:00:00.0 Class 0604: 17cb:0401 > 03:01:00.0 Class 0200: 8086:1572 > 03:01:00.1 Class 0200: 8086:1572 > > > It looks like ASPM is only getting configured for the root port following > insertion. > > Removal: > [ 32.142474] pci 0003:01:00.1: pcie_aspm_exit_link_state:662 > [ 34.142378] pci 0003:01:00.0: pcie_aspm_exit_link_state:659 > > Insertion: > [ 35.910342] pcieport 0003:00:00.0: pcie_aspm_init_link_state:565 > [ 35.931227] pcieport 0003:00:00.0: pcie_aspm_init_link_state:617 > > 551 void pcie_aspm_init_link_state(struct pci_dev *pdev) > 552 { > 553 struct pcie_link_state *link; > 554 int blacklist = !!pcie_aspm_sanity_check(pdev); > 555 > 556 if (!aspm_support_enabled) { > 557 dev_info(&pdev->dev, "%s:%d\n", __func__, __LINE__); > 558 return; > 559 } > 560 > 561 if (pdev->link_state) { > 562 dev_info(&pdev->dev, "%s:%d\n", __func__, __LINE__); > 563 return; > 564 } > 565 dev_info(&pdev->dev, "%s:%d\n", __func__, __LINE__); > > > 551 void pcie_aspm_init_link_state(struct pci_dev *pdev) > 552 { > ... > > 607 * At this stage drivers haven't had an opportunity to change the > 608 * link policy setting. Enabling ASPM on broken hardware can cripple > 609 * it even before the driver has had a chance to disable ASPM, so > 610 * default to a safe level right now. If we're enabling ASPM beyond > 611 * the BIOS's expectation, we'll do so once pci_enable_device() is > 612 * called. > 613 */ > 614 if (aspm_policy != POLICY_POWERSAVE) { > 615 pcie_config_aspm_path(link); > 616 pcie_set_clkpm(link, policy_to_clkpm_state(link)); > 617 dev_info(&pdev->dev, "%s:%d\n", __func__, __LINE__); > 618 } else { > 619 dev_info(&pdev->dev, "%s:%d\n", __func__, __LINE__); > 620 } > > > > Here is the exit path: 652 /* @pdev: the endpoint device */ 653 void pcie_aspm_exit_link_state(struct pci_dev *pdev) 654 { 655 struct pci_dev *parent = pdev->bus->self; 656 struct pcie_link_state *link, *root, *parent_link; 657 658 if (!parent || !parent->link_state) { 659 dev_info(&pdev->dev, "%s:%d\n", __func__, __LINE__); 660 return; 661 } 662 dev_info(&pdev->dev, "%s:%d\n", __func__, __LINE__); -- Sinan Kaya Qualcomm Datacenter Technologies, Inc. as an affiliate of Qualcomm Technologies, Inc. Qualcomm Technologies, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project. ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: ASPM after Hotplug Question 2017-01-22 19:08 ` Sinan Kaya @ 2017-01-23 15:35 ` Sinan Kaya 0 siblings, 0 replies; 5+ messages in thread From: Sinan Kaya @ 2017-01-23 15:35 UTC (permalink / raw) To: Bjorn Helgaas; +Cc: Linux PCI On 1/22/2017 2:08 PM, Sinan Kaya wrote: > [snip] > >>> >>> Bjorn >>> >> >> / # lspci >> 03:00:00.0 Class 0604: 17cb:0401 >> 03:01:00.0 Class 0200: 8086:1572 >> 03:01:00.1 Class 0200: 8086:1572 >> >> >> It looks like ASPM is only getting configured for the root port following >> insertion. >> >> Removal: >> [ 32.142474] pci 0003:01:00.1: pcie_aspm_exit_link_state:662 >> [ 34.142378] pci 0003:01:00.0: pcie_aspm_exit_link_state:659 >> >> Insertion: >> [ 35.910342] pcieport 0003:00:00.0: pcie_aspm_init_link_state:565 >> [ 35.931227] pcieport 0003:00:00.0: pcie_aspm_init_link_state:617 >> it looks like this is what is happening. hotplug insertion pcie_aspm_init_link_state pcie_config_aspm_path default policy, do nothing [ 128.691521] pcieport 0003:00:00.0: pcie_aspm_init_link_state:570 [ 128.712402] pcie_config_aspm_link:439 state=0 430 static void pcie_config_aspm_link(struct pcie_link_state *link, u32 state) 431 { 432 u32 upstream = 0, dwstream = 0; 433 struct pci_dev *child, *parent = link->pdev; 434 struct pci_bus *linkbus = parent->subordinate; 435 436 /* Nothing to do if the link is already in the requested state */ 437 state &= (link->aspm_capable & ~link->aspm_disable); 438 if (link->aspm_enabled == state) { 439 pr_info("%s:%d state=%d\n", __func__, __LINE__, state); 440 return; 441 } Should we add a new policy that comes through the hotplug insertion path? Regarding your question on why this is not being done in configure_device, probably the reason is that L0s and L1 needs to be enabled in a specific order before enabling on the root port. That must be the reason for attaching this code behavior. I think the real problem is the assumption default policy on the hotplug insertion path. -- Sinan Kaya Qualcomm Datacenter Technologies, Inc. as an affiliate of Qualcomm Technologies, Inc. Qualcomm Technologies, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project. ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2017-01-23 15:35 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2017-01-22 1:35 ASPM after Hotplug Question Sinan Kaya 2017-01-22 14:48 ` Bjorn Helgaas 2017-01-22 19:06 ` Sinan Kaya 2017-01-22 19:08 ` Sinan Kaya 2017-01-23 15:35 ` Sinan Kaya
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox