diff options
Diffstat (limited to 'drivers/misc/mic/card/mic_virtio.c')
-rw-r--r-- | drivers/misc/mic/card/mic_virtio.c | 33 |
1 files changed, 18 insertions, 15 deletions
diff --git a/drivers/misc/mic/card/mic_virtio.c b/drivers/misc/mic/card/mic_virtio.c index 8aa42e738acc..653799b96bfa 100644 --- a/drivers/misc/mic/card/mic_virtio.c +++ b/drivers/misc/mic/card/mic_virtio.c | |||
@@ -154,14 +154,14 @@ static void mic_reset_inform_host(struct virtio_device *vdev) | |||
154 | { | 154 | { |
155 | struct mic_vdev *mvdev = to_micvdev(vdev); | 155 | struct mic_vdev *mvdev = to_micvdev(vdev); |
156 | struct mic_device_ctrl __iomem *dc = mvdev->dc; | 156 | struct mic_device_ctrl __iomem *dc = mvdev->dc; |
157 | int retry = 100, i; | 157 | int retry; |
158 | 158 | ||
159 | iowrite8(0, &dc->host_ack); | 159 | iowrite8(0, &dc->host_ack); |
160 | iowrite8(1, &dc->vdev_reset); | 160 | iowrite8(1, &dc->vdev_reset); |
161 | mic_send_intr(mvdev->mdev, mvdev->c2h_vdev_db); | 161 | mic_send_intr(mvdev->mdev, mvdev->c2h_vdev_db); |
162 | 162 | ||
163 | /* Wait till host completes all card accesses and acks the reset */ | 163 | /* Wait till host completes all card accesses and acks the reset */ |
164 | for (i = retry; i--;) { | 164 | for (retry = 100; retry--;) { |
165 | if (ioread8(&dc->host_ack)) | 165 | if (ioread8(&dc->host_ack)) |
166 | break; | 166 | break; |
167 | msleep(100); | 167 | msleep(100); |
@@ -187,11 +187,12 @@ static void mic_reset(struct virtio_device *vdev) | |||
187 | /* | 187 | /* |
188 | * The virtio_ring code calls this API when it wants to notify the Host. | 188 | * The virtio_ring code calls this API when it wants to notify the Host. |
189 | */ | 189 | */ |
190 | static void mic_notify(struct virtqueue *vq) | 190 | static bool mic_notify(struct virtqueue *vq) |
191 | { | 191 | { |
192 | struct mic_vdev *mvdev = vq->priv; | 192 | struct mic_vdev *mvdev = vq->priv; |
193 | 193 | ||
194 | mic_send_intr(mvdev->mdev, mvdev->c2h_vdev_db); | 194 | mic_send_intr(mvdev->mdev, mvdev->c2h_vdev_db); |
195 | return true; | ||
195 | } | 196 | } |
196 | 197 | ||
197 | static void mic_del_vq(struct virtqueue *vq, int n) | 198 | static void mic_del_vq(struct virtqueue *vq, int n) |
@@ -247,17 +248,17 @@ static struct virtqueue *mic_find_vq(struct virtio_device *vdev, | |||
247 | /* First assign the vring's allocated in host memory */ | 248 | /* First assign the vring's allocated in host memory */ |
248 | vqconfig = mic_vq_config(mvdev->desc) + index; | 249 | vqconfig = mic_vq_config(mvdev->desc) + index; |
249 | memcpy_fromio(&config, vqconfig, sizeof(config)); | 250 | memcpy_fromio(&config, vqconfig, sizeof(config)); |
250 | _vr_size = vring_size(config.num, MIC_VIRTIO_RING_ALIGN); | 251 | _vr_size = vring_size(le16_to_cpu(config.num), MIC_VIRTIO_RING_ALIGN); |
251 | vr_size = PAGE_ALIGN(_vr_size + sizeof(struct _mic_vring_info)); | 252 | vr_size = PAGE_ALIGN(_vr_size + sizeof(struct _mic_vring_info)); |
252 | va = mic_card_map(mvdev->mdev, config.address, vr_size); | 253 | va = mic_card_map(mvdev->mdev, le64_to_cpu(config.address), vr_size); |
253 | if (!va) | 254 | if (!va) |
254 | return ERR_PTR(-ENOMEM); | 255 | return ERR_PTR(-ENOMEM); |
255 | mvdev->vr[index] = va; | 256 | mvdev->vr[index] = va; |
256 | memset_io(va, 0x0, _vr_size); | 257 | memset_io(va, 0x0, _vr_size); |
257 | vq = vring_new_virtqueue(index, | 258 | vq = vring_new_virtqueue(index, le16_to_cpu(config.num), |
258 | config.num, MIC_VIRTIO_RING_ALIGN, vdev, | 259 | MIC_VIRTIO_RING_ALIGN, vdev, false, |
259 | false, | 260 | (void __force *)va, mic_notify, callback, |
260 | va, mic_notify, callback, name); | 261 | name); |
261 | if (!vq) { | 262 | if (!vq) { |
262 | err = -ENOMEM; | 263 | err = -ENOMEM; |
263 | goto unmap; | 264 | goto unmap; |
@@ -272,7 +273,8 @@ static struct virtqueue *mic_find_vq(struct virtio_device *vdev, | |||
272 | 273 | ||
273 | /* Allocate and reassign used ring now */ | 274 | /* Allocate and reassign used ring now */ |
274 | mvdev->used_size[index] = PAGE_ALIGN(sizeof(__u16) * 3 + | 275 | mvdev->used_size[index] = PAGE_ALIGN(sizeof(__u16) * 3 + |
275 | sizeof(struct vring_used_elem) * config.num); | 276 | sizeof(struct vring_used_elem) * |
277 | le16_to_cpu(config.num)); | ||
276 | used = (void *)__get_free_pages(GFP_KERNEL | __GFP_ZERO, | 278 | used = (void *)__get_free_pages(GFP_KERNEL | __GFP_ZERO, |
277 | get_order(mvdev->used_size[index])); | 279 | get_order(mvdev->used_size[index])); |
278 | if (!used) { | 280 | if (!used) { |
@@ -309,7 +311,7 @@ static int mic_find_vqs(struct virtio_device *vdev, unsigned nvqs, | |||
309 | { | 311 | { |
310 | struct mic_vdev *mvdev = to_micvdev(vdev); | 312 | struct mic_vdev *mvdev = to_micvdev(vdev); |
311 | struct mic_device_ctrl __iomem *dc = mvdev->dc; | 313 | struct mic_device_ctrl __iomem *dc = mvdev->dc; |
312 | int i, err, retry = 100; | 314 | int i, err, retry; |
313 | 315 | ||
314 | /* We must have this many virtqueues. */ | 316 | /* We must have this many virtqueues. */ |
315 | if (nvqs > ioread8(&mvdev->desc->num_vq)) | 317 | if (nvqs > ioread8(&mvdev->desc->num_vq)) |
@@ -331,7 +333,7 @@ static int mic_find_vqs(struct virtio_device *vdev, unsigned nvqs, | |||
331 | * rings have been re-assigned. | 333 | * rings have been re-assigned. |
332 | */ | 334 | */ |
333 | mic_send_intr(mvdev->mdev, mvdev->c2h_vdev_db); | 335 | mic_send_intr(mvdev->mdev, mvdev->c2h_vdev_db); |
334 | for (i = retry; i--;) { | 336 | for (retry = 100; retry--;) { |
335 | if (!ioread8(&dc->used_address_updated)) | 337 | if (!ioread8(&dc->used_address_updated)) |
336 | break; | 338 | break; |
337 | msleep(100); | 339 | msleep(100); |
@@ -519,8 +521,8 @@ static void mic_scan_devices(struct mic_driver *mdrv, bool remove) | |||
519 | struct device *dev; | 521 | struct device *dev; |
520 | int ret; | 522 | int ret; |
521 | 523 | ||
522 | for (i = mic_aligned_size(struct mic_bootparam); | 524 | for (i = sizeof(struct mic_bootparam); i < MIC_DP_SIZE; |
523 | i < MIC_DP_SIZE; i += mic_total_desc_size(d)) { | 525 | i += mic_total_desc_size(d)) { |
524 | d = mdrv->dp + i; | 526 | d = mdrv->dp + i; |
525 | dc = (void __iomem *)d + mic_aligned_desc_size(d); | 527 | dc = (void __iomem *)d + mic_aligned_desc_size(d); |
526 | /* | 528 | /* |
@@ -539,7 +541,8 @@ static void mic_scan_devices(struct mic_driver *mdrv, bool remove) | |||
539 | continue; | 541 | continue; |
540 | 542 | ||
541 | /* device already exists */ | 543 | /* device already exists */ |
542 | dev = device_find_child(mdrv->dev, d, mic_match_desc); | 544 | dev = device_find_child(mdrv->dev, (void __force *)d, |
545 | mic_match_desc); | ||
543 | if (dev) { | 546 | if (dev) { |
544 | if (remove) | 547 | if (remove) |
545 | iowrite8(MIC_VIRTIO_PARAM_DEV_REMOVE, | 548 | iowrite8(MIC_VIRTIO_PARAM_DEV_REMOVE, |