Skip to content
Snippets Groups Projects
Commit b1a2c1ac authored by Myron Stowe's avatar Myron Stowe
Browse files

PCI/bwctrl: Add pcie_set_target_speed() to set PCIe Link Speed

JIRA: https://issues.redhat.com/browse/RHEL-81906
Upstream Status: de9a6c8d5dbfedb5eb3722c822da0490f6a59a45

commit de9a6c8d5dbfedb5eb3722c822da0490f6a59a45
Author: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Date:   Fri Oct 18 17:47:53 2024 +0300

    PCI/bwctrl: Add pcie_set_target_speed() to set PCIe Link Speed

    Currently, PCIe Link Speeds are adjusted by custom code rather than in a
    common function provided in PCI core. The PCIe bandwidth controller
    (bwctrl) introduces an in-kernel API, pcie_set_target_speed(), to set PCIe
    Link Speed.

    Convert Target Speed quirk to use the new API. The Target Speed quirk runs
    very early when bwctrl is not yet probed for a Port and can also run later
    when bwctrl is already setup for the Port, which requires the per port
    mutex (set_speed_mutex) to be only taken if the bwctrl setup is already
    complete.

    The new API is also intended to be used in an upcoming commit that adds a
    thermal cooling device to throttle PCIe bandwidth when thermal thresholds
    are reached.

    The PCIe bandwidth control procedure is as follows. The highest speed
    supported by the Port and the PCIe device which is not higher than the
    requested speed is selected and written into the Target Link Speed in the
    Link Control 2 Register. Then bandwidth controller retrains the PCIe Link.

    Bandwidth Notifications enable the cur_bus_speed in the struct pci_bus to
    keep track PCIe Link Speed changes. While Bandwidth Notifications should
    also be generated when bandwidth controller alters the PCIe Link Speed, a
    few platforms do not deliver LMBS interrupt after Link Training as
    expected. Thus, after changing the Link Speed, bandwidth controller makes
    additional read for the Link Status Register to ensure cur_bus_speed is
    consistent with the new PCIe Link Speed.

    Link: https://lore.kernel.org/r/20241018144755.7875-8-ilpo.jarvinen@linux.intel.com


Signed-off-by: default avatarIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
    [bhelgaas: squash devm_mutex_init() error checking from
    https://lore.kernel.org/r/20241030163139.2111689-1-andriy.shevchenko@linux.intel.com

,
    drop export of pcie_set_target_speed()]
Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
Reviewed-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>

Signed-off-by: default avatarMyron Stowe <mstowe@redhat.com>
parent 9512e6db
No related branches found
No related tags found
No related merge requests found
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment