aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMahesh Rajashekhara <Mahesh_Rajashekhara@pmc-sierra.com>2012-10-19 09:51:07 -0400
committerJames Bottomley <JBottomley@Parallels.com>2012-11-26 23:59:46 -0500
commit0b4334473d48aa18e8448f9f718f1dcd0398c550 (patch)
tree44902b95c4eb73914758430eabef102fd61e35cf
parentb56d1003512c33aa1752d84e3fa078bc76b15bf8 (diff)
[SCSI] aacraid: SCSI dma mapping failure case handling
This patch handles SCSI dma mapping failure case. Reporting error code to the upper layer instead of BUG_ON(). Signed-off-by: Mahesh Rajashekhara <Mahesh_Rajashekhara@pmc-sierra.com> Reviewed-by: Tomas Henzl <thenzl@redhat.com> Signed-off-by: James Bottomley <JBottomley@Parallels.com>
-rw-r--r--drivers/scsi/aacraid/aachba.c87
-rw-r--r--drivers/scsi/aacraid/aacraid.h2
2 files changed, 65 insertions, 24 deletions
diff --git a/drivers/scsi/aacraid/aachba.c b/drivers/scsi/aacraid/aachba.c
index d79457ac8bef..681434e2dfe9 100644
--- a/drivers/scsi/aacraid/aachba.c
+++ b/drivers/scsi/aacraid/aachba.c
@@ -132,11 +132,13 @@ struct inquiry_data {
132 * M O D U L E G L O B A L S 132 * M O D U L E G L O B A L S
133 */ 133 */
134 134
135static unsigned long aac_build_sg(struct scsi_cmnd* scsicmd, struct sgmap* sgmap); 135static long aac_build_sg(struct scsi_cmnd *scsicmd, struct sgmap *sgmap);
136static unsigned long aac_build_sg64(struct scsi_cmnd* scsicmd, struct sgmap64* psg); 136static long aac_build_sg64(struct scsi_cmnd *scsicmd, struct sgmap64 *psg);
137static unsigned long aac_build_sgraw(struct scsi_cmnd* scsicmd, struct sgmapraw* psg); 137static long aac_build_sgraw(struct scsi_cmnd *scsicmd, struct sgmapraw *psg);
138static unsigned long aac_build_sgraw2(struct scsi_cmnd *scsicmd, struct aac_raw_io2 *rio2, int sg_max); 138static long aac_build_sgraw2(struct scsi_cmnd *scsicmd,
139static int aac_convert_sgraw2(struct aac_raw_io2 *rio2, int pages, int nseg, int nseg_new); 139 struct aac_raw_io2 *rio2, int sg_max);
140static int aac_convert_sgraw2(struct aac_raw_io2 *rio2,
141 int pages, int nseg, int nseg_new);
140static int aac_send_srb_fib(struct scsi_cmnd* scsicmd); 142static int aac_send_srb_fib(struct scsi_cmnd* scsicmd);
141#ifdef AAC_DETAILED_STATUS_INFO 143#ifdef AAC_DETAILED_STATUS_INFO
142static char *aac_get_status_string(u32 status); 144static char *aac_get_status_string(u32 status);
@@ -971,6 +973,7 @@ static int aac_read_raw_io(struct fib * fib, struct scsi_cmnd * cmd, u64 lba, u3
971{ 973{
972 struct aac_dev *dev = fib->dev; 974 struct aac_dev *dev = fib->dev;
973 u16 fibsize, command; 975 u16 fibsize, command;
976 long ret;
974 977
975 aac_fib_init(fib); 978 aac_fib_init(fib);
976 if (dev->comm_interface == AAC_COMM_MESSAGE_TYPE2 && !dev->sync_mode) { 979 if (dev->comm_interface == AAC_COMM_MESSAGE_TYPE2 && !dev->sync_mode) {
@@ -982,7 +985,10 @@ static int aac_read_raw_io(struct fib * fib, struct scsi_cmnd * cmd, u64 lba, u3
982 readcmd2->byteCount = cpu_to_le32(count<<9); 985 readcmd2->byteCount = cpu_to_le32(count<<9);
983 readcmd2->cid = cpu_to_le16(scmd_id(cmd)); 986 readcmd2->cid = cpu_to_le16(scmd_id(cmd));
984 readcmd2->flags = cpu_to_le16(RIO2_IO_TYPE_READ); 987 readcmd2->flags = cpu_to_le16(RIO2_IO_TYPE_READ);
985 aac_build_sgraw2(cmd, readcmd2, dev->scsi_host_ptr->sg_tablesize); 988 ret = aac_build_sgraw2(cmd, readcmd2,
989 dev->scsi_host_ptr->sg_tablesize);
990 if (ret < 0)
991 return ret;
986 command = ContainerRawIo2; 992 command = ContainerRawIo2;
987 fibsize = sizeof(struct aac_raw_io2) + 993 fibsize = sizeof(struct aac_raw_io2) +
988 ((le32_to_cpu(readcmd2->sgeCnt)-1) * sizeof(struct sge_ieee1212)); 994 ((le32_to_cpu(readcmd2->sgeCnt)-1) * sizeof(struct sge_ieee1212));
@@ -996,7 +1002,9 @@ static int aac_read_raw_io(struct fib * fib, struct scsi_cmnd * cmd, u64 lba, u3
996 readcmd->flags = cpu_to_le16(RIO_TYPE_READ); 1002 readcmd->flags = cpu_to_le16(RIO_TYPE_READ);
997 readcmd->bpTotal = 0; 1003 readcmd->bpTotal = 0;
998 readcmd->bpComplete = 0; 1004 readcmd->bpComplete = 0;
999 aac_build_sgraw(cmd, &readcmd->sg); 1005 ret = aac_build_sgraw(cmd, &readcmd->sg);
1006 if (ret < 0)
1007 return ret;
1000 command = ContainerRawIo; 1008 command = ContainerRawIo;
1001 fibsize = sizeof(struct aac_raw_io) + 1009 fibsize = sizeof(struct aac_raw_io) +
1002 ((le32_to_cpu(readcmd->sg.count)-1) * sizeof(struct sgentryraw)); 1010 ((le32_to_cpu(readcmd->sg.count)-1) * sizeof(struct sgentryraw));
@@ -1019,6 +1027,8 @@ static int aac_read_block64(struct fib * fib, struct scsi_cmnd * cmd, u64 lba, u
1019{ 1027{
1020 u16 fibsize; 1028 u16 fibsize;
1021 struct aac_read64 *readcmd; 1029 struct aac_read64 *readcmd;
1030 long ret;
1031
1022 aac_fib_init(fib); 1032 aac_fib_init(fib);
1023 readcmd = (struct aac_read64 *) fib_data(fib); 1033 readcmd = (struct aac_read64 *) fib_data(fib);
1024 readcmd->command = cpu_to_le32(VM_CtHostRead64); 1034 readcmd->command = cpu_to_le32(VM_CtHostRead64);
@@ -1028,7 +1038,9 @@ static int aac_read_block64(struct fib * fib, struct scsi_cmnd * cmd, u64 lba, u
1028 readcmd->pad = 0; 1038 readcmd->pad = 0;
1029 readcmd->flags = 0; 1039 readcmd->flags = 0;
1030 1040
1031 aac_build_sg64(cmd, &readcmd->sg); 1041 ret = aac_build_sg64(cmd, &readcmd->sg);
1042 if (ret < 0)
1043 return ret;
1032 fibsize = sizeof(struct aac_read64) + 1044 fibsize = sizeof(struct aac_read64) +
1033 ((le32_to_cpu(readcmd->sg.count) - 1) * 1045 ((le32_to_cpu(readcmd->sg.count) - 1) *
1034 sizeof (struct sgentry64)); 1046 sizeof (struct sgentry64));
@@ -1050,6 +1062,8 @@ static int aac_read_block(struct fib * fib, struct scsi_cmnd * cmd, u64 lba, u32
1050{ 1062{
1051 u16 fibsize; 1063 u16 fibsize;
1052 struct aac_read *readcmd; 1064 struct aac_read *readcmd;
1065 long ret;
1066
1053 aac_fib_init(fib); 1067 aac_fib_init(fib);
1054 readcmd = (struct aac_read *) fib_data(fib); 1068 readcmd = (struct aac_read *) fib_data(fib);
1055 readcmd->command = cpu_to_le32(VM_CtBlockRead); 1069 readcmd->command = cpu_to_le32(VM_CtBlockRead);
@@ -1057,7 +1071,9 @@ static int aac_read_block(struct fib * fib, struct scsi_cmnd * cmd, u64 lba, u32
1057 readcmd->block = cpu_to_le32((u32)(lba&0xffffffff)); 1071 readcmd->block = cpu_to_le32((u32)(lba&0xffffffff));
1058 readcmd->count = cpu_to_le32(count * 512); 1072 readcmd->count = cpu_to_le32(count * 512);
1059 1073
1060 aac_build_sg(cmd, &readcmd->sg); 1074 ret = aac_build_sg(cmd, &readcmd->sg);
1075 if (ret < 0)
1076 return ret;
1061 fibsize = sizeof(struct aac_read) + 1077 fibsize = sizeof(struct aac_read) +
1062 ((le32_to_cpu(readcmd->sg.count) - 1) * 1078 ((le32_to_cpu(readcmd->sg.count) - 1) *
1063 sizeof (struct sgentry)); 1079 sizeof (struct sgentry));
@@ -1079,6 +1095,7 @@ static int aac_write_raw_io(struct fib * fib, struct scsi_cmnd * cmd, u64 lba, u
1079{ 1095{
1080 struct aac_dev *dev = fib->dev; 1096 struct aac_dev *dev = fib->dev;
1081 u16 fibsize, command; 1097 u16 fibsize, command;
1098 long ret;
1082 1099
1083 aac_fib_init(fib); 1100 aac_fib_init(fib);
1084 if (dev->comm_interface == AAC_COMM_MESSAGE_TYPE2 && !dev->sync_mode) { 1101 if (dev->comm_interface == AAC_COMM_MESSAGE_TYPE2 && !dev->sync_mode) {
@@ -1093,7 +1110,10 @@ static int aac_write_raw_io(struct fib * fib, struct scsi_cmnd * cmd, u64 lba, u
1093 (((aac_cache & 5) != 5) || !fib->dev->cache_protected)) ? 1110 (((aac_cache & 5) != 5) || !fib->dev->cache_protected)) ?
1094 cpu_to_le16(RIO2_IO_TYPE_WRITE|RIO2_IO_SUREWRITE) : 1111 cpu_to_le16(RIO2_IO_TYPE_WRITE|RIO2_IO_SUREWRITE) :
1095 cpu_to_le16(RIO2_IO_TYPE_WRITE); 1112 cpu_to_le16(RIO2_IO_TYPE_WRITE);
1096 aac_build_sgraw2(cmd, writecmd2, dev->scsi_host_ptr->sg_tablesize); 1113 ret = aac_build_sgraw2(cmd, writecmd2,
1114 dev->scsi_host_ptr->sg_tablesize);
1115 if (ret < 0)
1116 return ret;
1097 command = ContainerRawIo2; 1117 command = ContainerRawIo2;
1098 fibsize = sizeof(struct aac_raw_io2) + 1118 fibsize = sizeof(struct aac_raw_io2) +
1099 ((le32_to_cpu(writecmd2->sgeCnt)-1) * sizeof(struct sge_ieee1212)); 1119 ((le32_to_cpu(writecmd2->sgeCnt)-1) * sizeof(struct sge_ieee1212));
@@ -1110,7 +1130,9 @@ static int aac_write_raw_io(struct fib * fib, struct scsi_cmnd * cmd, u64 lba, u
1110 cpu_to_le16(RIO_TYPE_WRITE); 1130 cpu_to_le16(RIO_TYPE_WRITE);
1111 writecmd->bpTotal = 0; 1131 writecmd->bpTotal = 0;
1112 writecmd->bpComplete = 0; 1132 writecmd->bpComplete = 0;
1113 aac_build_sgraw(cmd, &writecmd->sg); 1133 ret = aac_build_sgraw(cmd, &writecmd->sg);
1134 if (ret < 0)
1135 return ret;
1114 command = ContainerRawIo; 1136 command = ContainerRawIo;
1115 fibsize = sizeof(struct aac_raw_io) + 1137 fibsize = sizeof(struct aac_raw_io) +
1116 ((le32_to_cpu(writecmd->sg.count)-1) * sizeof (struct sgentryraw)); 1138 ((le32_to_cpu(writecmd->sg.count)-1) * sizeof (struct sgentryraw));
@@ -1133,6 +1155,8 @@ static int aac_write_block64(struct fib * fib, struct scsi_cmnd * cmd, u64 lba,
1133{ 1155{
1134 u16 fibsize; 1156 u16 fibsize;
1135 struct aac_write64 *writecmd; 1157 struct aac_write64 *writecmd;
1158 long ret;
1159
1136 aac_fib_init(fib); 1160 aac_fib_init(fib);
1137 writecmd = (struct aac_write64 *) fib_data(fib); 1161 writecmd = (struct aac_write64 *) fib_data(fib);
1138 writecmd->command = cpu_to_le32(VM_CtHostWrite64); 1162 writecmd->command = cpu_to_le32(VM_CtHostWrite64);
@@ -1142,7 +1166,9 @@ static int aac_write_block64(struct fib * fib, struct scsi_cmnd * cmd, u64 lba,
1142 writecmd->pad = 0; 1166 writecmd->pad = 0;
1143 writecmd->flags = 0; 1167 writecmd->flags = 0;
1144 1168
1145 aac_build_sg64(cmd, &writecmd->sg); 1169 ret = aac_build_sg64(cmd, &writecmd->sg);
1170 if (ret < 0)
1171 return ret;
1146 fibsize = sizeof(struct aac_write64) + 1172 fibsize = sizeof(struct aac_write64) +
1147 ((le32_to_cpu(writecmd->sg.count) - 1) * 1173 ((le32_to_cpu(writecmd->sg.count) - 1) *
1148 sizeof (struct sgentry64)); 1174 sizeof (struct sgentry64));
@@ -1164,6 +1190,8 @@ static int aac_write_block(struct fib * fib, struct scsi_cmnd * cmd, u64 lba, u3
1164{ 1190{
1165 u16 fibsize; 1191 u16 fibsize;
1166 struct aac_write *writecmd; 1192 struct aac_write *writecmd;
1193 long ret;
1194
1167 aac_fib_init(fib); 1195 aac_fib_init(fib);
1168 writecmd = (struct aac_write *) fib_data(fib); 1196 writecmd = (struct aac_write *) fib_data(fib);
1169 writecmd->command = cpu_to_le32(VM_CtBlockWrite); 1197 writecmd->command = cpu_to_le32(VM_CtBlockWrite);
@@ -1173,7 +1201,9 @@ static int aac_write_block(struct fib * fib, struct scsi_cmnd * cmd, u64 lba, u3
1173 writecmd->sg.count = cpu_to_le32(1); 1201 writecmd->sg.count = cpu_to_le32(1);
1174 /* ->stable is not used - it did mean which type of write */ 1202 /* ->stable is not used - it did mean which type of write */
1175 1203
1176 aac_build_sg(cmd, &writecmd->sg); 1204 ret = aac_build_sg(cmd, &writecmd->sg);
1205 if (ret < 0)
1206 return ret;
1177 fibsize = sizeof(struct aac_write) + 1207 fibsize = sizeof(struct aac_write) +
1178 ((le32_to_cpu(writecmd->sg.count) - 1) * 1208 ((le32_to_cpu(writecmd->sg.count) - 1) *
1179 sizeof (struct sgentry)); 1209 sizeof (struct sgentry));
@@ -1235,8 +1265,11 @@ static int aac_scsi_64(struct fib * fib, struct scsi_cmnd * cmd)
1235{ 1265{
1236 u16 fibsize; 1266 u16 fibsize;
1237 struct aac_srb * srbcmd = aac_scsi_common(fib, cmd); 1267 struct aac_srb * srbcmd = aac_scsi_common(fib, cmd);
1268 long ret;
1238 1269
1239 aac_build_sg64(cmd, (struct sgmap64*) &srbcmd->sg); 1270 ret = aac_build_sg64(cmd, (struct sgmap64 *) &srbcmd->sg);
1271 if (ret < 0)
1272 return ret;
1240 srbcmd->count = cpu_to_le32(scsi_bufflen(cmd)); 1273 srbcmd->count = cpu_to_le32(scsi_bufflen(cmd));
1241 1274
1242 memset(srbcmd->cdb, 0, sizeof(srbcmd->cdb)); 1275 memset(srbcmd->cdb, 0, sizeof(srbcmd->cdb));
@@ -1263,8 +1296,11 @@ static int aac_scsi_32(struct fib * fib, struct scsi_cmnd * cmd)
1263{ 1296{
1264 u16 fibsize; 1297 u16 fibsize;
1265 struct aac_srb * srbcmd = aac_scsi_common(fib, cmd); 1298 struct aac_srb * srbcmd = aac_scsi_common(fib, cmd);
1299 long ret;
1266 1300
1267 aac_build_sg(cmd, (struct sgmap*)&srbcmd->sg); 1301 ret = aac_build_sg(cmd, (struct sgmap *)&srbcmd->sg);
1302 if (ret < 0)
1303 return ret;
1268 srbcmd->count = cpu_to_le32(scsi_bufflen(cmd)); 1304 srbcmd->count = cpu_to_le32(scsi_bufflen(cmd));
1269 1305
1270 memset(srbcmd->cdb, 0, sizeof(srbcmd->cdb)); 1306 memset(srbcmd->cdb, 0, sizeof(srbcmd->cdb));
@@ -2870,7 +2906,7 @@ static int aac_send_srb_fib(struct scsi_cmnd* scsicmd)
2870 return -1; 2906 return -1;
2871} 2907}
2872 2908
2873static unsigned long aac_build_sg(struct scsi_cmnd* scsicmd, struct sgmap* psg) 2909static long aac_build_sg(struct scsi_cmnd *scsicmd, struct sgmap *psg)
2874{ 2910{
2875 struct aac_dev *dev; 2911 struct aac_dev *dev;
2876 unsigned long byte_count = 0; 2912 unsigned long byte_count = 0;
@@ -2883,7 +2919,8 @@ static unsigned long aac_build_sg(struct scsi_cmnd* scsicmd, struct sgmap* psg)
2883 psg->sg[0].count = 0; 2919 psg->sg[0].count = 0;
2884 2920
2885 nseg = scsi_dma_map(scsicmd); 2921 nseg = scsi_dma_map(scsicmd);
2886 BUG_ON(nseg < 0); 2922 if (nseg < 0)
2923 return nseg;
2887 if (nseg) { 2924 if (nseg) {
2888 struct scatterlist *sg; 2925 struct scatterlist *sg;
2889 int i; 2926 int i;
@@ -2912,7 +2949,7 @@ static unsigned long aac_build_sg(struct scsi_cmnd* scsicmd, struct sgmap* psg)
2912} 2949}
2913 2950
2914 2951
2915static unsigned long aac_build_sg64(struct scsi_cmnd* scsicmd, struct sgmap64* psg) 2952static long aac_build_sg64(struct scsi_cmnd *scsicmd, struct sgmap64 *psg)
2916{ 2953{
2917 struct aac_dev *dev; 2954 struct aac_dev *dev;
2918 unsigned long byte_count = 0; 2955 unsigned long byte_count = 0;
@@ -2927,7 +2964,8 @@ static unsigned long aac_build_sg64(struct scsi_cmnd* scsicmd, struct sgmap64* p
2927 psg->sg[0].count = 0; 2964 psg->sg[0].count = 0;
2928 2965
2929 nseg = scsi_dma_map(scsicmd); 2966 nseg = scsi_dma_map(scsicmd);
2930 BUG_ON(nseg < 0); 2967 if (nseg < 0)
2968 return nseg;
2931 if (nseg) { 2969 if (nseg) {
2932 struct scatterlist *sg; 2970 struct scatterlist *sg;
2933 int i; 2971 int i;
@@ -2957,7 +2995,7 @@ static unsigned long aac_build_sg64(struct scsi_cmnd* scsicmd, struct sgmap64* p
2957 return byte_count; 2995 return byte_count;
2958} 2996}
2959 2997
2960static unsigned long aac_build_sgraw(struct scsi_cmnd* scsicmd, struct sgmapraw* psg) 2998static long aac_build_sgraw(struct scsi_cmnd *scsicmd, struct sgmapraw *psg)
2961{ 2999{
2962 unsigned long byte_count = 0; 3000 unsigned long byte_count = 0;
2963 int nseg; 3001 int nseg;
@@ -2972,7 +3010,8 @@ static unsigned long aac_build_sgraw(struct scsi_cmnd* scsicmd, struct sgmapraw*
2972 psg->sg[0].flags = 0; 3010 psg->sg[0].flags = 0;
2973 3011
2974 nseg = scsi_dma_map(scsicmd); 3012 nseg = scsi_dma_map(scsicmd);
2975 BUG_ON(nseg < 0); 3013 if (nseg < 0)
3014 return nseg;
2976 if (nseg) { 3015 if (nseg) {
2977 struct scatterlist *sg; 3016 struct scatterlist *sg;
2978 int i; 3017 int i;
@@ -3005,13 +3044,15 @@ static unsigned long aac_build_sgraw(struct scsi_cmnd* scsicmd, struct sgmapraw*
3005 return byte_count; 3044 return byte_count;
3006} 3045}
3007 3046
3008static unsigned long aac_build_sgraw2(struct scsi_cmnd *scsicmd, struct aac_raw_io2 *rio2, int sg_max) 3047static long aac_build_sgraw2(struct scsi_cmnd *scsicmd,
3048 struct aac_raw_io2 *rio2, int sg_max)
3009{ 3049{
3010 unsigned long byte_count = 0; 3050 unsigned long byte_count = 0;
3011 int nseg; 3051 int nseg;
3012 3052
3013 nseg = scsi_dma_map(scsicmd); 3053 nseg = scsi_dma_map(scsicmd);
3014 BUG_ON(nseg < 0); 3054 if (nseg < 0)
3055 return nseg;
3015 if (nseg) { 3056 if (nseg) {
3016 struct scatterlist *sg; 3057 struct scatterlist *sg;
3017 int i, conformable = 0; 3058 int i, conformable = 0;
diff --git a/drivers/scsi/aacraid/aacraid.h b/drivers/scsi/aacraid/aacraid.h
index 9e933a88a8bc..742f5d7eb0f5 100644
--- a/drivers/scsi/aacraid/aacraid.h
+++ b/drivers/scsi/aacraid/aacraid.h
@@ -12,7 +12,7 @@
12 *----------------------------------------------------------------------------*/ 12 *----------------------------------------------------------------------------*/
13 13
14#ifndef AAC_DRIVER_BUILD 14#ifndef AAC_DRIVER_BUILD
15# define AAC_DRIVER_BUILD 29800 15# define AAC_DRIVER_BUILD 29801
16# define AAC_DRIVER_BRANCH "-ms" 16# define AAC_DRIVER_BRANCH "-ms"
17#endif 17#endif
18#define MAXIMUM_NUM_CONTAINERS 32 18#define MAXIMUM_NUM_CONTAINERS 32