From: Bjorn Helgaas <helgaas@kernel.org>
To: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
Cc: Bjorn Helgaas <bhelgaas@google.com>,
Jonathan Cameron <Jonathan.Cameron@huawei.com>,
linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/1] PCI/bwctrl: Fix link speed return type
Date: Fri, 21 Mar 2025 12:13:19 -0500 [thread overview]
Message-ID: <20250321171319.GA1132947@bhelgaas> (raw)
In-Reply-To: <20250321163103.5145-1-ilpo.jarvinen@linux.intel.com>
On Fri, Mar 21, 2025 at 06:31:03PM +0200, Ilpo Järvinen wrote:
> pcie_bwctrl_select_speed() should take __fls() of the speed bit, not
> return it as a raw value. Instead of directly returning 2.5GT/s speed
> bit, simply assign the fallback speed (2.5GT/s) into supported_speeds
> variable to share the normal return path that calls
> pcie_supported_speeds2target_speed() to calculate __fls().
>
> This code path is not very likely to execute because
> pcie_get_supported_speeds() should provide valid ->supported_speeds but
> a spec violating device could fail to synthetize any speed in
> pcie_get_supported_speeds(). It could also happen in case the
> supported_speeds intersection is empty (also a violation of the current
> PCIe specs).
>
> Fixes: de9a6c8d5dbf ("PCI/bwctrl: Add pcie_set_target_speed() to set PCIe Link Speed")
> Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Applied to pci/bwctrl for v6.15, thanks!
> ---
> drivers/pci/pcie/bwctrl.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/pci/pcie/bwctrl.c b/drivers/pci/pcie/bwctrl.c
> index 0a5e7efbce2c..58ba8142c9a3 100644
> --- a/drivers/pci/pcie/bwctrl.c
> +++ b/drivers/pci/pcie/bwctrl.c
> @@ -113,7 +113,7 @@ static u16 pcie_bwctrl_select_speed(struct pci_dev *port, enum pci_bus_speed spe
> up_read(&pci_bus_sem);
> }
> if (!supported_speeds)
> - return PCI_EXP_LNKCAP2_SLS_2_5GB;
> + supported_speeds = PCI_EXP_LNKCAP2_SLS_2_5GB;
>
> return pcie_supported_speeds2target_speed(supported_speeds & desired_speeds);
> }
>
> base-commit: 2014c95afecee3e76ca4a56956a936e23283f05b
> --
> 2.39.5
>
prev parent reply other threads:[~2025-03-21 17:13 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-21 16:31 [PATCH 1/1] PCI/bwctrl: Fix link speed return type Ilpo Järvinen
2025-03-21 17:13 ` Bjorn Helgaas [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250321171319.GA1132947@bhelgaas \
--to=helgaas@kernel.org \
--cc=Jonathan.Cameron@huawei.com \
--cc=bhelgaas@google.com \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox