From: "Christian König" <christian.koenig@amd.com>
To: "Michał Winiarski" <michal.winiarski@intel.com>,
linux-pci@vger.kernel.org, intel-xe@lists.freedesktop.org,
dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
"Bjorn Helgaas" <bhelgaas@google.com>,
"Krzysztof Wilczyński" <kw@linux.com>,
"Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
Cc: "Rodrigo Vivi" <rodrigo.vivi@intel.com>,
"Michal Wajdeczko" <michal.wajdeczko@intel.com>,
"Lucas De Marchi" <lucas.demarchi@intel.com>,
"Thomas Hellström" <thomas.hellstrom@linux.intel.com>,
"Maarten Lankhorst" <maarten.lankhorst@linux.intel.com>,
"Maxime Ripard" <mripard@kernel.org>,
"Thomas Zimmermann" <tzimmermann@suse.de>,
"David Airlie" <airlied@gmail.com>,
"Simona Vetter" <simona@ffwll.ch>,
"Matt Roper" <matthew.d.roper@intel.com>
Subject: Re: [PATCH v4 2/7] PCI: Add a helper to identify IOV resources
Date: Tue, 29 Oct 2024 14:18:32 +0100 [thread overview]
Message-ID: <bc5473f8-1c40-4e50-bf8b-43233b3d53a5@amd.com> (raw)
In-Reply-To: <20241025215038.3125626-3-michal.winiarski@intel.com>
Am 25.10.24 um 23:50 schrieb Michał Winiarski:
> There are multiple places where special handling is required for IOV
> resources.
>
> Extract it to pci_resource_is_iov() helper and drop a few ifdefs.
>
> Signed-off-by: Michał Winiarski <michal.winiarski@intel.com>
> Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
> ---
> drivers/pci/pci.h | 19 +++++++++++++++----
> drivers/pci/setup-bus.c | 7 +++----
> drivers/pci/setup-res.c | 4 +---
> 3 files changed, 19 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
> index 14d00ce45bfa9..48d345607e57e 100644
> --- a/drivers/pci/pci.h
> +++ b/drivers/pci/pci.h
> @@ -580,6 +580,10 @@ void pci_iov_update_resource(struct pci_dev *dev, int resno);
> resource_size_t pci_sriov_resource_alignment(struct pci_dev *dev, int resno);
> void pci_restore_iov_state(struct pci_dev *dev);
> int pci_iov_bus_range(struct pci_bus *bus);
> +static inline bool pci_resource_is_iov(int resno)
> +{
> + return resno >= PCI_IOV_RESOURCES && resno <= PCI_IOV_RESOURCE_END;
> +}
> extern const struct attribute_group sriov_pf_dev_attr_group;
> extern const struct attribute_group sriov_vf_dev_attr_group;
> #else
> @@ -589,12 +593,21 @@ static inline int pci_iov_init(struct pci_dev *dev)
> }
> static inline void pci_iov_release(struct pci_dev *dev) { }
> static inline void pci_iov_remove(struct pci_dev *dev) { }
> +static inline void pci_iov_update_resource(struct pci_dev *dev, int resno) { }
> +static inline resource_size_t pci_sriov_resource_alignment(struct pci_dev *dev,
> + int resno)
> +{
> + return 0;
> +}
> static inline void pci_restore_iov_state(struct pci_dev *dev) { }
> static inline int pci_iov_bus_range(struct pci_bus *bus)
> {
> return 0;
> }
> -
> +static inline bool pci_resource_is_iov(int resno)
> +{
> + return false;
> +}
> #endif /* CONFIG_PCI_IOV */
>
> #ifdef CONFIG_PCIE_PTM
> @@ -616,12 +629,10 @@ unsigned long pci_cardbus_resource_alignment(struct resource *);
> static inline resource_size_t pci_resource_alignment(struct pci_dev *dev,
> struct resource *res)
> {
> -#ifdef CONFIG_PCI_IOV
> int resno = res - dev->resource;
>
> - if (resno >= PCI_IOV_RESOURCES && resno <= PCI_IOV_RESOURCE_END)
> + if (pci_resource_is_iov(resno))
> return pci_sriov_resource_alignment(dev, resno);
> -#endif
> if (dev->class >> 8 == PCI_CLASS_BRIDGE_CARDBUS)
> return pci_cardbus_resource_alignment(res);
> return resource_alignment(res);
> diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c
> index 23082bc0ca37a..ba293df10c050 100644
> --- a/drivers/pci/setup-bus.c
> +++ b/drivers/pci/setup-bus.c
> @@ -1093,17 +1093,16 @@ static int pbus_size_mem(struct pci_bus *bus, unsigned long mask,
> (r->flags & mask) != type3))
> continue;
> r_size = resource_size(r);
> -#ifdef CONFIG_PCI_IOV
> +
> /* Put SRIOV requested res to the optional list */
> - if (realloc_head && i >= PCI_IOV_RESOURCES &&
> - i <= PCI_IOV_RESOURCE_END) {
> + if (realloc_head && pci_resource_is_iov(i)) {
> add_align = max(pci_resource_alignment(dev, r), add_align);
> r->end = r->start - 1;
> add_to_list(realloc_head, dev, r, r_size, 0 /* Don't care */);
> children_add_size += r_size;
> continue;
> }
> -#endif
> +
> /*
> * aligns[0] is for 1MB (since bridge memory
> * windows are always at least 1MB aligned), so
> diff --git a/drivers/pci/setup-res.c b/drivers/pci/setup-res.c
> index c6d933ddfd464..e2cf79253ebda 100644
> --- a/drivers/pci/setup-res.c
> +++ b/drivers/pci/setup-res.c
> @@ -127,10 +127,8 @@ void pci_update_resource(struct pci_dev *dev, int resno)
> {
> if (resno <= PCI_ROM_RESOURCE)
> pci_std_update_resource(dev, resno);
> -#ifdef CONFIG_PCI_IOV
> - else if (resno >= PCI_IOV_RESOURCES && resno <= PCI_IOV_RESOURCE_END)
> + else if (pci_resource_is_iov(resno))
> pci_iov_update_resource(dev, resno);
> -#endif
> }
>
> int pci_claim_resource(struct pci_dev *dev, int resource)
next prev parent reply other threads:[~2024-10-29 13:18 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-25 21:50 [PATCH v4 0/7] PCI: VF resizable BAR Michał Winiarski
2024-10-25 21:50 ` [PATCH v4 1/7] PCI/IOV: Restore VF resizable BAR state after reset Michał Winiarski
2024-10-29 13:01 ` Christian König
2024-10-25 21:50 ` [PATCH v4 2/7] PCI: Add a helper to identify IOV resources Michał Winiarski
2024-10-29 13:18 ` Christian König [this message]
2024-10-25 21:50 ` [PATCH v4 3/7] PCI: Add a helper to convert between standard and " Michał Winiarski
2024-10-29 13:20 ` Christian König
2024-11-06 14:22 ` Ilpo Järvinen
2024-11-12 14:40 ` Michał Winiarski
2024-10-25 21:50 ` [PATCH v4 4/7] PCI: Allow IOV resources to be resized in pci_resize_resource() Michał Winiarski
2024-10-25 21:50 ` [PATCH v4 5/7] PCI/IOV: Check that VF BAR fits within the reservation Michał Winiarski
2024-10-28 11:20 ` Michał Winiarski
2024-10-28 16:56 ` Bjorn Helgaas
2024-10-30 11:43 ` Michał Winiarski
2024-10-30 16:55 ` Bjorn Helgaas
2024-11-12 14:31 ` Michał Winiarski
2024-10-25 21:50 ` [PATCH v4 6/7] PCI: Allow drivers to control VF BAR size Michał Winiarski
2024-10-28 16:50 ` Bjorn Helgaas
2024-11-12 14:55 ` Michał Winiarski
2024-10-25 21:50 ` [PATCH v4 7/7] drm/xe/pf: Set VF LMEM " Michał Winiarski
2024-10-25 23:16 ` ✓ CI.Patch_applied: success for PCI: VF resizable BAR (rev3) Patchwork
2024-10-25 23:16 ` ✗ CI.checkpatch: warning " Patchwork
2024-10-25 23:17 ` ✓ CI.KUnit: success " Patchwork
2024-10-25 23:29 ` ✓ CI.Build: " Patchwork
2024-10-25 23:31 ` ✓ CI.Hooks: " Patchwork
2024-10-25 23:33 ` ✗ CI.checksparse: warning " Patchwork
2024-10-25 23:57 ` ✗ CI.BAT: failure " Patchwork
2024-10-27 15:13 ` ✗ CI.FULL: " Patchwork
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=bc5473f8-1c40-4e50-bf8b-43233b3d53a5@amd.com \
--to=christian.koenig@amd.com \
--cc=airlied@gmail.com \
--cc=bhelgaas@google.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=intel-xe@lists.freedesktop.org \
--cc=kw@linux.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=lucas.demarchi@intel.com \
--cc=maarten.lankhorst@linux.intel.com \
--cc=matthew.d.roper@intel.com \
--cc=michal.wajdeczko@intel.com \
--cc=michal.winiarski@intel.com \
--cc=mripard@kernel.org \
--cc=rodrigo.vivi@intel.com \
--cc=simona@ffwll.ch \
--cc=thomas.hellstrom@linux.intel.com \
--cc=tzimmermann@suse.de \
/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