Commit graph

39459 commits

Author SHA1 Message Date
Warner Losh
67873a4fca nvd: For AHCI attached devices, report ahci bridge
When an NVME device is attached via a AHCI controller, we have no access
to its config space. So instead of information about the nvme drive
itself, return info about the AHCI controller as the next best
thing. Since the Intel Hardware RAID support looks at these values, this
likely is best.

Sponsored by:		Netflix
Reviewed by:		mav
Differential Revision:	https://reviews.freebsd.org/D33286

(cherry picked from commit b8194f3766)
2022-01-21 13:49:57 -05:00
Alexander Motin
fb56e14ce6 nvme: Do not rearm timeout for commands without one.
Admin queues almost always have several ASYNC_EVENT_REQUEST outstanding.
They have no timeouts, but their presence in qpair->outstanding_tr caused
useless timeout callout rearming twice a second.

While there, relax timeout callout period from 0.5s to 0.5-1s to improve
aggregation.  Command timeouts are measured in seconds, so we don't need
to be precise here.

Reviewed by:	imp
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D33781

(cherry picked from commit b3c9b6060f)
2022-01-20 21:07:31 -05:00
Warner Losh
f102ae7159 nvme_sim: Only report PCI related stats when we can
For AHCI attached devices, we report the location and identification
information of the AHCI controller that we're attached to. We also
don't reprot link speed in that case, since we can't get to the PCIe
config space registers to find that out.

Sponsored by:		Netflix
Reviewed by:		mav
Differential Revision:	https://reviews.freebsd.org/D33287

(cherry picked from commit 8f07932272)
2022-01-20 21:07:31 -05:00
Warner Losh
cc20d75705 nvme_ahci: Mark AHCI devices as such in the controller
Add a quirk to flag AHCI attachment to the controller. This is for any
of the strategies for attaching nvme devices as children of the AHCI
device for Intel's RAID devices. This also has a side effect of cleaning
up resource allocation from failed nvme_attach calls now.

Sponsored by:		Netflix
Reviewed by:		mav
Differential Revision:	https://reviews.freebsd.org/D33285

(cherry picked from commit 7cf8d63c88)
2022-01-20 21:07:31 -05:00
Warner Losh
2b2925d1e8 nvme: Move to a quirk for the Intel alignment data
Prior to NVMe 1.3, Intel produced a series of drives that had
performance alignment data in the vendor specific space since no
standard had been defined. Move testing the versions to a quick so the
NVMe NS code doesn't know about PCI device info.

Sponsored by:		Netflix
Reviewed by:		mav
Differential Revision:	https://reviews.freebsd.org/D33284

(cherry picked from commit 053f8ed6eb)
2022-01-20 21:07:31 -05:00
Warner Losh
f022d47f2f nvme: Reduce traffic to the doorbell register
Reduce traffic to doorbell register when processing multiple completion
events at once. Only write it at the end of the loop after we've
processed everything (assuming we found at least one completion,
even if that completion wasn't valid).

Sponsored by:		Netflix
Reviewed by:		mav
Differential Revision:	https://reviews.freebsd.org/D32470

(cherry picked from commit 2ec165e3f0)
2022-01-20 21:07:31 -05:00
Warner Losh
13b711e8c8 nvme: Restore hotplug warning
Restore hotplug warning in recovery state machine. No functional change
other than what message gets printed.

Sponsored by:		Netflix

(cherry picked from commit 18dc12bfd2)
2022-01-20 21:07:31 -05:00
Warner Losh
86721e606c nvme: Use adaptive spinning when polling for completion or state change
We only use nvme_completion_poll in the initialization path. The
commands they queue and wait for finish quickly as they involve no I/O
to the drive's media. These command take about 20-200 microsecnds
each. Set the wait time to 1us and then increase it by 1.5 each
successive iteration (max 1ms). This reduces initialization time by
80ms in cpervica's tests.

Use this same technique waiting for RDY state transitions. This saves
another 20ms. In total we're down from ~330ms to ~2ms.

Tested by:		cperciva
Sponsored by:		Netflix
Reviewed by:		mav
Differential Review:	https://reviews.freebsd.org/D32259

(cherry picked from commit 83581511d9)
2022-01-20 21:07:31 -05:00
Warner Losh
50b3d57e71 nvme: Only reset once on attach.
The FreeBSD nvme driver has reset the nvme controller twice on attach to
address a theoretical issue assuring the hardware is in a known
state. However, exierence has shown the second reset is unnecessary and
increases the time to boot. Eliminate the second reset. Should there be
a situation when you need a second reset (for buggy or at least somewhat
out of the mainstream hardware), the hardware option NVME_2X_RESET will
restore the old behavior. Document this in nvme(4).

If there's any trouble at all with this, I'll add a sysctl tunable to
control it.

Sponsored by:		Netflix
Reviewed by:		cperciva, mav
Differential Revision:	https://reviews.freebsd.org/D32241

(cherry picked from commit 4b3da659bf)
2022-01-20 21:07:31 -05:00
Warner Losh
932df0a258 nvme: Remove pause while resetting
After some study of the code and the standard, I think we can just drop
the pause(), unconditionally.  If we're not initialized, then there's
nothing to wait for from a software perspective.  If we are initialized,
then there might be outstanding I/O. If so, then the qpair 'recovery
state' will transition to WAITING in nvme_ctrlr_disable_qpairs, which
will ignore any interrupts for items that complete before we complete
the reset by setting cc.en=0.

If we go on to fail the controller, we'll cancel the outstanding I/O
transactions.  If we reset the controller, the hardware throws away
pending transactions and we retry all the pending I/O transactions. Any
transactions that happend to complete before cc.en=0 will have the same
effect in the end (doing the same transaction twice is just inefficient,
it won't affect the state of the device any differently than having done
it once).

The standard imposes no wait times here, so it isn't needed from that
perspective.

Unanswered Question: Do we may need to disable interrupts while we
disable in legacy mode since those are level-sensitive.

Sponsored by:		Netflix
Reviewed by:		mav
Differential Revision:	https://reviews.freebsd.org/D32248

(cherry picked from commit e5e26e4a24)
2022-01-20 21:07:30 -05:00
Warner Losh
0c3d88b9ab nvme: Explain a workaround a little better
The don't touch the mmio of the drive after we do a EN 1->0 transition
is only for a tiny number of dirves that have this unforunate issue.

Sponsored by:		Netflix

(cherry picked from commit 77054a897f)
2022-01-20 21:07:30 -05:00
Warner Losh
02325a44b5 nvme_ctrlr_enable: Small style nits
Rewrite the nested if's using the preferred FreeBSD style for branches
of ifs that return. NFC. Minor tweaks to the comments to better fit new
code layout.

Sponsored by:		Netflix
Reviewed by:		mav, chuck (prior rev, but comments rolled in)
Differential Revision:	https://reviews.freebsd.org/D32245

(cherry picked from commit a245627a4e)
2022-01-20 21:07:30 -05:00
Warner Losh
21de49b06c nvme: Use MS_2_TICKS rather than rolling our own
Sponsored by:		Netflix
Reviewed by:		mav
Differential Revision:	https://reviews.freebsd.org/D32246

(cherry picked from commit 26259f6ab9)
2022-01-20 21:07:30 -05:00
Warner Losh
a8ce655445 nvme_ctrlr_enable: Remove unnecessary 5ms delays
Remove the 5ms delays after writing the administrative queue
registers. These delays are from the very earliest days of the driver
(they are in the first commit) and were most likely vestiges of the
Chatham NVMe prototype card that was used to create this driver. Many of
the workarounds necessary for it aren't necessary for standards
compliant cards. The original driver had other areas marked for Chatham,
but these were not. They are unneeded. There's three lines of supporting
evidence.

First, the NVMe standards make no mention of a delay time after these
registers are written. Second, the Linux driver doesn't have them, even
as an option. Third, all my nvme cards work w/o them.

To be safe, add a write barrier between setting up the admin queue and
enabling the controller.

Sponsored by:		Netflix
Reviewed by:		mav
Differential Revision:	https://reviews.freebsd.org/D32247

(cherry picked from commit d5fca1dc1d)
2022-01-20 21:07:30 -05:00
Warner Losh
1397c8ebb7 nvme: Sanity check completion id
Make sure the completion ID is in the range of [0..num_trackers) since
the values past the end of the act_tr array are never going to be valid
trackers and will lead to pain and suffering if we try to dereference
them to get the tracker or to set the tracker back to NULL as we
complete the I/O.

Sponsored by:		Netflix
Reviewed by:		mav, chs, chuck
Differential Revision:	https://reviews.freebsd.org/D32088

(cherry picked from commit 36a87d0c6f)
2022-01-20 21:07:30 -05:00
Warner Losh
86990decd7 nvme: count number of ignored interrupts
Count the number of times we're asked to process completions, but that
we ignore because the state of the qpair isn't in RECOVERY_NONE.

Sponsored by:		Netflix
Reviewed by:		mav, chuck
Differential Revision:	https://reviews.freebsd.org/D32212

(cherry picked from commit 587aa25525)
2022-01-20 21:07:30 -05:00
Warner Losh
7144882ae1 nvme: Add sanity check for phase on startup.
The proper phase for the qpiar right after reset in the first interrupt
is 1. For it, make sure that we're not still in phase 0. This is an
illegal state to be processing interrupts and indicates that we've
failed to properly protect against a race between initializing our state
and processing interrupts. Modify stat resetting code so it resets the
number of interrpts to 1 instead of 0 so we don't trigger a false
positive panic.

Sponsored by:		Netflix
Reviewed by:		cperciva, mav (prior version)
Differential Revision:	https://reviews.freebsd.org/D32211

(cherry picked from commit 7d5eebe0f4)
2022-01-20 21:07:30 -05:00
Warner Losh
e8f693131c nvme: start qpair in state RECOVERY_WAITING
An interrupt happens on the admin queue right away after the reset, so
as soon as we enable interrupts, we'll get a call to our interrupt
handler. It is safe to ignore this interrupt if we're not yet
initialized, or	to process it if we are. If we are initialized,	we'll
see there's no completion records and return. If we're not, we'll
process	no completion records and return. Either way, nothing is
processed and nothing is lost.

Until we've completely setup the qpair, we need to avoid processing
completion records. Start the qpair in the waiting recovery state so we
return immediately when we try to process completions. The code already
sets it to 'NONE' when we're initialization is complete. It's safe to
defer completion processing here because we don't send any commands
before the initialization of the software state of the qpair is
complete. And even if we were to somehow send a command prior to that
completing, the completion record for that command would be processed
when we send commands to the admin qpair after we've setup the software
state. There's no good central point to add an assert for this last
condition.

This fixes an KASSERT "received completion for unknown cmd" panic on
boot.

Fixes:			502dc84a8b
Sponsored by:		Netflix
Reviewed by:		mav, cperciva, gallatin
Differential Revision:	https://reviews.freebsd.org/D32210

(cherry picked from commit fa81f3731d)
2022-01-20 21:07:30 -05:00
Warner Losh
9bbd0a7ca9 nvme: Use shared timeout rather than timeout per transaction
Keep track of the approximate time commands are 'due' and the next
deadline for a command. twice a second, wake up to see if any commands
have entered timeout. If so, quiessce and then enter a recovery mode
half the timeout further in the future to allow the ISR to
complete. Once we exit recovery mode, we go back to operations as
normal.

Sponsored by:		Netflix
Differential Revision:	https://reviews.freebsd.org/D28583

(cherry picked from commit 502dc84a8b)
2022-01-20 21:07:30 -05:00
Warner Losh
24d2d1813e nvme/nda: Fail all nvme I/Os after controller fails
Once the controller has failed, fail all I/O w/o sending it to the
device. The reset of the nvme driver won't schedule any I/O to the
failed device, and the controller is in an indeterminate state and can't
accept I/O. Fail both at the top end of the sim and the bottom
end. Don't bother queueing up the I/O for failure in a different task.

Reviewed by:		chuck
Sponsored by:		Netflix
Differential Revision:	https://reviews.freebsd.org/D31341

(cherry picked from commit 4b977e6dda)
2022-01-20 21:07:30 -05:00
Colin Percival
eb4d2eab07 Add some nvme initialization routines to TSLOG
About 335 ms of EC2 instance boot time is being spent here.

(cherry picked from commit bad42df9bf)
2022-01-20 21:07:30 -05:00
Michal Meloun
d6529c0d12 pci_dw_mv: Don't enable unhandled interrupts.
Mainly link errors interrupts should only be activated on fully linked port,
otherwise noise on lanes can cause livelock. But we don't have error
counters yet, so leave these interrupts disabled.

(cherry picked from commit ce5a4083de)
2022-01-20 11:35:51 +01:00
Michal Meloun
139afdb172 simple_mfd: switch to controllable locking for syscon provider.
MFC after	3 weeks

(cherry picked from commit f97f57b518)
2022-01-20 11:34:28 +01:00
Michal Meloun
f277be277d extres/clk: Add a method to detect the HW state of the clock gate.
- add method to read gate enable/disable staust from HW
- show gate status in sysctl clock dump

MFC after:	1 week

(cherry picked from commit 1a74d77f85)
2022-01-20 11:14:22 +01:00
Michal Meloun
3d4b9e5fa1 extres/clk: Improve sysctl dump of clocks.
Always recalculate the frequency, the cache is lazily initialized so it is not always up to date.
While I'm in mark sysctl as MPSAFE.

Discussed with:	manu, adrian
MFC after:	1 week

(cherry picked from commit 72a2f3b5e2)
2022-01-20 11:14:04 +01:00
Michal Meloun
a5e76683b2 dwmmc: Calculate the maximum transaction length correctly.
We should reserve two descriptors (not MMC_SECTORS) for potentially
unaligned (so bounced) buffer fragments, one for the starting fragment
and one for the ending fragment.

Submitted by:	kjopek@gmail.com
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D30387

(cherry picked from commit dfb7360222)
2022-01-20 11:11:17 +01:00
Michal Meloun
57dd17dd60 Fix error value returned by ofw_bus_gen_get_node().
By definition ofw_bus_get_node() should  consistently return -1 when there
is no associated OF node.

MFC after:	4 weeks
Discussed with:	nwhitehorn
Analyzed in: 	https://reviews.freebsd.org/D30761

(cherry picked from commit 3eae4e106a)
2022-01-20 11:00:55 +01:00
Stefan Eßer
dc4114875e Make CPU_SET macros compliant with other implementations
(cherry picked from commit e2650af157)
2022-01-14 18:17:30 +02:00
Greg V
ae4067ce94 efifb,vbefb: implement vd_fini
This removes the pmap entry when switching away to e.g. drm fb.

Differential Revision:	https://reviews.freebsd.org/D29020
MFC After:	1 month

(cherry picked from commit 8ebda6e44b)
2022-01-14 16:55:23 +01:00
Mark Johnston
4905ce27b8 mvneta: Unconditionally print an error message if mii_attach() fails
The error message is useful for diagnosing mvneta_attach() failures.

(cherry picked from commit ed166a0173)
2022-01-11 09:28:33 -05:00
Alexander Motin
4ee9fbcd85 acpi_support: Remove CTLFLAG_NEEDGIANT from sysctls.
MFC after:	2 weeks

(cherry picked from commit 6237a1cc2d)
2022-01-09 19:30:14 -05:00
Alexander Motin
1b1f80ae1c sound: Remove CTLFLAG_NEEDGIANT from some sysctls.
While there, remove some dead code.

MFC after:	2 weeks

(cherry picked from commit 3b4c543322)
2022-01-09 19:29:59 -05:00
Alexander Motin
f39bf9a217 acpica: Remove CTLFLAG_NEEDGIANT from most sysctls.
MFC after:	2 weeks

(cherry picked from commit 3e68d2c52b)
2022-01-09 19:29:55 -05:00
Alexander Motin
6bc8606fca pccbb: Remove Giant mention in comments.
MFC after:	2 weeks

(cherry picked from commit 22405bb2e4)
2022-01-08 20:24:13 -05:00
Alexander Motin
2a36679b74 amdtemp: Remove CTLFLAG_NEEDGIANT from sysctls.
It seems to be needed only to serialize very old K8 registers access.
Introduce separate lock for that and remove Giant dependency.

MFC after:	2 weeks

(cherry picked from commit 6c101ed7a3)
2022-01-08 20:24:07 -05:00
Alexander Motin
cd9fe8d81d uart: Remove CTLFLAG_NEEDGIANT from sysctl.
MFC after:	2 weeks

(cherry picked from commit c214c2c004)
2022-01-08 20:24:01 -05:00
Alexander Motin
7518562484 hwpmc: Remove CTLFLAG_NEEDGIANT from sysctl.
MFC after:	2 weeks

(cherry picked from commit 1886cef69b)
2022-01-08 20:23:58 -05:00
Hans Petter Selasky
457750da86 snd_uaudio(4): Loosen up the USB MIDI permissions.
This makes USB MIDI more userfriendly for desktop users.

PR:		260489
Sponsored by:	NVIDIA Networking

(cherry picked from commit 2fcd7d380b)
2022-01-07 14:23:26 +01:00
Scott Long
ea4e9becc7 Fix "set but not used" warnings in the mpr driver. This fixes a minor
bug in error handling.

(cherry picked from commit 61f17c5fd6)
2022-01-06 14:08:50 -05:00
Warner Losh
59e2f48e03 mpr: Minor formatting changes to match mps.
Minor reformatting nits to make mprsas_scsiio_timeout match
mpssas_scsiio_timeout more closely. The differences aren't necessary and
are distracting when comparing the routines. No functional changes.

Sponsored by:		Netflix

(cherry picked from commit 2bbaed4d7f)
2022-01-06 14:08:24 -05:00
Warner Losh
726d8e1852 mps(4): Fix unmatched devq release.
Port 9781c28c6d and a8837c77ef to the mps driver.  Before this
change devq was frozen only if some command was sent to the target after
reset started, but release was called always.  This change freezes the
devq immediately, leaving mprsas_action_scsiio() check only to cover
race condition due to different lock devq use.

This should also avoid unnecessary requeue of the commands, creating
additional log noise and confusing some broken apps. It also avoids a
'busy' requeue of I/Os failing when we're doing recovery that takes
longer than the normal busy timeout. These I/Os failing can lead to
filesystems being unmounted in the force unmount case for I/O errors.

Sponsored by:		Netflix
Reviewed by:		mav
Differential Revision:	https://reviews.freebsd.org/D33228

(cherry picked from commit a10253cffe)
2022-01-06 14:03:38 -05:00
Scott Long
0565198d80 Fix "set but not used" warnings in the mps driver.
(cherry picked from commit bcce9c5bed)
2022-01-06 14:01:59 -05:00
Warner Losh
f9c51d3a1d mps: Fix debugging line
Print cm instead of sc here, as is done in mpr. We can get the sc from
cm, but not vice versa.

Sponsored by:		Netflix

(cherry picked from commit b086bc0bf1)
2022-01-06 14:01:19 -05:00
Andrew Turner
bc98adaf6a Check cpu_softc is not NULL before dereferencing
In the acpi_cpu_postattach SYSINIT function cpu_softc may be NULL, e.g.
on arm64 when booting from FDT. Check it is not NULL at the start of
the function so we don't try to dereference a NULL pointer.

Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 4e50efb194)
2022-01-04 13:08:58 -05:00
Alexander Motin
6b06f8a792 amdtemp: Revert related part of "Make CPU children" commit.
While it still looks like previous code worked by coincidence, this
change broke things even more instead of fixing.

Reported by:	avg@
MFC after:	1 week

(cherry picked from commit 94a72c5ac4)
2022-01-04 12:21:49 -05:00
Alexander Motin
a77188ffd3 acpi_cpu: Fix panic if some CPU devices are disabled.
While there, remove couple unneeded global variables.

(cherry picked from commit 695323ae88)
2022-01-04 12:21:46 -05:00
Alexander Motin
b7668d009e Make CPU children explicitly share parent unit numbers.
Before this device unit number match was coincidental and broke if I
disabled some CPU device(s).  Aside of cosmetics, for some drivers
(may be considered broken) it caused talking to wrong CPUs.

(cherry picked from commit d3a8f98acb)
2022-01-04 12:21:42 -05:00
Alexander Motin
083a2ff0f0 acpi_cpu: Make device unit numbers match OS CPU IDs.
There are already APIC ID, ACPI ID and OS ID for each CPU.  In perfect
world all of those may match, but at least for SuperMicro server boards
none of them do.  Plus none of them match the CPU devices listing order
by ACPI.  Previous code used the ACPI device listing order to number
cpuX devices.  It looked nice from NewBus perspective, but introduced
4th different set of IDs. Extremely confusing one, since in some places
the device unit numbers were treated as OS CPU IDs (coretemp), but not
in others (sysctl dev.cpu.X.%location).

(cherry picked from commit c8077ccd70)
2022-01-04 12:21:35 -05:00
Alexander Motin
2572b6bd6b xen/blkfront: Remove CTLFLAG_NEEDGIANT from sysctl.
It only converts bit field into string.  It does not need locking.

MFC after:	1 week

(cherry picked from commit 54daceab55)
2022-01-02 16:39:28 -05:00
Bjoern A. Zeeb
a34668185b modules: increase MAXMODNAME and provide backward compat
With various firmware files used by graphics and wireless drivers
we are exceeding the current 32 character module name (file path
in kldxref) length.
In order to overcome this issue bump it to the maximum path length
for the next version.
To be able to MFC provide backward compat support for another version
of the struct as the offsets for the second half change due to the
array size increase.

MAXMODNAME being defined to MAXPATHLEN needs param.h to be
included first.  With only 7 modules (or LinuxKPI module.h) not
doing that adjust them rather than including param.h in module.h [1].

Reported by:	Greg V (greg unrelenting.technology)
Sponsored by:	The FreeBSD Foundation
Suggested by:	imp [1]
Reviewed by:	imp (and others to different level)
Differential Revision:	https://reviews.freebsd.org/D32383

(cherry picked from commit df38ada293)
2021-12-30 18:26:18 +00:00