diff options
| -rw-r--r-- | CREDITS | 5 | ||||
| -rw-r--r-- | Documentation/mic/mpssd/mpssd.c | 18 | ||||
| -rw-r--r-- | MAINTAINERS | 8 | ||||
| -rw-r--r-- | drivers/misc/mic/card/mic_virtio.c | 33 | ||||
| -rw-r--r-- | drivers/misc/mic/card/mic_virtio.h | 7 | ||||
| -rw-r--r-- | drivers/misc/mic/host/mic_boot.c | 2 | ||||
| -rw-r--r-- | drivers/misc/mic/host/mic_virtio.c | 30 | ||||
| -rw-r--r-- | drivers/misc/mic/host/mic_x100.c | 4 | ||||
| -rw-r--r-- | include/uapi/linux/mic_common.h | 40 |
9 files changed, 80 insertions, 67 deletions
| @@ -655,6 +655,11 @@ S: Stanford University | |||
| 655 | S: Stanford, California 94305 | 655 | S: Stanford, California 94305 |
| 656 | S: USA | 656 | S: USA |
| 657 | 657 | ||
| 658 | N: Carlos Chinea | ||
| 659 | E: carlos.chinea@nokia.com | ||
| 660 | E: cch.devel@gmail.com | ||
| 661 | D: Author of HSI Subsystem | ||
| 662 | |||
| 658 | N: Randolph Chung | 663 | N: Randolph Chung |
| 659 | E: tausq@debian.org | 664 | E: tausq@debian.org |
| 660 | D: Linux/PA-RISC hacker | 665 | D: Linux/PA-RISC hacker |
diff --git a/Documentation/mic/mpssd/mpssd.c b/Documentation/mic/mpssd/mpssd.c index 0c980ad40b17..4d17487d5ad9 100644 --- a/Documentation/mic/mpssd/mpssd.c +++ b/Documentation/mic/mpssd/mpssd.c | |||
| @@ -313,7 +313,7 @@ static struct mic_device_desc *get_device_desc(struct mic_info *mic, int type) | |||
| 313 | int i; | 313 | int i; |
| 314 | void *dp = get_dp(mic, type); | 314 | void *dp = get_dp(mic, type); |
| 315 | 315 | ||
| 316 | for (i = mic_aligned_size(struct mic_bootparam); i < PAGE_SIZE; | 316 | for (i = sizeof(struct mic_bootparam); i < PAGE_SIZE; |
| 317 | i += mic_total_desc_size(d)) { | 317 | i += mic_total_desc_size(d)) { |
| 318 | d = dp + i; | 318 | d = dp + i; |
| 319 | 319 | ||
| @@ -445,8 +445,8 @@ init_vr(struct mic_info *mic, int fd, int type, | |||
| 445 | __func__, mic->name, vr0->va, vr0->info, vr_size, | 445 | __func__, mic->name, vr0->va, vr0->info, vr_size, |
| 446 | vring_size(MIC_VRING_ENTRIES, MIC_VIRTIO_RING_ALIGN)); | 446 | vring_size(MIC_VRING_ENTRIES, MIC_VIRTIO_RING_ALIGN)); |
| 447 | mpsslog("magic 0x%x expected 0x%x\n", | 447 | mpsslog("magic 0x%x expected 0x%x\n", |
| 448 | vr0->info->magic, MIC_MAGIC + type); | 448 | le32toh(vr0->info->magic), MIC_MAGIC + type); |
| 449 | assert(vr0->info->magic == MIC_MAGIC + type); | 449 | assert(le32toh(vr0->info->magic) == MIC_MAGIC + type); |
| 450 | if (vr1) { | 450 | if (vr1) { |
| 451 | vr1->va = (struct mic_vring *) | 451 | vr1->va = (struct mic_vring *) |
| 452 | &va[MIC_DEVICE_PAGE_END + vr_size]; | 452 | &va[MIC_DEVICE_PAGE_END + vr_size]; |
| @@ -458,8 +458,8 @@ init_vr(struct mic_info *mic, int fd, int type, | |||
| 458 | __func__, mic->name, vr1->va, vr1->info, vr_size, | 458 | __func__, mic->name, vr1->va, vr1->info, vr_size, |
| 459 | vring_size(MIC_VRING_ENTRIES, MIC_VIRTIO_RING_ALIGN)); | 459 | vring_size(MIC_VRING_ENTRIES, MIC_VIRTIO_RING_ALIGN)); |
| 460 | mpsslog("magic 0x%x expected 0x%x\n", | 460 | mpsslog("magic 0x%x expected 0x%x\n", |
| 461 | vr1->info->magic, MIC_MAGIC + type + 1); | 461 | le32toh(vr1->info->magic), MIC_MAGIC + type + 1); |
| 462 | assert(vr1->info->magic == MIC_MAGIC + type + 1); | 462 | assert(le32toh(vr1->info->magic) == MIC_MAGIC + type + 1); |
| 463 | } | 463 | } |
| 464 | done: | 464 | done: |
| 465 | return va; | 465 | return va; |
| @@ -520,7 +520,7 @@ static void * | |||
| 520 | virtio_net(void *arg) | 520 | virtio_net(void *arg) |
| 521 | { | 521 | { |
| 522 | static __u8 vnet_hdr[2][sizeof(struct virtio_net_hdr)]; | 522 | static __u8 vnet_hdr[2][sizeof(struct virtio_net_hdr)]; |
| 523 | static __u8 vnet_buf[2][MAX_NET_PKT_SIZE] __aligned(64); | 523 | static __u8 vnet_buf[2][MAX_NET_PKT_SIZE] __attribute__ ((aligned(64))); |
| 524 | struct iovec vnet_iov[2][2] = { | 524 | struct iovec vnet_iov[2][2] = { |
| 525 | { { .iov_base = vnet_hdr[0], .iov_len = sizeof(vnet_hdr[0]) }, | 525 | { { .iov_base = vnet_hdr[0], .iov_len = sizeof(vnet_hdr[0]) }, |
| 526 | { .iov_base = vnet_buf[0], .iov_len = sizeof(vnet_buf[0]) } }, | 526 | { .iov_base = vnet_buf[0], .iov_len = sizeof(vnet_buf[0]) } }, |
| @@ -1412,6 +1412,12 @@ mic_config(void *arg) | |||
| 1412 | } | 1412 | } |
| 1413 | 1413 | ||
| 1414 | do { | 1414 | do { |
| 1415 | ret = lseek(fd, 0, SEEK_SET); | ||
| 1416 | if (ret < 0) { | ||
| 1417 | mpsslog("%s: Failed to seek to file start '%s': %s\n", | ||
| 1418 | mic->name, pathname, strerror(errno)); | ||
| 1419 | goto close_error1; | ||
| 1420 | } | ||
| 1415 | ret = read(fd, value, sizeof(value)); | 1421 | ret = read(fd, value, sizeof(value)); |
| 1416 | if (ret < 0) { | 1422 | if (ret < 0) { |
| 1417 | mpsslog("%s: Failed to read sysfs entry '%s': %s\n", | 1423 | mpsslog("%s: Failed to read sysfs entry '%s': %s\n", |
diff --git a/MAINTAINERS b/MAINTAINERS index 8285ed4676b6..a975b367f8c0 100644 --- a/MAINTAINERS +++ b/MAINTAINERS | |||
| @@ -4038,6 +4038,14 @@ W: http://artax.karlin.mff.cuni.cz/~mikulas/vyplody/hpfs/index-e.cgi | |||
| 4038 | S: Maintained | 4038 | S: Maintained |
| 4039 | F: fs/hpfs/ | 4039 | F: fs/hpfs/ |
| 4040 | 4040 | ||
| 4041 | HSI SUBSYSTEM | ||
| 4042 | M: Sebastian Reichel <sre@debian.org> | ||
| 4043 | S: Maintained | ||
| 4044 | F: Documentation/ABI/testing/sysfs-bus-hsi | ||
| 4045 | F: drivers/hsi/ | ||
| 4046 | F: include/linux/hsi/ | ||
| 4047 | F: include/uapi/linux/hsi/ | ||
| 4048 | |||
| 4041 | HSO 3G MODEM DRIVER | 4049 | HSO 3G MODEM DRIVER |
| 4042 | M: Jan Dumon <j.dumon@option.com> | 4050 | M: Jan Dumon <j.dumon@option.com> |
| 4043 | W: http://www.pharscape.org | 4051 | W: http://www.pharscape.org |
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, |
diff --git a/drivers/misc/mic/card/mic_virtio.h b/drivers/misc/mic/card/mic_virtio.h index 2c5c22c93ba8..d0407ba53bb7 100644 --- a/drivers/misc/mic/card/mic_virtio.h +++ b/drivers/misc/mic/card/mic_virtio.h | |||
| @@ -42,8 +42,8 @@ | |||
| 42 | 42 | ||
| 43 | static inline unsigned mic_desc_size(struct mic_device_desc __iomem *desc) | 43 | static inline unsigned mic_desc_size(struct mic_device_desc __iomem *desc) |
| 44 | { | 44 | { |
| 45 | return mic_aligned_size(*desc) | 45 | return sizeof(*desc) |
| 46 | + ioread8(&desc->num_vq) * mic_aligned_size(struct mic_vqconfig) | 46 | + ioread8(&desc->num_vq) * sizeof(struct mic_vqconfig) |
| 47 | + ioread8(&desc->feature_len) * 2 | 47 | + ioread8(&desc->feature_len) * 2 |
| 48 | + ioread8(&desc->config_len); | 48 | + ioread8(&desc->config_len); |
| 49 | } | 49 | } |
| @@ -67,8 +67,7 @@ mic_vq_configspace(struct mic_device_desc __iomem *desc) | |||
| 67 | } | 67 | } |
| 68 | static inline unsigned mic_total_desc_size(struct mic_device_desc __iomem *desc) | 68 | static inline unsigned mic_total_desc_size(struct mic_device_desc __iomem *desc) |
| 69 | { | 69 | { |
| 70 | return mic_aligned_desc_size(desc) + | 70 | return mic_aligned_desc_size(desc) + sizeof(struct mic_device_ctrl); |
| 71 | mic_aligned_size(struct mic_device_ctrl); | ||
| 72 | } | 71 | } |
| 73 | 72 | ||
| 74 | int mic_devices_init(struct mic_driver *mdrv); | 73 | int mic_devices_init(struct mic_driver *mdrv); |
diff --git a/drivers/misc/mic/host/mic_boot.c b/drivers/misc/mic/host/mic_boot.c index 7558d9186438..b75c6b5cc20f 100644 --- a/drivers/misc/mic/host/mic_boot.c +++ b/drivers/misc/mic/host/mic_boot.c | |||
| @@ -62,7 +62,7 @@ void mic_bootparam_init(struct mic_device *mdev) | |||
| 62 | { | 62 | { |
| 63 | struct mic_bootparam *bootparam = mdev->dp; | 63 | struct mic_bootparam *bootparam = mdev->dp; |
| 64 | 64 | ||
| 65 | bootparam->magic = MIC_MAGIC; | 65 | bootparam->magic = cpu_to_le32(MIC_MAGIC); |
| 66 | bootparam->c2h_shutdown_db = mdev->shutdown_db; | 66 | bootparam->c2h_shutdown_db = mdev->shutdown_db; |
| 67 | bootparam->h2c_shutdown_db = -1; | 67 | bootparam->h2c_shutdown_db = -1; |
| 68 | bootparam->h2c_config_db = -1; | 68 | bootparam->h2c_config_db = -1; |
diff --git a/drivers/misc/mic/host/mic_virtio.c b/drivers/misc/mic/host/mic_virtio.c index 5b8494bd1e00..e04bb4fe6823 100644 --- a/drivers/misc/mic/host/mic_virtio.c +++ b/drivers/misc/mic/host/mic_virtio.c | |||
| @@ -41,7 +41,7 @@ static int mic_virtio_copy_to_user(struct mic_vdev *mvdev, | |||
| 41 | * We are copying from IO below an should ideally use something | 41 | * We are copying from IO below an should ideally use something |
| 42 | * like copy_to_user_fromio(..) if it existed. | 42 | * like copy_to_user_fromio(..) if it existed. |
| 43 | */ | 43 | */ |
| 44 | if (copy_to_user(ubuf, dbuf, len)) { | 44 | if (copy_to_user(ubuf, (void __force *)dbuf, len)) { |
| 45 | err = -EFAULT; | 45 | err = -EFAULT; |
| 46 | dev_err(mic_dev(mvdev), "%s %d err %d\n", | 46 | dev_err(mic_dev(mvdev), "%s %d err %d\n", |
| 47 | __func__, __LINE__, err); | 47 | __func__, __LINE__, err); |
| @@ -66,7 +66,7 @@ static int mic_virtio_copy_from_user(struct mic_vdev *mvdev, | |||
| 66 | * We are copying to IO below and should ideally use something | 66 | * We are copying to IO below and should ideally use something |
| 67 | * like copy_from_user_toio(..) if it existed. | 67 | * like copy_from_user_toio(..) if it existed. |
| 68 | */ | 68 | */ |
| 69 | if (copy_from_user(dbuf, ubuf, len)) { | 69 | if (copy_from_user((void __force *)dbuf, ubuf, len)) { |
| 70 | err = -EFAULT; | 70 | err = -EFAULT; |
| 71 | dev_err(mic_dev(mvdev), "%s %d err %d\n", | 71 | dev_err(mic_dev(mvdev), "%s %d err %d\n", |
| 72 | __func__, __LINE__, err); | 72 | __func__, __LINE__, err); |
| @@ -293,7 +293,7 @@ static void mic_virtio_init_post(struct mic_vdev *mvdev) | |||
| 293 | continue; | 293 | continue; |
| 294 | } | 294 | } |
| 295 | mvdev->mvr[i].vrh.vring.used = | 295 | mvdev->mvr[i].vrh.vring.used = |
| 296 | mvdev->mdev->aper.va + | 296 | (void __force *)mvdev->mdev->aper.va + |
| 297 | le64_to_cpu(vqconfig[i].used_address); | 297 | le64_to_cpu(vqconfig[i].used_address); |
| 298 | } | 298 | } |
| 299 | 299 | ||
| @@ -378,7 +378,7 @@ int mic_virtio_config_change(struct mic_vdev *mvdev, | |||
| 378 | void __user *argp) | 378 | void __user *argp) |
| 379 | { | 379 | { |
| 380 | DECLARE_WAIT_QUEUE_HEAD_ONSTACK(wake); | 380 | DECLARE_WAIT_QUEUE_HEAD_ONSTACK(wake); |
| 381 | int ret = 0, retry = 100, i; | 381 | int ret = 0, retry, i; |
| 382 | struct mic_bootparam *bootparam = mvdev->mdev->dp; | 382 | struct mic_bootparam *bootparam = mvdev->mdev->dp; |
| 383 | s8 db = bootparam->h2c_config_db; | 383 | s8 db = bootparam->h2c_config_db; |
| 384 | 384 | ||
| @@ -401,7 +401,7 @@ int mic_virtio_config_change(struct mic_vdev *mvdev, | |||
| 401 | mvdev->dc->config_change = MIC_VIRTIO_PARAM_CONFIG_CHANGED; | 401 | mvdev->dc->config_change = MIC_VIRTIO_PARAM_CONFIG_CHANGED; |
| 402 | mvdev->mdev->ops->send_intr(mvdev->mdev, db); | 402 | mvdev->mdev->ops->send_intr(mvdev->mdev, db); |
| 403 | 403 | ||
| 404 | for (i = retry; i--;) { | 404 | for (retry = 100; retry--;) { |
| 405 | ret = wait_event_timeout(wake, | 405 | ret = wait_event_timeout(wake, |
| 406 | mvdev->dc->guest_ack, msecs_to_jiffies(100)); | 406 | mvdev->dc->guest_ack, msecs_to_jiffies(100)); |
| 407 | if (ret) | 407 | if (ret) |
| @@ -467,7 +467,7 @@ static int mic_copy_dp_entry(struct mic_vdev *mvdev, | |||
| 467 | } | 467 | } |
| 468 | 468 | ||
| 469 | /* Find the first free device page entry */ | 469 | /* Find the first free device page entry */ |
| 470 | for (i = mic_aligned_size(struct mic_bootparam); | 470 | for (i = sizeof(struct mic_bootparam); |
| 471 | i < MIC_DP_SIZE - mic_total_desc_size(dd_config); | 471 | i < MIC_DP_SIZE - mic_total_desc_size(dd_config); |
| 472 | i += mic_total_desc_size(devp)) { | 472 | i += mic_total_desc_size(devp)) { |
| 473 | devp = mdev->dp + i; | 473 | devp = mdev->dp + i; |
| @@ -525,6 +525,7 @@ int mic_virtio_add_device(struct mic_vdev *mvdev, | |||
| 525 | char irqname[10]; | 525 | char irqname[10]; |
| 526 | struct mic_bootparam *bootparam = mdev->dp; | 526 | struct mic_bootparam *bootparam = mdev->dp; |
| 527 | u16 num; | 527 | u16 num; |
| 528 | dma_addr_t vr_addr; | ||
| 528 | 529 | ||
| 529 | mutex_lock(&mdev->mic_mutex); | 530 | mutex_lock(&mdev->mic_mutex); |
| 530 | 531 | ||
| @@ -559,17 +560,16 @@ int mic_virtio_add_device(struct mic_vdev *mvdev, | |||
| 559 | } | 560 | } |
| 560 | vr->len = vr_size; | 561 | vr->len = vr_size; |
| 561 | vr->info = vr->va + vring_size(num, MIC_VIRTIO_RING_ALIGN); | 562 | vr->info = vr->va + vring_size(num, MIC_VIRTIO_RING_ALIGN); |
| 562 | vr->info->magic = MIC_MAGIC + mvdev->virtio_id + i; | 563 | vr->info->magic = cpu_to_le32(MIC_MAGIC + mvdev->virtio_id + i); |
| 563 | vqconfig[i].address = mic_map_single(mdev, | 564 | vr_addr = mic_map_single(mdev, vr->va, vr_size); |
| 564 | vr->va, vr_size); | 565 | if (mic_map_error(vr_addr)) { |
| 565 | if (mic_map_error(vqconfig[i].address)) { | ||
| 566 | free_pages((unsigned long)vr->va, get_order(vr_size)); | 566 | free_pages((unsigned long)vr->va, get_order(vr_size)); |
| 567 | ret = -ENOMEM; | 567 | ret = -ENOMEM; |
| 568 | dev_err(mic_dev(mvdev), "%s %d err %d\n", | 568 | dev_err(mic_dev(mvdev), "%s %d err %d\n", |
| 569 | __func__, __LINE__, ret); | 569 | __func__, __LINE__, ret); |
| 570 | goto err; | 570 | goto err; |
| 571 | } | 571 | } |
| 572 | vqconfig[i].address = cpu_to_le64(vqconfig[i].address); | 572 | vqconfig[i].address = cpu_to_le64(vr_addr); |
| 573 | 573 | ||
| 574 | vring_init(&vr->vr, num, vr->va, MIC_VIRTIO_RING_ALIGN); | 574 | vring_init(&vr->vr, num, vr->va, MIC_VIRTIO_RING_ALIGN); |
| 575 | ret = vringh_init_kern(&mvr->vrh, | 575 | ret = vringh_init_kern(&mvr->vrh, |
| @@ -639,7 +639,7 @@ void mic_virtio_del_device(struct mic_vdev *mvdev) | |||
| 639 | struct mic_vdev *tmp_mvdev; | 639 | struct mic_vdev *tmp_mvdev; |
| 640 | struct mic_device *mdev = mvdev->mdev; | 640 | struct mic_device *mdev = mvdev->mdev; |
| 641 | DECLARE_WAIT_QUEUE_HEAD_ONSTACK(wake); | 641 | DECLARE_WAIT_QUEUE_HEAD_ONSTACK(wake); |
| 642 | int i, ret, retry = 100; | 642 | int i, ret, retry; |
| 643 | struct mic_vqconfig *vqconfig; | 643 | struct mic_vqconfig *vqconfig; |
| 644 | struct mic_bootparam *bootparam = mdev->dp; | 644 | struct mic_bootparam *bootparam = mdev->dp; |
| 645 | s8 db; | 645 | s8 db; |
| @@ -652,16 +652,16 @@ void mic_virtio_del_device(struct mic_vdev *mvdev) | |||
| 652 | "Requesting hot remove id %d\n", mvdev->virtio_id); | 652 | "Requesting hot remove id %d\n", mvdev->virtio_id); |
| 653 | mvdev->dc->config_change = MIC_VIRTIO_PARAM_DEV_REMOVE; | 653 | mvdev->dc->config_change = MIC_VIRTIO_PARAM_DEV_REMOVE; |
| 654 | mdev->ops->send_intr(mdev, db); | 654 | mdev->ops->send_intr(mdev, db); |
| 655 | for (i = retry; i--;) { | 655 | for (retry = 100; retry--;) { |
| 656 | ret = wait_event_timeout(wake, | 656 | ret = wait_event_timeout(wake, |
| 657 | mvdev->dc->guest_ack, msecs_to_jiffies(100)); | 657 | mvdev->dc->guest_ack, msecs_to_jiffies(100)); |
| 658 | if (ret) | 658 | if (ret) |
| 659 | break; | 659 | break; |
| 660 | } | 660 | } |
| 661 | dev_dbg(mdev->sdev->parent, | 661 | dev_dbg(mdev->sdev->parent, |
| 662 | "Device id %d config_change %d guest_ack %d\n", | 662 | "Device id %d config_change %d guest_ack %d retry %d\n", |
| 663 | mvdev->virtio_id, mvdev->dc->config_change, | 663 | mvdev->virtio_id, mvdev->dc->config_change, |
| 664 | mvdev->dc->guest_ack); | 664 | mvdev->dc->guest_ack, retry); |
| 665 | mvdev->dc->config_change = 0; | 665 | mvdev->dc->config_change = 0; |
| 666 | mvdev->dc->guest_ack = 0; | 666 | mvdev->dc->guest_ack = 0; |
| 667 | skip_hot_remove: | 667 | skip_hot_remove: |
diff --git a/drivers/misc/mic/host/mic_x100.c b/drivers/misc/mic/host/mic_x100.c index 81e9541b784c..0dfa8a81436e 100644 --- a/drivers/misc/mic/host/mic_x100.c +++ b/drivers/misc/mic/host/mic_x100.c | |||
| @@ -397,8 +397,8 @@ mic_x100_load_ramdisk(struct mic_device *mdev) | |||
| 397 | * so copy over the ramdisk @ 128M. | 397 | * so copy over the ramdisk @ 128M. |
| 398 | */ | 398 | */ |
| 399 | memcpy_toio(mdev->aper.va + (mdev->bootaddr << 1), fw->data, fw->size); | 399 | memcpy_toio(mdev->aper.va + (mdev->bootaddr << 1), fw->data, fw->size); |
| 400 | iowrite32(cpu_to_le32(mdev->bootaddr << 1), &bp->hdr.ramdisk_image); | 400 | iowrite32(mdev->bootaddr << 1, &bp->hdr.ramdisk_image); |
| 401 | iowrite32(cpu_to_le32(fw->size), &bp->hdr.ramdisk_size); | 401 | iowrite32(fw->size, &bp->hdr.ramdisk_size); |
| 402 | release_firmware(fw); | 402 | release_firmware(fw); |
| 403 | error: | 403 | error: |
| 404 | return rc; | 404 | return rc; |
diff --git a/include/uapi/linux/mic_common.h b/include/uapi/linux/mic_common.h index 17e7d95e4f53..6eb40244e019 100644 --- a/include/uapi/linux/mic_common.h +++ b/include/uapi/linux/mic_common.h | |||
| @@ -23,12 +23,7 @@ | |||
| 23 | 23 | ||
| 24 | #include <linux/virtio_ring.h> | 24 | #include <linux/virtio_ring.h> |
| 25 | 25 | ||
| 26 | #ifndef __KERNEL__ | 26 | #define __mic_align(a, x) (((a) + (x) - 1) & ~((x) - 1)) |
| 27 | #define ALIGN(a, x) (((a) + (x) - 1) & ~((x) - 1)) | ||
| 28 | #define __aligned(x) __attribute__ ((aligned(x))) | ||
| 29 | #endif | ||
| 30 | |||
| 31 | #define mic_aligned_size(x) ALIGN(sizeof(x), 8) | ||
| 32 | 27 | ||
| 33 | /** | 28 | /** |
| 34 | * struct mic_device_desc: Virtio device information shared between the | 29 | * struct mic_device_desc: Virtio device information shared between the |
| @@ -48,8 +43,8 @@ struct mic_device_desc { | |||
| 48 | __u8 feature_len; | 43 | __u8 feature_len; |
| 49 | __u8 config_len; | 44 | __u8 config_len; |
| 50 | __u8 status; | 45 | __u8 status; |
| 51 | __u64 config[0]; | 46 | __le64 config[0]; |
| 52 | } __aligned(8); | 47 | } __attribute__ ((aligned(8))); |
| 53 | 48 | ||
| 54 | /** | 49 | /** |
| 55 | * struct mic_device_ctrl: Per virtio device information in the device page | 50 | * struct mic_device_ctrl: Per virtio device information in the device page |
| @@ -66,7 +61,7 @@ struct mic_device_desc { | |||
| 66 | * @h2c_vdev_db: The doorbell number to be used by host. Set by guest. | 61 | * @h2c_vdev_db: The doorbell number to be used by host. Set by guest. |
| 67 | */ | 62 | */ |
| 68 | struct mic_device_ctrl { | 63 | struct mic_device_ctrl { |
| 69 | __u64 vdev; | 64 | __le64 vdev; |
| 70 | __u8 config_change; | 65 | __u8 config_change; |
| 71 | __u8 vdev_reset; | 66 | __u8 vdev_reset; |
| 72 | __u8 guest_ack; | 67 | __u8 guest_ack; |
| @@ -74,7 +69,7 @@ struct mic_device_ctrl { | |||
| 74 | __u8 used_address_updated; | 69 | __u8 used_address_updated; |
| 75 | __s8 c2h_vdev_db; | 70 | __s8 c2h_vdev_db; |
| 76 | __s8 h2c_vdev_db; | 71 | __s8 h2c_vdev_db; |
| 77 | } __aligned(8); | 72 | } __attribute__ ((aligned(8))); |
| 78 | 73 | ||
| 79 | /** | 74 | /** |
| 80 | * struct mic_bootparam: Virtio device independent information in device page | 75 | * struct mic_bootparam: Virtio device independent information in device page |
| @@ -87,13 +82,13 @@ struct mic_device_ctrl { | |||
| 87 | * @shutdown_card: Set to 1 by the host when a card shutdown is initiated | 82 | * @shutdown_card: Set to 1 by the host when a card shutdown is initiated |
| 88 | */ | 83 | */ |
| 89 | struct mic_bootparam { | 84 | struct mic_bootparam { |
| 90 | __u32 magic; | 85 | __le32 magic; |
| 91 | __s8 c2h_shutdown_db; | 86 | __s8 c2h_shutdown_db; |
| 92 | __s8 h2c_shutdown_db; | 87 | __s8 h2c_shutdown_db; |
| 93 | __s8 h2c_config_db; | 88 | __s8 h2c_config_db; |
| 94 | __u8 shutdown_status; | 89 | __u8 shutdown_status; |
| 95 | __u8 shutdown_card; | 90 | __u8 shutdown_card; |
| 96 | } __aligned(8); | 91 | } __attribute__ ((aligned(8))); |
| 97 | 92 | ||
| 98 | /** | 93 | /** |
| 99 | * struct mic_device_page: High level representation of the device page | 94 | * struct mic_device_page: High level representation of the device page |
| @@ -116,10 +111,10 @@ struct mic_device_page { | |||
| 116 | * @num: The number of entries in the virtio_ring | 111 | * @num: The number of entries in the virtio_ring |
| 117 | */ | 112 | */ |
| 118 | struct mic_vqconfig { | 113 | struct mic_vqconfig { |
| 119 | __u64 address; | 114 | __le64 address; |
| 120 | __u64 used_address; | 115 | __le64 used_address; |
| 121 | __u16 num; | 116 | __le16 num; |
| 122 | } __aligned(8); | 117 | } __attribute__ ((aligned(8))); |
| 123 | 118 | ||
| 124 | /* | 119 | /* |
| 125 | * The alignment to use between consumer and producer parts of vring. | 120 | * The alignment to use between consumer and producer parts of vring. |
| @@ -154,7 +149,7 @@ struct mic_vqconfig { | |||
| 154 | */ | 149 | */ |
| 155 | struct _mic_vring_info { | 150 | struct _mic_vring_info { |
| 156 | __u16 avail_idx; | 151 | __u16 avail_idx; |
| 157 | int magic; | 152 | __le32 magic; |
| 158 | }; | 153 | }; |
| 159 | 154 | ||
| 160 | /** | 155 | /** |
| @@ -173,15 +168,13 @@ struct mic_vring { | |||
| 173 | int len; | 168 | int len; |
| 174 | }; | 169 | }; |
| 175 | 170 | ||
| 176 | #define mic_aligned_desc_size(d) ALIGN(mic_desc_size(d), 8) | 171 | #define mic_aligned_desc_size(d) __mic_align(mic_desc_size(d), 8) |
| 177 | 172 | ||
| 178 | #ifndef INTEL_MIC_CARD | 173 | #ifndef INTEL_MIC_CARD |
| 179 | static inline unsigned mic_desc_size(const struct mic_device_desc *desc) | 174 | static inline unsigned mic_desc_size(const struct mic_device_desc *desc) |
| 180 | { | 175 | { |
| 181 | return mic_aligned_size(*desc) | 176 | return sizeof(*desc) + desc->num_vq * sizeof(struct mic_vqconfig) |
| 182 | + desc->num_vq * mic_aligned_size(struct mic_vqconfig) | 177 | + desc->feature_len * 2 + desc->config_len; |
| 183 | + desc->feature_len * 2 | ||
| 184 | + desc->config_len; | ||
| 185 | } | 178 | } |
| 186 | 179 | ||
| 187 | static inline struct mic_vqconfig * | 180 | static inline struct mic_vqconfig * |
| @@ -201,8 +194,7 @@ static inline __u8 *mic_vq_configspace(const struct mic_device_desc *desc) | |||
| 201 | } | 194 | } |
| 202 | static inline unsigned mic_total_desc_size(struct mic_device_desc *desc) | 195 | static inline unsigned mic_total_desc_size(struct mic_device_desc *desc) |
| 203 | { | 196 | { |
| 204 | return mic_aligned_desc_size(desc) + | 197 | return mic_aligned_desc_size(desc) + sizeof(struct mic_device_ctrl); |
| 205 | mic_aligned_size(struct mic_device_ctrl); | ||
| 206 | } | 198 | } |
| 207 | #endif | 199 | #endif |
| 208 | 200 | ||
