Code that iterates over all standard PCI BARs typically uses
PCI_STD_RESOURCE_END, but this is error-prone because it requires
"i <= PCI_STD_RESOURCE_END" rather than something like
"i < PCI_STD_NUM_BARS". We could add such a definition and use it the same
way PCI_SRIOV_NUM_BARS is used. There is already the definition
PCI_BAR_COUNT for s390 only. Thus, this patchset introduces it globally.
The patch is splitted into 7 parts for different drivers/subsystems for
easy readability.
Denis Efremov (7):
PCI: Add define for the number of standard PCI BARs
s390/pci: Replace PCI_BAR_COUNT with PCI_STD_NUM_BARS
x86/PCI: Use PCI_STD_NUM_BARS in loops instead of PCI_STD_RESOURCE_END
PCI/net: Use PCI_STD_NUM_BARS in loops instead of PCI_STD_RESOURCE_END
rapidio/tsi721: use PCI_STD_NUM_BARS in loops instead of
PCI_STD_RESOURCE_END
efifb: Use PCI_STD_NUM_BARS in loops instead of PCI_STD_RESOURCE_END
vfio_pci: Use PCI_STD_NUM_BARS in loops instead of
PCI_STD_RESOURCE_END
arch/s390/include/asm/pci.h | 5 +----
arch/s390/include/asm/pci_clp.h | 6 +++---
arch/s390/pci/pci.c | 16 ++++++++--------
arch/s390/pci/pci_clp.c | 6 +++---
arch/x86/pci/common.c | 2 +-
drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c | 4 ++--
drivers/net/ethernet/synopsys/dwc-xlgmac-pci.c | 2 +-
drivers/pci/quirks.c | 2 +-
drivers/rapidio/devices/tsi721.c | 2 +-
drivers/vfio/pci/vfio_pci.c | 4 ++--
drivers/vfio/pci/vfio_pci_config.c | 2 +-
drivers/vfio/pci/vfio_pci_private.h | 4 ++--
drivers/video/fbdev/efifb.c | 2 +-
include/linux/pci.h | 2 +-
include/uapi/linux/pci_regs.h | 1 +
15 files changed, 29 insertions(+), 31 deletions(-)
--
2.21.0
Code that iterates over all standard PCI BARs typically uses
PCI_STD_RESOURCE_END. However, it requires the "unusual" loop condition
"i <= PCI_STD_RESOURCE_END" rather than something more standard like
"i < PCI_STD_NUM_BARS".
This patch adds the definition PCI_STD_NUM_BARS which is equivalent to
"PCI_STD_RESOURCE_END + 1" and updates loop conditions to use it.
Signed-off-by: Denis Efremov <efremov@linux.com>
---
drivers/pci/quirks.c | 2 +-
include/linux/pci.h | 2 +-
include/uapi/linux/pci_regs.h | 1 +
3 files changed, 3 insertions(+), 2 deletions(-)
From: Andrew Murray <hidden> Date: 2019-08-12 09:06:44
On Sun, Aug 11, 2019 at 06:07:55PM +0300, Denis Efremov wrote:
Code that iterates over all standard PCI BARs typically uses
PCI_STD_RESOURCE_END, but this is error-prone because it requires
"i <= PCI_STD_RESOURCE_END" rather than something like
"i < PCI_STD_NUM_BARS". We could add such a definition and use it the same
way PCI_SRIOV_NUM_BARS is used. There is already the definition
PCI_BAR_COUNT for s390 only. Thus, this patchset introduces it globally.
The patch is splitted into 7 parts for different drivers/subsystems for
easy readability.
Denis Efremov (7):
PCI: Add define for the number of standard PCI BARs
s390/pci: Replace PCI_BAR_COUNT with PCI_STD_NUM_BARS
x86/PCI: Use PCI_STD_NUM_BARS in loops instead of PCI_STD_RESOURCE_END
PCI/net: Use PCI_STD_NUM_BARS in loops instead of PCI_STD_RESOURCE_END
rapidio/tsi721: use PCI_STD_NUM_BARS in loops instead of
PCI_STD_RESOURCE_END
efifb: Use PCI_STD_NUM_BARS in loops instead of PCI_STD_RESOURCE_END
vfio_pci: Use PCI_STD_NUM_BARS in loops instead of
PCI_STD_RESOURCE_END
arch/s390/include/asm/pci.h | 5 +----
arch/s390/include/asm/pci_clp.h | 6 +++---
arch/s390/pci/pci.c | 16 ++++++++--------
arch/s390/pci/pci_clp.c | 6 +++---
arch/x86/pci/common.c | 2 +-
drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c | 4 ++--
drivers/net/ethernet/synopsys/dwc-xlgmac-pci.c | 2 +-
drivers/pci/quirks.c | 2 +-
drivers/rapidio/devices/tsi721.c | 2 +-
drivers/vfio/pci/vfio_pci.c | 4 ++--
drivers/vfio/pci/vfio_pci_config.c | 2 +-
drivers/vfio/pci/vfio_pci_private.h | 4 ++--
drivers/video/fbdev/efifb.c | 2 +-
include/linux/pci.h | 2 +-
include/uapi/linux/pci_regs.h | 1 +
Hi Denis,
You could also fix up a few cases where the number of BARs is hard coded in
loops, e.g.
drivers/pci/controller/pci-hyperv.c - look for uses of probed_bar in loops
drivers/pci/pci.c - pci_release_selected_regions and __pci_request_selected_regions
drivers/pci/quirks.c - quirk_alder_ioapic
Thanks,
Andrew Murray
On Sun, Aug 11, 2019 at 06:07:55PM +0300, Denis Efremov wrote:
Code that iterates over all standard PCI BARs typically uses
PCI_STD_RESOURCE_END, but this is error-prone because it requires
"i <= PCI_STD_RESOURCE_END" rather than something like
"i < PCI_STD_NUM_BARS". We could add such a definition and use it the same
way PCI_SRIOV_NUM_BARS is used. There is already the definition
PCI_BAR_COUNT for s390 only. Thus, this patchset introduces it globally.
The patch is splitted into 7 parts for different drivers/subsystems for
easy readability.
This looks good. I can take all these together, since they all depend
on the first patch. I have a few comments on the individual patches.
Denis Efremov (7):
PCI: Add define for the number of standard PCI BARs
s390/pci: Replace PCI_BAR_COUNT with PCI_STD_NUM_BARS
x86/PCI: Use PCI_STD_NUM_BARS in loops instead of PCI_STD_RESOURCE_END
PCI/net: Use PCI_STD_NUM_BARS in loops instead of PCI_STD_RESOURCE_END
rapidio/tsi721: use PCI_STD_NUM_BARS in loops instead of
PCI_STD_RESOURCE_END
efifb: Use PCI_STD_NUM_BARS in loops instead of PCI_STD_RESOURCE_END
vfio_pci: Use PCI_STD_NUM_BARS in loops instead of
PCI_STD_RESOURCE_END
arch/s390/include/asm/pci.h | 5 +----
arch/s390/include/asm/pci_clp.h | 6 +++---
arch/s390/pci/pci.c | 16 ++++++++--------
arch/s390/pci/pci_clp.c | 6 +++---
arch/x86/pci/common.c | 2 +-
drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c | 4 ++--
drivers/net/ethernet/synopsys/dwc-xlgmac-pci.c | 2 +-
drivers/pci/quirks.c | 2 +-
drivers/rapidio/devices/tsi721.c | 2 +-
drivers/vfio/pci/vfio_pci.c | 4 ++--
drivers/vfio/pci/vfio_pci_config.c | 2 +-
drivers/vfio/pci/vfio_pci_private.h | 4 ++--
drivers/video/fbdev/efifb.c | 2 +-
include/linux/pci.h | 2 +-
include/uapi/linux/pci_regs.h | 1 +
15 files changed, 29 insertions(+), 31 deletions(-)
--
2.21.0
From: Thomas Gleixner <hidden> Date: 2019-08-12 20:11:37
On Mon, 12 Aug 2019, Bjorn Helgaas wrote:
On Sun, Aug 11, 2019 at 06:07:55PM +0300, Denis Efremov wrote:
quoted
Code that iterates over all standard PCI BARs typically uses
PCI_STD_RESOURCE_END, but this is error-prone because it requires
"i <= PCI_STD_RESOURCE_END" rather than something like
"i < PCI_STD_NUM_BARS". We could add such a definition and use it the same
way PCI_SRIOV_NUM_BARS is used. There is already the definition
PCI_BAR_COUNT for s390 only. Thus, this patchset introduces it globally.
The patch is splitted into 7 parts for different drivers/subsystems for
easy readability.
This looks good. I can take all these together, since they all depend
on the first patch. I have a few comments on the individual patches.
quoted
Denis Efremov (7):
PCI: Add define for the number of standard PCI BARs
s390/pci: Replace PCI_BAR_COUNT with PCI_STD_NUM_BARS
x86/PCI: Use PCI_STD_NUM_BARS in loops instead of PCI_STD_RESOURCE_END
Fine with me for the x86 part. That's your turf anyway :)
Thanks,
tglx
You could also fix up a few cases where the number of BARs is hard coded in
loops, e.g.
drivers/pci/controller/pci-hyperv.c - look for uses of probed_bar in loops
drivers/pci/pci.c - pci_release_selected_regions and __pci_request_selected_regions
drivers/pci/quirks.c - quirk_alder_ioapic
Thanks for pointing me on that. I will take this into account in v2.
Denis
This patch refactors the loop condition scheme from
'i <= PCI_STD_RESOURCE_END' to 'i < PCI_STD_NUM_BARS'.
Signed-off-by: Denis Efremov <efremov@linux.com>