aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2013-12-08 21:47:25 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2013-12-08 21:47:25 -0500
commitf64001ef16312e94deb28297f5ffd4ada3e32ae9 (patch)
tree9b00f1efc3f593e9df7c7630ae29fd28d15df0a1
parentb19d69c72d4e3da67f0feb2ecf45d6e60c82baf1 (diff)
parent76a9635979e543f04a5885198e68ff28e3311b67 (diff)
Merge tag 'char-misc-3.13-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc
Pull char/misc driver fixes from Greg KH: "Nothing huge, just a few small bugfixes for problems reported, and a device id update" * tag 'char-misc-3.13-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc: mei: add 9 series PCH mei device ids drivers/char/i8k.c: add Dell XPLS L421X MAINTAINERS: add HSI subsystem misc: mic: Suppress memory space sparse warnings misc: mic: Fix endianness issues. misc: mic: Fix user space namespace pollution from mic_common.h. misc: mic: Bug fix for sysfs poll usage. misc: mic: Minor bug fix in 'retry' loops. misc: mic: Change mic_notify(...) to return true. extcon: remove freed groups caused the panic or warning in unregister flow extcon: arizona: Get pdata from arizona structure not device
-rw-r--r--CREDITS5
-rw-r--r--Documentation/mic/mpssd/mpssd.c18
-rw-r--r--MAINTAINERS8
-rw-r--r--drivers/char/i8k.c7
-rw-r--r--drivers/extcon/extcon-arizona.c4
-rw-r--r--drivers/extcon/extcon-class.c3
-rw-r--r--drivers/misc/mei/hw-me-regs.h5
-rw-r--r--drivers/misc/mei/pci-me.c4
-rw-r--r--drivers/misc/mic/card/mic_virtio.c33
-rw-r--r--drivers/misc/mic/card/mic_virtio.h7
-rw-r--r--drivers/misc/mic/host/mic_boot.c2
-rw-r--r--drivers/misc/mic/host/mic_virtio.c30
-rw-r--r--drivers/misc/mic/host/mic_x100.c4
-rw-r--r--include/uapi/linux/mic_common.h40
14 files changed, 97 insertions, 73 deletions
diff --git a/CREDITS b/CREDITS
index 4fc997d58ab2..4c7738f49357 100644
--- a/CREDITS
+++ b/CREDITS
@@ -655,6 +655,11 @@ S: Stanford University
655S: Stanford, California 94305 655S: Stanford, California 94305
656S: USA 656S: USA
657 657
658N: Carlos Chinea
659E: carlos.chinea@nokia.com
660E: cch.devel@gmail.com
661D: Author of HSI Subsystem
662
658N: Randolph Chung 663N: Randolph Chung
659E: tausq@debian.org 664E: tausq@debian.org
660D: Linux/PA-RISC hacker 665D: 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 }
464done: 464done:
465 return va; 465 return va;
@@ -520,7 +520,7 @@ static void *
520virtio_net(void *arg) 520virtio_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 cfd90c9d0740..9486fb6fe38e 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -4045,6 +4045,14 @@ W: http://artax.karlin.mff.cuni.cz/~mikulas/vyplody/hpfs/index-e.cgi
4045S: Maintained 4045S: Maintained
4046F: fs/hpfs/ 4046F: fs/hpfs/
4047 4047
4048HSI SUBSYSTEM
4049M: Sebastian Reichel <sre@debian.org>
4050S: Maintained
4051F: Documentation/ABI/testing/sysfs-bus-hsi
4052F: drivers/hsi/
4053F: include/linux/hsi/
4054F: include/uapi/linux/hsi/
4055
4048HSO 3G MODEM DRIVER 4056HSO 3G MODEM DRIVER
4049M: Jan Dumon <j.dumon@option.com> 4057M: Jan Dumon <j.dumon@option.com>
4050W: http://www.pharscape.org 4058W: http://www.pharscape.org
diff --git a/drivers/char/i8k.c b/drivers/char/i8k.c
index 40cc0cf2ded6..e6939e13e338 100644
--- a/drivers/char/i8k.c
+++ b/drivers/char/i8k.c
@@ -664,6 +664,13 @@ static struct dmi_system_id __initdata i8k_dmi_table[] = {
664 DMI_MATCH(DMI_PRODUCT_NAME, "Vostro"), 664 DMI_MATCH(DMI_PRODUCT_NAME, "Vostro"),
665 }, 665 },
666 }, 666 },
667 {
668 .ident = "Dell XPS421",
669 .matches = {
670 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
671 DMI_MATCH(DMI_PRODUCT_NAME, "XPS L421X"),
672 },
673 },
667 { } 674 { }
668}; 675};
669 676
diff --git a/drivers/extcon/extcon-arizona.c b/drivers/extcon/extcon-arizona.c
index 3c55ec856e39..a287cece0593 100644
--- a/drivers/extcon/extcon-arizona.c
+++ b/drivers/extcon/extcon-arizona.c
@@ -1082,7 +1082,7 @@ static void arizona_micd_set_level(struct arizona *arizona, int index,
1082static int arizona_extcon_probe(struct platform_device *pdev) 1082static int arizona_extcon_probe(struct platform_device *pdev)
1083{ 1083{
1084 struct arizona *arizona = dev_get_drvdata(pdev->dev.parent); 1084 struct arizona *arizona = dev_get_drvdata(pdev->dev.parent);
1085 struct arizona_pdata *pdata; 1085 struct arizona_pdata *pdata = &arizona->pdata;
1086 struct arizona_extcon_info *info; 1086 struct arizona_extcon_info *info;
1087 unsigned int val; 1087 unsigned int val;
1088 int jack_irq_fall, jack_irq_rise; 1088 int jack_irq_fall, jack_irq_rise;
@@ -1091,8 +1091,6 @@ static int arizona_extcon_probe(struct platform_device *pdev)
1091 if (!arizona->dapm || !arizona->dapm->card) 1091 if (!arizona->dapm || !arizona->dapm->card)
1092 return -EPROBE_DEFER; 1092 return -EPROBE_DEFER;
1093 1093
1094 pdata = dev_get_platdata(arizona->dev);
1095
1096 info = devm_kzalloc(&pdev->dev, sizeof(*info), GFP_KERNEL); 1094 info = devm_kzalloc(&pdev->dev, sizeof(*info), GFP_KERNEL);
1097 if (!info) { 1095 if (!info) {
1098 dev_err(&pdev->dev, "Failed to allocate memory\n"); 1096 dev_err(&pdev->dev, "Failed to allocate memory\n");
diff --git a/drivers/extcon/extcon-class.c b/drivers/extcon/extcon-class.c
index 15443d3b6be1..76322330cbd7 100644
--- a/drivers/extcon/extcon-class.c
+++ b/drivers/extcon/extcon-class.c
@@ -792,6 +792,8 @@ void extcon_dev_unregister(struct extcon_dev *edev)
792 return; 792 return;
793 } 793 }
794 794
795 device_unregister(&edev->dev);
796
795 if (edev->mutually_exclusive && edev->max_supported) { 797 if (edev->mutually_exclusive && edev->max_supported) {
796 for (index = 0; edev->mutually_exclusive[index]; 798 for (index = 0; edev->mutually_exclusive[index];
797 index++) 799 index++)
@@ -812,7 +814,6 @@ void extcon_dev_unregister(struct extcon_dev *edev)
812 if (switch_class) 814 if (switch_class)
813 class_compat_remove_link(switch_class, &edev->dev, NULL); 815 class_compat_remove_link(switch_class, &edev->dev, NULL);
814#endif 816#endif
815 device_unregister(&edev->dev);
816 put_device(&edev->dev); 817 put_device(&edev->dev);
817} 818}
818EXPORT_SYMBOL_GPL(extcon_dev_unregister); 819EXPORT_SYMBOL_GPL(extcon_dev_unregister);
diff --git a/drivers/misc/mei/hw-me-regs.h b/drivers/misc/mei/hw-me-regs.h
index 6c0fde55270d..66f411a6e8ea 100644
--- a/drivers/misc/mei/hw-me-regs.h
+++ b/drivers/misc/mei/hw-me-regs.h
@@ -109,9 +109,12 @@
109#define MEI_DEV_ID_PPT_2 0x1CBA /* Panther Point */ 109#define MEI_DEV_ID_PPT_2 0x1CBA /* Panther Point */
110#define MEI_DEV_ID_PPT_3 0x1DBA /* Panther Point */ 110#define MEI_DEV_ID_PPT_3 0x1DBA /* Panther Point */
111 111
112#define MEI_DEV_ID_LPT 0x8C3A /* Lynx Point */ 112#define MEI_DEV_ID_LPT_H 0x8C3A /* Lynx Point H */
113#define MEI_DEV_ID_LPT_W 0x8D3A /* Lynx Point - Wellsburg */ 113#define MEI_DEV_ID_LPT_W 0x8D3A /* Lynx Point - Wellsburg */
114#define MEI_DEV_ID_LPT_LP 0x9C3A /* Lynx Point LP */ 114#define MEI_DEV_ID_LPT_LP 0x9C3A /* Lynx Point LP */
115#define MEI_DEV_ID_LPT_HR 0x8CBA /* Lynx Point H Refresh */
116
117#define MEI_DEV_ID_WPT_LP 0x9CBA /* Wildcat Point LP */
115/* 118/*
116 * MEI HW Section 119 * MEI HW Section
117 */ 120 */
diff --git a/drivers/misc/mei/pci-me.c b/drivers/misc/mei/pci-me.c
index b96205aece0c..2cab3c0a6805 100644
--- a/drivers/misc/mei/pci-me.c
+++ b/drivers/misc/mei/pci-me.c
@@ -76,9 +76,11 @@ static DEFINE_PCI_DEVICE_TABLE(mei_me_pci_tbl) = {
76 {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_PPT_1)}, 76 {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_PPT_1)},
77 {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_PPT_2)}, 77 {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_PPT_2)},
78 {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_PPT_3)}, 78 {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_PPT_3)},
79 {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_LPT)}, 79 {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_LPT_H)},
80 {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_LPT_W)}, 80 {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_LPT_W)},
81 {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_LPT_LP)}, 81 {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_LPT_LP)},
82 {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_LPT_HR)},
83 {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_WPT_LP)},
82 84
83 /* required last entry */ 85 /* required last entry */
84 {0, } 86 {0, }
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 */
190static void mic_notify(struct virtqueue *vq) 190static 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
197static void mic_del_vq(struct virtqueue *vq, int n) 198static 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
43static inline unsigned mic_desc_size(struct mic_device_desc __iomem *desc) 43static 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}
68static inline unsigned mic_total_desc_size(struct mic_device_desc __iomem *desc) 68static 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
74int mic_devices_init(struct mic_driver *mdrv); 73int 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;
667skip_hot_remove: 667skip_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);
403error: 403error:
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 */
68struct mic_device_ctrl { 63struct 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 */
89struct mic_bootparam { 84struct 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 */
118struct mic_vqconfig { 113struct 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 */
155struct _mic_vring_info { 150struct _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
179static inline unsigned mic_desc_size(const struct mic_device_desc *desc) 174static 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
187static inline struct mic_vqconfig * 180static inline struct mic_vqconfig *
@@ -201,8 +194,7 @@ static inline __u8 *mic_vq_configspace(const struct mic_device_desc *desc)
201} 194}
202static inline unsigned mic_total_desc_size(struct mic_device_desc *desc) 195static 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