On several systems we've noticed that when NTB link goes down, the
Physical Layer User Test Pattern registers we use as additional
scratchpad registers (that is explicitly allowed by the chip specs)
become read-only for about 100us. I see no explanation for this in
the chip specs, neither why it was not seen before, may be a race.
Since we do need these registers, workaround it by repeating writes
until we succeed or 1ms timeout expire.
MFC after: 1 week
(cherry picked from commit 3883c6fbf232452098ba6ea802ef1426d83d2d68)
These functions may map more memory for DMA than is actually used, since
the allocator operates on multiples of a 4KB page size. Thus,
bus_dmamap_sync() can trigger KMSAN reports when the unused portion of
a page is not zero-ed.
Reported by: KMSAN
Reviewed by: kib
MFC after: 2 weeks
Sponsored by: Klara, Inc.
Sponsored by: Juniper Networks, Inc.
Differential Revision: https://reviews.freebsd.org/D43133
(cherry picked from commit 47a6fb9d5a2ebec12114a604053ffbd2929f0021)
Commit 6b6914c1e21b introduced a printf-like version of
device_set_desc(), so use it to simplify device description setting in
the audio stack.
Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks
Reviewed by: dev_submerge.ch, markj
Differential Revision: https://reviews.freebsd.org/D43467
(cherry picked from commit f7d3d0a4ded35ba15d63cdf9287b4a2d6f80da11)
device_set_usb_desc() first tries to fetch device information through
the iInterface descriptor, otherwise it falls back to usb_devinfo().
Since usb_devinfo() is both guaranteed to work, and is more verbose, get
rid of the initial iInterface attempt.
Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks
Reviewed by: imp, markj
Differential Revision: https://reviews.freebsd.org/D43383
(cherry picked from commit 45cd29412eadbb0e8c40590a94b10663addac17a)
Although the module is compiled "snd_uaudio.ko", follow the rest of the
sound modules' naming convention in the declaration as well.
Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks
Reviewed by: imp, emaste
Differential Revision: https://reviews.freebsd.org/D43396
(cherry picked from commit 06a4376346e55d1c7aefe7a48063dddc4d1da9b9)
PCM_KLDSTRING() prints the kernel module associated with a given audio
device only when that module is not compiled in. Get rid of
PCM_KLDSTRING() altogether and print the driver name (even for modules
that are compiled in) instead, as it implies the module as well.
While here, convert all status strings to the following dmesg-like
format:
[<port|mem> <irq>] on <driver>
Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks
Reviewed by: markj, imp
Differential Revision: https://reviews.freebsd.org/D43349
(cherry picked from commit 837cd192ebf2d0d4f5ded8883403ef11e6fa6438)
Unlike the other sound drivers, snd_uaudio(4) doesn't provide
information about the device's description and the driver it's attached
to. A side-effect of this is that applications such as mixer(8), that
fetch these strings through the OSS API's SNDCTL_CARDINFO ioctl will
show a USB audio device as:
pcm0:mixer: <USB Audio> at ? kld snd_uaudio
This patch replaces the generic "USB Audio" description with the
device's actual manufacturer and product strings, and the "at ?" string
with the driver it's attached to:
pcm0:mixer: <Focusrite Scarlett Solo USB> at uaudio0 kld snd_uaudio
Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks
Reviewed by: markj, emaste
Differential Revision: https://reviews.freebsd.org/D43347
(cherry picked from commit 18d87fe4fe3b310796e138855016678453140423)
ADAT connections transport 8, 4 or 2 audio channels depending on the
sample rate. Instead of splitting each physical ADAT port into 4
(potentially unmapped) stereo pcm devices, create just one pcm
device of variable channel width for every ADAT port.
Depending on the sample rate and channel width selected, the pcm
channels may be only partially mapped to ADAT channels and vice versa.
Added flexibility of the new channel mapping is also prerequisite to
introduce more pcm device layouts in follow-up commits.
Reviewed by: br
Differential Revision: https://reviews.freebsd.org/D43393
(cherry picked from commit d7fde2c9eccf90b2a889e92800f3bc07376e84f6)
a designated master clock to stay in sync. Add a sysctl setting
to control the preferred clock source for each HDSPe sound card.
Complement this by sysctl values to list available clock sources,
show the currently effective clock source and display the sync
status of all connections. Clock sources are named according to
RME user manuals.
Submitted by: Florian Walpen <dev@submerge.ch>
Differential Revision: https://reviews.freebsd.org/D43252
(cherry picked from commit b6052c10fb4ad70915e2f82ce606fd7715477eef)
bpfattach() is called in wg_clone_create(), but the bpfdetach() is
missing from wg_close_destroy(). Add the missing bpfdetach() to avoid
leaking both the associated bpf bits as well as the ifnet that bpf will
hold a reference to.
PR: 276526
(cherry picked from commit 43be2d7aaf25b719aec8f49aab110c0061f1edec)
These members are protected by the identity lock, so rlock it in
noise_remote_alloc() and then assert that we have it held to some extent
in noise_precompute_ss().
PR: 276392
(cherry picked from commit 7a4d1d1df0b2e369adcb32aea9ef8c180f885751)
In practice this is harmless; only keepalive packets may realistically have
p_mtu == 0, and they'll also have no payload so the math works out the same
either way. Still, let's prefer technical accuracy and calculate the amount
of padding needed rather than the padded length...
PR: 276363
(cherry picked from commit b891f61ef538a4e9b4658b4b756635c8036a5788)
For an unknown TX CQE error type (probably from a newer hardware),
still free the mbuf, update the queue tail, etc., otherwise the
accounting will be wrong.
Also, TX errors can be triggered by injecting corrupted packets, so
replace the mana_err to mana_dbg logging.
Reported by: NetApp
MFC after: 1 week
Sponsored by: Microsoft
(cherry picked from commit 516b5059705b6b8bbba28821dbe05964c128f9a9)
Use a while loop with cancel / drain to make sure that all tasks have
completed before proceeding to reset.
Suggested by: jhb
Sponsored by: Netflix
(cherry picked from commit 272a406042608da9bc3e67e41c6b7fc31d4166b8)
No sense having a variable for this. So use BUS_SPACE_MAXADDR and remove
dma_hiaddr from softc.
Suggested by: jhb
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D42808
(cherry picked from commit 1ec7c672bc2854a1efb1d50f189d4881163c16c6)
Replace the test for DataLength == 0 with an assert. It can't happen,
but an assert doesn't hurt. Emacs removed some trailing white space too.
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D42807
(cherry picked from commit 2361a0056fc16b5e11df2aa948aaa633ac01d685)
Use the simpler template code for the parent busdma tag for all I/O to
this card.
Reviewed by: mav, jhb, imp
Differential Revision: https://reviews.freebsd.org/D42607
(cherry picked from commit 489eee0d41dce317678adb0dae8d509a5f1d6d93)
These calls "should" all be synchrounous. There's no bouncing that's
needed for them (at least in the typical case that we have a sane card
that has more bits of dma addresses decoded than we have memory), so
there's no errors possible. Ensure these calls are really synchronous
with BUS_DMA_NOWAIT flags (which should never fail now that the
bus_dmamem_alloc() has succeeded).
Reviewed by: mav, jhb, imp
Differential Revision: https://reviews.freebsd.org/D42606
(cherry picked from commit 39a3e6a812ad9c089bd2c4935193f1b3c4c5c35a)
This usage is obsolete. Replace with maximum bus space size. maxphys
will sort itself out at higher levels.
Reviewed by: mav, jhb, imp
Differential Revision: https://reviews.freebsd.org/D42605
(cherry picked from commit 4e6d128bd823e5b5d0b058f918c7036978a0e8bf)
Publish the firmware version on the card like we do for mps/mpr.
Sponsored by: Netflix
Reviewed by: mav
Differential Revision: https://reviews.freebsd.org/D42588
(cherry picked from commit 28a274342ea0b0666b56704477d2d1c17564942e)
The number of signficant bits that are decoded are returned in the flags
field of the IOCFacts structure from the device. Rather than assume the
worst with a pessimal 32-bit maximum, look at this value and pass it
along to all the dma map creation requests.
A lof of those creations are repetitive and could just inherit from the
base tag if we moved to the templated interface. This is called out as
desireable future work not done at this time.
In addition, due to a chicken and an egg problem, we have to allocate
some of the maps with a 32-bit loaddr. These are the ones we need to
read iocfacts. And they are fine to be so restricted: they are little
used after startup, and when they are used, bouncing is fine.
Sponsored by: Netflix
Reviewed by: mav
Differential Revision: https://reviews.freebsd.org/D42559
(cherry picked from commit 91d961356d03465635c4784fab48acdd1304e1e0)
Move enqueueing of commands to bus_dmamap_load_ccb callback
Fix fundamental difference between FreeBSD and Linux. On Linux, your dma
load callback always happends before it returns, so drivers are written
to load the map, then submit to hardware. On FreeBSD, the callback may
be deferred and return EINPROGRESS. This means the callback is
responsible for queueing the request to the hardware is done after the
SGL list is created. Make a number of interrelated cahnages:
At the end of mpi3mr_prepare_sgls, add a call to mpi3mr_enqueue_request.
Split the hardware submission out from the end of mpi3mr_action_scsiio
and move it into a new routine mpi3mr_enqueue_request.
Move all error completion from the end of mpi3mr_action_scsiio to where
the error is detected. We cannot pass errors back from the
mpi3mr_enqueue_request to do this on a 'failed' mpi3mr in a centralized
place (since it has to be fire and forget).
Add comments about zero length SGLs never making it into
mpi3mr_prepare_sgls. Keep the code there for the moment, but we only set
cm->data to non-NULL when scsiio_req->DataLength is not zero. So the
datalength can't be zero and we can't send the zero SGLs.
Add commentts about other "impossible" tests in mpi3mr_prepare_sgls that
really should be simple asserts of some flavor.
Eliminate cm->error_code, since we can't pass data back from the
mpi3mr_prepare_sgl callback anymore.
In mpi3mr_map_request, call mpi3mr_enqueue_request for the no data case.
This seems to work even though we've not done the special zero length
handling that was in mpi3mr_prepare_sgls, giving further evidence to it
not actually being needed. This is needed for SCSI CDBs that have no
data to pass to the drive like TEST UNIT READY.
With this change, and the prior ones, we're now able to run with mpi3mr
on 128GB systems and very heavy disk load (so many buffers land > 4GB:
the driver instructs busdma to never use memory abouve 4GB, which may be
too conservative, but an issue for another time).
Sponsored by: Netflix
Reviewed by: sumit.saxena_broadcom.com, mav, jhb
Differential Revision: https://reviews.freebsd.org/D42543
(cherry picked from commit 3208a189c1e2c4ef35daa432fe45629a043d7047)
More uniformly use mpi3mr_set_ccbstatus in mpi3mr_action_scsiio. The
routine mostly used it, but also has setting of status by hand. In those
cases where we want to error out the request, use this routine.
As part of this, move setting CAM_SIM_QUEUED later in the function to
when we're sure it's been queued. Remove the places we clear it before
this.
Sponsored by: Netflix
Reviewed by: mav, jhb
Differential Revision: https://reviews.freebsd.org/D42542
(cherry picked from commit cf8c23230aabd30aa9251975dbe705da559a2d02)
Since we assume there's a timeout to cancel when this is true, only set
it true when we set the timeout. Otherwise we may try to cancel a timeout
when there's been an error in submission.
Sponsored by: Netflix
Reviewed by: mav
Differential Revision: https://reviews.freebsd.org/D42541
(cherry picked from commit 1cfd01111eb6a28ca5043e928aa8e9099064177a)
Fold two lines to make this more readable.
Sponsored by: Netflix
Reviewed by: mav, jhb
Differential Revision: https://reviews.freebsd.org/D42540
(cherry picked from commit e2b27df9eb324fa6e72e29d3185dcd6b390efa9d)
Reduce the scope of reset_mutext to protect the msleep in the watch dog
thread as well as the MPI3MR_FLAGS_SHUTDOWN bit. Use it to protect the
wakeup in mpi3mr_detach so this thread can exit sooner when we're trying
to do an orderly shutdown. Optimize the flow to check the sleep and
other conditions before going to sleep.
It's an open question if this should protect sc->unrecoverable, and if
we should wakeup the watchdog thread when we set it. We might also want
to move too booleans for the three flags that we have now in
mpi3mr_flags. There are a number of U8s that should really be bools and
we might want to also group them together to pack softc better.
Sponsored by: Netflix
Reviewed by: mav
Differential Revision: https://reviews.freebsd.org/D42539
(cherry picked from commit 7c4913093a759adf2e4c7d65535aee04aadee4df)
All of these fields are either unused, or just initialized. Remove
them. This saves about 1MB of memory for the cards that I have which can
do 8k transactions at once.
Sponsored by: Netflix
Reviewed by: mav, jhb
Differential Revision: https://reviews.freebsd.org/D42538
(cherry picked from commit a2b046620c54db977196128b3c53da2704b9fd20)
Holding fwevt_lock when we call taskqueue_drain can lead to deadlock
because it's draining a queue needs fwevt_lock to do work, so that other
thread will try to take out the lock and block, making the thread never
finish and taskqueue_drain never complete. There's a witness
warning/error for this which was exposed when the lock was converted to
a MTX_DEF lock from a MTX_SPIN prior to committing to the FreeBSD tree.
The lock appears to be to protect against additional items being added
to the event list while we're doing a reset. Since the taskqueue is
blocked, items can get added to the list, but won't be processed during
the reset, but there is still a (likely small) race between the
taskqueue_drain and the taskqueue_block calls where an interrupt could
fire on another CPU, resulting in a task being enqueued and started
before the block can take effect. The only way to fix that race is to
turn off interrupt processing during a reset. So we replace a deadlock
with a smaller race.
Sponsored by: Netflix
Reviewed by: sumit.saxena_broadcom.com, mav, jhb
Differential Revision: https://reviews.freebsd.org/D42537
(cherry picked from commit b411372b7d17ae7e5d6c944732d41b979bde2ac4)
Update 25xx firmware: version 8.8.207
Add 26xx firmware: version 8.8.231
Add 27xx firmware: version 9.12.0
Add 28xx firmware: version 9.12.1
Remove BUGS section from manpage as we now have firmware for
all supported controllers.
PR: 273263
MFC after: 1 month
Pull Request: https://github.com/freebsd/freebsd-src/pull/877
Sponsored by: Technical University of Munich
(cherry picked from commit b0c6b06836351b3908ba5b2a847c89c42d1a46c3)
Correctly identify the active firmware in flash on adapters with
primary and secondary firmware region in flash.
Correctly identify the active NVRAM on adapters with primary
and secondary NVRAM region in flash.
Loading ispfw(4) moved from isp_pci_attach() to isp_reset().
Drop the reference to ispfw(4) after using it so one can kldunload(8) it.
New isp_load_ram() function to load either ispfw(4) or flash firmware
into RISC's RAM.
New functions to read data from flash. The old ones will be removed later.
A bunch of new helper functions to identify and validate active flash
regions for firmware, auxiliary and NVRAM.
Overhaul ISP_FW_* macros and make use of it when comparing firmware
versions. We can handle firmware versions up to 255.255.255.
Firmware load priority slightly changed:
For 27xx and newer adapters:
- load ispfw(4) firmware
- request (active) flash firmware information
- compare version numbers of ispfw(4) and flash firmware
- load firmware with highest version into RISC's RAM
- if loading ispfw(4) is disabled or failed - load firmware from flash
- if everything else fails use MBOX_LOAD_FLASH_FIRMWARE as fallback
For 26xx and older adapters nothing changed:
- load ispfw(4) firmware and load it into RISC's RAM
- if loading ispfw(4) is disabled or failed use MBOX_EXEC_FIRMWARE
- for 26xx a preceding MBOX_LOAD_FLASH_FIRMWARE is used
New read only sysctl(8)'s:
dev.isp.N.fw_version_run: the firmware version actually running
dev.isp.N.fw_version_ispfw: the firmware version provided by ispfw(4)
dev.isp.N.fw_version_flash: the (active) firmware version in flash
While here:
- firmware attribute handling/parsing reworked
+ renamed defines from ISP2400_FW_ATTR_* to ISP_FW_ATTR_*
+ changed values to match new handling/parsing
+ added some more attributes
- enable FLT support on 26xx based adapters
- log level adjustments
- new function return status codes (some for now, some for later use)
- some minor style changes
Tested and approved to work on real hardware with:
- Qlogic ISP 2532 (QLogic QLE2560 8Gb FC Adapter)
- Qlogic ISP 2031 (QLogic QLE2662 16Gbit 2Port FC Adapter)
- Qlogic ISP 2722 (QLogic QLE2690 16Gb FC Adapter)
- Qlogic ISP 2812 (QLogic QLE2772 32Gbit 2Port FC Adapter)
PR: 273263
Reviewed by: mav
Pull Request: https://github.com/freebsd/freebsd-src/pull/877
MFC after: 1 month
Sponsored by: Technical University of Munich
(cherry picked from commit 10ed63fc06cb9902cc783ce8d0086c9aa97ed1e1)
Remove extra acpi_UserNotify() call per event. Filter duplicate
notifications received from ACPI without actual status change.
Without this on my Dell XPS 13 9310 I saw 4 devd events for either
open or close, now only one.
MFC after: 1 month
(cherry picked from commit 1a3ee6002f3e008e0bc29d04c976285434503e19)
While "fast" taskqueue may be more expensive due to spinlock use,
when used mainly for timeout tasks it allows to avoid extra context
switches to and from callout thread, that is even more expensive.
MFC after: 1 month
(cherry picked from commit 358453ce9bdd99eb69641b02f2d7e29cedecbe27)
taskqueue_enqueue_timeout(0) is equivalent to taskqueue_enqueue(),
so no need to create a separate periodic_task and event_task to run
exactly the same handler.
MFC after: 1 month
(cherry picked from commit a8f80c0c16c7fb38c46ddccd7e1b06dc46c407b1)
My previous commit by reducing precision reduced the sampling rate
from 60Hz to 40Hz on idle system. Return it back to 60-80Hz range,
that should be good for mouse smoothness on 60Hz displays.
MFC after: 1 months
(cherry picked from commit 68e457df0268113646264883515412af4c8808cb)
It should make pause interval less strict.
While there, add cpu_spinwait() into a tight spin wait loop to burn
less power and let other SMT thread work more.
MFC after: 1 month
(cherry picked from commit a74df3f96e3ea4cc632088be870d9b0b0198859c)
In sampling mode some devices return same data indefinitely even if
there is nothing to report. Previous idle hysteresis implementation
activated only when device returned no data, so some devices ended up
polled at fast rate all the time. This new implementation compares
each new report with the previous, and, if they are identical, after
reaching threshold also drop sampling rate to slow.
On my Dell XPS 13 9310 with iichid(4) touchscreen and touchpad this
reduces idle power consumption by ~0.5W by reducing number of context
switches in the driver from ~4000 to ~700 per second when not touched.
MFC after: 1 month
(cherry picked from commit 8c86b981240324c1daaa387d4d3f8e3e53db3d2e)
Before every wait for FIFO interrupt set how much data/space do we
want to see there. Previous code was not using it for receive, as
result aggregating interrupts only within processing latency. The
new code needs only one interrupt per transfer per FIFO length.
On my Dell XPS 13 9310 with iichid(4) touchscreen and touchpad this
reduces the interrupt rate per device down to 2 per sample or 16-20
per second when idle and 120-160 per second when actively touched.
MFC after: 1 month
(cherry picked from commit 13037eaabede7fb7fbc25f4e84b549c73f9acb3c)