MFC r233544:
Fix random deadlock on pmcstat exit:
- Exit the thread when soft shutdown is requested
- Wakeup owner thread.

Reproduced/tested by looping pmcstat measurement:
pmcstat -S instructions -O/tmp/test ls


git-svn-id: svn://svn.freebsd.org/base/stable/9@233824 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
MFC r233746:
Be more conservative in using READ CAPACITY(16) command. Previous code
checked PROTECT bit in INQUIRY data for all SPC devices, while it is defined
only since SPC-3. But there are some SPC-2 USB devices were reported, that
have PROTECT bit set, return no error for READ CAPACITY(16) command, but
return wrong sector count value in response.


git-svn-id: svn://svn.freebsd.org/base/stable/9@233828 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
MFC r233231:
Fix several problems with our ELF filters implementation.

Do not relocate twice an object which happens to be needed by loaded
binary (or dso) and some filtee opened due to symbol resolution when
relocating need objects.  Record the state of the relocation
processing in Obj_Entry and short-circuit relocate_objects() if
current object already processed.

Do not call constructors for filtees loaded during the early
relocation processing before image is initialized enough to run
user-provided code.  Filtees are loaded using dlopen_object(), which
normally performs relocation and initialization.  If filtee is
lazy-loaded during the relocation of dso needed by the main object,
dlopen_object() runs too earlier, when most runtime services are not
yet ready.

Postpone the constructors call to the time when main binary and
depended libraries constructors are run, passing the new flag
RTLD_LO_EARLY to dlopen_object().  Symbol lookups callers inform
symlook_* functions about early stage of initialization with
SYMLOOK_EARLY.  Pass flags through all functions participating in
object relocation.

Use the opportunity and fix flags argument to find_symdef() in
arch-specific reloc.c to use proper name SYMLOOK_IN_PLT instead of
true, which happen to have the same numeric value.

MFC r233777 (by kan):
Do not try to adjust stacks if dlopen_object is called too early.

MFC r233778 (by kan):
Remove extra blank line from revious commit.

MFC note: the ARM and MIPS TLS support is not merged back, so the chunks
from r233231 which fix misuse of flags in calls to find_symdef() in
the corresponding relocation type handlers were not applied. When TLS
support is merged, the rest of r233231 should be applied too.


git-svn-id: svn://svn.freebsd.org/base/stable/9@233831 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
MFC r233546:
Prevent rtld_verify_object_versions() from being called several times
for the same object.


git-svn-id: svn://svn.freebsd.org/base/stable/9@233832 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
MFC r233655:
Add a special case in do_dlsym() for TLS stored symbols.

MFC r233674:
Fix ia64 build after r233655.


git-svn-id: svn://svn.freebsd.org/base/stable/9@233833 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
MFC r229937:
Add pidfile_fileno() to obtain the file descriptor for an open
pidfile.


git-svn-id: svn://svn.freebsd.org/base/stable/9@233837 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
MFC r233567:
Add support for 6150 series devices.

Tested by:	Shane Riddle <sh4neriddle at yahoo dot com>


git-svn-id: svn://svn.freebsd.org/base/stable/9@233838 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
MFC r233568:
Add a list of available devices which matches the names shown by pciconf.
While here add 2 missing firmware modules.


git-svn-id: svn://svn.freebsd.org/base/stable/9@233840 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
MFC r233571:
strip (R) to match manpage and pci_vendors


git-svn-id: svn://svn.freebsd.org/base/stable/9@233842 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
MFC r232959 and r232960:

Prevent tmpfs_rename() deadlock in a way similar to UFS. Unlock
vnodes and try to lock them one by one. Relookup fvp and tvp.

Don't enforce LK_RETRY to get existing vnode in tmpfs_alloc_vp().
Doomed vnode is hardly of any use here, besides all callers handle
error case. vfs_hash_get() does the same. Don't mess with vnode
holdcount, vget() takes care of it already.

Approved by:	mdf (mentor)


git-svn-id: svn://svn.freebsd.org/base/stable/9@233851 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
MFC r229951,229985-229986,229988,230011,230037,230233,230599-230601
libutil.h and pidfile.c cleanup:

229951: Constify arguments (pjd)

229985: Fix forward structure declaration and prototype disorder.

229986: Fix namespace issues with prototype parameter names.
Add missing prototype parameter names.

229988: Fix prototype formatting (indentation, long lines, and
continued lines).

230011: More prototype formatting fixes, struct member formatting fixes,
and namespace fix for property_find() prototype.

230037: Move struct pidfh definition into pidfile.c, and leave a forward
declaration for pidfh in libutil.h in its place.
This allows us to hide the contents of the pidfh structure, and also
allowed removal of the "#ifdef _SYS_PARAM_H" guard from around the
pidfile_* function prototypes.

230233: Fix more disorder in prototypes and constants.
Fix header comments for each section of constants.
Fix whitespace in #define lines.
Fix unnecessary parenthesis in constants.

230599: Restore the parenthesis that are necessary around the
constant values.

230600: Make the comments consistent (capitalization, punctuation, and
format).

230601: Consensus between bde and pjd seemed to be that if the function
names are lined up, then any * after a long type should appear after
the type instead of being in front of the function name on the
following line.


git-svn-id: svn://svn.freebsd.org/base/stable/9@233855 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
MFC: 229942, 231938

229942: Style fixes courtesy of pjd.

231938: Set the O_CLOEXEC flag when opening the pidfile to avoid leaking the
file descriptor via exec(3).

Now that daemon(8) has been fixed to resolve the issue noted by trociny,
the consensus is that this change should be OK.


git-svn-id: svn://svn.freebsd.org/base/stable/9@233856 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
MFC r233608:
Microoptimize: in qsync loop over mount vnodes, only unlock mount
interlock after we committed to try to vget() the vnode.


git-svn-id: svn://svn.freebsd.org/base/stable/9@233859 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
MFC r233606:
Stop HDA controller polling callout on suspend and reset it on resume.

PR:		kern/166382


git-svn-id: svn://svn.freebsd.org/base/stable/9@233878 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
MFC r233692:
Reenable unsolicited responses on CODEC if hdaa_sense_init() called again.
This fixes jack connection events handling after suspend/resume.

PR:		kern/166382


git-svn-id: svn://svn.freebsd.org/base/stable/9@233879 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
MFC: r233747, r233748

- Fix panic on kernel traps having a mapping in trap_sig b0rked in r206086.
  Reported by: David E. Cross
- Remove checks that are redundant due to tf_type being unsigned.


git-svn-id: svn://svn.freebsd.org/base/stable/9@233889 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
MFC 232980,233011,233017,233117,233434,233436,233454,233529,233530,233618:

Major pmap performance, concurrency, and correctness improvements, mostly
for the 64-bit PMAP module (64-bit-capable CPUs with either a 32-bit or
64-bit kernel). Thanks to alc for his help and prodding.


git-svn-id: svn://svn.freebsd.org/base/stable/9@233911 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Merge remote-tracking branch 'upstream/svn_stable_9' into svn_stable_9