pm8001_sas.c 31 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105
  1. /*
  2. * PMC-Sierra SPC 8001 SAS/SATA based host adapters driver
  3. *
  4. * Copyright (c) 2008-2009 USI Co., Ltd.
  5. * All rights reserved.
  6. *
  7. * Redistribution and use in source and binary forms, with or without
  8. * modification, are permitted provided that the following conditions
  9. * are met:
  10. * 1. Redistributions of source code must retain the above copyright
  11. * notice, this list of conditions, and the following disclaimer,
  12. * without modification.
  13. * 2. Redistributions in binary form must reproduce at minimum a disclaimer
  14. * substantially similar to the "NO WARRANTY" disclaimer below
  15. * ("Disclaimer") and any redistribution must be conditioned upon
  16. * including a substantially similar Disclaimer requirement for further
  17. * binary redistribution.
  18. * 3. Neither the names of the above-listed copyright holders nor the names
  19. * of any contributors may be used to endorse or promote products derived
  20. * from this software without specific prior written permission.
  21. *
  22. * Alternatively, this software may be distributed under the terms of the
  23. * GNU General Public License ("GPL") version 2 as published by the Free
  24. * Software Foundation.
  25. *
  26. * NO WARRANTY
  27. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  28. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  29. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
  30. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  31. * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  32. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  33. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  34. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  35. * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
  36. * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  37. * POSSIBILITY OF SUCH DAMAGES.
  38. *
  39. */
  40. #include "pm8001_sas.h"
  41. /**
  42. * pm8001_find_tag - from sas task to find out tag that belongs to this task
  43. * @task: the task sent to the LLDD
  44. * @tag: the found tag associated with the task
  45. */
  46. static int pm8001_find_tag(struct sas_task *task, u32 *tag)
  47. {
  48. if (task->lldd_task) {
  49. struct pm8001_ccb_info *ccb;
  50. ccb = task->lldd_task;
  51. *tag = ccb->ccb_tag;
  52. return 1;
  53. }
  54. return 0;
  55. }
  56. /**
  57. * pm8001_tag_clear - clear the tags bitmap
  58. * @pm8001_ha: our hba struct
  59. * @tag: the found tag associated with the task
  60. */
  61. static void pm8001_tag_clear(struct pm8001_hba_info *pm8001_ha, u32 tag)
  62. {
  63. void *bitmap = pm8001_ha->tags;
  64. clear_bit(tag, bitmap);
  65. }
  66. static void pm8001_tag_free(struct pm8001_hba_info *pm8001_ha, u32 tag)
  67. {
  68. pm8001_tag_clear(pm8001_ha, tag);
  69. }
  70. static void pm8001_tag_set(struct pm8001_hba_info *pm8001_ha, u32 tag)
  71. {
  72. void *bitmap = pm8001_ha->tags;
  73. set_bit(tag, bitmap);
  74. }
  75. /**
  76. * pm8001_tag_alloc - allocate a empty tag for task used.
  77. * @pm8001_ha: our hba struct
  78. * @tag_out: the found empty tag .
  79. */
  80. inline int pm8001_tag_alloc(struct pm8001_hba_info *pm8001_ha, u32 *tag_out)
  81. {
  82. unsigned int index, tag;
  83. void *bitmap = pm8001_ha->tags;
  84. index = find_first_zero_bit(bitmap, pm8001_ha->tags_num);
  85. tag = index;
  86. if (tag >= pm8001_ha->tags_num)
  87. return -SAS_QUEUE_FULL;
  88. pm8001_tag_set(pm8001_ha, tag);
  89. *tag_out = tag;
  90. return 0;
  91. }
  92. void pm8001_tag_init(struct pm8001_hba_info *pm8001_ha)
  93. {
  94. int i;
  95. for (i = 0; i < pm8001_ha->tags_num; ++i)
  96. pm8001_tag_clear(pm8001_ha, i);
  97. }
  98. /**
  99. * pm8001_mem_alloc - allocate memory for pm8001.
  100. * @pdev: pci device.
  101. * @virt_addr: the allocated virtual address
  102. * @pphys_addr_hi: the physical address high byte address.
  103. * @pphys_addr_lo: the physical address low byte address.
  104. * @mem_size: memory size.
  105. */
  106. int pm8001_mem_alloc(struct pci_dev *pdev, void **virt_addr,
  107. dma_addr_t *pphys_addr, u32 *pphys_addr_hi,
  108. u32 *pphys_addr_lo, u32 mem_size, u32 align)
  109. {
  110. caddr_t mem_virt_alloc;
  111. dma_addr_t mem_dma_handle;
  112. u64 phys_align;
  113. u64 align_offset = 0;
  114. if (align)
  115. align_offset = (dma_addr_t)align - 1;
  116. mem_virt_alloc =
  117. pci_alloc_consistent(pdev, mem_size + align, &mem_dma_handle);
  118. if (!mem_virt_alloc) {
  119. pm8001_printk("memory allocation error\n");
  120. return -1;
  121. }
  122. memset((void *)mem_virt_alloc, 0, mem_size+align);
  123. *pphys_addr = mem_dma_handle;
  124. phys_align = (*pphys_addr + align_offset) & ~align_offset;
  125. *virt_addr = (void *)mem_virt_alloc + phys_align - *pphys_addr;
  126. *pphys_addr_hi = upper_32_bits(phys_align);
  127. *pphys_addr_lo = lower_32_bits(phys_align);
  128. return 0;
  129. }
  130. /**
  131. * pm8001_find_ha_by_dev - from domain device which come from sas layer to
  132. * find out our hba struct.
  133. * @dev: the domain device which from sas layer.
  134. */
  135. static
  136. struct pm8001_hba_info *pm8001_find_ha_by_dev(struct domain_device *dev)
  137. {
  138. struct sas_ha_struct *sha = dev->port->ha;
  139. struct pm8001_hba_info *pm8001_ha = sha->lldd_ha;
  140. return pm8001_ha;
  141. }
  142. /**
  143. * pm8001_phy_control - this function should be registered to
  144. * sas_domain_function_template to provide libsas used, note: this is just
  145. * control the HBA phy rather than other expander phy if you want control
  146. * other phy, you should use SMP command.
  147. * @sas_phy: which phy in HBA phys.
  148. * @func: the operation.
  149. * @funcdata: always NULL.
  150. */
  151. int pm8001_phy_control(struct asd_sas_phy *sas_phy, enum phy_func func,
  152. void *funcdata)
  153. {
  154. int rc = 0, phy_id = sas_phy->id;
  155. struct pm8001_hba_info *pm8001_ha = NULL;
  156. struct sas_phy_linkrates *rates;
  157. DECLARE_COMPLETION_ONSTACK(completion);
  158. pm8001_ha = sas_phy->ha->lldd_ha;
  159. pm8001_ha->phy[phy_id].enable_completion = &completion;
  160. switch (func) {
  161. case PHY_FUNC_SET_LINK_RATE:
  162. rates = funcdata;
  163. if (rates->minimum_linkrate) {
  164. pm8001_ha->phy[phy_id].minimum_linkrate =
  165. rates->minimum_linkrate;
  166. }
  167. if (rates->maximum_linkrate) {
  168. pm8001_ha->phy[phy_id].maximum_linkrate =
  169. rates->maximum_linkrate;
  170. }
  171. if (pm8001_ha->phy[phy_id].phy_state == 0) {
  172. PM8001_CHIP_DISP->phy_start_req(pm8001_ha, phy_id);
  173. wait_for_completion(&completion);
  174. }
  175. PM8001_CHIP_DISP->phy_ctl_req(pm8001_ha, phy_id,
  176. PHY_LINK_RESET);
  177. break;
  178. case PHY_FUNC_HARD_RESET:
  179. if (pm8001_ha->phy[phy_id].phy_state == 0) {
  180. PM8001_CHIP_DISP->phy_start_req(pm8001_ha, phy_id);
  181. wait_for_completion(&completion);
  182. }
  183. PM8001_CHIP_DISP->phy_ctl_req(pm8001_ha, phy_id,
  184. PHY_HARD_RESET);
  185. break;
  186. case PHY_FUNC_LINK_RESET:
  187. if (pm8001_ha->phy[phy_id].phy_state == 0) {
  188. PM8001_CHIP_DISP->phy_start_req(pm8001_ha, phy_id);
  189. wait_for_completion(&completion);
  190. }
  191. PM8001_CHIP_DISP->phy_ctl_req(pm8001_ha, phy_id,
  192. PHY_LINK_RESET);
  193. break;
  194. case PHY_FUNC_RELEASE_SPINUP_HOLD:
  195. PM8001_CHIP_DISP->phy_ctl_req(pm8001_ha, phy_id,
  196. PHY_LINK_RESET);
  197. break;
  198. case PHY_FUNC_DISABLE:
  199. PM8001_CHIP_DISP->phy_stop_req(pm8001_ha, phy_id);
  200. break;
  201. default:
  202. rc = -EOPNOTSUPP;
  203. }
  204. msleep(300);
  205. return rc;
  206. }
  207. int pm8001_slave_alloc(struct scsi_device *scsi_dev)
  208. {
  209. struct domain_device *dev = sdev_to_domain_dev(scsi_dev);
  210. if (dev_is_sata(dev)) {
  211. /* We don't need to rescan targets
  212. * if REPORT_LUNS request is failed
  213. */
  214. if (scsi_dev->lun > 0)
  215. return -ENXIO;
  216. scsi_dev->tagged_supported = 1;
  217. }
  218. return sas_slave_alloc(scsi_dev);
  219. }
  220. /**
  221. * pm8001_scan_start - we should enable all HBA phys by sending the phy_start
  222. * command to HBA.
  223. * @shost: the scsi host data.
  224. */
  225. void pm8001_scan_start(struct Scsi_Host *shost)
  226. {
  227. int i;
  228. struct pm8001_hba_info *pm8001_ha;
  229. struct sas_ha_struct *sha = SHOST_TO_SAS_HA(shost);
  230. pm8001_ha = sha->lldd_ha;
  231. PM8001_CHIP_DISP->sas_re_init_req(pm8001_ha);
  232. for (i = 0; i < pm8001_ha->chip->n_phy; ++i)
  233. PM8001_CHIP_DISP->phy_start_req(pm8001_ha, i);
  234. }
  235. int pm8001_scan_finished(struct Scsi_Host *shost, unsigned long time)
  236. {
  237. /* give the phy enabling interrupt event time to come in (1s
  238. * is empirically about all it takes) */
  239. if (time < HZ)
  240. return 0;
  241. /* Wait for discovery to finish */
  242. scsi_flush_work(shost);
  243. return 1;
  244. }
  245. /**
  246. * pm8001_task_prep_smp - the dispatcher function, prepare data for smp task
  247. * @pm8001_ha: our hba card information
  248. * @ccb: the ccb which attached to smp task
  249. */
  250. static int pm8001_task_prep_smp(struct pm8001_hba_info *pm8001_ha,
  251. struct pm8001_ccb_info *ccb)
  252. {
  253. return PM8001_CHIP_DISP->smp_req(pm8001_ha, ccb);
  254. }
  255. u32 pm8001_get_ncq_tag(struct sas_task *task, u32 *tag)
  256. {
  257. struct ata_queued_cmd *qc = task->uldd_task;
  258. if (qc) {
  259. if (qc->tf.command == ATA_CMD_FPDMA_WRITE ||
  260. qc->tf.command == ATA_CMD_FPDMA_READ) {
  261. *tag = qc->tag;
  262. return 1;
  263. }
  264. }
  265. return 0;
  266. }
  267. /**
  268. * pm8001_task_prep_ata - the dispatcher function, prepare data for sata task
  269. * @pm8001_ha: our hba card information
  270. * @ccb: the ccb which attached to sata task
  271. */
  272. static int pm8001_task_prep_ata(struct pm8001_hba_info *pm8001_ha,
  273. struct pm8001_ccb_info *ccb)
  274. {
  275. return PM8001_CHIP_DISP->sata_req(pm8001_ha, ccb);
  276. }
  277. /**
  278. * pm8001_task_prep_ssp_tm - the dispatcher function, prepare task management data
  279. * @pm8001_ha: our hba card information
  280. * @ccb: the ccb which attached to TM
  281. * @tmf: the task management IU
  282. */
  283. static int pm8001_task_prep_ssp_tm(struct pm8001_hba_info *pm8001_ha,
  284. struct pm8001_ccb_info *ccb, struct pm8001_tmf_task *tmf)
  285. {
  286. return PM8001_CHIP_DISP->ssp_tm_req(pm8001_ha, ccb, tmf);
  287. }
  288. /**
  289. * pm8001_task_prep_ssp - the dispatcher function,prepare ssp data for ssp task
  290. * @pm8001_ha: our hba card information
  291. * @ccb: the ccb which attached to ssp task
  292. */
  293. static int pm8001_task_prep_ssp(struct pm8001_hba_info *pm8001_ha,
  294. struct pm8001_ccb_info *ccb)
  295. {
  296. return PM8001_CHIP_DISP->ssp_io_req(pm8001_ha, ccb);
  297. }
  298. int pm8001_slave_configure(struct scsi_device *sdev)
  299. {
  300. struct domain_device *dev = sdev_to_domain_dev(sdev);
  301. int ret = sas_slave_configure(sdev);
  302. if (ret)
  303. return ret;
  304. if (dev_is_sata(dev)) {
  305. #ifdef PM8001_DISABLE_NCQ
  306. struct ata_port *ap = dev->sata_dev.ap;
  307. struct ata_device *adev = ap->link.device;
  308. adev->flags |= ATA_DFLAG_NCQ_OFF;
  309. scsi_adjust_queue_depth(sdev, MSG_SIMPLE_TAG, 1);
  310. #endif
  311. }
  312. return 0;
  313. }
  314. /**
  315. * pm8001_task_exec -execute the task which come from upper level, send the
  316. * command or data to DMA area and then increase CI,for queuecommand(ssp),
  317. * it is from upper layer and for smp command,it is from libsas,
  318. * for ata command it is from libata.
  319. * @task: the task to be execute.
  320. * @num: if can_queue great than 1, the task can be queued up. for SMP task,
  321. * we always execute one one time.
  322. * @gfp_flags: gfp_flags.
  323. * @is tmf: if it is task management task.
  324. * @tmf: the task management IU
  325. */
  326. #define DEV_IS_GONE(pm8001_dev) \
  327. ((!pm8001_dev || (pm8001_dev->dev_type == NO_DEVICE)))
  328. static int pm8001_task_exec(struct sas_task *task, const int num,
  329. gfp_t gfp_flags, int is_tmf, struct pm8001_tmf_task *tmf)
  330. {
  331. struct domain_device *dev = task->dev;
  332. struct pm8001_hba_info *pm8001_ha;
  333. struct pm8001_device *pm8001_dev;
  334. struct sas_task *t = task;
  335. struct pm8001_ccb_info *ccb;
  336. u32 tag = 0xdeadbeef, rc, n_elem = 0;
  337. u32 n = num;
  338. unsigned long flags = 0;
  339. if (!dev->port) {
  340. struct task_status_struct *tsm = &t->task_status;
  341. tsm->resp = SAS_TASK_UNDELIVERED;
  342. tsm->stat = SAS_PHY_DOWN;
  343. if (dev->dev_type != SATA_DEV)
  344. t->task_done(t);
  345. return 0;
  346. }
  347. pm8001_ha = pm8001_find_ha_by_dev(task->dev);
  348. PM8001_IO_DBG(pm8001_ha, pm8001_printk("pm8001_task_exec device \n "));
  349. spin_lock_irqsave(&pm8001_ha->lock, flags);
  350. do {
  351. dev = t->dev;
  352. pm8001_dev = dev->lldd_dev;
  353. if (DEV_IS_GONE(pm8001_dev)) {
  354. if (pm8001_dev) {
  355. PM8001_IO_DBG(pm8001_ha,
  356. pm8001_printk("device %d not ready.\n",
  357. pm8001_dev->device_id));
  358. } else {
  359. PM8001_IO_DBG(pm8001_ha,
  360. pm8001_printk("device %016llx not "
  361. "ready.\n", SAS_ADDR(dev->sas_addr)));
  362. }
  363. rc = SAS_PHY_DOWN;
  364. goto out_done;
  365. }
  366. rc = pm8001_tag_alloc(pm8001_ha, &tag);
  367. if (rc)
  368. goto err_out;
  369. ccb = &pm8001_ha->ccb_info[tag];
  370. if (!sas_protocol_ata(t->task_proto)) {
  371. if (t->num_scatter) {
  372. n_elem = dma_map_sg(pm8001_ha->dev,
  373. t->scatter,
  374. t->num_scatter,
  375. t->data_dir);
  376. if (!n_elem) {
  377. rc = -ENOMEM;
  378. goto err_out;
  379. }
  380. }
  381. } else {
  382. n_elem = t->num_scatter;
  383. }
  384. t->lldd_task = NULL;
  385. ccb->n_elem = n_elem;
  386. ccb->ccb_tag = tag;
  387. ccb->task = t;
  388. switch (t->task_proto) {
  389. case SAS_PROTOCOL_SMP:
  390. rc = pm8001_task_prep_smp(pm8001_ha, ccb);
  391. break;
  392. case SAS_PROTOCOL_SSP:
  393. if (is_tmf)
  394. rc = pm8001_task_prep_ssp_tm(pm8001_ha,
  395. ccb, tmf);
  396. else
  397. rc = pm8001_task_prep_ssp(pm8001_ha, ccb);
  398. break;
  399. case SAS_PROTOCOL_SATA:
  400. case SAS_PROTOCOL_STP:
  401. case SAS_PROTOCOL_SATA | SAS_PROTOCOL_STP:
  402. rc = pm8001_task_prep_ata(pm8001_ha, ccb);
  403. break;
  404. default:
  405. dev_printk(KERN_ERR, pm8001_ha->dev,
  406. "unknown sas_task proto: 0x%x\n",
  407. t->task_proto);
  408. rc = -EINVAL;
  409. break;
  410. }
  411. if (rc) {
  412. PM8001_IO_DBG(pm8001_ha,
  413. pm8001_printk("rc is %x\n", rc));
  414. goto err_out_tag;
  415. }
  416. t->lldd_task = ccb;
  417. /* TODO: select normal or high priority */
  418. spin_lock(&t->task_state_lock);
  419. t->task_state_flags |= SAS_TASK_AT_INITIATOR;
  420. spin_unlock(&t->task_state_lock);
  421. pm8001_dev->running_req++;
  422. if (n > 1)
  423. t = list_entry(t->list.next, struct sas_task, list);
  424. } while (--n);
  425. rc = 0;
  426. goto out_done;
  427. err_out_tag:
  428. pm8001_tag_free(pm8001_ha, tag);
  429. err_out:
  430. dev_printk(KERN_ERR, pm8001_ha->dev, "pm8001 exec failed[%d]!\n", rc);
  431. if (!sas_protocol_ata(t->task_proto))
  432. if (n_elem)
  433. dma_unmap_sg(pm8001_ha->dev, t->scatter, n_elem,
  434. t->data_dir);
  435. out_done:
  436. spin_unlock_irqrestore(&pm8001_ha->lock, flags);
  437. return rc;
  438. }
  439. /**
  440. * pm8001_queue_command - register for upper layer used, all IO commands sent
  441. * to HBA are from this interface.
  442. * @task: the task to be execute.
  443. * @num: if can_queue great than 1, the task can be queued up. for SMP task,
  444. * we always execute one one time
  445. * @gfp_flags: gfp_flags
  446. */
  447. int pm8001_queue_command(struct sas_task *task, const int num,
  448. gfp_t gfp_flags)
  449. {
  450. return pm8001_task_exec(task, num, gfp_flags, 0, NULL);
  451. }
  452. void pm8001_ccb_free(struct pm8001_hba_info *pm8001_ha, u32 ccb_idx)
  453. {
  454. pm8001_tag_clear(pm8001_ha, ccb_idx);
  455. }
  456. /**
  457. * pm8001_ccb_task_free - free the sg for ssp and smp command, free the ccb.
  458. * @pm8001_ha: our hba card information
  459. * @ccb: the ccb which attached to ssp task
  460. * @task: the task to be free.
  461. * @ccb_idx: ccb index.
  462. */
  463. void pm8001_ccb_task_free(struct pm8001_hba_info *pm8001_ha,
  464. struct sas_task *task, struct pm8001_ccb_info *ccb, u32 ccb_idx)
  465. {
  466. if (!ccb->task)
  467. return;
  468. if (!sas_protocol_ata(task->task_proto))
  469. if (ccb->n_elem)
  470. dma_unmap_sg(pm8001_ha->dev, task->scatter,
  471. task->num_scatter, task->data_dir);
  472. switch (task->task_proto) {
  473. case SAS_PROTOCOL_SMP:
  474. dma_unmap_sg(pm8001_ha->dev, &task->smp_task.smp_resp, 1,
  475. PCI_DMA_FROMDEVICE);
  476. dma_unmap_sg(pm8001_ha->dev, &task->smp_task.smp_req, 1,
  477. PCI_DMA_TODEVICE);
  478. break;
  479. case SAS_PROTOCOL_SATA:
  480. case SAS_PROTOCOL_STP:
  481. case SAS_PROTOCOL_SSP:
  482. default:
  483. /* do nothing */
  484. break;
  485. }
  486. task->lldd_task = NULL;
  487. ccb->task = NULL;
  488. ccb->ccb_tag = 0xFFFFFFFF;
  489. pm8001_ccb_free(pm8001_ha, ccb_idx);
  490. }
  491. /**
  492. * pm8001_alloc_dev - find the empty pm8001_device structure, allocate and
  493. * return it for use.
  494. * @pm8001_ha: our hba card information
  495. */
  496. struct pm8001_device *pm8001_alloc_dev(struct pm8001_hba_info *pm8001_ha)
  497. {
  498. u32 dev;
  499. for (dev = 0; dev < PM8001_MAX_DEVICES; dev++) {
  500. if (pm8001_ha->devices[dev].dev_type == NO_DEVICE) {
  501. pm8001_ha->devices[dev].id = dev;
  502. return &pm8001_ha->devices[dev];
  503. }
  504. }
  505. if (dev == PM8001_MAX_DEVICES) {
  506. PM8001_FAIL_DBG(pm8001_ha,
  507. pm8001_printk("max support %d devices, ignore ..\n",
  508. PM8001_MAX_DEVICES));
  509. }
  510. return NULL;
  511. }
  512. static void pm8001_free_dev(struct pm8001_device *pm8001_dev)
  513. {
  514. u32 id = pm8001_dev->id;
  515. memset(pm8001_dev, 0, sizeof(*pm8001_dev));
  516. pm8001_dev->id = id;
  517. pm8001_dev->dev_type = NO_DEVICE;
  518. pm8001_dev->device_id = PM8001_MAX_DEVICES;
  519. pm8001_dev->sas_device = NULL;
  520. }
  521. /**
  522. * pm8001_dev_found_notify - when libsas find a sas domain device, it should
  523. * tell the LLDD that device is found, and then LLDD register this device to
  524. * HBA FW by the command "OPC_INB_REG_DEV", after that the HBA will assign
  525. * a device ID(according to device's sas address) and returned it to LLDD.from
  526. * now on, we communicate with HBA FW with the device ID which HBA assigned
  527. * rather than sas address. it is the neccessary step for our HBA but it is
  528. * the optional for other HBA driver.
  529. * @dev: the device structure which sas layer used.
  530. */
  531. static int pm8001_dev_found_notify(struct domain_device *dev)
  532. {
  533. unsigned long flags = 0;
  534. int res = 0;
  535. struct pm8001_hba_info *pm8001_ha = NULL;
  536. struct domain_device *parent_dev = dev->parent;
  537. struct pm8001_device *pm8001_device;
  538. DECLARE_COMPLETION_ONSTACK(completion);
  539. u32 flag = 0;
  540. pm8001_ha = pm8001_find_ha_by_dev(dev);
  541. spin_lock_irqsave(&pm8001_ha->lock, flags);
  542. pm8001_device = pm8001_alloc_dev(pm8001_ha);
  543. pm8001_device->sas_device = dev;
  544. if (!pm8001_device) {
  545. res = -1;
  546. goto found_out;
  547. }
  548. dev->lldd_dev = pm8001_device;
  549. pm8001_device->dev_type = dev->dev_type;
  550. pm8001_device->dcompletion = &completion;
  551. if (parent_dev && DEV_IS_EXPANDER(parent_dev->dev_type)) {
  552. int phy_id;
  553. struct ex_phy *phy;
  554. for (phy_id = 0; phy_id < parent_dev->ex_dev.num_phys;
  555. phy_id++) {
  556. phy = &parent_dev->ex_dev.ex_phy[phy_id];
  557. if (SAS_ADDR(phy->attached_sas_addr)
  558. == SAS_ADDR(dev->sas_addr)) {
  559. pm8001_device->attached_phy = phy_id;
  560. break;
  561. }
  562. }
  563. if (phy_id == parent_dev->ex_dev.num_phys) {
  564. PM8001_FAIL_DBG(pm8001_ha,
  565. pm8001_printk("Error: no attached dev:%016llx"
  566. " at ex:%016llx.\n", SAS_ADDR(dev->sas_addr),
  567. SAS_ADDR(parent_dev->sas_addr)));
  568. res = -1;
  569. }
  570. } else {
  571. if (dev->dev_type == SATA_DEV) {
  572. pm8001_device->attached_phy =
  573. dev->rphy->identify.phy_identifier;
  574. flag = 1; /* directly sata*/
  575. }
  576. } /*register this device to HBA*/
  577. PM8001_DISC_DBG(pm8001_ha, pm8001_printk("Found device \n"));
  578. PM8001_CHIP_DISP->reg_dev_req(pm8001_ha, pm8001_device, flag);
  579. spin_unlock_irqrestore(&pm8001_ha->lock, flags);
  580. wait_for_completion(&completion);
  581. if (dev->dev_type == SAS_END_DEV)
  582. msleep(50);
  583. pm8001_ha->flags = PM8001F_RUN_TIME ;
  584. return 0;
  585. found_out:
  586. spin_unlock_irqrestore(&pm8001_ha->lock, flags);
  587. return res;
  588. }
  589. int pm8001_dev_found(struct domain_device *dev)
  590. {
  591. return pm8001_dev_found_notify(dev);
  592. }
  593. /**
  594. * pm8001_alloc_task - allocate a task structure for TMF
  595. */
  596. static struct sas_task *pm8001_alloc_task(void)
  597. {
  598. struct sas_task *task = kzalloc(sizeof(*task), GFP_KERNEL);
  599. if (task) {
  600. INIT_LIST_HEAD(&task->list);
  601. spin_lock_init(&task->task_state_lock);
  602. task->task_state_flags = SAS_TASK_STATE_PENDING;
  603. init_timer(&task->timer);
  604. init_completion(&task->completion);
  605. }
  606. return task;
  607. }
  608. static void pm8001_free_task(struct sas_task *task)
  609. {
  610. if (task) {
  611. BUG_ON(!list_empty(&task->list));
  612. kfree(task);
  613. }
  614. }
  615. static void pm8001_task_done(struct sas_task *task)
  616. {
  617. if (!del_timer(&task->timer))
  618. return;
  619. complete(&task->completion);
  620. }
  621. static void pm8001_tmf_timedout(unsigned long data)
  622. {
  623. struct sas_task *task = (struct sas_task *)data;
  624. task->task_state_flags |= SAS_TASK_STATE_ABORTED;
  625. complete(&task->completion);
  626. }
  627. #define PM8001_TASK_TIMEOUT 20
  628. /**
  629. * pm8001_exec_internal_tmf_task - when errors or exception happened, we may
  630. * want to do something, for example abort issued task which result in this
  631. * execption, this is by calling this function, note it is also with the task
  632. * execute interface.
  633. * @dev: the wanted device.
  634. * @tmf: which task management wanted to be take.
  635. * @para_len: para_len.
  636. * @parameter: ssp task parameter.
  637. */
  638. static int pm8001_exec_internal_tmf_task(struct domain_device *dev,
  639. void *parameter, u32 para_len, struct pm8001_tmf_task *tmf)
  640. {
  641. int res, retry;
  642. struct sas_task *task = NULL;
  643. struct pm8001_hba_info *pm8001_ha = pm8001_find_ha_by_dev(dev);
  644. for (retry = 0; retry < 3; retry++) {
  645. task = pm8001_alloc_task();
  646. if (!task)
  647. return -ENOMEM;
  648. task->dev = dev;
  649. task->task_proto = dev->tproto;
  650. memcpy(&task->ssp_task, parameter, para_len);
  651. task->task_done = pm8001_task_done;
  652. task->timer.data = (unsigned long)task;
  653. task->timer.function = pm8001_tmf_timedout;
  654. task->timer.expires = jiffies + PM8001_TASK_TIMEOUT*HZ;
  655. add_timer(&task->timer);
  656. res = pm8001_task_exec(task, 1, GFP_KERNEL, 1, tmf);
  657. if (res) {
  658. del_timer(&task->timer);
  659. PM8001_FAIL_DBG(pm8001_ha,
  660. pm8001_printk("Executing internal task "
  661. "failed\n"));
  662. goto ex_err;
  663. }
  664. wait_for_completion(&task->completion);
  665. res = -TMF_RESP_FUNC_FAILED;
  666. /* Even TMF timed out, return direct. */
  667. if ((task->task_state_flags & SAS_TASK_STATE_ABORTED)) {
  668. if (!(task->task_state_flags & SAS_TASK_STATE_DONE)) {
  669. PM8001_FAIL_DBG(pm8001_ha,
  670. pm8001_printk("TMF task[%x]timeout.\n",
  671. tmf->tmf));
  672. goto ex_err;
  673. }
  674. }
  675. if (task->task_status.resp == SAS_TASK_COMPLETE &&
  676. task->task_status.stat == SAM_GOOD) {
  677. res = TMF_RESP_FUNC_COMPLETE;
  678. break;
  679. }
  680. if (task->task_status.resp == SAS_TASK_COMPLETE &&
  681. task->task_status.stat == SAS_DATA_UNDERRUN) {
  682. /* no error, but return the number of bytes of
  683. * underrun */
  684. res = task->task_status.residual;
  685. break;
  686. }
  687. if (task->task_status.resp == SAS_TASK_COMPLETE &&
  688. task->task_status.stat == SAS_DATA_OVERRUN) {
  689. PM8001_FAIL_DBG(pm8001_ha,
  690. pm8001_printk("Blocked task error.\n"));
  691. res = -EMSGSIZE;
  692. break;
  693. } else {
  694. PM8001_IO_DBG(pm8001_ha,
  695. pm8001_printk(" Task to dev %016llx response: 0x%x"
  696. "status 0x%x\n",
  697. SAS_ADDR(dev->sas_addr),
  698. task->task_status.resp,
  699. task->task_status.stat));
  700. pm8001_free_task(task);
  701. task = NULL;
  702. }
  703. }
  704. ex_err:
  705. BUG_ON(retry == 3 && task != NULL);
  706. if (task != NULL)
  707. pm8001_free_task(task);
  708. return res;
  709. }
  710. static int
  711. pm8001_exec_internal_task_abort(struct pm8001_hba_info *pm8001_ha,
  712. struct pm8001_device *pm8001_dev, struct domain_device *dev, u32 flag,
  713. u32 task_tag)
  714. {
  715. int res, retry;
  716. u32 rc, ccb_tag;
  717. struct pm8001_ccb_info *ccb;
  718. struct sas_task *task = NULL;
  719. for (retry = 0; retry < 3; retry++) {
  720. task = pm8001_alloc_task();
  721. if (!task)
  722. return -ENOMEM;
  723. task->dev = dev;
  724. task->task_proto = dev->tproto;
  725. task->task_done = pm8001_task_done;
  726. task->timer.data = (unsigned long)task;
  727. task->timer.function = pm8001_tmf_timedout;
  728. task->timer.expires = jiffies + PM8001_TASK_TIMEOUT*HZ;
  729. add_timer(&task->timer);
  730. rc = pm8001_tag_alloc(pm8001_ha, &ccb_tag);
  731. if (rc)
  732. return rc;
  733. ccb = &pm8001_ha->ccb_info[ccb_tag];
  734. ccb->device = pm8001_dev;
  735. ccb->ccb_tag = ccb_tag;
  736. ccb->task = task;
  737. res = PM8001_CHIP_DISP->task_abort(pm8001_ha,
  738. pm8001_dev, flag, task_tag, ccb_tag);
  739. if (res) {
  740. del_timer(&task->timer);
  741. PM8001_FAIL_DBG(pm8001_ha,
  742. pm8001_printk("Executing internal task "
  743. "failed\n"));
  744. goto ex_err;
  745. }
  746. wait_for_completion(&task->completion);
  747. res = TMF_RESP_FUNC_FAILED;
  748. /* Even TMF timed out, return direct. */
  749. if ((task->task_state_flags & SAS_TASK_STATE_ABORTED)) {
  750. if (!(task->task_state_flags & SAS_TASK_STATE_DONE)) {
  751. PM8001_FAIL_DBG(pm8001_ha,
  752. pm8001_printk("TMF task timeout.\n"));
  753. goto ex_err;
  754. }
  755. }
  756. if (task->task_status.resp == SAS_TASK_COMPLETE &&
  757. task->task_status.stat == SAM_GOOD) {
  758. res = TMF_RESP_FUNC_COMPLETE;
  759. break;
  760. } else {
  761. PM8001_IO_DBG(pm8001_ha,
  762. pm8001_printk(" Task to dev %016llx response: "
  763. "0x%x status 0x%x\n",
  764. SAS_ADDR(dev->sas_addr),
  765. task->task_status.resp,
  766. task->task_status.stat));
  767. pm8001_free_task(task);
  768. task = NULL;
  769. }
  770. }
  771. ex_err:
  772. BUG_ON(retry == 3 && task != NULL);
  773. if (task != NULL)
  774. pm8001_free_task(task);
  775. return res;
  776. }
  777. /**
  778. * pm8001_dev_gone_notify - see the comments for "pm8001_dev_found_notify"
  779. * @dev: the device structure which sas layer used.
  780. */
  781. static void pm8001_dev_gone_notify(struct domain_device *dev)
  782. {
  783. unsigned long flags = 0;
  784. u32 tag;
  785. struct pm8001_hba_info *pm8001_ha;
  786. struct pm8001_device *pm8001_dev = dev->lldd_dev;
  787. u32 device_id = pm8001_dev->device_id;
  788. pm8001_ha = pm8001_find_ha_by_dev(dev);
  789. spin_lock_irqsave(&pm8001_ha->lock, flags);
  790. pm8001_tag_alloc(pm8001_ha, &tag);
  791. if (pm8001_dev) {
  792. PM8001_DISC_DBG(pm8001_ha,
  793. pm8001_printk("found dev[%d:%x] is gone.\n",
  794. pm8001_dev->device_id, pm8001_dev->dev_type));
  795. if (pm8001_dev->running_req) {
  796. spin_unlock_irqrestore(&pm8001_ha->lock, flags);
  797. pm8001_exec_internal_task_abort(pm8001_ha, pm8001_dev ,
  798. dev, 1, 0);
  799. spin_lock_irqsave(&pm8001_ha->lock, flags);
  800. }
  801. PM8001_CHIP_DISP->dereg_dev_req(pm8001_ha, device_id);
  802. pm8001_free_dev(pm8001_dev);
  803. } else {
  804. PM8001_DISC_DBG(pm8001_ha,
  805. pm8001_printk("Found dev has gone.\n"));
  806. }
  807. dev->lldd_dev = NULL;
  808. spin_unlock_irqrestore(&pm8001_ha->lock, flags);
  809. }
  810. void pm8001_dev_gone(struct domain_device *dev)
  811. {
  812. pm8001_dev_gone_notify(dev);
  813. }
  814. static int pm8001_issue_ssp_tmf(struct domain_device *dev,
  815. u8 *lun, struct pm8001_tmf_task *tmf)
  816. {
  817. struct sas_ssp_task ssp_task;
  818. if (!(dev->tproto & SAS_PROTOCOL_SSP))
  819. return TMF_RESP_FUNC_ESUPP;
  820. strncpy((u8 *)&ssp_task.LUN, lun, 8);
  821. return pm8001_exec_internal_tmf_task(dev, &ssp_task, sizeof(ssp_task),
  822. tmf);
  823. }
  824. /**
  825. * Standard mandates link reset for ATA (type 0) and hard reset for
  826. * SSP (type 1) , only for RECOVERY
  827. */
  828. int pm8001_I_T_nexus_reset(struct domain_device *dev)
  829. {
  830. int rc = TMF_RESP_FUNC_FAILED;
  831. struct pm8001_device *pm8001_dev;
  832. struct pm8001_hba_info *pm8001_ha;
  833. struct sas_phy *phy;
  834. if (!dev || !dev->lldd_dev)
  835. return -1;
  836. pm8001_dev = dev->lldd_dev;
  837. pm8001_ha = pm8001_find_ha_by_dev(dev);
  838. phy = sas_find_local_phy(dev);
  839. if (dev_is_sata(dev)) {
  840. DECLARE_COMPLETION_ONSTACK(completion_setstate);
  841. rc = sas_phy_reset(phy, 1);
  842. msleep(2000);
  843. rc = pm8001_exec_internal_task_abort(pm8001_ha, pm8001_dev ,
  844. dev, 1, 0);
  845. pm8001_dev->setds_completion = &completion_setstate;
  846. rc = PM8001_CHIP_DISP->set_dev_state_req(pm8001_ha,
  847. pm8001_dev, 0x01);
  848. wait_for_completion(&completion_setstate);
  849. } else{
  850. rc = sas_phy_reset(phy, 1);
  851. msleep(2000);
  852. }
  853. PM8001_EH_DBG(pm8001_ha, pm8001_printk(" for device[%x]:rc=%d\n",
  854. pm8001_dev->device_id, rc));
  855. return rc;
  856. }
  857. /* mandatory SAM-3, the task reset the specified LUN*/
  858. int pm8001_lu_reset(struct domain_device *dev, u8 *lun)
  859. {
  860. int rc = TMF_RESP_FUNC_FAILED;
  861. struct pm8001_tmf_task tmf_task;
  862. struct pm8001_device *pm8001_dev = dev->lldd_dev;
  863. struct pm8001_hba_info *pm8001_ha = pm8001_find_ha_by_dev(dev);
  864. if (dev_is_sata(dev)) {
  865. struct sas_phy *phy = sas_find_local_phy(dev);
  866. rc = pm8001_exec_internal_task_abort(pm8001_ha, pm8001_dev ,
  867. dev, 1, 0);
  868. rc = sas_phy_reset(phy, 1);
  869. rc = PM8001_CHIP_DISP->set_dev_state_req(pm8001_ha,
  870. pm8001_dev, 0x01);
  871. msleep(2000);
  872. } else {
  873. tmf_task.tmf = TMF_LU_RESET;
  874. rc = pm8001_issue_ssp_tmf(dev, lun, &tmf_task);
  875. }
  876. /* If failed, fall-through I_T_Nexus reset */
  877. PM8001_EH_DBG(pm8001_ha, pm8001_printk("for device[%x]:rc=%d\n",
  878. pm8001_dev->device_id, rc));
  879. return rc;
  880. }
  881. /* optional SAM-3 */
  882. int pm8001_query_task(struct sas_task *task)
  883. {
  884. u32 tag = 0xdeadbeef;
  885. int i = 0;
  886. struct scsi_lun lun;
  887. struct pm8001_tmf_task tmf_task;
  888. int rc = TMF_RESP_FUNC_FAILED;
  889. if (unlikely(!task || !task->lldd_task || !task->dev))
  890. return rc;
  891. if (task->task_proto & SAS_PROTOCOL_SSP) {
  892. struct scsi_cmnd *cmnd = task->uldd_task;
  893. struct domain_device *dev = task->dev;
  894. struct pm8001_hba_info *pm8001_ha =
  895. pm8001_find_ha_by_dev(dev);
  896. int_to_scsilun(cmnd->device->lun, &lun);
  897. rc = pm8001_find_tag(task, &tag);
  898. if (rc == 0) {
  899. rc = TMF_RESP_FUNC_FAILED;
  900. return rc;
  901. }
  902. PM8001_EH_DBG(pm8001_ha, pm8001_printk("Query:["));
  903. for (i = 0; i < 16; i++)
  904. printk(KERN_INFO "%02x ", cmnd->cmnd[i]);
  905. printk(KERN_INFO "]\n");
  906. tmf_task.tmf = TMF_QUERY_TASK;
  907. tmf_task.tag_of_task_to_be_managed = tag;
  908. rc = pm8001_issue_ssp_tmf(dev, lun.scsi_lun, &tmf_task);
  909. switch (rc) {
  910. /* The task is still in Lun, release it then */
  911. case TMF_RESP_FUNC_SUCC:
  912. PM8001_EH_DBG(pm8001_ha,
  913. pm8001_printk("The task is still in Lun \n"));
  914. /* The task is not in Lun or failed, reset the phy */
  915. case TMF_RESP_FUNC_FAILED:
  916. case TMF_RESP_FUNC_COMPLETE:
  917. PM8001_EH_DBG(pm8001_ha,
  918. pm8001_printk("The task is not in Lun or failed,"
  919. " reset the phy \n"));
  920. break;
  921. }
  922. }
  923. pm8001_printk(":rc= %d\n", rc);
  924. return rc;
  925. }
  926. /* mandatory SAM-3, still need free task/ccb info, abord the specified task */
  927. int pm8001_abort_task(struct sas_task *task)
  928. {
  929. unsigned long flags;
  930. u32 tag = 0xdeadbeef;
  931. u32 device_id;
  932. struct domain_device *dev ;
  933. struct pm8001_hba_info *pm8001_ha = NULL;
  934. struct pm8001_ccb_info *ccb;
  935. struct scsi_lun lun;
  936. struct pm8001_device *pm8001_dev;
  937. struct pm8001_tmf_task tmf_task;
  938. int rc = TMF_RESP_FUNC_FAILED;
  939. if (unlikely(!task || !task->lldd_task || !task->dev))
  940. return rc;
  941. spin_lock_irqsave(&task->task_state_lock, flags);
  942. if (task->task_state_flags & SAS_TASK_STATE_DONE) {
  943. spin_unlock_irqrestore(&task->task_state_lock, flags);
  944. rc = TMF_RESP_FUNC_COMPLETE;
  945. goto out;
  946. }
  947. spin_unlock_irqrestore(&task->task_state_lock, flags);
  948. if (task->task_proto & SAS_PROTOCOL_SSP) {
  949. struct scsi_cmnd *cmnd = task->uldd_task;
  950. dev = task->dev;
  951. ccb = task->lldd_task;
  952. pm8001_dev = dev->lldd_dev;
  953. pm8001_ha = pm8001_find_ha_by_dev(dev);
  954. int_to_scsilun(cmnd->device->lun, &lun);
  955. rc = pm8001_find_tag(task, &tag);
  956. if (rc == 0) {
  957. printk(KERN_INFO "No such tag in %s\n", __func__);
  958. rc = TMF_RESP_FUNC_FAILED;
  959. return rc;
  960. }
  961. device_id = pm8001_dev->device_id;
  962. PM8001_EH_DBG(pm8001_ha,
  963. pm8001_printk("abort io to device_id = %d\n", device_id));
  964. tmf_task.tmf = TMF_ABORT_TASK;
  965. tmf_task.tag_of_task_to_be_managed = tag;
  966. rc = pm8001_issue_ssp_tmf(dev, lun.scsi_lun, &tmf_task);
  967. rc = pm8001_exec_internal_task_abort(pm8001_ha, pm8001_dev,
  968. pm8001_dev->sas_device, 0, tag);
  969. } else if (task->task_proto & SAS_PROTOCOL_SATA ||
  970. task->task_proto & SAS_PROTOCOL_STP) {
  971. dev = task->dev;
  972. pm8001_dev = dev->lldd_dev;
  973. pm8001_ha = pm8001_find_ha_by_dev(dev);
  974. rc = pm8001_find_tag(task, &tag);
  975. if (rc == 0) {
  976. printk(KERN_INFO "No such tag in %s\n", __func__);
  977. rc = TMF_RESP_FUNC_FAILED;
  978. return rc;
  979. }
  980. rc = pm8001_exec_internal_task_abort(pm8001_ha, pm8001_dev,
  981. pm8001_dev->sas_device, 0, tag);
  982. } else if (task->task_proto & SAS_PROTOCOL_SMP) {
  983. /* SMP */
  984. dev = task->dev;
  985. pm8001_dev = dev->lldd_dev;
  986. pm8001_ha = pm8001_find_ha_by_dev(dev);
  987. rc = pm8001_find_tag(task, &tag);
  988. if (rc == 0) {
  989. printk(KERN_INFO "No such tag in %s\n", __func__);
  990. rc = TMF_RESP_FUNC_FAILED;
  991. return rc;
  992. }
  993. rc = pm8001_exec_internal_task_abort(pm8001_ha, pm8001_dev,
  994. pm8001_dev->sas_device, 0, tag);
  995. }
  996. out:
  997. if (rc != TMF_RESP_FUNC_COMPLETE)
  998. pm8001_printk("rc= %d\n", rc);
  999. return rc;
  1000. }
  1001. int pm8001_abort_task_set(struct domain_device *dev, u8 *lun)
  1002. {
  1003. int rc = TMF_RESP_FUNC_FAILED;
  1004. struct pm8001_tmf_task tmf_task;
  1005. tmf_task.tmf = TMF_ABORT_TASK_SET;
  1006. rc = pm8001_issue_ssp_tmf(dev, lun, &tmf_task);
  1007. return rc;
  1008. }
  1009. int pm8001_clear_aca(struct domain_device *dev, u8 *lun)
  1010. {
  1011. int rc = TMF_RESP_FUNC_FAILED;
  1012. struct pm8001_tmf_task tmf_task;
  1013. tmf_task.tmf = TMF_CLEAR_ACA;
  1014. rc = pm8001_issue_ssp_tmf(dev, lun, &tmf_task);
  1015. return rc;
  1016. }
  1017. int pm8001_clear_task_set(struct domain_device *dev, u8 *lun)
  1018. {
  1019. int rc = TMF_RESP_FUNC_FAILED;
  1020. struct pm8001_tmf_task tmf_task;
  1021. struct pm8001_device *pm8001_dev = dev->lldd_dev;
  1022. struct pm8001_hba_info *pm8001_ha = pm8001_find_ha_by_dev(dev);
  1023. PM8001_EH_DBG(pm8001_ha,
  1024. pm8001_printk("I_T_L_Q clear task set[%x]\n",
  1025. pm8001_dev->device_id));
  1026. tmf_task.tmf = TMF_CLEAR_TASK_SET;
  1027. rc = pm8001_issue_ssp_tmf(dev, lun, &tmf_task);
  1028. return rc;
  1029. }