Commit Graph

41171 Commits

Author SHA1 Message Date
John Baldwin
e0df0dce71 powerpc_nvram: Fix a bug in the adler32 checksum.
The Adler32 digest consists of two 16-bit words whose values are
calculated modulo 65521 (largest prime < 2^16).  To avoid two division
instructions per byte, this version copies an optimization found in
zlib which defers the modulus until close to the point that the
intermediate sums can overflow 2^32.  (zlib uses NMAX == 5552 for
this, this version uses 5000)

The bug is that in the deferred modulus case, the modulus was
only applied to the high word (and twice at that) but not to
the low word.  The fix is to apply it to both words.

Reviewed by:	jhibbits
Reported by:	Miod Vallat <miod@openbsd.org>
Differential Revision:	https://reviews.freebsd.org/D36798
2022-10-03 16:10:41 -07:00
John Baldwin
a9fca3b987 Fix various places which cast a pointer to a vm_paddr_t or vice versa.
GCC warns about the mismatched sizes on i386 where vm_paddr_t is 64
bits.

Reviewed by:	imp, markj
Differential Revision:	https://reviews.freebsd.org/D36750
2022-10-03 16:10:41 -07:00
Johannes Totz
a9a267c1f7 acpi_thermal: Fix a potential stack buffer overflow.
While here, fix a typo as well.

Reviewed by:	jhb
Differential Revision: https://reviews.freebsd.org/D36495
2022-10-03 11:16:27 -07:00
Doug Moore
368ee2f86a rb_tree: let insert search start from next node
When the node to insert in the rb_tree is known to precede or follow a
particular node, new methods RB_INSERT_PREV and RB_INSERT_NEXT,
defined here, allow the search for where to insert the new node begin
with that particular node, rather than at the root, to save a bit of
time.

Using those methods, instead of RB_INSERT, in managing a tree in
iommu_gas.c, saves a little time.

Reviewed by:	kib
MFC after:	3 weeks
Differential Revision:	https://reviews.freebsd.org/D35516
2022-10-02 22:27:21 -05:00
Warner Losh
f341e9bad3 uart: Remove sbbc reference
sbbc support is for sparc64 only, which was removed in 58aa35d429.

Sponsored by:		Netflix
2022-09-30 18:26:45 -06:00
Warner Losh
881fca442f arm: Catch up with Samsung S3C2xx0 code removal
The code backing these uart_class was removed 7 years ago in
4648ee9525.

Sponsored by:		Netflix
2022-09-30 18:12:10 -06:00
Ed Schouten
af3c78886f Alter the prototype of qsort_r(3) to match POSIX, which adopted the
glibc-based interface.

Unfortunately, the glibc maintainers, despite knowing the existence
of the FreeBSD qsort_r(3) interface in 2004 and refused to add the
same interface to glibc based on grounds of the lack of standardization
and portability concerns, has decided it was a good idea to introduce
their own qsort_r(3) interface in 2007 as a GNU extension with a
slightly different and incompatible interface.

With the adoption of their interface as POSIX standard, let's switch
to the same prototype, there is no need to remain incompatible.

C++ and C applications written for the historical FreeBSD interface
get source level compatibility when building in C++ mode, or when
building with a C compiler with C11 generics support, provided that
the caller passes a fifth parameter of qsort_r() that exactly matches
the historical FreeBSD comparator function pointer type and does not
redefine the historical qsort_r(3) prototype in their source code.

Symbol versioning is used to keep old binaries working.

MFC:			never
Relnotes:		yes
Reviewed by:		cem, imp, hps, pauamma
Differential revision:	https://reviews.freebsd.org/D17083
2022-09-30 15:26:30 -07:00
Kyle Evans
23c318ed86 extres: regulator: fix the build without FDT
The regnode interface is currently only built for FDT, thus not
applicable to ACPI-only kernels.  Move the "regnode_if.h" include
underneath a previously existing FDT cpp segment.

Reviewed by:	andrew, imp, manu
Differential Revision:	https://reviews.freebsd.org/D36790
2022-09-29 14:33:33 -05:00
Kyle Evans
4a4ad02da3 uart: uart_cpu_arm64: fix the build without FDT
clang 14 doesn't properly determine that we're unconditionally returning
if we have ACPI but not FDT.  Push FDT setup entirely into a new
function, much like we currently do with ACPI, and just return ENXIO if
that doesn't succeed.

Reviewed by:	andrew, manu (earlier version)
Differential Revision:	https://reviews.freebsd.org/D36788
2022-09-29 14:33:32 -05:00
Kyle Evans
79794d5c18 extres: syscon: pull in sys/malloc.h (fix !FDT)
syscon currently includes sys/malloc.h via header pollution from
dev/ofw/ofw_bus.h -> dev/ofw/openfirm.h.  Fix the build without FDT
defined by including sys/malloc.h directly.

Reviewed by:	andrew, imp, manu
Differential Revision:	https://reviews.freebsd.org/D36787
2022-09-29 14:33:32 -05:00
Souradeep Chakrabarti
6cf00ef80c arm64: enablement for ARM64 in Hyper-V (Part 1)
The changes are to refactor the code of vmbus.c and hyperv.c to keep minimal
arch specific codes there and have them in separate files in x86/ arm64/ .
x86 is a new directory, which contains codes for x86 / x86_64. Instead of
repeating the same codes in existing amd64/ and i386/, this approach reduced
the repetition. This is first of three patches for Hyper-V enablement.

Reviewed by:	whu
Tested by:	Souradeep Chakrabarti <schakrabarti@microsoft.com>
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D36466
2022-09-29 10:14:41 +00:00
Navdeep Parhar
8d2c13931b cxgbe/tom: Fix assertions in the code that maintains TCB history.
The tids used for TOE connections start from tid_base, not 0.

MFC after:	1 week
Sponsored by:	Chelsio Communications
2022-09-28 20:01:14 -07:00
John Baldwin
c5eed4146f Fix various places which cast a pointer to a uint64_t or vice versa.
GCC warns about the mismatched sizes on 32-bit platforms.

Reviewed by:	imp, markj
Differential Revision:	https://reviews.freebsd.org/D36752
2022-09-28 13:58:02 -07:00
John Baldwin
124e46735e ntb: Use uintmax_t casts and %j to print physical addresses.
This fixes -Wint-to-pointer-cast errors with GCC when compiling on
i386 where physical addresses are not the same size as pointers.

Reviewed by:	mav, imp
Differential Revision:	https://reviews.freebsd.org/D36751
2022-09-28 13:56:31 -07:00
Mitchell Horne
26d786331b usb: musb_otg_allwinner: de-constify bus_space_tags
The SAN interceptors simply take a bus_space_tag_t, so we're
dropping qualifiers here.  const semantics with a ptr typedef mean we'd
have to drop or change the bus_space_tag_t abstraction used in the SAN
sanitizers in order to make a compatible change there, which likely
isn't worth it.

Reviewed by:	andrew, markj
Sponsored by:	Juniper Networks, Inc.
Sponsored by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D36764
2022-09-27 15:54:00 -05:00
Hans Petter Selasky
2cce9aa078 vt(4): Make sure vt_switch_timer() has a sleepable context.
Fixes the following panic backtrace:

panic()
usbhid_sync_xfer()
usbhid_set_report()
hid_set_report()
hidbus_write()
hid_write()
hkbd_set_leds()
hkbd_ioctl_locked()
hkbd_ioctl_locked()
hkbd_ioctl()
kbdmux_ioctl()
vt_window_switch()
vt_switch_timer()

Differential Revision:	https://reviews.freebsd.org/D36715
MFC after:	1 week
Sponsored by:	NVIDIA Networking
2022-09-27 16:07:54 +02:00
John Baldwin
cee4fc7cad cxgbe: Use secq(9) to manage the timestamp generations.
This is mostly cosmetic, but it also doesn't leave a gap of time where
no structures are valid.  Instead, we permit the ISR to continue to
use the previous structure if the write to update cal_current isn't
yet visible.

Reviewed by:	gallatin
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D36669
2022-09-26 14:58:41 -07:00
John Baldwin
2c74c9dac3 cxgbe: Compute timestamps via sbintime_t.
This uses fixed-point math already used elsewhere in the kernel for
sub-second time values.  To avoid overflows this does require updating
the calibration once a second rather than once every 30 seconds.  Note
that the cxgbe driver already queries multiple registers once a second
for the statistics timers.  This version also uses fewer instructions
with no branches (for the math portion) in the per-packet fast path.

Reviewed by:	np
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D36663
2022-09-26 14:58:30 -07:00
Kyle Evans
bd93b5f79a pci_host_generic: stop address translation in bus_alloc_resource
Translating the provided range prior to rman_reserve_resource(9) is
decidedly wrong; the caller may be trying to do a wildcard allocation,
for which the implementation is expected to DTRT and clamp the range to
what's actually feasible.

We don't use the resulting translation here anyways, so just remove it
entirely -- the rman in the default implementation is derived from
sc->ranges, so the translation should trivially succeed every time as
long as the reservation succeeded.  If something has gone awry in a
derived driver, we'll detect it when we translate prior to activation,
so there's likely no diagnostic value in retaining the translation after
reservation either.

Reviewed by:	andrew
Noticed by:	jhb
Differential Revision:	https://reviews.freebsd.org/D36618
2022-09-26 14:25:13 -05:00
Wei Hu
7a58bf0443 arm64: Enabling new hypercalls using HvCallSetVpRegisters and HvCallGetVpRegisters
Enabling HvCallSetVpRegisters and HvCallGetVpRegisters for hypercalls to
read and write to specific MSRs. This is required for implementing wrmsr
and rdmsr, which is required for Hyper-V vmbus driver for ARM64.

Also we need to use arm smccc hvc 1.2 version as we need to access
registers beyond X0-X3 for HvCallGetVpRegisters. Currently scoping
it only for Hyper-V.

Reviewed by:	lwhsu, andrew, whu
Tested by:	Souradeep Chakrabarti <schakrabarti@microsoft.com>
Signed-off-by:	Souradeep Chakrabarti <schakrabarti@microsoft.com>
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D36256
2022-09-26 06:30:37 +00:00
Konstantin Belousov
550e01c552 snp(4): implement detach
PR:	257964
Reported by:	Bertrand Petit <bsdpr@phoe.frmug.org>
Reviewed by:	imp, markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D36690
2022-09-25 23:36:16 +03:00
Konstantin Belousov
bb4be76cf3 snp(4): properly report detached/revoked ttys
PR:	257964
Reported by:	Bertrand Petit <bsdpr@phoe.frmug.org>
Reviewed by:	imp, markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D36690
2022-09-25 23:36:16 +03:00
Hans Petter Selasky
f50274674e ibcore: The use of IN_LOOPBACK() now requires a valid VNET context.
Make sure the VNET is set before using this macro.

Fixes:		efe58855f3
PR:		266054
MFC after:	1 week
Sponsored by:	NVIDIA Networking
2022-09-23 13:42:03 +02:00
John Baldwin
f49fd63a6a kmem_malloc/free: Use void * instead of vm_offset_t for kernel pointers.
Reviewed by:	kib, markj
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D36549
2022-09-22 15:09:19 -07:00
John Baldwin
7ae99f80b6 pmap_unmapdev/bios: Accept a pointer instead of a vm_offset_t.
This matches the return type of pmap_mapdev/bios.

Reviewed by:	kib, markj
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D36548
2022-09-22 15:08:52 -07:00
Navdeep Parhar
02fac928ab cxgbe(4): Fix potential integer overflow in t4_tstmp_to_ns.
Coverity flagged this in its latest run but it is not a problem in
practice as the card's core clock would have to be > 4.2GHz for any
overflow to occur.

CID 1498303:  Integer handling issues  (OVERFLOW_BEFORE_WIDEN)
Potentially overflowing expression "sc->params.vpd.cclk * 1000U" with type "unsigned int" (32 bits, unsigned) is evaluated using 32-bit arithmetic, and then used in a context that expects an expression of type "uint64_t" (64 bits, unsigned).

Reported by:	Coverity Scan (CID 1498303)
Sponsored by:	Chelsio Communications
2022-09-22 09:47:11 -07:00
Alexander V. Chernikov
91ebcbe02a if_clone: migrate some consumers to the new KPI.
Convert most of the cloner customers who require custom params
 to the new if_clone KPI.

Reviewed by:	kp
Differential Revision:	https://reviews.freebsd.org/D36636
MFC after:	2 weeks
2022-09-22 12:30:09 +00:00
Zhenlei Huang
d819ddba9a lio: Remove unneeded include.
Reviewed by:		adiran, imp
Differential Revision:	https://reviews.freebsd.org/D36501
2022-09-21 14:53:00 -06:00
Konstantin Belousov
8d42019058 cxgbe: fix kernel build without TCP_OFFLOAD or RATELIMIT
Reviewed by:	np
Fixes:	e398922eaf
Sponsored by:	Nvidia networking
Differential revision:	https://reviews.freebsd.org/D36648
2022-09-21 19:19:28 +03:00
Doug Moore
b16f993ec2 rb_tree: augmentation shortcut
RB-tree augmentation maintains data in each node of the tree that
represents the product of some associative operator applied to all the
nodes of the subtree rooted at that node. If a node in the tree
changes, augmentation data for the node is updated for that node and
all nodes on the path from that node to the tree root. However,
sometimes, augmenting a node changes no data in that node,
particularly if the associated operation is something involving 'max'
or 'min'. If augmentation changes nothing in a node, then the work of
walking to the tree root from that point is pointless, because
augmentation will change nothing in those nodes either. This change
makes it possible to avoid that wasted work.

Define RB_AUGMENT_CHECK as a macro much like RB_AUGMENT, but which
returns a value 'true' when augmentation changes the augmentation data
of a node, and false otherwise. Change code that unconditionally walks
and augments to the top of tree to code that stops once an
augmentation has no effect. In the case of rebalancing the tree after
insertion or deletion, where previously a node rotated into the path
was inevitably augmented on the march to the tree root, now check to
see if it needs augmentation because the march to the tree root
stopped before reaching it.

Change the augmentation function in iommu_gas.c so that it returns
true/false to indicate whether the augmentation had any effect.

Reviewed by:	alc, kib
MFC after:	3 weeks
Differential Revision:	https://reviews.freebsd.org/D36509
2022-09-20 23:21:14 -05:00
Mateusz Guzik
d0b235c715 cxgbe: fix the build after e398922eaf 2022-09-20 21:31:49 +00:00
Randall Stewart
e398922eaf Enable M_TSTMP in Chelsio cxgbe driver by creating a mechanism that can sync the time.
Chelsio has always been recording a timestamp in the mbuf (rcv_tstmp) but
not setting the M_TSTMP bit in the mbuf flags. This is because the timestamp
was just the free running 60bit clock. This change fixes that so that
we keep a synchronization by periodically (every 30 seconds after startup)
getting the timestamp and the current nanosecond time. We always keep
several sets around and the current one we always keep the current pair
and the previous pair of timestamps. This allows us to setup a ratio
between the two so we can correctly translate the time. Note that
we use special care to split the timestamp into seconds (per the clock tick)
and nanoseconds otherwise 64bit math would overflow.

Reviewed by: np
Sponsored by: Netflix Inc
Differential Revision: https://reviews.freebsd.org/D36315
2022-09-20 15:13:16 -04:00
Randall Stewart
7cc3ea9c6f mlx5 M_TSTMP accuracy looses quite a bit of precision so lets fix it.
The way that the clock is synchronized between the system and the current mlx5 for the purposes of the M_TSTMP
being carried we loose a lot of precision. Instead lets change the math that calculates this to separate out
the seconds/nanoseconds and operate on the two values so we don't get overflow instead of just
shifting the value down and loosing precision.

Reviewed by: kib, hselasky
Sponsored by: Netflix Inc
Differential Revision: https://reviews.freebsd.org/D36327
2022-09-20 13:12:16 -04:00
Hubert Mazur
55760984d5 igc: Don't start in promiscious mode by default
The igc driver always sets the promiscious mode during initialization,
ignoring what is set in ifp.
Fix this by checking the interface flags and setting mode appropriately.

Reviewed by:	grehan
Obtained from:	Semihalf
Sponsored by:	Stormshield
MFC after:	1 week
Differential Revision: https://reviews.freebsd.org/D36591
2022-09-19 09:18:19 +02:00
Jakub Kołodziej
b8a083ea32 gpio: Merge TCA6416 & TCA6408 drivers into TCA64XX
This merges TCA6416, TCA6408 drivers and adds PCA9555 support.
They handle 8 pin and 16 pin ICs with basic INPUT/OUTPUT functionality.
The register map is fairly similar so there is no point in having two
separate drivers.

Reviewed by:	kd
Obtained from:	Semihalf
Differential Revision: https://reviews.freebsd.org/D36559
2022-09-19 09:18:08 +02:00
Doug Moore
87cd087a4a iommu_gas: don't remove and insert boundary entry
Avoid removing an item in iommu_gas_free_region only to reinsert it,
by avoiding removing an entry that is either first_place or
last_place.

Reviewed by:	kib
MFC after:	3 weeks
Differential Revision:	https://reviews.freebsd.org/D36597
2022-09-16 15:32:11 -05:00
Nuno Teixeira
b44869cba1 sound: add patch for Lenovo Legion 5 Intel
Laptop Legion Lenovo 5 15MH05 (Intel)

Patch to fix the sound on this machine.
It requires sending the speaker and the headphone jack to the same nid.

PR:		265632
Approved by:	emaste
MFC after:      1 week
Differential Revision:  https://reviews.freebsd.org/D36511
2022-09-16 14:29:30 +01:00
Ed Maste
9054e29681 Retire ISA sound card DMA support
As all ISA sound card drivers have been removed sndbuf_dma no longer
serves any purpose.

Reviewed by:	mav
Relnotes: 	Yes
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D34671
2022-09-15 10:07:23 -04:00
Gordon Bergling
a5c1b9e332 qlnxe(4): Fix a typo in a source code comment
- s/paramters/parameters/

MFC after:	3 days
2022-09-15 10:31:05 +02:00
Gordon Bergling
c86b1d9965 safexcel: Fix a typo in a source code comment
- s/paramters/parameters/

MFC after:	3 days
2022-09-15 10:26:48 +02:00
Tetsuya Uemura
e2386f18ec nxprtc: Fix timing issue with register access.
My Adafruit PCF8523 RTC on either RPi2B or RPi3B+ failed to work around
80 ~ 90 % of boot-ups, by printing the following log lines.

nxprtc0: <NXP PCF8523 RTC> at addr 0xd0 on iicbus0
nxprtc0: cannot set up timer
Warning: no time-of-day clock registered, system time will not be set accurately

This is due to pcf8523_start_timer(sc) returned non-zero in
nxprtc_start() due to a register read failure of PCF8523_R_TMR_A_FREQ or
PCF8523_R_TMR_CLKOUT or a failure to program a new value.

The pause_sbt("nxpbat") sleep was too short and caused the register
access failures.

PR: 266093
2022-09-14 07:34:15 -06:00
Jessica Clarke
129028c79c da9063_rtc: Add new driver for the Dialog Semiconductor DA9063 RTC
This is a simple RTC present in the PMIC, supporting 1s precision.

This is the PMIC on SiFive's HiFive Unmatched.

Reviewed by:	mhorne, imp
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D36200
2022-09-13 17:46:21 +01:00
Jessica Clarke
80466455ad da9063_iic: Add new driver for the Dialog Semiconductor DA9063 PMIC
This is an MFD with regulators, an RTC and a watchdog, among other
things. This adds the necessary infrastructure for specific children to
be added.

Note that the PMIC can also be attached via SPI, not just I2C, and so
the interface is abstracted. No SPI implementation is added, however.

This is the PMIC on SiFive's HiFive Unmatched.

Reviewed by:	manu, mhorne
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D36199
2022-09-13 17:46:09 +01:00
Pavel Timofeev
d88dc1b0b9 hda: add patch for Framework laptop v2 headphone jack
Fix headphone (12th gen Intel laptops) and mic jack (both 11th and
12th gen) switching.

PR:		262579
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D36354
2022-09-13 12:16:26 -04:00
Adrian Chadd
633d178c63 qcom_qup: compilation fixes
Fix compilation warning/errors - in this instance we do need the register
IO.

Reviewed by: imp

Differential Revision: https://reviews.freebsd.org/D36535
2022-09-12 20:10:25 -07:00
Adrian Chadd
82302a49fd qcom_tlmm: use return code instead of always returning true.
This was failing due to unused/ignored return values; so just use them.

Reviewed by: imp

Differential Revision: https://reviews.freebsd.org/D36534
2022-09-12 20:10:25 -07:00
Adrian Chadd
3d9bd82522 qcom_clk: compilation fixes
* remove dead code
* mark enabled as unused, happens if debugging isn't enabled
* log the enabled state if debugging is enabled

Reviewed by: imp

Differential Revision: https://reviews.freebsd.org/D36533
2022-09-12 20:10:25 -07:00
Adrian Chadd
f05b3c9f47 qcom_gcc: fix the parent clock to work again
Rename it to match the clock-output-names field in the device
tree.

Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D36531
2022-09-12 20:10:24 -07:00
Navdeep Parhar
998eb37aca cxgbe(4): Add knob to control congestion behavior for TOE queues.
hw.cxgbe.ofld_cong_drop works just like hw.cxgbe.cong_drop but for TOE
rx queues.

MFC after:	2 weeks
Sponsored by:	Chelsio Communications
2022-09-12 11:40:35 -07:00
Navdeep Parhar
df275ae509 cxgbe(4): Add another setting to the knob that controls congestion.
hw.cxgbe.cong_drop=2 will generate backpressure *and* drop frames for
queues that are congested.

MFC after:	2 weeks
Sponsored by:	Chelsio Communications
2022-09-12 11:40:29 -07:00