linux-2.6-block.git
6 months agoMerge patch series "lpfc: Update lpfc to revision 14.2.0.17"
Martin K. Petersen [Thu, 14 Dec 2023 03:19:32 +0000 (22:19 -0500)]
Merge patch series "lpfc: Update lpfc to revision 14.2.0.17"

Justin Tee <justintee8345@gmail.com> says:

Update lpfc to revision 14.2.0.17

This patch set contains bug fixes for the VMID feature.

The patches were cut against Martin's 6.8/scsi-queue tree.

Link: https://lore.kernel.org/r/20231207224039.35466-1-justintee8345@gmail.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 months agoscsi: lpfc: Update lpfc version to 14.2.0.17
Justin Tee [Thu, 7 Dec 2023 22:40:39 +0000 (14:40 -0800)]
scsi: lpfc: Update lpfc version to 14.2.0.17

Update lpfc version to 14.2.0.17

Signed-off-by: Justin Tee <justin.tee@broadcom.com>
Link: https://lore.kernel.org/r/20231207224039.35466-5-justintee8345@gmail.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 months agoscsi: lpfc: Move determination of vmid_flag after VMID reinitialization completes
Justin Tee [Thu, 7 Dec 2023 22:40:38 +0000 (14:40 -0800)]
scsi: lpfc: Move determination of vmid_flag after VMID reinitialization completes

If priority tagging is set in the service parameters of a FLOGI cmpl, then
we update the vmid_flag.  In the current logic, if a follow up FLOGI cmpl
updates its service parameters such that priority tagging is no longer set,
then the vmid_flag ends up keeping stale data.

Fix by ensuring we clear the vmid_flag member during lpfc_reinit_vmid, and
check the priority tagging service parameter after reinitialization of the
vmid data structures.

Signed-off-by: Justin Tee <justin.tee@broadcom.com>
Link: https://lore.kernel.org/r/20231207224039.35466-4-justintee8345@gmail.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 months agoscsi: lpfc: Reinitialize an NPIV's VMID data structures after FDISC
Justin Tee [Thu, 7 Dec 2023 22:40:37 +0000 (14:40 -0800)]
scsi: lpfc: Reinitialize an NPIV's VMID data structures after FDISC

After a follow up FDISC cmpl, an NPIV's VMID data structures are not
updated.

Fix by calling lpfc_reinit_vmid and copying the physical port's vmid_flag
to the NPIV's vmid_flag in the NPIV registration cmpl code path.

Signed-off-by: Justin Tee <justin.tee@broadcom.com>
Link: https://lore.kernel.org/r/20231207224039.35466-3-justintee8345@gmail.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 months agoscsi: lpfc: Change VMID driver load time parameters to read only
Justin Tee [Thu, 7 Dec 2023 22:40:36 +0000 (14:40 -0800)]
scsi: lpfc: Change VMID driver load time parameters to read only

VMID driver support is a load time configuration setting.  Thus, change
sysfs attributes to read only.

Signed-off-by: Justin Tee <justin.tee@broadcom.com>
Link: https://lore.kernel.org/r/20231207224039.35466-2-justintee8345@gmail.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 months agoMerge patch series "Introduce support for multiqueue (MQ) in fnic"
Martin K. Petersen [Thu, 14 Dec 2023 03:13:38 +0000 (22:13 -0500)]
Merge patch series "Introduce support for multiqueue (MQ) in fnic"

Karan Tilak Kumar <kartilak@cisco.com> says:

Hi Martin, reviewers,

This cover letter describes the feature: add support for
multiqueue (MQ) to fnic driver.

Background: The Virtual Interface Card (VIC) firmware exposes several
queues that can be configured for sending IOs and receiving IO
responses. Unified Computing System Manager (UCSM) and Intersight
Manager (IMM) allows users to configure the number of queues to be
used for IOs.

The number of IO queues to be used is stored in a configuration file
by the VIC firmware. The fNIC driver reads the configuration file and
sets the number of queues to be used. Previously, the driver was
hard-coded to use only one queue. With this set of changes, the fNIC
driver will configure itself to use multiple queues. This feature
takes advantage of the block multiqueue layer to parallelize IOs being
sent out of the VIC card.

Here's a brief description of some of the salient patches:

- vnic_scsi.h needs to be in sync with VIC firmware to be able to read
the number of queues from the firmware config file. A patch has been
created for this.
- In an environment with many fnics (like we see in our customer
environments), it is hard to distinguish which fnic is printing logs.
Therefore, an fnic number has been included in the logs.
- read the number of queues from the firmware config file.
- include definitions in fnic.h to support multiqueue.
- modify the interrupt service routines (ISRs) to read from the
correct registers. The numbers that are used here come from discussions
with the VIC firmware team.
- track IO statistics for different queues.
- remove usage of host_lock, and only use fnic_lock in the fnic driver.
- use a hardware queue based spinlock to protect io_req.
- replace the hard-coded zeroth queue with a hardware queue number.
This presents a bulk of the changes.
- modify the definition of fnic_queuecommand to accept multiqueue tags.
- improve log messages, and indicate fnic number and multiqueue tags for
effective debugging.

Even though the patches have been made into a series, some patches are
heavier than others.
But, every effort has been made to keep the purpose of each patch as
a single-purpose, and to compile cleanly.

This patchset has been tested as a whole. Therefore, the tested-by fields
have been added only to two patches
in the set. All the individual patches compile cleanly. However,
I've refrained from adding tested-by to
most of the patches, so as to not mislead the reviewer/reader.

A brief note on the unit tests:

1. Increase number of queues to 64. Load driver. Run IOs via Medusa.
12+ hour run successful.
2. Configure multipathing, and run link flaps on single link.
IOs drop briefly, but pick up as expected.
3. Configure multipathing, and run link flaps on two links, with a
30 second delay in between. IOs drop briefly, but pick up as expected.

Repeat the above tests with 1 queue and 32 queues.  All tests were
successful.

Please consider this patch series for the next merge window.

Link: https://lore.kernel.org/r/20231211173617.932990-1-kartilak@cisco.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 months agoscsi: fnic: Increment driver version
Karan Tilak Kumar [Mon, 11 Dec 2023 17:36:17 +0000 (09:36 -0800)]
scsi: fnic: Increment driver version

Increment driver version for multiqueue (MQ).

Reviewed-by: Sesidhar Baddela <sebaddel@cisco.com>
Reviewed-by: Arulprabhu Ponnusamy <arulponn@cisco.com>
Signed-off-by: Karan Tilak Kumar <kartilak@cisco.com>
Link: https://lore.kernel.org/r/20231211173617.932990-14-kartilak@cisco.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 months agoscsi: fnic: Improve logs and add support for multiqueue (MQ)
Karan Tilak Kumar [Mon, 11 Dec 2023 17:36:16 +0000 (09:36 -0800)]
scsi: fnic: Improve logs and add support for multiqueue (MQ)

Improve existing logs by adding fnic number, hardware queue, tag, and mqtag
in the prints.  Add logs with the above elements for effective debugging.

Reviewed-by: Sesidhar Baddela <sebaddel@cisco.com>
Reviewed-by: Arulprabhu Ponnusamy <arulponn@cisco.com>
Tested-by: Karan Tilak Kumar <kartilak@cisco.com>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Karan Tilak Kumar <kartilak@cisco.com>
Link: https://lore.kernel.org/r/20231211173617.932990-13-kartilak@cisco.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 months agoscsi: fnic: Add support for multiqueue (MQ) in fnic driver
Karan Tilak Kumar [Mon, 11 Dec 2023 17:36:15 +0000 (09:36 -0800)]
scsi: fnic: Add support for multiqueue (MQ) in fnic driver

Implement support for MQ in fnic driver:

The block multiqueue layer issues IO to the fnic driver with an MQ tag. Use
the mqtag and derive a tag from it.  Derive the hardware queue from the
mqtag and use it in all paths. Modify queuecommand to handle mqtag.

Replace wq and cq indices to support MQ. Replace the zeroth queue with a
hardware queue.  Implement spin locks on a per hardware queue basis.
Replace io_lock with per hardware queue spinlock.  Implement out of range
tag checks.

Allocate an io_req_table to track status of the io_req.

Test the driver by building it, loading it, and configuring 64 queues in
UCSM. Issue IOs using Medusa on multiple fnics. Enable/disable links to
exercise the abort and clean up path.

Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202310300032.2awCqkfn-lkp@intel.com/
Reviewed-by: Sesidhar Baddela <sebaddel@cisco.com>
Reviewed-by: Arulprabhu Ponnusamy <arulponn@cisco.com>
Tested-by: Karan Tilak Kumar <kartilak@cisco.com>
Signed-off-by: Karan Tilak Kumar <kartilak@cisco.com>
Link: https://lore.kernel.org/r/20231211173617.932990-12-kartilak@cisco.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 months agoscsi: fnic: Add support for multiqueue (MQ) in fnic_main.c
Karan Tilak Kumar [Mon, 11 Dec 2023 17:36:14 +0000 (09:36 -0800)]
scsi: fnic: Add support for multiqueue (MQ) in fnic_main.c

Set map_queues in the fnic_host_template to fnic_mq_map_queues_cpus.
Define fnic_mq_map_queues_cpus to set cpu assignment to fnic queues.
Refactor code in fnic_probe to enable vnic queues before scsi_add_host.
Modify notify set to the correct index.

Reviewed-by: Sesidhar Baddela <sebaddel@cisco.com>
Reviewed-by: Arulprabhu Ponnusamy <arulponn@cisco.com>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: John Garry <john.g.garry@oracle.com>
Signed-off-by: Karan Tilak Kumar <kartilak@cisco.com>
Link: https://lore.kernel.org/r/20231211173617.932990-11-kartilak@cisco.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 months agoscsi: fnic: Remove usage of host_lock
Karan Tilak Kumar [Mon, 11 Dec 2023 17:36:13 +0000 (09:36 -0800)]
scsi: fnic: Remove usage of host_lock

Remove usage of host_lock.  Replace with fnic_lock, where necessary.  fnic
does not use host_lock. fnic uses fnic_lock.  Use fnic lock to protect fnic
members in fnic_queuecommand.  Add log messages in error cases.

Reviewed-by: Sesidhar Baddela <sebaddel@cisco.com>
Reviewed-by: Arulprabhu Ponnusamy <arulponn@cisco.com>
Signed-off-by: Karan Tilak Kumar <kartilak@cisco.com>
Link: https://lore.kernel.org/r/20231211173617.932990-10-kartilak@cisco.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 months agoscsi: fnic: Define stats to track multiqueue (MQ) IOs
Karan Tilak Kumar [Mon, 11 Dec 2023 17:36:12 +0000 (09:36 -0800)]
scsi: fnic: Define stats to track multiqueue (MQ) IOs

Define an array to track IOs for the different queues, print the IO stats
in fnic get stats data.

Reviewed-by: Sesidhar Baddela <sebaddel@cisco.com>
Reviewed-by: Arulprabhu Ponnusamy <arulponn@cisco.com>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Karan Tilak Kumar <kartilak@cisco.com>
Link: https://lore.kernel.org/r/20231211173617.932990-9-kartilak@cisco.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 months agoscsi: fnic: Modify ISRs to support multiqueue (MQ)
Karan Tilak Kumar [Mon, 11 Dec 2023 17:36:11 +0000 (09:36 -0800)]
scsi: fnic: Modify ISRs to support multiqueue (MQ)

Modify interrupt service routines for INTx, MSI, and MSI-x to support
multiqueue.  Modify parameter list of fnic_wq_copy_cmpl_handler to take
cq_index.  Modify fnic_cleanup function to use the new function call of
fnic_wq_copy_cmpl_handler.  Refactor code to set interrupt mode to MSI-x to
a new function.  Add a new stat for intx_dummy.

Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202310251847.4T8BVZAZ-lkp@intel.com/
Reviewed-by: Sesidhar Baddela <sebaddel@cisco.com>
Reviewed-by: Arulprabhu Ponnusamy <arulponn@cisco.com>
Signed-off-by: Karan Tilak Kumar <kartilak@cisco.com>
Link: https://lore.kernel.org/r/20231211173617.932990-8-kartilak@cisco.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 months agoscsi: fnic: Refactor and redefine fnic.h for multiqueue
Karan Tilak Kumar [Mon, 11 Dec 2023 17:36:10 +0000 (09:36 -0800)]
scsi: fnic: Refactor and redefine fnic.h for multiqueue

Refactor and re-define values in fnic.h to implement multiqueue (MQ)
functionality.

VIC firmware allows fnic to create up to 64 copy workqueues. Update the
copy workqueue max to 64.  Modify the interrupt index to be in sync with
the firmware to support MQ.  Add irq number to the MSIX entry.  Define a
software workqueue table to track the status of io_reqs. Define a base for
the copy workqueue.

Reviewed-by: Sesidhar Baddela <sebaddel@cisco.com>
Reviewed-by: Arulprabhu Ponnusamy <arulponn@cisco.com>
Signed-off-by: Karan Tilak Kumar <kartilak@cisco.com>
Link: https://lore.kernel.org/r/20231211173617.932990-7-kartilak@cisco.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 months agoscsi: fnic: Get copy workqueue count and interrupt mode from config
Karan Tilak Kumar [Mon, 11 Dec 2023 17:36:09 +0000 (09:36 -0800)]
scsi: fnic: Get copy workqueue count and interrupt mode from config

Get the copy workqueue count and interrupt mode from the configuration. The
config can be changed via UCSM.  Add logs to print the interrupt mode and
copy workqueue count.  Add logs to print the vNIC resources.

Reviewed-by: Sesidhar Baddela <sebaddel@cisco.com>
Reviewed-by: Arulprabhu Ponnusamy <arulponn@cisco.com>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Karan Tilak Kumar <kartilak@cisco.com>
Link: https://lore.kernel.org/r/20231211173617.932990-6-kartilak@cisco.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 months agoscsi: fnic: Rename wq_copy to hw_copy_wq
Karan Tilak Kumar [Mon, 11 Dec 2023 17:36:08 +0000 (09:36 -0800)]
scsi: fnic: Rename wq_copy to hw_copy_wq

Rename wq_copy to hw_copy_wq to accurately describe the copy
workqueue. This will also help distinguish this data structure from
software data structures that can be introduced.

Reviewed-by: Sesidhar Baddela <sebaddel@cisco.com>
Reviewed-by: Arulprabhu Ponnusamy <arulponn@cisco.com>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Karan Tilak Kumar <kartilak@cisco.com>
Link: https://lore.kernel.org/r/20231211173617.932990-5-kartilak@cisco.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 months agoscsi: fnic: Add and improve log messages
Karan Tilak Kumar [Mon, 11 Dec 2023 17:36:07 +0000 (09:36 -0800)]
scsi: fnic: Add and improve log messages

Add link related log messages in fnic_fcs.c,
Improve log message in fnic_fcs.c,
Add log message in vnic_dev.c.

Reviewed-by: Sesidhar Baddela <sebaddel@cisco.com>
Reviewed-by: Arulprabhu Ponnusamy <arulponn@cisco.com>
Signed-off-by: Karan Tilak Kumar <kartilak@cisco.com>
Link: https://lore.kernel.org/r/20231211173617.932990-4-kartilak@cisco.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 months agoscsi: fnic: Add and use fnic number
Karan Tilak Kumar [Mon, 11 Dec 2023 17:36:06 +0000 (09:36 -0800)]
scsi: fnic: Add and use fnic number

Add fnic_num in fnic.h to identify fnic in a multi-fnic environment.
Increment and set the fnic number during driver load in fnic_probe.
Replace the host number with fnic number in debugfs.

Reviewed-by: Sesidhar Baddela <sebaddel@cisco.com>
Reviewed-by: Arulprabhu Ponnusamy <arulponn@cisco.com>
Signed-off-by: Karan Tilak Kumar <kartilak@cisco.com>
Link: https://lore.kernel.org/r/20231211173617.932990-3-kartilak@cisco.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 months agoscsi: fnic: Modify definitions to sync with VIC firmware
Karan Tilak Kumar [Mon, 11 Dec 2023 17:36:05 +0000 (09:36 -0800)]
scsi: fnic: Modify definitions to sync with VIC firmware

VIC firmware has updated definitions.  Modify structure and definitions to
sync with the latest VIC firmware.

Reviewed-by: Sesidhar Baddela <sebaddel@cisco.com>
Reviewed-by: Arulprabhu Ponnusamy <arulponn@cisco.com>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Karan Tilak Kumar <kartilak@cisco.com>
Link: https://lore.kernel.org/r/20231211173617.932990-2-kartilak@cisco.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 months agoscsi: mpi3mr: Fix printk() format strings
Arnd Bergmann [Thu, 7 Dec 2023 14:28:06 +0000 (15:28 +0100)]
scsi: mpi3mr: Fix printk() format strings

The newly introduced error messages get multiple format strings wrong:
size_t must be printed using the %z modifier rather than %l and dma_addr_t
must be printed by reference using the special %pad pointer type:

drivers/scsi/mpi3mr/mpi3mr_app.c: In function 'mpi3mr_build_nvme_prp':
include/linux/kern_levels.h:5:25: error: format '%llx' expects argument of type 'long long unsigned int', but argument 4 has type 'dma_addr_t' {aka 'unsigned int'} [-Werror=format=]
drivers/scsi/mpi3mr/mpi3mr_app.c:949:25: note: in expansion of macro 'dprint_bsg_err'
  949 |                         dprint_bsg_err(mrioc,
      |                         ^~~~~~~~~~~~~~
include/linux/kern_levels.h:5:25: error: format '%ld' expects argument of type 'long int', but argument 4 has type 'size_t' {aka 'unsigned int'} [-Werror=format=]
drivers/scsi/mpi3mr/mpi3mr_app.c:1112:41: note: in expansion of macro 'dprint_bsg_err'
 1112 |                                         dprint_bsg_err(mrioc,
      |                                         ^~~~~~~~~~~~~~

Fixes: 9536af615dc9 ("scsi: mpi3mr: Support for preallocation of SGL BSG data buffers part-3")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Link: https://lore.kernel.org/r/20231207142813.935717-1-arnd@kernel.org
Acked-by: Randy Dunlap <rdunlap@infradead.org>
Tested-by: Randy Dunlap <rdunlap@infradead.org> # build-tested
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 months agoMerge patch series "scsi: Convert to platform remove callback returning" void
Martin K. Petersen [Wed, 6 Dec 2023 02:54:06 +0000 (21:54 -0500)]
Merge patch series "scsi: Convert to platform remove callback returning" void

Uwe Kleine-König <u.kleine-koenig@pengutronix.de> says:

Hello,

this series converts all drivers below drivers/scsi to struct
platform_driver::remove_new(). See commit 5c5a7680e67b ("platform:
Provide a remove callback that returns no value") for an extended
explanation and the eventual goal.

All conversations are trivial, because all .remove() callbacks returned
zero unconditionally.

Best regards
Uwe

Link: https://lore.kernel.org/r/cover.1701619134.git.u.kleine-koenig@pengutronix.de
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 months agoscsi: sun_esp: Convert to platform remove callback returning void
Uwe Kleine-König [Sun, 3 Dec 2023 16:05:59 +0000 (17:05 +0100)]
scsi: sun_esp: Convert to platform remove callback returning void

The .remove() callback for a platform driver returns an int which makes
many driver authors wrongly assume it's possible to do error handling by
returning an error code. However the value returned is ignored (apart
from emitting a warning) and this typically results in resource leaks.

To improve here there is a quest to make the remove callback return
void. In the first step of this quest all drivers are converted to
.remove_new(), which already returns void. Eventually after all drivers
are converted, .remove_new() will be renamed to .remove().

In the error path emit an error message replacing the (less useful)
message by the core. Apart from the improved error message there is no
change in behaviour.

Trivially convert this driver from always returning zero in the remove
callback to the void returning variant.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Link: https://lore.kernel.org/r/1d385231c23c2a1e6e7dc1968eb111327386d1f6.1701619134.git.u.kleine-koenig@pengutronix.de
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 months agoscsi: sun3x_esp: Convert to platform remove callback returning void
Uwe Kleine-König [Sun, 3 Dec 2023 16:05:58 +0000 (17:05 +0100)]
scsi: sun3x_esp: Convert to platform remove callback returning void

The .remove() callback for a platform driver returns an int which makes
many driver authors wrongly assume it's possible to do error handling by
returning an error code. However the value returned is ignored (apart
from emitting a warning) and this typically results in resource leaks.

To improve here there is a quest to make the remove callback return
void. In the first step of this quest all drivers are converted to
.remove_new(), which already returns void. Eventually after all drivers
are converted, .remove_new() will be renamed to .remove().

In the error path emit an error message replacing the (less useful)
message by the core. Apart from the improved error message there is no
change in behaviour.

Trivially convert this driver from always returning zero in the remove
callback to the void returning variant.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Link: https://lore.kernel.org/r/5010d1a4f3d77eaa1114fa254c343c4f23313901.1701619134.git.u.kleine-koenig@pengutronix.de
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 months agoscsi: sun3: Convert to platform remove callback returning void
Uwe Kleine-König [Sun, 3 Dec 2023 16:05:57 +0000 (17:05 +0100)]
scsi: sun3: Convert to platform remove callback returning void

The .remove() callback for a platform driver returns an int which makes
many driver authors wrongly assume it's possible to do error handling by
returning an error code. However the value returned is ignored (apart
from emitting a warning) and this typically results in resource leaks.

To improve here there is a quest to make the remove callback return
void. In the first step of this quest all drivers are converted to
.remove_new(), which already returns void. Eventually after all drivers
are converted, .remove_new() will be renamed to .remove().

In the error path emit an error message replacing the (less useful)
message by the core. Apart from the improved error message there is no
change in behaviour.

Trivially convert this driver from always returning zero in the remove
callback to the void returning variant.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Link: https://lore.kernel.org/r/84239a68fe06143d1d6fed6c9aaae6a4680ead71.1701619134.git.u.kleine-koenig@pengutronix.de
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 months agoscsi: sni_53c710: Convert to platform remove callback returning void
Uwe Kleine-König [Sun, 3 Dec 2023 16:05:56 +0000 (17:05 +0100)]
scsi: sni_53c710: Convert to platform remove callback returning void

The .remove() callback for a platform driver returns an int which makes
many driver authors wrongly assume it's possible to do error handling by
returning an error code. However the value returned is ignored (apart
from emitting a warning) and this typically results in resource leaks.

To improve here there is a quest to make the remove callback return
void. In the first step of this quest all drivers are converted to
.remove_new(), which already returns void. Eventually after all drivers
are converted, .remove_new() will be renamed to .remove().

In the error path emit an error message replacing the (less useful)
message by the core. Apart from the improved error message there is no
change in behaviour.

Trivially convert this driver from always returning zero in the remove
callback to the void returning variant.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Link: https://lore.kernel.org/r/2f4b7366ca00a107a9595514795e909e632980da.1701619134.git.u.kleine-koenig@pengutronix.de
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 months agoscsi: sgiwd93: Convert to platform remove callback returning void
Uwe Kleine-König [Sun, 3 Dec 2023 16:05:55 +0000 (17:05 +0100)]
scsi: sgiwd93: Convert to platform remove callback returning void

The .remove() callback for a platform driver returns an int which makes
many driver authors wrongly assume it's possible to do error handling by
returning an error code. However the value returned is ignored (apart
from emitting a warning) and this typically results in resource leaks.

To improve here there is a quest to make the remove callback return
void. In the first step of this quest all drivers are converted to
.remove_new(), which already returns void. Eventually after all drivers
are converted, .remove_new() will be renamed to .remove().

In the error path emit an error message replacing the (less useful)
message by the core. Apart from the improved error message there is no
change in behaviour.

Trivially convert this driver from always returning zero in the remove
callback to the void returning variant.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Link: https://lore.kernel.org/r/92114604fd1274073915e515cae15003ff07aa4a.1701619134.git.u.kleine-koenig@pengutronix.de
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 months agoscsi: qlogicpti: Convert to platform remove callback returning void
Uwe Kleine-König [Sun, 3 Dec 2023 16:05:54 +0000 (17:05 +0100)]
scsi: qlogicpti: Convert to platform remove callback returning void

The .remove() callback for a platform driver returns an int which makes
many driver authors wrongly assume it's possible to do error handling by
returning an error code. However the value returned is ignored (apart
from emitting a warning) and this typically results in resource leaks.

To improve here there is a quest to make the remove callback return
void. In the first step of this quest all drivers are converted to
.remove_new(), which already returns void. Eventually after all drivers
are converted, .remove_new() will be renamed to .remove().

In the error path emit an error message replacing the (less useful)
message by the core. Apart from the improved error message there is no
change in behaviour.

Trivially convert this driver from always returning zero in the remove
callback to the void returning variant.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Link: https://lore.kernel.org/r/8242c07f617fc946aab857c9357f540598fe964e.1701619134.git.u.kleine-koenig@pengutronix.de
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 months agoscsi: mvme16x: Convert to platform remove callback returning void
Uwe Kleine-König [Sun, 3 Dec 2023 16:05:53 +0000 (17:05 +0100)]
scsi: mvme16x: Convert to platform remove callback returning void

The .remove() callback for a platform driver returns an int which makes
many driver authors wrongly assume it's possible to do error handling by
returning an error code. However the value returned is ignored (apart
from emitting a warning) and this typically results in resource leaks.

To improve here there is a quest to make the remove callback return
void. In the first step of this quest all drivers are converted to
.remove_new(), which already returns void. Eventually after all drivers
are converted, .remove_new() will be renamed to .remove().

In the error path emit an error message replacing the (less useful)
message by the core. Apart from the improved error message there is no
change in behaviour.

Trivially convert this driver from always returning zero in the remove
callback to the void returning variant.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Link: https://lore.kernel.org/r/1d16e93a498831abd64df8b8cf54fd8872cdd1cd.1701619134.git.u.kleine-koenig@pengutronix.de
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 months agoscsi: mac: Convert to platform remove callback returning void
Uwe Kleine-König [Sun, 3 Dec 2023 16:05:52 +0000 (17:05 +0100)]
scsi: mac: Convert to platform remove callback returning void

The .remove() callback for a platform driver returns an int which makes
many driver authors wrongly assume it's possible to do error handling by
returning an error code. However the value returned is ignored (apart
from emitting a warning) and this typically results in resource leaks.

To improve here there is a quest to make the remove callback return
void. In the first step of this quest all drivers are converted to
.remove_new(), which already returns void. Eventually after all drivers
are converted, .remove_new() will be renamed to .remove().

In the error path emit an error message replacing the (less useful)
message by the core. Apart from the improved error message there is no
change in behaviour.

Trivially convert this driver from always returning zero in the remove
callback to the void returning variant.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Link: https://lore.kernel.org/r/89ce161dad52d99df07135531512ccecb7f25d14.1701619134.git.u.kleine-koenig@pengutronix.de
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 months agoscsi: mac_esp: Convert to platform remove callback returning void
Uwe Kleine-König [Sun, 3 Dec 2023 16:05:51 +0000 (17:05 +0100)]
scsi: mac_esp: Convert to platform remove callback returning void

The .remove() callback for a platform driver returns an int which makes
many driver authors wrongly assume it's possible to do error handling by
returning an error code. However the value returned is ignored (apart
from emitting a warning) and this typically results in resource leaks.

To improve here there is a quest to make the remove callback return
void. In the first step of this quest all drivers are converted to
.remove_new(), which already returns void. Eventually after all drivers
are converted, .remove_new() will be renamed to .remove().

In the error path emit an error message replacing the (less useful)
message by the core. Apart from the improved error message there is no
change in behaviour.

Trivially convert this driver from always returning zero in the remove
callback to the void returning variant.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Link: https://lore.kernel.org/r/9013c84059b8ccd6a5c8305aa35cfdfa314ba74c.1701619134.git.u.kleine-koenig@pengutronix.de
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 months agoscsi: jazz_esp: Convert to platform remove callback returning void
Uwe Kleine-König [Sun, 3 Dec 2023 16:05:50 +0000 (17:05 +0100)]
scsi: jazz_esp: Convert to platform remove callback returning void

The .remove() callback for a platform driver returns an int which makes
many driver authors wrongly assume it's possible to do error handling by
returning an error code. However the value returned is ignored (apart
from emitting a warning) and this typically results in resource leaks.

To improve here there is a quest to make the remove callback return
void. In the first step of this quest all drivers are converted to
.remove_new(), which already returns void. Eventually after all drivers
are converted, .remove_new() will be renamed to .remove().

In the error path emit an error message replacing the (less useful)
message by the core. Apart from the improved error message there is no
change in behaviour.

Trivially convert this driver from always returning zero in the remove
callback to the void returning variant.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Link: https://lore.kernel.org/r/f71efbe17973c97fd2a1e78f8d7fcf456644510b.1701619134.git.u.kleine-koenig@pengutronix.de
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 months agoscsi: bvme6000: Convert to platform remove callback returning void
Uwe Kleine-König [Sun, 3 Dec 2023 16:05:49 +0000 (17:05 +0100)]
scsi: bvme6000: Convert to platform remove callback returning void

The .remove() callback for a platform driver returns an int which makes
many driver authors wrongly assume it's possible to do error handling by
returning an error code. However the value returned is ignored (apart
from emitting a warning) and this typically results in resource leaks.

To improve here there is a quest to make the remove callback return
void. In the first step of this quest all drivers are converted to
.remove_new(), which already returns void. Eventually after all drivers
are converted, .remove_new() will be renamed to .remove().

In the error path emit an error message replacing the (less useful)
message by the core. Apart from the improved error message there is no
change in behaviour.

Trivially convert this driver from always returning zero in the remove
callback to the void returning variant.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Link: https://lore.kernel.org/r/63294479a4e745210c078859afa88904fa0b3be8.1701619134.git.u.kleine-koenig@pengutronix.de
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 months agoscsi: atari: Convert to platform remove callback returning void
Uwe Kleine-König [Sun, 3 Dec 2023 16:05:48 +0000 (17:05 +0100)]
scsi: atari: Convert to platform remove callback returning void

The .remove() callback for a platform driver returns an int which makes
many driver authors wrongly assume it's possible to do error handling by
returning an error code. However the value returned is ignored (apart
from emitting a warning) and this typically results in resource leaks.

To improve here there is a quest to make the remove callback return
void. In the first step of this quest all drivers are converted to
.remove_new(), which already returns void. Eventually after all drivers
are converted, .remove_new() will be renamed to .remove().

In the error path emit an error message replacing the (less useful)
message by the core. Apart from the improved error message there is no
change in behaviour.

Trivially convert this driver from always returning zero in the remove
callback to the void returning variant.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Link: https://lore.kernel.org/r/27a2b133b1b88a9baf51353c511e93a5027f9602.1701619134.git.u.kleine-koenig@pengutronix.de
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 months agoscsi: a4000t: Convert to platform remove callback returning void
Uwe Kleine-König [Sun, 3 Dec 2023 16:05:47 +0000 (17:05 +0100)]
scsi: a4000t: Convert to platform remove callback returning void

The .remove() callback for a platform driver returns an int which makes
many driver authors wrongly assume it's possible to do error handling by
returning an error code. However the value returned is ignored (apart
from emitting a warning) and this typically results in resource leaks.

To improve here there is a quest to make the remove callback return
void. In the first step of this quest all drivers are converted to
.remove_new(), which already returns void. Eventually after all drivers
are converted, .remove_new() will be renamed to .remove().

In the error path emit an error message replacing the (less useful)
message by the core. Apart from the improved error message there is no
change in behaviour.

Trivially convert this driver from always returning zero in the remove
callback to the void returning variant.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Link: https://lore.kernel.org/r/c15ffc57efebc5da3f7e6dd558d69181e129cafe.1701619134.git.u.kleine-koenig@pengutronix.de
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 months agoscsi: a3000: Convert to platform remove callback returning void
Uwe Kleine-König [Sun, 3 Dec 2023 16:05:46 +0000 (17:05 +0100)]
scsi: a3000: Convert to platform remove callback returning void

The .remove() callback for a platform driver returns an int which makes
many driver authors wrongly assume it's possible to do error handling by
returning an error code. However the value returned is ignored (apart
from emitting a warning) and this typically results in resource leaks.

To improve here there is a quest to make the remove callback return
void. In the first step of this quest all drivers are converted to
.remove_new(), which already returns void. Eventually after all drivers
are converted, .remove_new() will be renamed to .remove().

In the error path emit an error message replacing the (less useful)
message by the core. Apart from the improved error message there is no
change in behaviour.

Trivially convert this driver from always returning zero in the remove
callback to the void returning variant.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Link: https://lore.kernel.org/r/811d180950b76c2d95cd080e3c251757ca011380.1701619134.git.u.kleine-koenig@pengutronix.de
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 months agoMerge branch '6.8/s/mpi3mr2' into 6.8/scsi-staging
Martin K. Petersen [Wed, 6 Dec 2023 02:46:32 +0000 (21:46 -0500)]
Merge branch '6.8/s/mpi3mr2' into 6.8/scsi-staging

Two driver updates from Chandrakanth patil at Broadcom:

  scsi: mpi3mr: Update driver version to 8.5.1.0.0
  scsi: mpi3mr: Support for preallocation of SGL BSG data buffers part-3
  scsi: mpi3mr: Support for preallocation of SGL BSG data buffers part-2
  scsi: mpi3mr: Support for preallocation of SGL BSG data buffers part-1
  scsi: mpi3mr: Fetch correct device dev handle for status reply descriptor
  scsi: mpi3mr: Block PEL Enable Command on Controller Reset and Unrecoverable State
  scsi: mpi3mr: Clean up block devices post controller reset
  scsi: mpi3mr: Refresh sdev queue depth after controller reset

Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 months agoscsi: mpi3mr: Update driver version to 8.5.1.0.0
Chandrakanth patil [Tue, 5 Dec 2023 19:16:30 +0000 (00:46 +0530)]
scsi: mpi3mr: Update driver version to 8.5.1.0.0

Update driver version to 8.5.1.0.0

Signed-off-by: Chandrakanth patil <chandrakanth.patil@broadcom.com>
Link: https://lore.kernel.org/r/20231205191630.12201-5-chandrakanth.patil@broadcom.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 months agoscsi: mpi3mr: Support for preallocation of SGL BSG data buffers part-3
Chandrakanth patil [Tue, 5 Dec 2023 19:16:29 +0000 (00:46 +0530)]
scsi: mpi3mr: Support for preallocation of SGL BSG data buffers part-3

The driver acquires the required NVMe SGLs from the pre-allocated
pool.

Co-developed-by: Sathya Prakash <sathya.prakash@broadcom.com>
Signed-off-by: Sathya Prakash <sathya.prakash@broadcom.com>
Signed-off-by: Chandrakanth patil <chandrakanth.patil@broadcom.com>
Link: https://lore.kernel.org/r/20231205191630.12201-4-chandrakanth.patil@broadcom.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 months agoscsi: mpi3mr: Support for preallocation of SGL BSG data buffers part-2
Chandrakanth patil [Tue, 5 Dec 2023 19:16:28 +0000 (00:46 +0530)]
scsi: mpi3mr: Support for preallocation of SGL BSG data buffers part-2

The driver acquires the required SGLs from the pre-allocated pool.

Co-developed-by: Sathya Prakash <sathya.prakash@broadcom.com>
Signed-off-by: Sathya Prakash <sathya.prakash@broadcom.com>
Signed-off-by: Chandrakanth patil <chandrakanth.patil@broadcom.com>
Link: https://lore.kernel.org/r/20231205191630.12201-3-chandrakanth.patil@broadcom.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 months agoscsi: mpi3mr: Support for preallocation of SGL BSG data buffers part-1
Chandrakanth patil [Tue, 5 Dec 2023 19:16:27 +0000 (00:46 +0530)]
scsi: mpi3mr: Support for preallocation of SGL BSG data buffers part-1

The driver now supports SGLs for BSG data transfer. Upon loading, the
driver pre-allocates SGLs in chunks of 8k, results in a total of 256 * 8k,
equal to 2MB. These pre-allocated SGLs are reserved for handling BSG
commands and are deallocated during driver unload.

Co-developed-by: Sathya Prakash <sathya.prakash@broadcom.com>
Signed-off-by: Sathya Prakash <sathya.prakash@broadcom.com>
Signed-off-by: Chandrakanth patil <chandrakanth.patil@broadcom.com>
Link: https://lore.kernel.org/r/20231205191630.12201-2-chandrakanth.patil@broadcom.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 months agoscsi: mpi3mr: Fetch correct device dev handle for status reply descriptor
Chandrakanth patil [Sun, 26 Nov 2023 05:31:34 +0000 (11:01 +0530)]
scsi: mpi3mr: Fetch correct device dev handle for status reply descriptor

The current dev handle for the status reply is 0xFFFF, which is invalid.
So fetch the correct value.

Co-developed-by: Sumit Saxena <sumit.saxena@broadcom.com>
Signed-off-by: Sumit Saxena <sumit.saxena@broadcom.com>
Signed-off-by: Chandrakanth patil <chandrakanth.patil@broadcom.com>
Link: https://lore.kernel.org/r/20231126053134.10133-5-chandrakanth.patil@broadcom.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 months agoscsi: mpi3mr: Block PEL Enable Command on Controller Reset and Unrecoverable State
Chandrakanth patil [Sun, 26 Nov 2023 05:31:33 +0000 (11:01 +0530)]
scsi: mpi3mr: Block PEL Enable Command on Controller Reset and Unrecoverable State

If a controller reset is underway or the controller is in an unrecoverable
state, the PEL enable management command will be returned as EAGAIN or
EFAULT.

Cc: <stable@vger.kernel.org> # v6.1+
Co-developed-by: Sathya Prakash <sathya.prakash@broadcom.com>
Signed-off-by: Sathya Prakash <sathya.prakash@broadcom.com>
Signed-off-by: Chandrakanth patil <chandrakanth.patil@broadcom.com>
Link: https://lore.kernel.org/r/20231126053134.10133-4-chandrakanth.patil@broadcom.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 months agoscsi: mpi3mr: Clean up block devices post controller reset
Chandrakanth patil [Sun, 26 Nov 2023 05:31:32 +0000 (11:01 +0530)]
scsi: mpi3mr: Clean up block devices post controller reset

After a controller reset, if the firmware changes the state of devices to
"hide", then remove those devices from the OS.

Cc: <stable@vger.kernel.org> # v6.6+
Co-developed-by: Sathya Prakash <sathya.prakash@broadcom.com>
Signed-off-by: Sathya Prakash <sathya.prakash@broadcom.com>
Signed-off-by: Chandrakanth patil <chandrakanth.patil@broadcom.com>
Link: https://lore.kernel.org/r/20231126053134.10133-3-chandrakanth.patil@broadcom.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 months agoscsi: mpi3mr: Refresh sdev queue depth after controller reset
Chandrakanth patil [Sun, 26 Nov 2023 05:31:31 +0000 (11:01 +0530)]
scsi: mpi3mr: Refresh sdev queue depth after controller reset

After a controller reset, the firmware may modify the device queue depth.
Therefore, update the device queue depth accordingly.

Cc: <stable@vger.kernel.org> # v5.15+
Co-developed-by: Sathya Prakash <sathya.prakash@broadcom.com>
Signed-off-by: Sathya Prakash <sathya.prakash@broadcom.com>
Signed-off-by: Chandrakanth patil <chandrakanth.patil@broadcom.com>
Link: https://lore.kernel.org/r/20231126053134.10133-2-chandrakanth.patil@broadcom.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 months agoMerge patch series "libfc: fixup command abort handling"
Martin K. Petersen [Wed, 6 Dec 2023 02:33:05 +0000 (21:33 -0500)]
Merge patch series "libfc: fixup command abort handling"

Hannes Reinecke <hare@kernel.org> says:

Hi all,

when testing command timeout with the help of XDP I found that
scsi_try_to_abort_cmd() would always return 'SUCCESS' for FCoE, even
if no commands could be sent over the wire.  Which is not only
surprising, but also can lead to data corruption as commands were
never aborted.  Root cause was that aborts had been sent twice, once
from FC error recovery and once from SCSI EH, with the former inducing
the latter to assume that the command was already aborted.

As usual, comments and reviews are welcome.

Link: https://lore.kernel.org/r/20231129165832.224100-1-hare@kernel.org
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 months agoscsi: libfc: Map FC_TIMED_OUT to DID_TIME_OUT
Hannes Reinecke [Wed, 29 Nov 2023 16:58:32 +0000 (17:58 +0100)]
scsi: libfc: Map FC_TIMED_OUT to DID_TIME_OUT

When an exchange is completed with FC_TIMED_OUT we should map it to
DID_TIME_OUT to inform the SCSI midlayer that this was a command timeout;
DID_BUS_BUSY implies that the command was never sent which is not the case
here.

Signed-off-by: Hannes Reinecke <hare@suse.de>
Link: https://lore.kernel.org/r/20231129165832.224100-4-hare@kernel.org
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 months agoscsi: libfc: Fix up timeout error in fc_fcp_rec_error()
Hannes Reinecke [Wed, 29 Nov 2023 16:58:31 +0000 (17:58 +0100)]
scsi: libfc: Fix up timeout error in fc_fcp_rec_error()

We should set the status to FC_TIMED_OUT when a timeout error is passed to
fc_fcp_rec_error().

Signed-off-by: Hannes Reinecke <hare@suse.de>
Link: https://lore.kernel.org/r/20231129165832.224100-3-hare@kernel.org
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 months agoscsi: libfc: Don't schedule abort twice
Hannes Reinecke [Wed, 29 Nov 2023 16:58:30 +0000 (17:58 +0100)]
scsi: libfc: Don't schedule abort twice

The current FC error recovery is sending up to three REC (recovery) frames
in 10 second intervals, and as a final step sending an ABTS after 30
seconds for the command itself.  Unfortunately sending an ABTS is also the
action for the SCSI abort handler, and the default timeout for SCSI
commands is also 30 seconds. This causes two ABTS to be scheduled, with the
libfc one slightly earlier. The ABTS scheduled by SCSI EH then sees the
command to be already aborted, and will always return with a 'GOOD' status
irrespective on the actual result from the first ABTS.  This causes the
SCSI EH abort handler to always succeed, and SCSI EH never to be engaged.
Fix this by not issuing an ABTS when a SCSI command is present for the
exchange, but rather wait for the abort scheduled from SCSI EH.  And warn
if an abort is already scheduled to avoid similar errors in the future.

Signed-off-by: Hannes Reinecke <hare@suse.de>
Link: https://lore.kernel.org/r/20231129165832.224100-2-hare@kernel.org
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 months agoscsi: aic7xxx: Return negative error codes in aic7770_probe()
Su Hui [Fri, 1 Dec 2023 02:59:56 +0000 (10:59 +0800)]
scsi: aic7xxx: Return negative error codes in aic7770_probe()

aic7770_config() returns both negative and positive error codes.  It's
better to make aic7770_probe() only return negative error codes.

A previous commit made ahc_linux_register_host() return negative error
codes, which makes sure aic7770_probe() returns negative error codes.

Signed-off-by: Su Hui <suhui@nfschina.com>
Link: https://lore.kernel.org/r/20231201025955.1584260-4-suhui@nfschina.com
Reviewed-by: Dan Carpenter <dan.carpenter@linaro.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 months agoscsi: aic7xxx: Return ahc_linux_register_host()'s value rather than zero
Su Hui [Fri, 1 Dec 2023 02:59:55 +0000 (10:59 +0800)]
scsi: aic7xxx: Return ahc_linux_register_host()'s value rather than zero

ahc_linux_register_host() can return an error code in case of failure. So
ahc_linux_pci_dev_probe() should return the value of
ahc_linux_register_host() rather than zero.

An earlier commit made ahc_linux_register_host() return negative error
codes, which makes sure ahc_linux_pci_dev_probe() returns negative error
codes.

Signed-off-by: Su Hui <suhui@nfschina.com>
Link: https://lore.kernel.org/r/20231201025955.1584260-3-suhui@nfschina.com
Reviewed-by: Dan Carpenter <dan.carpenter@linaro.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 months agoscsi: aic7xxx: Return negative error codes in ahc_linux_register_host()
Su Hui [Fri, 1 Dec 2023 02:59:54 +0000 (10:59 +0800)]
scsi: aic7xxx: Return negative error codes in ahc_linux_register_host()

ahc_linux_register_host() returns both positive and negative error codes.
It's better to make this function only return negative error codes.

Signed-off-by: Su Hui <suhui@nfschina.com>
Link: https://lore.kernel.org/r/20231201025955.1584260-2-suhui@nfschina.com
Reviewed-by: Dan Carpenter <dan.carpenter@linaro.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 months agoscsi: isci: Remove redundant check in isci_task_request_build()
Artem Chernyshev [Tue, 28 Nov 2023 12:11:59 +0000 (15:11 +0300)]
scsi: isci: Remove redundant check in isci_task_request_build()

sci_task_request_construct_ssp() has invariant return. Change this function
to void and get rid of unnecessary checks.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Signed-off-by: Artem Chernyshev <artem.chernyshev@red-soft.ru>
Link: https://lore.kernel.org/r/20231128121159.2373975-1-artem.chernyshev@red-soft.ru
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 months agoscsi: ipr: Remove obsolete check for old CPUs
Michael Ellerman [Mon, 27 Nov 2023 11:17:40 +0000 (22:17 +1100)]
scsi: ipr: Remove obsolete check for old CPUs

The IPR driver has a routine to check whether it's running on certain CPU
versions and if so whether the adapter is supported on that CPU.

But none of the CPUs it checks for are supported by Linux anymore.

The most recent CPU it checks for is Power4+ which was removed in commit
471d7ff8b51b ("powerpc/64s: Remove POWER4 support").

So drop the check. That makes the "testmode" module parameter unused, so
remove it as well.

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20231127111740.1288463-1-mpe@ellerman.id.au
Acked-by: Brian King <brking@linux.vnet.ibm.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 months agoscsi: ibmvscsi: Replace deprecated strncpy() with strscpy()
Justin Stitt [Mon, 30 Oct 2023 20:40:48 +0000 (20:40 +0000)]
scsi: ibmvscsi: Replace deprecated strncpy() with strscpy()

strncpy() is deprecated for use on NUL-terminated destination strings [1]
and as such we should prefer more robust and less ambiguous string
interfaces.

We expect partition_name to be NUL-terminated based on its usage with
format strings:
|       dev_info(hostdata->dev, "host srp version: %s, "
|                "host partition %s (%d), OS %d, max io %u\n",
|                hostdata->madapter_info.srp_version,
|                hostdata->madapter_info.partition_name,
|                be32_to_cpu(hostdata->madapter_info.partition_number),
|                be32_to_cpu(hostdata->madapter_info.os_type),
|                be32_to_cpu(hostdata->madapter_info.port_max_txu[0]));
...
|       len = snprintf(buf, PAGE_SIZE, "%s\n",
|                hostdata->madapter_info.partition_name);

Moreover, NUL-padding is not required as madapter_info is explicitly
memset to 0:
|       memset(&hostdata->madapter_info, 0x00,
|                       sizeof(hostdata->madapter_info));

Considering the above, a suitable replacement is strscpy() [2] due to the
fact that it guarantees NUL-termination on the destination buffer without
unnecessarily NUL-padding.

Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#strncpy-on-nul-terminated-strings
Link: https://manpages.debian.org/testing/linux-manual-4.8/strscpy.9.en.html
Link: https://github.com/KSPP/linux/issues/90
Cc: <linux-hardening@vger.kernel.org>
Signed-off-by: Justin Stitt <justinstitt@google.com>
Link: https://lore.kernel.org/r/20231030-strncpy-drivers-scsi-ibmvscsi-ibmvscsi-c-v1-1-f8b06ae9e3d5@google.com
Reviewed-by: Kees Cook <keescook@chromium.org>
Tested-by: Michael Ellerman <mpe@ellerman.id.au>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 months agoscsi: ibmvfc: Replace deprecated strncpy() with strscpy()
Justin Stitt [Mon, 30 Oct 2023 19:04:33 +0000 (19:04 +0000)]
scsi: ibmvfc: Replace deprecated strncpy() with strscpy()

strncpy() is deprecated for use on NUL-terminated destination strings [1]
and as such we should prefer more robust and less ambiguous string
interfaces.

We expect these fields to be NUL-terminated as the property names from
which they are derived are also NUL-terminated.

Moreover, NUL-padding is not required as our destination buffers are
already NUL-allocated and any future NUL-byte assignments are redundant
(like the ones that strncpy() does).
ibmvfc_probe() ->
|       struct ibmvfc_host *vhost;
|       struct Scsi_Host *shost;
...
|  shost = scsi_host_alloc(&driver_template, sizeof(*vhost));
... **side note: is this a bug? Looks like a type to me   ^^^^^**
...
| vhost = shost_priv(shost);

... where shost_priv() is:
|       static inline void *shost_priv(struct Scsi_Host *shost)
|       {
|        return (void *)shost->hostdata;
|       }

.. and:
scsi_host_alloc() ->
|  shost = kzalloc(sizeof(struct Scsi_Host) + privsize, GFP_KERNEL);

And for login_info->..., NUL-padding is also not required as it is
explicitly memset to 0:
| memset(login_info, 0, sizeof(*login_info));

Considering the above, a suitable replacement is strscpy() [2] due to
the fact that it guarantees NUL-termination on the destination buffer
without unnecessarily NUL-padding.

Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#strncpy-on-nul-terminated-strings
Link: https://manpages.debian.org/testing/linux-manual-4.8/strscpy.9.en.html
Link: https://github.com/KSPP/linux/issues/90
Cc: <linux-hardening@vger.kernel.org>
Signed-off-by: Justin Stitt <justinstitt@google.com>
Link: https://lore.kernel.org/r/20231030-strncpy-drivers-scsi-ibmvscsi-ibmvfc-c-v1-1-5a4909688435@google.com
Reviewed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 months agoscsi: zfcp: Replace strlcpy() with strscpy()
Kees Cook [Thu, 30 Nov 2023 20:41:00 +0000 (12:41 -0800)]
scsi: zfcp: Replace strlcpy() with strscpy()

strlcpy() reads the entire source buffer first. This read may exceed the
destination size limit. This is both inefficient and can lead to linear
read overflows if a source string is not NUL-terminated[1].  Additionally,
it returns the size of the source string, not the resulting size of the
destination string. In an effort to remove strlcpy() completely[2], replace
strlcpy() here with strscpy().

Overflow should be impossible here, but actually check for buffer sizes
being identical with BUILD_BUG_ON(), and include a run-time check as well.

Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#strlcpy
Link: https://github.com/KSPP/linux/issues/89
Cc: Martin K. Petersen <martin.petersen@oracle.com>
Cc: James E.J. Bottomley <jejb@linux.ibm.com>
Cc: Steffen Maier <maier@linux.ibm.com>
Cc: Benjamin Block <bblock@linux.ibm.com>
Cc: Heiko Carstens <hca@linux.ibm.com>
Cc: Vasily Gorbik <gor@linux.ibm.com>
Cc: Alexander Gordeev <agordeev@linux.ibm.com>
Cc: Christian Borntraeger <borntraeger@linux.ibm.com>
Cc: Sven Schnelle <svens@linux.ibm.com>
Cc: Azeem Shaikh <azeemshaikh38@gmail.com>
Cc: <linux-s390@vger.kernel.org>
Cc: <linux-scsi@vger.kernel.org>
Signed-off-by: Kees Cook <keescook@chromium.org>
Link: https://lore.kernel.org/r/20231130204056.it.978-kees@kernel.org
Acked-by: Benjamin Block <bblock@linux.ibm.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 months agoscsi: target: Enable READ CAPACITY for PR EARO
Benjamin Coddington [Wed, 29 Nov 2023 16:13:54 +0000 (11:13 -0500)]
scsi: target: Enable READ CAPACITY for PR EARO

SBC-4, Table 13 allows READ CAPACITY for all PR types.

Signed-off-by: Benjamin Coddington <bcodding@redhat.com>
Link: https://lore.kernel.org/r/ad095388dbc550c5b199a1dfa71bcbfc575a7abe.1701272679.git.bcodding@redhat.com
Reviewed-by: Mike Christie <michael.christie@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 months agoscsi: fnic: Return error if vmalloc() failed
Artem Chernyshev [Tue, 28 Nov 2023 11:10:08 +0000 (14:10 +0300)]
scsi: fnic: Return error if vmalloc() failed

In fnic_init_module() exists redundant check for return value from
fnic_debugfs_init(), because at moment it only can return zero. It make
sense to process theoretical vmalloc() failure.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Fixes: 9730ddfb123d ("scsi: fnic: remove redundant assignment of variable rc")
Signed-off-by: Artem Chernyshev <artem.chernyshev@red-soft.ru>
Link: https://lore.kernel.org/r/20231128111008.2280507-1-artem.chernyshev@red-soft.ru
Reviewed-by: Karan Tilak Kumar <kartilak@cisco.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
6 months agoscsi: ufs: dt-bindings: Add msi-parent for UFS MCQ
Ziqi Chen [Tue, 28 Nov 2023 04:07:47 +0000 (12:07 +0800)]
scsi: ufs: dt-bindings: Add msi-parent for UFS MCQ

The Message Signaled Interrupts (MSI) support has been introduced in UFSHCI
version 4.0 (JESD223E). The MSI is the recommended interrupt approach for
MCQ. If choose to use MSI, in UFS DT, we need to provide msi-parent
property that point to the hardware entity which serves as the MSI
controller for this UFS controller.

Acked-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Acked-by: Conor Dooley <conor.dooley@microchip.com>
Signed-off-by: Ziqi Chen <quic_ziqichen@quicinc.com>
Link: https://lore.kernel.org/r/1701144469-1018-1-git-send-email-quic_ziqichen@quicinc.com
Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 months agoMerge patch series "scsi: arcmsr: support Areca ARC-1688 Raid controller"
Martin K. Petersen [Sat, 25 Nov 2023 02:24:38 +0000 (21:24 -0500)]
Merge patch series "scsi: arcmsr: support Areca ARC-1688 Raid controller"

Driver update from ching Huang <ching2048@areca.com.tw>.

Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 months agoscsi: arcmsr: Update driver version to v1.51.00.14-20230915
ching Huang [Mon, 2 Oct 2023 09:54:20 +0000 (17:54 +0800)]
scsi: arcmsr: Update driver version to v1.51.00.14-20230915

Signed-off-by: ching Huang <ching2048@areca.com.tw>
Link: https://lore.kernel.org/r/514898a472dfdf0502afe27d127ed5145a1fb915.camel@areca.com.tw
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 months agoscsi: arcmsr: Support new PCI device IDs 1883 and 1886
ching Huang [Mon, 2 Oct 2023 09:50:27 +0000 (17:50 +0800)]
scsi: arcmsr: Support new PCI device IDs 1883 and 1886

Add support for Areca RAID controllers with PCI device IDs 1883 and 1886.

Signed-off-by: ching Huang <ching2048@areca.com.tw>
Link: https://lore.kernel.org/r/7732e743eaad57681b1552eec9c6a86c76dbe459.camel@areca.com.tw
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 months agoscsi: arcmsr: Support new RAID controller ARC-1688
ching Huang [Mon, 2 Oct 2023 09:42:19 +0000 (17:42 +0800)]
scsi: arcmsr: Support new RAID controller ARC-1688

Add support for new Areca RAID controller ARC-1688

Signed-off-by: ching Huang <ching2048@areca.com.tw>
Link: https://lore.kernel.org/r/110bdc873497d3d5e090b908fb159b6155bb3a2b.camel@areca.com.tw
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 months agoscsi: dc395x: Fix warning using plain integer as NULL
Abhinav Singh [Thu, 9 Nov 2023 21:50:49 +0000 (03:20 +0530)]
scsi: dc395x: Fix warning using plain integer as NULL

Sparse static analysis tool generates a warning with this message "Using
plain integer as NULL pointer". Fix it.

Signed-off-by: Abhinav Singh <singhabhinav9051571833@gmail.com>
Link: https://lore.kernel.org/r/20231109215049.1466431-1-singhabhinav9051571833@gmail.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 months agoMerge patch series "mpi3mr: Add support for Broadcom SAS5116 IO/RAID controllers"
Martin K. Petersen [Sat, 25 Nov 2023 01:55:24 +0000 (20:55 -0500)]
Merge patch series "mpi3mr: Add support for Broadcom SAS5116 IO/RAID controllers"

Sumit Saxena <sumit.saxena@broadcom.com> says:

These patches add support for Broadcom's SAS5116 IO/RAID controllers
in mpi3mr driver.

Link: https://lore.kernel.org/r/20231123160132.4155-1-sumit.saxena@broadcom.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 months agoscsi: mpi3mr: driver version upgrade to 8.5.0.0.50
Sumit Saxena [Thu, 23 Nov 2023 16:01:32 +0000 (21:31 +0530)]
scsi: mpi3mr: driver version upgrade to 8.5.0.0.50

Update driver version to 8.5.0.0.50.

Signed-off-by: Sumit Saxena <sumit.saxena@broadcom.com>
Link: https://lore.kernel.org/r/20231123160132.4155-6-sumit.saxena@broadcom.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 months agoscsi: mpi3mr: Add support for status reply descriptor
Sumit Saxena [Thu, 23 Nov 2023 16:01:31 +0000 (21:31 +0530)]
scsi: mpi3mr: Add support for status reply descriptor

Inform controller firmware that driver supports status reply descriptor.

Signed-off-by: Sumit Saxena <sumit.saxena@broadcom.com>
Link: https://lore.kernel.org/r/20231123160132.4155-5-sumit.saxena@broadcom.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 months agoscsi: mpi3mr: Increase maximum number of PHYs to 64 from 32
Sumit Saxena [Thu, 23 Nov 2023 16:01:30 +0000 (21:31 +0530)]
scsi: mpi3mr: Increase maximum number of PHYs to 64 from 32

SAS5116 controllers supports maximum 48 physical PHYs. Modify driver to
accommodate up to 64 PHYs (though current need is to support 48 PHYs).

Signed-off-by: Sumit Saxena <sumit.saxena@broadcom.com>
Link: https://lore.kernel.org/r/20231123160132.4155-4-sumit.saxena@broadcom.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 months agoscsi: mpi3mr: Add PCI checks where SAS5116 diverges from SAS4116
Sumit Saxena [Thu, 23 Nov 2023 16:01:29 +0000 (21:31 +0530)]
scsi: mpi3mr: Add PCI checks where SAS5116 diverges from SAS4116

Add PCI IDs checks for the cases where SAS5116 diverges from SAS4116 in
behavior.

Signed-off-by: Sumit Saxena <sumit.saxena@broadcom.com>
Link: https://lore.kernel.org/r/20231123160132.4155-3-sumit.saxena@broadcom.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 months agoscsi: mpi3mr: Add support for SAS5116 PCI IDs
Sumit Saxena [Thu, 23 Nov 2023 16:01:28 +0000 (21:31 +0530)]
scsi: mpi3mr: Add support for SAS5116 PCI IDs

Add support for Broadcom's SAS5116 IO/RAID controllers PCI IDs.

Signed-off-by: Sumit Saxena <sumit.saxena@broadcom.com>
Link: https://lore.kernel.org/r/20231123160132.4155-2-sumit.saxena@broadcom.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 months agoscsi: ufs: core: Warn if the request tag is truncated
Bart Van Assche [Wed, 15 Nov 2023 19:33:47 +0000 (11:33 -0800)]
scsi: ufs: core: Warn if the request tag is truncated

ufshcd_prepare_utp_scsi_cmd_upiu() only uses the lowest eight bits of
lrbp->task_tag. Issue a runtime warning if this results in truncation.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Link: https://lore.kernel.org/r/20231115193359.2262044-1-bvanassche@acm.org
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 months agoscsi: core: Add a precondition check in scsi_eh_scmd_add()
Bart Van Assche [Wed, 15 Nov 2023 19:33:43 +0000 (11:33 -0800)]
scsi: core: Add a precondition check in scsi_eh_scmd_add()

Calling scsi_eh_scmd_add() may cause the error handler never to be woken up
because this may result in shost->host_failed to become larger than
scsi_host_busy(shost). Hence complain if scsi_eh_scmd_add() is called after
SCMD_STATE_INFLIGHT has been cleared.

Cc: Hannes Reinecke <hare@suse.de>
Cc: Damien Le Moal <damien.lemoal@opensource.wdc.com>
Cc: Mike Christie <michael.christie@oracle.com>
Cc: John Garry <john.g.garry@oracle.com>
Cc: Ming Lei <ming.lei@redhat.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Link: https://lore.kernel.org/r/20231115193343.2262013-1-bvanassche@acm.org
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 months agoscsi: bfa: Use the proper data type for BLIST flags
Bart Van Assche [Wed, 15 Nov 2023 19:33:38 +0000 (11:33 -0800)]
scsi: bfa: Use the proper data type for BLIST flags

Fix the following sparse warning:

drivers/scsi/bfa/bfad_bsg.c:2553:50: sparse: sparse: incorrect type in initializer (different base types)

Fixes: 2e5a6c3baccd ("scsi: bfa: Convert bfad_reset_sdev_bflags() from a macro into a function")
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202311031255.lmSPisIk-lkp@intel.com/
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Link: https://lore.kernel.org/r/20231115193338.2261972-1-bvanassche@acm.org
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 months agoscsi: ufs: core: Make fault injection dynamically configurable per HBA
Akinobu Mita [Sat, 18 Nov 2023 12:44:43 +0000 (21:44 +0900)]
scsi: ufs: core: Make fault injection dynamically configurable per HBA

The UFS driver has two driver-specific fault injection mechanisms
(trigger_eh and timeout). Each fault injection configuration can only be
specified by a module parameter and cannot be reconfigured without
reloading the driver. Also, each configuration is common to all HBAs.

This change adds the following subdirectories for each UFS HBA when
debugfs is enabled:

  /sys/kernel/debug/ufshcd/<HBA>/timeout_inject
  /sys/kernel/debug/ufshcd/<HBA>/trigger_eh_inject

Each fault injection attribute can be dynamically set per HBA by a
corresponding file in these directories.

This is tested with QEMU UFS devices.

Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Link: https://lore.kernel.org/r/20231118124443.1007116-1-akinobu.mita@gmail.com
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 months agoscsi: ufs: mediatek: Change the maintainer for MediaTek UFS hooks
Stanley Jhu [Fri, 17 Nov 2023 10:38:10 +0000 (18:38 +0800)]
scsi: ufs: mediatek: Change the maintainer for MediaTek UFS hooks

Change the maintainer of MediaTek UFS hooks to Peter Wang.

The original maintainer, Stanley Chu, who could previously be reached at
stanley.chu@mediatek.com, has left MediaTek. Update the email address
accordingly and list Stanley as reviewer.

Cc: Stanley Chu <stanley.chu@mediatek.com>
Reviewed-by: Peter Wang <peter.wang@mediatek.com>
Reviewed-by: Macpaul Lin <macpaul.lin@mediatek.com>
Signed-off-by: Stanley Jhu <chu.stanley@gmail.com>
Link: https://lore.kernel.org/r/20231117103810.527-1-chu.stanley@gmail.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 months agoscsi: mpt3sas: Suppress a warning in debug kernel
Tomas Henzl [Thu, 19 Oct 2023 15:37:06 +0000 (17:37 +0200)]
scsi: mpt3sas: Suppress a warning in debug kernel

The mpt3sas_ctl_exit() should be called after communication with the
controller stops but currently it may cause false warnings about not
released memory. Fix this by letting mpt3sas_ctl_exit() handle misc driver
release per driver and release DMA in mpt3sas_ctl_release() per ioc.

Signed-off-by: Tomas Henzl <thenzl@redhat.com>
Link: https://lore.kernel.org/r/20231019153706.7967-1-thenzl@redhat.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 months agoscsi: ufs: ufs-sysfs: Expose UFS power info
Can Guo [Thu, 2 Nov 2023 01:58:36 +0000 (18:58 -0700)]
scsi: ufs: ufs-sysfs: Expose UFS power info

Having UFS power info available in sysfs makes it easier to tell the state
of the link during runtime considering we have a bunch of power saving
features and various combinations for backward compatibility.

Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Reviewed-by: Bean Huo <beanhuo@micron.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Can Guo <quic_cang@quicinc.com>
Link: https://lore.kernel.org/r/1698890324-7374-1-git-send-email-quic_cang@quicinc.com
Reviewed-by: Avri Altman <avri.altman@wdc.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 months agoMerge patch series "lpfc: Update lpfc to revision 14.2.0.16"
Martin K. Petersen [Wed, 15 Nov 2023 15:07:39 +0000 (10:07 -0500)]
Merge patch series "lpfc: Update lpfc to revision 14.2.0.16"

Justin Tee <justintee8345@gmail.com> says:

Update lpfc to revision 14.2.0.16

This patch set contains a user input range check correction, static
code analyzer fixes, refactoring of clean up code, and logging
enhancements.

The patches were cut against Martin's 6.7/scsi-queue tree.

Link: https://lore.kernel.org/r/20231031191224.150862-1-justintee8345@gmail.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 months agoMerge patch series "Replace deprecated strncpy() with strscpy()"
Martin K. Petersen [Wed, 15 Nov 2023 15:06:23 +0000 (10:06 -0500)]
Merge patch series "Replace deprecated strncpy() with strscpy()"

A series of patches from Justin Stitt.

Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 months agoMerge patch series "scsi: mpt3sas: Use flexible arrays and do a few cleanups"
Martin K. Petersen [Wed, 15 Nov 2023 15:04:03 +0000 (10:04 -0500)]
Merge patch series "scsi: mpt3sas: Use flexible arrays and do a few cleanups"

James Seo <james@equiv.tech> says:

Commit df8fc4e934c1 ("kbuild: Enable -fstrict-flex-arrays=3") has
resulted in the only arrays that UBSAN_BOUNDS considers unbounded
being trailing arrays declared with [] as the last member of a
struct. Unbounded trailing arrays declared with [1] are common in
mpt3sas, which is causing spurious warnings to appear in some
situations, e.g. when more than one physical disk is connected:

  UBSAN: array-index-out-of-bounds in drivers/scsi/mpt3sas/mpt3sas_scsih.c:6810:36
  index 1 is out of range for type 'MPI2_SAS_IO_UNIT0_PHY_DATA [1]'

which relates to this unbounded array access:

  port_id = sas_iounit_pg0->PhyData[i].Port;

and is just one example of 10 similar warnings currently occurring for
me during boot.

This series converts most trailing arrays declared with [1] in mptsas
into proper C99 flexible array members. Those that are not unbounded
and really are fixed-length arrays of length 1 are left alone.

I didn't find any conversions that required further source edits
besides changing [1] to [], and everything seems to work with my
SAS2008-based add-in card, but please look things over in case I
missed something subtle.

Rounding out the series are some opportunistic cleanups.

The only dependency is that patch 7 ("Use struct_size() for struct
size calculations") depends on patches 3-5.

Link: https://lore.kernel.org/r/20230806170604.16143-1-james@equiv.tech
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 months agoscsi: lpfc: Copyright updates for 14.2.0.16 patches
Justin Tee [Tue, 31 Oct 2023 19:12:24 +0000 (12:12 -0700)]
scsi: lpfc: Copyright updates for 14.2.0.16 patches

Update copyrights to 2023 for files modified in the 14.2.0.16 patch set.

Signed-off-by: Justin Tee <justin.tee@broadcom.com>
Link: https://lore.kernel.org/r/20231031191224.150862-10-justintee8345@gmail.com
Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 months agoscsi: lpfc: Update lpfc version to 14.2.0.16
Justin Tee [Tue, 31 Oct 2023 19:12:23 +0000 (12:12 -0700)]
scsi: lpfc: Update lpfc version to 14.2.0.16

Update lpfc version to 14.2.0.16.

Signed-off-by: Justin Tee <justin.tee@broadcom.com>
Link: https://lore.kernel.org/r/20231031191224.150862-9-justintee8345@gmail.com
Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 months agoscsi: lpfc: Enhance driver logging for selected discovery events
Justin Tee [Tue, 31 Oct 2023 19:12:22 +0000 (12:12 -0700)]
scsi: lpfc: Enhance driver logging for selected discovery events

Typically, debugging discovery issues requires the ndlp reference count,
nlp flags, transport flags, and the io tag for root cause analysis.

Modify important discovery log messages to include one or more of these
attributes to aid in debugging and support.

Signed-off-by: Justin Tee <justin.tee@broadcom.com>
Link: https://lore.kernel.org/r/20231031191224.150862-8-justintee8345@gmail.com
Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 months agoscsi: lpfc: Refactor and clean up mailbox command memory free
Justin Tee [Tue, 31 Oct 2023 19:12:21 +0000 (12:12 -0700)]
scsi: lpfc: Refactor and clean up mailbox command memory free

A lot of repeated clean up code exists when freeing mailbox commands in
lpfc_mem_free_all().

Introduce a lpfc_mem_free_sli_mbox() helper routine to refactor the
copy-paste code.  Additionally, reinitialize the mailbox command structure
context pointers to NULL in lpfc_sli4_mbox_cmd_free().

Signed-off-by: Justin Tee <justin.tee@broadcom.com>
Link: https://lore.kernel.org/r/20231031191224.150862-7-justintee8345@gmail.com
Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 months agoscsi: lpfc: Return early in lpfc_poll_eratt() when the driver is unloading
Justin Tee [Tue, 31 Oct 2023 19:12:20 +0000 (12:12 -0700)]
scsi: lpfc: Return early in lpfc_poll_eratt() when the driver is unloading

Add a check in lpfc_poll_eratt() when the driver is unloading.  There is no
point to check for error attention events if the driver is rmmod'ed.

If the driver is reloaded, as part of insmod initialization, then a fresh
reset is always asserted to start clean and free of error attention events.

Signed-off-by: Justin Tee <justin.tee@broadcom.com>
Link: https://lore.kernel.org/r/20231031191224.150862-6-justintee8345@gmail.com
Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 months agoscsi: lpfc: Eliminate unnecessary relocking in lpfc_check_nlp_post_devloss()
Justin Tee [Tue, 31 Oct 2023 19:12:19 +0000 (12:12 -0700)]
scsi: lpfc: Eliminate unnecessary relocking in lpfc_check_nlp_post_devloss()

In lpfc_check_nlp_post_devloss(), retaking of the ndlp lock in the if
statement is useless because the very next line unlocks. Simply return to
avoid relocking.

Signed-off-by: Justin Tee <justin.tee@broadcom.com>
Link: https://lore.kernel.org/r/20231031191224.150862-5-justintee8345@gmail.com
Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 months agoscsi: lpfc: Fix list_entry null check warning in lpfc_cmpl_els_plogi()
Justin Tee [Tue, 31 Oct 2023 19:12:18 +0000 (12:12 -0700)]
scsi: lpfc: Fix list_entry null check warning in lpfc_cmpl_els_plogi()

Smatch called out a warning for null checking a ptr that is assigned by
list_entry(). list_entry() does not return null and, if the list is empty,
can return an invalid ptr. Thus, the !psrp check does not execute properly.

 drivers/scsi/lpfc/lpfc_els.c:2133 lpfc_cmpl_els_plogi()
 warn: list_entry() does not return NULL 'prsp'

Replace list_entry() with list_get_first(), which does a list_empty() check
before returning the first entry.

Fixes: a3c3c0a806f1 ("scsi: lpfc: Validate ELS LS_ACC completion payload")
Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Closes: https://lore.kernel.org/linux-scsi/01b7568f-4ab4-4d56-bfa6-9ecc5fc261fe@moroto.mountain/
Signed-off-by: Justin Tee <justin.tee@broadcom.com>
Link: https://lore.kernel.org/r/20231031191224.150862-4-justintee8345@gmail.com
Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 months agoscsi: lpfc: Fix possible file string name overflow when updating firmware
Justin Tee [Tue, 31 Oct 2023 19:12:17 +0000 (12:12 -0700)]
scsi: lpfc: Fix possible file string name overflow when updating firmware

Because file_name and phba->ModelName are both declared a size 80 bytes,
the extra ".grp" file extension could cause an overflow into file_name.

Define a ELX_FW_NAME_SIZE macro with value 84.  84 incorporates the 4 extra
characters from ".grp".  file_name is changed to be declared as a char and
initialized to zeros i.e. null chars.

Signed-off-by: Justin Tee <justin.tee@broadcom.com>
Link: https://lore.kernel.org/r/20231031191224.150862-3-justintee8345@gmail.com
Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 months agoscsi: lpfc: Correct maximum PCI function value for RAS fw logging
Justin Tee [Tue, 31 Oct 2023 19:12:16 +0000 (12:12 -0700)]
scsi: lpfc: Correct maximum PCI function value for RAS fw logging

Currently, the ras_fwlog_func sysfs parameter allows users to input a value
greater than three when selecting a PCI function to enable RAS fw logging
feature.

The user's input is sanity checked in lpfc_sli4_ras_init(), but allowing an
input greater than three doesn't make sense because the max number of ports
per HBA is four.

Change the allowable range from [0, 7] to [0, 3].

Signed-off-by: Justin Tee <justin.tee@broadcom.com>
Link: https://lore.kernel.org/r/20231031191224.150862-2-justintee8345@gmail.com
Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 months agoscsi: elx: libefc: Replace deprecated strncpy() with strscpy_pad()/memcpy()
Justin Stitt [Thu, 26 Oct 2023 01:53:13 +0000 (01:53 +0000)]
scsi: elx: libefc: Replace deprecated strncpy() with strscpy_pad()/memcpy()

strncpy() is deprecated for use on NUL-terminated destination strings [1]
and as such we should prefer more robust and less ambiguous string
interfaces.

To keep node->current_state_name and node->prev_state_name NUL-padded and
NUL-terminated let's use strscpy_pad() as this implicitly provides both.

For the swap between the two, a simple memcpy() will suffice.

Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#strncpy-on-nul-terminated-strings
Link: https://manpages.debian.org/testing/linux-manual-4.8/strscpy.9.en.html
Link: https://github.com/KSPP/linux/issues/90
Cc: linux-hardening@vger.kernel.org
Signed-off-by: Justin Stitt <justinstitt@google.com>
Link: https://lore.kernel.org/r/20231026-strncpy-drivers-scsi-elx-libefc-efc_node-h-v2-1-5c083d0c13f4@google.com
Reviewed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 months agoscsi: csiostor: Replace deprecated strncpy() with strscpy()
Justin Stitt [Mon, 23 Oct 2023 20:26:13 +0000 (20:26 +0000)]
scsi: csiostor: Replace deprecated strncpy() with strscpy()

strncpy() is deprecated for use on NUL-terminated destination strings [1]
and as such we should prefer more robust and less ambiguous string
interfaces.

'hw' is kzalloc'd just before this string assignment:
|       hw = kzalloc(sizeof(struct csio_hw), GFP_KERNEL);

... which means any NUL-padding is redundant.

Since CSIO_DRV_VERSION is a small string literal (smaller than
sizeof(dest)):

... there is functionally no change in this swap from strncpy() to
strscpy(). Nonetheless, let's make the change for robustness' sake -- as
it will ensure that drv_version is _always_ NUL-terminated.

Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#strncpy-on-nul-terminated-strings
Link: https://github.com/KSPP/linux/issues/90
Cc: linux-hardening@vger.kernel.org
Signed-off-by: Justin Stitt <justinstitt@google.com>
Link: https://lore.kernel.org/r/20231023-strncpy-drivers-scsi-csiostor-csio_init-c-v1-1-5ea445b56864@google.com
Reviewed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 months agoscsi: ch: Replace deprecated strncpy() with strscpy()
Justin Stitt [Mon, 23 Oct 2023 20:20:14 +0000 (20:20 +0000)]
scsi: ch: Replace deprecated strncpy() with strscpy()

strncpy() is deprecated for use on NUL-terminated destination strings [1]
and as such we should prefer more robust and less ambiguous string
interfaces.

These labels get copied out to the user so lets make sure they are
NUL-terminated and NUL-padded.

vparams is already memset to 0 so we don't need to do any NUL-padding (like
what strncpy() is doing).

Considering the above, a suitable replacement is strscpy() [2] due to the
fact that it guarantees NUL-termination on the destination buffer without
unnecessarily NUL-padding.

Let's also opt to use the more idiomatic strscpy() usage of: (dest, src,
sizeof(dest)) as this more closely ties the destination buffer to the
length.

Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#strncpy-on-nul-terminated-strings
Link: https://manpages.debian.org/testing/linux-manual-4.8/strscpy.9.en.html
Link: https://github.com/KSPP/linux/issues/90
Cc: linux-hardening@vger.kernel.org
Signed-off-by: Justin Stitt <justinstitt@google.com>
Link: https://lore.kernel.org/r/20231023-strncpy-drivers-scsi-ch-c-v1-1-dc67ba8075a3@google.com
Reviewed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 months agoscsi: bnx2fc: Replace deprecated strncpy() with strscpy()
Justin Stitt [Mon, 23 Oct 2023 20:12:22 +0000 (20:12 +0000)]
scsi: bnx2fc: Replace deprecated strncpy() with strscpy()

strncpy() is deprecated for use on NUL-terminated destination strings [1]
and as such we should prefer more robust and less ambiguous string
interfaces.

We expect hba->chip_num to be NUL-terminated based on its usage with format
strings:

snprintf(fc_host_symbolic_name(lport->host), 256,
 "%s (QLogic %s) v%s over %s",
BNX2FC_NAME, hba->chip_num, BNX2FC_VERSION,
interface->netdev->name);

Moreover, NUL-padding is not required as hba is zero-allocated from its
callsite:

hba = kzalloc(sizeof(*hba), GFP_KERNEL);

Considering the above, a suitable replacement is strscpy() [2] due to the
fact that it guarantees NUL-termination on the destination buffer without
unnecessarily NUL-padding.

Regarding stats_addr->version, I've opted to also use strscpy() instead of
strscpy_pad() as I typically see these XYZ_get_strings() pass
zero-allocated data. I couldn't track all of where bnx2fc_ulp_get_stats()
is used and if required, we could opt for strscpy_pad().

Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#strncpy-on-nul-terminated-strings
Link: https://manpages.debian.org/testing/linux-manual-4.8/strscpy.9.en.html
Link: https://github.com/KSPP/linux/issues/90
Cc: linux-hardening@vger.kernel.org
Signed-off-by: Justin Stitt <justinstitt@google.com>
Link: https://lore.kernel.org/r/20231023-strncpy-drivers-scsi-bnx2fc-bnx2fc_fcoe-c-v1-1-a3736943cde2@google.com
Reviewed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 months agoscsi: 3w-sas: Replace deprecated strncpy() with strscpy()
Justin Stitt [Mon, 23 Oct 2023 19:50:57 +0000 (19:50 +0000)]
scsi: 3w-sas: Replace deprecated strncpy() with strscpy()

strncpy() is deprecated for use on NUL-terminated destination strings
[1] and as such we should prefer more robust and less ambiguous string
interfaces.

This pattern of strncpy(dest, src, strlen(src)) is extremely bug-prone.
This pattern basically never results in NUL-terminated destination
strings unless `dest` was zero-initialized. The current implementation
may be accidentally correct as tw_dev is zero-allocated via:

host = scsi_host_alloc(&driver_template, sizeof(TW_Device_Extension));
        ...
tw_dev = shost_priv(host);

... wherein scsi_host_alloc() zero-allocates host:

        shost = kzalloc(sizeof(struct Scsi_Host) + privsize, GFP_KERNEL);

Also, further suggesting this change is worthwhile is another strscpy()
usage in 3w-9xxx.c:

strscpy(tw_dev->tw_compat_info.driver_version, TW_DRIVER_VERSION,
sizeof(tw_dev->tw_compat_info.driver_version));

Considering the above, a suitable replacement is strscpy() [2] due to
the fact that it guarantees NUL-termination on the destination buffer
without unnecessarily NUL-padding.

Let's not be accidentally correct, let's be definitely correct.

Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#strncpy-on-nul-terminated-strings
Link: https://manpages.debian.org/testing/linux-manual-4.8/strscpy.9.en.html
Link: https://github.com/KSPP/linux/issues/90
Cc: linux-hardening@vger.kernel.org
Signed-off-by: Justin Stitt <justinstitt@google.com>
Link: https://lore.kernel.org/r/20231023-strncpy-drivers-scsi-3w-sas-c-v1-1-4c40a1e99dfc@google.com
Reviewed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 months agoscsi: mpt3sas: Replace dynamic allocations with local variables
James Seo [Sun, 6 Aug 2023 17:06:04 +0000 (10:06 -0700)]
scsi: mpt3sas: Replace dynamic allocations with local variables

mpt3sas_scsih.c:_scsih_scan_for_devices_after_reset() allocates and fetches
a MPI2_CONFIG_PAGE_RAID_VOL_0 struct (Mpi2RaidVolPage0_t) and a
MPI2_CONFIG_PAGE_RAID_VOL_1 struct (Mpi2RaidVolPage1_t), but does not
include the terminal flexible array members in the struct size
calculations, fetch those members, or otherwise use those members in any
way.

These dynamic allocations can be replaced with local variables.

Signed-off-by: James Seo <james@equiv.tech>
Link: https://lore.kernel.org/r/20230806170604.16143-13-james@equiv.tech
Tested-by: Borislav Petkov (AMD) <bp@alien8.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 months agoscsi: mpt3sas: Replace a dynamic allocation with a local variable
James Seo [Sun, 6 Aug 2023 17:06:03 +0000 (10:06 -0700)]
scsi: mpt3sas: Replace a dynamic allocation with a local variable

mpt3sas_base.c:_base_update_diag_trigger_pages() allocates and fetches a
MPI2_CONFIG_PAGE_SASIOUNIT_1 struct (Mpi2SasIOUnitPage_t), but does not
include the terminal flexible array member in the struct size calculation,
fetch that member, or otherwise use that member in any way.

This dynamic allocation can be replaced with a local variable.

Signed-off-by: James Seo <james@equiv.tech>
Link: https://lore.kernel.org/r/20230806170604.16143-12-james@equiv.tech
Tested-by: Borislav Petkov (AMD) <bp@alien8.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 months agoscsi: mpt3sas: Fix typo of "TRIGGER"
James Seo [Sun, 6 Aug 2023 17:06:02 +0000 (10:06 -0700)]
scsi: mpt3sas: Fix typo of "TRIGGER"

Change "TIGGER" to "TRIGGER" in struct names and typedefs.

Reviewed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: James Seo <james@equiv.tech>
Link: https://lore.kernel.org/r/20230806170604.16143-11-james@equiv.tech
Tested-by: Borislav Petkov (AMD) <bp@alien8.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 months agoscsi: mpt3sas: Fix an outdated comment
James Seo [Sun, 6 Aug 2023 17:06:01 +0000 (10:06 -0700)]
scsi: mpt3sas: Fix an outdated comment

May reduce confusion for users of MPI2_CONFIG_PAGE_IO_UNIT_3::GPIOVal[].

Fixes: a1c4d7741323 ("scsi: mpt3sas: Replace unnecessary dynamic allocation with a static one")
Reviewed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: James Seo <james@equiv.tech>
Link: https://lore.kernel.org/r/20230806170604.16143-10-james@equiv.tech
Tested-by: Borislav Petkov (AMD) <bp@alien8.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 months agoscsi: mpt3sas: Remove the iounit_pg8 member of the per-adapter struct
James Seo [Sun, 6 Aug 2023 17:06:00 +0000 (10:06 -0700)]
scsi: mpt3sas: Remove the iounit_pg8 member of the per-adapter struct

The per-adapter struct (struct MPT3SAS_ADAPTER) contains a
MPI2_CONFIG_PAGE_IO_UNIT_8 (Mpi2IOUnitPage8_t) iounit_pg8 member that is
populated by mpt3sas_base.c:_base_static_config_pages().

As the name of that function indicates, the iounit_pg8 member represents a
static configuration page data structure that rarely changes, and is among
several such static config pages that are currently being fetched once per
adapter per init (or reset) and copied to the per-adapter struct for later
use.

However, unlike the other static config pages, the iounit_pg8 member is
never actually used outside of _base_static_config_pages(). Also,
Mpi2IOUnitPage8_t has a flexible array member, making its presence in the
_middle_ of the per-adapter struct rather strange.

Remove this member from the per-adapter struct and fix up the portion of
_base_static_config_pages() that uses it.

Signed-off-by: James Seo <james@equiv.tech>
Link: https://lore.kernel.org/r/20230806170604.16143-9-james@equiv.tech
Tested-by: Borislav Petkov (AMD) <bp@alien8.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
7 months agoscsi: mpt3sas: Use struct_size() for struct size calculations
James Seo [Sun, 6 Aug 2023 17:05:59 +0000 (10:05 -0700)]
scsi: mpt3sas: Use struct_size() for struct size calculations

After converting terminal variable arrays into flexible array members, use
the bounds-checking struct_size() helper when possible to avoid open-coded
arithmetic struct size calculations.

Signed-off-by: James Seo <james@equiv.tech>
Link: https://lore.kernel.org/r/20230806170604.16143-8-james@equiv.tech
Tested-by: Borislav Petkov (AMD) <bp@alien8.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>