aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAshutosh Dixit <ashutosh.dixit@intel.com>2013-09-27 12:49:53 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-09-27 20:20:19 -0400
commitced2c60fb5024a5cf5c33cb573b3d6a66d738f36 (patch)
tree19763d6180d0a9b16f0da478c4801f3445424b28
parent4aa79961a50119d6112a160e97d5e6a77656b68c (diff)
misc: mic: cleanups for "--strict" checkpatch.
These changes were mostly authored by Joe Perches <joe@perches.com> @ https://lkml.org/lkml/2013/9/5/602 Reported-by: Joe Perches <joe@perches.com> Signed-off-by: Ashutosh Dixit <ashutosh.dixit@intel.com> Signed-off-by: Dasaratharaman Chandramouli <dasaratharaman.chandramouli@intel.com> Signed-off-by: Nikhil Rao <nikhil.rao@intel.com> Signed-off-by: Harshavardhan R Kharche <harshavardhan.r.kharche@intel.com> Signed-off-by: Sudeep Dutt <sudeep.dutt@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--Documentation/mic/mpssd/mpssd.c65
-rw-r--r--Documentation/mic/mpssd/sysfs.c4
-rw-r--r--drivers/misc/mic/card/mic_device.c1
-rw-r--r--drivers/misc/mic/card/mic_virtio.c17
-rw-r--r--drivers/misc/mic/card/mic_x100.c4
-rw-r--r--drivers/misc/mic/host/mic_debugfs.c90
-rw-r--r--drivers/misc/mic/host/mic_fops.c6
-rw-r--r--drivers/misc/mic/host/mic_intr.c34
-rw-r--r--drivers/misc/mic/host/mic_smpt.c14
-rw-r--r--drivers/misc/mic/host/mic_sysfs.c20
-rw-r--r--drivers/misc/mic/host/mic_virtio.c37
-rw-r--r--drivers/misc/mic/host/mic_x100.c33
12 files changed, 158 insertions, 167 deletions
diff --git a/Documentation/mic/mpssd/mpssd.c b/Documentation/mic/mpssd/mpssd.c
index 8064804cdac3..f9327a29ae4c 100644
--- a/Documentation/mic/mpssd/mpssd.c
+++ b/Documentation/mic/mpssd/mpssd.c
@@ -246,7 +246,7 @@ static int tun_alloc(struct mic_info *mic, char *dev)
246 if (*dev) 246 if (*dev)
247 strncpy(ifr.ifr_name, dev, IFNAMSIZ); 247 strncpy(ifr.ifr_name, dev, IFNAMSIZ);
248 248
249 err = ioctl(fd, TUNSETIFF, (void *) &ifr); 249 err = ioctl(fd, TUNSETIFF, (void *)&ifr);
250 if (err < 0) { 250 if (err < 0) {
251 mpsslog("%s %s %d TUNSETIFF failed %s\n", 251 mpsslog("%s %s %d TUNSETIFF failed %s\n",
252 mic->name, __func__, __LINE__, strerror(errno)); 252 mic->name, __func__, __LINE__, strerror(errno));
@@ -363,7 +363,7 @@ static inline void verify_out_len(struct mic_info *mic,
363{ 363{
364 if (copy->out_len != sum_iovec_len(copy)) { 364 if (copy->out_len != sum_iovec_len(copy)) {
365 mpsslog("%s %s %d BUG copy->out_len 0x%x len 0x%x\n", 365 mpsslog("%s %s %d BUG copy->out_len 0x%x len 0x%x\n",
366 mic->name, __func__, __LINE__, 366 mic->name, __func__, __LINE__,
367 copy->out_len, sum_iovec_len(copy)); 367 copy->out_len, sum_iovec_len(copy));
368 assert(copy->out_len == sum_iovec_len(copy)); 368 assert(copy->out_len == sum_iovec_len(copy));
369 } 369 }
@@ -372,7 +372,7 @@ static inline void verify_out_len(struct mic_info *mic,
372/* Display an iovec */ 372/* Display an iovec */
373static void 373static void
374disp_iovec(struct mic_info *mic, struct mic_copy_desc *copy, 374disp_iovec(struct mic_info *mic, struct mic_copy_desc *copy,
375 const char *s, int line) 375 const char *s, int line)
376{ 376{
377 int i; 377 int i;
378 378
@@ -401,7 +401,7 @@ static inline void txrx_prepare(int type, bool tx, struct mic_vring *vr,
401/* Central API which triggers the copies */ 401/* Central API which triggers the copies */
402static int 402static int
403mic_virtio_copy(struct mic_info *mic, int fd, 403mic_virtio_copy(struct mic_info *mic, int fd,
404 struct mic_vring *vr, struct mic_copy_desc *copy) 404 struct mic_vring *vr, struct mic_copy_desc *copy)
405{ 405{
406 int ret; 406 int ret;
407 407
@@ -440,7 +440,7 @@ init_vr(struct mic_info *mic, int fd, int type,
440 vr0->info = vr0->va + 440 vr0->info = vr0->va +
441 vring_size(MIC_VRING_ENTRIES, MIC_VIRTIO_RING_ALIGN); 441 vring_size(MIC_VRING_ENTRIES, MIC_VIRTIO_RING_ALIGN);
442 vring_init(&vr0->vr, 442 vring_init(&vr0->vr,
443 MIC_VRING_ENTRIES, vr0->va, MIC_VIRTIO_RING_ALIGN); 443 MIC_VRING_ENTRIES, vr0->va, MIC_VIRTIO_RING_ALIGN);
444 mpsslog("%s %s vr0 %p vr0->info %p vr_size 0x%x vring 0x%x ", 444 mpsslog("%s %s vr0 %p vr0->info %p vr_size 0x%x vring 0x%x ",
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));
@@ -453,7 +453,7 @@ init_vr(struct mic_info *mic, int fd, int type,
453 vr1->info = vr1->va + vring_size(MIC_VRING_ENTRIES, 453 vr1->info = vr1->va + vring_size(MIC_VRING_ENTRIES,
454 MIC_VIRTIO_RING_ALIGN); 454 MIC_VIRTIO_RING_ALIGN);
455 vring_init(&vr1->vr, 455 vring_init(&vr1->vr,
456 MIC_VRING_ENTRIES, vr1->va, MIC_VIRTIO_RING_ALIGN); 456 MIC_VRING_ENTRIES, vr1->va, MIC_VIRTIO_RING_ALIGN);
457 mpsslog("%s %s vr1 %p vr1->info %p vr_size 0x%x vring 0x%x ", 457 mpsslog("%s %s vr1 %p vr1->info %p vr_size 0x%x vring 0x%x ",
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));
@@ -551,7 +551,7 @@ virtio_net(void *arg)
551 net_poll[NET_FD_TUN].events = POLLIN; 551 net_poll[NET_FD_TUN].events = POLLIN;
552 552
553 if (MAP_FAILED == init_vr(mic, mic->mic_net.virtio_net_fd, 553 if (MAP_FAILED == init_vr(mic, mic->mic_net.virtio_net_fd,
554 VIRTIO_ID_NET, &tx_vr, &rx_vr, 554 VIRTIO_ID_NET, &tx_vr, &rx_vr,
555 virtnet_dev_page.dd.num_vq)) { 555 virtnet_dev_page.dd.num_vq)) {
556 mpsslog("%s init_vr failed %s\n", 556 mpsslog("%s init_vr failed %s\n",
557 mic->name, strerror(errno)); 557 mic->name, strerror(errno));
@@ -576,7 +576,7 @@ virtio_net(void *arg)
576 } 576 }
577 if (!(desc->status & VIRTIO_CONFIG_S_DRIVER_OK)) 577 if (!(desc->status & VIRTIO_CONFIG_S_DRIVER_OK))
578 wait_for_card_driver(mic, mic->mic_net.virtio_net_fd, 578 wait_for_card_driver(mic, mic->mic_net.virtio_net_fd,
579 VIRTIO_ID_NET); 579 VIRTIO_ID_NET);
580 /* 580 /*
581 * Check if there is data to be read from TUN and write to 581 * Check if there is data to be read from TUN and write to
582 * virtio net fd if there is. 582 * virtio net fd if there is.
@@ -587,7 +587,7 @@ virtio_net(void *arg)
587 copy.iov, copy.iovcnt); 587 copy.iov, copy.iovcnt);
588 if (len > 0) { 588 if (len > 0) {
589 struct virtio_net_hdr *hdr 589 struct virtio_net_hdr *hdr
590 = (struct virtio_net_hdr *) vnet_hdr[0]; 590 = (struct virtio_net_hdr *)vnet_hdr[0];
591 591
592 /* Disable checksums on the card since we are on 592 /* Disable checksums on the card since we are on
593 a reliable PCIe link */ 593 a reliable PCIe link */
@@ -606,7 +606,7 @@ virtio_net(void *arg)
606#endif 606#endif
607 spin_for_descriptors(mic, &tx_vr); 607 spin_for_descriptors(mic, &tx_vr);
608 txrx_prepare(VIRTIO_ID_NET, 1, &tx_vr, &copy, 608 txrx_prepare(VIRTIO_ID_NET, 1, &tx_vr, &copy,
609 len); 609 len);
610 610
611 err = mic_virtio_copy(mic, 611 err = mic_virtio_copy(mic,
612 mic->mic_net.virtio_net_fd, &tx_vr, 612 mic->mic_net.virtio_net_fd, &tx_vr,
@@ -644,7 +644,7 @@ virtio_net(void *arg)
644 le16toh(rx_vr.vr.avail->idx)) { 644 le16toh(rx_vr.vr.avail->idx)) {
645 copy.iov = iov1; 645 copy.iov = iov1;
646 txrx_prepare(VIRTIO_ID_NET, 0, &rx_vr, &copy, 646 txrx_prepare(VIRTIO_ID_NET, 0, &rx_vr, &copy,
647 MAX_NET_PKT_SIZE 647 MAX_NET_PKT_SIZE
648 + sizeof(struct virtio_net_hdr)); 648 + sizeof(struct virtio_net_hdr));
649 649
650 err = mic_virtio_copy(mic, 650 err = mic_virtio_copy(mic,
@@ -669,7 +669,7 @@ virtio_net(void *arg)
669 verify_out_len(mic, &copy); 669 verify_out_len(mic, &copy);
670#ifdef DEBUG 670#ifdef DEBUG
671 disp_iovec(mic, copy, __func__, 671 disp_iovec(mic, copy, __func__,
672 __LINE__); 672 __LINE__);
673 mpsslog("%s %s %d ", 673 mpsslog("%s %s %d ",
674 mic->name, __func__, __LINE__); 674 mic->name, __func__, __LINE__);
675 mpsslog("read from net 0x%lx\n", 675 mpsslog("read from net 0x%lx\n",
@@ -686,7 +686,7 @@ virtio_net(void *arg)
686 } else { 686 } else {
687#ifdef DEBUG 687#ifdef DEBUG
688 disp_iovec(mic, &copy, __func__, 688 disp_iovec(mic, &copy, __func__,
689 __LINE__); 689 __LINE__);
690 mpsslog("%s %s %d ", 690 mpsslog("%s %s %d ",
691 mic->name, __func__, 691 mic->name, __func__,
692 __LINE__); 692 __LINE__);
@@ -750,13 +750,13 @@ virtio_console(void *arg)
750 err = grantpt(pty_fd); 750 err = grantpt(pty_fd);
751 if (err < 0) { 751 if (err < 0) {
752 mpsslog("can't grant access: %s %s\n", 752 mpsslog("can't grant access: %s %s\n",
753 pts_name, strerror(errno)); 753 pts_name, strerror(errno));
754 goto _close_pty; 754 goto _close_pty;
755 } 755 }
756 err = unlockpt(pty_fd); 756 err = unlockpt(pty_fd);
757 if (err < 0) { 757 if (err < 0) {
758 mpsslog("can't unlock a pseudoterminal: %s %s\n", 758 mpsslog("can't unlock a pseudoterminal: %s %s\n",
759 pts_name, strerror(errno)); 759 pts_name, strerror(errno));
760 goto _close_pty; 760 goto _close_pty;
761 } 761 }
762 console_poll[MONITOR_FD].fd = pty_fd; 762 console_poll[MONITOR_FD].fd = pty_fd;
@@ -766,7 +766,7 @@ virtio_console(void *arg)
766 console_poll[VIRTIO_CONSOLE_FD].events = POLLIN; 766 console_poll[VIRTIO_CONSOLE_FD].events = POLLIN;
767 767
768 if (MAP_FAILED == init_vr(mic, mic->mic_console.virtio_console_fd, 768 if (MAP_FAILED == init_vr(mic, mic->mic_console.virtio_console_fd,
769 VIRTIO_ID_CONSOLE, &tx_vr, &rx_vr, 769 VIRTIO_ID_CONSOLE, &tx_vr, &rx_vr,
770 virtcons_dev_page.dd.num_vq)) { 770 virtcons_dev_page.dd.num_vq)) {
771 mpsslog("%s init_vr failed %s\n", 771 mpsslog("%s init_vr failed %s\n",
772 mic->name, strerror(errno)); 772 mic->name, strerror(errno));
@@ -787,7 +787,7 @@ virtio_console(void *arg)
787 } 787 }
788 if (!(desc->status & VIRTIO_CONFIG_S_DRIVER_OK)) 788 if (!(desc->status & VIRTIO_CONFIG_S_DRIVER_OK))
789 wait_for_card_driver(mic, 789 wait_for_card_driver(mic,
790 mic->mic_console.virtio_console_fd, 790 mic->mic_console.virtio_console_fd,
791 VIRTIO_ID_CONSOLE); 791 VIRTIO_ID_CONSOLE);
792 792
793 if (console_poll[MONITOR_FD].revents & POLLIN) { 793 if (console_poll[MONITOR_FD].revents & POLLIN) {
@@ -802,7 +802,7 @@ virtio_console(void *arg)
802#endif 802#endif
803 spin_for_descriptors(mic, &tx_vr); 803 spin_for_descriptors(mic, &tx_vr);
804 txrx_prepare(VIRTIO_ID_CONSOLE, 1, &tx_vr, 804 txrx_prepare(VIRTIO_ID_CONSOLE, 1, &tx_vr,
805 &copy, len); 805 &copy, len);
806 806
807 err = mic_virtio_copy(mic, 807 err = mic_virtio_copy(mic,
808 mic->mic_console.virtio_console_fd, 808 mic->mic_console.virtio_console_fd,
@@ -837,7 +837,7 @@ virtio_console(void *arg)
837 le16toh(rx_vr.vr.avail->idx)) { 837 le16toh(rx_vr.vr.avail->idx)) {
838 copy.iov = iov1; 838 copy.iov = iov1;
839 txrx_prepare(VIRTIO_ID_CONSOLE, 0, &rx_vr, 839 txrx_prepare(VIRTIO_ID_CONSOLE, 0, &rx_vr,
840 &copy, PAGE_SIZE); 840 &copy, PAGE_SIZE);
841 841
842 err = mic_virtio_copy(mic, 842 err = mic_virtio_copy(mic,
843 mic->mic_console.virtio_console_fd, 843 mic->mic_console.virtio_console_fd,
@@ -848,7 +848,7 @@ virtio_console(void *arg)
848 verify_out_len(mic, &copy); 848 verify_out_len(mic, &copy);
849#ifdef DEBUG 849#ifdef DEBUG
850 disp_iovec(mic, copy, __func__, 850 disp_iovec(mic, copy, __func__,
851 __LINE__); 851 __LINE__);
852 mpsslog("%s %s %d ", 852 mpsslog("%s %s %d ",
853 mic->name, __func__, __LINE__); 853 mic->name, __func__, __LINE__);
854 mpsslog("read from net 0x%lx\n", 854 mpsslog("read from net 0x%lx\n",
@@ -865,7 +865,7 @@ virtio_console(void *arg)
865 } else { 865 } else {
866#ifdef DEBUG 866#ifdef DEBUG
867 disp_iovec(mic, copy, __func__, 867 disp_iovec(mic, copy, __func__,
868 __LINE__); 868 __LINE__);
869 mpsslog("%s %s %d ", 869 mpsslog("%s %s %d ",
870 mic->name, __func__, 870 mic->name, __func__,
871 __LINE__); 871 __LINE__);
@@ -1033,7 +1033,8 @@ start_virtblk(struct mic_info *mic, struct mic_vring *vring)
1033 } 1033 }
1034 add_virtio_device(mic, &virtblk_dev_page.dd); 1034 add_virtio_device(mic, &virtblk_dev_page.dd);
1035 if (MAP_FAILED == init_vr(mic, mic->mic_virtblk.virtio_block_fd, 1035 if (MAP_FAILED == init_vr(mic, mic->mic_virtblk.virtio_block_fd,
1036 VIRTIO_ID_BLOCK, vring, NULL, virtblk_dev_page.dd.num_vq)) { 1036 VIRTIO_ID_BLOCK, vring, NULL,
1037 virtblk_dev_page.dd.num_vq)) {
1037 mpsslog("%s init_vr failed %s\n", 1038 mpsslog("%s init_vr failed %s\n",
1038 mic->name, strerror(errno)); 1039 mic->name, strerror(errno));
1039 return false; 1040 return false;
@@ -1060,7 +1061,7 @@ header_error_check(struct vring_desc *desc)
1060{ 1061{
1061 if (le32toh(desc->len) != sizeof(struct virtio_blk_outhdr)) { 1062 if (le32toh(desc->len) != sizeof(struct virtio_blk_outhdr)) {
1062 mpsslog("%s() %d: length is not sizeof(virtio_blk_outhd)\n", 1063 mpsslog("%s() %d: length is not sizeof(virtio_blk_outhd)\n",
1063 __func__, __LINE__); 1064 __func__, __LINE__);
1064 return -EIO; 1065 return -EIO;
1065 } 1066 }
1066 if (!(le16toh(desc->flags) & VRING_DESC_F_NEXT)) { 1067 if (!(le16toh(desc->flags) & VRING_DESC_F_NEXT)) {
@@ -1132,7 +1133,7 @@ write_status(int fd, __u8 *status)
1132static void * 1133static void *
1133virtio_block(void *arg) 1134virtio_block(void *arg)
1134{ 1135{
1135 struct mic_info *mic = (struct mic_info *) arg; 1136 struct mic_info *mic = (struct mic_info *)arg;
1136 int ret; 1137 int ret;
1137 struct pollfd block_poll; 1138 struct pollfd block_poll;
1138 struct mic_vring vring; 1139 struct mic_vring vring;
@@ -1219,8 +1220,8 @@ virtio_block(void *arg)
1219 status = 0; 1220 status = 0;
1220 fos = mic->mic_virtblk.backend_addr + 1221 fos = mic->mic_virtblk.backend_addr +
1221 (hdr.sector * SECTOR_SIZE); 1222 (hdr.sector * SECTOR_SIZE);
1222 buffer_desc_idx = desc_idx = 1223 buffer_desc_idx = next_desc(desc);
1223 next_desc(desc); 1224 desc_idx = buffer_desc_idx;
1224 for (desc = &vring.vr.desc[buffer_desc_idx]; 1225 for (desc = &vring.vr.desc[buffer_desc_idx];
1225 desc->flags & VRING_DESC_F_NEXT; 1226 desc->flags & VRING_DESC_F_NEXT;
1226 desc_idx = next_desc(desc), 1227 desc_idx = next_desc(desc),
@@ -1255,7 +1256,7 @@ virtio_block(void *arg)
1255 iovec, 1256 iovec,
1256 piov - iovec); 1257 piov - iovec);
1257 if (ret < 0 && 1258 if (ret < 0 &&
1258 status != 0) 1259 status != 0)
1259 status = ret; 1260 status = ret;
1260 } 1261 }
1261 /* write status and update used pointer */ 1262 /* write status and update used pointer */
@@ -1391,7 +1392,7 @@ mic_config(void *arg)
1391 char value[4096]; 1392 char value[4096];
1392 1393
1393 snprintf(pathname, PATH_MAX - 1, "%s/%s/%s", 1394 snprintf(pathname, PATH_MAX - 1, "%s/%s/%s",
1394 MICSYSFSDIR, mic->name, "state"); 1395 MICSYSFSDIR, mic->name, "state");
1395 1396
1396 fd = open(pathname, O_RDONLY); 1397 fd = open(pathname, O_RDONLY);
1397 if (fd < 0) { 1398 if (fd < 0) {
@@ -1560,22 +1561,22 @@ init_mic(struct mic_info *mic)
1560 virtio_console, mic); 1561 virtio_console, mic);
1561 if (err) 1562 if (err)
1562 mpsslog("%s virtcons pthread_create failed %s\n", 1563 mpsslog("%s virtcons pthread_create failed %s\n",
1563 mic->name, strerror(err)); 1564 mic->name, strerror(err));
1564 err = pthread_create(&mic->mic_net.net_thread, NULL, 1565 err = pthread_create(&mic->mic_net.net_thread, NULL,
1565 virtio_net, mic); 1566 virtio_net, mic);
1566 if (err) 1567 if (err)
1567 mpsslog("%s virtnet pthread_create failed %s\n", 1568 mpsslog("%s virtnet pthread_create failed %s\n",
1568 mic->name, strerror(err)); 1569 mic->name, strerror(err));
1569 err = pthread_create(&mic->mic_virtblk.block_thread, NULL, 1570 err = pthread_create(&mic->mic_virtblk.block_thread, NULL,
1570 virtio_block, mic); 1571 virtio_block, mic);
1571 if (err) 1572 if (err)
1572 mpsslog("%s virtblk pthread_create failed %s\n", 1573 mpsslog("%s virtblk pthread_create failed %s\n",
1573 mic->name, strerror(err)); 1574 mic->name, strerror(err));
1574 sigemptyset(&act.sa_mask); 1575 sigemptyset(&act.sa_mask);
1575 err = sigaction(SIGUSR1, &act, NULL); 1576 err = sigaction(SIGUSR1, &act, NULL);
1576 if (err) 1577 if (err)
1577 mpsslog("%s sigaction SIGUSR1 failed %s\n", 1578 mpsslog("%s sigaction SIGUSR1 failed %s\n",
1578 mic->name, strerror(errno)); 1579 mic->name, strerror(errno));
1579 while (1) 1580 while (1)
1580 sleep(60); 1581 sleep(60);
1581 case -1: 1582 case -1:
diff --git a/Documentation/mic/mpssd/sysfs.c b/Documentation/mic/mpssd/sysfs.c
index 11de72b63386..8dd326936083 100644
--- a/Documentation/mic/mpssd/sysfs.c
+++ b/Documentation/mic/mpssd/sysfs.c
@@ -35,7 +35,7 @@ readsysfs(char *dir, char *entry)
35 snprintf(filename, PATH_MAX, "%s/%s", MICSYSFSDIR, entry); 35 snprintf(filename, PATH_MAX, "%s/%s", MICSYSFSDIR, entry);
36 else 36 else
37 snprintf(filename, PATH_MAX, 37 snprintf(filename, PATH_MAX,
38 "%s/%s/%s", MICSYSFSDIR, dir, entry); 38 "%s/%s/%s", MICSYSFSDIR, dir, entry);
39 39
40 fd = open(filename, O_RDONLY); 40 fd = open(filename, O_RDONLY);
41 if (fd < 0) { 41 if (fd < 0) {
@@ -75,7 +75,7 @@ setsysfs(char *dir, char *entry, char *value)
75 snprintf(filename, PATH_MAX, "%s/%s", MICSYSFSDIR, entry); 75 snprintf(filename, PATH_MAX, "%s/%s", MICSYSFSDIR, entry);
76 else 76 else
77 snprintf(filename, PATH_MAX, "%s/%s/%s", 77 snprintf(filename, PATH_MAX, "%s/%s/%s",
78 MICSYSFSDIR, dir, entry); 78 MICSYSFSDIR, dir, entry);
79 79
80 oldvalue = readsysfs(dir, entry); 80 oldvalue = readsysfs(dir, entry);
81 81
diff --git a/drivers/misc/mic/card/mic_device.c b/drivers/misc/mic/card/mic_device.c
index 175d11425636..d0980ff96833 100644
--- a/drivers/misc/mic/card/mic_device.c
+++ b/drivers/misc/mic/card/mic_device.c
@@ -167,7 +167,6 @@ struct mic_irq *mic_request_card_irq(irqreturn_t (*func)(int irq, void *data),
167 return (struct mic_irq *)cookie; 167 return (struct mic_irq *)cookie;
168err: 168err:
169 return ERR_PTR(rc); 169 return ERR_PTR(rc);
170
171} 170}
172 171
173/** 172/**
diff --git a/drivers/misc/mic/card/mic_virtio.c b/drivers/misc/mic/card/mic_virtio.c
index 7420c33d8f65..914cc9b2caad 100644
--- a/drivers/misc/mic/card/mic_virtio.c
+++ b/drivers/misc/mic/card/mic_virtio.c
@@ -103,7 +103,7 @@ static void mic_finalize_features(struct virtio_device *vdev)
103 for (i = 0; i < bits; i++) { 103 for (i = 0; i < bits; i++) {
104 if (test_bit(i, vdev->features)) 104 if (test_bit(i, vdev->features))
105 iowrite8(ioread8(&out_features[i / 8]) | (1 << (i % 8)), 105 iowrite8(ioread8(&out_features[i / 8]) | (1 << (i % 8)),
106 &out_features[i / 8]); 106 &out_features[i / 8]);
107 } 107 }
108} 108}
109 109
@@ -197,10 +197,9 @@ static void mic_notify(struct virtqueue *vq)
197static void mic_del_vq(struct virtqueue *vq, int n) 197static void mic_del_vq(struct virtqueue *vq, int n)
198{ 198{
199 struct mic_vdev *mvdev = to_micvdev(vq->vdev); 199 struct mic_vdev *mvdev = to_micvdev(vq->vdev);
200 struct vring *vr = (struct vring *) (vq + 1); 200 struct vring *vr = (struct vring *)(vq + 1);
201 201
202 free_pages((unsigned long) vr->used, 202 free_pages((unsigned long) vr->used, get_order(mvdev->used_size[n]));
203 get_order(mvdev->used_size[n]));
204 vring_del_virtqueue(vq); 203 vring_del_virtqueue(vq);
205 mic_card_unmap(mvdev->mdev, mvdev->vr[n]); 204 mic_card_unmap(mvdev->mdev, mvdev->vr[n]);
206 mvdev->vr[n] = NULL; 205 mvdev->vr[n] = NULL;
@@ -274,8 +273,8 @@ static struct virtqueue *mic_find_vq(struct virtio_device *vdev,
274 /* Allocate and reassign used ring now */ 273 /* Allocate and reassign used ring now */
275 mvdev->used_size[index] = PAGE_ALIGN(sizeof(__u16) * 3 + 274 mvdev->used_size[index] = PAGE_ALIGN(sizeof(__u16) * 3 +
276 sizeof(struct vring_used_elem) * config.num); 275 sizeof(struct vring_used_elem) * config.num);
277 used = (void *) __get_free_pages(GFP_KERNEL | __GFP_ZERO, 276 used = (void *)__get_free_pages(GFP_KERNEL | __GFP_ZERO,
278 get_order(mvdev->used_size[index])); 277 get_order(mvdev->used_size[index]));
279 if (!used) { 278 if (!used) {
280 err = -ENOMEM; 279 err = -ENOMEM;
281 dev_err(mic_dev(mvdev), "%s %d err %d\n", 280 dev_err(mic_dev(mvdev), "%s %d err %d\n",
@@ -291,7 +290,7 @@ static struct virtqueue *mic_find_vq(struct virtio_device *vdev,
291 * vring_new_virtqueue() would ensure that 290 * vring_new_virtqueue() would ensure that
292 * (&vq->vring == (struct vring *) (&vq->vq + 1)); 291 * (&vq->vring == (struct vring *) (&vq->vq + 1));
293 */ 292 */
294 vr = (struct vring *) (vq + 1); 293 vr = (struct vring *)(vq + 1);
295 vr->used = used; 294 vr->used = used;
296 295
297 vq->priv = mvdev; 296 vq->priv = mvdev;
@@ -544,7 +543,7 @@ static void mic_scan_devices(struct mic_driver *mdrv, bool remove)
544 if (dev) { 543 if (dev) {
545 if (remove) 544 if (remove)
546 iowrite8(MIC_VIRTIO_PARAM_DEV_REMOVE, 545 iowrite8(MIC_VIRTIO_PARAM_DEV_REMOVE,
547 &dc->config_change); 546 &dc->config_change);
548 put_device(dev); 547 put_device(dev);
549 mic_handle_config_change(d, i, mdrv); 548 mic_handle_config_change(d, i, mdrv);
550 ret = mic_remove_device(d, i, mdrv); 549 ret = mic_remove_device(d, i, mdrv);
@@ -559,7 +558,7 @@ static void mic_scan_devices(struct mic_driver *mdrv, bool remove)
559 558
560 /* new device */ 559 /* new device */
561 dev_dbg(mdrv->dev, "%s %d Adding new virtio device %p\n", 560 dev_dbg(mdrv->dev, "%s %d Adding new virtio device %p\n",
562 __func__, __LINE__, d); 561 __func__, __LINE__, d);
563 if (!remove) 562 if (!remove)
564 mic_add_device(d, i, mdrv); 563 mic_add_device(d, i, mdrv);
565 } 564 }
diff --git a/drivers/misc/mic/card/mic_x100.c b/drivers/misc/mic/card/mic_x100.c
index f491c9163bb2..2868945c9a4d 100644
--- a/drivers/misc/mic/card/mic_x100.c
+++ b/drivers/misc/mic/card/mic_x100.c
@@ -66,8 +66,8 @@ void mic_send_intr(struct mic_device *mdev, int doorbell)
66 /* Ensure that the interrupt is ordered w.r.t previous stores. */ 66 /* Ensure that the interrupt is ordered w.r.t previous stores. */
67 wmb(); 67 wmb();
68 mic_mmio_write(mw, MIC_X100_SBOX_SDBIC0_DBREQ_BIT, 68 mic_mmio_write(mw, MIC_X100_SBOX_SDBIC0_DBREQ_BIT,
69 MIC_X100_SBOX_BASE_ADDRESS + 69 MIC_X100_SBOX_BASE_ADDRESS +
70 (MIC_X100_SBOX_SDBIC0 + (4 * doorbell))); 70 (MIC_X100_SBOX_SDBIC0 + (4 * doorbell)));
71} 71}
72 72
73/** 73/**
diff --git a/drivers/misc/mic/host/mic_debugfs.c b/drivers/misc/mic/host/mic_debugfs.c
index 98a61b4319f4..028ba5d6fd1c 100644
--- a/drivers/misc/mic/host/mic_debugfs.c
+++ b/drivers/misc/mic/host/mic_debugfs.c
@@ -103,7 +103,7 @@ static int mic_smpt_show(struct seq_file *s, void *pos)
103 unsigned long flags; 103 unsigned long flags;
104 104
105 seq_printf(s, "MIC %-2d |%-10s| %-14s %-10s\n", 105 seq_printf(s, "MIC %-2d |%-10s| %-14s %-10s\n",
106 mdev->id, "SMPT entry", "SW DMA addr", "RefCount"); 106 mdev->id, "SMPT entry", "SW DMA addr", "RefCount");
107 seq_puts(s, "====================================================\n"); 107 seq_puts(s, "====================================================\n");
108 108
109 if (mdev->smpt) { 109 if (mdev->smpt) {
@@ -111,8 +111,8 @@ static int mic_smpt_show(struct seq_file *s, void *pos)
111 spin_lock_irqsave(&smpt_info->smpt_lock, flags); 111 spin_lock_irqsave(&smpt_info->smpt_lock, flags);
112 for (i = 0; i < smpt_info->info.num_reg; i++) { 112 for (i = 0; i < smpt_info->info.num_reg; i++) {
113 seq_printf(s, "%9s|%-10d| %-#14llx %-10lld\n", 113 seq_printf(s, "%9s|%-10d| %-#14llx %-10lld\n",
114 " ", i, smpt_info->entry[i].dma_addr, 114 " ", i, smpt_info->entry[i].dma_addr,
115 smpt_info->entry[i].ref_count); 115 smpt_info->entry[i].ref_count);
116 } 116 }
117 spin_unlock_irqrestore(&smpt_info->smpt_lock, flags); 117 spin_unlock_irqrestore(&smpt_info->smpt_lock, flags);
118 } 118 }
@@ -203,17 +203,17 @@ static int mic_dp_show(struct seq_file *s, void *pos)
203 int i, j; 203 int i, j;
204 204
205 seq_printf(s, "Bootparam: magic 0x%x\n", 205 seq_printf(s, "Bootparam: magic 0x%x\n",
206 bootparam->magic); 206 bootparam->magic);
207 seq_printf(s, "Bootparam: h2c_shutdown_db %d\n", 207 seq_printf(s, "Bootparam: h2c_shutdown_db %d\n",
208 bootparam->h2c_shutdown_db); 208 bootparam->h2c_shutdown_db);
209 seq_printf(s, "Bootparam: h2c_config_db %d\n", 209 seq_printf(s, "Bootparam: h2c_config_db %d\n",
210 bootparam->h2c_config_db); 210 bootparam->h2c_config_db);
211 seq_printf(s, "Bootparam: c2h_shutdown_db %d\n", 211 seq_printf(s, "Bootparam: c2h_shutdown_db %d\n",
212 bootparam->c2h_shutdown_db); 212 bootparam->c2h_shutdown_db);
213 seq_printf(s, "Bootparam: shutdown_status %d\n", 213 seq_printf(s, "Bootparam: shutdown_status %d\n",
214 bootparam->shutdown_status); 214 bootparam->shutdown_status);
215 seq_printf(s, "Bootparam: shutdown_card %d\n", 215 seq_printf(s, "Bootparam: shutdown_card %d\n",
216 bootparam->shutdown_card); 216 bootparam->shutdown_card);
217 217
218 for (i = sizeof(*bootparam); i < MIC_DP_SIZE; 218 for (i = sizeof(*bootparam); i < MIC_DP_SIZE;
219 i += mic_total_desc_size(d)) { 219 i += mic_total_desc_size(d)) {
@@ -239,10 +239,10 @@ static int mic_dp_show(struct seq_file *s, void *pos)
239 seq_printf(s, "address 0x%llx ", vqconfig->address); 239 seq_printf(s, "address 0x%llx ", vqconfig->address);
240 seq_printf(s, "num %d ", vqconfig->num); 240 seq_printf(s, "num %d ", vqconfig->num);
241 seq_printf(s, "used address 0x%llx\n", 241 seq_printf(s, "used address 0x%llx\n",
242 vqconfig->used_address); 242 vqconfig->used_address);
243 } 243 }
244 244
245 features = (__u32 *) mic_vq_features(d); 245 features = (__u32 *)mic_vq_features(d);
246 seq_printf(s, "Features: Host 0x%x ", features[0]); 246 seq_printf(s, "Features: Host 0x%x ", features[0]);
247 seq_printf(s, "Guest 0x%x\n", features[1]); 247 seq_printf(s, "Guest 0x%x\n", features[1]);
248 248
@@ -256,7 +256,7 @@ static int mic_dp_show(struct seq_file *s, void *pos)
256 seq_printf(s, "Guest Ack %d ", dc->guest_ack); 256 seq_printf(s, "Guest Ack %d ", dc->guest_ack);
257 seq_printf(s, "Host ack %d\n", dc->host_ack); 257 seq_printf(s, "Host ack %d\n", dc->host_ack);
258 seq_printf(s, "Used address updated %d ", 258 seq_printf(s, "Used address updated %d ",
259 dc->used_address_updated); 259 dc->used_address_updated);
260 seq_printf(s, "Vdev 0x%llx\n", dc->vdev); 260 seq_printf(s, "Vdev 0x%llx\n", dc->vdev);
261 seq_printf(s, "c2h doorbell %d ", dc->c2h_vdev_db); 261 seq_printf(s, "c2h doorbell %d ", dc->c2h_vdev_db);
262 seq_printf(s, "h2c doorbell %d\n", dc->h2c_vdev_db); 262 seq_printf(s, "h2c doorbell %d\n", dc->h2c_vdev_db);
@@ -294,10 +294,10 @@ static int mic_vdev_info_show(struct seq_file *s, void *unused)
294 list_for_each_safe(pos, tmp, &mdev->vdev_list) { 294 list_for_each_safe(pos, tmp, &mdev->vdev_list) {
295 mvdev = list_entry(pos, struct mic_vdev, list); 295 mvdev = list_entry(pos, struct mic_vdev, list);
296 seq_printf(s, "VDEV type %d state %s in %ld out %ld\n", 296 seq_printf(s, "VDEV type %d state %s in %ld out %ld\n",
297 mvdev->virtio_id, 297 mvdev->virtio_id,
298 mic_vdevup(mvdev) ? "UP" : "DOWN", 298 mic_vdevup(mvdev) ? "UP" : "DOWN",
299 mvdev->in_bytes, 299 mvdev->in_bytes,
300 mvdev->out_bytes); 300 mvdev->out_bytes);
301 for (i = 0; i < MIC_MAX_VRINGS; i++) { 301 for (i = 0; i < MIC_MAX_VRINGS; i++) {
302 struct vring_desc *desc; 302 struct vring_desc *desc;
303 struct vring_avail *avail; 303 struct vring_avail *avail;
@@ -309,38 +309,38 @@ static int mic_vdev_info_show(struct seq_file *s, void *unused)
309 continue; 309 continue;
310 desc = vrh->vring.desc; 310 desc = vrh->vring.desc;
311 seq_printf(s, "vring i %d avail_idx %d", 311 seq_printf(s, "vring i %d avail_idx %d",
312 i, mvr->vring.info->avail_idx & (num - 1)); 312 i, mvr->vring.info->avail_idx & (num - 1));
313 seq_printf(s, " vring i %d avail_idx %d\n", 313 seq_printf(s, " vring i %d avail_idx %d\n",
314 i, mvr->vring.info->avail_idx); 314 i, mvr->vring.info->avail_idx);
315 seq_printf(s, "vrh i %d weak_barriers %d", 315 seq_printf(s, "vrh i %d weak_barriers %d",
316 i, vrh->weak_barriers); 316 i, vrh->weak_barriers);
317 seq_printf(s, " last_avail_idx %d last_used_idx %d", 317 seq_printf(s, " last_avail_idx %d last_used_idx %d",
318 vrh->last_avail_idx, vrh->last_used_idx); 318 vrh->last_avail_idx, vrh->last_used_idx);
319 seq_printf(s, " completed %d\n", vrh->completed); 319 seq_printf(s, " completed %d\n", vrh->completed);
320 for (j = 0; j < num; j++) { 320 for (j = 0; j < num; j++) {
321 seq_printf(s, "desc[%d] addr 0x%llx len %d", 321 seq_printf(s, "desc[%d] addr 0x%llx len %d",
322 j, desc->addr, desc->len); 322 j, desc->addr, desc->len);
323 seq_printf(s, " flags 0x%x next %d\n", 323 seq_printf(s, " flags 0x%x next %d\n",
324 desc->flags, 324 desc->flags, desc->next);
325 desc->next);
326 desc++; 325 desc++;
327 } 326 }
328 avail = vrh->vring.avail; 327 avail = vrh->vring.avail;
329 seq_printf(s, "avail flags 0x%x idx %d\n", 328 seq_printf(s, "avail flags 0x%x idx %d\n",
330 avail->flags, avail->idx & (num - 1)); 329 avail->flags, avail->idx & (num - 1));
331 seq_printf(s, "avail flags 0x%x idx %d\n", 330 seq_printf(s, "avail flags 0x%x idx %d\n",
332 avail->flags, avail->idx); 331 avail->flags, avail->idx);
333 for (j = 0; j < num; j++) 332 for (j = 0; j < num; j++)
334 seq_printf(s, "avail ring[%d] %d\n", 333 seq_printf(s, "avail ring[%d] %d\n",
335 j, avail->ring[j]); 334 j, avail->ring[j]);
336 used = vrh->vring.used; 335 used = vrh->vring.used;
337 seq_printf(s, "used flags 0x%x idx %d\n", 336 seq_printf(s, "used flags 0x%x idx %d\n",
338 used->flags, used->idx & (num - 1)); 337 used->flags, used->idx & (num - 1));
339 seq_printf(s, "used flags 0x%x idx %d\n", 338 seq_printf(s, "used flags 0x%x idx %d\n",
340 used->flags, used->idx); 339 used->flags, used->idx);
341 for (j = 0; j < num; j++) 340 for (j = 0; j < num; j++)
342 seq_printf(s, "used ring[%d] id %d len %d\n", 341 seq_printf(s, "used ring[%d] id %d len %d\n",
343 j, used->ring[j].id, used->ring[j].len); 342 j, used->ring[j].id,
343 used->ring[j].len);
344 } 344 }
345 } 345 }
346 mutex_unlock(&mdev->mic_mutex); 346 mutex_unlock(&mdev->mic_mutex);
@@ -389,7 +389,7 @@ static int mic_msi_irq_info_show(struct seq_file *s, void *pos)
389 reg = mdev->intr_ops->read_msi_to_src_map(mdev, entry); 389 reg = mdev->intr_ops->read_msi_to_src_map(mdev, entry);
390 390
391 seq_printf(s, "%s %-10d %s %-10d MXAR[%d]: %08X\n", 391 seq_printf(s, "%s %-10d %s %-10d MXAR[%d]: %08X\n",
392 "IRQ:", vector, "Entry:", entry, i, reg); 392 "IRQ:", vector, "Entry:", entry, i, reg);
393 393
394 seq_printf(s, "%-10s", "offset:"); 394 seq_printf(s, "%-10s", "offset:");
395 for (j = (MIC_NUM_OFFSETS - 1); j >= 0; j--) 395 for (j = (MIC_NUM_OFFSETS - 1); j >= 0; j--)
@@ -400,8 +400,8 @@ static int mic_msi_irq_info_show(struct seq_file *s, void *pos)
400 seq_printf(s, "%-10s", "count:"); 400 seq_printf(s, "%-10s", "count:");
401 for (j = (MIC_NUM_OFFSETS - 1); j >= 0; j--) 401 for (j = (MIC_NUM_OFFSETS - 1); j >= 0; j--)
402 seq_printf(s, "%4d ", 402 seq_printf(s, "%4d ",
403 (mdev->irq_info.mic_msi_map[i] & BIT(j)) ? 403 (mdev->irq_info.mic_msi_map[i] &
404 1 : 0); 404 BIT(j)) ? 1 : 0);
405 seq_puts(s, "\n\n"); 405 seq_puts(s, "\n\n");
406 } 406 }
407 } else { 407 } else {
@@ -409,7 +409,6 @@ static int mic_msi_irq_info_show(struct seq_file *s, void *pos)
409 } 409 }
410 410
411 return 0; 411 return 0;
412
413} 412}
414 413
415static int mic_msi_irq_info_debug_open(struct inode *inode, struct file *file) 414static int mic_msi_irq_info_debug_open(struct inode *inode, struct file *file)
@@ -443,26 +442,23 @@ void mic_create_debug_dir(struct mic_device *mdev)
443 if (!mdev->dbg_dir) 442 if (!mdev->dbg_dir)
444 return; 443 return;
445 444
446 debugfs_create_file("log_buf", 0444, mdev->dbg_dir, 445 debugfs_create_file("log_buf", 0444, mdev->dbg_dir, mdev, &log_buf_ops);
447 mdev, &log_buf_ops);
448 446
449 debugfs_create_file("smpt", 0444, mdev->dbg_dir, 447 debugfs_create_file("smpt", 0444, mdev->dbg_dir, mdev, &smpt_file_ops);
450 mdev, &smpt_file_ops);
451 448
452 debugfs_create_file("soft_reset", 0444, mdev->dbg_dir, 449 debugfs_create_file("soft_reset", 0444, mdev->dbg_dir, mdev,
453 mdev, &soft_reset_ops); 450 &soft_reset_ops);
454 451
455 debugfs_create_file("post_code", 0444, mdev->dbg_dir, 452 debugfs_create_file("post_code", 0444, mdev->dbg_dir, mdev,
456 mdev, &post_code_ops); 453 &post_code_ops);
457 454
458 debugfs_create_file("dp", 0444, mdev->dbg_dir, 455 debugfs_create_file("dp", 0444, mdev->dbg_dir, mdev, &dp_ops);
459 mdev, &dp_ops);
460 456
461 debugfs_create_file("vdev_info", 0444, mdev->dbg_dir, 457 debugfs_create_file("vdev_info", 0444, mdev->dbg_dir, mdev,
462 mdev, &vdev_info_ops); 458 &vdev_info_ops);
463 459
464 debugfs_create_file("msi_irq_info", 0444, mdev->dbg_dir, 460 debugfs_create_file("msi_irq_info", 0444, mdev->dbg_dir, mdev,
465 mdev, &msi_irq_info_ops); 461 &msi_irq_info_ops);
466} 462}
467 463
468/** 464/**
diff --git a/drivers/misc/mic/host/mic_fops.c b/drivers/misc/mic/host/mic_fops.c
index e699c80a8c0a..8dc6ff16845a 100644
--- a/drivers/misc/mic/host/mic_fops.c
+++ b/drivers/misc/mic/host/mic_fops.c
@@ -140,9 +140,9 @@ unsigned int mic_poll(struct file *f, poll_table *wait)
140 140
141 poll_wait(f, &mvdev->waitq, wait); 141 poll_wait(f, &mvdev->waitq, wait);
142 142
143 if (mic_vdev_inited(mvdev)) 143 if (mic_vdev_inited(mvdev)) {
144 mask = POLLERR; 144 mask = POLLERR;
145 else if (mvdev->poll_wake) { 145 } else if (mvdev->poll_wake) {
146 mvdev->poll_wake = 0; 146 mvdev->poll_wake = 0;
147 mask = POLLIN | POLLOUT; 147 mask = POLLIN | POLLOUT;
148 } 148 }
@@ -152,7 +152,7 @@ unsigned int mic_poll(struct file *f, poll_table *wait)
152 152
153static inline int 153static inline int
154mic_query_offset(struct mic_vdev *mvdev, unsigned long offset, 154mic_query_offset(struct mic_vdev *mvdev, unsigned long offset,
155 unsigned long *size, unsigned long *pa) 155 unsigned long *size, unsigned long *pa)
156{ 156{
157 struct mic_device *mdev = mvdev->mdev; 157 struct mic_device *mdev = mvdev->mdev;
158 unsigned long start = MIC_DP_SIZE; 158 unsigned long start = MIC_DP_SIZE;
diff --git a/drivers/misc/mic/host/mic_intr.c b/drivers/misc/mic/host/mic_intr.c
index 71a7521cf1a4..f9c29bc918bc 100644
--- a/drivers/misc/mic/host/mic_intr.c
+++ b/drivers/misc/mic/host/mic_intr.c
@@ -71,8 +71,8 @@ static irqreturn_t mic_interrupt(int irq, void *dev)
71 71
72/* Return the interrupt offset from the index. Index is 0 based. */ 72/* Return the interrupt offset from the index. Index is 0 based. */
73static u16 mic_map_src_to_offset(struct mic_device *mdev, 73static u16 mic_map_src_to_offset(struct mic_device *mdev,
74 int intr_src, enum mic_intr_type type) { 74 int intr_src, enum mic_intr_type type)
75 75{
76 if (type >= MIC_NUM_INTR_TYPES) 76 if (type >= MIC_NUM_INTR_TYPES)
77 return MIC_NUM_OFFSETS; 77 return MIC_NUM_OFFSETS;
78 if (intr_src >= mdev->intr_info->intr_len[type]) 78 if (intr_src >= mdev->intr_info->intr_len[type])
@@ -112,7 +112,7 @@ static struct mic_intr_cb *mic_register_intr_callback(struct mic_device *mdev,
112 struct mic_intr_cb *intr_cb; 112 struct mic_intr_cb *intr_cb;
113 unsigned long flags; 113 unsigned long flags;
114 int rc; 114 int rc;
115 intr_cb = kmalloc(sizeof(struct mic_intr_cb), GFP_KERNEL); 115 intr_cb = kmalloc(sizeof(*intr_cb), GFP_KERNEL);
116 116
117 if (!intr_cb) 117 if (!intr_cb)
118 return ERR_PTR(-ENOMEM); 118 return ERR_PTR(-ENOMEM);
@@ -159,7 +159,7 @@ static u8 mic_unregister_intr_callback(struct mic_device *mdev, u32 idx)
159 if (intr_cb->cb_id == idx) { 159 if (intr_cb->cb_id == idx) {
160 list_del(pos); 160 list_del(pos);
161 ida_simple_remove(&mdev->irq_info.cb_ida, 161 ida_simple_remove(&mdev->irq_info.cb_ida,
162 intr_cb->cb_id); 162 intr_cb->cb_id);
163 kfree(intr_cb); 163 kfree(intr_cb);
164 spin_unlock_irqrestore( 164 spin_unlock_irqrestore(
165 &mdev->irq_info.mic_intr_lock, flags); 165 &mdev->irq_info.mic_intr_lock, flags);
@@ -182,9 +182,10 @@ static u8 mic_unregister_intr_callback(struct mic_device *mdev, u32 idx)
182static int mic_setup_msix(struct mic_device *mdev, struct pci_dev *pdev) 182static int mic_setup_msix(struct mic_device *mdev, struct pci_dev *pdev)
183{ 183{
184 int rc, i; 184 int rc, i;
185 int entry_size = sizeof(*mdev->irq_info.msix_entries);
185 186
186 mdev->irq_info.msix_entries = kmalloc(sizeof(struct msix_entry) * 187 mdev->irq_info.msix_entries = kmalloc_array(MIC_MIN_MSIX,
187 MIC_MIN_MSIX, GFP_KERNEL); 188 entry_size, GFP_KERNEL);
188 if (!mdev->irq_info.msix_entries) { 189 if (!mdev->irq_info.msix_entries) {
189 rc = -ENOMEM; 190 rc = -ENOMEM;
190 goto err_nomem1; 191 goto err_nomem1;
@@ -231,8 +232,9 @@ static int mic_setup_callbacks(struct mic_device *mdev)
231{ 232{
232 int i; 233 int i;
233 234
234 mdev->irq_info.cb_list = kmalloc(sizeof(struct list_head) * 235 mdev->irq_info.cb_list = kmalloc_array(MIC_NUM_OFFSETS,
235 MIC_NUM_OFFSETS, GFP_KERNEL); 236 sizeof(*mdev->irq_info.cb_list),
237 GFP_KERNEL);
236 if (!mdev->irq_info.cb_list) 238 if (!mdev->irq_info.cb_list)
237 return -ENOMEM; 239 return -ENOMEM;
238 240
@@ -261,7 +263,7 @@ static void mic_release_callbacks(struct mic_device *mdev)
261 263
262 if (list_empty(&mdev->irq_info.cb_list[i])) { 264 if (list_empty(&mdev->irq_info.cb_list[i])) {
263 spin_unlock_irqrestore(&mdev->irq_info.mic_intr_lock, 265 spin_unlock_irqrestore(&mdev->irq_info.mic_intr_lock,
264 flags); 266 flags);
265 break; 267 break;
266 } 268 }
267 269
@@ -269,7 +271,7 @@ static void mic_release_callbacks(struct mic_device *mdev)
269 intr_cb = list_entry(pos, struct mic_intr_cb, list); 271 intr_cb = list_entry(pos, struct mic_intr_cb, list);
270 list_del(pos); 272 list_del(pos);
271 ida_simple_remove(&mdev->irq_info.cb_ida, 273 ida_simple_remove(&mdev->irq_info.cb_ida,
272 intr_cb->cb_id); 274 intr_cb->cb_id);
273 kfree(intr_cb); 275 kfree(intr_cb);
274 } 276 }
275 spin_unlock_irqrestore(&mdev->irq_info.mic_intr_lock, flags); 277 spin_unlock_irqrestore(&mdev->irq_info.mic_intr_lock, flags);
@@ -427,8 +429,8 @@ struct mic_irq *mic_request_irq(struct mic_device *mdev,
427 offset = mic_map_src_to_offset(mdev, intr_src, type); 429 offset = mic_map_src_to_offset(mdev, intr_src, type);
428 if (offset >= MIC_NUM_OFFSETS) { 430 if (offset >= MIC_NUM_OFFSETS) {
429 dev_err(mdev->sdev->parent, 431 dev_err(mdev->sdev->parent,
430 "Error mapping index %d to a valid source id.\n", 432 "Error mapping index %d to a valid source id.\n",
431 intr_src); 433 intr_src);
432 rc = -EINVAL; 434 rc = -EINVAL;
433 goto err; 435 goto err;
434 } 436 }
@@ -437,7 +439,7 @@ struct mic_irq *mic_request_irq(struct mic_device *mdev,
437 msix = mic_get_available_vector(mdev); 439 msix = mic_get_available_vector(mdev);
438 if (!msix) { 440 if (!msix) {
439 dev_err(mdev->sdev->parent, 441 dev_err(mdev->sdev->parent,
440 "No MSIx vectors available for use.\n"); 442 "No MSIx vectors available for use.\n");
441 rc = -ENOSPC; 443 rc = -ENOSPC;
442 goto err; 444 goto err;
443 } 445 }
@@ -460,7 +462,7 @@ struct mic_irq *mic_request_irq(struct mic_device *mdev,
460 offset, func, data); 462 offset, func, data);
461 if (IS_ERR(intr_cb)) { 463 if (IS_ERR(intr_cb)) {
462 dev_err(mdev->sdev->parent, 464 dev_err(mdev->sdev->parent,
463 "No available callback entries for use\n"); 465 "No available callback entries for use\n");
464 rc = PTR_ERR(intr_cb); 466 rc = PTR_ERR(intr_cb);
465 goto err; 467 goto err;
466 } 468 }
@@ -506,7 +508,7 @@ void mic_free_irq(struct mic_device *mdev,
506 if (mdev->irq_info.num_vectors > 1) { 508 if (mdev->irq_info.num_vectors > 1) {
507 if (entry >= mdev->irq_info.num_vectors) { 509 if (entry >= mdev->irq_info.num_vectors) {
508 dev_warn(mdev->sdev->parent, 510 dev_warn(mdev->sdev->parent,
509 "entry %d should be < num_irq %d\n", 511 "entry %d should be < num_irq %d\n",
510 entry, mdev->irq_info.num_vectors); 512 entry, mdev->irq_info.num_vectors);
511 return; 513 return;
512 } 514 }
@@ -581,7 +583,7 @@ void mic_free_interrupts(struct mic_device *mdev, struct pci_dev *pdev)
581 for (i = 0; i < mdev->irq_info.num_vectors; i++) { 583 for (i = 0; i < mdev->irq_info.num_vectors; i++) {
582 if (mdev->irq_info.mic_msi_map[i]) 584 if (mdev->irq_info.mic_msi_map[i])
583 dev_warn(&pdev->dev, "irq %d may still be in use.\n", 585 dev_warn(&pdev->dev, "irq %d may still be in use.\n",
584 mdev->irq_info.msix_entries[i].vector); 586 mdev->irq_info.msix_entries[i].vector);
585 } 587 }
586 kfree(mdev->irq_info.mic_msi_map); 588 kfree(mdev->irq_info.mic_msi_map);
587 kfree(mdev->irq_info.msix_entries); 589 kfree(mdev->irq_info.msix_entries);
diff --git a/drivers/misc/mic/host/mic_smpt.c b/drivers/misc/mic/host/mic_smpt.c
index 003d02b212be..fae474c4899e 100644
--- a/drivers/misc/mic/host/mic_smpt.c
+++ b/drivers/misc/mic/host/mic_smpt.c
@@ -84,7 +84,7 @@ static void mic_add_smpt_entry(int spt, s64 *ref, u64 addr,
84 for (i = spt; i < spt + entries; i++, 84 for (i = spt; i < spt + entries; i++,
85 addr += smpt_info->info.page_size) { 85 addr += smpt_info->info.page_size) {
86 if (!smpt_info->entry[i].ref_count && 86 if (!smpt_info->entry[i].ref_count &&
87 (smpt_info->entry[i].dma_addr != addr)) { 87 (smpt_info->entry[i].dma_addr != addr)) {
88 mdev->smpt_ops->set(mdev, addr, i); 88 mdev->smpt_ops->set(mdev, addr, i);
89 smpt_info->entry[i].dma_addr = addr; 89 smpt_info->entry[i].dma_addr = addr;
90 } 90 }
@@ -183,7 +183,7 @@ mic_to_dma_addr(struct mic_device *mdev, dma_addr_t mic_addr)
183 183
184 if (!mic_is_system_addr(mdev, mic_addr)) { 184 if (!mic_is_system_addr(mdev, mic_addr)) {
185 dev_err(mdev->sdev->parent, 185 dev_err(mdev->sdev->parent,
186 "mic_addr is invalid. mic_addr = 0x%llx\n", mic_addr); 186 "mic_addr is invalid. mic_addr = 0x%llx\n", mic_addr);
187 return -EINVAL; 187 return -EINVAL;
188 } 188 }
189 spt = mic_sys_addr_to_smpt(mdev, mic_addr); 189 spt = mic_sys_addr_to_smpt(mdev, mic_addr);
@@ -286,7 +286,7 @@ void mic_unmap(struct mic_device *mdev, dma_addr_t mic_addr, size_t size)
286 smpt_info->entry[i].ref_count -= ref[i - spt]; 286 smpt_info->entry[i].ref_count -= ref[i - spt];
287 if (smpt_info->entry[i].ref_count < 0) 287 if (smpt_info->entry[i].ref_count < 0)
288 dev_warn(mdev->sdev->parent, 288 dev_warn(mdev->sdev->parent,
289 "ref count for entry %d is negative\n", i); 289 "ref count for entry %d is negative\n", i);
290 } 290 }
291 spin_unlock_irqrestore(&smpt_info->smpt_lock, flags); 291 spin_unlock_irqrestore(&smpt_info->smpt_lock, flags);
292 kfree(ref); 292 kfree(ref);
@@ -320,7 +320,7 @@ dma_addr_t mic_map_single(struct mic_device *mdev, void *va, size_t size)
320 "mic_map failed dma_addr 0x%llx size 0x%lx\n", 320 "mic_map failed dma_addr 0x%llx size 0x%lx\n",
321 dma_addr, size); 321 dma_addr, size);
322 pci_unmap_single(pdev, dma_addr, 322 pci_unmap_single(pdev, dma_addr,
323 size, PCI_DMA_BIDIRECTIONAL); 323 size, PCI_DMA_BIDIRECTIONAL);
324 } 324 }
325 } 325 }
326 return mic_addr; 326 return mic_addr;
@@ -366,8 +366,8 @@ int mic_smpt_init(struct mic_device *mdev)
366 366
367 smpt_info = mdev->smpt; 367 smpt_info = mdev->smpt;
368 mdev->smpt_ops->init(mdev); 368 mdev->smpt_ops->init(mdev);
369 smpt_info->entry = kmalloc(sizeof(struct mic_smpt) 369 smpt_info->entry = kmalloc_array(smpt_info->info.num_reg,
370 * smpt_info->info.num_reg, GFP_KERNEL); 370 sizeof(*smpt_info->entry), GFP_KERNEL);
371 if (!smpt_info->entry) { 371 if (!smpt_info->entry) {
372 err = -ENOMEM; 372 err = -ENOMEM;
373 goto free_smpt; 373 goto free_smpt;
@@ -412,7 +412,7 @@ void mic_smpt_uninit(struct mic_device *mdev)
412 smpt_info->entry[i].ref_count); 412 smpt_info->entry[i].ref_count);
413 if (smpt_info->entry[i].ref_count) 413 if (smpt_info->entry[i].ref_count)
414 dev_warn(mdev->sdev->parent, 414 dev_warn(mdev->sdev->parent,
415 "ref count for entry %d is not zero\n", i); 415 "ref count for entry %d is not zero\n", i);
416 } 416 }
417 kfree(smpt_info->entry); 417 kfree(smpt_info->entry);
418 kfree(smpt_info); 418 kfree(smpt_info);
diff --git a/drivers/misc/mic/host/mic_sysfs.c b/drivers/misc/mic/host/mic_sysfs.c
index 029a4f31bee7..75746adfb155 100644
--- a/drivers/misc/mic/host/mic_sysfs.c
+++ b/drivers/misc/mic/host/mic_sysfs.c
@@ -130,7 +130,7 @@ state_show(struct device *dev, struct device_attribute *attr, char *buf)
130 130
131static ssize_t 131static ssize_t
132state_store(struct device *dev, struct device_attribute *attr, 132state_store(struct device *dev, struct device_attribute *attr,
133 const char *buf, size_t count) 133 const char *buf, size_t count)
134{ 134{
135 int rc = 0; 135 int rc = 0;
136 struct mic_device *mdev = dev_get_drvdata(dev->parent); 136 struct mic_device *mdev = dev_get_drvdata(dev->parent);
@@ -163,7 +163,7 @@ done:
163static DEVICE_ATTR_RW(state); 163static DEVICE_ATTR_RW(state);
164 164
165static ssize_t shutdown_status_show(struct device *dev, 165static ssize_t shutdown_status_show(struct device *dev,
166 struct device_attribute *attr, char *buf) 166 struct device_attribute *attr, char *buf)
167{ 167{
168 struct mic_device *mdev = dev_get_drvdata(dev->parent); 168 struct mic_device *mdev = dev_get_drvdata(dev->parent);
169 169
@@ -193,7 +193,7 @@ cmdline_show(struct device *dev, struct device_attribute *attr, char *buf)
193 193
194static ssize_t 194static ssize_t
195cmdline_store(struct device *dev, struct device_attribute *attr, 195cmdline_store(struct device *dev, struct device_attribute *attr,
196 const char *buf, size_t count) 196 const char *buf, size_t count)
197{ 197{
198 struct mic_device *mdev = dev_get_drvdata(dev->parent); 198 struct mic_device *mdev = dev_get_drvdata(dev->parent);
199 199
@@ -239,7 +239,7 @@ firmware_show(struct device *dev, struct device_attribute *attr, char *buf)
239 239
240static ssize_t 240static ssize_t
241firmware_store(struct device *dev, struct device_attribute *attr, 241firmware_store(struct device *dev, struct device_attribute *attr,
242 const char *buf, size_t count) 242 const char *buf, size_t count)
243{ 243{
244 struct mic_device *mdev = dev_get_drvdata(dev->parent); 244 struct mic_device *mdev = dev_get_drvdata(dev->parent);
245 245
@@ -284,7 +284,7 @@ ramdisk_show(struct device *dev, struct device_attribute *attr, char *buf)
284 284
285static ssize_t 285static ssize_t
286ramdisk_store(struct device *dev, struct device_attribute *attr, 286ramdisk_store(struct device *dev, struct device_attribute *attr,
287 const char *buf, size_t count) 287 const char *buf, size_t count)
288{ 288{
289 struct mic_device *mdev = dev_get_drvdata(dev->parent); 289 struct mic_device *mdev = dev_get_drvdata(dev->parent);
290 290
@@ -330,7 +330,7 @@ bootmode_show(struct device *dev, struct device_attribute *attr, char *buf)
330 330
331static ssize_t 331static ssize_t
332bootmode_store(struct device *dev, struct device_attribute *attr, 332bootmode_store(struct device *dev, struct device_attribute *attr,
333 const char *buf, size_t count) 333 const char *buf, size_t count)
334{ 334{
335 struct mic_device *mdev = dev_get_drvdata(dev->parent); 335 struct mic_device *mdev = dev_get_drvdata(dev->parent);
336 336
@@ -363,7 +363,7 @@ static DEVICE_ATTR_RW(bootmode);
363 363
364static ssize_t 364static ssize_t
365log_buf_addr_show(struct device *dev, struct device_attribute *attr, 365log_buf_addr_show(struct device *dev, struct device_attribute *attr,
366 char *buf) 366 char *buf)
367{ 367{
368 struct mic_device *mdev = dev_get_drvdata(dev->parent); 368 struct mic_device *mdev = dev_get_drvdata(dev->parent);
369 369
@@ -375,7 +375,7 @@ log_buf_addr_show(struct device *dev, struct device_attribute *attr,
375 375
376static ssize_t 376static ssize_t
377log_buf_addr_store(struct device *dev, struct device_attribute *attr, 377log_buf_addr_store(struct device *dev, struct device_attribute *attr,
378 const char *buf, size_t count) 378 const char *buf, size_t count)
379{ 379{
380 struct mic_device *mdev = dev_get_drvdata(dev->parent); 380 struct mic_device *mdev = dev_get_drvdata(dev->parent);
381 int ret; 381 int ret;
@@ -397,7 +397,7 @@ static DEVICE_ATTR_RW(log_buf_addr);
397 397
398static ssize_t 398static ssize_t
399log_buf_len_show(struct device *dev, struct device_attribute *attr, 399log_buf_len_show(struct device *dev, struct device_attribute *attr,
400 char *buf) 400 char *buf)
401{ 401{
402 struct mic_device *mdev = dev_get_drvdata(dev->parent); 402 struct mic_device *mdev = dev_get_drvdata(dev->parent);
403 403
@@ -409,7 +409,7 @@ log_buf_len_show(struct device *dev, struct device_attribute *attr,
409 409
410static ssize_t 410static ssize_t
411log_buf_len_store(struct device *dev, struct device_attribute *attr, 411log_buf_len_store(struct device *dev, struct device_attribute *attr,
412 const char *buf, size_t count) 412 const char *buf, size_t count)
413{ 413{
414 struct mic_device *mdev = dev_get_drvdata(dev->parent); 414 struct mic_device *mdev = dev_get_drvdata(dev->parent);
415 int ret; 415 int ret;
diff --git a/drivers/misc/mic/host/mic_virtio.c b/drivers/misc/mic/host/mic_virtio.c
index 9e0456fb1ea8..0c883cd4f1d1 100644
--- a/drivers/misc/mic/host/mic_virtio.c
+++ b/drivers/misc/mic/host/mic_virtio.c
@@ -195,7 +195,7 @@ static int _mic_virtio_copy(struct mic_vdev *mvdev,
195 MIC_VRINGH_READ, &out_len); 195 MIC_VRINGH_READ, &out_len);
196 if (ret) { 196 if (ret) {
197 dev_err(mic_dev(mvdev), "%s %d err %d\n", 197 dev_err(mic_dev(mvdev), "%s %d err %d\n",
198 __func__, __LINE__, ret); 198 __func__, __LINE__, ret);
199 break; 199 break;
200 } 200 }
201 len -= out_len; 201 len -= out_len;
@@ -206,7 +206,7 @@ static int _mic_virtio_copy(struct mic_vdev *mvdev,
206 !MIC_VRINGH_READ, &out_len); 206 !MIC_VRINGH_READ, &out_len);
207 if (ret) { 207 if (ret) {
208 dev_err(mic_dev(mvdev), "%s %d err %d\n", 208 dev_err(mic_dev(mvdev), "%s %d err %d\n",
209 __func__, __LINE__, ret); 209 __func__, __LINE__, ret);
210 break; 210 break;
211 } 211 }
212 len -= out_len; 212 len -= out_len;
@@ -225,8 +225,7 @@ static int _mic_virtio_copy(struct mic_vdev *mvdev,
225 * Update the used ring if a descriptor was available and some data was 225 * Update the used ring if a descriptor was available and some data was
226 * copied in/out and the user asked for a used ring update. 226 * copied in/out and the user asked for a used ring update.
227 */ 227 */
228 if (*head != USHRT_MAX && copy->out_len && 228 if (*head != USHRT_MAX && copy->out_len && copy->update_used) {
229 copy->update_used) {
230 u32 total = 0; 229 u32 total = 0;
231 230
232 /* Determine the total data consumed */ 231 /* Determine the total data consumed */
@@ -367,7 +366,6 @@ void mic_bh_handler(struct work_struct *work)
367 366
368static irqreturn_t mic_virtio_intr_handler(int irq, void *data) 367static irqreturn_t mic_virtio_intr_handler(int irq, void *data)
369{ 368{
370
371 struct mic_vdev *mvdev = data; 369 struct mic_vdev *mvdev = data;
372 struct mic_device *mdev = mvdev->mdev; 370 struct mic_device *mdev = mvdev->mdev;
373 371
@@ -394,7 +392,7 @@ int mic_virtio_config_change(struct mic_vdev *mvdev,
394 } 392 }
395 393
396 if (copy_from_user(mic_vq_configspace(mvdev->dd), 394 if (copy_from_user(mic_vq_configspace(mvdev->dd),
397 argp, mvdev->dd->config_len)) { 395 argp, mvdev->dd->config_len)) {
398 dev_err(mic_dev(mvdev), "%s %d err %d\n", 396 dev_err(mic_dev(mvdev), "%s %d err %d\n",
399 __func__, __LINE__, -EFAULT); 397 __func__, __LINE__, -EFAULT);
400 ret = -EFAULT; 398 ret = -EFAULT;
@@ -438,8 +436,8 @@ static int mic_copy_dp_entry(struct mic_vdev *mvdev,
438 return -EFAULT; 436 return -EFAULT;
439 } 437 }
440 438
441 if (mic_aligned_desc_size(&dd) > MIC_MAX_DESC_BLK_SIZE 439 if (mic_aligned_desc_size(&dd) > MIC_MAX_DESC_BLK_SIZE ||
442 || dd.num_vq > MIC_MAX_VRINGS) { 440 dd.num_vq > MIC_MAX_VRINGS) {
443 dev_err(mic_dev(mvdev), "%s %d err %d\n", 441 dev_err(mic_dev(mvdev), "%s %d err %d\n",
444 __func__, __LINE__, -EINVAL); 442 __func__, __LINE__, -EINVAL);
445 return -EINVAL; 443 return -EINVAL;
@@ -503,7 +501,7 @@ static void mic_init_device_ctrl(struct mic_vdev *mvdev,
503{ 501{
504 struct mic_device_ctrl *dc; 502 struct mic_device_ctrl *dc;
505 503
506 dc = mvdev->dc = (void *)devpage + mic_aligned_desc_size(devpage); 504 dc = (void *)devpage + mic_aligned_desc_size(devpage);
507 505
508 dc->config_change = 0; 506 dc->config_change = 0;
509 dc->guest_ack = 0; 507 dc->guest_ack = 0;
@@ -512,6 +510,7 @@ static void mic_init_device_ctrl(struct mic_vdev *mvdev,
512 dc->used_address_updated = 0; 510 dc->used_address_updated = 0;
513 dc->c2h_vdev_db = -1; 511 dc->c2h_vdev_db = -1;
514 dc->h2c_vdev_db = -1; 512 dc->h2c_vdev_db = -1;
513 mvdev->dc = dc;
515} 514}
516 515
517int mic_virtio_add_device(struct mic_vdev *mvdev, 516int mic_virtio_add_device(struct mic_vdev *mvdev,
@@ -551,7 +550,7 @@ int mic_virtio_add_device(struct mic_vdev *mvdev,
551 sizeof(struct _mic_vring_info)); 550 sizeof(struct _mic_vring_info));
552 vr->va = (void *) 551 vr->va = (void *)
553 __get_free_pages(GFP_KERNEL | __GFP_ZERO, 552 __get_free_pages(GFP_KERNEL | __GFP_ZERO,
554 get_order(vr_size)); 553 get_order(vr_size));
555 if (!vr->va) { 554 if (!vr->va) {
556 ret = -ENOMEM; 555 ret = -ENOMEM;
557 dev_err(mic_dev(mvdev), "%s %d err %d\n", 556 dev_err(mic_dev(mvdev), "%s %d err %d\n",
@@ -564,8 +563,7 @@ int mic_virtio_add_device(struct mic_vdev *mvdev,
564 vqconfig[i].address = mic_map_single(mdev, 563 vqconfig[i].address = mic_map_single(mdev,
565 vr->va, vr_size); 564 vr->va, vr_size);
566 if (mic_map_error(vqconfig[i].address)) { 565 if (mic_map_error(vqconfig[i].address)) {
567 free_pages((unsigned long)vr->va, 566 free_pages((unsigned long)vr->va, get_order(vr_size));
568 get_order(vr_size));
569 ret = -ENOMEM; 567 ret = -ENOMEM;
570 dev_err(mic_dev(mvdev), "%s %d err %d\n", 568 dev_err(mic_dev(mvdev), "%s %d err %d\n",
571 __func__, __LINE__, ret); 569 __func__, __LINE__, ret);
@@ -573,8 +571,7 @@ int mic_virtio_add_device(struct mic_vdev *mvdev,
573 } 571 }
574 vqconfig[i].address = cpu_to_le64(vqconfig[i].address); 572 vqconfig[i].address = cpu_to_le64(vqconfig[i].address);
575 573
576 vring_init(&vr->vr, num, 574 vring_init(&vr->vr, num, vr->va, MIC_VIRTIO_RING_ALIGN);
577 vr->va, MIC_VIRTIO_RING_ALIGN);
578 ret = vringh_init_kern(&mvr->vrh, 575 ret = vringh_init_kern(&mvr->vrh,
579 *(u32 *)mic_vq_features(mvdev->dd), num, false, 576 *(u32 *)mic_vq_features(mvdev->dd), num, false,
580 vr->vr.desc, vr->vr.avail, vr->vr.used); 577 vr->vr.desc, vr->vr.avail, vr->vr.used);
@@ -593,8 +590,8 @@ int mic_virtio_add_device(struct mic_vdev *mvdev,
593 __func__, __LINE__, i, vr->va, vr->info, vr_size); 590 __func__, __LINE__, i, vr->va, vr->info, vr_size);
594 } 591 }
595 592
596 snprintf(irqname, sizeof(irqname), 593 snprintf(irqname, sizeof(irqname), "mic%dvirtio%d", mdev->id,
597 "mic%dvirtio%d", mdev->id, mvdev->virtio_id); 594 mvdev->virtio_id);
598 mvdev->virtio_db = mic_next_db(mdev); 595 mvdev->virtio_db = mic_next_db(mdev);
599 mvdev->virtio_cookie = mic_request_irq(mdev, mic_virtio_intr_handler, 596 mvdev->virtio_cookie = mic_request_irq(mdev, mic_virtio_intr_handler,
600 irqname, mvdev, mvdev->virtio_db, MIC_INTR_DB); 597 irqname, mvdev, mvdev->virtio_db, MIC_INTR_DB);
@@ -628,9 +625,9 @@ err:
628 for (j = 0; j < i; j++) { 625 for (j = 0; j < i; j++) {
629 struct mic_vringh *mvr = &mvdev->mvr[j]; 626 struct mic_vringh *mvr = &mvdev->mvr[j];
630 mic_unmap_single(mdev, le64_to_cpu(vqconfig[j].address), 627 mic_unmap_single(mdev, le64_to_cpu(vqconfig[j].address),
631 mvr->vring.len); 628 mvr->vring.len);
632 free_pages((unsigned long)mvr->vring.va, 629 free_pages((unsigned long)mvr->vring.va,
633 get_order(mvr->vring.len)); 630 get_order(mvr->vring.len));
634 } 631 }
635 mutex_unlock(&mdev->mic_mutex); 632 mutex_unlock(&mdev->mic_mutex);
636 return ret; 633 return ret;
@@ -676,9 +673,9 @@ skip_hot_remove:
676 vringh_kiov_cleanup(&mvr->riov); 673 vringh_kiov_cleanup(&mvr->riov);
677 vringh_kiov_cleanup(&mvr->wiov); 674 vringh_kiov_cleanup(&mvr->wiov);
678 mic_unmap_single(mdev, le64_to_cpu(vqconfig[i].address), 675 mic_unmap_single(mdev, le64_to_cpu(vqconfig[i].address),
679 mvr->vring.len); 676 mvr->vring.len);
680 free_pages((unsigned long)mvr->vring.va, 677 free_pages((unsigned long)mvr->vring.va,
681 get_order(mvr->vring.len)); 678 get_order(mvr->vring.len));
682 } 679 }
683 680
684 list_for_each_safe(pos, tmp, &mdev->vdev_list) { 681 list_for_each_safe(pos, tmp, &mdev->vdev_list) {
diff --git a/drivers/misc/mic/host/mic_x100.c b/drivers/misc/mic/host/mic_x100.c
index 3a0d660bad4a..81e9541b784c 100644
--- a/drivers/misc/mic/host/mic_x100.c
+++ b/drivers/misc/mic/host/mic_x100.c
@@ -46,8 +46,8 @@ mic_x100_write_spad(struct mic_device *mdev, unsigned int idx, u32 val)
46 dev_dbg(mdev->sdev->parent, "Writing 0x%x to scratch pad index %d\n", 46 dev_dbg(mdev->sdev->parent, "Writing 0x%x to scratch pad index %d\n",
47 val, idx); 47 val, idx);
48 mic_mmio_write(&mdev->mmio, val, 48 mic_mmio_write(&mdev->mmio, val,
49 MIC_X100_SBOX_BASE_ADDRESS + 49 MIC_X100_SBOX_BASE_ADDRESS +
50 MIC_X100_SBOX_SPAD0 + idx * 4); 50 MIC_X100_SBOX_SPAD0 + idx * 4);
51} 51}
52 52
53/** 53/**
@@ -130,8 +130,8 @@ static void mic_x100_send_sbox_intr(struct mic_device *mdev,
130{ 130{
131 struct mic_mw *mw = &mdev->mmio; 131 struct mic_mw *mw = &mdev->mmio;
132 u64 apic_icr_offset = MIC_X100_SBOX_APICICR0 + doorbell * 8; 132 u64 apic_icr_offset = MIC_X100_SBOX_APICICR0 + doorbell * 8;
133 u32 apicicr_low = mic_mmio_read(mw, 133 u32 apicicr_low = mic_mmio_read(mw, MIC_X100_SBOX_BASE_ADDRESS +
134 MIC_X100_SBOX_BASE_ADDRESS + apic_icr_offset); 134 apic_icr_offset);
135 135
136 /* for MIC we need to make sure we "hit" the send_icr bit (13) */ 136 /* for MIC we need to make sure we "hit" the send_icr bit (13) */
137 apicicr_low = (apicicr_low | (1 << 13)); 137 apicicr_low = (apicicr_low | (1 << 13));
@@ -139,7 +139,7 @@ static void mic_x100_send_sbox_intr(struct mic_device *mdev,
139 /* Ensure that the interrupt is ordered w.r.t. previous stores. */ 139 /* Ensure that the interrupt is ordered w.r.t. previous stores. */
140 wmb(); 140 wmb();
141 mic_mmio_write(mw, apicicr_low, 141 mic_mmio_write(mw, apicicr_low,
142 MIC_X100_SBOX_BASE_ADDRESS + apic_icr_offset); 142 MIC_X100_SBOX_BASE_ADDRESS + apic_icr_offset);
143} 143}
144 144
145/** 145/**
@@ -153,7 +153,7 @@ static void mic_x100_send_rdmasr_intr(struct mic_device *mdev,
153 /* Ensure that the interrupt is ordered w.r.t. previous stores. */ 153 /* Ensure that the interrupt is ordered w.r.t. previous stores. */
154 wmb(); 154 wmb();
155 mic_mmio_write(&mdev->mmio, 0, 155 mic_mmio_write(&mdev->mmio, 0,
156 MIC_X100_SBOX_BASE_ADDRESS + rdmasr_offset); 156 MIC_X100_SBOX_BASE_ADDRESS + rdmasr_offset);
157} 157}
158 158
159/** 159/**
@@ -212,7 +212,7 @@ done:
212 */ 212 */
213static void mic_x100_hw_intr_init(struct mic_device *mdev) 213static void mic_x100_hw_intr_init(struct mic_device *mdev)
214{ 214{
215 mdev->intr_info = (struct mic_intr_info *) mic_x100_intr_init; 215 mdev->intr_info = (struct mic_intr_info *)mic_x100_intr_init;
216} 216}
217 217
218/** 218/**
@@ -244,7 +244,7 @@ mic_x100_read_msi_to_src_map(struct mic_device *mdev, int idx)
244 */ 244 */
245static void 245static void
246mic_x100_program_msi_to_src_map(struct mic_device *mdev, 246mic_x100_program_msi_to_src_map(struct mic_device *mdev,
247 int idx, int offset, bool set) 247 int idx, int offset, bool set)
248{ 248{
249 unsigned long reg; 249 unsigned long reg;
250 struct mic_mw *mw = &mdev->mmio; 250 struct mic_mw *mw = &mdev->mmio;
@@ -308,12 +308,12 @@ static void mic_x100_send_firmware_intr(struct mic_device *mdev)
308 apicicr_low = (vector | (1 << 13)); 308 apicicr_low = (vector | (1 << 13));
309 309
310 mic_mmio_write(mw, mic_x100_get_apic_id(mdev), 310 mic_mmio_write(mw, mic_x100_get_apic_id(mdev),
311 MIC_X100_SBOX_BASE_ADDRESS + apic_icr_offset + 4); 311 MIC_X100_SBOX_BASE_ADDRESS + apic_icr_offset + 4);
312 312
313 /* Ensure that the interrupt is ordered w.r.t. previous stores. */ 313 /* Ensure that the interrupt is ordered w.r.t. previous stores. */
314 wmb(); 314 wmb();
315 mic_mmio_write(mw, apicicr_low, 315 mic_mmio_write(mw, apicicr_low,
316 MIC_X100_SBOX_BASE_ADDRESS + apic_icr_offset); 316 MIC_X100_SBOX_BASE_ADDRESS + apic_icr_offset);
317} 317}
318 318
319/** 319/**
@@ -365,8 +365,7 @@ mic_x100_load_command_line(struct mic_device *mdev, const struct firmware *fw)
365 len += snprintf(buf, CMDLINE_SIZE - len, 365 len += snprintf(buf, CMDLINE_SIZE - len,
366 " mem=%dM", boot_mem); 366 " mem=%dM", boot_mem);
367 if (mdev->cmdline) 367 if (mdev->cmdline)
368 snprintf(buf + len, CMDLINE_SIZE - len, 368 snprintf(buf + len, CMDLINE_SIZE - len, " %s", mdev->cmdline);
369 " %s", mdev->cmdline);
370 memcpy_toio(cmd_line_va, buf, strlen(buf) + 1); 369 memcpy_toio(cmd_line_va, buf, strlen(buf) + 1);
371 kfree(buf); 370 kfree(buf);
372 return 0; 371 return 0;
@@ -397,8 +396,7 @@ mic_x100_load_ramdisk(struct mic_device *mdev)
397 * Typically the bootaddr for card OS is 64M 396 * Typically the bootaddr for card OS is 64M
398 * so copy over the ramdisk @ 128M. 397 * so copy over the ramdisk @ 128M.
399 */ 398 */
400 memcpy_toio(mdev->aper.va + (mdev->bootaddr << 1), 399 memcpy_toio(mdev->aper.va + (mdev->bootaddr << 1), fw->data, fw->size);
401 fw->data, fw->size);
402 iowrite32(cpu_to_le32(mdev->bootaddr << 1), &bp->hdr.ramdisk_image); 400 iowrite32(cpu_to_le32(mdev->bootaddr << 1), &bp->hdr.ramdisk_image);
403 iowrite32(cpu_to_le32(fw->size), &bp->hdr.ramdisk_size); 401 iowrite32(cpu_to_le32(fw->size), &bp->hdr.ramdisk_size);
404 release_firmware(fw); 402 release_firmware(fw);
@@ -484,8 +482,7 @@ mic_x100_load_firmware(struct mic_device *mdev, const char *buf)
484 if (mdev->ramdisk) 482 if (mdev->ramdisk)
485 rc = mic_x100_load_ramdisk(mdev); 483 rc = mic_x100_load_ramdisk(mdev);
486error: 484error:
487 dev_dbg(mdev->sdev->parent, "%s %d rc %d\n", 485 dev_dbg(mdev->sdev->parent, "%s %d rc %d\n", __func__, __LINE__, rc);
488 __func__, __LINE__, rc);
489done: 486done:
490 return rc; 487 return rc;
491} 488}
@@ -524,8 +521,8 @@ mic_x100_smpt_set(struct mic_device *mdev, dma_addr_t dma_addr, u8 index)
524 uint32_t smpt_reg_val = BUILD_SMPT(SNOOP_ON, 521 uint32_t smpt_reg_val = BUILD_SMPT(SNOOP_ON,
525 dma_addr >> mdev->smpt->info.page_shift); 522 dma_addr >> mdev->smpt->info.page_shift);
526 mic_mmio_write(&mdev->mmio, smpt_reg_val, 523 mic_mmio_write(&mdev->mmio, smpt_reg_val,
527 MIC_X100_SBOX_BASE_ADDRESS + 524 MIC_X100_SBOX_BASE_ADDRESS +
528 MIC_X100_SBOX_SMPT00 + (4 * index)); 525 MIC_X100_SBOX_SMPT00 + (4 * index));
529} 526}
530 527
531/** 528/**