All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Roger Pau Monné" <roger.pau@citrix.com>
To: "Chen, Jiqian" <Jiqian.Chen@amd.com>
Cc: "xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>,
	Andrew Cooper <andrew.cooper3@citrix.com>,
	Jan Beulich <jbeulich@suse.com>, Julien Grall <julien@xen.org>,
	Stefano Stabellini <sstabellini@kernel.org>
Subject: Re: [PATCH] vpci: Add resizable bar support
Date: Thu, 14 Nov 2024 18:58:31 +0100	[thread overview]
Message-ID: <ZzY6R4o9k8s8TsxH@macbook> (raw)
In-Reply-To: <BL1PR12MB5849F0606930076AC8CC66ADE75B2@BL1PR12MB5849.namprd12.prod.outlook.com>

On Thu, Nov 14, 2024 at 06:11:46AM +0000, Chen, Jiqian wrote:
> On 2024/11/13 18:30, Roger Pau Monné wrote:
> > On Wed, Nov 13, 2024 at 10:00:33AM +0000, Chen, Jiqian wrote:
> >> On 2024/11/13 17:30, Roger Pau Monné wrote:
> >>> On Wed, Nov 13, 2024 at 04:00:27PM +0800, Jiqian Chen wrote:
> >>>> Some devices, like discrete GPU of amd, support resizable bar capability,
> >>>> but vpci of Xen doesn't support this feature, so they fail to resize bars
> >>>> and then cause probing failure.
> >>>>
> >>>> According to PCIe spec, each bar that support resizing has two registers,
> >>>> PCI_REBAR_CAP and PCI_REBAR_CTRL, so add these two registers and their
> >>>> corresponding handler into vpci.
> >>>>
> >>>> PCI_REBAR_CAP is RO, only provide reading.
> >>>>
> >>>> PCI_REBAR_CTRL only has bar size is RW, so add write function to support
> >>>> setting the new size.
> >>>
> >>> I think the logic to handle resizable BAR could be much simpler.  Some
> >>> time ago I've made a patch to add support for it, but due to lack of
> >>> hardware on my side to test it I've never submitted it.
> >>>
> >>> My approach would be to detect the presence of the
> >>> PCI_EXT_CAP_ID_REBAR capability in init_header(), and if the
> >>> capability is present force the sizing of BARs each time they are
> >>> mapped in modify_bars().  I don't think we need to trap accesses to
> >>> the capability itself, as resizing can only happen when memory
> >>> decoding is not enabled for the device.  It's enough to fetch the size
> >>> of the BARs ahead of each enabling of memory decoding.
> >>>
> >>> Note that memory decoding implies mapping the BARs into the p2m, which
> >>> is already an expensive operation, the extra sizing is unlikely to
> >>> make much of a difference performance wise.
> >>>
> >>> I've found the following on my git tree and rebased on top of staging:
> >> OK.
> >> Do you need me to validate your patch in my environment?
> > 
> > Yes please, I have no way to test it.  Let's see what others think
> > about the different approaches.
> There are some errors with your method.
> I attached the dmesg and xl dmesg logs.
> From the dmesg logs, it seems that 0000:03:00.0 has addresse overlap with 0000:03:00.1

I'm attempting to go over Linux dmesg, and so far got the following
information about the BAR positions for 0000:03:00.0 and 0000:03:00.1:

[    1.101522] pci 0000:03:00.0: [1002:73ff] type 00 class 0x030000 PCIe Legacy Endpoint
[    1.102416] pci 0000:03:00.0: BAR 0 [mem 0xfc90000000-0xfc9fffffff 64bit pref]
[    1.105592] pci 0000:03:00.0: BAR 2 [mem 0xfca0000000-0xfca01fffff 64bit pref]
[    1.106665] pci 0000:03:00.0: BAR 4 [io  0x2000-0x20ff]
[    1.109858] pci 0000:03:00.0: BAR 5 [mem 0xd0600000-0xd06fffff]
[    1.112962] pci 0000:03:00.0: ROM [mem 0xfffe0000-0xffffffff pref]
[    1.113543] pci 0000:03:00.0: PME# supported from D1 D2 D3hot D3cold
[    1.114031] pci 0000:03:00.0: 63.008 Gb/s available PCIe bandwidth, limited by 8.0 GT/s PCIe x8 link at 0000:00:01.1 (capable of 252.048 Gb/s with 16.0 GT/s PCIe x16 link)
[    1.115074] pci 0000:03:00.1: [1002:ab28] type 00 class 0x040300 PCIe Legacy Endpoint
[    1.115207] pci 0000:03:00.1: BAR 0 [mem 0xd0700000-0xd0703fff]
[    1.115962] pci 0000:03:00.1: PME# supported from D1 D2 D3hot D3cold
[  120.049678] amdgpu 0000:03:00.0: BAR 2 [mem 0xfca0000000-0xfca01fffff 64bit pref]: releasing
[  120.049682] amdgpu 0000:03:00.0: BAR 0 [mem 0xfc90000000-0xfc9fffffff 64bit pref]: releasing
[  120.049815] amdgpu 0000:03:00.0: BAR 0 [mem 0xa00000000-0xbffffffff 64bit pref]: assigned
[  120.049833] amdgpu 0000:03:00.0: BAR 2 [mem 0x900000000-0x9001fffff 64bit pref]: assigned

So the only BAR from 0000:03:00.1 is always at 0xd0700000-0xd0703fff,
and BARs for 0000:03:00.0 are relocated from:

0xfca0000000-0xfca01fffff -> 0x900000000-0x9001fffff (same size)
0xfc90000000-0xfc9fffffff -> 0xa00000000-0xbffffffff (resized)

So I see no overlap between the BARs of 0000:03:00.0 and 0000:03:00.1,
but maybe I'm missing some position changes, following Linux dmesg is
not easy.

Regards, Roger.


  parent reply	other threads:[~2024-11-14 17:58 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-13  8:00 [PATCH] vpci: Add resizable bar support Jiqian Chen
2024-11-13  9:30 ` Roger Pau Monné
2024-11-13 10:00   ` Chen, Jiqian
2024-11-13 10:30     ` Roger Pau Monné
2024-11-13 10:36       ` Jan Beulich
2024-11-13 10:56         ` Roger Pau Monné
2024-11-13 11:01           ` Jan Beulich
2024-11-13 11:24             ` Roger Pau Monné
2024-11-13 11:29               ` Jan Beulich
2024-11-13 12:13                 ` Roger Pau Monné
2024-11-14  6:11       ` Chen, Jiqian
2024-11-14 15:52         ` Roger Pau Monné
2024-11-14 17:36           ` Roger Pau Monné
2024-11-15  3:04             ` Chen, Jiqian
2024-11-15 11:42               ` Roger Pau Monné
2024-11-18  6:06                 ` Chen, Jiqian
2024-11-19 12:46                   ` Roger Pau Monné
2024-11-20  3:01                     ` Chen, Jiqian
2024-11-20  9:01                       ` Roger Pau Monné
2024-11-20 10:06                         ` Jan Beulich
2024-11-20 10:25                         ` Chen, Jiqian
2024-11-21  3:05                         ` Chen, Jiqian
2024-11-21  9:52                           ` Roger Pau Monné
2024-11-22  4:04                             ` Chen, Jiqian
2024-11-22  7:58                               ` Roger Pau Monné
2024-11-25  3:44                             ` Chen, Jiqian
2024-11-25 12:47                               ` Roger Pau Monné
2024-11-26  6:02                                 ` Chen, Jiqian
2024-11-26  9:47                                   ` Jan Beulich
2024-11-27  9:07                                     ` Chen, Jiqian
2024-11-15  2:16           ` Chen, Jiqian
2024-11-14 17:58         ` Roger Pau Monné [this message]
2024-11-18 10:17 ` Roger Pau Monné
2024-11-18 10:26   ` Jan Beulich
2024-11-18 16:41   ` Stefano Stabellini
2024-11-19  7:31   ` Chen, Jiqian
2024-11-19  7:44     ` Jan Beulich
2024-11-20  2:26       ` Chen, Jiqian
2024-11-20  8:06         ` Roger Pau Monné
2024-11-19 12:51 ` Roger Pau Monné
2024-11-20  2:30   ` Chen, Jiqian
2024-11-20  8:09     ` Roger Pau Monné

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=ZzY6R4o9k8s8TsxH@macbook \
    --to=roger.pau@citrix.com \
    --cc=Jiqian.Chen@amd.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=jbeulich@suse.com \
    --cc=julien@xen.org \
    --cc=sstabellini@kernel.org \
    --cc=xen-devel@lists.xenproject.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.