diff options
Diffstat (limited to 'drivers/message/fusion/mptctl.c')
-rw-r--r-- | drivers/message/fusion/mptctl.c | 364 |
1 files changed, 182 insertions, 182 deletions
diff --git a/drivers/message/fusion/mptctl.c b/drivers/message/fusion/mptctl.c index 89695e705bd..6029509702d 100644 --- a/drivers/message/fusion/mptctl.c +++ b/drivers/message/fusion/mptctl.c | |||
@@ -1,10 +1,10 @@ | |||
1 | /* | 1 | /* |
2 | * linux/drivers/message/fusion/mptctl.c | 2 | * linux/drivers/message/fusion/mptctl.c |
3 | * mpt Ioctl driver. | 3 | * mpt Ioctl driver. |
4 | * For use with LSI Logic PCI chip/adapters | 4 | * For use with LSI PCI chip/adapters |
5 | * running LSI Logic Fusion MPT (Message Passing Technology) firmware. | 5 | * running LSI Fusion MPT (Message Passing Technology) firmware. |
6 | * | 6 | * |
7 | * Copyright (c) 1999-2007 LSI Logic Corporation | 7 | * Copyright (c) 1999-2007 LSI Corporation |
8 | * (mailto:DL-MPTFusionLinux@lsi.com) | 8 | * (mailto:DL-MPTFusionLinux@lsi.com) |
9 | * | 9 | * |
10 | */ | 10 | */ |
@@ -66,8 +66,8 @@ | |||
66 | #include <scsi/scsi_host.h> | 66 | #include <scsi/scsi_host.h> |
67 | #include <scsi/scsi_tcq.h> | 67 | #include <scsi/scsi_tcq.h> |
68 | 68 | ||
69 | #define COPYRIGHT "Copyright (c) 1999-2007 LSI Logic Corporation" | 69 | #define COPYRIGHT "Copyright (c) 1999-2007 LSI Corporation" |
70 | #define MODULEAUTHOR "LSI Logic Corporation" | 70 | #define MODULEAUTHOR "LSI Corporation" |
71 | #include "mptbase.h" | 71 | #include "mptbase.h" |
72 | #include "mptctl.h" | 72 | #include "mptctl.h" |
73 | 73 | ||
@@ -83,7 +83,7 @@ MODULE_VERSION(my_VERSION); | |||
83 | 83 | ||
84 | /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ | 84 | /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ |
85 | 85 | ||
86 | static int mptctl_id = -1; | 86 | static u8 mptctl_id = MPT_MAX_PROTOCOL_DRIVERS; |
87 | 87 | ||
88 | static DECLARE_WAIT_QUEUE_HEAD ( mptctl_wait ); | 88 | static DECLARE_WAIT_QUEUE_HEAD ( mptctl_wait ); |
89 | 89 | ||
@@ -181,7 +181,6 @@ static inline int | |||
181 | mptctl_syscall_down(MPT_ADAPTER *ioc, int nonblock) | 181 | mptctl_syscall_down(MPT_ADAPTER *ioc, int nonblock) |
182 | { | 182 | { |
183 | int rc = 0; | 183 | int rc = 0; |
184 | // dctlprintk(ioc, printk(KERN_DEBUG MYNAM "::mptctl_syscall_down(%p,%d) called\n", ioc, nonblock)); | ||
185 | 184 | ||
186 | if (nonblock) { | 185 | if (nonblock) { |
187 | if (!mutex_trylock(&ioc->ioctl->ioctl_mutex)) | 186 | if (!mutex_trylock(&ioc->ioctl->ioctl_mutex)) |
@@ -190,7 +189,6 @@ mptctl_syscall_down(MPT_ADAPTER *ioc, int nonblock) | |||
190 | if (mutex_lock_interruptible(&ioc->ioctl->ioctl_mutex)) | 189 | if (mutex_lock_interruptible(&ioc->ioctl->ioctl_mutex)) |
191 | rc = -ERESTARTSYS; | 190 | rc = -ERESTARTSYS; |
192 | } | 191 | } |
193 | // dctlprintk(ioc, printk(KERN_DEBUG MYNAM "::mptctl_syscall_down return %d\n", rc)); | ||
194 | return rc; | 192 | return rc; |
195 | } | 193 | } |
196 | 194 | ||
@@ -342,7 +340,7 @@ static int mptctl_bus_reset(MPT_IOCTL *ioctl) | |||
342 | SCSITaskMgmt_t *pScsiTm; | 340 | SCSITaskMgmt_t *pScsiTm; |
343 | MPT_SCSI_HOST *hd; | 341 | MPT_SCSI_HOST *hd; |
344 | int ii; | 342 | int ii; |
345 | int retval; | 343 | int retval=0; |
346 | 344 | ||
347 | 345 | ||
348 | ioctl->reset &= ~MPTCTL_RESET_OK; | 346 | ioctl->reset &= ~MPTCTL_RESET_OK; |
@@ -350,7 +348,7 @@ static int mptctl_bus_reset(MPT_IOCTL *ioctl) | |||
350 | if (ioctl->ioc->sh == NULL) | 348 | if (ioctl->ioc->sh == NULL) |
351 | return -EPERM; | 349 | return -EPERM; |
352 | 350 | ||
353 | hd = (MPT_SCSI_HOST *) ioctl->ioc->sh->hostdata; | 351 | hd = shost_priv(ioctl->ioc->sh); |
354 | if (hd == NULL) | 352 | if (hd == NULL) |
355 | return -EPERM; | 353 | return -EPERM; |
356 | 354 | ||
@@ -395,12 +393,19 @@ static int mptctl_bus_reset(MPT_IOCTL *ioctl) | |||
395 | DBG_DUMP_TM_REQUEST_FRAME(ioctl->ioc, (u32 *)mf); | 393 | DBG_DUMP_TM_REQUEST_FRAME(ioctl->ioc, (u32 *)mf); |
396 | 394 | ||
397 | ioctl->wait_done=0; | 395 | ioctl->wait_done=0; |
398 | if ((retval = mpt_send_handshake_request(mptctl_id, ioctl->ioc, | 396 | |
399 | sizeof(SCSITaskMgmt_t), (u32*)pScsiTm, CAN_SLEEP)) != 0) { | 397 | if ((ioctl->ioc->facts.IOCCapabilities & MPI_IOCFACTS_CAPABILITY_HIGH_PRI_Q) && |
400 | dfailprintk(ioctl->ioc, printk(MYIOC_s_ERR_FMT "_send_handshake FAILED!" | 398 | (ioctl->ioc->facts.MsgVersion >= MPI_VERSION_01_05)) |
401 | " (hd %p, ioc %p, mf %p) \n", hd->ioc->name, hd, | 399 | mpt_put_msg_frame_hi_pri(mptctl_id, ioctl->ioc, mf); |
402 | hd->ioc, mf)); | 400 | else { |
403 | goto mptctl_bus_reset_done; | 401 | retval = mpt_send_handshake_request(mptctl_id, ioctl->ioc, |
402 | sizeof(SCSITaskMgmt_t), (u32*)pScsiTm, CAN_SLEEP); | ||
403 | if (retval != 0) { | ||
404 | dfailprintk(ioctl->ioc, printk(MYIOC_s_ERR_FMT "_send_handshake FAILED!" | ||
405 | " (hd %p, ioc %p, mf %p) \n", hd->ioc->name, hd, | ||
406 | hd->ioc, mf)); | ||
407 | goto mptctl_bus_reset_done; | ||
408 | } | ||
404 | } | 409 | } |
405 | 410 | ||
406 | /* Now wait for the command to complete */ | 411 | /* Now wait for the command to complete */ |
@@ -444,7 +449,7 @@ mptctl_free_tm_flags(MPT_ADAPTER *ioc) | |||
444 | MPT_SCSI_HOST * hd; | 449 | MPT_SCSI_HOST * hd; |
445 | unsigned long flags; | 450 | unsigned long flags; |
446 | 451 | ||
447 | hd = (MPT_SCSI_HOST *) ioc->sh->hostdata; | 452 | hd = shost_priv(ioc->sh); |
448 | if (hd == NULL) | 453 | if (hd == NULL) |
449 | return; | 454 | return; |
450 | 455 | ||
@@ -468,7 +473,7 @@ static int | |||
468 | mptctl_ioc_reset(MPT_ADAPTER *ioc, int reset_phase) | 473 | mptctl_ioc_reset(MPT_ADAPTER *ioc, int reset_phase) |
469 | { | 474 | { |
470 | MPT_IOCTL *ioctl = ioc->ioctl; | 475 | MPT_IOCTL *ioctl = ioc->ioctl; |
471 | dctlprintk(ioc, printk(MYIOC_s_DEBUG_FMT ": IOC %s_reset routed to IOCTL driver!\n",ioc->name, | 476 | dctlprintk(ioc, printk(MYIOC_s_DEBUG_FMT "IOC %s_reset routed to IOCTL driver!\n", ioc->name, |
472 | reset_phase==MPT_IOC_SETUP_RESET ? "setup" : ( | 477 | reset_phase==MPT_IOC_SETUP_RESET ? "setup" : ( |
473 | reset_phase==MPT_IOC_PRE_RESET ? "pre" : "post"))); | 478 | reset_phase==MPT_IOC_PRE_RESET ? "pre" : "post"))); |
474 | 479 | ||
@@ -574,7 +579,7 @@ __mptctl_ioctl(struct file *file, unsigned int cmd, unsigned long arg) | |||
574 | MPT_ADAPTER *iocp = NULL; | 579 | MPT_ADAPTER *iocp = NULL; |
575 | 580 | ||
576 | if (copy_from_user(&khdr, uhdr, sizeof(khdr))) { | 581 | if (copy_from_user(&khdr, uhdr, sizeof(khdr))) { |
577 | printk(KERN_ERR "%s::mptctl_ioctl() @%d - " | 582 | printk(KERN_ERR MYNAM "%s::mptctl_ioctl() @%d - " |
578 | "Unable to copy mpt_ioctl_header data @ %p\n", | 583 | "Unable to copy mpt_ioctl_header data @ %p\n", |
579 | __FILE__, __LINE__, uhdr); | 584 | __FILE__, __LINE__, uhdr); |
580 | return -EFAULT; | 585 | return -EFAULT; |
@@ -587,13 +592,13 @@ __mptctl_ioctl(struct file *file, unsigned int cmd, unsigned long arg) | |||
587 | iocnumX = khdr.iocnum & 0xFF; | 592 | iocnumX = khdr.iocnum & 0xFF; |
588 | if (((iocnum = mpt_verify_adapter(iocnumX, &iocp)) < 0) || | 593 | if (((iocnum = mpt_verify_adapter(iocnumX, &iocp)) < 0) || |
589 | (iocp == NULL)) { | 594 | (iocp == NULL)) { |
590 | printk(KERN_DEBUG "%s::mptctl_ioctl() @%d - ioc%d not found!\n", | 595 | printk(KERN_DEBUG MYNAM "%s::mptctl_ioctl() @%d - ioc%d not found!\n", |
591 | __FILE__, __LINE__, iocnumX); | 596 | __FILE__, __LINE__, iocnumX); |
592 | return -ENODEV; | 597 | return -ENODEV; |
593 | } | 598 | } |
594 | 599 | ||
595 | if (!iocp->active) { | 600 | if (!iocp->active) { |
596 | printk(KERN_DEBUG "%s::mptctl_ioctl() @%d - Controller disabled.\n", | 601 | printk(KERN_DEBUG MYNAM "%s::mptctl_ioctl() @%d - Controller disabled.\n", |
597 | __FILE__, __LINE__); | 602 | __FILE__, __LINE__); |
598 | return -EFAULT; | 603 | return -EFAULT; |
599 | } | 604 | } |
@@ -660,14 +665,14 @@ static int mptctl_do_reset(unsigned long arg) | |||
660 | MPT_ADAPTER *iocp; | 665 | MPT_ADAPTER *iocp; |
661 | 666 | ||
662 | if (copy_from_user(&krinfo, urinfo, sizeof(struct mpt_ioctl_diag_reset))) { | 667 | if (copy_from_user(&krinfo, urinfo, sizeof(struct mpt_ioctl_diag_reset))) { |
663 | printk(KERN_ERR "%s@%d::mptctl_do_reset - " | 668 | printk(KERN_ERR MYNAM "%s@%d::mptctl_do_reset - " |
664 | "Unable to copy mpt_ioctl_diag_reset struct @ %p\n", | 669 | "Unable to copy mpt_ioctl_diag_reset struct @ %p\n", |
665 | __FILE__, __LINE__, urinfo); | 670 | __FILE__, __LINE__, urinfo); |
666 | return -EFAULT; | 671 | return -EFAULT; |
667 | } | 672 | } |
668 | 673 | ||
669 | if (mpt_verify_adapter(krinfo.hdr.iocnum, &iocp) < 0) { | 674 | if (mpt_verify_adapter(krinfo.hdr.iocnum, &iocp) < 0) { |
670 | printk(KERN_DEBUG "%s@%d::mptctl_do_reset - ioc%d not found!\n", | 675 | printk(KERN_DEBUG MYNAM "%s@%d::mptctl_do_reset - ioc%d not found!\n", |
671 | __FILE__, __LINE__, krinfo.hdr.iocnum); | 676 | __FILE__, __LINE__, krinfo.hdr.iocnum); |
672 | return -ENODEV; /* (-6) No such device or address */ | 677 | return -ENODEV; /* (-6) No such device or address */ |
673 | } | 678 | } |
@@ -676,8 +681,8 @@ static int mptctl_do_reset(unsigned long arg) | |||
676 | iocp->name)); | 681 | iocp->name)); |
677 | 682 | ||
678 | if (mpt_HardResetHandler(iocp, CAN_SLEEP) != 0) { | 683 | if (mpt_HardResetHandler(iocp, CAN_SLEEP) != 0) { |
679 | printk (KERN_ERR "%s@%d::mptctl_do_reset - reset failed.\n", | 684 | printk (MYIOC_s_ERR_FMT "%s@%d::mptctl_do_reset - reset failed.\n", |
680 | __FILE__, __LINE__); | 685 | iocp->name, __FILE__, __LINE__); |
681 | return -1; | 686 | return -1; |
682 | } | 687 | } |
683 | 688 | ||
@@ -708,7 +713,7 @@ mptctl_fw_download(unsigned long arg) | |||
708 | struct mpt_fw_xfer kfwdl; | 713 | struct mpt_fw_xfer kfwdl; |
709 | 714 | ||
710 | if (copy_from_user(&kfwdl, ufwdl, sizeof(struct mpt_fw_xfer))) { | 715 | if (copy_from_user(&kfwdl, ufwdl, sizeof(struct mpt_fw_xfer))) { |
711 | printk(KERN_ERR "%s@%d::_ioctl_fwdl - " | 716 | printk(KERN_ERR MYNAM "%s@%d::_ioctl_fwdl - " |
712 | "Unable to copy mpt_fw_xfer struct @ %p\n", | 717 | "Unable to copy mpt_fw_xfer struct @ %p\n", |
713 | __FILE__, __LINE__, ufwdl); | 718 | __FILE__, __LINE__, ufwdl); |
714 | return -EFAULT; | 719 | return -EFAULT; |
@@ -756,7 +761,8 @@ mptctl_do_fw_download(int ioc, char __user *ufwbuf, size_t fwlen) | |||
756 | pFWDownloadReply_t ReplyMsg = NULL; | 761 | pFWDownloadReply_t ReplyMsg = NULL; |
757 | 762 | ||
758 | if (mpt_verify_adapter(ioc, &iocp) < 0) { | 763 | if (mpt_verify_adapter(ioc, &iocp) < 0) { |
759 | printk(KERN_DEBUG "ioctl_fwdl - ioc%d not found!\n", ioc); | 764 | printk(KERN_DEBUG MYNAM "ioctl_fwdl - ioc%d not found!\n", |
765 | ioc); | ||
760 | return -ENODEV; /* (-6) No such device or address */ | 766 | return -ENODEV; /* (-6) No such device or address */ |
761 | } else { | 767 | } else { |
762 | 768 | ||
@@ -868,9 +874,9 @@ mptctl_do_fw_download(int ioc, char __user *ufwbuf, size_t fwlen) | |||
868 | mpt_add_sge(sgOut, sgIn->FlagsLength, sgIn->Address); | 874 | mpt_add_sge(sgOut, sgIn->FlagsLength, sgIn->Address); |
869 | n++; | 875 | n++; |
870 | if (copy_from_user(bl->kptr, ufwbuf+fw_bytes_copied, bl->len)) { | 876 | if (copy_from_user(bl->kptr, ufwbuf+fw_bytes_copied, bl->len)) { |
871 | printk(KERN_ERR "%s@%d::_ioctl_fwdl - " | 877 | printk(MYIOC_s_ERR_FMT "%s@%d::_ioctl_fwdl - " |
872 | "Unable to copy f/w buffer hunk#%d @ %p\n", | 878 | "Unable to copy f/w buffer hunk#%d @ %p\n", |
873 | __FILE__, __LINE__, n, ufwbuf); | 879 | iocp->name, __FILE__, __LINE__, n, ufwbuf); |
874 | goto fwdl_out; | 880 | goto fwdl_out; |
875 | } | 881 | } |
876 | fw_bytes_copied += bl->len; | 882 | fw_bytes_copied += bl->len; |
@@ -906,21 +912,22 @@ mptctl_do_fw_download(int ioc, char __user *ufwbuf, size_t fwlen) | |||
906 | ReplyMsg = (pFWDownloadReply_t)iocp->ioctl->ReplyFrame; | 912 | ReplyMsg = (pFWDownloadReply_t)iocp->ioctl->ReplyFrame; |
907 | iocstat = le16_to_cpu(ReplyMsg->IOCStatus) & MPI_IOCSTATUS_MASK; | 913 | iocstat = le16_to_cpu(ReplyMsg->IOCStatus) & MPI_IOCSTATUS_MASK; |
908 | if (iocstat == MPI_IOCSTATUS_SUCCESS) { | 914 | if (iocstat == MPI_IOCSTATUS_SUCCESS) { |
909 | printk(KERN_INFO MYNAM ": F/W update successfully sent to %s!\n", iocp->name); | 915 | printk(MYIOC_s_INFO_FMT "F/W update successfull!\n", iocp->name); |
910 | return 0; | 916 | return 0; |
911 | } else if (iocstat == MPI_IOCSTATUS_INVALID_FUNCTION) { | 917 | } else if (iocstat == MPI_IOCSTATUS_INVALID_FUNCTION) { |
912 | printk(KERN_WARNING MYNAM ": ?Hmmm... %s says it doesn't support F/W download!?!\n", | 918 | printk(MYIOC_s_WARN_FMT "Hmmm... F/W download not supported!?!\n", |
913 | iocp->name); | 919 | iocp->name); |
914 | printk(KERN_WARNING MYNAM ": (time to go bang on somebodies door)\n"); | 920 | printk(MYIOC_s_WARN_FMT "(time to go bang on somebodies door)\n", |
921 | iocp->name); | ||
915 | return -EBADRQC; | 922 | return -EBADRQC; |
916 | } else if (iocstat == MPI_IOCSTATUS_BUSY) { | 923 | } else if (iocstat == MPI_IOCSTATUS_BUSY) { |
917 | printk(KERN_WARNING MYNAM ": Warning! %s says: IOC_BUSY!\n", iocp->name); | 924 | printk(MYIOC_s_WARN_FMT "IOC_BUSY!\n", iocp->name); |
918 | printk(KERN_WARNING MYNAM ": (try again later?)\n"); | 925 | printk(MYIOC_s_WARN_FMT "(try again later?)\n", iocp->name); |
919 | return -EBUSY; | 926 | return -EBUSY; |
920 | } else { | 927 | } else { |
921 | printk(KERN_WARNING MYNAM "::ioctl_fwdl() ERROR! %s returned [bad] status = %04xh\n", | 928 | printk(MYIOC_s_WARN_FMT "ioctl_fwdl() returned [bad] status = %04xh\n", |
922 | iocp->name, iocstat); | 929 | iocp->name, iocstat); |
923 | printk(KERN_WARNING MYNAM ": (bad VooDoo)\n"); | 930 | printk(MYIOC_s_WARN_FMT "(bad VooDoo)\n", iocp->name); |
924 | return -ENOMSG; | 931 | return -ENOMSG; |
925 | } | 932 | } |
926 | return 0; | 933 | return 0; |
@@ -970,10 +977,9 @@ kbuf_alloc_2_sgl(int bytes, u32 sgdir, int sge_offset, int *frags, | |||
970 | * structures for the SG elements. | 977 | * structures for the SG elements. |
971 | */ | 978 | */ |
972 | i = MAX_SGL_BYTES / 8; | 979 | i = MAX_SGL_BYTES / 8; |
973 | buflist = kmalloc(i, GFP_USER); | 980 | buflist = kzalloc(i, GFP_USER); |
974 | if (buflist == NULL) | 981 | if (!buflist) |
975 | return NULL; | 982 | return NULL; |
976 | memset(buflist, 0, i); | ||
977 | buflist_ent = 0; | 983 | buflist_ent = 0; |
978 | 984 | ||
979 | /* Allocate a single block of memory to store the sg elements and | 985 | /* Allocate a single block of memory to store the sg elements and |
@@ -1008,10 +1014,10 @@ kbuf_alloc_2_sgl(int bytes, u32 sgdir, int sge_offset, int *frags, | |||
1008 | if (buflist[buflist_ent].kptr == NULL) { | 1014 | if (buflist[buflist_ent].kptr == NULL) { |
1009 | alloc_sz = alloc_sz / 2; | 1015 | alloc_sz = alloc_sz / 2; |
1010 | if (alloc_sz == 0) { | 1016 | if (alloc_sz == 0) { |
1011 | printk(KERN_WARNING MYNAM "-SG: No can do - " | 1017 | printk(MYIOC_s_WARN_FMT "-SG: No can do - " |
1012 | "not enough memory! :-(\n"); | 1018 | "not enough memory! :-(\n", ioc->name); |
1013 | printk(KERN_WARNING MYNAM "-SG: (freeing %d frags)\n", | 1019 | printk(MYIOC_s_WARN_FMT "-SG: (freeing %d frags)\n", |
1014 | numfrags); | 1020 | ioc->name, numfrags); |
1015 | goto free_and_fail; | 1021 | goto free_and_fail; |
1016 | } | 1022 | } |
1017 | continue; | 1023 | continue; |
@@ -1034,18 +1040,19 @@ kbuf_alloc_2_sgl(int bytes, u32 sgdir, int sge_offset, int *frags, | |||
1034 | 1040 | ||
1035 | /* Need to chain? */ | 1041 | /* Need to chain? */ |
1036 | if (fragcnt == sg_spill) { | 1042 | if (fragcnt == sg_spill) { |
1037 | printk(KERN_WARNING MYNAM "-SG: No can do - " "Chain required! :-(\n"); | 1043 | printk(MYIOC_s_WARN_FMT |
1038 | printk(KERN_WARNING MYNAM "(freeing %d frags)\n", numfrags); | 1044 | "-SG: No can do - " "Chain required! :-(\n", ioc->name); |
1045 | printk(MYIOC_s_WARN_FMT "(freeing %d frags)\n", ioc->name, numfrags); | ||
1039 | goto free_and_fail; | 1046 | goto free_and_fail; |
1040 | } | 1047 | } |
1041 | 1048 | ||
1042 | /* overflow check... */ | 1049 | /* overflow check... */ |
1043 | if (numfrags*8 > MAX_SGL_BYTES){ | 1050 | if (numfrags*8 > MAX_SGL_BYTES){ |
1044 | /* GRRRRR... */ | 1051 | /* GRRRRR... */ |
1045 | printk(KERN_WARNING MYNAM "-SG: No can do - " | 1052 | printk(MYIOC_s_WARN_FMT "-SG: No can do - " |
1046 | "too many SG frags! :-(\n"); | 1053 | "too many SG frags! :-(\n", ioc->name); |
1047 | printk(KERN_WARNING MYNAM "-SG: (freeing %d frags)\n", | 1054 | printk(MYIOC_s_WARN_FMT "-SG: (freeing %d frags)\n", |
1048 | numfrags); | 1055 | ioc->name, numfrags); |
1049 | goto free_and_fail; | 1056 | goto free_and_fail; |
1050 | } | 1057 | } |
1051 | } | 1058 | } |
@@ -1066,8 +1073,6 @@ kbuf_alloc_2_sgl(int bytes, u32 sgdir, int sge_offset, int *frags, | |||
1066 | 1073 | ||
1067 | free_and_fail: | 1074 | free_and_fail: |
1068 | if (sglbuf != NULL) { | 1075 | if (sglbuf != NULL) { |
1069 | int i; | ||
1070 | |||
1071 | for (i = 0; i < numfrags; i++) { | 1076 | for (i = 0; i < numfrags; i++) { |
1072 | dma_addr_t dma_addr; | 1077 | dma_addr_t dma_addr; |
1073 | u8 *kptr; | 1078 | u8 *kptr; |
@@ -1170,7 +1175,7 @@ mptctl_getiocinfo (unsigned long arg, unsigned int data_size) | |||
1170 | int cim_rev; | 1175 | int cim_rev; |
1171 | u8 revision; | 1176 | u8 revision; |
1172 | struct scsi_device *sdev; | 1177 | struct scsi_device *sdev; |
1173 | VirtDevice *vdev; | 1178 | VirtDevice *vdevice; |
1174 | 1179 | ||
1175 | /* Add of PCI INFO results in unaligned access for | 1180 | /* Add of PCI INFO results in unaligned access for |
1176 | * IA64 and Sparc. Reset long to int. Return no PCI | 1181 | * IA64 and Sparc. Reset long to int. Return no PCI |
@@ -1189,13 +1194,13 @@ mptctl_getiocinfo (unsigned long arg, unsigned int data_size) | |||
1189 | 1194 | ||
1190 | karg = kmalloc(data_size, GFP_KERNEL); | 1195 | karg = kmalloc(data_size, GFP_KERNEL); |
1191 | if (karg == NULL) { | 1196 | if (karg == NULL) { |
1192 | printk(KERN_ERR "%s::mpt_ioctl_iocinfo() @%d - no memory available!\n", | 1197 | printk(KERN_ERR MYNAM "%s::mpt_ioctl_iocinfo() @%d - no memory available!\n", |
1193 | __FILE__, __LINE__); | 1198 | __FILE__, __LINE__); |
1194 | return -ENOMEM; | 1199 | return -ENOMEM; |
1195 | } | 1200 | } |
1196 | 1201 | ||
1197 | if (copy_from_user(karg, uarg, data_size)) { | 1202 | if (copy_from_user(karg, uarg, data_size)) { |
1198 | printk(KERN_ERR "%s@%d::mptctl_getiocinfo - " | 1203 | printk(KERN_ERR MYNAM "%s@%d::mptctl_getiocinfo - " |
1199 | "Unable to read in mpt_ioctl_iocinfo struct @ %p\n", | 1204 | "Unable to read in mpt_ioctl_iocinfo struct @ %p\n", |
1200 | __FILE__, __LINE__, uarg); | 1205 | __FILE__, __LINE__, uarg); |
1201 | kfree(karg); | 1206 | kfree(karg); |
@@ -1204,7 +1209,7 @@ mptctl_getiocinfo (unsigned long arg, unsigned int data_size) | |||
1204 | 1209 | ||
1205 | if (((iocnum = mpt_verify_adapter(karg->hdr.iocnum, &ioc)) < 0) || | 1210 | if (((iocnum = mpt_verify_adapter(karg->hdr.iocnum, &ioc)) < 0) || |
1206 | (ioc == NULL)) { | 1211 | (ioc == NULL)) { |
1207 | printk(KERN_DEBUG "%s::mptctl_getiocinfo() @%d - ioc%d not found!\n", | 1212 | printk(KERN_DEBUG MYNAM "%s::mptctl_getiocinfo() @%d - ioc%d not found!\n", |
1208 | __FILE__, __LINE__, iocnum); | 1213 | __FILE__, __LINE__, iocnum); |
1209 | kfree(karg); | 1214 | kfree(karg); |
1210 | return -ENODEV; | 1215 | return -ENODEV; |
@@ -1212,9 +1217,9 @@ mptctl_getiocinfo (unsigned long arg, unsigned int data_size) | |||
1212 | 1217 | ||
1213 | /* Verify the data transfer size is correct. */ | 1218 | /* Verify the data transfer size is correct. */ |
1214 | if (karg->hdr.maxDataSize != data_size) { | 1219 | if (karg->hdr.maxDataSize != data_size) { |
1215 | printk(KERN_ERR "%s@%d::mptctl_getiocinfo - " | 1220 | printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_getiocinfo - " |
1216 | "Structure size mismatch. Command not completed.\n", | 1221 | "Structure size mismatch. Command not completed.\n", |
1217 | __FILE__, __LINE__); | 1222 | ioc->name, __FILE__, __LINE__); |
1218 | kfree(karg); | 1223 | kfree(karg); |
1219 | return -EFAULT; | 1224 | return -EFAULT; |
1220 | } | 1225 | } |
@@ -1265,8 +1270,8 @@ mptctl_getiocinfo (unsigned long arg, unsigned int data_size) | |||
1265 | karg->numDevices = 0; | 1270 | karg->numDevices = 0; |
1266 | if (ioc->sh) { | 1271 | if (ioc->sh) { |
1267 | shost_for_each_device(sdev, ioc->sh) { | 1272 | shost_for_each_device(sdev, ioc->sh) { |
1268 | vdev = sdev->hostdata; | 1273 | vdevice = sdev->hostdata; |
1269 | if (vdev->vtarget->tflags & | 1274 | if (vdevice->vtarget->tflags & |
1270 | MPT_TARGET_FLAGS_RAID_COMPONENT) | 1275 | MPT_TARGET_FLAGS_RAID_COMPONENT) |
1271 | continue; | 1276 | continue; |
1272 | karg->numDevices++; | 1277 | karg->numDevices++; |
@@ -1290,9 +1295,9 @@ mptctl_getiocinfo (unsigned long arg, unsigned int data_size) | |||
1290 | /* Copy the data from kernel memory to user memory | 1295 | /* Copy the data from kernel memory to user memory |
1291 | */ | 1296 | */ |
1292 | if (copy_to_user((char __user *)arg, karg, data_size)) { | 1297 | if (copy_to_user((char __user *)arg, karg, data_size)) { |
1293 | printk(KERN_ERR "%s@%d::mptctl_getiocinfo - " | 1298 | printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_getiocinfo - " |
1294 | "Unable to write out mpt_ioctl_iocinfo struct @ %p\n", | 1299 | "Unable to write out mpt_ioctl_iocinfo struct @ %p\n", |
1295 | __FILE__, __LINE__, uarg); | 1300 | ioc->name, __FILE__, __LINE__, uarg); |
1296 | kfree(karg); | 1301 | kfree(karg); |
1297 | return -EFAULT; | 1302 | return -EFAULT; |
1298 | } | 1303 | } |
@@ -1317,7 +1322,7 @@ mptctl_gettargetinfo (unsigned long arg) | |||
1317 | struct mpt_ioctl_targetinfo __user *uarg = (void __user *) arg; | 1322 | struct mpt_ioctl_targetinfo __user *uarg = (void __user *) arg; |
1318 | struct mpt_ioctl_targetinfo karg; | 1323 | struct mpt_ioctl_targetinfo karg; |
1319 | MPT_ADAPTER *ioc; | 1324 | MPT_ADAPTER *ioc; |
1320 | VirtDevice *vdev; | 1325 | VirtDevice *vdevice; |
1321 | char *pmem; | 1326 | char *pmem; |
1322 | int *pdata; | 1327 | int *pdata; |
1323 | int iocnum; | 1328 | int iocnum; |
@@ -1329,7 +1334,7 @@ mptctl_gettargetinfo (unsigned long arg) | |||
1329 | struct scsi_device *sdev; | 1334 | struct scsi_device *sdev; |
1330 | 1335 | ||
1331 | if (copy_from_user(&karg, uarg, sizeof(struct mpt_ioctl_targetinfo))) { | 1336 | if (copy_from_user(&karg, uarg, sizeof(struct mpt_ioctl_targetinfo))) { |
1332 | printk(KERN_ERR "%s@%d::mptctl_gettargetinfo - " | 1337 | printk(KERN_ERR MYNAM "%s@%d::mptctl_gettargetinfo - " |
1333 | "Unable to read in mpt_ioctl_targetinfo struct @ %p\n", | 1338 | "Unable to read in mpt_ioctl_targetinfo struct @ %p\n", |
1334 | __FILE__, __LINE__, uarg); | 1339 | __FILE__, __LINE__, uarg); |
1335 | return -EFAULT; | 1340 | return -EFAULT; |
@@ -1337,7 +1342,7 @@ mptctl_gettargetinfo (unsigned long arg) | |||
1337 | 1342 | ||
1338 | if (((iocnum = mpt_verify_adapter(karg.hdr.iocnum, &ioc)) < 0) || | 1343 | if (((iocnum = mpt_verify_adapter(karg.hdr.iocnum, &ioc)) < 0) || |
1339 | (ioc == NULL)) { | 1344 | (ioc == NULL)) { |
1340 | printk(KERN_DEBUG "%s::mptctl_gettargetinfo() @%d - ioc%d not found!\n", | 1345 | printk(KERN_DEBUG MYNAM "%s::mptctl_gettargetinfo() @%d - ioc%d not found!\n", |
1341 | __FILE__, __LINE__, iocnum); | 1346 | __FILE__, __LINE__, iocnum); |
1342 | return -ENODEV; | 1347 | return -ENODEV; |
1343 | } | 1348 | } |
@@ -1353,8 +1358,8 @@ mptctl_gettargetinfo (unsigned long arg) | |||
1353 | port = karg.hdr.port; | 1358 | port = karg.hdr.port; |
1354 | 1359 | ||
1355 | if (maxWordsLeft <= 0) { | 1360 | if (maxWordsLeft <= 0) { |
1356 | printk(KERN_ERR "%s::mptctl_gettargetinfo() @%d - no memory available!\n", | 1361 | printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_gettargetinfo() - no memory available!\n", |
1357 | __FILE__, __LINE__); | 1362 | ioc->name, __FILE__, __LINE__); |
1358 | return -ENOMEM; | 1363 | return -ENOMEM; |
1359 | } | 1364 | } |
1360 | 1365 | ||
@@ -1372,13 +1377,12 @@ mptctl_gettargetinfo (unsigned long arg) | |||
1372 | * 15- 8: Bus Number | 1377 | * 15- 8: Bus Number |
1373 | * 7- 0: Target ID | 1378 | * 7- 0: Target ID |
1374 | */ | 1379 | */ |
1375 | pmem = kmalloc(numBytes, GFP_KERNEL); | 1380 | pmem = kzalloc(numBytes, GFP_KERNEL); |
1376 | if (pmem == NULL) { | 1381 | if (!pmem) { |
1377 | printk(KERN_ERR "%s::mptctl_gettargetinfo() @%d - no memory available!\n", | 1382 | printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_gettargetinfo() - no memory available!\n", |
1378 | __FILE__, __LINE__); | 1383 | ioc->name, __FILE__, __LINE__); |
1379 | return -ENOMEM; | 1384 | return -ENOMEM; |
1380 | } | 1385 | } |
1381 | memset(pmem, 0, numBytes); | ||
1382 | pdata = (int *) pmem; | 1386 | pdata = (int *) pmem; |
1383 | 1387 | ||
1384 | /* Get number of devices | 1388 | /* Get number of devices |
@@ -1387,13 +1391,13 @@ mptctl_gettargetinfo (unsigned long arg) | |||
1387 | shost_for_each_device(sdev, ioc->sh) { | 1391 | shost_for_each_device(sdev, ioc->sh) { |
1388 | if (!maxWordsLeft) | 1392 | if (!maxWordsLeft) |
1389 | continue; | 1393 | continue; |
1390 | vdev = sdev->hostdata; | 1394 | vdevice = sdev->hostdata; |
1391 | if (vdev->vtarget->tflags & | 1395 | if (vdevice->vtarget->tflags & |
1392 | MPT_TARGET_FLAGS_RAID_COMPONENT) | 1396 | MPT_TARGET_FLAGS_RAID_COMPONENT) |
1393 | continue; | 1397 | continue; |
1394 | lun = (vdev->vtarget->raidVolume) ? 0x80 : vdev->lun; | 1398 | lun = (vdevice->vtarget->raidVolume) ? 0x80 : vdevice->lun; |
1395 | *pdata = (((u8)lun << 16) + (vdev->vtarget->channel << 8) + | 1399 | *pdata = (((u8)lun << 16) + (vdevice->vtarget->channel << 8) + |
1396 | (vdev->vtarget->id )); | 1400 | (vdevice->vtarget->id )); |
1397 | pdata++; | 1401 | pdata++; |
1398 | numDevices++; | 1402 | numDevices++; |
1399 | --maxWordsLeft; | 1403 | --maxWordsLeft; |
@@ -1405,9 +1409,9 @@ mptctl_gettargetinfo (unsigned long arg) | |||
1405 | */ | 1409 | */ |
1406 | if (copy_to_user((char __user *)arg, &karg, | 1410 | if (copy_to_user((char __user *)arg, &karg, |
1407 | sizeof(struct mpt_ioctl_targetinfo))) { | 1411 | sizeof(struct mpt_ioctl_targetinfo))) { |
1408 | printk(KERN_ERR "%s@%d::mptctl_gettargetinfo - " | 1412 | printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_gettargetinfo - " |
1409 | "Unable to write out mpt_ioctl_targetinfo struct @ %p\n", | 1413 | "Unable to write out mpt_ioctl_targetinfo struct @ %p\n", |
1410 | __FILE__, __LINE__, uarg); | 1414 | ioc->name, __FILE__, __LINE__, uarg); |
1411 | kfree(pmem); | 1415 | kfree(pmem); |
1412 | return -EFAULT; | 1416 | return -EFAULT; |
1413 | } | 1417 | } |
@@ -1415,9 +1419,9 @@ mptctl_gettargetinfo (unsigned long arg) | |||
1415 | /* Copy the remaining data from kernel memory to user memory | 1419 | /* Copy the remaining data from kernel memory to user memory |
1416 | */ | 1420 | */ |
1417 | if (copy_to_user(uarg->targetInfo, pmem, numBytes)) { | 1421 | if (copy_to_user(uarg->targetInfo, pmem, numBytes)) { |
1418 | printk(KERN_ERR "%s@%d::mptctl_gettargetinfo - " | 1422 | printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_gettargetinfo - " |
1419 | "Unable to write out mpt_ioctl_targetinfo struct @ %p\n", | 1423 | "Unable to write out mpt_ioctl_targetinfo struct @ %p\n", |
1420 | __FILE__, __LINE__, pdata); | 1424 | ioc->name, __FILE__, __LINE__, pdata); |
1421 | kfree(pmem); | 1425 | kfree(pmem); |
1422 | return -EFAULT; | 1426 | return -EFAULT; |
1423 | } | 1427 | } |
@@ -1444,7 +1448,7 @@ mptctl_readtest (unsigned long arg) | |||
1444 | int iocnum; | 1448 | int iocnum; |
1445 | 1449 | ||
1446 | if (copy_from_user(&karg, uarg, sizeof(struct mpt_ioctl_test))) { | 1450 | if (copy_from_user(&karg, uarg, sizeof(struct mpt_ioctl_test))) { |
1447 | printk(KERN_ERR "%s@%d::mptctl_readtest - " | 1451 | printk(KERN_ERR MYNAM "%s@%d::mptctl_readtest - " |
1448 | "Unable to read in mpt_ioctl_test struct @ %p\n", | 1452 | "Unable to read in mpt_ioctl_test struct @ %p\n", |
1449 | __FILE__, __LINE__, uarg); | 1453 | __FILE__, __LINE__, uarg); |
1450 | return -EFAULT; | 1454 | return -EFAULT; |
@@ -1452,7 +1456,7 @@ mptctl_readtest (unsigned long arg) | |||
1452 | 1456 | ||
1453 | if (((iocnum = mpt_verify_adapter(karg.hdr.iocnum, &ioc)) < 0) || | 1457 | if (((iocnum = mpt_verify_adapter(karg.hdr.iocnum, &ioc)) < 0) || |
1454 | (ioc == NULL)) { | 1458 | (ioc == NULL)) { |
1455 | printk(KERN_DEBUG "%s::mptctl_readtest() @%d - ioc%d not found!\n", | 1459 | printk(KERN_DEBUG MYNAM "%s::mptctl_readtest() @%d - ioc%d not found!\n", |
1456 | __FILE__, __LINE__, iocnum); | 1460 | __FILE__, __LINE__, iocnum); |
1457 | return -ENODEV; | 1461 | return -ENODEV; |
1458 | } | 1462 | } |
@@ -1476,9 +1480,9 @@ mptctl_readtest (unsigned long arg) | |||
1476 | /* Copy the data from kernel memory to user memory | 1480 | /* Copy the data from kernel memory to user memory |
1477 | */ | 1481 | */ |
1478 | if (copy_to_user((char __user *)arg, &karg, sizeof(struct mpt_ioctl_test))) { | 1482 | if (copy_to_user((char __user *)arg, &karg, sizeof(struct mpt_ioctl_test))) { |
1479 | printk(KERN_ERR "%s@%d::mptctl_readtest - " | 1483 | printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_readtest - " |
1480 | "Unable to write out mpt_ioctl_test struct @ %p\n", | 1484 | "Unable to write out mpt_ioctl_test struct @ %p\n", |
1481 | __FILE__, __LINE__, uarg); | 1485 | ioc->name, __FILE__, __LINE__, uarg); |
1482 | return -EFAULT; | 1486 | return -EFAULT; |
1483 | } | 1487 | } |
1484 | 1488 | ||
@@ -1505,7 +1509,7 @@ mptctl_eventquery (unsigned long arg) | |||
1505 | int iocnum; | 1509 | int iocnum; |
1506 | 1510 | ||
1507 | if (copy_from_user(&karg, uarg, sizeof(struct mpt_ioctl_eventquery))) { | 1511 | if (copy_from_user(&karg, uarg, sizeof(struct mpt_ioctl_eventquery))) { |
1508 | printk(KERN_ERR "%s@%d::mptctl_eventquery - " | 1512 | printk(KERN_ERR MYNAM "%s@%d::mptctl_eventquery - " |
1509 | "Unable to read in mpt_ioctl_eventquery struct @ %p\n", | 1513 | "Unable to read in mpt_ioctl_eventquery struct @ %p\n", |
1510 | __FILE__, __LINE__, uarg); | 1514 | __FILE__, __LINE__, uarg); |
1511 | return -EFAULT; | 1515 | return -EFAULT; |
@@ -1513,7 +1517,7 @@ mptctl_eventquery (unsigned long arg) | |||
1513 | 1517 | ||
1514 | if (((iocnum = mpt_verify_adapter(karg.hdr.iocnum, &ioc)) < 0) || | 1518 | if (((iocnum = mpt_verify_adapter(karg.hdr.iocnum, &ioc)) < 0) || |
1515 | (ioc == NULL)) { | 1519 | (ioc == NULL)) { |
1516 | printk(KERN_DEBUG "%s::mptctl_eventquery() @%d - ioc%d not found!\n", | 1520 | printk(KERN_DEBUG MYNAM "%s::mptctl_eventquery() @%d - ioc%d not found!\n", |
1517 | __FILE__, __LINE__, iocnum); | 1521 | __FILE__, __LINE__, iocnum); |
1518 | return -ENODEV; | 1522 | return -ENODEV; |
1519 | } | 1523 | } |
@@ -1526,9 +1530,9 @@ mptctl_eventquery (unsigned long arg) | |||
1526 | /* Copy the data from kernel memory to user memory | 1530 | /* Copy the data from kernel memory to user memory |
1527 | */ | 1531 | */ |
1528 | if (copy_to_user((char __user *)arg, &karg, sizeof(struct mpt_ioctl_eventquery))) { | 1532 | if (copy_to_user((char __user *)arg, &karg, sizeof(struct mpt_ioctl_eventquery))) { |
1529 | printk(KERN_ERR "%s@%d::mptctl_eventquery - " | 1533 | printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_eventquery - " |
1530 | "Unable to write out mpt_ioctl_eventquery struct @ %p\n", | 1534 | "Unable to write out mpt_ioctl_eventquery struct @ %p\n", |
1531 | __FILE__, __LINE__, uarg); | 1535 | ioc->name, __FILE__, __LINE__, uarg); |
1532 | return -EFAULT; | 1536 | return -EFAULT; |
1533 | } | 1537 | } |
1534 | return 0; | 1538 | return 0; |
@@ -1544,7 +1548,7 @@ mptctl_eventenable (unsigned long arg) | |||
1544 | int iocnum; | 1548 | int iocnum; |
1545 | 1549 | ||
1546 | if (copy_from_user(&karg, uarg, sizeof(struct mpt_ioctl_eventenable))) { | 1550 | if (copy_from_user(&karg, uarg, sizeof(struct mpt_ioctl_eventenable))) { |
1547 | printk(KERN_ERR "%s@%d::mptctl_eventenable - " | 1551 | printk(KERN_ERR MYNAM "%s@%d::mptctl_eventenable - " |
1548 | "Unable to read in mpt_ioctl_eventenable struct @ %p\n", | 1552 | "Unable to read in mpt_ioctl_eventenable struct @ %p\n", |
1549 | __FILE__, __LINE__, uarg); | 1553 | __FILE__, __LINE__, uarg); |
1550 | return -EFAULT; | 1554 | return -EFAULT; |
@@ -1552,7 +1556,7 @@ mptctl_eventenable (unsigned long arg) | |||
1552 | 1556 | ||
1553 | if (((iocnum = mpt_verify_adapter(karg.hdr.iocnum, &ioc)) < 0) || | 1557 | if (((iocnum = mpt_verify_adapter(karg.hdr.iocnum, &ioc)) < 0) || |
1554 | (ioc == NULL)) { | 1558 | (ioc == NULL)) { |
1555 | printk(KERN_DEBUG "%s::mptctl_eventenable() @%d - ioc%d not found!\n", | 1559 | printk(KERN_DEBUG MYNAM "%s::mptctl_eventenable() @%d - ioc%d not found!\n", |
1556 | __FILE__, __LINE__, iocnum); | 1560 | __FILE__, __LINE__, iocnum); |
1557 | return -ENODEV; | 1561 | return -ENODEV; |
1558 | } | 1562 | } |
@@ -1563,12 +1567,13 @@ mptctl_eventenable (unsigned long arg) | |||
1563 | /* Have not yet allocated memory - do so now. | 1567 | /* Have not yet allocated memory - do so now. |
1564 | */ | 1568 | */ |
1565 | int sz = MPTCTL_EVENT_LOG_SIZE * sizeof(MPT_IOCTL_EVENTS); | 1569 | int sz = MPTCTL_EVENT_LOG_SIZE * sizeof(MPT_IOCTL_EVENTS); |
1566 | ioc->events = kmalloc(sz, GFP_KERNEL); | 1570 | ioc->events = kzalloc(sz, GFP_KERNEL); |
1567 | if (ioc->events == NULL) { | 1571 | if (!ioc->events) { |
1568 | printk(KERN_ERR MYNAM ": ERROR - Insufficient memory to add adapter!\n"); | 1572 | printk(MYIOC_s_ERR_FMT |
1573 | ": ERROR - Insufficient memory to add adapter!\n", | ||
1574 | ioc->name); | ||
1569 | return -ENOMEM; | 1575 | return -ENOMEM; |
1570 | } | 1576 | } |
1571 | memset(ioc->events, 0, sz); | ||
1572 | ioc->alloc_total += sz; | 1577 | ioc->alloc_total += sz; |
1573 | 1578 | ||
1574 | ioc->eventContext = 0; | 1579 | ioc->eventContext = 0; |
@@ -1592,7 +1597,7 @@ mptctl_eventreport (unsigned long arg) | |||
1592 | int numBytes, maxEvents, max; | 1597 | int numBytes, maxEvents, max; |
1593 | 1598 | ||
1594 | if (copy_from_user(&karg, uarg, sizeof(struct mpt_ioctl_eventreport))) { | 1599 | if (copy_from_user(&karg, uarg, sizeof(struct mpt_ioctl_eventreport))) { |
1595 | printk(KERN_ERR "%s@%d::mptctl_eventreport - " | 1600 | printk(KERN_ERR MYNAM "%s@%d::mptctl_eventreport - " |
1596 | "Unable to read in mpt_ioctl_eventreport struct @ %p\n", | 1601 | "Unable to read in mpt_ioctl_eventreport struct @ %p\n", |
1597 | __FILE__, __LINE__, uarg); | 1602 | __FILE__, __LINE__, uarg); |
1598 | return -EFAULT; | 1603 | return -EFAULT; |
@@ -1600,7 +1605,7 @@ mptctl_eventreport (unsigned long arg) | |||
1600 | 1605 | ||
1601 | if (((iocnum = mpt_verify_adapter(karg.hdr.iocnum, &ioc)) < 0) || | 1606 | if (((iocnum = mpt_verify_adapter(karg.hdr.iocnum, &ioc)) < 0) || |
1602 | (ioc == NULL)) { | 1607 | (ioc == NULL)) { |
1603 | printk(KERN_DEBUG "%s::mptctl_eventreport() @%d - ioc%d not found!\n", | 1608 | printk(KERN_DEBUG MYNAM "%s::mptctl_eventreport() @%d - ioc%d not found!\n", |
1604 | __FILE__, __LINE__, iocnum); | 1609 | __FILE__, __LINE__, iocnum); |
1605 | return -ENODEV; | 1610 | return -ENODEV; |
1606 | } | 1611 | } |
@@ -1626,9 +1631,9 @@ mptctl_eventreport (unsigned long arg) | |||
1626 | */ | 1631 | */ |
1627 | numBytes = max * sizeof(MPT_IOCTL_EVENTS); | 1632 | numBytes = max * sizeof(MPT_IOCTL_EVENTS); |
1628 | if (copy_to_user(uarg->eventData, ioc->events, numBytes)) { | 1633 | if (copy_to_user(uarg->eventData, ioc->events, numBytes)) { |
1629 | printk(KERN_ERR "%s@%d::mptctl_eventreport - " | 1634 | printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_eventreport - " |
1630 | "Unable to write out mpt_ioctl_eventreport struct @ %p\n", | 1635 | "Unable to write out mpt_ioctl_eventreport struct @ %p\n", |
1631 | __FILE__, __LINE__, ioc->events); | 1636 | ioc->name, __FILE__, __LINE__, ioc->events); |
1632 | return -EFAULT; | 1637 | return -EFAULT; |
1633 | } | 1638 | } |
1634 | 1639 | ||
@@ -1646,7 +1651,7 @@ mptctl_replace_fw (unsigned long arg) | |||
1646 | int newFwSize; | 1651 | int newFwSize; |
1647 | 1652 | ||
1648 | if (copy_from_user(&karg, uarg, sizeof(struct mpt_ioctl_replace_fw))) { | 1653 | if (copy_from_user(&karg, uarg, sizeof(struct mpt_ioctl_replace_fw))) { |
1649 | printk(KERN_ERR "%s@%d::mptctl_replace_fw - " | 1654 | printk(KERN_ERR MYNAM "%s@%d::mptctl_replace_fw - " |
1650 | "Unable to read in mpt_ioctl_replace_fw struct @ %p\n", | 1655 | "Unable to read in mpt_ioctl_replace_fw struct @ %p\n", |
1651 | __FILE__, __LINE__, uarg); | 1656 | __FILE__, __LINE__, uarg); |
1652 | return -EFAULT; | 1657 | return -EFAULT; |
@@ -1654,7 +1659,7 @@ mptctl_replace_fw (unsigned long arg) | |||
1654 | 1659 | ||
1655 | if (((iocnum = mpt_verify_adapter(karg.hdr.iocnum, &ioc)) < 0) || | 1660 | if (((iocnum = mpt_verify_adapter(karg.hdr.iocnum, &ioc)) < 0) || |
1656 | (ioc == NULL)) { | 1661 | (ioc == NULL)) { |
1657 | printk(KERN_DEBUG "%s::mptctl_replace_fw() @%d - ioc%d not found!\n", | 1662 | printk(KERN_DEBUG MYNAM "%s::mptctl_replace_fw() @%d - ioc%d not found!\n", |
1658 | __FILE__, __LINE__, iocnum); | 1663 | __FILE__, __LINE__, iocnum); |
1659 | return -ENODEV; | 1664 | return -ENODEV; |
1660 | } | 1665 | } |
@@ -1684,9 +1689,9 @@ mptctl_replace_fw (unsigned long arg) | |||
1684 | /* Copy the data from user memory to kernel space | 1689 | /* Copy the data from user memory to kernel space |
1685 | */ | 1690 | */ |
1686 | if (copy_from_user(ioc->cached_fw, uarg->newImage, newFwSize)) { | 1691 | if (copy_from_user(ioc->cached_fw, uarg->newImage, newFwSize)) { |
1687 | printk(KERN_ERR "%s@%d::mptctl_replace_fw - " | 1692 | printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_replace_fw - " |
1688 | "Unable to read in mpt_ioctl_replace_fw image " | 1693 | "Unable to read in mpt_ioctl_replace_fw image " |
1689 | "@ %p\n", __FILE__, __LINE__, uarg); | 1694 | "@ %p\n", ioc->name, __FILE__, __LINE__, uarg); |
1690 | mpt_free_fw_memory(ioc); | 1695 | mpt_free_fw_memory(ioc); |
1691 | return -EFAULT; | 1696 | return -EFAULT; |
1692 | } | 1697 | } |
@@ -1720,7 +1725,7 @@ mptctl_mpt_command (unsigned long arg) | |||
1720 | 1725 | ||
1721 | 1726 | ||
1722 | if (copy_from_user(&karg, uarg, sizeof(struct mpt_ioctl_command))) { | 1727 | if (copy_from_user(&karg, uarg, sizeof(struct mpt_ioctl_command))) { |
1723 | printk(KERN_ERR "%s@%d::mptctl_mpt_command - " | 1728 | printk(KERN_ERR MYNAM "%s@%d::mptctl_mpt_command - " |
1724 | "Unable to read in mpt_ioctl_command struct @ %p\n", | 1729 | "Unable to read in mpt_ioctl_command struct @ %p\n", |
1725 | __FILE__, __LINE__, uarg); | 1730 | __FILE__, __LINE__, uarg); |
1726 | return -EFAULT; | 1731 | return -EFAULT; |
@@ -1728,7 +1733,7 @@ mptctl_mpt_command (unsigned long arg) | |||
1728 | 1733 | ||
1729 | if (((iocnum = mpt_verify_adapter(karg.hdr.iocnum, &ioc)) < 0) || | 1734 | if (((iocnum = mpt_verify_adapter(karg.hdr.iocnum, &ioc)) < 0) || |
1730 | (ioc == NULL)) { | 1735 | (ioc == NULL)) { |
1731 | printk(KERN_DEBUG "%s::mptctl_mpt_command() @%d - ioc%d not found!\n", | 1736 | printk(KERN_DEBUG MYNAM "%s::mptctl_mpt_command() @%d - ioc%d not found!\n", |
1732 | __FILE__, __LINE__, iocnum); | 1737 | __FILE__, __LINE__, iocnum); |
1733 | return -ENODEV; | 1738 | return -ENODEV; |
1734 | } | 1739 | } |
@@ -1769,21 +1774,24 @@ mptctl_do_mpt_command (struct mpt_ioctl_command karg, void __user *mfPtr) | |||
1769 | ulong timeout; | 1774 | ulong timeout; |
1770 | struct scsi_device *sdev; | 1775 | struct scsi_device *sdev; |
1771 | 1776 | ||
1777 | /* bufIn and bufOut are used for user to kernel space transfers | ||
1778 | */ | ||
1772 | bufIn.kptr = bufOut.kptr = NULL; | 1779 | bufIn.kptr = bufOut.kptr = NULL; |
1780 | bufIn.len = bufOut.len = 0; | ||
1773 | 1781 | ||
1774 | if (((iocnum = mpt_verify_adapter(karg.hdr.iocnum, &ioc)) < 0) || | 1782 | if (((iocnum = mpt_verify_adapter(karg.hdr.iocnum, &ioc)) < 0) || |
1775 | (ioc == NULL)) { | 1783 | (ioc == NULL)) { |
1776 | printk(KERN_DEBUG "%s::mptctl_do_mpt_command() @%d - ioc%d not found!\n", | 1784 | printk(KERN_DEBUG MYNAM "%s::mptctl_do_mpt_command() @%d - ioc%d not found!\n", |
1777 | __FILE__, __LINE__, iocnum); | 1785 | __FILE__, __LINE__, iocnum); |
1778 | return -ENODEV; | 1786 | return -ENODEV; |
1779 | } | 1787 | } |
1780 | if (!ioc->ioctl) { | 1788 | if (!ioc->ioctl) { |
1781 | printk(KERN_ERR "%s@%d::mptctl_do_mpt_command - " | 1789 | printk(KERN_ERR MYNAM "%s@%d::mptctl_do_mpt_command - " |
1782 | "No memory available during driver init.\n", | 1790 | "No memory available during driver init.\n", |
1783 | __FILE__, __LINE__); | 1791 | __FILE__, __LINE__); |
1784 | return -ENOMEM; | 1792 | return -ENOMEM; |
1785 | } else if (ioc->ioctl->status & MPT_IOCTL_STATUS_DID_IOCRESET) { | 1793 | } else if (ioc->ioctl->status & MPT_IOCTL_STATUS_DID_IOCRESET) { |
1786 | printk(KERN_ERR "%s@%d::mptctl_do_mpt_command - " | 1794 | printk(KERN_ERR MYNAM "%s@%d::mptctl_do_mpt_command - " |
1787 | "Busy with IOC Reset \n", __FILE__, __LINE__); | 1795 | "Busy with IOC Reset \n", __FILE__, __LINE__); |
1788 | return -EBUSY; | 1796 | return -EBUSY; |
1789 | } | 1797 | } |
@@ -1797,9 +1805,9 @@ mptctl_do_mpt_command (struct mpt_ioctl_command karg, void __user *mfPtr) | |||
1797 | sz += sizeof(dma_addr_t) + sizeof(u32); | 1805 | sz += sizeof(dma_addr_t) + sizeof(u32); |
1798 | 1806 | ||
1799 | if (sz > ioc->req_sz) { | 1807 | if (sz > ioc->req_sz) { |
1800 | printk(KERN_ERR "%s@%d::mptctl_do_mpt_command - " | 1808 | printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_do_mpt_command - " |
1801 | "Request frame too large (%d) maximum (%d)\n", | 1809 | "Request frame too large (%d) maximum (%d)\n", |
1802 | __FILE__, __LINE__, sz, ioc->req_sz); | 1810 | ioc->name, __FILE__, __LINE__, sz, ioc->req_sz); |
1803 | return -EFAULT; | 1811 | return -EFAULT; |
1804 | } | 1812 | } |
1805 | 1813 | ||
@@ -1817,9 +1825,9 @@ mptctl_do_mpt_command (struct mpt_ioctl_command karg, void __user *mfPtr) | |||
1817 | * Request frame in user space | 1825 | * Request frame in user space |
1818 | */ | 1826 | */ |
1819 | if (copy_from_user(mf, mfPtr, karg.dataSgeOffset * 4)) { | 1827 | if (copy_from_user(mf, mfPtr, karg.dataSgeOffset * 4)) { |
1820 | printk(KERN_ERR "%s@%d::mptctl_do_mpt_command - " | 1828 | printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_do_mpt_command - " |
1821 | "Unable to read MF from mpt_ioctl_command struct @ %p\n", | 1829 | "Unable to read MF from mpt_ioctl_command struct @ %p\n", |
1822 | __FILE__, __LINE__, mfPtr); | 1830 | ioc->name, __FILE__, __LINE__, mfPtr); |
1823 | rc = -EFAULT; | 1831 | rc = -EFAULT; |
1824 | goto done_free_mem; | 1832 | goto done_free_mem; |
1825 | } | 1833 | } |
@@ -1870,17 +1878,17 @@ mptctl_do_mpt_command (struct mpt_ioctl_command karg, void __user *mfPtr) | |||
1870 | 1878 | ||
1871 | id = (ioc->devices_per_bus == 0) ? 256 : ioc->devices_per_bus; | 1879 | id = (ioc->devices_per_bus == 0) ? 256 : ioc->devices_per_bus; |
1872 | if (pScsiReq->TargetID > id) { | 1880 | if (pScsiReq->TargetID > id) { |
1873 | printk(KERN_ERR "%s@%d::mptctl_do_mpt_command - " | 1881 | printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_do_mpt_command - " |
1874 | "Target ID out of bounds. \n", | 1882 | "Target ID out of bounds. \n", |
1875 | __FILE__, __LINE__); | 1883 | ioc->name, __FILE__, __LINE__); |
1876 | rc = -ENODEV; | 1884 | rc = -ENODEV; |
1877 | goto done_free_mem; | 1885 | goto done_free_mem; |
1878 | } | 1886 | } |
1879 | 1887 | ||
1880 | if (pScsiReq->Bus >= ioc->number_of_buses) { | 1888 | if (pScsiReq->Bus >= ioc->number_of_buses) { |
1881 | printk(KERN_ERR "%s@%d::mptctl_do_mpt_command - " | 1889 | printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_do_mpt_command - " |
1882 | "Target Bus out of bounds. \n", | 1890 | "Target Bus out of bounds. \n", |
1883 | __FILE__, __LINE__); | 1891 | ioc->name, __FILE__, __LINE__); |
1884 | rc = -ENODEV; | 1892 | rc = -ENODEV; |
1885 | goto done_free_mem; | 1893 | goto done_free_mem; |
1886 | } | 1894 | } |
@@ -1932,9 +1940,9 @@ mptctl_do_mpt_command (struct mpt_ioctl_command karg, void __user *mfPtr) | |||
1932 | ioc->ioctl->id = pScsiReq->TargetID; | 1940 | ioc->ioctl->id = pScsiReq->TargetID; |
1933 | 1941 | ||
1934 | } else { | 1942 | } else { |
1935 | printk(KERN_ERR "%s@%d::mptctl_do_mpt_command - " | 1943 | printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_do_mpt_command - " |
1936 | "SCSI driver is not loaded. \n", | 1944 | "SCSI driver is not loaded. \n", |
1937 | __FILE__, __LINE__); | 1945 | ioc->name, __FILE__, __LINE__); |
1938 | rc = -EFAULT; | 1946 | rc = -EFAULT; |
1939 | goto done_free_mem; | 1947 | goto done_free_mem; |
1940 | } | 1948 | } |
@@ -1951,9 +1959,9 @@ mptctl_do_mpt_command (struct mpt_ioctl_command karg, void __user *mfPtr) | |||
1951 | 1959 | ||
1952 | case MPI_FUNCTION_SATA_PASSTHROUGH: | 1960 | case MPI_FUNCTION_SATA_PASSTHROUGH: |
1953 | if (!ioc->sh) { | 1961 | if (!ioc->sh) { |
1954 | printk(KERN_ERR "%s@%d::mptctl_do_mpt_command - " | 1962 | printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_do_mpt_command - " |
1955 | "SCSI driver is not loaded. \n", | 1963 | "SCSI driver is not loaded. \n", |
1956 | __FILE__, __LINE__); | 1964 | ioc->name, __FILE__, __LINE__); |
1957 | rc = -EFAULT; | 1965 | rc = -EFAULT; |
1958 | goto done_free_mem; | 1966 | goto done_free_mem; |
1959 | } | 1967 | } |
@@ -2010,9 +2018,9 @@ mptctl_do_mpt_command (struct mpt_ioctl_command karg, void __user *mfPtr) | |||
2010 | ioc->ioctl->reset = MPTCTL_RESET_OK; | 2018 | ioc->ioctl->reset = MPTCTL_RESET_OK; |
2011 | ioc->ioctl->id = pScsiReq->TargetID; | 2019 | ioc->ioctl->id = pScsiReq->TargetID; |
2012 | } else { | 2020 | } else { |
2013 | printk(KERN_ERR "%s@%d::mptctl_do_mpt_command - " | 2021 | printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_do_mpt_command - " |
2014 | "SCSI driver is not loaded. \n", | 2022 | "SCSI driver is not loaded. \n", |
2015 | __FILE__, __LINE__); | 2023 | ioc->name, __FILE__, __LINE__); |
2016 | rc = -EFAULT; | 2024 | rc = -EFAULT; |
2017 | goto done_free_mem; | 2025 | goto done_free_mem; |
2018 | } | 2026 | } |
@@ -2021,10 +2029,10 @@ mptctl_do_mpt_command (struct mpt_ioctl_command karg, void __user *mfPtr) | |||
2021 | case MPI_FUNCTION_SCSI_TASK_MGMT: | 2029 | case MPI_FUNCTION_SCSI_TASK_MGMT: |
2022 | { | 2030 | { |
2023 | MPT_SCSI_HOST *hd = NULL; | 2031 | MPT_SCSI_HOST *hd = NULL; |
2024 | if ((ioc->sh == NULL) || ((hd = (MPT_SCSI_HOST *)ioc->sh->hostdata) == NULL)) { | 2032 | if ((ioc->sh == NULL) || ((hd = shost_priv(ioc->sh)) == NULL)) { |
2025 | printk(KERN_ERR "%s@%d::mptctl_do_mpt_command - " | 2033 | printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_do_mpt_command - " |
2026 | "SCSI driver not loaded or SCSI host not found. \n", | 2034 | "SCSI driver not loaded or SCSI host not found. \n", |
2027 | __FILE__, __LINE__); | 2035 | ioc->name, __FILE__, __LINE__); |
2028 | rc = -EFAULT; | 2036 | rc = -EFAULT; |
2029 | goto done_free_mem; | 2037 | goto done_free_mem; |
2030 | } else if (mptctl_set_tm_flags(hd) != 0) { | 2038 | } else if (mptctl_set_tm_flags(hd) != 0) { |
@@ -2055,9 +2063,9 @@ mptctl_do_mpt_command (struct mpt_ioctl_command karg, void __user *mfPtr) | |||
2055 | (pInit->ReplyFrameSize != cpu_to_le16(ioc->reply_sz)) || | 2063 | (pInit->ReplyFrameSize != cpu_to_le16(ioc->reply_sz)) || |
2056 | (pInit->HostMfaHighAddr != high_addr) || | 2064 | (pInit->HostMfaHighAddr != high_addr) || |
2057 | (pInit->SenseBufferHighAddr != sense_high)) { | 2065 | (pInit->SenseBufferHighAddr != sense_high)) { |
2058 | printk(KERN_ERR "%s@%d::mptctl_do_mpt_command - " | 2066 | printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_do_mpt_command - " |
2059 | "IOC_INIT issued with 1 or more incorrect parameters. Rejected.\n", | 2067 | "IOC_INIT issued with 1 or more incorrect parameters. Rejected.\n", |
2060 | __FILE__, __LINE__); | 2068 | ioc->name, __FILE__, __LINE__); |
2061 | rc = -EFAULT; | 2069 | rc = -EFAULT; |
2062 | goto done_free_mem; | 2070 | goto done_free_mem; |
2063 | } | 2071 | } |
@@ -2088,9 +2096,9 @@ mptctl_do_mpt_command (struct mpt_ioctl_command karg, void __user *mfPtr) | |||
2088 | MPI_FUNCTION_LAN_RESET | 2096 | MPI_FUNCTION_LAN_RESET |
2089 | */ | 2097 | */ |
2090 | 2098 | ||
2091 | printk(KERN_ERR "%s@%d::mptctl_do_mpt_command - " | 2099 | printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_do_mpt_command - " |
2092 | "Illegal request (function 0x%x) \n", | 2100 | "Illegal request (function 0x%x) \n", |
2093 | __FILE__, __LINE__, hdr->Function); | 2101 | ioc->name, __FILE__, __LINE__, hdr->Function); |
2094 | rc = -EFAULT; | 2102 | rc = -EFAULT; |
2095 | goto done_free_mem; | 2103 | goto done_free_mem; |
2096 | } | 2104 | } |
@@ -2103,11 +2111,6 @@ mptctl_do_mpt_command (struct mpt_ioctl_command karg, void __user *mfPtr) | |||
2103 | psge = (char *) (((int *) mf) + karg.dataSgeOffset); | 2111 | psge = (char *) (((int *) mf) + karg.dataSgeOffset); |
2104 | flagsLength = 0; | 2112 | flagsLength = 0; |
2105 | 2113 | ||
2106 | /* bufIn and bufOut are used for user to kernel space transfers | ||
2107 | */ | ||
2108 | bufIn.kptr = bufOut.kptr = NULL; | ||
2109 | bufIn.len = bufOut.len = 0; | ||
2110 | |||
2111 | if (karg.dataOutSize > 0) | 2114 | if (karg.dataOutSize > 0) |
2112 | sgSize ++; | 2115 | sgSize ++; |
2113 | 2116 | ||
@@ -2147,11 +2150,11 @@ mptctl_do_mpt_command (struct mpt_ioctl_command karg, void __user *mfPtr) | |||
2147 | if (copy_from_user(bufOut.kptr, | 2150 | if (copy_from_user(bufOut.kptr, |
2148 | karg.dataOutBufPtr, | 2151 | karg.dataOutBufPtr, |
2149 | bufOut.len)) { | 2152 | bufOut.len)) { |
2150 | printk(KERN_ERR | 2153 | printk(MYIOC_s_ERR_FMT |
2151 | "%s@%d::mptctl_do_mpt_command - Unable " | 2154 | "%s@%d::mptctl_do_mpt_command - Unable " |
2152 | "to read user data " | 2155 | "to read user data " |
2153 | "struct @ %p\n", | 2156 | "struct @ %p\n", |
2154 | __FILE__, __LINE__,karg.dataOutBufPtr); | 2157 | ioc->name, __FILE__, __LINE__,karg.dataOutBufPtr); |
2155 | rc = -EFAULT; | 2158 | rc = -EFAULT; |
2156 | goto done_free_mem; | 2159 | goto done_free_mem; |
2157 | } | 2160 | } |
@@ -2187,15 +2190,20 @@ mptctl_do_mpt_command (struct mpt_ioctl_command karg, void __user *mfPtr) | |||
2187 | 2190 | ||
2188 | DBG_DUMP_TM_REQUEST_FRAME(ioc, (u32 *)mf); | 2191 | DBG_DUMP_TM_REQUEST_FRAME(ioc, (u32 *)mf); |
2189 | 2192 | ||
2190 | if (mpt_send_handshake_request(mptctl_id, ioc, | 2193 | if ((ioc->facts.IOCCapabilities & MPI_IOCFACTS_CAPABILITY_HIGH_PRI_Q) && |
2191 | sizeof(SCSITaskMgmt_t), (u32*)mf, | 2194 | (ioc->facts.MsgVersion >= MPI_VERSION_01_05)) |
2192 | CAN_SLEEP) != 0) { | 2195 | mpt_put_msg_frame_hi_pri(mptctl_id, ioc, mf); |
2193 | dfailprintk(ioc, printk(MYIOC_s_ERR_FMT "_send_handshake FAILED!" | 2196 | else { |
2194 | " (ioc %p, mf %p) \n", ioc->name, | 2197 | rc =mpt_send_handshake_request(mptctl_id, ioc, |
2195 | ioc, mf)); | 2198 | sizeof(SCSITaskMgmt_t), (u32*)mf, CAN_SLEEP); |
2196 | mptctl_free_tm_flags(ioc); | 2199 | if (rc != 0) { |
2197 | rc = -ENODATA; | 2200 | dfailprintk(ioc, printk(MYIOC_s_ERR_FMT |
2198 | goto done_free_mem; | 2201 | "_send_handshake FAILED! (ioc %p, mf %p)\n", |
2202 | ioc->name, ioc, mf)); | ||
2203 | mptctl_free_tm_flags(ioc); | ||
2204 | rc = -ENODATA; | ||
2205 | goto done_free_mem; | ||
2206 | } | ||
2199 | } | 2207 | } |
2200 | 2208 | ||
2201 | } else | 2209 | } else |
@@ -2233,10 +2241,10 @@ mptctl_do_mpt_command (struct mpt_ioctl_command karg, void __user *mfPtr) | |||
2233 | if (sz > 0) { | 2241 | if (sz > 0) { |
2234 | if (copy_to_user(karg.replyFrameBufPtr, | 2242 | if (copy_to_user(karg.replyFrameBufPtr, |
2235 | &ioc->ioctl->ReplyFrame, sz)){ | 2243 | &ioc->ioctl->ReplyFrame, sz)){ |
2236 | printk(KERN_ERR | 2244 | printk(MYIOC_s_ERR_FMT |
2237 | "%s@%d::mptctl_do_mpt_command - " | 2245 | "%s@%d::mptctl_do_mpt_command - " |
2238 | "Unable to write out reply frame %p\n", | 2246 | "Unable to write out reply frame %p\n", |
2239 | __FILE__, __LINE__, karg.replyFrameBufPtr); | 2247 | ioc->name, __FILE__, __LINE__, karg.replyFrameBufPtr); |
2240 | rc = -ENODATA; | 2248 | rc = -ENODATA; |
2241 | goto done_free_mem; | 2249 | goto done_free_mem; |
2242 | } | 2250 | } |
@@ -2249,9 +2257,9 @@ mptctl_do_mpt_command (struct mpt_ioctl_command karg, void __user *mfPtr) | |||
2249 | sz = min(karg.maxSenseBytes, MPT_SENSE_BUFFER_SIZE); | 2257 | sz = min(karg.maxSenseBytes, MPT_SENSE_BUFFER_SIZE); |
2250 | if (sz > 0) { | 2258 | if (sz > 0) { |
2251 | if (copy_to_user(karg.senseDataPtr, ioc->ioctl->sense, sz)) { | 2259 | if (copy_to_user(karg.senseDataPtr, ioc->ioctl->sense, sz)) { |
2252 | printk(KERN_ERR "%s@%d::mptctl_do_mpt_command - " | 2260 | printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_do_mpt_command - " |
2253 | "Unable to write sense data to user %p\n", | 2261 | "Unable to write sense data to user %p\n", |
2254 | __FILE__, __LINE__, | 2262 | ioc->name, __FILE__, __LINE__, |
2255 | karg.senseDataPtr); | 2263 | karg.senseDataPtr); |
2256 | rc = -ENODATA; | 2264 | rc = -ENODATA; |
2257 | goto done_free_mem; | 2265 | goto done_free_mem; |
@@ -2267,9 +2275,9 @@ mptctl_do_mpt_command (struct mpt_ioctl_command karg, void __user *mfPtr) | |||
2267 | 2275 | ||
2268 | if (copy_to_user(karg.dataInBufPtr, | 2276 | if (copy_to_user(karg.dataInBufPtr, |
2269 | bufIn.kptr, karg.dataInSize)) { | 2277 | bufIn.kptr, karg.dataInSize)) { |
2270 | printk(KERN_ERR "%s@%d::mptctl_do_mpt_command - " | 2278 | printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_do_mpt_command - " |
2271 | "Unable to write data to user %p\n", | 2279 | "Unable to write data to user %p\n", |
2272 | __FILE__, __LINE__, | 2280 | ioc->name, __FILE__, __LINE__, |
2273 | karg.dataInBufPtr); | 2281 | karg.dataInBufPtr); |
2274 | rc = -ENODATA; | 2282 | rc = -ENODATA; |
2275 | } | 2283 | } |
@@ -2340,7 +2348,7 @@ mptctl_hp_hostinfo(unsigned long arg, unsigned int data_size) | |||
2340 | return -EFAULT; | 2348 | return -EFAULT; |
2341 | 2349 | ||
2342 | if (copy_from_user(&karg, uarg, sizeof(hp_host_info_t))) { | 2350 | if (copy_from_user(&karg, uarg, sizeof(hp_host_info_t))) { |
2343 | printk(KERN_ERR "%s@%d::mptctl_hp_host_info - " | 2351 | printk(KERN_ERR MYNAM "%s@%d::mptctl_hp_host_info - " |
2344 | "Unable to read in hp_host_info struct @ %p\n", | 2352 | "Unable to read in hp_host_info struct @ %p\n", |
2345 | __FILE__, __LINE__, uarg); | 2353 | __FILE__, __LINE__, uarg); |
2346 | return -EFAULT; | 2354 | return -EFAULT; |
@@ -2348,7 +2356,7 @@ mptctl_hp_hostinfo(unsigned long arg, unsigned int data_size) | |||
2348 | 2356 | ||
2349 | if (((iocnum = mpt_verify_adapter(karg.hdr.iocnum, &ioc)) < 0) || | 2357 | if (((iocnum = mpt_verify_adapter(karg.hdr.iocnum, &ioc)) < 0) || |
2350 | (ioc == NULL)) { | 2358 | (ioc == NULL)) { |
2351 | printk(KERN_DEBUG "%s::mptctl_hp_hostinfo() @%d - ioc%d not found!\n", | 2359 | printk(KERN_DEBUG MYNAM "%s::mptctl_hp_hostinfo() @%d - ioc%d not found!\n", |
2352 | __FILE__, __LINE__, iocnum); | 2360 | __FILE__, __LINE__, iocnum); |
2353 | return -ENODEV; | 2361 | return -ENODEV; |
2354 | } | 2362 | } |
@@ -2456,7 +2464,7 @@ mptctl_hp_hostinfo(unsigned long arg, unsigned int data_size) | |||
2456 | karg.soft_resets = 0; | 2464 | karg.soft_resets = 0; |
2457 | karg.timeouts = 0; | 2465 | karg.timeouts = 0; |
2458 | if (ioc->sh != NULL) { | 2466 | if (ioc->sh != NULL) { |
2459 | MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *)ioc->sh->hostdata; | 2467 | MPT_SCSI_HOST *hd = shost_priv(ioc->sh); |
2460 | 2468 | ||
2461 | if (hd && (cim_rev == 1)) { | 2469 | if (hd && (cim_rev == 1)) { |
2462 | karg.hard_resets = hd->hard_resets; | 2470 | karg.hard_resets = hd->hard_resets; |
@@ -2529,9 +2537,9 @@ mptctl_hp_hostinfo(unsigned long arg, unsigned int data_size) | |||
2529 | /* Copy the data from kernel memory to user memory | 2537 | /* Copy the data from kernel memory to user memory |
2530 | */ | 2538 | */ |
2531 | if (copy_to_user((char __user *)arg, &karg, sizeof(hp_host_info_t))) { | 2539 | if (copy_to_user((char __user *)arg, &karg, sizeof(hp_host_info_t))) { |
2532 | printk(KERN_ERR "%s@%d::mptctl_hpgethostinfo - " | 2540 | printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_hpgethostinfo - " |
2533 | "Unable to write out hp_host_info @ %p\n", | 2541 | "Unable to write out hp_host_info @ %p\n", |
2534 | __FILE__, __LINE__, uarg); | 2542 | ioc->name, __FILE__, __LINE__, uarg); |
2535 | return -EFAULT; | 2543 | return -EFAULT; |
2536 | } | 2544 | } |
2537 | 2545 | ||
@@ -2567,7 +2575,7 @@ mptctl_hp_targetinfo(unsigned long arg) | |||
2567 | int tmp, np, rc = 0; | 2575 | int tmp, np, rc = 0; |
2568 | 2576 | ||
2569 | if (copy_from_user(&karg, uarg, sizeof(hp_target_info_t))) { | 2577 | if (copy_from_user(&karg, uarg, sizeof(hp_target_info_t))) { |
2570 | printk(KERN_ERR "%s@%d::mptctl_hp_targetinfo - " | 2578 | printk(KERN_ERR MYNAM "%s@%d::mptctl_hp_targetinfo - " |
2571 | "Unable to read in hp_host_targetinfo struct @ %p\n", | 2579 | "Unable to read in hp_host_targetinfo struct @ %p\n", |
2572 | __FILE__, __LINE__, uarg); | 2580 | __FILE__, __LINE__, uarg); |
2573 | return -EFAULT; | 2581 | return -EFAULT; |
@@ -2575,11 +2583,11 @@ mptctl_hp_targetinfo(unsigned long arg) | |||
2575 | 2583 | ||
2576 | if (((iocnum = mpt_verify_adapter(karg.hdr.iocnum, &ioc)) < 0) || | 2584 | if (((iocnum = mpt_verify_adapter(karg.hdr.iocnum, &ioc)) < 0) || |
2577 | (ioc == NULL)) { | 2585 | (ioc == NULL)) { |
2578 | printk(KERN_DEBUG "%s::mptctl_hp_targetinfo() @%d - ioc%d not found!\n", | 2586 | printk(KERN_DEBUG MYNAM "%s::mptctl_hp_targetinfo() @%d - ioc%d not found!\n", |
2579 | __FILE__, __LINE__, iocnum); | 2587 | __FILE__, __LINE__, iocnum); |
2580 | return -ENODEV; | 2588 | return -ENODEV; |
2581 | } | 2589 | } |
2582 | dctlprintk(ioc, printk(MYIOC_s_DEBUG_FMT ": mptctl_hp_targetinfo called.\n", | 2590 | dctlprintk(ioc, printk(MYIOC_s_DEBUG_FMT "mptctl_hp_targetinfo called.\n", |
2583 | ioc->name)); | 2591 | ioc->name)); |
2584 | 2592 | ||
2585 | /* There is nothing to do for FCP parts. | 2593 | /* There is nothing to do for FCP parts. |
@@ -2673,16 +2681,16 @@ mptctl_hp_targetinfo(unsigned long arg) | |||
2673 | pci_free_consistent(ioc->pcidev, data_sz, (u8 *) pg3_alloc, page_dma); | 2681 | pci_free_consistent(ioc->pcidev, data_sz, (u8 *) pg3_alloc, page_dma); |
2674 | } | 2682 | } |
2675 | } | 2683 | } |
2676 | hd = (MPT_SCSI_HOST *) ioc->sh->hostdata; | 2684 | hd = shost_priv(ioc->sh); |
2677 | if (hd != NULL) | 2685 | if (hd != NULL) |
2678 | karg.select_timeouts = hd->sel_timeout[karg.hdr.id]; | 2686 | karg.select_timeouts = hd->sel_timeout[karg.hdr.id]; |
2679 | 2687 | ||
2680 | /* Copy the data from kernel memory to user memory | 2688 | /* Copy the data from kernel memory to user memory |
2681 | */ | 2689 | */ |
2682 | if (copy_to_user((char __user *)arg, &karg, sizeof(hp_target_info_t))) { | 2690 | if (copy_to_user((char __user *)arg, &karg, sizeof(hp_target_info_t))) { |
2683 | printk(KERN_ERR "%s@%d::mptctl_hp_target_info - " | 2691 | printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_hp_target_info - " |
2684 | "Unable to write out mpt_ioctl_targetinfo struct @ %p\n", | 2692 | "Unable to write out mpt_ioctl_targetinfo struct @ %p\n", |
2685 | __FILE__, __LINE__, uarg); | 2693 | ioc->name, __FILE__, __LINE__, uarg); |
2686 | return -EFAULT; | 2694 | return -EFAULT; |
2687 | } | 2695 | } |
2688 | 2696 | ||
@@ -2732,7 +2740,7 @@ compat_mptfwxfer_ioctl(struct file *filp, unsigned int cmd, | |||
2732 | if (((iocnum = mpt_verify_adapter(iocnumX, &iocp)) < 0) || | 2740 | if (((iocnum = mpt_verify_adapter(iocnumX, &iocp)) < 0) || |
2733 | (iocp == NULL)) { | 2741 | (iocp == NULL)) { |
2734 | printk(KERN_DEBUG MYNAM "::compat_mptfwxfer_ioctl @%d - ioc%d not found!\n", | 2742 | printk(KERN_DEBUG MYNAM "::compat_mptfwxfer_ioctl @%d - ioc%d not found!\n", |
2735 | __LINE__, iocnumX); | 2743 | __LINE__, iocnumX); |
2736 | return -ENODEV; | 2744 | return -ENODEV; |
2737 | } | 2745 | } |
2738 | 2746 | ||
@@ -2772,7 +2780,7 @@ compat_mpt_command(struct file *filp, unsigned int cmd, | |||
2772 | if (((iocnum = mpt_verify_adapter(iocnumX, &iocp)) < 0) || | 2780 | if (((iocnum = mpt_verify_adapter(iocnumX, &iocp)) < 0) || |
2773 | (iocp == NULL)) { | 2781 | (iocp == NULL)) { |
2774 | printk(KERN_DEBUG MYNAM "::compat_mpt_command @%d - ioc%d not found!\n", | 2782 | printk(KERN_DEBUG MYNAM "::compat_mpt_command @%d - ioc%d not found!\n", |
2775 | __LINE__, iocnumX); | 2783 | __LINE__, iocnumX); |
2776 | return -ENODEV; | 2784 | return -ENODEV; |
2777 | } | 2785 | } |
2778 | 2786 | ||
@@ -2853,31 +2861,22 @@ static long compat_mpctl_ioctl(struct file *f, unsigned int cmd, unsigned long a | |||
2853 | static int | 2861 | static int |
2854 | mptctl_probe(struct pci_dev *pdev, const struct pci_device_id *id) | 2862 | mptctl_probe(struct pci_dev *pdev, const struct pci_device_id *id) |
2855 | { | 2863 | { |
2856 | int err; | 2864 | MPT_IOCTL *mem; |
2857 | int sz; | ||
2858 | u8 *mem; | ||
2859 | MPT_ADAPTER *ioc = pci_get_drvdata(pdev); | 2865 | MPT_ADAPTER *ioc = pci_get_drvdata(pdev); |
2860 | 2866 | ||
2861 | /* | 2867 | /* |
2862 | * Allocate and inite a MPT_IOCTL structure | 2868 | * Allocate and inite a MPT_IOCTL structure |
2863 | */ | 2869 | */ |
2864 | sz = sizeof (MPT_IOCTL); | 2870 | mem = kzalloc(sizeof(MPT_IOCTL), GFP_KERNEL); |
2865 | mem = kmalloc(sz, GFP_KERNEL); | 2871 | if (!mem) { |
2866 | if (mem == NULL) { | 2872 | mptctl_remove(pdev); |
2867 | err = -ENOMEM; | 2873 | return -ENOMEM; |
2868 | goto out_fail; | ||
2869 | } | 2874 | } |
2870 | 2875 | ||
2871 | memset(mem, 0, sz); | 2876 | ioc->ioctl = mem; |
2872 | ioc->ioctl = (MPT_IOCTL *) mem; | ||
2873 | ioc->ioctl->ioc = ioc; | 2877 | ioc->ioctl->ioc = ioc; |
2874 | mutex_init(&ioc->ioctl->ioctl_mutex); | 2878 | mutex_init(&ioc->ioctl->ioctl_mutex); |
2875 | return 0; | 2879 | return 0; |
2876 | |||
2877 | out_fail: | ||
2878 | |||
2879 | mptctl_remove(pdev); | ||
2880 | return err; | ||
2881 | } | 2880 | } |
2882 | 2881 | ||
2883 | /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ | 2882 | /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ |
@@ -2924,7 +2923,8 @@ static int __init mptctl_init(void) | |||
2924 | * Install our handler | 2923 | * Install our handler |
2925 | */ | 2924 | */ |
2926 | ++where; | 2925 | ++where; |
2927 | if ((mptctl_id = mpt_register(mptctl_reply, MPTCTL_DRIVER)) < 0) { | 2926 | mptctl_id = mpt_register(mptctl_reply, MPTCTL_DRIVER); |
2927 | if (!mptctl_id || mptctl_id >= MPT_MAX_PROTOCOL_DRIVERS) { | ||
2928 | printk(KERN_ERR MYNAM ": ERROR: Failed to register with Fusion MPT base driver\n"); | 2928 | printk(KERN_ERR MYNAM ": ERROR: Failed to register with Fusion MPT base driver\n"); |
2929 | misc_deregister(&mptctl_miscdev); | 2929 | misc_deregister(&mptctl_miscdev); |
2930 | err = -EBUSY; | 2930 | err = -EBUSY; |