xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Roger Pau Monne <roger.pau@citrix.com>
To: xen-devel@lists.xenproject.org
Cc: Stefano Stabellini <sstabellini@kernel.org>,
	Wei Liu <wei.liu2@citrix.com>,
	George Dunlap <George.Dunlap@eu.citrix.com>,
	Andrew Cooper <andrew.cooper3@citrix.com>,
	Ian Jackson <ian.jackson@eu.citrix.com>, Tim Deegan <tim@xen.org>,
	Julien Grall <julien.grall@arm.com>,
	Jan Beulich <jbeulich@suse.com>,
	Roger Pau Monne <roger.pau@citrix.com>
Subject: [PATCH v2 09/11] pci: add vpci hooks for device addition/removal
Date: Tue, 17 Jul 2018 11:48:28 +0200	[thread overview]
Message-ID: <20180717094830.54806-10-roger.pau@citrix.com> (raw)
In-Reply-To: <20180717094830.54806-1-roger.pau@citrix.com>

So that pci_{add/remove}_device work correctly with vpci. Note that
this requires moving vpci_add_handlers out of the init section.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Reviewed-by: Wei Liu <wei.liu2@citrix.com>
---
Cc: Andrew Cooper <andrew.cooper3@citrix.com>
Cc: George Dunlap <George.Dunlap@eu.citrix.com>
Cc: Ian Jackson <ian.jackson@eu.citrix.com>
Cc: Jan Beulich <jbeulich@suse.com>
Cc: Julien Grall <julien.grall@arm.com>
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: Stefano Stabellini <sstabellini@kernel.org>
Cc: Tim Deegan <tim@xen.org>
Cc: Wei Liu <wei.liu2@citrix.com>
---
 xen/drivers/passthrough/pci.c | 8 ++++++++
 xen/drivers/vpci/vpci.c       | 2 +-
 xen/include/xen/vpci.h        | 2 ++
 3 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/xen/drivers/passthrough/pci.c b/xen/drivers/passthrough/pci.c
index a5d59b83b7..a712db0294 100644
--- a/xen/drivers/passthrough/pci.c
+++ b/xen/drivers/passthrough/pci.c
@@ -768,6 +768,13 @@ int pci_add_device(u16 seg, u8 bus, u8 devfn,
             goto out;
         }
 
+        ret = vpci_add_handlers(pdev);
+        if ( ret )
+        {
+            pdev->domain = NULL;
+            goto out;
+        }
+
         list_add(&pdev->domain_list, &hardware_domain->arch.pdev_list);
     }
     else
@@ -812,6 +819,7 @@ int pci_remove_device(u16 seg, u8 bus, u8 devfn)
     list_for_each_entry ( pdev, &pseg->alldevs_list, alldevs_list )
         if ( pdev->bus == bus && pdev->devfn == devfn )
         {
+            vpci_remove_device(pdev);
             ret = iommu_remove_device(pdev);
             if ( pdev->domain )
                 list_del(&pdev->domain_list);
diff --git a/xen/drivers/vpci/vpci.c b/xen/drivers/vpci/vpci.c
index 0569459699..732d3525ae 100644
--- a/xen/drivers/vpci/vpci.c
+++ b/xen/drivers/vpci/vpci.c
@@ -72,7 +72,7 @@ void vpci_remove_device(struct pci_dev *pdev)
     spin_unlock(&pdev->vpci_lock);
 }
 
-int __hwdom_init vpci_add_handlers(struct pci_dev *pdev)
+int vpci_add_handlers(struct pci_dev *pdev)
 {
     unsigned int i;
     int rc = 0;
diff --git a/xen/include/xen/vpci.h b/xen/include/xen/vpci.h
index 208667227e..e629224088 100644
--- a/xen/include/xen/vpci.h
+++ b/xen/include/xen/vpci.h
@@ -224,6 +224,8 @@ static inline int vpci_add_handlers(struct pci_dev *pdev)
     return 0;
 }
 
+static inline void vpci_remove_device(struct pci_dev *pdev) { }
+
 static inline void vpci_dump_msi(void) { }
 
 static inline uint32_t vpci_read(pci_sbdf_t sbdf, unsigned int reg,
-- 
2.17.1


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

  parent reply	other threads:[~2018-07-17  9:49 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-17  9:48 [PATCH v2 00/11] vpci: add support for SR-IOV capability Roger Pau Monne
2018-07-17  9:48 ` [PATCH v2 01/11] vpci: move lock Roger Pau Monne
2018-09-06  9:57   ` Wei Liu
2018-09-26 10:37   ` Jan Beulich
2018-07-17  9:48 ` [PATCH v2 02/11] vpci/msix: add lock to protect the list of MSIX regions Roger Pau Monne
2018-09-26 10:42   ` Jan Beulich
2018-07-17  9:48 ` [PATCH v2 03/11] vpci: add tear down functions Roger Pau Monne
2018-09-06  9:57   ` Wei Liu
2018-09-26 10:50   ` Jan Beulich
2018-07-17  9:48 ` [PATCH v2 04/11] vpci/msix: add teardown cleanup Roger Pau Monne
2018-09-06 10:14   ` Wei Liu
2018-09-26 15:32   ` Jan Beulich
2018-07-17  9:48 ` [PATCH v2 05/11] vpci/msi: " Roger Pau Monne
2018-09-06 10:14   ` Wei Liu
2018-09-26 15:34   ` Jan Beulich
2018-07-17  9:48 ` [PATCH v2 06/11] vpci/header: " Roger Pau Monne
2018-09-28 15:29   ` Jan Beulich
2018-07-17  9:48 ` [PATCH v2 07/11] rangeset: introduce rangeset_merge Roger Pau Monne
2018-07-17  9:48 ` [PATCH v2 08/11] vpci/header: allow multiple map operations Roger Pau Monne
2018-09-28 15:38   ` Jan Beulich
2018-07-17  9:48 ` Roger Pau Monne [this message]
2018-09-28 15:48   ` [PATCH v2 09/11] pci: add vpci hooks for device addition/removal Jan Beulich
2018-07-17  9:48 ` [PATCH v2 10/11] vpci: add a wait operation to the vpci vcpu pending actions Roger Pau Monne
2018-07-17  9:48 ` [PATCH v2 11/11] vpci/sriov: add support for SR-IOV capability Roger Pau Monne
2018-09-06 10:37   ` Wei Liu
2018-09-07  9:16     ` Roger Pau Monné
2018-10-04 14:50   ` Jan Beulich

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=20180717094830.54806-10-roger.pau@citrix.com \
    --to=roger.pau@citrix.com \
    --cc=George.Dunlap@eu.citrix.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=ian.jackson@eu.citrix.com \
    --cc=jbeulich@suse.com \
    --cc=julien.grall@arm.com \
    --cc=sstabellini@kernel.org \
    --cc=tim@xen.org \
    --cc=wei.liu2@citrix.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).