MFC r244983 (by jfv):
Add Intel Lynx Point PCH SATA Controller Device IDs


git-svn-id: svn+ssh://svn.freebsd.org/base/stable/9@247098 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
MFC r238379, r238382 (by bruefer):
Renamed the kern.cam.da.da_send_ordered sysctl and tunable to
kern.cam.da.send_ordered, more in line with the other da sysctls/tunables.
Renamed the kern.cam.ada.ada_send_ordered sysctl and tunable to
kern.cam.ada.send_ordered, more in line with the other da sysctls/tunables.

PR:		169765


git-svn-id: svn+ssh://svn.freebsd.org/base/stable/9@247103 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
MFC r230590 (by ken) except parts changing ABI:
Add CAM infrastructure to allow reporting when a drive's long read capacity
data changes.


git-svn-id: svn+ssh://svn.freebsd.org/base/stable/9@247111 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
MFC	r237574:

Ensure crunchen uses the same make binary as the rest of the build.

I actually had already merged the crunchgen part of it as part
of the the enhanced ELF support.

Discussed with:		Simon Gerraty


git-svn-id: svn+ssh://svn.freebsd.org/base/stable/9@247112 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
MFC r236138 (by ken) for recently merged scsi_enc.c:

Work around a race condition in devfs by changing the way closes
are handled in most CAM peripheral drivers that are not handled by
GEOM's disk class.

The usual character driver open and close semantics are that the
driver gets N open calls, but only one close, when the last caller
closes the device.

CAM peripheral drivers expect that behavior to be honored to the
letter, and the CAM peripheral driver code (specifically
cam_periph_release_locked_busses()) panics if it is done incorrectly.

Since devfs has to drop its locks while it calls a driver's close
routine, and it does not have a way to delay or prevent open calls
while it is calling the close routine, there is a race.

The sequence of events, simplified a bit, is:

- devfs acquires a lock
- devfs checks the reference count, and if it is 1, continues to close.
- devfs releases the lock

- 2nd process open call on the device happens here

- devfs calls the driver's close routine

- devfs acquires a lock
- devfs decrements the reference count
- devfs releases the lock

- 2nd process close call on the device happens here

At the second close, we get a panic in
cam_periph_release_locked_busses(), complaining that peripheral
has been released when the reference count is already 0.  This is
because we have gotten two closes in a row, which should not
happen.

The fix is to add the D_TRACKCLOSE flag to the driver's cdevsw, so
that we get a close() call for each open().  That does happen
reliably, so we can make sure that our reference counts are
correct.

Note that the sa(4) and pt(4) drivers only allow one context
through the open routine.  So these drivers aren't exposed to the
same race condition.

scsi_ch.c,
scsi_enc.c,
scsi_enc_internal.h,
scsi_pass.c,
scsi_sg.c:
		For these drivers, change the open() routine to
		increment the reference count for every open, and
		just decrement the reference count in the close.

		Call cam_periph_release_locked() in some scenarios
		to avoid additional lock and unlock calls.

scsi_pt.c:	Call cam_periph_release_locked() in some scenarios
		to avoid additional lock and unlock calls.


git-svn-id: svn+ssh://svn.freebsd.org/base/stable/9@247113 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
MFC r237328 (by ken) for recently merged scsi_enc.c:

Fix several reference counting and object lifetime issues between
the pass(4) and enc(4) drivers and devfs.

The pass(4) driver uses the destroy_dev_sched() routine to
schedule its device node for destruction in a separate thread
context.  It does this because the passcleanup() routine can get
called indirectly from the passclose() routine, and that would
cause a deadlock if the close routine tried to destroy its own
device node.

In any case, once a particular passthrough driver number, e.g.
pass3, is destroyed, CAM considers that unit number (3 in this
case) available for reuse.

The problem is that devfs may not be done cleaning up the previous
instance of pass3, and will panic if isn't done cleaning up the
previous instance.

The solution is to get a callback from devfs when the device node
is removed, and make sure we hold a reference to the peripheral
until that happens.

Testing exposed some other cases where we have reference counting
issues, and those were also fixed in the pass(4) driver.

cam_periph.c:	In camperiphfree(), reorder some of the operations.

		The peripheral destructor needs to be called before
		the peripheral is removed from the peripheral is
		removed from the list.  This is because once we
		remove the peripheral from the list, and drop the
		topology lock, the peripheral number may be reused.
		But if the destructor hasn't been called yet, there
		may still be resources hanging around (like devfs
		nodes) that haven't been fully cleaned up.

cam_xpt.c:	Add an argument to xpt_remove_periph() to indicate
		whether the topology lock is already held.

scsi_enc.c:	Acquire an extra reference to the peripheral during
		registration, and release it once we get a callback
		from devfs indicating that the device node is gone.

		Call destroy_dev_sched_cb() in enc_oninvalidate()
		instead of calling destroy_dev() in the cleanup
		routine.

scsi_pass.c:	Add reference counting to handle peripheral and
		devfs object lifetime issues.

		Add a reference to the peripheral and the devfs
		node in the peripheral registration.

		Don't attempt to add a physical path alias if the
		peripheral has been marked invalid.

		Release the devfs reference once the initial
		physical path alias taskqueue run has completed.

		Schedule devfs node destruction in the
		passoninvalidate(), and release our peripheral
		reference in a new routine, passdevgonecb() once
		the devfs node is gone.  This allows the peripheral
		to fully go away, and the peripheral destructor,
		passcleanup(), will get called.


git-svn-id: svn+ssh://svn.freebsd.org/base/stable/9@247114 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
MFC r244014 (by ken):

Fix a device departure bug for the the pass(4), enc(4), sg(4) and ch(4)
drivers.

The bug occurrs when a userland process has the driver instance
open and the underlying device goes away.  We get the devfs
callback that the device node has been destroyed, but not all of
the closes necessary to fully decrement the reference count on the
CAM peripheral.

The reason is that once devfs calls back and says the device has
been destroyed, it is moved off to deadfs, and devfs guarantees
that there will be no more open or close calls.  So the solution
is to keep track of how many outstanding open calls there are on
the device, and just release that many references when we get the
callback from devfs.

scsi_pass.c,
scsi_enc.c,
scsi_enc_internal.h:    Add an open count to the softc in these
                        drivers.  Increment it on open and
                        decrement it on close.

                        When we get a devfs callback to say that
                        the device node has gone away, decrement
                        the peripheral reference count by the
                        number of still outstanding opens.

                        Make sure we don't access the peripheral
                        with cam_periph_unlock() after what might
                        be the final call to
                        cam_periph_release_locked().  The
                        peripheral might have been freed, and we
                        will be dereferencing freed memory.

scsi_ch.c,
scsi_sg.c:              For the ch(4) and sg(4) drivers, add the
                        same changes described above, and in
                        addition, fix another bug that was
                        previously fixed in the pass(4) and enc(4)
                        drivers.

                        These drivers were calling destroy_dev()
                        from their cleanup routine, but that could
                        cause a deadlock because the cleanup
                        routine could be indirectly called from
                        the driver's close routine.  This would
                        cause a deadlock, because the device node
                        is being held open by the active close
                        call, and can't be destroyed.


git-svn-id: svn+ssh://svn.freebsd.org/base/stable/9@247115 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
MFC r244980 (by jvf):
Add Intel Lynx Point PCH HD Audio Device IDs


git-svn-id: svn+ssh://svn.freebsd.org/base/stable/9@247120 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
MFC r238802:
   Update the 'C1x draft' reference to '.St -isoC-2011' mdoc macro.


git-svn-id: svn+ssh://svn.freebsd.org/base/stable/9@247123 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
MFC r226064 (by wxs):
Fix a typo in a comment.


git-svn-id: svn+ssh://svn.freebsd.org/base/stable/9@247124 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
MFC: Merge sendmail 8.14.6 errata issue


git-svn-id: svn+ssh://svn.freebsd.org/base/stable/9@247141 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
MFC r246832:
  vn_io_faults_cnt:
  - use u_long consistently
  - use SYSCTL_ULONG to match the type of variable


git-svn-id: svn+ssh://svn.freebsd.org/base/stable/9@247149 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
MFC r242852, r243069:
Several optimizations to sched_idletd():
 - Do not try to steal load from other CPUs if there was no context switches
on this CPU (i.e. it was idle all the time and woke up just for bus mastering
or TLB shutdown). If current CPU was idle, then it is quite unlikely that some
other CPU has load to steal.  Under high I/O rate, when TLB shutdowns cause
numerous CPU wakeups, on 24-CPU system load stealing code may consume up to
25% of all CPU time without giving any benefits.
 - Change code that implements spinning for load to restart spin in case of
context switch.  Previous code periodically called cpu_idle() even under
high interrupt/context switch rate.
 - Rise spinning threshold to 10KHz, where it gives at least some effect
that may worth consumed power.


git-svn-id: svn+ssh://svn.freebsd.org/base/stable/9@247150 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
MFC r246857:

Regenerate libstdc++'s config.h, synchronizing it with our current
almost-C99 headers.


git-svn-id: svn+ssh://svn.freebsd.org/base/stable/9@247155 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
MFC r246858:

Pull in r175057 from upstream llvm trunk:

  X86: Disable generation of rep;movsl when %esi is used as a base pointer.

  This happens when there is both stack realignment and a dynamic alloca in the
  function. If we overwrite %esi (rep;movsl uses fixed registers) we'll lose the
  base pointer and the next register spill will write into oblivion.

  Fixes PR15249 and unbreaks firefox on i386/freebsd. Mozilla uses dynamic allocas
  and freebsd a 4 byte stack alignment.


git-svn-id: svn+ssh://svn.freebsd.org/base/stable/9@247156 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
MFC r247003:

Pull in r175360 from upstream llvm trunk:

  MCParser: Reject .balign with non-pow2 alignments.

  GNU as rejects them and there are configure scripts in the wild that
  check if the assembler rejects ".align 3" to determine whether the
  alignment is in bytes or powers of two.


git-svn-id: svn+ssh://svn.freebsd.org/base/stable/9@247157 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
MFC r246522: sh: Simplify mksyntax and make it fit for cross-compiling.

Now it outputs fixed files, which use constants provided by the C standard
library to determine appropriate values for the target machine.

Before, mksyntax inspected the host machine which resulted in subtle
breakage if e.g. char is signed on the host and unsigned on the target such
as when cross-compiling on x86 for ARM.

Submitted by:	Christoph Mallon


git-svn-id: svn+ssh://svn.freebsd.org/base/stable/9@247163 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
MFC support for -print-file-name=include.


git-svn-id: svn+ssh://svn.freebsd.org/base/stable/9@247167 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Whitespace. Direct commit to stable/9 (no sysinstall in head).


git-svn-id: svn+ssh://svn.freebsd.org/base/stable/9@247170 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
MFC	r246563, r246564, r246634:

ext2fs: Miscellaneous cleanups and fixes.

make e2fs_maxcontig local and remove tautological check.
Replace redundant EXT2_MIN_BLOCK with EXT2_MIN_BLOCK_SIZE.
Use prototype declarations for function definitions

Submitted by:		Christoph Mallon


git-svn-id: svn+ssh://svn.freebsd.org/base/stable/9@247209 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f