Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) // SPDX-License-Identifier: GPL-2.0-only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  * Aic94xx SAS/SATA Tasks
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  * Copyright (C) 2005 Adaptec, Inc.  All rights reserved.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  * Copyright (C) 2005 Luben Tuikov <luben_tuikov@adaptec.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) #include <linux/spinlock.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) #include "aic94xx.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) #include "aic94xx_sas.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) #include "aic94xx_hwi.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) static void asd_unbuild_ata_ascb(struct asd_ascb *a);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) static void asd_unbuild_smp_ascb(struct asd_ascb *a);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) static void asd_unbuild_ssp_ascb(struct asd_ascb *a);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) static void asd_can_dequeue(struct asd_ha_struct *asd_ha, int num)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) 	unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) 	spin_lock_irqsave(&asd_ha->seq.pend_q_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) 	asd_ha->seq.can_queue += num;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) 	spin_unlock_irqrestore(&asd_ha->seq.pend_q_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) /* DMA_... to our direction translation.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) static const u8 data_dir_flags[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 	[DMA_BIDIRECTIONAL]	= DATA_DIR_BYRECIPIENT,	/* UNSPECIFIED */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 	[DMA_TO_DEVICE]		= DATA_DIR_OUT,		/* OUTBOUND */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 	[DMA_FROM_DEVICE]	= DATA_DIR_IN,		/* INBOUND */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 	[DMA_NONE]		= DATA_DIR_NONE,	/* NO TRANSFER */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) static int asd_map_scatterlist(struct sas_task *task,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 			       struct sg_el *sg_arr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 			       gfp_t gfp_flags)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 	struct asd_ascb *ascb = task->lldd_task;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 	struct asd_ha_struct *asd_ha = ascb->ha;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 	struct scatterlist *sc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 	int num_sg, res;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 	if (task->data_dir == DMA_NONE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 	if (task->num_scatter == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 		void *p = task->scatter;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 		dma_addr_t dma = dma_map_single(&asd_ha->pcidev->dev, p,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 						task->total_xfer_len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 						task->data_dir);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 		sg_arr[0].bus_addr = cpu_to_le64((u64)dma);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 		sg_arr[0].size = cpu_to_le32(task->total_xfer_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 		sg_arr[0].flags |= ASD_SG_EL_LIST_EOL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 	/* STP tasks come from libata which has already mapped
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 	 * the SG list */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 	if (sas_protocol_ata(task->task_proto))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 		num_sg = task->num_scatter;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 		num_sg = dma_map_sg(&asd_ha->pcidev->dev, task->scatter,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 				    task->num_scatter, task->data_dir);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 	if (num_sg == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 		return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 	if (num_sg > 3) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 		int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 		ascb->sg_arr = asd_alloc_coherent(asd_ha,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 						  num_sg*sizeof(struct sg_el),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 						  gfp_flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 		if (!ascb->sg_arr) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 			res = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 			goto err_unmap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 		for_each_sg(task->scatter, sc, num_sg, i) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 			struct sg_el *sg =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 				&((struct sg_el *)ascb->sg_arr->vaddr)[i];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 			sg->bus_addr = cpu_to_le64((u64)sg_dma_address(sc));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 			sg->size = cpu_to_le32((u32)sg_dma_len(sc));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 			if (i == num_sg-1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 				sg->flags |= ASD_SG_EL_LIST_EOL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 		for_each_sg(task->scatter, sc, 2, i) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 			sg_arr[i].bus_addr =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 				cpu_to_le64((u64)sg_dma_address(sc));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 			sg_arr[i].size = cpu_to_le32((u32)sg_dma_len(sc));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 		sg_arr[1].next_sg_offs = 2 * sizeof(*sg_arr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 		sg_arr[1].flags |= ASD_SG_EL_LIST_EOS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 		memset(&sg_arr[2], 0, sizeof(*sg_arr));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 		sg_arr[2].bus_addr=cpu_to_le64((u64)ascb->sg_arr->dma_handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 		int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 		for_each_sg(task->scatter, sc, num_sg, i) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 			sg_arr[i].bus_addr =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 				cpu_to_le64((u64)sg_dma_address(sc));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 			sg_arr[i].size = cpu_to_le32((u32)sg_dma_len(sc));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 		sg_arr[i-1].flags |= ASD_SG_EL_LIST_EOL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) err_unmap:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 	if (sas_protocol_ata(task->task_proto))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 		dma_unmap_sg(&asd_ha->pcidev->dev, task->scatter,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 			     task->num_scatter, task->data_dir);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 	return res;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) static void asd_unmap_scatterlist(struct asd_ascb *ascb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 	struct asd_ha_struct *asd_ha = ascb->ha;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 	struct sas_task *task = ascb->uldd_task;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 	if (task->data_dir == DMA_NONE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 	if (task->num_scatter == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 		dma_addr_t dma = (dma_addr_t)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 		       le64_to_cpu(ascb->scb->ssp_task.sg_element[0].bus_addr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 		dma_unmap_single(&ascb->ha->pcidev->dev, dma,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 				 task->total_xfer_len, task->data_dir);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 	asd_free_coherent(asd_ha, ascb->sg_arr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 	if (task->task_proto != SAS_PROTOCOL_STP)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 		dma_unmap_sg(&asd_ha->pcidev->dev, task->scatter,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 			     task->num_scatter, task->data_dir);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) /* ---------- Task complete tasklet ---------- */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) static void asd_get_response_tasklet(struct asd_ascb *ascb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 				     struct done_list_struct *dl)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 	struct asd_ha_struct *asd_ha = ascb->ha;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 	struct sas_task *task = ascb->uldd_task;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 	struct task_status_struct *ts = &task->task_status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 	unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 	struct tc_resp_sb_struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 		__le16 index_escb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 		u8     len_lsb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 		u8     flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 	} __attribute__ ((packed)) *resp_sb = (void *) dl->status_block;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) /* 	int  size   = ((resp_sb->flags & 7) << 8) | resp_sb->len_lsb; */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 	int  edb_id = ((resp_sb->flags & 0x70) >> 4)-1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 	struct asd_ascb *escb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 	struct asd_dma_tok *edb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 	void *r;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 	spin_lock_irqsave(&asd_ha->seq.tc_index_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 	escb = asd_tc_index_find(&asd_ha->seq,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 				 (int)le16_to_cpu(resp_sb->index_escb));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 	spin_unlock_irqrestore(&asd_ha->seq.tc_index_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 	if (!escb) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 		ASD_DPRINTK("Uh-oh! No escb for this dl?!\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 	ts->buf_valid_size = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 	edb = asd_ha->seq.edb_arr[edb_id + escb->edb_index];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 	r = edb->vaddr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 	if (task->task_proto == SAS_PROTOCOL_SSP) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 		struct ssp_response_iu *iu =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 			r + 16 + sizeof(struct ssp_frame_hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 		ts->residual = le32_to_cpu(*(__le32 *)r);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 		sas_ssp_task_response(&asd_ha->pcidev->dev, task, iu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 	}  else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 		struct ata_task_resp *resp = (void *) &ts->buf[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 		ts->residual = le32_to_cpu(*(__le32 *)r);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 		if (SAS_STATUS_BUF_SIZE >= sizeof(*resp)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 			resp->frame_len = le16_to_cpu(*(__le16 *)(r+6));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 			memcpy(&resp->ending_fis[0], r+16, ATA_RESP_FIS_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 			ts->buf_valid_size = sizeof(*resp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 	asd_invalidate_edb(escb, edb_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) static void asd_task_tasklet_complete(struct asd_ascb *ascb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 				      struct done_list_struct *dl)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 	struct sas_task *task = ascb->uldd_task;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 	struct task_status_struct *ts = &task->task_status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 	unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 	u8 opcode = dl->opcode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 	asd_can_dequeue(ascb->ha, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) Again:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 	switch (opcode) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 	case TC_NO_ERROR:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 		ts->resp = SAS_TASK_COMPLETE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 		ts->stat = SAM_STAT_GOOD;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 	case TC_UNDERRUN:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 		ts->resp = SAS_TASK_COMPLETE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 		ts->stat = SAS_DATA_UNDERRUN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 		ts->residual = le32_to_cpu(*(__le32 *)dl->status_block);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 	case TC_OVERRUN:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 		ts->resp = SAS_TASK_COMPLETE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 		ts->stat = SAS_DATA_OVERRUN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 		ts->residual = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 	case TC_SSP_RESP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 	case TC_ATA_RESP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 		ts->resp = SAS_TASK_COMPLETE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 		ts->stat = SAS_PROTO_RESPONSE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 		asd_get_response_tasklet(ascb, dl);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 	case TF_OPEN_REJECT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 		ts->resp = SAS_TASK_UNDELIVERED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 		ts->stat = SAS_OPEN_REJECT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 		if (dl->status_block[1] & 2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 			ts->open_rej_reason = 1 + dl->status_block[2];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 		else if (dl->status_block[1] & 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 			ts->open_rej_reason = (dl->status_block[2] >> 4)+10;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 		else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 			ts->open_rej_reason = SAS_OREJ_UNKNOWN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 	case TF_OPEN_TO:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 		ts->resp = SAS_TASK_UNDELIVERED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 		ts->stat = SAS_OPEN_TO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 	case TF_PHY_DOWN:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 	case TU_PHY_DOWN:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) 		ts->resp = SAS_TASK_UNDELIVERED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 		ts->stat = SAS_PHY_DOWN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) 	case TI_PHY_DOWN:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) 		ts->resp = SAS_TASK_COMPLETE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) 		ts->stat = SAS_PHY_DOWN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) 	case TI_BREAK:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) 	case TI_PROTO_ERR:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) 	case TI_NAK:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) 	case TI_ACK_NAK_TO:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) 	case TF_SMP_XMIT_RCV_ERR:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) 	case TC_ATA_R_ERR_RECV:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) 		ts->resp = SAS_TASK_COMPLETE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) 		ts->stat = SAS_INTERRUPTED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) 	case TF_BREAK:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) 	case TU_BREAK:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) 	case TU_ACK_NAK_TO:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) 	case TF_SMPRSP_TO:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) 		ts->resp = SAS_TASK_UNDELIVERED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) 		ts->stat = SAS_DEV_NO_RESPONSE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) 	case TF_NAK_RECV:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) 		ts->resp = SAS_TASK_COMPLETE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) 		ts->stat = SAS_NAK_R_ERR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) 	case TA_I_T_NEXUS_LOSS:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) 		opcode = dl->status_block[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) 		goto Again;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) 	case TF_INV_CONN_HANDLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) 		ts->resp = SAS_TASK_UNDELIVERED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) 		ts->stat = SAS_DEVICE_UNKNOWN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) 	case TF_REQUESTED_N_PENDING:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) 		ts->resp = SAS_TASK_UNDELIVERED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) 		ts->stat = SAS_PENDING;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) 	case TC_TASK_CLEARED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) 	case TA_ON_REQ:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) 		ts->resp = SAS_TASK_COMPLETE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) 		ts->stat = SAS_ABORTED_TASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) 	case TF_NO_SMP_CONN:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) 	case TF_TMF_NO_CTX:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) 	case TF_TMF_NO_TAG:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) 	case TF_TMF_TAG_FREE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) 	case TF_TMF_TASK_DONE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) 	case TF_TMF_NO_CONN_HANDLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) 	case TF_IRTT_TO:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) 	case TF_IU_SHORT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) 	case TF_DATA_OFFS_ERR:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) 		ts->resp = SAS_TASK_UNDELIVERED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) 		ts->stat = SAS_DEV_NO_RESPONSE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) 	case TC_LINK_ADM_RESP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) 	case TC_CONTROL_PHY:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) 	case TC_RESUME:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) 	case TC_PARTIAL_SG_LIST:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) 		ASD_DPRINTK("%s: dl opcode: 0x%x?\n", __func__, opcode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) 	switch (task->task_proto) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) 	case SAS_PROTOCOL_SATA:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) 	case SAS_PROTOCOL_STP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) 		asd_unbuild_ata_ascb(ascb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) 	case SAS_PROTOCOL_SMP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) 		asd_unbuild_smp_ascb(ascb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) 	case SAS_PROTOCOL_SSP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) 		asd_unbuild_ssp_ascb(ascb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) 	spin_lock_irqsave(&task->task_state_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) 	task->task_state_flags &= ~SAS_TASK_STATE_PENDING;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) 	task->task_state_flags &= ~SAS_TASK_AT_INITIATOR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) 	task->task_state_flags |= SAS_TASK_STATE_DONE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) 	if (unlikely((task->task_state_flags & SAS_TASK_STATE_ABORTED))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) 		struct completion *completion = ascb->completion;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) 		spin_unlock_irqrestore(&task->task_state_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) 		ASD_DPRINTK("task 0x%p done with opcode 0x%x resp 0x%x "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) 			    "stat 0x%x but aborted by upper layer!\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) 			    task, opcode, ts->resp, ts->stat);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) 		if (completion)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) 			complete(completion);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) 		spin_unlock_irqrestore(&task->task_state_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) 		task->lldd_task = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) 		asd_ascb_free(ascb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) 		mb();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) 		task->task_done(task);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) /* ---------- ATA ---------- */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) static int asd_build_ata_ascb(struct asd_ascb *ascb, struct sas_task *task,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) 			      gfp_t gfp_flags)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) 	struct domain_device *dev = task->dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) 	struct scb *scb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) 	u8     flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) 	int    res = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) 	scb = ascb->scb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) 	if (unlikely(task->ata_task.device_control_reg_update))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) 		scb->header.opcode = CONTROL_ATA_DEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) 	else if (dev->sata_dev.class == ATA_DEV_ATAPI)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) 		scb->header.opcode = INITIATE_ATAPI_TASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) 		scb->header.opcode = INITIATE_ATA_TASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) 	scb->ata_task.proto_conn_rate = (1 << 5); /* STP */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) 	if (dev->port->oob_mode == SAS_OOB_MODE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) 		scb->ata_task.proto_conn_rate |= dev->linkrate;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) 	scb->ata_task.total_xfer_len = cpu_to_le32(task->total_xfer_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) 	scb->ata_task.fis = task->ata_task.fis;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) 	if (likely(!task->ata_task.device_control_reg_update))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) 		scb->ata_task.fis.flags |= 0x80; /* C=1: update ATA cmd reg */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) 	scb->ata_task.fis.flags &= 0xF0; /* PM_PORT field shall be 0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) 	if (dev->sata_dev.class == ATA_DEV_ATAPI)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) 		memcpy(scb->ata_task.atapi_packet, task->ata_task.atapi_packet,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) 		       16);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) 	scb->ata_task.sister_scb = cpu_to_le16(0xFFFF);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) 	scb->ata_task.conn_handle = cpu_to_le16(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) 		(u16)(unsigned long)dev->lldd_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) 	if (likely(!task->ata_task.device_control_reg_update)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) 		flags = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) 		if (task->ata_task.dma_xfer)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) 			flags |= DATA_XFER_MODE_DMA;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) 		if (task->ata_task.use_ncq &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) 		    dev->sata_dev.class != ATA_DEV_ATAPI)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) 			flags |= ATA_Q_TYPE_NCQ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) 		flags |= data_dir_flags[task->data_dir];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) 		scb->ata_task.ata_flags = flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) 		scb->ata_task.retry_count = task->ata_task.retry_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) 		flags = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) 		if (task->ata_task.set_affil_pol)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) 			flags |= SET_AFFIL_POLICY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) 		if (task->ata_task.stp_affil_pol)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) 			flags |= STP_AFFIL_POLICY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) 		scb->ata_task.flags = flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) 	ascb->tasklet_complete = asd_task_tasklet_complete;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) 	if (likely(!task->ata_task.device_control_reg_update))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) 		res = asd_map_scatterlist(task, scb->ata_task.sg_element,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) 					  gfp_flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) 	return res;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) static void asd_unbuild_ata_ascb(struct asd_ascb *a)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) 	asd_unmap_scatterlist(a);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) /* ---------- SMP ---------- */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) static int asd_build_smp_ascb(struct asd_ascb *ascb, struct sas_task *task,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) 			      gfp_t gfp_flags)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) 	struct asd_ha_struct *asd_ha = ascb->ha;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) 	struct domain_device *dev = task->dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) 	struct scb *scb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) 	dma_map_sg(&asd_ha->pcidev->dev, &task->smp_task.smp_req, 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) 		   DMA_TO_DEVICE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) 	dma_map_sg(&asd_ha->pcidev->dev, &task->smp_task.smp_resp, 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) 		   DMA_FROM_DEVICE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) 	scb = ascb->scb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) 	scb->header.opcode = INITIATE_SMP_TASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) 	scb->smp_task.proto_conn_rate = dev->linkrate;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) 	scb->smp_task.smp_req.bus_addr =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) 		cpu_to_le64((u64)sg_dma_address(&task->smp_task.smp_req));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) 	scb->smp_task.smp_req.size =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) 		cpu_to_le32((u32)sg_dma_len(&task->smp_task.smp_req)-4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) 	scb->smp_task.smp_resp.bus_addr =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) 		cpu_to_le64((u64)sg_dma_address(&task->smp_task.smp_resp));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) 	scb->smp_task.smp_resp.size =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) 		cpu_to_le32((u32)sg_dma_len(&task->smp_task.smp_resp)-4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) 	scb->smp_task.sister_scb = cpu_to_le16(0xFFFF);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) 	scb->smp_task.conn_handle = cpu_to_le16((u16)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) 						(unsigned long)dev->lldd_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) 	ascb->tasklet_complete = asd_task_tasklet_complete;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) static void asd_unbuild_smp_ascb(struct asd_ascb *a)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) 	struct sas_task *task = a->uldd_task;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) 	BUG_ON(!task);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) 	dma_unmap_sg(&a->ha->pcidev->dev, &task->smp_task.smp_req, 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) 		     DMA_TO_DEVICE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) 	dma_unmap_sg(&a->ha->pcidev->dev, &task->smp_task.smp_resp, 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) 		     DMA_FROM_DEVICE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) /* ---------- SSP ---------- */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) static int asd_build_ssp_ascb(struct asd_ascb *ascb, struct sas_task *task,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) 			      gfp_t gfp_flags)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) 	struct domain_device *dev = task->dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) 	struct scb *scb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) 	int    res = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) 	scb = ascb->scb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) 	scb->header.opcode = INITIATE_SSP_TASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) 	scb->ssp_task.proto_conn_rate  = (1 << 4); /* SSP */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) 	scb->ssp_task.proto_conn_rate |= dev->linkrate;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) 	scb->ssp_task.total_xfer_len = cpu_to_le32(task->total_xfer_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) 	scb->ssp_task.ssp_frame.frame_type = SSP_DATA;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) 	memcpy(scb->ssp_task.ssp_frame.hashed_dest_addr, dev->hashed_sas_addr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) 	       HASHED_SAS_ADDR_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) 	memcpy(scb->ssp_task.ssp_frame.hashed_src_addr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) 	       dev->port->ha->hashed_sas_addr, HASHED_SAS_ADDR_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) 	scb->ssp_task.ssp_frame.tptt = cpu_to_be16(0xFFFF);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) 	memcpy(scb->ssp_task.ssp_cmd.lun, task->ssp_task.LUN, 8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) 	if (task->ssp_task.enable_first_burst)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) 		scb->ssp_task.ssp_cmd.efb_prio_attr |= EFB_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) 	scb->ssp_task.ssp_cmd.efb_prio_attr |= (task->ssp_task.task_prio << 3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) 	scb->ssp_task.ssp_cmd.efb_prio_attr |= (task->ssp_task.task_attr & 7);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) 	memcpy(scb->ssp_task.ssp_cmd.cdb, task->ssp_task.cmd->cmnd,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) 	       task->ssp_task.cmd->cmd_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) 	scb->ssp_task.sister_scb = cpu_to_le16(0xFFFF);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) 	scb->ssp_task.conn_handle = cpu_to_le16(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) 		(u16)(unsigned long)dev->lldd_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) 	scb->ssp_task.data_dir = data_dir_flags[task->data_dir];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) 	scb->ssp_task.retry_count = scb->ssp_task.retry_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) 	ascb->tasklet_complete = asd_task_tasklet_complete;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) 	res = asd_map_scatterlist(task, scb->ssp_task.sg_element, gfp_flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) 	return res;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506) static void asd_unbuild_ssp_ascb(struct asd_ascb *a)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) 	asd_unmap_scatterlist(a);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) /* ---------- Execute Task ---------- */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513) static int asd_can_queue(struct asd_ha_struct *asd_ha, int num)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515) 	int res = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516) 	unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518) 	spin_lock_irqsave(&asd_ha->seq.pend_q_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519) 	if ((asd_ha->seq.can_queue - num) < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520) 		res = -SAS_QUEUE_FULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522) 		asd_ha->seq.can_queue -= num;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523) 	spin_unlock_irqrestore(&asd_ha->seq.pend_q_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525) 	return res;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528) int asd_execute_task(struct sas_task *task, gfp_t gfp_flags)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530) 	int res = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531) 	LIST_HEAD(alist);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532) 	struct sas_task *t = task;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533) 	struct asd_ascb *ascb = NULL, *a;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534) 	struct asd_ha_struct *asd_ha = task->dev->port->ha->lldd_ha;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535) 	unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 536) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 537) 	res = asd_can_queue(asd_ha, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 538) 	if (res)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 539) 		return res;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 540) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 541) 	res = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 542) 	ascb = asd_ascb_alloc_list(asd_ha, &res, gfp_flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 543) 	if (res) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 544) 		res = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 545) 		goto out_err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 546) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 547) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 548) 	__list_add(&alist, ascb->list.prev, &ascb->list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 549) 	list_for_each_entry(a, &alist, list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 550) 		a->uldd_task = t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 551) 		t->lldd_task = a;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 552) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 553) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 554) 	list_for_each_entry(a, &alist, list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 555) 		t = a->uldd_task;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 556) 		a->uldd_timer = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 557) 		if (t->task_proto & SAS_PROTOCOL_STP)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 558) 			t->task_proto = SAS_PROTOCOL_STP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 559) 		switch (t->task_proto) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 560) 		case SAS_PROTOCOL_SATA:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 561) 		case SAS_PROTOCOL_STP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 562) 			res = asd_build_ata_ascb(a, t, gfp_flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 563) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 564) 		case SAS_PROTOCOL_SMP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 565) 			res = asd_build_smp_ascb(a, t, gfp_flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 566) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 567) 		case SAS_PROTOCOL_SSP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 568) 			res = asd_build_ssp_ascb(a, t, gfp_flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 569) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 570) 		default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 571) 			asd_printk("unknown sas_task proto: 0x%x\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 572) 				   t->task_proto);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 573) 			res = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 574) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 575) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 576) 		if (res)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 577) 			goto out_err_unmap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 578) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 579) 		spin_lock_irqsave(&t->task_state_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 580) 		t->task_state_flags |= SAS_TASK_AT_INITIATOR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 581) 		spin_unlock_irqrestore(&t->task_state_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 582) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 583) 	list_del_init(&alist);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 584) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 585) 	res = asd_post_ascb_list(asd_ha, ascb, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 586) 	if (unlikely(res)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 587) 		a = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 588) 		__list_add(&alist, ascb->list.prev, &ascb->list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 589) 		goto out_err_unmap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 590) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 591) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 592) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 593) out_err_unmap:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 594) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 595) 		struct asd_ascb *b = a;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 596) 		list_for_each_entry(a, &alist, list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 597) 			if (a == b)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 598) 				break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 599) 			t = a->uldd_task;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 600) 			spin_lock_irqsave(&t->task_state_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 601) 			t->task_state_flags &= ~SAS_TASK_AT_INITIATOR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 602) 			spin_unlock_irqrestore(&t->task_state_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 603) 			switch (t->task_proto) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 604) 			case SAS_PROTOCOL_SATA:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 605) 			case SAS_PROTOCOL_STP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 606) 				asd_unbuild_ata_ascb(a);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 607) 				break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 608) 			case SAS_PROTOCOL_SMP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 609) 				asd_unbuild_smp_ascb(a);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 610) 				break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 611) 			case SAS_PROTOCOL_SSP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 612) 				asd_unbuild_ssp_ascb(a);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 613) 			default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 614) 				break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 615) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 616) 			t->lldd_task = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 617) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 618) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 619) 	list_del_init(&alist);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 620) out_err:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 621) 	if (ascb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 622) 		asd_ascb_free_list(ascb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 623) 	asd_can_dequeue(asd_ha, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 624) 	return res;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 625) }