linux-block.git
4 months agoscsi: core: Don't use "proxy" headers
Andy Shevchenko [Tue, 23 Apr 2024 21:18:43 +0000 (00:18 +0300)]
scsi: core: Don't use "proxy" headers

Update header inclusions to follow IWYU (Include What You Use) principle.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20240423211843.3996046-1-andriy.shevchenko@linux.intel.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 months agoscsi: bnx2fc: Remove redundant assignment to variable 'i'
Colin Ian King [Mon, 15 Apr 2024 10:43:11 +0000 (11:43 +0100)]
scsi: bnx2fc: Remove redundant assignment to variable 'i'

The variable 'i' is being assigned a value that is never read, the
following code path via the label ofld_err never refers to the
variable. The assignment is redundant and can be removed.

Cleans up clang scan warning:
drivers/scsi/bnx2fc/bnx2fc_tgt.c:132:5: warning: Value stored to 'i'
is never read [deadcode.DeadStores]

Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
Link: https://lore.kernel.org/r/20240415104311.484890-1-colin.i.king@gmail.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 months agoscsi: qedi: Fix crash while reading debugfs attribute
Manish Rangankar [Mon, 15 Apr 2024 07:21:55 +0000 (12:51 +0530)]
scsi: qedi: Fix crash while reading debugfs attribute

The qedi_dbg_do_not_recover_cmd_read() function invokes sprintf() directly
on a __user pointer, which results into the crash.

To fix this issue, use a small local stack buffer for sprintf() and then
call simple_read_from_buffer(), which in turns make the copy_to_user()
call.

BUG: unable to handle page fault for address: 00007f4801111000
PGD 8000000864df6067 P4D 8000000864df6067 PUD 864df7067 PMD 846028067 PTE 0
Oops: 0002 [#1] PREEMPT SMP PTI
Hardware name: HPE ProLiant DL380 Gen10/ProLiant DL380 Gen10, BIOS U30 06/15/2023
RIP: 0010:memcpy_orig+0xcd/0x130
RSP: 0018:ffffb7a18c3ffc40 EFLAGS: 00010202
RAX: 00007f4801111000 RBX: 00007f4801111000 RCX: 000000000000000f
RDX: 000000000000000f RSI: ffffffffc0bfd7a0 RDI: 00007f4801111000
RBP: ffffffffc0bfd7a0 R08: 725f746f6e5f6f64 R09: 3d7265766f636572
R10: ffffb7a18c3ffd08 R11: 0000000000000000 R12: 00007f4881110fff
R13: 000000007fffffff R14: ffffb7a18c3ffca0 R15: ffffffffc0bfd7af
FS:  00007f480118a740(0000) GS:ffff98e38af00000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007f4801111000 CR3: 0000000864b8e001 CR4: 00000000007706e0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
PKRU: 55555554
Call Trace:
 <TASK>
 ? __die_body+0x1a/0x60
 ? page_fault_oops+0x183/0x510
 ? exc_page_fault+0x69/0x150
 ? asm_exc_page_fault+0x22/0x30
 ? memcpy_orig+0xcd/0x130
 vsnprintf+0x102/0x4c0
 sprintf+0x51/0x80
 qedi_dbg_do_not_recover_cmd_read+0x2f/0x50 [qedi 6bcfdeeecdea037da47069eca2ba717c84a77324]
 full_proxy_read+0x50/0x80
 vfs_read+0xa5/0x2e0
 ? folio_add_new_anon_rmap+0x44/0xa0
 ? set_pte_at+0x15/0x30
 ? do_pte_missing+0x426/0x7f0
 ksys_read+0xa5/0xe0
 do_syscall_64+0x58/0x80
 ? __count_memcg_events+0x46/0x90
 ? count_memcg_event_mm+0x3d/0x60
 ? handle_mm_fault+0x196/0x2f0
 ? do_user_addr_fault+0x267/0x890
 ? exc_page_fault+0x69/0x150
 entry_SYSCALL_64_after_hwframe+0x72/0xdc
RIP: 0033:0x7f4800f20b4d

Tested-by: Martin Hoyer <mhoyer@redhat.com>
Reviewed-by: John Meneghini <jmeneghi@redhat.com>
Signed-off-by: Manish Rangankar <mrangankar@marvell.com>
Link: https://lore.kernel.org/r/20240415072155.30840-1-mrangankar@marvell.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 months agoscsi: ufs: core: mcq: Fix ufshcd_mcq_sqe_search()
Bart Van Assche [Wed, 10 Apr 2024 00:07:45 +0000 (17:07 -0700)]
scsi: ufs: core: mcq: Fix ufshcd_mcq_sqe_search()

Fix the calculation of the utrd pointer. This patch addresses the following
Coverity complaint:

CID 1538170: (#1 of 1): Extra sizeof expression (SIZEOF_MISMATCH)
suspicious_pointer_arithmetic: Adding sq_head_slot * 32UL /* sizeof (struct
utp_transfer_req_desc) */ to pointer hwq->sqe_base_addr of type struct
utp_transfer_req_desc * is suspicious because adding an integral value to
this pointer automatically scales that value by the size, 32 bytes, of the
pointed-to type, struct utp_transfer_req_desc. Most likely, the
multiplication by sizeof (struct utp_transfer_req_desc) in this expression
is extraneous and should be eliminated.

Cc: Bao D. Nguyen <quic_nguyenb@quicinc.com>
Cc: Stanley Chu <stanley.chu@mediatek.com>
Cc: Can Guo <quic_cang@quicinc.com>
Fixes: 8d7290348992 ("scsi: ufs: mcq: Add supporting functions for MCQ abort")
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Link: https://lore.kernel.org/r/20240410000751.1047758-1-bvanassche@acm.org
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
4 months agoscsi: qedf: Make qedf_execute_tmf() non-preemptible
John Meneghini [Wed, 3 Apr 2024 15:01:55 +0000 (11:01 -0400)]
scsi: qedf: Make qedf_execute_tmf() non-preemptible

Stop calling smp_processor_id() from preemptible code in
qedf_execute_tmf90.  This results in BUG_ON() when running an RT kernel.

[ 659.343280] BUG: using smp_processor_id() in preemptible [00000000] code: sg_reset/3646
[ 659.343282] caller is qedf_execute_tmf+0x8b/0x360 [qedf]

Tested-by: Guangwu Zhang <guazhang@redhat.com>
Cc: Saurav Kashyap <skashyap@marvell.com>
Cc: Nilesh Javali <njavali@marvell.com>
Signed-off-by: John Meneghini <jmeneghi@redhat.com>
Link: https://lore.kernel.org/r/20240403150155.412954-1-jmeneghi@redhat.com
Acked-by: Saurav Kashyap <skashyap@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 months agoscsi: hpsa: Fix allocation size for Scsi_Host private data
Yuri Karpov [Tue, 12 Mar 2024 17:04:47 +0000 (20:04 +0300)]
scsi: hpsa: Fix allocation size for Scsi_Host private data

struct Scsi_Host private data contains pointer to struct ctlr_info.

Restore allocation of only 8 bytes to store pointer in struct Scsi_Host
private data area.

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

Fixes: bbbd25499100 ("scsi: hpsa: Fix allocation size for scsi_host_alloc()")
Signed-off-by: Yuri Karpov <YKarpov@ispras.ru>
Link: https://lore.kernel.org/r/20240312170447.743709-1-YKarpov@ispras.ru
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 months agoMerge patch series "scsi: libsas: Fix the failure of adding phy with zero-address...
Martin K. Petersen [Sat, 20 Apr 2024 14:40:04 +0000 (10:40 -0400)]
Merge patch series "scsi: libsas: Fix the failure of adding phy with zero-address to new port"

Xingui Yang <yangxingui@huawei.com> says:

This series is to solve the problem of a BUG() when adding phy with
zero address to a new port.

Link: https://lore.kernel.org/r/20240312141103.31358-1-yangxingui@huawei.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 months agoscsi: libsas: Fix the failure of adding phy with zero-address to port
Xingui Yang [Tue, 12 Mar 2024 14:11:03 +0000 (14:11 +0000)]
scsi: libsas: Fix the failure of adding phy with zero-address to port

As of commit 7d1d86518118 ("[SCSI] libsas: fix false positive 'device
attached' conditions"), reset the phy->entacted_sas_addr address to a
zero-address when the link rate is less than 1.5G.

Currently we find that when a new device is attached, and the link rate is
less than 1.5G, but the device type is not NO_DEVICE, for example: the link
rate is SAS_PHY_RESET_IN_PROGRESS and the device type is stp. After setting
the phy->entacted_sas_addr address to the zero address, the port will
continue to be created for the phy with the zero-address, and other phys
with the zero-address will be tried to be added to the new port:

[562240.051197] sas: ex 500e004aaaaaaa1f phy19:U:0 attached: 0000000000000000 (no device)
// phy19 is deleted but still on the parent port's phy_list
[562240.062536] sas: ex 500e004aaaaaaa1f phy0 new device attached
[562240.062616] sas: ex 500e004aaaaaaa1f phy00:U:5 attached: 0000000000000000 (stp)
[562240.062680] port-7:7:0: trying to add phy phy-7:7:19 fails: it's already part of another port

Therefore, it should be the same as sas_get_phy_attached_dev(). Only when
device_type is SAS_PHY_UNUSED, sas_address is set to the 0 address.

Fixes: 7d1d86518118 ("[SCSI] libsas: fix false positive 'device attached' conditions")
Signed-off-by: Xingui Yang <yangxingui@huawei.com>
Link: https://lore.kernel.org/r/20240312141103.31358-5-yangxingui@huawei.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 months agoscsi: libsas: Set port when ex_phy is added or deleted
Xingui Yang [Tue, 12 Mar 2024 14:11:02 +0000 (14:11 +0000)]
scsi: libsas: Set port when ex_phy is added or deleted

We found that when ex_phy was attached and added to the parent wide port,
ex_phy->port was not set, resulting in sas_unregister_devs_sas_addr() not
calling sas_port_delete_phy() when deleting the phy, and the deleted phy
was still on the parent wide port's phy_list.

When we use sas_port_add_ex_phy() to set ex_phy->port to solve the above
problem, we find that after all the phys of the parent_port are removed and
the number of phy becomes 0, the parent_port will not be set to NULL.  This
causes the freed parent port to be used when attaching a new ex_phy in
sas_ex_add_parent_port().

Use sas_port_add_ex_phy() instead of sas_port_add_phy() to set ex_phy->port
when ex_phy is added to the parent port, and set ex_dev->parent_port to
NULL when the number of phy on the port becomes 0.

Signed-off-by: Xingui Yang <yangxingui@huawei.com>
Link: https://lore.kernel.org/r/20240312141103.31358-4-yangxingui@huawei.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 months agoscsi: libsas: Move sas_add_parent_port() to sas_expander.c
Xingui Yang [Tue, 12 Mar 2024 14:11:01 +0000 (14:11 +0000)]
scsi: libsas: Move sas_add_parent_port() to sas_expander.c

Move sas_add_parent_port() to sas_expander.c and rename it to
sas_ex_add_parent_port() as it is only used in this file.

Signed-off-by: Xingui Yang <yangxingui@huawei.com>
Link: https://lore.kernel.org/r/20240312141103.31358-3-yangxingui@huawei.com
Reviewed-by: John Garry <john.g.garry@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 months agoscsi: libsas: Add helper for port add ex_phy
Xingui Yang [Tue, 12 Mar 2024 14:11:00 +0000 (14:11 +0000)]
scsi: libsas: Add helper for port add ex_phy

This moves the process of adding ex_phy to a port into a new helper.

Signed-off-by: Xingui Yang <yangxingui@huawei.com>
Link: https://lore.kernel.org/r/20240312141103.31358-2-yangxingui@huawei.com
Reviewed-by: John Garry <john.g.garry@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 months agoMerge patch series "convert SCSI to atomic queue limits, part 1 (v3)"
Martin K. Petersen [Fri, 12 Apr 2024 10:35:55 +0000 (06:35 -0400)]
Merge patch series "convert SCSI to atomic queue limits, part 1 (v3)"

Christoph Hellwig <hch@lst.de> says:

Hi all,

this series converts the SCSI midlayer and LLDDs to use atomic queue
limits API.  It is pretty straight forward, except for the mpt3mr
driver which does really weird and probably already broken things by
setting limits from unlocked device iteration callbacks.

I will probably defer the (more complicated) ULD changes to the next
merge window as they would heavily conflict with Damien's zone write
plugging series.  With that the series could go in through the SCSI
tree if Jens' ACKs the core block layer bits.

Link: https://lore.kernel.org/r/20240409143748.980206-1-hch@lst.de
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 months agoscsi: block: Remove now unused queue limits helpers
Christoph Hellwig [Tue, 9 Apr 2024 14:37:48 +0000 (16:37 +0200)]
scsi: block: Remove now unused queue limits helpers

Signed-off-by: Christoph Hellwig <hch@lst.de>
Link: https://lore.kernel.org/r/20240409143748.980206-24-hch@lst.de
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: John Garry <john.g.garry@oracle.com>
Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 months agoscsi: uas: Switch to using ->device_configure to configure queue limits
Christoph Hellwig [Tue, 9 Apr 2024 14:37:47 +0000 (16:37 +0200)]
scsi: uas: Switch to using ->device_configure to configure queue limits

Switch to the ->device_configure method instead of ->slave_alloc and update
the block limits on the passed in queue_limits instead of using the
per-limit accessors.

Note that uas was the only driver setting these size limits from
->slave_alloc and not ->slave_configure and this makes it match everyone
else.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Link: https://lore.kernel.org/r/20240409143748.980206-23-hch@lst.de
Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 months agoscsi: MAINTAINERS: Make cxlflash obsolete
Andrew Donnellan [Tue, 9 Apr 2024 03:10:26 +0000 (13:10 +1000)]
scsi: MAINTAINERS: Make cxlflash obsolete

The cxlflash driver is no longer actively maintained and we intend to
remove it in a future kernel release. Change its status to obsolete.

While we're here, Matthew Ochs no longer works at IBM and is no longer in a
position to access cxlflash hardware, so remove him from the maintainers
list.

Signed-off-by: Andrew Donnellan <ajd@linux.ibm.com>
Link: https://lore.kernel.org/r/20240409031027.41587-1-ajd@linux.ibm.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 months agoscsi: ufs: mediatek: Fix module autoloading
Krzysztof Kozlowski [Tue, 9 Apr 2024 20:39:54 +0000 (22:39 +0200)]
scsi: ufs: mediatek: Fix module autoloading

Add MODULE_DEVICE_TABLE() so the module can be properly autoloaded based on
the alias from of_device_id table.

Cc: Will McVicker <willmcvicker@google.com>
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://lore.kernel.org/r/20240409203954.80484-1-krzysztof.kozlowski@linaro.org
Reviewed-by: Will McVicker <willmcvicker@google.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Reviewed-by: Peter Wang <peter.wang@mediatek.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 months agoscsi: ufs: exynos: Support module autoloading
Will McVicker [Tue, 9 Apr 2024 20:22:02 +0000 (13:22 -0700)]
scsi: ufs: exynos: Support module autoloading

Export the module alias information using the MODULE_DEVICE_TABLE() macro
in order to support auto-loading this module for devices that support it.

$ modinfo -F alias out/linux/drivers/ufs/host/ufs-exynos.ko
of:N*T*Ctesla,fsd-ufsC*
of:N*T*Ctesla,fsd-ufs
of:N*T*Csamsung,exynosautov9-ufs-vhC*
of:N*T*Csamsung,exynosautov9-ufs-vh
of:N*T*Csamsung,exynosautov9-ufsC*
of:N*T*Csamsung,exynosautov9-ufs
of:N*T*Csamsung,exynos7-ufsC*
of:N*T*Csamsung,exynos7-ufs

Signed-off-by: Will McVicker <willmcvicker@google.com>
Link: https://lore.kernel.org/r/20240409202203.1308163-1-willmcvicker@google.com
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 months agoscsi: ufs: core: Changing the status to check inflight
SEO HOYOUNG [Thu, 11 Apr 2024 07:14:44 +0000 (16:14 +0900)]
scsi: ufs: core: Changing the status to check inflight

ufshcd_cmd_inflight() is used to check whether or not a command is in
progress.  Make it skip commands that have already completed by changing
the !blk_mq_request_started(rq) check into blk_mq_rq_state(rq) !=
MQ_RQ_IN_FLIGHT.  We cannot rely on lrbp->cmd since lrbp->cmd is not
cleared when a command completes.

Link: https://lore.kernel.org/linux-scsi/20230517223157.1068210-3-bvanassche@acm.org/
Signed-off-by: SEO HOYOUNG <hy50.seo@samsung.com>
Link: https://lore.kernel.org/r/20240411071444.51873-1-hy50.seo@samsung.com
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 months agoscsi: ufs: Remove support for old UFSHCI versions
Avri Altman [Wed, 10 Apr 2024 18:37:19 +0000 (21:37 +0300)]
scsi: ufs: Remove support for old UFSHCI versions

UFS spec version 2.1 was published more than 10 years ago. It is
vanishingly unlikely that even there are out there platforms that uses
earlier host controllers, let alone that those ancient platforms will ever
run a V6.10 kernel.  To be extra cautious, leave out removal of UFSHCI 2.0
support from this patch, and just remove support of host controllers prior
to UFS2.0.

This patch removes some legacy tuning calls that no longer apply.

Signed-off-by: Avri Altman <avri.altman@wdc.com>
Link: https://lore.kernel.org/r/20240410183720.908-2-avri.altman@wdc.com
Acked-by: Bean Huo <beanhuo@micron.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 months agoscsi: mpi3mr: Switch to using ->device_configure
Christoph Hellwig [Tue, 9 Apr 2024 14:37:46 +0000 (16:37 +0200)]
scsi: mpi3mr: Switch to using ->device_configure

Switch to the ->device_configure method instead of ->slave_configure and
update the block limits on the passed in queue_limits instead of using the
per-limit accessors.

Note that mpi3mr also updates the limits from an event handler that
iterates all SCSI devices.  This is also updated to use the queue_limits,
but the complete locking of this path probably means it already is
completely broken and needs a proper audit.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Link: https://lore.kernel.org/r/20240409143748.980206-22-hch@lst.de
Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 months agoscsi: mpi3mr: Switch to using ->device_configure
Christoph Hellwig [Wed, 10 Apr 2024 04:27:59 +0000 (06:27 +0200)]
scsi: mpi3mr: Switch to using ->device_configure

Switch to the ->device_configure method instead of ->slave_configure and
update the block limits on the passed in queue_limits instead of using the
per-limit accessors.

Note that mpi3mr also updates the limits from an event handler that
iterates all SCSI devices.  This is also updated to use the queue_limits,
but the complete locking of this path probably means it already is
completely broken and needs a proper audit.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Link: https://lore.kernel.org/r/20240410042759.GA2637@lst.de
Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 months agoscsi: libata: Switch to using ->device_configure
Christoph Hellwig [Tue, 9 Apr 2024 14:37:45 +0000 (16:37 +0200)]
scsi: libata: Switch to using ->device_configure

Switch to the ->device_configure method instead of ->slave_configure and
update the block limits on the passed in queue_limits instead of using the
per-limit accessors.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Link: https://lore.kernel.org/r/20240409143748.980206-21-hch@lst.de
Reviewed-by: John Garry <john.g.garry@oracle.com>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Acked-by: Damien Le Moal <dlemoal@kernel.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 months agoscsi: pata_macio: Switch to using ->device_configure
Christoph Hellwig [Tue, 9 Apr 2024 14:37:44 +0000 (16:37 +0200)]
scsi: pata_macio: Switch to using ->device_configure

Switch to the ->device_configure method instead of ->slave_configure and
update the block limits on the passed in queue_limits instead of using the
per-limit accessors.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Link: https://lore.kernel.org/r/20240409143748.980206-20-hch@lst.de
Reviewed-by: Hannes Reinecke <hare@suse.de>
Acked-by: Damien Le Moal <dlemoal@kernel.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 months agoscsi: sata_nv: Switch to using ->device_configure
Christoph Hellwig [Tue, 9 Apr 2024 14:37:43 +0000 (16:37 +0200)]
scsi: sata_nv: Switch to using ->device_configure

Switch to the ->device_configure method instead of ->slave_configure and
update the block limits on the passed in queue_limits instead of using the
per-limit accessors.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Link: https://lore.kernel.org/r/20240409143748.980206-19-hch@lst.de
Reviewed-by: Hannes Reinecke <hare@suse.de>
Acked-by: Damien Le Moal <dlemoal@kernel.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 months agoscsi: usb-storage: Switch to using ->device_configure
Christoph Hellwig [Tue, 9 Apr 2024 14:37:42 +0000 (16:37 +0200)]
scsi: usb-storage: Switch to using ->device_configure

Switch to the ->device_configure method instead of ->slave_configure and
update the block limits on the passed in queue_limits instead of using the
per-limit accessors.

Also use the proper atomic queue limit update helpers and freeze the queue
when updating max_hw_sectors from sysfs.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Link: https://lore.kernel.org/r/20240409143748.980206-18-hch@lst.de
Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 months agoscsi: pmcraid: Switch to using ->device_configure
Christoph Hellwig [Tue, 9 Apr 2024 14:37:41 +0000 (16:37 +0200)]
scsi: pmcraid: Switch to using ->device_configure

Switch to the ->device_configure method instead of ->slave_configure and
update the block limits on the passed in queue_limits instead of using the
per-limit accessors.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Link: https://lore.kernel.org/r/20240409143748.980206-17-hch@lst.de
Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 months agoscsi: ipr: Switch to using ->device_configure
Christoph Hellwig [Tue, 9 Apr 2024 14:37:40 +0000 (16:37 +0200)]
scsi: ipr: Switch to using ->device_configure

Switch to the ->device_configure method instead of ->slave_configure and
update the block limits on the passed in queue_limits instead of using the
per-limit accessors.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Link: https://lore.kernel.org/r/20240409143748.980206-16-hch@lst.de
Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 months agoscsi: hptiop: Switch to using ->device_configure
Christoph Hellwig [Tue, 9 Apr 2024 14:37:39 +0000 (16:37 +0200)]
scsi: hptiop: Switch to using ->device_configure

Switch to the ->device_configure method instead of ->slave_configure and
update the block limits on the passed in queue_limits instead of using the
per-limit accessors.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Link: https://lore.kernel.org/r/20240409143748.980206-15-hch@lst.de
Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 months agoscsi: sbp2: Switch to using ->device_configure
Christoph Hellwig [Tue, 9 Apr 2024 14:37:38 +0000 (16:37 +0200)]
scsi: sbp2: Switch to using ->device_configure

Switch to the ->device_configure method instead of ->slave_configure and
update the block limits on the passed in queue_limits instead of using the
per-limit accessors.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Link: https://lore.kernel.org/r/20240409143748.980206-14-hch@lst.de
Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 months agoscsi: mpt3sas: Switch to using ->device_configure
Christoph Hellwig [Tue, 9 Apr 2024 14:37:37 +0000 (16:37 +0200)]
scsi: mpt3sas: Switch to using ->device_configure

Switch to the ->device_configure method instead of ->slave_configure and
update the block limits on the passed in queue_limits instead of using the
per-limit accessors.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Link: https://lore.kernel.org/r/20240409143748.980206-13-hch@lst.de
Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 months agoscsi: megaraid_sas: Switch to using ->device_configure
Christoph Hellwig [Tue, 9 Apr 2024 14:37:36 +0000 (16:37 +0200)]
scsi: megaraid_sas: Switch to using ->device_configure

Switch to the ->device_configure method instead of ->slave_configure and
update the block limits on the passed in queue_limits instead of using the
per-limit accessors.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Link: https://lore.kernel.org/r/20240409143748.980206-12-hch@lst.de
Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 months agoscsi: core: Add a device_configure method to the host template
Christoph Hellwig [Tue, 9 Apr 2024 14:37:35 +0000 (16:37 +0200)]
scsi: core: Add a device_configure method to the host template

This is a version of ->slave_configure that also takes a queue_limits
structure that the caller applies, and thus allows drivers to reconfigure
the queue using the atomic queue limits API.

In the long run it should also replace ->slave_configure entirely as there
is no need to have two different methods here, and the slave name in
addition to being politically charged also has no basis in the SCSI
standards or the kernel code.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Link: https://lore.kernel.org/r/20240409143748.980206-11-hch@lst.de
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 months agoscsi: core: Use the atomic queue limits API in scsi_add_lun()
Christoph Hellwig [Tue, 9 Apr 2024 14:37:34 +0000 (16:37 +0200)]
scsi: core: Use the atomic queue limits API in scsi_add_lun()

Switch scsi_add_lun() to use the atomic queue limits API to update the
max_hw_sectors for devices with quirks.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Link: https://lore.kernel.org/r/20240409143748.980206-10-hch@lst.de
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: John Garry <john.g.garry@oracle.com>
Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 months agoscsi: ufs: ufs-exynos: Move setting the the DMA alignment to the init method
Christoph Hellwig [Tue, 9 Apr 2024 14:37:33 +0000 (16:37 +0200)]
scsi: ufs: ufs-exynos: Move setting the the DMA alignment to the init method

Use the SCSI host's dma_alignment field and set it in ->init and remove the
now unused config_scsi_dev method.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Link: https://lore.kernel.org/r/20240409143748.980206-9-hch@lst.de
Reviewed-by: Alim Akhtar <alim.akhtar@samsung.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 months agoscsi: core: Add a dma_alignment field to the host and host template
Christoph Hellwig [Tue, 9 Apr 2024 14:37:32 +0000 (16:37 +0200)]
scsi: core: Add a dma_alignment field to the host and host template

Get drivers out of the business of having to call the block layer DMA
alignment limits helpers themselves.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Link: https://lore.kernel.org/r/20240409143748.980206-8-hch@lst.de
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: John Garry <john.g.garry@oracle.com>
Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 months agoscsi: core: Add a no_highmem flag to struct Scsi_Host
Christoph Hellwig [Tue, 9 Apr 2024 14:37:31 +0000 (16:37 +0200)]
scsi: core: Add a no_highmem flag to struct Scsi_Host

While we really should be killing the block layer bounce buffering ASAP, I
even more urgently need to stop the drivers to fiddle with the limits from
->slave_configure.  Add a no_highmem flag to the Scsi_Host to centralize
this setting and switch the remaining four drivers that use block layer
bounce buffering to it.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Link: https://lore.kernel.org/r/20240409143748.980206-7-hch@lst.de
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
Reviewed-by: John Garry <john.g.garry@oracle.com>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 months agoscsi: scsi_transport_fc: Add a max_bsg_segments field to struct fc_function_template
Christoph Hellwig [Tue, 9 Apr 2024 14:37:30 +0000 (16:37 +0200)]
scsi: scsi_transport_fc: Add a max_bsg_segments field to struct fc_function_template

ibmvfc only supports a single segment for BSG FC passthrough.  Instead of
having it set a queue limits after creating the BSG queues, add a field so
that the FC transport can set it before allocating the queue.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Link: https://lore.kernel.org/r/20240409143748.980206-6-hch@lst.de
Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 months agoscsi: core: Initialize scsi midlayer limits before allocating the queue
Christoph Hellwig [Tue, 9 Apr 2024 14:37:29 +0000 (16:37 +0200)]
scsi: core: Initialize scsi midlayer limits before allocating the queue

Turn __scsi_init_queue() into scsi_init_limits() which initializes
queue_limits structure that can be passed to blk_mq_alloc_queue().

Signed-off-by: Christoph Hellwig <hch@lst.de>
Link: https://lore.kernel.org/r/20240409143748.980206-5-hch@lst.de
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: John Garry <john.g.garry@oracle.com>
Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 months agoscsi: mpi3mr: Pass queue_limits to bsg_setup_queue()
Christoph Hellwig [Tue, 9 Apr 2024 14:37:28 +0000 (16:37 +0200)]
scsi: mpi3mr: Pass queue_limits to bsg_setup_queue()

Pass the limits to bsg_setup_queue() instead of setting them up on the live
queue.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Link: https://lore.kernel.org/r/20240409143748.980206-4-hch@lst.de
Reviewed-by: John Garry <john.g.garry@oracle.com>
Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 months agoscsi: bsg: Pass queue_limits to bsg_setup_queue()
Christoph Hellwig [Tue, 9 Apr 2024 14:37:27 +0000 (16:37 +0200)]
scsi: bsg: Pass queue_limits to bsg_setup_queue()

This allows bsg_setup_queue() to pass them to blk_mq_alloc_queue() and thus
set up the limits at queue allocation time.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Link: https://lore.kernel.org/r/20240409143748.980206-3-hch@lst.de
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: John Garry <john.g.garry@oracle.com>
Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 months agoscsi: block: Add a helper to cancel atomic queue limit updates
Christoph Hellwig [Tue, 9 Apr 2024 14:37:26 +0000 (16:37 +0200)]
scsi: block: Add a helper to cancel atomic queue limit updates

Drivers might have to perform complex actions to determine queue limits,
and those might fail.  Add a helper to cancel a queue limit update that can
be called in those cases.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Link: https://lore.kernel.org/r/20240409143748.980206-2-hch@lst.de
Reviewed-by: Kanchan Joshi <joshi.k@samsung.com>
Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: John Garry <john.g.garry@oracle.com>
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 months agoMerge patch series "Improve the code for showing commands in debugfs"
Martin K. Petersen [Tue, 9 Apr 2024 02:16:46 +0000 (22:16 -0400)]
Merge patch series "Improve the code for showing commands in debugfs"

Bart Van Assche <bvanassche@acm.org> says:

Hi Martin,

The SCSI debugfs code may show information in debugfs that is invalid.
Hence this patch series that makes sure only valid information is shown
in debugfs. Please consider this patch series for the next merge window.

Thanks,

Bart.

Link: https://lore.kernel.org/r/20240325224755.1477910-1-bvanassche@acm.org
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 months agoMerge patch series "scsi: documentation: clean up docs and fix kernel-doc"
Martin K. Petersen [Tue, 9 Apr 2024 02:16:25 +0000 (22:16 -0400)]
Merge patch series "scsi: documentation: clean up docs and fix kernel-doc"

Randy Dunlap <rdunlap@infradead.org> says:

Clean up some SCSI doc files and fix kernel-doc in 6 header files in
include/scsi/.

Link: https://lore.kernel.org/r/20240408025425.18778-1-rdunlap@infradead.org
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 months agoscsi: core: Improve the code for showing commands in debugfs
Bart Van Assche [Mon, 25 Mar 2024 22:47:54 +0000 (15:47 -0700)]
scsi: core: Improve the code for showing commands in debugfs

Some but not all command information is cleared by scsi_end_request().
As an example, if scsi_show_rq() is called after a SCSI command has been
allocated and before SCMD_INITIALIZED is set, .cmnd holds the CDB
of a previous command. Showing that information in debugfs is confusing.
Hence this patch that restricts the information shown in debugfs to
valid information.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Link: https://lore.kernel.org/r/20240325224755.1477910-3-bvanassche@acm.org
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 months agoscsi: core: Introduce scsi_cmd_list_info()
Bart Van Assche [Mon, 25 Mar 2024 22:47:53 +0000 (15:47 -0700)]
scsi: core: Introduce scsi_cmd_list_info()

Slightly improve code readability by introducing a helper function for
deriving the list information and by using guard() + return instead of
goto + explicit unlock + return.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Link: https://lore.kernel.org/r/20240325224755.1477910-2-bvanassche@acm.org
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 months agoscsi: scsi_transport_srp: Fix a couple of kernel-doc warnings
Randy Dunlap [Mon, 8 Apr 2024 02:54:25 +0000 (19:54 -0700)]
scsi: scsi_transport_srp: Fix a couple of kernel-doc warnings

Add a struct short description and a function return value to prevent
kernel-doc warnings:

scsi_transport_srp.h:77: warning: missing initial short description on line:
 * struct srp_function_template
scsi_transport_srp.h:132: warning: No description found for return value of 'srp_chkready'

Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
Link: https://lore.kernel.org/r/20240408025425.18778-9-rdunlap@infradead.org
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 months agoscsi: scsi_transport_fc: Add kernel-doc for function return
Randy Dunlap [Mon, 8 Apr 2024 02:54:24 +0000 (19:54 -0700)]
scsi: scsi_transport_fc: Add kernel-doc for function return

Add function return value to prevent a kernel-doc warning:

scsi_transport_fc.h:780: warning: No description found for return value of 'fc_remote_port_chkready'

Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
Link: https://lore.kernel.org/r/20240408025425.18778-8-rdunlap@infradead.org
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 months agoscsi: core: Add function return kernel-doc for 2 functions
Randy Dunlap [Mon, 8 Apr 2024 02:54:23 +0000 (19:54 -0700)]
scsi: core: Add function return kernel-doc for 2 functions

Add missing function return values to prevent kernel-doc warnings:

scsi.h:75: warning: No description found for return value of 'scsi_status_is_check_condition'
scsi.h:202: warning: No description found for return value of 'scsi_status_is_good'

Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
Link: https://lore.kernel.org/r/20240408025425.18778-7-rdunlap@infradead.org
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 months agoscsi: libfcoe: Fix a slew of kernel-doc warnings
Randy Dunlap [Mon, 8 Apr 2024 02:54:22 +0000 (19:54 -0700)]
scsi: libfcoe: Fix a slew of kernel-doc warnings

Fix all kernel-doc warnings in <scsi/libfcoe.h>:

libfcoe.h:163: warning: Function parameter or struct member 'ctlr' not described in 'fcoe_ctlr_priv'
libfcoe.h:163: warning: Excess function parameter 'cltr' description in 'fcoe_ctlr_priv'
libfcoe.h:163: warning: No description found for return value of 'fcoe_ctlr_priv'
libfcoe.h:218: warning: Function parameter or struct member 'fd_flags' not described in 'fcoe_fcf'
libfcoe.h:218: warning: Excess struct member 'event' description in 'fcoe_fcf'
libfcoe.h:240: warning: Function parameter or struct member 'rdata' not described in 'fcoe_rport'
libfcoe.h:273: warning: No description found for return value of 'is_fip_mode'
libfcoe.h:332: warning: Function parameter or struct member 'crc_eof_page' not described in 'fcoe_percpu_s'
libfcoe.h:332: warning: Function parameter or struct member 'lock' not described in 'fcoe_percpu_s'
libfcoe.h:332: warning: Excess struct member 'page' description in 'fcoe_percpu_s'
libfcoe.h:362: warning: Function parameter or struct member 'data_src_addr' not described in 'fcoe_port'
libfcoe.h:362: warning: Function parameter or struct member 'get_netdev' not described in 'fcoe_port'
libfcoe.h:362: warning: Excess struct member 'data_srt_addr' description in 'fcoe_port'
libfcoe.h:369: warning: No description found for return value of 'fcoe_get_netdev'
libfcoe.h:386: warning: missing initial short description on line:
 * struct netdev_list
libfcoe.h:393: warning: expecting prototype for struct netdev_list. Prototype was for struct fcoe_netdev_mapping instead

Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
Link: https://lore.kernel.org/r/20240408025425.18778-6-rdunlap@infradead.org
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 months agoscsi: iser: Fix @read_stag kernel-doc warning
Randy Dunlap [Mon, 8 Apr 2024 02:54:21 +0000 (19:54 -0700)]
scsi: iser: Fix @read_stag kernel-doc warning

Correct kernel-doc comments for struct iser_ctrl to prevent warnings:

iser.h:76: warning: Function parameter or struct member 'read_stag' not described in 'iser_ctrl'
iser.h:76: warning: Excess struct member 'reaf_stag' description in 'iser_ctrl'

Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
Link: https://lore.kernel.org/r/20240408025425.18778-5-rdunlap@infradead.org
Acked-by: Sagi Grimberg <sagi@grimberg.me>
Reviewed-by: Max Gurtovoy <mgurtovoy@nvidia.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 months agoscsi: core: Add kernel-doc for scsi_msg_to_host_byte()
Randy Dunlap [Mon, 8 Apr 2024 02:54:20 +0000 (19:54 -0700)]
scsi: core: Add kernel-doc for scsi_msg_to_host_byte()

Add entries for missing documentation to prevent kernel-doc warnings:

scsi_cmnd.h:365: warning: Function parameter or struct member 'cmd' not described in 'scsi_msg_to_host_byte'
scsi_cmnd.h:365: warning: Function parameter or struct member 'msg' not described in 'scsi_msg_to_host_byte'

Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
Link: https://lore.kernel.org/r/20240408025425.18778-4-rdunlap@infradead.org
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 months agoscsi: documentation: Clean up overview
Randy Dunlap [Mon, 8 Apr 2024 02:54:19 +0000 (19:54 -0700)]
scsi: documentation: Clean up overview

 - Change http to https where the latter works

 - Drop references to I2O (Intelligent I/O)

 - Use lore.kernel.org instead of marc.info for email links

 - Update the location of the scsi_debug documentation

Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
Link: https://lore.kernel.org/r/20240408025425.18778-3-rdunlap@infradead.org
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 months agoscsi: documentation: Clean up scsi_mid_low_api.rst
Randy Dunlap [Mon, 8 Apr 2024 02:54:18 +0000 (19:54 -0700)]
scsi: documentation: Clean up scsi_mid_low_api.rst

 - Update the format (txt to rst) and location of this document
   (archive.org to docs.kernel.org)

 - Change url to URL

 - Spell out "lk" (Linux Kernel)

Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
Link: https://lore.kernel.org/r/20240408025425.18778-2-rdunlap@infradead.org
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 months agoscsi: snic: Convert sprintf() family to sysfs_emit() family
Li Zhijian [Tue, 19 Mar 2024 06:31:19 +0000 (14:31 +0800)]
scsi: snic: Convert sprintf() family to sysfs_emit() family

Per filesystems/sysfs.rst, show() should only use sysfs_emit() or
sysfs_emit_at() when formatting the value to be returned to user space.

coccinelle complains that there are still a couple of functions that use
snprintf(). Convert them to sysfs_emit().

sprintf() and scnprintf() will be converted as well if they have.

Generally, this patch is generated by
make coccicheck M=<path/to/file> MODE=patch \
COCCI=scripts/coccinelle/api/device_attr_show.cocci

No functional change intended

CC: Karan Tilak Kumar <kartilak@cisco.com>
CC: Sesidhar Baddela <sebaddel@cisco.com>
CC: James E.J. Bottomley <jejb@linux.ibm.com>
CC: Martin K. Petersen <martin.petersen@oracle.com>
CC: linux-scsi@vger.kernel.org
Signed-off-by: Li Zhijian <lizhijian@fujitsu.com>
Link: https://lore.kernel.org/r/20240319063132.1588443-12-lizhijian@fujitsu.com
Reviewed-by: Karan Tilak Kumar <kartilak@cisco.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 months agoscsi: FlashPoint: Remove redundant assignment to pointer currTar_Info
Colin Ian King [Sat, 6 Apr 2024 15:50:29 +0000 (16:50 +0100)]
scsi: FlashPoint: Remove redundant assignment to pointer currTar_Info

Pointer currTar_Info is being assigned a value that is never read, it is
being re-assigned a few lines later in the start of a following do-while
loop. The assignment is redundant and can be removed.

Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
Link: https://lore.kernel.org/r/20240406155029.2593439-1-colin.i.king@gmail.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 months agoscsi: aic7xxx: Indent kconfig help text
Prasad Pandit [Mon, 8 Apr 2024 05:01:10 +0000 (10:31 +0530)]
scsi: aic7xxx: Indent kconfig help text

Fix indentation of config option's help text by adding leading spaces.
Generally help text is indented by two more spaces beyond the leading tab
<\t> character.  It helps Kconfig parsers to read file without error.

Signed-off-by: Prasad Pandit <pjp@fedoraproject.org>
Link: https://lore.kernel.org/r/20240408050110.3679890-1-ppandit@redhat.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 months agoscsi: qla2xxx: Indent help text
Prasad Pandit [Thu, 21 Mar 2024 11:24:38 +0000 (16:54 +0530)]
scsi: qla2xxx: Indent help text

Fix indentation of config option's help text by adding leading spaces.
Generally help text is indented by couple of spaces more beyond the leading
tab <\t> character.  It helps Kconfig parsers to read file without error.

Signed-off-by: Prasad Pandit <pjp@fedoraproject.org>
Link: https://lore.kernel.org/r/20240321112438.1759347-1-ppandit@redhat.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 months agoscsi: megaraid: Indent Kconfig option help text
Prasad Pandit [Mon, 11 Mar 2024 12:11:27 +0000 (17:41 +0530)]
scsi: megaraid: Indent Kconfig option help text

Fix indentation of megaraid options help text by adding leading spaces.
Generally help text is indented by couple of spaces more beyond the leading
tab <\t> character.

Signed-off-by: Prasad Pandit <pjp@fedoraproject.org>
Link: https://lore.kernel.org/r/20240311121127.1281159-1-ppandit@redhat.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 months agoscsi: cxlflash: Fix function pointer cast warnings
Arnd Bergmann [Thu, 4 Apr 2024 16:14:58 +0000 (18:14 +0200)]
scsi: cxlflash: Fix function pointer cast warnings

Calling a function through an incompatible pointer type causes breaks kcfi,
so clang warns about the assignments:

drivers/scsi/cxlflash/main.c:3498:3: error: cast from 'int (*)(struct cxlflash_cfg *, struct ht_cxlflash_lun_provision *)' to 'hioctl' (aka 'int (*)(struct cxlflash_cfg *, void *)') converts to incompatible function type [-Werror,-Wcast-function-type-strict]
 3498 |                 (hioctl)cxlflash_lun_provision },
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/scsi/cxlflash/main.c:3500:3: error: cast from 'int (*)(struct cxlflash_cfg *, struct ht_cxlflash_afu_debug *)' to 'hioctl' (aka 'int (*)(struct cxlflash_cfg *, void *)') converts to incompatible function type [-Werror,-Wcast-function-type-strict]
 3500 |                 (hioctl)cxlflash_afu_debug },
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~

Address these by changing the functions to have the correct type and
replace the function pointer cast with a cast of its argument.

Link: https://lore.kernel.org/lkml/20240326145140.3257163-6-arnd@kernel.org/
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Link: https://lore.kernel.org/r/20240404161524.3473857-1-arnd@kernel.org
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 months agoscsi: ufs: qcom: Add sanity checks for gear/lane values during ICC scaling
Manivannan Sadhasivam [Wed, 3 Apr 2024 13:20:04 +0000 (18:50 +0530)]
scsi: ufs: qcom: Add sanity checks for gear/lane values during ICC scaling

Let's add the checks to warn the user if the ICC scaling is not supported
for the gear/lane values and also fallback to the max value if that's the
case.

Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Link: https://lore.kernel.org/r/20240403-ufs-icc-fix-v2-2-958412a5eb45@linaro.org
Reviewed-by: Andrew Halaney <ahalaney@redhat.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 months agoMerge patch series "scsi: Prevent several section mismatch warnings"
Martin K. Petersen [Sat, 6 Apr 2024 01:12:01 +0000 (21:12 -0400)]
Merge patch series "scsi: Prevent several section mismatch warnings"

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

Hello,

this series fixes the same issue in four drivers. The warning is a false
positive and to suppress it the driver structs are marked with
__refdata and a comment is added to describe the (non-trivial)
situation.

Best regards
Uwe

Link: https://lore.kernel.org/r/cover.1711746359.git.u.kleine-koenig@pengutronix.de
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 months agoscsi: mac_scsi: Mark driver struct with __refdata to prevent section mismatch
Uwe Kleine-König [Fri, 29 Mar 2024 21:11:44 +0000 (22:11 +0100)]
scsi: mac_scsi: Mark driver struct with __refdata to prevent section mismatch

As described in the added code comment, a reference to .exit.text is ok for
drivers registered via module_platform_driver_probe(). Make this explicit
to prevent the following section mismatch warning

WARNING: modpost: drivers/scsi/mac_scsi: section mismatch in reference: mac_scsi_driver+0x8 (section: .data) -> mac_scsi_remove (section: .exit.text)

that triggers on an allmodconfig W=1 build.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Link: https://lore.kernel.org/r/e41d10906948a980e985f6065485445d9bbbd2f7.1711746359.git.u.kleine-koenig@pengutronix.de
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 months agoscsi: atari_scsi: Mark driver struct with __refdata to prevent section mismatch
Uwe Kleine-König [Fri, 29 Mar 2024 21:11:43 +0000 (22:11 +0100)]
scsi: atari_scsi: Mark driver struct with __refdata to prevent section mismatch

As described in the added code comment, a reference to .exit.text is ok for
drivers registered via module_platform_driver_probe(). Make this explicit
to prevent the following section mismatch warning

WARNING: modpost: drivers/scsi/atari_scsi: section mismatch in reference: atari_scsi_driver+0x8 (section: .data) -> atari_scsi_remove (section: .exit.text)

that triggers on an allmodconfig W=1 build.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Link: https://lore.kernel.org/r/0170bda7ac0be3d8b694dca1b2f079fb17d9539b.1711746359.git.u.kleine-koenig@pengutronix.de
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 months agoscsi: a4000t: Mark driver struct with __refdata to prevent section mismatch
Uwe Kleine-König [Fri, 29 Mar 2024 21:11:42 +0000 (22:11 +0100)]
scsi: a4000t: Mark driver struct with __refdata to prevent section mismatch

As described in the added code comment, a reference to .exit.text is ok for
drivers registered via module_platform_driver_probe(). Make this explicit
to prevent the following section mismatch warning

WARNING: modpost: drivers/scsi/a4000t: section mismatch in reference: amiga_a4000t_scsi_driver+0x8 (section: .data) -> amiga_a4000t_scsi_remove (section: .exit.text)

that triggers on an allmodconfig W=1 build.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Link: https://lore.kernel.org/r/743c3cfaf12b9f61f66afa5529ac126c856e4d11.1711746359.git.u.kleine-koenig@pengutronix.de
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 months agoscsi: a3000: Mark driver struct with __refdata to prevent section mismatch
Uwe Kleine-König [Fri, 29 Mar 2024 21:11:41 +0000 (22:11 +0100)]
scsi: a3000: Mark driver struct with __refdata to prevent section mismatch

As described in the added code comment, a reference to .exit.text is ok for
drivers registered via module_platform_driver_probe(). Make this explicit
to prevent the following section mismatch warning

WARNING: modpost: drivers/scsi/a3000: section mismatch in reference: amiga_a3000_scsi_driver+0x8 (section: .data) -> amiga_a3000_scsi_remove (section: .exit.text)

that triggers on an allmodconfig W=1 build.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Link: https://lore.kernel.org/r/c7222ad7f0baaff78b19f16e789726d42515f025.1711746359.git.u.kleine-koenig@pengutronix.de
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 months agoMerge patch series "scsi: ufs: Remove overzealous memory barriers"
Martin K. Petersen [Sat, 6 Apr 2024 01:07:23 +0000 (21:07 -0400)]
Merge patch series "scsi: ufs: Remove overzealous memory barriers"

Andrew Halaney <ahalaney@redhat.com> says:

Please review with care as I'm not all that confident in this subject.
UFS has a lot of mb() variants used, most with comments saying "ensure
this takes effect before continuing". mb()'s aren't really the way to
guarantee that, a read back is the best method.

Some of these though I think could go a step further and remove the
mb() variant without a read back. As far as I can tell there's no real
reason to ensure it takes effect in most cases (there's no delay() or
anything afterwards, and eventually another readl()/writel() happens
which is by definition ordered). Some of the patches in this series do
that if I was confident it was safe (or a reviewer pointed out prior
that they thought it was safe to do so).

Thanks in advance for the help,
Andrew

Link: https://lore.kernel.org/r/20240329-ufs-reset-ensure-effect-before-delay-v5-0-181252004586@redhat.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 months agoscsi: ufs: core: Remove unnecessary wmb() prior to writing run/stop regs
Andrew Halaney [Fri, 29 Mar 2024 20:46:53 +0000 (15:46 -0500)]
scsi: ufs: core: Remove unnecessary wmb() prior to writing run/stop regs

Currently a wmb() is used to ensure that writes to the
UTP_TASK_REQ_LIST_BASE* regs are completed prior to following writes to
the run/stop registers.

wmb() ensures that the write completes, but completion doesn't mean that
it isn't stored in a buffer somewhere. The recommendation for
ensuring the bits have taken effect on the device is to perform a read
back to force it to make it all the way to the device. This is
documented in device-io.rst and a talk by Will Deacon on this can
be seen over here:

    https://youtu.be/i6DayghhA8Q?si=MiyxB5cKJXSaoc01&t=1678

But, none of that is necessary here. All of the writel()/readl()'s here
are to the same endpoint, so they will be ordered. There's no subsequent
delay() etc that requires it to have taken effect already, so no
readback is necessary here.

For that reason just drop the wmb() altogether.

Fixes: 897efe628d7e ("scsi: ufs: add missing memory barriers")
Signed-off-by: Andrew Halaney <ahalaney@redhat.com>
Link: https://lore.kernel.org/r/20240329-ufs-reset-ensure-effect-before-delay-v5-11-181252004586@redhat.com
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 months agoscsi: ufs: core: Remove unnecessary wmb() after ringing doorbell
Andrew Halaney [Fri, 29 Mar 2024 20:46:52 +0000 (15:46 -0500)]
scsi: ufs: core: Remove unnecessary wmb() after ringing doorbell

Currently, the doorbell is written to and a wmb() is used to commit it
immediately.

wmb() ensures that the write completes before following writes occur, but
completion doesn't mean that it isn't stored in a buffer somewhere.  The
recommendation for ensuring this bit has taken effect on the device is to
perform a read back to force it to make it all the way to the device. This
is documented in device-io.rst and a talk by Will Deacon on this can be
seen over here:

    https://youtu.be/i6DayghhA8Q?si=MiyxB5cKJXSaoc01&t=1678

But, completion and taking effect aren't necessary to guarantee here.

There's already other examples of the doorbell being rung that don't do
this. The writel() of the doorbell guarantees prior writes by this thread
(to the request being setup for example) complete prior to the ringing of
the doorbell, and the following wait_for_completion_io_timeout() doesn't
require any special memory barriers either.

With that in mind, just remove the wmb() altogether here.

Fixes: ad1a1b9cd67a ("scsi: ufs: commit descriptors before setting the doorbell")
Signed-off-by: Andrew Halaney <ahalaney@redhat.com>
Link: https://lore.kernel.org/r/20240329-ufs-reset-ensure-effect-before-delay-v5-10-181252004586@redhat.com
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 months agoscsi: ufs: core: Perform read back after disabling UIC_COMMAND_COMPL
Andrew Halaney [Fri, 29 Mar 2024 20:46:51 +0000 (15:46 -0500)]
scsi: ufs: core: Perform read back after disabling UIC_COMMAND_COMPL

Currently, the UIC_COMMAND_COMPL interrupt is disabled and a wmb() is used
to complete the register write before any following writes.

wmb() ensures the writes complete in that order, but completion doesn't
mean that it isn't stored in a buffer somewhere. The recommendation for
ensuring this bit has taken effect on the device is to perform a read back
to force it to make it all the way to the device. This is documented in
device-io.rst and a talk by Will Deacon on this can be seen over here:

    https://youtu.be/i6DayghhA8Q?si=MiyxB5cKJXSaoc01&t=1678

Let's do that to ensure the bit hits the device. Because the wmb()'s
purpose wasn't to add extra ordering (on top of the ordering guaranteed by
writel()/readl()), it can safely be removed.

Fixes: d75f7fe495cf ("scsi: ufs: reduce the interrupts for power mode change requests")
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Can Guo <quic_cang@quicinc.com>
Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Signed-off-by: Andrew Halaney <ahalaney@redhat.com>
Link: https://lore.kernel.org/r/20240329-ufs-reset-ensure-effect-before-delay-v5-9-181252004586@redhat.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 months agoscsi: ufs: core: Perform read back after disabling interrupts
Andrew Halaney [Fri, 29 Mar 2024 20:46:50 +0000 (15:46 -0500)]
scsi: ufs: core: Perform read back after disabling interrupts

Currently, interrupts are cleared and disabled prior to registering the
interrupt. An mb() is used to complete the clear/disable writes before the
interrupt is registered.

mb() ensures that the write completes, but completion doesn't mean that it
isn't stored in a buffer somewhere. The recommendation for ensuring these
bits have taken effect on the device is to perform a read back to force it
to make it all the way to the device. This is documented in device-io.rst
and a talk by Will Deacon on this can be seen over here:

    https://youtu.be/i6DayghhA8Q?si=MiyxB5cKJXSaoc01&t=1678

Let's do that to ensure these bits hit the device. Because the mb()'s
purpose wasn't to add extra ordering (on top of the ordering guaranteed by
writel()/readl()), it can safely be removed.

Fixes: 199ef13cac7d ("scsi: ufs: avoid spurious UFS host controller interrupts")
Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Can Guo <quic_cang@quicinc.com>
Signed-off-by: Andrew Halaney <ahalaney@redhat.com>
Link: https://lore.kernel.org/r/20240329-ufs-reset-ensure-effect-before-delay-v5-8-181252004586@redhat.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 months agoscsi: ufs: core: Perform read back after writing UTP_TASK_REQ_LIST_BASE_H
Andrew Halaney [Fri, 29 Mar 2024 20:46:49 +0000 (15:46 -0500)]
scsi: ufs: core: Perform read back after writing UTP_TASK_REQ_LIST_BASE_H

Currently, the UTP_TASK_REQ_LIST_BASE_L/UTP_TASK_REQ_LIST_BASE_H regs are
written to and then completed with an mb().

mb() ensures that the write completes, but completion doesn't mean that it
isn't stored in a buffer somewhere. The recommendation for ensuring these
bits have taken effect on the device is to perform a read back to force it
to make it all the way to the device. This is documented in device-io.rst
and a talk by Will Deacon on this can be seen over here:

    https://youtu.be/i6DayghhA8Q?si=MiyxB5cKJXSaoc01&t=1678

Let's do that to ensure the bits hit the device. Because the mb()'s purpose
wasn't to add extra ordering (on top of the ordering guaranteed by
writel()/readl()), it can safely be removed.

Fixes: 88441a8d355d ("scsi: ufs: core: Add hibernation callbacks")
Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Can Guo <quic_cang@quicinc.com>
Signed-off-by: Andrew Halaney <ahalaney@redhat.com>
Link: https://lore.kernel.org/r/20240329-ufs-reset-ensure-effect-before-delay-v5-7-181252004586@redhat.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 months agoscsi: ufs: cdns-pltfrm: Perform read back after writing HCLKDIV
Andrew Halaney [Fri, 29 Mar 2024 20:46:48 +0000 (15:46 -0500)]
scsi: ufs: cdns-pltfrm: Perform read back after writing HCLKDIV

Currently, HCLKDIV is written to and then completed with an mb().

mb() ensures that the write completes, but completion doesn't mean that it
isn't stored in a buffer somewhere. The recommendation for ensuring this
bit has taken effect on the device is to perform a read back to force it to
make it all the way to the device. This is documented in device-io.rst and
a talk by Will Deacon on this can be seen over here:

    https://youtu.be/i6DayghhA8Q?si=MiyxB5cKJXSaoc01&t=1678

Let's do that to ensure the bit hits the device. Because the mb()'s purpose
wasn't to add extra ordering (on top of the ordering guaranteed by
writel()/readl()), it can safely be removed.

Fixes: d90996dae8e4 ("scsi: ufs: Add UFS platform driver for Cadence UFS")
Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Signed-off-by: Andrew Halaney <ahalaney@redhat.com>
Link: https://lore.kernel.org/r/20240329-ufs-reset-ensure-effect-before-delay-v5-6-181252004586@redhat.com
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 months agoscsi: ufs: qcom: Perform read back after writing CGC enable
Andrew Halaney [Fri, 29 Mar 2024 20:46:47 +0000 (15:46 -0500)]
scsi: ufs: qcom: Perform read back after writing CGC enable

Currently, the CGC enable bit is written and then an mb() is used to ensure
that completes before continuing.

mb() ensures that the write completes, but completion doesn't mean that it
isn't stored in a buffer somewhere. The recommendation for ensuring this
bit has taken effect on the device is to perform a read back to force it to
make it all the way to the device. This is documented in device-io.rst and
a talk by Will Deacon on this can be seen over here:

    https://youtu.be/i6DayghhA8Q?si=MiyxB5cKJXSaoc01&t=1678

Let's do that to ensure the bit hits the device. Because the mb()'s purpose
wasn't to add extra ordering (on top of the ordering guaranteed by
writel()/readl()), it can safely be removed.

Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Reviewed-by: Can Guo <quic_cang@quicinc.com>
Fixes: 81c0fc51b7a7 ("ufs-qcom: add support for Qualcomm Technologies Inc platforms")
Signed-off-by: Andrew Halaney <ahalaney@redhat.com>
Link: https://lore.kernel.org/r/20240329-ufs-reset-ensure-effect-before-delay-v5-5-181252004586@redhat.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 months agoscsi: ufs: qcom: Perform read back after writing unipro mode
Andrew Halaney [Fri, 29 Mar 2024 20:46:46 +0000 (15:46 -0500)]
scsi: ufs: qcom: Perform read back after writing unipro mode

Currently, the QUNIPRO_SEL bit is written to and then an mb() is used to
ensure that completes before continuing.

mb() ensures that the write completes, but completion doesn't mean that it
isn't stored in a buffer somewhere. The recommendation for ensuring this
bit has taken effect on the device is to perform a read back to force it to
make it all the way to the device. This is documented in device-io.rst and
a talk by Will Deacon on this can be seen over here:

    https://youtu.be/i6DayghhA8Q?si=MiyxB5cKJXSaoc01&t=1678

But, there's really no reason to even ensure completion before
continuing. The only requirement here is that this write is ordered to this
endpoint (which readl()/writel() guarantees already). For that reason the
mb() can be dropped altogether without anything forcing completion.

Fixes: f06fcc7155dc ("scsi: ufs-qcom: add QUniPro hardware support and power optimizations")
Signed-off-by: Andrew Halaney <ahalaney@redhat.com>
Link: https://lore.kernel.org/r/20240329-ufs-reset-ensure-effect-before-delay-v5-4-181252004586@redhat.com
Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 months agoscsi: ufs: qcom: Remove unnecessary mb() after writing testbus config
Andrew Halaney [Fri, 29 Mar 2024 20:46:45 +0000 (15:46 -0500)]
scsi: ufs: qcom: Remove unnecessary mb() after writing testbus config

Currently, the testbus configuration is written and completed with an mb().

mb() ensures that the write completes, but completion doesn't mean that it
isn't stored in a buffer somewhere. The recommendation for ensuring this
bit has taken effect on the device is to perform a read back to force it to
make it all the way to the device. This is documented in device-io.rst and
a talk by Will Deacon on this can be seen over here:

    https://youtu.be/i6DayghhA8Q?si=MiyxB5cKJXSaoc01&t=1678

But, there's really no reason to even ensure completion before
continuing. The only requirement here is that this write is ordered to this
endpoint (which readl()/writel() guarantees already). For that reason the
mb() can be dropped altogether without anything forcing completion.

Fixes: 9c46b8676271 ("scsi: ufs-qcom: dump additional testbus registers")
Signed-off-by: Andrew Halaney <ahalaney@redhat.com>
Link: https://lore.kernel.org/r/20240329-ufs-reset-ensure-effect-before-delay-v5-3-181252004586@redhat.com
Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 months agoscsi: ufs: qcom: Perform read back after writing REG_UFS_SYS1CLK_1US
Andrew Halaney [Fri, 29 Mar 2024 20:46:44 +0000 (15:46 -0500)]
scsi: ufs: qcom: Perform read back after writing REG_UFS_SYS1CLK_1US

Currently after writing to REG_UFS_SYS1CLK_1US a mb() is used to ensure
that write has gone through to the device.

mb() ensures that the write completes, but completion doesn't mean that it
isn't stored in a buffer somewhere. The recommendation for ensuring this
bit has taken effect on the device is to perform a read back to force it to
make it all the way to the device. This is documented in device-io.rst and
a talk by Will Deacon on this can be seen over here:

    https://youtu.be/i6DayghhA8Q?si=MiyxB5cKJXSaoc01&t=1678

Let's do that to ensure the bit hits the device. Because the mb()'s purpose
wasn't to add extra ordering (on top of the ordering guaranteed by
writel()/readl()), it can safely be removed.

Fixes: f06fcc7155dc ("scsi: ufs-qcom: add QUniPro hardware support and power optimizations")
Reviewed-by: Can Guo <quic_cang@quicinc.com>
Signed-off-by: Andrew Halaney <ahalaney@redhat.com>
Link: https://lore.kernel.org/r/20240329-ufs-reset-ensure-effect-before-delay-v5-2-181252004586@redhat.com
Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 months agoscsi: ufs: qcom: Perform read back after writing reset bit
Andrew Halaney [Fri, 29 Mar 2024 20:46:43 +0000 (15:46 -0500)]
scsi: ufs: qcom: Perform read back after writing reset bit

Currently, the reset bit for the UFS provided reset controller (used by its
phy) is written to, and then a mb() happens to try and ensure that hit the
device. Immediately afterwards a usleep_range() occurs.

mb() ensures that the write completes, but completion doesn't mean that it
isn't stored in a buffer somewhere. The recommendation for ensuring this
bit has taken effect on the device is to perform a read back to force it to
make it all the way to the device. This is documented in device-io.rst and
a talk by Will Deacon on this can be seen over here:

    https://youtu.be/i6DayghhA8Q?si=MiyxB5cKJXSaoc01&t=1678

Let's do that to ensure the bit hits the device. By doing so and
guaranteeing the ordering against the immediately following usleep_range(),
the mb() can safely be removed.

Fixes: 81c0fc51b7a7 ("ufs-qcom: add support for Qualcomm Technologies Inc platforms")
Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Reviewed-by: Can Guo <quic_cang@quicinc.com>
Signed-off-by: Andrew Halaney <ahalaney@redhat.com>
Link: https://lore.kernel.org/r/20240329-ufs-reset-ensure-effect-before-delay-v5-1-181252004586@redhat.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 months agoscsi: ufs: core: Drop driver owner initialization
Krzysztof Kozlowski [Thu, 28 Mar 2024 20:45:50 +0000 (21:45 +0100)]
scsi: ufs: core: Drop driver owner initialization

Core in scsi_register_driver() already sets the .owner, so driver does not
need to.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://lore.kernel.org/r/20240328-b4-module-owner-scsi-v1-6-c86cb4f6e91c@linaro.org
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 months agoscsi: st: Drop driver owner initialization
Krzysztof Kozlowski [Thu, 28 Mar 2024 20:45:49 +0000 (21:45 +0100)]
scsi: st: Drop driver owner initialization

Core in scsi_register_driver() already sets the .owner, so driver does not
need to.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://lore.kernel.org/r/20240328-b4-module-owner-scsi-v1-5-c86cb4f6e91c@linaro.org
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 months agoscsi: sr: Drop driver owner initialization
Krzysztof Kozlowski [Thu, 28 Mar 2024 20:45:48 +0000 (21:45 +0100)]
scsi: sr: Drop driver owner initialization

Core in scsi_register_driver() already sets the .owner, so driver does not
need to.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://lore.kernel.org/r/20240328-b4-module-owner-scsi-v1-4-c86cb4f6e91c@linaro.org
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 months agoscsi: ses: Drop driver owner initialization
Krzysztof Kozlowski [Thu, 28 Mar 2024 20:45:47 +0000 (21:45 +0100)]
scsi: ses: Drop driver owner initialization

Core in scsi_register_driver() already sets the .owner, so driver does not
need to.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://lore.kernel.org/r/20240328-b4-module-owner-scsi-v1-3-c86cb4f6e91c@linaro.org
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 months agoscsi: sd: Drop driver owner initialization
Krzysztof Kozlowski [Thu, 28 Mar 2024 20:45:46 +0000 (21:45 +0100)]
scsi: sd: Drop driver owner initialization

Core in scsi_register_driver() already sets the .owner, so driver does not
need to.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://lore.kernel.org/r/20240328-b4-module-owner-scsi-v1-2-c86cb4f6e91c@linaro.org
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 months agoscsi: core: Store owner from modules with scsi_register_driver()
Krzysztof Kozlowski [Thu, 28 Mar 2024 20:45:45 +0000 (21:45 +0100)]
scsi: core: Store owner from modules with scsi_register_driver()

Modules registering driver with scsi_driver_register() might forget to set
.owner field.  The field is used by some of other kernel parts for
reference counting (try_module_get()), so it is expected that drivers will
set it.

Solve the problem by moving this task away from the drivers to the core
scsi code, just like we did for platform_driver in commit 9447057eaff8
("platform_device: use a macro instead of platform_driver_register").

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://lore.kernel.org/r/20240328-b4-module-owner-scsi-v1-1-c86cb4f6e91c@linaro.org
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 months agoscsi: qla2xxx: Drop driver owner assignment
Krzysztof Kozlowski [Wed, 27 Mar 2024 17:49:21 +0000 (18:49 +0100)]
scsi: qla2xxx: Drop driver owner assignment

PCI core in pci_register_driver() already sets the .owner, so driver does
not need to.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://lore.kernel.org/r/20240327174921.519830-2-krzysztof.kozlowski@linaro.org
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 months agoscsi: csiostor: Drop driver owner assignment
Krzysztof Kozlowski [Wed, 27 Mar 2024 17:49:20 +0000 (18:49 +0100)]
scsi: csiostor: Drop driver owner assignment

PCI core in pci_register_driver() already sets the .owner, so driver does
not need to.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://lore.kernel.org/r/20240327174921.519830-1-krzysztof.kozlowski@linaro.org
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 months agoscsi: libsas: Fix declaration of ncq priority attributes
Damien Le Moal [Wed, 27 Mar 2024 02:01:22 +0000 (11:01 +0900)]
scsi: libsas: Fix declaration of ncq priority attributes

Commit b4d3ddd2df75 ("scsi: libsas: Define NCQ Priority sysfs attributes
for SATA devices") introduced support for ATA NCQ priority control for ATA
devices managed by libsas. This commit introduces the ncq_prio_supported
and ncq_prio_enable sysfs device attributes to discover and control the use
of this features, similarly to libata.  However, libata publicly declares
these device attributes and export them for use in ATA low level
drivers. This leads to a compilation error when libsas and libata are
built-in due to the double definition:

ld: drivers/ata/libata-sata.o:/home/Linux/scsi/drivers/ata/libata-sata.c:900:
multiple definition of `dev_attr_ncq_prio_supported';
drivers/scsi/libsas/sas_ata.o:/home/Linux/scsi/drivers/scsi/libsas/sas_ata.c:984:
first defined here
ld: drivers/ata/libata-sata.o:/home/Linux/scsi/drivers/ata/libata-sata.c:1026:
multiple definition of `dev_attr_ncq_prio_enable';
drivers/scsi/libsas/sas_ata.o:/home/Linux/scsi/drivers/scsi/libsas/sas_ata.c:1022:
first defined here

Resolve this problem by directly declaring the libsas attributes instead of
using the DEVICE_ATTR() macro. And for good measure, the device attribute
variables are also renamed.

Reported-by: Geert Uytterhoeven <geert@linux-m68k.org>
Fixes: b4d3ddd2df75 ("scsi: libsas: Define NCQ Priority sysfs attributes for SATA devices")
Signed-off-by: Damien Le Moal <dlemoal@kernel.org>
Link: https://lore.kernel.org/r/20240327020122.439424-1-dlemoal@kernel.org
Reviewed-by: John Garry <john.g.garry@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 months agoMerge patch series "ufs: host: mediatek: Provide features and fixes in MediaTek platf...
Martin K. Petersen [Tue, 26 Mar 2024 01:15:10 +0000 (21:15 -0400)]
Merge patch series "ufs: host: mediatek: Provide features and fixes in MediaTek platforms"

Peter Wang <peter.wang@mediatek.com> says:

This series fixes some defects and provide features in MediaTek UFS
drivers.

Link: https://lore.kernel.org/r/20240315083448.7185-1-peter.wang@mediatek.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 months agoscsi: ufs: mediatek: Support rtff in PM flow
Alice Chao [Fri, 15 Mar 2024 08:34:48 +0000 (16:34 +0800)]
scsi: ufs: mediatek: Support rtff in PM flow

Add mtcmos control function and config.

Signed-off-by: Alice Chao <alice.chao@mediatek.com>
Reviewed-by: Peter Wang <peter.wang@mediatek.com>
Acked-by: Chun-Hung Wu <Chun-Hung.Wu@mediatek.com>
Signed-off-by: Peter Wang <peter.wang@mediatek.com>
Link: https://lore.kernel.org/r/20240315083448.7185-8-peter.wang@mediatek.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 months agoscsi: ufs: mediatek: Support mphy reset
Peter Wang [Fri, 15 Mar 2024 08:34:47 +0000 (16:34 +0800)]
scsi: ufs: mediatek: Support mphy reset

Reset mphy when resetting host. Backup mphy setting after mphy reset
control get. Restore mphy setting after mphy reset.

Acked-by: Chun-Hung Wu <Chun-Hung.Wu@mediatek.com>
Signed-off-by: Peter Wang <peter.wang@mediatek.com>
Link: https://lore.kernel.org/r/20240315083448.7185-7-peter.wang@mediatek.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 months agoscsi: ufs: mediatek: Rename host power control API
Po-Wen Kao [Fri, 15 Mar 2024 08:34:46 +0000 (16:34 +0800)]
scsi: ufs: mediatek: Rename host power control API

Mediatek host power includes two parts:

 1. ufshci power, which is the main power of ufs host controller.

 2. ufshci crypto sram power, which is the power of ufs crypto engine.

The host power control is actually controlling crypto sram power. Rename
it.

Signed-off-by: Po-Wen Kao <powen.kao@mediatek.com>
Acked-by: Chun-Hung Wu <Chun-Hung.Wu@mediatek.com>
Reviewed-by: Peter Wang <peter.wang@mediatek.com>
Signed-off-by: Peter Wang <peter.wang@mediatek.com>
Reviewed-by: Avri Altman <avri.altman@wdc.com>
Link: https://lore.kernel.org/r/20240315083448.7185-6-peter.wang@mediatek.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 months agoscsi: ufs: mediatek: UFS mtk sip command reconstruct
Po-Wen Kao [Fri, 15 Mar 2024 08:34:45 +0000 (16:34 +0800)]
scsi: ufs: mediatek: UFS mtk sip command reconstruct

Move sip command and associated define to a new sip header file.

Signed-off-by: Po-Wen Kao <powen.kao@mediatek.com>
Acked-by: Chun-Hung Wu <Chun-Hung.Wu@mediatek.com>
Reviewed-by: Peter Wang <peter.wang@mediatek.com>
Signed-off-by: Peter Wang <peter.wang@mediatek.com>
Link: https://lore.kernel.org/r/20240315083448.7185-5-peter.wang@mediatek.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 months agoscsi: ufs: mediatek: Add UFS_MTK_CAP_DISABLE_MCQ
Po-Wen Kao [Fri, 15 Mar 2024 08:34:44 +0000 (16:34 +0800)]
scsi: ufs: mediatek: Add UFS_MTK_CAP_DISABLE_MCQ

Add new mediatek host cap UFS_MTK_CAP_DISABLE_MCQ to allow disabling MCQ
feature by assigning dts boolean property "mediatek,ufs-disable-mcq".

Signed-off-by: Po-Wen Kao <powen.kao@mediatek.com>
Reviewed-by: Peter Wang <peter.wang@mediatek.com>
Acked-by: Chun-Hung Wu <Chun-Hung.Wu@mediatek.com>
Signed-off-by: Peter Wang <peter.wang@mediatek.com>
Reviewed-by: Avri Altman <avri.altman@wdc.com>
Link: https://lore.kernel.org/r/20240315083448.7185-4-peter.wang@mediatek.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 months agoscsi: ufs: mediatek: TX skew fix
Peter Wang [Fri, 15 Mar 2024 08:34:43 +0000 (16:34 +0800)]
scsi: ufs: mediatek: TX skew fix

Fix Mediatek TX skew issue by checking dts setting and vendor/model. Then
set PA_TACTIVATE to 8.

Signed-off-by: Peter Wang <peter.wang@mediatek.com>
Acked-by: Chun-Hung Wu <Chun-Hung.Wu@mediatek.com>
Reviewed-by: Avri Altman <avri.altman@wdc.com>
Link: https://lore.kernel.org/r/20240315083448.7185-3-peter.wang@mediatek.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 months agoscsi: ufs: mediatek: Fix vsx/vccqx control logic
Peter Wang [Fri, 15 Mar 2024 08:34:42 +0000 (16:34 +0800)]
scsi: ufs: mediatek: Fix vsx/vccqx control logic

VSX (the upper layer of VCCQ/VCCQ2) should:

 1. Always set to hpm mode if ufs device is active.

 2. Enter lpm mode only if ufs device is not active.

VCCQX should:

 1. Keep hpm mode if vccq and vccq2 not set in dts.

 2. Keep hpm mode if vcc not set in dts keep vcc always on.

 3. Keep hpm if broken vcc keep vcc always on and not allow vccq lpm.

 4. Except upper case, can enter lpm mode if ufs device is not active.

Acked-by: Chun-Hung Wu <Chun-Hung.Wu@mediatek.com>
Signed-off-by: Peter Wang <peter.wang@mediatek.com>
Link: https://lore.kernel.org/r/20240315083448.7185-2-peter.wang@mediatek.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 months agoMerge patch series "mpi3mr: Few Enhancements and minor fixes"
Martin K. Petersen [Mon, 25 Mar 2024 22:15:27 +0000 (18:15 -0400)]
Merge patch series "mpi3mr: Few Enhancements and minor fixes"

Ranjan Kumar <ranjan.kumar@broadcom.com> says:

Few Enhancements and minor fixes of mpi3mr driver.

Link: https://lore.kernel.org/r/20240313100746.128951-1-ranjan.kumar@broadcom.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 months agoscsi: mpi3mr: Driver version update to 8.8.1.0.50
Ranjan Kumar [Wed, 13 Mar 2024 10:07:46 +0000 (15:37 +0530)]
scsi: mpi3mr: Driver version update to 8.8.1.0.50

Update driver version to 8.8.1.0.50.

Signed-off-by: Ranjan Kumar <ranjan.kumar@broadcom.com>
Link: https://lore.kernel.org/r/20240313100746.128951-8-ranjan.kumar@broadcom.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 months agoscsi: mpi3mr: Update MPI Headers to revision 31
Ranjan Kumar [Wed, 13 Mar 2024 10:07:45 +0000 (15:37 +0530)]
scsi: mpi3mr: Update MPI Headers to revision 31

Update MPI Headers to revision 31.

Signed-off-by: Ranjan Kumar <ranjan.kumar@broadcom.com>
Signed-off-by: Sathya Prakash <sathya.prakash@broadcom.com>
Link: https://lore.kernel.org/r/20240313100746.128951-7-ranjan.kumar@broadcom.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 months agoscsi: mpi3mr: Debug ability improvements
Ranjan Kumar [Wed, 13 Mar 2024 10:07:44 +0000 (15:37 +0530)]
scsi: mpi3mr: Debug ability improvements

Update driver to include OS type in fault/reset reason code.  MPI request
sent through ioctl now automatically dumped on timeout.

Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202403081903.q3Dq54zZ-lkp@intel.com/
Signed-off-by: Ranjan Kumar <ranjan.kumar@broadcom.com>
Signed-off-by: Sathya Prakash <sathya.prakash@broadcom.com>
Link: https://lore.kernel.org/r/20240313100746.128951-6-ranjan.kumar@broadcom.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 months agoscsi: mpi3mr: Set the WriteSame Divert Capability in the IOCInit MPI Request
Ranjan Kumar [Wed, 13 Mar 2024 10:07:43 +0000 (15:37 +0530)]
scsi: mpi3mr: Set the WriteSame Divert Capability in the IOCInit MPI Request

Modify driver to set the Write Same Divert Capability bit in the IOCInit
message for the firmware to know that the driver is capable of diverting
certain Write Same commands as defined by the MPI specification.

Signed-off-by: Ranjan Kumar <ranjan.kumar@broadcom.com>
Signed-off-by: Sathya Prakash <sathya.prakash@broadcom.com>
Link: https://lore.kernel.org/r/20240313100746.128951-5-ranjan.kumar@broadcom.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
5 months agoscsi: mpi3mr: Clear ioctl blocking flag for an unresponsive controller
Ranjan Kumar [Wed, 13 Mar 2024 10:07:42 +0000 (15:37 +0530)]
scsi: mpi3mr: Clear ioctl blocking flag for an unresponsive controller

The driver uses a controller-wide flag to block ioctls when a controller
reset is in progress. This flag is set before controller reset is initiated
and cleared after the reset has completed.

Make the driver clear the controller-wide block ioctls flag after a
controller reset fails and the controller is marked unrecoverable.

Signed-off-by: Ranjan Kumar <ranjan.kumar@broadcom.com>
Signed-off-by: Sumit Saxena <sumit.saxena@broadcom.com>
Link: https://lore.kernel.org/r/20240313100746.128951-4-ranjan.kumar@broadcom.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>