linux-2.6-microblaze.git
3 years agoscsi: cxgb4i: Fix TLS dependency
Randy Dunlap [Tue, 8 Dec 2020 22:05:05 +0000 (14:05 -0800)]
scsi: cxgb4i: Fix TLS dependency

SCSI_CXGB4_ISCSI selects CHELSIO_T4. The latter depends on TLS || TLS=n, so
since 'select' does not check dependencies of the selected symbol,
SCSI_CXGB4_ISCSI should also depend on TLS || TLS=n.

This prevents the following kconfig warning and restricts SCSI_CXGB4_ISCSI
to 'm' whenever TLS=m.

WARNING: unmet direct dependencies detected for CHELSIO_T4
  Depends on [m]: NETDEVICES [=y] && ETHERNET [=y] && NET_VENDOR_CHELSIO [=y] && PCI [=y] && (IPV6 [=y] || IPV6 [=y]=n) && (TLS [=m] || TLS [=m]=n)
  Selected by [y]:
  - SCSI_CXGB4_ISCSI [=y] && SCSI_LOWLEVEL [=y] && SCSI [=y] && PCI [=y] && INET [=y] && (IPV6 [=y] || IPV6 [=y]=n) && ETHERNET [=y]

Link: https://lore.kernel.org/r/20201208220505.24488-1-rdunlap@infradead.org
Fixes: 7b36b6e03b0d ("[SCSI] cxgb4i v5: iscsi driver")
Cc: Karen Xie <kxie@chelsio.com>
Cc: linux-scsi@vger.kernel.org
Cc: "James E.J. Bottomley" <jejb@linux.ibm.com>
Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: ufs: Un-inline ufshcd_vops_device_reset function
Stanley Chu [Tue, 8 Dec 2020 13:56:35 +0000 (21:56 +0800)]
scsi: ufs: Un-inline ufshcd_vops_device_reset function

More and more statements are being added to ufshcd_vops_device_reset() and
this function is being called from multiple locations in the driver.
Un-inline the function to allow the compiler to make better decisions.

Link: https://lore.kernel.org/r/20201208135635.15326-3-stanley.chu@mediatek.com
Reviewed-by: Bean Huo <beanhuo@micron.com>
Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: ufs: Re-enable WriteBooster after device reset
Stanley Chu [Tue, 8 Dec 2020 13:56:34 +0000 (21:56 +0800)]
scsi: ufs: Re-enable WriteBooster after device reset

UFS 3.1 specification mentions that the WriteBooster flags listed below
will be set to their default values, i.e. disabled, after power cycle or
any type of reset event. Thus we need to reset the flag variables kept in
struct hba to align with the device status and ensure that
WriteBooster-related functions are configured properly after device reset.

Without this fix, WriteBooster will not be enabled successfully after by
ufshcd_wb_ctrl() after device reset because hba->wb_enabled remains true.

Flags required to be reset to default values:

 - fWriteBoosterEn: hba->wb_enabled

 - fWriteBoosterBufferFlushEn: hba->wb_buf_flush_enabled

 - fWriteBoosterBufferFlushDuringHibernate: No variable mapped

Link: https://lore.kernel.org/r/20201208135635.15326-2-stanley.chu@mediatek.com
Fixes: 3d17b9b5ab11 ("scsi: ufs: Add write booster feature support")
Reviewed-by: Bean Huo <beanhuo@micron.com>
Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: ufs-mediatek: Use correct path to fix compile error
Zhen Lei [Wed, 9 Dec 2020 06:31:44 +0000 (14:31 +0800)]
scsi: ufs-mediatek: Use correct path to fix compile error

When the kernel is compiled with allmodconfig, the following error is
reported:

In file included from drivers/scsi/ufs/ufs-mediatek-trace.h:36:0,
                 from drivers/scsi/ufs/ufs-mediatek.c:28:
./include/trace/define_trace.h:95:42: fatal error: ./ufs-mediatek-trace.h: No such file or directory
 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)

The comment in include/trace/define_trace.h specifies that:
TRACE_INCLUDE_PATH: Note, the path is relative to define_trace.h, not the
file including it. Full path names for out of tree modules must be used.

So without "CFLAGS_ufs-mediatek.o := -I$(src)", the current directory "."
is "include/trace/", the relative path of ufs-mediatek-trace.h is
"../../drivers/scsi/ufs/".

Link: https://lore.kernel.org/r/20201209063144.1840-2-thunder.leizhen@huawei.com
Fixes: ca1bb061d644 ("scsi: ufs-mediatek: Introduce event_notify implementation")
Reviewed-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: mpt3sas: Signedness bug in _base_get_diag_triggers()
Dan Carpenter [Wed, 9 Dec 2020 14:03:11 +0000 (17:03 +0300)]
scsi: mpt3sas: Signedness bug in _base_get_diag_triggers()

The "trigger_flags" variable needs to be signed for the error checking to
work.

Link: https://lore.kernel.org/r/X9DZH37bYPHwSQRP@mwanda
Fixes: aec93e8e2385 ("scsi: mpt3sas: Add persistent trigger pages support")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: block: Do not accept any requests while suspended
Alan Stern [Wed, 9 Dec 2020 05:29:51 +0000 (21:29 -0800)]
scsi: block: Do not accept any requests while suspended

blk_queue_enter() accepts BLK_MQ_REQ_PM requests independent of the runtime
power management state. Now that SCSI domain validation no longer depends
on this behavior, modify the behavior of blk_queue_enter() as follows:

   - Do not accept any requests while suspended.

   - Only process power management requests while suspending or resuming.

Submitting BLK_MQ_REQ_PM requests to a device that is runtime suspended
causes runtime-suspended devices not to resume as they should. The request
which should cause a runtime resume instead gets issued directly, without
resuming the device first. Of course the device can't handle it properly,
the I/O fails, and the device remains suspended.

The problem is fixed by checking that the queue's runtime-PM status isn't
RPM_SUSPENDED before allowing a request to be issued, and queuing a
runtime-resume request if it is.  In particular, the inline
blk_pm_request_resume() routine is renamed blk_pm_resume_queue() and the
code is unified by merging the surrounding checks into the routine.  If the
queue isn't set up for runtime PM, or there currently is no restriction on
allowed requests, the request is allowed.  Likewise if the BLK_MQ_REQ_PM
flag is set and the status isn't RPM_SUSPENDED.  Otherwise a runtime resume
is queued and the request is blocked until conditions are more suitable.

[ bvanassche: modified commit message and removed Cc: stable because
  without the previous patches from this series this patch would break
  parallel SCSI domain validation + introduced queue_rpm_status() ]

Link: https://lore.kernel.org/r/20201209052951.16136-9-bvanassche@acm.org
Cc: Jens Axboe <axboe@kernel.dk>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Hannes Reinecke <hare@suse.de>
Cc: Can Guo <cang@codeaurora.org>
Cc: Stanley Chu <stanley.chu@mediatek.com>
Cc: Ming Lei <ming.lei@redhat.com>
Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Reported-and-tested-by: Martin Kepplinger <martin.kepplinger@puri.sm>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Can Guo <cang@codeaurora.org>
Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: block: Remove RQF_PREEMPT and BLK_MQ_REQ_PREEMPT
Bart Van Assche [Wed, 9 Dec 2020 05:29:50 +0000 (21:29 -0800)]
scsi: block: Remove RQF_PREEMPT and BLK_MQ_REQ_PREEMPT

Remove flag RQF_PREEMPT and BLK_MQ_REQ_PREEMPT since these are no longer
used by any kernel code.

Link: https://lore.kernel.org/r/20201209052951.16136-8-bvanassche@acm.org
Cc: Can Guo <cang@codeaurora.org>
Cc: Stanley Chu <stanley.chu@mediatek.com>
Cc: Alan Stern <stern@rowland.harvard.edu>
Cc: Ming Lei <ming.lei@redhat.com>
Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Cc: Martin Kepplinger <martin.kepplinger@puri.sm>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Jens Axboe <axboe@kernel.dk>
Reviewed-by: Can Guo <cang@codeaurora.org>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: core: Only process PM requests if rpm_status != RPM_ACTIVE
Bart Van Assche [Wed, 9 Dec 2020 05:29:49 +0000 (21:29 -0800)]
scsi: core: Only process PM requests if rpm_status != RPM_ACTIVE

Instead of submitting all SCSI commands submitted with scsi_execute() to a
SCSI device if rpm_status != RPM_ACTIVE, only submit RQF_PM (power
management requests) if rpm_status != RPM_ACTIVE. This patch makes the SCSI
core handle the runtime power management status (rpm_status) as it should
be handled.

Link: https://lore.kernel.org/r/20201209052951.16136-7-bvanassche@acm.org
Cc: Can Guo <cang@codeaurora.org>
Cc: Stanley Chu <stanley.chu@mediatek.com>
Cc: Alan Stern <stern@rowland.harvard.edu>
Cc: Ming Lei <ming.lei@redhat.com>
Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Cc: Martin Kepplinger <martin.kepplinger@puri.sm>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Jens Axboe <axboe@kernel.dk>
Reviewed-by: Can Guo <cang@codeaurora.org>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: scsi_transport_spi: Set RQF_PM for domain validation commands
Bart Van Assche [Wed, 9 Dec 2020 05:29:48 +0000 (21:29 -0800)]
scsi: scsi_transport_spi: Set RQF_PM for domain validation commands

Disable runtime power management during domain validation. Since a later
patch removes RQF_PREEMPT, set RQF_PM for domain validation commands such
that these are executed in the quiesced SCSI device state.

Link: https://lore.kernel.org/r/20201209052951.16136-6-bvanassche@acm.org
Cc: Alan Stern <stern@rowland.harvard.edu>
Cc: James Bottomley <James.Bottomley@HansenPartnership.com>
Cc: Woody Suwalski <terraluna977@gmail.com>
Cc: Can Guo <cang@codeaurora.org>
Cc: Stanley Chu <stanley.chu@mediatek.com>
Cc: Ming Lei <ming.lei@redhat.com>
Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Cc: Stan Johnson <userm57@yahoo.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Jens Axboe <axboe@kernel.dk>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: ide: Mark power management requests with RQF_PM instead of RQF_PREEMPT
Bart Van Assche [Wed, 9 Dec 2020 05:29:47 +0000 (21:29 -0800)]
scsi: ide: Mark power management requests with RQF_PM instead of RQF_PREEMPT

This is another step that prepares for the removal of RQF_PREEMPT.

Link: https://lore.kernel.org/r/20201209052951.16136-5-bvanassche@acm.org
Cc: David S. Miller <davem@davemloft.net>
Cc: Alan Stern <stern@rowland.harvard.edu>
Cc: Can Guo <cang@codeaurora.org>
Cc: Stanley Chu <stanley.chu@mediatek.com>
Cc: Ming Lei <ming.lei@redhat.com>
Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: ide: Do not set the RQF_PREEMPT flag for sense requests
Bart Van Assche [Wed, 9 Dec 2020 05:29:46 +0000 (21:29 -0800)]
scsi: ide: Do not set the RQF_PREEMPT flag for sense requests

RQF_PREEMPT is used for two different purposes in the legacy IDE code:

 1. To mark power management requests.

 2. To mark requests that should preempt another request. An (old)
    explanation of that feature is as follows: "The IDE driver in the Linux
    kernel normally uses a series of busywait delays during its
    initialization. When the driver executes these busywaits, the kernel
    does nothing for the duration of the wait. The time spent in these
    waits could be used for other initialization activities, if they could
    be run concurrently with these waits.

    More specifically, busywait-style delays such as udelay() in module
    init functions inhibit kernel preemption because the Big Kernel Lock is
    held, while yielding APIs such as schedule_timeout() allow
    preemption. This is true because the kernel handles the BKL specially
    and releases and reacquires it across reschedules allowed by the
    current thread.

    This IDE-preempt specification requires that the driver eliminate these
    busywaits and replace them with a mechanism that allows other work to
    proceed while the IDE driver is initializing."

Since I haven't found an implementation of (2), do not set the PREEMPT flag
for sense requests. This patch causes sense requests to be postponed while
a drive is suspended instead of being submitted to ide_queue_rq().

If it would ever be necessary to restore the IDE PREEMPT functionality,
that can be done by introducing a new flag in struct ide_request.

Link: https://lore.kernel.org/r/20201209052951.16136-4-bvanassche@acm.org
Cc: David S. Miller <davem@davemloft.net>
Cc: Alan Stern <stern@rowland.harvard.edu>
Cc: Can Guo <cang@codeaurora.org>
Cc: Stanley Chu <stanley.chu@mediatek.com>
Cc: Ming Lei <ming.lei@redhat.com>
Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: block: Introduce BLK_MQ_REQ_PM
Bart Van Assche [Wed, 9 Dec 2020 05:29:45 +0000 (21:29 -0800)]
scsi: block: Introduce BLK_MQ_REQ_PM

Introduce the BLK_MQ_REQ_PM flag. This flag makes the request allocation
functions set RQF_PM. This is the first step towards removing
BLK_MQ_REQ_PREEMPT.

Link: https://lore.kernel.org/r/20201209052951.16136-3-bvanassche@acm.org
Cc: Alan Stern <stern@rowland.harvard.edu>
Cc: Stanley Chu <stanley.chu@mediatek.com>
Cc: Ming Lei <ming.lei@redhat.com>
Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Cc: Can Guo <cang@codeaurora.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Jens Axboe <axboe@kernel.dk>
Reviewed-by: Can Guo <cang@codeaurora.org>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: block: Fix a race in the runtime power management code
Bart Van Assche [Wed, 9 Dec 2020 05:29:44 +0000 (21:29 -0800)]
scsi: block: Fix a race in the runtime power management code

With the current implementation the following race can happen:

 * blk_pre_runtime_suspend() calls blk_freeze_queue_start() and
   blk_mq_unfreeze_queue().

 * blk_queue_enter() calls blk_queue_pm_only() and that function returns
   true.

 * blk_queue_enter() calls blk_pm_request_resume() and that function does
   not call pm_request_resume() because the queue runtime status is
   RPM_ACTIVE.

 * blk_pre_runtime_suspend() changes the queue status into RPM_SUSPENDING.

Fix this race by changing the queue runtime status into RPM_SUSPENDING
before switching q_usage_counter to atomic mode.

Link: https://lore.kernel.org/r/20201209052951.16136-2-bvanassche@acm.org
Fixes: 986d413b7c15 ("blk-mq: Enable support for runtime power management")
Cc: Ming Lei <ming.lei@redhat.com>
Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Cc: stable <stable@vger.kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Jens Axboe <axboe@kernel.dk>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Acked-by: Stanley Chu <stanley.chu@mediatek.com>
Co-developed-by: Can Guo <cang@codeaurora.org>
Signed-off-by: Can Guo <cang@codeaurora.org>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: ufs-pci: Enable UFSHCD_CAP_RPM_AUTOSUSPEND for Intel controllers
Adrian Hunter [Mon, 7 Dec 2020 08:31:20 +0000 (10:31 +0200)]
scsi: ufs-pci: Enable UFSHCD_CAP_RPM_AUTOSUSPEND for Intel controllers

Enable runtime PM auto-suspend by default for Intel host controllers.

Link: https://lore.kernel.org/r/20201207083120.26732-5-adrian.hunter@intel.com
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: ufs-pci: Fix recovery from hibernate exit errors for Intel controllers
Adrian Hunter [Mon, 7 Dec 2020 08:31:19 +0000 (10:31 +0200)]
scsi: ufs-pci: Fix recovery from hibernate exit errors for Intel controllers

Intel controllers can end up in an unrecoverable state after a hibernate
exit error unless a full reset and restore is done before anything else.
Force that to happen.

Link: https://lore.kernel.org/r/20201207083120.26732-4-adrian.hunter@intel.com
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: ufs-pci: Ensure UFS device is in PowerDown mode for suspend-to-disk ->poweroff()
Adrian Hunter [Mon, 7 Dec 2020 08:31:18 +0000 (10:31 +0200)]
scsi: ufs-pci: Ensure UFS device is in PowerDown mode for suspend-to-disk ->poweroff()

The expectation for suspend-to-disk is that devices will be powered-off, so
the UFS device should be put in PowerDown mode. If spm_lvl is not 5, then
that will not happen. Change the pm callbacks to force spm_lvl 5 for
suspend-to-disk poweroff.

Link: https://lore.kernel.org/r/20201207083120.26732-3-adrian.hunter@intel.com
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: ufs-pci: Fix restore from S4 for Intel controllers
Adrian Hunter [Mon, 7 Dec 2020 08:31:17 +0000 (10:31 +0200)]
scsi: ufs-pci: Fix restore from S4 for Intel controllers

Currently, ufshcd-pci is the only UFS driver with support for
suspend-to-disk PM callbacks (i.e. freeze/thaw/restore/poweroff). These
callbacks are set by the macro SET_SYSTEM_SLEEP_PM_OPS to the same
functions as system suspend/resume. That will work with spm_lvl 5 because
spm_lvl 5 will result in a full restore for the ->restore() callback.  In
the absence of a full restore, the host controller registers will have
values set up by the restore kernel (the kernel that boots and loads the
restore image) which are not necessarily the same. However it turns out,
the only registers that sometimes need restore are the base address
registers. This has gone un-noticed because, depending on IOMMU settings,
the kernel can end up allocating the same addresses every time.

For Intel controllers, an spm_lvl other than 5 can be used, so to support
S4 (suspend-to-disk) with spm_lvl other than 5, restore the base address
registers.

Link: https://lore.kernel.org/r/20201207083120.26732-2-adrian.hunter@intel.com
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: ufs-mediatek: Keep VCC always-on for specific devices
Stanley Chu [Mon, 7 Dec 2020 05:49:55 +0000 (13:49 +0800)]
scsi: ufs-mediatek: Keep VCC always-on for specific devices

For some devices which need extra delay after VCC power down, VCC shall be
kept always-on in some MediaTek UFS platforms to ensure the stability of
such devices because the extra delay may not be enough in those platforms.

Link: https://lore.kernel.org/r/20201207054955.24366-3-stanley.chu@mediatek.com
Reviewed-by: Andy Teng <andy.teng@mediatek.com>
Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: ufs: Allow regulators being always-on
Stanley Chu [Mon, 7 Dec 2020 05:49:54 +0000 (13:49 +0800)]
scsi: ufs: Allow regulators being always-on

Introduce a flag "always_on" in struct ufs_vreg to allow vendors to keep
the regulator always-on.

Link: https://lore.kernel.org/r/20201207054955.24366-2-stanley.chu@mediatek.com
Reviewed-by: Andy Teng <andy.teng@mediatek.com>
Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: ufs: Clear UAC for RPMB after ufshcd resets
Randall Huang [Tue, 1 Dec 2020 04:14:02 +0000 (20:14 -0800)]
scsi: ufs: Clear UAC for RPMB after ufshcd resets

If RPMB is not provisioned, we may see RPMB failure after UFS
suspend/resume.  Inject request_sense to clear uac in ufshcd reset flow.

Link: https://lore.kernel.org/r/20201201041402.3860525-1-jaegeuk@kernel.org
Reported-by: kernel test robot <lkp@intel.com>
Reviewed-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Randall Huang <huangrandall@google.com>
Signed-off-by: Leo Liou <leoliou@google.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@google.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: ufs: Fix wrong print message in dev_err()
Bean Huo [Mon, 7 Dec 2020 19:01:37 +0000 (20:01 +0100)]
scsi: ufs: Fix wrong print message in dev_err()

Change dev_err() print message from "dme-reset" to "dme_enable" in function
ufshcd_dme_enable().

Link: https://lore.kernel.org/r/20201207190137.6858-3-huobean@gmail.com
Acked-by: Alim Akhtar <alim.akhtar@samsung.com>
Acked-by: Avri Altman <avri.altman@wdc.com>
Signed-off-by: Bean Huo <beanhuo@micron.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: ufs: Remove unused macro definition POWER_DESC_MAX_SIZE
Bean Huo [Mon, 7 Dec 2020 19:01:36 +0000 (20:01 +0100)]
scsi: ufs: Remove unused macro definition POWER_DESC_MAX_SIZE

POWER_DESC_MAX_SIZE is unused, remove it.

Link: https://lore.kernel.org/r/20201207190137.6858-2-huobean@gmail.com
Acked-by: Avri Altman <avri.altman@wdc.com>
Acked-by: Alim Akhtar <alim.akhtar@samsung.com>
Signed-off-by: Bean Huo <beanhuo@micron.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: mpt3sas: Update driver version to 36.100.00.00
Suganath Prabu S [Thu, 26 Nov 2020 09:43:11 +0000 (15:13 +0530)]
scsi: mpt3sas: Update driver version to 36.100.00.00

Update driver version to 36.100.00.00

Link: https://lore.kernel.org/r/20201126094311.8686-9-suganath-prabu.subramani@broadcom.com
Signed-off-by: Suganath Prabu S <suganath-prabu.subramani@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: mpt3sas: Handle trigger page after firmware update
Suganath Prabu S [Thu, 26 Nov 2020 09:43:10 +0000 (15:13 +0530)]
scsi: mpt3sas: Handle trigger page after firmware update

If a firmware update adds support for the trigger pages, then the driver
should handle this by writing the existing trigger data from the driver's
internal data structure to the corresponding trigger pages in NVRAM.

Also handle the case where the trigger page capability is no longer present
after a firmware downgrade.

Link: https://lore.kernel.org/r/20201126094311.8686-8-suganath-prabu.subramani@broadcom.com
Signed-off-by: Suganath Prabu S <suganath-prabu.subramani@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: mpt3sas: Add persistent MPI trigger page
Suganath Prabu S [Thu, 26 Nov 2020 09:43:09 +0000 (15:13 +0530)]
scsi: mpt3sas: Add persistent MPI trigger page

This page is used to store information about MPI (IOC Status & LogInfo)
triggers.

 Driver Persistent Trigger Page-4 format:
 -------------------------------------------------------
 | 31       24 23           16 15         8 7          0|  Byte
 -------------------------------------------------------
 | PageType   | PageNumber    | Reserved  | PageVersion |  0x00
 --------------------------------------------------------
 | Reserved   | ExtPageType   |      ExtPageLength      |  0x04
 --------------------------------------------------------
 |          Reserved          | NumMpiTriggerEntries    |  0x08
 --------------------------------------------------------
 |             MPITriggerEntry[0]                       |  0x0C
 --------------------------------------------------------
 |               …                                      |
 --------------------------------------------------------
 |            MPITriggerEntry[19]                       |  0xA4
 --------------------------------------------------------

NumMpiTriggerEntries:

This field indicates number of MPI (IOC Status & LogInfo) trigger entries
stored in this page. Currently driver is supporting a maximum of 20-MPI
trigger entries.

MPITriggerEntry:

 -----------------------------------------------------
 | 31                    16 15                     0 |
 -----------------------------------------------------
 |        Reserved         |      IOCStatus          |
 -----------------------------------------------------
 |                   IOCLogInfo                      |
 -----------------------------------------------------

IOCStatus  => Status value from the IOC
IOCLogInfo => Specific value that supplements the IOCStatus.

Link: https://lore.kernel.org/r/20201126094311.8686-7-suganath-prabu.subramani@broadcom.com
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Suganath Prabu S <suganath-prabu.subramani@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: mpt3sas: Add persistent SCSI sense trigger page
Suganath Prabu S [Thu, 26 Nov 2020 09:43:08 +0000 (15:13 +0530)]
scsi: mpt3sas: Add persistent SCSI sense trigger page

Trigger Page3 is used to store information about SCSI Sense triggers:

 Persistent Trigger Page-3
 ------------------------------------------------------------------
 | 31         24 23            16 15              8 7            0|    Byte
 ------------------------------------------------------------------
 | PageType      | PageNumber     | Reserved       | PageVersion  |    0x00
 ------------------------------------------------------------------
 | Reserved      | ExtPageType    |          ExtPageLen           |    0x04
 ------------------------------------------------------------------
 | Reserved      | NumScsiSense   |         TriggerEntries        |    0x08
 ------------------------------------------------------------------
 |               ScsiSenseTriggerEntry[0]                         |    0x0C
 ------------------------------------------------------------------
 |                    …        …                                  |
 ------------------------------------------------------------------
 |               ScsiSenseTriggerEntry[19]                        |    0x58
 ------------------------------------------------------------------

NumScsiSenseTriggerEntries:

This field indicates number of SCSI Sense trigger entries stored in this
page. Currently driver is supporting a maximum of 20-SCSI Sense trigger
entries.

ScsiSenseTriggerEntry:

 -----------------------------------------------
 | 31      24 23       16 15       8 7       0 |
 -----------------------------------------------
 | Reserved   | SenseKey  |    ASC   |   ASCQ  |
 -----------------------------------------------

 ASCQ     => Additional Sense Code Qualifier
 ASC      => Additional Sense Code
 SenseKey => Sense Key values

 ASCQ     => Additional Sense Code Qualifier
 ASC      => Additional Sense Code
 SenseKey => Sense Key values

Link: https://lore.kernel.org/r/20201126094311.8686-6-suganath-prabu.subramani@broadcom.com
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Suganath Prabu S <suganath-prabu.subramani@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: mpt3sas: Add persistent Event trigger page
Suganath Prabu S [Thu, 26 Nov 2020 09:43:07 +0000 (15:13 +0530)]
scsi: mpt3sas: Add persistent Event trigger page

Trigger Page2 is used to store information about Event triggers:

  31     24 23        16 15      8 7         0   Byte
 -----------------------------------------------
 |PageType  |PageNumber  |Reserved |PageVersion| 0x00
 -----------------------------------------------
 |Reserved  |ExtPageType |   ExtPageLength     | 0x04
 -----------------------------------------------
 |     Reserved          | NumMPIEventTriggers | 0x08
 -----------------------------------------------
 |                 MPIEventTriggerEntries      | 0x0C
 |                                             | 0xFC
 -----------------------------------------------

Number of MPI Event Trigger Entries currently stored in this page.  If this
is set to zero, there are no valid MPI-Event-Trigger entries available in
this page.

MPIEventTriggerEntry:

 - MPIEventCode [15:00]
   MPI Event code specified in MPI-Spec

 - MPIEventCodeSpecific [16:31]
   For Event Code “MPI2_EVENT_LOG_ENTRY_ADDED (0x0021)”,
   this field specifies the Log-Entry-Qualifier.
   For all other Event Codes, this field is reserved and not used

Maximum of 20-event trigger entries can be stored in this page.

Link: https://lore.kernel.org/r/20201126094311.8686-5-suganath-prabu.subramani@broadcom.com
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Suganath Prabu S <suganath-prabu.subramani@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: mpt3sas: Add persistent Master trigger page
Suganath Prabu S [Thu, 26 Nov 2020 09:43:06 +0000 (15:13 +0530)]
scsi: mpt3sas: Add persistent Master trigger page

Trigger Page 1 is used to store information about Master triggers.  Below
are the Master trigger conditions:

  Bit[3]  Trigger condition for Device Removal event
  Bit[2]  Trigger condition for TM command issued by driver
  Bit[1]  Trigger condition for Adapter reset issued by driver
  Bit[0]  Trigger condition for IOC Fault state

During driver load, if Master trigger type bit is enabled in the Persistent
Trigger Page0, then read the Persistent Trigger Page1 and update the IOC
instance's diag_trigger_master.MasterData with Persistent Trigger Page1's
MasterTriggerFlags.

Link: https://lore.kernel.org/r/20201126094311.8686-4-suganath-prabu.subramani@broadcom.com
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Suganath Prabu S <suganath-prabu.subramani@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: mpt3sas: Add persistent trigger pages support
Suganath Prabu S [Thu, 26 Nov 2020 09:43:05 +0000 (15:13 +0530)]
scsi: mpt3sas: Add persistent trigger pages support

The user can set trigger values in order to collect the IOC's host trace
buffer automatically upon detecting certain conditions. However, the
trigger values that the user sets are not persistent across system reboot
or reload of the driver.

In order to make the user trigger settings persistent, these trigger values
need to be saved in the IOC's NVRAM pages:

 - Driver Persistent Trigger Page 0:
     This page is used to store list of trigger types that are enabled

 - Driver Persistent Trigger Page 1:
     This page stores the list of Master triggers that are enabled

 - Driver Persistent Trigger Page 2:
     This page stores the list of MPI Event Triggers that are enabled

 - Driver Persistent Trigger Page 3:
     This page stores the list of SCSI Sense Triggers that are enabled

 - Driver Persistent Trigger Page 4:
     This page stores the list of IOCStatus-LogInfo Triggers that are
     enabled.

Whenever user configures triggers, the driver persists the values in the
corresponding trigger pages. When the driver is subsequently reloaded, the
driver reads the values from the trigger pages and configures the triggers
accordingly.

During firmware upload operation, if the newer firmware supports the
trigger page feature, then driver persists the configured diag trigger
values to NVRAM.

Link: https://lore.kernel.org/r/20201126094311.8686-3-suganath-prabu.subramani@broadcom.com
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Suganath Prabu S <suganath-prabu.subramani@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: mpt3sas: Sync time periodically between driver and firmware
Suganath Prabu S [Thu, 26 Nov 2020 09:43:04 +0000 (15:13 +0530)]
scsi: mpt3sas: Sync time periodically between driver and firmware

The controller time currently gets updated with host time during driver
load or when a controller reset is issued. I.e. when host issues the
IOCInit request message to the HBA firmware. This IOCInit message has a
field named 'TimeStamp' with which the host updates the controller time.

Sometimes controller time drifts with respect to the host and it is
difficult to correlate host logs with controller logs. Issuing a controller
reset to sync the time would impact in-flight I/O and is not a viable
option.

Instead the driver now sends an IO_UNIT_CONTROL Request to sync the time
periodically. This is done from the watchdog thread which gets invoked
every second.

The time synchronization interval is specified in the 'TimeSyncInterval'
field in Manufacturing Page11 by the controller:

    TimeSyncInterval - 8 bits
bits  0-6: Time stamp Synchronization interval value
bit 7: Time stamp Synchronization interval unit,
   (if this bit is one then Timestamp Synchronization
   interval value is specified in terms of hours else
   Timestamp Synchronization interval value is
   specified in terms of minutes).

The driver keeps track of the timer using IOC's timestamp_update_count
field. This field value gets incremented whenever the watchdog thread gets
invoked. And whenever this field value is greater than or equal to the Time
Stamp Synchronization interval value, the driver sends the IO_UNIT_CONTROL
Request message to controller to update the time and then it resets the
timestamp_update_count field to zero.

Link: https://lore.kernel.org/r/20201126094311.8686-2-suganath-prabu.subramani@broadcom.com
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Suganath Prabu S <suganath-prabu.subramani@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: qla2xxx: Update version to 10.02.00.104-k
Nilesh Javali [Wed, 2 Dec 2020 13:23:12 +0000 (05:23 -0800)]
scsi: qla2xxx: Update version to 10.02.00.104-k

Link: https://lore.kernel.org/r/20201202132312.19966-16-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>
3 years agoscsi: qla2xxx: Fix device loss on 4G and older HBAs
Arun Easi [Wed, 2 Dec 2020 13:23:11 +0000 (05:23 -0800)]
scsi: qla2xxx: Fix device loss on 4G and older HBAs

Due to a bug in the older scan logic, when a once lost device re-appeared,
it was not discovered. Fix this by resetting login_retry counter upon
device discovery.

This is applicable only for 4G and older HBAs.

Link: https://lore.kernel.org/r/20201202132312.19966-15-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>
3 years agoscsi: qla2xxx: If fcport is undergoing deletion complete I/O with retry
Saurav Kashyap [Wed, 2 Dec 2020 13:23:10 +0000 (05:23 -0800)]
scsi: qla2xxx: If fcport is undergoing deletion complete I/O with retry

Driver unload with I/Os in flight causes server to crash.  Complete I/O
with DID_IMM_RETRY if fcport undergoing deletion.

CPU: 44 PID: 35008 Comm: qla2xxx_4_dpc Kdump: loaded Tainted: G
OE  X   5.3.18-22-default #1 SLE15-SP2 (unreleased)
Hardware name: HPE ProLiant DL380 Gen10/ProLiant DL380 Gen10, BIOS U30 07/16/2020
RIP: 0010:dma_direct_unmap_sg+0x24/0x60
Code: 4c 8b 04 24 eb b9 0f 1f 44 00 00 85 d2 7e 4e 41 57
      4d 89 c7 41 56 41 89 ce 41 55 49 89 fd 41 54 41 89 d4 55 31 ed 53 48 89
      f3 <8b> 53 18 48 8b 73 10 4d 89 f8 44 89 f1 4c 89 ef 83 c5 01 e8 44 ff
RSP: 0018:ffffc0c661037d88 EFLAGS: 00010046
RAX: 0000000000000000 RBX: 0000000000000000 RCX: 0000000000000002
RDX: 000000000000001d RSI: 0000000000000000 RDI: ffff9a51ee53b0b0
RBP: 0000000000000000 R08: 0000000000000000 R09: ffff9a51ee53b0b0
R10: ffffc0c646463dc8 R11: ffff9a4a067087c8 R12: 000000000000001d
R13: ffff9a51ee53b0b0 R14: 0000000000000002 R15: 0000000000000000
FS:  0000000000000000(0000) GS:ffff9a523f800000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000000000000018 CR3: 000000043740a004 CR4: 00000000007606e0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
PKRU: 55555554
Call Trace:
qla2xxx_qpair_sp_free_dma+0x20d/0x3c0 [qla2xxx]
qla2xxx_qpair_sp_compl+0x35/0x90 [qla2xxx]
__qla2x00_abort_all_cmds+0x180/0x390 [qla2xxx]
? qla24xx_process_purex_list+0x100/0x100 [qla2xxx]
qla2x00_abort_all_cmds+0x5e/0x80 [qla2xxx]
qla2x00_do_dpc+0x317/0xa30 [qla2xxx]
kthread+0x10d/0x130
? kthread_park+0xa0/0xa0
ret_from_fork+0x35/0x40

Link: https://lore.kernel.org/r/20201202132312.19966-14-njavali@marvell.com
Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
Signed-off-by: Saurav Kashyap <skashyap@marvell.com>
Signed-off-by: Nilesh Javali <njavali@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: qla2xxx: Fix the call trace for flush workqueue
Saurav Kashyap [Wed, 2 Dec 2020 13:23:09 +0000 (05:23 -0800)]
scsi: qla2xxx: Fix the call trace for flush workqueue

The call trace was because workqueue was allocated without any flags, added
WQ_MEM_RECLAIM as flag when allocating.

kernel: workqueue: WQ_MEM_RECLAIM
kblockd:blk_mq_run_work_fn is flushing !WQ_MEM_RECLAIM qla2xxx_wq:0x0
kernel: WARNING: CPU: 0 PID: 2475 at
kernel/workqueue.c:2593 check_flush_dependency+0x110/0x130
kernel: CPU: 0 PID: 2475 Comm: kworker/0:1H Kdump:
loaded Tainted: G           OE    --------- -  - 4.18.0-193.el8.x86_64 #1
kernel: Hardware name: HPE ProLiant XL170r Gen10/ProLiant XL170r Gen10, BIOS U38 05/21/2019
kernel: Workqueue: kblockd blk_mq_run_work_fn
kernel: RIP: 0010:check_flush_dependency+0x110/0x130
kernel: Code: ff ff 48 8b 50 18 48 8d 8b b0 00 00 00 49 89 e8 48 81 c6 b0 00 00 00 48 c7 c7 00 1e e9
95 c6 05 dc 9a 2f 01 01 e8 1a 42 fe ff <0f> 0b e9 0a ff ff ff 80 3d ca 9a 2f 01 0 0 75 95 e9 41 ff ff ff 90
kernel: RSP: 0018:ffffa40f48b2baf8 EFLAGS: 00010282
kernel: RAX: 0000000000000000 RBX: ffff946795282600 RCX: 0000000000000000
kernel: RDX: 000000000000005f RSI: ffffffff96a1af7f RDI: 0000000000000246
kernel: RBP: 0000000000000000 R08: ffffffff96a1af20 R09: 0000000000029480
kernel: R10: 00080c89bb3e7462 R11: 00000000000009ab R12: ffff946773628000
kernel: R13: 0000000000000282 R14: 0000000000000246 R15: ffffa40f48b2bb40
kernel: FS:  0000000000000000(0000)  GS:ffff94679fa00000(0000) knlGS:0000000000000000
kernel: CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
kernel: CR2: 00005570c4b60110 CR3: 000000029140a005 CR4: 00000000007606f0
kernel: DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
kernel: DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
kernel: PKRU: 55555554
kernel: Call Trace:
kernel: flush_workqueue+0x13a/0x440
kernel: qla2x00_wait_for_sess_deletion+0x1d6/0x200 [qla2xxx]
kernel: ? finish_wait+0x80/0x80
kernel: qla2xxx_disable_port+0x2b/0x30 [qla2xxx]
kernel: qla2x00_process_vendor_specific+0x1dc9/0x2d20 [qla2xxx]
kernel: ? blk_rq_map_sg+0x195/0x570
kernel: qla24xx_bsg_request+0x1a3/0xf90 [qla2xxx]

Link: https://lore.kernel.org/r/20201202132312.19966-13-njavali@marvell.com
Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
Signed-off-by: Saurav Kashyap <skashyap@marvell.com>
Signed-off-by: Nilesh Javali <njavali@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: qla2xxx: Fix flash update in 28XX adapters on big endian machines
Arun Easi [Wed, 2 Dec 2020 13:23:08 +0000 (05:23 -0800)]
scsi: qla2xxx: Fix flash update in 28XX adapters on big endian machines

Flash update failed due to missing endian conversion in FLT region access
as well as in checksum computation.

Link: https://lore.kernel.org/r/20201202132312.19966-12-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>
3 years agoscsi: qla2xxx: Handle aborts correctly for port undergoing deletion
Saurav Kashyap [Wed, 2 Dec 2020 13:23:07 +0000 (05:23 -0800)]
scsi: qla2xxx: Handle aborts correctly for port undergoing deletion

Call trace observed while shutting down the adapter ports (LINK DOWN).
Handle aborts correctly.

localhost kernel: INFO: task nvme:44209 blocked for more than 120 seconds.
localhost kernel: "echo 0 >/proc/sys/kernel/hung_task_timeout_secs" disables this message.
localhost kernel: nvme            D ffff88b45fb5acc0     0 44209 1 0x00000080
localhost kernel: Call Trace:
localhost kernel: [<ffffffffbd187169>] schedule+0x29/0x70
localhost kernel: [<ffffffffbd184c51>] schedule_timeout+0x221/0x2d0
localhost kernel: [<ffffffffbcad7229>] ? ttwu_do_wakeup+0x19/0xe0
localhost kernel: [<ffffffffbcad735f>] ? ttwu_do_activate+0x6f/0x80
localhost kernel: [<ffffffffbcada830>] ? try_to_wake_up+0x190/0x390
localhost kernel: [<ffffffffbd18751d>] wait_for_completion+0xfd/0x140
localhost kernel: [<ffffffffbcadaaf0>] ? wake_up_state+0x20/0x20
localhost kernel: [<ffffffffbcabe3da>] flush_work+0x10a/0x1b0
localhost kernel: [<ffffffffbcabb0f0>] ? move_linked_works+0x90/0x90
localhost kernel: [<ffffffffbcabe6cf>] flush_delayed_work+0x3f/0x50
localhost kernel: [<ffffffffc0452767>] nvme_fc_init_ctrl+0x657/0x6a0 [nvme_fc]
localhost kernel: [<ffffffffc045293a>] nvme_fc_create_ctrl+0x18a/0x210 [nvme_fc]
localhost kernel: [<ffffffffc028962f>] nvmf_dev_write+0x98f/0xb35 [nvme_fabrics]
localhost kernel: [<ffffffffbcd08927>] ? security_file_permission+0x27/0xa0
localhost kernel: [<ffffffffbcc4db50>] vfs_write+0xc0/0x1f0
localhost kernel: [<ffffffffbcc4e92f>] SyS_write+0x7f/0xf0
localhost kernel: [<ffffffffbd193f92>] system_call_fastpath+0x25/0x2a

Link: https://lore.kernel.org/r/20201202132312.19966-11-njavali@marvell.com
Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
Signed-off-by: Saurav Kashyap <skashyap@marvell.com>
Signed-off-by: Nilesh Javali <njavali@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: qla2xxx: Fix N2N and NVMe connect retry failure
Quinn Tran [Wed, 2 Dec 2020 13:23:06 +0000 (05:23 -0800)]
scsi: qla2xxx: Fix N2N and NVMe connect retry failure

FC-NVMe target discovery failed when initiator wwpn < target wwpn in an N2N
(Direct Attach) config, where the driver was stuck on FCP PRLI mode and
failed to retry with NVMe PRLI.

Link: https://lore.kernel.org/r/20201202132312.19966-10-njavali@marvell.com
Fixes: 84ed362ac40c ("scsi: qla2xxx: Dual FCP-NVMe target port support”)
Fixes: 983f127603fa ("scsi: qla2xxx: Retry PLOGI on FC-NVMe PRLI failure”)
Signed-off-by: Quinn Tran <qutran@marvell.com>
Signed-off-by: Nilesh Javali <njavali@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: qla2xxx: Fix FW initialization error on big endian machines
Arun Easi [Wed, 2 Dec 2020 13:23:05 +0000 (05:23 -0800)]
scsi: qla2xxx: Fix FW initialization error on big endian machines

Some fields are not correctly byte swapped causing failure during
initialization. As probe() returns failure, HBAs will not be claimed when
this happens.

qla2xxx [0007:01:00.0]-ffff:3: Secure Flash Update in FW: Supported
qla2xxx [0007:01:00.0]-ffff:3: SCM in FW: Supported
qla2xxx [0007:01:00.0]-00d2:3: Init Firmware **** FAILED ****.
qla2xxx [0007:01:00.0]-00d6:3: Failed to initialize adapter - Adapter flags 2.
qla2xxx 0007:01:00.1: enabling device (0140 -> 0142)
qla2xxx [0007:01:00.1]-011c: : MSI-X vector count: 128.
qla2xxx [0007:01:00.1]-001d: : Found an ISP2289 irq 18 iobase 0xd000080080004000.
qla2xxx 0007:01:00.1: Using 64-bit direct DMA at offset 800000000000000
BUG: Bad page state in process insmod  pfn:67118 page:f00000000168bd40
count:-1 mapcount:0 mapping: (null) index:0x0
page flags: 0x3ffff800000000() page dumped because: nonzero _count
Modules linked in: qla2xxx(OE+) nvme_fc nvme_fabrics
nvme_core scsi_transport_fc scsi_tgt nls_utf8 isofs ip6t_rpfilter
ipt_REJECT nf_reject_ipv4 ip6t_REJECT nf_reject_ipv6 xt_conntrack ip_set
nfnetlink ebtable_nat ebtable_broute bridge stp llc ip6table_nat
nf_conntrack_ipv6 nf_defrag_ipv6 nf_nat_ipv6 ip6table_mangle
ip6table_security ip6table_raw iptable_nat nf_conntrack_ipv4
nf_defrag_ipv4 nf_nat_ipv4 nf_nat nf_conntrack iptable_mangle
iptable_security iptable_raw ebtable_filter ebtables ip6table_filter
ip6_tables iptable_filter nx_crypto ses enclosure scsi_transport_sas
pseries_rng sg ip_tables xfs libcrc32c sr_mod cdrom sd_mod crc_t10dif
crct10dif_generic crct10dif_common usb_storage ipr libata tg3 ptp
pps_core dm_mirror dm_region_hash dm_log dm_mod
CPU: 32 PID: 8560 Comm: insmod Kdump: loaded Tainted: G
OE  ------------   3.10.0-957.el7.ppc64 #1
Call Trace:
[c0000006dd7caa70] [c00000000001cca8] .show_stack+0x88/0x330 (unreliable)
[c0000006dd7cab30] [c000000000ac3d88] .dump_stack+0x28/0x3c
[c0000006dd7caba0] [c00000000029e48c] .bad_page+0x15c/0x1c0
[c0000006dd7cac40] [c00000000029f938] .get_page_from_freelist+0x11e8/0x1ea0
[c0000006dd7caf40] [c0000000002a1d30] .__alloc_pages_nodemask+0x1c0/0xc70
[c0000006dd7cb140] [c00000000002ba0c] .__dma_direct_alloc_coherent+0x8c/0x170
[c0000006dd7cb1e0] [d000000010a94688] .qla2x00_mem_alloc+0x10f8/0x1370 [qla2xxx]
[c0000006dd7cb2d0] [d000000010a9c790] .qla2x00_probe_one+0xb60/0x22e0 [qla2xxx]
[c0000006dd7cb540] [c0000000005de764] .pci_device_probe+0x204/0x300
[c0000006dd7cb600] [c0000000006ca61c] .driver_probe_device+0x2cc/0x6f0
[c0000006dd7cb6b0] [c0000000006cabec] .__driver_attach+0x10c/0x110
[c0000006dd7cb740] [c0000000006c5f04] .bus_for_each_dev+0x94/0x100
[c0000006dd7cb7e0] [c0000000006c94f4] .driver_attach+0x34/0x50
[c0000006dd7cb860] [c0000000006c8f58] .bus_add_driver+0x298/0x3b0
[c0000006dd7cb900] [c0000000006cb6e0] .driver_register+0xb0/0x1a0
[c0000006dd7cb980] [c0000000005dc474] .__pci_register_driver+0xc4/0xf0
[c0000006dd7cba10] [d000000010b94e20] .qla2x00_module_init+0x2a8/0x328 [qla2xxx]
[c0000006dd7cbaa0] [c00000000000c130] .do_one_initcall+0x130/0x2e0
[c0000006dd7cbb50] [c0000000001b2e8c] .load_module+0x1afc/0x2340
[c0000006dd7cbd40] [c0000000001b3920] .SyS_finit_module+0xd0/0x130
[c0000006dd7cbe30] [c00000000000a284]  system_call+0x38/0xfc

Link: https://lore.kernel.org/r/20201202132312.19966-9-njavali@marvell.com
Fixes: 9f2475fe7406 ("scsi: qla2xxx: SAN congestion management implementation")
Fixes: cf3c54fb49a4 ("scsi: qla2xxx: Add SLER and PI control support”)
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>
3 years agoscsi: qla2xxx: Fix crash during driver load on big endian machines
Arun Easi [Wed, 2 Dec 2020 13:23:04 +0000 (05:23 -0800)]
scsi: qla2xxx: Fix crash during driver load on big endian machines

Crash stack:
[576544.715489] Unable to handle kernel paging request for data at address 0xd00000000f970000
[576544.715497] Faulting instruction address: 0xd00000000f880f64
[576544.715503] Oops: Kernel access of bad area, sig: 11 [#1]
[576544.715506] SMP NR_CPUS=2048 NUMA pSeries
:
[576544.715703] NIP [d00000000f880f64] .qla27xx_fwdt_template_valid+0x94/0x100 [qla2xxx]
[576544.715722] LR [d00000000f7952dc] .qla24xx_load_risc_flash+0x2fc/0x590 [qla2xxx]
[576544.715726] Call Trace:
[576544.715731] [c0000004d0ffb000] [c0000006fe02c350] 0xc0000006fe02c350 (unreliable)
[576544.715750] [c0000004d0ffb080] [d00000000f7952dc] .qla24xx_load_risc_flash+0x2fc/0x590 [qla2xxx]
[576544.715770] [c0000004d0ffb170] [d00000000f7aa034] .qla81xx_load_risc+0x84/0x1a0 [qla2xxx]
[576544.715789] [c0000004d0ffb210] [d00000000f79f7c8] .qla2x00_setup_chip+0xc8/0x910 [qla2xxx]
[576544.715808] [c0000004d0ffb300] [d00000000f7a631c] .qla2x00_initialize_adapter+0x4dc/0xb00 [qla2xxx]
[576544.715826] [c0000004d0ffb3e0] [d00000000f78ce28] .qla2x00_probe_one+0xf08/0x2200 [qla2xxx]

Link: https://lore.kernel.org/r/20201202132312.19966-8-njavali@marvell.com
Fixes: f73cb695d3ec ("[SCSI] qla2xxx: Add support for ISP2071.")
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>
3 years agoscsi: qla2xxx: Fix compilation issue in PPC systems
Arun Easi [Wed, 2 Dec 2020 13:23:03 +0000 (05:23 -0800)]
scsi: qla2xxx: Fix compilation issue in PPC systems

Fix compile time errors reported on PPC systems,

qla_gbl.h:991:20: error: inlining failed in call to always_inline
     ‘qla_nvme_abort_set_option’: function body not available

Link: https://lore.kernel.org/r/20201202132312.19966-7-njavali@marvell.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>
3 years agoscsi: qla2xxx: Don't check for fw_started while posting NVMe command
Saurav Kashyap [Wed, 2 Dec 2020 13:23:02 +0000 (05:23 -0800)]
scsi: qla2xxx: Don't check for fw_started while posting NVMe command

NVMe commands can come only after successful addition of rport and NVMe
connect, and rport is only registered after FW started bit is set. Remove
the redundant check.

Link: https://lore.kernel.org/r/20201202132312.19966-6-njavali@marvell.com
Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
Signed-off-by: Saurav Kashyap <skashyap@marvell.com>
Signed-off-by: Nilesh Javali <njavali@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: qla2xxx: Tear down session if FW say it is down
Quinn Tran [Wed, 2 Dec 2020 13:23:01 +0000 (05:23 -0800)]
scsi: qla2xxx: Tear down session if FW say it is down

The completion status 0x28 (ppc = be = 0x2800) below indicates session is
not there, trigger session deletion.

qla2xxx [000b:04:00.1]-8009:8: DEVICE RESET ISSUED nexus=8:1:51 cmd=c000001432d0f600.
qla2xxx [000b:04:00.1]-5039:8: Async-tmf error - hdl=67b completion status(2800).
qla2xxx [000b:04:00.1]-8030:8: TM IOCB failed (102).
qla2xxx [000b:04:00.1]-800c:8: do_reset failed for cmd=c000001432d0f600.
qla2xxx [000b:04:00.1]-800f:8: DEVICE RESET FAILED: Task management failed nexus=8:1:51 cmd=c000001432d0f600.
qla2xxx [000b:04:00.1]-8009:8: DEVICE RESET ISSUED nexus=8:1:52 cmd=c000001432d0c200.
qla2xxx [000b:04:00.1]-5039:8: Async-tmf error - hdl=67c completion status(2800).
qla2xxx [000b:04:00.1]-8030:8: TM IOCB failed (102).

Link: https://lore.kernel.org/r/20201202132312.19966-5-njavali@marvell.com
Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
Signed-off-by: Quinn Tran <qutran@marvell.com>
Signed-off-by: Nilesh Javali <njavali@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: qla2xxx: Limit interrupt vectors to number of CPUs
Quinn Tran [Wed, 2 Dec 2020 13:23:00 +0000 (05:23 -0800)]
scsi: qla2xxx: Limit interrupt vectors to number of CPUs

Driver created too many QPairs(126) with 28xx adapter.  Limit to the number
of CPUs to minimize wasted resources.

Link: https://lore.kernel.org/r/20201202132312.19966-4-njavali@marvell.com
Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
Signed-off-by: Quinn Tran <qutran@marvell.com>
Signed-off-by: Nilesh Javali <njavali@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: qla2xxx: Change post del message from debug level to log level
Saurav Kashyap [Wed, 2 Dec 2020 13:22:59 +0000 (05:22 -0800)]
scsi: qla2xxx: Change post del message from debug level to log level

Change the message debug level.

Link: https://lore.kernel.org/r/20201202132312.19966-3-njavali@marvell.com
Signed-off-by: Saurav Kashyap <skashyap@marvell.com>
Signed-off-by: Nilesh Javali <njavali@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: qla2xxx: Return EBUSY on fcport deletion
Daniel Wagner [Wed, 2 Dec 2020 13:22:58 +0000 (05:22 -0800)]
scsi: qla2xxx: Return EBUSY on fcport deletion

When the fcport is about to be deleted we should return EBUSY instead of
ENODEV. Only for EBUSY will the request be requeued in a multipath setup.

Also return EBUSY when the firmware has not yet started to avoid dropping
the request.

Link: https://lore.kernel.org/r/20201014073048.36219-1-dwagner@suse.de
Link: https://lore.kernel.org/r/20201202132312.19966-2-njavali@marvell.com
Reviewed-by: Arun Easi <aeasi@marvell.com>
Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
Signed-off-by: Daniel Wagner <dwagner@suse.de>
Signed-off-by: Nilesh Javali <njavali@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: qla4xxx: Remove redundant assignment to variable rval
Colin Ian King [Fri, 4 Dec 2020 19:18:10 +0000 (19:18 +0000)]
scsi: qla4xxx: Remove redundant assignment to variable rval

The variable rval is being initialized with a value that is never read and
it is being updated later with a new value.  The initialization is
redundant and can be removed.

Link: https://lore.kernel.org/r/20201204191810.1150995-1-colin.king@canonical.com
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Addresses-Coverity: ("Unused value")

3 years agoscsi: qla2xxx: Remove trailing semicolon in macro definition
Tom Rix [Mon, 30 Nov 2020 20:55:09 +0000 (12:55 -0800)]
scsi: qla2xxx: Remove trailing semicolon in macro definition

The macro use will already have a semicolon. Remove unneeded escaped
newline.

Link: https://lore.kernel.org/r/20201130205509.3447316-1-trix@redhat.com
Reviewed-by: Daniel Wagner <dwagner@suse.de>
Signed-off-by: Tom Rix <trix@redhat.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: fnic: Fix error return code in fnic_probe()
Zhang Changzhong [Fri, 4 Dec 2020 07:47:39 +0000 (15:47 +0800)]
scsi: fnic: Fix error return code in fnic_probe()

Return a negative error code from the error handling case instead of 0 as
done elsewhere in this function.

Link: https://lore.kernel.org/r/1607068060-31203-1-git-send-email-zhangchangzhong@huawei.com
Fixes: 5df6d737dd4b ("[SCSI] fnic: Add new Cisco PCI-Express FCoE HBA")
Reported-by: Hulk Robot <hulkci@huawei.com>
Reviewed-by: Karan Tilak Kumar <kartilak@cisco.com>
Signed-off-by: Zhang Changzhong <zhangchangzhong@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: ufs: Fix -Wsometimes-uninitialized warning
Arnd Bergmann [Thu, 3 Dec 2020 22:31:26 +0000 (23:31 +0100)]
scsi: ufs: Fix -Wsometimes-uninitialized warning

clang complains about a possible code path in which a variable is used
without an initialization:

drivers/scsi/ufs/ufshcd.c:7690:3: error: variable 'sdp' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]
                BUG_ON(1);
                ^~~~~~~~~
include/asm-generic/bug.h:63:36: note: expanded from macro 'BUG_ON'
 #define BUG_ON(condition) do { if (unlikely(condition)) BUG(); } while (0)
                                   ^~~~~~~~~~~~~~~~~~~

Turn the BUG_ON(1) into an unconditional BUG() that makes it clear to clang
that this code path is never hit.

Link: https://lore.kernel.org/r/20201203223137.1205933-1-arnd@kernel.org
Fixes: 4f3e900b6282 ("scsi: ufs: Clear UAC for FFU and RPMB LUNs")
Reviewed-by: Avri Altman <avri.altman@wdc.com>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: NCR5380: Remove context check
Ahmed S. Darwish [Sun, 6 Dec 2020 07:51:57 +0000 (08:51 +0100)]
scsi: NCR5380: Remove context check

NCR5380_poll_politely2() uses in_interrupt() and irqs_disabled() to check
if it is safe to sleep.

Such usage in drivers is phased out and Linus clearly requested that code
which changes behaviour depending on context should either be separated, or
the context be explicitly conveyed in an argument passed by the caller.

Below is a context analysis of NCR5380_poll_politely2() uppermost callers:

  - NCR5380_maybe_reset_bus(), task, invoked during device probe.
    -> NCR5380_poll_politely()
    -> do_abort()

  - NCR5380_select(), task, but can only sleep in the "release, then
    re-acquire" regions of the spinlock held by its caller.
    Sleeping invocations (lock released):
    -> NCR5380_poll_politely2()

    Atomic invocations (lock acquired):
    -> NCR5380_reselect()
       -> NCR5380_poll_politely()
       -> do_abort()
       -> NCR5380_transfer_pio()

  - NCR5380_intr(), interrupt handler
    -> NCR5380_dma_complete()
       -> NCR5380_transfer_pio()
  -> NCR5380_poll_politely()
    -> NCR5380_reselect() (see above)

  - NCR5380_information_transfer(), task, but can only sleep in the
    "release, then re-acquire" regions of the caller-held spinlock.
    Sleeping invocations (lock released):
      - NCR5380_transfer_pio() -> NCR5380_poll_politely()
      - NCR5380_poll_politely()

    Atomic invocations (lock acquired):
      - NCR5380_transfer_dma()
-> NCR5380_dma_recv_setup()
           => generic_NCR5380_precv() -> NCR5380_poll_politely()
   => macscsi_pread() -> NCR5380_poll_politely()

-> NCR5380_dma_send_setup()
     => generic_NCR5380_psend -> NCR5380_poll_politely2()
   => macscsi_pwrite() -> NCR5380_poll_politely()

-> NCR5380_poll_politely2()
        -> NCR5380_dma_complete()
           -> NCR5380_transfer_pio()
      -> NCR5380_poll_politely()
      - NCR5380_transfer_pio() -> NCR5380_poll_politely

  - NCR5380_reselect(), atomic, always called with hostdata spinlock
    held.

Since NCR5380_poll_politely2() already takes a "wait" argument in jiffies,
use it to determine if the function can sleep. Modify atomic callers, which
passed an unused wait value in terms of HZ, to pass zero.

Link: https://lore.kernel.org/r/20201206075157.19067-1-a.darwish@linutronix.de
Cc: Michael Schmitz <schmitzmic@gmail.com>
Cc: <linux-m68k@lists.linux-m68k.org>
Suggested-by: Finn Thain <fthain@telegraphics.com.au>
Co-developed-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Acked-by: Finn Thain <fthain@telegraphics.com.au>
Signed-off-by: Ahmed S. Darwish <a.darwish@linutronix.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: ufs: Adjust ufshcd_hold() during sending attribute requests
jintae jang [Thu, 3 Dec 2020 05:25:32 +0000 (14:25 +0900)]
scsi: ufs: Adjust ufshcd_hold() during sending attribute requests

Invalidation check of arguments should have been checked before
ufshcd_hold(). This can help to prevent ufshcd_hold()/ ufshcd_release()
from being invoked unnecessarily.

[mkp: removed unused out: labels]

Link: https://lore.kernel.org/r/1606973132-5937-1-git-send-email-user@jang-Samsung-DeskTop-System
Reviewed-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: jintae jang <jt77.jang@samsung.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: ufs: Print host regs in IRQ handler when AH8 error happens
Can Guo [Wed, 2 Dec 2020 12:04:03 +0000 (04:04 -0800)]
scsi: ufs: Print host regs in IRQ handler when AH8 error happens

Dump registers and states prior to leaving IRQ handler when an AH8 error
occurs.

Link: https://lore.kernel.org/r/1606910644-21185-4-git-send-email-cang@codeaurora.org
Reviewed-by: Stanley Chu <stanley.chu@mediatek.com>
Reviewed-by: Bao D. Nguyen <nguyenb@codeaurora.org>
Reviewed-by: Asutosh Das <asutoshd@codeaurora.org>
Reviewed-by: Hongwu Su <hongwus@codeaurora.org>
Signed-off-by: Can Guo <cang@codeaurora.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: ufs: Fix a race condition between ufshcd_abort() and eh_work()
Can Guo [Wed, 2 Dec 2020 12:04:02 +0000 (04:04 -0800)]
scsi: ufs: Fix a race condition between ufshcd_abort() and eh_work()

In current task abort routine, if task abort happens to the device W-LUN,
the code directly jumps to ufshcd_eh_host_reset_handler() to perform a full
reset and restore then returns FAIL or SUCCESS. Commands sent to the device
W-LUN are most likely the SSU cmds sent during UFS PM operations. If such
SSU cmd enters task abort routine when ufshcd_eh_host_reset_handler()
flushes eh_work, it will get stuck there since err_handler is serialized
with PM operations.

In order to unblock above call path, we merely clean up the lrb taken by
this cmd, queue the eh_work and return SUCCESS. Once the cmd is aborted,
the PM operation which sends out the cmd just errors out, then err_handler
shall be able to proceed with the full reset and restore.

In this scenario, the cmd is aborted even before it is actually cleared by
HW, set the lrb->in_use flag to prevent subsequent cmds, including SCSI
cmds and dev cmds, from taking the lrb released from abort. The flag shall
evetually be cleared in __ufshcd_transfer_req_compl() invoked by the full
reset and restore from err_handler.

[mkp: conflict with event logging series]

Link: https://lore.kernel.org/r/1606910644-21185-3-git-send-email-cang@codeaurora.org
Reviewed-by: Asutosh Das <asutoshd@codeaurora.org>
Reviewed-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Can Guo <cang@codeaurora.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: ufs: Serialize eh_work with system PM events and async scan
Can Guo [Wed, 2 Dec 2020 12:04:01 +0000 (04:04 -0800)]
scsi: ufs: Serialize eh_work with system PM events and async scan

Serialize eh_work with system PM events and async scan to make sure eh_work
does not run in parallel with them.

Link: https://lore.kernel.org/r/1606910644-21185-2-git-send-email-cang@codeaurora.org
Reviewed-by: Stanley Chu <stanley.chu@mediatek.com>
Reviewed-by: Asutosh Das <asutoshd@codeaurora.org>
Reviewed-by: Hongwu Su <hongwus@codeaurora.org>
Signed-off-by: Can Guo <cang@codeaurora.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: ufs: Remove pre-defined initial voltage values of device power
Stanley Chu [Wed, 2 Dec 2020 09:18:19 +0000 (17:18 +0800)]
scsi: ufs: Remove pre-defined initial voltage values of device power

UFS specficication allows different VCC configurations for UFS devices,
for example:

(1). 2.70V - 3.60V (Activated by default in UFS core driver)
(2). 1.70V - 1.95V (Activated if "vcc-supply-1p8" is declared in
                          device tree)
(3). 2.40V - 2.70V (Supported since UFS 3.x)

With the introduction of UFS 3.x products, an issue is happening that UFS
driver will use wrong "min_uV-max_uV" values to configure the voltage of
VCC regulator on UFU 3.x products with the configuration (3) used.

To solve this issue, we simply remove pre-defined initial VCC voltage
values in UFS core driver with below reasons,

1. UFS specifications do not define how to detect the VCC configuration
   supported by attached device.

2. Device tree already supports standard regulator properties.

Therefore VCC voltage shall be defined correctly in device tree, and shall
not changed by UFS driver. What UFS driver needs to do is simply enable or
disable the VCC regulator only.

Similar change is applied to VCCQ and VCCQ2 as well.

Note that we keep struct ufs_vreg unchanged. This allows vendors to
configure proper min_uV and max_uV of any regulators to make
regulator_set_voltage() works during regulator toggling flow in the
future. Without specific vendor configurations, min_uV and max_uV will be
NULL by default and UFS core driver will enable or disable the regulator
only without adjusting its voltage.

Link: https://lore.kernel.org/r/20201202091819.22363-1-stanley.chu@mediatek.com
Reviewed-by: Asutosh Das <asutoshd@codeaurora.org>
Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Reviewed-by: Can Guo <cang@codeaurora.org>
Acked-by: Avri Altman <avri.altman@wdc.com>
Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: ufs-dwc: Use phy_initialization helper
Stanley Chu [Sat, 5 Dec 2020 12:00:41 +0000 (20:00 +0800)]
scsi: ufs-dwc: Use phy_initialization helper

Use phy_initialization helper instead of direct invocation.

Link: https://lore.kernel.org/r/20201205120041.26869-5-stanley.chu@mediatek.com
Reviewed-by: Avri Altman <avri.altman@wdc.com>
Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: ufs-cdns: Use phy_initialization helper
Stanley Chu [Sat, 5 Dec 2020 12:00:40 +0000 (20:00 +0800)]
scsi: ufs-cdns: Use phy_initialization helper

Use phy_initialization helper instead of direct function invocation.

Link: https://lore.kernel.org/r/20201205120041.26869-4-stanley.chu@mediatek.com
Reviewed-by: Avri Altman <avri.altman@wdc.com>
Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: ufs: Introduce phy_initialization helper
Stanley Chu [Sat, 5 Dec 2020 12:00:39 +0000 (20:00 +0800)]
scsi: ufs: Introduce phy_initialization helper

Introduce phy_initialization helper since this is the only one variant
function without helper.

Link: https://lore.kernel.org/r/20201205120041.26869-3-stanley.chu@mediatek.com
Reviewed-by: Avri Altman <avri.altman@wdc.com>
Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: ufs: Remove unused setup_regulators variant function
Stanley Chu [Sat, 5 Dec 2020 12:00:38 +0000 (20:00 +0800)]
scsi: ufs: Remove unused setup_regulators variant function

Since setup_regulators variant function is not used by any vendors, simply
remove it.

Link: https://lore.kernel.org/r/20201205120041.26869-2-stanley.chu@mediatek.com
Reviewed-by: Avri Altman <avri.altman@wdc.com>
Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: ufs-mediatek: Introduce event_notify implementation
Stanley Chu [Sat, 5 Dec 2020 11:59:01 +0000 (19:59 +0800)]
scsi: ufs-mediatek: Introduce event_notify implementation

Introduce event_notify implementation on MediaTek UFS platform. A
vendor-specific tracepoint is added that can be used for debugging
purposes.

Link: https://lore.kernel.org/r/20201205115901.26815-5-stanley.chu@mediatek.com
Reviewed-by: Avri Altman <avri.altman@wdc.com>
Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: ufs: Introduce event_notify variant function
Stanley Chu [Sat, 5 Dec 2020 11:59:00 +0000 (19:59 +0800)]
scsi: ufs: Introduce event_notify variant function

Introduce event_notify variant function to allow vendor to get notification
of important events and connect to any proprietary debugging facilities.

Link: https://lore.kernel.org/r/20201205115901.26815-4-stanley.chu@mediatek.com
Reviewed-by: Asutosh Das <asutoshd@codeaurora.org>
Reviewed-by: Can Guo <cang@codeaurora.org>
Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: ufs: Refine error history functions
Stanley Chu [Sat, 5 Dec 2020 11:58:59 +0000 (19:58 +0800)]
scsi: ufs: Refine error history functions

The UFS error history does not only have "history of errors" but also a
log of some other events which are not defined as errors.

This patch fixes the confused naming of related functions and changes the
approach for updating and printing history in preparation of next patch.

This patch does not change any functionality.

Link: https://lore.kernel.org/r/20201205115901.26815-3-stanley.chu@mediatek.com
Reviewed-by: Asutosh Das <asutoshd@codeaurora.org>
Reviewed-by: Can Guo <cang@codeaurora.org>
Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: ufs: Add error history for abort event in UFS Device W-LUN
Stanley Chu [Sat, 5 Dec 2020 11:58:58 +0000 (19:58 +0800)]
scsi: ufs: Add error history for abort event in UFS Device W-LUN

Add error history for abort event in UFS Device W-LUN.

Use specified value as parameter of ufshcd_update_reg_hist() to identify
the aborted tag or LUNs.

Link: https://lore.kernel.org/r/20201205115901.26815-2-stanley.chu@mediatek.com
Reviewed-by: Asutosh Das <asutoshd@codeaurora.org>
Reviewed-by: Can Guo <cang@codeaurora.org>
Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: iscsi: Fix inappropriate use of put_device()
Qinglang Miao [Fri, 20 Nov 2020 07:48:52 +0000 (15:48 +0800)]
scsi: iscsi: Fix inappropriate use of put_device()

kfree(conn) is called inside put_device(&conn->dev) which could lead to
use-after-free. In addition, device_unregister() should be used here rather
than put_deviceO().

Link: https://lore.kernel.org/r/20201120074852.31658-1-miaoqinglang@huawei.com
Fixes: f3c893e3dbb5 ("scsi: iscsi: Fail session and connection on transport registration failure")
Reported-by: Hulk Robot <hulkci@huawei.com>
Reviewed-by: Mike Christie <michael.christie@oracle.com>
Signed-off-by: Qinglang Miao <miaoqinglang@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: pm80xx: Fix error return in pm8001_pci_probe()
Zhang Qilong [Sat, 5 Dec 2020 11:55:51 +0000 (19:55 +0800)]
scsi: pm80xx: Fix error return in pm8001_pci_probe()

The driver did not return an error in the case where
pm8001_configure_phy_settings() failed.

Use rc to store the return value of pm8001_configure_phy_settings().

Link: https://lore.kernel.org/r/20201205115551.2079471-1-zhangqilong3@huawei.com
Fixes: 279094079a44 ("[SCSI] pm80xx: Phy settings support for motherboard controller.")
Acked-by: Jack Wang <jinpu.wang@cloud.ionos.com>
Signed-off-by: Zhang Qilong <zhangqilong3@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: qedi: Fix missing destroy_workqueue() on error in __qedi_probe
Qinglang Miao [Mon, 9 Nov 2020 09:15:18 +0000 (17:15 +0800)]
scsi: qedi: Fix missing destroy_workqueue() on error in __qedi_probe

Add the missing destroy_workqueue() before return from __qedi_probe in the
error handling case when fails to create workqueue qedi->offload_thread.

Link: https://lore.kernel.org/r/20201109091518.55941-1-miaoqinglang@huawei.com
Fixes: ace7f46ba5fd ("scsi: qedi: Add QLogic FastLinQ offload iSCSI driver framework.")
Reviewed-by: Mike Christie <michael.christie@oracle.com>
Signed-off-by: Qinglang Miao <miaoqinglang@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: target: core: Fix fall-through warnings for Clang
Gustavo A. R. Silva [Fri, 20 Nov 2020 18:32:32 +0000 (12:32 -0600)]
scsi: target: core: Fix fall-through warnings for Clang

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

Link: https://github.com/KSPP/linux/issues/115
Link: https://lore.kernel.org/r/761d6f755e8a6f8a6daebd1e5c1394167e5c780a.1605896059.git.gustavoars@kernel.org
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: stex: Fix fall-through warnings for Clang
Gustavo A. R. Silva [Fri, 20 Nov 2020 18:39:36 +0000 (12:39 -0600)]
scsi: stex: Fix fall-through warnings for Clang

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

Link: https://github.com/KSPP/linux/issues/115
Link: https://lore.kernel.org/r/20a7bcc10af2b762325c7078a4f472121a4fabc7.1605896060.git.gustavoars@kernel.org
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: lpfc: Fix fall-through warnings for Clang
Gustavo A. R. Silva [Fri, 20 Nov 2020 18:39:31 +0000 (12:39 -0600)]
scsi: lpfc: Fix fall-through warnings for Clang

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

Link: https://github.com/KSPP/linux/issues/115
Link: https://lore.kernel.org/r/fff8d6f1d33b9e2c94dbe024a4f8df22866d3bf8.1605896060.git.gustavoars@kernel.org
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: csiostor: Fix fall-through warnings for Clang
Gustavo A. R. Silva [Fri, 20 Nov 2020 18:39:26 +0000 (12:39 -0600)]
scsi: csiostor: Fix fall-through warnings for Clang

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

Link: https://github.com/KSPP/linux/issues/115
Link: https://lore.kernel.org/r/b77ee091548f16b52056c3b9ee8c76dc6691f868.1605896060.git.gustavoars@kernel.org
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: aha1740: Fix fall-through warnings for Clang
Gustavo A. R. Silva [Fri, 20 Nov 2020 18:39:21 +0000 (12:39 -0600)]
scsi: aha1740: Fix fall-through warnings for Clang

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

Link: https://github.com/KSPP/linux/issues/115
Link: https://lore.kernel.org/r/e9fc10eb7d843e6f31e50400d428bd7a217684ac.1605896060.git.gustavoars@kernel.org
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: aacraid: Fix fall-through warnings for Clang
Gustavo A. R. Silva [Fri, 20 Nov 2020 18:39:15 +0000 (12:39 -0600)]
scsi: aacraid: Fix fall-through warnings for Clang

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

Link: https://github.com/KSPP/linux/issues/115
Link: https://lore.kernel.org/r/e4e25e57964a69f7173f868ff93df9d6d08f360f.1605896060.git.gustavoars@kernel.org
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: bfa: Fix fall-through warnings for Clang
Gustavo A. R. Silva [Fri, 20 Nov 2020 18:27:30 +0000 (12:27 -0600)]
scsi: bfa: Fix fall-through warnings for Clang

In preparation to enable -Wimplicit-fallthrough for Clang, fix multiple
warnings by explicitly adding a couple break statements and replacing /*
fall through */ comments with the new pseudo-keyword macro fallthrough;
instead of just letting the code fall through to the next case.

Notice that Clang doesn't recognize /* fall through */ comments as implicit
fall-through markings.

Link: https://github.com/KSPP/linux/issues/115
Link: https://lore.kernel.org/r/2ae1cafd858238b85fc5e7fe5cc183843e21ec9f.1605896059.git.gustavoars@kernel.org
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: aic94xx: Fix fall-through warnings for Clang
Gustavo A. R. Silva [Fri, 20 Nov 2020 18:27:24 +0000 (12:27 -0600)]
scsi: aic94xx: Fix fall-through warnings for Clang

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

Link: https://github.com/KSPP/linux/issues/115
Link: https://lore.kernel.org/r/9b58459045d303bbea0160f2e349f5799402a2bf.1605896059.git.gustavoars@kernel.org
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: aic7xxx: Fix fall-through warnings for Clang
Gustavo A. R. Silva [Fri, 20 Nov 2020 18:27:16 +0000 (12:27 -0600)]
scsi: aic7xxx: Fix fall-through warnings for Clang

In preparation to enable -Wimplicit-fallthrough for Clang, fix multiple
warnings by explicitly adding multiple break statements instead of just
letting the code fall through to the next case, and by adding fallthrough
statements in places where the code is intended to fall through, and
finally by replacing /* FALLTHROUGH */ comments with the new pseudo-keyword
macro fallthrough.

Link: https://github.com/KSPP/linux/issues/115
Link: https://lore.kernel.org/r/1a7cd2f77623e6ab46bbec0b6103b18491419206.1605896059.git.gustavoars@kernel.org
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: lpfc: Correct null ndlp reference on routine exit
James Smart [Mon, 30 Nov 2020 18:12:26 +0000 (10:12 -0800)]
scsi: lpfc: Correct null ndlp reference on routine exit

smatch correctly called out a logic error with accessing a pointer after
checking it for null:

 drivers/scsi/lpfc/lpfc_els.c:2043 lpfc_cmpl_els_plogi()
 error: we previously assumed 'ndlp' could be null (see line 1942)

Adjust the exit point to avoid the trace printf ndlp reference. A trace
entry was already generated when the ndlp was checked for null.

Link: https://lore.kernel.org/r/20201130181226.16675-1-james.smart@broadcom.com
Fixes: 4430f7fd09ec ("scsi: lpfc: Rework locations of ndlp reference taking")
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: James Smart <james.smart@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: ufs: Stop hardcoding the scale down gear
Can Guo [Fri, 27 Nov 2020 01:58:48 +0000 (17:58 -0800)]
scsi: ufs: Stop hardcoding the scale down gear

Instead of hardcoding the scale down gear, make it a member of
the ufs_clk_scaling struct.

Link: https://lore.kernel.org/r/1606442334-22641-1-git-send-email-cang@codeaurora.org
Reviewed-by: Stanley Chu <stanley.chu@mediatek.com>
Reviewed-by: Bean Huo <beanhuo@micron.com>
Reviewed-by: Asutosh Das <asutoshd@codeaurora.org>
Signed-off-by: Can Guo <cang@codeaurora.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: ufs-qcom: Keep core_clk_unipro on while link is active
Can Guo [Thu, 26 Nov 2020 02:01:01 +0000 (18:01 -0800)]
scsi: ufs-qcom: Keep core_clk_unipro on while link is active

If we want to disable clocks to save power but still keep the link active,
core_clk_unipro, like ref_clk, should not be the one being disabled.

Link: https://lore.kernel.org/r/1606356063-38380-3-git-send-email-cang@codeaurora.org
Reviewed-by: Hongwu Su <hongwus@codeaurora.org>
Reviewed-by: Asutosh Das <asutoshd@codeaurora.org>
Signed-off-by: Can Guo <cang@codeaurora.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: ufs: Refactor ufshcd_setup_clocks() to remove skip_ref_clk
Can Guo [Thu, 26 Nov 2020 02:01:00 +0000 (18:01 -0800)]
scsi: ufs: Refactor ufshcd_setup_clocks() to remove skip_ref_clk

Remove the param skip_ref_clk from __ufshcd_setup_clocks(), but keep a flag
in struct ufs_clk_info to tell whether a clock can be disabled or not while
the link is active.

Link: https://lore.kernel.org/r/1606356063-38380-2-git-send-email-cang@codeaurora.org
Reviewed-by: Hongwu Su <hongwus@codeaurora.org>
Reviewed-by: Bean Huo <beanhuo@micron.com>
Reviewed-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Can Guo <cang@codeaurora.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: message: fusion: Remove in_interrupt() usage in mptsas_cleanup_fw_event_q()
Sebastian Andrzej Siewior [Thu, 26 Nov 2020 13:29:52 +0000 (14:29 +0100)]
scsi: message: fusion: Remove in_interrupt() usage in mptsas_cleanup_fw_event_q()

mptsas_cleanup_fw_event_q() uses in_interrupt() to determine if it is safe
to cancel a worker item.

Aside of that in_interrupt() is deprecated as it does not provide what the
name suggests. It covers more than hard/soft interrupt servicing context
and is semantically ill defined.

Looking closer there are a few problems with the current construct:

 - It could be invoked from an interrupt handler / non-blocking context
   because cancel_delayed_work() has no such restriction. Also,
   mptsas_free_fw_event() has no such restriction.

 - The list is accessed unlocked. It may dequeue a valid work-item but at
   the time of invoking cancel_delayed_work() the memory may be released or
   reused because the worker has already run.

mptsas_cleanup_fw_event_q() is invoked via mptsas_shutdown() which is
always invoked from preemtible context on device shutdown.  It is also
invoked via mptsas_ioc_reset(, MPT_IOC_POST_RESET) which is a
MptResetHandlers callback. The only caller here are mpt_SoftResetHandler(),
mpt_HardResetHandler() and mpt_Soft_Hard_ResetHandler(). All these
functions have a `sleepFlag' argument and each caller uses caller uses
`CAN_SLEEP' here and according to current documentation: | @sleepFlag:
Indicates if sleep or schedule must be called

So it is safe to sleep.

Add mptsas_hotplug_event::users member. Initialize it to one by default so
mptsas_free_fw_event() will free the memory.  mptsas_cleanup_fw_event_q()
will increment its value for items it dequeues and then it may keep a
pointer after dropping the lock.  Invoke cancel_delayed_work_sync() to
cancel the work item and wait if the worker is currently busy. Free the
memory afterwards since it owns the last reference to it.

Link: https://lore.kernel.org/r/20201126132952.2287996-15-bigeasy@linutronix.de
Cc: Sathya Prakash <sathya.prakash@broadcom.com>
Cc: Sreekanth Reddy <sreekanth.reddy@broadcom.com>
Cc: Suganath Prabu Subramani <suganath-prabu.subramani@broadcom.com>
Cc: MPT-FusionLinux.pdl@broadcom.com
Reviewed-by: Daniel Wagner <dwagner@suse.de>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: message: fusion: Remove in_interrupt() usage in mpt_config()
Thomas Gleixner [Thu, 26 Nov 2020 13:29:51 +0000 (14:29 +0100)]
scsi: message: fusion: Remove in_interrupt() usage in mpt_config()

in_interrupt() is referenced all over the place in these drivers. Most of
these references are comments which are outdated and wrong.

Aside of that in_interrupt() is deprecated as it does not provide what the
name suggests. It covers more than hard/soft interrupt servicing context
and is semantically ill defined.

>From reading the mpt_config() code and the history this is clearly a debug
mechanism and should probably be replaced by might_sleep() or completely
removed because such checks are already in the subsequent functions.

Remove the in_interrupt() references and replace the usage in mpt_config()
with might_sleep().

Link: https://lore.kernel.org/r/20201126132952.2287996-14-bigeasy@linutronix.de
Cc: Sathya Prakash <sathya.prakash@broadcom.com>
Cc: Sreekanth Reddy <sreekanth.reddy@broadcom.com>
Cc: Suganath Prabu Subramani <suganath-prabu.subramani@broadcom.com>
Cc: MPT-FusionLinux.pdl@broadcom.com
Reviewed-by: Daniel Wagner <dwagner@suse.de>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: myrs: Remove WARN_ON(in_interrupt())
Ahmed S. Darwish [Thu, 26 Nov 2020 13:29:49 +0000 (14:29 +0100)]
scsi: myrs: Remove WARN_ON(in_interrupt())

The in_interrupt() macro is ill-defined and does not provide what the name
suggests. The usage especially in driver code is deprecated and a tree-wide
effort to clean up and consolidate the (ab)usage of in_interrupt() and
related checks is happening.

In this case the check covers only parts of the contexts in which these
functions cannot be called. It fails to detect preemption or interrupt
disabled invocations.

As wait_for_completion() already contains a broad variety of checks (always
enabled or debug option dependent) which cover all invalid conditions
already, there is no point in having extra inconsistent warnings in
drivers.

Just remove it.

Link: https://lore.kernel.org/r/20201126132952.2287996-12-bigeasy@linutronix.de
Cc: Hannes Reinecke <hare@kernel.org>
Reviewed-by: Daniel Wagner <dwagner@suse.de>
Signed-off-by: Ahmed S. Darwish <a.darwish@linutronix.de>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: myrb: Remove WARN_ON(in_interrupt())
Ahmed S. Darwish [Thu, 26 Nov 2020 13:29:48 +0000 (14:29 +0100)]
scsi: myrb: Remove WARN_ON(in_interrupt())

The in_interrupt() macro is ill-defined and does not provide what the name
suggests. The usage especially in driver code is deprecated and a tree-wide
effort to clean up and consolidate the (ab)usage of in_interrupt() and
related checks is happening.

In this case the check covers only parts of the contexts in which these
functions cannot be called. It fails to detect preemption or interrupt
disabled invocations.

As wait_for_completion() already contains a broad variety of checks (always
enabled or debug option dependent) which cover all invalid conditions
already, there is no point in having extra inconsistent warnings in
drivers.

Just remove it.

Link: https://lore.kernel.org/r/20201126132952.2287996-11-bigeasy@linutronix.de
Cc: Hannes Reinecke <hare@kernel.org>
Reviewed-by: Daniel Wagner <dwagner@suse.de>
Signed-off-by: Ahmed S. Darwish <a.darwish@linutronix.de>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: mpt3sas: Remove in_interrupt()
Ahmed S. Darwish [Thu, 26 Nov 2020 13:29:47 +0000 (14:29 +0100)]
scsi: mpt3sas: Remove in_interrupt()

_scsih_fw_event_cleanup_queue() waits for all outstanding firmware events
wokrqueue handlers to finish. If in_interrupt() is true, it cancels itself
and return early.

That in_interrupt() check is ill-defined and does not provide what the name
suggests: it does not cover all states in which it is safe to block and
call functions like cancel_work_sync().

That check is also not needed: _scsih_fw_event_cleanup_queue() is always
invoked from process context. Below is an analysis of its callers:

  - scsih_remove(), bound to PCI ->remove(), process context

  - scsih_shutdown(), bound to PCI ->shutdown(), process context

  - mpt3sas_scsih_clear_outstanding_scsi_tm_commands(), called by
      => _base_clear_outstanding_commands(), called by
        =>_base_fault_reset_work(), workqueue
        => mpt3sas_base_hard_reset_handler(), locks mutex

Remove the in_interrupt() check. Change _scsih_fw_event_cleanup_queue()
specification to a purely process-context function and mark it with
"Context: task, can sleep".

Link: https://lore.kernel.org/r/20201126132952.2287996-10-bigeasy@linutronix.de
Cc: Sathya Prakash <sathya.prakash@broadcom.com>
Cc: Sreekanth Reddy <sreekanth.reddy@broadcom.com>
Cc: Suganath Prabu Subramani <suganath-prabu.subramani@broadcom.com>
Cc: <MPT-FusionLinux.pdl@broadcom.com>
Reviewed-by: Daniel Wagner <dwagner@suse.de>
Signed-off-by: Ahmed S. Darwish <a.darwish@linutronix.de>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: qla4xxx: Remove in_interrupt() from qla4_82xx_rom_lock()
Ahmed S. Darwish [Thu, 26 Nov 2020 13:29:46 +0000 (14:29 +0100)]
scsi: qla4xxx: Remove in_interrupt() from qla4_82xx_rom_lock()

qla4_82xx_rom_lock() spins on a certain hardware state until it is
updated. At the end of each spin, if in_interrupt() is true, it does 20
loops of cpu_relax(). Otherwise, it yields the CPU.

While in_interrupt() is ill-defined and does not provide what the name
suggests, it is not needed here: qla4_82xx_rom_lock() is always called
from process context. Below is an analysis of its callers:

  - ql4_nx.c: qla4_82xx_rom_fast_read(), all process context callers:
    => ql4_nx.c: qla4_82xx_pinit_from_rom(), GFP_KERNEL allocation
    => ql4_nx.c: qla4_82xx_load_from_flash(), msleep() in a loop

  - ql4_nx.c: qla4_82xx_pinit_from_rom(), earlier discussed

  - ql4_nx.c: qla4_82xx_rom_lock_recovery(), bound to "isp_operations"
    ->rom_lock_recovery() hook, which has one process context caller,
    qla4_8xxx_device_bootstrap(), with callers:
      => ql4_83xx.c: qla4_83xx_need_reset_handler(), process, msleep()
      => ql4_nx.c: qla4_8xxx_device_state_handler(), multiple msleep()s

  - ql4_nx.c: qla4_82xx_read_flash_data(), has cond_resched()

Remove the in_interrupt() check. Mark, qla4_82xx_rom_lock(), and the
->rom_lock_recovery() hook, with "Context: task, can sleep".

Change qla4_82xx_rom_lock() implementation to sleep 20ms, instead of a
schedule(), for each spin. This is more deterministic, and it matches
the other implementations bound to ->rom_lock_recovery().

Link: https://lore.kernel.org/r/20201126132952.2287996-9-bigeasy@linutronix.de
Cc: Nilesh Javali <njavali@marvell.com>
Cc: Manish Rangankar <mrangankar@marvell.com>
Cc: <GR-QLogic-Storage-Upstream@marvell.com>
Reviewed-by: Daniel Wagner <dwagner@suse.de>
Signed-off-by: Ahmed S. Darwish <a.darwish@linutronix.de>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: qla4xxx: Remove in_interrupt() from qla4_82xx_idc_lock()
Ahmed S. Darwish [Thu, 26 Nov 2020 13:29:45 +0000 (14:29 +0100)]
scsi: qla4xxx: Remove in_interrupt() from qla4_82xx_idc_lock()

qla4_82xx_idc_lock() spins on a certain hardware state until it is
updated. At the end of each spin, if in_interrupt() is true, it does 20
loops of cpu_relax(). Otherwise, it yields the CPU.

While in_interrupt() is ill-defined and does not provide what the name
suggests, it is not needed here: qla4_82xx_idc_lock() is always called from
process context. Below is an analysis of its callers:

  - ql4_nx.c: qla4_82xx_need_reset_handler(), 1-second msleep() in a
    loop.

  - ql4_nx.c: qla4_82xx_isp_reset(), calls
    qla4_8xxx_device_state_handler(), which has multiple msleep()s.

Beside direct calls, qla4_82xx_idc_lock() is also bound to isp_operations
->idc_lock() hook. Other functions which are bound to the same hook,
e.g. qla4_83xx_drv_lock(), also have an msleep(). For completeness, below
is an analysis of all callers of that hook:

  - ql4_83xx.c: qla4_83xx_need_reset_handler(), has an msleep()

  - ql4_83xx.c: qla4_83xx_isp_reset(), calls
    qla4_8xxx_device_state_handler(), which has multiple msleep()s.

  - ql4_83xx.c: qla4_83xx_disable_pause(), all process context callers:
    => ql4_mbx.c: qla4xxx_mailbox_command(), msleep(), mutex_lock()
    => ql4_os.c: qla4xxx_recover_adapter(), schedule_timeout() in loop
    => ql4_os.c: qla4xxx_do_dpc(), workqueue context

  - ql4_attr.c: qla4_8xxx_sysfs_write_fw_dump(), sysfs bin_attribute
    ->write() hook, process context

  - ql4_mbx.c: qla4xxx_mailbox_command(), earlier discussed

  - ql4_nx.c: qla4_8xxx_device_bootstrap(), callers:
    => ql4_83xx.c: qla4_83xx_need_reset_handler(), process, msleep()
    => ql4_nx.c: qla4_8xxx_device_state_handler(), earlier discussed

  - ql4_nx.c: qla4_8xxx_need_qsnt_handler(), callers:
    => ql4_nx.c: qla4_8xxx_device_state_handler(), multiple msleep()s
    => ql4_os.c: qla4xxx_do_dpc(), workqueue context

  - ql4_nx.c: qla4_8xxx_update_idc_reg(), callers:
    => ql4_nx.c: qla4_8xxx_device_state_handler(), earlier discussed
    => ql4_os.c: qla4_8xxx_error_recovery(), only called by
    qla4xxx_pci_slot_reset(), which is bound to PCI ->slot_reset()
    process-context hook

  - ql4_nx.c: qla4_8xxx_device_state_handler(), earlier discussed

  - ql4_os.c: qla4xxx_recover_adapter(), earlier discussed

  - ql4_os.c: qla4xxx_do_dpc(), earlier discussed

Remove the in_interrupt() check. Mark, qla4_82xx_idc_lock(), and the
->idc_lock() hook itself, with "Context: task, can sleep".

Change qla4_82xx_idc_lock() implementation to sleep 100ms, instead of a
schedule(), for each spin. This is more deterministic, and it matches other
PCI HW locking functions in the driver.

Link: https://lore.kernel.org/r/20201126132952.2287996-8-bigeasy@linutronix.de
Cc: Nilesh Javali <njavali@marvell.com>
Cc: Manish Rangankar <mrangankar@marvell.com>
Cc: <GR-QLogic-Storage-Upstream@marvell.com>
Reviewed-by: Daniel Wagner <dwagner@suse.de>
Signed-off-by: Ahmed S. Darwish <a.darwish@linutronix.de>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: qla2xxx: Remove in_interrupt() from qla83xx-specific code
Ahmed S. Darwish [Thu, 26 Nov 2020 13:29:44 +0000 (14:29 +0100)]
scsi: qla2xxx: Remove in_interrupt() from qla83xx-specific code

qla83xx_wait_logic() is used to control the frequency of device IDC lock
retries. If in_interrupt() is true, it does 20 loops of cpu_relax().
Otherwise, it sleeps for 100ms and yields the CPU.

While in_interrupt() is ill-defined and does not provide what the name
suggests, it is not needed here: that qla83xx_wait_logic() is exclusively
called by qla83xx_idc_lock() / unlock(), and they always run from process
context. Below is an analysis of all the idc lock/unlock callers, in order
of appearance:

  - qla_os.c:
      qla83xx_nic_core_unrecoverable_work(),
      qla83xx_idc_state_handler_work(),
      qla83xx_nic_core_reset_work(),
      qla83xx_service_idc_aen(), all workqueue context

  - qla_os.c: qla83xx_check_nic_core_fw_alive(), has msleep()

  - qla_os.c: qla83xx_set_drv_presence(), called once from
    qla2x00_abort_isp(), which is bound to process-context ->abort_isp()
    hook. It also invokes wait_for_completion_timeout() through the chain
    qla2x00_configure_hba() => qla24xx_link_initialize() =>
    qla2x00_mailbox_command().

  - qla_os.c: qla83xx_clear_drv_presence(), which is called from
    qla2x00_abort_isp() discussed above, and from qla2x00_remove_one()
    which is PCI process-context ->remove() hook.

  - qla_os.c: qla83xx_need_reset_handler(), has a one second msleep() in
    a loop.

  - qla_os.c: qla83xx_device_bootstrap(), called only by
    qla83xx_idc_state_handler(), which has multiple msleep()
    invocations.

  - qla_os.c: qla83xx_idc_state_handler(), multiple msleep()
    invocations.

  - qla_attr.c: qla2x00_sysfs_write_reset(), sysfs bin_attribute
    ->write() hook, process context

  - qla_init.c: qla83xx_nic_core_fw_load()
      => qla_init.c: qla2x00_initialize_adapter()
        => bound to isp_operations ->initialize_adapter() hook
        ** => qla_os.c: qla2x00_probe_one(), PCI ->probe() process ctx

  - qla_init.c: qla83xx_initiating_reset(), msleep() in a loop.

  - qla_init.c: qla83xx_nic_core_reset(), called by
    qla83xx_nic_core_reset_work(), workqueue context.

Remove the in_interrupt() check, and thus replace the entirety of
qla83xx_wait_logic() with an msleep(QLA83XX_WAIT_LOGIC_MS).

Mark qla83xx_idc_lock() / unlock() with "Context: task, can sleep".

Link: https://lore.kernel.org/r/20201126132952.2287996-7-bigeasy@linutronix.de
Cc: Nilesh Javali <njavali@marvell.com>
Cc: GR-QLogic-Storage-Upstream@marvell.com
Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
Reviewed-by: Daniel Wagner <dwagner@suse.de>
Signed-off-by: Ahmed S. Darwish <a.darwish@linutronix.de>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: target: tcm_qla2xxx: Remove BUG_ON(in_interrupt())
Ahmed S. Darwish [Thu, 26 Nov 2020 13:29:43 +0000 (14:29 +0100)]
scsi: target: tcm_qla2xxx: Remove BUG_ON(in_interrupt())

tcm_qla2xxx_free_session() has a BUG_ON(in_interrupt()).

While in_interrupt() is ill-defined and does not provide what the name
suggests, it is not needed here: the function is always invoked from
workqueue context through "struct qla_tgt_func_tmpl" ->free_session() hook
it is bound to.

The function also calls wait_event_timeout() down the chain, which already
has a might_sleep().

Remove the in_interrupt() check.

Link: https://lore.kernel.org/r/20201126132952.2287996-6-bigeasy@linutronix.de
Cc: Nilesh Javali <njavali@marvell.com>
Cc: <GR-QLogic-Storage-Upstream@marvell.com>
Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
Reviewed-by: Daniel Wagner <dwagner@suse.de>
Signed-off-by: Ahmed S. Darwish <a.darwish@linutronix.de>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: qla2xxx: Remove in_interrupt() from qla82xx-specific code
Ahmed S. Darwish [Thu, 26 Nov 2020 13:29:42 +0000 (14:29 +0100)]
scsi: qla2xxx: Remove in_interrupt() from qla82xx-specific code

qla82xx_idc_lock() spins on a certain hardware state until it's updated. At
the end of each spin, if in_interrupt() is true, it does 20 loops of
cpu_relax(). Otherwise, it yields the CPU.

While in_interrupt() is ill-defined and does not provide what the name
suggests, it is not needed here: qla82xx_idc_lock() is always called from
process context. Below is an analysis of its callers, in order of
appearance:

  - qla_nx.c: qla82xx_device_bootstrap(), only called by
    qla82xx_device_state_handler(), has multiple msleep()s.

  - qla_nx.c: qla82xx_need_qsnt_handler(), has one second msleep()

  - qla_nx.c: qla82xx_wait_for_state_change(), one second msleep()

  - qla_nx.c: qla82xx_need_reset_handler(), can sleep up to 10 seconds

  - qla_nx.c: qla82xx_device_state_handler(), has multiple msleep()s

  - qla_nx.c: qla82xx_abort_isp(), if it's a qla82xx controller, calls
    qla82xx_device_state_handler(), which sleeps. It's also bound to
    isp_operations ->abort_isp() hook, where all the callers are in process
    context.

  - qla_nx.c: qla82xx_beacon_on(), bound to isp_operations ->beacon_on()
    hook.  That hook is only called once, in a mutex locked context, from
    qla2x00_beacon_store().

  - qla_nx.c: qla82xx_beacon_off(), bound to isp_operations ->beacon_off()
    hook.  Like ->beacon_on(), it's only called once, in a mutex locked
    context, from qla2x00_beacon_store().

  - qla_nx.c: qla82xx_fw_dump(), calls qla2x00_wait_for_chip_reset(), which
    has msleep() in a loop. It is bound to isp_operations ->fw_dump()
    hook. That hook *is* called from atomic context at qla_isr.c by
    multiple interrupt handlers. Nonetheless, it's other controllers
    interrupt handlers, and not the qla82xx.

  - qla82xx_msix_default() and qla82xx_msix_rsp_q() call
    qla24xx_process_response_queue() which doesn't implement the firmware
    dumping.

  - qla_attr.c: qla2x00_sysfs_write_fw_dump(), and
    qla2x00_sysfs_write_reset(), process-context sysfs ->write() hooks.

  - qla_os.c: qla2x00_probe_one(). PCI ->probe(), process context.

  - qla_os.c: qla2x00_clear_drv_active(), called solely from
    qla2x00_remove_one(), which is PCI ->remove() hook, process context.

  - qla_os.c: qla2x00_do_dpc(), kthread function, process context.

Remove the in_interrupt() check. Change qla82xx_idc_lock() specification to
a purely process-context function. Mark it with "Context: task, might
sleep".

Change qla82xx_idc_lock() implementation to sleep 100ms, instead of a
schedule(), for each spin. This is more deterministic, and it matches the
other qla models idc_lock() functions.

Link: https://lore.kernel.org/r/20201126132952.2287996-5-bigeasy@linutronix.de
Cc: Nilesh Javali <njavali@marvell.com>
Cc: <GR-QLogic-Storage-Upstream@marvell.com>
Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
Reviewed-by: Daniel Wagner <dwagner@suse.de>
Signed-off-by: Ahmed S. Darwish <a.darwish@linutronix.de>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: qla4xxx: Remove in_interrupt()
Ahmed S. Darwish [Thu, 26 Nov 2020 13:29:41 +0000 (14:29 +0100)]
scsi: qla4xxx: Remove in_interrupt()

qla4_82xx_crb_win_lock() spins on a certain hardware state until it's
updated. At the end of each spin, if in_interrupt() is true, it does 20
loops of cpu_relax(). Otherwise, it yields the CPU.

The in_interrupt() macro is ill-defined as it does not provide what the
name suggests, and it does not catch the intended use-case here.

qla4_82xx_crb_win_lock() is always invoked with scsi_qla_host::hw_lock
acquired, with disabled interrupts. If the caller is in process context, as
in qla4_82xx_need_reset_handler(), then in_interrupt() will return false
even though it is not allowed to call schedule().

Remove the in_interrupt() check.

Change qla4_82xx_crb_win_lock() specification to a purely atomic
function. Mark it as static, remove its forward declaration, and move it
above its callers. To avoid hammering the PCI bus while spinning, use a 10
micro-second delay instead of cpu_relax().

Link: https://lore.kernel.org/r/20201126132952.2287996-4-bigeasy@linutronix.de
Fixes: f4f5df23bf72 ("[SCSI] qla4xxx: Added support for ISP82XX")
Cc: Nilesh Javali <njavali@marvell.com>
Cc: Manish Rangankar <mrangankar@marvell.com>
Cc: <GR-QLogic-Storage-Upstream@marvell.com>
Reviewed-by: Daniel Wagner <dwagner@suse.de>
Signed-off-by: Ahmed S. Darwish <a.darwish@linutronix.de>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: hisi_sas: Remove preemptible()
Ahmed S. Darwish [Thu, 26 Nov 2020 13:29:40 +0000 (14:29 +0100)]
scsi: hisi_sas: Remove preemptible()

hisi_sas_task_exec() uses preemptible() to see if it's safe to block.  This
does not work for CONFIG_PREEMPT_COUNT=n kernels in which preemptible()
always returns 0.

The problem is masked when enabling some of the common Kconfig.debug
options (like CONFIG_DEBUG_ATOMIC_SLEEP), as they implicitly enable the
preemption counter.

In general, driver leaf functions should not make logic decisions based on
the context they're called from. The caller should be the entity
responsible for explicitly indicating context.

Since hisi_sas_task_exec() already has a gfp_t flags parameter, use it as
the explicit context marker.

Link: https://lore.kernel.org/r/20201126132952.2287996-3-bigeasy@linutronix.de
Fixes: 214e702d4b70 ("scsi: hisi_sas: Adjust task reject period during host reset")
Fixes: 550c0d89d52d ("scsi: hisi_sas: Replace in_softirq() check in hisi_sas_task_exec()")
Cc: Xiaofei Tan <tanxiaofei@huawei.com>
Cc: Xiang Chen <chenxiang66@hisilicon.com>
Cc: John Garry <john.garry@huawei.com>
Acked-by: John Garry <john.garry@huawei.com>
Signed-off-by: Ahmed S. Darwish <a.darwish@linutronix.de>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: pm80xx: Do not sleep in atomic context
Ahmed S. Darwish [Thu, 26 Nov 2020 13:29:39 +0000 (14:29 +0100)]
scsi: pm80xx: Do not sleep in atomic context

hw_event_sas_phy_up() is used in hardirq/softirq context:

 pm8001_interrupt_handler_msix() || pm8001_interrupt_handler_intx() || pm8001_tasklet
   => PM8001_CHIP_DISP->isr() = pm80xx_chip_isr()
     => process_oq() [spin_lock_irqsave(&pm8001_ha->lock,)]
       => process_one_iomb()
         => mpi_hw_event()
           => hw_event_sas_phy_up()
             => msleep(200)

Revert the msleep() back to an mdelay() to avoid sleeping in atomic
context.

Link: https://lore.kernel.org/r/20201126132952.2287996-2-bigeasy@linutronix.de
Fixes: 4daf1ef3c681 ("scsi: pm80xx: Convert 'long' mdelay to msleep")
Cc: Vikram Auradkar <auradkar@google.com>
Cc: Jack Wang <jinpu.wang@cloud.ionos.com>
Acked-by: Jack Wang <jinpu.wang@cloud.ionos.com>
Signed-off-by: Ahmed S. Darwish <a.darwish@linutronix.de>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: ufs: Remove unnecessary if condition in ufshcd_suspend()
Bean Huo [Wed, 25 Nov 2020 18:53:00 +0000 (19:53 +0100)]
scsi: ufs: Remove unnecessary if condition in ufshcd_suspend()

In the case that auto_bkops_enable is false, which means auto bkops has
been disabled, there is no need to call ufshcd_disable_auto_bkops().

Link: https://lore.kernel.org/r/20201125185300.3394-1-huobean@gmail.com
Reviewed-by: Stanley Chu <stanley.chu@mediatek.com>
Reviewed-by: Can Guo <cang@codeaurora.org>
Signed-off-by: Bean Huo <beanhuo@micron.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: hisi_sas: Move debugfs code to v3 hw driver
Luo Jiaxing [Tue, 24 Nov 2020 08:46:34 +0000 (16:46 +0800)]
scsi: hisi_sas: Move debugfs code to v3 hw driver

Relocate all the debugfs code for DFX to v3 hw since no other versions
support it.

Link: https://lore.kernel.org/r/1606207594-196362-4-git-send-email-john.garry@huawei.com
Signed-off-by: Luo Jiaxing <luojiaxing@huawei.com>
Signed-off-by: John Garry <john.garry@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: hisi_sas: Fix up probe error handling for v3 hw
Xiang Chen [Tue, 24 Nov 2020 08:46:33 +0000 (16:46 +0800)]
scsi: hisi_sas: Fix up probe error handling for v3 hw

Fix some rollbacks in function hisi_sas_v3_probe() and
interrupt_init_v3_hw().

Link: https://lore.kernel.org/r/1606207594-196362-3-git-send-email-john.garry@huawei.com
Fixes: 8d98416a55eb ("scsi: hisi_sas: Switch v3 hw to MQ")
Signed-off-by: Xiang Chen <chenxiang66@hisilicon.com>
Signed-off-by: John Garry <john.garry@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: hisi_sas: Reduce some indirection in v3 hw driver
John Garry [Tue, 24 Nov 2020 08:46:32 +0000 (16:46 +0800)]
scsi: hisi_sas: Reduce some indirection in v3 hw driver

Sometimes local functions are called indirectly from the hw driver, which
only makes the code harder to follow. Remove these.

Method .hw_init is only called from platform driver probe, which is not
relevant, so don't set this either.

Link: https://lore.kernel.org/r/1606207594-196362-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>
3 years agoscsi: pm8001: Remove space in a debug message
Colin Ian King [Tue, 24 Nov 2020 09:38:28 +0000 (09:38 +0000)]
scsi: pm8001: Remove space in a debug message

There are two words that need separating with a space in a pm8001_dbg()
message. Fix it.

Link: https://lore.kernel.org/r/20201124093828.307709-1-colin.king@canonical.com
Reviewed-by: Ewan D. Milne <emilne@redhat.com>
Acked-by: Jack Wang <jinpu.wang@cloud.ionos.com>
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: pm8001: Fix misindentation
Joe Perches [Tue, 24 Nov 2020 04:36:04 +0000 (20:36 -0800)]
scsi: pm8001: Fix misindentation

kernel robot reported a misindentation of a goto.

Fix it.

At the same time, use a temporary for a repeated entry in the same block to
reduce visual noise.

Link: https://lore.kernel.org/r/9542a8be9954c1dca744f93f53bb1af6dd1436e8.1606192458.git.joe@perches.com
Reported-by: kernel test robot <lkp@intel.com>
Acked-by: Jack Wang <jinpu.wang@cloud.ionos.com>
Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: pm8001: Convert pm8001_printk() to pm8001_info()
Joe Perches [Tue, 24 Nov 2020 04:36:03 +0000 (20:36 -0800)]
scsi: pm8001: Convert pm8001_printk() to pm8001_info()

Use the more common logging style.

[mkp: fixed a few conflicts]

Link: https://lore.kernel.org/r/69dc34ff63adfa60b3f203ed2d58143b5692af57.1606192458.git.joe@perches.com
Acked-by: Jack Wang <jinpu.wang@cloud.ionos.com>
Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
3 years agoscsi: pmcraid: Use generic power management
Vaibhav Gupta [Mon, 2 Nov 2020 16:47:30 +0000 (22:17 +0530)]
scsi: pmcraid: Use generic power management

Drivers should do only device-specific jobs. But in general, drivers using
legacy PCI PM framework for .suspend()/.resume() have to manage many PCI
PM-related tasks themselves which can be done by PCI Core itself. This
brings extra load on the driver and it directly calls PCI helper functions
to handle them.

Switch to the new generic framework by updating function signatures and
define a "struct dev_pm_ops" variable to bind PM callbacks. Also, remove
unnecessary calls to the PCI Helper functions along with the legacy
.suspend & .resume bindings.

Link: https://lore.kernel.org/r/20201102164730.324035-30-vaibhavgupta40@gmail.com
Signed-off-by: Vaibhav Gupta <vaibhavgupta40@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>