mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-12-27 14:41:22 -05:00
PCI: Fix BUILD_BUG_ON usage for old gcc
As reported in the below link, it seems older versions of gcc cannot
determine that the howmany variable is known for all callers. Include
a test so that newer compilers can enforce this sanity check and older
compilers can still work. Add __always_inline attribute to give the
compiler an even better chance to know the inputs.
Link: https://lore.kernel.org/r/20250212185337.293023-1-alex.williamson@redhat.com
Fixes: 4453f36086 ("PCI: Batch BAR sizing operations")
Reported-by: Oleg Nesterov <oleg@redhat.com>
Link: https://lore.kernel.org/all/20250209154512.GA18688@redhat.com
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Tested-by: Oleg Nesterov <oleg@redhat.com>
Tested-by: Mitchell Augustin <mitchell.augustin@canonical.com>
This commit is contained in:
committed by
Bjorn Helgaas
parent
2014c95afe
commit
472ff48e2c
@@ -339,13 +339,14 @@ int __pci_read_base(struct pci_dev *dev, enum pci_bar_type type,
|
||||
return (res->flags & IORESOURCE_MEM_64) ? 1 : 0;
|
||||
}
|
||||
|
||||
static void pci_read_bases(struct pci_dev *dev, unsigned int howmany, int rom)
|
||||
static __always_inline void pci_read_bases(struct pci_dev *dev,
|
||||
unsigned int howmany, int rom)
|
||||
{
|
||||
u32 rombar, stdbars[PCI_STD_NUM_BARS];
|
||||
unsigned int pos, reg;
|
||||
u16 orig_cmd;
|
||||
|
||||
BUILD_BUG_ON(howmany > PCI_STD_NUM_BARS);
|
||||
BUILD_BUG_ON(statically_true(howmany > PCI_STD_NUM_BARS));
|
||||
|
||||
if (dev->non_compliant_bars)
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user