From: Felix Rubinstein <felixru-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: Jean Delvare <khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org>
Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: Intel ICHx bus driver
Date: Wed, 3 Mar 2010 18:36:40 +0200 [thread overview]
Message-ID: <af0693f01003030836u55bc4b0akbdf402327bd10e0@mail.gmail.com> (raw)
In-Reply-To: <20100302222203.1eb67c3a-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>
Hi Jean,
On Tue, Mar 2, 2010 at 11:22 PM, Jean Delvare <khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org> wrote:
>
> Hi Felix,
>
> On Wed, 24 Feb 2010 14:01:56 +0200, Felix Rubinstein wrote:
> > Here is my code:
> >
> > ------------
> > #include <stdio.h>
> > #include <unistd.h>
> > #include <sys/types.h>
> > #include <sys/stat.h>
> > #include <fcntl.h>
> > #include <sys/ioctl.h>
> > #include <stdlib.h>
> >
> > #include "i2c-dev.h"
> > #include "i2cbusses.h"
> > #include "util.h"
> >
> > /* actually smbus allows up to 32 and i2c even more */
> > #define I2CRWL_MAX_PARAMS 10
> > #define I2CRWL_PARAMS_SHIFT 3
> >
> > static int i2c_writel(int fd, int datac, char *datav[])
> > {
> > int i;
> > unsigned char buf[I2CRWL_MAX_PARAMS];
> > unsigned int data;
> >
> > for (i = 0; i < datac && i < I2CRWL_MAX_PARAMS; i++) {
> > sscanf(datav[i], "%x", &data);
> > buf[i] = (unsigned char)data;
> > }
> >
> > if (i2c_smbus_write_i2c_block_data(fd, buf[0], datac - 1,
> > &buf[1]) < 0) {
> > perror("\n");
>
> You'd rather use:
>
> perror("i2c_smbus_write_i2c_block_data");
>
> so that error messages are clearer.
>
> > return 1;
> > }
> >
> > return 0;
> > }
> >
> >
> > static void help(const char *progname)
> > {
> > fprintf(stderr,
> > "Usage: %s I2CBUS CHIP-ADDRESS DATA0 [DATA1
> > ... DATAn]\n"
> > " I2CBUS is an integer or an I2C bus name\n"
> > " CHIP-ADDRESS is an integer (0x03 - 0x77)\n"
> > " DATAx is data to be written to the chip,
> > where 0 <= x <= n\n\n", progname);
> > exit(1);
> > }
> >
> > int main(int argc, char *argv[])
> > {
> > int fd, i2cbus, addr, ret = 0;
> > char filename[20];
> >
> > if ((argc < I2CRWL_PARAMS_SHIFT + 1) || (I2CRWL_MAX_PARAMS +
> > I2CRWL_PARAMS_SHIFT < argc))
> > help(argv[0]);
> >
> > i2cbus = lookup_i2c_bus(argv[1]);
> > if (i2cbus < 0)
> > help(argv[0]);
> >
> > addr = parse_i2c_address(argv[2]);
> > if (addr < 0)
> > help(argv[0]);
> >
> > fd = open_i2c_dev(i2cbus, filename, 0);
> > if (fd < 0)
> > exit(1);
> >
> > if (ioctl(fd, I2C_SLAVE, addr) < 0) {
> > ret = 1;
> > perror("");
>
> Same here, perror("ioctl(I2C_SLAVE)") or similar.
>
> > goto out;
> > }
> >
> >
> > if (i2c_writel(fd, argc - I2CRWL_PARAMS_SHIFT,
> > &argv[I2CRWL_PARAMS_SHIFT])) {
> > ret = 1;
> > goto out;
> > }
> >
> >
> > out:
> > close(fd);
> >
> > return ret;
> > }
> > ------------
> >
> > BTW, I've disabled the FEATURE_BLOCK_BUFFER
> >
> > --- i2c-i801.c 2010-02-24 10:50:50.060209638 +0200
> > +++ i2c-i801.c.orig 2010-02-24 13:55:29.664070673 +0200
> > @@ -603,7 +603,6 @@
> > /* fall through */
> > case PCI_DEVICE_ID_INTEL_82801DB_3:
> > i801_features |= FEATURE_SMBUS_PEC;
> > - i801_features |= FEATURE_BLOCK_BUFFER;
> > break;
> > }
> >
> > and now everything works smoothly. I2C write transaction of arbitrary
> > length are seen even by scope :)
> >
> > In case if I don't, here is what I get:
> >
> > $ dmesg | tail
> > Transaction timeout
> > Terminating the current operation
> > Failed terminating the transaction
> > Failed clearing status flags at end of transaction ...
>
> Obviously, if disabling the block buffer makes the same transaction
> work, then it has to be a bug in the driver. And the good news is: I
> was able to reproduce the bug using your test program, on an ICH5
> running kernel 2.6.27.45. On the same system, I can get SMBus block
> reads to work with or without the block buffer, so block buffer support
> is not entirely broken (if it was, we'd certainly have noticed earlier.)
>
> Now ideally we need to figure out whether SMBus block writes are
> affected as well. We already know that SMBus block reads are not, and
> I2C block writes are. As I2C block reads are excluded (the block buffer
> can not be used for them according to the datasheet, and the driver
> already does the right thing), checking whether SMBus block writes are
> affected will tell us whether all block writes are affected, or if I2C
> block writes only are affected. This should help us find out where and
> what the bug could be.
Ok, here is what I did.
I run the code with i2c_smbus_write_block_data with E32B enabled,
i.e. the original version of the driver and SMBus multi-byte write
transactions were successful (I also verified it against the scope
analyzer).
But what I run the code with i2c_smbus_write_i2c_block_data, here is what I got:
# ./i2c_wl 0 0x28 0x1 0xff 0xff
i2c_smbus_write_i2c_block_data: Operation not permitted
l# ./i2c_wl 0 0x28 0x1 0xff 0xff 0xff 0xff
Success ...
# dmesg | tail
[ 430.580131] i801_smbus 0000:00:1f.3: Transaction (post): CNT=14,
CMD=01, ADD=50, DAT0=02, DAT1=00
[ 430.580312] i2c-adapter i2c-0: ioctl, cmd=0x708, arg=0x01
[ 464.280155] i2c-adapter i2c-0: ioctl, cmd=0x703, arg=0x28
[ 464.280155] i2c-adapter i2c-0: ioctl, cmd=0x708, arg=0x00
[ 464.280155] i2c-adapter i2c-0: ioctl, cmd=0x720, arg=0xbfdaa63c
[ 464.280155] i801_smbus 0000:00:1f.3: Transaction (pre): CNT=14,
CMD=01, ADD=50, DAT0=04, DAT1=00
[ 464.280155] i801_smbus 0000:00:1f.3: SMBus busy (14). Resetting...
[ 464.280155] i801_smbus 0000:00:1f.3: Successful!
[ 464.287033] i801_smbus 0000:00:1f.3: Transaction (post): CNT=14,
CMD=01, ADD=50, DAT0=04, DAT1=00
[ 464.287080] i2c-adapter i2c-0: ioctl, cmd=0x708, arg=0x01
In addition, the scope analyzer showed me that (when I run this
command ./i2c_wl 0 0x28 0x1 0xff 0xff) the last byte 0xff wasn't sent
on the bus. In contrary, every byte was on the bus with
i2c_smbus_write_block_data.
Thanks,
Felix R.
>
> --
> Jean Delvare
> http://khali.linux-fr.org/wishlist.html
next prev parent reply other threads:[~2010-03-03 16:36 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-01-27 17:56 Intel ICHx bus driver Felix Rubinstein
[not found] ` <af0693f01001270956h781f2832r928364574d3406aa-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2010-01-28 7:59 ` Jean Delvare
[not found] ` <20100128085904.4e202de1-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>
2010-01-28 9:32 ` Felix Rubinstein
[not found] ` <af0693f01001280132l4002af0fgf3137fa27ce8555e-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2010-01-28 9:53 ` Jean Delvare
[not found] ` <20100128105340.41aecf64-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>
2010-01-28 12:46 ` Felix Rubinstein
[not found] ` <af0693f01001280446u66923c70ld707d10b9fcee068-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2010-01-28 13:29 ` Jean Delvare
[not found] ` <af0693f01002182310i6678e4b5h80feb14b24b37742@mail.gmail.com>
[not found] ` <af0693f01002182310i6678e4b5h80feb14b24b37742-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2010-02-19 9:58 ` Jean Delvare
[not found] ` <20100219105841.2bd8b16c-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>
2010-02-22 16:12 ` Felix Rubinstein
[not found] ` <af0693f01002220812n5a6060cejc00d1ebbd7b9424d-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2010-02-22 21:58 ` Jean Delvare
[not found] ` <af0693f01002231521q4f99eb63ocd607670625fadfa@mail.gmail.com>
[not found] ` <af0693f01002231521q4f99eb63ocd607670625fadfa-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2010-02-24 12:01 ` Felix Rubinstein
[not found] ` <af0693f01002240401g1aeaf840ld06a156a06be9dbf-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2010-03-02 21:22 ` Jean Delvare
[not found] ` <20100302222203.1eb67c3a-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>
2010-03-03 16:36 ` Felix Rubinstein [this message]
2010-03-03 16:59 ` Jean Delvare
2010-02-28 11:08 ` Jean Delvare
[not found] ` <20100228120817.275ef279-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>
2010-02-28 13:45 ` Felix Rubinstein
[not found] ` <af0693f01002280545n622b1c41v1f8c104e57fb51b6-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2010-02-28 20:19 ` Jean Delvare
[not found] ` <20100228211949.3297a0ff-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>
2010-03-02 12:53 ` Felix Rubinstein
[not found] ` <af0693f01003020453m7ca6891bjca4833c7fa45f44d-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2010-03-12 13:19 ` Jean Delvare
[not found] ` <20100312141901.04299a55-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>
2010-03-12 16:24 ` Jean Delvare
[not found] ` <20100312172421.5b4907e6-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>
2010-03-15 9:43 ` Felix Rubinstein
[not found] ` <af0693f01003150243u4d4d76e7t71b37ecd452896ea-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2010-03-15 10:06 ` Jean Delvare
[not found] ` <20100315110645.1df3e4f0-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>
2010-03-15 11:12 ` Felix Rubinstein
[not found] ` <af0693f01003150412p5823d8e0j678b035b1c7cc4bb-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2010-03-15 11:46 ` Jean Delvare
[not found] ` <20100315124648.6dafae21-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>
2010-03-15 13:12 ` Felix Rubinstein
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=af0693f01003030836u55bc4b0akbdf402327bd10e0@mail.gmail.com \
--to=felixru-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
--cc=khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org \
--cc=linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).