aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/block
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2011-11-06 21:31:36 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2011-11-06 21:31:36 -0500
commit06d381484fe8fb1ba2996c22e89595a273e3634c (patch)
tree0d39c57cb8c501341ab8ed1d740f076b0b8c0bd0 /drivers/block
parent5d5a8d2d9d6cca979efe4fe1552d787fdc542603 (diff)
parentc9d6369978411f690513994e6e53e2e6410874a4 (diff)
Merge branch 'stable/vmalloc-3.2' of git://git.kernel.org/pub/scm/linux/kernel/git/konrad/xen
* 'stable/vmalloc-3.2' of git://git.kernel.org/pub/scm/linux/kernel/git/konrad/xen: net: xen-netback: use API provided by xenbus module to map rings block: xen-blkback: use API provided by xenbus module to map rings xen: use generic functions instead of xen_{alloc, free}_vm_area()
Diffstat (limited to 'drivers/block')
-rw-r--r--drivers/block/xen-blkback/common.h5
-rw-r--r--drivers/block/xen-blkback/xenbus.c54
2 files changed, 8 insertions, 51 deletions
diff --git a/drivers/block/xen-blkback/common.h b/drivers/block/xen-blkback/common.h
index de09f525d6c..dfb1b3a43a5 100644
--- a/drivers/block/xen-blkback/common.h
+++ b/drivers/block/xen-blkback/common.h
@@ -170,7 +170,7 @@ struct xen_blkif {
170 enum blkif_protocol blk_protocol; 170 enum blkif_protocol blk_protocol;
171 enum blkif_backend_type blk_backend_type; 171 enum blkif_backend_type blk_backend_type;
172 union blkif_back_rings blk_rings; 172 union blkif_back_rings blk_rings;
173 struct vm_struct *blk_ring_area; 173 void *blk_ring;
174 /* The VBD attached to this interface. */ 174 /* The VBD attached to this interface. */
175 struct xen_vbd vbd; 175 struct xen_vbd vbd;
176 /* Back pointer to the backend_info. */ 176 /* Back pointer to the backend_info. */
@@ -198,9 +198,6 @@ struct xen_blkif {
198 int st_wr_sect; 198 int st_wr_sect;
199 199
200 wait_queue_head_t waiting_to_free; 200 wait_queue_head_t waiting_to_free;
201
202 grant_handle_t shmem_handle;
203 grant_ref_t shmem_ref;
204}; 201};
205 202
206 203
diff --git a/drivers/block/xen-blkback/xenbus.c b/drivers/block/xen-blkback/xenbus.c
index 2c008afe63d..f759ad4584c 100644
--- a/drivers/block/xen-blkback/xenbus.c
+++ b/drivers/block/xen-blkback/xenbus.c
@@ -122,38 +122,6 @@ static struct xen_blkif *xen_blkif_alloc(domid_t domid)
122 return blkif; 122 return blkif;
123} 123}
124 124
125static int map_frontend_page(struct xen_blkif *blkif, unsigned long shared_page)
126{
127 struct gnttab_map_grant_ref op;
128
129 gnttab_set_map_op(&op, (unsigned long)blkif->blk_ring_area->addr,
130 GNTMAP_host_map, shared_page, blkif->domid);
131
132 if (HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1))
133 BUG();
134
135 if (op.status) {
136 DPRINTK("Grant table operation failure !\n");
137 return op.status;
138 }
139
140 blkif->shmem_ref = shared_page;
141 blkif->shmem_handle = op.handle;
142
143 return 0;
144}
145
146static void unmap_frontend_page(struct xen_blkif *blkif)
147{
148 struct gnttab_unmap_grant_ref op;
149
150 gnttab_set_unmap_op(&op, (unsigned long)blkif->blk_ring_area->addr,
151 GNTMAP_host_map, blkif->shmem_handle);
152
153 if (HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1))
154 BUG();
155}
156
157static int xen_blkif_map(struct xen_blkif *blkif, unsigned long shared_page, 125static int xen_blkif_map(struct xen_blkif *blkif, unsigned long shared_page,
158 unsigned int evtchn) 126 unsigned int evtchn)
159{ 127{
@@ -163,35 +131,29 @@ static int xen_blkif_map(struct xen_blkif *blkif, unsigned long shared_page,
163 if (blkif->irq) 131 if (blkif->irq)
164 return 0; 132 return 0;
165 133
166 blkif->blk_ring_area = alloc_vm_area(PAGE_SIZE); 134 err = xenbus_map_ring_valloc(blkif->be->dev, shared_page, &blkif->blk_ring);
167 if (!blkif->blk_ring_area) 135 if (err < 0)
168 return -ENOMEM;
169
170 err = map_frontend_page(blkif, shared_page);
171 if (err) {
172 free_vm_area(blkif->blk_ring_area);
173 return err; 136 return err;
174 }
175 137
176 switch (blkif->blk_protocol) { 138 switch (blkif->blk_protocol) {
177 case BLKIF_PROTOCOL_NATIVE: 139 case BLKIF_PROTOCOL_NATIVE:
178 { 140 {
179 struct blkif_sring *sring; 141 struct blkif_sring *sring;
180 sring = (struct blkif_sring *)blkif->blk_ring_area->addr; 142 sring = (struct blkif_sring *)blkif->blk_ring;
181 BACK_RING_INIT(&blkif->blk_rings.native, sring, PAGE_SIZE); 143 BACK_RING_INIT(&blkif->blk_rings.native, sring, PAGE_SIZE);
182 break; 144 break;
183 } 145 }
184 case BLKIF_PROTOCOL_X86_32: 146 case BLKIF_PROTOCOL_X86_32:
185 { 147 {
186 struct blkif_x86_32_sring *sring_x86_32; 148 struct blkif_x86_32_sring *sring_x86_32;
187 sring_x86_32 = (struct blkif_x86_32_sring *)blkif->blk_ring_area->addr; 149 sring_x86_32 = (struct blkif_x86_32_sring *)blkif->blk_ring;
188 BACK_RING_INIT(&blkif->blk_rings.x86_32, sring_x86_32, PAGE_SIZE); 150 BACK_RING_INIT(&blkif->blk_rings.x86_32, sring_x86_32, PAGE_SIZE);
189 break; 151 break;
190 } 152 }
191 case BLKIF_PROTOCOL_X86_64: 153 case BLKIF_PROTOCOL_X86_64:
192 { 154 {
193 struct blkif_x86_64_sring *sring_x86_64; 155 struct blkif_x86_64_sring *sring_x86_64;
194 sring_x86_64 = (struct blkif_x86_64_sring *)blkif->blk_ring_area->addr; 156 sring_x86_64 = (struct blkif_x86_64_sring *)blkif->blk_ring;
195 BACK_RING_INIT(&blkif->blk_rings.x86_64, sring_x86_64, PAGE_SIZE); 157 BACK_RING_INIT(&blkif->blk_rings.x86_64, sring_x86_64, PAGE_SIZE);
196 break; 158 break;
197 } 159 }
@@ -203,8 +165,7 @@ static int xen_blkif_map(struct xen_blkif *blkif, unsigned long shared_page,
203 xen_blkif_be_int, 0, 165 xen_blkif_be_int, 0,
204 "blkif-backend", blkif); 166 "blkif-backend", blkif);
205 if (err < 0) { 167 if (err < 0) {
206 unmap_frontend_page(blkif); 168 xenbus_unmap_ring_vfree(blkif->be->dev, blkif->blk_ring);
207 free_vm_area(blkif->blk_ring_area);
208 blkif->blk_rings.common.sring = NULL; 169 blkif->blk_rings.common.sring = NULL;
209 return err; 170 return err;
210 } 171 }
@@ -230,8 +191,7 @@ static void xen_blkif_disconnect(struct xen_blkif *blkif)
230 } 191 }
231 192
232 if (blkif->blk_rings.common.sring) { 193 if (blkif->blk_rings.common.sring) {
233 unmap_frontend_page(blkif); 194 xenbus_unmap_ring_vfree(blkif->be->dev, blkif->blk_ring);
234 free_vm_area(blkif->blk_ring_area);
235 blkif->blk_rings.common.sring = NULL; 195 blkif->blk_rings.common.sring = NULL;
236 } 196 }
237} 197}