From: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
To: "Michał Winiarski" <michal.winiarski@intel.com>
Cc: linux-pci@vger.kernel.org, intel-xe@lists.freedesktop.org,
dri-devel@lists.freedesktop.org,
LKML <linux-kernel@vger.kernel.org>,
"Bjorn Helgaas" <bhelgaas@google.com>,
"Christian König" <christian.koenig@amd.com>,
"Krzysztof Wilczyński" <kw@linux.com>,
"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 v3 2/5] PCI: Add a helper to identify IOV resources
Date: Thu, 10 Oct 2024 13:46:57 +0300 (EEST) [thread overview]
Message-ID: <f360f00e-2282-ff6b-a390-697f8acd7917@linux.intel.com> (raw)
In-Reply-To: <20241010103203.382898-3-michal.winiarski@intel.com>
[-- Attachment #1: Type: text/plain, Size: 4259 bytes --]
On Thu, 10 Oct 2024, Michał Winiarski wrote:
> There are multiple places where special handling is required for IOV
> resources.
> Extract it to a helper and drop a few ifdefs.
>
> Signed-off-by: Michał Winiarski <michal.winiarski@intel.com>
> ---
> drivers/pci/pci.h | 18 ++++++++++++++----
> drivers/pci/setup-bus.c | 5 +----
> drivers/pci/setup-res.c | 4 +---
> 3 files changed, 16 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
> index 14d00ce45bfa9..c55f2d7a4f37e 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,20 @@ 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 +628,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..8909948bc9a9f 100644
> --- a/drivers/pci/setup-bus.c
> +++ b/drivers/pci/setup-bus.c
> @@ -1093,17 +1093,14 @@ 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
Heh, I realized I've made pretty much the same patch a few days back...
Please leave empty lines around this SRIOV / optional resource.
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
--
i.
> /*
> * 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-10 10:47 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-10 10:31 [PATCH v3 0/5] PCI: VF resizable BAR Michał Winiarski
2024-10-10 10:31 ` [PATCH v3 1/5] PCI/IOV: Restore VF resizable BAR state after reset Michał Winiarski
2024-10-10 11:01 ` Ilpo Järvinen
2024-10-10 22:31 ` Bjorn Helgaas
2024-10-10 10:32 ` [PATCH v3 2/5] PCI: Add a helper to identify IOV resources Michał Winiarski
2024-10-10 10:46 ` Ilpo Järvinen [this message]
2024-10-10 22:30 ` Bjorn Helgaas
2024-10-10 10:32 ` [PATCH v3 3/5] PCI: Allow IOV resources to be resized in pci_resize_resource Michał Winiarski
2024-10-10 11:17 ` Ilpo Järvinen
2024-10-10 11:42 ` Michał Winiarski
2024-10-10 22:36 ` Bjorn Helgaas
2024-10-10 10:32 ` [PATCH v3 4/5] PCI/IOV: Allow extending VF BAR within original resource boundary Michał Winiarski
2024-10-10 22:27 ` Bjorn Helgaas
2024-10-10 10:32 ` [PATCH v3 5/5] drm/xe/pf: Extend the VF LMEM BAR Michał Winiarski
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=f360f00e-2282-ff6b-a390-697f8acd7917@linux.intel.com \
--to=ilpo.jarvinen@linux.intel.com \
--cc=airlied@gmail.com \
--cc=bhelgaas@google.com \
--cc=christian.koenig@amd.com \
--cc=dri-devel@lists.freedesktop.org \
--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