platform/kernel/linux-starfive.git
2 years agoscsi: mpi3mr: Increase cmd_per_lun to 128
Sreekanth Reddy [Tue, 28 Jun 2022 07:48:48 +0000 (13:18 +0530)]
scsi: mpi3mr: Increase cmd_per_lun to 128

Increase cmd_per_lun to 128.

Link: https://lore.kernel.org/r/20220628074848.5036-3-sreekanth.reddy@broadcom.com
Signed-off-by: Sreekanth Reddy <sreekanth.reddy@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 years agoscsi: mpi3mr: Enable shared host tagset
Sreekanth Reddy [Tue, 28 Jun 2022 07:48:47 +0000 (13:18 +0530)]
scsi: mpi3mr: Enable shared host tagset

Enable shared host tagset to make sure that total outstanding I/O count can
not exceed controller's can_queue setting.

Link: https://lore.kernel.org/r/20220628074848.5036-2-sreekanth.reddy@broadcom.com
Signed-off-by: Sreekanth Reddy <sreekanth.reddy@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 years agoscsi: qla2xxx: Check correct variable in qla24xx_async_gffid()
Dan Carpenter [Wed, 22 Jun 2022 06:21:55 +0000 (09:21 +0300)]
scsi: qla2xxx: Check correct variable in qla24xx_async_gffid()

There is a copy and paste bug here.  It should check ".rsp" instead of
".req".  The error message is copy and pasted as well so update that too.

Link: https://lore.kernel.org/r/YrK1A/t3L6HKnswO@kili
Fixes: 9c40c36e75ff ("scsi: qla2xxx: edif: Reduce Initiator-Initiator thrashing")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 years agoscsi: ufs: ufs-qcom: Remove unneeded code
ChanWoo Lee [Mon, 27 Jun 2022 23:55:45 +0000 (08:55 +0900)]
scsi: ufs: ufs-qcom: Remove unneeded code

Checks information about tx_lanes, but is not used.

Since commit 1e1e465c6d23 ("scsi/ufs: qcom: Remove ufs_qcom_phy_*() calls
from host"), tx_lanes is deprecated.

As a result, ufs_qcom_link_startup_notify -> POST_CHANGE action does
nothing.  If it is not going to be updated, it can be removed.

Link: https://lore.kernel.org/r/20220627235545.16943-1-cw9316.lee@samsung.com
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: ChanWoo Lee <cw9316.lee@samsung.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 years agoscsi: ufs: ufs-mediatek: Fix invalid access to vccqx
Alice Chao [Thu, 23 Jun 2022 03:50:52 +0000 (11:50 +0800)]
scsi: ufs: ufs-mediatek: Fix invalid access to vccqx

NULL pointer access issue was found for the regulator released
by ufs_mtk_vreg_fix_vccq(). Simply fix this issue by clearing
the released vreg pointer in ufs_hba struct.

Link: https://lore.kernel.org/r/20220623035052.18802-9-stanley.chu@mediatek.com
Reviewed-by: Stanley Chu <stanley.chu@mediatek.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Alice Chao <alice.chao@mediatek.com>
Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 years agoscsi: ufs: ufs-mediatek: Support performance boosting
Peter Wang [Thu, 23 Jun 2022 03:50:51 +0000 (11:50 +0800)]
scsi: ufs: ufs-mediatek: Support performance boosting

Add pm-qos request to support performance boosting in MediaTek UFS
platforms.

At the same time, adjust the order of function calls to be symmetric during
the low-power control flow.

Link: https://lore.kernel.org/r/20220623035052.18802-8-stanley.chu@mediatek.com
Reviewed-by: Stanley Chu <stanley.chu@mediatek.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Peter Wang <peter.wang@mediatek.com>
Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 years agoscsi: ufs: ufs-mediatek: Support host power control
Po-Wen Kao [Thu, 23 Jun 2022 03:50:50 +0000 (11:50 +0800)]
scsi: ufs: ufs-mediatek: Support host power control

Add interfaces for controlling the host power to optimize the power
consumption in MediaTek UFS platforms.

Link: https://lore.kernel.org/r/20220623035052.18802-7-stanley.chu@mediatek.com
Reviewed-by: Stanley Chu <stanley.chu@mediatek.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Po-Wen Kao <powen.kao@mediatek.com>
Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 years agoscsi: ufs: ufs-mediatek: Disable reset confirm feature by UniPro
Po-Wen Kao [Thu, 23 Jun 2022 03:50:49 +0000 (11:50 +0800)]
scsi: ufs: ufs-mediatek: Disable reset confirm feature by UniPro

In MediaTek UFS platforms, UniPro will not return reset confirm if it is in
POWERDOWN state thus hang issue may happen while disabling UFSHCI. Simply
disable this feature before UniPro leaves POWERDOWN state.

Link: https://lore.kernel.org/r/20220623035052.18802-6-stanley.chu@mediatek.com
Reviewed-by: Stanley Chu <stanley.chu@mediatek.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Po-Wen Kao <powen.kao@mediatek.com>
Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 years agoscsi: ufs: ufs-mediatek: Add stage information for ref-clk control
Peter Wang [Thu, 23 Jun 2022 03:50:48 +0000 (11:50 +0800)]
scsi: ufs: ufs-mediatek: Add stage information for ref-clk control

Add "PRE_CHANGE" and "POST_CHANGE" information for ref-clk control to
precisely configure the low-power state of the parent of ref-clk.

Link: https://lore.kernel.org/r/20220623035052.18802-5-stanley.chu@mediatek.com
Reviewed-by: Stanley Chu <stanley.chu@mediatek.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Peter Wang <peter.wang@mediatek.com>
Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 years agoscsi: ufs: ufs-mediatek: Prevent host hang by setting CLK_CG early
Peter Wang [Thu, 23 Jun 2022 03:50:47 +0000 (11:50 +0800)]
scsi: ufs: ufs-mediatek: Prevent host hang by setting CLK_CG early

Some UFSHCI hosts in MediaTek UFS platform need workaround to prevent host
hang issue by setting CLK_CG bit before host is enabled.

This operation shall have no side effect on those platforms which do not
support this bit.

Link: https://lore.kernel.org/r/20220623035052.18802-4-stanley.chu@mediatek.com
Reviewed-by: Stanley Chu <stanley.chu@mediatek.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Peter Wang <peter.wang@mediatek.com>
Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 years agoscsi: ufs: ufs-mediatek: Always add delays for VCC operations
Peter Wang [Thu, 23 Jun 2022 03:50:46 +0000 (11:50 +0800)]
scsi: ufs: ufs-mediatek: Always add delays for VCC operations

MediaTek decides to always add delays before and after VCC is turned-off.

Link: https://lore.kernel.org/r/20220623035052.18802-3-stanley.chu@mediatek.com
Reviewed-by: Stanley Chu <stanley.chu@mediatek.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Peter Wang <peter.wang@mediatek.com>
Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 years agoscsi: ufs: ufs-mediatek: Fix build warnings
Stanley Chu [Thu, 23 Jun 2022 03:50:45 +0000 (11:50 +0800)]
scsi: ufs: ufs-mediatek: Fix build warnings

Fix build warnings:

1.
../drivers/ufs/host/ufs-mediatek.c:1375:5: error: no previous prototype for function 'ufs_mtk_system_suspend' [-Werror,-Wmissing-prototypes]
int ufs_mtk_system_suspend(struct device *dev)
    ^
../drivers/ufs/host/ufs-mediatek.c:1375:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
int ufs_mtk_system_suspend(struct device *dev)
^
static

2.
../drivers/ufs/host/ufs-mediatek.c:702:50: error: format specifies type 'unsigned long' but the argument has type 'int' [-Werror,-Wformat]
                snprintf(vcc_name, MAX_VCC_NAME, "vcc-ufs%lu", ver);
                                                         ~~~   ^~~
                                                         %d

Link: https://lore.kernel.org/r/20220623035052.18802-2-stanley.chu@mediatek.com
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 years agoscsi: dpt_i2o: Remove obsolete driver
Arnd Bergmann [Fri, 24 Jun 2022 15:52:25 +0000 (17:52 +0200)]
scsi: dpt_i2o: Remove obsolete driver

The dpt_i2o driver was fixed to stop using virt_to_bus() in 2008, but it
still has a stale reference in an error handling code path that could never
work. I submitted a patch to fix this reference earlier, but Hannes
Reinecke suggested that removing the driver may be just as good here.

The i2o driver layer was removed in 2015 with commit 4a72a7af462d
("staging: remove i2o subsystem"), but the even older dpt_i2o scsi driver
stayed around.

The last non-cleanup patches I could find were from Miquel van Smoorenburg
and Mark Salyzyn back in 2008, they might know if there is any chance of
the hardware still being used anywhere.

Link: https://lore.kernel.org/linux-scsi/CAK8P3a1XfwkTOV7qOs1fTxf4vthNBRXKNu8A5V7TWnHT081NGA@mail.gmail.com/T/
Link: https://lore.kernel.org/r/20220624155226.2889613-3-arnd@kernel.org
Cc: Miquel van Smoorenburg <mikevs@xs4all.net>
Cc: Mark Salyzyn <salyzyn@android.com>
Cc: Hannes Reinecke <hare@suse.de>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 years agoscsi: BusLogic: Remove bus_to_virt()
Arnd Bergmann [Fri, 24 Jun 2022 15:52:24 +0000 (17:52 +0200)]
scsi: BusLogic: Remove bus_to_virt()

The BusLogic driver is the last remaining driver that relies on the
deprecated bus_to_virt() function, which in turn only works on a few
architectures, and is incompatible with both swiotlb and iommu support.

Before commit 391e2f25601e ("[SCSI] BusLogic: Port driver to 64-bit."), the
driver had a dependency on x86-32, presumably because of this
problem. However, the change introduced another bug that made it still
impossible to use the driver on any 64-bit machine.

This was in turn fixed in commit 56f396146af2 ("scsi: BusLogic: Fix 64-bit
system enumeration error for Buslogic"), 8 years later, which shows that
there are not a lot of users.

Maciej is still using the driver on 32-bit hardware, and Khalid mentioned
that the driver works with the device emulation used in VirtualBox and
VMware. Both of those only emulate it for Windows 2000 and older operating
systems that did not ship with the better LSI logic driver.

Do a minimum fix that searches through the list of descriptors to find one
that matches the bus address. This is clearly as inefficient as was
indicated in the code comment about the lack of a bus_to_virt()
replacement. A better fix would likely involve changing out the entire
descriptor allocation for a simpler one, but that would be much more
invasive.

Link: https://lore.kernel.org/r/20220624155226.2889613-2-arnd@kernel.org
Cc: Maciej W. Rozycki <macro@orcam.me.uk>
Cc: Matt Wang <wwentao@vmware.com>
Tested-by: Khalid Aziz <khalid@gonehiking.org>
Reviewed-by: Robin Murphy <robin.murphy@arm.com>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Acked-by: Khalid Aziz <khalid@gonehiking.org>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 years agoscsi: fcoe: Remove redundant assignment to variable 'wlen'
Colin Ian King [Thu, 23 Jun 2022 16:47:10 +0000 (17:47 +0100)]
scsi: fcoe: Remove redundant assignment to variable 'wlen'

Variable wlen is being assigned a value that is never read, it is being
re-assigned with a different value later on. The assignment is redundant
and can be removed.

Cleans up clang scan build warning:
drivers/scsi/fcoe/fcoe.c:1491:2: warning: Value stored to 'wlen'
is never read [deadcode.DeadStores]

Link: https://lore.kernel.org/r/20220623164710.76831-1-colin.i.king@gmail.com
Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 years agoscsi: ufs: ufshcd: Constify pointed data
Krzysztof Kozlowski [Thu, 23 Jun 2022 10:24:32 +0000 (12:24 +0200)]
scsi: ufs: ufshcd: Constify pointed data

For code safety, constify arrays and pointers to data which is not
modified.

Link: https://lore.kernel.org/r/20220623102432.108059-4-krzysztof.kozlowski@linaro.org
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 years agoscsi: ufs: ufshcd-pltfrm: Constify pointed data
Krzysztof Kozlowski [Thu, 23 Jun 2022 10:24:31 +0000 (12:24 +0200)]
scsi: ufs: ufshcd-pltfrm: Constify pointed data

For code safety, constify pointers to data which is not modified.

Link: https://lore.kernel.org/r/20220623102432.108059-3-krzysztof.kozlowski@linaro.org
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 years agoscsi: MAINTAINERS: Update cxgb3i and cxgb4i maintainer
Varun Prakash [Sun, 12 Jun 2022 12:13:40 +0000 (17:43 +0530)]
scsi: MAINTAINERS: Update cxgb3i and cxgb4i maintainer

Link: https://lore.kernel.org/r/20220612121340.6746-1-varun@chelsio.com
Signed-off-by: Varun Prakash <varun@chelsio.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 years agoscsi: mpt3sas: Remove flush_scheduled_work() call
Tetsuo Handa [Thu, 9 Jun 2022 13:26:48 +0000 (22:26 +0900)]
scsi: mpt3sas: Remove flush_scheduled_work() call

It seems to me that mpt3sas driver is using dedicated workqueues and is not
calling schedule{,_delayed}_work{,_on}(). Then, there will be no work to
flush using flush_scheduled_work().

Link: https://lore.kernel.org/r/f3b97c7c-1094-4e46-20d8-4321716d6f3f@I-love.SAKURA.ne.jp
Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 years agoscsi: trace: Print driver_tag and scheduler_tag in SCSI trace
Changyuan Lyu [Tue, 21 Jun 2022 18:11:25 +0000 (18:11 +0000)]
scsi: trace: Print driver_tag and scheduler_tag in SCSI trace

Trace events like scsi_dispatch_cmd_start and scsi_dispatch_cmd_done are
useful for tracking a command throughout its lifetime. But for some ATA
passthrough commands, the information printed in current logs is not enough
to identify and match them. For example, if two threads send SMART cmd to
the same disk at the same time, their trace logs may look the same, which
makes it hard to match scsi_dispatch_cmd_done and scsi_dispatch_cmd_start.

Printing tags can help us solve the problem.  Further, if a command failed
for some reason and then is retried, its driver_tag will change. So
scheduler_tag is also included such that we can track the retries of a
command.

Link: https://lore.kernel.org/r/20220621181125.3211399-1-changyuanl@google.com
Reviewed-by: Vishakha Channapattan <vishakhavc@google.com>
Reviewed-by: Jolly Shah <jollys@google.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Changyuan Lyu <changyuanl@google.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 years agoscsi: sym53c8xx_2: Remove redundant "with"
Jiang Jian [Tue, 21 Jun 2022 16:26:31 +0000 (00:26 +0800)]
scsi: sym53c8xx_2: Remove redundant "with"

Remove redundant "with" in comment

Link: https://lore.kernel.org/r/20220621162631.25353-1-jiangjian@cdjrlc.com
Signed-off-by: Jiang Jian <jiangjian@cdjrlc.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 years agoscsi: snic: Remove redundant "on"
Jiang Jian [Tue, 21 Jun 2022 15:01:36 +0000 (23:01 +0800)]
scsi: snic: Remove redundant "on"

Remove redundant "on" in comment.

Link: https://lore.kernel.org/r/20220621150136.9264-1-jiangjian@cdjrlc.com
Signed-off-by: Jiang Jian <jiangjian@cdjrlc.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 years agoscsi: ufs: core: Fix typos in error messages
Wolfram Sang [Tue, 21 Jun 2022 14:46:53 +0000 (16:46 +0200)]
scsi: ufs: core: Fix typos in error messages

Should be "retries" instead of "retires".

Link: https://lore.kernel.org/r/20220621144653.62630-1-wsa+renesas@sang-engineering.com
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 years agoscsi: aacraid: Remove redundant "the"
Jiang Jian [Tue, 21 Jun 2022 14:23:46 +0000 (22:23 +0800)]
scsi: aacraid: Remove redundant "the"

Remove redundant "the" in comment.

Link: https://lore.kernel.org/r/20220621142346.6429-1-jiangjian@cdjrlc.com
Signed-off-by: Jiang Jian <jiangjian@cdjrlc.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 years agoscsi: target: Remove duplicate "the"
Jiang Jian [Tue, 21 Jun 2022 14:20:12 +0000 (22:20 +0800)]
scsi: target: Remove duplicate "the"

Remove redundant "the" in comment".

Link: https://lore.kernel.org/r/20220621142012.4622-1-jiangjian@cdjrlc.com
Signed-off-by: Jiang Jian <jiangjian@cdjrlc.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 years agoscsi: message: fusion: Drop redundant "the"
Jiang Jian [Tue, 21 Jun 2022 10:31:19 +0000 (18:31 +0800)]
scsi: message: fusion: Drop redundant "the"

Redundant "the" in the comments can be dropped.

Link: https://lore.kernel.org/r/20220621103119.91492-1-jiangjian@cdjrlc.com
Signed-off-by: Jiang Jian <jiangjian@cdjrlc.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 years agoscsi: hisi_sas: Align comments
Jiang Jian [Tue, 21 Jun 2022 07:24:05 +0000 (15:24 +0800)]
scsi: hisi_sas: Align comments

Properly align comment lines in slot_index_alloc_quirk_v2_hw().

Link: https://lore.kernel.org/r/20220621072405.34394-1-jiangjian@cdjrlc.com
Signed-off-by: Jiang Jian <jiangjian@cdjrlc.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 years agoscsi: mpt3sas: Fix whitespace and spelling mistake
Zhang Jiaming [Fri, 17 Jun 2022 10:11:03 +0000 (18:11 +0800)]
scsi: mpt3sas: Fix whitespace and spelling mistake

There is a spelling mistake in _base_sas_ioc_info(). Change 'cant' to
'can't'.

Also fix up whitespace.

Link: https://lore.kernel.org/r/20220617101103.3162-1-jiaming@nfschina.com
Signed-off-by: Zhang Jiaming <jiaming@nfschina.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 years agoscsi: mpt3sas: Fix typo in comment
Ren Yu [Fri, 17 Jun 2022 08:15:57 +0000 (16:15 +0800)]
scsi: mpt3sas: Fix typo in comment

Spelling mistake in comment: non-succesfull -> non-successful.

Link: https://lore.kernel.org/r/20220617081557.9009-1-renyu@nfschina.com
Signed-off-by: Ren Yu <renyu@nfschina.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 years agoscsi: core: bsg: Remove usage of the deprecated ida_simple_xxx() API
Bo Liu [Fri, 17 Jun 2022 02:04:30 +0000 (22:04 -0400)]
scsi: core: bsg: Remove usage of the deprecated ida_simple_xxx() API

Use ida_alloc_xxx()/ida_free() instead of
ida_simple_get()/ida_simple_remove().

The latter is deprecated and more verbose.

Link: https://lore.kernel.org/r/20220617020430.2300-1-liubo03@inspur.com
Signed-off-by: Bo Liu <liubo03@inspur.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 years agoscsi: libiscsi: Improve conn_send_pdu API
Mike Christie [Thu, 16 Jun 2022 22:45:57 +0000 (17:45 -0500)]
scsi: libiscsi: Improve conn_send_pdu API

The conn_send_pdu API is evil in that it returns a pointer to an
iscsi_task, but that task might have been freed already so you can't touch
it. This patch splits the task allocation and transmission, so functions
like iscsi_send_nopout() can access the task before its sent and do
whatever bookkeeping is needed before it is sent.

Link: https://lore.kernel.org/r/20220616224557.115234-10-michael.christie@oracle.com
Reviewed-by: Lee Duncan <lduncan@suse.com>
Signed-off-by: Mike Christie <michael.christie@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 years agoscsi: iscsi: Try to avoid taking back_lock in xmit path
Mike Christie [Thu, 16 Jun 2022 22:45:56 +0000 (17:45 -0500)]
scsi: iscsi: Try to avoid taking back_lock in xmit path

We need the back lock when freeing a task, so we hold it when calling
__iscsi_put_task() from the completion path to make it easier and to avoid
having to retake it in that path. For iscsi_put_task() we just grabbed it
while also doing the decrement on the refcount but it's only really needed
if the refcount is zero and we free the task. This modifies
iscsi_put_task() to just take the lock when needed then has the xmit path
use it. Normally we will then not take the back lock from the xmit path. It
will only be rare cases where the network is so fast that we get a response
right after we send the header/data.

Link: https://lore.kernel.org/r/20220616224557.115234-9-michael.christie@oracle.com
Reviewed-by: Lee Duncan <lduncan@suse.com>
Signed-off-by: Mike Christie <michael.christie@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 years agoscsi: iscsi: Remove iscsi_get_task back_lock requirement
Mike Christie [Thu, 16 Jun 2022 22:45:55 +0000 (17:45 -0500)]
scsi: iscsi: Remove iscsi_get_task back_lock requirement

We currently require that the back_lock is held when calling the functions
that manipulate the iscsi_task refcount. The only reason for this is to
handle races where we are handling SCSI-ml EH callbacks and the cmd is
completing at the same time the normal completion path is running, and we
can't return from the EH callback until the driver has stopped accessing
the cmd. Holding the back_lock while also accessing the task->state made it
simple to check that a cmd is completing and also get/put a refcount at the
same time, and at the time we were not as concerned about performance.

The problem is that we don't want to take the back_lock from the xmit path
for normal I/O since it causes contention with the completion path if the
user has chosen to try and split those paths on different CPUs (in this
case abusing the CPUs and ignoring caching improves perf for some uses).

Begins to remove the back_lock requirement for iscsi_get/put_task by
removing the requirement for the get path. Instead of always holding the
back_lock we detect if something has done the last put and is about to call
iscsi_free_task(). A subsequent commit will then allow iSCSI code to do the
last put on a task and only grab the back_lock if the refcount is now zero
and it's going to call iscsi_free_task().

Link: https://lore.kernel.org/r/20220616224557.115234-8-michael.christie@oracle.com
Reviewed-by: Lee Duncan <lduncan@suse.com>
Signed-off-by: Mike Christie <michael.christie@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 years agoscsi: iscsi: Remove unneeded task state check
Mike Christie [Thu, 16 Jun 2022 22:45:54 +0000 (17:45 -0500)]
scsi: iscsi: Remove unneeded task state check

Commit 5923d64b7ab6 ("scsi: libiscsi: Drop taskqueuelock") added an extra
task->state because for commit 6f8830f5bbab ("scsi: libiscsi: add lock
around task lists to fix list corruption regression") we didn't know why we
ended up with cmds on the list and thought it might have been a bad target
sending a response while we were still sending the cmd. We were never able
to get a target to send us a response early, because it turns out the bug
was just a race in libiscsi/libiscsi_tcp where:

 1. iscsi_tcp_r2t_rsp() queues a r2t to tcp_task->r2tqueue.

 2. iscsi_tcp_task_xmit() runs iscsi_tcp_get_curr_r2t() and sees we have a
    r2t. It dequeues it and iscsi_tcp_task_xmit() starts to process it.

 3. iscsi_tcp_r2t_rsp() runs iscsi_requeue_task() and puts the task on the
    requeue list.

 4. iscsi_tcp_task_xmit() sends the data for r2t. This is the final chunk
    of data, so the cmd is done.

 5. target sends the response.

 6. On a different CPU from #3, iscsi_complete_task() processes the
    response.  Since there was no common lock for the list, the lists/tasks
    pointers are not fully in sync, so could end up with list corruption.

Since it was just a race on our side, remove the extra check and fix up the
comments.

Link: https://lore.kernel.org/r/20220616224557.115234-7-michael.christie@oracle.com
Reviewed-by: Wu Bo <wubo40@huawei.com>
Reviewed-by: Lee Duncan <lduncan@suse.com>
Signed-off-by: Mike Christie <michael.christie@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 years agoscsi: iscsi_tcp: Drop target_alloc use
Mike Christie [Thu, 16 Jun 2022 22:45:53 +0000 (17:45 -0500)]
scsi: iscsi_tcp: Drop target_alloc use

For software iSCSI, we do a session per host so there is no need to set the
target's can_queue since it's the same as the host one. Setting it just
results in extra atomic checks in the main I/O path.

Link: https://lore.kernel.org/r/20220616224557.115234-6-michael.christie@oracle.com
Reviewed-by: Lee Duncan <lduncan@suse.com>
Reviewed-by: Wu Bo <wubo40@huawei.com>
Signed-off-by: Mike Christie <michael.christie@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 years agoscsi: iscsi_tcp: Tell net when there's more data
Mike Christie [Thu, 16 Jun 2022 22:45:52 +0000 (17:45 -0500)]
scsi: iscsi_tcp: Tell net when there's more data

If we have more data, set the MSG_SENDPAGE_NOTLAST in case we go down the
sendpage path.

Link: https://lore.kernel.org/r/20220616224557.115234-5-michael.christie@oracle.com
Reviewed-by: Lee Duncan <lduncan@suse.com>
Signed-off-by: Mike Christie <michael.christie@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 years agoscsi: iscsi: Run recv path from workqueue
Mike Christie [Thu, 16 Jun 2022 22:45:51 +0000 (17:45 -0500)]
scsi: iscsi: Run recv path from workqueue

We don't always want to run the recv path from the network softirq because
when we have to have multiple sessions sharing the same CPUs, some sessions
can eat up the NAPI softirq budget and affect other sessions or users.

Allow us to queue the recv handling to the iscsi workqueue so we can have
the scheduler/wq code try to balance the work and CPU use across all
sessions' worker threads.

Note: It wasn't the original intent of the change but a nice side effect is
that for some workloads/configs we get a nice performance boost. For a
simple read heavy test:

  fio --direct=1 --filename=/dev/dm-0  --rw=randread --bs=256K
    --ioengine=libaio --iodepth=128 --numjobs=4

where the iscsi threads, fio jobs, and rps_cpus share CPUs we see a 32%
throughput boost. We also see increases for small I/O IOPs tests but it's
not as high.

Link: https://lore.kernel.org/r/20220616224557.115234-4-michael.christie@oracle.com
Reviewed-by: Lee Duncan <lduncan@suse.com>
Signed-off-by: Mike Christie <michael.christie@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 years agoscsi: iscsi: Add recv workqueue helpers
Mike Christie [Thu, 16 Jun 2022 22:45:50 +0000 (17:45 -0500)]
scsi: iscsi: Add recv workqueue helpers

Add helpers to allow the drivers to run their recv paths from libiscsi's
workqueue.

Link: https://lore.kernel.org/r/20220616224557.115234-3-michael.christie@oracle.com
Reviewed-by: Lee Duncan <lduncan@suse.com>
Signed-off-by: Mike Christie <michael.christie@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 years agoscsi: iscsi: Rename iscsi_conn_queue_work()
Mike Christie [Thu, 16 Jun 2022 22:45:49 +0000 (17:45 -0500)]
scsi: iscsi: Rename iscsi_conn_queue_work()

Rename iscsi_conn_queue_work() to iscsi_conn_queue_xmit() to reflect that
it handles queueing of xmits only.

Link: https://lore.kernel.org/r/20220616224557.115234-2-michael.christie@oracle.com
Reviewed-by: Lee Duncan <lduncan@suse.com>
Reviewed-by: Wu Bo <wubo40@huawei.com>
Signed-off-by: Mike Christie <michael.christie@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 years agoscsi: iscsi: Fix session removal on shutdown
Mike Christie [Thu, 16 Jun 2022 22:27:38 +0000 (17:27 -0500)]
scsi: iscsi: Fix session removal on shutdown

When the system is shutting down, iscsid is not running so we will not get
a response to the ISCSI_ERR_INVALID_HOST error event. The system shutdown
will then hang waiting on userspace to remove the session.

This has libiscsi force the destruction of the session from the kernel when
iscsi_host_remove() is called from a driver's shutdown callout.

This fixes a regression added in qedi boot with commit d1f2ce77638d ("scsi:
qedi: Fix host removal with running sessions") which made qedi use the
common session removal function that waits on userspace instead of rolling
its own kernel based removal.

Link: https://lore.kernel.org/r/20220616222738.5722-7-michael.christie@oracle.com
Fixes: d1f2ce77638d ("scsi: qedi: Fix host removal with running sessions")
Tested-by: Nilesh Javali <njavali@marvell.com>
Reviewed-by: Lee Duncan <lduncan@suse.com>
Reviewed-by: Nilesh Javali <njavali@marvell.com>
Signed-off-by: Mike Christie <michael.christie@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 years agoscsi: qedi: Use QEDI_MODE_NORMAL for error handling
Mike Christie [Thu, 16 Jun 2022 22:27:37 +0000 (17:27 -0500)]
scsi: qedi: Use QEDI_MODE_NORMAL for error handling

When handling errors that lead to host removal use QEDI_MODE_NORMAL. There
is currently no difference in behavior between NORMAL and SHUTDOWN, but in
a subsequent commit we will want to know when we are called from the
pci_driver shutdown callout vs remove/err_handler so we know when userspace
is up.

Link: https://lore.kernel.org/r/20220616222738.5722-6-michael.christie@oracle.com
Tested-by: Nilesh Javali <njavali@marvell.com>
Reviewed-by: Lee Duncan <lduncan@suse.com>
Reviewed-by: Nilesh Javali <njavali@marvell.com>
Signed-off-by: Mike Christie <michael.christie@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 years agoscsi: iscsi: Add helper to remove a session from the kernel
Mike Christie [Thu, 16 Jun 2022 22:27:36 +0000 (17:27 -0500)]
scsi: iscsi: Add helper to remove a session from the kernel

During qedi shutdown we need to stop the iSCSI layer from sending new nops
as pings and from responding to target ones and make sure there is no
running connection cleanups. Commit d1f2ce77638d ("scsi: qedi: Fix host
removal with running sessions") converted the driver to use the libicsi
helper to drive session removal, so the above issues could be handled. The
problem is that during system shutdown iscsid will not be running so when
we try to remove the root session we will hang waiting for userspace to
reply.

Add a helper that will drive the destruction of sessions like these during
system shutdown.

Link: https://lore.kernel.org/r/20220616222738.5722-5-michael.christie@oracle.com
Tested-by: Nilesh Javali <njavali@marvell.com>
Reviewed-by: Nilesh Javali <njavali@marvell.com>
Signed-off-by: Mike Christie <michael.christie@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 years agoscsi: iscsi: Clean up bound endpoints during shutdown
Mike Christie [Thu, 16 Jun 2022 22:27:35 +0000 (17:27 -0500)]
scsi: iscsi: Clean up bound endpoints during shutdown

In the next patch we allow drivers to drive session removal during
shutdown. In this case iscsid will not be running, so we need to detect
bound endpoints and disconnect them. This moves the bound ep check so we
now always check.

Link: https://lore.kernel.org/r/20220616222738.5722-4-michael.christie@oracle.com
Tested-by: Nilesh Javali <njavali@marvell.com>
Reviewed-by: Nilesh Javali <njavali@marvell.com>
Signed-off-by: Mike Christie <michael.christie@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 years agoscsi: iscsi: Allow iscsi_if_stop_conn() to be called from kernel
Mike Christie [Thu, 16 Jun 2022 22:27:34 +0000 (17:27 -0500)]
scsi: iscsi: Allow iscsi_if_stop_conn() to be called from kernel

iscsi_if_stop_conn() is only called from the userspace interface but in a
subsequent commit we will want to call it from the kernel interface to
allow drivers like qedi to remove sessions from inside the kernel during
shutdown. This removes the iscsi_uevent code from iscsi_if_stop_conn() so we
can call it in a new helper.

Link: https://lore.kernel.org/r/20220616222738.5722-3-michael.christie@oracle.com
Tested-by: Nilesh Javali <njavali@marvell.com>
Reviewed-by: Nilesh Javali <njavali@marvell.com>
Signed-off-by: Mike Christie <michael.christie@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 years agoscsi: iscsi: Fix HW conn removal use after free
Mike Christie [Thu, 16 Jun 2022 22:27:33 +0000 (17:27 -0500)]
scsi: iscsi: Fix HW conn removal use after free

If qla4xxx doesn't remove the connection before the session, the iSCSI
class tries to remove the connection for it. We were doing a
iscsi_put_conn() in the iter function which is not needed and will result
in a use after free because iscsi_remove_conn() will free the connection.

Link: https://lore.kernel.org/r/20220616222738.5722-2-michael.christie@oracle.com
Tested-by: Nilesh Javali <njavali@marvell.com>
Reviewed-by: Lee Duncan <lduncan@suse.com>
Reviewed-by: Nilesh Javali <njavali@marvell.com>
Signed-off-by: Mike Christie <michael.christie@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 years agoscsi: ufs: ufs-mediatek: Fix build error and type mismatch
Ren Zhijie [Sun, 19 Jun 2022 11:54:32 +0000 (19:54 +0800)]
scsi: ufs: ufs-mediatek: Fix build error and type mismatch

If CONFIG_PM_SLEEP is not set.

make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu-, will fail:

drivers/ufs/host/ufs-mediatek.c: In function ‘ufs_mtk_vreg_fix_vcc’:
drivers/ufs/host/ufs-mediatek.c:688:46: warning: format ‘%u’ expects argument of type ‘unsigned int’, but argument 4 has type ‘long unsigned int’ [-Wformat=]
    snprintf(vcc_name, MAX_VCC_NAME, "vcc-opt%u", res.a1);
                                             ~^   ~~~~~~
                                             %lu
drivers/ufs/host/ufs-mediatek.c: In function ‘ufs_mtk_system_suspend’:
drivers/ufs/host/ufs-mediatek.c:1371:8: error: implicit declaration of function ‘ufshcd_system_suspend’; did you mean ‘ufs_mtk_system_suspend’? [-Werror=implicit-function-declaration]
  ret = ufshcd_system_suspend(dev);
        ^~~~~~~~~~~~~~~~~~~~~
        ufs_mtk_system_suspend
drivers/ufs/host/ufs-mediatek.c: In function ‘ufs_mtk_system_resume’:
drivers/ufs/host/ufs-mediatek.c:1386:9: error: implicit declaration of function ‘ufshcd_system_resume’; did you mean ‘ufs_mtk_system_resume’? [-Werror=implicit-function-declaration]
  return ufshcd_system_resume(dev);
         ^~~~~~~~~~~~~~~~~~~~
         ufs_mtk_system_resume
cc1: some warnings being treated as errors

The declaration of func "ufshcd_system_suspend()" depends on
CONFIG_PM_SLEEP, so the function wrapper ufs_mtk_system_suspend() should
wrapped by CONFIG_PM_SLEEP too.

Link: https://lore.kernel.org/r/20220619115432.205504-1-renzhijie2@huawei.com
Fixes: 3fd23b8dfb54 ("scsi: ufs: ufs-mediatek: Fix the timing of configuring device regulators")
Reported-by: Hulk Robot <hulkci@huawei.com>
Reviewed-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Ren Zhijie <renzhijie2@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 years agoscsi: iscsi: Make iscsi_unregister_transport() return void
Max Gurtovoy [Thu, 16 Jun 2022 08:02:10 +0000 (11:02 +0300)]
scsi: iscsi: Make iscsi_unregister_transport() return void

This function always returns 0. We can make it return void to simplify the
code. Also, no caller ever checks the return value of this function.

Link: https://lore.kernel.org/r/20220616080210.18531-1-mgurtovoy@nvidia.com
Reviewed-by: Mike Christie <michael.christie@oracle.com>
Signed-off-by: Max Gurtovoy <mgurtovoy@nvidia.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 years agoscsi: ufs: ufs-mediatek: Disable unused VCCQx power rails
Stanley Chu [Thu, 16 Jun 2022 05:37:25 +0000 (13:37 +0800)]
scsi: ufs: ufs-mediatek: Disable unused VCCQx power rails

Some MediaTek UFS platforms support different VCCQx power rails, for
example, both 1.2v and 1.8v VCCQx, in a single kernel image.

To optimize the system power consumption, provide a way to disable and
release the unused power rail during the device probing.

Link: https://lore.kernel.org/r/20220616053725.5681-12-stanley.chu@mediatek.com
Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 years agoscsi: ufs: ufs-mediatek: Support multiple VCC sources
Stanley Chu [Thu, 16 Jun 2022 05:37:24 +0000 (13:37 +0800)]
scsi: ufs: ufs-mediatek: Support multiple VCC sources

Support multiple VCC sources in MediaTek UFS platforms.

Two options are provided and distinguished by specific device tree
attributes as below examples,

[Option 1: By numbering]
mediatek,ufs-vcc-by-num;
vcc-opt1-supply = <&mt6373_vbuck4_ufs>;
vcc-opt2-supply = <&mt6363_vemc>;

[Option 2: By UFS version]
mediatek,ufs-vcc-by-ver;
vcc-ufs3-supply = <&mt6373_vbuck4_ufs>;

Link: https://lore.kernel.org/r/20220616053725.5681-11-stanley.chu@mediatek.com
Signed-off-by: Alice Chao <alice.chao@mediatek.com>
Signed-off-by: Peter Wang <peter.wang@mediatek.com>
Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 years agoscsi: ufs: Export regulator functions
Stanley Chu [Thu, 16 Jun 2022 05:37:23 +0000 (13:37 +0800)]
scsi: ufs: Export regulator functions

Export below regulator functions to allow vendors to
customize regulator configuration in their own platforms.

int ufshcd_populate_vreg(struct device *dev, const char *name,
                         struct ufs_vreg **out_vreg);
int ufshcd_get_vreg(struct device *dev, struct ufs_vreg *vreg);

Link: https://lore.kernel.org/r/20220616053725.5681-10-stanley.chu@mediatek.com
Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 years agoscsi: ufs: ufs-mediatek: Support low-power mode for parents of VCCQx
Stanley Chu [Thu, 16 Jun 2022 05:37:22 +0000 (13:37 +0800)]
scsi: ufs: ufs-mediatek: Support low-power mode for parents of VCCQx

Provide the facility to configure parents of VCCQx power rails as low-power
or full-power mode in MediaTek UFS platforms.

Link: https://lore.kernel.org/r/20220616053725.5681-9-stanley.chu@mediatek.com
Signed-off-by: Alice Chao <alice.chao@mediatek.com>
Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 years agoscsi: ufs: ufs-mediatek: Support flexible parameters for SMC calls
Stanley Chu [Thu, 16 Jun 2022 05:37:21 +0000 (13:37 +0800)]
scsi: ufs: ufs-mediatek: Support flexible parameters for SMC calls

Provide flexible number of parameters for UFS SMC calls to be used in a
subsequent commit.

Link: https://lore.kernel.org/r/20220616053725.5681-8-stanley.chu@mediatek.com
Signed-off-by: Alice Chao <alice.chao@mediatek.com>
Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 years agoscsi: ufs: ufs-mediatek: Support low-power mode for VCCQ
Peter Wang [Thu, 16 Jun 2022 05:37:20 +0000 (13:37 +0800)]
scsi: ufs: ufs-mediatek: Support low-power mode for VCCQ

Allow VCCQ to enter low-power mode, and also remove the restriction of VCC
because VCCQ/VCCQ2 can be changed to low-power mode even if VCC stays on
while the device is not in active power mode.

Link: https://lore.kernel.org/r/20220616053725.5681-7-stanley.chu@mediatek.com
Reviewed-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Peter Wang <peter.wang@mediatek.com>
Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 years agoscsi: ufs: ufs-mediatek: Prevent device regulators setting LPM incorrectly
Po-Wen Kao [Thu, 16 Jun 2022 05:37:19 +0000 (13:37 +0800)]
scsi: ufs: ufs-mediatek: Prevent device regulators setting LPM incorrectly

Device regulatrs are allowed to enter low-power mode if neither device is
not in active mode, nor VCC does not keep on.

Fix this by adding conditions before LPM decision.

Link: https://lore.kernel.org/r/20220616053725.5681-6-stanley.chu@mediatek.com
Reviewed-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Po-Wen Kao <powen.kao@mediatek.com>
Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 years agoscsi: ufs: ufs-mediatek: Fix the timing of configuring device regulators
Po-Wen Kao [Thu, 16 Jun 2022 05:37:18 +0000 (13:37 +0800)]
scsi: ufs: ufs-mediatek: Fix the timing of configuring device regulators

Currently the LPM configurations of device regulators may not work since
VCC is not disabled yet while ufs_mtk_vreg_set_lpm() is executed.

Fix this by changing the timing of invoking ufs_mtk_vreg_set_lpm().

Link: https://lore.kernel.org/r/20220616053725.5681-5-stanley.chu@mediatek.com
Reviewed-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Po-Wen Kao <powen.kao@mediatek.com>
Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 years agoscsi: ufs: ufs-mediatek: Introduce workaround for power mode change
CC Chou [Thu, 16 Jun 2022 05:37:17 +0000 (13:37 +0800)]
scsi: ufs: ufs-mediatek: Introduce workaround for power mode change

Some MediaTek SoC chips need special flow for power mode change, especially
for chips supporting HS-G5.

Enable the workaround by setting the host-specific capability.

Link: https://lore.kernel.org/r/20220616053725.5681-4-stanley.chu@mediatek.com
Reviewed-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: CC Chou <cc.chou@mediatek.com>
Signed-off-by: Eddie Huang <eddie.huang@mediatek.com>
Signed-off-by: Dennis Yu <tun-yu.yu@mediatek.com>
Signed-off-by: Peter Wang <peter.want@medaitek.com>
Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 years agoscsi: ufs: Fix ADAPT logic for HS-G5
Stanley Chu [Thu, 16 Jun 2022 05:37:16 +0000 (13:37 +0800)]
scsi: ufs: Fix ADAPT logic for HS-G5

ADAPT now is added not only for HS Gear4 mode but also higher gears.  Fix
the logic for higher gears.

Link: https://lore.kernel.org/r/20220616053725.5681-3-stanley.chu@mediatek.com
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 years agoscsi: ufs: Export ufshcd_uic_change_pwr_mode()
Stanley Chu [Thu, 16 Jun 2022 05:37:15 +0000 (13:37 +0800)]
scsi: ufs: Export ufshcd_uic_change_pwr_mode()

Export ufshcd_uic_change_pwr_mode() to allow vendors to use it for
SoC-specific power mode change design limitations.

Link: https://lore.kernel.org/r/20220616053725.5681-2-stanley.chu@mediatek.com
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 years agoscsi: qla2xxx: Update version to 10.02.07.700-k
Nilesh Javali [Thu, 16 Jun 2022 05:35:08 +0000 (22:35 -0700)]
scsi: qla2xxx: Update version to 10.02.07.700-k

Link: https://lore.kernel.org/r/20220616053508.27186-12-njavali@marvell.com
Signed-off-by: Nilesh Javali <njavali@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 years agoscsi: qla2xxx: Fix erroneous mailbox timeout after PCI error injection
Quinn Tran [Thu, 16 Jun 2022 05:35:07 +0000 (22:35 -0700)]
scsi: qla2xxx: Fix erroneous mailbox timeout after PCI error injection

Clear wait for mailbox interrupt flag to prevent stale mailbox:

Feb 22 05:22:56 ltcden4-lp7 kernel: qla2xxx [0135:90:00.1]-500a:4: LOOP UP detected (16 Gbps).
Feb 22 05:22:59 ltcden4-lp7 kernel: qla2xxx [0135:90:00.1]-d04c:4: MBX Command timeout for cmd 69, ...

To fix the issue, driver needs to clear the MBX_INTR_WAIT flag on purging
the mailbox. When the stale mailbox completion does arrive, it will be
dropped.

Link: https://lore.kernel.org/r/20220616053508.27186-11-njavali@marvell.com
Fixes: b6faaaf796d7 ("scsi: qla2xxx: Serialize mailbox request")
Cc: Naresh Bannoth <nbannoth@in.ibm.com>
Cc: Kyle Mahlkuch <Kyle.Mahlkuch@ibm.com>
Cc: stable@vger.kernel.org
Reported-by: Naresh Bannoth <nbannoth@in.ibm.com>
Tested-by: Naresh Bannoth <nbannoth@in.ibm.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>
2 years agoscsi: qla2xxx: Fix losing FCP-2 targets on long port disable with I/Os
Arun Easi [Thu, 16 Jun 2022 05:35:06 +0000 (22:35 -0700)]
scsi: qla2xxx: Fix losing FCP-2 targets on long port disable with I/Os

FCP-2 devices were not coming back online once they were lost, login
retries exhausted, and then came back up.  Fix this by accepting RSCN when
the device is not online.

Link: https://lore.kernel.org/r/20220616053508.27186-10-njavali@marvell.com
Fixes: 44c57f205876 ("scsi: qla2xxx: Changes to support FCP2 Target")
Cc: stable@vger.kernel.org
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>
2 years agoscsi: qla2xxx: Add debug prints in the device remove path
Arun Easi [Thu, 16 Jun 2022 05:35:05 +0000 (22:35 -0700)]
scsi: qla2xxx: Add debug prints in the device remove path

Add a debug print in the devloss callback.

Link: https://lore.kernel.org/r/20220616053508.27186-9-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>
2 years agoscsi: qla2xxx: Fix losing target when it reappears during delete
Arun Easi [Thu, 16 Jun 2022 05:35:04 +0000 (22:35 -0700)]
scsi: qla2xxx: Fix losing target when it reappears during delete

FC target disappeared during port perturbation tests due to a race that
tramples target state.  Fix the issue by adding state checks before
proceeding.

Link: https://lore.kernel.org/r/20220616053508.27186-8-njavali@marvell.com
Fixes: 44c57f205876 ("scsi: qla2xxx: Changes to support FCP2 Target")
Cc: stable@vger.kernel.org
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>
2 years agoscsi: qla2xxx: Fix losing FCP-2 targets during port perturbation tests
Arun Easi [Thu, 16 Jun 2022 05:35:03 +0000 (22:35 -0700)]
scsi: qla2xxx: Fix losing FCP-2 targets during port perturbation tests

When a mix of FCP-2 (tape) and non-FCP-2 targets are present, FCP-2 target
state was incorrectly transitioned when both of the targets were gone. Fix
this by ignoring state transition for FCP-2 targets.

Link: https://lore.kernel.org/r/20220616053508.27186-7-njavali@marvell.com
Fixes: 44c57f205876 ("scsi: qla2xxx: Changes to support FCP2 Target")
Cc: stable@vger.kernel.org
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>
2 years agoscsi: qla2xxx: Fix crash due to stale SRB access around I/O timeouts
Arun Easi [Thu, 16 Jun 2022 05:35:02 +0000 (22:35 -0700)]
scsi: qla2xxx: Fix crash due to stale SRB access around I/O timeouts

Ensure SRB is returned during I/O timeout error escalation. If that is not
possible fail the escalation path.

Following crash stack was seen:

BUG: unable to handle kernel paging request at 0000002f56aa90f8
IP: qla_chk_edif_rx_sa_delete_pending+0x14/0x30 [qla2xxx]
Call Trace:
 ? qla2x00_status_entry+0x19f/0x1c50 [qla2xxx]
 ? qla2x00_start_sp+0x116/0x1170 [qla2xxx]
 ? dma_pool_alloc+0x1d6/0x210
 ? mempool_alloc+0x54/0x130
 ? qla24xx_process_response_queue+0x548/0x12b0 [qla2xxx]
 ? qla_do_work+0x2d/0x40 [qla2xxx]
 ? process_one_work+0x14c/0x390

Link: https://lore.kernel.org/r/20220616053508.27186-6-njavali@marvell.com
Fixes: d74595278f4a ("scsi: qla2xxx: Add multiple queue pair functionality.")
Cc: stable@vger.kernel.org
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>
2 years agoscsi: qla2xxx: Turn off multi-queue for 8G adapters
Quinn Tran [Thu, 16 Jun 2022 05:35:01 +0000 (22:35 -0700)]
scsi: qla2xxx: Turn off multi-queue for 8G adapters

For 8G adapters, multi-queue was enabled accidentally. Make sure
multi-queue is not enabled.

Link: https://lore.kernel.org/r/20220616053508.27186-5-njavali@marvell.com
Cc: stable@vger.kernel.org
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>
2 years agoscsi: qla2xxx: Wind down adapter after PCIe error
Quinn Tran [Thu, 16 Jun 2022 05:35:00 +0000 (22:35 -0700)]
scsi: qla2xxx: Wind down adapter after PCIe error

Put adapter into a wind down state if OS does not make any attempt to
recover the adapter after PCIe error.

Link: https://lore.kernel.org/r/20220616053508.27186-4-njavali@marvell.com
Cc: stable@vger.kernel.org
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>
2 years agoscsi: qla2xxx: Add a new v2 dport diagnostic feature
Bikash Hazarika [Thu, 16 Jun 2022 05:34:59 +0000 (22:34 -0700)]
scsi: qla2xxx: Add a new v2 dport diagnostic feature

FW requires minimum 72 bytes buffer size for D_port result. Buffer size
1024 is mentioned in the FW spec so buffer size is increased to 1024.
Rewrite the logic to handle START/RESTART command from SDMAPI.

Link: https://lore.kernel.org/r/20220616053508.27186-3-njavali@marvell.com
Signed-off-by: Bikash Hazarika <bhazarika@marvell.com>
Signed-off-by: Nilesh Javali <njavali@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 years agoscsi: qla2xxx: Fix excessive I/O error messages by default
Arun Easi [Thu, 16 Jun 2022 05:34:58 +0000 (22:34 -0700)]
scsi: qla2xxx: Fix excessive I/O error messages by default

Disable printing I/O error messages by default.  The messages will be
printed only when logging was enabled.

Link: https://lore.kernel.org/r/20220616053508.27186-2-njavali@marvell.com
Fixes: 8e2d81c6b5be ("scsi: qla2xxx: Fix excessive messages during device logout")
Cc: stable@vger.kernel.org
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>
2 years agoscsi: iscsi: Prefer xmit of DataOut over new commands
Dmitry Bogdanov [Tue, 7 Jun 2022 13:19:53 +0000 (16:19 +0300)]
scsi: iscsi: Prefer xmit of DataOut over new commands

iscsi_data_xmit() (TX worker) is iterating over the queue of new SCSI
commands concurrently with the queue being replenished. Only after the
queue is emptied will we start sending pending DataOut PDUs. That leads to
DataOut timeout on the target side and to connection reinstatement.

Give priority to pending DataOut commands over new commands.

Link: https://lore.kernel.org/r/20220607131953.11584-1-d.bogdanov@yadro.com
Reviewed-by: Konstantin Shelekhin <k.shelekhin@yadro.com>
Reviewed-by: Mike Christie <michael.christie@oracle.com>
Signed-off-by: Dmitry Bogdanov <d.bogdanov@yadro.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 years agoscsi: ufs: Rearrange addresses in increasing order
Alim Akhtar [Wed, 15 Jun 2022 12:12:04 +0000 (17:42 +0530)]
scsi: ufs: Rearrange addresses in increasing order

Rearrange all the unipro and mphy addresses in their increasing order.

Link: https://lore.kernel.org/r/20220615121204.16642-3-alim.akhtar@samsung.com
Reviewed-by: Chanho Park <chanho61.park@samsung.com>
Signed-off-by: Alim Akhtar <alim.akhtar@samsung.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 years agoscsi: ufs: host: ufs-exynos: Use already existing definition
Alim Akhtar [Wed, 15 Jun 2022 12:12:03 +0000 (17:42 +0530)]
scsi: ufs: host: ufs-exynos: Use already existing definition

UFS core already uses RX_MIN_ACTIVATETIME_CAPABILITY macro, let's use the
same in driver as well instead of having a different macro name for the
same offset.

Link: https://lore.kernel.org/r/20220615121204.16642-2-alim.akhtar@samsung.com
Reviewed-by: Chanho Park <chanho61.park@samsung.com>
Signed-off-by: Alim Akhtar <alim.akhtar@samsung.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 years agoscsi: ufs: host: ufs-exynos: Remove unused defines
Alim Akhtar [Wed, 15 Jun 2022 12:12:02 +0000 (17:42 +0530)]
scsi: ufs: host: ufs-exynos: Remove unused defines

Remove #defines as those are not used anywhere in the driver file.

Link: https://lore.kernel.org/r/20220615121204.16642-1-alim.akhtar@samsung.com
Reviewed-by: Chanho Park <chanho61.park@samsung.com>
Signed-off-by: Alim Akhtar <alim.akhtar@samsung.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 years agoscsi: pm8001: Expose hardware queues for pm80xx
John Garry [Fri, 10 Jun 2022 16:46:42 +0000 (00:46 +0800)]
scsi: pm8001: Expose hardware queues for pm80xx

In commit 05c6c029a44d ("scsi: pm80xx: Increase number of supported
queues"), support for 80xx chip was improved by enabling multiple HW
queues.

In this, like other SCSI MQ HBA drivers at the time, the HW queues were not
exposed to upper layer, and instead the driver managed the queues
internally.

However, this management duplicates blk-mq code. In addition, the HW queue
management is sub-optimal for a system where the number of CPUs exceeds the
HW queues - this is because queues are selected in a round-robin fashion,
when it would be better to make adjacent CPUs submit on the same queue. And
finally, the affinity of the completion queue interrupts is not set to
mirror the cpu<->HQ queue mapping, which is suboptimal.

As such, for when MSIX is supported, expose HW queues to upper layer. We
always use queue index #0 for "internal" commands, i.e. anything which does
not come from the block layer, so omit this from the affinity spreading.

Link: https://lore.kernel.org/r/1654879602-33497-5-git-send-email-john.garry@huawei.com
Tested-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
Signed-off-by: John Garry <john.garry@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 years agoscsi: pm8001: Use non-atomic bitmap ops for tag alloc + free
John Garry [Fri, 10 Jun 2022 16:46:41 +0000 (00:46 +0800)]
scsi: pm8001: Use non-atomic bitmap ops for tag alloc + free

In pm8001_tag_alloc() we don't require atomic set_bit() as we are already
in atomic context. In pm8001_tag_free() we should use the same host
spinlock to protect clearing the tag (and then don't require the atomic
clear_bit()).

Link: https://lore.kernel.org/r/1654879602-33497-4-git-send-email-john.garry@huawei.com
Tested-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
Signed-off-by: John Garry <john.garry@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 years agoscsi: pm8001: Set up tags before using them
John Garry [Fri, 10 Jun 2022 16:46:40 +0000 (00:46 +0800)]
scsi: pm8001: Set up tags before using them

The current code is buggy in that the tags are set up after they are needed
in pm80xx_chip_init() -> pm80xx_set_sas_protocol_timer_config().  The tag
depth is earlier read in pm80xx_chip_init() -> read_main_config_table().

Add a post init callback to do the pm80xx work which needs to be done after
reading the tags. I don't see a better way to do this.

Link: https://lore.kernel.org/r/1654879602-33497-3-git-send-email-john.garry@huawei.com
Tested-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
Signed-off-by: John Garry <john.garry@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 years agoscsi: pm8001: Rework shost initial values
John Garry [Fri, 10 Jun 2022 16:46:39 +0000 (00:46 +0800)]
scsi: pm8001: Rework shost initial values

Some values in pm8001_prep_sas_ha_init() are set the same as they would be
set in scsi_host_alloc(), or could be in the sht (which would be better),
or later just overwritten, so rework the following:

 - cmd_per_lun can be set in the sht

 - max_lun and max_channel are as scsi_host_alloc() (so no need to set)

 - can_queue is later overwritten (so don't set in
   pm8001_prep_sas_ha_init())

Link: https://lore.kernel.org/r/1654879602-33497-2-git-send-email-john.garry@huawei.com
Tested-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
Acked-by: Jack Wang <jinpu.wang@ionos.com>
Signed-off-by: John Garry <john.garry@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 years agoscsi: ufs: exynos: Constify driver data
Krzysztof Kozlowski [Mon, 13 Jun 2022 10:14:29 +0000 (12:14 +0200)]
scsi: ufs: exynos: Constify driver data

Constify the drv data because it should not be modified (used by multiple
devices).

Link: https://lore.kernel.org/r/20220613101429.114449-1-krzysztof.kozlowski@linaro.org
Reviewed-by: Chanho Park <chanho61.park@samsung.com>
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 years agoscsi: lpfc: Use memset_startat() helper in lpfc_nvmet_xmt_fcp_op_cmp()
Xiu Jianfeng [Mon, 13 Jun 2022 02:18:51 +0000 (10:18 +0800)]
scsi: lpfc: Use memset_startat() helper in lpfc_nvmet_xmt_fcp_op_cmp()

Use memset_startat() helper to simplify the code, no functional changes.

Link: https://lore.kernel.org/r/20220613021851.59699-1-xiujianfeng@huawei.com
Reviewed-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Xiu Jianfeng <xiujianfeng@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 years agoscsi: target: iscsi: Fix NULL pointer dereference in iscsi_conn_auth_required()
Yang Li [Mon, 13 Jun 2022 01:43:21 +0000 (09:43 +0800)]
scsi: target: iscsi: Fix NULL pointer dereference in iscsi_conn_auth_required()

Fix following coccicheck error:

./drivers/target/iscsi/iscsi_target_nego.c:831:13-26: ERROR: se_nacl is NULL but dereferenced.

Link: https://lore.kernel.org/r/20220613014321.107045-1-yang.lee@linux.alibaba.com
Fixes: a75fcb0912a5 ("scsi: target: iscsi: Extract auth functions")
Reported-by: Abaci Robot <abaci@linux.alibaba.com>
Reviewed-by: Mike Christie <michael.christie@oracle.com>
Signed-off-by: Yang Li <yang.lee@linux.alibaba.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 years agoscsi: MAINTAINERS: Add maintainer for Renesas UFS driver
Yoshihiro Shimoda [Fri, 3 Jun 2022 11:05:22 +0000 (20:05 +0900)]
scsi: MAINTAINERS: Add maintainer for Renesas UFS driver

Add maintainer for Renesas UFS driver.

Link: https://lore.kernel.org/r/20220603110524.1997825-6-yoshihiro.shimoda.uh@renesas.com
Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 years agoscsi: ufs: ufs-renesas: Add support for Renesas R-Car UFS controller
Yoshihiro Shimoda [Fri, 3 Jun 2022 11:05:21 +0000 (20:05 +0900)]
scsi: ufs: ufs-renesas: Add support for Renesas R-Car UFS controller

Add support for Renesas R-Car UFS controller which needs vendor-specific
initialization.

Link: https://lore.kernel.org/r/20220603110524.1997825-5-yoshihiro.shimoda.uh@renesas.com
Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 years agoscsi: ufs: core: Add UFSHCD_QUIRK_HIBERN_FASTAUTO
Yoshihiro Shimoda [Fri, 3 Jun 2022 11:05:20 +0000 (20:05 +0900)]
scsi: ufs: core: Add UFSHCD_QUIRK_HIBERN_FASTAUTO

Add UFSHCD_QUIRK_HIBERN_FASTAUTO quirk for host controllers which supports
auto-hibernate the capability but only FASTAUTO mode.

Link: https://lore.kernel.org/r/20220603110524.1997825-4-yoshihiro.shimoda.uh@renesas.com
Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 years agoscsi: ufs: core: Add UFSHCD_QUIRK_BROKEN_64BIT_ADDRESS
Yoshihiro Shimoda [Fri, 3 Jun 2022 11:05:19 +0000 (20:05 +0900)]
scsi: ufs: core: Add UFSHCD_QUIRK_BROKEN_64BIT_ADDRESS

Add UFSHCD_QUIRK_BROKEN_64BIT_ADDRESS for host controllers which do not
support 64-bit addressing.

Link: https://lore.kernel.org/r/20220603110524.1997825-3-yoshihiro.shimoda.uh@renesas.com
Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 years agoscsi: dt-bindings: ufs: Document Renesas R-Car UFS host controller
Yoshihiro Shimoda [Fri, 3 Jun 2022 11:05:18 +0000 (20:05 +0900)]
scsi: dt-bindings: ufs: Document Renesas R-Car UFS host controller

Document Renesas R-Car UFS host controller for R-Car S4-8 (r8a779f0).

Link: https://lore.kernel.org/r/20220603110524.1997825-2-yoshihiro.shimoda.uh@renesas.com
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 years agoscsi: ufs: host: ufs-exynos: Add support for FSD UFS HCI
Alim Akhtar [Fri, 10 Jun 2022 10:41:19 +0000 (16:11 +0530)]
scsi: ufs: host: ufs-exynos: Add support for FSD UFS HCI

Adds support of UFS HCI which is found in Tesla Full Self-Driving (FSD)
SoC.

Link: https://lore.kernel.org/r/20220610104119.66401-7-alim.akhtar@samsung.com
Co-developed-by: Bharat Uppal <bharat.uppal@samsung.com>
Signed-off-by: Bharat Uppal <bharat.uppal@samsung.com>
Signed-off-by: Alim Akhtar <alim.akhtar@samsung.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 years agoscsi: ufs: host: ufs-exynos: Add mphy apb clock mask
Alim Akhtar [Fri, 10 Jun 2022 10:41:18 +0000 (16:11 +0530)]
scsi: ufs: host: ufs-exynos: Add mphy apb clock mask

Bit[3] of HCI_CLKSTOP_CTRL register is for enabling/disabling MPHY APB
clock. Lets add it to CLK_STOP_MASK, so that the same can be controlled
during clock masking/unmasking.

Link: https://lore.kernel.org/r/20220610104119.66401-6-alim.akhtar@samsung.com
Tested-by: Chanho Park <chanho61.park@samsung.com>
Reviewed-by: Chanho Park <chanho61.park@samsung.com>
Signed-off-by: Alim Akhtar <alim.akhtar@samsung.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 years agoscsi: dt-bindings: ufs: exynos-ufs: Add FSD compatible
Alim Akhtar [Fri, 10 Jun 2022 10:41:17 +0000 (16:11 +0530)]
scsi: dt-bindings: ufs: exynos-ufs: Add FSD compatible

Adds tesla,fsd-ufs compatible for Tesla FSD SoC.

Link: https://lore.kernel.org/r/20220610104119.66401-5-alim.akhtar@samsung.com
Acked-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Co-developed-by: Bharat Uppal <bharat.uppal@samsung.com>
Signed-off-by: Bharat Uppal <bharat.uppal@samsung.com>
Signed-off-by: Alim Akhtar <alim.akhtar@samsung.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 years agoscsi: libsas: Introduce struct smp_rps_resp
Damien Le Moal [Thu, 9 Jun 2022 02:24:56 +0000 (11:24 +0900)]
scsi: libsas: Introduce struct smp_rps_resp

Similarly to sas report general and discovery responses, define the
structure struct smp_rps_resp to handle SATA PHY report responses using a
structure with a size that is exactly equal to the sas defined response
size.

With this change, struct smp_resp becomes unused and is removed.

Link: https://lore.kernel.org/r/20220609022456.409087-4-damien.lemoal@opensource.wdc.com
Reviewed-by: John Garry <john.garry@huawei.com>
Signed-off-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 years agoscsi: libsas: Introduce struct smp_rg_resp
Damien Le Moal [Thu, 9 Jun 2022 02:24:55 +0000 (11:24 +0900)]
scsi: libsas: Introduce struct smp_rg_resp

When compiling with gcc 12, several warnings are thrown by gcc when
compiling drivers/scsi/libsas/sas_expander.c, e.g.:

In function ‘sas_get_ex_change_count’,
    inlined from ‘sas_find_bcast_dev’ at
    drivers/scsi/libsas/sas_expander.c:1816:8:
drivers/scsi/libsas/sas_expander.c:1781:20: warning: array subscript
‘struct smp_resp[0]’ is partly outside array bounds of ‘unsigned
char[32]’ [-Warray-bounds]
 1781 |         if (rg_resp->result != SMP_RESP_FUNC_ACC) {
      |             ~~~~~~~^~~~~~~~

This is due to the use of the struct smp_resp to aggregate all possible
response types using a union but allocating a response buffer with a size
exactly equal to the size of the response type needed. This leads to access
to fields of struct smp_resp from an allocated memory area that is smaller
than the size of struct smp_resp.

Fix this by defining struct smp_rg_resp for sas report general responses.

Link: https://lore.kernel.org/r/20220609022456.409087-3-damien.lemoal@opensource.wdc.com
Reviewed-by: John Garry <john.garry@huawei.com>
Signed-off-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 years agoscsi: libsas: Introduce struct smp_disc_resp
Damien Le Moal [Thu, 9 Jun 2022 02:24:54 +0000 (11:24 +0900)]
scsi: libsas: Introduce struct smp_disc_resp

When compiling with gcc 12, several warnings are thrown by gcc when
compiling drivers/scsi/libsas/sas_expander.c, e.g.:

In function ‘sas_get_phy_change_count’,
    inlined from ‘sas_find_bcast_phy.constprop’ at
drivers/scsi/libsas/sas_expander.c:1737:9:
drivers/scsi/libsas/sas_expander.c:1697:39: warning: array subscript
‘struct smp_resp[0]’ is partly outside array bounds of ‘unsigned
char[56]’ [-Warray-bounds]
 1697 |                 *pcc = disc_resp->disc.change_count;
      |                        ~~~~~~~~~~~~~~~^~~~~~~~~~~~~

This is due to the use of the struct smp_resp to aggregate all possible
response types using a union but allocating a response buffer with a size
exactly equal to the size of the response type needed. This leads to access
to fields of struct smp_resp from an allocated memory area that is smaller
than the size of struct smp_resp.

Fix this by defining struct smp_disc_resp for sas discovery operations.
Since this structure and the generic struct smp_resp are identical for
the little endian and big endian archs, move the definition of these
structures at the end of include/scsi/sas.h to avoid repeating their
definition.

Link: https://lore.kernel.org/r/20220609022456.409087-2-damien.lemoal@opensource.wdc.com
Reviewed-by: John Garry <john.garry@huawei.com>
Signed-off-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2 years agoscsi: qla2xxx: Update version to 10.02.07.600-k
Nilesh Javali [Wed, 8 Jun 2022 11:58:49 +0000 (04:58 -0700)]
scsi: qla2xxx: Update version to 10.02.07.600-k

Link: https://lore.kernel.org/r/20220608115849.16693-11-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>
2 years agoscsi: qla2xxx: edif: Fix slow session teardown
Quinn Tran [Wed, 8 Jun 2022 11:58:48 +0000 (04:58 -0700)]
scsi: qla2xxx: edif: Fix slow session teardown

User experience slow recovery when target device went through a stop/start
of the authentication application (app_stop/app_start).

Between the period of app_stop and app_start on the target device, target
device choose to send ELS Reject for any receive AUTH ELS command.  At this
time, authentication application does not do ELS reject if it encounters
error.

Therefore, AUTH ELS reject signify authentication application is not
running. If driver passes up the AUTH ELS Reject to the authentication
application, then it would result in authentication application
retrying/resending the same AUTH ELS command again + delay.

As a work around, driver should trigger a session tear down where it tells
the local authentication application to also tear down.  At the next
relogin, both sides are then synchronized.

Link: https://lore.kernel.org/r/20220608115849.16693-10-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>
2 years agoscsi: qla2xxx: edif: Reduce N2N thrashing at app_start time
Quinn Tran [Wed, 8 Jun 2022 11:58:47 +0000 (04:58 -0700)]
scsi: qla2xxx: edif: Reduce N2N thrashing at app_start time

For N2N + remote WWPN is bigger than local adapter, remote adapter will
login to local adapter while authentication application is not running.
When authentication application starts, the current session in FW needs to
to be invalidated.

Make sure the old session is torn down before triggering a relogin.

Link: https://lore.kernel.org/r/20220608115849.16693-9-njavali@marvell.com
Fixes: 4de067e5df12 ("scsi: qla2xxx: edif: Add N2N support for EDIF")
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>
2 years agoscsi: qla2xxx: edif: Fix no logout on delete for N2N
Quinn Tran [Wed, 8 Jun 2022 11:58:46 +0000 (04:58 -0700)]
scsi: qla2xxx: edif: Fix no logout on delete for N2N

The driver failed to send implicit logout on session delete. For edif, this
failed to flush any lingering SA index in FW.

Set a flag to turn on implicit logout early in the session recovery to make
sure the logout will go out in case of error.

Link: https://lore.kernel.org/r/20220608115849.16693-8-njavali@marvell.com
Fixes: 4de067e5df12 ("scsi: qla2xxx: edif: Add N2N support for EDIF")
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>
2 years agoscsi: qla2xxx: edif: Fix session thrash
Quinn Tran [Wed, 8 Jun 2022 11:58:45 +0000 (04:58 -0700)]
scsi: qla2xxx: edif: Fix session thrash

Current code prematurely sends out PRLI before authentication application
has given the OK to do so. This causes PRLI failure and session teardown.

Prevents PRLI from going out before authentication app gives the OK.

Link: https://lore.kernel.org/r/20220608115849.16693-7-njavali@marvell.com
Fixes: 91f6f5fbe87b ("scsi: qla2xxx: edif: Reduce connection thrash")
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>
2 years agoscsi: qla2xxx: edif: Tear down session if keys have been removed
Quinn Tran [Wed, 8 Jun 2022 11:58:44 +0000 (04:58 -0700)]
scsi: qla2xxx: edif: Tear down session if keys have been removed

If all keys for a session have been deleted, trigger a session teardown.

Link: https://lore.kernel.org/r/20220608115849.16693-6-njavali@marvell.com
Fixes: dd30706e73b7 ("scsi: qla2xxx: edif: Add key update")
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>
2 years agoscsi: qla2xxx: edif: Fix no login after app start
Quinn Tran [Wed, 8 Jun 2022 11:58:43 +0000 (04:58 -0700)]
scsi: qla2xxx: edif: Fix no login after app start

The scenario is this: User loaded driver but has not started authentication
app. All sessions to secure device will exhaust all login attempts, fail,
and in stay in deleted state. Then some time later the app is started. The
driver will replenish the login retry count, trigger delete to prepare for
secure login. After deletion, relogin is triggered.

For the session that is already deleted, the delete trigger is a no-op. If
none of the sessions trigger a relogin, no progress is made.

Add a relogin trigger.

Link: https://lore.kernel.org/r/20220608115849.16693-5-njavali@marvell.com
Fixes: 7ebb336e45ef ("scsi: qla2xxx: edif: Add start + stop bsgs")
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>
2 years agoscsi: qla2xxx: edif: Reduce disruption due to multiple app start
Quinn Tran [Wed, 8 Jun 2022 11:58:42 +0000 (04:58 -0700)]
scsi: qla2xxx: edif: Reduce disruption due to multiple app start

Multiple app start can trigger a session bounce. Make driver skip over
session teardown if app start is seen more than once.

Link: https://lore.kernel.org/r/20220608115849.16693-4-njavali@marvell.com
Fixes: 7ebb336e45ef ("scsi: qla2xxx: edif: Add start + stop bsgs")
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>
2 years agoscsi: qla2xxx: edif: Send LOGO for unexpected IKE message
Quinn Tran [Wed, 8 Jun 2022 11:58:41 +0000 (04:58 -0700)]
scsi: qla2xxx: edif: Send LOGO for unexpected IKE message

If the session is down and the local port continues to receive AUTH ELS
messages, the driver needs to send back LOGO so that the remote device
knows to tear down its session. Terminate and clean up the AUTH ELS
exchange followed by a passthrough LOGO.

Link: https://lore.kernel.org/r/20220608115849.16693-3-njavali@marvell.com
Fixes: 225479296c4f ("scsi: qla2xxx: edif: Reject AUTH ELS on session down")
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>