iwlwifi: firmware: reduce script to extract fwget information
Due to driver changes it is no longer feasible to extract the full
PCI ID / firmware / card type information in one go as we used to
be able to.
We have already changed the way we extract firmware information for
ports and marked the iwlwififw.4 man page as obsolete.
Reduce the script to simply extarct the fwget(8) information and,
compared to the old times, sort each section so diffs will be easier
to see in the future. This was particular helpful this time to make
sure we do not lose entries with the change of technique.
We also keep the script in the best perl spirit to do the job but
not to win a price, especially given it seems we have to change
matters every (other) year.
Given we can no longer extract firmware information for the PCI IDs,
we need to "manually" check against the ports that names match.
[7 lines not shown]
Implement vmemdup_{array}_user
This is what FreeBSD now does for memdup_user and memdup_array_user
(which is wrong for memdup, but correct for vmemdup).
The amdgpu DRM driver started this in Linux ~6.12.86+
Reviewed by: wulf
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D57444
(cherry picked from commit 302c6d25da6907ec762ff8937fa86d380743b000)
LinuxKPI: add can_wakeup option and accessor functions
We can implement device_set_wakeup_capable() in the !CONFIG_PM_SLEEP
case; we do not have the infrastructure in place for the CONFIG_PM_SLEEP
case so leave a pr_debug TODO.
Needed by an upcoming wireless driver.
Reviewed by: dumbbell
Differential Revision: https://reviews.freebsd.org/D58883
(cherry picked from commit a424fb3519ebf8fb972e7ba45ba19df322992b00)
LinuxKPI: 802.11: Always lock around lkpi_80211_mo_{remove_interface,stop}()
Add the missing locking to another two MO driver downcalls, as drivers
always expect it (e.g. rtw89 by assertion).
Add the lock and might_sleep assertions to the respective lkpi_80211_mo_*
downcalls.
PR: 298417
Reviewed by: bz
Differential Revision: https://reviews.freebsd.org/D59608
(cherry picked from commit 73166d21bd831db264509cbdce1ab3b63ab5b189)
LinuxKPI: add PCI_IRQ_AFFINITY #define
Add the #define for PCI_IRQ_AFFINITY and leave a pr_debug note in
pci_alloc_irq_vectors() that it is unimplemented.
The flag is needed by an upcoming WiFi driver.
Reviewed by: dumbbell
Differential Revision: https://reviews.freebsd.org/D58881
(cherry picked from commit b589e403a2c3bd2a94fb2ab88cd23255c68a9f05)
linuxkpi: Define `DEFINE_CLASS()` and `CLASS()`
`DEFINE_CLASS()` is in fact named `LINUXKPI_DEFINE_CLASS()` because it
conflicts with `DEFINE_CLASS()` defined in <sys/kobj.h>.
This macro defines a type and a pair of constructor/destructor
functions.
They are to be used by `CLASS()`: this one declares a variable,
initialise it with the constructor and set the `__cleanup()` attribute
to call the destructor once the variable goes out of scope.
The DRM drivers generic code started to use `CLASS()` in Linux 6.13. It
requires the `fd` class to be defined in <linux/file.h>.
Reviewed by: bz
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D57583
(cherry picked from commit f2a2e02ae54b836d1e23648756a050406f65111e)
LinuxKPI: pci: add pci_select_bars() and pci_msix_vec_count()
For pci_select_bars() we use the LinuxKPI internal information, while
for pci_select_bars() we fall back to the native PCI stack.
Needed by a wifi driver.
Reviewed by: dumbbell
Differential Revision: https://reviews.freebsd.org/D58878
(cherry picked from commit 55c07af60172b211116be47010fc0831aafc99e8)
LinuxKPI: fix argument type to lkpi_pci_msi_desc_alloc()
lkpi_pci_msi_desc_alloc() takes an unsigned int, not an int.
While here make sure the prototype is visibile in interrupt.h as
well before use to avoid -Wimplicit-function-declaration errors.
Discovered while working on a wireless driver.
Reviewed by: dumbbell
Differential Revision: https://reviews.freebsd.org/D58879
(cherry picked from commit cfb23b01e269e8a0a84066637b82b746f01b46b4)
LinuxKPI: add #include of rculist.h to ethtool.h for Linux conformance
Add #include rculist.h to ethtool.h to fullfill expectations of
Linux drivers without having to modify them.
Reviewed by: dumbbell, emaste
Differential Revision: https://reviews.freebsd.org/D58874
(cherry picked from commit 4570a1bf760a3cd63eb7dd9e3ebbc3cf103bda4d)
LinuxKPI: rcu: add optional condition to list_for_each_entry_rcu()
list_for_each_entry_rcu() can take an optional condition. Add the
macro argument so code remains compiling but do not do anything with
it just yet.
Leave comments as list_for_each_entry_rcu() likely should have a
different implementation.
Sponsored by: The FreeBSD Foundation
Reviewed by: dumbbell
Differential Revision: https://reviews.freebsd.org/D59292
(cherry picked from commit e975ce86ff11a330128f5b21c7cd11c28d3aff87)
LinuxKPI: implement dma_{alloc,free}_{noncoherent,attrs}
We use one to implement the other given direction stays unused.
This is needed by an upcoming wifi driver.
Reviewed by: dumbbell
Differential Revision: https://reviews.freebsd.org/D58880
(cherry picked from commit c3fa17a6a331db8aad03e9cb89ba97e1811ab381)
pci_iov: Permit non-ARI VFs on a secondary bus
A non-zero VF device number does not always require ARI. The Intel
82576 and I350 [1] explicitly support a non-ARI layout that places VFs
on the next bus.
Check every requested VF RID and reject a non-zero device only when it
is on the PF bus. This retains the ARI guard for invalid same-bus
layouts while permitting the documented second-bus layout.
[1] Intel I350 Datasheet, sections 7.8.2.6.1.2, 9.6.4.6
Sponsored by: BBOX.io
(cherry picked from commit e795a31cb4d66368bdbe5ac7f61c0899d3ed39f8)
pci: Expose PME support by power state
The presence of the PCI power management capability does not imply that
a function can signal PME# from every power state. Drivers which
advertise wake based only on pci_has_pm() can consequently expose wake
modes that cannot work.
Add pci_has_pme() to query the PME_Support bitmap for a specific state.
Use it to implement LinuxKPI pci_pme_capable(), removing its duplicate
PME_Support decoder.
Validated the helper against PCI PMC capability values from 82571EB,
82573L, 82579LM, I210, I225, and I226-V controllers. The 82571 and
82573 reported PMC 0xc822, while the I226-V reported 0xc823. In both
values, bits 15, 14, and 11 advertise PME from D3cold, D3hot, and D0;
the low-bit difference is only the PM capability version.
Sponsored by: BBOX.io
(cherry picked from commit c4e24e95c3f905b817d4bfc6e93457eb297bfa4b)
pci: Expose a VF's owning PF to bus subclasses
ofw_pcibus now uses pci_iov_get_pf() to inherit PF locality for
VFs, but the accessor was inadvertently left in an uncommited ACPI
change. This breaks powerpc builds.
Expose the accessor from the PCI core and provide a stub when PCI_IOV
is omitted. Record VF ownership before pci_add_child() so child added
callbacks can safely query it, and remove the later redundant
assignment.
Sponsored by: BBOX.io
(cherry picked from commit 3481a9cdc4dc26ef583bb0f46a04d5d059cde466)
pci: Optionally disable endpoints with unsafe MPS
Keep warn-only behavior as the default. Add an opt-in policy that
clears endpoint decoding and bus mastering when a newly discovered
function cannot match its active path, while never disabling bridge
functions and their subtrees.
(cherry picked from commit 114f4a68f21345e1e6680b7acf1bf733d9047002)
pci: Do not reconcile MPS across PCI domains
A PCI function can provide a host bridge into a synthetic PCI domain.
Intel VMD does this: the host facing VMD function remains in its
original domain while the hidden Root Ports and endpoints appear in a
separate domain. The VMD function's Device Control does not describe
an upstream link in that synthetic hierarchy.
The hierarchy wide cold pass incorrectly used the VMD function's MPS
to reprogram the hidden ports and their endpoints. Stop both cold
reconciliation and runtime path walks at a PCI domain boundary. The
real Root Ports within the VMD domain continue to reconcile their
endpoints normally.
Reviewed by: imp
Tested by: Michael Butler <imb at protected-networks.net>
Fixes: 8e9fe9996a1f ("pci: Reconcile MPS before attaching PCIe devices")
Sponsored by: BBOX.io
Differential Revision: https://reviews.freebsd.org/D58837
[2 lines not shown]
pci: Reconcile MPS before attaching PCIe devices
Reconcile each newly enumerated link as a unit before child drivers
attach. Firmware may leave Bus Master Enable set after handoff, so use
the bus attachment state rather than that bit to identify the cold
phase.
Preserve an established hierarchy during rescan and hot-add. Refuse a
reduction below a switch because recursive enumeration may already have
made a sibling subtree live; lowering only the local port or Root Port
would produce an inconsistent path. Report capability and active-use
conflicts distinctly.
Handle OFW PCI buses that clone the generic enumeration path.
(cherry picked from commit 8e9fe9996a1fbdb79033b082e6a96b9e1266e33f)
pci_iov: Roll back failed VF enumeration
pci_iov_enumerate_vfs() logged a failed VF creation or driver
configuration but still reported the whole SR-IOV configuration as
successful. The PF remained enabled with the requested NumVFs and
driver state even though one or more VF children were absent.
Make VF enumeration atomic. Delete children created by the failed
attempt, invoke the PF driver cleanup, disable VF memory space and VF
Enable, release the IOV resources, and return the original error to
iovctl. Also treat failure to create a VF child as an error instead
of silently accepting a partial configuration.
(cherry picked from commit 4b195f1a25d5003117653a1a323ad19561dc8705)
pci: Skip PF SR-IOV state handling for VFs
A VF's pci_devinfo references its PF's pcicfg_iov for resource
bookkeeping, but only the PF implements the SR-IOV capability.
pci_cfg_save() and pci_cfg_restore() treated any non-NULL cfg.iov as
an owned capability and accessed the PF capability offset in VF
configuration space. Saving a VF could therefore replace the shared
PF settings with unrelated VF register values.
Skip SR-IOV capability save and restore for PCICFG_VF children. The
generic PCI and PCIe state of the VF remains preserved. This is also
required by drivers that save VF state around a PF-driven
function-level reset.
(cherry picked from commit 78547d542f776d366c36b5a2fc747ddfe99523c6)
pci: Export pcie_flr_supported()
Move the capability and quirk checks used by pcie_flr() into a public
side effect free helper. This lets callers determine whether an FLR
can be attempted before quiescing a device or saving state.
The helper considers the advertised PCIe FLR capability and both the
enable and disable FLR quirks.
Sponsored by: BBOX.io
(cherry picked from commit 5b48968c1a57bd1a7f086d7e09add59afa158340)
pci: Add a hierarchy-wide MPS limit
Add a boot-time ceiling for MPS reconciliation. Apply it only while an
entire cold-enumerated link can be configured consistently, and leave
an established active path unchanged.
(cherry picked from commit 673cb5265a2df2228982fc220f4e7ea62ab765b2)
pci_iov: Clear NumVFs when configuration fails
pci_iov_config() programs NumVFs before validating the final VF RID
layout and allocating all generic resources. A subsequent error ran the
driver uninit callback but left the hardware NumVFs register programmed
while the software VF count returned to zero.
Clear NumVFs in the error path after the driver uninit callback,
matching normal SR-IOV teardown ordering. This prevents stale hardware
state after a failed configuration and permits a clean retry.
Sponsored by: BBOX.io
(cherry picked from commit 621498b58cdab36a237d5f0b5c902952ad743fa9)
pci: Preserve adjusted PCIe control state
The PCI bus changes live capability registers after the initial
configuration snapshot has been saved. A later driver reprobe restores
that snapshot and can silently undo the adjustment.
Update the cached Device Control and Root Control bits together with
pcie_adjust_config() writes. Route the persistent Maximum Read Request
setter and the bus-owned AER control changes through that helper as
well, so they share the same restore semantics as MPS reconciliation.
Document the persistent-write contract. Merge only explicitly adjusted
bits into the saved image so unrelated or transient bits observed during
the hardware read-modify-write cannot become persistent.
(cherry picked from commit a9752e9ac8a635f49ca058dd7268298840c7e915)
pci: Permit function-level reset of 82599 VFs
Intel 82599 supports FLR on VFs but reports FLR support only in the PF
Device Capabilities register. The VF register therefore leaves the FLR
Capable bit clear, and pcie_flr() rejects the reset.
Intel documents the zeroed VF PCIe capability structure as erratum 35
in the 82599 Specification Update (B0=Yes; NoFix).
Add a positive FLR quirk for the 82599 VF. Keep the capability check
for every other function, so an unknown nonconforming VF cannot make
pcie_flr() report success when its reset request was ignored.
SR-IOV requires VFs to support FLR, but a clear capability bit cannot
distinguish the 82599's misadvertisement from a VF that fails to
implement it.
(cherry picked from commit ee776a8e291cb73845a8611d3dec5a2a966106b9)