gdth_proc.c 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586
  1. // SPDX-License-Identifier: GPL-2.0
  2. /* gdth_proc.c
  3. * $Id: gdth_proc.c,v 1.43 2006/01/11 16:15:00 achim Exp $
  4. */
  5. #include <linux/completion.h>
  6. #include <linux/slab.h>
  7. int gdth_set_info(struct Scsi_Host *host, char *buffer, int length)
  8. {
  9. gdth_ha_str *ha = shost_priv(host);
  10. int ret_val = -EINVAL;
  11. TRACE2(("gdth_set_info() ha %d\n",ha->hanum,));
  12. if (length >= 4) {
  13. if (strncmp(buffer,"gdth",4) == 0) {
  14. buffer += 5;
  15. length -= 5;
  16. ret_val = gdth_set_asc_info(host, buffer, length, ha);
  17. }
  18. }
  19. return ret_val;
  20. }
  21. static int gdth_set_asc_info(struct Scsi_Host *host, char *buffer,
  22. int length, gdth_ha_str *ha)
  23. {
  24. int orig_length, drive, wb_mode;
  25. int i, found;
  26. gdth_cmd_str gdtcmd;
  27. gdth_cpar_str *pcpar;
  28. char cmnd[MAX_COMMAND_SIZE];
  29. memset(cmnd, 0xff, 12);
  30. memset(&gdtcmd, 0, sizeof(gdth_cmd_str));
  31. TRACE2(("gdth_set_asc_info() ha %d\n",ha->hanum));
  32. orig_length = length + 5;
  33. drive = -1;
  34. wb_mode = 0;
  35. found = FALSE;
  36. if (length >= 5 && strncmp(buffer,"flush",5)==0) {
  37. buffer += 6;
  38. length -= 6;
  39. if (length && *buffer>='0' && *buffer<='9') {
  40. drive = (int)(*buffer-'0');
  41. ++buffer; --length;
  42. if (length && *buffer>='0' && *buffer<='9') {
  43. drive = drive*10 + (int)(*buffer-'0');
  44. ++buffer; --length;
  45. }
  46. printk("GDT: Flushing host drive %d .. ",drive);
  47. } else {
  48. printk("GDT: Flushing all host drives .. ");
  49. }
  50. for (i = 0; i < MAX_HDRIVES; ++i) {
  51. if (ha->hdr[i].present) {
  52. if (drive != -1 && i != drive)
  53. continue;
  54. found = TRUE;
  55. gdtcmd.Service = CACHESERVICE;
  56. gdtcmd.OpCode = GDT_FLUSH;
  57. if (ha->cache_feat & GDT_64BIT) {
  58. gdtcmd.u.cache64.DeviceNo = i;
  59. gdtcmd.u.cache64.BlockNo = 1;
  60. } else {
  61. gdtcmd.u.cache.DeviceNo = i;
  62. gdtcmd.u.cache.BlockNo = 1;
  63. }
  64. gdth_execute(host, &gdtcmd, cmnd, 30, NULL);
  65. }
  66. }
  67. if (!found)
  68. printk("\nNo host drive found !\n");
  69. else
  70. printk("Done.\n");
  71. return(orig_length);
  72. }
  73. if (length >= 7 && strncmp(buffer,"wbp_off",7)==0) {
  74. buffer += 8;
  75. length -= 8;
  76. printk("GDT: Disabling write back permanently .. ");
  77. wb_mode = 1;
  78. } else if (length >= 6 && strncmp(buffer,"wbp_on",6)==0) {
  79. buffer += 7;
  80. length -= 7;
  81. printk("GDT: Enabling write back permanently .. ");
  82. wb_mode = 2;
  83. } else if (length >= 6 && strncmp(buffer,"wb_off",6)==0) {
  84. buffer += 7;
  85. length -= 7;
  86. printk("GDT: Disabling write back commands .. ");
  87. if (ha->cache_feat & GDT_WR_THROUGH) {
  88. gdth_write_through = TRUE;
  89. printk("Done.\n");
  90. } else {
  91. printk("Not supported !\n");
  92. }
  93. return(orig_length);
  94. } else if (length >= 5 && strncmp(buffer,"wb_on",5)==0) {
  95. buffer += 6;
  96. length -= 6;
  97. printk("GDT: Enabling write back commands .. ");
  98. gdth_write_through = FALSE;
  99. printk("Done.\n");
  100. return(orig_length);
  101. }
  102. if (wb_mode) {
  103. unsigned long flags;
  104. BUILD_BUG_ON(sizeof(gdth_cpar_str) > GDTH_SCRATCH);
  105. spin_lock_irqsave(&ha->smp_lock, flags);
  106. if (ha->scratch_busy) {
  107. spin_unlock_irqrestore(&ha->smp_lock, flags);
  108. return -EBUSY;
  109. }
  110. ha->scratch_busy = TRUE;
  111. spin_unlock_irqrestore(&ha->smp_lock, flags);
  112. pcpar = (gdth_cpar_str *)ha->pscratch;
  113. memcpy( pcpar, &ha->cpar, sizeof(gdth_cpar_str) );
  114. gdtcmd.Service = CACHESERVICE;
  115. gdtcmd.OpCode = GDT_IOCTL;
  116. gdtcmd.u.ioctl.p_param = ha->scratch_phys;
  117. gdtcmd.u.ioctl.param_size = sizeof(gdth_cpar_str);
  118. gdtcmd.u.ioctl.subfunc = CACHE_CONFIG;
  119. gdtcmd.u.ioctl.channel = INVALID_CHANNEL;
  120. pcpar->write_back = wb_mode==1 ? 0:1;
  121. gdth_execute(host, &gdtcmd, cmnd, 30, NULL);
  122. spin_lock_irqsave(&ha->smp_lock, flags);
  123. ha->scratch_busy = FALSE;
  124. spin_unlock_irqrestore(&ha->smp_lock, flags);
  125. printk("Done.\n");
  126. return(orig_length);
  127. }
  128. printk("GDT: Unknown command: %s Length: %d\n",buffer,length);
  129. return(-EINVAL);
  130. }
  131. int gdth_show_info(struct seq_file *m, struct Scsi_Host *host)
  132. {
  133. gdth_ha_str *ha = shost_priv(host);
  134. int hlen;
  135. int id, i, j, k, sec, flag;
  136. int no_mdrv = 0, drv_no, is_mirr;
  137. u32 cnt;
  138. dma_addr_t paddr;
  139. int rc = -ENOMEM;
  140. gdth_cmd_str *gdtcmd;
  141. gdth_evt_str *estr;
  142. char hrec[277];
  143. char *buf;
  144. gdth_dskstat_str *pds;
  145. gdth_diskinfo_str *pdi;
  146. gdth_arrayinf_str *pai;
  147. gdth_defcnt_str *pdef;
  148. gdth_cdrinfo_str *pcdi;
  149. gdth_hget_str *phg;
  150. char cmnd[MAX_COMMAND_SIZE];
  151. gdtcmd = kmalloc(sizeof(*gdtcmd), GFP_KERNEL);
  152. estr = kmalloc(sizeof(*estr), GFP_KERNEL);
  153. if (!gdtcmd || !estr)
  154. goto free_fail;
  155. memset(cmnd, 0xff, 12);
  156. memset(gdtcmd, 0, sizeof(gdth_cmd_str));
  157. TRACE2(("gdth_get_info() ha %d\n",ha->hanum));
  158. /* request is i.e. "cat /proc/scsi/gdth/0" */
  159. /* format: %-15s\t%-10s\t%-15s\t%s */
  160. /* driver parameters */
  161. seq_puts(m, "Driver Parameters:\n");
  162. if (reserve_list[0] == 0xff)
  163. strcpy(hrec, "--");
  164. else {
  165. hlen = sprintf(hrec, "%d", reserve_list[0]);
  166. for (i = 1; i < MAX_RES_ARGS; i++) {
  167. if (reserve_list[i] == 0xff)
  168. break;
  169. hlen += scnprintf(hrec + hlen, 161 - hlen, ",%d", reserve_list[i]);
  170. }
  171. }
  172. seq_printf(m,
  173. " reserve_mode: \t%d \treserve_list: \t%s\n",
  174. reserve_mode, hrec);
  175. seq_printf(m,
  176. " max_ids: \t%-3d \thdr_channel: \t%d\n",
  177. max_ids, hdr_channel);
  178. /* controller information */
  179. seq_puts(m, "\nDisk Array Controller Information:\n");
  180. seq_printf(m,
  181. " Number: \t%d \tName: \t%s\n",
  182. ha->hanum, ha->binfo.type_string);
  183. seq_printf(m,
  184. " Driver Ver.: \t%-10s\tFirmware Ver.: \t",
  185. GDTH_VERSION_STR);
  186. if (ha->more_proc)
  187. seq_printf(m, "%d.%02d.%02d-%c%03X\n",
  188. (u8)(ha->binfo.upd_fw_ver>>24),
  189. (u8)(ha->binfo.upd_fw_ver>>16),
  190. (u8)(ha->binfo.upd_fw_ver),
  191. ha->bfeat.raid ? 'R':'N',
  192. ha->binfo.upd_revision);
  193. else
  194. seq_printf(m, "%d.%02d\n", (u8)(ha->cpar.version>>8),
  195. (u8)(ha->cpar.version));
  196. if (ha->more_proc)
  197. /* more information: 1. about controller */
  198. seq_printf(m,
  199. " Serial No.: \t0x%8X\tCache RAM size:\t%d KB\n",
  200. ha->binfo.ser_no, ha->binfo.memsize / 1024);
  201. if (ha->more_proc) {
  202. size_t size = max_t(size_t, GDTH_SCRATCH, sizeof(gdth_hget_str));
  203. /* more information: 2. about physical devices */
  204. seq_puts(m, "\nPhysical Devices:");
  205. flag = FALSE;
  206. buf = dma_alloc_coherent(&ha->pdev->dev, size, &paddr, GFP_KERNEL);
  207. if (!buf)
  208. goto stop_output;
  209. for (i = 0; i < ha->bus_cnt; ++i) {
  210. /* 2.a statistics (and retries/reassigns) */
  211. TRACE2(("pdr_statistics() chn %d\n",i));
  212. pds = (gdth_dskstat_str *)(buf + GDTH_SCRATCH/4);
  213. gdtcmd->Service = CACHESERVICE;
  214. gdtcmd->OpCode = GDT_IOCTL;
  215. gdtcmd->u.ioctl.p_param = paddr + GDTH_SCRATCH/4;
  216. gdtcmd->u.ioctl.param_size = 3*GDTH_SCRATCH/4;
  217. gdtcmd->u.ioctl.subfunc = DSK_STATISTICS | L_CTRL_PATTERN;
  218. gdtcmd->u.ioctl.channel = ha->raw[i].address | INVALID_CHANNEL;
  219. pds->bid = ha->raw[i].local_no;
  220. pds->first = 0;
  221. pds->entries = ha->raw[i].pdev_cnt;
  222. cnt = (3*GDTH_SCRATCH/4 - 5 * sizeof(u32)) /
  223. sizeof(pds->list[0]);
  224. if (pds->entries > cnt)
  225. pds->entries = cnt;
  226. if (gdth_execute(host, gdtcmd, cmnd, 30, NULL) != S_OK)
  227. pds->count = 0;
  228. /* other IOCTLs must fit into area GDTH_SCRATCH/4 */
  229. for (j = 0; j < ha->raw[i].pdev_cnt; ++j) {
  230. /* 2.b drive info */
  231. TRACE2(("scsi_drv_info() chn %d dev %d\n",
  232. i, ha->raw[i].id_list[j]));
  233. pdi = (gdth_diskinfo_str *)buf;
  234. gdtcmd->Service = CACHESERVICE;
  235. gdtcmd->OpCode = GDT_IOCTL;
  236. gdtcmd->u.ioctl.p_param = paddr;
  237. gdtcmd->u.ioctl.param_size = sizeof(gdth_diskinfo_str);
  238. gdtcmd->u.ioctl.subfunc = SCSI_DR_INFO | L_CTRL_PATTERN;
  239. gdtcmd->u.ioctl.channel =
  240. ha->raw[i].address | ha->raw[i].id_list[j];
  241. if (gdth_execute(host, gdtcmd, cmnd, 30, NULL) == S_OK) {
  242. strncpy(hrec,pdi->vendor,8);
  243. strncpy(hrec+8,pdi->product,16);
  244. strncpy(hrec+24,pdi->revision,4);
  245. hrec[28] = 0;
  246. seq_printf(m,
  247. "\n Chn/ID/LUN: \t%c/%02d/%d \tName: \t%s\n",
  248. 'A'+i,pdi->target_id,pdi->lun,hrec);
  249. flag = TRUE;
  250. pdi->no_ldrive &= 0xffff;
  251. if (pdi->no_ldrive == 0xffff)
  252. strcpy(hrec,"--");
  253. else
  254. sprintf(hrec,"%d",pdi->no_ldrive);
  255. seq_printf(m,
  256. " Capacity [MB]:\t%-6d \tTo Log. Drive: \t%s\n",
  257. pdi->blkcnt/(1024*1024/pdi->blksize),
  258. hrec);
  259. } else {
  260. pdi->devtype = 0xff;
  261. }
  262. if (pdi->devtype == 0) {
  263. /* search retries/reassigns */
  264. for (k = 0; k < pds->count; ++k) {
  265. if (pds->list[k].tid == pdi->target_id &&
  266. pds->list[k].lun == pdi->lun) {
  267. seq_printf(m,
  268. " Retries: \t%-6d \tReassigns: \t%d\n",
  269. pds->list[k].retries,
  270. pds->list[k].reassigns);
  271. break;
  272. }
  273. }
  274. /* 2.c grown defects */
  275. TRACE2(("scsi_drv_defcnt() chn %d dev %d\n",
  276. i, ha->raw[i].id_list[j]));
  277. pdef = (gdth_defcnt_str *)buf;
  278. gdtcmd->Service = CACHESERVICE;
  279. gdtcmd->OpCode = GDT_IOCTL;
  280. gdtcmd->u.ioctl.p_param = paddr;
  281. gdtcmd->u.ioctl.param_size = sizeof(gdth_defcnt_str);
  282. gdtcmd->u.ioctl.subfunc = SCSI_DEF_CNT | L_CTRL_PATTERN;
  283. gdtcmd->u.ioctl.channel =
  284. ha->raw[i].address | ha->raw[i].id_list[j];
  285. pdef->sddc_type = 0x08;
  286. if (gdth_execute(host, gdtcmd, cmnd, 30, NULL) == S_OK) {
  287. seq_printf(m,
  288. " Grown Defects:\t%d\n",
  289. pdef->sddc_cnt);
  290. }
  291. }
  292. }
  293. }
  294. if (!flag)
  295. seq_puts(m, "\n --\n");
  296. /* 3. about logical drives */
  297. seq_puts(m, "\nLogical Drives:");
  298. flag = FALSE;
  299. for (i = 0; i < MAX_LDRIVES; ++i) {
  300. if (!ha->hdr[i].is_logdrv)
  301. continue;
  302. drv_no = i;
  303. j = k = 0;
  304. is_mirr = FALSE;
  305. do {
  306. /* 3.a log. drive info */
  307. TRACE2(("cache_drv_info() drive no %d\n",drv_no));
  308. pcdi = (gdth_cdrinfo_str *)buf;
  309. gdtcmd->Service = CACHESERVICE;
  310. gdtcmd->OpCode = GDT_IOCTL;
  311. gdtcmd->u.ioctl.p_param = paddr;
  312. gdtcmd->u.ioctl.param_size = sizeof(gdth_cdrinfo_str);
  313. gdtcmd->u.ioctl.subfunc = CACHE_DRV_INFO;
  314. gdtcmd->u.ioctl.channel = drv_no;
  315. if (gdth_execute(host, gdtcmd, cmnd, 30, NULL) != S_OK)
  316. break;
  317. pcdi->ld_dtype >>= 16;
  318. j++;
  319. if (pcdi->ld_dtype > 2) {
  320. strcpy(hrec, "missing");
  321. } else if (pcdi->ld_error & 1) {
  322. strcpy(hrec, "fault");
  323. } else if (pcdi->ld_error & 2) {
  324. strcpy(hrec, "invalid");
  325. k++; j--;
  326. } else {
  327. strcpy(hrec, "ok");
  328. }
  329. if (drv_no == i) {
  330. seq_printf(m,
  331. "\n Number: \t%-2d \tStatus: \t%s\n",
  332. drv_no, hrec);
  333. flag = TRUE;
  334. no_mdrv = pcdi->cd_ldcnt;
  335. if (no_mdrv > 1 || pcdi->ld_slave != -1) {
  336. is_mirr = TRUE;
  337. strcpy(hrec, "RAID-1");
  338. } else if (pcdi->ld_dtype == 0) {
  339. strcpy(hrec, "Disk");
  340. } else if (pcdi->ld_dtype == 1) {
  341. strcpy(hrec, "RAID-0");
  342. } else if (pcdi->ld_dtype == 2) {
  343. strcpy(hrec, "Chain");
  344. } else {
  345. strcpy(hrec, "???");
  346. }
  347. seq_printf(m,
  348. " Capacity [MB]:\t%-6d \tType: \t%s\n",
  349. pcdi->ld_blkcnt/(1024*1024/pcdi->ld_blksize),
  350. hrec);
  351. } else {
  352. seq_printf(m,
  353. " Slave Number: \t%-2d \tStatus: \t%s\n",
  354. drv_no & 0x7fff, hrec);
  355. }
  356. drv_no = pcdi->ld_slave;
  357. } while (drv_no != -1);
  358. if (is_mirr)
  359. seq_printf(m,
  360. " Missing Drv.: \t%-2d \tInvalid Drv.: \t%d\n",
  361. no_mdrv - j - k, k);
  362. if (!ha->hdr[i].is_arraydrv)
  363. strcpy(hrec, "--");
  364. else
  365. sprintf(hrec, "%d", ha->hdr[i].master_no);
  366. seq_printf(m,
  367. " To Array Drv.:\t%s\n", hrec);
  368. }
  369. if (!flag)
  370. seq_puts(m, "\n --\n");
  371. /* 4. about array drives */
  372. seq_puts(m, "\nArray Drives:");
  373. flag = FALSE;
  374. for (i = 0; i < MAX_LDRIVES; ++i) {
  375. if (!(ha->hdr[i].is_arraydrv && ha->hdr[i].is_master))
  376. continue;
  377. /* 4.a array drive info */
  378. TRACE2(("array_info() drive no %d\n",i));
  379. pai = (gdth_arrayinf_str *)buf;
  380. gdtcmd->Service = CACHESERVICE;
  381. gdtcmd->OpCode = GDT_IOCTL;
  382. gdtcmd->u.ioctl.p_param = paddr;
  383. gdtcmd->u.ioctl.param_size = sizeof(gdth_arrayinf_str);
  384. gdtcmd->u.ioctl.subfunc = ARRAY_INFO | LA_CTRL_PATTERN;
  385. gdtcmd->u.ioctl.channel = i;
  386. if (gdth_execute(host, gdtcmd, cmnd, 30, NULL) == S_OK) {
  387. if (pai->ai_state == 0)
  388. strcpy(hrec, "idle");
  389. else if (pai->ai_state == 2)
  390. strcpy(hrec, "build");
  391. else if (pai->ai_state == 4)
  392. strcpy(hrec, "ready");
  393. else if (pai->ai_state == 6)
  394. strcpy(hrec, "fail");
  395. else if (pai->ai_state == 8 || pai->ai_state == 10)
  396. strcpy(hrec, "rebuild");
  397. else
  398. strcpy(hrec, "error");
  399. if (pai->ai_ext_state & 0x10)
  400. strcat(hrec, "/expand");
  401. else if (pai->ai_ext_state & 0x1)
  402. strcat(hrec, "/patch");
  403. seq_printf(m,
  404. "\n Number: \t%-2d \tStatus: \t%s\n",
  405. i,hrec);
  406. flag = TRUE;
  407. if (pai->ai_type == 0)
  408. strcpy(hrec, "RAID-0");
  409. else if (pai->ai_type == 4)
  410. strcpy(hrec, "RAID-4");
  411. else if (pai->ai_type == 5)
  412. strcpy(hrec, "RAID-5");
  413. else
  414. strcpy(hrec, "RAID-10");
  415. seq_printf(m,
  416. " Capacity [MB]:\t%-6d \tType: \t%s\n",
  417. pai->ai_size/(1024*1024/pai->ai_secsize),
  418. hrec);
  419. }
  420. }
  421. if (!flag)
  422. seq_puts(m, "\n --\n");
  423. /* 5. about host drives */
  424. seq_puts(m, "\nHost Drives:");
  425. flag = FALSE;
  426. for (i = 0; i < MAX_LDRIVES; ++i) {
  427. if (!ha->hdr[i].is_logdrv ||
  428. (ha->hdr[i].is_arraydrv && !ha->hdr[i].is_master))
  429. continue;
  430. /* 5.a get host drive list */
  431. TRACE2(("host_get() drv_no %d\n",i));
  432. phg = (gdth_hget_str *)buf;
  433. gdtcmd->Service = CACHESERVICE;
  434. gdtcmd->OpCode = GDT_IOCTL;
  435. gdtcmd->u.ioctl.p_param = paddr;
  436. gdtcmd->u.ioctl.param_size = sizeof(gdth_hget_str);
  437. gdtcmd->u.ioctl.subfunc = HOST_GET | LA_CTRL_PATTERN;
  438. gdtcmd->u.ioctl.channel = i;
  439. phg->entries = MAX_HDRIVES;
  440. phg->offset = GDTOFFSOF(gdth_hget_str, entry[0]);
  441. if (gdth_execute(host, gdtcmd, cmnd, 30, NULL) == S_OK) {
  442. ha->hdr[i].ldr_no = i;
  443. ha->hdr[i].rw_attribs = 0;
  444. ha->hdr[i].start_sec = 0;
  445. } else {
  446. for (j = 0; j < phg->entries; ++j) {
  447. k = phg->entry[j].host_drive;
  448. if (k >= MAX_LDRIVES)
  449. continue;
  450. ha->hdr[k].ldr_no = phg->entry[j].log_drive;
  451. ha->hdr[k].rw_attribs = phg->entry[j].rw_attribs;
  452. ha->hdr[k].start_sec = phg->entry[j].start_sec;
  453. }
  454. }
  455. }
  456. dma_free_coherent(&ha->pdev->dev, size, buf, paddr);
  457. for (i = 0; i < MAX_HDRIVES; ++i) {
  458. if (!(ha->hdr[i].present))
  459. continue;
  460. seq_printf(m,
  461. "\n Number: \t%-2d \tArr/Log. Drive:\t%d\n",
  462. i, ha->hdr[i].ldr_no);
  463. flag = TRUE;
  464. seq_printf(m,
  465. " Capacity [MB]:\t%-6d \tStart Sector: \t%d\n",
  466. (u32)(ha->hdr[i].size/2048), ha->hdr[i].start_sec);
  467. }
  468. if (!flag)
  469. seq_puts(m, "\n --\n");
  470. }
  471. /* controller events */
  472. seq_puts(m, "\nController Events:\n");
  473. for (id = -1;;) {
  474. id = gdth_read_event(ha, id, estr);
  475. if (estr->event_source == 0)
  476. break;
  477. if (estr->event_data.eu.driver.ionode == ha->hanum &&
  478. estr->event_source == ES_ASYNC) {
  479. gdth_log_event(&estr->event_data, hrec);
  480. /*
  481. * Elapsed seconds subtraction with unsigned operands is
  482. * safe from wrap around in year 2106. Executes as:
  483. * operand a + (2's complement operand b) + 1
  484. */
  485. sec = (int)((u32)ktime_get_real_seconds() - estr->first_stamp);
  486. if (sec < 0) sec = 0;
  487. seq_printf(m," date- %02d:%02d:%02d\t%s\n",
  488. sec/3600, sec%3600/60, sec%60, hrec);
  489. }
  490. if (id == -1)
  491. break;
  492. }
  493. stop_output:
  494. rc = 0;
  495. free_fail:
  496. kfree(gdtcmd);
  497. kfree(estr);
  498. return rc;
  499. }
  500. static void gdth_wait_completion(gdth_ha_str *ha, int busnum, int id)
  501. {
  502. unsigned long flags;
  503. int i;
  504. struct scsi_cmnd *scp;
  505. struct gdth_cmndinfo *cmndinfo;
  506. u8 b, t;
  507. spin_lock_irqsave(&ha->smp_lock, flags);
  508. for (i = 0; i < GDTH_MAXCMDS; ++i) {
  509. scp = ha->cmd_tab[i].cmnd;
  510. cmndinfo = gdth_cmnd_priv(scp);
  511. b = scp->device->channel;
  512. t = scp->device->id;
  513. if (!SPECIAL_SCP(scp) && t == (u8)id &&
  514. b == (u8)busnum) {
  515. cmndinfo->wait_for_completion = 0;
  516. spin_unlock_irqrestore(&ha->smp_lock, flags);
  517. while (!cmndinfo->wait_for_completion)
  518. barrier();
  519. spin_lock_irqsave(&ha->smp_lock, flags);
  520. }
  521. }
  522. spin_unlock_irqrestore(&ha->smp_lock, flags);
  523. }