diff options
author | Michael S. Tsirkin <mst@redhat.com> | 2010-04-29 10:26:37 -0400 |
---|---|---|
committer | Rusty Russell <rusty@rustcorp.com.au> | 2010-05-19 08:45:46 -0400 |
commit | bbd603efb4238cf78083c00f0a81adfa8994aa33 (patch) | |
tree | 3980961f9dbf08e748b3c2de56caf43dec21aa76 /drivers/virtio/virtio_ring.c | |
parent | dc3f5e68f846eec38fb31d78f0b6e83633ad375e (diff) |
virtio: add_buf_gfp
Add an add_buf variant that gets gfp parameter. Use that
to allocate indirect buffers.
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Diffstat (limited to 'drivers/virtio/virtio_ring.c')
-rw-r--r-- | drivers/virtio/virtio_ring.c | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c index 0717b5b000bb..1ca88908723b 100644 --- a/drivers/virtio/virtio_ring.c +++ b/drivers/virtio/virtio_ring.c | |||
@@ -110,13 +110,14 @@ struct vring_virtqueue | |||
110 | static int vring_add_indirect(struct vring_virtqueue *vq, | 110 | static int vring_add_indirect(struct vring_virtqueue *vq, |
111 | struct scatterlist sg[], | 111 | struct scatterlist sg[], |
112 | unsigned int out, | 112 | unsigned int out, |
113 | unsigned int in) | 113 | unsigned int in, |
114 | gfp_t gfp) | ||
114 | { | 115 | { |
115 | struct vring_desc *desc; | 116 | struct vring_desc *desc; |
116 | unsigned head; | 117 | unsigned head; |
117 | int i; | 118 | int i; |
118 | 119 | ||
119 | desc = kmalloc((out + in) * sizeof(struct vring_desc), GFP_ATOMIC); | 120 | desc = kmalloc((out + in) * sizeof(struct vring_desc), gfp); |
120 | if (!desc) | 121 | if (!desc) |
121 | return vq->vring.num; | 122 | return vq->vring.num; |
122 | 123 | ||
@@ -155,11 +156,12 @@ static int vring_add_indirect(struct vring_virtqueue *vq, | |||
155 | return head; | 156 | return head; |
156 | } | 157 | } |
157 | 158 | ||
158 | int virtqueue_add_buf(struct virtqueue *_vq, | 159 | int virtqueue_add_buf_gfp(struct virtqueue *_vq, |
159 | struct scatterlist sg[], | 160 | struct scatterlist sg[], |
160 | unsigned int out, | 161 | unsigned int out, |
161 | unsigned int in, | 162 | unsigned int in, |
162 | void *data) | 163 | void *data, |
164 | gfp_t gfp) | ||
163 | { | 165 | { |
164 | struct vring_virtqueue *vq = to_vvq(_vq); | 166 | struct vring_virtqueue *vq = to_vvq(_vq); |
165 | unsigned int i, avail, head, uninitialized_var(prev); | 167 | unsigned int i, avail, head, uninitialized_var(prev); |
@@ -171,7 +173,7 @@ int virtqueue_add_buf(struct virtqueue *_vq, | |||
171 | /* If the host supports indirect descriptor tables, and we have multiple | 173 | /* If the host supports indirect descriptor tables, and we have multiple |
172 | * buffers, then go indirect. FIXME: tune this threshold */ | 174 | * buffers, then go indirect. FIXME: tune this threshold */ |
173 | if (vq->indirect && (out + in) > 1 && vq->num_free) { | 175 | if (vq->indirect && (out + in) > 1 && vq->num_free) { |
174 | head = vring_add_indirect(vq, sg, out, in); | 176 | head = vring_add_indirect(vq, sg, out, in, gfp); |
175 | if (head != vq->vring.num) | 177 | if (head != vq->vring.num) |
176 | goto add_head; | 178 | goto add_head; |
177 | } | 179 | } |
@@ -232,7 +234,7 @@ add_head: | |||
232 | return vq->num_free ? vq->vring.num : 0; | 234 | return vq->num_free ? vq->vring.num : 0; |
233 | return vq->num_free; | 235 | return vq->num_free; |
234 | } | 236 | } |
235 | EXPORT_SYMBOL_GPL(virtqueue_add_buf); | 237 | EXPORT_SYMBOL_GPL(virtqueue_add_buf_gfp); |
236 | 238 | ||
237 | void virtqueue_kick(struct virtqueue *_vq) | 239 | void virtqueue_kick(struct virtqueue *_vq) |
238 | { | 240 | { |