pm8001_sas.c 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104
  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. for (i = 0; i < pm8001_ha->chip->n_phy; ++i)
  232. PM8001_CHIP_DISP->phy_start_req(pm8001_ha, i);
  233. }
  234. int pm8001_scan_finished(struct Scsi_Host *shost, unsigned long time)
  235. {
  236. /* give the phy enabling interrupt event time to come in (1s
  237. * is empirically about all it takes) */
  238. if (time < HZ)
  239. return 0;
  240. /* Wait for discovery to finish */
  241. scsi_flush_work(shost);
  242. return 1;
  243. }
  244. /**
  245. * pm8001_task_prep_smp - the dispatcher function, prepare data for smp task
  246. * @pm8001_ha: our hba card information
  247. * @ccb: the ccb which attached to smp task
  248. */
  249. static int pm8001_task_prep_smp(struct pm8001_hba_info *pm8001_ha,
  250. struct pm8001_ccb_info *ccb)
  251. {
  252. return PM8001_CHIP_DISP->smp_req(pm8001_ha, ccb);
  253. }
  254. u32 pm8001_get_ncq_tag(struct sas_task *task, u32 *tag)
  255. {
  256. struct ata_queued_cmd *qc = task->uldd_task;
  257. if (qc) {
  258. if (qc->tf.command == ATA_CMD_FPDMA_WRITE ||
  259. qc->tf.command == ATA_CMD_FPDMA_READ) {
  260. *tag = qc->tag;
  261. return 1;
  262. }
  263. }
  264. return 0;
  265. }
  266. /**
  267. * pm8001_task_prep_ata - the dispatcher function, prepare data for sata task
  268. * @pm8001_ha: our hba card information
  269. * @ccb: the ccb which attached to sata task
  270. */
  271. static int pm8001_task_prep_ata(struct pm8001_hba_info *pm8001_ha,
  272. struct pm8001_ccb_info *ccb)
  273. {
  274. return PM8001_CHIP_DISP->sata_req(pm8001_ha, ccb);
  275. }
  276. /**
  277. * pm8001_task_prep_ssp_tm - the dispatcher function, prepare task management data
  278. * @pm8001_ha: our hba card information
  279. * @ccb: the ccb which attached to TM
  280. * @tmf: the task management IU
  281. */
  282. static int pm8001_task_prep_ssp_tm(struct pm8001_hba_info *pm8001_ha,
  283. struct pm8001_ccb_info *ccb, struct pm8001_tmf_task *tmf)
  284. {
  285. return PM8001_CHIP_DISP->ssp_tm_req(pm8001_ha, ccb, tmf);
  286. }
  287. /**
  288. * pm8001_task_prep_ssp - the dispatcher function,prepare ssp data for ssp task
  289. * @pm8001_ha: our hba card information
  290. * @ccb: the ccb which attached to ssp task
  291. */
  292. static int pm8001_task_prep_ssp(struct pm8001_hba_info *pm8001_ha,
  293. struct pm8001_ccb_info *ccb)
  294. {
  295. return PM8001_CHIP_DISP->ssp_io_req(pm8001_ha, ccb);
  296. }
  297. int pm8001_slave_configure(struct scsi_device *sdev)
  298. {
  299. struct domain_device *dev = sdev_to_domain_dev(sdev);
  300. int ret = sas_slave_configure(sdev);
  301. if (ret)
  302. return ret;
  303. if (dev_is_sata(dev)) {
  304. #ifdef PM8001_DISABLE_NCQ
  305. struct ata_port *ap = dev->sata_dev.ap;
  306. struct ata_device *adev = ap->link.device;
  307. adev->flags |= ATA_DFLAG_NCQ_OFF;
  308. scsi_adjust_queue_depth(sdev, MSG_SIMPLE_TAG, 1);
  309. #endif
  310. }
  311. return 0;
  312. }
  313. /**
  314. * pm8001_task_exec -execute the task which come from upper level, send the
  315. * command or data to DMA area and then increase CI,for queuecommand(ssp),
  316. * it is from upper layer and for smp command,it is from libsas,
  317. * for ata command it is from libata.
  318. * @task: the task to be execute.
  319. * @num: if can_queue great than 1, the task can be queued up. for SMP task,
  320. * we always execute one one time.
  321. * @gfp_flags: gfp_flags.
  322. * @is tmf: if it is task management task.
  323. * @tmf: the task management IU
  324. */
  325. #define DEV_IS_GONE(pm8001_dev) \
  326. ((!pm8001_dev || (pm8001_dev->dev_type == NO_DEVICE)))
  327. static int pm8001_task_exec(struct sas_task *task, const int num,
  328. gfp_t gfp_flags, int is_tmf, struct pm8001_tmf_task *tmf)
  329. {
  330. struct domain_device *dev = task->dev;
  331. struct pm8001_hba_info *pm8001_ha;
  332. struct pm8001_device *pm8001_dev;
  333. struct sas_task *t = task;
  334. struct pm8001_ccb_info *ccb;
  335. u32 tag = 0xdeadbeef, rc, n_elem = 0;
  336. u32 n = num;
  337. unsigned long flags = 0;
  338. if (!dev->port) {
  339. struct task_status_struct *tsm = &t->task_status;
  340. tsm->resp = SAS_TASK_UNDELIVERED;
  341. tsm->stat = SAS_PHY_DOWN;
  342. if (dev->dev_type != SATA_DEV)
  343. t->task_done(t);
  344. return 0;
  345. }
  346. pm8001_ha = pm8001_find_ha_by_dev(task->dev);
  347. PM8001_IO_DBG(pm8001_ha, pm8001_printk("pm8001_task_exec device \n "));
  348. spin_lock_irqsave(&pm8001_ha->lock, flags);
  349. do {
  350. dev = t->dev;
  351. pm8001_dev = dev->lldd_dev;
  352. if (DEV_IS_GONE(pm8001_dev)) {
  353. if (pm8001_dev) {
  354. PM8001_IO_DBG(pm8001_ha,
  355. pm8001_printk("device %d not ready.\n",
  356. pm8001_dev->device_id));
  357. } else {
  358. PM8001_IO_DBG(pm8001_ha,
  359. pm8001_printk("device %016llx not "
  360. "ready.\n", SAS_ADDR(dev->sas_addr)));
  361. }
  362. rc = SAS_PHY_DOWN;
  363. goto out_done;
  364. }
  365. rc = pm8001_tag_alloc(pm8001_ha, &tag);
  366. if (rc)
  367. goto err_out;
  368. ccb = &pm8001_ha->ccb_info[tag];
  369. if (!sas_protocol_ata(t->task_proto)) {
  370. if (t->num_scatter) {
  371. n_elem = dma_map_sg(pm8001_ha->dev,
  372. t->scatter,
  373. t->num_scatter,
  374. t->data_dir);
  375. if (!n_elem) {
  376. rc = -ENOMEM;
  377. goto err_out;
  378. }
  379. }
  380. } else {
  381. n_elem = t->num_scatter;
  382. }
  383. t->lldd_task = NULL;
  384. ccb->n_elem = n_elem;
  385. ccb->ccb_tag = tag;
  386. ccb->task = t;
  387. switch (t->task_proto) {
  388. case SAS_PROTOCOL_SMP:
  389. rc = pm8001_task_prep_smp(pm8001_ha, ccb);
  390. break;
  391. case SAS_PROTOCOL_SSP:
  392. if (is_tmf)
  393. rc = pm8001_task_prep_ssp_tm(pm8001_ha,
  394. ccb, tmf);
  395. else
  396. rc = pm8001_task_prep_ssp(pm8001_ha, ccb);
  397. break;
  398. case SAS_PROTOCOL_SATA:
  399. case SAS_PROTOCOL_STP:
  400. case SAS_PROTOCOL_SATA | SAS_PROTOCOL_STP:
  401. rc = pm8001_task_prep_ata(pm8001_ha, ccb);
  402. break;
  403. default:
  404. dev_printk(KERN_ERR, pm8001_ha->dev,
  405. "unknown sas_task proto: 0x%x\n",
  406. t->task_proto);
  407. rc = -EINVAL;
  408. break;
  409. }
  410. if (rc) {
  411. PM8001_IO_DBG(pm8001_ha,
  412. pm8001_printk("rc is %x\n", rc));
  413. goto err_out_tag;
  414. }
  415. t->lldd_task = ccb;
  416. /* TODO: select normal or high priority */
  417. spin_lock(&t->task_state_lock);
  418. t->task_state_flags |= SAS_TASK_AT_INITIATOR;
  419. spin_unlock(&t->task_state_lock);
  420. pm8001_dev->running_req++;
  421. if (n > 1)
  422. t = list_entry(t->list.next, struct sas_task, list);
  423. } while (--n);
  424. rc = 0;
  425. goto out_done;
  426. err_out_tag:
  427. pm8001_tag_free(pm8001_ha, tag);
  428. err_out:
  429. dev_printk(KERN_ERR, pm8001_ha->dev, "pm8001 exec failed[%d]!\n", rc);
  430. if (!sas_protocol_ata(t->task_proto))
  431. if (n_elem)
  432. dma_unmap_sg(pm8001_ha->dev, t->scatter, n_elem,
  433. t->data_dir);
  434. out_done:
  435. spin_unlock_irqrestore(&pm8001_ha->lock, flags);
  436. return rc;
  437. }
  438. /**
  439. * pm8001_queue_command - register for upper layer used, all IO commands sent
  440. * to HBA are from this interface.
  441. * @task: the task to be execute.
  442. * @num: if can_queue great than 1, the task can be queued up. for SMP task,
  443. * we always execute one one time
  444. * @gfp_flags: gfp_flags
  445. */
  446. int pm8001_queue_command(struct sas_task *task, const int num,
  447. gfp_t gfp_flags)
  448. {
  449. return pm8001_task_exec(task, num, gfp_flags, 0, NULL);
  450. }
  451. void pm8001_ccb_free(struct pm8001_hba_info *pm8001_ha, u32 ccb_idx)
  452. {
  453. pm8001_tag_clear(pm8001_ha, ccb_idx);
  454. }
  455. /**
  456. * pm8001_ccb_task_free - free the sg for ssp and smp command, free the ccb.
  457. * @pm8001_ha: our hba card information
  458. * @ccb: the ccb which attached to ssp task
  459. * @task: the task to be free.
  460. * @ccb_idx: ccb index.
  461. */
  462. void pm8001_ccb_task_free(struct pm8001_hba_info *pm8001_ha,
  463. struct sas_task *task, struct pm8001_ccb_info *ccb, u32 ccb_idx)
  464. {
  465. if (!ccb->task)
  466. return;
  467. if (!sas_protocol_ata(task->task_proto))
  468. if (ccb->n_elem)
  469. dma_unmap_sg(pm8001_ha->dev, task->scatter,
  470. task->num_scatter, task->data_dir);
  471. switch (task->task_proto) {
  472. case SAS_PROTOCOL_SMP:
  473. dma_unmap_sg(pm8001_ha->dev, &task->smp_task.smp_resp, 1,
  474. PCI_DMA_FROMDEVICE);
  475. dma_unmap_sg(pm8001_ha->dev, &task->smp_task.smp_req, 1,
  476. PCI_DMA_TODEVICE);
  477. break;
  478. case SAS_PROTOCOL_SATA:
  479. case SAS_PROTOCOL_STP:
  480. case SAS_PROTOCOL_SSP:
  481. default:
  482. /* do nothing */
  483. break;
  484. }
  485. task->lldd_task = NULL;
  486. ccb->task = NULL;
  487. ccb->ccb_tag = 0xFFFFFFFF;
  488. pm8001_ccb_free(pm8001_ha, ccb_idx);
  489. }
  490. /**
  491. * pm8001_alloc_dev - find the empty pm8001_device structure, allocate and
  492. * return it for use.
  493. * @pm8001_ha: our hba card information
  494. */
  495. struct pm8001_device *pm8001_alloc_dev(struct pm8001_hba_info *pm8001_ha)
  496. {
  497. u32 dev;
  498. for (dev = 0; dev < PM8001_MAX_DEVICES; dev++) {
  499. if (pm8001_ha->devices[dev].dev_type == NO_DEVICE) {
  500. pm8001_ha->devices[dev].id = dev;
  501. return &pm8001_ha->devices[dev];
  502. }
  503. }
  504. if (dev == PM8001_MAX_DEVICES) {
  505. PM8001_FAIL_DBG(pm8001_ha,
  506. pm8001_printk("max support %d devices, ignore ..\n",
  507. PM8001_MAX_DEVICES));
  508. }
  509. return NULL;
  510. }
  511. static void pm8001_free_dev(struct pm8001_device *pm8001_dev)
  512. {
  513. u32 id = pm8001_dev->id;
  514. memset(pm8001_dev, 0, sizeof(*pm8001_dev));
  515. pm8001_dev->id = id;
  516. pm8001_dev->dev_type = NO_DEVICE;
  517. pm8001_dev->device_id = PM8001_MAX_DEVICES;
  518. pm8001_dev->sas_device = NULL;
  519. }
  520. /**
  521. * pm8001_dev_found_notify - when libsas find a sas domain device, it should
  522. * tell the LLDD that device is found, and then LLDD register this device to
  523. * HBA FW by the command "OPC_INB_REG_DEV", after that the HBA will assign
  524. * a device ID(according to device's sas address) and returned it to LLDD.from
  525. * now on, we communicate with HBA FW with the device ID which HBA assigned
  526. * rather than sas address. it is the neccessary step for our HBA but it is
  527. * the optional for other HBA driver.
  528. * @dev: the device structure which sas layer used.
  529. */
  530. static int pm8001_dev_found_notify(struct domain_device *dev)
  531. {
  532. unsigned long flags = 0;
  533. int res = 0;
  534. struct pm8001_hba_info *pm8001_ha = NULL;
  535. struct domain_device *parent_dev = dev->parent;
  536. struct pm8001_device *pm8001_device;
  537. DECLARE_COMPLETION_ONSTACK(completion);
  538. u32 flag = 0;
  539. pm8001_ha = pm8001_find_ha_by_dev(dev);
  540. spin_lock_irqsave(&pm8001_ha->lock, flags);
  541. pm8001_device = pm8001_alloc_dev(pm8001_ha);
  542. pm8001_device->sas_device = dev;
  543. if (!pm8001_device) {
  544. res = -1;
  545. goto found_out;
  546. }
  547. dev->lldd_dev = pm8001_device;
  548. pm8001_device->dev_type = dev->dev_type;
  549. pm8001_device->dcompletion = &completion;
  550. if (parent_dev && DEV_IS_EXPANDER(parent_dev->dev_type)) {
  551. int phy_id;
  552. struct ex_phy *phy;
  553. for (phy_id = 0; phy_id < parent_dev->ex_dev.num_phys;
  554. phy_id++) {
  555. phy = &parent_dev->ex_dev.ex_phy[phy_id];
  556. if (SAS_ADDR(phy->attached_sas_addr)
  557. == SAS_ADDR(dev->sas_addr)) {
  558. pm8001_device->attached_phy = phy_id;
  559. break;
  560. }
  561. }
  562. if (phy_id == parent_dev->ex_dev.num_phys) {
  563. PM8001_FAIL_DBG(pm8001_ha,
  564. pm8001_printk("Error: no attached dev:%016llx"
  565. " at ex:%016llx.\n", SAS_ADDR(dev->sas_addr),
  566. SAS_ADDR(parent_dev->sas_addr)));
  567. res = -1;
  568. }
  569. } else {
  570. if (dev->dev_type == SATA_DEV) {
  571. pm8001_device->attached_phy =
  572. dev->rphy->identify.phy_identifier;
  573. flag = 1; /* directly sata*/
  574. }
  575. } /*register this device to HBA*/
  576. PM8001_DISC_DBG(pm8001_ha, pm8001_printk("Found device \n"));
  577. PM8001_CHIP_DISP->reg_dev_req(pm8001_ha, pm8001_device, flag);
  578. spin_unlock_irqrestore(&pm8001_ha->lock, flags);
  579. wait_for_completion(&completion);
  580. if (dev->dev_type == SAS_END_DEV)
  581. msleep(50);
  582. pm8001_ha->flags = PM8001F_RUN_TIME ;
  583. return 0;
  584. found_out:
  585. spin_unlock_irqrestore(&pm8001_ha->lock, flags);
  586. return res;
  587. }
  588. int pm8001_dev_found(struct domain_device *dev)
  589. {
  590. return pm8001_dev_found_notify(dev);
  591. }
  592. /**
  593. * pm8001_alloc_task - allocate a task structure for TMF
  594. */
  595. static struct sas_task *pm8001_alloc_task(void)
  596. {
  597. struct sas_task *task = kzalloc(sizeof(*task), GFP_KERNEL);
  598. if (task) {
  599. INIT_LIST_HEAD(&task->list);
  600. spin_lock_init(&task->task_state_lock);
  601. task->task_state_flags = SAS_TASK_STATE_PENDING;
  602. init_timer(&task->timer);
  603. init_completion(&task->completion);
  604. }
  605. return task;
  606. }
  607. static void pm8001_free_task(struct sas_task *task)
  608. {
  609. if (task) {
  610. BUG_ON(!list_empty(&task->list));
  611. kfree(task);
  612. }
  613. }
  614. static void pm8001_task_done(struct sas_task *task)
  615. {
  616. if (!del_timer(&task->timer))
  617. return;
  618. complete(&task->completion);
  619. }
  620. static void pm8001_tmf_timedout(unsigned long data)
  621. {
  622. struct sas_task *task = (struct sas_task *)data;
  623. task->task_state_flags |= SAS_TASK_STATE_ABORTED;
  624. complete(&task->completion);
  625. }
  626. #define PM8001_TASK_TIMEOUT 20
  627. /**
  628. * pm8001_exec_internal_tmf_task - when errors or exception happened, we may
  629. * want to do something, for example abort issued task which result in this
  630. * execption, this is by calling this function, note it is also with the task
  631. * execute interface.
  632. * @dev: the wanted device.
  633. * @tmf: which task management wanted to be take.
  634. * @para_len: para_len.
  635. * @parameter: ssp task parameter.
  636. */
  637. static int pm8001_exec_internal_tmf_task(struct domain_device *dev,
  638. void *parameter, u32 para_len, struct pm8001_tmf_task *tmf)
  639. {
  640. int res, retry;
  641. struct sas_task *task = NULL;
  642. struct pm8001_hba_info *pm8001_ha = pm8001_find_ha_by_dev(dev);
  643. for (retry = 0; retry < 3; retry++) {
  644. task = pm8001_alloc_task();
  645. if (!task)
  646. return -ENOMEM;
  647. task->dev = dev;
  648. task->task_proto = dev->tproto;
  649. memcpy(&task->ssp_task, parameter, para_len);
  650. task->task_done = pm8001_task_done;
  651. task->timer.data = (unsigned long)task;
  652. task->timer.function = pm8001_tmf_timedout;
  653. task->timer.expires = jiffies + PM8001_TASK_TIMEOUT*HZ;
  654. add_timer(&task->timer);
  655. res = pm8001_task_exec(task, 1, GFP_KERNEL, 1, tmf);
  656. if (res) {
  657. del_timer(&task->timer);
  658. PM8001_FAIL_DBG(pm8001_ha,
  659. pm8001_printk("Executing internal task "
  660. "failed\n"));
  661. goto ex_err;
  662. }
  663. wait_for_completion(&task->completion);
  664. res = -TMF_RESP_FUNC_FAILED;
  665. /* Even TMF timed out, return direct. */
  666. if ((task->task_state_flags & SAS_TASK_STATE_ABORTED)) {
  667. if (!(task->task_state_flags & SAS_TASK_STATE_DONE)) {
  668. PM8001_FAIL_DBG(pm8001_ha,
  669. pm8001_printk("TMF task[%x]timeout.\n",
  670. tmf->tmf));
  671. goto ex_err;
  672. }
  673. }
  674. if (task->task_status.resp == SAS_TASK_COMPLETE &&
  675. task->task_status.stat == SAM_GOOD) {
  676. res = TMF_RESP_FUNC_COMPLETE;
  677. break;
  678. }
  679. if (task->task_status.resp == SAS_TASK_COMPLETE &&
  680. task->task_status.stat == SAS_DATA_UNDERRUN) {
  681. /* no error, but return the number of bytes of
  682. * underrun */
  683. res = task->task_status.residual;
  684. break;
  685. }
  686. if (task->task_status.resp == SAS_TASK_COMPLETE &&
  687. task->task_status.stat == SAS_DATA_OVERRUN) {
  688. PM8001_FAIL_DBG(pm8001_ha,
  689. pm8001_printk("Blocked task error.\n"));
  690. res = -EMSGSIZE;
  691. break;
  692. } else {
  693. PM8001_IO_DBG(pm8001_ha,
  694. pm8001_printk(" Task to dev %016llx response: 0x%x"
  695. "status 0x%x\n",
  696. SAS_ADDR(dev->sas_addr),
  697. task->task_status.resp,
  698. task->task_status.stat));
  699. pm8001_free_task(task);
  700. task = NULL;
  701. }
  702. }
  703. ex_err:
  704. BUG_ON(retry == 3 && task != NULL);
  705. if (task != NULL)
  706. pm8001_free_task(task);
  707. return res;
  708. }
  709. static int
  710. pm8001_exec_internal_task_abort(struct pm8001_hba_info *pm8001_ha,
  711. struct pm8001_device *pm8001_dev, struct domain_device *dev, u32 flag,
  712. u32 task_tag)
  713. {
  714. int res, retry;
  715. u32 rc, ccb_tag;
  716. struct pm8001_ccb_info *ccb;
  717. struct sas_task *task = NULL;
  718. for (retry = 0; retry < 3; retry++) {
  719. task = pm8001_alloc_task();
  720. if (!task)
  721. return -ENOMEM;
  722. task->dev = dev;
  723. task->task_proto = dev->tproto;
  724. task->task_done = pm8001_task_done;
  725. task->timer.data = (unsigned long)task;
  726. task->timer.function = pm8001_tmf_timedout;
  727. task->timer.expires = jiffies + PM8001_TASK_TIMEOUT*HZ;
  728. add_timer(&task->timer);
  729. rc = pm8001_tag_alloc(pm8001_ha, &ccb_tag);
  730. if (rc)
  731. return rc;
  732. ccb = &pm8001_ha->ccb_info[ccb_tag];
  733. ccb->device = pm8001_dev;
  734. ccb->ccb_tag = ccb_tag;
  735. ccb->task = task;
  736. res = PM8001_CHIP_DISP->task_abort(pm8001_ha,
  737. pm8001_dev, flag, task_tag, ccb_tag);
  738. if (res) {
  739. del_timer(&task->timer);
  740. PM8001_FAIL_DBG(pm8001_ha,
  741. pm8001_printk("Executing internal task "
  742. "failed\n"));
  743. goto ex_err;
  744. }
  745. wait_for_completion(&task->completion);
  746. res = TMF_RESP_FUNC_FAILED;
  747. /* Even TMF timed out, return direct. */
  748. if ((task->task_state_flags & SAS_TASK_STATE_ABORTED)) {
  749. if (!(task->task_state_flags & SAS_TASK_STATE_DONE)) {
  750. PM8001_FAIL_DBG(pm8001_ha,
  751. pm8001_printk("TMF task timeout.\n"));
  752. goto ex_err;
  753. }
  754. }
  755. if (task->task_status.resp == SAS_TASK_COMPLETE &&
  756. task->task_status.stat == SAM_GOOD) {
  757. res = TMF_RESP_FUNC_COMPLETE;
  758. break;
  759. } else {
  760. PM8001_IO_DBG(pm8001_ha,
  761. pm8001_printk(" Task to dev %016llx response: "
  762. "0x%x status 0x%x\n",
  763. SAS_ADDR(dev->sas_addr),
  764. task->task_status.resp,
  765. task->task_status.stat));
  766. pm8001_free_task(task);
  767. task = NULL;
  768. }
  769. }
  770. ex_err:
  771. BUG_ON(retry == 3 && task != NULL);
  772. if (task != NULL)
  773. pm8001_free_task(task);
  774. return res;
  775. }
  776. /**
  777. * pm8001_dev_gone_notify - see the comments for "pm8001_dev_found_notify"
  778. * @dev: the device structure which sas layer used.
  779. */
  780. static void pm8001_dev_gone_notify(struct domain_device *dev)
  781. {
  782. unsigned long flags = 0;
  783. u32 tag;
  784. struct pm8001_hba_info *pm8001_ha;
  785. struct pm8001_device *pm8001_dev = dev->lldd_dev;
  786. u32 device_id = pm8001_dev->device_id;
  787. pm8001_ha = pm8001_find_ha_by_dev(dev);
  788. spin_lock_irqsave(&pm8001_ha->lock, flags);
  789. pm8001_tag_alloc(pm8001_ha, &tag);
  790. if (pm8001_dev) {
  791. PM8001_DISC_DBG(pm8001_ha,
  792. pm8001_printk("found dev[%d:%x] is gone.\n",
  793. pm8001_dev->device_id, pm8001_dev->dev_type));
  794. if (pm8001_dev->running_req) {
  795. spin_unlock_irqrestore(&pm8001_ha->lock, flags);
  796. pm8001_exec_internal_task_abort(pm8001_ha, pm8001_dev ,
  797. dev, 1, 0);
  798. spin_lock_irqsave(&pm8001_ha->lock, flags);
  799. }
  800. PM8001_CHIP_DISP->dereg_dev_req(pm8001_ha, device_id);
  801. pm8001_free_dev(pm8001_dev);
  802. } else {
  803. PM8001_DISC_DBG(pm8001_ha,
  804. pm8001_printk("Found dev has gone.\n"));
  805. }
  806. dev->lldd_dev = NULL;
  807. spin_unlock_irqrestore(&pm8001_ha->lock, flags);
  808. }
  809. void pm8001_dev_gone(struct domain_device *dev)
  810. {
  811. pm8001_dev_gone_notify(dev);
  812. }
  813. static int pm8001_issue_ssp_tmf(struct domain_device *dev,
  814. u8 *lun, struct pm8001_tmf_task *tmf)
  815. {
  816. struct sas_ssp_task ssp_task;
  817. if (!(dev->tproto & SAS_PROTOCOL_SSP))
  818. return TMF_RESP_FUNC_ESUPP;
  819. strncpy((u8 *)&ssp_task.LUN, lun, 8);
  820. return pm8001_exec_internal_tmf_task(dev, &ssp_task, sizeof(ssp_task),
  821. tmf);
  822. }
  823. /**
  824. * Standard mandates link reset for ATA (type 0) and hard reset for
  825. * SSP (type 1) , only for RECOVERY
  826. */
  827. int pm8001_I_T_nexus_reset(struct domain_device *dev)
  828. {
  829. int rc = TMF_RESP_FUNC_FAILED;
  830. struct pm8001_device *pm8001_dev;
  831. struct pm8001_hba_info *pm8001_ha;
  832. struct sas_phy *phy;
  833. if (!dev || !dev->lldd_dev)
  834. return -1;
  835. pm8001_dev = dev->lldd_dev;
  836. pm8001_ha = pm8001_find_ha_by_dev(dev);
  837. phy = sas_find_local_phy(dev);
  838. if (dev_is_sata(dev)) {
  839. DECLARE_COMPLETION_ONSTACK(completion_setstate);
  840. rc = sas_phy_reset(phy, 1);
  841. msleep(2000);
  842. rc = pm8001_exec_internal_task_abort(pm8001_ha, pm8001_dev ,
  843. dev, 1, 0);
  844. pm8001_dev->setds_completion = &completion_setstate;
  845. rc = PM8001_CHIP_DISP->set_dev_state_req(pm8001_ha,
  846. pm8001_dev, 0x01);
  847. wait_for_completion(&completion_setstate);
  848. } else{
  849. rc = sas_phy_reset(phy, 1);
  850. msleep(2000);
  851. }
  852. PM8001_EH_DBG(pm8001_ha, pm8001_printk(" for device[%x]:rc=%d\n",
  853. pm8001_dev->device_id, rc));
  854. return rc;
  855. }
  856. /* mandatory SAM-3, the task reset the specified LUN*/
  857. int pm8001_lu_reset(struct domain_device *dev, u8 *lun)
  858. {
  859. int rc = TMF_RESP_FUNC_FAILED;
  860. struct pm8001_tmf_task tmf_task;
  861. struct pm8001_device *pm8001_dev = dev->lldd_dev;
  862. struct pm8001_hba_info *pm8001_ha = pm8001_find_ha_by_dev(dev);
  863. if (dev_is_sata(dev)) {
  864. struct sas_phy *phy = sas_find_local_phy(dev);
  865. rc = pm8001_exec_internal_task_abort(pm8001_ha, pm8001_dev ,
  866. dev, 1, 0);
  867. rc = sas_phy_reset(phy, 1);
  868. rc = PM8001_CHIP_DISP->set_dev_state_req(pm8001_ha,
  869. pm8001_dev, 0x01);
  870. msleep(2000);
  871. } else {
  872. tmf_task.tmf = TMF_LU_RESET;
  873. rc = pm8001_issue_ssp_tmf(dev, lun, &tmf_task);
  874. }
  875. /* If failed, fall-through I_T_Nexus reset */
  876. PM8001_EH_DBG(pm8001_ha, pm8001_printk("for device[%x]:rc=%d\n",
  877. pm8001_dev->device_id, rc));
  878. return rc;
  879. }
  880. /* optional SAM-3 */
  881. int pm8001_query_task(struct sas_task *task)
  882. {
  883. u32 tag = 0xdeadbeef;
  884. int i = 0;
  885. struct scsi_lun lun;
  886. struct pm8001_tmf_task tmf_task;
  887. int rc = TMF_RESP_FUNC_FAILED;
  888. if (unlikely(!task || !task->lldd_task || !task->dev))
  889. return rc;
  890. if (task->task_proto & SAS_PROTOCOL_SSP) {
  891. struct scsi_cmnd *cmnd = task->uldd_task;
  892. struct domain_device *dev = task->dev;
  893. struct pm8001_hba_info *pm8001_ha =
  894. pm8001_find_ha_by_dev(dev);
  895. int_to_scsilun(cmnd->device->lun, &lun);
  896. rc = pm8001_find_tag(task, &tag);
  897. if (rc == 0) {
  898. rc = TMF_RESP_FUNC_FAILED;
  899. return rc;
  900. }
  901. PM8001_EH_DBG(pm8001_ha, pm8001_printk("Query:["));
  902. for (i = 0; i < 16; i++)
  903. printk(KERN_INFO "%02x ", cmnd->cmnd[i]);
  904. printk(KERN_INFO "]\n");
  905. tmf_task.tmf = TMF_QUERY_TASK;
  906. tmf_task.tag_of_task_to_be_managed = tag;
  907. rc = pm8001_issue_ssp_tmf(dev, lun.scsi_lun, &tmf_task);
  908. switch (rc) {
  909. /* The task is still in Lun, release it then */
  910. case TMF_RESP_FUNC_SUCC:
  911. PM8001_EH_DBG(pm8001_ha,
  912. pm8001_printk("The task is still in Lun \n"));
  913. /* The task is not in Lun or failed, reset the phy */
  914. case TMF_RESP_FUNC_FAILED:
  915. case TMF_RESP_FUNC_COMPLETE:
  916. PM8001_EH_DBG(pm8001_ha,
  917. pm8001_printk("The task is not in Lun or failed,"
  918. " reset the phy \n"));
  919. break;
  920. }
  921. }
  922. pm8001_printk(":rc= %d\n", rc);
  923. return rc;
  924. }
  925. /* mandatory SAM-3, still need free task/ccb info, abord the specified task */
  926. int pm8001_abort_task(struct sas_task *task)
  927. {
  928. unsigned long flags;
  929. u32 tag = 0xdeadbeef;
  930. u32 device_id;
  931. struct domain_device *dev ;
  932. struct pm8001_hba_info *pm8001_ha = NULL;
  933. struct pm8001_ccb_info *ccb;
  934. struct scsi_lun lun;
  935. struct pm8001_device *pm8001_dev;
  936. struct pm8001_tmf_task tmf_task;
  937. int rc = TMF_RESP_FUNC_FAILED;
  938. if (unlikely(!task || !task->lldd_task || !task->dev))
  939. return rc;
  940. spin_lock_irqsave(&task->task_state_lock, flags);
  941. if (task->task_state_flags & SAS_TASK_STATE_DONE) {
  942. spin_unlock_irqrestore(&task->task_state_lock, flags);
  943. rc = TMF_RESP_FUNC_COMPLETE;
  944. goto out;
  945. }
  946. spin_unlock_irqrestore(&task->task_state_lock, flags);
  947. if (task->task_proto & SAS_PROTOCOL_SSP) {
  948. struct scsi_cmnd *cmnd = task->uldd_task;
  949. dev = task->dev;
  950. ccb = task->lldd_task;
  951. pm8001_dev = dev->lldd_dev;
  952. pm8001_ha = pm8001_find_ha_by_dev(dev);
  953. int_to_scsilun(cmnd->device->lun, &lun);
  954. rc = pm8001_find_tag(task, &tag);
  955. if (rc == 0) {
  956. printk(KERN_INFO "No such tag in %s\n", __func__);
  957. rc = TMF_RESP_FUNC_FAILED;
  958. return rc;
  959. }
  960. device_id = pm8001_dev->device_id;
  961. PM8001_EH_DBG(pm8001_ha,
  962. pm8001_printk("abort io to device_id = %d\n", device_id));
  963. tmf_task.tmf = TMF_ABORT_TASK;
  964. tmf_task.tag_of_task_to_be_managed = tag;
  965. rc = pm8001_issue_ssp_tmf(dev, lun.scsi_lun, &tmf_task);
  966. rc = pm8001_exec_internal_task_abort(pm8001_ha, pm8001_dev,
  967. pm8001_dev->sas_device, 0, tag);
  968. } else if (task->task_proto & SAS_PROTOCOL_SATA ||
  969. task->task_proto & SAS_PROTOCOL_STP) {
  970. dev = task->dev;
  971. pm8001_dev = dev->lldd_dev;
  972. pm8001_ha = pm8001_find_ha_by_dev(dev);
  973. rc = pm8001_find_tag(task, &tag);
  974. if (rc == 0) {
  975. printk(KERN_INFO "No such tag in %s\n", __func__);
  976. rc = TMF_RESP_FUNC_FAILED;
  977. return rc;
  978. }
  979. rc = pm8001_exec_internal_task_abort(pm8001_ha, pm8001_dev,
  980. pm8001_dev->sas_device, 0, tag);
  981. } else if (task->task_proto & SAS_PROTOCOL_SMP) {
  982. /* SMP */
  983. dev = task->dev;
  984. pm8001_dev = dev->lldd_dev;
  985. pm8001_ha = pm8001_find_ha_by_dev(dev);
  986. rc = pm8001_find_tag(task, &tag);
  987. if (rc == 0) {
  988. printk(KERN_INFO "No such tag in %s\n", __func__);
  989. rc = TMF_RESP_FUNC_FAILED;
  990. return rc;
  991. }
  992. rc = pm8001_exec_internal_task_abort(pm8001_ha, pm8001_dev,
  993. pm8001_dev->sas_device, 0, tag);
  994. }
  995. out:
  996. if (rc != TMF_RESP_FUNC_COMPLETE)
  997. pm8001_printk("rc= %d\n", rc);
  998. return rc;
  999. }
  1000. int pm8001_abort_task_set(struct domain_device *dev, u8 *lun)
  1001. {
  1002. int rc = TMF_RESP_FUNC_FAILED;
  1003. struct pm8001_tmf_task tmf_task;
  1004. tmf_task.tmf = TMF_ABORT_TASK_SET;
  1005. rc = pm8001_issue_ssp_tmf(dev, lun, &tmf_task);
  1006. return rc;
  1007. }
  1008. int pm8001_clear_aca(struct domain_device *dev, u8 *lun)
  1009. {
  1010. int rc = TMF_RESP_FUNC_FAILED;
  1011. struct pm8001_tmf_task tmf_task;
  1012. tmf_task.tmf = TMF_CLEAR_ACA;
  1013. rc = pm8001_issue_ssp_tmf(dev, lun, &tmf_task);
  1014. return rc;
  1015. }
  1016. int pm8001_clear_task_set(struct domain_device *dev, u8 *lun)
  1017. {
  1018. int rc = TMF_RESP_FUNC_FAILED;
  1019. struct pm8001_tmf_task tmf_task;
  1020. struct pm8001_device *pm8001_dev = dev->lldd_dev;
  1021. struct pm8001_hba_info *pm8001_ha = pm8001_find_ha_by_dev(dev);
  1022. PM8001_EH_DBG(pm8001_ha,
  1023. pm8001_printk("I_T_L_Q clear task set[%x]\n",
  1024. pm8001_dev->device_id));
  1025. tmf_task.tmf = TMF_CLEAR_TASK_SET;
  1026. rc = pm8001_issue_ssp_tmf(dev, lun, &tmf_task);
  1027. return rc;
  1028. }