aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>2009-12-09 17:43:15 -0500
committerKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>2011-07-19 20:58:29 -0400
commit6221a9b2a11acfb54e7b41da425e961b31e88553 (patch)
treecea7181fabd0f3baacb50cbc67c87d58ff17e7ec
parent8bfd4e023f5fb5793d7d7483b6e17e04933c53e9 (diff)
xen/pciback: Register the owner (domain) of the PCI device.
When the front-end and back-end start negotiating we register the domain that will use the PCI device. Furthermore during shutdown of guest or unbinding of the PCI device (and unloading of module) from pciback we unregister the domain owner. Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
-rw-r--r--drivers/xen/xen-pciback/pci_stub.c2
-rw-r--r--drivers/xen/xen-pciback/xenbus.c13
2 files changed, 15 insertions, 0 deletions
diff --git a/drivers/xen/xen-pciback/pci_stub.c b/drivers/xen/xen-pciback/pci_stub.c
index e7853c340d7..ac8396d8206 100644
--- a/drivers/xen/xen-pciback/pci_stub.c
+++ b/drivers/xen/xen-pciback/pci_stub.c
@@ -90,6 +90,8 @@ static void pcistub_device_release(struct kref *kref)
90 90
91 dev_dbg(&psdev->dev->dev, "pcistub_device_release\n"); 91 dev_dbg(&psdev->dev->dev, "pcistub_device_release\n");
92 92
93 xen_unregister_device_domain_owner(psdev->dev);
94
93 /* Clean-up the device */ 95 /* Clean-up the device */
94 pciback_reset_device(psdev->dev); 96 pciback_reset_device(psdev->dev);
95 pciback_config_free_dyn_fields(psdev->dev); 97 pciback_config_free_dyn_fields(psdev->dev);
diff --git a/drivers/xen/xen-pciback/xenbus.c b/drivers/xen/xen-pciback/xenbus.c
index c0984cb442c..a0cf7285d32 100644
--- a/drivers/xen/xen-pciback/xenbus.c
+++ b/drivers/xen/xen-pciback/xenbus.c
@@ -10,6 +10,7 @@
10#include <linux/workqueue.h> 10#include <linux/workqueue.h>
11#include <xen/xenbus.h> 11#include <xen/xenbus.h>
12#include <xen/events.h> 12#include <xen/events.h>
13#include <asm/xen/pci.h>
13#include <linux/workqueue.h> 14#include <linux/workqueue.h>
14#include "pciback.h" 15#include "pciback.h"
15 16
@@ -221,6 +222,15 @@ static int pciback_export_device(struct pciback_device *pdev,
221 if (err) 222 if (err)
222 goto out; 223 goto out;
223 224
225 dev_dbg(&dev->dev, "registering for %d\n", pdev->xdev->otherend_id);
226 if (xen_register_device_domain_owner(dev,
227 pdev->xdev->otherend_id) != 0) {
228 dev_err(&dev->dev, "device has been assigned to another " \
229 "domain! Over-writting the ownership, but beware.\n");
230 xen_unregister_device_domain_owner(dev);
231 xen_register_device_domain_owner(dev, pdev->xdev->otherend_id);
232 }
233
224 /* TODO: It'd be nice to export a bridge and have all of its children 234 /* TODO: It'd be nice to export a bridge and have all of its children
225 * get exported with it. This may be best done in xend (which will 235 * get exported with it. This may be best done in xend (which will
226 * have to calculate resource usage anyway) but we probably want to 236 * have to calculate resource usage anyway) but we probably want to
@@ -251,6 +261,9 @@ static int pciback_remove_device(struct pciback_device *pdev,
251 goto out; 261 goto out;
252 } 262 }
253 263
264 dev_dbg(&dev->dev, "unregistering for %d\n", pdev->xdev->otherend_id);
265 xen_unregister_device_domain_owner(dev);
266
254 pciback_release_pci_dev(pdev, dev); 267 pciback_release_pci_dev(pdev, dev);
255 268
256out: 269out: