aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/mpi3mr/mpi3mr_fw.c (follow)
AgeCommit message (Collapse)AuthorFilesLines
2021-08-24scsi: mpi3mr: Set up IRQs in resume pathKashyap Desai1-17/+20
Driver is not setting up IRQs in the resume path. As a result, hibernation path is broken and controller will not be operational after system is resumed. Set up IRQs to handle the hibernation case. Link: https://lore.kernel.org/r/20210818081755.1274470-1-kashyap.desai@broadcom.com Cc: sathya.prakash@broadcom.com Cc: thenzl@redhat.com Reported-by: Marco Patalano <mpatalan@redhat.com> Tested-by: Marco Patalano <mpatalan@redhat.com> Signed-off-by: Kashyap Desai <kashyap.desai@broadcom.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2021-07-12scsi: mpi3mr: Fix W=1 compilation warningsSreekanth Reddy1-8/+7
Fix for the following W=1 compilation warning: 'strncpy' output may be truncated copying 16 bytes from a string of length 64 Link: https://lore.kernel.org/r/20210707081756.20922-1-sreekanth.reddy@broadcom.com Reported-by: kernel test robot <lkp@intel.com> Signed-off-by: Sreekanth Reddy <sreekanth.reddy@broadcom.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2021-06-18scsi: mpi3mr: Make some symbols staticYang Yingliang1-1/+0
Fix the following warnings: drivers/scsi/mpi3mr/mpi3mr_os.c:24:5: warning: symbol 'prot_mask' was not declared. Should it be static? drivers/scsi/mpi3mr/mpi3mr_os.c:28:5: warning: symbol 'prot_guard_mask' was not declared. Should it be static? drivers/scsi/mpi3mr/mpi3mr_os.c:31:5: warning: symbol 'logging_level' was not declared. Should it be static? Link: https://lore.kernel.org/r/20210604071407.1360742-1-yangyingliang@huawei.com Reported-by: Hulk Robot <hulkci@huawei.com> Acked-by: Kashyap Desai <kashyap.desai@broadcom.com> Signed-off-by: Yang Yingliang <yangyingliang@huawei.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2021-06-18scsi: mpi3mr: Fix error return code in mpi3mr_init_ioc()Yang Yingliang1-0/+2
Fix to return a negative error code from the error handling case instead of 0 as done elsewhere in this function. Link: https://lore.kernel.org/r/20210603151653.711020-1-yangyingliang@huawei.com Fixes: fb9b04574f14 ("scsi: mpi3mr: Add support for recovering controller") Fixes: 824a156633df ("scsi: mpi3mr: Base driver code") Reported-by: Hulk Robot <hulkci@huawei.com> Acked-by: Kashyap Desai <kashyap.desai@broadcom.com> Signed-off-by: Yang Yingliang <yangyingliang@huawei.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2021-06-18scsi: mpi3mr: Fix missing unlock on errorYang Yingliang1-2/+2
Goto unlock path before return from function in the error handling case. Link: https://lore.kernel.org/r/20210603152803.717505-1-yangyingliang@huawei.com Fixes: c9566231cfaf ("scsi: mpi3mr: Create operational request and reply queue pair") Reported-by: Hulk Robot <hulkci@huawei.com> Acked-by: Kashyap Desai <kashyap.desai@broadcom.com> Signed-off-by: Yang Yingliang <yangyingliang@huawei.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2021-06-09scsi: mpi3mr: Fix error handling in mpi3mr_setup_isr()Dan Carpenter1-11/+13
The pci_alloc_irq_vectors_affinity() function returns negative error codes or it returns a number between the minimum vectors (1 in this case) and max_vectors. It won't return zero. Because "i" is a u16 then the error handling won't work. And also if it did work the error code was not set. Really "max_vectors" can be an int as well because we're doing a min_t() on int type. The other change is that it's better to remove unnecessary initialization so that static checkers can warn us if there are ever uninitialized variable bugs introduced in the future. I changed the error code from -1 (-EPERM) if the kmalloc() failed to -ENOMEM. And on success path I changed it from "return retval;" to "return 0;" which shouldn't affect the compiled code but makes it more readable. Link: https://lore.kernel.org/r/YMCJcnmSI4kOIyv/@mwanda Fixes: 824a156633df ("scsi: mpi3mr: Base driver code") Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2021-06-09scsi: mpi3mr: Delete unnecessary NULL checkDan Carpenter1-2/+1
The "mrioc->intr_info" pointer can't be NULL, but if it could then the second iteration through the loop would Oops. Let's delete the confusing and impossible NULL check. Link: https://lore.kernel.org/r/YMCJKgykDYtyvY44@mwanda Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2021-06-02scsi: mpi3mr: Add event handling debug printsKashyap Desai1-0/+115
Link: https://lore.kernel.org/r/20210520152545.2710479-25-kashyap.desai@broadcom.com Cc: sathya.prakash@broadcom.com Reviewed-by: Hannes Reinecke <hare@suse.de> Reviewed-by: Tomas Henzl <thenzl@redhat.com> Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com> Signed-off-by: Kashyap Desai <kashyap.desai@broadcom.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2021-06-02scsi: mpi3mr: Add EEDP DIF DIX supportKashyap Desai1-0/+7
Link: https://lore.kernel.org/r/20210520152545.2710479-24-kashyap.desai@broadcom.com Cc: sathya.prakash@broadcom.com Reviewed-by: Hannes Reinecke <hare@suse.de> Reviewed-by: Tomas Henzl <thenzl@redhat.com> Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com> Signed-off-by: Kashyap Desai <kashyap.desai@broadcom.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2021-06-02scsi: mpi3mr: Wait for pending I/O completions upon detection of VD I/O timeoutKashyap Desai1-0/+2
Wait for host I/O completion (default 180 seconds) if I/O timeout is detected on VDs. Link: https://lore.kernel.org/r/20210520152545.2710479-21-kashyap.desai@broadcom.com Cc: sathya.prakash@broadcom.com Reviewed-by: Hannes Reinecke <hare@suse.de> Reviewed-by: Tomas Henzl <thenzl@redhat.com> Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com> Signed-off-by: Kashyap Desai <kashyap.desai@broadcom.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2021-06-02scsi: mpi3mr: Complete support for soft resetKashyap Desai1-2/+244
Unlock the host diagnostic register, write the specific reset type to that and wait for reset acknowledgment from the controller. If the reset is not successful retry for the predefined number of times Link: https://lore.kernel.org/r/20210520152545.2710479-19-kashyap.desai@broadcom.com Cc: sathya.prakash@broadcom.com Reviewed-by: Hannes Reinecke <hare@suse.de> Reviewed-by: Tomas Henzl <thenzl@redhat.com> Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com> Signed-off-by: Kashyap Desai <kashyap.desai@broadcom.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2021-06-02scsi: mpi3mr: Add support for threaded ISRKashyap Desai1-3/+76
Register driver for threaded interrupts. By default the driver will attempt I/O completion from interrupt context (primary handler). Since the driver tracks per reply queue outstanding I/Os, it will schedule threaded ISR if there are any outstanding I/Os expected on that particular reply queue. Threaded ISR (secondary handler) will loop for I/O completion as long as there are outstanding I/Os (speculative method using same per reply queue outstanding counter) or it has completed some X amount of commands (something like budget). Link: https://lore.kernel.org/r/20210520152545.2710479-18-kashyap.desai@broadcom.com Cc: sathya.prakash@broadcom.com Reviewed-by: Hannes Reinecke <hare@suse.de> Reviewed-by: Tomas Henzl <thenzl@redhat.com> Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com> Signed-off-by: Kashyap Desai <kashyap.desai@broadcom.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2021-06-02scsi: mpi3mr: Implement SCSI error handler hooksKashyap Desai1-0/+35
Link: https://lore.kernel.org/r/20210520152545.2710479-14-kashyap.desai@broadcom.com Cc: sathya.prakash@broadcom.com Cc: hare@suse.de Cc: thenzl@redhat.com Reviewed-by: Hannes Reinecke <hare@suse.de> Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com> Reviewed-by: Tomas Henzl <thenzl@redhat.com> Signed-off-by: Kashyap Desai <kashyap.desai@broadcom.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2021-06-02scsi: mpi3mr: Print IOC info for debuggingKashyap Desai1-0/+95
Link: https://lore.kernel.org/r/20210520152545.2710479-12-kashyap.desai@broadcom.com Cc: sathya.prakash@broadcom.com Reviewed-by: Tomas Henzl <thenzl@redhat.com> Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com> Reviewed-by: Hannes Reinecke <hare@suse.de> Signed-off-by: Kashyap Desai <kashyap.desai@broadcom.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2021-06-02scsi: mpi3mr: Add support for timestamp sync with firmwareKashyap Desai1-0/+74
This operation requests that the IOC update the TimeStamp. When the I/O Unit is powered on it sets the TimeStamp field value to 0x0000_0000_0000_0000 and increments the current value every millisecond. A host driver sets the TimeStamp field to the current time by using an IOCInit request. The TimeStamp field is periodically updated by the host driver. Link: https://lore.kernel.org/r/20210520152545.2710479-11-kashyap.desai@broadcom.com Cc: sathya.prakash@broadcom.com Reviewed-by: Hannes Reinecke <hare@suse.de> Reviewed-by: Tomas Henzl <thenzl@redhat.com> Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com> Signed-off-by: Kashyap Desai <kashyap.desai@broadcom.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2021-06-02scsi: mpi3mr: Add support for recovering controllerKashyap Desai1-36/+379
Detection of firmware fault or any kind of unresponsiveness in the controller (any admin command which times out) results in resetting the controller. The primary reset mechanisms used are either soft reset or diag fault reset. A reset is performed if the host sets the ResetAction field in the HostDiagnostic register to either 001b (soft reset) or 007b (diag fault reset). After successfully resetting the controller the driver reinitializes the controller by going through start of the day initialization procedure. Pending I/Os during the reset are returned back to the SCSI midlayer for retry. Link: https://lore.kernel.org/r/20210520152545.2710479-10-kashyap.desai@broadcom.com Cc: sathya.prakash@broadcom.co Reviewed-by: Hannes Reinecke <hare@suse.de> Reviewed-by: Tomas Henzl <thenzl@redhat.com> Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com> Signed-off-by: Kashyap Desai <kashyap.desai@broadcom.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2021-06-02scsi: mpi3mr: Additional event handlingKashyap Desai1-0/+3
Implement support for handling the following MPI events: - MPI3_EVENT_SAS_BROADCAST_PRIMITIVE - MPI3_EVENT_CABLE_MGMT - MPI3_EVENT_ENERGY_PACK_CHANGE Link: https://lore.kernel.org/r/20210520152545.2710479-9-kashyap.desai@broadcom.com Cc: sathya.prakash@broadcom.com Reviewed-by: Hannes Reinecke <hare@suse.de> Reviewed-by: Tomas Henzl <thenzl@redhat.com> Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com> Signed-off-by: Kashyap Desai <kashyap.desai@broadcom.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2021-06-02scsi: mpi3mr: Add support for PCIe device event handlingKashyap Desai1-0/+2
Implement support for the following PCIe-related MPI events: - MPI3_EVENT_PCIE_TOPOLOGY_CHANGE_LIST - MPI3_EVENT_PCIE_ENUMERATION Link: https://lore.kernel.org/r/20210520152545.2710479-8-kashyap.desai@broadcom.com Cc: sathya.prakash@broadcom.com Reviewed-by: Hannes Reinecke <hare@suse.de> Reviewed-by: Tomas Henzl <thenzl@redhat.com> Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com> Signed-off-by: Kashyap Desai <kashyap.desai@broadcom.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2021-06-02scsi: mpi3mr: Add support for device add/remove event handlingKashyap Desai1-1/+196
Firmware can report various MPI Events. Enable support for processing the following events related to device addition/removal to the driver: - MPI3_EVENT_DEVICE_ADDED - MPI3_EVENT_DEVICE_INFO_CHANGED - MPI3_EVENT_DEVICE_STATUS_CHANGE - MPI3_EVENT_ENCL_DEVICE_STATUS_CHANGE - MPI3_EVENT_SAS_TOPOLOGY_CHANGE_LIST - MPI3_EVENT_SAS_DISCOVERY - MPI3_EVENT_SAS_DEVICE_DISCOVERY_ERROR Link: https://lore.kernel.org/r/20210520152545.2710479-7-kashyap.desai@broadcom.com Cc: sathya.prakash@broadcom.com Reported-by: kernel test robot <lkp@intel.com> Reviewed-by: Tomas Henzl <thenzl@redhat.com> Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com> Reviewed-by: Hannes Reinecke <hare@suse.de> Signed-off-by: Kashyap Desai <kashyap.desai@broadcom.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2021-06-02scsi: mpi3mr: Add support for internal watchdog threadKashyap Desai1-0/+125
The watchdog thread is the driver's internal thread which does a few things such as detecting firmware faults, resetting the controller, performing timestamp sync, etc. Link: https://lore.kernel.org/r/20210520152545.2710479-6-kashyap.desai@broadcom.com Cc: sathya.prakash@broadcom.com Reviewed-by: Hannes Reinecke <hare@suse.de> Reviewed-by: Tomas Henzl <thenzl@redhat.com> Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com> Signed-off-by: Kashyap Desai <kashyap.desai@broadcom.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2021-06-02scsi: mpi3mr: Add support for queue command processingKashyap Desai1-0/+244
Send Port Enable Request to FW for Device Discovery. As part of port enable completion driver calls scan_start and scan_finished hooks. SCSI layer references like sdev, starget, etc. are added but actual device discovery will be supported once driver adds complete event process handling. Link: https://lore.kernel.org/r/20210520152545.2710479-5-kashyap.desai@broadcom.com Cc: sathya.prakash@broadcom.com Cc: hare@suse.de Reviewed-by: Tomas Henzl <thenzl@redhat.com> Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com> Reviewed-by: Hannes Reinecke <hare@suse.de> Signed-off-by: Kashyap Desai <kashyap.desai@broadcom.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2021-06-02scsi: mpi3mr: Create operational request and reply queue pairKashyap Desai1-0/+596
Create operational request and reply queue pair. The MPI3 transport interface consists of an Administrative Request Queue, an Administrative Reply Queue, and Operational Messaging Queues. The Operational Messaging Queues are the primary communication mechanism between the host and the I/O Controller (IOC). Request messages, allocated in host memory, identify I/O operations to be performed by the IOC. These operations are queued on an Operational Request Queue by the host driver. Reply descriptors track I/O operations as they complete. The IOC queues these completions in an Operational Reply Queue. To fulfil large contiguous memory requirement, driver creates multiple segments and provide the list of segments. Each segment size should be 4K which is a hardware requirement. An element array is contiguous or segmented. A contiguous element array is located in contiguous physical memory. A contiguous element array must be aligned on an element size boundary. An element's physical address within the array may be directly calculated from the base address, the Producer/Consumer index, and the element size. Expected phased identifier bit is used to find out valid entry on reply queue. Driver sets <ephase> bit and IOC inverts the value of this bit on each pass. Link: https://lore.kernel.org/r/20210520152545.2710479-4-kashyap.desai@broadcom.com Cc: sathya.prakash@broadcom.com Reviewed-by: Hannes Reinecke <hare@suse.de> Reviewed-by: Tomas Henzl <thenzl@redhat.com> Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com> Signed-off-by: Kashyap Desai <kashyap.desai@broadcom.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2021-06-02scsi: mpi3mr: Base driver codeKashyap Desai1-0/+1805
Implement basic pci device driver requirements: Device probing, memory allocation, mapping system registers, allocate irq lines, etc. Source is managed in mainly three different files: - mpi3mr_fw.c: Common code which interacts with underlying fw/hw. - mpi3mr_os.c: Common code which interacts with SCSI midlayer. - mpi3mr_app.c: Common code which interacts with application/ioctl. This is currently work in progress. Link: https://lore.kernel.org/r/20210520152545.2710479-3-kashyap.desai@broadcom.com Cc: sathya.prakash@broadcom.com Cc: bvanassche@acm.org Reviewed-by: Hannes Reinecke <hare@suse.de> Reviewed-by: Tomas Henzl <thenzl@redhat.com> Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com> Signed-off-by: Kashyap Desai <kashyap.desai@broadcom.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>