Commit Graph

69 Commits

Author SHA1 Message Date
Pedro F. Giffuni
718cf2ccb9 sys/dev: further adoption of SPDX licensing ID tags.
Mainly focus on files that use BSD 2-Clause license, however the tool I
was using misidentified many licenses so this was mostly a manual - error
prone - task.

The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.
2017-11-27 14:52:40 +00:00
Conrad Meyer
db4fcadf52 "Buses" is the preferred plural of "bus"
Replace archaic "busses" with modern form "buses."

Intentionally excluded:
* Old/random drivers I didn't recognize
  * Old hardware in general
* Use of "busses" in code as identifiers

No functional change.

http://grammarist.com/spelling/buses-busses/

PR:		216099
Reported by:	bltsrc at mail.ru
Sponsored by:	Dell EMC Isilon
2017-01-15 17:54:01 +00:00
Scott Long
e0629b31f3 Fix the fallout from r308268 (mpt driver causes endless witness warnings in
VMWare and elsewhere) with the precision of a dull, rusty butter knife.

Reported by:	tuexen
Obtained from:	Netflix
2016-11-07 17:34:19 +00:00
Pedro F. Giffuni
453130d9bf sys/dev: minor spelling fixes.
Most affect comments, very few have user-visible effects.
2016-05-03 03:41:25 +00:00
Marius Strobl
e18e2adaae - In mpt_send_handshake_cmd(), use bus_space_write_stream_4(9) for writing
raw data to the doorbell offset in order to clarify the intent and for
  avoiding unnecessarily converting the endianess back and forth.
  Unfortunately, the same can't be done in mpt_recv_handshake_reply() as
  16-bit data needs to be read using 32-bit bus accessors.
- In mpt_recv_handshake_reply(), get rid of a redundant variable.

MFC after:	1 fortnight
2015-07-24 16:00:35 +00:00
Ian Lepore
2b7b77f06b Squelch a (bogus) used before init warning when building with gcc. 2014-11-23 21:37:33 +00:00
Steven Hartland
85c9dd9d89 Prevent overflow issues in timeout processing
Previously, any timeout value for which (timeout * hz) will overflow the
signed integer, will give weird results, since callout(9) routines will
convert negative values of ticks to '1'. For unsigned integer overflow we
will get sufficiently smaller timeout values than expected.

Switch from callout_reset, which requires conversion to int based ticks
to callout_reset_sbt to avoid this.

Also correct isci to correctly resolve ccb timeout.

This was based on the original work done by Eygene Ryabinkin
<rea@freebsd.org> back in 5 Aug 2011 which used a macro to help avoid
the overlow.

Differential Revision:	https://reviews.freebsd.org/D1157
Reviewed by:	mav, davide
MFC after:	1 month
Sponsored by:	Multiplay
2014-11-21 21:01:24 +00:00
Marius Strobl
4b847ffaa3 After r241858, remove the remainder of FreeBSD ~4 support from mpt(4).
MFC after:	1 week
2012-10-22 10:42:59 +00:00
Marius Strobl
04016bcf93 Flesh out support for SAS1078 and SAS1078DE (which are said to actually
be the same chip):
- The I/O port resource may not be available with these. However, given
  that we actually only need this resource for some controllers that
  require their firmware to be up- and downloaded (which excludes the
  SAS1078{,DE}) just handle failure to allocate this resource gracefully
  when possible. While at it, generally put non-fatal resource allocation
  failures under bootverbose.
- SAS1078{,DE} use a different hard reset protocol.
- Add workarounds for the 36GB physical address limitation of scatter/
  gather elements of these controllers.

Tested by:	Slawa Olhovchenkov

PR:	149220 (remaining part)
2012-02-11 12:03:44 +00:00
Marius Strobl
4349d27828 Remove extra newlines from panic messages. 2012-02-08 21:40:54 +00:00
Marius Strobl
84ceb5f6d3 Increase the IOC port initialization timeouts by ten times to what the
corresponding Linux driver uses. This allows mpt(4) to still recognize
all good SATA devices in presence of a defective one, which takes about
45 seconds.
In the long term we probably should implement the logic used by mpt2sas(4)
allowing IOC port initialization to complete at a later time.

Submitted by:	Andrew Boyer
MFC after:	3 days
2011-11-01 18:28:33 +00:00
Marius Strobl
87e255ac52 - Staticize functions as appropriate and comment out unused ones.
- Sprinkle some const where appropriate.
- Consistently use target_id_t for the target parameter of mpt_map_physdisk()
  and mpt_is_raid_volume().
- Fix some whitespace bugs.

Approved by:	re (kib)
2011-07-29 18:35:10 +00:00
Marius Strobl
5ab13afc94 Correct spelling.
Submitted by:	brucec
2011-04-22 09:59:16 +00:00
Marius Strobl
6c5276c828 - Allocate the DMA memory shared between the host and the controller as
coherent.
- Add some missing bus_dmamap_sync() calls. This includes putting such
  calls before calling reply handlers instead of calling bus_dmamap_sync()
  for the request queue from individual reply handlers as these handlers
  generally read back updates by the controller.

Tested on amd64 and sparc64.

MFC after:	2 weeks
2011-03-06 12:48:15 +00:00
Matthew D Fleming
6dc7dc9a3e sysctl(9) cleanup checkpoint: amd64 GENERIC builds cleanly.
Commit the rest of the devices.
2011-01-12 19:53:56 +00:00
Marius Strobl
67a1357c25 Improve r56796; the reply handler actually may remove the request from
the chain in which case it shouldn't be removed twice.
Reported by:	Staale Kristoffersen

MFC after:	1 week
2010-09-24 16:40:46 +00:00
Marius Strobl
cac33e16cf - Make the maxsize parameter of the data buffer DMA tag match maxio, which
was missed in r209599.
  Reported and tested by: Michael Moll
- Declare mpt_dma_buf_alloc() static just like mpt_dma_buf_free(), both are
  used in mpt.c only.

Reviewed by:	ken
MFC after:	r209599
2010-07-12 22:57:57 +00:00
Kenneth D. Merry
4201341ff7 Change the mpt driver to allow larger I/O sizes.
The mpt driver previously didn't report a 'maxio' size to CAM, and so the
da(4) driver limited I/O sizes to DFLTPHYS (64K) by default.  The number
of scatter gather segments allowed, as reported to busdma, was
(128K / PAGE_SIZE) + 1, or 33 on architectures with 4K pages.

Change things around so that we wait until we've determined how many
segments the adapter can support before creating the busdma tag used for
buffers, so we can potentially support more S/G segments and therefore
larger I/O sizes.

Also, fix some things that were broken about the module unload path.  It
still gets hung up inside CAM, though.

mpt.c:		Move some busdma initialization calls in here, and call
		them just after we've gotten the IOCFacts, and know how
		many S/G segments this adapter can support.

mpt.h:		Get rid of MPT_MAXPHYS, it is no longer used.

		Add max_cam_seg_cnt, which is used to report our maximum
		I/O size up to CAM.

mpt_cam.c:	Use max_cam_seg_cnt to report our maximum I/O size to CAM.

		Fix the locking in mpt_cam_detach().

mpt_pci.c:	Pull some busdma initialization and teardown out and put
		it in mpt.c.  We now delay it until we know many scatter
		gather segments the adapter can support, and therefore
		how to setup our busdma tags.

mpt_raid.c:	Make sure we wake up the right wait channel to get the
		raid thread to wake up when we're trying to shut it down.

Reviewed by:	gibbs, mjacob
MFC after:	2 weeks
2010-06-29 22:07:53 +00:00
Marius Strobl
8ba5efbd6f On sparc64 obtain the initiator ID to be used for SPI HBAs from the
Open Firmware device tree in order to match what the PROM built-in
driver uses. This is especially important when netbooting Fujitsu
Siemens PRIMEPOWER250 as in that case the built-in driver isn't used
and the port facts PortSCSIID defaults to 0, conflicting with the
disk at the same address.
2010-04-27 18:41:16 +00:00
Alexander Kabaev
363b8ed74f Use callout_init_mtx on FreeBSD versions recent enough. This closes
the race where interrupt thread can complete the request for which
timeout has fired and while mpt_timeout has blocked on mpt_lock.

Do a best effort to keep 4.x ang Giant-locked configurartions
compiling still.

Reported by: ups
Reviewed by: scottl
2009-10-20 02:35:12 +00:00
Marius Strobl
7ee3780799 Make the whole initiator mode part of mpt(4) endian-clean,
specifically SPI controllers now also work in big-endian
machines and some conversions relevant for FC and SAS
controllers as well as support for ILP32 machines which all
were omitted in previous attempts are now also implemented.
The IOCTL-interface is intentionally left (and where needed
actually changed) to be completely little-endian as otherwise
we would have to add conversion code for every possible
configuration page to mpt(4), which didn't seem the right
thing to do, neither did converting only half of the user-
interface to the native byte order.
This change was tested on amd64 (SAS+SPI), i386 (SAS) and
sparc64 (SAS+SPI). Due to lack of the necessary hardware
the target mode code is still left to be made endian-clean.

Reviewed by:	scottl
MFC after:	1 month
2009-01-07 21:52:47 +00:00
Scott Long
942adee743 Don't force a reset at driver attach time. It doesn't work on some
adapters, apparently.
2008-04-03 14:39:48 +00:00
Scott Long
e955d4fd10 The MPT driver treats the "core" module with the same importance and
abstraction as the RAID and CAM modules, making it nearly impossible
for enough initialization to be done in time for the RAID module to
know whether to attach.  On top of this, no reset was being done on
the controller on attach, in violation of the spec.  Additionally,
the port enable step was being deferred to the end of the attach
process, long after it should have been done to ensure reliable
operation from the controller.  Fix all of these with a few hacks
to force the "attach" and "enable" steps of the core module early
on, and ensure that a reset and port enable also happens early on.
In the future, the driver needs to be refactored to eliminate the
core module abstraction, clean up withe reset/enable steps, and
defer event messages until all of the modules are available to
recieve them.
2008-03-31 21:54:05 +00:00
Scott Long
fee67c1a14 Ever since the module registration system was introduced to this driver,
it's been printing out scary messages about "Unhanded Event Notify Frame"
that are needlessly worrisome to users.  Change this warning to only print
out at an elevated debugging level.
2007-11-03 17:33:41 +00:00
Kevin Lo
976b010645 Spelling fix for interupt -> interrupt 2007-10-12 06:03:46 +00:00
Scott Long
9adc3a2dfb Move callout initialization to the proper spot. This prevents panics during
error recovery.

Approved by: re
Found by: kan
2007-08-14 19:17:35 +00:00
Scott Long
a490742913 Track an update in the MPI headers that was missed earlier. 2007-06-04 06:18:07 +00:00
Scott Long
1d558d6a15 mpt.c:
mpt.h:
	Add support for reading extended configuration pages.
mpt_cam.c:
	Do a top level topology scan on the SAS controller.  If any SATA
	device are discovered in this scan, send a passthrough FIS to set
	the write cache.  This is controllable through the following
	tunable at boot:

	hw.mpt.enable_sata_wc:
		-1 = Do not configure, use the controller default
		 0 = Disable the write cache
		 1 = Enable the write cache

	The default is -1.  This tunable is just a hack and may be
	deprecated in the future.

Turning on the write cache alleviates the write performance problems with
SATA that many people have observed.  It is not recommend for those who
value data reliability!  I cannot stress this strongly enough.  However,
it is useful in certain circumstances, and it brings the performence in line
with what a generic SATA controller running under the FreeBSD ATA driver
provides (and the ATA driver has had the WC enabled by default for years).
2007-06-03 23:13:05 +00:00
Matt Jacob
d0a68c2747 Make this driver MP safe and still be a multi-release driver.
Obtained from:	99% of the work done by Scott Long.
MFC after:	3 days
2007-05-05 20:18:24 +00:00
Matt Jacob
a2baed9764 (commented out) multipath fault injection code.
Some code to make diffs with RELENG_6 easier.
2007-01-05 22:49:05 +00:00
Matt Jacob
7185cd3625 PH! Forgot to do my cross-compile check. Also now rearranged things so
the ENDIAN defines are consistent between mpt.h and mpt.c.
2006-12-07 23:51:00 +00:00
Matt Jacob
0e0521a153 MFP4: principally to reapply tagged command support to FC and SAS cards. 2006-12-07 22:02:28 +00:00
Matt Jacob
a54067cc0e Fix a debug message which didn't quite get it right about data direction.
Fix things to use the LSI-Logic Fusion Library mask and shift names for
offset and sync, no matter how awkward they are, in preference to just
plain numbers.
2006-12-03 00:28:11 +00:00
John Birrell
3f970273b1 Add big endian support.
Submitted by:	scottl
Reviewed by:	mjacob
2006-11-15 21:46:36 +00:00
Matt Jacob
a7303be1a8 Create a 'ready' handler for each personality. The purpose of this handler
is to able to be called after *all* attach and enable events are done.

We establish a SYSINIT hook to call this handler. The current usage for it
is to add scsi target resources *after* all enables are done. There seems
to be some dependencies between different halves of a dual-port with respect
to target mode.

Put in more meaningful event messages for some events- in particular
QUEUE FULL events so we can see what the queue depth was when the
IOC sent us this message.

MFC after:	1 week
2006-09-07 23:08:21 +00:00
Matt Jacob
6621d786eb If we're in mpt_wait_req and the command times out,
mark it as timed out. Don't try and free the config
request for read_cfg_header that times out because
it's still active. Put in code for the config reply
handler that will then free up timed out requests.

Fix the FC_PRIMITIVE_SEND completion to not try
and free a command twice. Dunno how this possibly
could have been working for awhile.

MFC after:	2 weeks
2006-07-16 03:34:55 +00:00
Matt Jacob
b4c618c099 Fix config page writes to not strip out the attributes when you
actually go write the config page. This fixes the long standing
problem about updating NVRAM on Fibre Channel cards and seems
so far to not break SPI config page writes.

Put back role setting into mpt. That is, you can set a desired role
for mpt as a hint. On the next reboot, it'll pick that up and redo
the NVRAM settings appropriately and warn you that this won't take
effect until the next reboot. This saves people the step of having
to find a BIOS utilities disk to set target and/or initiator role
for the MPT cards.
2006-07-12 07:48:50 +00:00
Matt Jacob
9fe6d25444 Major Fixes:
Don't enable/disable I/O space except for SAS adapters.
  This fixes a problem with VMware 4.5 Workstation.

  Fix an egregious bug introduced to target mode so it actually
  will not panic when you first enable a lun.

Minor fixes:

  Take more infor from port facts and configuration pages.

MFC after:	1 week
2006-06-25 04:23:26 +00:00
Matt Jacob
5580ce963e More checkpointing on the way toward really (finally)
fixing speed negotiation.

Also fix the mpt_execute_req function to actually
match mpt_execute_req_a64. This may explain why
i386 users were having more grief.
2006-06-02 18:50:39 +00:00
Matt Jacob
ec5fe39d39 Add acknowledgements to LSI-Logic for support 2006-05-29 20:34:28 +00:00
Matt Jacob
1d79ca0e46 Work in progress toward fixing IM checked in after having
lost one set to a peninsula power failure last night. After
this, I can see both submembers and the raid volumes again,
but speed negotiation is still broken.

Add a mpt_raid_free_mem function to centralize the resource
reclaim and fixed a small memory leak.

Remove restriction on number of targets for systems with IM enabled-
you can have setups that have both IM volumes as well as other devices.

Fix target id selection for passthru and nonpastrhu cases.

Move complete command dumpt to MPT_PRT_DEBUG1 level so that just
setting debug level gets mostly informative albeit less verbose
dumping.
2006-05-27 17:26:57 +00:00
Matt Jacob
1043516d26 Remove handrolled raw dump of a request from
mpt_send_cmd and replace with a new debug function.
2006-05-26 05:41:14 +00:00
Matt Jacob
4f9f0449c6 Remove debounce code in mpt_intr. After some reflection
and watching a debounce followed by a timeout, I think
I'm forced to conclude that it was not a good idea.
2006-04-19 21:17:33 +00:00
Matt Jacob
5089bd63bd A large set of changes:
+ Add boatloads of KASSERTs and *really* check out more locking
issues (to catch recursions when we actually go to real locking
in CAM soon). The KASSERTs also caught lots of other issues like
using commands that were put back on free lists, etc.

+ Target mode: role setting is derived directly from port capabilities.
There is no need to set a role any more. Some target mode resources
are allocated early on (ELS), but target command buffer allocation
is deferred until the first lun enable.

+ Fix some breakages I introduced with target mode in that some commands
are *repeating* commands. That is, the reply shows up but the command
isn't really done (we don't free it). We still need to take it off the
pending list because when we resubmit it, bad things then  happen.

+ Fix more of the way that timed out commands and bus reset is done. The
actual TMF response code was being ignored.

+ For SPI, honor BIOS settings. This doesn't quite fix the problems we've
seen where we can't seem to (re)negotiate U320 on all drives but avoids
it instead by letting us honor the BIOS settings. I'm sure this is not
quite right and will have to change again soon.
2006-04-11 16:47:30 +00:00
Matt Jacob
33f3184660 Fix fat-fingered version define. 2006-04-01 19:49:55 +00:00
Matt Jacob
5e073106d5 Fix some of the previus changes 'better'.
There's something strange going on with async events. They seem
to be be treated differently for different Fusion implementations.
Some will really tell you when it's okay to free the request that
started them.  Some won't. Very disconcerting.

This is particularily bad when the chip (FC in this case) tells you
in the reply that it's not a continuation reply, which means you
can free the request that its associated with. However, if you do
that, I've found that additional async event replies come back for
that message context after you freed it. Very Bad Things Happen.

Put in a reply register debounce. Warn about out of range context
indices. Use more MPILIB defines where possible. Replace bzero with
memset. Add tons more KASSERTS. Do a *lot* more request free list
auditting and serial number usages. Get rid of the warning about
the short IOC Facts Reply.  Go back to 16 bits of context index.

Do a lot more target state auditting as well. Make a tag out
of not only the ioindex but the request index as well and worry
less about keeping a full serial number.
2006-04-01 07:12:18 +00:00
Matt Jacob
a529c6a2dc Correct bad format args. Interesting- the lines that generated
the error on sparc64 hadn't changed since the last checkin, pass
LINT on other platforms and mpt doesn't work on sparc64 anyway
and the tinderbox build didn't work for me in a cross build case
on my main build machine (which runs RELENG_6). Sigh. Still
need to try harder.
2006-03-26 07:16:17 +00:00
Matt Jacob
c87e3f833c Some fairly major changes to this driver.
A) Fibre Channel Target Mode support mostly works
(SAS/SPI won't be too far behind). I'd say that
this probably works just about as well as isp(4)
does right now. Still, it and isp(4) and the whole
target mode stack need a bit of tightening.

B) The startup sequence has been changed so that
after all attaches are done, a set of enable functions
are called. The idea here is that the attaches do
whatever needs to be done *prior* to a port being
enabled and the enables do what need to be done for
enabling stuff for a port after it's been enabled.

This means that we also have events handled by their
proper handlers as we start up.

C) Conditional code that means that this driver goes
back all the way to RELENG_4 in terms of support.

D) Quite a lot of little nitty bug fixes- some discovered
by doing RELENG_4 support. We've been living under Giant
*waaaayyyyy* too long and it's made some of us (me) sloppy.

E) Some shutdown hook stuff that makes sure we don't blow
up during a reboot (like by the arrival of a new command
from an initiator).

There's been some testing and LINT checking, but not as
complete as would be liked. Regression testing with Fusion
RAID instances has not been possible. Caveat Emptor.

Sponsored by: LSI-Logic.
2006-03-25 07:08:27 +00:00
Matt Jacob
9b7de73509 In mpt_complete_request_chain don't depend on somebody else to
remove the request from the TAILQ.
2006-03-17 04:52:27 +00:00
Matt Jacob
7a49a0d1fb Add a serial number for requests so we don't just depend on a request pointer
to try and do forensics on what has occurred.
2006-03-07 17:56:40 +00:00