aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/xen/xen-pciback/xenbus.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/xen/xen-pciback/xenbus.c')
-rw-r--r--drivers/xen/xen-pciback/xenbus.c22
1 files changed, 9 insertions, 13 deletions
diff --git a/drivers/xen/xen-pciback/xenbus.c b/drivers/xen/xen-pciback/xenbus.c
index 522f2daa96cc..474d52ec3374 100644
--- a/drivers/xen/xen-pciback/xenbus.c
+++ b/drivers/xen/xen-pciback/xenbus.c
@@ -43,7 +43,7 @@ static struct xen_pcibk_device *alloc_pdev(struct xenbus_device *xdev)
43 pdev->xdev = xdev; 43 pdev->xdev = xdev;
44 dev_set_drvdata(&xdev->dev, pdev); 44 dev_set_drvdata(&xdev->dev, pdev);
45 45
46 spin_lock_init(&pdev->dev_lock); 46 mutex_init(&pdev->dev_lock);
47 47
48 pdev->sh_info = NULL; 48 pdev->sh_info = NULL;
49 pdev->evtchn_irq = INVALID_EVTCHN_IRQ; 49 pdev->evtchn_irq = INVALID_EVTCHN_IRQ;
@@ -61,14 +61,12 @@ out:
61 61
62static void xen_pcibk_disconnect(struct xen_pcibk_device *pdev) 62static void xen_pcibk_disconnect(struct xen_pcibk_device *pdev)
63{ 63{
64 spin_lock(&pdev->dev_lock); 64 mutex_lock(&pdev->dev_lock);
65
66 /* Ensure the guest can't trigger our handler before removing devices */ 65 /* Ensure the guest can't trigger our handler before removing devices */
67 if (pdev->evtchn_irq != INVALID_EVTCHN_IRQ) { 66 if (pdev->evtchn_irq != INVALID_EVTCHN_IRQ) {
68 unbind_from_irqhandler(pdev->evtchn_irq, pdev); 67 unbind_from_irqhandler(pdev->evtchn_irq, pdev);
69 pdev->evtchn_irq = INVALID_EVTCHN_IRQ; 68 pdev->evtchn_irq = INVALID_EVTCHN_IRQ;
70 } 69 }
71 spin_unlock(&pdev->dev_lock);
72 70
73 /* If the driver domain started an op, make sure we complete it 71 /* If the driver domain started an op, make sure we complete it
74 * before releasing the shared memory */ 72 * before releasing the shared memory */
@@ -76,13 +74,11 @@ static void xen_pcibk_disconnect(struct xen_pcibk_device *pdev)
76 /* Note, the workqueue does not use spinlocks at all.*/ 74 /* Note, the workqueue does not use spinlocks at all.*/
77 flush_workqueue(xen_pcibk_wq); 75 flush_workqueue(xen_pcibk_wq);
78 76
79 spin_lock(&pdev->dev_lock);
80 if (pdev->sh_info != NULL) { 77 if (pdev->sh_info != NULL) {
81 xenbus_unmap_ring_vfree(pdev->xdev, pdev->sh_info); 78 xenbus_unmap_ring_vfree(pdev->xdev, pdev->sh_info);
82 pdev->sh_info = NULL; 79 pdev->sh_info = NULL;
83 } 80 }
84 spin_unlock(&pdev->dev_lock); 81 mutex_unlock(&pdev->dev_lock);
85
86} 82}
87 83
88static void free_pdev(struct xen_pcibk_device *pdev) 84static void free_pdev(struct xen_pcibk_device *pdev)
@@ -119,9 +115,7 @@ static int xen_pcibk_do_attach(struct xen_pcibk_device *pdev, int gnt_ref,
119 goto out; 115 goto out;
120 } 116 }
121 117
122 spin_lock(&pdev->dev_lock);
123 pdev->sh_info = vaddr; 118 pdev->sh_info = vaddr;
124 spin_unlock(&pdev->dev_lock);
125 119
126 err = bind_interdomain_evtchn_to_irqhandler( 120 err = bind_interdomain_evtchn_to_irqhandler(
127 pdev->xdev->otherend_id, remote_evtchn, xen_pcibk_handle_event, 121 pdev->xdev->otherend_id, remote_evtchn, xen_pcibk_handle_event,
@@ -131,10 +125,7 @@ static int xen_pcibk_do_attach(struct xen_pcibk_device *pdev, int gnt_ref,
131 "Error binding event channel to IRQ"); 125 "Error binding event channel to IRQ");
132 goto out; 126 goto out;
133 } 127 }
134
135 spin_lock(&pdev->dev_lock);
136 pdev->evtchn_irq = err; 128 pdev->evtchn_irq = err;
137 spin_unlock(&pdev->dev_lock);
138 err = 0; 129 err = 0;
139 130
140 dev_dbg(&pdev->xdev->dev, "Attached!\n"); 131 dev_dbg(&pdev->xdev->dev, "Attached!\n");
@@ -149,6 +140,7 @@ static int xen_pcibk_attach(struct xen_pcibk_device *pdev)
149 char *magic = NULL; 140 char *magic = NULL;
150 141
151 142
143 mutex_lock(&pdev->dev_lock);
152 /* Make sure we only do this setup once */ 144 /* Make sure we only do this setup once */
153 if (xenbus_read_driver_state(pdev->xdev->nodename) != 145 if (xenbus_read_driver_state(pdev->xdev->nodename) !=
154 XenbusStateInitialised) 146 XenbusStateInitialised)
@@ -193,6 +185,7 @@ static int xen_pcibk_attach(struct xen_pcibk_device *pdev)
193 185
194 dev_dbg(&pdev->xdev->dev, "Connected? %d\n", err); 186 dev_dbg(&pdev->xdev->dev, "Connected? %d\n", err);
195out: 187out:
188 mutex_unlock(&pdev->dev_lock);
196 189
197 kfree(magic); 190 kfree(magic);
198 191
@@ -368,6 +361,7 @@ static int xen_pcibk_reconfigure(struct xen_pcibk_device *pdev)
368 361
369 dev_dbg(&pdev->xdev->dev, "Reconfiguring device ...\n"); 362 dev_dbg(&pdev->xdev->dev, "Reconfiguring device ...\n");
370 363
364 mutex_lock(&pdev->dev_lock);
371 /* Make sure we only reconfigure once */ 365 /* Make sure we only reconfigure once */
372 if (xenbus_read_driver_state(pdev->xdev->nodename) != 366 if (xenbus_read_driver_state(pdev->xdev->nodename) !=
373 XenbusStateReconfiguring) 367 XenbusStateReconfiguring)
@@ -505,6 +499,7 @@ static int xen_pcibk_reconfigure(struct xen_pcibk_device *pdev)
505 } 499 }
506 500
507out: 501out:
502 mutex_unlock(&pdev->dev_lock);
508 return 0; 503 return 0;
509} 504}
510 505
@@ -561,6 +556,7 @@ static int xen_pcibk_setup_backend(struct xen_pcibk_device *pdev)
561 char dev_str[64]; 556 char dev_str[64];
562 char state_str[64]; 557 char state_str[64];
563 558
559 mutex_lock(&pdev->dev_lock);
564 /* It's possible we could get the call to setup twice, so make sure 560 /* It's possible we could get the call to setup twice, so make sure
565 * we're not already connected. 561 * we're not already connected.
566 */ 562 */
@@ -641,10 +637,10 @@ static int xen_pcibk_setup_backend(struct xen_pcibk_device *pdev)
641 "Error switching to initialised state!"); 637 "Error switching to initialised state!");
642 638
643out: 639out:
640 mutex_unlock(&pdev->dev_lock);
644 if (!err) 641 if (!err)
645 /* see if pcifront is already configured (if not, we'll wait) */ 642 /* see if pcifront is already configured (if not, we'll wait) */
646 xen_pcibk_attach(pdev); 643 xen_pcibk_attach(pdev);
647
648 return err; 644 return err;
649} 645}
650 646