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: Mon, 25 Nov 2024 13:47:20 +0100 [thread overview]
Message-ID: <Z0Rx2IXqqvrLaIIq@macbook> (raw)
In-Reply-To: <BL1PR12MB584977971D2C0A00443A1A79E72E2@BL1PR12MB5849.namprd12.prod.outlook.com>
On Mon, Nov 25, 2024 at 03:44:52AM +0000, Chen, Jiqian wrote:
> On 2024/11/21 17:52, Roger Pau Monné wrote:
> > On Thu, Nov 21, 2024 at 03:05:14AM +0000, Chen, Jiqian wrote:
> >> On 2024/11/20 17:01, Roger Pau Monné wrote:
> >>> On Wed, Nov 20, 2024 at 03:01:57AM +0000, Chen, Jiqian wrote:
> >>>> The only difference between our methods is the timing of updating the size.
> >>>> Yours is later than mine because you updated the size when the driver re-enabled memory decoding, while I updated the size in time when driver resize it.
> >>>
> >>> Indeed, my last guess is the stale cached size is somehow used in my
> >>> approach, and that leads to the failures. One last (possibly dummy?)
> >>> thing to try might be to use your patch to detect writes to the resize
> >>> control register, but update the BAR sizes in modify_bars(), while
> >>> keeping the traces of when the operations happen.
> >>>
> >> This can work, combine our method, use my patch to detect and write the size into hardware register, and use your patch to update bar[i].size in modify_bars().
> >> Attached the combined patch and the xl dmesg.
> >
> > This is even weirder, so the attached patch works fine? The only
> > difference with my proposal is that you trap the CTRL registers, but
> > the sizing is still done in modify_bars().
> >
> > What happens if (based on the attached patch) you change
> > rebar_ctrl_write() to:
> >
> > static void cf_check rebar_ctrl_write(const struct pci_dev *pdev,
> > unsigned int reg,
> > uint32_t val,
> > void *data)
> > {
> > pci_conf_write32(pdev->sbdf, reg, val);
> > }
> >
> If I change rebar_ctrl_write() to:
> static void cf_check rebar_ctrl_write(const struct pci_dev *pdev,
> unsigned int reg,
> uint32_t val,
> void *data)
> {
> printk("cjq_debug %pp: bar ctrl write reg %u, val %x\n", &pdev->sbdf, reg, val);
> pci_conf_write32(pdev->sbdf, reg, val);
> }
>
> I can see three time prints, it can't work.
> (XEN) cjq_debug 0000:03:00.0: bar ctrl write reg 520, val d40
> (XEN) cjq_debug 0000:03:00.0: bar ctrl write reg 520, val d40
> (XEN) cjq_debug 0000:03:00.0: bar ctrl write reg 528, val 102
>
> If I change rebar_ctrl_write() to:
> static void cf_check rebar_ctrl_write(const struct pci_dev *pdev,
> unsigned int reg,
> uint32_t val,
> void *data)
> {
> if ( pci_conf_read16(pdev->sbdf, PCI_COMMAND) & PCI_COMMAND_MEMORY )
> return;
> printk("cjq_debug %pp: bar ctrl write reg %u, val %x\n", &pdev->sbdf, reg, val);
> pci_conf_write32(pdev->sbdf, reg, val);
> }
>
> I can only see one time print:
> (XEN) cjq_debug 0000:03:00.0: bar ctrl write reg 520, val d40
>
> The check prevented the two times incorrect write actions.
> if ( pci_conf_read16(pdev->sbdf, PCI_COMMAND) & PCI_COMMAND_MEMORY )
> return;
>
> And why my original patch can work too, the check:
> + ctrl = pci_conf_read32(pdev->sbdf, reg);
> + if ( ctrl == val )
> + return;
> happened to play the same role as PCI_COMMAND_MEMORY check.
Thank you very much for figuring this out. So in the end it's a bug
in the driver that plays with PCI_REBAR_CTRL with memory decoding
enabled.
Won't this also cause issues when running natively without Xen?
I think we have no other option but to trap accesses to the capability
registers themselves in order to ensure a minimum amount of sanity
(iow: no writes to the ReBAR control registers decoding is enabled).
Thanks, Roger.
next prev parent reply other threads:[~2024-11-25 12:47 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é [this message]
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é
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=Z0Rx2IXqqvrLaIIq@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.