Commit graph

138999 commits

Author SHA1 Message Date
Vladimir Kondratyev
bc3e9499ca LinuxKPI: Implement dev_driver_string()
Required by drm-kmod 5.7

MFC after:	1 week
Reviewed by:	bz, hselasky, manu
Differential Revision:	https://reviews.freebsd.org/D33290

(cherry picked from commit bc923d93df)
2022-01-22 22:34:36 +03:00
Vladimir Kondratyev
b3407b54d3 LinuxKPI: Implement clflush_cache_range()
Required by drm-kmod 5.7

MFC after:	1 week
Reviewed by:	hselasky, manu
Differential Revision:	https://reviews.freebsd.org/D33289

(cherry picked from commit db562aeff7)
2022-01-22 22:34:36 +03:00
Vladimir Kondratyev
e2cc6a467f LinuxKPI: Add clflush argument type conversion wrapper
to reduce amount of source patching in drm-kmod.

MFC after:	1 week
Reviewed by:	manu
Differential Revision:	https://reviews.freebsd.org/D33288

(cherry picked from commit 9a79e08ae7)
2022-01-22 22:34:35 +03:00
Vladimir Kondratyev
10cb54117e LinuxKPI: Implement interval_tree
Required by drm-kmod

MFC after:	1 week
Reviewed by:	hselasky, manu
Differential Revision: https://reviews.freebsd.org/D32869

(cherry picked from commit dbc920bd9a)
2022-01-22 22:34:35 +03:00
Vladimir Kondratyev
c8ddc214cf LinuxKPI: Import some linux/rbtree.h functions from OpenBSD
Required by drm-kmod

Obtained from:	OpenBSD
MFC after:	1 week

(cherry picked from commit dd52763387)
2022-01-22 22:34:35 +03:00
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
Gleb Smirnoff
f7735c3952 carp: fix send error demotion recovery
The problem is that carp(4) would clear the error counter on first
successful send, and stop counting successes after that.  Fix this
logic and document it in human language.

PR:			260499
Differential revision:	https://reviews.freebsd.org/D33536

(cherry picked from commit 9a8cf950b2)
2022-01-21 10:41:46 -08:00
Andriy Gapon
89ac48cf3b adaspindown: check disk power mode before sending IDLE command
If a disk is already in STANDBY mode, then setting IDLE mode can
actually spin it up.

(cherry picked from commit 15910dc0bc)
2022-01-21 09:01:09 +02: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
Alexander Motin
d0cb410baa Fix build. Sorry.
MFC after:	2 weeks

(cherry picked from commit 135c269d87)
2022-01-20 20:59:34 -05:00
Alexander Motin
9a45d88946 CTL: Relax callouts precisions.
MFC after:	2 weeks

(cherry picked from commit f4d499fd67)
2022-01-20 20:59:34 -05:00
Alexander Motin
d1bc234901 cam: Relax callouts precisions.
On large systems even relatively rare callouts may fire many times
per second.  This should allow them to aggregate better, since we do
not require any precision when polling for media change, etc.

MFC after:	2 weeks

(cherry picked from commit 0e5c50bf60)
2022-01-20 20:59:34 -05:00
Kenneth D. Merry
2077f85a63 Free UMA zones when a pass(4) instance goes away.
If the UMA zones are not freed, we get warnings about re-using the
sysctl variables associated with the UMA zones, and we're leaking
the other memory associated with the zone structures.  e.g.:

sysctl_warn_reuse: can't re-use a leaf (vm.uma.pass44.size)!
sysctl_warn_reuse: can't re-use a leaf (vm.uma.pass44.flags)!
sysctl_warn_reuse: can't re-use a leaf (vm.uma.pass44.bucket_size)!
sysctl_warn_reuse: can't re-use a leaf (vm.uma.pass44.bucket_size_max)!
sysctl_warn_reuse: can't re-use a leaf (vm.uma.pass44.keg.name)!
sysctl_warn_reuse: can't re-use a leaf (vm.uma.pass44.keg.rsize)!
sysctl_warn_reuse: can't re-use a leaf (vm.uma.pass44.keg.ppera)!
sysctl_warn_reuse: can't re-use a leaf (vm.uma.pass44.keg.ipers)!

Also, correctly clear the PASS_FLAG_ZONE_INPROG flag in
passcreatezone().  The way it was previously done, it would have
had set the flag and cleared all other flags that were set at
that point.

Sponsored by:	Spectra Logic

(cherry picked from commit ca2a7262df)
2022-01-20 14:55:04 -05:00
Bjoern A. Zeeb
0ff24a520a net80211: ieee80211_dump_node() cosmetics
Printing %p does not need the 0x prefix and while here mark the
ieee80211_node_table argument unused given we do not need it in the
current incarnation of the function.

Sponsored by:	The FreeBSD Foundation

(cherry picked from commit c3db9d4a14)
2022-01-20 14:06:15 +00:00
Bjoern A. Zeeb
bb53dafe14 LinuxKPI: 802.11 correct enum ieee80211_channel_flags
enum ieee80211_channel_flags are used as bit fields and not as 1..n.
Correct the values using BIT(n).

This is also hoped to fix problems with 7260 cards which come up and
panic due to an empty channel list as all channels are set disabled [1][2].
It will hopefully also fix the one or other oddity.

Reported by:	ambrisko, Mike Tancsa (mike sentex.net) [1]
Confirmed to fix by: ambrisko, Mike Tancsa (mike sentex.net) [2]
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit d7ce88aafc)
2022-01-20 14:05:37 +00:00
Bjoern A. Zeeb
f27c46a850 LinuxKPI: 802.11 Refine/add DTIM/TSF handling
Correct data types related to delivery traffic indication map (DTIM)/
timing synchronization function (TSF) and implement/refine their
handling.  This information is used/needed by iwlwifi to set a station
as associated.  This will hopefully avoid more "no beacon heard"
time event failures.

The recording of the Linux specific sync_device_ts is done in the
receive path for now in case we do have the right information
available.  I need to investigate as to how-much it may make sense
to also migrate it into net80211 in the future depending on the
usage in other drivers (or how we did handle this in the past in
natively ported versions, e.g. iwm).

Sponsored by:	The FreeBSD Foundation

(cherry picked from commit c8dafefaee)
2022-01-20 14:05:26 +00:00
Bjoern A. Zeeb
ccda5ec945 LinuxKPI: 802.11 handle connection loss differently
Rather than just bouncing back to SCAN bounce to INIT on connection
loss.  This is should be refined in the future as the comment already
indicates but we need to tie two different worlds together.

Sponsored by:	The FreeBSD Foundation

(cherry picked from commit f3229b62a1)
2022-01-20 14:05:17 +00: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
40a0633862 mvebu_gpio: Fix settings of gpio pin direction.
Data Output Enable Control register is inverted – 0 means output direction.
Reflect this fact in code.

MFC after:	3 weeks

(cherry picked from commit 01c6d79189)
2022-01-20 11:22:30 +01:00
Michal Meloun
9ddb35ef1f mvebu_gpio: Multiple fixes.
- gpio register access primitives
- locking in interrupt path
- cleanup

In cooperation with: mw
Reviewed by:	mw (initial version)
MFC after:	3 weeks
Differential Revision:	https://reviews.freebsd.org/D29044
Differential Revision:	https://reviews.freebsd.org/D28911

(cherry picked from commit a5dce53b75)
2022-01-20 11:22:04 +01:00
Marcin Wojtas
8c12f9dea1 mvebu_gpio: fix interrupt cause register configuration
According to Armada 8k documentation, the interrupt cause register
(at offset 0x14) is RW0C. Update the configuration in attach and
the mvebu_gpio_isrc_eoi() to follow the description.

Reviewed by: mmel
Obtained from: Semihalf
Sponsored by: Marvell
Differential Revision: https://reviews.freebsd.org/D29013

(cherry picked from commit 819760b35f)
2022-01-20 11:21:42 +01:00
Michal Meloun
f84b424eaf tegra/ahci: do not advertise enclosure management facility
It is not implemented in HW.

MFC after:	1 week

(cherry picked from commit 6e9119768d)
2022-01-20 11:15:47 +01:00
Michal Meloun
7a647bb045 tegra124: Implement new get_gate method for tegra124 clocks.
MFC after:	1 week

(cherry picked from commit be01656fa4)
2022-01-20 11:15:15 +01:00
Michal Meloun
6f63b227bd tegra210: Implement new get_gate method for tegra210 clocks.
MFC after:	1 week

(cherry picked from commit 7c0ec66385)
2022-01-20 11:14:53 +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
79631b49ee arm: Fix handling of undefined instruction aborts in THUMB2 mode.
Correctly recognize NEON/SIMD and VFP instructions in THUMB2 mode and pass
these to the appropriate handler. Note that it is not necessary to filter
all undefined instruction variant or register combinations, this is a job
for given handler.

Reported by:	Robert Clausecker <fuz@fuz.su>
PR:		259187
MFC after:	2 weks

(cherry picked from commit a670e1c13a)
2022-01-20 11:12:36 +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
8e3cc69a4e booti: Enable loading the kernel image to any address aligned to 2 MB
We've supported this for a long time, plus most u-boot setups quietly expect

MFC after:	2 weeks

(cherry picked from commit b07a6bd15a)
2022-01-20 11:10:21 +01:00
Michal Meloun
2ace1585b0 intrng: remove now redundant shadow variable.
Should not be a functional change.

Submitted by: 	ehem_freebsd@m5p.com
Discussed in:	https://reviews.freebsd.org/D29310
MFC after:	4 weeks

(cherry picked from commit e88c3b1b02)
2022-01-20 11:08:45 +01:00