Commit Graph

43 Commits

Author SHA1 Message Date
John Baldwin
83a273efce dev/amd*: Remove unused devclass arguments to DRIVER_MODULE. 2022-05-09 12:22:00 -07:00
Alexander Motin
6c101ed7a3 amdtemp: Remove CTLFLAG_NEEDGIANT from sysctls.
It seems to be needed only to serialize very old K8 registers access.
Introduce separate lock for that and remove Giant dependency.

MFC after:	2 weeks
2021-12-25 21:03:54 -05:00
Mateusz Guzik
b9723c5ba9 amdtemp: plug set-but-not-used vars
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2021-12-09 16:37:26 +00:00
Cy Schubert
db0ac6ded6 Revert "wpa: Import wpa_supplicant/hostapd commit 14ab4a816"
This reverts commit 266f97b5e9, reversing
changes made to a10253cffe.

A mismerge of a merge to catch up to main resulted in files being
committed which should not have been.
2021-12-02 14:45:04 -08:00
Cy Schubert
266f97b5e9 wpa: Import wpa_supplicant/hostapd commit 14ab4a816
This is the November update to vendor/wpa committed upstream 2021-11-26.

MFC after:      1 month
2021-12-02 13:35:14 -08:00
Alexander Motin
94a72c5ac4 amdtemp: Revert related part of "Make CPU children" commit.
While it still looks like previous code worked by coincidence, this
change broke things even more instead of fixing.

Reported by:	avg@
MFC after:	1 week
2021-12-01 13:04:31 -05:00
Alexander Motin
d3a8f98acb Make CPU children explicitly share parent unit numbers.
Before this device unit number match was coincidental and broke if I
disabled some CPU device(s).  Aside of cosmetics, for some drivers
(may be considered broken) it caused talking to wrong CPUs.
2021-09-24 23:31:51 -04:00
Conrad Meyer
b499ab877f amdtemp(4): Add missing Family 17h models
Add missing model numbers M20h (Dali, Zen1), M60H (Renoir, Zen2), and
M90H (Van Gogh, Zen2).

Submitted by:	Greg V <greg AT unrelenting.technology>
2020-12-12 19:43:38 +00:00
Conrad Meyer
ea6189d3a4 amdsmn(4), amdtemp(4): add support for Family 19h (Zen 3)
Zen 3 "Vermeer" support, tested on Ryzen 9 5950X.

Model numbers from https://en.wikichip.org/wiki/amd/cpuid "Extended
Model" column.

Submitted by:	Greg V <greg AT unrelenting.technology>
Differential Revision:	https://reviews.freebsd.org/D27552
2020-12-12 19:34:12 +00:00
Conrad Meyer
5b50517079 amdtemp(4), amdsmn(4): Attach to Ryzen 4000 APU (Zen 2, "Renoir")
PR:		249864
Reported by:	Florian Millet <florian.millet AT laposte.net>
Tested by:	Florian Millet
2020-09-25 04:16:28 +00:00
Kyle Evans
c79cee7136 kernel: provide panicky version of __unreachable
__builtin_unreachable doesn't raise any compile-time warnings/errors on its
own, so problems with its usage can't be easily detected. While it would be
nice for this situation to change and compilers to at least add a warning
for trivial cases where local state means the instruction can't be reached,
this isn't the case at the moment and likely will not happen.

This commit adds an __assert_unreachable, whose intent is incredibly clear:
it asserts that this instruction is unreachable. On INVARIANTS builds, it's
a panic(), and on non-INVARIANTS it expands to  __unreachable().

Existing users of __unreachable() are converted to __assert_unreachable,
to improve debuggability if this assumption is violated.

Reviewed by:	mjg
Differential Revision:	https://reviews.freebsd.org/D23793
2020-05-13 18:07:37 +00:00
Pawel Biernacki
7029da5c36 Mark more nodes as CTLFLAG_MPSAFE or CTLFLAG_NEEDGIANT (17 of many)
r357614 added CTLFLAG_NEEDGIANT to make it easier to find nodes that are
still not MPSAFE (or already are but aren’t properly marked).
Use it in preparation for a general review of all nodes.

This is non-functional change that adds annotations to SYSCTL_NODE and
SYSCTL_PROC nodes using one of the soon-to-be-required flags.

Mark all obvious cases as MPSAFE.  All entries that haven't been marked
as MPSAFE before are by default marked as NEEDGIANT

Approved by:	kib (mentor, blanket)
Commented by:	kib, gallatin, melifaro
Differential Revision:	https://reviews.freebsd.org/D23718
2020-02-26 14:26:36 +00:00
Conrad Meyer
cc3b01385b amdtemp(4): Remove dead code that snuck in with r357190
I intended to remove this before committing, but neglected to.
2020-01-28 03:27:06 +00:00
Conrad Meyer
c59b9a4f8d amdtemp(4): Add support for Family 17h CCD sensors
Probe Family 17h CPUs for up to 4 (Zen, Zen+) or 8 (Zen2) CCD temperature
sensors.  These were discovered by Ondrej Čerman
(https://github.com/ocerman) and collaborators experimentally, and are not
currently documented in any datasheet I have access to.
2020-01-28 01:39:50 +00:00
Conrad Meyer
02f7000293 amdtemp(4): Refactor shared temperature calculation logic
No functional change intended.
2020-01-28 01:38:51 +00:00
Conrad Meyer
85dbddbe14 amdtemp(4), amdsmn(4): Attach to Ryzen 3 (Zen 2) hostbridges
PR:	239607
Reported by:	"drclaw" <drclaw AT gmail.com>
2019-08-06 03:54:27 +00:00
Conrad Meyer
e49ec46114 amdtemp(4): Add support for Family 15h, Model >=60h
Family 15h is a bit of an oddball.  Early models used the same temperature
register and spec (mostly[1]) as earlier CPU families.

Model 60h-6Fh and 70-7Fh use something more like Family 17h's Service
Management Network, communicating with it in a similar fashion.  To support
them, add support for their version of SMU indirection to amdsmn(4) and use
it in amdtemp(4) on these models.

While here, clarify some of the deviceid macros in amdtemp(4) that were
added with arbitrary, incorrect family numbers, and remove ones that were
not used.  Additionally, clarify intent and condition of heterogenous
multi-socket system detection.

[1]: 15h adds the "adjust range by -49°C if a certain condition is met,"
which previous families did not have.

Reported by:	D. C. <tjoard AT gmail.com>
PR:		234657
Tested by:	D. C. <tjoard AT gmail.com>
2019-01-12 22:36:33 +00:00
Conrad Meyer
fbd5d78209 amdtemp(4): Fix temperature reporting on AMD 2990WX
Update the AMD family 17h temperature reporting based on AMD Tech Doc 56255
OSRR, section 4.2.1.

For CPUS w/CUR_TEMP_RANGE_SEL set, scale the reported temperature into the
range -49..206; i.e., subtract 49°C.

Submitted by:	gallatin@
Reported by:	bcran@
Reviewed by:	me (long ago)
MFC after:	22.57 seconds
Relnotes:	yea
Differential Revision:	https://reviews.freebsd.org/D16855
2018-11-14 04:50:29 +00:00
Conrad Meyer
9d49c4229a amdsmn(4)/amdtemp(4): Attach to Ryzen 2 hostbridges
As reported, tested, and patch supplied by Johannes.

There may be future work to do to support multiple sensors, but for now, any
sensor at all is a strict improvement for Ryzen 2 systems.

PR:		228480
Submitted by:	Johannes Lundberg <johalun0 AT gmail.com> (earlier version)
Reported by:	deischen@, Johannes, and numerous others
MFC after:	3.72 days
2018-11-14 03:42:39 +00:00
Warner Losh
329e817fcc Reapply, with minor tweaks, r338025, from the original commit:
Remove unused and easy to misuse PNP macro parameter

Inspired by r338025, just remove the element size parameter to the
MODULE_PNP_INFO macro entirely.  The 'table' parameter is now required to
have correct pointer (or array) type.  Since all invocations of the macro
already had this property and the emitted PNP data continues to include the
element size, there is no functional change.

Mostly done with the coccinelle 'spatch' tool:

  $ cat modpnpsize0.cocci
    @normaltables@
    identifier b,c;
    expression a,d,e;
    declarer MODULE_PNP_INFO;
    @@
     MODULE_PNP_INFO(a,b,c,d,
    -sizeof(d[0]),
     e);

    @singletons@
    identifier b,c,d;
    expression a;
    declarer MODULE_PNP_INFO;
    @@
     MODULE_PNP_INFO(a,b,c,&d,
    -sizeof(d),
     1);

  $ rg -l MODULE_PNP_INFO -- sys | \
    xargs spatch --in-place --sp-file modpnpsize0.cocci

(Note that coccinelle invokes diff(1) via a PATH search and expects diff to
tolerate the -B flag, which BSD diff does not.  So I had to link gdiff into
PATH as diff to use spatch.)

Tinderbox'd (-DMAKE_JUST_KERNELS).
Approved by: re (glen)
2018-09-26 17:12:14 +00:00
Conrad Meyer
b8e771e97a Back out r338035 until Warner is finished churning GSoC PNP patches
I was not aware Warner was making or planning to make forward progress in
this area and have since been informed of that.

It's easy to apply/reapply when churn dies down.
2018-08-19 00:46:22 +00:00
Conrad Meyer
faa319436f Remove unused and easy to misuse PNP macro parameter
Inspired by r338025, just remove the element size parameter to the
MODULE_PNP_INFO macro entirely.  The 'table' parameter is now required to
have correct pointer (or array) type.  Since all invocations of the macro
already had this property and the emitted PNP data continues to include the
element size, there is no functional change.

Mostly done with the coccinelle 'spatch' tool:

  $ cat modpnpsize0.cocci
    @normaltables@
    identifier b,c;
    expression a,d,e;
    declarer MODULE_PNP_INFO;
    @@
     MODULE_PNP_INFO(a,b,c,d,
    -sizeof(d[0]),
     e);

    @singletons@
    identifier b,c,d;
    expression a;
    declarer MODULE_PNP_INFO;
    @@
     MODULE_PNP_INFO(a,b,c,&d,
    -sizeof(d),
     1);

  $ rg -l MODULE_PNP_INFO -- sys | \
    xargs spatch --in-place --sp-file modpnpsize0.cocci

(Note that coccinelle invokes diff(1) via a PATH search and expects diff to
tolerate the -B flag, which BSD diff does not.  So I had to link gdiff into
PATH as diff to use spatch.)

Tinderbox'd (-DMAKE_JUST_KERNELS).
2018-08-19 00:22:21 +00:00
Pedro F. Giffuni
718cf2ccb9 sys/dev: further adoption of SPDX licensing ID tags.
Mainly focus on files that use BSD 2-Clause license, however the tool I
was using misidentified many licenses so this was mostly a manual - error
prone - task.

The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.
2017-11-27 14:52:40 +00:00
Conrad Meyer
a64bf59c49 Add PNP metadata to a few drivers
An eventual devd(8) or other component should be able to scan buses and
automatically load drivers that match device ids described in this metadata.

Reviewed by:	imp
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D12364
2017-09-14 15:34:45 +00:00
Conrad Meyer
40f7bccb5d amdtemp(4): Do not probe not matching hostbridges
Some systems have hostbs that do not match our PCI device id criteria.
Detect and ignore these devices in probe.

PR:		218264
Sponsored by:	Dell EMC Isilon
2017-09-05 20:35:25 +00:00
Conrad Meyer
a03d621bfa amdtemp(4): Add support for Family 17h temperature sensor
The sensor value is formatted similarly to previous models (same
bitfield sizes, same units), but must be read off of the internal
System Management Network (SMN) from the System Management Unit (SMU)
co-processor.

PR:		218264
Reported and tested by:	Nils Beyer <nbe AT renzel.net>
Reviewed by:	avg (no +1), mjoras, truckman
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D12217
2017-09-05 15:19:14 +00:00
Luiz Otavio O Souza
9d6672e13b Fix the deciKelvin to Celsius conversion in kernel.
After r285994, sysctl(8) was fixed to use 273.15 instead of 273.20 as 0C
reference and as result, the temperature read in sysctl(8) now exibits a
+0.1C difference.

This commit fix the kernel references to match the reference value used in
sysctl(8) after r285994.

Sponsored by:	Rubicon Communications (Netgate)
2016-05-22 13:58:32 +00:00
Luiz Otavio O Souza
df20515d58 Add PCI ID for family 10h model 30h to amdtemp(4).
This adds support to CPU found in PC Engines APU2 series.

MFC after:	3 weeks
Sponsored by:	Rubicon Communications (Netgate)
2016-04-19 15:07:04 +00:00
Christian Brueffer
9bfafa1055 Add one more AMD Kaveri APU device ID.
Submitted by:	Remy Nonnenmacher <remy.nonnenmacher@activnetworks.com>
MFC after:	1 week
2014-10-13 13:13:42 +00:00
Christian Brueffer
2b56f12b7e Add support for AMD Family 16h (Kabini) sensor devices.
PR:		186587
Submitted by:	David Rufino <david.rufino at gmail.com>
MFC after:	2 weeks
2014-03-14 12:15:28 +00:00
John-Mark Gurney
534b11a131 Add support for my:
CPU: AMD A10-5700 APU with Radeon(tm) HD Graphics    (3393.89-MHz K8-class CPU)
2013-08-26 17:38:36 +00:00
Sofian Brabez
61bfd86762 Use DEVMETHOD_END macro defined in sys/bus.h instead of {0, 0} sentinel on device_method_t arrays
Reviewed by:	cognet
Approved by:	cognet
2013-01-30 18:01:20 +00:00
Eitan Adler
a8de37b024 This isn't functionally identical. In some cases a hint to disable
unit 0 would in fact disable all units.

This reverts r241856

Approved by: cperciva (implicit)
2012-10-22 13:06:09 +00:00
Eitan Adler
76b7512247 Now that device disabling is generic, remove extraneous code from the
device drivers that used to provide this feature.

Reviewed by:	des
Approved by:	cperciva
MFC after:	1 week
2012-10-22 03:41:14 +00:00
Jung-uk Kim
074d80ac13 - Add support for Family 12h, 14h and 15h processors.
- Remove all attempts to guess physical temperature using DiodeOffset.
There are too many reports that it varies wildly depending on motherboard.
Instead, if it is known to scale well and its offset is known from other
temperature sensors on board, the user may set "dev.amdtemp.0.sensor_offset"
tunable to compensate the difference.  Document the caveats in amdtemp(4).
- Add a quirk for Socket AM2 Revision G processors.  These processors are
known to have a different offset according to Linux k8temp driver.
- Warn about Family 10h Erratum 319.  These processors have broken sensors.
- Report temperature in more logical orders under dev.amdtemp node.  For
example, "dev.amdtemp.0.sensor0.core0" is now "dev.amdtemp.0.core0.sensor0".
- Replace K8, K10 and K11 with official processor names in amdtemp(4).
2012-02-24 00:02:46 +00:00
Jung-uk Kim
fdfa6079a2 Restore (undocumented) support for early revisions and add more comments.
Reported by:	kris
2009-09-14 23:08:19 +00:00
Jung-uk Kim
7ca2d97bbd Fix typos in comments from the previous commit. 2009-09-11 22:05:59 +00:00
Jung-uk Kim
a4165bba6f Improve amdtemp(4) significantly:
- Improve newer AMD processor support (Family 0Fh Revision F and later).
- Adjust offset if DiodeOffet is set and valid.  Note it is experimental
but it seems to give us more realistic temperatures.  Newer Linux driver
blindly adds 21C for Family 0Fh desktop processors, however.
- Always populate dev.cpu and dev.amdtemp sysctl trees regardless of probe
order for consistency.  Previously, dev.cpu.N.temperature was not populated
if amdtemp was loaded later than ACPI CPU driver and temperatures were not
accessible from dev.amdtemp.N.sensor0 tree for Family 10h/11h processors.
- Read the CPUID from PCI register instead of CPUID instruction to prevent
possible revision mismatches on multi-socket system.
- Change macros and variables to make them closer to AMD documents.
- Fix style(9) nits and improve comments.
2009-09-11 21:47:44 +00:00
John Baldwin
a56fe095f0 Temporarily revert the new-bus locking for 8.0 release. It will be
reintroduced after HEAD is reopened for commits by re@.

Approved by:	re (kib), attilio
2009-08-20 19:17:53 +00:00
Attilio Rao
444b91868b Make the newbus subsystem Giant free by adding the new newbus sxlock.
The newbus lock is responsible for protecting newbus internIal structures,
device states and devclass flags. It is necessary to hold it when all
such datas are accessed. For the other operations, softc locking should
ensure enough protection to avoid races.

Newbus lock is automatically held when virtual operations on the device
and bus are invoked when loading the driver or when the suspend/resume
take place. For other 'spourious' operations trying to access/modify
the newbus topology, newbus lock needs to be automatically acquired and
dropped.

For the moment Giant is also acquired in some key point (modules subsystem)
in order to avoid problems before the 8.0 release as module handlers could
make assumptions about it. This Giant locking should go just after
the release happens.

Please keep in mind that the public interface can be expanded in order
to provide more support, if there are really necessities at some point
and also some bugs could arise as long as the patch needs a bit of
further testing.

Bump __FreeBSD_version in order to reflect the newbus lock introduction.

Reviewed by:    ed, hps, jhb, imp, mav, scottl
No answer by:   ariff, thompsa, yongari
Tested by:      pho,
                G. Trematerra <giovanni dot trematerra at gmail dot com>,
                Brandon Gooch <jamesbrandongooch at gmail dot com>
Sponsored by:   Yahoo! Incorporated
Approved by:	re (ksmith)
2009-08-02 14:28:40 +00:00
Rui Paulo
869041cd77 Fix comment explaining where this driver came from.
MFC after:	2 weeks
2009-03-13 16:43:31 +00:00
Rui Paulo
454e82d77e Rename all the variables/function names/structs/etc. to reflect the
driver name change.
While there, update copyright.

MFC after:	2 weeks
2009-03-13 16:28:25 +00:00
Rui Paulo
fc1f75e512 Rename the k8temp driver to amdtemp.
MFC after:	2 weeks
2009-03-13 16:08:08 +00:00