Commit Graph

31200 Commits

Author SHA1 Message Date
Hans Petter Selasky
6a55ff4866 Ensure waiting loops terminate during cold boot. This fixes boot with
MacBookPro and i915kms_load="YES" in /boot/loader.conf.

A lowlevel timeout in one of the display ports caused an infinite wait
because a ticks/jiffies comparison was constant. The clock subsystem
which makes ticks/jiffies increment is started after the initial
driver probing is done. Refer to sys/kernel.h and SI_SUB_DRIVERS vs
SI_SUB_CLOCKS .

Discussed with:	kmacy @
2016-05-10 18:18:29 +00:00
Pedro F. Giffuni
594c945a54 aic7xxx: minor spelling fixes.
Affects mostly comments but also a visible text string,

Differential Revision:	https://reviews.freebsd.org/D6270
2016-05-10 16:40:19 +00:00
Hans Petter Selasky
ae14b49908 Fix kernel LINT build after r299363.
Define shadowing macros the same way to avoid macro redefinition
compile error(s) for now.

Approved by:	np @
2016-05-10 16:31:18 +00:00
Edward Tomasz Napierala
13a8942827 Remove NULL checks after M_WAITOK allocations from mpr(4).
Reviewed by:	asomers@
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D6297
2016-05-10 15:04:24 +00:00
Edward Tomasz Napierala
6db37b5649 Remove NULL checks after M_WAITOK allocations from mps(4).
Reviewed by:	asomers@
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D6296
2016-05-10 14:57:14 +00:00
Edward Tomasz Napierala
084d207584 Remove misc NULL checks after M_WAITOK allocations.
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
2016-05-10 10:26:07 +00:00
Edward Tomasz Napierala
b00039f739 Remove NULL check after M_WAITOK allocations from mfi(4).
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
2016-05-10 10:24:35 +00:00
Edward Tomasz Napierala
256a4cb9d7 Remove NULL checks after M_WAITOK allocations from firewire.
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
2016-05-10 10:21:03 +00:00
Andrew Rybchenko
a07bcda4ea sfxge(4): cleanup: fix typo
Submitted by:   Andy Moreton <amoreton at solarflare.com>
Sponsored by:   Solarflare Communications, Inc.
MFC after:      1 week
2016-05-10 08:00:40 +00:00
Andrew Rybchenko
dcb49ebade sfxge(4): cleanup: remove unneeded include files
Submitted by:   Andy Moreton <amoreton at solarflare.com>
Sponsored by:   Solarflare Communications, Inc.
MFC after:      1 week
2016-05-10 07:59:23 +00:00
Andrew Rybchenko
04bd9a165a sfxge(4): cleanup: remove unused efx_infer_family()
Submitted by:   Andy Moreton <amoreton at solarflare.com>
Sponsored by:   Solarflare Communications, Inc.
MFC after:      1 week
2016-05-10 07:42:18 +00:00
Andrew Rybchenko
908ecfc65d sfxge(4): cleanup: remove obsolete common code module
Submitted by:   Andy Moreton <amoreton at solarflare.com>
Sponsored by:   Solarflare Communications, Inc.
MFC after:      1 week
2016-05-10 07:40:03 +00:00
Andrew Rybchenko
7bfe1d8677 sfxge(4): cleanup: fix typos
Submitted by:   Andy Moreton <amoreton at solarflare.com>
Sponsored by:   Solarflare Communications, Inc.
MFC after:      1 week
2016-05-10 07:38:23 +00:00
Andrew Rybchenko
69a8775247 sfxge(4): cleanup efx_check.h comments and error messages
Submitted by:   Andy Moreton <amoreton at solarflare.com>
Sponsored by:   Solarflare Communications, Inc.
MFC after:      1 week
2016-05-10 07:22:19 +00:00
Andrew Rybchenko
b18622c3b3 sfxge(4): remove EFSYS_OPT_PHY_TXC43128
Submitted by:   Andy Moreton <amoreton at solarflare.com>
Sponsored by:   Solarflare Communications, Inc.
MFC after:      1 week
2016-05-10 07:21:14 +00:00
Andrew Rybchenko
ffb5b3947f sfxge(4): remove EFSYS_OPT_PHY_SFX7101
Submitted by:   Andy Moreton <amoreton at solarflare.com>
Sponsored by:   Solarflare Communications, Inc.
MFC after:      1 week
2016-05-10 07:20:18 +00:00
Andrew Rybchenko
7d276678b9 sfxge(4): remove EFSYS_OPT_PHY_SFT9001
Submitted by:   Andy Moreton <amoreton at solarflare.com>
Sponsored by:   Solarflare Communications, Inc.
MFC after:      1 week
2016-05-10 07:19:15 +00:00
Andrew Rybchenko
784995f8f3 sfxge(4): remove EFSYS_OPT_PHY_QT2025C
Submitted by:   Andy Moreton <amoreton at solarflare.com>
Sponsored by:   Solarflare Communications, Inc.
MFC after:      1 week
2016-05-10 07:18:18 +00:00
Andrew Rybchenko
0c2328b0ad sfxge(4): remove EFSYS_OPT_PHY_QT2022C2
Submitted by:   Andy Moreton <amoreton at solarflare.com>
Sponsored by:   Solarflare Communications, Inc.
MFC after:      1 week
2016-05-10 07:17:08 +00:00
Andrew Rybchenko
45a31c66ed sfxge(4): remove EFSYS_OPT_PHY_NULL
Submitted by:   Andy Moreton <amoreton at solarflare.com>
Sponsored by:   Solarflare Communications, Inc.
MFC after:      1 week
2016-05-10 07:15:57 +00:00
Andrew Rybchenko
eaec7581ab sfxge(4): remove EFSYS_OPT_NVRAM_SFX7101
Submitted by:   Andy Moreton <amoreton at solarflare.com>
Sponsored by:   Solarflare Communications, Inc.
MFC after:      1 week
2016-05-10 07:15:09 +00:00
Andrew Rybchenko
d9b66edc7e sfxge(4): remove EFSYS_OPT_NVRAM_SFT9001
Submitted by:   Andy Moreton <amoreton at solarflare.com>
Sponsored by:   Solarflare Communications, Inc.
MFC after:      1 week
2016-05-10 07:13:45 +00:00
Andrew Rybchenko
6e85f167f6 sfxge(4): remove EFSYS_OPT_FALCON_BOOTROM
Submitted by:   Andy Moreton <amoreton at solarflare.com>
Sponsored by:   Solarflare Communications, Inc.
MFC after:      1 week
2016-05-10 07:12:27 +00:00
Andrew Rybchenko
1c7fb9c767 sfxge(4): remove EFSYS_OPT_MON_NULL
Submitted by:   Andy Moreton <amoreton at solarflare.com>
Sponsored by:   Solarflare Communications, Inc.
MFC after:      1 week
2016-05-10 07:11:09 +00:00
Andrew Rybchenko
3f20cf969d sfxge(4): remove EFSYS_OPT_MON_MAX6647
Submitted by:   Andy Moreton <amoreton at solarflare.com>
Sponsored by:   Solarflare Communications, Inc.
MFC after:      1 week
2016-05-10 07:09:18 +00:00
Andrew Rybchenko
4060d2b031 sfxge(4): remove EFSYS_OPT_MON_LM87
Submitted by:   Andy Moreton <amoreton at solarflare.com>
Sponsored by:   Solarflare Communications, Inc.
MFC after:      1 week
2016-05-10 07:08:40 +00:00
Andrew Rybchenko
16f997ae55 sfxge(4): remove EFSYS_OPT_MAC_FALCON_XMAC
Submitted by:   Andy Moreton <amoreton at solarflare.com>
Sponsored by:   Solarflare Communications, Inc.
MFC after:      1 week
2016-05-10 07:07:49 +00:00
Andrew Rybchenko
56dae5be28 sfxge(4): remove EFSYS_OPT_MAC_FALCON_GMAC
Submitted by:   Andy Moreton <amoreton at solarflare.com>
Sponsored by:   Solarflare Communications, Inc.
MFC after:      1 week
2016-05-10 07:06:44 +00:00
Andrew Rybchenko
53e1d37767 sfxge(4): remove EFSYS_OPT_FALCON_NIC_CFG_OVERRIDE
Submitted by:   Andy Moreton <amoreton at solarflare.com>
Sponsored by:   Solarflare Communications, Inc.
MFC after:      1 week
2016-05-10 07:02:59 +00:00
Andrew Rybchenko
e75412c9cb sfxge(4): remove EFSYS_OPT_FALCON
Submitted by:   Andy Moreton <amoreton at solarflare.com>
Sponsored by:   Solarflare Communications, Inc.
MFC after:      1 week
2016-05-10 07:01:06 +00:00
Andrew Rybchenko
0d38c77d19 sfxge(4): add TLV item manipulation functions to common code
Add creation, deletion and checksumming operations to the private copy of
TLV functions in the common code.  Functions added in preparation for V3
licensing support, as licensing keys are stored in the TLV format.  Missing
support for multiple segment partitions added. Annotations for Windows code
analysis also updated.

Submitted by:   Richard Houldsworth <rhouldsworth at solarflare.com>
Sponsored by:   Solarflare Communications, Inc.
MFC after:      1 week
Differential Revision:  https://reviews.freebsd.org/D6264
2016-05-10 06:53:38 +00:00
Andrew Rybchenko
5abce2b919 sfxge(4): restructure TLV buffer validation
Move TLV buffer validation into ef10-specific function and add accessor
function which also converts the partition ID to the internal
representation.

Submitted by:   Richard Houldsworth <rhouldsworth at solarflare.com>
Sponsored by:   Solarflare Communications, Inc.
MFC after:      1 week
Differential Revision:  https://reviews.freebsd.org/D6263
2016-05-10 06:51:20 +00:00
Adrian Chadd
45d8d7918e [siba] migrate siba.c to siba_mips.c
Turns out that ye olde siba.c is /just/ the siba mips code (used by
the initial SENTRY5 port.  However, I don't think it was ever
finished enough to be useful, and I do have this nagging feeling
that we'll eventually replace it with the bhnd code.

But, since bhnd(4) introduced siba.c too, we ended up with a
source file name clash, and that broke the SENTRY5 build.

It /looks/ like this is the only place siba.c / device siba is
used.
2016-05-10 05:05:23 +00:00
Adrian Chadd
05992f9e2c [bhnd] fix bcma resource allocation for regions; EROM work around.
* bcma.c - assign different resource IDs for different regions
* bcma_erom.c - workaround for BCM/MIPS bus enumerations

Tested:

* (submitter) Tested on ASUS RT-N16 initially, double checked on ASUS RT-N53
* (landonf) BCM4331

Submitted by:	Michael Zhilin <mizkha@gmail.com>
Differential Revision:	https://reviews.freebsd.org/D6245
2016-05-10 04:55:57 +00:00
John Baldwin
f7bc393477 Forward declare 'struct cpl_set_tcb_rpl' before including t4_tom.h. 2016-05-10 03:32:22 +00:00
John Baldwin
8d791e5af1 Add a new bus method to fetch device-specific CPU sets.
bus_get_cpus() returns a specified set of CPUs for a device.  It accepts
an enum for the second parameter that indicates the type of cpuset to
request.  Currently two valus are supported:

 - LOCAL_CPUS (on x86 this returns all the CPUs in the package closest to
   the device when DEVICE_NUMA is enabled)
 - INTR_CPUS (like LOCAL_CPUS but only returns 1 SMT thread for each core)

For systems that do not support NUMA (or if it is not enabled in the kernel
config), LOCAL_CPUS fails with EINVAL.  INTR_CPUS is mapped to 'all_cpus'
by default.  The idea is that INTR_CPUS should always return a valid set.

Device drivers which want to use per-CPU interrupts should start using
INTR_CPUS instead of simply assigning interrupts to all available CPUs.
In the future we may wish to add tunables to control the policy of
INTR_CPUS (e.g. should it be local-only or global, should it ignore
SMT threads or not).

The x86 nexus driver exposes the internal set of interrupt CPUs from the
the x86 interrupt code via INTR_CPUS.

The ACPI bus driver and PCI bridge drivers use _PXM to return a suitable
LOCAL_CPUS set when _PXM exists and DEVICE_NUMA is enabled.  They also and
the global INTR_CPUS set from the nexus driver with the per-domain set from
_PXM to generate a local INTR_CPUS set for child devices.

Compared to the r298933, this version uses 'struct _cpuset' in
<sys/bus.h> instead of 'cpuset_t' to avoid requiring <sys/param.h>
(<sys/_cpuset.h> still requires <sys/param.h> for MAXCPU even though
<sys/_bitset.h> does not after recent changes).
2016-05-09 20:50:21 +00:00
John Baldwin
d3cd2df1f2 Forward declare 'struct cpl_set_tcb_rpl' before including t4_tom.h.
Other structures needed by prototypes in t4_tom.h are explicitly
declared in this file, so adding the prototype here seems most
consistent with existing code.
2016-05-09 20:01:34 +00:00
Pedro F. Giffuni
9be4c8d056 otus: minor catchup with OpenBSD.
Bump the OpenBSD revision tag since the corresponding changes don't
apply to us and drop an unnecessary header.

No functional change.
2016-05-09 19:28:22 +00:00
Adrian Chadd
f9cf87a0e0 [bhnd] fix incorrect typing.
Pointed out by: emaste
2016-05-09 17:19:17 +00:00
Stephen McConnell
e769dfac49 Bump version of mpr driver to 13.00.00.00-fbsd
Approved by:	ken, scottl, ambrisko
MFC after:      1 week
2016-05-09 16:38:51 +00:00
Stephen McConnell
58581c1363 Disks can go missing until a reboot is done in some cases.
This is due to the DevHandle not being released, which causes the Firmware to
not allow that disk to be re-added.

Reviewed by:    ken, scottl, ambrisko, asomers
Approved by:	ken, scottl, ambrisko
MFC after:      1 week
Differential Revision: https://reviews.freebsd.org/D6102
2016-05-09 16:36:40 +00:00
Stephen McConnell
5d21655f67 done_ccb pointer can be used if it is NULL.
To prevent this, move check for done_ccb == NULL to before done_ccb is used in
mprsas_stop_unit_done().

Reviewed by:    ken, scottl, ambrisko, asomers
Approved by:	ken, scottl, ambrisko
MFC after:      1 week
Differential Revision: https://reviews.freebsd.org/D6099
2016-05-09 16:34:06 +00:00
Stephen McConnell
407073a044 Use callout_reset_sbt() instead of callout_reset() if FreeBSD ver is >= 1000029
Reviewed by:    ken, scottl, ambrisko, asomers
Approved by:	ken, scottl, ambrisko
MFC after:      1 week
Differential Revision: https://reviews.freebsd.org/D6101
2016-05-09 16:31:43 +00:00
Stephen McConnell
dd9f4a95b2 No need to set the MPRSAS_SHUTDOWN flag because it's never used.
Approved by:	ken, scottl, ambrisko
MFC after:      1 week
2016-05-09 16:29:25 +00:00
Stephen McConnell
8861939221 Fix possible use of invalid pointer.
It was possible to use an invalid pointer to get the target ID value. To fix
this, initialize a local Target ID variable to an invalid value and change that
variable to a valid value only if the pointer to the Target ID is not NULL.

Reviewed by:    ken, scottl, ambrisko, asomers
Approved by:	ken, scottl, ambrisko
MFC after:      1 week
Differential Revision: https://reviews.freebsd.org/D6100
2016-05-09 16:26:34 +00:00
Stephen McConnell
b41c6ff97a Change logging level for a debug string to use MPR_LOG instead of MPR_INFO.
Approved by:	ken, scottl, ambrisko
MFC after:      1 week
2016-05-09 16:24:16 +00:00
Stephen McConnell
d3f6eabf13 No log bit in IOCStatus and endian-safe changes.
Use MPI2_IOCSTATUS_MASK when checking IOCStatus to mask off the log bit, and
make a few more things endian-safe.

Reviewed by:    ken, scottl, ambrisko, asomers
Approved by:	ken, scottl, ambrisko
MFC after:      1 week
Differential Revision: https://reviews.freebsd.org/D6097
2016-05-09 16:21:14 +00:00
Stephen McConnell
2bbc5fcb4b Add support for the Broadcom (Avago/LSI) 9305 16 and 24 port HBA's.
Reviewed by:    ken, scottl, ambrisko, asomers
Approved by:	ken, scottl, ambrisko
MFC after:      1 week
Relnotes:       yes
Differential Revision: https://reviews.freebsd.org/D6098
2016-05-09 16:19:13 +00:00
Stephen McConnell
7a2a6a1a6f Several style changes and add copyrights for 2016.
Reviewed by:    ken, scottl, ambrisko, asomers
Approved by:	ken, scottl, ambrisko
MFC after:      1 week
Differential Revision: https://reviews.freebsd.org/D6103
2016-05-09 16:16:00 +00:00
Stephen McConnell
28ae62b066 Update MPI headers to version 42.
Reviewed by:    ken, scottl, ambrisko, asomers
Approved by:	ken, scottl, ambrisko
MFC after:      1 week
Differential Revision: https://reviews.freebsd.org/D6096
2016-05-09 16:12:32 +00:00
Andrew Rybchenko
ca738e7a95 sfxge(4): remove EFSYS_OPT_PCIE_TUNE
With the removal of Falcon support, this is now dead code.

Submitted by:   Andy Moreton <amoreton at solarflare.com>
Sponsored by:   Solarflare Communications, Inc.
MFC after:      1 week
2016-05-09 08:38:56 +00:00
Andrew Rybchenko
5af774cbaf sfxge(4): disable common code support for Falcon
This patch ensures that client code will fail to build
with Falcon support. Following patches remove Falcon
support code entirely.

sfxge(4) has never supported Falcon.

Submitted by:   Andy Moreton <amoreton at solarflare.com>
Sponsored by:   Solarflare Communications, Inc.
MFC after:      1 week
2016-05-09 08:37:42 +00:00
Andrew Rybchenko
aa7e294253 sfxge(4): cleanup: fix obsolete EFSYS_OPT_PHY_BIST option
Submitted by:   Andy Moreton <amoreton at solarflare.com>
Sponsored by:   Solarflare Communications, Inc.
MFC after:      1 week
2016-05-09 08:35:08 +00:00
Andrew Rybchenko
edf6d8af7a sfxge(4): Siena no longer supports EFSYS_OPT_PCIE_TUNE
Submitted by:   Andy Moreton <amoreton at solarflare.com>
Sponsored by:   Solarflare Communications, Inc.
MFC after:      1 week
2016-05-09 08:32:49 +00:00
Andrew Rybchenko
cc22e260bb sfxge(4): remove unused efx_nic_pcie_extended_sync()
Submitted by:   Andy Moreton <amoreton at solarflare.com>
Sponsored by:   Solarflare Communications, Inc.
MFC after:      1 week
2016-05-09 08:28:52 +00:00
Adrian Chadd
c39790cd22 [siba] add 2GHz/5GHz FEM parameter fetching and accessor methods.
This is used by the bwn(4) PHY-N code that I'm working on.
2016-05-09 06:30:00 +00:00
Adrian Chadd
53daa9cd9c [siba] add FEM variables from the r8 SPROM layout.
This will eventually be used the bwn(4) N-PHY code that I'm (slowly)
writing.

Obtained from:	Linux b43
2016-05-09 06:05:23 +00:00
Adrian Chadd
e83ce34035 [bhnd] Initial bhnd(4) SPROM/NVRAM support.
This adds support for the NVRAM handling and the basic SPROM
hardware used on siba(4) and bcma(4) devices, including:

* SPROM directly attached to the PCI core, accessible via PCI configuration
  space.
* SPROM attached to later ChipCommon cores.
* SPROM variables vended from the parent SoC bus (e.g. via a directly-attached
  flash device).

Additional improvements to the NVRAM/SPROM interface will
be required, but this changeset stands alone as working
checkpoint.

Submitted by:	Landon Fuller <landonf@landonf.org>
Reviewed by:	Michael Zhilin <mizkha@gmail.com> (Broadcom MIPS support)
Differential Revision:	https://reviews.freebsd.org/D6196
2016-05-08 19:14:05 +00:00
Adrian Chadd
f74f1a68d5 [bhnd] Add support for matching on chip identifiers.
This is used by the upcoming SPROM code to match on chipsets
that require special handling of muxed SPROM pins.

Submitted by:	Landon Fuller <landonf@landonf.org>
Differential Revision:	https://reviews.freebsd.org/D6195
2016-05-08 18:30:08 +00:00
Adrian Chadd
a73ac06d93 [bhnd] Add bhnd_resource support for the bus_(read|write)(_multi_)stream_* functions.
This adds additional bhnd_resource shims used by the upcoming SPROM deltas.

Submitted by:	Landon Fuller <landonf@landonf.org>
Differential Revision:	https://reviews.freebsd.org/D6194
2016-05-08 18:20:01 +00:00
Adrian Chadd
d935257080 [bhnd] Replace is_hostb_device() with a more general find_hostb_device()
This allows bus children to query for the host bridge device, rather
than having to iterate over all attached devices.

Submitted by:	Landon Fuller <landonf@landonf.org>
Differential Revision:	https://reviews.freebsd.org/D6193
2016-05-08 17:52:12 +00:00
John Baldwin
dc9643853d Use DDP to implement zerocopy TCP receive with aio_read().
Chelsio's TCP offload engine supports direct DMA of received TCP payload
into wired user buffers.  This feature is known as Direct-Data Placement.
However, to scale well the adapter needs to prepare buffers for DDP
before data arrives.  aio_read() is more amenable to this requirement than
read() as applications often call read() only after data is available in
the socket buffer.

When DDP is enabled, TOE sockets use the recently added pru_aio_queue
protocol hook to claim aio_read(2) requests instead of letting them use
the default AIO socket logic.  The DDP feature supports scheduling DMA
to two buffers at a time so that the second buffer is ready for use
after the first buffer is filled.  The aio/DDP code optimizes the case
of an application ping-ponging between two buffers (similar to the
zero-copy bpf(4) code) by keeping the two most recently used AIO buffers
wired.  If a buffer is reused, the aio/DDP code is able to reuse the
vm_page_t array as well as page pod mappings (a kind of MMU mapping the
Chelsio NIC uses to describe user buffers).  The generation of the
vmspace of the calling process is used in conjunction with the user
buffer's address and length to determine if a user buffer matches a
previously used buffer.  If an application queues a buffer for AIO that
does not match a previously used buffer then the least recently used
buffer is unwired before the new buffer is wired.  This ensures that no
more than two user buffers per socket are ever wired.

Note that this feature is best suited to applications sending a steady
stream of data vs short bursts of traffic.

Discussed with:	np
Relnotes:	yes
Sponsored by:	Chelsio Communications
2016-05-07 00:33:35 +00:00
John Baldwin
826c2372c5 Set the correct vnet in TOE event handlers.
Differential Revision:	https://reviews.freebsd.org/D6152
2016-05-06 23:49:10 +00:00
John Baldwin
1963070cd3 Restore name=value format of PCI location strings.
When devctl was added, the location string for PCI devices was changed to
use the PCI "selector" that pciconf and devctl accept.  However, devd
assumes that location strings are formatted as a list of name=value pairs.
As a result, devd is no longer parsing any of the values out of PCI
device events.  Restore the previous format of the PCI location strings
to restore the location and slot keywords in case any devd scripts are
using this.  Add the "selector" as a new 'dbsf' location variable.

Reviewed by:	imp
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D6253
2016-05-06 23:46:35 +00:00
Pedro F. Giffuni
363089d89e dev/e1000,ixgbe: minor spelling fixes.
No functional change.

Differential Revision:	https://reviews.freebsd.org/D6177
2016-05-06 22:54:56 +00:00
Andriy Voskoboinyk
bec488d17d iwn: fix comments for iwn_read_eeprom_channels().
It's used for all channels (20MHz and 40MHz).
2016-05-06 17:39:12 +00:00
Sean Bruno
40b6008fc5 Since igb_detach() cleans up all the data structures that will be
free'd by the functions following its call, we can simply return instead
of crashing and burning in the event of igb_detach() failing.

PR:		197139
Submitted by:	rupavath@juniper.net
MFC after:	2 weeks
2016-05-06 17:00:45 +00:00
Roger Pau Monné
288b2385b8 xen/privcmd: fix integer truncation in IOCTL_PRIVCMD_MMAPBATCH
The size field in the XENMEM_add_to_physmap_range is an uint16_t, and the
privcmd driver was doing an implicit truncation of an int into an uint16_t
when filling the hypercall parameters.

Fix this by adding a loop and making sure privcmd splits ioctl request into
2^16 chunks when issuing the hypercalls.

Reported and tested by:	Marcin Cieslak <saper@saper.info>
Sponsored by:		Citrix Systems R&D
2016-05-06 16:44:46 +00:00
Sean Bruno
eb9f04ddd9 If ALTQ is defined in the kern conf, switch to Legacy Mode.
PR:		208409
Submitted by:	freebsd@mcwest.org
MFC after:	2 weeks
2016-05-06 15:41:38 +00:00
Pedro F. Giffuni
25cd047538 dev/usb: unsigned some loop indexes.
Although usually small, values produced by nitems() are unsigned.
By unsigning the corresponding indexes we avoid signed vs unsigned
comparisons. This may have some effect on performance, although given the
small sizes the effect will not be perceivable, and it makes the code
clearer.

Respect the style of the changed files: one uses u_int while the other
uses "unsigned int".

Reviewed by:	hselasky
2016-05-06 15:09:21 +00:00
John Baldwin
82cb5c3b5b Native PCI-express HotPlug support.
PCI-express HotPlug support is implemented via bits in the slot
registers of the PCI-express capability of the downstream port along
with an interrupt that triggers when bits in the slot status register
change.

This is implemented for FreeBSD by adding HotPlug support to the
PCI-PCI bridge driver which attaches to the virtual PCI-PCI bridges
representing downstream ports on HotPlug slots. The PCI-PCI bridge
driver registers an interrupt handler to receive HotPlug events. It
also uses the slot registers to determine the current HotPlug state
and drive an internal HotPlug state machine. For simplicty of
implementation, the PCI-PCI bridge device detaches and deletes the
child PCI device when a card is removed from a slot and creates and
attaches a PCI child device when a card is inserted into the slot.

The PCI-PCI bridge driver provides a bus_child_present which claims
that child devices are present on HotPlug-capable slots only when a
card is inserted. Rather than requiring a timeout in the RC for
config accesses to not-present children, the pcib_read/write_config
methods fail all requests when a card is not present (or not yet
ready).

These changes include support for various optional HotPlug
capabilities such as a power controller, mechanical latch,
electro-mechanical interlock, indicators, and an attention button.
It also includes support for devices which require waiting for
command completion events before initiating a subsequent HotPlug
command. However, it has only been tested on ExpressCard systems
which support surprise removal and have none of these optional
capabilities.

PCI-express HotPlug support is conditional on the PCI_HP option
which is enabled by default on arm64, x86, and powerpc.

Reviewed by:	adrian, imp, vangyzen (older versions)
Relnotes:	yes
Differential Revision:	https://reviews.freebsd.org/D6136
2016-05-05 22:26:23 +00:00
Adrian Chadd
eb98afc8b0 .. delete this; I don't know why this was here. oops! 2016-05-05 20:16:58 +00:00
Adrian Chadd
426a80d44d [bhnd] don't use anonymous unions.
Found by: gcc-4.2
2016-05-05 19:56:18 +00:00
Adrian Chadd
054ae23156 [bhnd] default to BUS_PROBE_DEFAULT for unknown BHND classes.
Found by: gcc-4.2
2016-05-05 19:55:16 +00:00
Adrian Chadd
0aba90e3bc [bhnd] handle unknown bhnd port type. 2016-05-05 19:54:17 +00:00
Adrian Chadd
3b0750141a [bwn] fix signed-ness of the rssi parameter.
It's a uint8_t from the hardware.

Found by: gcc
2016-05-05 19:40:26 +00:00
Adrian Chadd
10cb4427d5 [bhnd] quieten gcc warning. 2016-05-05 19:38:53 +00:00
Adrian Chadd
988fa8d078 [bhnd] handle unknown port type.
Reported by: emaste
2016-05-05 19:30:14 +00:00
Jung-uk Kim
c19e9bb3b0 Fix intmax_t to uintptr_t casting on 32-bit platforms. Found by GCC.
Submitted by:	bde
2016-05-05 18:43:31 +00:00
Ed Maste
c009c4021c bhnd: another build fix for GCC-using architectures
Further to r299119. GCC architectures failed with
bcma_subr.c:138: warning: control reaches end of non-void function

Sponsored by:	The FreeBSD Foundation
2016-05-05 17:47:03 +00:00
Alan Somers
6adfa7edf0 mpr(4) and mps(4) shouldn't indefinitely retry for "terminated ioc" errors
Submitted by:	ken
Reviewed by:	slm
MFC after:	4 weeks
Sponsored by:	Spectra Logic Corp
Differential Revision:	https://reviews.freebsd.org/D6210
2016-05-05 15:32:47 +00:00
Ed Maste
c2ec037ff5 bhnd: fix build on gcc architectures
"make tinderbox" fails on sparc64 GENERIC-NODEBUG with:
bhnd_subr.c:188: warning: control reaches end of non-void function

Sponsored by:	The FreeBSD Foundation
2016-05-05 15:07:40 +00:00
Adrian Chadd
af4ae173e4 [bwn] implement firmware tx/rx versioning and fix RSSI calculation.
Different versions of firmware have different requirments for TX/RX
packet layouts (and other things, of course.)  Currently the driver
checks between 3xx and 4xx firmware by using the BWN_ISOLDFMT() macro,
which doesn't take into account the 5xx firmware (which I think I need
for the HT and N series PHY chips.  I'll know when I do the port.)
BWN_HDRSIZE() also needs to learn about the 5xx series firmware
as well.

So:

* add a firmware version enum
* populate it based on the firmware version we read at load time
* don't finish loading if the firmware is the 5xx firmware; any
  code using BWN_ISOLDFMT or BWN_HDRSIZE needs updating (most notably
  the TX and RX bits.)

Then, for RX RSSI:

* write down and reimplement the b43 rssi calculation method;
* use it for the correct PHYs (which are all the ones we support);
* do the RSSI calculation before radiotap, not after.

Tested:

* Broadcom BCM4312, STA mode

Obtained from:	Linux b43 (careful writing and reimplementing; lots of integer math..)
2016-05-05 07:04:38 +00:00
Adrian Chadd
148ed57165 [bwn] [bhnd] initial support for using bhnd for if_bwn devices.
This is an initial work in progress to use the replacement bhnd
bus code for devices which support it.

* Add manpage updates for bhnd, bhndb, siba
* Add kernel options for bhnd, bhndbus, etc
* Add initial support in if_bwn_pci / if_bwn_mac for using bhnd
  as the bus transport for suppoted NICs
* if_bwn_pci will eventually be the PCI bus glue to interface to bwn,
  which will use the right backend bus to attach to, versus direct
  nexus/bhnd attachments (as found in embedded broadcom devices.)

The PCI glue defaults to probing at a lower level than the bwn glue,
so bwn should still attach as per normal without a boot time tunable set.

It's also not fully fleshed out - the bwn probe/attach code needs to be
broken out into platform and bus specific things (just like ath, ath_pci,
ath_ahb) before we can shift the driver over to using this.

Tested:

* BCM4311, STA mode
* BCM4312, STA mode

Submitted by:	Landon Fuller <landonf@landonf.org>
Differential Revision:	https://reviews.freebsd.org/D6191
2016-05-04 23:38:27 +00:00
John Baldwin
e45163b216 Fix the acpi attachment to always start the worker thread.
The previous change to split the worker thread start out of fdc_attach()
did not start the worker thread if the fdc device in the ACPI namespace
did not have an _FDE method.  This fixes hangs when booting with a
floppy controller enabled on certain machines with ACPI.

Tested by:	joel
2016-05-04 23:00:57 +00:00
Alan Somers
8907f744ff Improve performance and functionality of the bitstring(3) api
Two new functions are provided, bit_ffs_at() and bit_ffc_at(), which allow
for efficient searching of set or cleared bits starting from any bit offset
within the bit string.

Performance is improved by operating on longs instead of bytes and using
ffsl() for searches within a long. ffsl() is a compiler builtin in both
clang and gcc for most architectures, converting what was a brute force
while loop search into a couple of instructions.

All of the bitstring(3) API continues to be contained in the header file.
Some of the functions are large enough that perhaps they should be uninlined
and moved to a library, but that is beyond the scope of this commit.

sys/sys/bitstring.h:
        Convert the majority of the existing bit string implementation from
        macros to inline functions.

        Properly protect the implementation from inadvertant macro expansion
        when included in a user's program by prefixing all private
        macros/functions and local variables with '_'.

        Add bit_ffs_at() and bit_ffc_at(). Implement bit_ffs() and
        bit_ffc() in terms of their "at" counterparts.

        Provide a kernel implementation of bit_alloc(), making the full API
        usable in the kernel.

        Improve code documenation.

share/man/man3/bitstring.3:
        Add pre-exisiting API bit_ffc() to the synopsis.

        Document new APIs.

        Document the initialization state of the bit strings
        allocated/declared by bit_alloc() and bit_decl().

        Correct documentation for bitstr_size(). The original code comments
        indicate the size is in bytes, not "elements of bitstr_t". The new
        implementation follows this lead. Only hastd assumed "elements"
        rather than bytes and it has been corrected.

etc/mtree/BSD.tests.dist:
tests/sys/Makefile:
tests/sys/sys/Makefile:
tests/sys/sys/bitstring.c:
        Add tests for all existing and new functionality.

include/bitstring.h
	Include all headers needed by sys/bitstring.h

lib/libbluetooth/bluetooth.h:
usr.sbin/bluetooth/hccontrol/le.c:
        Include bitstring.h instead of sys/bitstring.h.

sbin/hastd/activemap.c:
        Correct usage of bitstr_size().

sys/dev/xen/blkback/blkback.c
        Use new bit_alloc.

sys/kern/subr_unit.c:
        Remove hard-coded assumption that sizeof(bitstr_t) is 1.  Get rid of
        unrb.busy, which caches the number of bits set in unrb.map.  When
        INVARIANTS are disabled, nothing needs to know that information.
        callapse_unr can be adapted to use bit_ffs and bit_ffc instead.
        Eliminating unrb.busy saves memory, simplifies the code, and
        provides a slight speedup when INVARIANTS are disabled.

sys/net/flowtable.c:
        Use the new kernel implementation of bit-alloc, instead of hacking
        the old libc-dependent macro.

sys/sys/param.h
        Update __FreeBSD_version to indicate availability of new API

Submitted by:   gibbs, asomers
Reviewed by:    gibbs, ngie
MFC after:      4 weeks
Sponsored by:   Spectra Logic Corp
Differential Revision:  https://reviews.freebsd.org/D6004
2016-05-04 22:34:11 +00:00
Andriy Voskoboinyk
4772b8701c wi: fix a comment (0x1fff has 13 bits set). 2016-05-04 18:08:38 +00:00
Pedro F. Giffuni
4a00a65162 dev/pms: minor spelling fixes for the FreeBSD-specific part. 2016-05-04 17:52:53 +00:00
Roger Pau Monné
2ed46a6f7d xen/pvclock: set the correct resolution for the Xen PV clock
The Xen PV clock has a resolution of 1ns, so set the resolution to the
highest one that FreeBSD supports, which is 1us.

MFC after:	2 weeks
Sponsored by:	Citrix Systems R&D
2016-05-04 13:49:59 +00:00
Andriy Voskoboinyk
a7d1e7a9ec iwn: fix device reset after watchdog timeout.
Simple device reset (stop/start) is not enough here;
post-init state changes must be applied too.
2016-05-04 12:51:27 +00:00
Hans Petter Selasky
869df73304 Extend the UQ_NO_STRINGS quirk to also cover the USB language string
descriptor. This fixes enumeration of some older Samsung Galaxy S3
phones.

MFC after:	1 week
2016-05-04 08:57:40 +00:00
Adrian Chadd
a8cd039341 s/struct device */device_t/g
Submitted by:	kmacy
2016-05-04 06:26:27 +00:00
Adrian Chadd
cde57cac55 s/struct device */device_t/g
Submitted by:	kmacy
2016-05-04 06:25:12 +00:00
Adrian Chadd
ade965c38b s/struct device */device_t/g
Submitted by:	kmacy
2016-05-04 06:24:51 +00:00
Adrian Chadd
d19677ddd7 s/struct device */device_t/g
Submitted by:	kmacy
2016-05-04 06:24:10 +00:00
Adrian Chadd
748cd4c30d s/struct device */device_t/g
Submitted by:	kmacy
2016-05-04 06:23:49 +00:00
Jung-uk Kim
12b204a61b Fix build without "options PCI_IOV". 2016-05-04 06:22:41 +00:00
Adrian Chadd
d191ae19a2 [bwn] fix rate control feedback.
* Add a debug print for the xmit completion status fields.
  Yes, I like staring at a stream of DWORDS.

* Set the retrycnt to the number of full frame retries for now;
  I'll figure out how to factor rts/cts failures into it when
  I figure out what the difference is.

  It's -1 because it's not "retries", it's "tries".

It now passes the youtube test.

Tested:

* BCM4312, STA mode
2016-05-04 02:11:45 +00:00
Alexander Kabaev
cdd2592ffd Fix nvram2env after bus_space_fdt removal.
The generic bus space does the mapping now, no need to pre-translate
phys addresses to KSEG1 anymore.

Submitted by: Hiroki Mori
2016-05-04 01:56:37 +00:00
Marcelo Araujo
b3956646bf Use imin() macro from sys/libkern.h.
MFC after:	2 weeks.
2016-05-04 01:43:07 +00:00