History log of /freebsd-current/sys/dev/mrsas/mrsas.c
Revision Date Author Comments
# 4640df1b 06-Oct-2023 Mark Johnston <markj@FreeBSD.org>

mrsas: Fix callout locking in mrsas_complete_cmd()

callout_stop() requires the associated lock to be held.

This is a bit hacky, but I believe it's safe since the subsequent
mrsas_cmd_done() call will also acquire the SIM lock to stop a different
callout.

PR: 265484
Reviewed by: imp
Tested by: Jérémie Jourdin <jeremie.jourdin@advens.fr>
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D39559


# 685dc743 16-Aug-2023 Warner Losh <imp@FreeBSD.org>

sys: Remove $FreeBSD$: one-line .c pattern

Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/


# e315351f 24-Aug-2022 Doug Ambrisko <ambrisko@FreeBSD.org>

Add the mfi(4) ioctl support to mrsas(4)

The hardware supported by mfi(4) and mrsas(4) use the same dcmd's.
mfiutil(8) in theory could run on controlled attached to mrsas(4).
It can't since mrsas(4) doesn't have support for the FreeBSD mfi(4)
ioctl. Porting the ioctl from mfi(4) to mrsas(4) would be the first
step in making mrsasutil(8) which is an additional name for mfiutil(8)
but opens /dev/mrsasX instead of /dev/mfiX

PR: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=265794
Reviewed by: jhb
Differential revision: https://reviews.freebsd.org/D36342
Tested by: Dan Mahoney <freebsd@gushi.org>


# 9f0c0e6e 21-Dec-2022 John Baldwin <jhb@FreeBSD.org>

mrsas: Don't leak a stack pointer value in the softc.

mrsas_issue_blocked_cmd stores a pointer to an on-stack variable
in its softc so that the driver can call wakeup() on the correct
pointer. Once the loop around tsleep() has finished however, the
pointer is no longer needed and any further use would be invalid.
Clear sc->chan to NULL after the loop.

Reported by: GCC -Wdangling-pointer
Differential Revision: https://reviews.freebsd.org/D37628


# 8b2be9cb 20-Apr-2022 John Baldwin <jhb@FreeBSD.org>

mrsas: Remove unused devclass argument to DRIVER_MODULE.


# 79c4c4be 21-Jan-2022 Chandrakanth Patil <chandrakanth.patil@broadcom.com>

mrsas: if controller reset is in progress, refrain from firing DCMDs to
firmware in shutdown

If controller reset is in progress, at same time if system shutdown is
issued then corresponding shutdown function in driver will be invoked
where driver is waiting 15 seconds to complete the controller reset.

If the reset is not complteted within that time frame driver will go
ahead and fire cache flush and shutdown DCMDs which will end up
accessing the the queues which are not initialized due to undergoing
reset leads to FMU error in firmware.

Fix:
In shutdown function, if controller reset is not finished within 15
seconds than driver will return to the OS without firing any DCMDs.

Reviewed by: imp
PR: 261375


# 32c601b6 02-Apr-2022 Gordon Bergling <gbe@FreeBSD.org>

mrsas(4): Fix a typo in a source code comment

- s/alloction/allocation/

MFC after: 3 days


# 98470f0e 04-Dec-2021 Scott Long <scottl@FreeBSD.org>

Fix "set but not used" in mrsas. This includes removing unnecessary cdevsw
methods.

Sponsored by: Rubicon Communications, LLC ("Netgate")


# fa3d57c2 01-Jul-2021 Alexander Motin <mav@FreeBSD.org>

mrsas(4): Report more correct maximum I/O size.

Subtract one SGE for the case of misaligned address. Also take into
account maximum number of sectors reported by firmware, that gives
nicer 256KB limit instead of 276KB calculated from the SGE limit.

While there, remove number of I/O size checks, duplicating what is
already checked by CAM and busdma(9).

MFC after: 1 month
Sponsored by: iXsystems, Inc.


# 59fffbcf 05-Feb-2021 Alfredo Dal'Ava Junior <alfredo@FreeBSD.org>

mrsas: unbreak i386 build

Fix build regression introduced by
e34a057ca6ebdf8e30ec8b0dc21d18eb450bf36a

Reviewed by: jhibbits
Sponsored by: Eldorado Research Institute (eldorado.org.br)
Differential Revision: https://reviews.freebsd.org/D28494


# e34a057c 03-Feb-2021 Alfredo Dal'Ava Junior <alfredo@FreeBSD.org>

[POWERPC64BE] mrsas: add big-endian support

Add endiannes conversions in order to support big-endian platforms

Submitted by: Andre Fernando da Silva <andre.silva@eldorado.org.br>
Reviewed by: luporl, alfredo, kadesai (on email)
Sponsored by: Eldorado Research Institute (eldorado.org.br)
Differential Revision: https://reviews.freebsd.org/D26531


# cd853791 27-Nov-2020 Konstantin Belousov <kib@FreeBSD.org>

Make MAXPHYS tunable. Bump MAXPHYS to 1M.

Replace MAXPHYS by runtime variable maxphys. It is initialized from
MAXPHYS by default, but can be also adjusted with the tunable kern.maxphys.

Make b_pages[] array in struct buf flexible. Size b_pages[] for buffer
cache buffers exactly to atop(maxbcachebuf) (currently it is sized to
atop(MAXPHYS)), and b_pages[] for pbufs is sized to atop(maxphys) + 1.
The +1 for pbufs allow several pbuf consumers, among them vmapbuf(),
to use unaligned buffers still sized to maxphys, esp. when such
buffers come from userspace (*). Overall, we save significant amount
of otherwise wasted memory in b_pages[] for buffer cache buffers,
while bumping MAXPHYS to desired high value.

Eliminate all direct uses of the MAXPHYS constant in kernel and driver
sources, except a place which initialize maxphys. Some random (and
arguably weird) uses of MAXPHYS, e.g. in linuxolator, are converted
straight. Some drivers, which use MAXPHYS to size embeded structures,
get private MAXPHYS-like constant; their convertion is out of scope
for this work.

Changes to cam/, dev/ahci, dev/ata, dev/mpr, dev/mpt, dev/mvs,
dev/siis, where either submitted by, or based on changes by mav.

Suggested by: mav (*)
Reviewed by: imp, mav, imp, mckusick, scottl (intermediate versions)
Tested by: pho
Sponsored by: The FreeBSD Foundation
Differential revision: https://reviews.freebsd.org/D27225


# 139b723f 01-Sep-2020 Mateusz Guzik <mjg@FreeBSD.org>

mrsas: clean up empty lines in .c and .h files


# 7029da5c 26-Feb-2020 Pawel Biernacki <kaktus@FreeBSD.org>

Mark more nodes as CTLFLAG_MPSAFE or CTLFLAG_NEEDGIANT (17 of many)

r357614 added CTLFLAG_NEEDGIANT to make it easier to find nodes that are
still not MPSAFE (or already are but aren’t properly marked).
Use it in preparation for a general review of all nodes.

This is non-functional change that adds annotations to SYSCTL_NODE and
SYSCTL_PROC nodes using one of the soon-to-be-required flags.

Mark all obvious cases as MPSAFE. All entries that haven't been marked
as MPSAFE before are by default marked as NEEDGIANT

Approved by: kib (mentor, blanket)
Commented by: kib, gallatin, melifaro
Differential Revision: https://reviews.freebsd.org/D23718


# 879e0604 11-Jan-2020 Mateusz Guzik <mjg@FreeBSD.org>

Add KERNEL_PANICKED macro for use in place of direct panicstr tests


# f28ecf2b 22-May-2019 Andriy Gapon <avg@FreeBSD.org>

add mrsas_shutdown method

It should be safer to flush controller and disk caches on the shutdown.
And to gracefully shut down the controller as well.
It seems that the Linux driver has been doing that for a long time.

Discussed with: scottl
Reviewed by: imp, Sumit Saxena <sumit.saxena@broadcom.com>
(both earlier version)
MFC after: 3 weeks
Sponsored by: Panzura
Differential Revision: https://reviews.freebsd.org/D19817


# 54f784f5 12-Mar-2019 Kashyap D Desai <kadesai@FreeBSD.org>

Allocated MFI frames should be same as MPT frames reserved for DCMDs

Submitted by: Sumit Saxena <sumit.saxena@broadcom.com>
Reviewed by: Kashyap Desai <Kashyap.Desai@broadcom.com>
Approved by: Ken
MFC after: 3 days
Sponsored by: Broadcom Inc


# 5437c8b8 12-Mar-2019 Kashyap D Desai <kadesai@FreeBSD.org>

fw_outstanding"(outstanding IOs at firmware level) counter gets screwed up when R1 fastpath
writes are running. Some of the cases which are not handled properly in driver are:

1. With R1 fastpath supported, single write from CAM layer can consume 2 MPT frames
at driver/firmware level for fastpath qualification(if fw_outstanding < controller Queue Depth).
Due to this driver has to throttle IOs coming from CAM layer as well as second fastpath
write(of R1 write) against Adapter Queue Depth.
If "fw_outstanding" reaches to adapter queue depth, driver should return IOs from CAM layer with
device busy status.While allocating second MPT frame(corresponding to R1 FP write) also, driver
should ensure fw_outstanding should not exceed adapter QD.

2. For R1 fastpath writes completion, driver decrements "fw_oustanding" counter without
really returning MPT frame to free pool. It may cause IOs(with heavy IOs running, consuming whole
adapter Queue Depth) consuming MPT frames reserved for DCMDs(management commands) and
DCMDs(internal and sent by application) not getting MPT frame will start failing.

Below is one test case to hit the issue described above-
1. Run heavy IOs (outstanding IOs should hit adapter Queue Depth).
2. Run management tool (Broadcom's storcli tool) querying adapter in loop (run command- "storcli64 /c0 show" in loop).
3. Management tool's requests would start failing due to non-availability of free MPT frames as all frames would be consumed by IOs.

Fix: Increment/decrement of "fw_outstanding" counter should be in sync with MPT frame get/return.

Submitted by: Sumit Saxena <sumit.saxena@broadcom.com>
Reviewed by: Kashyap Desai <Kashyap.Desai@broadcom.com>
Approved by: Ken
MFC after: 3 days
Sponsored by: Broadcom Inc


# e315cf4d 26-Dec-2018 Kashyap D Desai <kadesai@FreeBSD.org>

Problem statement:
Due to hardware errata in Aero controllers, reads to certain
fusion registers could intermittently return all zeroes.
This behavior is transient in nature and subsequent reads will return
valid value.

Fix:
For Aero controllers, any read will retry the read operations
from certain registers for maximum three times, if read returns zero.

Submitted by: Sumit Saxena <sumit.saxena@broadcom.com>
Reviewed by: Kashyap Desai <Kashyap.Desai@broadcom.com>
Approved by: ken
MFC after: 3 days
Sponsored by: Broadcom Inc


# b518670c 26-Dec-2018 Kashyap D Desai <kadesai@FreeBSD.org>

This patch will add support for 32 bit atomic request descriptor for Aero adapters.

For Aero adapters-
1. Driver will use 32 bit atomic descriptor to fire IOs and DCMDs.
2. Driver will use 64 bit request descriptor to fire IOC INIT.
3. If Aero firmware supports 32 bit atomic descriptor, then only driver will use it
otherwise driver will use 64 bit request descriptor.

For rest of adapters(Ventura, Invader and Thunderbolt), driver will use 64 bit request
descriptors only.

Submitted by: Sumit Saxena <sumit.saxena@broadcom.com>
Reviewed by: Kashyap Desai <Kashyap.Desai@broadcom.com>
Approved by: ken
MFC after: 3 days
Sponsored by: Broadcom Inc


# 2909aab4 26-Dec-2018 Kashyap D Desai <kadesai@FreeBSD.org>

This patch will add support for latest generation MegaRAID adapters- Aero(39xx).
Driver will throw a warning message when a Configurable secure type controller is
encountered.

Submitted by: Sumit Saxena <sumit.saxena@broadcom.com>
Reviewed by: Kashyap Desai <Kashyap.Desai@broadcom.com>
Approved by: ken
MFC after: 3 days
Sponsored by: Broadcom Inc


# 56d91e49 14-Dec-2018 Kashyap D Desai <kadesai@FreeBSD.org>

This patch will increase debug level as current logging level has
very minimal prints and even few important messages will not get logged.

Submitted by: Sumit Saxena <sumit.saxena@broadcom.com>
Reviewed by: Kashyap Desai <Kashyap.Desai@broadcom.com>
Approved by: ken
MFC after: 3 days
Sponsored by: Broadcom Inc


# e80341d5 14-Dec-2018 Kashyap D Desai <kadesai@FreeBSD.org>

Change IOC INIT wait time to 180 secs to keep it inline with timeout
used by internal DCMDs.

Submitted by: Sumit Saxena <sumit.saxena@broadcom.com>
Reviewed by: Kashyap Desai <Kashyap.Desai@broadcom.com>
Approved by: ken
MFC after: 3 days
Sponsored by: Broadcom Inc


# 3d273176 14-Dec-2018 Kashyap D Desai <kadesai@FreeBSD.org>

This patch will add support for NVME PRPs creation by driver for fastpath
capable IOs. NVME specification supports specific type of scatter gather list
called as PRP (Physical Region Page) for IO data buffers. Since NVME drive is
connected behind SAS3.5 tri-mode adapter, MegaRAID driver/firmware has to convert
OS SGLs in native NVMe PRP format. For IOs sent to firmware, MegaRAID firmware
does this job of OS SGLs to PRP translation and send PRPs to backend NVME device.
For fastpath IOs, driver will do this OS SGLs to PRP translation.

Submitted by: Sumit Saxena <sumit.saxena@broadcom.com>
Reviewed by: Kashyap Desai <Kashyap.Desai@broadcom.com>
Approved by: ken
MFC after: 3 days
Sponsored by: Broadcom Inc


# 79b4460b 14-Dec-2018 Kashyap D Desai <kadesai@FreeBSD.org>

This patch will add support for new DCMD to get PD information and a single data structure
to specify LD and JBOD.

Submitted by: Sumit Saxena <sumit.saxena@broadcom.com>
Reviewed by: Kashyap Desai <Kashyap.Desai@broadcom.com>
Approved by: ken
MFC after: 3 days
Sponsored by: Broadcom Inc


# 2a1d3bcd 14-Dec-2018 Kashyap D Desai <kadesai@FreeBSD.org>

To improve RAID 1/10 Write performance, OS drivers need to issue the
required Write IOs as Fast Path IOs (after the appropriate checks
allowing Fast Path to be used) to the appropriate physical drives
(translated from the OS logical IO) and wait for all Write IOs to complete.

Design: A write IO on RAID volume will be examined if it can be sent in
Fast Path based on IO size and starting LBA and ending LBA falling on to
a Physical Drive boundary. If the underlying RAID volume is a RAID 1/10,
driver issues two fast path write IOs one for each corresponding physical
drive after computing the corresponding start LBA for each physical drive.
Both write IOs will have the same payload and are posted to HW such that
replies land in the same reply queue.

If there are no resources available for sending two IOs, driver will send
the original IO from upper layer to RAID volume through the Firmware.

When both IOs are completed by HW, the resources will be released
and SCSI IO completion handler will be called.

Submitted by: Sumit Saxena <sumit.saxena@broadcom.com>
Reviewed by: Kashyap Desai <Kashyap.Desai@broadcom.com>
Approved by: ken
MFC after: 3 days
Sponsored by: Broadcom Inc


# 821df4b9 14-Dec-2018 Kashyap D Desai <kadesai@FreeBSD.org>

Detect sequential Write IOs and pass the hint that it is part of sequential
stream to help HBA Firmware do the Full Stripe Writes. For read IOs on
certain RAID volumes like Read Ahead volumes,this will help driver to
send it to Firmware even if the IOs can potentially be sent to
hardware directly (called fast path) bypassing firmware.

Design: 8 streams are maintained per RAID volume as per the combined
firmware/driver design. When there is no stream detected the LRU stream
is used for next potential stream and LRU/MRU map is updated to make this
as MRU stream. Every time a stream is detected the MRU map
is updated to make the current stream as MRU stream.

Submitted by: Sumit Saxena <sumit.saxena@broadcom.com>
Reviewed by: Kashyap Desai <Kashyap.Desai@broadcom.com>
Approved by: ken
MFC after: 3 days
Sponsored by: Broadcom Inc


# c376f864 14-Dec-2018 Kashyap D Desai <kadesai@FreeBSD.org>

This patch will add new interface to support more than 256 JBODs.

Submitted by: Sumit Saxena <sumit.saxena@broadcom.com>
Reviewed by: Kashyap Desai <Kashyap.Desai@broadcom.com>
Approved by: ken
MFC after: 3 days
Sponsored by: Broadcom Inc


# 503c4f8d 14-Dec-2018 Kashyap D Desai <kadesai@FreeBSD.org>

This patch will add support for divert bitmap in RAID map. Divert bitmap is supported for
SAS3.5 adapters only.

Submitted by: Sumit Saxena <sumit.saxena@broadcom.com>
Reviewed by: Kashyap Desai <Kashyap.Desai@broadcom.com>
Approved by: ken
MFC after: 3 days
Sponsored by: Broadcom Inc


# 4ad83576 14-Dec-2018 Kashyap D Desai <kadesai@FreeBSD.org>

This patch will add support for new Dynamic RaidMap to have different sizes
for different number of supported VDs for SAS3.5 MegaRAID adapters.

Submitted by: Sumit Saxena <sumit.saxena@broadcom.com>
Reviewed by: Kashyap Desai <Kashyap.Desai@broadcom.com>
Approved by: ken
MFC after: 3 days
Sponsored by: Broadcom Inc


# 7aade8bf 14-Dec-2018 Kashyap D Desai <kadesai@FreeBSD.org>

This patch will add support for next generation(SAS3.5) of Tri mode(SAS, SATA, NVMe)
MegaRAID adapters.

Submitted by: Sumit Saxena <sumit.saxena@broadcom.com>
Reviewed by: Kashyap Desai <Kashyap.Desai@broadcom.com>
Approved by: ken
MFC after: 3 days
Sponsored by: Broadcom Inc


# ac2fffa4 21-Jan-2018 Pedro F. Giffuni <pfg@FreeBSD.org>

Revert r327828, r327949, r327953, r328016-r328026, r328041:
Uses of mallocarray(9).

The use of mallocarray(9) has rocketed the required swap to build FreeBSD.
This is likely caused by the allocation size attributes which put extra pressure
on the compiler.

Given that most of these checks are superfluous we have to choose better
where to use mallocarray(9). We still have more uses of mallocarray(9) but
hopefully this is enough to bring swap usage to a reasonable level.

Reported by: wosch
PR: 225197


# 26c1d774 13-Jan-2018 Pedro F. Giffuni <pfg@FreeBSD.org>

dev: make some use of mallocarray(9).

Focus on code where we are doing multiplications within malloc(9). None of
these is likely to overflow, however the change is still useful as some
static checkers can benefit from the allocation attributes we use for
mallocarray.

This initial sweep only covers malloc(9) calls with M_NOWAIT. No good
reason but I started doing the changes before r327796 and at that time it
was convenient to make sure the sorrounding code could handle NULL values.


# 2d53b485 29-Nov-2016 Kashyap D Desai <kadesai@FreeBSD.org>

This patch will add code to refire IOCTL commands after OCR.

Submitted by: Sumit Saxena <sumit.saxena@broadcom.com>
Reviewed by: Kashyap Desai <Kashyap.Desai@broadcom.com>
MFC after: 3 days
Sponsored by: Broadcom Limited/AVAGO Technologies


# d993dd83 29-Nov-2016 Kashyap D Desai <kadesai@FreeBSD.org>

This patch will unblock SYNCHRONIZE_CACHE command to firmware, i.e. don't block the SYNCHRONIZE_CACHE command at driver instead of
passing it to firmware for all Gen3 controllers.
For Thunderbolt controller, keep the legacy behavior i.e. return the SYNCHRONIZE_CACHE command with success status from driver itself.

There is Sysctl parameter 'block_sync_cache' is provided to enable customers either to block/unblock these commands to facilitate
legacy behavior if there is a compatibility issue. Default value for module parameter is to unblock this command.

Submitted by: Sumit Saxena <sumit.saxena@broadcom.com>
Reviewed by: Kashyap Desai <Kashyap.Desai@broadcom.com>
MFC after: 3 days
Sponsored by: Broadcom Limited/AVAGO Technologies


# 85c0a961 29-Nov-2016 Kashyap D Desai <kadesai@FreeBSD.org>

Wait for AEN task to be completed(if in queue) before resetting the controller
and return without processing event in AEN thread, if controller reset is in progress.

Submitted by: Sumit Saxena <sumit.saxena@broadcom.com>
Reviewed by: Kashyap Desai <Kashyap.Desai@broadcom.com>
MFC after: 3 days
Sponsored by: Broadcom Limited/AVAGO Technologies


# 8bb601ac 29-Nov-2016 Kashyap D Desai <kadesai@FreeBSD.org>

This patch will add task management support in driver. Below is high level description:
If a SCSI IO times out, then before initiating OCR, now the driver will try to send a
target reset to the particular target for which the IO is timed out. If that also fails,
then the driver will initiate OCR.

Submitted by: Sumit Saxena <sumit.saxena@broadcom.com>
Reviewed by: Kashyap Desai <Kashyap.Desai@broadcom.com>
MFC after: 3 days
Sponsored by: Broadcom Limited/AVAGO Technologies


# e2e8afb1 28-Nov-2016 Kashyap D Desai <kadesai@FreeBSD.org>

Process outstanding reply descriptors from all the reply descriptor post queues before initiating OCR.

Submitted by: Sumit Saxena <sumit.saxena@broadcom.com>
Reviewed by: Kashyap Desai <Kashyap.Desai@broadcom.com>
MFC after: 3 days
Sponsored by: Broadcom Limited/AVAGO Technologies


# c2a20ff9 28-Nov-2016 Kashyap D Desai <kadesai@FreeBSD.org>

Clean up reference to AEN command if abort AEN is succesful as the command is aborted.
Did the same by setting sc->aen_cmd = NULL when aborting AEN is successful.

Submitted by: Sumit Saxena <sumit.saxena@broadcom.com>
Reviewed by: Kashyap Desai <Kashyap.Desai@broadcom.com>
MFC after: 3 days
Sponsored by: Broadcom Limited/AVAGO Technologies


# 8bc320ad 28-Nov-2016 Kashyap D Desai <kadesai@FreeBSD.org>

Update controller properties(read OCR capability bit) when MR_EVT_CTRL_PROP_CHANGED recieved.

Submitted by: Sumit Saxena <sumit.saxena@broadcom.com>
Reviewed by: Kashyap Desai <Kashyap.Desai@broadcom.com>
MFC after: 3 days
Sponsored by: Broadcom Limited/AVAGO Technologies


# 808517a4 28-Nov-2016 Kashyap D Desai <kadesai@FreeBSD.org>

Add sanity check in IO and IOCTL path not to process command further if controller is in
HW_CRITICAL_ERROR.

Submitted by: Sumit Saxena <sumit.saxena@broadcom.com>
Reviewed by: Kashyap Desai <Kashyap.Desai@broadcom.com>
MFC after: 3 days
Sponsored by: Broadcom Limited/AVAGO Technologies


# f9c63081 28-Nov-2016 Kashyap D Desai <kadesai@FreeBSD.org>

Use a variable to indicate Gen3 controllers and remove all PCI ids based
checks used for gen3 controllers.

Submitted by: Sumit Saxena <sumit.saxena@broadcom.com>
Reviewed by: Kashyap Desai <Kashyap.Desai@broadcom.com>
MFC after: 3 days
Sponsored by: Broadcom Limited/AVAGO Technologies


# 731b7561 28-Nov-2016 Kashyap D Desai <kadesai@FreeBSD.org>

Problem statement:
MFI linked list in megaraid_sas driver is used for mfi-mpt pass-through commands.
This list can be corrupted due to many possible race conditions in driver and
eventually we may see kernel panic.

One example -
MFI frame is freed from calling process as driver send command via polling method and interrupt
for that command comes after driver free mfi frame (actually even after some other context reuse
the mfi frame). When driver receive MPT frame in ISR, driver will be using the index of MFI and
access that MFI frame and finally in-used MFI frames list will be corrupted.

High level description of new solution -
Free MFI and MPT command from same context.
Free both the command either from process (from where mfi-mpt pass-through was called) or from
ISR context. Do not split freeing of MFI and MPT, because it creates the race condition which
will do MFI/MPT list.

Submitted by: Sumit Saxena <sumit.saxena@broadcom.com>
Reviewed by: Kashyap Desai <Kashyap.Desai@broadcom.com>
MFC after: 3 days
Sponsored by: Broadcom Limited/AVAGO Technologies


# 8cd174a4 01-Jun-2016 Kashyap D Desai <kadesai@FreeBSD.org>

Added support for Avago/Broadcom Cutlass(12 Gbps- 16 port count) controllers.

Submitted by: Sumit Saxena <Sumit.Saxena@broadcom.com>
Reviewed by: Kashyap Desai <Kashyap.Desai@broadcom.com>
MFC after: 3 days
Sponsored by: AVAGO/BROADCOM Limited


# 4bb0a4f0 12-May-2016 Kashyap D Desai <kadesai@FreeBSD.org>

Following bugs fixed as part of this patch:
.Kernel panic while collecting kdump (reported by Doug A.)
.NULL pointer dereference at sertain places
.Removed dead codes

Submitted by: Sumit Saxena <sumit.saxena@broadcom.com>
Reviewed by: Kashyap Desai <Kashyap.Desai@broadcom.com>
MFC after: 3 days
Sponsored by: AVAGO Technologies


# c620f351 12-May-2016 Kashyap D Desai <kadesai@FreeBSD.org>

Added supprot for Avago Intruder controller.

Submitted by: Sumit Saxena <sumit.saxena@broadcom.com>
Reviewed by: Kashyap Desai <Kashyap.Desai@broadcom.com>
MFC after: 3 days
Sponsored by: AVAGO Technologies


# 8071588d 12-May-2016 Kashyap D Desai <kadesai@FreeBSD.org>

Implemented interrupt Config Hook in mrsas(4) to defer some of the tasks, like:
riegistering AEN, creating cdev.

Submitted by: Sumit Saxena <sumit.saxena@broadcom.com>
Reviewed by: Kashyap Desai <Kashyap.Desai@broadcom.com>
MFC after: 3 days
Sponsored by: AVAGO Technologies


# 3a3fc6cb 12-May-2016 Kashyap D Desai <kadesai@FreeBSD.org>

This patch implements driver support for 1MB IO size.

NOTE:
The FreeBSD system currently restricts the MAX IO size to MAXPHYS which
in turn is 128KB. We tested the 1MB IO by converting the MAXPHYS to 1MB.

Following is the mail reference:
http://lists.freebsd.org/pipermail/freebsd-scsi/2015-January/006568.html

Submitted by: Sumit Saxena <sumit.saxena@broadcom.com>
Reviewed by: Kashyap Desai <Kashyap.Desai@broadcom.com>
MFC after: 3 days
Sponsored by: AVAGO Technologies


# a688fcd0 12-May-2016 Kashyap D Desai <kadesai@FreeBSD.org>

Similar to RAID map for Logical Drives, now JBOD map has been introduced for
JBODs. Driver has to sync the JBOD map with firmware and use sequence number
as a reference for JBOD FastPath I/O's.

Submitted by: Sumit Saxena <sumit.saxena@broadcom.com>
Reviewed by: Kashyap Desai <Kashyap.Desai@broadcom.com>
MFC after: 3 days
Sponsored by: AVAGO Technologies


# f0c7594b 12-May-2016 Kashyap D Desai <kadesai@FreeBSD.org>

There was no ERROR handling for firmware command TIMEOUT. This patch
takes care of any firmware command timeout scenarios by initiating OCR.

Submitted by: Sumit Saxena <sumit.saxena@broadcom.com>
Reviewed by: Kashyap Desai <Kashyap.Desai@broadcom.com>
MFC after: 3 days
Sponsored by: AVAGO Technologies


# 453130d9 02-May-2016 Pedro F. Giffuni <pfg@FreeBSD.org>

sys/dev: minor spelling fixes.

Most affect comments, very few have user-visible effects.


# 5bae00d6 24-Feb-2016 Steven Hartland <smh@FreeBSD.org>

Fix NULL pointer dereferences

Fix NULL pointer dereferences identified as V522 by PVS-Studio.

MFC after: 1 week
Sponsored by: Multiplay


# 43cd6160 18-Feb-2016 Justin Hibbits <jhibbits@FreeBSD.org>

Replace several bus_alloc_resource() calls using default arguments with bus_alloc_resource_any()

Since these calls only use default arguments, bus_alloc_resource_any() is the
right call.

Differential Revision: https://reviews.freebsd.org/D5306


# 2f2163ab 25-Jun-2015 Kashyap D Desai <kadesai@FreeBSD.org>

Counter part of mfi driver commit in mrsas

Switch from make_dev_alias to make_dev_alias_p since make_dev_alias_p can
gracefully fail if the /dev/megaraid_sas_ioctl_node symlink already exists.
This can happen if mfi(4) and mrsas(4) are both attached to cards and
providing Linux emulation support. Let the first one win. An equivalent
change has been done in mfi(4). Extra credit would be to pass the
Linux emulation call to the other driver when appropriate. This will
probably be a rare case and the user can manually change where the symlink
points to.

MFC after: 3 days


# 5b2490f8 26-Jun-2015 Kashyap D Desai <kadesai@FreeBSD.org>

Kernel panic may be observed by user, if MR controller is under Chip reset (OCR)
and there are some pending IOs at the time of OCR. This is mainly because of
recursive mutext in OCR and IO completion function call. Generic IO completion (from ISR) needs
sim_lock to be held before it calls completion to CAM (xpt_done), but in case of OCR path mrsas_ocr thread
itself take sim_lock, so this condition is now handled in this patch.

MFC after: 3 days


# dbcc81df 06-May-2015 Kashyap D Desai <kadesai@FreeBSD.org>

Corrected indentation on conflicted source files.

Reviewed by: ambrisko
MFC after: 2 weeks
Sponsored by: AVAGO Technologies


# ecea5be4 06-May-2015 Kashyap D Desai <kadesai@FreeBSD.org>

1. All LSI namings are converted to AVAGO Tech.
2. Fix in AEN path(suggested by John Baldwin).
3. Fix IOCTL path w.r.t Sense key handling

Reviewed by: ambrisko
MFC after: 2 weeks
Sponsored by: AVAGO Technologies


# 2f863eb8 06-May-2015 Kashyap D Desai <kadesai@FreeBSD.org>

Bug fixes found internally as detailed below:
1. While disabling interrupt the FW disables interrupts for only 16 vectors.
In case of Invader which supports 96 MSI-x vectors, some spurious interrupts
may come on other vectors even after interrupt disable. So, driver uses a flag
and ignores the spurious interrupts.
2. Reply queue depth is made double the number of commands supported by FW.
3. Misplaced interrupt enable code is now moved down in the OCR path.
4. Updated error handling code in OCR path.
5. Removed un-necessary print.

Reviewed by: ambrisko
MFC after: 2 weeks
Sponsored by: AVAGO Technologies


# daeed973 06-May-2015 Kashyap D Desai <kadesai@FreeBSD.org>

Driver calls mrsas_complete_cmd() to call mrsas_wakeup() for each MFI frame that was
issued through the ioctl() interface prior to the kill adapter. This ensures
userspace ioctl() system calls issued just before a kill adapter don't get stuck in
wait state and IOCTLs are returned to application.

Reviewed by: ambrisko
MFC after: 2 weeks
Sponsored by: AVAGO Technologies


# af51c29f 06-May-2015 Kashyap D Desai <kadesai@FreeBSD.org>

In OCR(Online Controller Reset) path, driver sets adapter state to
MEGASAS_HBA_OPERATIONAL before getting new RAID map.
There will be a small window where IO will come from OS with old RAID map.
This patch will update adapter state to MEGASAS_HBA_OPERATIONAL,
only after driver has new RAID map to avoid any IOs getting build using old RAID map.

Reviewed by: ambrisko
MFC after: 2 weeks
Sponsored by: AVAGO Technologies


# 16dc2814 06-May-2015 Kashyap D Desai <kadesai@FreeBSD.org>

Current driver does fast path read load balancing between arm and mirror disk
for two Drive Raid-1 configuration only.

Now, Driver support fast path read load balancing for all (any number of disk) Raid-1 configuration.

Reviewed by: ambrisko
MFC after: 2 weeks
Sponsored by: AVAGO Technologies


# 77cf7df8 06-May-2015 Kashyap D Desai <kadesai@FreeBSD.org>

Now Driver expose Secure Jbod Support via driver_operations in MFI INIT Frame.
FW expose Secure Jbod support via Controller properity.

Firmware expect IOs to be received from different IO path than
conventional fast path queue, in case of SED drives.

To have Secure jbod support user need driver and firmware support.

Reviewed by: ambrisko
MFC after: 2 weeks
Sponsored by: AVAGO Technologies


# 5844115e 06-May-2015 Kashyap D Desai <kadesai@FreeBSD.org>

This patch adds the feature to provide PCI information via IOCTL query.

Reviewed by: ambrisko
MFC after: 2 weeks
Sponsored by: AVAGO Technologies


# 7fc5f329 06-Jan-2015 John Baldwin <jhb@FreeBSD.org>

Use struct thread directly instead of d_thread_t. This driver is not
likely to be backported to 4.x.

Reviewed by: kadesai


# f0188618 21-Oct-2014 Hans Petter Selasky <hselasky@FreeBSD.org>

Fix multiple incorrect SYSCTL arguments in the kernel:

- Wrong integer type was specified.

- Wrong or missing "access" specifier. The "access" specifier
sometimes included the SYSCTL type, which it should not, except for
procedural SYSCTL nodes.

- Logical OR where binary OR was expected.

- Properly assert the "access" argument passed to all SYSCTL macros,
using the CTASSERT macro. This applies to both static- and dynamically
created SYSCTLs.

- Properly assert the the data type for both static and dynamic
SYSCTLs. In the case of static SYSCTLs we only assert that the data
pointed to by the SYSCTL data pointer has the correct size, hence
there is no easy way to assert types in the C language outside a
C-function.

- Rewrote some code which doesn't pass a constant "access" specifier
when creating dynamic SYSCTL nodes, which is now a requirement.

- Updated "EXAMPLES" section in SYSCTL manual page.

MFC after: 3 days
Sponsored by: Mellanox Technologies


# f5fb2237 13-Oct-2014 Kashyap D Desai <kadesai@FreeBSD.org>

Fix for build issue on i386.xen and amd64.xen.

This is a duplicate variable reference in mrsas, so now this patch isolate atomic_ variable and relavent
function call using prefix mrsas_xx.

Issue was introduced in r272737.

MFC after: 2 weeks
Sponsored by: Avago Technology


# 8e727371 08-Oct-2014 Kashyap D Desai <kadesai@FreeBSD.org>

No logical code change in this pathc.
Only Style 9 changes for mrsas driver.

Reviewed by: ambrisko
MFC after: 2 weeks
Sponsored by: AVAGO Technologies


# 839ee025 08-Oct-2014 Kashyap D Desai <kadesai@FreeBSD.org>

In the passthru IOCTL path, the mfi command pool was freely accessible N times
where as there are limited number(32) of mfi commands in the pool.
The mfi command pool is now restricted to 27 simultaneous accesses by using
a counting semaphore while calling the passthru function.

In the mrsas_cam.c source file there was a same function name mrsas_poll(),
which was same as the mrsas_poll() implemented in the mrsas.c file for the
polling interface.
To clearly distinguish the functionality by usage we have renamed the former
as mrsas_cam_poll().

In the passthru function let's say it has got an mfi command from the pool
but it has failed in one of the DMA function call which will lead to leak
an mfi command because in the ERROR case it directly returns and not freeing up
the occupied mfi command.

Reviewed by: ambrisko
MFC after: 2 weeks
Sponsored by: AVAGO Technologies


# da011113 08-Oct-2014 Kashyap D Desai <kadesai@FreeBSD.org>

d_poll() callback function is the entry point for poll system call for the application.
It is meant to notify the applications which will be waiting for some
controller events to be occured.

Reviewed by: ambrisko
MFC after: 2 weeks
Sponsored by: AVAGO Technologies


# d18d1b47 08-Oct-2014 Kashyap D Desai <kadesai@FreeBSD.org>

Extended MSI-x vectors support for Invader and Fury(12Gb/s HBA).

This Driver will create multiple MSI-x vector depending upon what FW expose.
As of now 12 Gbp/s MR controller (Invader and Fury) expose 96 msix vector.
As of now 6 Gbp/s MR controller (Thunderbolt) expose 16 msix vector.

Reviewed by: ambrisko
MFC after: 2 weeks
Sponsored by: AVAGO Technologies


# 536094dc 08-Oct-2014 Kashyap D Desai <kadesai@FreeBSD.org>

This is a feature provided to run 32-bit linux binaries on FreeBSD 64bit
machine, for which 32bit compatibilty code has been added.
As in linux there is only one device entry that is used to fire IOCTL commands,
a new device entry megaraid_sas_ioctl_node is added for solely this
purpose.

From one dev node i.e mrgaraid_sa_ioctl_node we have to find out the
controller instance in case of multicontroller, for which one management info
structure has been added.

Reviewed by: ambrisko
MFC after: 2 weeks
Sponsored by: AVAGO Technologies


# 4799d485 08-Oct-2014 Kashyap D Desai <kadesai@FreeBSD.org>

Current MegaRAID firmware and hence the driver only supported 64VDs.
E.g: If the user wants to create more than 64VD on a controller,
it is not possible on current firmware/driver.

New feature and requirement to support upto 256VD, firmware/driver/apps need changes.
In addition to that, there must be a backward compatibility of the new driver with the
older firmware and vice versa.

RAID map is the interface between Driver and FW to fetch all required
fields(attributes) for each Virtual Drives.
In the earlier design driver was using the FW copy of RAID map where as
in the new design the Driver will keep the RAID map copy of its own; on which
it will operate for any raid map access in fast path.

Local driver raid map copy will provide ease of access through out the code
and provide generic interface for future FW raid map changes.

For the backward compatibility driver will notify FW that it supports 256VD
to the FW in driver capability field.
Based on the controller properly returned by the FW, the Driver will know
whether it supports 256VD or not and will copy the RAID map accordingly.

At any given time, driver will always have old or new Raid map.

Reviewed by : ambrisko
MFC after : 2 weeks
Sponsored by: AVAGO Technologies


# 665484d8 07-May-2014 Doug Ambrisko <ambrisko@FreeBSD.org>

Add mrsas(4) driver from LSI official support of newer MegaRAID SAS
cards. LSI has been maintaining this driver outside of the FreeBSD
tree. It overlaps support of ThunderBolt and Invader cards that mfi(4)
supports. By default mfi(4) will attach to cards. If the tunable:
hw.mfi.mrsas_enable=1
is set then mfi(4) will not probe and attach to these newer cards and
allow mrsas(4) to attach. So by default this driver will not effect
a FreeBSD system unless mfi(4) is removed from the kernel or the
tunable is enabled.

mrsas(4) attaches disks to the CAM layer so it depends on CAM and devices
show up as /dev/daX. mfiutil(8) does not work with mrsas. The FreeBSD
version of MegaCli and StorCli from LSI do work with mrsas. It appears
that StorCli only works with mrsas. MegaCli appears to work with mfi(4)
and mrsas(4).

It would be good to add mfiutil(4) support to mrsas, emulations modes,
kernel logging, device aliases to ease the transition between mfi(4)
and mrsas(4).

Style issues should be resolved by LSI when they get committers approved.
The plan is get this driver in FreeBSD 9.3 to improve HW support.

Thanks to LSI for developing, testing and working with FreeBSD to
make this driver co-exist in FreeBSD. This improves the overall
support of MegaRAID SAS.

Submitted by: Kashyap Desai <Kashyap.Desai@lsi.com>
Reviewed by: scottl
MFC after: 3 days
Sponsored by: LSI