<feed xmlns='http://www.w3.org/2005/Atom'>
<title>src/sys/dev/mpr/mpr_user.c, branch releng/12.2</title>
<subtitle>FreeBSD source tree</subtitle>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/'/>
<entry>
<title>MFC r363608:</title>
<updated>2020-08-03T23:06:33+00:00</updated>
<author>
<name>Mark Johnston</name>
<email>markj@FreeBSD.org</email>
</author>
<published>2020-08-03T23:06:33+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=9c4a78a41a2cdce7b1a749ad9a295a8953faa9ab'/>
<id>9c4a78a41a2cdce7b1a749ad9a295a8953faa9ab</id>
<content type='text'>
mpr(4), mps(4): Stop checking for failures from malloc(M_WAITOK).
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
mpr(4), mps(4): Stop checking for failures from malloc(M_WAITOK).
</pre>
</div>
</content>
</entry>
<entry>
<title>MFC r359937:</title>
<updated>2020-04-28T17:59:37+00:00</updated>
<author>
<name>Brooks Davis</name>
<email>brooks@FreeBSD.org</email>
</author>
<published>2020-04-28T17:59:37+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=18fec7394da653a176be797ebcdd1eaf55897f9d'/>
<id>18fec7394da653a176be797ebcdd1eaf55897f9d</id>
<content type='text'>
Centralize compatability translation macros.

Copy the CP, PTRIN, etc macros from freebsd32.h into a sys/abi_compat.h
and replace existing definitation with includes where required. This
eliminates duplicate code and allows Linux and FreeBSD compatability
headers to be included in the same files.

Obtained from:	CheriBSD
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D24275
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Centralize compatability translation macros.

Copy the CP, PTRIN, etc macros from freebsd32.h into a sys/abi_compat.h
and replace existing definitation with includes where required. This
eliminates duplicate code and allows Linux and FreeBSD compatability
headers to be included in the same files.

Obtained from:	CheriBSD
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D24275
</pre>
</div>
</content>
</entry>
<entry>
<title>Catch up with stability fixes to mpr/mps in -current since 12</title>
<updated>2019-09-26T01:54:24+00:00</updated>
<author>
<name>Warner Losh</name>
<email>imp@FreeBSD.org</email>
</author>
<published>2019-09-26T01:54:24+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=40d21e921a551c61306276dfee10a5529ffe6dbf'/>
<id>40d21e921a551c61306276dfee10a5529ffe6dbf</id>
<content type='text'>
was branched.

MFC r341755,r342354,r342355,r342386,r342387,r342388,r342526,r342528,
r342530,r342531,r342533,r342534,r342535,r342536,r342659,r345479,
r345485,r345573,r347237,r349849,r349909:

  r341755:
    Copy and clear the reply descriptor atomically.  This prevents concurrency
    in the interrupt handlers (usually due to timeout/error recovery) from
    seeing and processing the same descriptor twice.
  r342354:
    mps(4), mpr(4): Fix lifetime of command buffer for mp?sas_get_sata_identify
  r342355:
    mps(4), mpr(4): remove SATA ID command cancellation hack
  r342386:
    First step in refactoring and fixing the error recovery and task management
    code in the mpr and mps drivers.  Eliminate duplicated code and fix some
    comments.
  r342387:
    Commands for user-initated device resets should come from the high-priority
    allocator.  Prior to this change, they would leak from the normal
    allocator.
  r342388:
    Further refactoring for task management commands.  Also fix a related typo
    from the previous commit.
  r342526:
    Update MPI header files version to 2.00.52 from 2.00.48
  r342528:
    Copy back the Sense data at proper location expected by the application
  r342530:
    Added support for NVMe Task Management
  r342531:
    Add Sea,Aero adapter support
  r342533:
    Enable atomic type descriptor support only for Sea &amp; Aero cards
  r342534:
    On Aero/Sea A0 cards retry MPT Fusion registers reads for max three times
  r342535:
    Update copyright information
  r342536:
    Update mpr driver version to v23.00.00.00-fbsd
  r342659:
    Fix whitespace from r342528
  r345479:
    r329522 created problemss with commands that enter the TIMEDOUT state but
    are successfully returned by the card (usually due to an abort being issued
    as part of timeout recovery). Remove what amounts to an insufficient
    KASSERT, and don't overwrite the state value. State should probably be
    re-designed, and that will be done with a future commit.
  r345485:
    Add event table decoding for SAS Broadcast Primitive events.
  r345573:
    Add missing break statements.  Coverity CID 1400446.
  r347237:
    Add missing newline to debug printf.
  r349849:
    Fix bugs in recovery path and improve cm tracking
  r349909:
    More fully implement the state machine.

Sponsored by: Netflix, Inc
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
was branched.

MFC r341755,r342354,r342355,r342386,r342387,r342388,r342526,r342528,
r342530,r342531,r342533,r342534,r342535,r342536,r342659,r345479,
r345485,r345573,r347237,r349849,r349909:

  r341755:
    Copy and clear the reply descriptor atomically.  This prevents concurrency
    in the interrupt handlers (usually due to timeout/error recovery) from
    seeing and processing the same descriptor twice.
  r342354:
    mps(4), mpr(4): Fix lifetime of command buffer for mp?sas_get_sata_identify
  r342355:
    mps(4), mpr(4): remove SATA ID command cancellation hack
  r342386:
    First step in refactoring and fixing the error recovery and task management
    code in the mpr and mps drivers.  Eliminate duplicated code and fix some
    comments.
  r342387:
    Commands for user-initated device resets should come from the high-priority
    allocator.  Prior to this change, they would leak from the normal
    allocator.
  r342388:
    Further refactoring for task management commands.  Also fix a related typo
    from the previous commit.
  r342526:
    Update MPI header files version to 2.00.52 from 2.00.48
  r342528:
    Copy back the Sense data at proper location expected by the application
  r342530:
    Added support for NVMe Task Management
  r342531:
    Add Sea,Aero adapter support
  r342533:
    Enable atomic type descriptor support only for Sea &amp; Aero cards
  r342534:
    On Aero/Sea A0 cards retry MPT Fusion registers reads for max three times
  r342535:
    Update copyright information
  r342536:
    Update mpr driver version to v23.00.00.00-fbsd
  r342659:
    Fix whitespace from r342528
  r345479:
    r329522 created problemss with commands that enter the TIMEDOUT state but
    are successfully returned by the card (usually due to an abort being issued
    as part of timeout recovery). Remove what amounts to an insufficient
    KASSERT, and don't overwrite the state value. State should probably be
    re-designed, and that will be done with a future commit.
  r345485:
    Add event table decoding for SAS Broadcast Primitive events.
  r345573:
    Add missing break statements.  Coverity CID 1400446.
  r347237:
    Add missing newline to debug printf.
  r349849:
    Fix bugs in recovery path and improve cm tracking
  r349909:
    More fully implement the state machine.

Sponsored by: Netflix, Inc
</pre>
</div>
</content>
</entry>
<entry>
<title>MFC r348417: Fix busy status leak in case of incorrect passthrough args.</title>
<updated>2019-06-06T01:16:04+00:00</updated>
<author>
<name>Alexander Motin</name>
<email>mav@FreeBSD.org</email>
</author>
<published>2019-06-06T01:16:04+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=9f7521af587c2de56a2c19a7240f6beab2c7a81e'/>
<id>9f7521af587c2de56a2c19a7240f6beab2c7a81e</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>Move most of the contents of opt_compat.h to opt_global.h.</title>
<updated>2018-04-06T17:35:35+00:00</updated>
<author>
<name>Brooks Davis</name>
<email>brooks@FreeBSD.org</email>
</author>
<published>2018-04-06T17:35:35+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=6469bdcdb6a5968dc7edfcfb495d427b4bfdb3dd'/>
<id>6469bdcdb6a5968dc7edfcfb495d427b4bfdb3dd</id>
<content type='text'>
opt_compat.h is mentioned in nearly 180 files. In-progress network
driver compabibility improvements may add over 100 more so this is
closer to "just about everywhere" than "only some files" per the
guidance in sys/conf/options.

Keep COMPAT_LINUX32 in opt_compat.h as it is confined to a subset of
sys/compat/linux/*.c.  A fake _COMPAT_LINUX option ensure opt_compat.h
is created on all architectures.

Move COMPAT_LINUXKPI to opt_dontuse.h as it is only used to control the
set of compiled files.

Reviewed by:	kib, cem, jhb, jtl
Sponsored by:	DARPA, AFRL
Differential Revision:	https://reviews.freebsd.org/D14941
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
opt_compat.h is mentioned in nearly 180 files. In-progress network
driver compabibility improvements may add over 100 more so this is
closer to "just about everywhere" than "only some files" per the
guidance in sys/conf/options.

Keep COMPAT_LINUX32 in opt_compat.h as it is confined to a subset of
sys/compat/linux/*.c.  A fake _COMPAT_LINUX option ensure opt_compat.h
is created on all architectures.

Move COMPAT_LINUXKPI to opt_dontuse.h as it is only used to control the
set of compiled files.

Reviewed by:	kib, cem, jhb, jtl
Sponsored by:	DARPA, AFRL
Differential Revision:	https://reviews.freebsd.org/D14941
</pre>
</div>
</content>
</entry>
<entry>
<title>Update mpr(4) driver from v15 to v18 from Broadcom site.</title>
<updated>2018-03-19T23:21:45+00:00</updated>
<author>
<name>Alexander Motin</name>
<email>mav@FreeBSD.org</email>
</author>
<published>2018-03-19T23:21:45+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=5f5baf0e9697eea27a5a8e77fbdb639397f7f388'/>
<id>5f5baf0e9697eea27a5a8e77fbdb639397f7f388</id>
<content type='text'>
Version 16 is just a number bump, since we already had those changes.

Version 17 introduces new AdapterType value, that allows new user-space
tools from Broadcom to differentiate adapter generations 3 and 3.5.

Version 18 updates headers and adds SAS_DEVICE_DISCOVERY_ERROR reporting.

MFC after:	2 weeks
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Version 16 is just a number bump, since we already had those changes.

Version 17 introduces new AdapterType value, that allows new user-space
tools from Broadcom to differentiate adapter generations 3 and 3.5.

Version 18 updates headers and adds SAS_DEVICE_DISCOVERY_ERROR reporting.

MFC after:	2 weeks
</pre>
</div>
</content>
</entry>
<entry>
<title>Cache the value of the request and reply frame size since it's used quite</title>
<updated>2018-02-06T21:01:38+00:00</updated>
<author>
<name>Scott Long</name>
<email>scottl@FreeBSD.org</email>
</author>
<published>2018-02-06T21:01:38+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=964107031b45bfdae417fc22847e41463c6918c3'/>
<id>964107031b45bfdae417fc22847e41463c6918c3</id>
<content type='text'>
a bit in the normal operation of the driver.  Covert it to represent bytes
instead of 32bit words.  Fix what I believe to be is a bug in this respect
with the Tri-mode cards.

Sponsored by:	Netflix
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
a bit in the normal operation of the driver.  Covert it to represent bytes
instead of 32bit words.  Fix what I believe to be is a bug in this respect
with the Tri-mode cards.

Sponsored by:	Netflix
</pre>
</div>
</content>
</entry>
<entry>
<title>Diagnostic buffer fixes for the mps(4) and mpr(4) drivers.</title>
<updated>2018-02-06T15:58:22+00:00</updated>
<author>
<name>Kenneth D. Merry</name>
<email>ken@FreeBSD.org</email>
</author>
<published>2018-02-06T15:58:22+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=e2997a03b7f76a19fc56a6d8c3536c76617a7ad7'/>
<id>e2997a03b7f76a19fc56a6d8c3536c76617a7ad7</id>
<content type='text'>
In mp{r,s}_diag_register(), which is used to register diagnostic
buffers with the mp{r,s}(4) firmware, we allocate DMAable memory.

There were several issues here:
 o No checking of the bus_dmamap_load() return value.  If the load
   failed or got deferred, mp{r,s}_diag_register() continued on as if
   nothing had happened.  We now check the return value and bail
   out if it fails.

 o No waiting for a deferred load callback.  bus_dmamap_load()
   calls a supplied callback when the mapping is done.  This is
   generally done immediately, but it can be deferred.
   mp{r,s}_diag_register() did not check to see whether the callback
   was already done before proceeding on.  We now sleep until the
   callback is done if it is deferred.

 o No call to bus_dmamap_sync(... BUS_DMASYNC_PREREAD) after the
   memory is allocated and loaded.  This is necessary on some
   platforms to synchronize host memory that is going to be updated
   by a device.

Both drivers would also panic if the firmware was reinitialized while
a diagnostic buffer operation was in progress.  This fixes that problem
as well.  (The driver will reinitialize the firmware in various
circumstances, but the problem I ran into was that the firmware would
generate an IOC Fault due to a PCIe error.)

mp{r,s}var.h:
	Add a new structure, struct mpr_busdma_context, that is
	used for deferred busdma load callbacks.

	Add a prototype for mp{r,s}_memaddr_wait_cb().
mp{r,s}.c:
	Add a new busdma callback function, mp{r,s}_memaddr_wait_cb().
	This provides synchronization for callers that want to
	wait on a deferred bus_dmamap_load() callback.

mp{r,s}_user.c:
	In bus_dmamap_register(), add a call to bus_dmamap_sync()
	with the BUS_DMASYNC_PREREAD flag set after an allocation
	is loaded.

	Also, check the return value of bus_dmamap_load().  If it
	fails, bail out.  If it is EINPROGRESS, wait for the
	callback to happen.  We use an interruptible sleep (msleep
	with PCATCH) and let the callback clean things up if we get
	interrupted.

	In mpr_diag_read_buffer() and mps_diag_read_buffer(), call
	bus_dmamap_sync(..., BUS_DMASYNC_POSTREAD) before copying
	the data out to make sure the data is in stable storage.

	In mp{r,s}_post_fw_diag_buffer() and
	mp{r,s}_release_fw_diag_buffer(), check the reply to see
	whether it is NULL.  It can be NULL (and the command non-NULL)
	if the controller gets reinitialized while we're waiting for
	the command to complete but the driver structures aren't
	reallocated.  The driver structures generally won't be
	reallocated unless there is a firmware upgrade that changes
	one of the IOCFacts.

	When freeing diagnostic buffers in mp{r,s}_diag_register()
	and mp{r,s}_diag_unregister(), zero/NULL out the buffer after
	freeing it.  This will prevent a duplicate free in some
	situations.

Sponsored by:	Spectra Logic
Reviewed by:	mav, scottl
MFC after:	1 week
Differential Revision:	D13453
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
In mp{r,s}_diag_register(), which is used to register diagnostic
buffers with the mp{r,s}(4) firmware, we allocate DMAable memory.

There were several issues here:
 o No checking of the bus_dmamap_load() return value.  If the load
   failed or got deferred, mp{r,s}_diag_register() continued on as if
   nothing had happened.  We now check the return value and bail
   out if it fails.

 o No waiting for a deferred load callback.  bus_dmamap_load()
   calls a supplied callback when the mapping is done.  This is
   generally done immediately, but it can be deferred.
   mp{r,s}_diag_register() did not check to see whether the callback
   was already done before proceeding on.  We now sleep until the
   callback is done if it is deferred.

 o No call to bus_dmamap_sync(... BUS_DMASYNC_PREREAD) after the
   memory is allocated and loaded.  This is necessary on some
   platforms to synchronize host memory that is going to be updated
   by a device.

Both drivers would also panic if the firmware was reinitialized while
a diagnostic buffer operation was in progress.  This fixes that problem
as well.  (The driver will reinitialize the firmware in various
circumstances, but the problem I ran into was that the firmware would
generate an IOC Fault due to a PCIe error.)

mp{r,s}var.h:
	Add a new structure, struct mpr_busdma_context, that is
	used for deferred busdma load callbacks.

	Add a prototype for mp{r,s}_memaddr_wait_cb().
mp{r,s}.c:
	Add a new busdma callback function, mp{r,s}_memaddr_wait_cb().
	This provides synchronization for callers that want to
	wait on a deferred bus_dmamap_load() callback.

mp{r,s}_user.c:
	In bus_dmamap_register(), add a call to bus_dmamap_sync()
	with the BUS_DMASYNC_PREREAD flag set after an allocation
	is loaded.

	Also, check the return value of bus_dmamap_load().  If it
	fails, bail out.  If it is EINPROGRESS, wait for the
	callback to happen.  We use an interruptible sleep (msleep
	with PCATCH) and let the callback clean things up if we get
	interrupted.

	In mpr_diag_read_buffer() and mps_diag_read_buffer(), call
	bus_dmamap_sync(..., BUS_DMASYNC_POSTREAD) before copying
	the data out to make sure the data is in stable storage.

	In mp{r,s}_post_fw_diag_buffer() and
	mp{r,s}_release_fw_diag_buffer(), check the reply to see
	whether it is NULL.  It can be NULL (and the command non-NULL)
	if the controller gets reinitialized while we're waiting for
	the command to complete but the driver structures aren't
	reallocated.  The driver structures generally won't be
	reallocated unless there is a firmware upgrade that changes
	one of the IOCFacts.

	When freeing diagnostic buffers in mp{r,s}_diag_register()
	and mp{r,s}_diag_unregister(), zero/NULL out the buffer after
	freeing it.  This will prevent a duplicate free in some
	situations.

Sponsored by:	Spectra Logic
Reviewed by:	mav, scottl
MFC after:	1 week
Differential Revision:	D13453
</pre>
</div>
</content>
</entry>
<entry>
<title>Start overhauling debug printing in the MPS and MPR drivers.  The focus of this</title>
<updated>2017-08-27T06:24:06+00:00</updated>
<author>
<name>Scott Long</name>
<email>scottl@FreeBSD.org</email>
</author>
<published>2017-08-27T06:24:06+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=757ff642169adb670993476297f25ada8c5646cf'/>
<id>757ff642169adb670993476297f25ada8c5646cf</id>
<content type='text'>
commit it to make initiazation less chatty in the normal case, and more useful
and informative when real debugging is turned on.

Reviewed by:	ken (earlier version)
Sponsored by:	Netflix
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
commit it to make initiazation less chatty in the normal case, and more useful
and informative when real debugging is turned on.

Reviewed by:	ken (earlier version)
Sponsored by:	Netflix
</pre>
</div>
</content>
</entry>
<entry>
<title>Changes to make mps(4) and mpr(4) handle reinit with reallocation.</title>
<updated>2017-08-10T14:59:17+00:00</updated>
<author>
<name>Kenneth D. Merry</name>
<email>ken@FreeBSD.org</email>
</author>
<published>2017-08-10T14:59:17+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=6d4ffcb4acd13b34175df069e09e8d7920188bd4'/>
<id>6d4ffcb4acd13b34175df069e09e8d7920188bd4</id>
<content type='text'>
When the mps(4) and mpr(4) drivers need to reinitialize the
firmware, they sometimes need to reallocate all of the memory
allocated by the driver.  The reallocation happens whenever the IOC
Facts change.  That should only happen after a firmware upgrade.

If the reinitialization happens as a result of a timed out command
sent to the card, the command that timed out and triggered the
reinit may have been freed if iocfacts_allocate() reallocated all
memory.  If the caller attempts to access the command after that,
the kernel will panic because the caller will be dereferencing
freed memory.

The solution is to set a flag in the softc when we reallocate,
and avoid dereferencing the command strucure if we've reallocated.

The changes are largely the same in both drivers, since mpr(4) is a
derivative of mps(4).

 o In iocfacts_allocate(), if the IOC Facts have changed and we
   need to reallocate, set the REALLOCATED flag in the softc.

 o Change wait_command() to take a struct mps_command ** instead of
   a struct mps_command *.  This allows us to NULL out the caller's
   command pointer if we have to reinit the controller and the data
   structures get reallocated.  (The REALLOCATED flag will be set
   in the softc if that has happened.)

 o In every place that calls wait_command(), make sure we handle
   the case where the command is NULL after the call.

 o The mpr(4) driver has mpr_request_polled() which can also
   reinitialize the card.  Also check for reallocation there.

Reviewed by:	scottl, slm
MFC after:	1 week
Sponsored by:	Spectra Logic
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
When the mps(4) and mpr(4) drivers need to reinitialize the
firmware, they sometimes need to reallocate all of the memory
allocated by the driver.  The reallocation happens whenever the IOC
Facts change.  That should only happen after a firmware upgrade.

If the reinitialization happens as a result of a timed out command
sent to the card, the command that timed out and triggered the
reinit may have been freed if iocfacts_allocate() reallocated all
memory.  If the caller attempts to access the command after that,
the kernel will panic because the caller will be dereferencing
freed memory.

The solution is to set a flag in the softc when we reallocate,
and avoid dereferencing the command strucure if we've reallocated.

The changes are largely the same in both drivers, since mpr(4) is a
derivative of mps(4).

 o In iocfacts_allocate(), if the IOC Facts have changed and we
   need to reallocate, set the REALLOCATED flag in the softc.

 o Change wait_command() to take a struct mps_command ** instead of
   a struct mps_command *.  This allows us to NULL out the caller's
   command pointer if we have to reinit the controller and the data
   structures get reallocated.  (The REALLOCATED flag will be set
   in the softc if that has happened.)

 o In every place that calls wait_command(), make sure we handle
   the case where the command is NULL after the call.

 o The mpr(4) driver has mpr_request_polled() which can also
   reinitialize the card.  Also check for reallocation there.

Reviewed by:	scottl, slm
MFC after:	1 week
Sponsored by:	Spectra Logic
</pre>
</div>
</content>
</entry>
</feed>
