| .. | .. |
|---|
| 180 | 180 | case MPI2_FUNCTION_SMP_PASSTHROUGH: |
|---|
| 181 | 181 | desc = "smp_passthrough"; |
|---|
| 182 | 182 | break; |
|---|
| 183 | + case MPI2_FUNCTION_TOOLBOX: |
|---|
| 184 | + desc = "toolbox"; |
|---|
| 185 | + break; |
|---|
| 186 | + case MPI2_FUNCTION_NVME_ENCAPSULATED: |
|---|
| 187 | + desc = "nvme_encapsulated"; |
|---|
| 188 | + break; |
|---|
| 183 | 189 | } |
|---|
| 184 | 190 | |
|---|
| 185 | 191 | if (!desc) |
|---|
| 186 | 192 | return; |
|---|
| 187 | 193 | |
|---|
| 188 | | - pr_info(MPT3SAS_FMT "%s: %s, smid(%d)\n", |
|---|
| 189 | | - ioc->name, calling_function_name, desc, smid); |
|---|
| 194 | + ioc_info(ioc, "%s: %s, smid(%d)\n", calling_function_name, desc, smid); |
|---|
| 190 | 195 | |
|---|
| 191 | 196 | if (!mpi_reply) |
|---|
| 192 | 197 | return; |
|---|
| 193 | 198 | |
|---|
| 194 | 199 | if (mpi_reply->IOCStatus || mpi_reply->IOCLogInfo) |
|---|
| 195 | | - pr_info(MPT3SAS_FMT |
|---|
| 196 | | - "\tiocstatus(0x%04x), loginfo(0x%08x)\n", |
|---|
| 197 | | - ioc->name, le16_to_cpu(mpi_reply->IOCStatus), |
|---|
| 198 | | - le32_to_cpu(mpi_reply->IOCLogInfo)); |
|---|
| 200 | + ioc_info(ioc, "\tiocstatus(0x%04x), loginfo(0x%08x)\n", |
|---|
| 201 | + le16_to_cpu(mpi_reply->IOCStatus), |
|---|
| 202 | + le32_to_cpu(mpi_reply->IOCLogInfo)); |
|---|
| 199 | 203 | |
|---|
| 200 | 204 | if (mpi_request->Function == MPI2_FUNCTION_SCSI_IO_REQUEST || |
|---|
| 201 | 205 | mpi_request->Function == |
|---|
| .. | .. |
|---|
| 208 | 212 | sas_device = mpt3sas_get_sdev_by_handle(ioc, |
|---|
| 209 | 213 | le16_to_cpu(scsi_reply->DevHandle)); |
|---|
| 210 | 214 | if (sas_device) { |
|---|
| 211 | | - pr_warn(MPT3SAS_FMT "\tsas_address(0x%016llx), phy(%d)\n", |
|---|
| 212 | | - ioc->name, (unsigned long long) |
|---|
| 213 | | - sas_device->sas_address, sas_device->phy); |
|---|
| 214 | | - pr_warn(MPT3SAS_FMT |
|---|
| 215 | | - "\tenclosure_logical_id(0x%016llx), slot(%d)\n", |
|---|
| 216 | | - ioc->name, (unsigned long long) |
|---|
| 217 | | - sas_device->enclosure_logical_id, sas_device->slot); |
|---|
| 215 | + ioc_warn(ioc, "\tsas_address(0x%016llx), phy(%d)\n", |
|---|
| 216 | + (u64)sas_device->sas_address, |
|---|
| 217 | + sas_device->phy); |
|---|
| 218 | + ioc_warn(ioc, "\tenclosure_logical_id(0x%016llx), slot(%d)\n", |
|---|
| 219 | + (u64)sas_device->enclosure_logical_id, |
|---|
| 220 | + sas_device->slot); |
|---|
| 218 | 221 | sas_device_put(sas_device); |
|---|
| 219 | 222 | } |
|---|
| 220 | 223 | if (!sas_device) { |
|---|
| 221 | 224 | pcie_device = mpt3sas_get_pdev_by_handle(ioc, |
|---|
| 222 | 225 | le16_to_cpu(scsi_reply->DevHandle)); |
|---|
| 223 | 226 | if (pcie_device) { |
|---|
| 224 | | - pr_warn(MPT3SAS_FMT |
|---|
| 225 | | - "\tWWID(0x%016llx), port(%d)\n", ioc->name, |
|---|
| 226 | | - (unsigned long long)pcie_device->wwid, |
|---|
| 227 | | - pcie_device->port_num); |
|---|
| 227 | + ioc_warn(ioc, "\tWWID(0x%016llx), port(%d)\n", |
|---|
| 228 | + (unsigned long long)pcie_device->wwid, |
|---|
| 229 | + pcie_device->port_num); |
|---|
| 228 | 230 | if (pcie_device->enclosure_handle != 0) |
|---|
| 229 | | - pr_warn(MPT3SAS_FMT |
|---|
| 230 | | - "\tenclosure_logical_id(0x%016llx), slot(%d)\n", |
|---|
| 231 | | - ioc->name, (unsigned long long) |
|---|
| 232 | | - pcie_device->enclosure_logical_id, |
|---|
| 233 | | - pcie_device->slot); |
|---|
| 231 | + ioc_warn(ioc, "\tenclosure_logical_id(0x%016llx), slot(%d)\n", |
|---|
| 232 | + (u64)pcie_device->enclosure_logical_id, |
|---|
| 233 | + pcie_device->slot); |
|---|
| 234 | 234 | pcie_device_put(pcie_device); |
|---|
| 235 | 235 | } |
|---|
| 236 | 236 | } |
|---|
| 237 | 237 | if (scsi_reply->SCSIState || scsi_reply->SCSIStatus) |
|---|
| 238 | | - pr_info(MPT3SAS_FMT |
|---|
| 239 | | - "\tscsi_state(0x%02x), scsi_status" |
|---|
| 240 | | - "(0x%02x)\n", ioc->name, |
|---|
| 241 | | - scsi_reply->SCSIState, |
|---|
| 242 | | - scsi_reply->SCSIStatus); |
|---|
| 238 | + ioc_info(ioc, "\tscsi_state(0x%02x), scsi_status(0x%02x)\n", |
|---|
| 239 | + scsi_reply->SCSIState, |
|---|
| 240 | + scsi_reply->SCSIStatus); |
|---|
| 243 | 241 | } |
|---|
| 244 | 242 | } |
|---|
| 245 | 243 | |
|---|
| .. | .. |
|---|
| 466 | 464 | int i; |
|---|
| 467 | 465 | u8 issue_reset; |
|---|
| 468 | 466 | |
|---|
| 469 | | - dtmprintk(ioc, pr_info(MPT3SAS_FMT |
|---|
| 470 | | - "%s: MPT3_IOC_PRE_RESET\n", ioc->name, __func__)); |
|---|
| 467 | + dtmprintk(ioc, ioc_info(ioc, "%s: MPT3_IOC_PRE_RESET\n", __func__)); |
|---|
| 471 | 468 | for (i = 0; i < MPI2_DIAG_BUF_TYPE_COUNT; i++) { |
|---|
| 472 | 469 | if (!(ioc->diag_buffer_status[i] & |
|---|
| 473 | 470 | MPT3_DIAG_BUFFER_IS_REGISTERED)) |
|---|
| .. | .. |
|---|
| 475 | 472 | if ((ioc->diag_buffer_status[i] & |
|---|
| 476 | 473 | MPT3_DIAG_BUFFER_IS_RELEASED)) |
|---|
| 477 | 474 | continue; |
|---|
| 475 | + |
|---|
| 476 | + /* |
|---|
| 477 | + * add a log message to indicate the release |
|---|
| 478 | + */ |
|---|
| 479 | + ioc_info(ioc, |
|---|
| 480 | + "%s: Releasing the trace buffer due to adapter reset.", |
|---|
| 481 | + __func__); |
|---|
| 478 | 482 | mpt3sas_send_diag_release(ioc, i, &issue_reset); |
|---|
| 479 | 483 | } |
|---|
| 480 | 484 | } |
|---|
| 481 | 485 | |
|---|
| 482 | 486 | /** |
|---|
| 483 | | - * mpt3sas_ctl_reset_handler - reset callback handler (for ctl) |
|---|
| 487 | + * mpt3sas_ctl_reset_handler - clears outstanding ioctl cmd. |
|---|
| 484 | 488 | * @ioc: per adapter object |
|---|
| 485 | 489 | * |
|---|
| 486 | 490 | * The handler for doing any required cleanup or initialization. |
|---|
| 487 | 491 | */ |
|---|
| 488 | | -void mpt3sas_ctl_after_reset_handler(struct MPT3SAS_ADAPTER *ioc) |
|---|
| 492 | +void mpt3sas_ctl_clear_outstanding_ioctls(struct MPT3SAS_ADAPTER *ioc) |
|---|
| 489 | 493 | { |
|---|
| 490 | | - dtmprintk(ioc, pr_info(MPT3SAS_FMT |
|---|
| 491 | | - "%s: MPT3_IOC_AFTER_RESET\n", ioc->name, __func__)); |
|---|
| 494 | + dtmprintk(ioc, |
|---|
| 495 | + ioc_info(ioc, "%s: clear outstanding ioctl cmd\n", __func__)); |
|---|
| 492 | 496 | if (ioc->ctl_cmds.status & MPT3_CMD_PENDING) { |
|---|
| 493 | 497 | ioc->ctl_cmds.status |= MPT3_CMD_RESET; |
|---|
| 494 | 498 | mpt3sas_base_free_smid(ioc, ioc->ctl_cmds.smid); |
|---|
| .. | .. |
|---|
| 506 | 510 | { |
|---|
| 507 | 511 | int i; |
|---|
| 508 | 512 | |
|---|
| 509 | | - dtmprintk(ioc, pr_info(MPT3SAS_FMT |
|---|
| 510 | | - "%s: MPT3_IOC_DONE_RESET\n", ioc->name, __func__)); |
|---|
| 513 | + dtmprintk(ioc, ioc_info(ioc, "%s: MPT3_IOC_DONE_RESET\n", __func__)); |
|---|
| 511 | 514 | |
|---|
| 512 | 515 | for (i = 0; i < MPI2_DIAG_BUF_TYPE_COUNT; i++) { |
|---|
| 513 | 516 | if (!(ioc->diag_buffer_status[i] & |
|---|
| .. | .. |
|---|
| 607 | 610 | if (priv_data->sas_target->handle != handle) |
|---|
| 608 | 611 | continue; |
|---|
| 609 | 612 | st = scsi_cmd_priv(scmd); |
|---|
| 610 | | - tm_request->TaskMID = cpu_to_le16(st->smid); |
|---|
| 611 | | - found = 1; |
|---|
| 613 | + |
|---|
| 614 | + /* |
|---|
| 615 | + * If the given TaskMID from the user space is zero, then the |
|---|
| 616 | + * first outstanding smid will be picked up. Otherwise, |
|---|
| 617 | + * targeted smid will be the one. |
|---|
| 618 | + */ |
|---|
| 619 | + if (!tm_request->TaskMID || tm_request->TaskMID == st->smid) { |
|---|
| 620 | + tm_request->TaskMID = cpu_to_le16(st->smid); |
|---|
| 621 | + found = 1; |
|---|
| 622 | + } |
|---|
| 612 | 623 | } |
|---|
| 613 | 624 | |
|---|
| 614 | 625 | if (!found) { |
|---|
| 615 | | - dctlprintk(ioc, pr_info(MPT3SAS_FMT |
|---|
| 616 | | - "%s: handle(0x%04x), lun(%d), no active mid!!\n", |
|---|
| 617 | | - ioc->name, |
|---|
| 618 | | - desc, le16_to_cpu(tm_request->DevHandle), lun)); |
|---|
| 626 | + dctlprintk(ioc, |
|---|
| 627 | + ioc_info(ioc, "%s: handle(0x%04x), lun(%d), no active mid!!\n", |
|---|
| 628 | + desc, le16_to_cpu(tm_request->DevHandle), |
|---|
| 629 | + lun)); |
|---|
| 619 | 630 | tm_reply = ioc->ctl_cmds.reply; |
|---|
| 620 | 631 | tm_reply->DevHandle = tm_request->DevHandle; |
|---|
| 621 | 632 | tm_reply->Function = MPI2_FUNCTION_SCSI_TASK_MGMT; |
|---|
| .. | .. |
|---|
| 631 | 642 | return 1; |
|---|
| 632 | 643 | } |
|---|
| 633 | 644 | |
|---|
| 634 | | - dctlprintk(ioc, pr_info(MPT3SAS_FMT |
|---|
| 635 | | - "%s: handle(0x%04x), lun(%d), task_mid(%d)\n", ioc->name, |
|---|
| 636 | | - desc, le16_to_cpu(tm_request->DevHandle), lun, |
|---|
| 637 | | - le16_to_cpu(tm_request->TaskMID))); |
|---|
| 645 | + dctlprintk(ioc, |
|---|
| 646 | + ioc_info(ioc, "%s: handle(0x%04x), lun(%d), task_mid(%d)\n", |
|---|
| 647 | + desc, le16_to_cpu(tm_request->DevHandle), lun, |
|---|
| 648 | + le16_to_cpu(tm_request->TaskMID))); |
|---|
| 638 | 649 | return 0; |
|---|
| 639 | 650 | } |
|---|
| 640 | 651 | |
|---|
| .. | .. |
|---|
| 652 | 663 | MPI2DefaultReply_t *mpi_reply; |
|---|
| 653 | 664 | Mpi26NVMeEncapsulatedRequest_t *nvme_encap_request = NULL; |
|---|
| 654 | 665 | struct _pcie_device *pcie_device = NULL; |
|---|
| 655 | | - u32 ioc_state; |
|---|
| 656 | 666 | u16 smid; |
|---|
| 657 | 667 | unsigned long timeout; |
|---|
| 658 | 668 | u8 issue_reset; |
|---|
| .. | .. |
|---|
| 665 | 675 | dma_addr_t data_in_dma = 0; |
|---|
| 666 | 676 | size_t data_in_sz = 0; |
|---|
| 667 | 677 | long ret; |
|---|
| 668 | | - u16 wait_state_count; |
|---|
| 669 | 678 | u16 device_handle = MPT3SAS_INVALID_DEVICE_HANDLE; |
|---|
| 670 | | - u8 tr_method = MPI26_SCSITASKMGMT_MSGFLAGS_PROTOCOL_LVL_RST_PCIE; |
|---|
| 671 | 679 | |
|---|
| 672 | 680 | issue_reset = 0; |
|---|
| 673 | 681 | |
|---|
| 674 | 682 | if (ioc->ctl_cmds.status != MPT3_CMD_NOT_USED) { |
|---|
| 675 | | - pr_err(MPT3SAS_FMT "%s: ctl_cmd in use\n", |
|---|
| 676 | | - ioc->name, __func__); |
|---|
| 683 | + ioc_err(ioc, "%s: ctl_cmd in use\n", __func__); |
|---|
| 677 | 684 | ret = -EAGAIN; |
|---|
| 678 | 685 | goto out; |
|---|
| 679 | 686 | } |
|---|
| 680 | 687 | |
|---|
| 681 | | - wait_state_count = 0; |
|---|
| 682 | | - ioc_state = mpt3sas_base_get_iocstate(ioc, 1); |
|---|
| 683 | | - while (ioc_state != MPI2_IOC_STATE_OPERATIONAL) { |
|---|
| 684 | | - if (wait_state_count++ == 10) { |
|---|
| 685 | | - pr_err(MPT3SAS_FMT |
|---|
| 686 | | - "%s: failed due to ioc not operational\n", |
|---|
| 687 | | - ioc->name, __func__); |
|---|
| 688 | | - ret = -EFAULT; |
|---|
| 689 | | - goto out; |
|---|
| 690 | | - } |
|---|
| 691 | | - ssleep(1); |
|---|
| 692 | | - ioc_state = mpt3sas_base_get_iocstate(ioc, 1); |
|---|
| 693 | | - pr_info(MPT3SAS_FMT |
|---|
| 694 | | - "%s: waiting for operational state(count=%d)\n", |
|---|
| 695 | | - ioc->name, |
|---|
| 696 | | - __func__, wait_state_count); |
|---|
| 697 | | - } |
|---|
| 698 | | - if (wait_state_count) |
|---|
| 699 | | - pr_info(MPT3SAS_FMT "%s: ioc is operational\n", |
|---|
| 700 | | - ioc->name, __func__); |
|---|
| 688 | + ret = mpt3sas_wait_for_ioc(ioc, IOC_OPERATIONAL_WAIT_COUNT); |
|---|
| 689 | + if (ret) |
|---|
| 690 | + goto out; |
|---|
| 701 | 691 | |
|---|
| 702 | 692 | mpi_request = kzalloc(ioc->request_sz, GFP_KERNEL); |
|---|
| 703 | 693 | if (!mpi_request) { |
|---|
| 704 | | - pr_err(MPT3SAS_FMT |
|---|
| 705 | | - "%s: failed obtaining a memory for mpi_request\n", |
|---|
| 706 | | - ioc->name, __func__); |
|---|
| 694 | + ioc_err(ioc, "%s: failed obtaining a memory for mpi_request\n", |
|---|
| 695 | + __func__); |
|---|
| 707 | 696 | ret = -ENOMEM; |
|---|
| 708 | 697 | goto out; |
|---|
| 709 | 698 | } |
|---|
| .. | .. |
|---|
| 726 | 715 | if (mpi_request->Function == MPI2_FUNCTION_SCSI_TASK_MGMT) { |
|---|
| 727 | 716 | smid = mpt3sas_base_get_smid_hpr(ioc, ioc->ctl_cb_idx); |
|---|
| 728 | 717 | if (!smid) { |
|---|
| 729 | | - pr_err(MPT3SAS_FMT "%s: failed obtaining a smid\n", |
|---|
| 730 | | - ioc->name, __func__); |
|---|
| 718 | + ioc_err(ioc, "%s: failed obtaining a smid\n", __func__); |
|---|
| 731 | 719 | ret = -EAGAIN; |
|---|
| 732 | 720 | goto out; |
|---|
| 733 | 721 | } |
|---|
| .. | .. |
|---|
| 740 | 728 | ioc->ctl_cmds.status = MPT3_CMD_PENDING; |
|---|
| 741 | 729 | memset(ioc->ctl_cmds.reply, 0, ioc->reply_sz); |
|---|
| 742 | 730 | request = mpt3sas_base_get_msg_frame(ioc, smid); |
|---|
| 731 | + memset(request, 0, ioc->request_sz); |
|---|
| 743 | 732 | memcpy(request, mpi_request, karg.data_sge_offset*4); |
|---|
| 744 | 733 | ioc->ctl_cmds.smid = smid; |
|---|
| 745 | 734 | data_out_sz = karg.data_out_size; |
|---|
| .. | .. |
|---|
| 762 | 751 | |
|---|
| 763 | 752 | /* obtain dma-able memory for data transfer */ |
|---|
| 764 | 753 | if (data_out_sz) /* WRITE */ { |
|---|
| 765 | | - data_out = pci_alloc_consistent(ioc->pdev, data_out_sz, |
|---|
| 766 | | - &data_out_dma); |
|---|
| 754 | + data_out = dma_alloc_coherent(&ioc->pdev->dev, data_out_sz, |
|---|
| 755 | + &data_out_dma, GFP_KERNEL); |
|---|
| 767 | 756 | if (!data_out) { |
|---|
| 768 | 757 | pr_err("failure at %s:%d/%s()!\n", __FILE__, |
|---|
| 769 | 758 | __LINE__, __func__); |
|---|
| .. | .. |
|---|
| 782 | 771 | } |
|---|
| 783 | 772 | |
|---|
| 784 | 773 | if (data_in_sz) /* READ */ { |
|---|
| 785 | | - data_in = pci_alloc_consistent(ioc->pdev, data_in_sz, |
|---|
| 786 | | - &data_in_dma); |
|---|
| 774 | + data_in = dma_alloc_coherent(&ioc->pdev->dev, data_in_sz, |
|---|
| 775 | + &data_in_dma, GFP_KERNEL); |
|---|
| 787 | 776 | if (!data_in) { |
|---|
| 788 | 777 | pr_err("failure at %s:%d/%s()!\n", __FILE__, |
|---|
| 789 | 778 | __LINE__, __func__); |
|---|
| .. | .. |
|---|
| 803 | 792 | case MPI2_FUNCTION_NVME_ENCAPSULATED: |
|---|
| 804 | 793 | { |
|---|
| 805 | 794 | nvme_encap_request = (Mpi26NVMeEncapsulatedRequest_t *)request; |
|---|
| 795 | + if (!ioc->pcie_sg_lookup) { |
|---|
| 796 | + dtmprintk(ioc, ioc_info(ioc, |
|---|
| 797 | + "HBA doesn't support NVMe. Rejecting NVMe Encapsulated request.\n" |
|---|
| 798 | + )); |
|---|
| 799 | + |
|---|
| 800 | + if (ioc->logging_level & MPT_DEBUG_TM) |
|---|
| 801 | + _debug_dump_mf(nvme_encap_request, |
|---|
| 802 | + ioc->request_sz/4); |
|---|
| 803 | + mpt3sas_base_free_smid(ioc, smid); |
|---|
| 804 | + ret = -EINVAL; |
|---|
| 805 | + goto out; |
|---|
| 806 | + } |
|---|
| 806 | 807 | /* |
|---|
| 807 | 808 | * Get the Physical Address of the sense buffer. |
|---|
| 808 | 809 | * Use Error Response buffer address field to hold the sense |
|---|
| .. | .. |
|---|
| 823 | 824 | ioc->build_nvme_prp(ioc, smid, nvme_encap_request, |
|---|
| 824 | 825 | data_out_dma, data_out_sz, data_in_dma, data_in_sz); |
|---|
| 825 | 826 | if (test_bit(device_handle, ioc->device_remove_in_progress)) { |
|---|
| 826 | | - dtmprintk(ioc, pr_info(MPT3SAS_FMT "handle(0x%04x) :" |
|---|
| 827 | | - "ioctl failed due to device removal in progress\n", |
|---|
| 828 | | - ioc->name, device_handle)); |
|---|
| 827 | + dtmprintk(ioc, |
|---|
| 828 | + ioc_info(ioc, "handle(0x%04x): ioctl failed due to device removal in progress\n", |
|---|
| 829 | + device_handle)); |
|---|
| 829 | 830 | mpt3sas_base_free_smid(ioc, smid); |
|---|
| 830 | 831 | ret = -EINVAL; |
|---|
| 831 | 832 | goto out; |
|---|
| .. | .. |
|---|
| 843 | 844 | mpt3sas_base_get_sense_buffer_dma(ioc, smid); |
|---|
| 844 | 845 | memset(ioc->ctl_cmds.sense, 0, SCSI_SENSE_BUFFERSIZE); |
|---|
| 845 | 846 | if (test_bit(device_handle, ioc->device_remove_in_progress)) { |
|---|
| 846 | | - dtmprintk(ioc, pr_info(MPT3SAS_FMT |
|---|
| 847 | | - "handle(0x%04x) :ioctl failed due to device removal in progress\n", |
|---|
| 848 | | - ioc->name, device_handle)); |
|---|
| 847 | + dtmprintk(ioc, |
|---|
| 848 | + ioc_info(ioc, "handle(0x%04x) :ioctl failed due to device removal in progress\n", |
|---|
| 849 | + device_handle)); |
|---|
| 849 | 850 | mpt3sas_base_free_smid(ioc, smid); |
|---|
| 850 | 851 | ret = -EINVAL; |
|---|
| 851 | 852 | goto out; |
|---|
| .. | .. |
|---|
| 855 | 856 | if (mpi_request->Function == MPI2_FUNCTION_SCSI_IO_REQUEST) |
|---|
| 856 | 857 | ioc->put_smid_scsi_io(ioc, smid, device_handle); |
|---|
| 857 | 858 | else |
|---|
| 858 | | - mpt3sas_base_put_smid_default(ioc, smid); |
|---|
| 859 | + ioc->put_smid_default(ioc, smid); |
|---|
| 859 | 860 | break; |
|---|
| 860 | 861 | } |
|---|
| 861 | 862 | case MPI2_FUNCTION_SCSI_TASK_MGMT: |
|---|
| .. | .. |
|---|
| 863 | 864 | Mpi2SCSITaskManagementRequest_t *tm_request = |
|---|
| 864 | 865 | (Mpi2SCSITaskManagementRequest_t *)request; |
|---|
| 865 | 866 | |
|---|
| 866 | | - dtmprintk(ioc, pr_info(MPT3SAS_FMT |
|---|
| 867 | | - "TASK_MGMT: handle(0x%04x), task_type(0x%02x)\n", |
|---|
| 868 | | - ioc->name, |
|---|
| 869 | | - le16_to_cpu(tm_request->DevHandle), tm_request->TaskType)); |
|---|
| 867 | + dtmprintk(ioc, |
|---|
| 868 | + ioc_info(ioc, "TASK_MGMT: handle(0x%04x), task_type(0x%02x)\n", |
|---|
| 869 | + le16_to_cpu(tm_request->DevHandle), |
|---|
| 870 | + tm_request->TaskType)); |
|---|
| 870 | 871 | ioc->got_task_abort_from_ioctl = 1; |
|---|
| 871 | 872 | if (tm_request->TaskType == |
|---|
| 872 | 873 | MPI2_SCSITASKMGMT_TASKTYPE_ABORT_TASK || |
|---|
| .. | .. |
|---|
| 881 | 882 | ioc->got_task_abort_from_ioctl = 0; |
|---|
| 882 | 883 | |
|---|
| 883 | 884 | if (test_bit(device_handle, ioc->device_remove_in_progress)) { |
|---|
| 884 | | - dtmprintk(ioc, pr_info(MPT3SAS_FMT |
|---|
| 885 | | - "handle(0x%04x) :ioctl failed due to device removal in progress\n", |
|---|
| 886 | | - ioc->name, device_handle)); |
|---|
| 885 | + dtmprintk(ioc, |
|---|
| 886 | + ioc_info(ioc, "handle(0x%04x) :ioctl failed due to device removal in progress\n", |
|---|
| 887 | + device_handle)); |
|---|
| 887 | 888 | mpt3sas_base_free_smid(ioc, smid); |
|---|
| 888 | 889 | ret = -EINVAL; |
|---|
| 889 | 890 | goto out; |
|---|
| .. | .. |
|---|
| 892 | 893 | tm_request->DevHandle)); |
|---|
| 893 | 894 | ioc->build_sg_mpi(ioc, psge, data_out_dma, data_out_sz, |
|---|
| 894 | 895 | data_in_dma, data_in_sz); |
|---|
| 895 | | - mpt3sas_base_put_smid_hi_priority(ioc, smid, 0); |
|---|
| 896 | + ioc->put_smid_hi_priority(ioc, smid, 0); |
|---|
| 896 | 897 | break; |
|---|
| 897 | 898 | } |
|---|
| 898 | 899 | case MPI2_FUNCTION_SMP_PASSTHROUGH: |
|---|
| .. | .. |
|---|
| 923 | 924 | } |
|---|
| 924 | 925 | ioc->build_sg(ioc, psge, data_out_dma, data_out_sz, data_in_dma, |
|---|
| 925 | 926 | data_in_sz); |
|---|
| 926 | | - mpt3sas_base_put_smid_default(ioc, smid); |
|---|
| 927 | + ioc->put_smid_default(ioc, smid); |
|---|
| 927 | 928 | break; |
|---|
| 928 | 929 | } |
|---|
| 929 | 930 | case MPI2_FUNCTION_SATA_PASSTHROUGH: |
|---|
| 930 | 931 | { |
|---|
| 931 | 932 | if (test_bit(device_handle, ioc->device_remove_in_progress)) { |
|---|
| 932 | | - dtmprintk(ioc, pr_info(MPT3SAS_FMT |
|---|
| 933 | | - "handle(0x%04x) :ioctl failed due to device removal in progress\n", |
|---|
| 934 | | - ioc->name, device_handle)); |
|---|
| 933 | + dtmprintk(ioc, |
|---|
| 934 | + ioc_info(ioc, "handle(0x%04x) :ioctl failed due to device removal in progress\n", |
|---|
| 935 | + device_handle)); |
|---|
| 935 | 936 | mpt3sas_base_free_smid(ioc, smid); |
|---|
| 936 | 937 | ret = -EINVAL; |
|---|
| 937 | 938 | goto out; |
|---|
| 938 | 939 | } |
|---|
| 939 | 940 | ioc->build_sg(ioc, psge, data_out_dma, data_out_sz, data_in_dma, |
|---|
| 940 | 941 | data_in_sz); |
|---|
| 941 | | - mpt3sas_base_put_smid_default(ioc, smid); |
|---|
| 942 | + ioc->put_smid_default(ioc, smid); |
|---|
| 942 | 943 | break; |
|---|
| 943 | 944 | } |
|---|
| 944 | 945 | case MPI2_FUNCTION_FW_DOWNLOAD: |
|---|
| .. | .. |
|---|
| 946 | 947 | { |
|---|
| 947 | 948 | ioc->build_sg(ioc, psge, data_out_dma, data_out_sz, data_in_dma, |
|---|
| 948 | 949 | data_in_sz); |
|---|
| 949 | | - mpt3sas_base_put_smid_default(ioc, smid); |
|---|
| 950 | + ioc->put_smid_default(ioc, smid); |
|---|
| 950 | 951 | break; |
|---|
| 951 | 952 | } |
|---|
| 952 | 953 | case MPI2_FUNCTION_TOOLBOX: |
|---|
| .. | .. |
|---|
| 954 | 955 | Mpi2ToolboxCleanRequest_t *toolbox_request = |
|---|
| 955 | 956 | (Mpi2ToolboxCleanRequest_t *)mpi_request; |
|---|
| 956 | 957 | |
|---|
| 957 | | - if (toolbox_request->Tool == MPI2_TOOLBOX_DIAGNOSTIC_CLI_TOOL) { |
|---|
| 958 | + if ((toolbox_request->Tool == MPI2_TOOLBOX_DIAGNOSTIC_CLI_TOOL) |
|---|
| 959 | + || (toolbox_request->Tool == |
|---|
| 960 | + MPI26_TOOLBOX_BACKEND_PCIE_LANE_MARGIN)) |
|---|
| 958 | 961 | ioc->build_sg(ioc, psge, data_out_dma, data_out_sz, |
|---|
| 959 | 962 | data_in_dma, data_in_sz); |
|---|
| 960 | | - } else { |
|---|
| 963 | + else if (toolbox_request->Tool == |
|---|
| 964 | + MPI2_TOOLBOX_MEMORY_MOVE_TOOL) { |
|---|
| 965 | + Mpi2ToolboxMemMoveRequest_t *mem_move_request = |
|---|
| 966 | + (Mpi2ToolboxMemMoveRequest_t *)request; |
|---|
| 967 | + Mpi2SGESimple64_t tmp, *src = NULL, *dst = NULL; |
|---|
| 968 | + |
|---|
| 969 | + ioc->build_sg_mpi(ioc, psge, data_out_dma, |
|---|
| 970 | + data_out_sz, data_in_dma, data_in_sz); |
|---|
| 971 | + if (data_out_sz && !data_in_sz) { |
|---|
| 972 | + dst = |
|---|
| 973 | + (Mpi2SGESimple64_t *)&mem_move_request->SGL; |
|---|
| 974 | + src = (void *)dst + ioc->sge_size; |
|---|
| 975 | + |
|---|
| 976 | + memcpy(&tmp, src, ioc->sge_size); |
|---|
| 977 | + memcpy(src, dst, ioc->sge_size); |
|---|
| 978 | + memcpy(dst, &tmp, ioc->sge_size); |
|---|
| 979 | + } |
|---|
| 980 | + if (ioc->logging_level & MPT_DEBUG_TM) { |
|---|
| 981 | + ioc_info(ioc, |
|---|
| 982 | + "Mpi2ToolboxMemMoveRequest_t request msg\n"); |
|---|
| 983 | + _debug_dump_mf(mem_move_request, |
|---|
| 984 | + ioc->request_sz/4); |
|---|
| 985 | + } |
|---|
| 986 | + } else |
|---|
| 961 | 987 | ioc->build_sg_mpi(ioc, psge, data_out_dma, data_out_sz, |
|---|
| 962 | | - data_in_dma, data_in_sz); |
|---|
| 963 | | - } |
|---|
| 964 | | - mpt3sas_base_put_smid_default(ioc, smid); |
|---|
| 988 | + data_in_dma, data_in_sz); |
|---|
| 989 | + ioc->put_smid_default(ioc, smid); |
|---|
| 965 | 990 | break; |
|---|
| 966 | 991 | } |
|---|
| 967 | 992 | case MPI2_FUNCTION_SAS_IO_UNIT_CONTROL: |
|---|
| .. | .. |
|---|
| 977 | 1002 | } |
|---|
| 978 | 1003 | /* drop to default case for posting the request */ |
|---|
| 979 | 1004 | } |
|---|
| 980 | | - /* fall through */ |
|---|
| 1005 | + fallthrough; |
|---|
| 981 | 1006 | default: |
|---|
| 982 | 1007 | ioc->build_sg_mpi(ioc, psge, data_out_dma, data_out_sz, |
|---|
| 983 | 1008 | data_in_dma, data_in_sz); |
|---|
| 984 | | - mpt3sas_base_put_smid_default(ioc, smid); |
|---|
| 1009 | + ioc->put_smid_default(ioc, smid); |
|---|
| 985 | 1010 | break; |
|---|
| 986 | 1011 | } |
|---|
| 987 | 1012 | |
|---|
| .. | .. |
|---|
| 1003 | 1028 | ioc->ignore_loginfos = 0; |
|---|
| 1004 | 1029 | } |
|---|
| 1005 | 1030 | if (!(ioc->ctl_cmds.status & MPT3_CMD_COMPLETE)) { |
|---|
| 1006 | | - issue_reset = |
|---|
| 1007 | | - mpt3sas_base_check_cmd_timeout(ioc, |
|---|
| 1008 | | - ioc->ctl_cmds.status, mpi_request, |
|---|
| 1009 | | - karg.data_sge_offset); |
|---|
| 1031 | + mpt3sas_check_cmd_timeout(ioc, |
|---|
| 1032 | + ioc->ctl_cmds.status, mpi_request, |
|---|
| 1033 | + karg.data_sge_offset, issue_reset); |
|---|
| 1010 | 1034 | goto issue_host_reset; |
|---|
| 1011 | 1035 | } |
|---|
| 1012 | 1036 | |
|---|
| .. | .. |
|---|
| 1017 | 1041 | Mpi2SCSITaskManagementReply_t *tm_reply = |
|---|
| 1018 | 1042 | (Mpi2SCSITaskManagementReply_t *)mpi_reply; |
|---|
| 1019 | 1043 | |
|---|
| 1020 | | - pr_info(MPT3SAS_FMT "TASK_MGMT: " \ |
|---|
| 1021 | | - "IOCStatus(0x%04x), IOCLogInfo(0x%08x), " |
|---|
| 1022 | | - "TerminationCount(0x%08x)\n", ioc->name, |
|---|
| 1023 | | - le16_to_cpu(tm_reply->IOCStatus), |
|---|
| 1024 | | - le32_to_cpu(tm_reply->IOCLogInfo), |
|---|
| 1025 | | - le32_to_cpu(tm_reply->TerminationCount)); |
|---|
| 1044 | + ioc_info(ioc, "TASK_MGMT: IOCStatus(0x%04x), IOCLogInfo(0x%08x), TerminationCount(0x%08x)\n", |
|---|
| 1045 | + le16_to_cpu(tm_reply->IOCStatus), |
|---|
| 1046 | + le32_to_cpu(tm_reply->IOCLogInfo), |
|---|
| 1047 | + le32_to_cpu(tm_reply->TerminationCount)); |
|---|
| 1026 | 1048 | } |
|---|
| 1027 | 1049 | |
|---|
| 1028 | 1050 | /* copy out xdata to user */ |
|---|
| .. | .. |
|---|
| 1054 | 1076 | MPI2_FUNCTION_RAID_SCSI_IO_PASSTHROUGH || mpi_request->Function == |
|---|
| 1055 | 1077 | MPI2_FUNCTION_NVME_ENCAPSULATED)) { |
|---|
| 1056 | 1078 | if (karg.sense_data_ptr == NULL) { |
|---|
| 1057 | | - pr_info(MPT3SAS_FMT "Response buffer provided" |
|---|
| 1058 | | - " by application is NULL; Response data will" |
|---|
| 1059 | | - " not be returned.\n", ioc->name); |
|---|
| 1079 | + ioc_info(ioc, "Response buffer provided by application is NULL; Response data will not be returned\n"); |
|---|
| 1060 | 1080 | goto out; |
|---|
| 1061 | 1081 | } |
|---|
| 1062 | 1082 | sz_arg = (mpi_request->Function == |
|---|
| .. | .. |
|---|
| 1079 | 1099 | mpi_request->Function == |
|---|
| 1080 | 1100 | MPI2_FUNCTION_RAID_SCSI_IO_PASSTHROUGH || |
|---|
| 1081 | 1101 | mpi_request->Function == MPI2_FUNCTION_SATA_PASSTHROUGH)) { |
|---|
| 1082 | | - pr_info(MPT3SAS_FMT "issue target reset: handle = (0x%04x)\n", |
|---|
| 1083 | | - ioc->name, |
|---|
| 1084 | | - le16_to_cpu(mpi_request->FunctionDependent1)); |
|---|
| 1102 | + ioc_info(ioc, "issue target reset: handle = (0x%04x)\n", |
|---|
| 1103 | + le16_to_cpu(mpi_request->FunctionDependent1)); |
|---|
| 1085 | 1104 | mpt3sas_halt_firmware(ioc); |
|---|
| 1086 | 1105 | pcie_device = mpt3sas_get_pdev_by_handle(ioc, |
|---|
| 1087 | 1106 | le16_to_cpu(mpi_request->FunctionDependent1)); |
|---|
| 1088 | | - if (pcie_device && (!ioc->tm_custom_handling)) |
|---|
| 1107 | + if (pcie_device && (!ioc->tm_custom_handling) && |
|---|
| 1108 | + (!(mpt3sas_scsih_is_pcie_scsi_device( |
|---|
| 1109 | + pcie_device->device_info)))) |
|---|
| 1089 | 1110 | mpt3sas_scsih_issue_locked_tm(ioc, |
|---|
| 1090 | 1111 | le16_to_cpu(mpi_request->FunctionDependent1), |
|---|
| 1091 | | - 0, MPI2_SCSITASKMGMT_TASKTYPE_TARGET_RESET, 0, |
|---|
| 1112 | + 0, 0, 0, |
|---|
| 1113 | + MPI2_SCSITASKMGMT_TASKTYPE_TARGET_RESET, 0, |
|---|
| 1092 | 1114 | 0, pcie_device->reset_timeout, |
|---|
| 1093 | | - tr_method); |
|---|
| 1115 | + MPI26_SCSITASKMGMT_MSGFLAGS_PROTOCOL_LVL_RST_PCIE); |
|---|
| 1094 | 1116 | else |
|---|
| 1095 | 1117 | mpt3sas_scsih_issue_locked_tm(ioc, |
|---|
| 1096 | 1118 | le16_to_cpu(mpi_request->FunctionDependent1), |
|---|
| 1097 | | - 0, MPI2_SCSITASKMGMT_TASKTYPE_TARGET_RESET, 0, |
|---|
| 1119 | + 0, 0, 0, |
|---|
| 1120 | + MPI2_SCSITASKMGMT_TASKTYPE_TARGET_RESET, 0, |
|---|
| 1098 | 1121 | 0, 30, MPI2_SCSITASKMGMT_MSGFLAGS_LINK_RESET); |
|---|
| 1099 | 1122 | } else |
|---|
| 1100 | 1123 | mpt3sas_base_hard_reset_handler(ioc, FORCE_BIG_HAMMER); |
|---|
| .. | .. |
|---|
| 1106 | 1129 | |
|---|
| 1107 | 1130 | /* free memory associated with sg buffers */ |
|---|
| 1108 | 1131 | if (data_in) |
|---|
| 1109 | | - pci_free_consistent(ioc->pdev, data_in_sz, data_in, |
|---|
| 1132 | + dma_free_coherent(&ioc->pdev->dev, data_in_sz, data_in, |
|---|
| 1110 | 1133 | data_in_dma); |
|---|
| 1111 | 1134 | |
|---|
| 1112 | 1135 | if (data_out) |
|---|
| 1113 | | - pci_free_consistent(ioc->pdev, data_out_sz, data_out, |
|---|
| 1136 | + dma_free_coherent(&ioc->pdev->dev, data_out_sz, data_out, |
|---|
| 1114 | 1137 | data_out_dma); |
|---|
| 1115 | 1138 | |
|---|
| 1116 | 1139 | kfree(mpi_request); |
|---|
| .. | .. |
|---|
| 1128 | 1151 | { |
|---|
| 1129 | 1152 | struct mpt3_ioctl_iocinfo karg; |
|---|
| 1130 | 1153 | |
|---|
| 1131 | | - dctlprintk(ioc, pr_info(MPT3SAS_FMT "%s: enter\n", ioc->name, |
|---|
| 1132 | | - __func__)); |
|---|
| 1154 | + dctlprintk(ioc, ioc_info(ioc, "%s: enter\n", |
|---|
| 1155 | + __func__)); |
|---|
| 1133 | 1156 | |
|---|
| 1134 | 1157 | memset(&karg, 0 , sizeof(karg)); |
|---|
| 1135 | 1158 | if (ioc->pfacts) |
|---|
| .. | .. |
|---|
| 1188 | 1211 | return -EFAULT; |
|---|
| 1189 | 1212 | } |
|---|
| 1190 | 1213 | |
|---|
| 1191 | | - dctlprintk(ioc, pr_info(MPT3SAS_FMT "%s: enter\n", ioc->name, |
|---|
| 1192 | | - __func__)); |
|---|
| 1214 | + dctlprintk(ioc, ioc_info(ioc, "%s: enter\n", |
|---|
| 1215 | + __func__)); |
|---|
| 1193 | 1216 | |
|---|
| 1194 | 1217 | karg.event_entries = MPT3SAS_CTL_EVENT_LOG_SIZE; |
|---|
| 1195 | 1218 | memcpy(karg.event_types, ioc->event_type, |
|---|
| .. | .. |
|---|
| 1219 | 1242 | return -EFAULT; |
|---|
| 1220 | 1243 | } |
|---|
| 1221 | 1244 | |
|---|
| 1222 | | - dctlprintk(ioc, pr_info(MPT3SAS_FMT "%s: enter\n", ioc->name, |
|---|
| 1223 | | - __func__)); |
|---|
| 1245 | + dctlprintk(ioc, ioc_info(ioc, "%s: enter\n", |
|---|
| 1246 | + __func__)); |
|---|
| 1224 | 1247 | |
|---|
| 1225 | 1248 | memcpy(ioc->event_type, karg.event_types, |
|---|
| 1226 | 1249 | MPI2_EVENT_NOTIFY_EVENTMASK_WORDS * sizeof(u32)); |
|---|
| .. | .. |
|---|
| 1259 | 1282 | return -EFAULT; |
|---|
| 1260 | 1283 | } |
|---|
| 1261 | 1284 | |
|---|
| 1262 | | - dctlprintk(ioc, pr_info(MPT3SAS_FMT "%s: enter\n", ioc->name, |
|---|
| 1263 | | - __func__)); |
|---|
| 1285 | + dctlprintk(ioc, ioc_info(ioc, "%s: enter\n", |
|---|
| 1286 | + __func__)); |
|---|
| 1264 | 1287 | |
|---|
| 1265 | 1288 | number_bytes = karg.hdr.max_data_size - |
|---|
| 1266 | 1289 | sizeof(struct mpt3_ioctl_header); |
|---|
| .. | .. |
|---|
| 1306 | 1329 | ioc->is_driver_loading) |
|---|
| 1307 | 1330 | return -EAGAIN; |
|---|
| 1308 | 1331 | |
|---|
| 1309 | | - dctlprintk(ioc, pr_info(MPT3SAS_FMT "%s: enter\n", ioc->name, |
|---|
| 1310 | | - __func__)); |
|---|
| 1332 | + dctlprintk(ioc, ioc_info(ioc, "%s: enter\n", |
|---|
| 1333 | + __func__)); |
|---|
| 1311 | 1334 | |
|---|
| 1312 | 1335 | retval = mpt3sas_base_hard_reset_handler(ioc, FORCE_BIG_HAMMER); |
|---|
| 1313 | | - pr_info(MPT3SAS_FMT "host reset: %s\n", |
|---|
| 1314 | | - ioc->name, ((!retval) ? "SUCCESS" : "FAILED")); |
|---|
| 1336 | + ioc_info(ioc, |
|---|
| 1337 | + "Ioctl: host reset: %s\n", ((!retval) ? "SUCCESS" : "FAILED")); |
|---|
| 1315 | 1338 | return 0; |
|---|
| 1316 | 1339 | } |
|---|
| 1317 | 1340 | |
|---|
| .. | .. |
|---|
| 1440 | 1463 | return -EFAULT; |
|---|
| 1441 | 1464 | } |
|---|
| 1442 | 1465 | |
|---|
| 1443 | | - dctlprintk(ioc, pr_info(MPT3SAS_FMT "%s\n", ioc->name, |
|---|
| 1444 | | - __func__)); |
|---|
| 1466 | + dctlprintk(ioc, ioc_info(ioc, "%s\n", |
|---|
| 1467 | + __func__)); |
|---|
| 1445 | 1468 | |
|---|
| 1446 | 1469 | rc = _ctl_btdh_search_sas_device(ioc, &karg); |
|---|
| 1447 | 1470 | if (!rc) |
|---|
| .. | .. |
|---|
| 1489 | 1512 | return rc; |
|---|
| 1490 | 1513 | } |
|---|
| 1491 | 1514 | |
|---|
| 1515 | +/** |
|---|
| 1516 | + * _ctl_diag_get_bufftype - return diag buffer type |
|---|
| 1517 | + * either TRACE, SNAPSHOT, or EXTENDED |
|---|
| 1518 | + * @ioc: per adapter object |
|---|
| 1519 | + * @unique_id: specifies the unique_id for the buffer |
|---|
| 1520 | + * |
|---|
| 1521 | + * returns MPT3_DIAG_UID_NOT_FOUND if the id not found |
|---|
| 1522 | + */ |
|---|
| 1523 | +static u8 |
|---|
| 1524 | +_ctl_diag_get_bufftype(struct MPT3SAS_ADAPTER *ioc, u32 unique_id) |
|---|
| 1525 | +{ |
|---|
| 1526 | + u8 index; |
|---|
| 1527 | + |
|---|
| 1528 | + for (index = 0; index < MPI2_DIAG_BUF_TYPE_COUNT; index++) { |
|---|
| 1529 | + if (ioc->unique_id[index] == unique_id) |
|---|
| 1530 | + return index; |
|---|
| 1531 | + } |
|---|
| 1532 | + |
|---|
| 1533 | + return MPT3_DIAG_UID_NOT_FOUND; |
|---|
| 1534 | +} |
|---|
| 1492 | 1535 | |
|---|
| 1493 | 1536 | /** |
|---|
| 1494 | 1537 | * _ctl_diag_register_2 - wrapper for registering diag buffer support |
|---|
| .. | .. |
|---|
| 1512 | 1555 | u32 ioc_state; |
|---|
| 1513 | 1556 | u8 issue_reset = 0; |
|---|
| 1514 | 1557 | |
|---|
| 1515 | | - dctlprintk(ioc, pr_info(MPT3SAS_FMT "%s\n", ioc->name, |
|---|
| 1516 | | - __func__)); |
|---|
| 1558 | + dctlprintk(ioc, ioc_info(ioc, "%s\n", |
|---|
| 1559 | + __func__)); |
|---|
| 1517 | 1560 | |
|---|
| 1518 | 1561 | ioc_state = mpt3sas_base_get_iocstate(ioc, 1); |
|---|
| 1519 | 1562 | if (ioc_state != MPI2_IOC_STATE_OPERATIONAL) { |
|---|
| 1520 | | - pr_err(MPT3SAS_FMT |
|---|
| 1521 | | - "%s: failed due to ioc not operational\n", |
|---|
| 1522 | | - ioc->name, __func__); |
|---|
| 1563 | + ioc_err(ioc, "%s: failed due to ioc not operational\n", |
|---|
| 1564 | + __func__); |
|---|
| 1523 | 1565 | rc = -EAGAIN; |
|---|
| 1524 | 1566 | goto out; |
|---|
| 1525 | 1567 | } |
|---|
| 1526 | 1568 | |
|---|
| 1527 | 1569 | if (ioc->ctl_cmds.status != MPT3_CMD_NOT_USED) { |
|---|
| 1528 | | - pr_err(MPT3SAS_FMT "%s: ctl_cmd in use\n", |
|---|
| 1529 | | - ioc->name, __func__); |
|---|
| 1570 | + ioc_err(ioc, "%s: ctl_cmd in use\n", __func__); |
|---|
| 1530 | 1571 | rc = -EAGAIN; |
|---|
| 1531 | 1572 | goto out; |
|---|
| 1532 | 1573 | } |
|---|
| 1533 | 1574 | |
|---|
| 1534 | 1575 | buffer_type = diag_register->buffer_type; |
|---|
| 1535 | 1576 | if (!_ctl_diag_capability(ioc, buffer_type)) { |
|---|
| 1536 | | - pr_err(MPT3SAS_FMT |
|---|
| 1537 | | - "%s: doesn't have capability for buffer_type(0x%02x)\n", |
|---|
| 1538 | | - ioc->name, __func__, buffer_type); |
|---|
| 1577 | + ioc_err(ioc, "%s: doesn't have capability for buffer_type(0x%02x)\n", |
|---|
| 1578 | + __func__, buffer_type); |
|---|
| 1539 | 1579 | return -EPERM; |
|---|
| 1580 | + } |
|---|
| 1581 | + |
|---|
| 1582 | + if (diag_register->unique_id == 0) { |
|---|
| 1583 | + ioc_err(ioc, |
|---|
| 1584 | + "%s: Invalid UID(0x%08x), buffer_type(0x%02x)\n", __func__, |
|---|
| 1585 | + diag_register->unique_id, buffer_type); |
|---|
| 1586 | + return -EINVAL; |
|---|
| 1587 | + } |
|---|
| 1588 | + |
|---|
| 1589 | + if ((ioc->diag_buffer_status[buffer_type] & |
|---|
| 1590 | + MPT3_DIAG_BUFFER_IS_APP_OWNED) && |
|---|
| 1591 | + !(ioc->diag_buffer_status[buffer_type] & |
|---|
| 1592 | + MPT3_DIAG_BUFFER_IS_RELEASED)) { |
|---|
| 1593 | + ioc_err(ioc, |
|---|
| 1594 | + "%s: buffer_type(0x%02x) is already registered by application with UID(0x%08x)\n", |
|---|
| 1595 | + __func__, buffer_type, ioc->unique_id[buffer_type]); |
|---|
| 1596 | + return -EINVAL; |
|---|
| 1540 | 1597 | } |
|---|
| 1541 | 1598 | |
|---|
| 1542 | 1599 | if (ioc->diag_buffer_status[buffer_type] & |
|---|
| 1543 | 1600 | MPT3_DIAG_BUFFER_IS_REGISTERED) { |
|---|
| 1544 | | - pr_err(MPT3SAS_FMT |
|---|
| 1545 | | - "%s: already has a registered buffer for buffer_type(0x%02x)\n", |
|---|
| 1546 | | - ioc->name, __func__, |
|---|
| 1547 | | - buffer_type); |
|---|
| 1548 | | - return -EINVAL; |
|---|
| 1601 | + /* |
|---|
| 1602 | + * If driver posts buffer initially, then an application wants |
|---|
| 1603 | + * to Register that buffer (own it) without Releasing first, |
|---|
| 1604 | + * the application Register command MUST have the same buffer |
|---|
| 1605 | + * type and size in the Register command (obtained from the |
|---|
| 1606 | + * Query command). Otherwise that Register command will be |
|---|
| 1607 | + * failed. If the application has released the buffer but wants |
|---|
| 1608 | + * to re-register it, it should be allowed as long as the |
|---|
| 1609 | + * Unique-Id/Size match. |
|---|
| 1610 | + */ |
|---|
| 1611 | + |
|---|
| 1612 | + if (ioc->unique_id[buffer_type] == MPT3DIAGBUFFUNIQUEID && |
|---|
| 1613 | + ioc->diag_buffer_sz[buffer_type] == |
|---|
| 1614 | + diag_register->requested_buffer_size) { |
|---|
| 1615 | + |
|---|
| 1616 | + if (!(ioc->diag_buffer_status[buffer_type] & |
|---|
| 1617 | + MPT3_DIAG_BUFFER_IS_RELEASED)) { |
|---|
| 1618 | + dctlprintk(ioc, ioc_info(ioc, |
|---|
| 1619 | + "%s: diag_buffer (%d) ownership changed. old-ID(0x%08x), new-ID(0x%08x)\n", |
|---|
| 1620 | + __func__, buffer_type, |
|---|
| 1621 | + ioc->unique_id[buffer_type], |
|---|
| 1622 | + diag_register->unique_id)); |
|---|
| 1623 | + |
|---|
| 1624 | + /* |
|---|
| 1625 | + * Application wants to own the buffer with |
|---|
| 1626 | + * the same size. |
|---|
| 1627 | + */ |
|---|
| 1628 | + ioc->unique_id[buffer_type] = |
|---|
| 1629 | + diag_register->unique_id; |
|---|
| 1630 | + rc = 0; /* success */ |
|---|
| 1631 | + goto out; |
|---|
| 1632 | + } |
|---|
| 1633 | + } else if (ioc->unique_id[buffer_type] != |
|---|
| 1634 | + MPT3DIAGBUFFUNIQUEID) { |
|---|
| 1635 | + if (ioc->unique_id[buffer_type] != |
|---|
| 1636 | + diag_register->unique_id || |
|---|
| 1637 | + ioc->diag_buffer_sz[buffer_type] != |
|---|
| 1638 | + diag_register->requested_buffer_size || |
|---|
| 1639 | + !(ioc->diag_buffer_status[buffer_type] & |
|---|
| 1640 | + MPT3_DIAG_BUFFER_IS_RELEASED)) { |
|---|
| 1641 | + ioc_err(ioc, |
|---|
| 1642 | + "%s: already has a registered buffer for buffer_type(0x%02x)\n", |
|---|
| 1643 | + __func__, buffer_type); |
|---|
| 1644 | + return -EINVAL; |
|---|
| 1645 | + } |
|---|
| 1646 | + } else { |
|---|
| 1647 | + ioc_err(ioc, "%s: already has a registered buffer for buffer_type(0x%02x)\n", |
|---|
| 1648 | + __func__, buffer_type); |
|---|
| 1649 | + return -EINVAL; |
|---|
| 1650 | + } |
|---|
| 1651 | + } else if (ioc->diag_buffer_status[buffer_type] & |
|---|
| 1652 | + MPT3_DIAG_BUFFER_IS_DRIVER_ALLOCATED) { |
|---|
| 1653 | + |
|---|
| 1654 | + if (ioc->unique_id[buffer_type] != MPT3DIAGBUFFUNIQUEID || |
|---|
| 1655 | + ioc->diag_buffer_sz[buffer_type] != |
|---|
| 1656 | + diag_register->requested_buffer_size) { |
|---|
| 1657 | + |
|---|
| 1658 | + ioc_err(ioc, |
|---|
| 1659 | + "%s: already a buffer is allocated for buffer_type(0x%02x) of size %d bytes, so please try registering again with same size\n", |
|---|
| 1660 | + __func__, buffer_type, |
|---|
| 1661 | + ioc->diag_buffer_sz[buffer_type]); |
|---|
| 1662 | + return -EINVAL; |
|---|
| 1663 | + } |
|---|
| 1549 | 1664 | } |
|---|
| 1550 | 1665 | |
|---|
| 1551 | 1666 | if (diag_register->requested_buffer_size % 4) { |
|---|
| 1552 | | - pr_err(MPT3SAS_FMT |
|---|
| 1553 | | - "%s: the requested_buffer_size is not 4 byte aligned\n", |
|---|
| 1554 | | - ioc->name, __func__); |
|---|
| 1667 | + ioc_err(ioc, "%s: the requested_buffer_size is not 4 byte aligned\n", |
|---|
| 1668 | + __func__); |
|---|
| 1555 | 1669 | return -EINVAL; |
|---|
| 1556 | 1670 | } |
|---|
| 1557 | 1671 | |
|---|
| 1558 | 1672 | smid = mpt3sas_base_get_smid(ioc, ioc->ctl_cb_idx); |
|---|
| 1559 | 1673 | if (!smid) { |
|---|
| 1560 | | - pr_err(MPT3SAS_FMT "%s: failed obtaining a smid\n", |
|---|
| 1561 | | - ioc->name, __func__); |
|---|
| 1674 | + ioc_err(ioc, "%s: failed obtaining a smid\n", __func__); |
|---|
| 1562 | 1675 | rc = -EAGAIN; |
|---|
| 1563 | 1676 | goto out; |
|---|
| 1564 | 1677 | } |
|---|
| .. | .. |
|---|
| 1572 | 1685 | request_data = ioc->diag_buffer[buffer_type]; |
|---|
| 1573 | 1686 | request_data_sz = diag_register->requested_buffer_size; |
|---|
| 1574 | 1687 | ioc->unique_id[buffer_type] = diag_register->unique_id; |
|---|
| 1575 | | - ioc->diag_buffer_status[buffer_type] = 0; |
|---|
| 1688 | + ioc->diag_buffer_status[buffer_type] &= |
|---|
| 1689 | + MPT3_DIAG_BUFFER_IS_DRIVER_ALLOCATED; |
|---|
| 1576 | 1690 | memcpy(ioc->product_specific[buffer_type], |
|---|
| 1577 | 1691 | diag_register->product_specific, MPT3_PRODUCT_SPECIFIC_DWORDS); |
|---|
| 1578 | 1692 | ioc->diagnostic_flags[buffer_type] = diag_register->diagnostic_flags; |
|---|
| .. | .. |
|---|
| 1580 | 1694 | if (request_data) { |
|---|
| 1581 | 1695 | request_data_dma = ioc->diag_buffer_dma[buffer_type]; |
|---|
| 1582 | 1696 | if (request_data_sz != ioc->diag_buffer_sz[buffer_type]) { |
|---|
| 1583 | | - pci_free_consistent(ioc->pdev, |
|---|
| 1584 | | - ioc->diag_buffer_sz[buffer_type], |
|---|
| 1585 | | - request_data, request_data_dma); |
|---|
| 1697 | + dma_free_coherent(&ioc->pdev->dev, |
|---|
| 1698 | + ioc->diag_buffer_sz[buffer_type], |
|---|
| 1699 | + request_data, request_data_dma); |
|---|
| 1586 | 1700 | request_data = NULL; |
|---|
| 1587 | 1701 | } |
|---|
| 1588 | 1702 | } |
|---|
| .. | .. |
|---|
| 1590 | 1704 | if (request_data == NULL) { |
|---|
| 1591 | 1705 | ioc->diag_buffer_sz[buffer_type] = 0; |
|---|
| 1592 | 1706 | ioc->diag_buffer_dma[buffer_type] = 0; |
|---|
| 1593 | | - request_data = pci_alloc_consistent( |
|---|
| 1594 | | - ioc->pdev, request_data_sz, &request_data_dma); |
|---|
| 1707 | + request_data = dma_alloc_coherent(&ioc->pdev->dev, |
|---|
| 1708 | + request_data_sz, &request_data_dma, GFP_KERNEL); |
|---|
| 1595 | 1709 | if (request_data == NULL) { |
|---|
| 1596 | | - pr_err(MPT3SAS_FMT "%s: failed allocating memory" \ |
|---|
| 1597 | | - " for diag buffers, requested size(%d)\n", |
|---|
| 1598 | | - ioc->name, __func__, request_data_sz); |
|---|
| 1710 | + ioc_err(ioc, "%s: failed allocating memory for diag buffers, requested size(%d)\n", |
|---|
| 1711 | + __func__, request_data_sz); |
|---|
| 1599 | 1712 | mpt3sas_base_free_smid(ioc, smid); |
|---|
| 1600 | 1713 | rc = -ENOMEM; |
|---|
| 1601 | 1714 | goto out; |
|---|
| .. | .. |
|---|
| 1613 | 1726 | mpi_request->VF_ID = 0; /* TODO */ |
|---|
| 1614 | 1727 | mpi_request->VP_ID = 0; |
|---|
| 1615 | 1728 | |
|---|
| 1616 | | - dctlprintk(ioc, pr_info(MPT3SAS_FMT |
|---|
| 1617 | | - "%s: diag_buffer(0x%p), dma(0x%llx), sz(%d)\n", |
|---|
| 1618 | | - ioc->name, __func__, request_data, |
|---|
| 1619 | | - (unsigned long long)request_data_dma, |
|---|
| 1620 | | - le32_to_cpu(mpi_request->BufferLength))); |
|---|
| 1729 | + dctlprintk(ioc, |
|---|
| 1730 | + ioc_info(ioc, "%s: diag_buffer(0x%p), dma(0x%llx), sz(%d)\n", |
|---|
| 1731 | + __func__, request_data, |
|---|
| 1732 | + (unsigned long long)request_data_dma, |
|---|
| 1733 | + le32_to_cpu(mpi_request->BufferLength))); |
|---|
| 1621 | 1734 | |
|---|
| 1622 | 1735 | for (i = 0; i < MPT3_PRODUCT_SPECIFIC_DWORDS; i++) |
|---|
| 1623 | 1736 | mpi_request->ProductSpecific[i] = |
|---|
| 1624 | 1737 | cpu_to_le32(ioc->product_specific[buffer_type][i]); |
|---|
| 1625 | 1738 | |
|---|
| 1626 | 1739 | init_completion(&ioc->ctl_cmds.done); |
|---|
| 1627 | | - mpt3sas_base_put_smid_default(ioc, smid); |
|---|
| 1740 | + ioc->put_smid_default(ioc, smid); |
|---|
| 1628 | 1741 | wait_for_completion_timeout(&ioc->ctl_cmds.done, |
|---|
| 1629 | 1742 | MPT3_IOCTL_DEFAULT_TIMEOUT*HZ); |
|---|
| 1630 | 1743 | |
|---|
| 1631 | 1744 | if (!(ioc->ctl_cmds.status & MPT3_CMD_COMPLETE)) { |
|---|
| 1632 | | - issue_reset = |
|---|
| 1633 | | - mpt3sas_base_check_cmd_timeout(ioc, |
|---|
| 1634 | | - ioc->ctl_cmds.status, mpi_request, |
|---|
| 1635 | | - sizeof(Mpi2DiagBufferPostRequest_t)/4); |
|---|
| 1745 | + mpt3sas_check_cmd_timeout(ioc, |
|---|
| 1746 | + ioc->ctl_cmds.status, mpi_request, |
|---|
| 1747 | + sizeof(Mpi2DiagBufferPostRequest_t)/4, issue_reset); |
|---|
| 1636 | 1748 | goto issue_host_reset; |
|---|
| 1637 | 1749 | } |
|---|
| 1638 | 1750 | |
|---|
| 1639 | 1751 | /* process the completed Reply Message Frame */ |
|---|
| 1640 | 1752 | if ((ioc->ctl_cmds.status & MPT3_CMD_REPLY_VALID) == 0) { |
|---|
| 1641 | | - pr_err(MPT3SAS_FMT "%s: no reply message\n", |
|---|
| 1642 | | - ioc->name, __func__); |
|---|
| 1753 | + ioc_err(ioc, "%s: no reply message\n", __func__); |
|---|
| 1643 | 1754 | rc = -EFAULT; |
|---|
| 1644 | 1755 | goto out; |
|---|
| 1645 | 1756 | } |
|---|
| .. | .. |
|---|
| 1650 | 1761 | if (ioc_status == MPI2_IOCSTATUS_SUCCESS) { |
|---|
| 1651 | 1762 | ioc->diag_buffer_status[buffer_type] |= |
|---|
| 1652 | 1763 | MPT3_DIAG_BUFFER_IS_REGISTERED; |
|---|
| 1653 | | - dctlprintk(ioc, pr_info(MPT3SAS_FMT "%s: success\n", |
|---|
| 1654 | | - ioc->name, __func__)); |
|---|
| 1764 | + dctlprintk(ioc, ioc_info(ioc, "%s: success\n", __func__)); |
|---|
| 1655 | 1765 | } else { |
|---|
| 1656 | | - pr_info(MPT3SAS_FMT |
|---|
| 1657 | | - "%s: ioc_status(0x%04x) log_info(0x%08x)\n", |
|---|
| 1658 | | - ioc->name, __func__, |
|---|
| 1659 | | - ioc_status, le32_to_cpu(mpi_reply->IOCLogInfo)); |
|---|
| 1766 | + ioc_info(ioc, "%s: ioc_status(0x%04x) log_info(0x%08x)\n", |
|---|
| 1767 | + __func__, |
|---|
| 1768 | + ioc_status, le32_to_cpu(mpi_reply->IOCLogInfo)); |
|---|
| 1660 | 1769 | rc = -EFAULT; |
|---|
| 1661 | 1770 | } |
|---|
| 1662 | 1771 | |
|---|
| .. | .. |
|---|
| 1666 | 1775 | |
|---|
| 1667 | 1776 | out: |
|---|
| 1668 | 1777 | |
|---|
| 1669 | | - if (rc && request_data) |
|---|
| 1670 | | - pci_free_consistent(ioc->pdev, request_data_sz, |
|---|
| 1778 | + if (rc && request_data) { |
|---|
| 1779 | + dma_free_coherent(&ioc->pdev->dev, request_data_sz, |
|---|
| 1671 | 1780 | request_data, request_data_dma); |
|---|
| 1781 | + ioc->diag_buffer_status[buffer_type] &= |
|---|
| 1782 | + ~MPT3_DIAG_BUFFER_IS_DRIVER_ALLOCATED; |
|---|
| 1783 | + } |
|---|
| 1672 | 1784 | |
|---|
| 1673 | 1785 | ioc->ctl_cmds.status = MPT3_CMD_NOT_USED; |
|---|
| 1674 | 1786 | return rc; |
|---|
| .. | .. |
|---|
| 1686 | 1798 | mpt3sas_enable_diag_buffer(struct MPT3SAS_ADAPTER *ioc, u8 bits_to_register) |
|---|
| 1687 | 1799 | { |
|---|
| 1688 | 1800 | struct mpt3_diag_register diag_register; |
|---|
| 1801 | + u32 ret_val; |
|---|
| 1802 | + u32 trace_buff_size = ioc->manu_pg11.HostTraceBufferMaxSizeKB<<10; |
|---|
| 1803 | + u32 min_trace_buff_size = 0; |
|---|
| 1804 | + u32 decr_trace_buff_size = 0; |
|---|
| 1689 | 1805 | |
|---|
| 1690 | 1806 | memset(&diag_register, 0, sizeof(struct mpt3_diag_register)); |
|---|
| 1691 | 1807 | |
|---|
| 1692 | 1808 | if (bits_to_register & 1) { |
|---|
| 1693 | | - pr_info(MPT3SAS_FMT "registering trace buffer support\n", |
|---|
| 1694 | | - ioc->name); |
|---|
| 1809 | + ioc_info(ioc, "registering trace buffer support\n"); |
|---|
| 1695 | 1810 | ioc->diag_trigger_master.MasterData = |
|---|
| 1696 | 1811 | (MASTER_TRIGGER_FW_FAULT + MASTER_TRIGGER_ADAPTER_RESET); |
|---|
| 1697 | 1812 | diag_register.buffer_type = MPI2_DIAG_BUF_TYPE_TRACE; |
|---|
| 1698 | | - /* register for 2MB buffers */ |
|---|
| 1699 | | - diag_register.requested_buffer_size = 2 * (1024 * 1024); |
|---|
| 1700 | | - diag_register.unique_id = 0x7075900; |
|---|
| 1701 | | - _ctl_diag_register_2(ioc, &diag_register); |
|---|
| 1813 | + diag_register.unique_id = |
|---|
| 1814 | + (ioc->hba_mpi_version_belonged == MPI2_VERSION) ? |
|---|
| 1815 | + (MPT2DIAGBUFFUNIQUEID):(MPT3DIAGBUFFUNIQUEID); |
|---|
| 1816 | + |
|---|
| 1817 | + if (trace_buff_size != 0) { |
|---|
| 1818 | + diag_register.requested_buffer_size = trace_buff_size; |
|---|
| 1819 | + min_trace_buff_size = |
|---|
| 1820 | + ioc->manu_pg11.HostTraceBufferMinSizeKB<<10; |
|---|
| 1821 | + decr_trace_buff_size = |
|---|
| 1822 | + ioc->manu_pg11.HostTraceBufferDecrementSizeKB<<10; |
|---|
| 1823 | + |
|---|
| 1824 | + if (min_trace_buff_size > trace_buff_size) { |
|---|
| 1825 | + /* The buff size is not set correctly */ |
|---|
| 1826 | + ioc_err(ioc, |
|---|
| 1827 | + "Min Trace Buff size (%d KB) greater than Max Trace Buff size (%d KB)\n", |
|---|
| 1828 | + min_trace_buff_size>>10, |
|---|
| 1829 | + trace_buff_size>>10); |
|---|
| 1830 | + ioc_err(ioc, |
|---|
| 1831 | + "Using zero Min Trace Buff Size\n"); |
|---|
| 1832 | + min_trace_buff_size = 0; |
|---|
| 1833 | + } |
|---|
| 1834 | + |
|---|
| 1835 | + if (decr_trace_buff_size == 0) { |
|---|
| 1836 | + /* |
|---|
| 1837 | + * retry the min size if decrement |
|---|
| 1838 | + * is not available. |
|---|
| 1839 | + */ |
|---|
| 1840 | + decr_trace_buff_size = |
|---|
| 1841 | + trace_buff_size - min_trace_buff_size; |
|---|
| 1842 | + } |
|---|
| 1843 | + } else { |
|---|
| 1844 | + /* register for 2MB buffers */ |
|---|
| 1845 | + diag_register.requested_buffer_size = 2 * (1024 * 1024); |
|---|
| 1846 | + } |
|---|
| 1847 | + |
|---|
| 1848 | + do { |
|---|
| 1849 | + ret_val = _ctl_diag_register_2(ioc, &diag_register); |
|---|
| 1850 | + |
|---|
| 1851 | + if (ret_val == -ENOMEM && min_trace_buff_size && |
|---|
| 1852 | + (trace_buff_size - decr_trace_buff_size) >= |
|---|
| 1853 | + min_trace_buff_size) { |
|---|
| 1854 | + /* adjust the buffer size */ |
|---|
| 1855 | + trace_buff_size -= decr_trace_buff_size; |
|---|
| 1856 | + diag_register.requested_buffer_size = |
|---|
| 1857 | + trace_buff_size; |
|---|
| 1858 | + } else |
|---|
| 1859 | + break; |
|---|
| 1860 | + } while (true); |
|---|
| 1861 | + |
|---|
| 1862 | + if (ret_val == -ENOMEM) |
|---|
| 1863 | + ioc_err(ioc, |
|---|
| 1864 | + "Cannot allocate trace buffer memory. Last memory tried = %d KB\n", |
|---|
| 1865 | + diag_register.requested_buffer_size>>10); |
|---|
| 1866 | + else if (ioc->diag_buffer_status[MPI2_DIAG_BUF_TYPE_TRACE] |
|---|
| 1867 | + & MPT3_DIAG_BUFFER_IS_REGISTERED) { |
|---|
| 1868 | + ioc_err(ioc, "Trace buffer memory %d KB allocated\n", |
|---|
| 1869 | + diag_register.requested_buffer_size>>10); |
|---|
| 1870 | + if (ioc->hba_mpi_version_belonged != MPI2_VERSION) |
|---|
| 1871 | + ioc->diag_buffer_status[ |
|---|
| 1872 | + MPI2_DIAG_BUF_TYPE_TRACE] |= |
|---|
| 1873 | + MPT3_DIAG_BUFFER_IS_DRIVER_ALLOCATED; |
|---|
| 1874 | + } |
|---|
| 1702 | 1875 | } |
|---|
| 1703 | 1876 | |
|---|
| 1704 | 1877 | if (bits_to_register & 2) { |
|---|
| 1705 | | - pr_info(MPT3SAS_FMT "registering snapshot buffer support\n", |
|---|
| 1706 | | - ioc->name); |
|---|
| 1878 | + ioc_info(ioc, "registering snapshot buffer support\n"); |
|---|
| 1707 | 1879 | diag_register.buffer_type = MPI2_DIAG_BUF_TYPE_SNAPSHOT; |
|---|
| 1708 | 1880 | /* register for 2MB buffers */ |
|---|
| 1709 | 1881 | diag_register.requested_buffer_size = 2 * (1024 * 1024); |
|---|
| .. | .. |
|---|
| 1712 | 1884 | } |
|---|
| 1713 | 1885 | |
|---|
| 1714 | 1886 | if (bits_to_register & 4) { |
|---|
| 1715 | | - pr_info(MPT3SAS_FMT "registering extended buffer support\n", |
|---|
| 1716 | | - ioc->name); |
|---|
| 1887 | + ioc_info(ioc, "registering extended buffer support\n"); |
|---|
| 1717 | 1888 | diag_register.buffer_type = MPI2_DIAG_BUF_TYPE_EXTENDED; |
|---|
| 1718 | 1889 | /* register for 2MB buffers */ |
|---|
| 1719 | 1890 | diag_register.requested_buffer_size = 2 * (1024 * 1024); |
|---|
| .. | .. |
|---|
| 1743 | 1914 | } |
|---|
| 1744 | 1915 | |
|---|
| 1745 | 1916 | rc = _ctl_diag_register_2(ioc, &karg); |
|---|
| 1917 | + |
|---|
| 1918 | + if (!rc && (ioc->diag_buffer_status[karg.buffer_type] & |
|---|
| 1919 | + MPT3_DIAG_BUFFER_IS_REGISTERED)) |
|---|
| 1920 | + ioc->diag_buffer_status[karg.buffer_type] |= |
|---|
| 1921 | + MPT3_DIAG_BUFFER_IS_APP_OWNED; |
|---|
| 1922 | + |
|---|
| 1746 | 1923 | return rc; |
|---|
| 1747 | 1924 | } |
|---|
| 1748 | 1925 | |
|---|
| .. | .. |
|---|
| 1769 | 1946 | return -EFAULT; |
|---|
| 1770 | 1947 | } |
|---|
| 1771 | 1948 | |
|---|
| 1772 | | - dctlprintk(ioc, pr_info(MPT3SAS_FMT "%s\n", ioc->name, |
|---|
| 1773 | | - __func__)); |
|---|
| 1949 | + dctlprintk(ioc, ioc_info(ioc, "%s\n", |
|---|
| 1950 | + __func__)); |
|---|
| 1774 | 1951 | |
|---|
| 1775 | | - buffer_type = karg.unique_id & 0x000000ff; |
|---|
| 1952 | + buffer_type = _ctl_diag_get_bufftype(ioc, karg.unique_id); |
|---|
| 1953 | + if (buffer_type == MPT3_DIAG_UID_NOT_FOUND) { |
|---|
| 1954 | + ioc_err(ioc, "%s: buffer with unique_id(0x%08x) not found\n", |
|---|
| 1955 | + __func__, karg.unique_id); |
|---|
| 1956 | + return -EINVAL; |
|---|
| 1957 | + } |
|---|
| 1958 | + |
|---|
| 1776 | 1959 | if (!_ctl_diag_capability(ioc, buffer_type)) { |
|---|
| 1777 | | - pr_err(MPT3SAS_FMT |
|---|
| 1778 | | - "%s: doesn't have capability for buffer_type(0x%02x)\n", |
|---|
| 1779 | | - ioc->name, __func__, buffer_type); |
|---|
| 1960 | + ioc_err(ioc, "%s: doesn't have capability for buffer_type(0x%02x)\n", |
|---|
| 1961 | + __func__, buffer_type); |
|---|
| 1780 | 1962 | return -EPERM; |
|---|
| 1781 | 1963 | } |
|---|
| 1782 | 1964 | |
|---|
| 1783 | 1965 | if ((ioc->diag_buffer_status[buffer_type] & |
|---|
| 1784 | 1966 | MPT3_DIAG_BUFFER_IS_REGISTERED) == 0) { |
|---|
| 1785 | | - pr_err(MPT3SAS_FMT |
|---|
| 1786 | | - "%s: buffer_type(0x%02x) is not registered\n", |
|---|
| 1787 | | - ioc->name, __func__, buffer_type); |
|---|
| 1967 | + ioc_err(ioc, "%s: buffer_type(0x%02x) is not registered\n", |
|---|
| 1968 | + __func__, buffer_type); |
|---|
| 1788 | 1969 | return -EINVAL; |
|---|
| 1789 | 1970 | } |
|---|
| 1790 | 1971 | if ((ioc->diag_buffer_status[buffer_type] & |
|---|
| 1791 | 1972 | MPT3_DIAG_BUFFER_IS_RELEASED) == 0) { |
|---|
| 1792 | | - pr_err(MPT3SAS_FMT |
|---|
| 1793 | | - "%s: buffer_type(0x%02x) has not been released\n", |
|---|
| 1794 | | - ioc->name, __func__, buffer_type); |
|---|
| 1973 | + ioc_err(ioc, "%s: buffer_type(0x%02x) has not been released\n", |
|---|
| 1974 | + __func__, buffer_type); |
|---|
| 1795 | 1975 | return -EINVAL; |
|---|
| 1796 | 1976 | } |
|---|
| 1797 | 1977 | |
|---|
| 1798 | 1978 | if (karg.unique_id != ioc->unique_id[buffer_type]) { |
|---|
| 1799 | | - pr_err(MPT3SAS_FMT |
|---|
| 1800 | | - "%s: unique_id(0x%08x) is not registered\n", |
|---|
| 1801 | | - ioc->name, __func__, karg.unique_id); |
|---|
| 1979 | + ioc_err(ioc, "%s: unique_id(0x%08x) is not registered\n", |
|---|
| 1980 | + __func__, karg.unique_id); |
|---|
| 1802 | 1981 | return -EINVAL; |
|---|
| 1803 | 1982 | } |
|---|
| 1804 | 1983 | |
|---|
| 1805 | 1984 | request_data = ioc->diag_buffer[buffer_type]; |
|---|
| 1806 | 1985 | if (!request_data) { |
|---|
| 1807 | | - pr_err(MPT3SAS_FMT |
|---|
| 1808 | | - "%s: doesn't have memory allocated for buffer_type(0x%02x)\n", |
|---|
| 1809 | | - ioc->name, __func__, buffer_type); |
|---|
| 1986 | + ioc_err(ioc, "%s: doesn't have memory allocated for buffer_type(0x%02x)\n", |
|---|
| 1987 | + __func__, buffer_type); |
|---|
| 1810 | 1988 | return -ENOMEM; |
|---|
| 1811 | 1989 | } |
|---|
| 1812 | 1990 | |
|---|
| 1813 | | - request_data_sz = ioc->diag_buffer_sz[buffer_type]; |
|---|
| 1814 | | - request_data_dma = ioc->diag_buffer_dma[buffer_type]; |
|---|
| 1815 | | - pci_free_consistent(ioc->pdev, request_data_sz, |
|---|
| 1816 | | - request_data, request_data_dma); |
|---|
| 1817 | | - ioc->diag_buffer[buffer_type] = NULL; |
|---|
| 1818 | | - ioc->diag_buffer_status[buffer_type] = 0; |
|---|
| 1991 | + if (ioc->diag_buffer_status[buffer_type] & |
|---|
| 1992 | + MPT3_DIAG_BUFFER_IS_DRIVER_ALLOCATED) { |
|---|
| 1993 | + ioc->unique_id[buffer_type] = MPT3DIAGBUFFUNIQUEID; |
|---|
| 1994 | + ioc->diag_buffer_status[buffer_type] &= |
|---|
| 1995 | + ~MPT3_DIAG_BUFFER_IS_APP_OWNED; |
|---|
| 1996 | + ioc->diag_buffer_status[buffer_type] &= |
|---|
| 1997 | + ~MPT3_DIAG_BUFFER_IS_REGISTERED; |
|---|
| 1998 | + } else { |
|---|
| 1999 | + request_data_sz = ioc->diag_buffer_sz[buffer_type]; |
|---|
| 2000 | + request_data_dma = ioc->diag_buffer_dma[buffer_type]; |
|---|
| 2001 | + dma_free_coherent(&ioc->pdev->dev, request_data_sz, |
|---|
| 2002 | + request_data, request_data_dma); |
|---|
| 2003 | + ioc->diag_buffer[buffer_type] = NULL; |
|---|
| 2004 | + ioc->diag_buffer_status[buffer_type] = 0; |
|---|
| 2005 | + } |
|---|
| 1819 | 2006 | return 0; |
|---|
| 1820 | 2007 | } |
|---|
| 1821 | 2008 | |
|---|
| .. | .. |
|---|
| 1842 | 2029 | return -EFAULT; |
|---|
| 1843 | 2030 | } |
|---|
| 1844 | 2031 | |
|---|
| 1845 | | - dctlprintk(ioc, pr_info(MPT3SAS_FMT "%s\n", ioc->name, |
|---|
| 1846 | | - __func__)); |
|---|
| 2032 | + dctlprintk(ioc, ioc_info(ioc, "%s\n", |
|---|
| 2033 | + __func__)); |
|---|
| 1847 | 2034 | |
|---|
| 1848 | 2035 | karg.application_flags = 0; |
|---|
| 1849 | 2036 | buffer_type = karg.buffer_type; |
|---|
| 1850 | 2037 | |
|---|
| 1851 | 2038 | if (!_ctl_diag_capability(ioc, buffer_type)) { |
|---|
| 1852 | | - pr_err(MPT3SAS_FMT |
|---|
| 1853 | | - "%s: doesn't have capability for buffer_type(0x%02x)\n", |
|---|
| 1854 | | - ioc->name, __func__, buffer_type); |
|---|
| 2039 | + ioc_err(ioc, "%s: doesn't have capability for buffer_type(0x%02x)\n", |
|---|
| 2040 | + __func__, buffer_type); |
|---|
| 1855 | 2041 | return -EPERM; |
|---|
| 1856 | 2042 | } |
|---|
| 1857 | 2043 | |
|---|
| 1858 | | - if ((ioc->diag_buffer_status[buffer_type] & |
|---|
| 1859 | | - MPT3_DIAG_BUFFER_IS_REGISTERED) == 0) { |
|---|
| 1860 | | - pr_err(MPT3SAS_FMT |
|---|
| 1861 | | - "%s: buffer_type(0x%02x) is not registered\n", |
|---|
| 1862 | | - ioc->name, __func__, buffer_type); |
|---|
| 1863 | | - return -EINVAL; |
|---|
| 2044 | + if (!(ioc->diag_buffer_status[buffer_type] & |
|---|
| 2045 | + MPT3_DIAG_BUFFER_IS_DRIVER_ALLOCATED)) { |
|---|
| 2046 | + if ((ioc->diag_buffer_status[buffer_type] & |
|---|
| 2047 | + MPT3_DIAG_BUFFER_IS_REGISTERED) == 0) { |
|---|
| 2048 | + ioc_err(ioc, "%s: buffer_type(0x%02x) is not registered\n", |
|---|
| 2049 | + __func__, buffer_type); |
|---|
| 2050 | + return -EINVAL; |
|---|
| 2051 | + } |
|---|
| 1864 | 2052 | } |
|---|
| 1865 | 2053 | |
|---|
| 1866 | | - if (karg.unique_id & 0xffffff00) { |
|---|
| 2054 | + if (karg.unique_id) { |
|---|
| 1867 | 2055 | if (karg.unique_id != ioc->unique_id[buffer_type]) { |
|---|
| 1868 | | - pr_err(MPT3SAS_FMT |
|---|
| 1869 | | - "%s: unique_id(0x%08x) is not registered\n", |
|---|
| 1870 | | - ioc->name, __func__, karg.unique_id); |
|---|
| 2056 | + ioc_err(ioc, "%s: unique_id(0x%08x) is not registered\n", |
|---|
| 2057 | + __func__, karg.unique_id); |
|---|
| 1871 | 2058 | return -EINVAL; |
|---|
| 1872 | 2059 | } |
|---|
| 1873 | 2060 | } |
|---|
| 1874 | 2061 | |
|---|
| 1875 | 2062 | request_data = ioc->diag_buffer[buffer_type]; |
|---|
| 1876 | 2063 | if (!request_data) { |
|---|
| 1877 | | - pr_err(MPT3SAS_FMT |
|---|
| 1878 | | - "%s: doesn't have buffer for buffer_type(0x%02x)\n", |
|---|
| 1879 | | - ioc->name, __func__, buffer_type); |
|---|
| 2064 | + ioc_err(ioc, "%s: doesn't have buffer for buffer_type(0x%02x)\n", |
|---|
| 2065 | + __func__, buffer_type); |
|---|
| 1880 | 2066 | return -ENOMEM; |
|---|
| 1881 | 2067 | } |
|---|
| 1882 | 2068 | |
|---|
| 1883 | | - if (ioc->diag_buffer_status[buffer_type] & MPT3_DIAG_BUFFER_IS_RELEASED) |
|---|
| 1884 | | - karg.application_flags = (MPT3_APP_FLAGS_APP_OWNED | |
|---|
| 1885 | | - MPT3_APP_FLAGS_BUFFER_VALID); |
|---|
| 1886 | | - else |
|---|
| 1887 | | - karg.application_flags = (MPT3_APP_FLAGS_APP_OWNED | |
|---|
| 1888 | | - MPT3_APP_FLAGS_BUFFER_VALID | |
|---|
| 1889 | | - MPT3_APP_FLAGS_FW_BUFFER_ACCESS); |
|---|
| 2069 | + if ((ioc->diag_buffer_status[buffer_type] & |
|---|
| 2070 | + MPT3_DIAG_BUFFER_IS_REGISTERED)) |
|---|
| 2071 | + karg.application_flags |= MPT3_APP_FLAGS_BUFFER_VALID; |
|---|
| 2072 | + |
|---|
| 2073 | + if (!(ioc->diag_buffer_status[buffer_type] & |
|---|
| 2074 | + MPT3_DIAG_BUFFER_IS_RELEASED)) |
|---|
| 2075 | + karg.application_flags |= MPT3_APP_FLAGS_FW_BUFFER_ACCESS; |
|---|
| 2076 | + |
|---|
| 2077 | + if (!(ioc->diag_buffer_status[buffer_type] & |
|---|
| 2078 | + MPT3_DIAG_BUFFER_IS_DRIVER_ALLOCATED)) |
|---|
| 2079 | + karg.application_flags |= MPT3_APP_FLAGS_DYNAMIC_BUFFER_ALLOC; |
|---|
| 2080 | + |
|---|
| 2081 | + if ((ioc->diag_buffer_status[buffer_type] & |
|---|
| 2082 | + MPT3_DIAG_BUFFER_IS_APP_OWNED)) |
|---|
| 2083 | + karg.application_flags |= MPT3_APP_FLAGS_APP_OWNED; |
|---|
| 1890 | 2084 | |
|---|
| 1891 | 2085 | for (i = 0; i < MPT3_PRODUCT_SPECIFIC_DWORDS; i++) |
|---|
| 1892 | 2086 | karg.product_specific[i] = |
|---|
| .. | .. |
|---|
| 1898 | 2092 | karg.diagnostic_flags = ioc->diagnostic_flags[buffer_type]; |
|---|
| 1899 | 2093 | |
|---|
| 1900 | 2094 | if (copy_to_user(arg, &karg, sizeof(struct mpt3_diag_query))) { |
|---|
| 1901 | | - pr_err(MPT3SAS_FMT |
|---|
| 1902 | | - "%s: unable to write mpt3_diag_query data @ %p\n", |
|---|
| 1903 | | - ioc->name, __func__, arg); |
|---|
| 2095 | + ioc_err(ioc, "%s: unable to write mpt3_diag_query data @ %p\n", |
|---|
| 2096 | + __func__, arg); |
|---|
| 1904 | 2097 | return -EFAULT; |
|---|
| 1905 | 2098 | } |
|---|
| 1906 | 2099 | return 0; |
|---|
| .. | .. |
|---|
| 1923 | 2116 | u16 ioc_status; |
|---|
| 1924 | 2117 | u32 ioc_state; |
|---|
| 1925 | 2118 | int rc; |
|---|
| 2119 | + u8 reset_needed = 0; |
|---|
| 1926 | 2120 | |
|---|
| 1927 | | - dctlprintk(ioc, pr_info(MPT3SAS_FMT "%s\n", ioc->name, |
|---|
| 1928 | | - __func__)); |
|---|
| 2121 | + dctlprintk(ioc, ioc_info(ioc, "%s\n", |
|---|
| 2122 | + __func__)); |
|---|
| 1929 | 2123 | |
|---|
| 1930 | 2124 | rc = 0; |
|---|
| 1931 | 2125 | *issue_reset = 0; |
|---|
| 2126 | + |
|---|
| 1932 | 2127 | |
|---|
| 1933 | 2128 | ioc_state = mpt3sas_base_get_iocstate(ioc, 1); |
|---|
| 1934 | 2129 | if (ioc_state != MPI2_IOC_STATE_OPERATIONAL) { |
|---|
| .. | .. |
|---|
| 1936 | 2131 | MPT3_DIAG_BUFFER_IS_REGISTERED) |
|---|
| 1937 | 2132 | ioc->diag_buffer_status[buffer_type] |= |
|---|
| 1938 | 2133 | MPT3_DIAG_BUFFER_IS_RELEASED; |
|---|
| 1939 | | - dctlprintk(ioc, pr_info(MPT3SAS_FMT |
|---|
| 1940 | | - "%s: skipping due to FAULT state\n", ioc->name, |
|---|
| 1941 | | - __func__)); |
|---|
| 2134 | + dctlprintk(ioc, |
|---|
| 2135 | + ioc_info(ioc, "%s: skipping due to FAULT state\n", |
|---|
| 2136 | + __func__)); |
|---|
| 1942 | 2137 | rc = -EAGAIN; |
|---|
| 1943 | 2138 | goto out; |
|---|
| 1944 | 2139 | } |
|---|
| 1945 | 2140 | |
|---|
| 1946 | 2141 | if (ioc->ctl_cmds.status != MPT3_CMD_NOT_USED) { |
|---|
| 1947 | | - pr_err(MPT3SAS_FMT "%s: ctl_cmd in use\n", |
|---|
| 1948 | | - ioc->name, __func__); |
|---|
| 2142 | + ioc_err(ioc, "%s: ctl_cmd in use\n", __func__); |
|---|
| 1949 | 2143 | rc = -EAGAIN; |
|---|
| 1950 | 2144 | goto out; |
|---|
| 1951 | 2145 | } |
|---|
| 1952 | 2146 | |
|---|
| 1953 | 2147 | smid = mpt3sas_base_get_smid(ioc, ioc->ctl_cb_idx); |
|---|
| 1954 | 2148 | if (!smid) { |
|---|
| 1955 | | - pr_err(MPT3SAS_FMT "%s: failed obtaining a smid\n", |
|---|
| 1956 | | - ioc->name, __func__); |
|---|
| 2149 | + ioc_err(ioc, "%s: failed obtaining a smid\n", __func__); |
|---|
| 1957 | 2150 | rc = -EAGAIN; |
|---|
| 1958 | 2151 | goto out; |
|---|
| 1959 | 2152 | } |
|---|
| .. | .. |
|---|
| 1969 | 2162 | mpi_request->VP_ID = 0; |
|---|
| 1970 | 2163 | |
|---|
| 1971 | 2164 | init_completion(&ioc->ctl_cmds.done); |
|---|
| 1972 | | - mpt3sas_base_put_smid_default(ioc, smid); |
|---|
| 2165 | + ioc->put_smid_default(ioc, smid); |
|---|
| 1973 | 2166 | wait_for_completion_timeout(&ioc->ctl_cmds.done, |
|---|
| 1974 | 2167 | MPT3_IOCTL_DEFAULT_TIMEOUT*HZ); |
|---|
| 1975 | 2168 | |
|---|
| 1976 | 2169 | if (!(ioc->ctl_cmds.status & MPT3_CMD_COMPLETE)) { |
|---|
| 1977 | | - *issue_reset = mpt3sas_base_check_cmd_timeout(ioc, |
|---|
| 1978 | | - ioc->ctl_cmds.status, mpi_request, |
|---|
| 1979 | | - sizeof(Mpi2DiagReleaseRequest_t)/4); |
|---|
| 2170 | + mpt3sas_check_cmd_timeout(ioc, |
|---|
| 2171 | + ioc->ctl_cmds.status, mpi_request, |
|---|
| 2172 | + sizeof(Mpi2DiagReleaseRequest_t)/4, reset_needed); |
|---|
| 2173 | + *issue_reset = reset_needed; |
|---|
| 1980 | 2174 | rc = -EFAULT; |
|---|
| 1981 | 2175 | goto out; |
|---|
| 1982 | 2176 | } |
|---|
| 1983 | 2177 | |
|---|
| 1984 | 2178 | /* process the completed Reply Message Frame */ |
|---|
| 1985 | 2179 | if ((ioc->ctl_cmds.status & MPT3_CMD_REPLY_VALID) == 0) { |
|---|
| 1986 | | - pr_err(MPT3SAS_FMT "%s: no reply message\n", |
|---|
| 1987 | | - ioc->name, __func__); |
|---|
| 2180 | + ioc_err(ioc, "%s: no reply message\n", __func__); |
|---|
| 1988 | 2181 | rc = -EFAULT; |
|---|
| 1989 | 2182 | goto out; |
|---|
| 1990 | 2183 | } |
|---|
| .. | .. |
|---|
| 1995 | 2188 | if (ioc_status == MPI2_IOCSTATUS_SUCCESS) { |
|---|
| 1996 | 2189 | ioc->diag_buffer_status[buffer_type] |= |
|---|
| 1997 | 2190 | MPT3_DIAG_BUFFER_IS_RELEASED; |
|---|
| 1998 | | - dctlprintk(ioc, pr_info(MPT3SAS_FMT "%s: success\n", |
|---|
| 1999 | | - ioc->name, __func__)); |
|---|
| 2191 | + dctlprintk(ioc, ioc_info(ioc, "%s: success\n", __func__)); |
|---|
| 2000 | 2192 | } else { |
|---|
| 2001 | | - pr_info(MPT3SAS_FMT |
|---|
| 2002 | | - "%s: ioc_status(0x%04x) log_info(0x%08x)\n", |
|---|
| 2003 | | - ioc->name, __func__, |
|---|
| 2004 | | - ioc_status, le32_to_cpu(mpi_reply->IOCLogInfo)); |
|---|
| 2193 | + ioc_info(ioc, "%s: ioc_status(0x%04x) log_info(0x%08x)\n", |
|---|
| 2194 | + __func__, |
|---|
| 2195 | + ioc_status, le32_to_cpu(mpi_reply->IOCLogInfo)); |
|---|
| 2005 | 2196 | rc = -EFAULT; |
|---|
| 2006 | 2197 | } |
|---|
| 2007 | 2198 | |
|---|
| .. | .. |
|---|
| 2034 | 2225 | return -EFAULT; |
|---|
| 2035 | 2226 | } |
|---|
| 2036 | 2227 | |
|---|
| 2037 | | - dctlprintk(ioc, pr_info(MPT3SAS_FMT "%s\n", ioc->name, |
|---|
| 2038 | | - __func__)); |
|---|
| 2228 | + dctlprintk(ioc, ioc_info(ioc, "%s\n", |
|---|
| 2229 | + __func__)); |
|---|
| 2039 | 2230 | |
|---|
| 2040 | | - buffer_type = karg.unique_id & 0x000000ff; |
|---|
| 2231 | + buffer_type = _ctl_diag_get_bufftype(ioc, karg.unique_id); |
|---|
| 2232 | + if (buffer_type == MPT3_DIAG_UID_NOT_FOUND) { |
|---|
| 2233 | + ioc_err(ioc, "%s: buffer with unique_id(0x%08x) not found\n", |
|---|
| 2234 | + __func__, karg.unique_id); |
|---|
| 2235 | + return -EINVAL; |
|---|
| 2236 | + } |
|---|
| 2237 | + |
|---|
| 2041 | 2238 | if (!_ctl_diag_capability(ioc, buffer_type)) { |
|---|
| 2042 | | - pr_err(MPT3SAS_FMT |
|---|
| 2043 | | - "%s: doesn't have capability for buffer_type(0x%02x)\n", |
|---|
| 2044 | | - ioc->name, __func__, buffer_type); |
|---|
| 2239 | + ioc_err(ioc, "%s: doesn't have capability for buffer_type(0x%02x)\n", |
|---|
| 2240 | + __func__, buffer_type); |
|---|
| 2045 | 2241 | return -EPERM; |
|---|
| 2046 | 2242 | } |
|---|
| 2047 | 2243 | |
|---|
| 2048 | 2244 | if ((ioc->diag_buffer_status[buffer_type] & |
|---|
| 2049 | 2245 | MPT3_DIAG_BUFFER_IS_REGISTERED) == 0) { |
|---|
| 2050 | | - pr_err(MPT3SAS_FMT |
|---|
| 2051 | | - "%s: buffer_type(0x%02x) is not registered\n", |
|---|
| 2052 | | - ioc->name, __func__, buffer_type); |
|---|
| 2246 | + ioc_err(ioc, "%s: buffer_type(0x%02x) is not registered\n", |
|---|
| 2247 | + __func__, buffer_type); |
|---|
| 2053 | 2248 | return -EINVAL; |
|---|
| 2054 | 2249 | } |
|---|
| 2055 | 2250 | |
|---|
| 2056 | 2251 | if (karg.unique_id != ioc->unique_id[buffer_type]) { |
|---|
| 2057 | | - pr_err(MPT3SAS_FMT |
|---|
| 2058 | | - "%s: unique_id(0x%08x) is not registered\n", |
|---|
| 2059 | | - ioc->name, __func__, karg.unique_id); |
|---|
| 2252 | + ioc_err(ioc, "%s: unique_id(0x%08x) is not registered\n", |
|---|
| 2253 | + __func__, karg.unique_id); |
|---|
| 2060 | 2254 | return -EINVAL; |
|---|
| 2061 | 2255 | } |
|---|
| 2062 | 2256 | |
|---|
| 2063 | 2257 | if (ioc->diag_buffer_status[buffer_type] & |
|---|
| 2064 | 2258 | MPT3_DIAG_BUFFER_IS_RELEASED) { |
|---|
| 2065 | | - pr_err(MPT3SAS_FMT |
|---|
| 2066 | | - "%s: buffer_type(0x%02x) is already released\n", |
|---|
| 2067 | | - ioc->name, __func__, |
|---|
| 2068 | | - buffer_type); |
|---|
| 2069 | | - return 0; |
|---|
| 2259 | + ioc_err(ioc, "%s: buffer_type(0x%02x) is already released\n", |
|---|
| 2260 | + __func__, buffer_type); |
|---|
| 2261 | + return -EINVAL; |
|---|
| 2070 | 2262 | } |
|---|
| 2071 | 2263 | |
|---|
| 2072 | 2264 | request_data = ioc->diag_buffer[buffer_type]; |
|---|
| 2073 | 2265 | |
|---|
| 2074 | 2266 | if (!request_data) { |
|---|
| 2075 | | - pr_err(MPT3SAS_FMT |
|---|
| 2076 | | - "%s: doesn't have memory allocated for buffer_type(0x%02x)\n", |
|---|
| 2077 | | - ioc->name, __func__, buffer_type); |
|---|
| 2267 | + ioc_err(ioc, "%s: doesn't have memory allocated for buffer_type(0x%02x)\n", |
|---|
| 2268 | + __func__, buffer_type); |
|---|
| 2078 | 2269 | return -ENOMEM; |
|---|
| 2079 | 2270 | } |
|---|
| 2080 | 2271 | |
|---|
| .. | .. |
|---|
| 2085 | 2276 | MPT3_DIAG_BUFFER_IS_RELEASED; |
|---|
| 2086 | 2277 | ioc->diag_buffer_status[buffer_type] &= |
|---|
| 2087 | 2278 | ~MPT3_DIAG_BUFFER_IS_DIAG_RESET; |
|---|
| 2088 | | - pr_err(MPT3SAS_FMT |
|---|
| 2089 | | - "%s: buffer_type(0x%02x) was released due to host reset\n", |
|---|
| 2090 | | - ioc->name, __func__, buffer_type); |
|---|
| 2279 | + ioc_err(ioc, "%s: buffer_type(0x%02x) was released due to host reset\n", |
|---|
| 2280 | + __func__, buffer_type); |
|---|
| 2091 | 2281 | return 0; |
|---|
| 2092 | 2282 | } |
|---|
| 2093 | 2283 | |
|---|
| .. | .. |
|---|
| 2125 | 2315 | return -EFAULT; |
|---|
| 2126 | 2316 | } |
|---|
| 2127 | 2317 | |
|---|
| 2128 | | - dctlprintk(ioc, pr_info(MPT3SAS_FMT "%s\n", ioc->name, |
|---|
| 2129 | | - __func__)); |
|---|
| 2318 | + dctlprintk(ioc, ioc_info(ioc, "%s\n", |
|---|
| 2319 | + __func__)); |
|---|
| 2130 | 2320 | |
|---|
| 2131 | | - buffer_type = karg.unique_id & 0x000000ff; |
|---|
| 2321 | + buffer_type = _ctl_diag_get_bufftype(ioc, karg.unique_id); |
|---|
| 2322 | + if (buffer_type == MPT3_DIAG_UID_NOT_FOUND) { |
|---|
| 2323 | + ioc_err(ioc, "%s: buffer with unique_id(0x%08x) not found\n", |
|---|
| 2324 | + __func__, karg.unique_id); |
|---|
| 2325 | + return -EINVAL; |
|---|
| 2326 | + } |
|---|
| 2327 | + |
|---|
| 2132 | 2328 | if (!_ctl_diag_capability(ioc, buffer_type)) { |
|---|
| 2133 | | - pr_err(MPT3SAS_FMT |
|---|
| 2134 | | - "%s: doesn't have capability for buffer_type(0x%02x)\n", |
|---|
| 2135 | | - ioc->name, __func__, buffer_type); |
|---|
| 2329 | + ioc_err(ioc, "%s: doesn't have capability for buffer_type(0x%02x)\n", |
|---|
| 2330 | + __func__, buffer_type); |
|---|
| 2136 | 2331 | return -EPERM; |
|---|
| 2137 | 2332 | } |
|---|
| 2138 | 2333 | |
|---|
| 2139 | 2334 | if (karg.unique_id != ioc->unique_id[buffer_type]) { |
|---|
| 2140 | | - pr_err(MPT3SAS_FMT |
|---|
| 2141 | | - "%s: unique_id(0x%08x) is not registered\n", |
|---|
| 2142 | | - ioc->name, __func__, karg.unique_id); |
|---|
| 2335 | + ioc_err(ioc, "%s: unique_id(0x%08x) is not registered\n", |
|---|
| 2336 | + __func__, karg.unique_id); |
|---|
| 2143 | 2337 | return -EINVAL; |
|---|
| 2144 | 2338 | } |
|---|
| 2145 | 2339 | |
|---|
| 2146 | 2340 | request_data = ioc->diag_buffer[buffer_type]; |
|---|
| 2147 | 2341 | if (!request_data) { |
|---|
| 2148 | | - pr_err(MPT3SAS_FMT |
|---|
| 2149 | | - "%s: doesn't have buffer for buffer_type(0x%02x)\n", |
|---|
| 2150 | | - ioc->name, __func__, buffer_type); |
|---|
| 2342 | + ioc_err(ioc, "%s: doesn't have buffer for buffer_type(0x%02x)\n", |
|---|
| 2343 | + __func__, buffer_type); |
|---|
| 2151 | 2344 | return -ENOMEM; |
|---|
| 2152 | 2345 | } |
|---|
| 2153 | 2346 | |
|---|
| 2154 | 2347 | request_size = ioc->diag_buffer_sz[buffer_type]; |
|---|
| 2155 | 2348 | |
|---|
| 2156 | 2349 | if ((karg.starting_offset % 4) || (karg.bytes_to_read % 4)) { |
|---|
| 2157 | | - pr_err(MPT3SAS_FMT "%s: either the starting_offset " \ |
|---|
| 2158 | | - "or bytes_to_read are not 4 byte aligned\n", ioc->name, |
|---|
| 2159 | | - __func__); |
|---|
| 2350 | + ioc_err(ioc, "%s: either the starting_offset or bytes_to_read are not 4 byte aligned\n", |
|---|
| 2351 | + __func__); |
|---|
| 2160 | 2352 | return -EINVAL; |
|---|
| 2161 | 2353 | } |
|---|
| 2162 | 2354 | |
|---|
| .. | .. |
|---|
| 2164 | 2356 | return -EINVAL; |
|---|
| 2165 | 2357 | |
|---|
| 2166 | 2358 | diag_data = (void *)(request_data + karg.starting_offset); |
|---|
| 2167 | | - dctlprintk(ioc, pr_info(MPT3SAS_FMT |
|---|
| 2168 | | - "%s: diag_buffer(%p), offset(%d), sz(%d)\n", |
|---|
| 2169 | | - ioc->name, __func__, |
|---|
| 2170 | | - diag_data, karg.starting_offset, karg.bytes_to_read)); |
|---|
| 2359 | + dctlprintk(ioc, |
|---|
| 2360 | + ioc_info(ioc, "%s: diag_buffer(%p), offset(%d), sz(%d)\n", |
|---|
| 2361 | + __func__, diag_data, karg.starting_offset, |
|---|
| 2362 | + karg.bytes_to_read)); |
|---|
| 2171 | 2363 | |
|---|
| 2172 | 2364 | /* Truncate data on requests that are too large */ |
|---|
| 2173 | 2365 | if ((diag_data + karg.bytes_to_read < diag_data) || |
|---|
| .. | .. |
|---|
| 2178 | 2370 | |
|---|
| 2179 | 2371 | if (copy_to_user((void __user *)uarg->diagnostic_data, |
|---|
| 2180 | 2372 | diag_data, copy_size)) { |
|---|
| 2181 | | - pr_err(MPT3SAS_FMT |
|---|
| 2182 | | - "%s: Unable to write mpt_diag_read_buffer_t data @ %p\n", |
|---|
| 2183 | | - ioc->name, __func__, diag_data); |
|---|
| 2373 | + ioc_err(ioc, "%s: Unable to write mpt_diag_read_buffer_t data @ %p\n", |
|---|
| 2374 | + __func__, diag_data); |
|---|
| 2184 | 2375 | return -EFAULT; |
|---|
| 2185 | 2376 | } |
|---|
| 2186 | 2377 | |
|---|
| 2187 | 2378 | if ((karg.flags & MPT3_FLAGS_REREGISTER) == 0) |
|---|
| 2188 | 2379 | return 0; |
|---|
| 2189 | 2380 | |
|---|
| 2190 | | - dctlprintk(ioc, pr_info(MPT3SAS_FMT |
|---|
| 2191 | | - "%s: Reregister buffer_type(0x%02x)\n", |
|---|
| 2192 | | - ioc->name, __func__, buffer_type)); |
|---|
| 2381 | + dctlprintk(ioc, |
|---|
| 2382 | + ioc_info(ioc, "%s: Reregister buffer_type(0x%02x)\n", |
|---|
| 2383 | + __func__, buffer_type)); |
|---|
| 2193 | 2384 | if ((ioc->diag_buffer_status[buffer_type] & |
|---|
| 2194 | 2385 | MPT3_DIAG_BUFFER_IS_RELEASED) == 0) { |
|---|
| 2195 | | - dctlprintk(ioc, pr_info(MPT3SAS_FMT |
|---|
| 2196 | | - "%s: buffer_type(0x%02x) is still registered\n", |
|---|
| 2197 | | - ioc->name, __func__, buffer_type)); |
|---|
| 2386 | + dctlprintk(ioc, |
|---|
| 2387 | + ioc_info(ioc, "%s: buffer_type(0x%02x) is still registered\n", |
|---|
| 2388 | + __func__, buffer_type)); |
|---|
| 2198 | 2389 | return 0; |
|---|
| 2199 | 2390 | } |
|---|
| 2200 | 2391 | /* Get a free request frame and save the message context. |
|---|
| 2201 | 2392 | */ |
|---|
| 2202 | 2393 | |
|---|
| 2203 | 2394 | if (ioc->ctl_cmds.status != MPT3_CMD_NOT_USED) { |
|---|
| 2204 | | - pr_err(MPT3SAS_FMT "%s: ctl_cmd in use\n", |
|---|
| 2205 | | - ioc->name, __func__); |
|---|
| 2395 | + ioc_err(ioc, "%s: ctl_cmd in use\n", __func__); |
|---|
| 2206 | 2396 | rc = -EAGAIN; |
|---|
| 2207 | 2397 | goto out; |
|---|
| 2208 | 2398 | } |
|---|
| 2209 | 2399 | |
|---|
| 2210 | 2400 | smid = mpt3sas_base_get_smid(ioc, ioc->ctl_cb_idx); |
|---|
| 2211 | 2401 | if (!smid) { |
|---|
| 2212 | | - pr_err(MPT3SAS_FMT "%s: failed obtaining a smid\n", |
|---|
| 2213 | | - ioc->name, __func__); |
|---|
| 2402 | + ioc_err(ioc, "%s: failed obtaining a smid\n", __func__); |
|---|
| 2214 | 2403 | rc = -EAGAIN; |
|---|
| 2215 | 2404 | goto out; |
|---|
| 2216 | 2405 | } |
|---|
| .. | .. |
|---|
| 2234 | 2423 | mpi_request->VP_ID = 0; |
|---|
| 2235 | 2424 | |
|---|
| 2236 | 2425 | init_completion(&ioc->ctl_cmds.done); |
|---|
| 2237 | | - mpt3sas_base_put_smid_default(ioc, smid); |
|---|
| 2426 | + ioc->put_smid_default(ioc, smid); |
|---|
| 2238 | 2427 | wait_for_completion_timeout(&ioc->ctl_cmds.done, |
|---|
| 2239 | 2428 | MPT3_IOCTL_DEFAULT_TIMEOUT*HZ); |
|---|
| 2240 | 2429 | |
|---|
| 2241 | 2430 | if (!(ioc->ctl_cmds.status & MPT3_CMD_COMPLETE)) { |
|---|
| 2242 | | - issue_reset = |
|---|
| 2243 | | - mpt3sas_base_check_cmd_timeout(ioc, |
|---|
| 2244 | | - ioc->ctl_cmds.status, mpi_request, |
|---|
| 2245 | | - sizeof(Mpi2DiagBufferPostRequest_t)/4); |
|---|
| 2431 | + mpt3sas_check_cmd_timeout(ioc, |
|---|
| 2432 | + ioc->ctl_cmds.status, mpi_request, |
|---|
| 2433 | + sizeof(Mpi2DiagBufferPostRequest_t)/4, issue_reset); |
|---|
| 2246 | 2434 | goto issue_host_reset; |
|---|
| 2247 | 2435 | } |
|---|
| 2248 | 2436 | |
|---|
| 2249 | 2437 | /* process the completed Reply Message Frame */ |
|---|
| 2250 | 2438 | if ((ioc->ctl_cmds.status & MPT3_CMD_REPLY_VALID) == 0) { |
|---|
| 2251 | | - pr_err(MPT3SAS_FMT "%s: no reply message\n", |
|---|
| 2252 | | - ioc->name, __func__); |
|---|
| 2439 | + ioc_err(ioc, "%s: no reply message\n", __func__); |
|---|
| 2253 | 2440 | rc = -EFAULT; |
|---|
| 2254 | 2441 | goto out; |
|---|
| 2255 | 2442 | } |
|---|
| .. | .. |
|---|
| 2260 | 2447 | if (ioc_status == MPI2_IOCSTATUS_SUCCESS) { |
|---|
| 2261 | 2448 | ioc->diag_buffer_status[buffer_type] |= |
|---|
| 2262 | 2449 | MPT3_DIAG_BUFFER_IS_REGISTERED; |
|---|
| 2263 | | - dctlprintk(ioc, pr_info(MPT3SAS_FMT "%s: success\n", |
|---|
| 2264 | | - ioc->name, __func__)); |
|---|
| 2450 | + ioc->diag_buffer_status[buffer_type] &= |
|---|
| 2451 | + ~MPT3_DIAG_BUFFER_IS_RELEASED; |
|---|
| 2452 | + dctlprintk(ioc, ioc_info(ioc, "%s: success\n", __func__)); |
|---|
| 2265 | 2453 | } else { |
|---|
| 2266 | | - pr_info(MPT3SAS_FMT |
|---|
| 2267 | | - "%s: ioc_status(0x%04x) log_info(0x%08x)\n", |
|---|
| 2268 | | - ioc->name, __func__, |
|---|
| 2269 | | - ioc_status, le32_to_cpu(mpi_reply->IOCLogInfo)); |
|---|
| 2454 | + ioc_info(ioc, "%s: ioc_status(0x%04x) log_info(0x%08x)\n", |
|---|
| 2455 | + __func__, ioc_status, |
|---|
| 2456 | + le32_to_cpu(mpi_reply->IOCLogInfo)); |
|---|
| 2270 | 2457 | rc = -EFAULT; |
|---|
| 2271 | 2458 | } |
|---|
| 2272 | 2459 | |
|---|
| .. | .. |
|---|
| 2405 | 2592 | break; |
|---|
| 2406 | 2593 | } |
|---|
| 2407 | 2594 | |
|---|
| 2595 | + if (karg.hdr.ioc_number != ioctl_header.ioc_number) { |
|---|
| 2596 | + ret = -EINVAL; |
|---|
| 2597 | + break; |
|---|
| 2598 | + } |
|---|
| 2408 | 2599 | if (_IOC_SIZE(cmd) == sizeof(struct mpt3_ioctl_command)) { |
|---|
| 2409 | 2600 | uarg = arg; |
|---|
| 2410 | 2601 | ret = _ctl_do_mpt_command(ioc, karg, &uarg->mf); |
|---|
| .. | .. |
|---|
| 2451 | 2642 | ret = _ctl_diag_read_buffer(ioc, arg); |
|---|
| 2452 | 2643 | break; |
|---|
| 2453 | 2644 | default: |
|---|
| 2454 | | - dctlprintk(ioc, pr_info(MPT3SAS_FMT |
|---|
| 2455 | | - "unsupported ioctl opcode(0x%08x)\n", ioc->name, cmd)); |
|---|
| 2645 | + dctlprintk(ioc, |
|---|
| 2646 | + ioc_info(ioc, "unsupported ioctl opcode(0x%08x)\n", |
|---|
| 2647 | + cmd)); |
|---|
| 2456 | 2648 | break; |
|---|
| 2457 | 2649 | } |
|---|
| 2458 | 2650 | |
|---|
| .. | .. |
|---|
| 2538 | 2730 | |
|---|
| 2539 | 2731 | /* scsi host attributes */ |
|---|
| 2540 | 2732 | /** |
|---|
| 2541 | | - * _ctl_version_fw_show - firmware version |
|---|
| 2733 | + * version_fw_show - firmware version |
|---|
| 2542 | 2734 | * @cdev: pointer to embedded class device |
|---|
| 2543 | 2735 | * @attr: ? |
|---|
| 2544 | 2736 | * @buf: the buffer returned |
|---|
| .. | .. |
|---|
| 2546 | 2738 | * A sysfs 'read-only' shost attribute. |
|---|
| 2547 | 2739 | */ |
|---|
| 2548 | 2740 | static ssize_t |
|---|
| 2549 | | -_ctl_version_fw_show(struct device *cdev, struct device_attribute *attr, |
|---|
| 2741 | +version_fw_show(struct device *cdev, struct device_attribute *attr, |
|---|
| 2550 | 2742 | char *buf) |
|---|
| 2551 | 2743 | { |
|---|
| 2552 | 2744 | struct Scsi_Host *shost = class_to_shost(cdev); |
|---|
| .. | .. |
|---|
| 2558 | 2750 | (ioc->facts.FWVersion.Word & 0x0000FF00) >> 8, |
|---|
| 2559 | 2751 | ioc->facts.FWVersion.Word & 0x000000FF); |
|---|
| 2560 | 2752 | } |
|---|
| 2561 | | -static DEVICE_ATTR(version_fw, S_IRUGO, _ctl_version_fw_show, NULL); |
|---|
| 2753 | +static DEVICE_ATTR_RO(version_fw); |
|---|
| 2562 | 2754 | |
|---|
| 2563 | 2755 | /** |
|---|
| 2564 | | - * _ctl_version_bios_show - bios version |
|---|
| 2756 | + * version_bios_show - bios version |
|---|
| 2565 | 2757 | * @cdev: pointer to embedded class device |
|---|
| 2566 | 2758 | * @attr: ? |
|---|
| 2567 | 2759 | * @buf: the buffer returned |
|---|
| .. | .. |
|---|
| 2569 | 2761 | * A sysfs 'read-only' shost attribute. |
|---|
| 2570 | 2762 | */ |
|---|
| 2571 | 2763 | static ssize_t |
|---|
| 2572 | | -_ctl_version_bios_show(struct device *cdev, struct device_attribute *attr, |
|---|
| 2764 | +version_bios_show(struct device *cdev, struct device_attribute *attr, |
|---|
| 2573 | 2765 | char *buf) |
|---|
| 2574 | 2766 | { |
|---|
| 2575 | 2767 | struct Scsi_Host *shost = class_to_shost(cdev); |
|---|
| .. | .. |
|---|
| 2583 | 2775 | (version & 0x0000FF00) >> 8, |
|---|
| 2584 | 2776 | version & 0x000000FF); |
|---|
| 2585 | 2777 | } |
|---|
| 2586 | | -static DEVICE_ATTR(version_bios, S_IRUGO, _ctl_version_bios_show, NULL); |
|---|
| 2778 | +static DEVICE_ATTR_RO(version_bios); |
|---|
| 2587 | 2779 | |
|---|
| 2588 | 2780 | /** |
|---|
| 2589 | | - * _ctl_version_mpi_show - MPI (message passing interface) version |
|---|
| 2781 | + * version_mpi_show - MPI (message passing interface) version |
|---|
| 2590 | 2782 | * @cdev: pointer to embedded class device |
|---|
| 2591 | 2783 | * @attr: ? |
|---|
| 2592 | 2784 | * @buf: the buffer returned |
|---|
| .. | .. |
|---|
| 2594 | 2786 | * A sysfs 'read-only' shost attribute. |
|---|
| 2595 | 2787 | */ |
|---|
| 2596 | 2788 | static ssize_t |
|---|
| 2597 | | -_ctl_version_mpi_show(struct device *cdev, struct device_attribute *attr, |
|---|
| 2789 | +version_mpi_show(struct device *cdev, struct device_attribute *attr, |
|---|
| 2598 | 2790 | char *buf) |
|---|
| 2599 | 2791 | { |
|---|
| 2600 | 2792 | struct Scsi_Host *shost = class_to_shost(cdev); |
|---|
| .. | .. |
|---|
| 2603 | 2795 | return snprintf(buf, PAGE_SIZE, "%03x.%02x\n", |
|---|
| 2604 | 2796 | ioc->facts.MsgVersion, ioc->facts.HeaderVersion >> 8); |
|---|
| 2605 | 2797 | } |
|---|
| 2606 | | -static DEVICE_ATTR(version_mpi, S_IRUGO, _ctl_version_mpi_show, NULL); |
|---|
| 2798 | +static DEVICE_ATTR_RO(version_mpi); |
|---|
| 2607 | 2799 | |
|---|
| 2608 | 2800 | /** |
|---|
| 2609 | | - * _ctl_version_product_show - product name |
|---|
| 2801 | + * version_product_show - product name |
|---|
| 2610 | 2802 | * @cdev: pointer to embedded class device |
|---|
| 2611 | 2803 | * @attr: ? |
|---|
| 2612 | 2804 | * @buf: the buffer returned |
|---|
| .. | .. |
|---|
| 2614 | 2806 | * A sysfs 'read-only' shost attribute. |
|---|
| 2615 | 2807 | */ |
|---|
| 2616 | 2808 | static ssize_t |
|---|
| 2617 | | -_ctl_version_product_show(struct device *cdev, struct device_attribute *attr, |
|---|
| 2809 | +version_product_show(struct device *cdev, struct device_attribute *attr, |
|---|
| 2618 | 2810 | char *buf) |
|---|
| 2619 | 2811 | { |
|---|
| 2620 | 2812 | struct Scsi_Host *shost = class_to_shost(cdev); |
|---|
| .. | .. |
|---|
| 2622 | 2814 | |
|---|
| 2623 | 2815 | return snprintf(buf, 16, "%s\n", ioc->manu_pg0.ChipName); |
|---|
| 2624 | 2816 | } |
|---|
| 2625 | | -static DEVICE_ATTR(version_product, S_IRUGO, _ctl_version_product_show, NULL); |
|---|
| 2817 | +static DEVICE_ATTR_RO(version_product); |
|---|
| 2626 | 2818 | |
|---|
| 2627 | 2819 | /** |
|---|
| 2628 | | - * _ctl_version_nvdata_persistent_show - ndvata persistent version |
|---|
| 2820 | + * version_nvdata_persistent_show - ndvata persistent version |
|---|
| 2629 | 2821 | * @cdev: pointer to embedded class device |
|---|
| 2630 | 2822 | * @attr: ? |
|---|
| 2631 | 2823 | * @buf: the buffer returned |
|---|
| .. | .. |
|---|
| 2633 | 2825 | * A sysfs 'read-only' shost attribute. |
|---|
| 2634 | 2826 | */ |
|---|
| 2635 | 2827 | static ssize_t |
|---|
| 2636 | | -_ctl_version_nvdata_persistent_show(struct device *cdev, |
|---|
| 2828 | +version_nvdata_persistent_show(struct device *cdev, |
|---|
| 2637 | 2829 | struct device_attribute *attr, char *buf) |
|---|
| 2638 | 2830 | { |
|---|
| 2639 | 2831 | struct Scsi_Host *shost = class_to_shost(cdev); |
|---|
| .. | .. |
|---|
| 2642 | 2834 | return snprintf(buf, PAGE_SIZE, "%08xh\n", |
|---|
| 2643 | 2835 | le32_to_cpu(ioc->iounit_pg0.NvdataVersionPersistent.Word)); |
|---|
| 2644 | 2836 | } |
|---|
| 2645 | | -static DEVICE_ATTR(version_nvdata_persistent, S_IRUGO, |
|---|
| 2646 | | - _ctl_version_nvdata_persistent_show, NULL); |
|---|
| 2837 | +static DEVICE_ATTR_RO(version_nvdata_persistent); |
|---|
| 2647 | 2838 | |
|---|
| 2648 | 2839 | /** |
|---|
| 2649 | | - * _ctl_version_nvdata_default_show - nvdata default version |
|---|
| 2840 | + * version_nvdata_default_show - nvdata default version |
|---|
| 2650 | 2841 | * @cdev: pointer to embedded class device |
|---|
| 2651 | 2842 | * @attr: ? |
|---|
| 2652 | 2843 | * @buf: the buffer returned |
|---|
| .. | .. |
|---|
| 2654 | 2845 | * A sysfs 'read-only' shost attribute. |
|---|
| 2655 | 2846 | */ |
|---|
| 2656 | 2847 | static ssize_t |
|---|
| 2657 | | -_ctl_version_nvdata_default_show(struct device *cdev, struct device_attribute |
|---|
| 2848 | +version_nvdata_default_show(struct device *cdev, struct device_attribute |
|---|
| 2658 | 2849 | *attr, char *buf) |
|---|
| 2659 | 2850 | { |
|---|
| 2660 | 2851 | struct Scsi_Host *shost = class_to_shost(cdev); |
|---|
| .. | .. |
|---|
| 2663 | 2854 | return snprintf(buf, PAGE_SIZE, "%08xh\n", |
|---|
| 2664 | 2855 | le32_to_cpu(ioc->iounit_pg0.NvdataVersionDefault.Word)); |
|---|
| 2665 | 2856 | } |
|---|
| 2666 | | -static DEVICE_ATTR(version_nvdata_default, S_IRUGO, |
|---|
| 2667 | | - _ctl_version_nvdata_default_show, NULL); |
|---|
| 2857 | +static DEVICE_ATTR_RO(version_nvdata_default); |
|---|
| 2668 | 2858 | |
|---|
| 2669 | 2859 | /** |
|---|
| 2670 | | - * _ctl_board_name_show - board name |
|---|
| 2860 | + * board_name_show - board name |
|---|
| 2671 | 2861 | * @cdev: pointer to embedded class device |
|---|
| 2672 | 2862 | * @attr: ? |
|---|
| 2673 | 2863 | * @buf: the buffer returned |
|---|
| .. | .. |
|---|
| 2675 | 2865 | * A sysfs 'read-only' shost attribute. |
|---|
| 2676 | 2866 | */ |
|---|
| 2677 | 2867 | static ssize_t |
|---|
| 2678 | | -_ctl_board_name_show(struct device *cdev, struct device_attribute *attr, |
|---|
| 2868 | +board_name_show(struct device *cdev, struct device_attribute *attr, |
|---|
| 2679 | 2869 | char *buf) |
|---|
| 2680 | 2870 | { |
|---|
| 2681 | 2871 | struct Scsi_Host *shost = class_to_shost(cdev); |
|---|
| .. | .. |
|---|
| 2683 | 2873 | |
|---|
| 2684 | 2874 | return snprintf(buf, 16, "%s\n", ioc->manu_pg0.BoardName); |
|---|
| 2685 | 2875 | } |
|---|
| 2686 | | -static DEVICE_ATTR(board_name, S_IRUGO, _ctl_board_name_show, NULL); |
|---|
| 2876 | +static DEVICE_ATTR_RO(board_name); |
|---|
| 2687 | 2877 | |
|---|
| 2688 | 2878 | /** |
|---|
| 2689 | | - * _ctl_board_assembly_show - board assembly name |
|---|
| 2879 | + * board_assembly_show - board assembly name |
|---|
| 2690 | 2880 | * @cdev: pointer to embedded class device |
|---|
| 2691 | 2881 | * @attr: ? |
|---|
| 2692 | 2882 | * @buf: the buffer returned |
|---|
| .. | .. |
|---|
| 2694 | 2884 | * A sysfs 'read-only' shost attribute. |
|---|
| 2695 | 2885 | */ |
|---|
| 2696 | 2886 | static ssize_t |
|---|
| 2697 | | -_ctl_board_assembly_show(struct device *cdev, struct device_attribute *attr, |
|---|
| 2887 | +board_assembly_show(struct device *cdev, struct device_attribute *attr, |
|---|
| 2698 | 2888 | char *buf) |
|---|
| 2699 | 2889 | { |
|---|
| 2700 | 2890 | struct Scsi_Host *shost = class_to_shost(cdev); |
|---|
| .. | .. |
|---|
| 2702 | 2892 | |
|---|
| 2703 | 2893 | return snprintf(buf, 16, "%s\n", ioc->manu_pg0.BoardAssembly); |
|---|
| 2704 | 2894 | } |
|---|
| 2705 | | -static DEVICE_ATTR(board_assembly, S_IRUGO, _ctl_board_assembly_show, NULL); |
|---|
| 2895 | +static DEVICE_ATTR_RO(board_assembly); |
|---|
| 2706 | 2896 | |
|---|
| 2707 | 2897 | /** |
|---|
| 2708 | | - * _ctl_board_tracer_show - board tracer number |
|---|
| 2898 | + * board_tracer_show - board tracer number |
|---|
| 2709 | 2899 | * @cdev: pointer to embedded class device |
|---|
| 2710 | 2900 | * @attr: ? |
|---|
| 2711 | 2901 | * @buf: the buffer returned |
|---|
| .. | .. |
|---|
| 2713 | 2903 | * A sysfs 'read-only' shost attribute. |
|---|
| 2714 | 2904 | */ |
|---|
| 2715 | 2905 | static ssize_t |
|---|
| 2716 | | -_ctl_board_tracer_show(struct device *cdev, struct device_attribute *attr, |
|---|
| 2906 | +board_tracer_show(struct device *cdev, struct device_attribute *attr, |
|---|
| 2717 | 2907 | char *buf) |
|---|
| 2718 | 2908 | { |
|---|
| 2719 | 2909 | struct Scsi_Host *shost = class_to_shost(cdev); |
|---|
| .. | .. |
|---|
| 2721 | 2911 | |
|---|
| 2722 | 2912 | return snprintf(buf, 16, "%s\n", ioc->manu_pg0.BoardTracerNumber); |
|---|
| 2723 | 2913 | } |
|---|
| 2724 | | -static DEVICE_ATTR(board_tracer, S_IRUGO, _ctl_board_tracer_show, NULL); |
|---|
| 2914 | +static DEVICE_ATTR_RO(board_tracer); |
|---|
| 2725 | 2915 | |
|---|
| 2726 | 2916 | /** |
|---|
| 2727 | | - * _ctl_io_delay_show - io missing delay |
|---|
| 2917 | + * io_delay_show - io missing delay |
|---|
| 2728 | 2918 | * @cdev: pointer to embedded class device |
|---|
| 2729 | 2919 | * @attr: ? |
|---|
| 2730 | 2920 | * @buf: the buffer returned |
|---|
| .. | .. |
|---|
| 2735 | 2925 | * A sysfs 'read-only' shost attribute. |
|---|
| 2736 | 2926 | */ |
|---|
| 2737 | 2927 | static ssize_t |
|---|
| 2738 | | -_ctl_io_delay_show(struct device *cdev, struct device_attribute *attr, |
|---|
| 2928 | +io_delay_show(struct device *cdev, struct device_attribute *attr, |
|---|
| 2739 | 2929 | char *buf) |
|---|
| 2740 | 2930 | { |
|---|
| 2741 | 2931 | struct Scsi_Host *shost = class_to_shost(cdev); |
|---|
| .. | .. |
|---|
| 2743 | 2933 | |
|---|
| 2744 | 2934 | return snprintf(buf, PAGE_SIZE, "%02d\n", ioc->io_missing_delay); |
|---|
| 2745 | 2935 | } |
|---|
| 2746 | | -static DEVICE_ATTR(io_delay, S_IRUGO, _ctl_io_delay_show, NULL); |
|---|
| 2936 | +static DEVICE_ATTR_RO(io_delay); |
|---|
| 2747 | 2937 | |
|---|
| 2748 | 2938 | /** |
|---|
| 2749 | | - * _ctl_device_delay_show - device missing delay |
|---|
| 2939 | + * device_delay_show - device missing delay |
|---|
| 2750 | 2940 | * @cdev: pointer to embedded class device |
|---|
| 2751 | 2941 | * @attr: ? |
|---|
| 2752 | 2942 | * @buf: the buffer returned |
|---|
| .. | .. |
|---|
| 2757 | 2947 | * A sysfs 'read-only' shost attribute. |
|---|
| 2758 | 2948 | */ |
|---|
| 2759 | 2949 | static ssize_t |
|---|
| 2760 | | -_ctl_device_delay_show(struct device *cdev, struct device_attribute *attr, |
|---|
| 2950 | +device_delay_show(struct device *cdev, struct device_attribute *attr, |
|---|
| 2761 | 2951 | char *buf) |
|---|
| 2762 | 2952 | { |
|---|
| 2763 | 2953 | struct Scsi_Host *shost = class_to_shost(cdev); |
|---|
| .. | .. |
|---|
| 2765 | 2955 | |
|---|
| 2766 | 2956 | return snprintf(buf, PAGE_SIZE, "%02d\n", ioc->device_missing_delay); |
|---|
| 2767 | 2957 | } |
|---|
| 2768 | | -static DEVICE_ATTR(device_delay, S_IRUGO, _ctl_device_delay_show, NULL); |
|---|
| 2958 | +static DEVICE_ATTR_RO(device_delay); |
|---|
| 2769 | 2959 | |
|---|
| 2770 | 2960 | /** |
|---|
| 2771 | | - * _ctl_fw_queue_depth_show - global credits |
|---|
| 2961 | + * fw_queue_depth_show - global credits |
|---|
| 2772 | 2962 | * @cdev: pointer to embedded class device |
|---|
| 2773 | 2963 | * @attr: ? |
|---|
| 2774 | 2964 | * @buf: the buffer returned |
|---|
| .. | .. |
|---|
| 2778 | 2968 | * A sysfs 'read-only' shost attribute. |
|---|
| 2779 | 2969 | */ |
|---|
| 2780 | 2970 | static ssize_t |
|---|
| 2781 | | -_ctl_fw_queue_depth_show(struct device *cdev, struct device_attribute *attr, |
|---|
| 2971 | +fw_queue_depth_show(struct device *cdev, struct device_attribute *attr, |
|---|
| 2782 | 2972 | char *buf) |
|---|
| 2783 | 2973 | { |
|---|
| 2784 | 2974 | struct Scsi_Host *shost = class_to_shost(cdev); |
|---|
| .. | .. |
|---|
| 2786 | 2976 | |
|---|
| 2787 | 2977 | return snprintf(buf, PAGE_SIZE, "%02d\n", ioc->facts.RequestCredit); |
|---|
| 2788 | 2978 | } |
|---|
| 2789 | | -static DEVICE_ATTR(fw_queue_depth, S_IRUGO, _ctl_fw_queue_depth_show, NULL); |
|---|
| 2979 | +static DEVICE_ATTR_RO(fw_queue_depth); |
|---|
| 2790 | 2980 | |
|---|
| 2791 | 2981 | /** |
|---|
| 2792 | | - * _ctl_sas_address_show - sas address |
|---|
| 2982 | + * sas_address_show - sas address |
|---|
| 2793 | 2983 | * @cdev: pointer to embedded class device |
|---|
| 2794 | 2984 | * @attr: ? |
|---|
| 2795 | 2985 | * @buf: the buffer returned |
|---|
| .. | .. |
|---|
| 2799 | 2989 | * A sysfs 'read-only' shost attribute. |
|---|
| 2800 | 2990 | */ |
|---|
| 2801 | 2991 | static ssize_t |
|---|
| 2802 | | -_ctl_host_sas_address_show(struct device *cdev, struct device_attribute *attr, |
|---|
| 2992 | +host_sas_address_show(struct device *cdev, struct device_attribute *attr, |
|---|
| 2803 | 2993 | char *buf) |
|---|
| 2804 | 2994 | |
|---|
| 2805 | 2995 | { |
|---|
| .. | .. |
|---|
| 2809 | 2999 | return snprintf(buf, PAGE_SIZE, "0x%016llx\n", |
|---|
| 2810 | 3000 | (unsigned long long)ioc->sas_hba.sas_address); |
|---|
| 2811 | 3001 | } |
|---|
| 2812 | | -static DEVICE_ATTR(host_sas_address, S_IRUGO, |
|---|
| 2813 | | - _ctl_host_sas_address_show, NULL); |
|---|
| 3002 | +static DEVICE_ATTR_RO(host_sas_address); |
|---|
| 2814 | 3003 | |
|---|
| 2815 | 3004 | /** |
|---|
| 2816 | | - * _ctl_logging_level_show - logging level |
|---|
| 3005 | + * logging_level_show - logging level |
|---|
| 2817 | 3006 | * @cdev: pointer to embedded class device |
|---|
| 2818 | 3007 | * @attr: ? |
|---|
| 2819 | 3008 | * @buf: the buffer returned |
|---|
| .. | .. |
|---|
| 2821 | 3010 | * A sysfs 'read/write' shost attribute. |
|---|
| 2822 | 3011 | */ |
|---|
| 2823 | 3012 | static ssize_t |
|---|
| 2824 | | -_ctl_logging_level_show(struct device *cdev, struct device_attribute *attr, |
|---|
| 3013 | +logging_level_show(struct device *cdev, struct device_attribute *attr, |
|---|
| 2825 | 3014 | char *buf) |
|---|
| 2826 | 3015 | { |
|---|
| 2827 | 3016 | struct Scsi_Host *shost = class_to_shost(cdev); |
|---|
| .. | .. |
|---|
| 2830 | 3019 | return snprintf(buf, PAGE_SIZE, "%08xh\n", ioc->logging_level); |
|---|
| 2831 | 3020 | } |
|---|
| 2832 | 3021 | static ssize_t |
|---|
| 2833 | | -_ctl_logging_level_store(struct device *cdev, struct device_attribute *attr, |
|---|
| 3022 | +logging_level_store(struct device *cdev, struct device_attribute *attr, |
|---|
| 2834 | 3023 | const char *buf, size_t count) |
|---|
| 2835 | 3024 | { |
|---|
| 2836 | 3025 | struct Scsi_Host *shost = class_to_shost(cdev); |
|---|
| .. | .. |
|---|
| 2841 | 3030 | return -EINVAL; |
|---|
| 2842 | 3031 | |
|---|
| 2843 | 3032 | ioc->logging_level = val; |
|---|
| 2844 | | - pr_info(MPT3SAS_FMT "logging_level=%08xh\n", ioc->name, |
|---|
| 2845 | | - ioc->logging_level); |
|---|
| 3033 | + ioc_info(ioc, "logging_level=%08xh\n", |
|---|
| 3034 | + ioc->logging_level); |
|---|
| 2846 | 3035 | return strlen(buf); |
|---|
| 2847 | 3036 | } |
|---|
| 2848 | | -static DEVICE_ATTR(logging_level, S_IRUGO | S_IWUSR, _ctl_logging_level_show, |
|---|
| 2849 | | - _ctl_logging_level_store); |
|---|
| 3037 | +static DEVICE_ATTR_RW(logging_level); |
|---|
| 2850 | 3038 | |
|---|
| 2851 | 3039 | /** |
|---|
| 2852 | | - * _ctl_fwfault_debug_show - show/store fwfault_debug |
|---|
| 3040 | + * fwfault_debug_show - show/store fwfault_debug |
|---|
| 2853 | 3041 | * @cdev: pointer to embedded class device |
|---|
| 2854 | 3042 | * @attr: ? |
|---|
| 2855 | 3043 | * @buf: the buffer returned |
|---|
| .. | .. |
|---|
| 2858 | 3046 | * A sysfs 'read/write' shost attribute. |
|---|
| 2859 | 3047 | */ |
|---|
| 2860 | 3048 | static ssize_t |
|---|
| 2861 | | -_ctl_fwfault_debug_show(struct device *cdev, struct device_attribute *attr, |
|---|
| 3049 | +fwfault_debug_show(struct device *cdev, struct device_attribute *attr, |
|---|
| 2862 | 3050 | char *buf) |
|---|
| 2863 | 3051 | { |
|---|
| 2864 | 3052 | struct Scsi_Host *shost = class_to_shost(cdev); |
|---|
| .. | .. |
|---|
| 2867 | 3055 | return snprintf(buf, PAGE_SIZE, "%d\n", ioc->fwfault_debug); |
|---|
| 2868 | 3056 | } |
|---|
| 2869 | 3057 | static ssize_t |
|---|
| 2870 | | -_ctl_fwfault_debug_store(struct device *cdev, struct device_attribute *attr, |
|---|
| 3058 | +fwfault_debug_store(struct device *cdev, struct device_attribute *attr, |
|---|
| 2871 | 3059 | const char *buf, size_t count) |
|---|
| 2872 | 3060 | { |
|---|
| 2873 | 3061 | struct Scsi_Host *shost = class_to_shost(cdev); |
|---|
| .. | .. |
|---|
| 2878 | 3066 | return -EINVAL; |
|---|
| 2879 | 3067 | |
|---|
| 2880 | 3068 | ioc->fwfault_debug = val; |
|---|
| 2881 | | - pr_info(MPT3SAS_FMT "fwfault_debug=%d\n", ioc->name, |
|---|
| 2882 | | - ioc->fwfault_debug); |
|---|
| 3069 | + ioc_info(ioc, "fwfault_debug=%d\n", |
|---|
| 3070 | + ioc->fwfault_debug); |
|---|
| 2883 | 3071 | return strlen(buf); |
|---|
| 2884 | 3072 | } |
|---|
| 2885 | | -static DEVICE_ATTR(fwfault_debug, S_IRUGO | S_IWUSR, |
|---|
| 2886 | | - _ctl_fwfault_debug_show, _ctl_fwfault_debug_store); |
|---|
| 3073 | +static DEVICE_ATTR_RW(fwfault_debug); |
|---|
| 2887 | 3074 | |
|---|
| 2888 | 3075 | /** |
|---|
| 2889 | | - * _ctl_ioc_reset_count_show - ioc reset count |
|---|
| 3076 | + * ioc_reset_count_show - ioc reset count |
|---|
| 2890 | 3077 | * @cdev: pointer to embedded class device |
|---|
| 2891 | 3078 | * @attr: ? |
|---|
| 2892 | 3079 | * @buf: the buffer returned |
|---|
| .. | .. |
|---|
| 2896 | 3083 | * A sysfs 'read-only' shost attribute. |
|---|
| 2897 | 3084 | */ |
|---|
| 2898 | 3085 | static ssize_t |
|---|
| 2899 | | -_ctl_ioc_reset_count_show(struct device *cdev, struct device_attribute *attr, |
|---|
| 3086 | +ioc_reset_count_show(struct device *cdev, struct device_attribute *attr, |
|---|
| 2900 | 3087 | char *buf) |
|---|
| 2901 | 3088 | { |
|---|
| 2902 | 3089 | struct Scsi_Host *shost = class_to_shost(cdev); |
|---|
| .. | .. |
|---|
| 2904 | 3091 | |
|---|
| 2905 | 3092 | return snprintf(buf, PAGE_SIZE, "%d\n", ioc->ioc_reset_count); |
|---|
| 2906 | 3093 | } |
|---|
| 2907 | | -static DEVICE_ATTR(ioc_reset_count, S_IRUGO, _ctl_ioc_reset_count_show, NULL); |
|---|
| 3094 | +static DEVICE_ATTR_RO(ioc_reset_count); |
|---|
| 2908 | 3095 | |
|---|
| 2909 | 3096 | /** |
|---|
| 2910 | | - * _ctl_ioc_reply_queue_count_show - number of reply queues |
|---|
| 3097 | + * reply_queue_count_show - number of reply queues |
|---|
| 2911 | 3098 | * @cdev: pointer to embedded class device |
|---|
| 2912 | 3099 | * @attr: ? |
|---|
| 2913 | 3100 | * @buf: the buffer returned |
|---|
| .. | .. |
|---|
| 2917 | 3104 | * A sysfs 'read-only' shost attribute. |
|---|
| 2918 | 3105 | */ |
|---|
| 2919 | 3106 | static ssize_t |
|---|
| 2920 | | -_ctl_ioc_reply_queue_count_show(struct device *cdev, |
|---|
| 3107 | +reply_queue_count_show(struct device *cdev, |
|---|
| 2921 | 3108 | struct device_attribute *attr, char *buf) |
|---|
| 2922 | 3109 | { |
|---|
| 2923 | 3110 | u8 reply_queue_count; |
|---|
| .. | .. |
|---|
| 2932 | 3119 | |
|---|
| 2933 | 3120 | return snprintf(buf, PAGE_SIZE, "%d\n", reply_queue_count); |
|---|
| 2934 | 3121 | } |
|---|
| 2935 | | -static DEVICE_ATTR(reply_queue_count, S_IRUGO, _ctl_ioc_reply_queue_count_show, |
|---|
| 2936 | | - NULL); |
|---|
| 3122 | +static DEVICE_ATTR_RO(reply_queue_count); |
|---|
| 2937 | 3123 | |
|---|
| 2938 | 3124 | /** |
|---|
| 2939 | | - * _ctl_BRM_status_show - Backup Rail Monitor Status |
|---|
| 3125 | + * BRM_status_show - Backup Rail Monitor Status |
|---|
| 2940 | 3126 | * @cdev: pointer to embedded class device |
|---|
| 2941 | 3127 | * @attr: ? |
|---|
| 2942 | 3128 | * @buf: the buffer returned |
|---|
| .. | .. |
|---|
| 2946 | 3132 | * A sysfs 'read-only' shost attribute. |
|---|
| 2947 | 3133 | */ |
|---|
| 2948 | 3134 | static ssize_t |
|---|
| 2949 | | -_ctl_BRM_status_show(struct device *cdev, struct device_attribute *attr, |
|---|
| 3135 | +BRM_status_show(struct device *cdev, struct device_attribute *attr, |
|---|
| 2950 | 3136 | char *buf) |
|---|
| 2951 | 3137 | { |
|---|
| 2952 | 3138 | struct Scsi_Host *shost = class_to_shost(cdev); |
|---|
| .. | .. |
|---|
| 2959 | 3145 | ssize_t rc = 0; |
|---|
| 2960 | 3146 | |
|---|
| 2961 | 3147 | if (!ioc->is_warpdrive) { |
|---|
| 2962 | | - pr_err(MPT3SAS_FMT "%s: BRM attribute is only for" |
|---|
| 2963 | | - " warpdrive\n", ioc->name, __func__); |
|---|
| 2964 | | - goto out; |
|---|
| 3148 | + ioc_err(ioc, "%s: BRM attribute is only for warpdrive\n", |
|---|
| 3149 | + __func__); |
|---|
| 3150 | + return 0; |
|---|
| 2965 | 3151 | } |
|---|
| 2966 | 3152 | /* pci_access_mutex lock acquired by sysfs show path */ |
|---|
| 2967 | 3153 | mutex_lock(&ioc->pci_access_mutex); |
|---|
| 2968 | | - if (ioc->pci_error_recovery || ioc->remove_host) { |
|---|
| 2969 | | - mutex_unlock(&ioc->pci_access_mutex); |
|---|
| 2970 | | - return 0; |
|---|
| 2971 | | - } |
|---|
| 3154 | + if (ioc->pci_error_recovery || ioc->remove_host) |
|---|
| 3155 | + goto out; |
|---|
| 2972 | 3156 | |
|---|
| 2973 | 3157 | /* allocate upto GPIOVal 36 entries */ |
|---|
| 2974 | 3158 | sz = offsetof(Mpi2IOUnitPage3_t, GPIOVal) + (sizeof(u16) * 36); |
|---|
| 2975 | 3159 | io_unit_pg3 = kzalloc(sz, GFP_KERNEL); |
|---|
| 2976 | 3160 | if (!io_unit_pg3) { |
|---|
| 2977 | | - pr_err(MPT3SAS_FMT "%s: failed allocating memory " |
|---|
| 2978 | | - "for iounit_pg3: (%d) bytes\n", ioc->name, __func__, sz); |
|---|
| 3161 | + rc = -ENOMEM; |
|---|
| 3162 | + ioc_err(ioc, "%s: failed allocating memory for iounit_pg3: (%d) bytes\n", |
|---|
| 3163 | + __func__, sz); |
|---|
| 2979 | 3164 | goto out; |
|---|
| 2980 | 3165 | } |
|---|
| 2981 | 3166 | |
|---|
| 2982 | 3167 | if (mpt3sas_config_get_iounit_pg3(ioc, &mpi_reply, io_unit_pg3, sz) != |
|---|
| 2983 | 3168 | 0) { |
|---|
| 2984 | | - pr_err(MPT3SAS_FMT |
|---|
| 2985 | | - "%s: failed reading iounit_pg3\n", ioc->name, |
|---|
| 2986 | | - __func__); |
|---|
| 3169 | + ioc_err(ioc, "%s: failed reading iounit_pg3\n", |
|---|
| 3170 | + __func__); |
|---|
| 3171 | + rc = -EINVAL; |
|---|
| 2987 | 3172 | goto out; |
|---|
| 2988 | 3173 | } |
|---|
| 2989 | 3174 | |
|---|
| 2990 | 3175 | ioc_status = le16_to_cpu(mpi_reply.IOCStatus) & MPI2_IOCSTATUS_MASK; |
|---|
| 2991 | 3176 | if (ioc_status != MPI2_IOCSTATUS_SUCCESS) { |
|---|
| 2992 | | - pr_err(MPT3SAS_FMT "%s: iounit_pg3 failed with " |
|---|
| 2993 | | - "ioc_status(0x%04x)\n", ioc->name, __func__, ioc_status); |
|---|
| 3177 | + ioc_err(ioc, "%s: iounit_pg3 failed with ioc_status(0x%04x)\n", |
|---|
| 3178 | + __func__, ioc_status); |
|---|
| 3179 | + rc = -EINVAL; |
|---|
| 2994 | 3180 | goto out; |
|---|
| 2995 | 3181 | } |
|---|
| 2996 | 3182 | |
|---|
| 2997 | 3183 | if (io_unit_pg3->GPIOCount < 25) { |
|---|
| 2998 | | - pr_err(MPT3SAS_FMT "%s: iounit_pg3->GPIOCount less than " |
|---|
| 2999 | | - "25 entries, detected (%d) entries\n", ioc->name, __func__, |
|---|
| 3000 | | - io_unit_pg3->GPIOCount); |
|---|
| 3184 | + ioc_err(ioc, "%s: iounit_pg3->GPIOCount less than 25 entries, detected (%d) entries\n", |
|---|
| 3185 | + __func__, io_unit_pg3->GPIOCount); |
|---|
| 3186 | + rc = -EINVAL; |
|---|
| 3001 | 3187 | goto out; |
|---|
| 3002 | 3188 | } |
|---|
| 3003 | 3189 | |
|---|
| .. | .. |
|---|
| 3010 | 3196 | mutex_unlock(&ioc->pci_access_mutex); |
|---|
| 3011 | 3197 | return rc; |
|---|
| 3012 | 3198 | } |
|---|
| 3013 | | -static DEVICE_ATTR(BRM_status, S_IRUGO, _ctl_BRM_status_show, NULL); |
|---|
| 3199 | +static DEVICE_ATTR_RO(BRM_status); |
|---|
| 3014 | 3200 | |
|---|
| 3015 | 3201 | struct DIAG_BUFFER_START { |
|---|
| 3016 | 3202 | __le32 Size; |
|---|
| .. | .. |
|---|
| 3023 | 3209 | }; |
|---|
| 3024 | 3210 | |
|---|
| 3025 | 3211 | /** |
|---|
| 3026 | | - * _ctl_host_trace_buffer_size_show - host buffer size (trace only) |
|---|
| 3212 | + * host_trace_buffer_size_show - host buffer size (trace only) |
|---|
| 3027 | 3213 | * @cdev: pointer to embedded class device |
|---|
| 3028 | 3214 | * @attr: ? |
|---|
| 3029 | 3215 | * @buf: the buffer returned |
|---|
| .. | .. |
|---|
| 3031 | 3217 | * A sysfs 'read-only' shost attribute. |
|---|
| 3032 | 3218 | */ |
|---|
| 3033 | 3219 | static ssize_t |
|---|
| 3034 | | -_ctl_host_trace_buffer_size_show(struct device *cdev, |
|---|
| 3220 | +host_trace_buffer_size_show(struct device *cdev, |
|---|
| 3035 | 3221 | struct device_attribute *attr, char *buf) |
|---|
| 3036 | 3222 | { |
|---|
| 3037 | 3223 | struct Scsi_Host *shost = class_to_shost(cdev); |
|---|
| .. | .. |
|---|
| 3040 | 3226 | struct DIAG_BUFFER_START *request_data; |
|---|
| 3041 | 3227 | |
|---|
| 3042 | 3228 | if (!ioc->diag_buffer[MPI2_DIAG_BUF_TYPE_TRACE]) { |
|---|
| 3043 | | - pr_err(MPT3SAS_FMT |
|---|
| 3044 | | - "%s: host_trace_buffer is not registered\n", |
|---|
| 3045 | | - ioc->name, __func__); |
|---|
| 3229 | + ioc_err(ioc, "%s: host_trace_buffer is not registered\n", |
|---|
| 3230 | + __func__); |
|---|
| 3046 | 3231 | return 0; |
|---|
| 3047 | 3232 | } |
|---|
| 3048 | 3233 | |
|---|
| 3049 | 3234 | if ((ioc->diag_buffer_status[MPI2_DIAG_BUF_TYPE_TRACE] & |
|---|
| 3050 | 3235 | MPT3_DIAG_BUFFER_IS_REGISTERED) == 0) { |
|---|
| 3051 | | - pr_err(MPT3SAS_FMT |
|---|
| 3052 | | - "%s: host_trace_buffer is not registered\n", |
|---|
| 3053 | | - ioc->name, __func__); |
|---|
| 3236 | + ioc_err(ioc, "%s: host_trace_buffer is not registered\n", |
|---|
| 3237 | + __func__); |
|---|
| 3054 | 3238 | return 0; |
|---|
| 3055 | 3239 | } |
|---|
| 3056 | 3240 | |
|---|
| .. | .. |
|---|
| 3065 | 3249 | ioc->ring_buffer_sz = size; |
|---|
| 3066 | 3250 | return snprintf(buf, PAGE_SIZE, "%d\n", size); |
|---|
| 3067 | 3251 | } |
|---|
| 3068 | | -static DEVICE_ATTR(host_trace_buffer_size, S_IRUGO, |
|---|
| 3069 | | - _ctl_host_trace_buffer_size_show, NULL); |
|---|
| 3252 | +static DEVICE_ATTR_RO(host_trace_buffer_size); |
|---|
| 3070 | 3253 | |
|---|
| 3071 | 3254 | /** |
|---|
| 3072 | | - * _ctl_host_trace_buffer_show - firmware ring buffer (trace only) |
|---|
| 3255 | + * host_trace_buffer_show - firmware ring buffer (trace only) |
|---|
| 3073 | 3256 | * @cdev: pointer to embedded class device |
|---|
| 3074 | 3257 | * @attr: ? |
|---|
| 3075 | 3258 | * @buf: the buffer returned |
|---|
| .. | .. |
|---|
| 3081 | 3264 | * offset to the same attribute, it will move the pointer. |
|---|
| 3082 | 3265 | */ |
|---|
| 3083 | 3266 | static ssize_t |
|---|
| 3084 | | -_ctl_host_trace_buffer_show(struct device *cdev, struct device_attribute *attr, |
|---|
| 3267 | +host_trace_buffer_show(struct device *cdev, struct device_attribute *attr, |
|---|
| 3085 | 3268 | char *buf) |
|---|
| 3086 | 3269 | { |
|---|
| 3087 | 3270 | struct Scsi_Host *shost = class_to_shost(cdev); |
|---|
| .. | .. |
|---|
| 3090 | 3273 | u32 size; |
|---|
| 3091 | 3274 | |
|---|
| 3092 | 3275 | if (!ioc->diag_buffer[MPI2_DIAG_BUF_TYPE_TRACE]) { |
|---|
| 3093 | | - pr_err(MPT3SAS_FMT |
|---|
| 3094 | | - "%s: host_trace_buffer is not registered\n", |
|---|
| 3095 | | - ioc->name, __func__); |
|---|
| 3276 | + ioc_err(ioc, "%s: host_trace_buffer is not registered\n", |
|---|
| 3277 | + __func__); |
|---|
| 3096 | 3278 | return 0; |
|---|
| 3097 | 3279 | } |
|---|
| 3098 | 3280 | |
|---|
| 3099 | 3281 | if ((ioc->diag_buffer_status[MPI2_DIAG_BUF_TYPE_TRACE] & |
|---|
| 3100 | 3282 | MPT3_DIAG_BUFFER_IS_REGISTERED) == 0) { |
|---|
| 3101 | | - pr_err(MPT3SAS_FMT |
|---|
| 3102 | | - "%s: host_trace_buffer is not registered\n", |
|---|
| 3103 | | - ioc->name, __func__); |
|---|
| 3283 | + ioc_err(ioc, "%s: host_trace_buffer is not registered\n", |
|---|
| 3284 | + __func__); |
|---|
| 3104 | 3285 | return 0; |
|---|
| 3105 | 3286 | } |
|---|
| 3106 | 3287 | |
|---|
| .. | .. |
|---|
| 3115 | 3296 | } |
|---|
| 3116 | 3297 | |
|---|
| 3117 | 3298 | static ssize_t |
|---|
| 3118 | | -_ctl_host_trace_buffer_store(struct device *cdev, struct device_attribute *attr, |
|---|
| 3299 | +host_trace_buffer_store(struct device *cdev, struct device_attribute *attr, |
|---|
| 3119 | 3300 | const char *buf, size_t count) |
|---|
| 3120 | 3301 | { |
|---|
| 3121 | 3302 | struct Scsi_Host *shost = class_to_shost(cdev); |
|---|
| .. | .. |
|---|
| 3128 | 3309 | ioc->ring_buffer_offset = val; |
|---|
| 3129 | 3310 | return strlen(buf); |
|---|
| 3130 | 3311 | } |
|---|
| 3131 | | -static DEVICE_ATTR(host_trace_buffer, S_IRUGO | S_IWUSR, |
|---|
| 3132 | | - _ctl_host_trace_buffer_show, _ctl_host_trace_buffer_store); |
|---|
| 3312 | +static DEVICE_ATTR_RW(host_trace_buffer); |
|---|
| 3133 | 3313 | |
|---|
| 3134 | 3314 | |
|---|
| 3135 | 3315 | /*****************************************/ |
|---|
| 3136 | 3316 | |
|---|
| 3137 | 3317 | /** |
|---|
| 3138 | | - * _ctl_host_trace_buffer_enable_show - firmware ring buffer (trace only) |
|---|
| 3318 | + * host_trace_buffer_enable_show - firmware ring buffer (trace only) |
|---|
| 3139 | 3319 | * @cdev: pointer to embedded class device |
|---|
| 3140 | 3320 | * @attr: ? |
|---|
| 3141 | 3321 | * @buf: the buffer returned |
|---|
| .. | .. |
|---|
| 3145 | 3325 | * This is a mechnism to post/release host_trace_buffers |
|---|
| 3146 | 3326 | */ |
|---|
| 3147 | 3327 | static ssize_t |
|---|
| 3148 | | -_ctl_host_trace_buffer_enable_show(struct device *cdev, |
|---|
| 3328 | +host_trace_buffer_enable_show(struct device *cdev, |
|---|
| 3149 | 3329 | struct device_attribute *attr, char *buf) |
|---|
| 3150 | 3330 | { |
|---|
| 3151 | 3331 | struct Scsi_Host *shost = class_to_shost(cdev); |
|---|
| .. | .. |
|---|
| 3163 | 3343 | } |
|---|
| 3164 | 3344 | |
|---|
| 3165 | 3345 | static ssize_t |
|---|
| 3166 | | -_ctl_host_trace_buffer_enable_store(struct device *cdev, |
|---|
| 3346 | +host_trace_buffer_enable_store(struct device *cdev, |
|---|
| 3167 | 3347 | struct device_attribute *attr, const char *buf, size_t count) |
|---|
| 3168 | 3348 | { |
|---|
| 3169 | 3349 | struct Scsi_Host *shost = class_to_shost(cdev); |
|---|
| .. | .. |
|---|
| 3189 | 3369 | MPT3_DIAG_BUFFER_IS_RELEASED) == 0)) |
|---|
| 3190 | 3370 | goto out; |
|---|
| 3191 | 3371 | memset(&diag_register, 0, sizeof(struct mpt3_diag_register)); |
|---|
| 3192 | | - pr_info(MPT3SAS_FMT "posting host trace buffers\n", |
|---|
| 3193 | | - ioc->name); |
|---|
| 3372 | + ioc_info(ioc, "posting host trace buffers\n"); |
|---|
| 3194 | 3373 | diag_register.buffer_type = MPI2_DIAG_BUF_TYPE_TRACE; |
|---|
| 3195 | | - diag_register.requested_buffer_size = (1024 * 1024); |
|---|
| 3196 | | - diag_register.unique_id = 0x7075900; |
|---|
| 3374 | + |
|---|
| 3375 | + if (ioc->manu_pg11.HostTraceBufferMaxSizeKB != 0 && |
|---|
| 3376 | + ioc->diag_buffer_sz[MPI2_DIAG_BUF_TYPE_TRACE] != 0) { |
|---|
| 3377 | + /* post the same buffer allocated previously */ |
|---|
| 3378 | + diag_register.requested_buffer_size = |
|---|
| 3379 | + ioc->diag_buffer_sz[MPI2_DIAG_BUF_TYPE_TRACE]; |
|---|
| 3380 | + } else { |
|---|
| 3381 | + /* |
|---|
| 3382 | + * Free the diag buffer memory which was previously |
|---|
| 3383 | + * allocated by an application. |
|---|
| 3384 | + */ |
|---|
| 3385 | + if ((ioc->diag_buffer_sz[MPI2_DIAG_BUF_TYPE_TRACE] != 0) |
|---|
| 3386 | + && |
|---|
| 3387 | + (ioc->diag_buffer_status[MPI2_DIAG_BUF_TYPE_TRACE] & |
|---|
| 3388 | + MPT3_DIAG_BUFFER_IS_APP_OWNED)) { |
|---|
| 3389 | + dma_free_coherent(&ioc->pdev->dev, |
|---|
| 3390 | + ioc->diag_buffer_sz[MPI2_DIAG_BUF_TYPE_TRACE], |
|---|
| 3391 | + ioc->diag_buffer[MPI2_DIAG_BUF_TYPE_TRACE], |
|---|
| 3392 | + ioc->diag_buffer_dma[MPI2_DIAG_BUF_TYPE_TRACE]); |
|---|
| 3393 | + ioc->diag_buffer[MPI2_DIAG_BUF_TYPE_TRACE] = |
|---|
| 3394 | + NULL; |
|---|
| 3395 | + } |
|---|
| 3396 | + |
|---|
| 3397 | + diag_register.requested_buffer_size = (1024 * 1024); |
|---|
| 3398 | + } |
|---|
| 3399 | + |
|---|
| 3400 | + diag_register.unique_id = |
|---|
| 3401 | + (ioc->hba_mpi_version_belonged == MPI2_VERSION) ? |
|---|
| 3402 | + (MPT2DIAGBUFFUNIQUEID):(MPT3DIAGBUFFUNIQUEID); |
|---|
| 3197 | 3403 | ioc->diag_buffer_status[MPI2_DIAG_BUF_TYPE_TRACE] = 0; |
|---|
| 3198 | 3404 | _ctl_diag_register_2(ioc, &diag_register); |
|---|
| 3405 | + if (ioc->diag_buffer_status[MPI2_DIAG_BUF_TYPE_TRACE] & |
|---|
| 3406 | + MPT3_DIAG_BUFFER_IS_REGISTERED) { |
|---|
| 3407 | + ioc_info(ioc, |
|---|
| 3408 | + "Trace buffer %d KB allocated through sysfs\n", |
|---|
| 3409 | + diag_register.requested_buffer_size>>10); |
|---|
| 3410 | + if (ioc->hba_mpi_version_belonged != MPI2_VERSION) |
|---|
| 3411 | + ioc->diag_buffer_status[ |
|---|
| 3412 | + MPI2_DIAG_BUF_TYPE_TRACE] |= |
|---|
| 3413 | + MPT3_DIAG_BUFFER_IS_DRIVER_ALLOCATED; |
|---|
| 3414 | + } |
|---|
| 3199 | 3415 | } else if (!strcmp(str, "release")) { |
|---|
| 3200 | 3416 | /* exit out if host buffers are already released */ |
|---|
| 3201 | 3417 | if (!ioc->diag_buffer[MPI2_DIAG_BUF_TYPE_TRACE]) |
|---|
| .. | .. |
|---|
| 3206 | 3422 | if ((ioc->diag_buffer_status[MPI2_DIAG_BUF_TYPE_TRACE] & |
|---|
| 3207 | 3423 | MPT3_DIAG_BUFFER_IS_RELEASED)) |
|---|
| 3208 | 3424 | goto out; |
|---|
| 3209 | | - pr_info(MPT3SAS_FMT "releasing host trace buffer\n", |
|---|
| 3210 | | - ioc->name); |
|---|
| 3425 | + ioc_info(ioc, "releasing host trace buffer\n"); |
|---|
| 3211 | 3426 | mpt3sas_send_diag_release(ioc, MPI2_DIAG_BUF_TYPE_TRACE, |
|---|
| 3212 | 3427 | &issue_reset); |
|---|
| 3213 | 3428 | } |
|---|
| .. | .. |
|---|
| 3215 | 3430 | out: |
|---|
| 3216 | 3431 | return strlen(buf); |
|---|
| 3217 | 3432 | } |
|---|
| 3218 | | -static DEVICE_ATTR(host_trace_buffer_enable, S_IRUGO | S_IWUSR, |
|---|
| 3219 | | - _ctl_host_trace_buffer_enable_show, |
|---|
| 3220 | | - _ctl_host_trace_buffer_enable_store); |
|---|
| 3433 | +static DEVICE_ATTR_RW(host_trace_buffer_enable); |
|---|
| 3221 | 3434 | |
|---|
| 3222 | 3435 | /*********** diagnostic trigger suppport *********************************/ |
|---|
| 3223 | 3436 | |
|---|
| 3224 | 3437 | /** |
|---|
| 3225 | | - * _ctl_diag_trigger_master_show - show the diag_trigger_master attribute |
|---|
| 3438 | + * diag_trigger_master_show - show the diag_trigger_master attribute |
|---|
| 3226 | 3439 | * @cdev: pointer to embedded class device |
|---|
| 3227 | 3440 | * @attr: ? |
|---|
| 3228 | 3441 | * @buf: the buffer returned |
|---|
| .. | .. |
|---|
| 3230 | 3443 | * A sysfs 'read/write' shost attribute. |
|---|
| 3231 | 3444 | */ |
|---|
| 3232 | 3445 | static ssize_t |
|---|
| 3233 | | -_ctl_diag_trigger_master_show(struct device *cdev, |
|---|
| 3446 | +diag_trigger_master_show(struct device *cdev, |
|---|
| 3234 | 3447 | struct device_attribute *attr, char *buf) |
|---|
| 3235 | 3448 | |
|---|
| 3236 | 3449 | { |
|---|
| .. | .. |
|---|
| 3247 | 3460 | } |
|---|
| 3248 | 3461 | |
|---|
| 3249 | 3462 | /** |
|---|
| 3250 | | - * _ctl_diag_trigger_master_store - store the diag_trigger_master attribute |
|---|
| 3463 | + * diag_trigger_master_store - store the diag_trigger_master attribute |
|---|
| 3251 | 3464 | * @cdev: pointer to embedded class device |
|---|
| 3252 | 3465 | * @attr: ? |
|---|
| 3253 | 3466 | * @buf: the buffer returned |
|---|
| .. | .. |
|---|
| 3256 | 3469 | * A sysfs 'read/write' shost attribute. |
|---|
| 3257 | 3470 | */ |
|---|
| 3258 | 3471 | static ssize_t |
|---|
| 3259 | | -_ctl_diag_trigger_master_store(struct device *cdev, |
|---|
| 3472 | +diag_trigger_master_store(struct device *cdev, |
|---|
| 3260 | 3473 | struct device_attribute *attr, const char *buf, size_t count) |
|---|
| 3261 | 3474 | |
|---|
| 3262 | 3475 | { |
|---|
| .. | .. |
|---|
| 3275 | 3488 | spin_unlock_irqrestore(&ioc->diag_trigger_lock, flags); |
|---|
| 3276 | 3489 | return rc; |
|---|
| 3277 | 3490 | } |
|---|
| 3278 | | -static DEVICE_ATTR(diag_trigger_master, S_IRUGO | S_IWUSR, |
|---|
| 3279 | | - _ctl_diag_trigger_master_show, _ctl_diag_trigger_master_store); |
|---|
| 3491 | +static DEVICE_ATTR_RW(diag_trigger_master); |
|---|
| 3280 | 3492 | |
|---|
| 3281 | 3493 | |
|---|
| 3282 | 3494 | /** |
|---|
| 3283 | | - * _ctl_diag_trigger_event_show - show the diag_trigger_event attribute |
|---|
| 3495 | + * diag_trigger_event_show - show the diag_trigger_event attribute |
|---|
| 3284 | 3496 | * @cdev: pointer to embedded class device |
|---|
| 3285 | 3497 | * @attr: ? |
|---|
| 3286 | 3498 | * @buf: the buffer returned |
|---|
| .. | .. |
|---|
| 3288 | 3500 | * A sysfs 'read/write' shost attribute. |
|---|
| 3289 | 3501 | */ |
|---|
| 3290 | 3502 | static ssize_t |
|---|
| 3291 | | -_ctl_diag_trigger_event_show(struct device *cdev, |
|---|
| 3503 | +diag_trigger_event_show(struct device *cdev, |
|---|
| 3292 | 3504 | struct device_attribute *attr, char *buf) |
|---|
| 3293 | 3505 | { |
|---|
| 3294 | 3506 | struct Scsi_Host *shost = class_to_shost(cdev); |
|---|
| .. | .. |
|---|
| 3304 | 3516 | } |
|---|
| 3305 | 3517 | |
|---|
| 3306 | 3518 | /** |
|---|
| 3307 | | - * _ctl_diag_trigger_event_store - store the diag_trigger_event attribute |
|---|
| 3519 | + * diag_trigger_event_store - store the diag_trigger_event attribute |
|---|
| 3308 | 3520 | * @cdev: pointer to embedded class device |
|---|
| 3309 | 3521 | * @attr: ? |
|---|
| 3310 | 3522 | * @buf: the buffer returned |
|---|
| .. | .. |
|---|
| 3313 | 3525 | * A sysfs 'read/write' shost attribute. |
|---|
| 3314 | 3526 | */ |
|---|
| 3315 | 3527 | static ssize_t |
|---|
| 3316 | | -_ctl_diag_trigger_event_store(struct device *cdev, |
|---|
| 3528 | +diag_trigger_event_store(struct device *cdev, |
|---|
| 3317 | 3529 | struct device_attribute *attr, const char *buf, size_t count) |
|---|
| 3318 | 3530 | |
|---|
| 3319 | 3531 | { |
|---|
| .. | .. |
|---|
| 3332 | 3544 | spin_unlock_irqrestore(&ioc->diag_trigger_lock, flags); |
|---|
| 3333 | 3545 | return sz; |
|---|
| 3334 | 3546 | } |
|---|
| 3335 | | -static DEVICE_ATTR(diag_trigger_event, S_IRUGO | S_IWUSR, |
|---|
| 3336 | | - _ctl_diag_trigger_event_show, _ctl_diag_trigger_event_store); |
|---|
| 3547 | +static DEVICE_ATTR_RW(diag_trigger_event); |
|---|
| 3337 | 3548 | |
|---|
| 3338 | 3549 | |
|---|
| 3339 | 3550 | /** |
|---|
| 3340 | | - * _ctl_diag_trigger_scsi_show - show the diag_trigger_scsi attribute |
|---|
| 3551 | + * diag_trigger_scsi_show - show the diag_trigger_scsi attribute |
|---|
| 3341 | 3552 | * @cdev: pointer to embedded class device |
|---|
| 3342 | 3553 | * @attr: ? |
|---|
| 3343 | 3554 | * @buf: the buffer returned |
|---|
| .. | .. |
|---|
| 3345 | 3556 | * A sysfs 'read/write' shost attribute. |
|---|
| 3346 | 3557 | */ |
|---|
| 3347 | 3558 | static ssize_t |
|---|
| 3348 | | -_ctl_diag_trigger_scsi_show(struct device *cdev, |
|---|
| 3559 | +diag_trigger_scsi_show(struct device *cdev, |
|---|
| 3349 | 3560 | struct device_attribute *attr, char *buf) |
|---|
| 3350 | 3561 | { |
|---|
| 3351 | 3562 | struct Scsi_Host *shost = class_to_shost(cdev); |
|---|
| .. | .. |
|---|
| 3361 | 3572 | } |
|---|
| 3362 | 3573 | |
|---|
| 3363 | 3574 | /** |
|---|
| 3364 | | - * _ctl_diag_trigger_scsi_store - store the diag_trigger_scsi attribute |
|---|
| 3575 | + * diag_trigger_scsi_store - store the diag_trigger_scsi attribute |
|---|
| 3365 | 3576 | * @cdev: pointer to embedded class device |
|---|
| 3366 | 3577 | * @attr: ? |
|---|
| 3367 | 3578 | * @buf: the buffer returned |
|---|
| .. | .. |
|---|
| 3370 | 3581 | * A sysfs 'read/write' shost attribute. |
|---|
| 3371 | 3582 | */ |
|---|
| 3372 | 3583 | static ssize_t |
|---|
| 3373 | | -_ctl_diag_trigger_scsi_store(struct device *cdev, |
|---|
| 3584 | +diag_trigger_scsi_store(struct device *cdev, |
|---|
| 3374 | 3585 | struct device_attribute *attr, const char *buf, size_t count) |
|---|
| 3375 | 3586 | { |
|---|
| 3376 | 3587 | struct Scsi_Host *shost = class_to_shost(cdev); |
|---|
| .. | .. |
|---|
| 3379 | 3590 | ssize_t sz; |
|---|
| 3380 | 3591 | |
|---|
| 3381 | 3592 | spin_lock_irqsave(&ioc->diag_trigger_lock, flags); |
|---|
| 3382 | | - sz = min(sizeof(struct SL_WH_SCSI_TRIGGERS_T), count); |
|---|
| 3383 | | - memset(&ioc->diag_trigger_scsi, 0, |
|---|
| 3384 | | - sizeof(struct SL_WH_EVENT_TRIGGERS_T)); |
|---|
| 3593 | + sz = min(sizeof(ioc->diag_trigger_scsi), count); |
|---|
| 3594 | + memset(&ioc->diag_trigger_scsi, 0, sizeof(ioc->diag_trigger_scsi)); |
|---|
| 3385 | 3595 | memcpy(&ioc->diag_trigger_scsi, buf, sz); |
|---|
| 3386 | 3596 | if (ioc->diag_trigger_scsi.ValidEntries > NUM_VALID_ENTRIES) |
|---|
| 3387 | 3597 | ioc->diag_trigger_scsi.ValidEntries = NUM_VALID_ENTRIES; |
|---|
| 3388 | 3598 | spin_unlock_irqrestore(&ioc->diag_trigger_lock, flags); |
|---|
| 3389 | 3599 | return sz; |
|---|
| 3390 | 3600 | } |
|---|
| 3391 | | -static DEVICE_ATTR(diag_trigger_scsi, S_IRUGO | S_IWUSR, |
|---|
| 3392 | | - _ctl_diag_trigger_scsi_show, _ctl_diag_trigger_scsi_store); |
|---|
| 3601 | +static DEVICE_ATTR_RW(diag_trigger_scsi); |
|---|
| 3393 | 3602 | |
|---|
| 3394 | 3603 | |
|---|
| 3395 | 3604 | /** |
|---|
| 3396 | | - * _ctl_diag_trigger_scsi_show - show the diag_trigger_mpi attribute |
|---|
| 3605 | + * diag_trigger_scsi_show - show the diag_trigger_mpi attribute |
|---|
| 3397 | 3606 | * @cdev: pointer to embedded class device |
|---|
| 3398 | 3607 | * @attr: ? |
|---|
| 3399 | 3608 | * @buf: the buffer returned |
|---|
| .. | .. |
|---|
| 3401 | 3610 | * A sysfs 'read/write' shost attribute. |
|---|
| 3402 | 3611 | */ |
|---|
| 3403 | 3612 | static ssize_t |
|---|
| 3404 | | -_ctl_diag_trigger_mpi_show(struct device *cdev, |
|---|
| 3613 | +diag_trigger_mpi_show(struct device *cdev, |
|---|
| 3405 | 3614 | struct device_attribute *attr, char *buf) |
|---|
| 3406 | 3615 | { |
|---|
| 3407 | 3616 | struct Scsi_Host *shost = class_to_shost(cdev); |
|---|
| .. | .. |
|---|
| 3417 | 3626 | } |
|---|
| 3418 | 3627 | |
|---|
| 3419 | 3628 | /** |
|---|
| 3420 | | - * _ctl_diag_trigger_mpi_store - store the diag_trigger_mpi attribute |
|---|
| 3629 | + * diag_trigger_mpi_store - store the diag_trigger_mpi attribute |
|---|
| 3421 | 3630 | * @cdev: pointer to embedded class device |
|---|
| 3422 | 3631 | * @attr: ? |
|---|
| 3423 | 3632 | * @buf: the buffer returned |
|---|
| .. | .. |
|---|
| 3426 | 3635 | * A sysfs 'read/write' shost attribute. |
|---|
| 3427 | 3636 | */ |
|---|
| 3428 | 3637 | static ssize_t |
|---|
| 3429 | | -_ctl_diag_trigger_mpi_store(struct device *cdev, |
|---|
| 3638 | +diag_trigger_mpi_store(struct device *cdev, |
|---|
| 3430 | 3639 | struct device_attribute *attr, const char *buf, size_t count) |
|---|
| 3431 | 3640 | { |
|---|
| 3432 | 3641 | struct Scsi_Host *shost = class_to_shost(cdev); |
|---|
| .. | .. |
|---|
| 3445 | 3654 | return sz; |
|---|
| 3446 | 3655 | } |
|---|
| 3447 | 3656 | |
|---|
| 3448 | | -static DEVICE_ATTR(diag_trigger_mpi, S_IRUGO | S_IWUSR, |
|---|
| 3449 | | - _ctl_diag_trigger_mpi_show, _ctl_diag_trigger_mpi_store); |
|---|
| 3657 | +static DEVICE_ATTR_RW(diag_trigger_mpi); |
|---|
| 3450 | 3658 | |
|---|
| 3451 | 3659 | /*********** diagnostic trigger suppport *** END ****************************/ |
|---|
| 3452 | 3660 | |
|---|
| 3453 | 3661 | /*****************************************/ |
|---|
| 3662 | + |
|---|
| 3663 | +/** |
|---|
| 3664 | + * drv_support_bitmap_show - driver supported feature bitmap |
|---|
| 3665 | + * @cdev: pointer to embedded class device |
|---|
| 3666 | + * @attr: unused |
|---|
| 3667 | + * @buf: the buffer returned |
|---|
| 3668 | + * |
|---|
| 3669 | + * A sysfs 'read-only' shost attribute. |
|---|
| 3670 | + */ |
|---|
| 3671 | +static ssize_t |
|---|
| 3672 | +drv_support_bitmap_show(struct device *cdev, |
|---|
| 3673 | + struct device_attribute *attr, char *buf) |
|---|
| 3674 | +{ |
|---|
| 3675 | + struct Scsi_Host *shost = class_to_shost(cdev); |
|---|
| 3676 | + struct MPT3SAS_ADAPTER *ioc = shost_priv(shost); |
|---|
| 3677 | + |
|---|
| 3678 | + return snprintf(buf, PAGE_SIZE, "0x%08x\n", ioc->drv_support_bitmap); |
|---|
| 3679 | +} |
|---|
| 3680 | +static DEVICE_ATTR_RO(drv_support_bitmap); |
|---|
| 3681 | + |
|---|
| 3682 | +/** |
|---|
| 3683 | + * enable_sdev_max_qd_show - display whether sdev max qd is enabled/disabled |
|---|
| 3684 | + * @cdev: pointer to embedded class device |
|---|
| 3685 | + * @attr: unused |
|---|
| 3686 | + * @buf: the buffer returned |
|---|
| 3687 | + * |
|---|
| 3688 | + * A sysfs read/write shost attribute. This attribute is used to set the |
|---|
| 3689 | + * targets queue depth to HBA IO queue depth if this attribute is enabled. |
|---|
| 3690 | + */ |
|---|
| 3691 | +static ssize_t |
|---|
| 3692 | +enable_sdev_max_qd_show(struct device *cdev, |
|---|
| 3693 | + struct device_attribute *attr, char *buf) |
|---|
| 3694 | +{ |
|---|
| 3695 | + struct Scsi_Host *shost = class_to_shost(cdev); |
|---|
| 3696 | + struct MPT3SAS_ADAPTER *ioc = shost_priv(shost); |
|---|
| 3697 | + |
|---|
| 3698 | + return snprintf(buf, PAGE_SIZE, "%d\n", ioc->enable_sdev_max_qd); |
|---|
| 3699 | +} |
|---|
| 3700 | + |
|---|
| 3701 | +/** |
|---|
| 3702 | + * enable_sdev_max_qd_store - Enable/disable sdev max qd |
|---|
| 3703 | + * @cdev: pointer to embedded class device |
|---|
| 3704 | + * @attr: unused |
|---|
| 3705 | + * @buf: the buffer returned |
|---|
| 3706 | + * @count: unused |
|---|
| 3707 | + * |
|---|
| 3708 | + * A sysfs read/write shost attribute. This attribute is used to set the |
|---|
| 3709 | + * targets queue depth to HBA IO queue depth if this attribute is enabled. |
|---|
| 3710 | + * If this attribute is disabled then targets will have corresponding default |
|---|
| 3711 | + * queue depth. |
|---|
| 3712 | + */ |
|---|
| 3713 | +static ssize_t |
|---|
| 3714 | +enable_sdev_max_qd_store(struct device *cdev, |
|---|
| 3715 | + struct device_attribute *attr, const char *buf, size_t count) |
|---|
| 3716 | +{ |
|---|
| 3717 | + struct Scsi_Host *shost = class_to_shost(cdev); |
|---|
| 3718 | + struct MPT3SAS_ADAPTER *ioc = shost_priv(shost); |
|---|
| 3719 | + struct MPT3SAS_DEVICE *sas_device_priv_data; |
|---|
| 3720 | + struct MPT3SAS_TARGET *sas_target_priv_data; |
|---|
| 3721 | + int val = 0; |
|---|
| 3722 | + struct scsi_device *sdev; |
|---|
| 3723 | + struct _raid_device *raid_device; |
|---|
| 3724 | + int qdepth; |
|---|
| 3725 | + |
|---|
| 3726 | + if (kstrtoint(buf, 0, &val) != 0) |
|---|
| 3727 | + return -EINVAL; |
|---|
| 3728 | + |
|---|
| 3729 | + switch (val) { |
|---|
| 3730 | + case 0: |
|---|
| 3731 | + ioc->enable_sdev_max_qd = 0; |
|---|
| 3732 | + shost_for_each_device(sdev, ioc->shost) { |
|---|
| 3733 | + sas_device_priv_data = sdev->hostdata; |
|---|
| 3734 | + if (!sas_device_priv_data) |
|---|
| 3735 | + continue; |
|---|
| 3736 | + sas_target_priv_data = sas_device_priv_data->sas_target; |
|---|
| 3737 | + if (!sas_target_priv_data) |
|---|
| 3738 | + continue; |
|---|
| 3739 | + |
|---|
| 3740 | + if (sas_target_priv_data->flags & |
|---|
| 3741 | + MPT_TARGET_FLAGS_VOLUME) { |
|---|
| 3742 | + raid_device = |
|---|
| 3743 | + mpt3sas_raid_device_find_by_handle(ioc, |
|---|
| 3744 | + sas_target_priv_data->handle); |
|---|
| 3745 | + |
|---|
| 3746 | + switch (raid_device->volume_type) { |
|---|
| 3747 | + case MPI2_RAID_VOL_TYPE_RAID0: |
|---|
| 3748 | + if (raid_device->device_info & |
|---|
| 3749 | + MPI2_SAS_DEVICE_INFO_SSP_TARGET) |
|---|
| 3750 | + qdepth = |
|---|
| 3751 | + MPT3SAS_SAS_QUEUE_DEPTH; |
|---|
| 3752 | + else |
|---|
| 3753 | + qdepth = |
|---|
| 3754 | + MPT3SAS_SATA_QUEUE_DEPTH; |
|---|
| 3755 | + break; |
|---|
| 3756 | + case MPI2_RAID_VOL_TYPE_RAID1E: |
|---|
| 3757 | + case MPI2_RAID_VOL_TYPE_RAID1: |
|---|
| 3758 | + case MPI2_RAID_VOL_TYPE_RAID10: |
|---|
| 3759 | + case MPI2_RAID_VOL_TYPE_UNKNOWN: |
|---|
| 3760 | + default: |
|---|
| 3761 | + qdepth = MPT3SAS_RAID_QUEUE_DEPTH; |
|---|
| 3762 | + } |
|---|
| 3763 | + } else if (sas_target_priv_data->flags & |
|---|
| 3764 | + MPT_TARGET_FLAGS_PCIE_DEVICE) |
|---|
| 3765 | + qdepth = MPT3SAS_NVME_QUEUE_DEPTH; |
|---|
| 3766 | + else |
|---|
| 3767 | + qdepth = MPT3SAS_SAS_QUEUE_DEPTH; |
|---|
| 3768 | + |
|---|
| 3769 | + mpt3sas_scsih_change_queue_depth(sdev, qdepth); |
|---|
| 3770 | + } |
|---|
| 3771 | + break; |
|---|
| 3772 | + case 1: |
|---|
| 3773 | + ioc->enable_sdev_max_qd = 1; |
|---|
| 3774 | + shost_for_each_device(sdev, ioc->shost) |
|---|
| 3775 | + mpt3sas_scsih_change_queue_depth(sdev, |
|---|
| 3776 | + shost->can_queue); |
|---|
| 3777 | + break; |
|---|
| 3778 | + default: |
|---|
| 3779 | + return -EINVAL; |
|---|
| 3780 | + } |
|---|
| 3781 | + |
|---|
| 3782 | + return strlen(buf); |
|---|
| 3783 | +} |
|---|
| 3784 | +static DEVICE_ATTR_RW(enable_sdev_max_qd); |
|---|
| 3454 | 3785 | |
|---|
| 3455 | 3786 | struct device_attribute *mpt3sas_host_attrs[] = { |
|---|
| 3456 | 3787 | &dev_attr_version_fw, |
|---|
| .. | .. |
|---|
| 3477 | 3808 | &dev_attr_diag_trigger_event, |
|---|
| 3478 | 3809 | &dev_attr_diag_trigger_scsi, |
|---|
| 3479 | 3810 | &dev_attr_diag_trigger_mpi, |
|---|
| 3811 | + &dev_attr_drv_support_bitmap, |
|---|
| 3480 | 3812 | &dev_attr_BRM_status, |
|---|
| 3813 | + &dev_attr_enable_sdev_max_qd, |
|---|
| 3481 | 3814 | NULL, |
|---|
| 3482 | 3815 | }; |
|---|
| 3483 | 3816 | |
|---|
| 3484 | 3817 | /* device attributes */ |
|---|
| 3485 | 3818 | |
|---|
| 3486 | 3819 | /** |
|---|
| 3487 | | - * _ctl_device_sas_address_show - sas address |
|---|
| 3820 | + * sas_address_show - sas address |
|---|
| 3488 | 3821 | * @dev: pointer to embedded class device |
|---|
| 3489 | 3822 | * @attr: ? |
|---|
| 3490 | 3823 | * @buf: the buffer returned |
|---|
| .. | .. |
|---|
| 3494 | 3827 | * A sysfs 'read-only' shost attribute. |
|---|
| 3495 | 3828 | */ |
|---|
| 3496 | 3829 | static ssize_t |
|---|
| 3497 | | -_ctl_device_sas_address_show(struct device *dev, struct device_attribute *attr, |
|---|
| 3830 | +sas_address_show(struct device *dev, struct device_attribute *attr, |
|---|
| 3498 | 3831 | char *buf) |
|---|
| 3499 | 3832 | { |
|---|
| 3500 | 3833 | struct scsi_device *sdev = to_scsi_device(dev); |
|---|
| .. | .. |
|---|
| 3503 | 3836 | return snprintf(buf, PAGE_SIZE, "0x%016llx\n", |
|---|
| 3504 | 3837 | (unsigned long long)sas_device_priv_data->sas_target->sas_address); |
|---|
| 3505 | 3838 | } |
|---|
| 3506 | | -static DEVICE_ATTR(sas_address, S_IRUGO, _ctl_device_sas_address_show, NULL); |
|---|
| 3839 | +static DEVICE_ATTR_RO(sas_address); |
|---|
| 3507 | 3840 | |
|---|
| 3508 | 3841 | /** |
|---|
| 3509 | | - * _ctl_device_handle_show - device handle |
|---|
| 3842 | + * sas_device_handle_show - device handle |
|---|
| 3510 | 3843 | * @dev: pointer to embedded class device |
|---|
| 3511 | 3844 | * @attr: ? |
|---|
| 3512 | 3845 | * @buf: the buffer returned |
|---|
| .. | .. |
|---|
| 3516 | 3849 | * A sysfs 'read-only' shost attribute. |
|---|
| 3517 | 3850 | */ |
|---|
| 3518 | 3851 | static ssize_t |
|---|
| 3519 | | -_ctl_device_handle_show(struct device *dev, struct device_attribute *attr, |
|---|
| 3852 | +sas_device_handle_show(struct device *dev, struct device_attribute *attr, |
|---|
| 3520 | 3853 | char *buf) |
|---|
| 3521 | 3854 | { |
|---|
| 3522 | 3855 | struct scsi_device *sdev = to_scsi_device(dev); |
|---|
| .. | .. |
|---|
| 3525 | 3858 | return snprintf(buf, PAGE_SIZE, "0x%04x\n", |
|---|
| 3526 | 3859 | sas_device_priv_data->sas_target->handle); |
|---|
| 3527 | 3860 | } |
|---|
| 3528 | | -static DEVICE_ATTR(sas_device_handle, S_IRUGO, _ctl_device_handle_show, NULL); |
|---|
| 3861 | +static DEVICE_ATTR_RO(sas_device_handle); |
|---|
| 3529 | 3862 | |
|---|
| 3530 | 3863 | /** |
|---|
| 3531 | | - * _ctl_device_ncq_io_prio_show - send prioritized io commands to device |
|---|
| 3864 | + * sas_ncq_io_prio_show - send prioritized io commands to device |
|---|
| 3532 | 3865 | * @dev: pointer to embedded device |
|---|
| 3533 | 3866 | * @attr: ? |
|---|
| 3534 | 3867 | * @buf: the buffer returned |
|---|
| .. | .. |
|---|
| 3536 | 3869 | * A sysfs 'read/write' sdev attribute, only works with SATA |
|---|
| 3537 | 3870 | */ |
|---|
| 3538 | 3871 | static ssize_t |
|---|
| 3539 | | -_ctl_device_ncq_prio_enable_show(struct device *dev, |
|---|
| 3872 | +sas_ncq_prio_enable_show(struct device *dev, |
|---|
| 3540 | 3873 | struct device_attribute *attr, char *buf) |
|---|
| 3541 | 3874 | { |
|---|
| 3542 | 3875 | struct scsi_device *sdev = to_scsi_device(dev); |
|---|
| .. | .. |
|---|
| 3547 | 3880 | } |
|---|
| 3548 | 3881 | |
|---|
| 3549 | 3882 | static ssize_t |
|---|
| 3550 | | -_ctl_device_ncq_prio_enable_store(struct device *dev, |
|---|
| 3883 | +sas_ncq_prio_enable_store(struct device *dev, |
|---|
| 3551 | 3884 | struct device_attribute *attr, |
|---|
| 3552 | 3885 | const char *buf, size_t count) |
|---|
| 3553 | 3886 | { |
|---|
| .. | .. |
|---|
| 3564 | 3897 | sas_device_priv_data->ncq_prio_enable = ncq_prio_enable; |
|---|
| 3565 | 3898 | return strlen(buf); |
|---|
| 3566 | 3899 | } |
|---|
| 3567 | | -static DEVICE_ATTR(sas_ncq_prio_enable, S_IRUGO | S_IWUSR, |
|---|
| 3568 | | - _ctl_device_ncq_prio_enable_show, |
|---|
| 3569 | | - _ctl_device_ncq_prio_enable_store); |
|---|
| 3900 | +static DEVICE_ATTR_RW(sas_ncq_prio_enable); |
|---|
| 3570 | 3901 | |
|---|
| 3571 | 3902 | struct device_attribute *mpt3sas_dev_attrs[] = { |
|---|
| 3572 | 3903 | &dev_attr_sas_address, |
|---|
| .. | .. |
|---|
| 3653 | 3984 | for (i = 0; i < MPI2_DIAG_BUF_TYPE_COUNT; i++) { |
|---|
| 3654 | 3985 | if (!ioc->diag_buffer[i]) |
|---|
| 3655 | 3986 | continue; |
|---|
| 3656 | | - if (!(ioc->diag_buffer_status[i] & |
|---|
| 3657 | | - MPT3_DIAG_BUFFER_IS_REGISTERED)) |
|---|
| 3658 | | - continue; |
|---|
| 3659 | | - if ((ioc->diag_buffer_status[i] & |
|---|
| 3660 | | - MPT3_DIAG_BUFFER_IS_RELEASED)) |
|---|
| 3661 | | - continue; |
|---|
| 3662 | | - pci_free_consistent(ioc->pdev, ioc->diag_buffer_sz[i], |
|---|
| 3663 | | - ioc->diag_buffer[i], ioc->diag_buffer_dma[i]); |
|---|
| 3987 | + dma_free_coherent(&ioc->pdev->dev, |
|---|
| 3988 | + ioc->diag_buffer_sz[i], |
|---|
| 3989 | + ioc->diag_buffer[i], |
|---|
| 3990 | + ioc->diag_buffer_dma[i]); |
|---|
| 3664 | 3991 | ioc->diag_buffer[i] = NULL; |
|---|
| 3665 | 3992 | ioc->diag_buffer_status[i] = 0; |
|---|
| 3666 | 3993 | } |
|---|