mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Hans Zhang <18255117159@163.com>
To: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
Cc: bhelgaas@google.com, lpieralisi@kernel.org, kw@linux.com,
	kwilczynski@kernel.org, mani@kernel.org, jingoohan1@gmail.com,
	robh@kernel.org, linux-pci@vger.kernel.org,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v5 2/3] PCI: Move pci_bus_speed2lnkctl2() to public header
Date: Tue, 7 Apr 2026 20:09:24 +0800	[thread overview]
Message-ID: <e1acfaad-faaa-410e-a20c-94552fded7a3@163.com> (raw)
In-Reply-To: <d19c8a93-71ae-187d-4aa6-a22105edcde3@linux.intel.com>



On 4/7/26 16:11, Ilpo Järvinen wrote:
> On Mon, 6 Apr 2026, Hans Zhang wrote:
> 
>> Move the static array-based pci_bus_speed2lnkctl2() function from
>> bwctrl.c to pci.h as a public inline function.
>>
>> This provides efficient O(1) speed-to-LNKCTL2 value conversion using
>> static array lookup, maintaining optimal performance while enabling
>> code reuse by other PCIe drivers.
>>
>> Signed-off-by: Hans Zhang <18255117159@163.com>
>> ---
>>   drivers/pci/pci.h         | 17 +++++++++++++++++
>>   drivers/pci/pcie/bwctrl.c | 17 -----------------
>>   2 files changed, 17 insertions(+), 17 deletions(-)
>>
>> diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
>> index f0a082bfd6f1..db91878a86ac 100644
>> --- a/drivers/pci/pci.h
>> +++ b/drivers/pci/pci.h
>> @@ -611,6 +611,23 @@ static inline bool pcie_valid_speed(enum pci_bus_speed speed)
>>   	return (speed >= PCIE_SPEED_2_5GT) && (speed <= PCIE_SPEED_64_0GT);
>>   }
>>   
>> +static inline u16 pci_bus_speed2lnkctl2(enum pci_bus_speed speed)
>> +{
>> +	static const u8 speed_conv[] = {
>> +		[PCIE_SPEED_2_5GT] = PCI_EXP_LNKCTL2_TLS_2_5GT,
>> +		[PCIE_SPEED_5_0GT] = PCI_EXP_LNKCTL2_TLS_5_0GT,
>> +		[PCIE_SPEED_8_0GT] = PCI_EXP_LNKCTL2_TLS_8_0GT,
>> +		[PCIE_SPEED_16_0GT] = PCI_EXP_LNKCTL2_TLS_16_0GT,
>> +		[PCIE_SPEED_32_0GT] = PCI_EXP_LNKCTL2_TLS_32_0GT,
>> +		[PCIE_SPEED_64_0GT] = PCI_EXP_LNKCTL2_TLS_64_0GT,
>> +	};
>> +
>> +	if (WARN_ON_ONCE(!pcie_valid_speed(speed)))
> 
> drivers/pci/pci.h doesn't seem to have include for WARN_ON_ONCE() so you
> should add it.

Hi Ilpo,

In the file "drivers/pci/pcie/bwctrl.c", there is no reference to the 
header file of WARN_ON_ONCE(). It seems that no error was reported. I 
think it might be that some other header files have indirectly 
referenced the header file of WARN_ON_ONCE(). However, when I compiled 
it locally, no errors were reported.

I think if we want to add a header file, it should be #include 
<asm-generic/bug.h> ?

Best regards,
Hans

> 


  reply	other threads:[~2026-04-07 12:10 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-06 10:47 [PATCH v5 0/3] PCI: Refactor PCIe speed validation and conversion functions Hans Zhang
2026-04-06 10:47 ` [PATCH v5 1/3] PCI: Add public pcie_valid_speed() for shared validation Hans Zhang
2026-04-06 10:47 ` [PATCH v5 2/3] PCI: Move pci_bus_speed2lnkctl2() to public header Hans Zhang
2026-04-07  8:11   ` Ilpo Järvinen
2026-04-07 12:09     ` Hans Zhang [this message]
2026-04-07 12:26       ` Ilpo Järvinen
2026-04-07 12:29         ` Hans Zhang
2026-04-07 12:48           ` Hans Zhang
2026-04-07 12:53             ` Ilpo Järvinen
2026-04-07 13:01               ` Hans Zhang
2026-04-06 10:47 ` [PATCH v5 3/3] PCI: dwc: Use common speed conversion function Hans Zhang
2026-04-06 10:54   ` Hans Zhang

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=e1acfaad-faaa-410e-a20c-94552fded7a3@163.com \
    --to=18255117159@163.com \
    --cc=bhelgaas@google.com \
    --cc=ilpo.jarvinen@linux.intel.com \
    --cc=jingoohan1@gmail.com \
    --cc=kw@linux.com \
    --cc=kwilczynski@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=lpieralisi@kernel.org \
    --cc=mani@kernel.org \
    --cc=robh@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

all inboxes | Powered by JetHome®