All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Roger Pau Monné" <roger.pau@citrix.com>
To: Oleksandr Andrushchenko <Oleksandr_Andrushchenko@epam.com>
Cc: "xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>,
	"julien@xen.org" <julien@xen.org>,
	"sstabellini@kernel.org" <sstabellini@kernel.org>,
	Oleksandr Tyshchenko <Oleksandr_Tyshchenko@epam.com>,
	Volodymyr Babchuk <Volodymyr_Babchuk@epam.com>,
	Artem Mygaiev <Artem_Mygaiev@epam.com>,
	"jbeulich@suse.com" <jbeulich@suse.com>,
	Bertrand Marquis <bertrand.marquis@arm.com>,
	Rahul Singh <rahul.singh@arm.com>
Subject: Re: [PATCH v3 04/11] vpci/header: Add and remove register handlers dynamically
Date: Tue, 2 Nov 2021 11:03:02 +0100	[thread overview]
Message-ID: <YYEM1lX8NhK7nfhj@Air-de-Roger> (raw)
In-Reply-To: <ba1fea82-e2db-89af-b48d-56d393bd4ce8@epam.com>

On Mon, Nov 01, 2021 at 09:18:17AM +0000, Oleksandr Andrushchenko wrote:
> 
> >> +    if ( rc )
> >> +        gdprintk(XENLOG_ERR,
> >> +                 "%pp: failed to add BAR handlers for dom%pd: %d\n",
> >> +                 &pdev->sbdf, d, rc);
> >> +    return rc;
> >> +}
> >> +
> >> +int vpci_bar_remove_handlers(const struct domain *d, const struct pci_dev *pdev)
> >> +{
> >> +    /* Remove previously added registers. */
> >> +    vpci_remove_device_registers(pdev);
> >> +    return 0;
> >> +}
> >> +#endif
> >> +
> >>   /*
> >>    * Local variables:
> >>    * mode: C
> >> diff --git a/xen/drivers/vpci/vpci.c b/xen/drivers/vpci/vpci.c
> >> index 0fe86cb30d23..702f7b5d5dda 100644
> >> --- a/xen/drivers/vpci/vpci.c
> >> +++ b/xen/drivers/vpci/vpci.c
> >> @@ -95,7 +95,7 @@ int vpci_assign_device(struct domain *d, const struct pci_dev *dev)
> >>       if ( is_system_domain(d) || !has_vpci(d) )
> >>           return 0;
> >>   
> >> -    return 0;
> >> +    return vpci_bar_add_handlers(d, dev);
> >>   }
> >>   
> >>   /* Notify vPCI that device is de-assigned from guest. */
> >> @@ -105,7 +105,7 @@ int vpci_deassign_device(struct domain *d, const struct pci_dev *dev)
> >>       if ( is_system_domain(d) || !has_vpci(d) )
> >>           return 0;
> >>   
> >> -    return 0;
> >> +    return vpci_bar_remove_handlers(d, dev);
> > I think it would be better to use something similar to
> > REGISTER_VPCI_INIT here, otherwise this will need to be modified every
> > time a new capability is handled by Xen.
> >
> > Maybe we could reuse or expand REGISTER_VPCI_INIT adding another field
> > to be used for guest initialization?
> >
> >>   }
> >>   #endif /* CONFIG_HAS_VPCI_GUEST_SUPPORT */
> >>   
> >> diff --git a/xen/include/xen/vpci.h b/xen/include/xen/vpci.h
> >> index ecc08f2c0f65..fd822c903af5 100644
> >> --- a/xen/include/xen/vpci.h
> >> +++ b/xen/include/xen/vpci.h
> >> @@ -57,6 +57,14 @@ uint32_t vpci_hw_read32(const struct pci_dev *pdev, unsigned int reg,
> >>    */
> >>   bool __must_check vpci_process_pending(struct vcpu *v);
> >>   
> >> +#ifdef CONFIG_HAS_VPCI_GUEST_SUPPORT
> >> +/* Add/remove BAR handlers for a domain. */
> >> +int vpci_bar_add_handlers(const struct domain *d,
> >> +                          const struct pci_dev *pdev);
> >> +int vpci_bar_remove_handlers(const struct domain *d,
> >> +                             const struct pci_dev *pdev);
> >> +#endif
> > This would then go away if we implement a mechanism similar to
> > REGISTER_VPCI_INIT.
> >
> > Thanks, Roger.
> Ok, so I can extend REGISTER_VPCI_INIT with an action parameter:
> 
> "There are number of actions to be taken while first initializing vPCI
> for a PCI device or when the device is assigned to a guest or when it
> is de-assigned and so on.
> Every time a new action is needed during these steps we need to call some
> relevant function to handle that. Make it is easier to track the required
> steps by extending REGISTER_VPCI_INIT machinery with an action parameter
> which shows which exactly step/action is being performed."
> 
> So, we have
> 
> -typedef int vpci_register_init_t(struct pci_dev *dev);
> +enum VPCI_INIT_ACTION {
> +  VPCI_INIT_ADD,
> +  VPCI_INIT_ASSIGN,
> +  VPCI_INIT_DEASSIGN,
> +};
> +
> +typedef int vpci_register_init_t(struct pci_dev *dev,
> +                                 enum VPCI_INIT_ACTION action);
> 
> and, for example,
> 
> @@ -452,6 +452,9 @@ static int init_bars(struct pci_dev *pdev)
>       struct vpci_bar *bars = header->bars;
>       int rc;
> 
> +    if ( action != VPCI_INIT_ADD )
> +        return 0;
> +
> 
> I was thinking about adding dedicated machinery similar to REGISTER_VPCI_INIT,
> e.g. REGISTER_VPCI_{ASSIGN|DEASSIGN} + dedicated sections in the linker scripts,
> but it seems not worth it: these steps are only executed at device init/assign/deassign,
> so extending the existing approach doesn't seem to hurt performance much.
> 
> Please let me know if this is what you mean, so I can re-work the relevant code.

I'm afraid I'm still unsure whether we need an explicit helper to
execute when assigning a device, rather than just using the current
init helpers (init_bars &c).

You said that sizing the BARs when assigning to a domU was not
possible [0], but I'm missing an explanation of why it's not possible,
as I think that won't be an issue on x86 [1].

Thanks, Roger.

[0] https://lore.kernel.org/xen-devel/368bf4b5-f9fd-76a6-294e-dbb93a18e73f@epam.com/
[1] https://lore.kernel.org/xen-devel/YXlxmdYdwptakDDK@Air-de-Roger/


  reply	other threads:[~2021-11-02 10:03 UTC|newest]

Thread overview: 98+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-30  7:52 [PATCH v3 00/11] PCI devices passthrough on Arm, part 3 Oleksandr Andrushchenko
2021-09-30  7:52 ` [PATCH v3 01/11] vpci: Make vpci registers removal a dedicated function Oleksandr Andrushchenko
2021-10-13 11:11   ` Roger Pau Monné
2021-10-27  9:12     ` Oleksandr Andrushchenko
2021-10-27  9:24       ` Roger Pau Monné
2021-10-27  9:41         ` Oleksandr Andrushchenko
2021-09-30  7:52 ` [PATCH v3 02/11] vpci: Add hooks for PCI device assign/de-assign Oleksandr Andrushchenko
2021-09-30  8:21   ` Jan Beulich
2021-09-30  8:45     ` Oleksandr Andrushchenko
2021-09-30  9:06       ` Jan Beulich
2021-09-30  9:21         ` Oleksandr Andrushchenko
2021-09-30 10:14           ` Jan Beulich
2021-09-30 10:30             ` Oleksandr Andrushchenko
2021-10-13 11:29   ` Roger Pau Monné
2021-10-13 12:47     ` Jan Beulich
2021-10-27  9:53     ` Oleksandr Andrushchenko
2021-09-30  7:52 ` [PATCH v3 03/11] vpci/header: Move register assignments from init_bars Oleksandr Andrushchenko
2021-10-13 13:51   ` Roger Pau Monné
2021-10-15  6:04     ` Jan Beulich
2021-10-25 14:28       ` Roger Pau Monné
2021-10-27 10:17     ` Oleksandr Andrushchenko
2021-10-27 11:59       ` Oleksandr Andrushchenko
2021-10-27 13:23         ` Roger Pau Monné
2021-10-27 14:06           ` Oleksandr Andrushchenko
2021-10-27 15:34             ` Roger Pau Monné
2021-09-30  7:52 ` [PATCH v3 04/11] vpci/header: Add and remove register handlers dynamically Oleksandr Andrushchenko
2021-10-01 13:26   ` Jan Beulich
2021-10-04  5:58     ` Oleksandr Andrushchenko
2021-10-07  7:22       ` Jan Beulich
2021-10-13 15:38         ` Roger Pau Monné
2021-10-15  6:09           ` Jan Beulich
2021-10-25 15:48   ` Roger Pau Monné
2021-11-01  9:18     ` Oleksandr Andrushchenko
2021-11-02 10:03       ` Roger Pau Monné [this message]
2021-11-02 10:29         ` Oleksandr Andrushchenko
2021-09-30  7:52 ` [PATCH v3 05/11] vpci/header: Implement guest BAR register handlers Oleksandr Andrushchenko
2021-10-01 13:31   ` Jan Beulich
2021-10-26  7:50   ` Roger Pau Monné
2021-10-26  8:09     ` Oleksandr Andrushchenko
2021-09-30  7:52 ` [PATCH v3 06/11] vpci/header: Handle p2m range sets per BAR Oleksandr Andrushchenko
2021-10-25 11:51   ` Oleksandr Andrushchenko
2021-10-26  9:40     ` Roger Pau Monné
2021-11-02 11:13       ` Jan Beulich
2021-10-26  9:08   ` Roger Pau Monné
2021-11-02 10:34     ` Oleksandr Andrushchenko
2021-09-30  7:52 ` [PATCH v3 07/11] vpci/header: program p2m with guest BAR view Oleksandr Andrushchenko
2021-10-01 13:38   ` Jan Beulich
2021-10-04  6:26     ` Oleksandr Andrushchenko
2021-10-26 10:35   ` Roger Pau Monné
2021-11-02 10:43     ` Oleksandr Andrushchenko
2021-09-30  7:52 ` [PATCH v3 08/11] vpci/header: Emulate PCI_COMMAND register for guests Oleksandr Andrushchenko
2021-10-26 10:52   ` Roger Pau Monné
2021-11-02 10:48     ` Oleksandr Andrushchenko
2021-11-02 11:19     ` Jan Beulich
2021-11-02 11:50       ` Roger Pau Monné
2021-11-02 13:54         ` Jan Beulich
2021-11-02 14:10           ` Oleksandr Andrushchenko
2021-11-03  8:53             ` Oleksandr Andrushchenko
2021-11-03  9:11               ` Jan Beulich
2021-11-03  9:18                 ` Oleksandr Andrushchenko
2021-11-03  9:24                   ` Jan Beulich
2021-11-03  9:30                     ` Oleksandr Andrushchenko
2021-11-03  9:49                       ` Jan Beulich
2021-11-03 10:24                         ` Oleksandr Andrushchenko
2021-11-03 10:34                           ` Jan Beulich
2021-11-03 10:36                             ` Oleksandr Andrushchenko
2021-11-03 11:01                               ` Roger Pau Monné
2021-11-03 11:02                                 ` Oleksandr Andrushchenko
2021-11-03 11:26                                   ` Roger Pau Monné
2021-11-03 11:34                                     ` Oleksandr Andrushchenko
2021-11-03  9:39                   ` Roger Pau Monné
2021-11-03  9:50                     ` Oleksandr Andrushchenko
2021-11-02 14:17         ` Julien Grall
2021-09-30  7:52 ` [PATCH v3 09/11] vpci/header: Reset the command register when adding devices Oleksandr Andrushchenko
2021-10-26 11:00   ` Roger Pau Monné
2021-11-02 11:11     ` Oleksandr Andrushchenko
2021-09-30  7:52 ` [PATCH v3 10/11] vpci: Add initial support for virtual PCI bus topology Oleksandr Andrushchenko
2021-09-30  8:51   ` Jan Beulich
2021-09-30  9:34     ` Oleksandr Andrushchenko
2021-09-30 10:23       ` Jan Beulich
2021-09-30 10:26         ` Oleksandr Andrushchenko
2021-10-26 11:33   ` Roger Pau Monné
2021-11-03  6:34     ` Oleksandr Andrushchenko
2021-11-03  8:41       ` Jan Beulich
2021-11-03  8:57         ` Oleksandr Andrushchenko
2021-11-03  8:52       ` Roger Pau Monné
2021-11-03  8:59         ` Oleksandr Andrushchenko
2021-09-30  7:52 ` [PATCH v3 11/11] xen/arm: Translate virtual PCI bus topology for guests Oleksandr Andrushchenko
2021-09-30  8:53   ` Jan Beulich
2021-09-30  9:35     ` Oleksandr Andrushchenko
2021-09-30 10:25       ` Jan Beulich
2021-09-30 16:57     ` Oleksandr Andrushchenko
2021-10-01  7:42       ` Jan Beulich
2021-10-01  7:57         ` Oleksandr Andrushchenko
2021-10-01  8:12           ` Jan Beulich
2021-10-18 18:32   ` Julien Grall
2021-10-26 13:30   ` Roger Pau Monné
2021-10-26 13:57     ` Oleksandr Andrushchenko

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=YYEM1lX8NhK7nfhj@Air-de-Roger \
    --to=roger.pau@citrix.com \
    --cc=Artem_Mygaiev@epam.com \
    --cc=Oleksandr_Andrushchenko@epam.com \
    --cc=Oleksandr_Tyshchenko@epam.com \
    --cc=Volodymyr_Babchuk@epam.com \
    --cc=bertrand.marquis@arm.com \
    --cc=jbeulich@suse.com \
    --cc=julien@xen.org \
    --cc=rahul.singh@arm.com \
    --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.