From: "Roger Pau Monné" <roger.pau@citrix.com>
To: Jan Beulich <jbeulich@suse.com>
Cc: Alex Olson <this.is.a0lson@gmail.com>, <xen-devel@lists.xenproject.org>
Subject: Re: [PATCH v4] vpci/msix: fix PBA accesses
Date: Tue, 8 Mar 2022 10:05:12 +0100 [thread overview]
Message-ID: <YiccSMWbV2StPFB1@Air-de-Roger> (raw)
In-Reply-To: <fbc1388e-8211-f498-b134-4df5b1ccd003@suse.com>
On Tue, Mar 08, 2022 at 09:31:34AM +0100, Jan Beulich wrote:
> On 07.03.2022 17:37, Roger Pau Monne wrote:
> > Map the PBA in order to access it from the MSI-X read and write
> > handlers. Note that previously the handlers would pass the physical
> > host address into the {read,write}{l,q} handlers, which is wrong as
> > those expect a linear address.
> >
> > Map the PBA using ioremap when the first access is performed. Note
> > that 32bit arches might want to abstract the call to ioremap into a
> > vPCI arch handler, so they can use a fixmap range to map the PBA.
> >
> > Reported-by: Jan Beulich <jbeulich@suse.com>
> > Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
>
> Reviewed-by: Jan Beulich <jbeulich@suse.com>
>
> > Cc: Alex Olson <this.is.a0lson@gmail.com>
>
> I'll wait a little with committing, in the hope for Alex to re-provide
> a Tested-by.
>
> > --- a/xen/drivers/vpci/msix.c
> > +++ b/xen/drivers/vpci/msix.c
> > @@ -182,6 +182,38 @@ static struct vpci_msix_entry *get_entry(struct vpci_msix *msix,
> > return &msix->entries[(addr - start) / PCI_MSIX_ENTRY_SIZE];
> > }
> >
> > +static void __iomem *get_pba(struct vpci *vpci)
> > +{
> > + struct vpci_msix *msix = vpci->msix;
> > + /*
> > + * PBA will only be unmapped when the device is deassigned, so access it
> > + * without holding the vpci lock.
> > + */
> > + void __iomem *pba = read_atomic(&msix->pba);
> > +
> > + if ( likely(pba) )
> > + return pba;
> > +
> > + pba = ioremap(vmsix_table_addr(vpci, VPCI_MSIX_PBA),
> > + vmsix_table_size(vpci, VPCI_MSIX_PBA));
> > + if ( !pba )
> > + return read_atomic(&msix->pba);
> > +
> > + spin_lock(&vpci->lock);
> > + if ( !msix->pba )
> > + {
> > + write_atomic(&msix->pba, pba);
> > + spin_unlock(&vpci->lock);
> > + }
> > + else
> > + {
> > + spin_unlock(&vpci->lock);
> > + iounmap(pba);
> > + }
>
> TBH I had been hoping for just a single spin_unlock(), but you're
> the maintainer of this code ...
Would you prefer something like:
spin_lock(&vpci->lock);
if ( !msix->pba )
write_atomic(&msix->pba, pba);
spin_unlock(&vpci->lock);
if ( read_atomic(&msix->pba) != pba )
iounmap(pba);
?
Thanks, Roger.
next prev parent reply other threads:[~2022-03-08 9:05 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-07 16:37 [PATCH v4] vpci/msix: fix PBA accesses Roger Pau Monne
2022-03-08 8:31 ` Jan Beulich
2022-03-08 9:05 ` Roger Pau Monné [this message]
2022-03-08 10:46 ` Jan Beulich
2022-03-08 12:37 ` Roger Pau Monné
2022-03-08 18:19 ` Alex Olson
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=YiccSMWbV2StPFB1@Air-de-Roger \
--to=roger.pau@citrix.com \
--cc=jbeulich@suse.com \
--cc=this.is.a0lson@gmail.com \
--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.