Skip to contentSkip to conversation

hwmon: add support for GM/GME965

PATCH In review lu zhihe 3 participants 9 messages Jul 9, 2009 – Oct 8, 2009

lore
Share & tools
lore

lu zhihe

author
#0 lore raw

PATCH 1/1 hwmon: add support for GM/GME965

From: Lu Zhihe <[email protected]>

Subject: [PATCH] hwmon: add support for GM/GME965 IGP temperature report.

Exported the graphics hot spot temperature report via sysfs.

---

Add GM/GME965 IGP temperature report for hwmon.

The GM/GME965 datasheet can get from:
http://www.intel.com/Assets/PDF/datasheet/316273.pdf

The Calibration Fomula comes from a earlier version:
http://www.intel.com/design/chipsets/datashts/313053.htm
Page 358.

diff -uprN linux-2.6.31-rc2.orig/drivers/hwmon/Kconfig linux-2.6.31-rc2/drivers/hwmon/Kconfig
--- linux-2.6.31-rc2.orig/drivers/hwmon/Kconfig 2009-07-08
23:26:56.000000000 +0000
+++ linux-2.6.31-rc2/drivers/hwmon/Kconfig 2009-07-08 22:49:37.000000000 +0000
@@ -401,6 +401,16 @@ config SENSORS_GL520SM
This driver can also be built as a module. If so, the module will be called gl520sm.

+config SENSORS_GM965

+        tristate "Intel GM965 temperature sensor"
+        depends on PCI
+        help

+ If you say yes here you get support for GM965 IGP temperatue
+ sensor.
+
+ This driver can also be built as a module. If so, the module
+ will be called gm965temp.
+
config SENSORS_CORETEMP
tristate "Intel Core (2) Duo/Solo temperature sensor" depends on X86 && EXPERIMENTAL
diff -uprN linux-2.6.31-rc2.orig/drivers/hwmon/Makefile linux-2.6.31-rc2/drivers/hwmon/Makefile
--- linux-2.6.31-rc2.orig/drivers/hwmon/Makefile 2009-07-08
23:27:07.000000000 +0000
+++ linux-2.6.31-rc2/drivers/hwmon/Makefile 2009-07-08 22:48:02.000000000 +0000
@@ -46,6 +46,7 @@ obj-$(CONFIG_SENSORS_FSCPOS) += fscpos.o
obj-$(CONFIG_SENSORS_G760A) += g760a.o
obj-$(CONFIG_SENSORS_GL518SM) += gl518sm.o
obj-$(CONFIG_SENSORS_GL520SM) += gl520sm.o
+obj-$(CONFIG_SENSORS_GM965) += gm965temp.o
obj-$(CONFIG_SENSORS_ULTRA45) += ultra45_env.o
obj-$(CONFIG_SENSORS_HDAPS) += hdaps.o
obj-$(CONFIG_SENSORS_I5K_AMB) += i5k_amb.o
diff -uprN linux-2.6.31-rc2.orig/drivers/hwmon/gm965temp.c linux-2.6.31-rc2/drivers/hwmon/gm965temp.c
--- linux-2.6.31-rc2.orig/drivers/hwmon/gm965temp.c 1970-01-01
00:00:00.000000000 +0000
+++ linux-2.6.31-rc2/drivers/hwmon/gm965temp.c 2009-07-09
20:25:12.000000000 +0000
@@ -0,0 +1,348 @@
+/*
+ * A hwmon driver for the Intel GM/GME965 chipset IGP
+ * temperature sensors
+ *
+ * Copyright (C) 2009 Lu Zhihe <tombowfly at gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include <linux/module.h>
+#include <linux/jiffies.h>
+#include <linux/hwmon.h>
+#include <linux/hwmon-sysfs.h>
+#include <linux/err.h>
+#include <linux/mutex.h>
+#include <linux/delay.h>
+#include <linux/pci.h>
+#include <linux/platform_device.h>
+
+#define DRVNAME "gm965temp"
+
+enum { SHOW_TEMP, SHOW_LABEL } SHOW;
+

+#define PCI_DEVICE_ID_INTEL_82965GM       0x2a00
+#define PCI_DEVICE_ID_INTEL_82965GME      0x2a10
+#define GM965_SYSFS_NAME_LEN              16

+
+#define MCHBAR_I965 0x48 /* MCH Memory Mapped Register BAR */
+#define MCHBAR_MASK 0xfffffc000ULL /* bits 35:14 */
+
+static ssize_t show_label(struct device *dev,
+ struct device_attribute *devattr,
+ char *buf);
+
+static ssize_t show_igp_temp(struct device *dev,
+ struct device_attribute *devattr,
+ char *buf);
+
+struct gm965temp_data {
+ struct device *hwmon_dev;
+ struct mutex update_lock;
+
+ u64 igp_base;
+ unsigned long igp_len;
+ void __iomem *igp_mmio;
+ unsigned long chipset_id;
+};
+
+static ssize_t show_name(struct device *dev, struct device_attribute *devattr,
+ char *buf)
+{
+ return sprintf(buf, "%s\n", DRVNAME);
+}
+
+static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_igp_temp, NULL, SHOW_TEMP);
+static SENSOR_DEVICE_ATTR(temp1_label, S_IRUGO, show_label, NULL, SHOW_LABEL); +static DEVICE_ATTR(name, S_IRUGO, show_name, NULL);
+
+static struct attribute *gm965temp_attributes[] = {
+ &sensor_dev_attr_temp1_label.dev_attr.attr,
+ &sensor_dev_attr_temp1_input.dev_attr.attr,
+ NULL
+};
+
+static const struct attribute_group gm965temp_group = {
+ .attrs = gm965temp_attributes,
+};
+
+static struct platform_device *igp_pdev;
+
+static u8 igp_read_byte(struct gm965temp_data *data, unsigned long offset) +{
+ return ioread8(data->igp_mmio + offset);
+}
+
+static u16 igp_read_short(struct gm965temp_data *data, unsigned long offset) +{
+ return ioread16(data->igp_mmio + offset);
+}
+
+static void igp_write_short(struct gm965temp_data *data, unsigned long offset,
+ u16 val)
+{
+ iowrite16(val, data->igp_mmio + offset);
+}
+
+static ssize_t show_label(struct device *dev,
+ struct device_attribute *devattr,
+ char *buf)
+{
+ return sprintf(buf, "GM965 IGP temperature report\n");
+}
+
+#define TSC1 0x1001
+#define TSS1 0x1004
+#define TR1 0x1006
+
+#define TSE 0x8000
+#define TMOV (0x01 << 10)
+
+#define MAX_RETRIS 3
+
+static ssize_t show_igp_temp(struct device *dev,
+ struct device_attribute *devattr,
+ char *buf)
+{
+ struct gm965temp_data *data = dev_get_drvdata(dev);
+ unsigned short tsc1_val = 0;
+ unsigned char tr1_val = 0;
+ unsigned short tss1_val = 0;
+ unsigned long temp = 0;
+ int i = 0;
+ i = MAX_RETRIS;
+
+ mutex_lock(&data->update_lock);
+
+ tsc1_val = igp_read_short(data, TSC1);
+
+ if (!(tsc1_val & TSE)) {
+ igp_write_short(data, TSC1, tsc1_val|TSE);
+ tsc1_val = igp_read_short(data, TSC1);
+ } else {
+try_againt:
+ tss1_val = igp_read_short(data, TSS1);
+
+ if (tss1_val & TMOV) {
+ tr1_val = igp_read_byte(data, TR1);
+ if ((tr1_val != 0xFF) && (tr1_val != 0x0))
+ temp = (16*tr1_val*tr1_val - 11071*tr1_val + 1610500)
+ /10;
+ } else {
+ do {
+ mdelay(1);
+ udelay(300);
+ goto try_againt;
+ } while (i--);
+ }
+ }
+
+ mutex_unlock(&data->update_lock);
+ return sprintf(buf, "%d\n", (unsigned int)temp);
+}
+
+static int __devinit gm965temp_hwmon_init(struct platform_device *pdev) +{
+ int res = 0;
+ struct gm965temp_data *data = platform_get_drvdata(pdev);
+
+ res = device_create_file(&pdev->dev, &dev_attr_name);
+ if (res)
+ goto exit_remove;
+
+ res = sysfs_create_group(&pdev->dev.kobj, &gm965temp_group);
+ if (res)
+ goto exit_dev;
+
+ data->hwmon_dev = hwmon_device_register(&pdev->dev);
+ if (IS_ERR(data->hwmon_dev)) {
+ res = PTR_ERR(data->hwmon_dev);
+ goto exit_remove;
+ }
+
+ return res;
+
+exit_remove:
+ sysfs_remove_group(&pdev->dev.kobj, &gm965temp_group);
+exit_dev:
+ device_remove_file(&pdev->dev, &dev_attr_name);
+
+ return res;
+}
+
+static int __devinit gm965temp_add(void)
+{
+ int res = -ENODEV;
+
+ /* only ever going to be one of these */
+ igp_pdev = platform_device_alloc(DRVNAME, 0);
+ if (!igp_pdev)
+ return -ENOMEM;
+
+ res = platform_device_add(igp_pdev);
+ if (res)
+ goto err;
+ return 0;
+
+err:
+ platform_device_put(igp_pdev);
+ return res;
+}
+
+static int __devinit gm965_find_igp_registers(struct gm965temp_data *data,
+ unsigned long devid)
+{
+ struct pci_dev *pcidev;
+ u32 val32;
+ u64 val64 = 0x0ULL;
+ int res = -ENODEV;
+
+ pcidev = pci_get_device(PCI_VENDOR_ID_INTEL,
+ devid,
+ NULL);
+ if (!pcidev) {
+ printk(KERN_ERR "pci_get_device failed\n");
+ return -ENODEV;
+ }
+
+ if (pci_read_config_dword(pcidev, MCHBAR_I965 + 4, &val32))
+ goto out;
+ val64 = (u64)val32;
+ val64 <<= 32;
+ if (pci_read_config_dword(pcidev, MCHBAR_I965, &val32))
+ goto out;
+
+ val64 |= val32;
+ data->igp_base = val64 & MCHBAR_MASK;
+ data->igp_len = 16*1024;
+
+ data->chipset_id = devid;
+
+ res = 0;
+out:
+ pci_dev_put(pcidev);
+ return res;
+}
+
+static unsigned long chipset_ids[] = {
+ PCI_DEVICE_ID_INTEL_82965GM,
+ PCI_DEVICE_ID_INTEL_82965GME,
+ 0
+};
+
+static int __devinit gm965temp_probe(struct platform_device *pdev) +{
+ struct gm965temp_data *data;
+ struct resource *reso;
+ int i;
+ int res = -ENODEV;
+
+ data = kzalloc(sizeof(*data), GFP_KERNEL);
+ if (!data)
+ return -ENOMEM;
+
+ i = 0;
+ do {
+ res = gm965_find_igp_registers(data, chipset_ids[i]);
+ i++;
+ } while (res && chipset_ids[i]);
+
+ if (res)
+ goto err;
+ /* Set up resource regions */
+ reso = request_mem_region(data->igp_base, data->igp_len, DRVNAME);
+ if (!reso) {
+ printk(KERN_ERR "request_mem_region failed\n");
+ res = -EBUSY;
+ goto err;
+ }
+
+ data->igp_mmio = ioremap_nocache(data->igp_base, data->igp_len);
+ if (!data->igp_mmio) {
+ printk(KERN_ERR "ioremap_nocache failed\n");
+ res = -EBUSY;
+ goto err_map_failed;
+ }
+
+ platform_set_drvdata(pdev, data);
+
+ mutex_init(&data->update_lock);
+
+ res = gm965temp_hwmon_init(pdev);
+ if (res)
+ goto err_init_failed;
+
+ return res;
+
+err_init_failed:
+ iounmap(data->igp_mmio);
+ platform_set_drvdata(pdev, NULL);
+err_map_failed:
+ release_mem_region(data->igp_base, data->igp_len);
+err:
+ kfree(data);
+ return res;
+}
+
+static int __devexit gm965temp_remove(struct platform_device *pdev) +{
+ struct gm965temp_data *data = platform_get_drvdata(pdev);
+ hwmon_device_unregister(data->hwmon_dev);
+ device_remove_file(&pdev->dev, &dev_attr_name);
+
+ iounmap(data->igp_mmio);
+ release_mem_region(data->igp_base, data->igp_len);
+ platform_set_drvdata(pdev, NULL);
+ kfree(data);
+ return 0;
+}
+
+static struct platform_driver gm965temp_driver = {
+ .driver = {
+ .owner = THIS_MODULE,
+ .name = DRVNAME,
+ },
+ .probe = gm965temp_probe,
+ .remove = __devexit_p(gm965temp_remove),
+};
+
+static int __init gm965temp_init(void)
+{
+ int res;
+
+ res = platform_driver_register(&gm965temp_driver);
+ if (res)
+ return res;
+
+ res = gm965temp_add();
+ if (res)
+ platform_driver_unregister(&gm965temp_driver);
+
+ return res;
+}
+
+static void __exit gm965temp_exit(void)
+{
+ platform_device_unregister(igp_pdev);
+ platform_driver_unregister(&gm965temp_driver);
+}
+
+MODULE_AUTHOR("Lu Zhihe");
+MODULE_DESCRIPTION("Intel GM965 chipset IGP temperature sensor"); +MODULE_LICENSE("GPL");
+
+module_init(gm965temp_init);
+module_exit(gm965temp_exit);
+

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

#1 lore raw

Re: [lm-sensors] [PATCH 2.6.31-rc2] hwmon: add support for

Hi Lu,

Quoted 9 lines · lu zhihe

From: Lu Zhihe <[email protected]>

Subject: [PATCH] hwmon: add support for GM/GME965 IGP temperature report.

Exported the graphics hot spot temperature report via sysfs.

---
(...)

Review

Quoted 5 lines
(quoted diff) +5 -0
+static unsigned long chipset_ids[] = {
+	PCI_DEVICE_ID_INTEL_82965GM,
+	PCI_DEVICE_ID_INTEL_82965GME,
+	0
+};

These defines do not exist in the current kernel tree. I presume you forgot to includes changes to include/linux/pci_ids.h?

I am also curious what these PCI devices are. We do not want to have driver conflicts, so it might make more sense to add hardware monitoring functionality to an existing driver than writing a brand new driver.

Signature · 6 lines
Jean Delvare

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
author
#2 lore raw

Re: [lm-sensors] [PATCH 2.6.31-rc2] hwmon: add support for

In reply to lu zhihe

Hello Jean,

Quoted 8 lines

Review

Quoted 5 lines
(quoted diff) +5 -0
+static unsigned long chipset_ids[] = {
+     PCI_DEVICE_ID_INTEL_82965GM,
+     PCI_DEVICE_ID_INTEL_82965GME,
+     0
+};

These defines do not exist in the current kernel tree. I presume you forgot to includes changes to include/linux/pci_ids.h?

I found these defines on "drivers/char/agp/intel-agp.c", they
defined as "PCI_DEVICE_ID_INTEL_82965GM_HB" and "PCI_DEVICE_ID_INTEL_82965GME_HB".
While, they are as agpgart device driver, no include in "include/linux/pci_ids.h".
If add 82965GM/82965GME define on pci_ids.h, it may duplicate the
definition. But, it seems it's better to move them to pci_ids.h, because 82915GM and 82945GM are define in it.

Quoted 4 lines

I am also curious what these PCI devices are. We do not want to have driver conflicts, so it might make more sense to add hardware monitoring functionality to an existing driver than writing a brand new driver.

They are Host Bridge Devices D0:F0. As driver touch North Bridge, it
need to avoid drivers conflict.
Although I test on my Lenovo F31G platform, it seems work.

But it need to make sure, as your suggestion.

I check i915.ko and agp-intel.ko. What I found are:
1. i915.ko (drivers/gpu/drm/i915) is registed as Internal Graphics Device 2(D2:F0-F1) driver.
2. agp-intel.ko (drivers/char/agp/intel-agp.c) is registed as Host Bridge Devices D0:F0 pci driver.

May be gm965temp will conflict with agp-intel. And I check agp-intel driver, it don't touch MCHBAR register. For GM965, it only touch:

/* Intel 965G registers */
#define I965_MSAC 0x62
#define I965_IFPADDR 0x70

And it mainly focus on Internal Graphics Device 2(D2:F0-F1) configure and process.
It don't touch the Thermal sensor register, even don't touch MCHBAR register.

apg-intel focus on agpgart table setting, so I curious that it should not add function as hwmon driver too.

What's more. I check hwmon's PCI driver, sis5595, it's ID is "PCI_DEVICE_ID_SI_503". And it also register on drivers/i2c/busses/i2c-sis5595 as PCI driver. The situation is similar as gm965temp and agp-intel.

Above are my opinion for PCI driver conflict.
Please help me to review them?

May be I just make some mistake, and don't notice. :-)

Signature · 8 lines
Thanks,

Lu Zhihe

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
#3 lore raw

Re: [lm-sensors] [PATCH 2.6.31-rc2] hwmon: add support for

In reply to lu zhihe

Hello all,

Quoted 12 lines · Jean Delvare

Review

Quoted 5 lines · lu zhihe
(quoted diff) +5 -0
+static unsigned long chipset_ids[] = {
+	PCI_DEVICE_ID_INTEL_82965GM,
+	PCI_DEVICE_ID_INTEL_82965GME,
+	0
+};

I am also curious what these PCI devices are. We do not want to have driver conflicts, so it might make more sense to add hardware monitoring functionality to an existing driver than writing a brand new driver.

He is talking to the Host Bridge Device 0 (D0:F0) of the Mobile Intel 965 Express Chipset. This includes the following intel chipsets:
PM965/GM965/GL960/GME965/GLE960. Basically the Santa Rosa chipset northbridges.

This northbridges does have two temperature sensors according to the intel spec (316273.pdf). He's reading one of the sensors and displaying its temperature. I've tested the coded on my GM965 and it reports meaningful values. I also put the northbridge under load (shared graphics) and its temperature rises.

I see that other chipsets although southbridges also have their own driver e.g. SENSORS_VIA686A. To me it makes perfectly sense to put a hwmon driver for intel MCH here and nowhere else. Even if other parts of the kernel touch the same device, their functions should be orthogonal. If you look at the VIA686A again: You wouldn't remove the driver from here just because the ATA component of the same device is used by the libata drivers.

The intel Montevina (Centrino 2) platform comprised of GM45/GL40/GS45/PM45 also features the same registers and likely works with this driver (once hardware support is extended to device id 0x2E10h, 2E20h, 2E30h, 2E40h, 2E90h).

All those are intel MCH (memory controller hub) north bridges. Some feature a graphics engine - some not (such as PM965/PM45). I can't tell yet whether for all those devices the sensors deliver meaningful values, but they feature the same registers and documentation. However the hwmon module shouldn't be called gm965temp in this case. I suggest something more general like "imhc" to express "intel memory controller hub" and the documentation to this module should refine for which chipsets support has been added and tested.

Intel desktop Series 3 and 4 also feature similar temperature measurement facilities. Slightly different registers (see TSTTP), but given that they also report meaningful values those could be added to this driver in future.

Regards,
7oby

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

#4 lore raw

Re: [lm-sensors] [PATCH 2.6.31-rc2] hwmon: add support for

In reply to lu zhihe

Hi Tobias,

Quoted 28 lines · Tobias Hain

Hello all,

Quoted 12 lines · Jean Delvare

Review

Quoted 5 lines · lu zhihe
(quoted diff) +5 -0
+static unsigned long chipset_ids[] = {
+	PCI_DEVICE_ID_INTEL_82965GM,
+	PCI_DEVICE_ID_INTEL_82965GME,
+	0
+};

I am also curious what these PCI devices are. We do not want to have driver conflicts, so it might make more sense to add hardware monitoring functionality to an existing driver than writing a brand new driver.

He is talking to the Host Bridge Device 0 (D0:F0) of the Mobile Intel 965 Express Chipset. This includes the following intel chipsets:
PM965/GM965/GL960/GME965/GLE960. Basically the Santa Rosa chipset northbridges.

This northbridges does have two temperature sensors according to the intel spec (316273.pdf). He's reading one of the sensors and displaying its temperature. I've tested the coded on my GM965 and it reports meaningful values. I also put the northbridge under load (shared graphics) and its temperature rises.

Quoted 3 lines

I see that other chipsets although southbridges also have their own driver e.g. SENSORS_VIA686A. To me it makes perfectly sense to put a hwmon driver for intel MCH here and nowhere else.

And the via686a happens to be one of these drivers which caused trouble in the past because other drivers would also bind to the same PCI device and the first one would win. We have worked around this since then, by not letting the driver bind to the device, but this is not clean. I'd rather avoid having more drivers like that.

Quoted 2 lines

Even if other parts of the kernel touch
the same device, their functions should be orthogonal.

It's not a question whether functions are orthogonal. It's a limitation of the device driver model to only let one driver bind to a given device at any given time. Hardware vendor should use PCI function numbers for separate functions, when they do there is no problem. But VIA usually doesn't.

Quoted 3 lines

If you look at the
VIA686A again: You wouldn't remove the driver from here just because the ATA component of the same device is used by the libata drivers.

There's a big difference between the VIA 686 and the Intel 965: the VIA 686 embeds a full hardware monitoring component for fans, temperatures and voltages. The Intel 965 on the other hand simply has one or maybe two temperature sensors. It is not a hardware monitoring chip. So while I wouldn't want to hide the hardware monitoring support of the VIA 686 in another driver, I would be totally fine with adding temperature reporting to whatever driver is already handling the Intel
965. At this point I still believe this is the way to go.

Quoted 5 lines

The intel Montevina (Centrino 2) platform comprised of GM45/GL40/GS45/PM45 also features the same registers and likely works with this driver (once hardware support is extended to device id 0x2E10h, 2E20h, 2E30h, 2E40h, 2E90h).

Quoted 8 lines

All those are intel MCH (memory controller hub) north bridges. Some feature a graphics engine - some not (such as PM965/PM45). I can't tell yet whether for all those devices the sensors deliver meaningful values, but they feature the same registers and documentation. However the hwmon module shouldn't be called gm965temp in this case. I suggest something more general like "imhc" to express "intel memory controller hub" and the documentation to this module should refine for which chipsets support has been added and tested.

"imhc" is as cryptic as you can think, I don't like it, while "gm965temp" was much clearer (if we really want a separate driver.) There is no problem naming a driver after the first device it supports, actually this is the case of almost all hardware monitoring drivers.

Quoted 3 lines

Intel desktop Series 3 and 4 also feature similar temperature measurement facilities. Slightly different registers (see TSTTP), but given that they also report meaningful values those could be added to this driver in future.

Thanks for all the information.

Signature · 6 lines
Jean Delvare

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
#5 lore raw

Re: [lm-sensors] [PATCH 2.6.31-rc2] hwmon: add support for

In reply to lu zhihe

Hello Jean,

Quoted 4 lines

So while I wouldn't want to hide the hardware monitoring support of the VIA 686 in another driver, I would be totally fine with adding temperature reporting to whatever driver is already handling the Intel
965. At this point I still believe this is the way to go.

intel-agp.c contains the device ids for all intel host bridges. None of the symbols (= device ids) intel-agp.c used has been exported to include/linux/pci_ids.h and I guess there's a reason for this.

intel-agp.c has 2432 LOC and only deals with AGP/GART table management. I don't think anybody would be amused to see other code in there. I don't see other infrastructure in place (e.g. dispatchers) to management access from multiple modules.

Do you have a successful example where temperature reading and evaluating is done in an unrelated kernel module? To have a look at how they did it.

Thanks,
7oby

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

#6 lore raw

Re: [lm-sensors] [PATCH 2.6.31-rc2] hwmon: add support for

In reply to lu zhihe

Hi Tobias,

Quoted 10 lines · Tobias Hain

Hello Jean,

Quoted 4 lines

So while I wouldn't want to hide the hardware monitoring support of the VIA 686 in another driver, I would be totally fine with adding temperature reporting to whatever driver is already handling the Intel
965. At this point I still believe this is the way to go.

intel-agp.c contains the device ids for all intel host bridges. None of the symbols (= device ids) intel-agp.c used has been exported to include/linux/pci_ids.h and I guess there's a reason for this.

I don't quite follow you... what would that reason be?

Quoted 2 lines

intel-agp.c has 2432 LOC and only deals with AGP/GART table management. I don't think anybody would be amused to see other code in there.

Well, the driver posted by Lu was rather small, and most of it is for device management, not functionality. Adding temperature reading to another driver would probably fit in 250 lines.

Quoted 3 lines

I don't see
other infrastructure in place (e.g. dispatchers) to management access from multiple modules.

Just because something isn't there doesn't mean we don't want to implement it. Maybe nobody had the need so far.

Quoted 2 lines

Do you have a successful example where temperature reading and evaluating is done in an unrelated kernel module? To have a look at how they did it.

A quick grep reveals these drivers:

drivers/input/touchscreen/ads7846.c
drivers/platform/x86/eeepc-laptop.c
drivers/platform/x86/thinkpad_acpi.c
drivers/thermal/thermal_sys.c

But there may be other drivers which do export temperature readings without registering a proper hwmon class device.

Signature · 6 lines
Jean Delvare

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
author
#7 lore raw

Re: [lm-sensors] [PATCH 2.6.31-rc2] hwmon: add support for

In reply to lu zhihe

Hi Jean,

Quoted 8 lines

2009/7/13 Jean Delvare <[email protected]>:

Quoted 2 lines

intel-agp.c has 2432 LOC and only deals with AGP/GART table management. I don't think anybody would be amused to see other code in there.

Well, the driver posted by Lu was rather small, and most of it is for device management, not functionality. Adding temperature reading to another driver would probably fit in 250 lines.

I agree with you.
While, as there is not GM965 North Bridge driver direct process MCHBAR_I965 (MCH Memory Mapped Register BAR), if any driver module try to support GM965 thermal sensor, it need to call "pci_get_device", read the MCHBAR base address, and do ioremap_nocache to access the Thermal sensor register.

If it doesn't do on drivers/hwmon, it need to do on drivers/char/agp or some how.

Quoted 2 lines

2009/7/12 Jean Delvare <[email protected]>:
It's a limitation of the device driver model to only let one driver bind to a given device at any given time.

I understand what you means, it DID has PCI driver conflict when two driver register as PCI device.
While, apggart-intel is registed as PCI driver, gm965temp is as Platfrom devices driver. Gm965temp uses "pseudo-bus".

Take a "tree -d /sys/device" snapshot:

|-- pci0000:00
|   |-- 0000:00:00.0                                        ***
|   |   |-- bus -> ../../../bus/pci                        ***
|   |   |-- driver -> ../../../bus/pci/drivers/agpgart-intel   ***
|   |   |-- firmware_node -> ../../LNXSYSTM:00/device:00/PNP0A08:00/PNP0C02:00
|   |   |-- power
|   |   `-- subsystem -> ../../../bus/pci
|   |-- 0000:00:02.0
|   |   |-- bus -> ../../../bus/pci
|   |   |-- driver -> ../../../bus/pci/drivers/i915
|   |   |-- drm:card0 -> ../../../class/drm/card0
|   |   |-- drm:controlD64 -> ../../../class/drm/controlD64
|   |   |-- firmware_node -> ../../LNXSYSTM:00/device:00/PNP0A08:00/device:07
|   |   |-- graphics:fb1 -> ../../../class/graphics/fb1
|   |   |-- i2c-adapter:i2c-1 -> ../../../class/i2c-adapter/i2c-1
|   |   |-- i2c-adapter:i2c-2 -> ../../../class/i2c-adapter/i2c-2
|   |   |-- power
|   |   `-- subsystem -> ../../../bus/pci
...
|-- platform
|   |-- gm965temp.0                                       ***
|   |   |-- bus -> ../../../bus/platform                   **
|   |   |-- driver -> ../../../bus/platform/drivers/gm965temp  ***
|   |   |-- hwmon:hwmon1 -> ../../../class/hwmon/hwmon1
|   |   |-- power
|   |   `-- subsystem -> ../../../bus/platform

...

In this sysfs layout, I don't think agpgart-intel and gm965temp will conflict.

--
Thx

Lu Zhihe

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

#8 lore raw

Re: [lm-sensors] [PATCH 2.6.31-rc2] hwmon: add support for

In reply to lu zhihe

Hi Lu,

Sorry for the late answer.

Quoted 28 lines · lu zhihe
Quoted 4 lines

I am also curious what these PCI devices are. We do not want to have driver conflicts, so it might make more sense to add hardware monitoring functionality to an existing driver than writing a brand new driver.

They are Host Bridge Devices D0:F0. As driver touch North Bridge, it
need to avoid drivers conflict.
Although I test on my Lenovo F31G platform, it seems work.

But it need to make sure, as your suggestion.

I check i915.ko and agp-intel.ko. What I found are:
1. i915.ko (drivers/gpu/drm/i915) is registed as Internal Graphics Device 2(D2:F0-F1) driver.
2. agp-intel.ko (drivers/char/agp/intel-agp.c) is registed as Host Bridge Devices D0:F0 pci driver.

May be gm965temp will conflict with agp-intel. And I check agp-intel driver, it don't touch MCHBAR register. For GM965, it only touch:

/* Intel 965G registers */
#define I965_MSAC 0x62
#define I965_IFPADDR 0x70

And it mainly focus on Internal Graphics Device 2(D2:F0-F1) configure and process.
It don't touch the Thermal sensor register, even don't touch MCHBAR register.

Quoted 7 lines

apg-intel focus on agpgart table setting, so I curious that it should not add function as hwmon driver too.

What's more. I check hwmon's PCI driver, sis5595, it's ID is "PCI_DEVICE_ID_SI_503". And it also register on drivers/i2c/busses/i2c-sis5595 as PCI driver. The situation is similar as gm965temp and agp-intel.

You will notice that both the (hwmon) sis5595 and i2c-sis5595 drivers have a probe function which ends with:

	pci_dev_get(dev);
	return -ENODEV;

Basically we have to fail the probe, otherwise the device is marked as busy and the second driver can't bind. This works, but it has a number of downsides, for example all drivers must cooperate, and it doesn't fit the device driver model so things like power management can be difficult to implement properly. And these drivers can only support one device, or they become more complex.

It would certainly be possible to do the same in your case. However, while it does make sense for relatively large drivers (and sis5595 and i2c-sis5595 both fall into this category with 26 kB and 12 kB of source code, respectively), the driver you want to add is small (less than 8 kB) so the alternative of just adding the hwmon feature to an existing driver is appealing. But there are other things to consider too, for example whether the different devices you want to support have the same "main" driver today or not.

Quoted 4 lines

Above are my opinion for PCI driver conflict.
Please help me to review them?

May be I just make some mistake, and don't notice. :-)

Thanks for your analysis. I'll think about it, look at the code more deeply, and come back to you when I'm done.

Signature · 6 lines
Jean Delvare

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors