Commit bbfe82cd authored by John Garry's avatar John Garry Committed by Martin K. Petersen
Browse files

scsi: libsas: Add struct sas_tmf_task

Some of the LLDDs which use libsas have their own definition of a struct
to hold TMF info, so add a common struct for libsas.

Also add an interim force phy id field for hisi_sas driver, which will be
removed once the STP "TMF" code is factored out.

Even though some LLDDs (pm8001) use a u32 for the tag, u16 will be adequate,
as that named driver only uses tags in range [0, 1024).

Link: https://lore.kernel.org/r/1645112566-115804-8-git-send-email-john.garry@huawei.com


Tested-by: default avatarYihang Li <liyihang6@hisilicon.com>
Tested-by: default avatarDamien Le Moal <damien.lemoal@opensource.wdc.com>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarJohn Garry <john.garry@huawei.com>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent 4aef43b2
Loading
Loading
Loading
Loading
+1 −8
Original line number Diff line number Diff line
@@ -234,13 +234,6 @@ struct hisi_sas_device {
	spinlock_t lock; /* For protecting slots */
};

struct hisi_sas_tmf_task {
	int force_phy;
	int phy_id;
	u8 tmf;
	u16 tag_of_task_to_be_managed;
};

struct hisi_sas_slot {
	struct list_head entry;
	struct list_head delivery;
@@ -259,7 +252,7 @@ struct hisi_sas_slot {
	dma_addr_t cmd_hdr_dma;
	struct timer_list internal_abort_timer;
	bool is_internal;
	struct hisi_sas_tmf_task *tmf;
	struct sas_tmf_task *tmf;
	/* Do not reorder/change members after here */
	void	*buf;
	dma_addr_t buf_dma;
+11 −11
Original line number Diff line number Diff line
@@ -11,7 +11,7 @@
	((!dev) || (dev->dev_type == SAS_PHY_UNUSED))

static int hisi_sas_debug_issue_ssp_tmf(struct domain_device *device,
				u8 *lun, struct hisi_sas_tmf_task *tmf);
				u8 *lun, struct sas_tmf_task *tmf);
static int
hisi_sas_internal_task_abort(struct hisi_hba *hisi_hba,
			     struct domain_device *device,
@@ -464,7 +464,7 @@ void hisi_sas_task_deliver(struct hisi_hba *hisi_hba,
}

static int hisi_sas_task_exec(struct sas_task *task, gfp_t gfp_flags,
			      struct hisi_sas_tmf_task *tmf)
			      struct sas_tmf_task *tmf)
{
	int n_elem = 0, n_elem_dif = 0, n_elem_req = 0;
	struct domain_device *device = task->dev;
@@ -672,7 +672,7 @@ static int hisi_sas_init_device(struct domain_device *device)
{
	int rc = TMF_RESP_FUNC_COMPLETE;
	struct scsi_lun lun;
	struct hisi_sas_tmf_task tmf_task;
	struct sas_tmf_task tmf_task;
	int retry = HISI_SAS_DISK_RECOVER_CNT;
	struct hisi_hba *hisi_hba = dev_to_hisi_hba(device);
	struct device *dev = hisi_hba->dev;
@@ -1236,7 +1236,7 @@ static void hisi_sas_tmf_timedout(struct timer_list *t)
#define INTERNAL_ABORT_TIMEOUT		(6 * HZ)
static int hisi_sas_exec_internal_tmf_task(struct domain_device *device,
					   void *parameter, u32 para_len,
					   struct hisi_sas_tmf_task *tmf)
					   struct sas_tmf_task *tmf)
{
	struct hisi_sas_device *sas_dev = device->lldd_dev;
	struct hisi_hba *hisi_hba = sas_dev->hisi_hba;
@@ -1371,7 +1371,7 @@ static int hisi_sas_softreset_ata_disk(struct domain_device *device)
	struct hisi_hba *hisi_hba = dev_to_hisi_hba(device);
	struct device *dev = hisi_hba->dev;
	int s = sizeof(struct host_to_dev_fis);
	struct hisi_sas_tmf_task tmf = {};
	struct sas_tmf_task tmf = {};

	ata_for_each_link(link, ap, EDGE) {
		int pmp = sata_srst_pmp(link);
@@ -1405,7 +1405,7 @@ static int hisi_sas_softreset_ata_disk(struct domain_device *device)
}

static int hisi_sas_debug_issue_ssp_tmf(struct domain_device *device,
				u8 *lun, struct hisi_sas_tmf_task *tmf)
				u8 *lun, struct sas_tmf_task *tmf)
{
	struct sas_ssp_task ssp_task;

@@ -1512,7 +1512,7 @@ static void hisi_sas_send_ata_reset_each_phy(struct hisi_hba *hisi_hba,
					     struct asd_sas_port *sas_port,
					     struct domain_device *device)
{
	struct hisi_sas_tmf_task tmf_task = { .force_phy = 1 };
	struct sas_tmf_task tmf_task = { .force_phy = 1 };
	struct ata_port *ap = device->sata_dev.ap;
	struct device *dev = hisi_hba->dev;
	int s = sizeof(struct host_to_dev_fis);
@@ -1664,7 +1664,7 @@ static int hisi_sas_controller_reset(struct hisi_hba *hisi_hba)
static int hisi_sas_abort_task(struct sas_task *task)
{
	struct scsi_lun lun;
	struct hisi_sas_tmf_task tmf_task;
	struct sas_tmf_task tmf_task;
	struct domain_device *device = task->dev;
	struct hisi_sas_device *sas_dev = device->lldd_dev;
	struct hisi_hba *hisi_hba;
@@ -1773,7 +1773,7 @@ static int hisi_sas_abort_task_set(struct domain_device *device, u8 *lun)
{
	struct hisi_hba *hisi_hba = dev_to_hisi_hba(device);
	struct device *dev = hisi_hba->dev;
	struct hisi_sas_tmf_task tmf_task;
	struct sas_tmf_task tmf_task;
	int rc;

	rc = hisi_sas_internal_task_abort(hisi_hba, device,
@@ -1924,7 +1924,7 @@ static int hisi_sas_lu_reset(struct domain_device *device, u8 *lun)
			hisi_sas_release_task(hisi_hba, device);
		sas_put_local_phy(phy);
	} else {
		struct hisi_sas_tmf_task tmf_task = { .tmf =  TMF_LU_RESET };
		struct sas_tmf_task tmf_task = { .tmf =  TMF_LU_RESET };

		rc = hisi_sas_debug_issue_ssp_tmf(device, lun, &tmf_task);
		if (rc == TMF_RESP_FUNC_COMPLETE)
@@ -1982,7 +1982,7 @@ static int hisi_sas_clear_nexus_ha(struct sas_ha_struct *sas_ha)
static int hisi_sas_query_task(struct sas_task *task)
{
	struct scsi_lun lun;
	struct hisi_sas_tmf_task tmf_task;
	struct sas_tmf_task tmf_task;
	int rc = TMF_RESP_FUNC_FAILED;

	if (task->lldd_task && task->task_proto & SAS_PROTOCOL_SSP) {
+1 −1
Original line number Diff line number Diff line
@@ -958,7 +958,7 @@ static void prep_ssp_v1_hw(struct hisi_hba *hisi_hba,
	struct hisi_sas_port *port = slot->port;
	struct sas_ssp_task *ssp_task = &task->ssp_task;
	struct scsi_cmnd *scsi_cmnd = ssp_task->cmd;
	struct hisi_sas_tmf_task *tmf = slot->tmf;
	struct sas_tmf_task *tmf = slot->tmf;
	int has_data = 0, priority = !!tmf;
	u8 *buf_cmd, fburst = 0;
	u32 dw1, dw2;
+2 −2
Original line number Diff line number Diff line
@@ -1742,7 +1742,7 @@ static void prep_ssp_v2_hw(struct hisi_hba *hisi_hba,
	struct hisi_sas_port *port = slot->port;
	struct sas_ssp_task *ssp_task = &task->ssp_task;
	struct scsi_cmnd *scsi_cmnd = ssp_task->cmd;
	struct hisi_sas_tmf_task *tmf = slot->tmf;
	struct sas_tmf_task *tmf = slot->tmf;
	int has_data = 0, priority = !!tmf;
	u8 *buf_cmd;
	u32 dw1 = 0, dw2 = 0;
@@ -2491,7 +2491,7 @@ static void prep_ata_v2_hw(struct hisi_hba *hisi_hba,
	struct hisi_sas_cmd_hdr *hdr = slot->cmd_hdr;
	struct asd_sas_port *sas_port = device->port;
	struct hisi_sas_port *port = to_hisi_sas_port(sas_port);
	struct hisi_sas_tmf_task *tmf = slot->tmf;
	struct sas_tmf_task *tmf = slot->tmf;
	u8 *buf_cmd;
	int has_data = 0, hdr_tag = 0;
	u32 dw0, dw1 = 0, dw2 = 0;
+1 −1
Original line number Diff line number Diff line
@@ -1219,7 +1219,7 @@ static void prep_ssp_v3_hw(struct hisi_hba *hisi_hba,
	struct hisi_sas_port *port = slot->port;
	struct sas_ssp_task *ssp_task = &task->ssp_task;
	struct scsi_cmnd *scsi_cmnd = ssp_task->cmd;
	struct hisi_sas_tmf_task *tmf = slot->tmf;
	struct sas_tmf_task *tmf = slot->tmf;
	int has_data = 0, priority = !!tmf;
	unsigned char prot_op;
	u8 *buf_cmd;
Loading