Skip to contentSkip to conversation

net: hwmon fixes

PATCH Applied Guenter Roeck 6 participants 27 messages Nov 23, 2013 – Nov 28, 2013

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

cover net: hwmon fixes

The hwmon subsystem is used by various network drivers to report temperature sensor and other information. Unfortunately, its use is often not correct. Typical errors are that the mandatory name sysfs attribute is not created, that the temperature sensor index starts with 0 instead of 1, and/or that sysfs attributes are created after the hwmon device was created. The following sequence of patches fixes most of the problems.

The igb patches have been tested with real hardware; the others are compile tested only.

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

#1 lore raw

PATCH 1/5 tg3: Convert to use hwmon_device_register_with_groups

Use new hwmon API to simplify code, provide missing mandatory 'name' sysfs attribute, and attach hwmon attributes to hwmon device instead of pci device.

---
 drivers/net/ethernet/broadcom/tg3.c |   25 ++++++-------------------
 1 file changed, 6 insertions(+), 19 deletions(-)
drivers/net/ethernet/broadcom/tg3.c +6 -19
index a9e0684..369b736 100644
@@ -10629,10 +10629,8 @@ static void tg3_sd_scan_scratchpad(struct tg3 *tp, struct tg3_ocir *ocir)
 static ssize_t tg3_show_temp(struct device *dev,
 			     struct device_attribute *devattr, char *buf)
 {
-	struct pci_dev *pdev = to_pci_dev(dev);
-	struct net_device *netdev = pci_get_drvdata(pdev);
-	struct tg3 *tp = netdev_priv(netdev);
 	struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
+	struct tg3 *tp = dev_get_drvdata(dev);
 	u32 temperature;
 
 	spin_lock_bh(&tp->lock);
@@ -10650,29 +10648,25 @@ static SENSOR_DEVICE_ATTR(temp1_crit, S_IRUGO, tg3_show_temp, NULL,
 static SENSOR_DEVICE_ATTR(temp1_max, S_IRUGO, tg3_show_temp, NULL,
 			  TG3_TEMP_MAX_OFFSET);
 
-static struct attribute *tg3_attributes[] = {
+static struct attribute *tg3_attrs[] = {
 	&sensor_dev_attr_temp1_input.dev_attr.attr,
 	&sensor_dev_attr_temp1_crit.dev_attr.attr,
 	&sensor_dev_attr_temp1_max.dev_attr.attr,
 	NULL
 };
-
-static const struct attribute_group tg3_group = {
-	.attrs = tg3_attributes,
-};
+ATTRIBUTE_GROUPS(tg3);
 
 static void tg3_hwmon_close(struct tg3 *tp)
 {
 	if (tp->hwmon_dev) {
 		hwmon_device_unregister(tp->hwmon_dev);
 		tp->hwmon_dev = NULL;
-		sysfs_remove_group(&tp->pdev->dev.kobj, &tg3_group);
 	}
 }
 
 static void tg3_hwmon_open(struct tg3 *tp)
 {
-	int i, err;
+	int i;
 	u32 size = 0;
 	struct pci_dev *pdev = tp->pdev;
 	struct tg3_ocir ocirs[TG3_SD_NUM_RECS];
@@ -10690,18 +10684,11 @@ static void tg3_hwmon_open(struct tg3 *tp)
 	if (!size)
 		return;
 
-	/* Register hwmon sysfs hooks */
-	err = sysfs_create_group(&pdev->dev.kobj, &tg3_group);
-	if (err) {
-		dev_err(&pdev->dev, "Cannot create sysfs group, aborting\n");
-		return;
-	}
-
-	tp->hwmon_dev = hwmon_device_register(&pdev->dev);
+	tp->hwmon_dev = hwmon_device_register_with_groups(&pdev->dev, "tg3",
+							  tp, tg3_groups);
 	if (IS_ERR(tp->hwmon_dev)) {
 		tp->hwmon_dev = NULL;
 		dev_err(&pdev->dev, "Cannot register hwmon device, aborting\n");
-		sysfs_remove_group(&pdev->dev.kobj, &tg3_group);
 	}
 }
 
Signature · 7 lines
1.7.9.7


_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Reviewed-by on v1 1/5
#2 lore raw

Re: [lm-sensors] [PATCH 1/5] tg3: Convert to use hwmon_device_register_with_groups

Hi Guenter,

Quoted 69 lines · Guenter Roeck

Use new hwmon API to simplify code, provide missing mandatory 'name' sysfs attribute, and attach hwmon attributes to hwmon device instead of pci device.

---
 drivers/net/ethernet/broadcom/tg3.c |   25 ++++++-------------------
 1 file changed, 6 insertions(+), 19 deletions(-)
drivers/net/ethernet/broadcom/tg3.c +4 -17
index a9e0684..369b736 100644
@@ -10629,10 +10629,8 @@ static void tg3_sd_scan_scratchpad(struct tg3 *tp, struct tg3_ocir *ocir)
 static ssize_t tg3_show_temp(struct device *dev,
 			     struct device_attribute *devattr, char *buf)
 {
-	struct pci_dev *pdev = to_pci_dev(dev);
-	struct net_device *netdev = pci_get_drvdata(pdev);
-	struct tg3 *tp = netdev_priv(netdev);
 	struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
+	struct tg3 *tp = dev_get_drvdata(dev);
 	u32 temperature;
 
 	spin_lock_bh(&tp->lock);
@@ -10650,29 +10648,25 @@ static SENSOR_DEVICE_ATTR(temp1_crit, S_IRUGO, tg3_show_temp, NULL,
 static SENSOR_DEVICE_ATTR(temp1_max, S_IRUGO, tg3_show_temp, NULL,
 			  TG3_TEMP_MAX_OFFSET);
 
-static struct attribute *tg3_attributes[] = {
+static struct attribute *tg3_attrs[] = {
 	&sensor_dev_attr_temp1_input.dev_attr.attr,
 	&sensor_dev_attr_temp1_crit.dev_attr.attr,
 	&sensor_dev_attr_temp1_max.dev_attr.attr,
 	NULL
 };
-
-static const struct attribute_group tg3_group = {
-	.attrs = tg3_attributes,
-};
+ATTRIBUTE_GROUPS(tg3);
 
 static void tg3_hwmon_close(struct tg3 *tp)
 {
 	if (tp->hwmon_dev) {
 		hwmon_device_unregister(tp->hwmon_dev);
 		tp->hwmon_dev = NULL;
-		sysfs_remove_group(&tp->pdev->dev.kobj, &tg3_group);
 	}
 }
 
 static void tg3_hwmon_open(struct tg3 *tp)
 {
-	int i, err;
+	int i;
 	u32 size = 0;
 	struct pci_dev *pdev = tp->pdev;
 	struct tg3_ocir ocirs[TG3_SD_NUM_RECS];
@@ -10690,18 +10684,11 @@ static void tg3_hwmon_open(struct tg3 *tp)
 	if (!size)
 		return;
 
-	/* Register hwmon sysfs hooks */
-	err = sysfs_create_group(&pdev->dev.kobj, &tg3_group);
-	if (err) {
-		dev_err(&pdev->dev, "Cannot create sysfs group, aborting\n");
-		return;
-	}
-

drivers/net/ethernet/broadcom/tg3.c static void tg3_hwmon_open(struct tg3 *tp) · line 10694

Quoted 10 lines
drivers/net/ethernet/broadcom/tg3.c +2 -2
-	tp->hwmon_dev = hwmon_device_register(&pdev->dev);
+	tp->hwmon_dev = hwmon_device_register_with_groups(&pdev->dev, "tg3",
+							  tp, tg3_groups);
 	if (IS_ERR(tp->hwmon_dev)) {
 		tp->hwmon_dev = NULL;
 		dev_err(&pdev->dev, "Cannot register hwmon device, aborting\n");
-		sysfs_remove_group(&pdev->dev.kobj, &tg3_group);
 	}
 }
 

I can't test this, but the changes look good to me.

Signature · 6 lines
Jean Delvare

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

Re: [PATCH 1/5] tg3: Convert to use hwmon_device_register_with_groups

In reply to Guenter Roeck
Quoted 14 lines · Guenter Roeck

Use new hwmon API to simplify code, provide missing mandatory 'name' sysfs attribute, and attach hwmon attributes to hwmon device instead of pci device.

---
  drivers/net/ethernet/broadcom/tg3.c |   25 ++++++-------------------
  1 file changed, 6 insertions(+), 19 deletions(-)
drivers/net/ethernet/broadcom/tg3.c +0 -0
index a9e0684..369b736 100644

drivers/net/ethernet/broadcom/tg3.c static void tg3_sd_scan_scratchpad(struct tg3 *tp, struct tg3_ocir *ocir) · line 10633

Quoted 8 lines
drivers/net/ethernet/broadcom/tg3.c +1 -3
@@ -10629,10 +10629,8 @@ static void tg3_sd_scan_scratchpad(struct tg3 *tp, struct tg3_ocir *ocir)
  static ssize_t tg3_show_temp(struct device *dev,
  			     struct device_attribute *devattr, char *buf)
  {
-	struct pci_dev *pdev = to_pci_dev(dev);
-	struct net_device *netdev = pci_get_drvdata(pdev);
-	struct tg3 *tp = netdev_priv(netdev);
  	struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
+	struct tg3 *tp = dev_get_drvdata(dev);

Shouldn't this be
struct tg3 *tp = netdev_priv(dev_get_drvdata(dev));

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

#4 lore raw

Re: [PATCH 1/5] tg3: Convert to use hwmon_device_register_with_groups

Quoted 21 lines · Nithin Nayak Sujir
Quoted 18 lines · Guenter Roeck

Use new hwmon API to simplify code, provide missing mandatory 'name' sysfs attribute, and attach hwmon attributes to hwmon device instead of pci device.

---
  drivers/net/ethernet/broadcom/tg3.c |   25 ++++++-------------------
  1 file changed, 6 insertions(+), 19 deletions(-)
drivers/net/ethernet/broadcom/tg3.c +0 -1
index a9e0684..369b736 100644
@@ -10629,10 +10629,8 @@ static void tg3_sd_scan_scratchpad(struct tg3 *tp, struct tg3_ocir *ocir)
  static ssize_t tg3_show_temp(struct device *dev,
                   struct device_attribute *devattr, char *buf)
  {
-    struct pci_dev *pdev = to_pci_dev(dev);
Quoted 9 lines

drivers/net/ethernet/broadcom/tg3.c static void tg3_sd_scan_scratchpad(struct tg3 *tp, struct tg3_ocir *ocir) · line 10633

Quoted 4 lines
drivers/net/ethernet/broadcom/tg3.c +1 -2
-    struct net_device *netdev = pci_get_drvdata(pdev);
-    struct tg3 *tp = netdev_priv(netdev);
      struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
+    struct tg3 *tp = dev_get_drvdata(dev);

Shouldn't this be
struct tg3 *tp = netdev_priv(dev_get_drvdata(dev));

'struct tg3 *tp' is attached to the hwmon device in hwmon_device_register_with_groups(), so it can be retrieved with dev_get_drvdata() from there. Keep in mind that 'dev' is no longer the pci device but the hwmon device.

Guenter

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

#5 lore raw

Re: [PATCH 1/5] tg3: Convert to use hwmon_device_register_with_groups

Quoted 34 lines · Guenter Roeck
Quoted 23 lines · Nithin Nayak Sujir
Quoted 20 lines · Guenter Roeck

Use new hwmon API to simplify code, provide missing mandatory 'name' sysfs attribute, and attach hwmon attributes to hwmon device instead of pci device.

---
  drivers/net/ethernet/broadcom/tg3.c |   25 ++++++-------------------
  1 file changed, 6 insertions(+), 19 deletions(-)
drivers/net/ethernet/broadcom/tg3.c +0 -1
index a9e0684..369b736 100644
@@ -10629,10 +10629,8 @@ static void tg3_sd_scan_scratchpad(struct tg3 *tp,
 struct tg3_ocir *ocir)
  static ssize_t tg3_show_temp(struct device *dev,
                   struct device_attribute *devattr, char *buf)
  {
-    struct pci_dev *pdev = to_pci_dev(dev);
Quoted 9 lines

drivers/net/ethernet/broadcom/tg3.c static void tg3_sd_scan_scratchpad(struct tg3 *tp, struct tg3_ocir *ocir) · line 10633

Quoted 4 lines
drivers/net/ethernet/broadcom/tg3.c +1 -2
-    struct net_device *netdev = pci_get_drvdata(pdev);
-    struct tg3 *tp = netdev_priv(netdev);
      struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
+    struct tg3 *tp = dev_get_drvdata(dev);

Shouldn't this be
struct tg3 *tp = netdev_priv(dev_get_drvdata(dev));

Quoted 5 lines

'struct tg3 *tp' is attached to the hwmon device in hwmon_device_register_with_groups(), so it can be retrieved with dev_get_drvdata() from there. Keep in mind that 'dev' is no longer the pci device but the hwmon device.

Ah, I see.

Quoted 8 lines

Guenter

--
To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

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

maintainer Applied
#6 lore raw

Re: [PATCH 1/5] tg3: Convert to use hwmon_device_register_with_groups

In reply to Guenter Roeck

From: Guenter Roeck <[email protected]>
Date: Fri, 22 Nov 2013 22:07:57 -0800

Quoted 5 lines

Use new hwmon API to simplify code, provide missing mandatory 'name' sysfs attribute, and attach hwmon attributes to hwmon device instead of pci device.

Applied, thanks.

Jeff Kirsher will pull the rest of this series in via his Intel ethernet driver tree.

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

#7 lore raw

PATCH 2/5 igb: Convert to use devm_hwmon_device_register_with_groups

In reply to Guenter Roeck

Simplify the code. Attach hwmon sysfs attributes to hwmon device instead of pci device. Avoid race conditions caused by attributes being created after registration and provide mandatory 'name' attribute by using new hwmon API.

Other cleanup:

Instead of allocating memory for hwmon attributes, move attributes and all other hwmon related data into struct hwmon_buff and allocate the entire structure using devm_kzalloc.

Check return value from calls to igb_add_hwmon_attr() one by one instead of logically combining them all together.

---
 drivers/net/ethernet/intel/igb/igb.h       |    8 ++-
 drivers/net/ethernet/intel/igb/igb_hwmon.c |  100 +++++++++++++---------------
 2 files changed, 53 insertions(+), 55 deletions(-)
drivers/net/ethernet/intel/igb/igb.h +5 -3
index 5e9ed89..99c3d33 100644
@@ -337,8 +337,10 @@ struct hwmon_attr {
 	};
 
 struct hwmon_buff {
-	struct device *device;
-	struct hwmon_attr *hwmon_list;
+	struct attribute_group group;
+	const struct attribute_group *groups[2];
+	struct attribute *attrs[E1000_MAX_SENSORS * 4 + 1];
+	struct hwmon_attr hwmon_list[E1000_MAX_SENSORS * 4];
 	unsigned int n_hwmon;
 	};
 #endif
@@ -440,7 +442,7 @@ struct igb_adapter {
 
 	char fw_version[32];
 #ifdef CONFIG_IGB_HWMON
-	struct hwmon_buff igb_hwmon_buff;
+	struct hwmon_buff *igb_hwmon_buff;
 	bool ets;
 #endif
 	struct i2c_algo_bit_data i2c_algo;
drivers/net/ethernet/intel/igb/igb_hwmon.c +48 -52

142 lines not on this page · raw message

Signature · 7 lines
1.7.9.7


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

Re: [PATCH 2/5] igb: Convert to use devm_hwmon_device_register_with_groups

Quoted 15 lines · Guenter Roeck

Simplify the code. Attach hwmon sysfs attributes to hwmon device instead of pci device. Avoid race conditions caused by attributes being created after registration and provide mandatory 'name' attribute by using new hwmon API.

Other cleanup:

Instead of allocating memory for hwmon attributes, move attributes and all other hwmon related data into struct hwmon_buff and allocate the entire structure using devm_kzalloc.

Check return value from calls to igb_add_hwmon_attr() one by one instead
of logically combining them all together.

Quoted 6 lines
---
 drivers/net/ethernet/intel/igb/igb.h       |    8 ++-
 drivers/net/ethernet/intel/igb/igb_hwmon.c |  100
+++++++++++++---------------
 2 files changed, 53 insertions(+), 55 deletions(-)

I have added this to my queue, thanks!

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

#9 lore raw

PATCH 3/5 ixgbe: Convert to use devm_hwmon_device_register_with_groups

In reply to Guenter Roeck

Simplify the code. Attach hwmon sysfs attributes to hwmon device instead of pci device. Avoid race conditions caused by attributes being created after hwmon device registration. Implicitly (through hwmon API) add mandatory 'name' sysfs attribute.

Other cleanup:

Instead of allocating memory for hwmon attributes, move attributes and all other hwmon related data into struct hwmon_buff and allocate the entire structure using devm_kzalloc.

Check return value from calls to igb_add_hwmon_attr() one by one instead of logically combining them all together.

---
 drivers/net/ethernet/intel/ixgbe/ixgbe.h       |    8 ++-
 drivers/net/ethernet/intel/ixgbe/ixgbe_sysfs.c |   76 ++++++++++--------------
 2 files changed, 36 insertions(+), 48 deletions(-)
drivers/net/ethernet/intel/ixgbe/ixgbe.h +5 -3
index f38fc0a..49531cd 100644
@@ -552,8 +552,10 @@ struct hwmon_attr {
 };
 
 struct hwmon_buff {
-	struct device *device;
-	struct hwmon_attr *hwmon_list;
+	struct attribute_group group;
+	const struct attribute_group *groups[2];
+	struct attribute *attrs[IXGBE_MAX_SENSORS * 4 + 1];
+	struct hwmon_attr hwmon_list[IXGBE_MAX_SENSORS * 4];
 	unsigned int n_hwmon;
 };
 #endif /* CONFIG_IXGBE_HWMON */
@@ -775,7 +777,7 @@ struct ixgbe_adapter {
 	u32 vferr_refcount;
 	struct kobject *info_kobj;
 #ifdef CONFIG_IXGBE_HWMON
-	struct hwmon_buff ixgbe_hwmon_buff;
+	struct hwmon_buff *ixgbe_hwmon_buff;
 #endif /* CONFIG_IXGBE_HWMON */
 #ifdef CONFIG_DEBUG_FS
 	struct dentry *ixgbe_dbg_adapter;
drivers/net/ethernet/intel/ixgbe/ixgbe_sysfs.c +31 -45

120 lines not on this page · raw message

Signature · 7 lines
1.7.9.7


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

Re: [PATCH 3/5] ixgbe: Convert to use devm_hwmon_device_register_with_groups

Quoted 15 lines · Guenter Roeck

Simplify the code. Attach hwmon sysfs attributes to hwmon device instead of pci device. Avoid race conditions caused by attributes being created after hwmon device registration. Implicitly (through hwmon API) add mandatory 'name' sysfs attribute.

Other cleanup:

Instead of allocating memory for hwmon attributes, move attributes and all other hwmon related data into struct hwmon_buff and allocate the entire structure using devm_kzalloc.

Check return value from calls to igb_add_hwmon_attr() one by one instead
of logically combining them all together.

Quoted 6 lines
---
 drivers/net/ethernet/intel/ixgbe/ixgbe.h       |    8 ++-
 drivers/net/ethernet/intel/ixgbe/ixgbe_sysfs.c |   76
++++++++++--------------
 2 files changed, 36 insertions(+), 48 deletions(-)

I have added this to my queue, thanks!

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

#11 lore raw

PATCH 4/5 igb: Start temperature sensor attribute index with 1

In reply to Guenter Roeck

Per hwmon ABI, temperature sensor attribute index starts with 1, not 0.

---
 drivers/net/ethernet/intel/igb/igb_hwmon.c |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/ethernet/intel/igb/igb_hwmon.c +4 -4
index 2e7ef2d..e0af5bc 100644
@@ -124,22 +124,22 @@ static int igb_add_hwmon_attr(struct igb_adapter *adapter,
 	case IGB_HWMON_TYPE_LOC:
 		igb_attr->dev_attr.show = igb_hwmon_show_location;
 		snprintf(igb_attr->name, sizeof(igb_attr->name),
-			 "temp%u_label", offset);
+			 "temp%u_label", offset + 1);
 		break;
 	case IGB_HWMON_TYPE_TEMP:
 		igb_attr->dev_attr.show = igb_hwmon_show_temp;
 		snprintf(igb_attr->name, sizeof(igb_attr->name),
-			 "temp%u_input", offset);
+			 "temp%u_input", offset + 1);
 		break;
 	case IGB_HWMON_TYPE_CAUTION:
 		igb_attr->dev_attr.show = igb_hwmon_show_cautionthresh;
 		snprintf(igb_attr->name, sizeof(igb_attr->name),
-			 "temp%u_max", offset);
+			 "temp%u_max", offset + 1);
 		break;
 	case IGB_HWMON_TYPE_MAX:
 		igb_attr->dev_attr.show = igb_hwmon_show_maxopthresh;
 		snprintf(igb_attr->name, sizeof(igb_attr->name),
-			 "temp%u_crit", offset);
+			 "temp%u_crit", offset + 1);
 		break;
 	default:
 		rc = -EPERM;
Signature · 7 lines
1.7.9.7


_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Reviewed-by on v1 4/5
#12 lore raw

Re: [lm-sensors] [PATCH 4/5] igb: Start temperature sensor attribute index with 1

Quoted 28 lines · Guenter Roeck

Per hwmon ABI, temperature sensor attribute index starts with 1, not 0.

---
 drivers/net/ethernet/intel/igb/igb_hwmon.c |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/ethernet/intel/igb/igb_hwmon.c +2 -3
index 2e7ef2d..e0af5bc 100644
@@ -124,22 +124,22 @@ static int igb_add_hwmon_attr(struct igb_adapter *adapter,
 	case IGB_HWMON_TYPE_LOC:
 		igb_attr->dev_attr.show = igb_hwmon_show_location;
 		snprintf(igb_attr->name, sizeof(igb_attr->name),
-			 "temp%u_label", offset);
+			 "temp%u_label", offset + 1);
 		break;
 	case IGB_HWMON_TYPE_TEMP:
 		igb_attr->dev_attr.show = igb_hwmon_show_temp;
 		snprintf(igb_attr->name, sizeof(igb_attr->name),
-			 "temp%u_input", offset);
+			 "temp%u_input", offset + 1);
 		break;
 	case IGB_HWMON_TYPE_CAUTION:
 		igb_attr->dev_attr.show = igb_hwmon_show_cautionthresh;
 		snprintf(igb_attr->name, sizeof(igb_attr->name),
-			 "temp%u_max", offset);

drivers/net/ethernet/intel/igb/igb_hwmon.c static int igb_add_hwmon_attr(struct igb_adapter *adapter, · line 145

Quoted 10 lines
drivers/net/ethernet/intel/igb/igb_hwmon.c +2 -1
+			 "temp%u_max", offset + 1);
 		break;
 	case IGB_HWMON_TYPE_MAX:
 		igb_attr->dev_attr.show = igb_hwmon_show_maxopthresh;
 		snprintf(igb_attr->name, sizeof(igb_attr->name),
-			 "temp%u_crit", offset);
+			 "temp%u_crit", offset + 1);
 		break;
 	default:
 		rc = -EPERM;
Signature · 6 lines
Jean Delvare

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

Re: [PATCH 4/5] igb: Start temperature sensor attribute index with 1

In reply to Guenter Roeck
Quoted 7 lines · Guenter Roeck

Per hwmon ABI, temperature sensor attribute index starts with 1, not 0.

---
 drivers/net/ethernet/intel/igb/igb_hwmon.c |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

I have also added this to my queue, thank you.

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

#14 lore raw

PATCH 5/5 ixgbe: Start temperature sensor attribute index with 1

In reply to Guenter Roeck

Per hwmon ABI, temperature sensor attribute index starts with 1, not 0.

---
 drivers/net/ethernet/intel/ixgbe/ixgbe_sysfs.c |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/ethernet/intel/ixgbe/ixgbe_sysfs.c +4 -4
index 3081974..e74ae36 100644
@@ -118,22 +118,22 @@ static int ixgbe_add_hwmon_attr(struct ixgbe_adapter *adapter,
 	case IXGBE_HWMON_TYPE_LOC:
 		ixgbe_attr->dev_attr.show = ixgbe_hwmon_show_location;
 		snprintf(ixgbe_attr->name, sizeof(ixgbe_attr->name),
-			 "temp%u_label", offset);
+			 "temp%u_label", offset + 1);
 		break;
 	case IXGBE_HWMON_TYPE_TEMP:
 		ixgbe_attr->dev_attr.show = ixgbe_hwmon_show_temp;
 		snprintf(ixgbe_attr->name, sizeof(ixgbe_attr->name),
-			 "temp%u_input", offset);
+			 "temp%u_input", offset + 1);
 		break;
 	case IXGBE_HWMON_TYPE_CAUTION:
 		ixgbe_attr->dev_attr.show = ixgbe_hwmon_show_cautionthresh;
 		snprintf(ixgbe_attr->name, sizeof(ixgbe_attr->name),
-			 "temp%u_max", offset);
+			 "temp%u_max", offset + 1);
 		break;
 	case IXGBE_HWMON_TYPE_MAX:
 		ixgbe_attr->dev_attr.show = ixgbe_hwmon_show_maxopthresh;
 		snprintf(ixgbe_attr->name, sizeof(ixgbe_attr->name),
-			 "temp%u_crit", offset);
+			 "temp%u_crit", offset + 1);
 		break;
 	default:
 		rc = -EPERM;
Signature · 7 lines
1.7.9.7


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

Re: [lm-sensors] [PATCH 5/5] ixgbe: Start temperature sensor attribute index with 1

Quoted 28 lines · Guenter Roeck

Per hwmon ABI, temperature sensor attribute index starts with 1, not 0.

---
 drivers/net/ethernet/intel/ixgbe/ixgbe_sysfs.c |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/ethernet/intel/ixgbe/ixgbe_sysfs.c +2 -3
index 3081974..e74ae36 100644
@@ -118,22 +118,22 @@ static int ixgbe_add_hwmon_attr(struct ixgbe_adapter *adapter,
 	case IXGBE_HWMON_TYPE_LOC:
 		ixgbe_attr->dev_attr.show = ixgbe_hwmon_show_location;
 		snprintf(ixgbe_attr->name, sizeof(ixgbe_attr->name),
-			 "temp%u_label", offset);
+			 "temp%u_label", offset + 1);
 		break;
 	case IXGBE_HWMON_TYPE_TEMP:
 		ixgbe_attr->dev_attr.show = ixgbe_hwmon_show_temp;
 		snprintf(ixgbe_attr->name, sizeof(ixgbe_attr->name),
-			 "temp%u_input", offset);
+			 "temp%u_input", offset + 1);
 		break;
 	case IXGBE_HWMON_TYPE_CAUTION:
 		ixgbe_attr->dev_attr.show = ixgbe_hwmon_show_cautionthresh;
 		snprintf(ixgbe_attr->name, sizeof(ixgbe_attr->name),
-			 "temp%u_max", offset);

drivers/net/ethernet/intel/ixgbe/ixgbe_sysfs.c static int ixgbe_add_hwmon_attr(struct ixgbe_adapter *adapter, · line 139

Quoted 10 lines
drivers/net/ethernet/intel/ixgbe/ixgbe_sysfs.c +2 -1
+			 "temp%u_max", offset + 1);
 		break;
 	case IXGBE_HWMON_TYPE_MAX:
 		ixgbe_attr->dev_attr.show = ixgbe_hwmon_show_maxopthresh;
 		snprintf(ixgbe_attr->name, sizeof(ixgbe_attr->name),
-			 "temp%u_crit", offset);
+			 "temp%u_crit", offset + 1);
 		break;
 	default:
 		rc = -EPERM;
Signature · 6 lines
Jean Delvare

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

Re: [lm-sensors] [PATCH 5/5] ixgbe: Start temperature sensor attribute index with 1

Quoted 33 lines · Jean Delvare
Quoted 32 lines · Guenter Roeck

Per hwmon ABI, temperature sensor attribute index starts with 1, not 0.

---
 drivers/net/ethernet/intel/ixgbe/ixgbe_sysfs.c |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/ethernet/intel/ixgbe/ixgbe_sysfs.c +3 -3
index 3081974..e74ae36 100644
@@ -118,22 +118,22 @@ static int ixgbe_add_hwmon_attr(struct ixgbe_adapter *adapter,
 	case IXGBE_HWMON_TYPE_LOC:
 		ixgbe_attr->dev_attr.show = ixgbe_hwmon_show_location;
 		snprintf(ixgbe_attr->name, sizeof(ixgbe_attr->name),
-			 "temp%u_label", offset);
+			 "temp%u_label", offset + 1);
 		break;
 	case IXGBE_HWMON_TYPE_TEMP:
 		ixgbe_attr->dev_attr.show = ixgbe_hwmon_show_temp;
 		snprintf(ixgbe_attr->name, sizeof(ixgbe_attr->name),
-			 "temp%u_input", offset);
+			 "temp%u_input", offset + 1);
 		break;
 	case IXGBE_HWMON_TYPE_CAUTION:
 		ixgbe_attr->dev_attr.show = ixgbe_hwmon_show_cautionthresh;
 		snprintf(ixgbe_attr->name, sizeof(ixgbe_attr->name),
-			 "temp%u_max", offset);
+			 "temp%u_max", offset + 1);
 		break;
 	case IXGBE_HWMON_TYPE_MAX:
 		ixgbe_attr->dev_attr.show = ixgbe_hwmon_show_maxopthresh;
Quoted 9 lines

drivers/net/ethernet/intel/ixgbe/ixgbe_sysfs.c static int ixgbe_add_hwmon_attr(struct ixgbe_adapter *adapter, · line 139

Quoted 6 lines
drivers/net/ethernet/intel/ixgbe/ixgbe_sysfs.c +1 -1
 		snprintf(ixgbe_attr->name, sizeof(ixgbe_attr->name),
-			 "temp%u_crit", offset);
+			 "temp%u_crit", offset + 1);
 		break;
 	default:
 		rc = -EPERM;

Hi Jean,

thanks a lot for the reviews!

Guenter

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

#17 lore raw

Re: [PATCH 5/5] ixgbe: Start temperature sensor attribute index with 1

In reply to Guenter Roeck
Quoted 7 lines · Guenter Roeck

Per hwmon ABI, temperature sensor attribute index starts with 1, not 0.

---
 drivers/net/ethernet/intel/ixgbe/ixgbe_sysfs.c |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

I have also added this to my queue, thank you.

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

#18 lore raw
In reply to Guenter Roeck
Quoted 5 lines · Guenter Roeck

The hwmon subsystem is used by various network drivers to report temperature sensor and other information. Unfortunately, its use is often not correct. Typical errors are that the mandatory name sysfs attribute is not created, that the temperature sensor index starts with 0 instead of 1, and/or that sysfs attributes are created after the hwmon device was created.

As it happens, I was just looking at what we do in sfc (drivers/net/ethernet/sfc/mcdi_mon.c) and wondering why I made it create the hwmon device before the attributes. I think I avoided the other bugs though.

Ben.

Quoted 4 lines

The following sequence of patches fixes most of the problems.

The igb patches have been tested with real hardware; the others are compile tested only.

Signature · 9 lines
Ben Hutchings, Staff Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.


_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
#19 lore raw
Quoted 7 lines · Ben Hutchings
Quoted 5 lines · Guenter Roeck

The hwmon subsystem is used by various network drivers to report temperature sensor and other information. Unfortunately, its use is often not correct. Typical errors are that the mandatory name sysfs attribute is not created, that the temperature sensor index starts with 0 instead of 1, and/or that sysfs attributes are created after the hwmon device was created.

Quoted 5 lines

As it happens, I was just looking at what we do in sfc (drivers/net/ethernet/sfc/mcdi_mon.c) and wondering why I made it create the hwmon device before the attributes. I think I avoided the other bugs though.

Hi Ben,

Yes, I know about that one. It concluded that it would be too invasive and risky to try to fix it without access to hardware to test the results. That is why I said "fixes _most_ of the problems".

As for why the attributes are created after registration, it was most likely because there was no API available to attach the sysfs attributes to the hwmon device in a clean way. The new APIs fix that.

Thanks,
Guenter

Quoted 7 lines

Ben.

Quoted 4 lines

The following sequence of patches fixes most of the problems.

The igb patches have been tested with real hardware; the others are compile tested only.

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

#20 lore raw
Quoted 15 lines · Guenter Roeck
Quoted 7 lines · Ben Hutchings
Quoted 5 lines · Guenter Roeck

The hwmon subsystem is used by various network drivers to report temperature sensor and other information. Unfortunately, its use is often not correct. Typical errors are that the mandatory name sysfs attribute is not created, that the temperature sensor index starts with 0 instead of 1, and/or that sysfs attributes are created after the hwmon device was created.

Quoted 5 lines

As it happens, I was just looking at what we do in sfc (drivers/net/ethernet/sfc/mcdi_mon.c) and wondering why I made it create the hwmon device before the attributes. I think I avoided the other bugs though.

Hi Ben,

Quoted 7 lines

Yes, I know about that one. It concluded that it would be too invasive and risky to try to fix it without access to hardware to test the results. That is why I said "fixes _most_ of the problems".

As for why the attributes are created after registration, it was most likely because there was no API available to attach the sysfs attributes to the hwmon device in a clean way. The new APIs fix that.

We don't attach them to the hwmon device either, and I would rather not change that yet because lm-sensors 2 is still widely used.

Ben.

Signature · 9 lines
Ben Hutchings, Staff Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.


_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
#21 lore raw
Quoted 20 lines · Ben Hutchings
Quoted 19 lines · Guenter Roeck
Quoted 7 lines · Ben Hutchings
Quoted 5 lines · Guenter Roeck

The hwmon subsystem is used by various network drivers to report temperature sensor and other information. Unfortunately, its use is often not correct. Typical errors are that the mandatory name sysfs attribute is not created, that the temperature sensor index starts with 0 instead of 1, and/or that sysfs attributes are created after the hwmon device was created.

Quoted 5 lines

As it happens, I was just looking at what we do in sfc (drivers/net/ethernet/sfc/mcdi_mon.c) and wondering why I made it create the hwmon device before the attributes. I think I avoided the other bugs though.

Hi Ben,

Yes, I know about that one. It concluded that it would be too invasive and risky to try to fix it without access to hardware to test the results. That is why I said "fixes _most_ of the problems".

Quoted 7 lines
Quoted 3 lines

As for why the attributes are created after registration, it was most likely because there was no API available to attach the sysfs attributes to the hwmon device in a clean way. The new APIs fix that.

We don't attach them to the hwmon device either, and I would rather not change that yet because lm-sensors 2 is still widely used.

Hmm .. then there should be no good reason to create the attributes only after hwmon registration.

As for lm-sensors 2 ... really ? Seems odd that people would use the latest kernel with 5+ years old versions of applications / libraries. but I guess the world is full of such oddities, so maybe I should not be surprised.

Note that the drivers in the hwmon subsystem are expected to move to the new API over time, and some of them already did. New drivers will likely not work with lm-sensors 2. So it may be time for those still using lm-sensors 2 to consider an update, at least if they plan to use those drivers with the latest kernel.

Thanks,
Guenter

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

#22 lore raw
Quoted 29 lines · Guenter Roeck
Quoted 20 lines · Ben Hutchings
Quoted 19 lines · Guenter Roeck
Quoted 7 lines · Ben Hutchings
Quoted 5 lines · Guenter Roeck

The hwmon subsystem is used by various network drivers to report temperature sensor and other information. Unfortunately, its use is often not correct. Typical errors are that the mandatory name sysfs attribute is not created, that the temperature sensor index starts with 0 instead of 1, and/or that sysfs attributes are created after the hwmon device was created.

Quoted 5 lines

As it happens, I was just looking at what we do in sfc (drivers/net/ethernet/sfc/mcdi_mon.c) and wondering why I made it create the hwmon device before the attributes. I think I avoided the other bugs though.

Hi Ben,

Yes, I know about that one. It concluded that it would be too invasive and risky to try to fix it without access to hardware to test the results. That is why I said "fixes _most_ of the problems".

Quoted 7 lines
Quoted 3 lines

As for why the attributes are created after registration, it was most likely because there was no API available to attach the sysfs attributes to the hwmon device in a clean way. The new APIs fix that.

We don't attach them to the hwmon device either, and I would rather not change that yet because lm-sensors 2 is still widely used.

Quoted 7 lines

Hmm .. then there should be no good reason to create the attributes only after hwmon registration.

As for lm-sensors 2 ... really ? Seems odd that people would use the latest kernel with 5+ years old versions of applications / libraries. but I guess the world is full of such oddities, so maybe I should not be surprised.

[...]

As Jean pointed out, the net drivers implementing hwmon aren't supported by lm-sensors 2 anyway. So we should go ahead and use the new API in sfc. I've opened an internal bug report for this, but it is likely to be low priority for the team. But if you write a patch I can test it.

Ben.

Signature · 9 lines
Ben Hutchings, Staff Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.


_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
#23 lore raw
Quoted 37 lines · Ben Hutchings
Quoted 29 lines · Guenter Roeck
Quoted 20 lines · Ben Hutchings
Quoted 19 lines · Guenter Roeck
Quoted 7 lines · Ben Hutchings
Quoted 5 lines · Guenter Roeck

The hwmon subsystem is used by various network drivers to report temperature sensor and other information. Unfortunately, its use is often not correct. Typical errors are that the mandatory name sysfs attribute is not created, that the temperature sensor index starts with 0 instead of 1, and/or that sysfs attributes are created after the hwmon device was created.

Quoted 5 lines

As it happens, I was just looking at what we do in sfc (drivers/net/ethernet/sfc/mcdi_mon.c) and wondering why I made it create the hwmon device before the attributes. I think I avoided the other bugs though.

Hi Ben,

Yes, I know about that one. It concluded that it would be too invasive and risky to try to fix it without access to hardware to test the results. That is why I said "fixes _most_ of the problems".

Quoted 7 lines
Quoted 3 lines

As for why the attributes are created after registration, it was most likely because there was no API available to attach the sysfs attributes to the hwmon device in a clean way. The new APIs fix that.

We don't attach them to the hwmon device either, and I would rather not change that yet because lm-sensors 2 is still widely used.

Quoted 7 lines

Hmm .. then there should be no good reason to create the attributes only after hwmon registration.

As for lm-sensors 2 ... really ? Seems odd that people would use the latest kernel with 5+ years old versions of applications / libraries. but I guess the world is full of such oddities, so maybe I should not be surprised.

Quoted 7 lines

[...]

As Jean pointed out, the net drivers implementing hwmon aren't supported by lm-sensors 2 anyway. So we should go ahead and use the new API in sfc. I've opened an internal bug report for this, but it is likely to be low priority for the team. But if you write a patch I can test it.

You'll get one shortly.

Thanks,
Guenter

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

#24 lore raw
In reply to Ben Hutchings
Quoted 11 lines · Ben Hutchings
Quoted 7 lines · Guenter Roeck

Yes, I know about that one. It concluded that it would be too invasive and risky to try to fix it without access to hardware to test the results. That is why I said "fixes _most_ of the problems".

As for why the attributes are created after registration, it was most likely because there was no API available to attach the sysfs attributes to the hwmon device in a clean way. The new APIs fix that.

We don't attach them to the hwmon device either, and I would rather not change that yet because lm-sensors 2 is still widely used.

Mouahahahah.

No, seriously, it's not. And lm-sensors 2 doesn't even support your device so this is a totally moot point.

Signature · 6 lines
Jean Delvare

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
#25 lore raw
Quoted 10 lines · Jean Delvare
Quoted 9 lines · Ben Hutchings
Quoted 7 lines · Guenter Roeck

Yes, I know about that one. It concluded that it would be too invasive and risky to try to fix it without access to hardware to test the results. That is why I said "fixes _most_ of the problems".

As for why the attributes are created after registration, it was most likely because there was no API available to attach the sysfs attributes to the hwmon device in a clean way. The new APIs fix that.

Quoted 6 lines
Quoted 2 lines

We don't attach them to the hwmon device either, and I would rather not change that yet because lm-sensors 2 is still widely used.

Mouahahahah.

No, seriously, it's not.

RHEL 5 has it, and that is widely used - even with recent mainline kernels, in some cases.

Quoted 2 lines

And lm-sensors 2 doesn't even support your
device so this is a totally moot point.

I thought it did work with arbitrary devices providing the right attributes, but obviously I misremembered. So there's no reason not to change. Thanks.

Ben.

Signature · 9 lines
Ben Hutchings, Staff Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.


_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
#26 lore raw
Quoted 11 lines · Ben Hutchings
Quoted 7 lines · Jean Delvare
Quoted 2 lines · Ben Hutchings

We don't attach them to the hwmon device either, and I would rather not change that yet because lm-sensors 2 is still widely used.

Mouahahahah.

No, seriously, it's not.

RHEL 5 has it, and that is widely used - even with recent mainline kernels, in some cases.

RHEL 5 comes with kernel 2.6.18, which isn't exactly recent. I very much doubt a significant share of users dare to use a brand new kernel on such an old distribution. And if they do, then there are several packages which need to be updated (udev, kernel-firmware...), lm-sensors is only one of them, and the user should be aware of that.

Quoted 5 lines
Quoted 2 lines

And lm-sensors 2 doesn't even support your
device so this is a totally moot point.

I thought it did work with arbitrary devices providing the right attributes, but obviously I misremembered.

This is how lm-sensors 3 works. But lm-sensors 2 needs explicit support for each and every device. Which is exactly why version 2 sucked and nobody should be using it any longer.

Quoted 1 line

So there's no reason not to change. Thanks.

Good to hear :)

Signature · 6 lines
Jean Delvare

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