Skip to contentSkip to conversation

i2c algo, Add i2c-algo-i801 driver [v1]

RFC PATCH In review Prarit Bhargava 6 participants 24 messages Apr 9, 2014 – Apr 11, 2014 7 messages not in the archive

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

RFC PATCH 1/1 i2c algo, Add i2c-algo-i801 driver [v1]

RFC and a work in progress ... I need to go through and do a bunch of error condition checking, more testing, etc. I'm just throwing this out there to see if anyone has any major concerns about doing something like this.

TODO:

- decipher error returns from ACPI AML operations (and implement those too)
- additional error checking from i2c and acpi function calls (this code is not robust enough)
- testing

P.

----8<----

Some ACPI tables on new systems implement an SBUS device in ACPI. This results in a conflict with the ACPI tables and the i2c-i801 driver over the address space. As a result the i2c-i801 driver will not load. To workaround this, we have users use the kernel parameter "acpi_enforce_resources=lax". This, isn't a good solution as I've seen other conflicts on some systems that are also overriden. I thought about implementing an i2c-core kernel parameter and a wrapper function for acpi_check_resource_conflict() but that seems rather clunky and doesn't resolve the issue of the shared resource between the ACPI and the device.

There isn't any documentaton on Intel's website about the SBUS device but from reading the acpidump it looks like the operations are straightforward.

SSXB
transmit one byte
SRXB
receive one byte
SWRB
write one byte
SRDB
read one byte
SWRW
write one word
SRDW
read one word
SBLW
write block
SBRW
read block

I've implemented these as an i2c algorithm so that users who cannot load the regular i801 i2c driver can at least get the functionality they are looking for.

Cc Jean Delvare <[email protected]>
Cc Seth Heasley <[email protected]>
Cc Matthew Garrett <matthew.garrett-05XSO3Yj/[email protected]>
Cc Bjorn Helgaas <[email protected]>
Cc Rafael J. Wysocki <[email protected]>
Cc Janet Morgan <[email protected]>
Cc Myron Stowe <[email protected]>
---
 drivers/i2c/algos/Kconfig         |    3 +
 drivers/i2c/algos/Makefile        |    1 +
 drivers/i2c/algos/i2c-algo-i801.c |  211 +++++++++++++++++++++++++++++++++++++
 drivers/i2c/busses/Kconfig        |    1 +
 4 files changed, 216 insertions(+)
 create mode 100644 drivers/i2c/algos/i2c-algo-i801.c
drivers/i2c/algos/Kconfig +3 -0
index f1cfe7e..98b382c 100644
@@ -14,4 +14,7 @@ config I2C_ALGOPCF
 config I2C_ALGOPCA
 	tristate "I2C PCA 9564 interfaces"
 
+config I2C_ALGOI801
+	tristate "I2C I801 interfaces"
+
 endmenu
drivers/i2c/algos/Makefile +1 -0
index 215303f..2c7cc99 100644
@@ -5,5 +5,6 @@
 obj-$(CONFIG_I2C_ALGOBIT)	+= i2c-algo-bit.o
 obj-$(CONFIG_I2C_ALGOPCF)	+= i2c-algo-pcf.o
 obj-$(CONFIG_I2C_ALGOPCA)	+= i2c-algo-pca.o
+obj-$(CONFIG_I2C_ALGOI801)	+= i2c-algo-i801.o
 
 ccflags-$(CONFIG_I2C_DEBUG_ALGO) := -DDEBUG
drivers/i2c/algos/i2c-algo-i801.c new file +211 -0

211 lines not on this page · raw message

drivers/i2c/busses/Kconfig +1 -0
index 014afab..a4d97ae 100644
@@ -81,6 +81,7 @@ config I2C_I801
 	tristate "Intel 82801 (ICH/PCH)"
 	depends on PCI
 	select CHECK_SIGNATURE if X86 && DMI
+	select I2C_ALGOI801
 	help
 	  If you say yes to this option, support will be included for the Intel
 	  801 family of mainboard I2C interfaces.  Specifically, the following
Signature · 1 line
1.7.9.3

A message that is not in the archive (sent off-list or not yet received): 1397060563-30431-1-git-send-email-prarit-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org

#2 lore raw
Quoted 3 lines · Prarit Bhargava

RFC and a work in progress ... I need to go through and do a bunch of error condition checking, more testing, etc. I'm just throwing this out there to see if anyone has any major concerns about doing something like this.

This isn't really a good approach. These aren't standardised ACPI methods, so you have no guarantee that they exist. The fact that a method with one of these names exists is no guarantee that it has the same behaviour as the ones on your board. There's no guarantee that you're not racing against the firmware.

These systems simply don't safely support OS-level i2c access.

Signature · 1 line
Matthew Garrett <[email protected]>
#3 lore raw
Quoted 7 lines · Matthew Garrett
Quoted 3 lines · Prarit Bhargava

RFC and a work in progress ... I need to go through and do a bunch of error condition checking, more testing, etc. I'm just throwing this out there to see if anyone has any major concerns about doing something like this.

This isn't really a good approach. These aren't standardised ACPI methods, so you have no guarantee that they exist. The fact that a

I've looked at the ACPI dump across six different systems (3 different vendors, and an intel whitebox), and the data appears to be identical. Could Intel change these? Yes, of course they could, but that's no different from any other undocumented driver in the kernel.

Quoted 4 lines

method with one of these names exists is no guarantee that it has the same behaviour as the ones on your board. There's no guarantee that you're not racing against the firmware.

I think there is -- AFAICT the operations are serialized; if they aren't that is an associated risk. Hopefully someone from Intel will lend a hand here and let me know if I'm doing something horrible ;)

Quoted 1 line

These systems simply don't safely support OS-level i2c access.

Possibly -- my interpretation of the ACPI AML could be wrong but it seems like these operations are here for the OS.

I'm not denying there is a lot of risk in doing this...

P.

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

#5 lore raw
Quoted 7 lines · Prarit Bhargava
Quoted 5 lines · Matthew Garrett
Quoted 3 lines · Prarit Bhargava

RFC and a work in progress ... I need to go through and do a bunch of error condition checking, more testing, etc. I'm just throwing this out there to see if anyone has any major concerns about doing something like this.

Quoted 7 lines
Quoted 2 lines

This isn't really a good approach. These aren't standardised ACPI methods, so you have no guarantee that they exist. The fact that a

I've looked at the ACPI dump across six different systems (3 different vendors, and an intel whitebox), and the data appears to be identical. Could Intel change these? Yes, of course they could, but that's no different from any other undocumented driver in the kernel.

Not really. These are an internal implementation detail, not an exported interface. We try to write drivers for exported interfaces, even if they're not documented.

Quoted 8 lines
Quoted 4 lines

method with one of these names exists is no guarantee that it has the same behaviour as the ones on your board. There's no guarantee that you're not racing against the firmware.

I think there is -- AFAICT the operations are serialized; if they aren't that is an associated risk. Hopefully someone from Intel will lend a hand here and let me know if I'm doing something horrible ;)

Imagine an i2c chip with indexed register access. What stops:

CPU0 (i2c): CPU1 (ACPI):
SBWB register address
SBWB register address
SBRB register value
SBRB register value

and CPU0 getting back the wrong value?

Signature · 1 line
Matthew Garrett <[email protected]>
#6 lore raw
Quoted 29 lines · Matthew Garrett
Quoted 7 lines · Prarit Bhargava
Quoted 5 lines · Matthew Garrett
Quoted 3 lines · Prarit Bhargava

RFC and a work in progress ... I need to go through and do a bunch of error condition checking, more testing, etc. I'm just throwing this out there to see if anyone has any major concerns about doing something like this.

Quoted 7 lines
Quoted 2 lines

This isn't really a good approach. These aren't standardised ACPI methods, so you have no guarantee that they exist. The fact that a

I've looked at the ACPI dump across six different systems (3 different vendors, and an intel whitebox), and the data appears to be identical. Could Intel change these? Yes, of course they could, but that's no different from any other undocumented driver in the kernel.

Not really. These are an internal implementation detail, not an exported interface. We try to write drivers for exported interfaces, even if they're not documented.

Quoted 8 lines
Quoted 4 lines

method with one of these names exists is no guarantee that it has the same behaviour as the ones on your board. There's no guarantee that you're not racing against the firmware.

I think there is -- AFAICT the operations are serialized; if they aren't that is an associated risk. Hopefully someone from Intel will lend a hand here and let me know if I'm doing something horrible ;)

Quoted 8 lines

Imagine an i2c chip with indexed register access. What stops:

CPU0 (i2c): CPU1 (ACPI):
SBWB register address
SBWB register address
SBRB register value
SBRB register value

Your example is no different from what we've told people to do right now when they see the ACPI resource conflict message and use a kernel parameter to override the error condition. I'm not disputing that this could be a problem -- see my previous comment about hoping that someone @ Intel will let us know if we're doing something horrible.

P.

Quoted 2 lines

and CPU0 getting back the wrong value?

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

#8 lore raw
Quoted 10 lines · Prarit Bhargava
Quoted 8 lines · Matthew Garrett

Imagine an i2c chip with indexed register access. What stops:

CPU0 (i2c): CPU1 (ACPI):
SBWB register address
SBWB register address
SBRB register value
SBRB register value

Quoted 5 lines

Your example is no different from what we've told people to do right now when they see the ACPI resource conflict message and use a kernel parameter to override the error condition. I'm not disputing that this could be a problem -- see my previous comment about hoping that someone @ Intel will let us know if we're doing something horrible.

Right. It's dangerous, which is why we forbid it by default. How do we benefit from having a driver that's no safer?

Signature · 1 line
Matthew Garrett <[email protected]>
#9 lore raw
Quoted 11 lines · Matthew Garrett
Quoted 10 lines · Prarit Bhargava
Quoted 8 lines · Matthew Garrett

Imagine an i2c chip with indexed register access. What stops:

CPU0 (i2c): CPU1 (ACPI):
SBWB register address
SBWB register address
SBRB register value
SBRB register value

Quoted 8 lines
Quoted 5 lines

Your example is no different from what we've told people to do right now when they see the ACPI resource conflict message and use a kernel parameter to override the error condition. I'm not disputing that this could be a problem -- see my previous comment about hoping that someone @ Intel will let us know if we're doing something horrible.

Right. It's dangerous, which is why we forbid it by default. How do we benefit from having a driver that's no safer?

We have yet to see where the existing case exhibits the behaviour of a race. In fact, AFAICT, all we've seen is stability. So it's no safer? Yep. It's as equally not racy as the existing workaround.

P.

Quoted 1 line

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

#11 lore raw
Quoted 8 lines · Prarit Bhargava
Quoted 2 lines · Matthew Garrett

Right. It's dangerous, which is why we forbid it by default. How do we benefit from having a driver that's no safer?

We have yet to see where the existing case exhibits the behaviour of a race. In fact, AFAICT, all we've seen is stability. So it's no safer? Yep. It's as equally not racy as the existing workaround.

So... why add the driver at all? Refusing to permit the kernel to touch these resources is a deliberate design choice, because of the potential for these races. It'll work absolutely fine right up until the point where you end up reading the wrong temperature value from an i2c hwmon chip and perform a critical thermal shutdown.

Signature · 1 line
Matthew Garrett <[email protected]>
#12 lore raw
Quoted 10 lines · Matthew Garrett
Quoted 8 lines · Prarit Bhargava
Quoted 2 lines · Matthew Garrett

Right. It's dangerous, which is why we forbid it by default. How do we benefit from having a driver that's no safer?

We have yet to see where the existing case exhibits the behaviour of a race. In fact, AFAICT, all we've seen is stability. So it's no safer? Yep. It's as equally not racy as the existing workaround.

Quoted 5 lines

So... why add the driver at all? Refusing to permit the kernel to touch these resources is a deliberate design choice, because of the potential for these races. It'll work absolutely fine right up until the point where you end up reading the wrong temperature value from an i2c hwmon chip and perform a critical thermal shutdown.

Because it seems like the "right" thing to do is use the ACPI interface rather than the i801 pci driver. At least to me that makes sense. OTOH, if Jean thinks there isn't a need I can drop it.

P.

Quoted 1 line

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

#14 lore raw
Quoted 11 lines · Prarit Bhargava
Quoted 5 lines · Matthew Garrett

So... why add the driver at all? Refusing to permit the kernel to touch these resources is a deliberate design choice, because of the potential for these races. It'll work absolutely fine right up until the point where you end up reading the wrong temperature value from an i2c hwmon chip and perform a critical thermal shutdown.

Because it seems like the "right" thing to do is use the ACPI interface rather than the i801 pci driver. At least to me that makes sense. OTOH, if Jean thinks there isn't a need I can drop it.

We should use any ACPI interface that allows us to perform appropriate synchronisation with the hardware, but there's no real advantage in using an ACPI interface that's still racy.

Signature · 1 line
Matthew Garrett <[email protected]>
#15 lore raw
In reply to Matthew Garrett
Quoted 6 lines · Matthew Garrett
Quoted 5 lines · Prarit Bhargava
Quoted 2 lines · Matthew Garrett

Right. It's dangerous, which is why we forbid it by default. How do we benefit from having a driver that's no safer?

Quoted 7 lines
Quoted 3 lines

We have yet to see where the existing case exhibits the behaviour of a race. In fact, AFAICT, all we've seen is stability. So it's no safer? Yep. It's as equally not racy as the existing workaround.

So... why add the driver at all? Refusing to permit the kernel to touch these resources is a deliberate design choice, because of the potential for these races. (...)

So it is a deliberate design choice to prevent the user from accessing his/her own hardware? I want to be able to read the SPD EEPROMs and the temperature sensors on my memory modules, and this requires SMBus access.

The ACPI interface to hardware monitoring chips is horribly limited. Until the ACPI people come up with something which really exposes most of the features of the hardware monitoring chips currently provide, native access it required. At the moment, when a full-featured hardware monitoring chip monitors 5 to 10 voltage inputs, 5 fans and 3 temperature sensors, ACPI will show 2 thermal zones at best, not always updated in real-time, with limited resolution, and the fans are shown without their speed. That simply sucks.

So we need either proper ACPI interfaces to all the useful features, or low-level, safe access to the registers through ACPI. Until we have that, we are condemned to live dangerously in an hostile world :(

Signature · 2 lines
Jean Delvare
SUSE L3 Support
#16 lore raw
Quoted 9 lines · Jean Delvare
Quoted 3 lines · Matthew Garrett

So... why add the driver at all? Refusing to permit the kernel to touch these resources is a deliberate design choice, because of the potential for these races. (...)

So it is a deliberate design choice to prevent the user from accessing his/her own hardware? I want to be able to read the SPD EEPROMs and the temperature sensors on my memory modules, and this requires SMBus access.

Sure, and if you have made a conscious decision that it's safe to do so in your specific use case then you can pass the kernel parameter that allows you to. But it's unsafe in the general case, and so the appropriate thing is for the kernel to forbid it.

Signature · 1 line
Matthew Garrett <[email protected]>
#17 lore raw
In reply to Matthew Garrett
Quoted 12 lines · Matthew Garrett
Quoted 8 lines · Prarit Bhargava
Quoted 3 lines · Matthew Garrett

method with one of these names exists is no guarantee that it has the same behaviour as the ones on your board. There's no guarantee that you're not racing against the firmware.

I think there is -- AFAICT the operations are serialized; if they aren't that is an associated risk. Hopefully someone from Intel will lend a hand here and let me know if I'm doing something horrible ;)

Imagine an i2c chip with indexed register access. What stops:

Quoted 7 lines

CPU0 (i2c): CPU1 (ACPI):
SBWB register address
SBWB register address
SBRB register value
SBRB register value

and CPU0 getting back the wrong value?

Certainly there is some ACPI lock to prevent ACPI from racing with itself. Can't we just use it too?

Signature · 2 lines
Jean Delvare
SUSE L3 Support
#18 lore raw
Quoted 2 lines · Jean Delvare

Certainly there is some ACPI lock to prevent ACPI from racing with itself. Can't we just use it too?

There may be, but it's up to the firmware vendor to implement that and there's no standard. Some systems may just skip it because there's only a single entry point.

Signature · 1 line
Matthew Garrett <[email protected]>
#19 lore raw
In reply to Matthew Garrett
Quoted 11 lines · Matthew Garrett
Quoted 10 lines · Prarit Bhargava
Quoted 7 lines · Matthew Garrett
Quoted 3 lines · Prarit Bhargava

RFC and a work in progress ... I need to go through and do a bunch of error condition checking, more testing, etc. I'm just throwing this out there to see if anyone has any major concerns about doing something like this.

This isn't really a good approach. These aren't standardised ACPI methods, so you have no guarantee that they exist. The fact that a

Quoted 8 lines
Quoted 4 lines

I've looked at the ACPI dump across six different systems (3 different vendors, and an intel whitebox), and the data appears to be identical. Could Intel change these? Yes, of course they could, but that's no different from any other undocumented driver in the kernel.

Not really. These are an internal implementation detail, not an exported interface. We try to write drivers for exported interfaces, even if they're not documented.

Aren't the methods the exported interface? I'm obviously missing something :)

Quoted 12 lines
Quoted 9 lines
Quoted 5 lines

method with one of these names exists is no guarantee that it has the same behaviour as the ones on your board. There's no guarantee that you're not racing against the firmware.

I think there is -- AFAICT the operations are serialized; if they aren't that is an associated risk. Hopefully someone from Intel will lend a hand here and let me know if I'm doing something horrible ;)

Imagine an i2c chip with indexed register access. What stops:

Quoted 7 lines

CPU0 (i2c): CPU1 (ACPI):
SBWB register address
SBWB register address
SBRB register value
SBRB register value

and CPU0 getting back the wrong value?

I thought that the "Serialized" keyword in the methods specifically indicate that this cannot happen.

/me could be confused but from the ACPI spec:

SerializeRule is optional and is a flag that defines whether the method is serialized or not and is one of the following: Serialized or NotSerialized. A method that is serialized cannot be reentered by additional threads. If not specified, the default is NotSerialized.

P.

#20 lore raw
Quoted 7 lines · Prarit Bhargava
Quoted 3 lines · Matthew Garrett

Not really. These are an internal implementation detail, not an exported interface. We try to write drivers for exported interfaces, even if they're not documented.

Aren't the methods the exported interface? I'm obviously missing something :)

No. The device doesn't have a _HID(), so they're internal methods.

Quoted 8 lines
Quoted 8 lines

Imagine an i2c chip with indexed register access. What stops:

CPU0 (i2c): CPU1 (ACPI):
SBWB register address
SBWB register address
SBRB register value
SBRB register value

Quoted 4 lines
Quoted 1 line

and CPU0 getting back the wrong value?

I thought that the "Serialized" keyword in the methods specifically indicate that this cannot happen.

It means you can't run the same method twice at the same time, but in the above case you're not doing that. Nothing ensures that SBWB can't be run again before SBRB is run.

Signature · 1 line
Matthew Garrett <[email protected]>
#21 lore raw
Quoted 13 lines · Matthew Garrett
Quoted 7 lines · Prarit Bhargava
Quoted 3 lines · Matthew Garrett

Not really. These are an internal implementation detail, not an exported interface. We try to write drivers for exported interfaces, even if they're not documented.

Aren't the methods the exported interface? I'm obviously missing something :)

No. The device doesn't have a _HID(), so they're internal methods.

Quoted 2 lines
Quoted 2 lines

Imagine an i2c chip with indexed register access. What stops:

I think I missed something in this example (and if I have this wrong, please say so).

Are you saying *both* the old (pci-style) driver and my new driver (ACPI) are loaded? Or something else?

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

CPU0 (i2c): CPU1 (ACPI):
SBWB register address
SBWB register address
SBRB register value
SBRB register value

and CPU0 getting back the wrong value?

P.

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

#23 lore raw
Quoted 5 lines · Prarit Bhargava

I think I missed something in this example (and if I have this wrong, please say so).

Are you saying *both* the old (pci-style) driver and my new driver (ACPI) are loaded? Or something else?

Your ACPI driver is loaded. The user attempts to read a value from a thermal hwmon chip. You execute SBWB in order to write the register address to the chip. You then take an ACPI interrupt. The ACPI core executes a method that executes SBWB and writes a different register address to the chip. Control passes back to you. You call SBRB and read back a value from the wrong register.

Signature · 1 line
Matthew Garrett <[email protected]>
#24 lore raw
In reply to Matthew Garrett

Hi Matthew,

Quoted 5 lines · Matthew Garrett
Quoted 3 lines · Prarit Bhargava

RFC and a work in progress ... I need to go through and do a bunch of error condition checking, more testing, etc. I'm just throwing this out there to see if anyone has any major concerns about doing something like this.

Quoted 7 lines

This isn't really a good approach. These aren't standardised ACPI methods, so you have no guarantee that they exist. The fact that a method with one of these names exists is no guarantee that it has the same behaviour as the ones on your board. There's no guarantee that you're not racing against the firmware.

These systems simply don't safely support OS-level i2c access.

But people need that. And they have been for almost a decade. It's about time that hardware vendors realize that. Yes, I mean Intel, amongst others.

Prarit's approach may not be perfect but it has the merit of bringing the topic for discussion, at last. And using his driver would still be much safer than using i2c-i801 with acpi_enforce_resources=lax. If we can come up with a detection method that is reliable enough, it looks completely acceptable to me.

Of course it would be much better if vendors could just implement the standard SMBus CMI interface, but having a way to deal with existing hardware and BIOSes is still good.

Signature · 2 lines
Jean Delvare
SUSE L3 Support
#25 lore raw
Quoted 7 lines · Jean Delvare

Hi Matthew,

Quoted 2 lines

These systems simply don't safely support OS-level i2c access.

But people need that. And they have been for almost a decade. It's about time that hardware vendors realize that. Yes, I mean Intel, amongst others.

There is no safe way to do it. If the user is happy to accept the inherent dangers, the user can pass the kernel parameter.

Signature · 1 line
Matthew Garrett <[email protected]>
#26 lore raw
Quoted 11 lines · Matthew Garrett
Quoted 7 lines · Jean Delvare

Hi Matthew,

Quoted 2 lines

These systems simply don't safely support OS-level i2c access.

But people need that. And they have been for almost a decade. It's about time that hardware vendors realize that. Yes, I mean Intel, amongst others.

There is no safe way to do it. If the user is happy to accept the inherent dangers, the user can pass the kernel parameter.

Oh, there is. There always is. It would just take a few engineers, an equal amount of chairs and pencils, a table and a few sheets of paper. There's no technical reason why this problem can't be solved.

Signature · 2 lines
Jean Delvare
SUSE L3 Support
#27 lore raw
In reply to a message not in the archive

Hi Prarit,

Quoted 45 lines · Prarit Bhargava

RFC and a work in progress ... I need to go through and do a bunch of error condition checking, more testing, etc. I'm just throwing this out there to see if anyone has any major concerns about doing something like this.

TODO:

- decipher error returns from ACPI AML operations (and implement those too)
- additional error checking from i2c and acpi function calls (this code is not robust enough)
- testing

P.

----8<----

Some ACPI tables on new systems implement an SBUS device in ACPI. This results in a conflict with the ACPI tables and the i2c-i801 driver over the address space. As a result the i2c-i801 driver will not load. To workaround this, we have users use the kernel parameter "acpi_enforce_resources=lax". This, isn't a good solution as I've seen other conflicts on some systems that are also overriden. I thought about implementing an i2c-core kernel parameter and a wrapper function for acpi_check_resource_conflict() but that seems rather clunky and doesn't resolve the issue of the shared resource between the ACPI and the device.

There isn't any documentaton on Intel's website about the SBUS device but from reading the acpidump it looks like the operations are straightforward.

SSXB
transmit one byte
SRXB
receive one byte
SWRB
write one byte
SRDB
read one byte
SWRW
write one word
SRDW
read one word
SBLW
write block
SBRW
read block

Quoted 3 lines

I've implemented these as an i2c algorithm so that users who cannot load the regular i801 i2c driver can at least get the functionality they are looking for.

Writing a driver for the ACPI interface to the SMBus is IMHO a very good idea, thanks for doing that.

However I have two technical concerns with your approach:

1* What you wrote is NOT an "i2c algo". i2c "algorithms" are abstracted I2C implementations, not correlated with any hardware or BIOS specific interfaces. If you check other drivers under i2c/algos you'll see they do NOT call i2c_add_adapter (although they may implement helper wrappers around that function.) Hardware-specific drivers which build on top of the algo driver are responsible for that.

What you wrote is much more like i2c/busses/i2c-scmi.c, so it is actually an i2c _bus_ driver.

2* You are creating a link between i2c-i801 and your driver, where IMHO there should not be any. Both drivers are independent, and from the kernel's perspective, they are not even for the same hardware. In your case the ACPI interface is backed by an i801-like chip, but the same interface could totally be implemented on top of any other chip.

So I invite you to make your driver an independent i2c bus driver much like i2c-scmi.

Thanks,

Signature · 2 lines
Jean Delvare
SUSE L3 Support
#28 lore raw
Quoted 67 lines · Jean Delvare

Hi Prarit,

Quoted 45 lines · Prarit Bhargava

RFC and a work in progress ... I need to go through and do a bunch of error condition checking, more testing, etc. I'm just throwing this out there to see if anyone has any major concerns about doing something like this.

TODO:

- decipher error returns from ACPI AML operations (and implement those too)
- additional error checking from i2c and acpi function calls (this code is not robust enough)
- testing

P.

----8<----

Some ACPI tables on new systems implement an SBUS device in ACPI. This results in a conflict with the ACPI tables and the i2c-i801 driver over the address space. As a result the i2c-i801 driver will not load. To workaround this, we have users use the kernel parameter "acpi_enforce_resources=lax". This, isn't a good solution as I've seen other conflicts on some systems that are also overriden. I thought about implementing an i2c-core kernel parameter and a wrapper function for acpi_check_resource_conflict() but that seems rather clunky and doesn't resolve the issue of the shared resource between the ACPI and the device.

There isn't any documentaton on Intel's website about the SBUS device but from reading the acpidump it looks like the operations are straightforward.

SSXB
transmit one byte
SRXB
receive one byte
SWRB
write one byte
SRDB
read one byte
SWRW
write one word
SRDW
read one word
SBLW
write block
SBRW
read block

Quoted 3 lines

I've implemented these as an i2c algorithm so that users who cannot load the regular i801 i2c driver can at least get the functionality they are looking for.

Writing a driver for the ACPI interface to the SMBus is IMHO a very good idea, thanks for doing that.

However I have two technical concerns with your approach:

1* What you wrote is NOT an "i2c algo". i2c "algorithms" are abstracted I2C implementations, not correlated with any hardware or BIOS specific interfaces. If you check other drivers under i2c/algos you'll see they do NOT call i2c_add_adapter (although they may implement helper wrappers around that function.) Hardware-specific drivers which build on top of the algo driver are responsible for that.

What you wrote is much more like i2c/busses/i2c-scmi.c, so it is actually an i2c _bus_ driver.

Quoted 8 lines

2* You are creating a link between i2c-i801 and your driver, where IMHO there should not be any. Both drivers are independent, and from the kernel's perspective, they are not even for the same hardware. In your case the ACPI interface is backed by an i801-like chip, but the same interface could totally be implemented on top of any other chip.

So I invite you to make your driver an independent i2c bus driver much like i2c-scmi.

Hey Jean -- thanks for the valuable feedback. This is exactly why I RFC'd it :) before I got in too deep :)

I'll rework the patch with your suggestions. I may have (possibly dumb) questions and I hope that's okay ..

P.

Quoted 3 lines

Thanks,

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

#30 lore raw
Quoted 2 lines · Prarit Bhargava

I'll rework the patch with your suggestions. I may have (possibly dumb) questions and I hope that's okay ..

No problem, I'll help as much as I can :)

Signature · 2 lines
Jean Delvare
SUSE L3 Support