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: Jan Beulich <jbeulich@suse.com>,
	"xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>,
	Andrew Cooper <andrew.cooper3@citrix.com>,
	Julien Grall <julien@xen.org>,
	Stefano Stabellini <sstabellini@kernel.org>,
	"Huang, Ray" <Ray.Huang@amd.com>
Subject: Re: [PATCH v5] vpci: Add resizable bar support
Date: Tue, 21 Jan 2025 10:29:06 +0100	[thread overview]
Message-ID: <Z49o4iyY7vPhz2ow@macbook.local> (raw)
In-Reply-To: <BL1PR12MB58492016DDBB106A607F32CDE7E62@BL1PR12MB5849.namprd12.prod.outlook.com>

On Tue, Jan 21, 2025 at 09:10:26AM +0000, Chen, Jiqian wrote:
> On 2025/1/21 16:46, Roger Pau Monné wrote:
> > On Tue, Jan 14, 2025 at 11:26:36AM +0800, Jiqian Chen wrote:
> >> +    ctrl = pci_conf_read32(pdev->sbdf, rebar_offset + PCI_REBAR_CTRL(0));
> >> +    nbars = MASK_EXTR(ctrl, PCI_REBAR_CTRL_NBAR_MASK);
> >> +    for ( unsigned int i = 0; i < nbars; i++ )
> >> +    {
> >> +        int rc;
> >> +        struct vpci_bar *bar;
> >> +        unsigned int index;
> >> +
> >> +        ctrl = pci_conf_read32(pdev->sbdf, rebar_offset + PCI_REBAR_CTRL(i));
> >> +        index = ctrl & PCI_REBAR_CTRL_BAR_IDX;
> >> +        if ( index >= PCI_HEADER_NORMAL_NR_BARS )
> >> +        {
> >> +            printk(XENLOG_ERR "%pd %pp: too big BAR number %u in REBAR_CTRL\n",
> >> +                   pdev->domain, &pdev->sbdf, index);
> >> +            continue;
> >> +        }
> >> +
> >> +        bar = &pdev->vpci->header.bars[index];
> >> +        if ( bar->type != VPCI_BAR_MEM64_LO && bar->type != VPCI_BAR_MEM32 )
> >> +        {
> >> +            printk(XENLOG_ERR "%pd %pp: BAR%u is not in memory space\n",
> >> +                   pdev->domain, &pdev->sbdf, index);
> >> +            continue;
> >> +        }
> >> +
> >> +        rc = vpci_add_register(pdev->vpci, vpci_hw_read32, vpci_hw_write32,
> >> +                               rebar_offset + PCI_REBAR_CAP(i), 4, NULL);
> >> +        if ( rc )
> >> +        {
> >> +            /*
> >> +             * TODO: for failed pathes, need to hide ReBar capability
> >> +             * from hardware domain instead of returning an error.
> >> +             */
> >> +            printk(XENLOG_ERR "%pd %pp: fail to add reg of REBAR_CAP rc=%d\n",
> >> +                   pdev->domain, &pdev->sbdf, rc);
> >> +            return rc;
> >> +        }
> >> +
> >> +        rc = vpci_add_register(pdev->vpci, vpci_hw_read32, rebar_ctrl_write,
> >> +                               rebar_offset + PCI_REBAR_CTRL(i), 4, bar);
> >> +        if ( rc )
> >> +        {
> >> +            printk(XENLOG_ERR "%pd %pp: fail to add reg of REBAR_CTRL rc=%d\n",
> >> +                   pdev->domain, &pdev->sbdf, rc);
> >> +            return rc;
> > 
> > I think we said we wanted to attempt to continue here, rather than
> > returning an error and thus removing all vPCI handlers from the
> > device?
> I thought the result of your discussion with Jan was that I only needed to change the above two error paths to be "continue".
> If these two also need to be changed, I will modify them in the next version.

Hm, let's wait for Jan to confirm, but even if handler cannot be setup
for some of the registers, it's better than just allowing dom0
unmediated access to the capability.

None of this is ideal, but it seems to be the option that gives dom0
most options to successfully boot.

Thanks, Roger.


  reply	other threads:[~2025-01-21  9:29 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-14  3:26 [PATCH v5] vpci: Add resizable bar support Jiqian Chen
2025-01-20 15:35 ` Jan Beulich
2025-01-21  6:19   ` Chen, Jiqian
2025-01-21  8:46 ` Roger Pau Monné
2025-01-21  9:10   ` Chen, Jiqian
2025-01-21  9:29     ` Roger Pau Monné [this message]
2025-01-21 10:29       ` Jan Beulich
2025-01-22  2:50         ` Chen, Jiqian

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=Z49o4iyY7vPhz2ow@macbook.local \
    --to=roger.pau@citrix.com \
    --cc=Jiqian.Chen@amd.com \
    --cc=Ray.Huang@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.