OSDN Git Service

tomoyo/tomoyo-test1.git
3 years agoscsi: core: Introduce enums for the SAM and host status codes
Bart Van Assche [Mon, 24 May 2021 02:54:56 +0000 (19:54 -0700)]
scsi: core: Introduce enums for the SAM and host status codes

Make it possible for the compiler to verify whether SAM and host
status codes are used correctly.

[mkp: resolve conflicts with Hannes' SCSI result series]

Link: https://lore.kernel.org/r/20210524025457.11299-3-bvanassche@acm.org
Cc: Hannes Reinecke <hare@suse.com>
Reviewed-by: John Garry <john.garry@huawei.com>
Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: libsas: Introduce more SAM status code aliases in enum exec_status
Bart Van Assche [Mon, 24 May 2021 02:54:55 +0000 (19:54 -0700)]
scsi: libsas: Introduce more SAM status code aliases in enum exec_status

This patch prepares for converting SAM status codes into an enum. Without
this patch converting SAM status codes into an enumeration type would
trigger complaints about enum type mismatches for the SAS code.

Link: https://lore.kernel.org/r/20210524025457.11299-2-bvanassche@acm.org
Cc: Hannes Reinecke <hare@suse.com>
Cc: Artur Paszkiewicz <artur.paszkiewicz@intel.com>
Cc: Jason Yan <yanaijie@huawei.com>
Reviewed-by: John Garry <john.garry@huawei.com>
Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
Acked-by: Jack Wang <jinpu.wang@ionos.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoMerge branch '5.14/scsi-result' into 5.14/scsi-staging
Martin K. Petersen [Wed, 2 Jun 2021 05:33:12 +0000 (01:33 -0400)]
Merge branch '5.14/scsi-result' into 5.14/scsi-staging

Include Hannes' SCSI command result rework in the staging branch.

[mkp: remove DRIVER_SENSE from mpi3mr]

Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: qedi: Wake up if cmd_cleanup_req is set
Mike Christie [Tue, 25 May 2021 18:18:21 +0000 (13:18 -0500)]
scsi: qedi: Wake up if cmd_cleanup_req is set

If we got a response then we should always wake up the conn. For both the
cmd_cleanup_req == 0 or cmd_cleanup_req > 0, we shouldn't dig into
iscsi_itt_to_task because we don't know what the upper layers are doing.

We can also remove the qedi_clear_task_idx call here because once we signal
success libiscsi will loop over the affected commands and end up calling
the cleanup_task callout which will release it.

Link: https://lore.kernel.org/r/20210525181821.7617-29-michael.christie@oracle.com
Reviewed-by: Manish Rangankar <mrangankar@marvell.com>
Signed-off-by: Mike Christie <michael.christie@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: qedi: Complete TMF works before disconnect
Mike Christie [Tue, 25 May 2021 18:18:20 +0000 (13:18 -0500)]
scsi: qedi: Complete TMF works before disconnect

We need to make sure that abort and reset completion work has completed
before ep_disconnect returns. After ep_disconnect we can't manipulate
cmds because libiscsi will call conn_stop and take onwership.

We are trying to make sure abort work and reset completion work has
completed before we do the cmd clean up in ep_disconnect. The problem is
that:

 1. the work function sets the QEDI_CONN_FW_CLEANUP bit, so if the work was
    still pending we would not see the bit set. We need to do this before
    the work is queued.

 2. If we had multiple works queued then we could break from the loop in
    qedi_ep_disconnect early because when abort work 1 completes it could
    clear QEDI_CONN_FW_CLEANUP. qedi_ep_disconnect could then see that
    before work 2 has run.

 3. A TMF reset completion work could run after ep_disconnect starts
    cleaning up cmds via qedi_clearsq. ep_disconnect's call to qedi_clearsq
    -> qedi_cleanup_all_io would might think it's done cleaning up cmds,
    but the reset completion work could still be running. We then return
    from ep_disconnect while still doing cleanup.

This replaces the bit with a counter to track the number of queued TMF
works, and adds a bool to prevent new works from starting from the
completion path once a ep_disconnect starts.

Link: https://lore.kernel.org/r/20210525181821.7617-28-michael.christie@oracle.com
Reviewed-by: Manish Rangankar <mrangankar@marvell.com>
Signed-off-by: Mike Christie <michael.christie@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: qedi: Pass send_iscsi_tmf task to abort
Mike Christie [Tue, 25 May 2021 18:18:19 +0000 (13:18 -0500)]
scsi: qedi: Pass send_iscsi_tmf task to abort

qedi_abort_work knows what task to abort so just pass it to send_iscsi_tmf.

Link: https://lore.kernel.org/r/20210525181821.7617-27-michael.christie@oracle.com
Reviewed-by: Manish Rangankar <mrangankar@marvell.com>
Signed-off-by: Mike Christie <michael.christie@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: qedi: Fix cleanup session block/unblock use
Mike Christie [Tue, 25 May 2021 18:18:18 +0000 (13:18 -0500)]
scsi: qedi: Fix cleanup session block/unblock use

Drivers shouldn't be calling block/unblock session for cmd cleanup because
the functions can change the session state from under libiscsi.  This adds
a new a driver level bit so it can block all I/O the host while it drains
the card.

Link: https://lore.kernel.org/r/20210525181821.7617-26-michael.christie@oracle.com
Reviewed-by: Manish Rangankar <mrangankar@marvell.com>
Signed-off-by: Mike Christie <michael.christie@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: qedi: Fix TMF session block/unblock use
Mike Christie [Tue, 25 May 2021 18:18:17 +0000 (13:18 -0500)]
scsi: qedi: Fix TMF session block/unblock use

Drivers shouldn't be calling block/unblock session for tmf handling because
the functions can change the session state from under libiscsi.
iscsi_queuecommand's call to iscsi_prep_scsi_cmd_pdu->
iscsi_check_tmf_restrictions will prevent new cmds from being sent to qedi
after we've started handling a TMF. So we don't need to try and block it in
the driver, and we can remove these block calls.

Link: https://lore.kernel.org/r/20210525181821.7617-25-michael.christie@oracle.com
Reviewed-by: Manish Rangankar <mrangankar@marvell.com>
Signed-off-by: Mike Christie <michael.christie@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: qedi: Use GFP_NOIO for TMF allocation
Mike Christie [Tue, 25 May 2021 18:18:16 +0000 (13:18 -0500)]
scsi: qedi: Use GFP_NOIO for TMF allocation

We run from a workqueue with no locks held so use GFP_NOIO.

Link: https://lore.kernel.org/r/20210525181821.7617-24-michael.christie@oracle.com
Reviewed-by: Manish Rangankar <mrangankar@marvell.com>
Signed-off-by: Mike Christie <michael.christie@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: qedi: Fix TMF tid allocation
Mike Christie [Tue, 25 May 2021 18:18:15 +0000 (13:18 -0500)]
scsi: qedi: Fix TMF tid allocation

qedi_iscsi_abort_work and qedi_tmf_work both allocate a tid then call
qedi_send_iscsi_tmf which also allocates a tid. This removes the tid
allocation from the callers.

Link: https://lore.kernel.org/r/20210525181821.7617-23-michael.christie@oracle.com
Reviewed-by: Manish Rangankar <mrangankar@marvell.com>
Signed-off-by: Mike Christie <michael.christie@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: qedi: Fix use after free during abort cleanup
Mike Christie [Tue, 25 May 2021 18:18:14 +0000 (13:18 -0500)]
scsi: qedi: Fix use after free during abort cleanup

If qedi_tmf_work's qedi_wait_for_cleanup_request call times out we will
also force the clean up of the qedi_work_map but
qedi_process_cmd_cleanup_resp could still be accessing the qedi_cmd.

To fix this issue we extend where we hold the tmf_work_lock and back_lock
so the qedi_process_cmd_cleanup_resp access is serialized with the cleanup
done in qedi_tmf_work and any completion handling for the iscsi_task.

Link: https://lore.kernel.org/r/20210525181821.7617-22-michael.christie@oracle.com
Reviewed-by: Manish Rangankar <mrangankar@marvell.com>
Signed-off-by: Mike Christie <michael.christie@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: qedi: Fix race during abort timeouts
Mike Christie [Tue, 25 May 2021 18:18:13 +0000 (13:18 -0500)]
scsi: qedi: Fix race during abort timeouts

If the SCSI cmd completes after qedi_tmf_work calls iscsi_itt_to_task then
the qedi qedi_cmd->task_id could be freed and used for another cmd. If we
then call qedi_iscsi_cleanup_task with that task_id we will be cleaning up
the wrong cmd.

Wait to release the task_id until the last put has been done on the
iscsi_task. Because libiscsi grabs a ref to the task when sending the
abort, we know that for the non-abort timeout case that the task_id we are
referencing is for the cmd that was supposed to be aborted.

A latter commit will fix the case where the abort times out while we are
running qedi_tmf_work.

Link: https://lore.kernel.org/r/20210525181821.7617-21-michael.christie@oracle.com
Reviewed-by: Manish Rangankar <mrangankar@marvell.com>
Signed-off-by: Mike Christie <michael.christie@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: qedi: Fix null ref during abort handling
Mike Christie [Tue, 25 May 2021 18:18:12 +0000 (13:18 -0500)]
scsi: qedi: Fix null ref during abort handling

If qedi_process_cmd_cleanup_resp finds the cmd it frees the work and sets
list_tmf_work to NULL, so qedi_tmf_work should check if list_tmf_work is
non-NULL when it wants to force cleanup.

Link: https://lore.kernel.org/r/20210525181821.7617-20-michael.christie@oracle.com
Reviewed-by: Manish Rangankar <mrangankar@marvell.com>
Signed-off-by: Mike Christie <michael.christie@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: iscsi: Move pool freeing
Mike Christie [Tue, 25 May 2021 18:18:11 +0000 (13:18 -0500)]
scsi: iscsi: Move pool freeing

This doesn't fix any bugs, but it makes more sense to free the pool after
we have removed the session. At that time we know nothing is touching any
of the session fields, because all devices have been removed and scans are
stopped.

Link: https://lore.kernel.org/r/20210525181821.7617-19-michael.christie@oracle.com
Reviewed-by: Lee Duncan <lduncan@suse.com>
Signed-off-by: Mike Christie <michael.christie@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: iscsi: Hold task ref during TMF timeout handling
Mike Christie [Tue, 25 May 2021 18:18:10 +0000 (13:18 -0500)]
scsi: iscsi: Hold task ref during TMF timeout handling

For aborts, qedi needs to cleanup the FW then send the TMF from a worker
thread. While it's doing these the cmd could complete normally and the TMF
could time out. libiscsi would then complete the iscsi_task which will call
into the driver to cleanup the driver level resources while it still might
be accessing them for the cleanup/abort.

This has iscsi_eh_abort keep the iscsi_task ref if the TMF times out, so
qedi does not have to worry about if the task is being freed while in use
and does not need to get its own ref.

Link: https://lore.kernel.org/r/20210525181821.7617-18-michael.christie@oracle.com
Reviewed-by: Lee Duncan <lduncan@suse.com>
Signed-off-by: Mike Christie <michael.christie@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: iscsi: Flush block work before unblock
Mike Christie [Tue, 25 May 2021 18:18:09 +0000 (13:18 -0500)]
scsi: iscsi: Flush block work before unblock

We set the max_active iSCSI EH works to 1, so all work is going to execute
in order by default. However, userspace can now override this in sysfs. If
max_active > 1, we can end up with the block_work on CPU1 and
iscsi_unblock_session running the unblock_work on CPU2 and the session and
target/device state will end up out of sync with each other.

This adds a flush of the block_work in iscsi_unblock_session.

Link: https://lore.kernel.org/r/20210525181821.7617-17-michael.christie@oracle.com
Fixes: 1d726aa6ef57 ("scsi: iscsi: Optimize work queue flush use")
Reviewed-by: Lee Duncan <lduncan@suse.com>
Signed-off-by: Mike Christie <michael.christie@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: iscsi: Fix completion check during abort races
Mike Christie [Tue, 25 May 2021 18:18:08 +0000 (13:18 -0500)]
scsi: iscsi: Fix completion check during abort races

We have a ref to the task being aborted, so SCp.ptr will never be NULL. We
need to use iscsi_task_is_completed to check for the completed state.

Link: https://lore.kernel.org/r/20210525181821.7617-16-michael.christie@oracle.com
Reviewed-by: Lee Duncan <lduncan@suse.com>
Signed-off-by: Mike Christie <michael.christie@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: iscsi: Fix shost->max_id use
Mike Christie [Tue, 25 May 2021 18:18:07 +0000 (13:18 -0500)]
scsi: iscsi: Fix shost->max_id use

The iscsi offload drivers are setting the shost->max_id to the max number
of sessions they support. The problem is that max_id is not the max number
of targets but the highest identifier the targets can have. To use it to
limit the number of targets we need to set it to max sessions - 1, or we
can end up with a session we might not have preallocated resources for.

Link: https://lore.kernel.org/r/20210525181821.7617-15-michael.christie@oracle.com
Reviewed-by: Lee Duncan <lduncan@suse.com>
Signed-off-by: Mike Christie <michael.christie@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: iscsi: Fix conn use after free during resets
Mike Christie [Tue, 25 May 2021 18:18:06 +0000 (13:18 -0500)]
scsi: iscsi: Fix conn use after free during resets

If we haven't done a unbind target call we can race where
iscsi_conn_teardown wakes up the EH thread and then frees the conn while
those threads are still accessing the conn ehwait.

We can only do one TMF per session so this just moves the TMF fields from
the conn to the session. We can then rely on the
iscsi_session_teardown->iscsi_remove_session->__iscsi_unbind_session call
to remove the target and it's devices, and know after that point there is
no device or scsi-ml callout trying to access the session.

Link: https://lore.kernel.org/r/20210525181821.7617-14-michael.christie@oracle.com
Reviewed-by: Lee Duncan <lduncan@suse.com>
Signed-off-by: Mike Christie <michael.christie@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: iscsi: Get ref to conn during reset handling
Mike Christie [Tue, 25 May 2021 18:18:05 +0000 (13:18 -0500)]
scsi: iscsi: Get ref to conn during reset handling

The comment in iscsi_eh_session_reset is wrong and we don't wait for the
EH to complete before tearing down the conn. This has us get a ref to the
conn when we are not holding the eh_mutex/frwd_lock so it does not get
freed from under us.

Link: https://lore.kernel.org/r/20210525181821.7617-13-michael.christie@oracle.com
Reviewed-by: Lee Duncan <lduncan@suse.com>
Signed-off-by: Mike Christie <michael.christie@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: iscsi: Have abort handler get ref to conn
Mike Christie [Tue, 25 May 2021 18:18:04 +0000 (13:18 -0500)]
scsi: iscsi: Have abort handler get ref to conn

If SCSI midlayer is aborting a task when we are tearing down the conn we
could free the conn while the abort thread is accessing the conn. This has
the abort handler get a ref to the conn so it won't be freed from under it.

Note: this is not needed for device/target reset because we are holding the
eh_mutex when accessing the conn.

Link: https://lore.kernel.org/r/20210525181821.7617-12-michael.christie@oracle.com
Reviewed-by: Lee Duncan <lduncan@suse.com>
Signed-off-by: Mike Christie <michael.christie@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: iscsi: Add iscsi_cls_conn refcount helpers
Mike Christie [Tue, 25 May 2021 18:18:03 +0000 (13:18 -0500)]
scsi: iscsi: Add iscsi_cls_conn refcount helpers

There are a couple places where we could free the iscsi_cls_conn while it's
still in use. This adds some helpers to get/put a refcount on the struct
and converts an exiting user. Subsequent commits will then use the helpers
to fix 2 bugs in the eh code.

Link: https://lore.kernel.org/r/20210525181821.7617-11-michael.christie@oracle.com
Reviewed-by: Lee Duncan <lduncan@suse.com>
Signed-off-by: Mike Christie <michael.christie@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: iscsi: iscsi_tcp: Start socket shutdown during conn stop
Mike Christie [Tue, 25 May 2021 18:18:02 +0000 (13:18 -0500)]
scsi: iscsi: iscsi_tcp: Start socket shutdown during conn stop

Make sure the conn socket shutdown starts before we start the timer to fail
commands to upper layers.

Link: https://lore.kernel.org/r/20210525181821.7617-10-michael.christie@oracle.com
Reviewed-by: Lee Duncan <lduncan@suse.com>
Signed-off-by: Mike Christie <michael.christie@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: iscsi: iscsi_tcp: Set no linger
Mike Christie [Tue, 25 May 2021 18:18:01 +0000 (13:18 -0500)]
scsi: iscsi: iscsi_tcp: Set no linger

Userspace (open-iscsi based tools at least) sets no linger on the socket to
prevent stale data from being sent. However, with the in-kernel cleanup if
userspace is not up the sockfd_put will release the socket without having
set that sockopt.

iscsid sets that opt at socket close time, but it seems ok to set this at
setup time in the kernel for all tools.

Link: https://lore.kernel.org/r/20210525181821.7617-9-michael.christie@oracle.com
Reviewed-by: Lee Duncan <lduncan@suse.com>
Signed-off-by: Mike Christie <michael.christie@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: iscsi: Fix in-kernel conn failure handling
Mike Christie [Tue, 25 May 2021 18:18:00 +0000 (13:18 -0500)]
scsi: iscsi: Fix in-kernel conn failure handling

Commit 0ab710458da1 ("scsi: iscsi: Perform connection failure entirely in
kernel space") has the following regressions/bugs that this patch fixes:

1. It can return cmds to upper layers like dm-multipath where that can
retry them. After they are successful the fs/app can send new I/O to the
same sectors, but we've left the cmds running in FW or in the net layer.
We need to be calling ep_disconnect if userspace is not up.

This patch only fixes the issue for offload drivers. iscsi_tcp will be
fixed in separate commit because it doesn't have a ep_disconnect call.

2. The drivers that implement ep_disconnect expect that it's called before
conn_stop. Besides crashes, if the cleanup_task callout is called before
ep_disconnect it might free up driver/card resources for session1 then they
could be allocated for session2. But because the driver's ep_disconnect is
not called it has not cleaned up the firmware so the card is still using
the resources for the original cmd.

3. The stop_conn_work_fn can run after userspace has done its recovery and
we are happily using the session. We will then end up with various bugs
depending on what is going on at the time.

We may also run stop_conn_work_fn late after userspace has called stop_conn
and ep_disconnect and is now going to call start/bind conn. If
stop_conn_work_fn runs after bind but before start, we would leave the conn
in a unbound but sort of started state where IO might be allowed even
though the drivers have been set in a state where they no longer expect
I/O.

4. Returning -EAGAIN in iscsi_if_destroy_conn if we haven't yet run the in
kernel stop_conn function is breaking userspace. We should have been doing
this for the caller.

Link: https://lore.kernel.org/r/20210525181821.7617-8-michael.christie@oracle.com
Fixes: 0ab710458da1 ("scsi: iscsi: Perform connection failure entirely in kernel space")
Reviewed-by: Lee Duncan <lduncan@suse.com>
Signed-off-by: Mike Christie <michael.christie@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: iscsi: Rel ref after iscsi_lookup_endpoint()
Mike Christie [Tue, 25 May 2021 18:17:59 +0000 (13:17 -0500)]
scsi: iscsi: Rel ref after iscsi_lookup_endpoint()

Subsequent commits allow the kernel to do ep_disconnect. In that case we
will have to get a proper refcount on the ep so one thread does not delete
it from under another.

Link: https://lore.kernel.org/r/20210525181821.7617-7-michael.christie@oracle.com
Reviewed-by: Lee Duncan <lduncan@suse.com>
Signed-off-by: Mike Christie <michael.christie@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: iscsi: Use system_unbound_wq for destroy_work
Mike Christie [Tue, 25 May 2021 18:17:58 +0000 (13:17 -0500)]
scsi: iscsi: Use system_unbound_wq for destroy_work

Use the system_unbound_wq for async session destruction. We don't need a
dedicated workqueue for async session destruction because:

 1. perf does not seem to be an issue since we only allow 1 active work.

 2. it does not have deps with other system works and we can run them in
    parallel with each other.

Link: https://lore.kernel.org/r/20210525181821.7617-6-michael.christie@oracle.com
Reviewed-by: Lee Duncan <lduncan@suse.com>
Signed-off-by: Mike Christie <michael.christie@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: iscsi: Force immediate failure during shutdown
Mike Christie [Tue, 25 May 2021 18:17:57 +0000 (13:17 -0500)]
scsi: iscsi: Force immediate failure during shutdown

If the system is not up, we can just fail immediately since iscsid is not
going to ever answer our netlink events. We are already setting the
recovery_tmo to 0, but by passing stop_conn STOP_CONN_TERM we never will
block the session and start the recovery timer, because for that flag
userspace will do the unbind and destroy events which would remove the
devices and wake up and kill the eh.

Since the conn is dead and the system is going dowm this just has us use
STOP_CONN_RECOVER with recovery_tmo=0 so we fail immediately. However, if
the user has set the recovery_tmo=-1 we let the system hang like they
requested since they might have used that setting for specific reasons
(one known reason is for buggy cluster software).

Link: https://lore.kernel.org/r/20210525181821.7617-5-michael.christie@oracle.com
Signed-off-by: Mike Christie <michael.christie@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: iscsi: Drop suspend calls from ep_disconnect
Mike Christie [Tue, 25 May 2021 18:17:56 +0000 (13:17 -0500)]
scsi: iscsi: Drop suspend calls from ep_disconnect

libiscsi will now suspend the send/tx queue for the drivers so we can drop
it from the drivers ep_disconnect.

Link: https://lore.kernel.org/r/20210525181821.7617-4-michael.christie@oracle.com
Reviewed-by: Lee Duncan <lduncan@suse.com>
Signed-off-by: Mike Christie <michael.christie@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: iscsi: Stop queueing during ep_disconnect
Mike Christie [Tue, 25 May 2021 18:17:55 +0000 (13:17 -0500)]
scsi: iscsi: Stop queueing during ep_disconnect

During ep_disconnect we have been doing iscsi_suspend_tx/queue to block new
I/O but every driver except cxgbi and iscsi_tcp can still get I/O from
__iscsi_conn_send_pdu() if we haven't called iscsi_conn_failure() before
ep_disconnect. This could happen if we were terminating the session, and
the logout timed out before it was even sent to libiscsi.

Fix the issue by adding a helper which reverses the bind_conn call that
allows new I/O to be queued. Drivers implementing ep_disconnect can use this
to make sure new I/O is not queued to them when handling the disconnect.

Link: https://lore.kernel.org/r/20210525181821.7617-3-michael.christie@oracle.com
Reviewed-by: Lee Duncan <lduncan@suse.com>
Signed-off-by: Mike Christie <michael.christie@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: iscsi: Add task completion helper
Mike Christie [Tue, 25 May 2021 18:17:54 +0000 (13:17 -0500)]
scsi: iscsi: Add task completion helper

This adds a helper to detect if a cmd has completed but is not yet freed.

Link: https://lore.kernel.org/r/20210525181821.7617-2-michael.christie@oracle.com
Reviewed-by: Lee Duncan <lduncan@suse.com>
Signed-off-by: Mike Christie <michael.christie@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: megaraid_sas: Update driver version to 07.717.02.00-rc1
Chandrakanth Patil [Fri, 28 May 2021 13:13:07 +0000 (18:43 +0530)]
scsi: megaraid_sas: Update driver version to 07.717.02.00-rc1

Link: https://lore.kernel.org/r/20210528131307.25683-6-chandrakanth.patil@broadcom.com
Signed-off-by: Chandrakanth Patil <chandrakanth.patil@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: megaraid_sas: Handle missing interrupts while re-enabling IRQs
Chandrakanth Patil [Fri, 28 May 2021 13:13:06 +0000 (18:43 +0530)]
scsi: megaraid_sas: Handle missing interrupts while re-enabling IRQs

While reenabling the IRQ after IRQ poll there may be a small window for the
firmware to post the replies with interrupts raised. In that case the
driver will not see the interrupts which leads to I/O timeout.

This issue only happens when there are many I/O completions on a single
reply queue. This forces the driver to switch between the interrupt and IRQ
context.

Make the driver process the reply queue one more time after enabling the
IRQ.

Link: https://lore.kernel.org/linux-scsi/20201102072746.27410-1-sreekanth.reddy@broadcom.com/
Link: https://lore.kernel.org/r/20210528131307.25683-5-chandrakanth.patil@broadcom.com
Cc: Tomas Henzl <thenzl@redhat.com>
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Chandrakanth Patil <chandrakanth.patil@broadcom.com>
Signed-off-by: Sumit Saxena <sumit.saxena@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: megaraid_sas: Early detection of VD deletion through RaidMap update
Kashyap Desai [Fri, 28 May 2021 13:13:05 +0000 (18:43 +0530)]
scsi: megaraid_sas: Early detection of VD deletion through RaidMap update

Consider the case where a VD is deleted and the targetID of that VD is
assigned to a newly created VD. If the sequence of deletion/addition of VD
happens very quickly there is a possibility that second event (VD add)
occurs even before the driver processes the first event (VD delete).  As
event processing is done in deferred context the device list remains the
same (but targetID is re-used) so driver will not learn the VD
deletion/additon. I/Os meant for the older VD will be directed to new VD
which may lead to data corruption.

Make driver detect the deleted VD as soon as possible based on the RaidMap
update and block further I/O to that device.

Link: https://lore.kernel.org/r/20210528131307.25683-4-chandrakanth.patil@broadcom.com
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Kashyap Desai <kashyap.desai@broadcom.com>
Signed-off-by: Chandrakanth Patil <chandrakanth.patil@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: megaraid_sas: Fix resource leak in case of probe failure
Chandrakanth Patil [Fri, 28 May 2021 13:13:04 +0000 (18:43 +0530)]
scsi: megaraid_sas: Fix resource leak in case of probe failure

The driver doesn't clean up all the allocated resources properly when
scsi_add_host(), megasas_start_aen() function fails during the PCI device
probe.

Clean up all those resources.

Link: https://lore.kernel.org/r/20210528131307.25683-3-chandrakanth.patil@broadcom.com
Signed-off-by: Chandrakanth Patil <chandrakanth.patil@broadcom.com>
Signed-off-by: Sumit Saxena <sumit.saxena@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: megaraid_sas: Send all non-RW I/Os for TYPE_ENCLOSURE device through firmware
Chandrakanth Patil [Fri, 28 May 2021 13:13:03 +0000 (18:43 +0530)]
scsi: megaraid_sas: Send all non-RW I/Os for TYPE_ENCLOSURE device through firmware

The driver issues all non-ReadWrite I/Os for TYPE_ENCLOSURE devices through
the fast path with invalid dev handle. Fast path in turn directs all the
I/Os to the firmware. As firmware stopped handling those I/Os from SAS3.5
generation of controllers (Ventura generation and onwards) this will lead
to I/O failures.

Switch the driver to issue all the non-ReadWrite I/Os for TYPE_ENCLOSURE
devices directly to firmware for SAS3.5 generation of controllers and
later.

Link: https://lore.kernel.org/r/20210528131307.25683-2-chandrakanth.patil@broadcom.com
Cc: <stable@vger.kernel.org> # v5.11+
Signed-off-by: Chandrakanth Patil <chandrakanth.patil@broadcom.com>
Signed-off-by: Sumit Saxena <sumit.saxena@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: mpi3mr: Add event handling debug prints
Kashyap Desai [Thu, 20 May 2021 15:25:45 +0000 (20:55 +0530)]
scsi: mpi3mr: Add event handling debug prints

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>
3 years agoscsi: mpi3mr: Add EEDP DIF DIX support
Kashyap Desai [Thu, 20 May 2021 15:25:44 +0000 (20:55 +0530)]
scsi: mpi3mr: Add EEDP DIF DIX support

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>
3 years agoscsi: mpi3mr: Add support for DSN secure firmware check
Kashyap Desai [Thu, 20 May 2021 15:25:43 +0000 (20:55 +0530)]
scsi: mpi3mr: Add support for DSN secure firmware check

Read PCI_EXT_CAP_ID_DSN to query security status.

The driver will throw a warning message when a non-secure type controller
is detected. The purpose of this interface is to avoid interacting with any
firmware which is not secured/signed by Broadcom.  Any tampering on
firmware component will be detected by hardware and it will be communicated
to the driver to avoid any further interaction with that component.

Link: https://lore.kernel.org/r/20210520152545.2710479-23-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>
3 years agoscsi: mpi3mr: Add support for PM suspend and resume
Kashyap Desai [Thu, 20 May 2021 15:25:42 +0000 (20:55 +0530)]
scsi: mpi3mr: Add support for PM suspend and resume

Link: https://lore.kernel.org/r/20210520152545.2710479-22-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>
3 years agoscsi: mpi3mr: Wait for pending I/O completions upon detection of VD I/O timeout
Kashyap Desai [Thu, 20 May 2021 15:25:41 +0000 (20:55 +0530)]
scsi: mpi3mr: Wait for pending I/O completions upon detection of VD I/O timeout

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>
3 years agoscsi: mpi3mr: Print pending host I/Os for debugging
Kashyap Desai [Thu, 20 May 2021 15:25:40 +0000 (20:55 +0530)]
scsi: mpi3mr: Print pending host I/Os for debugging

Link: https://lore.kernel.org/r/20210520152545.2710479-20-kashyap.desai@broadcom.com
Cc: sathya.prakash@broadcom.com
Reviewed-by: Tomas Henzl <thenzl@redhat.com>
Reviewed-by: Hannes Reinecke <hare@suse.de>
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>
3 years agoscsi: mpi3mr: Complete support for soft reset
Kashyap Desai [Thu, 20 May 2021 15:25:39 +0000 (20:55 +0530)]
scsi: mpi3mr: Complete support for soft reset

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>
3 years agoscsi: mpi3mr: Add support for threaded ISR
Kashyap Desai [Thu, 20 May 2021 15:25:38 +0000 (20:55 +0530)]
scsi: mpi3mr: Add support for threaded ISR

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>
3 years agoscsi: mpi3mr: Hardware workaround for UNMAP commands to NVMe drives
Kashyap Desai [Thu, 20 May 2021 15:25:37 +0000 (20:55 +0530)]
scsi: mpi3mr: Hardware workaround for UNMAP commands to NVMe drives

The controller hardware can not handle certain UNMAP commands for NVMe
drives. Add support in the driver for checking those commands and handle
them appropriately.

Link: https://lore.kernel.org/r/20210520152545.2710479-17-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>
3 years agoscsi: mpi3mr: Allow certain commands during pci-remove hook
Kashyap Desai [Thu, 20 May 2021 15:25:36 +0000 (20:55 +0530)]
scsi: mpi3mr: Allow certain commands during pci-remove hook

Instead of driver returning DID_NO_CONNECT during driver unload allow SSU
and Sync Cache commands to be sent to the controller to flush any cached
data from the drive.

Link: https://lore.kernel.org/r/20210520152545.2710479-16-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>
3 years agoscsi: mpi3mr: Add change queue depth support
Kashyap Desai [Thu, 20 May 2021 15:25:35 +0000 (20:55 +0530)]
scsi: mpi3mr: Add change queue depth support

Link: https://lore.kernel.org/r/20210520152545.2710479-15-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>
3 years agoscsi: mpi3mr: Implement SCSI error handler hooks
Kashyap Desai [Thu, 20 May 2021 15:25:34 +0000 (20:55 +0530)]
scsi: mpi3mr: Implement SCSI error handler hooks

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>
3 years agoscsi: mpi3mr: Add bios_param SCSI host template hook
Kashyap Desai [Thu, 20 May 2021 15:25:33 +0000 (20:55 +0530)]
scsi: mpi3mr: Add bios_param SCSI host template hook

Link: https://lore.kernel.org/r/20210520152545.2710479-13-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>
3 years agoscsi: mpi3mr: Print IOC info for debugging
Kashyap Desai [Thu, 20 May 2021 15:25:32 +0000 (20:55 +0530)]
scsi: mpi3mr: Print IOC info for debugging

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>
3 years agoscsi: mpi3mr: Add support for timestamp sync with firmware
Kashyap Desai [Thu, 20 May 2021 15:25:31 +0000 (20:55 +0530)]
scsi: mpi3mr: Add support for timestamp sync with firmware

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>
3 years agoscsi: mpi3mr: Add support for recovering controller
Kashyap Desai [Thu, 20 May 2021 15:25:30 +0000 (20:55 +0530)]
scsi: mpi3mr: Add support for recovering controller

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>
3 years agoscsi: mpi3mr: Additional event handling
Kashyap Desai [Thu, 20 May 2021 15:25:29 +0000 (20:55 +0530)]
scsi: mpi3mr: Additional event handling

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>
3 years agoscsi: mpi3mr: Add support for PCIe device event handling
Kashyap Desai [Thu, 20 May 2021 15:25:28 +0000 (20:55 +0530)]
scsi: mpi3mr: Add support for PCIe device event handling

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>
3 years agoscsi: mpi3mr: Add support for device add/remove event handling
Kashyap Desai [Thu, 20 May 2021 15:25:27 +0000 (20:55 +0530)]
scsi: mpi3mr: Add support for device add/remove event handling

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>
3 years agoscsi: mpi3mr: Add support for internal watchdog thread
Kashyap Desai [Thu, 20 May 2021 15:25:26 +0000 (20:55 +0530)]
scsi: mpi3mr: Add support for internal watchdog thread

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>
3 years agoscsi: mpi3mr: Add support for queue command processing
Kashyap Desai [Thu, 20 May 2021 15:25:25 +0000 (20:55 +0530)]
scsi: mpi3mr: Add support for queue command processing

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>
3 years agoscsi: mpi3mr: Create operational request and reply queue pair
Kashyap Desai [Thu, 20 May 2021 15:25:24 +0000 (20:55 +0530)]
scsi: mpi3mr: Create operational request and reply queue pair

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>
3 years agoscsi: mpi3mr: Base driver code
Kashyap Desai [Thu, 20 May 2021 15:25:23 +0000 (20:55 +0530)]
scsi: mpi3mr: Base driver code

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>
3 years agoscsi: mpi3mr: Add mpi30 Rev-R headers and Kconfig
Kashyap Desai [Thu, 20 May 2021 15:25:22 +0000 (20:55 +0530)]
scsi: mpi3mr: Add mpi30 Rev-R headers and Kconfig

This adds the Kconfig and mpi30 headers.

Link: https://lore.kernel.org/r/20210520152545.2710479-2-kashyap.desai@broadcom.com
Cc: sathya.prakash@broadcom.com
Cc: bvanassche@acm.org
Cc: hch@infradead.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>
3 years agoscsi: ufs: Fix a kernel-doc related formatting issue
Bean Huo [Mon, 31 May 2021 16:31:22 +0000 (18:31 +0200)]
scsi: ufs: Fix a kernel-doc related formatting issue

Fix the following W=1 kernel build warning:

drivers/scsi/ufs/ufshcd.c:9773: warning: This comment starts with '/**', but isn't a kernel-doc comment. Refer Documentation/doc-guide/kernel-doc.rst

[mkp: upcase abbreviations]

Link: https://lore.kernel.org/r/20210531163122.451375-1-huobean@gmail.com
Reviewed-by: Alim Akhtar <alim.akhtar@samsung.com>
Signed-off-by: Bean Huo <beanhuo@micron.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: isci: Use correctly sized target buffer for memcpy()
Kees Cook [Fri, 28 May 2021 18:13:37 +0000 (11:13 -0700)]
scsi: isci: Use correctly sized target buffer for memcpy()

In preparation for FORTIFY_SOURCE performing compile-time and run-time
field bounds checking for memcpy(), avoid intentionally writing across
neighboring array fields.

Switch from rsp_ui to resp_buf, since resp_ui isn't SSP_RESP_IU_MAX_SIZE
bytes in length. This avoids future compile-time warnings.

Link: https://lore.kernel.org/r/20210528181337.792268-4-keescook@chromium.org
Reviewed-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: esas2r: Switch to flexible array member
Kees Cook [Fri, 28 May 2021 18:13:36 +0000 (11:13 -0700)]
scsi: esas2r: Switch to flexible array member

In preparation for FORTIFY_SOURCE performing compile-time and run-time
field bounds checking for memcpy(), avoid intentionally writing across
neighboring array fields.

Remove old-style 1-byte array in favor of a flexible array[1] to avoid
future false-positive cross-field memcpy() warning in:

esas2r_vda.c:
memcpy(vi->cmd.gsv.version_info, esas2r_vdaioctl_versions, ...)

The change in struct size doesn't change other structure sizes (it is
already maxed out to 256 bytes, for example here:

        union {
                struct atto_ioctl_vda_scsi_cmd scsi;
                struct atto_ioctl_vda_flash_cmd flash;
                struct atto_ioctl_vda_diag_cmd diag;
                struct atto_ioctl_vda_cli_cmd cli;
                struct atto_ioctl_vda_smp_cmd smp;
                struct atto_ioctl_vda_cfg_cmd cfg;
                struct atto_ioctl_vda_mgt_cmd mgt;
                struct atto_ioctl_vda_gsv_cmd gsv;
                u8 cmd_info[256];
        } cmd;

No sizes are calculated using the enclosing structure, so no other
updates are needed.

Link: https://lore.kernel.org/r/20210528181337.792268-3-keescook@chromium.org
Reviewed-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: FlashPoint: Rename si_flags field
Randy Dunlap [Sat, 29 May 2021 23:48:57 +0000 (16:48 -0700)]
scsi: FlashPoint: Rename si_flags field

The BusLogic driver has build errors on ia64 due to a name collision (in
the #included FlashPoint.c file). Rename the struct field in struct
sccb_mgr_info from si_flags to si_mflags (manager flags) to mend the build.

This is the first problem. There are 50+ others after this one:

In file included from ../include/uapi/linux/signal.h:6,
                 from ../include/linux/signal_types.h:10,
                 from ../include/linux/sched.h:29,
                 from ../include/linux/hardirq.h:9,
                 from ../include/linux/interrupt.h:11,
                 from ../drivers/scsi/BusLogic.c:27:
../arch/ia64/include/uapi/asm/siginfo.h:15:27: error: expected ':', ',', ';', '}' or '__attribute__' before '.' token
   15 | #define si_flags _sifields._sigfault._flags
      |                           ^
../drivers/scsi/FlashPoint.c:43:6: note: in expansion of macro 'si_flags'
   43 |  u16 si_flags;
      |      ^~~~~~~~
In file included from ../drivers/scsi/BusLogic.c:51:
../drivers/scsi/FlashPoint.c: In function 'FlashPoint_ProbeHostAdapter':
../drivers/scsi/FlashPoint.c:1076:11: error: 'struct sccb_mgr_info' has no member named '_sifields'
 1076 |  pCardInfo->si_flags = 0x0000;
      |           ^~
../drivers/scsi/FlashPoint.c:1079:12: error: 'struct sccb_mgr_info' has no member named '_sifields'

Link: https://lore.kernel.org/r/20210529234857.6870-1-rdunlap@infradead.org
Fixes: 391e2f25601e ("[SCSI] BusLogic: Port driver to 64-bit.")
Cc: "James E.J. Bottomley" <jejb@linux.ibm.com>
Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: Hannes Reinecke <hare@suse.de>
Cc: Khalid Aziz <khalid.aziz@oracle.com>
Cc: Khalid Aziz <khalid@gonehiking.org>
Reported-by: kernel test robot <lkp@intel.com>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: mpt3sas: Fix fall-through warnings for Clang
Gustavo A. R. Silva [Fri, 28 May 2021 20:08:28 +0000 (15:08 -0500)]
scsi: mpt3sas: Fix fall-through warnings for Clang

In preparation to enable -Wimplicit-fallthrough for Clang, fix a couple
of warnings by explicitly adding break statements instead of just letting
the code fall through to the next case.

Link: https://github.com/KSPP/linux/issues/115
Link: https://lore.kernel.org/r/20210528200828.GA39349@embeddedor
Reviewed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: qla2xxx: Log PCI address in qla_nvme_unregister_remote_port()
Daniel Wagner [Mon, 31 May 2021 12:24:44 +0000 (14:24 +0200)]
scsi: qla2xxx: Log PCI address in qla_nvme_unregister_remote_port()

Pass in fcport->vha to ql_log() in order to add the PCI address to the log.

Currently NULL is passed in which gives this confusing log entry:

> qla2xxx [0000:00:00.0]-2112: : qla_nvme_unregister_remote_port: unregister remoteport on 0000000009d6a2e9 50000973981648c7

Link: https://lore.kernel.org/r/20210531122444.116655-1-dwagner@suse.de
Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
Signed-off-by: Daniel Wagner <dwagner@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: ufs: ufs-mediatek: Disable HCI before HW reset
Alice.Chao [Fri, 28 May 2021 03:36:22 +0000 (11:36 +0800)]
scsi: ufs: ufs-mediatek: Disable HCI before HW reset

MediaTek ufshci needs to be disabled before HW reset to avoid potential
issues.

Link: https://lore.kernel.org/r/20210528033624.12170-3-alice.chao@mediatek.com
Reviewed-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Alice.Chao <alice.chao@mediatek.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: ufs: core: Export ufshcd_hba_stop()
Alice.Chao [Fri, 28 May 2021 03:36:21 +0000 (11:36 +0800)]
scsi: ufs: core: Export ufshcd_hba_stop()

Export ufshcd_hba_stop() to allow vendors to disable HCI in variant ops.

Link: https://lore.kernel.org/r/20210528033624.12170-2-alice.chao@mediatek.com
Reviewed-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Alice.Chao <alice.chao@mediatek.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: core: Drop obsolete Linux-specific SCSI status codes
Hannes Reinecke [Tue, 27 Apr 2021 08:30:46 +0000 (10:30 +0200)]
scsi: core: Drop obsolete Linux-specific SCSI status codes

Originally the SCSI subsystem has been using 'special' SCSI status codes,
which were the SAM-specified ones but shifted by 1.  As most drivers have
now been modified to use the SAM-specified ones, having two nearly
identical sets of definitions only causes confusion.

The Linux-specifed SCSI status codes have been marked obsolete for several
years so drop them and use the SAM-specified status codes throughout.

Link: https://lore.kernel.org/r/20210427083046.31620-41-hare@suse.de
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Douglas Gilbert <dgilbert@interlog.com>
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: pcmcia: nsp_cs: Use SAM_STAT_CHECK_CONDITION
Hannes Reinecke [Thu, 27 May 2021 07:22:17 +0000 (09:22 +0200)]
scsi: pcmcia: nsp_cs: Use SAM_STAT_CHECK_CONDITION

The nsp_cs driver stores the SAM status values in SCp.Status, so we need to
use the non-shifted version SAM_STAT_CHECK_CONDITION.

Link: https://lore.kernel.org/r/20210527072217.117126-1-hare@suse.de
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: target: Use standard SAM status types
Hannes Reinecke [Tue, 27 Apr 2021 08:30:45 +0000 (10:30 +0200)]
scsi: target: Use standard SAM status types

target_complete_cmd() and friends requires a SAM status type, so passing
GOOD here is actually wrong.

Link: https://lore.kernel.org/r/20210427083046.31620-40-hare@suse.de
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: core: Kill message byte
Hannes Reinecke [Tue, 27 Apr 2021 08:30:44 +0000 (10:30 +0200)]
scsi: core: Kill message byte

Remove last vestiges of SCSI status message bytes.

Link: https://lore.kernel.org/r/20210427083046.31620-39-hare@suse.de
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: core: Drop message byte helper
Hannes Reinecke [Tue, 27 Apr 2021 08:30:43 +0000 (10:30 +0200)]
scsi: core: Drop message byte helper

The message byte is now unused, so we can drop the helper to set the
message byte and the check for message bytes during error recovery.

Link: https://lore.kernel.org/r/20210427083046.31620-38-hare@suse.de
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: fdomain: Translate message to host byte status
Hannes Reinecke [Tue, 27 Apr 2021 08:30:42 +0000 (10:30 +0200)]
scsi: fdomain: Translate message to host byte status

Instead of setting the message byte translate it to the appropriate host
byte. As error recovery would return DID_ERROR for any non-zero message
byte the translation doesn't change the error handling.

Link: https://lore.kernel.org/r/20210427083046.31620-37-hare@suse.de
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: fdomain: Drop last argument to fdomain_finish_cmd()
Hannes Reinecke [Tue, 27 Apr 2021 08:30:41 +0000 (10:30 +0200)]
scsi: fdomain: Drop last argument to fdomain_finish_cmd()

Set the SCSI host status before calling fdomain_finish_cmd() and drop the
last argument to that function.

Link: https://lore.kernel.org/r/20210427083046.31620-36-hare@suse.de
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: FlashPoint: Use standard SCSI definitions
Hannes Reinecke [Tue, 27 Apr 2021 08:30:40 +0000 (10:30 +0200)]
scsi: FlashPoint: Use standard SCSI definitions

No point in having the driver providing its own definitions.

Link: https://lore.kernel.org/r/20210427083046.31620-35-hare@suse.de
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: fas216: Use get_status_byte() to avoid using Linux-specific status codes
Hannes Reinecke [Tue, 27 Apr 2021 08:30:39 +0000 (10:30 +0200)]
scsi: fas216: Use get_status_byte() to avoid using Linux-specific status codes

The driver should be using the standard SAM_STAT_ values, and not the
Linux-specific ones.

Link: https://lore.kernel.org/r/20210427083046.31620-34-hare@suse.de
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: fas216: Translate message to host byte status
Hannes Reinecke [Tue, 27 Apr 2021 08:30:38 +0000 (10:30 +0200)]
scsi: fas216: Translate message to host byte status

Instead of setting the message byte translate it to the appropriate host
byte. As error recovery would return DID_ERROR for any non-zero message
byte the translation doesn't change the error handling.

[mkp: zeroday bug report: s/SCpnt->result/SCpnt/]

Link: https://lore.kernel.org/r/20210427083046.31620-33-hare@suse.de
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: advansys: Do not set message byte in SCSI status
Hannes Reinecke [Tue, 27 Apr 2021 08:30:37 +0000 (10:30 +0200)]
scsi: advansys: Do not set message byte in SCSI status

The host byte in the SCSI status takes precedence during error recovery, so
there is no point in setting the message byte in addition to a host byte
which is not DID_OK.

Link: https://lore.kernel.org/r/20210427083046.31620-32-hare@suse.de
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: aha152x: Do not set message byte when calling scsi_done()
Hannes Reinecke [Tue, 27 Apr 2021 08:30:36 +0000 (10:30 +0200)]
scsi: aha152x: Do not set message byte when calling scsi_done()

The done() function is called with a host_byte indicating the actual error
when the message byte is set. As the host byte takes precedence during
error recovery we can drop setting the message byte if the host byte is
set, too.  The only other case is when the host byte is DID_OK, but in that
case the message byte is always COMMAND_COMPLETE (i.e. 0), so we can drop
it there, too.

Link: https://lore.kernel.org/r/20210427083046.31620-31-hare@suse.de
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: aha152x: Modify done() to use separate status bytes
Hannes Reinecke [Tue, 27 Apr 2021 08:30:35 +0000 (10:30 +0200)]
scsi: aha152x: Modify done() to use separate status bytes

Instead of passing in the combined SCSI result values, split them off into
separate status, message, and host byte values.

Link: https://lore.kernel.org/r/20210427083046.31620-30-hare@suse.de
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: acornscsi: Translate message byte to host byte
Hannes Reinecke [Tue, 27 Apr 2021 08:30:34 +0000 (10:30 +0200)]
scsi: acornscsi: Translate message byte to host byte

Instead of setting the message byte translate it to the appropriate host
byte. As error recovery would return DID_ERROR for any non-zero message
byte the translation doesn't change the error handling.  And use SCSI
result accessors while we're at it.

Link: https://lore.kernel.org/r/20210427083046.31620-29-hare@suse.de
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: acornscsi: Remove acornscsi_reportstatus()
Hannes Reinecke [Tue, 27 Apr 2021 08:30:33 +0000 (10:30 +0200)]
scsi: acornscsi: Remove acornscsi_reportstatus()

Unused.

Link: https://lore.kernel.org/r/20210427083046.31620-28-hare@suse.de
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: mesh: Translate message to host byte status
Hannes Reinecke [Tue, 27 Apr 2021 08:30:32 +0000 (10:30 +0200)]
scsi: mesh: Translate message to host byte status

Instead of setting the message byte translate it to a host byte status. As
the error recovery would map it to DID_ERROR anyway the translation doesn't
change the SCSI error handling.

Link: https://lore.kernel.org/r/20210427083046.31620-27-hare@suse.de
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: wd33c93: Translate message byte to host byte
Hannes Reinecke [Tue, 27 Apr 2021 08:30:31 +0000 (10:30 +0200)]
scsi: wd33c93: Translate message byte to host byte

Instead of setting the message byte translate it to the appropriate host
byte. As error recovery would return DID_ERROR for any non-zero message
byte the translation doesn't change the error handling.

Link: https://lore.kernel.org/r/20210427083046.31620-26-hare@suse.de
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: nsp32: Do not set message byte
Hannes Reinecke [Tue, 27 Apr 2021 08:30:30 +0000 (10:30 +0200)]
scsi: nsp32: Do not set message byte

The message byte always devolves to COMMAND_COMPLETE, so there is no point
in setting it.

Link: https://lore.kernel.org/r/20210427083046.31620-25-hare@suse.de
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: nsp32: Whitespace cleanup
Hannes Reinecke [Tue, 27 Apr 2021 08:30:29 +0000 (10:30 +0200)]
scsi: nsp32: Whitespace cleanup

[mkp: fix kernel test robot warning]

Link: https://lore.kernel.org/r/20210427083046.31620-24-hare@suse.de
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: qlogicfas408: Whitespace cleanup
Hannes Reinecke [Tue, 27 Apr 2021 08:30:27 +0000 (10:30 +0200)]
scsi: qlogicfas408: Whitespace cleanup

Link: https://lore.kernel.org/r/20210427083046.31620-22-hare@suse.de
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: qlogicfas408: make ql_pcmd() a void function
Hannes Reinecke [Tue, 27 Apr 2021 08:30:26 +0000 (10:30 +0200)]
scsi: qlogicfas408: make ql_pcmd() a void function

Make ql_pcmd() a void function and set the SCSI result directly.

[mkp: fix zeroday 'result' warning]

Link: https://lore.kernel.org/r/20210427083046.31620-21-hare@suse.de
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
fix

3 years agoscsi: dc395: Translate message bytes
Hannes Reinecke [Tue, 27 Apr 2021 08:30:25 +0000 (10:30 +0200)]
scsi: dc395: Translate message bytes

Drop message byte setting if the host byte is already set, and translate
message bytes into the related host bytes when evaluating an overrun or
underrun.

Link: https://lore.kernel.org/r/20210427083046.31620-20-hare@suse.de
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: dc395: Use standard macros to set SCSI result
Hannes Reinecke [Tue, 27 Apr 2021 08:30:24 +0000 (10:30 +0200)]
scsi: dc395: Use standard macros to set SCSI result

Use standard macros to set the SCSI result and drop the internal ones.

Link: https://lore.kernel.org/r/20210427083046.31620-19-hare@suse.de
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: core: Add scsi_msg_to_host_byte()
Hannes Reinecke [Tue, 27 Apr 2021 08:30:23 +0000 (10:30 +0200)]
scsi: core: Add scsi_msg_to_host_byte()

Add helper to convert message byte into a host byte code.

Link: https://lore.kernel.org/r/20210427083046.31620-18-hare@suse.de
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: core: Add get_{status,host}_byte() accessor functions
Hannes Reinecke [Tue, 27 Apr 2021 08:30:22 +0000 (10:30 +0200)]
scsi: core: Add get_{status,host}_byte() accessor functions

Add accessor functions for the host and status byte.

Link: https://lore.kernel.org/r/20210427083046.31620-17-hare@suse.de
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: NCR5380: Fold SCSI message ABORT onto DID_ABORT
Hannes Reinecke [Tue, 27 Apr 2021 08:30:21 +0000 (10:30 +0200)]
scsi: NCR5380: Fold SCSI message ABORT onto DID_ABORT

The message byte can take only two values, COMMAND_COMPLETE and ABORT.  So
we can easily map ABORT to DID_ABORT and not set the message byte.

Link: https://lore.kernel.org/r/20210427083046.31620-16-hare@suse.de
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: core: Drop the now obsolete driver_byte definitions
Hannes Reinecke [Tue, 27 Apr 2021 08:30:20 +0000 (10:30 +0200)]
scsi: core: Drop the now obsolete driver_byte definitions

The driver_byte field in the result is now unused, so we can drop the
definitions.

Link: https://lore.kernel.org/r/20210427083046.31620-15-hare@suse.de
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: xen-scsifront: Compability status handling
Hannes Reinecke [Tue, 27 Apr 2021 08:30:19 +0000 (10:30 +0200)]
scsi: xen-scsifront: Compability status handling

The Xen guest might run against arbitrary backends, so the driver might
receive a status with driver_byte set. Map these errors to DID_ERROR to be
consistent with recent changes.

Link: https://lore.kernel.org/r/20210427083046.31620-14-hare@suse.de
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: xen-scsiback: Use DID_ERROR instead of DRIVER_ERROR
Hannes Reinecke [Tue, 27 Apr 2021 08:30:18 +0000 (10:30 +0200)]
scsi: xen-scsiback: Use DID_ERROR instead of DRIVER_ERROR

DRIVER_ERROR was supposed to signal an error generated by the driver, which
xen-scsiback arguably isn't. Also the driver bytes don't have a detailed
error recovery, so we should rather return DID_ERROR instead of
DRIVER_ERROR.

Link: https://lore.kernel.org/r/20210427083046.31620-13-hare@suse.de
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: core: Use DID_TIME_OUT instead of DRIVER_TIMEOUT
Hannes Reinecke [Tue, 27 Apr 2021 08:30:17 +0000 (10:30 +0200)]
scsi: core: Use DID_TIME_OUT instead of DRIVER_TIMEOUT

Set DID_TIME_OUT instead of DRIVER_TIMEOUT when a command
is finally marked as failed after error recovery.

Link: https://lore.kernel.org/r/20210427083046.31620-12-hare@suse.de
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: core: Do not use DRIVER_INVALID
Hannes Reinecke [Tue, 27 Apr 2021 08:30:16 +0000 (10:30 +0200)]
scsi: core: Do not use DRIVER_INVALID

There is no point in returning DID_ABORT together with DRIVER_INVALID, as
the caller couldn't care less where the abort originated.  So drop the use
of DRIVER_INVALID.

Link: https://lore.kernel.org/r/20210427083046.31620-11-hare@suse.de
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: core: Kill DRIVER_SENSE
Hannes Reinecke [Tue, 27 Apr 2021 08:30:15 +0000 (10:30 +0200)]
scsi: core: Kill DRIVER_SENSE

Replace the check for DRIVER_SENSE with a check for
scsi_status_is_check_condition().

Audit all callsites to ensure the SAM status is set correctly. For
backwards compability move the DRIVER_SENSE definition to sg.h, and update
sg, bsg, and scsi_ioctl to set the DRIVER_SENSE driver_status whenever
SAM_STAT_CHECK_CONDITION is present.

[mkp: fix zeroday srp warning]

Link: https://lore.kernel.org/r/20210427083046.31620-10-hare@suse.de
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
fix