diff options
author | Frank Haverkamp <haver@linux.vnet.ibm.com> | 2013-12-22 08:16:36 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2014-01-08 18:18:02 -0500 |
commit | d276b6c54d47a427e4cffd7c84f3b631a1edf98e (patch) | |
tree | 3c0ce045698f9aa3f86e16a26d1223a1b51af5bd /drivers/misc/genwqe | |
parent | 11d5ceb646d11caecb57a4347ff97e59ab4a5b51 (diff) |
GenWQE: Rework return code for flash-update ioctl
Instead of remaining bytes of a failing copy_to_user, the flash-update
ioctl is returning now -EFAULT. In addtion Dan discovered user triggerable
dev_errs(). Those I removed now from card_dev.c too. Some dev_infos()
were deleted and some others turned into dev_dbgs().
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Frank Haverkamp <haver@linux.vnet.ibm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/misc/genwqe')
-rw-r--r-- | drivers/misc/genwqe/card_dev.c | 172 |
1 files changed, 43 insertions, 129 deletions
diff --git a/drivers/misc/genwqe/card_dev.c b/drivers/misc/genwqe/card_dev.c index bcd3081b55b9..9c1157e6ec0d 100644 --- a/drivers/misc/genwqe/card_dev.c +++ b/drivers/misc/genwqe/card_dev.c | |||
@@ -516,17 +516,11 @@ static int do_flash_update(struct genwqe_file *cfile, | |||
516 | struct genwqe_dev *cd = cfile->cd; | 516 | struct genwqe_dev *cd = cfile->cd; |
517 | struct pci_dev *pci_dev = cd->pci_dev; | 517 | struct pci_dev *pci_dev = cd->pci_dev; |
518 | 518 | ||
519 | if ((load->size & 0x3) != 0) { | 519 | if ((load->size & 0x3) != 0) |
520 | dev_err(&pci_dev->dev, | ||
521 | "err: buf %d bytes not 4 bytes aligned!\n", | ||
522 | load->size); | ||
523 | return -EINVAL; | 520 | return -EINVAL; |
524 | } | 521 | |
525 | if (((unsigned long)(load->data_addr) & ~PAGE_MASK) != 0) { | 522 | if (((unsigned long)(load->data_addr) & ~PAGE_MASK) != 0) |
526 | dev_err(&pci_dev->dev, | ||
527 | "err: buf is not page aligned!\n"); | ||
528 | return -EINVAL; | 523 | return -EINVAL; |
529 | } | ||
530 | 524 | ||
531 | /* FIXME Bits have changed for new service layer! */ | 525 | /* FIXME Bits have changed for new service layer! */ |
532 | switch ((char)load->partition) { | 526 | switch ((char)load->partition) { |
@@ -538,20 +532,13 @@ static int do_flash_update(struct genwqe_file *cfile, | |||
538 | break; /* download/erase_first/part_1 */ | 532 | break; /* download/erase_first/part_1 */ |
539 | case 'v': /* cmdopts = 0x0c (VPD) */ | 533 | case 'v': /* cmdopts = 0x0c (VPD) */ |
540 | default: | 534 | default: |
541 | dev_err(&pci_dev->dev, | ||
542 | "err: invalid partition %02x!\n", load->partition); | ||
543 | return -EINVAL; | 535 | return -EINVAL; |
544 | } | 536 | } |
545 | dev_info(&pci_dev->dev, | ||
546 | "[%s] start flash update UID: 0x%x size: %u bytes part: %c\n", | ||
547 | __func__, load->uid, load->size, (char)load->partition); | ||
548 | 537 | ||
549 | buf = (u8 __user *)load->data_addr; | 538 | buf = (u8 __user *)load->data_addr; |
550 | xbuf = __genwqe_alloc_consistent(cd, FLASH_BLOCK, &dma_addr); | 539 | xbuf = __genwqe_alloc_consistent(cd, FLASH_BLOCK, &dma_addr); |
551 | if (xbuf == NULL) { | 540 | if (xbuf == NULL) |
552 | dev_err(&pci_dev->dev, "err: no memory\n"); | ||
553 | return -ENOMEM; | 541 | return -ENOMEM; |
554 | } | ||
555 | 542 | ||
556 | blocks_to_flash = load->size / FLASH_BLOCK; | 543 | blocks_to_flash = load->size / FLASH_BLOCK; |
557 | while (load->size) { | 544 | while (load->size) { |
@@ -565,14 +552,13 @@ static int do_flash_update(struct genwqe_file *cfile, | |||
565 | 552 | ||
566 | rc = copy_from_user(xbuf, buf, tocopy); | 553 | rc = copy_from_user(xbuf, buf, tocopy); |
567 | if (rc) { | 554 | if (rc) { |
568 | dev_err(&pci_dev->dev, | 555 | rc = -EFAULT; |
569 | "err: could not copy all data rc=%d\n", rc); | ||
570 | goto free_buffer; | 556 | goto free_buffer; |
571 | } | 557 | } |
572 | crc = genwqe_crc32(xbuf, tocopy, 0xffffffff); | 558 | crc = genwqe_crc32(xbuf, tocopy, 0xffffffff); |
573 | 559 | ||
574 | dev_info(&pci_dev->dev, | 560 | dev_dbg(&pci_dev->dev, |
575 | "[%s] DMA: 0x%llx CRC: %08x SZ: %ld %d\n", | 561 | "[%s] DMA: 0x%llx CRC: %08x SZ: %ld %d\n", |
576 | __func__, dma_addr, crc, tocopy, blocks_to_flash); | 562 | __func__, dma_addr, crc, tocopy, blocks_to_flash); |
577 | 563 | ||
578 | /* prepare DDCB for SLU process */ | 564 | /* prepare DDCB for SLU process */ |
@@ -626,21 +612,11 @@ static int do_flash_update(struct genwqe_file *cfile, | |||
626 | load->progress = req->progress; | 612 | load->progress = req->progress; |
627 | 613 | ||
628 | if (rc < 0) { | 614 | if (rc < 0) { |
629 | dev_err(&pci_dev->dev, | ||
630 | " [%s] DDCB returned (RETC=%x ATTN=%x " | ||
631 | "PROG=%x rc=%d)\n", __func__, req->retc, | ||
632 | req->attn, req->progress, rc); | ||
633 | |||
634 | ddcb_requ_free(req); | 615 | ddcb_requ_free(req); |
635 | goto free_buffer; | 616 | goto free_buffer; |
636 | } | 617 | } |
637 | 618 | ||
638 | if (req->retc != DDCB_RETC_COMPLETE) { | 619 | if (req->retc != DDCB_RETC_COMPLETE) { |
639 | dev_info(&pci_dev->dev, | ||
640 | " [%s] DDCB returned (RETC=%x ATTN=%x " | ||
641 | "PROG=%x)\n", __func__, req->retc, | ||
642 | req->attn, req->progress); | ||
643 | |||
644 | rc = -EIO; | 620 | rc = -EIO; |
645 | ddcb_requ_free(req); | 621 | ddcb_requ_free(req); |
646 | goto free_buffer; | 622 | goto free_buffer; |
@@ -671,16 +647,11 @@ static int do_flash_read(struct genwqe_file *cfile, | |||
671 | struct pci_dev *pci_dev = cd->pci_dev; | 647 | struct pci_dev *pci_dev = cd->pci_dev; |
672 | struct genwqe_ddcb_cmd *cmd; | 648 | struct genwqe_ddcb_cmd *cmd; |
673 | 649 | ||
674 | if ((load->size & 0x3) != 0) { | 650 | if ((load->size & 0x3) != 0) |
675 | dev_err(&pci_dev->dev, | ||
676 | "err: buf size %d bytes not 4 bytes aligned!\n", | ||
677 | load->size); | ||
678 | return -EINVAL; | 651 | return -EINVAL; |
679 | } | 652 | |
680 | if (((unsigned long)(load->data_addr) & ~PAGE_MASK) != 0) { | 653 | if (((unsigned long)(load->data_addr) & ~PAGE_MASK) != 0) |
681 | dev_err(&pci_dev->dev, "err: buf is not page aligned!\n"); | ||
682 | return -EINVAL; | 654 | return -EINVAL; |
683 | } | ||
684 | 655 | ||
685 | /* FIXME Bits have changed for new service layer! */ | 656 | /* FIXME Bits have changed for new service layer! */ |
686 | switch ((char)load->partition) { | 657 | switch ((char)load->partition) { |
@@ -692,20 +663,13 @@ static int do_flash_read(struct genwqe_file *cfile, | |||
692 | break; /* upload/part_1 */ | 663 | break; /* upload/part_1 */ |
693 | case 'v': | 664 | case 'v': |
694 | default: | 665 | default: |
695 | dev_err(&pci_dev->dev, | ||
696 | "err: invalid partition %02x!\n", load->partition); | ||
697 | return -EINVAL; | 666 | return -EINVAL; |
698 | } | 667 | } |
699 | dev_info(&pci_dev->dev, | ||
700 | "[%s] start flash read UID: 0x%x size: %u bytes part: %c\n", | ||
701 | __func__, load->uid, load->size, (char)load->partition); | ||
702 | 668 | ||
703 | buf = (u8 __user *)load->data_addr; | 669 | buf = (u8 __user *)load->data_addr; |
704 | xbuf = __genwqe_alloc_consistent(cd, FLASH_BLOCK, &dma_addr); | 670 | xbuf = __genwqe_alloc_consistent(cd, FLASH_BLOCK, &dma_addr); |
705 | if (xbuf == NULL) { | 671 | if (xbuf == NULL) |
706 | dev_err(&pci_dev->dev, "err: no memory\n"); | ||
707 | return -ENOMEM; | 672 | return -ENOMEM; |
708 | } | ||
709 | 673 | ||
710 | blocks_to_flash = load->size / FLASH_BLOCK; | 674 | blocks_to_flash = load->size / FLASH_BLOCK; |
711 | while (load->size) { | 675 | while (load->size) { |
@@ -715,9 +679,9 @@ static int do_flash_read(struct genwqe_file *cfile, | |||
715 | */ | 679 | */ |
716 | tocopy = min_t(size_t, load->size, FLASH_BLOCK); | 680 | tocopy = min_t(size_t, load->size, FLASH_BLOCK); |
717 | 681 | ||
718 | dev_info(&pci_dev->dev, | 682 | dev_dbg(&pci_dev->dev, |
719 | "[%s] DMA: 0x%llx SZ: %ld %d\n", | 683 | "[%s] DMA: 0x%llx SZ: %ld %d\n", |
720 | __func__, dma_addr, tocopy, blocks_to_flash); | 684 | __func__, dma_addr, tocopy, blocks_to_flash); |
721 | 685 | ||
722 | /* prepare DDCB for SLU process */ | 686 | /* prepare DDCB for SLU process */ |
723 | cmd = ddcb_requ_alloc(); | 687 | cmd = ddcb_requ_alloc(); |
@@ -735,7 +699,7 @@ static int do_flash_read(struct genwqe_file *cfile, | |||
735 | *(__be64 *)&cmd->__asiv[16] = cpu_to_be64(flash); | 699 | *(__be64 *)&cmd->__asiv[16] = cpu_to_be64(flash); |
736 | *(__be32 *)&cmd->__asiv[24] = cpu_to_be32(0); | 700 | *(__be32 *)&cmd->__asiv[24] = cpu_to_be32(0); |
737 | cmd->__asiv[24] = load->uid; | 701 | cmd->__asiv[24] = load->uid; |
738 | *(__be32 *)&cmd->__asiv[28] = cpu_to_be32(0) /* CRC */; | 702 | *(__be32 *)&cmd->__asiv[28] = cpu_to_be32(0) /* CRC */; |
739 | cmd->asiv_length = 32; /* bytes included in crc calc */ | 703 | cmd->asiv_length = 32; /* bytes included in crc calc */ |
740 | } else { /* setup DDCB for ATS architecture */ | 704 | } else { /* setup DDCB for ATS architecture */ |
741 | *(__be64 *)&cmd->asiv[0] = cpu_to_be64(dma_addr); | 705 | *(__be64 *)&cmd->asiv[0] = cpu_to_be64(dma_addr); |
@@ -761,20 +725,13 @@ static int do_flash_read(struct genwqe_file *cfile, | |||
761 | load->progress = cmd->progress; | 725 | load->progress = cmd->progress; |
762 | 726 | ||
763 | if ((rc < 0) && (rc != -EBADMSG)) { | 727 | if ((rc < 0) && (rc != -EBADMSG)) { |
764 | dev_err(&pci_dev->dev, | ||
765 | " [%s] DDCB returned (RETC=%x ATTN=%x " | ||
766 | "PROG=%x rc=%d)\n", __func__, cmd->retc, | ||
767 | cmd->attn, cmd->progress, rc); | ||
768 | ddcb_requ_free(cmd); | 728 | ddcb_requ_free(cmd); |
769 | goto free_buffer; | 729 | goto free_buffer; |
770 | } | 730 | } |
771 | 731 | ||
772 | rc = copy_to_user(buf, xbuf, tocopy); | 732 | rc = copy_to_user(buf, xbuf, tocopy); |
773 | if (rc) { | 733 | if (rc) { |
774 | dev_err(&pci_dev->dev, | 734 | rc = -EFAULT; |
775 | " [%s] copy data to user failed rc=%d\n", | ||
776 | __func__, rc); | ||
777 | rc = -EIO; | ||
778 | ddcb_requ_free(cmd); | 735 | ddcb_requ_free(cmd); |
779 | goto free_buffer; | 736 | goto free_buffer; |
780 | } | 737 | } |
@@ -784,10 +741,6 @@ static int do_flash_read(struct genwqe_file *cfile, | |||
784 | (cmd->attn != 0x02)) || /* Normally ignore CRC error */ | 741 | (cmd->attn != 0x02)) || /* Normally ignore CRC error */ |
785 | ((cmd->retc == DDCB_RETC_COMPLETE) && | 742 | ((cmd->retc == DDCB_RETC_COMPLETE) && |
786 | (cmd->attn != 0x00))) { /* Everything was fine */ | 743 | (cmd->attn != 0x00))) { /* Everything was fine */ |
787 | dev_err(&pci_dev->dev, | ||
788 | " [%s] DDCB returned (RETC=%x ATTN=%x " | ||
789 | "PROG=%x rc=%d)\n", __func__, cmd->retc, | ||
790 | cmd->attn, cmd->progress, rc); | ||
791 | rc = -EIO; | 744 | rc = -EIO; |
792 | ddcb_requ_free(cmd); | 745 | ddcb_requ_free(cmd); |
793 | goto free_buffer; | 746 | goto free_buffer; |
@@ -906,7 +859,6 @@ static int ddcb_cmd_fixups(struct genwqe_file *cfile, struct ddcb_requ *req) | |||
906 | struct genwqe_dev *cd = cfile->cd; | 859 | struct genwqe_dev *cd = cfile->cd; |
907 | struct genwqe_ddcb_cmd *cmd = &req->cmd; | 860 | struct genwqe_ddcb_cmd *cmd = &req->cmd; |
908 | struct dma_mapping *m; | 861 | struct dma_mapping *m; |
909 | struct pci_dev *pci_dev = cd->pci_dev; | ||
910 | const char *type = "UNKNOWN"; | 862 | const char *type = "UNKNOWN"; |
911 | 863 | ||
912 | for (i = 0, asiv_offs = 0x00; asiv_offs <= 0x58; | 864 | for (i = 0, asiv_offs = 0x00; asiv_offs <= 0x58; |
@@ -1018,9 +970,6 @@ static int ddcb_cmd_fixups(struct genwqe_file *cfile, struct ddcb_requ *req) | |||
1018 | break; | 970 | break; |
1019 | } | 971 | } |
1020 | default: | 972 | default: |
1021 | dev_err(&pci_dev->dev, | ||
1022 | "[%s] err: invalid ATS flags %01llx\n", | ||
1023 | __func__, ats_flags); | ||
1024 | rc = -EINVAL; | 973 | rc = -EINVAL; |
1025 | goto err_out; | 974 | goto err_out; |
1026 | } | 975 | } |
@@ -1028,7 +977,6 @@ static int ddcb_cmd_fixups(struct genwqe_file *cfile, struct ddcb_requ *req) | |||
1028 | return 0; | 977 | return 0; |
1029 | 978 | ||
1030 | err_out: | 979 | err_out: |
1031 | dev_err(&pci_dev->dev, "[%s] err: rc=%d\n", __func__, rc); | ||
1032 | ddcb_cmd_cleanup(cfile, req); | 980 | ddcb_cmd_cleanup(cfile, req); |
1033 | return rc; | 981 | return rc; |
1034 | } | 982 | } |
@@ -1063,7 +1011,6 @@ static int do_execute_ddcb(struct genwqe_file *cfile, | |||
1063 | struct genwqe_ddcb_cmd *cmd; | 1011 | struct genwqe_ddcb_cmd *cmd; |
1064 | struct ddcb_requ *req; | 1012 | struct ddcb_requ *req; |
1065 | struct genwqe_dev *cd = cfile->cd; | 1013 | struct genwqe_dev *cd = cfile->cd; |
1066 | struct pci_dev *pci_dev = cd->pci_dev; | ||
1067 | 1014 | ||
1068 | cmd = ddcb_requ_alloc(); | 1015 | cmd = ddcb_requ_alloc(); |
1069 | if (cmd == NULL) | 1016 | if (cmd == NULL) |
@@ -1072,8 +1019,6 @@ static int do_execute_ddcb(struct genwqe_file *cfile, | |||
1072 | req = container_of(cmd, struct ddcb_requ, cmd); | 1019 | req = container_of(cmd, struct ddcb_requ, cmd); |
1073 | 1020 | ||
1074 | if (copy_from_user(cmd, (void __user *)arg, sizeof(*cmd))) { | 1021 | if (copy_from_user(cmd, (void __user *)arg, sizeof(*cmd))) { |
1075 | dev_err(&pci_dev->dev, | ||
1076 | "err: could not copy params from user\n"); | ||
1077 | ddcb_requ_free(cmd); | 1022 | ddcb_requ_free(cmd); |
1078 | return -EFAULT; | 1023 | return -EFAULT; |
1079 | } | 1024 | } |
@@ -1087,8 +1032,6 @@ static int do_execute_ddcb(struct genwqe_file *cfile, | |||
1087 | back since the copy got modified by the driver. */ | 1032 | back since the copy got modified by the driver. */ |
1088 | if (copy_to_user((void __user *)arg, cmd, | 1033 | if (copy_to_user((void __user *)arg, cmd, |
1089 | sizeof(*cmd) - DDCB_ASIV_LENGTH)) { | 1034 | sizeof(*cmd) - DDCB_ASIV_LENGTH)) { |
1090 | dev_err(&pci_dev->dev, | ||
1091 | "err: could not copy params to user\n"); | ||
1092 | ddcb_requ_free(cmd); | 1035 | ddcb_requ_free(cmd); |
1093 | return -EFAULT; | 1036 | return -EFAULT; |
1094 | } | 1037 | } |
@@ -1114,12 +1057,9 @@ static long genwqe_ioctl(struct file *filp, unsigned int cmd, | |||
1114 | struct genwqe_reg_io __user *io; | 1057 | struct genwqe_reg_io __user *io; |
1115 | u64 val; | 1058 | u64 val; |
1116 | u32 reg_offs; | 1059 | u32 reg_offs; |
1117 | struct pci_dev *pci_dev = cd->pci_dev; | ||
1118 | 1060 | ||
1119 | if (_IOC_TYPE(cmd) != GENWQE_IOC_CODE) { | 1061 | if (_IOC_TYPE(cmd) != GENWQE_IOC_CODE) |
1120 | dev_err(&pci_dev->dev, "err: ioctl code does not match!\n"); | ||
1121 | return -EINVAL; | 1062 | return -EINVAL; |
1122 | } | ||
1123 | 1063 | ||
1124 | switch (cmd) { | 1064 | switch (cmd) { |
1125 | 1065 | ||
@@ -1131,10 +1071,9 @@ static long genwqe_ioctl(struct file *filp, unsigned int cmd, | |||
1131 | case GENWQE_READ_REG64: { | 1071 | case GENWQE_READ_REG64: { |
1132 | io = (struct genwqe_reg_io __user *)arg; | 1072 | io = (struct genwqe_reg_io __user *)arg; |
1133 | 1073 | ||
1134 | if (get_user(reg_offs, &io->num)) { | 1074 | if (get_user(reg_offs, &io->num)) |
1135 | dev_err(&pci_dev->dev, "err: reg read64\n"); | ||
1136 | return -EFAULT; | 1075 | return -EFAULT; |
1137 | } | 1076 | |
1138 | if ((reg_offs >= cd->mmio_len) || (reg_offs & 0x7)) | 1077 | if ((reg_offs >= cd->mmio_len) || (reg_offs & 0x7)) |
1139 | return -EINVAL; | 1078 | return -EINVAL; |
1140 | 1079 | ||
@@ -1152,17 +1091,15 @@ static long genwqe_ioctl(struct file *filp, unsigned int cmd, | |||
1152 | if ((filp->f_flags & O_ACCMODE) == O_RDONLY) | 1091 | if ((filp->f_flags & O_ACCMODE) == O_RDONLY) |
1153 | return -EPERM; | 1092 | return -EPERM; |
1154 | 1093 | ||
1155 | if (get_user(reg_offs, &io->num)) { | 1094 | if (get_user(reg_offs, &io->num)) |
1156 | dev_err(&pci_dev->dev, "err: reg write64\n"); | ||
1157 | return -EFAULT; | 1095 | return -EFAULT; |
1158 | } | 1096 | |
1159 | if ((reg_offs >= cd->mmio_len) || (reg_offs & 0x7)) | 1097 | if ((reg_offs >= cd->mmio_len) || (reg_offs & 0x7)) |
1160 | return -EINVAL; | 1098 | return -EINVAL; |
1161 | 1099 | ||
1162 | if (get_user(val, &io->val64)) { | 1100 | if (get_user(val, &io->val64)) |
1163 | dev_err(&pci_dev->dev, "err: reg write64\n"); | ||
1164 | return -EFAULT; | 1101 | return -EFAULT; |
1165 | } | 1102 | |
1166 | __genwqe_writeq(cd, reg_offs, val); | 1103 | __genwqe_writeq(cd, reg_offs, val); |
1167 | return 0; | 1104 | return 0; |
1168 | } | 1105 | } |
@@ -1170,10 +1107,9 @@ static long genwqe_ioctl(struct file *filp, unsigned int cmd, | |||
1170 | case GENWQE_READ_REG32: { | 1107 | case GENWQE_READ_REG32: { |
1171 | io = (struct genwqe_reg_io __user *)arg; | 1108 | io = (struct genwqe_reg_io __user *)arg; |
1172 | 1109 | ||
1173 | if (get_user(reg_offs, &io->num)) { | 1110 | if (get_user(reg_offs, &io->num)) |
1174 | dev_err(&pci_dev->dev, "err: reg read32\n"); | ||
1175 | return -EFAULT; | 1111 | return -EFAULT; |
1176 | } | 1112 | |
1177 | if ((reg_offs >= cd->mmio_len) || (reg_offs & 0x3)) | 1113 | if ((reg_offs >= cd->mmio_len) || (reg_offs & 0x3)) |
1178 | return -EINVAL; | 1114 | return -EINVAL; |
1179 | 1115 | ||
@@ -1191,17 +1127,15 @@ static long genwqe_ioctl(struct file *filp, unsigned int cmd, | |||
1191 | if ((filp->f_flags & O_ACCMODE) == O_RDONLY) | 1127 | if ((filp->f_flags & O_ACCMODE) == O_RDONLY) |
1192 | return -EPERM; | 1128 | return -EPERM; |
1193 | 1129 | ||
1194 | if (get_user(reg_offs, &io->num)) { | 1130 | if (get_user(reg_offs, &io->num)) |
1195 | dev_err(&pci_dev->dev, "err: reg write32\n"); | ||
1196 | return -EFAULT; | 1131 | return -EFAULT; |
1197 | } | 1132 | |
1198 | if ((reg_offs >= cd->mmio_len) || (reg_offs & 0x3)) | 1133 | if ((reg_offs >= cd->mmio_len) || (reg_offs & 0x3)) |
1199 | return -EINVAL; | 1134 | return -EINVAL; |
1200 | 1135 | ||
1201 | if (get_user(val, &io->val64)) { | 1136 | if (get_user(val, &io->val64)) |
1202 | dev_err(&pci_dev->dev, "err: reg write32\n"); | ||
1203 | return -EFAULT; | 1137 | return -EFAULT; |
1204 | } | 1138 | |
1205 | __genwqe_writel(cd, reg_offs, val); | 1139 | __genwqe_writel(cd, reg_offs, val); |
1206 | return 0; | 1140 | return 0; |
1207 | } | 1141 | } |
@@ -1217,19 +1151,14 @@ static long genwqe_ioctl(struct file *filp, unsigned int cmd, | |||
1217 | return -EPERM; | 1151 | return -EPERM; |
1218 | 1152 | ||
1219 | if (copy_from_user(&load, (void __user *)arg, | 1153 | if (copy_from_user(&load, (void __user *)arg, |
1220 | sizeof(load))) { | 1154 | sizeof(load))) |
1221 | dev_err(&pci_dev->dev, | ||
1222 | "err: could not copy params from user\n"); | ||
1223 | return -EFAULT; | 1155 | return -EFAULT; |
1224 | } | 1156 | |
1225 | rc = do_flash_update(cfile, &load); | 1157 | rc = do_flash_update(cfile, &load); |
1226 | 1158 | ||
1227 | if (copy_to_user((void __user *)arg, &load, sizeof(load))) { | 1159 | if (copy_to_user((void __user *)arg, &load, sizeof(load))) |
1228 | dev_err(&pci_dev->dev, | ||
1229 | "err: could not copy params to user\n"); | ||
1230 | return -EFAULT; | 1160 | return -EFAULT; |
1231 | } | 1161 | |
1232 | dev_info(&pci_dev->dev, "[%s] rc=%d\n", __func__, rc); | ||
1233 | return rc; | 1162 | return rc; |
1234 | } | 1163 | } |
1235 | 1164 | ||
@@ -1242,20 +1171,14 @@ static long genwqe_ioctl(struct file *filp, unsigned int cmd, | |||
1242 | if (genwqe_flash_readback_fails(cd)) | 1171 | if (genwqe_flash_readback_fails(cd)) |
1243 | return -ENOSPC; /* known to fail for old versions */ | 1172 | return -ENOSPC; /* known to fail for old versions */ |
1244 | 1173 | ||
1245 | if (copy_from_user(&load, (void __user *)arg, | 1174 | if (copy_from_user(&load, (void __user *)arg, sizeof(load))) |
1246 | sizeof(load))) { | ||
1247 | dev_err(&pci_dev->dev, | ||
1248 | "err: could not copy params from user\n"); | ||
1249 | return -EFAULT; | 1175 | return -EFAULT; |
1250 | } | 1176 | |
1251 | rc = do_flash_read(cfile, &load); | 1177 | rc = do_flash_read(cfile, &load); |
1252 | 1178 | ||
1253 | if (copy_to_user((void __user *)arg, &load, sizeof(load))) { | 1179 | if (copy_to_user((void __user *)arg, &load, sizeof(load))) |
1254 | dev_err(&pci_dev->dev, | ||
1255 | "err: could not copy params to user\n"); | ||
1256 | return -EFAULT; | 1180 | return -EFAULT; |
1257 | } | 1181 | |
1258 | dev_info(&pci_dev->dev, "[%s] rc=%d\n", __func__, rc); | ||
1259 | return rc; | 1182 | return rc; |
1260 | } | 1183 | } |
1261 | 1184 | ||
@@ -1263,24 +1186,18 @@ static long genwqe_ioctl(struct file *filp, unsigned int cmd, | |||
1263 | case GENWQE_PIN_MEM: { | 1186 | case GENWQE_PIN_MEM: { |
1264 | struct genwqe_mem m; | 1187 | struct genwqe_mem m; |
1265 | 1188 | ||
1266 | if (copy_from_user(&m, (void __user *)arg, | 1189 | if (copy_from_user(&m, (void __user *)arg, sizeof(m))) |
1267 | sizeof(m))) { | ||
1268 | dev_err(&pci_dev->dev, | ||
1269 | "err: could not copy params from user\n"); | ||
1270 | return -EFAULT; | 1190 | return -EFAULT; |
1271 | } | 1191 | |
1272 | return genwqe_pin_mem(cfile, &m); | 1192 | return genwqe_pin_mem(cfile, &m); |
1273 | } | 1193 | } |
1274 | 1194 | ||
1275 | case GENWQE_UNPIN_MEM: { | 1195 | case GENWQE_UNPIN_MEM: { |
1276 | struct genwqe_mem m; | 1196 | struct genwqe_mem m; |
1277 | 1197 | ||
1278 | if (copy_from_user(&m, (void __user *)arg, | 1198 | if (copy_from_user(&m, (void __user *)arg, sizeof(m))) |
1279 | sizeof(m))) { | ||
1280 | dev_err(&pci_dev->dev, | ||
1281 | "err: could not copy params from user\n"); | ||
1282 | return -EFAULT; | 1199 | return -EFAULT; |
1283 | } | 1200 | |
1284 | return genwqe_unpin_mem(cfile, &m); | 1201 | return genwqe_unpin_mem(cfile, &m); |
1285 | } | 1202 | } |
1286 | 1203 | ||
@@ -1290,16 +1207,13 @@ static long genwqe_ioctl(struct file *filp, unsigned int cmd, | |||
1290 | 1207 | ||
1291 | case GENWQE_EXECUTE_RAW_DDCB: { | 1208 | case GENWQE_EXECUTE_RAW_DDCB: { |
1292 | 1209 | ||
1293 | if (!capable(CAP_SYS_ADMIN)) { | 1210 | if (!capable(CAP_SYS_ADMIN)) |
1294 | dev_err(&pci_dev->dev, | ||
1295 | "err: must be superuser execute raw DDCB!\n"); | ||
1296 | return -EPERM; | 1211 | return -EPERM; |
1297 | } | 1212 | |
1298 | return do_execute_ddcb(cfile, arg, 1); | 1213 | return do_execute_ddcb(cfile, arg, 1); |
1299 | } | 1214 | } |
1300 | 1215 | ||
1301 | default: | 1216 | default: |
1302 | pr_err("unknown ioctl %x/%lx**\n", cmd, arg); | ||
1303 | return -EINVAL; | 1217 | return -EINVAL; |
1304 | } | 1218 | } |
1305 | 1219 | ||