mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Hans Zhang <18255117159@163.com>
To: kernel test robot <lkp@intel.com>,
	lpieralisi@kernel.org, jingoohan1@gmail.com, mani@kernel.org,
	kwilczynski@kernel.org, bhelgaas@google.com, helgaas@kernel.org
Cc: oe-kbuild-all@lists.linux.dev, robh@kernel.org,
	ilpo.jarvinen@linux.intel.com, linux-pci@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v7 2/2] PCI: dwc: Validate max-link-speed property
Date: Mon, 9 Mar 2026 22:45:38 +0800	[thread overview]
Message-ID: <42c07f4a-d32b-4219-a0a7-ccec5f125b32@163.com> (raw)
In-Reply-To: <202603090252.S3qQ67Kh-lkp@intel.com>



On 2026/3/9 02:10, kernel test robot wrote:
> Hi Hans,
> 
> kernel test robot noticed the following build errors:
> 
> [auto build test ERROR on c23719abc3308df7ed3ad35650ad211fb2d2003d]
> 
> url:    https://github.com/intel-lab-lkp/linux/commits/Hans-Zhang/PCI-of-Remove-max-link-speed-generation-validation/20260308-223128
> base:   c23719abc3308df7ed3ad35650ad211fb2d2003d
> patch link:    https://lore.kernel.org/r/20260308142629.75392-3-18255117159%40163.com
> patch subject: [PATCH v7 2/2] PCI: dwc: Validate max-link-speed property
> config: csky-randconfig-r071-20260308 (https://download.01.org/0day-ci/archive/20260309/202603090252.S3qQ67Kh-lkp@intel.com/config)
> compiler: csky-linux-gcc (GCC) 10.5.0
> smatch: v0.5.0-9004-gb810ac53
> reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260309/202603090252.S3qQ67Kh-lkp@intel.com/reproduce)
> 
> If you fix the issue in a separate patch/commit (i.e. not just a new version of
> the same patch/commit), kindly add following tags
> | Reported-by: kernel test robot <lkp@intel.com>
> | Closes: https://lore.kernel.org/oe-kbuild-all/202603090252.S3qQ67Kh-lkp@intel.com/
> 
> All errors (new ones prefixed by >>):
> 
>     In file included from include/linux/kernel.h:16,
>                      from include/linux/clk.h:13,
>                      from drivers/pci/controller/dwc/pcie-designware.c:13:
>     drivers/pci/controller/dwc/pcie-designware.c: In function 'dw_pcie_get_link_speed':
>>> include/linux/array_size.h:11:32: error: invalid application of 'sizeof' to incomplete type 'const unsigned char[]'
>        11 | #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr))
>           |                                ^
>     drivers/pci/controller/dwc/pcie-designware.c:128:19: note: in expansion of macro 'ARRAY_SIZE'
>       128 |      max_speed >= ARRAY_SIZE(pcie_link_speed) ||
>           |                   ^~~~~~~~~~
> 
Hi Bjorn and Mani,

I am currently working on a patch series aimed at removing the range 
check in the of_pci_get_max_link_speed() function and adding validation 
functionality in the DWC driver.

In patch 2 of v7, I used ARRAY_SIZE(pcie_link_speed) in the DWC driver 
to validate the "max-link-speed" attribute. However, the kernel test 
robot reported a build error [2] because pcie_link_speed is an 
incomplete type (only an external declaration) in the pcie-designware.c 
file, so ARRAY_SIZE cannot be used.

To solve this problem, I suggest adding a macro named "#define 
PCIE_LINK_SPEED_COUNT 16" in the <linux/pci.h> file to represent the 
fixed size of the pcie_link_speed array (with 16 entries according to 
the 4-bit field of the PCIe standard). Then use this macro in the DWC 
driver instead of using ARRAY_SIZE.

The reason for adding the macro instead of using the fixed value "16" is 
to make the code more self-explanatory and this array size can be used 
for many years in 16 cases.

Do you agree with this approach? Please let me know. Perhaps there are 
any other better methods?

Best regards,
Hans

> 
> vim +11 include/linux/array_size.h
> 
> 3cd39bc3b11b8d Alejandro Colomar 2023-10-03   6
> 3cd39bc3b11b8d Alejandro Colomar 2023-10-03   7  /**
> 3cd39bc3b11b8d Alejandro Colomar 2023-10-03   8   * ARRAY_SIZE - get the number of elements in array @arr
> 3cd39bc3b11b8d Alejandro Colomar 2023-10-03   9   * @arr: array to be sized
> 3cd39bc3b11b8d Alejandro Colomar 2023-10-03  10   */
> 3cd39bc3b11b8d Alejandro Colomar 2023-10-03 @11  #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr))
> 3cd39bc3b11b8d Alejandro Colomar 2023-10-03  12
> 


  reply	other threads:[~2026-03-09 14:46 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-08 14:26 [PATCH v7 0/2] PCI: of: Remove max-link-speed generation validation Hans Zhang
2026-03-08 14:26 ` [PATCH v7 1/2] " Hans Zhang
2026-03-09  0:38   ` Shawn Lin
2026-03-09 14:21     ` Hans Zhang
2026-03-09 11:47   ` Manivannan Sadhasivam
2026-03-09 14:47     ` Hans Zhang
2026-03-10 22:37   ` Bjorn Helgaas
2026-03-12 16:18     ` Hans Zhang
2026-03-08 14:26 ` [PATCH v7 2/2] PCI: dwc: Validate max-link-speed property Hans Zhang
2026-03-08 18:10   ` kernel test robot
2026-03-09 14:45     ` Hans Zhang [this message]
2026-03-09 11:11   ` kernel test robot
2026-03-09 15:44   ` kernel test robot

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=42c07f4a-d32b-4219-a0a7-ccec5f125b32@163.com \
    --to=18255117159@163.com \
    --cc=bhelgaas@google.com \
    --cc=helgaas@kernel.org \
    --cc=ilpo.jarvinen@linux.intel.com \
    --cc=jingoohan1@gmail.com \
    --cc=kwilczynski@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=lkp@intel.com \
    --cc=lpieralisi@kernel.org \
    --cc=mani@kernel.org \
    --cc=oe-kbuild-all@lists.linux.dev \
    --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®