public inbox for linux-i2c@vger.kernel.org
 help / color / mirror / Atom feed
From: Ivo Manca <pinkel-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: Jean Delvare <khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org>
Cc: Hans de Goede <j.w.r.degoede-fbo2DhPpy/Q@public.gmane.org>,
	i2c-GZX6beZjE8VD60Wz+7aTrA@public.gmane.org
Subject: Re: [PATCH 01/03] i2c-i801: Add basic interrupt support
Date: Wed, 13 Aug 2008 21:17:22 +0200	[thread overview]
Message-ID: <48A33342.1050105@gmail.com> (raw)
In-Reply-To: <20080812101545.600ca850-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>

Hey Jean,
> Please provide patches that can be applied with patch -p1 from the root
> of the kernel source tree.
>   
Will do, sorry about that

> Having this here is a bit confusing, you should leave all the
> transaction types (from I801_QUICK to I801_I2C_BLOCK_LAST) as a block.
>   
Oops, not a smart place to put this constant, I agree. Moved to

> I801_HST_CNT_INTREN (which could probably be renamed to just
> I801_INTREN for brevity) would go first.
>
> Also note that the drivers already had a define for this flag, named
> ENABLE_INT9, although it was disabled. I agree that I801_INTREN is a
> better name, but it would probably be a good idea to delete ENABLE_INT9
> and all references thereto first, otherwise the code becomes a little
> confusing.
>   
Will do. I'll just delete ENABLE_INT9 all together.

> You never really use the irq value, only whether it is -1 or not. So it
> might make more sense to turn it into a flag and rename it to use_irq?
>   
Yup, seems like a waste to store the value :)

> Please make this HZ/2 a define so that it's easy to change. 
Done

> Ideally this define would replace MAX_TIMEOUT (in a separate patch) so 
> that both
> the poll-based and the interrupt-driven paths have the same timeout 
> value. Right now,
> the timeout handling of the poll-based path is rather ugly (the actual 
> timeout depends on
> the value of HZ.)
Hm, seems like a very sensible thing to do. However, I have no idea how 
to implement that, since you don't really know how long msleep slept, or 
not? I sadly don't really have time to look into this right now, sorry.

> Not sure why you make this wait interruptible. The poll-based path
> isn't interruptible, and you do not handle the interrupted case anyway.
>   
I'm not an expert, but I think this is the right way to use it.
The interupt handler i801_isr catches the interrupt, saves the status to 
algo_data and calls wake_up_interruptable. This will wake up the wait.

I'm not sure whether this is the correct way or not. Any input from an 
interrupt expert is very much welcome.
I did test it without the event_interruptable, which produces nonsense, 
like:

====
polling
====
[root@localhost busses]# time i2cdetect -y 0
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- 08 -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- 44 -- -- -- -- -- -- -- -- -- -- --
50: 50 -- -- -- 54 55 -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- 69 -- -- -- -- -- --
70: -- -- -- UU -- -- -- --

real    0m0.235s
user    0m0.000s
sys     0m0.003s

====
wait_event_interruptable_timeout
====
[root@localhost busses]# time i2cdetect -y 0
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- 08 -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- 44 -- -- -- -- -- -- -- -- -- -- --
50: 50 -- -- -- 54 55 -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- 69 -- -- -- -- -- --
70: -- -- -- UU -- -- -- --

real    0m0.130s
user    0m0.001s
sys     0m0.009s

====
wait_event_timeout
====
[root@localhost busses]# time i2cdetect -y 0
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- 0a -- -- -- -- --
10: 10 -- -- -- -- -- -- -- -- 19 -- -- -- -- 1e --
20: -- -- -- -- 24 -- -- -- -- 29 -- -- -- -- -- --
30: 30 -- -- 33 -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --

real    0m4.090s
user    0m0.000s
sys     0m0.004s

> The polled-based path has additional logic to handle the timeout case
> (by resetting the controller.) I would guess you want the same for the
> interrupt-driven path?
>   
Agree. After merging to 2.6.27-rc3, I noticed a helper function called 
i801_check_post was added. Seems to be the ideal place to pass the 
return data to.

> Please add a trailing comma.
>   
Done
> i801_adapter.name is a rather long string, I think I'd rather use
> i801_driver.name to register the IRQ.
>   
Ok
> I think you have a race here. You free the irq before removing the i2c
> adapter. What will happen if someone initiates an I2C transaction after
> the IRQ has been freed? It would probably be better to remove the i2c
> adapter first.
>   
Quite an obvious race as well... Changed already.
> Other than that, it looks good to me, good work. Note though that I am
> in no way an expert of interrupt handling, as this is the first
> PC-style SMBus controller driver which gets converted to use interrupts
> instead of polling.
>   
Thanks. I'm by no means an expert as well, it's all quite new to me. 
Thanks a lot for your patience.

I'll send you an updated patch later this evening. I don't know anything 
about config files though, so that'll have to wait a bit... The module 
parameter will be added though.

Ivo

_______________________________________________
i2c mailing list
i2c-GZX6beZjE8VD60Wz+7aTrA@public.gmane.org
http://lists.lm-sensors.org/mailman/listinfo/i2c

  parent reply	other threads:[~2008-08-13 19:17 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-07-23 16:56 [PATCH 01/03] i2c-i801: Add basic interrupt support Ivo Manca
     [not found] ` <488762C8.6090105-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2008-08-12  8:15   ` Jean Delvare
     [not found]     ` <20080812101545.600ca850-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>
2008-08-13 19:17       ` Ivo Manca [this message]
     [not found]         ` <48A33342.1050105-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2008-08-13 19:59           ` Ivo Manca
2008-08-13 20:38           ` 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=48A33342.1050105@gmail.com \
    --to=pinkel-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
    --cc=i2c-GZX6beZjE8VD60Wz+7aTrA@public.gmane.org \
    --cc=j.w.r.degoede-fbo2DhPpy/Q@public.gmane.org \
    --cc=khali-PUYAD+kWke1g9hUCZPvPmw@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