aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2022-10-01scsi: target: core: UA on all LUNs after resetDmitry Bogdanov3-2/+21
Allocate UNIT ATTENTION "BUS DEVICE RESET OCCURRED" on all LUNs on all target ports of the device upon reception of TMF LUN RESET. This change passes libiscsi test SCSI.MultipathIO.Reset. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Dmitry Bogdanov <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2022-10-01scsi: target: core: New key must be used for moved PRDmitry Bogdanov1-2/+6
According to SPC4 5.12.8: e) Retain the reservation key specified in the SERVICE ACTION RESERVATION KEY field and associated information; But currently sa_res_key is only used for the not existing I_T nexus. Add a changing of the key for the existing I_T nexus the PR moved to. Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Mike Christie <[email protected]> Signed-off-by: Dmitry Bogdanov <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2022-10-01scsi: target: core: Abort all preempted regs if requestedDmitry Bogdanov1-1/+15
According to SPC the preempted commands shall be always aborted. SPC-4: 5.12.11.2.6 Preempting and aborting c) all commands from the I_T nexus(es) associated with the persistent reservations or registrations being preempted (i.e., preempted commands) except the PERSISTENT RESERVE OUT command itself shall be aborted as defined in SAM-5; Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Mike Christie <[email protected]> Signed-off-by: Dmitry Bogdanov <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2022-10-01scsi: target: core: Fix memory leak in preempt_and_abortDmitry Bogdanov1-4/+5
Always release preempt_and_abort_list to avoid memory leak of t10_pr_registration objects in it. Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Mike Christie <[email protected]> Signed-off-by: Dmitry Bogdanov <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2022-10-01scsi: target: core: Fix preempt and abort for allreg resDmitry Bogdanov1-1/+1
Match a key only if SARK is not zero according to SPC-4 and the comment above the code: If an all registrants persistent reservation is present and the SERVICE ACTION RESERVATION KEY field is set to zero, then all registrations shall be removed except for that of the I_T nexus that is being used for the PERSISTENT RESERVE OUT command; Without this patch in case of SARK==0 no registrants will be removed. Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Mike Christie <[email protected]> Signed-off-by: Dmitry Bogdanov <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2022-09-25scsi: iscsi: iscsi_tcp: Fix null-ptr-deref while calling getpeername()Mike Christie2-21/+55
Fix a NULL pointer crash that occurs when we are freeing the socket at the same time we access it via sysfs. The problem is that: 1. iscsi_sw_tcp_conn_get_param() and iscsi_sw_tcp_host_get_param() take the frwd_lock and do sock_hold() then drop the frwd_lock. sock_hold() does a get on the "struct sock". 2. iscsi_sw_tcp_release_conn() does sockfd_put() which does the last put on the "struct socket" and that does __sock_release() which sets the sock->ops to NULL. 3. iscsi_sw_tcp_conn_get_param() and iscsi_sw_tcp_host_get_param() then call kernel_getpeername() which accesses the NULL sock->ops. Above we do a get on the "struct sock", but we needed a get on the "struct socket". Originally, we just held the frwd_lock the entire time but in commit bcf3a2953d36 ("scsi: iscsi: iscsi_tcp: Avoid holding spinlock while calling getpeername()") we switched to refcount based because the network layer changed and started taking a mutex in that path, so we could no longer hold the frwd_lock. Instead of trying to maintain multiple refcounts, this just has us use a mutex for accessing the socket in the interface code paths. Link: https://lore.kernel.org/r/[email protected] Fixes: bcf3a2953d36 ("scsi: iscsi: iscsi_tcp: Avoid holding spinlock while calling getpeername()") Signed-off-by: Mike Christie <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2022-09-25scsi: mpi3mr: Remove unnecessary castJules Irenge1-2/+1
coccinelle reports a warning: WARNING: casting value returned by memory allocation function to (struct mpi3mr_throttle_group_info *) is useless To fix this, the unnecessary cast is removed. Link: https://lore.kernel.org/r/Yx+kp8NxHvDHs7dv@playground Signed-off-by: Jules Irenge <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2022-09-25scsi: stex: Properly zero out the passthrough command structureLinus Torvalds2-9/+10
The passthrough structure is declared off of the stack, so it needs to be set to zero before copied back to userspace to prevent any unintentional data leakage. Switch things to be statically allocated which will fill the unused fields with 0 automatically. Link: https://lore.kernel.org/r/[email protected] Cc: [email protected] Cc: "James E.J. Bottomley" <[email protected]> Cc: "Martin K. Petersen" <[email protected]> Cc: Dan Carpenter <[email protected]> Reported-by: hdthky <[email protected]> Signed-off-by: Linus Torvalds <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2022-09-25scsi: mpi3mr: Update driver version to 8.2.0.3.0Sreekanth Reddy1-2/+2
Update driver version to 8.2.0.3.0. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Sreekanth Reddy <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2022-09-25scsi: mpi3mr: Fix scheduling while atomic type bugSreekanth Reddy2-6/+5
Fix 'scheduling while atomic' type bug, which is observed when pci_irq_vector() is called from interrupt context. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Sreekanth Reddy <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2022-09-25scsi: mpi3mr: Scan the devices during resume timeSreekanth Reddy3-5/+9
Scan the target devices during system resume time and add or remove the target device with the SML if the corresponding target device is newly added or removed respectively. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Sreekanth Reddy <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2022-09-25scsi: mpi3mr: Free enclosure objects during driver unloadSreekanth Reddy3-0/+24
Free the enclosure device objects during driver unload and before rescanning the target devices during controller 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-09-25scsi: mpi3mr: Handle 0xF003 Fault CodeSreekanth Reddy1-1/+2
Handle the 0xF003 controller fault code as a special case by marking the controller as unrecoverable with logging a message indicating the driver marks the controller as unrecoverable due to the specific fault. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Sreekanth Reddy <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2022-09-25scsi: mpi3mr: Graceful handling of surprise removal of PCIe HBASreekanth Reddy3-8/+145
Implement graceful handling of surprise or orderly removal of PCIe HBA: - Detect a hot removal of the controller at certain critical places in the driver. Early detection will help to reduce the time taken for cleaning up the hot-removed controller at the driver level. - Poll the status of the port enable issued after reset once every 5 seconds to avoid a long delay in detecting unavailable controller. Link: https://lore.kernel.org/r/[email protected] Reported-by: kernel test robot <[email protected]> Signed-off-by: Sreekanth Reddy <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2022-09-25scsi: mpi3mr: Schedule IRQ kthreads only on non-RT kernelsSreekanth Reddy1-1/+15
In RT kernels, the IRQ handler's code is executed as a kernel thread. Modify the driver to avoid explicitly scheduling the IRQ kernel thread. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Sreekanth Reddy <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2022-09-25scsi: mpi3mr: Support new power management frameworkSreekanth Reddy1-20/+13
Switch to the new generic PCI power management framework. Also, remove unnecessary calls to the PCI helper functions (such as pci_set_power_state(), pci_enable_wake(), pci_save_state(), pci_restore_state() etc). Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Sreekanth Reddy <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2022-09-25scsi: mpi3mr: Update mpi3 header filesSreekanth Reddy7-52/+165
Update the mpi3 header files. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Sreekanth Reddy <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2022-09-25scsi: mpt3sas: Revert "scsi: mpt3sas: Fix ioc->base_readl() use"Damien Le Moal1-6/+7
This reverts commit 7ab4d2441b952977556672c2fe3f4c2a698cbb37 as it is breaking the mpt3sas driver on big-endian machines. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Damien Le Moal <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2022-09-25scsi: mpt3sas: Revert "scsi: mpt3sas: Fix writel() use"Damien Le Moal1-5/+5
This reverts commit b4efbec4c2a75b619fae4e8768be379e88c78687 as it is breaking the mpt3sas driver on big-endian machines. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Damien Le Moal <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2022-09-25scsi: wd33c93: Remove dead code related to the long-gone config WD33C93_PIOLukas Bulwahn2-65/+0
The historical commit 5e018f7e60c9 ("Remove PC9800 support") from 2004 in linux's history.git removed the config WD33C93_PIO to tweak the scsi wd33c93 driver for the PC9800. Some dead code in drivers/scsi/wd33c93.[ch] under an ifdef WD33C93_PIO continued to remain in the repository until now. Remove this dead code. This issue was discovered with ./scripts/checkkconfigsymbols.py. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Lukas Bulwahn <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2022-09-25scsi: core: Add I/O timeout count for SCSI deviceWu Bo3-0/+4
Currently struct scsi_device maintains counters for requests, completions, and errors but is missing a counter for timeouts. For better tracking of timeouts, add a suitable counter. Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Bart Van Assche <[email protected]> Signed-off-by: Wu Bo <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2022-09-25scsi: qedf: Populate sysfs attributes for vportSaurav Kashyap1-0/+21
Few vport parameters were displayed by systool as 'Unknown' or 'NULL'. Copy speed, supported_speed, frame_size and update port_type for NPIV port. Link: https://lore.kernel.org/r/[email protected] Cc: [email protected] Tested-by: Guangwu Zhang <[email protected]> Reviewed-by: John Meneghini <[email protected]> Signed-off-by: Saurav Kashyap <[email protected]> Signed-off-by: Nilesh Javali <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2022-09-25scsi: pm8001: Replace one-element array with flexible-array memberGustavo A. R. Silva1-1/+1
One-element arrays are deprecated, and we are replacing them with flexible array members instead. So, replace one-element array with flexible-array member in struct fw_control_info. This helps with the ongoing efforts to tighten the FORTIFY_SOURCE routines on memcpy() and help us make progress towards globally enabling -fstrict-flex-arrays=3 [1]. Link: https://github.com/KSPP/linux/issues/79 Link: https://github.com/KSPP/linux/issues/207 Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101836 [1] Link: https://lore.kernel.org/r/Yyy31OuBza1FJCXP@work Reviewed-by: Kees Cook <[email protected]> Acked-by: Jack Wang <[email protected]> Signed-off-by: Gustavo A. R. Silva <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2022-09-25scsi: 3w-xxxx: Replace one-element array with flexible-array memberGustavo A. R. Silva2-8/+8
One-element arrays are deprecated, and we are replacing them with flexible array members instead. So, replace one-element array with flexible-array member in struct TAG_TW_New_Ioctl and refactor the rest of the code, accordingly. Notice that, in multiple places, the subtraction of 1 from sizeof(TW_New_Ioctl) is removed, as this operation is now implicit after the flex-array transformation. Link: https://github.com/KSPP/linux/issues/79 Link: https://github.com/KSPP/linux/issues/206 Link: https://lore.kernel.org/r/YyyyvB30jnjRaw/F@work Reviewed-by: Kees Cook <[email protected]> Signed-off-by: Gustavo A. R. Silva <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2022-09-25scsi: hptiop: Replace one-element array with flexible-array member in struct ↵Gustavo A. R. Silva1-1/+1
hpt_iop_request_ioctl_command() One-element arrays are deprecated, and we are replacing them with flexible array members instead. So, replace one-element array with flexible-array member in struct hpt_iop_request_ioctl_command. Link: https://github.com/KSPP/linux/issues/79 Link: https://github.com/KSPP/linux/issues/205 Link: https://lore.kernel.org/r/YyyUvuId7dAZadej@work Reviewed-by: Kees Cook <[email protected]> Signed-off-by: Gustavo A. R. Silva <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2022-09-25scsi: hptiop: Use struct_size() helper in code related to struct ↵Gustavo A. R. Silva1-5/+3
hpt_iop_request_scsi_command Prefer struct_size() over open-coded versions of idiom: sizeof(struct-with-flex-array) + sizeof(typeof-flex-array-elements) * count where count is the max number of items the flexible array is supposed to contain. Link: https://github.com/KSPP/linux/issues/160 Link: https://lore.kernel.org/r/54e2bb1e39b21394c5a90cacbadfb6136b012788.1663865333.git.gustavoars@kernel.org Reviewed-by: Kees Cook <[email protected]> Signed-off-by: Gustavo A. R. Silva <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2022-09-25scsi: hptiop: Replace one-element array with flexible-array memberGustavo A. R. Silva2-3/+2
One-element arrays are deprecated, and we are replacing them with flexible array members instead. So, replace one-element array with flexible-array member in struct hpt_iop_request_scsi_command and refactor the rest of the code, accordingly. The following pieces of code suggest that the one element of array sg_list in struct hpt_iop_request_scsi_command is not taken into account when calculating the total size for both struct hpt_iop_request_scsi_command and the maximum number of elements sg_list will contain: 1047 req->header.size = cpu_to_le32( 1048 sizeof(struct hpt_iop_request_scsi_command) 1049 - sizeof(struct hpt_iopsg) 1050 + sg_count * sizeof(struct hpt_iopsg)); 1400 req_size = sizeof(struct hpt_iop_request_scsi_command) 1401 + sizeof(struct hpt_iopsg) * (hba->max_sg_descriptors - 1); So it's safe to replace the one-element array with a flexible-array member and update the code above, accordingly: now we don't need to subtract sizeof(struct hpt_iopsg) from sizeof(struct hpt_iop_request_scsi_command) because this is implicitly done by the flex-array transformation. Link: https://github.com/KSPP/linux/issues/79 Link: https://github.com/KSPP/linux/issues/205 Link: https://lore.kernel.org/r/6238ccf37798e36d783f5ce5e483e6837e98be79.1663865333.git.gustavoars@kernel.org Reviewed-by: Kees Cook <[email protected]> Signed-off-by: Gustavo A. R. Silva <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2022-09-25scsi: pm8001: Fix running_req for internal abort commandsJohn Garry1-0/+4
Disabling the remote phy for a SATA disk causes a hang: root@(none)$ more /sys/class/sas_phy/phy-0:0:8/target_port_protocols sata root@(none)$ echo 0 > sys/class/sas_phy/phy-0:0:8/enable root@(none)$ [ 67.855950] sas: ex 500e004aaaaaaa1f phy08 change count has changed [ 67.920585] sd 0:0:2:0: [sdc] Synchronizing SCSI cache [ 67.925780] sd 0:0:2:0: [sdc] Synchronize Cache(10) failed: Result: hostbyte=0x04 driverbyte=DRIVER_OK [ 67.935094] sd 0:0:2:0: [sdc] Stopping disk [ 67.939305] sd 0:0:2:0: [sdc] Start/Stop Unit failed: Result: hostbyte=0x04 driverbyte=DRIVER_OK ... [ 123.998998] INFO: task kworker/u192:1:642 blocked for more than 30 seconds. [ 124.005960] Not tainted 6.0.0-rc1-205202-gf26f8f761e83 #218 [ 124.012049] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message. [ 124.019872] task:kworker/u192:1 state:D stack:0 pid: 642 ppid: 2 flags:0x00000008 [ 124.028223] Workqueue: 0000:04:00.0_event_q sas_port_event_worker [ 124.034319] Call trace: [ 124.036758] __switch_to+0x128/0x278 [ 124.040333] __schedule+0x434/0xa58 [ 124.043820] schedule+0x94/0x138 [ 124.047045] schedule_timeout+0x2fc/0x368 [ 124.051052] wait_for_completion+0xdc/0x200 [ 124.055234] __flush_workqueue+0x1a8/0x708 [ 124.059328] sas_porte_broadcast_rcvd+0xa8/0xc0 [ 124.063858] sas_port_event_worker+0x60/0x98 [ 124.068126] process_one_work+0x3f8/0x660 [ 124.072134] worker_thread+0x70/0x700 [ 124.075793] kthread+0x1a4/0x1b8 [ 124.079014] ret_from_fork+0x10/0x20 The issue is that the per-device running_req read in pm8001_dev_gone_notify() never goes to zero and we never make progress. This is caused by missing accounting for running_req for when an internal abort command completes. In commit 2cbbf489778e ("scsi: pm8001: Use libsas internal abort support") we started to send internal abort commands as a proper sas_task. In this when we deliver a sas_task to HW the per-device running_req is incremented in pm8001_queue_command(). However it is never decremented for internal abort commnds, so decrement in pm8001_mpi_task_abort_resp(). Link: https://lore.kernel.org/r/[email protected] Fixes: 2cbbf489778e ("scsi: pm8001: Use libsas internal abort support") Acked-by: Jack Wang <[email protected]> Signed-off-by: John Garry <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2022-09-25scsi: libsas: Fix use-after-free bug in smp_execute_task_sg()Duoming Zhou1-1/+1
When executing SMP task failed, the smp_execute_task_sg() calls del_timer() to delete "slow_task->timer". However, if the timer handler sas_task_internal_timedout() is running, the del_timer() in smp_execute_task_sg() will not stop it and a UAF will happen. The process is shown below: (thread 1) | (thread 2) smp_execute_task_sg() | sas_task_internal_timedout() ... | del_timer() | ... | ... sas_free_task(task) | kfree(task->slow_task) //FREE| | task->slow_task->... //USE Fix by calling del_timer_sync() in smp_execute_task_sg(), which makes sure the timer handler have finished before the "task->slow_task" is deallocated. Link: https://lore.kernel.org/r/[email protected] Fixes: 2908d778ab3e ("[SCSI] aic94xx: new driver") Reviewed-by: Jason Yan <[email protected]> Signed-off-by: Duoming Zhou <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2022-09-25scsi: scsi_transport_fc: Adjust struct fc_nl_event flex array usageKees Cook2-5/+10
In order to help the compiler reason about the destination buffer in struct fc_nl_event, add a flexible array member for this purpose. However, since the header is UAPI, it must not change size or layout, so a union is used. The allocation size calculations are also corrected (it was potentially allocating an extra 8 bytes), and the padding is zeroed to avoid leaking kernel heap memory contents. Detected at run-time by the recently added memcpy() bounds checking: memcpy: detected field-spanning write (size 8) of single field "&event->event_data" at drivers/scsi/scsi_transport_fc.c:581 (size 4) Link: https://lore.kernel.org/linux-next/[email protected]/ Link: https://lore.kernel.org/r/[email protected] Cc: "James E.J. Bottomley" <[email protected]> Cc: "Martin K. Petersen" <[email protected]> Cc: [email protected] Reported-by: Sachin Sant <[email protected]> Tested-by: Sachin Sant <[email protected]> Reviewed-by: James Smart <[email protected]> Signed-off-by: Kees Cook <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2022-09-25scsi: ufs: core: Remove redundant function definitions from ufshcd.hArthur Simchaev2-20/+5
Remove Query-Request API function declarations from include/ufs/ufshcd.h and move them to the ufs core private header. Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Bean Huo <[email protected]> Reviewed-by: Bart Van Assche <[email protected]> Signed-off-by: Arthur Simchaev <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2022-09-25scsi: core: Make SCSI_MOD depend on BLOCK for cleaner .config filesLukas Bulwahn1-3/+4
SCSI_MOD is a helper config symbol for configuring RAID_ATTRS properly, i.e., RAID_ATTRS needs to be m when SCSI=m. This helper config symbol SCSI_MOD still shows up even in kernel configurations that do not select the block subsystem and where SCSI is not even a configuration option mentioned and selectable. Make this SCSI_MOD depend on BLOCK, so that it only shows up when it is slightly relevant in the kernel configuration. Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Bart Van Assche <[email protected]> Signed-off-by: Lukas Bulwahn <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2022-09-25scsi: tracing: Fix compile error in trace_array calls when TRACING is disabledArun Easi1-2/+34
Fix this compilation error seen when CONFIG_TRACING is not enabled: drivers/scsi/qla2xxx/qla_os.c: In function 'qla_trace_init': drivers/scsi/qla2xxx/qla_os.c:2854:25: error: implicit declaration of function 'trace_array_get_by_name'; did you mean 'trace_array_set_clr_event'? [-Werror=implicit-function-declaration] 2854 | qla_trc_array = trace_array_get_by_name("qla2xxx"); | ^~~~~~~~~~~~~~~~~~~~~~~ | trace_array_set_clr_event drivers/scsi/qla2xxx/qla_os.c: In function 'qla_trace_uninit': drivers/scsi/qla2xxx/qla_os.c:2869:9: error: implicit declaration of function 'trace_array_put' [-Werror=implicit-function-declaration] 2869 | trace_array_put(qla_trc_array); | ^~~~~~~~~~~~~~~ Link: https://lore.kernel.org/r/[email protected] Reported-by: kernel test robot <[email protected]> Reviewed-by: Steven Rostedt (Google) <[email protected]> Signed-off-by: Arun Easi <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2022-09-15scsi: scsi_transport_fc: Use %u for dev_loss_tmoMartin Wilck1-1/+1
dev_loss_tmo is an unsigned value. Using "%d" as output format causes irritating negative values to be shown in sysfs. Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Steffen Maier <[email protected]> Signed-off-by: Martin Wilck <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2022-09-15scsi: csiostor: Convert sysfs snprintf() to sysfs_emit()Xuezhi Zhang1-5/+5
Follow the advice of the Documentation/filesystems/sysfs.rst and show() should only use sysfs_emit() or sysfs_emit_at() when formatting the value to be returned to user space. Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Damien Le Moal <[email protected]> Signed-off-by: Xuezhi Zhang <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2022-09-15scsi: megaraid: Convert sysfs snprintf() to sysfs_emit()Xuezhi Zhang1-2/+2
Fix up sysfs show entries to use sysfs_emit() Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Damien Le Moal <[email protected]> Signed-off-by: Xuezhi Zhang <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2022-09-15scsi: ibmvscsi_tgt: Fix repeated words in commentwangjianli1-1/+1
Delete the redundant word 'to'. Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Chaitanya Kulkarni <[email protected]> Signed-off-by: wangjianli <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2022-09-15scsi: lpfc: Update lpfc version to 14.2.0.7James Smart1-1/+1
Update lpfc version to 14.2.0.7 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-09-15scsi: lpfc: Fix various issues reported by toolsJames Smart6-118/+148
This patch fixes below Smatch reported issues: 1. lpfc_hbadisc.c:3020 lpfc_mbx_cmpl_fcf_rr_read_fcf_rec() error: uninitialized symbol 'vlan_id'. 2. lpfc_hbadisc.c:3121 lpfc_mbx_cmpl_read_fcf_rec() error: uninitialized symbol 'vlan_id'. 3. lpfc_init.c:335 lpfc_dump_wakeup_param_cmpl() warn: always true condition '(prg->dist < 4) => (0-3 < 4)' 4. lpfc_init.c:2419 lpfc_parse_vpd() warn: inconsistent indenting. 5. lpfc_init.c:13248 lpfc_sli4_enable_msi() warn: 'phba->pcidev->irq' 2147483648 can't fit into 65535 'eqhdl->irq' 6. lpfc_debugfs.c:5300 lpfc_idiag_extacc_avail_get() error: uninitialized symbol 'ext_cnt' 7. lpfc_debugfs.c:5300 lpfc_idiag_extacc_avail_get() error: uninitialized symbol 'ext_size' 8. lpfc_vmid.c:248 lpfc_vmid_get_appid() warn: sleeping in atomic context. 9. lpfc_init.c:8342 lpfc_sli4_driver_resource_setup() warn: missing error code 'rc'. 10. lpfc_init.c:13573 lpfc_sli4_hba_unset() warn: variable dereferenced before check 'phba->pport' (see line 13546) 11. lpfc_auth.c:1923 lpfc_auth_handle_dhchap_reply() error: double free of 'hash_value' Fixes: 1. Initialize vlan_id to LPFC_FCOE_NULL_VID. 2. Initialize vlan_id to LPFC_FCOE_NULL_VID. 3. prg->dist is a 2 bit field. Its value can only be between 0-3. Remove redundent check 'if (prg->dist < 4)'. 4. Fix inconsistent indenting. Moved logic into helper function lpfc_fill_vpd(). 5. Define 'eqhdl->irq' as int value as pci_irq_vector() returns int. Also, check for return value of pci_irq_vector() and log message in case of failure. 6. Initialize 'ext_cnt' to 0. 7. Initialize 'ext_size' to 0. 8. Use alloc_percpu_gfp() with GFP_ATOMIC flag. 9. 'rc' was not updated when dma_pool_create() fails. Update 'rc = -ENOMEM' when dma_pool_create() fails before calling goto statement. 10. Add check for 'phba->pport' in lpfc_cpuhp_remove(). 11. Initialize 'hash_value' to NULL, same like 'aug_chal' variable. 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-09-15scsi: lpfc: Add reporting capability for Link Degrade SignalingJames Smart8-68/+224
Firmware reports link degrade signaling via ACQES. Handlers and new additions to the SET_FEATURES mbox command are implemented so that link degrade parameters for 64GB capable links are reported through EDC ELS frames. 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-09-15scsi: lpfc: Rework FDMI attribute registration for unintential paddingJames Smart2-669/+350
Removed the lpfc_fdmi_attr_entry and lpfc_fdmi_attr_def structures that had a union causing unintentional zero padding, which required the usage of __packed. They are replaced with explicit lpfc_fdmi_attr_u32, lpfc_fdmi_attr_wwn, lpfc_fdmi_attr_fc4types, and lpfc_fdmi_attr_string structure defines instead of living in a union. This rids of ambiguous compiler zero padding, and entailed cleaning up bitwise endian declarations. As such, all FDMI attribute registration routines are replaced with generic void *arg and handlers for each of the newly defined attribute structure types. 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-09-15scsi: lpfc: Rework lpfc_fdmi_cmd() routine for cleanup and consistencyJames Smart1-23/+30
Switch case logics are reworked so they appear more similar and consistent. This eliminates compiler errors indicating unaligned pointer values and packed members. Added comments to explain previous size offset accumulations. 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-09-15scsi: lpfc: Rename mp/bmp dma buffers to rq/rsp in lpfc_fdmi_cmdJames Smart1-31/+32
Clarify naming of the mp/bmp dma buffers: - Rename mp to rq as it is the request buffer - Rename bmp to rsp as it is the response buffer This reduces confusion about what the buffer content is based on their name. 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-09-15scsi: lpfc: Update congestion mode logging for Emulex SAN Manager applicationJames Smart1-6/+22
If there is a congestion or automated congestion response mode change, then log the reported change to kmsg. 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-09-15scsi: lpfc: Move scsi_host_template outside dynamically allocated/freed phbaJames Smart4-34/+48
On a PCI hotplug capable system, it is possible for scsi_device_put() to happen after lpfc_pci_remove_one() is called. As a result, the sdev->host->hostt->module dereference is for a previously freed memory location because the phba structure containing the hostt template was already freed when lpfc_pci_remove_one() returned. Since the lpfc module is still loaded during power slot disable, all scsi_host_templates should be declared as part of the global data segment instead of inside the heap allocated phba structure. This way the sdev->host->hostt memory area is always valid as long as the module is loaded regardless if PCI hotplug dynamically allocates or frees phba structures. Move all scsi_host_templates in the phba structure to global variables. Create a small helper routine to determine appropriate sg_tablesize during shost allocation. Link: https://lore.kernel.org/r/[email protected] Co-developed-by: Dwip N. Banerjee <[email protected]> Signed-off-by: Dwip N. Banerjee <[email protected]> Co-developed-by: Daniel Wagner <[email protected]> Signed-off-by: Daniel Wagner <[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-09-15scsi: lpfc: Fix multiple NVMe remoteport registration calls for the same ↵James Smart3-41/+37
NPort ID When a target makes the mistake of registering a FC4 type with the fabric, but then rejects a PRLI of that type, the lpfc driver incorrectly retries the PRLI causing multiple registrations with the transport. The driver needs to detect the reject reason data and stop any retry. Rework the PRLI reject scenarios. 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-09-15scsi: lpfc: Add missing free iocb and nlp kref put for early return VMID casesJames Smart1-3/+7
Sometimes VMID targets are not getting rediscovered after a port reset. The iocb is not freed in lpfc_cmpl_ct_cmd_vmid(), which is the completion function for the appid CT commands. So after a port reset, the count of sges is less than the expected count of 250. This causes post reset operation logic to fail and keep the port offline. Fix by freeing the iocb and kref put for the lpfc_cmpl_ct_cmd_vmid() early return cases. 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-09-15scsi: lpfc: Fix mbuf pool resource detected as busy at driver unloadJames Smart1-0/+7
In a situation where the node state changes while a REG_LOGIN is in progress, the LPFC_MBOXQ_t structure is cleared and reused for an UNREG_LOGIN command to release RPI resources without first freeing the mbuf pool resource allocated for REG_LOGIN. Release mbuf pool resource prior to repurposing of the mailbox command structure from REG_LOGIN to UNREG_LOGIN. 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-09-15scsi: lpfc: Fix FLOGI ACC with wrong SID in PT2PT topologyJames Smart1-2/+7
When a FLOGI is received before we have issued our FLOGI, the ACC response to the received FLOGI is issued with SID 2 instead of the expected fabric controller SID. Certain target vendors ignore the malformed ACC with SID 2 and wait for a properly filled ACC with a fabric controller SID. The lpfc_sli_prep_wqe() routine depends on the FC_PT2PT flag to fill in the fabric controller SID when in PT2PT mode, but due to a previous commit the flag was getting cleared. Fix by adding a check for the defer_flogi_acc flag to know whether or not to clear the FC_PT2PT flag on link up. Link: https://lore.kernel.org/r/[email protected] Fixes: 439b93293ff2 ("scsi: lpfc: Fix unsolicited FLOGI receive handling during PT2PT discovery") 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-09-15scsi: lpfc: Fix prli_fc4_req checks in PRLI handlingJames Smart1-2/+2
The if statment check (prli_fc4_req & PRLI_NVME_TYPE) evaluates to true when receiving a PRLI request for bogus FC4 type codes that happen to have the 3rd or 5th bit set because PRLI_NVME_TYPE is 0x28. This leads to sending a PRLI_NVME_ACC even for bogus FC4 type codes. Change the bitwise & check to an exact == type code check to ensure we send PRLI_NVME_ACC only for NVME type coded PRLI requests. 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]>