RFC: complete rewrite of i2c-i801 for 2.6.x
Hello all:
I've started a complete re-write of the i2c-i801 SMBus driver. As compared to the old one, this one:
1) Supports fewer transaction types... still TODO
2) Does not have any BIOS workaround nastiness. I am hoping that I can leave that out and that people who need that can be directed to just use the old driver.
3) Does not support PEC (not sure who uses it... can also be TODO if there's interest).
And the primary difference 4) uses interrupts instead of polling.
I'm not exactly a stranger to interrupt-handling, having designed whole interrupt handling mechanisms for (non-Linux) embedded systems. *But*, as this is my first shot at it with a Linux driver... I would appreciate a close look at those parts. The design is similar to i2c-iop3xx, except where it's different. :)
My test target / dev host shares an IRQ between sound and SMBus; almost all of my testing was performed with xmms blasting away.
Re performance: this driver does not improve CPU utilization, because the polling loop on the old one sleeps a lot anyway. Elapsed time per transaction did improve by varying degrees, depending on the transaction type:
OLD:I2C_SMBUS_QUICK(nodev) 0.00202I2C_SMBUS_QUICK 0.00203I2C_SMBUS_BYTE 0.00203I2C_SMBUS_BYTE_DATA 0.00402I2C_SMBUS_WORD_DATA 0.00602
NEW:I2C_SMBUS_QUICK(nodev) 0.00108I2C_SMBUS_QUICK 0.00107I2C_SMBUS_BYTE 0.00190I2C_SMBUS_BYTE_DATA 0.00365I2C_SMBUS_WORD_DATA 0.00449
(Script for above: http://members.dca.net/mhoffman/sensors/temp/test.pl)
The diff is harder to read than the complete files which are attached...
Thanks and regards,
Signature · 509 lines
Mark M. Hoffman [email protected] -------------- next part -------------- /* i2c-i801.c - Part of lm_sensors, Linux kernel modules for hardware monitoring Copyright (c) 2004 Mark M. Hoffman <[email protected]> derived in part from an older i2c-i801.c: Copyright (c) 1998-2002 Frodo Looijaard <[email protected]>, Philip Edelbrock <[email protected]>, and Mark D. Studebaker <[email protected]> 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* PCI Address Constants */ #define I801_PCI_BAR 0x04 #define I801_PCI_HOSTC 0x40 #define I801_PCI_HOSTC_I2C_EN (1 << 2) #define I801_PCI_HOSTC_SMB_SMI_EN (1 << 1) #define I801_PCI_HOSTC_HST_EN (1 << 0) /* * HOST STATUS REGISTER */ #define I801_REG_HST_STS 0x00 #define I801_HST_STS_BDS (1 << 7) #define I801_HST_STS_IU (1 << 6) #define I801_HST_STS_ALERT (1 << 5) #define I801_HST_STS_FAIL (1 << 4) #define I801_HST_STS_COLL (1 << 3) #define I801_HST_STS_DEV (1 << 2) #define I801_HST_STS_INTR (1 << 1) #define I801_HST_STS_BUSY (1 << 0) /* mask for events we normally handle */ #define I801_HST_STS_MASK_NORM ( \ I801_HST_STS_FAIL | \ I801_HST_STS_COLL | \ I801_HST_STS_DEV | \ I801_HST_STS_INTR) /* mask for all events */ #define I801_HST_STS_MASK_ALL ( \ I801_HST_STS_BDS | \ I801_HST_STS_ALERT | \ I801_HST_STS_FAIL | \ I801_HST_STS_COLL | \ I801_HST_STS_DEV | \ I801_HST_STS_INTR) /* * HOST CONTROL REGISTER */ #define I801_REG_HST_CNT 0x02 #define I801_HST_CNT_START 0x40 #define I801_HST_CNT_INTREN 0x01 /* SMB CMD field values */ #define I801_HST_CNT_QUICK (0x0 << 2) #define I801_HST_CNT_BYTE (0x1 << 2) #define I801_HST_CNT_BYTE_DATA (0x2 << 2) #define I801_HST_CNT_WORD_DATA (0x3 << 2) #define I801_HST_CNT_PROC_CALL (0x4 << 2) #define I801_HST_CNT_BLOCK (0x5 << 2) #define I801_HST_CNT_I2C_READ (0x6 << 2) #define I801_HST_CNT_BLOCK_PROC (0x7 << 2) #define I801_REG_HST_CMD 0x03 #define I801_REG_XMIT_SLVA 0x04 #define I801_REG_HST_D0 0x05 #define I801_REG_HST_D1 0x06 #define I801_REG_HOST_BLOCK_DB 0x07 #define I801_REG_PEC 0x08 #define I801_REG_RCV_SLVA 0x09 #define I801_REG_SLV_DATA 0x0a #define I801_REG_AUX_STS 0x0c #define I801_REG_AUX_CTL 0x0d #define I801_REG_SMLINK_PIN_CTL 0x0e #define I801_REG_SMBUS_PIN_CTL 0x0f /* remaining regs on >= ICH3 only */ #define I801_REG_SLV_STS 0x10 #define I801_REG_SLV_CMD 0x11 #define I801_REG_NOTIFY_DADDR 0x14 #define I801_REG_NOTIFY_DLOW 0x16 #define I801_REG_NOTIFY_DHIGH 0x17 -------------- next part -------------- /* i2c-i801.c - Part of lm_sensors, Linux kernel modules for hardware monitoring Copyright (c) 2004 Mark M. Hoffman <[email protected]> derived in part from an older i2c-i801.c: Copyright (c) 1998-2002 Frodo Looijaard <[email protected]>, Philip Edelbrock <[email protected]>, and Mark D. Studebaker <[email protected]> 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* PCI/ID IO BB Name AKA --------------------------------------------------- 8086:2413 16 no ICH 82801AA 8086:2423 16 no ICH0 82801AB 8086:2443 16 no ICH2 82801BA 8086:2443 16 no ICH2M 82801BAM 8086:2483 32 no ICH3S 82801CA 8086:2483 32 no ICH3M 82801CAM 8086:24c3 32 yes ICH4 82801DB 8086:24c3 32 yes ICH4M 82801DBM 8086:24d3 32 yes ICH5 82801EB 8086:24d3 32 yes ICH5R 82801ER 8086:25a4 32 yes ICH(?) 6300ESB 8086:266a 32 yes ICH6 82801FB 8086:266a 32 yes ICH6R 82801FR 8086:266a 32 yes ICH6W 82801FW 8086:266a 32 yes ICH6RW 82801FRW IO indicates the size of the port region BB indicates the existence of a block buffer */ //#define DEBUG 1 #include <linux/config.h> #include <linux/module.h> #include <linux/pci.h> #include <linux/kernel.h> #include <linux/stddef.h> #include <linux/delay.h> #include <linux/sched.h> #include <linux/ioport.h> #include <linux/interrupt.h> #include <linux/init.h> #include <linux/i2c.h> #include <asm/io.h> #include "i2c-i801.h" struct i2c_i801_algo_data { spinlock_t lock; wait_queue_head_t waitq; int status; /* copy of h/w register */ }; /* I/O port base address & size */ /* TODO: bundle these into i2c_i801_algo_data structure */ static unsigned i801_smba; static unsigned i801_iosize; static inline u8 i801_read(u8 reg) { return inb(i801_smba + reg); } static inline void i801_write(u8 reg, u8 data) { outb(data, i801_smba + reg); } static struct pci_dev *I801_dev; /* TODO: remove */ static void i801_abort(struct i2c_adapter *adap) { /* TODO: add code here */ } /* fetch & consume host status out of algo_data */ static inline int i801_get_status(struct i2c_i801_algo_data *algo_data) { unsigned long flags; int status; spin_lock_irqsave(&algo_data->lock, flags); status = algo_data->status; algo_data->status = 0; spin_unlock_irqrestore(&algo_data->lock, flags); return status; } static int i801_transaction(struct i2c_adapter *adap, int smbcmd) { struct i2c_i801_algo_data *algo_data = adap->algo_data; int interrupted, status, ret = 0; /* TODO: add status check / bus reset code here */ /* start the transaction */ i801_write(I801_REG_HST_CNT, smbcmd | I801_HST_CNT_INTREN | I801_HST_CNT_START); interrupted = wait_event_interruptible_timeout(algo_data->waitq, ((status = i801_get_status(algo_data)) & I801_HST_STS_MASK_NORM), HZ/2); if (unlikely(interrupted < 0)) { dev_dbg(&I801_dev->dev, "Transfer interrupted, aborting!\n"); ret = -ERESTARTSYS; } else if (likely(I801_HST_STS_INTR = (status & I801_HST_STS_MASK_NORM))) { ret = 0; } else if (status & I801_HST_STS_FAIL) { dev_dbg(&I801_dev->dev, "Transaction failed!\n"); ret = -1; } else if (status & I801_HST_STS_COLL) { dev_dbg(&I801_dev->dev, "Bus collision!\n"); ret = -1; } else if (status & I801_HST_STS_DEV) { dev_dbg(&I801_dev->dev, "No response from client!\n"); ret = -1; } else { dev_dbg(&I801_dev->dev, "Host bus timeout!\n"); ret = -1; } if (unlikely(ret)) i801_abort(adap); return ret; } static s32 i801_access(struct i2c_adapter * adap, u16 addr, unsigned short flags, char read_write, u8 command, int size, union i2c_smbus_data * data) { s32 ret; int smbcmd; switch (size) { case I2C_SMBUS_QUICK: i801_write(I801_REG_XMIT_SLVA, ((addr & 0x7f) << 1) | (read_write & 0x01)); smbcmd = I801_HST_CNT_QUICK; break; case I2C_SMBUS_BYTE: i801_write(I801_REG_XMIT_SLVA, ((addr & 0x7f) << 1) | (read_write & 0x01)); if (read_write = I2C_SMBUS_WRITE) i801_write(I801_REG_HST_CMD, command); smbcmd = I801_HST_CNT_BYTE; break; case I2C_SMBUS_BYTE_DATA: i801_write(I801_REG_XMIT_SLVA, ((addr & 0x7f) << 1) | (read_write & 0x01)); i801_write(I801_REG_HST_CMD, command); if (read_write = I2C_SMBUS_WRITE) i801_write(I801_REG_HST_D0, data->byte); smbcmd = I801_HST_CNT_BYTE_DATA; break; case I2C_SMBUS_WORD_DATA: i801_write(I801_REG_XMIT_SLVA, ((addr & 0x7f) << 1) | (read_write & 0x01)); i801_write(I801_REG_HST_CMD, command); if (read_write = I2C_SMBUS_WRITE) { i801_write(I801_REG_HST_D0, data->word & 0xff); i801_write(I801_REG_HST_D1, data->word >> 8 & 0xff); } smbcmd = I801_HST_CNT_WORD_DATA; break; default: dev_err(&I801_dev->dev, "Unsupported transaction %d\n", size); return -1; } if ((ret = i801_transaction(adap, smbcmd))) return -1; if ((read_write = I2C_SMBUS_WRITE) || (smbcmd = I801_HST_CNT_QUICK)) return 0; switch (smbcmd) { case I801_HST_CNT_BYTE: case I801_HST_CNT_BYTE_DATA: data->byte = i801_read(I801_REG_HST_D0); break; case I801_HST_CNT_WORD_DATA: data->word = (i801_read(I801_REG_HST_D1) << 8) + i801_read(I801_REG_HST_D0); break; } return 0; } static u32 i801_func(struct i2c_adapter *adapter) { return I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_BYTE | I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA; } /* * pass the interrupt status back through algo_data * some events that can occur are not handled by this driver (e.g. SMBALERT) * these are quietly ACK'ed, without waking anyone */ static irqreturn_t i801_isr(int irq, void *dev_id, struct pt_regs *regs) { u8 status = i801_read(I801_REG_HST_STS); /* bail if it's not ours */ if (unlikely(!(status & I801_HST_STS_MASK_ALL))) return IRQ_NONE; dev_dbg(&I801_dev->dev, "IRQ status: 0x%02x\n", status); /* ACK */ i801_write(I801_REG_HST_STS, (status & I801_HST_STS_MASK_ALL)); if (likely(status & I801_HST_STS_MASK_NORM)) { struct i2c_adapter *adap = dev_id; struct i2c_i801_algo_data *algo_data = adap->algo_data; unsigned long flags; spin_lock_irqsave(&algo_data->lock, flags); algo_data->status = status; spin_unlock_irqrestore(&algo_data->lock, flags); wake_up_interruptible(&algo_data->waitq); } return IRQ_HANDLED; } static struct i2c_algorithm i801_algorithm = { .name = "i801 I2C Algorithm", .id = I2C_ALGO_SMBUS, .smbus_xfer = i801_access, .functionality = i801_func, }; static struct i2c_i801_algo_data i801_algo_data; static struct i2c_adapter i801_adapter = { .owner = THIS_MODULE, .class = I2C_CLASS_HWMON, .algo = &i801_algorithm, .name = "i2c-i801", .algo_data = &i801_algo_data, }; static int __devinit i801_probe(struct pci_dev *pcidev, const struct pci_device_id *id) { struct i2c_i801_algo_data *algo_data = i801_adapter.algo_data; int ret; unsigned char temp; if (i801_smba) { dev_err(&pcidev->dev, "Only one device supported.\n"); return -EBUSY; } if ((ret = pci_enable_device(pcidev))) { dev_err(&pcidev->dev, "Couldn't enable device!\n"); return ret; } I801_dev = pcidev; /* TODO: remove */ /* the older chipsets in this family have a smaller IO region */ if ((pcidev->device = PCI_DEVICE_ID_INTEL_82801AA_3) || (pcidev->device = PCI_DEVICE_ID_INTEL_82801AB_3) || (pcidev->device = PCI_DEVICE_ID_INTEL_82801BA_2)) i801_iosize = 16; else i801_iosize = 32; /* grab IO space */ i801_smba = pci_resource_start(pcidev, I801_PCI_BAR); if(!i801_smba) { dev_err(&pcidev->dev, "SMBus base address not initialized!\n"); return -ENODEV; } if (!request_region(i801_smba, i801_iosize, i801_adapter.name)) { dev_err(&pcidev->dev, "SMBus registers 0x%04x-0x%04x " "already in use!\n", i801_smba, i801_smba + i801_iosize - 1); i801_smba = 0; return -ENODEV; } init_waitqueue_head(&algo_data->waitq); spin_lock_init(&algo_data->lock); /* grab interrupt */ if ((ret = request_irq(pcidev->irq, i801_isr, SA_SHIRQ, i801_adapter.name, &i801_adapter))) { dev_err(&pcidev->dev, "request irq %d failed!\n", pcidev->irq); goto OUT1; } dev_info(&pcidev->dev, "SMBus base address: 0x%04x, IRQ: %d\n", i801_smba, pcidev->irq); /* default: SMBus, no SMI#, enable host controller */ pci_write_config_byte(pcidev, I801_PCI_HOSTC, 0x01); pci_read_config_byte(pcidev, I801_PCI_HOSTC, &temp); /* set up the driverfs linkage to our parent device */ i801_adapter.dev.parent = &pcidev->dev; if ((ret = i2c_add_adapter(&i801_adapter))) { dev_err(&pcidev->dev, "Couldn't register adapter!\n"); goto OUT2; } else return 0; OUT2: free_irq(pcidev->irq, &i801_adapter); OUT1: release_region(i801_smba, i801_iosize); i801_smba = 0; return ret; } static void __devexit i801_remove(struct pci_dev *pcidev) { if (i801_smba) { i2c_del_adapter(&i801_adapter); release_region(i801_smba, i801_iosize); free_irq(pcidev->irq, &i801_adapter); i801_smba = 0; } } #define INTEL_SMBUS_DEVICE(id) { \ .vendor = PCI_VENDOR_ID_INTEL, .device = (id), \ .subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID } static struct pci_device_id i801_ids[] = { INTEL_SMBUS_DEVICE(PCI_DEVICE_ID_INTEL_82801AA_3), /* ICH */ INTEL_SMBUS_DEVICE(PCI_DEVICE_ID_INTEL_82801AB_3), /* ICH0 */ INTEL_SMBUS_DEVICE(PCI_DEVICE_ID_INTEL_82801BA_2), /* ICH2 (M) */ INTEL_SMBUS_DEVICE(PCI_DEVICE_ID_INTEL_82801CA_3), /* ICH3 (S,W) */ INTEL_SMBUS_DEVICE(PCI_DEVICE_ID_INTEL_82801DB_3), /* ICH4 (M) */ INTEL_SMBUS_DEVICE(PCI_DEVICE_ID_INTEL_82801EB_3), /* ICH5 (R) */ INTEL_SMBUS_DEVICE(PCI_DEVICE_ID_INTEL_ESB_4), /* ICH??? */ INTEL_SMBUS_DEVICE(PCI_DEVICE_ID_INTEL_ICH6_16), /* ICH6 (R,W,RW) */ { 0, } }; MODULE_DEVICE_TABLE (pci, i801_ids); static struct pci_driver i801_driver = { .name = "i801_smbus", .id_table = i801_ids, .probe = i801_probe, .remove = __devexit_p(i801_remove), }; static int __init i801_init(void) { return pci_register_driver(&i801_driver); } static void __exit i801_exit(void) { pci_unregister_driver(&i801_driver); } MODULE_AUTHOR ("Mark M. Hoffman <[email protected]>"); MODULE_DESCRIPTION("i801 SMBus driver"); MODULE_LICENSE("GPL"); module_init(i801_init); module_exit(i801_exit);
Hi Zwane:
Thanks for the reply!
Quoted 3 lines · Zwane Mwaikambo
Looking at the driver,
algo_data->lockonly protects status, which can easily be overwritten if the reader doesn't read it before the next interrupt.
For this driver at least: after one interrupt sets the status, the next interrupt will either be 1) caused by an asynchronous event (wrt normal bus transfers) like SMBAlert that we silently ignore, or
2) caused by the next transfer, which cannot have been started until the status from the first one is consumed.
Quoted 2 lines
In which case it seems like overkill using a lock, why not just do an atomic xchg?
I.e. the way I wrote it was correct but non-optimal? How about this? It compiles & runs at least, and it looks correct to me.
i2c-i801.c renamed from i2c-i801.c.orig +1 -14
@@ -64,7 +64,6 @@#include "i2c-i801.h" struct i2c_i801_algo_data { -spinlock_t lock;wait_queue_head_t waitq;int status;/* copy of h/w register */ };
@@ -94,15 +93,7 @@ static void i801_abort(struct i2c_adapte/* fetch & consume host status out of algo_data */ static inline int i801_get_status (struct i2c_i801_algo_data *algo_data) { -unsigned long flags; -int status; - -spin_lock_irqsave (&algo_data->lock, flags); - status = algo_data->status; - algo_data->status =0 ; -spin_unlock_irqrestore (&algo_data->lock, flags); - -return status; +return xchg (&algo_data->status,0 ); }static int i801_transaction (struct i2c_adapter *adap,int smbcmd)
@@ -246,11 +237,8 @@ static irqreturn_t i801_isr(int irq, voiif (likely (status &I801_HST_STS_MASK_NORM )) {struct i2c_adapter *adap = dev_id;struct i2c_i801_algo_data *algo_data = adap->algo_data; -unsigned long flags; -spin_lock_irqsave (&algo_data->lock, flags); algo_data->status = status; -spin_unlock_irqrestore (&algo_data->lock, flags);wake_up_interruptible (&algo_data->waitq); }
@@ -317,7 +305,6 @@ static int __devinit i801_probe(struct p }init_waitqueue_head (&algo_data->waitq); -spin_lock_init (&algo_data->lock);/* grab interrupt */ if ((ret = request_irq(pcidev->irq, i801_isr, SA_SHIRQ,
Regards,
Signature · 2 lines
Mark M. Hoffman [email protected]
Hi Mark:
Quoted 4 lines · Mark D. Studebaker
Not sure what BIOS stuff you took out (#2), but I don't think it would be very clean
to have two different drivers supporting the same chips, so that doesn't sound good.
I took out the force_addr module parameter, which is used when the BIOS doesn't allocate an IO region properly. Any BIOS which is broken enough to do that is probably not going to route the IRQ properly either. One alternative would be to do a driver that supports polling and IRQ modes (ala i2c-keywest and others) but that's a lot of extra complexity for IMHO not much gain. I found that code much harder to read.
There is precedent to having two implementations of the same driver - at least Adaptec 2940 that I know of. Ultimately it's up to Greg I guess...
Quoted 3 lines
Removing block transactions and PEC (#1 and 3) isn't wise, and not just because
I did most of that code and it was a lot of work :)
As I mentioned, that's TODO. I wasn't going to ask for this to be merged until I implemented the remaining transactions. BTW I still assert that (some) block transactions of the existing i801 driver have major problems...
http://archives.andrew.net.au/lm-sensors/msg18794.html
Quoted 8 lines
The 801 driver covers a large number of popular chips,
and has possibly the highest "market share" of all the bus drivers. It's essentially our "reference design" for block and PEC transactions and is the driver I've often used to test the i2c-core and i2cdump implementations for these transactions.
Just because most bus drivers don't have block and SMBUS 2.0 transactions doesn't mean
we should take it out of the 801.
OK
Quoted 8 lines
And I wouldn't give up on SMBus 2.0 yet. The W83791D sensor chip supports it;
if the W83792D does as well (awaiting datasheet from Winbond), we can enable it
in the forthcoming driver from Winbond and have end-to-end hardware error checking for
i2c transactions on a system with a 792 and a 801, should such a system appear.
I might own one myself. I just noticed that CVS sensors-detect finds a 792 now. I think it's unlikely, as I *know* this board has a 627thf (I've been using it for a while and have physically located it on the board). I'll have to open it up again and search for the 792.
So, assuming I really have one of these, and that it (792) does PEC... that will make for easy testing. :) Speaking of which: I ran my tests on an ICH5, let me know if you get it to work on one of the other supported chipsets, especially the older ones <= ich3.
Thanks and regards,
Signature · 2 lines
Mark M. Hoffman [email protected]
Hello MDS, again:
Quoted 9 lines · Mark D. Studebaker
Quoted 8 lines
And I wouldn't give up on SMBus 2.0 yet. The W83791D sensor chip supports it;
if the W83792D does as well (awaiting datasheet from Winbond), we can enable it
in the forthcoming driver from Winbond and have end-to-end hardware error checking for
i2c transactions on a system with a 792 and a 801, should such a system appear.
Quoted 9 lines · Mark M. Hoffman
I might own one myself. I just noticed that CVS sensors-detect finds a 792 now. I think it's unlikely, as I *know* this board has a 627thf (I've been using it for a while and have physically located it on the board). I'll have to open it up again and search for the 792.
So, assuming I really have one of these, and that it (792) does PEC... that will make for easy testing. :) Speaking of which: I ran my tests on an ICH5, let me know if you get it to work on one of the other supported chipsets, especially the older ones <= ich3.
Apparently sensors-detect is wrong about 792d. What I really have is a w83791sd (determined by inspection).
BTW, there's really no point to implementing I2C_FUNC_SMBUS_BLOCK_DATA in the new i801 driver as i2c_smbus_[read|write]_block_data() were yanked out of i2c-core anyway. And that reminds me: you probably shouldn't speak too loudly about any other parts (shhhh... PEC, SMBus 2.0) that have no current users, as the bloat police might show up and rip them out too. ;)
Regards,
Signature · 2 lines
Mark M. Hoffman [email protected]
Quoted 4 lines · Mark M. Hoffman
There is precedent to having two implementations of the same driver - at least Adaptec 2940 that I know of. Ultimately it's up to Greg I guess...
There is the uhci and usb-uhci drivers in the 2.4 kernel too, if you are looking for precedent. But in the end, it's a big pain to have two drivers, as distros will ask you which one they need to pick. And if one of them works for everyone, then why not just have one driver.
So try to prevent it if you can.
thanks,
greg k-h
Hi Mark & Mark,
Quoted 4 lines
I've started a complete re-write of the i2c-i801 SMBus driver. As compared to the old one, this one:
1) Supports fewer transaction types... still TODO
See below for my requests ;)
Quoted 3 lines
2) Does not have any BIOS workaround nastiness. I am hoping that I can leave that out and that people who need that can be directed to just use the old driver.
The old driver would most likely be deprecated and removed so you better don't count on it. OTOH I think that the workarounds would best be placed with the other PCI quirks, so I'm fine if the driver doesn't handle that case. And my own i801 machine doesn't need it anyway ;)
Quoted 2 lines
3) Does not support PEC (not sure who uses it... can also be TODO if there's interest).
Very interesting question, why was PEC introduced in the first place (generic question, not limited to i801). Proof of concept, or did we already see a bus+chip combination using it? Would we want to use it wherever possible, regardless of the discussable benefit and the obvious speed penalty in most cases (non-block commands)?
Quoted 1 line
And the primary difference 4) uses interrupts instead of polling.
Sounds good :)
Quoted 12 lines
Re performance: this driver does not improve CPU utilization, because the polling loop on the old one sleeps a lot anyway. Elapsed time per transaction did improve by varying degrees, depending on the transaction type:
OLD:
I2C_SMBUS_QUICK(nodev)0.00202I2C_SMBUS_QUICK0.00203I2C_SMBUS_BYTE0.00203I2C_SMBUS_BYTE_DATA0.00402I2C_SMBUS_WORD_DATA0.00602
Quoted 6 lines
NEW:
I2C_SMBUS_QUICK(nodev)0.00108I2C_SMBUS_QUICK0.00107I2C_SMBUS_BYTE0.00190I2C_SMBUS_BYTE_DATA0.00365I2C_SMBUS_WORD_DATA0.00449
My own real-world test confirms the improvement. My test case is:
time for i in $(seq 1 100)
do
cat /sys/bus/i2c/devices/4-0050/eeprom > /dev/null
done
(Note that I modified the eeprom driver to remove data caching, so as to make the benchmarking easier - or possible at all.)
Old driver:
real 0m53.583s user 0m0.052s sys 0m0.075s
New driver:
real 0m35.986s user 0m0.067s sys 0m0.214s
+48% speed improvement, I'm quite impressed. Congrats Mark :)
Also note that I had music playing on the system, where every device uses IRQ 9 (ACPI enabled) and sound still worked like a charm during the tests.
Now it could probably be even more impressive if you would implement I2C_FUNC_SMBUS_READ_I2C_BLOCK, which the eeprom driver can make use of when present.
Now I would have one question for Mark Studebaker. Mark, why is it that the the original i2c-i801 driver would not implement I2C_FUNC_SMBUS_READ_I2C_BLOCK, while it implements all other BLOCK functions? The code has the following message if you try:
"I2C_SMBUS_I2C_BLOCK_READ not DB!". What is it supposed to mean? I see in doc/busses/i2c-i801 that the i801 has a special 3-byte address block read, does it mean that it does *not* support the regular (1-byte address) I2C block read command?
If nothing else, a more understandable error message would help :)
Thanks,
Signature · 2 lines
Jean Delvare http://khali.linux-fr.org/
Hi Mark,
I have been (partly) reviewing the code of your i2c-i801 driver today, and also (partly) read the datasheet for my own variant, the ICH3-M.
First, I'd have a question. What is I801_PCI_BAR (and how do you know its value)? Looks like you get the base address in a different way than the old driver did, can you explain how it works and how different it is exactly?
Second I'd have a suggestion. It looks like you can detect the length of the I/O space automatically. You'd simply do:
i801_iosize = pci_resource_len(pcidev, I801_PCI_BAR);
instead of explicitely setting it to 16 or 32. This makes the code more compact and will automatically support the possibly different length of future compatible chips. I would also suggest that you compute i801_smba before i801_iosize, because the former can fail, and also because it is more logical that way (IMHO at least).
I tested it and it works fine for me.
I'm impatient to test the next version of your driver :)
Thanks,
Signature · 2 lines
Jean Delvare http://khali.linux-fr.org/
Hi Jean:
Quoted 2 lines · Jean Delvare
I have been (partly) reviewing the code of your i2c-i801 driver today, and also (partly) read the datasheet for my own variant, the ICH3-M.
Good, thanks!
Quoted 4 lines
First, I'd have a question. What is
I801_PCI_BAR(and how do you know its value)? Looks like you get the base address in a different way than the old driver did, can you explain how it works and how different it is exactly?
I'm using pci_resource_start() instead of reading the PCI config space directly with pci_read_config_word(). Within the PCI config space, there are six possible locations for a base address register: 0x10, 0x14, ... 0x24. The second argument to pci_resource_start() specifies from which of those locations to read: 0 -> 0x10, 1 -> 0x14, etc. Given that, it should be obvious why I801_PCI_BAR is 4.
Quoted 10 lines
Second I'd have a suggestion. It looks like you can detect the length of the I/O space automatically. You'd simply do:
i801_iosize = pci_resource_len(pcidev, I801_PCI_BAR);instead of explicitely setting it to 16 or 32. This makes the code more compact and will automatically support the possibly different length of future compatible chips. I would also suggest that you compute
i801_smbabeforei801_iosize, because the former can fail, and also because it is more logical that way (IMHO at least).
Good point about pci_resource_len(), I'll do that. Eventually though, I'll need to check the PCI IDs anyway when I want to use some features that the older chipsets don't have. I.e. it won't save me the "if" statements by then.
Quoted 3 lines
I tested it and it works fine for me.
I'm impatient to test the next version of your driver :)
Be patient please. :)
Regards,
Signature · 2 lines
Mark M. Hoffman [email protected]
thanks for asking for comments.
No objections to a cleanup, or to using interrupts (#4).
Not sure what BIOS stuff you took out (#2), but I don't think it would be very clean to have two different drivers supporting the same chips, so that doesn't sound good.
Removing block transactions and PEC (#1 and 3) isn't wise, and not just because
I did most of that code and it was a lot of work :)
The 801 driver covers a large number of popular chips,
and has possibly the highest "market share" of all the bus drivers.
It's essentially our "reference design" for block and PEC transactions
and is the driver I've often used to test the i2c-core and i2cdump implementations for these transactions. Just because most bus drivers don't have block and SMBUS 2.0 transactions doesn't mean
we should take it out of the 801.
And I wouldn't give up on SMBus 2.0 yet. The W83791D sensor chip supports it; if the W83792D does as well (awaiting datasheet from Winbond), we can enable it in the forthcoming driver from Winbond and have end-to-end hardware error checking for i2c transactions on a system with a 792 and a 801, should such a system appear.
mds
Quoted 50 lines · Mark M. Hoffman
Hello all:
I've started a complete re-write of the i2c-i801 SMBus driver. As compared to the old one, this one:
1) Supports fewer transaction types... still TODO
2) Does not have any BIOS workaround nastiness. I am hoping that I can leave that out and that people who need that can be directed to just use the old driver.
3) Does not support PEC (not sure who uses it... can also be TODO if there's interest).
And the primary difference 4) uses interrupts instead of polling.
I'm not exactly a stranger to interrupt-handling, having designed whole interrupt handling mechanisms for (non-Linux) embedded systems. *But*, as this is my first shot at it with a Linux driver... I would appreciate a close look at those parts. The design is similar to i2c-iop3xx, except where it's different. :)
My test target / dev host shares an IRQ between sound and SMBus; almost all of my testing was performed with xmms blasting away.
Re performance: this driver does not improve CPU utilization, because the polling loop on the old one sleeps a lot anyway. Elapsed time per transaction did improve by varying degrees, depending on the transaction type:
OLD:
I2C_SMBUS_QUICK(nodev)0.00202I2C_SMBUS_QUICK0.00203I2C_SMBUS_BYTE0.00203I2C_SMBUS_BYTE_DATA0.00402I2C_SMBUS_WORD_DATA0.00602NEW:
I2C_SMBUS_QUICK(nodev)0.00108I2C_SMBUS_QUICK0.00107I2C_SMBUS_BYTE0.00190I2C_SMBUS_BYTE_DATA0.00365I2C_SMBUS_WORD_DATA0.00449(Script for above: http://members.dca.net/mhoffman/sensors/temp/test.pl)
The diff is harder to read than the complete files which are attached...
Thanks and regards,
Quoted 14 lines · Mark M. Hoffman
Hello all:
I've started a complete re-write of the i2c-i801 SMBus driver. As compared to the old one, this one:
1) Supports fewer transaction types... still TODO
2) Does not have any BIOS workaround nastiness. I am hoping that I can leave that out and that people who need that can be directed to just use the old driver.
3) Does not support PEC (not sure who uses it... can also be TODO if there's interest).
Quoted 7 lines
And the primary difference 4) uses interrupts instead of polling.
I'm not exactly a stranger to interrupt-handling, having designed whole interrupt handling mechanisms for (non-Linux) embedded systems. *But*, as this is my first shot at it with a Linux driver... I would appreciate a close look at those parts. The design is similar to i2c-iop3xx, except where it's different. :)
Looking at the driver, algo_data->lock only protects status, which can easily be overwritten if the reader doesn't read it before the next interrupt. In which case it seems like overkill using a lock, why not just do an atomic xchg?
Hello Mark,
Quoted 2 lines · Mark M. Hoffman
I.e. the way I wrote it was correct but non-optimal? How about this? It compiles & runs at least, and it looks correct to me.
Yes, the datum being protected can be accessed atomically without spinlocks.
Quoted 5 lines
(quoted diff) +1
-0+ return xchg(&algo_data->status,0); } static int i801_transaction(struct i2c_adapter *adap, int smbcmd)
Review static irqreturn_t i801_isr(int irq, voi · line 242
Quoted 9 lines
(quoted diff) +0
-3@@ -246,11 +237,8 @@ static irqreturn_t i801_isr(int irq, voi if (likely(status & I801_HST_STS_MASK_NORM)) { struct i2c_adapter *adap = dev_id; struct i2c_i801_algo_data *algo_data = adap->algo_data; - unsigned long flags; - spin_lock_irqsave(&algo_data->lock, flags); algo_data->status = status; - spin_unlock_irqrestore(&algo_data->lock, flags); wake_up_interruptible(&algo_data->waitq);
This needs to be done atomically via xchg too.
Thanks,
Zwane
Hi Mark:
(trimmed CCs)
Quoted 5 lines · * I wrote:
Quoted 5 lines
BTW, there's really no point to implementing
I2C_FUNC_SMBUS_BLOCK_DATAin the new i801 driver as i2c_smbus_[read|write]_block_data() were yanked out of i2c-core anyway. And that reminds me: you probably shouldn't speak too loudly about any other parts (shhhh... PEC, SMBus 2.0) that have no current users, as the bloat police might show up and rip them out too. ;)
Quoted 5 lines · Mark D. Studebaker
As I understand the bloat-police thread, there's no objection to adding back in the removed functions
when they're needed.
It's a little irritating that things are being ripped out but I can understand it.
:)
Quoted 3 lines
It should be our goal to get the block functions back in as soon as possible.
You should include it with any 801 patch submission.
I will. Contrary to what I wrote above, userspace can still access those transfers without the i2c-core helpers. And who is to say that there aren't any block transfer users through i2c-dev?
Quoted 1 line
I guess the write was already put back but the read wasn't?
Sounds right.
Regards,
Signature · 2 lines
Mark M. Hoffman [email protected]
Hi Mark:
(CCs trimmed)
Quoted 4 lines · Mark D. Studebaker
My reading of the DB datasheet (in 2002 and now) is that it doesn't support a standard i2c block read. The driver functionality bitmask reflects that. I fixed the error message (which would only print out if a driver ignored the functionality mask).
Interesting. It looks like that datasheet only shows this:
S Addr Wr [A] Comm [A] D0 [A] D1 [A] S (read bytes...)
I agree that's not like any transaction we support.
OTOH, the ICH5 [1] datasheet shows this:
S Addr Wr [A] D1 [A] S (read bytes...)
That's exactly the transfer protocol that eeproms need, right? (That's why I mentioned to Khali by IRC last weekend that I thought it should be possible.)
It would be really bizarre if these two chipsets behaved differently in this respect - I wonder if the datasheets are correct?
[1] Well I just scanned all the other datasheets... only ICH5, ICH6, and 6300ESB appear to support the standard I2C block read. Sorry Khali. :)
Regards,
Signature · 2 lines
Mark M. Hoffman [email protected]
Hi Mark:
Quoted 12 lines · Mark D. Studebaker
(...)
Quoted 9 lines
OTOH, the ICH5 [1] datasheet shows this:
S Addr Wr [A] D1 [A] S (read bytes...)That's exactly the transfer protocol that eeproms need, right? (That's why I
mentioned to Khali by IRC last weekend that I thought it should be possible.)
Quoted 8 lines
I think it is what eeproms need (you omitted 'Addr' after the second 'S'). It matches what I wrote in doc/smbus-protocol in i2c
(that is, the i2c block functions are defined to take a 'command' byte, matching
what eeproms need for 'random' reads and writes).Does anybody have a ICH5/6? If so I can add support to the driver for testing.
I have an ICH5; I'll definitely test it if you add it. I'm working on adding this to the new i801 driver as well.
Regards,
Signature · 2 lines
Mark M. Hoffman [email protected]
Quoted 5 lines
It's a lost cause, I think.
The controller is going to use the first byte for the length the slave intends to send. TheLAST_BYTEbit means the SW telling the master it wants to stop. If the first byte is > 32 or doesn't match the actual message length I think the results are likely to be bad.
Yeah, something like that. I'm giving it up now.
Signature · 2 lines
Jean Delvare http://khali.linux-fr.org/
Quoted 11 lines
Quoted 4 lines
First, I'd have a question. What is
I801_PCI_BAR(and how do you know its value)? Looks like you get the base address in a different way than the old driver did, can you explain how it works and how different it is exactly?I'm using
pci_resource_start()instead of reading the PCI config space directly withpci_read_config_word(). Within the PCI config space, there are six possible locations for a base address register:0x10,0x14, ...0x24. The second argument topci_resource_start()specifies from which of those locations to read: 0 ->0x10, 1 ->0x14, etc. Given that, it should be obvious whyI801_PCI_BARis 4.
OK. But then you shouldn't present it as if it were a register. Defining it as 4 instead of 0x04 would certainly help, and an empty line to separate it from I801_PCI_HOSTC may be welcome as well and/or a relevant comment maybe?
One more comment about the code:
Quoted 3 lines
/* default: SMBus, no SMI#, enable host controller */ pci_write_config_byte(pcidev, I801_PCI_HOSTC, 0x01); pci_read_config_byte(pcidev, I801_PCI_HOSTC, &temp);
And after that you don't use temp... Am I missing something?
You might want to only write the bits that you know about, in case future chips would have more. Also you could use the constants you defined earlier. What about:
Quoted 4 lines
/* default: SMBus, no SMI#, enable host controller */ pci_read_config_byte(pcidev, I801_PCI_HOSTC, &temp); pci_write_config_byte(pcidev, I801_PCI_HOSTC, (temp & 0xF8) | I801_PCI_HOSTC_HST_EN);
Thanks,
Signature · 2 lines
Jean Delvare http://khali.linux-fr.org/
Quoted 5 lines · Jean Delvare
Quoted 3 lines
/* default: SMBus, no SMI#, enable host controller */ pci_write_config_byte(pcidev, I801_PCI_HOSTC, 0x01); pci_read_config_byte(pcidev, I801_PCI_HOSTC, &temp);And after that you don't use temp... Am I missing something?
This is commonly done to ensure that the write actually hits the bus before the code continues. Otherwise, the write could happen at some later point in time. The read after a write ensures that everything is synced up properly.
Quoted 8 lines
You might want to only write the bits that you know about, in case future chips would have more. Also you could use the constants you defined earlier. What about:
Quoted 4 lines
/* default: SMBus, no SMI#, enable host controller */ pci_read_config_byte(pcidev, I801_PCI_HOSTC, &temp); pci_write_config_byte(pcidev, I801_PCI_HOSTC, (temp & 0xF8) | I801_PCI_HOSTC_HST_EN);
And then put a read after it too :)
thanks,
greg k-h
Quoted 6 lines · Jean Delvare
Quoted 6 lines
Quoted 5 lines
Quoted 3 lines
/* default: SMBus, no SMI#, enable host controller */ pci_write_config_byte(pcidev, I801_PCI_HOSTC, 0x01); pci_read_config_byte(pcidev, I801_PCI_HOSTC, &temp);And after that you don't use temp... Am I missing something?
Quoted 7 lines
Quoted 4 lines
This is commonly done to ensure that the write actually hits the bus before the code continues. Otherwise, the write could happen at some later point in time. The read after a write ensures that everything is synced up properly.
That's odd. Is is a hardware issue or is it implied by the way the PCI accesses are handled by Linux itself?
It's implied by the way the PCI bus works, it's not a Linux thing at all.
thanks,
greg k-h
Quoted 10 lines
Quoted 5 lines
Quoted 3 lines
/* default: SMBus, no SMI#, enable host controller */ pci_write_config_byte(pcidev, I801_PCI_HOSTC, 0x01); pci_read_config_byte(pcidev, I801_PCI_HOSTC, &temp);And after that you don't use temp... Am I missing something?
This is commonly done to ensure that the write actually hits the bus before the code continues. Otherwise, the write could happen at some later point in time. The read after a write ensures that everything is synced up properly.
That's odd. Is is a hardware issue or is it implied by the way the PCI accesses are handled by Linux itself?
Thanks,
Signature · 2 lines
Jean Delvare http://khali.linux-fr.org/
Hi Jean:
Quoted 12 lines · Jean Delvare
Quoted 11 lines
Quoted 4 lines
First, I'd have a question. What is
I801_PCI_BAR(and how do you know its value)? Looks like you get the base address in a different way than the old driver did, can you explain how it works and how different it is exactly?I'm using
pci_resource_start()instead of reading the PCI config space directly withpci_read_config_word(). Within the PCI config space, there are six possible locations for a base address register:0x10,0x14, ...0x24. The second argument topci_resource_start()specifies from which of those locations to read: 0 ->0x10, 1 ->0x14, etc. Given that, it should be obvious whyI801_PCI_BARis 4.
Quoted 4 lines
OK. But then you shouldn't present it as if it were a register. Defining it as 4 instead of
0x04would certainly help, and an empty line to separate it fromI801_PCI_HOSTCmay be welcome as well and/or a relevant comment maybe?
Sure.
Quoted 7 lines
One more comment about the code:
Quoted 3 lines
/* default: SMBus, no SMI#, enable host controller */ pci_write_config_byte(pcidev, I801_PCI_HOSTC, 0x01); pci_read_config_byte(pcidev, I801_PCI_HOSTC, &temp);And after that you don't use temp... Am I missing something?
Yeah... what Greg said. ;) I'll change "temp" to "ignore".
Quoted 8 lines
You might want to only write the bits that you know about, in case future chips would have more. Also you could use the constants you defined earlier. What about:
Quoted 4 lines
/* default: SMBus, no SMI#, enable host controller */ pci_read_config_byte(pcidev, I801_PCI_HOSTC, &temp); pci_write_config_byte(pcidev, I801_PCI_HOSTC, (temp & 0xF8) | I801_PCI_HOSTC_HST_EN);
I disagree. The reserved bits default to 0 by spec. If I write them to 0, I get the behavior I know about (unless Intel screws up badly). I don't want to keep anything the BIOS might have written there - that might enable some behavior that the driver isn't equipped to handle.
Yes, this is contrary to our "don't init" policy of chip drivers... but it's the chip driver policy which is unusual (although warranted, because we'll never have all the info we would need to do it right).
In general, (i.e. non sensors chip) drivers would do well to init everything to a known state.
Regards,
Signature · 2 lines
Mark M. Hoffman [email protected]
Mark,
I don't think that there are any changes to the ICH7 SMBus Controller, other then DID, which is 27DAh. The Datasheet will not be available until the product launches. I will however, patch the driver with the new DID, test it out and then submit the patch here and to the LKML. My plan is to do this within the next six weeks or so. Unless you can or want to add the DID now?
Let me know if you would still like me to try something out on ICH5, ICH6 or ESB6300.
Thanks,
Jason Gaston
-----Original Message-----
From: Mark Studebaker [mailto:[email protected]]
Sent: Wednesday, December 08, 2004 9:37 AM
To: Gaston, Jason D
Cc: LM Sensors
Subject: Re: RFC: complete rewrite of i2c-i801 for 2.6.x
thanks for offer. i2c block read support for ich5 and later is now in CVS.
Best way to test bus drivers is with 'i2cdump'.
In particular to test i2c block reads, best way is with the "i" mode of i2cdump.
If it works, regular byte ("b") mode and "i" mode should have identical results
when reading from an eeprom.
For the ICH7, first we've heard of it, but not surprised it would be the chip
after ICH6 :)
I see there's nothing on developer.intel.com about it. Will there be any changes in the SMBus controller? What is the device ID? Datasheet availability?
Whether you submit 2.4 or 2.6 patches doesn't really matter. But with the device ID, and assurances that the SMBus part of the chip didn't change,
it's real easy.
mds
Quoted 6 lines · Jason D
Mark,
I would be willing to do some testing of the i2c-i801 driver on ICH5, ICH6, ESB6300 and ICH7. I have access to boards/systems, but I am not proficient in i2c testing, other then running "sensors" and seeing the data. If you know of some instructions for the testing you are
looking
Quoted 68 lines
for, I am willing to give it a go.
In addition, I will soon want to get support for ICH7 added to the i2c-i801 driver. Last time, when I wanted to get support for ICH6 added, I posted a patch, adding the DID's, to the LKML and Greg KH. This made it into the 2.6 kernel. Perhaps I should get support added here first and then the base kernel?
Let me know how I can help,
Jason Gaston
[email protected]-----Original Message-----
From: Mark Studebaker [mailto:[email protected]]
Sent: Tuesday, December 07, 2004 7:02 PM
To: Sensors
Subject: Re: RFC: complete rewrite of i2c-i801 for 2.6.xQuoted 8 lines · Mark M. Hoffman
Hi Mark:
(CCs trimmed)
Quoted 1 line · Mark D. Studebaker
My reading of the DB datasheet (in 2002 and now) is that it doesn't
support a
Quoted 1 line
Quoted 1 line
standard i2c block read. The driver functionality bitmask reflects
that.
Quoted 1 line
Quoted 1 line
I fixed the error message (which would only print out if a driver
ignored
Quoted 8 lines
Quoted 1 line
the functionality mask).
Interesting. It looks like that datasheet only shows this:
S Addr Wr [A] Comm [A] D0 [A] D1 [A] S (read bytes...)I agree that's not like any transaction we support.
correct. don't know what they were thinking.
Quoted 5 lines
OTOH, the ICH5 [1] datasheet shows this:
S Addr Wr [A] D1 [A] S (read bytes...)That's exactly the transfer protocol that eeproms need, right?
(That's why I
Quoted 1 line
mentioned to Khali by IRC last weekend that I thought it should be
Quoted 7 lines
possible.)
I think it is what eeproms need (you omitted 'Addr' after the second 'S').
It matches what I wrote in doc/smbus-protocol in i2c (that is, the i2c block functions are defined to take a 'command'
byte,
Quoted 29 lines
matching
what eeproms need for 'random' reads and writes).Does anybody have a ICH5/6? If so I can add support to the driver for testing.
mds
Quoted 1 line
It would be really bizarre if these two chipsets behaved differently
in this
Quoted 3 lines
respect - I wonder if the datasheets are correct?
[1] Well I just scanned all the other datasheets... only ICH5, ICH6,
and
Quoted 1 line
6300ESB appear to support the standard I2C block read. Sorry Khali.
:)
Quoted 2 lines
Regards,
Mark,
I see that you are using the DID's directly, for ICH5,6,7, rather then using the pci_ids.h defines. Is this your preference or would you rather use the pci_ids.h names?
I am wondering if I should also just use the actual DID's for the 2.6 patch?
Thanks,
Jason Gaston
-----Original Message-----
From: Mark Studebaker [mailto:[email protected]]
Sent: Wednesday, December 08, 2004 1:01 PM
To: Gaston, Jason D
Cc: LM Sensors
Subject: Re: RFC: complete rewrite of i2c-i801 for 2.6.x
since I'm in the middle of 801 driver updates already, I'll go ahead and add support to
the driver and sensors-detect in CVS. I'll leave the 2.6 patch to you. let us know when you have test results.
thanks
mds
Quoted 6 lines · Jason D
Mark,
I don't think that there are any changes to the ICH7 SMBus Controller, other then DID, which is 27DAh. The Datasheet will not be available until the product launches. I will however, patch the driver with the new DID, test it out and then submit the patch here and to the LKML.
My
Quoted 19 lines
plan is to do this within the next six weeks or so. Unless you can or want to add the DID now?
Let me know if you would still like me to try something out on ICH5, ICH6 or ESB6300.
Thanks,
Jason Gaston
-----Original Message-----
From: Mark Studebaker [mailto:[email protected]]
Sent: Wednesday, December 08, 2004 9:37 AM
To: Gaston, Jason D
Cc: LM Sensors
Subject: Re: RFC: complete rewrite of i2c-i801 for 2.6.x
Quoted 4 lines
thanks for offer. i2c block read support for ich5 and later is now in CVS.
Best way to test bus drivers is with 'i2cdump'.
In particular to test i2c block reads, best way is with the "i" mode
of
Quoted 2 lines
i2cdump.
If it works, regular byte ("b") mode and "i" mode should have
identical
Quoted 4 lines
results
when reading from an eeprom.For the ICH7, first we've heard of it, but not surprised it would be
the
Quoted 3 lines
chip
after ICH6 :)
I see there's nothing on developer.intel.com about it. Will there be
any
Quoted 141 lines
changes in the SMBus controller? What is the device ID? Datasheet availability?
Whether you submit 2.4 or 2.6 patches doesn't really matter. But with the device ID, and assurances that the SMBus part of the chip didn't change,
it's real easy.mds
Quoted 6 lines · Jason D
Mark,
I would be willing to do some testing of the i2c-i801 driver on ICH5, ICH6, ESB6300 and ICH7. I have access to boards/systems, but I am not proficient in i2c testing, other then running "sensors" and seeing the data. If you know of some instructions for the testing you are
looking
Quoted 75 lines
for, I am willing to give it a go.
In addition, I will soon want to get support for ICH7 added to the i2c-i801 driver. Last time, when I wanted to get support for ICH6 added, I posted a patch, adding the DID's, to the LKML and Greg KH. This made it into the 2.6 kernel. Perhaps I should get support added here first and then the base kernel?
Let me know how I can help,
Jason Gaston
[email protected]-----Original Message-----
From: Mark Studebaker [mailto:[email protected]]
Sent: Tuesday, December 07, 2004 7:02 PM
To: Sensors
Subject: Re: RFC: complete rewrite of i2c-i801 for 2.6.xQuoted 9 lines · Mark M. Hoffman
Hi Mark:
(CCs trimmed)
Quoted 1 line · Mark D. Studebaker
My reading of the DB datasheet (in 2002 and now) is that it doesn't
support a
Quoted 1 line
Quoted 1 line
standard i2c block read. The driver functionality bitmask reflects
that.
Quoted 1 line
Quoted 1 line
I fixed the error message (which would only print out if a driver
ignored
Quoted 8 lines
Quoted 1 line
the functionality mask).
Interesting. It looks like that datasheet only shows this:
S Addr Wr [A] Comm [A] D0 [A] D1 [A] S (read bytes...)I agree that's not like any transaction we support.
correct. don't know what they were thinking.
Quoted 5 lines
OTOH, the ICH5 [1] datasheet shows this:
S Addr Wr [A] D1 [A] S (read bytes...)That's exactly the transfer protocol that eeproms need, right?
(That's why I
Quoted 1 line
mentioned to Khali by IRC last weekend that I thought it should be
Quoted 7 lines
possible.)
I think it is what eeproms need (you omitted 'Addr' after the second 'S').
It matches what I wrote in doc/smbus-protocol in i2c (that is, the i2c block functions are defined to take a 'command'byte,
Quoted 33 lines
matching
what eeproms need for 'random' reads and writes).Does anybody have a ICH5/6? If so I can add support to the driver for testing.
mds
Quoted 1 line
It would be really bizarre if these two chipsets behaved differently
in this
Quoted 3 lines
respect - I wonder if the datasheets are correct?
[1] Well I just scanned all the other datasheets... only ICH5, ICH6,
and
Quoted 1 line
6300ESB appear to support the standard I2C block read. Sorry Khali.
:)
Quoted 2 lines
Regards,
Quoted 7 lines · Jean Delvare
Hi Mark & Mark,
Quoted 2 lines
3) Does not support PEC (not sure who uses it... can also be TODO if there's interest).
Quoted 7 lines
Very interesting question, why was PEC introduced in the first place (generic question, not limited to i801). Proof of concept, or did we already see a bus+chip combination using it? Would we want to use it wherever possible, regardless of the discussable benefit and the obvious speed penalty in most cases (non-block commands)?
I developed the kernel PEC support with an 82801DB and an Intel 82551 NIC. The board had an I2C bus to all the PCI slots (according to the updated PCI standard). With I2C to PCI slots, the bus/chip combinations are obviously more flexible. That's also why SMBus ARP makes sense (PCI hotplug).
When we get a dedicated (and stable) driver for a chip supporting PEC (83791?) we should turn on PEC in the chip driver. This will enable HW PEC on the bus drivers that support it, and SW PEC in the kernel i2c layer for bus drivers that don't. Then we can get some experience on the benefits and penalties, if any.
Quoted 13 lines
Now it could probably be even more impressive if you would implement
I2C_FUNC_SMBUS_READ_I2C_BLOCK, which the eeprom driver can make use of when present.Now I would have one question for Mark Studebaker. Mark, why is it that the the original i2c-i801 driver would not implement
I2C_FUNC_SMBUS_READ_I2C_BLOCK, while it implements all other BLOCK functions? The code has the following message if you try:
"I2C_SMBUS_I2C_BLOCK_READnot DB!". What is it supposed to mean? I see in doc/busses/i2c-i801 that the i801 has a special 3-byte address block read, does it mean that it does *not* support the regular (1-byte address) I2C block read command?
Quoted 1 line
If nothing else, a more understandable error message would help :)
My reading of the DB datasheet (in 2002 and now) is that it doesn't support a standard i2c block read. The driver functionality bitmask reflects that.
I fixed the error message (which would only print out if a driver ignored the functionality mask).
mds
Quoted 7 lines · Mark M. Hoffman
Hello MDS, again:
BTW, there's really no point to implementing
I2C_FUNC_SMBUS_BLOCK_DATAin the new i801 driver as i2c_smbus_[read|write]_block_data() were yanked out of i2c-core anyway. And that reminds me: you probably shouldn't speak too loudly about any other parts (shhhh... PEC, SMBus 2.0) that have no current users, as the bloat police might show up and rip them out too. ;)
As I understand the bloat-police thread, there's no objection to adding back in the removed functions when they're needed.
It's a little irritating that things are being ripped out but I can understand it.
It should be our goal to get the block functions back in as soon as possible.
You should include it with any 801 patch submission.
I guess the write was already put back but the read wasn't?
Quoted 12 lines · Mark M. Hoffman
Hi Mark:
(CCs trimmed)
Quoted 4 lines · Mark D. Studebaker
My reading of the DB datasheet (in 2002 and now) is that it doesn't support a standard i2c block read. The driver functionality bitmask reflects that. I fixed the error message (which would only print out if a driver ignored the functionality mask).
Quoted 5 lines
Interesting. It looks like that datasheet only shows this:
S Addr Wr [A] Comm [A] D0 [A] D1 [A] S (read bytes...)I agree that's not like any transaction we support.
correct. don't know what they were thinking.
Quoted 8 lines
OTOH, the ICH5 [1] datasheet shows this:
S Addr Wr [A] D1 [A] S (read bytes...)That's exactly the transfer protocol that eeproms need, right? (That's why I mentioned to Khali by IRC last weekend that I thought it should be possible.)
I think it is what eeproms need (you omitted 'Addr' after the second 'S'). It matches what I wrote in doc/smbus-protocol in i2c
(that is, the i2c block functions are defined to take a 'command' byte, matching
what eeproms need for 'random' reads and writes).
Does anybody have a ICH5/6? If so I can add support to the driver for testing.
mds
Quoted 8 lines
It would be really bizarre if these two chipsets behaved differently in this respect - I wonder if the datasheets are correct?
[1] Well I just scanned all the other datasheets... only ICH5, ICH6, and 6300ESB appear to support the standard I2C block read. Sorry Khali. :)
Regards,
Quoted 6 lines · Mark M. Hoffman
I have an ICH5; I'll definitely test it if you add it. I'm working on adding this to the new i801 driver as well.
Regards,
checked in, give it a try. wasn't too many lines so maybe I'm missing something? no promises... test with 'i' mode of i2cdump.
thanks for offer. i2c block read support for ich5 and later is now in CVS. Best way to test bus drivers is with 'i2cdump'.
In particular to test i2c block reads, best way is with the "i" mode of i2cdump. If it works, regular byte ("b") mode and "i" mode should have identical results when reading from an eeprom.
For the ICH7, first we've heard of it, but not surprised it would be the chip after ICH6 :)
I see there's nothing on developer.intel.com about it. Will there be any changes in the SMBus controller? What is the device ID? Datasheet availability? Whether you submit 2.4 or 2.6 patches doesn't really matter.
But with the device ID, and assurances that the SMBus part of the chip didn't change, it's real easy.
mds
Quoted 110 lines · Jason D
Mark,
I would be willing to do some testing of the i2c-i801 driver on ICH5, ICH6, ESB6300 and ICH7. I have access to boards/systems, but I am not proficient in i2c testing, other then running "sensors" and seeing the data. If you know of some instructions for the testing you are looking for, I am willing to give it a go.
In addition, I will soon want to get support for ICH7 added to the i2c-i801 driver. Last time, when I wanted to get support for ICH6 added, I posted a patch, adding the DID's, to the LKML and Greg KH. This made it into the 2.6 kernel. Perhaps I should get support added here first and then the base kernel?
Let me know how I can help,
Jason Gaston
[email protected]-----Original Message-----
From: Mark Studebaker [mailto:[email protected]]
Sent: Tuesday, December 07, 2004 7:02 PM
To: Sensors
Subject: Re: RFC: complete rewrite of i2c-i801 for 2.6.xQuoted 8 lines · Mark M. Hoffman
Hi Mark:
(CCs trimmed)
Quoted 1 line · Mark D. Studebaker
My reading of the DB datasheet (in 2002 and now) is that it doesn't
support a
Quoted 1 line
Quoted 1 line
standard i2c block read. The driver functionality bitmask reflects
that.
Quoted 1 line
Quoted 1 line
I fixed the error message (which would only print out if a driver
ignored
Quoted 8 lines
Quoted 1 line
the functionality mask).
Interesting. It looks like that datasheet only shows this:
S Addr Wr [A] Comm [A] D0 [A] D1 [A] S (read bytes...)I agree that's not like any transaction we support.
correct. don't know what they were thinking.
Quoted 5 lines
OTOH, the ICH5 [1] datasheet shows this:
S Addr Wr [A] D1 [A] S (read bytes...)That's exactly the transfer protocol that eeproms need, right?
(That's why I
Quoted 1 line
mentioned to Khali by IRC last weekend that I thought it should be
possible.)
I think it is what eeproms need (you omitted 'Addr' after the second 'S').
It matches what I wrote in doc/smbus-protocol in i2c
(that is, the i2c block functions are defined to take a 'command' byte, matching
what eeproms need for 'random' reads and writes).Does anybody have a ICH5/6? If so I can add support to the driver for testing.
mds
Quoted 1 line
It would be really bizarre if these two chipsets behaved differently
in this
Quoted 3 lines
respect - I wonder if the datasheets are correct?
[1] Well I just scanned all the other datasheets... only ICH5, ICH6,
and
Quoted 1 line
6300ESB appear to support the standard I2C block read. Sorry Khali.
:)
Quoted 2 lines
Regards,
It's a lost cause, I think.
The controller is going to use the first byte for the length the slave intends to send. The LAST_BYTE bit means the SW telling the master it wants to stop.
If the first byte is > 32 or doesn't match the actual message length I think the results are likely to be bad.
Quoted 81 lines · Jean Delvare
Hi Mark,
Quoted 5 lines
Interesting. It looks like that datasheet only shows this:
S Addr Wr [A] Comm [A] D0 [A] D1 [A] S (read bytes...)I agree that's not like any transaction we support.
True. Not only that but it seems that this function is broken at least in the ICH3-M (which I have). The specification update from Intel [1] says so.
Quoted 7 lines
OTOH, the ICH5 [1] datasheet shows this:
S Addr Wr [A] D1 [A] S (read bytes...)That's exactly the transfer protocol that eeproms need, right? (That's why I mentioned to Khali by IRC last weekend that I thought it should be possible.)
True again.
Quoted 2 lines
It would be really bizarre if these two chipsets behaved differently in this respect - I wonder if the datasheets are correct?
I think they are. Intel are very serious with datasheets. I believe they implemented a useless function, realized that and simply changed it in the newer revisions of the ICH. BTW it would certainly be worth looking at the revision numbers of our chips. The revision is shown by lspci (aming others). Mine is 01. I would expect a different value for the chips with the new I2C block read function. If I'm right, that would be a convenient detection method.
I will not try the weird I2C block read on my system since it really starts like a write command and I wouldn't want to trash my eeproms accidentally.
Quoted 2 lines
[1] Well I just scanned all the other datasheets... only ICH5, ICH6, and 6300ESB appear to support the standard I2C block read. Sorry Khali. :)
Yes, it looks so. I guess I'll have to change my laptop for an ICH6-based one then ;)
However, what I had in mind was NOT to use that weird function but to hi-jack the SMBus block read command. Unless I am mistaken, the only difference between SMBus and I2C block reads is that the former has an additional leading (read) byte for the length while the latter doesn't. My plan was to implement I2C block reads using the SMBus block read. All I'd need to do is copy the supposed length byte as the first data byte and shift all other data bytes by one position. Sounds simple... except that it doesn't seem to work. Or, more precisely, sometimes it works and sometimes is doesn't. Seems to depend on the first byte read. I suppose that the ICH3-M trusts this byte more than the
LAST_BYTEbit (the specification update confirms that this is the case for the weird I2C block read function, making it useless as I said earlier). I tried to overwrite the byte length with 32 after the first transfer of the block but it didn't seem to help. Also, I see no relation between the value of the first byte and the point at which the block read dies on a timeout, although this is perfectly reproducible.I'll investigate again this evening but with little hope. And anyway this sounds like a trick we might not want to implement in the released driver even if it somewhat works, especially since I2C block reads are really only a bonus for EEPROMs, not a vital feature for hardware monitoring.
[1] http://www.intel.com/design/chipsets/specupdt/290718.htm
Thanks,
--
Jean Delvare
since I'm in the middle of 801 driver updates already, I'll go ahead and add support to the driver and sensors-detect in CVS. I'll leave the 2.6 patch to you. let us know when you have test results.
thanks
mds
Quoted 179 lines · Jason D
Mark,
I don't think that there are any changes to the ICH7 SMBus Controller, other then DID, which is 27DAh. The Datasheet will not be available until the product launches. I will however, patch the driver with the new DID, test it out and then submit the patch here and to the LKML. My plan is to do this within the next six weeks or so. Unless you can or want to add the DID now?
Let me know if you would still like me to try something out on ICH5, ICH6 or ESB6300.
Thanks,
Jason Gaston
-----Original Message-----
From: Mark Studebaker [mailto:[email protected]]
Sent: Wednesday, December 08, 2004 9:37 AM
To: Gaston, Jason D
Cc: LM Sensors
Subject: Re: RFC: complete rewrite of i2c-i801 for 2.6.xthanks for offer. i2c block read support for ich5 and later is now in CVS.
Best way to test bus drivers is with 'i2cdump'.
In particular to test i2c block reads, best way is with the "i" mode of i2cdump.
If it works, regular byte ("b") mode and "i" mode should have identical results
when reading from an eeprom.For the ICH7, first we've heard of it, but not surprised it would be the chip
after ICH6 :)
I see there's nothing on developer.intel.com about it. Will there be any changes in the SMBus controller? What is the device ID? Datasheet availability?
Whether you submit 2.4 or 2.6 patches doesn't really matter. But with the device ID, and assurances that the SMBus part of the chip didn't change,
it's real easy.mds
Quoted 6 lines · Jason D
Mark,
I would be willing to do some testing of the i2c-i801 driver on ICH5, ICH6, ESB6300 and ICH7. I have access to boards/systems, but I am not proficient in i2c testing, other then running "sensors" and seeing the data. If you know of some instructions for the testing you are
looking
Quoted 75 lines
for, I am willing to give it a go.
In addition, I will soon want to get support for ICH7 added to the i2c-i801 driver. Last time, when I wanted to get support for ICH6 added, I posted a patch, adding the DID's, to the LKML and Greg KH. This made it into the 2.6 kernel. Perhaps I should get support added here first and then the base kernel?
Let me know how I can help,
Jason Gaston
[email protected]-----Original Message-----
From: Mark Studebaker [mailto:[email protected]]
Sent: Tuesday, December 07, 2004 7:02 PM
To: Sensors
Subject: Re: RFC: complete rewrite of i2c-i801 for 2.6.xQuoted 9 lines · Mark M. Hoffman
Hi Mark:
(CCs trimmed)
Quoted 1 line · Mark D. Studebaker
My reading of the DB datasheet (in 2002 and now) is that it doesn't
support a
Quoted 1 line
Quoted 1 line
standard i2c block read. The driver functionality bitmask reflects
that.
Quoted 1 line
Quoted 1 line
I fixed the error message (which would only print out if a driver
ignored
Quoted 8 lines
Quoted 1 line
the functionality mask).
Interesting. It looks like that datasheet only shows this:
S Addr Wr [A] Comm [A] D0 [A] D1 [A] S (read bytes...)I agree that's not like any transaction we support.
correct. don't know what they were thinking.
Quoted 5 lines
OTOH, the ICH5 [1] datasheet shows this:
S Addr Wr [A] D1 [A] S (read bytes...)That's exactly the transfer protocol that eeproms need, right?
(That's why I
Quoted 1 line
mentioned to Khali by IRC last weekend that I thought it should be
Quoted 7 lines
possible.)
I think it is what eeproms need (you omitted 'Addr' after the second 'S').
It matches what I wrote in doc/smbus-protocol in i2c (that is, the i2c block functions are defined to take a 'command'byte,
Quoted 33 lines
matching
what eeproms need for 'random' reads and writes).Does anybody have a ICH5/6? If so I can add support to the driver for testing.
mds
Quoted 1 line
It would be really bizarre if these two chipsets behaved differently
in this
Quoted 3 lines
respect - I wonder if the datasheets are correct?
[1] Well I just scanned all the other datasheets... only ICH5, ICH6,
and
Quoted 1 line
6300ESB appear to support the standard I2C block read. Sorry Khali.
:)
Quoted 2 lines
Regards,
This is true for "regular" PCI bus writes (which can be "posted") but not for accesses to config space, which are never posted.
The dummy reads are not necessary after config space writes.
mds
Quoted 33 lines · Greg KH
Quoted 5 lines · Jean Delvare
Quoted 3 lines
/* default: SMBus, no SMI#, enable host controller */ pci_write_config_byte(pcidev, I801_PCI_HOSTC, 0x01); pci_read_config_byte(pcidev, I801_PCI_HOSTC, &temp);And after that you don't use temp... Am I missing something?
This is commonly done to ensure that the write actually hits the bus before the code continues. Otherwise, the write could happen at some later point in time. The read after a write ensures that everything is synced up properly.
Quoted 9 lines
You might want to only write the bits that you know about, in case future chips would have more. Also you could use the constants you defined earlier. What about:
Quoted 4 lines
/* default: SMBus, no SMI#, enable host controller */ pci_read_config_byte(pcidev, I801_PCI_HOSTC, &temp); pci_write_config_byte(pcidev, I801_PCI_HOSTC, (temp & 0xF8) | I801_PCI_HOSTC_HST_EN);And then put a read after it too :)
thanks,
greg k-h
for CVS sensors modules, which must work with kernels 2.4.9 - 2.4.xx, we use hex ids if they aren't defined in 2.4.9.
For a 2.6 kernel patch, the preference is to include a patch to pci_ids.h if necessary and use only names in the driver.
mds
Quoted 240 lines · Jason D
Mark,
I see that you are using the DID's directly, for ICH5,6,7, rather then using the
pci_ids.hdefines. Is this your preference or would you rather use thepci_ids.hnames?I am wondering if I should also just use the actual DID's for the 2.6 patch?
Thanks,
Jason Gaston
-----Original Message-----
From: Mark Studebaker [mailto:[email protected]]
Sent: Wednesday, December 08, 2004 1:01 PM
To: Gaston, Jason D
Cc: LM Sensors
Subject: Re: RFC: complete rewrite of i2c-i801 for 2.6.xsince I'm in the middle of 801 driver updates already, I'll go ahead and add support to
the driver and sensors-detect in CVS. I'll leave the 2.6 patch to you. let us know when you have test results.
thanks
mdsQuoted 6 lines · Jason D
Mark,
I don't think that there are any changes to the ICH7 SMBus Controller, other then DID, which is 27DAh. The Datasheet will not be available until the product launches. I will however, patch the driver with the new DID, test it out and then submit the patch here and to the LKML.
My
Quoted 19 lines
plan is to do this within the next six weeks or so. Unless you can or want to add the DID now?
Let me know if you would still like me to try something out on ICH5, ICH6 or ESB6300.
Thanks,
Jason Gaston
-----Original Message-----
From: Mark Studebaker [mailto:[email protected]]
Sent: Wednesday, December 08, 2004 9:37 AM
To: Gaston, Jason D
Cc: LM Sensors
Subject: Re: RFC: complete rewrite of i2c-i801 for 2.6.xQuoted 4 lines
thanks for offer. i2c block read support for ich5 and later is now in CVS.
Best way to test bus drivers is with 'i2cdump'.
In particular to test i2c block reads, best way is with the "i" modeof
Quoted 2 lines
i2cdump.
If it works, regular byte ("b") mode and "i" mode should haveidentical
Quoted 4 lines
results
when reading from an eeprom.For the ICH7, first we've heard of it, but not surprised it would be
the
Quoted 3 lines
chip
after ICH6 :)
I see there's nothing on developer.intel.com about it. Will there beany
Quoted 154 lines
changes in the SMBus controller? What is the device ID? Datasheet availability?
Whether you submit 2.4 or 2.6 patches doesn't really matter. But with the device ID, and assurances that the SMBus part of the chip didn't change,
it's real easy.mds
Quoted 6 lines · Jason D
Mark,
I would be willing to do some testing of the i2c-i801 driver on ICH5, ICH6, ESB6300 and ICH7. I have access to boards/systems, but I am not proficient in i2c testing, other then running "sensors" and seeing the data. If you know of some instructions for the testing you are
looking
Quoted 82 lines
for, I am willing to give it a go.
In addition, I will soon want to get support for ICH7 added to the i2c-i801 driver. Last time, when I wanted to get support for ICH6 added, I posted a patch, adding the DID's, to the LKML and Greg KH. This made it into the 2.6 kernel. Perhaps I should get support added here first and then the base kernel?
Let me know how I can help,
Jason Gaston
[email protected]-----Original Message-----
From: Mark Studebaker [mailto:[email protected]]
Sent: Tuesday, December 07, 2004 7:02 PM
To: Sensors
Subject: Re: RFC: complete rewrite of i2c-i801 for 2.6.xQuoted 10 lines · Mark M. Hoffman
Hi Mark:
(CCs trimmed)
Quoted 1 line · Mark D. Studebaker
My reading of the DB datasheet (in 2002 and now) is that it doesn't
support a
Quoted 1 line
Quoted 1 line
standard i2c block read. The driver functionality bitmask reflects
that.
Quoted 1 line
Quoted 1 line
I fixed the error message (which would only print out if a driver
ignored
Quoted 8 lines
Quoted 1 line
the functionality mask).
Interesting. It looks like that datasheet only shows this:
S Addr Wr [A] Comm [A] D0 [A] D1 [A] S (read bytes...)I agree that's not like any transaction we support.
correct. don't know what they were thinking.
Quoted 5 lines
OTOH, the ICH5 [1] datasheet shows this:
S Addr Wr [A] D1 [A] S (read bytes...)That's exactly the transfer protocol that eeproms need, right?
(That's why I
Quoted 1 line
mentioned to Khali by IRC last weekend that I thought it should be
Quoted 7 lines
possible.)
I think it is what eeproms need (you omitted 'Addr' after the second 'S').
It matches what I wrote in doc/smbus-protocol in i2c (that is, the i2c block functions are defined to take a 'command'byte,
Quoted 37 lines
matching
what eeproms need for 'random' reads and writes).Does anybody have a ICH5/6? If so I can add support to the driver for testing.
mds
Quoted 1 line
It would be really bizarre if these two chipsets behaved differently
in this
Quoted 3 lines
respect - I wonder if the datasheets are correct?
[1] Well I just scanned all the other datasheets... only ICH5, ICH6,
and
Quoted 1 line
6300ESB appear to support the standard I2C block read. Sorry Khali.
:)
Quoted 2 lines
Regards,
Hi Mark,
Quoted 5 lines
Interesting. It looks like that datasheet only shows this:
S Addr Wr [A] Comm [A] D0 [A] D1 [A] S (read bytes...)I agree that's not like any transaction we support.
True. Not only that but it seems that this function is broken at least in the ICH3-M (which I have). The specification update from Intel [1] says so.
Quoted 7 lines
OTOH, the ICH5 [1] datasheet shows this:
S Addr Wr [A] D1 [A] S (read bytes...)That's exactly the transfer protocol that eeproms need, right? (That's why I mentioned to Khali by IRC last weekend that I thought it should be possible.)
True again.
Quoted 2 lines
It would be really bizarre if these two chipsets behaved differently in this respect - I wonder if the datasheets are correct?
I think they are. Intel are very serious with datasheets. I believe they implemented a useless function, realized that and simply changed it in the newer revisions of the ICH. BTW it would certainly be worth looking at the revision numbers of our chips. The revision is shown by lspci (aming others). Mine is 01. I would expect a different value for the chips with the new I2C block read function. If I'm right, that would be a convenient detection method.
I will not try the weird I2C block read on my system since it really starts like a write command and I wouldn't want to trash my eeproms accidentally.
Quoted 2 lines
[1] Well I just scanned all the other datasheets... only ICH5, ICH6, and 6300ESB appear to support the standard I2C block read. Sorry Khali. :)
Yes, it looks so. I guess I'll have to change my laptop for an ICH6-based one then ;)
However, what I had in mind was NOT to use that weird function but to hi-jack the SMBus block read command. Unless I am mistaken, the only difference between SMBus and I2C block reads is that the former has an additional leading (read) byte for the length while the latter doesn't. My plan was to implement I2C block reads using the SMBus block read. All I'd need to do is copy the supposed length byte as the first data byte and shift all other data bytes by one position. Sounds simple... except that it doesn't seem to work. Or, more precisely, sometimes it works and sometimes is doesn't. Seems to depend on the first byte read. I suppose that the ICH3-M trusts this byte more than the LAST_BYTE bit (the specification update confirms that this is the case for the weird I2C block read function, making it useless as I said earlier). I tried to overwrite the byte length with 32 after the first transfer of the block but it didn't seem to help. Also, I see no relation between the value of the first byte and the point at which the block read dies on a timeout, although this is perfectly reproducible.
I'll investigate again this evening but with little hope. And anyway this sounds like a trick we might not want to implement in the released driver even if it somewhat works, especially since I2C block reads are really only a bonus for EEPROMs, not a vital feature for hardware monitoring.
[1] http://www.intel.com/design/chipsets/specupdt/290718.htm
Thanks,
--
Jean Delvare