Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 4 Oct 2017 18:15:05 +0300
From:      Vasily Postnicov <shamaz.mazum@gmail.com>
To:        freebsd-hackers@freebsd.org
Subject:   hwmon status in FreeBSD and radeon driver.
Message-ID:  <CADnZ6BkqBgwoe4vJwidFxv1TaBg_z_EfffDBUwt4Q%2BZGEVdaYg@mail.gmail.com>

next in thread | raw e-mail | index | archive | help

[-- Attachment #1 --]
Hello. I have created a thread on FreeBSD forums but was redirected here.
Its about temperature sensors for AMD Radeon graphic cards which is present
in FreeBSD code but is surrounded by #ifdef FREEBSD_WIP ... #endif macros.
It relays on hwmon from Linux and does not work. I suggest to replace
hwmon-dependent parts with traditional sysctl variables either temporary or
permanently (which depends on status of hwmon in FreeBSD, in other words
are there plans to port it or not).

https://forums.freebsd.org/threads/62714/

I would like to send a patch but I do not know how to deal with hwmon
parts. I attach a patch which I use on my system

[-- Attachment #2 --]
From d1729722122c6aeb770d84d1c1374c8902364fe4 Mon Sep 17 00:00:00 2001
From: Charlie Root <shamaz.mazum@gmail.com>
Date: Mon, 2 Oct 2017 20:47:01 +0300
Subject: [PATCH] Unlock temperature sensors for radeon

---
 sys/dev/drm2/radeon/radeon_pm.c | 45 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 45 insertions(+)

diff --git a/sys/dev/drm2/radeon/radeon_pm.c b/sys/dev/drm2/radeon/radeon_pm.c
index 18d800334be..ac36b677220 100644
--- a/sys/dev/drm2/radeon/radeon_pm.c
+++ b/sys/dev/drm2/radeon/radeon_pm.c
@@ -22,6 +22,9 @@
  */
 
 #include <sys/cdefs.h>
+#include <sys/param.h>
+#include <sys/sysctl.h>
+#include <sys/bus.h>
 __FBSDID("$FreeBSD$");
 
 #include <dev/drm2/drmP.h>
@@ -488,6 +491,42 @@ static struct attribute *hwmon_attributes[] = {
 static const struct attribute_group hwmon_attrgroup = {
 	.attrs = hwmon_attributes,
 };
+#else /* FREEBSD_WIP */
+
+static int sysctl_radeon_temp (SYSCTL_HANDLER_ARGS)
+{
+	device_t dev = oidp->oid_arg1;;
+	struct drm_device *ddev = device_get_softc(dev);
+	struct radeon_device *rdev = ddev->dev_private;
+	int temp, err;
+
+	switch (rdev->pm.int_thermal_type) {
+	case THERMAL_TYPE_RV6XX:
+		temp = rv6xx_get_temp(rdev);
+		break;
+	case THERMAL_TYPE_RV770:
+		temp = rv770_get_temp(rdev);
+		break;
+	case THERMAL_TYPE_EVERGREEN:
+	case THERMAL_TYPE_NI:
+		temp = evergreen_get_temp(rdev);
+		break;
+	case THERMAL_TYPE_SUMO:
+		temp = sumo_get_temp(rdev);
+		break;
+	case THERMAL_TYPE_SI:
+		temp = si_get_temp(rdev);
+		break;
+	default:
+		temp = 0;
+		break;
+	}
+
+	temp += 273150;
+	err = sysctl_handle_int (oidp, &temp, 0, req);
+	return err;
+}
+
 #endif /* FREEBSD_WIP */
 
 static int radeon_hwmon_init(struct radeon_device *rdev)
@@ -524,6 +563,12 @@ static int radeon_hwmon_init(struct radeon_device *rdev)
 				"Unable to create hwmon sysfs file: %d\n", err);
 			hwmon_device_unregister(rdev->dev);
 		}
+#else /* FREEBSD_WIP */
+        device_printf (rdev->dev, "Adding temperature sysctl\n");
+        SYSCTL_ADD_PROC (device_get_sysctl_ctx (rdev->dev),
+                         SYSCTL_CHILDREN(device_get_sysctl_tree (rdev->dev)), OID_AUTO,
+                         "temperature", CTLFLAG_RD | CTLTYPE_INT, rdev->dev, sizeof (rdev->dev),
+                         sysctl_radeon_temp, "IK3", "Radeon card temperature");
 #endif /* FREEBSD_WIP */
 		break;
 	default:
-- 
2.14.1


Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CADnZ6BkqBgwoe4vJwidFxv1TaBg_z_EfffDBUwt4Q%2BZGEVdaYg>