All of lore.kernel.org
 help / color / mirror / Atom feed
From: Feng Tang <feng.tang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
To: Jean Delvare <khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org>
Cc: "jacob.jun.pan-VuQAYsv1563Yd54FQh9/CA@public.gmane.org"
	<jacob.jun.pan-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>,
	i2c list <linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	Ben Dooks <ben-linux-elnMNo+KYs3YtjvyW6yDsg@public.gmane.org>,
	wen.w.wang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org
Subject: Re: [PATCH] i2c: skip address detection if provided in board_info
Date: Thu, 14 Oct 2010 01:04:22 +0800	[thread overview]
Message-ID: <20101014010422.0247b96b@feng-vmt> (raw)
In-Reply-To: <20101012133425.490e3c4c-R0o5gVi9kd7kN2dkZ6Wm7A@public.gmane.org>

Hi Jean,

On Tue, 12 Oct 2010 19:34:25 +0800
Jean Delvare <khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org> wrote:

> Hi Feng,
> 
> On Tue, 12 Oct 2010 17:30:28 +0800, Feng Tang wrote:
> > On Tue, 12 Oct 2010 16:47:07 +0800
> > Jean Delvare <khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org> wrote:
> > > Of course i2c_detect gets called at times, otherwise we would
> > > delete it altogether ;)
> > > 
> > > Please point me to the I2C adapter driver(s) you care about, and
> > > also the platform init code for your system. I would like to see
> > > how it looks like.
> > > 
> > > I think it would also help if I had a global picture of your
> > > project and what you are trying to achieve. I presume we are
> > > talking about an embedded system? With a custom kernel maybe?
> > > Which platform/architecture?
> > 
> > Yes, we are working a x86 based embedded system, Intel's Moorestown
> > and Medfield systems, its current platform init code is
> > arch/x86/kernel/mrst.c, but the I2c init code hasn't been pushed
> > upstream yet :(, but basically it get i2c devices info from a SFI
> > table (drivers/sfi/) and use i2c_register_board_info for them.
> > 
> > The adapter driver is i2c-mrst.c which is not in current i2c
> > subsystem yet, seems it has been submitted to i2c devel list
> > before. And our platform has many identical adapters. 
> 
> I remember that driver, I reviewed it long ago (more than 1 year ago I
> think). Apparently driver was renamed to i2c-intel-mid meanwhile.
> Still not upstream indeed, but the last version of the driver posted
> by Alan Cox [1] does _not_ set the i2c_adapter.class field.
> 
> [1] http://marc.info/?l=linux-i2c&m=128292492431251&w=2

Yes, it was. But the latest code we are using set the class, that's why we
hit the problem :(

> 
> > > (...)
> > > But you normally only load the hwmon drivers you need on a given
> > > machine. That's only a couple of them. Or are you, by any chance,
> > > building a monolithic kernel with all hwmon drivers included? This
> > > would indeed be a problem, the i2c subsystem isn't prepared for
> > > that.
> > 
> > Actually we run into a long boot time problem while we build in only
> > one i2c device driver (drivers/hwmon/emc1403.c) which has 4
> > addresses in its address lit, it took more than 10 seconds for the
> > driver to init on our platforms. So if we build in more i2c hwmon
> > drivers, things will get much worse. That's why Jacob posted the
> > patch.
> 
> This suggests that the i2c adapter driver is pretty bad at handling
> NACKs when trying to access a non-existing device. It might be worth
> checking if this can be improved, because that case could happen not
> only during device detection but also in other circumstances.
> 
> > I did read code about setting adapter->class, seems most driver set
> > its class in their proble function, trying set it in platform code
> > may looks not very clean.
> 
> Actually this is very clean and by far my preferred way to solve your
> problem. This is exactly how things are done on the PXA platform
> (check i2c-pxa.c.)

Yes, setting the class to 0 should fix our problem, though still need the
driver author to confirm the change doesn't have other side effects.
Thanks for your time helping figure this out.

But I still have some concern (not specific to our platforms), I just checked,
there are 42 i2c adapter drivers set their class to I2C_CLASS_HWMON and 50
hwmon i2c device drivers set it as well. So if a kernel has an adapter driver
and hwmon driver which both set I2C_CLASS_HWMON, the long init time problem
will show up again, and it will be worse if there are multiple adapters HW
there.

Thanks,
Feng   

> 
> > Yours suggestion of using a build time option definitely will
> > shrink the kernel size. But our platform is under arch/x86, and one
> > general rule is to one generic kernel config should work for all
> > x86 platforms, so I'm afraid it can't solve our problem.
> 
> OK, fair enough.
> 
> > So I still prefer the option of adding a flag, and leave the choice
> > for platform code whether to do the detect. If you agree, I would
> > make a cleaner patch.
> 
> And I prefer that you set the class flag value in the platform data
> and have your i2c adapter driver read it. This is already supported
> and should work very fine without any change to i2c-core. I see no
> point in adding a global flag when we already have a much
> finer-grained setting available.
> 

  parent reply	other threads:[~2010-10-13 17:04 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-11 23:10 [PATCH] i2c: skip address detection if provided in board_info jacob.jun.pan-VuQAYsv1563Yd54FQh9/CA
     [not found] ` <1286838635-16474-1-git-send-email-jacob.jun.pan-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2010-10-12  7:28   ` Jean Delvare
     [not found]     ` <20101012092822.6f4e4aa5-R0o5gVi9kd7kN2dkZ6Wm7A@public.gmane.org>
2010-10-12  8:21       ` Feng Tang
2010-10-12  8:47         ` Jean Delvare
     [not found]           ` <20101012104707.3318511d-R0o5gVi9kd7kN2dkZ6Wm7A@public.gmane.org>
2010-10-12  9:30             ` Feng Tang
2010-10-12 11:34               ` Jean Delvare
     [not found]                 ` <20101012133425.490e3c4c-R0o5gVi9kd7kN2dkZ6Wm7A@public.gmane.org>
2010-10-12 18:01                   ` Jacob Pan
2010-10-13  7:26                     ` Jean Delvare
     [not found]                       ` <20101013092654.7e26fa00-R0o5gVi9kd7kN2dkZ6Wm7A@public.gmane.org>
2010-10-13 15:54                         ` Jacob Pan
2010-10-13 16:07                           ` Jean Delvare
     [not found]                             ` <20101013180751.2d37c513-R0o5gVi9kd7kN2dkZ6Wm7A@public.gmane.org>
2010-10-13 17:01                               ` Jacob Pan
2010-10-13 17:04                   ` Feng Tang [this message]
2010-10-13  9:29                     ` Jean Delvare

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=20101014010422.0247b96b@feng-vmt \
    --to=feng.tang-ral2jqcrhueavxtiumwx3w@public.gmane.org \
    --cc=ben-linux-elnMNo+KYs3YtjvyW6yDsg@public.gmane.org \
    --cc=jacob.jun.pan-VuQAYsv1563Yd54FQh9/CA@public.gmane.org \
    --cc=khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org \
    --cc=linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=wen.w.wang-ral2JQCrhuEAvxtiuMwx3w@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.