Commit graph

39882 commits

Author SHA1 Message Date
Alexander Motin
2bd4b5475f hwpmc: Skip GLOBAL_CTRL updates on stop_pmc().
After we wipe PMC configuration, including its local enable bit(s),
we don't really care about its global enable bit.  Global enable bits
now may only be cleared by interrupt handler in case of error (sample
buffer overflow).  Being set is actually a reset default for them.

This saves one WRMSR per process-scope PMC per context switch, that
is clearly visible in profiles.

MFC after:	1 month

(cherry picked from commit 326a8d3e08)
2022-07-04 13:48:10 -04:00
Alexander Motin
6b1e6a629d hwpmc: Bump Intel's IA32_PERFEVTSELx width to 64 bits.
Haswell added there bits 32/33 for TSX, and AlderLake added bit 34
for Adaptive PEBS Record.

MFC after:	1 month

(cherry picked from commit 1a4614a51e)
2022-07-04 13:48:10 -04:00
Alexander Motin
fad7a311d9 hwpmc: Make powerpc memory allocation alike to x86.
It should remove some unneeded pointer dereferences.

MFC after:	1 month

(cherry picked from commit 47699fc265)
2022-07-04 13:48:10 -04:00
Alexander Motin
633cab8aa4 hwpmc: Remove always zero pc_resync field.
MFC after:	1 month

(cherry picked from commit 5acb4c862b)
2022-07-04 13:48:09 -04:00
Alexander Motin
b8ef2ca9ea hwpmc: Add basic Intel Alderlake CPUs support.
The PMC subsystem is not designed for non-uniform CPU capabilities
(P/E-cores are different), but at least several working architectural
events like cpu_clk_unhalted.thread_p should be better than nothing.

MFC after:	1 month

(cherry picked from commit fe109d3113)
2022-07-04 13:48:09 -04:00
Alexander Motin
e7b63a7c6d hwpmc: Update Intel's programmable counters restrictions.
Primarily remove unneeded restrictions from later CPUs.

MFC after:	1 month

(cherry picked from commit ae57fbc7ec)
2022-07-04 13:48:09 -04:00
Alexander Motin
2154db2220 hwpmc: Correct selection of Intel fixed counters.
Intel json's use event=0 to specify fixed counter number via umask.
Alternatively fixed counters have equivalent programmable event/umask.

MFC after:	1 month

(cherry picked from commit c1e813d123)
2022-07-04 13:48:09 -04:00
Alexander Motin
a7588be68c hwpmc: Use hardware PMCs freezing on PMI on Intel v2+.
Since version 2 Intel CPUs can freeze PMCs when intering PMI to reduce
PMI effects on collected statistics.  Since version 4 hardware supports
"streamlined" mechanism, not requiring IA_GLOBAL_CTRL MSR access.

MFC after:	1 month

(cherry picked from commit 81ffb45f02)
2022-07-04 13:48:09 -04:00
Alexander Motin
698c67184a hwpmc: Add Intel Core register defines up to version 5.
MFC after:	1 month

(cherry picked from commit 245b056556)
2022-07-04 13:48:08 -04:00
Mitchell Horne
78f8ebe0c3 hwpmc_intel: assert for correct nclasses value
This variable is set based on the exact CPU model detected. If this
value is set too small, it could lead to a NULL-dereference from an
improperly initialized pmc_rowindex_to_classdep array.

Though it has been fixed, this was previously the case for Broadwell.
Add two asserts to catch this in DEBUG kernels, as it represents a
configuration error that may be hard to uncover otherwise.

PR:		253687
Reported by:	Zhenlei Huang <zlei.huang@gmail.com>
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 8399d923a5)
2022-07-04 13:48:08 -04:00
Mitchell Horne
bdedfb3a00 if_ffec: free the dmamem allocation in detach
Calling bus_dmamap_destroy() for a mapping which was allocated with
bus_dmamem_alloc() will result in a panic. This change is not run-time
tested, but I identified the issue while implementing the analogous
method in if_dwc(4), using this implementation as the template.

MFC after:	1 week
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 8757d0fca9)
2022-07-04 13:34:57 -03:00
Mitchell Horne
eea2563d7f if_ffec: fix some misleading indentation
(cherry picked from commit b93985c11a)
2022-07-04 13:34:57 -03:00
Mitchell Horne
3a72965a25 if_dwc: avoid duplicate packet counts
We already increment the unicast IPACKETS and OPACKETS counters in the
rx/tx paths, respectively. Multicast packets are counted in the generic
ethernet code. Therefore, we shouldn't increment these counters in
dwc_harvest_stats().

Drop the early return from dwc_rxfinish_one() so that we still count
received packets with e.g. a checksum error.

PR:		263817
Reported by:	Jiahao LI <jiahali@blackberry.com>
Reviewed by:	manu
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D35499

(cherry picked from commit 9718759043)
2022-07-04 13:34:57 -03:00
Mitchell Horne
5dec16de37 if_dwc: add detach method
It can be useful for testing.

Reviewed by:	manu
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D35496

(cherry picked from commit 27b39e58b3)
2022-07-04 13:34:57 -03:00
Jiahao Li
164bdd8f9a if_dwc: enable RX checksum offload feature
We claim support in ifcaps, but don't actually enable it.

PR:		263886
Reviewed by:	manu
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D35498

(cherry picked from commit 35c9edab41)
2022-07-04 13:34:56 -03:00
Mitchell Horne
68d02feaef if_dwc: consistently use if.c helper methods
And if_t rather than struct ifnet *. No functional change intended.

Reviewed by:	manu
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D35497

(cherry picked from commit ca01879004)
2022-07-04 13:34:56 -03:00
Bjoern A. Zeeb
66754c01ff XHCI: clear warm and port reset
It seems we do not clear UPS_C_BH_PORT_RESET and UPS_C_PORT_RESET
conditions after warm or port reset.  Add that code.

Obtained from:	an old patch mainly debugging other problems
Reviewed by:	hselasky
Differential Revision: https://reviews.freebsd.org/D35483

(cherry picked from commit 8f892e9bee)
2022-07-01 13:50:19 +00:00
Bjoern A. Zeeb
39cd7aa134 USB: add quirks to XHCI
While XHCI is very generic some revisions of chipsets have problems.
On dwc3 <= 3.00a Port Disable does not seem to work so we need to not
enable it.
For that introduce quirks to xhci so that controllers can steer
certain features.  I would hope that this is and remains the only one.

Obtained from:	an old patch mainly debugging other problems
Reviewed by:	hselasky
Differential Revision: https://reviews.freebsd.org/D35482

(cherry picked from commit 447c418da0)
2022-07-01 13:50:10 +00:00
Hans Petter Selasky
20d3224919 uhid(4): Don't read-ahead from the USB IN endpoint.
This avoids an issue where IN endpoint data received from the device right
before the file handle is closed, gets lost.

PR:		263995
Sponsored by:	NVIDIA Networking

(cherry picked from commit b6f615255d)
2022-06-30 11:39:43 +02:00
Neel Chauhan
7a8188739a if_ix: Reset on an ECC error
This mirrors the Linux behavior as seen in the kernel commit d773ce2.

Reviewed by:		kbowling
MFH after:		3 days
Differential Revision:	https://reviews.freebsd.org/D35542

(cherry picked from commit 4f1d91e413)
2022-06-29 10:07:50 -07:00
Mitchell Horne
e06f07bc3f kerneldump: remove physical argument from d_dumper
The physical address argument is essentially ignored by every dumper
method. In addition, the dump routines don't actually pass a real
address; every call to dump_append() passes a value of zero for
physical.

Reviewed by:	markj
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D35173

(cherry picked from commit 489ba22236)
2022-06-27 16:32:06 -03:00
Mitchell Horne
758e72c0a8 Add new vnode dumper to support live minidumps
This dumper can instantiate and write the dump's contents to a
file-backed vnode.

Unlike existing disk or network dumpers, the vnode dumper should not be
invoked during a system panic, and therefore is not added to the global
dumper_configs list. Instead, the vnode dumper is constructed ad-hoc
when a live dump is requested using the new ioctl on /dev/mem. This is
similar in spirit to a kgdb session against the live system via
/dev/mem.

As described briefly in the mem(4) man page, live dumps are not
guaranteed to result in a usuable output file, but offer some debugging
value where forcefully panicing a system to dump its memory is not
desirable/feasible.

A future change to savecore(8) will add an option to save a live dump.

Reviewed by:	markj, Pau Amma <pauamma@gundo.com> (manpages)
Discussed with:	kib
MFC after:	3 weeks
Sponsored by:	Juniper Networks, Inc.
Sponsored by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D33813

(cherry picked from commit c9114f9f86)
2022-06-27 16:32:06 -03:00
Doug Moore
c253ae9fe4 iommu_gas: restrict tree search to promising paths
In iommu_gas_lowermatch and iommu_gas_uppermatch, a subtree search is
quickly terminated if the largest available free space in the subtree
is below a limit, where that limit is related to the size of the
allocation request. However, that limit is too small; it does not
account for both of the guard pages that will surround the allocated
space, but only for one of them. Consequently, it permits the search
to proceed through nodes that cannot produce a successful allocation
for all the requested space. Fix that limit to improve search
performance.

Reviewed by:	alc, kib
Submitted by:	Weixi Zhu (wxzhu@rice.edu)
MFC after:	3 weeks
Differential Revision:	https://reviews.freebsd.org/D35414

(cherry picked from commit b831865fe3)
2022-06-27 00:36:42 -05:00
Doug Moore
4d517feaea busdma_iommu: simplify split logic
iommu_bus_dmamap_load_something1 includes code for handling the
possibility of splitting a buffer that is needlessly complex.
Simplify it.

Reviewed by:	alc, kib
MFC after:	3 weeks
Tested by: pho (previous revisions)
Differential Revision:	https://reviews.freebsd.org/D35232

(cherry picked from commit 04e86ae357)
2022-06-27 00:34:59 -05:00
Mitchell Horne
70bb14b902 ddb: namespacing of struct command
'command' is too generic for something specific to the kernel debugger;
change this so it is less likely to collide with local variable names.
Also rename struct command_table to struct db_command_table.

Reviewed by:	markj
MFC after:	1 week
Sponsored by:	Juniper Networks, Inc.
Sponsored by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D35367

(cherry picked from commit 4ef7db5a7e)
2022-06-23 19:19:48 -03:00
Mitchell Horne
0db22efc94 Use KERNEL_PANICKED() in more places
This is slightly more optimized than checking panicstr directly. For
most of these instances performance doesn't matter, but let's make
KERNEL_PANICKED() the common idiom.

Reviewed by:	mjg
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D35373

(cherry picked from commit 35eb9b10c2)
2022-06-23 19:19:26 -03:00
Warner Losh
db761c6a64 Create wrapper for Giant taken for newbus
Create a wrapper for newbus to take giant and for busses to take it too.
bus_topo_lock() should be called before interacting with newbus routines
and unlocked with bus_topo_unlock(). If you need the topology lock for
some reason, bus_topo_mtx() will provide that.

Sponsored by:		Netflix
Reviewed by:		mav
Differential Revision:	https://reviews.freebsd.org/D31831

(cherry picked from commit c6df6f5322)
2022-06-21 17:13:20 +02:00
Hans Petter Selasky
492f5e6494 mlx5ib: Fix memory leak in clean_mr() error path
In the clean_mr() error path the 'mr' should be freed.

Linux commit:
5942d8ae411775b76e5e1ab0cce57b0666516f2d

PR:		264653
Sponsored by:	NVIDIA Networking

(cherry picked from commit e4d178d093)
2022-06-20 13:08:39 +02:00
Hans Petter Selasky
0b5f08439d uchcom(4): Add new USB ID.
PR:		260783
PR:		264634
Sponsored by:	NVIDIA Networking

(cherry picked from commit f25a0a0f21)
2022-06-20 13:08:39 +02:00
Hans Petter Selasky
026e19496c urtw(4): Adjust all pause calls to use milliseconds instead of ticks.
Sponsored by:	NVIDIA Networking

(cherry picked from commit c6c22ebb38)
2022-06-16 04:55:52 +02:00
Hans Petter Selasky
1c5c1e4486 upgt(4): Adjust all pause calls to use milliseconds instead of ticks.
Sponsored by:	NVIDIA Networking

(cherry picked from commit bc2e447338)
2022-06-16 04:55:52 +02:00
Hans Petter Selasky
be3f667388 mlx4core: Use-after-free causes a resource leak in flow-steering detach
mlx4_QP_FLOW_STEERING_DETACH_wrapper first removes the steering
rule (which results in freeing the rule structure), and then
references a field in this struct (the qp number) when releasing the
busy-status on the rule's qp.

Since this memory was freed, it could reallocated and changed.
Therefore, the qp number in the struct may be incorrect,
so that we are releasing the incorrect qp. This leaves the rule's qp
in the busy state (and could possibly release an incorrect qp as well).

Fix this by saving the qp number in a local variable, for use after
removing the steering rule.

Linux commit:
3b01fe7f91c8e4f9afc4fae3c5af72c14958d2d8

PR:	     	264469
Sponsored by:	NVIDIA Networking

(cherry picked from commit dd2a8c8f72)
2022-06-14 11:39:23 +02:00
Gordon Bergling
ca753c6495 al_eth: Fix a typo in a source code comment
- s/enought/enough/

(cherry picked from commit 45b143d2ea)
2022-06-10 14:33:13 +02:00
Gordon Bergling
836ade5e8f amdsbwd(4): Fix a typo in a source code comment
- s/accross/across/

(cherry picked from commit 68c0bd3e3f)
2022-06-10 14:32:22 +02:00
Gordon Bergling
a270ec979f nvmw(4): Fix a typo in a source code comment
- s/inaccessable/inaccessible/

(cherry picked from commit 6e8ab6715d)
2022-06-10 14:31:11 +02:00
Gordon Bergling
aa5c134817 aic7xxx: Fix a few typos in comments and an error message
- s/directrive/directive/
- s/specifiled/specified/
- s/Decend/Descend/
- s/tranversal/transversal/

Obtained from:	NetBSD

(cherry picked from commit d35e1c29a9)
2022-06-10 14:29:50 +02:00
Gordon Bergling
466a3ed5c3 ena(4): Fix a typo in a source code comment
- s/entred/entered/

(cherry picked from commit eb3f25b413)
2022-06-10 14:29:20 +02:00
Gordon Bergling
a9d1abf00e sound(4): Fix a typo in a source code comment
- s/alltogether/altogether/

(cherry picked from commit 70311ccffc)
2022-06-10 14:28:55 +02:00
Gordon Bergling
80bc6e0126 hptmv(4): Fix a typo in a source code comment
- s/continous/continuous/

(cherry picked from commit bbb0ca45f8)
2022-06-10 14:28:42 +02:00
Gordon Bergling
abcfcce068 le(4): Fix a typo in a source code comment
- s/brodcast/broadcast/

(cherry picked from commit b008ab622c)
2022-06-10 14:28:14 +02:00
Gordon Bergling
e59da6ed98 if_sis(4): Fix a typo in a source code comment
- s/emperical/empirical/

(cherry picked from commit 3c2ea3ca28)
2022-06-10 14:26:53 +02:00
Gordon Bergling
1dceda2ccd aic79xx: Fix a typo in a source code comment
- s/Disble/Disable/

Obtained from:	NetBSD

(cherry picked from commit 2cada72c65)
2022-06-10 14:26:12 +02:00
Gordon Bergling
59a480875d qlnxe(4): Fix a typo in a source code comment
- s/indepent/independent/

(cherry picked from commit a87f167c41)
2022-06-10 14:25:08 +02:00
Gordon Bergling
0fa1bbeebc twe(4): Fix a common typo in a source code comment
- s/independant/independent/

(cherry picked from commit 508a46c745)
2022-06-10 14:24:54 +02:00
Gordon Bergling
8b5309ab25 qlxgbe(4): Fix a common typo in a source code comment
- s/independant/independent/

(cherry picked from commit f129473702)
2022-06-10 14:24:40 +02:00
Gordon Bergling
3d5aa46fc6 ffec: Fix a common typo in a source code comment
- s/independant/independent/

(cherry picked from commit d3e0919b56)
2022-06-10 14:24:11 +02:00
Gordon Bergling
c7aa67863c if_age(4): Fix a typo in a source code comment
- s/indepent/independent/

(cherry picked from commit f207bdd2cc)
2022-06-10 14:23:57 +02:00
Gordon Bergling
402a483124 mlx(4): Fix a common typo in a source code comment
- s/independant/independent/

(cherry picked from commit 9ae6b386ab)
2022-06-10 14:23:42 +02:00
Gordon Bergling
cc57e03523 ixgbe(4): Fix common typos in source code comments
- s/filer/filter/

Obtained from:	NetBSD

(cherry picked from commit cd7e11f78d)
2022-06-10 14:22:46 +02:00
Hans Petter Selasky
d264494e98 mlx4core: Fix a memory leak when deleting slave's resources
mlx4_delete_all_resources_for_slave() in the resource tracker should free
all memory allocated for a slave. While releasing memory of fs_rule,
it misses releasing memory of fs_rule->mirr_mbox.

Linux commit:
461d5f1b59490ce0096dfda45e10038c122a7892

PR:		264249
Sponsored by:	NVIDIA Networking

(cherry picked from commit f29c9901a4)
2022-06-07 08:44:29 +02:00