Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: Yihang Li <liyihang6@hisilicon.com>
Tested-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: John Garry <john.garry@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>

authored by

John Garry and committed by
Martin K. Petersen
bbfe82cd 4aef43b2

+49 -56
+1 -8
drivers/scsi/hisi_sas/hisi_sas.h
··· 234 234 spinlock_t lock; /* For protecting slots */ 235 235 }; 236 236 237 - struct hisi_sas_tmf_task { 238 - int force_phy; 239 - int phy_id; 240 - u8 tmf; 241 - u16 tag_of_task_to_be_managed; 242 - }; 243 - 244 237 struct hisi_sas_slot { 245 238 struct list_head entry; 246 239 struct list_head delivery; ··· 252 259 dma_addr_t cmd_hdr_dma; 253 260 struct timer_list internal_abort_timer; 254 261 bool is_internal; 255 - struct hisi_sas_tmf_task *tmf; 262 + struct sas_tmf_task *tmf; 256 263 /* Do not reorder/change members after here */ 257 264 void *buf; 258 265 dma_addr_t buf_dma;
+11 -11
drivers/scsi/hisi_sas/hisi_sas_main.c
··· 11 11 ((!dev) || (dev->dev_type == SAS_PHY_UNUSED)) 12 12 13 13 static int hisi_sas_debug_issue_ssp_tmf(struct domain_device *device, 14 - u8 *lun, struct hisi_sas_tmf_task *tmf); 14 + u8 *lun, struct sas_tmf_task *tmf); 15 15 static int 16 16 hisi_sas_internal_task_abort(struct hisi_hba *hisi_hba, 17 17 struct domain_device *device, ··· 464 464 } 465 465 466 466 static int hisi_sas_task_exec(struct sas_task *task, gfp_t gfp_flags, 467 - struct hisi_sas_tmf_task *tmf) 467 + struct sas_tmf_task *tmf) 468 468 { 469 469 int n_elem = 0, n_elem_dif = 0, n_elem_req = 0; 470 470 struct domain_device *device = task->dev; ··· 672 672 { 673 673 int rc = TMF_RESP_FUNC_COMPLETE; 674 674 struct scsi_lun lun; 675 - struct hisi_sas_tmf_task tmf_task; 675 + struct sas_tmf_task tmf_task; 676 676 int retry = HISI_SAS_DISK_RECOVER_CNT; 677 677 struct hisi_hba *hisi_hba = dev_to_hisi_hba(device); 678 678 struct device *dev = hisi_hba->dev; ··· 1236 1236 #define INTERNAL_ABORT_TIMEOUT (6 * HZ) 1237 1237 static int hisi_sas_exec_internal_tmf_task(struct domain_device *device, 1238 1238 void *parameter, u32 para_len, 1239 - struct hisi_sas_tmf_task *tmf) 1239 + struct sas_tmf_task *tmf) 1240 1240 { 1241 1241 struct hisi_sas_device *sas_dev = device->lldd_dev; 1242 1242 struct hisi_hba *hisi_hba = sas_dev->hisi_hba; ··· 1371 1371 struct hisi_hba *hisi_hba = dev_to_hisi_hba(device); 1372 1372 struct device *dev = hisi_hba->dev; 1373 1373 int s = sizeof(struct host_to_dev_fis); 1374 - struct hisi_sas_tmf_task tmf = {}; 1374 + struct sas_tmf_task tmf = {}; 1375 1375 1376 1376 ata_for_each_link(link, ap, EDGE) { 1377 1377 int pmp = sata_srst_pmp(link); ··· 1405 1405 } 1406 1406 1407 1407 static int hisi_sas_debug_issue_ssp_tmf(struct domain_device *device, 1408 - u8 *lun, struct hisi_sas_tmf_task *tmf) 1408 + u8 *lun, struct sas_tmf_task *tmf) 1409 1409 { 1410 1410 struct sas_ssp_task ssp_task; 1411 1411 ··· 1512 1512 struct asd_sas_port *sas_port, 1513 1513 struct domain_device *device) 1514 1514 { 1515 - struct hisi_sas_tmf_task tmf_task = { .force_phy = 1 }; 1515 + struct sas_tmf_task tmf_task = { .force_phy = 1 }; 1516 1516 struct ata_port *ap = device->sata_dev.ap; 1517 1517 struct device *dev = hisi_hba->dev; 1518 1518 int s = sizeof(struct host_to_dev_fis); ··· 1664 1664 static int hisi_sas_abort_task(struct sas_task *task) 1665 1665 { 1666 1666 struct scsi_lun lun; 1667 - struct hisi_sas_tmf_task tmf_task; 1667 + struct sas_tmf_task tmf_task; 1668 1668 struct domain_device *device = task->dev; 1669 1669 struct hisi_sas_device *sas_dev = device->lldd_dev; 1670 1670 struct hisi_hba *hisi_hba; ··· 1773 1773 { 1774 1774 struct hisi_hba *hisi_hba = dev_to_hisi_hba(device); 1775 1775 struct device *dev = hisi_hba->dev; 1776 - struct hisi_sas_tmf_task tmf_task; 1776 + struct sas_tmf_task tmf_task; 1777 1777 int rc; 1778 1778 1779 1779 rc = hisi_sas_internal_task_abort(hisi_hba, device, ··· 1924 1924 hisi_sas_release_task(hisi_hba, device); 1925 1925 sas_put_local_phy(phy); 1926 1926 } else { 1927 - struct hisi_sas_tmf_task tmf_task = { .tmf = TMF_LU_RESET }; 1927 + struct sas_tmf_task tmf_task = { .tmf = TMF_LU_RESET }; 1928 1928 1929 1929 rc = hisi_sas_debug_issue_ssp_tmf(device, lun, &tmf_task); 1930 1930 if (rc == TMF_RESP_FUNC_COMPLETE) ··· 1982 1982 static int hisi_sas_query_task(struct sas_task *task) 1983 1983 { 1984 1984 struct scsi_lun lun; 1985 - struct hisi_sas_tmf_task tmf_task; 1985 + struct sas_tmf_task tmf_task; 1986 1986 int rc = TMF_RESP_FUNC_FAILED; 1987 1987 1988 1988 if (task->lldd_task && task->task_proto & SAS_PROTOCOL_SSP) {
+1 -1
drivers/scsi/hisi_sas/hisi_sas_v1_hw.c
··· 958 958 struct hisi_sas_port *port = slot->port; 959 959 struct sas_ssp_task *ssp_task = &task->ssp_task; 960 960 struct scsi_cmnd *scsi_cmnd = ssp_task->cmd; 961 - struct hisi_sas_tmf_task *tmf = slot->tmf; 961 + struct sas_tmf_task *tmf = slot->tmf; 962 962 int has_data = 0, priority = !!tmf; 963 963 u8 *buf_cmd, fburst = 0; 964 964 u32 dw1, dw2;
+2 -2
drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
··· 1742 1742 struct hisi_sas_port *port = slot->port; 1743 1743 struct sas_ssp_task *ssp_task = &task->ssp_task; 1744 1744 struct scsi_cmnd *scsi_cmnd = ssp_task->cmd; 1745 - struct hisi_sas_tmf_task *tmf = slot->tmf; 1745 + struct sas_tmf_task *tmf = slot->tmf; 1746 1746 int has_data = 0, priority = !!tmf; 1747 1747 u8 *buf_cmd; 1748 1748 u32 dw1 = 0, dw2 = 0; ··· 2491 2491 struct hisi_sas_cmd_hdr *hdr = slot->cmd_hdr; 2492 2492 struct asd_sas_port *sas_port = device->port; 2493 2493 struct hisi_sas_port *port = to_hisi_sas_port(sas_port); 2494 - struct hisi_sas_tmf_task *tmf = slot->tmf; 2494 + struct sas_tmf_task *tmf = slot->tmf; 2495 2495 u8 *buf_cmd; 2496 2496 int has_data = 0, hdr_tag = 0; 2497 2497 u32 dw0, dw1 = 0, dw2 = 0;
+1 -1
drivers/scsi/hisi_sas/hisi_sas_v3_hw.c
··· 1219 1219 struct hisi_sas_port *port = slot->port; 1220 1220 struct sas_ssp_task *ssp_task = &task->ssp_task; 1221 1221 struct scsi_cmnd *scsi_cmnd = ssp_task->cmd; 1222 - struct hisi_sas_tmf_task *tmf = slot->tmf; 1222 + struct sas_tmf_task *tmf = slot->tmf; 1223 1223 int has_data = 0, priority = !!tmf; 1224 1224 unsigned char prot_op; 1225 1225 u8 *buf_cmd;
-5
drivers/scsi/mvsas/mv_defs.h
··· 486 486 SENSE_DATA = 2, 487 487 }; 488 488 489 - /* define task management IU */ 490 - struct mvs_tmf_task{ 491 - u8 tmf; 492 - u16 tag_of_task_to_be_managed; 493 - }; 494 489 #endif
+10 -10
drivers/scsi/mvsas/mv_sas.c
··· 556 556 557 557 static int mvs_task_prep_ssp(struct mvs_info *mvi, 558 558 struct mvs_task_exec_info *tei, int is_tmf, 559 - struct mvs_tmf_task *tmf) 559 + struct sas_tmf_task *tmf) 560 560 { 561 561 struct sas_task *task = tei->task; 562 562 struct mvs_cmd_hdr *hdr = tei->hdr; ··· 696 696 697 697 #define DEV_IS_GONE(mvi_dev) ((!mvi_dev || (mvi_dev->dev_type == SAS_PHY_UNUSED))) 698 698 static int mvs_task_prep(struct sas_task *task, struct mvs_info *mvi, int is_tmf, 699 - struct mvs_tmf_task *tmf, int *pass) 699 + struct sas_tmf_task *tmf, int *pass) 700 700 { 701 701 struct domain_device *dev = task->dev; 702 702 struct mvs_device *mvi_dev = dev->lldd_dev; ··· 839 839 840 840 static int mvs_task_exec(struct sas_task *task, gfp_t gfp_flags, 841 841 struct completion *completion, int is_tmf, 842 - struct mvs_tmf_task *tmf) 842 + struct sas_tmf_task *tmf) 843 843 { 844 844 struct mvs_info *mvi = NULL; 845 845 u32 rc = 0; ··· 1277 1277 1278 1278 #define MVS_TASK_TIMEOUT 20 1279 1279 static int mvs_exec_internal_tmf_task(struct domain_device *dev, 1280 - void *parameter, u32 para_len, struct mvs_tmf_task *tmf) 1280 + void *parameter, u32 para_len, struct sas_tmf_task *tmf) 1281 1281 { 1282 1282 int res, retry; 1283 1283 struct sas_task *task = NULL; ··· 1352 1352 } 1353 1353 1354 1354 static int mvs_debug_issue_ssp_tmf(struct domain_device *dev, 1355 - u8 *lun, struct mvs_tmf_task *tmf) 1355 + u8 *lun, struct sas_tmf_task *tmf) 1356 1356 { 1357 1357 struct sas_ssp_task ssp_task; 1358 1358 if (!(dev->tproto & SAS_PROTOCOL_SSP)) ··· 1384 1384 { 1385 1385 unsigned long flags; 1386 1386 int rc = TMF_RESP_FUNC_FAILED; 1387 - struct mvs_tmf_task tmf_task; 1387 + struct sas_tmf_task tmf_task; 1388 1388 struct mvs_device * mvi_dev = dev->lldd_dev; 1389 1389 struct mvs_info *mvi = mvi_dev->mvi_info; 1390 1390 ··· 1428 1428 { 1429 1429 u32 tag; 1430 1430 struct scsi_lun lun; 1431 - struct mvs_tmf_task tmf_task; 1431 + struct sas_tmf_task tmf_task; 1432 1432 int rc = TMF_RESP_FUNC_FAILED; 1433 1433 1434 1434 if (task->lldd_task && task->task_proto & SAS_PROTOCOL_SSP) { ··· 1465 1465 int mvs_abort_task(struct sas_task *task) 1466 1466 { 1467 1467 struct scsi_lun lun; 1468 - struct mvs_tmf_task tmf_task; 1468 + struct sas_tmf_task tmf_task; 1469 1469 struct domain_device *dev = task->dev; 1470 1470 struct mvs_device *mvi_dev = (struct mvs_device *)dev->lldd_dev; 1471 1471 struct mvs_info *mvi; ··· 1542 1542 int mvs_abort_task_set(struct domain_device *dev, u8 *lun) 1543 1543 { 1544 1544 int rc; 1545 - struct mvs_tmf_task tmf_task; 1545 + struct sas_tmf_task tmf_task; 1546 1546 1547 1547 tmf_task.tmf = TMF_ABORT_TASK_SET; 1548 1548 rc = mvs_debug_issue_ssp_tmf(dev, lun, &tmf_task); ··· 1553 1553 int mvs_clear_task_set(struct domain_device *dev, u8 *lun) 1554 1554 { 1555 1555 int rc = TMF_RESP_FUNC_FAILED; 1556 - struct mvs_tmf_task tmf_task; 1556 + struct sas_tmf_task tmf_task; 1557 1557 1558 1558 tmf_task.tmf = TMF_CLEAR_TASK_SET; 1559 1559 rc = mvs_debug_issue_ssp_tmf(dev, lun, &tmf_task);
+2 -2
drivers/scsi/pm8001/pm8001_hwi.c
··· 4602 4602 * @tmf: task management function. 4603 4603 */ 4604 4604 int pm8001_chip_ssp_tm_req(struct pm8001_hba_info *pm8001_ha, 4605 - struct pm8001_ccb_info *ccb, struct pm8001_tmf_task *tmf) 4605 + struct pm8001_ccb_info *ccb, struct sas_tmf_task *tmf) 4606 4606 { 4607 4607 struct sas_task *task = ccb->task; 4608 4608 struct domain_device *dev = task->dev; ··· 4614 4614 4615 4615 memset(&sspTMCmd, 0, sizeof(sspTMCmd)); 4616 4616 sspTMCmd.device_id = cpu_to_le32(pm8001_dev->device_id); 4617 - sspTMCmd.relate_tag = cpu_to_le32(tmf->tag_of_task_to_be_managed); 4617 + sspTMCmd.relate_tag = cpu_to_le32((u32)tmf->tag_of_task_to_be_managed); 4618 4618 sspTMCmd.tmf = cpu_to_le32(tmf->tmf); 4619 4619 memcpy(sspTMCmd.lun, task->ssp_task.LUN, 8); 4620 4620 sspTMCmd.tag = cpu_to_le32(ccb->ccb_tag);
+9 -9
drivers/scsi/pm8001/pm8001_sas.c
··· 336 336 * @tmf: the task management IU 337 337 */ 338 338 static int pm8001_task_prep_ssp_tm(struct pm8001_hba_info *pm8001_ha, 339 - struct pm8001_ccb_info *ccb, struct pm8001_tmf_task *tmf) 339 + struct pm8001_ccb_info *ccb, struct sas_tmf_task *tmf) 340 340 { 341 341 return PM8001_CHIP_DISP->ssp_tm_req(pm8001_ha, ccb, tmf); 342 342 } ··· 379 379 * @tmf: the task management IU 380 380 */ 381 381 static int pm8001_task_exec(struct sas_task *task, 382 - gfp_t gfp_flags, int is_tmf, struct pm8001_tmf_task *tmf) 382 + gfp_t gfp_flags, int is_tmf, struct sas_tmf_task *tmf) 383 383 { 384 384 struct domain_device *dev = task->dev; 385 385 struct pm8001_hba_info *pm8001_ha; ··· 728 728 * this function, note it is also with the task execute interface. 729 729 */ 730 730 static int pm8001_exec_internal_tmf_task(struct domain_device *dev, 731 - void *parameter, u32 para_len, struct pm8001_tmf_task *tmf) 731 + void *parameter, u32 para_len, struct sas_tmf_task *tmf) 732 732 { 733 733 int res, retry; 734 734 struct sas_task *task = NULL; ··· 919 919 } 920 920 921 921 static int pm8001_issue_ssp_tmf(struct domain_device *dev, 922 - u8 *lun, struct pm8001_tmf_task *tmf) 922 + u8 *lun, struct sas_tmf_task *tmf) 923 923 { 924 924 struct sas_ssp_task ssp_task; 925 925 if (!(dev->tproto & SAS_PROTOCOL_SSP)) ··· 1120 1120 int pm8001_lu_reset(struct domain_device *dev, u8 *lun) 1121 1121 { 1122 1122 int rc = TMF_RESP_FUNC_FAILED; 1123 - struct pm8001_tmf_task tmf_task; 1123 + struct sas_tmf_task tmf_task; 1124 1124 struct pm8001_device *pm8001_dev = dev->lldd_dev; 1125 1125 struct pm8001_hba_info *pm8001_ha = pm8001_find_ha_by_dev(dev); 1126 1126 DECLARE_COMPLETION_ONSTACK(completion_setstate); ··· 1149 1149 { 1150 1150 u32 tag = 0xdeadbeef; 1151 1151 struct scsi_lun lun; 1152 - struct pm8001_tmf_task tmf_task; 1152 + struct sas_tmf_task tmf_task; 1153 1153 int rc = TMF_RESP_FUNC_FAILED; 1154 1154 if (unlikely(!task || !task->lldd_task || !task->dev)) 1155 1155 return rc; ··· 1198 1198 struct pm8001_hba_info *pm8001_ha; 1199 1199 struct scsi_lun lun; 1200 1200 struct pm8001_device *pm8001_dev; 1201 - struct pm8001_tmf_task tmf_task; 1201 + struct sas_tmf_task tmf_task; 1202 1202 int rc = TMF_RESP_FUNC_FAILED, ret; 1203 1203 u32 phy_id, port_id; 1204 1204 struct sas_task_slow slow_task; ··· 1352 1352 1353 1353 int pm8001_abort_task_set(struct domain_device *dev, u8 *lun) 1354 1354 { 1355 - struct pm8001_tmf_task tmf_task; 1355 + struct sas_tmf_task tmf_task; 1356 1356 1357 1357 tmf_task.tmf = TMF_ABORT_TASK_SET; 1358 1358 return pm8001_issue_ssp_tmf(dev, lun, &tmf_task); ··· 1360 1360 1361 1361 int pm8001_clear_task_set(struct domain_device *dev, u8 *lun) 1362 1362 { 1363 - struct pm8001_tmf_task tmf_task; 1363 + struct sas_tmf_task tmf_task; 1364 1364 struct pm8001_device *pm8001_dev = dev->lldd_dev; 1365 1365 struct pm8001_hba_info *pm8001_ha = pm8001_find_ha_by_dev(dev); 1366 1366
+3 -7
drivers/scsi/pm8001/pm8001_sas.h
··· 99 99 struct pm8001_hba_info; 100 100 struct pm8001_ccb_info; 101 101 struct pm8001_device; 102 - /* define task management IU */ 103 - struct pm8001_tmf_task { 104 - u8 tmf; 105 - u32 tag_of_task_to_be_managed; 106 - }; 102 + 107 103 struct pm8001_ioctl_payload { 108 104 u32 signature; 109 105 u16 major_function; ··· 199 203 struct pm8001_device *pm8001_dev, u8 flag, u32 task_tag, 200 204 u32 cmd_tag); 201 205 int (*ssp_tm_req)(struct pm8001_hba_info *pm8001_ha, 202 - struct pm8001_ccb_info *ccb, struct pm8001_tmf_task *tmf); 206 + struct pm8001_ccb_info *ccb, struct sas_tmf_task *tmf); 203 207 int (*get_nvmd_req)(struct pm8001_hba_info *pm8001_ha, void *payload); 204 208 int (*set_nvmd_req)(struct pm8001_hba_info *pm8001_ha, void *payload); 205 209 int (*fw_flash_update_req)(struct pm8001_hba_info *pm8001_ha, ··· 683 687 int pm8001_chip_get_nvmd_req(struct pm8001_hba_info *pm8001_ha, void *payload); 684 688 int pm8001_chip_ssp_tm_req(struct pm8001_hba_info *pm8001_ha, 685 689 struct pm8001_ccb_info *ccb, 686 - struct pm8001_tmf_task *tmf); 690 + struct sas_tmf_task *tmf); 687 691 int pm8001_chip_abort_task(struct pm8001_hba_info *pm8001_ha, 688 692 struct pm8001_device *pm8001_dev, 689 693 u8 flag, u32 task_tag, u32 cmd_tag);
+9
include/scsi/libsas.h
··· 576 576 struct scsi_cmnd *cmd; 577 577 }; 578 578 579 + struct sas_tmf_task { 580 + u8 tmf; 581 + u16 tag_of_task_to_be_managed; 582 + 583 + /* Temp */ 584 + int force_phy; 585 + int phy_id; 586 + }; 587 + 579 588 struct sas_task { 580 589 struct domain_device *dev; 581 590