{
int err = 0;
struct passthrough_dev_data *dev_data = pdev->pci_dev_data;
- struct pci_dev_entry *dev_entry, *e;
+ struct pci_dev_entry *dev_entry, *e, *tmp;
struct pci_dev *dev;
int found;
unsigned int domain, bus;
spin_lock(&dev_data->lock);
- list_for_each_entry(dev_entry, &dev_data->dev_list, list) {
+ list_for_each_entry_safe(dev_entry, tmp, &dev_data->dev_list, list) {
/* Only publish this device as a root if none of its
* parent bridges are exported
*/
bus = (unsigned int)dev_entry->dev->bus->number;
if (!found) {
+ spin_unlock(&dev_data->lock);
err = publish_root_cb(pdev, domain, bus);
if (err)
break;
+ spin_lock(&dev_data->lock);
}
}
- spin_unlock(&dev_data->lock);
+ if (!err)
+ spin_unlock(&dev_data->lock);
return err;
}
unbind_from_irqhandler(pdev->evtchn_irq, pdev);
pdev->evtchn_irq = INVALID_EVTCHN_IRQ;
}
+ spin_unlock(&pdev->dev_lock);
/* If the driver domain started an op, make sure we complete it
* before releasing the shared memory */
+
+ /* Note, the workqueue does not use spinlocks at all.*/
flush_workqueue(pciback_wq);
+ spin_lock(&pdev->dev_lock);
if (pdev->sh_info != NULL) {
xenbus_unmap_ring_vfree(pdev->xdev, pdev->sh_info);
pdev->sh_info = NULL;
}
-
spin_unlock(&pdev->dev_lock);
+
}
static void free_pdev(struct pciback_device *pdev)
{
- if (pdev->be_watching)
+ if (pdev->be_watching) {
unregister_xenbus_watch(&pdev->be_watch);
+ pdev->be_watching = 0;
+ }
pciback_disconnect(pdev);
"Error mapping other domain page in ours.");
goto out;
}
+
+ spin_lock(&pdev->dev_lock);
pdev->sh_info = vaddr;
+ spin_unlock(&pdev->dev_lock);
err = bind_interdomain_evtchn_to_irqhandler(
pdev->xdev->otherend_id, remote_evtchn, pciback_handle_event,
"Error binding event channel to IRQ");
goto out;
}
+
+ spin_lock(&pdev->dev_lock);
pdev->evtchn_irq = err;
+ spin_unlock(&pdev->dev_lock);
err = 0;
dev_dbg(&pdev->xdev->dev, "Attached!\n");
int gnt_ref, remote_evtchn;
char *magic = NULL;
- spin_lock(&pdev->dev_lock);
/* Make sure we only do this setup once */
if (xenbus_read_driver_state(pdev->xdev->nodename) !=
dev_dbg(&pdev->xdev->dev, "Connected? %d\n", err);
out:
- spin_unlock(&pdev->dev_lock);
kfree(magic);
char state_str[64];
char dev_str[64];
- spin_lock(&pdev->dev_lock);
dev_dbg(&pdev->xdev->dev, "Reconfiguring device ...\n");
}
out:
- spin_unlock(&pdev->dev_lock);
-
return 0;
}
char dev_str[64];
char state_str[64];
- spin_lock(&pdev->dev_lock);
-
/* It's possible we could get the call to setup twice, so make sure
* we're not already connected.
*/
"Error switching to initialised state!");
out:
- spin_unlock(&pdev->dev_lock);
-
if (!err)
/* see if pcifront is already configured (if not, we'll wait) */
pciback_attach(pdev);
pciback_be_watch);
if (err)
goto out;
+
pdev->be_watching = 1;
/* We need to force a call to our callback here in case