platform/kernel/linux-starfive.git
22 months agoscsi: aic79xx: Use __ro_after_init explicitly
Kees Cook [Wed, 14 Sep 2022 11:59:53 +0000 (04:59 -0700)]
scsi: aic79xx: Use __ro_after_init explicitly

ahd_linux_setup_iocell_info() intentionally writes to the const-marked
aic79xx_iocell_info array, but is called during __init, so the location is
actually writable at this point on most architectures. Annotate this
explicitly with __ro_after_init to avoid static analysis confusion.

Link: https://lpc.events/event/16/contributions/1175/attachments/1109/2128/2022-LPC-analyzer-talk.pdf
Link: https://lore.kernel.org/r/20220914115953.3854029-1-keescook@chromium.org
Cc: Hannes Reinecke <hare@suse.com>
Cc: "James E.J. Bottomley" <jejb@linux.ibm.com>
Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
Cc: linux-scsi@vger.kernel.org
Reported-by: David Malcolm <dmalcolm@redhat.com>
Signed-off-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
22 months agoscsi: target: Remove unused se_tmr_req_cache declaration
Gaosheng Cui [Tue, 13 Sep 2022 02:37:22 +0000 (10:37 +0800)]
scsi: target: Remove unused se_tmr_req_cache declaration

se_tmr_req_cache has been removed since commit c8e31f26feeb ("target: Add
SCF_SCSI_TMR_CDB usage and drop se_tmr_req_cache").

Remove extern.

Link: https://lore.kernel.org/r/20220913023722.547249-3-cuigaosheng1@huawei.com
Signed-off-by: Gaosheng Cui <cuigaosheng1@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
22 months agoscsi: qla2xxx: Remove unused declarations for qla2xxx
Gaosheng Cui [Tue, 13 Sep 2022 02:37:21 +0000 (10:37 +0800)]
scsi: qla2xxx: Remove unused declarations for qla2xxx

qla2x00_get_fw_version_str() has been removed since commit abbd8870b9cb
("[SCSI] qla2xxx: Factor-out ISP specific functions to method-based call
tables.").

qla2x00_release_nvram_protection() has been removed since commit
459c537807bd ("[SCSI] qla2xxx: Add ISP24xx flash-manipulation routines.").

qla82xx_rdmem() and qla82xx_wrmem() have been removed since commit
3711333dfbee ("[SCSI] qla2xxx: Updates for ISP82xx.").

qla25xx_rd_req_reg(), qla24xx_rd_req_reg(), qla25xx_wrt_rsp_reg(),
qla24xx_wrt_rsp_reg(), qla25xx_wrt_req_reg() and qla24xx_wrt_req_reg() have
been removed since commit 08029990b25b ("[SCSI] qla2xxx: Refactor
request/response-queue register handling.").

qla2x00_async_login_done() has been removed since commit 726b85487067
("qla2xxx: Add framework for async fabric discovery").

qlt_24xx_process_response_error() has been removed since commit
c5419e2618b9 ("scsi: qla2xxx: Combine Active command arrays.").

Remove the declarations for them from header file.

Link: https://lore.kernel.org/r/20220913023722.547249-2-cuigaosheng1@huawei.com
Signed-off-by: Gaosheng Cui <cuigaosheng1@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
22 months agoscsi: target: alua: Do not report emtpy port group
Dmitry Bogdanov [Mon, 12 Sep 2022 21:45:49 +0000 (00:45 +0300)]
scsi: target: alua: Do not report emtpy port group

The default target port group is always returned in the list of port
groups, even if the behaviour is unwanted, i.e. it has no members and
non-default port groups are primary port groups.

That violates SPC-4 "6.37 REPORT TARGET PORT GROUPS command":

  Every target port group shall contain at least one target port. The
  target port group descriptor shall include one target port descriptor for
  each target port in the target port group.

This patch hides port groups with no ports in REPORT TARGET PORT GROUPS
response.

Link: https://lore.kernel.org/r/20220912214549.27882-1-d.bogdanov@yadro.com
Signed-off-by: Dmitry Bogdanov <d.bogdanov@yadro.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
22 months agoscsi: target: core: Set MULTIP bit for se_device with multiple ports
Dmitry Bogdanov [Mon, 12 Sep 2022 12:54:57 +0000 (15:54 +0300)]
scsi: target: core: Set MULTIP bit for se_device with multiple ports

SAM-5 4.8.3 (SCSI target device with multiple SCSI ports structure)
obligates to set MULTIP bit when there's multiple SCSI target ports:

  Each device server shall indicate the presence of multiple SCSI
  target ports by setting the MULTIP bit to one in its standard
  INQUIRY data (see SPC-4).

Set MULTIP bit automatically to indicate the presence of multiple SCSI
target ports within standard inquiry response data if there are
multiple target ports in all target port groups of the se_device.

Link: https://lore.kernel.org/r/20220912125457.22573-2-d.bogdanov@yadro.com
Reviewed-by: Mike Christie <michael.christie@oracle.com>
Co-developed-by: Roman Bolshakov <r.bolshakov@yadro.com>
Signed-off-by: Roman Bolshakov <r.bolshakov@yadro.com>
Signed-off-by: Dmitry Bogdanov <d.bogdanov@yadro.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
22 months agoscsi: qla2xxx: Fix spelling mistake "definiton" -> "definition"
Colin Ian King [Tue, 6 Sep 2022 14:00:10 +0000 (15:00 +0100)]
scsi: qla2xxx: Fix spelling mistake "definiton" -> "definition"

There is a spelling mistake in a MODULE_PARM_DESC description. Fix it.

Link: https://lore.kernel.org/r/20220906140010.194273-1-colin.i.king@gmail.com
Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
22 months agoscsi: hisi_sas: Don't send bcast events from HW during nexus HA reset
John Garry [Mon, 5 Sep 2022 11:48:49 +0000 (19:48 +0800)]
scsi: hisi_sas: Don't send bcast events from HW during nexus HA reset

Remote devices may go missing from the per-device nexus reset part of the
HA nexus, i.e after the controller reset. This is because libsas may find
the devices to be gone as the phy may be temporarily down when processing
the bcast event generated from the nexus reset. Filter out bcast events
during this time to stop the devices being lost.

Link: https://lore.kernel.org/r/1662378529-101489-6-git-send-email-john.garry@huawei.com
Signed-off-by: John Garry <john.garry@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
22 months agoscsi: hisi_sas: Add helper to process bcast events
John Garry [Mon, 5 Sep 2022 11:48:48 +0000 (19:48 +0800)]
scsi: hisi_sas: Add helper to process bcast events

Add a helper for bcast processing to reduce duplication.

Link: https://lore.kernel.org/r/1662378529-101489-5-git-send-email-john.garry@huawei.com
Signed-off-by: John Garry <john.garry@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
22 months agoscsi: hisi_sas: Drain bcast events in hisi_sas_rescan_topology()
John Garry [Mon, 5 Sep 2022 11:48:47 +0000 (19:48 +0800)]
scsi: hisi_sas: Drain bcast events in hisi_sas_rescan_topology()

In resetting the controller, SATA devices may be lost.

The issue is that when we insert the bcast events to rescan the topology in
hisi_sas_rescan_topology(), when we subsequently nexus reset the SATA
devices in hisi_sas_async_I_T_nexus_reset(), there is a small timing window
in which the remote phy is down and we process the bcast event (meaning
that libsas judges that the disk is lost).

Ensure that all bcast events are processed prior to the nexus reset to
close this window.

Link: https://lore.kernel.org/r/1662378529-101489-4-git-send-email-john.garry@huawei.com
Signed-off-by: John Garry <john.garry@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
22 months agoscsi: hisi_sas: Clear HISI_SAS_HW_FAULT_BIT earlier
John Garry [Mon, 5 Sep 2022 11:48:46 +0000 (19:48 +0800)]
scsi: hisi_sas: Clear HISI_SAS_HW_FAULT_BIT earlier

Once the controller HW has been reset then we can unset flag
HISI_SAS_HW_FAULT_BIT. In clearing this flag earlier we can now
successfully execute commands in hisi_sas_controller_reset_done(), like
bcast processing.

Link: https://lore.kernel.org/r/1662378529-101489-3-git-send-email-john.garry@huawei.com
Signed-off-by: John Garry <john.garry@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
22 months agoscsi: hisi_sas: Revert change to limit max hw sectors for v3 HW
John Garry [Mon, 5 Sep 2022 11:48:45 +0000 (19:48 +0800)]
scsi: hisi_sas: Revert change to limit max hw sectors for v3 HW

Now that libsas and the SCSI core code limits the default sectors from
commit 4cbfca5f7750 ("scsi: scsi_transport_sas: cap shost opt_sectors
according to DMA optimal limit") and commit 608128d391fa ("scsi: sd: allow
max_sectors be capped at DMA optimal size limit"), there is no need for
the hack to limit the max HW sectors.

Link: https://lore.kernel.org/r/1662378529-101489-2-git-send-email-john.garry@huawei.com
Signed-off-by: John Garry <john.garry@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
22 months agoscsi: esas2r: Use flex array destination for memcpy()
Kees Cook [Thu, 1 Sep 2022 20:57:29 +0000 (13:57 -0700)]
scsi: esas2r: Use flex array destination for memcpy()

In preparation for FORTIFY_SOURCE performing run-time destination buffer
bounds checking for memcpy(), specify the destination output buffer
explicitly, instead of asking memcpy() to write past the end of what looked
like a fixed-size object. Silences future run-time warning:

  memcpy: detected field-spanning write (size 80) of single field "trc + 1" (size 64)

There is no binary code output differences from this change.

Link: https://lore.kernel.org/r/20220901205729.2260982-1-keescook@chromium.org
Cc: Bradley Grove <linuxdrivers@attotech.com>
Cc: "James E.J. Bottomley" <jejb@linux.ibm.com>
Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
Cc: linux-scsi@vger.kernel.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>
22 months agoscsi: 3w-9xxx: Avoid disabling device if failing to enable it
Letu Ren [Mon, 29 Aug 2022 11:01:15 +0000 (19:01 +0800)]
scsi: 3w-9xxx: Avoid disabling device if failing to enable it

The original code will "goto out_disable_device" and call
pci_disable_device() if pci_enable_device() fails. The kernel will generate
a warning message like "3w-9xxx 0000:00:05.0: disabling already-disabled
device".

We shouldn't disable a device that failed to be enabled. A simple return is
fine.

Link: https://lore.kernel.org/r/20220829110115.38789-1-fantasquex@gmail.com
Reported-by: Zheyu Ma <zheyuma97@gmail.com>
Signed-off-by: Letu Ren <fantasquex@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
22 months agoscsi: ufs: core: Print UFSHCD capabilities in controller's sysfs node
Daniil Lunev [Sun, 28 Aug 2022 22:18:58 +0000 (08:18 +1000)]
scsi: ufs: core: Print UFSHCD capabilities in controller's sysfs node

Userspace may want to manually control when the data should go into
WriteBooster buffer. The control happens via "wb_on" node, but presently,
there is no simple way to check if WriteBooster is supported and
enabled.

Expose the Write Booster and Clock Scaling capabilities to be able to
determine if the Write Booster is available and if its manual control is
blocked by Clock Scaling mechanism.

Link: https://lore.kernel.org/r/20220829081845.v8.1.Ibf9efc9be50783eeee55befa2270b7d38552354c@changeid
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Daniil Lunev <dlunev@chromium.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
22 months agoscsi: qlogicpti: Fix dma_map_sg() check
Jack Wang [Fri, 26 Aug 2022 10:14:35 +0000 (12:14 +0200)]
scsi: qlogicpti: Fix dma_map_sg() check

Add missing error check for dma_map_sg().

Cc: "James E.J. Bottomley" <jejb@linux.ibm.com>
Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
Cc: linux-scsi@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Link: https://lore.kernel.org/r/20220826101435.79170-1-jinpu.wang@ionos.com
Signed-off-by: Jack Wang <jinpu.wang@ionos.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
22 months agoscsi: core: Remove useless host error codes
Mike Christie [Fri, 12 Aug 2022 01:00:27 +0000 (20:00 -0500)]
scsi: core: Remove useless host error codes

The host codes that were supposed to only be used for internal use are now
not used, so remove them.

Link: https://lore.kernel.org/r/20220812010027.8251-11-michael.christie@oracle.com
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Mike Christie <michael.christie@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
22 months agoscsi: core: Convert scsi_decide_disposition() to use SCSIML_STAT
Mike Christie [Fri, 12 Aug 2022 01:00:26 +0000 (20:00 -0500)]
scsi: core: Convert scsi_decide_disposition() to use SCSIML_STAT

Don't use:

 - DID_TARGET_FAILURE

 - DID_NEXUS_FAILURE

 - DID_ALLOC_FAILURE

 - DID_MEDIUM_ERROR

Instead use the SCSI midlayer internal values.

Link: https://lore.kernel.org/r/20220812010027.8251-10-michael.christie@oracle.com
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Mike Christie <michael.christie@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
22 months agoscsi: core: Add error codes for internal SCSI midlayer use
Mike Christie [Fri, 12 Aug 2022 01:00:25 +0000 (20:00 -0500)]
scsi: core: Add error codes for internal SCSI midlayer use

If a driver returns:

 - DID_TARGET_FAILURE

 - DID_NEXUS_FAILURE

 - DID_ALLOC_FAILURE

 - DID_MEDIUM_ERROR

we hit a couple bugs:

1. The SCSI error handler runs because scsi_decide_disposition() has no
case statements for them and we return FAILED.

2. For SG IO the userspace app gets a success status instead of failed,
because scsi_result_to_blk_status() clears those errors.

This patch adds a new internal error code byte for use by the SCSI
midlayer.  This will be used instead of the above error codes, so we don't
have to play that clearing the host code game in
scsi_result_to_blk_status() and drivers cannot accidentally use them.

A subsequent commit will then remove the internal users of the above codes
and convert us to use the new ones.

Link: https://lore.kernel.org/r/20220812010027.8251-9-michael.christie@oracle.com
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Mike Christie <michael.christie@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
22 months agoscsi: cxlflash: Drop DID_ALLOC_FAILURE use
Mike Christie [Fri, 12 Aug 2022 01:00:24 +0000 (20:00 -0500)]
scsi: cxlflash: Drop DID_ALLOC_FAILURE use

DID_ALLOC_FAILURE is internal to the SCSI layer. Drivers must not use it
because:

 1. It's not propagated upwards, so SG IO/passthrough users will not see an
    error and think a command was successful.

 2. There is no handling for it in scsi_decide_disposition() so it results
    in entering SCSI error handling.

By the code comment, it looks like the driver wanted a retryable error
code, so this has it use DID_ERROR.

Link: https://lore.kernel.org/r/20220812010027.8251-8-michael.christie@oracle.com
Signed-off-by: Mike Christie <michael.christie@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
22 months agoscsi: qla2xxx: Drop DID_TARGET_FAILURE use
Mike Christie [Fri, 12 Aug 2022 01:00:23 +0000 (20:00 -0500)]
scsi: qla2xxx: Drop DID_TARGET_FAILURE use

DID_TARGET_FAILURE is internal to the SCSI layer. Drivers must not use it
because:

 1. It's not propagated upwards, so SG IO/passthrough users will not see an
    error and think a command was successful.

 2. There is no handling for it in scsi_decide_disposition() so it
    results in entering SCSI error handling.

This has qla2xxx use DID_NO_CONNECT because it looks like we hit this error
when we can't find a port. It will give us the same hard error behavior and
it seems to match the error where we can't find the endpoint.

Link: https://lore.kernel.org/r/20220812010027.8251-7-michael.christie@oracle.com
Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
Signed-off-by: Mike Christie <michael.christie@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
22 months agoscsi: virtio_scsi: Drop DID_NEXUS_FAILURE use
Mike Christie [Fri, 12 Aug 2022 01:00:22 +0000 (20:00 -0500)]
scsi: virtio_scsi: Drop DID_NEXUS_FAILURE use

DID_NEXUS_FAILURE is internal to the SCSI layer. Drivers must not use it
because:

 1. It's not propagated upwards, so SG IO/passthrough users will not see an
    error and think a command was successful.

 2. There is no handling for it in scsi_decide_disposition() so it results
    in entering SCSI error handling.

virtio_scsi gets this when something like qemu returns
VIRTIO_SCSI_S_NEXUS_FAILURE. It looks like qemu returns that error code if
host OS returns DID_NEXUS_FAILURE (qemu's internal
SCSI_HOST_RESERVATION_ERROR maps to DID_NEXUS_FAILURE). This shouldn't
happen for Linux since we don't propagate that error code to userspace.

This has us convert VIRTIO_SCSI_S_NEXUS_FAILURE to a
SAM_STAT_RESERVATION_CONFLICT in case some other virt layer is returning
it. In that case we will still get the reservation confict failure we
expect.

Link: https://lore.kernel.org/r/20220812010027.8251-6-michael.christie@oracle.com
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Mike Christie <michael.christie@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
22 months agoscsi: virtio_scsi: Drop DID_TARGET_FAILURE use
Mike Christie [Fri, 12 Aug 2022 01:00:21 +0000 (20:00 -0500)]
scsi: virtio_scsi: Drop DID_TARGET_FAILURE use

DID_TARGET_FAILURE is internal to the SCSI layer. Drivers must not use it
because:

 1. It's not propagated upwards, so SG IO/passthrough users will not see an
    error and think a command was successful.

 2. There is no handling for it in scsi_decide_disposition() so it results
    in entering SCSI error handling.

virtio_scsi gets this when something like qemu returns
VIRTIO_SCSI_S_TARGET_FAILURE.  It looks like qemu returns that error code
if a host OS returns it, but this shouldn't happen for Linux since we never
propagate that error to userspace.

This has us use DID_BAD_TARGET in case some other virt layer is returning
it. In that case we will still get a hard error like before and it conveys
something unexpected happened.

Link: https://lore.kernel.org/r/20220812010027.8251-5-michael.christie@oracle.com
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Mike Christie <michael.christie@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
22 months agoscsi: uas: Drop DID_TARGET_FAILURE use
Mike Christie [Fri, 12 Aug 2022 01:00:20 +0000 (20:00 -0500)]
scsi: uas: Drop DID_TARGET_FAILURE use

DID_TARGET_FAILURE is internal to the SCSI layer. Drivers must not use it
because:

 1. It's not propagated upwards, so SG IO/passthrough users will not see an
    error and think a command was successful.

 2. There is no handling for it in scsi_decide_disposition() so it results
    in entering SCSI error handling.

It looks like the driver wanted a hard failure so this swaps it with
DID_BAD_TARGET which gives us that behavior. The error looks like it's for
a case where the target did not support a TMF we wanted to use (maybe not a
bad target but disappointing so close enough).

Link: https://lore.kernel.org/r/20220812010027.8251-4-michael.christie@oracle.com
Signed-off-by: Mike Christie <michael.christie@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
22 months agoscsi: storvsc: Drop DID_TARGET_FAILURE use
Mike Christie [Fri, 12 Aug 2022 01:00:19 +0000 (20:00 -0500)]
scsi: storvsc: Drop DID_TARGET_FAILURE use

DID_TARGET_FAILURE is internal to the SCSI layer. Drivers must not use it
because:

 1. It's not propagated upwards, so SG IO/passthrough users will not see an
    error and think a command was successful.

 2. There is no handling for it in scsi_decide_disposition() so it results
    in the SCSI error handling running.

It looks like the driver wanted a hard failure so swap it with
DID_BAD_TARGET.

Link: https://lore.kernel.org/r/20220812010027.8251-3-michael.christie@oracle.com
Signed-off-by: Mike Christie <michael.christie@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
22 months agoscsi: xen: Drop use of internal host codes
Mike Christie [Fri, 12 Aug 2022 01:00:18 +0000 (20:00 -0500)]
scsi: xen: Drop use of internal host codes

The error codes:

 - DID_TARGET_FAILURE

 - DID_NEXUS_FAILURE

 - DID_ALLOC_FAILURE

 - DID_MEDIUM_ERROR

are internal to the SCSI layer. Drivers must not use them because:

 1. They are not propagated upwards, so SG IO/passthrough users will not
    see an error and think a command was successful.

    xen-scsiback will never see this error and should not try to send it.

 2. There is no handling for them in scsi_decide_disposition() so if
    xen-scsifront were to return the error to the SCSI midlayer then it
    kicks off the error handler which is definitely not what we want.

Remove the use from xen-scsifront/back.

Link: https://lore.kernel.org/r/20220812010027.8251-2-michael.christie@oracle.com
Reviewed-by: Juergen Gross <jgross@suse.com>
Signed-off-by: Mike Christie <michael.christie@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
22 months agoscsi: target: pscsi: Remove repeated word "calling"
Shaomin Deng [Thu, 11 Aug 2022 15:39:23 +0000 (11:39 -0400)]
scsi: target: pscsi: Remove repeated word "calling"

There is repeated word, remove it.

Link: https://lore.kernel.org/r/20220811153923.17278-1-dengshaomin@cdjrlc.com
Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
Signed-off-by: Shaomin Deng <dengshaomin@cdjrlc.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
22 months agoscsi: hpsa: Simplify {clear|set}_bit() parameters
Christophe JAILLET [Wed, 20 Jul 2022 18:14:02 +0000 (20:14 +0200)]
scsi: hpsa: Simplify {clear|set}_bit() parameters

{clear|set}_bit() can take an almost arbitrarily large bit number, so there
is no need to manually compute addresses. This is just redundant.

Link: https://lore.kernel.org/r/c3429a22023f58e5e5cc65d6cd7e83fb2bd9b870.1658340442.git.christophe.jaillet@wanadoo.fr
Tested-by: Don Brace <don.brace@microchip.com>
Acked-by: Don Brace <don.brace@microchip.com>
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
22 months agoscsi: hpsa: Use the bitmap API to allocate bitmaps
Christophe JAILLET [Wed, 20 Jul 2022 18:13:54 +0000 (20:13 +0200)]
scsi: hpsa: Use the bitmap API to allocate bitmaps

Use bitmap_zalloc()/bitmap_free() instead of hand-writing them. It is less
verbose and it improves the semantic.

Link: https://lore.kernel.org/r/5f975ef43f8b7306e4ac4e2e8ce4bcd53f6092bb.1658340441.git.christophe.jaillet@wanadoo.fr
Tested-by: Don Brace <don.brace@microchip.com>
Acked-by: Don Brace <don.brace@microchip.com>
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
22 months agoscsi: lpfc: Remove unneeded result variable
ye xingchen [Wed, 24 Aug 2022 07:51:23 +0000 (07:51 +0000)]
scsi: lpfc: Remove unneeded result variable

Return the value from lpfc_issue_reg_vfi() directly instead of storing it
in another redundant variable.

Link: https://lore.kernel.org/r/20220824075123.221316-1-ye.xingchen@zte.com.cn
Reported-by: Zeal Robot <zealci@zte.com.cn>
Reviewed-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: ye xingchen <ye.xingchen@zte.com.cn>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
22 months agoscsi: lpfc: Remove the unneeded result variable
ye xingchen [Wed, 24 Aug 2022 07:50:17 +0000 (07:50 +0000)]
scsi: lpfc: Remove the unneeded result variable

Return the value from lpfc_sli4_issue_wqe() directly instead of storing it
in another redundant variable.

Link: https://lore.kernel.org/r/20220824075017.221244-1-ye.xingchen@zte.com.cn
Reported-by: Zeal Robot <zealci@zte.com.cn>
Reviewed-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: ye xingchen <ye.xingchen@zte.com.cn>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
22 months agoscsi: docs: Fix a typo
Randy Dunlap [Sat, 27 Aug 2022 22:17:19 +0000 (15:17 -0700)]
scsi: docs: Fix a typo

Correct a typo in SCSI documentation.

Link: https://lore.kernel.org/r/20220827221719.11006-1-rdunlap@infradead.org
Cc: "James E.J. Bottomley" <jejb@linux.ibm.com>
Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
Cc: linux-scsi@vger.kernel.org
Cc: Jonathan Corbet <corbet@lwn.net>
Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
22 months agoscsi: qla2xxx: Update version to 10.02.07.900-k
Nilesh Javali [Fri, 26 Aug 2022 10:25:59 +0000 (03:25 -0700)]
scsi: qla2xxx: Update version to 10.02.07.900-k

Link: https://lore.kernel.org/r/20220826102559.17474-8-njavali@marvell.com
Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
Signed-off-by: Nilesh Javali <njavali@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
22 months agoscsi: qla2xxx: Define static symbols
Nilesh Javali [Fri, 26 Aug 2022 10:25:58 +0000 (03:25 -0700)]
scsi: qla2xxx: Define static symbols

drivers/scsi/qla2xxx/qla_os.c:40:20: warning: symbol 'qla_trc_array'
was not declared. Should it be static?
drivers/scsi/qla2xxx/qla_os.c:345:5: warning: symbol
'ql2xdelay_before_pci_error_handling' was not declared.
Should it be static?

Define qla_trc_array and ql2xdelay_before_pci_error_handling as static to
fix sparse warnings.

Link: https://lore.kernel.org/r/20220826102559.17474-7-njavali@marvell.com
Cc: stable@vger.kernel.org
Reported-by: kernel test robot <lkp@intel.com>
Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
Signed-off-by: Nilesh Javali <njavali@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
22 months agoscsi: qla2xxx: Enhance driver tracing with separate tunable and more
Arun Easi [Fri, 26 Aug 2022 10:25:57 +0000 (03:25 -0700)]
scsi: qla2xxx: Enhance driver tracing with separate tunable and more

Older tracing of driver messages was to:

    - log only debug messages to kernel main trace buffer; and

    - log only if extended logging bits corresponding to this message is
      off

This has been modified and extended as follows:

    - Tracing is now controlled via ql2xextended_error_logging_ktrace
      module parameter. Bit usages same as ql2xextended_error_logging.

    - Tracing uses "qla2xxx" trace instance, unless instance creation have
      issues.

    - Tracing is enabled (compile time tunable).

    - All driver messages, include debug and log messages are now traced in
      kernel trace buffer.

Trace messages can be viewed by looking at the qla2xxx instance at:

    /sys/kernel/tracing/instances/qla2xxx/trace

Trace tunable that takes the same bit mask as ql2xextended_error_logging
is:

    ql2xextended_error_logging_ktrace (default=1)

Link: https://lore.kernel.org/r/20220826102559.17474-6-njavali@marvell.com
Suggested-by: Daniel Wagner <dwagner@suse.de>
Suggested-by: Steven Rostedt <rostedt@goodmis.org>
Tested-by: Himanshu Madhani <himanshu.madhani@oracle.com>
Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
Reviewed-by: Daniel Wagner <dwagner@suse.de>
Signed-off-by: Arun Easi <aeasi@marvell.com>
Signed-off-by: Nilesh Javali <njavali@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
22 months agoscsi: qla2xxx: Add NVMe parameters support in Auxiliary Image Status
Anil Gurumurthy [Fri, 26 Aug 2022 10:25:56 +0000 (03:25 -0700)]
scsi: qla2xxx: Add NVMe parameters support in Auxiliary Image Status

Add new API to obtain the NVMe Parameters region status from the Auxiliary
Image Status bitmap.

Link: https://lore.kernel.org/r/20220826102559.17474-5-njavali@marvell.com
Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
Signed-off-by: Anil Gurumurthy <agurumurthy@marvell.com>
Signed-off-by: Nilesh Javali <njavali@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
22 months agoscsi: qla2xxx: Add debugfs create/delete helpers
Arun Easi [Fri, 26 Aug 2022 10:25:55 +0000 (03:25 -0700)]
scsi: qla2xxx: Add debugfs create/delete helpers

Define a few helpful macros for creating debugfs files.

Link: https://lore.kernel.org/r/20220826102559.17474-4-njavali@marvell.com
Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
Signed-off-by: Arun Easi <aeasi@marvell.com>
Signed-off-by: Nilesh Javali <njavali@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
22 months agoscsi: qla2xxx: Fix response queue handler reading stale packets
Arun Easi [Fri, 26 Aug 2022 10:25:54 +0000 (03:25 -0700)]
scsi: qla2xxx: Fix response queue handler reading stale packets

On some platforms, the current logic of relying on finding new packet
solely based on signature pattern can lead to driver reading stale
packets. Though this is a bug in those platforms, reduce such exposures by
limiting reading packets until the IN pointer.

Link: https://lore.kernel.org/r/20220826102559.17474-3-njavali@marvell.com
Cc: stable@vger.kernel.org
Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
Signed-off-by: Arun Easi <aeasi@marvell.com>
Signed-off-by: Nilesh Javali <njavali@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
22 months agoscsi: qla2xxx: Revert "scsi: qla2xxx: Fix response queue handler reading stale packets"
Arun Easi [Fri, 26 Aug 2022 10:25:53 +0000 (03:25 -0700)]
scsi: qla2xxx: Revert "scsi: qla2xxx: Fix response queue handler reading stale packets"

Reverting this commit so that a fixed up patch, without adding new module
parameters, can be submitted.

Link: https://lore.kernel.org/stable/166039743723771@kroah.com/
This reverts commit b1f707146923335849fb70237eec27d4d1ae7d62.

Link: https://lore.kernel.org/r/20220826102559.17474-2-njavali@marvell.com
Cc: stable@vger.kernel.org
Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
Signed-off-by: Arun Easi <aeasi@marvell.com>
Signed-off-by: Nilesh Javali <njavali@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
22 months agoscsi: qla2xxx: Log message "skipping scsi_scan_host()" as informational
Mauricio Faria de Oliveira [Thu, 25 Aug 2022 12:01:59 +0000 (09:01 -0300)]
scsi: qla2xxx: Log message "skipping scsi_scan_host()" as informational

This message is helpful to troubleshoot missing LUNs/SAN boot errors.  It'd
be nice to log it by default instead of only being enabled with debug.

This user had an accidental/forgotten file modprobe.d/qla2xxx.conf w/
option qlini_mode=disabled from experiments with FC target mode, and their
boot LUN didn't come up, as it skips SCSI scan, of course.

However, their boot log didn't provide any clues to help understand that.

The issue/message could be figured out w/ ql2xextended_error_logging, but
it would have been simpler (or even deflected/addressed by user) if it had
been there by default. And it also would help support/triage/deflection
tooling.

Expected change:

 scsi host15: qla2xxx
+qla2xxx [0000:3b:00.0]-00fb:15: skipping scsi_scan_host() for non-initiator port
 qla2xxx [0000:3b:00.0]-00fb:15: QLogic QLE2692 - QLE2692 Dual Port 16Gb FC to PCIe Gen3 x8 Adapter.

According to:

  qla2x00_probe_one()
  ...
          ret = scsi_add_host(...);
  ...
                  ql_log(ql_log_info, ...
                          "skipping scsi_scan_host() for non-initiator port\n");
  ...
          ql_log(ql_log_info, ...
              "QLogic %s - %s.\n", ha->model_number, ha->model_desc);

Link: https://lore.kernel.org/r/20220825120159.275051-1-mfo@canonical.com
Tested-by: Himanshu Madhani <himanshu.madhani@oracle.com>
Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
Signed-off-by: Mauricio Faria de Oliveira <mfo@canonical.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
22 months agoscsi: mpt3sas: Update driver version to 43.100.00.00
Sreekanth Reddy [Thu, 25 Aug 2022 07:54:57 +0000 (13:24 +0530)]
scsi: mpt3sas: Update driver version to 43.100.00.00

Update driver version to 43.100.00.00.

Link: https://lore.kernel.org/r/20220825075457.16422-5-sreekanth.reddy@broadcom.com
Signed-off-by: Sreekanth Reddy <sreekanth.reddy@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
22 months agoscsi: mpt3sas: Increase cmd_per_lun to 128
Sreekanth Reddy [Thu, 25 Aug 2022 07:54:56 +0000 (13:24 +0530)]
scsi: mpt3sas: Increase cmd_per_lun to 128

With cmd_per_lun value 7, a higher number of cache lines (map_nr) are
needed while allocating sdev->budget_map which is not reasonable and hence
increase the cmd_per_lun value to 128.

Link: https://lore.kernel.org/r/20220825075457.16422-4-sreekanth.reddy@broadcom.com
Signed-off-by: Sreekanth Reddy <sreekanth.reddy@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
22 months agoscsi: mpt3sas: Fix trace buffer registration failed
Sreekanth Reddy [Thu, 25 Aug 2022 07:54:55 +0000 (13:24 +0530)]
scsi: mpt3sas: Fix trace buffer registration failed

The ExtendedType field was set to 1 in the diag buffer register command and
hence MPT Endpoint firmware is failing the request with Invalid Field
IOCStatus.

memset the request frame to zero before framing the diag buffer register
command.

Link: https://lore.kernel.org/r/20220825075457.16422-3-sreekanth.reddy@broadcom.com
Signed-off-by: Sreekanth Reddy <sreekanth.reddy@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
22 months agoscsi: mpt3sas: Don't change DMA mask while reallocating pools
Sreekanth Reddy [Thu, 25 Aug 2022 07:54:54 +0000 (13:24 +0530)]
scsi: mpt3sas: Don't change DMA mask while reallocating pools

When a pool crosses the 4GB boundary region then before reallocating pools
change the coherent DMA mask to 32 bits and keep the normal DMA mask set to
63/64 bits.

Link: https://lore.kernel.org/r/20220825075457.16422-2-sreekanth.reddy@broadcom.com
Signed-off-by: Sreekanth Reddy <sreekanth.reddy@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
22 months agoscsi: mpt3sas: Prevent error handler escalation when device removed
Sreekanth Reddy [Tue, 16 Aug 2022 08:08:01 +0000 (13:38 +0530)]
scsi: mpt3sas: Prevent error handler escalation when device removed

If SCSI error handling is taking place for timed out I/Os on a drive and
the corresponding drive is removed, then stop escalating to higher level of
reset by returning the TUR with "I_T NEXUS LOSS OCCURRED" sense key.

Link: https://lore.kernel.org/r/20220816080801.13929-1-sreekanth.reddy@broadcom.com
Signed-off-by: Sreekanth Reddy <sreekanth.reddy@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
22 months agoscsi: megaraid_sas: Use struct_size() in code related to struct MR_PD_CFG_SEQ_NUM_SYNC
Gustavo A. R. Silva [Mon, 15 Aug 2022 21:52:33 +0000 (16:52 -0500)]
scsi: megaraid_sas: Use struct_size() in code related to struct MR_PD_CFG_SEQ_NUM_SYNC

Prefer struct_size() over open-coded versions of idiom:

        sizeof(struct-with-flex-array) + sizeof(type-of-flex-array) * count

where count is the max number of items the flexible array is supposed to
have.

Link: https://github.com/KSPP/linux/issues/160
Link: https://lore.kernel.org/r/b215f4760f0e8fbe5fc35be20f2487e89924424d.1660592640.git.gustavoars@kernel.org
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>
22 months agoscsi: megaraid_sas: Use struct_size() in code related to struct MR_FW_RAID_MAP
Gustavo A. R. Silva [Mon, 15 Aug 2022 21:51:36 +0000 (16:51 -0500)]
scsi: megaraid_sas: Use struct_size() in code related to struct MR_FW_RAID_MAP

Prefer struct_size() over open-coded versions of idiom:

sizeof(struct-with-flex-array) + sizeof(type-of-flex-array) * count

where count is the max number of items the flexible array is supposed to
have.

Link: https://github.com/KSPP/linux/issues/160
Link: https://lore.kernel.org/r/1211398fb8f7ab332a93f4f8f1a63e8168dbd002.1660592640.git.gustavoars@kernel.org
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>
22 months agoscsi: megaraid_sas: Replace one-element array with flexible-array member in MR_PD_CFG...
Gustavo A. R. Silva [Mon, 15 Aug 2022 21:49:38 +0000 (16:49 -0500)]
scsi: megaraid_sas: Replace one-element array with flexible-array member in MR_PD_CFG_SEQ_NUM_SYNC

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 MR_PD_CFG_SEQ_NUM_SYNC and refactor the rest of the code
accordingly.

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 [0].

Link: https://github.com/KSPP/linux/issues/79
Link: https://github.com/KSPP/linux/issues/109
Link: https://reviews.llvm.org/D126864
Link: https://lore.kernel.org/r/78e9261591db072b67fcf49f0216d7046a67ca6d.1660592640.git.gustavoars@kernel.org
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>
22 months agoscsi: megaraid_sas: Replace one-element array with flexible-array member in MR_DRV_RA...
Gustavo A. R. Silva [Mon, 15 Aug 2022 21:46:13 +0000 (16:46 -0500)]
scsi: megaraid_sas: Replace one-element array with flexible-array member in MR_DRV_RAID_MAP

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 MR_DRV_RAID_MAP and refactor the code accordingly.

This helps with the ongoing efforts to tighten the FORTIFY_SOURCE routines
on memcpy().

Link: https://github.com/KSPP/linux/issues/79
Link: https://github.com/KSPP/linux/issues/109
Link: https://lore.kernel.org/r/1448f387821833726b99f0ce13069ada89164eb5.1660592640.git.gustavoars@kernel.org
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>
Enhanced-by: Kees Cook <keescook@chromium.org> # Change in struct MR_DRV_RAID_MAP_ALL
22 months agoscsi: megaraid_sas: Replace one-element array with flexible-array member in MR_FW_RAI...
Gustavo A. R. Silva [Mon, 15 Aug 2022 21:42:21 +0000 (16:42 -0500)]
scsi: megaraid_sas: Replace one-element array with flexible-array member in MR_FW_RAID_MAP_DYNAMIC

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 MR_FW_RAID_MAP_DYNAMIC.

This helps with the ongoing efforts to tighten the FORTIFY_SOURCE routines
on memcpy().

Link: https://github.com/KSPP/linux/issues/79
Link: https://github.com/KSPP/linux/issues/109
Link: https://lore.kernel.org/r/896476f8fe43cf83b491c6c13f59c9ace780d82c.1660592640.git.gustavoars@kernel.org
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>
22 months agoscsi: megaraid_sas: Replace one-element array with flexible-array member in MR_FW_RAI...
Gustavo A. R. Silva [Mon, 15 Aug 2022 21:40:35 +0000 (16:40 -0500)]
scsi: megaraid_sas: Replace one-element array with flexible-array member in MR_FW_RAID_MAP

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 MR_DRV_RAID_MAP and refactor the the rest of the code
accordingly.

This helps with the ongoing efforts to tighten the FORTIFY_SOURCE routines
on memcpy().

Link: https://github.com/KSPP/linux/issues/79
Link: https://github.com/KSPP/linux/issues/109
Link: https://lore.kernel.org/r/4495ce170c8ef088a10f1abe0e7c227368f43242.1660592640.git.gustavoars@kernel.org
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>
Enhanced-by: Kees Cook <keescook@chromium.org> # Change in struct MR_FW_RAID_MAP_ALL
22 months agoscsi: qla2xxx: Avoid flush_scheduled_work() usage
Tetsuo Handa [Sun, 21 Aug 2022 03:59:44 +0000 (12:59 +0900)]
scsi: qla2xxx: Avoid flush_scheduled_work() usage

Although qla2xxx driver is calling schedule_{,delayed}_work() from 10
locations, I assume that flush_scheduled_work() from qlt_stop_phase1()
needs to flush only works scheduled by qlt_sched_sess_work(), for this loop
continues while "struct qla_tgt"->sess_works_list is not empty.

Link: https://lore.kernel.org/r/133c6723-90b6-5c8b-72b4-cc01eeb3a8c0@I-love.SAKURA.ne.jp
Tested-by: Himanshu Madhani <himanshu.madhani@oracle.com>
Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
22 months agoscsi: qla2xxx: Always wait for qlt_sess_work_fn() from qlt_stop_phase1()
Tetsuo Handa [Sun, 21 Aug 2022 03:59:00 +0000 (12:59 +0900)]
scsi: qla2xxx: Always wait for qlt_sess_work_fn() from qlt_stop_phase1()

Currently qlt_stop_phase1() may fail to call flush_scheduled_work(), for
list_empty() may return true as soon as qlt_sess_work_fn() called
list_del(). In order to close this race window, check list_empty() after
calling flush_scheduled_work().

If this patch causes problems, please check commit c4f135d64382
("workqueue: Wrap flush_workqueue() using a macro"). We are on the way to
remove all flush_scheduled_work() calls from the kernel.

Link: https://lore.kernel.org/r/7f24469d-9e39-3398-d851-329b54c0b923@I-love.SAKURA.ne.jp
Tested-by: Himanshu Madhani <himanshu.madhani@oracle.com>
Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
22 months agoscsi: qla2xxx: Remove unused qlt_tmr_work()
Tetsuo Handa [Sun, 21 Aug 2022 03:58:24 +0000 (12:58 +0900)]
scsi: qla2xxx: Remove unused qlt_tmr_work()

qlt_tmr_work() is no longer used since commit fb35265b12bb ("scsi:
qla2xxx: Remove session creation redundant code").

Link: https://lore.kernel.org/r/a0e53c70-b801-adf5-0549-b2b1e421a819@I-love.SAKURA.ne.jp
Tested-by: Himanshu Madhani <himanshu.madhani@oracle.com>
Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
22 months agoscsi: qla2xxx: Remove unused del_sess_list field
Tetsuo Handa [Sun, 21 Aug 2022 03:57:50 +0000 (12:57 +0900)]
scsi: qla2xxx: Remove unused del_sess_list field

"struct qla_tgt"->del_sess_list is no longer used since commit
726b85487067 ("qla2xxx: Add framework for async fabric discovery").

Link: https://lore.kernel.org/r/0c335e86-5624-b599-5137-f1377419fb0c@I-love.SAKURA.ne.jp
Tested-by: Himanshu Madhani <himanshu.madhani@oracle.com>
Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
22 months agoscsi: lpfc: Copyright updates for 14.2.0.6 patches
James Smart [Fri, 19 Aug 2022 01:17:36 +0000 (18:17 -0700)]
scsi: lpfc: Copyright updates for 14.2.0.6 patches

Update copyrights to 2022 for files modified in the 14.2.0.6 patch set.

Link: https://lore.kernel.org/r/20220819011736.14141-8-jsmart2021@gmail.com
Co-developed-by: Justin Tee <justin.tee@broadcom.com>
Signed-off-by: Justin Tee <justin.tee@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
22 months agoscsi: lpfc: Update lpfc version to 14.2.0.6
James Smart [Fri, 19 Aug 2022 01:17:35 +0000 (18:17 -0700)]
scsi: lpfc: Update lpfc version to 14.2.0.6

Update lpfc version to 14.2.0.6.

Link: https://lore.kernel.org/r/20220819011736.14141-7-jsmart2021@gmail.com
Co-developed-by: Justin Tee <justin.tee@broadcom.com>
Signed-off-by: Justin Tee <justin.tee@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
22 months agoscsi: lpfc: Remove SANDiags related code
James Smart [Fri, 19 Aug 2022 01:17:34 +0000 (18:17 -0700)]
scsi: lpfc: Remove SANDiags related code

The SANDiags feature is unused, and related code is removed.

Link: https://lore.kernel.org/r/20220819011736.14141-6-jsmart2021@gmail.com
Co-developed-by: Justin Tee <justin.tee@broadcom.com>
Signed-off-by: Justin Tee <justin.tee@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
22 months agoscsi: lpfc: Add warning notification period to CMF_SYNC_WQE
James Smart [Fri, 19 Aug 2022 01:17:33 +0000 (18:17 -0700)]
scsi: lpfc: Add warning notification period to CMF_SYNC_WQE

Add capability to specify warning notification period to help firmware
adjust to congestion accordingly.

Link: https://lore.kernel.org/r/20220819011736.14141-5-jsmart2021@gmail.com
Co-developed-by: Justin Tee <justin.tee@broadcom.com>
Signed-off-by: Justin Tee <justin.tee@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
22 months agoscsi: lpfc: Rework MIB Rx Monitor debug info logic
James Smart [Fri, 19 Aug 2022 01:17:32 +0000 (18:17 -0700)]
scsi: lpfc: Rework MIB Rx Monitor debug info logic

The kernel test robot reported the following sparse warning:

arch/arm64/include/asm/cmpxchg.h:88:1: sparse: sparse: cast truncates
   bits from constant value (369 becomes 69)

On arm64, atomic_xchg only works on 8-bit byte fields.  Thus, the macro
usage of LPFC_RXMONITOR_TABLE_IN_USE can be unintentionally truncated
leading to all logic involving the LPFC_RXMONITOR_TABLE_IN_USE macro to not
work properly.

Replace the Rx Table atomic_t indexing logic with a new
lpfc_rx_info_monitor structure that holds a circular ring buffer.  For
locking semantics, a spinlock_t is used.

Link: https://lore.kernel.org/r/20220819011736.14141-4-jsmart2021@gmail.com
Fixes: 17b27ac59224 ("scsi: lpfc: Add rx monitoring statistics")
Cc: <stable@vger.kernel.org> # v5.15+
Co-developed-by: Justin Tee <justin.tee@broadcom.com>
Signed-off-by: Justin Tee <justin.tee@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
22 months agoscsi: lpfc: Fix null ndlp ptr dereference in abnormal exit path for GFT_ID
James Smart [Fri, 19 Aug 2022 01:17:31 +0000 (18:17 -0700)]
scsi: lpfc: Fix null ndlp ptr dereference in abnormal exit path for GFT_ID

An error case exit from lpfc_cmpl_ct_cmd_gft_id() results in a call to
lpfc_nlp_put() with a null pointer to a nodelist structure.

Changed lpfc_cmpl_ct_cmd_gft_id() to initialize nodelist pointer upon
entry.

Link: https://lore.kernel.org/r/20220819011736.14141-3-jsmart2021@gmail.com
Co-developed-by: Justin Tee <justin.tee@broadcom.com>
Signed-off-by: Justin Tee <justin.tee@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
22 months agoscsi: lpfc: Fix unsolicited FLOGI receive handling during PT2PT discovery
James Smart [Fri, 19 Aug 2022 01:17:30 +0000 (18:17 -0700)]
scsi: lpfc: Fix unsolicited FLOGI receive handling during PT2PT discovery

During a stress offline/online test in PT2PT topology, target rediscovery
can fail with a specific target vendor array.

When the HBA transitions to online mode it is possible to receive an
unsolicited FLOGI before processing the Link Up event. The received FLOGI
will set the defer_flogi_acc_flag, which instructs the driver to wait until
it transmits its own FLOGI before ACKing the received FLOGI.  In this
failure scenario, the link up processing clears the set
defer_flogi_acc_flag before we have sent out the FLOGI.  As the target has
the higher WWPN and is responsible for sending the PLOGI, the target is
stuck waiting for its FLOGI_ACC that the driver will never send.

Remove the clear of defer_flogi_acc_flag from Link Up event processing.  In
this stress test case, the defer_flogi_acc_flag is cleared during the Link
Down event processing anyways.

Link: https://lore.kernel.org/r/20220819011736.14141-2-jsmart2021@gmail.com
Co-developed-by: Justin Tee <justin.tee@broadcom.com>
Signed-off-by: Justin Tee <justin.tee@broadcom.com>
Signed-off-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
22 months agoscsi: st: Remove redundant variable pointer stp
Colin Ian King [Fri, 5 Aug 2022 11:56:52 +0000 (12:56 +0100)]
scsi: st: Remove redundant variable pointer stp

Variable stp is assigned a value that is never read, the assignment and the
variable stp are redundant and can be removed.

Cleans up clang scan build warning:

drivers/scsi/st.c:4253:7: warning: Although the value stored to 'stp'
is used in the enclosing expression, the value is never actually
read from 'stp' [deadcode.DeadStores]

Link: https://lore.kernel.org/r/20220805115652.2340991-1-colin.i.king@gmail.com
Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
22 months agoscsi: megaraid: Remove redundant assignment to variable mfiStatus
Colin Ian King [Fri, 5 Aug 2022 11:50:42 +0000 (12:50 +0100)]
scsi: megaraid: Remove redundant assignment to variable mfiStatus

The variable mfiStatus is assigned a value but it is never read. The
assignment is redundant and can be removed. Also remove { } as the return
statement does not need to be in its own code block.

Cleans up clang scan build warning:

drivers/scsi/megaraid/megaraid_sas_base.c:4026:7: warning: Although the
value stored to 'mfiStatus' is used in the enclosing expression, the
value is never actually read from 'mfiStatus' [deadcode.DeadStores]

Link: https://lore.kernel.org/r/20220805115042.2340400-1-colin.i.king@gmail.com
Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
22 months agoscsi: initio: Remove redundant assignment to pointer scb
Colin Ian King [Fri, 5 Aug 2022 11:41:00 +0000 (12:41 +0100)]
scsi: initio: Remove redundant assignment to pointer scb

The variable scb is assigned a value but it is never read. The assignment
is redundant and can be removed. Also replace the != NULL check with the
more usual non-null check idiom.

Cleans up clang scan build warning:

drivers/scsi/initio.c:1169:9: warning: Although the value stored to 'scb'
is used in the enclosing expression, the value is never actually read
from 'scb' [deadcode.DeadStores]

Link: https://lore.kernel.org/r/20220805114100.2339637-1-colin.i.king@gmail.com
Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
22 months agoscsi: message: fusion: Remove redundant variable iocnum
Colin Ian King [Fri, 5 Aug 2022 11:32:14 +0000 (12:32 +0100)]
scsi: message: fusion: Remove redundant variable iocnum

Variable iocnum is assigned a value that is never read, the assignment and
hence the variable are redundant can be removed. Also update the comment to
reflect the correct name of the variable being updated.

Cleans up clang-scan warning:

drivers/message/fusion/mptctl.c:641:8: warning: Although the value stored
to 'iocnum' is used in the enclosing expression, the value is never
actually read from 'iocnum' [deadcode.DeadStores]

Link: https://lore.kernel.org/r/20220805113214.2339022-1-colin.i.king@gmail.com
Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
22 months agoscsi: mpt3sas: Disable MPI2_FUNCTION_FW_DOWNLOAD for ATTO devices
Bradley Grove [Fri, 5 Aug 2022 17:46:09 +0000 (13:46 -0400)]
scsi: mpt3sas: Disable MPI2_FUNCTION_FW_DOWNLOAD for ATTO devices

Disable firmware download for ATTO devices where it is not supported.

Link: https://lore.kernel.org/r/20220805174609.14830-2-bgrove@attotech.com
Co-developed-by: Rob Crispo <rcrispo@attotech.com>
Signed-off-by: Rob Crispo <rcrispo@attotech.com>
Signed-off-by: Bradley Grove <bgrove@attotech.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
22 months agoscsi: mpt3sas: Add support for ATTO ExpressSAS H12xx GT devices
Bradley Grove [Fri, 5 Aug 2022 17:46:08 +0000 (13:46 -0400)]
scsi: mpt3sas: Add support for ATTO ExpressSAS H12xx GT devices

Add ATTO's PCI IDs and modify the driver to handle the unique NVRAM
structure used by ATTO's devices.

Link: https://lore.kernel.org/r/20220805174609.14830-1-bgrove@attotech.com
Co-developed-by: Rob Crispo <rcrispo@attotech.com>
Signed-off-by: Rob Crispo <rcrispo@attotech.com>
Signed-off-by: Bradley Grove <bgrove@attotech.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
22 months agoscsi: mpi3mr: Block I/Os while refreshing target dev objects
Sreekanth Reddy [Thu, 4 Aug 2022 13:12:26 +0000 (18:42 +0530)]
scsi: mpi3mr: Block I/Os while refreshing target dev objects

Block the I/Os on the target devices until corresponding target device's
target dev objects are refreshed as part of post controller reset
operation.

Link: https://lore.kernel.org/r/20220804131226.16653-16-sreekanth.reddy@broadcom.com
Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
Signed-off-by: Sreekanth Reddy <sreekanth.reddy@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
22 months agoscsi: mpi3mr: Refresh SAS ports during soft reset
Sreekanth Reddy [Thu, 4 Aug 2022 13:12:25 +0000 (18:42 +0530)]
scsi: mpi3mr: Refresh SAS ports during soft reset

Update the host's SAS ports if there is change in port id or phys. If the
port id is changed, then the driver updates it. If some phys are
enabled/disabled during reset, then driver updates them in STL.

Check for the responding expander devices and update the device handle if
it got changed. Register the expander with STL if it got added during reset
and unregister the expander device if it got removed during reset.

[mkp: include fix for zeroday warning]

Link: https://lore.kernel.org/r/20220804131226.16653-15-sreekanth.reddy@broadcom.com
Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
Signed-off-by: Sreekanth Reddy <sreekanth.reddy@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
23 months agoscsi: mpi3mr: Support SAS transport class callbacks
Sreekanth Reddy [Thu, 4 Aug 2022 13:12:24 +0000 (18:42 +0530)]
scsi: mpi3mr: Support SAS transport class callbacks

Add support for the following SAS transport class callbacks:

 - get_linkerrors
 - get_enclosure_identifier
 - get_bay_identifier
 - phy_reset
 - phy_enable
 - set_phy_speed
 - smp_handler

Link: https://lore.kernel.org/r/20220804131226.16653-14-sreekanth.reddy@broadcom.com
Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
Signed-off-by: Sreekanth Reddy <sreekanth.reddy@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
23 months agoscsi: mpi3mr: Add framework to issue MPT transport cmds
Sreekanth Reddy [Thu, 4 Aug 2022 13:12:23 +0000 (18:42 +0530)]
scsi: mpi3mr: Add framework to issue MPT transport cmds

Add framework to issue MPT transport commands to controllers.  Also issue
the MPT transport commands to get the manufacturing info of SAS expander
device.

Link: https://lore.kernel.org/r/20220804131226.16653-13-sreekanth.reddy@broadcom.com
Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
Signed-off-by: Sreekanth Reddy <sreekanth.reddy@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
23 months agoscsi: mpi3mr: Add SAS SATA end devices to STL
Sreekanth Reddy [Thu, 4 Aug 2022 13:12:22 +0000 (18:42 +0530)]
scsi: mpi3mr: Add SAS SATA end devices to STL

Register/unregister the SAS, SATA devices to SCSI Transport Layer(STL)
whenever the corresponding device is added/removed from topology.

Link: https://lore.kernel.org/r/20220804131226.16653-12-sreekanth.reddy@broadcom.com
Reported-by: kernel test robot <lkp@intel.com>
Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
Signed-off-by: Sreekanth Reddy <sreekanth.reddy@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
23 months agoscsi: mpi3mr: Get target object based on rphy
Sreekanth Reddy [Thu, 4 Aug 2022 13:12:21 +0000 (18:42 +0530)]
scsi: mpi3mr: Get target object based on rphy

When device is registered with the STL then get the corresponding device's
target object using the rphy in below callback functions:

 - mpi3mr_target_alloc()

 - mpi3mr_slave_alloc()

 - mpi3mr_slave_configure()

 - mpi3mr_slave_destroy()

Link: https://lore.kernel.org/r/20220804131226.16653-11-sreekanth.reddy@broadcom.com
Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
Signed-off-by: Sreekanth Reddy <sreekanth.reddy@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
23 months agoscsi: mpi3mr: Add expander devices to STL
Sreekanth Reddy [Thu, 4 Aug 2022 13:12:20 +0000 (18:42 +0530)]
scsi: mpi3mr: Add expander devices to STL

Register/unregister the expander devices to SCSI Transport Layer(STL)
whenever the corresponding expander is added/removed from topology.

Link: https://lore.kernel.org/r/20220804131226.16653-10-sreekanth.reddy@broadcom.com
Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
Signed-off-by: Sreekanth Reddy <sreekanth.reddy@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
23 months agoscsi: mpi3mr: Enable STL on HBAs where multipath is disabled
Sreekanth Reddy [Thu, 4 Aug 2022 13:12:19 +0000 (18:42 +0530)]
scsi: mpi3mr: Enable STL on HBAs where multipath is disabled

Register the SAS, SATA devices to SCSI Transport Layer (STL) only if
multipath capability is disabled in the controller's firmware.

Link: https://lore.kernel.org/r/20220804131226.16653-9-sreekanth.reddy@broadcom.com
Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
Signed-off-by: Sreekanth Reddy <sreekanth.reddy@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
23 months agoscsi: mpi3mr: Add helper functions to manage device's port
Sreekanth Reddy [Thu, 4 Aug 2022 13:12:18 +0000 (18:42 +0530)]
scsi: mpi3mr: Add helper functions to manage device's port

Add the following helper functions:

 - Update the host phys with STL

 - Remove the device's SAS port with STL

Link: https://lore.kernel.org/r/20220804131226.16653-8-sreekanth.reddy@broadcom.com
Reviewed-by: Himanshu Madhani <himanshu.madani@oracle.com>
Signed-off-by: Sreekanth Reddy <sreekanth.reddy@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
23 months agoscsi: mpi3mr: Add helper functions to retrieve device objects
Sreekanth Reddy [Thu, 4 Aug 2022 13:12:17 +0000 (18:42 +0530)]
scsi: mpi3mr: Add helper functions to retrieve device objects

Add the following helper functions:

 - Get the device's sas address by reading corresponding device's Device
   page0

 - Get the expander object from expander list based on expander's handle

 - Get the target device object from target device list based on device's
   sas address

 - Get the expander device object from expander list based on expanders's
   sas address

 - Get hba port object from hba port table list based on port's port id

Link: https://lore.kernel.org/r/20220804131226.16653-7-sreekanth.reddy@broadcom.com
Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
Signed-off-by: Sreekanth Reddy <sreekanth.reddy@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
23 months agoscsi: mpi3mr: Add framework to add phys to STL
Sreekanth Reddy [Thu, 4 Aug 2022 13:12:16 +0000 (18:42 +0530)]
scsi: mpi3mr: Add framework to add phys to STL

Add framework to register and unregister the host and expander phys with
SCSI Transport Layer (STL).

Link: https://lore.kernel.org/r/20220804131226.16653-6-sreekanth.reddy@broadcom.com
Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
Signed-off-by: Sreekanth Reddy <sreekanth.reddy@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
23 months agoscsi: mpi3mr: Enable Enclosure device add event
Sreekanth Reddy [Thu, 4 Aug 2022 13:12:15 +0000 (18:42 +0530)]
scsi: mpi3mr: Enable Enclosure device add event

Enable and process the Enclosure device add event.

Link: https://lore.kernel.org/r/20220804131226.16653-5-sreekanth.reddy@broadcom.com
Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
Signed-off-by: Sreekanth Reddy <sreekanth.reddy@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
23 months agoscsi: mpi3mr: Add helper functions to retrieve config pages
Sreekanth Reddy [Thu, 4 Aug 2022 13:12:14 +0000 (18:42 +0530)]
scsi: mpi3mr: Add helper functions to retrieve config pages

Add helper functions to retrieve below controller's config pages:

 - SAS IOUnit Page0

 - SAS IOUnit Page1

 - Driver Page1

 - Device Page0

 - SAS Phy Page0

 - SAS Phy Page1

 - SAS Expander Page0

 - SAS Expander Page1

 - Enclosure Page0

Also add the helper function to set SAS IOUnit Page1.

Link: https://lore.kernel.org/r/20220804131226.16653-4-sreekanth.reddy@broadcom.com
Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
Signed-off-by: Sreekanth Reddy <sreekanth.reddy@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
23 months agoscsi: mpi3mr: Add framework to issue config requests
Sreekanth Reddy [Thu, 4 Aug 2022 13:12:13 +0000 (18:42 +0530)]
scsi: mpi3mr: Add framework to issue config requests

Add framework to issue config requests commands to controller firmware.

Link: https://lore.kernel.org/r/20220804131226.16653-3-sreekanth.reddy@broadcom.com
Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
Signed-off-by: Sreekanth Reddy <sreekanth.reddy@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
23 months agoscsi: mpi3mr: Add config and transport related debug flags
Sreekanth Reddy [Thu, 4 Aug 2022 13:12:12 +0000 (18:42 +0530)]
scsi: mpi3mr: Add config and transport related debug flags

Add config and transport request related error & info debug flags and
functions.

Link: https://lore.kernel.org/r/20220804131226.16653-2-sreekanth.reddy@broadcom.com
Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
Signed-off-by: Sreekanth Reddy <sreekanth.reddy@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
23 months agoscsi: ufs: wb: Modify messages
Jinyoung Choi [Thu, 4 Aug 2022 07:55:19 +0000 (16:55 +0900)]
scsi: ufs: wb: Modify messages

Modify messages to fit the format of others.

Link: https://lore.kernel.org/r/20220804075519epcms2p148b6ae956b172925b26304b50d6a0da9@epcms2p1
Reviewed-by: Avri Altman <avri.altman@wdc.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Jinyoung Choi <j-young.choi@samsung.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
23 months agoscsi: ufs: wb: Introduce ufshcd_is_wb_buf_flush_allowed()
Jinyoung Choi [Thu, 4 Aug 2022 07:54:44 +0000 (16:54 +0900)]
scsi: ufs: wb: Introduce ufshcd_is_wb_buf_flush_allowed()

The explicit flushing should check the following:

 - UFSHCD_CAP_WB_EN

 - UFSHCI_QUIRK_SKIP_MANUAL_WB_FLUSH_CTRL

Add helper to improve readability.

Link: https://lore.kernel.org/r/20220804075444epcms2p4a0520880262281f02be65ce0fe50602d@epcms2p4
Reviewed-by: Avri Altman <avri.altman@wdc.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Stanley Chu <stanley.chu@mediatek.com>
Acked-by: Bean Huo <beanhuo@micron.com>
Signed-off-by: Jinyoung Choi <j-young.choi@samsung.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
23 months agoscsi: ufs: wb: Add explicit flush sysfs attribute
Jinyoung Choi [Thu, 4 Aug 2022 07:53:54 +0000 (16:53 +0900)]
scsi: ufs: wb: Add explicit flush sysfs attribute

There is the following quirk to bypass "WB Flush" in Write Booster.

- UFSHCI_QUIRK_SKIP_MANUAL_WB_FLUSH_CTRL

If this quirk is not set, there is no knob that can control "WB Flush".

There are three flags that control Write Booster Feature:

1. WB ON/OFF
2. WB Hibern Flush ON/OFF (implicitly)
3. WB Flush ON/OFF (explicit)

The sysfs attribute that controls the WB was implemented. (1)

In the case of "Hibern Flush", it is always good to turn on.  Control may
not be required. (2)

Finally, "Flush" may be necessary because the Auto-Hibern8 is not supported
in a specific environment.  So the sysfs attribute that controls this is
necessary. (3)

Link: https://lore.kernel.org/r/20220804075354epcms2p8c21c894b4e28840c5fc651875b7f435f@epcms2p8
Reviewed-by: Avri Altman <avri.altman@wdc.com>
Signed-off-by: Jinyoung Choi <j-young.choi@samsung.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
23 months agoscsi: ufs: wb: Change function name and parameter names
Jinyoung Choi [Thu, 4 Aug 2022 07:50:58 +0000 (16:50 +0900)]
scsi: ufs: wb: Change function name and parameter names

Change the parameter names of ufshcd_wb_toggle_flush_during_h8() to match
the other toggle functions.

Link: https://lore.kernel.org/r/20220804075058epcms2p550c578d743fe0a94888b3d71cc9076d4@epcms2p5
Reviewed-by: Avri Altman <avri.altman@wdc.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Jinyoung Choi <j-young.choi@samsung.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
23 months agoscsi: ufs: wb: Change wb_enabled condition test
Jinyoung Choi [Thu, 4 Aug 2022 07:49:28 +0000 (16:49 +0900)]
scsi: ufs: wb: Change wb_enabled condition test

Change to improve readability.

Link: https://lore.kernel.org/r/20220804074928epcms2p86582693a39597501b491400a28543a92@epcms2p8
Reviewed-by: Avri Altman <avri.altman@wdc.com>
Reviewed-by: Bean Huo <beanhuo@micron.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Jinyoung Choi <j-young.choi@samsung.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
23 months agoscsi: ufs: core: Allow host driver to disable wb toggling during clock scaling
Peter Wang [Thu, 4 Aug 2022 02:54:22 +0000 (10:54 +0800)]
scsi: ufs: core: Allow host driver to disable wb toggling during clock scaling

Mediatek UFS does not want to toggle write booster during clock scaling.
Permit host driver to disable wb toggling during clock scaling.

Introduce a flag UFSHCD_CAP_WB_WITH_CLK_SCALING to decouple WB and clock
scaling.  UFSHCD_CAP_WB_WITH_CLK_SCALING is only valid when
UFSHCD_CAP_CLK_SCALING is set. Just like UFSHCD_CAP_HIBERN8_WITH_CLK_GATING
is valid only when UFSHCD_CAP_CLK_GATING set.

Set UFSHCD_CAP_WB_WITH_CLK_SCALING for qcom to compatible legacy design at
the same time.

Link: https://lore.kernel.org/r/20220804025422.18803-1-peter.wang@mediatek.com
Reviewed-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Peter Wang <peter.wang@mediatek.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
23 months agoscsi: ufs: core: Use local_clock() for debugging timestamps
Daniil Lunev [Wed, 3 Aug 2022 20:50:34 +0000 (06:50 +1000)]
scsi: ufs: core: Use local_clock() for debugging timestamps

CLOCK_MONOTONIC is not advanced when the system is in suspend. This becomes
problematic when debugging issues related to suspend-resume: the timestamps
printed by ufshcd_print_trs can not be correlated with dmesg entries, which
are timestamped with local_clock().

Change the used clock to local_clock() for the informational timestamp
variables and adds mirroring *_local_clock instances for variables used in
subsequent derevations (to not change the semantics of those derevations).

Link: https://lore.kernel.org/r/20220804065019.v5.1.I699244ea7efbd326a34a6dfd9b5a31e78400cf68@changeid
Acked-by: Stanley Chu <stanley.chu@mediatek.com>
Acked-by: Avri Altman <avri.altman@wdc.com>
Signed-off-by: Daniil Lunev <dlunev@chromium.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
23 months agoscsi: ufs: ufs-mediatek: Support clk-scaling to optimize power consumption
Po-Wen Kao [Tue, 2 Aug 2022 23:54:37 +0000 (07:54 +0800)]
scsi: ufs: ufs-mediatek: Support clk-scaling to optimize power consumption

Provide clk-scaling feature in MediaTek UFS platforms.

MediaTek platform supports clk-scaling by switching parent clock mux of
UFSHCI main clocks: ufs_sel.

The driver needs to prevent changing the rate of ufs_sel because its parent
PLL clock may be shared between multiple IPs. In order to achieve this
goal, the maximum and minimum clock rates of ufs_sel defined in dts should
match the rate of "ufs_sel_max_src" and "ufs_sel_min_src" respectively.

Link: https://lore.kernel.org/r/20220802235437.4547-6-stanley.chu@mediatek.com
Reviewed-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Po-Wen Kao <powen.kao@mediatek.com>
Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
23 months agoscsi: ufs: ufs-mediatek: Fix performance scaling
Peter Wang [Tue, 2 Aug 2022 23:54:36 +0000 (07:54 +0800)]
scsi: ufs: ufs-mediatek: Fix performance scaling

If clk-scaling is enabled, performance scaling can be bound to the decision
of clk-scaling to avoid unnecessary boosting.

In addition, fix missing initialization of pm-qos request.

Link: https://lore.kernel.org/r/20220802235437.4547-5-stanley.chu@mediatek.com
Reviewed-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Peter Wang <peter.wang@mediatek.com>
Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
23 months agoscsi: ufs: ufs-mediatek: Dump more registers
Peter Wang [Tue, 2 Aug 2022 23:54:35 +0000 (07:54 +0800)]
scsi: ufs: ufs-mediatek: Dump more registers

Dump more proprietary UFSHCI status registers for easier issue breakdown.

Link: https://lore.kernel.org/r/20220802235437.4547-4-stanley.chu@mediatek.com
Reviewed-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Peter Wang <peter.wang@mediatek.com>
Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
23 months agoscsi: ufs: ufs-mediatek: Provide detailed description for UIC errors
Stanley Chu [Tue, 2 Aug 2022 23:54:34 +0000 (07:54 +0800)]
scsi: ufs: ufs-mediatek: Provide detailed description for UIC errors

Provide detailed description in logs for UIC errors for easier issue
breakdown.

Link: https://lore.kernel.org/r/20220802235437.4547-3-stanley.chu@mediatek.com
Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
23 months agoscsi: ufs: ufs-mediatek: Remove redundant header files
Stanley Chu [Tue, 2 Aug 2022 23:54:33 +0000 (07:54 +0800)]
scsi: ufs: ufs-mediatek: Remove redundant header files

Remove redundant #include of header file <linux/sched/clock.h>.

Link: https://lore.kernel.org/r/20220802235437.4547-2-stanley.chu@mediatek.com
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
23 months agoLinux 6.0-rc1
Linus Torvalds [Sun, 14 Aug 2022 22:50:18 +0000 (15:50 -0700)]
Linux 6.0-rc1

23 months agoradix-tree: replace gfp.h inclusion with gfp_types.h
Yury Norov [Fri, 12 Aug 2022 05:34:25 +0000 (22:34 -0700)]
radix-tree: replace gfp.h inclusion with gfp_types.h

Radix tree header includes gfp.h for __GFP_BITS_SHIFT only. Now we
have gfp_types.h for this.

Fixes powerpc allmodconfig build:

   In file included from include/linux/nodemask.h:97,
                    from include/linux/mmzone.h:17,
                    from include/linux/gfp.h:7,
                    from include/linux/radix-tree.h:12,
                    from include/linux/idr.h:15,
                    from include/linux/kernfs.h:12,
                    from include/linux/sysfs.h:16,
                    from include/linux/kobject.h:20,
                    from include/linux/pci.h:35,
                    from arch/powerpc/kernel/prom_init.c:24:
   include/linux/random.h: In function 'add_latent_entropy':
>> include/linux/random.h:25:46: error: 'latent_entropy' undeclared (first use in this function); did you mean 'add_latent_entropy'?
      25 |         add_device_randomness((const void *)&latent_entropy, sizeof(latent_entropy));
         |                                              ^~~~~~~~~~~~~~
         |                                              add_latent_entropy
   include/linux/random.h:25:46: note: each undeclared identifier is reported only once for each function it appears in

Reported-by: kernel test robot <lkp@intel.com>
CC: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
CC: Andrew Morton <akpm@linux-foundation.org>
CC: Jason A. Donenfeld <Jason@zx2c4.com>
Signed-off-by: Yury Norov <yury.norov@gmail.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
23 months agoMerge tag 'pull-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
Linus Torvalds [Sun, 14 Aug 2022 20:03:53 +0000 (13:03 -0700)]
Merge tag 'pull-fixes' of git://git./linux/kernel/git/viro/vfs

Pull vfs lseek fix from Al Viro:
 "Fix proc_reg_llseek() breakage. Always had been possible if somebody
  left NULL ->proc_lseek, became a practical issue now"

* tag 'pull-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs:
  take care to handle NULL ->proc_lseek()

23 months agotake care to handle NULL ->proc_lseek()
Al Viro [Sun, 14 Aug 2022 19:16:18 +0000 (15:16 -0400)]
take care to handle NULL ->proc_lseek()

Easily done now, just by clearing FMODE_LSEEK in ->f_mode
during proc_reg_open() for such entries.

Fixes: 868941b14441 "fs: remove no_llseek"
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
23 months agoMerge tag 'for-linus-6.0-rc1b-tag' of git://git.kernel.org/pub/scm/linux/kernel/git...
Linus Torvalds [Sun, 14 Aug 2022 16:28:54 +0000 (09:28 -0700)]
Merge tag 'for-linus-6.0-rc1b-tag' of git://git./linux/kernel/git/xen/tip

Pull more xen updates from Juergen Gross:

 - fix the handling of the "persistent grants" feature negotiation
   between Xen blkfront and Xen blkback drivers

 - a cleanup of xen.config and adding xen.config to Xen section in
   MAINTAINERS

 - support HVMOP_set_evtchn_upcall_vector, which is more compliant to
   "normal" interrupt handling than the global callback used up to now

 - further small cleanups

* tag 'for-linus-6.0-rc1b-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/xen/tip:
  MAINTAINERS: add xen config fragments to XEN HYPERVISOR sections
  xen: remove XEN_SCRUB_PAGES in xen.config
  xen/pciback: Fix comment typo
  xen/xenbus: fix return type in xenbus_file_read()
  xen-blkfront: Apply 'feature_persistent' parameter when connect
  xen-blkback: Apply 'feature_persistent' parameter when connect
  xen-blkback: fix persistent grants negotiation
  x86/xen: Add support for HVMOP_set_evtchn_upcall_vector

23 months agoMerge tag 'perf-tools-fixes-for-v6.0-2022-08-13' of git://git.kernel.org/pub/scm...
Linus Torvalds [Sun, 14 Aug 2022 16:22:11 +0000 (09:22 -0700)]
Merge tag 'perf-tools-fixes-for-v6.0-2022-08-13' of git://git./linux/kernel/git/acme/linux

Pull more perf tool updates from Arnaldo Carvalho de Melo:

 - 'perf c2c' now supports ARM64, adjust its output to cope with
   differences with what is in x86_64. Now go find false sharing on
   ARM64 (at least Neoverse) as well!

 - Refactor the JSON processing, making the output more compact and thus
   reducing the size of the resulting perf binary

 - Improvements for 'perf offcpu' profiling, including tracking child
   processes

 - Update Intel JSON metrics and events files for broadwellde,
   broadwellx, cascadelakex, haswellx, icelakex, ivytown, jaketown,
   knightslanding, sapphirerapids, skylakex and snowridgex

 - Add 'perf stat' JSON output and a 'perf test' entry for it

 - Ignore memfd and anonymous mmap events if jitdump present

 - Refactor 'perf test' shell tests allowing subdirs

 - Fix an error handling path in 'parse_perf_probe_command()'

 - Fixes for the guest Intel PT tracing patchkit in the 1st batch of
   this merge window

 - Print debuginfod queries if -v option is used, to explain delays in
   processing when debuginfo servers are enabled to fetch DSOs with
   richer symbol tables

 - Improve error message for 'perf record -p not_existing_pid'

 - Fix openssl and libbpf feature detection

 - Add PMU pai_crypto event description for IBM z16 on 'perf list'

 - Fix typos and duplicated words on comments in various places

* tag 'perf-tools-fixes-for-v6.0-2022-08-13' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux: (81 commits)
  perf test: Refactor shell tests allowing subdirs
  perf vendor events: Update events for snowridgex
  perf vendor events: Update events and metrics for skylakex
  perf vendor events: Update metrics for sapphirerapids
  perf vendor events: Update events for knightslanding
  perf vendor events: Update metrics for jaketown
  perf vendor events: Update metrics for ivytown
  perf vendor events: Update events and metrics for icelakex
  perf vendor events: Update events and metrics for haswellx
  perf vendor events: Update events and metrics for cascadelakex
  perf vendor events: Update events and metrics for broadwellx
  perf vendor events: Update metrics for broadwellde
  perf jevents: Fold strings optimization
  perf jevents: Compress the pmu_events_table
  perf metrics: Copy entire pmu_event in find metric
  perf pmu-events: Hide the pmu_events
  perf pmu-events: Don't assume pmu_event is an array
  perf pmu-events: Move test events/metrics to JSON
  perf test: Use full metric resolution
  perf pmu-events: Hide pmu_events_map
  ...