Commit graph

39932 commits

Author SHA1 Message Date
Dimitry Andric
fde05f9864 Fix clang 15 warning in cxgbe
Clang 15 warns:

    sys/dev/cxgbe/cudbg/cudbg_lib.c:2949:6: error: variable 'i' set but not used [-Werror,-Wunused-but-set-variable]
            int i = 0;
                ^

Apparently 'i' was meant as the current retry counter, but '1' was used
in the while loop comparison instead, making the loop potentially
infinite, if 'busy' never gets reset.

MFC after:	3 days
Reviewed by:	np
Differential Revision: https://reviews.freebsd.org/D35834

(cherry picked from commit fb0493d559)
2022-07-20 18:51:15 +02:00
Dimitry Andric
ac1daaa6f8 Adjust agp_find_device() definition in agp.c to avoid clang 15 warning
With clang 15, the following -Werror warning is produced:

    sys/dev/agp/agp.c:910:16: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
    agp_find_device()
                   ^
                    void

This is because agp_find_device() is declared with a (void) argument
list, and defined with an empty argument list. Make the definition match
the declaration.

MFC after:	3 days

(cherry picked from commit c0817e2aba)
2022-07-19 20:02:06 +02:00
Dimitry Andric
dae26c1153 Remove unused but set variable in cxgb_sge
Clang 15 warns:

    sys/dev/cxgb/cxgb_sge.c:1290:21: error: variable 'txsd' set but not used [-Werror,-Wunused-but-set-variable]
            struct tx_sw_desc *txsd = &txq->sdesc[txqs->pidx];
                               ^

It appears 'txsd' is a leftover from a previous refactoring (see
3f345a5d09), but is no longer used for anything, and can be removed
without any functional change.

MFC after:	3 days
Reviewed by:	np
Differential Revision: https://reviews.freebsd.org/D35833

(cherry picked from commit cab040039d)
2022-07-19 20:01:49 +02:00
Gordon Bergling
9fd95378f3 qat(4): Fix a typo in a source code comment
- s/bufer/buffer/

Obtained from:	NetBSD

(cherry picked from commit e4a203234a)
2022-07-19 18:01:23 +02:00
Gordon Bergling
000e2a5b3d qat(4): Fix a typo in a source code comment
- s/mirco/micro/

Obtained from:	NetBSD

(cherry picked from commit db1c3dbe82)
2022-07-19 18:00:51 +02:00
Gordon Bergling
ee4dc8211a cxgbe(4): Fix a typo in a source code comment
- s/alredy/already/

(cherry picked from commit 63303133a7)
2022-07-19 17:59:46 +02:00
Mark Johnston
b7806e7bae ktls: Zero out TLS_GET_RECORD control messages
Otherwise we end up copying one uninitialized byte into the socket
buffer.

Reported by:	KMSAN
Reviewed by:	jhb
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 6be8944d96)
2022-07-19 09:53:41 -04:00
Kornel Dulęba
0627a69cd8 e6000sw: Fix direct register write logic
When accessing a register directly from etherswitchcfg one must specify
a register group(e.g. registers of portN) and the register offset within
the group. The latter is passed as the 5 least significant bits.
Extract the former by dividing the register address by 32, not by 5.

Approved by:	mw(mentor)
Obtained from:	Semihalf
Sponsored by:	Stormshield
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D35672

(cherry picked from commit 6654825907)
2022-07-19 11:36:55 +02:00
Kornel Dulęba
94c272b4c6 igc: Change default duplex setting
During media selection through ifconfig one might not specify
the duplex setting through the mediaopt flag.
In that case the igc driver would default to full-duplex.
The problem with this approach is that e1000(em/igb) driver
defaults to half-duplex.
Because of that if one connects both NICs and sets media to
e.g. 100baseTX on both of them no link will be found.
Fix that by matching igc behaviour with what e1000 does.

Reviewed by: grehan
Approved by: mw(mentor)
Obtained from: Semihalf
Sponsored by: Stormshield
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D35673

(cherry picked from commit 3b8d04f845)
2022-07-19 11:36:48 +02:00
Andrew Turner
2069f112f0 Clean up in the pci host generic driver
Add clean up on failure and a detach function to the pci host generic
driver.

Reviewed by:	jhb (earlier version)
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D35291

(cherry picked from commit d843dd0e1a)
2022-07-19 08:03:30 +01:00
Bjoern A. Zeeb
30f6e37522 dwc3: add ACPI attachment
Split the current FDT-only implementation up into an FDT and an
ACPI part reusing and sharing as much code as possible (thanks mw!).

This makes the Synopsis XHCI root hubs attach correctly on SolidRun's
HoenyComb instead of just the generic XHCI root and this means we
are also doing proper chip setup and applying the quirk needed there [1].

There is one problem with ACPI attachment in that it uses the generic
XHCI PNP ID.  So we need to do extra checks in order to not claim
all xhci, which means we check for a known quirk to be present
in acpi_probe.  Long term this isn't scaling and this was discussed
in SolidRun's Discord Channel in 2021 with the intend that "jnettlet"
will take this to a steering committee.  Since then ACPI has kind-of
become a technology non grata (due to not getting changes into Linux
timely) so it is unclear if this will ever happen.  If there will be
further hardware with dwc3/ACPI we should go and make sure this problem
gets solved.

[1] 24698f90b7/Silicon/NXP/LX2160A/AcpiTables/Dsdt/Usb.asl

Reviewed by:		manu, mw
Differential Revision:	https://reviews.freebsd.org/D32256

(cherry picked from commit fbb5cb66f7)
2022-07-18 01:00:21 +00:00
Bjoern A. Zeeb
ae33d74d47 dwc3: improve debugging
Rather than hiding behind #if 0, hide the debugging behind DWC3_DEBUG
so it can be turned on with a single define.  Require bootverbose
to print anything so we can still avoid spamming the console if DWC3_DEBUG
is on.
Harmonize the format string in snsp_dwc3_dump_regs() to always print the
full register and also print the XHCI quirks.
Call snsp_dwc3_dump_regs() twice, before and after generic XHCI attachment
and initialisation as this may have an effect on the confirgumation state.

Obtained from:	an old debug patch
Reviewed by:	mw
Differential Revision: https://reviews.freebsd.org/D35700

(cherry picked from commit 11a7d5e5d9)
2022-07-18 01:00:21 +00:00
Bjoern A. Zeeb
a7717dc610 dwc3: add more quirks and checks
Rather than just printing the Global SNPS ID Register store it as well
so we can do a version check later.
In addition, for debugging purposes, read the Global Hardware Parameters
Registers and print them.

Based on the snpsid disable an XHCI feature using a quirk prepared
in 447c418da0.
Add the "snps,dis_u3_susphy_quirk" quirk and handle Suspend USB3.0 SS PHY
after power-on-reset/during core initialization (suggested to be cleared)
based on the DWC3_GHWPARAMS0 register.

Obtained from:	an old debugging patch
Reviewed by:	mw (earlier version), mmel
Differential Revision: https://reviews.freebsd.org/D35699

(cherry picked from commit 09cdf4878c)
(cherry picked from commit ec32fc2af5)
2022-07-18 01:00:21 +00:00
Bjoern A. Zeeb
486d99faa3 dwc3: uncondinationally enable Host IN Auto Retry
Enable dwc3's auto retry feature. For IN transfers with crc errors
or internal overruns this will make the host reply with a
non-terminating retry ACK.  I believe the hope was to improve
reliability after seeing occasional hiccups.

Obtained from:	an old debugging patch
Reviewed by:	mw
Differential Revision: https://reviews.freebsd.org/D35698

(cherry picked from commit cec0a5ec6b)
2022-07-18 01:00:21 +00:00
Bjoern A. Zeeb
9ffd5ef82f dwc3: fix snps,dis-del-phy-power-chg-quirk
If snps,dis-del-phy-power-chg-quirk is set, the register bit should be
cleared not ored on (it's the "dis" version).

Reviewed by:	mw
Differential Revision: https://reviews.freebsd.org/D35697

(cherry picked from commit 0084212bfd)
2022-07-18 01:00:20 +00:00
Bjoern A. Zeeb
bf7ce29414 USB: dwc3: use device_{has,get}_property()
Switch the driver to use device based functions which will work not
only with FDT but also ACPI.

While here make dr_mode a local variable as it is only used during
probe and not needed later in the softc.

Reviewed by:	mw
Differential Revision: https://reviews.freebsd.org/D33170

(cherry picked from commit b11f52f4db)
2022-07-18 01:00:20 +00:00
Bjoern A. Zeeb
ab82f64eb5 pca954x: harmonize pca9547 and pca954x and add pca9540 support
The two implementations for the pca9548 switch and the pca9547 mux
seemed close enough so we can put them together and with a bit more
abstraction add pca9540 support.

While here apply a bit of consistency in variable and driver naming and
use device_has_property instead of the FDT-only OF_ variant.

This disconnects pca9547 from the build but does not yet delete it.

Reviewed by:	mmel (earlier version), avg
Sponsored by:	Traverse Technologies (providing Ten64 HW for testing)
Differential Revision: https://reviews.freebsd.org/D35701

(cherry picked from commit 97dbd37753)
2022-07-18 01:00:20 +00:00
Bjoern A. Zeeb
74c7b2d74a tca6416: add support for tca9539
Programming-wise tca6416 and tca9539 seem identical so all we have to
do is add the extra ofw_compat_data line.

Reviewed by:	mw
Sponsored by:	Traverse Technologies (providing Ten64 HW for testing)
Differential Revision: https://reviews.freebsd.org/D35702

(cherry picked from commit c4b98101c5)
2022-07-18 00:44:05 +00:00
Bjoern A. Zeeb
e4d7f82bf5 ACPI: change arguments to internal acpi_find_dsd()
acpi_find_dsd() is not a bus function and we only need the acpi_device (ad).
The only caller has already looked up the ad (from ivars) for us.
Directly pass the ad to acpi_find_dsd() instead of bus, dev and remove
the extra call to device_get_ivars(); the changed argument also means we
now call AcpiEvaluateObject directly on the handle.

This optimisation was done a while ago while debugging a driver which
ended up with a bad bus, dev combination making the old version fail.

Reviewed by:	mw
Differential Revision: https://reviews.freebsd.org/D35558

(cherry picked from commit 945eaca155)
2022-07-18 00:43:32 +00:00
John Baldwin
46b46bb774 hwpmc: Permit the minimum sampling count to be set as a sysctl.
A rarely occurring event (e.g. an event that occurs less than 1000
times during execution of a program) may require a lower minimum
threshold than 1000.  Replace the hardcoded 1000 with a sysctl that
the administrator can use to permit smaller sampling count values.

Reviewed by:	mhorne, mav
Sponsored by:	University of Cambridge, Google, Inc.
Differential Revision:	https://reviews.freebsd.org/D35400

(cherry picked from commit ca341f3cf5)
2022-07-13 09:19:13 -07:00
Doug Moore
069ec467c1 iommu_gas: Drop needless bound check in lowermatch
The loop iteration in iommu_gas_lowermatch checks the bound
a->common->lowaddr twice per loop iteration. Rewrite to test only once
per iteration.  Do not worry about passing to iommu_gas_match_one a
range wholly beyond lowaddr. Since that function checks the upper end
of the range against lowaddr, it'll get rejected there.

Reviewed by:	alc
MFC after:	3 weeks
Differential Revision:	https://reviews.freebsd.org/D35522

(cherry picked from commit 70b5d8fa0f)
2022-07-12 12:37:48 -05:00
Doug Moore
0cbb744f96 iommu_gas: Rename a function missed earlier
Reported by:	jenkins
Fixes:	c606ab59e7 vm_extern: use standard address checkers everywhere

(cherry picked from commit cfb2aa3f53)
2022-07-12 11:26:07 -05:00
Doug Moore
c5a5a9dbcf vm_extern: use standard address checkers everywhere
Define simple functions for alignment and boundary checks and use them
everywhere instead of having slightly different implementations
scattered about. Define them in vm_extern.h and use them where
possible where vm_extern.h is included.

Reviewed by:	kib, markj
Differential Revision:	https://reviews.freebsd.org/D33685

(cherry picked from commit c606ab59e7)
2022-07-12 11:26:03 -05:00
Yuri
81fe400fb1 ipmi: do not omit lun in BMC addresses
Some systems put sensors on non-0 lun, so we should not omit it.  This
was the only difference with the Linux driver, where DIMM sensors could
be queried, but not on FreeBSD.

See this report[1] on the FreeBSD forums:
https://forums.freebsd.org/threads/freebsd-cannot-get-dimm-temperature-sensor-value.85166/

Reviewed by:	philip
Tested by:	Andrey Lanin[1]
Differential Revision: https://reviews.freebsd.org/D35612

(cherry picked from commit 177f8b3294)
2022-07-11 11:10:23 +08:00
Yuri
1549a6172f ipmi: correctly handle ipmb requests
Handle IPMB requests using SEND_MSG (sent as driver request as we do not
need to return anything back to userland for this) and GET_MSG (sent as
usual request so we can return the data for RECEIVE_MSG ioctl) pair.

This fixes fetching complete sensor data from boards (e.g. HP ProLiant
DL380 Gen10).

Reviewed by:	philip
Differential Revision: https://reviews.freebsd.org/D35605

(cherry picked from commit 18db96dbfd)
(cherry picked from commit c4995b69db)
2022-07-11 11:10:05 +08:00
Gordon Bergling
7dff1d4be7 aic7xxx: Fix a few common typos in source code comments
- s/ingnore/ignore/
- s/ingnored/ignored/

(cherry picked from commit 9bfefcea43)
2022-07-08 04:25:03 +02:00
Gordon Bergling
7e6f7610cf ata(4): Fix a typo in a source code comment
- s/fuctions/functions/

(cherry picked from commit 23781068af)
2022-07-08 04:23:56 +02:00
Gordon Bergling
dc7de3cab9 jme(4): Fix a typo in a source code comment
- s/fuctions/functions/

(cherry picked from commit 015d570cc9)
2022-07-08 04:23:41 +02:00
Gordon Bergling
9179bf221a aic7xxx: Fix a few common typo in source code comments
- s/irrespecitve/irrespective/

Obtained from:	NetBSD

(cherry picked from commit 66147d138a)
2022-07-08 04:23:25 +02:00
Gordon Bergling
23bb344ee3 pci(4): Fix a common typo in source code comments
- s/transistions/transitions/

(cherry picked from commit 00c00c3824)
2022-07-08 04:23:07 +02:00
Alan Cox
815db559ec busdma_iommu: Fine-grained locking for the dmamap's map list
Introduce fine-grained locking on the dmamap's list of map entries,
replacing the use of the domain lock.  This is not the most significant
source of lock contention, but it is the easiest to address.

Reviewed by:	kib
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D35557

(cherry picked from commit eeb46578c2)
2022-07-06 12:11:10 -05:00
Alan Cox
a408ed1c92 iommu_gas: Eliminate unnecessary wrappers
Eliminate trivial wrappers for several iommu_gas functions that serve
no functional purpose.

Reviewed by:	br, dougm, kib
MFC after:	3 weeks
Differential Revision:	https://reviews.freebsd.org/D35487

(cherry picked from commit fc2e4f15a9)
2022-07-06 12:10:52 -05:00
Alan Cox
01ebb5b8cf iommu_gas: Fix a recent regression with IOMMU_MF_CANSPLIT
As of 19bb5a7244, the IOMMU_MF_CANSPLIT case in iommu_gas_match_one()
must take into account the specified offset.  Otherwise, the recently
changed end calculation in iommu_gas_match_insert() could produce an
end address that crosses the specified boundary by one page.

Reviewed by:	dougm
MFC with:	19bb5a7244

(cherry picked from commit 7b39a9bc1d)
2022-07-06 12:01:41 -05:00
Alan Cox
cf70aef401 iommu_gas: Tidy up
Move a comment to the code that it describes.  Improve the wording.

Style fixes.

MFC after:	2 weeks

(cherry picked from commit da33f6d76b)
2022-07-06 12:00:59 -05:00
Alan Cox
895d8b1d3c iommu_gas: Add a missing error-case unlock
Release the domain lock when iommu_gas_reserve_region_extend()'s call to
iommu_gas_reserve_region_locked() fails.

MFC after:	2 weeks

(cherry picked from commit 0ba1d86082)
2022-07-06 11:53:38 -05:00
Alan Cox
1334074959 busdma_iommu: Eliminate a redundant trunc_page()
Since OFF_TO_IDX() inherently truncates the given value, there is no
need to perform trunc_page() on it.

MFC after:	2 weeks

(cherry picked from commit 32e82bcc15)
2022-07-06 11:52:52 -05:00
Alan Cox
fed2c1ce8f iommu_gas: Eliminate a stale comment
As of 19bb5a7244, the size passed to iommu_gas_map is no longer
required to be a multiple of the CPU page size.

MFC after:	2 weeks

(cherry picked from commit 164491fb03)
2022-07-06 11:52:06 -05:00
Alan Cox
8c1edfe309 iommu_gas: Correct a broken KASSERT
If iommu_gas_find_space() ever called iommu_gas_uppermatch(), and it
succeeded in allocating space, then the subsequent KASSERT would be
triggered.  Change that KASSERT to accept either success or ENOMEM.

MFC after:	1 week

(cherry picked from commit e6775534ae)
2022-07-06 11:51:05 -05:00
Doug Moore
3a33ebe65f iommu_gas: make iommu_gas_lowermatch non-recursive
Change the recursive implementation to one that uses parent pointers
to walk back up the rb-tree, to slightly improve performance.

Reviewed by:	alc, kib
MFC after:	3 weeks
Differential Revision:	https://reviews.freebsd.org/D35486

(cherry picked from commit f979ad0030)
2022-07-06 11:43:37 -05:00
Doug Moore
9b12e43d1f iommu_gas: use to first-fit search for lowermatch
Reverse the order of the search for a free space in lowermatch, to
make it a first-fit search. Iommu_gas_match_one always allocates from
the beginning of the free gap discovered from searching the tree, so
the current code isn't really allocating in a reverse first-fit
anyway, and making the search first-fit reduces the number of iommu
page table pages that are used.

Reported by:	alc
Reviewed by:	alc, kib
MFC after:	3 weeks
Differential Revision:	https://reviews.freebsd.org/D35458

(cherry picked from commit 975715b788)
2022-07-06 11:42:48 -05:00
Doug Moore
2d8b9313f4 iommu_gas: pass size to iommu_map without rounding
Let the caller to iommu_map pass the size parameter without rounding
it up to a multiple of page size.  Let iommu_map round it up when
necessary, which is not all of the time, so that in some cases less
space is reserved.

Reviewed by:	alc, kib (previous version)
Tested by:	pho, br
Discussed with:	andrew
MFC after:	3 weeks
Differential Revision:	https://reviews.freebsd.org/D35424

(cherry picked from commit 19bb5a7244)
2022-07-06 11:41:50 -05:00
Doug Moore
80ad47c932 iommu_gas: Change find_space lower search order
iommu_gas_lowermatch looks right, then left, then right again in its
search for free space.  Change to a more straightforward last-fit
search that touches fewer tree nodes and improves performance.

Reported by:	wxzhu@rice.edu
Reviewed by:	alc, kib
MFC after:	3 weeks
Differential Revision:	https://reviews.freebsd.org/D35439

(cherry picked from commit 3003117253)
2022-07-06 11:39:17 -05:00
Mitchell Horne
b475ab8c78 hwpmc: don't validate capabilities in allocation method
These checks were inconsistently applied across the various hwpmc
classes. The condition is already checked by the generic code in
hwpmc_mod.c, so remove them.

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

(cherry picked from commit 0e78510b75)
2022-07-05 12:39:02 -04:00
Mitchell Horne
1e8f338d7f hwpmc: consistently validate PMC class in allocation method
It is always a good idea. In one case, attempting to allocate N+1 PMCs
from a class with N hardware counters would incorrectly attempt to
allocate from the next class in the list. Without this validation, this
can lead to all kinds of strange behaviour.

Since powerpc_allocate_pmc() is used by both the mpc7xxx and ppc970
classes, add a new global to track which is active (it will never be
both).

Reviewed by:	luporl, ray
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D31387

(cherry picked from commit 315cd55dba)
2022-07-05 12:38:52 -04:00
Hans Petter Selasky
d4dd3c8f8b vt: Improve multi lingual word separation.
Suggested by:	Tomoaki AOKI <junchoon@dec.sakura.ne.jp>
Differential Revision:	https://reviews.freebsd.org/D35552
PR:		263084
Sponsored by:	NVIDIA Networking

(cherry picked from commit 9971e6aff1)
2022-07-05 13:42:28 +02:00
Hans Petter Selasky
4437a2e1dd vt: Fix contents of paste buffer for newcons.
Trim all word separators from end of line, except for last line and
only use '\r' to terminate the pasted lines as expected by TTY.

Submitted by:	Ivan Quitschal <tezeka@hotmail.com>
Differential Revision:	https://reviews.freebsd.org/D35552
PR:		263084
Sponsored by:	NVIDIA Networking

(cherry picked from commit 5fe0a82501)
2022-07-05 13:42:28 +02:00
Alexander Motin
5c55abaf08 hwpmc: Reenable PME before reenabling counters.
Doing otherwise may lead to lost interrupts, that in combination
with hardware PMCs freezing may leave them frozen forever.  It may
also slightly improve profiling accuracy.

MFC after:	2 weeks

(cherry picked from commit f9e62419f6)
2022-07-04 13:48:10 -04:00
Alexander Motin
194796b386 hwpmc: Correct sysctl description.
MFC after:	2 weeks

(cherry picked from commit 918505d0a0)
2022-07-04 13:48:10 -04:00
Alexander Motin
6a69bfc8d5 hwpmc: Increase thread priority while iterating CPUs.
This allows to profile already running high-priority threads, that
otherwise by blocking thread migration to respective CPUs blocked PMC
management, i.e. profiling could start only when workload completed.

While there, return the thread to its original CPU after iterating
the list.  Otherwise all threads using PMC end up on the last CPU.

MFC after:	1 month

(cherry picked from commit eff9ee7c0c)
2022-07-04 13:48:10 -04:00
Alexander Motin
56294dd6b1 hwpmc: Add IDs for few more Intel Atom CPUs.
MFC after:	1 month

(cherry picked from commit 1326017849)
2022-07-04 13:48:10 -04:00