pm8001_sas.c 31 KB

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