[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v3 01/11] vpci: Make vpci registers removal a dedicated function


  • To: Oleksandr Andrushchenko <andr2000@xxxxxxxxx>
  • From: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Date: Wed, 13 Oct 2021 13:11:30 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=h7OQN7BI/Pam2ZgJKQI4eQX42gLcyydSXTJrvLWaQEY=; b=T98yJItHVzeVRboQoqbpg0UfzDuYJ9OL3rF3M+pWXDu+jqvKeCrMLGW7LbcjrjIZkeU5kDgFE8+oS2RVWqLQwD+4D1Z03mYRI7KCoBR6wcb2CHniznUS5rn6LUfnvba9xNBAEj3mHn9q6cFXR9gHOKWWP3rU5lsG1wrzP12WMz+FQejzaVOpGU0bTkCsyv1RqJ29nfIs33HnE/C/HUp+e+1uQzxcGuXwV5pJvGpaImKECX5oJfRFXckvS8GwTA4pxhJFn3l9FGYvK7yTCrztqGHLgd9ITfiSITVk7VSGGhJtbgfFn5OijwEUbDLC6WHISEk3PPna1wUqliP4HGUhKA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bfGYgkozpzMVVPTEfNc8aNzNN9Qn+Xfjr8a+zCNUdaAWOlJh7XnOer/t8vkAKtHweBMUE430ij1wp/AzZ5V2qSuQNDPE79EtMT5TK7Bw74n4JaWlKrKKQ1fqm1DOUClUMWlPTpEcMJyOtnjqoy5Sa9V7OYnVj2HrOB35alog3tsDX5L2z7wFC3QHa5PgVaylYCCLm3cAlVLNgU2pFfQGpmml6a6MkhVOurCPZaxxLh8rsCdrDna+e1cYyylWkW8nh4FG8IXIs1sm0K0pMq+xgunTo3mdenC7D/Hiq6Yvv4x/GahJsMkQFuTUtr/xiOs8M2DVgztwYfKhkXnS6NwlLg==
  • Authentication-results: esa4.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com
  • Cc: <xen-devel@xxxxxxxxxxxxxxxxxxxx>, <julien@xxxxxxx>, <sstabellini@xxxxxxxxxx>, <oleksandr_tyshchenko@xxxxxxxx>, <volodymyr_babchuk@xxxxxxxx>, <Artem_Mygaiev@xxxxxxxx>, <jbeulich@xxxxxxxx>, <bertrand.marquis@xxxxxxx>, <rahul.singh@xxxxxxx>, Oleksandr Andrushchenko <oleksandr_andrushchenko@xxxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>
  • Delivery-date: Wed, 13 Oct 2021 11:12:11 +0000
  • Ironport-data: A9a23:Xp/oRaJBTYwPHGMUFE+RHJMlxSXFcZb7ZxGr2PjKsXjdYENS1TZSz zdMCmnUaP+MN2X9edh0YIuz/UkDu5/Rz98yT1NlqX01Q3x08seUXt7xwmUcns+xwm8vaGo9s q3yv/GZdJhcokcxIn5BC5C5xZVG/fjgqoHUVaiUZ0ideSc+EH140Eo6wLZg6mJVqYPR7z2l6 IuaT/L3YDdJ6xYsWo7Dw/vewP/HlK2aVAIw5jTSV9gS1LPtvyB94KYkDbOwNxPFrrx8RYZWc QphIIaRpQs19z91Yj+sfy2SnkciGtY+NiDW4pZatjTLbrGvaUXe345iXMfwZ3u7hB27p+x09 vJy66b3biUCGqqVgtYXCylxRnQW0a1uoNcrIFC6uM2XiUbHb2Ht07NlC0Re0Y8wo7gtRzsUr LpBdW5LPkvra+GemdpXTsF2gcsuNo/zNZ43sXB81zDJS/0hRPgvRo2Xu44Fh2tg3KiiG97ad /c1OAdPYijtIEYfOQc2Jch5ltmB0yyXnzpw9wvO+PtfD3Lo5A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FZuXNHcn3q2X0LJ/dUy7xob7zgX3H+AQDgrx3KUFp8 647FDpslMZtkE/M2SmqlLG1HbQMtgut7WmD6CYjGCHRDpaQCr0aNaJsPRSeiSU4aiq2qilmodh OtNVE545f5c6hgn+YarLHI4yEKhjJt5f4tBp6EDf4jfND57/0oMzaEstqliS/B8FDlhinqrfq/ mjQjLNULZ15W3gE7WWIl6JKM
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On Thu, Sep 30, 2021 at 10:52:13AM +0300, Oleksandr Andrushchenko wrote:
> From: Oleksandr Andrushchenko <oleksandr_andrushchenko@xxxxxxxx>
> 
> This is in preparation for dynamic assignment of the vpci register
> handlers depending on the domain: hwdom or guest.
> 
> Signed-off-by: Oleksandr Andrushchenko <oleksandr_andrushchenko@xxxxxxxx>
> Reviewed-by: Michal Orzel <michal.orzel@xxxxxxx>
> ---
> Since v1:
>  - constify struct pci_dev where possible
> ---
>  xen/drivers/vpci/vpci.c | 7 ++++++-
>  xen/include/xen/vpci.h  | 2 ++
>  2 files changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/xen/drivers/vpci/vpci.c b/xen/drivers/vpci/vpci.c
> index cbd1bac7fc33..1666402d55b8 100644
> --- a/xen/drivers/vpci/vpci.c
> +++ b/xen/drivers/vpci/vpci.c
> @@ -35,7 +35,7 @@ extern vpci_register_init_t *const __start_vpci_array[];
>  extern vpci_register_init_t *const __end_vpci_array[];
>  #define NUM_VPCI_INIT (__end_vpci_array - __start_vpci_array)
>  
> -void vpci_remove_device(struct pci_dev *pdev)
> +void vpci_remove_device_registers(const struct pci_dev *pdev)

Making this const is kind of misleading, as you end up modifying
contents of the pdev, is just that vpci data is stored as a pointer
inside the struct so you avoid the effects of the constification.

>  {
>      spin_lock(&pdev->vpci->lock);
>      while ( !list_empty(&pdev->vpci->handlers) )
> @@ -48,6 +48,11 @@ void vpci_remove_device(struct pci_dev *pdev)
>          xfree(r);
>      }
>      spin_unlock(&pdev->vpci->lock);
> +}
> +
> +void vpci_remove_device(struct pci_dev *pdev)
> +{
> +    vpci_remove_device_registers(pdev);
>      xfree(pdev->vpci->msix);
>      xfree(pdev->vpci->msi);
>      xfree(pdev->vpci);
> diff --git a/xen/include/xen/vpci.h b/xen/include/xen/vpci.h
> index 9f5b5d52e159..2e910d0b1f90 100644
> --- a/xen/include/xen/vpci.h
> +++ b/xen/include/xen/vpci.h
> @@ -28,6 +28,8 @@ int __must_check vpci_add_handlers(struct pci_dev *dev);
>  
>  /* Remove all handlers and free vpci related structures. */
>  void vpci_remove_device(struct pci_dev *pdev);
> +/* Remove all handlers for the device given. */

I would drop the 'given' form the end of the sentence...

> +void vpci_remove_device_registers(const struct pci_dev *pdev);

...and maybe name this vpci_remove_device_handlers as it's clearer
IMO.

Thanks, Roger.



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.