History

Merge tag 'scsi-misc' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi

Pull SCSI updates from James Bottomley: "This series consists of the usual driver updates (ufs, pm80xx, lpfc, mpi3mr, mpt3sas, hisi_sas, libsas) and minor updates and bug fixes. The most impactful change is likely the switch from GFP_DMA to GFP_KERNEL in a bunch of drivers, but even that shouldn't affect too many people" * tag 'scsi-misc' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi: (121 commits) scsi: mpi3mr: Bump driver version to 8.0.0.61.0 scsi: mpi3mr: Fixes around reply request queues scsi: mpi3mr: Enhanced Task Management Support Reply handling scsi: mpi3mr: Use TM response codes from MPI3 headers scsi: mpi3mr: Add io_uring interface support in I/O-polled mode scsi: mpi3mr: Print cable mngnt and temp threshold events scsi: mpi3mr: Support Prepare for Reset event scsi: mpi3mr: Add Event acknowledgment logic scsi: mpi3mr: Gracefully handle online FW update operation scsi: mpi3mr: Detect async reset that occurred in firmware scsi: mpi3mr: Add IOC reinit function scsi: mpi3mr: Handle offline FW activation in graceful manner scsi: mpi3mr: Code refactor of IOC init - part2 scsi: mpi3mr: Code refactor of IOC init - part1 scsi: mpi3mr: Fault IOC when internal command gets timeout scsi: mpi3mr: Display IOC firmware package version scsi: mpi3mr: Handle unaligned PLL in unmap cmnds scsi: mpi3mr: Increase internal cmnds timeout to 60s scsi: mpi3mr: Do access status validation before adding devices scsi: mpi3mr: Add support for PCIe Managed Switch SES device ...

Linus Torvalds committed 4 years ago

Commit e1a7aa22 parents fb3b067 c77b1f892 files · +3714 −1628Browse files

Unified · Split

92 files
  1. MAINTAINERS +0 −2
  2. block/blk-pm.c +7 −15
  3. drivers/message/fusion/mptbase.c +2 −4
  4. drivers/scsi/a100u2w.c +0 −2
  5. drivers/scsi/atp870u.c +0 −1
  6. drivers/scsi/bfa/bfad_attr.c +1 −1
  7. drivers/scsi/ch.c +3 −3
  8. drivers/scsi/dc395x.c +1 −2
  9. drivers/scsi/elx/efct/efct_driver.c +1 −1
  10. drivers/scsi/elx/efct/efct_hw.c +5 −5
  11. drivers/scsi/elx/efct/efct_io.c +1 −1
  12. drivers/scsi/elx/libefc/efc_cmds.c +2 −2
  13. drivers/scsi/elx/libefc/efc_els.c +2 −2
  14. drivers/scsi/elx/libefc_sli/sli4.c +7 −7
  15. drivers/scsi/hisi_sas/hisi_sas.h +6 −1
  16. drivers/scsi/hisi_sas/hisi_sas_main.c +190 −206
  17. drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +29 −6
  18. drivers/scsi/hosts.c +3 −12
  19. drivers/scsi/hpsa.c +0 −2
  20. drivers/scsi/initio.c +2 −3
  21. drivers/scsi/libsas/sas_discover.c +0 −1
  22. drivers/scsi/libsas/sas_event.c +63 −14
  23. drivers/scsi/libsas/sas_expander.c +3 −0
  24. drivers/scsi/libsas/sas_init.c +47 −2
  25. drivers/scsi/libsas/sas_internal.h +2 −0
  26. drivers/scsi/libsas/sas_scsi_host.c +4 −3
  27. drivers/scsi/lpfc/lpfc.h +47 −50
  28. drivers/scsi/lpfc/lpfc_attr.c +40 −22
  29. drivers/scsi/lpfc/lpfc_debugfs.c +20 −7
  30. drivers/scsi/lpfc/lpfc_debugfs.h +1 −1
  31. drivers/scsi/lpfc/lpfc_els.c +15 −7
  32. drivers/scsi/lpfc/lpfc_hbadisc.c +7 −3
  33. drivers/scsi/lpfc/lpfc_hw.h +18 −11
  34. drivers/scsi/lpfc/lpfc_init.c +29 −12
  35. drivers/scsi/lpfc/lpfc_nportdisc.c +6 −0
  36. drivers/scsi/lpfc/lpfc_scsi.c +5 −3
  37. drivers/scsi/lpfc/lpfc_sli.c +15 −23
  38. drivers/scsi/lpfc/lpfc_version.h +1 −1
  39. drivers/scsi/lpfc/lpfc_vport.c +63 −20
  40. drivers/scsi/megaraid/megaraid_mbox.c +0 −1
  41. drivers/scsi/mpi3mr/mpi/mpi30_cnfg.h +498 −105
  42. drivers/scsi/mpi3mr/mpi/mpi30_image.h +58 −1
  43. drivers/scsi/mpi3mr/mpi/mpi30_init.h +12 −3
  44. drivers/scsi/mpi3mr/mpi/mpi30_ioc.h +99 −29
  45. drivers/scsi/mpi3mr/mpi/mpi30_pci.h +44 −0
  46. drivers/scsi/mpi3mr/mpi/mpi30_sas.h +14 −0
  47. drivers/scsi/mpi3mr/mpi/mpi30_transport.h +19 −12
  48. drivers/scsi/mpi3mr/mpi3mr.h +86 −40
  49. drivers/scsi/mpi3mr/mpi3mr_debug.h +109 −24
  50. drivers/scsi/mpi3mr/mpi3mr_fw.c +951 −500
  51. drivers/scsi/mpi3mr/mpi3mr_os.c +642 −129
  52. drivers/scsi/mvsas/mv_sas.c +5 −0
  53. drivers/scsi/myrb.c +1 −1
  54. drivers/scsi/myrs.c +4 −6
  55. drivers/scsi/pm8001/Makefile +5 −2
  56. drivers/scsi/pm8001/pm8001_ctl.c +12 −12
  57. drivers/scsi/pm8001/pm8001_hwi.c +12 −21
  58. drivers/scsi/pm8001/pm8001_init.c +2 −2
  59. drivers/scsi/pm8001/pm8001_sas.c +16 −0
  60. drivers/scsi/pm8001/pm80xx_hwi.c +16 −22
  61. drivers/scsi/pm8001/pm80xx_tracepoints.c +10 −0
  62. drivers/scsi/pm8001/pm80xx_tracepoints.h +113 −0
  63. drivers/scsi/pmcraid.c +2 −3
  64. drivers/scsi/qedi/qedi_main.c +2 −6
  65. drivers/scsi/qla2xxx/qla_attr.c +6 −0
  66. drivers/scsi/qla2xxx/qla_init.c +3 −7
  67. drivers/scsi/qla2xxx/qla_nvme.c +4 −1
  68. drivers/scsi/qla4xxx/ql4_os.c +2 −2
  69. drivers/scsi/scsi.c +2 −3
  70. drivers/scsi/scsi_debugfs.c +1 −0
  71. drivers/scsi/scsi_error.c +57 −55
  72. drivers/scsi/scsi_pm.c +1 −2
  73. drivers/scsi/scsi_priv.h +1 −2
  74. drivers/scsi/scsi_scan.c +2 −2
  75. drivers/scsi/scsi_sysfs.c +6 −1
  76. drivers/scsi/sd.c +0 −1
  77. drivers/scsi/sd_zbc.c +3 −3
  78. drivers/scsi/snic/snic_disc.c +1 −1
  79. drivers/scsi/sr.c +1 −1
  80. drivers/scsi/sr_vendor.c +2 −2
  81. drivers/scsi/ufs/Kconfig +8 −7
  82. drivers/scsi/ufs/tc-dwc-g210-pci.c +0 −1
  83. drivers/scsi/ufs/ufs-exynos.c +2 −2
  84. drivers/scsi/ufs/ufs-hisi.c +7 −1
  85. drivers/scsi/ufs/ufshcd-pci.c +0 −2
  86. drivers/scsi/ufs/ufshcd-pltfrm.c +0 −2
  87. drivers/scsi/ufs/ufshcd.c +206 −141
  88. drivers/scsi/ufs/ufshcd.h +16 −4
  89. drivers/scsi/ufs/ufshpb.c +0 −1
  90. include/linux/blk-pm.h +1 −1
  91. include/scsi/libsas.h +2 −0
  92. include/scsi/scsi_host.h +0 −6
MAINTAINERS+0−2
@@ -7081,9 +7081,7 @@ S: Maintained · 7080 unmodified lines
70817081 F: drivers/mmc/host/cqhci*
70827082
70837083 EMULEX 10Gbps iSCSI - OneConnect DRIVER
7084−M: Subbu Seetharaman <subbu.seetharaman@broadcom.com>
70857084 M: Ketan Mukadam <ketan.mukadam@broadcom.com>
7086−M: Jitendra Bhivare <jitendra.bhivare@broadcom.com>
70877085 L: linux-scsi@vger.kernel.org
70887086 S: Supported
70897087 W: http://www.broadcom.com
block/blk-pm.c+7−15
@@ -163,27 +163,19 @@ EXPORT_SYMBOL(blk_pre_runtime_resume); · 162 unmodified lines
163163 /**
164164 * blk_post_runtime_resume - Post runtime resume processing
165165 * @q: the queue of the device
166− * @err: return value of the device's runtime_resume function
167166 *
168167 * Description:
169− * Update the queue's runtime status according to the return value of the
170− * device's runtime_resume function. If the resume was successful, call
171− * blk_set_runtime_active() to do the real work of restarting the queue.
168+ * For historical reasons, this routine merely calls blk_set_runtime_active()
169+ * to do the real work of restarting the queue. It does this regardless of
170+ * whether the device's runtime-resume succeeded; even if it failed the
171+ * driver or error handler will need to communicate with the device.
172172 *
173173 * This function should be called near the end of the device's
174174 * runtime_resume callback.
175175 */
176−void blk_post_runtime_resume(struct request_queue *q, int err)
176+void blk_post_runtime_resume(struct request_queue *q)
177177 {
178− if (!q->dev)
179− return;
180− if (!err) {
181− blk_set_runtime_active(q);
182− } else {
183− spin_lock_irq(&q->queue_lock);
184− q->rpm_status = RPM_SUSPENDED;
185− spin_unlock_irq(&q->queue_lock);
186− }
178+ blk_set_runtime_active(q);
187179 }
188180 EXPORT_SYMBOL(blk_post_runtime_resume);
189181
@@ -201,7 +193,7 @@ EXPORT_SYMBOL(blk_post_runtime_resume); · 11 unmodified lines
201193 * runtime PM status and re-enable peeking requests from the queue. It
202194 * should be called before first request is added to the queue.
203195 *
204− * This function is also called by blk_post_runtime_resume() for successful
196+ * This function is also called by blk_post_runtime_resume() for
205197 * runtime resumes. It does everything necessary to restart the queue.
206198 */
207199 void blk_set_runtime_active(struct request_queue *q)
drivers/message/fusion/mptbase.c+2−4
@@ -1274,8 +1274,6 @@ mpt_send_handshake_request(u8 cb_idx, MPT_ADAPTER *ioc, int reqBytes, u32 *req, · 1273 unmodified lines
12741274 static int
12751275 mpt_host_page_access_control(MPT_ADAPTER *ioc, u8 access_control_value, int sleepFlag)
12761276 {
1277− int r = 0;
1278−
12791277 /* return if in use */
12801278 if (CHIPREG_READ32(&ioc->chip->Doorbell)
12811279 & MPI_DOORBELL_ACTIVE)
@@ -1289,9 +1287,9 @@ mpt_host_page_access_control(MPT_ADAPTER *ioc, u8 access_control_value, int slee · 7 unmodified lines
12891287 (access_control_value<<12)));
12901288
12911289 /* Wait for IOC to clear Doorbell Status bit */
1292− if ((r = WaitForDoorbellAck(ioc, 5, sleepFlag)) < 0) {
1290+ if (WaitForDoorbellAck(ioc, 5, sleepFlag) < 0)
12931291 return -2;
1294− }else
1292+ else
12951293 return 0;
12961294 }
12971295
drivers/scsi/a100u2w.c+0−2
@@ -904,13 +904,11 @@ static int inia100_build_scb(struct orc_host * host, struct orc_scb * scb, struc · 903 unmodified lines
904904 /**
905905 * inia100_queue_lck - queue command with host
906906 * @cmd: Command block
907− * @done: Completion function
908907 *
909908 * Called by the mid layer to queue a command. Process the command
910909 * block, build the host specific scb structures and if there is room
911910 * queue the command down to the controller
912911 */
913−
914912 static int inia100_queue_lck(struct scsi_cmnd *cmd)
915913 {
916914 struct orc_scb *scb;
drivers/scsi/atp870u.c+0−1
@@ -614,7 +614,6 @@ static irqreturn_t atp870u_intr_handle(int irq, void *dev_id) · 613 unmodified lines
614614 /**
615615 * atp870u_queuecommand_lck - Queue SCSI command
616616 * @req_p: request block
617− * @done: completion function
618617 *
619618 * Queue a command to the ATP queue. Called with the host lock held.
620619 */
drivers/scsi/bfa/bfad_attr.c+1−1
@@ -981,7 +981,7 @@ const struct attribute_group *bfad_im_host_groups[] = { · 980 unmodified lines
981981 NULL
982982 };
983983
984−struct attribute *bfad_im_vport_attrs[] = {
984+static struct attribute *bfad_im_vport_attrs[] = {
985985 &dev_attr_serial_number.attr,
986986 &dev_attr_model.attr,
987987 &dev_attr_model_description.attr,
drivers/scsi/ch.c+3−3
@@ -239,7 +239,7 @@ ch_read_element_status(scsi_changer *ch, u_int elem, char *data) · 238 unmodified lines
239239 u_char *buffer;
240240 int result;
241241
242− buffer = kmalloc(512, GFP_KERNEL | GFP_DMA);
242+ buffer = kmalloc(512, GFP_KERNEL);
243243 if(!buffer)
244244 return -ENOMEM;
245245
@@ -297,7 +297,7 @@ ch_readconfig(scsi_changer *ch) · 51 unmodified lines
297297 int result,id,lun,i;
298298 u_int elem;
299299
300− buffer = kzalloc(512, GFP_KERNEL | GFP_DMA);
300+ buffer = kzalloc(512, GFP_KERNEL);
301301 if (!buffer)
302302 return -ENOMEM;
303303
@@ -783,7 +783,7 @@ static long ch_ioctl(struct file *file, · 479 unmodified lines
783783 return -EINVAL;
784784 elem = ch->firsts[cge.cge_type] + cge.cge_unit;
785785
786− buffer = kmalloc(512, GFP_KERNEL | GFP_DMA);
786+ buffer = kmalloc(512, GFP_KERNEL);
787787 if (!buffer)
788788 return -ENOMEM;
789789 mutex_lock(&ch->lock);
drivers/scsi/dc395x.c+1−2
@@ -946,7 +946,6 @@ static void build_srb(struct scsi_cmnd *cmd, struct DeviceCtlBlk *dcb, · 945 unmodified lines
946946 * layer, invoke 'done' on completion
947947 *
948948 * @cmd: pointer to scsi command object
949− * @done: function pointer to be invoked on completion
950949 *
951950 * Returns 1 if the adapter (host) is busy, else returns 0. One
952951 * reason for an adapter to be busy is that the number
@@ -959,7 +958,7 @@ static void build_srb(struct scsi_cmnd *cmd, struct DeviceCtlBlk *dcb, · 6 unmodified lines
959958 * Locks: struct Scsi_Host::host_lock held on entry (with "irqsave")
960959 * and is expected to be held on return.
961960 *
962− **/
961+ */
963962 static int dc395x_queue_command_lck(struct scsi_cmnd *cmd)
964963 {
965964 void (*done)(struct scsi_cmnd *) = scsi_done;
drivers/scsi/elx/efct/efct_driver.c+1−1
@@ -261,7 +261,7 @@ efct_firmware_write(struct efct *efct, const u8 *buf, size_t buf_len, · 260 unmodified lines
261261
262262 dma.size = FW_WRITE_BUFSIZE;
263263 dma.virt = dma_alloc_coherent(&efct->pci->dev,
264− dma.size, &dma.phys, GFP_DMA);
264+ dma.size, &dma.phys, GFP_KERNEL);
265265 if (!dma.virt)
266266 return -ENOMEM;
267267
drivers/scsi/elx/efct/efct_hw.c+5−5
@@ -516,7 +516,7 @@ efct_hw_setup_io(struct efct_hw *hw) · 515 unmodified lines
516516 dma = &hw->xfer_rdy;
517517 dma->size = sizeof(struct fcp_txrdy) * hw->config.n_io;
518518 dma->virt = dma_alloc_coherent(&efct->pci->dev,
519− dma->size, &dma->phys, GFP_DMA);
519+ dma->size, &dma->phys, GFP_KERNEL);
520520 if (!dma->virt)
521521 return -ENOMEM;
522522 }
@@ -562,7 +562,7 @@ efct_hw_setup_io(struct efct_hw *hw) · 39 unmodified lines
562562 sizeof(struct sli4_sge);
563563 dma->virt = dma_alloc_coherent(&efct->pci->dev,
564564 dma->size, &dma->phys,
565− GFP_DMA);
565+ GFP_KERNEL);
566566 if (!dma->virt) {
567567 efc_log_err(hw->os, "dma_alloc fail %d\n", i);
568568 memset(&io->def_sgl, 0,
@@ -618,7 +618,7 @@ efct_hw_init_prereg_io(struct efct_hw *hw) · 49 unmodified lines
618618 memset(&req, 0, sizeof(struct efc_dma));
619619 req.size = 32 + sgls_per_request * 16;
620620 req.virt = dma_alloc_coherent(&efct->pci->dev, req.size, &req.phys,
621− GFP_DMA);
621+ GFP_KERNEL);
622622 if (!req.virt) {
623623 kfree(sgls);
624624 return -ENOMEM;
@@ -1063,7 +1063,7 @@ efct_hw_init(struct efct_hw *hw) · 438 unmodified lines
10631063 dma = &hw->loop_map;
10641064 dma->size = SLI4_MIN_LOOP_MAP_BYTES;
10651065 dma->virt = dma_alloc_coherent(&hw->os->pci->dev, dma->size, &dma->phys,
1066− GFP_DMA);
1066+ GFP_KERNEL);
10671067 if (!dma->virt)
10681068 return -EIO;
10691069
@@ -1192,7 +1192,7 @@ efct_hw_rx_buffer_alloc(struct efct_hw *hw, u32 rqindex, u32 count, · 122 unmodified lines
11921192 prq->dma.virt = dma_alloc_coherent(&efct->pci->dev,
11931193 prq->dma.size,
11941194 &prq->dma.phys,
1195− GFP_DMA);
1195+ GFP_KERNEL);
11961196 if (!prq->dma.virt) {
11971197 efc_log_err(hw->os, "DMA allocation failed\n");
11981198 kfree(rq_buf);
drivers/scsi/elx/efct/efct_io.c+1−1
@@ -48,7 +48,7 @@ efct_io_pool_create(struct efct *efct, u32 num_sgl) · 47 unmodified lines
4848 io->rspbuf.size = SCSI_RSP_BUF_LENGTH;
4949 io->rspbuf.virt = dma_alloc_coherent(&efct->pci->dev,
5050 io->rspbuf.size,
51− &io->rspbuf.phys, GFP_DMA);
51+ &io->rspbuf.phys, GFP_KERNEL);
5252 if (!io->rspbuf.virt) {
5353 efc_log_err(efct, "dma_alloc rspbuf failed\n");
5454 efct_io_pool_free(io_pool);
drivers/scsi/elx/libefc/efc_cmds.c+2−2
@@ -179,7 +179,7 @@ efc_nport_alloc_read_sparm64(struct efc *efc, struct efc_nport *nport) · 178 unmodified lines
179179 nport->dma.size = EFC_SPARAM_DMA_SZ;
180180 nport->dma.virt = dma_alloc_coherent(&efc->pci->dev,
181181 nport->dma.size, &nport->dma.phys,
182− GFP_DMA);
182+ GFP_KERNEL);
183183 if (!nport->dma.virt) {
184184 efc_log_err(efc, "Failed to allocate DMA memory\n");
185185 efc_nport_free_resources(nport, EFC_EVT_NPORT_ALLOC_FAIL, data);
@@ -466,7 +466,7 @@ efc_cmd_domain_alloc(struct efc *efc, struct efc_domain *domain, u32 fcf) · 280 unmodified lines
466466 domain->dma.size = EFC_SPARAM_DMA_SZ;
467467 domain->dma.virt = dma_alloc_coherent(&efc->pci->dev,
468468 domain->dma.size,
469− &domain->dma.phys, GFP_DMA);
469+ &domain->dma.phys, GFP_KERNEL);
470470 if (!domain->dma.virt) {
471471 efc_log_err(efc, "Failed to allocate DMA memory\n");
472472 return -EIO;
drivers/scsi/elx/libefc/efc_els.c+2−2
@@ -71,7 +71,7 @@ efc_els_io_alloc_size(struct efc_node *node, u32 reqlen, u32 rsplen) · 70 unmodified lines
7171 /* now allocate DMA for request and response */
7272 els->io.req.size = reqlen;
7373 els->io.req.virt = dma_alloc_coherent(&efc->pci->dev, els->io.req.size,
74− &els->io.req.phys, GFP_DMA);
74+ &els->io.req.phys, GFP_KERNEL);
7575 if (!els->io.req.virt) {
7676 mempool_free(els, efc->els_io_pool);
7777 spin_unlock_irqrestore(&node->els_ios_lock, flags);
@@ -80,7 +80,7 @@ efc_els_io_alloc_size(struct efc_node *node, u32 reqlen, u32 rsplen) · 2 unmodified lines
8080
8181 els->io.rsp.size = rsplen;
8282 els->io.rsp.virt = dma_alloc_coherent(&efc->pci->dev, els->io.rsp.size,
83− &els->io.rsp.phys, GFP_DMA);
83+ &els->io.rsp.phys, GFP_KERNEL);
8484 if (!els->io.rsp.virt) {
8585 dma_free_coherent(&efc->pci->dev, els->io.req.size,
8686 els->io.req.virt, els->io.req.phys);
drivers/scsi/elx/libefc_sli/sli4.c+7−7
@@ -445,7 +445,7 @@ sli_cmd_rq_create_v2(struct sli4 *sli4, u32 num_rqs, · 444 unmodified lines
445445
446446 dma->size = payload_size;
447447 dma->virt = dma_alloc_coherent(&sli4->pci->dev, dma->size,
448− &dma->phys, GFP_DMA);
448+ &dma->phys, GFP_KERNEL);
449449 if (!dma->virt)
450450 return -EIO;
451451
@@ -508,7 +508,7 @@ __sli_queue_init(struct sli4 *sli4, struct sli4_queue *q, u32 qtype, · 56 unmodified lines
508508
509509 q->dma.size = size * n_entries;
510510 q->dma.virt = dma_alloc_coherent(&sli4->pci->dev, q->dma.size,
511− &q->dma.phys, GFP_DMA);
511+ &q->dma.phys, GFP_KERNEL);
512512 if (!q->dma.virt) {
513513 memset(&q->dma, 0, sizeof(struct efc_dma));
514514 efc_log_err(sli4, "%s allocation failed\n", SLI4_QNAME[qtype]);
@@ -849,7 +849,7 @@ static int sli_cmd_cq_set_create(struct sli4 *sli4, · 334 unmodified lines
849849
850850 dma->size = payload_size;
851851 dma->virt = dma_alloc_coherent(&sli4->pci->dev, dma->size,
852− &dma->phys, GFP_DMA);
852+ &dma->phys, GFP_KERNEL);
853853 if (!dma->virt)
854854 return -EIO;
855855
@@ -4413,7 +4413,7 @@ sli_get_ctrl_attributes(struct sli4 *sli4) · 3557 unmodified lines
44134413 psize = sizeof(struct sli4_rsp_cmn_get_cntl_addl_attributes);
44144414 data.size = psize;
44154415 data.virt = dma_alloc_coherent(&sli4->pci->dev, data.size,
4416− &data.phys, GFP_DMA);
4416+ &data.phys, GFP_KERNEL);
44174417 if (!data.virt) {
44184418 memset(&data, 0, sizeof(struct efc_dma));
44194419 efc_log_err(sli4, "Failed to allocate memory for GET_CNTL_ADDL_ATTR\n");
@@ -4653,7 +4653,7 @@ sli_setup(struct sli4 *sli4, void *os, struct pci_dev *pdev, · 233 unmodified lines
46534653 */
46544654 sli4->bmbx.size = SLI4_BMBX_SIZE + sizeof(struct sli4_mcqe);
46554655 sli4->bmbx.virt = dma_alloc_coherent(&pdev->dev, sli4->bmbx.size,
4656− &sli4->bmbx.phys, GFP_DMA);
4656+ &sli4->bmbx.phys, GFP_KERNEL);
46574657 if (!sli4->bmbx.virt) {
46584658 memset(&sli4->bmbx, 0, sizeof(struct efc_dma));
46594659 efc_log_err(sli4, "bootstrap mailbox allocation failed\n");
@@ -4674,7 +4674,7 @@ sli_setup(struct sli4 *sli4, void *os, struct pci_dev *pdev, · 14 unmodified lines
46744674 sli4->vpd_data.virt = dma_alloc_coherent(&pdev->dev,
46754675 sli4->vpd_data.size,
46764676 &sli4->vpd_data.phys,
4677− GFP_DMA);
4677+ GFP_KERNEL);
46784678 if (!sli4->vpd_data.virt) {
46794679 memset(&sli4->vpd_data, 0, sizeof(struct efc_dma));
46804680 /* Note that failure isn't fatal in this specific case */
@@ -5070,7 +5070,7 @@ sli_cmd_post_hdr_templates(struct sli4 *sli4, void *buf, struct efc_dma *dma, · 389 unmodified lines
50705070 payload_dma->size = payload_size;
50715071 payload_dma->virt = dma_alloc_coherent(&sli4->pci->dev,
50725072 payload_dma->size,
5073− &payload_dma->phys, GFP_DMA);
5073+ &payload_dma->phys, GFP_KERNEL);
50745074 if (!payload_dma->virt) {
50755075 memset(payload_dma, 0, sizeof(struct efc_dma));
50765076 efc_log_err(sli4, "mbox payload memory allocation fail\n");
drivers/scsi/hisi_sas/hisi_sas.h+6−1
@@ -8,7 +8,6 @@ · 7 unmodified lines
88 #define _HISI_SAS_H_
99
1010 #include <linux/acpi.h>
11−#include <linux/async.h>
1211 #include <linux/blk-mq.h>
1312 #include <linux/blk-mq-pci.h>
1413 #include <linux/clk.h>
@@ -134,6 +133,11 @@ struct hisi_sas_rst { · 119 unmodified lines
134133 bool done;
135134 };
136135
136+struct hisi_sas_internal_abort {
137+ unsigned int flag;
138+ unsigned int tag;
139+};
140+
137141 #define HISI_SAS_RST_WORK_INIT(r, c) \
138142 { .hisi_hba = hisi_hba, \
139143 .completion = &c, \
@@ -154,6 +158,7 @@ enum hisi_sas_bit_err_type { · 14 unmodified lines
154158 enum hisi_sas_phy_event {
155159 HISI_PHYE_PHY_UP = 0U,
156160 HISI_PHYE_LINK_RESET,
161+ HISI_PHYE_PHY_UP_PM,
157162 HISI_PHYES_NUM,
158163 };
159164
drivers/scsi/hisi_sas/hisi_sas_main.c+190−206
@@ -158,7 +158,7 @@ static void hisi_sas_slot_index_clear(struct hisi_hba *hisi_hba, int slot_idx) · 157 unmodified lines
158158 {
159159 void *bitmap = hisi_hba->slot_index_tags;
160160
161− clear_bit(slot_idx, bitmap);
161+ __clear_bit(slot_idx, bitmap);
162162 }
163163
164164 static void hisi_sas_slot_index_free(struct hisi_hba *hisi_hba, int slot_idx)
@@ -175,7 +175,7 @@ static void hisi_sas_slot_index_set(struct hisi_hba *hisi_hba, int slot_idx) · 10 unmodified lines
175175 {
176176 void *bitmap = hisi_hba->slot_index_tags;
177177
178− set_bit(slot_idx, bitmap);
178+ __set_bit(slot_idx, bitmap);
179179 }
180180
181181 static int hisi_sas_slot_index_alloc(struct hisi_hba *hisi_hba,
@@ -206,14 +206,6 @@ static int hisi_sas_slot_index_alloc(struct hisi_hba *hisi_hba, · 24 unmodified lines
206206 return index;
207207 }
208208
209−static void hisi_sas_slot_index_init(struct hisi_hba *hisi_hba)
210−{
211− int i;
212−
213− for (i = 0; i < hisi_hba->slot_index_count; ++i)
214− hisi_sas_slot_index_clear(hisi_hba, i);
215−}
216−
217209 void hisi_sas_slot_task_free(struct hisi_hba *hisi_hba, struct sas_task *task,
218210 struct hisi_sas_slot *slot)
219211 {
@@ -273,11 +265,11 @@ static void hisi_sas_task_prep_ata(struct hisi_hba *hisi_hba, · 53 unmodified lines
273265 }
274266
275267 static void hisi_sas_task_prep_abort(struct hisi_hba *hisi_hba,
276− struct hisi_sas_slot *slot,
277− int device_id, int abort_flag, int tag_to_abort)
268+ struct hisi_sas_internal_abort *abort,
269+ struct hisi_sas_slot *slot, int device_id)
278270 {
279271 hisi_hba->hw->prep_abort(hisi_hba, slot,
280− device_id, abort_flag, tag_to_abort);
272+ device_id, abort->flag, abort->tag);
281273 }
282274
283275 static void hisi_sas_dma_unmap(struct hisi_hba *hisi_hba,
@@ -403,95 +395,20 @@ err_out_dif_dma_unmap: · 119 unmodified lines
403395 return rc;
404396 }
405397
406−static int hisi_sas_task_prep(struct sas_task *task,
407− struct hisi_sas_dq **dq_pointer,
408− bool is_tmf, struct hisi_sas_tmf_task *tmf,
409− int *pass)
398+static
399+void hisi_sas_task_deliver(struct hisi_hba *hisi_hba,
400+ struct hisi_sas_slot *slot,
401+ struct hisi_sas_dq *dq,
402+ struct hisi_sas_device *sas_dev,
403+ struct hisi_sas_internal_abort *abort,
404+ struct hisi_sas_tmf_task *tmf)
410405 {
411− struct domain_device *device = task->dev;
412− struct hisi_hba *hisi_hba = dev_to_hisi_hba(device);
413− struct hisi_sas_device *sas_dev = device->lldd_dev;
414− struct hisi_sas_port *port;
415− struct hisi_sas_slot *slot;
416− struct hisi_sas_cmd_hdr *cmd_hdr_base;
417− struct asd_sas_port *sas_port = device->port;
418− struct device *dev = hisi_hba->dev;
419− int dlvry_queue_slot, dlvry_queue, rc, slot_idx;
420− int n_elem = 0, n_elem_dif = 0, n_elem_req = 0;
421− struct scsi_cmnd *scmd = NULL;
422− struct hisi_sas_dq *dq;
406+ struct hisi_sas_cmd_hdr *cmd_hdr_base;
407+ int dlvry_queue_slot, dlvry_queue;
408+ struct sas_task *task = slot->task;
423409 unsigned long flags;
424410 int wr_q_index;
425411
426− if (DEV_IS_GONE(sas_dev)) {
427− if (sas_dev)
428− dev_info(dev, "task prep: device %d not ready\n",
429− sas_dev->device_id);
430− else
431− dev_info(dev, "task prep: device %016llx not ready\n",
432− SAS_ADDR(device->sas_addr));
433−
434− return -ECOMM;
435− }
436−
437− if (task->uldd_task) {
438− struct ata_queued_cmd *qc;
439−
440− if (dev_is_sata(device)) {
441− qc = task->uldd_task;
442− scmd = qc->scsicmd;
443− } else {
444− scmd = task->uldd_task;
445− }
446− }
447−
448− if (scmd) {
449− unsigned int dq_index;
450− u32 blk_tag;
451−
452− blk_tag = blk_mq_unique_tag(scsi_cmd_to_rq(scmd));
453− dq_index = blk_mq_unique_tag_to_hwq(blk_tag);
454− *dq_pointer = dq = &hisi_hba->dq[dq_index];
455− } else {
456− struct Scsi_Host *shost = hisi_hba->shost;
457− struct blk_mq_queue_map *qmap = &shost->tag_set.map[HCTX_TYPE_DEFAULT];
458− int queue = qmap->mq_map[raw_smp_processor_id()];
459−
460− *dq_pointer = dq = &hisi_hba->dq[queue];
461− }
462−
463− port = to_hisi_sas_port(sas_port);
464− if (port && !port->port_attached) {
465− dev_info(dev, "task prep: %s port%d not attach device\n",
466− (dev_is_sata(device)) ?
467− "SATA/STP" : "SAS",
468− device->port->id);
469−
470− return -ECOMM;
471− }
472−
473− rc = hisi_sas_dma_map(hisi_hba, task, &n_elem,
474− &n_elem_req);
475− if (rc < 0)
476− goto prep_out;
477−
478− if (!sas_protocol_ata(task->task_proto)) {
479− rc = hisi_sas_dif_dma_map(hisi_hba, &n_elem_dif, task);
480− if (rc < 0)
481− goto err_out_dma_unmap;
482− }
483−
484− if (hisi_hba->hw->slot_index_alloc)
485− rc = hisi_hba->hw->slot_index_alloc(hisi_hba, device);
486− else
487− rc = hisi_sas_slot_index_alloc(hisi_hba, scmd);
488−
489− if (rc < 0)
490− goto err_out_dif_dma_unmap;
491−
492− slot_idx = rc;
493− slot = &hisi_hba->slot_info[slot_idx];
494−
495412 spin_lock(&dq->lock);
496413 wr_q_index = dq->wr_point;
497414 dq->wr_point = (dq->wr_point + 1) % HISI_SAS_QUEUE_SLOTS;
@@ -505,16 +422,13 @@ static int hisi_sas_task_prep(struct sas_task *task, · 7 unmodified lines
505422 dlvry_queue_slot = wr_q_index;
506423
507424 slot->device_id = sas_dev->device_id;
508− slot->n_elem = n_elem;
509− slot->n_elem_dif = n_elem_dif;
510425 slot->dlvry_queue = dlvry_queue;
511426 slot->dlvry_queue_slot = dlvry_queue_slot;
512427 cmd_hdr_base = hisi_hba->cmd_hdr[dlvry_queue];
513428 slot->cmd_hdr = &cmd_hdr_base[dlvry_queue_slot];
514− slot->task = task;
515− slot->port = port;
429+
516430 slot->tmf = tmf;
517− slot->is_internal = is_tmf;
431+ slot->is_internal = tmf;
518432 task->lldd_task = slot;
519433
520434 memset(slot->cmd_hdr, 0, sizeof(struct hisi_sas_cmd_hdr));
@@ -534,8 +448,14 @@ static int hisi_sas_task_prep(struct sas_task *task, · 13 unmodified lines
534448 case SAS_PROTOCOL_SATA | SAS_PROTOCOL_STP:
535449 hisi_sas_task_prep_ata(hisi_hba, slot);
536450 break;
451+ case SAS_PROTOCOL_NONE:
452+ if (abort) {
453+ hisi_sas_task_prep_abort(hisi_hba, abort, slot, sas_dev->device_id);
454+ break;
455+ }
456+ fallthrough;
537457 default:
538− dev_err(dev, "task prep: unknown/unsupported proto (0x%x)\n",
458+ dev_err(hisi_hba->dev, "task prep: unknown/unsupported proto (0x%x)\n",
539459 task->task_proto);
540460 break;
541461 }
@@ -544,32 +464,27 @@ static int hisi_sas_task_prep(struct sas_task *task, · 2 unmodified lines
544464 task->task_state_flags |= SAS_TASK_AT_INITIATOR;
545465 spin_unlock_irqrestore(&task->task_state_lock, flags);
546466
547− ++(*pass);
548467 WRITE_ONCE(slot->ready, 1);
549468
550− return 0;
551−
552−err_out_dif_dma_unmap:
553− if (!sas_protocol_ata(task->task_proto))
554− hisi_sas_dif_dma_unmap(hisi_hba, task, n_elem_dif);
555−err_out_dma_unmap:
556− hisi_sas_dma_unmap(hisi_hba, task, n_elem,
557− n_elem_req);
558−prep_out:
559− dev_err(dev, "task prep: failed[%d]!\n", rc);
560− return rc;
469+ spin_lock(&dq->lock);
470+ hisi_hba->hw->start_delivery(dq);
471+ spin_unlock(&dq->lock);
561472 }
562473
563474 static int hisi_sas_task_exec(struct sas_task *task, gfp_t gfp_flags,
564− bool is_tmf, struct hisi_sas_tmf_task *tmf)
475+ struct hisi_sas_tmf_task *tmf)
565476 {
566− u32 rc;
567− u32 pass = 0;
568− struct hisi_hba *hisi_hba;
569− struct device *dev;
477+ int n_elem = 0, n_elem_dif = 0, n_elem_req = 0;
570478 struct domain_device *device = task->dev;
571479 struct asd_sas_port *sas_port = device->port;
480+ struct hisi_sas_device *sas_dev = device->lldd_dev;
481+ struct scsi_cmnd *scmd = NULL;
572482 struct hisi_sas_dq *dq = NULL;
483+ struct hisi_sas_port *port;
484+ struct hisi_hba *hisi_hba;
485+ struct hisi_sas_slot *slot;
486+ struct device *dev;
487+ int rc;
573488
574489 if (!sas_port) {
575490 struct task_status_struct *ts = &task->task_status;
@@ -596,17 +511,94 @@ static int hisi_sas_task_exec(struct sas_task *task, gfp_t gfp_flags, · 20 unmodified lines
596511 up(&hisi_hba->sem);
597512 }
598513
599− /* protect task_prep and start_delivery sequence */
600− rc = hisi_sas_task_prep(task, &dq, is_tmf, tmf, &pass);
601− if (rc)
602− dev_err(dev, "task exec: failed[%d]!\n", rc);
514+ if (DEV_IS_GONE(sas_dev)) {
515+ if (sas_dev)
516+ dev_info(dev, "task prep: device %d not ready\n",
517+ sas_dev->device_id);
518+ else
519+ dev_info(dev, "task prep: device %016llx not ready\n",
520+ SAS_ADDR(device->sas_addr));
521+
522+ return -ECOMM;
523+ }
524+
525+ if (task->uldd_task) {
526+ struct ata_queued_cmd *qc;
527+
528+ if (dev_is_sata(device)) {
529+ qc = task->uldd_task;
530+ scmd = qc->scsicmd;
531+ } else {
532+ scmd = task->uldd_task;
533+ }
534+ }
603535
604− if (likely(pass)) {
605− spin_lock(&dq->lock);
606− hisi_hba->hw->start_delivery(dq);
607− spin_unlock(&dq->lock);
536+ if (scmd) {
537+ unsigned int dq_index;
538+ u32 blk_tag;
539+
540+ blk_tag = blk_mq_unique_tag(scsi_cmd_to_rq(scmd));
541+ dq_index = blk_mq_unique_tag_to_hwq(blk_tag);
542+ dq = &hisi_hba->dq[dq_index];
543+ } else {
544+ struct Scsi_Host *shost = hisi_hba->shost;
545+ struct blk_mq_queue_map *qmap = &shost->tag_set.map[HCTX_TYPE_DEFAULT];
546+ int queue = qmap->mq_map[raw_smp_processor_id()];
547+
548+ dq = &hisi_hba->dq[queue];
549+ }
550+
551+ port = to_hisi_sas_port(sas_port);
552+ if (port && !port->port_attached) {
553+ dev_info(dev, "task prep: %s port%d not attach device\n",
554+ (dev_is_sata(device)) ?
555+ "SATA/STP" : "SAS",
556+ device->port->id);
557+
558+ return -ECOMM;
608559 }
609560
561+ rc = hisi_sas_dma_map(hisi_hba, task, &n_elem,
562+ &n_elem_req);
563+ if (rc < 0)
564+ goto prep_out;
565+
566+ if (!sas_protocol_ata(task->task_proto)) {
567+ rc = hisi_sas_dif_dma_map(hisi_hba, &n_elem_dif, task);
568+ if (rc < 0)
569+ goto err_out_dma_unmap;
570+ }
571+
572+ if (hisi_hba->hw->slot_index_alloc)
573+ rc = hisi_hba->hw->slot_index_alloc(hisi_hba, device);
574+ else
575+ rc = hisi_sas_slot_index_alloc(hisi_hba, scmd);
576+
577+ if (rc < 0)
578+ goto err_out_dif_dma_unmap;
579+
580+ slot = &hisi_hba->slot_info[rc];
581+ slot->n_elem = n_elem;
582+ slot->n_elem_dif = n_elem_dif;
583+ slot->task = task;
584+ slot->port = port;
585+
586+ slot->tmf = tmf;
587+ slot->is_internal = tmf;
588+
589+ /* protect task_prep and start_delivery sequence */
590+ hisi_sas_task_deliver(hisi_hba, slot, dq, sas_dev, NULL, tmf);
591+
592+ return 0;
593+
594+err_out_dif_dma_unmap:
595+ if (!sas_protocol_ata(task->task_proto))
596+ hisi_sas_dif_dma_unmap(hisi_hba, task, n_elem_dif);
597+err_out_dma_unmap:
598+ hisi_sas_dma_unmap(hisi_hba, task, n_elem,
599+ n_elem_req);
600+prep_out:
601+ dev_err(dev, "task exec: failed[%d]!\n", rc);
610602 return rc;
611603 }
612604
@@ -619,12 +611,6 @@ static void hisi_sas_bytes_dmaed(struct hisi_hba *hisi_hba, int phy_no, · 6 unmodified lines
619611 if (!phy->phy_attached)
620612 return;
621613
622− if (test_bit(HISI_SAS_PM_BIT, &hisi_hba->flags) &&
623− !sas_phy->suspended) {
624− dev_warn(hisi_hba->dev, "phy%d during suspend filtered out\n", phy_no);
625− return;
626− }
627−
628614 sas_notify_phy_event(sas_phy, PHYE_OOB_DONE, gfp_flags);
629615
630616 if (sas_phy->phy) {
@@ -860,10 +846,11 @@ int hisi_sas_scan_finished(struct Scsi_Host *shost, unsigned long time) · 229 unmodified lines
860846 }
861847 EXPORT_SYMBOL_GPL(hisi_sas_scan_finished);
862848
863−static void hisi_sas_phyup_work(struct work_struct *work)
849+static void hisi_sas_phyup_work_common(struct work_struct *work,
850+ enum hisi_sas_phy_event event)
864851 {
865852 struct hisi_sas_phy *phy =
866− container_of(work, typeof(*phy), works[HISI_PHYE_PHY_UP]);
853+ container_of(work, typeof(*phy), works[event]);
867854 struct hisi_hba *hisi_hba = phy->hisi_hba;
868855 struct asd_sas_phy *sas_phy = &phy->sas_phy;
869856 int phy_no = sas_phy->id;
@@ -874,6 +861,11 @@ static void hisi_sas_phyup_work(struct work_struct *work) · 4 unmodified lines
874861 hisi_sas_bytes_dmaed(hisi_hba, phy_no, GFP_KERNEL);
875862 }
876863
864+static void hisi_sas_phyup_work(struct work_struct *work)
865+{
866+ hisi_sas_phyup_work_common(work, HISI_PHYE_PHY_UP);
867+}
868+
877869 static void hisi_sas_linkreset_work(struct work_struct *work)
878870 {
879871 struct hisi_sas_phy *phy =
@@ -883,9 +875,21 @@ static void hisi_sas_linkreset_work(struct work_struct *work) · 3 unmodified lines
883875 hisi_sas_control_phy(sas_phy, PHY_FUNC_LINK_RESET, NULL);
884876 }
885877
878+static void hisi_sas_phyup_pm_work(struct work_struct *work)
879+{
880+ struct hisi_sas_phy *phy =
881+ container_of(work, typeof(*phy), works[HISI_PHYE_PHY_UP_PM]);
882+ struct hisi_hba *hisi_hba = phy->hisi_hba;
883+ struct device *dev = hisi_hba->dev;
884+
885+ hisi_sas_phyup_work_common(work, HISI_PHYE_PHY_UP_PM);
886+ pm_runtime_put_sync(dev);
887+}
888+
886889 static const work_func_t hisi_sas_phye_fns[HISI_PHYES_NUM] = {
887890 [HISI_PHYE_PHY_UP] = hisi_sas_phyup_work,
888891 [HISI_PHYE_LINK_RESET] = hisi_sas_linkreset_work,
892+ [HISI_PHYE_PHY_UP_PM] = hisi_sas_phyup_pm_work,
889893 };
890894
891895 bool hisi_sas_notify_phy_event(struct hisi_sas_phy *phy,
@@ -917,10 +921,14 @@ void hisi_sas_phy_oob_ready(struct hisi_hba *hisi_hba, int phy_no) · 25 unmodified lines
917921 {
918922 struct hisi_sas_phy *phy = &hisi_hba->phy[phy_no];
919923 struct device *dev = hisi_hba->dev;
924+ unsigned long flags;
920925
921926 dev_dbg(dev, "phy%d OOB ready\n", phy_no);
922− if (phy->phy_attached)
927+ spin_lock_irqsave(&phy->lock, flags);
928+ if (phy->phy_attached) {
929+ spin_unlock_irqrestore(&phy->lock, flags);
923930 return;
931+ }
924932
925933 if (!timer_pending(&phy->timer)) {
926934 if (phy->wait_phyup_cnt < HISI_SAS_WAIT_PHYUP_RETRIES) {
@@ -928,13 +936,17 @@ void hisi_sas_phy_oob_ready(struct hisi_hba *hisi_hba, int phy_no) · 1 unmodified line
928936 phy->timer.expires = jiffies +
929937 HISI_SAS_WAIT_PHYUP_TIMEOUT;
930938 add_timer(&phy->timer);
931− } else {
932− dev_warn(dev, "phy%d failed to come up %d times, giving up\n",
933− phy_no, phy->wait_phyup_cnt);
934− phy->wait_phyup_cnt = 0;
939+ spin_unlock_irqrestore(&phy->lock, flags);
940+ return;
935941 }
942+
943+ dev_warn(dev, "phy%d failed to come up %d times, giving up\n",
944+ phy_no, phy->wait_phyup_cnt);
945+ phy->wait_phyup_cnt = 0;
936946 }
947+ spin_unlock_irqrestore(&phy->lock, flags);
937948 }
949+
938950 EXPORT_SYMBOL_GPL(hisi_sas_phy_oob_ready);
939951
940952 static void hisi_sas_phy_init(struct hisi_hba *hisi_hba, int phy_no)
@@ -1105,7 +1117,7 @@ static void hisi_sas_dev_gone(struct domain_device *device) · 164 unmodified lines
11051117
11061118 static int hisi_sas_queue_command(struct sas_task *task, gfp_t gfp_flags)
11071119 {
1108− return hisi_sas_task_exec(task, gfp_flags, 0, NULL);
1120+ return hisi_sas_task_exec(task, gfp_flags, NULL);
11091121 }
11101122
11111123 static int hisi_sas_phy_set_linkrate(struct hisi_hba *hisi_hba, int phy_no,
@@ -1156,6 +1168,7 @@ static int hisi_sas_control_phy(struct asd_sas_phy *sas_phy, enum phy_func func, · 44 unmodified lines
11561168 u8 sts = phy->phy_attached;
11571169 int ret = 0;
11581170
1171+ down(&hisi_hba->sem);
11591172 phy->reset_completion = &completion;
11601173
11611174 switch (func) {
@@ -1199,6 +1212,7 @@ static int hisi_sas_control_phy(struct asd_sas_phy *sas_phy, enum phy_func func, · 37 unmodified lines
11991212 out:
12001213 phy->reset_completion = NULL;
12011214
1215+ up(&hisi_hba->sem);
12021216 return ret;
12031217 }
12041218
@@ -1259,8 +1273,7 @@ static int hisi_sas_exec_internal_tmf_task(struct domain_device *device, · 54 unmodified lines
12591273 task->slow_task->timer.expires = jiffies + TASK_TIMEOUT;
12601274 add_timer(&task->slow_task->timer);
12611275
1262− res = hisi_sas_task_exec(task, GFP_KERNEL, 1, tmf);
1263−
1276+ res = hisi_sas_task_exec(task, GFP_KERNEL, tmf);
12641277 if (res) {
12651278 del_timer_sync(&task->slow_task->timer);
12661279 dev_err(dev, "abort tmf: executing internal task failed: %d\n",
@@ -1433,11 +1446,13 @@ static void hisi_sas_refresh_port_id(struct hisi_hba *hisi_hba) · 166 unmodified lines
14331446 sas_port = device->port;
14341447 port = to_hisi_sas_port(sas_port);
14351448
1449+ spin_lock(&sas_port->phy_list_lock);
14361450 list_for_each_entry(sas_phy, &sas_port->phy_list, port_phy_el)
14371451 if (state & BIT(sas_phy->id)) {
14381452 phy = sas_phy->lldd_phy;
14391453 break;
14401454 }
1455+ spin_unlock(&sas_port->phy_list_lock);
14411456
14421457 if (phy) {
14431458 port->id = phy->port_id;
@@ -1514,22 +1529,25 @@ static void hisi_sas_send_ata_reset_each_phy(struct hisi_hba *hisi_hba, · 70 unmodified lines
15141529 struct ata_link *link;
15151530 u8 fis[20] = {0};
15161531 u32 state;
1532+ int i;
15171533
15181534 state = hisi_hba->hw->get_phys_state(hisi_hba);
1519− list_for_each_entry(sas_phy, &sas_port->phy_list, port_phy_el) {
1535+ for (i = 0; i < hisi_hba->n_phy; i++) {
15201536 if (!(state & BIT(sas_phy->id)))
15211537 continue;
1538+ if (!(sas_port->phy_mask & BIT(i)))
1539+ continue;
15221540
15231541 ata_for_each_link(link, ap, EDGE) {
15241542 int pmp = sata_srst_pmp(link);
15251543
1526− tmf_task.phy_id = sas_phy->id;
1544+ tmf_task.phy_id = i;
15271545 hisi_sas_fill_ata_reset_cmd(link->device, 1, pmp, fis);
15281546 rc = hisi_sas_exec_internal_tmf_task(device, fis, s,
15291547 &tmf_task);
15301548 if (rc != TMF_RESP_FUNC_COMPLETE) {
15311549 dev_err(dev, "phy%d ata reset failed rc=%d\n",
1532− sas_phy->id, rc);
1550+ i, rc);
15331551 break;
15341552 }
15351553 }
@@ -1581,7 +1599,6 @@ void hisi_sas_controller_reset_prepare(struct hisi_hba *hisi_hba) · 45 unmodified lines
15811599 {
15821600 struct Scsi_Host *shost = hisi_hba->shost;
15831601
1584− down(&hisi_hba->sem);
15851602 hisi_hba->phy_state = hisi_hba->hw->get_phys_state(hisi_hba);
15861603
15871604 scsi_block_requests(shost);
@@ -1606,9 +1623,9 @@ void hisi_sas_controller_reset_done(struct hisi_hba *hisi_hba) · 18 unmodified lines
16061623 if (hisi_hba->reject_stp_links_msk)
16071624 hisi_sas_terminate_stp_reject(hisi_hba);
16081625 hisi_sas_reset_init_all_devices(hisi_hba);
1609− up(&hisi_hba->sem);
16101626 scsi_unblock_requests(shost);
16111627 clear_bit(HISI_SAS_RESETTING_BIT, &hisi_hba->flags);
1628+ up(&hisi_hba->sem);
16121629
16131630 hisi_sas_rescan_topology(hisi_hba, hisi_hba->phy_state);
16141631 }
@@ -1619,8 +1636,11 @@ static int hisi_sas_controller_prereset(struct hisi_hba *hisi_hba) · 4 unmodified lines
16191636 if (!hisi_hba->hw->soft_reset)
16201637 return -1;
16211638
1622− if (test_and_set_bit(HISI_SAS_RESETTING_BIT, &hisi_hba->flags))
1639+ down(&hisi_hba->sem);
1640+ if (test_and_set_bit(HISI_SAS_RESETTING_BIT, &hisi_hba->flags)) {
1641+ up(&hisi_hba->sem);
16231642 return -1;
1643+ }
16241644
16251645 if (hisi_sas_debugfs_enable && hisi_hba->debugfs_itct[0].itct)
16261646 hisi_hba->hw->debugfs_snapshot_regs(hisi_hba);
@@ -2021,19 +2041,17 @@ static int hisi_sas_query_task(struct sas_task *task) · 394 unmodified lines
20212041
20222042 static int
20232043 hisi_sas_internal_abort_task_exec(struct hisi_hba *hisi_hba, int device_id,
2024− struct sas_task *task, int abort_flag,
2025− int task_tag, struct hisi_sas_dq *dq)
2044+ struct hisi_sas_internal_abort *abort,
2045+ struct sas_task *task,
2046+ struct hisi_sas_dq *dq)
20262047 {
20272048 struct domain_device *device = task->dev;
20282049 struct hisi_sas_device *sas_dev = device->lldd_dev;
20292050 struct device *dev = hisi_hba->dev;
20302051 struct hisi_sas_port *port;
2031− struct hisi_sas_slot *slot;
20322052 struct asd_sas_port *sas_port = device->port;
2033− struct hisi_sas_cmd_hdr *cmd_hdr_base;
2034− int dlvry_queue_slot, dlvry_queue, n_elem = 0, rc, slot_idx;
2035− unsigned long flags;
2036− int wr_q_index;
2053+ struct hisi_sas_slot *slot;
2054+ int slot_idx;
20372055
20382056 if (unlikely(test_bit(HISI_SAS_REJECT_CMD_BIT, &hisi_hba->flags)))
20392057 return -EINVAL;
@@ -2044,59 +2062,24 @@ hisi_sas_internal_abort_task_exec(struct hisi_hba *hisi_hba, int device_id, · 4 unmodified lines
20442062 port = to_hisi_sas_port(sas_port);
20452063
20462064 /* simply get a slot and send abort command */
2047− rc = hisi_sas_slot_index_alloc(hisi_hba, NULL);
2048− if (rc < 0)
2065+ slot_idx = hisi_sas_slot_index_alloc(hisi_hba, NULL);
2066+ if (slot_idx < 0)
20492067 goto err_out;
20502068
2051− slot_idx = rc;
20522069 slot = &hisi_hba->slot_info[slot_idx];
2053−
2054− spin_lock(&dq->lock);
2055− wr_q_index = dq->wr_point;
2056− dq->wr_point = (dq->wr_point + 1) % HISI_SAS_QUEUE_SLOTS;
2057− list_add_tail(&slot->delivery, &dq->list);
2058− spin_unlock(&dq->lock);
2059− spin_lock(&sas_dev->lock);
2060− list_add_tail(&slot->entry, &sas_dev->list);
2061− spin_unlock(&sas_dev->lock);
2062−
2063− dlvry_queue = dq->id;
2064− dlvry_queue_slot = wr_q_index;
2065−
2066− slot->device_id = sas_dev->device_id;
2067− slot->n_elem = n_elem;
2068− slot->dlvry_queue = dlvry_queue;
2069− slot->dlvry_queue_slot = dlvry_queue_slot;
2070− cmd_hdr_base = hisi_hba->cmd_hdr[dlvry_queue];
2071− slot->cmd_hdr = &cmd_hdr_base[dlvry_queue_slot];
2070+ slot->n_elem = 0;
20722071 slot->task = task;
20732072 slot->port = port;
20742073 slot->is_internal = true;
2075− task->lldd_task = slot;
2076−
2077− memset(slot->cmd_hdr, 0, sizeof(struct hisi_sas_cmd_hdr));
2078− memset(hisi_sas_cmd_hdr_addr_mem(slot), 0, HISI_SAS_COMMAND_TABLE_SZ);
2079− memset(hisi_sas_status_buf_addr_mem(slot), 0,
2080− sizeof(struct hisi_sas_err_record));
20812074
2082− hisi_sas_task_prep_abort(hisi_hba, slot, device_id,
2083− abort_flag, task_tag);
2084−
2085− spin_lock_irqsave(&task->task_state_lock, flags);
2086− task->task_state_flags |= SAS_TASK_AT_INITIATOR;
2087− spin_unlock_irqrestore(&task->task_state_lock, flags);
2088− WRITE_ONCE(slot->ready, 1);
2089− /* send abort command to the chip */
2090− spin_lock(&dq->lock);
2091− hisi_hba->hw->start_delivery(dq);
2092− spin_unlock(&dq->lock);
2075+ hisi_sas_task_deliver(hisi_hba, slot, dq, sas_dev, abort, NULL);
20932076
20942077 return 0;
20952078
20962079 err_out:
2097− dev_err(dev, "internal abort task prep: failed[%d]!\n", rc);
2080+ dev_err(dev, "internal abort task prep: failed[%d]!\n", slot_idx);
20982081
2099− return rc;
2082+ return slot_idx;
21002083 }
21012084
21022085 /**
@@ -2118,9 +2101,12 @@ _hisi_sas_internal_task_abort(struct hisi_hba *hisi_hba, · 15 unmodified lines
21182101 {
21192102 struct sas_task *task;
21202103 struct hisi_sas_device *sas_dev = device->lldd_dev;
2104+ struct hisi_sas_internal_abort abort = {
2105+ .flag = abort_flag,
2106+ .tag = tag,
2107+ };
21212108 struct device *dev = hisi_hba->dev;
21222109 int res;
2123−
21242110 /*
21252111 * The interface is not realized means this HW don't support internal
21262112 * abort, or don't need to do internal abort. Then here, we return
@@ -2138,14 +2124,14 @@ _hisi_sas_internal_task_abort(struct hisi_hba *hisi_hba, · 11 unmodified lines
21382124 return -ENOMEM;
21392125
21402126 task->dev = device;
2141− task->task_proto = device->tproto;
2127+ task->task_proto = SAS_PROTOCOL_NONE;
21422128 task->task_done = hisi_sas_task_done;
21432129 task->slow_task->timer.function = hisi_sas_tmf_timedout;
21442130 task->slow_task->timer.expires = jiffies + INTERNAL_ABORT_TIMEOUT;
21452131 add_timer(&task->slow_task->timer);
21462132
21472133 res = hisi_sas_internal_abort_task_exec(hisi_hba, sas_dev->device_id,
2148− task, abort_flag, tag, dq);
2134+ &abort, task, dq);
21492135 if (res) {
21502136 del_timer_sync(&task->slow_task->timer);
21512137 dev_err(dev, "internal task abort: executing internal task failed: %d\n",
@@ -2516,9 +2502,8 @@ int hisi_sas_alloc(struct hisi_hba *hisi_hba) · 364 unmodified lines
25162502 if (!hisi_hba->breakpoint)
25172503 goto err_out;
25182504
2519− hisi_hba->slot_index_count = max_command_entries;
2520− s = hisi_hba->slot_index_count / BITS_PER_BYTE;
2521− hisi_hba->slot_index_tags = devm_kzalloc(dev, s, GFP_KERNEL);
2505+ s = hisi_hba->slot_index_count = max_command_entries;
2506+ hisi_hba->slot_index_tags = devm_bitmap_zalloc(dev, s, GFP_KERNEL);
25222507 if (!hisi_hba->slot_index_tags)
25232508 goto err_out;
25242509
@@ -2536,7 +2521,6 @@ int hisi_sas_alloc(struct hisi_hba *hisi_hba) · 11 unmodified lines
25362521 if (!hisi_hba->sata_breakpoint)
25372522 goto err_out;
25382523
2539− hisi_sas_slot_index_init(hisi_hba);
25402524 hisi_hba->last_slot_index = HISI_SAS_UNRESERVED_IPTT;
25412525
25422526 hisi_hba->wq = create_singlethread_workqueue(dev_name(dev));
drivers/scsi/hisi_sas/hisi_sas_v3_hw.c+29−6
@@ -1484,7 +1484,6 @@ static irqreturn_t phy_up_v3_hw(int phy_no, struct hisi_hba *hisi_hba) · 1483 unmodified lines
14841484 struct asd_sas_phy *sas_phy = &phy->sas_phy;
14851485 struct device *dev = hisi_hba->dev;
14861486
1487− del_timer(&phy->timer);
14881487 hisi_sas_phy_write32(hisi_hba, phy_no, PHYCTRL_PHY_ENA_MSK, 1);
14891488
14901489 port_id = hisi_sas_read32(hisi_hba, PHY_PORT_NUM_MA);
@@ -1561,9 +1560,18 @@ static irqreturn_t phy_up_v3_hw(int phy_no, struct hisi_hba *hisi_hba) · 70 unmodified lines
15611560 }
15621561
15631562 phy->port_id = port_id;
1564− phy->phy_attached = 1;
1565− hisi_sas_notify_phy_event(phy, HISI_PHYE_PHY_UP);
1563+
1564+ /* Call pm_runtime_put_sync() with pairs in hisi_sas_phyup_pm_work() */
1565+ pm_runtime_get_noresume(dev);
1566+ hisi_sas_notify_phy_event(phy, HISI_PHYE_PHY_UP_PM);
1567+
15661568 res = IRQ_HANDLED;
1569+
1570+ spin_lock(&phy->lock);
1571+ /* Delete timer and set phy_attached atomically */
1572+ del_timer(&phy->timer);
1573+ phy->phy_attached = 1;
1574+ spin_unlock(&phy->lock);
15671575 end:
15681576 if (phy->reset_completion)
15691577 complete(phy->reset_completion);
@@ -4775,6 +4783,8 @@ hisi_sas_v3_probe(struct pci_dev *pdev, const struct pci_device_id *id) · 3205 unmodified lines
47754783
47764784 scsi_scan_host(shost);
47774785
4786+ pm_runtime_set_autosuspend_delay(dev, 5000);
4787+ pm_runtime_use_autosuspend(dev);
47784788 /*
47794789 * For the situation that there are ATA disks connected with SAS
47804790 * controller, it additionally creates ata_port which will affect the
@@ -4848,6 +4858,7 @@ static void hisi_sas_reset_prepare_v3_hw(struct pci_dev *pdev) · 67 unmodified lines
48484858 int rc;
48494859
48504860 dev_info(dev, "FLR prepare\n");
4861+ down(&hisi_hba->sem);
48514862 set_bit(HISI_SAS_RESETTING_BIT, &hisi_hba->flags);
48524863 hisi_sas_controller_reset_prepare(hisi_hba);
48534864
@@ -4897,6 +4908,8 @@ static int _suspend_v3_hw(struct device *device) · 43 unmodified lines
48974908 if (test_and_set_bit(HISI_SAS_RESETTING_BIT, &hisi_hba->flags))
48984909 return -1;
48994910
4911+ dev_warn(dev, "entering suspend state\n");
4912+
49004913 scsi_block_requests(shost);
49014914 set_bit(HISI_SAS_REJECT_CMD_BIT, &hisi_hba->flags);
49024915 flush_workqueue(hisi_hba->wq);
@@ -4912,11 +4925,11 @@ static int _suspend_v3_hw(struct device *device) · 9 unmodified lines
49124925
49134926 hisi_sas_init_mem(hisi_hba);
49144927
4915− dev_warn(dev, "entering suspend state\n");
4916−
49174928 hisi_sas_release_tasks(hisi_hba);
49184929
49194930 sas_suspend_ha(sha);
4931+
4932+ dev_warn(dev, "end of suspending controller\n");
49204933 return 0;
49214934 }
49224935
@@ -4943,9 +4956,19 @@ static int _resume_v3_hw(struct device *device) · 20 unmodified lines
49434956 return rc;
49444957 }
49454958 phys_init_v3_hw(hisi_hba);
4946− sas_resume_ha(sha);
4959+
4960+ /*
4961+ * If a directly-attached disk is removed during suspend, a deadlock
4962+ * may occur, as the PHYE_RESUME_TIMEOUT processing will require the
4963+ * hisi_hba->device to be active, which can only happen when resume
4964+ * completes. So don't wait for the HA event workqueue to drain upon
4965+ * resume.
4966+ */
4967+ sas_resume_ha_no_sync(sha);
49474968 clear_bit(HISI_SAS_RESETTING_BIT, &hisi_hba->flags);
49484969
4970+ dev_warn(dev, "end of resuming controller\n");
4971+
49494972 return 0;
49504973 }
49514974
drivers/scsi/hosts.c+3−12
@@ -61,6 +61,7 @@ static void scsi_host_cls_release(struct device *dev) · 60 unmodified lines
6161 static struct class shost_class = {
6262 .name = "scsi_host",
6363 .dev_release = scsi_host_cls_release,
64+ .dev_groups = scsi_shost_groups,
6465 };
6566
6667 /**
@@ -377,7 +378,7 @@ static struct device_type scsi_host_type = { · 310 unmodified lines
377378 struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize)
378379 {
379380 struct Scsi_Host *shost;
380− int index, i, j = 0;
381+ int index;
381382
382383 shost = kzalloc(sizeof(struct Scsi_Host) + privsize, GFP_KERNEL);
383384 if (!shost)
@@ -483,17 +484,7 @@ struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize) · 99 unmodified lines
483484 shost->shost_dev.parent = &shost->shost_gendev;
484485 shost->shost_dev.class = &shost_class;
485486 dev_set_name(&shost->shost_dev, "host%d", shost->host_no);
486− shost->shost_dev.groups = shost->shost_dev_attr_groups;
487− shost->shost_dev_attr_groups[j++] = &scsi_shost_attr_group;
488− if (sht->shost_groups) {
489− for (i = 0; sht->shost_groups[i] &&
490− j < ARRAY_SIZE(shost->shost_dev_attr_groups);
491− i++, j++) {
492− shost->shost_dev_attr_groups[j] =
493− sht->shost_groups[i];
494− }
495− }
496− WARN_ON_ONCE(j >= ARRAY_SIZE(shost->shost_dev_attr_groups));
487+ shost->shost_dev.groups = sht->shost_groups;
497488
498489 shost->ehandler = kthread_run(scsi_error_handler, shost,
499490 "scsi_eh_%d", shost->host_no);
drivers/scsi/hpsa.c+0−2
@@ -4354,7 +4354,6 @@ static void hpsa_update_scsi_devices(struct ctlr_info *h) · 4353 unmodified lines
43544354 int i, ndevs_to_allocate;
43554355 int raid_ctlr_position;
43564356 bool physical_device;
4357− DECLARE_BITMAP(lunzerobits, MAX_EXT_TARGETS);
43584357
43594358 currentsd = kcalloc(HPSA_MAX_DEVICES, sizeof(*currentsd), GFP_KERNEL);
43604359 physdev_list = kzalloc(sizeof(*physdev_list), GFP_KERNEL);
@@ -4368,7 +4367,6 @@ static void hpsa_update_scsi_devices(struct ctlr_info *h) · 7 unmodified lines
43684367 dev_err(&h->pdev->dev, "out of memory\n");
43694368 goto out;
43704369 }
4371− memset(lunzerobits, 0, sizeof(lunzerobits));
43724370
43734371 h->drv_req_rescan = 0; /* cancel scheduled rescan - we're doing it. */
43744372
drivers/scsi/initio.c+2−3
@@ -2602,13 +2602,11 @@ static void initio_build_scb(struct initio_host * host, struct scsi_ctrl_blk * c · 2601 unmodified lines
26022602 /**
26032603 * i91u_queuecommand_lck - Queue a new command if possible
26042604 * @cmd: SCSI command block from the mid layer
2605− * @done: Completion handler
26062605 *
26072606 * Attempts to queue a new command with the host adapter. Will return
26082607 * zero if successful or indicate a host busy condition if not (which
26092608 * will cause the mid layer to call us again later with the command)
26102609 */
2611−
26122610 static int i91u_queuecommand_lck(struct scsi_cmnd *cmd)
26132611 {
26142612 struct initio_host *host = (struct initio_host *) cmd->device->host->hostdata;
@@ -2849,7 +2847,8 @@ static int initio_probe_one(struct pci_dev *pdev, · 234 unmodified lines
28492847
28502848 for (; num_scb >= MAX_TARGETS + 3; num_scb--) {
28512849 i = num_scb * sizeof(struct scsi_ctrl_blk);
2852− if ((scb = kzalloc(i, GFP_DMA)) != NULL)
2850+ scb = kzalloc(i, GFP_KERNEL);
2851+ if (scb)
28532852 break;
28542853 }
28552854
drivers/scsi/libsas/sas_discover.c+0−1
@@ -8,7 +8,6 @@ · 7 unmodified lines
88
99 #include <linux/scatterlist.h>
1010 #include <linux/slab.h>
11−#include <linux/async.h>
1211 #include <scsi/scsi_host.h>
1312 #include <scsi/scsi_eh.h>
1413 #include "sas_internal.h"
drivers/scsi/libsas/sas_event.c+63−14
@@ -41,12 +41,25 @@ static int sas_queue_event(int event, struct sas_work *work, · 40 unmodified lines
4141 return rc;
4242 }
4343
44−
45−void __sas_drain_work(struct sas_ha_struct *ha)
44+void sas_queue_deferred_work(struct sas_ha_struct *ha)
4645 {
4746 struct sas_work *sw, *_sw;
4847 int ret;
4948
49+ spin_lock_irq(&ha->lock);
50+ list_for_each_entry_safe(sw, _sw, &ha->defer_q, drain_node) {
51+ list_del_init(&sw->drain_node);
52+ ret = sas_queue_work(ha, sw);
53+ if (ret != 1) {
54+ pm_runtime_put(ha->dev);
55+ sas_free_event(to_asd_sas_event(&sw->work));
56+ }
57+ }
58+ spin_unlock_irq(&ha->lock);
59+}
60+
61+void __sas_drain_work(struct sas_ha_struct *ha)
62+{
5063 set_bit(SAS_HA_DRAINING, &ha->state);
5164 /* flush submitters */
5265 spin_lock_irq(&ha->lock);
@@ -55,16 +68,8 @@ void __sas_drain_work(struct sas_ha_struct *ha) · 2 unmodified lines
5568 drain_workqueue(ha->event_q);
5669 drain_workqueue(ha->disco_q);
5770
58− spin_lock_irq(&ha->lock);
5971 clear_bit(SAS_HA_DRAINING, &ha->state);
60− list_for_each_entry_safe(sw, _sw, &ha->defer_q, drain_node) {
61− list_del_init(&sw->drain_node);
62− ret = sas_queue_work(ha, sw);
63− if (ret != 1)
64− sas_free_event(to_asd_sas_event(&sw->work));
65−
66− }
67− spin_unlock_irq(&ha->lock);
72+ sas_queue_deferred_work(ha);
6873 }
6974
7075 int sas_drain_work(struct sas_ha_struct *ha)
@@ -104,11 +109,15 @@ void sas_enable_revalidation(struct sas_ha_struct *ha) · 33 unmodified lines
104109 if (!test_and_clear_bit(ev, &d->pending))
105110 continue;
106111
107− if (list_empty(&port->phy_list))
112+ spin_lock(&port->phy_list_lock);
113+ if (list_empty(&port->phy_list)) {
114+ spin_unlock(&port->phy_list_lock);
108115 continue;
116+ }
109117
110118 sas_phy = container_of(port->phy_list.next, struct asd_sas_phy,
111119 port_phy_el);
120+ spin_unlock(&port->phy_list_lock);
112121 sas_notify_port_event(sas_phy,
113122 PORTE_BROADCAST_RCVD, GFP_KERNEL);
114123 }
@@ -119,19 +128,43 @@ void sas_enable_revalidation(struct sas_ha_struct *ha) · 4 unmodified lines
119128 static void sas_port_event_worker(struct work_struct *work)
120129 {
121130 struct asd_sas_event *ev = to_asd_sas_event(work);
131+ struct asd_sas_phy *phy = ev->phy;
132+ struct sas_ha_struct *ha = phy->ha;
122133
123134 sas_port_event_fns[ev->event](work);
135+ pm_runtime_put(ha->dev);
124136 sas_free_event(ev);
125137 }
126138
127139 static void sas_phy_event_worker(struct work_struct *work)
128140 {
129141 struct asd_sas_event *ev = to_asd_sas_event(work);
142+ struct asd_sas_phy *phy = ev->phy;
143+ struct sas_ha_struct *ha = phy->ha;
130144
131145 sas_phy_event_fns[ev->event](work);
146+ pm_runtime_put(ha->dev);
132147 sas_free_event(ev);
133148 }
134149
150+/* defer works of new phys during suspend */
151+static bool sas_defer_event(struct asd_sas_phy *phy, struct asd_sas_event *ev)
152+{
153+ struct sas_ha_struct *ha = phy->ha;
154+ unsigned long flags;
155+ bool deferred = false;
156+
157+ spin_lock_irqsave(&ha->lock, flags);
158+ if (test_bit(SAS_HA_RESUMING, &ha->state) && !phy->suspended) {
159+ struct sas_work *sw = &ev->work;
160+
161+ list_add_tail(&sw->drain_node, &ha->defer_q);
162+ deferred = true;
163+ }
164+ spin_unlock_irqrestore(&ha->lock, flags);
165+ return deferred;
166+}
167+
135168 int sas_notify_port_event(struct asd_sas_phy *phy, enum port_event event,
136169 gfp_t gfp_flags)
137170 {
@@ -145,11 +178,19 @@ int sas_notify_port_event(struct asd_sas_phy *phy, enum port_event event, · 7 unmodified lines
145178 if (!ev)
146179 return -ENOMEM;
147180
181+ /* Call pm_runtime_put() with pairs in sas_port_event_worker() */
182+ pm_runtime_get_noresume(ha->dev);
183+
148184 INIT_SAS_EVENT(ev, sas_port_event_worker, phy, event);
149185
186+ if (sas_defer_event(phy, ev))
187+ return 0;
188+
150189 ret = sas_queue_event(event, &ev->work, ha);
151− if (ret != 1)
190+ if (ret != 1) {
191+ pm_runtime_put(ha->dev);
152192 sas_free_event(ev);
193+ }
153194
154195 return ret;
155196 }
@@ -168,11 +209,19 @@ int sas_notify_phy_event(struct asd_sas_phy *phy, enum phy_event event, · 12 unmodified lines
168209 if (!ev)
169210 return -ENOMEM;
170211
212+ /* Call pm_runtime_put() with pairs in sas_phy_event_worker() */
213+ pm_runtime_get_noresume(ha->dev);
214+
171215 INIT_SAS_EVENT(ev, sas_phy_event_worker, phy, event);
172216
217+ if (sas_defer_event(phy, ev))
218+ return 0;
219+
173220 ret = sas_queue_event(event, &ev->work, ha);
174− if (ret != 1)
221+ if (ret != 1) {
222+ pm_runtime_put(ha->dev);
175223 sas_free_event(ev);
224+ }
176225
177226 return ret;
178227 }
drivers/scsi/libsas/sas_expander.c+3−0
@@ -58,7 +58,9 @@ static int smp_execute_task_sg(struct domain_device *dev, · 57 unmodified lines
5858 struct sas_task *task = NULL;
5959 struct sas_internal *i =
6060 to_sas_internal(dev->port->ha->core.shost->transportt);
61+ struct sas_ha_struct *ha = dev->port->ha;
6162
63+ pm_runtime_get_sync(ha->dev);
6264 mutex_lock(&dev->ex_dev.cmd_mutex);
6365 for (retry = 0; retry < 3; retry++) {
6466 if (test_bit(SAS_DEV_GONE, &dev->state)) {
@@ -131,6 +133,7 @@ static int smp_execute_task_sg(struct domain_device *dev, · 66 unmodified lines
131133 }
132134 }
133135 mutex_unlock(&dev->ex_dev.cmd_mutex);
136+ pm_runtime_put_sync(ha->dev);
134137
135138 BUG_ON(retry == 3 && task != NULL);
136139 sas_free_task(task);
drivers/scsi/libsas/sas_init.c+47−2
@@ -362,6 +362,7 @@ void sas_prep_resume_ha(struct sas_ha_struct *ha) · 361 unmodified lines
362362 int i;
363363
364364 set_bit(SAS_HA_REGISTERED, &ha->state);
365+ set_bit(SAS_HA_RESUMING, &ha->state);
365366
366367 /* clear out any stale link events/data from the suspension path */
367368 for (i = 0; i < ha->num_phys; i++) {
@@ -387,7 +388,31 @@ static int phys_suspended(struct sas_ha_struct *ha) · 19 unmodified lines
387388 return rc;
388389 }
389390
390−void sas_resume_ha(struct sas_ha_struct *ha)
391+static void sas_resume_insert_broadcast_ha(struct sas_ha_struct *ha)
392+{
393+ int i;
394+
395+ for (i = 0; i < ha->num_phys; i++) {
396+ struct asd_sas_port *port = ha->sas_port[i];
397+ struct domain_device *dev = port->port_dev;
398+
399+ if (dev && dev_is_expander(dev->dev_type)) {
400+ struct asd_sas_phy *first_phy;
401+
402+ spin_lock(&port->phy_list_lock);
403+ first_phy = list_first_entry_or_null(
404+ &port->phy_list, struct asd_sas_phy,
405+ port_phy_el);
406+ spin_unlock(&port->phy_list_lock);
407+
408+ if (first_phy)
409+ sas_notify_port_event(first_phy,
410+ PORTE_BROADCAST_RCVD, GFP_KERNEL);
411+ }
412+ }
413+}
414+
415+static void _sas_resume_ha(struct sas_ha_struct *ha, bool drain)
391416 {
392417 const unsigned long tmo = msecs_to_jiffies(25000);
393418 int i;
@@ -417,10 +442,30 @@ void sas_resume_ha(struct sas_ha_struct *ha) · 23 unmodified lines
417442 * flush out disks that did not return
418443 */
419444 scsi_unblock_requests(ha->core.shost);
420− sas_drain_work(ha);
445+ if (drain)
446+ sas_drain_work(ha);
447+ clear_bit(SAS_HA_RESUMING, &ha->state);
448+
449+ sas_queue_deferred_work(ha);
450+ /* send event PORTE_BROADCAST_RCVD to identify some new inserted
451+ * disks for expander
452+ */
453+ sas_resume_insert_broadcast_ha(ha);
454+}
455+
456+void sas_resume_ha(struct sas_ha_struct *ha)
457+{
458+ _sas_resume_ha(ha, true);
421459 }
422460 EXPORT_SYMBOL(sas_resume_ha);
423461
462+/* A no-sync variant, which does not call sas_drain_ha(). */
463+void sas_resume_ha_no_sync(struct sas_ha_struct *ha)
464+{
465+ _sas_resume_ha(ha, false);
466+}
467+EXPORT_SYMBOL(sas_resume_ha_no_sync);
468+
424469 void sas_suspend_ha(struct sas_ha_struct *ha)
425470 {
426471 int i;
drivers/scsi/libsas/sas_internal.h+2−0
@@ -14,6 +14,7 @@ · 13 unmodified lines
1414 #include <scsi/scsi_transport_sas.h>
1515 #include <scsi/libsas.h>
1616 #include <scsi/sas_ata.h>
17+#include <linux/pm_runtime.h>
1718
1819 #ifdef pr_fmt
1920 #undef pr_fmt
@@ -56,6 +57,7 @@ void sas_unregister_ports(struct sas_ha_struct *sas_ha); · 36 unmodified lines
5657
5758 void sas_disable_revalidation(struct sas_ha_struct *ha);
5859 void sas_enable_revalidation(struct sas_ha_struct *ha);
60+void sas_queue_deferred_work(struct sas_ha_struct *ha);
5961 void __sas_drain_work(struct sas_ha_struct *ha);
6062
6163 void sas_deform_port(struct asd_sas_phy *phy, int gone);
drivers/scsi/libsas/sas_scsi_host.c+4−3
@@ -37,7 +37,8 @@ · 36 unmodified lines
3737 static void sas_end_task(struct scsi_cmnd *sc, struct sas_task *task)
3838 {
3939 struct task_status_struct *ts = &task->task_status;
40− int hs = 0, stat = 0;
40+ enum scsi_host_status hs = DID_OK;
41+ enum exec_status stat = SAS_SAM_STAT_GOOD;
4142
4243 if (ts->resp == SAS_TASK_UNDELIVERED) {
4344 /* transport error */
@@ -82,10 +83,10 @@ static void sas_end_task(struct scsi_cmnd *sc, struct sas_task *task) · 38 unmodified lines
8283 case SAS_ABORTED_TASK:
8384 hs = DID_ABORT;
8485 break;
85− case SAM_STAT_CHECK_CONDITION:
86+ case SAS_SAM_STAT_CHECK_CONDITION:
8687 memcpy(sc->sense_buffer, ts->buf,
8788 min(SCSI_SENSE_BUFFERSIZE, ts->buf_valid_size));
88− stat = SAM_STAT_CHECK_CONDITION;
89+ stat = SAS_SAM_STAT_CHECK_CONDITION;
8990 break;
9091 default:
9192 stat = ts->stat;
drivers/scsi/lpfc/lpfc.h+47−50
@@ -496,52 +496,50 @@ struct lpfc_cgn_info { · 495 unmodified lines
496496 __le32 cgn_alarm_hr[24];
497497 __le32 cgn_alarm_day[LPFC_MAX_CGN_DAYS];
498498
499− /* Start of congestion statistics */
500− uint8_t cgn_stat_npm; /* Notifications per minute */
501−
502− /* Start Time */
503− uint8_t cgn_stat_month;
504− uint8_t cgn_stat_day;
505− uint8_t cgn_stat_year;
506− uint8_t cgn_stat_hour;
507− uint8_t cgn_stat_minute;
508− uint8_t cgn_pad2[2];
509−
510− __le32 cgn_notification;
511− __le32 cgn_peer_notification;
512− __le32 link_integ_notification;
513− __le32 delivery_notification;
514−
515− uint8_t cgn_stat_cgn_month; /* Last congestion notification FPIN */
516− uint8_t cgn_stat_cgn_day;
517− uint8_t cgn_stat_cgn_year;
518− uint8_t cgn_stat_cgn_hour;
519− uint8_t cgn_stat_cgn_min;
520− uint8_t cgn_stat_cgn_sec;
521−
522− uint8_t cgn_stat_peer_month; /* Last peer congestion FPIN */
523− uint8_t cgn_stat_peer_day;
524− uint8_t cgn_stat_peer_year;
525− uint8_t cgn_stat_peer_hour;
526− uint8_t cgn_stat_peer_min;
527− uint8_t cgn_stat_peer_sec;
528−
529− uint8_t cgn_stat_lnk_month; /* Last link integrity FPIN */
530− uint8_t cgn_stat_lnk_day;
531− uint8_t cgn_stat_lnk_year;
532− uint8_t cgn_stat_lnk_hour;
533− uint8_t cgn_stat_lnk_min;
534− uint8_t cgn_stat_lnk_sec;
535−
536− uint8_t cgn_stat_del_month; /* Last delivery notification FPIN */
537− uint8_t cgn_stat_del_day;
538− uint8_t cgn_stat_del_year;
539− uint8_t cgn_stat_del_hour;
540− uint8_t cgn_stat_del_min;
541− uint8_t cgn_stat_del_sec;
542−#define LPFC_CGN_STAT_SIZE 48
543−#define LPFC_CGN_DATA_SIZE (sizeof(struct lpfc_cgn_info) - \
544− LPFC_CGN_STAT_SIZE - sizeof(uint32_t))
499+ struct_group(cgn_stat,
500+ uint8_t cgn_stat_npm; /* Notifications per minute */
501+
502+ /* Start Time */
503+ uint8_t cgn_stat_month;
504+ uint8_t cgn_stat_day;
505+ uint8_t cgn_stat_year;
506+ uint8_t cgn_stat_hour;
507+ uint8_t cgn_stat_minute;
508+ uint8_t cgn_pad2[2];
509+
510+ __le32 cgn_notification;
511+ __le32 cgn_peer_notification;
512+ __le32 link_integ_notification;
513+ __le32 delivery_notification;
514+
515+ uint8_t cgn_stat_cgn_month; /* Last congestion notification FPIN */
516+ uint8_t cgn_stat_cgn_day;
517+ uint8_t cgn_stat_cgn_year;
518+ uint8_t cgn_stat_cgn_hour;
519+ uint8_t cgn_stat_cgn_min;
520+ uint8_t cgn_stat_cgn_sec;
521+
522+ uint8_t cgn_stat_peer_month; /* Last peer congestion FPIN */
523+ uint8_t cgn_stat_peer_day;
524+ uint8_t cgn_stat_peer_year;
525+ uint8_t cgn_stat_peer_hour;
526+ uint8_t cgn_stat_peer_min;
527+ uint8_t cgn_stat_peer_sec;
528+
529+ uint8_t cgn_stat_lnk_month; /* Last link integrity FPIN */
530+ uint8_t cgn_stat_lnk_day;
531+ uint8_t cgn_stat_lnk_year;
532+ uint8_t cgn_stat_lnk_hour;
533+ uint8_t cgn_stat_lnk_min;
534+ uint8_t cgn_stat_lnk_sec;
535+
536+ uint8_t cgn_stat_del_month; /* Last delivery notification FPIN */
537+ uint8_t cgn_stat_del_day;
538+ uint8_t cgn_stat_del_year;
539+ uint8_t cgn_stat_del_hour;
540+ uint8_t cgn_stat_del_min;
541+ uint8_t cgn_stat_del_sec;
542+ );
545543
546544 __le32 cgn_info_crc;
547545 #define LPFC_CGN_CRC32_MAGIC_NUMBER 0x1EDC6F41
@@ -669,8 +667,6 @@ struct lpfc_vport { · 121 unmodified lines
669667 struct timer_list els_tmofunc;
670668 struct timer_list delayed_disc_tmo;
671669
672− int unreg_vpi_cmpl;
673−
674670 uint8_t load_flag;
675671 #define FC_LOADING 0x1 /* HBA in process of loading drvr */
676672 #define FC_UNLOADING 0x2 /* HBA in process of unloading drvr */
@@ -1023,7 +1019,6 @@ struct lpfc_hba { · 346 unmodified lines
10231019 #define HBA_DEVLOSS_TMO 0x2000 /* HBA in devloss timeout */
10241020 #define HBA_RRQ_ACTIVE 0x4000 /* process the rrq active list */
10251021 #define HBA_IOQ_FLUSH 0x8000 /* FCP/NVME I/O queues being flushed */
1026−#define HBA_FW_DUMP_OP 0x10000 /* Skips fn reset before FW dump */
10271022 #define HBA_RECOVERABLE_UE 0x20000 /* Firmware supports recoverable UE */
10281023 #define HBA_FORCED_LINK_SPEED 0x40000 /*
10291024 * Firmware supports Forced Link Speed
@@ -1031,7 +1026,7 @@ struct lpfc_hba { · 1 unmodified line
10311026 */
10321027 #define HBA_PCI_ERR 0x80000 /* The PCI slot is offline */
10331028 #define HBA_FLOGI_ISSUED 0x100000 /* FLOGI was issued */
1034−#define HBA_CGN_RSVD1 0x200000 /* Reserved CGN flag */
1029+#define HBA_SHORT_CMF 0x200000 /* shorter CMF timer routine */
10351030 #define HBA_CGN_DAY_WRAP 0x400000 /* HBA Congestion info day wraps */
10361031 #define HBA_DEFER_FLOGI 0x800000 /* Defer FLOGI till read_sparm cmpl */
10371032 #define HBA_SETUP 0x1000000 /* Signifies HBA setup is completed */
@@ -1040,6 +1035,7 @@ struct lpfc_hba { · 2 unmodified lines
10401035 #define HBA_HBEAT_TMO 0x8000000 /* HBEAT initiated after timeout */
10411036 #define HBA_FLOGI_OUTSTANDING 0x10000000 /* FLOGI is outstanding */
10421037
1038+ struct completion *fw_dump_cmpl; /* cmpl event tracker for fw_dump */
10431039 uint32_t fcp_ring_in_use; /* When polling test if intr-hndlr active*/
10441040 struct lpfc_dmabuf slim2p;
10451041
@@ -1604,6 +1600,7 @@ struct lpfc_hba { · 558 unmodified lines
16041600 #define LPFC_MAX_RXMONITOR_ENTRY 800
16051601 #define LPFC_MAX_RXMONITOR_DUMP 32
16061602 struct rxtable_entry {
1603+ uint64_t cmf_bytes; /* Total no of read bytes for CMF_SYNC_WQE */
16071604 uint64_t total_bytes; /* Total no of read bytes requested */
16081605 uint64_t rcv_bytes; /* Total no of read bytes completed */
16091606 uint64_t avg_io_size;
drivers/scsi/lpfc/lpfc_attr.c+40−22
@@ -1709,25 +1709,25 @@ lpfc_sli4_pdev_reg_request(struct lpfc_hba *phba, uint32_t opcode) · 1708 unmodified lines
17091709 before_fc_flag = phba->pport->fc_flag;
17101710 sriov_nr_virtfn = phba->cfg_sriov_nr_virtfn;
17111711
1712− /* Disable SR-IOV virtual functions if enabled */
1713− if (phba->cfg_sriov_nr_virtfn) {
1714− pci_disable_sriov(pdev);
1715− phba->cfg_sriov_nr_virtfn = 0;
1716− }
1712+ if (opcode == LPFC_FW_DUMP) {
1713+ init_completion(&online_compl);
1714+ phba->fw_dump_cmpl = &online_compl;
1715+ } else {
1716+ /* Disable SR-IOV virtual functions if enabled */
1717+ if (phba->cfg_sriov_nr_virtfn) {
1718+ pci_disable_sriov(pdev);
1719+ phba->cfg_sriov_nr_virtfn = 0;
1720+ }
17171721
1718− if (opcode == LPFC_FW_DUMP)
1719− phba->hba_flag |= HBA_FW_DUMP_OP;
1722+ status = lpfc_do_offline(phba, LPFC_EVT_OFFLINE);
17201723
1721− status = lpfc_do_offline(phba, LPFC_EVT_OFFLINE);
1724+ if (status != 0)
1725+ return status;
17221726
1723− if (status != 0) {
1724− phba->hba_flag &= ~HBA_FW_DUMP_OP;
1725− return status;
1727+ /* wait for the device to be quiesced before firmware reset */
1728+ msleep(100);
17261729 }
17271730
1728− /* wait for the device to be quiesced before firmware reset */
1729− msleep(100);
1730−
17311731 reg_val = readl(phba->sli4_hba.conf_regs_memmap_p +
17321732 LPFC_CTL_PDEV_CTL_OFFSET);
17331733
@@ -1756,24 +1756,42 @@ lpfc_sli4_pdev_reg_request(struct lpfc_hba *phba, uint32_t opcode) · 22 unmodified lines
17561756 lpfc_printf_log(phba, KERN_ERR, LOG_SLI,
17571757 "3153 Fail to perform the requested "
17581758 "access: x%x\n", reg_val);
1759+ if (phba->fw_dump_cmpl)
1760+ phba->fw_dump_cmpl = NULL;
17591761 return rc;
17601762 }
17611763
17621764 /* keep the original port state */
1763− if (before_fc_flag & FC_OFFLINE_MODE)
1764− goto out;
1765−
1766− init_completion(&online_compl);
1767− job_posted = lpfc_workq_post_event(phba, &status, &online_compl,
1768− LPFC_EVT_ONLINE);
1769− if (!job_posted)
1765+ if (before_fc_flag & FC_OFFLINE_MODE) {
1766+ if (phba->fw_dump_cmpl)
1767+ phba->fw_dump_cmpl = NULL;
17701768 goto out;
1769+ }
17711770
1772− wait_for_completion(&online_compl);
1771+ /* Firmware dump will trigger an HA_ERATT event, and
1772+ * lpfc_handle_eratt_s4 routine already handles bringing the port back
1773+ * online.
1774+ */
1775+ if (opcode == LPFC_FW_DUMP) {
1776+ wait_for_completion(phba->fw_dump_cmpl);
1777+ } else {
1778+ init_completion(&online_compl);
1779+ job_posted = lpfc_workq_post_event(phba, &status, &online_compl,
1780+ LPFC_EVT_ONLINE);
1781+ if (!job_posted)
1782+ goto out;
17731783
1784+ wait_for_completion(&online_compl);
1785+ }
17741786 out:
17751787 /* in any case, restore the virtual functions enabled as before */
17761788 if (sriov_nr_virtfn) {
1789+ /* If fw_dump was performed, first disable to clean up */
1790+ if (opcode == LPFC_FW_DUMP) {
1791+ pci_disable_sriov(pdev);
1792+ phba->cfg_sriov_nr_virtfn = 0;
1793+ }
1794+
17771795 sriov_err =
17781796 lpfc_sli_probe_sriov_nr_virtfn(phba, sriov_nr_virtfn);
17791797 if (!sriov_err)
drivers/scsi/lpfc/lpfc_debugfs.c+20−7
@@ -5484,7 +5484,7 @@ lpfc_cgn_buffer_read(struct file *file, char __user *buf, size_t nbytes, · 5483 unmodified lines
54845484 if (len > (LPFC_CGN_BUF_SIZE - LPFC_DEBUG_OUT_LINE_SZ)) {
54855485 len += scnprintf(buffer + len, LPFC_CGN_BUF_SIZE - len,
54865486 "Truncated . . .\n");
5487− break;
5487+ goto out;
54885488 }
54895489 len += scnprintf(buffer + len, LPFC_CGN_BUF_SIZE - len,
54905490 "%03x: %08x %08x %08x %08x "
@@ -5495,6 +5495,17 @@ lpfc_cgn_buffer_read(struct file *file, char __user *buf, size_t nbytes, · 4 unmodified lines
54955495 cnt += 32;
54965496 ptr += 8;
54975497 }
5498+ if (len > (LPFC_CGN_BUF_SIZE - LPFC_DEBUG_OUT_LINE_SZ)) {
5499+ len += scnprintf(buffer + len, LPFC_CGN_BUF_SIZE - len,
5500+ "Truncated . . .\n");
5501+ goto out;
5502+ }
5503+ len += scnprintf(buffer + len, LPFC_CGN_BUF_SIZE - len,
5504+ "Parameter Data\n");
5505+ ptr = (uint32_t *)&phba->cgn_p;
5506+ len += scnprintf(buffer + len, LPFC_CGN_BUF_SIZE - len,
5507+ "%08x %08x %08x %08x\n",
5508+ *ptr, *(ptr + 1), *(ptr + 2), *(ptr + 3));
54985509 out:
54995510 return simple_read_from_buffer(buf, nbytes, ppos, buffer, len);
55005511 }
@@ -5561,22 +5572,24 @@ lpfc_rx_monitor_read(struct file *file, char __user *buf, size_t nbytes, · 60 unmodified lines
55615572 start = tail;
55625573
55635574 len += scnprintf(buffer + len, MAX_DEBUGFS_RX_TABLE_SIZE - len,
5564− " MaxBPI\t Total Data Cmd Total Data Cmpl "
5565− " Latency(us) Avg IO Size\tMax IO Size IO cnt "
5566− "Info BWutil(ms)\n");
5575+ " MaxBPI Tot_Data_CMF Tot_Data_Cmd "
5576+ "Tot_Data_Cmpl Lat(us) Avg_IO Max_IO "
5577+ "Bsy IO_cnt Info BWutil(ms)\n");
55675578 get_table:
55685579 for (i = start; i < last; i++) {
55695580 entry = &phba->rxtable[i];
55705581 len += scnprintf(buffer + len, MAX_DEBUGFS_RX_TABLE_SIZE - len,
5571− "%3d:%12lld %12lld\t%12lld\t"
5572− "%8lldus\t%8lld\t%10lld "
5573− "%8d %2d %2d(%2d)\n",
5582+ "%3d:%12lld %12lld %12lld %12lld "
5583+ "%7lldus %8lld %7lld "
5584+ "%2d %4d %2d %2d(%2d)\n",
55745585 i, entry->max_bytes_per_interval,
5586+ entry->cmf_bytes,
55755587 entry->total_bytes,
55765588 entry->rcv_bytes,
55775589 entry->avg_io_latency,
55785590 entry->avg_io_size,
55795591 entry->max_read_cnt,
5592+ entry->cmf_busy,
55805593 entry->io_cnt,
55815594 entry->cmf_info,
55825595 entry->timer_utilization,
drivers/scsi/lpfc/lpfc_debugfs.h+1−1
@@ -282,7 +282,7 @@ struct lpfc_idiag { · 281 unmodified lines
282282 void *ptr_private;
283283 };
284284
285−#define MAX_DEBUGFS_RX_TABLE_SIZE (100 * LPFC_MAX_RXMONITOR_ENTRY)
285+#define MAX_DEBUGFS_RX_TABLE_SIZE (128 * LPFC_MAX_RXMONITOR_ENTRY)
286286 struct lpfc_rx_monitor_debug {
287287 char *i_private;
288288 char *buffer;
drivers/scsi/lpfc/lpfc_els.c+15−7
@@ -3538,11 +3538,6 @@ lpfc_issue_els_rscn(struct lpfc_vport *vport, uint8_t retry) · 3537 unmodified lines
35383538 return 1;
35393539 }
35403540
3541− /* This will cause the callback-function lpfc_cmpl_els_cmd to
3542− * trigger the release of node.
3543− */
3544− if (!(vport->fc_flag & FC_PT2PT))
3545− lpfc_nlp_put(ndlp);
35463541 return 0;
35473542 }
35483543
@@ -6899,6 +6894,7 @@ static int · 3350 unmodified lines
68996894 lpfc_get_rdp_info(struct lpfc_hba *phba, struct lpfc_rdp_context *rdp_context)
69006895 {
69016896 LPFC_MBOXQ_t *mbox = NULL;
6897+ struct lpfc_dmabuf *mp;
69026898 int rc;
69036899
69046900 mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
@@ -6914,8 +6910,11 @@ lpfc_get_rdp_info(struct lpfc_hba *phba, struct lpfc_rdp_context *rdp_context) · 9 unmodified lines
69146910 mbox->mbox_cmpl = lpfc_mbx_cmpl_rdp_page_a0;
69156911 mbox->ctx_ndlp = (struct lpfc_rdp_context *)rdp_context;
69166912 rc = lpfc_sli_issue_mbox(phba, mbox, MBX_NOWAIT);
6917− if (rc == MBX_NOT_FINISHED)
6913+ if (rc == MBX_NOT_FINISHED) {
6914+ mp = (struct lpfc_dmabuf *)mbox->ctx_buf;
6915+ lpfc_mbuf_free(phba, mp->virt, mp->phys);
69186916 goto issue_mbox_fail;
6917+ }
69196918
69206919 return 0;
69216920
@@ -10974,10 +10973,19 @@ lpfc_cmpl_els_npiv_logo(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 4052 unmodified lines
1097410973 lpfc_can_disctmo(vport);
1097510974 }
1097610975
10976+ if (ndlp->save_flags & NLP_WAIT_FOR_LOGO) {
10977+ /* Wake up lpfc_vport_delete if waiting...*/
10978+ if (ndlp->logo_waitq)
10979+ wake_up(ndlp->logo_waitq);
10980+ spin_lock_irq(&ndlp->lock);
10981+ ndlp->nlp_flag &= ~(NLP_ISSUE_LOGO | NLP_LOGO_SND);
10982+ ndlp->save_flags &= ~NLP_WAIT_FOR_LOGO;
10983+ spin_unlock_irq(&ndlp->lock);
10984+ }
10985+
1097710986 /* Safe to release resources now. */
1097810987 lpfc_els_free_iocb(phba, cmdiocb);
1097910988 lpfc_nlp_put(ndlp);
10980− vport->unreg_vpi_cmpl = VPORT_ERROR;
1098110989 }
1098210990
1098310991 /**
drivers/scsi/lpfc/lpfc_hbadisc.c+7−3
@@ -869,10 +869,16 @@ lpfc_work_done(struct lpfc_hba *phba) · 868 unmodified lines
869869 if (phba->pci_dev_grp == LPFC_PCI_DEV_OC)
870870 lpfc_sli4_post_async_mbox(phba);
871871
872− if (ha_copy & HA_ERATT)
872+ if (ha_copy & HA_ERATT) {
873873 /* Handle the error attention event */
874874 lpfc_handle_eratt(phba);
875875
876+ if (phba->fw_dump_cmpl) {
877+ complete(phba->fw_dump_cmpl);
878+ phba->fw_dump_cmpl = NULL;
879+ }
880+ }
881+
876882 if (ha_copy & HA_MBATT)
877883 lpfc_sli_handle_mb_event(phba);
878884
@@ -3928,7 +3934,6 @@ lpfc_mbx_cmpl_unreg_vpi(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb) · 3049 unmodified lines
39283934 vport->vpi_state &= ~LPFC_VPI_REGISTERED;
39293935 vport->fc_flag |= FC_VPORT_NEEDS_REG_VPI;
39303936 spin_unlock_irq(shost->host_lock);
3931− vport->unreg_vpi_cmpl = VPORT_OK;
39323937 mempool_free(pmb, phba->mbox_mem_pool);
39333938 lpfc_cleanup_vports_rrqs(vport, NULL);
39343939 /*
@@ -3958,7 +3963,6 @@ lpfc_mbx_unreg_vpi(struct lpfc_vport *vport) · 23 unmodified lines
39583963 lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
39593964 "1800 Could not issue unreg_vpi\n");
39603965 mempool_free(mbox, phba->mbox_mem_pool);
3961− vport->unreg_vpi_cmpl = VPORT_ERROR;
39623966 return rc;
39633967 }
39643968 return 0;
drivers/scsi/lpfc/lpfc_hw.h+18−11
@@ -3675,19 +3675,26 @@ union sli_var { · 3674 unmodified lines
36753675 };
36763676
36773677 typedef struct {
3678+ struct_group_tagged(MAILBOX_word0, bits,
3679+ union {
3680+ struct {
36783681 #ifdef __BIG_ENDIAN_BITFIELD
3679− uint16_t mbxStatus;
3680− uint8_t mbxCommand;
3681− uint8_t mbxReserved:6;
3682− uint8_t mbxHc:1;
3683− uint8_t mbxOwner:1; /* Low order bit first word */
3682+ uint16_t mbxStatus;
3683+ uint8_t mbxCommand;
3684+ uint8_t mbxReserved:6;
3685+ uint8_t mbxHc:1;
3686+ uint8_t mbxOwner:1; /* Low order bit first word */
36843687 #else /* __LITTLE_ENDIAN_BITFIELD */
3685− uint8_t mbxOwner:1; /* Low order bit first word */
3686− uint8_t mbxHc:1;
3687− uint8_t mbxReserved:6;
3688− uint8_t mbxCommand;
3689− uint16_t mbxStatus;
3688+ uint8_t mbxOwner:1; /* Low order bit first word */
3689+ uint8_t mbxHc:1;
3690+ uint8_t mbxReserved:6;
3691+ uint8_t mbxCommand;
3692+ uint16_t mbxStatus;
36903693 #endif
3694+ };
3695+ u32 word0;
3696+ };
3697+ );
36913698
36923699 MAILVARIANTS un;
36933700 union sli_var us;
@@ -3746,7 +3753,7 @@ typedef struct { · 52 unmodified lines
37463753 #define IOERR_ILLEGAL_COMMAND 0x06
37473754 #define IOERR_XCHG_DROPPED 0x07
37483755 #define IOERR_ILLEGAL_FIELD 0x08
3749−#define IOERR_BAD_CONTINUE 0x09
3756+#define IOERR_RPI_SUSPENDED 0x09
37503757 #define IOERR_TOO_MANY_BUFFERS 0x0A
37513758 #define IOERR_RCV_BUFFER_WAITING 0x0B
37523759 #define IOERR_NO_CONNECTION 0x0C
drivers/scsi/lpfc/lpfc_init.c+29−12
@@ -5373,8 +5373,10 @@ lpfc_sli4_async_link_evt(struct lpfc_hba *phba, · 5372 unmodified lines
53735373 */
53745374 if (!(phba->hba_flag & HBA_FCOE_MODE)) {
53755375 rc = lpfc_sli_issue_mbox(phba, pmb, MBX_NOWAIT);
5376− if (rc == MBX_NOT_FINISHED)
5376+ if (rc == MBX_NOT_FINISHED) {
5377+ lpfc_mbuf_free(phba, mp->virt, mp->phys);
53775378 goto out_free_dmabuf;
5379+ }
53785380 return;
53795381 }
53805382 /*
@@ -5925,7 +5927,7 @@ lpfc_cmf_timer(struct hrtimer *timer) · 544 unmodified lines
59255927 uint32_t io_cnt;
59265928 uint32_t head, tail;
59275929 uint32_t busy, max_read;
5928− uint64_t total, rcv, lat, mbpi, extra;
5930+ uint64_t total, rcv, lat, mbpi, extra, cnt;
59295931 int timer_interval = LPFC_CMF_INTERVAL;
59305932 uint32_t ms;
59315933 struct lpfc_cgn_stat *cgs;
@@ -5996,20 +5998,28 @@ lpfc_cmf_timer(struct hrtimer *timer) · 64 unmodified lines
59965998
59975999 /* Calculate any extra bytes needed to account for the
59986000 * timer accuracy. If we are less than LPFC_CMF_INTERVAL
5999− * add an extra 3% slop factor, equal to LPFC_CMF_INTERVAL
6000− * add an extra 2%. The goal is to equalize total with a
6001− * time > LPFC_CMF_INTERVAL or <= LPFC_CMF_INTERVAL + 1
6001+ * calculate the adjustment needed for total to reflect
6002+ * a full LPFC_CMF_INTERVAL.
60026003 */
6003− if (ms == LPFC_CMF_INTERVAL)
6004− extra = div_u64(total, 50);
6005− else if (ms < LPFC_CMF_INTERVAL)
6006− extra = div_u64(total, 33);
6004+ if (ms && ms < LPFC_CMF_INTERVAL) {
6005+ cnt = div_u64(total, ms); /* bytes per ms */
6006+ cnt *= LPFC_CMF_INTERVAL; /* what total should be */
6007+
6008+ /* If the timeout is scheduled to be shorter,
6009+ * this value may skew the data, so cap it at mbpi.
6010+ */
6011+ if ((phba->hba_flag & HBA_SHORT_CMF) && cnt > mbpi)
6012+ cnt = mbpi;
6013+
6014+ extra = cnt - total;
6015+ }
60076016 lpfc_issue_cmf_sync_wqe(phba, LPFC_CMF_INTERVAL, total + extra);
60086017 } else {
60096018 /* For Monitor mode or link down we want mbpi
60106019 * to be the full link speed
60116020 */
60126021 mbpi = phba->cmf_link_byte_count;
6022+ extra = 0;
60136023 }
60146024 phba->cmf_timer_cnt++;
60156025
@@ -6040,6 +6050,7 @@ lpfc_cmf_timer(struct hrtimer *timer) · 24 unmodified lines
60406050 LPFC_RXMONITOR_TABLE_IN_USE);
60416051 entry = &phba->rxtable[head];
60426052 entry->total_bytes = total;
6053+ entry->cmf_bytes = total + extra;
60436054 entry->rcv_bytes = rcv;
60446055 entry->cmf_busy = busy;
60456056 entry->cmf_info = phba->cmf_active_info;
@@ -6082,6 +6093,8 @@ lpfc_cmf_timer(struct hrtimer *timer) · 36 unmodified lines
60826093 /* Each minute save Fabric and Driver congestion information */
60836094 lpfc_cgn_save_evt_cnt(phba);
60846095
6096+ phba->hba_flag &= ~HBA_SHORT_CMF;
6097+
60856098 /* Since we need to call lpfc_cgn_save_evt_cnt every minute, on the
60866099 * minute, adjust our next timer interval, if needed, to ensure a
60876100 * 1 minute granularity when we get the next timer interrupt.
@@ -6092,6 +6105,8 @@ lpfc_cmf_timer(struct hrtimer *timer) · 4 unmodified lines
60926105 jiffies);
60936106 if (timer_interval <= 0)
60946107 timer_interval = LPFC_CMF_INTERVAL;
6108+ else
6109+ phba->hba_flag |= HBA_SHORT_CMF;
60956110
60966111 /* If we adjust timer_interval, max_bytes_per_interval
60976112 * needs to be adjusted as well.
@@ -6337,8 +6352,10 @@ lpfc_sli4_async_fc_evt(struct lpfc_hba *phba, struct lpfc_acqe_fc_la *acqe_fc) · 239 unmodified lines
63376352 }
63386353
63396354 rc = lpfc_sli_issue_mbox(phba, pmb, MBX_NOWAIT);
6340− if (rc == MBX_NOT_FINISHED)
6355+ if (rc == MBX_NOT_FINISHED) {
6356+ lpfc_mbuf_free(phba, mp->virt, mp->phys);
63416357 goto out_free_dmabuf;
6358+ }
63426359 return;
63436360
63446361 out_free_dmabuf:
@@ -13464,7 +13481,7 @@ lpfc_init_congestion_buf(struct lpfc_hba *phba) · 7119 unmodified lines
1346413481 phba->cgn_evt_minute = 0;
1346513482 phba->hba_flag &= ~HBA_CGN_DAY_WRAP;
1346613483
13467− memset(cp, 0xff, LPFC_CGN_DATA_SIZE);
13484+ memset(cp, 0xff, offsetof(struct lpfc_cgn_info, cgn_stat));
1346813485 cp->cgn_info_size = cpu_to_le16(LPFC_CGN_INFO_SZ);
1346913486 cp->cgn_info_version = LPFC_CGN_INFO_V3;
1347013487
@@ -13523,7 +13540,7 @@ lpfc_init_congestion_stat(struct lpfc_hba *phba) · 52 unmodified lines
1352313540 return;
1352413541
1352513542 cp = (struct lpfc_cgn_info *)phba->cgn_i->virt;
13526− memset(&cp->cgn_stat_npm, 0, LPFC_CGN_STAT_SIZE);
13543+ memset(&cp->cgn_stat, 0, sizeof(cp->cgn_stat));
1352713544
1352813545 ktime_get_real_ts64(&cmpl_time);
1352913546 time64_to_tm(cmpl_time.tv_sec, 0, &broken);
drivers/scsi/lpfc/lpfc_nportdisc.c+6−0
@@ -322,6 +322,7 @@ lpfc_rcv_plogi(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, · 321 unmodified lines
322322 {
323323 struct lpfc_hba *phba = vport->phba;
324324 struct lpfc_dmabuf *pcmd;
325+ struct lpfc_dmabuf *mp;
325326 uint64_t nlp_portwwn = 0;
326327 uint32_t *lp;
327328 IOCB_t *icmd;
@@ -571,6 +572,11 @@ lpfc_rcv_plogi(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, · 243 unmodified lines
571572 * a default RPI.
572573 */
573574 if (phba->sli_rev == LPFC_SLI_REV4) {
575+ mp = (struct lpfc_dmabuf *)login_mbox->ctx_buf;
576+ if (mp) {
577+ lpfc_mbuf_free(phba, mp->virt, mp->phys);
578+ kfree(mp);
579+ }
574580 mempool_free(login_mbox, phba->mbox_mem_pool);
575581 login_mbox = NULL;
576582 } else {
drivers/scsi/lpfc/lpfc_scsi.c+5−3
@@ -4393,6 +4393,7 @@ lpfc_fcp_io_cmd_wqe_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *pwqeIn, · 4392 unmodified lines
43934393 if (lpfc_cmd->result == IOERR_INVALID_RPI ||
43944394 lpfc_cmd->result == IOERR_NO_RESOURCES ||
43954395 lpfc_cmd->result == IOERR_ABORT_REQUESTED ||
4396+ lpfc_cmd->result == IOERR_RPI_SUSPENDED ||
43964397 lpfc_cmd->result == IOERR_SLER_CMD_RCV_FAILURE) {
43974398 cmd->result = DID_REQUEUE << 16;
43984399 break;
@@ -4448,10 +4449,11 @@ lpfc_fcp_io_cmd_wqe_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *pwqeIn, · 49 unmodified lines
44484449
44494450 lpfc_printf_vlog(vport, KERN_INFO, LOG_FCP,
44504451 "9039 Iodone <%d/%llu> cmd x%px, error "
4451− "x%x SNS x%x x%x Data: x%x x%x\n",
4452+ "x%x SNS x%x x%x LBA x%llx Data: x%x x%x\n",
44524453 cmd->device->id, cmd->device->lun, cmd,
4453− cmd->result, *lp, *(lp + 3), cmd->retries,
4454− scsi_get_resid(cmd));
4454+ cmd->result, *lp, *(lp + 3),
4455+ (u64)scsi_get_lba(cmd),
4456+ cmd->retries, scsi_get_resid(cmd));
44554457 }
44564458
44574459 lpfc_update_stats(vport, lpfc_cmd);
drivers/scsi/lpfc/lpfc_sli.c+15−23
@@ -4749,7 +4749,7 @@ void lpfc_reset_barrier(struct lpfc_hba *phba) · 4748 unmodified lines
47494749 {
47504750 uint32_t __iomem *resp_buf;
47514751 uint32_t __iomem *mbox_buf;
4752− volatile uint32_t mbox;
4752+ volatile struct MAILBOX_word0 mbox;
47534753 uint32_t hc_copy, ha_copy, resp_data;
47544754 int i;
47554755 uint8_t hdrtype;
@@ -4783,13 +4783,13 @@ void lpfc_reset_barrier(struct lpfc_hba *phba) · 27 unmodified lines
47834783 phba->pport->stopped = 1;
47844784 }
47854785
4786− mbox = 0;
4787− ((MAILBOX_t *)&mbox)->mbxCommand = MBX_KILL_BOARD;
4788− ((MAILBOX_t *)&mbox)->mbxOwner = OWN_CHIP;
4786+ mbox.word0 = 0;
4787+ mbox.mbxCommand = MBX_KILL_BOARD;
4788+ mbox.mbxOwner = OWN_CHIP;
47894789
47904790 writel(BARRIER_TEST_PATTERN, (resp_buf + 1));
47914791 mbox_buf = phba->MBslimaddr;
4792− writel(mbox, mbox_buf);
4792+ writel(mbox.word0, mbox_buf);
47934793
47944794 for (i = 0; i < 50; i++) {
47954795 if (lpfc_readl((resp_buf + 1), &resp_data))
@@ -4810,12 +4810,12 @@ void lpfc_reset_barrier(struct lpfc_hba *phba) · 14 unmodified lines
48104810 goto clear_errat;
48114811 }
48124812
4813− ((MAILBOX_t *)&mbox)->mbxOwner = OWN_HOST;
4813+ mbox.mbxOwner = OWN_HOST;
48144814 resp_data = 0;
48154815 for (i = 0; i < 500; i++) {
48164816 if (lpfc_readl(resp_buf, &resp_data))
48174817 return;
4818− if (resp_data != mbox)
4818+ if (resp_data != mbox.word0)
48194819 mdelay(1);
48204820 else
48214821 break;
@@ -5046,12 +5046,6 @@ lpfc_sli4_brdreset(struct lpfc_hba *phba) · 224 unmodified lines
50465046 phba->fcf.fcf_flag = 0;
50475047 spin_unlock_irq(&phba->hbalock);
50485048
5049− /* SLI4 INTF 2: if FW dump is being taken skip INIT_PORT */
5050− if (phba->hba_flag & HBA_FW_DUMP_OP) {
5051− phba->hba_flag &= ~HBA_FW_DUMP_OP;
5052− return rc;
5053− }
5054−
50555049 /* Now physically reset the device */
50565050 lpfc_printf_log(phba, KERN_INFO, LOG_INIT,
50575051 "0389 Performing PCI function reset!\n");
@@ -5091,9 +5085,8 @@ lpfc_sli4_brdreset(struct lpfc_hba *phba) · 33 unmodified lines
50915085 static int
50925086 lpfc_sli_brdrestart_s3(struct lpfc_hba *phba)
50935087 {
5094− MAILBOX_t *mb;
5088+ volatile struct MAILBOX_word0 mb;
50955089 struct lpfc_sli *psli;
5096− volatile uint32_t word0;
50975090 void __iomem *to_slim;
50985091 uint32_t hba_aer_enabled;
50995092
@@ -5110,24 +5103,23 @@ lpfc_sli_brdrestart_s3(struct lpfc_hba *phba) · 10 unmodified lines
51105103 (phba->pport) ? phba->pport->port_state : 0,
51115104 psli->sli_flag);
51125105
5113− word0 = 0;
5114− mb = (MAILBOX_t *) &word0;
5115− mb->mbxCommand = MBX_RESTART;
5116− mb->mbxHc = 1;
5106+ mb.word0 = 0;
5107+ mb.mbxCommand = MBX_RESTART;
5108+ mb.mbxHc = 1;
51175109
51185110 lpfc_reset_barrier(phba);
51195111
51205112 to_slim = phba->MBslimaddr;
5121− writel(*(uint32_t *) mb, to_slim);
5113+ writel(mb.word0, to_slim);
51225114 readl(to_slim); /* flush */
51235115
51245116 /* Only skip post after fc_ffinit is completed */
51255117 if (phba->pport && phba->pport->port_state)
5126− word0 = 1; /* This is really setting up word1 */
5118+ mb.word0 = 1; /* This is really setting up word1 */
51275119 else
5128− word0 = 0; /* This is really setting up word1 */
5120+ mb.word0 = 0; /* This is really setting up word1 */
51295121 to_slim = phba->MBslimaddr + sizeof (uint32_t);
5130− writel(*(uint32_t *) mb, to_slim);
5122+ writel(mb.word0, to_slim);
51315123 readl(to_slim); /* flush */
51325124
51335125 lpfc_sli_brdreset(phba);
drivers/scsi/lpfc/lpfc_version.h+1−1
@@ -20,7 +20,7 @@ · 19 unmodified lines
2020 * included with this package. *
2121 *******************************************************************/
2222
23−#define LPFC_DRIVER_VERSION "14.0.0.3"
23+#define LPFC_DRIVER_VERSION "14.0.0.4"
2424 #define LPFC_DRIVER_NAME "lpfc"
2525
2626 /* Used for SLI 2/3 */
drivers/scsi/lpfc/lpfc_vport.c+63−20
@@ -485,23 +485,68 @@ error_out: · 484 unmodified lines
485485 return rc;
486486 }
487487
488+static int
489+lpfc_send_npiv_logo(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp)
490+{
491+ int rc;
492+ struct lpfc_hba *phba = vport->phba;
493+
494+ DECLARE_WAIT_QUEUE_HEAD_ONSTACK(waitq);
495+
496+ spin_lock_irq(&ndlp->lock);
497+ if (!(ndlp->save_flags & NLP_WAIT_FOR_LOGO) &&
498+ !ndlp->logo_waitq) {
499+ ndlp->logo_waitq = &waitq;
500+ ndlp->nlp_fcp_info &= ~NLP_FCP_2_DEVICE;
501+ ndlp->nlp_flag |= NLP_ISSUE_LOGO;
502+ ndlp->save_flags |= NLP_WAIT_FOR_LOGO;
503+ }
504+ spin_unlock_irq(&ndlp->lock);
505+ rc = lpfc_issue_els_npiv_logo(vport, ndlp);
506+ if (!rc) {
507+ wait_event_timeout(waitq,
508+ (!(ndlp->save_flags & NLP_WAIT_FOR_LOGO)),
509+ msecs_to_jiffies(phba->fc_ratov * 2000));
510+
511+ if (!(ndlp->save_flags & NLP_WAIT_FOR_LOGO))
512+ goto logo_cmpl;
513+ /* LOGO wait failed. Correct status. */
514+ rc = -EINTR;
515+ } else {
516+ rc = -EIO;
517+ }
518+
519+ /* Error - clean up node flags. */
520+ spin_lock_irq(&ndlp->lock);
521+ ndlp->nlp_flag &= ~NLP_ISSUE_LOGO;
522+ ndlp->save_flags &= ~NLP_WAIT_FOR_LOGO;
523+ spin_unlock_irq(&ndlp->lock);
524+
525+ logo_cmpl:
526+ lpfc_printf_vlog(vport, KERN_INFO, LOG_VPORT,
527+ "1824 Issue LOGO completes with status %d\n",
528+ rc);
529+ spin_lock_irq(&ndlp->lock);
530+ ndlp->logo_waitq = NULL;
531+ spin_unlock_irq(&ndlp->lock);
532+ return rc;
533+}
534+
488535 static int
489536 disable_vport(struct fc_vport *fc_vport)
490537 {
491538 struct lpfc_vport *vport = *(struct lpfc_vport **)fc_vport->dd_data;
492539 struct lpfc_hba *phba = vport->phba;
493540 struct lpfc_nodelist *ndlp = NULL, *next_ndlp = NULL;
494− long timeout;
495541 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
496542
543+ /* Can't disable during an outstanding delete. */
544+ if (vport->load_flag & FC_UNLOADING)
545+ return 0;
546+
497547 ndlp = lpfc_findnode_did(vport, Fabric_DID);
498− if (ndlp && phba->link_state >= LPFC_LINK_UP) {
499− vport->unreg_vpi_cmpl = VPORT_INVAL;
500− timeout = msecs_to_jiffies(phba->fc_ratov * 2000);
501− if (!lpfc_issue_els_npiv_logo(vport, ndlp))
502− while (vport->unreg_vpi_cmpl == VPORT_INVAL && timeout)
503− timeout = schedule_timeout(timeout);
504− }
548+ if (ndlp && phba->link_state >= LPFC_LINK_UP)
549+ (void)lpfc_send_npiv_logo(vport, ndlp);
505550
506551 lpfc_sli_host_down(vport);
507552
@@ -600,7 +645,7 @@ lpfc_vport_delete(struct fc_vport *fc_vport) · 92 unmodified lines
600645 struct lpfc_vport *vport = *(struct lpfc_vport **)fc_vport->dd_data;
601646 struct Scsi_Host *shost = lpfc_shost_from_vport(vport);
602647 struct lpfc_hba *phba = vport->phba;
603− long timeout;
648+ int rc;
604649
605650 if (vport->port_type == LPFC_PHYSICAL_PORT) {
606651 lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
@@ -665,15 +710,14 @@ lpfc_vport_delete(struct fc_vport *fc_vport) · 58 unmodified lines
665710 phba->fc_topology != LPFC_TOPOLOGY_LOOP) {
666711 if (vport->cfg_enable_da_id) {
667712 /* Send DA_ID and wait for a completion. */
668− timeout = msecs_to_jiffies(phba->fc_ratov * 2000);
669− if (!lpfc_ns_cmd(vport, SLI_CTNS_DA_ID, 0, 0))
670− while (vport->ct_flags && timeout)
671− timeout = schedule_timeout(timeout);
672− else
713+ rc = lpfc_ns_cmd(vport, SLI_CTNS_DA_ID, 0, 0);
714+ if (rc) {
673715 lpfc_printf_log(vport->phba, KERN_WARNING,
674716 LOG_VPORT,
675717 "1829 CT command failed to "
676− "delete objects on fabric\n");
718+ "delete objects on fabric, "
719+ "rc %d\n", rc);
720+ }
677721 }
678722
679723 /*
@@ -688,11 +732,10 @@ lpfc_vport_delete(struct fc_vport *fc_vport) · 8 unmodified lines
688732 ndlp = lpfc_findnode_did(vport, Fabric_DID);
689733 if (!ndlp)
690734 goto skip_logo;
691− vport->unreg_vpi_cmpl = VPORT_INVAL;
692− timeout = msecs_to_jiffies(phba->fc_ratov * 2000);
693− if (!lpfc_issue_els_npiv_logo(vport, ndlp))
694− while (vport->unreg_vpi_cmpl == VPORT_INVAL && timeout)
695− timeout = schedule_timeout(timeout);
735+
736+ rc = lpfc_send_npiv_logo(vport, ndlp);
737+ if (rc)
738+ goto skip_logo;
696739 }
697740
698741 if (!(phba->pport->load_flag & FC_UNLOADING))
drivers/scsi/megaraid/megaraid_mbox.c+0−1
@@ -1431,7 +1431,6 @@ mbox_post_cmd(adapter_t *adapter, scb_t *scb) · 1430 unmodified lines
14311431 /**
14321432 * megaraid_queue_command_lck - generic queue entry point for all LLDs
14331433 * @scp : pointer to the scsi command to be executed
1434− * @done : callback routine to be called after the cmd has be completed
14351434 *
14361435 * Queue entry point for mailbox based controllers.
14371436 */
drivers/scsi/mpi3mr/mpi/mpi30_cnfg.h+498−105
@@ -8,7 +8,7 @@ · 7 unmodified lines
88 #define MPI3_CONFIG_PAGETYPE_IO_UNIT (0x00)
99 #define MPI3_CONFIG_PAGETYPE_MANUFACTURING (0x01)
1010 #define MPI3_CONFIG_PAGETYPE_IOC (0x02)
11−#define MPI3_CONFIG_PAGETYPE_UEFI_BSD (0x03)
11+#define MPI3_CONFIG_PAGETYPE_DRIVER (0x03)
1212 #define MPI3_CONFIG_PAGETYPE_SECURITY (0x04)
1313 #define MPI3_CONFIG_PAGETYPE_ENCLOSURE (0x11)
1414 #define MPI3_CONFIG_PAGETYPE_DEVICE (0x12)
@@ -181,8 +181,17 @@ struct mpi3_config_page_header { · 166 unmodified lines
181181 #define MPI3_SAS_HWRATE_MIN_RATE_6_0 (0x0a)
182182 #define MPI3_SAS_HWRATE_MIN_RATE_12_0 (0x0b)
183183 #define MPI3_SAS_HWRATE_MIN_RATE_22_5 (0x0c)
184−#define MPI3_SLOT_INVALID (0xffff)
185−#define MPI3_SLOT_INDEX_INVALID (0xffff)
184+#define MPI3_SLOT_INVALID (0xffff)
185+#define MPI3_SLOT_INDEX_INVALID (0xffff)
186+#define MPI3_LINK_CHANGE_COUNT_INVALID (0xffff)
187+#define MPI3_RATE_CHANGE_COUNT_INVALID (0xffff)
188+#define MPI3_TEMP_SENSOR_LOCATION_INTERNAL (0x0)
189+#define MPI3_TEMP_SENSOR_LOCATION_INLET (0x1)
190+#define MPI3_TEMP_SENSOR_LOCATION_OUTLET (0x2)
191+#define MPI3_TEMP_SENSOR_LOCATION_DRAM (0x3)
192+#define MPI3_MFGPAGE_VENDORID_BROADCOM (0x1000)
193+#define MPI3_MFGPAGE_DEVID_SAS4116 (0x00a5)
194+#define MPI3_MFGPAGE_DEVID_SAS4016 (0x00a7)
186195 struct mpi3_man_page0 {
187196 struct mpi3_config_page_header header;
188197 u8 chip_revision[8];
@@ -195,7 +204,7 @@ struct mpi3_man_page0 { · 6 unmodified lines
195204 __le32 reserved98;
196205 u8 oem;
197206 u8 sub_oem;
198− __le16 reserved9e;
207+ __le16 flags;
199208 u8 board_mfg_day;
200209 u8 board_mfg_month;
201210 __le16 board_mfg_year;
@@ -208,6 +217,8 @@ struct mpi3_man_page0 { · 6 unmodified lines
208217 };
209218
210219 #define MPI3_MAN0_PAGEVERSION (0x00)
220+#define MPI3_MAN0_FLAGS_SWITCH_PRESENT (0x0002)
221+#define MPI3_MAN0_FLAGS_EXPANDER_PRESENT (0x0001)
211222 #define MPI3_MAN1_VPD_SIZE (512)
212223 struct mpi3_man_page1 {
213224 struct mpi3_config_page_header header;
@@ -236,7 +247,7 @@ struct mpi3_man_page5 { · 22 unmodified lines
236247 #define MPI3_MAN5_PAGEVERSION (0x00)
237248 struct mpi3_man6_gpio_entry {
238249 u8 function_code;
239− u8 reserved01;
250+ u8 function_flags;
240251 __le16 flags;
241252 u8 param1;
242253 u8 param2;
@@ -253,7 +264,6 @@ struct mpi3_man6_gpio_entry { · 10 unmodified lines
253264 #define MPI3_MAN6_GPIO_FUNCTION_PORT_STATUS_YELLOW (0x06)
254265 #define MPI3_MAN6_GPIO_FUNCTION_CABLE_MANAGEMENT (0x07)
255266 #define MPI3_MAN6_GPIO_FUNCTION_BKPLANE_MGMT_TYPE (0x08)
256−#define MPI3_MAN6_GPIO_FUNCTION_ISTWI_MUX_RESET (0x09)
257267 #define MPI3_MAN6_GPIO_FUNCTION_ISTWI_RESET (0x0a)
258268 #define MPI3_MAN6_GPIO_FUNCTION_BACKEND_PCIE_RESET (0x0b)
259269 #define MPI3_MAN6_GPIO_FUNCTION_GLOBAL_FAULT (0x0c)
@@ -263,6 +273,10 @@ struct mpi3_man6_gpio_entry { · 3 unmodified lines
263273 #define MPI3_MAN6_GPIO_FUNCTION_CTRL_TYPE (0x10)
264274 #define MPI3_MAN6_GPIO_FUNCTION_LICENSE (0x11)
265275 #define MPI3_MAN6_GPIO_FUNCTION_REFCLK_CONTROL (0x12)
276+#define MPI3_MAN6_GPIO_FUNCTION_BACKEND_PCIE_RESET_CLAMP (0x13)
277+#define MPI3_MAN6_GPIO_ISTWI_RESET_FUNCTIONFLAGS_DEVSELECT_MASK (0x01)
278+#define MPI3_MAN6_GPIO_ISTWI_RESET_FUNCTIONFLAGS_DEVSELECT_ISTWI (0x00)
279+#define MPI3_MAN6_GPIO_ISTWI_RESET_FUNCTIONFLAGS_DEVSELECT_RECEPTACLEID (0x01)
266280 #define MPI3_MAN6_GPIO_EXTINT_PARAM1_FLAGS_SOURCE_MASK (0xf0)
267281 #define MPI3_MAN6_GPIO_EXTINT_PARAM1_FLAGS_SOURCE_GENERIC (0x00)
268282 #define MPI3_MAN6_GPIO_EXTINT_PARAM1_FLAGS_SOURCE_CABLE_MGMT (0x10)
@@ -275,8 +289,6 @@ struct mpi3_man6_gpio_entry { · 6 unmodified lines
275289 #define MPI3_MAN6_GPIO_CABLE_MGMT_PARAM1_INTERFACE_MODULE_PRESENT (0x00)
276290 #define MPI3_MAN6_GPIO_CABLE_MGMT_PARAM1_INTERFACE_ACTIVE_CABLE_ENABLE (0x01)
277291 #define MPI3_MAN6_GPIO_CABLE_MGMT_PARAM1_INTERFACE_CABLE_MGMT_ENABLE (0x02)
278−#define MPI3_MAN6_GPIO_ISTWI_MUX_RESET_PARAM2_SPEC_MUX (0x00)
279−#define MPI3_MAN6_GPIO_ISTWI_MUX_RESET_PARAM2_ALL_MUXES (0x01)
280292 #define MPI3_MAN6_GPIO_LICENSE_PARAM1_TYPE_IBUTTON (0x00)
281293 #define MPI3_MAN6_GPIO_FLAGS_SLEW_RATE_MASK (0x0100)
282294 #define MPI3_MAN6_GPIO_FLAGS_SLEW_RATE_FAST_EDGE (0x0100)
@@ -353,6 +365,7 @@ struct mpi3_man8_phy_info { · 70 unmodified lines
353365 __le32 reserved0c;
354366 };
355367
368+#define MPI3_MAN8_PHY_INFO_RECEPTACLE_ID_HOST_PHY (0xff)
356369 #ifndef MPI3_MAN8_PHY_INFO_MAX
357370 #define MPI3_MAN8_PHY_INFO_MAX (1)
358371 #endif
@@ -373,20 +386,22 @@ struct mpi3_man9_rsrc_entry { · 14 unmodified lines
373386 };
374387
375388 enum mpi3_man9_resources {
376− MPI3_MAN9_RSRC_OUTSTANDING_REQS = 0,
377− MPI3_MAN9_RSRC_TARGET_CMDS = 1,
378− MPI3_MAN9_RSRC_SAS_TARGETS = 2,
379− MPI3_MAN9_RSRC_PCIE_TARGETS = 3,
380− MPI3_MAN9_RSRC_INITIATORS = 4,
381− MPI3_MAN9_RSRC_VDS = 5,
382− MPI3_MAN9_RSRC_ENCLOSURES = 6,
383− MPI3_MAN9_RSRC_ENCLOSURE_PHYS = 7,
384− MPI3_MAN9_RSRC_EXPANDERS = 8,
385− MPI3_MAN9_RSRC_PCIE_SWITCHES = 9,
386− MPI3_MAN9_RSRC_PDS = 10,
387− MPI3_MAN9_RSRC_HOST_PDS = 11,
388− MPI3_MAN9_RSRC_ADV_HOST_PDS = 12,
389− MPI3_MAN9_RSRC_RAID_PDS = 13,
389+ MPI3_MAN9_RSRC_OUTSTANDING_REQS = 0,
390+ MPI3_MAN9_RSRC_TARGET_CMDS = 1,
391+ MPI3_MAN9_RSRC_RESERVED02 = 2,
392+ MPI3_MAN9_RSRC_NVME = 3,
393+ MPI3_MAN9_RSRC_INITIATORS = 4,
394+ MPI3_MAN9_RSRC_VDS = 5,
395+ MPI3_MAN9_RSRC_ENCLOSURES = 6,
396+ MPI3_MAN9_RSRC_ENCLOSURE_PHYS = 7,
397+ MPI3_MAN9_RSRC_EXPANDERS = 8,
398+ MPI3_MAN9_RSRC_PCIE_SWITCHES = 9,
399+ MPI3_MAN9_RSRC_RESERVED10 = 10,
400+ MPI3_MAN9_RSRC_HOST_PD_DRIVES = 11,
401+ MPI3_MAN9_RSRC_ADV_HOST_PD_DRIVES = 12,
402+ MPI3_MAN9_RSRC_RAID_PD_DRIVES = 13,
403+ MPI3_MAN9_RSRC_DRV_DIAG_BUF = 14,
404+ MPI3_MAN9_RSRC_NAMESPACE_COUNT = 15,
390405 MPI3_MAN9_RSRC_NUM_RESOURCES
391406 };
392407
@@ -402,6 +417,7 @@ enum mpi3_man9_resources { · 9 unmodified lines
402417 #define MPI3_MAN9_MIN_ENCLOSURES (0)
403418 #define MPI3_MAN9_MAX_ENCLOSURES (65535)
404419 #define MPI3_MAN9_MIN_ENCLOSURE_PHYS (0)
420+#define MPI3_MAN9_MIN_NAMESPACE_COUNT (1)
405421 #define MPI3_MAN9_MIN_EXPANDERS (0)
406422 #define MPI3_MAN9_MAX_EXPANDERS (65535)
407423 #define MPI3_MAN9_MIN_PCIE_SWITCHES (0)
@@ -422,9 +438,14 @@ struct mpi3_man_page9 { · 14 unmodified lines
422438 struct mpi3_man10_istwi_ctrlr_entry {
423439 __le16 slave_address;
424440 __le16 flags;
425− __le32 reserved04;
441+ u8 scl_low_override;
442+ u8 scl_high_override;
443+ __le16 reserved06;
426444 };
427445
446+#define MPI3_MAN10_ISTWI_CTRLR_FLAGS_BUS_SPEED_MASK (0x000c)
447+#define MPI3_MAN10_ISTWI_CTRLR_FLAGS_BUS_SPEED_100K (0x0000)
448+#define MPI3_MAN10_ISTWI_CTRLR_FLAGS_BUS_SPEED_400K (0x0004)
428449 #define MPI3_MAN10_ISTWI_CTRLR_FLAGS_SLAVE_ENABLED (0x0002)
429450 #define MPI3_MAN10_ISTWI_CTRLR_FLAGS_MASTER_ENABLED (0x0001)
430451 #ifndef MPI3_MAN10_ISTWI_CTRLR_MAX
@@ -451,10 +472,13 @@ struct mpi3_man11_temp_sensor_device_format { · 20 unmodified lines
451472 u8 temp_channel[4];
452473 };
453474
454−#define MPI3_MAN11_TEMP_SENSOR_TYPE_MAX6654 (0x00)
455−#define MPI3_MAN11_TEMP_SENSOR_TYPE_EMC1442 (0x01)
456−#define MPI3_MAN11_TEMP_SENSOR_TYPE_ADT7476 (0x02)
457−#define MPI3_MAN11_TEMP_SENSOR_CHANNEL_ENABLED (0x01)
475+#define MPI3_MAN11_TEMP_SENSOR_TYPE_MAX6654 (0x00)
476+#define MPI3_MAN11_TEMP_SENSOR_TYPE_EMC1442 (0x01)
477+#define MPI3_MAN11_TEMP_SENSOR_TYPE_ADT7476 (0x02)
478+#define MPI3_MAN11_TEMP_SENSOR_TYPE_SE97B (0x03)
479+#define MPI3_MAN11_TEMP_SENSOR_CHANNEL_LOCATION_MASK (0xe0)
480+#define MPI3_MAN11_TEMP_SENSOR_CHANNEL_LOCATION_SHIFT (5)
481+#define MPI3_MAN11_TEMP_SENSOR_CHANNEL_ENABLED (0x01)
458482 struct mpi3_man11_seeprom_device_format {
459483 u8 size;
460484 u8 page_write_size;
@@ -495,31 +519,40 @@ struct mpi3_man11_bkplane_spec_ubm_format { · 34 unmodified lines
495519 #define MPI3_MAN11_BKPLANE_UBM_FLAGS_MAX_FRU_SHIFT (4)
496520 #define MPI3_MAN11_BKPLANE_UBM_FLAGS_POLL_INTERVAL_MASK (0x000f)
497521 #define MPI3_MAN11_BKPLANE_UBM_FLAGS_POLL_INTERVAL_SHIFT (0)
498−struct mpi3_man11_bkplane_spec_vpp_format {
522+struct mpi3_man11_bkplane_spec_non_ubm_format {
499523 __le16 flags;
500− __le16 reserved02;
524+ u8 reserved02;
525+ u8 type;
501526 };
502527
503−#define MPI3_MAN11_BKPLANE_VPP_FLAGS_REFCLK_POLICY_ALWAYS_ENABLED (0x0040)
504−#define MPI3_MAN11_BKPLANE_VPP_FLAGS_PRESENCE_DETECT_MASK (0x0030)
505−#define MPI3_MAN11_BKPLANE_VPP_FLAGS_PRESENCE_DETECT_GPIO (0x0000)
506−#define MPI3_MAN11_BKPLANE_VPP_FLAGS_PRESENCE_DETECT_REG (0x0010)
507−#define MPI3_MAN11_BKPLANE_VPP_FLAGS_POLL_INTERVAL_MASK (0x000f)
508−#define MPI3_MAN11_BKPLANE_VPP_FLAGS_POLL_INTERVAL_SHIFT (0)
528+#define MPI3_MAN11_BKPLANE_NON_UBM_FLAGS_GROUP_MASK (0xf000)
529+#define MPI3_MAN11_BKPLANE_NON_UBM_FLAGS_GROUP_SHIFT (12)
530+#define MPI3_MAN11_BKPLANE_NON_UBM_FLAGS_REFCLK_POLICY_ALWAYS_ENABLED (0x0200)
531+#define MPI3_MAN11_BKPLANE_NON_UBM_FLAGS_PRESENCE_DETECT_MASK (0x0030)
532+#define MPI3_MAN11_BKPLANE_NON_UBM_FLAGS_PRESENCE_DETECT_GPIO (0x0000)
533+#define MPI3_MAN11_BKPLANE_NON_UBM_FLAGS_PRESENCE_DETECT_REG (0x0010)
534+#define MPI3_MAN11_BKPLANE_NON_UBM_FLAGS_POLL_INTERVAL_MASK (0x000f)
535+#define MPI3_MAN11_BKPLANE_NON_UBM_FLAGS_POLL_INTERVAL_SHIFT (0)
536+#define MPI3_MAN11_BKPLANE_NON_UBM_TYPE_VPP (0x00)
509537 union mpi3_man11_bkplane_spec_format {
510− struct mpi3_man11_bkplane_spec_ubm_format ubm;
511− struct mpi3_man11_bkplane_spec_vpp_format vpp;
538+ struct mpi3_man11_bkplane_spec_ubm_format ubm;
539+ struct mpi3_man11_bkplane_spec_non_ubm_format non_ubm;
512540 };
513541
514542 struct mpi3_man11_bkplane_mgmt_device_format {
515543 u8 type;
516544 u8 receptacle_id;
517− __le16 reserved02;
545+ u8 reset_info;
546+ u8 reserved03;
518547 union mpi3_man11_bkplane_spec_format backplane_mgmt_specific;
519548 };
520549
521550 #define MPI3_MAN11_BKPLANE_MGMT_TYPE_UBM (0x00)
522−#define MPI3_MAN11_BKPLANE_MGMT_TYPE_VPP (0x01)
551+#define MPI3_MAN11_BKPLANE_MGMT_TYPE_NON_UBM (0x01)
552+#define MPI3_MAN11_BACKPLANE_RESETINFO_ASSERT_TIME_MASK (0xf0)
553+#define MPI3_MAN11_BACKPLANE_RESETINFO_ASSERT_TIME_SHIFT (4)
554+#define MPI3_MAN11_BACKPLANE_RESETINFO_READY_TIME_MASK (0x0f)
555+#define MPI3_MAN11_BACKPLANE_RESETINFO_READY_TIME_SHIFT (0)
523556 struct mpi3_man11_gas_gauge_device_format {
524557 u8 type;
525558 u8 reserved01[3];
@@ -527,6 +560,11 @@ struct mpi3_man11_gas_gauge_device_format { · 1 unmodified line
527560 };
528561
529562 #define MPI3_MAN11_GAS_GAUGE_TYPE_STANDARD (0x00)
563+struct mpi3_man11_mgmt_ctrlr_device_format {
564+ __le32 reserved00;
565+ __le32 reserved04;
566+};
567+
530568 union mpi3_man11_device_specific_format {
531569 struct mpi3_man11_mux_device_format mux;
532570 struct mpi3_man11_temp_sensor_device_format temp_sensor;
@@ -535,6 +573,7 @@ union mpi3_man11_device_specific_format { · 2 unmodified lines
535573 struct mpi3_man11_cable_mgmt_device_format cable_mgmt;
536574 struct mpi3_man11_bkplane_mgmt_device_format bkplane_mgmt;
537575 struct mpi3_man11_gas_gauge_device_format gas_gauge;
576+ struct mpi3_man11_mgmt_ctrlr_device_format mgmt_controller;
538577 __le32 words[2];
539578 };
540579
@@ -556,10 +595,8 @@ struct mpi3_man11_istwi_device_format { · 15 unmodified lines
556595 #define MPI3_MAN11_ISTWI_DEVTYPE_CABLE_MGMT (0x04)
557596 #define MPI3_MAN11_ISTWI_DEVTYPE_BACKPLANE_MGMT (0x05)
558597 #define MPI3_MAN11_ISTWI_DEVTYPE_GAS_GAUGE (0x06)
598+#define MPI3_MAN11_ISTWI_DEVTYPE_MGMT_CONTROLLER (0x07)
559599 #define MPI3_MAN11_ISTWI_FLAGS_MUX_PRESENT (0x01)
560−#define MPI3_MAN11_ISTWI_FLAGS_BUS_SPEED_MASK (0x06)
561−#define MPI3_MAN11_ISTWI_FLAGS_BUS_SPEED_100KHZ (0x00)
562−#define MPI3_MAN11_ISTWI_FLAGS_BUS_SPEED_400KHZ (0x02)
563600 #ifndef MPI3_MAN11_ISTWI_DEVICE_MAX
564601 #define MPI3_MAN11_ISTWI_DEVICE_MAX (1)
565602 #endif
@@ -692,8 +729,8 @@ struct mpi3_man_page14 { · 126 unmodified lines
692729 #define MPI3_MAN14_FLAGS_AUTH_SESSION_REQ (0x01)
693730 #define MPI3_MAN14_FLAGS_AUTH_API_MASK (0x0e)
694731 #define MPI3_MAN14_FLAGS_AUTH_API_NONE (0x00)
695−#define MPI3_MAN14_FLAGS_AUTH_API_CEREBUS (0x02)
696−#define MPI3_MAN14_FLAGS_AUTH_API_DMTF_PMCI (0x04)
732+#define MPI3_MAN14_FLAGS_AUTH_API_CERBERUS (0x02)
733+#define MPI3_MAN14_FLAGS_AUTH_API_SPDM (0x04)
697734 #ifndef MPI3_MAN15_VERSION_RECORD_MAX
698735 #define MPI3_MAN15_VERSION_RECORD_MAX 1
699736 #endif
@@ -808,7 +845,7 @@ struct mpi3_io_unit_page1 { · 108 unmodified lines
808845 struct mpi3_config_page_header header;
809846 __le32 flags;
810847 u8 dmd_io_delay;
811− u8 dmd_report_pc_ie;
848+ u8 dmd_report_pcie;
812849 u8 dmd_report_sata;
813850 u8 dmd_report_sas;
814851 };
@@ -844,26 +881,30 @@ struct mpi3_io_unit_page2 { · 29 unmodified lines
844881 #define MPI3_IOUNIT2_GPIO_SETTING_ON (0x0001)
845882 struct mpi3_io_unit3_sensor {
846883 __le16 flags;
847− __le16 reserved02;
848− __le16 threshold[4];
884+ u8 threshold_margin;
885+ u8 reserved03;
886+ __le16 threshold[3];
887+ __le16 reserved0a;
849888 __le32 reserved0c;
850889 __le32 reserved10;
851890 __le32 reserved14;
852891 };
853892
854−#define MPI3_IOUNIT3_SENSOR_FLAGS_T3_ENABLE (0x0008)
855−#define MPI3_IOUNIT3_SENSOR_FLAGS_T2_ENABLE (0x0004)
856−#define MPI3_IOUNIT3_SENSOR_FLAGS_T1_ENABLE (0x0002)
857−#define MPI3_IOUNIT3_SENSOR_FLAGS_T0_ENABLE (0x0001)
893+#define MPI3_IOUNIT3_SENSOR_FLAGS_FATAL_EVENT_ENABLED (0x0010)
894+#define MPI3_IOUNIT3_SENSOR_FLAGS_FATAL_ACTION_ENABLED (0x0008)
895+#define MPI3_IOUNIT3_SENSOR_FLAGS_CRITICAL_EVENT_ENABLED (0x0004)
896+#define MPI3_IOUNIT3_SENSOR_FLAGS_CRITICAL_ACTION_ENABLED (0x0002)
897+#define MPI3_IOUNIT3_SENSOR_FLAGS_WARNING_EVENT_ENABLED (0x0001)
858898 #ifndef MPI3_IO_UNIT3_SENSOR_MAX
859−#define MPI3_IO_UNIT3_SENSOR_MAX (1)
899+#define MPI3_IO_UNIT3_SENSOR_MAX (1)
860900 #endif
861901 struct mpi3_io_unit_page3 {
862902 struct mpi3_config_page_header header;
863903 __le32 reserved08;
864904 u8 num_sensors;
865− u8 polling_interval;
866− __le16 reserved0e;
905+ u8 nominal_poll_interval;
906+ u8 warning_poll_interval;
907+ u8 reserved0f;
867908 struct mpi3_io_unit3_sensor sensor[MPI3_IO_UNIT3_SENSOR_MAX];
868909 };
869910
@@ -873,13 +914,19 @@ struct mpi3_io_unit4_sensor { · 3 unmodified lines
873914 __le16 reserved02;
874915 u8 flags;
875916 u8 reserved05[3];
876− __le32 reserved08;
917+ __le16 istwi_index;
918+ u8 channel;
919+ u8 reserved0b;
877920 __le32 reserved0c;
878921 };
879922
923+#define MPI3_IOUNIT4_SENSOR_FLAGS_LOC_MASK (0xe0)
924+#define MPI3_IOUNIT4_SENSOR_FLAGS_LOC_SHIFT (5)
880925 #define MPI3_IOUNIT4_SENSOR_FLAGS_TEMP_VALID (0x01)
926+#define MPI3_IOUNIT4_SENSOR_ISTWI_INDEX_INTERNAL (0xffff)
927+#define MPI3_IOUNIT4_SENSOR_CHANNEL_RESERVED (0xff)
881928 #ifndef MPI3_IO_UNIT4_SENSOR_MAX
882−#define MPI3_IO_UNIT4_SENSOR_MAX (1)
929+#define MPI3_IO_UNIT4_SENSOR_MAX (1)
883930 #endif
884931 struct mpi3_io_unit_page4 {
885932 struct mpi3_config_page_header header;
@@ -906,8 +953,9 @@ struct mpi3_io_unit_page5 { · 20 unmodified lines
906953 struct mpi3_io_unit5_spinup_group spinup_group_parameters[4];
907954 __le32 reserved18;
908955 __le32 reserved1c;
909− __le32 reserved20;
910− u8 reserved24;
956+ __le16 device_shutdown;
957+ __le16 reserved22;
958+ u8 pcie_device_wait_time;
911959 u8 sata_device_wait_time;
912960 u8 spinup_encl_drive_count;
913961 u8 spinup_encl_delay;
@@ -919,6 +967,22 @@ struct mpi3_io_unit_page5 { · 5 unmodified lines
919967 };
920968
921969 #define MPI3_IOUNIT5_PAGEVERSION (0x00)
970+#define MPI3_IOUNIT5_DEVICE_SHUTDOWN_NO_ACTION (0x00)
971+#define MPI3_IOUNIT5_DEVICE_SHUTDOWN_DIRECT_ATTACHED (0x01)
972+#define MPI3_IOUNIT5_DEVICE_SHUTDOWN_EXPANDER_ATTACHED (0x02)
973+#define MPI3_IOUNIT5_DEVICE_SHUTDOWN_SWITCH_ATTACHED (0x02)
974+#define MPI3_IOUNIT5_DEVICE_SHUTDOWN_DIRECT_AND_EXPANDER (0x03)
975+#define MPI3_IOUNIT5_DEVICE_SHUTDOWN_DIRECT_AND_SWITCH (0x03)
976+#define MPI3_IOUNIT5_DEVICE_SHUTDOWN_SATA_HDD_MASK (0x0300)
977+#define MPI3_IOUNIT5_DEVICE_SHUTDOWN_SATA_HDD_SHIFT (8)
978+#define MPI3_IOUNIT5_DEVICE_SHUTDOWN_SAS_HDD_MASK (0x00c0)
979+#define MPI3_IOUNIT5_DEVICE_SHUTDOWN_SAS_HDD_SHIFT (6)
980+#define MPI3_IOUNIT5_DEVICE_SHUTDOWN_NVME_SSD_MASK (0x0030)
981+#define MPI3_IOUNIT5_DEVICE_SHUTDOWN_NVME_SSD_SHIFT (4)
982+#define MPI3_IOUNIT5_DEVICE_SHUTDOWN_SATA_SSD_MASK (0x000c)
983+#define MPI3_IOUNIT5_DEVICE_SHUTDOWN_SATA_SSD_SHIFT (2)
984+#define MPI3_IOUNIT5_DEVICE_SHUTDOWN_SAS_SSD_MASK (0x0003)
985+#define MPI3_IOUNIT5_DEVICE_SHUTDOWN_SAA_SSD_SHIFT (0)
922986 #define MPI3_IOUNIT5_FLAGS_POWER_CAPABLE_SPINUP (0x02)
923987 #define MPI3_IOUNIT5_FLAGS_AUTO_PORT_ENABLE (0x01)
924988 #define MPI3_IOUNIT5_PHY_SPINUP_GROUP_MASK (0x03)
@@ -1012,7 +1076,52 @@ struct mpi3_ioc_page2 { · 87 unmodified lines
10121076 };
10131077
10141078 #define MPI3_IOC2_PAGEVERSION (0x00)
1015−struct mpi3_uefibsd_page0 {
1079+#define MPI3_DRIVER_FLAGS_ADMINRAIDPD_BLOCKED (0x0010)
1080+#define MPI3_DRIVER_FLAGS_OOBRAIDPD_BLOCKED (0x0008)
1081+#define MPI3_DRIVER_FLAGS_OOBRAIDVD_BLOCKED (0x0004)
1082+#define MPI3_DRIVER_FLAGS_OOBADVHOSTPD_BLOCKED (0x0002)
1083+#define MPI3_DRIVER_FLAGS_OOBHOSTPD_BLOCKED (0x0001)
1084+struct mpi3_allowed_cmd_scsi {
1085+ __le16 service_action;
1086+ u8 operation_code;
1087+ u8 command_flags;
1088+};
1089+
1090+struct mpi3_allowed_cmd_ata {
1091+ u8 subcommand;
1092+ u8 reserved01;
1093+ u8 command;
1094+ u8 command_flags;
1095+};
1096+
1097+struct mpi3_allowed_cmd_nvme {
1098+ u8 reserved00;
1099+ u8 nvme_cmd_flags;
1100+ u8 op_code;
1101+ u8 command_flags;
1102+};
1103+
1104+#define MPI3_DRIVER_ALLOWEDCMD_NVMECMDFLAGS_SUBQ_TYPE_MASK (0x80)
1105+#define MPI3_DRIVER_ALLOWEDCMD_NVMECMDFLAGS_SUBQ_TYPE_IO (0x00)
1106+#define MPI3_DRIVER_ALLOWEDCMD_NVMECMDFLAGS_SUBQ_TYPE_ADMIN (0x80)
1107+#define MPI3_DRIVER_ALLOWEDCMD_NVMECMDFLAGS_CMDSET_MASK (0x3f)
1108+#define MPI3_DRIVER_ALLOWEDCMD_NVMECMDFLAGS_CMDSET_NVM (0x00)
1109+union mpi3_allowed_cmd {
1110+ struct mpi3_allowed_cmd_scsi scsi;
1111+ struct mpi3_allowed_cmd_ata ata;
1112+ struct mpi3_allowed_cmd_nvme nvme;
1113+};
1114+
1115+#define MPI3_DRIVER_ALLOWEDCMD_CMDFLAGS_ADMINRAIDPD_BLOCKED (0x20)
1116+#define MPI3_DRIVER_ALLOWEDCMD_CMDFLAGS_OOBRAIDPD_BLOCKED (0x10)
1117+#define MPI3_DRIVER_ALLOWEDCMD_CMDFLAGS_OOBRAIDVD_BLOCKED (0x08)
1118+#define MPI3_DRIVER_ALLOWEDCMD_CMDFLAGS_OOBADVHOSTPD_BLOCKED (0x04)
1119+#define MPI3_DRIVER_ALLOWEDCMD_CMDFLAGS_OOBHOSTPD_BLOCKED (0x02)
1120+#define MPI3_DRIVER_ALLOWEDCMD_CMDFLAGS_CHECKSUBCMD_ENABLED (0x01)
1121+#ifndef MPI3_ALLOWED_CMDS_MAX
1122+#define MPI3_ALLOWED_CMDS_MAX (1)
1123+#endif
1124+struct mpi3_driver_page0 {
10161125 struct mpi3_config_page_header header;
10171126 __le32 bsd_options;
10181127 u8 ssu_timeout;
@@ -1026,13 +1135,122 @@ struct mpi3_uefibsd_page0 { · 7 unmodified lines
10261135 __le32 reserved18;
10271136 };
10281137
1029−#define MPI3_UEFIBSD_PAGEVERSION (0x00)
1030−#define MPI3_UEFIBSD_BSDOPTS_REGISTRATION_MASK (0x00000003)
1031−#define MPI3_UEFIBSD_BSDOPTS_REGISTRATION_IOC_AND_DEVS (0x00000000)
1032−#define MPI3_UEFIBSD_BSDOPTS_REGISTRATION_IOC_ONLY (0x00000001)
1033−#define MPI3_UEFIBSD_BSDOPTS_REGISTRATION_NONE (0x00000002)
1034−#define MPI3_UEFIBSD_BSDOPTS_DIS_HII_CONFIG_UTIL (0x00000004)
1035−#define MPI3_UEFIBSD_BSDOPTS_EN_ADV_ADAPTER_CONFIG (0x00000008)
1138+#define MPI3_DRIVER0_PAGEVERSION (0x00)
1139+#define MPI3_DRIVER0_BSDOPTS_REGISTRATION_MASK (0x00000003)
1140+#define MPI3_DRIVER0_BSDOPTS_REGISTRATION_IOC_AND_DEVS (0x00000000)
1141+#define MPI3_DRIVER0_BSDOPTS_REGISTRATION_IOC_ONLY (0x00000001)
1142+#define MPI3_DRIVER0_BSDOPTS_DIS_HII_CONFIG_UTIL (0x00000004)
1143+#define MPI3_DRIVER0_BSDOPTS_EN_ADV_ADAPTER_CONFIG (0x00000008)
1144+struct mpi3_driver_page1 {
1145+ struct mpi3_config_page_header header;
1146+ __le32 flags;
1147+ __le32 reserved0c;
1148+ __le16 host_diag_trace_max_size;
1149+ __le16 host_diag_trace_min_size;
1150+ __le16 host_diag_trace_decrement_size;
1151+ __le16 reserved16;
1152+ __le16 host_diag_fw_max_size;
1153+ __le16 host_diag_fw_min_size;
1154+ __le16 host_diag_fw_decrement_size;
1155+ __le16 reserved1e;
1156+ __le16 host_diag_driver_max_size;
1157+ __le16 host_diag_driver_min_size;
1158+ __le16 host_diag_driver_decrement_size;
1159+ __le16 reserved26;
1160+};
1161+
1162+#define MPI3_DRIVER1_PAGEVERSION (0x00)
1163+#ifndef MPI3_DRIVER2_TRIGGER_MAX
1164+#define MPI3_DRIVER2_TRIGGER_MAX (1)
1165+#endif
1166+struct mpi3_driver2_trigger_event {
1167+ u8 type;
1168+ u8 flags;
1169+ u8 reserved02;
1170+ u8 event;
1171+ __le32 reserved04[3];
1172+};
1173+
1174+struct mpi3_driver2_trigger_scsi_sense {
1175+ u8 type;
1176+ u8 flags;
1177+ __le16 reserved02;
1178+ u8 ascq;
1179+ u8 asc;
1180+ u8 sense_key;
1181+ u8 reserved07;
1182+ __le32 reserved08[2];
1183+};
1184+
1185+#define MPI3_DRIVER2_TRIGGER_SCSI_SENSE_ASCQ_MATCH_ALL (0xff)
1186+#define MPI3_DRIVER2_TRIGGER_SCSI_SENSE_ASC_MATCH_ALL (0xff)
1187+#define MPI3_DRIVER2_TRIGGER_SCSI_SENSE_SENSE_KEY_MATCH_ALL (0xff)
1188+struct mpi3_driver2_trigger_reply {
1189+ u8 type;
1190+ u8 flags;
1191+ __le16 ioc_status;
1192+ __le32 ioc_log_info;
1193+ __le32 ioc_log_info_mask;
1194+ __le32 reserved0c;
1195+};
1196+
1197+#define MPI3_DRIVER2_TRIGGER_REPLY_IOCSTATUS_MATCH_ALL (0xffff)
1198+union mpi3_driver2_trigger_element {
1199+ struct mpi3_driver2_trigger_event event;
1200+ struct mpi3_driver2_trigger_scsi_sense scsi_sense;
1201+ struct mpi3_driver2_trigger_reply reply;
1202+};
1203+
1204+#define MPI3_DRIVER2_TRIGGER_TYPE_EVENT (0x00)
1205+#define MPI3_DRIVER2_TRIGGER_TYPE_SCSI_SENSE (0x01)
1206+#define MPI3_DRIVER2_TRIGGER_TYPE_REPLY (0x02)
1207+#define MPI3_DRIVER2_TRIGGER_FLAGS_DIAG_TRACE_RELEASE (0x02)
1208+#define MPI3_DRIVER2_TRIGGER_FLAGS_DIAG_FW_RELEASE (0x01)
1209+struct mpi3_driver_page2 {
1210+ struct mpi3_config_page_header header;
1211+ __le64 master_trigger;
1212+ __le32 reserved10[3];
1213+ u8 num_triggers;
1214+ u8 reserved1d[3];
1215+ union mpi3_driver2_trigger_element trigger[MPI3_DRIVER2_TRIGGER_MAX];
1216+};
1217+
1218+#define MPI3_DRIVER2_PAGEVERSION (0x00)
1219+#define MPI3_DRIVER2_MASTERTRIGGER_DIAG_TRACE_RELEASE (0x8000000000000000ULL)
1220+#define MPI3_DRIVER2_MASTERTRIGGER_DIAG_FW_RELEASE (0x4000000000000000ULL)
1221+#define MPI3_DRIVER2_MASTERTRIGGER_SNAPDUMP (0x2000000000000000ULL)
1222+#define MPI3_DRIVER2_MASTERTRIGGER_DEVICE_REMOVAL_ENABLED (0x0000000000000004ULL)
1223+#define MPI3_DRIVER2_MASTERTRIGGER_TASK_MANAGEMENT_ENABLED (0x0000000000000002ULL)
1224+struct mpi3_driver_page10 {
1225+ struct mpi3_config_page_header header;
1226+ __le16 flags;
1227+ __le16 reserved0a;
1228+ u8 num_allowed_commands;
1229+ u8 reserved0d[3];
1230+ union mpi3_allowed_cmd allowed_command[MPI3_ALLOWED_CMDS_MAX];
1231+};
1232+
1233+#define MPI3_DRIVER10_PAGEVERSION (0x00)
1234+struct mpi3_driver_page20 {
1235+ struct mpi3_config_page_header header;
1236+ __le16 flags;
1237+ __le16 reserved0a;
1238+ u8 num_allowed_commands;
1239+ u8 reserved0d[3];
1240+ union mpi3_allowed_cmd allowed_command[MPI3_ALLOWED_CMDS_MAX];
1241+};
1242+
1243+#define MPI3_DRIVER20_PAGEVERSION (0x00)
1244+struct mpi3_driver_page30 {
1245+ struct mpi3_config_page_header header;
1246+ __le16 flags;
1247+ __le16 reserved0a;
1248+ u8 num_allowed_commands;
1249+ u8 reserved0d[3];
1250+ union mpi3_allowed_cmd allowed_command[MPI3_ALLOWED_CMDS_MAX];
1251+};
1252+
1253+#define MPI3_DRIVER30_PAGEVERSION (0x00)
10361254 union mpi3_security_mac {
10371255 __le32 dword[16];
10381256 __le16 word[32];
@@ -1102,7 +1320,7 @@ struct mpi3_security1_key_record { · 63 unmodified lines
11021320 #define MPI3_SECURITY1_KEY_RECORD_CONSUMER_NOT_VALID (0x00)
11031321 #define MPI3_SECURITY1_KEY_RECORD_CONSUMER_SAFESTORE (0x01)
11041322 #define MPI3_SECURITY1_KEY_RECORD_CONSUMER_CERT_CHAIN (0x02)
1105−#define MPI3_SECURITY1_KEY_RECORD_CONSUMER_AUTH_DEV_KEY (0x03)
1323+#define MPI3_SECURITY1_KEY_RECORD_CONSUMER_DEVICE_KEY (0x03)
11061324 #define MPI3_SECURITY1_KEY_RECORD_CONSUMER_CACHE_OFFLOAD (0x04)
11071325 struct mpi3_security_page1 {
11081326 struct mpi3_config_page_header header;
@@ -1137,16 +1355,30 @@ struct mpi3_sas_io_unit_page0 { · 28 unmodified lines
11371355 struct mpi3_config_page_header header;
11381356 __le32 reserved08;
11391357 u8 num_phys;
1140− u8 reserved0d[3];
1358+ u8 init_status;
1359+ __le16 reserved0e;
11411360 struct mpi3_sas_io_unit0_phy_data phy_data[MPI3_SAS_IO_UNIT0_PHY_MAX];
11421361 };
11431362
1144−#define MPI3_SASIOUNIT0_PAGEVERSION (0x00)
1145−#define MPI3_SASIOUNIT0_PORTFLAGS_DISC_IN_PROGRESS (0x08)
1146−#define MPI3_SASIOUNIT0_PORTFLAGS_AUTO_PORT_CONFIG (0x01)
1147−#define MPI3_SASIOUNIT0_PHYFLAGS_INIT_PERSIST_CONNECT (0x40)
1148−#define MPI3_SASIOUNIT0_PHYFLAGS_TARG_PERSIST_CONNECT (0x20)
1149−#define MPI3_SASIOUNIT0_PHYFLAGS_PHY_DISABLED (0x08)
1363+#define MPI3_SASIOUNIT0_PAGEVERSION (0x00)
1364+#define MPI3_SASIOUNIT0_INITSTATUS_NO_ERRORS (0x00)
1365+#define MPI3_SASIOUNIT0_INITSTATUS_NEEDS_INITIALIZATION (0x01)
1366+#define MPI3_SASIOUNIT0_INITSTATUS_NO_TARGETS_ALLOCATED (0x02)
1367+#define MPI3_SASIOUNIT0_INITSTATUS_BAD_NUM_PHYS (0x04)
1368+#define MPI3_SASIOUNIT0_INITSTATUS_UNSUPPORTED_CONFIG (0x05)
1369+#define MPI3_SASIOUNIT0_INITSTATUS_HOST_PHYS_ENABLED (0x06)
1370+#define MPI3_SASIOUNIT0_INITSTATUS_PRODUCT_SPECIFIC_MIN (0xf0)
1371+#define MPI3_SASIOUNIT0_INITSTATUS_PRODUCT_SPECIFIC_MAX (0xff)
1372+#define MPI3_SASIOUNIT0_PORTFLAGS_DISC_IN_PROGRESS (0x08)
1373+#define MPI3_SASIOUNIT0_PORTFLAGS_AUTO_PORT_CONFIG_MASK (0x03)
1374+#define MPI3_SASIOUNIT0_PORTFLAGS_AUTO_PORT_CONFIG_IOUNIT1 (0x00)
1375+#define MPI3_SASIOUNIT0_PORTFLAGS_AUTO_PORT_CONFIG_DYNAMIC (0x01)
1376+#define MPI3_SASIOUNIT0_PORTFLAGS_AUTO_PORT_CONFIG_BACKPLANE (0x02)
1377+#define MPI3_SASIOUNIT0_PHYFLAGS_INIT_PERSIST_CONNECT (0x40)
1378+#define MPI3_SASIOUNIT0_PHYFLAGS_TARG_PERSIST_CONNECT (0x20)
1379+#define MPI3_SASIOUNIT0_PHYFLAGS_PHY_DISABLED (0x08)
1380+#define MPI3_SASIOUNIT0_PHYFLAGS_VIRTUAL_PHY (0x02)
1381+#define MPI3_SASIOUNIT0_PHYFLAGS_HOST_PHY (0x01)
11501382 struct mpi3_sas_io_unit1_phy_data {
11511383 u8 io_unit_port;
11521384 u8 port_flags;
@@ -1343,6 +1575,26 @@ struct mpi3_sas_expander_page1 { · 190 unmodified lines
13431575 #define MPI3_SASEXPANDER1_DISCINFO_BAD_PHY_DISABLED (0x04)
13441576 #define MPI3_SASEXPANDER1_DISCINFO_LINK_STATUS_CHANGE (0x02)
13451577 #define MPI3_SASEXPANDER1_DISCINFO_NO_ROUTING_ENTRIES (0x01)
1578+#ifndef MPI3_SASEXPANDER2_MAX_NUM_PHYS
1579+#define MPI3_SASEXPANDER2_MAX_NUM_PHYS (1)
1580+#endif
1581+struct mpi3_sasexpander2_phy_element {
1582+ u8 link_change_count;
1583+ u8 reserved01;
1584+ __le16 rate_change_count;
1585+ __le32 reserved04;
1586+};
1587+
1588+struct mpi3_sas_expander_page2 {
1589+ struct mpi3_config_page_header header;
1590+ u8 num_phys;
1591+ u8 reserved09;
1592+ __le16 dev_handle;
1593+ __le32 reserved0c;
1594+ struct mpi3_sasexpander2_phy_element phy[MPI3_SASEXPANDER2_MAX_NUM_PHYS];
1595+};
1596+
1597+#define MPI3_SASEXPANDER2_PAGEVERSION (0x00)
13461598 struct mpi3_sas_port_page0 {
13471599 struct mpi3_config_page_header header;
13481600 u8 port_number;
@@ -1510,6 +1762,14 @@ struct mpi3_sas_phy_page4 { · 161 unmodified lines
15101762 #define MPI3_PCIE_NEG_LINK_RATE_8_0 (0x04)
15111763 #define MPI3_PCIE_NEG_LINK_RATE_16_0 (0x05)
15121764 #define MPI3_PCIE_NEG_LINK_RATE_32_0 (0x06)
1765+#define MPI3_PCIE_ASPM_ENABLE_NONE (0x0)
1766+#define MPI3_PCIE_ASPM_ENABLE_L0S (0x1)
1767+#define MPI3_PCIE_ASPM_ENABLE_L1 (0x2)
1768+#define MPI3_PCIE_ASPM_ENABLE_L0S_L1 (0x3)
1769+#define MPI3_PCIE_ASPM_SUPPORT_NONE (0x0)
1770+#define MPI3_PCIE_ASPM_SUPPORT_L0S (0x1)
1771+#define MPI3_PCIE_ASPM_SUPPORT_L1 (0x2)
1772+#define MPI3_PCIE_ASPM_SUPPORT_L0S_L1 (0x3)
15131773 struct mpi3_pcie_io_unit0_phy_data {
15141774 u8 link;
15151775 u8 link_flags;
@@ -1540,7 +1800,8 @@ struct mpi3_pcie_io_unit_page0 { · 24 unmodified lines
15401800 __le32 reserved08;
15411801 u8 num_phys;
15421802 u8 init_status;
1543− __le16 reserved0e;
1803+ u8 aspm;
1804+ u8 reserved0f;
15441805 struct mpi3_pcie_io_unit0_phy_data phy_data[MPI3_PCIE_IO_UNIT0_PHY_MAX];
15451806 };
15461807
@@ -1556,6 +1817,14 @@ struct mpi3_pcie_io_unit_page0 { · 9 unmodified lines
15561817 #define MPI3_PCIEIOUNIT0_INITSTATUS_BAD_CLOCKING_MODE (0x08)
15571818 #define MPI3_PCIEIOUNIT0_INITSTATUS_PROD_SPEC_START (0xf0)
15581819 #define MPI3_PCIEIOUNIT0_INITSTATUS_PROD_SPEC_END (0xff)
1820+#define MPI3_PCIEIOUNIT0_ASPM_SWITCH_STATES_MASK (0xc0)
1821+#define MPI3_PCIEIOUNIT0_ASPM_SWITCH_STATES_SHIFT (6)
1822+#define MPI3_PCIEIOUNIT0_ASPM_DIRECT_STATES_MASK (0x30)
1823+#define MPI3_PCIEIOUNIT0_ASPM_DIRECT_STATES_SHIFT (4)
1824+#define MPI3_PCIEIOUNIT0_ASPM_SWITCH_SUPPORT_MASK (0x0c)
1825+#define MPI3_PCIEIOUNIT0_ASPM_SWITCH_SUPPORT_SHIFT (2)
1826+#define MPI3_PCIEIOUNIT0_ASPM_DIRECT_SUPPORT_MASK (0x03)
1827+#define MPI3_PCIEIOUNIT0_ASPM_DIRECT_SUPPORT_SHIFT (0)
15591828 struct mpi3_pcie_io_unit1_phy_data {
15601829 u8 link;
15611830 u8 link_flags;
@@ -1569,16 +1838,16 @@ struct mpi3_pcie_io_unit1_phy_data { · 7 unmodified lines
15691838 #define MPI3_PCIEIOUNIT1_LINKFLAGS_PCIE_CLK_MODE_DIS_SEPARATE_REFCLK (0x00)
15701839 #define MPI3_PCIEIOUNIT1_LINKFLAGS_PCIE_CLK_MODE_EN_SRIS (0x01)
15711840 #define MPI3_PCIEIOUNIT1_LINKFLAGS_PCIE_CLK_MODE_EN_SRNS (0x02)
1572−#define MPI3_PCIEIOUNIT1_PHYFLAGS_PHY_DISABLE (0x08)
1573−#define MPI3_PCIEIOUNIT1_MMLR_MAX_RATE_MASK (0xf0)
1574−#define MPI3_PCIEIOUNIT1_MMLR_MAX_RATE_SHIFT (4)
1575−#define MPI3_PCIEIOUNIT1_MMLR_MAX_RATE_2_5 (0x20)
1576−#define MPI3_PCIEIOUNIT1_MMLR_MAX_RATE_5_0 (0x30)
1577−#define MPI3_PCIEIOUNIT1_MMLR_MAX_RATE_8_0 (0x40)
1578−#define MPI3_PCIEIOUNIT1_MMLR_MAX_RATE_16_0 (0x50)
1579−#define MPI3_PCIEIOUNIT1_MMLR_MAX_RATE_32_0 (0x60)
1841+#define MPI3_PCIEIOUNIT1_PHYFLAGS_PHY_DISABLE (0x08)
1842+#define MPI3_PCIEIOUNIT1_MMLR_MAX_RATE_MASK (0xf0)
1843+#define MPI3_PCIEIOUNIT1_MMLR_MAX_RATE_SHIFT (4)
1844+#define MPI3_PCIEIOUNIT1_MMLR_MAX_RATE_2_5 (0x20)
1845+#define MPI3_PCIEIOUNIT1_MMLR_MAX_RATE_5_0 (0x30)
1846+#define MPI3_PCIEIOUNIT1_MMLR_MAX_RATE_8_0 (0x40)
1847+#define MPI3_PCIEIOUNIT1_MMLR_MAX_RATE_16_0 (0x50)
1848+#define MPI3_PCIEIOUNIT1_MMLR_MAX_RATE_32_0 (0x60)
15801849 #ifndef MPI3_PCIE_IO_UNIT1_PHY_MAX
1581−#define MPI3_PCIE_IO_UNIT1_PHY_MAX (1)
1850+#define MPI3_PCIE_IO_UNIT1_PHY_MAX (1)
15821851 #endif
15831852 struct mpi3_pcie_io_unit_page1 {
15841853 struct mpi3_config_page_header header;
@@ -1586,21 +1855,66 @@ struct mpi3_pcie_io_unit_page1 { · 1 unmodified line
15861855 __le32 reserved0c;
15871856 u8 num_phys;
15881857 u8 reserved11;
1589− __le16 reserved12;
1858+ u8 aspm;
1859+ u8 reserved13;
15901860 struct mpi3_pcie_io_unit1_phy_data phy_data[MPI3_PCIE_IO_UNIT1_PHY_MAX];
15911861 };
15921862
1593−#define MPI3_PCIEIOUNIT1_PAGEVERSION (0x00)
1863+#define MPI3_PCIEIOUNIT1_PAGEVERSION (0x00)
1864+#define MPI3_PCIEIOUNIT1_CONTROL_FLAGS_LINK_OVERRIDE_DISABLE (0x80)
1865+#define MPI3_PCIEIOUNIT1_CONTROL_FLAGS_CLOCK_OVERRIDE_DISABLE (0x40)
1866+#define MPI3_PCIEIOUNIT1_CONTROL_FLAGS_CLOCK_OVERRIDE_MODE_MASK (0x30)
1867+#define MPI3_PCIEIOUNIT1_CONTROL_FLAGS_CLOCK_OVERRIDE_MODE_SHIFT (4)
1868+#define MPI3_PCIEIOUNIT1_CONTROL_FLAGS_CLOCK_OVERRIDE_MODE_SRIS_SRNS_DISABLED (0x00)
1869+#define MPI3_PCIEIOUNIT1_CONTROL_FLAGS_CLOCK_OVERRIDE_MODE_SRIS_ENABLED (0x10)
1870+#define MPI3_PCIEIOUNIT1_CONTROL_FLAGS_CLOCK_OVERRIDE_MODE_SRNS_ENABLED (0x20)
1871+#define MPI3_PCIEIOUNIT1_CONTROL_FLAGS_LINK_RATE_OVERRIDE_MASK (0x0f)
1872+#define MPI3_PCIEIOUNIT1_CONTROL_FLAGS_LINK_RATE_OVERRIDE_MAX_2_5 (0x02)
1873+#define MPI3_PCIEIOUNIT1_CONTROL_FLAGS_LINK_RATE_OVERRIDE_MAX_5_0 (0x03)
1874+#define MPI3_PCIEIOUNIT1_CONTROL_FLAGS_LINK_RATE_OVERRIDE_MAX_8_0 (0x04)
1875+#define MPI3_PCIEIOUNIT1_CONTROL_FLAGS_LINK_RATE_OVERRIDE_MAX_16_0 (0x05)
1876+#define MPI3_PCIEIOUNIT1_CONTROL_FLAGS_LINK_RATE_OVERRIDE_MAX_32_0 (0x06)
1877+#define MPI3_PCIEIOUNIT1_ASPM_SWITCH_MASK (0x0c)
1878+#define MPI3_PCIEIOUNIT1_ASPM_SWITCH_SHIFT (2)
1879+#define MPI3_PCIEIOUNIT1_ASPM_DIRECT_MASK (0x03)
1880+#define MPI3_PCIEIOUNIT1_ASPM_DIRECT_SHIFT (0)
15941881 struct mpi3_pcie_io_unit_page2 {
15951882 struct mpi3_config_page_header header;
1596− __le16 nv_me_max_queue_depth;
1597− __le16 reserved0a;
1598− u8 nv_me_abort_to;
1883+ __le16 nvme_max_q_dx1;
1884+ __le16 nvme_max_q_dx2;
1885+ u8 nvme_abort_to;
15991886 u8 reserved0d;
1600− __le16 reserved0e;
1887+ __le16 nvme_max_q_dx4;
16011888 };
16021889
16031890 #define MPI3_PCIEIOUNIT2_PAGEVERSION (0x00)
1891+#define MPI3_PCIEIOUNIT3_ERROR_RECEIVER_ERROR (0)
1892+#define MPI3_PCIEIOUNIT3_ERROR_RECOVERY (1)
1893+#define MPI3_PCIEIOUNIT3_ERROR_CORRECTABLE_ERROR_MSG (2)
1894+#define MPI3_PCIEIOUNIT3_ERROR_BAD_DLLP (3)
1895+#define MPI3_PCIEIOUNIT3_ERROR_BAD_TLP (4)
1896+#define MPI3_PCIEIOUNIT3_NUM_ERROR_INDEX (5)
1897+struct mpi3_pcie_io_unit3_error {
1898+ __le16 threshold_count;
1899+ __le16 reserved02;
1900+};
1901+
1902+struct mpi3_pcie_io_unit_page3 {
1903+ struct mpi3_config_page_header header;
1904+ u8 threshold_window;
1905+ u8 threshold_action;
1906+ u8 escalation_count;
1907+ u8 escalation_action;
1908+ u8 num_errors;
1909+ u8 reserved0d[3];
1910+ struct mpi3_pcie_io_unit3_error error[MPI3_PCIEIOUNIT3_NUM_ERROR_INDEX];
1911+};
1912+
1913+#define MPI3_PCIEIOUNIT3_PAGEVERSION (0x00)
1914+#define MPI3_PCIEIOUNIT3_ACTION_NO_ACTION (0x00)
1915+#define MPI3_PCIEIOUNIT3_ACTION_HOT_RESET (0x01)
1916+#define MPI3_PCIEIOUNIT3_ACTION_REDUCE_LINK_RATE_ONLY (0x02)
1917+#define MPI3_PCIEIOUNIT3_ACTION_REDUCE_LINK_RATE_NO_ACCESS (0x03)
16041918 struct mpi3_pcie_switch_page0 {
16051919 struct mpi3_config_page_header header;
16061920 u8 io_unit_port;
@@ -1609,7 +1923,7 @@ struct mpi3_pcie_switch_page0 { · 2 unmodified lines
16091923 __le16 dev_handle;
16101924 __le16 parent_dev_handle;
16111925 u8 num_ports;
1612− u8 pc_ie_level;
1926+ u8 pcie_level;
16131927 __le16 reserved12;
16141928 __le32 reserved14;
16151929 __le32 reserved18;
@@ -1623,7 +1937,8 @@ struct mpi3_pcie_switch_page0 { · 7 unmodified lines
16231937 struct mpi3_pcie_switch_page1 {
16241938 struct mpi3_config_page_header header;
16251939 u8 io_unit_port;
1626− u8 reserved09[3];
1940+ u8 flags;
1941+ __le16 reserved0a;
16271942 u8 num_ports;
16281943 u8 port_num;
16291944 __le16 attached_dev_handle;
@@ -1636,15 +1951,43 @@ struct mpi3_pcie_switch_page1 { · 6 unmodified lines
16361951 };
16371952
16381953 #define MPI3_PCIESWITCH1_PAGEVERSION (0x00)
1954+#define MPI3_PCIESWITCH1_FLAGS_ASPMSTATE_MASK (0x0c)
1955+#define MPI3_PCIESWITCH1_FLAGS_ASPMSTATE_SHIFT (2)
1956+#define MPI3_PCIESWITCH1_FLAGS_ASPMSUPPORT_MASK (0x03)
1957+#define MPI3_PCIESWITCH1_FLAGS_ASPMSUPPORT_SHIFT (0)
1958+#ifndef MPI3_PCIESWITCH2_MAX_NUM_PORTS
1959+#define MPI3_PCIESWITCH2_MAX_NUM_PORTS (1)
1960+#endif
1961+struct mpi3_pcieswitch2_port_element {
1962+ __le16 link_change_count;
1963+ __le16 rate_change_count;
1964+ __le32 reserved04;
1965+};
1966+
1967+struct mpi3_pcie_switch_page2 {
1968+ struct mpi3_config_page_header header;
1969+ u8 num_ports;
1970+ u8 reserved09;
1971+ __le16 dev_handle;
1972+ __le32 reserved0c;
1973+ struct mpi3_pcieswitch2_port_element port[MPI3_PCIESWITCH2_MAX_NUM_PORTS];
1974+};
1975+
1976+#define MPI3_PCIESWITCH2_PAGEVERSION (0x00)
16391977 struct mpi3_pcie_link_page0 {
16401978 struct mpi3_config_page_header header;
16411979 u8 link;
16421980 u8 reserved09[3];
1643− __le32 correctable_error_count;
1644− __le16 n_fatal_error_count;
1645− __le16 reserved12;
1646− __le16 fatal_error_count;
1647− __le16 reserved16;
1981+ __le32 reserved0c;
1982+ __le32 receiver_error_count;
1983+ __le32 recovery_count;
1984+ __le32 corr_error_msg_count;
1985+ __le32 non_fatal_error_msg_count;
1986+ __le32 fatal_error_msg_count;
1987+ __le32 non_fatal_error_count;
1988+ __le32 fatal_error_count;
1989+ __le32 bad_dllp_count;
1990+ __le32 bad_tlp_count;
16481991 };
16491992
16501993 #define MPI3_PCIELINK0_PAGEVERSION (0x00)
@@ -1654,11 +1997,12 @@ struct mpi3_enclosure_page0 { · 3 unmodified lines
16541997 __le16 flags;
16551998 __le16 enclosure_handle;
16561999 __le16 num_slots;
1657− __le16 start_slot;
2000+ __le16 reserved16;
16582001 u8 io_unit_port;
16592002 u8 enclosure_level;
16602003 __le16 sep_dev_handle;
1661− __le32 reserved1c;
2004+ u8 chassis_slot;
2005+ u8 reserved1d[3];
16622006 };
16632007
16642008 #define MPI3_ENCLOSURE0_PAGEVERSION (0x00)
@@ -1666,6 +2010,7 @@ struct mpi3_enclosure_page0 { · 1 unmodified line
16662010 #define MPI3_ENCLS0_FLAGS_ENCL_TYPE_VIRTUAL (0x0000)
16672011 #define MPI3_ENCLS0_FLAGS_ENCL_TYPE_SAS (0x4000)
16682012 #define MPI3_ENCLS0_FLAGS_ENCL_TYPE_PCIE (0x8000)
2013+#define MPI3_ENCLS0_FLAGS_CHASSIS_SLOT_VALID (0x0020)
16692014 #define MPI3_ENCLS0_FLAGS_ENCL_DEV_PRESENT_MASK (0x0010)
16702015 #define MPI3_ENCLS0_FLAGS_ENCL_DEV_NOT_FOUND (0x0000)
16712016 #define MPI3_ENCLS0_FLAGS_ENCL_DEV_PRESENT (0x0010)
@@ -1686,6 +2031,7 @@ struct mpi3_device0_sas_sata_format { · 14 unmodified lines
16862031 u8 zone_group;
16872032 };
16882033
2034+#define MPI3_DEVICE0_SASSATA_FLAGS_WRITE_SAME_UNMAP_NCQ (0x0400)
16892035 #define MPI3_DEVICE0_SASSATA_FLAGS_SLUMBER_CAP (0x0200)
16902036 #define MPI3_DEVICE0_SASSATA_FLAGS_PARTIAL_CAP (0x0100)
16912037 #define MPI3_DEVICE0_SASSATA_FLAGS_ASYNC_NOTIFY (0x0080)
@@ -1707,10 +2053,11 @@ struct mpi3_device0_pcie_format { · 15 unmodified lines
17072053 __le32 maximum_data_transfer_size;
17082054 __le32 capabilities;
17092055 __le16 noiob;
1710− u8 nv_me_abort_to;
2056+ u8 nvme_abort_to;
17112057 u8 page_size;
17122058 __le16 shutdown_latency;
1713− __le16 reserved16;
2059+ u8 recovery_info;
2060+ u8 reserved17;
17142061 };
17152062
17162063 #define MPI3_DEVICE0_PCIE_LINK_RATE_32_0_SUPP (0x10)
@@ -1718,16 +2065,38 @@ struct mpi3_device0_pcie_format { · 1 unmodified line
17182065 #define MPI3_DEVICE0_PCIE_LINK_RATE_8_0_SUPP (0x04)
17192066 #define MPI3_DEVICE0_PCIE_LINK_RATE_5_0_SUPP (0x02)
17202067 #define MPI3_DEVICE0_PCIE_LINK_RATE_2_5_SUPP (0x01)
1721−#define MPI3_DEVICE0_PCIE_DEVICE_INFO_TYPE_MASK (0x0003)
2068+#define MPI3_DEVICE0_PCIE_DEVICE_INFO_TYPE_MASK (0x0007)
17222069 #define MPI3_DEVICE0_PCIE_DEVICE_INFO_TYPE_NO_DEVICE (0x0000)
17232070 #define MPI3_DEVICE0_PCIE_DEVICE_INFO_TYPE_NVME_DEVICE (0x0001)
17242071 #define MPI3_DEVICE0_PCIE_DEVICE_INFO_TYPE_SWITCH_DEVICE (0x0002)
17252072 #define MPI3_DEVICE0_PCIE_DEVICE_INFO_TYPE_SCSI_DEVICE (0x0003)
2073+#define MPI3_DEVICE0_PCIE_DEVICE_INFO_ASPM_MASK (0x0030)
2074+#define MPI3_DEVICE0_PCIE_DEVICE_INFO_ASPM_SHIFT (4)
2075+#define MPI3_DEVICE0_PCIE_DEVICE_INFO_PITYPE_MASK (0x00c0)
2076+#define MPI3_DEVICE0_PCIE_DEVICE_INFO_PITYPE_SHIFT (6)
2077+#define MPI3_DEVICE0_PCIE_DEVICE_INFO_PITYPE_0 (0x0000)
2078+#define MPI3_DEVICE0_PCIE_DEVICE_INFO_PITYPE_1 (0x0040)
2079+#define MPI3_DEVICE0_PCIE_DEVICE_INFO_PITYPE_2 (0x0080)
2080+#define MPI3_DEVICE0_PCIE_DEVICE_INFO_PITYPE_3 (0x00c0)
2081+#define MPI3_DEVICE0_PCIE_CAP_SGL_EXTRA_LENGTH_SUPPORTED (0x00000020)
17262082 #define MPI3_DEVICE0_PCIE_CAP_METADATA_SEPARATED (0x00000010)
17272083 #define MPI3_DEVICE0_PCIE_CAP_SGL_DWORD_ALIGN_REQUIRED (0x00000008)
1728−#define MPI3_DEVICE0_PCIE_CAP_NVME_SGL_ENABLED (0x00000004)
2084+#define MPI3_DEVICE0_PCIE_CAP_SGL_FORMAT_SGL (0x00000004)
2085+#define MPI3_DEVICE0_PCIE_CAP_SGL_FORMAT_PRP (0x00000000)
17292086 #define MPI3_DEVICE0_PCIE_CAP_BIT_BUCKET_SGL_SUPP (0x00000002)
17302087 #define MPI3_DEVICE0_PCIE_CAP_SGL_SUPP (0x00000001)
2088+#define MPI3_DEVICE0_PCIE_CAP_ASPM_MASK (0x000000c0)
2089+#define MPI3_DEVICE0_PCIE_CAP_ASPM_SHIFT (6)
2090+#define MPI3_DEVICE0_PCIE_RECOVER_METHOD_MASK (0xe0)
2091+#define MPI3_DEVICE0_PCIE_RECOVER_METHOD_NS_MGMT (0x00)
2092+#define MPI3_DEVICE0_PCIE_RECOVER_METHOD_FORMAT (0x20)
2093+#define MPI3_DEVICE0_PCIE_RECOVER_REASON_MASK (0x1f)
2094+#define MPI3_DEVICE0_PCIE_RECOVER_REASON_NO_NS (0x00)
2095+#define MPI3_DEVICE0_PCIE_RECOVER_REASON_NO_NSID_1 (0x01)
2096+#define MPI3_DEVICE0_PCIE_RECOVER_REASON_TOO_MANY_NS (0x02)
2097+#define MPI3_DEVICE0_PCIE_RECOVER_REASON_PROTECTION (0x03)
2098+#define MPI3_DEVICE0_PCIE_RECOVER_REASON_METADATA_SZ (0x04)
2099+#define MPI3_DEVICE0_PCIE_RECOVER_REASON_LBA_DATA_SZ (0x05)
17312100 struct mpi3_device0_vd_format {
17322101 u8 vd_state;
17332102 u8 raid_level;
@@ -1783,6 +2152,8 @@ struct mpi3_device_page0 { · 49 unmodified lines
17832152 };
17842153
17852154 #define MPI3_DEVICE0_PAGEVERSION (0x00)
2155+#define MPI3_DEVICE0_PARENT_INVALID (0xffff)
2156+#define MPI3_DEVICE0_ENCLOSURE_HANDLE_NO_ENCLOSURE (0x0000)
17862157 #define MPI3_DEVICE0_WWID_INVALID (0xffffffffffffffff)
17872158 #define MPI3_DEVICE0_PERSISTENTID_INVALID (0xffff)
17882159 #define MPI3_DEVICE0_IOUNITPORT_INVALID (0xff)
@@ -1792,9 +2163,13 @@ struct mpi3_device_page0 { · 3 unmodified lines
17922163 #define MPI3_DEVICE0_ASTATUS_DEVICE_BLOCKED (0x03)
17932164 #define MPI3_DEVICE0_ASTATUS_UNAUTHORIZED (0x04)
17942165 #define MPI3_DEVICE0_ASTATUS_DEVICE_MISSING_DELAY (0x05)
2166+#define MPI3_DEVICE0_ASTATUS_PREPARE (0x06)
2167+#define MPI3_DEVICE0_ASTATUS_SAFE_MODE (0x07)
2168+#define MPI3_DEVICE0_ASTATUS_GENERIC_MAX (0x0f)
17952169 #define MPI3_DEVICE0_ASTATUS_SAS_UNKNOWN (0x10)
17962170 #define MPI3_DEVICE0_ASTATUS_ROUTE_NOT_ADDRESSABLE (0x11)
17972171 #define MPI3_DEVICE0_ASTATUS_SMP_ERROR_NOT_ADDRESSABLE (0x12)
2172+#define MPI3_DEVICE0_ASTATUS_SAS_MAX (0x1f)
17982173 #define MPI3_DEVICE0_ASTATUS_SIF_UNKNOWN (0x20)
17992174 #define MPI3_DEVICE0_ASTATUS_SIF_AFFILIATION_CONFLICT (0x21)
18002175 #define MPI3_DEVICE0_ASTATUS_SIF_DIAG (0x22)
@@ -1810,6 +2185,8 @@ struct mpi3_device_page0 { · 9 unmodified lines
18102185 #define MPI3_DEVICE0_ASTATUS_PCIE_MEM_SPACE_ACCESS (0x31)
18112186 #define MPI3_DEVICE0_ASTATUS_PCIE_UNSUPPORTED (0x32)
18122187 #define MPI3_DEVICE0_ASTATUS_PCIE_MSIX_REQUIRED (0x33)
2188+#define MPI3_DEVICE0_ASTATUS_PCIE_ECRC_REQUIRED (0x34)
2189+#define MPI3_DEVICE0_ASTATUS_PCIE_MAX (0x3f)
18132190 #define MPI3_DEVICE0_ASTATUS_NVME_UNKNOWN (0x40)
18142191 #define MPI3_DEVICE0_ASTATUS_NVME_READY_TIMEOUT (0x41)
18152192 #define MPI3_DEVICE0_ASTATUS_NVME_DEVCFG_UNSUPPORTED (0x42)
@@ -1820,7 +2197,17 @@ struct mpi3_device_page0 { · 4 unmodified lines
18202197 #define MPI3_DEVICE0_ASTATUS_NVME_GET_FEATURE_STAT_FAILED (0x47)
18212198 #define MPI3_DEVICE0_ASTATUS_NVME_IDLE_TIMEOUT (0x48)
18222199 #define MPI3_DEVICE0_ASTATUS_NVME_CTRL_FAILURE_STATUS (0x49)
1823−#define MPI3_DEVICE0_ASTATUS_VD_UNKNOWN (0x50)
2200+#define MPI3_DEVICE0_ASTATUS_NVME_INSUFFICIENT_POWER (0x4a)
2201+#define MPI3_DEVICE0_ASTATUS_NVME_DOORBELL_STRIDE (0x4b)
2202+#define MPI3_DEVICE0_ASTATUS_NVME_MEM_PAGE_MIN_SIZE (0x4c)
2203+#define MPI3_DEVICE0_ASTATUS_NVME_MEMORY_ALLOCATION (0x4d)
2204+#define MPI3_DEVICE0_ASTATUS_NVME_COMPLETION_TIME (0x4e)
2205+#define MPI3_DEVICE0_ASTATUS_NVME_BAR (0x4f)
2206+#define MPI3_DEVICE0_ASTATUS_NVME_NS_DESCRIPTOR (0x50)
2207+#define MPI3_DEVICE0_ASTATUS_NVME_INCOMPATIBLE_SETTINGS (0x51)
2208+#define MPI3_DEVICE0_ASTATUS_NVME_MAX (0x5f)
2209+#define MPI3_DEVICE0_ASTATUS_VD_UNKNOWN (0x80)
2210+#define MPI3_DEVICE0_ASTATUS_VD_MAX (0x8f)
18242211 #define MPI3_DEVICE0_FLAGS_CONTROLLER_DEV_HANDLE (0x0080)
18252212 #define MPI3_DEVICE0_FLAGS_HIDDEN (0x0008)
18262213 #define MPI3_DEVICE0_FLAGS_ATT_METHOD_MASK (0x0006)
@@ -1870,11 +2257,17 @@ struct mpi3_device_page1 { · 43 unmodified lines
18702257 struct mpi3_config_page_header header;
18712258 __le16 dev_handle;
18722259 __le16 reserved0a;
1873− __le32 reserved0c[12];
2260+ __le16 link_change_count;
2261+ __le16 rate_change_count;
2262+ __le16 tm_count;
2263+ __le16 reserved12;
2264+ __le32 reserved14[10];
18742265 u8 reserved3c[3];
18752266 u8 device_form;
18762267 union mpi3_device1_dev_spec_format device_specific;
18772268 };
18782269
18792270 #define MPI3_DEVICE1_PAGEVERSION (0x00)
2271+#define MPI3_DEVICE1_COUNTER_MAX (0xfffe)
2272+#define MPI3_DEVICE1_COUNTER_INVALID (0xffff)
18802273 #endif
drivers/scsi/mpi3mr/mpi/mpi30_image.h+58−1
@@ -61,6 +61,8 @@ struct mpi3_component_image_header { · 60 unmodified lines
6161 #define MPI3_IMAGE_HEADER_SIGNATURE1_SPD (0x20445053)
6262 #define MPI3_IMAGE_HEADER_SIGNATURE1_GAS_GAUGE (0x20534147)
6363 #define MPI3_IMAGE_HEADER_SIGNATURE1_PBLP (0x504c4250)
64+#define MPI3_IMAGE_HEADER_SIGNATURE1_MANIFEST (0x464e414d)
65+#define MPI3_IMAGE_HEADER_SIGNATURE1_OEM (0x204d454f)
6466 #define MPI3_IMAGE_HEADER_SIGNATURE2_VALUE (0x50584546)
6567 #define MPI3_IMAGE_HEADER_FLAGS_DEVICE_KEY_BASIS_MASK (0x00000030)
6668 #define MPI3_IMAGE_HEADER_FLAGS_DEVICE_KEY_BASIS_CDI (0x00000000)
@@ -94,6 +96,61 @@ struct mpi3_component_image_header { · 27 unmodified lines
9496 #define MPI3_IMAGE_HEADER_HASH_EXCLUSION_OFFSET (0x5c)
9597 #define MPI3_IMAGE_HEADER_NEXT_IMAGE_HEADER_OFFSET_OFFSET (0x7c)
9698 #define MPI3_IMAGE_HEADER_SIZE (0x100)
99+#ifndef MPI3_CI_MANIFEST_MPI_MAX
100+#define MPI3_CI_MANIFEST_MPI_MAX (1)
101+#endif
102+struct mpi3_ci_manifest_mpi_comp_image_ref {
103+ __le32 signature1;
104+ __le32 reserved04[3];
105+ struct mpi3_comp_image_version component_image_version;
106+ __le32 component_image_version_string_offset;
107+ __le32 crc;
108+};
109+
110+struct mpi3_ci_manifest_mpi {
111+ u8 manifest_type;
112+ u8 reserved01[3];
113+ __le32 reserved04[3];
114+ u8 num_image_references;
115+ u8 release_level;
116+ __le16 reserved12;
117+ __le16 reserved14;
118+ __le16 flags;
119+ __le32 reserved18[2];
120+ __le16 vendor_id;
121+ __le16 device_id;
122+ __le16 subsystem_vendor_id;
123+ __le16 subsystem_id;
124+ __le32 reserved28[2];
125+ union mpi3_version_union package_security_version;
126+ __le32 reserved34;
127+ struct mpi3_comp_image_version package_version;
128+ __le32 package_version_string_offset;
129+ __le32 package_build_date_string_offset;
130+ __le32 package_build_time_string_offset;
131+ __le32 reserved4c;
132+ __le32 diag_authorization_identifier[16];
133+ struct mpi3_ci_manifest_mpi_comp_image_ref component_image_ref[MPI3_CI_MANIFEST_MPI_MAX];
134+};
135+
136+#define MPI3_CI_MANIFEST_MPI_RELEASE_LEVEL_DEV (0x00)
137+#define MPI3_CI_MANIFEST_MPI_RELEASE_LEVEL_PREALPHA (0x10)
138+#define MPI3_CI_MANIFEST_MPI_RELEASE_LEVEL_ALPHA (0x20)
139+#define MPI3_CI_MANIFEST_MPI_RELEASE_LEVEL_BETA (0x30)
140+#define MPI3_CI_MANIFEST_MPI_RELEASE_LEVEL_RC (0x40)
141+#define MPI3_CI_MANIFEST_MPI_RELEASE_LEVEL_GCA (0x50)
142+#define MPI3_CI_MANIFEST_MPI_RELEASE_LEVEL_POINT (0x60)
143+#define MPI3_CI_MANIFEST_MPI_FLAGS_DIAG_AUTHORIZATION (0x01)
144+#define MPI3_CI_MANIFEST_MPI_SUBSYSTEMID_IGNORED (0xffff)
145+#define MPI3_CI_MANIFEST_MPI_PKG_VER_STR_OFF_UNSPECIFIED (0x00000000)
146+#define MPI3_CI_MANIFEST_MPI_PKG_BUILD_DATE_STR_OFF_UNSPECIFIED (0x00000000)
147+#define MPI3_CI_MANIFEST_MPI_PKG_BUILD_TIME_STR_OFF_UNSPECIFIED (0x00000000)
148+union mpi3_ci_manifest {
149+ struct mpi3_ci_manifest_mpi mpi;
150+ __le32 dword[1];
151+};
152+
153+#define MPI3_CI_MANIFEST_TYPE_MPI (0x00)
97154 struct mpi3_extended_image_header {
98155 u8 image_type;
99156 u8 reserved01[3];
@@ -161,6 +218,7 @@ struct mpi3_encrypted_hash_entry { · 61 unmodified lines
161218 #define MPI3_HASH_ALGORITHM_SIZE_UNUSED (0x00)
162219 #define MPI3_HASH_ALGORITHM_SIZE_SHA256 (0x01)
163220 #define MPI3_HASH_ALGORITHM_SIZE_SHA512 (0x02)
221+#define MPI3_HASH_ALGORITHM_SIZE_SHA384 (0x03)
164222 #define MPI3_ENCRYPTION_ALGORITHM_UNUSED (0x00)
165223 #define MPI3_ENCRYPTION_ALGORITHM_RSA256 (0x01)
166224 #define MPI3_ENCRYPTION_ALGORITHM_RSA512 (0x02)
@@ -178,7 +236,6 @@ struct mpi3_encrypted_key_with_hash_entry { · 11 unmodified lines
178236 u8 reserved03;
179237 __le32 reserved04;
180238 __le32 public_key[MPI3_PUBLIC_KEY_MAX];
181− __le32 encrypted_hash[MPI3_ENCRYPTED_HASH_MAX];
182239 };
183240
184241 #ifndef MPI3_ENCRYPTED_HASH_ENTRY_MAX
drivers/scsi/mpi3mr/mpi/mpi30_init.h+12−3
@@ -13,7 +13,7 @@ struct mpi3_scsi_io_cdb_eedp32 { · 12 unmodified lines
1313 __le32 transfer_length;
1414 };
1515
16−union mpi3_scso_io_cdb_union {
16+union mpi3_scsi_io_cdb_union {
1717 u8 cdb32[32];
1818 struct mpi3_scsi_io_cdb_eedp32 eedp32;
1919 struct mpi3_sge_common sge;
@@ -32,11 +32,12 @@ struct mpi3_scsi_io_request { · 12 unmodified lines
3232 __le32 skip_count;
3333 __le32 data_length;
3434 u8 lun[8];
35− union mpi3_scso_io_cdb_union cdb;
35+ union mpi3_scsi_io_cdb_union cdb;
3636 union mpi3_sge_union sgl[4];
3737 };
3838
3939 #define MPI3_SCSIIO_MSGFLAGS_METASGL_VALID (0x80)
40+#define MPI3_SCSIIO_MSGFLAGS_DIVERT_TO_FIRMWARE (0x40)
4041 #define MPI3_SCSIIO_FLAGS_LARGE_CDB (0x60000000)
4142 #define MPI3_SCSIIO_FLAGS_CDB_16_OR_LESS (0x00000000)
4243 #define MPI3_SCSIIO_FLAGS_CDB_GREATER_THAN_16 (0x20000000)
@@ -155,5 +156,13 @@ struct mpi3_scsi_task_mgmt_reply { · 112 unmodified lines
155156 __le32 reserved18;
156157 };
157158
158−#define MPI3_SCSITASKMGMT_RSPCODE_IO_QUEUED_ON_IOC (0x80)
159+#define MPI3_SCSITASKMGMT_RSPCODE_TM_COMPLETE (0x00)
160+#define MPI3_SCSITASKMGMT_RSPCODE_INVALID_FRAME (0x02)
161+#define MPI3_SCSITASKMGMT_RSPCODE_TM_FUNCTION_NOT_SUPPORTED (0x04)
162+#define MPI3_SCSITASKMGMT_RSPCODE_TM_FAILED (0x05)
163+#define MPI3_SCSITASKMGMT_RSPCODE_TM_SUCCEEDED (0x08)
164+#define MPI3_SCSITASKMGMT_RSPCODE_TM_INVALID_LUN (0x09)
165+#define MPI3_SCSITASKMGMT_RSPCODE_TM_OVERLAPPED_TAG (0x0a)
166+#define MPI3_SCSITASKMGMT_RSPCODE_IO_QUEUED_ON_IOC (0x80)
167+#define MPI3_SCSITASKMGMT_RSPCODE_TM_NVME_DENIED (0x81)
159168 #endif
drivers/scsi/mpi3mr/mpi/mpi30_ioc.h+99−29
@@ -29,10 +29,15 @@ struct mpi3_ioc_init_request { · 28 unmodified lines
2929 __le64 driver_information_address;
3030 };
3131
32−#define MPI3_WHOINIT_NOT_INITIALIZED (0x00)
33−#define MPI3_WHOINIT_ROM_BIOS (0x02)
34−#define MPI3_WHOINIT_HOST_DRIVER (0x03)
35−#define MPI3_WHOINIT_MANUFACTURER (0x04)
32+#define MPI3_IOCINIT_MSGFLAGS_HOSTMETADATA_MASK (0x03)
33+#define MPI3_IOCINIT_MSGFLAGS_HOSTMETADATA_NOT_USED (0x00)
34+#define MPI3_IOCINIT_MSGFLAGS_HOSTMETADATA_SEPARATED (0x01)
35+#define MPI3_IOCINIT_MSGFLAGS_HOSTMETADATA_INLINE (0x02)
36+#define MPI3_IOCINIT_MSGFLAGS_HOSTMETADATA_BOTH (0x03)
37+#define MPI3_WHOINIT_NOT_INITIALIZED (0x00)
38+#define MPI3_WHOINIT_ROM_BIOS (0x02)
39+#define MPI3_WHOINIT_HOST_DRIVER (0x03)
40+#define MPI3_WHOINIT_MANUFACTURER (0x04)
3641 struct mpi3_driver_info_layout {
3742 __le32 information_length;
3843 u8 driver_signature[12];
@@ -77,17 +82,17 @@ struct mpi3_ioc_facts_data { · 38 unmodified lines
7782 u8 sge_modifier_shift;
7883 u8 protocol_flags;
7984 __le16 max_sas_initiators;
80− __le16 max_sas_targets;
85+ __le16 reserved2a;
8186 __le16 max_sas_expanders;
8287 __le16 max_enclosures;
8388 __le16 min_dev_handle;
8489 __le16 max_dev_handle;
85− __le16 max_pc_ie_switches;
90+ __le16 max_pcie_switches;
8691 __le16 max_nvme;
87− __le16 max_pds;
92+ __le16 reserved38;
8893 __le16 max_vds;
8994 __le16 max_host_pds;
90− __le16 max_advanced_host_pds;
95+ __le16 max_adv_host_pds;
9196 __le16 max_raid_pds;
9297 __le16 max_posted_cmd_buffers;
9398 __le32 flags;
@@ -97,26 +102,41 @@ struct mpi3_ioc_facts_data { · 3 unmodified lines
97102 __le16 reserved4e;
98103 __le32 diag_trace_size;
99104 __le32 diag_fw_size;
105+ __le32 diag_driver_size;
106+ u8 max_host_pd_ns_count;
107+ u8 max_adv_host_pd_ns_count;
108+ u8 max_raidpd_ns_count;
109+ u8 reserved5f;
100110 };
101111
102−#define MPI3_IOCFACTS_CAPABILITY_ADVANCED_HOST_PD (0x00000010)
112+#define MPI3_IOCFACTS_CAPABILITY_NON_SUPERVISOR_MASK (0x80000000)
113+#define MPI3_IOCFACTS_CAPABILITY_SUPERVISOR_IOC (0x00000000)
114+#define MPI3_IOCFACTS_CAPABILITY_NON_SUPERVISOR_IOC (0x10000000)
115+#define MPI3_IOCFACTS_CAPABILITY_COMPLETE_RESET_CAPABLE (0x00000100)
116+#define MPI3_IOCFACTS_CAPABILITY_SEG_DIAG_TRACE_ENABLED (0x00000080)
117+#define MPI3_IOCFACTS_CAPABILITY_SEG_DIAG_FW_ENABLED (0x00000040)
118+#define MPI3_IOCFACTS_CAPABILITY_SEG_DIAG_DRIVER_ENABLED (0x00000020)
119+#define MPI3_IOCFACTS_CAPABILITY_ADVANCED_HOST_PD_ENABLED (0x00000010)
103120 #define MPI3_IOCFACTS_CAPABILITY_RAID_CAPABLE (0x00000008)
104−#define MPI3_IOCFACTS_CAPABILITY_COALESCE_CTRL_GRAN_MASK (0x00000001)
105−#define MPI3_IOCFACTS_CAPABILITY_COALESCE_CTRL_IOC_GRAN (0x00000000)
106−#define MPI3_IOCFACTS_CAPABILITY_COALESCE_CTRL_REPLY_Q_GRAN (0x00000001)
121+#define MPI3_IOCFACTS_CAPABILITY_MULTIPATH_ENABLED (0x00000002)
122+#define MPI3_IOCFACTS_CAPABILITY_COALESCE_CTRL_SUPPORTED (0x00000001)
107123 #define MPI3_IOCFACTS_PID_TYPE_MASK (0xf000)
108124 #define MPI3_IOCFACTS_PID_TYPE_SHIFT (12)
109125 #define MPI3_IOCFACTS_PID_PRODUCT_MASK (0x0f00)
110126 #define MPI3_IOCFACTS_PID_PRODUCT_SHIFT (8)
111127 #define MPI3_IOCFACTS_PID_FAMILY_MASK (0x00ff)
112128 #define MPI3_IOCFACTS_PID_FAMILY_SHIFT (0)
129+#define MPI3_IOCFACTS_EXCEPT_SECURITY_REKEY (0x2000)
130+#define MPI3_IOCFACTS_EXCEPT_SAS_DISABLED (0x1000)
113131 #define MPI3_IOCFACTS_EXCEPT_SAFE_MODE (0x0800)
114132 #define MPI3_IOCFACTS_EXCEPT_SECURITY_KEY_MASK (0x0700)
115133 #define MPI3_IOCFACTS_EXCEPT_SECURITY_KEY_NONE (0x0000)
116−#define MPI3_IOCFACTS_EXCEPT_SECURITY_KEY_LOCAL_VIA_RAID (0x0100)
117−#define MPI3_IOCFACTS_EXCEPT_SECURITY_KEY_LOCAL_VIA_OOB (0x0200)
118−#define MPI3_IOCFACTS_EXCEPT_SECURITY_KEY_EXT_VIA_RAID (0x0300)
119−#define MPI3_IOCFACTS_EXCEPT_SECURITY_KEY_EXT_VIA_OOB (0x0400)
134+#define MPI3_IOCFACTS_EXCEPT_SECURITY_KEY_LOCAL_VIA_MGMT (0x0100)
135+#define MPI3_IOCFACTS_EXCEPT_SECURITY_KEY_EXT_VIA_MGMT (0x0200)
136+#define MPI3_IOCFACTS_EXCEPT_SECURITY_KEY_DRIVE_EXT_VIA_MGMT (0x0300)
137+#define MPI3_IOCFACTS_EXCEPT_SECURITY_KEY_LOCAL_VIA_OOB (0x0400)
138+#define MPI3_IOCFACTS_EXCEPT_SECURITY_KEY_EXT_VIA_OOB (0x0500)
139+#define MPI3_IOCFACTS_EXCEPT_SECURITY_KEY_DRIVE_EXT_VIA_OOB (0x0600)
120140 #define MPI3_IOCFACTS_EXCEPT_PCIE_DISABLED (0x0080)
121141 #define MPI3_IOCFACTS_EXCEPT_PARTIAL_MEMORY_FAILURE (0x0040)
122142 #define MPI3_IOCFACTS_EXCEPT_MANUFACT_CHECKSUM_FAIL (0x0020)
@@ -175,6 +195,7 @@ struct mpi3_create_request_queue_request { · 52 unmodified lines
175195 #define MPI3_CREATE_REQUEST_QUEUE_FLAGS_SEGMENTED_MASK (0x80)
176196 #define MPI3_CREATE_REQUEST_QUEUE_FLAGS_SEGMENTED_SEGMENTED (0x80)
177197 #define MPI3_CREATE_REQUEST_QUEUE_FLAGS_SEGMENTED_CONTIGUOUS (0x00)
198+#define MPI3_CREATE_REQUEST_QUEUE_SIZE_MINIMUM (2)
178199 struct mpi3_delete_request_queue_request {
179200 __le16 host_tag;
180201 u8 ioc_use_only02;
@@ -210,6 +231,7 @@ struct mpi3_create_reply_queue_request { · 29 unmodified lines
210231 #define MPI3_CREATE_REPLY_QUEUE_FLAGS_INT_ENABLE_MASK (0x01)
211232 #define MPI3_CREATE_REPLY_QUEUE_FLAGS_INT_ENABLE_DISABLE (0x00)
212233 #define MPI3_CREATE_REPLY_QUEUE_FLAGS_INT_ENABLE_ENABLE (0x01)
234+#define MPI3_CREATE_REPLY_QUEUE_SIZE_MINIMUM (2)
213235 struct mpi3_delete_reply_queue_request {
214236 __le16 host_tag;
215237 u8 ioc_use_only02;
@@ -255,7 +277,9 @@ struct mpi3_port_enable_request { · 39 unmodified lines
255277 #define MPI3_EVENT_SAS_DEVICE_DISCOVERY_ERROR (0x19)
256278 #define MPI3_EVENT_PCIE_TOPOLOGY_CHANGE_LIST (0x20)
257279 #define MPI3_EVENT_PCIE_ENUMERATION (0x22)
280+#define MPI3_EVENT_PCIE_ERROR_THRESHOLD (0x23)
258281 #define MPI3_EVENT_HARD_RESET_RECEIVED (0x40)
282+#define MPI3_EVENT_DIAGNOSTIC_BUFFER_STATUS_CHANGE (0x50)
259283 #define MPI3_EVENT_MIN_PRODUCT_SPECIFIC (0x60)
260284 #define MPI3_EVENT_MAX_PRODUCT_SPECIFIC (0x7f)
261285 #define MPI3_EVENT_NOTIFY_EVENTMASK_WORDS (4)
@@ -311,10 +335,9 @@ struct mpi3_event_data_temp_threshold { · 49 unmodified lines
311335 __le32 reserved0c;
312336 };
313337
314−#define MPI3_EVENT_TEMP_THRESHOLD_STATUS_THRESHOLD3_EXCEEDED (0x0008)
315−#define MPI3_EVENT_TEMP_THRESHOLD_STATUS_THRESHOLD2_EXCEEDED (0x0004)
316−#define MPI3_EVENT_TEMP_THRESHOLD_STATUS_THRESHOLD1_EXCEEDED (0x0002)
317−#define MPI3_EVENT_TEMP_THRESHOLD_STATUS_THRESHOLD0_EXCEEDED (0x0001)
338+#define MPI3_EVENT_TEMP_THRESHOLD_STATUS_FATAL_THRESHOLD_EXCEEDED (0x0004)
339+#define MPI3_EVENT_TEMP_THRESHOLD_STATUS_CRITICAL_THRESHOLD_EXCEEDED (0x0002)
340+#define MPI3_EVENT_TEMP_THRESHOLD_STATUS_WARNING_THRESHOLD_EXCEEDED (0x0001)
318341 struct mpi3_event_data_cable_management {
319342 __le32 active_cable_power_requirement;
320343 u8 status;
@@ -398,8 +421,10 @@ struct mpi3_event_data_sas_discovery { · 77 unmodified lines
398421 #define MPI3_SAS_DISC_STATUS_MAX_EXPANDERS_EXCEED (0x40000000)
399422 #define MPI3_SAS_DISC_STATUS_MAX_DEVICES_EXCEED (0x20000000)
400423 #define MPI3_SAS_DISC_STATUS_MAX_TOPO_PHYS_EXCEED (0x10000000)
424+#define MPI3_SAS_DISC_STATUS_INVALID_CEI (0x00010000)
425+#define MPI3_SAS_DISC_STATUS_FECEI_MISMATCH (0x00008000)
401426 #define MPI3_SAS_DISC_STATUS_MULTIPLE_DEVICES_IN_SLOT (0x00004000)
402−#define MPI3_SAS_DISC_STATUS_SLOT_COUNT_MISMATCH (0x00002000)
427+#define MPI3_SAS_DISC_STATUS_NECEI_MISMATCH (0x00002000)
403428 #define MPI3_SAS_DISC_STATUS_TOO_MANY_SLOTS (0x00001000)
404429 #define MPI3_SAS_DISC_STATUS_EXP_MULTI_SUBTRACTIVE (0x00000800)
405430 #define MPI3_SAS_DISC_STATUS_MULTI_PORT_DOMAIN (0x00000400)
@@ -581,6 +606,20 @@ struct mpi3_event_data_pcie_topology_change_list { · 175 unmodified lines
581606 #define MPI3_EVENT_PCIE_TOPO_SS_NOT_RESPONDING (0x02)
582607 #define MPI3_EVENT_PCIE_TOPO_SS_RESPONDING (0x03)
583608 #define MPI3_EVENT_PCIE_TOPO_SS_DELAY_NOT_RESPONDING (0x04)
609+struct mpi3_event_data_pcie_error_threshold {
610+ __le64 timestamp;
611+ u8 reason_code;
612+ u8 port;
613+ __le16 switch_dev_handle;
614+ u8 error;
615+ u8 action;
616+ __le16 threshold_count;
617+ __le16 attached_dev_handle;
618+ __le16 reserved12;
619+};
620+
621+#define MPI3_EVENT_PCI_ERROR_RC_THRESHOLD_EXCEEDED (0x00)
622+#define MPI3_EVENT_PCI_ERROR_RC_ESCALATION (0x01)
584623 struct mpi3_event_data_sas_init_dev_status_change {
585624 u8 reason_code;
586625 u8 io_unit_port;
@@ -604,6 +643,16 @@ struct mpi3_event_data_hard_reset_received { · 17 unmodified lines
604643 __le16 reserved02;
605644 };
606645
646+struct mpi3_event_data_diag_buffer_status_change {
647+ u8 type;
648+ u8 reason_code;
649+ __le16 reserved02;
650+ __le32 reserved04;
651+};
652+
653+#define MPI3_EVENT_DIAG_BUFFER_STATUS_CHANGE_RC_RELEASED (0x01)
654+#define MPI3_EVENT_DIAG_BUFFER_STATUS_CHANGE_RC_PAUSED (0x02)
655+#define MPI3_EVENT_DIAG_BUFFER_STATUS_CHANGE_RC_RESUMED (0x03)
607656 #define MPI3_PEL_LOCALE_FLAGS_NON_BLOCKING_BOOT_EVENT (0x0200)
608657 #define MPI3_PEL_LOCALE_FLAGS_BLOCKING_BOOT_EVENT (0x0100)
609658 #define MPI3_PEL_LOCALE_FLAGS_PCIE (0x0080)
@@ -645,21 +694,23 @@ struct mpi3_pel_seq { · 35 unmodified lines
645694 };
646695
647696 struct mpi3_pel_entry {
697+ __le64 time_stamp;
648698 __le32 sequence_number;
649− __le32 time_stamp[2];
650699 __le16 log_code;
651700 __le16 arg_type;
652701 __le16 locale;
653702 u8 class;
654− u8 reserved13;
703+ u8 flags;
655704 u8 ext_num;
656705 u8 num_exts;
657706 u8 arg_data_size;
658− u8 fixed_format_size;
707+ u8 fixed_format_strings_size;
659708 __le32 reserved18[2];
660709 __le32 pel_info[24];
661710 };
662711
712+#define MPI3_PEL_FLAGS_COMPLETE_RESET_NEEDED (0x02)
713+#define MPI3_PEL_FLAGS_ACK_NEEDED (0x01)
663714 struct mpi3_pel_list {
664715 __le32 log_count;
665716 __le32 reserved04;
@@ -837,7 +888,10 @@ struct mpi3_pel_req_action_acknowledge { · 171 unmodified lines
837888 __le32 reserved10;
838889 };
839890
840−#define MPI3_PELACKNOWLEDGE_MSGFLAGS_SAFE_MODE_EXIT (0x01)
891+#define MPI3_PELACKNOWLEDGE_MSGFLAGS_SAFE_MODE_EXIT_MASK (0x03)
892+#define MPI3_PELACKNOWLEDGE_MSGFLAGS_SAFE_MODE_EXIT_NO_GUIDANCE (0x00)
893+#define MPI3_PELACKNOWLEDGE_MSGFLAGS_SAFE_MODE_EXIT_CONTINUE_OP (0x01)
894+#define MPI3_PELACKNOWLEDGE_MSGFLAGS_SAFE_MODE_EXIT_TRANSITION_TO_FAULT (0x02)
841895 struct mpi3_pel_reply {
842896 __le16 host_tag;
843897 u8 ioc_use_only02;
@@ -885,6 +939,7 @@ struct mpi3_ci_download_request { · 41 unmodified lines
885939 #define MPI3_CI_DOWNLOAD_ACTION_ONLINE_ACTIVATION (0x02)
886940 #define MPI3_CI_DOWNLOAD_ACTION_OFFLINE_ACTIVATION (0x03)
887941 #define MPI3_CI_DOWNLOAD_ACTION_GET_STATUS (0x04)
942+#define MPI3_CI_DOWNLOAD_ACTION_CANCEL_OFFLINE_ACTIVATION (0x05)
888943 struct mpi3_ci_download_reply {
889944 __le16 host_tag;
890945 u8 ioc_use_only02;
@@ -902,6 +957,7 @@ struct mpi3_ci_download_reply { · 11 unmodified lines
902957 };
903958
904959 #define MPI3_CI_DOWNLOAD_FLAGS_DOWNLOAD_IN_PROGRESS (0x80)
960+#define MPI3_CI_DOWNLOAD_FLAGS_OFFLINE_ACTIVATION_REQUIRED (0x20)
905961 #define MPI3_CI_DOWNLOAD_FLAGS_KEY_UPDATE_PENDING (0x10)
906962 #define MPI3_CI_DOWNLOAD_FLAGS_ACTIVATION_STATUS_MASK (0x0e)
907963 #define MPI3_CI_DOWNLOAD_FLAGS_ACTIVATION_STATUS_NOT_NEEDED (0x00)
@@ -939,19 +995,28 @@ struct mpi3_ci_upload_request { · 31 unmodified lines
939995 #define MPI3_CTRL_OP_REMOVE_DEVICE (0x10)
940996 #define MPI3_CTRL_OP_CLOSE_PERSISTENT_CONNECTION (0x11)
941997 #define MPI3_CTRL_OP_HIDDEN_ACK (0x12)
998+#define MPI3_CTRL_OP_CLEAR_DEVICE_COUNTERS (0x13)
942999 #define MPI3_CTRL_OP_SAS_SEND_PRIMITIVE (0x20)
943−#define MPI3_CTRL_OP_SAS_CLEAR_ERROR_LOG (0x21)
944−#define MPI3_CTRL_OP_PCIE_CLEAR_ERROR_LOG (0x22)
1000+#define MPI3_CTRL_OP_SAS_PHY_CONTROL (0x21)
1001+#define MPI3_CTRL_OP_READ_INTERNAL_BUS (0x23)
1002+#define MPI3_CTRL_OP_WRITE_INTERNAL_BUS (0x24)
1003+#define MPI3_CTRL_OP_PCIE_LINK_CONTROL (0x30)
9451004 #define MPI3_CTRL_OP_LOOKUP_MAPPING_PARAM8_LOOKUP_METHOD_INDEX (0x00)
9461005 #define MPI3_CTRL_OP_UPDATE_TIMESTAMP_PARAM64_TIMESTAMP_INDEX (0x00)
9471006 #define MPI3_CTRL_OP_REMOVE_DEVICE_PARAM16_DEVHANDLE_INDEX (0x00)
9481007 #define MPI3_CTRL_OP_CLOSE_PERSIST_CONN_PARAM16_DEVHANDLE_INDEX (0x00)
9491008 #define MPI3_CTRL_OP_HIDDEN_ACK_PARAM16_DEVHANDLE_INDEX (0x00)
1009+#define MPI3_CTRL_OP_CLEAR_DEVICE_COUNTERS_PARAM16_DEVHANDLE_INDEX (0x00)
9501010 #define MPI3_CTRL_OP_SAS_SEND_PRIM_PARAM8_PHY_INDEX (0x00)
9511011 #define MPI3_CTRL_OP_SAS_SEND_PRIM_PARAM8_PRIMSEQ_INDEX (0x01)
9521012 #define MPI3_CTRL_OP_SAS_SEND_PRIM_PARAM32_PRIMITIVE_INDEX (0x00)
953−#define MPI3_CTRL_OP_SAS_CLEAR_ERR_LOG_PARAM8_PHY_INDEX (0x00)
954−#define MPI3_CTRL_OP_PCIE_CLEAR_ERR_LOG_PARAM8_PHY_INDEX (0x00)
1013+#define MPI3_CTRL_OP_SAS_PHY_CONTROL_PARAM8_ACTION_INDEX (0x00)
1014+#define MPI3_CTRL_OP_SAS_PHY_CONTROL_PARAM8_PHY_INDEX (0x01)
1015+#define MPI3_CTRL_OP_READ_INTERNAL_BUS_PARAM64_ADDRESS_INDEX (0x00)
1016+#define MPI3_CTRL_OP_WRITE_INTERNAL_BUS_PARAM64_ADDRESS_INDEX (0x00)
1017+#define MPI3_CTRL_OP_WRITE_INTERNAL_BUS_PARAM32_VALUE_INDEX (0x00)
1018+#define MPI3_CTRL_OP_PCIE_LINK_CONTROL_PARAM8_ACTION_INDEX (0x00)
1019+#define MPI3_CTRL_OP_PCIE_LINK_CONTROL_PARAM8_LINK_INDEX (0x01)
9551020 #define MPI3_CTRL_LOOKUP_METHOD_WWID_ADDRESS (0x01)
9561021 #define MPI3_CTRL_LOOKUP_METHOD_ENCLOSURE_SLOT (0x02)
9571022 #define MPI3_CTRL_LOOKUP_METHOD_SAS_DEVICE_NAME (0x03)
@@ -966,9 +1031,14 @@ struct mpi3_ci_upload_request { · 8 unmodified lines
9661031 #define MPI3_CTRL_LOOKUP_METHOD_PERSISTID_PARAM16_PERSISTENT_ID_INDEX (1)
9671032 #define MPI3_CTRL_LOOKUP_METHOD_VALUE16_DEVH_INDEX (0)
9681033 #define MPI3_CTRL_GET_TIMESTAMP_VALUE64_TIMESTAMP_INDEX (0)
1034+#define MPI3_CTRL_READ_INTERNAL_BUS_VALUE32_VALUE_INDEX (0)
9691035 #define MPI3_CTRL_PRIMFLAGS_SINGLE (0x01)
9701036 #define MPI3_CTRL_PRIMFLAGS_TRIPLE (0x03)
9711037 #define MPI3_CTRL_PRIMFLAGS_REDUNDANT (0x06)
1038+#define MPI3_CTRL_ACTION_NOP (0x00)
1039+#define MPI3_CTRL_ACTION_LINK_RESET (0x01)
1040+#define MPI3_CTRL_ACTION_HARD_RESET (0x02)
1041+#define MPI3_CTRL_ACTION_CLEAR_ERROR_LOG (0x05)
9721042 struct mpi3_iounit_control_request {
9731043 __le16 host_tag;
9741044 u8 ioc_use_only02;
drivers/scsi/mpi3mr/mpi/mpi30_pci.h+44−0
@@ -0,0 +1,44 @@
1+/* SPDX-License-Identifier: GPL-2.0-or-later */
2+/*
3+ * Copyright 2016-2021 Broadcom Inc. All rights reserved.
4+ *
5+ */
6+#ifndef MPI30_PCI_H
7+#define MPI30_PCI_H 1
8+#ifndef MPI3_NVME_ENCAP_CMD_MAX
9+#define MPI3_NVME_ENCAP_CMD_MAX (1)
10+#endif
11+struct mpi3_nvme_encapsulated_request {
12+ __le16 host_tag;
13+ u8 ioc_use_only02;
14+ u8 function;
15+ __le16 ioc_use_only04;
16+ u8 ioc_use_only06;
17+ u8 msg_flags;
18+ __le16 change_count;
19+ __le16 dev_handle;
20+ __le16 encapsulated_command_length;
21+ __le16 flags;
22+ __le32 reserved10[4];
23+ __le32 command[MPI3_NVME_ENCAP_CMD_MAX];
24+};
25+
26+#define MPI3_NVME_FLAGS_FORCE_ADMIN_ERR_REPLY_MASK (0x0002)
27+#define MPI3_NVME_FLAGS_FORCE_ADMIN_ERR_REPLY_FAIL_ONLY (0x0000)
28+#define MPI3_NVME_FLAGS_FORCE_ADMIN_ERR_REPLY_ALL (0x0002)
29+#define MPI3_NVME_FLAGS_SUBMISSIONQ_MASK (0x0001)
30+#define MPI3_NVME_FLAGS_SUBMISSIONQ_IO (0x0000)
31+#define MPI3_NVME_FLAGS_SUBMISSIONQ_ADMIN (0x0001)
32+struct mpi3_nvme_encapsulated_error_reply {
33+ __le16 host_tag;
34+ u8 ioc_use_only02;
35+ u8 function;
36+ __le16 ioc_use_only04;
37+ u8 ioc_use_only06;
38+ u8 msg_flags;
39+ __le16 ioc_use_only08;
40+ __le16 ioc_status;
41+ __le32 ioc_log_info;
42+ __le32 nvme_completion_entry[4];
43+};
44+#endif
drivers/scsi/mpi3mr/mpi/mpi30_sas.h+14−0
@@ -30,4 +30,18 @@ struct mpi3_smp_passthrough_request { · 29 unmodified lines
3030 struct mpi3_sge_common request_sge;
3131 struct mpi3_sge_common response_sge;
3232 };
33+
34+struct mpi3_smp_passthrough_reply {
35+ __le16 host_tag;
36+ u8 ioc_use_only02;
37+ u8 function;
38+ __le16 ioc_use_only04;
39+ u8 ioc_use_only06;
40+ u8 msg_flags;
41+ __le16 ioc_use_only08;
42+ __le16 ioc_status;
43+ __le32 ioc_log_info;
44+ __le16 response_data_length;
45+ __le16 reserved12;
46+};
3347 #endif
drivers/scsi/mpi3mr/mpi/mpi30_transport.h+19−12
@@ -19,8 +19,8 @@ union mpi3_version_union { · 18 unmodified lines
1919
2020 #define MPI3_VERSION_MAJOR (3)
2121 #define MPI3_VERSION_MINOR (0)
22−#define MPI3_VERSION_UNIT (0)
23−#define MPI3_VERSION_DEV (18)
22+#define MPI3_VERSION_UNIT (22)
23+#define MPI3_VERSION_DEV (0)
2424 struct mpi3_sysif_oper_queue_indexes {
2525 __le16 producer_index;
2626 __le16 reserved02;
@@ -74,6 +74,7 @@ struct mpi3_sysif_registers { · 47 unmodified lines
7474 #define MPI3_SYSIF_IOC_INFO_HIGH_OFFSET (0x00000004)
7575 #define MPI3_SYSIF_IOC_INFO_LOW_TIMEOUT_MASK (0xff000000)
7676 #define MPI3_SYSIF_IOC_INFO_LOW_TIMEOUT_SHIFT (24)
77+#define MPI3_SYSIF_IOC_INFO_LOW_HCB_DISABLED (0x00000001)
7778 #define MPI3_SYSIF_IOC_CONFIG_OFFSET (0x00000014)
7879 #define MPI3_SYSIF_IOC_CONFIG_OPER_RPY_ENT_SZ (0x00f00000)
7980 #define MPI3_SYSIF_IOC_CONFIG_OPER_RPY_ENT_SZ_SHIFT (20)
@@ -82,12 +83,13 @@ struct mpi3_sysif_registers { · 2 unmodified lines
8283 #define MPI3_SYSIF_IOC_CONFIG_SHUTDOWN_MASK (0x0000c000)
8384 #define MPI3_SYSIF_IOC_CONFIG_SHUTDOWN_NO (0x00000000)
8485 #define MPI3_SYSIF_IOC_CONFIG_SHUTDOWN_NORMAL (0x00004000)
85−#define MPI3_SYSIF_IOC_CONFIG_DEVICE_SHUTDOWN (0x00002000)
86+#define MPI3_SYSIF_IOC_CONFIG_DEVICE_SHUTDOWN_SEND_REQ (0x00002000)
8687 #define MPI3_SYSIF_IOC_CONFIG_DIAG_SAVE (0x00000010)
8788 #define MPI3_SYSIF_IOC_CONFIG_ENABLE_IOC (0x00000001)
8889 #define MPI3_SYSIF_IOC_STATUS_OFFSET (0x0000001c)
8990 #define MPI3_SYSIF_IOC_STATUS_RESET_HISTORY (0x00000010)
9091 #define MPI3_SYSIF_IOC_STATUS_SHUTDOWN_MASK (0x0000000c)
92+#define MPI3_SYSIF_IOC_STATUS_SHUTDOWN_SHIFT (0x00000002)
9193 #define MPI3_SYSIF_IOC_STATUS_SHUTDOWN_NONE (0x00000000)
9294 #define MPI3_SYSIF_IOC_STATUS_SHUTDOWN_IN_PROGRESS (0x00000004)
9395 #define MPI3_SYSIF_IOC_STATUS_SHUTDOWN_COMPLETE (0x00000008)
@@ -107,9 +109,9 @@ struct mpi3_sysif_registers { · 13 unmodified lines
107109 #define MPI3_SYSIF_COALESCE_CONTROL_ENABLE_NO_CHANGE (0x00000000)
108110 #define MPI3_SYSIF_COALESCE_CONTROL_ENABLE_DISABLE (0x40000000)
109111 #define MPI3_SYSIF_COALESCE_CONTROL_ENABLE_ENABLE (0xc0000000)
110−#define MPI3_SYSIF_COALESCE_CONTROL_VALID (0x30000000)
111−#define MPI3_SYSIF_COALESCE_CONTROL_QUEUE_ID_MASK (0x00ff0000)
112−#define MPI3_SYSIF_COALESCE_CONTROL_QUEUE_ID_SHIFT (16)
112+#define MPI3_SYSIF_COALESCE_CONTROL_VALID (0x20000000)
113+#define MPI3_SYSIF_COALESCE_CONTROL_MSIX_IDX_MASK (0x01ff0000)
114+#define MPI3_SYSIF_COALESCE_CONTROL_MSIX_IDX_SHIFT (16)
113115 #define MPI3_SYSIF_COALESCE_CONTROL_TIMEOUT_MASK (0x0000ff00)
114116 #define MPI3_SYSIF_COALESCE_CONTROL_TIMEOUT_SHIFT (8)
115117 #define MPI3_SYSIF_COALESCE_CONTROL_DEPTH_MASK (0x000000ff)
@@ -117,9 +119,9 @@ struct mpi3_sysif_registers { · 1 unmodified line
117119 #define MPI3_SYSIF_ADMIN_REQ_Q_PI_OFFSET (0x00001000)
118120 #define MPI3_SYSIF_ADMIN_REPLY_Q_CI_OFFSET (0x00001004)
119121 #define MPI3_SYSIF_OPER_REQ_Q_PI_OFFSET (0x00001008)
120−#define MPI3_SYSIF_OPER_REQ_Q_N_PI_OFFSET(n) (MPI3_SYSIF_OPER_REQ_Q_PI_OFFSET + (((n) - 1) * 8))
122+#define MPI3_SYSIF_OPER_REQ_Q_N_PI_OFFSET(N) (MPI3_SYSIF_OPER_REQ_Q_PI_OFFSET + (((N) - 1) * 8))
121123 #define MPI3_SYSIF_OPER_REPLY_Q_CI_OFFSET (0x0000100c)
122−#define MPI3_SYSIF_OPER_REPLY_Q_N_CI_OFFSET(n) (MPI3_SYSIF_OPER_REPLY_Q_CI_OFFSET + (((n) - 1) * 8))
124+#define MPI3_SYSIF_OPER_REPLY_Q_N_CI_OFFSET(N) (MPI3_SYSIF_OPER_REPLY_Q_CI_OFFSET + (((N) - 1) * 8))
123125 #define MPI3_SYSIF_WRITE_SEQUENCE_OFFSET (0x00001c04)
124126 #define MPI3_SYSIF_WRITE_SEQUENCE_KEY_VALUE_MASK (0x0000000f)
125127 #define MPI3_SYSIF_WRITE_SEQUENCE_KEY_VALUE_FLUSH (0x0)
@@ -133,7 +135,7 @@ struct mpi3_sysif_registers { · 7 unmodified lines
133135 #define MPI3_SYSIF_HOST_DIAG_RESET_ACTION_MASK (0x00000700)
134136 #define MPI3_SYSIF_HOST_DIAG_RESET_ACTION_NO_RESET (0x00000000)
135137 #define MPI3_SYSIF_HOST_DIAG_RESET_ACTION_SOFT_RESET (0x00000100)
136−#define MPI3_SYSIF_HOST_DIAG_RESET_ACTION_FLASH_RCVRY_RESET (0x00000200)
138+#define MPI3_SYSIF_HOST_DIAG_RESET_ACTION_HOST_CONTROL_BOOT_RESET (0x00000200)
137139 #define MPI3_SYSIF_HOST_DIAG_RESET_ACTION_COMPLETE_RESET (0x00000300)
138140 #define MPI3_SYSIF_HOST_DIAG_RESET_ACTION_DIAG_FAULT (0x00000700)
139141 #define MPI3_SYSIF_HOST_DIAG_SAVE_IN_PROGRESS (0x00000080)
@@ -153,8 +155,9 @@ struct mpi3_sysif_registers { · 13 unmodified lines
153155 #define MPI3_SYSIF_FAULT_CODE_CI_ACTIVATION_RESET (0x0000f001)
154156 #define MPI3_SYSIF_FAULT_CODE_SOFT_RESET_IN_PROGRESS (0x0000f002)
155157 #define MPI3_SYSIF_FAULT_CODE_COMPLETE_RESET_NEEDED (0x0000f003)
156−#define MPI3_SYSIF_FAULT_CODE_SAFE_MODE_EXIT (0x0000f004)
157−#define MPI3_SYSIF_FAULT_CODE_FACTORY_RESET (0x0000f005)
158+#define MPI3_SYSIF_FAULT_CODE_SOFT_RESET_NEEDED (0x0000f004)
159+#define MPI3_SYSIF_FAULT_CODE_POWER_CYCLE_REQUIRED (0x0000f005)
160+#define MPI3_SYSIF_FAULT_CODE_TEMP_THRESHOLD_EXCEEDED (0x0000f006)
158161 #define MPI3_SYSIF_FAULT_INFO0_OFFSET (0x00001c14)
159162 #define MPI3_SYSIF_FAULT_INFO1_OFFSET (0x00001c18)
160163 #define MPI3_SYSIF_FAULT_INFO2_OFFSET (0x00001c1c)
@@ -409,6 +412,8 @@ struct mpi3_default_reply { · 248 unmodified lines
409412 #define MPI3_IOCSTATUS_INVALID_STATE (0x0008)
410413 #define MPI3_IOCSTATUS_INSUFFICIENT_POWER (0x000a)
411414 #define MPI3_IOCSTATUS_INVALID_CHANGE_COUNT (0x000b)
415+#define MPI3_IOCSTATUS_ALLOWED_CMD_BLOCK (0x000c)
416+#define MPI3_IOCSTATUS_SUPERVISOR_ONLY (0x000d)
412417 #define MPI3_IOCSTATUS_FAILURE (0x001f)
413418 #define MPI3_IOCSTATUS_CONFIG_INVALID_ACTION (0x0020)
414419 #define MPI3_IOCSTATUS_CONFIG_INVALID_TYPE (0x0021)
@@ -448,8 +453,10 @@ struct mpi3_default_reply { · 33 unmodified lines
448453 #define MPI3_IOCSTATUS_CI_UNSUPPORTED (0x00b0)
449454 #define MPI3_IOCSTATUS_CI_UPDATE_SEQUENCE (0x00b1)
450455 #define MPI3_IOCSTATUS_CI_VALIDATION_FAILED (0x00b2)
451−#define MPI3_IOCSTATUS_CI_UPDATE_PENDING (0x00b3)
456+#define MPI3_IOCSTATUS_CI_KEY_UPDATE_PENDING (0x00b3)
457+#define MPI3_IOCSTATUS_CI_KEY_UPDATE_NOT_POSSIBLE (0x00b4)
452458 #define MPI3_IOCSTATUS_SECURITY_KEY_REQUIRED (0x00c0)
459+#define MPI3_IOCSTATUS_SECURITY_VIOLATION (0x00c1)
453460 #define MPI3_IOCSTATUS_INVALID_QUEUE_ID (0x0f00)
454461 #define MPI3_IOCSTATUS_INVALID_QUEUE_SIZE (0x0f01)
455462 #define MPI3_IOCSTATUS_INVALID_MSIX_VECTOR (0x0f02)
drivers/scsi/mpi3mr/mpi3mr.h+86−40
@@ -45,6 +45,7 @@ · 44 unmodified lines
4545 #include "mpi/mpi30_init.h"
4646 #include "mpi/mpi30_ioc.h"
4747 #include "mpi/mpi30_sas.h"
48+#include "mpi/mpi30_pci.h"
4849 #include "mpi3mr_debug.h"
4950
5051 /* Global list and lock for storing multiple adapters managed by the driver */
@@ -52,8 +53,8 @@ extern spinlock_t mrioc_list_lock; · 1 unmodified line
5253 extern struct list_head mrioc_list;
5354 extern int prot_mask;
5455
55−#define MPI3MR_DRIVER_VERSION "00.255.45.01"
56−#define MPI3MR_DRIVER_RELDATE "12-December-2020"
56+#define MPI3MR_DRIVER_VERSION "8.0.0.61.0"
57+#define MPI3MR_DRIVER_RELDATE "20-December-2021"
5758
5859 #define MPI3MR_DRIVER_NAME "mpi3mr"
5960 #define MPI3MR_DRIVER_LICENSE "GPL"
@@ -79,7 +80,8 @@ extern int prot_mask; · 19 unmodified lines
7980
8081 /* Operational queue management definitions */
8182 #define MPI3MR_OP_REQ_Q_QD 512
82−#define MPI3MR_OP_REP_Q_QD 4096
83+#define MPI3MR_OP_REP_Q_QD 1024
84+#define MPI3MR_OP_REP_Q_QD4K 4096
8385 #define MPI3MR_OP_REQ_Q_SEG_SIZE 4096
8486 #define MPI3MR_OP_REP_Q_SEG_SIZE 4096
8587 #define MPI3MR_MAX_SEG_LIST_SIZE 4096
@@ -90,25 +92,31 @@ extern int prot_mask; · 4 unmodified lines
9092 #define MPI3MR_HOSTTAG_IOCTLCMDS 2
9193 #define MPI3MR_HOSTTAG_BLK_TMS 5
9294
93−#define MPI3MR_NUM_DEVRMCMD 1
95+#define MPI3MR_NUM_DEVRMCMD 16
9496 #define MPI3MR_HOSTTAG_DEVRMCMD_MIN (MPI3MR_HOSTTAG_BLK_TMS + 1)
9597 #define MPI3MR_HOSTTAG_DEVRMCMD_MAX (MPI3MR_HOSTTAG_DEVRMCMD_MIN + \
9698 MPI3MR_NUM_DEVRMCMD - 1)
9799
98−#define MPI3MR_INTERNAL_CMDS_RESVD MPI3MR_HOSTTAG_DEVRMCMD_MAX
100+#define MPI3MR_INTERNAL_CMDS_RESVD MPI3MR_HOSTTAG_DEVRMCMD_MAX
101+#define MPI3MR_NUM_EVTACKCMD 4
102+#define MPI3MR_HOSTTAG_EVTACKCMD_MIN (MPI3MR_HOSTTAG_DEVRMCMD_MAX + 1)
103+#define MPI3MR_HOSTTAG_EVTACKCMD_MAX (MPI3MR_HOSTTAG_EVTACKCMD_MIN + \
104+ MPI3MR_NUM_EVTACKCMD - 1)
99105
100106 /* Reduced resource count definition for crash kernel */
101107 #define MPI3MR_HOST_IOS_KDUMP 128
102108
103109 /* command/controller interaction timeout definitions in seconds */
104−#define MPI3MR_INTADMCMD_TIMEOUT 10
110+#define MPI3MR_INTADMCMD_TIMEOUT 60
105111 #define MPI3MR_PORTENABLE_TIMEOUT 300
106−#define MPI3MR_ABORTTM_TIMEOUT 30
107−#define MPI3MR_RESETTM_TIMEOUT 30
112+#define MPI3MR_ABORTTM_TIMEOUT 60
113+#define MPI3MR_RESETTM_TIMEOUT 60
108114 #define MPI3MR_RESET_HOST_IOWAIT_TIMEOUT 5
109115 #define MPI3MR_TSUPDATE_INTERVAL 900
110116 #define MPI3MR_DEFAULT_SHUTDOWN_TIME 120
111117 #define MPI3MR_RAID_ERRREC_RESET_TIMEOUT 180
118+#define MPI3MR_PREPARE_FOR_RESET_TIMEOUT 180
119+#define MPI3MR_RESET_ACK_TIMEOUT 30
112120
113121 #define MPI3MR_WATCHDOG_INTERVAL 1000 /* in milli seconds */
114122
@@ -121,7 +129,7 @@ extern int prot_mask; · 6 unmodified lines
121129
122130 /* Definitions for Event replies and sense buffer allocated per controller */
123131 #define MPI3MR_NUM_EVT_REPLIES 64
124−#define MPI3MR_SENSEBUF_SZ 256
132+#define MPI3MR_SENSE_BUF_SZ 256
125133 #define MPI3MR_SENSEBUF_FACTOR 3
126134 #define MPI3MR_CHAINBUF_FACTOR 3
127135 #define MPI3MR_CHAINBUFDIX_FACTOR 2
@@ -135,17 +143,11 @@ extern int prot_mask; · 7 unmodified lines
135143
136144 /* ResponseCode definitions */
137145 #define MPI3MR_RI_MASK_RESPCODE (0x000000FF)
138−#define MPI3MR_RSP_TM_COMPLETE 0x00
139−#define MPI3MR_RSP_INVALID_FRAME 0x02
140−#define MPI3MR_RSP_TM_NOT_SUPPORTED 0x04
141−#define MPI3MR_RSP_TM_FAILED 0x05
142−#define MPI3MR_RSP_TM_SUCCEEDED 0x08
143−#define MPI3MR_RSP_TM_INVALID_LUN 0x09
144−#define MPI3MR_RSP_TM_OVERLAPPED_TAG 0x0A
145146 #define MPI3MR_RSP_IO_QUEUED_ON_IOC \
146147 MPI3_SCSITASKMGMT_RSPCODE_IO_QUEUED_ON_IOC
147148
148149 #define MPI3MR_DEFAULT_MDTS (128 * 1024)
150+#define MPI3MR_DEFAULT_PGSZEXP (12)
149151 /* Command retry count definitions */
150152 #define MPI3MR_DEV_RMHS_RETRY_COUNT 3
151153
@@ -183,20 +185,6 @@ enum mpi3mr_iocstate { · 31 unmodified lines
183185 MRIOC_STATE_UNRECOVERABLE,
184186 };
185187
186−/* Init type definitions */
187−enum mpi3mr_init_type {
188− MPI3MR_IT_INIT = 0,
189− MPI3MR_IT_RESET,
190− MPI3MR_IT_RESUME,
191−};
192−
193−/* Cleanup reason definitions */
194−enum mpi3mr_cleanup_reason {
195− MPI3MR_COMPLETE_CLEANUP = 0,
196− MPI3MR_REINIT_FAILURE,
197− MPI3MR_SUSPEND,
198−};
199−
200188 /* Reset reason code definitions*/
201189 enum mpi3mr_reset_reason {
202190 MPI3MR_RESET_FROM_BRINGUP = 1,
@@ -222,7 +210,14 @@ enum mpi3mr_reset_reason { · 19 unmodified lines
222210 MPI3MR_RESET_FROM_GETPKGVER_TIMEOUT = 21,
223211 MPI3MR_RESET_FROM_PELABORT_TIMEOUT = 22,
224212 MPI3MR_RESET_FROM_SYSFS = 23,
225− MPI3MR_RESET_FROM_SYSFS_TIMEOUT = 24
213+ MPI3MR_RESET_FROM_SYSFS_TIMEOUT = 24,
214+ MPI3MR_RESET_FROM_FIRMWARE = 27,
215+};
216+
217+/* Queue type definitions */
218+enum queue_type {
219+ MPI3MR_DEFAULT_QUEUE = 0,
220+ MPI3MR_POLL_QUEUE,
226221 };
227222
228223 /**
@@ -263,7 +258,7 @@ struct mpi3mr_ioc_facts { · 34 unmodified lines
263258 u16 max_vds;
264259 u16 max_hpds;
265260 u16 max_advhpds;
266− u16 max_raidpds;
261+ u16 max_raid_pds;
267262 u16 min_devhandle;
268263 u16 max_devhandle;
269264 u16 max_op_req_q;
@@ -336,6 +331,7 @@ struct op_req_qinfo { · 66 unmodified lines
336331 * @pend_ios: Number of IOs pending in HW for this queue
337332 * @enable_irq_poll: Flag to indicate polling is enabled
338333 * @in_use: Queue is handled by poll/ISR
334+ * @qtype: Type of queue (types defined in enum queue_type)
339335 */
340336 struct op_reply_qinfo {
341337 u16 ci;
@@ -350,6 +346,7 @@ struct op_reply_qinfo { · 8 unmodified lines
350346 atomic_t pend_ios;
351347 bool enable_irq_poll;
352348 atomic_t in_use;
349+ enum queue_type qtype;
353350 };
354351
355352 /**
@@ -388,6 +385,7 @@ struct tgt_dev_sas_sata { · 32 unmodified lines
388385 * @pgsz: Device page size
389386 * @abort_to: Timeout for abort TM
390387 * @reset_to: Timeout for Target/LUN reset TM
388+ * @dev_info: Device information bits
391389 */
392390 struct tgt_dev_pcie {
393391 u32 mdts;
@@ -395,6 +393,7 @@ struct tgt_dev_pcie { · 1 unmodified line
395393 u8 pgsz;
396394 u8 abort_to;
397395 u8 reset_to;
396+ u16 dev_info;
398397 };
399398
400399 /**
@@ -499,6 +498,8 @@ static inline void mpi3mr_tgtdev_put(struct mpi3mr_tgt_dev *s) · 98 unmodified lines
499498 * @dev_removedelay: Device is waiting to be removed in FW
500499 * @dev_type: Device type
501500 * @tgt_dev: Internal target device pointer
501+ * @pend_count: Counter to track pending I/Os during error
502+ * handling
502503 */
503504 struct mpi3mr_stgt_priv_data {
504505 struct scsi_target *starget;
@@ -510,6 +511,7 @@ struct mpi3mr_stgt_priv_data { · 5 unmodified lines
510511 u8 dev_removedelay;
511512 u8 dev_type;
512513 struct mpi3mr_tgt_dev *tgt_dev;
514+ u32 pend_count;
513515 };
514516
515517 /**
@@ -518,11 +520,14 @@ struct mpi3mr_stgt_priv_data { · 2 unmodified lines
518520 * @tgt_priv_data: Scsi_target private data pointer
519521 * @lun_id: LUN ID of the device
520522 * @ncq_prio_enable: NCQ priority enable for SATA device
523+ * @pend_count: Counter to track pending I/Os during error
524+ * handling
521525 */
522526 struct mpi3mr_sdev_priv_data {
523527 struct mpi3mr_stgt_priv_data *tgt_priv_data;
524528 u32 lun_id;
525529 u8 ncq_prio_enable;
530+ u32 pend_count;
526531 };
527532
528533 /**
@@ -630,6 +635,7 @@ struct scmd_priv { · 101 unmodified lines
630635 * @ready_timeout: Controller ready timeout
631636 * @intr_info: Interrupt cookie pointer
632637 * @intr_info_count: Number of interrupt cookies
638+ * @is_intr_info_set: Flag to indicate intr info is setup
633639 * @num_queues: Number of operational queues
634640 * @num_op_req_q: Number of operational request queues
635641 * @req_qinfo: Operational request queue info pointer
@@ -681,17 +687,23 @@ struct scmd_priv { · 45 unmodified lines
681687 * @chain_buf_lock: Chain buffer list lock
682688 * @host_tm_cmds: Command tracker for task management commands
683689 * @dev_rmhs_cmds: Command tracker for device removal commands
690+ * @evtack_cmds: Command tracker for event ack commands
684691 * @devrem_bitmap_sz: Device removal bitmap size
685692 * @devrem_bitmap: Device removal bitmap
686693 * @dev_handle_bitmap_sz: Device handle bitmap size
687694 * @removepend_bitmap: Remove pending bitmap
688695 * @delayed_rmhs_list: Delayed device removal list
696+ * @evtack_cmds_bitmap_sz: Event Ack bitmap size
697+ * @evtack_cmds_bitmap: Event Ack bitmap
698+ * @delayed_evtack_cmds_list: Delayed event acknowledgment list
689699 * @ts_update_counter: Timestamp update counter
690− * @fault_dbg: Fault debug flag
691700 * @reset_in_progress: Reset in progress flag
692701 * @unrecoverable: Controller unrecoverable flag
702+ * @prev_reset_result: Result of previous reset
693703 * @reset_mutex: Controller reset mutex
694704 * @reset_waitq: Controller reset wait queue
705+ * @prepare_for_reset: Prepare for reset event received
706+ * @prepare_for_reset_timeout_counter: Prepare for reset timeout
695707 * @diagsave_timeout: Diagnostic information save timeout
696708 * @logging_level: Controller debug logging level
697709 * @flush_io_count: I/O count to flush after reset
@@ -699,6 +711,9 @@ struct scmd_priv { · 1 unmodified line
699711 * @driver_info: Driver, Kernel, OS information to firmware
700712 * @change_count: Topology change count
701713 * @op_reply_q_offset: Operational reply queue offset with MSIx
714+ * @default_qcount: Total Default queues
715+ * @active_poll_qcount: Currently active poll queue count
716+ * @requested_poll_qcount: User requested poll queue count
702717 */
703718 struct mpi3mr_ioc {
704719 struct list_head list;
@@ -739,6 +754,7 @@ struct mpi3mr_ioc { · 34 unmodified lines
739754
740755 struct mpi3mr_intr_info *intr_info;
741756 u16 intr_info_count;
757+ bool is_intr_info_set;
742758
743759 u16 num_queues;
744760 u16 num_op_req_q;
@@ -758,6 +774,7 @@ struct mpi3mr_ioc { · 13 unmodified lines
758774 dma_addr_t reply_buf_dma_max_address;
759775
760776 u16 reply_free_qsz;
777+ u16 reply_sz;
761778 struct dma_pool *reply_free_q_pool;
762779 __le64 *reply_free_q;
763780 dma_addr_t reply_free_q_dma;
@@ -805,19 +822,26 @@ struct mpi3mr_ioc { · 41 unmodified lines
805822
806823 struct mpi3mr_drv_cmd host_tm_cmds;
807824 struct mpi3mr_drv_cmd dev_rmhs_cmds[MPI3MR_NUM_DEVRMCMD];
825+ struct mpi3mr_drv_cmd evtack_cmds[MPI3MR_NUM_EVTACKCMD];
808826 u16 devrem_bitmap_sz;
809827 void *devrem_bitmap;
810828 u16 dev_handle_bitmap_sz;
811829 void *removepend_bitmap;
812830 struct list_head delayed_rmhs_list;
831+ u16 evtack_cmds_bitmap_sz;
832+ void *evtack_cmds_bitmap;
833+ struct list_head delayed_evtack_cmds_list;
813834
814835 u32 ts_update_counter;
815− u8 fault_dbg;
816836 u8 reset_in_progress;
817837 u8 unrecoverable;
838+ int prev_reset_result;
818839 struct mutex reset_mutex;
819840 wait_queue_head_t reset_waitq;
820841
842+ u8 prepare_for_reset;
843+ u16 prepare_for_reset_timeout_counter;
844+
821845 u16 diagsave_timeout;
822846 int logging_level;
823847 u16 flush_io_count;
@@ -826,6 +850,10 @@ struct mpi3mr_ioc { · 2 unmodified lines
826850 struct mpi3_driver_info_layout driver_info;
827851 u16 change_count;
828852 u16 op_reply_q_offset;
853+
854+ u16 default_qcount;
855+ u16 active_poll_qcount;
856+ u16 requested_poll_qcount;
829857 };
830858
831859 /**
@@ -867,10 +895,23 @@ struct delayed_dev_rmhs_node { · 35 unmodified lines
867895 u8 iou_rc;
868896 };
869897
898+/**
899+ * struct delayed_evt_ack_node - Delayed event ack node
900+ * @list: list head
901+ * @event: MPI3 event ID
902+ * @event_ctx: event context
903+ */
904+struct delayed_evt_ack_node {
905+ struct list_head list;
906+ u8 event;
907+ u32 event_ctx;
908+};
909+
870910 int mpi3mr_setup_resources(struct mpi3mr_ioc *mrioc);
871911 void mpi3mr_cleanup_resources(struct mpi3mr_ioc *mrioc);
872−int mpi3mr_init_ioc(struct mpi3mr_ioc *mrioc, u8 init_type);
873−void mpi3mr_cleanup_ioc(struct mpi3mr_ioc *mrioc, u8 reason);
912+int mpi3mr_init_ioc(struct mpi3mr_ioc *mrioc);
913+int mpi3mr_reinit_ioc(struct mpi3mr_ioc *mrioc, u8 is_resume);
914+void mpi3mr_cleanup_ioc(struct mpi3mr_ioc *mrioc);
874915 int mpi3mr_issue_port_enable(struct mpi3mr_ioc *mrioc, u8 async);
875916 int mpi3mr_admin_request_post(struct mpi3mr_ioc *mrioc, void *admin_req,
876917 u16 admin_req_sz, u8 ignore_reset);
@@ -887,6 +928,7 @@ void mpi3mr_repost_sense_buf(struct mpi3mr_ioc *mrioc, · 10 unmodified lines
887928 u64 sense_buf_dma);
888929
889930 void mpi3mr_memset_buffers(struct mpi3mr_ioc *mrioc);
931+void mpi3mr_free_mem(struct mpi3mr_ioc *mrioc);
890932 void mpi3mr_os_handle_events(struct mpi3mr_ioc *mrioc,
891933 struct mpi3_event_notification_reply *event_reply);
892934 void mpi3mr_process_op_reply_desc(struct mpi3mr_ioc *mrioc,
@@ -897,13 +939,11 @@ void mpi3mr_stop_watchdog(struct mpi3mr_ioc *mrioc); · 4 unmodified lines
897939
898940 int mpi3mr_soft_reset_handler(struct mpi3mr_ioc *mrioc,
899941 u32 reset_reason, u8 snapdump);
900−int mpi3mr_diagfault_reset_handler(struct mpi3mr_ioc *mrioc,
901− u32 reset_reason);
902942 void mpi3mr_ioc_disable_intr(struct mpi3mr_ioc *mrioc);
903943 void mpi3mr_ioc_enable_intr(struct mpi3mr_ioc *mrioc);
904944
905945 enum mpi3mr_iocstate mpi3mr_get_iocstate(struct mpi3mr_ioc *mrioc);
906−int mpi3mr_send_event_ack(struct mpi3mr_ioc *mrioc, u8 event,
946+int mpi3mr_process_event_ack(struct mpi3mr_ioc *mrioc, u8 event,
907947 u32 event_ctx);
908948
909949 void mpi3mr_wait_for_host_io(struct mpi3mr_ioc *mrioc, u32 timeout);
@@ -911,6 +951,12 @@ void mpi3mr_cleanup_fwevt_list(struct mpi3mr_ioc *mrioc); · 1 unmodified line
911951 void mpi3mr_flush_host_io(struct mpi3mr_ioc *mrioc);
912952 void mpi3mr_invalidate_devhandles(struct mpi3mr_ioc *mrioc);
913953 void mpi3mr_rfresh_tgtdevs(struct mpi3mr_ioc *mrioc);
914−void mpi3mr_flush_delayed_rmhs_list(struct mpi3mr_ioc *mrioc);
954+void mpi3mr_flush_delayed_cmd_lists(struct mpi3mr_ioc *mrioc);
955+void mpi3mr_check_rh_fault_ioc(struct mpi3mr_ioc *mrioc, u32 reason_code);
956+void mpi3mr_print_fault_info(struct mpi3mr_ioc *mrioc);
957+void mpi3mr_check_rh_fault_ioc(struct mpi3mr_ioc *mrioc, u32 reason_code);
958+int mpi3mr_process_op_reply_q(struct mpi3mr_ioc *mrioc,
959+ struct op_reply_qinfo *op_reply_q);
960+int mpi3mr_blk_mq_poll(struct Scsi_Host *shost, unsigned int queue_num);
915961
916962 #endif /*MPI3MR_H_INCLUDED*/
drivers/scsi/mpi3mr/mpi3mr_debug.h+109−24
@@ -14,27 +14,20 @@ · 13 unmodified lines
1414 /*
1515 * debug levels
1616 */
17−#define MPI3_DEBUG 0x00000001
18−#define MPI3_DEBUG_MSG_FRAME 0x00000002
19−#define MPI3_DEBUG_SG 0x00000004
20−#define MPI3_DEBUG_EVENTS 0x00000008
21−#define MPI3_DEBUG_EVENT_WORK_TASK 0x00000010
22−#define MPI3_DEBUG_INIT 0x00000020
23−#define MPI3_DEBUG_EXIT 0x00000040
24−#define MPI3_DEBUG_FAIL 0x00000080
25−#define MPI3_DEBUG_TM 0x00000100
26−#define MPI3_DEBUG_REPLY 0x00000200
27−#define MPI3_DEBUG_HANDSHAKE 0x00000400
28−#define MPI3_DEBUG_CONFIG 0x00000800
29−#define MPI3_DEBUG_DL 0x00001000
30−#define MPI3_DEBUG_RESET 0x00002000
31−#define MPI3_DEBUG_SCSI 0x00004000
32−#define MPI3_DEBUG_IOCTL 0x00008000
33−#define MPI3_DEBUG_CSMISAS 0x00010000
34−#define MPI3_DEBUG_SAS 0x00020000
35−#define MPI3_DEBUG_TRANSPORT 0x00040000
36−#define MPI3_DEBUG_TASK_SET_FULL 0x00080000
37−#define MPI3_DEBUG_TRIGGER_DIAG 0x00200000
17+
18+#define MPI3_DEBUG_EVENT 0x00000001
19+#define MPI3_DEBUG_EVENT_WORK_TASK 0x00000002
20+#define MPI3_DEBUG_INIT 0x00000004
21+#define MPI3_DEBUG_EXIT 0x00000008
22+#define MPI3_DEBUG_TM 0x00000010
23+#define MPI3_DEBUG_RESET 0x00000020
24+#define MPI3_DEBUG_SCSI_ERROR 0x00000040
25+#define MPI3_DEBUG_REPLY 0x00000080
26+#define MPI3_DEBUG_IOCTL_ERROR 0x00008000
27+#define MPI3_DEBUG_IOCTL_INFO 0x00010000
28+#define MPI3_DEBUG_SCSI_INFO 0x00020000
29+#define MPI3_DEBUG 0x01000000
30+#define MPI3_DEBUG_SG 0x02000000
3831
3932
4033 /*
@@ -50,11 +43,103 @@ · 9 unmodified lines
5043 #define ioc_info(ioc, fmt, ...) \
5144 pr_info("%s: " fmt, (ioc)->name, ##__VA_ARGS__)
5245
46+#define dprint(ioc, fmt, ...) \
47+ do { \
48+ if (ioc->logging_level & MPI3_DEBUG) \
49+ pr_info("%s: " fmt, (ioc)->name, ##__VA_ARGS__); \
50+ } while (0)
51+
52+#define dprint_event_th(ioc, fmt, ...) \
53+ do { \
54+ if (ioc->logging_level & MPI3_DEBUG_EVENT) \
55+ pr_info("%s: " fmt, (ioc)->name, ##__VA_ARGS__); \
56+ } while (0)
57+
58+#define dprint_event_bh(ioc, fmt, ...) \
59+ do { \
60+ if (ioc->logging_level & MPI3_DEBUG_EVENT_WORK_TASK) \
61+ pr_info("%s: " fmt, (ioc)->name, ##__VA_ARGS__); \
62+ } while (0)
63+
64+#define dprint_init(ioc, fmt, ...) \
65+ do { \
66+ if (ioc->logging_level & MPI3_DEBUG_INIT) \
67+ pr_info("%s: " fmt, (ioc)->name, ##__VA_ARGS__); \
68+ } while (0)
69+
70+#define dprint_exit(ioc, fmt, ...) \
71+ do { \
72+ if (ioc->logging_level & MPI3_DEBUG_EXIT) \
73+ pr_info("%s: " fmt, (ioc)->name, ##__VA_ARGS__); \
74+ } while (0)
75+
76+#define dprint_tm(ioc, fmt, ...) \
77+ do { \
78+ if (ioc->logging_level & MPI3_DEBUG_TM) \
79+ pr_info("%s: " fmt, (ioc)->name, ##__VA_ARGS__); \
80+ } while (0)
81+
82+#define dprint_reply(ioc, fmt, ...) \
83+ do { \
84+ if (ioc->logging_level & MPI3_DEBUG_REPLY) \
85+ pr_info("%s: " fmt, (ioc)->name, ##__VA_ARGS__); \
86+ } while (0)
87+
88+#define dprint_reset(ioc, fmt, ...) \
89+ do { \
90+ if (ioc->logging_level & MPI3_DEBUG_RESET) \
91+ pr_info("%s: " fmt, (ioc)->name, ##__VA_ARGS__); \
92+ } while (0)
93+
94+#define dprint_scsi_info(ioc, fmt, ...) \
95+ do { \
96+ if (ioc->logging_level & MPI3_DEBUG_SCSI_INFO) \
97+ pr_info("%s: " fmt, (ioc)->name, ##__VA_ARGS__); \
98+ } while (0)
99+
100+#define dprint_scsi_err(ioc, fmt, ...) \
101+ do { \
102+ if (ioc->logging_level & MPI3_DEBUG_SCSI_ERROR) \
103+ pr_info("%s: " fmt, (ioc)->name, ##__VA_ARGS__); \
104+ } while (0)
105+
106+#define dprint_scsi_command(ioc, SCMD, LOG_LEVEL) \
107+ do { \
108+ if (ioc->logging_level & LOG_LEVEL) \
109+ scsi_print_command(SCMD); \
110+ } while (0)
111+
112+
113+#define dprint_ioctl_info(ioc, fmt, ...) \
114+ do { \
115+ if (ioc->logging_level & MPI3_DEBUG_IOCTL_INFO) \
116+ pr_info("%s: " fmt, (ioc)->name, ##__VA_ARGS__); \
117+ } while (0)
53118
54−#define dbgprint(IOC, FMT, ...) \
119+#define dprint_ioctl_err(ioc, fmt, ...) \
55120 do { \
56− if (IOC->logging_level & MPI3_DEBUG) \
57− pr_info("%s: " FMT, (IOC)->name, ##__VA_ARGS__); \
121+ if (ioc->logging_level & MPI3_DEBUG_IOCTL_ERROR) \
122+ pr_info("%s: " fmt, (ioc)->name, ##__VA_ARGS__); \
58123 } while (0)
59124
60125 #endif /* MPT3SAS_DEBUG_H_INCLUDED */
126+
127+/**
128+ * dprint_dump_req - print message frame contents
129+ * @req: pointer to message frame
130+ * @sz: number of dwords
131+ */
132+static inline void
133+dprint_dump_req(void *req, int sz)
134+{
135+ int i;
136+ __le32 *mfp = (__le32 *)req;
137+
138+ pr_info("request:\n\t");
139+ for (i = 0; i < sz; i++) {
140+ if (i && ((i % 8) == 0))
141+ pr_info("\n\t");
142+ pr_info("%08x ", le32_to_cpu(mfp[i]));
143+ }
144+ pr_info("\n");
145+}
drivers/scsi/mpi3mr/mpi3mr_fw.c+951−500
@@ -10,6 +10,16 @@ · 9 unmodified lines
1010 #include "mpi3mr.h"
1111 #include <linux/io-64-nonatomic-lo-hi.h>
1212
13+static int
14+mpi3mr_issue_reset(struct mpi3mr_ioc *mrioc, u16 reset_type, u32 reset_reason);
15+static int mpi3mr_setup_admin_qpair(struct mpi3mr_ioc *mrioc);
16+static void mpi3mr_process_factsdata(struct mpi3mr_ioc *mrioc,
17+ struct mpi3_ioc_facts_data *facts_data);
18+
19+static int poll_queues;
20+module_param(poll_queues, int, 0444);
21+MODULE_PARM_DESC(poll_queues, "Number of queues for io_uring poll mode. (Range 1 - 126)");
22+
1323 #if defined(writeq) && defined(CONFIG_64BIT)
1424 static inline void mpi3mr_writeq(__u64 b, volatile void __iomem *addr)
1525 {
@@ -78,6 +88,7 @@ static void mpi3mr_cleanup_isr(struct mpi3mr_ioc *mrioc) · 62 unmodified lines
7888 kfree(mrioc->intr_info);
7989 mrioc->intr_info = NULL;
8090 mrioc->intr_info_count = 0;
91+ mrioc->is_intr_info_set = false;
8192 pci_free_irq_vectors(mrioc->pdev);
8293 }
8394
@@ -124,8 +135,9 @@ static void mpi3mr_repost_reply_buf(struct mpi3mr_ioc *mrioc, · 40 unmodified lines
124135 u64 reply_dma)
125136 {
126137 u32 old_idx = 0;
138+ unsigned long flags;
127139
128− spin_lock(&mrioc->reply_free_queue_lock);
140+ spin_lock_irqsave(&mrioc->reply_free_queue_lock, flags);
129141 old_idx = mrioc->reply_free_queue_host_index;
130142 mrioc->reply_free_queue_host_index = (
131143 (mrioc->reply_free_queue_host_index ==
@@ -134,15 +146,16 @@ static void mpi3mr_repost_reply_buf(struct mpi3mr_ioc *mrioc, · 2 unmodified lines
134146 mrioc->reply_free_q[old_idx] = cpu_to_le64(reply_dma);
135147 writel(mrioc->reply_free_queue_host_index,
136148 &mrioc->sysif_regs->reply_free_host_index);
137− spin_unlock(&mrioc->reply_free_queue_lock);
149+ spin_unlock_irqrestore(&mrioc->reply_free_queue_lock, flags);
138150 }
139151
140152 void mpi3mr_repost_sense_buf(struct mpi3mr_ioc *mrioc,
141153 u64 sense_buf_dma)
142154 {
143155 u32 old_idx = 0;
156+ unsigned long flags;
144157
145− spin_lock(&mrioc->sbq_lock);
158+ spin_lock_irqsave(&mrioc->sbq_lock, flags);
146159 old_idx = mrioc->sbq_host_index;
147160 mrioc->sbq_host_index = ((mrioc->sbq_host_index ==
148161 (mrioc->sense_buf_q_sz - 1)) ? 0 :
@@ -150,7 +163,7 @@ void mpi3mr_repost_sense_buf(struct mpi3mr_ioc *mrioc, · 1 unmodified line
150163 mrioc->sense_buf_q[old_idx] = cpu_to_le64(sense_buf_dma);
151164 writel(mrioc->sbq_host_index,
152165 &mrioc->sysif_regs->sense_buffer_free_host_index);
153− spin_unlock(&mrioc->sbq_lock);
166+ spin_unlock_irqrestore(&mrioc->sbq_lock, flags);
154167 }
155168
156169 static void mpi3mr_print_event_data(struct mpi3mr_ioc *mrioc,
@@ -303,6 +316,12 @@ mpi3mr_get_drv_cmd(struct mpi3mr_ioc *mrioc, u16 host_tag, · 146 unmodified lines
303316 return &mrioc->dev_rmhs_cmds[idx];
304317 }
305318
319+ if (host_tag >= MPI3MR_HOSTTAG_EVTACKCMD_MIN &&
320+ host_tag <= MPI3MR_HOSTTAG_EVTACKCMD_MAX) {
321+ idx = host_tag - MPI3MR_HOSTTAG_EVTACKCMD_MIN;
322+ return &mrioc->evtack_cmds[idx];
323+ }
324+
306325 return NULL;
307326 }
308327
@@ -369,7 +388,7 @@ static void mpi3mr_process_admin_reply_desc(struct mpi3mr_ioc *mrioc, · 60 unmodified lines
369388 if (def_reply) {
370389 cmdptr->state |= MPI3MR_CMD_REPLY_VALID;
371390 memcpy((u8 *)cmdptr->reply, (u8 *)def_reply,
372− mrioc->facts.reply_sz);
391+ mrioc->reply_sz);
373392 }
374393 if (cmdptr->is_waiting) {
375394 complete(&cmdptr->done);
@@ -446,10 +465,21 @@ mpi3mr_get_reply_desc(struct op_reply_qinfo *op_reply_q, u32 reply_ci) · 70 unmodified lines
446465 return reply_desc;
447466 }
448467
449−static int mpi3mr_process_op_reply_q(struct mpi3mr_ioc *mrioc,
450− struct mpi3mr_intr_info *intr_info)
468+/**
469+ * mpi3mr_process_op_reply_q - Operational reply queue handler
470+ * @mrioc: Adapter instance reference
471+ * @op_reply_q: Operational reply queue info
472+ *
473+ * Checks the specific operational reply queue and drains the
474+ * reply queue entries until the queue is empty and process the
475+ * individual reply descriptors.
476+ *
477+ * Return: 0 if queue is already processed,or number of reply
478+ * descriptors processed.
479+ */
480+int mpi3mr_process_op_reply_q(struct mpi3mr_ioc *mrioc,
481+ struct op_reply_qinfo *op_reply_q)
451482 {
452− struct op_reply_qinfo *op_reply_q = intr_info->op_reply_q;
453483 struct op_req_qinfo *op_req_q;
454484 u32 exp_phase;
455485 u32 reply_ci;
@@ -500,7 +530,7 @@ static int mpi3mr_process_op_reply_q(struct mpi3mr_ioc *mrioc, · 44 unmodified lines
500530 * Ensure remaining completion happens from threaded ISR.
501531 */
502532 if (num_op_reply > mrioc->max_host_ios) {
503− intr_info->op_reply_q->enable_irq_poll = true;
533+ op_reply_q->enable_irq_poll = true;
504534 break;
505535 }
506536
@@ -515,6 +545,34 @@ static int mpi3mr_process_op_reply_q(struct mpi3mr_ioc *mrioc, · 8 unmodified lines
515545 return num_op_reply;
516546 }
517547
548+/**
549+ * mpi3mr_blk_mq_poll - Operational reply queue handler
550+ * @shost: SCSI Host reference
551+ * @queue_num: Request queue number (w.r.t OS it is hardware context number)
552+ *
553+ * Checks the specific operational reply queue and drains the
554+ * reply queue entries until the queue is empty and process the
555+ * individual reply descriptors.
556+ *
557+ * Return: 0 if queue is already processed,or number of reply
558+ * descriptors processed.
559+ */
560+int mpi3mr_blk_mq_poll(struct Scsi_Host *shost, unsigned int queue_num)
561+{
562+ int num_entries = 0;
563+ struct mpi3mr_ioc *mrioc;
564+
565+ mrioc = (struct mpi3mr_ioc *)shost->hostdata;
566+
567+ if ((mrioc->reset_in_progress || mrioc->prepare_for_reset))
568+ return 0;
569+
570+ num_entries = mpi3mr_process_op_reply_q(mrioc,
571+ &mrioc->op_reply_qinfo[queue_num]);
572+
573+ return num_entries;
574+}
575+
518576 static irqreturn_t mpi3mr_isr_primary(int irq, void *privdata)
519577 {
520578 struct mpi3mr_intr_info *intr_info = privdata;
@@ -535,7 +593,8 @@ static irqreturn_t mpi3mr_isr_primary(int irq, void *privdata) · 14 unmodified lines
535593 if (!midx)
536594 num_admin_replies = mpi3mr_process_admin_reply_q(mrioc);
537595 if (intr_info->op_reply_q)
538− num_op_reply = mpi3mr_process_op_reply_q(mrioc, intr_info);
596+ num_op_reply = mpi3mr_process_op_reply_q(mrioc,
597+ intr_info->op_reply_q);
539598
540599 if (num_admin_replies || num_op_reply)
541600 return IRQ_HANDLED;
@@ -606,9 +665,10 @@ static irqreturn_t mpi3mr_isr_poll(int irq, void *privdata) · 64 unmodified lines
606665 mpi3mr_process_admin_reply_q(mrioc);
607666 if (intr_info->op_reply_q)
608667 num_op_reply +=
609− mpi3mr_process_op_reply_q(mrioc, intr_info);
668+ mpi3mr_process_op_reply_q(mrioc,
669+ intr_info->op_reply_q);
610670
611− usleep_range(mrioc->irqpoll_sleep, 10 * mrioc->irqpoll_sleep);
671+ usleep_range(MPI3MR_IRQ_POLL_SLEEP, 10 * MPI3MR_IRQ_POLL_SLEEP);
612672
613673 } while (atomic_read(&intr_info->op_reply_q->pend_ios) &&
614674 (num_op_reply < mrioc->max_host_ios));
@@ -652,6 +712,25 @@ static inline int mpi3mr_request_irq(struct mpi3mr_ioc *mrioc, u16 index) · 37 unmodified lines
652712 return retval;
653713 }
654714
715+static void mpi3mr_calc_poll_queues(struct mpi3mr_ioc *mrioc, u16 max_vectors)
716+{
717+ if (!mrioc->requested_poll_qcount)
718+ return;
719+
720+ /* Reserved for Admin and Default Queue */
721+ if (max_vectors > 2 &&
722+ (mrioc->requested_poll_qcount < max_vectors - 2)) {
723+ ioc_info(mrioc,
724+ "enabled polled queues (%d) msix (%d)\n",
725+ mrioc->requested_poll_qcount, max_vectors);
726+ } else {
727+ ioc_info(mrioc,
728+ "disabled polled queues (%d) msix (%d) because of no resources for default queue\n",
729+ mrioc->requested_poll_qcount, max_vectors);
730+ mrioc->requested_poll_qcount = 0;
731+ }
732+}
733+
655734 /**
656735 * mpi3mr_setup_isr - Setup ISR for the controller
657736 * @mrioc: Adapter instance reference
@@ -664,48 +743,72 @@ static inline int mpi3mr_request_irq(struct mpi3mr_ioc *mrioc, u16 index) · 6 unmodified lines
664743 static int mpi3mr_setup_isr(struct mpi3mr_ioc *mrioc, u8 setup_one)
665744 {
666745 unsigned int irq_flags = PCI_IRQ_MSIX;
667− int max_vectors;
746+ int max_vectors, min_vec;
668747 int retval;
669748 int i;
670− struct irq_affinity desc = { .pre_vectors = 1};
749+ struct irq_affinity desc = { .pre_vectors = 1, .post_vectors = 1 };
750+
751+ if (mrioc->is_intr_info_set)
752+ return 0;
671753
672754 mpi3mr_cleanup_isr(mrioc);
673755
674− if (setup_one || reset_devices)
756+ if (setup_one || reset_devices) {
675757 max_vectors = 1;
676− else {
758+ retval = pci_alloc_irq_vectors(mrioc->pdev,
759+ 1, max_vectors, irq_flags);
760+ if (retval < 0) {
761+ ioc_err(mrioc, "cannot allocate irq vectors, ret %d\n",
762+ retval);
763+ goto out_failed;
764+ }
765+ } else {
677766 max_vectors =
678− min_t(int, mrioc->cpu_count + 1, mrioc->msix_count);
767+ min_t(int, mrioc->cpu_count + 1 +
768+ mrioc->requested_poll_qcount, mrioc->msix_count);
769+
770+ mpi3mr_calc_poll_queues(mrioc, max_vectors);
679771
680772 ioc_info(mrioc,
681773 "MSI-X vectors supported: %d, no of cores: %d,",
682774 mrioc->msix_count, mrioc->cpu_count);
683775 ioc_info(mrioc,
684− "MSI-x vectors requested: %d\n", max_vectors);
685− }
776+ "MSI-x vectors requested: %d poll_queues %d\n",
777+ max_vectors, mrioc->requested_poll_qcount);
778+
779+ desc.post_vectors = mrioc->requested_poll_qcount;
780+ min_vec = desc.pre_vectors + desc.post_vectors;
781+ irq_flags |= PCI_IRQ_AFFINITY | PCI_IRQ_ALL_TYPES;
782+
783+ retval = pci_alloc_irq_vectors_affinity(mrioc->pdev,
784+ min_vec, max_vectors, irq_flags, &desc);
785+
786+ if (retval < 0) {
787+ ioc_err(mrioc, "cannot allocate irq vectors, ret %d\n",
788+ retval);
789+ goto out_failed;
790+ }
686791
687− irq_flags |= PCI_IRQ_AFFINITY | PCI_IRQ_ALL_TYPES;
688792
689− mrioc->op_reply_q_offset = (max_vectors > 1) ? 1 : 0;
690− retval = pci_alloc_irq_vectors_affinity(mrioc->pdev,
691− 1, max_vectors, irq_flags, &desc);
692− if (retval < 0) {
693− ioc_err(mrioc, "Cannot alloc irq vectors\n");
694− goto out_failed;
695− }
696− if (retval != max_vectors) {
697− ioc_info(mrioc,
698− "allocated vectors (%d) are less than configured (%d)\n",
699− retval, max_vectors);
700793 /*
701794 * If only one MSI-x is allocated, then MSI-x 0 will be shared
702795 * between Admin queue and operational queue
703796 */
704− if (retval == 1)
797+ if (retval == min_vec)
705798 mrioc->op_reply_q_offset = 0;
799+ else if (retval != (max_vectors)) {
800+ ioc_info(mrioc,
801+ "allocated vectors (%d) are less than configured (%d)\n",
802+ retval, max_vectors);
803+ }
706804
707805 max_vectors = retval;
806+ mrioc->op_reply_q_offset = (max_vectors > 1) ? 1 : 0;
807+
808+ mpi3mr_calc_poll_queues(mrioc, max_vectors);
809+
708810 }
811+
709812 mrioc->intr_info = kzalloc(sizeof(struct mpi3mr_intr_info) * max_vectors,
710813 GFP_KERNEL);
711814 if (!mrioc->intr_info) {
@@ -720,6 +823,8 @@ static int mpi3mr_setup_isr(struct mpi3mr_ioc *mrioc, u8 setup_one) · 8 unmodified lines
720823 goto out_failed;
721824 }
722825 }
826+ if (reset_devices || !setup_one)
827+ mrioc->is_intr_info_set = true;
723828 mrioc->intr_info_count = max_vectors;
724829 mpi3mr_ioc_enable_intr(mrioc);
725830 return 0;
@@ -796,6 +901,7 @@ static const struct { · 70 unmodified lines
796901 },
797902 { MPI3MR_RESET_FROM_SYSFS, "sysfs invocation" },
798903 { MPI3MR_RESET_FROM_SYSFS_TIMEOUT, "sysfs TM timeout" },
904+ { MPI3MR_RESET_FROM_FIRMWARE, "firmware asynchronus reset" },
799905 };
800906
801907 /**
@@ -860,7 +966,7 @@ static const char *mpi3mr_reset_type_name(u16 reset_type) · 58 unmodified lines
860966 *
861967 * Return: Nothing.
862968 */
863−static void mpi3mr_print_fault_info(struct mpi3mr_ioc *mrioc)
969+void mpi3mr_print_fault_info(struct mpi3mr_ioc *mrioc)
864970 {
865971 u32 ioc_status, code, code1, code2, code3;
866972
@@ -958,31 +1064,91 @@ static int mpi3mr_issue_and_process_mur(struct mpi3mr_ioc *mrioc, · 91 unmodified lines
9581064 ioc_config &= ~MPI3_SYSIF_IOC_CONFIG_ENABLE_IOC;
9591065 writel(ioc_config, &mrioc->sysif_regs->ioc_configuration);
9601066
961− timeout = mrioc->ready_timeout * 10;
1067+ timeout = MPI3MR_RESET_ACK_TIMEOUT * 10;
9621068 do {
9631069 ioc_status = readl(&mrioc->sysif_regs->ioc_status);
9641070 if ((ioc_status & MPI3_SYSIF_IOC_STATUS_RESET_HISTORY)) {
9651071 mpi3mr_clear_reset_history(mrioc);
966− ioc_config =
967− readl(&mrioc->sysif_regs->ioc_configuration);
968− if (!((ioc_status & MPI3_SYSIF_IOC_STATUS_READY) ||
969− (ioc_status & MPI3_SYSIF_IOC_STATUS_FAULT) ||
970− (ioc_config & MPI3_SYSIF_IOC_CONFIG_ENABLE_IOC))) {
971− retval = 0;
972− break;
973− }
1072+ break;
1073+ }
1074+ if (ioc_status & MPI3_SYSIF_IOC_STATUS_FAULT) {
1075+ mpi3mr_print_fault_info(mrioc);
1076+ break;
9741077 }
9751078 msleep(100);
9761079 } while (--timeout);
9771080
978− ioc_status = readl(&mrioc->sysif_regs->ioc_status);
9791081 ioc_config = readl(&mrioc->sysif_regs->ioc_configuration);
1082+ if (timeout && !((ioc_status & MPI3_SYSIF_IOC_STATUS_READY) ||
1083+ (ioc_status & MPI3_SYSIF_IOC_STATUS_FAULT) ||
1084+ (ioc_config & MPI3_SYSIF_IOC_CONFIG_ENABLE_IOC)))
1085+ retval = 0;
9801086
9811087 ioc_info(mrioc, "Base IOC Sts/Config after %s MUR is (0x%x)/(0x%x)\n",
9821088 (!retval) ? "successful" : "failed", ioc_status, ioc_config);
9831089 return retval;
9841090 }
9851091
1092+/**
1093+ * mpi3mr_revalidate_factsdata - validate IOCFacts parameters
1094+ * during reset/resume
1095+ * @mrioc: Adapter instance reference
1096+ *
1097+ * Return zero if the new IOCFacts parameters value is compatible with
1098+ * older values else return -EPERM
1099+ */
1100+static int
1101+mpi3mr_revalidate_factsdata(struct mpi3mr_ioc *mrioc)
1102+{
1103+ u16 dev_handle_bitmap_sz;
1104+ void *removepend_bitmap;
1105+
1106+ if (mrioc->facts.reply_sz > mrioc->reply_sz) {
1107+ ioc_err(mrioc,
1108+ "cannot increase reply size from %d to %d\n",
1109+ mrioc->reply_sz, mrioc->facts.reply_sz);
1110+ return -EPERM;
1111+ }
1112+
1113+ if (mrioc->facts.max_op_reply_q < mrioc->num_op_reply_q) {
1114+ ioc_err(mrioc,
1115+ "cannot reduce number of operational reply queues from %d to %d\n",
1116+ mrioc->num_op_reply_q,
1117+ mrioc->facts.max_op_reply_q);
1118+ return -EPERM;
1119+ }
1120+
1121+ if (mrioc->facts.max_op_req_q < mrioc->num_op_req_q) {
1122+ ioc_err(mrioc,
1123+ "cannot reduce number of operational request queues from %d to %d\n",
1124+ mrioc->num_op_req_q, mrioc->facts.max_op_req_q);
1125+ return -EPERM;
1126+ }
1127+
1128+ dev_handle_bitmap_sz = mrioc->facts.max_devhandle / 8;
1129+ if (mrioc->facts.max_devhandle % 8)
1130+ dev_handle_bitmap_sz++;
1131+ if (dev_handle_bitmap_sz > mrioc->dev_handle_bitmap_sz) {
1132+ removepend_bitmap = krealloc(mrioc->removepend_bitmap,
1133+ dev_handle_bitmap_sz, GFP_KERNEL);
1134+ if (!removepend_bitmap) {
1135+ ioc_err(mrioc,
1136+ "failed to increase removepend_bitmap sz from: %d to %d\n",
1137+ mrioc->dev_handle_bitmap_sz, dev_handle_bitmap_sz);
1138+ return -EPERM;
1139+ }
1140+ memset(removepend_bitmap + mrioc->dev_handle_bitmap_sz, 0,
1141+ dev_handle_bitmap_sz - mrioc->dev_handle_bitmap_sz);
1142+ mrioc->removepend_bitmap = removepend_bitmap;
1143+ ioc_info(mrioc,
1144+ "increased dev_handle_bitmap_sz from %d to %d\n",
1145+ mrioc->dev_handle_bitmap_sz, dev_handle_bitmap_sz);
1146+ mrioc->dev_handle_bitmap_sz = dev_handle_bitmap_sz;
1147+ }
1148+
1149+ return 0;
1150+}
1151+
9861152 /**
9871153 * mpi3mr_bring_ioc_ready - Bring controller to ready state
9881154 * @mrioc: Adapter instance reference
@@ -990,26 +1156,105 @@ static int mpi3mr_issue_and_process_mur(struct mpi3mr_ioc *mrioc, · 1 unmodified line
9901156 * Set Enable IOC bit in IOC configuration register and wait for
9911157 * the controller to become ready.
9921158 *
993− * Return: 0 on success, -1 on failure.
1159+ * Return: 0 on success, appropriate error on failure.
9941160 */
9951161 static int mpi3mr_bring_ioc_ready(struct mpi3mr_ioc *mrioc)
9961162 {
997− u32 ioc_config, timeout;
998− enum mpi3mr_iocstate current_state;
1163+ u32 ioc_config, ioc_status, timeout;
1164+ int retval = 0;
1165+ enum mpi3mr_iocstate ioc_state;
1166+ u64 base_info;
1167+
1168+ ioc_status = readl(&mrioc->sysif_regs->ioc_status);
1169+ ioc_config = readl(&mrioc->sysif_regs->ioc_configuration);
1170+ base_info = lo_hi_readq(&mrioc->sysif_regs->ioc_information);
1171+ ioc_info(mrioc, "ioc_status(0x%08x), ioc_config(0x%08x), ioc_info(0x%016llx) at the bringup\n",
1172+ ioc_status, ioc_config, base_info);
1173+
1174+ /*The timeout value is in 2sec unit, changing it to seconds*/
1175+ mrioc->ready_timeout =
1176+ ((base_info & MPI3_SYSIF_IOC_INFO_LOW_TIMEOUT_MASK) >>
1177+ MPI3_SYSIF_IOC_INFO_LOW_TIMEOUT_SHIFT) * 2;
1178+
1179+ ioc_info(mrioc, "ready timeout: %d seconds\n", mrioc->ready_timeout);
1180+
1181+ ioc_state = mpi3mr_get_iocstate(mrioc);
1182+ ioc_info(mrioc, "controller is in %s state during detection\n",
1183+ mpi3mr_iocstate_name(ioc_state));
1184+
1185+ if (ioc_state == MRIOC_STATE_BECOMING_READY ||
1186+ ioc_state == MRIOC_STATE_RESET_REQUESTED) {
1187+ timeout = mrioc->ready_timeout * 10;
1188+ do {
1189+ msleep(100);
1190+ } while (--timeout);
1191+
1192+ ioc_state = mpi3mr_get_iocstate(mrioc);
1193+ ioc_info(mrioc,
1194+ "controller is in %s state after waiting to reset\n",
1195+ mpi3mr_iocstate_name(ioc_state));
1196+ }
1197+
1198+ if (ioc_state == MRIOC_STATE_READY) {
1199+ ioc_info(mrioc, "issuing message unit reset (MUR) to bring to reset state\n");
1200+ retval = mpi3mr_issue_and_process_mur(mrioc,
1201+ MPI3MR_RESET_FROM_BRINGUP);
1202+ ioc_state = mpi3mr_get_iocstate(mrioc);
1203+ if (retval)
1204+ ioc_err(mrioc,
1205+ "message unit reset failed with error %d current state %s\n",
1206+ retval, mpi3mr_iocstate_name(ioc_state));
1207+ }
1208+ if (ioc_state != MRIOC_STATE_RESET) {
1209+ mpi3mr_print_fault_info(mrioc);
1210+ ioc_info(mrioc, "issuing soft reset to bring to reset state\n");
1211+ retval = mpi3mr_issue_reset(mrioc,
1212+ MPI3_SYSIF_HOST_DIAG_RESET_ACTION_SOFT_RESET,
1213+ MPI3MR_RESET_FROM_BRINGUP);
1214+ if (retval) {
1215+ ioc_err(mrioc,
1216+ "soft reset failed with error %d\n", retval);
1217+ goto out_failed;
1218+ }
1219+ }
1220+ ioc_state = mpi3mr_get_iocstate(mrioc);
1221+ if (ioc_state != MRIOC_STATE_RESET) {
1222+ ioc_err(mrioc,
1223+ "cannot bring controller to reset state, current state: %s\n",
1224+ mpi3mr_iocstate_name(ioc_state));
1225+ goto out_failed;
1226+ }
1227+ mpi3mr_clear_reset_history(mrioc);
1228+ retval = mpi3mr_setup_admin_qpair(mrioc);
1229+ if (retval) {
1230+ ioc_err(mrioc, "failed to setup admin queues: error %d\n",
1231+ retval);
1232+ goto out_failed;
1233+ }
9991234
1235+ ioc_info(mrioc, "bringing controller to ready state\n");
10001236 ioc_config = readl(&mrioc->sysif_regs->ioc_configuration);
10011237 ioc_config |= MPI3_SYSIF_IOC_CONFIG_ENABLE_IOC;
10021238 writel(ioc_config, &mrioc->sysif_regs->ioc_configuration);
10031239
10041240 timeout = mrioc->ready_timeout * 10;
10051241 do {
1006− current_state = mpi3mr_get_iocstate(mrioc);
1007− if (current_state == MRIOC_STATE_READY)
1242+ ioc_state = mpi3mr_get_iocstate(mrioc);
1243+ if (ioc_state == MRIOC_STATE_READY) {
1244+ ioc_info(mrioc,
1245+ "successfully transistioned to %s state\n",
1246+ mpi3mr_iocstate_name(ioc_state));
10081247 return 0;
1248+ }
10091249 msleep(100);
10101250 } while (--timeout);
10111251
1012− return -1;
1252+out_failed:
1253+ ioc_state = mpi3mr_get_iocstate(mrioc);
1254+ ioc_err(mrioc,
1255+ "failed to bring to ready state, current state: %s\n",
1256+ mpi3mr_iocstate_name(ioc_state));
1257+ return retval;
10131258 }
10141259
10151260 /**
@@ -1026,7 +1271,6 @@ static inline bool · 10 unmodified lines
10261271 mpi3mr_soft_reset_success(u32 ioc_status, u32 ioc_config)
10271272 {
10281273 if (!((ioc_status & MPI3_SYSIF_IOC_STATUS_READY) ||
1029− (ioc_status & MPI3_SYSIF_IOC_STATUS_FAULT) ||
10301274 (ioc_config & MPI3_SYSIF_IOC_CONFIG_ENABLE_IOC)))
10311275 return true;
10321276 return false;
@@ -1049,8 +1293,10 @@ static inline bool mpi3mr_diagfault_success(struct mpi3mr_ioc *mrioc, · 16 unmodified lines
10491293 if (!(ioc_status & MPI3_SYSIF_IOC_STATUS_FAULT))
10501294 return false;
10511295 fault = readl(&mrioc->sysif_regs->fault) & MPI3_SYSIF_FAULT_CODE_MASK;
1052− if (fault == MPI3_SYSIF_FAULT_CODE_DIAG_FAULT_RESET)
1296+ if (fault == MPI3_SYSIF_FAULT_CODE_DIAG_FAULT_RESET) {
1297+ mpi3mr_print_fault_info(mrioc);
10531298 return true;
1299+ }
10541300 return false;
10551301 }
10561302
@@ -1089,26 +1335,36 @@ static int mpi3mr_issue_reset(struct mpi3mr_ioc *mrioc, u16 reset_type, · 32 unmodified lines
10891335 u32 reset_reason)
10901336 {
10911337 int retval = -1;
1092− u8 unlock_retry_count, reset_retry_count = 0;
1093− u32 host_diagnostic, timeout, ioc_status, ioc_config;
1338+ u8 unlock_retry_count = 0;
1339+ u32 host_diagnostic, ioc_status, ioc_config;
1340+ u32 timeout = MPI3MR_RESET_ACK_TIMEOUT * 10;
10941341
1095− pci_cfg_access_lock(mrioc->pdev);
10961342 if ((reset_type != MPI3_SYSIF_HOST_DIAG_RESET_ACTION_SOFT_RESET) &&
10971343 (reset_type != MPI3_SYSIF_HOST_DIAG_RESET_ACTION_DIAG_FAULT))
1098− goto out;
1344+ return retval;
10991345 if (mrioc->unrecoverable)
1100− goto out;
1101−retry_reset:
1102− unlock_retry_count = 0;
1346+ return retval;
1347+ if (reset_reason == MPI3MR_RESET_FROM_FIRMWARE) {
1348+ retval = 0;
1349+ return retval;
1350+ }
1351+
1352+ ioc_info(mrioc, "%s reset due to %s(0x%x)\n",
1353+ mpi3mr_reset_type_name(reset_type),
1354+ mpi3mr_reset_rc_name(reset_reason), reset_reason);
1355+
11031356 mpi3mr_clear_reset_history(mrioc);
11041357 do {
11051358 ioc_info(mrioc,
11061359 "Write magic sequence to unlock host diag register (retry=%d)\n",
11071360 ++unlock_retry_count);
11081361 if (unlock_retry_count >= MPI3MR_HOSTDIAG_UNLOCK_RETRY_COUNT) {
1109− writel(reset_reason, &mrioc->sysif_regs->scratchpad[0]);
1362+ ioc_err(mrioc,
1363+ "%s reset failed due to unlock failure, host_diagnostic(0x%08x)\n",
1364+ mpi3mr_reset_type_name(reset_type),
1365+ host_diagnostic);
11101366 mrioc->unrecoverable = 1;
1111− goto out;
1367+ return retval;
11121368 }
11131369
11141370 writel(MPI3_SYSIF_WRITE_SEQUENCE_KEY_VALUE_FLUSH,
@@ -1133,31 +1389,26 @@ retry_reset: · 18 unmodified lines
11331389 } while (!(host_diagnostic & MPI3_SYSIF_HOST_DIAG_DIAG_WRITE_ENABLE));
11341390
11351391 writel(reset_reason, &mrioc->sysif_regs->scratchpad[0]);
1136− ioc_info(mrioc, "%s reset due to %s(0x%x)\n",
1137− mpi3mr_reset_type_name(reset_type),
1138− mpi3mr_reset_rc_name(reset_reason), reset_reason);
11391392 writel(host_diagnostic | reset_type,
11401393 &mrioc->sysif_regs->host_diagnostic);
1141− timeout = mrioc->ready_timeout * 10;
1142− if (reset_type == MPI3_SYSIF_HOST_DIAG_RESET_ACTION_SOFT_RESET) {
1394+ switch (reset_type) {
1395+ case MPI3_SYSIF_HOST_DIAG_RESET_ACTION_SOFT_RESET:
11431396 do {
11441397 ioc_status = readl(&mrioc->sysif_regs->ioc_status);
1145− if (ioc_status &
1146− MPI3_SYSIF_IOC_STATUS_RESET_HISTORY) {
1398+ ioc_config =
1399+ readl(&mrioc->sysif_regs->ioc_configuration);
1400+ if ((ioc_status & MPI3_SYSIF_IOC_STATUS_RESET_HISTORY)
1401+ && mpi3mr_soft_reset_success(ioc_status, ioc_config)
1402+ ) {
11471403 mpi3mr_clear_reset_history(mrioc);
1148− ioc_config =
1149− readl(&mrioc->sysif_regs->ioc_configuration);
1150− if (mpi3mr_soft_reset_success(ioc_status,
1151− ioc_config)) {
1152− retval = 0;
1153− break;
1154− }
1404+ retval = 0;
1405+ break;
11551406 }
11561407 msleep(100);
11571408 } while (--timeout);
1158− writel(MPI3_SYSIF_WRITE_SEQUENCE_KEY_VALUE_2ND,
1159− &mrioc->sysif_regs->write_sequence);
1160− } else if (reset_type == MPI3_SYSIF_HOST_DIAG_RESET_ACTION_DIAG_FAULT) {
1409+ mpi3mr_print_fault_info(mrioc);
1410+ break;
1411+ case MPI3_SYSIF_HOST_DIAG_RESET_ACTION_DIAG_FAULT:
11611412 do {
11621413 ioc_status = readl(&mrioc->sysif_regs->ioc_status);
11631414 if (mpi3mr_diagfault_success(mrioc, ioc_status)) {
@@ -1166,28 +1417,22 @@ retry_reset: · 2 unmodified lines
11661417 }
11671418 msleep(100);
11681419 } while (--timeout);
1169− mpi3mr_clear_reset_history(mrioc);
1170− writel(MPI3_SYSIF_WRITE_SEQUENCE_KEY_VALUE_2ND,
1171− &mrioc->sysif_regs->write_sequence);
1172− }
1173− if (retval && ((++reset_retry_count) < MPI3MR_MAX_RESET_RETRY_COUNT)) {
1174− ioc_status = readl(&mrioc->sysif_regs->ioc_status);
1175− ioc_config = readl(&mrioc->sysif_regs->ioc_configuration);
1176− ioc_info(mrioc,
1177− "Base IOC Sts/Config after reset try %d is (0x%x)/(0x%x)\n",
1178− reset_retry_count, ioc_status, ioc_config);
1179− goto retry_reset;
1420+ break;
1421+ default:
1422+ break;
11801423 }
11811424
1182−out:
1183− pci_cfg_access_unlock(mrioc->pdev);
1184− ioc_status = readl(&mrioc->sysif_regs->ioc_status);
1185− ioc_config = readl(&mrioc->sysif_regs->ioc_configuration);
1425+ writel(MPI3_SYSIF_WRITE_SEQUENCE_KEY_VALUE_2ND,
1426+ &mrioc->sysif_regs->write_sequence);
11861427
1428+ ioc_config = readl(&mrioc->sysif_regs->ioc_configuration);
1429+ ioc_status = readl(&mrioc->sysif_regs->ioc_status);
11871430 ioc_info(mrioc,
1188− "Base IOC Sts/Config after %s reset is (0x%x)/(0x%x)\n",
1189− (!retval) ? "successful" : "failed", ioc_status,
1431+ "ioc_status/ioc_onfig after %s reset is (0x%x)/(0x%x)\n",
1432+ (!retval)?"successful":"failed", ioc_status,
11901433 ioc_config);
1434+ if (retval)
1435+ mrioc->unrecoverable = 1;
11911436 return retval;
11921437 }
11931438
@@ -1278,7 +1523,7 @@ static void mpi3mr_free_op_req_q_segments(struct mpi3mr_ioc *mrioc, u16 q_idx) · 84 unmodified lines
12781523 mrioc->op_reply_qinfo[q_idx].q_segment_list = NULL;
12791524 }
12801525 } else
1281− size = mrioc->req_qinfo[q_idx].num_requests *
1526+ size = mrioc->req_qinfo[q_idx].segment_qd *
12821527 mrioc->facts.op_req_sz;
12831528
12841529 for (j = 0; j < mrioc->req_qinfo[q_idx].num_segments; j++) {
@@ -1351,10 +1596,11 @@ static void mpi3mr_free_op_reply_q_segments(struct mpi3mr_ioc *mrioc, u16 q_idx) · 66 unmodified lines
13511596 static int mpi3mr_delete_op_reply_q(struct mpi3mr_ioc *mrioc, u16 qidx)
13521597 {
13531598 struct mpi3_delete_reply_queue_request delq_req;
1599+ struct op_reply_qinfo *op_reply_q = mrioc->op_reply_qinfo + qidx;
13541600 int retval = 0;
13551601 u16 reply_qid = 0, midx;
13561602
1357− reply_qid = mrioc->op_reply_qinfo[qidx].qid;
1603+ reply_qid = op_reply_q->qid;
13581604
13591605 midx = REPLY_QUEUE_IDX_TO_MSIX_IDX(qidx, mrioc->op_reply_q_offset);
13601606
@@ -1364,6 +1610,9 @@ static int mpi3mr_delete_op_reply_q(struct mpi3mr_ioc *mrioc, u16 qidx) · 3 unmodified lines
13641610 goto out;
13651611 }
13661612
1613+ (op_reply_q->qtype == MPI3MR_DEFAULT_QUEUE) ? mrioc->default_qcount-- :
1614+ mrioc->active_poll_qcount--;
1615+
13671616 memset(&delq_req, 0, sizeof(delq_req));
13681617 mutex_lock(&mrioc->init_cmds.mutex);
13691618 if (mrioc->init_cmds.state & MPI3MR_CMD_PENDING) {
@@ -1389,13 +1638,9 @@ static int mpi3mr_delete_op_reply_q(struct mpi3mr_ioc *mrioc, u16 qidx) · 19 unmodified lines
13891638 wait_for_completion_timeout(&mrioc->init_cmds.done,
13901639 (MPI3MR_INTADMCMD_TIMEOUT * HZ));
13911640 if (!(mrioc->init_cmds.state & MPI3MR_CMD_COMPLETE)) {
1392− ioc_err(mrioc, "Issue DelRepQ: command timed out\n");
1393− mpi3mr_set_diagsave(mrioc);
1394− mpi3mr_issue_reset(mrioc,
1395− MPI3_SYSIF_HOST_DIAG_RESET_ACTION_DIAG_FAULT,
1641+ ioc_err(mrioc, "delete reply queue timed out\n");
1642+ mpi3mr_check_rh_fault_ioc(mrioc,
13961643 MPI3MR_RESET_FROM_DELREPQ_TIMEOUT);
1397− mrioc->unrecoverable = 1;
1398−
13991644 retval = -1;
14001645 goto out_unlock;
14011646 }
@@ -1565,6 +1810,8 @@ static int mpi3mr_create_op_reply_q(struct mpi3mr_ioc *mrioc, u16 qidx) · 163 unmodified lines
15651810
15661811 reply_qid = qidx + 1;
15671812 op_reply_q->num_replies = MPI3MR_OP_REP_Q_QD;
1813+ if (!mrioc->pdev->revision)
1814+ op_reply_q->num_replies = MPI3MR_OP_REP_Q_QD4K;
15681815 op_reply_q->ci = 0;
15691816 op_reply_q->ephase = 1;
15701817 atomic_set(&op_reply_q->pend_ios, 0);
@@ -1592,8 +1839,26 @@ static int mpi3mr_create_op_reply_q(struct mpi3mr_ioc *mrioc, u16 qidx) · 21 unmodified lines
15921839 create_req.host_tag = cpu_to_le16(MPI3MR_HOSTTAG_INITCMDS);
15931840 create_req.function = MPI3_FUNCTION_CREATE_REPLY_QUEUE;
15941841 create_req.queue_id = cpu_to_le16(reply_qid);
1595− create_req.flags = MPI3_CREATE_REPLY_QUEUE_FLAGS_INT_ENABLE_ENABLE;
1596− create_req.msix_index = cpu_to_le16(mrioc->intr_info[midx].msix_index);
1842+
1843+ if (midx < (mrioc->intr_info_count - mrioc->requested_poll_qcount))
1844+ op_reply_q->qtype = MPI3MR_DEFAULT_QUEUE;
1845+ else
1846+ op_reply_q->qtype = MPI3MR_POLL_QUEUE;
1847+
1848+ if (op_reply_q->qtype == MPI3MR_DEFAULT_QUEUE) {
1849+ create_req.flags =
1850+ MPI3_CREATE_REPLY_QUEUE_FLAGS_INT_ENABLE_ENABLE;
1851+ create_req.msix_index =
1852+ cpu_to_le16(mrioc->intr_info[midx].msix_index);
1853+ } else {
1854+ create_req.msix_index = cpu_to_le16(mrioc->intr_info_count - 1);
1855+ ioc_info(mrioc, "create reply queue(polled): for qid(%d), midx(%d)\n",
1856+ reply_qid, midx);
1857+ if (!mrioc->active_poll_qcount)
1858+ disable_irq_nosync(pci_irq_vector(mrioc->pdev,
1859+ mrioc->intr_info_count - 1));
1860+ }
1861+
15971862 if (mrioc->enable_segqueue) {
15981863 create_req.flags |=
15991864 MPI3_CREATE_REQUEST_QUEUE_FLAGS_SEGMENTED_SEGMENTED;
@@ -1615,12 +1880,9 @@ static int mpi3mr_create_op_reply_q(struct mpi3mr_ioc *mrioc, u16 qidx) · 15 unmodified lines
16151880 wait_for_completion_timeout(&mrioc->init_cmds.done,
16161881 (MPI3MR_INTADMCMD_TIMEOUT * HZ));
16171882 if (!(mrioc->init_cmds.state & MPI3MR_CMD_COMPLETE)) {
1618− ioc_err(mrioc, "CreateRepQ: command timed out\n");
1619− mpi3mr_set_diagsave(mrioc);
1620− mpi3mr_issue_reset(mrioc,
1621− MPI3_SYSIF_HOST_DIAG_RESET_ACTION_DIAG_FAULT,
1883+ ioc_err(mrioc, "create reply queue timed out\n");
1884+ mpi3mr_check_rh_fault_ioc(mrioc,
16221885 MPI3MR_RESET_FROM_CREATEREPQ_TIMEOUT);
1623− mrioc->unrecoverable = 1;
16241886 retval = -1;
16251887 goto out_unlock;
16261888 }
@@ -1634,7 +1896,11 @@ static int mpi3mr_create_op_reply_q(struct mpi3mr_ioc *mrioc, u16 qidx) · 7 unmodified lines
16341896 goto out_unlock;
16351897 }
16361898 op_reply_q->qid = reply_qid;
1637− mrioc->intr_info[midx].op_reply_q = op_reply_q;
1899+ if (midx < mrioc->intr_info_count)
1900+ mrioc->intr_info[midx].op_reply_q = op_reply_q;
1901+
1902+ (op_reply_q->qtype == MPI3MR_DEFAULT_QUEUE) ? mrioc->default_qcount++ :
1903+ mrioc->active_poll_qcount++;
16381904
16391905 out_unlock:
16401906 mrioc->init_cmds.state = MPI3MR_CMD_NOTUSED;
@@ -1722,12 +1988,9 @@ static int mpi3mr_create_op_req_q(struct mpi3mr_ioc *mrioc, u16 idx, · 81 unmodified lines
17221988 wait_for_completion_timeout(&mrioc->init_cmds.done,
17231989 (MPI3MR_INTADMCMD_TIMEOUT * HZ));
17241990 if (!(mrioc->init_cmds.state & MPI3MR_CMD_COMPLETE)) {
1725− ioc_err(mrioc, "CreateReqQ: command timed out\n");
1726− mpi3mr_set_diagsave(mrioc);
1727− if (mpi3mr_issue_reset(mrioc,
1728− MPI3_SYSIF_HOST_DIAG_RESET_ACTION_DIAG_FAULT,
1729− MPI3MR_RESET_FROM_CREATEREQQ_TIMEOUT))
1730− mrioc->unrecoverable = 1;
1991+ ioc_err(mrioc, "create request queue timed out\n");
1992+ mpi3mr_check_rh_fault_ioc(mrioc,
1993+ MPI3MR_RESET_FROM_CREATEREQQ_TIMEOUT);
17311994 retval = -1;
17321995 goto out_unlock;
17331996 }
@@ -1771,8 +2034,13 @@ static int mpi3mr_create_op_queues(struct mpi3mr_ioc *mrioc) · 37 unmodified lines
17712034 mrioc->intr_info_count - mrioc->op_reply_q_offset;
17722035 if (!mrioc->num_queues)
17732036 mrioc->num_queues = min_t(int, num_queues, msix_count_op_q);
1774− num_queues = mrioc->num_queues;
1775− ioc_info(mrioc, "Trying to create %d Operational Q pairs\n",
2037+ /*
2038+ * During reset set the num_queues to the number of queues
2039+ * that was set before the reset.
2040+ */
2041+ num_queues = mrioc->num_op_reply_q ?
2042+ mrioc->num_op_reply_q : mrioc->num_queues;
2043+ ioc_info(mrioc, "trying to create %d operational queue pairs\n",
17762044 num_queues);
17772045
17782046 if (!mrioc->req_qinfo) {
@@ -1814,8 +2082,10 @@ static int mpi3mr_create_op_queues(struct mpi3mr_ioc *mrioc) · 35 unmodified lines
18142082 goto out_failed;
18152083 }
18162084 mrioc->num_op_reply_q = mrioc->num_op_req_q = i;
1817− ioc_info(mrioc, "Successfully created %d Operational Q pairs\n",
1818− mrioc->num_op_reply_q);
2085+ ioc_info(mrioc,
2086+ "successfully created %d operational queue pairs(default/polled) queue = (%d/%d)\n",
2087+ mrioc->num_op_reply_q, mrioc->default_qcount,
2088+ mrioc->active_poll_qcount);
18192089
18202090 return retval;
18212091 out_failed:
@@ -1863,7 +2133,7 @@ int mpi3mr_op_request_post(struct mpi3mr_ioc *mrioc, · 41 unmodified lines
18632133 if (mpi3mr_check_req_qfull(op_req_q)) {
18642134 midx = REPLY_QUEUE_IDX_TO_MSIX_IDX(
18652135 reply_qidx, mrioc->op_reply_q_offset);
1866− mpi3mr_process_op_reply_q(mrioc, &mrioc->intr_info[midx]);
2136+ mpi3mr_process_op_reply_q(mrioc, mrioc->intr_info[midx].op_reply_q);
18672137
18682138 if (mpi3mr_check_req_qfull(op_req_q)) {
18692139 retval = -EAGAIN;
@@ -1900,6 +2170,42 @@ out: · 30 unmodified lines
19002170 return retval;
19012171 }
19022172
2173+/**
2174+ * mpi3mr_check_rh_fault_ioc - check reset history and fault
2175+ * controller
2176+ * @mrioc: Adapter instance reference
2177+ * @reason_code, reason code for the fault.
2178+ *
2179+ * This routine will save snapdump and fault the controller with
2180+ * the given reason code if it is not already in the fault or
2181+ * not asynchronosuly reset. This will be used to handle
2182+ * initilaization time faults/resets/timeout as in those cases
2183+ * immediate soft reset invocation is not required.
2184+ *
2185+ * Return: None.
2186+ */
2187+void mpi3mr_check_rh_fault_ioc(struct mpi3mr_ioc *mrioc, u32 reason_code)
2188+{
2189+ u32 ioc_status, host_diagnostic, timeout;
2190+
2191+ ioc_status = readl(&mrioc->sysif_regs->ioc_status);
2192+ if ((ioc_status & MPI3_SYSIF_IOC_STATUS_RESET_HISTORY) ||
2193+ (ioc_status & MPI3_SYSIF_IOC_STATUS_FAULT)) {
2194+ mpi3mr_print_fault_info(mrioc);
2195+ return;
2196+ }
2197+ mpi3mr_set_diagsave(mrioc);
2198+ mpi3mr_issue_reset(mrioc, MPI3_SYSIF_HOST_DIAG_RESET_ACTION_DIAG_FAULT,
2199+ reason_code);
2200+ timeout = MPI3_SYSIF_DIAG_SAVE_TIMEOUT * 10;
2201+ do {
2202+ host_diagnostic = readl(&mrioc->sysif_regs->host_diagnostic);
2203+ if (!(host_diagnostic & MPI3_SYSIF_HOST_DIAG_SAVE_IN_PROGRESS))
2204+ break;
2205+ msleep(100);
2206+ } while (--timeout);
2207+}
2208+
19032209 /**
19042210 * mpi3mr_sync_timestamp - Issue time stamp sync request
19052211 * @mrioc: Adapter reference
@@ -1945,8 +2251,9 @@ static int mpi3mr_sync_timestamp(struct mpi3mr_ioc *mrioc) · 39 unmodified lines
19452251 if (!(mrioc->init_cmds.state & MPI3MR_CMD_COMPLETE)) {
19462252 ioc_err(mrioc, "Issue IOUCTL time_stamp: command timed out\n");
19472253 mrioc->init_cmds.is_waiting = 0;
1948− mpi3mr_soft_reset_handler(mrioc,
1949− MPI3MR_RESET_FROM_TSU_TIMEOUT, 1);
2254+ if (!(mrioc->init_cmds.state & MPI3MR_CMD_RESET))
2255+ mpi3mr_soft_reset_handler(mrioc,
2256+ MPI3MR_RESET_FROM_TSU_TIMEOUT, 1);
19502257 retval = -1;
19512258 goto out_unlock;
19522259 }
@@ -1969,65 +2276,166 @@ out: · 16 unmodified lines
19692276 }
19702277
19712278 /**
1972− * mpi3mr_watchdog_work - watchdog thread to monitor faults
1973− * @work: work struct
2279+ * mpi3mr_print_pkg_ver - display controller fw package version
2280+ * @mrioc: Adapter reference
19742281 *
1975− * Watch dog work periodically executed (1 second interval) to
1976− * monitor firmware fault and to issue periodic timer sync to
1977− * the firmware.
2282+ * Retrieve firmware package version from the component image
2283+ * header of the controller flash and display it.
19782284 *
1979− * Return: Nothing.
2285+ * Return: 0 on success and non-zero on failure.
19802286 */
1981−static void mpi3mr_watchdog_work(struct work_struct *work)
2287+static int mpi3mr_print_pkg_ver(struct mpi3mr_ioc *mrioc)
19822288 {
1983− struct mpi3mr_ioc *mrioc =
1984− container_of(work, struct mpi3mr_ioc, watchdog_work.work);
1985− unsigned long flags;
1986− enum mpi3mr_iocstate ioc_state;
1987− u32 fault, host_diagnostic;
2289+ struct mpi3_ci_upload_request ci_upload;
2290+ int retval = -1;
2291+ void *data = NULL;
2292+ dma_addr_t data_dma;
2293+ struct mpi3_ci_manifest_mpi *manifest;
2294+ u32 data_len = sizeof(struct mpi3_ci_manifest_mpi);
2295+ u8 sgl_flags = MPI3MR_SGEFLAGS_SYSTEM_SIMPLE_END_OF_LIST;
2296+
2297+ data = dma_alloc_coherent(&mrioc->pdev->dev, data_len, &data_dma,
2298+ GFP_KERNEL);
2299+ if (!data)
2300+ return -ENOMEM;
2301+
2302+ memset(&ci_upload, 0, sizeof(ci_upload));
2303+ mutex_lock(&mrioc->init_cmds.mutex);
2304+ if (mrioc->init_cmds.state & MPI3MR_CMD_PENDING) {
2305+ ioc_err(mrioc, "sending get package version failed due to command in use\n");
2306+ mutex_unlock(&mrioc->init_cmds.mutex);
2307+ goto out;
2308+ }
2309+ mrioc->init_cmds.state = MPI3MR_CMD_PENDING;
2310+ mrioc->init_cmds.is_waiting = 1;
2311+ mrioc->init_cmds.callback = NULL;
2312+ ci_upload.host_tag = cpu_to_le16(MPI3MR_HOSTTAG_INITCMDS);
2313+ ci_upload.function = MPI3_FUNCTION_CI_UPLOAD;
2314+ ci_upload.msg_flags = MPI3_CI_UPLOAD_MSGFLAGS_LOCATION_PRIMARY;
2315+ ci_upload.signature1 = cpu_to_le32(MPI3_IMAGE_HEADER_SIGNATURE1_MANIFEST);
2316+ ci_upload.image_offset = cpu_to_le32(MPI3_IMAGE_HEADER_SIZE);
2317+ ci_upload.segment_size = cpu_to_le32(data_len);
2318+
2319+ mpi3mr_add_sg_single(&ci_upload.sgl, sgl_flags, data_len,
2320+ data_dma);
2321+ init_completion(&mrioc->init_cmds.done);
2322+ retval = mpi3mr_admin_request_post(mrioc, &ci_upload,
2323+ sizeof(ci_upload), 1);
2324+ if (retval) {
2325+ ioc_err(mrioc, "posting get package version failed\n");
2326+ goto out_unlock;
2327+ }
2328+ wait_for_completion_timeout(&mrioc->init_cmds.done,
2329+ (MPI3MR_INTADMCMD_TIMEOUT * HZ));
2330+ if (!(mrioc->init_cmds.state & MPI3MR_CMD_COMPLETE)) {
2331+ ioc_err(mrioc, "get package version timed out\n");
2332+ mpi3mr_check_rh_fault_ioc(mrioc,
2333+ MPI3MR_RESET_FROM_GETPKGVER_TIMEOUT);
2334+ retval = -1;
2335+ goto out_unlock;
2336+ }
2337+ if ((mrioc->init_cmds.ioc_status & MPI3_IOCSTATUS_STATUS_MASK)
2338+ == MPI3_IOCSTATUS_SUCCESS) {
2339+ manifest = (struct mpi3_ci_manifest_mpi *) data;
2340+ if (manifest->manifest_type == MPI3_CI_MANIFEST_TYPE_MPI) {
2341+ ioc_info(mrioc,
2342+ "firmware package version(%d.%d.%d.%d.%05d-%05d)\n",
2343+ manifest->package_version.gen_major,
2344+ manifest->package_version.gen_minor,
2345+ manifest->package_version.phase_major,
2346+ manifest->package_version.phase_minor,
2347+ manifest->package_version.customer_id,
2348+ manifest->package_version.build_num);
2349+ }
2350+ }
2351+ retval = 0;
2352+out_unlock:
2353+ mrioc->init_cmds.state = MPI3MR_CMD_NOTUSED;
2354+ mutex_unlock(&mrioc->init_cmds.mutex);
2355+
2356+out:
2357+ if (data)
2358+ dma_free_coherent(&mrioc->pdev->dev, data_len, data,
2359+ data_dma);
2360+ return retval;
2361+}
2362+
2363+/**
2364+ * mpi3mr_watchdog_work - watchdog thread to monitor faults
2365+ * @work: work struct
2366+ *
2367+ * Watch dog work periodically executed (1 second interval) to
2368+ * monitor firmware fault and to issue periodic timer sync to
2369+ * the firmware.
2370+ *
2371+ * Return: Nothing.
2372+ */
2373+static void mpi3mr_watchdog_work(struct work_struct *work)
2374+{
2375+ struct mpi3mr_ioc *mrioc =
2376+ container_of(work, struct mpi3mr_ioc, watchdog_work.work);
2377+ unsigned long flags;
2378+ enum mpi3mr_iocstate ioc_state;
2379+ u32 fault, host_diagnostic, ioc_status;
2380+ u32 reset_reason = MPI3MR_RESET_FROM_FAULT_WATCH;
2381+
2382+ if (mrioc->reset_in_progress || mrioc->unrecoverable)
2383+ return;
19882384
19892385 if (mrioc->ts_update_counter++ >= MPI3MR_TSUPDATE_INTERVAL) {
19902386 mrioc->ts_update_counter = 0;
19912387 mpi3mr_sync_timestamp(mrioc);
19922388 }
19932389
2390+ if ((mrioc->prepare_for_reset) &&
2391+ ((mrioc->prepare_for_reset_timeout_counter++) >=
2392+ MPI3MR_PREPARE_FOR_RESET_TIMEOUT)) {
2393+ mpi3mr_soft_reset_handler(mrioc,
2394+ MPI3MR_RESET_FROM_CIACTVRST_TIMER, 1);
2395+ return;
2396+ }
2397+
2398+ ioc_status = readl(&mrioc->sysif_regs->ioc_status);
2399+ if (ioc_status & MPI3_SYSIF_IOC_STATUS_RESET_HISTORY) {
2400+ mpi3mr_soft_reset_handler(mrioc, MPI3MR_RESET_FROM_FIRMWARE, 0);
2401+ return;
2402+ }
2403+
19942404 /*Check for fault state every one second and issue Soft reset*/
19952405 ioc_state = mpi3mr_get_iocstate(mrioc);
1996− if (ioc_state == MRIOC_STATE_FAULT) {
1997− fault = readl(&mrioc->sysif_regs->fault) &
1998− MPI3_SYSIF_FAULT_CODE_MASK;
1999− host_diagnostic = readl(&mrioc->sysif_regs->host_diagnostic);
2000− if (host_diagnostic & MPI3_SYSIF_HOST_DIAG_SAVE_IN_PROGRESS) {
2001− if (!mrioc->diagsave_timeout) {
2002− mpi3mr_print_fault_info(mrioc);
2003− ioc_warn(mrioc, "Diag save in progress\n");
2004− }
2005− if ((mrioc->diagsave_timeout++) <=
2006− MPI3_SYSIF_DIAG_SAVE_TIMEOUT)
2007− goto schedule_work;
2008− } else
2009− mpi3mr_print_fault_info(mrioc);
2010− mrioc->diagsave_timeout = 0;
2406+ if (ioc_state != MRIOC_STATE_FAULT)
2407+ goto schedule_work;
20112408
2012− if (fault == MPI3_SYSIF_FAULT_CODE_FACTORY_RESET) {
2013− ioc_info(mrioc,
2014− "Factory Reset fault occurred marking controller as unrecoverable"
2015− );
2016− mrioc->unrecoverable = 1;
2017− goto out;
2409+ fault = readl(&mrioc->sysif_regs->fault) & MPI3_SYSIF_FAULT_CODE_MASK;
2410+ host_diagnostic = readl(&mrioc->sysif_regs->host_diagnostic);
2411+ if (host_diagnostic & MPI3_SYSIF_HOST_DIAG_SAVE_IN_PROGRESS) {
2412+ if (!mrioc->diagsave_timeout) {
2413+ mpi3mr_print_fault_info(mrioc);
2414+ ioc_warn(mrioc, "diag save in progress\n");
20182415 }
2416+ if ((mrioc->diagsave_timeout++) <= MPI3_SYSIF_DIAG_SAVE_TIMEOUT)
2417+ goto schedule_work;
2418+ }
20192419
2020− if ((fault == MPI3_SYSIF_FAULT_CODE_DIAG_FAULT_RESET) ||
2021− (fault == MPI3_SYSIF_FAULT_CODE_SOFT_RESET_IN_PROGRESS) ||
2022− (mrioc->reset_in_progress))
2023− goto out;
2024− if (fault == MPI3_SYSIF_FAULT_CODE_CI_ACTIVATION_RESET)
2025− mpi3mr_soft_reset_handler(mrioc,
2026− MPI3MR_RESET_FROM_CIACTIV_FAULT, 0);
2027− else
2028− mpi3mr_soft_reset_handler(mrioc,
2029− MPI3MR_RESET_FROM_FAULT_WATCH, 0);
2420+ mpi3mr_print_fault_info(mrioc);
2421+ mrioc->diagsave_timeout = 0;
2422+
2423+ switch (fault) {
2424+ case MPI3_SYSIF_FAULT_CODE_POWER_CYCLE_REQUIRED:
2425+ ioc_info(mrioc,
2426+ "controller requires system power cycle, marking controller as unrecoverable\n");
2427+ mrioc->unrecoverable = 1;
2428+ return;
2429+ case MPI3_SYSIF_FAULT_CODE_SOFT_RESET_IN_PROGRESS:
2430+ return;
2431+ case MPI3_SYSIF_FAULT_CODE_CI_ACTIVATION_RESET:
2432+ reset_reason = MPI3MR_RESET_FROM_CIACTIV_FAULT;
2433+ break;
2434+ default:
2435+ break;
20302436 }
2437+ mpi3mr_soft_reset_handler(mrioc, reset_reason, 0);
2438+ return;
20312439
20322440 schedule_work:
20332441 spin_lock_irqsave(&mrioc->watchdog_lock, flags);
@@ -2036,7 +2444,6 @@ schedule_work: · 2 unmodified lines
20362444 &mrioc->watchdog_work,
20372445 msecs_to_jiffies(MPI3MR_WATCHDOG_INTERVAL));
20382446 spin_unlock_irqrestore(&mrioc->watchdog_lock, flags);
2039−out:
20402447 return;
20412448 }
20422449
@@ -2096,41 +2503,6 @@ void mpi3mr_stop_watchdog(struct mpi3mr_ioc *mrioc) · 53 unmodified lines
20962503 }
20972504 }
20982505
2099−/**
2100− * mpi3mr_kill_ioc - Kill the controller
2101− * @mrioc: Adapter instance reference
2102− * @reason: reason for the failure.
2103− *
2104− * If fault debug is enabled, display the fault info else issue
2105− * diag fault and freeze the system for controller debug
2106− * purpose.
2107− *
2108− * Return: Nothing.
2109− */
2110−static void mpi3mr_kill_ioc(struct mpi3mr_ioc *mrioc, u32 reason)
2111−{
2112− enum mpi3mr_iocstate ioc_state;
2113−
2114− if (!mrioc->fault_dbg)
2115− return;
2116−
2117− dump_stack();
2118−
2119− ioc_state = mpi3mr_get_iocstate(mrioc);
2120− if (ioc_state == MRIOC_STATE_FAULT)
2121− mpi3mr_print_fault_info(mrioc);
2122− else {
2123− ioc_err(mrioc, "Firmware is halted due to the reason %d\n",
2124− reason);
2125− mpi3mr_diagfault_reset_handler(mrioc, reason);
2126− }
2127− if (mrioc->fault_dbg == 2)
2128− for (;;)
2129− ;
2130− else
2131− panic("panic in %s\n", __func__);
2132−}
2133−
21342506 /**
21352507 * mpi3mr_setup_admin_qpair - Setup admin queue pair
21362508 * @mrioc: Adapter instance reference
@@ -2258,12 +2630,9 @@ static int mpi3mr_issue_iocfacts(struct mpi3mr_ioc *mrioc, · 121 unmodified lines
22582630 wait_for_completion_timeout(&mrioc->init_cmds.done,
22592631 (MPI3MR_INTADMCMD_TIMEOUT * HZ));
22602632 if (!(mrioc->init_cmds.state & MPI3MR_CMD_COMPLETE)) {
2261− ioc_err(mrioc, "Issue IOCFacts: command timed out\n");
2262− mpi3mr_set_diagsave(mrioc);
2263− mpi3mr_issue_reset(mrioc,
2264− MPI3_SYSIF_HOST_DIAG_RESET_ACTION_DIAG_FAULT,
2633+ ioc_err(mrioc, "ioc_facts timed out\n");
2634+ mpi3mr_check_rh_fault_ioc(mrioc,
22652635 MPI3MR_RESET_FROM_IOCFACTS_TIMEOUT);
2266− mrioc->unrecoverable = 1;
22672636 retval = -1;
22682637 goto out_unlock;
22692638 }
@@ -2277,6 +2646,7 @@ static int mpi3mr_issue_iocfacts(struct mpi3mr_ioc *mrioc, · 7 unmodified lines
22772646 goto out_unlock;
22782647 }
22792648 memcpy(facts_data, (u8 *)data, data_len);
2649+ mpi3mr_process_factsdata(mrioc, facts_data);
22802650 out_unlock:
22812651 mrioc->init_cmds.state = MPI3MR_CMD_NOTUSED;
22822652 mutex_unlock(&mrioc->init_cmds.mutex);
@@ -2374,14 +2744,13 @@ static void mpi3mr_process_factsdata(struct mpi3mr_ioc *mrioc, · 91 unmodified lines
23742744 mrioc->facts.reply_sz = le16_to_cpu(facts_data->reply_frame_size) * 4;
23752745 mrioc->facts.exceptions = le16_to_cpu(facts_data->ioc_exceptions);
23762746 mrioc->facts.max_perids = le16_to_cpu(facts_data->max_persistent_id);
2377− mrioc->facts.max_pds = le16_to_cpu(facts_data->max_pds);
23782747 mrioc->facts.max_vds = le16_to_cpu(facts_data->max_vds);
23792748 mrioc->facts.max_hpds = le16_to_cpu(facts_data->max_host_pds);
2380− mrioc->facts.max_advhpds = le16_to_cpu(facts_data->max_advanced_host_pds);
2381− mrioc->facts.max_raidpds = le16_to_cpu(facts_data->max_raid_pds);
2749+ mrioc->facts.max_advhpds = le16_to_cpu(facts_data->max_adv_host_pds);
2750+ mrioc->facts.max_raid_pds = le16_to_cpu(facts_data->max_raid_pds);
23822751 mrioc->facts.max_nvme = le16_to_cpu(facts_data->max_nvme);
23832752 mrioc->facts.max_pcie_switches =
2384− le16_to_cpu(facts_data->max_pc_ie_switches);
2753+ le16_to_cpu(facts_data->max_pcie_switches);
23852754 mrioc->facts.max_sasexpanders =
23862755 le16_to_cpu(facts_data->max_sas_expanders);
23872756 mrioc->facts.max_sasinitiators =
@@ -2415,22 +2784,15 @@ static void mpi3mr_process_factsdata(struct mpi3mr_ioc *mrioc, · 27 unmodified lines
24152784 mrioc->facts.ioc_num, mrioc->facts.max_op_req_q,
24162785 mrioc->facts.max_op_reply_q, mrioc->facts.max_devhandle);
24172786 ioc_info(mrioc,
2418− "maxreqs(%d), mindh(%d) maxPDs(%d) maxvectors(%d) maxperids(%d)\n",
2787+ "maxreqs(%d), mindh(%d) maxvectors(%d) maxperids(%d)\n",
24192788 mrioc->facts.max_reqs, mrioc->facts.min_devhandle,
2420− mrioc->facts.max_pds, mrioc->facts.max_msix_vectors,
2421− mrioc->facts.max_perids);
2789+ mrioc->facts.max_msix_vectors, mrioc->facts.max_perids);
24222790 ioc_info(mrioc, "SGEModMask 0x%x SGEModVal 0x%x SGEModShift 0x%x ",
24232791 mrioc->facts.sge_mod_mask, mrioc->facts.sge_mod_value,
24242792 mrioc->facts.sge_mod_shift);
24252793 ioc_info(mrioc, "DMA mask %d InitialPE status 0x%x\n",
24262794 mrioc->facts.dma_mask, (facts_flags &
24272795 MPI3_IOCFACTS_FLAGS_INITIAL_PORT_ENABLE_MASK));
2428−
2429− mrioc->max_host_ios = mrioc->facts.max_reqs - MPI3MR_INTERNAL_CMDS_RESVD;
2430−
2431− if (reset_devices)
2432− mrioc->max_host_ios = min_t(int, mrioc->max_host_ios,
2433− MPI3MR_HOST_IOS_KDUMP);
24342796 }
24352797
24362798 /**
@@ -2446,23 +2808,29 @@ static int mpi3mr_alloc_reply_sense_bufs(struct mpi3mr_ioc *mrioc) · 9 unmodified lines
24462808 {
24472809 int retval = 0;
24482810 u32 sz, i;
2449− dma_addr_t phy_addr;
24502811
24512812 if (mrioc->init_cmds.reply)
2452− goto post_reply_sbuf;
2813+ return retval;
24532814
2454− mrioc->init_cmds.reply = kzalloc(mrioc->facts.reply_sz, GFP_KERNEL);
2815+ mrioc->init_cmds.reply = kzalloc(mrioc->reply_sz, GFP_KERNEL);
24552816 if (!mrioc->init_cmds.reply)
24562817 goto out_failed;
24572818
24582819 for (i = 0; i < MPI3MR_NUM_DEVRMCMD; i++) {
2459− mrioc->dev_rmhs_cmds[i].reply = kzalloc(mrioc->facts.reply_sz,
2820+ mrioc->dev_rmhs_cmds[i].reply = kzalloc(mrioc->reply_sz,
24602821 GFP_KERNEL);
24612822 if (!mrioc->dev_rmhs_cmds[i].reply)
24622823 goto out_failed;
24632824 }
24642825
2465− mrioc->host_tm_cmds.reply = kzalloc(mrioc->facts.reply_sz, GFP_KERNEL);
2826+ for (i = 0; i < MPI3MR_NUM_EVTACKCMD; i++) {
2827+ mrioc->evtack_cmds[i].reply = kzalloc(mrioc->reply_sz,
2828+ GFP_KERNEL);
2829+ if (!mrioc->evtack_cmds[i].reply)
2830+ goto out_failed;
2831+ }
2832+
2833+ mrioc->host_tm_cmds.reply = kzalloc(mrioc->reply_sz, GFP_KERNEL);
24662834 if (!mrioc->host_tm_cmds.reply)
24672835 goto out_failed;
24682836
@@ -2482,13 +2850,21 @@ static int mpi3mr_alloc_reply_sense_bufs(struct mpi3mr_ioc *mrioc) · 13 unmodified lines
24822850 if (!mrioc->devrem_bitmap)
24832851 goto out_failed;
24842852
2853+ mrioc->evtack_cmds_bitmap_sz = MPI3MR_NUM_EVTACKCMD / 8;
2854+ if (MPI3MR_NUM_EVTACKCMD % 8)
2855+ mrioc->evtack_cmds_bitmap_sz++;
2856+ mrioc->evtack_cmds_bitmap = kzalloc(mrioc->evtack_cmds_bitmap_sz,
2857+ GFP_KERNEL);
2858+ if (!mrioc->evtack_cmds_bitmap)
2859+ goto out_failed;
2860+
24852861 mrioc->num_reply_bufs = mrioc->facts.max_reqs + MPI3MR_NUM_EVT_REPLIES;
24862862 mrioc->reply_free_qsz = mrioc->num_reply_bufs + 1;
24872863 mrioc->num_sense_bufs = mrioc->facts.max_reqs / MPI3MR_SENSEBUF_FACTOR;
24882864 mrioc->sense_buf_q_sz = mrioc->num_sense_bufs + 1;
24892865
24902866 /* reply buffer pool, 16 byte align */
2491− sz = mrioc->num_reply_bufs * mrioc->facts.reply_sz;
2867+ sz = mrioc->num_reply_bufs * mrioc->reply_sz;
24922868 mrioc->reply_buf_pool = dma_pool_create("reply_buf pool",
24932869 &mrioc->pdev->dev, sz, 16, 0);
24942870 if (!mrioc->reply_buf_pool) {
@@ -2517,7 +2893,7 @@ static int mpi3mr_alloc_reply_sense_bufs(struct mpi3mr_ioc *mrioc) · 22 unmodified lines
25172893 goto out_failed;
25182894
25192895 /* sense buffer pool, 4 byte align */
2520− sz = mrioc->num_sense_bufs * MPI3MR_SENSEBUF_SZ;
2896+ sz = mrioc->num_sense_bufs * MPI3MR_SENSE_BUF_SZ;
25212897 mrioc->sense_buf_pool = dma_pool_create("sense_buf pool",
25222898 &mrioc->pdev->dev, sz, 4, 0);
25232899 if (!mrioc->sense_buf_pool) {
@@ -2542,21 +2918,42 @@ static int mpi3mr_alloc_reply_sense_bufs(struct mpi3mr_ioc *mrioc) · 18 unmodified lines
25422918 if (!mrioc->sense_buf_q)
25432919 goto out_failed;
25442920
2545−post_reply_sbuf:
2546− sz = mrioc->num_reply_bufs * mrioc->facts.reply_sz;
2921+ return retval;
2922+
2923+out_failed:
2924+ retval = -1;
2925+ return retval;
2926+}
2927+
2928+/**
2929+ * mpimr_initialize_reply_sbuf_queues - initialize reply sense
2930+ * buffers
2931+ * @mrioc: Adapter instance reference
2932+ *
2933+ * Helper function to initialize reply and sense buffers along
2934+ * with some debug prints.
2935+ *
2936+ * Return: None.
2937+ */
2938+static void mpimr_initialize_reply_sbuf_queues(struct mpi3mr_ioc *mrioc)
2939+{
2940+ u32 sz, i;
2941+ dma_addr_t phy_addr;
2942+
2943+ sz = mrioc->num_reply_bufs * mrioc->reply_sz;
25472944 ioc_info(mrioc,
25482945 "reply buf pool(0x%p): depth(%d), frame_size(%d), pool_size(%d kB), reply_dma(0x%llx)\n",
2549− mrioc->reply_buf, mrioc->num_reply_bufs, mrioc->facts.reply_sz,
2946+ mrioc->reply_buf, mrioc->num_reply_bufs, mrioc->reply_sz,
25502947 (sz / 1024), (unsigned long long)mrioc->reply_buf_dma);
25512948 sz = mrioc->reply_free_qsz * 8;
25522949 ioc_info(mrioc,
25532950 "reply_free_q pool(0x%p): depth(%d), frame_size(%d), pool_size(%d kB), reply_dma(0x%llx)\n",
25542951 mrioc->reply_free_q, mrioc->reply_free_qsz, 8, (sz / 1024),
25552952 (unsigned long long)mrioc->reply_free_q_dma);
2556− sz = mrioc->num_sense_bufs * MPI3MR_SENSEBUF_SZ;
2953+ sz = mrioc->num_sense_bufs * MPI3MR_SENSE_BUF_SZ;
25572954 ioc_info(mrioc,
25582955 "sense_buf pool(0x%p): depth(%d), frame_size(%d), pool_size(%d kB), sense_dma(0x%llx)\n",
2559− mrioc->sense_buf, mrioc->num_sense_bufs, MPI3MR_SENSEBUF_SZ,
2956+ mrioc->sense_buf, mrioc->num_sense_bufs, MPI3MR_SENSE_BUF_SZ,
25602957 (sz / 1024), (unsigned long long)mrioc->sense_buf_dma);
25612958 sz = mrioc->sense_buf_q_sz * 8;
25622959 ioc_info(mrioc,
@@ -2566,20 +2963,15 @@ post_reply_sbuf: · 3 unmodified lines
25662963
25672964 /* initialize Reply buffer Queue */
25682965 for (i = 0, phy_addr = mrioc->reply_buf_dma;
2569− i < mrioc->num_reply_bufs; i++, phy_addr += mrioc->facts.reply_sz)
2966+ i < mrioc->num_reply_bufs; i++, phy_addr += mrioc->reply_sz)
25702967 mrioc->reply_free_q[i] = cpu_to_le64(phy_addr);
25712968 mrioc->reply_free_q[i] = cpu_to_le64(0);
25722969
25732970 /* initialize Sense Buffer Queue */
25742971 for (i = 0, phy_addr = mrioc->sense_buf_dma;
2575− i < mrioc->num_sense_bufs; i++, phy_addr += MPI3MR_SENSEBUF_SZ)
2972+ i < mrioc->num_sense_bufs; i++, phy_addr += MPI3MR_SENSE_BUF_SZ)
25762973 mrioc->sense_buf_q[i] = cpu_to_le64(phy_addr);
25772974 mrioc->sense_buf_q[i] = cpu_to_le64(0);
2578− return retval;
2579−
2580−out_failed:
2581− retval = -1;
2582− return retval;
25832975 }
25842976
25852977 /**
@@ -2606,6 +2998,8 @@ static int mpi3mr_issue_iocinit(struct mpi3mr_ioc *mrioc) · 20 unmodified lines
26062998 retval = -1;
26072999 goto out;
26083000 }
3001+ mpimr_initialize_reply_sbuf_queues(mrioc);
3002+
26093003 drv_info->information_length = cpu_to_le32(data_len);
26103004 strscpy(drv_info->driver_signature, "Broadcom", sizeof(drv_info->driver_signature));
26113005 strscpy(drv_info->os_name, utsname()->sysname, sizeof(drv_info->os_name));
@@ -2639,7 +3033,7 @@ static int mpi3mr_issue_iocinit(struct mpi3mr_ioc *mrioc) · 27 unmodified lines
26393033 iocinit_req.reply_free_queue_depth = cpu_to_le16(mrioc->reply_free_qsz);
26403034 iocinit_req.reply_free_queue_address =
26413035 cpu_to_le64(mrioc->reply_free_q_dma);
2642− iocinit_req.sense_buffer_length = cpu_to_le16(MPI3MR_SENSEBUF_SZ);
3036+ iocinit_req.sense_buffer_length = cpu_to_le16(MPI3MR_SENSE_BUF_SZ);
26433037 iocinit_req.sense_buffer_free_queue_depth =
26443038 cpu_to_le16(mrioc->sense_buf_q_sz);
26453039 iocinit_req.sense_buffer_free_queue_address =
@@ -2659,12 +3053,9 @@ static int mpi3mr_issue_iocinit(struct mpi3mr_ioc *mrioc) · 13 unmodified lines
26593053 wait_for_completion_timeout(&mrioc->init_cmds.done,
26603054 (MPI3MR_INTADMCMD_TIMEOUT * HZ));
26613055 if (!(mrioc->init_cmds.state & MPI3MR_CMD_COMPLETE)) {
2662− mpi3mr_set_diagsave(mrioc);
2663− mpi3mr_issue_reset(mrioc,
2664− MPI3_SYSIF_HOST_DIAG_RESET_ACTION_DIAG_FAULT,
3056+ mpi3mr_check_rh_fault_ioc(mrioc,
26653057 MPI3MR_RESET_FROM_IOCINIT_TIMEOUT);
2666− mrioc->unrecoverable = 1;
2667− ioc_err(mrioc, "Issue IOCInit: command timed out\n");
3058+ ioc_err(mrioc, "ioc_init timed out\n");
26683059 retval = -1;
26693060 goto out_unlock;
26703061 }
@@ -2678,6 +3069,13 @@ static int mpi3mr_issue_iocinit(struct mpi3mr_ioc *mrioc) · 7 unmodified lines
26783069 goto out_unlock;
26793070 }
26803071
3072+ mrioc->reply_free_queue_host_index = mrioc->num_reply_bufs;
3073+ writel(mrioc->reply_free_queue_host_index,
3074+ &mrioc->sysif_regs->reply_free_host_index);
3075+
3076+ mrioc->sbq_host_index = mrioc->num_sense_bufs;
3077+ writel(mrioc->sbq_host_index,
3078+ &mrioc->sysif_regs->sense_buffer_free_host_index);
26813079 out_unlock:
26823080 mrioc->init_cmds.state = MPI3MR_CMD_NOTUSED;
26833081 mutex_unlock(&mrioc->init_cmds.mutex);
@@ -2755,12 +3153,9 @@ static int mpi3mr_issue_event_notification(struct mpi3mr_ioc *mrioc) · 71 unmodified lines
27553153 wait_for_completion_timeout(&mrioc->init_cmds.done,
27563154 (MPI3MR_INTADMCMD_TIMEOUT * HZ));
27573155 if (!(mrioc->init_cmds.state & MPI3MR_CMD_COMPLETE)) {
2758− ioc_err(mrioc, "Issue EvtNotify: command timed out\n");
2759− mpi3mr_set_diagsave(mrioc);
2760− mpi3mr_issue_reset(mrioc,
2761− MPI3_SYSIF_HOST_DIAG_RESET_ACTION_DIAG_FAULT,
3156+ ioc_err(mrioc, "event notification timed out\n");
3157+ mpi3mr_check_rh_fault_ioc(mrioc,
27623158 MPI3MR_RESET_FROM_EVTNOTIFY_TIMEOUT);
2763− mrioc->unrecoverable = 1;
27643159 retval = -1;
27653160 goto out_unlock;
27663161 }
@@ -2782,17 +3177,17 @@ out: · 15 unmodified lines
27823177 }
27833178
27843179 /**
2785− * mpi3mr_send_event_ack - Send event acknowledgment
3180+ * mpi3mr_process_event_ack - Process event acknowledgment
27863181 * @mrioc: Adapter instance reference
27873182 * @event: MPI3 event ID
2788− * @event_ctx: Event context
3183+ * @event_ctx: event context
27893184 *
27903185 * Send event acknowledgment through admin queue and wait for
27913186 * it to complete.
27923187 *
27933188 * Return: 0 on success, non-zero on failures.
27943189 */
2795−int mpi3mr_send_event_ack(struct mpi3mr_ioc *mrioc, u8 event,
3190+int mpi3mr_process_event_ack(struct mpi3mr_ioc *mrioc, u8 event,
27963191 u32 event_ctx)
27973192 {
27983193 struct mpi3_event_ack_request evtack_req;
@@ -2825,8 +3220,9 @@ int mpi3mr_send_event_ack(struct mpi3mr_ioc *mrioc, u8 event, · 26 unmodified lines
28253220 (MPI3MR_INTADMCMD_TIMEOUT * HZ));
28263221 if (!(mrioc->init_cmds.state & MPI3MR_CMD_COMPLETE)) {
28273222 ioc_err(mrioc, "Issue EvtNotify: command timed out\n");
2828− mpi3mr_soft_reset_handler(mrioc,
2829− MPI3MR_RESET_FROM_EVTACK_TIMEOUT, 1);
3223+ if (!(mrioc->init_cmds.state & MPI3MR_CMD_RESET))
3224+ mpi3mr_soft_reset_handler(mrioc,
3225+ MPI3MR_RESET_FROM_EVTACK_TIMEOUT, 1);
28303226 retval = -1;
28313227 goto out_unlock;
28323228 }
@@ -2863,6 +3259,9 @@ static int mpi3mr_alloc_chain_bufs(struct mpi3mr_ioc *mrioc) · 30 unmodified lines
28633259 u32 sz, i;
28643260 u16 num_chains;
28653261
3262+ if (mrioc->chain_sgl_list)
3263+ return retval;
3264+
28663265 num_chains = mrioc->max_host_ios / MPI3MR_CHAINBUF_FACTOR;
28673266
28683267 if (prot_mask & (SHOST_DIX_TYPE0_PROTECTION
@@ -2966,29 +3365,28 @@ int mpi3mr_issue_port_enable(struct mpi3mr_ioc *mrioc, u8 async) · 97 unmodified lines
29663365 ioc_err(mrioc, "Issue PortEnable: Admin Post failed\n");
29673366 goto out_unlock;
29683367 }
2969− if (!async) {
2970− wait_for_completion_timeout(&mrioc->init_cmds.done,
2971− (pe_timeout * HZ));
2972− if (!(mrioc->init_cmds.state & MPI3MR_CMD_COMPLETE)) {
2973− ioc_err(mrioc, "Issue PortEnable: command timed out\n");
2974− retval = -1;
2975− mrioc->scan_failed = MPI3_IOCSTATUS_INTERNAL_ERROR;
2976− mpi3mr_set_diagsave(mrioc);
2977− mpi3mr_issue_reset(mrioc,
2978− MPI3_SYSIF_HOST_DIAG_RESET_ACTION_DIAG_FAULT,
2979− MPI3MR_RESET_FROM_PE_TIMEOUT);
2980− mrioc->unrecoverable = 1;
2981− goto out_unlock;
2982− }
2983− mpi3mr_port_enable_complete(mrioc, &mrioc->init_cmds);
3368+ if (async) {
3369+ mutex_unlock(&mrioc->init_cmds.mutex);
3370+ goto out;
29843371 }
3372+
3373+ wait_for_completion_timeout(&mrioc->init_cmds.done, (pe_timeout * HZ));
3374+ if (!(mrioc->init_cmds.state & MPI3MR_CMD_COMPLETE)) {
3375+ ioc_err(mrioc, "port enable timed out\n");
3376+ retval = -1;
3377+ mpi3mr_check_rh_fault_ioc(mrioc, MPI3MR_RESET_FROM_PE_TIMEOUT);
3378+ goto out_unlock;
3379+ }
3380+ mpi3mr_port_enable_complete(mrioc, &mrioc->init_cmds);
3381+
29853382 out_unlock:
3383+ mrioc->init_cmds.state = MPI3MR_CMD_NOTUSED;
29863384 mutex_unlock(&mrioc->init_cmds.mutex);
29873385 out:
29883386 return retval;
29893387 }
29903388
2991−/* Protocol type to name mapper structure*/
3389+/* Protocol type to name mapper structure */
29923390 static const struct {
29933391 u8 protocol;
29943392 char *name;
@@ -3181,6 +3579,10 @@ int mpi3mr_setup_resources(struct mpi3mr_ioc *mrioc) · 186 unmodified lines
31813579 mrioc->sysif_regs, memap_sz);
31823580 ioc_info(mrioc, "Number of MSI-X vectors found in capabilities: (%d)\n",
31833581 mrioc->msix_count);
3582+
3583+ if (!reset_devices && poll_queues > 0)
3584+ mrioc->requested_poll_qcount = min_t(int, poll_queues,
3585+ mrioc->msix_count - 2);
31843586 return retval;
31853587
31863588 out_failed:
@@ -3188,6 +3590,46 @@ out_failed: · 1 unmodified line
31883590 return retval;
31893591 }
31903592
3593+/**
3594+ * mpi3mr_enable_events - Enable required events
3595+ * @mrioc: Adapter instance reference
3596+ *
3597+ * This routine unmasks the events required by the driver by
3598+ * sennding appropriate event mask bitmapt through an event
3599+ * notification request.
3600+ *
3601+ * Return: 0 on success and non-zero on failure.
3602+ */
3603+static int mpi3mr_enable_events(struct mpi3mr_ioc *mrioc)
3604+{
3605+ int retval = 0;
3606+ u32 i;
3607+
3608+ for (i = 0; i < MPI3_EVENT_NOTIFY_EVENTMASK_WORDS; i++)
3609+ mrioc->event_masks[i] = -1;
3610+
3611+ mpi3mr_unmask_events(mrioc, MPI3_EVENT_DEVICE_ADDED);
3612+ mpi3mr_unmask_events(mrioc, MPI3_EVENT_DEVICE_INFO_CHANGED);
3613+ mpi3mr_unmask_events(mrioc, MPI3_EVENT_DEVICE_STATUS_CHANGE);
3614+ mpi3mr_unmask_events(mrioc, MPI3_EVENT_ENCL_DEVICE_STATUS_CHANGE);
3615+ mpi3mr_unmask_events(mrioc, MPI3_EVENT_SAS_TOPOLOGY_CHANGE_LIST);
3616+ mpi3mr_unmask_events(mrioc, MPI3_EVENT_SAS_DISCOVERY);
3617+ mpi3mr_unmask_events(mrioc, MPI3_EVENT_SAS_DEVICE_DISCOVERY_ERROR);
3618+ mpi3mr_unmask_events(mrioc, MPI3_EVENT_SAS_BROADCAST_PRIMITIVE);
3619+ mpi3mr_unmask_events(mrioc, MPI3_EVENT_PCIE_TOPOLOGY_CHANGE_LIST);
3620+ mpi3mr_unmask_events(mrioc, MPI3_EVENT_PCIE_ENUMERATION);
3621+ mpi3mr_unmask_events(mrioc, MPI3_EVENT_PREPARE_FOR_RESET);
3622+ mpi3mr_unmask_events(mrioc, MPI3_EVENT_CABLE_MGMT);
3623+ mpi3mr_unmask_events(mrioc, MPI3_EVENT_ENERGY_PACK_CHANGE);
3624+ mpi3mr_unmask_events(mrioc, MPI3_EVENT_TEMP_THRESHOLD);
3625+
3626+ retval = mpi3mr_issue_event_notification(mrioc);
3627+ if (retval)
3628+ ioc_err(mrioc, "failed to issue event notification %d\n",
3629+ retval);
3630+ return retval;
3631+}
3632+
31913633 /**
31923634 * mpi3mr_init_ioc - Initialize the controller
31933635 * @mrioc: Adapter instance reference
@@ -3204,227 +3646,240 @@ out_failed: · 10 unmodified lines
32043646 *
32053647 * Return: 0 on success and non-zero on failure.
32063648 */
3207−int mpi3mr_init_ioc(struct mpi3mr_ioc *mrioc, u8 init_type)
3649+int mpi3mr_init_ioc(struct mpi3mr_ioc *mrioc)
32083650 {
32093651 int retval = 0;
3210− enum mpi3mr_iocstate ioc_state;
3211− u64 base_info;
3212− u32 timeout;
3213− u32 ioc_status, ioc_config, i;
3652+ u8 retry = 0;
32143653 struct mpi3_ioc_facts_data facts_data;
32153654
3216− mrioc->irqpoll_sleep = MPI3MR_IRQ_POLL_SLEEP;
3217− mrioc->change_count = 0;
3218− if (init_type == MPI3MR_IT_INIT) {
3219− mrioc->cpu_count = num_online_cpus();
3220− retval = mpi3mr_setup_resources(mrioc);
3221− if (retval) {
3222− ioc_err(mrioc, "Failed to setup resources:error %d\n",
3223− retval);
3224− goto out_nocleanup;
3225− }
3655+retry_init:
3656+ retval = mpi3mr_bring_ioc_ready(mrioc);
3657+ if (retval) {
3658+ ioc_err(mrioc, "Failed to bring ioc ready: error %d\n",
3659+ retval);
3660+ goto out_failed_noretry;
32263661 }
32273662
3228− ioc_status = readl(&mrioc->sysif_regs->ioc_status);
3229− ioc_config = readl(&mrioc->sysif_regs->ioc_configuration);
3663+ retval = mpi3mr_setup_isr(mrioc, 1);
3664+ if (retval) {
3665+ ioc_err(mrioc, "Failed to setup ISR error %d\n",
3666+ retval);
3667+ goto out_failed_noretry;
3668+ }
32303669
3231− ioc_info(mrioc, "SOD status %x configuration %x\n",
3232− ioc_status, ioc_config);
3670+ retval = mpi3mr_issue_iocfacts(mrioc, &facts_data);
3671+ if (retval) {
3672+ ioc_err(mrioc, "Failed to Issue IOC Facts %d\n",
3673+ retval);
3674+ goto out_failed;
3675+ }
32333676
3234− base_info = lo_hi_readq(&mrioc->sysif_regs->ioc_information);
3235− ioc_info(mrioc, "SOD base_info %llx\n", base_info);
3677+ mrioc->max_host_ios = mrioc->facts.max_reqs - MPI3MR_INTERNAL_CMDS_RESVD;
32363678
3237− /*The timeout value is in 2sec unit, changing it to seconds*/
3238− mrioc->ready_timeout =
3239− ((base_info & MPI3_SYSIF_IOC_INFO_LOW_TIMEOUT_MASK) >>
3240− MPI3_SYSIF_IOC_INFO_LOW_TIMEOUT_SHIFT) * 2;
3679+ if (reset_devices)
3680+ mrioc->max_host_ios = min_t(int, mrioc->max_host_ios,
3681+ MPI3MR_HOST_IOS_KDUMP);
32413682
3242− ioc_info(mrioc, "IOC ready timeout %d\n", mrioc->ready_timeout);
3683+ mrioc->reply_sz = mrioc->facts.reply_sz;
32433684
3244− ioc_state = mpi3mr_get_iocstate(mrioc);
3245− ioc_info(mrioc, "IOC in %s state during detection\n",
3246− mpi3mr_iocstate_name(ioc_state));
3685+ retval = mpi3mr_check_reset_dma_mask(mrioc);
3686+ if (retval) {
3687+ ioc_err(mrioc, "Resetting dma mask failed %d\n",
3688+ retval);
3689+ goto out_failed_noretry;
3690+ }
32473691
3248− if (ioc_state == MRIOC_STATE_BECOMING_READY ||
3249− ioc_state == MRIOC_STATE_RESET_REQUESTED) {
3250− timeout = mrioc->ready_timeout * 10;
3251− do {
3252− msleep(100);
3253− } while (--timeout);
3692+ mpi3mr_print_ioc_info(mrioc);
32543693
3255− ioc_state = mpi3mr_get_iocstate(mrioc);
3256− ioc_info(mrioc,
3257− "IOC in %s state after waiting for reset time\n",
3258− mpi3mr_iocstate_name(ioc_state));
3694+ retval = mpi3mr_alloc_reply_sense_bufs(mrioc);
3695+ if (retval) {
3696+ ioc_err(mrioc,
3697+ "%s :Failed to allocated reply sense buffers %d\n",
3698+ __func__, retval);
3699+ goto out_failed_noretry;
32593700 }
32603701
3261− if (ioc_state == MRIOC_STATE_READY) {
3262− retval = mpi3mr_issue_and_process_mur(mrioc,
3263− MPI3MR_RESET_FROM_BRINGUP);
3264− if (retval) {
3265− ioc_err(mrioc, "Failed to MU reset IOC error %d\n",
3266− retval);
3267− }
3268− ioc_state = mpi3mr_get_iocstate(mrioc);
3702+ retval = mpi3mr_alloc_chain_bufs(mrioc);
3703+ if (retval) {
3704+ ioc_err(mrioc, "Failed to allocated chain buffers %d\n",
3705+ retval);
3706+ goto out_failed_noretry;
32693707 }
3270− if (ioc_state != MRIOC_STATE_RESET) {
3271− mpi3mr_print_fault_info(mrioc);
3272− retval = mpi3mr_issue_reset(mrioc,
3273− MPI3_SYSIF_HOST_DIAG_RESET_ACTION_SOFT_RESET,
3274− MPI3MR_RESET_FROM_BRINGUP);
3275− if (retval) {
3276− ioc_err(mrioc,
3277− "%s :Failed to soft reset IOC error %d\n",
3278− __func__, retval);
3279− goto out_failed;
3280− }
3708+
3709+ retval = mpi3mr_issue_iocinit(mrioc);
3710+ if (retval) {
3711+ ioc_err(mrioc, "Failed to Issue IOC Init %d\n",
3712+ retval);
3713+ goto out_failed;
32813714 }
3282− ioc_state = mpi3mr_get_iocstate(mrioc);
3283− if (ioc_state != MRIOC_STATE_RESET) {
3284− retval = -1;
3285− ioc_err(mrioc, "Cannot bring IOC to reset state\n");
3715+
3716+ retval = mpi3mr_print_pkg_ver(mrioc);
3717+ if (retval) {
3718+ ioc_err(mrioc, "failed to get package version\n");
32863719 goto out_failed;
32873720 }
32883721
3289− retval = mpi3mr_setup_admin_qpair(mrioc);
3722+ retval = mpi3mr_setup_isr(mrioc, 0);
32903723 if (retval) {
3291− ioc_err(mrioc, "Failed to setup admin Qs: error %d\n",
3724+ ioc_err(mrioc, "Failed to re-setup ISR, error %d\n",
3725+ retval);
3726+ goto out_failed_noretry;
3727+ }
3728+
3729+ retval = mpi3mr_create_op_queues(mrioc);
3730+ if (retval) {
3731+ ioc_err(mrioc, "Failed to create OpQueues error %d\n",
32923732 retval);
32933733 goto out_failed;
32943734 }
32953735
3296− retval = mpi3mr_bring_ioc_ready(mrioc);
3736+ retval = mpi3mr_enable_events(mrioc);
32973737 if (retval) {
3298− ioc_err(mrioc, "Failed to bring ioc ready: error %d\n",
3738+ ioc_err(mrioc, "failed to enable events %d\n",
32993739 retval);
33003740 goto out_failed;
33013741 }
33023742
3303− if (init_type != MPI3MR_IT_RESET) {
3743+ ioc_info(mrioc, "controller initialization completed successfully\n");
3744+ return retval;
3745+out_failed:
3746+ if (retry < 2) {
3747+ retry++;
3748+ ioc_warn(mrioc, "retrying controller initialization, retry_count:%d\n",
3749+ retry);
3750+ mpi3mr_memset_buffers(mrioc);
3751+ goto retry_init;
3752+ }
3753+out_failed_noretry:
3754+ ioc_err(mrioc, "controller initialization failed\n");
3755+ mpi3mr_issue_reset(mrioc, MPI3_SYSIF_HOST_DIAG_RESET_ACTION_DIAG_FAULT,
3756+ MPI3MR_RESET_FROM_CTLR_CLEANUP);
3757+ mrioc->unrecoverable = 1;
3758+ return retval;
3759+}
3760+
3761+/**
3762+ * mpi3mr_reinit_ioc - Re-Initialize the controller
3763+ * @mrioc: Adapter instance reference
3764+ * @is_resume: Called from resume or reset path
3765+ *
3766+ * This the controller re-initialization routine, executed from
3767+ * the soft reset handler or resume callback. Creates
3768+ * operational reply queue pairs, allocate required memory for
3769+ * reply pool, sense buffer pool, issue IOC init request to the
3770+ * firmware, unmask the events and issue port enable to discover
3771+ * SAS/SATA/NVMe devices and RAID volumes.
3772+ *
3773+ * Return: 0 on success and non-zero on failure.
3774+ */
3775+int mpi3mr_reinit_ioc(struct mpi3mr_ioc *mrioc, u8 is_resume)
3776+{
3777+ int retval = 0;
3778+ u8 retry = 0;
3779+ struct mpi3_ioc_facts_data facts_data;
3780+
3781+retry_init:
3782+ dprint_reset(mrioc, "bringing up the controller to ready state\n");
3783+ retval = mpi3mr_bring_ioc_ready(mrioc);
3784+ if (retval) {
3785+ ioc_err(mrioc, "failed to bring to ready state\n");
3786+ goto out_failed_noretry;
3787+ }
3788+
3789+ if (is_resume) {
3790+ dprint_reset(mrioc, "setting up single ISR\n");
33043791 retval = mpi3mr_setup_isr(mrioc, 1);
33053792 if (retval) {
3306− ioc_err(mrioc, "Failed to setup ISR error %d\n",
3307− retval);
3308− goto out_failed;
3793+ ioc_err(mrioc, "failed to setup ISR\n");
3794+ goto out_failed_noretry;
33093795 }
33103796 } else
33113797 mpi3mr_ioc_enable_intr(mrioc);
33123798
3799+ dprint_reset(mrioc, "getting ioc_facts\n");
33133800 retval = mpi3mr_issue_iocfacts(mrioc, &facts_data);
33143801 if (retval) {
3315− ioc_err(mrioc, "Failed to Issue IOC Facts %d\n",
3316− retval);
3802+ ioc_err(mrioc, "failed to get ioc_facts\n");
33173803 goto out_failed;
33183804 }
33193805
3320− mpi3mr_process_factsdata(mrioc, &facts_data);
3321− if (init_type == MPI3MR_IT_INIT) {
3322− retval = mpi3mr_check_reset_dma_mask(mrioc);
3323− if (retval) {
3324− ioc_err(mrioc, "Resetting dma mask failed %d\n",
3325− retval);
3326− goto out_failed;
3327− }
3806+ dprint_reset(mrioc, "validating ioc_facts\n");
3807+ retval = mpi3mr_revalidate_factsdata(mrioc);
3808+ if (retval) {
3809+ ioc_err(mrioc, "failed to revalidate ioc_facts data\n");
3810+ goto out_failed_noretry;
33283811 }
33293812
33303813 mpi3mr_print_ioc_info(mrioc);
33313814
3332− retval = mpi3mr_alloc_reply_sense_bufs(mrioc);
3815+ dprint_reset(mrioc, "sending ioc_init\n");
3816+ retval = mpi3mr_issue_iocinit(mrioc);
33333817 if (retval) {
3334− ioc_err(mrioc,
3335− "%s :Failed to allocated reply sense buffers %d\n",
3336− __func__, retval);
3818+ ioc_err(mrioc, "failed to send ioc_init\n");
33373819 goto out_failed;
33383820 }
33393821
3340− if (init_type == MPI3MR_IT_INIT) {
3341− retval = mpi3mr_alloc_chain_bufs(mrioc);
3342− if (retval) {
3343− ioc_err(mrioc, "Failed to allocated chain buffers %d\n",
3344− retval);
3345− goto out_failed;
3346− }
3347− }
3348−
3349− retval = mpi3mr_issue_iocinit(mrioc);
3822+ dprint_reset(mrioc, "getting package version\n");
3823+ retval = mpi3mr_print_pkg_ver(mrioc);
33503824 if (retval) {
3351− ioc_err(mrioc, "Failed to Issue IOC Init %d\n",
3352− retval);
3825+ ioc_err(mrioc, "failed to get package version\n");
33533826 goto out_failed;
33543827 }
3355− mrioc->reply_free_queue_host_index = mrioc->num_reply_bufs;
3356− writel(mrioc->reply_free_queue_host_index,
3357− &mrioc->sysif_regs->reply_free_host_index);
33583828
3359− mrioc->sbq_host_index = mrioc->num_sense_bufs;
3360− writel(mrioc->sbq_host_index,
3361− &mrioc->sysif_regs->sense_buffer_free_host_index);
3362−
3363− if (init_type != MPI3MR_IT_RESET) {
3829+ if (is_resume) {
3830+ dprint_reset(mrioc, "setting up multiple ISR\n");
33643831 retval = mpi3mr_setup_isr(mrioc, 0);
33653832 if (retval) {
3366− ioc_err(mrioc, "Failed to re-setup ISR, error %d\n",
3367− retval);
3368− goto out_failed;
3833+ ioc_err(mrioc, "failed to re-setup ISR\n");
3834+ goto out_failed_noretry;
33693835 }
33703836 }
33713837
3838+ dprint_reset(mrioc, "creating operational queue pairs\n");
33723839 retval = mpi3mr_create_op_queues(mrioc);
33733840 if (retval) {
3374− ioc_err(mrioc, "Failed to create OpQueues error %d\n",
3375− retval);
3841+ ioc_err(mrioc, "failed to create operational queue pairs\n");
33763842 goto out_failed;
33773843 }
33783844
3379− if ((init_type != MPI3MR_IT_INIT) &&
3380− (mrioc->shost->nr_hw_queues > mrioc->num_op_reply_q)) {
3381− retval = -1;
3845+ if (mrioc->shost->nr_hw_queues > mrioc->num_op_reply_q) {
33823846 ioc_err(mrioc,
3383− "Cannot create minimum number of OpQueues expected:%d created:%d\n",
3847+ "cannot create minimum number of operatioanl queues expected:%d created:%d\n",
33843848 mrioc->shost->nr_hw_queues, mrioc->num_op_reply_q);
3385− goto out_failed;
3849+ goto out_failed_noretry;
33863850 }
33873851
3388− for (i = 0; i < MPI3_EVENT_NOTIFY_EVENTMASK_WORDS; i++)
3389− mrioc->event_masks[i] = -1;
3390−
3391− mpi3mr_unmask_events(mrioc, MPI3_EVENT_DEVICE_ADDED);
3392− mpi3mr_unmask_events(mrioc, MPI3_EVENT_DEVICE_INFO_CHANGED);
3393− mpi3mr_unmask_events(mrioc, MPI3_EVENT_DEVICE_STATUS_CHANGE);
3394− mpi3mr_unmask_events(mrioc, MPI3_EVENT_ENCL_DEVICE_STATUS_CHANGE);
3395− mpi3mr_unmask_events(mrioc, MPI3_EVENT_SAS_TOPOLOGY_CHANGE_LIST);
3396− mpi3mr_unmask_events(mrioc, MPI3_EVENT_SAS_DISCOVERY);
3397− mpi3mr_unmask_events(mrioc, MPI3_EVENT_SAS_DEVICE_DISCOVERY_ERROR);
3398− mpi3mr_unmask_events(mrioc, MPI3_EVENT_SAS_BROADCAST_PRIMITIVE);
3399− mpi3mr_unmask_events(mrioc, MPI3_EVENT_PCIE_TOPOLOGY_CHANGE_LIST);
3400− mpi3mr_unmask_events(mrioc, MPI3_EVENT_PCIE_ENUMERATION);
3401− mpi3mr_unmask_events(mrioc, MPI3_EVENT_CABLE_MGMT);
3402− mpi3mr_unmask_events(mrioc, MPI3_EVENT_ENERGY_PACK_CHANGE);
3403−
3404− retval = mpi3mr_issue_event_notification(mrioc);
3852+ dprint_reset(mrioc, "enabling events\n");
3853+ retval = mpi3mr_enable_events(mrioc);
34053854 if (retval) {
3406− ioc_err(mrioc, "Failed to issue event notification %d\n",
3407− retval);
3855+ ioc_err(mrioc, "failed to enable events\n");
34083856 goto out_failed;
34093857 }
34103858
3411− if (init_type != MPI3MR_IT_INIT) {
3412− ioc_info(mrioc, "Issuing Port Enable\n");
3413− retval = mpi3mr_issue_port_enable(mrioc, 0);
3414− if (retval) {
3415− ioc_err(mrioc, "Failed to issue port enable %d\n",
3416− retval);
3417− goto out_failed;
3418− }
3859+ ioc_info(mrioc, "sending port enable\n");
3860+ retval = mpi3mr_issue_port_enable(mrioc, 0);
3861+ if (retval) {
3862+ ioc_err(mrioc, "failed to issue port enable\n");
3863+ goto out_failed;
34193864 }
3420− return retval;
34213865
3866+ ioc_info(mrioc, "controller %s completed successfully\n",
3867+ (is_resume)?"resume":"re-initialization");
3868+ return retval;
34223869 out_failed:
3423− if (init_type == MPI3MR_IT_INIT)
3424− mpi3mr_cleanup_ioc(mrioc, MPI3MR_COMPLETE_CLEANUP);
3425− else
3426− mpi3mr_cleanup_ioc(mrioc, MPI3MR_REINIT_FAILURE);
3427−out_nocleanup:
3870+ if (retry < 2) {
3871+ retry++;
3872+ ioc_warn(mrioc, "retrying controller %s, retry_count:%d\n",
3873+ (is_resume)?"resume":"re-initialization", retry);
3874+ mpi3mr_memset_buffers(mrioc);
3875+ goto retry_init;
3876+ }
3877+out_failed_noretry:
3878+ ioc_err(mrioc, "controller %s is failed\n",
3879+ (is_resume)?"resume":"re-initialization");
3880+ mpi3mr_issue_reset(mrioc, MPI3_SYSIF_HOST_DIAG_RESET_ACTION_DIAG_FAULT,
3881+ MPI3MR_RESET_FROM_CTLR_CLEANUP);
3882+ mrioc->unrecoverable = 1;
34283883 return retval;
34293884 }
34303885
@@ -3488,17 +3943,29 @@ void mpi3mr_memset_buffers(struct mpi3mr_ioc *mrioc) · 57 unmodified lines
34883943 {
34893944 u16 i;
34903945
3491− memset(mrioc->admin_req_base, 0, mrioc->admin_req_q_sz);
3492− memset(mrioc->admin_reply_base, 0, mrioc->admin_reply_q_sz);
3493−
3494− memset(mrioc->init_cmds.reply, 0, sizeof(*mrioc->init_cmds.reply));
3495− memset(mrioc->host_tm_cmds.reply, 0,
3496− sizeof(*mrioc->host_tm_cmds.reply));
3497− for (i = 0; i < MPI3MR_NUM_DEVRMCMD; i++)
3498− memset(mrioc->dev_rmhs_cmds[i].reply, 0,
3499− sizeof(*mrioc->dev_rmhs_cmds[i].reply));
3500− memset(mrioc->removepend_bitmap, 0, mrioc->dev_handle_bitmap_sz);
3501− memset(mrioc->devrem_bitmap, 0, mrioc->devrem_bitmap_sz);
3946+ mrioc->change_count = 0;
3947+ mrioc->active_poll_qcount = 0;
3948+ mrioc->default_qcount = 0;
3949+ if (mrioc->admin_req_base)
3950+ memset(mrioc->admin_req_base, 0, mrioc->admin_req_q_sz);
3951+ if (mrioc->admin_reply_base)
3952+ memset(mrioc->admin_reply_base, 0, mrioc->admin_reply_q_sz);
3953+
3954+ if (mrioc->init_cmds.reply) {
3955+ memset(mrioc->init_cmds.reply, 0, sizeof(*mrioc->init_cmds.reply));
3956+ memset(mrioc->host_tm_cmds.reply, 0,
3957+ sizeof(*mrioc->host_tm_cmds.reply));
3958+ for (i = 0; i < MPI3MR_NUM_DEVRMCMD; i++)
3959+ memset(mrioc->dev_rmhs_cmds[i].reply, 0,
3960+ sizeof(*mrioc->dev_rmhs_cmds[i].reply));
3961+ for (i = 0; i < MPI3MR_NUM_EVTACKCMD; i++)
3962+ memset(mrioc->evtack_cmds[i].reply, 0,
3963+ sizeof(*mrioc->evtack_cmds[i].reply));
3964+ memset(mrioc->removepend_bitmap, 0, mrioc->dev_handle_bitmap_sz);
3965+ memset(mrioc->devrem_bitmap, 0, mrioc->devrem_bitmap_sz);
3966+ memset(mrioc->evtack_cmds_bitmap, 0,
3967+ mrioc->evtack_cmds_bitmap_sz);
3968+ }
35023969
35033970 for (i = 0; i < mrioc->num_queues; i++) {
35043971 mrioc->op_reply_qinfo[i].qid = 0;
@@ -3527,7 +3994,7 @@ void mpi3mr_memset_buffers(struct mpi3mr_ioc *mrioc) · 22 unmodified lines
35273994 *
35283995 * Return: Nothing.
35293996 */
3530−static void mpi3mr_free_mem(struct mpi3mr_ioc *mrioc)
3997+void mpi3mr_free_mem(struct mpi3mr_ioc *mrioc)
35313998 {
35323999 u16 i;
35334000 struct mpi3mr_intr_info *intr_info;
@@ -3591,12 +4058,20 @@ static void mpi3mr_free_mem(struct mpi3mr_ioc *mrioc) · 57 unmodified lines
35914058 kfree(mrioc->host_tm_cmds.reply);
35924059 mrioc->host_tm_cmds.reply = NULL;
35934060
4061+ for (i = 0; i < MPI3MR_NUM_EVTACKCMD; i++) {
4062+ kfree(mrioc->evtack_cmds[i].reply);
4063+ mrioc->evtack_cmds[i].reply = NULL;
4064+ }
4065+
35944066 kfree(mrioc->removepend_bitmap);
35954067 mrioc->removepend_bitmap = NULL;
35964068
35974069 kfree(mrioc->devrem_bitmap);
35984070 mrioc->devrem_bitmap = NULL;
35994071
4072+ kfree(mrioc->evtack_cmds_bitmap);
4073+ mrioc->evtack_cmds_bitmap = NULL;
4074+
36004075 kfree(mrioc->chain_bitmap);
36014076 mrioc->chain_bitmap = NULL;
36024077
@@ -3663,7 +4138,7 @@ static void mpi3mr_issue_ioc_shutdown(struct mpi3mr_ioc *mrioc) · 60 unmodified lines
36634138
36644139 ioc_config = readl(&mrioc->sysif_regs->ioc_configuration);
36654140 ioc_config |= MPI3_SYSIF_IOC_CONFIG_SHUTDOWN_NORMAL;
3666− ioc_config |= MPI3_SYSIF_IOC_CONFIG_DEVICE_SHUTDOWN;
4141+ ioc_config |= MPI3_SYSIF_IOC_CONFIG_DEVICE_SHUTDOWN_SEND_REQ;
36674142
36684143 writel(ioc_config, &mrioc->sysif_regs->ioc_configuration);
36694144
@@ -3699,21 +4174,17 @@ static void mpi3mr_issue_ioc_shutdown(struct mpi3mr_ioc *mrioc) · 29 unmodified lines
36994174 /**
37004175 * mpi3mr_cleanup_ioc - Cleanup controller
37014176 * @mrioc: Adapter instance reference
3702− * @reason: Cleanup reason
3703− *
4177+
37044178 * controller cleanup handler, Message unit reset or soft reset
3705− * and shutdown notification is issued to the controller and the
3706− * associated memory resources are freed.
4179+ * and shutdown notification is issued to the controller.
37074180 *
37084181 * Return: Nothing.
37094182 */
3710−void mpi3mr_cleanup_ioc(struct mpi3mr_ioc *mrioc, u8 reason)
4183+void mpi3mr_cleanup_ioc(struct mpi3mr_ioc *mrioc)
37114184 {
37124185 enum mpi3mr_iocstate ioc_state;
37134186
3714− if (reason == MPI3MR_COMPLETE_CLEANUP)
3715− mpi3mr_stop_watchdog(mrioc);
3716−
4187+ dprint_exit(mrioc, "cleaning up the controller\n");
37174188 mpi3mr_ioc_disable_intr(mrioc);
37184189
37194190 ioc_state = mpi3mr_get_iocstate(mrioc);
@@ -3725,15 +4196,9 @@ void mpi3mr_cleanup_ioc(struct mpi3mr_ioc *mrioc, u8 reason) · 5 unmodified lines
37254196 mpi3mr_issue_reset(mrioc,
37264197 MPI3_SYSIF_HOST_DIAG_RESET_ACTION_SOFT_RESET,
37274198 MPI3MR_RESET_FROM_MUR_FAILURE);
3728−
3729− if (reason != MPI3MR_REINIT_FAILURE)
3730− mpi3mr_issue_ioc_shutdown(mrioc);
3731− }
3732−
3733− if (reason == MPI3MR_COMPLETE_CLEANUP) {
3734− mpi3mr_free_mem(mrioc);
3735− mpi3mr_cleanup_resources(mrioc);
4199+ mpi3mr_issue_ioc_shutdown(mrioc);
37364200 }
4201+ dprint_exit(mrioc, "controller cleanup completed\n");
37374202 }
37384203
37394204 /**
@@ -3782,41 +4247,11 @@ static void mpi3mr_flush_drv_cmds(struct mpi3mr_ioc *mrioc) · 42 unmodified lines
37824247 cmdptr = &mrioc->dev_rmhs_cmds[i];
37834248 mpi3mr_drv_cmd_comp_reset(mrioc, cmdptr);
37844249 }
3785−}
3786−
3787−/**
3788− * mpi3mr_diagfault_reset_handler - Diag fault reset handler
3789− * @mrioc: Adapter instance reference
3790− * @reset_reason: Reset reason code
3791− *
3792− * This is an handler for issuing diag fault reset from the
3793− * applications through IOCTL path to stop the execution of the
3794− * controller
3795− *
3796− * Return: 0 on success, non-zero on failure.
3797− */
3798−int mpi3mr_diagfault_reset_handler(struct mpi3mr_ioc *mrioc,
3799− u32 reset_reason)
3800−{
3801− int retval = 0;
3802−
3803− ioc_info(mrioc, "Entry: reason code: %s\n",
3804− mpi3mr_reset_rc_name(reset_reason));
3805− mrioc->reset_in_progress = 1;
3806−
3807− mpi3mr_ioc_disable_intr(mrioc);
3808−
3809− retval = mpi3mr_issue_reset(mrioc,
3810− MPI3_SYSIF_HOST_DIAG_RESET_ACTION_DIAG_FAULT, reset_reason);
38114250
3812− if (retval) {
3813− ioc_err(mrioc, "The diag fault reset failed: reason %d\n",
3814− reset_reason);
3815− mpi3mr_ioc_enable_intr(mrioc);
4251+ for (i = 0; i < MPI3MR_NUM_EVTACKCMD; i++) {
4252+ cmdptr = &mrioc->evtack_cmds[i];
4253+ mpi3mr_drv_cmd_comp_reset(mrioc, cmdptr);
38164254 }
3817− ioc_info(mrioc, "%s\n", ((retval == 0) ? "SUCCESS" : "FAILED"));
3818− mrioc->reset_in_progress = 0;
3819− return retval;
38204255 }
38214256
38224257 /**
@@ -3847,34 +4282,44 @@ int mpi3mr_soft_reset_handler(struct mpi3mr_ioc *mrioc, · 24 unmodified lines
38474282 unsigned long flags;
38484283 u32 host_diagnostic, timeout = MPI3_SYSIF_DIAG_SAVE_TIMEOUT * 10;
38494284
3850− if (mrioc->fault_dbg) {
3851− if (snapdump)
3852− mpi3mr_set_diagsave(mrioc);
3853− mpi3mr_kill_ioc(mrioc, reset_reason);
3854− }
3855−
4285+ /* Block the reset handler until diag save in progress*/
4286+ dprint_reset(mrioc,
4287+ "soft_reset_handler: check and block on diagsave_timeout(%d)\n",
4288+ mrioc->diagsave_timeout);
4289+ while (mrioc->diagsave_timeout)
4290+ ssleep(1);
38564291 /*
38574292 * Block new resets until the currently executing one is finished and
38584293 * return the status of the existing reset for all blocked resets
38594294 */
4295+ dprint_reset(mrioc, "soft_reset_handler: acquiring reset_mutex\n");
38604296 if (!mutex_trylock(&mrioc->reset_mutex)) {
3861− ioc_info(mrioc, "Another reset in progress\n");
3862− return -1;
4297+ ioc_info(mrioc,
4298+ "controller reset triggered by %s is blocked due to another reset in progress\n",
4299+ mpi3mr_reset_rc_name(reset_reason));
4300+ do {
4301+ ssleep(1);
4302+ } while (mrioc->reset_in_progress == 1);
4303+ ioc_info(mrioc,
4304+ "returning previous reset result(%d) for the reset triggered by %s\n",
4305+ mrioc->prev_reset_result,
4306+ mpi3mr_reset_rc_name(reset_reason));
4307+ return mrioc->prev_reset_result;
38634308 }
4309+ ioc_info(mrioc, "controller reset is triggered by %s\n",
4310+ mpi3mr_reset_rc_name(reset_reason));
4311+
38644312 mrioc->reset_in_progress = 1;
4313+ mrioc->prev_reset_result = -1;
38654314
38664315 if ((!snapdump) && (reset_reason != MPI3MR_RESET_FROM_FAULT_WATCH) &&
4316+ (reset_reason != MPI3MR_RESET_FROM_FIRMWARE) &&
38674317 (reset_reason != MPI3MR_RESET_FROM_CIACTIV_FAULT)) {
38684318 for (i = 0; i < MPI3_EVENT_NOTIFY_EVENTMASK_WORDS; i++)
38694319 mrioc->event_masks[i] = -1;
38704320
3871− retval = mpi3mr_issue_event_notification(mrioc);
3872−
3873− if (retval) {
3874− ioc_err(mrioc,
3875− "Failed to turn off events prior to reset %d\n",
3876− retval);
3877− }
4321+ dprint_reset(mrioc, "soft_reset_handler: masking events\n");
4322+ mpi3mr_issue_event_notification(mrioc);
38784323 }
38794324
38804325 mpi3mr_wait_for_host_io(mrioc, MPI3MR_RESET_HOST_IOWAIT_TIMEOUT);
@@ -3904,15 +4349,20 @@ int mpi3mr_soft_reset_handler(struct mpi3mr_ioc *mrioc, · 23 unmodified lines
39044349 goto out;
39054350 }
39064351
3907− mpi3mr_flush_delayed_rmhs_list(mrioc);
4352+ mpi3mr_flush_delayed_cmd_lists(mrioc);
39084353 mpi3mr_flush_drv_cmds(mrioc);
39094354 memset(mrioc->devrem_bitmap, 0, mrioc->devrem_bitmap_sz);
39104355 memset(mrioc->removepend_bitmap, 0, mrioc->dev_handle_bitmap_sz);
4356+ memset(mrioc->evtack_cmds_bitmap, 0, mrioc->evtack_cmds_bitmap_sz);
39114357 mpi3mr_cleanup_fwevt_list(mrioc);
39124358 mpi3mr_flush_host_io(mrioc);
39134359 mpi3mr_invalidate_devhandles(mrioc);
4360+ if (mrioc->prepare_for_reset) {
4361+ mrioc->prepare_for_reset = 0;
4362+ mrioc->prepare_for_reset_timeout_counter = 0;
4363+ }
39144364 mpi3mr_memset_buffers(mrioc);
3915− retval = mpi3mr_init_ioc(mrioc, MPI3MR_IT_RESET);
4365+ retval = mpi3mr_reinit_ioc(mrioc, 0);
39164366 if (retval) {
39174367 pr_err(IOCNAME "reinit after soft reset failed: reason %d\n",
39184368 mrioc->name, reset_reason);
@@ -3922,8 +4372,8 @@ int mpi3mr_soft_reset_handler(struct mpi3mr_ioc *mrioc, · 3 unmodified lines
39224372
39234373 out:
39244374 if (!retval) {
4375+ mrioc->diagsave_timeout = 0;
39254376 mrioc->reset_in_progress = 0;
3926− scsi_unblock_requests(mrioc->shost);
39274377 mpi3mr_rfresh_tgtdevs(mrioc);
39284378 mrioc->ts_update_counter = 0;
39294379 spin_lock_irqsave(&mrioc->watchdog_lock, flags);
@@ -3939,8 +4389,9 @@ out: · 9 unmodified lines
39394389 mrioc->reset_in_progress = 0;
39404390 retval = -1;
39414391 }
3942−
4392+ mrioc->prev_reset_result = retval;
39434393 mutex_unlock(&mrioc->reset_mutex);
3944− ioc_info(mrioc, "%s\n", ((retval == 0) ? "SUCCESS" : "FAILED"));
4394+ ioc_info(mrioc, "controller reset is %s\n",
4395+ ((retval == 0) ? "successful" : "failed"));
39454396 return retval;
39464397 }
drivers/scsi/mpi3mr/mpi3mr_os.c+642−129
@@ -34,6 +34,9 @@ MODULE_PARM_DESC(logging_level, · 33 unmodified lines
3434 " bits for enabling additional logging info (default=0)");
3535
3636 /* Forward declarations*/
37+static void mpi3mr_send_event_ack(struct mpi3mr_ioc *mrioc, u8 event,
38+ struct mpi3mr_drv_cmd *cmdparam, u32 event_ctx);
39+
3740 /**
3841 * mpi3mr_host_tag_for_scmd - Get host tag for a scmd
3942 * @mrioc: Adapter instance reference
@@ -417,6 +420,74 @@ out: · 377 unmodified lines
417420 return(true);
418421 }
419422
423+/**
424+ * mpi3mr_count_dev_pending - Count commands pending for a lun
425+ * @rq: Block request
426+ * @data: SCSI device reference
427+ * @reserved: Unused
428+ *
429+ * This is an iterator function called for each SCSI command in
430+ * a host and if the command is pending in the LLD for the
431+ * specific device(lun) then device specific pending I/O counter
432+ * is updated in the device structure.
433+ *
434+ * Return: true always.
435+ */
436+
437+static bool mpi3mr_count_dev_pending(struct request *rq,
438+ void *data, bool reserved)
439+{
440+ struct scsi_device *sdev = (struct scsi_device *)data;
441+ struct mpi3mr_sdev_priv_data *sdev_priv_data = sdev->hostdata;
442+ struct scsi_cmnd *scmd = blk_mq_rq_to_pdu(rq);
443+ struct scmd_priv *priv;
444+
445+ if (scmd) {
446+ priv = scsi_cmd_priv(scmd);
447+ if (!priv->in_lld_scope)
448+ goto out;
449+ if (scmd->device == sdev)
450+ sdev_priv_data->pend_count++;
451+ }
452+
453+out:
454+ return true;
455+}
456+
457+/**
458+ * mpi3mr_count_tgt_pending - Count commands pending for target
459+ * @rq: Block request
460+ * @data: SCSI target reference
461+ * @reserved: Unused
462+ *
463+ * This is an iterator function called for each SCSI command in
464+ * a host and if the command is pending in the LLD for the
465+ * specific target then target specific pending I/O counter is
466+ * updated in the target structure.
467+ *
468+ * Return: true always.
469+ */
470+
471+static bool mpi3mr_count_tgt_pending(struct request *rq,
472+ void *data, bool reserved)
473+{
474+ struct scsi_target *starget = (struct scsi_target *)data;
475+ struct mpi3mr_stgt_priv_data *stgt_priv_data = starget->hostdata;
476+ struct scsi_cmnd *scmd = blk_mq_rq_to_pdu(rq);
477+ struct scmd_priv *priv;
478+
479+ if (scmd) {
480+ priv = scsi_cmd_priv(scmd);
481+ if (!priv->in_lld_scope)
482+ goto out;
483+ if (scmd->device && (scsi_target(scmd->device) == starget))
484+ stgt_priv_data->pend_count++;
485+ }
486+
487+out:
488+ return true;
489+}
490+
420491 /**
421492 * mpi3mr_flush_host_io - Flush host I/Os
422493 * @mrioc: Adapter instance reference
@@ -742,11 +813,18 @@ mpi3mr_update_sdev(struct scsi_device *sdev, void *data) · 319 unmodified lines
742813 switch (tgtdev->dev_type) {
743814 case MPI3_DEVICE_DEVFORM_PCIE:
744815 /*The block layer hw sector size = 512*/
745− blk_queue_max_hw_sectors(sdev->request_queue,
746− tgtdev->dev_spec.pcie_inf.mdts / 512);
747− blk_queue_virt_boundary(sdev->request_queue,
748− ((1 << tgtdev->dev_spec.pcie_inf.pgsz) - 1));
749−
816+ if ((tgtdev->dev_spec.pcie_inf.dev_info &
817+ MPI3_DEVICE0_PCIE_DEVICE_INFO_TYPE_MASK) ==
818+ MPI3_DEVICE0_PCIE_DEVICE_INFO_TYPE_NVME_DEVICE) {
819+ blk_queue_max_hw_sectors(sdev->request_queue,
820+ tgtdev->dev_spec.pcie_inf.mdts / 512);
821+ if (tgtdev->dev_spec.pcie_inf.pgsz == 0)
822+ blk_queue_virt_boundary(sdev->request_queue,
823+ ((1 << MPI3MR_DEFAULT_PGSZEXP) - 1));
824+ else
825+ blk_queue_virt_boundary(sdev->request_queue,
826+ ((1 << tgtdev->dev_spec.pcie_inf.pgsz) - 1));
827+ }
750828 break;
751829 default:
752830 break;
@@ -824,6 +902,17 @@ static void mpi3mr_update_tgtdev(struct mpi3mr_ioc *mrioc, · 71 unmodified lines
824902 scsi_tgt_priv_data->dev_type = tgtdev->dev_type;
825903 }
826904
905+ switch (dev_pg0->access_status) {
906+ case MPI3_DEVICE0_ASTATUS_NO_ERRORS:
907+ case MPI3_DEVICE0_ASTATUS_PREPARE:
908+ case MPI3_DEVICE0_ASTATUS_NEEDS_INITIALIZATION:
909+ case MPI3_DEVICE0_ASTATUS_DEVICE_MISSING_DELAY:
910+ break;
911+ default:
912+ tgtdev->is_hidden = 1;
913+ break;
914+ }
915+
827916 switch (tgtdev->dev_type) {
828917 case MPI3_DEVICE_DEVFORM_SAS_SATA:
829918 {
@@ -848,6 +937,7 @@ static void mpi3mr_update_tgtdev(struct mpi3mr_ioc *mrioc, · 18 unmodified lines
848937 &dev_pg0->device_specific.pcie_format;
849938 u16 dev_info = le16_to_cpu(pcieinf->device_info);
850939
940+ tgtdev->dev_spec.pcie_inf.dev_info = dev_info;
851941 tgtdev->dev_spec.pcie_inf.capb =
852942 le32_to_cpu(pcieinf->capabilities);
853943 tgtdev->dev_spec.pcie_inf.mdts = MPI3MR_DEFAULT_MDTS;
@@ -858,14 +948,18 @@ static void mpi3mr_update_tgtdev(struct mpi3mr_ioc *mrioc, · 4 unmodified lines
858948 le32_to_cpu(pcieinf->maximum_data_transfer_size);
859949 tgtdev->dev_spec.pcie_inf.pgsz = pcieinf->page_size;
860950 tgtdev->dev_spec.pcie_inf.reset_to =
861− pcieinf->controller_reset_to;
951+ max_t(u8, pcieinf->controller_reset_to,
952+ MPI3MR_INTADMCMD_TIMEOUT);
862953 tgtdev->dev_spec.pcie_inf.abort_to =
863− pcieinf->nv_me_abort_to;
954+ max_t(u8, pcieinf->nvme_abort_to,
955+ MPI3MR_INTADMCMD_TIMEOUT);
864956 }
865957 if (tgtdev->dev_spec.pcie_inf.mdts > (1024 * 1024))
866958 tgtdev->dev_spec.pcie_inf.mdts = (1024 * 1024);
867− if ((dev_info & MPI3_DEVICE0_PCIE_DEVICE_INFO_TYPE_MASK) !=
868− MPI3_DEVICE0_PCIE_DEVICE_INFO_TYPE_NVME_DEVICE)
959+ if (((dev_info & MPI3_DEVICE0_PCIE_DEVICE_INFO_TYPE_MASK) !=
960+ MPI3_DEVICE0_PCIE_DEVICE_INFO_TYPE_NVME_DEVICE) &&
961+ ((dev_info & MPI3_DEVICE0_PCIE_DEVICE_INFO_TYPE_MASK) !=
962+ MPI3_DEVICE0_PCIE_DEVICE_INFO_TYPE_SCSI_DEVICE))
869963 tgtdev->is_hidden = 1;
870964 if (!mrioc->shost)
871965 break;
@@ -1313,7 +1407,7 @@ static void mpi3mr_fwevt_bh(struct mpi3mr_ioc *mrioc, · 441 unmodified lines
13131407
13141408 evt_ack:
13151409 if (fwevt->send_ack)
1316− mpi3mr_send_event_ack(mrioc, fwevt->event_id,
1410+ mpi3mr_process_event_ack(mrioc, fwevt->event_id,
13171411 fwevt->evt_ctx);
13181412 out:
13191413 /* Put fwevt reference count to neutralize kref_init increment */
@@ -1377,24 +1471,33 @@ static int mpi3mr_create_tgtdev(struct mpi3mr_ioc *mrioc, · 57 unmodified lines
13771471 }
13781472
13791473 /**
1380− * mpi3mr_flush_delayed_rmhs_list - Flush pending commands
1474+ * mpi3mr_flush_delayed_cmd_lists - Flush pending commands
13811475 * @mrioc: Adapter instance reference
13821476 *
1383− * Flush pending commands in the delayed removal handshake list
1384− * due to a controller reset or driver removal as a cleanup.
1477+ * Flush pending commands in the delayed lists due to a
1478+ * controller reset or driver removal as a cleanup.
13851479 *
13861480 * Return: Nothing
13871481 */
1388−void mpi3mr_flush_delayed_rmhs_list(struct mpi3mr_ioc *mrioc)
1482+void mpi3mr_flush_delayed_cmd_lists(struct mpi3mr_ioc *mrioc)
13891483 {
13901484 struct delayed_dev_rmhs_node *_rmhs_node;
1485+ struct delayed_evt_ack_node *_evtack_node;
13911486
1487+ dprint_reset(mrioc, "flushing delayed dev_remove_hs commands\n");
13921488 while (!list_empty(&mrioc->delayed_rmhs_list)) {
13931489 _rmhs_node = list_entry(mrioc->delayed_rmhs_list.next,
13941490 struct delayed_dev_rmhs_node, list);
13951491 list_del(&_rmhs_node->list);
13961492 kfree(_rmhs_node);
13971493 }
1494+ dprint_reset(mrioc, "flushing delayed event ack commands\n");
1495+ while (!list_empty(&mrioc->delayed_evtack_cmds_list)) {
1496+ _evtack_node = list_entry(mrioc->delayed_evtack_cmds_list.next,
1497+ struct delayed_evt_ack_node, list);
1498+ list_del(&_evtack_node->list);
1499+ kfree(_evtack_node);
1500+ }
13981501 }
13991502
14001503 /**
@@ -1610,6 +1713,141 @@ out_failed: · 209 unmodified lines
16101713 clear_bit(cmd_idx, mrioc->devrem_bitmap);
16111714 }
16121715
1716+/**
1717+ * mpi3mr_complete_evt_ack - event ack request completion
1718+ * @mrioc: Adapter instance reference
1719+ * @drv_cmd: Internal command tracker
1720+ *
1721+ * This is the completion handler for non blocking event
1722+ * acknowledgment sent to the firmware and this will issue any
1723+ * pending event acknowledgment request.
1724+ *
1725+ * Return: Nothing
1726+ */
1727+static void mpi3mr_complete_evt_ack(struct mpi3mr_ioc *mrioc,
1728+ struct mpi3mr_drv_cmd *drv_cmd)
1729+{
1730+ u16 cmd_idx = drv_cmd->host_tag - MPI3MR_HOSTTAG_EVTACKCMD_MIN;
1731+ struct delayed_evt_ack_node *delayed_evtack = NULL;
1732+
1733+ if (drv_cmd->ioc_status != MPI3_IOCSTATUS_SUCCESS) {
1734+ dprint_event_th(mrioc,
1735+ "immediate event ack failed with ioc_status(0x%04x) log_info(0x%08x)\n",
1736+ (drv_cmd->ioc_status & MPI3_IOCSTATUS_STATUS_MASK),
1737+ drv_cmd->ioc_loginfo);
1738+ }
1739+
1740+ if (!list_empty(&mrioc->delayed_evtack_cmds_list)) {
1741+ delayed_evtack =
1742+ list_entry(mrioc->delayed_evtack_cmds_list.next,
1743+ struct delayed_evt_ack_node, list);
1744+ mpi3mr_send_event_ack(mrioc, delayed_evtack->event, drv_cmd,
1745+ delayed_evtack->event_ctx);
1746+ list_del(&delayed_evtack->list);
1747+ kfree(delayed_evtack);
1748+ return;
1749+ }
1750+ drv_cmd->state = MPI3MR_CMD_NOTUSED;
1751+ drv_cmd->callback = NULL;
1752+ clear_bit(cmd_idx, mrioc->evtack_cmds_bitmap);
1753+}
1754+
1755+/**
1756+ * mpi3mr_send_event_ack - Issue event acknwoledgment request
1757+ * @mrioc: Adapter instance reference
1758+ * @event: MPI3 event id
1759+ * @cmdparam: Internal command tracker
1760+ * @event_ctx: event context
1761+ *
1762+ * Issues event acknowledgment request to the firmware if there
1763+ * is a free command to send the event ack else it to a pend
1764+ * list so that it will be processed on a completion of a prior
1765+ * event acknowledgment .
1766+ *
1767+ * Return: Nothing
1768+ */
1769+static void mpi3mr_send_event_ack(struct mpi3mr_ioc *mrioc, u8 event,
1770+ struct mpi3mr_drv_cmd *cmdparam, u32 event_ctx)
1771+{
1772+ struct mpi3_event_ack_request evtack_req;
1773+ int retval = 0;
1774+ u8 retrycount = 5;
1775+ u16 cmd_idx = MPI3MR_NUM_EVTACKCMD;
1776+ struct mpi3mr_drv_cmd *drv_cmd = cmdparam;
1777+ struct delayed_evt_ack_node *delayed_evtack = NULL;
1778+
1779+ if (drv_cmd) {
1780+ dprint_event_th(mrioc,
1781+ "sending delayed event ack in the top half for event(0x%02x), event_ctx(0x%08x)\n",
1782+ event, event_ctx);
1783+ goto issue_cmd;
1784+ }
1785+ dprint_event_th(mrioc,
1786+ "sending event ack in the top half for event(0x%02x), event_ctx(0x%08x)\n",
1787+ event, event_ctx);
1788+ do {
1789+ cmd_idx = find_first_zero_bit(mrioc->evtack_cmds_bitmap,
1790+ MPI3MR_NUM_EVTACKCMD);
1791+ if (cmd_idx < MPI3MR_NUM_EVTACKCMD) {
1792+ if (!test_and_set_bit(cmd_idx,
1793+ mrioc->evtack_cmds_bitmap))
1794+ break;
1795+ cmd_idx = MPI3MR_NUM_EVTACKCMD;
1796+ }
1797+ } while (retrycount--);
1798+
1799+ if (cmd_idx >= MPI3MR_NUM_EVTACKCMD) {
1800+ delayed_evtack = kzalloc(sizeof(*delayed_evtack),
1801+ GFP_ATOMIC);
1802+ if (!delayed_evtack)
1803+ return;
1804+ INIT_LIST_HEAD(&delayed_evtack->list);
1805+ delayed_evtack->event = event;
1806+ delayed_evtack->event_ctx = event_ctx;
1807+ list_add_tail(&delayed_evtack->list,
1808+ &mrioc->delayed_evtack_cmds_list);
1809+ dprint_event_th(mrioc,
1810+ "event ack in the top half for event(0x%02x), event_ctx(0x%08x) is postponed\n",
1811+ event, event_ctx);
1812+ return;
1813+ }
1814+ drv_cmd = &mrioc->evtack_cmds[cmd_idx];
1815+
1816+issue_cmd:
1817+ cmd_idx = drv_cmd->host_tag - MPI3MR_HOSTTAG_EVTACKCMD_MIN;
1818+
1819+ memset(&evtack_req, 0, sizeof(evtack_req));
1820+ if (drv_cmd->state & MPI3MR_CMD_PENDING) {
1821+ dprint_event_th(mrioc,
1822+ "sending event ack failed due to command in use\n");
1823+ goto out;
1824+ }
1825+ drv_cmd->state = MPI3MR_CMD_PENDING;
1826+ drv_cmd->is_waiting = 0;
1827+ drv_cmd->callback = mpi3mr_complete_evt_ack;
1828+ evtack_req.host_tag = cpu_to_le16(drv_cmd->host_tag);
1829+ evtack_req.function = MPI3_FUNCTION_EVENT_ACK;
1830+ evtack_req.event = event;
1831+ evtack_req.event_context = cpu_to_le32(event_ctx);
1832+ retval = mpi3mr_admin_request_post(mrioc, &evtack_req,
1833+ sizeof(evtack_req), 1);
1834+ if (retval) {
1835+ dprint_event_th(mrioc,
1836+ "posting event ack request is failed\n");
1837+ goto out_failed;
1838+ }
1839+
1840+ dprint_event_th(mrioc,
1841+ "event ack in the top half for event(0x%02x), event_ctx(0x%08x) is posted\n",
1842+ event, event_ctx);
1843+out:
1844+ return;
1845+out_failed:
1846+ drv_cmd->state = MPI3MR_CMD_NOTUSED;
1847+ drv_cmd->callback = NULL;
1848+ clear_bit(cmd_idx, mrioc->evtack_cmds_bitmap);
1849+}
1850+
16131851 /**
16141852 * mpi3mr_pcietopochg_evt_th - PCIETopologyChange evt tophalf
16151853 * @mrioc: Adapter instance reference
@@ -1818,6 +2056,40 @@ out: · 202 unmodified lines
18182056 mpi3mr_tgtdev_put(tgtdev);
18192057 }
18202058
2059+/**
2060+ * mpi3mr_preparereset_evt_th - Prepare for reset event tophalf
2061+ * @mrioc: Adapter instance reference
2062+ * @event_reply: event data
2063+ *
2064+ * Blocks and unblocks host level I/O based on the reason code
2065+ *
2066+ * Return: Nothing
2067+ */
2068+static void mpi3mr_preparereset_evt_th(struct mpi3mr_ioc *mrioc,
2069+ struct mpi3_event_notification_reply *event_reply)
2070+{
2071+ struct mpi3_event_data_prepare_for_reset *evtdata =
2072+ (struct mpi3_event_data_prepare_for_reset *)event_reply->event_data;
2073+
2074+ if (evtdata->reason_code == MPI3_EVENT_PREPARE_RESET_RC_START) {
2075+ dprint_event_th(mrioc,
2076+ "prepare for reset event top half with rc=start\n");
2077+ if (mrioc->prepare_for_reset)
2078+ return;
2079+ mrioc->prepare_for_reset = 1;
2080+ mrioc->prepare_for_reset_timeout_counter = 0;
2081+ } else if (evtdata->reason_code == MPI3_EVENT_PREPARE_RESET_RC_ABORT) {
2082+ dprint_event_th(mrioc,
2083+ "prepare for reset top half with rc=abort\n");
2084+ mrioc->prepare_for_reset = 0;
2085+ mrioc->prepare_for_reset_timeout_counter = 0;
2086+ }
2087+ if ((event_reply->msg_flags & MPI3_EVENT_NOTIFY_MSGFLAGS_ACK_MASK)
2088+ == MPI3_EVENT_NOTIFY_MSGFLAGS_ACK_REQUIRED)
2089+ mpi3mr_send_event_ack(mrioc, event_reply->event, NULL,
2090+ le32_to_cpu(event_reply->event_context));
2091+}
2092+
18212093 /**
18222094 * mpi3mr_energypackchg_evt_th - Energy pack change evt tophalf
18232095 * @mrioc: Adapter instance reference
@@ -1847,6 +2119,66 @@ static void mpi3mr_energypackchg_evt_th(struct mpi3mr_ioc *mrioc, · 23 unmodified lines
18472119 mrioc->facts.shutdown_timeout = shutdown_timeout;
18482120 }
18492121
2122+/**
2123+ * mpi3mr_tempthreshold_evt_th - Temp threshold event tophalf
2124+ * @mrioc: Adapter instance reference
2125+ * @event_reply: event data
2126+ *
2127+ * Displays temperature threshold event details and fault code
2128+ * if any is hit due to temperature exceeding threshold.
2129+ *
2130+ * Return: Nothing
2131+ */
2132+static void mpi3mr_tempthreshold_evt_th(struct mpi3mr_ioc *mrioc,
2133+ struct mpi3_event_notification_reply *event_reply)
2134+{
2135+ struct mpi3_event_data_temp_threshold *evtdata =
2136+ (struct mpi3_event_data_temp_threshold *)event_reply->event_data;
2137+
2138+ ioc_err(mrioc, "Temperature threshold levels %s%s%s exceeded for sensor: %d !!! Current temperature in Celsius: %d\n",
2139+ (le16_to_cpu(evtdata->status) & 0x1) ? "Warning " : " ",
2140+ (le16_to_cpu(evtdata->status) & 0x2) ? "Critical " : " ",
2141+ (le16_to_cpu(evtdata->status) & 0x4) ? "Fatal " : " ", evtdata->sensor_num,
2142+ le16_to_cpu(evtdata->current_temperature));
2143+ mpi3mr_print_fault_info(mrioc);
2144+}
2145+
2146+/**
2147+ * mpi3mr_cablemgmt_evt_th - Cable management event tophalf
2148+ * @mrioc: Adapter instance reference
2149+ * @event_reply: event data
2150+ *
2151+ * Displays Cable manegemt event details.
2152+ *
2153+ * Return: Nothing
2154+ */
2155+static void mpi3mr_cablemgmt_evt_th(struct mpi3mr_ioc *mrioc,
2156+ struct mpi3_event_notification_reply *event_reply)
2157+{
2158+ struct mpi3_event_data_cable_management *evtdata =
2159+ (struct mpi3_event_data_cable_management *)event_reply->event_data;
2160+
2161+ switch (evtdata->status) {
2162+ case MPI3_EVENT_CABLE_MGMT_STATUS_INSUFFICIENT_POWER:
2163+ {
2164+ ioc_info(mrioc, "An active cable with receptacle_id %d cannot be powered.\n"
2165+ "Devices connected to this cable are not detected.\n"
2166+ "This cable requires %d mW of power.\n",
2167+ evtdata->receptacle_id,
2168+ le32_to_cpu(evtdata->active_cable_power_requirement));
2169+ break;
2170+ }
2171+ case MPI3_EVENT_CABLE_MGMT_STATUS_DEGRADED:
2172+ {
2173+ ioc_info(mrioc, "A cable with receptacle_id %d is not running at optimal speed\n",
2174+ evtdata->receptacle_id);
2175+ break;
2176+ }
2177+ default:
2178+ break;
2179+ }
2180+}
2181+
18502182 /**
18512183 * mpi3mr_os_handle_events - Firmware event handler
18522184 * @mrioc: Adapter instance reference
@@ -1905,6 +2237,12 @@ void mpi3mr_os_handle_events(struct mpi3mr_ioc *mrioc, · 52 unmodified lines
19052237 mpi3mr_pcietopochg_evt_th(mrioc, event_reply);
19062238 break;
19072239 }
2240+ case MPI3_EVENT_PREPARE_FOR_RESET:
2241+ {
2242+ mpi3mr_preparereset_evt_th(mrioc, event_reply);
2243+ ack_req = 0;
2244+ break;
2245+ }
19082246 case MPI3_EVENT_DEVICE_INFO_CHANGED:
19092247 {
19102248 process_evt_bh = 1;
@@ -1915,9 +2253,18 @@ void mpi3mr_os_handle_events(struct mpi3mr_ioc *mrioc, · 4 unmodified lines
19152253 mpi3mr_energypackchg_evt_th(mrioc, event_reply);
19162254 break;
19172255 }
2256+ case MPI3_EVENT_TEMP_THRESHOLD:
2257+ {
2258+ mpi3mr_tempthreshold_evt_th(mrioc, event_reply);
2259+ break;
2260+ }
2261+ case MPI3_EVENT_CABLE_MGMT:
2262+ {
2263+ mpi3mr_cablemgmt_evt_th(mrioc, event_reply);
2264+ break;
2265+ }
19182266 case MPI3_EVENT_ENCL_DEVICE_STATUS_CHANGE:
19192267 case MPI3_EVENT_SAS_DISCOVERY:
1920− case MPI3_EVENT_CABLE_MGMT:
19212268 case MPI3_EVENT_SAS_DEVICE_DISCOVERY_ERROR:
19222269 case MPI3_EVENT_SAS_BROADCAST_PRIMITIVE:
19232270 case MPI3_EVENT_PCIE_ENUMERATION:
@@ -2520,49 +2867,63 @@ static int mpi3mr_build_sg_scmd(struct mpi3mr_ioc *mrioc, · 596 unmodified lines
25202867 }
25212868
25222869 /**
2523− * mpi3mr_print_response_code - print TM response as a string
2524− * @mrioc: Adapter instance reference
2870+ * mpi3mr_tm_response_name - get TM response as a string
25252871 * @resp_code: TM response code
25262872 *
2527− * Print TM response code as a readable string.
2873+ * Convert known task management response code as a readable
2874+ * string.
25282875 *
2529− * Return: Nothing.
2876+ * Return: response code string.
25302877 */
2531−static void mpi3mr_print_response_code(struct mpi3mr_ioc *mrioc, u8 resp_code)
2878+static const char *mpi3mr_tm_response_name(u8 resp_code)
25322879 {
25332880 char *desc;
25342881
25352882 switch (resp_code) {
2536− case MPI3MR_RSP_TM_COMPLETE:
2883+ case MPI3_SCSITASKMGMT_RSPCODE_TM_COMPLETE:
25372884 desc = "task management request completed";
25382885 break;
2539− case MPI3MR_RSP_INVALID_FRAME:
2886+ case MPI3_SCSITASKMGMT_RSPCODE_INVALID_FRAME:
25402887 desc = "invalid frame";
25412888 break;
2542− case MPI3MR_RSP_TM_NOT_SUPPORTED:
2889+ case MPI3_SCSITASKMGMT_RSPCODE_TM_FUNCTION_NOT_SUPPORTED:
25432890 desc = "task management request not supported";
25442891 break;
2545− case MPI3MR_RSP_TM_FAILED:
2892+ case MPI3_SCSITASKMGMT_RSPCODE_TM_FAILED:
25462893 desc = "task management request failed";
25472894 break;
2548− case MPI3MR_RSP_TM_SUCCEEDED:
2895+ case MPI3_SCSITASKMGMT_RSPCODE_TM_SUCCEEDED:
25492896 desc = "task management request succeeded";
25502897 break;
2551− case MPI3MR_RSP_TM_INVALID_LUN:
2552− desc = "invalid lun";
2898+ case MPI3_SCSITASKMGMT_RSPCODE_TM_INVALID_LUN:
2899+ desc = "invalid LUN";
25532900 break;
2554− case MPI3MR_RSP_TM_OVERLAPPED_TAG:
2901+ case MPI3_SCSITASKMGMT_RSPCODE_TM_OVERLAPPED_TAG:
25552902 desc = "overlapped tag attempted";
25562903 break;
2557− case MPI3MR_RSP_IO_QUEUED_ON_IOC:
2904+ case MPI3_SCSITASKMGMT_RSPCODE_IO_QUEUED_ON_IOC:
25582905 desc = "task queued, however not sent to target";
25592906 break;
2907+ case MPI3_SCSITASKMGMT_RSPCODE_TM_NVME_DENIED:
2908+ desc = "task management request denied by NVMe device";
2909+ break;
25602910 default:
25612911 desc = "unknown";
25622912 break;
25632913 }
2564− ioc_info(mrioc, "%s :response_code(0x%01x): %s\n", __func__,
2565− resp_code, desc);
2914+
2915+ return desc;
2916+}
2917+
2918+inline void mpi3mr_poll_pend_io_completions(struct mpi3mr_ioc *mrioc)
2919+{
2920+ int i;
2921+ int num_of_reply_queues =
2922+ mrioc->num_op_reply_q + mrioc->op_reply_q_offset;
2923+
2924+ for (i = mrioc->op_reply_q_offset; i < num_of_reply_queues; i++)
2925+ mpi3mr_process_op_reply_q(mrioc,
2926+ mrioc->intr_info[i].op_reply_q);
25662927 }
25672928
25682929 /**
@@ -2572,9 +2933,10 @@ static void mpi3mr_print_response_code(struct mpi3mr_ioc *mrioc, u8 resp_code) · 3 unmodified lines
25722933 * @handle: Device handle
25732934 * @lun: lun ID
25742935 * @htag: Host tag of the TM request
2936+ * @timeout: TM timeout value
25752937 * @drv_cmd: Internal command tracker
25762938 * @resp_code: Response code place holder
2577− * @cmd_priv: SCSI command private data
2939+ * @scmd: SCSI command
25782940 *
25792941 * Issues a Task Management Request to the controller for a
25802942 * specified target, lun and command and wait for its completion
@@ -2586,14 +2948,16 @@ static void mpi3mr_print_response_code(struct mpi3mr_ioc *mrioc, u8 resp_code) · 5 unmodified lines
25862948 static int mpi3mr_issue_tm(struct mpi3mr_ioc *mrioc, u8 tm_type,
25872949 u16 handle, uint lun, u16 htag, ulong timeout,
25882950 struct mpi3mr_drv_cmd *drv_cmd,
2589− u8 *resp_code, struct scmd_priv *cmd_priv)
2951+ u8 *resp_code, struct scsi_cmnd *scmd)
25902952 {
25912953 struct mpi3_scsi_task_mgmt_request tm_req;
25922954 struct mpi3_scsi_task_mgmt_reply *tm_reply = NULL;
25932955 int retval = 0;
25942956 struct mpi3mr_tgt_dev *tgtdev = NULL;
25952957 struct mpi3mr_stgt_priv_data *scsi_tgt_priv_data = NULL;
2596− struct op_req_qinfo *op_req_q = NULL;
2958+ struct scmd_priv *cmd_priv = NULL;
2959+ struct scsi_device *sdev = NULL;
2960+ struct mpi3mr_sdev_priv_data *sdev_priv_data = NULL;
25972961
25982962 ioc_info(mrioc, "%s :Issue TM: TM type (0x%x) for devhandle 0x%04x\n",
25992963 __func__, tm_type, handle);
@@ -2630,16 +2994,21 @@ static int mpi3mr_issue_tm(struct mpi3mr_ioc *mrioc, u8 tm_type, · 30 unmodified lines
26302994 tm_req.function = MPI3_FUNCTION_SCSI_TASK_MGMT;
26312995
26322996 tgtdev = mpi3mr_get_tgtdev_by_handle(mrioc, handle);
2633− if (tgtdev && tgtdev->starget && tgtdev->starget->hostdata) {
2634− scsi_tgt_priv_data = (struct mpi3mr_stgt_priv_data *)
2635− tgtdev->starget->hostdata;
2636− atomic_inc(&scsi_tgt_priv_data->block_io);
2637− }
2638− if (cmd_priv) {
2639− op_req_q = &mrioc->req_qinfo[cmd_priv->req_q_idx];
2640− tm_req.task_host_tag = cpu_to_le16(cmd_priv->host_tag);
2641− tm_req.task_request_queue_id = cpu_to_le16(op_req_q->qid);
2997+
2998+ if (scmd) {
2999+ sdev = scmd->device;
3000+ sdev_priv_data = sdev->hostdata;
3001+ scsi_tgt_priv_data = ((sdev_priv_data) ?
3002+ sdev_priv_data->tgt_priv_data : NULL);
3003+ } else {
3004+ if (tgtdev && tgtdev->starget && tgtdev->starget->hostdata)
3005+ scsi_tgt_priv_data = (struct mpi3mr_stgt_priv_data *)
3006+ tgtdev->starget->hostdata;
26423007 }
3008+
3009+ if (scsi_tgt_priv_data)
3010+ atomic_inc(&scsi_tgt_priv_data->block_io);
3011+
26433012 if (tgtdev && (tgtdev->dev_type == MPI3_DEVICE_DEVFORM_PCIE)) {
26443013 if (cmd_priv && tgtdev->dev_spec.pcie_inf.abort_to)
26453014 timeout = tgtdev->dev_spec.pcie_inf.abort_to;
@@ -2656,39 +3025,49 @@ static int mpi3mr_issue_tm(struct mpi3mr_ioc *mrioc, u8 tm_type, · 10 unmodified lines
26563025 wait_for_completion_timeout(&drv_cmd->done, (timeout * HZ));
26573026
26583027 if (!(drv_cmd->state & MPI3MR_CMD_COMPLETE)) {
2659− ioc_err(mrioc, "%s :Issue TM: command timed out\n", __func__);
26603028 drv_cmd->is_waiting = 0;
26613029 retval = -1;
2662− mpi3mr_soft_reset_handler(mrioc,
2663− MPI3MR_RESET_FROM_TM_TIMEOUT, 1);
3030+ if (!(drv_cmd->state & MPI3MR_CMD_RESET)) {
3031+ dprint_tm(mrioc,
3032+ "task management request timed out after %ld seconds\n",
3033+ timeout);
3034+ if (mrioc->logging_level & MPI3_DEBUG_TM)
3035+ dprint_dump_req(&tm_req, sizeof(tm_req)/4);
3036+ mpi3mr_soft_reset_handler(mrioc,
3037+ MPI3MR_RESET_FROM_TM_TIMEOUT, 1);
3038+ }
26643039 goto out_unlock;
26653040 }
26663041
2667− if (drv_cmd->state & MPI3MR_CMD_REPLY_VALID)
2668− tm_reply = (struct mpi3_scsi_task_mgmt_reply *)drv_cmd->reply;
2669−
2670− if (drv_cmd->ioc_status != MPI3_IOCSTATUS_SUCCESS) {
2671− ioc_err(mrioc,
2672− "%s :Issue TM: handle(0x%04x) Failed ioc_status(0x%04x) Loginfo(0x%08x)\n",
2673− __func__, handle, drv_cmd->ioc_status,
2674− drv_cmd->ioc_loginfo);
3042+ if (!(drv_cmd->state & MPI3MR_CMD_REPLY_VALID)) {
3043+ dprint_tm(mrioc, "invalid task management reply message\n");
26753044 retval = -1;
26763045 goto out_unlock;
26773046 }
26783047
2679− if (!tm_reply) {
2680− ioc_err(mrioc, "%s :Issue TM: No TM Reply message\n", __func__);
3048+ tm_reply = (struct mpi3_scsi_task_mgmt_reply *)drv_cmd->reply;
3049+
3050+ switch (drv_cmd->ioc_status) {
3051+ case MPI3_IOCSTATUS_SUCCESS:
3052+ *resp_code = le32_to_cpu(tm_reply->response_data) &
3053+ MPI3MR_RI_MASK_RESPCODE;
3054+ break;
3055+ case MPI3_IOCSTATUS_SCSI_IOC_TERMINATED:
3056+ *resp_code = MPI3_SCSITASKMGMT_RSPCODE_TM_COMPLETE;
3057+ break;
3058+ default:
3059+ dprint_tm(mrioc,
3060+ "task management request to handle(0x%04x) is failed with ioc_status(0x%04x) log_info(0x%08x)\n",
3061+ handle, drv_cmd->ioc_status, drv_cmd->ioc_loginfo);
26813062 retval = -1;
26823063 goto out_unlock;
26833064 }
26843065
2685− *resp_code = le32_to_cpu(tm_reply->response_data) &
2686− MPI3MR_RI_MASK_RESPCODE;
26873066 switch (*resp_code) {
2688− case MPI3MR_RSP_TM_SUCCEEDED:
2689− case MPI3MR_RSP_TM_COMPLETE:
3067+ case MPI3_SCSITASKMGMT_RSPCODE_TM_SUCCEEDED:
3068+ case MPI3_SCSITASKMGMT_RSPCODE_TM_COMPLETE:
26903069 break;
2691− case MPI3MR_RSP_IO_QUEUED_ON_IOC:
3070+ case MPI3_SCSITASKMGMT_RSPCODE_IO_QUEUED_ON_IOC:
26923071 if (tm_type != MPI3_SCSITASKMGMT_TASKTYPE_QUERY_TASK)
26933072 retval = -1;
26943073 break;
@@ -2697,14 +3076,37 @@ static int mpi3mr_issue_tm(struct mpi3mr_ioc *mrioc, u8 tm_type, · 2 unmodified lines
26973076 break;
26983077 }
26993078
2700− ioc_info(mrioc,
2701− "%s :Issue TM: Completed TM type (0x%x) handle(0x%04x) ",
2702− __func__, tm_type, handle);
2703− ioc_info(mrioc,
2704− "with ioc_status(0x%04x), loginfo(0x%08x), term_count(0x%08x)\n",
2705− drv_cmd->ioc_status, drv_cmd->ioc_loginfo,
2706− le32_to_cpu(tm_reply->termination_count));
2707− mpi3mr_print_response_code(mrioc, *resp_code);
3079+ dprint_tm(mrioc,
3080+ "task management request type(%d) completed for handle(0x%04x) with ioc_status(0x%04x), log_info(0x%08x), termination_count(%d), response:%s(0x%x)\n",
3081+ tm_type, handle, drv_cmd->ioc_status, drv_cmd->ioc_loginfo,
3082+ le32_to_cpu(tm_reply->termination_count),
3083+ mpi3mr_tm_response_name(*resp_code), *resp_code);
3084+
3085+ if (!retval) {
3086+ mpi3mr_ioc_disable_intr(mrioc);
3087+ mpi3mr_poll_pend_io_completions(mrioc);
3088+ mpi3mr_ioc_enable_intr(mrioc);
3089+ mpi3mr_poll_pend_io_completions(mrioc);
3090+ }
3091+ switch (tm_type) {
3092+ case MPI3_SCSITASKMGMT_TASKTYPE_TARGET_RESET:
3093+ if (!scsi_tgt_priv_data)
3094+ break;
3095+ scsi_tgt_priv_data->pend_count = 0;
3096+ blk_mq_tagset_busy_iter(&mrioc->shost->tag_set,
3097+ mpi3mr_count_tgt_pending,
3098+ (void *)scsi_tgt_priv_data->starget);
3099+ break;
3100+ case MPI3_SCSITASKMGMT_TASKTYPE_LOGICAL_UNIT_RESET:
3101+ if (!sdev_priv_data)
3102+ break;
3103+ sdev_priv_data->pend_count = 0;
3104+ blk_mq_tagset_busy_iter(&mrioc->shost->tag_set,
3105+ mpi3mr_count_dev_pending, (void *)sdev);
3106+ break;
3107+ default:
3108+ break;
3109+ }
27083110
27093111 out_unlock:
27103112 drv_cmd->state = MPI3MR_CMD_NOTUSED;
@@ -2713,14 +3115,6 @@ out_unlock: · 2 unmodified lines
27133115 atomic_dec_if_positive(&scsi_tgt_priv_data->block_io);
27143116 if (tgtdev)
27153117 mpi3mr_tgtdev_put(tgtdev);
2716− if (!retval) {
2717− /*
2718− * Flush all IRQ handlers by calling synchronize_irq().
2719− * mpi3mr_ioc_disable_intr() takes care of it.
2720− */
2721− mpi3mr_ioc_disable_intr(mrioc);
2722− mpi3mr_ioc_enable_intr(mrioc);
2723− }
27243118 out:
27253119 return retval;
27263120 }
@@ -2769,17 +3163,49 @@ static int mpi3mr_bios_param(struct scsi_device *sdev, · 42 unmodified lines
27693163 * mpi3mr_map_queues - Map queues callback handler
27703164 * @shost: SCSI host reference
27713165 *
2772− * Call the blk_mq_pci_map_queues with from which operational
2773− * queue the mapping has to be done
3166+ * Maps default and poll queues.
27743167 *
2775− * Return: return of blk_mq_pci_map_queues
3168+ * Return: return zero.
27763169 */
27773170 static int mpi3mr_map_queues(struct Scsi_Host *shost)
27783171 {
27793172 struct mpi3mr_ioc *mrioc = shost_priv(shost);
3173+ int i, qoff, offset;
3174+ struct blk_mq_queue_map *map = NULL;
3175+
3176+ offset = mrioc->op_reply_q_offset;
3177+
3178+ for (i = 0, qoff = 0; i < HCTX_MAX_TYPES; i++) {
3179+ map = &shost->tag_set.map[i];
3180+
3181+ map->nr_queues = 0;
3182+
3183+ if (i == HCTX_TYPE_DEFAULT)
3184+ map->nr_queues = mrioc->default_qcount;
3185+ else if (i == HCTX_TYPE_POLL)
3186+ map->nr_queues = mrioc->active_poll_qcount;
3187+
3188+ if (!map->nr_queues) {
3189+ BUG_ON(i == HCTX_TYPE_DEFAULT);
3190+ continue;
3191+ }
3192+
3193+ /*
3194+ * The poll queue(s) doesn't have an IRQ (and hence IRQ
3195+ * affinity), so use the regular blk-mq cpu mapping
3196+ */
3197+ map->queue_offset = qoff;
3198+ if (i != HCTX_TYPE_POLL)
3199+ blk_mq_pci_map_queues(map, mrioc->pdev, offset);
3200+ else
3201+ blk_mq_map_queues(map);
3202+
3203+ qoff += map->nr_queues;
3204+ offset += map->nr_queues;
3205+ }
3206+
3207+ return 0;
27803208
2781− return blk_mq_pci_map_queues(&shost->tag_set.map[HCTX_TYPE_DEFAULT],
2782− mrioc->pdev, mrioc->op_reply_q_offset);
27833209 }
27843210
27853211 /**
@@ -2938,6 +3364,13 @@ static int mpi3mr_eh_target_reset(struct scsi_cmnd *scmd) · 152 unmodified lines
29383364
29393365 stgt_priv_data = sdev_priv_data->tgt_priv_data;
29403366 dev_handle = stgt_priv_data->dev_handle;
3367+ if (stgt_priv_data->dev_removed) {
3368+ sdev_printk(KERN_INFO, scmd->device,
3369+ "%s:target(handle = 0x%04x) is removed, target reset is not issued\n",
3370+ mrioc->name, dev_handle);
3371+ retval = FAILED;
3372+ goto out;
3373+ }
29413374 sdev_printk(KERN_INFO, scmd->device,
29423375 "Target Reset is issued to handle(0x%04x)\n",
29433376 dev_handle);
@@ -2945,15 +3378,22 @@ static int mpi3mr_eh_target_reset(struct scsi_cmnd *scmd) · 1 unmodified line
29453378 ret = mpi3mr_issue_tm(mrioc,
29463379 MPI3_SCSITASKMGMT_TASKTYPE_TARGET_RESET, dev_handle,
29473380 sdev_priv_data->lun_id, MPI3MR_HOSTTAG_BLK_TMS,
2948− MPI3MR_RESETTM_TIMEOUT, &mrioc->host_tm_cmds, &resp_code, NULL);
3381+ MPI3MR_RESETTM_TIMEOUT, &mrioc->host_tm_cmds, &resp_code, scmd);
29493382
29503383 if (ret)
29513384 goto out;
29523385
3386+ if (stgt_priv_data->pend_count) {
3387+ sdev_printk(KERN_INFO, scmd->device,
3388+ "%s: target has %d pending commands, target reset is failed\n",
3389+ mrioc->name, sdev_priv_data->pend_count);
3390+ goto out;
3391+ }
3392+
29533393 retval = SUCCESS;
29543394 out:
29553395 sdev_printk(KERN_INFO, scmd->device,
2956− "Target reset is %s for scmd(%p)\n",
3396+ "%s: target reset is %s for scmd(%p)\n", mrioc->name,
29573397 ((retval == SUCCESS) ? "SUCCESS" : "FAILED"), scmd);
29583398
29593399 return retval;
@@ -2992,21 +3432,34 @@ static int mpi3mr_eh_dev_reset(struct scsi_cmnd *scmd) · 32 unmodified lines
29923432
29933433 stgt_priv_data = sdev_priv_data->tgt_priv_data;
29943434 dev_handle = stgt_priv_data->dev_handle;
3435+ if (stgt_priv_data->dev_removed) {
3436+ sdev_printk(KERN_INFO, scmd->device,
3437+ "%s: device(handle = 0x%04x) is removed, device(LUN) reset is not issued\n",
3438+ mrioc->name, dev_handle);
3439+ retval = FAILED;
3440+ goto out;
3441+ }
29953442 sdev_printk(KERN_INFO, scmd->device,
29963443 "Device(lun) Reset is issued to handle(0x%04x)\n", dev_handle);
29973444
29983445 ret = mpi3mr_issue_tm(mrioc,
29993446 MPI3_SCSITASKMGMT_TASKTYPE_LOGICAL_UNIT_RESET, dev_handle,
30003447 sdev_priv_data->lun_id, MPI3MR_HOSTTAG_BLK_TMS,
3001− MPI3MR_RESETTM_TIMEOUT, &mrioc->host_tm_cmds, &resp_code, NULL);
3448+ MPI3MR_RESETTM_TIMEOUT, &mrioc->host_tm_cmds, &resp_code, scmd);
30023449
30033450 if (ret)
30043451 goto out;
30053452
3453+ if (sdev_priv_data->pend_count) {
3454+ sdev_printk(KERN_INFO, scmd->device,
3455+ "%s: device has %d pending commands, device(LUN) reset is failed\n",
3456+ mrioc->name, sdev_priv_data->pend_count);
3457+ goto out;
3458+ }
30063459 retval = SUCCESS;
30073460 out:
30083461 sdev_printk(KERN_INFO, scmd->device,
3009− "Device(lun) reset is %s for scmd(%p)\n",
3462+ "%s: device(LUN) reset is %s for scmd(%p)\n", mrioc->name,
30103463 ((retval == SUCCESS) ? "SUCCESS" : "FAILED"), scmd);
30113464
30123465 return retval;
@@ -3049,32 +3502,42 @@ static int mpi3mr_scan_finished(struct Scsi_Host *shost, · 36 unmodified lines
30493502 {
30503503 struct mpi3mr_ioc *mrioc = shost_priv(shost);
30513504 u32 pe_timeout = MPI3MR_PORTENABLE_TIMEOUT;
3505+ u32 ioc_status = readl(&mrioc->sysif_regs->ioc_status);
30523506
3053− if (time >= (pe_timeout * HZ)) {
3507+ if ((ioc_status & MPI3_SYSIF_IOC_STATUS_RESET_HISTORY) ||
3508+ (ioc_status & MPI3_SYSIF_IOC_STATUS_FAULT)) {
3509+ ioc_err(mrioc, "port enable failed due to fault or reset\n");
3510+ mpi3mr_print_fault_info(mrioc);
3511+ mrioc->scan_failed = MPI3_IOCSTATUS_INTERNAL_ERROR;
3512+ mrioc->scan_started = 0;
30543513 mrioc->init_cmds.is_waiting = 0;
30553514 mrioc->init_cmds.callback = NULL;
30563515 mrioc->init_cmds.state = MPI3MR_CMD_NOTUSED;
3057− ioc_err(mrioc, "%s :port enable request timed out\n", __func__);
3058− mrioc->is_driver_loading = 0;
3059− mpi3mr_soft_reset_handler(mrioc,
3060− MPI3MR_RESET_FROM_PE_TIMEOUT, 1);
30613516 }
30623517
3063− if (mrioc->scan_failed) {
3064− ioc_err(mrioc,
3065− "%s :port enable failed with (ioc_status=0x%08x)\n",
3066− __func__, mrioc->scan_failed);
3067− mrioc->is_driver_loading = 0;
3068− mrioc->stop_drv_processing = 1;
3069− return 1;
3518+ if (time >= (pe_timeout * HZ)) {
3519+ ioc_err(mrioc, "port enable failed due to time out\n");
3520+ mpi3mr_check_rh_fault_ioc(mrioc,
3521+ MPI3MR_RESET_FROM_PE_TIMEOUT);
3522+ mrioc->scan_failed = MPI3_IOCSTATUS_INTERNAL_ERROR;
3523+ mrioc->scan_started = 0;
3524+ mrioc->init_cmds.is_waiting = 0;
3525+ mrioc->init_cmds.callback = NULL;
3526+ mrioc->init_cmds.state = MPI3MR_CMD_NOTUSED;
30703527 }
30713528
30723529 if (mrioc->scan_started)
30733530 return 0;
3074− ioc_info(mrioc, "%s :port enable: SUCCESS\n", __func__);
3531+
3532+ if (mrioc->scan_failed) {
3533+ ioc_err(mrioc,
3534+ "port enable failed with status=0x%04x\n",
3535+ mrioc->scan_failed);
3536+ } else
3537+ ioc_info(mrioc, "port enable is successfully completed\n");
3538+
30753539 mpi3mr_start_watchdog(mrioc);
30763540 mrioc->is_driver_loading = 0;
3077−
30783541 return 1;
30793542 }
30803543
@@ -3189,10 +3652,18 @@ static int mpi3mr_slave_configure(struct scsi_device *sdev) · 108 unmodified lines
31893652 switch (tgt_dev->dev_type) {
31903653 case MPI3_DEVICE_DEVFORM_PCIE:
31913654 /*The block layer hw sector size = 512*/
3192− blk_queue_max_hw_sectors(sdev->request_queue,
3193− tgt_dev->dev_spec.pcie_inf.mdts / 512);
3194− blk_queue_virt_boundary(sdev->request_queue,
3195− ((1 << tgt_dev->dev_spec.pcie_inf.pgsz) - 1));
3655+ if ((tgt_dev->dev_spec.pcie_inf.dev_info &
3656+ MPI3_DEVICE0_PCIE_DEVICE_INFO_TYPE_MASK) ==
3657+ MPI3_DEVICE0_PCIE_DEVICE_INFO_TYPE_NVME_DEVICE) {
3658+ blk_queue_max_hw_sectors(sdev->request_queue,
3659+ tgt_dev->dev_spec.pcie_inf.mdts / 512);
3660+ if (tgt_dev->dev_spec.pcie_inf.pgsz == 0)
3661+ blk_queue_virt_boundary(sdev->request_queue,
3662+ ((1 << MPI3MR_DEFAULT_PGSZEXP) - 1));
3663+ else
3664+ blk_queue_virt_boundary(sdev->request_queue,
3665+ ((1 << tgt_dev->dev_spec.pcie_inf.pgsz) - 1));
3666+ }
31963667 break;
31973668 default:
31983669 break;
@@ -3312,9 +3783,22 @@ static bool mpi3mr_check_return_unmap(struct mpi3mr_ioc *mrioc, · 113 unmodified lines
33123783 struct scsi_cmnd *scmd)
33133784 {
33143785 unsigned char *buf;
3315− u16 param_len, desc_len;
3316−
3317− param_len = get_unaligned_be16(scmd->cmnd + 7);
3786+ u16 param_len, desc_len, trunc_param_len;
3787+
3788+ trunc_param_len = param_len = get_unaligned_be16(scmd->cmnd + 7);
3789+
3790+ if (mrioc->pdev->revision) {
3791+ if ((param_len > 24) && ((param_len - 8) & 0xF)) {
3792+ trunc_param_len -= (param_len - 8) & 0xF;
3793+ dprint_scsi_command(mrioc, scmd, MPI3_DEBUG_SCSI_ERROR);
3794+ dprint_scsi_err(mrioc,
3795+ "truncating param_len from (%d) to (%d)\n",
3796+ param_len, trunc_param_len);
3797+ put_unaligned_be16(trunc_param_len, scmd->cmnd + 7);
3798+ dprint_scsi_command(mrioc, scmd, MPI3_DEBUG_SCSI_ERROR);
3799+ }
3800+ return false;
3801+ }
33183802
33193803 if (!param_len) {
33203804 ioc_warn(mrioc,
@@ -3374,12 +3858,12 @@ static bool mpi3mr_check_return_unmap(struct mpi3mr_ioc *mrioc, · 53 unmodified lines
33743858 }
33753859
33763860 if (param_len > (desc_len + 8)) {
3861+ trunc_param_len = desc_len + 8;
33773862 scsi_print_command(scmd);
3378− ioc_warn(mrioc,
3379− "%s: Truncating param_len(%d) to desc_len+8(%d)\n",
3380− __func__, param_len, (desc_len + 8));
3381− param_len = desc_len + 8;
3382− put_unaligned_be16(param_len, scmd->cmnd + 7);
3863+ dprint_scsi_err(mrioc,
3864+ "truncating param_len(%d) to desc_len+8(%d)\n",
3865+ param_len, trunc_param_len);
3866+ put_unaligned_be16(trunc_param_len, scmd->cmnd + 7);
33833867 scsi_print_command(scmd);
33843868 }
33853869
@@ -3434,6 +3918,7 @@ static int mpi3mr_qcmd(struct Scsi_Host *shost, · 48 unmodified lines
34343918 u32 scsiio_flags = 0;
34353919 struct request *rq = scsi_cmd_to_rq(scmd);
34363920 int iprio_class;
3921+ u8 is_pcie_dev = 0;
34373922
34383923 sdev_priv_data = scmd->device->hostdata;
34393924 if (!sdev_priv_data || !sdev_priv_data->tgt_priv_data) {
@@ -3478,8 +3963,10 @@ static int mpi3mr_qcmd(struct Scsi_Host *shost, · 38 unmodified lines
34783963 goto out;
34793964 }
34803965
3481− if ((scmd->cmnd[0] == UNMAP) &&
3482− (stgt_priv_data->dev_type == MPI3_DEVICE_DEVFORM_PCIE) &&
3966+ if (stgt_priv_data->dev_type == MPI3_DEVICE_DEVFORM_PCIE)
3967+ is_pcie_dev = 1;
3968+ if ((scmd->cmnd[0] == UNMAP) && is_pcie_dev &&
3969+ (mrioc->pdev->device == MPI3_MFGPAGE_DEVID_SAS4116) &&
34833970 mpi3mr_check_return_unmap(mrioc, scmd))
34843971 goto out;
34853972
@@ -3559,6 +4046,7 @@ static struct scsi_host_template mpi3mr_driver_template = { · 73 unmodified lines
35594046 .eh_host_reset_handler = mpi3mr_eh_host_reset,
35604047 .bios_param = mpi3mr_bios_param,
35614048 .map_queues = mpi3mr_map_queues,
4049+ .mq_poll = mpi3mr_blk_mq_poll,
35624050 .no_write_same = 1,
35634051 .can_queue = 1,
35644052 .this_id = -1,
@@ -3567,6 +4055,7 @@ static struct scsi_host_template mpi3mr_driver_template = { · 2 unmodified lines
35674055 */
35684056 .max_sectors = 2048,
35694057 .cmd_per_lun = MPI3MR_MAX_CMDS_LUN,
4058+ .max_segment_size = 0xffffffff,
35704059 .track_queue_depth = 1,
35714060 .cmd_size = sizeof(struct scmd_priv),
35724061 };
@@ -3714,6 +4203,7 @@ mpi3mr_probe(struct pci_dev *pdev, const struct pci_device_id *id) · 141 unmodified lines
37144203 INIT_LIST_HEAD(&mrioc->fwevt_list);
37154204 INIT_LIST_HEAD(&mrioc->tgtdev_list);
37164205 INIT_LIST_HEAD(&mrioc->delayed_rmhs_list);
4206+ INIT_LIST_HEAD(&mrioc->delayed_evtack_cmds_list);
37174207
37184208 mutex_init(&mrioc->reset_mutex);
37194209 mpi3mr_init_drv_cmd(&mrioc->init_cmds, MPI3MR_HOSTTAG_INITCMDS);
@@ -3772,21 +4262,29 @@ mpi3mr_probe(struct pci_dev *pdev, const struct pci_device_id *id) · 52 unmodified lines
37724262 ioc_err(mrioc, "failure at %s:%d/%s()!\n",
37734263 __FILE__, __LINE__, __func__);
37744264 retval = -ENODEV;
3775− goto out_fwevtthread_failed;
4265+ goto fwevtthread_failed;
37764266 }
37774267
37784268 mrioc->is_driver_loading = 1;
3779− if (mpi3mr_init_ioc(mrioc, MPI3MR_IT_INIT)) {
3780− ioc_err(mrioc, "failure at %s:%d/%s()!\n",
3781− __FILE__, __LINE__, __func__);
4269+ mrioc->cpu_count = num_online_cpus();
4270+ if (mpi3mr_setup_resources(mrioc)) {
4271+ ioc_err(mrioc, "setup resources failed\n");
37824272 retval = -ENODEV;
3783− goto out_iocinit_failed;
4273+ goto resource_alloc_failed;
4274+ }
4275+ if (mpi3mr_init_ioc(mrioc)) {
4276+ ioc_err(mrioc, "initializing IOC failed\n");
4277+ retval = -ENODEV;
4278+ goto init_ioc_failed;
37844279 }
37854280
37864281 shost->nr_hw_queues = mrioc->num_op_reply_q;
4282+ if (mrioc->active_poll_qcount)
4283+ shost->nr_maps = 3;
4284+
37874285 shost->can_queue = mrioc->max_host_ios;
37884286 shost->sg_tablesize = MPI3MR_SG_DEPTH;
3789− shost->max_id = mrioc->facts.max_perids;
4287+ shost->max_id = mrioc->facts.max_perids + 1;
37904288
37914289 retval = scsi_add_host(shost, &pdev->dev);
37924290 if (retval) {
@@ -3799,10 +4297,14 @@ mpi3mr_probe(struct pci_dev *pdev, const struct pci_device_id *id) · 6 unmodified lines
37994297 return retval;
38004298
38014299 addhost_failed:
3802− mpi3mr_cleanup_ioc(mrioc, MPI3MR_COMPLETE_CLEANUP);
3803−out_iocinit_failed:
4300+ mpi3mr_stop_watchdog(mrioc);
4301+ mpi3mr_cleanup_ioc(mrioc);
4302+init_ioc_failed:
4303+ mpi3mr_free_mem(mrioc);
4304+ mpi3mr_cleanup_resources(mrioc);
4305+resource_alloc_failed:
38044306 destroy_workqueue(mrioc->fwevt_worker_thread);
3805−out_fwevtthread_failed:
4307+fwevtthread_failed:
38064308 spin_lock(&mrioc_list_lock);
38074309 list_del(&mrioc->list);
38084310 spin_unlock(&mrioc_list_lock);
@@ -3815,6 +4317,7 @@ shost_failed: · 6 unmodified lines
38154317 * mpi3mr_remove - PCI remove callback
38164318 * @pdev: PCI device instance
38174319 *
4320+ * Cleanup the IOC by issuing MUR and shutdown notification.
38184321 * Free up all memory and resources associated with the
38194322 * controllerand target devices, unregister the shost.
38204323 *
@@ -3851,7 +4354,10 @@ static void mpi3mr_remove(struct pci_dev *pdev) · 30 unmodified lines
38514354 mpi3mr_tgtdev_del_from_list(mrioc, tgtdev);
38524355 mpi3mr_tgtdev_put(tgtdev);
38534356 }
3854− mpi3mr_cleanup_ioc(mrioc, MPI3MR_COMPLETE_CLEANUP);
4357+ mpi3mr_stop_watchdog(mrioc);
4358+ mpi3mr_cleanup_ioc(mrioc);
4359+ mpi3mr_free_mem(mrioc);
4360+ mpi3mr_cleanup_resources(mrioc);
38554361
38564362 spin_lock(&mrioc_list_lock);
38574363 list_del(&mrioc->list);
@@ -3891,7 +4397,10 @@ static void mpi3mr_shutdown(struct pci_dev *pdev) · 33 unmodified lines
38914397 spin_unlock_irqrestore(&mrioc->fwevt_lock, flags);
38924398 if (wq)
38934399 destroy_workqueue(wq);
3894− mpi3mr_cleanup_ioc(mrioc, MPI3MR_COMPLETE_CLEANUP);
4400+
4401+ mpi3mr_stop_watchdog(mrioc);
4402+ mpi3mr_cleanup_ioc(mrioc);
4403+ mpi3mr_cleanup_resources(mrioc);
38954404 }
38964405
38974406 #ifdef CONFIG_PM
@@ -3921,7 +4430,7 @@ static int mpi3mr_suspend(struct pci_dev *pdev, pm_message_t state) · 23 unmodified lines
39214430 mpi3mr_cleanup_fwevt_list(mrioc);
39224431 scsi_block_requests(shost);
39234432 mpi3mr_stop_watchdog(mrioc);
3924− mpi3mr_cleanup_ioc(mrioc, MPI3MR_SUSPEND);
4433+ mpi3mr_cleanup_ioc(mrioc);
39254434
39264435 device_state = pci_choose_state(pdev, state);
39274436 ioc_info(mrioc, "pdev=0x%p, slot=%s, entering operating state [D%d]\n",
@@ -3970,7 +4479,11 @@ static int mpi3mr_resume(struct pci_dev *pdev) · 42 unmodified lines
39704479
39714480 mrioc->stop_drv_processing = 0;
39724481 mpi3mr_memset_buffers(mrioc);
3973− mpi3mr_init_ioc(mrioc, MPI3MR_IT_RESUME);
4482+ r = mpi3mr_reinit_ioc(mrioc, 1);
4483+ if (r) {
4484+ ioc_err(mrioc, "resuming controller failed[%d]\n", r);
4485+ return r;
4486+ }
39744487 scsi_unblock_requests(shost);
39754488 mpi3mr_start_watchdog(mrioc);
39764489
@@ -3980,8 +4493,8 @@ static int mpi3mr_resume(struct pci_dev *pdev) · 3 unmodified lines
39804493
39814494 static const struct pci_device_id mpi3mr_pci_id_table[] = {
39824495 {
3983− PCI_DEVICE_SUB(PCI_VENDOR_ID_LSI_LOGIC, 0x00A5,
3984− PCI_ANY_ID, PCI_ANY_ID)
4496+ PCI_DEVICE_SUB(MPI3_MFGPAGE_VENDORID_BROADCOM,
4497+ MPI3_MFGPAGE_DEVID_SAS4116, PCI_ANY_ID, PCI_ANY_ID)
39854498 },
39864499 { 0 }
39874500 };
drivers/scsi/mvsas/mv_sas.c+5−0
@@ -67,8 +67,10 @@ static struct mvs_info *mvs_find_dev_mvi(struct domain_device *dev) · 66 unmodified lines
6767
6868 while (sha->sas_port[i]) {
6969 if (sha->sas_port[i] == dev->port) {
70+ spin_lock(&sha->sas_port[i]->phy_list_lock);
7071 phy = container_of(sha->sas_port[i]->phy_list.next,
7172 struct asd_sas_phy, port_phy_el);
73+ spin_unlock(&sha->sas_port[i]->phy_list_lock);
7274 j = 0;
7375 while (sha->sas_phy[j]) {
7476 if (sha->sas_phy[j] == phy)
@@ -96,6 +98,8 @@ static int mvs_find_dev_phyno(struct domain_device *dev, int *phyno) · 21 unmodified lines
9698 while (sha->sas_port[i]) {
9799 if (sha->sas_port[i] == dev->port) {
98100 struct asd_sas_phy *phy;
101+
102+ spin_lock(&sha->sas_port[i]->phy_list_lock);
99103 list_for_each_entry(phy,
100104 &sha->sas_port[i]->phy_list, port_phy_el) {
101105 j = 0;
@@ -109,6 +113,7 @@ static int mvs_find_dev_phyno(struct domain_device *dev, int *phyno) · 7 unmodified lines
109113 num++;
110114 n++;
111115 }
116+ spin_unlock(&sha->sas_port[i]->phy_list_lock);
112117 break;
113118 }
114119 i++;
drivers/scsi/myrb.c+1−1
@@ -1674,7 +1674,7 @@ static int myrb_pdev_slave_alloc(struct scsi_device *sdev) · 1673 unmodified lines
16741674 if (sdev->id > MYRB_MAX_TARGETS)
16751675 return -ENXIO;
16761676
1677− pdev_info = kzalloc(sizeof(*pdev_info), GFP_KERNEL|GFP_DMA);
1677+ pdev_info = kzalloc(sizeof(*pdev_info), GFP_KERNEL);
16781678 if (!pdev_info)
16791679 return -ENOMEM;
16801680
drivers/scsi/myrs.c+4−6
@@ -538,13 +538,11 @@ static bool myrs_enable_mmio_mbox(struct myrs_hba *cs, · 537 unmodified lines
538538 cs->fwstat_buf = NULL;
539539 goto out_free;
540540 }
541− cs->ctlr_info = kzalloc(sizeof(struct myrs_ctlr_info),
542− GFP_KERNEL | GFP_DMA);
541+ cs->ctlr_info = kzalloc(sizeof(struct myrs_ctlr_info), GFP_KERNEL);
543542 if (!cs->ctlr_info)
544543 goto out_free;
545544
546− cs->event_buf = kzalloc(sizeof(struct myrs_event),
547− GFP_KERNEL | GFP_DMA);
545+ cs->event_buf = kzalloc(sizeof(struct myrs_event), GFP_KERNEL);
548546 if (!cs->event_buf)
549547 goto out_free;
550548
@@ -1805,7 +1803,7 @@ static int myrs_slave_alloc(struct scsi_device *sdev) · 1254 unmodified lines
18051803
18061804 ldev_num = myrs_translate_ldev(cs, sdev);
18071805
1808− ldev_info = kzalloc(sizeof(*ldev_info), GFP_KERNEL|GFP_DMA);
1806+ ldev_info = kzalloc(sizeof(*ldev_info), GFP_KERNEL);
18091807 if (!ldev_info)
18101808 return -ENOMEM;
18111809
@@ -1867,7 +1865,7 @@ static int myrs_slave_alloc(struct scsi_device *sdev) · 55 unmodified lines
18671865 } else {
18681866 struct myrs_pdev_info *pdev_info;
18691867
1870− pdev_info = kzalloc(sizeof(*pdev_info), GFP_KERNEL|GFP_DMA);
1868+ pdev_info = kzalloc(sizeof(*pdev_info), GFP_KERNEL);
18711869 if (!pdev_info)
18721870 return -ENOMEM;
18731871
drivers/scsi/pm8001/Makefile+5−2
@@ -6,9 +6,12 @@ · 5 unmodified lines
66
77
88 obj-$(CONFIG_SCSI_PM8001) += pm80xx.o
9+
10+CFLAGS_pm80xx_tracepoints.o := -I$(src)
11+
912 pm80xx-y += pm8001_init.o \
1013 pm8001_sas.o \
1114 pm8001_ctl.o \
1215 pm8001_hwi.o \
13− pm80xx_hwi.o
14−
16+ pm80xx_hwi.o \
17+ pm80xx_tracepoints.o
drivers/scsi/pm8001/pm8001_ctl.c+12−12
@@ -889,14 +889,6 @@ static ssize_t pm8001_show_update_fw(struct device *cdev, · 888 unmodified lines
889889 static DEVICE_ATTR(update_fw, S_IRUGO|S_IWUSR|S_IWGRP,
890890 pm8001_show_update_fw, pm8001_store_update_fw);
891891
892−/**
893− * ctl_mpi_state_show - controller MPI state check
894− * @cdev: pointer to embedded class device
895− * @buf: the buffer returned
896− *
897− * A sysfs 'read-only' shost attribute.
898− */
899−
900892 static const char *const mpiStateText[] = {
901893 "MPI is not initialized",
902894 "MPI is successfully initialized",
@@ -904,6 +896,14 @@ static const char *const mpiStateText[] = { · 1 unmodified line
904896 "MPI initialization failed with error in [31:16]"
905897 };
906898
899+/**
900+ * ctl_mpi_state_show - controller MPI state check
901+ * @cdev: pointer to embedded class device
902+ * @attr: device attribute (unused)
903+ * @buf: the buffer returned
904+ *
905+ * A sysfs 'read-only' shost attribute.
906+ */
907907 static ssize_t ctl_mpi_state_show(struct device *cdev,
908908 struct device_attribute *attr, char *buf)
909909 {
@@ -920,11 +920,11 @@ static DEVICE_ATTR_RO(ctl_mpi_state); · 10 unmodified lines
920920 /**
921921 * ctl_hmi_error_show - controller MPI initialization fails
922922 * @cdev: pointer to embedded class device
923+ * @attr: device attribute (unused)
923924 * @buf: the buffer returned
924925 *
925926 * A sysfs 'read-only' shost attribute.
926927 */
927−
928928 static ssize_t ctl_hmi_error_show(struct device *cdev,
929929 struct device_attribute *attr, char *buf)
930930 {
@@ -941,11 +941,11 @@ static DEVICE_ATTR_RO(ctl_hmi_error); · 10 unmodified lines
941941 /**
942942 * ctl_raae_count_show - controller raae count check
943943 * @cdev: pointer to embedded class device
944+ * @attr: device attribute (unused)
944945 * @buf: the buffer returned
945946 *
946947 * A sysfs 'read-only' shost attribute.
947948 */
948−
949949 static ssize_t ctl_raae_count_show(struct device *cdev,
950950 struct device_attribute *attr, char *buf)
951951 {
@@ -962,11 +962,11 @@ static DEVICE_ATTR_RO(ctl_raae_count); · 10 unmodified lines
962962 /**
963963 * ctl_iop0_count_show - controller iop0 count check
964964 * @cdev: pointer to embedded class device
965+ * @attr: device attribute (unused)
965966 * @buf: the buffer returned
966967 *
967968 * A sysfs 'read-only' shost attribute.
968969 */
969−
970970 static ssize_t ctl_iop0_count_show(struct device *cdev,
971971 struct device_attribute *attr, char *buf)
972972 {
@@ -983,11 +983,11 @@ static DEVICE_ATTR_RO(ctl_iop0_count); · 10 unmodified lines
983983 /**
984984 * ctl_iop1_count_show - controller iop1 count check
985985 * @cdev: pointer to embedded class device
986+ * @attr: device attribute (unused)
986987 * @buf: the buffer returned
987988 *
988989 * A sysfs 'read-only' shost attribute.
989990 */
990−
991991 static ssize_t ctl_iop1_count_show(struct device *cdev,
992992 struct device_attribute *attr, char *buf)
993993 {
drivers/scsi/pm8001/pm8001_hwi.c+12−21
@@ -42,6 +42,7 @@ · 41 unmodified lines
4242 #include "pm8001_hwi.h"
4343 #include "pm8001_chips.h"
4444 #include "pm8001_ctl.h"
45+ #include "pm80xx_tracepoints.h"
4546
4647 /**
4748 * read_main_config_table - read the configure table and save it.
@@ -1324,8 +1325,14 @@ int pm8001_mpi_build_cmd(struct pm8001_hba_info *pm8001_ha, · 1276 unmodified lines
13241325 unsigned long flags;
13251326 int q_index = circularQ - pm8001_ha->inbnd_q_tbl;
13261327 int rv;
1328+ u32 htag = le32_to_cpu(*(__le32 *)payload);
1329+
1330+ trace_pm80xx_mpi_build_cmd(pm8001_ha->id, opCode, htag, q_index,
1331+ circularQ->producer_idx, le32_to_cpu(circularQ->consumer_index));
1332+
1333+ if (WARN_ON(q_index >= pm8001_ha->max_q_num))
1334+ return -EINVAL;
13271335
1328− WARN_ON(q_index >= PM8001_MAX_INB_NUM);
13291336 spin_lock_irqsave(&circularQ->iq_lock, flags);
13301337 rv = pm8001_mpi_msg_free_get(circularQ, pm8001_ha->iomb_size,
13311338 &pMessage);
@@ -2304,21 +2311,17 @@ mpi_sata_completion(struct pm8001_hba_info *pm8001_ha, void *piomb) · 972 unmodified lines
23042311
23052312 psataPayload = (struct sata_completion_resp *)(piomb + 4);
23062313 status = le32_to_cpu(psataPayload->status);
2314+ param = le32_to_cpu(psataPayload->param);
23072315 tag = le32_to_cpu(psataPayload->tag);
23082316
23092317 if (!tag) {
23102318 pm8001_dbg(pm8001_ha, FAIL, "tag null\n");
23112319 return;
23122320 }
2321+
23132322 ccb = &pm8001_ha->ccb_info[tag];
2314− param = le32_to_cpu(psataPayload->param);
2315− if (ccb) {
2316− t = ccb->task;
2317− pm8001_dev = ccb->device;
2318− } else {
2319− pm8001_dbg(pm8001_ha, FAIL, "ccb null\n");
2320− return;
2321− }
2323+ t = ccb->task;
2324+ pm8001_dev = ccb->device;
23222325
23232326 if (t) {
23242327 if (t->dev && (t->dev->lldd_dev))
@@ -2335,10 +2338,6 @@ mpi_sata_completion(struct pm8001_hba_info *pm8001_ha, void *piomb) · 10 unmodified lines
23352338 }
23362339
23372340 ts = &t->task_status;
2338− if (!ts) {
2339− pm8001_dbg(pm8001_ha, FAIL, "ts null\n");
2340− return;
2341− }
23422341
23432342 if (status)
23442343 pm8001_dbg(pm8001_ha, IOERR,
@@ -2695,14 +2694,6 @@ static void mpi_sata_event(struct pm8001_hba_info *pm8001_ha, void *piomb) · 350 unmodified lines
26952694 u32 dev_id = le32_to_cpu(psataPayload->device_id);
26962695 unsigned long flags;
26972696
2698− ccb = &pm8001_ha->ccb_info[tag];
2699−
2700− if (ccb) {
2701− t = ccb->task;
2702− pm8001_dev = ccb->device;
2703− } else {
2704− pm8001_dbg(pm8001_ha, FAIL, "No CCB !!!. returning\n");
2705− }
27062697 if (event)
27072698 pm8001_dbg(pm8001_ha, FAIL, "SATA EVENT 0x%x\n", event);
27082699
drivers/scsi/pm8001/pm8001_init.c+2−2
@@ -179,7 +179,7 @@ static void pm8001_free(struct pm8001_hba_info *pm8001_ha) · 178 unmodified lines
179179 }
180180 PM8001_CHIP_DISP->chip_iounmap(pm8001_ha);
181181 flush_workqueue(pm8001_wq);
182− kfree(pm8001_ha->tags);
182+ bitmap_free(pm8001_ha->tags);
183183 kfree(pm8001_ha);
184184 }
185185
@@ -1192,7 +1192,7 @@ pm8001_init_ccb_tag(struct pm8001_hba_info *pm8001_ha, struct Scsi_Host *shost, · 1006 unmodified lines
11921192 can_queue = ccb_count - PM8001_RESERVE_SLOT;
11931193 shost->can_queue = can_queue;
11941194
1195− pm8001_ha->tags = kzalloc(ccb_count, GFP_KERNEL);
1195+ pm8001_ha->tags = bitmap_zalloc(ccb_count, GFP_KERNEL);
11961196 if (!pm8001_ha->tags)
11971197 goto err_out;
11981198
drivers/scsi/pm8001/pm8001_sas.c+16−0
@@ -40,6 +40,7 @@ · 39 unmodified lines
4040
4141 #include <linux/slab.h>
4242 #include "pm8001_sas.h"
43+#include "pm80xx_tracepoints.h"
4344
4445 /**
4546 * pm8001_find_tag - from sas task to find out tag that belongs to this task
@@ -527,6 +528,9 @@ int pm8001_queue_command(struct sas_task *task, gfp_t gfp_flags) · 481 unmodified lines
527528 void pm8001_ccb_task_free(struct pm8001_hba_info *pm8001_ha,
528529 struct sas_task *task, struct pm8001_ccb_info *ccb, u32 ccb_idx)
529530 {
531+ struct ata_queued_cmd *qc;
532+ struct pm8001_device *pm8001_dev;
533+
530534 if (!ccb->task)
531535 return;
532536 if (!sas_protocol_ata(task->task_proto))
@@ -549,6 +553,18 @@ void pm8001_ccb_task_free(struct pm8001_hba_info *pm8001_ha, · 16 unmodified lines
549553 /* do nothing */
550554 break;
551555 }
556+
557+ if (sas_protocol_ata(task->task_proto)) {
558+ // For SCSI/ATA commands uldd_task points to ata_queued_cmd
559+ qc = task->uldd_task;
560+ pm8001_dev = ccb->device;
561+ trace_pm80xx_request_complete(pm8001_ha->id,
562+ pm8001_dev ? pm8001_dev->attached_phy : PM8001_MAX_PHYS,
563+ ccb_idx, 0 /* ctlr_opcode not known */,
564+ qc ? qc->tf.command : 0, // ata opcode
565+ pm8001_dev ? atomic_read(&pm8001_dev->running_req) : -1);
566+ }
567+
552568 task->lldd_task = NULL;
553569 ccb->task = NULL;
554570 ccb->ccb_tag = 0xFFFFFFFF;
drivers/scsi/pm8001/pm80xx_hwi.c+16−22
@@ -42,6 +42,7 @@ · 41 unmodified lines
4242 #include "pm80xx_hwi.h"
4343 #include "pm8001_chips.h"
4444 #include "pm8001_ctl.h"
45+#include "pm80xx_tracepoints.h"
4546
4647 #define SMP_DIRECT 1
4748 #define SMP_INDIRECT 2
@@ -2400,21 +2401,17 @@ mpi_sata_completion(struct pm8001_hba_info *pm8001_ha, · 2352 unmodified lines
24002401
24012402 psataPayload = (struct sata_completion_resp *)(piomb + 4);
24022403 status = le32_to_cpu(psataPayload->status);
2404+ param = le32_to_cpu(psataPayload->param);
24032405 tag = le32_to_cpu(psataPayload->tag);
24042406
24052407 if (!tag) {
24062408 pm8001_dbg(pm8001_ha, FAIL, "tag null\n");
24072409 return;
24082410 }
2411+
24092412 ccb = &pm8001_ha->ccb_info[tag];
2410− param = le32_to_cpu(psataPayload->param);
2411− if (ccb) {
2412− t = ccb->task;
2413− pm8001_dev = ccb->device;
2414− } else {
2415− pm8001_dbg(pm8001_ha, FAIL, "ccb null\n");
2416− return;
2417− }
2413+ t = ccb->task;
2414+ pm8001_dev = ccb->device;
24182415
24192416 if (t) {
24202417 if (t->dev && (t->dev->lldd_dev))
@@ -2431,10 +2428,6 @@ mpi_sata_completion(struct pm8001_hba_info *pm8001_ha, · 10 unmodified lines
24312428 }
24322429
24332430 ts = &t->task_status;
2434− if (!ts) {
2435− pm8001_dbg(pm8001_ha, FAIL, "ts null\n");
2436− return;
2437− }
24382431
24392432 if (status != IO_SUCCESS) {
24402433 pm8001_dbg(pm8001_ha, FAIL,
@@ -2830,15 +2823,6 @@ static void mpi_sata_event(struct pm8001_hba_info *pm8001_ha, · 389 unmodified lines
28302823 u32 dev_id = le32_to_cpu(psataPayload->device_id);
28312824 unsigned long flags;
28322825
2833− ccb = &pm8001_ha->ccb_info[tag];
2834−
2835− if (ccb) {
2836− t = ccb->task;
2837− pm8001_dev = ccb->device;
2838− } else {
2839− pm8001_dbg(pm8001_ha, FAIL, "No CCB !!!. returning\n");
2840− return;
2841− }
28422826 if (event)
28432827 pm8001_dbg(pm8001_ha, FAIL, "SATA EVENT 0x%x\n", event);
28442828
@@ -2852,6 +2836,10 @@ static void mpi_sata_event(struct pm8001_hba_info *pm8001_ha, · 7 unmodified lines
28522836 return;
28532837 }
28542838
2839+ ccb = &pm8001_ha->ccb_info[tag];
2840+ t = ccb->task;
2841+ pm8001_dev = ccb->device;
2842+
28552843 if (unlikely(!t || !t->lldd_task || !t->dev)) {
28562844 pm8001_dbg(pm8001_ha, FAIL, "task or dev null\n");
28572845 return;
@@ -3522,7 +3510,7 @@ static int mpi_phy_start_resp(struct pm8001_hba_info *pm8001_ha, void *piomb) · 664 unmodified lines
35223510 u32 status =
35233511 le32_to_cpu(pPayload->status);
35243512 u32 phy_id =
3525− le32_to_cpu(pPayload->phyid);
3513+ le32_to_cpu(pPayload->phyid) & 0xFF;
35263514 struct pm8001_phy *phy = &pm8001_ha->phy[phy_id];
35273515
35283516 pm8001_dbg(pm8001_ha, INIT,
@@ -4547,6 +4535,7 @@ static int pm80xx_chip_sata_req(struct pm8001_hba_info *pm8001_ha, · 1018 unmodified lines
45474535 struct sas_task *task = ccb->task;
45484536 struct domain_device *dev = task->dev;
45494537 struct pm8001_device *pm8001_ha_dev = dev->lldd_dev;
4538+ struct ata_queued_cmd *qc = task->uldd_task;
45504539 u32 tag = ccb->ccb_tag;
45514540 int ret;
45524541 u32 q_index, cpu_id;
@@ -4766,6 +4755,11 @@ static int pm80xx_chip_sata_req(struct pm8001_hba_info *pm8001_ha, · 213 unmodified lines
47664755 }
47674756 }
47684757 }
4758+ trace_pm80xx_request_issue(pm8001_ha->id,
4759+ ccb->device ? ccb->device->attached_phy : PM8001_MAX_PHYS,
4760+ ccb->ccb_tag, opc,
4761+ qc ? qc->tf.command : 0, // ata opcode
4762+ ccb->device ? atomic_read(&ccb->device->running_req) : 0);
47694763 ret = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc,
47704764 &sata_cmd, sizeof(sata_cmd), q_index);
47714765 return ret;
drivers/scsi/pm8001/pm80xx_tracepoints.c+10−0
@@ -0,0 +1,10 @@
1+// SPDX-License-Identifier: GPL-2.0
2+/*
3+ * Trace events in pm8001 driver.
4+ *
5+ * Copyright 2020 Google LLC
6+ * Author: Akshat Jain <akshatzen@google.com>
7+ */
8+
9+#define CREATE_TRACE_POINTS
10+#include "pm80xx_tracepoints.h"
drivers/scsi/pm8001/pm80xx_tracepoints.h+113−0
@@ -0,0 +1,113 @@
1+/* SPDX-License-Identifier: GPL-2.0 */
2+/*
3+ * Trace events in pm8001 driver.
4+ *
5+ * Copyright 2020 Google LLC
6+ * Author: Akshat Jain <akshatzen@google.com>
7+ */
8+
9+#undef TRACE_SYSTEM
10+#define TRACE_SYSTEM pm80xx
11+
12+#if !defined(_TRACE_PM80XX_H) || defined(TRACE_HEADER_MULTI_READ)
13+#define _TRACE_PM80XX_H
14+
15+#include <linux/tracepoint.h>
16+#include "pm8001_sas.h"
17+
18+TRACE_EVENT(pm80xx_request_issue,
19+ TP_PROTO(u32 id, u32 phy_id, u32 htag, u32 ctlr_opcode,
20+ u16 ata_opcode, int running_req),
21+
22+ TP_ARGS(id, phy_id, htag, ctlr_opcode, ata_opcode, running_req),
23+
24+ TP_STRUCT__entry(
25+ __field(u32, id)
26+ __field(u32, phy_id)
27+ __field(u32, htag)
28+ __field(u32, ctlr_opcode)
29+ __field(u16, ata_opcode)
30+ __field(int, running_req)
31+ ),
32+
33+ TP_fast_assign(
34+ __entry->id = id;
35+ __entry->phy_id = phy_id;
36+ __entry->htag = htag;
37+ __entry->ctlr_opcode = ctlr_opcode;
38+ __entry->ata_opcode = ata_opcode;
39+ __entry->running_req = running_req;
40+ ),
41+
42+ TP_printk("ctlr_id = %u phy_id = %u htag = %#x, ctlr_opcode = %#x ata_opcode = %#x running_req = %d",
43+ __entry->id, __entry->phy_id, __entry->htag,
44+ __entry->ctlr_opcode, __entry->ata_opcode,
45+ __entry->running_req)
46+);
47+
48+TRACE_EVENT(pm80xx_request_complete,
49+ TP_PROTO(u32 id, u32 phy_id, u32 htag, u32 ctlr_opcode,
50+ u16 ata_opcode, int running_req),
51+
52+ TP_ARGS(id, phy_id, htag, ctlr_opcode, ata_opcode, running_req),
53+
54+ TP_STRUCT__entry(
55+ __field(u32, id)
56+ __field(u32, phy_id)
57+ __field(u32, htag)
58+ __field(u32, ctlr_opcode)
59+ __field(u16, ata_opcode)
60+ __field(int, running_req)
61+ ),
62+
63+ TP_fast_assign(
64+ __entry->id = id;
65+ __entry->phy_id = phy_id;
66+ __entry->htag = htag;
67+ __entry->ctlr_opcode = ctlr_opcode;
68+ __entry->ata_opcode = ata_opcode;
69+ __entry->running_req = running_req;
70+ ),
71+
72+ TP_printk("ctlr_id = %u phy_id = %u htag = %#x, ctlr_opcode = %#x ata_opcode = %#x running_req = %d",
73+ __entry->id, __entry->phy_id, __entry->htag,
74+ __entry->ctlr_opcode, __entry->ata_opcode,
75+ __entry->running_req)
76+);
77+
78+TRACE_EVENT(pm80xx_mpi_build_cmd,
79+ TP_PROTO(u32 id, u32 opc, u32 htag, u32 qi, u32 pi, u32 ci),
80+
81+ TP_ARGS(id, opc, htag, qi, pi, ci),
82+
83+ TP_STRUCT__entry(
84+ __field(u32, id)
85+ __field(u32, opc)
86+ __field(u32, htag)
87+ __field(u32, qi)
88+ __field(u32, pi)
89+ __field(u32, ci)
90+ ),
91+
92+ TP_fast_assign(
93+ __entry->id = id;
94+ __entry->opc = opc;
95+ __entry->htag = htag;
96+ __entry->qi = qi;
97+ __entry->pi = pi;
98+ __entry->ci = ci;
99+ ),
100+
101+ TP_printk("ctlr_id = %u opc = %#x htag = %#x QI = %u PI = %u CI = %u",
102+ __entry->id, __entry->opc, __entry->htag, __entry->qi,
103+ __entry->pi, __entry->ci)
104+);
105+
106+#endif /* _TRACE_PM80XX_H_ */
107+
108+#undef TRACE_INCLUDE_PATH
109+#undef TRACE_INCLUDE_FILE
110+#define TRACE_INCLUDE_PATH .
111+#define TRACE_INCLUDE_FILE pm80xx_tracepoints
112+
113+#include <trace/define_trace.h>
drivers/scsi/pmcraid.c+2−3
@@ -3221,8 +3221,8 @@ static struct pmcraid_sglist *pmcraid_alloc_sglist(int buflen) · 3220 unmodified lines
32213221 return NULL;
32223222
32233223 sglist->order = order;
3224− sgl_alloc_order(buflen, order, false,
3225− GFP_KERNEL | GFP_DMA | __GFP_ZERO, &sglist->num_sg);
3224+ sgl_alloc_order(buflen, order, false, GFP_KERNEL | __GFP_ZERO,
3225+ &sglist->num_sg);
32263226
32273227 return sglist;
32283228 }
@@ -3302,7 +3302,6 @@ static int pmcraid_copy_sglist( · 73 unmodified lines
33023302 /**
33033303 * pmcraid_queuecommand_lck - Queue a mid-layer request
33043304 * @scsi_cmd: scsi command struct
3305− * @done: done function
33063305 *
33073306 * This function queues a request generated by the mid-layer. Midlayer calls
33083307 * this routine within host->lock. Some of the functions called by queuecommand
drivers/scsi/qedi/qedi_main.c+2−6
@@ -1538,7 +1538,6 @@ static int qedi_alloc_bdq(struct qedi_ctx *qedi) · 1537 unmodified lines
15381538 int i;
15391539 struct scsi_bd *pbl;
15401540 u64 *list;
1541− dma_addr_t page;
15421541
15431542 /* Alloc dma memory for BDQ buffers */
15441543 for (i = 0; i < QEDI_BDQ_NUM; i++) {
@@ -1608,11 +1607,9 @@ static int qedi_alloc_bdq(struct qedi_ctx *qedi) · 63 unmodified lines
16081607 qedi->bdq_pbl_list_num_entries = qedi->bdq_pbl_mem_size /
16091608 QEDI_PAGE_SIZE;
16101609 list = (u64 *)qedi->bdq_pbl_list;
1611− page = qedi->bdq_pbl_list_dma;
16121610 for (i = 0; i < qedi->bdq_pbl_list_num_entries; i++) {
16131611 *list = qedi->bdq_pbl_dma;
16141612 list++;
1615− page += QEDI_PAGE_SIZE;
16161613 }
16171614
16181615 return 0;
@@ -2089,8 +2086,7 @@ static ssize_t qedi_show_boot_eth_info(void *data, int type, char *buf) · 470 unmodified lines
20892086 rc = snprintf(buf, ip_len, fmt, gw);
20902087 break;
20912088 case ISCSI_BOOT_ETH_FLAGS:
2092− rc = snprintf(buf, 3, "%hhd\n",
2093− SYSFS_FLAG_FW_SEL_BOOT);
2089+ rc = snprintf(buf, 3, "%d\n", (char)SYSFS_FLAG_FW_SEL_BOOT);
20942090 break;
20952091 case ISCSI_BOOT_ETH_INDEX:
20962092 rc = snprintf(buf, 3, "0\n");
@@ -2257,7 +2253,7 @@ qedi_show_boot_tgt_info(struct qedi_ctx *qedi, int type, · 160 unmodified lines
22572253 mchap_secret);
22582254 break;
22592255 case ISCSI_BOOT_TGT_FLAGS:
2260− rc = snprintf(buf, 3, "%hhd\n", SYSFS_FLAG_FW_SEL_BOOT);
2256+ rc = snprintf(buf, 3, "%d\n", (char)SYSFS_FLAG_FW_SEL_BOOT);
22612257 break;
22622258 case ISCSI_BOOT_TGT_NIC_ASSOC:
22632259 rc = snprintf(buf, 3, "0\n");
drivers/scsi/qla2xxx/qla_attr.c+6−0
@@ -2700,7 +2700,13 @@ qla2x00_get_starget_port_id(struct scsi_target *starget) · 2699 unmodified lines
27002700 static inline void
27012701 qla2x00_set_rport_loss_tmo(struct fc_rport *rport, uint32_t timeout)
27022702 {
2703+ fc_port_t *fcport = *(fc_port_t **)rport->dd_data;
2704+
27032705 rport->dev_loss_tmo = timeout ? timeout : 1;
2706+
2707+ if (IS_ENABLED(CONFIG_NVME_FC) && fcport && fcport->nvme_remote_port)
2708+ nvme_fc_set_remoteport_devloss(fcport->nvme_remote_port,
2709+ rport->dev_loss_tmo);
27042710 }
27052711
27062712 static void
drivers/scsi/qla2xxx/qla_init.c+3−7
@@ -5828,13 +5828,6 @@ qla2x00_update_fcport(scsi_qla_host_t *vha, fc_port_t *fcport) · 5827 unmodified lines
58285828
58295829 qla2x00_dfs_create_rport(vha, fcport);
58305830
5831− if (NVME_TARGET(vha->hw, fcport)) {
5832− qla_nvme_register_remote(vha, fcport);
5833− qla2x00_set_fcport_disc_state(fcport, DSC_LOGIN_COMPLETE);
5834− qla2x00_set_fcport_state(fcport, FCS_ONLINE);
5835− return;
5836− }
5837−
58385831 qla24xx_update_fcport_fcp_prio(vha, fcport);
58395832
58405833 switch (vha->host->active_mode) {
@@ -5856,6 +5849,9 @@ qla2x00_update_fcport(scsi_qla_host_t *vha, fc_port_t *fcport) · 15 unmodified lines
58565849 break;
58575850 }
58585851
5852+ if (NVME_TARGET(vha->hw, fcport))
5853+ qla_nvme_register_remote(vha, fcport);
5854+
58595855 qla2x00_set_fcport_state(fcport, FCS_ONLINE);
58605856
58615857 if (IS_IIDMA_CAPABLE(vha->hw) && vha->hw->flags.gpsc_supported) {
drivers/scsi/qla2xxx/qla_nvme.c+4−1
@@ -43,7 +43,7 @@ int qla_nvme_register_remote(struct scsi_qla_host *vha, struct fc_port *fcport) · 42 unmodified lines
4343 req.port_name = wwn_to_u64(fcport->port_name);
4444 req.node_name = wwn_to_u64(fcport->node_name);
4545 req.port_role = 0;
46− req.dev_loss_tmo = 0;
46+ req.dev_loss_tmo = fcport->dev_loss_tmo;
4747
4848 if (fcport->nvme_prli_service_param & NVME_PRLI_SP_INITIATOR)
4949 req.port_role = FC_PORT_ROLE_NVME_INITIATOR;
@@ -70,6 +70,9 @@ int qla_nvme_register_remote(struct scsi_qla_host *vha, struct fc_port *fcport) · 20 unmodified lines
7070 return ret;
7171 }
7272
73+ nvme_fc_set_remoteport_devloss(fcport->nvme_remote_port,
74+ fcport->dev_loss_tmo);
75+
7376 if (fcport->nvme_prli_service_param & NVME_PRLI_SP_SLER)
7477 ql_log(ql_log_info, vha, 0x212a,
7578 "PortID:%06x Supports SLER\n", req.port_id);
drivers/scsi/qla4xxx/ql4_os.c+2−2
@@ -5734,7 +5734,7 @@ static ssize_t qla4xxx_show_boot_eth_info(void *data, int type, char *buf) · 5733 unmodified lines
57345734
57355735 switch (type) {
57365736 case ISCSI_BOOT_ETH_FLAGS:
5737− rc = sprintf(str, "%d\n", SYSFS_FLAG_FW_SEL_BOOT);
5737+ rc = sprintf(str, "%d\n", (char)SYSFS_FLAG_FW_SEL_BOOT);
57385738 break;
57395739 case ISCSI_BOOT_ETH_INDEX:
57405740 rc = sprintf(str, "0\n");
@@ -5843,7 +5843,7 @@ qla4xxx_show_boot_tgt_info(struct ql4_boot_session_info *boot_sess, int type, · 102 unmodified lines
58435843 (char *)&boot_conn->chap.intr_secret);
58445844 break;
58455845 case ISCSI_BOOT_TGT_FLAGS:
5846− rc = sprintf(str, "%d\n", SYSFS_FLAG_FW_SEL_BOOT);
5846+ rc = sprintf(str, "%d\n", (char)SYSFS_FLAG_FW_SEL_BOOT);
58475847 break;
58485848 case ISCSI_BOOT_TGT_NIC_ASSOC:
58495849 rc = sprintf(str, "0\n");
drivers/scsi/scsi.c+2−3
@@ -55,7 +55,6 @@ · 54 unmodified lines
5555 #include <linux/notifier.h>
5656 #include <linux/cpu.h>
5757 #include <linux/mutex.h>
58−#include <linux/async.h>
5958 #include <asm/unaligned.h>
6059
6160 #include <scsi/scsi.h>
@@ -201,11 +200,11 @@ void scsi_finish_command(struct scsi_cmnd *cmd) · 139 unmodified lines
201200
202201
203202 /*
204− * 1024 is big enough for saturating the fast scsi LUN now
203+ * 1024 is big enough for saturating fast SCSI LUNs.
205204 */
206205 int scsi_device_max_queue_depth(struct scsi_device *sdev)
207206 {
208− return max_t(int, sdev->host->can_queue, 1024);
207+ return min_t(int, sdev->host->can_queue, 1024);
209208 }
210209
211210 /**
drivers/scsi/scsi_debugfs.c+1−0
@@ -9,6 +9,7 @@ · 8 unmodified lines
99 static const char *const scsi_cmd_flags[] = {
1010 SCSI_CMD_FLAG_NAME(TAGGED),
1111 SCSI_CMD_FLAG_NAME(INITIALIZED),
12+ SCSI_CMD_FLAG_NAME(LAST),
1213 };
1314 #undef SCSI_CMD_FLAG_NAME
1415
drivers/scsi/scsi_error.c+57−55
@@ -133,23 +133,6 @@ static bool scsi_eh_should_retry_cmd(struct scsi_cmnd *cmd) · 132 unmodified lines
133133 return true;
134134 }
135135
136−static void scsi_eh_complete_abort(struct scsi_cmnd *scmd, struct Scsi_Host *shost)
137−{
138− unsigned long flags;
139−
140− spin_lock_irqsave(shost->host_lock, flags);
141− list_del_init(&scmd->eh_entry);
142− /*
143− * If the abort succeeds, and there is no further
144− * EH action, clear the ->last_reset time.
145− */
146− if (list_empty(&shost->eh_abort_list) &&
147− list_empty(&shost->eh_cmd_q))
148− if (shost->eh_deadline != -1)
149− shost->last_reset = 0;
150− spin_unlock_irqrestore(shost->host_lock, flags);
151−}
152−
153136 /**
154137 * scmd_eh_abort_handler - Handle command aborts
155138 * @work: command to be aborted.
@@ -166,54 +149,72 @@ scmd_eh_abort_handler(struct work_struct *work) · 10 unmodified lines
166149 struct scsi_cmnd *scmd =
167150 container_of(work, struct scsi_cmnd, abort_work.work);
168151 struct scsi_device *sdev = scmd->device;
152+ struct Scsi_Host *shost = sdev->host;
169153 enum scsi_disposition rtn;
170154 unsigned long flags;
171155
172− if (scsi_host_eh_past_deadline(sdev->host)) {
156+ if (scsi_host_eh_past_deadline(shost)) {
173157 SCSI_LOG_ERROR_RECOVERY(3,
174158 scmd_printk(KERN_INFO, scmd,
175159 "eh timeout, not aborting\n"));
176− } else {
177− SCSI_LOG_ERROR_RECOVERY(3,
160+ goto out;
161+ }
162+
163+ SCSI_LOG_ERROR_RECOVERY(3,
178164 scmd_printk(KERN_INFO, scmd,
179165 "aborting command\n"));
180− rtn = scsi_try_to_abort_cmd(sdev->host->hostt, scmd);
181− if (rtn == SUCCESS) {
182− set_host_byte(scmd, DID_TIME_OUT);
183− if (scsi_host_eh_past_deadline(sdev->host)) {
184− SCSI_LOG_ERROR_RECOVERY(3,
185− scmd_printk(KERN_INFO, scmd,
186− "eh timeout, not retrying "
187− "aborted command\n"));
188− } else if (!scsi_noretry_cmd(scmd) &&
189− scsi_cmd_retry_allowed(scmd) &&
190− scsi_eh_should_retry_cmd(scmd)) {
191− SCSI_LOG_ERROR_RECOVERY(3,
192− scmd_printk(KERN_WARNING, scmd,
193− "retry aborted command\n"));
194− scsi_eh_complete_abort(scmd, sdev->host);
195− scsi_queue_insert(scmd, SCSI_MLQUEUE_EH_RETRY);
196− return;
197− } else {
198− SCSI_LOG_ERROR_RECOVERY(3,
199− scmd_printk(KERN_WARNING, scmd,
200− "finish aborted command\n"));
201− scsi_eh_complete_abort(scmd, sdev->host);
202− scsi_finish_command(scmd);
203− return;
204− }
205− } else {
206− SCSI_LOG_ERROR_RECOVERY(3,
207− scmd_printk(KERN_INFO, scmd,
208− "cmd abort %s\n",
209− (rtn == FAST_IO_FAIL) ?
210− "not send" : "failed"));
211− }
166+ rtn = scsi_try_to_abort_cmd(shost->hostt, scmd);
167+ if (rtn != SUCCESS) {
168+ SCSI_LOG_ERROR_RECOVERY(3,
169+ scmd_printk(KERN_INFO, scmd,
170+ "cmd abort %s\n",
171+ (rtn == FAST_IO_FAIL) ?
172+ "not send" : "failed"));
173+ goto out;
174+ }
175+ set_host_byte(scmd, DID_TIME_OUT);
176+ if (scsi_host_eh_past_deadline(shost)) {
177+ SCSI_LOG_ERROR_RECOVERY(3,
178+ scmd_printk(KERN_INFO, scmd,
179+ "eh timeout, not retrying "
180+ "aborted command\n"));
181+ goto out;
212182 }
213183
214− spin_lock_irqsave(sdev->host->host_lock, flags);
184+ spin_lock_irqsave(shost->host_lock, flags);
215185 list_del_init(&scmd->eh_entry);
216− spin_unlock_irqrestore(sdev->host->host_lock, flags);
186+
187+ /*
188+ * If the abort succeeds, and there is no further
189+ * EH action, clear the ->last_reset time.
190+ */
191+ if (list_empty(&shost->eh_abort_list) &&
192+ list_empty(&shost->eh_cmd_q))
193+ if (shost->eh_deadline != -1)
194+ shost->last_reset = 0;
195+
196+ spin_unlock_irqrestore(shost->host_lock, flags);
197+
198+ if (!scsi_noretry_cmd(scmd) &&
199+ scsi_cmd_retry_allowed(scmd) &&
200+ scsi_eh_should_retry_cmd(scmd)) {
201+ SCSI_LOG_ERROR_RECOVERY(3,
202+ scmd_printk(KERN_WARNING, scmd,
203+ "retry aborted command\n"));
204+ scsi_queue_insert(scmd, SCSI_MLQUEUE_EH_RETRY);
205+ } else {
206+ SCSI_LOG_ERROR_RECOVERY(3,
207+ scmd_printk(KERN_WARNING, scmd,
208+ "finish aborted command\n"));
209+ scsi_finish_command(scmd);
210+ }
211+ return;
212+
213+out:
214+ spin_lock_irqsave(shost->host_lock, flags);
215+ list_del_init(&scmd->eh_entry);
216+ spin_unlock_irqrestore(shost->host_lock, flags);
217+
217218 scsi_eh_scmd_add(scmd);
218219 }
219220
@@ -1429,7 +1430,8 @@ static int scsi_eh_try_stu(struct scsi_cmnd *scmd) · 1209 unmodified lines
14291430 enum scsi_disposition rtn = NEEDS_RETRY;
14301431
14311432 for (i = 0; rtn == NEEDS_RETRY && i < 2; i++)
1432− rtn = scsi_send_eh_cmnd(scmd, stu_command, 6, scmd->device->request_queue->rq_timeout, 0);
1433+ rtn = scsi_send_eh_cmnd(scmd, stu_command, 6,
1434+ scmd->device->eh_timeout, 0);
14331435
14341436 if (rtn == SUCCESS)
14351437 return 0;
drivers/scsi/scsi_pm.c+1−2
@@ -8,7 +8,6 @@ · 7 unmodified lines
88
99 #include <linux/pm_runtime.h>
1010 #include <linux/export.h>
11−#include <linux/async.h>
1211 #include <linux/blk-pm.h>
1312
1413 #include <scsi/scsi.h>
@@ -181,7 +180,7 @@ static int sdev_runtime_resume(struct device *dev) · 166 unmodified lines
181180 blk_pre_runtime_resume(sdev->request_queue);
182181 if (pm && pm->runtime_resume)
183182 err = pm->runtime_resume(dev);
184− blk_post_runtime_resume(sdev->request_queue, err);
183+ blk_post_runtime_resume(sdev->request_queue);
185184
186185 return err;
187186 }
drivers/scsi/scsi_priv.h+1−2
@@ -3,7 +3,6 @@ · 2 unmodified lines
33 #define _SCSI_PRIV_H
44
55 #include <linux/device.h>
6−#include <linux/async.h>
76 #include <scsi/scsi_device.h>
87 #include <linux/sbitmap.h>
98
@@ -144,7 +143,7 @@ extern struct scsi_transport_template blank_transport_template; · 134 unmodified lines
144143 extern void __scsi_remove_device(struct scsi_device *);
145144
146145 extern struct bus_type scsi_bus_type;
147−extern const struct attribute_group scsi_shost_attr_group;
146+extern const struct attribute_group *scsi_shost_groups[];
148147
149148 /* scsi_netlink.c */
150149 #ifdef CONFIG_SCSI_NETLINK
drivers/scsi/scsi_scan.c+2−2
@@ -97,7 +97,7 @@ MODULE_PARM_DESC(max_luns, · 96 unmodified lines
9797 #define SCSI_SCAN_TYPE_DEFAULT "sync"
9898 #endif
9999
100−char scsi_scan_type[7] = SCSI_SCAN_TYPE_DEFAULT;
100+static char scsi_scan_type[7] = SCSI_SCAN_TYPE_DEFAULT;
101101
102102 module_param_string(scan, scsi_scan_type, sizeof(scsi_scan_type),
103103 S_IRUGO|S_IWUSR);
@@ -122,7 +122,7 @@ struct async_scan_data { · 18 unmodified lines
122122 struct completion prev_finished;
123123 };
124124
125−/**
125+/*
126126 * scsi_enable_async_suspend - Enable async suspend and resume
127127 */
128128 void scsi_enable_async_suspend(struct device *dev)
drivers/scsi/scsi_sysfs.c+6−1
@@ -424,10 +424,15 @@ static struct attribute *scsi_sysfs_shost_attrs[] = { · 423 unmodified lines
424424 NULL
425425 };
426426
427−const struct attribute_group scsi_shost_attr_group = {
427+static const struct attribute_group scsi_shost_attr_group = {
428428 .attrs = scsi_sysfs_shost_attrs,
429429 };
430430
431+const struct attribute_group *scsi_shost_groups[] = {
432+ &scsi_shost_attr_group,
433+ NULL
434+};
435+
431436 static void scsi_device_cls_release(struct device *class_dev)
432437 {
433438 struct scsi_device *sdev;
drivers/scsi/sd.c+0−1
@@ -51,7 +51,6 @@ · 50 unmodified lines
5151 #include <linux/major.h>
5252 #include <linux/mutex.h>
5353 #include <linux/string_helpers.h>
54−#include <linux/async.h>
5554 #include <linux/slab.h>
5655 #include <linux/sed-opal.h>
5756 #include <linux/pm_runtime.h>
drivers/scsi/sd_zbc.c+3−3
@@ -61,10 +61,10 @@ static int sd_zbc_parse_report(struct scsi_disk *sdkp, u8 *buf, · 60 unmodified lines
6161 zone.len = logical_to_sectors(sdp, get_unaligned_be64(&buf[8]));
6262 zone.capacity = zone.len;
6363 zone.start = logical_to_sectors(sdp, get_unaligned_be64(&buf[16]));
64− zone.wp = logical_to_sectors(sdp, get_unaligned_be64(&buf[24]));
65− if (zone.type != ZBC_ZONE_TYPE_CONV &&
66− zone.cond == ZBC_ZONE_COND_FULL)
64+ if (zone.cond == ZBC_ZONE_COND_FULL)
6765 zone.wp = zone.start + zone.len;
66+ else
67+ zone.wp = logical_to_sectors(sdp, get_unaligned_be64(&buf[24]));
6868
6969 ret = cb(&zone, idx, data);
7070 if (ret)
drivers/scsi/snic/snic_disc.c+1−1
@@ -100,7 +100,7 @@ snic_queue_report_tgt_req(struct snic *snic) · 99 unmodified lines
100100 SNIC_BUG_ON(ntgts == 0);
101101 buf_len = ntgts * sizeof(struct snic_tgt_id) + SNIC_SG_DESC_ALIGN;
102102
103− buf = kzalloc(buf_len, GFP_KERNEL|GFP_DMA);
103+ buf = kzalloc(buf_len, GFP_KERNEL);
104104 if (!buf) {
105105 snic_req_free(snic, rqi);
106106 SNIC_HOST_ERR(snic->shost, "Resp Buf Alloc Failed.\n");
drivers/scsi/sr.c+1−1
@@ -855,7 +855,7 @@ static void get_capabilities(struct scsi_cd *cd) · 854 unmodified lines
855855
856856
857857 /* allocate transfer buffer */
858− buffer = kmalloc(512, GFP_KERNEL | GFP_DMA);
858+ buffer = kmalloc(512, GFP_KERNEL);
859859 if (!buffer) {
860860 sr_printk(KERN_ERR, cd, "out of memory.\n");
861861 return;
drivers/scsi/sr_vendor.c+2−2
@@ -131,7 +131,7 @@ int sr_set_blocklength(Scsi_CD *cd, int blocklength) · 130 unmodified lines
131131 if (cd->vendor == VENDOR_TOSHIBA)
132132 density = (blocklength > 2048) ? 0x81 : 0x83;
133133
134− buffer = kmalloc(512, GFP_KERNEL | GFP_DMA);
134+ buffer = kmalloc(512, GFP_KERNEL);
135135 if (!buffer)
136136 return -ENOMEM;
137137
@@ -179,7 +179,7 @@ int sr_cd_check(struct cdrom_device_info *cdi) · 41 unmodified lines
179179 if (cd->cdi.mask & CDC_MULTI_SESSION)
180180 return 0;
181181
182− buffer = kmalloc(512, GFP_KERNEL | GFP_DMA);
182+ buffer = kmalloc(512, GFP_KERNEL);
183183 if (!buffer)
184184 return -ENOMEM;
185185
drivers/scsi/ufs/Kconfig+8−7
@@ -50,9 +50,11 @@ config SCSI_UFSHCD · 49 unmodified lines
5050 However, do not compile this as a module if your root file system
5151 (the one containing the directory /) is located on a UFS device.
5252
53+if SCSI_UFSHCD
54+
5355 config SCSI_UFSHCD_PCI
5456 tristate "PCI bus based UFS Controller support"
55− depends on SCSI_UFSHCD && PCI
57+ depends on PCI
5658 help
5759 This selects the PCI UFS Host Controller Interface. Select this if
5860 you have UFS Host Controller with PCI Interface.
@@ -71,7 +73,6 @@ config SCSI_UFS_DWC_TC_PCI · 12 unmodified lines
7173
7274 config SCSI_UFSHCD_PLATFORM
7375 tristate "Platform bus based UFS Controller support"
74− depends on SCSI_UFSHCD
7576 depends on HAS_IOMEM
7677 help
7778 This selects the UFS host controller support. Select this if
@@ -147,7 +148,6 @@ config SCSI_UFS_TI_J721E · 69 unmodified lines
147148
148149 config SCSI_UFS_BSG
149150 bool "Universal Flash Storage BSG device node"
150− depends on SCSI_UFSHCD
151151 select BLK_DEV_BSGLIB
152152 help
153153 Universal Flash Storage (UFS) is SCSI transport specification for
@@ -177,7 +177,7 @@ config SCSI_UFS_EXYNOS · 23 unmodified lines
177177
178178 config SCSI_UFS_CRYPTO
179179 bool "UFS Crypto Engine Support"
180− depends on SCSI_UFSHCD && BLK_INLINE_ENCRYPTION
180+ depends on BLK_INLINE_ENCRYPTION
181181 help
182182 Enable Crypto Engine Support in UFS.
183183 Enabling this makes it possible for the kernel to use the crypto
@@ -186,7 +186,6 @@ config SCSI_UFS_CRYPTO · 2 unmodified lines
186186
187187 config SCSI_UFS_HPB
188188 bool "Support UFS Host Performance Booster"
189− depends on SCSI_UFSHCD
190189 help
191190 The UFS HPB feature improves random read performance. It caches
192191 L2P (logical to physical) map of UFS to host DRAM. The driver uses HPB
@@ -195,16 +194,18 @@ config SCSI_UFS_HPB · 2 unmodified lines
195194
196195 config SCSI_UFS_FAULT_INJECTION
197196 bool "UFS Fault Injection Support"
198− depends on SCSI_UFSHCD && FAULT_INJECTION
197+ depends on FAULT_INJECTION
199198 help
200199 Enable fault injection support in the UFS driver. This makes it easier
201200 to test the UFS error handler and abort handler.
202201
203202 config SCSI_UFS_HWMON
204− bool "UFS Temperature Notification"
203+ bool "UFS Temperature Notification"
205204 depends on SCSI_UFSHCD=HWMON || HWMON=y
206205 help
207206 This provides support for UFS hardware monitoring. If enabled,
208207 a hardware monitoring device will be created for the UFS device.
209208
210209 If unsure, say N.
210+
211+endif
drivers/scsi/ufs/tc-dwc-g210-pci.c+0−1
@@ -110,7 +110,6 @@ tc_dwc_g210_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) · 109 unmodified lines
110110 return err;
111111 }
112112
113− pci_set_drvdata(pdev, hba);
114113 pm_runtime_put_noidle(&pdev->dev);
115114 pm_runtime_allow(&pdev->dev);
116115
drivers/scsi/ufs/ufs-exynos.c+2−2
@@ -853,14 +853,14 @@ static int exynos_ufs_post_pwr_mode(struct ufs_hba *hba, · 852 unmodified lines
853853 }
854854
855855 static void exynos_ufs_specify_nexus_t_xfer_req(struct ufs_hba *hba,
856− int tag, bool op)
856+ int tag, bool is_scsi_cmd)
857857 {
858858 struct exynos_ufs *ufs = ufshcd_get_variant(hba);
859859 u32 type;
860860
861861 type = hci_readl(ufs, HCI_UTRL_NEXUS_TYPE);
862862
863− if (op)
863+ if (is_scsi_cmd)
864864 hci_writel(ufs, type | (1 << tag), HCI_UTRL_NEXUS_TYPE);
865865 else
866866 hci_writel(ufs, type & ~(1 << tag), HCI_UTRL_NEXUS_TYPE);
drivers/scsi/ufs/ufs-hisi.c+7−1
@@ -396,6 +396,12 @@ out: · 395 unmodified lines
396396 return ret;
397397 }
398398
399+static int ufs_hisi_suspend_prepare(struct device *dev)
400+{
401+ /* RPM and SPM are different. Refer ufs_hisi_suspend() */
402+ return __ufshcd_suspend_prepare(dev, false);
403+}
404+
399405 static int ufs_hisi_suspend(struct ufs_hba *hba, enum ufs_pm_op pm_op,
400406 enum ufs_notify_change_status status)
401407 {
@@ -578,7 +584,7 @@ static int ufs_hisi_remove(struct platform_device *pdev) · 176 unmodified lines
578584 static const struct dev_pm_ops ufs_hisi_pm_ops = {
579585 SET_SYSTEM_SLEEP_PM_OPS(ufshcd_system_suspend, ufshcd_system_resume)
580586 SET_RUNTIME_PM_OPS(ufshcd_runtime_suspend, ufshcd_runtime_resume, NULL)
581− .prepare = ufshcd_suspend_prepare,
587+ .prepare = ufs_hisi_suspend_prepare,
582588 .complete = ufshcd_resume_complete,
583589 };
584590
drivers/scsi/ufs/ufshcd-pci.c+0−2
@@ -538,8 +538,6 @@ ufshcd_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) · 537 unmodified lines
538538 return err;
539539 }
540540
541− pci_set_drvdata(pdev, hba);
542−
543541 hba->vops = (struct ufs_hba_variant_ops *)id->driver_data;
544542
545543 err = ufshcd_init(hba, mmio_base, pdev->irq);
drivers/scsi/ufs/ufshcd-pltfrm.c+0−2
@@ -361,8 +361,6 @@ int ufshcd_pltfrm_init(struct platform_device *pdev, · 360 unmodified lines
361361 goto dealloc_host;
362362 }
363363
364− platform_set_drvdata(pdev, hba);
365−
366364 pm_runtime_set_active(&pdev->dev);
367365 pm_runtime_enable(&pdev->dev);
368366
drivers/scsi/ufs/ufshcd.c+206−141
@@ -128,8 +128,9 @@ EXPORT_SYMBOL_GPL(ufshcd_dump_regs); · 127 unmodified lines
128128 enum {
129129 UFSHCD_MAX_CHANNEL = 0,
130130 UFSHCD_MAX_ID = 1,
131− UFSHCD_CMD_PER_LUN = 32,
132− UFSHCD_CAN_QUEUE = 32,
131+ UFSHCD_NUM_RESERVED = 1,
132+ UFSHCD_CMD_PER_LUN = 32 - UFSHCD_NUM_RESERVED,
133+ UFSHCD_CAN_QUEUE = 32 - UFSHCD_NUM_RESERVED,
133134 };
134135
135136 static const char *const ufshcd_state_name[] = {
@@ -1069,13 +1070,32 @@ static bool ufshcd_is_devfreq_scaling_required(struct ufs_hba *hba, · 933 unmodified lines
10691070 return false;
10701071 }
10711072
1073+/*
1074+ * Determine the number of pending commands by counting the bits in the SCSI
1075+ * device budget maps. This approach has been selected because a bit is set in
1076+ * the budget map before scsi_host_queue_ready() checks the host_self_blocked
1077+ * flag. The host_self_blocked flag can be modified by calling
1078+ * scsi_block_requests() or scsi_unblock_requests().
1079+ */
1080+static u32 ufshcd_pending_cmds(struct ufs_hba *hba)
1081+{
1082+ struct scsi_device *sdev;
1083+ u32 pending = 0;
1084+
1085+ lockdep_assert_held(hba->host->host_lock);
1086+ __shost_for_each_device(sdev, hba->host)
1087+ pending += sbitmap_weight(&sdev->budget_map);
1088+
1089+ return pending;
1090+}
1091+
10721092 static int ufshcd_wait_for_doorbell_clr(struct ufs_hba *hba,
10731093 u64 wait_timeout_us)
10741094 {
10751095 unsigned long flags;
10761096 int ret = 0;
10771097 u32 tm_doorbell;
1078− u32 tr_doorbell;
1098+ u32 tr_pending;
10791099 bool timeout = false, do_last_check = false;
10801100 ktime_t start;
10811101
@@ -1093,8 +1113,8 @@ static int ufshcd_wait_for_doorbell_clr(struct ufs_hba *hba, · 11 unmodified lines
10931113 }
10941114
10951115 tm_doorbell = ufshcd_readl(hba, REG_UTP_TASK_REQ_DOOR_BELL);
1096− tr_doorbell = ufshcd_readl(hba, REG_UTP_TRANSFER_REQ_DOOR_BELL);
1097− if (!tm_doorbell && !tr_doorbell) {
1116+ tr_pending = ufshcd_pending_cmds(hba);
1117+ if (!tm_doorbell && !tr_pending) {
10981118 timeout = false;
10991119 break;
11001120 } else if (do_last_check) {
@@ -1114,12 +1134,12 @@ static int ufshcd_wait_for_doorbell_clr(struct ufs_hba *hba, · 13 unmodified lines
11141134 do_last_check = true;
11151135 }
11161136 spin_lock_irqsave(hba->host->host_lock, flags);
1117− } while (tm_doorbell || tr_doorbell);
1137+ } while (tm_doorbell || tr_pending);
11181138
11191139 if (timeout) {
11201140 dev_err(hba->dev,
11211141 "%s: timedout waiting for doorbell to clear (tm=0x%x, tr=0x%x)\n",
1122− __func__, tm_doorbell, tr_doorbell);
1142+ __func__, tm_doorbell, tr_pending);
11231143 ret = -EBUSY;
11241144 }
11251145 out:
@@ -1352,25 +1372,6 @@ out: · 226 unmodified lines
13521372 return ret;
13531373 }
13541374
1355−static bool ufshcd_is_busy(struct request *req, void *priv, bool reserved)
1356−{
1357− int *busy = priv;
1358−
1359− WARN_ON_ONCE(reserved);
1360− (*busy)++;
1361− return false;
1362−}
1363−
1364−/* Whether or not any tag is in use by a request that is in progress. */
1365−static bool ufshcd_any_tag_in_use(struct ufs_hba *hba)
1366−{
1367− struct request_queue *q = hba->cmd_queue;
1368− int busy = 0;
1369−
1370− blk_mq_tagset_busy_iter(q->tag_set, ufshcd_is_busy, &busy);
1371− return busy;
1372−}
1373−
13741375 static int ufshcd_devfreq_get_dev_status(struct device *dev,
13751376 struct devfreq_dev_status *stat)
13761377 {
@@ -1666,7 +1667,8 @@ int ufshcd_hold(struct ufs_hba *hba, bool async) · 289 unmodified lines
16661667 bool flush_result;
16671668 unsigned long flags;
16681669
1669− if (!ufshcd_is_clkgating_allowed(hba))
1670+ if (!ufshcd_is_clkgating_allowed(hba) ||
1671+ !hba->clk_gating.is_initialized)
16701672 goto out;
16711673 spin_lock_irqsave(hba->host->host_lock, flags);
16721674 hba->clk_gating.active_reqs++;
@@ -1769,7 +1771,7 @@ static void ufshcd_gate_work(struct work_struct *work) · 96 unmodified lines
17691771
17701772 if (hba->clk_gating.active_reqs
17711773 || hba->ufshcd_state != UFSHCD_STATE_OPERATIONAL
1772− || ufshcd_any_tag_in_use(hba) || hba->outstanding_tasks
1774+ || hba->outstanding_reqs || hba->outstanding_tasks
17731775 || hba->active_uic_cmd || hba->uic_async_done)
17741776 goto rel_lock;
17751777
@@ -1826,7 +1828,7 @@ static void __ufshcd_release(struct ufs_hba *hba) · 50 unmodified lines
18261828
18271829 if (hba->clk_gating.active_reqs || hba->clk_gating.is_suspended ||
18281830 hba->ufshcd_state != UFSHCD_STATE_OPERATIONAL ||
1829− hba->outstanding_tasks ||
1831+ hba->outstanding_tasks || !hba->clk_gating.is_initialized ||
18301832 hba->active_uic_cmd || hba->uic_async_done ||
18311833 hba->clk_gating.state == CLKS_OFF)
18321834 return;
@@ -1961,11 +1963,15 @@ static void ufshcd_exit_clk_gating(struct ufs_hba *hba) · 128 unmodified lines
19611963 {
19621964 if (!hba->clk_gating.is_initialized)
19631965 return;
1966+
19641967 ufshcd_remove_clk_gating_sysfs(hba);
1965− cancel_work_sync(&hba->clk_gating.ungate_work);
1966− cancel_delayed_work_sync(&hba->clk_gating.gate_work);
1967− destroy_workqueue(hba->clk_gating.clk_gating_workq);
1968+
1969+ /* Ungate the clock if necessary. */
1970+ ufshcd_hold(hba, false);
19681971 hba->clk_gating.is_initialized = false;
1972+ ufshcd_release(hba);
1973+
1974+ destroy_workqueue(hba->clk_gating.clk_gating_workq);
19691975 }
19701976
19711977 /* Must be called with host lock acquired */
@@ -2189,6 +2195,7 @@ static inline int ufshcd_hba_capabilities(struct ufs_hba *hba) · 217 unmodified lines
21892195 hba->nutrs = (hba->capabilities & MASK_TRANSFER_REQUESTS_SLOTS) + 1;
21902196 hba->nutmrs =
21912197 ((hba->capabilities & MASK_TASK_MANAGEMENT_REQUEST_SLOTS) >> 16) + 1;
2198+ hba->reserved_slot = hba->nutrs - 1;
21922199
21932200 /* Read crypto capabilities */
21942201 err = ufshcd_hba_init_crypto_capabilities(hba);
@@ -2650,17 +2657,42 @@ static inline u16 ufshcd_upiu_wlun_to_scsi_wlun(u8 upiu_wlun_id) · 455 unmodified lines
26502657 return (upiu_wlun_id & ~UFS_UPIU_WLUN_ID) | SCSI_W_LUN_BASE;
26512658 }
26522659
2653−static inline bool is_rpmb_wlun(struct scsi_device *sdev)
2654−{
2655− return sdev->lun == ufshcd_upiu_wlun_to_scsi_wlun(UFS_UPIU_RPMB_WLUN);
2656−}
2657−
26582660 static inline bool is_device_wlun(struct scsi_device *sdev)
26592661 {
26602662 return sdev->lun ==
26612663 ufshcd_upiu_wlun_to_scsi_wlun(UFS_UPIU_UFS_DEVICE_WLUN);
26622664 }
26632665
2666+/*
2667+ * Associate the UFS controller queue with the default and poll HCTX types.
2668+ * Initialize the mq_map[] arrays.
2669+ */
2670+static int ufshcd_map_queues(struct Scsi_Host *shost)
2671+{
2672+ int i, ret;
2673+
2674+ for (i = 0; i < shost->nr_maps; i++) {
2675+ struct blk_mq_queue_map *map = &shost->tag_set.map[i];
2676+
2677+ switch (i) {
2678+ case HCTX_TYPE_DEFAULT:
2679+ case HCTX_TYPE_POLL:
2680+ map->nr_queues = 1;
2681+ break;
2682+ case HCTX_TYPE_READ:
2683+ map->nr_queues = 0;
2684+ break;
2685+ default:
2686+ WARN_ON_ONCE(true);
2687+ }
2688+ map->queue_offset = 0;
2689+ ret = blk_mq_map_queues(map);
2690+ WARN_ON_ONCE(ret);
2691+ }
2692+
2693+ return 0;
2694+}
2695+
26642696 static void ufshcd_init_lrb(struct ufs_hba *hba, struct ufshcd_lrb *lrb, int i)
26652697 {
26662698 struct utp_transfer_cmd_desc *cmd_descp = hba->ucdl_base_addr;
@@ -2696,10 +2728,13 @@ static int ufshcd_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd) · 29 unmodified lines
26962728 struct ufshcd_lrb *lrbp;
26972729 int err = 0;
26982730
2699− WARN_ONCE(tag < 0, "Invalid tag %d\n", tag);
2731+ WARN_ONCE(tag < 0 || tag >= hba->nutrs, "Invalid tag %d\n", tag);
27002732
2701− if (!down_read_trylock(&hba->clk_scaling_lock))
2702− return SCSI_MLQUEUE_HOST_BUSY;
2733+ /*
2734+ * Allows the UFS error handler to wait for prior ufshcd_queuecommand()
2735+ * calls.
2736+ */
2737+ rcu_read_lock();
27032738
27042739 switch (hba->ufshcd_state) {
27052740 case UFSHCD_STATE_OPERATIONAL:
@@ -2779,8 +2814,9 @@ static int ufshcd_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd) · 73 unmodified lines
27792814 }
27802815
27812816 ufshcd_send_command(hba, tag);
2817+
27822818 out:
2783− up_read(&hba->clk_scaling_lock);
2819+ rcu_read_unlock();
27842820
27852821 if (ufs_trigger_eh()) {
27862822 unsigned long flags;
@@ -2936,30 +2972,15 @@ static int ufshcd_wait_for_dev_cmd(struct ufs_hba *hba, · 149 unmodified lines
29362972 static int ufshcd_exec_dev_cmd(struct ufs_hba *hba,
29372973 enum dev_cmd_type cmd_type, int timeout)
29382974 {
2939− struct request_queue *q = hba->cmd_queue;
29402975 DECLARE_COMPLETION_ONSTACK(wait);
2941− struct request *req;
2976+ const u32 tag = hba->reserved_slot;
29422977 struct ufshcd_lrb *lrbp;
29432978 int err;
2944− int tag;
29452979
2946− down_read(&hba->clk_scaling_lock);
2980+ /* Protects use of hba->reserved_slot. */
2981+ lockdep_assert_held(&hba->dev_cmd.lock);
29472982
2948− /*
2949− * Get free slot, sleep if slots are unavailable.
2950− * Even though we use wait_event() which sleeps indefinitely,
2951− * the maximum wait time is bounded by SCSI request timeout.
2952− */
2953− req = blk_mq_alloc_request(q, REQ_OP_DRV_OUT, 0);
2954− if (IS_ERR(req)) {
2955− err = PTR_ERR(req);
2956− goto out_unlock;
2957− }
2958− tag = req->tag;
2959− WARN_ONCE(tag < 0, "Invalid tag %d\n", tag);
2960− /* Set the timeout such that the SCSI error handler is not activated. */
2961− req->timeout = msecs_to_jiffies(2 * timeout);
2962− blk_mq_start_request(req);
2983+ down_read(&hba->clk_scaling_lock);
29632984
29642985 lrbp = &hba->lrb[tag];
29652986 WARN_ON(lrbp->cmd);
@@ -2977,8 +2998,6 @@ static int ufshcd_exec_dev_cmd(struct ufs_hba *hba, · 11 unmodified lines
29772998 (struct utp_upiu_req *)lrbp->ucd_rsp_ptr);
29782999
29793000 out:
2980− blk_mq_free_request(req);
2981−out_unlock:
29823001 up_read(&hba->clk_scaling_lock);
29833002 return err;
29843003 }
@@ -4960,11 +4979,7 @@ static int ufshcd_slave_alloc(struct scsi_device *sdev) · 1975 unmodified lines
49604979 */
49614980 static int ufshcd_change_queue_depth(struct scsi_device *sdev, int depth)
49624981 {
4963− struct ufs_hba *hba = shost_priv(sdev->host);
4964−
4965− if (depth > hba->nutrs)
4966− depth = hba->nutrs;
4967− return scsi_change_queue_depth(sdev, depth);
4982+ return scsi_change_queue_depth(sdev, min(depth, sdev->host->can_queue));
49684983 }
49694984
49704985 static void ufshcd_hpb_destroy(struct ufs_hba *hba, struct scsi_device *sdev)
@@ -5256,6 +5271,18 @@ static irqreturn_t ufshcd_uic_cmd_compl(struct ufs_hba *hba, u32 intr_status) · 285 unmodified lines
52565271 return retval;
52575272 }
52585273
5274+/* Release the resources allocated for processing a SCSI command. */
5275+static void ufshcd_release_scsi_cmd(struct ufs_hba *hba,
5276+ struct ufshcd_lrb *lrbp)
5277+{
5278+ struct scsi_cmnd *cmd = lrbp->cmd;
5279+
5280+ scsi_dma_unmap(cmd);
5281+ lrbp->cmd = NULL; /* Mark the command as completed. */
5282+ ufshcd_release(hba);
5283+ ufshcd_clk_scaling_update_busy(hba);
5284+}
5285+
52595286 /**
52605287 * __ufshcd_transfer_req_compl - handle SCSI and query command completion
52615288 * @hba: per adapter instance
@@ -5266,9 +5293,7 @@ static void __ufshcd_transfer_req_compl(struct ufs_hba *hba, · 4 unmodified lines
52665293 {
52675294 struct ufshcd_lrb *lrbp;
52685295 struct scsi_cmnd *cmd;
5269− int result;
52705296 int index;
5271− bool update_scaling = false;
52725297
52735298 for_each_set_bit(index, &completed_reqs, hba->nutrs) {
52745299 lrbp = &hba->lrb[index];
@@ -5278,29 +5303,47 @@ static void __ufshcd_transfer_req_compl(struct ufs_hba *hba, · 3 unmodified lines
52785303 if (unlikely(ufshcd_should_inform_monitor(hba, lrbp)))
52795304 ufshcd_update_monitor(hba, lrbp);
52805305 ufshcd_add_command_trace(hba, index, UFS_CMD_COMP);
5281− result = ufshcd_transfer_rsp_status(hba, lrbp);
5282− scsi_dma_unmap(cmd);
5283− cmd->result = result;
5284− /* Mark completed command as NULL in LRB */
5285− lrbp->cmd = NULL;
5306+ cmd->result = ufshcd_transfer_rsp_status(hba, lrbp);
5307+ ufshcd_release_scsi_cmd(hba, lrbp);
52865308 /* Do not touch lrbp after scsi done */
52875309 scsi_done(cmd);
5288− ufshcd_release(hba);
5289− update_scaling = true;
52905310 } else if (lrbp->command_type == UTP_CMD_TYPE_DEV_MANAGE ||
52915311 lrbp->command_type == UTP_CMD_TYPE_UFS_STORAGE) {
52925312 if (hba->dev_cmd.complete) {
52935313 ufshcd_add_command_trace(hba, index,
52945314 UFS_DEV_COMP);
52955315 complete(hba->dev_cmd.complete);
5296− update_scaling = true;
5316+ ufshcd_clk_scaling_update_busy(hba);
52975317 }
52985318 }
5299− if (update_scaling)
5300− ufshcd_clk_scaling_update_busy(hba);
53015319 }
53025320 }
53035321
5322+/*
5323+ * Returns > 0 if one or more commands have been completed or 0 if no
5324+ * requests have been completed.
5325+ */
5326+static int ufshcd_poll(struct Scsi_Host *shost, unsigned int queue_num)
5327+{
5328+ struct ufs_hba *hba = shost_priv(shost);
5329+ unsigned long completed_reqs, flags;
5330+ u32 tr_doorbell;
5331+
5332+ spin_lock_irqsave(&hba->outstanding_lock, flags);
5333+ tr_doorbell = ufshcd_readl(hba, REG_UTP_TRANSFER_REQ_DOOR_BELL);
5334+ completed_reqs = ~tr_doorbell & hba->outstanding_reqs;
5335+ WARN_ONCE(completed_reqs & ~hba->outstanding_reqs,
5336+ "completed: %#lx; outstanding: %#lx\n", completed_reqs,
5337+ hba->outstanding_reqs);
5338+ hba->outstanding_reqs &= ~completed_reqs;
5339+ spin_unlock_irqrestore(&hba->outstanding_lock, flags);
5340+
5341+ if (completed_reqs)
5342+ __ufshcd_transfer_req_compl(hba, completed_reqs);
5343+
5344+ return completed_reqs;
5345+}
5346+
53045347 /**
53055348 * ufshcd_transfer_req_compl - handle SCSI and query command completion
53065349 * @hba: per adapter instance
@@ -5311,9 +5354,6 @@ static void __ufshcd_transfer_req_compl(struct ufs_hba *hba, · 4 unmodified lines
53115354 */
53125355 static irqreturn_t ufshcd_transfer_req_compl(struct ufs_hba *hba)
53135356 {
5314− unsigned long completed_reqs, flags;
5315− u32 tr_doorbell;
5316−
53175357 /* Resetting interrupt aggregation counters first and reading the
53185358 * DOOR_BELL afterward allows us to handle all the completed requests.
53195359 * In order to prevent other interrupts starvation the DB is read once
@@ -5328,21 +5368,13 @@ static irqreturn_t ufshcd_transfer_req_compl(struct ufs_hba *hba) · 8 unmodified lines
53285368 if (ufs_fail_completion())
53295369 return IRQ_HANDLED;
53305370
5331− spin_lock_irqsave(&hba->outstanding_lock, flags);
5332− tr_doorbell = ufshcd_readl(hba, REG_UTP_TRANSFER_REQ_DOOR_BELL);
5333− completed_reqs = ~tr_doorbell & hba->outstanding_reqs;
5334− WARN_ONCE(completed_reqs & ~hba->outstanding_reqs,
5335− "completed: %#lx; outstanding: %#lx\n", completed_reqs,
5336− hba->outstanding_reqs);
5337− hba->outstanding_reqs &= ~completed_reqs;
5338− spin_unlock_irqrestore(&hba->outstanding_lock, flags);
5371+ /*
5372+ * Ignore the ufshcd_poll() return value and return IRQ_HANDLED since we
5373+ * do not want polling to trigger spurious interrupt complaints.
5374+ */
5375+ ufshcd_poll(hba->host, 0);
53395376
5340− if (completed_reqs) {
5341− __ufshcd_transfer_req_compl(hba, completed_reqs);
5342− return IRQ_HANDLED;
5343− } else {
5344− return IRQ_NONE;
5345− }
5377+ return IRQ_HANDLED;
53465378 }
53475379
53485380 int __ufshcd_write_ee_control(struct ufs_hba *hba, u32 ee_ctrl_mask)
@@ -5986,8 +6018,7 @@ static void ufshcd_err_handling_prepare(struct ufs_hba *hba) · 637 unmodified lines
59866018 }
59876019 ufshcd_scsi_block_requests(hba);
59886020 /* Drain ufshcd_queuecommand() */
5989− down_write(&hba->clk_scaling_lock);
5990− up_write(&hba->clk_scaling_lock);
6021+ synchronize_rcu();
59916022 cancel_work_sync(&hba->eeh_work);
59926023 }
59936024
@@ -6594,6 +6625,8 @@ static int __ufshcd_issue_tm_cmd(struct ufs_hba *hba, · 600 unmodified lines
65946625 spin_lock_irqsave(host->host_lock, flags);
65956626
65966627 task_tag = req->tag;
6628+ WARN_ONCE(task_tag < 0 || task_tag >= hba->nutmrs, "Invalid tag %d\n",
6629+ task_tag);
65976630 hba->tmf_rqs[req->tag] = req;
65986631 treq->upiu_req.req_header.dword_0 |= cpu_to_be32(task_tag);
65996632
@@ -6711,28 +6744,16 @@ static int ufshcd_issue_devman_upiu_cmd(struct ufs_hba *hba, · 111 unmodified lines
67116744 enum dev_cmd_type cmd_type,
67126745 enum query_opcode desc_op)
67136746 {
6714− struct request_queue *q = hba->cmd_queue;
67156747 DECLARE_COMPLETION_ONSTACK(wait);
6716− struct request *req;
6748+ const u32 tag = hba->reserved_slot;
67176749 struct ufshcd_lrb *lrbp;
67186750 int err = 0;
6719− int tag;
67206751 u8 upiu_flags;
67216752
6722− down_read(&hba->clk_scaling_lock);
6723−
6724− req = blk_mq_alloc_request(q, REQ_OP_DRV_OUT, 0);
6725− if (IS_ERR(req)) {
6726− err = PTR_ERR(req);
6727− goto out_unlock;
6728− }
6729− tag = req->tag;
6730− WARN_ONCE(tag < 0, "Invalid tag %d\n", tag);
6753+ /* Protects use of hba->reserved_slot. */
6754+ lockdep_assert_held(&hba->dev_cmd.lock);
67316755
6732− if (unlikely(test_bit(tag, &hba->outstanding_reqs))) {
6733− err = -EBUSY;
6734− goto out;
6735− }
6756+ down_read(&hba->clk_scaling_lock);
67366757
67376758 lrbp = &hba->lrb[tag];
67386759 WARN_ON(lrbp->cmd);
@@ -6801,9 +6822,6 @@ static int ufshcd_issue_devman_upiu_cmd(struct ufs_hba *hba, · 62 unmodified lines
68016822 ufshcd_add_query_upiu_trace(hba, err ? UFS_QUERY_ERR : UFS_QUERY_COMP,
68026823 (struct utp_upiu_req *)lrbp->ucd_rsp_ptr);
68036824
6804−out:
6805− blk_mq_free_request(req);
6806−out_unlock:
68076825 up_read(&hba->clk_scaling_lock);
68086826 return err;
68096827 }
@@ -7033,6 +7051,7 @@ static int ufshcd_abort(struct scsi_cmnd *cmd) · 223 unmodified lines
70337051 struct ufshcd_lrb *lrbp = &hba->lrb[tag];
70347052 unsigned long flags;
70357053 int err = FAILED;
7054+ bool outstanding;
70367055 u32 reg;
70377056
70387057 WARN_ONCE(tag < 0, "Invalid tag %d\n", tag);
@@ -7110,7 +7129,17 @@ static int ufshcd_abort(struct scsi_cmnd *cmd) · 71 unmodified lines
71107129 goto release;
71117130 }
71127131
7113− lrbp->cmd = NULL;
7132+ /*
7133+ * Clear the corresponding bit from outstanding_reqs since the command
7134+ * has been aborted successfully.
7135+ */
7136+ spin_lock_irqsave(&hba->outstanding_lock, flags);
7137+ outstanding = __test_and_clear_bit(tag, &hba->outstanding_reqs);
7138+ spin_unlock_irqrestore(&hba->outstanding_lock, flags);
7139+
7140+ if (outstanding)
7141+ ufshcd_release_scsi_cmd(hba, lrbp);
7142+
71147143 err = SUCCESS;
71157144
71167145 release:
@@ -7412,7 +7441,7 @@ static inline void ufshcd_blk_pm_runtime_init(struct scsi_device *sdev) · 295 unmodified lines
74127441 static int ufshcd_scsi_add_wlus(struct ufs_hba *hba)
74137442 {
74147443 int ret = 0;
7415− struct scsi_device *sdev_boot;
7444+ struct scsi_device *sdev_boot, *sdev_rpmb;
74167445
74177446 hba->sdev_ufs_device = __scsi_add_device(hba->host, 0, 0,
74187447 ufshcd_upiu_wlun_to_scsi_wlun(UFS_UPIU_UFS_DEVICE_WLUN), NULL);
@@ -7423,14 +7452,14 @@ static int ufshcd_scsi_add_wlus(struct ufs_hba *hba) · 4 unmodified lines
74237452 }
74247453 scsi_device_put(hba->sdev_ufs_device);
74257454
7426− hba->sdev_rpmb = __scsi_add_device(hba->host, 0, 0,
7455+ sdev_rpmb = __scsi_add_device(hba->host, 0, 0,
74277456 ufshcd_upiu_wlun_to_scsi_wlun(UFS_UPIU_RPMB_WLUN), NULL);
7428− if (IS_ERR(hba->sdev_rpmb)) {
7429− ret = PTR_ERR(hba->sdev_rpmb);
7457+ if (IS_ERR(sdev_rpmb)) {
7458+ ret = PTR_ERR(sdev_rpmb);
74307459 goto remove_sdev_ufs_device;
74317460 }
7432− ufshcd_blk_pm_runtime_init(hba->sdev_rpmb);
7433− scsi_device_put(hba->sdev_rpmb);
7461+ ufshcd_blk_pm_runtime_init(sdev_rpmb);
7462+ scsi_device_put(sdev_rpmb);
74347463
74357464 sdev_boot = __scsi_add_device(hba->host, 0, 0,
74367465 ufshcd_upiu_wlun_to_scsi_wlun(UFS_UPIU_BOOT_WLUN), NULL);
@@ -8156,7 +8185,9 @@ static struct scsi_host_template ufshcd_driver_template = { · 719 unmodified lines
81568185 .module = THIS_MODULE,
81578186 .name = UFSHCD,
81588187 .proc_name = UFSHCD,
8188+ .map_queues = ufshcd_map_queues,
81598189 .queuecommand = ufshcd_queuecommand,
8190+ .mq_poll = ufshcd_poll,
81608191 .slave_alloc = ufshcd_slave_alloc,
81618192 .slave_configure = ufshcd_slave_configure,
81628193 .slave_destroy = ufshcd_slave_destroy,
@@ -9384,7 +9415,6 @@ void ufshcd_remove(struct ufs_hba *hba) · 1221 unmodified lines
93849415 ufs_sysfs_remove_nodes(hba->dev);
93859416 blk_cleanup_queue(hba->tmf_queue);
93869417 blk_mq_free_tag_set(&hba->tmf_tag_set);
9387− blk_cleanup_queue(hba->cmd_queue);
93889418 scsi_remove_host(hba->host);
93899419 /* disable interrupts */
93909420 ufshcd_disable_intr(hba, hba->intr_mask);
@@ -9445,6 +9475,7 @@ int ufshcd_alloc_host(struct device *dev, struct ufs_hba **hba_handle) · 54 unmodified lines
94459475 err = -ENOMEM;
94469476 goto out_error;
94479477 }
9478+ host->nr_maps = HCTX_TYPE_POLL + 1;
94489479 hba = shost_priv(host);
94499480 hba->host = host;
94509481 hba->dev = dev;
@@ -9486,6 +9517,13 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq) · 35 unmodified lines
94869517 struct device *dev = hba->dev;
94879518 char eh_wq_name[sizeof("ufs_eh_wq_00")];
94889519
9520+ /*
9521+ * dev_set_drvdata() must be called before any callbacks are registered
9522+ * that use dev_get_drvdata() (frequency scaling, clock scaling, hwmon,
9523+ * sysfs).
9524+ */
9525+ dev_set_drvdata(dev, hba);
9526+
94899527 if (!mmio_base) {
94909528 dev_err(hba->dev,
94919529 "Invalid memory reference for mmio_base is NULL\n");
@@ -9528,8 +9566,8 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq) · 36 unmodified lines
95289566 /* Configure LRB */
95299567 ufshcd_host_memory_configure(hba);
95309568
9531− host->can_queue = hba->nutrs;
9532− host->cmd_per_lun = hba->nutrs;
9569+ host->can_queue = hba->nutrs - UFSHCD_NUM_RESERVED;
9570+ host->cmd_per_lun = hba->nutrs - UFSHCD_NUM_RESERVED;
95339571 host->max_id = UFSHCD_MAX_ID;
95349572 host->max_lun = UFS_MAX_LUNS;
95359573 host->max_channel = UFSHCD_MAX_CHANNEL;
@@ -9597,12 +9635,6 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq) · 61 unmodified lines
95979635 goto out_disable;
95989636 }
95999637
9600− hba->cmd_queue = blk_mq_init_queue(&hba->host->tag_set);
9601− if (IS_ERR(hba->cmd_queue)) {
9602− err = PTR_ERR(hba->cmd_queue);
9603− goto out_remove_scsi_host;
9604− }
9605−
96069638 hba->tmf_tag_set = (struct blk_mq_tag_set) {
96079639 .nr_hw_queues = 1,
96089640 .queue_depth = hba->nutmrs,
@@ -9611,7 +9643,7 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq) · 2 unmodified lines
96119643 };
96129644 err = blk_mq_alloc_tag_set(&hba->tmf_tag_set);
96139645 if (err < 0)
9614− goto free_cmd_queue;
9646+ goto out_remove_scsi_host;
96159647 hba->tmf_queue = blk_mq_init_queue(&hba->tmf_tag_set);
96169648 if (IS_ERR(hba->tmf_queue)) {
96179649 err = PTR_ERR(hba->tmf_queue);
@@ -9680,8 +9712,6 @@ free_tmf_queue: · 62 unmodified lines
96809712 blk_cleanup_queue(hba->tmf_queue);
96819713 free_tmf_tag_set:
96829714 blk_mq_free_tag_set(&hba->tmf_tag_set);
9683−free_cmd_queue:
9684− blk_cleanup_queue(hba->cmd_queue);
96859715 out_remove_scsi_host:
96869716 scsi_remove_host(hba->host);
96879717 out_disable:
@@ -9703,7 +9733,27 @@ void ufshcd_resume_complete(struct device *dev) · 15 unmodified lines
97039733 }
97049734 EXPORT_SYMBOL_GPL(ufshcd_resume_complete);
97059735
9706−int ufshcd_suspend_prepare(struct device *dev)
9736+static bool ufshcd_rpm_ok_for_spm(struct ufs_hba *hba)
9737+{
9738+ struct device *dev = &hba->sdev_ufs_device->sdev_gendev;
9739+ enum ufs_dev_pwr_mode dev_pwr_mode;
9740+ enum uic_link_state link_state;
9741+ unsigned long flags;
9742+ bool res;
9743+
9744+ spin_lock_irqsave(&dev->power.lock, flags);
9745+ dev_pwr_mode = ufs_get_pm_lvl_to_dev_pwr_mode(hba->spm_lvl);
9746+ link_state = ufs_get_pm_lvl_to_link_pwr_state(hba->spm_lvl);
9747+ res = pm_runtime_suspended(dev) &&
9748+ hba->curr_dev_pwr_mode == dev_pwr_mode &&
9749+ hba->uic_link_state == link_state &&
9750+ !hba->dev_info.b_rpm_dev_flush_capable;
9751+ spin_unlock_irqrestore(&dev->power.lock, flags);
9752+
9753+ return res;
9754+}
9755+
9756+int __ufshcd_suspend_prepare(struct device *dev, bool rpm_ok_for_spm)
97079757 {
97089758 struct ufs_hba *hba = dev_get_drvdata(dev);
97099759 int ret;
@@ -9715,15 +9765,30 @@ int ufshcd_suspend_prepare(struct device *dev) · 5 unmodified lines
97159765 * Refer ufshcd_resume_complete()
97169766 */
97179767 if (hba->sdev_ufs_device) {
9718− ret = ufshcd_rpm_get_sync(hba);
9719− if (ret < 0 && ret != -EACCES) {
9720− ufshcd_rpm_put(hba);
9721− return ret;
9768+ /* Prevent runtime suspend */
9769+ ufshcd_rpm_get_noresume(hba);
9770+ /*
9771+ * Check if already runtime suspended in same state as system
9772+ * suspend would be.
9773+ */
9774+ if (!rpm_ok_for_spm || !ufshcd_rpm_ok_for_spm(hba)) {
9775+ /* RPM state is not ok for SPM, so runtime resume */
9776+ ret = ufshcd_rpm_resume(hba);
9777+ if (ret < 0 && ret != -EACCES) {
9778+ ufshcd_rpm_put(hba);
9779+ return ret;
9780+ }
97229781 }
97239782 hba->complete_put = true;
97249783 }
97259784 return 0;
97269785 }
9786+EXPORT_SYMBOL_GPL(__ufshcd_suspend_prepare);
9787+
9788+int ufshcd_suspend_prepare(struct device *dev)
9789+{
9790+ return __ufshcd_suspend_prepare(dev, true);
9791+}
97279792 EXPORT_SYMBOL_GPL(ufshcd_suspend_prepare);
97289793
97299794 #ifdef CONFIG_PM_SLEEP
drivers/scsi/ufs/ufshcd.h+16−4
@@ -338,7 +338,8 @@ struct ufs_hba_variant_ops { · 337 unmodified lines
338338 enum ufs_notify_change_status status,
339339 struct ufs_pa_layer_attr *,
340340 struct ufs_pa_layer_attr *);
341− void (*setup_xfer_req)(struct ufs_hba *, int, bool);
341+ void (*setup_xfer_req)(struct ufs_hba *hba, int tag,
342+ bool is_scsi_cmd);
342343 void (*setup_task_mgmt)(struct ufs_hba *, int, u8);
343344 void (*hibern8_notify)(struct ufs_hba *, enum uic_cmd_dme,
344345 enum ufs_notify_change_status);
@@ -737,13 +738,13 @@ struct ufs_hba_monitor { · 392 unmodified lines
737738 * @host: Scsi_Host instance of the driver
738739 * @dev: device handle
739740 * @lrb: local reference block
740− * @cmd_queue: Used to allocate command tags from hba->host->tag_set.
741741 * @outstanding_tasks: Bits representing outstanding task requests
742742 * @outstanding_lock: Protects @outstanding_reqs.
743743 * @outstanding_reqs: Bits representing outstanding transfer requests
744744 * @capabilities: UFS Controller Capabilities
745745 * @nutrs: Transfer Request Queue depth supported by controller
746746 * @nutmrs: Task Management Queue depth supported by controller
747+ * @reserved_slot: Used to submit device commands. Protected by @dev_cmd.lock.
747748 * @ufs_version: UFS Version to which controller complies
748749 * @vops: pointer to variant specific operations
749750 * @priv: pointer to variant specific private data
@@ -777,6 +778,7 @@ struct ufs_hba_monitor { · 27 unmodified lines
777778 * @clk_list_head: UFS host controller clocks list node head
778779 * @pwr_info: holds current power mode
779780 * @max_pwr_info: keeps the device max valid pwm
781+ * @clk_scaling_lock: used to serialize device commands and clock scaling
780782 * @desc_size: descriptor sizes reported by device
781783 * @urgent_bkops_lvl: keeps track of urgent bkops level for device
782784 * @is_urgent_bkops_lvl_checked: keeps track if the urgent bkops level for
@@ -802,13 +804,11 @@ struct ufs_hba { · 19 unmodified lines
802804
803805 struct Scsi_Host *host;
804806 struct device *dev;
805− struct request_queue *cmd_queue;
806807 /*
807808 * This field is to keep a reference to "scsi_device" corresponding to
808809 * "UFS device" W-LU.
809810 */
810811 struct scsi_device *sdev_ufs_device;
811− struct scsi_device *sdev_rpmb;
812812
813813 #ifdef CONFIG_SCSI_UFS_HWMON
814814 struct device *hwmon_device;
@@ -836,6 +836,7 @@ struct ufs_hba { · 21 unmodified lines
836836 u32 capabilities;
837837 int nutrs;
838838 int nutmrs;
839+ u32 reserved_slot;
839840 u32 ufs_version;
840841 const struct ufs_hba_variant_ops *vops;
841842 struct ufs_hba_variant_params *vps;
@@ -1211,6 +1212,7 @@ int ufshcd_exec_raw_upiu_cmd(struct ufs_hba *hba, · 369 unmodified lines
12111212
12121213 int ufshcd_wb_toggle(struct ufs_hba *hba, bool enable);
12131214 int ufshcd_suspend_prepare(struct device *dev);
1215+int __ufshcd_suspend_prepare(struct device *dev, bool rpm_ok_for_spm);
12141216 void ufshcd_resume_complete(struct device *dev);
12151217
12161218 /* Wrapper functions for safely calling variant operations */
@@ -1420,6 +1422,16 @@ static inline int ufshcd_rpm_put_sync(struct ufs_hba *hba) · 203 unmodified lines
14201422 return pm_runtime_put_sync(&hba->sdev_ufs_device->sdev_gendev);
14211423 }
14221424
1425+static inline void ufshcd_rpm_get_noresume(struct ufs_hba *hba)
1426+{
1427+ pm_runtime_get_noresume(&hba->sdev_ufs_device->sdev_gendev);
1428+}
1429+
1430+static inline int ufshcd_rpm_resume(struct ufs_hba *hba)
1431+{
1432+ return pm_runtime_resume(&hba->sdev_ufs_device->sdev_gendev);
1433+}
1434+
14231435 static inline int ufshcd_rpm_put(struct ufs_hba *hba)
14241436 {
14251437 return pm_runtime_put(&hba->sdev_ufs_device->sdev_gendev);
drivers/scsi/ufs/ufshpb.c+0−1
@@ -10,7 +10,6 @@ · 9 unmodified lines
1010 */
1111
1212 #include <asm/unaligned.h>
13−#include <linux/async.h>
1413
1514 #include "ufshcd.h"
1615 #include "ufshpb.h"
include/linux/blk-pm.h+1−1
@@ -14,7 +14,7 @@ extern void blk_pm_runtime_init(struct request_queue *q, struct device *dev); · 13 unmodified lines
1414 extern int blk_pre_runtime_suspend(struct request_queue *q);
1515 extern void blk_post_runtime_suspend(struct request_queue *q, int err);
1616 extern void blk_pre_runtime_resume(struct request_queue *q);
17−extern void blk_post_runtime_resume(struct request_queue *q, int err);
17+extern void blk_post_runtime_resume(struct request_queue *q);
1818 extern void blk_set_runtime_active(struct request_queue *q);
1919 #else
2020 static inline void blk_pm_runtime_init(struct request_queue *q,
include/scsi/libsas.h+2−0
@@ -356,6 +356,7 @@ enum sas_ha_state { · 355 unmodified lines
356356 SAS_HA_DRAINING,
357357 SAS_HA_ATA_EH_ACTIVE,
358358 SAS_HA_FROZEN,
359+ SAS_HA_RESUMING,
359360 };
360361
361362 struct sas_ha_struct {
@@ -660,6 +661,7 @@ extern int sas_register_ha(struct sas_ha_struct *); · 298 unmodified lines
660661 extern int sas_unregister_ha(struct sas_ha_struct *);
661662 extern void sas_prep_resume_ha(struct sas_ha_struct *sas_ha);
662663 extern void sas_resume_ha(struct sas_ha_struct *sas_ha);
664+extern void sas_resume_ha_no_sync(struct sas_ha_struct *sas_ha);
663665 extern void sas_suspend_ha(struct sas_ha_struct *sas_ha);
664666
665667 int sas_set_phy_speed(struct sas_phy *phy, struct sas_phy_linkrates *rates);
include/scsi/scsi_host.h+0−6
@@ -691,12 +691,6 @@ struct Scsi_Host { · 690 unmodified lines
691691
692692 /* ldm bits */
693693 struct device shost_gendev, shost_dev;
694− /*
695− * The array size 3 provides space for one attribute group defined by
696− * the SCSI core, one attribute group defined by the SCSI LLD and one
697− * terminating NULL pointer.
698− */
699− const struct attribute_group *shost_dev_attr_groups[3];
700694
701695 /*
702696 * Points to the transport data (if any) which is allocated