Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 293978
b: refs/heads/master
c: cd9db80
h: refs/heads/master
v: v3
  • Loading branch information
Konrad Rzeszutek Wilk committed Jan 12, 2012
1 parent a2f9d03 commit 796bc99
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 4 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: a96d627abaac899e8bfaf18fd0578b228c9c752f
refs/heads/master: cd9db80e5257682a7f7ab245a2459648b3c8d268
41 changes: 38 additions & 3 deletions trunk/drivers/xen/xen-pciback/pci_stub.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,19 +85,34 @@ static struct pcistub_device *pcistub_device_alloc(struct pci_dev *dev)
static void pcistub_device_release(struct kref *kref)
{
struct pcistub_device *psdev;
struct xen_pcibk_dev_data *dev_data;

psdev = container_of(kref, struct pcistub_device, kref);
dev_data = pci_get_drvdata(psdev->dev);

dev_dbg(&psdev->dev->dev, "pcistub_device_release\n");

xen_unregister_device_domain_owner(psdev->dev);

/* Clean-up the device */
/* Call the reset function which does not take lock as this
* is called from "unbind" which takes a device_lock mutex.
*/
__pci_reset_function_locked(psdev->dev);
if (pci_load_and_free_saved_state(psdev->dev,
&dev_data->pci_saved_state)) {
dev_dbg(&psdev->dev->dev, "Could not reload PCI state\n");
} else
pci_restore_state(psdev->dev);

/* Disable the device */
xen_pcibk_reset_device(psdev->dev);

kfree(dev_data);
pci_set_drvdata(psdev->dev, NULL);

/* Clean-up the device */
xen_pcibk_config_free_dyn_fields(psdev->dev);
xen_pcibk_config_free_dev(psdev->dev);
kfree(pci_get_drvdata(psdev->dev));
pci_set_drvdata(psdev->dev, NULL);

psdev->dev->dev_flags &= ~PCI_DEV_FLAGS_ASSIGNED;
pci_dev_put(psdev->dev);
Expand Down Expand Up @@ -231,7 +246,17 @@ void pcistub_put_pci_dev(struct pci_dev *dev)
/* Cleanup our device
* (so it's ready for the next domain)
*/

/* This is OK - we are running from workqueue context
* and want to inhibit the user from fiddling with 'reset'
*/
pci_reset_function(dev);
pci_restore_state(psdev->dev);

/* This disables the device. */
xen_pcibk_reset_device(found_psdev->dev);

/* And cleanup up our emulated fields. */
xen_pcibk_config_free_dyn_fields(found_psdev->dev);
xen_pcibk_config_reset_dev(found_psdev->dev);

Expand Down Expand Up @@ -328,6 +353,16 @@ static int __devinit pcistub_init_device(struct pci_dev *dev)
if (err)
goto config_release;

dev_dbg(&dev->dev, "reseting (FLR, D3, etc) the device\n");
__pci_reset_function_locked(dev);

/* We need the device active to save the state. */
dev_dbg(&dev->dev, "save state of device\n");
pci_save_state(dev);
dev_data->pci_saved_state = pci_store_saved_state(dev);
if (!dev_data->pci_saved_state)
dev_err(&dev->dev, "Could not store PCI conf saved state!\n");

/* Now disable the device (this also ensures some private device
* data is setup before we export)
*/
Expand Down
1 change: 1 addition & 0 deletions trunk/drivers/xen/xen-pciback/pciback.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ struct xen_pcibk_device {

struct xen_pcibk_dev_data {
struct list_head config_fields;
struct pci_saved_state *pci_saved_state;
unsigned int permissive:1;
unsigned int warned_on_write:1;
unsigned int enable_intx:1;
Expand Down

0 comments on commit 796bc99

Please sign in to comment.