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

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
...

+3727 -1641
-2
MAINTAINERS
··· 7081 7081 F: drivers/mmc/host/cqhci* 7082 7082 7083 7083 EMULEX 10Gbps iSCSI - OneConnect DRIVER 7084 - M: Subbu Seetharaman <subbu.seetharaman@broadcom.com> 7085 7084 M: Ketan Mukadam <ketan.mukadam@broadcom.com> 7086 - M: Jitendra Bhivare <jitendra.bhivare@broadcom.com> 7087 7085 L: linux-scsi@vger.kernel.org 7088 7086 S: Supported 7089 7087 W: http://www.broadcom.com
+7 -15
block/blk-pm.c
··· 163 163 /** 164 164 * blk_post_runtime_resume - Post runtime resume processing 165 165 * @q: the queue of the device 166 - * @err: return value of the device's runtime_resume function 167 166 * 168 167 * 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. 172 172 * 173 173 * This function should be called near the end of the device's 174 174 * runtime_resume callback. 175 175 */ 176 - void blk_post_runtime_resume(struct request_queue *q, int err) 176 + void blk_post_runtime_resume(struct request_queue *q) 177 177 { 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); 187 179 } 188 180 EXPORT_SYMBOL(blk_post_runtime_resume); 189 181 ··· 193 201 * runtime PM status and re-enable peeking requests from the queue. It 194 202 * should be called before first request is added to the queue. 195 203 * 196 - * This function is also called by blk_post_runtime_resume() for successful 204 + * This function is also called by blk_post_runtime_resume() for 197 205 * runtime resumes. It does everything necessary to restart the queue. 198 206 */ 199 207 void blk_set_runtime_active(struct request_queue *q)
+2 -4
drivers/message/fusion/mptbase.c
··· 1274 1274 static int 1275 1275 mpt_host_page_access_control(MPT_ADAPTER *ioc, u8 access_control_value, int sleepFlag) 1276 1276 { 1277 - int r = 0; 1278 - 1279 1277 /* return if in use */ 1280 1278 if (CHIPREG_READ32(&ioc->chip->Doorbell) 1281 1279 & MPI_DOORBELL_ACTIVE) ··· 1287 1289 (access_control_value<<12))); 1288 1290 1289 1291 /* Wait for IOC to clear Doorbell Status bit */ 1290 - if ((r = WaitForDoorbellAck(ioc, 5, sleepFlag)) < 0) { 1292 + if (WaitForDoorbellAck(ioc, 5, sleepFlag) < 0) 1291 1293 return -2; 1292 - }else 1294 + else 1293 1295 return 0; 1294 1296 } 1295 1297
-2
drivers/scsi/a100u2w.c
··· 904 904 /** 905 905 * inia100_queue_lck - queue command with host 906 906 * @cmd: Command block 907 - * @done: Completion function 908 907 * 909 908 * Called by the mid layer to queue a command. Process the command 910 909 * block, build the host specific scb structures and if there is room 911 910 * queue the command down to the controller 912 911 */ 913 - 914 912 static int inia100_queue_lck(struct scsi_cmnd *cmd) 915 913 { 916 914 struct orc_scb *scb;
-1
drivers/scsi/atp870u.c
··· 614 614 /** 615 615 * atp870u_queuecommand_lck - Queue SCSI command 616 616 * @req_p: request block 617 - * @done: completion function 618 617 * 619 618 * Queue a command to the ATP queue. Called with the host lock held. 620 619 */
+1 -1
drivers/scsi/bfa/bfad_attr.c
··· 981 981 NULL 982 982 }; 983 983 984 - struct attribute *bfad_im_vport_attrs[] = { 984 + static struct attribute *bfad_im_vport_attrs[] = { 985 985 &dev_attr_serial_number.attr, 986 986 &dev_attr_model.attr, 987 987 &dev_attr_model_description.attr,
+3 -3
drivers/scsi/ch.c
··· 239 239 u_char *buffer; 240 240 int result; 241 241 242 - buffer = kmalloc(512, GFP_KERNEL | GFP_DMA); 242 + buffer = kmalloc(512, GFP_KERNEL); 243 243 if(!buffer) 244 244 return -ENOMEM; 245 245 ··· 297 297 int result,id,lun,i; 298 298 u_int elem; 299 299 300 - buffer = kzalloc(512, GFP_KERNEL | GFP_DMA); 300 + buffer = kzalloc(512, GFP_KERNEL); 301 301 if (!buffer) 302 302 return -ENOMEM; 303 303 ··· 783 783 return -EINVAL; 784 784 elem = ch->firsts[cge.cge_type] + cge.cge_unit; 785 785 786 - buffer = kmalloc(512, GFP_KERNEL | GFP_DMA); 786 + buffer = kmalloc(512, GFP_KERNEL); 787 787 if (!buffer) 788 788 return -ENOMEM; 789 789 mutex_lock(&ch->lock);
+1 -2
drivers/scsi/dc395x.c
··· 946 946 * layer, invoke 'done' on completion 947 947 * 948 948 * @cmd: pointer to scsi command object 949 - * @done: function pointer to be invoked on completion 950 949 * 951 950 * Returns 1 if the adapter (host) is busy, else returns 0. One 952 951 * reason for an adapter to be busy is that the number ··· 958 959 * Locks: struct Scsi_Host::host_lock held on entry (with "irqsave") 959 960 * and is expected to be held on return. 960 961 * 961 - **/ 962 + */ 962 963 static int dc395x_queue_command_lck(struct scsi_cmnd *cmd) 963 964 { 964 965 void (*done)(struct scsi_cmnd *) = scsi_done;
+1 -1
drivers/scsi/elx/efct/efct_driver.c
··· 261 261 262 262 dma.size = FW_WRITE_BUFSIZE; 263 263 dma.virt = dma_alloc_coherent(&efct->pci->dev, 264 - dma.size, &dma.phys, GFP_DMA); 264 + dma.size, &dma.phys, GFP_KERNEL); 265 265 if (!dma.virt) 266 266 return -ENOMEM; 267 267
+5 -5
drivers/scsi/elx/efct/efct_hw.c
··· 516 516 dma = &hw->xfer_rdy; 517 517 dma->size = sizeof(struct fcp_txrdy) * hw->config.n_io; 518 518 dma->virt = dma_alloc_coherent(&efct->pci->dev, 519 - dma->size, &dma->phys, GFP_DMA); 519 + dma->size, &dma->phys, GFP_KERNEL); 520 520 if (!dma->virt) 521 521 return -ENOMEM; 522 522 } ··· 562 562 sizeof(struct sli4_sge); 563 563 dma->virt = dma_alloc_coherent(&efct->pci->dev, 564 564 dma->size, &dma->phys, 565 - GFP_DMA); 565 + GFP_KERNEL); 566 566 if (!dma->virt) { 567 567 efc_log_err(hw->os, "dma_alloc fail %d\n", i); 568 568 memset(&io->def_sgl, 0, ··· 618 618 memset(&req, 0, sizeof(struct efc_dma)); 619 619 req.size = 32 + sgls_per_request * 16; 620 620 req.virt = dma_alloc_coherent(&efct->pci->dev, req.size, &req.phys, 621 - GFP_DMA); 621 + GFP_KERNEL); 622 622 if (!req.virt) { 623 623 kfree(sgls); 624 624 return -ENOMEM; ··· 1063 1063 dma = &hw->loop_map; 1064 1064 dma->size = SLI4_MIN_LOOP_MAP_BYTES; 1065 1065 dma->virt = dma_alloc_coherent(&hw->os->pci->dev, dma->size, &dma->phys, 1066 - GFP_DMA); 1066 + GFP_KERNEL); 1067 1067 if (!dma->virt) 1068 1068 return -EIO; 1069 1069 ··· 1192 1192 prq->dma.virt = dma_alloc_coherent(&efct->pci->dev, 1193 1193 prq->dma.size, 1194 1194 &prq->dma.phys, 1195 - GFP_DMA); 1195 + GFP_KERNEL); 1196 1196 if (!prq->dma.virt) { 1197 1197 efc_log_err(hw->os, "DMA allocation failed\n"); 1198 1198 kfree(rq_buf);
+1 -1
drivers/scsi/elx/efct/efct_io.c
··· 48 48 io->rspbuf.size = SCSI_RSP_BUF_LENGTH; 49 49 io->rspbuf.virt = dma_alloc_coherent(&efct->pci->dev, 50 50 io->rspbuf.size, 51 - &io->rspbuf.phys, GFP_DMA); 51 + &io->rspbuf.phys, GFP_KERNEL); 52 52 if (!io->rspbuf.virt) { 53 53 efc_log_err(efct, "dma_alloc rspbuf failed\n"); 54 54 efct_io_pool_free(io_pool);
+2 -2
drivers/scsi/elx/libefc/efc_cmds.c
··· 179 179 nport->dma.size = EFC_SPARAM_DMA_SZ; 180 180 nport->dma.virt = dma_alloc_coherent(&efc->pci->dev, 181 181 nport->dma.size, &nport->dma.phys, 182 - GFP_DMA); 182 + GFP_KERNEL); 183 183 if (!nport->dma.virt) { 184 184 efc_log_err(efc, "Failed to allocate DMA memory\n"); 185 185 efc_nport_free_resources(nport, EFC_EVT_NPORT_ALLOC_FAIL, data); ··· 466 466 domain->dma.size = EFC_SPARAM_DMA_SZ; 467 467 domain->dma.virt = dma_alloc_coherent(&efc->pci->dev, 468 468 domain->dma.size, 469 - &domain->dma.phys, GFP_DMA); 469 + &domain->dma.phys, GFP_KERNEL); 470 470 if (!domain->dma.virt) { 471 471 efc_log_err(efc, "Failed to allocate DMA memory\n"); 472 472 return -EIO;
+2 -2
drivers/scsi/elx/libefc/efc_els.c
··· 71 71 /* now allocate DMA for request and response */ 72 72 els->io.req.size = reqlen; 73 73 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); 75 75 if (!els->io.req.virt) { 76 76 mempool_free(els, efc->els_io_pool); 77 77 spin_unlock_irqrestore(&node->els_ios_lock, flags); ··· 80 80 81 81 els->io.rsp.size = rsplen; 82 82 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); 84 84 if (!els->io.rsp.virt) { 85 85 dma_free_coherent(&efc->pci->dev, els->io.req.size, 86 86 els->io.req.virt, els->io.req.phys);
+7 -7
drivers/scsi/elx/libefc_sli/sli4.c
··· 445 445 446 446 dma->size = payload_size; 447 447 dma->virt = dma_alloc_coherent(&sli4->pci->dev, dma->size, 448 - &dma->phys, GFP_DMA); 448 + &dma->phys, GFP_KERNEL); 449 449 if (!dma->virt) 450 450 return -EIO; 451 451 ··· 508 508 509 509 q->dma.size = size * n_entries; 510 510 q->dma.virt = dma_alloc_coherent(&sli4->pci->dev, q->dma.size, 511 - &q->dma.phys, GFP_DMA); 511 + &q->dma.phys, GFP_KERNEL); 512 512 if (!q->dma.virt) { 513 513 memset(&q->dma, 0, sizeof(struct efc_dma)); 514 514 efc_log_err(sli4, "%s allocation failed\n", SLI4_QNAME[qtype]); ··· 849 849 850 850 dma->size = payload_size; 851 851 dma->virt = dma_alloc_coherent(&sli4->pci->dev, dma->size, 852 - &dma->phys, GFP_DMA); 852 + &dma->phys, GFP_KERNEL); 853 853 if (!dma->virt) 854 854 return -EIO; 855 855 ··· 4413 4413 psize = sizeof(struct sli4_rsp_cmn_get_cntl_addl_attributes); 4414 4414 data.size = psize; 4415 4415 data.virt = dma_alloc_coherent(&sli4->pci->dev, data.size, 4416 - &data.phys, GFP_DMA); 4416 + &data.phys, GFP_KERNEL); 4417 4417 if (!data.virt) { 4418 4418 memset(&data, 0, sizeof(struct efc_dma)); 4419 4419 efc_log_err(sli4, "Failed to allocate memory for GET_CNTL_ADDL_ATTR\n"); ··· 4653 4653 */ 4654 4654 sli4->bmbx.size = SLI4_BMBX_SIZE + sizeof(struct sli4_mcqe); 4655 4655 sli4->bmbx.virt = dma_alloc_coherent(&pdev->dev, sli4->bmbx.size, 4656 - &sli4->bmbx.phys, GFP_DMA); 4656 + &sli4->bmbx.phys, GFP_KERNEL); 4657 4657 if (!sli4->bmbx.virt) { 4658 4658 memset(&sli4->bmbx, 0, sizeof(struct efc_dma)); 4659 4659 efc_log_err(sli4, "bootstrap mailbox allocation failed\n"); ··· 4674 4674 sli4->vpd_data.virt = dma_alloc_coherent(&pdev->dev, 4675 4675 sli4->vpd_data.size, 4676 4676 &sli4->vpd_data.phys, 4677 - GFP_DMA); 4677 + GFP_KERNEL); 4678 4678 if (!sli4->vpd_data.virt) { 4679 4679 memset(&sli4->vpd_data, 0, sizeof(struct efc_dma)); 4680 4680 /* Note that failure isn't fatal in this specific case */ ··· 5070 5070 payload_dma->size = payload_size; 5071 5071 payload_dma->virt = dma_alloc_coherent(&sli4->pci->dev, 5072 5072 payload_dma->size, 5073 - &payload_dma->phys, GFP_DMA); 5073 + &payload_dma->phys, GFP_KERNEL); 5074 5074 if (!payload_dma->virt) { 5075 5075 memset(payload_dma, 0, sizeof(struct efc_dma)); 5076 5076 efc_log_err(sli4, "mbox payload memory allocation fail\n");
+6 -1
drivers/scsi/hisi_sas/hisi_sas.h
··· 8 8 #define _HISI_SAS_H_ 9 9 10 10 #include <linux/acpi.h> 11 - #include <linux/async.h> 12 11 #include <linux/blk-mq.h> 13 12 #include <linux/blk-mq-pci.h> 14 13 #include <linux/clk.h> ··· 133 134 bool done; 134 135 }; 135 136 137 + struct hisi_sas_internal_abort { 138 + unsigned int flag; 139 + unsigned int tag; 140 + }; 141 + 136 142 #define HISI_SAS_RST_WORK_INIT(r, c) \ 137 143 { .hisi_hba = hisi_hba, \ 138 144 .completion = &c, \ ··· 158 154 enum hisi_sas_phy_event { 159 155 HISI_PHYE_PHY_UP = 0U, 160 156 HISI_PHYE_LINK_RESET, 157 + HISI_PHYE_PHY_UP_PM, 161 158 HISI_PHYES_NUM, 162 159 }; 163 160
+195 -211
drivers/scsi/hisi_sas/hisi_sas_main.c
··· 158 158 { 159 159 void *bitmap = hisi_hba->slot_index_tags; 160 160 161 - clear_bit(slot_idx, bitmap); 161 + __clear_bit(slot_idx, bitmap); 162 162 } 163 163 164 164 static void hisi_sas_slot_index_free(struct hisi_hba *hisi_hba, int slot_idx) ··· 175 175 { 176 176 void *bitmap = hisi_hba->slot_index_tags; 177 177 178 - set_bit(slot_idx, bitmap); 178 + __set_bit(slot_idx, bitmap); 179 179 } 180 180 181 181 static int hisi_sas_slot_index_alloc(struct hisi_hba *hisi_hba, ··· 204 204 spin_unlock(&hisi_hba->lock); 205 205 206 206 return index; 207 - } 208 - 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 207 } 216 208 217 209 void hisi_sas_slot_task_free(struct hisi_hba *hisi_hba, struct sas_task *task, ··· 265 273 } 266 274 267 275 static void hisi_sas_task_prep_abort(struct hisi_hba *hisi_hba, 268 - struct hisi_sas_slot *slot, 269 - int device_id, int abort_flag, int tag_to_abort) 276 + struct hisi_sas_internal_abort *abort, 277 + struct hisi_sas_slot *slot, int device_id) 270 278 { 271 279 hisi_hba->hw->prep_abort(hisi_hba, slot, 272 - device_id, abort_flag, tag_to_abort); 280 + device_id, abort->flag, abort->tag); 273 281 } 274 282 275 283 static void hisi_sas_dma_unmap(struct hisi_hba *hisi_hba, ··· 395 403 return rc; 396 404 } 397 405 398 - static int hisi_sas_task_prep(struct sas_task *task, 399 - struct hisi_sas_dq **dq_pointer, 400 - bool is_tmf, struct hisi_sas_tmf_task *tmf, 401 - int *pass) 406 + static 407 + void hisi_sas_task_deliver(struct hisi_hba *hisi_hba, 408 + struct hisi_sas_slot *slot, 409 + struct hisi_sas_dq *dq, 410 + struct hisi_sas_device *sas_dev, 411 + struct hisi_sas_internal_abort *abort, 412 + struct hisi_sas_tmf_task *tmf) 402 413 { 403 - struct domain_device *device = task->dev; 404 - struct hisi_hba *hisi_hba = dev_to_hisi_hba(device); 405 - struct hisi_sas_device *sas_dev = device->lldd_dev; 406 - struct hisi_sas_port *port; 407 - struct hisi_sas_slot *slot; 408 - struct hisi_sas_cmd_hdr *cmd_hdr_base; 409 - struct asd_sas_port *sas_port = device->port; 410 - struct device *dev = hisi_hba->dev; 411 - int dlvry_queue_slot, dlvry_queue, rc, slot_idx; 412 - int n_elem = 0, n_elem_dif = 0, n_elem_req = 0; 413 - struct scsi_cmnd *scmd = NULL; 414 - struct hisi_sas_dq *dq; 414 + struct hisi_sas_cmd_hdr *cmd_hdr_base; 415 + int dlvry_queue_slot, dlvry_queue; 416 + struct sas_task *task = slot->task; 415 417 unsigned long flags; 416 418 int wr_q_index; 419 + 420 + spin_lock(&dq->lock); 421 + wr_q_index = dq->wr_point; 422 + dq->wr_point = (dq->wr_point + 1) % HISI_SAS_QUEUE_SLOTS; 423 + list_add_tail(&slot->delivery, &dq->list); 424 + spin_unlock(&dq->lock); 425 + spin_lock(&sas_dev->lock); 426 + list_add_tail(&slot->entry, &sas_dev->list); 427 + spin_unlock(&sas_dev->lock); 428 + 429 + dlvry_queue = dq->id; 430 + dlvry_queue_slot = wr_q_index; 431 + 432 + slot->device_id = sas_dev->device_id; 433 + slot->dlvry_queue = dlvry_queue; 434 + slot->dlvry_queue_slot = dlvry_queue_slot; 435 + cmd_hdr_base = hisi_hba->cmd_hdr[dlvry_queue]; 436 + slot->cmd_hdr = &cmd_hdr_base[dlvry_queue_slot]; 437 + 438 + slot->tmf = tmf; 439 + slot->is_internal = tmf; 440 + task->lldd_task = slot; 441 + 442 + memset(slot->cmd_hdr, 0, sizeof(struct hisi_sas_cmd_hdr)); 443 + memset(hisi_sas_cmd_hdr_addr_mem(slot), 0, HISI_SAS_COMMAND_TABLE_SZ); 444 + memset(hisi_sas_status_buf_addr_mem(slot), 0, 445 + sizeof(struct hisi_sas_err_record)); 446 + 447 + switch (task->task_proto) { 448 + case SAS_PROTOCOL_SMP: 449 + hisi_sas_task_prep_smp(hisi_hba, slot); 450 + break; 451 + case SAS_PROTOCOL_SSP: 452 + hisi_sas_task_prep_ssp(hisi_hba, slot); 453 + break; 454 + case SAS_PROTOCOL_SATA: 455 + case SAS_PROTOCOL_STP: 456 + case SAS_PROTOCOL_SATA | SAS_PROTOCOL_STP: 457 + hisi_sas_task_prep_ata(hisi_hba, slot); 458 + break; 459 + case SAS_PROTOCOL_NONE: 460 + if (abort) { 461 + hisi_sas_task_prep_abort(hisi_hba, abort, slot, sas_dev->device_id); 462 + break; 463 + } 464 + fallthrough; 465 + default: 466 + dev_err(hisi_hba->dev, "task prep: unknown/unsupported proto (0x%x)\n", 467 + task->task_proto); 468 + break; 469 + } 470 + 471 + spin_lock_irqsave(&task->task_state_lock, flags); 472 + task->task_state_flags |= SAS_TASK_AT_INITIATOR; 473 + spin_unlock_irqrestore(&task->task_state_lock, flags); 474 + 475 + WRITE_ONCE(slot->ready, 1); 476 + 477 + spin_lock(&dq->lock); 478 + hisi_hba->hw->start_delivery(dq); 479 + spin_unlock(&dq->lock); 480 + } 481 + 482 + static int hisi_sas_task_exec(struct sas_task *task, gfp_t gfp_flags, 483 + struct hisi_sas_tmf_task *tmf) 484 + { 485 + int n_elem = 0, n_elem_dif = 0, n_elem_req = 0; 486 + struct domain_device *device = task->dev; 487 + struct asd_sas_port *sas_port = device->port; 488 + struct hisi_sas_device *sas_dev = device->lldd_dev; 489 + struct scsi_cmnd *scmd = NULL; 490 + struct hisi_sas_dq *dq = NULL; 491 + struct hisi_sas_port *port; 492 + struct hisi_hba *hisi_hba; 493 + struct hisi_sas_slot *slot; 494 + struct device *dev; 495 + int rc; 496 + 497 + if (!sas_port) { 498 + struct task_status_struct *ts = &task->task_status; 499 + 500 + ts->resp = SAS_TASK_UNDELIVERED; 501 + ts->stat = SAS_PHY_DOWN; 502 + /* 503 + * libsas will use dev->port, should 504 + * not call task_done for sata 505 + */ 506 + if (device->dev_type != SAS_SATA_DEV) 507 + task->task_done(task); 508 + return -ECOMM; 509 + } 510 + 511 + hisi_hba = dev_to_hisi_hba(device); 512 + dev = hisi_hba->dev; 513 + 514 + if (unlikely(test_bit(HISI_SAS_REJECT_CMD_BIT, &hisi_hba->flags))) { 515 + if (!gfpflags_allow_blocking(gfp_flags)) 516 + return -EINVAL; 517 + 518 + down(&hisi_hba->sem); 519 + up(&hisi_hba->sem); 520 + } 417 521 418 522 if (DEV_IS_GONE(sas_dev)) { 419 523 if (sas_dev) ··· 539 451 540 452 blk_tag = blk_mq_unique_tag(scsi_cmd_to_rq(scmd)); 541 453 dq_index = blk_mq_unique_tag_to_hwq(blk_tag); 542 - *dq_pointer = dq = &hisi_hba->dq[dq_index]; 454 + dq = &hisi_hba->dq[dq_index]; 543 455 } else { 544 456 struct Scsi_Host *shost = hisi_hba->shost; 545 457 struct blk_mq_queue_map *qmap = &shost->tag_set.map[HCTX_TYPE_DEFAULT]; 546 458 int queue = qmap->mq_map[raw_smp_processor_id()]; 547 459 548 - *dq_pointer = dq = &hisi_hba->dq[queue]; 460 + dq = &hisi_hba->dq[queue]; 549 461 } 550 462 551 463 port = to_hisi_sas_port(sas_port); ··· 577 489 if (rc < 0) 578 490 goto err_out_dif_dma_unmap; 579 491 580 - slot_idx = rc; 581 - slot = &hisi_hba->slot_info[slot_idx]; 582 - 583 - spin_lock(&dq->lock); 584 - wr_q_index = dq->wr_point; 585 - dq->wr_point = (dq->wr_point + 1) % HISI_SAS_QUEUE_SLOTS; 586 - list_add_tail(&slot->delivery, &dq->list); 587 - spin_unlock(&dq->lock); 588 - spin_lock(&sas_dev->lock); 589 - list_add_tail(&slot->entry, &sas_dev->list); 590 - spin_unlock(&sas_dev->lock); 591 - 592 - dlvry_queue = dq->id; 593 - dlvry_queue_slot = wr_q_index; 594 - 595 - slot->device_id = sas_dev->device_id; 492 + slot = &hisi_hba->slot_info[rc]; 596 493 slot->n_elem = n_elem; 597 494 slot->n_elem_dif = n_elem_dif; 598 - slot->dlvry_queue = dlvry_queue; 599 - slot->dlvry_queue_slot = dlvry_queue_slot; 600 - cmd_hdr_base = hisi_hba->cmd_hdr[dlvry_queue]; 601 - slot->cmd_hdr = &cmd_hdr_base[dlvry_queue_slot]; 602 495 slot->task = task; 603 496 slot->port = port; 497 + 604 498 slot->tmf = tmf; 605 - slot->is_internal = is_tmf; 606 - task->lldd_task = slot; 499 + slot->is_internal = tmf; 607 500 608 - memset(slot->cmd_hdr, 0, sizeof(struct hisi_sas_cmd_hdr)); 609 - memset(hisi_sas_cmd_hdr_addr_mem(slot), 0, HISI_SAS_COMMAND_TABLE_SZ); 610 - memset(hisi_sas_status_buf_addr_mem(slot), 0, 611 - sizeof(struct hisi_sas_err_record)); 612 - 613 - switch (task->task_proto) { 614 - case SAS_PROTOCOL_SMP: 615 - hisi_sas_task_prep_smp(hisi_hba, slot); 616 - break; 617 - case SAS_PROTOCOL_SSP: 618 - hisi_sas_task_prep_ssp(hisi_hba, slot); 619 - break; 620 - case SAS_PROTOCOL_SATA: 621 - case SAS_PROTOCOL_STP: 622 - case SAS_PROTOCOL_SATA | SAS_PROTOCOL_STP: 623 - hisi_sas_task_prep_ata(hisi_hba, slot); 624 - break; 625 - default: 626 - dev_err(dev, "task prep: unknown/unsupported proto (0x%x)\n", 627 - task->task_proto); 628 - break; 629 - } 630 - 631 - spin_lock_irqsave(&task->task_state_lock, flags); 632 - task->task_state_flags |= SAS_TASK_AT_INITIATOR; 633 - spin_unlock_irqrestore(&task->task_state_lock, flags); 634 - 635 - ++(*pass); 636 - WRITE_ONCE(slot->ready, 1); 501 + /* protect task_prep and start_delivery sequence */ 502 + hisi_sas_task_deliver(hisi_hba, slot, dq, sas_dev, NULL, tmf); 637 503 638 504 return 0; 639 505 ··· 596 554 hisi_sas_dif_dma_unmap(hisi_hba, task, n_elem_dif); 597 555 err_out_dma_unmap: 598 556 hisi_sas_dma_unmap(hisi_hba, task, n_elem, 599 - n_elem_req); 557 + n_elem_req); 600 558 prep_out: 601 - dev_err(dev, "task prep: failed[%d]!\n", rc); 602 - return rc; 603 - } 604 - 605 - static int hisi_sas_task_exec(struct sas_task *task, gfp_t gfp_flags, 606 - bool is_tmf, struct hisi_sas_tmf_task *tmf) 607 - { 608 - u32 rc; 609 - u32 pass = 0; 610 - struct hisi_hba *hisi_hba; 611 - struct device *dev; 612 - struct domain_device *device = task->dev; 613 - struct asd_sas_port *sas_port = device->port; 614 - struct hisi_sas_dq *dq = NULL; 615 - 616 - if (!sas_port) { 617 - struct task_status_struct *ts = &task->task_status; 618 - 619 - ts->resp = SAS_TASK_UNDELIVERED; 620 - ts->stat = SAS_PHY_DOWN; 621 - /* 622 - * libsas will use dev->port, should 623 - * not call task_done for sata 624 - */ 625 - if (device->dev_type != SAS_SATA_DEV) 626 - task->task_done(task); 627 - return -ECOMM; 628 - } 629 - 630 - hisi_hba = dev_to_hisi_hba(device); 631 - dev = hisi_hba->dev; 632 - 633 - if (unlikely(test_bit(HISI_SAS_REJECT_CMD_BIT, &hisi_hba->flags))) { 634 - if (!gfpflags_allow_blocking(gfp_flags)) 635 - return -EINVAL; 636 - 637 - down(&hisi_hba->sem); 638 - up(&hisi_hba->sem); 639 - } 640 - 641 - /* protect task_prep and start_delivery sequence */ 642 - rc = hisi_sas_task_prep(task, &dq, is_tmf, tmf, &pass); 643 - if (rc) 644 - dev_err(dev, "task exec: failed[%d]!\n", rc); 645 - 646 - if (likely(pass)) { 647 - spin_lock(&dq->lock); 648 - hisi_hba->hw->start_delivery(dq); 649 - spin_unlock(&dq->lock); 650 - } 651 - 559 + dev_err(dev, "task exec: failed[%d]!\n", rc); 652 560 return rc; 653 561 } 654 562 ··· 610 618 611 619 if (!phy->phy_attached) 612 620 return; 613 - 614 - if (test_bit(HISI_SAS_PM_BIT, &hisi_hba->flags) && 615 - !sas_phy->suspended) { 616 - dev_warn(hisi_hba->dev, "phy%d during suspend filtered out\n", phy_no); 617 - return; 618 - } 619 621 620 622 sas_notify_phy_event(sas_phy, PHYE_OOB_DONE, gfp_flags); 621 623 ··· 846 860 } 847 861 EXPORT_SYMBOL_GPL(hisi_sas_scan_finished); 848 862 849 - static void hisi_sas_phyup_work(struct work_struct *work) 863 + static void hisi_sas_phyup_work_common(struct work_struct *work, 864 + enum hisi_sas_phy_event event) 850 865 { 851 866 struct hisi_sas_phy *phy = 852 - container_of(work, typeof(*phy), works[HISI_PHYE_PHY_UP]); 867 + container_of(work, typeof(*phy), works[event]); 853 868 struct hisi_hba *hisi_hba = phy->hisi_hba; 854 869 struct asd_sas_phy *sas_phy = &phy->sas_phy; 855 870 int phy_no = sas_phy->id; ··· 859 872 if (phy->identify.target_port_protocols == SAS_PROTOCOL_SSP) 860 873 hisi_hba->hw->sl_notify_ssp(hisi_hba, phy_no); 861 874 hisi_sas_bytes_dmaed(hisi_hba, phy_no, GFP_KERNEL); 875 + } 876 + 877 + static void hisi_sas_phyup_work(struct work_struct *work) 878 + { 879 + hisi_sas_phyup_work_common(work, HISI_PHYE_PHY_UP); 862 880 } 863 881 864 882 static void hisi_sas_linkreset_work(struct work_struct *work) ··· 875 883 hisi_sas_control_phy(sas_phy, PHY_FUNC_LINK_RESET, NULL); 876 884 } 877 885 886 + static void hisi_sas_phyup_pm_work(struct work_struct *work) 887 + { 888 + struct hisi_sas_phy *phy = 889 + container_of(work, typeof(*phy), works[HISI_PHYE_PHY_UP_PM]); 890 + struct hisi_hba *hisi_hba = phy->hisi_hba; 891 + struct device *dev = hisi_hba->dev; 892 + 893 + hisi_sas_phyup_work_common(work, HISI_PHYE_PHY_UP_PM); 894 + pm_runtime_put_sync(dev); 895 + } 896 + 878 897 static const work_func_t hisi_sas_phye_fns[HISI_PHYES_NUM] = { 879 898 [HISI_PHYE_PHY_UP] = hisi_sas_phyup_work, 880 899 [HISI_PHYE_LINK_RESET] = hisi_sas_linkreset_work, 900 + [HISI_PHYE_PHY_UP_PM] = hisi_sas_phyup_pm_work, 881 901 }; 882 902 883 903 bool hisi_sas_notify_phy_event(struct hisi_sas_phy *phy, ··· 921 917 { 922 918 struct hisi_sas_phy *phy = &hisi_hba->phy[phy_no]; 923 919 struct device *dev = hisi_hba->dev; 920 + unsigned long flags; 924 921 925 922 dev_dbg(dev, "phy%d OOB ready\n", phy_no); 926 - if (phy->phy_attached) 923 + spin_lock_irqsave(&phy->lock, flags); 924 + if (phy->phy_attached) { 925 + spin_unlock_irqrestore(&phy->lock, flags); 927 926 return; 927 + } 928 928 929 929 if (!timer_pending(&phy->timer)) { 930 930 if (phy->wait_phyup_cnt < HISI_SAS_WAIT_PHYUP_RETRIES) { ··· 936 928 phy->timer.expires = jiffies + 937 929 HISI_SAS_WAIT_PHYUP_TIMEOUT; 938 930 add_timer(&phy->timer); 939 - } else { 940 - dev_warn(dev, "phy%d failed to come up %d times, giving up\n", 941 - phy_no, phy->wait_phyup_cnt); 942 - phy->wait_phyup_cnt = 0; 931 + spin_unlock_irqrestore(&phy->lock, flags); 932 + return; 943 933 } 934 + 935 + dev_warn(dev, "phy%d failed to come up %d times, giving up\n", 936 + phy_no, phy->wait_phyup_cnt); 937 + phy->wait_phyup_cnt = 0; 944 938 } 939 + spin_unlock_irqrestore(&phy->lock, flags); 945 940 } 941 + 946 942 EXPORT_SYMBOL_GPL(hisi_sas_phy_oob_ready); 947 943 948 944 static void hisi_sas_phy_init(struct hisi_hba *hisi_hba, int phy_no) ··· 1117 1105 1118 1106 static int hisi_sas_queue_command(struct sas_task *task, gfp_t gfp_flags) 1119 1107 { 1120 - return hisi_sas_task_exec(task, gfp_flags, 0, NULL); 1108 + return hisi_sas_task_exec(task, gfp_flags, NULL); 1121 1109 } 1122 1110 1123 1111 static int hisi_sas_phy_set_linkrate(struct hisi_hba *hisi_hba, int phy_no, ··· 1168 1156 u8 sts = phy->phy_attached; 1169 1157 int ret = 0; 1170 1158 1159 + down(&hisi_hba->sem); 1171 1160 phy->reset_completion = &completion; 1172 1161 1173 1162 switch (func) { ··· 1212 1199 out: 1213 1200 phy->reset_completion = NULL; 1214 1201 1202 + up(&hisi_hba->sem); 1215 1203 return ret; 1216 1204 } 1217 1205 ··· 1273 1259 task->slow_task->timer.expires = jiffies + TASK_TIMEOUT; 1274 1260 add_timer(&task->slow_task->timer); 1275 1261 1276 - res = hisi_sas_task_exec(task, GFP_KERNEL, 1, tmf); 1277 - 1262 + res = hisi_sas_task_exec(task, GFP_KERNEL, tmf); 1278 1263 if (res) { 1279 1264 del_timer_sync(&task->slow_task->timer); 1280 1265 dev_err(dev, "abort tmf: executing internal task failed: %d\n", ··· 1446 1433 sas_port = device->port; 1447 1434 port = to_hisi_sas_port(sas_port); 1448 1435 1436 + spin_lock(&sas_port->phy_list_lock); 1449 1437 list_for_each_entry(sas_phy, &sas_port->phy_list, port_phy_el) 1450 1438 if (state & BIT(sas_phy->id)) { 1451 1439 phy = sas_phy->lldd_phy; 1452 1440 break; 1453 1441 } 1442 + spin_unlock(&sas_port->phy_list_lock); 1454 1443 1455 1444 if (phy) { 1456 1445 port->id = phy->port_id; ··· 1529 1514 struct ata_link *link; 1530 1515 u8 fis[20] = {0}; 1531 1516 u32 state; 1517 + int i; 1532 1518 1533 1519 state = hisi_hba->hw->get_phys_state(hisi_hba); 1534 - list_for_each_entry(sas_phy, &sas_port->phy_list, port_phy_el) { 1520 + for (i = 0; i < hisi_hba->n_phy; i++) { 1535 1521 if (!(state & BIT(sas_phy->id))) 1522 + continue; 1523 + if (!(sas_port->phy_mask & BIT(i))) 1536 1524 continue; 1537 1525 1538 1526 ata_for_each_link(link, ap, EDGE) { 1539 1527 int pmp = sata_srst_pmp(link); 1540 1528 1541 - tmf_task.phy_id = sas_phy->id; 1529 + tmf_task.phy_id = i; 1542 1530 hisi_sas_fill_ata_reset_cmd(link->device, 1, pmp, fis); 1543 1531 rc = hisi_sas_exec_internal_tmf_task(device, fis, s, 1544 1532 &tmf_task); 1545 1533 if (rc != TMF_RESP_FUNC_COMPLETE) { 1546 1534 dev_err(dev, "phy%d ata reset failed rc=%d\n", 1547 - sas_phy->id, rc); 1535 + i, rc); 1548 1536 break; 1549 1537 } 1550 1538 } ··· 1599 1581 { 1600 1582 struct Scsi_Host *shost = hisi_hba->shost; 1601 1583 1602 - down(&hisi_hba->sem); 1603 1584 hisi_hba->phy_state = hisi_hba->hw->get_phys_state(hisi_hba); 1604 1585 1605 1586 scsi_block_requests(shost); ··· 1623 1606 if (hisi_hba->reject_stp_links_msk) 1624 1607 hisi_sas_terminate_stp_reject(hisi_hba); 1625 1608 hisi_sas_reset_init_all_devices(hisi_hba); 1626 - up(&hisi_hba->sem); 1627 1609 scsi_unblock_requests(shost); 1628 1610 clear_bit(HISI_SAS_RESETTING_BIT, &hisi_hba->flags); 1611 + up(&hisi_hba->sem); 1629 1612 1630 1613 hisi_sas_rescan_topology(hisi_hba, hisi_hba->phy_state); 1631 1614 } ··· 1636 1619 if (!hisi_hba->hw->soft_reset) 1637 1620 return -1; 1638 1621 1639 - if (test_and_set_bit(HISI_SAS_RESETTING_BIT, &hisi_hba->flags)) 1622 + down(&hisi_hba->sem); 1623 + if (test_and_set_bit(HISI_SAS_RESETTING_BIT, &hisi_hba->flags)) { 1624 + up(&hisi_hba->sem); 1640 1625 return -1; 1626 + } 1641 1627 1642 1628 if (hisi_sas_debugfs_enable && hisi_hba->debugfs_itct[0].itct) 1643 1629 hisi_hba->hw->debugfs_snapshot_regs(hisi_hba); ··· 2041 2021 2042 2022 static int 2043 2023 hisi_sas_internal_abort_task_exec(struct hisi_hba *hisi_hba, int device_id, 2044 - struct sas_task *task, int abort_flag, 2045 - int task_tag, struct hisi_sas_dq *dq) 2024 + struct hisi_sas_internal_abort *abort, 2025 + struct sas_task *task, 2026 + struct hisi_sas_dq *dq) 2046 2027 { 2047 2028 struct domain_device *device = task->dev; 2048 2029 struct hisi_sas_device *sas_dev = device->lldd_dev; 2049 2030 struct device *dev = hisi_hba->dev; 2050 2031 struct hisi_sas_port *port; 2051 - struct hisi_sas_slot *slot; 2052 2032 struct asd_sas_port *sas_port = device->port; 2053 - struct hisi_sas_cmd_hdr *cmd_hdr_base; 2054 - int dlvry_queue_slot, dlvry_queue, n_elem = 0, rc, slot_idx; 2055 - unsigned long flags; 2056 - int wr_q_index; 2033 + struct hisi_sas_slot *slot; 2034 + int slot_idx; 2057 2035 2058 2036 if (unlikely(test_bit(HISI_SAS_REJECT_CMD_BIT, &hisi_hba->flags))) 2059 2037 return -EINVAL; ··· 2062 2044 port = to_hisi_sas_port(sas_port); 2063 2045 2064 2046 /* simply get a slot and send abort command */ 2065 - rc = hisi_sas_slot_index_alloc(hisi_hba, NULL); 2066 - if (rc < 0) 2047 + slot_idx = hisi_sas_slot_index_alloc(hisi_hba, NULL); 2048 + if (slot_idx < 0) 2067 2049 goto err_out; 2068 2050 2069 - slot_idx = rc; 2070 2051 slot = &hisi_hba->slot_info[slot_idx]; 2071 - 2072 - spin_lock(&dq->lock); 2073 - wr_q_index = dq->wr_point; 2074 - dq->wr_point = (dq->wr_point + 1) % HISI_SAS_QUEUE_SLOTS; 2075 - list_add_tail(&slot->delivery, &dq->list); 2076 - spin_unlock(&dq->lock); 2077 - spin_lock(&sas_dev->lock); 2078 - list_add_tail(&slot->entry, &sas_dev->list); 2079 - spin_unlock(&sas_dev->lock); 2080 - 2081 - dlvry_queue = dq->id; 2082 - dlvry_queue_slot = wr_q_index; 2083 - 2084 - slot->device_id = sas_dev->device_id; 2085 - slot->n_elem = n_elem; 2086 - slot->dlvry_queue = dlvry_queue; 2087 - slot->dlvry_queue_slot = dlvry_queue_slot; 2088 - cmd_hdr_base = hisi_hba->cmd_hdr[dlvry_queue]; 2089 - slot->cmd_hdr = &cmd_hdr_base[dlvry_queue_slot]; 2052 + slot->n_elem = 0; 2090 2053 slot->task = task; 2091 2054 slot->port = port; 2092 2055 slot->is_internal = true; 2093 - task->lldd_task = slot; 2094 2056 2095 - memset(slot->cmd_hdr, 0, sizeof(struct hisi_sas_cmd_hdr)); 2096 - memset(hisi_sas_cmd_hdr_addr_mem(slot), 0, HISI_SAS_COMMAND_TABLE_SZ); 2097 - memset(hisi_sas_status_buf_addr_mem(slot), 0, 2098 - sizeof(struct hisi_sas_err_record)); 2099 - 2100 - hisi_sas_task_prep_abort(hisi_hba, slot, device_id, 2101 - abort_flag, task_tag); 2102 - 2103 - spin_lock_irqsave(&task->task_state_lock, flags); 2104 - task->task_state_flags |= SAS_TASK_AT_INITIATOR; 2105 - spin_unlock_irqrestore(&task->task_state_lock, flags); 2106 - WRITE_ONCE(slot->ready, 1); 2107 - /* send abort command to the chip */ 2108 - spin_lock(&dq->lock); 2109 - hisi_hba->hw->start_delivery(dq); 2110 - spin_unlock(&dq->lock); 2057 + hisi_sas_task_deliver(hisi_hba, slot, dq, sas_dev, abort, NULL); 2111 2058 2112 2059 return 0; 2113 2060 2114 2061 err_out: 2115 - dev_err(dev, "internal abort task prep: failed[%d]!\n", rc); 2062 + dev_err(dev, "internal abort task prep: failed[%d]!\n", slot_idx); 2116 2063 2117 - return rc; 2064 + return slot_idx; 2118 2065 } 2119 2066 2120 2067 /** ··· 2101 2118 { 2102 2119 struct sas_task *task; 2103 2120 struct hisi_sas_device *sas_dev = device->lldd_dev; 2121 + struct hisi_sas_internal_abort abort = { 2122 + .flag = abort_flag, 2123 + .tag = tag, 2124 + }; 2104 2125 struct device *dev = hisi_hba->dev; 2105 2126 int res; 2106 - 2107 2127 /* 2108 2128 * The interface is not realized means this HW don't support internal 2109 2129 * abort, or don't need to do internal abort. Then here, we return ··· 2124 2138 return -ENOMEM; 2125 2139 2126 2140 task->dev = device; 2127 - task->task_proto = device->tproto; 2141 + task->task_proto = SAS_PROTOCOL_NONE; 2128 2142 task->task_done = hisi_sas_task_done; 2129 2143 task->slow_task->timer.function = hisi_sas_tmf_timedout; 2130 2144 task->slow_task->timer.expires = jiffies + INTERNAL_ABORT_TIMEOUT; 2131 2145 add_timer(&task->slow_task->timer); 2132 2146 2133 2147 res = hisi_sas_internal_abort_task_exec(hisi_hba, sas_dev->device_id, 2134 - task, abort_flag, tag, dq); 2148 + &abort, task, dq); 2135 2149 if (res) { 2136 2150 del_timer_sync(&task->slow_task->timer); 2137 2151 dev_err(dev, "internal task abort: executing internal task failed: %d\n", ··· 2502 2516 if (!hisi_hba->breakpoint) 2503 2517 goto err_out; 2504 2518 2505 - hisi_hba->slot_index_count = max_command_entries; 2506 - s = hisi_hba->slot_index_count / BITS_PER_BYTE; 2507 - hisi_hba->slot_index_tags = devm_kzalloc(dev, s, GFP_KERNEL); 2519 + s = hisi_hba->slot_index_count = max_command_entries; 2520 + hisi_hba->slot_index_tags = devm_bitmap_zalloc(dev, s, GFP_KERNEL); 2508 2521 if (!hisi_hba->slot_index_tags) 2509 2522 goto err_out; 2510 2523 ··· 2521 2536 if (!hisi_hba->sata_breakpoint) 2522 2537 goto err_out; 2523 2538 2524 - hisi_sas_slot_index_init(hisi_hba); 2525 2539 hisi_hba->last_slot_index = HISI_SAS_UNRESERVED_IPTT; 2526 2540 2527 2541 hisi_hba->wq = create_singlethread_workqueue(dev_name(dev));
+29 -6
drivers/scsi/hisi_sas/hisi_sas_v3_hw.c
··· 1484 1484 struct asd_sas_phy *sas_phy = &phy->sas_phy; 1485 1485 struct device *dev = hisi_hba->dev; 1486 1486 1487 - del_timer(&phy->timer); 1488 1487 hisi_sas_phy_write32(hisi_hba, phy_no, PHYCTRL_PHY_ENA_MSK, 1); 1489 1488 1490 1489 port_id = hisi_sas_read32(hisi_hba, PHY_PORT_NUM_MA); ··· 1560 1561 } 1561 1562 1562 1563 phy->port_id = port_id; 1563 - phy->phy_attached = 1; 1564 - hisi_sas_notify_phy_event(phy, HISI_PHYE_PHY_UP); 1564 + 1565 + /* Call pm_runtime_put_sync() with pairs in hisi_sas_phyup_pm_work() */ 1566 + pm_runtime_get_noresume(dev); 1567 + hisi_sas_notify_phy_event(phy, HISI_PHYE_PHY_UP_PM); 1568 + 1565 1569 res = IRQ_HANDLED; 1570 + 1571 + spin_lock(&phy->lock); 1572 + /* Delete timer and set phy_attached atomically */ 1573 + del_timer(&phy->timer); 1574 + phy->phy_attached = 1; 1575 + spin_unlock(&phy->lock); 1566 1576 end: 1567 1577 if (phy->reset_completion) 1568 1578 complete(phy->reset_completion); ··· 4783 4775 4784 4776 scsi_scan_host(shost); 4785 4777 4778 + pm_runtime_set_autosuspend_delay(dev, 5000); 4779 + pm_runtime_use_autosuspend(dev); 4786 4780 /* 4787 4781 * For the situation that there are ATA disks connected with SAS 4788 4782 * controller, it additionally creates ata_port which will affect the ··· 4858 4848 int rc; 4859 4849 4860 4850 dev_info(dev, "FLR prepare\n"); 4851 + down(&hisi_hba->sem); 4861 4852 set_bit(HISI_SAS_RESETTING_BIT, &hisi_hba->flags); 4862 4853 hisi_sas_controller_reset_prepare(hisi_hba); 4863 4854 ··· 4908 4897 if (test_and_set_bit(HISI_SAS_RESETTING_BIT, &hisi_hba->flags)) 4909 4898 return -1; 4910 4899 4900 + dev_warn(dev, "entering suspend state\n"); 4901 + 4911 4902 scsi_block_requests(shost); 4912 4903 set_bit(HISI_SAS_REJECT_CMD_BIT, &hisi_hba->flags); 4913 4904 flush_workqueue(hisi_hba->wq); ··· 4925 4912 4926 4913 hisi_sas_init_mem(hisi_hba); 4927 4914 4928 - dev_warn(dev, "entering suspend state\n"); 4929 - 4930 4915 hisi_sas_release_tasks(hisi_hba); 4931 4916 4932 4917 sas_suspend_ha(sha); 4918 + 4919 + dev_warn(dev, "end of suspending controller\n"); 4933 4920 return 0; 4934 4921 } 4935 4922 ··· 4956 4943 return rc; 4957 4944 } 4958 4945 phys_init_v3_hw(hisi_hba); 4959 - sas_resume_ha(sha); 4946 + 4947 + /* 4948 + * If a directly-attached disk is removed during suspend, a deadlock 4949 + * may occur, as the PHYE_RESUME_TIMEOUT processing will require the 4950 + * hisi_hba->device to be active, which can only happen when resume 4951 + * completes. So don't wait for the HA event workqueue to drain upon 4952 + * resume. 4953 + */ 4954 + sas_resume_ha_no_sync(sha); 4960 4955 clear_bit(HISI_SAS_RESETTING_BIT, &hisi_hba->flags); 4956 + 4957 + dev_warn(dev, "end of resuming controller\n"); 4961 4958 4962 4959 return 0; 4963 4960 }
+3 -12
drivers/scsi/hosts.c
··· 61 61 static struct class shost_class = { 62 62 .name = "scsi_host", 63 63 .dev_release = scsi_host_cls_release, 64 + .dev_groups = scsi_shost_groups, 64 65 }; 65 66 66 67 /** ··· 378 377 struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize) 379 378 { 380 379 struct Scsi_Host *shost; 381 - int index, i, j = 0; 380 + int index; 382 381 383 382 shost = kzalloc(sizeof(struct Scsi_Host) + privsize, GFP_KERNEL); 384 383 if (!shost) ··· 484 483 shost->shost_dev.parent = &shost->shost_gendev; 485 484 shost->shost_dev.class = &shost_class; 486 485 dev_set_name(&shost->shost_dev, "host%d", shost->host_no); 487 - shost->shost_dev.groups = shost->shost_dev_attr_groups; 488 - shost->shost_dev_attr_groups[j++] = &scsi_shost_attr_group; 489 - if (sht->shost_groups) { 490 - for (i = 0; sht->shost_groups[i] && 491 - j < ARRAY_SIZE(shost->shost_dev_attr_groups); 492 - i++, j++) { 493 - shost->shost_dev_attr_groups[j] = 494 - sht->shost_groups[i]; 495 - } 496 - } 497 - WARN_ON_ONCE(j >= ARRAY_SIZE(shost->shost_dev_attr_groups)); 486 + shost->shost_dev.groups = sht->shost_groups; 498 487 499 488 shost->ehandler = kthread_run(scsi_error_handler, shost, 500 489 "scsi_eh_%d", shost->host_no);
-2
drivers/scsi/hpsa.c
··· 4354 4354 int i, ndevs_to_allocate; 4355 4355 int raid_ctlr_position; 4356 4356 bool physical_device; 4357 - DECLARE_BITMAP(lunzerobits, MAX_EXT_TARGETS); 4358 4357 4359 4358 currentsd = kcalloc(HPSA_MAX_DEVICES, sizeof(*currentsd), GFP_KERNEL); 4360 4359 physdev_list = kzalloc(sizeof(*physdev_list), GFP_KERNEL); ··· 4367 4368 dev_err(&h->pdev->dev, "out of memory\n"); 4368 4369 goto out; 4369 4370 } 4370 - memset(lunzerobits, 0, sizeof(lunzerobits)); 4371 4371 4372 4372 h->drv_req_rescan = 0; /* cancel scheduled rescan - we're doing it. */ 4373 4373
+2 -3
drivers/scsi/initio.c
··· 2602 2602 /** 2603 2603 * i91u_queuecommand_lck - Queue a new command if possible 2604 2604 * @cmd: SCSI command block from the mid layer 2605 - * @done: Completion handler 2606 2605 * 2607 2606 * Attempts to queue a new command with the host adapter. Will return 2608 2607 * zero if successful or indicate a host busy condition if not (which 2609 2608 * will cause the mid layer to call us again later with the command) 2610 2609 */ 2611 - 2612 2610 static int i91u_queuecommand_lck(struct scsi_cmnd *cmd) 2613 2611 { 2614 2612 struct initio_host *host = (struct initio_host *) cmd->device->host->hostdata; ··· 2847 2849 2848 2850 for (; num_scb >= MAX_TARGETS + 3; num_scb--) { 2849 2851 i = num_scb * sizeof(struct scsi_ctrl_blk); 2850 - if ((scb = kzalloc(i, GFP_DMA)) != NULL) 2852 + scb = kzalloc(i, GFP_KERNEL); 2853 + if (scb) 2851 2854 break; 2852 2855 } 2853 2856
-1
drivers/scsi/libsas/sas_discover.c
··· 8 8 9 9 #include <linux/scatterlist.h> 10 10 #include <linux/slab.h> 11 - #include <linux/async.h> 12 11 #include <scsi/scsi_host.h> 13 12 #include <scsi/scsi_eh.h> 14 13 #include "sas_internal.h"
+63 -14
drivers/scsi/libsas/sas_event.c
··· 41 41 return rc; 42 42 } 43 43 44 - 45 - void __sas_drain_work(struct sas_ha_struct *ha) 44 + void sas_queue_deferred_work(struct sas_ha_struct *ha) 46 45 { 47 46 struct sas_work *sw, *_sw; 48 47 int ret; 49 48 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 + { 50 63 set_bit(SAS_HA_DRAINING, &ha->state); 51 64 /* flush submitters */ 52 65 spin_lock_irq(&ha->lock); ··· 68 55 drain_workqueue(ha->event_q); 69 56 drain_workqueue(ha->disco_q); 70 57 71 - spin_lock_irq(&ha->lock); 72 58 clear_bit(SAS_HA_DRAINING, &ha->state); 73 - list_for_each_entry_safe(sw, _sw, &ha->defer_q, drain_node) { 74 - list_del_init(&sw->drain_node); 75 - ret = sas_queue_work(ha, sw); 76 - if (ret != 1) 77 - sas_free_event(to_asd_sas_event(&sw->work)); 78 - 79 - } 80 - spin_unlock_irq(&ha->lock); 59 + sas_queue_deferred_work(ha); 81 60 } 82 61 83 62 int sas_drain_work(struct sas_ha_struct *ha) ··· 109 104 if (!test_and_clear_bit(ev, &d->pending)) 110 105 continue; 111 106 112 - if (list_empty(&port->phy_list)) 107 + spin_lock(&port->phy_list_lock); 108 + if (list_empty(&port->phy_list)) { 109 + spin_unlock(&port->phy_list_lock); 113 110 continue; 111 + } 114 112 115 113 sas_phy = container_of(port->phy_list.next, struct asd_sas_phy, 116 114 port_phy_el); 115 + spin_unlock(&port->phy_list_lock); 117 116 sas_notify_port_event(sas_phy, 118 117 PORTE_BROADCAST_RCVD, GFP_KERNEL); 119 118 } ··· 128 119 static void sas_port_event_worker(struct work_struct *work) 129 120 { 130 121 struct asd_sas_event *ev = to_asd_sas_event(work); 122 + struct asd_sas_phy *phy = ev->phy; 123 + struct sas_ha_struct *ha = phy->ha; 131 124 132 125 sas_port_event_fns[ev->event](work); 126 + pm_runtime_put(ha->dev); 133 127 sas_free_event(ev); 134 128 } 135 129 136 130 static void sas_phy_event_worker(struct work_struct *work) 137 131 { 138 132 struct asd_sas_event *ev = to_asd_sas_event(work); 133 + struct asd_sas_phy *phy = ev->phy; 134 + struct sas_ha_struct *ha = phy->ha; 139 135 140 136 sas_phy_event_fns[ev->event](work); 137 + pm_runtime_put(ha->dev); 141 138 sas_free_event(ev); 139 + } 140 + 141 + /* defer works of new phys during suspend */ 142 + static bool sas_defer_event(struct asd_sas_phy *phy, struct asd_sas_event *ev) 143 + { 144 + struct sas_ha_struct *ha = phy->ha; 145 + unsigned long flags; 146 + bool deferred = false; 147 + 148 + spin_lock_irqsave(&ha->lock, flags); 149 + if (test_bit(SAS_HA_RESUMING, &ha->state) && !phy->suspended) { 150 + struct sas_work *sw = &ev->work; 151 + 152 + list_add_tail(&sw->drain_node, &ha->defer_q); 153 + deferred = true; 154 + } 155 + spin_unlock_irqrestore(&ha->lock, flags); 156 + return deferred; 142 157 } 143 158 144 159 int sas_notify_port_event(struct asd_sas_phy *phy, enum port_event event, ··· 178 145 if (!ev) 179 146 return -ENOMEM; 180 147 148 + /* Call pm_runtime_put() with pairs in sas_port_event_worker() */ 149 + pm_runtime_get_noresume(ha->dev); 150 + 181 151 INIT_SAS_EVENT(ev, sas_port_event_worker, phy, event); 182 152 153 + if (sas_defer_event(phy, ev)) 154 + return 0; 155 + 183 156 ret = sas_queue_event(event, &ev->work, ha); 184 - if (ret != 1) 157 + if (ret != 1) { 158 + pm_runtime_put(ha->dev); 185 159 sas_free_event(ev); 160 + } 186 161 187 162 return ret; 188 163 } ··· 209 168 if (!ev) 210 169 return -ENOMEM; 211 170 171 + /* Call pm_runtime_put() with pairs in sas_phy_event_worker() */ 172 + pm_runtime_get_noresume(ha->dev); 173 + 212 174 INIT_SAS_EVENT(ev, sas_phy_event_worker, phy, event); 213 175 176 + if (sas_defer_event(phy, ev)) 177 + return 0; 178 + 214 179 ret = sas_queue_event(event, &ev->work, ha); 215 - if (ret != 1) 180 + if (ret != 1) { 181 + pm_runtime_put(ha->dev); 216 182 sas_free_event(ev); 183 + } 217 184 218 185 return ret; 219 186 }
+3
drivers/scsi/libsas/sas_expander.c
··· 58 58 struct sas_task *task = NULL; 59 59 struct sas_internal *i = 60 60 to_sas_internal(dev->port->ha->core.shost->transportt); 61 + struct sas_ha_struct *ha = dev->port->ha; 61 62 63 + pm_runtime_get_sync(ha->dev); 62 64 mutex_lock(&dev->ex_dev.cmd_mutex); 63 65 for (retry = 0; retry < 3; retry++) { 64 66 if (test_bit(SAS_DEV_GONE, &dev->state)) { ··· 133 131 } 134 132 } 135 133 mutex_unlock(&dev->ex_dev.cmd_mutex); 134 + pm_runtime_put_sync(ha->dev); 136 135 137 136 BUG_ON(retry == 3 && task != NULL); 138 137 sas_free_task(task);
+47 -2
drivers/scsi/libsas/sas_init.c
··· 362 362 int i; 363 363 364 364 set_bit(SAS_HA_REGISTERED, &ha->state); 365 + set_bit(SAS_HA_RESUMING, &ha->state); 365 366 366 367 /* clear out any stale link events/data from the suspension path */ 367 368 for (i = 0; i < ha->num_phys; i++) { ··· 388 387 return rc; 389 388 } 390 389 391 - void sas_resume_ha(struct sas_ha_struct *ha) 390 + static void sas_resume_insert_broadcast_ha(struct sas_ha_struct *ha) 391 + { 392 + int i; 393 + 394 + for (i = 0; i < ha->num_phys; i++) { 395 + struct asd_sas_port *port = ha->sas_port[i]; 396 + struct domain_device *dev = port->port_dev; 397 + 398 + if (dev && dev_is_expander(dev->dev_type)) { 399 + struct asd_sas_phy *first_phy; 400 + 401 + spin_lock(&port->phy_list_lock); 402 + first_phy = list_first_entry_or_null( 403 + &port->phy_list, struct asd_sas_phy, 404 + port_phy_el); 405 + spin_unlock(&port->phy_list_lock); 406 + 407 + if (first_phy) 408 + sas_notify_port_event(first_phy, 409 + PORTE_BROADCAST_RCVD, GFP_KERNEL); 410 + } 411 + } 412 + } 413 + 414 + static void _sas_resume_ha(struct sas_ha_struct *ha, bool drain) 392 415 { 393 416 const unsigned long tmo = msecs_to_jiffies(25000); 394 417 int i; ··· 442 417 * flush out disks that did not return 443 418 */ 444 419 scsi_unblock_requests(ha->core.shost); 445 - sas_drain_work(ha); 420 + if (drain) 421 + sas_drain_work(ha); 422 + clear_bit(SAS_HA_RESUMING, &ha->state); 423 + 424 + sas_queue_deferred_work(ha); 425 + /* send event PORTE_BROADCAST_RCVD to identify some new inserted 426 + * disks for expander 427 + */ 428 + sas_resume_insert_broadcast_ha(ha); 429 + } 430 + 431 + void sas_resume_ha(struct sas_ha_struct *ha) 432 + { 433 + _sas_resume_ha(ha, true); 446 434 } 447 435 EXPORT_SYMBOL(sas_resume_ha); 436 + 437 + /* A no-sync variant, which does not call sas_drain_ha(). */ 438 + void sas_resume_ha_no_sync(struct sas_ha_struct *ha) 439 + { 440 + _sas_resume_ha(ha, false); 441 + } 442 + EXPORT_SYMBOL(sas_resume_ha_no_sync); 448 443 449 444 void sas_suspend_ha(struct sas_ha_struct *ha) 450 445 {
+2
drivers/scsi/libsas/sas_internal.h
··· 14 14 #include <scsi/scsi_transport_sas.h> 15 15 #include <scsi/libsas.h> 16 16 #include <scsi/sas_ata.h> 17 + #include <linux/pm_runtime.h> 17 18 18 19 #ifdef pr_fmt 19 20 #undef pr_fmt ··· 57 56 58 57 void sas_disable_revalidation(struct sas_ha_struct *ha); 59 58 void sas_enable_revalidation(struct sas_ha_struct *ha); 59 + void sas_queue_deferred_work(struct sas_ha_struct *ha); 60 60 void __sas_drain_work(struct sas_ha_struct *ha); 61 61 62 62 void sas_deform_port(struct asd_sas_phy *phy, int gone);
+4 -3
drivers/scsi/libsas/sas_scsi_host.c
··· 37 37 static void sas_end_task(struct scsi_cmnd *sc, struct sas_task *task) 38 38 { 39 39 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; 41 42 42 43 if (ts->resp == SAS_TASK_UNDELIVERED) { 43 44 /* transport error */ ··· 83 82 case SAS_ABORTED_TASK: 84 83 hs = DID_ABORT; 85 84 break; 86 - case SAM_STAT_CHECK_CONDITION: 85 + case SAS_SAM_STAT_CHECK_CONDITION: 87 86 memcpy(sc->sense_buffer, ts->buf, 88 87 min(SCSI_SENSE_BUFFERSIZE, ts->buf_valid_size)); 89 - stat = SAM_STAT_CHECK_CONDITION; 88 + stat = SAS_SAM_STAT_CHECK_CONDITION; 90 89 break; 91 90 default: 92 91 stat = ts->stat;
+41 -44
drivers/scsi/lpfc/lpfc.h
··· 496 496 __le32 cgn_alarm_hr[24]; 497 497 __le32 cgn_alarm_day[LPFC_MAX_CGN_DAYS]; 498 498 499 - /* Start of congestion statistics */ 500 - uint8_t cgn_stat_npm; /* Notifications per minute */ 499 + struct_group(cgn_stat, 500 + uint8_t cgn_stat_npm; /* Notifications per minute */ 501 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]; 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 509 510 - __le32 cgn_notification; 511 - __le32 cgn_peer_notification; 512 - __le32 link_integ_notification; 513 - __le32 delivery_notification; 510 + __le32 cgn_notification; 511 + __le32 cgn_peer_notification; 512 + __le32 link_integ_notification; 513 + __le32 delivery_notification; 514 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; 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 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; 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 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; 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 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)) 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 + ); 545 543 546 544 __le32 cgn_info_crc; 547 545 #define LPFC_CGN_CRC32_MAGIC_NUMBER 0x1EDC6F41 ··· 666 668 667 669 struct timer_list els_tmofunc; 668 670 struct timer_list delayed_disc_tmo; 669 - 670 - int unreg_vpi_cmpl; 671 671 672 672 uint8_t load_flag; 673 673 #define FC_LOADING 0x1 /* HBA in process of loading drvr */ ··· 1019 1023 #define HBA_DEVLOSS_TMO 0x2000 /* HBA in devloss timeout */ 1020 1024 #define HBA_RRQ_ACTIVE 0x4000 /* process the rrq active list */ 1021 1025 #define HBA_IOQ_FLUSH 0x8000 /* FCP/NVME I/O queues being flushed */ 1022 - #define HBA_FW_DUMP_OP 0x10000 /* Skips fn reset before FW dump */ 1023 1026 #define HBA_RECOVERABLE_UE 0x20000 /* Firmware supports recoverable UE */ 1024 1027 #define HBA_FORCED_LINK_SPEED 0x40000 /* 1025 1028 * Firmware supports Forced Link Speed ··· 1026 1031 */ 1027 1032 #define HBA_PCI_ERR 0x80000 /* The PCI slot is offline */ 1028 1033 #define HBA_FLOGI_ISSUED 0x100000 /* FLOGI was issued */ 1029 - #define HBA_CGN_RSVD1 0x200000 /* Reserved CGN flag */ 1034 + #define HBA_SHORT_CMF 0x200000 /* shorter CMF timer routine */ 1030 1035 #define HBA_CGN_DAY_WRAP 0x400000 /* HBA Congestion info day wraps */ 1031 1036 #define HBA_DEFER_FLOGI 0x800000 /* Defer FLOGI till read_sparm cmpl */ 1032 1037 #define HBA_SETUP 0x1000000 /* Signifies HBA setup is completed */ ··· 1035 1040 #define HBA_HBEAT_TMO 0x8000000 /* HBEAT initiated after timeout */ 1036 1041 #define HBA_FLOGI_OUTSTANDING 0x10000000 /* FLOGI is outstanding */ 1037 1042 1043 + struct completion *fw_dump_cmpl; /* cmpl event tracker for fw_dump */ 1038 1044 uint32_t fcp_ring_in_use; /* When polling test if intr-hndlr active*/ 1039 1045 struct lpfc_dmabuf slim2p; 1040 1046 ··· 1600 1604 #define LPFC_MAX_RXMONITOR_ENTRY 800 1601 1605 #define LPFC_MAX_RXMONITOR_DUMP 32 1602 1606 struct rxtable_entry { 1607 + uint64_t cmf_bytes; /* Total no of read bytes for CMF_SYNC_WQE */ 1603 1608 uint64_t total_bytes; /* Total no of read bytes requested */ 1604 1609 uint64_t rcv_bytes; /* Total no of read bytes completed */ 1605 1610 uint64_t avg_io_size;
+43 -25
drivers/scsi/lpfc/lpfc_attr.c
··· 1709 1709 before_fc_flag = phba->pport->fc_flag; 1710 1710 sriov_nr_virtfn = phba->cfg_sriov_nr_virtfn; 1711 1711 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; 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 + } 1721 + 1722 + status = lpfc_do_offline(phba, LPFC_EVT_OFFLINE); 1723 + 1724 + if (status != 0) 1725 + return status; 1726 + 1727 + /* wait for the device to be quiesced before firmware reset */ 1728 + msleep(100); 1716 1729 } 1717 - 1718 - if (opcode == LPFC_FW_DUMP) 1719 - phba->hba_flag |= HBA_FW_DUMP_OP; 1720 - 1721 - status = lpfc_do_offline(phba, LPFC_EVT_OFFLINE); 1722 - 1723 - if (status != 0) { 1724 - phba->hba_flag &= ~HBA_FW_DUMP_OP; 1725 - return status; 1726 - } 1727 - 1728 - /* wait for the device to be quiesced before firmware reset */ 1729 - msleep(100); 1730 1730 1731 1731 reg_val = readl(phba->sli4_hba.conf_regs_memmap_p + 1732 1732 LPFC_CTL_PDEV_CTL_OFFSET); ··· 1756 1756 lpfc_printf_log(phba, KERN_ERR, LOG_SLI, 1757 1757 "3153 Fail to perform the requested " 1758 1758 "access: x%x\n", reg_val); 1759 + if (phba->fw_dump_cmpl) 1760 + phba->fw_dump_cmpl = NULL; 1759 1761 return rc; 1760 1762 } 1761 1763 1762 1764 /* keep the original port state */ 1763 - if (before_fc_flag & FC_OFFLINE_MODE) 1765 + if (before_fc_flag & FC_OFFLINE_MODE) { 1766 + if (phba->fw_dump_cmpl) 1767 + phba->fw_dump_cmpl = NULL; 1764 1768 goto out; 1769 + } 1765 1770 1766 - init_completion(&online_compl); 1767 - job_posted = lpfc_workq_post_event(phba, &status, &online_compl, 1768 - LPFC_EVT_ONLINE); 1769 - if (!job_posted) 1770 - goto out; 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; 1771 1783 1772 - wait_for_completion(&online_compl); 1773 - 1784 + wait_for_completion(&online_compl); 1785 + } 1774 1786 out: 1775 1787 /* in any case, restore the virtual functions enabled as before */ 1776 1788 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 + 1777 1795 sriov_err = 1778 1796 lpfc_sli_probe_sriov_nr_virtfn(phba, sriov_nr_virtfn); 1779 1797 if (!sriov_err)
+20 -7
drivers/scsi/lpfc/lpfc_debugfs.c
··· 5484 5484 if (len > (LPFC_CGN_BUF_SIZE - LPFC_DEBUG_OUT_LINE_SZ)) { 5485 5485 len += scnprintf(buffer + len, LPFC_CGN_BUF_SIZE - len, 5486 5486 "Truncated . . .\n"); 5487 - break; 5487 + goto out; 5488 5488 } 5489 5489 len += scnprintf(buffer + len, LPFC_CGN_BUF_SIZE - len, 5490 5490 "%03x: %08x %08x %08x %08x " ··· 5495 5495 cnt += 32; 5496 5496 ptr += 8; 5497 5497 } 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)); 5498 5509 out: 5499 5510 return simple_read_from_buffer(buf, nbytes, ppos, buffer, len); 5500 5511 } ··· 5572 5561 start = tail; 5573 5562 5574 5563 len += scnprintf(buffer + len, MAX_DEBUGFS_RX_TABLE_SIZE - len, 5575 - " MaxBPI\t Total Data Cmd Total Data Cmpl " 5576 - " Latency(us) Avg IO Size\tMax IO Size IO cnt " 5577 - "Info BWutil(ms)\n"); 5564 + " MaxBPI Tot_Data_CMF Tot_Data_Cmd " 5565 + "Tot_Data_Cmpl Lat(us) Avg_IO Max_IO " 5566 + "Bsy IO_cnt Info BWutil(ms)\n"); 5578 5567 get_table: 5579 5568 for (i = start; i < last; i++) { 5580 5569 entry = &phba->rxtable[i]; 5581 5570 len += scnprintf(buffer + len, MAX_DEBUGFS_RX_TABLE_SIZE - len, 5582 - "%3d:%12lld %12lld\t%12lld\t" 5583 - "%8lldus\t%8lld\t%10lld " 5584 - "%8d %2d %2d(%2d)\n", 5571 + "%3d:%12lld %12lld %12lld %12lld " 5572 + "%7lldus %8lld %7lld " 5573 + "%2d %4d %2d %2d(%2d)\n", 5585 5574 i, entry->max_bytes_per_interval, 5575 + entry->cmf_bytes, 5586 5576 entry->total_bytes, 5587 5577 entry->rcv_bytes, 5588 5578 entry->avg_io_latency, 5589 5579 entry->avg_io_size, 5590 5580 entry->max_read_cnt, 5581 + entry->cmf_busy, 5591 5582 entry->io_cnt, 5592 5583 entry->cmf_info, 5593 5584 entry->timer_utilization,
+1 -1
drivers/scsi/lpfc/lpfc_debugfs.h
··· 282 282 void *ptr_private; 283 283 }; 284 284 285 - #define MAX_DEBUGFS_RX_TABLE_SIZE (100 * LPFC_MAX_RXMONITOR_ENTRY) 285 + #define MAX_DEBUGFS_RX_TABLE_SIZE (128 * LPFC_MAX_RXMONITOR_ENTRY) 286 286 struct lpfc_rx_monitor_debug { 287 287 char *i_private; 288 288 char *buffer;
+15 -7
drivers/scsi/lpfc/lpfc_els.c
··· 3538 3538 return 1; 3539 3539 } 3540 3540 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); 3546 3541 return 0; 3547 3542 } 3548 3543 ··· 6894 6899 lpfc_get_rdp_info(struct lpfc_hba *phba, struct lpfc_rdp_context *rdp_context) 6895 6900 { 6896 6901 LPFC_MBOXQ_t *mbox = NULL; 6902 + struct lpfc_dmabuf *mp; 6897 6903 int rc; 6898 6904 6899 6905 mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); ··· 6910 6914 mbox->mbox_cmpl = lpfc_mbx_cmpl_rdp_page_a0; 6911 6915 mbox->ctx_ndlp = (struct lpfc_rdp_context *)rdp_context; 6912 6916 rc = lpfc_sli_issue_mbox(phba, mbox, MBX_NOWAIT); 6913 - if (rc == MBX_NOT_FINISHED) 6917 + if (rc == MBX_NOT_FINISHED) { 6918 + mp = (struct lpfc_dmabuf *)mbox->ctx_buf; 6919 + lpfc_mbuf_free(phba, mp->virt, mp->phys); 6914 6920 goto issue_mbox_fail; 6921 + } 6915 6922 6916 6923 return 0; 6917 6924 ··· 10973 10974 lpfc_can_disctmo(vport); 10974 10975 } 10975 10976 10977 + if (ndlp->save_flags & NLP_WAIT_FOR_LOGO) { 10978 + /* Wake up lpfc_vport_delete if waiting...*/ 10979 + if (ndlp->logo_waitq) 10980 + wake_up(ndlp->logo_waitq); 10981 + spin_lock_irq(&ndlp->lock); 10982 + ndlp->nlp_flag &= ~(NLP_ISSUE_LOGO | NLP_LOGO_SND); 10983 + ndlp->save_flags &= ~NLP_WAIT_FOR_LOGO; 10984 + spin_unlock_irq(&ndlp->lock); 10985 + } 10986 + 10976 10987 /* Safe to release resources now. */ 10977 10988 lpfc_els_free_iocb(phba, cmdiocb); 10978 10989 lpfc_nlp_put(ndlp); 10979 - vport->unreg_vpi_cmpl = VPORT_ERROR; 10980 10990 } 10981 10991 10982 10992 /**
+7 -3
drivers/scsi/lpfc/lpfc_hbadisc.c
··· 869 869 if (phba->pci_dev_grp == LPFC_PCI_DEV_OC) 870 870 lpfc_sli4_post_async_mbox(phba); 871 871 872 - if (ha_copy & HA_ERATT) 872 + if (ha_copy & HA_ERATT) { 873 873 /* Handle the error attention event */ 874 874 lpfc_handle_eratt(phba); 875 + 876 + if (phba->fw_dump_cmpl) { 877 + complete(phba->fw_dump_cmpl); 878 + phba->fw_dump_cmpl = NULL; 879 + } 880 + } 875 881 876 882 if (ha_copy & HA_MBATT) 877 883 lpfc_sli_handle_mb_event(phba); ··· 3934 3928 vport->vpi_state &= ~LPFC_VPI_REGISTERED; 3935 3929 vport->fc_flag |= FC_VPORT_NEEDS_REG_VPI; 3936 3930 spin_unlock_irq(shost->host_lock); 3937 - vport->unreg_vpi_cmpl = VPORT_OK; 3938 3931 mempool_free(pmb, phba->mbox_mem_pool); 3939 3932 lpfc_cleanup_vports_rrqs(vport, NULL); 3940 3933 /* ··· 3963 3958 lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT, 3964 3959 "1800 Could not issue unreg_vpi\n"); 3965 3960 mempool_free(mbox, phba->mbox_mem_pool); 3966 - vport->unreg_vpi_cmpl = VPORT_ERROR; 3967 3961 return rc; 3968 3962 } 3969 3963 return 0;
+18 -11
drivers/scsi/lpfc/lpfc_hw.h
··· 3675 3675 }; 3676 3676 3677 3677 typedef struct { 3678 + struct_group_tagged(MAILBOX_word0, bits, 3679 + union { 3680 + struct { 3678 3681 #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 */ 3684 3687 #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; 3690 3693 #endif 3694 + }; 3695 + u32 word0; 3696 + }; 3697 + ); 3691 3698 3692 3699 MAILVARIANTS un; 3693 3700 union sli_var us; ··· 3753 3746 #define IOERR_ILLEGAL_COMMAND 0x06 3754 3747 #define IOERR_XCHG_DROPPED 0x07 3755 3748 #define IOERR_ILLEGAL_FIELD 0x08 3756 - #define IOERR_BAD_CONTINUE 0x09 3749 + #define IOERR_RPI_SUSPENDED 0x09 3757 3750 #define IOERR_TOO_MANY_BUFFERS 0x0A 3758 3751 #define IOERR_RCV_BUFFER_WAITING 0x0B 3759 3752 #define IOERR_NO_CONNECTION 0x0C
+29 -12
drivers/scsi/lpfc/lpfc_init.c
··· 5373 5373 */ 5374 5374 if (!(phba->hba_flag & HBA_FCOE_MODE)) { 5375 5375 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); 5377 5378 goto out_free_dmabuf; 5379 + } 5378 5380 return; 5379 5381 } 5380 5382 /* ··· 5927 5925 uint32_t io_cnt; 5928 5926 uint32_t head, tail; 5929 5927 uint32_t busy, max_read; 5930 - uint64_t total, rcv, lat, mbpi, extra; 5928 + uint64_t total, rcv, lat, mbpi, extra, cnt; 5931 5929 int timer_interval = LPFC_CMF_INTERVAL; 5932 5930 uint32_t ms; 5933 5931 struct lpfc_cgn_stat *cgs; ··· 5998 5996 5999 5997 /* Calculate any extra bytes needed to account for the 6000 5998 * timer accuracy. If we are less than LPFC_CMF_INTERVAL 6001 - * add an extra 3% slop factor, equal to LPFC_CMF_INTERVAL 6002 - * add an extra 2%. The goal is to equalize total with a 6003 - * time > LPFC_CMF_INTERVAL or <= LPFC_CMF_INTERVAL + 1 5999 + * calculate the adjustment needed for total to reflect 6000 + * a full LPFC_CMF_INTERVAL. 6004 6001 */ 6005 - if (ms == LPFC_CMF_INTERVAL) 6006 - extra = div_u64(total, 50); 6007 - else if (ms < LPFC_CMF_INTERVAL) 6008 - extra = div_u64(total, 33); 6002 + if (ms && ms < LPFC_CMF_INTERVAL) { 6003 + cnt = div_u64(total, ms); /* bytes per ms */ 6004 + cnt *= LPFC_CMF_INTERVAL; /* what total should be */ 6005 + 6006 + /* If the timeout is scheduled to be shorter, 6007 + * this value may skew the data, so cap it at mbpi. 6008 + */ 6009 + if ((phba->hba_flag & HBA_SHORT_CMF) && cnt > mbpi) 6010 + cnt = mbpi; 6011 + 6012 + extra = cnt - total; 6013 + } 6009 6014 lpfc_issue_cmf_sync_wqe(phba, LPFC_CMF_INTERVAL, total + extra); 6010 6015 } else { 6011 6016 /* For Monitor mode or link down we want mbpi 6012 6017 * to be the full link speed 6013 6018 */ 6014 6019 mbpi = phba->cmf_link_byte_count; 6020 + extra = 0; 6015 6021 } 6016 6022 phba->cmf_timer_cnt++; 6017 6023 ··· 6050 6040 LPFC_RXMONITOR_TABLE_IN_USE); 6051 6041 entry = &phba->rxtable[head]; 6052 6042 entry->total_bytes = total; 6043 + entry->cmf_bytes = total + extra; 6053 6044 entry->rcv_bytes = rcv; 6054 6045 entry->cmf_busy = busy; 6055 6046 entry->cmf_info = phba->cmf_active_info; ··· 6093 6082 /* Each minute save Fabric and Driver congestion information */ 6094 6083 lpfc_cgn_save_evt_cnt(phba); 6095 6084 6085 + phba->hba_flag &= ~HBA_SHORT_CMF; 6086 + 6096 6087 /* Since we need to call lpfc_cgn_save_evt_cnt every minute, on the 6097 6088 * minute, adjust our next timer interval, if needed, to ensure a 6098 6089 * 1 minute granularity when we get the next timer interrupt. ··· 6105 6092 jiffies); 6106 6093 if (timer_interval <= 0) 6107 6094 timer_interval = LPFC_CMF_INTERVAL; 6095 + else 6096 + phba->hba_flag |= HBA_SHORT_CMF; 6108 6097 6109 6098 /* If we adjust timer_interval, max_bytes_per_interval 6110 6099 * needs to be adjusted as well. ··· 6352 6337 } 6353 6338 6354 6339 rc = lpfc_sli_issue_mbox(phba, pmb, MBX_NOWAIT); 6355 - if (rc == MBX_NOT_FINISHED) 6340 + if (rc == MBX_NOT_FINISHED) { 6341 + lpfc_mbuf_free(phba, mp->virt, mp->phys); 6356 6342 goto out_free_dmabuf; 6343 + } 6357 6344 return; 6358 6345 6359 6346 out_free_dmabuf: ··· 13481 13464 phba->cgn_evt_minute = 0; 13482 13465 phba->hba_flag &= ~HBA_CGN_DAY_WRAP; 13483 13466 13484 - memset(cp, 0xff, LPFC_CGN_DATA_SIZE); 13467 + memset(cp, 0xff, offsetof(struct lpfc_cgn_info, cgn_stat)); 13485 13468 cp->cgn_info_size = cpu_to_le16(LPFC_CGN_INFO_SZ); 13486 13469 cp->cgn_info_version = LPFC_CGN_INFO_V3; 13487 13470 ··· 13540 13523 return; 13541 13524 13542 13525 cp = (struct lpfc_cgn_info *)phba->cgn_i->virt; 13543 - memset(&cp->cgn_stat_npm, 0, LPFC_CGN_STAT_SIZE); 13526 + memset(&cp->cgn_stat, 0, sizeof(cp->cgn_stat)); 13544 13527 13545 13528 ktime_get_real_ts64(&cmpl_time); 13546 13529 time64_to_tm(cmpl_time.tv_sec, 0, &broken);
+6
drivers/scsi/lpfc/lpfc_nportdisc.c
··· 322 322 { 323 323 struct lpfc_hba *phba = vport->phba; 324 324 struct lpfc_dmabuf *pcmd; 325 + struct lpfc_dmabuf *mp; 325 326 uint64_t nlp_portwwn = 0; 326 327 uint32_t *lp; 327 328 IOCB_t *icmd; ··· 572 571 * a default RPI. 573 572 */ 574 573 if (phba->sli_rev == LPFC_SLI_REV4) { 574 + mp = (struct lpfc_dmabuf *)login_mbox->ctx_buf; 575 + if (mp) { 576 + lpfc_mbuf_free(phba, mp->virt, mp->phys); 577 + kfree(mp); 578 + } 575 579 mempool_free(login_mbox, phba->mbox_mem_pool); 576 580 login_mbox = NULL; 577 581 } else {
+5 -3
drivers/scsi/lpfc/lpfc_scsi.c
··· 4393 4393 if (lpfc_cmd->result == IOERR_INVALID_RPI || 4394 4394 lpfc_cmd->result == IOERR_NO_RESOURCES || 4395 4395 lpfc_cmd->result == IOERR_ABORT_REQUESTED || 4396 + lpfc_cmd->result == IOERR_RPI_SUSPENDED || 4396 4397 lpfc_cmd->result == IOERR_SLER_CMD_RCV_FAILURE) { 4397 4398 cmd->result = DID_REQUEUE << 16; 4398 4399 break; ··· 4449 4448 4450 4449 lpfc_printf_vlog(vport, KERN_INFO, LOG_FCP, 4451 4450 "9039 Iodone <%d/%llu> cmd x%px, error " 4452 - "x%x SNS x%x x%x Data: x%x x%x\n", 4451 + "x%x SNS x%x x%x LBA x%llx Data: x%x x%x\n", 4453 4452 cmd->device->id, cmd->device->lun, cmd, 4454 - cmd->result, *lp, *(lp + 3), cmd->retries, 4455 - scsi_get_resid(cmd)); 4453 + cmd->result, *lp, *(lp + 3), 4454 + (u64)scsi_get_lba(cmd), 4455 + cmd->retries, scsi_get_resid(cmd)); 4456 4456 } 4457 4457 4458 4458 lpfc_update_stats(vport, lpfc_cmd);
+15 -23
drivers/scsi/lpfc/lpfc_sli.c
··· 4749 4749 { 4750 4750 uint32_t __iomem *resp_buf; 4751 4751 uint32_t __iomem *mbox_buf; 4752 - volatile uint32_t mbox; 4752 + volatile struct MAILBOX_word0 mbox; 4753 4753 uint32_t hc_copy, ha_copy, resp_data; 4754 4754 int i; 4755 4755 uint8_t hdrtype; ··· 4783 4783 phba->pport->stopped = 1; 4784 4784 } 4785 4785 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; 4789 4789 4790 4790 writel(BARRIER_TEST_PATTERN, (resp_buf + 1)); 4791 4791 mbox_buf = phba->MBslimaddr; 4792 - writel(mbox, mbox_buf); 4792 + writel(mbox.word0, mbox_buf); 4793 4793 4794 4794 for (i = 0; i < 50; i++) { 4795 4795 if (lpfc_readl((resp_buf + 1), &resp_data)) ··· 4810 4810 goto clear_errat; 4811 4811 } 4812 4812 4813 - ((MAILBOX_t *)&mbox)->mbxOwner = OWN_HOST; 4813 + mbox.mbxOwner = OWN_HOST; 4814 4814 resp_data = 0; 4815 4815 for (i = 0; i < 500; i++) { 4816 4816 if (lpfc_readl(resp_buf, &resp_data)) 4817 4817 return; 4818 - if (resp_data != mbox) 4818 + if (resp_data != mbox.word0) 4819 4819 mdelay(1); 4820 4820 else 4821 4821 break; ··· 5046 5046 phba->fcf.fcf_flag = 0; 5047 5047 spin_unlock_irq(&phba->hbalock); 5048 5048 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 - 5055 5049 /* Now physically reset the device */ 5056 5050 lpfc_printf_log(phba, KERN_INFO, LOG_INIT, 5057 5051 "0389 Performing PCI function reset!\n"); ··· 5085 5091 static int 5086 5092 lpfc_sli_brdrestart_s3(struct lpfc_hba *phba) 5087 5093 { 5088 - MAILBOX_t *mb; 5094 + volatile struct MAILBOX_word0 mb; 5089 5095 struct lpfc_sli *psli; 5090 - volatile uint32_t word0; 5091 5096 void __iomem *to_slim; 5092 5097 uint32_t hba_aer_enabled; 5093 5098 ··· 5103 5110 (phba->pport) ? phba->pport->port_state : 0, 5104 5111 psli->sli_flag); 5105 5112 5106 - word0 = 0; 5107 - mb = (MAILBOX_t *) &word0; 5108 - mb->mbxCommand = MBX_RESTART; 5109 - mb->mbxHc = 1; 5113 + mb.word0 = 0; 5114 + mb.mbxCommand = MBX_RESTART; 5115 + mb.mbxHc = 1; 5110 5116 5111 5117 lpfc_reset_barrier(phba); 5112 5118 5113 5119 to_slim = phba->MBslimaddr; 5114 - writel(*(uint32_t *) mb, to_slim); 5120 + writel(mb.word0, to_slim); 5115 5121 readl(to_slim); /* flush */ 5116 5122 5117 5123 /* Only skip post after fc_ffinit is completed */ 5118 5124 if (phba->pport && phba->pport->port_state) 5119 - word0 = 1; /* This is really setting up word1 */ 5125 + mb.word0 = 1; /* This is really setting up word1 */ 5120 5126 else 5121 - word0 = 0; /* This is really setting up word1 */ 5127 + mb.word0 = 0; /* This is really setting up word1 */ 5122 5128 to_slim = phba->MBslimaddr + sizeof (uint32_t); 5123 - writel(*(uint32_t *) mb, to_slim); 5129 + writel(mb.word0, to_slim); 5124 5130 readl(to_slim); /* flush */ 5125 5131 5126 5132 lpfc_sli_brdreset(phba);
+1 -1
drivers/scsi/lpfc/lpfc_version.h
··· 20 20 * included with this package. * 21 21 *******************************************************************/ 22 22 23 - #define LPFC_DRIVER_VERSION "14.0.0.3" 23 + #define LPFC_DRIVER_VERSION "14.0.0.4" 24 24 #define LPFC_DRIVER_NAME "lpfc" 25 25 26 26 /* Used for SLI 2/3 */
+63 -20
drivers/scsi/lpfc/lpfc_vport.c
··· 486 486 } 487 487 488 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 + 535 + static int 489 536 disable_vport(struct fc_vport *fc_vport) 490 537 { 491 538 struct lpfc_vport *vport = *(struct lpfc_vport **)fc_vport->dd_data; 492 539 struct lpfc_hba *phba = vport->phba; 493 540 struct lpfc_nodelist *ndlp = NULL, *next_ndlp = NULL; 494 - long timeout; 495 541 struct Scsi_Host *shost = lpfc_shost_from_vport(vport); 496 542 543 + /* Can't disable during an outstanding delete. */ 544 + if (vport->load_flag & FC_UNLOADING) 545 + return 0; 546 + 497 547 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); 505 550 506 551 lpfc_sli_host_down(vport); 507 552 ··· 645 600 struct lpfc_vport *vport = *(struct lpfc_vport **)fc_vport->dd_data; 646 601 struct Scsi_Host *shost = lpfc_shost_from_vport(vport); 647 602 struct lpfc_hba *phba = vport->phba; 648 - long timeout; 603 + int rc; 649 604 650 605 if (vport->port_type == LPFC_PHYSICAL_PORT) { 651 606 lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT, ··· 710 665 phba->fc_topology != LPFC_TOPOLOGY_LOOP) { 711 666 if (vport->cfg_enable_da_id) { 712 667 /* Send DA_ID and wait for a completion. */ 713 - timeout = msecs_to_jiffies(phba->fc_ratov * 2000); 714 - if (!lpfc_ns_cmd(vport, SLI_CTNS_DA_ID, 0, 0)) 715 - while (vport->ct_flags && timeout) 716 - timeout = schedule_timeout(timeout); 717 - else 668 + rc = lpfc_ns_cmd(vport, SLI_CTNS_DA_ID, 0, 0); 669 + if (rc) { 718 670 lpfc_printf_log(vport->phba, KERN_WARNING, 719 671 LOG_VPORT, 720 672 "1829 CT command failed to " 721 - "delete objects on fabric\n"); 673 + "delete objects on fabric, " 674 + "rc %d\n", rc); 675 + } 722 676 } 723 677 724 678 /* ··· 732 688 ndlp = lpfc_findnode_did(vport, Fabric_DID); 733 689 if (!ndlp) 734 690 goto skip_logo; 735 - vport->unreg_vpi_cmpl = VPORT_INVAL; 736 - timeout = msecs_to_jiffies(phba->fc_ratov * 2000); 737 - if (!lpfc_issue_els_npiv_logo(vport, ndlp)) 738 - while (vport->unreg_vpi_cmpl == VPORT_INVAL && timeout) 739 - timeout = schedule_timeout(timeout); 691 + 692 + rc = lpfc_send_npiv_logo(vport, ndlp); 693 + if (rc) 694 + goto skip_logo; 740 695 } 741 696 742 697 if (!(phba->pport->load_flag & FC_UNLOADING))
-1
drivers/scsi/megaraid/megaraid_mbox.c
··· 1431 1431 /** 1432 1432 * megaraid_queue_command_lck - generic queue entry point for all LLDs 1433 1433 * @scp : pointer to the scsi command to be executed 1434 - * @done : callback routine to be called after the cmd has be completed 1435 1434 * 1436 1435 * Queue entry point for mailbox based controllers. 1437 1436 */
+498 -105
drivers/scsi/mpi3mr/mpi/mpi30_cnfg.h
··· 8 8 #define MPI3_CONFIG_PAGETYPE_IO_UNIT (0x00) 9 9 #define MPI3_CONFIG_PAGETYPE_MANUFACTURING (0x01) 10 10 #define MPI3_CONFIG_PAGETYPE_IOC (0x02) 11 - #define MPI3_CONFIG_PAGETYPE_UEFI_BSD (0x03) 11 + #define MPI3_CONFIG_PAGETYPE_DRIVER (0x03) 12 12 #define MPI3_CONFIG_PAGETYPE_SECURITY (0x04) 13 13 #define MPI3_CONFIG_PAGETYPE_ENCLOSURE (0x11) 14 14 #define MPI3_CONFIG_PAGETYPE_DEVICE (0x12) ··· 181 181 #define MPI3_SAS_HWRATE_MIN_RATE_6_0 (0x0a) 182 182 #define MPI3_SAS_HWRATE_MIN_RATE_12_0 (0x0b) 183 183 #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) 186 195 struct mpi3_man_page0 { 187 196 struct mpi3_config_page_header header; 188 197 u8 chip_revision[8]; ··· 204 195 __le32 reserved98; 205 196 u8 oem; 206 197 u8 sub_oem; 207 - __le16 reserved9e; 198 + __le16 flags; 208 199 u8 board_mfg_day; 209 200 u8 board_mfg_month; 210 201 __le16 board_mfg_year; ··· 217 208 }; 218 209 219 210 #define MPI3_MAN0_PAGEVERSION (0x00) 211 + #define MPI3_MAN0_FLAGS_SWITCH_PRESENT (0x0002) 212 + #define MPI3_MAN0_FLAGS_EXPANDER_PRESENT (0x0001) 220 213 #define MPI3_MAN1_VPD_SIZE (512) 221 214 struct mpi3_man_page1 { 222 215 struct mpi3_config_page_header header; ··· 247 236 #define MPI3_MAN5_PAGEVERSION (0x00) 248 237 struct mpi3_man6_gpio_entry { 249 238 u8 function_code; 250 - u8 reserved01; 239 + u8 function_flags; 251 240 __le16 flags; 252 241 u8 param1; 253 242 u8 param2; ··· 264 253 #define MPI3_MAN6_GPIO_FUNCTION_PORT_STATUS_YELLOW (0x06) 265 254 #define MPI3_MAN6_GPIO_FUNCTION_CABLE_MANAGEMENT (0x07) 266 255 #define MPI3_MAN6_GPIO_FUNCTION_BKPLANE_MGMT_TYPE (0x08) 267 - #define MPI3_MAN6_GPIO_FUNCTION_ISTWI_MUX_RESET (0x09) 268 256 #define MPI3_MAN6_GPIO_FUNCTION_ISTWI_RESET (0x0a) 269 257 #define MPI3_MAN6_GPIO_FUNCTION_BACKEND_PCIE_RESET (0x0b) 270 258 #define MPI3_MAN6_GPIO_FUNCTION_GLOBAL_FAULT (0x0c) ··· 273 263 #define MPI3_MAN6_GPIO_FUNCTION_CTRL_TYPE (0x10) 274 264 #define MPI3_MAN6_GPIO_FUNCTION_LICENSE (0x11) 275 265 #define MPI3_MAN6_GPIO_FUNCTION_REFCLK_CONTROL (0x12) 266 + #define MPI3_MAN6_GPIO_FUNCTION_BACKEND_PCIE_RESET_CLAMP (0x13) 267 + #define MPI3_MAN6_GPIO_ISTWI_RESET_FUNCTIONFLAGS_DEVSELECT_MASK (0x01) 268 + #define MPI3_MAN6_GPIO_ISTWI_RESET_FUNCTIONFLAGS_DEVSELECT_ISTWI (0x00) 269 + #define MPI3_MAN6_GPIO_ISTWI_RESET_FUNCTIONFLAGS_DEVSELECT_RECEPTACLEID (0x01) 276 270 #define MPI3_MAN6_GPIO_EXTINT_PARAM1_FLAGS_SOURCE_MASK (0xf0) 277 271 #define MPI3_MAN6_GPIO_EXTINT_PARAM1_FLAGS_SOURCE_GENERIC (0x00) 278 272 #define MPI3_MAN6_GPIO_EXTINT_PARAM1_FLAGS_SOURCE_CABLE_MGMT (0x10) ··· 289 275 #define MPI3_MAN6_GPIO_CABLE_MGMT_PARAM1_INTERFACE_MODULE_PRESENT (0x00) 290 276 #define MPI3_MAN6_GPIO_CABLE_MGMT_PARAM1_INTERFACE_ACTIVE_CABLE_ENABLE (0x01) 291 277 #define MPI3_MAN6_GPIO_CABLE_MGMT_PARAM1_INTERFACE_CABLE_MGMT_ENABLE (0x02) 292 - #define MPI3_MAN6_GPIO_ISTWI_MUX_RESET_PARAM2_SPEC_MUX (0x00) 293 - #define MPI3_MAN6_GPIO_ISTWI_MUX_RESET_PARAM2_ALL_MUXES (0x01) 294 278 #define MPI3_MAN6_GPIO_LICENSE_PARAM1_TYPE_IBUTTON (0x00) 295 279 #define MPI3_MAN6_GPIO_FLAGS_SLEW_RATE_MASK (0x0100) 296 280 #define MPI3_MAN6_GPIO_FLAGS_SLEW_RATE_FAST_EDGE (0x0100) ··· 365 353 __le32 reserved0c; 366 354 }; 367 355 356 + #define MPI3_MAN8_PHY_INFO_RECEPTACLE_ID_HOST_PHY (0xff) 368 357 #ifndef MPI3_MAN8_PHY_INFO_MAX 369 358 #define MPI3_MAN8_PHY_INFO_MAX (1) 370 359 #endif ··· 386 373 }; 387 374 388 375 enum mpi3_man9_resources { 389 - MPI3_MAN9_RSRC_OUTSTANDING_REQS = 0, 390 - MPI3_MAN9_RSRC_TARGET_CMDS = 1, 391 - MPI3_MAN9_RSRC_SAS_TARGETS = 2, 392 - MPI3_MAN9_RSRC_PCIE_TARGETS = 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_PDS = 10, 400 - MPI3_MAN9_RSRC_HOST_PDS = 11, 401 - MPI3_MAN9_RSRC_ADV_HOST_PDS = 12, 402 - MPI3_MAN9_RSRC_RAID_PDS = 13, 376 + MPI3_MAN9_RSRC_OUTSTANDING_REQS = 0, 377 + MPI3_MAN9_RSRC_TARGET_CMDS = 1, 378 + MPI3_MAN9_RSRC_RESERVED02 = 2, 379 + MPI3_MAN9_RSRC_NVME = 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_RESERVED10 = 10, 387 + MPI3_MAN9_RSRC_HOST_PD_DRIVES = 11, 388 + MPI3_MAN9_RSRC_ADV_HOST_PD_DRIVES = 12, 389 + MPI3_MAN9_RSRC_RAID_PD_DRIVES = 13, 390 + MPI3_MAN9_RSRC_DRV_DIAG_BUF = 14, 391 + MPI3_MAN9_RSRC_NAMESPACE_COUNT = 15, 403 392 MPI3_MAN9_RSRC_NUM_RESOURCES 404 393 }; 405 394 ··· 417 402 #define MPI3_MAN9_MIN_ENCLOSURES (0) 418 403 #define MPI3_MAN9_MAX_ENCLOSURES (65535) 419 404 #define MPI3_MAN9_MIN_ENCLOSURE_PHYS (0) 405 + #define MPI3_MAN9_MIN_NAMESPACE_COUNT (1) 420 406 #define MPI3_MAN9_MIN_EXPANDERS (0) 421 407 #define MPI3_MAN9_MAX_EXPANDERS (65535) 422 408 #define MPI3_MAN9_MIN_PCIE_SWITCHES (0) ··· 438 422 struct mpi3_man10_istwi_ctrlr_entry { 439 423 __le16 slave_address; 440 424 __le16 flags; 441 - __le32 reserved04; 425 + u8 scl_low_override; 426 + u8 scl_high_override; 427 + __le16 reserved06; 442 428 }; 443 429 430 + #define MPI3_MAN10_ISTWI_CTRLR_FLAGS_BUS_SPEED_MASK (0x000c) 431 + #define MPI3_MAN10_ISTWI_CTRLR_FLAGS_BUS_SPEED_100K (0x0000) 432 + #define MPI3_MAN10_ISTWI_CTRLR_FLAGS_BUS_SPEED_400K (0x0004) 444 433 #define MPI3_MAN10_ISTWI_CTRLR_FLAGS_SLAVE_ENABLED (0x0002) 445 434 #define MPI3_MAN10_ISTWI_CTRLR_FLAGS_MASTER_ENABLED (0x0001) 446 435 #ifndef MPI3_MAN10_ISTWI_CTRLR_MAX ··· 472 451 u8 temp_channel[4]; 473 452 }; 474 453 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_CHANNEL_ENABLED (0x01) 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_TYPE_SE97B (0x03) 458 + #define MPI3_MAN11_TEMP_SENSOR_CHANNEL_LOCATION_MASK (0xe0) 459 + #define MPI3_MAN11_TEMP_SENSOR_CHANNEL_LOCATION_SHIFT (5) 460 + #define MPI3_MAN11_TEMP_SENSOR_CHANNEL_ENABLED (0x01) 479 461 struct mpi3_man11_seeprom_device_format { 480 462 u8 size; 481 463 u8 page_write_size; ··· 519 495 #define MPI3_MAN11_BKPLANE_UBM_FLAGS_MAX_FRU_SHIFT (4) 520 496 #define MPI3_MAN11_BKPLANE_UBM_FLAGS_POLL_INTERVAL_MASK (0x000f) 521 497 #define MPI3_MAN11_BKPLANE_UBM_FLAGS_POLL_INTERVAL_SHIFT (0) 522 - struct mpi3_man11_bkplane_spec_vpp_format { 498 + struct mpi3_man11_bkplane_spec_non_ubm_format { 523 499 __le16 flags; 524 - __le16 reserved02; 500 + u8 reserved02; 501 + u8 type; 525 502 }; 526 503 527 - #define MPI3_MAN11_BKPLANE_VPP_FLAGS_REFCLK_POLICY_ALWAYS_ENABLED (0x0040) 528 - #define MPI3_MAN11_BKPLANE_VPP_FLAGS_PRESENCE_DETECT_MASK (0x0030) 529 - #define MPI3_MAN11_BKPLANE_VPP_FLAGS_PRESENCE_DETECT_GPIO (0x0000) 530 - #define MPI3_MAN11_BKPLANE_VPP_FLAGS_PRESENCE_DETECT_REG (0x0010) 531 - #define MPI3_MAN11_BKPLANE_VPP_FLAGS_POLL_INTERVAL_MASK (0x000f) 532 - #define MPI3_MAN11_BKPLANE_VPP_FLAGS_POLL_INTERVAL_SHIFT (0) 504 + #define MPI3_MAN11_BKPLANE_NON_UBM_FLAGS_GROUP_MASK (0xf000) 505 + #define MPI3_MAN11_BKPLANE_NON_UBM_FLAGS_GROUP_SHIFT (12) 506 + #define MPI3_MAN11_BKPLANE_NON_UBM_FLAGS_REFCLK_POLICY_ALWAYS_ENABLED (0x0200) 507 + #define MPI3_MAN11_BKPLANE_NON_UBM_FLAGS_PRESENCE_DETECT_MASK (0x0030) 508 + #define MPI3_MAN11_BKPLANE_NON_UBM_FLAGS_PRESENCE_DETECT_GPIO (0x0000) 509 + #define MPI3_MAN11_BKPLANE_NON_UBM_FLAGS_PRESENCE_DETECT_REG (0x0010) 510 + #define MPI3_MAN11_BKPLANE_NON_UBM_FLAGS_POLL_INTERVAL_MASK (0x000f) 511 + #define MPI3_MAN11_BKPLANE_NON_UBM_FLAGS_POLL_INTERVAL_SHIFT (0) 512 + #define MPI3_MAN11_BKPLANE_NON_UBM_TYPE_VPP (0x00) 533 513 union mpi3_man11_bkplane_spec_format { 534 - struct mpi3_man11_bkplane_spec_ubm_format ubm; 535 - struct mpi3_man11_bkplane_spec_vpp_format vpp; 514 + struct mpi3_man11_bkplane_spec_ubm_format ubm; 515 + struct mpi3_man11_bkplane_spec_non_ubm_format non_ubm; 536 516 }; 537 517 538 518 struct mpi3_man11_bkplane_mgmt_device_format { 539 519 u8 type; 540 520 u8 receptacle_id; 541 - __le16 reserved02; 521 + u8 reset_info; 522 + u8 reserved03; 542 523 union mpi3_man11_bkplane_spec_format backplane_mgmt_specific; 543 524 }; 544 525 545 526 #define MPI3_MAN11_BKPLANE_MGMT_TYPE_UBM (0x00) 546 - #define MPI3_MAN11_BKPLANE_MGMT_TYPE_VPP (0x01) 527 + #define MPI3_MAN11_BKPLANE_MGMT_TYPE_NON_UBM (0x01) 528 + #define MPI3_MAN11_BACKPLANE_RESETINFO_ASSERT_TIME_MASK (0xf0) 529 + #define MPI3_MAN11_BACKPLANE_RESETINFO_ASSERT_TIME_SHIFT (4) 530 + #define MPI3_MAN11_BACKPLANE_RESETINFO_READY_TIME_MASK (0x0f) 531 + #define MPI3_MAN11_BACKPLANE_RESETINFO_READY_TIME_SHIFT (0) 547 532 struct mpi3_man11_gas_gauge_device_format { 548 533 u8 type; 549 534 u8 reserved01[3]; ··· 560 527 }; 561 528 562 529 #define MPI3_MAN11_GAS_GAUGE_TYPE_STANDARD (0x00) 530 + struct mpi3_man11_mgmt_ctrlr_device_format { 531 + __le32 reserved00; 532 + __le32 reserved04; 533 + }; 534 + 563 535 union mpi3_man11_device_specific_format { 564 536 struct mpi3_man11_mux_device_format mux; 565 537 struct mpi3_man11_temp_sensor_device_format temp_sensor; ··· 573 535 struct mpi3_man11_cable_mgmt_device_format cable_mgmt; 574 536 struct mpi3_man11_bkplane_mgmt_device_format bkplane_mgmt; 575 537 struct mpi3_man11_gas_gauge_device_format gas_gauge; 538 + struct mpi3_man11_mgmt_ctrlr_device_format mgmt_controller; 576 539 __le32 words[2]; 577 540 }; 578 541 ··· 595 556 #define MPI3_MAN11_ISTWI_DEVTYPE_CABLE_MGMT (0x04) 596 557 #define MPI3_MAN11_ISTWI_DEVTYPE_BACKPLANE_MGMT (0x05) 597 558 #define MPI3_MAN11_ISTWI_DEVTYPE_GAS_GAUGE (0x06) 559 + #define MPI3_MAN11_ISTWI_DEVTYPE_MGMT_CONTROLLER (0x07) 598 560 #define MPI3_MAN11_ISTWI_FLAGS_MUX_PRESENT (0x01) 599 - #define MPI3_MAN11_ISTWI_FLAGS_BUS_SPEED_MASK (0x06) 600 - #define MPI3_MAN11_ISTWI_FLAGS_BUS_SPEED_100KHZ (0x00) 601 - #define MPI3_MAN11_ISTWI_FLAGS_BUS_SPEED_400KHZ (0x02) 602 561 #ifndef MPI3_MAN11_ISTWI_DEVICE_MAX 603 562 #define MPI3_MAN11_ISTWI_DEVICE_MAX (1) 604 563 #endif ··· 729 692 #define MPI3_MAN14_FLAGS_AUTH_SESSION_REQ (0x01) 730 693 #define MPI3_MAN14_FLAGS_AUTH_API_MASK (0x0e) 731 694 #define MPI3_MAN14_FLAGS_AUTH_API_NONE (0x00) 732 - #define MPI3_MAN14_FLAGS_AUTH_API_CEREBUS (0x02) 733 - #define MPI3_MAN14_FLAGS_AUTH_API_DMTF_PMCI (0x04) 695 + #define MPI3_MAN14_FLAGS_AUTH_API_CERBERUS (0x02) 696 + #define MPI3_MAN14_FLAGS_AUTH_API_SPDM (0x04) 734 697 #ifndef MPI3_MAN15_VERSION_RECORD_MAX 735 698 #define MPI3_MAN15_VERSION_RECORD_MAX 1 736 699 #endif ··· 845 808 struct mpi3_config_page_header header; 846 809 __le32 flags; 847 810 u8 dmd_io_delay; 848 - u8 dmd_report_pc_ie; 811 + u8 dmd_report_pcie; 849 812 u8 dmd_report_sata; 850 813 u8 dmd_report_sas; 851 814 }; ··· 881 844 #define MPI3_IOUNIT2_GPIO_SETTING_ON (0x0001) 882 845 struct mpi3_io_unit3_sensor { 883 846 __le16 flags; 884 - __le16 reserved02; 885 - __le16 threshold[4]; 847 + u8 threshold_margin; 848 + u8 reserved03; 849 + __le16 threshold[3]; 850 + __le16 reserved0a; 886 851 __le32 reserved0c; 887 852 __le32 reserved10; 888 853 __le32 reserved14; 889 854 }; 890 855 891 - #define MPI3_IOUNIT3_SENSOR_FLAGS_T3_ENABLE (0x0008) 892 - #define MPI3_IOUNIT3_SENSOR_FLAGS_T2_ENABLE (0x0004) 893 - #define MPI3_IOUNIT3_SENSOR_FLAGS_T1_ENABLE (0x0002) 894 - #define MPI3_IOUNIT3_SENSOR_FLAGS_T0_ENABLE (0x0001) 856 + #define MPI3_IOUNIT3_SENSOR_FLAGS_FATAL_EVENT_ENABLED (0x0010) 857 + #define MPI3_IOUNIT3_SENSOR_FLAGS_FATAL_ACTION_ENABLED (0x0008) 858 + #define MPI3_IOUNIT3_SENSOR_FLAGS_CRITICAL_EVENT_ENABLED (0x0004) 859 + #define MPI3_IOUNIT3_SENSOR_FLAGS_CRITICAL_ACTION_ENABLED (0x0002) 860 + #define MPI3_IOUNIT3_SENSOR_FLAGS_WARNING_EVENT_ENABLED (0x0001) 895 861 #ifndef MPI3_IO_UNIT3_SENSOR_MAX 896 - #define MPI3_IO_UNIT3_SENSOR_MAX (1) 862 + #define MPI3_IO_UNIT3_SENSOR_MAX (1) 897 863 #endif 898 864 struct mpi3_io_unit_page3 { 899 865 struct mpi3_config_page_header header; 900 866 __le32 reserved08; 901 867 u8 num_sensors; 902 - u8 polling_interval; 903 - __le16 reserved0e; 868 + u8 nominal_poll_interval; 869 + u8 warning_poll_interval; 870 + u8 reserved0f; 904 871 struct mpi3_io_unit3_sensor sensor[MPI3_IO_UNIT3_SENSOR_MAX]; 905 872 }; 906 873 ··· 914 873 __le16 reserved02; 915 874 u8 flags; 916 875 u8 reserved05[3]; 917 - __le32 reserved08; 876 + __le16 istwi_index; 877 + u8 channel; 878 + u8 reserved0b; 918 879 __le32 reserved0c; 919 880 }; 920 881 882 + #define MPI3_IOUNIT4_SENSOR_FLAGS_LOC_MASK (0xe0) 883 + #define MPI3_IOUNIT4_SENSOR_FLAGS_LOC_SHIFT (5) 921 884 #define MPI3_IOUNIT4_SENSOR_FLAGS_TEMP_VALID (0x01) 885 + #define MPI3_IOUNIT4_SENSOR_ISTWI_INDEX_INTERNAL (0xffff) 886 + #define MPI3_IOUNIT4_SENSOR_CHANNEL_RESERVED (0xff) 922 887 #ifndef MPI3_IO_UNIT4_SENSOR_MAX 923 - #define MPI3_IO_UNIT4_SENSOR_MAX (1) 888 + #define MPI3_IO_UNIT4_SENSOR_MAX (1) 924 889 #endif 925 890 struct mpi3_io_unit_page4 { 926 891 struct mpi3_config_page_header header; ··· 953 906 struct mpi3_io_unit5_spinup_group spinup_group_parameters[4]; 954 907 __le32 reserved18; 955 908 __le32 reserved1c; 956 - __le32 reserved20; 957 - u8 reserved24; 909 + __le16 device_shutdown; 910 + __le16 reserved22; 911 + u8 pcie_device_wait_time; 958 912 u8 sata_device_wait_time; 959 913 u8 spinup_encl_drive_count; 960 914 u8 spinup_encl_delay; ··· 967 919 }; 968 920 969 921 #define MPI3_IOUNIT5_PAGEVERSION (0x00) 922 + #define MPI3_IOUNIT5_DEVICE_SHUTDOWN_NO_ACTION (0x00) 923 + #define MPI3_IOUNIT5_DEVICE_SHUTDOWN_DIRECT_ATTACHED (0x01) 924 + #define MPI3_IOUNIT5_DEVICE_SHUTDOWN_EXPANDER_ATTACHED (0x02) 925 + #define MPI3_IOUNIT5_DEVICE_SHUTDOWN_SWITCH_ATTACHED (0x02) 926 + #define MPI3_IOUNIT5_DEVICE_SHUTDOWN_DIRECT_AND_EXPANDER (0x03) 927 + #define MPI3_IOUNIT5_DEVICE_SHUTDOWN_DIRECT_AND_SWITCH (0x03) 928 + #define MPI3_IOUNIT5_DEVICE_SHUTDOWN_SATA_HDD_MASK (0x0300) 929 + #define MPI3_IOUNIT5_DEVICE_SHUTDOWN_SATA_HDD_SHIFT (8) 930 + #define MPI3_IOUNIT5_DEVICE_SHUTDOWN_SAS_HDD_MASK (0x00c0) 931 + #define MPI3_IOUNIT5_DEVICE_SHUTDOWN_SAS_HDD_SHIFT (6) 932 + #define MPI3_IOUNIT5_DEVICE_SHUTDOWN_NVME_SSD_MASK (0x0030) 933 + #define MPI3_IOUNIT5_DEVICE_SHUTDOWN_NVME_SSD_SHIFT (4) 934 + #define MPI3_IOUNIT5_DEVICE_SHUTDOWN_SATA_SSD_MASK (0x000c) 935 + #define MPI3_IOUNIT5_DEVICE_SHUTDOWN_SATA_SSD_SHIFT (2) 936 + #define MPI3_IOUNIT5_DEVICE_SHUTDOWN_SAS_SSD_MASK (0x0003) 937 + #define MPI3_IOUNIT5_DEVICE_SHUTDOWN_SAA_SSD_SHIFT (0) 970 938 #define MPI3_IOUNIT5_FLAGS_POWER_CAPABLE_SPINUP (0x02) 971 939 #define MPI3_IOUNIT5_FLAGS_AUTO_PORT_ENABLE (0x01) 972 940 #define MPI3_IOUNIT5_PHY_SPINUP_GROUP_MASK (0x03) ··· 1076 1012 }; 1077 1013 1078 1014 #define MPI3_IOC2_PAGEVERSION (0x00) 1079 - struct mpi3_uefibsd_page0 { 1015 + #define MPI3_DRIVER_FLAGS_ADMINRAIDPD_BLOCKED (0x0010) 1016 + #define MPI3_DRIVER_FLAGS_OOBRAIDPD_BLOCKED (0x0008) 1017 + #define MPI3_DRIVER_FLAGS_OOBRAIDVD_BLOCKED (0x0004) 1018 + #define MPI3_DRIVER_FLAGS_OOBADVHOSTPD_BLOCKED (0x0002) 1019 + #define MPI3_DRIVER_FLAGS_OOBHOSTPD_BLOCKED (0x0001) 1020 + struct mpi3_allowed_cmd_scsi { 1021 + __le16 service_action; 1022 + u8 operation_code; 1023 + u8 command_flags; 1024 + }; 1025 + 1026 + struct mpi3_allowed_cmd_ata { 1027 + u8 subcommand; 1028 + u8 reserved01; 1029 + u8 command; 1030 + u8 command_flags; 1031 + }; 1032 + 1033 + struct mpi3_allowed_cmd_nvme { 1034 + u8 reserved00; 1035 + u8 nvme_cmd_flags; 1036 + u8 op_code; 1037 + u8 command_flags; 1038 + }; 1039 + 1040 + #define MPI3_DRIVER_ALLOWEDCMD_NVMECMDFLAGS_SUBQ_TYPE_MASK (0x80) 1041 + #define MPI3_DRIVER_ALLOWEDCMD_NVMECMDFLAGS_SUBQ_TYPE_IO (0x00) 1042 + #define MPI3_DRIVER_ALLOWEDCMD_NVMECMDFLAGS_SUBQ_TYPE_ADMIN (0x80) 1043 + #define MPI3_DRIVER_ALLOWEDCMD_NVMECMDFLAGS_CMDSET_MASK (0x3f) 1044 + #define MPI3_DRIVER_ALLOWEDCMD_NVMECMDFLAGS_CMDSET_NVM (0x00) 1045 + union mpi3_allowed_cmd { 1046 + struct mpi3_allowed_cmd_scsi scsi; 1047 + struct mpi3_allowed_cmd_ata ata; 1048 + struct mpi3_allowed_cmd_nvme nvme; 1049 + }; 1050 + 1051 + #define MPI3_DRIVER_ALLOWEDCMD_CMDFLAGS_ADMINRAIDPD_BLOCKED (0x20) 1052 + #define MPI3_DRIVER_ALLOWEDCMD_CMDFLAGS_OOBRAIDPD_BLOCKED (0x10) 1053 + #define MPI3_DRIVER_ALLOWEDCMD_CMDFLAGS_OOBRAIDVD_BLOCKED (0x08) 1054 + #define MPI3_DRIVER_ALLOWEDCMD_CMDFLAGS_OOBADVHOSTPD_BLOCKED (0x04) 1055 + #define MPI3_DRIVER_ALLOWEDCMD_CMDFLAGS_OOBHOSTPD_BLOCKED (0x02) 1056 + #define MPI3_DRIVER_ALLOWEDCMD_CMDFLAGS_CHECKSUBCMD_ENABLED (0x01) 1057 + #ifndef MPI3_ALLOWED_CMDS_MAX 1058 + #define MPI3_ALLOWED_CMDS_MAX (1) 1059 + #endif 1060 + struct mpi3_driver_page0 { 1080 1061 struct mpi3_config_page_header header; 1081 1062 __le32 bsd_options; 1082 1063 u8 ssu_timeout; ··· 1135 1026 __le32 reserved18; 1136 1027 }; 1137 1028 1138 - #define MPI3_UEFIBSD_PAGEVERSION (0x00) 1139 - #define MPI3_UEFIBSD_BSDOPTS_REGISTRATION_MASK (0x00000003) 1140 - #define MPI3_UEFIBSD_BSDOPTS_REGISTRATION_IOC_AND_DEVS (0x00000000) 1141 - #define MPI3_UEFIBSD_BSDOPTS_REGISTRATION_IOC_ONLY (0x00000001) 1142 - #define MPI3_UEFIBSD_BSDOPTS_REGISTRATION_NONE (0x00000002) 1143 - #define MPI3_UEFIBSD_BSDOPTS_DIS_HII_CONFIG_UTIL (0x00000004) 1144 - #define MPI3_UEFIBSD_BSDOPTS_EN_ADV_ADAPTER_CONFIG (0x00000008) 1029 + #define MPI3_DRIVER0_PAGEVERSION (0x00) 1030 + #define MPI3_DRIVER0_BSDOPTS_REGISTRATION_MASK (0x00000003) 1031 + #define MPI3_DRIVER0_BSDOPTS_REGISTRATION_IOC_AND_DEVS (0x00000000) 1032 + #define MPI3_DRIVER0_BSDOPTS_REGISTRATION_IOC_ONLY (0x00000001) 1033 + #define MPI3_DRIVER0_BSDOPTS_DIS_HII_CONFIG_UTIL (0x00000004) 1034 + #define MPI3_DRIVER0_BSDOPTS_EN_ADV_ADAPTER_CONFIG (0x00000008) 1035 + struct mpi3_driver_page1 { 1036 + struct mpi3_config_page_header header; 1037 + __le32 flags; 1038 + __le32 reserved0c; 1039 + __le16 host_diag_trace_max_size; 1040 + __le16 host_diag_trace_min_size; 1041 + __le16 host_diag_trace_decrement_size; 1042 + __le16 reserved16; 1043 + __le16 host_diag_fw_max_size; 1044 + __le16 host_diag_fw_min_size; 1045 + __le16 host_diag_fw_decrement_size; 1046 + __le16 reserved1e; 1047 + __le16 host_diag_driver_max_size; 1048 + __le16 host_diag_driver_min_size; 1049 + __le16 host_diag_driver_decrement_size; 1050 + __le16 reserved26; 1051 + }; 1052 + 1053 + #define MPI3_DRIVER1_PAGEVERSION (0x00) 1054 + #ifndef MPI3_DRIVER2_TRIGGER_MAX 1055 + #define MPI3_DRIVER2_TRIGGER_MAX (1) 1056 + #endif 1057 + struct mpi3_driver2_trigger_event { 1058 + u8 type; 1059 + u8 flags; 1060 + u8 reserved02; 1061 + u8 event; 1062 + __le32 reserved04[3]; 1063 + }; 1064 + 1065 + struct mpi3_driver2_trigger_scsi_sense { 1066 + u8 type; 1067 + u8 flags; 1068 + __le16 reserved02; 1069 + u8 ascq; 1070 + u8 asc; 1071 + u8 sense_key; 1072 + u8 reserved07; 1073 + __le32 reserved08[2]; 1074 + }; 1075 + 1076 + #define MPI3_DRIVER2_TRIGGER_SCSI_SENSE_ASCQ_MATCH_ALL (0xff) 1077 + #define MPI3_DRIVER2_TRIGGER_SCSI_SENSE_ASC_MATCH_ALL (0xff) 1078 + #define MPI3_DRIVER2_TRIGGER_SCSI_SENSE_SENSE_KEY_MATCH_ALL (0xff) 1079 + struct mpi3_driver2_trigger_reply { 1080 + u8 type; 1081 + u8 flags; 1082 + __le16 ioc_status; 1083 + __le32 ioc_log_info; 1084 + __le32 ioc_log_info_mask; 1085 + __le32 reserved0c; 1086 + }; 1087 + 1088 + #define MPI3_DRIVER2_TRIGGER_REPLY_IOCSTATUS_MATCH_ALL (0xffff) 1089 + union mpi3_driver2_trigger_element { 1090 + struct mpi3_driver2_trigger_event event; 1091 + struct mpi3_driver2_trigger_scsi_sense scsi_sense; 1092 + struct mpi3_driver2_trigger_reply reply; 1093 + }; 1094 + 1095 + #define MPI3_DRIVER2_TRIGGER_TYPE_EVENT (0x00) 1096 + #define MPI3_DRIVER2_TRIGGER_TYPE_SCSI_SENSE (0x01) 1097 + #define MPI3_DRIVER2_TRIGGER_TYPE_REPLY (0x02) 1098 + #define MPI3_DRIVER2_TRIGGER_FLAGS_DIAG_TRACE_RELEASE (0x02) 1099 + #define MPI3_DRIVER2_TRIGGER_FLAGS_DIAG_FW_RELEASE (0x01) 1100 + struct mpi3_driver_page2 { 1101 + struct mpi3_config_page_header header; 1102 + __le64 master_trigger; 1103 + __le32 reserved10[3]; 1104 + u8 num_triggers; 1105 + u8 reserved1d[3]; 1106 + union mpi3_driver2_trigger_element trigger[MPI3_DRIVER2_TRIGGER_MAX]; 1107 + }; 1108 + 1109 + #define MPI3_DRIVER2_PAGEVERSION (0x00) 1110 + #define MPI3_DRIVER2_MASTERTRIGGER_DIAG_TRACE_RELEASE (0x8000000000000000ULL) 1111 + #define MPI3_DRIVER2_MASTERTRIGGER_DIAG_FW_RELEASE (0x4000000000000000ULL) 1112 + #define MPI3_DRIVER2_MASTERTRIGGER_SNAPDUMP (0x2000000000000000ULL) 1113 + #define MPI3_DRIVER2_MASTERTRIGGER_DEVICE_REMOVAL_ENABLED (0x0000000000000004ULL) 1114 + #define MPI3_DRIVER2_MASTERTRIGGER_TASK_MANAGEMENT_ENABLED (0x0000000000000002ULL) 1115 + struct mpi3_driver_page10 { 1116 + struct mpi3_config_page_header header; 1117 + __le16 flags; 1118 + __le16 reserved0a; 1119 + u8 num_allowed_commands; 1120 + u8 reserved0d[3]; 1121 + union mpi3_allowed_cmd allowed_command[MPI3_ALLOWED_CMDS_MAX]; 1122 + }; 1123 + 1124 + #define MPI3_DRIVER10_PAGEVERSION (0x00) 1125 + struct mpi3_driver_page20 { 1126 + struct mpi3_config_page_header header; 1127 + __le16 flags; 1128 + __le16 reserved0a; 1129 + u8 num_allowed_commands; 1130 + u8 reserved0d[3]; 1131 + union mpi3_allowed_cmd allowed_command[MPI3_ALLOWED_CMDS_MAX]; 1132 + }; 1133 + 1134 + #define MPI3_DRIVER20_PAGEVERSION (0x00) 1135 + struct mpi3_driver_page30 { 1136 + struct mpi3_config_page_header header; 1137 + __le16 flags; 1138 + __le16 reserved0a; 1139 + u8 num_allowed_commands; 1140 + u8 reserved0d[3]; 1141 + union mpi3_allowed_cmd allowed_command[MPI3_ALLOWED_CMDS_MAX]; 1142 + }; 1143 + 1144 + #define MPI3_DRIVER30_PAGEVERSION (0x00) 1145 1145 union mpi3_security_mac { 1146 1146 __le32 dword[16]; 1147 1147 __le16 word[32]; ··· 1320 1102 #define MPI3_SECURITY1_KEY_RECORD_CONSUMER_NOT_VALID (0x00) 1321 1103 #define MPI3_SECURITY1_KEY_RECORD_CONSUMER_SAFESTORE (0x01) 1322 1104 #define MPI3_SECURITY1_KEY_RECORD_CONSUMER_CERT_CHAIN (0x02) 1323 - #define MPI3_SECURITY1_KEY_RECORD_CONSUMER_AUTH_DEV_KEY (0x03) 1105 + #define MPI3_SECURITY1_KEY_RECORD_CONSUMER_DEVICE_KEY (0x03) 1324 1106 #define MPI3_SECURITY1_KEY_RECORD_CONSUMER_CACHE_OFFLOAD (0x04) 1325 1107 struct mpi3_security_page1 { 1326 1108 struct mpi3_config_page_header header; ··· 1355 1137 struct mpi3_config_page_header header; 1356 1138 __le32 reserved08; 1357 1139 u8 num_phys; 1358 - u8 reserved0d[3]; 1140 + u8 init_status; 1141 + __le16 reserved0e; 1359 1142 struct mpi3_sas_io_unit0_phy_data phy_data[MPI3_SAS_IO_UNIT0_PHY_MAX]; 1360 1143 }; 1361 1144 1362 - #define MPI3_SASIOUNIT0_PAGEVERSION (0x00) 1363 - #define MPI3_SASIOUNIT0_PORTFLAGS_DISC_IN_PROGRESS (0x08) 1364 - #define MPI3_SASIOUNIT0_PORTFLAGS_AUTO_PORT_CONFIG (0x01) 1365 - #define MPI3_SASIOUNIT0_PHYFLAGS_INIT_PERSIST_CONNECT (0x40) 1366 - #define MPI3_SASIOUNIT0_PHYFLAGS_TARG_PERSIST_CONNECT (0x20) 1367 - #define MPI3_SASIOUNIT0_PHYFLAGS_PHY_DISABLED (0x08) 1145 + #define MPI3_SASIOUNIT0_PAGEVERSION (0x00) 1146 + #define MPI3_SASIOUNIT0_INITSTATUS_NO_ERRORS (0x00) 1147 + #define MPI3_SASIOUNIT0_INITSTATUS_NEEDS_INITIALIZATION (0x01) 1148 + #define MPI3_SASIOUNIT0_INITSTATUS_NO_TARGETS_ALLOCATED (0x02) 1149 + #define MPI3_SASIOUNIT0_INITSTATUS_BAD_NUM_PHYS (0x04) 1150 + #define MPI3_SASIOUNIT0_INITSTATUS_UNSUPPORTED_CONFIG (0x05) 1151 + #define MPI3_SASIOUNIT0_INITSTATUS_HOST_PHYS_ENABLED (0x06) 1152 + #define MPI3_SASIOUNIT0_INITSTATUS_PRODUCT_SPECIFIC_MIN (0xf0) 1153 + #define MPI3_SASIOUNIT0_INITSTATUS_PRODUCT_SPECIFIC_MAX (0xff) 1154 + #define MPI3_SASIOUNIT0_PORTFLAGS_DISC_IN_PROGRESS (0x08) 1155 + #define MPI3_SASIOUNIT0_PORTFLAGS_AUTO_PORT_CONFIG_MASK (0x03) 1156 + #define MPI3_SASIOUNIT0_PORTFLAGS_AUTO_PORT_CONFIG_IOUNIT1 (0x00) 1157 + #define MPI3_SASIOUNIT0_PORTFLAGS_AUTO_PORT_CONFIG_DYNAMIC (0x01) 1158 + #define MPI3_SASIOUNIT0_PORTFLAGS_AUTO_PORT_CONFIG_BACKPLANE (0x02) 1159 + #define MPI3_SASIOUNIT0_PHYFLAGS_INIT_PERSIST_CONNECT (0x40) 1160 + #define MPI3_SASIOUNIT0_PHYFLAGS_TARG_PERSIST_CONNECT (0x20) 1161 + #define MPI3_SASIOUNIT0_PHYFLAGS_PHY_DISABLED (0x08) 1162 + #define MPI3_SASIOUNIT0_PHYFLAGS_VIRTUAL_PHY (0x02) 1163 + #define MPI3_SASIOUNIT0_PHYFLAGS_HOST_PHY (0x01) 1368 1164 struct mpi3_sas_io_unit1_phy_data { 1369 1165 u8 io_unit_port; 1370 1166 u8 port_flags; ··· 1575 1343 #define MPI3_SASEXPANDER1_DISCINFO_BAD_PHY_DISABLED (0x04) 1576 1344 #define MPI3_SASEXPANDER1_DISCINFO_LINK_STATUS_CHANGE (0x02) 1577 1345 #define MPI3_SASEXPANDER1_DISCINFO_NO_ROUTING_ENTRIES (0x01) 1346 + #ifndef MPI3_SASEXPANDER2_MAX_NUM_PHYS 1347 + #define MPI3_SASEXPANDER2_MAX_NUM_PHYS (1) 1348 + #endif 1349 + struct mpi3_sasexpander2_phy_element { 1350 + u8 link_change_count; 1351 + u8 reserved01; 1352 + __le16 rate_change_count; 1353 + __le32 reserved04; 1354 + }; 1355 + 1356 + struct mpi3_sas_expander_page2 { 1357 + struct mpi3_config_page_header header; 1358 + u8 num_phys; 1359 + u8 reserved09; 1360 + __le16 dev_handle; 1361 + __le32 reserved0c; 1362 + struct mpi3_sasexpander2_phy_element phy[MPI3_SASEXPANDER2_MAX_NUM_PHYS]; 1363 + }; 1364 + 1365 + #define MPI3_SASEXPANDER2_PAGEVERSION (0x00) 1578 1366 struct mpi3_sas_port_page0 { 1579 1367 struct mpi3_config_page_header header; 1580 1368 u8 port_number; ··· 1762 1510 #define MPI3_PCIE_NEG_LINK_RATE_8_0 (0x04) 1763 1511 #define MPI3_PCIE_NEG_LINK_RATE_16_0 (0x05) 1764 1512 #define MPI3_PCIE_NEG_LINK_RATE_32_0 (0x06) 1513 + #define MPI3_PCIE_ASPM_ENABLE_NONE (0x0) 1514 + #define MPI3_PCIE_ASPM_ENABLE_L0S (0x1) 1515 + #define MPI3_PCIE_ASPM_ENABLE_L1 (0x2) 1516 + #define MPI3_PCIE_ASPM_ENABLE_L0S_L1 (0x3) 1517 + #define MPI3_PCIE_ASPM_SUPPORT_NONE (0x0) 1518 + #define MPI3_PCIE_ASPM_SUPPORT_L0S (0x1) 1519 + #define MPI3_PCIE_ASPM_SUPPORT_L1 (0x2) 1520 + #define MPI3_PCIE_ASPM_SUPPORT_L0S_L1 (0x3) 1765 1521 struct mpi3_pcie_io_unit0_phy_data { 1766 1522 u8 link; 1767 1523 u8 link_flags; ··· 1800 1540 __le32 reserved08; 1801 1541 u8 num_phys; 1802 1542 u8 init_status; 1803 - __le16 reserved0e; 1543 + u8 aspm; 1544 + u8 reserved0f; 1804 1545 struct mpi3_pcie_io_unit0_phy_data phy_data[MPI3_PCIE_IO_UNIT0_PHY_MAX]; 1805 1546 }; 1806 1547 ··· 1817 1556 #define MPI3_PCIEIOUNIT0_INITSTATUS_BAD_CLOCKING_MODE (0x08) 1818 1557 #define MPI3_PCIEIOUNIT0_INITSTATUS_PROD_SPEC_START (0xf0) 1819 1558 #define MPI3_PCIEIOUNIT0_INITSTATUS_PROD_SPEC_END (0xff) 1559 + #define MPI3_PCIEIOUNIT0_ASPM_SWITCH_STATES_MASK (0xc0) 1560 + #define MPI3_PCIEIOUNIT0_ASPM_SWITCH_STATES_SHIFT (6) 1561 + #define MPI3_PCIEIOUNIT0_ASPM_DIRECT_STATES_MASK (0x30) 1562 + #define MPI3_PCIEIOUNIT0_ASPM_DIRECT_STATES_SHIFT (4) 1563 + #define MPI3_PCIEIOUNIT0_ASPM_SWITCH_SUPPORT_MASK (0x0c) 1564 + #define MPI3_PCIEIOUNIT0_ASPM_SWITCH_SUPPORT_SHIFT (2) 1565 + #define MPI3_PCIEIOUNIT0_ASPM_DIRECT_SUPPORT_MASK (0x03) 1566 + #define MPI3_PCIEIOUNIT0_ASPM_DIRECT_SUPPORT_SHIFT (0) 1820 1567 struct mpi3_pcie_io_unit1_phy_data { 1821 1568 u8 link; 1822 1569 u8 link_flags; ··· 1838 1569 #define MPI3_PCIEIOUNIT1_LINKFLAGS_PCIE_CLK_MODE_DIS_SEPARATE_REFCLK (0x00) 1839 1570 #define MPI3_PCIEIOUNIT1_LINKFLAGS_PCIE_CLK_MODE_EN_SRIS (0x01) 1840 1571 #define MPI3_PCIEIOUNIT1_LINKFLAGS_PCIE_CLK_MODE_EN_SRNS (0x02) 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) 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) 1849 1580 #ifndef MPI3_PCIE_IO_UNIT1_PHY_MAX 1850 - #define MPI3_PCIE_IO_UNIT1_PHY_MAX (1) 1581 + #define MPI3_PCIE_IO_UNIT1_PHY_MAX (1) 1851 1582 #endif 1852 1583 struct mpi3_pcie_io_unit_page1 { 1853 1584 struct mpi3_config_page_header header; ··· 1855 1586 __le32 reserved0c; 1856 1587 u8 num_phys; 1857 1588 u8 reserved11; 1858 - __le16 reserved12; 1589 + u8 aspm; 1590 + u8 reserved13; 1859 1591 struct mpi3_pcie_io_unit1_phy_data phy_data[MPI3_PCIE_IO_UNIT1_PHY_MAX]; 1860 1592 }; 1861 1593 1862 - #define MPI3_PCIEIOUNIT1_PAGEVERSION (0x00) 1594 + #define MPI3_PCIEIOUNIT1_PAGEVERSION (0x00) 1595 + #define MPI3_PCIEIOUNIT1_CONTROL_FLAGS_LINK_OVERRIDE_DISABLE (0x80) 1596 + #define MPI3_PCIEIOUNIT1_CONTROL_FLAGS_CLOCK_OVERRIDE_DISABLE (0x40) 1597 + #define MPI3_PCIEIOUNIT1_CONTROL_FLAGS_CLOCK_OVERRIDE_MODE_MASK (0x30) 1598 + #define MPI3_PCIEIOUNIT1_CONTROL_FLAGS_CLOCK_OVERRIDE_MODE_SHIFT (4) 1599 + #define MPI3_PCIEIOUNIT1_CONTROL_FLAGS_CLOCK_OVERRIDE_MODE_SRIS_SRNS_DISABLED (0x00) 1600 + #define MPI3_PCIEIOUNIT1_CONTROL_FLAGS_CLOCK_OVERRIDE_MODE_SRIS_ENABLED (0x10) 1601 + #define MPI3_PCIEIOUNIT1_CONTROL_FLAGS_CLOCK_OVERRIDE_MODE_SRNS_ENABLED (0x20) 1602 + #define MPI3_PCIEIOUNIT1_CONTROL_FLAGS_LINK_RATE_OVERRIDE_MASK (0x0f) 1603 + #define MPI3_PCIEIOUNIT1_CONTROL_FLAGS_LINK_RATE_OVERRIDE_MAX_2_5 (0x02) 1604 + #define MPI3_PCIEIOUNIT1_CONTROL_FLAGS_LINK_RATE_OVERRIDE_MAX_5_0 (0x03) 1605 + #define MPI3_PCIEIOUNIT1_CONTROL_FLAGS_LINK_RATE_OVERRIDE_MAX_8_0 (0x04) 1606 + #define MPI3_PCIEIOUNIT1_CONTROL_FLAGS_LINK_RATE_OVERRIDE_MAX_16_0 (0x05) 1607 + #define MPI3_PCIEIOUNIT1_CONTROL_FLAGS_LINK_RATE_OVERRIDE_MAX_32_0 (0x06) 1608 + #define MPI3_PCIEIOUNIT1_ASPM_SWITCH_MASK (0x0c) 1609 + #define MPI3_PCIEIOUNIT1_ASPM_SWITCH_SHIFT (2) 1610 + #define MPI3_PCIEIOUNIT1_ASPM_DIRECT_MASK (0x03) 1611 + #define MPI3_PCIEIOUNIT1_ASPM_DIRECT_SHIFT (0) 1863 1612 struct mpi3_pcie_io_unit_page2 { 1864 1613 struct mpi3_config_page_header header; 1865 - __le16 nv_me_max_queue_depth; 1866 - __le16 reserved0a; 1867 - u8 nv_me_abort_to; 1614 + __le16 nvme_max_q_dx1; 1615 + __le16 nvme_max_q_dx2; 1616 + u8 nvme_abort_to; 1868 1617 u8 reserved0d; 1869 - __le16 reserved0e; 1618 + __le16 nvme_max_q_dx4; 1870 1619 }; 1871 1620 1872 1621 #define MPI3_PCIEIOUNIT2_PAGEVERSION (0x00) 1622 + #define MPI3_PCIEIOUNIT3_ERROR_RECEIVER_ERROR (0) 1623 + #define MPI3_PCIEIOUNIT3_ERROR_RECOVERY (1) 1624 + #define MPI3_PCIEIOUNIT3_ERROR_CORRECTABLE_ERROR_MSG (2) 1625 + #define MPI3_PCIEIOUNIT3_ERROR_BAD_DLLP (3) 1626 + #define MPI3_PCIEIOUNIT3_ERROR_BAD_TLP (4) 1627 + #define MPI3_PCIEIOUNIT3_NUM_ERROR_INDEX (5) 1628 + struct mpi3_pcie_io_unit3_error { 1629 + __le16 threshold_count; 1630 + __le16 reserved02; 1631 + }; 1632 + 1633 + struct mpi3_pcie_io_unit_page3 { 1634 + struct mpi3_config_page_header header; 1635 + u8 threshold_window; 1636 + u8 threshold_action; 1637 + u8 escalation_count; 1638 + u8 escalation_action; 1639 + u8 num_errors; 1640 + u8 reserved0d[3]; 1641 + struct mpi3_pcie_io_unit3_error error[MPI3_PCIEIOUNIT3_NUM_ERROR_INDEX]; 1642 + }; 1643 + 1644 + #define MPI3_PCIEIOUNIT3_PAGEVERSION (0x00) 1645 + #define MPI3_PCIEIOUNIT3_ACTION_NO_ACTION (0x00) 1646 + #define MPI3_PCIEIOUNIT3_ACTION_HOT_RESET (0x01) 1647 + #define MPI3_PCIEIOUNIT3_ACTION_REDUCE_LINK_RATE_ONLY (0x02) 1648 + #define MPI3_PCIEIOUNIT3_ACTION_REDUCE_LINK_RATE_NO_ACCESS (0x03) 1873 1649 struct mpi3_pcie_switch_page0 { 1874 1650 struct mpi3_config_page_header header; 1875 1651 u8 io_unit_port; ··· 1923 1609 __le16 dev_handle; 1924 1610 __le16 parent_dev_handle; 1925 1611 u8 num_ports; 1926 - u8 pc_ie_level; 1612 + u8 pcie_level; 1927 1613 __le16 reserved12; 1928 1614 __le32 reserved14; 1929 1615 __le32 reserved18; ··· 1937 1623 struct mpi3_pcie_switch_page1 { 1938 1624 struct mpi3_config_page_header header; 1939 1625 u8 io_unit_port; 1940 - u8 reserved09[3]; 1626 + u8 flags; 1627 + __le16 reserved0a; 1941 1628 u8 num_ports; 1942 1629 u8 port_num; 1943 1630 __le16 attached_dev_handle; ··· 1951 1636 }; 1952 1637 1953 1638 #define MPI3_PCIESWITCH1_PAGEVERSION (0x00) 1639 + #define MPI3_PCIESWITCH1_FLAGS_ASPMSTATE_MASK (0x0c) 1640 + #define MPI3_PCIESWITCH1_FLAGS_ASPMSTATE_SHIFT (2) 1641 + #define MPI3_PCIESWITCH1_FLAGS_ASPMSUPPORT_MASK (0x03) 1642 + #define MPI3_PCIESWITCH1_FLAGS_ASPMSUPPORT_SHIFT (0) 1643 + #ifndef MPI3_PCIESWITCH2_MAX_NUM_PORTS 1644 + #define MPI3_PCIESWITCH2_MAX_NUM_PORTS (1) 1645 + #endif 1646 + struct mpi3_pcieswitch2_port_element { 1647 + __le16 link_change_count; 1648 + __le16 rate_change_count; 1649 + __le32 reserved04; 1650 + }; 1651 + 1652 + struct mpi3_pcie_switch_page2 { 1653 + struct mpi3_config_page_header header; 1654 + u8 num_ports; 1655 + u8 reserved09; 1656 + __le16 dev_handle; 1657 + __le32 reserved0c; 1658 + struct mpi3_pcieswitch2_port_element port[MPI3_PCIESWITCH2_MAX_NUM_PORTS]; 1659 + }; 1660 + 1661 + #define MPI3_PCIESWITCH2_PAGEVERSION (0x00) 1954 1662 struct mpi3_pcie_link_page0 { 1955 1663 struct mpi3_config_page_header header; 1956 1664 u8 link; 1957 1665 u8 reserved09[3]; 1958 - __le32 correctable_error_count; 1959 - __le16 n_fatal_error_count; 1960 - __le16 reserved12; 1961 - __le16 fatal_error_count; 1962 - __le16 reserved16; 1666 + __le32 reserved0c; 1667 + __le32 receiver_error_count; 1668 + __le32 recovery_count; 1669 + __le32 corr_error_msg_count; 1670 + __le32 non_fatal_error_msg_count; 1671 + __le32 fatal_error_msg_count; 1672 + __le32 non_fatal_error_count; 1673 + __le32 fatal_error_count; 1674 + __le32 bad_dllp_count; 1675 + __le32 bad_tlp_count; 1963 1676 }; 1964 1677 1965 1678 #define MPI3_PCIELINK0_PAGEVERSION (0x00) ··· 1997 1654 __le16 flags; 1998 1655 __le16 enclosure_handle; 1999 1656 __le16 num_slots; 2000 - __le16 start_slot; 1657 + __le16 reserved16; 2001 1658 u8 io_unit_port; 2002 1659 u8 enclosure_level; 2003 1660 __le16 sep_dev_handle; 2004 - __le32 reserved1c; 1661 + u8 chassis_slot; 1662 + u8 reserved1d[3]; 2005 1663 }; 2006 1664 2007 1665 #define MPI3_ENCLOSURE0_PAGEVERSION (0x00) ··· 2010 1666 #define MPI3_ENCLS0_FLAGS_ENCL_TYPE_VIRTUAL (0x0000) 2011 1667 #define MPI3_ENCLS0_FLAGS_ENCL_TYPE_SAS (0x4000) 2012 1668 #define MPI3_ENCLS0_FLAGS_ENCL_TYPE_PCIE (0x8000) 1669 + #define MPI3_ENCLS0_FLAGS_CHASSIS_SLOT_VALID (0x0020) 2013 1670 #define MPI3_ENCLS0_FLAGS_ENCL_DEV_PRESENT_MASK (0x0010) 2014 1671 #define MPI3_ENCLS0_FLAGS_ENCL_DEV_NOT_FOUND (0x0000) 2015 1672 #define MPI3_ENCLS0_FLAGS_ENCL_DEV_PRESENT (0x0010) ··· 2031 1686 u8 zone_group; 2032 1687 }; 2033 1688 1689 + #define MPI3_DEVICE0_SASSATA_FLAGS_WRITE_SAME_UNMAP_NCQ (0x0400) 2034 1690 #define MPI3_DEVICE0_SASSATA_FLAGS_SLUMBER_CAP (0x0200) 2035 1691 #define MPI3_DEVICE0_SASSATA_FLAGS_PARTIAL_CAP (0x0100) 2036 1692 #define MPI3_DEVICE0_SASSATA_FLAGS_ASYNC_NOTIFY (0x0080) ··· 2053 1707 __le32 maximum_data_transfer_size; 2054 1708 __le32 capabilities; 2055 1709 __le16 noiob; 2056 - u8 nv_me_abort_to; 1710 + u8 nvme_abort_to; 2057 1711 u8 page_size; 2058 1712 __le16 shutdown_latency; 2059 - __le16 reserved16; 1713 + u8 recovery_info; 1714 + u8 reserved17; 2060 1715 }; 2061 1716 2062 1717 #define MPI3_DEVICE0_PCIE_LINK_RATE_32_0_SUPP (0x10) ··· 2065 1718 #define MPI3_DEVICE0_PCIE_LINK_RATE_8_0_SUPP (0x04) 2066 1719 #define MPI3_DEVICE0_PCIE_LINK_RATE_5_0_SUPP (0x02) 2067 1720 #define MPI3_DEVICE0_PCIE_LINK_RATE_2_5_SUPP (0x01) 2068 - #define MPI3_DEVICE0_PCIE_DEVICE_INFO_TYPE_MASK (0x0003) 1721 + #define MPI3_DEVICE0_PCIE_DEVICE_INFO_TYPE_MASK (0x0007) 2069 1722 #define MPI3_DEVICE0_PCIE_DEVICE_INFO_TYPE_NO_DEVICE (0x0000) 2070 1723 #define MPI3_DEVICE0_PCIE_DEVICE_INFO_TYPE_NVME_DEVICE (0x0001) 2071 1724 #define MPI3_DEVICE0_PCIE_DEVICE_INFO_TYPE_SWITCH_DEVICE (0x0002) 2072 1725 #define MPI3_DEVICE0_PCIE_DEVICE_INFO_TYPE_SCSI_DEVICE (0x0003) 1726 + #define MPI3_DEVICE0_PCIE_DEVICE_INFO_ASPM_MASK (0x0030) 1727 + #define MPI3_DEVICE0_PCIE_DEVICE_INFO_ASPM_SHIFT (4) 1728 + #define MPI3_DEVICE0_PCIE_DEVICE_INFO_PITYPE_MASK (0x00c0) 1729 + #define MPI3_DEVICE0_PCIE_DEVICE_INFO_PITYPE_SHIFT (6) 1730 + #define MPI3_DEVICE0_PCIE_DEVICE_INFO_PITYPE_0 (0x0000) 1731 + #define MPI3_DEVICE0_PCIE_DEVICE_INFO_PITYPE_1 (0x0040) 1732 + #define MPI3_DEVICE0_PCIE_DEVICE_INFO_PITYPE_2 (0x0080) 1733 + #define MPI3_DEVICE0_PCIE_DEVICE_INFO_PITYPE_3 (0x00c0) 1734 + #define MPI3_DEVICE0_PCIE_CAP_SGL_EXTRA_LENGTH_SUPPORTED (0x00000020) 2073 1735 #define MPI3_DEVICE0_PCIE_CAP_METADATA_SEPARATED (0x00000010) 2074 1736 #define MPI3_DEVICE0_PCIE_CAP_SGL_DWORD_ALIGN_REQUIRED (0x00000008) 2075 - #define MPI3_DEVICE0_PCIE_CAP_NVME_SGL_ENABLED (0x00000004) 1737 + #define MPI3_DEVICE0_PCIE_CAP_SGL_FORMAT_SGL (0x00000004) 1738 + #define MPI3_DEVICE0_PCIE_CAP_SGL_FORMAT_PRP (0x00000000) 2076 1739 #define MPI3_DEVICE0_PCIE_CAP_BIT_BUCKET_SGL_SUPP (0x00000002) 2077 1740 #define MPI3_DEVICE0_PCIE_CAP_SGL_SUPP (0x00000001) 1741 + #define MPI3_DEVICE0_PCIE_CAP_ASPM_MASK (0x000000c0) 1742 + #define MPI3_DEVICE0_PCIE_CAP_ASPM_SHIFT (6) 1743 + #define MPI3_DEVICE0_PCIE_RECOVER_METHOD_MASK (0xe0) 1744 + #define MPI3_DEVICE0_PCIE_RECOVER_METHOD_NS_MGMT (0x00) 1745 + #define MPI3_DEVICE0_PCIE_RECOVER_METHOD_FORMAT (0x20) 1746 + #define MPI3_DEVICE0_PCIE_RECOVER_REASON_MASK (0x1f) 1747 + #define MPI3_DEVICE0_PCIE_RECOVER_REASON_NO_NS (0x00) 1748 + #define MPI3_DEVICE0_PCIE_RECOVER_REASON_NO_NSID_1 (0x01) 1749 + #define MPI3_DEVICE0_PCIE_RECOVER_REASON_TOO_MANY_NS (0x02) 1750 + #define MPI3_DEVICE0_PCIE_RECOVER_REASON_PROTECTION (0x03) 1751 + #define MPI3_DEVICE0_PCIE_RECOVER_REASON_METADATA_SZ (0x04) 1752 + #define MPI3_DEVICE0_PCIE_RECOVER_REASON_LBA_DATA_SZ (0x05) 2078 1753 struct mpi3_device0_vd_format { 2079 1754 u8 vd_state; 2080 1755 u8 raid_level; ··· 2152 1783 }; 2153 1784 2154 1785 #define MPI3_DEVICE0_PAGEVERSION (0x00) 1786 + #define MPI3_DEVICE0_PARENT_INVALID (0xffff) 1787 + #define MPI3_DEVICE0_ENCLOSURE_HANDLE_NO_ENCLOSURE (0x0000) 2155 1788 #define MPI3_DEVICE0_WWID_INVALID (0xffffffffffffffff) 2156 1789 #define MPI3_DEVICE0_PERSISTENTID_INVALID (0xffff) 2157 1790 #define MPI3_DEVICE0_IOUNITPORT_INVALID (0xff) ··· 2163 1792 #define MPI3_DEVICE0_ASTATUS_DEVICE_BLOCKED (0x03) 2164 1793 #define MPI3_DEVICE0_ASTATUS_UNAUTHORIZED (0x04) 2165 1794 #define MPI3_DEVICE0_ASTATUS_DEVICE_MISSING_DELAY (0x05) 1795 + #define MPI3_DEVICE0_ASTATUS_PREPARE (0x06) 1796 + #define MPI3_DEVICE0_ASTATUS_SAFE_MODE (0x07) 1797 + #define MPI3_DEVICE0_ASTATUS_GENERIC_MAX (0x0f) 2166 1798 #define MPI3_DEVICE0_ASTATUS_SAS_UNKNOWN (0x10) 2167 1799 #define MPI3_DEVICE0_ASTATUS_ROUTE_NOT_ADDRESSABLE (0x11) 2168 1800 #define MPI3_DEVICE0_ASTATUS_SMP_ERROR_NOT_ADDRESSABLE (0x12) 1801 + #define MPI3_DEVICE0_ASTATUS_SAS_MAX (0x1f) 2169 1802 #define MPI3_DEVICE0_ASTATUS_SIF_UNKNOWN (0x20) 2170 1803 #define MPI3_DEVICE0_ASTATUS_SIF_AFFILIATION_CONFLICT (0x21) 2171 1804 #define MPI3_DEVICE0_ASTATUS_SIF_DIAG (0x22) ··· 2185 1810 #define MPI3_DEVICE0_ASTATUS_PCIE_MEM_SPACE_ACCESS (0x31) 2186 1811 #define MPI3_DEVICE0_ASTATUS_PCIE_UNSUPPORTED (0x32) 2187 1812 #define MPI3_DEVICE0_ASTATUS_PCIE_MSIX_REQUIRED (0x33) 1813 + #define MPI3_DEVICE0_ASTATUS_PCIE_ECRC_REQUIRED (0x34) 1814 + #define MPI3_DEVICE0_ASTATUS_PCIE_MAX (0x3f) 2188 1815 #define MPI3_DEVICE0_ASTATUS_NVME_UNKNOWN (0x40) 2189 1816 #define MPI3_DEVICE0_ASTATUS_NVME_READY_TIMEOUT (0x41) 2190 1817 #define MPI3_DEVICE0_ASTATUS_NVME_DEVCFG_UNSUPPORTED (0x42) ··· 2197 1820 #define MPI3_DEVICE0_ASTATUS_NVME_GET_FEATURE_STAT_FAILED (0x47) 2198 1821 #define MPI3_DEVICE0_ASTATUS_NVME_IDLE_TIMEOUT (0x48) 2199 1822 #define MPI3_DEVICE0_ASTATUS_NVME_CTRL_FAILURE_STATUS (0x49) 2200 - #define MPI3_DEVICE0_ASTATUS_VD_UNKNOWN (0x50) 1823 + #define MPI3_DEVICE0_ASTATUS_NVME_INSUFFICIENT_POWER (0x4a) 1824 + #define MPI3_DEVICE0_ASTATUS_NVME_DOORBELL_STRIDE (0x4b) 1825 + #define MPI3_DEVICE0_ASTATUS_NVME_MEM_PAGE_MIN_SIZE (0x4c) 1826 + #define MPI3_DEVICE0_ASTATUS_NVME_MEMORY_ALLOCATION (0x4d) 1827 + #define MPI3_DEVICE0_ASTATUS_NVME_COMPLETION_TIME (0x4e) 1828 + #define MPI3_DEVICE0_ASTATUS_NVME_BAR (0x4f) 1829 + #define MPI3_DEVICE0_ASTATUS_NVME_NS_DESCRIPTOR (0x50) 1830 + #define MPI3_DEVICE0_ASTATUS_NVME_INCOMPATIBLE_SETTINGS (0x51) 1831 + #define MPI3_DEVICE0_ASTATUS_NVME_MAX (0x5f) 1832 + #define MPI3_DEVICE0_ASTATUS_VD_UNKNOWN (0x80) 1833 + #define MPI3_DEVICE0_ASTATUS_VD_MAX (0x8f) 2201 1834 #define MPI3_DEVICE0_FLAGS_CONTROLLER_DEV_HANDLE (0x0080) 2202 1835 #define MPI3_DEVICE0_FLAGS_HIDDEN (0x0008) 2203 1836 #define MPI3_DEVICE0_FLAGS_ATT_METHOD_MASK (0x0006) ··· 2257 1870 struct mpi3_config_page_header header; 2258 1871 __le16 dev_handle; 2259 1872 __le16 reserved0a; 2260 - __le32 reserved0c[12]; 1873 + __le16 link_change_count; 1874 + __le16 rate_change_count; 1875 + __le16 tm_count; 1876 + __le16 reserved12; 1877 + __le32 reserved14[10]; 2261 1878 u8 reserved3c[3]; 2262 1879 u8 device_form; 2263 1880 union mpi3_device1_dev_spec_format device_specific; 2264 1881 }; 2265 1882 2266 1883 #define MPI3_DEVICE1_PAGEVERSION (0x00) 1884 + #define MPI3_DEVICE1_COUNTER_MAX (0xfffe) 1885 + #define MPI3_DEVICE1_COUNTER_INVALID (0xffff) 2267 1886 #endif
+58 -1
drivers/scsi/mpi3mr/mpi/mpi30_image.h
··· 61 61 #define MPI3_IMAGE_HEADER_SIGNATURE1_SPD (0x20445053) 62 62 #define MPI3_IMAGE_HEADER_SIGNATURE1_GAS_GAUGE (0x20534147) 63 63 #define MPI3_IMAGE_HEADER_SIGNATURE1_PBLP (0x504c4250) 64 + #define MPI3_IMAGE_HEADER_SIGNATURE1_MANIFEST (0x464e414d) 65 + #define MPI3_IMAGE_HEADER_SIGNATURE1_OEM (0x204d454f) 64 66 #define MPI3_IMAGE_HEADER_SIGNATURE2_VALUE (0x50584546) 65 67 #define MPI3_IMAGE_HEADER_FLAGS_DEVICE_KEY_BASIS_MASK (0x00000030) 66 68 #define MPI3_IMAGE_HEADER_FLAGS_DEVICE_KEY_BASIS_CDI (0x00000000) ··· 96 94 #define MPI3_IMAGE_HEADER_HASH_EXCLUSION_OFFSET (0x5c) 97 95 #define MPI3_IMAGE_HEADER_NEXT_IMAGE_HEADER_OFFSET_OFFSET (0x7c) 98 96 #define MPI3_IMAGE_HEADER_SIZE (0x100) 97 + #ifndef MPI3_CI_MANIFEST_MPI_MAX 98 + #define MPI3_CI_MANIFEST_MPI_MAX (1) 99 + #endif 100 + struct mpi3_ci_manifest_mpi_comp_image_ref { 101 + __le32 signature1; 102 + __le32 reserved04[3]; 103 + struct mpi3_comp_image_version component_image_version; 104 + __le32 component_image_version_string_offset; 105 + __le32 crc; 106 + }; 107 + 108 + struct mpi3_ci_manifest_mpi { 109 + u8 manifest_type; 110 + u8 reserved01[3]; 111 + __le32 reserved04[3]; 112 + u8 num_image_references; 113 + u8 release_level; 114 + __le16 reserved12; 115 + __le16 reserved14; 116 + __le16 flags; 117 + __le32 reserved18[2]; 118 + __le16 vendor_id; 119 + __le16 device_id; 120 + __le16 subsystem_vendor_id; 121 + __le16 subsystem_id; 122 + __le32 reserved28[2]; 123 + union mpi3_version_union package_security_version; 124 + __le32 reserved34; 125 + struct mpi3_comp_image_version package_version; 126 + __le32 package_version_string_offset; 127 + __le32 package_build_date_string_offset; 128 + __le32 package_build_time_string_offset; 129 + __le32 reserved4c; 130 + __le32 diag_authorization_identifier[16]; 131 + struct mpi3_ci_manifest_mpi_comp_image_ref component_image_ref[MPI3_CI_MANIFEST_MPI_MAX]; 132 + }; 133 + 134 + #define MPI3_CI_MANIFEST_MPI_RELEASE_LEVEL_DEV (0x00) 135 + #define MPI3_CI_MANIFEST_MPI_RELEASE_LEVEL_PREALPHA (0x10) 136 + #define MPI3_CI_MANIFEST_MPI_RELEASE_LEVEL_ALPHA (0x20) 137 + #define MPI3_CI_MANIFEST_MPI_RELEASE_LEVEL_BETA (0x30) 138 + #define MPI3_CI_MANIFEST_MPI_RELEASE_LEVEL_RC (0x40) 139 + #define MPI3_CI_MANIFEST_MPI_RELEASE_LEVEL_GCA (0x50) 140 + #define MPI3_CI_MANIFEST_MPI_RELEASE_LEVEL_POINT (0x60) 141 + #define MPI3_CI_MANIFEST_MPI_FLAGS_DIAG_AUTHORIZATION (0x01) 142 + #define MPI3_CI_MANIFEST_MPI_SUBSYSTEMID_IGNORED (0xffff) 143 + #define MPI3_CI_MANIFEST_MPI_PKG_VER_STR_OFF_UNSPECIFIED (0x00000000) 144 + #define MPI3_CI_MANIFEST_MPI_PKG_BUILD_DATE_STR_OFF_UNSPECIFIED (0x00000000) 145 + #define MPI3_CI_MANIFEST_MPI_PKG_BUILD_TIME_STR_OFF_UNSPECIFIED (0x00000000) 146 + union mpi3_ci_manifest { 147 + struct mpi3_ci_manifest_mpi mpi; 148 + __le32 dword[1]; 149 + }; 150 + 151 + #define MPI3_CI_MANIFEST_TYPE_MPI (0x00) 99 152 struct mpi3_extended_image_header { 100 153 u8 image_type; 101 154 u8 reserved01[3]; ··· 218 161 #define MPI3_HASH_ALGORITHM_SIZE_UNUSED (0x00) 219 162 #define MPI3_HASH_ALGORITHM_SIZE_SHA256 (0x01) 220 163 #define MPI3_HASH_ALGORITHM_SIZE_SHA512 (0x02) 164 + #define MPI3_HASH_ALGORITHM_SIZE_SHA384 (0x03) 221 165 #define MPI3_ENCRYPTION_ALGORITHM_UNUSED (0x00) 222 166 #define MPI3_ENCRYPTION_ALGORITHM_RSA256 (0x01) 223 167 #define MPI3_ENCRYPTION_ALGORITHM_RSA512 (0x02) ··· 236 178 u8 reserved03; 237 179 __le32 reserved04; 238 180 __le32 public_key[MPI3_PUBLIC_KEY_MAX]; 239 - __le32 encrypted_hash[MPI3_ENCRYPTED_HASH_MAX]; 240 181 }; 241 182 242 183 #ifndef MPI3_ENCRYPTED_HASH_ENTRY_MAX
+12 -3
drivers/scsi/mpi3mr/mpi/mpi30_init.h
··· 13 13 __le32 transfer_length; 14 14 }; 15 15 16 - union mpi3_scso_io_cdb_union { 16 + union mpi3_scsi_io_cdb_union { 17 17 u8 cdb32[32]; 18 18 struct mpi3_scsi_io_cdb_eedp32 eedp32; 19 19 struct mpi3_sge_common sge; ··· 32 32 __le32 skip_count; 33 33 __le32 data_length; 34 34 u8 lun[8]; 35 - union mpi3_scso_io_cdb_union cdb; 35 + union mpi3_scsi_io_cdb_union cdb; 36 36 union mpi3_sge_union sgl[4]; 37 37 }; 38 38 39 39 #define MPI3_SCSIIO_MSGFLAGS_METASGL_VALID (0x80) 40 + #define MPI3_SCSIIO_MSGFLAGS_DIVERT_TO_FIRMWARE (0x40) 40 41 #define MPI3_SCSIIO_FLAGS_LARGE_CDB (0x60000000) 41 42 #define MPI3_SCSIIO_FLAGS_CDB_16_OR_LESS (0x00000000) 42 43 #define MPI3_SCSIIO_FLAGS_CDB_GREATER_THAN_16 (0x20000000) ··· 156 155 __le32 reserved18; 157 156 }; 158 157 159 - #define MPI3_SCSITASKMGMT_RSPCODE_IO_QUEUED_ON_IOC (0x80) 158 + #define MPI3_SCSITASKMGMT_RSPCODE_TM_COMPLETE (0x00) 159 + #define MPI3_SCSITASKMGMT_RSPCODE_INVALID_FRAME (0x02) 160 + #define MPI3_SCSITASKMGMT_RSPCODE_TM_FUNCTION_NOT_SUPPORTED (0x04) 161 + #define MPI3_SCSITASKMGMT_RSPCODE_TM_FAILED (0x05) 162 + #define MPI3_SCSITASKMGMT_RSPCODE_TM_SUCCEEDED (0x08) 163 + #define MPI3_SCSITASKMGMT_RSPCODE_TM_INVALID_LUN (0x09) 164 + #define MPI3_SCSITASKMGMT_RSPCODE_TM_OVERLAPPED_TAG (0x0a) 165 + #define MPI3_SCSITASKMGMT_RSPCODE_IO_QUEUED_ON_IOC (0x80) 166 + #define MPI3_SCSITASKMGMT_RSPCODE_TM_NVME_DENIED (0x81) 160 167 #endif
+99 -29
drivers/scsi/mpi3mr/mpi/mpi30_ioc.h
··· 29 29 __le64 driver_information_address; 30 30 }; 31 31 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) 36 41 struct mpi3_driver_info_layout { 37 42 __le32 information_length; 38 43 u8 driver_signature[12]; ··· 82 77 u8 sge_modifier_shift; 83 78 u8 protocol_flags; 84 79 __le16 max_sas_initiators; 85 - __le16 max_sas_targets; 80 + __le16 reserved2a; 86 81 __le16 max_sas_expanders; 87 82 __le16 max_enclosures; 88 83 __le16 min_dev_handle; 89 84 __le16 max_dev_handle; 90 - __le16 max_pc_ie_switches; 85 + __le16 max_pcie_switches; 91 86 __le16 max_nvme; 92 - __le16 max_pds; 87 + __le16 reserved38; 93 88 __le16 max_vds; 94 89 __le16 max_host_pds; 95 - __le16 max_advanced_host_pds; 90 + __le16 max_adv_host_pds; 96 91 __le16 max_raid_pds; 97 92 __le16 max_posted_cmd_buffers; 98 93 __le32 flags; ··· 102 97 __le16 reserved4e; 103 98 __le32 diag_trace_size; 104 99 __le32 diag_fw_size; 100 + __le32 diag_driver_size; 101 + u8 max_host_pd_ns_count; 102 + u8 max_adv_host_pd_ns_count; 103 + u8 max_raidpd_ns_count; 104 + u8 reserved5f; 105 105 }; 106 106 107 - #define MPI3_IOCFACTS_CAPABILITY_ADVANCED_HOST_PD (0x00000010) 107 + #define MPI3_IOCFACTS_CAPABILITY_NON_SUPERVISOR_MASK (0x80000000) 108 + #define MPI3_IOCFACTS_CAPABILITY_SUPERVISOR_IOC (0x00000000) 109 + #define MPI3_IOCFACTS_CAPABILITY_NON_SUPERVISOR_IOC (0x10000000) 110 + #define MPI3_IOCFACTS_CAPABILITY_COMPLETE_RESET_CAPABLE (0x00000100) 111 + #define MPI3_IOCFACTS_CAPABILITY_SEG_DIAG_TRACE_ENABLED (0x00000080) 112 + #define MPI3_IOCFACTS_CAPABILITY_SEG_DIAG_FW_ENABLED (0x00000040) 113 + #define MPI3_IOCFACTS_CAPABILITY_SEG_DIAG_DRIVER_ENABLED (0x00000020) 114 + #define MPI3_IOCFACTS_CAPABILITY_ADVANCED_HOST_PD_ENABLED (0x00000010) 108 115 #define MPI3_IOCFACTS_CAPABILITY_RAID_CAPABLE (0x00000008) 109 - #define MPI3_IOCFACTS_CAPABILITY_COALESCE_CTRL_GRAN_MASK (0x00000001) 110 - #define MPI3_IOCFACTS_CAPABILITY_COALESCE_CTRL_IOC_GRAN (0x00000000) 111 - #define MPI3_IOCFACTS_CAPABILITY_COALESCE_CTRL_REPLY_Q_GRAN (0x00000001) 116 + #define MPI3_IOCFACTS_CAPABILITY_MULTIPATH_ENABLED (0x00000002) 117 + #define MPI3_IOCFACTS_CAPABILITY_COALESCE_CTRL_SUPPORTED (0x00000001) 112 118 #define MPI3_IOCFACTS_PID_TYPE_MASK (0xf000) 113 119 #define MPI3_IOCFACTS_PID_TYPE_SHIFT (12) 114 120 #define MPI3_IOCFACTS_PID_PRODUCT_MASK (0x0f00) 115 121 #define MPI3_IOCFACTS_PID_PRODUCT_SHIFT (8) 116 122 #define MPI3_IOCFACTS_PID_FAMILY_MASK (0x00ff) 117 123 #define MPI3_IOCFACTS_PID_FAMILY_SHIFT (0) 124 + #define MPI3_IOCFACTS_EXCEPT_SECURITY_REKEY (0x2000) 125 + #define MPI3_IOCFACTS_EXCEPT_SAS_DISABLED (0x1000) 118 126 #define MPI3_IOCFACTS_EXCEPT_SAFE_MODE (0x0800) 119 127 #define MPI3_IOCFACTS_EXCEPT_SECURITY_KEY_MASK (0x0700) 120 128 #define MPI3_IOCFACTS_EXCEPT_SECURITY_KEY_NONE (0x0000) 121 - #define MPI3_IOCFACTS_EXCEPT_SECURITY_KEY_LOCAL_VIA_RAID (0x0100) 122 - #define MPI3_IOCFACTS_EXCEPT_SECURITY_KEY_LOCAL_VIA_OOB (0x0200) 123 - #define MPI3_IOCFACTS_EXCEPT_SECURITY_KEY_EXT_VIA_RAID (0x0300) 124 - #define MPI3_IOCFACTS_EXCEPT_SECURITY_KEY_EXT_VIA_OOB (0x0400) 129 + #define MPI3_IOCFACTS_EXCEPT_SECURITY_KEY_LOCAL_VIA_MGMT (0x0100) 130 + #define MPI3_IOCFACTS_EXCEPT_SECURITY_KEY_EXT_VIA_MGMT (0x0200) 131 + #define MPI3_IOCFACTS_EXCEPT_SECURITY_KEY_DRIVE_EXT_VIA_MGMT (0x0300) 132 + #define MPI3_IOCFACTS_EXCEPT_SECURITY_KEY_LOCAL_VIA_OOB (0x0400) 133 + #define MPI3_IOCFACTS_EXCEPT_SECURITY_KEY_EXT_VIA_OOB (0x0500) 134 + #define MPI3_IOCFACTS_EXCEPT_SECURITY_KEY_DRIVE_EXT_VIA_OOB (0x0600) 125 135 #define MPI3_IOCFACTS_EXCEPT_PCIE_DISABLED (0x0080) 126 136 #define MPI3_IOCFACTS_EXCEPT_PARTIAL_MEMORY_FAILURE (0x0040) 127 137 #define MPI3_IOCFACTS_EXCEPT_MANUFACT_CHECKSUM_FAIL (0x0020) ··· 195 175 #define MPI3_CREATE_REQUEST_QUEUE_FLAGS_SEGMENTED_MASK (0x80) 196 176 #define MPI3_CREATE_REQUEST_QUEUE_FLAGS_SEGMENTED_SEGMENTED (0x80) 197 177 #define MPI3_CREATE_REQUEST_QUEUE_FLAGS_SEGMENTED_CONTIGUOUS (0x00) 178 + #define MPI3_CREATE_REQUEST_QUEUE_SIZE_MINIMUM (2) 198 179 struct mpi3_delete_request_queue_request { 199 180 __le16 host_tag; 200 181 u8 ioc_use_only02; ··· 231 210 #define MPI3_CREATE_REPLY_QUEUE_FLAGS_INT_ENABLE_MASK (0x01) 232 211 #define MPI3_CREATE_REPLY_QUEUE_FLAGS_INT_ENABLE_DISABLE (0x00) 233 212 #define MPI3_CREATE_REPLY_QUEUE_FLAGS_INT_ENABLE_ENABLE (0x01) 213 + #define MPI3_CREATE_REPLY_QUEUE_SIZE_MINIMUM (2) 234 214 struct mpi3_delete_reply_queue_request { 235 215 __le16 host_tag; 236 216 u8 ioc_use_only02; ··· 277 255 #define MPI3_EVENT_SAS_DEVICE_DISCOVERY_ERROR (0x19) 278 256 #define MPI3_EVENT_PCIE_TOPOLOGY_CHANGE_LIST (0x20) 279 257 #define MPI3_EVENT_PCIE_ENUMERATION (0x22) 258 + #define MPI3_EVENT_PCIE_ERROR_THRESHOLD (0x23) 280 259 #define MPI3_EVENT_HARD_RESET_RECEIVED (0x40) 260 + #define MPI3_EVENT_DIAGNOSTIC_BUFFER_STATUS_CHANGE (0x50) 281 261 #define MPI3_EVENT_MIN_PRODUCT_SPECIFIC (0x60) 282 262 #define MPI3_EVENT_MAX_PRODUCT_SPECIFIC (0x7f) 283 263 #define MPI3_EVENT_NOTIFY_EVENTMASK_WORDS (4) ··· 335 311 __le32 reserved0c; 336 312 }; 337 313 338 - #define MPI3_EVENT_TEMP_THRESHOLD_STATUS_THRESHOLD3_EXCEEDED (0x0008) 339 - #define MPI3_EVENT_TEMP_THRESHOLD_STATUS_THRESHOLD2_EXCEEDED (0x0004) 340 - #define MPI3_EVENT_TEMP_THRESHOLD_STATUS_THRESHOLD1_EXCEEDED (0x0002) 341 - #define MPI3_EVENT_TEMP_THRESHOLD_STATUS_THRESHOLD0_EXCEEDED (0x0001) 314 + #define MPI3_EVENT_TEMP_THRESHOLD_STATUS_FATAL_THRESHOLD_EXCEEDED (0x0004) 315 + #define MPI3_EVENT_TEMP_THRESHOLD_STATUS_CRITICAL_THRESHOLD_EXCEEDED (0x0002) 316 + #define MPI3_EVENT_TEMP_THRESHOLD_STATUS_WARNING_THRESHOLD_EXCEEDED (0x0001) 342 317 struct mpi3_event_data_cable_management { 343 318 __le32 active_cable_power_requirement; 344 319 u8 status; ··· 421 398 #define MPI3_SAS_DISC_STATUS_MAX_EXPANDERS_EXCEED (0x40000000) 422 399 #define MPI3_SAS_DISC_STATUS_MAX_DEVICES_EXCEED (0x20000000) 423 400 #define MPI3_SAS_DISC_STATUS_MAX_TOPO_PHYS_EXCEED (0x10000000) 401 + #define MPI3_SAS_DISC_STATUS_INVALID_CEI (0x00010000) 402 + #define MPI3_SAS_DISC_STATUS_FECEI_MISMATCH (0x00008000) 424 403 #define MPI3_SAS_DISC_STATUS_MULTIPLE_DEVICES_IN_SLOT (0x00004000) 425 - #define MPI3_SAS_DISC_STATUS_SLOT_COUNT_MISMATCH (0x00002000) 404 + #define MPI3_SAS_DISC_STATUS_NECEI_MISMATCH (0x00002000) 426 405 #define MPI3_SAS_DISC_STATUS_TOO_MANY_SLOTS (0x00001000) 427 406 #define MPI3_SAS_DISC_STATUS_EXP_MULTI_SUBTRACTIVE (0x00000800) 428 407 #define MPI3_SAS_DISC_STATUS_MULTI_PORT_DOMAIN (0x00000400) ··· 606 581 #define MPI3_EVENT_PCIE_TOPO_SS_NOT_RESPONDING (0x02) 607 582 #define MPI3_EVENT_PCIE_TOPO_SS_RESPONDING (0x03) 608 583 #define MPI3_EVENT_PCIE_TOPO_SS_DELAY_NOT_RESPONDING (0x04) 584 + struct mpi3_event_data_pcie_error_threshold { 585 + __le64 timestamp; 586 + u8 reason_code; 587 + u8 port; 588 + __le16 switch_dev_handle; 589 + u8 error; 590 + u8 action; 591 + __le16 threshold_count; 592 + __le16 attached_dev_handle; 593 + __le16 reserved12; 594 + }; 595 + 596 + #define MPI3_EVENT_PCI_ERROR_RC_THRESHOLD_EXCEEDED (0x00) 597 + #define MPI3_EVENT_PCI_ERROR_RC_ESCALATION (0x01) 609 598 struct mpi3_event_data_sas_init_dev_status_change { 610 599 u8 reason_code; 611 600 u8 io_unit_port; ··· 643 604 __le16 reserved02; 644 605 }; 645 606 607 + struct mpi3_event_data_diag_buffer_status_change { 608 + u8 type; 609 + u8 reason_code; 610 + __le16 reserved02; 611 + __le32 reserved04; 612 + }; 613 + 614 + #define MPI3_EVENT_DIAG_BUFFER_STATUS_CHANGE_RC_RELEASED (0x01) 615 + #define MPI3_EVENT_DIAG_BUFFER_STATUS_CHANGE_RC_PAUSED (0x02) 616 + #define MPI3_EVENT_DIAG_BUFFER_STATUS_CHANGE_RC_RESUMED (0x03) 646 617 #define MPI3_PEL_LOCALE_FLAGS_NON_BLOCKING_BOOT_EVENT (0x0200) 647 618 #define MPI3_PEL_LOCALE_FLAGS_BLOCKING_BOOT_EVENT (0x0100) 648 619 #define MPI3_PEL_LOCALE_FLAGS_PCIE (0x0080) ··· 694 645 }; 695 646 696 647 struct mpi3_pel_entry { 648 + __le64 time_stamp; 697 649 __le32 sequence_number; 698 - __le32 time_stamp[2]; 699 650 __le16 log_code; 700 651 __le16 arg_type; 701 652 __le16 locale; 702 653 u8 class; 703 - u8 reserved13; 654 + u8 flags; 704 655 u8 ext_num; 705 656 u8 num_exts; 706 657 u8 arg_data_size; 707 - u8 fixed_format_size; 658 + u8 fixed_format_strings_size; 708 659 __le32 reserved18[2]; 709 660 __le32 pel_info[24]; 710 661 }; 711 662 663 + #define MPI3_PEL_FLAGS_COMPLETE_RESET_NEEDED (0x02) 664 + #define MPI3_PEL_FLAGS_ACK_NEEDED (0x01) 712 665 struct mpi3_pel_list { 713 666 __le32 log_count; 714 667 __le32 reserved04; ··· 888 837 __le32 reserved10; 889 838 }; 890 839 891 - #define MPI3_PELACKNOWLEDGE_MSGFLAGS_SAFE_MODE_EXIT (0x01) 840 + #define MPI3_PELACKNOWLEDGE_MSGFLAGS_SAFE_MODE_EXIT_MASK (0x03) 841 + #define MPI3_PELACKNOWLEDGE_MSGFLAGS_SAFE_MODE_EXIT_NO_GUIDANCE (0x00) 842 + #define MPI3_PELACKNOWLEDGE_MSGFLAGS_SAFE_MODE_EXIT_CONTINUE_OP (0x01) 843 + #define MPI3_PELACKNOWLEDGE_MSGFLAGS_SAFE_MODE_EXIT_TRANSITION_TO_FAULT (0x02) 892 844 struct mpi3_pel_reply { 893 845 __le16 host_tag; 894 846 u8 ioc_use_only02; ··· 939 885 #define MPI3_CI_DOWNLOAD_ACTION_ONLINE_ACTIVATION (0x02) 940 886 #define MPI3_CI_DOWNLOAD_ACTION_OFFLINE_ACTIVATION (0x03) 941 887 #define MPI3_CI_DOWNLOAD_ACTION_GET_STATUS (0x04) 888 + #define MPI3_CI_DOWNLOAD_ACTION_CANCEL_OFFLINE_ACTIVATION (0x05) 942 889 struct mpi3_ci_download_reply { 943 890 __le16 host_tag; 944 891 u8 ioc_use_only02; ··· 957 902 }; 958 903 959 904 #define MPI3_CI_DOWNLOAD_FLAGS_DOWNLOAD_IN_PROGRESS (0x80) 905 + #define MPI3_CI_DOWNLOAD_FLAGS_OFFLINE_ACTIVATION_REQUIRED (0x20) 960 906 #define MPI3_CI_DOWNLOAD_FLAGS_KEY_UPDATE_PENDING (0x10) 961 907 #define MPI3_CI_DOWNLOAD_FLAGS_ACTIVATION_STATUS_MASK (0x0e) 962 908 #define MPI3_CI_DOWNLOAD_FLAGS_ACTIVATION_STATUS_NOT_NEEDED (0x00) ··· 995 939 #define MPI3_CTRL_OP_REMOVE_DEVICE (0x10) 996 940 #define MPI3_CTRL_OP_CLOSE_PERSISTENT_CONNECTION (0x11) 997 941 #define MPI3_CTRL_OP_HIDDEN_ACK (0x12) 942 + #define MPI3_CTRL_OP_CLEAR_DEVICE_COUNTERS (0x13) 998 943 #define MPI3_CTRL_OP_SAS_SEND_PRIMITIVE (0x20) 999 - #define MPI3_CTRL_OP_SAS_CLEAR_ERROR_LOG (0x21) 1000 - #define MPI3_CTRL_OP_PCIE_CLEAR_ERROR_LOG (0x22) 944 + #define MPI3_CTRL_OP_SAS_PHY_CONTROL (0x21) 945 + #define MPI3_CTRL_OP_READ_INTERNAL_BUS (0x23) 946 + #define MPI3_CTRL_OP_WRITE_INTERNAL_BUS (0x24) 947 + #define MPI3_CTRL_OP_PCIE_LINK_CONTROL (0x30) 1001 948 #define MPI3_CTRL_OP_LOOKUP_MAPPING_PARAM8_LOOKUP_METHOD_INDEX (0x00) 1002 949 #define MPI3_CTRL_OP_UPDATE_TIMESTAMP_PARAM64_TIMESTAMP_INDEX (0x00) 1003 950 #define MPI3_CTRL_OP_REMOVE_DEVICE_PARAM16_DEVHANDLE_INDEX (0x00) 1004 951 #define MPI3_CTRL_OP_CLOSE_PERSIST_CONN_PARAM16_DEVHANDLE_INDEX (0x00) 1005 952 #define MPI3_CTRL_OP_HIDDEN_ACK_PARAM16_DEVHANDLE_INDEX (0x00) 953 + #define MPI3_CTRL_OP_CLEAR_DEVICE_COUNTERS_PARAM16_DEVHANDLE_INDEX (0x00) 1006 954 #define MPI3_CTRL_OP_SAS_SEND_PRIM_PARAM8_PHY_INDEX (0x00) 1007 955 #define MPI3_CTRL_OP_SAS_SEND_PRIM_PARAM8_PRIMSEQ_INDEX (0x01) 1008 956 #define MPI3_CTRL_OP_SAS_SEND_PRIM_PARAM32_PRIMITIVE_INDEX (0x00) 1009 - #define MPI3_CTRL_OP_SAS_CLEAR_ERR_LOG_PARAM8_PHY_INDEX (0x00) 1010 - #define MPI3_CTRL_OP_PCIE_CLEAR_ERR_LOG_PARAM8_PHY_INDEX (0x00) 957 + #define MPI3_CTRL_OP_SAS_PHY_CONTROL_PARAM8_ACTION_INDEX (0x00) 958 + #define MPI3_CTRL_OP_SAS_PHY_CONTROL_PARAM8_PHY_INDEX (0x01) 959 + #define MPI3_CTRL_OP_READ_INTERNAL_BUS_PARAM64_ADDRESS_INDEX (0x00) 960 + #define MPI3_CTRL_OP_WRITE_INTERNAL_BUS_PARAM64_ADDRESS_INDEX (0x00) 961 + #define MPI3_CTRL_OP_WRITE_INTERNAL_BUS_PARAM32_VALUE_INDEX (0x00) 962 + #define MPI3_CTRL_OP_PCIE_LINK_CONTROL_PARAM8_ACTION_INDEX (0x00) 963 + #define MPI3_CTRL_OP_PCIE_LINK_CONTROL_PARAM8_LINK_INDEX (0x01) 1011 964 #define MPI3_CTRL_LOOKUP_METHOD_WWID_ADDRESS (0x01) 1012 965 #define MPI3_CTRL_LOOKUP_METHOD_ENCLOSURE_SLOT (0x02) 1013 966 #define MPI3_CTRL_LOOKUP_METHOD_SAS_DEVICE_NAME (0x03) ··· 1031 966 #define MPI3_CTRL_LOOKUP_METHOD_PERSISTID_PARAM16_PERSISTENT_ID_INDEX (1) 1032 967 #define MPI3_CTRL_LOOKUP_METHOD_VALUE16_DEVH_INDEX (0) 1033 968 #define MPI3_CTRL_GET_TIMESTAMP_VALUE64_TIMESTAMP_INDEX (0) 969 + #define MPI3_CTRL_READ_INTERNAL_BUS_VALUE32_VALUE_INDEX (0) 1034 970 #define MPI3_CTRL_PRIMFLAGS_SINGLE (0x01) 1035 971 #define MPI3_CTRL_PRIMFLAGS_TRIPLE (0x03) 1036 972 #define MPI3_CTRL_PRIMFLAGS_REDUNDANT (0x06) 973 + #define MPI3_CTRL_ACTION_NOP (0x00) 974 + #define MPI3_CTRL_ACTION_LINK_RESET (0x01) 975 + #define MPI3_CTRL_ACTION_HARD_RESET (0x02) 976 + #define MPI3_CTRL_ACTION_CLEAR_ERROR_LOG (0x05) 1037 977 struct mpi3_iounit_control_request { 1038 978 __le16 host_tag; 1039 979 u8 ioc_use_only02;
+44
drivers/scsi/mpi3mr/mpi/mpi30_pci.h
··· 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
+14
drivers/scsi/mpi3mr/mpi/mpi30_sas.h
··· 30 30 struct mpi3_sge_common request_sge; 31 31 struct mpi3_sge_common response_sge; 32 32 }; 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 + }; 33 47 #endif
+19 -12
drivers/scsi/mpi3mr/mpi/mpi30_transport.h
··· 19 19 20 20 #define MPI3_VERSION_MAJOR (3) 21 21 #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) 24 24 struct mpi3_sysif_oper_queue_indexes { 25 25 __le16 producer_index; 26 26 __le16 reserved02; ··· 74 74 #define MPI3_SYSIF_IOC_INFO_HIGH_OFFSET (0x00000004) 75 75 #define MPI3_SYSIF_IOC_INFO_LOW_TIMEOUT_MASK (0xff000000) 76 76 #define MPI3_SYSIF_IOC_INFO_LOW_TIMEOUT_SHIFT (24) 77 + #define MPI3_SYSIF_IOC_INFO_LOW_HCB_DISABLED (0x00000001) 77 78 #define MPI3_SYSIF_IOC_CONFIG_OFFSET (0x00000014) 78 79 #define MPI3_SYSIF_IOC_CONFIG_OPER_RPY_ENT_SZ (0x00f00000) 79 80 #define MPI3_SYSIF_IOC_CONFIG_OPER_RPY_ENT_SZ_SHIFT (20) ··· 83 82 #define MPI3_SYSIF_IOC_CONFIG_SHUTDOWN_MASK (0x0000c000) 84 83 #define MPI3_SYSIF_IOC_CONFIG_SHUTDOWN_NO (0x00000000) 85 84 #define MPI3_SYSIF_IOC_CONFIG_SHUTDOWN_NORMAL (0x00004000) 86 - #define MPI3_SYSIF_IOC_CONFIG_DEVICE_SHUTDOWN (0x00002000) 85 + #define MPI3_SYSIF_IOC_CONFIG_DEVICE_SHUTDOWN_SEND_REQ (0x00002000) 87 86 #define MPI3_SYSIF_IOC_CONFIG_DIAG_SAVE (0x00000010) 88 87 #define MPI3_SYSIF_IOC_CONFIG_ENABLE_IOC (0x00000001) 89 88 #define MPI3_SYSIF_IOC_STATUS_OFFSET (0x0000001c) 90 89 #define MPI3_SYSIF_IOC_STATUS_RESET_HISTORY (0x00000010) 91 90 #define MPI3_SYSIF_IOC_STATUS_SHUTDOWN_MASK (0x0000000c) 91 + #define MPI3_SYSIF_IOC_STATUS_SHUTDOWN_SHIFT (0x00000002) 92 92 #define MPI3_SYSIF_IOC_STATUS_SHUTDOWN_NONE (0x00000000) 93 93 #define MPI3_SYSIF_IOC_STATUS_SHUTDOWN_IN_PROGRESS (0x00000004) 94 94 #define MPI3_SYSIF_IOC_STATUS_SHUTDOWN_COMPLETE (0x00000008) ··· 109 107 #define MPI3_SYSIF_COALESCE_CONTROL_ENABLE_NO_CHANGE (0x00000000) 110 108 #define MPI3_SYSIF_COALESCE_CONTROL_ENABLE_DISABLE (0x40000000) 111 109 #define MPI3_SYSIF_COALESCE_CONTROL_ENABLE_ENABLE (0xc0000000) 112 - #define MPI3_SYSIF_COALESCE_CONTROL_VALID (0x30000000) 113 - #define MPI3_SYSIF_COALESCE_CONTROL_QUEUE_ID_MASK (0x00ff0000) 114 - #define MPI3_SYSIF_COALESCE_CONTROL_QUEUE_ID_SHIFT (16) 110 + #define MPI3_SYSIF_COALESCE_CONTROL_VALID (0x20000000) 111 + #define MPI3_SYSIF_COALESCE_CONTROL_MSIX_IDX_MASK (0x01ff0000) 112 + #define MPI3_SYSIF_COALESCE_CONTROL_MSIX_IDX_SHIFT (16) 115 113 #define MPI3_SYSIF_COALESCE_CONTROL_TIMEOUT_MASK (0x0000ff00) 116 114 #define MPI3_SYSIF_COALESCE_CONTROL_TIMEOUT_SHIFT (8) 117 115 #define MPI3_SYSIF_COALESCE_CONTROL_DEPTH_MASK (0x000000ff) ··· 119 117 #define MPI3_SYSIF_ADMIN_REQ_Q_PI_OFFSET (0x00001000) 120 118 #define MPI3_SYSIF_ADMIN_REPLY_Q_CI_OFFSET (0x00001004) 121 119 #define MPI3_SYSIF_OPER_REQ_Q_PI_OFFSET (0x00001008) 122 - #define MPI3_SYSIF_OPER_REQ_Q_N_PI_OFFSET(n) (MPI3_SYSIF_OPER_REQ_Q_PI_OFFSET + (((n) - 1) * 8)) 120 + #define MPI3_SYSIF_OPER_REQ_Q_N_PI_OFFSET(N) (MPI3_SYSIF_OPER_REQ_Q_PI_OFFSET + (((N) - 1) * 8)) 123 121 #define MPI3_SYSIF_OPER_REPLY_Q_CI_OFFSET (0x0000100c) 124 - #define MPI3_SYSIF_OPER_REPLY_Q_N_CI_OFFSET(n) (MPI3_SYSIF_OPER_REPLY_Q_CI_OFFSET + (((n) - 1) * 8)) 122 + #define MPI3_SYSIF_OPER_REPLY_Q_N_CI_OFFSET(N) (MPI3_SYSIF_OPER_REPLY_Q_CI_OFFSET + (((N) - 1) * 8)) 125 123 #define MPI3_SYSIF_WRITE_SEQUENCE_OFFSET (0x00001c04) 126 124 #define MPI3_SYSIF_WRITE_SEQUENCE_KEY_VALUE_MASK (0x0000000f) 127 125 #define MPI3_SYSIF_WRITE_SEQUENCE_KEY_VALUE_FLUSH (0x0) ··· 135 133 #define MPI3_SYSIF_HOST_DIAG_RESET_ACTION_MASK (0x00000700) 136 134 #define MPI3_SYSIF_HOST_DIAG_RESET_ACTION_NO_RESET (0x00000000) 137 135 #define MPI3_SYSIF_HOST_DIAG_RESET_ACTION_SOFT_RESET (0x00000100) 138 - #define MPI3_SYSIF_HOST_DIAG_RESET_ACTION_FLASH_RCVRY_RESET (0x00000200) 136 + #define MPI3_SYSIF_HOST_DIAG_RESET_ACTION_HOST_CONTROL_BOOT_RESET (0x00000200) 139 137 #define MPI3_SYSIF_HOST_DIAG_RESET_ACTION_COMPLETE_RESET (0x00000300) 140 138 #define MPI3_SYSIF_HOST_DIAG_RESET_ACTION_DIAG_FAULT (0x00000700) 141 139 #define MPI3_SYSIF_HOST_DIAG_SAVE_IN_PROGRESS (0x00000080) ··· 155 153 #define MPI3_SYSIF_FAULT_CODE_CI_ACTIVATION_RESET (0x0000f001) 156 154 #define MPI3_SYSIF_FAULT_CODE_SOFT_RESET_IN_PROGRESS (0x0000f002) 157 155 #define MPI3_SYSIF_FAULT_CODE_COMPLETE_RESET_NEEDED (0x0000f003) 158 - #define MPI3_SYSIF_FAULT_CODE_SAFE_MODE_EXIT (0x0000f004) 159 - #define MPI3_SYSIF_FAULT_CODE_FACTORY_RESET (0x0000f005) 156 + #define MPI3_SYSIF_FAULT_CODE_SOFT_RESET_NEEDED (0x0000f004) 157 + #define MPI3_SYSIF_FAULT_CODE_POWER_CYCLE_REQUIRED (0x0000f005) 158 + #define MPI3_SYSIF_FAULT_CODE_TEMP_THRESHOLD_EXCEEDED (0x0000f006) 160 159 #define MPI3_SYSIF_FAULT_INFO0_OFFSET (0x00001c14) 161 160 #define MPI3_SYSIF_FAULT_INFO1_OFFSET (0x00001c18) 162 161 #define MPI3_SYSIF_FAULT_INFO2_OFFSET (0x00001c1c) ··· 412 409 #define MPI3_IOCSTATUS_INVALID_STATE (0x0008) 413 410 #define MPI3_IOCSTATUS_INSUFFICIENT_POWER (0x000a) 414 411 #define MPI3_IOCSTATUS_INVALID_CHANGE_COUNT (0x000b) 412 + #define MPI3_IOCSTATUS_ALLOWED_CMD_BLOCK (0x000c) 413 + #define MPI3_IOCSTATUS_SUPERVISOR_ONLY (0x000d) 415 414 #define MPI3_IOCSTATUS_FAILURE (0x001f) 416 415 #define MPI3_IOCSTATUS_CONFIG_INVALID_ACTION (0x0020) 417 416 #define MPI3_IOCSTATUS_CONFIG_INVALID_TYPE (0x0021) ··· 453 448 #define MPI3_IOCSTATUS_CI_UNSUPPORTED (0x00b0) 454 449 #define MPI3_IOCSTATUS_CI_UPDATE_SEQUENCE (0x00b1) 455 450 #define MPI3_IOCSTATUS_CI_VALIDATION_FAILED (0x00b2) 456 - #define MPI3_IOCSTATUS_CI_UPDATE_PENDING (0x00b3) 451 + #define MPI3_IOCSTATUS_CI_KEY_UPDATE_PENDING (0x00b3) 452 + #define MPI3_IOCSTATUS_CI_KEY_UPDATE_NOT_POSSIBLE (0x00b4) 457 453 #define MPI3_IOCSTATUS_SECURITY_KEY_REQUIRED (0x00c0) 454 + #define MPI3_IOCSTATUS_SECURITY_VIOLATION (0x00c1) 458 455 #define MPI3_IOCSTATUS_INVALID_QUEUE_ID (0x0f00) 459 456 #define MPI3_IOCSTATUS_INVALID_QUEUE_SIZE (0x0f01) 460 457 #define MPI3_IOCSTATUS_INVALID_MSIX_VECTOR (0x0f02)
+86 -40
drivers/scsi/mpi3mr/mpi3mr.h
··· 45 45 #include "mpi/mpi30_init.h" 46 46 #include "mpi/mpi30_ioc.h" 47 47 #include "mpi/mpi30_sas.h" 48 + #include "mpi/mpi30_pci.h" 48 49 #include "mpi3mr_debug.h" 49 50 50 51 /* Global list and lock for storing multiple adapters managed by the driver */ ··· 53 52 extern struct list_head mrioc_list; 54 53 extern int prot_mask; 55 54 56 - #define MPI3MR_DRIVER_VERSION "00.255.45.01" 57 - #define MPI3MR_DRIVER_RELDATE "12-December-2020" 55 + #define MPI3MR_DRIVER_VERSION "8.0.0.61.0" 56 + #define MPI3MR_DRIVER_RELDATE "20-December-2021" 58 57 59 58 #define MPI3MR_DRIVER_NAME "mpi3mr" 60 59 #define MPI3MR_DRIVER_LICENSE "GPL" ··· 80 79 81 80 /* Operational queue management definitions */ 82 81 #define MPI3MR_OP_REQ_Q_QD 512 83 - #define MPI3MR_OP_REP_Q_QD 4096 82 + #define MPI3MR_OP_REP_Q_QD 1024 83 + #define MPI3MR_OP_REP_Q_QD4K 4096 84 84 #define MPI3MR_OP_REQ_Q_SEG_SIZE 4096 85 85 #define MPI3MR_OP_REP_Q_SEG_SIZE 4096 86 86 #define MPI3MR_MAX_SEG_LIST_SIZE 4096 ··· 92 90 #define MPI3MR_HOSTTAG_IOCTLCMDS 2 93 91 #define MPI3MR_HOSTTAG_BLK_TMS 5 94 92 95 - #define MPI3MR_NUM_DEVRMCMD 1 93 + #define MPI3MR_NUM_DEVRMCMD 16 96 94 #define MPI3MR_HOSTTAG_DEVRMCMD_MIN (MPI3MR_HOSTTAG_BLK_TMS + 1) 97 95 #define MPI3MR_HOSTTAG_DEVRMCMD_MAX (MPI3MR_HOSTTAG_DEVRMCMD_MIN + \ 98 96 MPI3MR_NUM_DEVRMCMD - 1) 99 97 100 - #define MPI3MR_INTERNAL_CMDS_RESVD MPI3MR_HOSTTAG_DEVRMCMD_MAX 98 + #define MPI3MR_INTERNAL_CMDS_RESVD MPI3MR_HOSTTAG_DEVRMCMD_MAX 99 + #define MPI3MR_NUM_EVTACKCMD 4 100 + #define MPI3MR_HOSTTAG_EVTACKCMD_MIN (MPI3MR_HOSTTAG_DEVRMCMD_MAX + 1) 101 + #define MPI3MR_HOSTTAG_EVTACKCMD_MAX (MPI3MR_HOSTTAG_EVTACKCMD_MIN + \ 102 + MPI3MR_NUM_EVTACKCMD - 1) 101 103 102 104 /* Reduced resource count definition for crash kernel */ 103 105 #define MPI3MR_HOST_IOS_KDUMP 128 104 106 105 107 /* command/controller interaction timeout definitions in seconds */ 106 - #define MPI3MR_INTADMCMD_TIMEOUT 10 108 + #define MPI3MR_INTADMCMD_TIMEOUT 60 107 109 #define MPI3MR_PORTENABLE_TIMEOUT 300 108 - #define MPI3MR_ABORTTM_TIMEOUT 30 109 - #define MPI3MR_RESETTM_TIMEOUT 30 110 + #define MPI3MR_ABORTTM_TIMEOUT 60 111 + #define MPI3MR_RESETTM_TIMEOUT 60 110 112 #define MPI3MR_RESET_HOST_IOWAIT_TIMEOUT 5 111 113 #define MPI3MR_TSUPDATE_INTERVAL 900 112 114 #define MPI3MR_DEFAULT_SHUTDOWN_TIME 120 113 115 #define MPI3MR_RAID_ERRREC_RESET_TIMEOUT 180 116 + #define MPI3MR_PREPARE_FOR_RESET_TIMEOUT 180 117 + #define MPI3MR_RESET_ACK_TIMEOUT 30 114 118 115 119 #define MPI3MR_WATCHDOG_INTERVAL 1000 /* in milli seconds */ 116 120 ··· 129 121 130 122 /* Definitions for Event replies and sense buffer allocated per controller */ 131 123 #define MPI3MR_NUM_EVT_REPLIES 64 132 - #define MPI3MR_SENSEBUF_SZ 256 124 + #define MPI3MR_SENSE_BUF_SZ 256 133 125 #define MPI3MR_SENSEBUF_FACTOR 3 134 126 #define MPI3MR_CHAINBUF_FACTOR 3 135 127 #define MPI3MR_CHAINBUFDIX_FACTOR 2 ··· 143 135 144 136 /* ResponseCode definitions */ 145 137 #define MPI3MR_RI_MASK_RESPCODE (0x000000FF) 146 - #define MPI3MR_RSP_TM_COMPLETE 0x00 147 - #define MPI3MR_RSP_INVALID_FRAME 0x02 148 - #define MPI3MR_RSP_TM_NOT_SUPPORTED 0x04 149 - #define MPI3MR_RSP_TM_FAILED 0x05 150 - #define MPI3MR_RSP_TM_SUCCEEDED 0x08 151 - #define MPI3MR_RSP_TM_INVALID_LUN 0x09 152 - #define MPI3MR_RSP_TM_OVERLAPPED_TAG 0x0A 153 138 #define MPI3MR_RSP_IO_QUEUED_ON_IOC \ 154 139 MPI3_SCSITASKMGMT_RSPCODE_IO_QUEUED_ON_IOC 155 140 156 141 #define MPI3MR_DEFAULT_MDTS (128 * 1024) 142 + #define MPI3MR_DEFAULT_PGSZEXP (12) 157 143 /* Command retry count definitions */ 158 144 #define MPI3MR_DEV_RMHS_RETRY_COUNT 3 159 145 ··· 185 183 MRIOC_STATE_UNRECOVERABLE, 186 184 }; 187 185 188 - /* Init type definitions */ 189 - enum mpi3mr_init_type { 190 - MPI3MR_IT_INIT = 0, 191 - MPI3MR_IT_RESET, 192 - MPI3MR_IT_RESUME, 193 - }; 194 - 195 - /* Cleanup reason definitions */ 196 - enum mpi3mr_cleanup_reason { 197 - MPI3MR_COMPLETE_CLEANUP = 0, 198 - MPI3MR_REINIT_FAILURE, 199 - MPI3MR_SUSPEND, 200 - }; 201 - 202 186 /* Reset reason code definitions*/ 203 187 enum mpi3mr_reset_reason { 204 188 MPI3MR_RESET_FROM_BRINGUP = 1, ··· 210 222 MPI3MR_RESET_FROM_GETPKGVER_TIMEOUT = 21, 211 223 MPI3MR_RESET_FROM_PELABORT_TIMEOUT = 22, 212 224 MPI3MR_RESET_FROM_SYSFS = 23, 213 - MPI3MR_RESET_FROM_SYSFS_TIMEOUT = 24 225 + MPI3MR_RESET_FROM_SYSFS_TIMEOUT = 24, 226 + MPI3MR_RESET_FROM_FIRMWARE = 27, 227 + }; 228 + 229 + /* Queue type definitions */ 230 + enum queue_type { 231 + MPI3MR_DEFAULT_QUEUE = 0, 232 + MPI3MR_POLL_QUEUE, 214 233 }; 215 234 216 235 /** ··· 258 263 u16 max_vds; 259 264 u16 max_hpds; 260 265 u16 max_advhpds; 261 - u16 max_raidpds; 266 + u16 max_raid_pds; 262 267 u16 min_devhandle; 263 268 u16 max_devhandle; 264 269 u16 max_op_req_q; ··· 331 336 * @pend_ios: Number of IOs pending in HW for this queue 332 337 * @enable_irq_poll: Flag to indicate polling is enabled 333 338 * @in_use: Queue is handled by poll/ISR 339 + * @qtype: Type of queue (types defined in enum queue_type) 334 340 */ 335 341 struct op_reply_qinfo { 336 342 u16 ci; ··· 346 350 atomic_t pend_ios; 347 351 bool enable_irq_poll; 348 352 atomic_t in_use; 353 + enum queue_type qtype; 349 354 }; 350 355 351 356 /** ··· 385 388 * @pgsz: Device page size 386 389 * @abort_to: Timeout for abort TM 387 390 * @reset_to: Timeout for Target/LUN reset TM 391 + * @dev_info: Device information bits 388 392 */ 389 393 struct tgt_dev_pcie { 390 394 u32 mdts; ··· 393 395 u8 pgsz; 394 396 u8 abort_to; 395 397 u8 reset_to; 398 + u16 dev_info; 396 399 }; 397 400 398 401 /** ··· 498 499 * @dev_removedelay: Device is waiting to be removed in FW 499 500 * @dev_type: Device type 500 501 * @tgt_dev: Internal target device pointer 502 + * @pend_count: Counter to track pending I/Os during error 503 + * handling 501 504 */ 502 505 struct mpi3mr_stgt_priv_data { 503 506 struct scsi_target *starget; ··· 511 510 u8 dev_removedelay; 512 511 u8 dev_type; 513 512 struct mpi3mr_tgt_dev *tgt_dev; 513 + u32 pend_count; 514 514 }; 515 515 516 516 /** ··· 520 518 * @tgt_priv_data: Scsi_target private data pointer 521 519 * @lun_id: LUN ID of the device 522 520 * @ncq_prio_enable: NCQ priority enable for SATA device 521 + * @pend_count: Counter to track pending I/Os during error 522 + * handling 523 523 */ 524 524 struct mpi3mr_sdev_priv_data { 525 525 struct mpi3mr_stgt_priv_data *tgt_priv_data; 526 526 u32 lun_id; 527 527 u8 ncq_prio_enable; 528 + u32 pend_count; 528 529 }; 529 530 530 531 /** ··· 635 630 * @ready_timeout: Controller ready timeout 636 631 * @intr_info: Interrupt cookie pointer 637 632 * @intr_info_count: Number of interrupt cookies 633 + * @is_intr_info_set: Flag to indicate intr info is setup 638 634 * @num_queues: Number of operational queues 639 635 * @num_op_req_q: Number of operational request queues 640 636 * @req_qinfo: Operational request queue info pointer ··· 687 681 * @chain_buf_lock: Chain buffer list lock 688 682 * @host_tm_cmds: Command tracker for task management commands 689 683 * @dev_rmhs_cmds: Command tracker for device removal commands 684 + * @evtack_cmds: Command tracker for event ack commands 690 685 * @devrem_bitmap_sz: Device removal bitmap size 691 686 * @devrem_bitmap: Device removal bitmap 692 687 * @dev_handle_bitmap_sz: Device handle bitmap size 693 688 * @removepend_bitmap: Remove pending bitmap 694 689 * @delayed_rmhs_list: Delayed device removal list 690 + * @evtack_cmds_bitmap_sz: Event Ack bitmap size 691 + * @evtack_cmds_bitmap: Event Ack bitmap 692 + * @delayed_evtack_cmds_list: Delayed event acknowledgment list 695 693 * @ts_update_counter: Timestamp update counter 696 - * @fault_dbg: Fault debug flag 697 694 * @reset_in_progress: Reset in progress flag 698 695 * @unrecoverable: Controller unrecoverable flag 696 + * @prev_reset_result: Result of previous reset 699 697 * @reset_mutex: Controller reset mutex 700 698 * @reset_waitq: Controller reset wait queue 699 + * @prepare_for_reset: Prepare for reset event received 700 + * @prepare_for_reset_timeout_counter: Prepare for reset timeout 701 701 * @diagsave_timeout: Diagnostic information save timeout 702 702 * @logging_level: Controller debug logging level 703 703 * @flush_io_count: I/O count to flush after reset ··· 711 699 * @driver_info: Driver, Kernel, OS information to firmware 712 700 * @change_count: Topology change count 713 701 * @op_reply_q_offset: Operational reply queue offset with MSIx 702 + * @default_qcount: Total Default queues 703 + * @active_poll_qcount: Currently active poll queue count 704 + * @requested_poll_qcount: User requested poll queue count 714 705 */ 715 706 struct mpi3mr_ioc { 716 707 struct list_head list; ··· 754 739 755 740 struct mpi3mr_intr_info *intr_info; 756 741 u16 intr_info_count; 742 + bool is_intr_info_set; 757 743 758 744 u16 num_queues; 759 745 u16 num_op_req_q; ··· 774 758 dma_addr_t reply_buf_dma_max_address; 775 759 776 760 u16 reply_free_qsz; 761 + u16 reply_sz; 777 762 struct dma_pool *reply_free_q_pool; 778 763 __le64 *reply_free_q; 779 764 dma_addr_t reply_free_q_dma; ··· 822 805 823 806 struct mpi3mr_drv_cmd host_tm_cmds; 824 807 struct mpi3mr_drv_cmd dev_rmhs_cmds[MPI3MR_NUM_DEVRMCMD]; 808 + struct mpi3mr_drv_cmd evtack_cmds[MPI3MR_NUM_EVTACKCMD]; 825 809 u16 devrem_bitmap_sz; 826 810 void *devrem_bitmap; 827 811 u16 dev_handle_bitmap_sz; 828 812 void *removepend_bitmap; 829 813 struct list_head delayed_rmhs_list; 814 + u16 evtack_cmds_bitmap_sz; 815 + void *evtack_cmds_bitmap; 816 + struct list_head delayed_evtack_cmds_list; 830 817 831 818 u32 ts_update_counter; 832 - u8 fault_dbg; 833 819 u8 reset_in_progress; 834 820 u8 unrecoverable; 821 + int prev_reset_result; 835 822 struct mutex reset_mutex; 836 823 wait_queue_head_t reset_waitq; 824 + 825 + u8 prepare_for_reset; 826 + u16 prepare_for_reset_timeout_counter; 837 827 838 828 u16 diagsave_timeout; 839 829 int logging_level; ··· 850 826 struct mpi3_driver_info_layout driver_info; 851 827 u16 change_count; 852 828 u16 op_reply_q_offset; 829 + 830 + u16 default_qcount; 831 + u16 active_poll_qcount; 832 + u16 requested_poll_qcount; 853 833 }; 854 834 855 835 /** ··· 895 867 u8 iou_rc; 896 868 }; 897 869 870 + /** 871 + * struct delayed_evt_ack_node - Delayed event ack node 872 + * @list: list head 873 + * @event: MPI3 event ID 874 + * @event_ctx: event context 875 + */ 876 + struct delayed_evt_ack_node { 877 + struct list_head list; 878 + u8 event; 879 + u32 event_ctx; 880 + }; 881 + 898 882 int mpi3mr_setup_resources(struct mpi3mr_ioc *mrioc); 899 883 void mpi3mr_cleanup_resources(struct mpi3mr_ioc *mrioc); 900 - int mpi3mr_init_ioc(struct mpi3mr_ioc *mrioc, u8 init_type); 901 - void mpi3mr_cleanup_ioc(struct mpi3mr_ioc *mrioc, u8 reason); 884 + int mpi3mr_init_ioc(struct mpi3mr_ioc *mrioc); 885 + int mpi3mr_reinit_ioc(struct mpi3mr_ioc *mrioc, u8 is_resume); 886 + void mpi3mr_cleanup_ioc(struct mpi3mr_ioc *mrioc); 902 887 int mpi3mr_issue_port_enable(struct mpi3mr_ioc *mrioc, u8 async); 903 888 int mpi3mr_admin_request_post(struct mpi3mr_ioc *mrioc, void *admin_req, 904 889 u16 admin_req_sz, u8 ignore_reset); ··· 928 887 u64 sense_buf_dma); 929 888 930 889 void mpi3mr_memset_buffers(struct mpi3mr_ioc *mrioc); 890 + void mpi3mr_free_mem(struct mpi3mr_ioc *mrioc); 931 891 void mpi3mr_os_handle_events(struct mpi3mr_ioc *mrioc, 932 892 struct mpi3_event_notification_reply *event_reply); 933 893 void mpi3mr_process_op_reply_desc(struct mpi3mr_ioc *mrioc, ··· 939 897 940 898 int mpi3mr_soft_reset_handler(struct mpi3mr_ioc *mrioc, 941 899 u32 reset_reason, u8 snapdump); 942 - int mpi3mr_diagfault_reset_handler(struct mpi3mr_ioc *mrioc, 943 - u32 reset_reason); 944 900 void mpi3mr_ioc_disable_intr(struct mpi3mr_ioc *mrioc); 945 901 void mpi3mr_ioc_enable_intr(struct mpi3mr_ioc *mrioc); 946 902 947 903 enum mpi3mr_iocstate mpi3mr_get_iocstate(struct mpi3mr_ioc *mrioc); 948 - int mpi3mr_send_event_ack(struct mpi3mr_ioc *mrioc, u8 event, 904 + int mpi3mr_process_event_ack(struct mpi3mr_ioc *mrioc, u8 event, 949 905 u32 event_ctx); 950 906 951 907 void mpi3mr_wait_for_host_io(struct mpi3mr_ioc *mrioc, u32 timeout); ··· 951 911 void mpi3mr_flush_host_io(struct mpi3mr_ioc *mrioc); 952 912 void mpi3mr_invalidate_devhandles(struct mpi3mr_ioc *mrioc); 953 913 void mpi3mr_rfresh_tgtdevs(struct mpi3mr_ioc *mrioc); 954 - void mpi3mr_flush_delayed_rmhs_list(struct mpi3mr_ioc *mrioc); 914 + void mpi3mr_flush_delayed_cmd_lists(struct mpi3mr_ioc *mrioc); 915 + void mpi3mr_check_rh_fault_ioc(struct mpi3mr_ioc *mrioc, u32 reason_code); 916 + void mpi3mr_print_fault_info(struct mpi3mr_ioc *mrioc); 917 + void mpi3mr_check_rh_fault_ioc(struct mpi3mr_ioc *mrioc, u32 reason_code); 918 + int mpi3mr_process_op_reply_q(struct mpi3mr_ioc *mrioc, 919 + struct op_reply_qinfo *op_reply_q); 920 + int mpi3mr_blk_mq_poll(struct Scsi_Host *shost, unsigned int queue_num); 955 921 956 922 #endif /*MPI3MR_H_INCLUDED*/
+110 -25
drivers/scsi/mpi3mr/mpi3mr_debug.h
··· 14 14 /* 15 15 * debug levels 16 16 */ 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 38 31 39 32 40 33 /* ··· 43 50 #define ioc_info(ioc, fmt, ...) \ 44 51 pr_info("%s: " fmt, (ioc)->name, ##__VA_ARGS__) 45 52 46 - 47 - #define dbgprint(IOC, FMT, ...) \ 53 + #define dprint(ioc, fmt, ...) \ 48 54 do { \ 49 - if (IOC->logging_level & MPI3_DEBUG) \ 50 - pr_info("%s: " FMT, (IOC)->name, ##__VA_ARGS__); \ 55 + if (ioc->logging_level & MPI3_DEBUG) \ 56 + pr_info("%s: " fmt, (ioc)->name, ##__VA_ARGS__); \ 57 + } while (0) 58 + 59 + #define dprint_event_th(ioc, fmt, ...) \ 60 + do { \ 61 + if (ioc->logging_level & MPI3_DEBUG_EVENT) \ 62 + pr_info("%s: " fmt, (ioc)->name, ##__VA_ARGS__); \ 63 + } while (0) 64 + 65 + #define dprint_event_bh(ioc, fmt, ...) \ 66 + do { \ 67 + if (ioc->logging_level & MPI3_DEBUG_EVENT_WORK_TASK) \ 68 + pr_info("%s: " fmt, (ioc)->name, ##__VA_ARGS__); \ 69 + } while (0) 70 + 71 + #define dprint_init(ioc, fmt, ...) \ 72 + do { \ 73 + if (ioc->logging_level & MPI3_DEBUG_INIT) \ 74 + pr_info("%s: " fmt, (ioc)->name, ##__VA_ARGS__); \ 75 + } while (0) 76 + 77 + #define dprint_exit(ioc, fmt, ...) \ 78 + do { \ 79 + if (ioc->logging_level & MPI3_DEBUG_EXIT) \ 80 + pr_info("%s: " fmt, (ioc)->name, ##__VA_ARGS__); \ 81 + } while (0) 82 + 83 + #define dprint_tm(ioc, fmt, ...) \ 84 + do { \ 85 + if (ioc->logging_level & MPI3_DEBUG_TM) \ 86 + pr_info("%s: " fmt, (ioc)->name, ##__VA_ARGS__); \ 87 + } while (0) 88 + 89 + #define dprint_reply(ioc, fmt, ...) \ 90 + do { \ 91 + if (ioc->logging_level & MPI3_DEBUG_REPLY) \ 92 + pr_info("%s: " fmt, (ioc)->name, ##__VA_ARGS__); \ 93 + } while (0) 94 + 95 + #define dprint_reset(ioc, fmt, ...) \ 96 + do { \ 97 + if (ioc->logging_level & MPI3_DEBUG_RESET) \ 98 + pr_info("%s: " fmt, (ioc)->name, ##__VA_ARGS__); \ 99 + } while (0) 100 + 101 + #define dprint_scsi_info(ioc, fmt, ...) \ 102 + do { \ 103 + if (ioc->logging_level & MPI3_DEBUG_SCSI_INFO) \ 104 + pr_info("%s: " fmt, (ioc)->name, ##__VA_ARGS__); \ 105 + } while (0) 106 + 107 + #define dprint_scsi_err(ioc, fmt, ...) \ 108 + do { \ 109 + if (ioc->logging_level & MPI3_DEBUG_SCSI_ERROR) \ 110 + pr_info("%s: " fmt, (ioc)->name, ##__VA_ARGS__); \ 111 + } while (0) 112 + 113 + #define dprint_scsi_command(ioc, SCMD, LOG_LEVEL) \ 114 + do { \ 115 + if (ioc->logging_level & LOG_LEVEL) \ 116 + scsi_print_command(SCMD); \ 117 + } while (0) 118 + 119 + 120 + #define dprint_ioctl_info(ioc, fmt, ...) \ 121 + do { \ 122 + if (ioc->logging_level & MPI3_DEBUG_IOCTL_INFO) \ 123 + pr_info("%s: " fmt, (ioc)->name, ##__VA_ARGS__); \ 124 + } while (0) 125 + 126 + #define dprint_ioctl_err(ioc, fmt, ...) \ 127 + do { \ 128 + if (ioc->logging_level & MPI3_DEBUG_IOCTL_ERROR) \ 129 + pr_info("%s: " fmt, (ioc)->name, ##__VA_ARGS__); \ 51 130 } while (0) 52 131 53 132 #endif /* MPT3SAS_DEBUG_H_INCLUDED */ 133 + 134 + /** 135 + * dprint_dump_req - print message frame contents 136 + * @req: pointer to message frame 137 + * @sz: number of dwords 138 + */ 139 + static inline void 140 + dprint_dump_req(void *req, int sz) 141 + { 142 + int i; 143 + __le32 *mfp = (__le32 *)req; 144 + 145 + pr_info("request:\n\t"); 146 + for (i = 0; i < sz; i++) { 147 + if (i && ((i % 8) == 0)) 148 + pr_info("\n\t"); 149 + pr_info("%08x ", le32_to_cpu(mfp[i])); 150 + } 151 + pr_info("\n"); 152 + }
+956 -505
drivers/scsi/mpi3mr/mpi3mr_fw.c
··· 10 10 #include "mpi3mr.h" 11 11 #include <linux/io-64-nonatomic-lo-hi.h> 12 12 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 + 13 23 #if defined(writeq) && defined(CONFIG_64BIT) 14 24 static inline void mpi3mr_writeq(__u64 b, volatile void __iomem *addr) 15 25 { ··· 88 78 kfree(mrioc->intr_info); 89 79 mrioc->intr_info = NULL; 90 80 mrioc->intr_info_count = 0; 81 + mrioc->is_intr_info_set = false; 91 82 pci_free_irq_vectors(mrioc->pdev); 92 83 } 93 84 ··· 135 124 u64 reply_dma) 136 125 { 137 126 u32 old_idx = 0; 127 + unsigned long flags; 138 128 139 - spin_lock(&mrioc->reply_free_queue_lock); 129 + spin_lock_irqsave(&mrioc->reply_free_queue_lock, flags); 140 130 old_idx = mrioc->reply_free_queue_host_index; 141 131 mrioc->reply_free_queue_host_index = ( 142 132 (mrioc->reply_free_queue_host_index == ··· 146 134 mrioc->reply_free_q[old_idx] = cpu_to_le64(reply_dma); 147 135 writel(mrioc->reply_free_queue_host_index, 148 136 &mrioc->sysif_regs->reply_free_host_index); 149 - spin_unlock(&mrioc->reply_free_queue_lock); 137 + spin_unlock_irqrestore(&mrioc->reply_free_queue_lock, flags); 150 138 } 151 139 152 140 void mpi3mr_repost_sense_buf(struct mpi3mr_ioc *mrioc, 153 141 u64 sense_buf_dma) 154 142 { 155 143 u32 old_idx = 0; 144 + unsigned long flags; 156 145 157 - spin_lock(&mrioc->sbq_lock); 146 + spin_lock_irqsave(&mrioc->sbq_lock, flags); 158 147 old_idx = mrioc->sbq_host_index; 159 148 mrioc->sbq_host_index = ((mrioc->sbq_host_index == 160 149 (mrioc->sense_buf_q_sz - 1)) ? 0 : ··· 163 150 mrioc->sense_buf_q[old_idx] = cpu_to_le64(sense_buf_dma); 164 151 writel(mrioc->sbq_host_index, 165 152 &mrioc->sysif_regs->sense_buffer_free_host_index); 166 - spin_unlock(&mrioc->sbq_lock); 153 + spin_unlock_irqrestore(&mrioc->sbq_lock, flags); 167 154 } 168 155 169 156 static void mpi3mr_print_event_data(struct mpi3mr_ioc *mrioc, ··· 316 303 return &mrioc->dev_rmhs_cmds[idx]; 317 304 } 318 305 306 + if (host_tag >= MPI3MR_HOSTTAG_EVTACKCMD_MIN && 307 + host_tag <= MPI3MR_HOSTTAG_EVTACKCMD_MAX) { 308 + idx = host_tag - MPI3MR_HOSTTAG_EVTACKCMD_MIN; 309 + return &mrioc->evtack_cmds[idx]; 310 + } 311 + 319 312 return NULL; 320 313 } 321 314 ··· 388 369 if (def_reply) { 389 370 cmdptr->state |= MPI3MR_CMD_REPLY_VALID; 390 371 memcpy((u8 *)cmdptr->reply, (u8 *)def_reply, 391 - mrioc->facts.reply_sz); 372 + mrioc->reply_sz); 392 373 } 393 374 if (cmdptr->is_waiting) { 394 375 complete(&cmdptr->done); ··· 465 446 return reply_desc; 466 447 } 467 448 468 - static int mpi3mr_process_op_reply_q(struct mpi3mr_ioc *mrioc, 469 - struct mpi3mr_intr_info *intr_info) 449 + /** 450 + * mpi3mr_process_op_reply_q - Operational reply queue handler 451 + * @mrioc: Adapter instance reference 452 + * @op_reply_q: Operational reply queue info 453 + * 454 + * Checks the specific operational reply queue and drains the 455 + * reply queue entries until the queue is empty and process the 456 + * individual reply descriptors. 457 + * 458 + * Return: 0 if queue is already processed,or number of reply 459 + * descriptors processed. 460 + */ 461 + int mpi3mr_process_op_reply_q(struct mpi3mr_ioc *mrioc, 462 + struct op_reply_qinfo *op_reply_q) 470 463 { 471 - struct op_reply_qinfo *op_reply_q = intr_info->op_reply_q; 472 464 struct op_req_qinfo *op_req_q; 473 465 u32 exp_phase; 474 466 u32 reply_ci; ··· 530 500 * Ensure remaining completion happens from threaded ISR. 531 501 */ 532 502 if (num_op_reply > mrioc->max_host_ios) { 533 - intr_info->op_reply_q->enable_irq_poll = true; 503 + op_reply_q->enable_irq_poll = true; 534 504 break; 535 505 } 536 506 ··· 543 513 544 514 atomic_dec(&op_reply_q->in_use); 545 515 return num_op_reply; 516 + } 517 + 518 + /** 519 + * mpi3mr_blk_mq_poll - Operational reply queue handler 520 + * @shost: SCSI Host reference 521 + * @queue_num: Request queue number (w.r.t OS it is hardware context number) 522 + * 523 + * Checks the specific operational reply queue and drains the 524 + * reply queue entries until the queue is empty and process the 525 + * individual reply descriptors. 526 + * 527 + * Return: 0 if queue is already processed,or number of reply 528 + * descriptors processed. 529 + */ 530 + int mpi3mr_blk_mq_poll(struct Scsi_Host *shost, unsigned int queue_num) 531 + { 532 + int num_entries = 0; 533 + struct mpi3mr_ioc *mrioc; 534 + 535 + mrioc = (struct mpi3mr_ioc *)shost->hostdata; 536 + 537 + if ((mrioc->reset_in_progress || mrioc->prepare_for_reset)) 538 + return 0; 539 + 540 + num_entries = mpi3mr_process_op_reply_q(mrioc, 541 + &mrioc->op_reply_qinfo[queue_num]); 542 + 543 + return num_entries; 546 544 } 547 545 548 546 static irqreturn_t mpi3mr_isr_primary(int irq, void *privdata) ··· 593 535 if (!midx) 594 536 num_admin_replies = mpi3mr_process_admin_reply_q(mrioc); 595 537 if (intr_info->op_reply_q) 596 - num_op_reply = mpi3mr_process_op_reply_q(mrioc, intr_info); 538 + num_op_reply = mpi3mr_process_op_reply_q(mrioc, 539 + intr_info->op_reply_q); 597 540 598 541 if (num_admin_replies || num_op_reply) 599 542 return IRQ_HANDLED; ··· 665 606 mpi3mr_process_admin_reply_q(mrioc); 666 607 if (intr_info->op_reply_q) 667 608 num_op_reply += 668 - mpi3mr_process_op_reply_q(mrioc, intr_info); 609 + mpi3mr_process_op_reply_q(mrioc, 610 + intr_info->op_reply_q); 669 611 670 - usleep_range(mrioc->irqpoll_sleep, 10 * mrioc->irqpoll_sleep); 612 + usleep_range(MPI3MR_IRQ_POLL_SLEEP, 10 * MPI3MR_IRQ_POLL_SLEEP); 671 613 672 614 } while (atomic_read(&intr_info->op_reply_q->pend_ios) && 673 615 (num_op_reply < mrioc->max_host_ios)); ··· 712 652 return retval; 713 653 } 714 654 655 + static void mpi3mr_calc_poll_queues(struct mpi3mr_ioc *mrioc, u16 max_vectors) 656 + { 657 + if (!mrioc->requested_poll_qcount) 658 + return; 659 + 660 + /* Reserved for Admin and Default Queue */ 661 + if (max_vectors > 2 && 662 + (mrioc->requested_poll_qcount < max_vectors - 2)) { 663 + ioc_info(mrioc, 664 + "enabled polled queues (%d) msix (%d)\n", 665 + mrioc->requested_poll_qcount, max_vectors); 666 + } else { 667 + ioc_info(mrioc, 668 + "disabled polled queues (%d) msix (%d) because of no resources for default queue\n", 669 + mrioc->requested_poll_qcount, max_vectors); 670 + mrioc->requested_poll_qcount = 0; 671 + } 672 + } 673 + 715 674 /** 716 675 * mpi3mr_setup_isr - Setup ISR for the controller 717 676 * @mrioc: Adapter instance reference ··· 743 664 static int mpi3mr_setup_isr(struct mpi3mr_ioc *mrioc, u8 setup_one) 744 665 { 745 666 unsigned int irq_flags = PCI_IRQ_MSIX; 746 - int max_vectors; 667 + int max_vectors, min_vec; 747 668 int retval; 748 669 int i; 749 - struct irq_affinity desc = { .pre_vectors = 1}; 670 + struct irq_affinity desc = { .pre_vectors = 1, .post_vectors = 1 }; 671 + 672 + if (mrioc->is_intr_info_set) 673 + return 0; 750 674 751 675 mpi3mr_cleanup_isr(mrioc); 752 676 753 - if (setup_one || reset_devices) 677 + if (setup_one || reset_devices) { 754 678 max_vectors = 1; 755 - else { 679 + retval = pci_alloc_irq_vectors(mrioc->pdev, 680 + 1, max_vectors, irq_flags); 681 + if (retval < 0) { 682 + ioc_err(mrioc, "cannot allocate irq vectors, ret %d\n", 683 + retval); 684 + goto out_failed; 685 + } 686 + } else { 756 687 max_vectors = 757 - min_t(int, mrioc->cpu_count + 1, mrioc->msix_count); 688 + min_t(int, mrioc->cpu_count + 1 + 689 + mrioc->requested_poll_qcount, mrioc->msix_count); 690 + 691 + mpi3mr_calc_poll_queues(mrioc, max_vectors); 758 692 759 693 ioc_info(mrioc, 760 694 "MSI-X vectors supported: %d, no of cores: %d,", 761 695 mrioc->msix_count, mrioc->cpu_count); 762 696 ioc_info(mrioc, 763 - "MSI-x vectors requested: %d\n", max_vectors); 764 - } 697 + "MSI-x vectors requested: %d poll_queues %d\n", 698 + max_vectors, mrioc->requested_poll_qcount); 765 699 766 - irq_flags |= PCI_IRQ_AFFINITY | PCI_IRQ_ALL_TYPES; 700 + desc.post_vectors = mrioc->requested_poll_qcount; 701 + min_vec = desc.pre_vectors + desc.post_vectors; 702 + irq_flags |= PCI_IRQ_AFFINITY | PCI_IRQ_ALL_TYPES; 767 703 768 - mrioc->op_reply_q_offset = (max_vectors > 1) ? 1 : 0; 769 - retval = pci_alloc_irq_vectors_affinity(mrioc->pdev, 770 - 1, max_vectors, irq_flags, &desc); 771 - if (retval < 0) { 772 - ioc_err(mrioc, "Cannot alloc irq vectors\n"); 773 - goto out_failed; 774 - } 775 - if (retval != max_vectors) { 776 - ioc_info(mrioc, 777 - "allocated vectors (%d) are less than configured (%d)\n", 778 - retval, max_vectors); 704 + retval = pci_alloc_irq_vectors_affinity(mrioc->pdev, 705 + min_vec, max_vectors, irq_flags, &desc); 706 + 707 + if (retval < 0) { 708 + ioc_err(mrioc, "cannot allocate irq vectors, ret %d\n", 709 + retval); 710 + goto out_failed; 711 + } 712 + 713 + 779 714 /* 780 715 * If only one MSI-x is allocated, then MSI-x 0 will be shared 781 716 * between Admin queue and operational queue 782 717 */ 783 - if (retval == 1) 718 + if (retval == min_vec) 784 719 mrioc->op_reply_q_offset = 0; 720 + else if (retval != (max_vectors)) { 721 + ioc_info(mrioc, 722 + "allocated vectors (%d) are less than configured (%d)\n", 723 + retval, max_vectors); 724 + } 785 725 786 726 max_vectors = retval; 727 + mrioc->op_reply_q_offset = (max_vectors > 1) ? 1 : 0; 728 + 729 + mpi3mr_calc_poll_queues(mrioc, max_vectors); 730 + 787 731 } 732 + 788 733 mrioc->intr_info = kzalloc(sizeof(struct mpi3mr_intr_info) * max_vectors, 789 734 GFP_KERNEL); 790 735 if (!mrioc->intr_info) { ··· 823 720 goto out_failed; 824 721 } 825 722 } 723 + if (reset_devices || !setup_one) 724 + mrioc->is_intr_info_set = true; 826 725 mrioc->intr_info_count = max_vectors; 827 726 mpi3mr_ioc_enable_intr(mrioc); 828 727 return 0; ··· 901 796 }, 902 797 { MPI3MR_RESET_FROM_SYSFS, "sysfs invocation" }, 903 798 { MPI3MR_RESET_FROM_SYSFS_TIMEOUT, "sysfs TM timeout" }, 799 + { MPI3MR_RESET_FROM_FIRMWARE, "firmware asynchronus reset" }, 904 800 }; 905 801 906 802 /** ··· 966 860 * 967 861 * Return: Nothing. 968 862 */ 969 - static void mpi3mr_print_fault_info(struct mpi3mr_ioc *mrioc) 863 + void mpi3mr_print_fault_info(struct mpi3mr_ioc *mrioc) 970 864 { 971 865 u32 ioc_status, code, code1, code2, code3; 972 866 ··· 1064 958 ioc_config &= ~MPI3_SYSIF_IOC_CONFIG_ENABLE_IOC; 1065 959 writel(ioc_config, &mrioc->sysif_regs->ioc_configuration); 1066 960 1067 - timeout = mrioc->ready_timeout * 10; 961 + timeout = MPI3MR_RESET_ACK_TIMEOUT * 10; 1068 962 do { 1069 963 ioc_status = readl(&mrioc->sysif_regs->ioc_status); 1070 964 if ((ioc_status & MPI3_SYSIF_IOC_STATUS_RESET_HISTORY)) { 1071 965 mpi3mr_clear_reset_history(mrioc); 1072 - ioc_config = 1073 - readl(&mrioc->sysif_regs->ioc_configuration); 1074 - if (!((ioc_status & MPI3_SYSIF_IOC_STATUS_READY) || 1075 - (ioc_status & MPI3_SYSIF_IOC_STATUS_FAULT) || 1076 - (ioc_config & MPI3_SYSIF_IOC_CONFIG_ENABLE_IOC))) { 1077 - retval = 0; 1078 - break; 1079 - } 966 + break; 967 + } 968 + if (ioc_status & MPI3_SYSIF_IOC_STATUS_FAULT) { 969 + mpi3mr_print_fault_info(mrioc); 970 + break; 1080 971 } 1081 972 msleep(100); 1082 973 } while (--timeout); 1083 974 1084 - ioc_status = readl(&mrioc->sysif_regs->ioc_status); 1085 975 ioc_config = readl(&mrioc->sysif_regs->ioc_configuration); 976 + if (timeout && !((ioc_status & MPI3_SYSIF_IOC_STATUS_READY) || 977 + (ioc_status & MPI3_SYSIF_IOC_STATUS_FAULT) || 978 + (ioc_config & MPI3_SYSIF_IOC_CONFIG_ENABLE_IOC))) 979 + retval = 0; 1086 980 1087 981 ioc_info(mrioc, "Base IOC Sts/Config after %s MUR is (0x%x)/(0x%x)\n", 1088 982 (!retval) ? "successful" : "failed", ioc_status, ioc_config); 1089 983 return retval; 984 + } 985 + 986 + /** 987 + * mpi3mr_revalidate_factsdata - validate IOCFacts parameters 988 + * during reset/resume 989 + * @mrioc: Adapter instance reference 990 + * 991 + * Return zero if the new IOCFacts parameters value is compatible with 992 + * older values else return -EPERM 993 + */ 994 + static int 995 + mpi3mr_revalidate_factsdata(struct mpi3mr_ioc *mrioc) 996 + { 997 + u16 dev_handle_bitmap_sz; 998 + void *removepend_bitmap; 999 + 1000 + if (mrioc->facts.reply_sz > mrioc->reply_sz) { 1001 + ioc_err(mrioc, 1002 + "cannot increase reply size from %d to %d\n", 1003 + mrioc->reply_sz, mrioc->facts.reply_sz); 1004 + return -EPERM; 1005 + } 1006 + 1007 + if (mrioc->facts.max_op_reply_q < mrioc->num_op_reply_q) { 1008 + ioc_err(mrioc, 1009 + "cannot reduce number of operational reply queues from %d to %d\n", 1010 + mrioc->num_op_reply_q, 1011 + mrioc->facts.max_op_reply_q); 1012 + return -EPERM; 1013 + } 1014 + 1015 + if (mrioc->facts.max_op_req_q < mrioc->num_op_req_q) { 1016 + ioc_err(mrioc, 1017 + "cannot reduce number of operational request queues from %d to %d\n", 1018 + mrioc->num_op_req_q, mrioc->facts.max_op_req_q); 1019 + return -EPERM; 1020 + } 1021 + 1022 + dev_handle_bitmap_sz = mrioc->facts.max_devhandle / 8; 1023 + if (mrioc->facts.max_devhandle % 8) 1024 + dev_handle_bitmap_sz++; 1025 + if (dev_handle_bitmap_sz > mrioc->dev_handle_bitmap_sz) { 1026 + removepend_bitmap = krealloc(mrioc->removepend_bitmap, 1027 + dev_handle_bitmap_sz, GFP_KERNEL); 1028 + if (!removepend_bitmap) { 1029 + ioc_err(mrioc, 1030 + "failed to increase removepend_bitmap sz from: %d to %d\n", 1031 + mrioc->dev_handle_bitmap_sz, dev_handle_bitmap_sz); 1032 + return -EPERM; 1033 + } 1034 + memset(removepend_bitmap + mrioc->dev_handle_bitmap_sz, 0, 1035 + dev_handle_bitmap_sz - mrioc->dev_handle_bitmap_sz); 1036 + mrioc->removepend_bitmap = removepend_bitmap; 1037 + ioc_info(mrioc, 1038 + "increased dev_handle_bitmap_sz from %d to %d\n", 1039 + mrioc->dev_handle_bitmap_sz, dev_handle_bitmap_sz); 1040 + mrioc->dev_handle_bitmap_sz = dev_handle_bitmap_sz; 1041 + } 1042 + 1043 + return 0; 1090 1044 } 1091 1045 1092 1046 /** ··· 1156 990 * Set Enable IOC bit in IOC configuration register and wait for 1157 991 * the controller to become ready. 1158 992 * 1159 - * Return: 0 on success, -1 on failure. 993 + * Return: 0 on success, appropriate error on failure. 1160 994 */ 1161 995 static int mpi3mr_bring_ioc_ready(struct mpi3mr_ioc *mrioc) 1162 996 { 1163 - u32 ioc_config, timeout; 1164 - enum mpi3mr_iocstate current_state; 997 + u32 ioc_config, ioc_status, timeout; 998 + int retval = 0; 999 + enum mpi3mr_iocstate ioc_state; 1000 + u64 base_info; 1165 1001 1002 + ioc_status = readl(&mrioc->sysif_regs->ioc_status); 1003 + ioc_config = readl(&mrioc->sysif_regs->ioc_configuration); 1004 + base_info = lo_hi_readq(&mrioc->sysif_regs->ioc_information); 1005 + ioc_info(mrioc, "ioc_status(0x%08x), ioc_config(0x%08x), ioc_info(0x%016llx) at the bringup\n", 1006 + ioc_status, ioc_config, base_info); 1007 + 1008 + /*The timeout value is in 2sec unit, changing it to seconds*/ 1009 + mrioc->ready_timeout = 1010 + ((base_info & MPI3_SYSIF_IOC_INFO_LOW_TIMEOUT_MASK) >> 1011 + MPI3_SYSIF_IOC_INFO_LOW_TIMEOUT_SHIFT) * 2; 1012 + 1013 + ioc_info(mrioc, "ready timeout: %d seconds\n", mrioc->ready_timeout); 1014 + 1015 + ioc_state = mpi3mr_get_iocstate(mrioc); 1016 + ioc_info(mrioc, "controller is in %s state during detection\n", 1017 + mpi3mr_iocstate_name(ioc_state)); 1018 + 1019 + if (ioc_state == MRIOC_STATE_BECOMING_READY || 1020 + ioc_state == MRIOC_STATE_RESET_REQUESTED) { 1021 + timeout = mrioc->ready_timeout * 10; 1022 + do { 1023 + msleep(100); 1024 + } while (--timeout); 1025 + 1026 + ioc_state = mpi3mr_get_iocstate(mrioc); 1027 + ioc_info(mrioc, 1028 + "controller is in %s state after waiting to reset\n", 1029 + mpi3mr_iocstate_name(ioc_state)); 1030 + } 1031 + 1032 + if (ioc_state == MRIOC_STATE_READY) { 1033 + ioc_info(mrioc, "issuing message unit reset (MUR) to bring to reset state\n"); 1034 + retval = mpi3mr_issue_and_process_mur(mrioc, 1035 + MPI3MR_RESET_FROM_BRINGUP); 1036 + ioc_state = mpi3mr_get_iocstate(mrioc); 1037 + if (retval) 1038 + ioc_err(mrioc, 1039 + "message unit reset failed with error %d current state %s\n", 1040 + retval, mpi3mr_iocstate_name(ioc_state)); 1041 + } 1042 + if (ioc_state != MRIOC_STATE_RESET) { 1043 + mpi3mr_print_fault_info(mrioc); 1044 + ioc_info(mrioc, "issuing soft reset to bring to reset state\n"); 1045 + retval = mpi3mr_issue_reset(mrioc, 1046 + MPI3_SYSIF_HOST_DIAG_RESET_ACTION_SOFT_RESET, 1047 + MPI3MR_RESET_FROM_BRINGUP); 1048 + if (retval) { 1049 + ioc_err(mrioc, 1050 + "soft reset failed with error %d\n", retval); 1051 + goto out_failed; 1052 + } 1053 + } 1054 + ioc_state = mpi3mr_get_iocstate(mrioc); 1055 + if (ioc_state != MRIOC_STATE_RESET) { 1056 + ioc_err(mrioc, 1057 + "cannot bring controller to reset state, current state: %s\n", 1058 + mpi3mr_iocstate_name(ioc_state)); 1059 + goto out_failed; 1060 + } 1061 + mpi3mr_clear_reset_history(mrioc); 1062 + retval = mpi3mr_setup_admin_qpair(mrioc); 1063 + if (retval) { 1064 + ioc_err(mrioc, "failed to setup admin queues: error %d\n", 1065 + retval); 1066 + goto out_failed; 1067 + } 1068 + 1069 + ioc_info(mrioc, "bringing controller to ready state\n"); 1166 1070 ioc_config = readl(&mrioc->sysif_regs->ioc_configuration); 1167 1071 ioc_config |= MPI3_SYSIF_IOC_CONFIG_ENABLE_IOC; 1168 1072 writel(ioc_config, &mrioc->sysif_regs->ioc_configuration); 1169 1073 1170 1074 timeout = mrioc->ready_timeout * 10; 1171 1075 do { 1172 - current_state = mpi3mr_get_iocstate(mrioc); 1173 - if (current_state == MRIOC_STATE_READY) 1076 + ioc_state = mpi3mr_get_iocstate(mrioc); 1077 + if (ioc_state == MRIOC_STATE_READY) { 1078 + ioc_info(mrioc, 1079 + "successfully transistioned to %s state\n", 1080 + mpi3mr_iocstate_name(ioc_state)); 1174 1081 return 0; 1082 + } 1175 1083 msleep(100); 1176 1084 } while (--timeout); 1177 1085 1178 - return -1; 1086 + out_failed: 1087 + ioc_state = mpi3mr_get_iocstate(mrioc); 1088 + ioc_err(mrioc, 1089 + "failed to bring to ready state, current state: %s\n", 1090 + mpi3mr_iocstate_name(ioc_state)); 1091 + return retval; 1179 1092 } 1180 1093 1181 1094 /** ··· 1271 1026 mpi3mr_soft_reset_success(u32 ioc_status, u32 ioc_config) 1272 1027 { 1273 1028 if (!((ioc_status & MPI3_SYSIF_IOC_STATUS_READY) || 1274 - (ioc_status & MPI3_SYSIF_IOC_STATUS_FAULT) || 1275 1029 (ioc_config & MPI3_SYSIF_IOC_CONFIG_ENABLE_IOC))) 1276 1030 return true; 1277 1031 return false; ··· 1293 1049 if (!(ioc_status & MPI3_SYSIF_IOC_STATUS_FAULT)) 1294 1050 return false; 1295 1051 fault = readl(&mrioc->sysif_regs->fault) & MPI3_SYSIF_FAULT_CODE_MASK; 1296 - if (fault == MPI3_SYSIF_FAULT_CODE_DIAG_FAULT_RESET) 1052 + if (fault == MPI3_SYSIF_FAULT_CODE_DIAG_FAULT_RESET) { 1053 + mpi3mr_print_fault_info(mrioc); 1297 1054 return true; 1055 + } 1298 1056 return false; 1299 1057 } 1300 1058 ··· 1335 1089 u32 reset_reason) 1336 1090 { 1337 1091 int retval = -1; 1338 - u8 unlock_retry_count, reset_retry_count = 0; 1339 - u32 host_diagnostic, timeout, ioc_status, ioc_config; 1092 + u8 unlock_retry_count = 0; 1093 + u32 host_diagnostic, ioc_status, ioc_config; 1094 + u32 timeout = MPI3MR_RESET_ACK_TIMEOUT * 10; 1340 1095 1341 - pci_cfg_access_lock(mrioc->pdev); 1342 1096 if ((reset_type != MPI3_SYSIF_HOST_DIAG_RESET_ACTION_SOFT_RESET) && 1343 1097 (reset_type != MPI3_SYSIF_HOST_DIAG_RESET_ACTION_DIAG_FAULT)) 1344 - goto out; 1098 + return retval; 1345 1099 if (mrioc->unrecoverable) 1346 - goto out; 1347 - retry_reset: 1348 - unlock_retry_count = 0; 1100 + return retval; 1101 + if (reset_reason == MPI3MR_RESET_FROM_FIRMWARE) { 1102 + retval = 0; 1103 + return retval; 1104 + } 1105 + 1106 + ioc_info(mrioc, "%s reset due to %s(0x%x)\n", 1107 + mpi3mr_reset_type_name(reset_type), 1108 + mpi3mr_reset_rc_name(reset_reason), reset_reason); 1109 + 1349 1110 mpi3mr_clear_reset_history(mrioc); 1350 1111 do { 1351 1112 ioc_info(mrioc, 1352 1113 "Write magic sequence to unlock host diag register (retry=%d)\n", 1353 1114 ++unlock_retry_count); 1354 1115 if (unlock_retry_count >= MPI3MR_HOSTDIAG_UNLOCK_RETRY_COUNT) { 1355 - writel(reset_reason, &mrioc->sysif_regs->scratchpad[0]); 1116 + ioc_err(mrioc, 1117 + "%s reset failed due to unlock failure, host_diagnostic(0x%08x)\n", 1118 + mpi3mr_reset_type_name(reset_type), 1119 + host_diagnostic); 1356 1120 mrioc->unrecoverable = 1; 1357 - goto out; 1121 + return retval; 1358 1122 } 1359 1123 1360 1124 writel(MPI3_SYSIF_WRITE_SEQUENCE_KEY_VALUE_FLUSH, ··· 1389 1133 } while (!(host_diagnostic & MPI3_SYSIF_HOST_DIAG_DIAG_WRITE_ENABLE)); 1390 1134 1391 1135 writel(reset_reason, &mrioc->sysif_regs->scratchpad[0]); 1392 - ioc_info(mrioc, "%s reset due to %s(0x%x)\n", 1393 - mpi3mr_reset_type_name(reset_type), 1394 - mpi3mr_reset_rc_name(reset_reason), reset_reason); 1395 1136 writel(host_diagnostic | reset_type, 1396 1137 &mrioc->sysif_regs->host_diagnostic); 1397 - timeout = mrioc->ready_timeout * 10; 1398 - if (reset_type == MPI3_SYSIF_HOST_DIAG_RESET_ACTION_SOFT_RESET) { 1138 + switch (reset_type) { 1139 + case MPI3_SYSIF_HOST_DIAG_RESET_ACTION_SOFT_RESET: 1399 1140 do { 1400 1141 ioc_status = readl(&mrioc->sysif_regs->ioc_status); 1401 - if (ioc_status & 1402 - MPI3_SYSIF_IOC_STATUS_RESET_HISTORY) { 1142 + ioc_config = 1143 + readl(&mrioc->sysif_regs->ioc_configuration); 1144 + if ((ioc_status & MPI3_SYSIF_IOC_STATUS_RESET_HISTORY) 1145 + && mpi3mr_soft_reset_success(ioc_status, ioc_config) 1146 + ) { 1403 1147 mpi3mr_clear_reset_history(mrioc); 1404 - ioc_config = 1405 - readl(&mrioc->sysif_regs->ioc_configuration); 1406 - if (mpi3mr_soft_reset_success(ioc_status, 1407 - ioc_config)) { 1408 - retval = 0; 1409 - break; 1410 - } 1148 + retval = 0; 1149 + break; 1411 1150 } 1412 1151 msleep(100); 1413 1152 } while (--timeout); 1414 - writel(MPI3_SYSIF_WRITE_SEQUENCE_KEY_VALUE_2ND, 1415 - &mrioc->sysif_regs->write_sequence); 1416 - } else if (reset_type == MPI3_SYSIF_HOST_DIAG_RESET_ACTION_DIAG_FAULT) { 1153 + mpi3mr_print_fault_info(mrioc); 1154 + break; 1155 + case MPI3_SYSIF_HOST_DIAG_RESET_ACTION_DIAG_FAULT: 1417 1156 do { 1418 1157 ioc_status = readl(&mrioc->sysif_regs->ioc_status); 1419 1158 if (mpi3mr_diagfault_success(mrioc, ioc_status)) { ··· 1417 1166 } 1418 1167 msleep(100); 1419 1168 } while (--timeout); 1420 - mpi3mr_clear_reset_history(mrioc); 1421 - writel(MPI3_SYSIF_WRITE_SEQUENCE_KEY_VALUE_2ND, 1422 - &mrioc->sysif_regs->write_sequence); 1423 - } 1424 - if (retval && ((++reset_retry_count) < MPI3MR_MAX_RESET_RETRY_COUNT)) { 1425 - ioc_status = readl(&mrioc->sysif_regs->ioc_status); 1426 - ioc_config = readl(&mrioc->sysif_regs->ioc_configuration); 1427 - ioc_info(mrioc, 1428 - "Base IOC Sts/Config after reset try %d is (0x%x)/(0x%x)\n", 1429 - reset_retry_count, ioc_status, ioc_config); 1430 - goto retry_reset; 1169 + break; 1170 + default: 1171 + break; 1431 1172 } 1432 1173 1433 - out: 1434 - pci_cfg_access_unlock(mrioc->pdev); 1435 - ioc_status = readl(&mrioc->sysif_regs->ioc_status); 1174 + writel(MPI3_SYSIF_WRITE_SEQUENCE_KEY_VALUE_2ND, 1175 + &mrioc->sysif_regs->write_sequence); 1176 + 1436 1177 ioc_config = readl(&mrioc->sysif_regs->ioc_configuration); 1437 - 1178 + ioc_status = readl(&mrioc->sysif_regs->ioc_status); 1438 1179 ioc_info(mrioc, 1439 - "Base IOC Sts/Config after %s reset is (0x%x)/(0x%x)\n", 1440 - (!retval) ? "successful" : "failed", ioc_status, 1180 + "ioc_status/ioc_onfig after %s reset is (0x%x)/(0x%x)\n", 1181 + (!retval)?"successful":"failed", ioc_status, 1441 1182 ioc_config); 1183 + if (retval) 1184 + mrioc->unrecoverable = 1; 1442 1185 return retval; 1443 1186 } 1444 1187 ··· 1523 1278 mrioc->op_reply_qinfo[q_idx].q_segment_list = NULL; 1524 1279 } 1525 1280 } else 1526 - size = mrioc->req_qinfo[q_idx].num_requests * 1281 + size = mrioc->req_qinfo[q_idx].segment_qd * 1527 1282 mrioc->facts.op_req_sz; 1528 1283 1529 1284 for (j = 0; j < mrioc->req_qinfo[q_idx].num_segments; j++) { ··· 1596 1351 static int mpi3mr_delete_op_reply_q(struct mpi3mr_ioc *mrioc, u16 qidx) 1597 1352 { 1598 1353 struct mpi3_delete_reply_queue_request delq_req; 1354 + struct op_reply_qinfo *op_reply_q = mrioc->op_reply_qinfo + qidx; 1599 1355 int retval = 0; 1600 1356 u16 reply_qid = 0, midx; 1601 1357 1602 - reply_qid = mrioc->op_reply_qinfo[qidx].qid; 1358 + reply_qid = op_reply_q->qid; 1603 1359 1604 1360 midx = REPLY_QUEUE_IDX_TO_MSIX_IDX(qidx, mrioc->op_reply_q_offset); 1605 1361 ··· 1609 1363 ioc_err(mrioc, "Issue DelRepQ: called with invalid ReqQID\n"); 1610 1364 goto out; 1611 1365 } 1366 + 1367 + (op_reply_q->qtype == MPI3MR_DEFAULT_QUEUE) ? mrioc->default_qcount-- : 1368 + mrioc->active_poll_qcount--; 1612 1369 1613 1370 memset(&delq_req, 0, sizeof(delq_req)); 1614 1371 mutex_lock(&mrioc->init_cmds.mutex); ··· 1638 1389 wait_for_completion_timeout(&mrioc->init_cmds.done, 1639 1390 (MPI3MR_INTADMCMD_TIMEOUT * HZ)); 1640 1391 if (!(mrioc->init_cmds.state & MPI3MR_CMD_COMPLETE)) { 1641 - ioc_err(mrioc, "Issue DelRepQ: command timed out\n"); 1642 - mpi3mr_set_diagsave(mrioc); 1643 - mpi3mr_issue_reset(mrioc, 1644 - MPI3_SYSIF_HOST_DIAG_RESET_ACTION_DIAG_FAULT, 1392 + ioc_err(mrioc, "delete reply queue timed out\n"); 1393 + mpi3mr_check_rh_fault_ioc(mrioc, 1645 1394 MPI3MR_RESET_FROM_DELREPQ_TIMEOUT); 1646 - mrioc->unrecoverable = 1; 1647 - 1648 1395 retval = -1; 1649 1396 goto out_unlock; 1650 1397 } ··· 1810 1565 1811 1566 reply_qid = qidx + 1; 1812 1567 op_reply_q->num_replies = MPI3MR_OP_REP_Q_QD; 1568 + if (!mrioc->pdev->revision) 1569 + op_reply_q->num_replies = MPI3MR_OP_REP_Q_QD4K; 1813 1570 op_reply_q->ci = 0; 1814 1571 op_reply_q->ephase = 1; 1815 1572 atomic_set(&op_reply_q->pend_ios, 0); ··· 1839 1592 create_req.host_tag = cpu_to_le16(MPI3MR_HOSTTAG_INITCMDS); 1840 1593 create_req.function = MPI3_FUNCTION_CREATE_REPLY_QUEUE; 1841 1594 create_req.queue_id = cpu_to_le16(reply_qid); 1842 - create_req.flags = MPI3_CREATE_REPLY_QUEUE_FLAGS_INT_ENABLE_ENABLE; 1843 - create_req.msix_index = cpu_to_le16(mrioc->intr_info[midx].msix_index); 1595 + 1596 + if (midx < (mrioc->intr_info_count - mrioc->requested_poll_qcount)) 1597 + op_reply_q->qtype = MPI3MR_DEFAULT_QUEUE; 1598 + else 1599 + op_reply_q->qtype = MPI3MR_POLL_QUEUE; 1600 + 1601 + if (op_reply_q->qtype == MPI3MR_DEFAULT_QUEUE) { 1602 + create_req.flags = 1603 + MPI3_CREATE_REPLY_QUEUE_FLAGS_INT_ENABLE_ENABLE; 1604 + create_req.msix_index = 1605 + cpu_to_le16(mrioc->intr_info[midx].msix_index); 1606 + } else { 1607 + create_req.msix_index = cpu_to_le16(mrioc->intr_info_count - 1); 1608 + ioc_info(mrioc, "create reply queue(polled): for qid(%d), midx(%d)\n", 1609 + reply_qid, midx); 1610 + if (!mrioc->active_poll_qcount) 1611 + disable_irq_nosync(pci_irq_vector(mrioc->pdev, 1612 + mrioc->intr_info_count - 1)); 1613 + } 1614 + 1844 1615 if (mrioc->enable_segqueue) { 1845 1616 create_req.flags |= 1846 1617 MPI3_CREATE_REQUEST_QUEUE_FLAGS_SEGMENTED_SEGMENTED; ··· 1880 1615 wait_for_completion_timeout(&mrioc->init_cmds.done, 1881 1616 (MPI3MR_INTADMCMD_TIMEOUT * HZ)); 1882 1617 if (!(mrioc->init_cmds.state & MPI3MR_CMD_COMPLETE)) { 1883 - ioc_err(mrioc, "CreateRepQ: command timed out\n"); 1884 - mpi3mr_set_diagsave(mrioc); 1885 - mpi3mr_issue_reset(mrioc, 1886 - MPI3_SYSIF_HOST_DIAG_RESET_ACTION_DIAG_FAULT, 1618 + ioc_err(mrioc, "create reply queue timed out\n"); 1619 + mpi3mr_check_rh_fault_ioc(mrioc, 1887 1620 MPI3MR_RESET_FROM_CREATEREPQ_TIMEOUT); 1888 - mrioc->unrecoverable = 1; 1889 1621 retval = -1; 1890 1622 goto out_unlock; 1891 1623 } ··· 1896 1634 goto out_unlock; 1897 1635 } 1898 1636 op_reply_q->qid = reply_qid; 1899 - mrioc->intr_info[midx].op_reply_q = op_reply_q; 1637 + if (midx < mrioc->intr_info_count) 1638 + mrioc->intr_info[midx].op_reply_q = op_reply_q; 1639 + 1640 + (op_reply_q->qtype == MPI3MR_DEFAULT_QUEUE) ? mrioc->default_qcount++ : 1641 + mrioc->active_poll_qcount++; 1900 1642 1901 1643 out_unlock: 1902 1644 mrioc->init_cmds.state = MPI3MR_CMD_NOTUSED; ··· 1988 1722 wait_for_completion_timeout(&mrioc->init_cmds.done, 1989 1723 (MPI3MR_INTADMCMD_TIMEOUT * HZ)); 1990 1724 if (!(mrioc->init_cmds.state & MPI3MR_CMD_COMPLETE)) { 1991 - ioc_err(mrioc, "CreateReqQ: command timed out\n"); 1992 - mpi3mr_set_diagsave(mrioc); 1993 - if (mpi3mr_issue_reset(mrioc, 1994 - MPI3_SYSIF_HOST_DIAG_RESET_ACTION_DIAG_FAULT, 1995 - MPI3MR_RESET_FROM_CREATEREQQ_TIMEOUT)) 1996 - mrioc->unrecoverable = 1; 1725 + ioc_err(mrioc, "create request queue timed out\n"); 1726 + mpi3mr_check_rh_fault_ioc(mrioc, 1727 + MPI3MR_RESET_FROM_CREATEREQQ_TIMEOUT); 1997 1728 retval = -1; 1998 1729 goto out_unlock; 1999 1730 } ··· 2034 1771 mrioc->intr_info_count - mrioc->op_reply_q_offset; 2035 1772 if (!mrioc->num_queues) 2036 1773 mrioc->num_queues = min_t(int, num_queues, msix_count_op_q); 2037 - num_queues = mrioc->num_queues; 2038 - ioc_info(mrioc, "Trying to create %d Operational Q pairs\n", 1774 + /* 1775 + * During reset set the num_queues to the number of queues 1776 + * that was set before the reset. 1777 + */ 1778 + num_queues = mrioc->num_op_reply_q ? 1779 + mrioc->num_op_reply_q : mrioc->num_queues; 1780 + ioc_info(mrioc, "trying to create %d operational queue pairs\n", 2039 1781 num_queues); 2040 1782 2041 1783 if (!mrioc->req_qinfo) { ··· 2082 1814 goto out_failed; 2083 1815 } 2084 1816 mrioc->num_op_reply_q = mrioc->num_op_req_q = i; 2085 - ioc_info(mrioc, "Successfully created %d Operational Q pairs\n", 2086 - mrioc->num_op_reply_q); 1817 + ioc_info(mrioc, 1818 + "successfully created %d operational queue pairs(default/polled) queue = (%d/%d)\n", 1819 + mrioc->num_op_reply_q, mrioc->default_qcount, 1820 + mrioc->active_poll_qcount); 2087 1821 2088 1822 return retval; 2089 1823 out_failed: ··· 2133 1863 if (mpi3mr_check_req_qfull(op_req_q)) { 2134 1864 midx = REPLY_QUEUE_IDX_TO_MSIX_IDX( 2135 1865 reply_qidx, mrioc->op_reply_q_offset); 2136 - mpi3mr_process_op_reply_q(mrioc, &mrioc->intr_info[midx]); 1866 + mpi3mr_process_op_reply_q(mrioc, mrioc->intr_info[midx].op_reply_q); 2137 1867 2138 1868 if (mpi3mr_check_req_qfull(op_req_q)) { 2139 1869 retval = -EAGAIN; ··· 2168 1898 out: 2169 1899 spin_unlock_irqrestore(&op_req_q->q_lock, flags); 2170 1900 return retval; 1901 + } 1902 + 1903 + /** 1904 + * mpi3mr_check_rh_fault_ioc - check reset history and fault 1905 + * controller 1906 + * @mrioc: Adapter instance reference 1907 + * @reason_code, reason code for the fault. 1908 + * 1909 + * This routine will save snapdump and fault the controller with 1910 + * the given reason code if it is not already in the fault or 1911 + * not asynchronosuly reset. This will be used to handle 1912 + * initilaization time faults/resets/timeout as in those cases 1913 + * immediate soft reset invocation is not required. 1914 + * 1915 + * Return: None. 1916 + */ 1917 + void mpi3mr_check_rh_fault_ioc(struct mpi3mr_ioc *mrioc, u32 reason_code) 1918 + { 1919 + u32 ioc_status, host_diagnostic, timeout; 1920 + 1921 + ioc_status = readl(&mrioc->sysif_regs->ioc_status); 1922 + if ((ioc_status & MPI3_SYSIF_IOC_STATUS_RESET_HISTORY) || 1923 + (ioc_status & MPI3_SYSIF_IOC_STATUS_FAULT)) { 1924 + mpi3mr_print_fault_info(mrioc); 1925 + return; 1926 + } 1927 + mpi3mr_set_diagsave(mrioc); 1928 + mpi3mr_issue_reset(mrioc, MPI3_SYSIF_HOST_DIAG_RESET_ACTION_DIAG_FAULT, 1929 + reason_code); 1930 + timeout = MPI3_SYSIF_DIAG_SAVE_TIMEOUT * 10; 1931 + do { 1932 + host_diagnostic = readl(&mrioc->sysif_regs->host_diagnostic); 1933 + if (!(host_diagnostic & MPI3_SYSIF_HOST_DIAG_SAVE_IN_PROGRESS)) 1934 + break; 1935 + msleep(100); 1936 + } while (--timeout); 2171 1937 } 2172 1938 2173 1939 /** ··· 2251 1945 if (!(mrioc->init_cmds.state & MPI3MR_CMD_COMPLETE)) { 2252 1946 ioc_err(mrioc, "Issue IOUCTL time_stamp: command timed out\n"); 2253 1947 mrioc->init_cmds.is_waiting = 0; 2254 - mpi3mr_soft_reset_handler(mrioc, 2255 - MPI3MR_RESET_FROM_TSU_TIMEOUT, 1); 1948 + if (!(mrioc->init_cmds.state & MPI3MR_CMD_RESET)) 1949 + mpi3mr_soft_reset_handler(mrioc, 1950 + MPI3MR_RESET_FROM_TSU_TIMEOUT, 1); 2256 1951 retval = -1; 2257 1952 goto out_unlock; 2258 1953 } ··· 2276 1969 } 2277 1970 2278 1971 /** 1972 + * mpi3mr_print_pkg_ver - display controller fw package version 1973 + * @mrioc: Adapter reference 1974 + * 1975 + * Retrieve firmware package version from the component image 1976 + * header of the controller flash and display it. 1977 + * 1978 + * Return: 0 on success and non-zero on failure. 1979 + */ 1980 + static int mpi3mr_print_pkg_ver(struct mpi3mr_ioc *mrioc) 1981 + { 1982 + struct mpi3_ci_upload_request ci_upload; 1983 + int retval = -1; 1984 + void *data = NULL; 1985 + dma_addr_t data_dma; 1986 + struct mpi3_ci_manifest_mpi *manifest; 1987 + u32 data_len = sizeof(struct mpi3_ci_manifest_mpi); 1988 + u8 sgl_flags = MPI3MR_SGEFLAGS_SYSTEM_SIMPLE_END_OF_LIST; 1989 + 1990 + data = dma_alloc_coherent(&mrioc->pdev->dev, data_len, &data_dma, 1991 + GFP_KERNEL); 1992 + if (!data) 1993 + return -ENOMEM; 1994 + 1995 + memset(&ci_upload, 0, sizeof(ci_upload)); 1996 + mutex_lock(&mrioc->init_cmds.mutex); 1997 + if (mrioc->init_cmds.state & MPI3MR_CMD_PENDING) { 1998 + ioc_err(mrioc, "sending get package version failed due to command in use\n"); 1999 + mutex_unlock(&mrioc->init_cmds.mutex); 2000 + goto out; 2001 + } 2002 + mrioc->init_cmds.state = MPI3MR_CMD_PENDING; 2003 + mrioc->init_cmds.is_waiting = 1; 2004 + mrioc->init_cmds.callback = NULL; 2005 + ci_upload.host_tag = cpu_to_le16(MPI3MR_HOSTTAG_INITCMDS); 2006 + ci_upload.function = MPI3_FUNCTION_CI_UPLOAD; 2007 + ci_upload.msg_flags = MPI3_CI_UPLOAD_MSGFLAGS_LOCATION_PRIMARY; 2008 + ci_upload.signature1 = cpu_to_le32(MPI3_IMAGE_HEADER_SIGNATURE1_MANIFEST); 2009 + ci_upload.image_offset = cpu_to_le32(MPI3_IMAGE_HEADER_SIZE); 2010 + ci_upload.segment_size = cpu_to_le32(data_len); 2011 + 2012 + mpi3mr_add_sg_single(&ci_upload.sgl, sgl_flags, data_len, 2013 + data_dma); 2014 + init_completion(&mrioc->init_cmds.done); 2015 + retval = mpi3mr_admin_request_post(mrioc, &ci_upload, 2016 + sizeof(ci_upload), 1); 2017 + if (retval) { 2018 + ioc_err(mrioc, "posting get package version failed\n"); 2019 + goto out_unlock; 2020 + } 2021 + wait_for_completion_timeout(&mrioc->init_cmds.done, 2022 + (MPI3MR_INTADMCMD_TIMEOUT * HZ)); 2023 + if (!(mrioc->init_cmds.state & MPI3MR_CMD_COMPLETE)) { 2024 + ioc_err(mrioc, "get package version timed out\n"); 2025 + mpi3mr_check_rh_fault_ioc(mrioc, 2026 + MPI3MR_RESET_FROM_GETPKGVER_TIMEOUT); 2027 + retval = -1; 2028 + goto out_unlock; 2029 + } 2030 + if ((mrioc->init_cmds.ioc_status & MPI3_IOCSTATUS_STATUS_MASK) 2031 + == MPI3_IOCSTATUS_SUCCESS) { 2032 + manifest = (struct mpi3_ci_manifest_mpi *) data; 2033 + if (manifest->manifest_type == MPI3_CI_MANIFEST_TYPE_MPI) { 2034 + ioc_info(mrioc, 2035 + "firmware package version(%d.%d.%d.%d.%05d-%05d)\n", 2036 + manifest->package_version.gen_major, 2037 + manifest->package_version.gen_minor, 2038 + manifest->package_version.phase_major, 2039 + manifest->package_version.phase_minor, 2040 + manifest->package_version.customer_id, 2041 + manifest->package_version.build_num); 2042 + } 2043 + } 2044 + retval = 0; 2045 + out_unlock: 2046 + mrioc->init_cmds.state = MPI3MR_CMD_NOTUSED; 2047 + mutex_unlock(&mrioc->init_cmds.mutex); 2048 + 2049 + out: 2050 + if (data) 2051 + dma_free_coherent(&mrioc->pdev->dev, data_len, data, 2052 + data_dma); 2053 + return retval; 2054 + } 2055 + 2056 + /** 2279 2057 * mpi3mr_watchdog_work - watchdog thread to monitor faults 2280 2058 * @work: work struct 2281 2059 * ··· 2376 1984 container_of(work, struct mpi3mr_ioc, watchdog_work.work); 2377 1985 unsigned long flags; 2378 1986 enum mpi3mr_iocstate ioc_state; 2379 - u32 fault, host_diagnostic; 1987 + u32 fault, host_diagnostic, ioc_status; 1988 + u32 reset_reason = MPI3MR_RESET_FROM_FAULT_WATCH; 1989 + 1990 + if (mrioc->reset_in_progress || mrioc->unrecoverable) 1991 + return; 2380 1992 2381 1993 if (mrioc->ts_update_counter++ >= MPI3MR_TSUPDATE_INTERVAL) { 2382 1994 mrioc->ts_update_counter = 0; 2383 1995 mpi3mr_sync_timestamp(mrioc); 2384 1996 } 2385 1997 1998 + if ((mrioc->prepare_for_reset) && 1999 + ((mrioc->prepare_for_reset_timeout_counter++) >= 2000 + MPI3MR_PREPARE_FOR_RESET_TIMEOUT)) { 2001 + mpi3mr_soft_reset_handler(mrioc, 2002 + MPI3MR_RESET_FROM_CIACTVRST_TIMER, 1); 2003 + return; 2004 + } 2005 + 2006 + ioc_status = readl(&mrioc->sysif_regs->ioc_status); 2007 + if (ioc_status & MPI3_SYSIF_IOC_STATUS_RESET_HISTORY) { 2008 + mpi3mr_soft_reset_handler(mrioc, MPI3MR_RESET_FROM_FIRMWARE, 0); 2009 + return; 2010 + } 2011 + 2386 2012 /*Check for fault state every one second and issue Soft reset*/ 2387 2013 ioc_state = mpi3mr_get_iocstate(mrioc); 2388 - if (ioc_state == MRIOC_STATE_FAULT) { 2389 - fault = readl(&mrioc->sysif_regs->fault) & 2390 - MPI3_SYSIF_FAULT_CODE_MASK; 2391 - host_diagnostic = readl(&mrioc->sysif_regs->host_diagnostic); 2392 - if (host_diagnostic & MPI3_SYSIF_HOST_DIAG_SAVE_IN_PROGRESS) { 2393 - if (!mrioc->diagsave_timeout) { 2394 - mpi3mr_print_fault_info(mrioc); 2395 - ioc_warn(mrioc, "Diag save in progress\n"); 2396 - } 2397 - if ((mrioc->diagsave_timeout++) <= 2398 - MPI3_SYSIF_DIAG_SAVE_TIMEOUT) 2399 - goto schedule_work; 2400 - } else 2014 + if (ioc_state != MRIOC_STATE_FAULT) 2015 + goto schedule_work; 2016 + 2017 + fault = readl(&mrioc->sysif_regs->fault) & MPI3_SYSIF_FAULT_CODE_MASK; 2018 + host_diagnostic = readl(&mrioc->sysif_regs->host_diagnostic); 2019 + if (host_diagnostic & MPI3_SYSIF_HOST_DIAG_SAVE_IN_PROGRESS) { 2020 + if (!mrioc->diagsave_timeout) { 2401 2021 mpi3mr_print_fault_info(mrioc); 2402 - mrioc->diagsave_timeout = 0; 2403 - 2404 - if (fault == MPI3_SYSIF_FAULT_CODE_FACTORY_RESET) { 2405 - ioc_info(mrioc, 2406 - "Factory Reset fault occurred marking controller as unrecoverable" 2407 - ); 2408 - mrioc->unrecoverable = 1; 2409 - goto out; 2022 + ioc_warn(mrioc, "diag save in progress\n"); 2410 2023 } 2411 - 2412 - if ((fault == MPI3_SYSIF_FAULT_CODE_DIAG_FAULT_RESET) || 2413 - (fault == MPI3_SYSIF_FAULT_CODE_SOFT_RESET_IN_PROGRESS) || 2414 - (mrioc->reset_in_progress)) 2415 - goto out; 2416 - if (fault == MPI3_SYSIF_FAULT_CODE_CI_ACTIVATION_RESET) 2417 - mpi3mr_soft_reset_handler(mrioc, 2418 - MPI3MR_RESET_FROM_CIACTIV_FAULT, 0); 2419 - else 2420 - mpi3mr_soft_reset_handler(mrioc, 2421 - MPI3MR_RESET_FROM_FAULT_WATCH, 0); 2024 + if ((mrioc->diagsave_timeout++) <= MPI3_SYSIF_DIAG_SAVE_TIMEOUT) 2025 + goto schedule_work; 2422 2026 } 2027 + 2028 + mpi3mr_print_fault_info(mrioc); 2029 + mrioc->diagsave_timeout = 0; 2030 + 2031 + switch (fault) { 2032 + case MPI3_SYSIF_FAULT_CODE_POWER_CYCLE_REQUIRED: 2033 + ioc_info(mrioc, 2034 + "controller requires system power cycle, marking controller as unrecoverable\n"); 2035 + mrioc->unrecoverable = 1; 2036 + return; 2037 + case MPI3_SYSIF_FAULT_CODE_SOFT_RESET_IN_PROGRESS: 2038 + return; 2039 + case MPI3_SYSIF_FAULT_CODE_CI_ACTIVATION_RESET: 2040 + reset_reason = MPI3MR_RESET_FROM_CIACTIV_FAULT; 2041 + break; 2042 + default: 2043 + break; 2044 + } 2045 + mpi3mr_soft_reset_handler(mrioc, reset_reason, 0); 2046 + return; 2423 2047 2424 2048 schedule_work: 2425 2049 spin_lock_irqsave(&mrioc->watchdog_lock, flags); ··· 2444 2036 &mrioc->watchdog_work, 2445 2037 msecs_to_jiffies(MPI3MR_WATCHDOG_INTERVAL)); 2446 2038 spin_unlock_irqrestore(&mrioc->watchdog_lock, flags); 2447 - out: 2448 2039 return; 2449 2040 } 2450 2041 ··· 2501 2094 flush_workqueue(wq); 2502 2095 destroy_workqueue(wq); 2503 2096 } 2504 - } 2505 - 2506 - /** 2507 - * mpi3mr_kill_ioc - Kill the controller 2508 - * @mrioc: Adapter instance reference 2509 - * @reason: reason for the failure. 2510 - * 2511 - * If fault debug is enabled, display the fault info else issue 2512 - * diag fault and freeze the system for controller debug 2513 - * purpose. 2514 - * 2515 - * Return: Nothing. 2516 - */ 2517 - static void mpi3mr_kill_ioc(struct mpi3mr_ioc *mrioc, u32 reason) 2518 - { 2519 - enum mpi3mr_iocstate ioc_state; 2520 - 2521 - if (!mrioc->fault_dbg) 2522 - return; 2523 - 2524 - dump_stack(); 2525 - 2526 - ioc_state = mpi3mr_get_iocstate(mrioc); 2527 - if (ioc_state == MRIOC_STATE_FAULT) 2528 - mpi3mr_print_fault_info(mrioc); 2529 - else { 2530 - ioc_err(mrioc, "Firmware is halted due to the reason %d\n", 2531 - reason); 2532 - mpi3mr_diagfault_reset_handler(mrioc, reason); 2533 - } 2534 - if (mrioc->fault_dbg == 2) 2535 - for (;;) 2536 - ; 2537 - else 2538 - panic("panic in %s\n", __func__); 2539 2097 } 2540 2098 2541 2099 /** ··· 2630 2258 wait_for_completion_timeout(&mrioc->init_cmds.done, 2631 2259 (MPI3MR_INTADMCMD_TIMEOUT * HZ)); 2632 2260 if (!(mrioc->init_cmds.state & MPI3MR_CMD_COMPLETE)) { 2633 - ioc_err(mrioc, "Issue IOCFacts: command timed out\n"); 2634 - mpi3mr_set_diagsave(mrioc); 2635 - mpi3mr_issue_reset(mrioc, 2636 - MPI3_SYSIF_HOST_DIAG_RESET_ACTION_DIAG_FAULT, 2261 + ioc_err(mrioc, "ioc_facts timed out\n"); 2262 + mpi3mr_check_rh_fault_ioc(mrioc, 2637 2263 MPI3MR_RESET_FROM_IOCFACTS_TIMEOUT); 2638 - mrioc->unrecoverable = 1; 2639 2264 retval = -1; 2640 2265 goto out_unlock; 2641 2266 } ··· 2646 2277 goto out_unlock; 2647 2278 } 2648 2279 memcpy(facts_data, (u8 *)data, data_len); 2280 + mpi3mr_process_factsdata(mrioc, facts_data); 2649 2281 out_unlock: 2650 2282 mrioc->init_cmds.state = MPI3MR_CMD_NOTUSED; 2651 2283 mutex_unlock(&mrioc->init_cmds.mutex); ··· 2744 2374 mrioc->facts.reply_sz = le16_to_cpu(facts_data->reply_frame_size) * 4; 2745 2375 mrioc->facts.exceptions = le16_to_cpu(facts_data->ioc_exceptions); 2746 2376 mrioc->facts.max_perids = le16_to_cpu(facts_data->max_persistent_id); 2747 - mrioc->facts.max_pds = le16_to_cpu(facts_data->max_pds); 2748 2377 mrioc->facts.max_vds = le16_to_cpu(facts_data->max_vds); 2749 2378 mrioc->facts.max_hpds = le16_to_cpu(facts_data->max_host_pds); 2750 - mrioc->facts.max_advhpds = le16_to_cpu(facts_data->max_advanced_host_pds); 2751 - mrioc->facts.max_raidpds = le16_to_cpu(facts_data->max_raid_pds); 2379 + mrioc->facts.max_advhpds = le16_to_cpu(facts_data->max_adv_host_pds); 2380 + mrioc->facts.max_raid_pds = le16_to_cpu(facts_data->max_raid_pds); 2752 2381 mrioc->facts.max_nvme = le16_to_cpu(facts_data->max_nvme); 2753 2382 mrioc->facts.max_pcie_switches = 2754 - le16_to_cpu(facts_data->max_pc_ie_switches); 2383 + le16_to_cpu(facts_data->max_pcie_switches); 2755 2384 mrioc->facts.max_sasexpanders = 2756 2385 le16_to_cpu(facts_data->max_sas_expanders); 2757 2386 mrioc->facts.max_sasinitiators = ··· 2784 2415 mrioc->facts.ioc_num, mrioc->facts.max_op_req_q, 2785 2416 mrioc->facts.max_op_reply_q, mrioc->facts.max_devhandle); 2786 2417 ioc_info(mrioc, 2787 - "maxreqs(%d), mindh(%d) maxPDs(%d) maxvectors(%d) maxperids(%d)\n", 2418 + "maxreqs(%d), mindh(%d) maxvectors(%d) maxperids(%d)\n", 2788 2419 mrioc->facts.max_reqs, mrioc->facts.min_devhandle, 2789 - mrioc->facts.max_pds, mrioc->facts.max_msix_vectors, 2790 - mrioc->facts.max_perids); 2420 + mrioc->facts.max_msix_vectors, mrioc->facts.max_perids); 2791 2421 ioc_info(mrioc, "SGEModMask 0x%x SGEModVal 0x%x SGEModShift 0x%x ", 2792 2422 mrioc->facts.sge_mod_mask, mrioc->facts.sge_mod_value, 2793 2423 mrioc->facts.sge_mod_shift); 2794 2424 ioc_info(mrioc, "DMA mask %d InitialPE status 0x%x\n", 2795 2425 mrioc->facts.dma_mask, (facts_flags & 2796 2426 MPI3_IOCFACTS_FLAGS_INITIAL_PORT_ENABLE_MASK)); 2797 - 2798 - mrioc->max_host_ios = mrioc->facts.max_reqs - MPI3MR_INTERNAL_CMDS_RESVD; 2799 - 2800 - if (reset_devices) 2801 - mrioc->max_host_ios = min_t(int, mrioc->max_host_ios, 2802 - MPI3MR_HOST_IOS_KDUMP); 2803 2427 } 2804 2428 2805 2429 /** ··· 2808 2446 { 2809 2447 int retval = 0; 2810 2448 u32 sz, i; 2811 - dma_addr_t phy_addr; 2812 2449 2813 2450 if (mrioc->init_cmds.reply) 2814 - goto post_reply_sbuf; 2451 + return retval; 2815 2452 2816 - mrioc->init_cmds.reply = kzalloc(mrioc->facts.reply_sz, GFP_KERNEL); 2453 + mrioc->init_cmds.reply = kzalloc(mrioc->reply_sz, GFP_KERNEL); 2817 2454 if (!mrioc->init_cmds.reply) 2818 2455 goto out_failed; 2819 2456 2820 2457 for (i = 0; i < MPI3MR_NUM_DEVRMCMD; i++) { 2821 - mrioc->dev_rmhs_cmds[i].reply = kzalloc(mrioc->facts.reply_sz, 2458 + mrioc->dev_rmhs_cmds[i].reply = kzalloc(mrioc->reply_sz, 2822 2459 GFP_KERNEL); 2823 2460 if (!mrioc->dev_rmhs_cmds[i].reply) 2824 2461 goto out_failed; 2825 2462 } 2826 2463 2827 - mrioc->host_tm_cmds.reply = kzalloc(mrioc->facts.reply_sz, GFP_KERNEL); 2464 + for (i = 0; i < MPI3MR_NUM_EVTACKCMD; i++) { 2465 + mrioc->evtack_cmds[i].reply = kzalloc(mrioc->reply_sz, 2466 + GFP_KERNEL); 2467 + if (!mrioc->evtack_cmds[i].reply) 2468 + goto out_failed; 2469 + } 2470 + 2471 + mrioc->host_tm_cmds.reply = kzalloc(mrioc->reply_sz, GFP_KERNEL); 2828 2472 if (!mrioc->host_tm_cmds.reply) 2829 2473 goto out_failed; 2830 2474 ··· 2850 2482 if (!mrioc->devrem_bitmap) 2851 2483 goto out_failed; 2852 2484 2485 + mrioc->evtack_cmds_bitmap_sz = MPI3MR_NUM_EVTACKCMD / 8; 2486 + if (MPI3MR_NUM_EVTACKCMD % 8) 2487 + mrioc->evtack_cmds_bitmap_sz++; 2488 + mrioc->evtack_cmds_bitmap = kzalloc(mrioc->evtack_cmds_bitmap_sz, 2489 + GFP_KERNEL); 2490 + if (!mrioc->evtack_cmds_bitmap) 2491 + goto out_failed; 2492 + 2853 2493 mrioc->num_reply_bufs = mrioc->facts.max_reqs + MPI3MR_NUM_EVT_REPLIES; 2854 2494 mrioc->reply_free_qsz = mrioc->num_reply_bufs + 1; 2855 2495 mrioc->num_sense_bufs = mrioc->facts.max_reqs / MPI3MR_SENSEBUF_FACTOR; 2856 2496 mrioc->sense_buf_q_sz = mrioc->num_sense_bufs + 1; 2857 2497 2858 2498 /* reply buffer pool, 16 byte align */ 2859 - sz = mrioc->num_reply_bufs * mrioc->facts.reply_sz; 2499 + sz = mrioc->num_reply_bufs * mrioc->reply_sz; 2860 2500 mrioc->reply_buf_pool = dma_pool_create("reply_buf pool", 2861 2501 &mrioc->pdev->dev, sz, 16, 0); 2862 2502 if (!mrioc->reply_buf_pool) { ··· 2893 2517 goto out_failed; 2894 2518 2895 2519 /* sense buffer pool, 4 byte align */ 2896 - sz = mrioc->num_sense_bufs * MPI3MR_SENSEBUF_SZ; 2520 + sz = mrioc->num_sense_bufs * MPI3MR_SENSE_BUF_SZ; 2897 2521 mrioc->sense_buf_pool = dma_pool_create("sense_buf pool", 2898 2522 &mrioc->pdev->dev, sz, 4, 0); 2899 2523 if (!mrioc->sense_buf_pool) { ··· 2918 2542 if (!mrioc->sense_buf_q) 2919 2543 goto out_failed; 2920 2544 2921 - post_reply_sbuf: 2922 - sz = mrioc->num_reply_bufs * mrioc->facts.reply_sz; 2545 + return retval; 2546 + 2547 + out_failed: 2548 + retval = -1; 2549 + return retval; 2550 + } 2551 + 2552 + /** 2553 + * mpimr_initialize_reply_sbuf_queues - initialize reply sense 2554 + * buffers 2555 + * @mrioc: Adapter instance reference 2556 + * 2557 + * Helper function to initialize reply and sense buffers along 2558 + * with some debug prints. 2559 + * 2560 + * Return: None. 2561 + */ 2562 + static void mpimr_initialize_reply_sbuf_queues(struct mpi3mr_ioc *mrioc) 2563 + { 2564 + u32 sz, i; 2565 + dma_addr_t phy_addr; 2566 + 2567 + sz = mrioc->num_reply_bufs * mrioc->reply_sz; 2923 2568 ioc_info(mrioc, 2924 2569 "reply buf pool(0x%p): depth(%d), frame_size(%d), pool_size(%d kB), reply_dma(0x%llx)\n", 2925 - mrioc->reply_buf, mrioc->num_reply_bufs, mrioc->facts.reply_sz, 2570 + mrioc->reply_buf, mrioc->num_reply_bufs, mrioc->reply_sz, 2926 2571 (sz / 1024), (unsigned long long)mrioc->reply_buf_dma); 2927 2572 sz = mrioc->reply_free_qsz * 8; 2928 2573 ioc_info(mrioc, 2929 2574 "reply_free_q pool(0x%p): depth(%d), frame_size(%d), pool_size(%d kB), reply_dma(0x%llx)\n", 2930 2575 mrioc->reply_free_q, mrioc->reply_free_qsz, 8, (sz / 1024), 2931 2576 (unsigned long long)mrioc->reply_free_q_dma); 2932 - sz = mrioc->num_sense_bufs * MPI3MR_SENSEBUF_SZ; 2577 + sz = mrioc->num_sense_bufs * MPI3MR_SENSE_BUF_SZ; 2933 2578 ioc_info(mrioc, 2934 2579 "sense_buf pool(0x%p): depth(%d), frame_size(%d), pool_size(%d kB), sense_dma(0x%llx)\n", 2935 - mrioc->sense_buf, mrioc->num_sense_bufs, MPI3MR_SENSEBUF_SZ, 2580 + mrioc->sense_buf, mrioc->num_sense_bufs, MPI3MR_SENSE_BUF_SZ, 2936 2581 (sz / 1024), (unsigned long long)mrioc->sense_buf_dma); 2937 2582 sz = mrioc->sense_buf_q_sz * 8; 2938 2583 ioc_info(mrioc, ··· 2963 2566 2964 2567 /* initialize Reply buffer Queue */ 2965 2568 for (i = 0, phy_addr = mrioc->reply_buf_dma; 2966 - i < mrioc->num_reply_bufs; i++, phy_addr += mrioc->facts.reply_sz) 2569 + i < mrioc->num_reply_bufs; i++, phy_addr += mrioc->reply_sz) 2967 2570 mrioc->reply_free_q[i] = cpu_to_le64(phy_addr); 2968 2571 mrioc->reply_free_q[i] = cpu_to_le64(0); 2969 2572 2970 2573 /* initialize Sense Buffer Queue */ 2971 2574 for (i = 0, phy_addr = mrioc->sense_buf_dma; 2972 - i < mrioc->num_sense_bufs; i++, phy_addr += MPI3MR_SENSEBUF_SZ) 2575 + i < mrioc->num_sense_bufs; i++, phy_addr += MPI3MR_SENSE_BUF_SZ) 2973 2576 mrioc->sense_buf_q[i] = cpu_to_le64(phy_addr); 2974 2577 mrioc->sense_buf_q[i] = cpu_to_le64(0); 2975 - return retval; 2976 - 2977 - out_failed: 2978 - retval = -1; 2979 - return retval; 2980 2578 } 2981 2579 2982 2580 /** ··· 2998 2606 retval = -1; 2999 2607 goto out; 3000 2608 } 2609 + mpimr_initialize_reply_sbuf_queues(mrioc); 2610 + 3001 2611 drv_info->information_length = cpu_to_le32(data_len); 3002 2612 strscpy(drv_info->driver_signature, "Broadcom", sizeof(drv_info->driver_signature)); 3003 2613 strscpy(drv_info->os_name, utsname()->sysname, sizeof(drv_info->os_name)); ··· 3033 2639 iocinit_req.reply_free_queue_depth = cpu_to_le16(mrioc->reply_free_qsz); 3034 2640 iocinit_req.reply_free_queue_address = 3035 2641 cpu_to_le64(mrioc->reply_free_q_dma); 3036 - iocinit_req.sense_buffer_length = cpu_to_le16(MPI3MR_SENSEBUF_SZ); 2642 + iocinit_req.sense_buffer_length = cpu_to_le16(MPI3MR_SENSE_BUF_SZ); 3037 2643 iocinit_req.sense_buffer_free_queue_depth = 3038 2644 cpu_to_le16(mrioc->sense_buf_q_sz); 3039 2645 iocinit_req.sense_buffer_free_queue_address = ··· 3053 2659 wait_for_completion_timeout(&mrioc->init_cmds.done, 3054 2660 (MPI3MR_INTADMCMD_TIMEOUT * HZ)); 3055 2661 if (!(mrioc->init_cmds.state & MPI3MR_CMD_COMPLETE)) { 3056 - mpi3mr_set_diagsave(mrioc); 3057 - mpi3mr_issue_reset(mrioc, 3058 - MPI3_SYSIF_HOST_DIAG_RESET_ACTION_DIAG_FAULT, 2662 + mpi3mr_check_rh_fault_ioc(mrioc, 3059 2663 MPI3MR_RESET_FROM_IOCINIT_TIMEOUT); 3060 - mrioc->unrecoverable = 1; 3061 - ioc_err(mrioc, "Issue IOCInit: command timed out\n"); 2664 + ioc_err(mrioc, "ioc_init timed out\n"); 3062 2665 retval = -1; 3063 2666 goto out_unlock; 3064 2667 } ··· 3069 2678 goto out_unlock; 3070 2679 } 3071 2680 2681 + mrioc->reply_free_queue_host_index = mrioc->num_reply_bufs; 2682 + writel(mrioc->reply_free_queue_host_index, 2683 + &mrioc->sysif_regs->reply_free_host_index); 2684 + 2685 + mrioc->sbq_host_index = mrioc->num_sense_bufs; 2686 + writel(mrioc->sbq_host_index, 2687 + &mrioc->sysif_regs->sense_buffer_free_host_index); 3072 2688 out_unlock: 3073 2689 mrioc->init_cmds.state = MPI3MR_CMD_NOTUSED; 3074 2690 mutex_unlock(&mrioc->init_cmds.mutex); ··· 3153 2755 wait_for_completion_timeout(&mrioc->init_cmds.done, 3154 2756 (MPI3MR_INTADMCMD_TIMEOUT * HZ)); 3155 2757 if (!(mrioc->init_cmds.state & MPI3MR_CMD_COMPLETE)) { 3156 - ioc_err(mrioc, "Issue EvtNotify: command timed out\n"); 3157 - mpi3mr_set_diagsave(mrioc); 3158 - mpi3mr_issue_reset(mrioc, 3159 - MPI3_SYSIF_HOST_DIAG_RESET_ACTION_DIAG_FAULT, 2758 + ioc_err(mrioc, "event notification timed out\n"); 2759 + mpi3mr_check_rh_fault_ioc(mrioc, 3160 2760 MPI3MR_RESET_FROM_EVTNOTIFY_TIMEOUT); 3161 - mrioc->unrecoverable = 1; 3162 2761 retval = -1; 3163 2762 goto out_unlock; 3164 2763 } ··· 3177 2782 } 3178 2783 3179 2784 /** 3180 - * mpi3mr_send_event_ack - Send event acknowledgment 2785 + * mpi3mr_process_event_ack - Process event acknowledgment 3181 2786 * @mrioc: Adapter instance reference 3182 2787 * @event: MPI3 event ID 3183 - * @event_ctx: Event context 2788 + * @event_ctx: event context 3184 2789 * 3185 2790 * Send event acknowledgment through admin queue and wait for 3186 2791 * it to complete. 3187 2792 * 3188 2793 * Return: 0 on success, non-zero on failures. 3189 2794 */ 3190 - int mpi3mr_send_event_ack(struct mpi3mr_ioc *mrioc, u8 event, 2795 + int mpi3mr_process_event_ack(struct mpi3mr_ioc *mrioc, u8 event, 3191 2796 u32 event_ctx) 3192 2797 { 3193 2798 struct mpi3_event_ack_request evtack_req; ··· 3220 2825 (MPI3MR_INTADMCMD_TIMEOUT * HZ)); 3221 2826 if (!(mrioc->init_cmds.state & MPI3MR_CMD_COMPLETE)) { 3222 2827 ioc_err(mrioc, "Issue EvtNotify: command timed out\n"); 3223 - mpi3mr_soft_reset_handler(mrioc, 3224 - MPI3MR_RESET_FROM_EVTACK_TIMEOUT, 1); 2828 + if (!(mrioc->init_cmds.state & MPI3MR_CMD_RESET)) 2829 + mpi3mr_soft_reset_handler(mrioc, 2830 + MPI3MR_RESET_FROM_EVTACK_TIMEOUT, 1); 3225 2831 retval = -1; 3226 2832 goto out_unlock; 3227 2833 } ··· 3258 2862 int retval = 0; 3259 2863 u32 sz, i; 3260 2864 u16 num_chains; 2865 + 2866 + if (mrioc->chain_sgl_list) 2867 + return retval; 3261 2868 3262 2869 num_chains = mrioc->max_host_ios / MPI3MR_CHAINBUF_FACTOR; 3263 2870 ··· 3365 2966 ioc_err(mrioc, "Issue PortEnable: Admin Post failed\n"); 3366 2967 goto out_unlock; 3367 2968 } 3368 - if (!async) { 3369 - wait_for_completion_timeout(&mrioc->init_cmds.done, 3370 - (pe_timeout * HZ)); 3371 - if (!(mrioc->init_cmds.state & MPI3MR_CMD_COMPLETE)) { 3372 - ioc_err(mrioc, "Issue PortEnable: command timed out\n"); 3373 - retval = -1; 3374 - mrioc->scan_failed = MPI3_IOCSTATUS_INTERNAL_ERROR; 3375 - mpi3mr_set_diagsave(mrioc); 3376 - mpi3mr_issue_reset(mrioc, 3377 - MPI3_SYSIF_HOST_DIAG_RESET_ACTION_DIAG_FAULT, 3378 - MPI3MR_RESET_FROM_PE_TIMEOUT); 3379 - mrioc->unrecoverable = 1; 3380 - goto out_unlock; 3381 - } 3382 - mpi3mr_port_enable_complete(mrioc, &mrioc->init_cmds); 2969 + if (async) { 2970 + mutex_unlock(&mrioc->init_cmds.mutex); 2971 + goto out; 3383 2972 } 2973 + 2974 + wait_for_completion_timeout(&mrioc->init_cmds.done, (pe_timeout * HZ)); 2975 + if (!(mrioc->init_cmds.state & MPI3MR_CMD_COMPLETE)) { 2976 + ioc_err(mrioc, "port enable timed out\n"); 2977 + retval = -1; 2978 + mpi3mr_check_rh_fault_ioc(mrioc, MPI3MR_RESET_FROM_PE_TIMEOUT); 2979 + goto out_unlock; 2980 + } 2981 + mpi3mr_port_enable_complete(mrioc, &mrioc->init_cmds); 2982 + 3384 2983 out_unlock: 2984 + mrioc->init_cmds.state = MPI3MR_CMD_NOTUSED; 3385 2985 mutex_unlock(&mrioc->init_cmds.mutex); 3386 2986 out: 3387 2987 return retval; 3388 2988 } 3389 2989 3390 - /* Protocol type to name mapper structure*/ 2990 + /* Protocol type to name mapper structure */ 3391 2991 static const struct { 3392 2992 u8 protocol; 3393 2993 char *name; ··· 3579 3181 mrioc->sysif_regs, memap_sz); 3580 3182 ioc_info(mrioc, "Number of MSI-X vectors found in capabilities: (%d)\n", 3581 3183 mrioc->msix_count); 3184 + 3185 + if (!reset_devices && poll_queues > 0) 3186 + mrioc->requested_poll_qcount = min_t(int, poll_queues, 3187 + mrioc->msix_count - 2); 3582 3188 return retval; 3583 3189 3584 3190 out_failed: 3585 3191 mpi3mr_cleanup_resources(mrioc); 3192 + return retval; 3193 + } 3194 + 3195 + /** 3196 + * mpi3mr_enable_events - Enable required events 3197 + * @mrioc: Adapter instance reference 3198 + * 3199 + * This routine unmasks the events required by the driver by 3200 + * sennding appropriate event mask bitmapt through an event 3201 + * notification request. 3202 + * 3203 + * Return: 0 on success and non-zero on failure. 3204 + */ 3205 + static int mpi3mr_enable_events(struct mpi3mr_ioc *mrioc) 3206 + { 3207 + int retval = 0; 3208 + u32 i; 3209 + 3210 + for (i = 0; i < MPI3_EVENT_NOTIFY_EVENTMASK_WORDS; i++) 3211 + mrioc->event_masks[i] = -1; 3212 + 3213 + mpi3mr_unmask_events(mrioc, MPI3_EVENT_DEVICE_ADDED); 3214 + mpi3mr_unmask_events(mrioc, MPI3_EVENT_DEVICE_INFO_CHANGED); 3215 + mpi3mr_unmask_events(mrioc, MPI3_EVENT_DEVICE_STATUS_CHANGE); 3216 + mpi3mr_unmask_events(mrioc, MPI3_EVENT_ENCL_DEVICE_STATUS_CHANGE); 3217 + mpi3mr_unmask_events(mrioc, MPI3_EVENT_SAS_TOPOLOGY_CHANGE_LIST); 3218 + mpi3mr_unmask_events(mrioc, MPI3_EVENT_SAS_DISCOVERY); 3219 + mpi3mr_unmask_events(mrioc, MPI3_EVENT_SAS_DEVICE_DISCOVERY_ERROR); 3220 + mpi3mr_unmask_events(mrioc, MPI3_EVENT_SAS_BROADCAST_PRIMITIVE); 3221 + mpi3mr_unmask_events(mrioc, MPI3_EVENT_PCIE_TOPOLOGY_CHANGE_LIST); 3222 + mpi3mr_unmask_events(mrioc, MPI3_EVENT_PCIE_ENUMERATION); 3223 + mpi3mr_unmask_events(mrioc, MPI3_EVENT_PREPARE_FOR_RESET); 3224 + mpi3mr_unmask_events(mrioc, MPI3_EVENT_CABLE_MGMT); 3225 + mpi3mr_unmask_events(mrioc, MPI3_EVENT_ENERGY_PACK_CHANGE); 3226 + mpi3mr_unmask_events(mrioc, MPI3_EVENT_TEMP_THRESHOLD); 3227 + 3228 + retval = mpi3mr_issue_event_notification(mrioc); 3229 + if (retval) 3230 + ioc_err(mrioc, "failed to issue event notification %d\n", 3231 + retval); 3586 3232 return retval; 3587 3233 } 3588 3234 ··· 3646 3204 * 3647 3205 * Return: 0 on success and non-zero on failure. 3648 3206 */ 3649 - int mpi3mr_init_ioc(struct mpi3mr_ioc *mrioc, u8 init_type) 3207 + int mpi3mr_init_ioc(struct mpi3mr_ioc *mrioc) 3650 3208 { 3651 3209 int retval = 0; 3652 - enum mpi3mr_iocstate ioc_state; 3653 - u64 base_info; 3654 - u32 timeout; 3655 - u32 ioc_status, ioc_config, i; 3210 + u8 retry = 0; 3656 3211 struct mpi3_ioc_facts_data facts_data; 3657 3212 3658 - mrioc->irqpoll_sleep = MPI3MR_IRQ_POLL_SLEEP; 3659 - mrioc->change_count = 0; 3660 - if (init_type == MPI3MR_IT_INIT) { 3661 - mrioc->cpu_count = num_online_cpus(); 3662 - retval = mpi3mr_setup_resources(mrioc); 3663 - if (retval) { 3664 - ioc_err(mrioc, "Failed to setup resources:error %d\n", 3665 - retval); 3666 - goto out_nocleanup; 3667 - } 3668 - } 3669 - 3670 - ioc_status = readl(&mrioc->sysif_regs->ioc_status); 3671 - ioc_config = readl(&mrioc->sysif_regs->ioc_configuration); 3672 - 3673 - ioc_info(mrioc, "SOD status %x configuration %x\n", 3674 - ioc_status, ioc_config); 3675 - 3676 - base_info = lo_hi_readq(&mrioc->sysif_regs->ioc_information); 3677 - ioc_info(mrioc, "SOD base_info %llx\n", base_info); 3678 - 3679 - /*The timeout value is in 2sec unit, changing it to seconds*/ 3680 - mrioc->ready_timeout = 3681 - ((base_info & MPI3_SYSIF_IOC_INFO_LOW_TIMEOUT_MASK) >> 3682 - MPI3_SYSIF_IOC_INFO_LOW_TIMEOUT_SHIFT) * 2; 3683 - 3684 - ioc_info(mrioc, "IOC ready timeout %d\n", mrioc->ready_timeout); 3685 - 3686 - ioc_state = mpi3mr_get_iocstate(mrioc); 3687 - ioc_info(mrioc, "IOC in %s state during detection\n", 3688 - mpi3mr_iocstate_name(ioc_state)); 3689 - 3690 - if (ioc_state == MRIOC_STATE_BECOMING_READY || 3691 - ioc_state == MRIOC_STATE_RESET_REQUESTED) { 3692 - timeout = mrioc->ready_timeout * 10; 3693 - do { 3694 - msleep(100); 3695 - } while (--timeout); 3696 - 3697 - ioc_state = mpi3mr_get_iocstate(mrioc); 3698 - ioc_info(mrioc, 3699 - "IOC in %s state after waiting for reset time\n", 3700 - mpi3mr_iocstate_name(ioc_state)); 3701 - } 3702 - 3703 - if (ioc_state == MRIOC_STATE_READY) { 3704 - retval = mpi3mr_issue_and_process_mur(mrioc, 3705 - MPI3MR_RESET_FROM_BRINGUP); 3706 - if (retval) { 3707 - ioc_err(mrioc, "Failed to MU reset IOC error %d\n", 3708 - retval); 3709 - } 3710 - ioc_state = mpi3mr_get_iocstate(mrioc); 3711 - } 3712 - if (ioc_state != MRIOC_STATE_RESET) { 3713 - mpi3mr_print_fault_info(mrioc); 3714 - retval = mpi3mr_issue_reset(mrioc, 3715 - MPI3_SYSIF_HOST_DIAG_RESET_ACTION_SOFT_RESET, 3716 - MPI3MR_RESET_FROM_BRINGUP); 3717 - if (retval) { 3718 - ioc_err(mrioc, 3719 - "%s :Failed to soft reset IOC error %d\n", 3720 - __func__, retval); 3721 - goto out_failed; 3722 - } 3723 - } 3724 - ioc_state = mpi3mr_get_iocstate(mrioc); 3725 - if (ioc_state != MRIOC_STATE_RESET) { 3726 - retval = -1; 3727 - ioc_err(mrioc, "Cannot bring IOC to reset state\n"); 3728 - goto out_failed; 3729 - } 3730 - 3731 - retval = mpi3mr_setup_admin_qpair(mrioc); 3732 - if (retval) { 3733 - ioc_err(mrioc, "Failed to setup admin Qs: error %d\n", 3734 - retval); 3735 - goto out_failed; 3736 - } 3737 - 3213 + retry_init: 3738 3214 retval = mpi3mr_bring_ioc_ready(mrioc); 3739 3215 if (retval) { 3740 3216 ioc_err(mrioc, "Failed to bring ioc ready: error %d\n", 3741 3217 retval); 3742 - goto out_failed; 3218 + goto out_failed_noretry; 3743 3219 } 3744 3220 3745 - if (init_type != MPI3MR_IT_RESET) { 3746 - retval = mpi3mr_setup_isr(mrioc, 1); 3747 - if (retval) { 3748 - ioc_err(mrioc, "Failed to setup ISR error %d\n", 3749 - retval); 3750 - goto out_failed; 3751 - } 3752 - } else 3753 - mpi3mr_ioc_enable_intr(mrioc); 3221 + retval = mpi3mr_setup_isr(mrioc, 1); 3222 + if (retval) { 3223 + ioc_err(mrioc, "Failed to setup ISR error %d\n", 3224 + retval); 3225 + goto out_failed_noretry; 3226 + } 3754 3227 3755 3228 retval = mpi3mr_issue_iocfacts(mrioc, &facts_data); 3756 3229 if (retval) { ··· 3674 3317 goto out_failed; 3675 3318 } 3676 3319 3677 - mpi3mr_process_factsdata(mrioc, &facts_data); 3678 - if (init_type == MPI3MR_IT_INIT) { 3679 - retval = mpi3mr_check_reset_dma_mask(mrioc); 3680 - if (retval) { 3681 - ioc_err(mrioc, "Resetting dma mask failed %d\n", 3682 - retval); 3683 - goto out_failed; 3684 - } 3320 + mrioc->max_host_ios = mrioc->facts.max_reqs - MPI3MR_INTERNAL_CMDS_RESVD; 3321 + 3322 + if (reset_devices) 3323 + mrioc->max_host_ios = min_t(int, mrioc->max_host_ios, 3324 + MPI3MR_HOST_IOS_KDUMP); 3325 + 3326 + mrioc->reply_sz = mrioc->facts.reply_sz; 3327 + 3328 + retval = mpi3mr_check_reset_dma_mask(mrioc); 3329 + if (retval) { 3330 + ioc_err(mrioc, "Resetting dma mask failed %d\n", 3331 + retval); 3332 + goto out_failed_noretry; 3685 3333 } 3686 3334 3687 3335 mpi3mr_print_ioc_info(mrioc); ··· 3696 3334 ioc_err(mrioc, 3697 3335 "%s :Failed to allocated reply sense buffers %d\n", 3698 3336 __func__, retval); 3699 - goto out_failed; 3337 + goto out_failed_noretry; 3700 3338 } 3701 3339 3702 - if (init_type == MPI3MR_IT_INIT) { 3703 - retval = mpi3mr_alloc_chain_bufs(mrioc); 3704 - if (retval) { 3705 - ioc_err(mrioc, "Failed to allocated chain buffers %d\n", 3706 - retval); 3707 - goto out_failed; 3708 - } 3340 + retval = mpi3mr_alloc_chain_bufs(mrioc); 3341 + if (retval) { 3342 + ioc_err(mrioc, "Failed to allocated chain buffers %d\n", 3343 + retval); 3344 + goto out_failed_noretry; 3709 3345 } 3710 3346 3711 3347 retval = mpi3mr_issue_iocinit(mrioc); ··· 3712 3352 retval); 3713 3353 goto out_failed; 3714 3354 } 3715 - mrioc->reply_free_queue_host_index = mrioc->num_reply_bufs; 3716 - writel(mrioc->reply_free_queue_host_index, 3717 - &mrioc->sysif_regs->reply_free_host_index); 3718 3355 3719 - mrioc->sbq_host_index = mrioc->num_sense_bufs; 3720 - writel(mrioc->sbq_host_index, 3721 - &mrioc->sysif_regs->sense_buffer_free_host_index); 3356 + retval = mpi3mr_print_pkg_ver(mrioc); 3357 + if (retval) { 3358 + ioc_err(mrioc, "failed to get package version\n"); 3359 + goto out_failed; 3360 + } 3722 3361 3723 - if (init_type != MPI3MR_IT_RESET) { 3724 - retval = mpi3mr_setup_isr(mrioc, 0); 3725 - if (retval) { 3726 - ioc_err(mrioc, "Failed to re-setup ISR, error %d\n", 3727 - retval); 3728 - goto out_failed; 3729 - } 3362 + retval = mpi3mr_setup_isr(mrioc, 0); 3363 + if (retval) { 3364 + ioc_err(mrioc, "Failed to re-setup ISR, error %d\n", 3365 + retval); 3366 + goto out_failed_noretry; 3730 3367 } 3731 3368 3732 3369 retval = mpi3mr_create_op_queues(mrioc); ··· 3733 3376 goto out_failed; 3734 3377 } 3735 3378 3736 - if ((init_type != MPI3MR_IT_INIT) && 3737 - (mrioc->shost->nr_hw_queues > mrioc->num_op_reply_q)) { 3738 - retval = -1; 3739 - ioc_err(mrioc, 3740 - "Cannot create minimum number of OpQueues expected:%d created:%d\n", 3741 - mrioc->shost->nr_hw_queues, mrioc->num_op_reply_q); 3742 - goto out_failed; 3743 - } 3744 - 3745 - for (i = 0; i < MPI3_EVENT_NOTIFY_EVENTMASK_WORDS; i++) 3746 - mrioc->event_masks[i] = -1; 3747 - 3748 - mpi3mr_unmask_events(mrioc, MPI3_EVENT_DEVICE_ADDED); 3749 - mpi3mr_unmask_events(mrioc, MPI3_EVENT_DEVICE_INFO_CHANGED); 3750 - mpi3mr_unmask_events(mrioc, MPI3_EVENT_DEVICE_STATUS_CHANGE); 3751 - mpi3mr_unmask_events(mrioc, MPI3_EVENT_ENCL_DEVICE_STATUS_CHANGE); 3752 - mpi3mr_unmask_events(mrioc, MPI3_EVENT_SAS_TOPOLOGY_CHANGE_LIST); 3753 - mpi3mr_unmask_events(mrioc, MPI3_EVENT_SAS_DISCOVERY); 3754 - mpi3mr_unmask_events(mrioc, MPI3_EVENT_SAS_DEVICE_DISCOVERY_ERROR); 3755 - mpi3mr_unmask_events(mrioc, MPI3_EVENT_SAS_BROADCAST_PRIMITIVE); 3756 - mpi3mr_unmask_events(mrioc, MPI3_EVENT_PCIE_TOPOLOGY_CHANGE_LIST); 3757 - mpi3mr_unmask_events(mrioc, MPI3_EVENT_PCIE_ENUMERATION); 3758 - mpi3mr_unmask_events(mrioc, MPI3_EVENT_CABLE_MGMT); 3759 - mpi3mr_unmask_events(mrioc, MPI3_EVENT_ENERGY_PACK_CHANGE); 3760 - 3761 - retval = mpi3mr_issue_event_notification(mrioc); 3379 + retval = mpi3mr_enable_events(mrioc); 3762 3380 if (retval) { 3763 - ioc_err(mrioc, "Failed to issue event notification %d\n", 3381 + ioc_err(mrioc, "failed to enable events %d\n", 3764 3382 retval); 3765 3383 goto out_failed; 3766 3384 } 3767 3385 3768 - if (init_type != MPI3MR_IT_INIT) { 3769 - ioc_info(mrioc, "Issuing Port Enable\n"); 3770 - retval = mpi3mr_issue_port_enable(mrioc, 0); 3386 + ioc_info(mrioc, "controller initialization completed successfully\n"); 3387 + return retval; 3388 + out_failed: 3389 + if (retry < 2) { 3390 + retry++; 3391 + ioc_warn(mrioc, "retrying controller initialization, retry_count:%d\n", 3392 + retry); 3393 + mpi3mr_memset_buffers(mrioc); 3394 + goto retry_init; 3395 + } 3396 + out_failed_noretry: 3397 + ioc_err(mrioc, "controller initialization failed\n"); 3398 + mpi3mr_issue_reset(mrioc, MPI3_SYSIF_HOST_DIAG_RESET_ACTION_DIAG_FAULT, 3399 + MPI3MR_RESET_FROM_CTLR_CLEANUP); 3400 + mrioc->unrecoverable = 1; 3401 + return retval; 3402 + } 3403 + 3404 + /** 3405 + * mpi3mr_reinit_ioc - Re-Initialize the controller 3406 + * @mrioc: Adapter instance reference 3407 + * @is_resume: Called from resume or reset path 3408 + * 3409 + * This the controller re-initialization routine, executed from 3410 + * the soft reset handler or resume callback. Creates 3411 + * operational reply queue pairs, allocate required memory for 3412 + * reply pool, sense buffer pool, issue IOC init request to the 3413 + * firmware, unmask the events and issue port enable to discover 3414 + * SAS/SATA/NVMe devices and RAID volumes. 3415 + * 3416 + * Return: 0 on success and non-zero on failure. 3417 + */ 3418 + int mpi3mr_reinit_ioc(struct mpi3mr_ioc *mrioc, u8 is_resume) 3419 + { 3420 + int retval = 0; 3421 + u8 retry = 0; 3422 + struct mpi3_ioc_facts_data facts_data; 3423 + 3424 + retry_init: 3425 + dprint_reset(mrioc, "bringing up the controller to ready state\n"); 3426 + retval = mpi3mr_bring_ioc_ready(mrioc); 3427 + if (retval) { 3428 + ioc_err(mrioc, "failed to bring to ready state\n"); 3429 + goto out_failed_noretry; 3430 + } 3431 + 3432 + if (is_resume) { 3433 + dprint_reset(mrioc, "setting up single ISR\n"); 3434 + retval = mpi3mr_setup_isr(mrioc, 1); 3771 3435 if (retval) { 3772 - ioc_err(mrioc, "Failed to issue port enable %d\n", 3773 - retval); 3774 - goto out_failed; 3436 + ioc_err(mrioc, "failed to setup ISR\n"); 3437 + goto out_failed_noretry; 3438 + } 3439 + } else 3440 + mpi3mr_ioc_enable_intr(mrioc); 3441 + 3442 + dprint_reset(mrioc, "getting ioc_facts\n"); 3443 + retval = mpi3mr_issue_iocfacts(mrioc, &facts_data); 3444 + if (retval) { 3445 + ioc_err(mrioc, "failed to get ioc_facts\n"); 3446 + goto out_failed; 3447 + } 3448 + 3449 + dprint_reset(mrioc, "validating ioc_facts\n"); 3450 + retval = mpi3mr_revalidate_factsdata(mrioc); 3451 + if (retval) { 3452 + ioc_err(mrioc, "failed to revalidate ioc_facts data\n"); 3453 + goto out_failed_noretry; 3454 + } 3455 + 3456 + mpi3mr_print_ioc_info(mrioc); 3457 + 3458 + dprint_reset(mrioc, "sending ioc_init\n"); 3459 + retval = mpi3mr_issue_iocinit(mrioc); 3460 + if (retval) { 3461 + ioc_err(mrioc, "failed to send ioc_init\n"); 3462 + goto out_failed; 3463 + } 3464 + 3465 + dprint_reset(mrioc, "getting package version\n"); 3466 + retval = mpi3mr_print_pkg_ver(mrioc); 3467 + if (retval) { 3468 + ioc_err(mrioc, "failed to get package version\n"); 3469 + goto out_failed; 3470 + } 3471 + 3472 + if (is_resume) { 3473 + dprint_reset(mrioc, "setting up multiple ISR\n"); 3474 + retval = mpi3mr_setup_isr(mrioc, 0); 3475 + if (retval) { 3476 + ioc_err(mrioc, "failed to re-setup ISR\n"); 3477 + goto out_failed_noretry; 3775 3478 } 3776 3479 } 3777 - return retval; 3778 3480 3481 + dprint_reset(mrioc, "creating operational queue pairs\n"); 3482 + retval = mpi3mr_create_op_queues(mrioc); 3483 + if (retval) { 3484 + ioc_err(mrioc, "failed to create operational queue pairs\n"); 3485 + goto out_failed; 3486 + } 3487 + 3488 + if (mrioc->shost->nr_hw_queues > mrioc->num_op_reply_q) { 3489 + ioc_err(mrioc, 3490 + "cannot create minimum number of operatioanl queues expected:%d created:%d\n", 3491 + mrioc->shost->nr_hw_queues, mrioc->num_op_reply_q); 3492 + goto out_failed_noretry; 3493 + } 3494 + 3495 + dprint_reset(mrioc, "enabling events\n"); 3496 + retval = mpi3mr_enable_events(mrioc); 3497 + if (retval) { 3498 + ioc_err(mrioc, "failed to enable events\n"); 3499 + goto out_failed; 3500 + } 3501 + 3502 + ioc_info(mrioc, "sending port enable\n"); 3503 + retval = mpi3mr_issue_port_enable(mrioc, 0); 3504 + if (retval) { 3505 + ioc_err(mrioc, "failed to issue port enable\n"); 3506 + goto out_failed; 3507 + } 3508 + 3509 + ioc_info(mrioc, "controller %s completed successfully\n", 3510 + (is_resume)?"resume":"re-initialization"); 3511 + return retval; 3779 3512 out_failed: 3780 - if (init_type == MPI3MR_IT_INIT) 3781 - mpi3mr_cleanup_ioc(mrioc, MPI3MR_COMPLETE_CLEANUP); 3782 - else 3783 - mpi3mr_cleanup_ioc(mrioc, MPI3MR_REINIT_FAILURE); 3784 - out_nocleanup: 3513 + if (retry < 2) { 3514 + retry++; 3515 + ioc_warn(mrioc, "retrying controller %s, retry_count:%d\n", 3516 + (is_resume)?"resume":"re-initialization", retry); 3517 + mpi3mr_memset_buffers(mrioc); 3518 + goto retry_init; 3519 + } 3520 + out_failed_noretry: 3521 + ioc_err(mrioc, "controller %s is failed\n", 3522 + (is_resume)?"resume":"re-initialization"); 3523 + mpi3mr_issue_reset(mrioc, MPI3_SYSIF_HOST_DIAG_RESET_ACTION_DIAG_FAULT, 3524 + MPI3MR_RESET_FROM_CTLR_CLEANUP); 3525 + mrioc->unrecoverable = 1; 3785 3526 return retval; 3786 3527 } 3787 3528 ··· 3943 3488 { 3944 3489 u16 i; 3945 3490 3946 - memset(mrioc->admin_req_base, 0, mrioc->admin_req_q_sz); 3947 - memset(mrioc->admin_reply_base, 0, mrioc->admin_reply_q_sz); 3491 + mrioc->change_count = 0; 3492 + mrioc->active_poll_qcount = 0; 3493 + mrioc->default_qcount = 0; 3494 + if (mrioc->admin_req_base) 3495 + memset(mrioc->admin_req_base, 0, mrioc->admin_req_q_sz); 3496 + if (mrioc->admin_reply_base) 3497 + memset(mrioc->admin_reply_base, 0, mrioc->admin_reply_q_sz); 3948 3498 3949 - memset(mrioc->init_cmds.reply, 0, sizeof(*mrioc->init_cmds.reply)); 3950 - memset(mrioc->host_tm_cmds.reply, 0, 3951 - sizeof(*mrioc->host_tm_cmds.reply)); 3952 - for (i = 0; i < MPI3MR_NUM_DEVRMCMD; i++) 3953 - memset(mrioc->dev_rmhs_cmds[i].reply, 0, 3954 - sizeof(*mrioc->dev_rmhs_cmds[i].reply)); 3955 - memset(mrioc->removepend_bitmap, 0, mrioc->dev_handle_bitmap_sz); 3956 - memset(mrioc->devrem_bitmap, 0, mrioc->devrem_bitmap_sz); 3499 + if (mrioc->init_cmds.reply) { 3500 + memset(mrioc->init_cmds.reply, 0, sizeof(*mrioc->init_cmds.reply)); 3501 + memset(mrioc->host_tm_cmds.reply, 0, 3502 + sizeof(*mrioc->host_tm_cmds.reply)); 3503 + for (i = 0; i < MPI3MR_NUM_DEVRMCMD; i++) 3504 + memset(mrioc->dev_rmhs_cmds[i].reply, 0, 3505 + sizeof(*mrioc->dev_rmhs_cmds[i].reply)); 3506 + for (i = 0; i < MPI3MR_NUM_EVTACKCMD; i++) 3507 + memset(mrioc->evtack_cmds[i].reply, 0, 3508 + sizeof(*mrioc->evtack_cmds[i].reply)); 3509 + memset(mrioc->removepend_bitmap, 0, mrioc->dev_handle_bitmap_sz); 3510 + memset(mrioc->devrem_bitmap, 0, mrioc->devrem_bitmap_sz); 3511 + memset(mrioc->evtack_cmds_bitmap, 0, 3512 + mrioc->evtack_cmds_bitmap_sz); 3513 + } 3957 3514 3958 3515 for (i = 0; i < mrioc->num_queues; i++) { 3959 3516 mrioc->op_reply_qinfo[i].qid = 0; ··· 3994 3527 * 3995 3528 * Return: Nothing. 3996 3529 */ 3997 - static void mpi3mr_free_mem(struct mpi3mr_ioc *mrioc) 3530 + void mpi3mr_free_mem(struct mpi3mr_ioc *mrioc) 3998 3531 { 3999 3532 u16 i; 4000 3533 struct mpi3mr_intr_info *intr_info; ··· 4058 3591 kfree(mrioc->host_tm_cmds.reply); 4059 3592 mrioc->host_tm_cmds.reply = NULL; 4060 3593 3594 + for (i = 0; i < MPI3MR_NUM_EVTACKCMD; i++) { 3595 + kfree(mrioc->evtack_cmds[i].reply); 3596 + mrioc->evtack_cmds[i].reply = NULL; 3597 + } 3598 + 4061 3599 kfree(mrioc->removepend_bitmap); 4062 3600 mrioc->removepend_bitmap = NULL; 4063 3601 4064 3602 kfree(mrioc->devrem_bitmap); 4065 3603 mrioc->devrem_bitmap = NULL; 3604 + 3605 + kfree(mrioc->evtack_cmds_bitmap); 3606 + mrioc->evtack_cmds_bitmap = NULL; 4066 3607 4067 3608 kfree(mrioc->chain_bitmap); 4068 3609 mrioc->chain_bitmap = NULL; ··· 4138 3663 4139 3664 ioc_config = readl(&mrioc->sysif_regs->ioc_configuration); 4140 3665 ioc_config |= MPI3_SYSIF_IOC_CONFIG_SHUTDOWN_NORMAL; 4141 - ioc_config |= MPI3_SYSIF_IOC_CONFIG_DEVICE_SHUTDOWN; 3666 + ioc_config |= MPI3_SYSIF_IOC_CONFIG_DEVICE_SHUTDOWN_SEND_REQ; 4142 3667 4143 3668 writel(ioc_config, &mrioc->sysif_regs->ioc_configuration); 4144 3669 ··· 4174 3699 /** 4175 3700 * mpi3mr_cleanup_ioc - Cleanup controller 4176 3701 * @mrioc: Adapter instance reference 4177 - * @reason: Cleanup reason 4178 - * 3702 + 4179 3703 * controller cleanup handler, Message unit reset or soft reset 4180 - * and shutdown notification is issued to the controller and the 4181 - * associated memory resources are freed. 3704 + * and shutdown notification is issued to the controller. 4182 3705 * 4183 3706 * Return: Nothing. 4184 3707 */ 4185 - void mpi3mr_cleanup_ioc(struct mpi3mr_ioc *mrioc, u8 reason) 3708 + void mpi3mr_cleanup_ioc(struct mpi3mr_ioc *mrioc) 4186 3709 { 4187 3710 enum mpi3mr_iocstate ioc_state; 4188 3711 4189 - if (reason == MPI3MR_COMPLETE_CLEANUP) 4190 - mpi3mr_stop_watchdog(mrioc); 4191 - 3712 + dprint_exit(mrioc, "cleaning up the controller\n"); 4192 3713 mpi3mr_ioc_disable_intr(mrioc); 4193 3714 4194 3715 ioc_state = mpi3mr_get_iocstate(mrioc); ··· 4196 3725 mpi3mr_issue_reset(mrioc, 4197 3726 MPI3_SYSIF_HOST_DIAG_RESET_ACTION_SOFT_RESET, 4198 3727 MPI3MR_RESET_FROM_MUR_FAILURE); 4199 - 4200 - if (reason != MPI3MR_REINIT_FAILURE) 4201 - mpi3mr_issue_ioc_shutdown(mrioc); 3728 + mpi3mr_issue_ioc_shutdown(mrioc); 4202 3729 } 4203 - 4204 - if (reason == MPI3MR_COMPLETE_CLEANUP) { 4205 - mpi3mr_free_mem(mrioc); 4206 - mpi3mr_cleanup_resources(mrioc); 4207 - } 3730 + dprint_exit(mrioc, "controller cleanup completed\n"); 4208 3731 } 4209 3732 4210 3733 /** ··· 4247 3782 cmdptr = &mrioc->dev_rmhs_cmds[i]; 4248 3783 mpi3mr_drv_cmd_comp_reset(mrioc, cmdptr); 4249 3784 } 4250 - } 4251 3785 4252 - /** 4253 - * mpi3mr_diagfault_reset_handler - Diag fault reset handler 4254 - * @mrioc: Adapter instance reference 4255 - * @reset_reason: Reset reason code 4256 - * 4257 - * This is an handler for issuing diag fault reset from the 4258 - * applications through IOCTL path to stop the execution of the 4259 - * controller 4260 - * 4261 - * Return: 0 on success, non-zero on failure. 4262 - */ 4263 - int mpi3mr_diagfault_reset_handler(struct mpi3mr_ioc *mrioc, 4264 - u32 reset_reason) 4265 - { 4266 - int retval = 0; 4267 - 4268 - ioc_info(mrioc, "Entry: reason code: %s\n", 4269 - mpi3mr_reset_rc_name(reset_reason)); 4270 - mrioc->reset_in_progress = 1; 4271 - 4272 - mpi3mr_ioc_disable_intr(mrioc); 4273 - 4274 - retval = mpi3mr_issue_reset(mrioc, 4275 - MPI3_SYSIF_HOST_DIAG_RESET_ACTION_DIAG_FAULT, reset_reason); 4276 - 4277 - if (retval) { 4278 - ioc_err(mrioc, "The diag fault reset failed: reason %d\n", 4279 - reset_reason); 4280 - mpi3mr_ioc_enable_intr(mrioc); 3786 + for (i = 0; i < MPI3MR_NUM_EVTACKCMD; i++) { 3787 + cmdptr = &mrioc->evtack_cmds[i]; 3788 + mpi3mr_drv_cmd_comp_reset(mrioc, cmdptr); 4281 3789 } 4282 - ioc_info(mrioc, "%s\n", ((retval == 0) ? "SUCCESS" : "FAILED")); 4283 - mrioc->reset_in_progress = 0; 4284 - return retval; 4285 3790 } 4286 3791 4287 3792 /** ··· 4282 3847 unsigned long flags; 4283 3848 u32 host_diagnostic, timeout = MPI3_SYSIF_DIAG_SAVE_TIMEOUT * 10; 4284 3849 4285 - if (mrioc->fault_dbg) { 4286 - if (snapdump) 4287 - mpi3mr_set_diagsave(mrioc); 4288 - mpi3mr_kill_ioc(mrioc, reset_reason); 4289 - } 4290 - 3850 + /* Block the reset handler until diag save in progress*/ 3851 + dprint_reset(mrioc, 3852 + "soft_reset_handler: check and block on diagsave_timeout(%d)\n", 3853 + mrioc->diagsave_timeout); 3854 + while (mrioc->diagsave_timeout) 3855 + ssleep(1); 4291 3856 /* 4292 3857 * Block new resets until the currently executing one is finished and 4293 3858 * return the status of the existing reset for all blocked resets 4294 3859 */ 3860 + dprint_reset(mrioc, "soft_reset_handler: acquiring reset_mutex\n"); 4295 3861 if (!mutex_trylock(&mrioc->reset_mutex)) { 4296 - ioc_info(mrioc, "Another reset in progress\n"); 4297 - return -1; 3862 + ioc_info(mrioc, 3863 + "controller reset triggered by %s is blocked due to another reset in progress\n", 3864 + mpi3mr_reset_rc_name(reset_reason)); 3865 + do { 3866 + ssleep(1); 3867 + } while (mrioc->reset_in_progress == 1); 3868 + ioc_info(mrioc, 3869 + "returning previous reset result(%d) for the reset triggered by %s\n", 3870 + mrioc->prev_reset_result, 3871 + mpi3mr_reset_rc_name(reset_reason)); 3872 + return mrioc->prev_reset_result; 4298 3873 } 3874 + ioc_info(mrioc, "controller reset is triggered by %s\n", 3875 + mpi3mr_reset_rc_name(reset_reason)); 3876 + 4299 3877 mrioc->reset_in_progress = 1; 3878 + mrioc->prev_reset_result = -1; 4300 3879 4301 3880 if ((!snapdump) && (reset_reason != MPI3MR_RESET_FROM_FAULT_WATCH) && 3881 + (reset_reason != MPI3MR_RESET_FROM_FIRMWARE) && 4302 3882 (reset_reason != MPI3MR_RESET_FROM_CIACTIV_FAULT)) { 4303 3883 for (i = 0; i < MPI3_EVENT_NOTIFY_EVENTMASK_WORDS; i++) 4304 3884 mrioc->event_masks[i] = -1; 4305 3885 4306 - retval = mpi3mr_issue_event_notification(mrioc); 4307 - 4308 - if (retval) { 4309 - ioc_err(mrioc, 4310 - "Failed to turn off events prior to reset %d\n", 4311 - retval); 4312 - } 3886 + dprint_reset(mrioc, "soft_reset_handler: masking events\n"); 3887 + mpi3mr_issue_event_notification(mrioc); 4313 3888 } 4314 3889 4315 3890 mpi3mr_wait_for_host_io(mrioc, MPI3MR_RESET_HOST_IOWAIT_TIMEOUT); ··· 4349 3904 goto out; 4350 3905 } 4351 3906 4352 - mpi3mr_flush_delayed_rmhs_list(mrioc); 3907 + mpi3mr_flush_delayed_cmd_lists(mrioc); 4353 3908 mpi3mr_flush_drv_cmds(mrioc); 4354 3909 memset(mrioc->devrem_bitmap, 0, mrioc->devrem_bitmap_sz); 4355 3910 memset(mrioc->removepend_bitmap, 0, mrioc->dev_handle_bitmap_sz); 3911 + memset(mrioc->evtack_cmds_bitmap, 0, mrioc->evtack_cmds_bitmap_sz); 4356 3912 mpi3mr_cleanup_fwevt_list(mrioc); 4357 3913 mpi3mr_flush_host_io(mrioc); 4358 3914 mpi3mr_invalidate_devhandles(mrioc); 3915 + if (mrioc->prepare_for_reset) { 3916 + mrioc->prepare_for_reset = 0; 3917 + mrioc->prepare_for_reset_timeout_counter = 0; 3918 + } 4359 3919 mpi3mr_memset_buffers(mrioc); 4360 - retval = mpi3mr_init_ioc(mrioc, MPI3MR_IT_RESET); 3920 + retval = mpi3mr_reinit_ioc(mrioc, 0); 4361 3921 if (retval) { 4362 3922 pr_err(IOCNAME "reinit after soft reset failed: reason %d\n", 4363 3923 mrioc->name, reset_reason); ··· 4372 3922 4373 3923 out: 4374 3924 if (!retval) { 3925 + mrioc->diagsave_timeout = 0; 4375 3926 mrioc->reset_in_progress = 0; 4376 - scsi_unblock_requests(mrioc->shost); 4377 3927 mpi3mr_rfresh_tgtdevs(mrioc); 4378 3928 mrioc->ts_update_counter = 0; 4379 3929 spin_lock_irqsave(&mrioc->watchdog_lock, flags); ··· 4389 3939 mrioc->reset_in_progress = 0; 4390 3940 retval = -1; 4391 3941 } 4392 - 3942 + mrioc->prev_reset_result = retval; 4393 3943 mutex_unlock(&mrioc->reset_mutex); 4394 - ioc_info(mrioc, "%s\n", ((retval == 0) ? "SUCCESS" : "FAILED")); 3944 + ioc_info(mrioc, "controller reset is %s\n", 3945 + ((retval == 0) ? "successful" : "failed")); 4395 3946 return retval; 4396 3947 }
+645 -132
drivers/scsi/mpi3mr/mpi3mr_os.c
··· 34 34 " bits for enabling additional logging info (default=0)"); 35 35 36 36 /* 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 + 37 40 /** 38 41 * mpi3mr_host_tag_for_scmd - Get host tag for a scmd 39 42 * @mrioc: Adapter instance reference ··· 421 418 } 422 419 423 420 /** 421 + * mpi3mr_count_dev_pending - Count commands pending for a lun 422 + * @rq: Block request 423 + * @data: SCSI device reference 424 + * @reserved: Unused 425 + * 426 + * This is an iterator function called for each SCSI command in 427 + * a host and if the command is pending in the LLD for the 428 + * specific device(lun) then device specific pending I/O counter 429 + * is updated in the device structure. 430 + * 431 + * Return: true always. 432 + */ 433 + 434 + static bool mpi3mr_count_dev_pending(struct request *rq, 435 + void *data, bool reserved) 436 + { 437 + struct scsi_device *sdev = (struct scsi_device *)data; 438 + struct mpi3mr_sdev_priv_data *sdev_priv_data = sdev->hostdata; 439 + struct scsi_cmnd *scmd = blk_mq_rq_to_pdu(rq); 440 + struct scmd_priv *priv; 441 + 442 + if (scmd) { 443 + priv = scsi_cmd_priv(scmd); 444 + if (!priv->in_lld_scope) 445 + goto out; 446 + if (scmd->device == sdev) 447 + sdev_priv_data->pend_count++; 448 + } 449 + 450 + out: 451 + return true; 452 + } 453 + 454 + /** 455 + * mpi3mr_count_tgt_pending - Count commands pending for target 456 + * @rq: Block request 457 + * @data: SCSI target reference 458 + * @reserved: Unused 459 + * 460 + * This is an iterator function called for each SCSI command in 461 + * a host and if the command is pending in the LLD for the 462 + * specific target then target specific pending I/O counter is 463 + * updated in the target structure. 464 + * 465 + * Return: true always. 466 + */ 467 + 468 + static bool mpi3mr_count_tgt_pending(struct request *rq, 469 + void *data, bool reserved) 470 + { 471 + struct scsi_target *starget = (struct scsi_target *)data; 472 + struct mpi3mr_stgt_priv_data *stgt_priv_data = starget->hostdata; 473 + struct scsi_cmnd *scmd = blk_mq_rq_to_pdu(rq); 474 + struct scmd_priv *priv; 475 + 476 + if (scmd) { 477 + priv = scsi_cmd_priv(scmd); 478 + if (!priv->in_lld_scope) 479 + goto out; 480 + if (scmd->device && (scsi_target(scmd->device) == starget)) 481 + stgt_priv_data->pend_count++; 482 + } 483 + 484 + out: 485 + return true; 486 + } 487 + 488 + /** 424 489 * mpi3mr_flush_host_io - Flush host I/Os 425 490 * @mrioc: Adapter instance reference 426 491 * ··· 813 742 switch (tgtdev->dev_type) { 814 743 case MPI3_DEVICE_DEVFORM_PCIE: 815 744 /*The block layer hw sector size = 512*/ 816 - blk_queue_max_hw_sectors(sdev->request_queue, 817 - tgtdev->dev_spec.pcie_inf.mdts / 512); 818 - blk_queue_virt_boundary(sdev->request_queue, 819 - ((1 << tgtdev->dev_spec.pcie_inf.pgsz) - 1)); 820 - 745 + if ((tgtdev->dev_spec.pcie_inf.dev_info & 746 + MPI3_DEVICE0_PCIE_DEVICE_INFO_TYPE_MASK) == 747 + MPI3_DEVICE0_PCIE_DEVICE_INFO_TYPE_NVME_DEVICE) { 748 + blk_queue_max_hw_sectors(sdev->request_queue, 749 + tgtdev->dev_spec.pcie_inf.mdts / 512); 750 + if (tgtdev->dev_spec.pcie_inf.pgsz == 0) 751 + blk_queue_virt_boundary(sdev->request_queue, 752 + ((1 << MPI3MR_DEFAULT_PGSZEXP) - 1)); 753 + else 754 + blk_queue_virt_boundary(sdev->request_queue, 755 + ((1 << tgtdev->dev_spec.pcie_inf.pgsz) - 1)); 756 + } 821 757 break; 822 758 default: 823 759 break; ··· 902 824 scsi_tgt_priv_data->dev_type = tgtdev->dev_type; 903 825 } 904 826 827 + switch (dev_pg0->access_status) { 828 + case MPI3_DEVICE0_ASTATUS_NO_ERRORS: 829 + case MPI3_DEVICE0_ASTATUS_PREPARE: 830 + case MPI3_DEVICE0_ASTATUS_NEEDS_INITIALIZATION: 831 + case MPI3_DEVICE0_ASTATUS_DEVICE_MISSING_DELAY: 832 + break; 833 + default: 834 + tgtdev->is_hidden = 1; 835 + break; 836 + } 837 + 905 838 switch (tgtdev->dev_type) { 906 839 case MPI3_DEVICE_DEVFORM_SAS_SATA: 907 840 { ··· 937 848 &dev_pg0->device_specific.pcie_format; 938 849 u16 dev_info = le16_to_cpu(pcieinf->device_info); 939 850 851 + tgtdev->dev_spec.pcie_inf.dev_info = dev_info; 940 852 tgtdev->dev_spec.pcie_inf.capb = 941 853 le32_to_cpu(pcieinf->capabilities); 942 854 tgtdev->dev_spec.pcie_inf.mdts = MPI3MR_DEFAULT_MDTS; ··· 948 858 le32_to_cpu(pcieinf->maximum_data_transfer_size); 949 859 tgtdev->dev_spec.pcie_inf.pgsz = pcieinf->page_size; 950 860 tgtdev->dev_spec.pcie_inf.reset_to = 951 - pcieinf->controller_reset_to; 861 + max_t(u8, pcieinf->controller_reset_to, 862 + MPI3MR_INTADMCMD_TIMEOUT); 952 863 tgtdev->dev_spec.pcie_inf.abort_to = 953 - pcieinf->nv_me_abort_to; 864 + max_t(u8, pcieinf->nvme_abort_to, 865 + MPI3MR_INTADMCMD_TIMEOUT); 954 866 } 955 867 if (tgtdev->dev_spec.pcie_inf.mdts > (1024 * 1024)) 956 868 tgtdev->dev_spec.pcie_inf.mdts = (1024 * 1024); 957 - if ((dev_info & MPI3_DEVICE0_PCIE_DEVICE_INFO_TYPE_MASK) != 958 - MPI3_DEVICE0_PCIE_DEVICE_INFO_TYPE_NVME_DEVICE) 869 + if (((dev_info & MPI3_DEVICE0_PCIE_DEVICE_INFO_TYPE_MASK) != 870 + MPI3_DEVICE0_PCIE_DEVICE_INFO_TYPE_NVME_DEVICE) && 871 + ((dev_info & MPI3_DEVICE0_PCIE_DEVICE_INFO_TYPE_MASK) != 872 + MPI3_DEVICE0_PCIE_DEVICE_INFO_TYPE_SCSI_DEVICE)) 959 873 tgtdev->is_hidden = 1; 960 874 if (!mrioc->shost) 961 875 break; ··· 1407 1313 1408 1314 evt_ack: 1409 1315 if (fwevt->send_ack) 1410 - mpi3mr_send_event_ack(mrioc, fwevt->event_id, 1316 + mpi3mr_process_event_ack(mrioc, fwevt->event_id, 1411 1317 fwevt->evt_ctx); 1412 1318 out: 1413 1319 /* Put fwevt reference count to neutralize kref_init increment */ ··· 1471 1377 } 1472 1378 1473 1379 /** 1474 - * mpi3mr_flush_delayed_rmhs_list - Flush pending commands 1380 + * mpi3mr_flush_delayed_cmd_lists - Flush pending commands 1475 1381 * @mrioc: Adapter instance reference 1476 1382 * 1477 - * Flush pending commands in the delayed removal handshake list 1478 - * due to a controller reset or driver removal as a cleanup. 1383 + * Flush pending commands in the delayed lists due to a 1384 + * controller reset or driver removal as a cleanup. 1479 1385 * 1480 1386 * Return: Nothing 1481 1387 */ 1482 - void mpi3mr_flush_delayed_rmhs_list(struct mpi3mr_ioc *mrioc) 1388 + void mpi3mr_flush_delayed_cmd_lists(struct mpi3mr_ioc *mrioc) 1483 1389 { 1484 1390 struct delayed_dev_rmhs_node *_rmhs_node; 1391 + struct delayed_evt_ack_node *_evtack_node; 1485 1392 1393 + dprint_reset(mrioc, "flushing delayed dev_remove_hs commands\n"); 1486 1394 while (!list_empty(&mrioc->delayed_rmhs_list)) { 1487 1395 _rmhs_node = list_entry(mrioc->delayed_rmhs_list.next, 1488 1396 struct delayed_dev_rmhs_node, list); 1489 1397 list_del(&_rmhs_node->list); 1490 1398 kfree(_rmhs_node); 1399 + } 1400 + dprint_reset(mrioc, "flushing delayed event ack commands\n"); 1401 + while (!list_empty(&mrioc->delayed_evtack_cmds_list)) { 1402 + _evtack_node = list_entry(mrioc->delayed_evtack_cmds_list.next, 1403 + struct delayed_evt_ack_node, list); 1404 + list_del(&_evtack_node->list); 1405 + kfree(_evtack_node); 1491 1406 } 1492 1407 } 1493 1408 ··· 1714 1611 } 1715 1612 1716 1613 /** 1614 + * mpi3mr_complete_evt_ack - event ack request completion 1615 + * @mrioc: Adapter instance reference 1616 + * @drv_cmd: Internal command tracker 1617 + * 1618 + * This is the completion handler for non blocking event 1619 + * acknowledgment sent to the firmware and this will issue any 1620 + * pending event acknowledgment request. 1621 + * 1622 + * Return: Nothing 1623 + */ 1624 + static void mpi3mr_complete_evt_ack(struct mpi3mr_ioc *mrioc, 1625 + struct mpi3mr_drv_cmd *drv_cmd) 1626 + { 1627 + u16 cmd_idx = drv_cmd->host_tag - MPI3MR_HOSTTAG_EVTACKCMD_MIN; 1628 + struct delayed_evt_ack_node *delayed_evtack = NULL; 1629 + 1630 + if (drv_cmd->ioc_status != MPI3_IOCSTATUS_SUCCESS) { 1631 + dprint_event_th(mrioc, 1632 + "immediate event ack failed with ioc_status(0x%04x) log_info(0x%08x)\n", 1633 + (drv_cmd->ioc_status & MPI3_IOCSTATUS_STATUS_MASK), 1634 + drv_cmd->ioc_loginfo); 1635 + } 1636 + 1637 + if (!list_empty(&mrioc->delayed_evtack_cmds_list)) { 1638 + delayed_evtack = 1639 + list_entry(mrioc->delayed_evtack_cmds_list.next, 1640 + struct delayed_evt_ack_node, list); 1641 + mpi3mr_send_event_ack(mrioc, delayed_evtack->event, drv_cmd, 1642 + delayed_evtack->event_ctx); 1643 + list_del(&delayed_evtack->list); 1644 + kfree(delayed_evtack); 1645 + return; 1646 + } 1647 + drv_cmd->state = MPI3MR_CMD_NOTUSED; 1648 + drv_cmd->callback = NULL; 1649 + clear_bit(cmd_idx, mrioc->evtack_cmds_bitmap); 1650 + } 1651 + 1652 + /** 1653 + * mpi3mr_send_event_ack - Issue event acknwoledgment request 1654 + * @mrioc: Adapter instance reference 1655 + * @event: MPI3 event id 1656 + * @cmdparam: Internal command tracker 1657 + * @event_ctx: event context 1658 + * 1659 + * Issues event acknowledgment request to the firmware if there 1660 + * is a free command to send the event ack else it to a pend 1661 + * list so that it will be processed on a completion of a prior 1662 + * event acknowledgment . 1663 + * 1664 + * Return: Nothing 1665 + */ 1666 + static void mpi3mr_send_event_ack(struct mpi3mr_ioc *mrioc, u8 event, 1667 + struct mpi3mr_drv_cmd *cmdparam, u32 event_ctx) 1668 + { 1669 + struct mpi3_event_ack_request evtack_req; 1670 + int retval = 0; 1671 + u8 retrycount = 5; 1672 + u16 cmd_idx = MPI3MR_NUM_EVTACKCMD; 1673 + struct mpi3mr_drv_cmd *drv_cmd = cmdparam; 1674 + struct delayed_evt_ack_node *delayed_evtack = NULL; 1675 + 1676 + if (drv_cmd) { 1677 + dprint_event_th(mrioc, 1678 + "sending delayed event ack in the top half for event(0x%02x), event_ctx(0x%08x)\n", 1679 + event, event_ctx); 1680 + goto issue_cmd; 1681 + } 1682 + dprint_event_th(mrioc, 1683 + "sending event ack in the top half for event(0x%02x), event_ctx(0x%08x)\n", 1684 + event, event_ctx); 1685 + do { 1686 + cmd_idx = find_first_zero_bit(mrioc->evtack_cmds_bitmap, 1687 + MPI3MR_NUM_EVTACKCMD); 1688 + if (cmd_idx < MPI3MR_NUM_EVTACKCMD) { 1689 + if (!test_and_set_bit(cmd_idx, 1690 + mrioc->evtack_cmds_bitmap)) 1691 + break; 1692 + cmd_idx = MPI3MR_NUM_EVTACKCMD; 1693 + } 1694 + } while (retrycount--); 1695 + 1696 + if (cmd_idx >= MPI3MR_NUM_EVTACKCMD) { 1697 + delayed_evtack = kzalloc(sizeof(*delayed_evtack), 1698 + GFP_ATOMIC); 1699 + if (!delayed_evtack) 1700 + return; 1701 + INIT_LIST_HEAD(&delayed_evtack->list); 1702 + delayed_evtack->event = event; 1703 + delayed_evtack->event_ctx = event_ctx; 1704 + list_add_tail(&delayed_evtack->list, 1705 + &mrioc->delayed_evtack_cmds_list); 1706 + dprint_event_th(mrioc, 1707 + "event ack in the top half for event(0x%02x), event_ctx(0x%08x) is postponed\n", 1708 + event, event_ctx); 1709 + return; 1710 + } 1711 + drv_cmd = &mrioc->evtack_cmds[cmd_idx]; 1712 + 1713 + issue_cmd: 1714 + cmd_idx = drv_cmd->host_tag - MPI3MR_HOSTTAG_EVTACKCMD_MIN; 1715 + 1716 + memset(&evtack_req, 0, sizeof(evtack_req)); 1717 + if (drv_cmd->state & MPI3MR_CMD_PENDING) { 1718 + dprint_event_th(mrioc, 1719 + "sending event ack failed due to command in use\n"); 1720 + goto out; 1721 + } 1722 + drv_cmd->state = MPI3MR_CMD_PENDING; 1723 + drv_cmd->is_waiting = 0; 1724 + drv_cmd->callback = mpi3mr_complete_evt_ack; 1725 + evtack_req.host_tag = cpu_to_le16(drv_cmd->host_tag); 1726 + evtack_req.function = MPI3_FUNCTION_EVENT_ACK; 1727 + evtack_req.event = event; 1728 + evtack_req.event_context = cpu_to_le32(event_ctx); 1729 + retval = mpi3mr_admin_request_post(mrioc, &evtack_req, 1730 + sizeof(evtack_req), 1); 1731 + if (retval) { 1732 + dprint_event_th(mrioc, 1733 + "posting event ack request is failed\n"); 1734 + goto out_failed; 1735 + } 1736 + 1737 + dprint_event_th(mrioc, 1738 + "event ack in the top half for event(0x%02x), event_ctx(0x%08x) is posted\n", 1739 + event, event_ctx); 1740 + out: 1741 + return; 1742 + out_failed: 1743 + drv_cmd->state = MPI3MR_CMD_NOTUSED; 1744 + drv_cmd->callback = NULL; 1745 + clear_bit(cmd_idx, mrioc->evtack_cmds_bitmap); 1746 + } 1747 + 1748 + /** 1717 1749 * mpi3mr_pcietopochg_evt_th - PCIETopologyChange evt tophalf 1718 1750 * @mrioc: Adapter instance reference 1719 1751 * @event_reply: event data ··· 2057 1819 } 2058 1820 2059 1821 /** 1822 + * mpi3mr_preparereset_evt_th - Prepare for reset event tophalf 1823 + * @mrioc: Adapter instance reference 1824 + * @event_reply: event data 1825 + * 1826 + * Blocks and unblocks host level I/O based on the reason code 1827 + * 1828 + * Return: Nothing 1829 + */ 1830 + static void mpi3mr_preparereset_evt_th(struct mpi3mr_ioc *mrioc, 1831 + struct mpi3_event_notification_reply *event_reply) 1832 + { 1833 + struct mpi3_event_data_prepare_for_reset *evtdata = 1834 + (struct mpi3_event_data_prepare_for_reset *)event_reply->event_data; 1835 + 1836 + if (evtdata->reason_code == MPI3_EVENT_PREPARE_RESET_RC_START) { 1837 + dprint_event_th(mrioc, 1838 + "prepare for reset event top half with rc=start\n"); 1839 + if (mrioc->prepare_for_reset) 1840 + return; 1841 + mrioc->prepare_for_reset = 1; 1842 + mrioc->prepare_for_reset_timeout_counter = 0; 1843 + } else if (evtdata->reason_code == MPI3_EVENT_PREPARE_RESET_RC_ABORT) { 1844 + dprint_event_th(mrioc, 1845 + "prepare for reset top half with rc=abort\n"); 1846 + mrioc->prepare_for_reset = 0; 1847 + mrioc->prepare_for_reset_timeout_counter = 0; 1848 + } 1849 + if ((event_reply->msg_flags & MPI3_EVENT_NOTIFY_MSGFLAGS_ACK_MASK) 1850 + == MPI3_EVENT_NOTIFY_MSGFLAGS_ACK_REQUIRED) 1851 + mpi3mr_send_event_ack(mrioc, event_reply->event, NULL, 1852 + le32_to_cpu(event_reply->event_context)); 1853 + } 1854 + 1855 + /** 2060 1856 * mpi3mr_energypackchg_evt_th - Energy pack change evt tophalf 2061 1857 * @mrioc: Adapter instance reference 2062 1858 * @event_reply: event data ··· 2117 1845 "%s :Previous Shutdown Timeout Value = %d New Shutdown Timeout Value = %d\n", 2118 1846 __func__, mrioc->facts.shutdown_timeout, shutdown_timeout); 2119 1847 mrioc->facts.shutdown_timeout = shutdown_timeout; 1848 + } 1849 + 1850 + /** 1851 + * mpi3mr_tempthreshold_evt_th - Temp threshold event tophalf 1852 + * @mrioc: Adapter instance reference 1853 + * @event_reply: event data 1854 + * 1855 + * Displays temperature threshold event details and fault code 1856 + * if any is hit due to temperature exceeding threshold. 1857 + * 1858 + * Return: Nothing 1859 + */ 1860 + static void mpi3mr_tempthreshold_evt_th(struct mpi3mr_ioc *mrioc, 1861 + struct mpi3_event_notification_reply *event_reply) 1862 + { 1863 + struct mpi3_event_data_temp_threshold *evtdata = 1864 + (struct mpi3_event_data_temp_threshold *)event_reply->event_data; 1865 + 1866 + ioc_err(mrioc, "Temperature threshold levels %s%s%s exceeded for sensor: %d !!! Current temperature in Celsius: %d\n", 1867 + (le16_to_cpu(evtdata->status) & 0x1) ? "Warning " : " ", 1868 + (le16_to_cpu(evtdata->status) & 0x2) ? "Critical " : " ", 1869 + (le16_to_cpu(evtdata->status) & 0x4) ? "Fatal " : " ", evtdata->sensor_num, 1870 + le16_to_cpu(evtdata->current_temperature)); 1871 + mpi3mr_print_fault_info(mrioc); 1872 + } 1873 + 1874 + /** 1875 + * mpi3mr_cablemgmt_evt_th - Cable management event tophalf 1876 + * @mrioc: Adapter instance reference 1877 + * @event_reply: event data 1878 + * 1879 + * Displays Cable manegemt event details. 1880 + * 1881 + * Return: Nothing 1882 + */ 1883 + static void mpi3mr_cablemgmt_evt_th(struct mpi3mr_ioc *mrioc, 1884 + struct mpi3_event_notification_reply *event_reply) 1885 + { 1886 + struct mpi3_event_data_cable_management *evtdata = 1887 + (struct mpi3_event_data_cable_management *)event_reply->event_data; 1888 + 1889 + switch (evtdata->status) { 1890 + case MPI3_EVENT_CABLE_MGMT_STATUS_INSUFFICIENT_POWER: 1891 + { 1892 + ioc_info(mrioc, "An active cable with receptacle_id %d cannot be powered.\n" 1893 + "Devices connected to this cable are not detected.\n" 1894 + "This cable requires %d mW of power.\n", 1895 + evtdata->receptacle_id, 1896 + le32_to_cpu(evtdata->active_cable_power_requirement)); 1897 + break; 1898 + } 1899 + case MPI3_EVENT_CABLE_MGMT_STATUS_DEGRADED: 1900 + { 1901 + ioc_info(mrioc, "A cable with receptacle_id %d is not running at optimal speed\n", 1902 + evtdata->receptacle_id); 1903 + break; 1904 + } 1905 + default: 1906 + break; 1907 + } 2120 1908 } 2121 1909 2122 1910 /** ··· 2237 1905 mpi3mr_pcietopochg_evt_th(mrioc, event_reply); 2238 1906 break; 2239 1907 } 1908 + case MPI3_EVENT_PREPARE_FOR_RESET: 1909 + { 1910 + mpi3mr_preparereset_evt_th(mrioc, event_reply); 1911 + ack_req = 0; 1912 + break; 1913 + } 2240 1914 case MPI3_EVENT_DEVICE_INFO_CHANGED: 2241 1915 { 2242 1916 process_evt_bh = 1; ··· 2253 1915 mpi3mr_energypackchg_evt_th(mrioc, event_reply); 2254 1916 break; 2255 1917 } 1918 + case MPI3_EVENT_TEMP_THRESHOLD: 1919 + { 1920 + mpi3mr_tempthreshold_evt_th(mrioc, event_reply); 1921 + break; 1922 + } 1923 + case MPI3_EVENT_CABLE_MGMT: 1924 + { 1925 + mpi3mr_cablemgmt_evt_th(mrioc, event_reply); 1926 + break; 1927 + } 2256 1928 case MPI3_EVENT_ENCL_DEVICE_STATUS_CHANGE: 2257 1929 case MPI3_EVENT_SAS_DISCOVERY: 2258 - case MPI3_EVENT_CABLE_MGMT: 2259 1930 case MPI3_EVENT_SAS_DEVICE_DISCOVERY_ERROR: 2260 1931 case MPI3_EVENT_SAS_BROADCAST_PRIMITIVE: 2261 1932 case MPI3_EVENT_PCIE_ENUMERATION: ··· 2867 2520 } 2868 2521 2869 2522 /** 2870 - * mpi3mr_print_response_code - print TM response as a string 2871 - * @mrioc: Adapter instance reference 2523 + * mpi3mr_tm_response_name - get TM response as a string 2872 2524 * @resp_code: TM response code 2873 2525 * 2874 - * Print TM response code as a readable string. 2526 + * Convert known task management response code as a readable 2527 + * string. 2875 2528 * 2876 - * Return: Nothing. 2529 + * Return: response code string. 2877 2530 */ 2878 - static void mpi3mr_print_response_code(struct mpi3mr_ioc *mrioc, u8 resp_code) 2531 + static const char *mpi3mr_tm_response_name(u8 resp_code) 2879 2532 { 2880 2533 char *desc; 2881 2534 2882 2535 switch (resp_code) { 2883 - case MPI3MR_RSP_TM_COMPLETE: 2536 + case MPI3_SCSITASKMGMT_RSPCODE_TM_COMPLETE: 2884 2537 desc = "task management request completed"; 2885 2538 break; 2886 - case MPI3MR_RSP_INVALID_FRAME: 2539 + case MPI3_SCSITASKMGMT_RSPCODE_INVALID_FRAME: 2887 2540 desc = "invalid frame"; 2888 2541 break; 2889 - case MPI3MR_RSP_TM_NOT_SUPPORTED: 2542 + case MPI3_SCSITASKMGMT_RSPCODE_TM_FUNCTION_NOT_SUPPORTED: 2890 2543 desc = "task management request not supported"; 2891 2544 break; 2892 - case MPI3MR_RSP_TM_FAILED: 2545 + case MPI3_SCSITASKMGMT_RSPCODE_TM_FAILED: 2893 2546 desc = "task management request failed"; 2894 2547 break; 2895 - case MPI3MR_RSP_TM_SUCCEEDED: 2548 + case MPI3_SCSITASKMGMT_RSPCODE_TM_SUCCEEDED: 2896 2549 desc = "task management request succeeded"; 2897 2550 break; 2898 - case MPI3MR_RSP_TM_INVALID_LUN: 2899 - desc = "invalid lun"; 2551 + case MPI3_SCSITASKMGMT_RSPCODE_TM_INVALID_LUN: 2552 + desc = "invalid LUN"; 2900 2553 break; 2901 - case MPI3MR_RSP_TM_OVERLAPPED_TAG: 2554 + case MPI3_SCSITASKMGMT_RSPCODE_TM_OVERLAPPED_TAG: 2902 2555 desc = "overlapped tag attempted"; 2903 2556 break; 2904 - case MPI3MR_RSP_IO_QUEUED_ON_IOC: 2557 + case MPI3_SCSITASKMGMT_RSPCODE_IO_QUEUED_ON_IOC: 2905 2558 desc = "task queued, however not sent to target"; 2559 + break; 2560 + case MPI3_SCSITASKMGMT_RSPCODE_TM_NVME_DENIED: 2561 + desc = "task management request denied by NVMe device"; 2906 2562 break; 2907 2563 default: 2908 2564 desc = "unknown"; 2909 2565 break; 2910 2566 } 2911 - ioc_info(mrioc, "%s :response_code(0x%01x): %s\n", __func__, 2912 - resp_code, desc); 2567 + 2568 + return desc; 2569 + } 2570 + 2571 + inline void mpi3mr_poll_pend_io_completions(struct mpi3mr_ioc *mrioc) 2572 + { 2573 + int i; 2574 + int num_of_reply_queues = 2575 + mrioc->num_op_reply_q + mrioc->op_reply_q_offset; 2576 + 2577 + for (i = mrioc->op_reply_q_offset; i < num_of_reply_queues; i++) 2578 + mpi3mr_process_op_reply_q(mrioc, 2579 + mrioc->intr_info[i].op_reply_q); 2913 2580 } 2914 2581 2915 2582 /** ··· 2933 2572 * @handle: Device handle 2934 2573 * @lun: lun ID 2935 2574 * @htag: Host tag of the TM request 2575 + * @timeout: TM timeout value 2936 2576 * @drv_cmd: Internal command tracker 2937 2577 * @resp_code: Response code place holder 2938 - * @cmd_priv: SCSI command private data 2578 + * @scmd: SCSI command 2939 2579 * 2940 2580 * Issues a Task Management Request to the controller for a 2941 2581 * specified target, lun and command and wait for its completion ··· 2948 2586 static int mpi3mr_issue_tm(struct mpi3mr_ioc *mrioc, u8 tm_type, 2949 2587 u16 handle, uint lun, u16 htag, ulong timeout, 2950 2588 struct mpi3mr_drv_cmd *drv_cmd, 2951 - u8 *resp_code, struct scmd_priv *cmd_priv) 2589 + u8 *resp_code, struct scsi_cmnd *scmd) 2952 2590 { 2953 2591 struct mpi3_scsi_task_mgmt_request tm_req; 2954 2592 struct mpi3_scsi_task_mgmt_reply *tm_reply = NULL; 2955 2593 int retval = 0; 2956 2594 struct mpi3mr_tgt_dev *tgtdev = NULL; 2957 2595 struct mpi3mr_stgt_priv_data *scsi_tgt_priv_data = NULL; 2958 - struct op_req_qinfo *op_req_q = NULL; 2596 + struct scmd_priv *cmd_priv = NULL; 2597 + struct scsi_device *sdev = NULL; 2598 + struct mpi3mr_sdev_priv_data *sdev_priv_data = NULL; 2959 2599 2960 2600 ioc_info(mrioc, "%s :Issue TM: TM type (0x%x) for devhandle 0x%04x\n", 2961 2601 __func__, tm_type, handle); ··· 2994 2630 tm_req.function = MPI3_FUNCTION_SCSI_TASK_MGMT; 2995 2631 2996 2632 tgtdev = mpi3mr_get_tgtdev_by_handle(mrioc, handle); 2997 - if (tgtdev && tgtdev->starget && tgtdev->starget->hostdata) { 2998 - scsi_tgt_priv_data = (struct mpi3mr_stgt_priv_data *) 2999 - tgtdev->starget->hostdata; 2633 + 2634 + if (scmd) { 2635 + sdev = scmd->device; 2636 + sdev_priv_data = sdev->hostdata; 2637 + scsi_tgt_priv_data = ((sdev_priv_data) ? 2638 + sdev_priv_data->tgt_priv_data : NULL); 2639 + } else { 2640 + if (tgtdev && tgtdev->starget && tgtdev->starget->hostdata) 2641 + scsi_tgt_priv_data = (struct mpi3mr_stgt_priv_data *) 2642 + tgtdev->starget->hostdata; 2643 + } 2644 + 2645 + if (scsi_tgt_priv_data) 3000 2646 atomic_inc(&scsi_tgt_priv_data->block_io); 3001 - } 3002 - if (cmd_priv) { 3003 - op_req_q = &mrioc->req_qinfo[cmd_priv->req_q_idx]; 3004 - tm_req.task_host_tag = cpu_to_le16(cmd_priv->host_tag); 3005 - tm_req.task_request_queue_id = cpu_to_le16(op_req_q->qid); 3006 - } 2647 + 3007 2648 if (tgtdev && (tgtdev->dev_type == MPI3_DEVICE_DEVFORM_PCIE)) { 3008 2649 if (cmd_priv && tgtdev->dev_spec.pcie_inf.abort_to) 3009 2650 timeout = tgtdev->dev_spec.pcie_inf.abort_to; ··· 3025 2656 wait_for_completion_timeout(&drv_cmd->done, (timeout * HZ)); 3026 2657 3027 2658 if (!(drv_cmd->state & MPI3MR_CMD_COMPLETE)) { 3028 - ioc_err(mrioc, "%s :Issue TM: command timed out\n", __func__); 3029 2659 drv_cmd->is_waiting = 0; 3030 2660 retval = -1; 3031 - mpi3mr_soft_reset_handler(mrioc, 3032 - MPI3MR_RESET_FROM_TM_TIMEOUT, 1); 2661 + if (!(drv_cmd->state & MPI3MR_CMD_RESET)) { 2662 + dprint_tm(mrioc, 2663 + "task management request timed out after %ld seconds\n", 2664 + timeout); 2665 + if (mrioc->logging_level & MPI3_DEBUG_TM) 2666 + dprint_dump_req(&tm_req, sizeof(tm_req)/4); 2667 + mpi3mr_soft_reset_handler(mrioc, 2668 + MPI3MR_RESET_FROM_TM_TIMEOUT, 1); 2669 + } 3033 2670 goto out_unlock; 3034 2671 } 3035 2672 3036 - if (drv_cmd->state & MPI3MR_CMD_REPLY_VALID) 3037 - tm_reply = (struct mpi3_scsi_task_mgmt_reply *)drv_cmd->reply; 3038 - 3039 - if (drv_cmd->ioc_status != MPI3_IOCSTATUS_SUCCESS) { 3040 - ioc_err(mrioc, 3041 - "%s :Issue TM: handle(0x%04x) Failed ioc_status(0x%04x) Loginfo(0x%08x)\n", 3042 - __func__, handle, drv_cmd->ioc_status, 3043 - drv_cmd->ioc_loginfo); 2673 + if (!(drv_cmd->state & MPI3MR_CMD_REPLY_VALID)) { 2674 + dprint_tm(mrioc, "invalid task management reply message\n"); 3044 2675 retval = -1; 3045 2676 goto out_unlock; 3046 2677 } 3047 2678 3048 - if (!tm_reply) { 3049 - ioc_err(mrioc, "%s :Issue TM: No TM Reply message\n", __func__); 3050 - retval = -1; 3051 - goto out_unlock; 3052 - } 2679 + tm_reply = (struct mpi3_scsi_task_mgmt_reply *)drv_cmd->reply; 3053 2680 3054 - *resp_code = le32_to_cpu(tm_reply->response_data) & 3055 - MPI3MR_RI_MASK_RESPCODE; 3056 - switch (*resp_code) { 3057 - case MPI3MR_RSP_TM_SUCCEEDED: 3058 - case MPI3MR_RSP_TM_COMPLETE: 2681 + switch (drv_cmd->ioc_status) { 2682 + case MPI3_IOCSTATUS_SUCCESS: 2683 + *resp_code = le32_to_cpu(tm_reply->response_data) & 2684 + MPI3MR_RI_MASK_RESPCODE; 3059 2685 break; 3060 - case MPI3MR_RSP_IO_QUEUED_ON_IOC: 2686 + case MPI3_IOCSTATUS_SCSI_IOC_TERMINATED: 2687 + *resp_code = MPI3_SCSITASKMGMT_RSPCODE_TM_COMPLETE; 2688 + break; 2689 + default: 2690 + dprint_tm(mrioc, 2691 + "task management request to handle(0x%04x) is failed with ioc_status(0x%04x) log_info(0x%08x)\n", 2692 + handle, drv_cmd->ioc_status, drv_cmd->ioc_loginfo); 2693 + retval = -1; 2694 + goto out_unlock; 2695 + } 2696 + 2697 + switch (*resp_code) { 2698 + case MPI3_SCSITASKMGMT_RSPCODE_TM_SUCCEEDED: 2699 + case MPI3_SCSITASKMGMT_RSPCODE_TM_COMPLETE: 2700 + break; 2701 + case MPI3_SCSITASKMGMT_RSPCODE_IO_QUEUED_ON_IOC: 3061 2702 if (tm_type != MPI3_SCSITASKMGMT_TASKTYPE_QUERY_TASK) 3062 2703 retval = -1; 3063 2704 break; ··· 3076 2697 break; 3077 2698 } 3078 2699 3079 - ioc_info(mrioc, 3080 - "%s :Issue TM: Completed TM type (0x%x) handle(0x%04x) ", 3081 - __func__, tm_type, handle); 3082 - ioc_info(mrioc, 3083 - "with ioc_status(0x%04x), loginfo(0x%08x), term_count(0x%08x)\n", 3084 - drv_cmd->ioc_status, drv_cmd->ioc_loginfo, 3085 - le32_to_cpu(tm_reply->termination_count)); 3086 - mpi3mr_print_response_code(mrioc, *resp_code); 2700 + dprint_tm(mrioc, 2701 + "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", 2702 + tm_type, handle, drv_cmd->ioc_status, drv_cmd->ioc_loginfo, 2703 + le32_to_cpu(tm_reply->termination_count), 2704 + mpi3mr_tm_response_name(*resp_code), *resp_code); 2705 + 2706 + if (!retval) { 2707 + mpi3mr_ioc_disable_intr(mrioc); 2708 + mpi3mr_poll_pend_io_completions(mrioc); 2709 + mpi3mr_ioc_enable_intr(mrioc); 2710 + mpi3mr_poll_pend_io_completions(mrioc); 2711 + } 2712 + switch (tm_type) { 2713 + case MPI3_SCSITASKMGMT_TASKTYPE_TARGET_RESET: 2714 + if (!scsi_tgt_priv_data) 2715 + break; 2716 + scsi_tgt_priv_data->pend_count = 0; 2717 + blk_mq_tagset_busy_iter(&mrioc->shost->tag_set, 2718 + mpi3mr_count_tgt_pending, 2719 + (void *)scsi_tgt_priv_data->starget); 2720 + break; 2721 + case MPI3_SCSITASKMGMT_TASKTYPE_LOGICAL_UNIT_RESET: 2722 + if (!sdev_priv_data) 2723 + break; 2724 + sdev_priv_data->pend_count = 0; 2725 + blk_mq_tagset_busy_iter(&mrioc->shost->tag_set, 2726 + mpi3mr_count_dev_pending, (void *)sdev); 2727 + break; 2728 + default: 2729 + break; 2730 + } 3087 2731 3088 2732 out_unlock: 3089 2733 drv_cmd->state = MPI3MR_CMD_NOTUSED; ··· 3115 2713 atomic_dec_if_positive(&scsi_tgt_priv_data->block_io); 3116 2714 if (tgtdev) 3117 2715 mpi3mr_tgtdev_put(tgtdev); 3118 - if (!retval) { 3119 - /* 3120 - * Flush all IRQ handlers by calling synchronize_irq(). 3121 - * mpi3mr_ioc_disable_intr() takes care of it. 3122 - */ 3123 - mpi3mr_ioc_disable_intr(mrioc); 3124 - mpi3mr_ioc_enable_intr(mrioc); 3125 - } 3126 2716 out: 3127 2717 return retval; 3128 2718 } ··· 3163 2769 * mpi3mr_map_queues - Map queues callback handler 3164 2770 * @shost: SCSI host reference 3165 2771 * 3166 - * Call the blk_mq_pci_map_queues with from which operational 3167 - * queue the mapping has to be done 2772 + * Maps default and poll queues. 3168 2773 * 3169 - * Return: return of blk_mq_pci_map_queues 2774 + * Return: return zero. 3170 2775 */ 3171 2776 static int mpi3mr_map_queues(struct Scsi_Host *shost) 3172 2777 { 3173 2778 struct mpi3mr_ioc *mrioc = shost_priv(shost); 2779 + int i, qoff, offset; 2780 + struct blk_mq_queue_map *map = NULL; 3174 2781 3175 - return blk_mq_pci_map_queues(&shost->tag_set.map[HCTX_TYPE_DEFAULT], 3176 - mrioc->pdev, mrioc->op_reply_q_offset); 2782 + offset = mrioc->op_reply_q_offset; 2783 + 2784 + for (i = 0, qoff = 0; i < HCTX_MAX_TYPES; i++) { 2785 + map = &shost->tag_set.map[i]; 2786 + 2787 + map->nr_queues = 0; 2788 + 2789 + if (i == HCTX_TYPE_DEFAULT) 2790 + map->nr_queues = mrioc->default_qcount; 2791 + else if (i == HCTX_TYPE_POLL) 2792 + map->nr_queues = mrioc->active_poll_qcount; 2793 + 2794 + if (!map->nr_queues) { 2795 + BUG_ON(i == HCTX_TYPE_DEFAULT); 2796 + continue; 2797 + } 2798 + 2799 + /* 2800 + * The poll queue(s) doesn't have an IRQ (and hence IRQ 2801 + * affinity), so use the regular blk-mq cpu mapping 2802 + */ 2803 + map->queue_offset = qoff; 2804 + if (i != HCTX_TYPE_POLL) 2805 + blk_mq_pci_map_queues(map, mrioc->pdev, offset); 2806 + else 2807 + blk_mq_map_queues(map); 2808 + 2809 + qoff += map->nr_queues; 2810 + offset += map->nr_queues; 2811 + } 2812 + 2813 + return 0; 2814 + 3177 2815 } 3178 2816 3179 2817 /** ··· 3364 2938 3365 2939 stgt_priv_data = sdev_priv_data->tgt_priv_data; 3366 2940 dev_handle = stgt_priv_data->dev_handle; 2941 + if (stgt_priv_data->dev_removed) { 2942 + sdev_printk(KERN_INFO, scmd->device, 2943 + "%s:target(handle = 0x%04x) is removed, target reset is not issued\n", 2944 + mrioc->name, dev_handle); 2945 + retval = FAILED; 2946 + goto out; 2947 + } 3367 2948 sdev_printk(KERN_INFO, scmd->device, 3368 2949 "Target Reset is issued to handle(0x%04x)\n", 3369 2950 dev_handle); ··· 3378 2945 ret = mpi3mr_issue_tm(mrioc, 3379 2946 MPI3_SCSITASKMGMT_TASKTYPE_TARGET_RESET, dev_handle, 3380 2947 sdev_priv_data->lun_id, MPI3MR_HOSTTAG_BLK_TMS, 3381 - MPI3MR_RESETTM_TIMEOUT, &mrioc->host_tm_cmds, &resp_code, NULL); 2948 + MPI3MR_RESETTM_TIMEOUT, &mrioc->host_tm_cmds, &resp_code, scmd); 3382 2949 3383 2950 if (ret) 3384 2951 goto out; 3385 2952 2953 + if (stgt_priv_data->pend_count) { 2954 + sdev_printk(KERN_INFO, scmd->device, 2955 + "%s: target has %d pending commands, target reset is failed\n", 2956 + mrioc->name, sdev_priv_data->pend_count); 2957 + goto out; 2958 + } 2959 + 3386 2960 retval = SUCCESS; 3387 2961 out: 3388 2962 sdev_printk(KERN_INFO, scmd->device, 3389 - "Target reset is %s for scmd(%p)\n", 2963 + "%s: target reset is %s for scmd(%p)\n", mrioc->name, 3390 2964 ((retval == SUCCESS) ? "SUCCESS" : "FAILED"), scmd); 3391 2965 3392 2966 return retval; ··· 3432 2992 3433 2993 stgt_priv_data = sdev_priv_data->tgt_priv_data; 3434 2994 dev_handle = stgt_priv_data->dev_handle; 2995 + if (stgt_priv_data->dev_removed) { 2996 + sdev_printk(KERN_INFO, scmd->device, 2997 + "%s: device(handle = 0x%04x) is removed, device(LUN) reset is not issued\n", 2998 + mrioc->name, dev_handle); 2999 + retval = FAILED; 3000 + goto out; 3001 + } 3435 3002 sdev_printk(KERN_INFO, scmd->device, 3436 3003 "Device(lun) Reset is issued to handle(0x%04x)\n", dev_handle); 3437 3004 3438 3005 ret = mpi3mr_issue_tm(mrioc, 3439 3006 MPI3_SCSITASKMGMT_TASKTYPE_LOGICAL_UNIT_RESET, dev_handle, 3440 3007 sdev_priv_data->lun_id, MPI3MR_HOSTTAG_BLK_TMS, 3441 - MPI3MR_RESETTM_TIMEOUT, &mrioc->host_tm_cmds, &resp_code, NULL); 3008 + MPI3MR_RESETTM_TIMEOUT, &mrioc->host_tm_cmds, &resp_code, scmd); 3442 3009 3443 3010 if (ret) 3444 3011 goto out; 3445 3012 3013 + if (sdev_priv_data->pend_count) { 3014 + sdev_printk(KERN_INFO, scmd->device, 3015 + "%s: device has %d pending commands, device(LUN) reset is failed\n", 3016 + mrioc->name, sdev_priv_data->pend_count); 3017 + goto out; 3018 + } 3446 3019 retval = SUCCESS; 3447 3020 out: 3448 3021 sdev_printk(KERN_INFO, scmd->device, 3449 - "Device(lun) reset is %s for scmd(%p)\n", 3022 + "%s: device(LUN) reset is %s for scmd(%p)\n", mrioc->name, 3450 3023 ((retval == SUCCESS) ? "SUCCESS" : "FAILED"), scmd); 3451 3024 3452 3025 return retval; ··· 3502 3049 { 3503 3050 struct mpi3mr_ioc *mrioc = shost_priv(shost); 3504 3051 u32 pe_timeout = MPI3MR_PORTENABLE_TIMEOUT; 3052 + u32 ioc_status = readl(&mrioc->sysif_regs->ioc_status); 3505 3053 3506 - if (time >= (pe_timeout * HZ)) { 3054 + if ((ioc_status & MPI3_SYSIF_IOC_STATUS_RESET_HISTORY) || 3055 + (ioc_status & MPI3_SYSIF_IOC_STATUS_FAULT)) { 3056 + ioc_err(mrioc, "port enable failed due to fault or reset\n"); 3057 + mpi3mr_print_fault_info(mrioc); 3058 + mrioc->scan_failed = MPI3_IOCSTATUS_INTERNAL_ERROR; 3059 + mrioc->scan_started = 0; 3507 3060 mrioc->init_cmds.is_waiting = 0; 3508 3061 mrioc->init_cmds.callback = NULL; 3509 3062 mrioc->init_cmds.state = MPI3MR_CMD_NOTUSED; 3510 - ioc_err(mrioc, "%s :port enable request timed out\n", __func__); 3511 - mrioc->is_driver_loading = 0; 3512 - mpi3mr_soft_reset_handler(mrioc, 3513 - MPI3MR_RESET_FROM_PE_TIMEOUT, 1); 3514 3063 } 3515 3064 3516 - if (mrioc->scan_failed) { 3517 - ioc_err(mrioc, 3518 - "%s :port enable failed with (ioc_status=0x%08x)\n", 3519 - __func__, mrioc->scan_failed); 3520 - mrioc->is_driver_loading = 0; 3521 - mrioc->stop_drv_processing = 1; 3522 - return 1; 3065 + if (time >= (pe_timeout * HZ)) { 3066 + ioc_err(mrioc, "port enable failed due to time out\n"); 3067 + mpi3mr_check_rh_fault_ioc(mrioc, 3068 + MPI3MR_RESET_FROM_PE_TIMEOUT); 3069 + mrioc->scan_failed = MPI3_IOCSTATUS_INTERNAL_ERROR; 3070 + mrioc->scan_started = 0; 3071 + mrioc->init_cmds.is_waiting = 0; 3072 + mrioc->init_cmds.callback = NULL; 3073 + mrioc->init_cmds.state = MPI3MR_CMD_NOTUSED; 3523 3074 } 3524 3075 3525 3076 if (mrioc->scan_started) 3526 3077 return 0; 3527 - ioc_info(mrioc, "%s :port enable: SUCCESS\n", __func__); 3078 + 3079 + if (mrioc->scan_failed) { 3080 + ioc_err(mrioc, 3081 + "port enable failed with status=0x%04x\n", 3082 + mrioc->scan_failed); 3083 + } else 3084 + ioc_info(mrioc, "port enable is successfully completed\n"); 3085 + 3528 3086 mpi3mr_start_watchdog(mrioc); 3529 3087 mrioc->is_driver_loading = 0; 3530 - 3531 3088 return 1; 3532 3089 } 3533 3090 ··· 3652 3189 switch (tgt_dev->dev_type) { 3653 3190 case MPI3_DEVICE_DEVFORM_PCIE: 3654 3191 /*The block layer hw sector size = 512*/ 3655 - blk_queue_max_hw_sectors(sdev->request_queue, 3656 - tgt_dev->dev_spec.pcie_inf.mdts / 512); 3657 - blk_queue_virt_boundary(sdev->request_queue, 3658 - ((1 << tgt_dev->dev_spec.pcie_inf.pgsz) - 1)); 3192 + if ((tgt_dev->dev_spec.pcie_inf.dev_info & 3193 + MPI3_DEVICE0_PCIE_DEVICE_INFO_TYPE_MASK) == 3194 + MPI3_DEVICE0_PCIE_DEVICE_INFO_TYPE_NVME_DEVICE) { 3195 + blk_queue_max_hw_sectors(sdev->request_queue, 3196 + tgt_dev->dev_spec.pcie_inf.mdts / 512); 3197 + if (tgt_dev->dev_spec.pcie_inf.pgsz == 0) 3198 + blk_queue_virt_boundary(sdev->request_queue, 3199 + ((1 << MPI3MR_DEFAULT_PGSZEXP) - 1)); 3200 + else 3201 + blk_queue_virt_boundary(sdev->request_queue, 3202 + ((1 << tgt_dev->dev_spec.pcie_inf.pgsz) - 1)); 3203 + } 3659 3204 break; 3660 3205 default: 3661 3206 break; ··· 3783 3312 struct scsi_cmnd *scmd) 3784 3313 { 3785 3314 unsigned char *buf; 3786 - u16 param_len, desc_len; 3315 + u16 param_len, desc_len, trunc_param_len; 3787 3316 3788 - param_len = get_unaligned_be16(scmd->cmnd + 7); 3317 + trunc_param_len = param_len = get_unaligned_be16(scmd->cmnd + 7); 3318 + 3319 + if (mrioc->pdev->revision) { 3320 + if ((param_len > 24) && ((param_len - 8) & 0xF)) { 3321 + trunc_param_len -= (param_len - 8) & 0xF; 3322 + dprint_scsi_command(mrioc, scmd, MPI3_DEBUG_SCSI_ERROR); 3323 + dprint_scsi_err(mrioc, 3324 + "truncating param_len from (%d) to (%d)\n", 3325 + param_len, trunc_param_len); 3326 + put_unaligned_be16(trunc_param_len, scmd->cmnd + 7); 3327 + dprint_scsi_command(mrioc, scmd, MPI3_DEBUG_SCSI_ERROR); 3328 + } 3329 + return false; 3330 + } 3789 3331 3790 3332 if (!param_len) { 3791 3333 ioc_warn(mrioc, ··· 3858 3374 } 3859 3375 3860 3376 if (param_len > (desc_len + 8)) { 3377 + trunc_param_len = desc_len + 8; 3861 3378 scsi_print_command(scmd); 3862 - ioc_warn(mrioc, 3863 - "%s: Truncating param_len(%d) to desc_len+8(%d)\n", 3864 - __func__, param_len, (desc_len + 8)); 3865 - param_len = desc_len + 8; 3866 - put_unaligned_be16(param_len, scmd->cmnd + 7); 3379 + dprint_scsi_err(mrioc, 3380 + "truncating param_len(%d) to desc_len+8(%d)\n", 3381 + param_len, trunc_param_len); 3382 + put_unaligned_be16(trunc_param_len, scmd->cmnd + 7); 3867 3383 scsi_print_command(scmd); 3868 3384 } 3869 3385 ··· 3918 3434 u32 scsiio_flags = 0; 3919 3435 struct request *rq = scsi_cmd_to_rq(scmd); 3920 3436 int iprio_class; 3437 + u8 is_pcie_dev = 0; 3921 3438 3922 3439 sdev_priv_data = scmd->device->hostdata; 3923 3440 if (!sdev_priv_data || !sdev_priv_data->tgt_priv_data) { ··· 3963 3478 goto out; 3964 3479 } 3965 3480 3966 - if ((scmd->cmnd[0] == UNMAP) && 3967 - (stgt_priv_data->dev_type == MPI3_DEVICE_DEVFORM_PCIE) && 3481 + if (stgt_priv_data->dev_type == MPI3_DEVICE_DEVFORM_PCIE) 3482 + is_pcie_dev = 1; 3483 + if ((scmd->cmnd[0] == UNMAP) && is_pcie_dev && 3484 + (mrioc->pdev->device == MPI3_MFGPAGE_DEVID_SAS4116) && 3968 3485 mpi3mr_check_return_unmap(mrioc, scmd)) 3969 3486 goto out; 3970 3487 ··· 4046 3559 .eh_host_reset_handler = mpi3mr_eh_host_reset, 4047 3560 .bios_param = mpi3mr_bios_param, 4048 3561 .map_queues = mpi3mr_map_queues, 3562 + .mq_poll = mpi3mr_blk_mq_poll, 4049 3563 .no_write_same = 1, 4050 3564 .can_queue = 1, 4051 3565 .this_id = -1, ··· 4055 3567 */ 4056 3568 .max_sectors = 2048, 4057 3569 .cmd_per_lun = MPI3MR_MAX_CMDS_LUN, 3570 + .max_segment_size = 0xffffffff, 4058 3571 .track_queue_depth = 1, 4059 3572 .cmd_size = sizeof(struct scmd_priv), 4060 3573 }; ··· 4203 3714 INIT_LIST_HEAD(&mrioc->fwevt_list); 4204 3715 INIT_LIST_HEAD(&mrioc->tgtdev_list); 4205 3716 INIT_LIST_HEAD(&mrioc->delayed_rmhs_list); 3717 + INIT_LIST_HEAD(&mrioc->delayed_evtack_cmds_list); 4206 3718 4207 3719 mutex_init(&mrioc->reset_mutex); 4208 3720 mpi3mr_init_drv_cmd(&mrioc->init_cmds, MPI3MR_HOSTTAG_INITCMDS); ··· 4262 3772 ioc_err(mrioc, "failure at %s:%d/%s()!\n", 4263 3773 __FILE__, __LINE__, __func__); 4264 3774 retval = -ENODEV; 4265 - goto out_fwevtthread_failed; 3775 + goto fwevtthread_failed; 4266 3776 } 4267 3777 4268 3778 mrioc->is_driver_loading = 1; 4269 - if (mpi3mr_init_ioc(mrioc, MPI3MR_IT_INIT)) { 4270 - ioc_err(mrioc, "failure at %s:%d/%s()!\n", 4271 - __FILE__, __LINE__, __func__); 3779 + mrioc->cpu_count = num_online_cpus(); 3780 + if (mpi3mr_setup_resources(mrioc)) { 3781 + ioc_err(mrioc, "setup resources failed\n"); 4272 3782 retval = -ENODEV; 4273 - goto out_iocinit_failed; 3783 + goto resource_alloc_failed; 3784 + } 3785 + if (mpi3mr_init_ioc(mrioc)) { 3786 + ioc_err(mrioc, "initializing IOC failed\n"); 3787 + retval = -ENODEV; 3788 + goto init_ioc_failed; 4274 3789 } 4275 3790 4276 3791 shost->nr_hw_queues = mrioc->num_op_reply_q; 3792 + if (mrioc->active_poll_qcount) 3793 + shost->nr_maps = 3; 3794 + 4277 3795 shost->can_queue = mrioc->max_host_ios; 4278 3796 shost->sg_tablesize = MPI3MR_SG_DEPTH; 4279 - shost->max_id = mrioc->facts.max_perids; 3797 + shost->max_id = mrioc->facts.max_perids + 1; 4280 3798 4281 3799 retval = scsi_add_host(shost, &pdev->dev); 4282 3800 if (retval) { ··· 4297 3799 return retval; 4298 3800 4299 3801 addhost_failed: 4300 - mpi3mr_cleanup_ioc(mrioc, MPI3MR_COMPLETE_CLEANUP); 4301 - out_iocinit_failed: 3802 + mpi3mr_stop_watchdog(mrioc); 3803 + mpi3mr_cleanup_ioc(mrioc); 3804 + init_ioc_failed: 3805 + mpi3mr_free_mem(mrioc); 3806 + mpi3mr_cleanup_resources(mrioc); 3807 + resource_alloc_failed: 4302 3808 destroy_workqueue(mrioc->fwevt_worker_thread); 4303 - out_fwevtthread_failed: 3809 + fwevtthread_failed: 4304 3810 spin_lock(&mrioc_list_lock); 4305 3811 list_del(&mrioc->list); 4306 3812 spin_unlock(&mrioc_list_lock); ··· 4317 3815 * mpi3mr_remove - PCI remove callback 4318 3816 * @pdev: PCI device instance 4319 3817 * 3818 + * Cleanup the IOC by issuing MUR and shutdown notification. 4320 3819 * Free up all memory and resources associated with the 4321 3820 * controllerand target devices, unregister the shost. 4322 3821 * ··· 4354 3851 mpi3mr_tgtdev_del_from_list(mrioc, tgtdev); 4355 3852 mpi3mr_tgtdev_put(tgtdev); 4356 3853 } 4357 - mpi3mr_cleanup_ioc(mrioc, MPI3MR_COMPLETE_CLEANUP); 3854 + mpi3mr_stop_watchdog(mrioc); 3855 + mpi3mr_cleanup_ioc(mrioc); 3856 + mpi3mr_free_mem(mrioc); 3857 + mpi3mr_cleanup_resources(mrioc); 4358 3858 4359 3859 spin_lock(&mrioc_list_lock); 4360 3860 list_del(&mrioc->list); ··· 4397 3891 spin_unlock_irqrestore(&mrioc->fwevt_lock, flags); 4398 3892 if (wq) 4399 3893 destroy_workqueue(wq); 4400 - mpi3mr_cleanup_ioc(mrioc, MPI3MR_COMPLETE_CLEANUP); 3894 + 3895 + mpi3mr_stop_watchdog(mrioc); 3896 + mpi3mr_cleanup_ioc(mrioc); 3897 + mpi3mr_cleanup_resources(mrioc); 4401 3898 } 4402 3899 4403 3900 #ifdef CONFIG_PM ··· 4430 3921 mpi3mr_cleanup_fwevt_list(mrioc); 4431 3922 scsi_block_requests(shost); 4432 3923 mpi3mr_stop_watchdog(mrioc); 4433 - mpi3mr_cleanup_ioc(mrioc, MPI3MR_SUSPEND); 3924 + mpi3mr_cleanup_ioc(mrioc); 4434 3925 4435 3926 device_state = pci_choose_state(pdev, state); 4436 3927 ioc_info(mrioc, "pdev=0x%p, slot=%s, entering operating state [D%d]\n", ··· 4479 3970 4480 3971 mrioc->stop_drv_processing = 0; 4481 3972 mpi3mr_memset_buffers(mrioc); 4482 - mpi3mr_init_ioc(mrioc, MPI3MR_IT_RESUME); 3973 + r = mpi3mr_reinit_ioc(mrioc, 1); 3974 + if (r) { 3975 + ioc_err(mrioc, "resuming controller failed[%d]\n", r); 3976 + return r; 3977 + } 4483 3978 scsi_unblock_requests(shost); 4484 3979 mpi3mr_start_watchdog(mrioc); 4485 3980 ··· 4493 3980 4494 3981 static const struct pci_device_id mpi3mr_pci_id_table[] = { 4495 3982 { 4496 - PCI_DEVICE_SUB(PCI_VENDOR_ID_LSI_LOGIC, 0x00A5, 4497 - PCI_ANY_ID, PCI_ANY_ID) 3983 + PCI_DEVICE_SUB(MPI3_MFGPAGE_VENDORID_BROADCOM, 3984 + MPI3_MFGPAGE_DEVID_SAS4116, PCI_ANY_ID, PCI_ANY_ID) 4498 3985 }, 4499 3986 { 0 } 4500 3987 };
+5
drivers/scsi/mvsas/mv_sas.c
··· 67 67 68 68 while (sha->sas_port[i]) { 69 69 if (sha->sas_port[i] == dev->port) { 70 + spin_lock(&sha->sas_port[i]->phy_list_lock); 70 71 phy = container_of(sha->sas_port[i]->phy_list.next, 71 72 struct asd_sas_phy, port_phy_el); 73 + spin_unlock(&sha->sas_port[i]->phy_list_lock); 72 74 j = 0; 73 75 while (sha->sas_phy[j]) { 74 76 if (sha->sas_phy[j] == phy) ··· 98 96 while (sha->sas_port[i]) { 99 97 if (sha->sas_port[i] == dev->port) { 100 98 struct asd_sas_phy *phy; 99 + 100 + spin_lock(&sha->sas_port[i]->phy_list_lock); 101 101 list_for_each_entry(phy, 102 102 &sha->sas_port[i]->phy_list, port_phy_el) { 103 103 j = 0; ··· 113 109 num++; 114 110 n++; 115 111 } 112 + spin_unlock(&sha->sas_port[i]->phy_list_lock); 116 113 break; 117 114 } 118 115 i++;
+1 -1
drivers/scsi/myrb.c
··· 1674 1674 if (sdev->id > MYRB_MAX_TARGETS) 1675 1675 return -ENXIO; 1676 1676 1677 - pdev_info = kzalloc(sizeof(*pdev_info), GFP_KERNEL|GFP_DMA); 1677 + pdev_info = kzalloc(sizeof(*pdev_info), GFP_KERNEL); 1678 1678 if (!pdev_info) 1679 1679 return -ENOMEM; 1680 1680
+4 -6
drivers/scsi/myrs.c
··· 538 538 cs->fwstat_buf = NULL; 539 539 goto out_free; 540 540 } 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); 543 542 if (!cs->ctlr_info) 544 543 goto out_free; 545 544 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); 548 546 if (!cs->event_buf) 549 547 goto out_free; 550 548 ··· 1803 1805 1804 1806 ldev_num = myrs_translate_ldev(cs, sdev); 1805 1807 1806 - ldev_info = kzalloc(sizeof(*ldev_info), GFP_KERNEL|GFP_DMA); 1808 + ldev_info = kzalloc(sizeof(*ldev_info), GFP_KERNEL); 1807 1809 if (!ldev_info) 1808 1810 return -ENOMEM; 1809 1811 ··· 1865 1867 } else { 1866 1868 struct myrs_pdev_info *pdev_info; 1867 1869 1868 - pdev_info = kzalloc(sizeof(*pdev_info), GFP_KERNEL|GFP_DMA); 1870 + pdev_info = kzalloc(sizeof(*pdev_info), GFP_KERNEL); 1869 1871 if (!pdev_info) 1870 1872 return -ENOMEM; 1871 1873
+5 -2
drivers/scsi/pm8001/Makefile
··· 6 6 7 7 8 8 obj-$(CONFIG_SCSI_PM8001) += pm80xx.o 9 + 10 + CFLAGS_pm80xx_tracepoints.o := -I$(src) 11 + 9 12 pm80xx-y += pm8001_init.o \ 10 13 pm8001_sas.o \ 11 14 pm8001_ctl.o \ 12 15 pm8001_hwi.o \ 13 - pm80xx_hwi.o 14 - 16 + pm80xx_hwi.o \ 17 + pm80xx_tracepoints.o
+12 -12
drivers/scsi/pm8001/pm8001_ctl.c
··· 889 889 static DEVICE_ATTR(update_fw, S_IRUGO|S_IWUSR|S_IWGRP, 890 890 pm8001_show_update_fw, pm8001_store_update_fw); 891 891 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 - 900 892 static const char *const mpiStateText[] = { 901 893 "MPI is not initialized", 902 894 "MPI is successfully initialized", ··· 896 904 "MPI initialization failed with error in [31:16]" 897 905 }; 898 906 907 + /** 908 + * ctl_mpi_state_show - controller MPI state check 909 + * @cdev: pointer to embedded class device 910 + * @attr: device attribute (unused) 911 + * @buf: the buffer returned 912 + * 913 + * A sysfs 'read-only' shost attribute. 914 + */ 899 915 static ssize_t ctl_mpi_state_show(struct device *cdev, 900 916 struct device_attribute *attr, char *buf) 901 917 { ··· 920 920 /** 921 921 * ctl_hmi_error_show - controller MPI initialization fails 922 922 * @cdev: pointer to embedded class device 923 + * @attr: device attribute (unused) 923 924 * @buf: the buffer returned 924 925 * 925 926 * A sysfs 'read-only' shost attribute. 926 927 */ 927 - 928 928 static ssize_t ctl_hmi_error_show(struct device *cdev, 929 929 struct device_attribute *attr, char *buf) 930 930 { ··· 941 941 /** 942 942 * ctl_raae_count_show - controller raae count check 943 943 * @cdev: pointer to embedded class device 944 + * @attr: device attribute (unused) 944 945 * @buf: the buffer returned 945 946 * 946 947 * A sysfs 'read-only' shost attribute. 947 948 */ 948 - 949 949 static ssize_t ctl_raae_count_show(struct device *cdev, 950 950 struct device_attribute *attr, char *buf) 951 951 { ··· 962 962 /** 963 963 * ctl_iop0_count_show - controller iop0 count check 964 964 * @cdev: pointer to embedded class device 965 + * @attr: device attribute (unused) 965 966 * @buf: the buffer returned 966 967 * 967 968 * A sysfs 'read-only' shost attribute. 968 969 */ 969 - 970 970 static ssize_t ctl_iop0_count_show(struct device *cdev, 971 971 struct device_attribute *attr, char *buf) 972 972 { ··· 983 983 /** 984 984 * ctl_iop1_count_show - controller iop1 count check 985 985 * @cdev: pointer to embedded class device 986 + * @attr: device attribute (unused) 986 987 * @buf: the buffer returned 987 988 * 988 989 * A sysfs 'read-only' shost attribute. 989 990 */ 990 - 991 991 static ssize_t ctl_iop1_count_show(struct device *cdev, 992 992 struct device_attribute *attr, char *buf) 993 993 {
+12 -21
drivers/scsi/pm8001/pm8001_hwi.c
··· 42 42 #include "pm8001_hwi.h" 43 43 #include "pm8001_chips.h" 44 44 #include "pm8001_ctl.h" 45 + #include "pm80xx_tracepoints.h" 45 46 46 47 /** 47 48 * read_main_config_table - read the configure table and save it. ··· 1325 1324 unsigned long flags; 1326 1325 int q_index = circularQ - pm8001_ha->inbnd_q_tbl; 1327 1326 int rv; 1327 + u32 htag = le32_to_cpu(*(__le32 *)payload); 1328 1328 1329 - WARN_ON(q_index >= PM8001_MAX_INB_NUM); 1329 + trace_pm80xx_mpi_build_cmd(pm8001_ha->id, opCode, htag, q_index, 1330 + circularQ->producer_idx, le32_to_cpu(circularQ->consumer_index)); 1331 + 1332 + if (WARN_ON(q_index >= pm8001_ha->max_q_num)) 1333 + return -EINVAL; 1334 + 1330 1335 spin_lock_irqsave(&circularQ->iq_lock, flags); 1331 1336 rv = pm8001_mpi_msg_free_get(circularQ, pm8001_ha->iomb_size, 1332 1337 &pMessage); ··· 2311 2304 2312 2305 psataPayload = (struct sata_completion_resp *)(piomb + 4); 2313 2306 status = le32_to_cpu(psataPayload->status); 2307 + param = le32_to_cpu(psataPayload->param); 2314 2308 tag = le32_to_cpu(psataPayload->tag); 2315 2309 2316 2310 if (!tag) { 2317 2311 pm8001_dbg(pm8001_ha, FAIL, "tag null\n"); 2318 2312 return; 2319 2313 } 2314 + 2320 2315 ccb = &pm8001_ha->ccb_info[tag]; 2321 - param = le32_to_cpu(psataPayload->param); 2322 - if (ccb) { 2323 - t = ccb->task; 2324 - pm8001_dev = ccb->device; 2325 - } else { 2326 - pm8001_dbg(pm8001_ha, FAIL, "ccb null\n"); 2327 - return; 2328 - } 2316 + t = ccb->task; 2317 + pm8001_dev = ccb->device; 2329 2318 2330 2319 if (t) { 2331 2320 if (t->dev && (t->dev->lldd_dev)) ··· 2338 2335 } 2339 2336 2340 2337 ts = &t->task_status; 2341 - if (!ts) { 2342 - pm8001_dbg(pm8001_ha, FAIL, "ts null\n"); 2343 - return; 2344 - } 2345 2338 2346 2339 if (status) 2347 2340 pm8001_dbg(pm8001_ha, IOERR, ··· 2694 2695 u32 dev_id = le32_to_cpu(psataPayload->device_id); 2695 2696 unsigned long flags; 2696 2697 2697 - ccb = &pm8001_ha->ccb_info[tag]; 2698 - 2699 - if (ccb) { 2700 - t = ccb->task; 2701 - pm8001_dev = ccb->device; 2702 - } else { 2703 - pm8001_dbg(pm8001_ha, FAIL, "No CCB !!!. returning\n"); 2704 - } 2705 2698 if (event) 2706 2699 pm8001_dbg(pm8001_ha, FAIL, "SATA EVENT 0x%x\n", event); 2707 2700
+2 -2
drivers/scsi/pm8001/pm8001_init.c
··· 179 179 } 180 180 PM8001_CHIP_DISP->chip_iounmap(pm8001_ha); 181 181 flush_workqueue(pm8001_wq); 182 - kfree(pm8001_ha->tags); 182 + bitmap_free(pm8001_ha->tags); 183 183 kfree(pm8001_ha); 184 184 } 185 185 ··· 1192 1192 can_queue = ccb_count - PM8001_RESERVE_SLOT; 1193 1193 shost->can_queue = can_queue; 1194 1194 1195 - pm8001_ha->tags = kzalloc(ccb_count, GFP_KERNEL); 1195 + pm8001_ha->tags = bitmap_zalloc(ccb_count, GFP_KERNEL); 1196 1196 if (!pm8001_ha->tags) 1197 1197 goto err_out; 1198 1198
+16
drivers/scsi/pm8001/pm8001_sas.c
··· 40 40 41 41 #include <linux/slab.h> 42 42 #include "pm8001_sas.h" 43 + #include "pm80xx_tracepoints.h" 43 44 44 45 /** 45 46 * pm8001_find_tag - from sas task to find out tag that belongs to this task ··· 528 527 void pm8001_ccb_task_free(struct pm8001_hba_info *pm8001_ha, 529 528 struct sas_task *task, struct pm8001_ccb_info *ccb, u32 ccb_idx) 530 529 { 530 + struct ata_queued_cmd *qc; 531 + struct pm8001_device *pm8001_dev; 532 + 531 533 if (!ccb->task) 532 534 return; 533 535 if (!sas_protocol_ata(task->task_proto)) ··· 553 549 /* do nothing */ 554 550 break; 555 551 } 552 + 553 + if (sas_protocol_ata(task->task_proto)) { 554 + // For SCSI/ATA commands uldd_task points to ata_queued_cmd 555 + qc = task->uldd_task; 556 + pm8001_dev = ccb->device; 557 + trace_pm80xx_request_complete(pm8001_ha->id, 558 + pm8001_dev ? pm8001_dev->attached_phy : PM8001_MAX_PHYS, 559 + ccb_idx, 0 /* ctlr_opcode not known */, 560 + qc ? qc->tf.command : 0, // ata opcode 561 + pm8001_dev ? atomic_read(&pm8001_dev->running_req) : -1); 562 + } 563 + 556 564 task->lldd_task = NULL; 557 565 ccb->task = NULL; 558 566 ccb->ccb_tag = 0xFFFFFFFF;
+16 -22
drivers/scsi/pm8001/pm80xx_hwi.c
··· 42 42 #include "pm80xx_hwi.h" 43 43 #include "pm8001_chips.h" 44 44 #include "pm8001_ctl.h" 45 + #include "pm80xx_tracepoints.h" 45 46 46 47 #define SMP_DIRECT 1 47 48 #define SMP_INDIRECT 2 ··· 2401 2400 2402 2401 psataPayload = (struct sata_completion_resp *)(piomb + 4); 2403 2402 status = le32_to_cpu(psataPayload->status); 2403 + param = le32_to_cpu(psataPayload->param); 2404 2404 tag = le32_to_cpu(psataPayload->tag); 2405 2405 2406 2406 if (!tag) { 2407 2407 pm8001_dbg(pm8001_ha, FAIL, "tag null\n"); 2408 2408 return; 2409 2409 } 2410 + 2410 2411 ccb = &pm8001_ha->ccb_info[tag]; 2411 - param = le32_to_cpu(psataPayload->param); 2412 - if (ccb) { 2413 - t = ccb->task; 2414 - pm8001_dev = ccb->device; 2415 - } else { 2416 - pm8001_dbg(pm8001_ha, FAIL, "ccb null\n"); 2417 - return; 2418 - } 2412 + t = ccb->task; 2413 + pm8001_dev = ccb->device; 2419 2414 2420 2415 if (t) { 2421 2416 if (t->dev && (t->dev->lldd_dev)) ··· 2428 2431 } 2429 2432 2430 2433 ts = &t->task_status; 2431 - if (!ts) { 2432 - pm8001_dbg(pm8001_ha, FAIL, "ts null\n"); 2433 - return; 2434 - } 2435 2434 2436 2435 if (status != IO_SUCCESS) { 2437 2436 pm8001_dbg(pm8001_ha, FAIL, ··· 2823 2830 u32 dev_id = le32_to_cpu(psataPayload->device_id); 2824 2831 unsigned long flags; 2825 2832 2826 - ccb = &pm8001_ha->ccb_info[tag]; 2827 - 2828 - if (ccb) { 2829 - t = ccb->task; 2830 - pm8001_dev = ccb->device; 2831 - } else { 2832 - pm8001_dbg(pm8001_ha, FAIL, "No CCB !!!. returning\n"); 2833 - return; 2834 - } 2835 2833 if (event) 2836 2834 pm8001_dbg(pm8001_ha, FAIL, "SATA EVENT 0x%x\n", event); 2837 2835 ··· 2835 2851 pm80xx_send_read_log(pm8001_ha, pm8001_dev); 2836 2852 return; 2837 2853 } 2854 + 2855 + ccb = &pm8001_ha->ccb_info[tag]; 2856 + t = ccb->task; 2857 + pm8001_dev = ccb->device; 2838 2858 2839 2859 if (unlikely(!t || !t->lldd_task || !t->dev)) { 2840 2860 pm8001_dbg(pm8001_ha, FAIL, "task or dev null\n"); ··· 3510 3522 u32 status = 3511 3523 le32_to_cpu(pPayload->status); 3512 3524 u32 phy_id = 3513 - le32_to_cpu(pPayload->phyid); 3525 + le32_to_cpu(pPayload->phyid) & 0xFF; 3514 3526 struct pm8001_phy *phy = &pm8001_ha->phy[phy_id]; 3515 3527 3516 3528 pm8001_dbg(pm8001_ha, INIT, ··· 4535 4547 struct sas_task *task = ccb->task; 4536 4548 struct domain_device *dev = task->dev; 4537 4549 struct pm8001_device *pm8001_ha_dev = dev->lldd_dev; 4550 + struct ata_queued_cmd *qc = task->uldd_task; 4538 4551 u32 tag = ccb->ccb_tag; 4539 4552 int ret; 4540 4553 u32 q_index, cpu_id; ··· 4755 4766 } 4756 4767 } 4757 4768 } 4769 + trace_pm80xx_request_issue(pm8001_ha->id, 4770 + ccb->device ? ccb->device->attached_phy : PM8001_MAX_PHYS, 4771 + ccb->ccb_tag, opc, 4772 + qc ? qc->tf.command : 0, // ata opcode 4773 + ccb->device ? atomic_read(&ccb->device->running_req) : 0); 4758 4774 ret = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, 4759 4775 &sata_cmd, sizeof(sata_cmd), q_index); 4760 4776 return ret;
+10
drivers/scsi/pm8001/pm80xx_tracepoints.c
··· 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"
+113
drivers/scsi/pm8001/pm80xx_tracepoints.h
··· 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>
+2 -3
drivers/scsi/pmcraid.c
··· 3221 3221 return NULL; 3222 3222 3223 3223 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); 3226 3226 3227 3227 return sglist; 3228 3228 } ··· 3302 3302 /** 3303 3303 * pmcraid_queuecommand_lck - Queue a mid-layer request 3304 3304 * @scsi_cmd: scsi command struct 3305 - * @done: done function 3306 3305 * 3307 3306 * This function queues a request generated by the mid-layer. Midlayer calls 3308 3307 * this routine within host->lock. Some of the functions called by queuecommand
+2 -6
drivers/scsi/qedi/qedi_main.c
··· 1538 1538 int i; 1539 1539 struct scsi_bd *pbl; 1540 1540 u64 *list; 1541 - dma_addr_t page; 1542 1541 1543 1542 /* Alloc dma memory for BDQ buffers */ 1544 1543 for (i = 0; i < QEDI_BDQ_NUM; i++) { ··· 1607 1608 qedi->bdq_pbl_list_num_entries = qedi->bdq_pbl_mem_size / 1608 1609 QEDI_PAGE_SIZE; 1609 1610 list = (u64 *)qedi->bdq_pbl_list; 1610 - page = qedi->bdq_pbl_list_dma; 1611 1611 for (i = 0; i < qedi->bdq_pbl_list_num_entries; i++) { 1612 1612 *list = qedi->bdq_pbl_dma; 1613 1613 list++; 1614 - page += QEDI_PAGE_SIZE; 1615 1614 } 1616 1615 1617 1616 return 0; ··· 2086 2089 rc = snprintf(buf, ip_len, fmt, gw); 2087 2090 break; 2088 2091 case ISCSI_BOOT_ETH_FLAGS: 2089 - rc = snprintf(buf, 3, "%hhd\n", 2090 - SYSFS_FLAG_FW_SEL_BOOT); 2092 + rc = snprintf(buf, 3, "%d\n", (char)SYSFS_FLAG_FW_SEL_BOOT); 2091 2093 break; 2092 2094 case ISCSI_BOOT_ETH_INDEX: 2093 2095 rc = snprintf(buf, 3, "0\n"); ··· 2253 2257 mchap_secret); 2254 2258 break; 2255 2259 case ISCSI_BOOT_TGT_FLAGS: 2256 - rc = snprintf(buf, 3, "%hhd\n", SYSFS_FLAG_FW_SEL_BOOT); 2260 + rc = snprintf(buf, 3, "%d\n", (char)SYSFS_FLAG_FW_SEL_BOOT); 2257 2261 break; 2258 2262 case ISCSI_BOOT_TGT_NIC_ASSOC: 2259 2263 rc = snprintf(buf, 3, "0\n");
+6
drivers/scsi/qla2xxx/qla_attr.c
··· 2700 2700 static inline void 2701 2701 qla2x00_set_rport_loss_tmo(struct fc_rport *rport, uint32_t timeout) 2702 2702 { 2703 + fc_port_t *fcport = *(fc_port_t **)rport->dd_data; 2704 + 2703 2705 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); 2704 2710 } 2705 2711 2706 2712 static void
+3 -7
drivers/scsi/qla2xxx/qla_init.c
··· 5828 5828 5829 5829 qla2x00_dfs_create_rport(vha, fcport); 5830 5830 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 - 5838 5831 qla24xx_update_fcport_fcp_prio(vha, fcport); 5839 5832 5840 5833 switch (vha->host->active_mode) { ··· 5848 5855 default: 5849 5856 break; 5850 5857 } 5858 + 5859 + if (NVME_TARGET(vha->hw, fcport)) 5860 + qla_nvme_register_remote(vha, fcport); 5851 5861 5852 5862 qla2x00_set_fcport_state(fcport, FCS_ONLINE); 5853 5863
+4 -1
drivers/scsi/qla2xxx/qla_nvme.c
··· 43 43 req.port_name = wwn_to_u64(fcport->port_name); 44 44 req.node_name = wwn_to_u64(fcport->node_name); 45 45 req.port_role = 0; 46 - req.dev_loss_tmo = 0; 46 + req.dev_loss_tmo = fcport->dev_loss_tmo; 47 47 48 48 if (fcport->nvme_prli_service_param & NVME_PRLI_SP_INITIATOR) 49 49 req.port_role = FC_PORT_ROLE_NVME_INITIATOR; ··· 69 69 ret); 70 70 return ret; 71 71 } 72 + 73 + nvme_fc_set_remoteport_devloss(fcport->nvme_remote_port, 74 + fcport->dev_loss_tmo); 72 75 73 76 if (fcport->nvme_prli_service_param & NVME_PRLI_SP_SLER) 74 77 ql_log(ql_log_info, vha, 0x212a,
+2 -2
drivers/scsi/qla4xxx/ql4_os.c
··· 5734 5734 5735 5735 switch (type) { 5736 5736 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); 5738 5738 break; 5739 5739 case ISCSI_BOOT_ETH_INDEX: 5740 5740 rc = sprintf(str, "0\n"); ··· 5843 5843 (char *)&boot_conn->chap.intr_secret); 5844 5844 break; 5845 5845 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); 5847 5847 break; 5848 5848 case ISCSI_BOOT_TGT_NIC_ASSOC: 5849 5849 rc = sprintf(str, "0\n");
+2 -3
drivers/scsi/scsi.c
··· 55 55 #include <linux/notifier.h> 56 56 #include <linux/cpu.h> 57 57 #include <linux/mutex.h> 58 - #include <linux/async.h> 59 58 #include <asm/unaligned.h> 60 59 61 60 #include <scsi/scsi.h> ··· 200 201 201 202 202 203 /* 203 - * 1024 is big enough for saturating the fast scsi LUN now 204 + * 1024 is big enough for saturating fast SCSI LUNs. 204 205 */ 205 206 int scsi_device_max_queue_depth(struct scsi_device *sdev) 206 207 { 207 - return max_t(int, sdev->host->can_queue, 1024); 208 + return min_t(int, sdev->host->can_queue, 1024); 208 209 } 209 210 210 211 /**
+1
drivers/scsi/scsi_debugfs.c
··· 9 9 static const char *const scsi_cmd_flags[] = { 10 10 SCSI_CMD_FLAG_NAME(TAGGED), 11 11 SCSI_CMD_FLAG_NAME(INITIALIZED), 12 + SCSI_CMD_FLAG_NAME(LAST), 12 13 }; 13 14 #undef SCSI_CMD_FLAG_NAME 14 15
+59 -57
drivers/scsi/scsi_error.c
··· 133 133 return true; 134 134 } 135 135 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 - 153 136 /** 154 137 * scmd_eh_abort_handler - Handle command aborts 155 138 * @work: command to be aborted. ··· 149 166 struct scsi_cmnd *scmd = 150 167 container_of(work, struct scsi_cmnd, abort_work.work); 151 168 struct scsi_device *sdev = scmd->device; 169 + struct Scsi_Host *shost = sdev->host; 152 170 enum scsi_disposition rtn; 153 171 unsigned long flags; 154 172 155 - if (scsi_host_eh_past_deadline(sdev->host)) { 173 + if (scsi_host_eh_past_deadline(shost)) { 156 174 SCSI_LOG_ERROR_RECOVERY(3, 157 175 scmd_printk(KERN_INFO, scmd, 158 176 "eh timeout, not aborting\n")); 159 - } else { 160 - SCSI_LOG_ERROR_RECOVERY(3, 161 - scmd_printk(KERN_INFO, scmd, 162 - "aborting command\n")); 163 - rtn = scsi_try_to_abort_cmd(sdev->host->hostt, scmd); 164 - if (rtn == SUCCESS) { 165 - set_host_byte(scmd, DID_TIME_OUT); 166 - if (scsi_host_eh_past_deadline(sdev->host)) { 167 - SCSI_LOG_ERROR_RECOVERY(3, 168 - scmd_printk(KERN_INFO, scmd, 169 - "eh timeout, not retrying " 170 - "aborted command\n")); 171 - } else if (!scsi_noretry_cmd(scmd) && 172 - scsi_cmd_retry_allowed(scmd) && 173 - scsi_eh_should_retry_cmd(scmd)) { 174 - SCSI_LOG_ERROR_RECOVERY(3, 175 - scmd_printk(KERN_WARNING, scmd, 176 - "retry aborted command\n")); 177 - scsi_eh_complete_abort(scmd, sdev->host); 178 - scsi_queue_insert(scmd, SCSI_MLQUEUE_EH_RETRY); 179 - return; 180 - } else { 181 - SCSI_LOG_ERROR_RECOVERY(3, 182 - scmd_printk(KERN_WARNING, scmd, 183 - "finish aborted command\n")); 184 - scsi_eh_complete_abort(scmd, sdev->host); 185 - scsi_finish_command(scmd); 186 - return; 187 - } 188 - } else { 189 - SCSI_LOG_ERROR_RECOVERY(3, 190 - scmd_printk(KERN_INFO, scmd, 191 - "cmd abort %s\n", 192 - (rtn == FAST_IO_FAIL) ? 193 - "not send" : "failed")); 194 - } 177 + goto out; 195 178 } 196 179 197 - spin_lock_irqsave(sdev->host->host_lock, flags); 180 + SCSI_LOG_ERROR_RECOVERY(3, 181 + scmd_printk(KERN_INFO, scmd, 182 + "aborting command\n")); 183 + rtn = scsi_try_to_abort_cmd(shost->hostt, scmd); 184 + if (rtn != SUCCESS) { 185 + SCSI_LOG_ERROR_RECOVERY(3, 186 + scmd_printk(KERN_INFO, scmd, 187 + "cmd abort %s\n", 188 + (rtn == FAST_IO_FAIL) ? 189 + "not send" : "failed")); 190 + goto out; 191 + } 192 + set_host_byte(scmd, DID_TIME_OUT); 193 + if (scsi_host_eh_past_deadline(shost)) { 194 + SCSI_LOG_ERROR_RECOVERY(3, 195 + scmd_printk(KERN_INFO, scmd, 196 + "eh timeout, not retrying " 197 + "aborted command\n")); 198 + goto out; 199 + } 200 + 201 + spin_lock_irqsave(shost->host_lock, flags); 198 202 list_del_init(&scmd->eh_entry); 199 - spin_unlock_irqrestore(sdev->host->host_lock, flags); 203 + 204 + /* 205 + * If the abort succeeds, and there is no further 206 + * EH action, clear the ->last_reset time. 207 + */ 208 + if (list_empty(&shost->eh_abort_list) && 209 + list_empty(&shost->eh_cmd_q)) 210 + if (shost->eh_deadline != -1) 211 + shost->last_reset = 0; 212 + 213 + spin_unlock_irqrestore(shost->host_lock, flags); 214 + 215 + if (!scsi_noretry_cmd(scmd) && 216 + scsi_cmd_retry_allowed(scmd) && 217 + scsi_eh_should_retry_cmd(scmd)) { 218 + SCSI_LOG_ERROR_RECOVERY(3, 219 + scmd_printk(KERN_WARNING, scmd, 220 + "retry aborted command\n")); 221 + scsi_queue_insert(scmd, SCSI_MLQUEUE_EH_RETRY); 222 + } else { 223 + SCSI_LOG_ERROR_RECOVERY(3, 224 + scmd_printk(KERN_WARNING, scmd, 225 + "finish aborted command\n")); 226 + scsi_finish_command(scmd); 227 + } 228 + return; 229 + 230 + out: 231 + spin_lock_irqsave(shost->host_lock, flags); 232 + list_del_init(&scmd->eh_entry); 233 + spin_unlock_irqrestore(shost->host_lock, flags); 234 + 200 235 scsi_eh_scmd_add(scmd); 201 236 } 202 237 ··· 1430 1429 enum scsi_disposition rtn = NEEDS_RETRY; 1431 1430 1432 1431 for (i = 0; rtn == NEEDS_RETRY && i < 2; i++) 1433 - rtn = scsi_send_eh_cmnd(scmd, stu_command, 6, scmd->device->request_queue->rq_timeout, 0); 1432 + rtn = scsi_send_eh_cmnd(scmd, stu_command, 6, 1433 + scmd->device->eh_timeout, 0); 1434 1434 1435 1435 if (rtn == SUCCESS) 1436 1436 return 0;
+1 -2
drivers/scsi/scsi_pm.c
··· 8 8 9 9 #include <linux/pm_runtime.h> 10 10 #include <linux/export.h> 11 - #include <linux/async.h> 12 11 #include <linux/blk-pm.h> 13 12 14 13 #include <scsi/scsi.h> ··· 180 181 blk_pre_runtime_resume(sdev->request_queue); 181 182 if (pm && pm->runtime_resume) 182 183 err = pm->runtime_resume(dev); 183 - blk_post_runtime_resume(sdev->request_queue, err); 184 + blk_post_runtime_resume(sdev->request_queue); 184 185 185 186 return err; 186 187 }
+1 -2
drivers/scsi/scsi_priv.h
··· 3 3 #define _SCSI_PRIV_H 4 4 5 5 #include <linux/device.h> 6 - #include <linux/async.h> 7 6 #include <scsi/scsi_device.h> 8 7 #include <linux/sbitmap.h> 9 8 ··· 143 144 extern void __scsi_remove_device(struct scsi_device *); 144 145 145 146 extern struct bus_type scsi_bus_type; 146 - extern const struct attribute_group scsi_shost_attr_group; 147 + extern const struct attribute_group *scsi_shost_groups[]; 147 148 148 149 /* scsi_netlink.c */ 149 150 #ifdef CONFIG_SCSI_NETLINK
+2 -2
drivers/scsi/scsi_scan.c
··· 97 97 #define SCSI_SCAN_TYPE_DEFAULT "sync" 98 98 #endif 99 99 100 - char scsi_scan_type[7] = SCSI_SCAN_TYPE_DEFAULT; 100 + static char scsi_scan_type[7] = SCSI_SCAN_TYPE_DEFAULT; 101 101 102 102 module_param_string(scan, scsi_scan_type, sizeof(scsi_scan_type), 103 103 S_IRUGO|S_IWUSR); ··· 122 122 struct completion prev_finished; 123 123 }; 124 124 125 - /** 125 + /* 126 126 * scsi_enable_async_suspend - Enable async suspend and resume 127 127 */ 128 128 void scsi_enable_async_suspend(struct device *dev)
+6 -1
drivers/scsi/scsi_sysfs.c
··· 424 424 NULL 425 425 }; 426 426 427 - const struct attribute_group scsi_shost_attr_group = { 427 + static const struct attribute_group scsi_shost_attr_group = { 428 428 .attrs = scsi_sysfs_shost_attrs, 429 + }; 430 + 431 + const struct attribute_group *scsi_shost_groups[] = { 432 + &scsi_shost_attr_group, 433 + NULL 429 434 }; 430 435 431 436 static void scsi_device_cls_release(struct device *class_dev)
-1
drivers/scsi/sd.c
··· 51 51 #include <linux/major.h> 52 52 #include <linux/mutex.h> 53 53 #include <linux/string_helpers.h> 54 - #include <linux/async.h> 55 54 #include <linux/slab.h> 56 55 #include <linux/sed-opal.h> 57 56 #include <linux/pm_runtime.h>
+3 -3
drivers/scsi/sd_zbc.c
··· 61 61 zone.len = logical_to_sectors(sdp, get_unaligned_be64(&buf[8])); 62 62 zone.capacity = zone.len; 63 63 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) 67 65 zone.wp = zone.start + zone.len; 66 + else 67 + zone.wp = logical_to_sectors(sdp, get_unaligned_be64(&buf[24])); 68 68 69 69 ret = cb(&zone, idx, data); 70 70 if (ret)
+1 -1
drivers/scsi/snic/snic_disc.c
··· 100 100 SNIC_BUG_ON(ntgts == 0); 101 101 buf_len = ntgts * sizeof(struct snic_tgt_id) + SNIC_SG_DESC_ALIGN; 102 102 103 - buf = kzalloc(buf_len, GFP_KERNEL|GFP_DMA); 103 + buf = kzalloc(buf_len, GFP_KERNEL); 104 104 if (!buf) { 105 105 snic_req_free(snic, rqi); 106 106 SNIC_HOST_ERR(snic->shost, "Resp Buf Alloc Failed.\n");
+1 -1
drivers/scsi/sr.c
··· 855 855 856 856 857 857 /* allocate transfer buffer */ 858 - buffer = kmalloc(512, GFP_KERNEL | GFP_DMA); 858 + buffer = kmalloc(512, GFP_KERNEL); 859 859 if (!buffer) { 860 860 sr_printk(KERN_ERR, cd, "out of memory.\n"); 861 861 return;
+2 -2
drivers/scsi/sr_vendor.c
··· 131 131 if (cd->vendor == VENDOR_TOSHIBA) 132 132 density = (blocklength > 2048) ? 0x81 : 0x83; 133 133 134 - buffer = kmalloc(512, GFP_KERNEL | GFP_DMA); 134 + buffer = kmalloc(512, GFP_KERNEL); 135 135 if (!buffer) 136 136 return -ENOMEM; 137 137 ··· 179 179 if (cd->cdi.mask & CDC_MULTI_SESSION) 180 180 return 0; 181 181 182 - buffer = kmalloc(512, GFP_KERNEL | GFP_DMA); 182 + buffer = kmalloc(512, GFP_KERNEL); 183 183 if (!buffer) 184 184 return -ENOMEM; 185 185
+8 -7
drivers/scsi/ufs/Kconfig
··· 50 50 However, do not compile this as a module if your root file system 51 51 (the one containing the directory /) is located on a UFS device. 52 52 53 + if SCSI_UFSHCD 54 + 53 55 config SCSI_UFSHCD_PCI 54 56 tristate "PCI bus based UFS Controller support" 55 - depends on SCSI_UFSHCD && PCI 57 + depends on PCI 56 58 help 57 59 This selects the PCI UFS Host Controller Interface. Select this if 58 60 you have UFS Host Controller with PCI Interface. ··· 73 71 74 72 config SCSI_UFSHCD_PLATFORM 75 73 tristate "Platform bus based UFS Controller support" 76 - depends on SCSI_UFSHCD 77 74 depends on HAS_IOMEM 78 75 help 79 76 This selects the UFS host controller support. Select this if ··· 148 147 149 148 config SCSI_UFS_BSG 150 149 bool "Universal Flash Storage BSG device node" 151 - depends on SCSI_UFSHCD 152 150 select BLK_DEV_BSGLIB 153 151 help 154 152 Universal Flash Storage (UFS) is SCSI transport specification for ··· 177 177 178 178 config SCSI_UFS_CRYPTO 179 179 bool "UFS Crypto Engine Support" 180 - depends on SCSI_UFSHCD && BLK_INLINE_ENCRYPTION 180 + depends on BLK_INLINE_ENCRYPTION 181 181 help 182 182 Enable Crypto Engine Support in UFS. 183 183 Enabling this makes it possible for the kernel to use the crypto ··· 186 186 187 187 config SCSI_UFS_HPB 188 188 bool "Support UFS Host Performance Booster" 189 - depends on SCSI_UFSHCD 190 189 help 191 190 The UFS HPB feature improves random read performance. It caches 192 191 L2P (logical to physical) map of UFS to host DRAM. The driver uses HPB ··· 194 195 195 196 config SCSI_UFS_FAULT_INJECTION 196 197 bool "UFS Fault Injection Support" 197 - depends on SCSI_UFSHCD && FAULT_INJECTION 198 + depends on FAULT_INJECTION 198 199 help 199 200 Enable fault injection support in the UFS driver. This makes it easier 200 201 to test the UFS error handler and abort handler. 201 202 202 203 config SCSI_UFS_HWMON 203 - bool "UFS Temperature Notification" 204 + bool "UFS Temperature Notification" 204 205 depends on SCSI_UFSHCD=HWMON || HWMON=y 205 206 help 206 207 This provides support for UFS hardware monitoring. If enabled, 207 208 a hardware monitoring device will be created for the UFS device. 208 209 209 210 If unsure, say N. 211 + 212 + endif
-1
drivers/scsi/ufs/tc-dwc-g210-pci.c
··· 110 110 return err; 111 111 } 112 112 113 - pci_set_drvdata(pdev, hba); 114 113 pm_runtime_put_noidle(&pdev->dev); 115 114 pm_runtime_allow(&pdev->dev); 116 115
+2 -2
drivers/scsi/ufs/ufs-exynos.c
··· 853 853 } 854 854 855 855 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) 857 857 { 858 858 struct exynos_ufs *ufs = ufshcd_get_variant(hba); 859 859 u32 type; 860 860 861 861 type = hci_readl(ufs, HCI_UTRL_NEXUS_TYPE); 862 862 863 - if (op) 863 + if (is_scsi_cmd) 864 864 hci_writel(ufs, type | (1 << tag), HCI_UTRL_NEXUS_TYPE); 865 865 else 866 866 hci_writel(ufs, type & ~(1 << tag), HCI_UTRL_NEXUS_TYPE);
+7 -1
drivers/scsi/ufs/ufs-hisi.c
··· 396 396 return ret; 397 397 } 398 398 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 + 399 405 static int ufs_hisi_suspend(struct ufs_hba *hba, enum ufs_pm_op pm_op, 400 406 enum ufs_notify_change_status status) 401 407 { ··· 584 578 static const struct dev_pm_ops ufs_hisi_pm_ops = { 585 579 SET_SYSTEM_SLEEP_PM_OPS(ufshcd_system_suspend, ufshcd_system_resume) 586 580 SET_RUNTIME_PM_OPS(ufshcd_runtime_suspend, ufshcd_runtime_resume, NULL) 587 - .prepare = ufshcd_suspend_prepare, 581 + .prepare = ufs_hisi_suspend_prepare, 588 582 .complete = ufshcd_resume_complete, 589 583 }; 590 584
-2
drivers/scsi/ufs/ufshcd-pci.c
··· 538 538 return err; 539 539 } 540 540 541 - pci_set_drvdata(pdev, hba); 542 - 543 541 hba->vops = (struct ufs_hba_variant_ops *)id->driver_data; 544 542 545 543 err = ufshcd_init(hba, mmio_base, pdev->irq);
-2
drivers/scsi/ufs/ufshcd-pltfrm.c
··· 361 361 goto dealloc_host; 362 362 } 363 363 364 - platform_set_drvdata(pdev, hba); 365 - 366 364 pm_runtime_set_active(&pdev->dev); 367 365 pm_runtime_enable(&pdev->dev); 368 366
+206 -141
drivers/scsi/ufs/ufshcd.c
··· 128 128 enum { 129 129 UFSHCD_MAX_CHANNEL = 0, 130 130 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, 133 134 }; 134 135 135 136 static const char *const ufshcd_state_name[] = { ··· 1070 1069 return false; 1071 1070 } 1072 1071 1072 + /* 1073 + * Determine the number of pending commands by counting the bits in the SCSI 1074 + * device budget maps. This approach has been selected because a bit is set in 1075 + * the budget map before scsi_host_queue_ready() checks the host_self_blocked 1076 + * flag. The host_self_blocked flag can be modified by calling 1077 + * scsi_block_requests() or scsi_unblock_requests(). 1078 + */ 1079 + static u32 ufshcd_pending_cmds(struct ufs_hba *hba) 1080 + { 1081 + struct scsi_device *sdev; 1082 + u32 pending = 0; 1083 + 1084 + lockdep_assert_held(hba->host->host_lock); 1085 + __shost_for_each_device(sdev, hba->host) 1086 + pending += sbitmap_weight(&sdev->budget_map); 1087 + 1088 + return pending; 1089 + } 1090 + 1073 1091 static int ufshcd_wait_for_doorbell_clr(struct ufs_hba *hba, 1074 1092 u64 wait_timeout_us) 1075 1093 { 1076 1094 unsigned long flags; 1077 1095 int ret = 0; 1078 1096 u32 tm_doorbell; 1079 - u32 tr_doorbell; 1097 + u32 tr_pending; 1080 1098 bool timeout = false, do_last_check = false; 1081 1099 ktime_t start; 1082 1100 ··· 1113 1093 } 1114 1094 1115 1095 tm_doorbell = ufshcd_readl(hba, REG_UTP_TASK_REQ_DOOR_BELL); 1116 - tr_doorbell = ufshcd_readl(hba, REG_UTP_TRANSFER_REQ_DOOR_BELL); 1117 - if (!tm_doorbell && !tr_doorbell) { 1096 + tr_pending = ufshcd_pending_cmds(hba); 1097 + if (!tm_doorbell && !tr_pending) { 1118 1098 timeout = false; 1119 1099 break; 1120 1100 } else if (do_last_check) { ··· 1134 1114 do_last_check = true; 1135 1115 } 1136 1116 spin_lock_irqsave(hba->host->host_lock, flags); 1137 - } while (tm_doorbell || tr_doorbell); 1117 + } while (tm_doorbell || tr_pending); 1138 1118 1139 1119 if (timeout) { 1140 1120 dev_err(hba->dev, 1141 1121 "%s: timedout waiting for doorbell to clear (tm=0x%x, tr=0x%x)\n", 1142 - __func__, tm_doorbell, tr_doorbell); 1122 + __func__, tm_doorbell, tr_pending); 1143 1123 ret = -EBUSY; 1144 1124 } 1145 1125 out: ··· 1370 1350 &hba->clk_scaling.suspend_work); 1371 1351 1372 1352 return ret; 1373 - } 1374 - 1375 - static bool ufshcd_is_busy(struct request *req, void *priv, bool reserved) 1376 - { 1377 - int *busy = priv; 1378 - 1379 - WARN_ON_ONCE(reserved); 1380 - (*busy)++; 1381 - return false; 1382 - } 1383 - 1384 - /* Whether or not any tag is in use by a request that is in progress. */ 1385 - static bool ufshcd_any_tag_in_use(struct ufs_hba *hba) 1386 - { 1387 - struct request_queue *q = hba->cmd_queue; 1388 - int busy = 0; 1389 - 1390 - blk_mq_tagset_busy_iter(q->tag_set, ufshcd_is_busy, &busy); 1391 - return busy; 1392 1353 } 1393 1354 1394 1355 static int ufshcd_devfreq_get_dev_status(struct device *dev, ··· 1667 1666 bool flush_result; 1668 1667 unsigned long flags; 1669 1668 1670 - if (!ufshcd_is_clkgating_allowed(hba)) 1669 + if (!ufshcd_is_clkgating_allowed(hba) || 1670 + !hba->clk_gating.is_initialized) 1671 1671 goto out; 1672 1672 spin_lock_irqsave(hba->host->host_lock, flags); 1673 1673 hba->clk_gating.active_reqs++; ··· 1771 1769 1772 1770 if (hba->clk_gating.active_reqs 1773 1771 || hba->ufshcd_state != UFSHCD_STATE_OPERATIONAL 1774 - || ufshcd_any_tag_in_use(hba) || hba->outstanding_tasks 1772 + || hba->outstanding_reqs || hba->outstanding_tasks 1775 1773 || hba->active_uic_cmd || hba->uic_async_done) 1776 1774 goto rel_lock; 1777 1775 ··· 1828 1826 1829 1827 if (hba->clk_gating.active_reqs || hba->clk_gating.is_suspended || 1830 1828 hba->ufshcd_state != UFSHCD_STATE_OPERATIONAL || 1831 - hba->outstanding_tasks || 1829 + hba->outstanding_tasks || !hba->clk_gating.is_initialized || 1832 1830 hba->active_uic_cmd || hba->uic_async_done || 1833 1831 hba->clk_gating.state == CLKS_OFF) 1834 1832 return; ··· 1963 1961 { 1964 1962 if (!hba->clk_gating.is_initialized) 1965 1963 return; 1964 + 1966 1965 ufshcd_remove_clk_gating_sysfs(hba); 1967 - cancel_work_sync(&hba->clk_gating.ungate_work); 1968 - cancel_delayed_work_sync(&hba->clk_gating.gate_work); 1969 - destroy_workqueue(hba->clk_gating.clk_gating_workq); 1966 + 1967 + /* Ungate the clock if necessary. */ 1968 + ufshcd_hold(hba, false); 1970 1969 hba->clk_gating.is_initialized = false; 1970 + ufshcd_release(hba); 1971 + 1972 + destroy_workqueue(hba->clk_gating.clk_gating_workq); 1971 1973 } 1972 1974 1973 1975 /* Must be called with host lock acquired */ ··· 2195 2189 hba->nutrs = (hba->capabilities & MASK_TRANSFER_REQUESTS_SLOTS) + 1; 2196 2190 hba->nutmrs = 2197 2191 ((hba->capabilities & MASK_TASK_MANAGEMENT_REQUEST_SLOTS) >> 16) + 1; 2192 + hba->reserved_slot = hba->nutrs - 1; 2198 2193 2199 2194 /* Read crypto capabilities */ 2200 2195 err = ufshcd_hba_init_crypto_capabilities(hba); ··· 2657 2650 return (upiu_wlun_id & ~UFS_UPIU_WLUN_ID) | SCSI_W_LUN_BASE; 2658 2651 } 2659 2652 2660 - static inline bool is_rpmb_wlun(struct scsi_device *sdev) 2661 - { 2662 - return sdev->lun == ufshcd_upiu_wlun_to_scsi_wlun(UFS_UPIU_RPMB_WLUN); 2663 - } 2664 - 2665 2653 static inline bool is_device_wlun(struct scsi_device *sdev) 2666 2654 { 2667 2655 return sdev->lun == 2668 2656 ufshcd_upiu_wlun_to_scsi_wlun(UFS_UPIU_UFS_DEVICE_WLUN); 2657 + } 2658 + 2659 + /* 2660 + * Associate the UFS controller queue with the default and poll HCTX types. 2661 + * Initialize the mq_map[] arrays. 2662 + */ 2663 + static int ufshcd_map_queues(struct Scsi_Host *shost) 2664 + { 2665 + int i, ret; 2666 + 2667 + for (i = 0; i < shost->nr_maps; i++) { 2668 + struct blk_mq_queue_map *map = &shost->tag_set.map[i]; 2669 + 2670 + switch (i) { 2671 + case HCTX_TYPE_DEFAULT: 2672 + case HCTX_TYPE_POLL: 2673 + map->nr_queues = 1; 2674 + break; 2675 + case HCTX_TYPE_READ: 2676 + map->nr_queues = 0; 2677 + break; 2678 + default: 2679 + WARN_ON_ONCE(true); 2680 + } 2681 + map->queue_offset = 0; 2682 + ret = blk_mq_map_queues(map); 2683 + WARN_ON_ONCE(ret); 2684 + } 2685 + 2686 + return 0; 2669 2687 } 2670 2688 2671 2689 static void ufshcd_init_lrb(struct ufs_hba *hba, struct ufshcd_lrb *lrb, int i) ··· 2728 2696 struct ufshcd_lrb *lrbp; 2729 2697 int err = 0; 2730 2698 2731 - WARN_ONCE(tag < 0, "Invalid tag %d\n", tag); 2699 + WARN_ONCE(tag < 0 || tag >= hba->nutrs, "Invalid tag %d\n", tag); 2732 2700 2733 - if (!down_read_trylock(&hba->clk_scaling_lock)) 2734 - return SCSI_MLQUEUE_HOST_BUSY; 2701 + /* 2702 + * Allows the UFS error handler to wait for prior ufshcd_queuecommand() 2703 + * calls. 2704 + */ 2705 + rcu_read_lock(); 2735 2706 2736 2707 switch (hba->ufshcd_state) { 2737 2708 case UFSHCD_STATE_OPERATIONAL: ··· 2814 2779 } 2815 2780 2816 2781 ufshcd_send_command(hba, tag); 2782 + 2817 2783 out: 2818 - up_read(&hba->clk_scaling_lock); 2784 + rcu_read_unlock(); 2819 2785 2820 2786 if (ufs_trigger_eh()) { 2821 2787 unsigned long flags; ··· 2972 2936 static int ufshcd_exec_dev_cmd(struct ufs_hba *hba, 2973 2937 enum dev_cmd_type cmd_type, int timeout) 2974 2938 { 2975 - struct request_queue *q = hba->cmd_queue; 2976 2939 DECLARE_COMPLETION_ONSTACK(wait); 2977 - struct request *req; 2940 + const u32 tag = hba->reserved_slot; 2978 2941 struct ufshcd_lrb *lrbp; 2979 2942 int err; 2980 - int tag; 2943 + 2944 + /* Protects use of hba->reserved_slot. */ 2945 + lockdep_assert_held(&hba->dev_cmd.lock); 2981 2946 2982 2947 down_read(&hba->clk_scaling_lock); 2983 - 2984 - /* 2985 - * Get free slot, sleep if slots are unavailable. 2986 - * Even though we use wait_event() which sleeps indefinitely, 2987 - * the maximum wait time is bounded by SCSI request timeout. 2988 - */ 2989 - req = blk_mq_alloc_request(q, REQ_OP_DRV_OUT, 0); 2990 - if (IS_ERR(req)) { 2991 - err = PTR_ERR(req); 2992 - goto out_unlock; 2993 - } 2994 - tag = req->tag; 2995 - WARN_ONCE(tag < 0, "Invalid tag %d\n", tag); 2996 - /* Set the timeout such that the SCSI error handler is not activated. */ 2997 - req->timeout = msecs_to_jiffies(2 * timeout); 2998 - blk_mq_start_request(req); 2999 2948 3000 2949 lrbp = &hba->lrb[tag]; 3001 2950 WARN_ON(lrbp->cmd); ··· 2998 2977 (struct utp_upiu_req *)lrbp->ucd_rsp_ptr); 2999 2978 3000 2979 out: 3001 - blk_mq_free_request(req); 3002 - out_unlock: 3003 2980 up_read(&hba->clk_scaling_lock); 3004 2981 return err; 3005 2982 } ··· 4979 4960 */ 4980 4961 static int ufshcd_change_queue_depth(struct scsi_device *sdev, int depth) 4981 4962 { 4982 - struct ufs_hba *hba = shost_priv(sdev->host); 4983 - 4984 - if (depth > hba->nutrs) 4985 - depth = hba->nutrs; 4986 - return scsi_change_queue_depth(sdev, depth); 4963 + return scsi_change_queue_depth(sdev, min(depth, sdev->host->can_queue)); 4987 4964 } 4988 4965 4989 4966 static void ufshcd_hpb_destroy(struct ufs_hba *hba, struct scsi_device *sdev) ··· 5271 5256 return retval; 5272 5257 } 5273 5258 5259 + /* Release the resources allocated for processing a SCSI command. */ 5260 + static void ufshcd_release_scsi_cmd(struct ufs_hba *hba, 5261 + struct ufshcd_lrb *lrbp) 5262 + { 5263 + struct scsi_cmnd *cmd = lrbp->cmd; 5264 + 5265 + scsi_dma_unmap(cmd); 5266 + lrbp->cmd = NULL; /* Mark the command as completed. */ 5267 + ufshcd_release(hba); 5268 + ufshcd_clk_scaling_update_busy(hba); 5269 + } 5270 + 5274 5271 /** 5275 5272 * __ufshcd_transfer_req_compl - handle SCSI and query command completion 5276 5273 * @hba: per adapter instance ··· 5293 5266 { 5294 5267 struct ufshcd_lrb *lrbp; 5295 5268 struct scsi_cmnd *cmd; 5296 - int result; 5297 5269 int index; 5298 - bool update_scaling = false; 5299 5270 5300 5271 for_each_set_bit(index, &completed_reqs, hba->nutrs) { 5301 5272 lrbp = &hba->lrb[index]; ··· 5303 5278 if (unlikely(ufshcd_should_inform_monitor(hba, lrbp))) 5304 5279 ufshcd_update_monitor(hba, lrbp); 5305 5280 ufshcd_add_command_trace(hba, index, UFS_CMD_COMP); 5306 - result = ufshcd_transfer_rsp_status(hba, lrbp); 5307 - scsi_dma_unmap(cmd); 5308 - cmd->result = result; 5309 - /* Mark completed command as NULL in LRB */ 5310 - lrbp->cmd = NULL; 5281 + cmd->result = ufshcd_transfer_rsp_status(hba, lrbp); 5282 + ufshcd_release_scsi_cmd(hba, lrbp); 5311 5283 /* Do not touch lrbp after scsi done */ 5312 5284 scsi_done(cmd); 5313 - ufshcd_release(hba); 5314 - update_scaling = true; 5315 5285 } else if (lrbp->command_type == UTP_CMD_TYPE_DEV_MANAGE || 5316 5286 lrbp->command_type == UTP_CMD_TYPE_UFS_STORAGE) { 5317 5287 if (hba->dev_cmd.complete) { 5318 5288 ufshcd_add_command_trace(hba, index, 5319 5289 UFS_DEV_COMP); 5320 5290 complete(hba->dev_cmd.complete); 5321 - update_scaling = true; 5291 + ufshcd_clk_scaling_update_busy(hba); 5322 5292 } 5323 5293 } 5324 - if (update_scaling) 5325 - ufshcd_clk_scaling_update_busy(hba); 5326 5294 } 5295 + } 5296 + 5297 + /* 5298 + * Returns > 0 if one or more commands have been completed or 0 if no 5299 + * requests have been completed. 5300 + */ 5301 + static int ufshcd_poll(struct Scsi_Host *shost, unsigned int queue_num) 5302 + { 5303 + struct ufs_hba *hba = shost_priv(shost); 5304 + unsigned long completed_reqs, flags; 5305 + u32 tr_doorbell; 5306 + 5307 + spin_lock_irqsave(&hba->outstanding_lock, flags); 5308 + tr_doorbell = ufshcd_readl(hba, REG_UTP_TRANSFER_REQ_DOOR_BELL); 5309 + completed_reqs = ~tr_doorbell & hba->outstanding_reqs; 5310 + WARN_ONCE(completed_reqs & ~hba->outstanding_reqs, 5311 + "completed: %#lx; outstanding: %#lx\n", completed_reqs, 5312 + hba->outstanding_reqs); 5313 + hba->outstanding_reqs &= ~completed_reqs; 5314 + spin_unlock_irqrestore(&hba->outstanding_lock, flags); 5315 + 5316 + if (completed_reqs) 5317 + __ufshcd_transfer_req_compl(hba, completed_reqs); 5318 + 5319 + return completed_reqs; 5327 5320 } 5328 5321 5329 5322 /** ··· 5354 5311 */ 5355 5312 static irqreturn_t ufshcd_transfer_req_compl(struct ufs_hba *hba) 5356 5313 { 5357 - unsigned long completed_reqs, flags; 5358 - u32 tr_doorbell; 5359 - 5360 5314 /* Resetting interrupt aggregation counters first and reading the 5361 5315 * DOOR_BELL afterward allows us to handle all the completed requests. 5362 5316 * In order to prevent other interrupts starvation the DB is read once ··· 5368 5328 if (ufs_fail_completion()) 5369 5329 return IRQ_HANDLED; 5370 5330 5371 - spin_lock_irqsave(&hba->outstanding_lock, flags); 5372 - tr_doorbell = ufshcd_readl(hba, REG_UTP_TRANSFER_REQ_DOOR_BELL); 5373 - completed_reqs = ~tr_doorbell & hba->outstanding_reqs; 5374 - WARN_ONCE(completed_reqs & ~hba->outstanding_reqs, 5375 - "completed: %#lx; outstanding: %#lx\n", completed_reqs, 5376 - hba->outstanding_reqs); 5377 - hba->outstanding_reqs &= ~completed_reqs; 5378 - spin_unlock_irqrestore(&hba->outstanding_lock, flags); 5331 + /* 5332 + * Ignore the ufshcd_poll() return value and return IRQ_HANDLED since we 5333 + * do not want polling to trigger spurious interrupt complaints. 5334 + */ 5335 + ufshcd_poll(hba->host, 0); 5379 5336 5380 - if (completed_reqs) { 5381 - __ufshcd_transfer_req_compl(hba, completed_reqs); 5382 - return IRQ_HANDLED; 5383 - } else { 5384 - return IRQ_NONE; 5385 - } 5337 + return IRQ_HANDLED; 5386 5338 } 5387 5339 5388 5340 int __ufshcd_write_ee_control(struct ufs_hba *hba, u32 ee_ctrl_mask) ··· 6018 5986 } 6019 5987 ufshcd_scsi_block_requests(hba); 6020 5988 /* Drain ufshcd_queuecommand() */ 6021 - down_write(&hba->clk_scaling_lock); 6022 - up_write(&hba->clk_scaling_lock); 5989 + synchronize_rcu(); 6023 5990 cancel_work_sync(&hba->eeh_work); 6024 5991 } 6025 5992 ··· 6625 6594 spin_lock_irqsave(host->host_lock, flags); 6626 6595 6627 6596 task_tag = req->tag; 6597 + WARN_ONCE(task_tag < 0 || task_tag >= hba->nutmrs, "Invalid tag %d\n", 6598 + task_tag); 6628 6599 hba->tmf_rqs[req->tag] = req; 6629 6600 treq->upiu_req.req_header.dword_0 |= cpu_to_be32(task_tag); 6630 6601 ··· 6744 6711 enum dev_cmd_type cmd_type, 6745 6712 enum query_opcode desc_op) 6746 6713 { 6747 - struct request_queue *q = hba->cmd_queue; 6748 6714 DECLARE_COMPLETION_ONSTACK(wait); 6749 - struct request *req; 6715 + const u32 tag = hba->reserved_slot; 6750 6716 struct ufshcd_lrb *lrbp; 6751 6717 int err = 0; 6752 - int tag; 6753 6718 u8 upiu_flags; 6754 6719 6720 + /* Protects use of hba->reserved_slot. */ 6721 + lockdep_assert_held(&hba->dev_cmd.lock); 6722 + 6755 6723 down_read(&hba->clk_scaling_lock); 6756 - 6757 - req = blk_mq_alloc_request(q, REQ_OP_DRV_OUT, 0); 6758 - if (IS_ERR(req)) { 6759 - err = PTR_ERR(req); 6760 - goto out_unlock; 6761 - } 6762 - tag = req->tag; 6763 - WARN_ONCE(tag < 0, "Invalid tag %d\n", tag); 6764 - 6765 - if (unlikely(test_bit(tag, &hba->outstanding_reqs))) { 6766 - err = -EBUSY; 6767 - goto out; 6768 - } 6769 6724 6770 6725 lrbp = &hba->lrb[tag]; 6771 6726 WARN_ON(lrbp->cmd); ··· 6822 6801 ufshcd_add_query_upiu_trace(hba, err ? UFS_QUERY_ERR : UFS_QUERY_COMP, 6823 6802 (struct utp_upiu_req *)lrbp->ucd_rsp_ptr); 6824 6803 6825 - out: 6826 - blk_mq_free_request(req); 6827 - out_unlock: 6828 6804 up_read(&hba->clk_scaling_lock); 6829 6805 return err; 6830 6806 } ··· 7051 7033 struct ufshcd_lrb *lrbp = &hba->lrb[tag]; 7052 7034 unsigned long flags; 7053 7035 int err = FAILED; 7036 + bool outstanding; 7054 7037 u32 reg; 7055 7038 7056 7039 WARN_ONCE(tag < 0, "Invalid tag %d\n", tag); ··· 7129 7110 goto release; 7130 7111 } 7131 7112 7132 - lrbp->cmd = NULL; 7113 + /* 7114 + * Clear the corresponding bit from outstanding_reqs since the command 7115 + * has been aborted successfully. 7116 + */ 7117 + spin_lock_irqsave(&hba->outstanding_lock, flags); 7118 + outstanding = __test_and_clear_bit(tag, &hba->outstanding_reqs); 7119 + spin_unlock_irqrestore(&hba->outstanding_lock, flags); 7120 + 7121 + if (outstanding) 7122 + ufshcd_release_scsi_cmd(hba, lrbp); 7123 + 7133 7124 err = SUCCESS; 7134 7125 7135 7126 release: ··· 7441 7412 static int ufshcd_scsi_add_wlus(struct ufs_hba *hba) 7442 7413 { 7443 7414 int ret = 0; 7444 - struct scsi_device *sdev_boot; 7415 + struct scsi_device *sdev_boot, *sdev_rpmb; 7445 7416 7446 7417 hba->sdev_ufs_device = __scsi_add_device(hba->host, 0, 0, 7447 7418 ufshcd_upiu_wlun_to_scsi_wlun(UFS_UPIU_UFS_DEVICE_WLUN), NULL); ··· 7452 7423 } 7453 7424 scsi_device_put(hba->sdev_ufs_device); 7454 7425 7455 - hba->sdev_rpmb = __scsi_add_device(hba->host, 0, 0, 7426 + sdev_rpmb = __scsi_add_device(hba->host, 0, 0, 7456 7427 ufshcd_upiu_wlun_to_scsi_wlun(UFS_UPIU_RPMB_WLUN), NULL); 7457 - if (IS_ERR(hba->sdev_rpmb)) { 7458 - ret = PTR_ERR(hba->sdev_rpmb); 7428 + if (IS_ERR(sdev_rpmb)) { 7429 + ret = PTR_ERR(sdev_rpmb); 7459 7430 goto remove_sdev_ufs_device; 7460 7431 } 7461 - ufshcd_blk_pm_runtime_init(hba->sdev_rpmb); 7462 - scsi_device_put(hba->sdev_rpmb); 7432 + ufshcd_blk_pm_runtime_init(sdev_rpmb); 7433 + scsi_device_put(sdev_rpmb); 7463 7434 7464 7435 sdev_boot = __scsi_add_device(hba->host, 0, 0, 7465 7436 ufshcd_upiu_wlun_to_scsi_wlun(UFS_UPIU_BOOT_WLUN), NULL); ··· 8185 8156 .module = THIS_MODULE, 8186 8157 .name = UFSHCD, 8187 8158 .proc_name = UFSHCD, 8159 + .map_queues = ufshcd_map_queues, 8188 8160 .queuecommand = ufshcd_queuecommand, 8161 + .mq_poll = ufshcd_poll, 8189 8162 .slave_alloc = ufshcd_slave_alloc, 8190 8163 .slave_configure = ufshcd_slave_configure, 8191 8164 .slave_destroy = ufshcd_slave_destroy, ··· 9415 9384 ufs_sysfs_remove_nodes(hba->dev); 9416 9385 blk_cleanup_queue(hba->tmf_queue); 9417 9386 blk_mq_free_tag_set(&hba->tmf_tag_set); 9418 - blk_cleanup_queue(hba->cmd_queue); 9419 9387 scsi_remove_host(hba->host); 9420 9388 /* disable interrupts */ 9421 9389 ufshcd_disable_intr(hba, hba->intr_mask); ··· 9475 9445 err = -ENOMEM; 9476 9446 goto out_error; 9477 9447 } 9448 + host->nr_maps = HCTX_TYPE_POLL + 1; 9478 9449 hba = shost_priv(host); 9479 9450 hba->host = host; 9480 9451 hba->dev = dev; ··· 9516 9485 struct Scsi_Host *host = hba->host; 9517 9486 struct device *dev = hba->dev; 9518 9487 char eh_wq_name[sizeof("ufs_eh_wq_00")]; 9488 + 9489 + /* 9490 + * dev_set_drvdata() must be called before any callbacks are registered 9491 + * that use dev_get_drvdata() (frequency scaling, clock scaling, hwmon, 9492 + * sysfs). 9493 + */ 9494 + dev_set_drvdata(dev, hba); 9519 9495 9520 9496 if (!mmio_base) { 9521 9497 dev_err(hba->dev, ··· 9566 9528 /* Configure LRB */ 9567 9529 ufshcd_host_memory_configure(hba); 9568 9530 9569 - host->can_queue = hba->nutrs; 9570 - host->cmd_per_lun = hba->nutrs; 9531 + host->can_queue = hba->nutrs - UFSHCD_NUM_RESERVED; 9532 + host->cmd_per_lun = hba->nutrs - UFSHCD_NUM_RESERVED; 9571 9533 host->max_id = UFSHCD_MAX_ID; 9572 9534 host->max_lun = UFS_MAX_LUNS; 9573 9535 host->max_channel = UFSHCD_MAX_CHANNEL; ··· 9635 9597 goto out_disable; 9636 9598 } 9637 9599 9638 - hba->cmd_queue = blk_mq_init_queue(&hba->host->tag_set); 9639 - if (IS_ERR(hba->cmd_queue)) { 9640 - err = PTR_ERR(hba->cmd_queue); 9641 - goto out_remove_scsi_host; 9642 - } 9643 - 9644 9600 hba->tmf_tag_set = (struct blk_mq_tag_set) { 9645 9601 .nr_hw_queues = 1, 9646 9602 .queue_depth = hba->nutmrs, ··· 9643 9611 }; 9644 9612 err = blk_mq_alloc_tag_set(&hba->tmf_tag_set); 9645 9613 if (err < 0) 9646 - goto free_cmd_queue; 9614 + goto out_remove_scsi_host; 9647 9615 hba->tmf_queue = blk_mq_init_queue(&hba->tmf_tag_set); 9648 9616 if (IS_ERR(hba->tmf_queue)) { 9649 9617 err = PTR_ERR(hba->tmf_queue); ··· 9712 9680 blk_cleanup_queue(hba->tmf_queue); 9713 9681 free_tmf_tag_set: 9714 9682 blk_mq_free_tag_set(&hba->tmf_tag_set); 9715 - free_cmd_queue: 9716 - blk_cleanup_queue(hba->cmd_queue); 9717 9683 out_remove_scsi_host: 9718 9684 scsi_remove_host(hba->host); 9719 9685 out_disable: ··· 9733 9703 } 9734 9704 EXPORT_SYMBOL_GPL(ufshcd_resume_complete); 9735 9705 9736 - int ufshcd_suspend_prepare(struct device *dev) 9706 + static bool ufshcd_rpm_ok_for_spm(struct ufs_hba *hba) 9707 + { 9708 + struct device *dev = &hba->sdev_ufs_device->sdev_gendev; 9709 + enum ufs_dev_pwr_mode dev_pwr_mode; 9710 + enum uic_link_state link_state; 9711 + unsigned long flags; 9712 + bool res; 9713 + 9714 + spin_lock_irqsave(&dev->power.lock, flags); 9715 + dev_pwr_mode = ufs_get_pm_lvl_to_dev_pwr_mode(hba->spm_lvl); 9716 + link_state = ufs_get_pm_lvl_to_link_pwr_state(hba->spm_lvl); 9717 + res = pm_runtime_suspended(dev) && 9718 + hba->curr_dev_pwr_mode == dev_pwr_mode && 9719 + hba->uic_link_state == link_state && 9720 + !hba->dev_info.b_rpm_dev_flush_capable; 9721 + spin_unlock_irqrestore(&dev->power.lock, flags); 9722 + 9723 + return res; 9724 + } 9725 + 9726 + int __ufshcd_suspend_prepare(struct device *dev, bool rpm_ok_for_spm) 9737 9727 { 9738 9728 struct ufs_hba *hba = dev_get_drvdata(dev); 9739 9729 int ret; ··· 9765 9715 * Refer ufshcd_resume_complete() 9766 9716 */ 9767 9717 if (hba->sdev_ufs_device) { 9768 - ret = ufshcd_rpm_get_sync(hba); 9769 - if (ret < 0 && ret != -EACCES) { 9770 - ufshcd_rpm_put(hba); 9771 - return ret; 9718 + /* Prevent runtime suspend */ 9719 + ufshcd_rpm_get_noresume(hba); 9720 + /* 9721 + * Check if already runtime suspended in same state as system 9722 + * suspend would be. 9723 + */ 9724 + if (!rpm_ok_for_spm || !ufshcd_rpm_ok_for_spm(hba)) { 9725 + /* RPM state is not ok for SPM, so runtime resume */ 9726 + ret = ufshcd_rpm_resume(hba); 9727 + if (ret < 0 && ret != -EACCES) { 9728 + ufshcd_rpm_put(hba); 9729 + return ret; 9730 + } 9772 9731 } 9773 9732 hba->complete_put = true; 9774 9733 } 9775 9734 return 0; 9735 + } 9736 + EXPORT_SYMBOL_GPL(__ufshcd_suspend_prepare); 9737 + 9738 + int ufshcd_suspend_prepare(struct device *dev) 9739 + { 9740 + return __ufshcd_suspend_prepare(dev, true); 9776 9741 } 9777 9742 EXPORT_SYMBOL_GPL(ufshcd_suspend_prepare); 9778 9743
+16 -4
drivers/scsi/ufs/ufshcd.h
··· 338 338 enum ufs_notify_change_status status, 339 339 struct ufs_pa_layer_attr *, 340 340 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); 342 343 void (*setup_task_mgmt)(struct ufs_hba *, int, u8); 343 344 void (*hibern8_notify)(struct ufs_hba *, enum uic_cmd_dme, 344 345 enum ufs_notify_change_status); ··· 738 737 * @host: Scsi_Host instance of the driver 739 738 * @dev: device handle 740 739 * @lrb: local reference block 741 - * @cmd_queue: Used to allocate command tags from hba->host->tag_set. 742 740 * @outstanding_tasks: Bits representing outstanding task requests 743 741 * @outstanding_lock: Protects @outstanding_reqs. 744 742 * @outstanding_reqs: Bits representing outstanding transfer requests 745 743 * @capabilities: UFS Controller Capabilities 746 744 * @nutrs: Transfer Request Queue depth supported by controller 747 745 * @nutmrs: Task Management Queue depth supported by controller 746 + * @reserved_slot: Used to submit device commands. Protected by @dev_cmd.lock. 748 747 * @ufs_version: UFS Version to which controller complies 749 748 * @vops: pointer to variant specific operations 750 749 * @priv: pointer to variant specific private data ··· 778 777 * @clk_list_head: UFS host controller clocks list node head 779 778 * @pwr_info: holds current power mode 780 779 * @max_pwr_info: keeps the device max valid pwm 780 + * @clk_scaling_lock: used to serialize device commands and clock scaling 781 781 * @desc_size: descriptor sizes reported by device 782 782 * @urgent_bkops_lvl: keeps track of urgent bkops level for device 783 783 * @is_urgent_bkops_lvl_checked: keeps track if the urgent bkops level for ··· 804 802 805 803 struct Scsi_Host *host; 806 804 struct device *dev; 807 - struct request_queue *cmd_queue; 808 805 /* 809 806 * This field is to keep a reference to "scsi_device" corresponding to 810 807 * "UFS device" W-LU. 811 808 */ 812 809 struct scsi_device *sdev_ufs_device; 813 - struct scsi_device *sdev_rpmb; 814 810 815 811 #ifdef CONFIG_SCSI_UFS_HWMON 816 812 struct device *hwmon_device; ··· 836 836 u32 capabilities; 837 837 int nutrs; 838 838 int nutmrs; 839 + u32 reserved_slot; 839 840 u32 ufs_version; 840 841 const struct ufs_hba_variant_ops *vops; 841 842 struct ufs_hba_variant_params *vps; ··· 1212 1211 1213 1212 int ufshcd_wb_toggle(struct ufs_hba *hba, bool enable); 1214 1213 int ufshcd_suspend_prepare(struct device *dev); 1214 + int __ufshcd_suspend_prepare(struct device *dev, bool rpm_ok_for_spm); 1215 1215 void ufshcd_resume_complete(struct device *dev); 1216 1216 1217 1217 /* Wrapper functions for safely calling variant operations */ ··· 1420 1418 static inline int ufshcd_rpm_put_sync(struct ufs_hba *hba) 1421 1419 { 1422 1420 return pm_runtime_put_sync(&hba->sdev_ufs_device->sdev_gendev); 1421 + } 1422 + 1423 + static inline void ufshcd_rpm_get_noresume(struct ufs_hba *hba) 1424 + { 1425 + pm_runtime_get_noresume(&hba->sdev_ufs_device->sdev_gendev); 1426 + } 1427 + 1428 + static inline int ufshcd_rpm_resume(struct ufs_hba *hba) 1429 + { 1430 + return pm_runtime_resume(&hba->sdev_ufs_device->sdev_gendev); 1423 1431 } 1424 1432 1425 1433 static inline int ufshcd_rpm_put(struct ufs_hba *hba)
-1
drivers/scsi/ufs/ufshpb.c
··· 10 10 */ 11 11 12 12 #include <asm/unaligned.h> 13 - #include <linux/async.h> 14 13 15 14 #include "ufshcd.h" 16 15 #include "ufshpb.h"
+1 -1
include/linux/blk-pm.h
··· 14 14 extern int blk_pre_runtime_suspend(struct request_queue *q); 15 15 extern void blk_post_runtime_suspend(struct request_queue *q, int err); 16 16 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); 18 18 extern void blk_set_runtime_active(struct request_queue *q); 19 19 #else 20 20 static inline void blk_pm_runtime_init(struct request_queue *q,
+2
include/scsi/libsas.h
··· 356 356 SAS_HA_DRAINING, 357 357 SAS_HA_ATA_EH_ACTIVE, 358 358 SAS_HA_FROZEN, 359 + SAS_HA_RESUMING, 359 360 }; 360 361 361 362 struct sas_ha_struct { ··· 661 660 extern int sas_unregister_ha(struct sas_ha_struct *); 662 661 extern void sas_prep_resume_ha(struct sas_ha_struct *sas_ha); 663 662 extern void sas_resume_ha(struct sas_ha_struct *sas_ha); 663 + extern void sas_resume_ha_no_sync(struct sas_ha_struct *sas_ha); 664 664 extern void sas_suspend_ha(struct sas_ha_struct *sas_ha); 665 665 666 666 int sas_set_phy_speed(struct sas_phy *phy, struct sas_phy_linkrates *rates);
-6
include/scsi/scsi_host.h
··· 691 691 692 692 /* ldm bits */ 693 693 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]; 700 694 701 695 /* 702 696 * Points to the transport data (if any) which is allocated