ian [Mon, 11 Sep 2017 20:33:20 +0000 (20:33 +0000)]
MFC r321876:
In xdev-links, when installing symlinks to the cross-compiler pieces that
includes the OS version (armv6-freebsd12.0-cc, etc), use the OS version of
the compiler/world source code, not the version of the build host machine.
MFC r323128: Increase negotiation polling period from 10ms to 100ms.
There is no big need to burn CPU if other side may be not there yet. For
example, the PLX hardware by default enables the NTB link up on reset, not
dependig on driver to do it. In case of Intel hardware this also reduces
race between MSI-X workaround negotiation and upper layers, using the same
scratchpad registers in different time.
MFC r323074: Clear doorbell bits after masking them before processing.
In theory this allows to avoid one more expensive doorbell register read
later in some scenarios. But in practice it also significantly increases
packet rate on PLX hardware, that I can't explain yet, possibly work-
arounding some interrupt delays.
This driver supports both NTB-to-NTB and NTB-to-Root Port modes (though
the second with predictable complications on hot-plug and reboot events).
I tested it with PEX 8717 and PEX 8733 chips, but expect it should work
with many other compatible ones too. It supports up to two NT bridges
per chip, each of which can have up to 2 64-bit or 4 32-bit memory windows,
6 or 12 scratchpad registers and 16 doorbells. There are also 4 DMA engines
in those chips, but they are not yet supported.
While there, rename Intel NTB driver from generic ntb_hw(4) to more specific
ntb_hw_intel(4), so now it is on par with this new ntb_hw_plx(4) driver and
alike to Linux naming.
MFC r322981: Mask doorbells while processing them.
This fixes interrupt storms on hardware using legacy level-triggered
interrupts, since doorbell processing could take time after interrupt
handler completion, that triggered extra interrupts in a loop.
MFC r322980: Fix fake interrupt when set doorbell is unmasked.
Since the doorbell bit is already set when interrupt handler is called,
the event was not propagated to upper layer. It was working normally
because present code was not using masking actively, but that is going
to change.
r320901:
Protect access to the AT realtime clock with its own mutex.
The mutex protecting access to the registered realtime clock should not be
overloaded to protect access to the atrtc hardware, which might not even be
the registered rtc. More importantly, the resettodr mutex needs to be
eliminated to remove locking/sleeping restrictions on clock drivers, and
that can't happen if MD code for amd64 depends on it. This change moves the
protection into what's really being protected: access to the atrtc date and
time registers.
This change also adds protection when the clock is accessed from
xentimer_settime(), which bypasses the resettodr locking.
r320902:
Support multiple realtime clocks, and remove locking/sleeping restrictions
on clock drivers.
This tracks multiple concurrent realtime clock drivers in a list sorted by
clock resolution. When system time changes (and periodically) the
clock_settime() methods of all registered clocks are invoked.
To initialize system time, each driver is tried in turn from best to worst
resolution, until one succesfully returns a valid time.
The code no longer holds a mutex while calling the clock_settime() and
clock_gettime() methods of the registered clocks. This allows clock drivers
to do whatever kind of locking or sleeping is necessary (this is especially
important for i2c clock chips since i2c drivers often need to sleep).
A new clock_register_flags() function allows the clock driver to pass
flags. The flags currently defined help support drivers that use their own
techniques to avoid roundoff errors (prevents the 4/5 rounding done by the
subr_rtc code). A driver which may need to wait for resources (such as bus
ownership) may pass a flag to indicate that it will obtain system time for
itself after waiting for resources; this is merely an optimization to avoid
the common code retrieving a timespec that will never get used.
r320996:
Allow setting debug.clocktime as a tunable. Print 64-bit time_t correctly
on 32-bit systems.
r320997:
Minor optimization: instead of converting between days and years using
loops that start in 1970, assume most conversions are going to be for recent
dates and use a precomputed number of days through the end of 2016.
r321002:
Revert r320997. There are reports of it getting the wrong results, so
clearly my testing was insuffficent, and it's best to just revert it
until I get it straightened out.
r321048:
Minor optimization: instead of converting between days and years using loops
that start in 1970, assume most conversions are going to be for recent dates
and use a precomputed number of days through the end of 2016.
This is a do-over of r320997, hopefully this time with 100% more workiness.
The first attempt had an off-by-one error, but instead of just adding
another mysterious +1 adjustment, this rearranges the relationship between
recent_base_year and recent_base_days so that the latter is the number of
days that occurred before the start of the associated year (instead of the
count thru the end of that year). This makes the recent_base stuff work
more like the original loop logic that didn't need any +1 adjustments.
r321400:
Add common code to support realtime clocks that store year without century.
Most realtime clocks store the year as 2 BCD digits. Some add a century bit
to extend the range another hundred years. Every clock driver has its own
code to determine the century and pass a full year value to clock_ct_to_ts().
Now clock drivers can just convert BCD to bin and store the result in the
clocktime struct and let the common code figure out the century. Clocks
with a century bit can just add 100 to year if the century bit is on.
r321743:
Add taskqueue_enqueue_timeout_sbt(), because sometimes you want more control
over the scheduling precision than 'ticks' can offer, and because sometimes
you're already working with sbintime_t units and it's dumb to convert them
to ticks just so they can get converted back to sbintime_t under the hood.
r321745:
Add clock_schedule(), a feature that allows realtime clock drivers to
request that their clock_settime() methods be called at a given offset
from top-of-second. This adds a timeout_task to the rtc_instance so that
each clock can be separately added to taskqueue_thread with the scheduling
it prefers, instead of looping through all the clocks at once with a
single task on taskqueue_thread. If a driver doesn't call clock_schedule()
the default is the old behavior: clock_settime() is queued immediately.
ian [Mon, 11 Sep 2017 17:01:26 +0000 (17:01 +0000)]
MFC r321583, r321584:
Add a pair of convenience routines for doing simple "register" read/writes
on i2c devices, where the "register" can be any length.
Add support for tracking nested calls to iicbus_request/release_bus().
Usually it is sufficient to use iicbus_transfer_excl(), or one of the
higher-level convenience functions that use it, to reserve the bus for the
duration of each register access. Occasionally it is important that a
series of accesses or read-modify-write operations must be done without any
other intervening access to the device, to prevent corrupting state.
bsdgrep: add a primitive literal matcher to unbreak fgrep in some scenarios
MFC r322825: bsdgrep: add some additional tests for fgrep
Previously added tests only check that fgrep is somewhat sane and works. Add
some more tests that check that the implementation is basically functional
and not producing incorrect results with various flags.
MFC r322826: bsdgrep: add a primitive literal matcher
fgrep/grep -F will error out at runtime if compiled with a regex(3)
that does not define REG_NOSPEC or REG_LITERAL. glibc is one such regex(3)
implementation, and as it turns out they don't support literal matching at
all.
Provide a primitive literal matcher for use with glibc and other
implementations that don't support literal matching so that we don't
completely lose fgrep/grep -F if compiled against libgnuregex on stable/10,
stable/11, or other systems that we don't necessarily support.
This is a wholly unoptimized implementation with no plans to optimize it as
of now. This is due to both its use-case being primarily on unsupported
systems in the near-distant future and that it's reinventing the wheel that
we already have available as a feature of regex(3).
ian [Mon, 11 Sep 2017 02:57:55 +0000 (02:57 +0000)]
MFC r320928, r320929:
Support the "disable-over-current" property for imx ehci controllers.
It turns out that this is more than a power optization. The OTG port
won't work on boards that have this property unless this setting is honored.
Also ensure that the usb phy device attaches before ehci.
Put an #ifdef notyet wrapper around a function that's not being used yet,
to avoid compile warnings.
ian [Mon, 11 Sep 2017 02:56:45 +0000 (02:56 +0000)]
MFC r320743:
Fix drivers that assume ticks starts at zero. These drivers all have logic
similar to "if (ticks > localvar+interval) {localvar=ticks; ...}" where
localvar is initialized to zero. Ticks is initialized to a negative value
since r278230, and that leads to these if statements never being true.
ian [Mon, 11 Sep 2017 02:52:41 +0000 (02:52 +0000)]
MFC r320655, r321933:
Add a driver for the imx6 on-chip realtime clock (snvs).
The imx6_snvs driver is not strictly required for the system to run, so
change it from standard to optional and add a device statement for it so
that it's included unless someone uses nodevice to eliminate it.
ian [Mon, 11 Sep 2017 02:50:24 +0000 (02:50 +0000)]
MFC r320460, r320461, r320462, r320463:
If an i2c transfer ends due to error, issue a stop on the bus even if the
nostop option is set, if a start was issued.
Add iic_recover_bus(), a helper function that can be used by any i2c driver
which is able to manipulate the clock and data lines directly.
When an i2c bus is hung by a slave device stuck in the middle of a
transaction that didn't complete properly, this function manipulates the
clock and data lines in a sequence known to reliably reset slave devices.
The most common cause of a hung i2c bus is a system reboot in the middle of
an i2c transfer (so it doesnt' happen often, but now there is a way other
than power cycling to recover from it).
Add bus recovery handling to the imx5/imx6 i2c driver.
ian [Mon, 11 Sep 2017 02:38:57 +0000 (02:38 +0000)]
MFC r320076:
Add a driver for the imx6 EPIT timer that can be used as the system
timecounter instead of the GPT timer, freeing up the more flexible GPT
hardware for other uses. The EPIT driver is a standard (always in the
kernel) driver, and the existing GPT driver is now optional and included
only if you ask for device imx_gpt.
ian [Mon, 11 Sep 2017 01:59:24 +0000 (01:59 +0000)]
MFC r319814, r319815, r319818:
Add a set of constants describing the ways a MAC and PHY can be connected.
While the initial need for this is to help support phy drivers which are
configured with FDT data, there is nothing devicetree-specific about the
concept or the names, so they are available for use even on non-FDT systems.
Add some utility functions to help a PHY driver on an FDT-configured
system retrieve its config data from the fdt data.
Convert if_ffec from local code and constants for mac<->phy connection type
to new common fdt helper code.
ian [Mon, 11 Sep 2017 01:53:22 +0000 (01:53 +0000)]
MFC r319859, r319888:
Add support for "make universe_kernels -DMAKE_GENERIC_KERNELS" to build
just the GENERIC kernels for each arch (including variations such as
GENERIC-NODEBUG, GENERIC64, etc).
This helps with quickly doing a test build for all[*] arches without
building dozens of variant kernels for the arches that have lots of
hardware/board/system variations.
[*] Not all arches have a generic kernel (but they probably should for
test-building purposes, even if it can't boot on any real hardware).
By popular demand: change MAKE_GENERIC_KERNELS to MAKE_LINT_KERNELS.
It appears that the same arches that lack GENERIC kernel configs also lack
LINT. But enough different arches get built to ensure a kernel change
should build everywhere (32 and 64 bit, clang and old gcc, little and big
endian).
ian [Mon, 11 Sep 2017 01:26:26 +0000 (01:26 +0000)]
MFC r319811, r319813:
Allow building if_ffec as a module.
if_ffec bugfixes related to harvesting of hardware-maintained statistics...
After harvesting the hardware statistics counters and summing them into the
interface stats, properly clear the hardware counters back to zero. On imx5
and earlier hardware it is necessary to disable collection of stats while
writing zeroes to all the registers. On imx6 and newer it turns out it's
not even possible to write zeroes, instead you have to toggle a special
"zero everything" control bit in a register.
Count incoming packets with a bad start frame delim as input errors, and
incoming packets dropped due to no fifo space as input drops.
Remove all code related to harvesting the hardware stats less often than
once per second. It turns out the 32-bit stats registers are backed by
16-bit counters under the hood, and they can easily roll over if you only
harvest them once every 3 seconds like the old code was doing. Now we just
read all the regs once a second.
The combination of not properly zeroing the stats registers and 16-bit
counters sometimes wrapping between harvest calls resulted in basically
unusable statistics before these changes.
ian [Mon, 11 Sep 2017 01:01:00 +0000 (01:01 +0000)]
MFC r316664, r316670, r316972, r316996, r317033:
Add imx6ul support (applies to all files).
Add code/constants for detecting imx6ul (ultralite) chips, a species of
imx6 based on a single cortex-a7 core. Other changes to imx6 drivers
and support code are needed to fully support the imx6ul.
if_ffec: Add imx6ul SoC support, and get the PHY number from the FDT data.
If there is no phy-handle property, fall back to using MII_PHY_ANY.
This still doesn't support an mdio bus with multiple PHYs on it, or the
possibility that the PHY being used by this instance of ffec is on the
mdio bus of some other instance (which is now a possibility with imx6ul).
Adding that support will require changes in fdt_get_phyaddr(), which is
currently making some assumptions that don't work with modern fdt data.
ian [Mon, 11 Sep 2017 00:55:18 +0000 (00:55 +0000)]
MFC r316374, r316377:
Preserve the registers containing argc, argv, and return address values
passed in from u-boot across the call to self_reloc and any other early-init
code, and restore them before calling main().
Correct a comment... the stack used by ubldr is the same stack u-boot was
running on when it jumped to the ubldr entry point. None of the arches
that use this code set up a different stack in their start.S routines.
ian [Sun, 10 Sep 2017 23:48:20 +0000 (23:48 +0000)]
MFC r315589, r315591, r316659, r316661:
Eliminate unnecessary read/modify/write sequences during eventtimer setup.
Replace the hard-coded way-too-small minimum event timer period with a value
calculated at runtime based on how long it takes to set up an event in
hardware. This fixes the intermittant 1-minute hang at boot on imx5
systems, and also the occasional oversleeping while running. It doesn't
affect imx6 systems, which use different hardware for eventtimers.
Remove some old interrupt handling workaround code from the pre-INTRNG days.
At this point, INTRNG is not going away (the option may go away, but the
code is not), so we no longer need code to support workarounds that handled
the lack of INTRNG functionality.
Update the code that compensates for the lack of a GPC interrupt controller
driver for imx6. Some newer dts source puts the GIC node at the root
instead of under /soc, so look in both places. Also, sometimes the GIC
node doesn't list itself as its own interrupt-parent, allow that too.
ian [Sun, 10 Sep 2017 23:31:21 +0000 (23:31 +0000)]
MFC r315572, r315573, r315575, r315578:
Add a module to build imx5 dtb files.
Add dtb/imx5 module build to the IMX53 kernel config.
Remove configs for IMX53-QSB and DIGI-CCWMX53. They were just
standard IMX53 with static dtb added, and now that imx53 can use vendor-
supplied dts files and ubldr, there is no need for a static-dtb variant.
ian [Sun, 10 Sep 2017 23:09:17 +0000 (23:09 +0000)]
MFC r315490, r315508:
Make the imx5 clocks driver work with vendor-supplied dts (which does not
supply the addresses for the DPLL register blocks) by hard-coding the
addresses in the driver source code. Yes, this is just as bad an idea as
it sounds, but we have no choice.
Remove hardcoded bootverbose=1; imx53 systems boot using loader(8) and
users can set verbose if they want to.
Remove SUBDIR ordering/uniquifying in *bin/Makefile
After the addition of SUBDIR.yes, uniquifying/ordering the SUBDIRs doesn't
make a whole lot of sense, and it's in effect a half measure.
Ordering SUBDIR (after adding SUBDIR.yes to it) in bsd.subdir.mk is a
separate change that warrants more discussion/testing, because while
the SUBDIR_PARALLEL work largely fixed dependency ordering for SUBDIRs,
there might be downstream FreeBSD consumers that rely on the SUBDIR
ordering.
Only expose :accuracy and :reduction if !i386, similar to before,
but more holistically to avoid future -Wunused issue with the unused
functions.
r321484:
Only test ld_pi_odd with LDBL_MANT_DIG == 64 to fix the build
The empty (unimplemented) test inputs for sparc64 trigger a -Wtype-limits build
failure because nitems of an empty array is always false, i.e., deadcode.
marius [Fri, 8 Sep 2017 00:11:10 +0000 (00:11 +0000)]
- Ever since the workaround for the silicon bug of TSO4 causing MAC hangs
was committed in r295133, CSUM_TSO gets always disabled by em(4) on the
first invocation of em_init_locked() given that at that point no link is
established, yet. In turn, this causes CSUM_TSO also to be off when em(4)
is used as a parent device for vlan(4), i. e. besides IFCAP_TSO4, also
IFCAP_VLAN_HWTSO effectively doesn't work.
In head an attempt to fix this was made with r308345, but that revision
had several problems on its own. One of which was that r308345 caused
IFCAP_TSO4 to also be cleared from both the interface capability and
capability enable bits. Thus, once a link switched from gigabit to a
lower speed, TSO no longer could be enabled, even not via ifconfig(8).
So this change moves the aforementioned WAR to em_update_link_status()
like r308345 did, but only alters the hardware assist bits accordingly,
leaving IFCAP_TSO4 flags alone.
Still, this isn't the only problem r308345 had. Another one is that there
just is no way to atomically flush TSO-using descriptors already queued
at the point in time a link speed switch to below GbE occurs. Thus, such
in-flight descriptors still may hang the MAC. Moreover, at least currently
there also is no way of triggering a reconfiguration of vlan(4) when the
state of IFCAP_VLAN_HWTSO support changes at runtime, causing vlan(4) to
continue employing TSO. Last but not least, testing shows that - despite
all the WARs for TSO-related silicon bugs in em(4) - at least 82579 still
may hang at gigabit speed with IFCAP_TSO4 enabled. Therefore, this change
further removes IFCAP_TSO4 and IFCAP_VLAN_HWTSO from interface capability
enable bits as set by em(4). While at it, the use of CSUM_TCP is replaced
with CSUM_IP_TSO as em(4) only implements support for IFCAP_TSO4 but not
IFCAP_TSO6 (although in principle available with a subset of the supported
MACs).
At the bottom line, this change allows IFCAP_TSO4 and IFCAP_VLAN_HWTSO to
be used again with em(4), but these hardware offloading capabilities now
need to be explicitly enabled via ifconfig(8). Beware that it's only
considered safe to do so (and also only may work) in environments where
the link speed is not to be expected to change from GbE. Moreover, em(4)
appears to still be missing some more TSO workarounds for at least some
models, specifically the 82579 (I could not find an errata sheet and
"specification update" respectively for these latter, though, and the
generic ICH8 one doesn't list any TSO related bugs).
- Let igb_tso_setup() handle EtherType protocols that are unsupported or
for which support hasn't been compiled in gracefully instead of calling
panic(9).
- Make em_allocate_{legacy,msix}() and lem_allocate_irq() match their
prototypes WRT static.
This is a direct commit to stable/11 as corresponding code is no longer
present in head.
MFC r322810 and r322830:
Add new mlx5ib(4) driver to the kernel source tree which supports
Remote DMA over Converged Ethernet, RoCE, for the ConnectX-4 series of
PCI express network cards.
There is currently no user-space support and this driver only supports
kernel side non-routable RoCE V1. The krping kernel module can be used
to test this driver. Full user-space support including RoCE V2 will be
added as part of the ongoing upgrade to ibcore from Linux 4.9. Otherwise
this driver is feature equivalent to mlx4ib(4). The mlx5ib(4) kernel
module will only be built when WITH_OFED=YES is specified.
dim [Tue, 5 Sep 2017 16:59:19 +0000 (16:59 +0000)]
MFC r323001:
In compiler-rt, a few assembler implementations for i386 floating point
conversion functions use SSE2 instructions, but these are not guarded by
#ifdef __SSE2__, and there is no implementation using general purpose
registers. For these functions, use the generic C variants instead,
otherwise they will cause SIGILL on older processors.
newvers.sh looks for a .vcs subdirectory (e.g. .git, .svn) to determine
which vcs info tool to run (e.g., git rev-parse, svn info).
(As of r308789 in head / r323167 in stable/11 if a .vcs subdirectory is
not found at ${TOPDIR} then newvers.sh walks up successive parent
directories, testing for the .vcs subdirectory at each step. This is
done in case the FreeBSD source is built in a subdirectory as part of
some larger project, but either way newvers.sh still tests for the .vcs
subdirectory.)
However, when using git worktree there is no .git subdirectory but
rather a plain text .git file which contains a reference to the main
working tree.
Change findvcs() to test that the .vcs entry exists, regardless of type.
If FreeBSD source tree is a subproject of a bigger project, then .git or
.hg may reside above FreeBSD sources root. Provide function findvcs()
that will climb up and seek for presence of a VCS directory.
MFC r303188,r303190,r303271,r303438,r303453: Warn flags for gcc 6.1
r303188 (by br):
Add warn flags for GCC 6.1 compiler.
r303190 (by br):
Add GCC 6.1 warn flags for kernel as well.
r303271 (by br):
Fix style.
r303438 (by br):
o Add warn flags required to build modules with GCC 6.1;
o Sort GCC 4.8 warn flags.
r303453 (by br):
Normalise the CWARNFLAGS inter-word spacing: remove all leading and
trailing space, and convert multiple consecutive spaces to single
space.