History log of /linux-master/drivers/scsi/myrb.c
Revision Date Author Comments
# 1197c5b2 26-Mar-2024 Arnd Bergmann <arnd@arndb.de>

scsi: mylex: Fix sysfs buffer lengths

The myrb and myrs drivers use an odd way of implementing their sysfs files,
calling snprintf() with a fixed length of 32 bytes to print into a page
sized buffer. One of the strings is actually longer than 32 bytes, which
clang can warn about:

drivers/scsi/myrb.c:1906:10: error: 'snprintf' will always be truncated; specified size is 32, but format string expands to at least 34 [-Werror,-Wformat-truncation]
drivers/scsi/myrs.c:1089:10: error: 'snprintf' will always be truncated; specified size is 32, but format string expands to at least 34 [-Werror,-Wformat-truncation]

These could all be plain sprintf() without a length as the buffer is always
long enough. On the other hand, sysfs files should not be overly long
either, so just double the length to make sure the longest strings don't
get truncated here.

Fixes: 77266186397c ("scsi: myrs: Add Mylex RAID controller (SCSI interface)")
Fixes: 081ff398c56c ("scsi: myrb: Add Mylex RAID controller (block interface)")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Link: https://lore.kernel.org/r/20240326223825.4084412-8-arnd@kernel.org
Reviewed-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 8e64d59d 22-Mar-2023 Bart Van Assche <bvanassche@acm.org>

scsi: myrb: Declare SCSI host template const

Make it explicit that the SCSI host template is not modified.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Link: https://lore.kernel.org/r/20230322195515.1267197-59-bvanassche@acm.org
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# f9f0a461 23-May-2022 Hannes Reinecke <hare@suse.de>

scsi: myrb: Fix up null pointer access on myrb_cleanup()

When myrb_probe() fails the callback might not be set, so we need to
validate the 'disable_intr' callback in myrb_cleanup() to not cause a null
pointer exception. And while at it do not call myrb_cleanup() if we cannot
enable the PCI device at all.

Link: https://lore.kernel.org/r/20220523120244.99515-1-hare@suse.de
Reported-by: Zheyu Ma <zheyuma97@gmail.com>
Tested-by: Zheyu Ma <zheyuma97@gmail.com>
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 27363ba8 22-Dec-2021 Christoph Hellwig <hch@lst.de>

scsi: myrb: Don't use GFP_DMA in myrb_pdev_slave_alloc()

The driver doesn't express DMA addressing limitation under 32-bits anywhere
else, so remove the spurious GFP_DMA allocation.

Link: https://lore.kernel.org/r/20211222091801.924745-1-hch@lst.de
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 582c0360 12-Oct-2021 Bart Van Assche <bvanassche@acm.org>

scsi: myrb: Switch to attribute groups

struct device supports attribute groups directly but does not support
struct device_attribute directly. Hence switch to attribute groups.

Link: https://lore.kernel.org/r/20211012233558.4066756-32-bvanassche@acm.org
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 0061e3f5 07-Oct-2021 Bart Van Assche <bvanassche@acm.org>

scsi: myrb: Call scsi_done() directly

Conditional statements are faster than indirect calls. Hence call
scsi_done() directly.

Link: https://lore.kernel.org/r/20211007202923.2174984-55-bvanassche@acm.org
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 2fd8f23a 09-Aug-2021 Bart Van Assche <bvanassche@acm.org>

scsi: myrb: Use scsi_cmd_to_rq() instead of scsi_cmnd.request

Prepare for removal of the request pointer by using scsi_cmd_to_rq()
instead. This patch does not change any functionality.

Link: https://lore.kernel.org/r/20210809230355.8186-33-bvanassche@acm.org
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# f2b1e9c6 27-Apr-2021 Hannes Reinecke <hare@suse.de>

scsi: core: Introduce scsi_build_sense()

Introduce scsi_build_sense() as a wrapper around scsi_build_sense_buffer()
to format the buffer and set the correct SCSI status.

Link: https://lore.kernel.org/r/20210427083046.31620-8-hare@suse.de
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 3690ad67 15-Apr-2021 Bart Van Assche <bvanassche@acm.org>

scsi: myrb: Remove unused functions

This was detected by building the kernel with clang and W=1.

Link: https://lore.kernel.org/r/20210415220826.29438-11-bvanassche@acm.org
Cc: Hannes Reinecke <hare@kernel.org>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 182ad87c 27-Mar-2021 Shixin Liu <liushixin2@huawei.com>

scsi: myrb: Make symbols DAC960_{LA/PG/PD/P}_privdata static

This symbol is not used outside of myrb.c, so we can mark it static.

Link: https://lore.kernel.org/r/20210327073156.1786722-1-liushixin2@huawei.com
Signed-off-by: Shixin Liu <liushixin2@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 12a1b740 17-Mar-2021 Lee Jones <lee.jones@linaro.org>

scsi: myrb: Demote non-conformant kernel-doc headers and fix others

Fixes the following W=1 kernel build warning(s):

drivers/scsi/myrb.c:91: warning: Function parameter or member 'pdev' not described in 'myrb_create_mempools'
drivers/scsi/myrb.c:91: warning: Function parameter or member 'cb' not described in 'myrb_create_mempools'
drivers/scsi/myrb.c:141: warning: Function parameter or member 'cb' not described in 'myrb_destroy_mempools'
drivers/scsi/myrb.c:153: warning: Function parameter or member 'cmd_blk' not described in 'myrb_reset_cmd'
drivers/scsi/myrb.c:164: warning: Function parameter or member 'cb' not described in 'myrb_qcmd'
drivers/scsi/myrb.c:164: warning: Function parameter or member 'cmd_blk' not described in 'myrb_qcmd'
drivers/scsi/myrb.c:187: warning: Function parameter or member 'cb' not described in 'myrb_exec_cmd'
drivers/scsi/myrb.c:187: warning: Function parameter or member 'cmd_blk' not described in 'myrb_exec_cmd'
drivers/scsi/myrb.c:208: warning: Function parameter or member 'cb' not described in 'myrb_exec_type3'
drivers/scsi/myrb.c:208: warning: Function parameter or member 'op' not described in 'myrb_exec_type3'
drivers/scsi/myrb.c:208: warning: Function parameter or member 'addr' not described in 'myrb_exec_type3'
drivers/scsi/myrb.c:231: warning: Function parameter or member 'cb' not described in 'myrb_exec_type3D'
drivers/scsi/myrb.c:231: warning: Function parameter or member 'op' not described in 'myrb_exec_type3D'
drivers/scsi/myrb.c:231: warning: Function parameter or member 'sdev' not described in 'myrb_exec_type3D'
drivers/scsi/myrb.c:231: warning: Function parameter or member 'pdev_info' not described in 'myrb_exec_type3D'
drivers/scsi/myrb.c:341: warning: Function parameter or member 'cb' not described in 'myrb_get_errtable'
drivers/scsi/myrb.c:388: warning: Function parameter or member 'cb' not described in 'myrb_get_ldev_info'
drivers/scsi/myrb.c:440: warning: Function parameter or member 'cb' not described in 'myrb_get_rbld_progress'
drivers/scsi/myrb.c:440: warning: Function parameter or member 'rbld' not described in 'myrb_get_rbld_progress'
drivers/scsi/myrb.c:472: warning: Function parameter or member 'cb' not described in 'myrb_update_rbld_progress'
drivers/scsi/myrb.c:533: warning: Function parameter or member 'cb' not described in 'myrb_get_cc_progress'
drivers/scsi/myrb.c:580: warning: Function parameter or member 'cb' not described in 'myrb_bgi_control'
drivers/scsi/myrb.c:671: warning: Function parameter or member 'cb' not described in 'myrb_hba_enquiry'
drivers/scsi/myrb.c:782: warning: Function parameter or member 'cb' not described in 'myrb_set_pdev_state'
drivers/scsi/myrb.c:782: warning: Function parameter or member 'sdev' not described in 'myrb_set_pdev_state'
drivers/scsi/myrb.c:782: warning: Function parameter or member 'state' not described in 'myrb_set_pdev_state'
drivers/scsi/myrb.c:808: warning: Function parameter or member 'cb' not described in 'myrb_enable_mmio'
drivers/scsi/myrb.c:808: warning: Function parameter or member 'mmio_init_fn' not described in 'myrb_enable_mmio'
drivers/scsi/myrb.c:913: warning: Function parameter or member 'cb' not described in 'myrb_get_hba_config'
drivers/scsi/myrb.c:1200: warning: Function parameter or member 'cb' not described in 'myrb_unmap'
drivers/scsi/myrb.c:1236: warning: Function parameter or member 'cb' not described in 'myrb_cleanup'
drivers/scsi/myrb.c:2249: warning: Function parameter or member 'dev' not described in 'myrb_is_raid'
drivers/scsi/myrb.c:2260: warning: Function parameter or member 'dev' not described in 'myrb_get_resync'
drivers/scsi/myrb.c:2287: warning: Function parameter or member 'dev' not described in 'myrb_get_state'
drivers/scsi/myrb.c:2493: warning: Function parameter or member 'cb' not described in 'myrb_err_status'
drivers/scsi/myrb.c:2493: warning: Function parameter or member 'error' not described in 'myrb_err_status'
drivers/scsi/myrb.c:2493: warning: Function parameter or member 'parm0' not described in 'myrb_err_status'
drivers/scsi/myrb.c:2493: warning: Function parameter or member 'parm1' not described in 'myrb_err_status'

Link: https://lore.kernel.org/r/20210317091230.2912389-2-lee.jones@linaro.org
Cc: Hannes Reinecke <hare@kernel.org>
Cc: "James E.J. Bottomley" <jejb@linux.ibm.com>
Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
Cc: Linux GmbH <hare@suse.com>
Cc: "Leonard N. Zubkoff" <lnz@dandelion.com>
Cc: linux-scsi@vger.kernel.org
Signed-off-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 3bc08b95 26-Nov-2020 Ahmed S. Darwish <a.darwish@linutronix.de>

scsi: myrb: Remove WARN_ON(in_interrupt())

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

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

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

Just remove it.

Link: https://lore.kernel.org/r/20201126132952.2287996-11-bigeasy@linutronix.de
Cc: Hannes Reinecke <hare@kernel.org>
Reviewed-by: Daniel Wagner <dwagner@suse.de>
Signed-off-by: Ahmed S. Darwish <a.darwish@linutronix.de>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# fc29f04a 29-Sep-2020 Ye Bin <yebin10@huawei.com>

scsi: myrb: Fix inconsistent format argument types

Fix the following warnings:

[drivers/scsi/myrb.c:1052]: (warning) %d in format string (no. 1)
requires 'int' but the argument type is 'unsigned int'.
[drivers/scsi/myrb.c:1052]: (warning) %d in format string (no. 2)
requires 'int' but the argument type is 'unsigned int'.
[drivers/scsi/myrb.c:1052]: (warning) %d in format string (no. 4)
requires 'int' but the argument type is 'unsigned int'.
[drivers/scsi/myrb.c:2170]: (warning) %d in format string (no. 1)
requires 'int' but the argument type is 'unsigned int'.

Link: https://lore.kernel.org/r/20200930021637.2831618-1-yebin10@huawei.com
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Ye Bin <yebin10@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 5f6dcb55 28-Sep-2020 Jing Xiangfeng <jingxiangfeng@huawei.com>

scsi: myrb: Remove redundant assignment to variable timeout

The variable timeout has been initialized with a value '0'. The assignment
before while loop is redundant. Remove it.

Link: https://lore.kernel.org/r/20200929022458.40652-1-jingxiangfeng@huawei.com
Signed-off-by: Jing Xiangfeng <jingxiangfeng@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 9d8a5510 15-Sep-2020 Jason Yan <yanaijie@huawei.com>

scsi: myrb: Make some symblos static

This addresses the following sparse warning:

drivers/scsi/myrb.c:2229:27: warning: symbol 'myrb_template' was not
declared. Should it be static?
drivers/scsi/myrb.c:2318:31: warning: symbol 'myrb_raid_functions' was
not declared. Should it be static?
drivers/scsi/myrb.c:2492:6: warning: symbol 'myrb_err_status' was not
declared. Should it be static?

Link: https://lore.kernel.org/r/20200915084018.2826922-1-yanaijie@huawei.com
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Jason Yan <yanaijie@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# df561f66 23-Aug-2020 Gustavo A. R. Silva <gustavoars@kernel.org>

treewide: Use fallthrough pseudo-keyword

Replace the existing /* fall through */ comments and its variants with
the new pseudo-keyword macro fallthrough[1]. Also, remove unnecessary
fall-through markings when it is the case.

[1] https://www.kernel.org/doc/html/v5.7/process/deprecated.html?highlight=fallthrough#implicit-switch-case-fall-through

Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>


# 4bdc0d67 06-Jan-2020 Christoph Hellwig <hch@lst.de>

remove ioremap_nocache and devm_ioremap_nocache

ioremap has provided non-cached semantics by default since the Linux 2.6
days, so remove the additional ioremap_nocache interface.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Acked-by: Arnd Bergmann <arnd@arndb.de>


# 4c5765e4 27-Nov-2018 Gustavo A. R. Silva <gustavo@embeddedor.com>

scsi: myrb: Mark expected switch fall-throughs

In preparation to enabling -Wimplicit-fallthrough, mark switch cases where
we are expecting to fall through.

Addresses-Coverity-ID: 1465234 ("Missing break in switch")
Addresses-Coverity-ID: 1465238 ("Missing break in switch")
Addresses-Coverity-ID: 1465242 ("Missing break in switch")
Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# c3d6189f 19-Dec-2018 Christoph Hellwig <hch@lst.de>

scsi: myrb: remove the dma_boundary limit

The old DAC960 driver was fine with merging over segment boundaries, so
this new driver should be too.

[mkp: typos]

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 4af14d11 13-Dec-2018 Christoph Hellwig <hch@lst.de>

scsi: remove the use_clustering flag

The same effects can be achieved by setting the dma_boundary to
PAGE_SIZE - 1 and the max_segment_size to PAGE_SIZE, so shift those
settings into the drivers. Note that in many cases the setting might
be bogus, but this keeps the status quo.

[mkp: fix myrs and myrb]

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 4dd4130a 13-Dec-2018 Christoph Hellwig <hch@lst.de>

scsi: make sure all drivers set the use_clustering flag

A few drivers were not setting the use_clustering flag at all and thus
default to disable. Fix them up to explicitly set this field in
preparation for additional cleanups.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# f8f4adc1 02-Nov-2018 Arnd Bergmann <arnd@arndb.de>

scsi: myrb: fix sprintf buffer overflow warning

gcc warns that the 12 byte fw_version field might not be long enough to
contain the generated firmware name string:

drivers/scsi/myrb.c: In function 'myrb_get_hba_config':
drivers/scsi/myrb.c:1052:38: error: '%02d' directive writing between 2 and 3 bytes into a region of size between 2 and 5 [-Werror=format-overflow=]
sprintf(cb->fw_version, "%d.%02d-%c-%02d",
^~~~
drivers/scsi/myrb.c:1052:26: note: directive argument in the range [0, 255]
sprintf(cb->fw_version, "%d.%02d-%c-%02d",
^~~~~~~~~~~~~~~~~
drivers/scsi/myrb.c:1052:2: note: 'sprintf' output between 10 and 14 bytes into a destination of size 12
sprintf(cb->fw_version, "%d.%02d-%c-%02d",
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
enquiry2->fw.major_version,
~~~~~~~~~~~~~~~~~~~~~~~~~~~
enquiry2->fw.minor_version,
~~~~~~~~~~~~~~~~~~~~~~~~~~~
enquiry2->fw.firmware_type,
~~~~~~~~~~~~~~~~~~~~~~~~~~~
enquiry2->fw.turn_id);
~~~~~~~~~~~~~~~~~~~~~

I have not checked whether there are appropriate range checks before the
sprintf, but there is a range check after it that will bail out in case
of out of range version numbers. This means we can simply use snprintf()
instead of sprintf() to limit the output buffer size, and it will work
correctly.

Fixes: 081ff398c56c ("scsi: myrb: Add Mylex RAID controller (block interface)")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 081ff398 17-Oct-2018 Hannes Reinecke <hare@suse.com>

scsi: myrb: Add Mylex RAID controller (block interface)

This patch adds support for the Mylex DAC960 RAID controller,
supporting the older, block-based interface only. The driver is a
re-implementation of the original DAC960 driver.

Signed-off-by: Hannes Reinecke <hare@suse.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>