aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2022-05-19scsi: elx: efct: Remove NULL check after calling container_of()Haowen Bai1-3/+0
container_of() will never return NULL. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Haowen Bai <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2022-05-19scsi: dpt_i2o: Drop redundant spinlock initializationHaowen Bai1-1/+0
adpt_post_wait_lock was declared and initialized by DEFINE_SPINLOCK so we don't need to call spin_lock_init(). Drop the call. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Haowen Bai <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2022-05-19scsi: qedf: Remove redundant variable opColin Ian King1-2/+1
The variable 'op' is assigned a value and is never read. The variable is not used and is redundant, remove it. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Colin Ian King <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2022-05-19scsi: hisi_sas: Fix memory ordering in hisi_sas_task_deliver()John Garry1-0/+2
The memories for the slot should be observed to be written prior to observing the slot as ready. Prior to commit 26fc0ea74fcb ("scsi: libsas: Drop SAS_TASK_AT_INITIATOR"), we had a spin_lock() + spin_unlock() immediately before marking the slot as ready. The spin_unlock() - with release semantics - caused the slot memory to be observed to be written. Now that the spin_lock() + spin_unlock() is gone, use a smp_wmb(). Link: https://lore.kernel.org/r/[email protected] Fixes: 26fc0ea74fcb ("scsi: libsas: Drop SAS_TASK_AT_INITIATOR") Reported-by: Yihang Li <[email protected]> Tested-by: Yihang Li <[email protected]> Signed-off-by: John Garry <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2022-05-19scsi: fnic: Replace DMA mask of 64 bits with 47 bitsKaran Tilak Kumar2-4/+4
Cisco VIC supports only 47 bits. If the host sends DMA addresses that are greater than 47 bits, it causes work queue (WQ) errors in the VIC. Link: https://lore.kernel.org/r/[email protected] Tested-by: Karan Tilak Kumar <[email protected]> Co-developed-by: Dhanraj Jhawar <[email protected]> Signed-off-by: Dhanraj Jhawar <[email protected]> Co-developed-by: Sesidhar Baddela <[email protected]> Signed-off-by: Sesidhar Baddela <[email protected]> Signed-off-by: Arulprabhu Ponnusamy <[email protected]> Signed-off-by: Karan Tilak Kumar <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2022-05-19scsi: mpi3mr: Add target device related sysfs attributesSreekanth Reddy3-0/+122
Add sysfs attributes for exposing target device details such as SAS address, firmware device handle, and persistent ID for the controller-attached devices and RAID volumes. Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Himanshu Madhani <[email protected]> Signed-off-by: Sreekanth Reddy <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2022-05-19scsi: mpi3mr: Add shost related sysfs attributesSreekanth Reddy1-2/+141
Add shost related sysfs attributes to display the controller's firmware version, queue depth, number of requests, and number of reply queues. Also add an attribute to set & get the logging_level. Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Himanshu Madhani <[email protected]> Signed-off-by: Sreekanth Reddy <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2022-05-19scsi: elx: efct: Remove redundant memset() statementHarshit Mogalapalli1-1/+0
As memset() of bmbx is immediately followed by a memcpy() where bmbx is the destination, the memset() is redundant. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Harshit Mogalapalli <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2022-05-19scsi: megaraid_sas: Remove redundant memset() statementHarshit Mogalapalli1-2/+0
As memset() of scmd->sense_buffer is immediately followed by a memcpy() where scmd->sense_buffer is the destination. The memset() is redundant. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Harshit Mogalapalli <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2022-05-19scsi: mpi3mr: Return error if dma_alloc_coherent() failsDan Carpenter1-2/+6
Return -ENOMEM instead of success if dma_alloc_coherent() fails. Link: https://lore.kernel.org/r/YnOmMGHqCOtUCYQ1@kili Fixes: 43ca11005098 ("scsi: mpi3mr: Add support for PEL commands") Signed-off-by: Dan Carpenter <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2022-05-19scsi: hisi_sas: Fix rescan after deleting a diskJohn Garry1-29/+18
Removing an ATA device via sysfs means that the device may not be found through re-scanning: root@ubuntu:/home/john# lsscsi [0:0:0:0] disk SanDisk LT0200MO P404 /dev/sda [0:0:1:0] disk ATA HGST HUS724040AL A8B0 /dev/sdb [0:0:8:0] enclosu 12G SAS Expander RevB - root@ubuntu:/home/john# echo 1 > /sys/block/sdb/device/delete root@ubuntu:/home/john# echo "- - -" > /sys/class/scsi_host/host0/scan root@ubuntu:/home/john# lsscsi [0:0:0:0] disk SanDisk LT0200MO P404 /dev/sda [0:0:8:0] enclosu 12G SAS Expander RevB - root@ubuntu:/home/john# The problem is that the rescan of the device may conflict with the device in being re-initialized, as follows: - In the rescan we call hisi_sas_slave_alloc() in store_scan() -> sas_user_scan() -> [__]scsi_scan_target() -> scsi_probe_and_add_lunc() -> scsi_alloc_sdev() -> hisi_sas_slave_alloc() -> hisi_sas_init_device() In hisi_sas_init_device() we issue an IT nexus reset for ATA devices - That IT nexus causes the remote PHY to go down and this triggers a bcast event - In parallel libsas processes the bcast event, finds that the phy is down and marks the device as gone The hard reset issued in hisi_sas_init_device() is unncessary - as described in the code comment - so remove it. Also set dev status as HISI_SAS_DEV_NORMAL as the hisi_sas_init_device() call. Link: https://lore.kernel.org/r/[email protected] Fixes: 36c6b7613ef1 ("scsi: hisi_sas: Initialise devices in .slave_alloc callback") Tested-by: Yihang Li <[email protected]> Reviewed-by: Xiang Chen <[email protected]> Signed-off-by: John Garry <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2022-05-19scsi: hisi_sas: Use sas_ata_wait_after_reset() in IT nexus resetJohn Garry1-7/+12
We have seen errors like this when a SATA device is probed: [524.566298] hisi_sas_v3_hw 0000L74:02.0: erroneous completion iptt=4096 ... [524.582827] sas: TMF task open reject failed 500e004aaaaaaaa00 Since commit 21c7e972475e ("scsi: hisi_sas: Disable SATA disk phy for severe I_T nexus reset failure"), we issue an ATA softreset to disks after a phy reset to ensure that they are in sound working order. If the softreset is issued before the remote phy has come back up then the softreset will fail (errors as above). Remedy this by waiting for the phy to come back up after the reset. Link: https://lore.kernel.org/r/[email protected] Tested-by: Yihang Li <[email protected]> Reviewed-by: Xiang Chen <[email protected]> Signed-off-by: John Garry <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2022-05-19scsi: libsas: Refactor sas_ata_hard_reset()John Garry2-14/+34
Create function sas_ata_wait_after_reset() from sas_ata_hard_reset() as some LLDDs may want to check for a remote ATA phy is up after reset. Link: https://lore.kernel.org/r/[email protected] Tested-by: Yihang Li <[email protected]> Reviewed-by: Xiang Chen <[email protected]> Signed-off-by: John Garry <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2022-05-19scsi: mpt3sas: Update driver version to 42.100.00.00Sreekanth Reddy1-2/+2
Update driver version to 42.100.00.00. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Sreekanth Reddy <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2022-05-19scsi: mpt3sas: Fix junk chars displayed while printing ChipNameSreekanth Reddy1-1/+1
Terminate string after copying 16 bytes of ChipName data from Manufacturing Page0 to prevent %s from printing junk characters. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Sreekanth Reddy <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2022-05-16scsi: ipr: Use kobj_to_dev()Minghao Chi1-5/+5
Use kobj_to_dev() instead of open-coding it. Link: https://lore.kernel.org/r/[email protected] Reported-by: Zeal Robot <[email protected]> Acked-by: Brian King <[email protected]> Signed-off-by: Minghao Chi <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2022-05-16scsi: mpi3mr: Fix a NULL vs IS_ERR() bug in mpi3mr_bsg_init()Dan Carpenter1-1/+1
The bsg_setup_queue() function does not return NULL. It returns error pointers. Fix the check accordingly. Link: https://lore.kernel.org/r/YnUf7RQl+A3tigWh@kili Fixes: 4268fa751365 ("scsi: mpi3mr: Add bsg device support") Signed-off-by: Dan Carpenter <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2022-05-16scsi: bnx2fc: Avoid using get_cpu() in bnx2fc_cmd_alloc()Sebastian Andrzej Siewior1-3/+1
Using get_cpu() leads to disabling preemption and in this context it is not possible to acquire the following spinlock_t on PREEMPT_RT because it becomes a sleeping lock. Commit 0ea5c27583e1 ("[SCSI] bnx2fc: common free list for cleanup commands") says that it is using get_cpu() as a fix in case the CPU is preempted. While this might be true, the important part is that it is now using the same CPU for locking and unlocking while previously it always relied on smp_processor_id(). The date structure itself is protected with a lock so it does not rely on CPU-local access. Replace get_cpu() with raw_smp_processor_id() to obtain the current CPU number which is used as an index for the per-CPU resource. Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Davidlohr Bueso <[email protected]> Signed-off-by: Sebastian Andrzej Siewior <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2022-05-16scsi: libfc: Remove get_cpu() semantics in fc_exch_em_alloc()Davidlohr Bueso1-2/+1
The get_cpu() in fc_exch_em_alloc() was introduced in commit f018b73af6db ("[SCSI] libfc, libfcoe, fcoe: use smp_processor_id() only when preempt disabled") for no other reason than to simply use smp_processor_id() without getting a warning, because everything is done with the pool->lock held anyway. However, get_cpu(), by disabling preemption, does not play well with PREEMPT_RT, particularly when acquiring a regular (and thus sleepable) spinlock. Therefore remove the get_cpu() and just use the unstable value as we will have CPU locality guarantees next by taking the lock. The window of migration, as noted by Sebastian, is small and even if it happens the result is correct. Link: https://lore.kernel.org/r/[email protected] Link: https://lore.kernel.org/r/[email protected] Acked-by: Sebastian Andrzej Siewior <[email protected]> Signed-off-by: Davidlohr Bueso <[email protected]> Signed-off-by: Sebastian Andrzej Siewior <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2022-05-16scsi: fcoe: Use per-CPU API to update per-CPU statisticsSebastian Andrzej Siewior8-107/+62
The per-CPU statistics (struct fc_stats) is updated by getting a stable per-CPU pointer via get_cpu() + per_cpu_ptr() and then performing the increment. This can be optimized by using this_cpu_*() which will do whatever is needed on the architecture to perform the update safe and efficient. The read out of the individual value (fc_get_host_stats()) should be done by using READ_ONCE() instead of a plain-C access. The difference is that READ_ONCE() will always perform a single access while the plain-C access can be split by the compiler into two loads if it appears beneficial. The usage of u64 has the side-effect that it is also 64bit wide on 32bit architectures and the read is always split into two loads. The can lead to strange values if the read happens during an update which alters both 32bit parts of the 64bit value. This can be circumvented by either using a 32bit variables on 32bit architecures or extending the statistics with a sequence counter. Use this_cpu_*() API to update the statistics and READ_ONCE() to read it. Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Davidlohr Bueso <[email protected]> Signed-off-by: Sebastian Andrzej Siewior <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2022-05-16scsi: fcoe: Add a local_lock to fcoe_percpuDavidlohr Bueso2-2/+6
fcoe_get_paged_crc_eof() relies on the caller having preemption disabled to ensure the per-CPU fcoe_percpu context remains valid throughout the call. This is done by either holding spinlocks (such as bnx2fc_global_lock or qedf_global_lock) or the get_cpu() from fcoe_alloc_paged_crc_eof(). This last one breaks PREEMPT_RT semantics as there can be memory allocation and end up sleeping in atomic contexts. Introduce a local_lock_t to struct fcoe_percpu that will keep the non-RT case the same, mapping to preempt_disable/enable, while RT will use a per-CPU spinlock allowing the region to be preemptible but still maintain CPU locality. The other users of fcoe_percpu are already safe in this regard and do not require local_lock()ing. Link: https://lore.kernel.org/r/[email protected] Link: https://lore.kernel.org/r/[email protected] Acked-by: Sebastian Andrzej Siewior <[email protected]> Signed-off-by: Davidlohr Bueso <[email protected]> Signed-off-by: Sebastian Andrzej Siewior <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2022-05-10scsi: target: iscsi: Rename iscsi_session to iscsit_sessionMax Gurtovoy23-125/+125
The structure iscsi_session naming is used by the iSCSI initiator driver. Rename the target session to iscsit_session to have more readable code. Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Mike Christie <[email protected]> Signed-off-by: Max Gurtovoy <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2022-05-10scsi: target: iscsi: Rename iscsi_conn to iscsit_connMax Gurtovoy33-456/+456
The structure iscsi_conn naming is used by the iSCSI initiator driver. Rename the target conn to iscsit_conn to have more readable code. Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Mike Christie <[email protected]> Signed-off-by: Max Gurtovoy <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2022-05-10scsi: target: iscsi: Rename iscsi_cmd to iscsit_cmdMax Gurtovoy27-393/+393
The structure iscsi_cmd naming is used by the iSCSI initiator driver. Rename the target cmd to iscsit_cmd to have more readable code. Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Mike Christie <[email protected]> Signed-off-by: Max Gurtovoy <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2022-05-10scsi: mpi3mr: Return I/Os to an unrecoverable HBA with DID_ERRORSreekanth Reddy1-0/+6
Complete all new I/O requests issued to an unrecoverable controller with DID_ERROR status instead of returning the I/O requests with SCSI_MLQUEUE_HOST_BUSY. This will prevent the infinite retries of the new I/Os when a controller is in an unrecoverable state. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Sreekanth Reddy <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2022-05-10scsi: mpi3mr: Hidden drives not removed during soft resetSreekanth Reddy1-3/+5
If any drive is missing during reset, the driver checks whether the device is exposed to the OS. If it is, then it removes the device from the OS and its own internal list. For hidden devices, even if they are found as missing during reset, the driver is not removing them from its internal list. Modify driver to remove hidden devices from the driver's target device list if they are missing during soft reset. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Sreekanth Reddy <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2022-05-10scsi: mpi3mr: Increase I/O timeout value to 60sSreekanth Reddy2-0/+7
Set each SCSI device's default I/O timeout and default error handling I/O timeout to 60s. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Sreekanth Reddy <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2022-05-10scsi: lpfc: Update lpfc version to 14.2.0.3James Smart1-1/+1
Update lpfc version to 14.2.0.3 Link: https://lore.kernel.org/r/[email protected] Co-developed-by: Justin Tee <[email protected]> Signed-off-by: Justin Tee <[email protected]> Signed-off-by: James Smart <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2022-05-10scsi: lpfc: Use sg_dma_address() and sg_dma_len() macros for NVMe I/OJames Smart1-2/+2
NVMe I/O problems may be seen on IOMMU enabled platforms. Adapter I/Os failing with transfer length mismatches. The sg list processing routine for NVMe I/O is accessing the sg entry directly for the length and address fields. On some IOMMU platforms, contigous mappings are compressed to the first sg entry with the sum of the lengths set to the sg entry dma_length field. The length fields are left for later use by the unmap call. As such, the driver didn't see the actual dma_length value, just the first entries length value. Drivers are to use the sg_dma_length() and sg_dma_address() macros to reference the sg entry. The macros select the proper length field (dma_length or length) to reference. Fix the offending code to use the sg_dma_xxx macros. Link: https://lore.kernel.org/r/[email protected] Tested-by: Jerry Snitselaar <[email protected]> Reviewed-by: Jerry Snitselaar <[email protected]> Co-developed-by: Nigel Kirkland <[email protected]> Signed-off-by: Nigel Kirkland <[email protected]> Signed-off-by: James Smart <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2022-05-10scsi: lpfc: Alter FPIN stat accounting logicJames Smart2-54/+17
When configuring CMF management based on signals instead of FPINs, FPIN alarm and warning statistics are not tracked. Change the behavior so that FPIN alarms and warnings are always tracked regardless of the configured mode. Similar changes are made in the CMF signal stat accounting logic. Upon receipt of a signal, only track signaled alarms and warnings. FPIN stats should not be incremented upon receipt of a signal. Link: https://lore.kernel.org/r/[email protected] Co-developed-by: Justin Tee <[email protected]> Signed-off-by: Justin Tee <[email protected]> Signed-off-by: James Smart <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2022-05-10scsi: lpfc: Rework FDMI initialization after link upJames Smart5-20/+129
After a link up, it's possible for the switch to change FDMI support (e.g. FDMI1 vs FDMI2 vs SmartSAN). If the switch reverts to FDMI1, then the revert is currently not detected. Additionally, when NPIV is configured, it's possible the physical port's RHBA is unprocessed by the switch before reciept of an NPIV port issued RPRT. This causes some switches vendors to reject the NPIV's RPRT. Fix by reinitializing base FDMI mode on link up, and defer FDMI vport RPRT submission until after confirming physical port's RHBA is completed. Link: https://lore.kernel.org/r/[email protected] Co-developed-by: Justin Tee <[email protected]> Signed-off-by: Justin Tee <[email protected]> Signed-off-by: James Smart <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2022-05-10scsi: lpfc: Change VMID registration to be based on fabric parametersJames Smart4-11/+14
Currently, VMID registration is configured via module parameters. This could lead to VMID compatibility issues if two ports are connected to different brands of switches, as the two brands implement VMID differently. Make logical changes so that VMID registration is based on common service parameters from FLOGI_ACC with fabric rather than module parameters. Link: https://lore.kernel.org/r/[email protected] Co-developed-by: Justin Tee <[email protected]> Signed-off-by: Justin Tee <[email protected]> Signed-off-by: James Smart <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2022-05-10scsi: lpfc: Decrement outstanding gidft_inp counter if lpfc_err_lost_link()James Smart2-4/+17
During large NPIV port testing, it was sometimes seen that not all vports would log back in to the target device. There are instances when the fabric is slow to respond to a spam of GID_PT requests and as a result the SLI PORT may abort the GID_PT request because the fabric takes so long. lpfc_cmpl_ct_cmd_gid_pt() would enter the lpfc_err_lost_link() logic and attempt to lpfc_els_flush_rscn(), which is fine, but forgets to decrement the gidft_inp counter. This results in a vport->gidft_inp never reaching 0 and never restarting discovery again. Decrement vport->gidft_inp if lpfc_err_lost_link() is true for both lpfc_cmpl_ct_cmd_gid_pt() and lpfc_cmpl_ct_cmd_gid_ft(). Increase logging info during RSCN timeout and lpfc_err_lost_link() events. Link: https://lore.kernel.org/r/[email protected] Co-developed-by: Justin Tee <[email protected]> Signed-off-by: Justin Tee <[email protected]> Signed-off-by: James Smart <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2022-05-10scsi: lpfc: Use list_for_each_entry_safe() in rscn_recovery_check()James Smart1-2/+2
In GID_PT mode with lpfc_ns_query=1, a race condition between iterating the vport->fc_nodes list in lpfc_rscn_recovery_check() and cleanup of an ndlp can trigger a crash while processing the RSCN of another initiator from the same zone. During iteration of the vport->fc_nodes list, an ndlp is cleaned up and released. lpfc_dequeue_node() is called from lpfc_cleanup_node() leading to a bad ndlp dereference in lpfc_rscn_recovery_check(). Change list_for_each_entry() to list_for_each_entry_safe() in lpfc_rscn_recovery_check() to protect against removal of an initiator ndlp, while walking the vport->fc_nodes list. Link: https://lore.kernel.org/r/[email protected] Co-developed-by: Justin Tee <[email protected]> Signed-off-by: Justin Tee <[email protected]> Signed-off-by: James Smart <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2022-05-10scsi: lpfc: Fix dmabuf ptr assignment in lpfc_ct_reject_event()James Smart1-12/+3
Upon driver receipt of a CT cmd for type = 0xFA (Management Server) and subtype = 0x11 (Fabric Device Management Interface), the driver is responding with garbage CT cmd data when it should send a properly formed RJT. The __lpfc_prep_xmit_seq64_s4() routine was using the wrong buffer for the reject. Fix by converting the routine to use the buffer specified in the bde within the wqe rather than the ill-set bmp element. Link: https://lore.kernel.org/r/[email protected] Fixes: 61910d6a5243 ("scsi: lpfc: SLI path split: Refactor CT paths") Co-developed-by: Justin Tee <[email protected]> Signed-off-by: Justin Tee <[email protected]> Signed-off-by: James Smart <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2022-05-10scsi: lpfc: Inhibit aborts if external loopback plug is insertedJames Smart4-3/+21
After running a short external loopback test, when the external loopback is removed and a normal cable inserted that is directly connected to a target device, the system oops in the llpfc_set_rrq_active() routine. When the loopback was inserted an FLOGI was transmit. As we're looped back, we receive the FLOGI request. The FLOGI is ABTS'd as we recognize the same wppn thus understand it's a loopback. However, as the ABTS sends address information the port is not set to (fffffe), the ABTS is dropped on the wire. A short 1 frame loopback test is run and completes before the ABTS times out. The looback is unplugged and the new cable plugged in, and the an FLOGI to the new device occurs and completes. Due to a mixup in ref counting the completion of the new FLOGI releases the fabric ndlp. Then the original ABTS completes and references the released ndlp generating the oops. Correct by no-op'ing the ABTS when in loopback mode (it will be dropped anyway). Added a flag to track the mode to recognize when it should be no-op'd. Link: https://lore.kernel.org/r/[email protected] Co-developed-by: Justin Tee <[email protected]> Signed-off-by: Justin Tee <[email protected]> Signed-off-by: James Smart <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2022-05-10scsi: lpfc: Fix ndlp put following a LOGO completionJames Smart1-1/+7
During testing with repeated asynchronous resets of the target, an issue was found when the driver issues a LOGO to disconnect its login and recover all exchanges. The LOGO command takes a node reference but neglects to remove it, keeping the node reference count artifically high. Add a call to lpfc_nlp_put() to lpfc_nlp_logo_unreg() and move the mempool free call to the routine exit along with the needed put. This is always safe as this will not be the last reference removed as lpfc_unreg_rpi() ensures there is an additional reference on the ndlp. Link: https://lore.kernel.org/r/[email protected] Co-developed-by: Justin Tee <[email protected]> Signed-off-by: Justin Tee <[email protected]> Signed-off-by: James Smart <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2022-05-10scsi: lpfc: Fill in missing ndlp kref puts in error pathsJames Smart4-9/+28
Code review, following every lpfc_nlp_get() call vs calls during error handling, discovered cases of missing put calls. Correct by adding ndlp kref puts in the respective error paths. Also added comments to several of the error paths to record relationships to reference counts. Link: https://lore.kernel.org/r/[email protected] Co-developed-by: Justin Tee <[email protected]> Signed-off-by: Justin Tee <[email protected]> Signed-off-by: James Smart <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2022-05-10scsi: lpfc: Fix element offset in __lpfc_sli_release_iocbq_s4()James Smart1-1/+1
The prior commit that moved from iocb elements to explicit wqe elements missed a name change. Correct __lpfc_sli_release_iocbq_s4() to reference wqe rather than iocb. Link: https://lore.kernel.org/r/[email protected] Fixes: a680a9298e7b ("scsi: lpfc: SLI path split: Refactor lpfc_iocbq") Co-developed-by: Justin Tee <[email protected]> Signed-off-by: Justin Tee <[email protected]> Signed-off-by: James Smart <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2022-05-10scsi: ufs: ufshpb: Clean up ufshpb_suspend()/resume()Bean Huo1-11/+4
ufshpb_resume() is only called when the HPB state is HPB_SUSPEND, so the check statement for "ufshpb_get_state(hpb) != HPB_PRESENT" is useless. Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Keoseong Park <[email protected]> Signed-off-by: Bean Huo <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2022-05-10scsi: ufs: ufshpb: Add handing of device reset regions in HPB device modeBean Huo1-24/+58
In UFS HPB Spec JESD220-3A, "5.8. Active and inactive information upon power cycle ... When the device is powered off by the host, the device may restore L2P map data upon power up or build from the host's HPB READ command. In case device powered up and lost HPB information, device can signal to the host through HPB Sense data, by setting HPB Operation as '2' which will inform the host that device reset HPB information." Therefore, for HPB device control mode, if the UFS device is reset via the RST_N pin, the active region information in the device will be reset. If the host side receives this notification from the device side, it is recommended to inactivate all active regions in the host's HPB cache. Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Keoseong Park <[email protected]> Reviewed-by: Daejun Park <[email protected]> Signed-off-by: Bean Huo <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2022-05-10scsi: ufs: ufshpb: Change sysfs node hpb_stats/rb_* prefix to start with rcmd_*Bean Huo3-22/+26
According to the documentation of the sysfs nodes rb_noti_cnt, rb_active_cnt and rb_inactive_cnt, these are all related to HPB recommendation in UPIU response packet. 'rcmd' (recommendation) should be the correct abbreviation. Change the sysfs documentation about these sysfs nodes to highlight what they mean under different HPB control modes. Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Keoseong Park <[email protected]> Signed-off-by: Bean Huo <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2022-05-10scsi: ufs: ufshpb: Clean up the handler when device resets HPB informationBean Huo1-12/+23
"When the device is powered off by the host, the device may restore L2P map data upon power up or build from the host's HPB READ command. In case device powered up and lost HPB information, device can signal to the host through HPB Sense data, by setting HPB Operation as '2' which will inform the host that device reset HPB information." Clean up the handler and make the intent of this handler more readable, no functional change. Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Keoseong Park <[email protected]> Reviewed-by: Daejun Park <[email protected]> Signed-off-by: Bean Huo <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2022-05-10scsi: ufs: ufshpb: Remove enum initialization valueBean Huo1-2/+2
If the first enumerator has no initializer, the value of the corresponding constant is zero. Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Keoseong Park <[email protected]> Signed-off-by: Bean Huo <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2022-05-10scsi: ufs: ufshpb: Merge ufshpb_reset() and ufshpb_reset_host()Bean Huo3-29/+17
There is no functional change in this patch, just merge ufshpb_reset() and ufshpb_reset_host() into one function ufshpb_toggle_state(). Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Keoseong Park <[email protected]> Signed-off-by: Bean Huo <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2022-05-10scsi: ufs: qcom: Enable RPM_AUTOSUSPEND for runtime PMManivannan Sadhasivam1-0/+1
In order to allow the block devices to enter autosuspend mode during runtime, thereby allowing the ufshcd host driver to also runtime suspend, let's make use of the RPM_AUTOSUSPEND flag. Without this flag, userspace needs to enable the autosuspend feature of the block devices through sysfs. Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Bjorn Andersson <[email protected]> Signed-off-by: Manivannan Sadhasivam <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2022-05-10scsi: ufs: core: Remove redundant wmb() in ufshcd_send_command()Manivannan Sadhasivam1-3/+0
The wmb() inside ufshcd_send_command() is added to make sure that the doorbell is committed immediately. This leads to couple of expectations: 1. The doorbell write should complete before the function return. 2. The doorbell write should not cross the function boundary. 2nd expectation is fullfilled by the Linux memory model as there is a guarantee that the critical section won't cross the unlock (release) operation. 1st expectation is not really needed here as there is no following read/ write that depends on the doorbell to be complete implicitly. Even if the doorbell write is in a CPUs Write Buffer (WB), wmb() won't flush it. And there is no real need of a WB flush here as well. So let's get rid of the wmb() that seems redundant. Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Bart Van Assche <[email protected]> Reviewed-by: Bjorn Andersson <[email protected]> Acked-by: Bean Huo <[email protected]> Signed-off-by: Manivannan Sadhasivam <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2022-05-10scsi: ufs: qcom: Add a readl() to make sure ref_clk gets enabledManivannan Sadhasivam1-2/+5
In ufs_qcom_dev_ref_clk_ctrl(), it was noted that the ref_clk needs to be stable for at least 1us. Even though there is wmb() to make sure the write gets "completed", there is no guarantee that the write actually reached the UFS device. There is a good chance that the write could be stored in a Write Buffer (WB). In that case, even though the CPU waits for 1us, the ref_clk might not be stable for that period. So lets do a readl() to make sure that the previous write has reached the UFS device before udelay(). Also, the wmb() after writel_relaxed() is not really needed. Both writel() and readl() are ordered on all architectures and the CPU won't speculate instructions after readl() due to the in-built control dependency with read value on weakly ordered architectures. So it can be safely removed. Link: https://lore.kernel.org/r/[email protected] Fixes: f06fcc7155dc ("scsi: ufs-qcom: add QUniPro hardware support and power optimizations") Cc: [email protected] Reviewed-by: Bjorn Andersson <[email protected]> Signed-off-by: Manivannan Sadhasivam <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2022-05-10scsi: ufs: qcom: Simplify handling of devm_phy_get()Manivannan Sadhasivam1-22/+4
There is no need to call devm_phy_get() if ACPI is used, so skip it. The host->generic_phy pointer should already be NULL due to the kzalloc(), so no need to set it NULL again. While at it, also remove the comment that has no relationship with devm_phy_get(). Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Bjorn Andersson <[email protected]> Reviewed-by: Andrew Halaney <[email protected]> Signed-off-by: Manivannan Sadhasivam <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2022-05-10scsi: ufs: qcom: Fix acquiring the optional reset control lineManivannan Sadhasivam1-6/+5
On Qcom UFS platforms, the reset control line seems to be optional (for SoCs like MSM8996 and probably for others too). The current logic tries to mimic the devm_reset_control_get_optional() API but it also continues the probe if there is an error with the declared reset line in DT/ACPI. In an ideal case, if the reset line is not declared in DT/ACPI, the probe should continue. But if there is problem in acquiring the declared reset line (like EPROBE_DEFER) it should fail and return the appropriate error code. Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Bjorn Andersson <[email protected]> Reviewed-by: Andrew Halaney <[email protected]> Signed-off-by: Manivannan Sadhasivam <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>