These patches are based on Martin Petersen's 6.12/scsi-queue tree
https://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git
6.12/scsi-queue
There are two functional changes:
smartpqi-add-fw-log-to-kdump
smartpqi-add-counter-for-parity-write-stream-requests
There are three minor bug fixes:
smartpqi-fix-stream-detection
smartpqi-fix-rare-system-hang-during-LUN-reset
smartpqi-fix-volume-size-updates
The other two patches add PCI-IDs for new controllers and change the
driver version.
This set of changes consists of:
* smartpqi-add-fw-log-to-kdump
During a kdump, the driver tells the controller to copy its logging
information to some pre-allocated buffers that can be analyzed
later.
This is a "feature" driven capability and is backward compatible
with existing controller FW.
This patch renames some prefixes for OFA (Online-Firmware Activation
ofa_*) buffers to host_memory_*. So, not a lot of actual functional
changes to smartpqi_init.c, mainly determining the memory size
allocation.
We added a function to notify the controller to copy debug data into
host memory before continuing kdump.
Most of the functional changes are in smartpqi_sis.c where the
actual handshaking is done.
* smartpqi-fix-stream-detection
Correct some false write-stream detections. The data structure used
to check for write-streams was not initialized to all 0's causing
some false write stream detections. The driver sends down streamed
requests to the raid engine instead of using AIO bypass for some
extra performance. (Potential full-stripe write verses Read Modify
Write).
False detections have not caused any data corruption. Found by
internal testing. No known externally reported bugs.
Adding some counters for raid_bypass and write streams. These two
counters are related because write stream detection is only checked
if an I/O request is eligible for bypass (AIO).
The bypass counter (raid_bypass_cnt) was moved into a common
structure (pqi_raid_io_stats) and changed to type __percpu. The
write stream counter is (write_stream_cnt) has been added to this
same structure.
These counters are __percpu counters for performance. We added a
sysfs entry to show the write stream count. The raid bypass counter
sysfs entry already exists.
Useful for checking streaming writes. The change in the sysfs entry
write_stream_cnt can be checked during AIO eligible write
operations.
* smartpqi-add-new-controller-PCI-IDs
Adding support for new controller HW. No functional changes.
* smartpqi-fix-rare-system-hang-during-LUN-reset
We found a rare race condition that can occur during a LUN reset. We
were not emptying our internal queue completely.
There have been some rare conditions where our internal request
queue has requests for multiple LUNs and a reset comes in for one of
the LUNs. The driver waits for this internal queue to empty. We were
only clearing out the requests for the LUN being reset so the
request queue was never empty causing a hang.
The Fix:
For all requests in our internal request queue:
Complete requests with DID_RESET for queued requests for the
device undergoing a reset.
Complete requests with DID_REQUEUE for all other queued requests.
Found by internal testing. No known externally reported bugs.
* smartpqi-fix-volume-size-updates
The current code only checks for a size change if there is also a
queue depth change. We are separating the check for queue depth and
the size changes.
Found by internal testing. No known bugs were filed.
* smartpqi-update-version-to-2.1.30-031
No functional changes.
Murthy Bhat [Tue, 27 Aug 2024 18:54:59 +0000 (13:54 -0500)]
scsi: smartpqi: fix rare system hang during LUN reset
Correct a rare case where in a LUN reset occurs on a device and I/O
requests for other devices persist in the driver's internal request queue.
Part of a LUN reset involves waiting for our internal request queue to
empty before proceeding. The internal request queue contains requests not
yet sent down to the controller.
We were clearing the requests queued for the LUN undergoing a reset, but
not all of the queued requests. Causing a hang.
For all requests in our internal request queue:
Complete requests with DID_RESET for queued requests for the device
undergoing a reset.
Complete requests with DID_REQUEUE for all other queued requests.
scsi: smartpqi: add counter for parity write stream requests
Add sysfs entry to check for write stream requests.
Move existing raid_bypass_cnt into a structure named pqi_raid_io_stats and
add member write_stream_cnt. These two counters are related because write
stream detection is only checked if an I/O request is eligible for bypass
(AIO).
Example usage:
lsscsi
[15:1:0:0] disk Adaptec LOGICAL VOLUME 0129 /dev/sdae
cat /sys/block/sdae/device/ssd_smart_path_enabled
1
^
|
+---- NOTE: here bypass has been enabled on device sdae
To read the counter for parity write stream requests:
Correct stream detection by initializing the structure
pqi_scsi_dev_raid_map_data to 0s.
When the OS issues SCSI READ commands, the driver erroneously considers
them as SCSI WRITES. If they are identified as sequential IOs, the driver
then submits those requests via the RAID path instead of the AIO path.
The 'is_write' flag might be set for SCSI READ commands also. The driver
may interpret SCSI READ commands as SCSI WRITE commands, resulting in IOs
being submitted through the RAID path.
Murthy Bhat [Tue, 27 Aug 2024 18:54:55 +0000 (13:54 -0500)]
scsi: smartpqi: Add fw log to kdump
Add controller logs to kdump.
Driver allocates DMA memory and communicates this address to FW. In the
event of system crash, host driver notifies the firmware about the crash
and firmware posts all the necessary logs in the pre-allocated host buffer
for firmware debugging.
Once firmware notifies the completion of the log uploading to the host
memory and host continues with the OS crash dump saving.
This is a "feature" driven capability and is backward compatible with
existing controller FW.
Rename some prefixes for OFA (Online-Firmware Activation ofa_*) buffers to
host_memory_*. So, not a lot of actual functional changes to
smartpqi_init.c, mainly determining the memory size allocation.
Added a function to notify the controller to copy debug data into host
memory before continuing kdump.
Most of the functional changes are in smartpqi_sis.c where the actual
handshaking is done.
scsi: qla2xxx: Remove the unused 'del_list_entry' field in struct fc_port
The 'del_list_entry' field in "struct fc_port" is unused.
The field was introduced in commit 2d70c103fd2a ("[SCSI] qla2xxx: Add LLD
target-mode infrastructure for >= 24xx series") in 2012-05 and the last
user was removed in commit 726b85487067 ("qla2xxx: Add framework for async
fabric discovery") in 2017-02.
Bao D. Nguyen [Tue, 27 Aug 2024 23:14:13 +0000 (16:14 -0700)]
scsi: ufs: core: Remove ufshcd_urgent_bkops()
ufshcd_urgent_bkops() is a wrapper function. It only calls
ufshcd_bkops_ctrl(). Remove it to simplify the ufs core driver. Replace any
references to ufshcd_urgent_bkops() with ufshcd_bkops_ctrl().
In addition, remove the second parameter in the ufshcd_bkops_ctrl() because
the information can be retrieved from the first parameter.
Multiple SCSI drivers use snprintf() to format a workqueue name before
invoking one of the create*_workqueue() macros. This patch series
simplifies such code by passing the format string and arguments to
alloc_workqueue(). Additionally, the structure members that are only
used as a temporary buffer for formatting workqueue names are
removed. Please consider this patch series for the next merge window.
Bart Van Assche [Thu, 22 Aug 2024 19:59:22 +0000 (12:59 -0700)]
scsi: core: Simplify an alloc_workqueue() invocation
Let alloc_workqueue() format the workqueue name. Remove the
work_q_name[] member from struct Scsi_Host because it is no longer
used by any SCSI driver nor by the SCSI core.
Let alloc_workqueue() format the workqueue name instead of calling
snprintf() explicitly. Not setting shost->work_q_name is safe because
there is no code that reads the value set by the removed code.
Bart Van Assche [Thu, 22 Aug 2024 19:59:05 +0000 (12:59 -0700)]
scsi: Expand all create*_workqueue() invocations
The workqueue maintainer wants to remove the create*_workqueue() macros
because these macros always set the WQ_MEM_RECLAIM flag and because these
only support literal workqueue names. Hence this patch that replaces the
create*_workqueue() invocations with the definition of this macro. The
WQ_MEM_RECLAIM flag has been retained because I think that flag is necessary
for workqueues created by storage drivers. This patch has been generated by
running spatch and git clang-format. spatch has been invoked as follows:
Commit d703ce2f7f4d ("iscsi/iser-target: Convert to command priv_size
usage") remove iscsit_alloc_cmd() but left declaration.
And finally, a few other declarations were never implenmented since
introduction in commit e48354ce078c ("iscsi-target: Add iSCSI fabric
support for target v4.1").
Dan Carpenter [Thu, 15 Aug 2024 11:29:05 +0000 (14:29 +0300)]
scsi: elx: libefc: Fix potential use after free in efc_nport_vport_del()
The kref_put() function will call nport->release if the refcount drops to
zero. The nport->release release function is _efc_nport_free() which frees
"nport". But then we dereference "nport" on the next line which is a use
after free. Re-order these lines to avoid the use after free.
Dan Carpenter [Thu, 15 Aug 2024 11:24:36 +0000 (14:24 +0300)]
scsi: ufs: ufshcd-pltfrm: Signedness bug in ufshcd_parse_clock_info()
The "sz" variable needs to be a signed type for the error handling to work
as intended. Fortunately, there is some sanity checking on "sz" on the
next line, so negative values would be caught and it doesn't really affect
runtime.
Avri Altman [Sun, 11 Aug 2024 14:37:57 +0000 (17:37 +0300)]
scsi: ufs: Add HCI capabilities sysfs group
The standard register map of UFSHCI is comprised of several groups. The
first group (starting from offset 0x00), is the host capabilities group.
It contains some interesting information that otherwise is not available,
e.g. the UFS version of the platform etc.
Avri Altman [Sun, 11 Aug 2024 14:37:56 +0000 (17:37 +0300)]
scsi: ufs: Prepare to add HCI capabilities sysfs
Prepare so we'll be able to read various other HCI registers. While at it,
fix the HCPID & HCMID register names to stand for what they really are.
Also replace the pm_runtime_{get/put}_sync() calls in auto_hibern8_show to
ufshcd_rpm_{get/put}_sync() as any host controller register reads should.
This series begins with some work on the mac_scsi driver to improve
compatibility with SCSI2SD v5 devices. Better error handling is needed
there because the PDMA hardware does not tolerate the write latency
spikes which SD cards can produce.
A bug is fixed in the 5380 core driver so that scatter/gather can be
enabled in mac_scsi.
Several patches at the end of this series improve robustness and
correctness in the core driver.
This series has been tested on a variety of mac_scsi hosts. A variety
of SCSI targets was also tested, including Quantum HDD, Fujitsu HDD,
Iomega FDD, Ricoh CD-RW, Matsushita CD-ROM, SCSI2SD and BlueSCSI.
Finn Thain [Wed, 7 Aug 2024 03:36:28 +0000 (13:36 +1000)]
scsi: NCR5380: Remove redundant result calculation from NCR5380_transfer_pio()
NCR5380_transfer_pio() returns an ambiguous value which is ignored by
callers. Make it void and remove the redundant calculation. Adopt
kernel-doc format for the updated description.
Finn Thain [Wed, 7 Aug 2024 03:36:28 +0000 (13:36 +1000)]
scsi: NCR5380: Handle BSY signal loss during information transfer phases
Improve robustness by checking for a lost BSY signal during the information
transfer loop. The status register is being polled anyway, so a BSY check
costs nothing. BSY signal loss could be caused by a target error or a
kicked plug etc. A bus reset is another possibility but that is already
handled and hostdata->connected would be NULL.
Finn Thain [Wed, 7 Aug 2024 03:36:28 +0000 (13:36 +1000)]
scsi: NCR5380: Initialize buffer for MSG IN and STATUS transfers
Following an incomplete transfer in MSG IN phase, the driver would not
notice the problem and would make use of invalid data. Initialize 'tmp'
appropriately and bail out if no message was received. For STATUS phase,
preserve the existing status code unless a new value was transferred.
Finn Thain [Wed, 7 Aug 2024 03:36:28 +0000 (13:36 +1000)]
scsi: mac_scsi: Enable scatter/gather by default
Now that FLAG_DMA_FIXUP has itself been fixed up, it can be used to enable
scatter/gather. Increase the default value for sg_tablesize to SG_ALL for
those systems which are compatible with FLAG_DMA_FIXUP.
Finn Thain [Wed, 7 Aug 2024 03:36:28 +0000 (13:36 +1000)]
scsi: NCR5380: Check for phase match during PDMA fixup
It's not an error for a target to change the bus phase during a transfer.
Unfortunately, the FLAG_DMA_FIXUP workaround does not allow for that -- a
phase change produces a DRQ timeout error and the device borken flag will
be set.
Check the phase match bit during FLAG_DMA_FIXUP processing. Don't forget to
decrement the command residual. While we are here, change shost_printk()
into scmd_printk() for better consistency with other DMA error messages.
Finn Thain [Wed, 7 Aug 2024 03:36:28 +0000 (13:36 +1000)]
scsi: mac_scsi: Disallow bus errors during PDMA send
SD cards can produce write latency spikes on the order of a hundred
milliseconds. If the target firmware does not hide that latency during DATA
IN and OUT phases it can cause the PDMA circuitry to raise a processor bus
fault which in turn leads to an unreliable byte count and a DMA overrun.
The Last Byte Sent flag is used to detect the overrun but this mechanism is
unreliable on some systems. Instead, set a DID_ERROR result whenever there
is a bus fault during a PDMA send, unless the cause was a phase mismatch.
Finn Thain [Wed, 7 Aug 2024 03:36:28 +0000 (13:36 +1000)]
scsi: mac_scsi: Refactor polling loop
Before the error handling can be revised, some preparation is needed.
Refactor the polling loop with a new function, macscsi_wait_for_drq().
This function will gain more call sites in the next patch.
After a bus fault, capture and log the chip registers immediately, if the
NDEBUG_PSEUDO_DMA macro is defined. Remove some printk(KERN_DEBUG ...)
messages that aren't needed any more. Don't skip the debug message when
bytes == 0. Show all of the byte counters in the debug messages.
Ranjan Kumar [Thu, 8 Aug 2024 12:54:17 +0000 (18:24 +0530)]
scsi: mpi3mr: Update consumer index of reply queues after every 100 replies
Instead of updating the ConsumerIndex of the Admin and Operational
ReplyQueues after processing all replies in the queue, the index will now
be periodically updated after processing every 100 replies.
Ranjan Kumar [Thu, 8 Aug 2024 12:54:16 +0000 (18:24 +0530)]
scsi: mpi3mr: Return complete ioc_status for ioctl commands
The driver masked the loginfo available bit in the iocstatus before passing
it to the applications, causing a mismatch in error messages between Linux
and other operating systems.
Modify driver to return unmasked (complete) iocstatus, including the
loginfo available bit, for the MPI commands sent through the ioctl
interface.
scsi: ufs: ufshcd-pltfrm: Use of_property_count_u32_elems() to get property length
Replace of_get_property() with the type specific
of_property_count_u32_elems() to get the property length.
This is part of a larger effort to remove callers of of_get_property() and
similar functions. of_get_property() leaks the DT property data pointer
which is a problem for dynamically allocated nodes which may be freed.
scsi: ufs: ufshcd-pltfrm: Use of_property_present()
Use of_property_present() to test for property presence rather than
of_find_property(). This is part of a larger effort to remove callers of
of_find_property() and similar functions. of_find_property() leaks the DT
struct property and data pointers which is a problem for dynamically
allocated nodes which may be freed.
John Garry [Mon, 5 Aug 2024 11:33:15 +0000 (11:33 +0000)]
scsi: block: Don't check REQ_ATOMIC for reads
We check in submit_bio_noacct() if flag REQ_ATOMIC is set for both read and
write operations, and then validate the atomic operation if set. Flag
REQ_ATOMIC can only be set for writes, so don't bother checking for reads.
The functional changes of note to smartpqi are for: multipath failover
and improving the accuracy of our RAID bypass counter.
For multipath we are:
Reverting commit 94a68c814328 ("scsi: smartpqi: Quickly propagate
path failures to SCSI midlayer") because under certain rare
conditions involving encryption-enabled devices, a false path
failure is reported to the SML causing multipath to failover to
the other path.
Improving errors returned from the driver back to the SML by
checking for error codes returned from the firmware and returning
the correct ASC/ASCQ codes to the SML.
The other two patches add PCI-IDs for new controllers and change the
driver version.
Correct a rare multipath failure issue by reverting commit 94a68c814328
("scsi: smartpqi: Quickly propagate path failures to SCSI midlayer") [1].
Reason for revert: The patch propagated the path failure to SML quickly
when one of the path fails during IO and AIO path gets disabled for a
multipath device.
But it created a new issue: when creating a volume on an encryption-enabled
controller, the firmware reports the AIO path is disabled, which cause the
driver to report a path failure to SML for a multipath device.
There will be a new fix to handle "Illegal request" and "Invalid field in
parameter list" on RAID path when the AIO path is disabled on a multipath
device.
Kevin Barnett [Thu, 11 Jul 2024 19:47:01 +0000 (14:47 -0500)]
scsi: smartpqi: Improve accuracy/performance of raid-bypass-counter
The original implementation of this counter used an atomic variable.
However, this implementation negatively impacted performance in some
configurations.
This patch set contains diagnostic logging improvements, a minor clean
up when submitting abort requests, a bug fix related to reset and
errata paths, and modifications to FLOGI and PRLO ELS command
handling.
The patches were cut against Martin's 6.11/scsi-queue tree.
Justin Tee [Fri, 26 Jul 2024 23:15:10 +0000 (16:15 -0700)]
scsi: lpfc: Update PRLO handling in direct attached topology
A kref imbalance occurs when handling an unsolicited PRLO in direct
attached topology.
Rework PRLO rcv handling when in MAPPED state. Save the state that we were
handling a PRLO by setting nlp_last_elscmd to ELS_CMD_PRLO. Then in the
lpfc_cmpl_els_logo_acc() completion routine, manually restart discovery.
By issuing the PLOGI, which nlp_gets, before nlp_put at the end of the
lpfc_cmpl_els_logo_acc() routine, we are saving us from a final nlp_put.
And, we are still allowing the unreg_rpi to happen.
Justin Tee [Fri, 26 Jul 2024 23:15:09 +0000 (16:15 -0700)]
scsi: lpfc: Fix unsolicited FLOGI kref imbalance when in direct attached topology
In direct attached topology, certain target vendors that are quick to issue
FLOGI followed by a cable pull for more than dev_loss_tmo may result in a
kref imbalance for the remote port ndlp object.
Add an nlp_get when the defer_flogi_acc flag is set. This is expected to
balance the nlp_put in the defer_flogi_acc clause in the
lpfc_issue_els_flogi() routine. Because we need to retain the ndlp ptr,
reorganize all of the defer_flogi_acc information into one
lpfc_defer_flogi_acc struct.
Justin Tee [Fri, 26 Jul 2024 23:15:08 +0000 (16:15 -0700)]
scsi: lpfc: Fix unintentional double clearing of vmid_flag
The vport->vmid_flag is unintentionally cleared twice after an issue_lip
via the lpfc_reinit_vmid routine().
The first call to lpfc_reinit_vmid() is in lpfc_cmpl_els_flogi(). Then
lpfc_cmpl_els_flogi_fabric() calls lpfc_register_new_vport(), which calls
lpfc_cmpl_reg_new_vport() when the mbox command completes and calls
lpfc_reinit_vmid() a second time.
Fix by moving the vmid_flag clear outside of the lpfc_reinit_vmid() routine
so that vmid_flag is only cleared once upon FLOGI completion.
Justin Tee [Fri, 26 Jul 2024 23:15:07 +0000 (16:15 -0700)]
scsi: lpfc: Validate hdwq pointers before dereferencing in reset/errata paths
When the HBA is undergoing a reset or is handling an errata event, NULL ptr
dereference crashes may occur in routines such as
lpfc_sli_flush_io_rings(), lpfc_dev_loss_tmo_callbk(), or
lpfc_abort_handler().
Add NULL ptr checks before dereferencing hdwq pointers that may have been
freed due to operations colliding with a reset or errata event handler.
Justin Tee [Fri, 26 Jul 2024 23:15:05 +0000 (16:15 -0700)]
scsi: lpfc: Change diagnostic log flag during receipt of unknown ELS cmds
During diagnostics, it has been determined that the 0115 log message for
receipt of unknown ELS cmds does not benefit from trace buffer dumps. The
trace buffer dump floods the console with unnecessary information, and the
singular LOG_ELS flag has proven more beneficial in debugging efforts when
dealing with unknown ELS cmds.
Bao D. Nguyen [Wed, 24 Jul 2024 03:49:32 +0000 (20:49 -0700)]
scsi: ufs: core: Support Updating UIC Command Timeout
The default UIC command timeout still remains 500ms. Allow platform
drivers to override the UIC command timeout if desired.
In a real product, the 500ms timeout value is probably good enough.
However, during the product development where there are a lot of logging
and debug messages being printed to the UART console, interrupt starvations
happen occasionally because the UART may print long debug messages from
different modules in the system. While printing, the UART may have
interrupts disabled for more than 500ms, causing UIC command timeout. The
UIC command timeout would trigger more printing from the UFS driver, and
eventually a watchdog timeout may occur unnecessarily.
Add support for overriding the UIC command timeout value with the newly
created uic_cmd_timeout kernel module parameter. Default value is
500ms. Supported values range from 500ms to 2 seconds.
This replaces some of the last remaining uses in the kernel of
1-element "fake" flexible arrays with modern C99 flexible arrays. Some
refactoring is done to ease this, and binary differences are
identified. For the on stack size changes in patch 2, the "yes, that
is the source of the binary differences" debugging patch can be found
here[1].
scsi: aacraid: struct {user,}sgmap{,64,raw}: Replace 1-element arrays with flexible arrays
Replace the deprecated[1] use of 1-element arrays in struct sgmap, struct
sgmap64, struct sgmapraw, struct user_sgmap, and struct user_sgmap64 with
modern flexible arrays. Additionally remove struct user_sgmapraw as it is
unused.
The resulting binary output differences from this change are limited only
to stack space consumption of the smaller "srbu" variable in
aac_issue_safw_bmic_identify() and aac_get_safw_ciss_luns(), as well as the
smaller associated pair of memcpy()s in
aac_send_safw_bmic_cmd(). Artificially growing the size of srbu back to its
prior size removes all binary differences[2].
As an aside, after studying the aacraid driver code I wonder how
aac_send_wellness_command() ever works. It is reporting a size 4 bytes too
small for what it has constructed in memory in the DMA region: sgentry64 is
size 12, whereas sgentry is size 8. Perhaps the hardware doesn't
care. (Regardless, it is unchanged by this patch.)
scsi: aacraid: Rearrange order of struct aac_srb_unit
struct aac_srb_unit contains struct aac_srb, which contains struct sgmap,
which ends in a (currently) "fake" (1-element) flexible array. Converting
this to a flexible array is needed so that runtime bounds checking won't
think the array is fixed size (i.e. under CONFIG_FORTIFY_SOURCE=y and/or
CONFIG_UBSAN_BOUNDS=y), as other parts of aacraid use struct sgmap as a
flexible array.
It is not legal to have a flexible array in the middle of a structure, so
it either needs to be split up or rearranged so that it is at the end of
the structure. Luckily, struct aac_srb_unit, which is exclusively
consumed/updated by aac_send_safw_bmic_cmd(), does not depend on member
ordering.
The values set in the on-stack struct aac_srb_unit instance "srbu" by the
only two callers, aac_issue_safw_bmic_identify() and
aac_get_safw_ciss_luns(), do not contain anything in srbu.srb.sgmap.sg, and
they both implicitly initialize srbu.srb.sgmap.count to 0 during
memset(). For example:
But this is happening in the DMA memory, not in srbu.srb. An attempt to
copy the changes back to srbu does happen:
/*
* Copy the updated data for other dumping or other usage if
* needed
*/
memcpy(&srbu->srb, srb, sizeof(struct aac_srb));
But this was never correct: the sg64 (3 u32s) overlap of srb.sg (2 u32s)
always meant that srbu.srb would have held truncated information and any
attempt to walk srbu.srb.sg.sg based on the value of srbu.srb.sg.count
would result in attempting to parse past the end of srbu.srb.sg.sg[0] into
srbu.srb_reply.
After getting a reply from hardware, the reply is copied into
srbu.srb_reply:
This has always been fixed-size, so there's no issue here. It is worth
noting that the two callers _never check_ srbu contents -- neither
srbu.srb nor srbu.srb_reply is examined. (They depend on the mapped
xfer_buf instead.)
Therefore, the ordering of members in struct aac_srb_unit does not matter,
and the flexible array member can moved to the end.
(Additionally, the two memcpy()s that update srbu could be entirely
removed as they are never consumed, but I left that as-is.)
Replace all remaining uses of deprecated 1-element "fake" flexible
arrays with modern C99 flexible arrays. Add __counted_by annotations
at the same time.
Replace the deprecated[1] use of a 1-element array in struct
_CONFIG_PAGE_IOC_2 with a modern flexible array.
Additionally add __counted_by annotation since RaidVolume is only ever
accessed from loops controlled by NumActiveVolumes:
lsi/mpi_cnfg.h: CONFIG_PAGE_IOC_2_RAID_VOL RaidVolume[] __counted_by(NumActiveVolumes); /* 0Ch */
mptbase.c: for (i = 0; i < pIoc2->NumActiveVolumes ; i++)
mptbase.c: pIoc2->RaidVolume[i].VolumeBus,
mptbase.c: pIoc2->RaidVolume[i].VolumeID);
mptsas.c: for (i = 0; i < ioc->raid_data.pIocPg2->NumActiveVolumes; i++) {
mptsas.c: RaidVolume[i].VolumeID) {
mptsas.c: RaidVolume[i].VolumeBus;
mptsas.c: for (i = 0; i < ioc->raid_data.pIocPg2->NumActiveVolumes; i++) {
mptsas.c: ioc->raid_data.pIocPg2->RaidVolume[i].VolumeID, 0);
mptsas.c: ioc->raid_data.pIocPg2->RaidVolume[i].VolumeID);
mptsas.c: ioc->raid_data.pIocPg2->RaidVolume[i].VolumeID, 0);
mptsas.c: for (i = 0; i < ioc->raid_data.pIocPg2->NumActiveVolumes; i++) {
mptsas.c: if (ioc->raid_data.pIocPg2->RaidVolume[i].VolumeID ==
mptsas.c: for (i = 0; i < ioc->raid_data.pIocPg2->NumActiveVolumes; i++)
mptsas.c: if (ioc->raid_data.pIocPg2->RaidVolume[i].VolumeID == id)
mptspi.c: for (i=0; i < ioc->raid_data.pIocPg2->NumActiveVolumes; i++) {
mptspi.c: if (ioc->raid_data.pIocPg2->RaidVolume[i].VolumeID == id) {
No binary differences are present after this conversion.
scsi: ipr: Replace 1-element arrays with flexible arrays
Replace the deprecated[1] use of a 1-element arrays in struct
ipr_hostrcb_fabric_desc and struct ipr_hostrcb64_fabric_desc with modern
flexible arrays.
No binary differences are present after this conversion.
scsi: aacraid: union aac_init: Replace 1-element array with flexible array
Replace the deprecated[1] use of a 1-element array in union aac_init with a
modern flexible array.
Additionally add __counted_by annotation since rrq is only ever accessed
after rr_queue_count has been set (with the same value used to control the
loop):
init->r8.rr_queue_count = cpu_to_le32(dev->max_msix);
...
for (i = 0; i < dev->max_msix; i++) {
addr = (u64)dev->host_rrq_pa + dev->vector_cap * i *
sizeof(u32);
init->r8.rrq[i].host_addr_high = cpu_to_le32(
upper_32_bits(addr));
No binary differences are present after this conversion.
The memset() clears only the non-flexible array fields. Looking at the rest
of the function, this appears to be fine: firmware is using this region to
communicate with the kernel, so it likely never made sense to clear the
first MR_HOST_DEVICE_LIST_ENTRY.
Merge tag 'kbuild-fixes-v6.11' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild
Pull Kbuild fixes from Masahiro Yamada:
- Fix RPM package build error caused by an incorrect locale setup
- Mark modules.weakdep as ghost in RPM package
- Fix the odd combination of -S and -c in stack protector scripts,
which is an error with the latest Clang
* tag 'kbuild-fixes-v6.11' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild:
kbuild: Fix '-S -c' in x86 stack protector scripts
kbuild: rpm-pkg: ghost modules.weakdep file
kbuild: rpm-pkg: Fix C locale setup
minmax: simplify and clarify min_t()/max_t() implementation
This simplifies the min_t() and max_t() macros by no longer making them
work in the context of a C constant expression.
That means that you can no longer use them for static initializers or
for array sizes in type definitions, but there were only a couple of
such uses, and all of them were converted (famous last words) to use
MIN_T/MAX_T instead.
Commit 3a7e02c040b1 ("minmax: avoid overly complicated constant
expressions in VM code") added the simpler MIN_T/MAX_T macros in order
to avoid some excessive expansion from the rather complicated regular
min/max macros.
The complexity of those macros stems from two issues:
(a) trying to use them in situations that require a C constant
expression (in static initializers and for array sizes)
(b) the type sanity checking
and MIN_T/MAX_T avoids both of these issues.
Now, in the whole (long) discussion about all this, it was pointed out
that the whole type sanity checking is entirely unnecessary for
min_t/max_t which get a fixed type that the comparison is done in.
But that still leaves min_t/max_t unnecessarily complicated due to
worries about the C constant expression case.
However, it turns out that there really aren't very many cases that use
min_t/max_t for this, and we can just force-convert those.
This does exactly that.
Which in turn will then allow for much simpler implementations of
min_t()/max_t(). All the usual "macros in all upper case will evaluate
the arguments multiple times" rules apply.
We should do all the same things for the regular min/max() vs MIN/MAX()
cases, but that has the added complexity of various drivers defining
their own local versions of MIN/MAX, so that needs another level of
fixes first.
kbuild: Fix '-S -c' in x86 stack protector scripts
After a recent change in clang to stop consuming all instances of '-S'
and '-c' [1], the stack protector scripts break due to the kernel's use
of -Werror=unused-command-line-argument to catch cases where flags are
not being properly consumed by the compiler driver:
$ echo | clang -o - -x c - -S -c -Werror=unused-command-line-argument
clang: error: argument unused during compilation: '-c' [-Werror,-Wunused-command-line-argument]
This results in CONFIG_STACKPROTECTOR getting disabled because
CONFIG_CC_HAS_SANE_STACKPROTECTOR is no longer set.
'-c' and '-S' both instruct the compiler to stop at different stages of
the pipeline ('-S' after compiling, '-c' after assembling), so having
them present together in the same command makes little sense. In this
case, the test wants to stop before assembling because it is looking at
the textual assembly output of the compiler for either '%fs' or '%gs',
so remove '-c' from the list of arguments to resolve the error.
All versions of GCC continue to work after this change, along with
versions of clang that do or do not contain the change mentioned above.