Skip to contentSkip to conversation

i2c-i801: Don't probe for slaves on IDF channels

PATCH In review Jean Delvare 3 participants 5 messages May 10, 2011 3 messages not in the archive

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

PATCH 1/1 i2c-i801: Don't probe for slaves on IDF channels

I don't know if Fujitsu is ever going to produce Patsburg-based machines, but if they do, I'd rather not probe the secondary (IDF) SMBus channels. At least not until we have a good reason for doing so.

On a side note, I'm not even sure if it is right to enable detection of HWMON and DDC devices on the IDF channels. Time will tell...

Cc Hans de Goede <[email protected]>
CC David Woodhouse <[email protected]>

---
Hans, David, what do you think?

 drivers/i2c/busses/i2c-i801.c |   45 +++++++++++++++++++++++++++--------------
 1 file changed, 30 insertions(+), 15 deletions(-)
drivers/i2c/busses/i2c-i801.c +30 -15
@@ -158,6 +158,7 @@ static struct pci_driver i801_driver;
 #define FEATURE_BLOCK_BUFFER	(1 << 1)
 #define FEATURE_BLOCK_PROC	(1 << 2)
 #define FEATURE_I2C_BLOCK_READ	(1 << 3)
+#define FEATURE_IDF		(1 << 4)
 
 static const char *i801_feature_names[] = {
 	"SMBus PEC",
@@ -735,6 +736,29 @@ static void __devinit dmi_check_onboard_
 }
 #endif
 
+/* Register optional slaves */
+static void __devinit i801_probe_optional_slaves(struct i801_priv *priv)
+{
+	/* Only register slaves on main SMBus channel */
+	if (priv->features & FEATURE_IDF)
+		return;
+
+#if defined CONFIG_INPUT_APANEL || defined CONFIG_INPUT_APANEL_MODULE
+	if (apanel_addr) {
+		struct i2c_board_info info;
+
+		memset(&info, 0, sizeof(struct i2c_board_info));
+		info.addr = apanel_addr;
+		strlcpy(info.type, "fujitsu_apanel", I2C_NAME_SIZE);
+		i2c_new_device(&priv->adapter, &info);
+	}
+#endif
+#if defined CONFIG_SENSORS_FSCHMD || defined CONFIG_SENSORS_FSCHMD_MODULE
+	if (dmi_name_in_vendors("FUJITSU"))
+		dmi_walk(dmi_check_onboard_devices, &priv->adapter);
+#endif
+}
+
 static int __devinit i801_probe(struct pci_dev *dev,
 				const struct pci_device_id *id)
 {
@@ -753,6 +777,11 @@ static int __devinit i801_probe(struct p
 
 	priv->pci_dev = dev;
 	switch (dev->device) {
+	case PCI_DEVICE_ID_INTEL_PATSBURG_SMBUS_IDF0:
+	case PCI_DEVICE_ID_INTEL_PATSBURG_SMBUS_IDF1:
+	case PCI_DEVICE_ID_INTEL_PATSBURG_SMBUS_IDF2:
+		priv->features |= FEATURE_IDF;
+		/* fall through */
 	default:
 		priv->features |= FEATURE_I2C_BLOCK_READ;
 		/* fall through */
@@ -838,21 +867,7 @@ static int __devinit i801_probe(struct p
 		goto exit_release;
 	}
 
-	/* Register optional slaves */
-#if defined CONFIG_INPUT_APANEL || defined CONFIG_INPUT_APANEL_MODULE
-	if (apanel_addr) {
-		struct i2c_board_info info;
-
-		memset(&info, 0, sizeof(struct i2c_board_info));
-		info.addr = apanel_addr;
-		strlcpy(info.type, "fujitsu_apanel", I2C_NAME_SIZE);
-		i2c_new_device(&priv->adapter, &info);
-	}
-#endif
-#if defined CONFIG_SENSORS_FSCHMD || defined CONFIG_SENSORS_FSCHMD_MODULE
-	if (dmi_name_in_vendors("FUJITSU"))
-		dmi_walk(dmi_check_onboard_devices, &priv->adapter);
-#endif
+	i801_probe_optional_slaves(priv);
 
 	pci_set_drvdata(dev, priv);
 	return 0;
Signature · 1 line
Jean Delvare

A message that is not in the archive (sent off-list or not yet received): [email protected]

#2 lore raw

Hi,

Quoted 4 lines · Jean Delvare

I don't know if Fujitsu is ever going to produce Patsburg-based machines, but if they do, I'd rather not probe the secondary (IDF) SMBus channels. At least not until we have a good reason for doing so.

Quoted 8 lines

On a side note, I'm not even sure if it is right to enable detection of HWMON and DDC devices on the IDF channels. Time will tell...

Cc Hans de Goede<[email protected]>
CC David Woodhouse<[email protected]>

---
Hans, David, what do you think?

Not probing for the FSC devices on the idf channel sounds reasonable to me. Note that Fujitsu has moved to using super io chips for hwmon now instead of their own i2c solutions, so for newer motherboards there aren't any of these i2c chips present at all.

Regards,

Hans

A message that is not in the archive (sent off-list or not yet received): [email protected]

#4 lore raw
Quoted 16 lines · Hans de Goede

Hi,

Quoted 4 lines · Jean Delvare

I don't know if Fujitsu is ever going to produce Patsburg-based machines, but if they do, I'd rather not probe the secondary (IDF) SMBus channels. At least not until we have a good reason for doing so.

Quoted 8 lines

On a side note, I'm not even sure if it is right to enable detection of HWMON and DDC devices on the IDF channels. Time will tell...

Cc Hans de Goede<[email protected]>
CC David Woodhouse<[email protected]>

---
Hans, David, what do you think?

Quoted 4 lines

Not probing for the FSC devices on the idf channel sounds reasonable to me. Note that Fujitsu has moved to using super io chips for hwmon now instead of their own i2c solutions, so for newer motherboards there aren't any of these i2c chips present at all.

Good to know, thanks for the info. Good move I'd say, it should be less work for us to support their boards.

Signature · 1 line
Jean Delvare
#5 lore raw
In reply to a message not in the archive
Quoted 3 lines · Jean Delvare

I don't know if Fujitsu is ever going to produce Patsburg-based machines, but if they do, I'd rather not probe the secondary (IDF) SMBus channels. At least not until we have a good reason for doing so.

Seems reasonable in principle.

drivers/i2c/busses/i2c-i801.c static void __devinit dmi_check_onboard_ · line 756

Quoted 3 lines
drivers/i2c/busses/i2c-i801.c +2 -0
+#if defined CONFIG_INPUT_APANEL || defined CONFIG_INPUT_APANEL_MODULE
 
+#if defined CONFIG_SENSORS_FSCHMD || defined CONFIG_SENSORS_FSCHMD_MODULE

This kind of ifdef is horrid though, and should be avoided at all costs. A setting of CONFIG_xxx_MODULE should not affect the *static* kernel image. You should be able to enable an additional module, build it and use it without having to rebuild/reboot the kernel.

I know there are *some* cases where we violate that rule, but that doesn't make it any nicer.

Signature · 2 lines
David Woodhouse                            Open Source Technology Centre
[email protected]                              Intel Corporation

A message that is not in the archive (sent off-list or not yet received): 1305039012.30435.85.camel-W2I5cNIroUsVm/[email protected]

#7 lore raw

Hi David,

Quoted 6 lines · David
Quoted 3 lines · Jean Delvare

I don't know if Fujitsu is ever going to produce Patsburg-based machines, but if they do, I'd rather not probe the secondary (IDF) SMBus channels. At least not until we have a good reason for doing so.

Seems reasonable in principle.

OK, I'll push this change upstream then, thanks.

Any opinion on the detection class flags for the IDF channels? Do you have any idea what these IDF channels are supposed to be dedicated to?

Quoted 8 lines

drivers/i2c/busses/i2c-i801.c static void __devinit dmi_check_onboard_ · line 756

Quoted 3 lines
drivers/i2c/busses/i2c-i801.c +2 -0
+#if defined CONFIG_INPUT_APANEL || defined CONFIG_INPUT_APANEL_MODULE
 
+#if defined CONFIG_SENSORS_FSCHMD || defined CONFIG_SENSORS_FSCHMD_MODULE

This kind of ifdef is horrid though, and should be avoided at all costs. A setting of CONFIG_xxx_MODULE should not affect the *static* kernel image. You should be able to enable an additional module, build it and use it without having to rebuild/reboot the kernel.

In general, the i2c-i801 driver will be built as a module, so that won't affect the kernel image. While I understand your point, there was a reason for the horrid ifdefs. The idea was that we don't want to bloat the kernel (or the i2c-i801 module) with hardware system specific code if the builder knows upfront that the kernel will never run on the relevant hardware system. So, if the builder doesn't select the apanel and fschmd drivers, we build the i2c-i801 driver without the specific code for systems with these devices. The fact is that i2c-i801 is a very popular driver when apanel and fschmd are only used on a few systems.

Of course this would go wrong if a user was to build the apanel or fschmd driver out of tree, but we couldn't find any reason why anybody would be doing so.

With x86 becoming an embedded architecture, it seemed relevant to let people build as small an x86 kernel as possible, thus the decision to go for the horrid ifdefs.

Quoted 2 lines

I know there are *some* cases where we violate that rule, but that doesn't make it any nicer.

Note that my patch is merely moving this code around, it's not introducing it.

If you really think we should change this, then maybe a good compromise would be to use #ifdef CONFIG_X86 instead of the module-specific ones. This would let at least non-x86 systems built the i2c-i801 driver without the hardware specific code. But OTOH I'm not even sure if there's any non-x86 system out there using an Intel 82801 chipset, so maybe that would be exactly equivalent to dropping the ifdefs altogether. Or IA64 systems maybe...?

Yet another possibility would be a dedicated Kconfig option (CONFIG_I2C_I801_POPULATE or even CONFIG_I2C_POPULATE and make it cross-driver) that would be hidden and enabled by default, and visible only when CONFIG_EMBEDDED is set?

In both cases, that would be an all-or-nothing setting, but I guess that people who care about the size of i2c-i801 have a proper way to declare their I2C devices on the SMBus. Or at least I hope so...

I'm glad we're discussing this now, as I am on my way to add even more such hardware-specific code to the i2c-i801 driver. All in all this really shows how much x86 lacks proper description for the hardware setup at the firmware or platform code level, but fixing this is out of scope for me.

Signature · 1 line
Jean Delvare