Commit graph

39069 commits

Author SHA1 Message Date
Neel Chauhan
4f6eeb1cb1 vmd_bus: Fix typo in comment
Reviewed by:		imp
Differential Revision:	https://reviews.freebsd.org/D31210

(cherry picked from commit 76fffd0a86)
2021-09-12 18:44:12 -04:00
Neel Chauhan
75547acf1c vmd: Rename vmd_bus class to pci
This fixes a kernel panic when probing for vmd_bus on Intel TigerLake on
14-CURRENT. Apparently, vmd_bus is a type of PCI bus, but was registered
as a separate device class.

PR:			256915
Reviewed by:		imp
Differential Revision:	https://reviews.freebsd.org/D31071

(cherry picked from commit ad1f608fb2)
2021-09-12 18:44:12 -04:00
Warner Losh
4c2819607a rtsx: Fix wakeup race similar to sdhci one fixed in 35547df5c7
rtsx copied code from sdhci, and has the same wakeup race bug that was
fixed in 35547df5c7, so apply a similar fix here.

Sponsored by:		Netflix

(cherry picked from commit 9339e7c0bd)
2021-09-12 09:56:16 -06:00
Vladimir Kondratyev
139144a7ae wsp(4): Add evdev support.
Reviewed by:	hselasky
Tested by:	Greg V, Constantin Furst<constantin_AT_fuersten_DOT_info>
PR:		252236
Differential revision:	https://reviews.freebsd.org/D31653

(cherry picked from commit 8d73071c47)
2021-09-08 03:01:07 +03:00
Vladimir Kondratyev
d780fe9df0 wsp(4): Compact parameter structure.
(cherry picked from commit 250ab00407)
2021-09-08 03:00:47 +03:00
Vladimir Kondratyev
5a5bab49a0 atp(4), wsp(4): Return correct priority from probe() method;
(cherry picked from commit 9fa1201d60)
2021-09-08 03:00:27 +03:00
Vladimir Kondratyev
45fd5fe9e9 evdev: Add support for automatic MT protocol type A to type B conversion.
(cherry picked from commit d056693d7b)
2021-09-08 02:59:57 +03:00
Vladimir Kondratyev
4174302b4a evdev: Add implicit mode for touch tracking.
In implicit mode assignment of slot number and tracking id is performed
automatically on each synchronization requested by device driver.

This is done with creation of intermediate buffer for multitouch events.
This buffer holds untracked events until synchronization is requested by
device driver. It is needed as touch assigment requires
knowledges of all touch positions pushed in current and previous reports.

(cherry picked from commit f76051c7da)
2021-09-08 02:59:35 +03:00
Vladimir Kondratyev
b79de251fc evdev: Import support for touch-tracking.
Touch tracking is a process of assignment of unique trackingID to each
initiated contact on the surface.  Keeping the trackingIDs persistent
across multitouch reports requires solving of so called Euclidian
Bipartite Matching problem.

This commit imports EBM-solver implementation based on Dinitz-Kronrod
algorithm to find minimum cost matching between contacts listed in two
consecutive reports.

Obtained from:	OpenBSD

(cherry picked from commit 4c0a134e32)
2021-09-08 02:59:12 +03:00
Vladimir Kondratyev
f160aa0d3d evdev: Make MT tracking IDs monotonically increasing sequence.
(cherry picked from commit 66bd52f5e2)
2021-09-08 02:58:47 +03:00
Vladimir Kondratyev
759a5cd1ef evdev: Give short aliases to items of evdev_mt_slot array
with using of unioned anonymous structure.

Access to the same data by using different members of union generally
works despite it is not supported by C specs.

Also add helper function to report entire slot state.

(cherry picked from commit 059360287e)
2021-09-08 02:58:25 +03:00
Vladimir Kondratyev
de6d60ee1c evdev: Normalize width and pressure of single touch compat events
to match Synaptics touchpad reporting range.

(cherry picked from commit 127e54deb6)
2021-09-08 02:57:57 +03:00
Vladimir Kondratyev
de20578e6d evdev: force no fuzz for autogenerated single touch compat events.
As fuzz has already been applied on multitouch event processing.
This allows to remove existing workaround for double fuzz procesing.

(cherry picked from commit 314913ed7c)
2021-09-08 02:57:34 +03:00
Vladimir Kondratyev
f7d9821cdb evdev: Send first active rather than 0-th slot state as ST report
(cherry picked from commit fbe17f9017)
2021-09-08 02:57:11 +03:00
Vladimir Kondratyev
5bf6cf0fbb evdev: Use bitsets to track active touches and slots changed in current report
Obtained from:	OpenBSD

(cherry picked from commit 2dc7188e53)
2021-09-08 02:55:37 +03:00
Vladimir Kondratyev
a437dfa5ca evdev: Multitouch code style changes.
1. Move touch count reporting helpers to utils. They are not multitouch.
2. Use evdev_mt prefix for private multitouch support routines.
3. Use int instead of int32_t where fixed size is not required.
4. Export some internal functions.

This change should be no-op.

(cherry picked from commit 98a7606b85)
2021-09-08 02:55:12 +03:00
Zhenlei Huang
e8df60a69a routing: Allow using IPv6 next-hops for IPv4 routes (RFC 5549).
Implement kernel support for RFC 5549/8950.

* Relax control plane restrictions and allow specifying IPv6 gateways
 for IPv4 routes. This behavior is controlled by the
 net.route.rib_route_ipv6_nexthop sysctl (on by default).

* Always pass final destination in ro->ro_dst in ip_forward().

* Use ro->ro_dst to exract packet family inside if_output() routines.
 Consistently use RO_GET_FAMILY() macro to handle ro=NULL case.

* Pass extracted family to nd6_resolve() to get the LLE with proper encap.
 It leverages recent lltable changes committed in c541bd368f.

Presence of the functionality can be checked using ipv4_rfc5549_support feature(3).
Example usage:
  route add -net 192.0.0.0/24 -inet6 fe80::5054:ff:fe14:e319%vtnet0

Differential Revision: https://reviews.freebsd.org/D30398

(cherry picked from commit 62e1a437f3)
2021-09-07 21:25:06 +00:00
Mark Johnston
b036a48de6 md: Clamp to a multiple of the sector size when resizing
We do this when creating md(4) devices, in kern_mdattach_locked(), but
not when resizing the provider.  Apply the same policy when resizing, as
many GEOM classes do not expect to deal with providers for which
pp->mediasize % pp->sectorsize != 0.

Reported by:	syzkaller
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 47619b6044)
2021-09-07 09:36:19 -04:00
Thomas Skibo
01ecff28ad mx25l: Add support for Integrated Silicon Solution is25wp256
This is used for the on-board flash on the HiFive Unmatched board.

Reviewed by:	#riscv, jrtc27
MFC after:	1 week
Differential Revision: https://reviews.freebsd.org/D31562

(cherry picked from commit 416ac155bb)
2021-09-07 13:08:20 +01:00
Jessica Clarke
3b30406bff pci_dw: Drop unconditional explicit DEBUG define
This has been present since the first revision of the file. The debugf
macros have always been unused so it doesn't actually do anything
useful, and besides, debugging should not be unconditionally turned on
for a production driver. Moreover, this breaks the riscv LINT kernel
build as sys/conf/NOTES includes options DEBUG, resulting in a macro
redefinition error. This does not show up in the arm64 LINT kernel build
since that has an explicit nooptions DEBUG, which is dubious and should
be revisited. Rather than copy such a hack to riscv's NOTES, fix this
specific instance of DEBUG breaking.

Fixes:		896e217a0e ("fu740_pci_dw: Add SiFive FU740 PCIe controller driver")
MFC after:	1 week

(cherry picked from commit 22997b7550)
2021-09-07 13:08:15 +01:00
Jessica Clarke
0889033d28 pci_dw: Detect number of outbound regions automatically
Currently we use the num-viewports property to decide how many outbound
regions there are we can use, defaulting to 2. However, Linux has
stopped using that and so it no longer appears in new device trees, such
as for the SiFive FU740. Instead, it's possible to just probe the
hardware directly.

Reviewed by:	mmel
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D31030

(cherry picked from commit 4707bb0430)
2021-09-07 13:06:48 +01:00
Jessica Clarke
15a5871387 pci_dw: Support modern "unroll" iATU mode
This supersedes the old legacy mode where a viewport register was used
to mux multiple regions behind a single set of registers, and is used on
the SiFive FU740.

Reviewed by:	mmel
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D31029

(cherry picked from commit f240dfff22)
2021-09-07 13:06:48 +01:00
Jessica Clarke
982d709cdc pci_dw: Support multiple memory windows
Currently we assume there is only one memory and one prefetch memory
window, and ignore the latter. However, the SiFive FU740 has two normal
memory windows.

As part of this, the viewports are rearranged. Previously the viewports
were memory, config then optionally I/O. Both to simplify the config
index calculation and to ensure it can always be mapped even if we have
too many memory windows for the number of viewports, config is moved to
being the first viewport.

This generalisation now also naturally supports mapping prefetch memory
windows.

Reviewed by:	mmel
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D31028

(cherry picked from commit f8c1701f23)
2021-09-07 13:06:47 +01:00
Wojciech Macek
215db69fbc pci_dw: Trim ATU windows bigger than 4GB
The size of the ATU MEM/IO windows is implicitly casted to uint32_t.
Because of that some window sizes were silently demoted to 0 and ignored.
Check the size if its too large, trim it to 4GB and print a warning message.

Submitted by: Kornel Duleba <mindal@semihalf.com>
Reviewed by: mw
Obtained from: Semihalf
Sponsored by: Marvell
Differential revision: https://reviews.freebsd.org/D29625

(cherry picked from commit 243000b19f)
2021-09-07 13:06:47 +01:00
Marcin Wojtas
0e948ed6d6 pci_dw: fix outbound I/O window configuration
Use viewport "2" instead of "0" and change window type from MEM to IO.
Without these changes the MEM ATU window can be overwritten with the IO one.

Submitted by: Kornel Duleba <mindal@semihalf.com>
Obtained from: Semihalf
Sponsored by: Marvell
Differential revision: https://reviews.freebsd.org/D29516

(cherry picked from commit 57dbb3c259)
2021-09-07 13:06:47 +01:00
Jessica Clarke
2427c88574 cgem: Add support for the SiFive FU740
Note that currently Linux's device tree uses the FU540's compatible
string, as does upstream U-Boot, but the U-Boot shipped with the board
based on an older patch series has the correct FU740 name. Thankfully
they are the same, at least as far as software is concerned.

Whilst here, fix a style(9) nit.

Reviewed by:	philip, kp
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D31034

(cherry picked from commit 4c4a6884ad)
2021-09-07 13:06:45 +01:00
Gordon Bergling
6a93acc380 Fix a common typo in source code comments
- s/existant/existent/

(cherry picked from commit 631504fb34)
2021-09-07 09:24:05 +02:00
Alexander Motin
0e6969a0f4 nvme(4): Add MSI and single MSI-X support.
If we can't allocate more MSI-X vectors, accept using single shared.
If we can't allocate any MSI-X, try to allocate 2 MSI vectors, but
accept single shared.  If still no luck, fall back to shared INTx.

This provides maximal flexibility in some limited scenarios.  For
example, vmd(4) does not support INTx and can handle only limited
number of MSI/MSI-X vectors without sharing.

MFC after:	1 week

(cherry picked from commit e3bdf3da76)
2021-09-06 21:24:54 -04:00
Alexander Motin
d9cacf0b66 nvme(4): Do not panic on admin queue construct error.
MFC after:	1 week

(cherry picked from commit 31111372e6)
2021-09-06 21:24:53 -04:00
Alexander Motin
a996b55ab3 mpr(4): Fix unmatched devq release.
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.

MFC after:	2 weeks
Sponsored by:	iXsystems, Inc.

(cherry picked from commit 9781c28c6d)
2021-09-02 20:35:27 -04:00
Alexander Motin
0149aaeb8f mpr(4): Handle mprsas_alloc_tm() errors on device removal.
SAS9305-16e with firmware 16.00.01.00 report HighPriorityCredit of
only 8, while for comparison some other combinations I have report
100 or even 128.  In case of large JBOD detach requirement to send
target reset command to each target same time overflows the limit,
and without adequate handling makes devices stuck in half-detached
state, preventing later re-attach.

To handle that in case of allocation error mark the target with new
MPRSAS_TARGET_TOREMOVE flag, and retry the removal attempt next time
something else free high priority command.  With this patch I can
successfully detach/attach 102 disk JBOD from/to the SAS9305-16e.

MFC after:	2 weeks
Sponsored by:	iXsystems, Inc.

(cherry picked from commit e3c5965c25)
2021-09-02 20:35:27 -04:00
Warner Losh
a2784b47e4 mpr/mps: Minor state machine fix
When a DMA chain can't be loaded, set the state to STATE_INQUEUE so that
the mp[rs]_complete_command can properly fail the command.

Sponsored by:		Netflix

(cherry picked from commit 33755dbb20)
2021-09-02 20:34:22 -04:00
Kenneth D. Merry
8a6e5ade16 Fix mpr(4) and mps(4) state transitions and a use-after-free panic.
When the mpr(4) and mps(4) drivers probe a SATA device, they issue an
ATA Identify command (via mp{s,r}sas_get_sata_identify()) before the
target is fully setup in the driver.  The drivers wait for completion of
the identify command, and have a 5 second timeout.  If the timeout
fires, the command is marked with the SATA_ID_TIMEOUT flag so it can be
freed later.

That is where the use-after-free problem comes in.  Once the ATA
Identify times out, the driver sends a target reset, and then frees any
identify commands that have timed out.  But, once the target reset
completes, commands that were queued to the drive are returned to the
driver by the controller.

At that point, the driver (in mp{s,r}_intr_locked()) looks up the
command descriptor for that particular SMID, marks it CM_STATE_BUSY and
sends it on for completion handling.

The problem at this stage is that the command has already been freed,
and put on the free queue, so its state is CM_STATE_FREE.  If INVARIANTS
are turned on, we get a panic as soon as this command is allocated,
because its state is no longer CM_STATE_FREE, but rather CM_STATE_BUSY.

So, the solution is to not free ATA Identify commands that get stuck
until they actually return from the controller.  Hopefully this works
correctly on older firmware versions.  If not, it could result in
commands hanging around indefinitely.  But, the alternative is a
use-after-free panic or assertion (in the INVARIANTS case).

This also tightens up the state transitions between CM_STATE_FREE,
CM_STATE_BUSY and CM_STATE_INQUEUE, so that the state transitions happen
once, and we have assertions to make sure that commands are in the
correct state before transitioning to the next state.  Also, for each
state assertion, we print out the current state of the command if it is
incorrect.

mp{s,r}.c:      Add a new sysctl variable, dump_reqs_alltypes,
                that controls the behavior of the dump_reqs sysctl.
                If dump_reqs_alltypes is non-zero, it will dump
                all commands, not just the commands that are in the
                CM_STATE_INQUEUE state.  (You can see the commands
                that are in the queue by using mp{s,r}util debug
                dumpreqs.)

                Make sure that the INQUEUE -> BUSY state transition
                happens in one place, the mp{s,r}_complete_command
                routine.

mp{s,r}_sas.c:  Make sure we print the current command type in
                command state assertions.

mp{s,r}_sas_lsi.c:
                Add a new completion handler,
                mp{s,r}sas_ata_id_complete.  This completion
                handler will free data allocated for an ATA
                Identify command and free the command structure.

                In mp{s,r}_ata_id_timeout, do not set the command
                state to CM_STATE_BUSY.  The command is still in
                queue in the controller.  Since we were blocking
                waiting for this command to complete, there was
                no completion handler previously.  Set the
                completion handler, so that whenever the command
                does come back, it will get freed properly.

                Do not free ATA Identify commands that have timed
                out in mp{s,r}sas_add_device().  Wait for them
                to actually come back from the controller.

mp{s,r}var.h:   Add a dump_reqs_alltypes variable for the new
                dump_reqs_alltypes sysctl.

                Make sure we print the current state for state
                transition asserts.

This was tested in the Spectra Logic test bed (as described in the
review), as well Netflix's Open Connect fleet (where panics dropped from
a dozen or two a month to zero).

Reviewed by:		imp@ (who is handling the commit with ken's OK)
Sponsored by:		Spectra Logic
Differential Revision:	https://reviews.freebsd.org/D25476

(cherry picked from commit 175ad3d003)
2021-09-02 20:33:28 -04:00
Gordon Bergling
aa9d47d9de Fix a common typo in man pages and src comments
- s/desciptor/descriptor/

(cherry picked from commit b1603638e3)
2021-09-02 08:13:48 +02:00
Alexander Motin
c4bd6b589c pcib(4): Write window registers after resource adjustment
When adjusting resources we should write updated window base/limit into
the registers.  Without this newly added address range won't be routed
through the bridge properly.

Use MIN()/MAX() against current window base/limit to not shrink it on
the other side if the window is shared by several resources.

Align passed resource start/end to the set window granularity to keep
it properly aligned.  Currently this is mostly called by other bridges
having the same window alignment, but it may be change one day.

Reviewed by:	jrtc27, jhb
MFC after:	1 week
Sponsored by:	iXsystems, Inc.
Differential Revision: 	https://reviews.freebsd.org/D31693
2021-09-01 16:55:13 -04:00
Jessica Clarke
8ee90cc8d3 pci_pci: Support growing windows in bus_adjust_resource for NEW_PCIB
If we allocate a new window for a bridge rather than reusing an existing
one set up by firmware to cover all the devices then the new window only
includes the range needed for the first device to allocate the resource.
If a request comes in to adjust this resource in order to extend a
downstream window for another device then this will fail as the rman
doesn't have any space, so we must first grow the bridge's own window.

This is needed to support successfully attaching more than one PCI
device on SiFive's HiFive Unmatched, which has the following topology:

  Root Port <---> Bridge <---> Bridge <-+-> Bridge <---> (Unused)
   (pcib0)        (pcib1)      (pcib2)  |   (pcib3)
                                        +-> Bridge <---> xHCI
                                        |   (pcib4)
                                        +-> Bridge <---> M.2 E-key
                                        |   (pcib5)
                                        +-> Bridge <---> M.2 M-key
                                        |   (pcib6)
                                        +-> Bridge <---> x16 slot
                                            (pcib7)

Without this, the xHCI endpoint successfully attaches but NVMe M.2 M-key
endpoint fails to attach as, when its adjacent bridge (pcib6) attempts
to allocate a window from its parent (pcib2) on the other side of the
switch, its parent attempts to grow its own window by calling
bus_adjust_resource on its own parent (pcib1) which fails to call the
root port device (pcib0) to request more memory to grow its own window.
Had the root port been directly connected to the switch without the
bridge in the middle then the existing code would have worked, but the
extra hop broke it.

Reviewed by:	jhb
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D31035
2021-09-01 16:55:13 -04:00
Gordon Bergling
52237be90c isci(4): Fix a common typo in src comments
- s/exlusive/exclusive/

(cherry picked from commit 2dfcc3a91d)
2021-09-01 06:34:00 +02:00
Gordon Bergling
70af7d622c Fix a common typo in source code comments
- s/concurently/concurrently/

(cherry picked from commit 5d785ad65e)
2021-09-01 06:33:35 +02:00
Gordon Bergling
dbb74dd891 Fix some common typos in source code comments
- s/priviledged/privileged/
- s/funtion/function/
- s/doens't/doesn't/
- s/sychronization/synchronization/

(cherry picked from commit 5bdf58e196)
2021-08-31 08:13:15 +02:00
Gordon Bergling
1c327515a9 sound(4): Fix some common typos in comments
- s/doens't/doesn't/
- s/apropriate/appropriate/
- s/intepretation/interpretation/

(cherry picked from commit 58d868c88d)
2021-08-31 08:12:40 +02:00
Alfredo Dal'Ava Junior
7e583075a4 virtio-modern: fix PCI common read/write functions on big endian targets
Virtio modern has the common data organized in little endian, but
on powerpc64 BE it was reading and writing in the wrong endian.

Submitted by:	Leonardo Bianconi <leonardo.bianconi@eldorado.org.br>
Reviewed by:	bryanv, alfredo
Sponsored by:	Eldorado Research Institute (eldorado.org.br)
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D28947

(cherry picked from commit fb53b42e36)
2021-08-30 13:14:20 -03:00
Mark Johnston
9d3454e1e1 pci: Add an ioctl to perform I/O to BARs
This is useful for bhyve, which otherwise has to use /dev/io to handle
accesses to I/O port BARs when PCI passthrough is in use.

Reviewed by:	imp, kib
Discussed with:	jhb
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 7e14be0b07)
2021-08-29 12:39:42 -04:00
Kevin Bowling
8b043521b4 intel ethernet: Use ether_gen_addr(9)
Use ether_gen_addr(9) for VF MAC generation

Reviewed by:	Intel Networking (erj), kevans
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D31616

(cherry picked from commit 0e5811a2a9)
2021-08-26 18:33:48 -07:00
Kevin Bowling
524ea0dea9 e1000: Update intel shared code
Sync the e1000 shared code with DPDK shared code
"cid-gigabit.2020.06.05.tar.gz released by ND"

Primary focus was on client platforms (ich8lan). More work remains here
but we need an Intel contact for client networking.

Reviewed by:	grehan, Intel Networking (erj, earlier rev)
Obtained from:	DPDK <http://git.dpdk.org/dpdk/tree/drivers/net/e1000/base>
MFC after:	1 week
Sponsored by:	me
Differential Revision:	https://reviews.freebsd.org/D31547

(cherry picked from commit fc7682b17f)
2021-08-25 17:31:17 -07:00
Alexander Motin
2daa57cafb Mark some sysctls as CTLFLAG_MPSAFE.
MFC after:	2 weeks

(cherry picked from commit b776de6796)
2021-08-24 21:53:18 -04:00
Alexander Motin
17c83ffd10 ntb_hw_intel(4): Add CTLFLAG_MPSAFE flags.
I should have added those in 50f16247a1.

MFC after:	2 weeks

(cherry picked from commit 94feb1f1eb)
2021-08-23 22:35:30 -04:00
Alexander Motin
a58ed3b4f4 ntb_hw_intel(4): Remove CTLFLAG_NEEDGIANT flags.
Most of the sysctls just read hardware registers.  They don't need
any locking.

MFC after:	2 weeks

(cherry picked from commit 50f16247a1)
2021-08-23 22:29:46 -04:00
Alexander Motin
ccda3e7069 ntb_transport(4): Mark callouts MP-safe.
The only thing around NTB using Giant lock is NewBus, and these callouts
have nothing to do with it.

MFC after:	2 weeks

(cherry picked from commit c6902e7796)
2021-08-23 22:29:46 -04:00
Kevin Bowling
784459fc16 ixgbe: Avoid sbuf_trim(9) in sysctl handler
This was an error, we cannot use sbuf_trim(9) in the
ixgbe_sbuf_fw_version function because it also gets called in
the context of sbuf_new_for_sysctl(9). sbuf(9) explains the interaction
with drain functions as used by sbuf_new_for_sysctl(9).

Reviewed by:	imp
Fixes:		7660e4ea5c
MFC after:	1 day
Differential Revision:	https://reviews.freebsd.org/D31633

(cherry picked from commit 5de5419b5e)
2021-08-23 17:50:02 -07:00
Vladimir Kondratyev
04a49585bb evdev: Use bit_foreach helper macro
for traversing all bits set in the bitstring(9).

While here move bit_change() definition to common header.

(cherry picked from commit 5f99ae56c9)
2021-08-24 01:23:41 +03:00