public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
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 v6 6/6] drm/xe/pf: Set VF LMEM BAR size
Date: Wed, 26 Mar 2025 17:29:31 +0200 (EET)	[thread overview]
Message-ID: <bdfe5413-547a-67b0-b822-9852d3f94cc5@linux.intel.com> (raw)
In-Reply-To: <20250320110854.3866284-7-michal.winiarski@intel.com>

[-- Attachment #1: Type: text/plain, Size: 2847 bytes --]

On Thu, 20 Mar 2025, Michał Winiarski wrote:

> LMEM is partitioned between multiple VFs and we expect that the more
> VFs we have, the less LMEM is assigned to each VF.
> This means that we can achieve full LMEM BAR access without the need to
> attempt full VF LMEM BAR resize via pci_resize_resource().
> 
> Always set the largest possible BAR size that allows to fit the number
> of enabled VFs.
> 
> Signed-off-by: Michał Winiarski <michal.winiarski@intel.com>
> ---
>  drivers/gpu/drm/xe/regs/xe_bars.h |  1 +
>  drivers/gpu/drm/xe/xe_pci_sriov.c | 22 ++++++++++++++++++++++
>  2 files changed, 23 insertions(+)
> 
> diff --git a/drivers/gpu/drm/xe/regs/xe_bars.h b/drivers/gpu/drm/xe/regs/xe_bars.h
> index ce05b6ae832f1..880140d6ccdca 100644
> --- a/drivers/gpu/drm/xe/regs/xe_bars.h
> +++ b/drivers/gpu/drm/xe/regs/xe_bars.h
> @@ -7,5 +7,6 @@
>  
>  #define GTTMMADR_BAR			0 /* MMIO + GTT */
>  #define LMEM_BAR			2 /* VRAM */
> +#define VF_LMEM_BAR			9 /* VF VRAM */
>  
>  #endif
> diff --git a/drivers/gpu/drm/xe/xe_pci_sriov.c b/drivers/gpu/drm/xe/xe_pci_sriov.c
> index aaceee748287e..57cdeb41ef1d9 100644
> --- a/drivers/gpu/drm/xe/xe_pci_sriov.c
> +++ b/drivers/gpu/drm/xe/xe_pci_sriov.c
> @@ -3,6 +3,10 @@
>   * Copyright © 2023-2024 Intel Corporation
>   */
>  
> +#include <linux/bitops.h>
> +#include <linux/pci.h>
> +
> +#include "regs/xe_bars.h"
>  #include "xe_assert.h"
>  #include "xe_device.h"
>  #include "xe_gt_sriov_pf_config.h"
> @@ -62,6 +66,18 @@ static void pf_reset_vfs(struct xe_device *xe, unsigned int num_vfs)
>  			xe_gt_sriov_pf_control_trigger_flr(gt, n);
>  }
>  
> +static int resize_vf_vram_bar(struct xe_device *xe, int num_vfs)
> +{
> +	struct pci_dev *pdev = to_pci_dev(xe->drm.dev);
> +	u32 sizes;
> +
> +	sizes = pci_iov_vf_bar_get_sizes(pdev, VF_LMEM_BAR, num_vfs);
> +	if (!sizes)
> +		return 0;
> +
> +	return pci_iov_vf_bar_set_size(pdev, VF_LMEM_BAR, __fls(sizes));
> +}
> +
>  static int pf_enable_vfs(struct xe_device *xe, int num_vfs)
>  {
>  	struct pci_dev *pdev = to_pci_dev(xe->drm.dev);
> @@ -88,6 +104,12 @@ static int pf_enable_vfs(struct xe_device *xe, int num_vfs)
>  	if (err < 0)
>  		goto failed;
>  
> +	if (IS_DGFX(xe)) {
> +		err = resize_vf_vram_bar(xe, num_vfs);
> +		if (err)
> +			xe_sriov_info(xe, "Failed to set VF LMEM BAR size: %d\n", err);

If you intended this error to not result in failure, please mention it 
in the changelog so that it's recorded somewhere for those who have to 
look up things from the git history one day :-).

> +	}
> +
>  	err = pci_enable_sriov(pdev, num_vfs);
>  	if (err < 0)
>  		goto failed;

Seems pretty straightforward after reading the support code on the PCI 
core side,

Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>

-- 
 i.

  reply	other threads:[~2025-03-26 15:29 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-20 11:08 [PATCH v6 0/6] PCI: VF resizable BAR Michał Winiarski
2025-03-20 11:08 ` [PATCH v6 1/6] PCI/IOV: Restore VF resizable BAR state after reset Michał Winiarski
2025-03-26 14:42   ` Ilpo Järvinen
2025-03-26 14:52     ` Ilpo Järvinen
2025-04-02 10:20       ` Michał Winiarski
2025-03-20 11:08 ` [PATCH v6 2/6] PCI: Add a helper to convert between VF BAR number and IOV resource Michał Winiarski
2025-03-26 14:46   ` Ilpo Järvinen
2025-04-02 10:23     ` Michał Winiarski
2025-03-20 11:08 ` [PATCH v6 3/6] PCI: Allow IOV resources to be resized in pci_resize_resource() Michał Winiarski
2025-03-26 14:58   ` Ilpo Järvinen
2025-04-02 10:25     ` Michał Winiarski
2025-03-20 11:08 ` [PATCH v6 4/6] PCI/IOV: Check that VF BAR fits within the reservation Michał Winiarski
2025-03-26 15:11   ` Ilpo Järvinen
2025-03-28 16:39     ` Ilpo Järvinen
2025-04-02 10:33       ` Michał Winiarski
2025-04-02 10:31     ` Michał Winiarski
2025-03-20 11:08 ` [PATCH v6 5/6] PCI: Allow drivers to control VF BAR size Michał Winiarski
2025-03-26 15:22   ` Ilpo Järvinen
2025-04-02 10:43     ` Michał Winiarski
2025-04-02 12:04       ` Ilpo Järvinen
2025-03-20 11:08 ` [PATCH v6 6/6] drm/xe/pf: Set VF LMEM " Michał Winiarski
2025-03-26 15:29   ` Ilpo Järvinen [this message]
2025-04-02 10:44     ` 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=bdfe5413-547a-67b0-b822-9852d3f94cc5@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