Commit graph

42057 commits

Author SHA1 Message Date
Emmanuel Vadot
801fb66a7e dwc: Do not re-invent phy mode type
Directly uses the MII_CONTYPE_*

No functional changes intended.
2023-10-05 17:34:40 +02:00
Emmanuel Vadot
5d88a52be4 dwc: Move dma engine configuration to dwc1000_dma.c
No functional changes intended.
2023-10-05 17:34:40 +02:00
Emmanuel Vadot
363b7c39fb dwc: Move the dma reset code in dwc1000_dma.c
No functional changes intended
2023-10-05 17:34:40 +02:00
Emmanuel Vadot
f0a7dd7703 dwc: Setup desc addresses in the dma init function. 2023-10-05 17:34:40 +02:00
Emmanuel Vadot
29776aa436 dwc: Move interrupt related code to core and dma file
No functional changes intended.
2023-10-05 17:34:40 +02:00
Emmanuel Vadot
fe82f82dcc dwc: Put all DMA related defines in dma1000_dma.c
No need to polute dwm1000_dma.h now.

No functional changes intended.
2023-10-05 17:34:39 +02:00
Emmanuel Vadot
627726b5b6 dwc: Move struct dwc_hash_maddr_ctx declaration in dwc1000_core
it's only used there.

No functional change intended.
2023-10-05 17:34:39 +02:00
Emmanuel Vadot
afa0f66e81 dwc: Move the txstart dma part to dwc1000_dma
This is dma related to move it to the dma file.

No functional changes intended.
2023-10-05 17:34:39 +02:00
Emmanuel Vadot
62519d5a4f dwc: Split core functions
Synopsis/Designware controller have multiple version. The version currently
supported by dwc(4) is the version 3 and it's usually called 1000 for gigabit.
In the goal to support all of those in the same base driver start splitting the
core function to a new file.

No functional changes intended.
2023-10-05 17:34:39 +02:00
Emmanuel Vadot
972adf0f97 dwc: Split dma functions
Synopsis/Designware controller have multiple dma version, the one included
in the driver is the base one. if_awg is one example of a dwc variant that
have another DMA controller. eqos is a newer variant of dwc that have a newer
dma controller.
In the goal to support all of those in the same base driver start splitting the
dma function to a new file.

No functional changes intended.
2023-10-05 17:34:39 +02:00
Emmanuel Vadot
c36125f6cc dwc: Rename if_dwc.h to dwc1000_reg.h
Synopsis/Designware controller have multiple version. The version currently
supported by dwc(4) is the version 3 and it's usually called 1000 for gigabit.
This file only have definition for the registers of this version so rename it.

No functional changes intended.
2023-10-05 17:34:39 +02:00
Emmanuel Vadot
9e3879fcc1 dwc: Drop 'All rights reserved'
Discussed with:	br
2023-10-05 17:34:39 +02:00
Emmanuel Vadot
50059a60ed dwc: Rewrite clock and reset functions
snps,dwmac have one required clock named stmmaceth and one optional pclk,
correctly handle both in if_dwc, no need to get/enable stmmacseth again
in if_dwc_rk.
It also have one required reset also named stmmaceth and one optional ahb,
correctly handle both.
Rockchip have another optional clock named clk_mac_speed, get it and enable it
if present. Also fix the optional RMII clocks, they were previously wrongly
enabled in RGMII case.
2023-10-05 17:34:38 +02:00
Emmanuel Vadot
b69c49d106 dwc: Add support for aal
snps,aal is used to indicate that the DMA engine should
use Address-Aligned Beats.
2023-10-05 17:34:38 +02:00
Emmanuel Vadot
f4bb6ea521 dwc: Add support for mixed-burst
snps,mixed-burst is used to indicate that the DMA engine should
use mixed-burst mode.
2023-10-05 17:34:38 +02:00
Emmanuel Vadot
27f03f1608 dwc: Remove unused GPIO_ACTIVE_LOW define
While here move comment block above the appropriate functions.
2023-10-05 17:34:38 +02:00
Emmanuel Vadot
f114aadd3e dwc: Rename dwc_reset to dwc_reset_phy
It only deals with reseting the phy.
While here avoid calling ofw_bus_get_node again and save the node in softc.
2023-10-05 17:34:38 +02:00
Emmanuel Vadot
432ae724e6 dwc: Move every sub drivers to dev/dwc
It makes it easier to find all the sub drivers and change them if needed.
While here do not gate dwc_rk with soc options, dwc_rk is made for all rockchip
SoCs. Same thing for dwc_socfpga
2023-10-05 17:34:38 +02:00
Damien Broka
6962da914d axge: Add support for AX88179A
The AX88179A has two firmware modes, one of which is backward
compatible with existing AX88178A/179 driver. The active firmware mode
can be controlled through a register.

Update axge(4) man page to mention 179A support and ensure that, when
bound to a AX88179A, the driver activates the compatible firmware mode.

Reviewed by:	markj
Pull Request:	https://github.com/freebsd/freebsd-src/pull/854
MFC after:	1 week
2023-10-04 11:08:06 -04:00
Emmanuel Vadot
1d6a6a5244 i2c: Add Microcrystal RV3032 RTC driver
This is a simple RTC driver for the rv3032 from Microcrystal.
Just the basic functionality is implemented (no timer, alarm etc ..).

Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D41995
2023-10-03 09:56:20 +02:00
Emmanuel Vadot
137b58e4d2 i2c: Add cadence iic driver
This IP is found in Xilinx SoC, it only been tested on ZynqMP (arm64)
so only enable it there for now.

Differential Revision:	https://reviews.freebsd.org/D41994
2023-10-03 09:56:20 +02:00
Emmanuel Vadot
125f5c5b48 iicbus: Move opencores i2c driver into controller subdirectory
Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D41914
2023-10-03 09:56:20 +02:00
Emmanuel Vadot
7c569caa0a iicbus: Move i2c sensors drivers into new sensor subdirectory
No reason that they should live directly under iicbus

Sponsored by:   Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D41913
2023-10-03 09:56:20 +02:00
Emmanuel Vadot
06589d6e02 iicbus: Move ADC drivers into a new adc subfolder
No reason that they should live directly under iicbus

Sponsored by:   Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D41911
2023-10-03 09:56:19 +02:00
Emmanuel Vadot
22d7dd834b iicbus: Move adm1030 and adt746x to new pwm subdirectory
Those are (mainly) pwm controller so move it under a new subdirectory.

Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D41910
2023-10-03 09:56:19 +02:00
Emmanuel Vadot
062944cc42 iicbus: Move Silergy pmic/regulators under pmic/silergy subdirectory
Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D41909
2023-10-03 09:56:19 +02:00
Emmanuel Vadot
2f16049c98 iicbus: Move remaining rtc driver into rtc subfolder
No reason that they should live directly under iicbus

Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D41908
2023-10-03 09:56:19 +02:00
Emmanuel Vadot
580d00f42f iicbus: Move twsi under a new controller subdirectory
The folder is a mess so start moving stuff into sub-directories.

Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D41907
2023-10-03 09:56:19 +02:00
Olivier Certner
ebaea1bcd2 x86: AMD Zen2: Zenbleed chicken bit mitigation
Applies only to bare-metal Zen2 processors.  The system currently
automatically applies it to all of them.

Tunable/sysctl 'machdep.mitigations.zenbleed.enable' can be used to
forcibly enable or disable the mitigation at boot or run-time.  Possible
values are:

    0: Mitigation disabled
    1: Mitigation enabled
    2: Run the automatic determination.

Currently, value 2 is the default and has identical effect as value 1.
This might change in the future if we choose to take into account
microcode revisions in the automatic determination process.

The tunable/sysctl value is simply ignored on non-applicable CPU models,
which is useful to apply the same configuration on a set of machines
that do not all have Zen2 processors.  Trying to set it to any integer
value not listed above is silently equivalent to setting it to value 2
(automatic determination).

The current mitigation state can be queried through sysctl
'machdep.mitigations.zenbleed.state', which returns "Not applicable",
"Mitigation enabled" or "Mitigation disabled".  Note that this state is
not guaranteed to be accurate in case of intervening modifications of
the corresponding chicken bit directly via cpuctl(4) (this includes the
cpucontrol(8) utility).  Resetting the desired policy through
'machdep.mitigations.zenbleed.enable' (possibly to its current value)
will reset the hardware state and ensure that the reported state is
again coherent with it.

Reviewed by:	kib
Sponsored by:   The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D41817
2023-10-02 15:29:18 -04:00
David Sloan
7ea866eb14 nvme: Fix memory leak in pt ioctl commands
When running nvme passthrough commands through the ioctl interface
memory is mapped with vmapbuf() but not unmapped. This results in leaked
memory whenever a process executes an nvme passthrough command with a
data buffer. This can be replicated with a simple c function (error
checks skipped for brevity):

void leak_memory(int nvme_ns_fd, uint16_t nblocks) {
	struct nvme_pt_command pt = {
		.cmd = {
			.opc = NVME_OPC_READ,
			.cdw12 = nblocks - 1,
		},
		.len = nblocks * 512, // Assumes devices with 512 byte lba
		.is_read = 1, // Reads and writes should both trigger leak
	}
	void *buf;

	posix_memalign(&buf, nblocks * 512);
	pt.buf = buf;
	ioctl(nvme_ns_fd, NVME_PASSTHROUGH_COMMAND, &pt);
	free(buf);
}

Signed-off-by: David Sloan <david.sloan@eideticom.com>

PR:		273626
Reviewed by:	imp, markj
MFC after:	1 week
2023-10-02 11:50:14 -04:00
Bjoern A. Zeeb
f156cd892b net80211 / drivers: remove public use of ieee80211_node_incref()
ieee80211_node_incref() is the FreeBSD implementation of
ieee80211_ref_node().  Not being interested in the node returned
it was used as a shortcut in 3 drivers (ath, uath, wpi).
Replace the call with the public KPI of ieee80211_ref_node() and
ignore the result.
This leaves us with the single internal call going
ieee80211_ref_node() -> ieee80211_node_incref() and that should
help increasing portability but also limiting the places to trace
for node reference operations.

Sponsored by:	The FreeBSD Foundation
MFC after:	4 weeks
2023-10-02 14:52:57 +00:00
Mark Johnston
015daf5221 hdac: Defer interrupt allocation in hdac_attach()
hdac_attach() registers an interrupt handler before allocating various
driver resources which are accessed by the interrupt handler.  On some
platforms we observe what appear to be spurious interrupts upon a cold
boot, resulting in panics.

Partially work around the problem by deferring irq allocation until
after other resources are allocated.  I think this is not a complete
solution, but is correct and sufficient to work around the problems
reported in the PR.

PR:		268393
Tested by:	Alexander Sherikov <asherikov@yandex.com>
Tested by:	Oleh Hushchenkov <o.hushchenkov@gmail.com>
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D41883
2023-09-27 08:28:27 -04:00
Warner Losh
1d6021cd72 nvme: Supress noise messages
When we're suspending, we get messages about waiting for the controller
to reset. These are in error: we're not waiting for it to reset. We put
the recovery state as part of suspending, so we should suppress these as
a false positive.

Also remove a stray debug that's left over from earlier versions of
the recovery code that no longer makes sense.

Sponsored by:		Netflix
2023-09-25 22:21:58 -06:00
John Baldwin
99159b076a Update a couple of tools to not embed __FBSDID in generated files
Reviewed by:	imp, emaste
Differential Revision:	https://reviews.freebsd.org/D41955
2023-09-25 07:50:11 -07:00
John Baldwin
16837d353c Remove a few more stray __FBSDID uses
Reviewed by:	imp, emaste
Differential Revision:	https://reviews.freebsd.org/D41954
2023-09-25 07:49:52 -07:00
John Baldwin
fc3cc652e5 videomode: Regenerate files
Reviewed by:	imp, emaste
Differential Revision:	https://reviews.freebsd.org/D41953
2023-09-25 07:49:30 -07:00
John Baldwin
bd524e2ddb videomode/devlist2h.awk: Don't include $FreeBSD$ in generated files
Reviewed by:	imp, emaste
Differential Revision:	https://reviews.freebsd.org/D41952
2023-09-25 07:46:53 -07:00
Priit Trees
0a5d2802b4 vge: correct pause_frames sysctl description
Reviewed by:	emaste
Pull Request:	https://github.com/freebsd/freebsd-src/pull/806
2023-09-24 13:34:36 -04:00
Warner Losh
da8324a925 nvme: Fix locking protocol violation to fix suspend / resume
Currently, when we suspend, we need to tear down all the qpairs. We call
nvme_admin_qpair_abort_aers with the admin qpair lock held, but the
tracker it will call for the pending AER also locks it (recursively)
hitting an assert. This routine is called without the qpair lock held
when we destroy the device entirely in a number of places. Add an assert
to this effect and drop the qpair lock before calling it.
nvme_admin_qpair_abort_aers then locks the qpair lock to traverse the
list, dropping it around calls to nvme_qpair_complete_tracker, and
restarting the list scan after picking it back up.

Note: If interrupts are still running, there's a tiny window for these
AERs: If one fires just an instant after we manually complete it, then
we'll be fine: we set the state of the queue to 'waiting' and we ignore
interrupts while 'waiting'. We know we'll destroy all the queue state
with these pending interrupts before looking at them again and we know
all the TRs will have been completed or rescheduled. So either way we're
covered.

Also, tidy up the failure case as well: failing a queue is a superset of
disabling it, so no need to call disable first. This solves solves some
locking issues with recursion since we don't need to recurse.. Set the
qpair state of failed queues to RECOVERY_FAILED and stop scheduling the
watchdog. Assert we're not failed when we're enabling a qpair, since
failure currently is one-way. Make failure a little less verbose.

Next, kill the pre/post reset stuff. It's completely bogus since we
disable the qparis, we don't need to also hold the lock through the
reset: disabling will cause the ISR to return early. This keeps us from
recursing on the recovery lock when resuming. We only need the recovery
lock to avoid a specific race between the timer and the ISR.

Finally, kill NVME_RESET_2X. It'S been a major release since we put it
in and nobody has used it as far as I can tell. And it was a motivator
for the pre/post uglification.

These are all interrelated, so need to be done at the same time.

Sponsored by:		Netflix
Reviewed by:		jhb
Tested by:		jhb (made sure suspend / resume worked)
MFC After:		3 days
Differential Revision:	https://reviews.freebsd.org/D41866
2023-09-24 07:17:18 -06:00
Emmanuel Vadot
6694651138 iicbus: pmic: rk8xx: Fix logic in clock-output-names detection
Pointy hat to:	manu (probably)
2023-09-22 18:51:33 +02:00
Alan Somers
7d154c4dc6 mprutil: "fix user reply buffer (64)..." warnings
Depending on the card's firmware version, it may return different length
responses for MPI2_FUNCTION_IOC_FACTS.  But the first part of the
response contains the length of the rest, so query it first to get the
length and then use that to size the buffer for the full response.

Also, correctly zero-initialize MPI2_IOC_FACTS_REQUEST.  It only worked
by luck before.

PR:		264848
Reported by:	Julien Cigar <julien@perdition.city>
MFC after:	1 week
Sponsored by:	Axcient
Reviewed by:	scottl, imp
Differential Revision: https://reviews.freebsd.org/D38739
2023-09-21 08:38:24 -06:00
Andrew Turner
4386935191 vtgpu: Fix the physical memory size
Use the correct endian switching function when switching to a little
endian 64-bit address. Even on a little-endian machine this will
truncate the address to a 32-bit value.

Sponsored by:	Arm Ltd
2023-09-21 11:50:29 +01:00
Andrew Turner
8a723e2bd8 Check SMCCC is ready before using
Add asserts to check SMCCC has been initialised before callers try to
use it.

Reviewed by:	emaste
Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D41917
2023-09-20 17:01:37 +01:00
Gleb Smirnoff
2bcef59d42 psm: recognize post-IBM trackpoints on Thinkpads
Newer Thinkpads come with trackpoints from different vendors.  They
are mostly compatible with the original one.  Not sure all features
are going to work, but at least this fixes resume operation.

Tested on:		Thinkpad X1 Carbon 7th Gen
Reviewed by:		wulf, imp
Diffrential Revision:	https://reviews.FreeBSD.org/D41871
2023-09-19 09:41:04 -07:00
Mateusz Guzik
c9130a46bc drm2: whack set-but-not-used warns 2023-09-18 21:11:26 +00:00
Mina Galić
180c02405b virtio: remove virtio_alloc_virtqueues' flags arg
Summary:
the flags argument is unused.
Its initial design idea has been superceded by the addition of
virtio_setup_intr and related APIs.

Sponsored by: The FreeBSD Foundation

Reviewers: bryanv

Reviewed By: bryanv

Subscribers: cognet, imp

Differential Revision: https://reviews.freebsd.org/D41850
2023-09-18 22:03:31 +02:00
Mina Galić
ccb576a83c virtio: use bool for boolean functions
Summary:
these static functions:
- vq_ring_use_indirect

and these public functions:
- virtio_bus_is_modern
- virtio_with_feature
- virtqueue_empty
- virtqueue_full

exclusively return a boolean value.
Change their return values to bool.

Sponsored by: The FreeBSD Foundation

Reviewers: bryanv

Reviewed By: bryanv

Subscribers: cognet, imp

Differential Revision: https://reviews.freebsd.org/D41848
2023-09-18 22:03:26 +02:00
Emmanuel Vadot
4c52dde5bd if_cgem: Rewrite clock part
- pclk and hclk are mandatory so always try to get them.
   Don't make it fatal if it fails as some platform (like Zynq) don't
   have a proper clock driver.
 - Always use pclk for the reference clock.
 - Try to get all the possible clocks and enable them.

Reviewed-by:	mhorne
Tested-by:	Milan Obuch <bsd@dino.sk>
Differential Revision:	https://reviews.freebsd.org/D41857
Sponsored by:	Beckhoff Automation GmbH & Co. KG
2023-09-18 15:24:27 +02:00
Emmanuel Vadot
bdbbbbb321 if_cgem: Cleanup compatible and add new ones
- Remove cdns,gem, it's the generic binding but for all platform that include
  this one we need specific drivers setup so remove it.
- Remove cdns,macb, it's the generic binding for Atmel AT91 which we don't suport
- Remove cadence,gem, it's not an official binding and seems to be only used in some
  obscure ARM11 SoC.
- Note that the cdns,zynq* are deprecated
- Add the new Xilinx compatible for zynq and zynqmp

Reviewed-by:	mhorne
Tested-by:	skibo, Milan Obuch <bsd@dino.sk>
Differential Revision:	https://reviews.freebsd.org/D41856
Sponsored by:	Beckhoff Automation GmbH & Co. KG
2023-09-18 15:24:24 +02:00
Emmanuel Vadot
81a4fe38a6 sdhci: fdt: Correctly export clock per the binding
The binding says that we can have one or two clocks to export.
The first one is the actual sdclock while the second is the sample clock.
Both have the same parent, clk_xin.
Correctly export the clocks for RK3399 and ZynqMP.
No need to use a high ID as before, we have our own clock domain so use
ids starting at 1 as all exported clocks should be.

Reviewed-by:	bz
Differential Revision:	https://reviews.freebsd.org/D41810
Sponsored by:	Beckhoff Automation GmbH & Co. KG
2023-09-18 15:23:55 +02:00