Commit Graph

36824 Commits

Author SHA1 Message Date
Takanori Watanabe
ca78bcd73b Add embedded Managed Object Format blob access to acpi_wmi(4).
This blob is can be converted to human readable form by bmfdec.
(http://github.com/pali/bmfdec)

Differential Revision:	https://reviews.freebsd.org/D21529
2019-09-06 10:12:05 +00:00
Ian Lepore
acce2d7606 Use a single write of 3 bytes instead of iicdev_writeto() in ads111x.
The iicdev_writeto() function basically does scatter-gather IO by filling
in a pair of iic_msg structs to write the register address then the data
from different locations but with a single bus START/xfer/STOP sequence.
It turns out several low-level i2c controller drivers do not honor the
IIC_NOSTART flag, so the second piece of the write gets a new START on
the bus, and that confuses the ads111x chips which expect a continuous
write of 3 bytes to set a register.

A proper fix for this is to track down all the misbehaving controllers
drivers and fix them.  For now this change makes this driver work again.
2019-09-05 19:17:53 +00:00
Ian Lepore
c56cf3d276 Ensure a measurement is complete before reading the result in ads111x.
Also, disable the comparator by default; it's not used for anything.

The previous logic would start a measurement, and then pause_sbt() for the
averaging time currently configured in the chip.  After waiting that long,
the code would blindly read the measurement register and return its value.
The problem is that the chip's idea of averaging time is based on its
internal free-running 1MHz oscillator, which may be running at a wildly
different rate than the kernel clock.  If the chip's internal timer was
running slower than the kernel clock, we'd end up grabbing a stale result
from an old measurement.

The driver now still uses pause_sbt() to yield the cpu while waiting for
the measurement to complete, but after sleeping it checks the chip's status
register to ensure the measurement engine is idle.  If it's not, the driver
uses a retry loop to wait a bit (5% of the original wait time) then check
again for completion.
2019-09-05 19:07:48 +00:00
Ed Maste
aa91d4b3a9 pcie: return an error if a matching resource is not found
Submitted by:	markj
Reviewed by:	manu
Event:		vBSDCon FreeBSD hackathon
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D20884
2019-09-05 15:45:21 +00:00
Hans Petter Selasky
a48a37bee2 Decrease the default audio playback latency to a maximum of 21.3ms.
This significantly improves the audio playback response time.

Discussed with:	mav@
MFC after:	1 week
Sponsored by:	Mellanox Technologies
2019-09-05 10:49:12 +00:00
Warner Losh
f93b7f954e Support doorbell strides != 0.
The NVMe standard (1.4) states

>>> 8.6 Doorbell Stride for Software Emulation
>>> The doorbell stride,...is useful in software emulation of an NVM
>>> Express controller. ...  For hardware implementations of the NVM
>>> Express interface, the expected doorbell stride value is 0h.

However, hardware in the wild exists with a doorbell stride of 1
(meaning 8 byte separation). This change supports that hardware, as
well as software emulators as envisioned in Section 8.6. Since this is
the fast path, care has been taken to make this computation
efficient. The bit of math to compute an offset for each is replaced
by a memory load from cache of a pre-computed value.

MFC After: 3 days
Reviewed by: scottl@
Differential Revision: https://reviews.freebsd.org/D21514
2019-09-04 20:08:36 +00:00
Ruslan Bukin
564e82561b o Add support for multi-port instances of Synopsys DesignWare APB GPIO
Controller.
o Rename the driver to dwgpio.

Sponsored by:	DARPA, AFRL
2019-09-04 15:37:24 +00:00
Warner Losh
4d5475613e Implement nvme suspend / resume for pci attachment
When we suspend, we need to properly shutdown the NVME controller. The
controller may go into D3 state (or may have the power removed), and
to properly flush the metadata to non-volatile RAM, we must complete a
normal shutdown. This consists of deleting the I/O queues and setting
the shutodown bit. We have to do some extra stuff to make sure we
reset the software state of the queues as well.

On resume, we have to reset the card twice, for reasons described in
the attach funcion. Once we've done that, we can restart the card. If
any of this fails, we'll fail the NVMe card, just like we do when a
reset fails.

Set is_resetting for the duration of the suspend / resume. This keeps
the reset taskqueue from running a concurrent reset, and also is
needed to prevent any hw completions from queueing more I/O to the
card. Pass resetting flag to nvme_ctrlr_start. It doesn't need to get
that from the global state of the ctrlr. Wait for any pending reset to
finish. All queued I/O will get sent to the hardware as part of
nvme_ctrlr_start(), though the upper layers shouldn't send any
down. Disabling the qpairs is the other failsafe to ensure all I/O is
queued.

Rename nvme_ctrlr_destory_qpairs to nvme_ctrlr_delete_qpairs to avoid
confusion with all the other destroy functions.  It just removes the
queues in hardware, while the other _destroy_ functions tear down
driver data structures.

Split parts of the hardware reset function up so that I can
do part of the reset in suspsend. Split out the software disabling
of the qpairs into nvme_ctrlr_disable_qpairs.

Finally, fix a couple of spelling errors in comments related to
this.

Relnotes: Yes
MFC After: 1 week
Reviewed by: scottl@ (prior version)
Differential Revision: https://reviews.freebsd.org/D21493
2019-09-03 15:26:11 +00:00
Andriy Gapon
50f14c4f68 superio: fix the copyright block and update the year
MFC after:	2 weeks
2019-09-03 12:40:58 +00:00
Warner Losh
31b11bb3f2 In nvme_completion_poll, add a sanity check to make sure that we complete the
polling within a second. Panic if we don't. All the commands that use this
interface should typically complete within a few tens to hundreds of
microseconds. Panic rather than return ETIMEDOUT because if the command somehow
does later complete, it will randomly corrupt memory. Also, it helps to get a
traceback from where the unexpected failure happens, rather than an infinite
loop.
2019-09-02 17:11:32 +00:00
Warner Losh
ab0681aac9 In all the places that we use the polled for completion interface, except crash
dump support code, move the while loop into an inline function. These aren't
done in the fast path, so if the compiler choses to not inline, any performance
hit is tiny.
2019-09-02 17:11:27 +00:00
Warner Losh
fc68da4b4d Add a brief comment explaining why we can return ETIMEDOUT from the call to the
polled interface. Normally this would have the potential to corrupt stack memory
because the completion routines would run after we return. In this case,
however, we're doing a dump so it's safe for reasons explained in the comment.
2019-09-02 17:10:46 +00:00
Hans Petter Selasky
f6549df685 Fix regression issue after r351616. Make sure the mbuf queue gets initialized.
Found by:	gonzo@
MFC after:	1 week
Sponsored by:	Mellanox Technologies
2019-09-02 08:31:18 +00:00
Ed Maste
73f4b4ebac vnic: correct and simplify SIOCSIFFLAGS
PR:		223573, 223575
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D13028
2019-09-01 16:53:17 +00:00
Vincenzo Maffione
253b2ec199 netmap: import changes from upstream (SHA 137f537eae513)
- Rework option processing.
 - Use larger integers for memory size values in the
   memory management code.

MFC after:	2 weeks
2019-09-01 14:47:41 +00:00
Jung-uk Kim
1c9c1f5903 Add support for TP-Link Archer T2U Nano.
MFC after:	2 weeks
2019-09-01 06:40:58 +00:00
Mark Johnston
7da9377b0d Properly check for an interrupted cv_wait_sig().
The returned error number may be EINTR or ERESTART depending on
whether or not the signal is supposed to interrupt the system call.

Reported and tested by:	pho
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
2019-08-30 15:40:31 +00:00
Ed Maste
d676fedfbc xdma: avoid NULL deref in error case
Reported by:	Dr Silvio Cesare of InfoSect
MFC after:	3 days
Sponsored by:	The FreeBSD Foundation
2019-08-30 00:40:08 +00:00
Ed Maste
7e0025dea2 qlxgbe: avoid NULL deref in error case
Reported by:	Dr Silvio Cesare of InfoSect
MFC after:	3 days
Sponsored by:	The FreeBSD Foundation
2019-08-30 00:38:16 +00:00
Gleb Smirnoff
35d3dd8b12 Use mbuf queue instead of ifqueue in USB network drivers.
Reviewed by:	stevek
2019-08-30 00:05:04 +00:00
Yuri Pankov
2051169a4f ichsmb: defer smbus attach until interrupts are available
This fixes a "timed sleep before timers are working" panic seen
while attaching jedec_dimm(4) instances too early in the boot.

Submitted by:	ian
Reviewed by:	hselasky
Differential Revision:	https://reviews.freebsd.org/D21452
2019-08-29 12:49:21 +00:00
Ed Maste
3485f4574e vnic: avoid NULL deref in error case
Reported by:	Dr Silvio Cesare of InfoSect
MFC after:	3 days
Sponsored by:	The FreeBSD Foundation
2019-08-29 12:05:06 +00:00
Navdeep Parhar
5fc7854e69 cxgbe/t4_tom: Use the correct value of sndbuf in AIO Tx.
This should have been part of r351540.

Sponsored by:	Chelsio Communications
2019-08-28 23:31:58 +00:00
Alexander Motin
610defb17c Fix AHCI Enclosure Management, broken by r351356.
ivars value of -1 was used to distinguish EM device, and r351356 left some
wrong checks for it.  Give EM device separate flag there instead.
2019-08-28 22:04:04 +00:00
Navdeep Parhar
c537e887ac cxgbe/t4_tom: Initialize all TOE connection parameters in one place.
Remove now-redundant items from toepcb and synq_entry and the code to
support them.

Let the driver calculate tx_align, rx_coalesce, and sndbuf by default.

Reviewed by:	jhb@
MFC after:	1 week
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D21387
2019-08-27 04:19:40 +00:00
Navdeep Parhar
241c83909c cxgbe/t4_tom: Limit work requests with immediate payload to a single
descriptor.  The per-tid tx credits are in demand during active Tx and
it's best not to use too many just for payload.

Sponsored by:	Chelsio Communications
2019-08-27 01:16:02 +00:00
Alexander Motin
4e38d474e1 Announce PCI Segment Groups supported to PCI host _OSC.
According to ACPI 6.3 specification:
    The OS sets this bit to 1 if it supports PCI Segment Groups as defined
    by the _SEG object, and access to the configuration space of devices
    in PCI Segment Groups as described by this specification.  Otherwise,
    the OS sets this bit to 0.

As far as I see we support both of those as PCI domains for quite a while.

MFC after:	2 months
2019-08-26 17:54:19 +00:00
Alexander Motin
21e51c82fb Don't consider PCIe hot-plug command timeout fatal.
According to my tests and errata to several generations of Intel CPUs,
PCIe hot-plug command completion reporting is not very reliable thing.
At least on my Supermicro X11DPi-NT board I never saw it reported.
Before this change timeout code detached devices and tried to disable
the slot, that in my case resulted in hot-plugged device being detached
just a second after it was successfully detected and attached.  This
change removes that, so in case of timeout it just prints the error and
continue operation.  Linux does the same.

MFC after:	1 week
Sponsored by:	iXsystems, Inc.
2019-08-26 17:27:36 +00:00
Vincenzo Maffione
df4e516f0f netmap: remove obsolete file
The netmap_pt.c module has become obsolete after
the refactoring that added netmap_kloop.c.
Remove it and unlink it from the build system.

MFC after:	1 week
2019-08-25 20:16:03 +00:00
Hiroki Sato
639eac2087 Add MODULE_PNP_INFO() to vmci(4). This allows devd(8) to load the
kernel module automatically when FreeBSD is running on VMware.

Reviewed by:		mp
Differential Revision:	https://reviews.freebsd.org/D21182
2019-08-25 18:46:10 +00:00
Warner Losh
5f9e856e3a It turns out the duplication is only mostly harmless.
While it worked with the kenrel, it wasn't working with the loader.
It failed to handle dependencies correctly. The reason for that is
that we never created a nvme module with the DRIVER_MODULE, but
instead a nvme_pci and nvme_ahci module. Create a real nvme module
that nvd can be dependent on so it can import the nvme symbols it
needs from there.

Arguably, nvd should just be a simple child of nvme, but transitioning
to that (and winning that argument given why it was done this way) is
beyond the scope of this change.

Reviewed by: jhb@
Differential Revision: https://reviews.freebsd.org/D21382
2019-08-23 22:52:58 +00:00
Navdeep Parhar
c5560a884d cxgbe/t4_tom: Any invalid scaling factor in the hardware's wsf field
implies that window scaling is not in use.

MFC after:	3 days
Sponsored by:	Chelsio Communications
2019-08-23 22:41:16 +00:00
Navdeep Parhar
4e4469cf3c whitespace nit. 2019-08-23 22:34:14 +00:00
Navdeep Parhar
8bf3090312 cxgbe(4): Use the same buffer size for TOE rx queues as the NIC rx queues.
This is a minor simplification.

MFC after:	1 week
Sponsored by:	Chelsio Communications
2019-08-23 22:22:34 +00:00
Warner Losh
8e61280bd9 When we have errors resetting the device before we allocate the
queues, don't try to tear them down in the ctrlr_destroy
path. Otherwise, we dereference queue structures that are NULL and we
trap.

This fix is incomplete: we leak IRQ and MSI resources when this
happens. That's preferable to a crash but still should be fixed.
2019-08-22 21:56:11 +00:00
Warner Losh
2d43fab9c2 We need to define version 1 of nvme, not nvme_foo. Otherwise nvd won't
load and people who pull in nvme/nvd from modules can't load nvd.ko
since it depends on nvme, not nvme_foo. The duplicate doesn't matter
since kldxref properly handles that case.
2019-08-22 21:12:51 +00:00
Warner Losh
ec743e0c33 Move releasing of resources to later
Turn off bus master after we detach the device (to match the prior
order).  Release MSI after we're done detaching and have turned off
all the interrupts. Otherwise this may cause problems as other threads
race nvme_detach. This more closely matches the old order.

Reviewed by: mav@
2019-08-22 20:09:32 +00:00
Bjoern A. Zeeb
c982e56f4b usb: fix usb_fdt_support.c when altq enabled (usb_ehernet.h changes)
After r351243 when ALTQ was enabled in the kernel, the inline functions
in ifq.h would not have full type information as if_var.h was not
included.

Given usb_ethernet.h already includes all the various headers (which)
is the cause of the problem here, add if_var.h to it.  This fixes the
builds again.

Reported by:	CI system, e.g. FreeBSD-head-aarch64-LINT
2019-08-22 09:24:43 +00:00
Warner Losh
acc48026b3 Remove stray line that was duplicated.
Noticed by: rpokala@
2019-08-22 02:53:51 +00:00
Warner Losh
93289cfcd2 Create a AHCI attachment for nvme.
Intel has created RST and many laptops from vendors like Lenovo and Asus. It's a
mechanism for creating multiple boot devices under windows. It effectively hides
the nvme drive inside of the ahci controller. The details are supposed to be a
trade secret. However, there's a reverse engineered Linux driver, and this
implements similar operations to allow nvme drives to attach. The ahci driver
attaches nvme children that proxy the remapped resources to the child. nvme_ahci
is just like nvme_pci, except it doesn't do the PCI specific things. That's
moved into ahci where appropriate.

When the nvme drive is remapped, MSI-x interrupts aren't forwarded (the linux
driver doesn't know how to use this either). INTx interrupts are used
instead. This is suboptimal, but usually sufficient for the laptops these parts
are in.

This is based loosely on https://www.spinics.net/lists/linux-ide/msg53364.html
submitted, but not accepted by, Linux. It was written by Dan Williams. These
changes were written from scratch by Olivier Houchard.

Submitted by: cognet@ (Olivier Houchard)
2019-08-21 22:18:01 +00:00
Warner Losh
f182f928db Separate the pci attachment from the rest of nvme
Nvme drives can be attached in a number of different ways. Separate out the PCI
attachment so that we can have other attachment types, like ahci and various
types of NVMeoF.

Submitted by: cognet@
2019-08-21 22:17:55 +00:00
Alexander Motin
71a2818142 Improve NVMe hot unplug handling.
If device is unplugged from the system (CSTS register reads return
0xffffffff), it makes no sense to send any more recovery requests or
expect any responses back.  If there is a detach call in such state,
just stop all activity and free resources.  If there is no detach
call (hot-plug is not supported), rely on normal timeout handling,
but when it trigger controller reset, do not wait for impossible and
quickly report failure.

MFC after:	2 weeks
Sponsored by:	iXsystems, Inc.
2019-08-21 20:17:30 +00:00
Xin LI
5473ef874e Fix sound on headset jack for ThinkPad T51. 2019-08-21 08:01:43 +00:00
Justin Hibbits
aef13f050c dpaa: Fix warnings in dtsec(4) found by clang
These are all trivial warnings that have no real functional change.
2019-08-21 02:26:22 +00:00
Alexander Motin
51b92c1af6 Formalize NVMe controller consumer life cycle.
This fixes possible double call of fail_fn, for example on hot removal.
It also allows ctrlr_fn to safely return NULL cookie in case of failure
and not get useless ns_fn or fail_fn call with NULL cookie later.

MFC after:	2 weeks
2019-08-21 02:17:39 +00:00
Mark Johnston
35fd0fc409 Use a sleepable lock for midistat functions.
Otherwise the mutex needs to be dropped when copying out the midistat
sbuf, leading to a race which allows one to read kernel memory beyond
the end of the sbuf buffer.

Reported and tested by:	pho
Security:	CVE-2019-5612
2019-08-20 17:52:12 +00:00
Justin Hibbits
31c484ad31 Unbreak USB ethernet module builds
Sponsored by:	Juniper Networks, Inc.
2019-08-20 15:14:32 +00:00
Stephen J. Kiernan
df845c0f86 usb_ethernet.h includes a number of mii headers, but only does so in
order to have struct mii_data available. However, it only really needs
a forward declaration of struct mii_data for use in pointer form for
the return type of a function prototype.

Custom kernel configuration that have usb and fdt enabled, but no miibus,
end up with compilation failures because miibus_if.h will not get
generated.

Due to the above, the following changes have been made to usb_ethernet.h:
 * remove the inclusion of mii headers
 * forward-declare struct mii_data
 * include net/ifq.h to satify the need for complete struct ifqueue

Reviewed by:	ian
Obtained from:	Juniper Networks, Inc.
Differential Revision:	https://reviews.freebsd.org/D21293
2019-08-20 01:06:43 +00:00
Jung-uk Kim
8a3238521b Partially revert the previous commit.
It was an experiment and not meant to be committed. :-(
2019-08-19 21:45:25 +00:00
Jung-uk Kim
ff0107de44 Fix sound on headset jack for Lenovo Thinkpad X1 Carbon Gen 6 (model 20KH).
Note this commit was inspired by r350433.

MFC after:	2 weeks
2019-08-19 21:30:12 +00:00