pm8001_sas.c 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110
  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 <linux/slab.h>
  41. #include "pm8001_sas.h"
  42. /**
  43. * pm8001_find_tag - from sas task to find out tag that belongs to this task
  44. * @task: the task sent to the LLDD
  45. * @tag: the found tag associated with the task
  46. */
  47. static int pm8001_find_tag(struct sas_task *task, u32 *tag)
  48. {
  49. if (task->lldd_task) {
  50. struct pm8001_ccb_info *ccb;
  51. ccb = task->lldd_task;
  52. *tag = ccb->ccb_tag;
  53. return 1;
  54. }
  55. return 0;
  56. }
  57. /**
  58. * pm8001_tag_clear - clear the tags bitmap
  59. * @pm8001_ha: our hba struct
  60. * @tag: the found tag associated with the task
  61. */
  62. static void pm8001_tag_clear(struct pm8001_hba_info *pm8001_ha, u32 tag)
  63. {
  64. void *bitmap = pm8001_ha->tags;
  65. clear_bit(tag, bitmap);
  66. }
  67. static void pm8001_tag_free(struct pm8001_hba_info *pm8001_ha, u32 tag)
  68. {
  69. pm8001_tag_clear(pm8001_ha, tag);
  70. }
  71. static void pm8001_tag_set(struct pm8001_hba_info *pm8001_ha, u32 tag)
  72. {
  73. void *bitmap = pm8001_ha->tags;
  74. set_bit(tag, bitmap);
  75. }
  76. /**
  77. * pm8001_tag_alloc - allocate a empty tag for task used.
  78. * @pm8001_ha: our hba struct
  79. * @tag_out: the found empty tag .
  80. */
  81. inline int pm8001_tag_alloc(struct pm8001_hba_info *pm8001_ha, u32 *tag_out)
  82. {
  83. unsigned int index, tag;
  84. void *bitmap = pm8001_ha->tags;
  85. index = find_first_zero_bit(bitmap, pm8001_ha->tags_num);
  86. tag = index;
  87. if (tag >= pm8001_ha->tags_num)
  88. return -SAS_QUEUE_FULL;
  89. pm8001_tag_set(pm8001_ha, tag);
  90. *tag_out = tag;
  91. return 0;
  92. }
  93. void pm8001_tag_init(struct pm8001_hba_info *pm8001_ha)
  94. {
  95. int i;
  96. for (i = 0; i < pm8001_ha->tags_num; ++i)
  97. pm8001_tag_clear(pm8001_ha, i);
  98. }
  99. /**
  100. * pm8001_mem_alloc - allocate memory for pm8001.
  101. * @pdev: pci device.
  102. * @virt_addr: the allocated virtual address
  103. * @pphys_addr_hi: the physical address high byte address.
  104. * @pphys_addr_lo: the physical address low byte address.
  105. * @mem_size: memory size.
  106. */
  107. int pm8001_mem_alloc(struct pci_dev *pdev, void **virt_addr,
  108. dma_addr_t *pphys_addr, u32 *pphys_addr_hi,
  109. u32 *pphys_addr_lo, u32 mem_size, u32 align)
  110. {
  111. caddr_t mem_virt_alloc;
  112. dma_addr_t mem_dma_handle;
  113. u64 phys_align;
  114. u64 align_offset = 0;
  115. if (align)
  116. align_offset = (dma_addr_t)align - 1;
  117. mem_virt_alloc =
  118. pci_alloc_consistent(pdev, mem_size + align, &mem_dma_handle);
  119. if (!mem_virt_alloc) {
  120. pm8001_printk("memory allocation error\n");
  121. return -1;
  122. }
  123. memset((void *)mem_virt_alloc, 0, mem_size+align);
  124. *pphys_addr = mem_dma_handle;
  125. phys_align = (*pphys_addr + align_offset) & ~align_offset;
  126. *virt_addr = (void *)mem_virt_alloc + phys_align - *pphys_addr;
  127. *pphys_addr_hi = upper_32_bits(phys_align);
  128. *pphys_addr_lo = lower_32_bits(phys_align);
  129. return 0;
  130. }
  131. /**
  132. * pm8001_find_ha_by_dev - from domain device which come from sas layer to
  133. * find out our hba struct.
  134. * @dev: the domain device which from sas layer.
  135. */
  136. static
  137. struct pm8001_hba_info *pm8001_find_ha_by_dev(struct domain_device *dev)
  138. {
  139. struct sas_ha_struct *sha = dev->port->ha;
  140. struct pm8001_hba_info *pm8001_ha = sha->lldd_ha;
  141. return pm8001_ha;
  142. }
  143. /**
  144. * pm8001_phy_control - this function should be registered to
  145. * sas_domain_function_template to provide libsas used, note: this is just
  146. * control the HBA phy rather than other expander phy if you want control
  147. * other phy, you should use SMP command.
  148. * @sas_phy: which phy in HBA phys.
  149. * @func: the operation.
  150. * @funcdata: always NULL.
  151. */
  152. int pm8001_phy_control(struct asd_sas_phy *sas_phy, enum phy_func func,
  153. void *funcdata)
  154. {
  155. int rc = 0, phy_id = sas_phy->id;
  156. struct pm8001_hba_info *pm8001_ha = NULL;
  157. struct sas_phy_linkrates *rates;
  158. DECLARE_COMPLETION_ONSTACK(completion);
  159. unsigned long flags;
  160. pm8001_ha = sas_phy->ha->lldd_ha;
  161. pm8001_ha->phy[phy_id].enable_completion = &completion;
  162. switch (func) {
  163. case PHY_FUNC_SET_LINK_RATE:
  164. rates = funcdata;
  165. if (rates->minimum_linkrate) {
  166. pm8001_ha->phy[phy_id].minimum_linkrate =
  167. rates->minimum_linkrate;
  168. }
  169. if (rates->maximum_linkrate) {
  170. pm8001_ha->phy[phy_id].maximum_linkrate =
  171. rates->maximum_linkrate;
  172. }
  173. if (pm8001_ha->phy[phy_id].phy_state == 0) {
  174. PM8001_CHIP_DISP->phy_start_req(pm8001_ha, phy_id);
  175. wait_for_completion(&completion);
  176. }
  177. PM8001_CHIP_DISP->phy_ctl_req(pm8001_ha, phy_id,
  178. PHY_LINK_RESET);
  179. break;
  180. case PHY_FUNC_HARD_RESET:
  181. if (pm8001_ha->phy[phy_id].phy_state == 0) {
  182. PM8001_CHIP_DISP->phy_start_req(pm8001_ha, phy_id);
  183. wait_for_completion(&completion);
  184. }
  185. PM8001_CHIP_DISP->phy_ctl_req(pm8001_ha, phy_id,
  186. PHY_HARD_RESET);
  187. break;
  188. case PHY_FUNC_LINK_RESET:
  189. if (pm8001_ha->phy[phy_id].phy_state == 0) {
  190. PM8001_CHIP_DISP->phy_start_req(pm8001_ha, phy_id);
  191. wait_for_completion(&completion);
  192. }
  193. PM8001_CHIP_DISP->phy_ctl_req(pm8001_ha, phy_id,
  194. PHY_LINK_RESET);
  195. break;
  196. case PHY_FUNC_RELEASE_SPINUP_HOLD:
  197. PM8001_CHIP_DISP->phy_ctl_req(pm8001_ha, phy_id,
  198. PHY_LINK_RESET);
  199. break;
  200. case PHY_FUNC_DISABLE:
  201. PM8001_CHIP_DISP->phy_stop_req(pm8001_ha, phy_id);
  202. break;
  203. case PHY_FUNC_GET_EVENTS:
  204. spin_lock_irqsave(&pm8001_ha->lock, flags);
  205. if (-1 == pm8001_bar4_shift(pm8001_ha,
  206. (phy_id < 4) ? 0x30000 : 0x40000)) {
  207. spin_unlock_irqrestore(&pm8001_ha->lock, flags);
  208. return -EINVAL;
  209. }
  210. {
  211. struct sas_phy *phy = sas_phy->phy;
  212. uint32_t *qp = (uint32_t *)(((char *)
  213. pm8001_ha->io_mem[2].memvirtaddr)
  214. + 0x1034 + (0x4000 * (phy_id & 3)));
  215. phy->invalid_dword_count = qp[0];
  216. phy->running_disparity_error_count = qp[1];
  217. phy->loss_of_dword_sync_count = qp[3];
  218. phy->phy_reset_problem_count = qp[4];
  219. }
  220. pm8001_bar4_shift(pm8001_ha, 0);
  221. spin_unlock_irqrestore(&pm8001_ha->lock, flags);
  222. return 0;
  223. default:
  224. rc = -EOPNOTSUPP;
  225. }
  226. msleep(300);
  227. return rc;
  228. }
  229. /**
  230. * pm8001_scan_start - we should enable all HBA phys by sending the phy_start
  231. * command to HBA.
  232. * @shost: the scsi host data.
  233. */
  234. void pm8001_scan_start(struct Scsi_Host *shost)
  235. {
  236. int i;
  237. struct pm8001_hba_info *pm8001_ha;
  238. struct sas_ha_struct *sha = SHOST_TO_SAS_HA(shost);
  239. pm8001_ha = sha->lldd_ha;
  240. PM8001_CHIP_DISP->sas_re_init_req(pm8001_ha);
  241. for (i = 0; i < pm8001_ha->chip->n_phy; ++i)
  242. PM8001_CHIP_DISP->phy_start_req(pm8001_ha, i);
  243. }
  244. int pm8001_scan_finished(struct Scsi_Host *shost, unsigned long time)
  245. {
  246. /* give the phy enabling interrupt event time to come in (1s
  247. * is empirically about all it takes) */
  248. if (time < HZ)
  249. return 0;
  250. /* Wait for discovery to finish */
  251. scsi_flush_work(shost);
  252. return 1;
  253. }
  254. /**
  255. * pm8001_task_prep_smp - the dispatcher function, prepare data for smp task
  256. * @pm8001_ha: our hba card information
  257. * @ccb: the ccb which attached to smp task
  258. */
  259. static int pm8001_task_prep_smp(struct pm8001_hba_info *pm8001_ha,
  260. struct pm8001_ccb_info *ccb)
  261. {
  262. return PM8001_CHIP_DISP->smp_req(pm8001_ha, ccb);
  263. }
  264. u32 pm8001_get_ncq_tag(struct sas_task *task, u32 *tag)
  265. {
  266. struct ata_queued_cmd *qc = task->uldd_task;
  267. if (qc) {
  268. if (qc->tf.command == ATA_CMD_FPDMA_WRITE ||
  269. qc->tf.command == ATA_CMD_FPDMA_READ) {
  270. *tag = qc->tag;
  271. return 1;
  272. }
  273. }
  274. return 0;
  275. }
  276. /**
  277. * pm8001_task_prep_ata - the dispatcher function, prepare data for sata task
  278. * @pm8001_ha: our hba card information
  279. * @ccb: the ccb which attached to sata task
  280. */
  281. static int pm8001_task_prep_ata(struct pm8001_hba_info *pm8001_ha,
  282. struct pm8001_ccb_info *ccb)
  283. {
  284. return PM8001_CHIP_DISP->sata_req(pm8001_ha, ccb);
  285. }
  286. /**
  287. * pm8001_task_prep_ssp_tm - the dispatcher function, prepare task management data
  288. * @pm8001_ha: our hba card information
  289. * @ccb: the ccb which attached to TM
  290. * @tmf: the task management IU
  291. */
  292. static int pm8001_task_prep_ssp_tm(struct pm8001_hba_info *pm8001_ha,
  293. struct pm8001_ccb_info *ccb, struct pm8001_tmf_task *tmf)
  294. {
  295. return PM8001_CHIP_DISP->ssp_tm_req(pm8001_ha, ccb, tmf);
  296. }
  297. /**
  298. * pm8001_task_prep_ssp - the dispatcher function,prepare ssp data for ssp task
  299. * @pm8001_ha: our hba card information
  300. * @ccb: the ccb which attached to ssp task
  301. */
  302. static int pm8001_task_prep_ssp(struct pm8001_hba_info *pm8001_ha,
  303. struct pm8001_ccb_info *ccb)
  304. {
  305. return PM8001_CHIP_DISP->ssp_io_req(pm8001_ha, ccb);
  306. }
  307. /* Find the local port id that's attached to this device */
  308. static int sas_find_local_port_id(struct domain_device *dev)
  309. {
  310. struct domain_device *pdev = dev->parent;
  311. /* Directly attached device */
  312. if (!pdev)
  313. return dev->port->id;
  314. while (pdev) {
  315. struct domain_device *pdev_p = pdev->parent;
  316. if (!pdev_p)
  317. return pdev->port->id;
  318. pdev = pdev->parent;
  319. }
  320. return 0;
  321. }
  322. /**
  323. * pm8001_task_exec - queue the task(ssp, smp && ata) to the hardware.
  324. * @task: the task to be execute.
  325. * @num: if can_queue great than 1, the task can be queued up. for SMP task,
  326. * we always execute one one time.
  327. * @gfp_flags: gfp_flags.
  328. * @is_tmf: if it is task management task.
  329. * @tmf: the task management IU
  330. */
  331. #define DEV_IS_GONE(pm8001_dev) \
  332. ((!pm8001_dev || (pm8001_dev->dev_type == NO_DEVICE)))
  333. static int pm8001_task_exec(struct sas_task *task, const int num,
  334. gfp_t gfp_flags, int is_tmf, struct pm8001_tmf_task *tmf)
  335. {
  336. struct domain_device *dev = task->dev;
  337. struct pm8001_hba_info *pm8001_ha;
  338. struct pm8001_device *pm8001_dev;
  339. struct pm8001_port *port = NULL;
  340. struct sas_task *t = task;
  341. struct pm8001_ccb_info *ccb;
  342. u32 tag = 0xdeadbeef, rc, n_elem = 0;
  343. u32 n = num;
  344. unsigned long flags = 0, flags_libsas = 0;
  345. if (!dev->port) {
  346. struct task_status_struct *tsm = &t->task_status;
  347. tsm->resp = SAS_TASK_UNDELIVERED;
  348. tsm->stat = SAS_PHY_DOWN;
  349. if (dev->dev_type != SATA_DEV)
  350. t->task_done(t);
  351. return 0;
  352. }
  353. pm8001_ha = pm8001_find_ha_by_dev(task->dev);
  354. PM8001_IO_DBG(pm8001_ha, pm8001_printk("pm8001_task_exec device \n "));
  355. spin_lock_irqsave(&pm8001_ha->lock, flags);
  356. do {
  357. dev = t->dev;
  358. pm8001_dev = dev->lldd_dev;
  359. port = &pm8001_ha->port[sas_find_local_port_id(dev)];
  360. if (DEV_IS_GONE(pm8001_dev) || !port->port_attached) {
  361. if (sas_protocol_ata(t->task_proto)) {
  362. struct task_status_struct *ts = &t->task_status;
  363. ts->resp = SAS_TASK_UNDELIVERED;
  364. ts->stat = SAS_PHY_DOWN;
  365. spin_unlock_irqrestore(&pm8001_ha->lock, flags);
  366. spin_unlock_irqrestore(dev->sata_dev.ap->lock,
  367. flags_libsas);
  368. t->task_done(t);
  369. spin_lock_irqsave(dev->sata_dev.ap->lock,
  370. flags_libsas);
  371. spin_lock_irqsave(&pm8001_ha->lock, flags);
  372. if (n > 1)
  373. t = list_entry(t->list.next,
  374. struct sas_task, list);
  375. continue;
  376. } else {
  377. struct task_status_struct *ts = &t->task_status;
  378. ts->resp = SAS_TASK_UNDELIVERED;
  379. ts->stat = SAS_PHY_DOWN;
  380. t->task_done(t);
  381. if (n > 1)
  382. t = list_entry(t->list.next,
  383. struct sas_task, list);
  384. continue;
  385. }
  386. }
  387. rc = pm8001_tag_alloc(pm8001_ha, &tag);
  388. if (rc)
  389. goto err_out;
  390. ccb = &pm8001_ha->ccb_info[tag];
  391. if (!sas_protocol_ata(t->task_proto)) {
  392. if (t->num_scatter) {
  393. n_elem = dma_map_sg(pm8001_ha->dev,
  394. t->scatter,
  395. t->num_scatter,
  396. t->data_dir);
  397. if (!n_elem) {
  398. rc = -ENOMEM;
  399. goto err_out_tag;
  400. }
  401. }
  402. } else {
  403. n_elem = t->num_scatter;
  404. }
  405. t->lldd_task = ccb;
  406. ccb->n_elem = n_elem;
  407. ccb->ccb_tag = tag;
  408. ccb->task = t;
  409. switch (t->task_proto) {
  410. case SAS_PROTOCOL_SMP:
  411. rc = pm8001_task_prep_smp(pm8001_ha, ccb);
  412. break;
  413. case SAS_PROTOCOL_SSP:
  414. if (is_tmf)
  415. rc = pm8001_task_prep_ssp_tm(pm8001_ha,
  416. ccb, tmf);
  417. else
  418. rc = pm8001_task_prep_ssp(pm8001_ha, ccb);
  419. break;
  420. case SAS_PROTOCOL_SATA:
  421. case SAS_PROTOCOL_STP:
  422. case SAS_PROTOCOL_SATA | SAS_PROTOCOL_STP:
  423. rc = pm8001_task_prep_ata(pm8001_ha, ccb);
  424. break;
  425. default:
  426. dev_printk(KERN_ERR, pm8001_ha->dev,
  427. "unknown sas_task proto: 0x%x\n",
  428. t->task_proto);
  429. rc = -EINVAL;
  430. break;
  431. }
  432. if (rc) {
  433. PM8001_IO_DBG(pm8001_ha,
  434. pm8001_printk("rc is %x\n", rc));
  435. goto err_out_tag;
  436. }
  437. /* TODO: select normal or high priority */
  438. spin_lock(&t->task_state_lock);
  439. t->task_state_flags |= SAS_TASK_AT_INITIATOR;
  440. spin_unlock(&t->task_state_lock);
  441. pm8001_dev->running_req++;
  442. if (n > 1)
  443. t = list_entry(t->list.next, struct sas_task, list);
  444. } while (--n);
  445. rc = 0;
  446. goto out_done;
  447. err_out_tag:
  448. pm8001_tag_free(pm8001_ha, tag);
  449. err_out:
  450. dev_printk(KERN_ERR, pm8001_ha->dev, "pm8001 exec failed[%d]!\n", rc);
  451. if (!sas_protocol_ata(t->task_proto))
  452. if (n_elem)
  453. dma_unmap_sg(pm8001_ha->dev, t->scatter, n_elem,
  454. t->data_dir);
  455. out_done:
  456. spin_unlock_irqrestore(&pm8001_ha->lock, flags);
  457. return rc;
  458. }
  459. /**
  460. * pm8001_queue_command - register for upper layer used, all IO commands sent
  461. * to HBA are from this interface.
  462. * @task: the task to be execute.
  463. * @num: if can_queue great than 1, the task can be queued up. for SMP task,
  464. * we always execute one one time
  465. * @gfp_flags: gfp_flags
  466. */
  467. int pm8001_queue_command(struct sas_task *task, const int num,
  468. gfp_t gfp_flags)
  469. {
  470. return pm8001_task_exec(task, num, gfp_flags, 0, NULL);
  471. }
  472. void pm8001_ccb_free(struct pm8001_hba_info *pm8001_ha, u32 ccb_idx)
  473. {
  474. pm8001_tag_clear(pm8001_ha, ccb_idx);
  475. }
  476. /**
  477. * pm8001_ccb_task_free - free the sg for ssp and smp command, free the ccb.
  478. * @pm8001_ha: our hba card information
  479. * @ccb: the ccb which attached to ssp task
  480. * @task: the task to be free.
  481. * @ccb_idx: ccb index.
  482. */
  483. void pm8001_ccb_task_free(struct pm8001_hba_info *pm8001_ha,
  484. struct sas_task *task, struct pm8001_ccb_info *ccb, u32 ccb_idx)
  485. {
  486. if (!ccb->task)
  487. return;
  488. if (!sas_protocol_ata(task->task_proto))
  489. if (ccb->n_elem)
  490. dma_unmap_sg(pm8001_ha->dev, task->scatter,
  491. task->num_scatter, task->data_dir);
  492. switch (task->task_proto) {
  493. case SAS_PROTOCOL_SMP:
  494. dma_unmap_sg(pm8001_ha->dev, &task->smp_task.smp_resp, 1,
  495. PCI_DMA_FROMDEVICE);
  496. dma_unmap_sg(pm8001_ha->dev, &task->smp_task.smp_req, 1,
  497. PCI_DMA_TODEVICE);
  498. break;
  499. case SAS_PROTOCOL_SATA:
  500. case SAS_PROTOCOL_STP:
  501. case SAS_PROTOCOL_SSP:
  502. default:
  503. /* do nothing */
  504. break;
  505. }
  506. task->lldd_task = NULL;
  507. ccb->task = NULL;
  508. ccb->ccb_tag = 0xFFFFFFFF;
  509. pm8001_ccb_free(pm8001_ha, ccb_idx);
  510. }
  511. /**
  512. * pm8001_alloc_dev - find a empty pm8001_device
  513. * @pm8001_ha: our hba card information
  514. */
  515. struct pm8001_device *pm8001_alloc_dev(struct pm8001_hba_info *pm8001_ha)
  516. {
  517. u32 dev;
  518. for (dev = 0; dev < PM8001_MAX_DEVICES; dev++) {
  519. if (pm8001_ha->devices[dev].dev_type == NO_DEVICE) {
  520. pm8001_ha->devices[dev].id = dev;
  521. return &pm8001_ha->devices[dev];
  522. }
  523. }
  524. if (dev == PM8001_MAX_DEVICES) {
  525. PM8001_FAIL_DBG(pm8001_ha,
  526. pm8001_printk("max support %d devices, ignore ..\n",
  527. PM8001_MAX_DEVICES));
  528. }
  529. return NULL;
  530. }
  531. static void pm8001_free_dev(struct pm8001_device *pm8001_dev)
  532. {
  533. u32 id = pm8001_dev->id;
  534. memset(pm8001_dev, 0, sizeof(*pm8001_dev));
  535. pm8001_dev->id = id;
  536. pm8001_dev->dev_type = NO_DEVICE;
  537. pm8001_dev->device_id = PM8001_MAX_DEVICES;
  538. pm8001_dev->sas_device = NULL;
  539. }
  540. /**
  541. * pm8001_dev_found_notify - libsas notify a device is found.
  542. * @dev: the device structure which sas layer used.
  543. *
  544. * when libsas find a sas domain device, it should tell the LLDD that
  545. * device is found, and then LLDD register this device to HBA firmware
  546. * by the command "OPC_INB_REG_DEV", after that the HBA will assign a
  547. * device ID(according to device's sas address) and returned it to LLDD. From
  548. * now on, we communicate with HBA FW with the device ID which HBA assigned
  549. * rather than sas address. it is the necessary step for our HBA but it is
  550. * the optional for other HBA driver.
  551. */
  552. static int pm8001_dev_found_notify(struct domain_device *dev)
  553. {
  554. unsigned long flags = 0;
  555. int res = 0;
  556. struct pm8001_hba_info *pm8001_ha = NULL;
  557. struct domain_device *parent_dev = dev->parent;
  558. struct pm8001_device *pm8001_device;
  559. DECLARE_COMPLETION_ONSTACK(completion);
  560. u32 flag = 0;
  561. pm8001_ha = pm8001_find_ha_by_dev(dev);
  562. spin_lock_irqsave(&pm8001_ha->lock, flags);
  563. pm8001_device = pm8001_alloc_dev(pm8001_ha);
  564. if (!pm8001_device) {
  565. res = -1;
  566. goto found_out;
  567. }
  568. pm8001_device->sas_device = dev;
  569. dev->lldd_dev = pm8001_device;
  570. pm8001_device->dev_type = dev->dev_type;
  571. pm8001_device->dcompletion = &completion;
  572. if (parent_dev && DEV_IS_EXPANDER(parent_dev->dev_type)) {
  573. int phy_id;
  574. struct ex_phy *phy;
  575. for (phy_id = 0; phy_id < parent_dev->ex_dev.num_phys;
  576. phy_id++) {
  577. phy = &parent_dev->ex_dev.ex_phy[phy_id];
  578. if (SAS_ADDR(phy->attached_sas_addr)
  579. == SAS_ADDR(dev->sas_addr)) {
  580. pm8001_device->attached_phy = phy_id;
  581. break;
  582. }
  583. }
  584. if (phy_id == parent_dev->ex_dev.num_phys) {
  585. PM8001_FAIL_DBG(pm8001_ha,
  586. pm8001_printk("Error: no attached dev:%016llx"
  587. " at ex:%016llx.\n", SAS_ADDR(dev->sas_addr),
  588. SAS_ADDR(parent_dev->sas_addr)));
  589. res = -1;
  590. }
  591. } else {
  592. if (dev->dev_type == SATA_DEV) {
  593. pm8001_device->attached_phy =
  594. dev->rphy->identify.phy_identifier;
  595. flag = 1; /* directly sata*/
  596. }
  597. } /*register this device to HBA*/
  598. PM8001_DISC_DBG(pm8001_ha, pm8001_printk("Found device\n"));
  599. PM8001_CHIP_DISP->reg_dev_req(pm8001_ha, pm8001_device, flag);
  600. spin_unlock_irqrestore(&pm8001_ha->lock, flags);
  601. wait_for_completion(&completion);
  602. if (dev->dev_type == SAS_END_DEV)
  603. msleep(50);
  604. pm8001_ha->flags = PM8001F_RUN_TIME;
  605. return 0;
  606. found_out:
  607. spin_unlock_irqrestore(&pm8001_ha->lock, flags);
  608. return res;
  609. }
  610. int pm8001_dev_found(struct domain_device *dev)
  611. {
  612. return pm8001_dev_found_notify(dev);
  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 - execute some task management commands.
  629. * @dev: the wanted device.
  630. * @tmf: which task management wanted to be take.
  631. * @para_len: para_len.
  632. * @parameter: ssp task parameter.
  633. *
  634. * when errors or exception happened, we may want to do something, for example
  635. * abort the issued task which result in this execption, it is done by calling
  636. * this function, note it is also with the task execute interface.
  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 = sas_alloc_task(GFP_KERNEL);
  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_STAT_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_EH_DBG(pm8001_ha,
  695. pm8001_printk(" Task to dev %016llx response:"
  696. "0x%x status 0x%x\n",
  697. SAS_ADDR(dev->sas_addr),
  698. task->task_status.resp,
  699. task->task_status.stat));
  700. sas_free_task(task);
  701. task = NULL;
  702. }
  703. }
  704. ex_err:
  705. BUG_ON(retry == 3 && task != NULL);
  706. sas_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 ccb_tag;
  716. struct pm8001_ccb_info *ccb;
  717. struct sas_task *task = NULL;
  718. for (retry = 0; retry < 3; retry++) {
  719. task = sas_alloc_task(GFP_KERNEL);
  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. res = pm8001_tag_alloc(pm8001_ha, &ccb_tag);
  730. if (res)
  731. return res;
  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_STAT_GOOD) {
  757. res = TMF_RESP_FUNC_COMPLETE;
  758. break;
  759. } else {
  760. PM8001_EH_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. sas_free_task(task);
  767. task = NULL;
  768. }
  769. }
  770. ex_err:
  771. BUG_ON(retry == 3 && task != NULL);
  772. sas_free_task(task);
  773. return res;
  774. }
  775. /**
  776. * pm8001_dev_gone_notify - see the comments for "pm8001_dev_found_notify"
  777. * @dev: the device structure which sas layer used.
  778. */
  779. static void pm8001_dev_gone_notify(struct domain_device *dev)
  780. {
  781. unsigned long flags = 0;
  782. u32 tag;
  783. struct pm8001_hba_info *pm8001_ha;
  784. struct pm8001_device *pm8001_dev = dev->lldd_dev;
  785. pm8001_ha = pm8001_find_ha_by_dev(dev);
  786. spin_lock_irqsave(&pm8001_ha->lock, flags);
  787. pm8001_tag_alloc(pm8001_ha, &tag);
  788. if (pm8001_dev) {
  789. u32 device_id = pm8001_dev->device_id;
  790. PM8001_DISC_DBG(pm8001_ha,
  791. pm8001_printk("found dev[%d:%x] is gone.\n",
  792. pm8001_dev->device_id, pm8001_dev->dev_type));
  793. if (pm8001_dev->running_req) {
  794. spin_unlock_irqrestore(&pm8001_ha->lock, flags);
  795. pm8001_exec_internal_task_abort(pm8001_ha, pm8001_dev ,
  796. dev, 1, 0);
  797. spin_lock_irqsave(&pm8001_ha->lock, flags);
  798. }
  799. PM8001_CHIP_DISP->dereg_dev_req(pm8001_ha, device_id);
  800. pm8001_free_dev(pm8001_dev);
  801. } else {
  802. PM8001_DISC_DBG(pm8001_ha,
  803. pm8001_printk("Found dev has gone.\n"));
  804. }
  805. dev->lldd_dev = NULL;
  806. spin_unlock_irqrestore(&pm8001_ha->lock, flags);
  807. }
  808. void pm8001_dev_gone(struct domain_device *dev)
  809. {
  810. pm8001_dev_gone_notify(dev);
  811. }
  812. static int pm8001_issue_ssp_tmf(struct domain_device *dev,
  813. u8 *lun, struct pm8001_tmf_task *tmf)
  814. {
  815. struct sas_ssp_task ssp_task;
  816. if (!(dev->tproto & SAS_PROTOCOL_SSP))
  817. return TMF_RESP_FUNC_ESUPP;
  818. strncpy((u8 *)&ssp_task.LUN, lun, 8);
  819. return pm8001_exec_internal_tmf_task(dev, &ssp_task, sizeof(ssp_task),
  820. tmf);
  821. }
  822. /**
  823. * Standard mandates link reset for ATA (type 0) and hard reset for
  824. * SSP (type 1) , only for RECOVERY
  825. */
  826. int pm8001_I_T_nexus_reset(struct domain_device *dev)
  827. {
  828. int rc = TMF_RESP_FUNC_FAILED;
  829. struct pm8001_device *pm8001_dev;
  830. struct pm8001_hba_info *pm8001_ha;
  831. struct sas_phy *phy;
  832. if (!dev || !dev->lldd_dev)
  833. return -1;
  834. pm8001_dev = dev->lldd_dev;
  835. pm8001_ha = pm8001_find_ha_by_dev(dev);
  836. phy = sas_find_local_phy(dev);
  837. if (dev_is_sata(dev)) {
  838. DECLARE_COMPLETION_ONSTACK(completion_setstate);
  839. if (scsi_is_sas_phy_local(phy))
  840. return 0;
  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. break;
  915. /* The task is not in Lun or failed, reset the phy */
  916. case TMF_RESP_FUNC_FAILED:
  917. case TMF_RESP_FUNC_COMPLETE:
  918. PM8001_EH_DBG(pm8001_ha,
  919. pm8001_printk("The task is not in Lun or failed,"
  920. " reset the phy\n"));
  921. break;
  922. }
  923. }
  924. pm8001_printk(":rc= %d\n", rc);
  925. return rc;
  926. }
  927. /* mandatory SAM-3, still need free task/ccb info, abord the specified task */
  928. int pm8001_abort_task(struct sas_task *task)
  929. {
  930. unsigned long flags;
  931. u32 tag = 0xdeadbeef;
  932. u32 device_id;
  933. struct domain_device *dev ;
  934. struct pm8001_hba_info *pm8001_ha = NULL;
  935. struct pm8001_ccb_info *ccb;
  936. struct scsi_lun lun;
  937. struct pm8001_device *pm8001_dev;
  938. struct pm8001_tmf_task tmf_task;
  939. int rc = TMF_RESP_FUNC_FAILED;
  940. if (unlikely(!task || !task->lldd_task || !task->dev))
  941. return rc;
  942. spin_lock_irqsave(&task->task_state_lock, flags);
  943. if (task->task_state_flags & SAS_TASK_STATE_DONE) {
  944. spin_unlock_irqrestore(&task->task_state_lock, flags);
  945. rc = TMF_RESP_FUNC_COMPLETE;
  946. goto out;
  947. }
  948. spin_unlock_irqrestore(&task->task_state_lock, flags);
  949. if (task->task_proto & SAS_PROTOCOL_SSP) {
  950. struct scsi_cmnd *cmnd = task->uldd_task;
  951. dev = task->dev;
  952. ccb = task->lldd_task;
  953. pm8001_dev = dev->lldd_dev;
  954. pm8001_ha = pm8001_find_ha_by_dev(dev);
  955. int_to_scsilun(cmnd->device->lun, &lun);
  956. rc = pm8001_find_tag(task, &tag);
  957. if (rc == 0) {
  958. printk(KERN_INFO "No such tag in %s\n", __func__);
  959. rc = TMF_RESP_FUNC_FAILED;
  960. return rc;
  961. }
  962. device_id = pm8001_dev->device_id;
  963. PM8001_EH_DBG(pm8001_ha,
  964. pm8001_printk("abort io to deviceid= %d\n", device_id));
  965. tmf_task.tmf = TMF_ABORT_TASK;
  966. tmf_task.tag_of_task_to_be_managed = tag;
  967. rc = pm8001_issue_ssp_tmf(dev, lun.scsi_lun, &tmf_task);
  968. pm8001_exec_internal_task_abort(pm8001_ha, pm8001_dev,
  969. pm8001_dev->sas_device, 0, tag);
  970. } else if (task->task_proto & SAS_PROTOCOL_SATA ||
  971. task->task_proto & SAS_PROTOCOL_STP) {
  972. dev = task->dev;
  973. pm8001_dev = dev->lldd_dev;
  974. pm8001_ha = pm8001_find_ha_by_dev(dev);
  975. rc = pm8001_find_tag(task, &tag);
  976. if (rc == 0) {
  977. printk(KERN_INFO "No such tag in %s\n", __func__);
  978. rc = TMF_RESP_FUNC_FAILED;
  979. return rc;
  980. }
  981. rc = pm8001_exec_internal_task_abort(pm8001_ha, pm8001_dev,
  982. pm8001_dev->sas_device, 0, tag);
  983. } else if (task->task_proto & SAS_PROTOCOL_SMP) {
  984. /* SMP */
  985. dev = task->dev;
  986. pm8001_dev = dev->lldd_dev;
  987. pm8001_ha = pm8001_find_ha_by_dev(dev);
  988. rc = pm8001_find_tag(task, &tag);
  989. if (rc == 0) {
  990. printk(KERN_INFO "No such tag in %s\n", __func__);
  991. rc = TMF_RESP_FUNC_FAILED;
  992. return rc;
  993. }
  994. rc = pm8001_exec_internal_task_abort(pm8001_ha, pm8001_dev,
  995. pm8001_dev->sas_device, 0, tag);
  996. }
  997. out:
  998. if (rc != TMF_RESP_FUNC_COMPLETE)
  999. pm8001_printk("rc= %d\n", rc);
  1000. return rc;
  1001. }
  1002. int pm8001_abort_task_set(struct domain_device *dev, u8 *lun)
  1003. {
  1004. int rc = TMF_RESP_FUNC_FAILED;
  1005. struct pm8001_tmf_task tmf_task;
  1006. tmf_task.tmf = TMF_ABORT_TASK_SET;
  1007. rc = pm8001_issue_ssp_tmf(dev, lun, &tmf_task);
  1008. return rc;
  1009. }
  1010. int pm8001_clear_aca(struct domain_device *dev, u8 *lun)
  1011. {
  1012. int rc = TMF_RESP_FUNC_FAILED;
  1013. struct pm8001_tmf_task tmf_task;
  1014. tmf_task.tmf = TMF_CLEAR_ACA;
  1015. rc = pm8001_issue_ssp_tmf(dev, lun, &tmf_task);
  1016. return rc;
  1017. }
  1018. int pm8001_clear_task_set(struct domain_device *dev, u8 *lun)
  1019. {
  1020. int rc = TMF_RESP_FUNC_FAILED;
  1021. struct pm8001_tmf_task tmf_task;
  1022. struct pm8001_device *pm8001_dev = dev->lldd_dev;
  1023. struct pm8001_hba_info *pm8001_ha = pm8001_find_ha_by_dev(dev);
  1024. PM8001_EH_DBG(pm8001_ha,
  1025. pm8001_printk("I_T_L_Q clear task set[%x]\n",
  1026. pm8001_dev->device_id));
  1027. tmf_task.tmf = TMF_CLEAR_TASK_SET;
  1028. rc = pm8001_issue_ssp_tmf(dev, lun, &tmf_task);
  1029. return rc;
  1030. }