LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Charles Keepax <ckeepax@opensource.cirrus.com>
To: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Cc: Wolfram Sang <wsa@the-dreams.de>,
	Linux I2C <linux-i2c@vger.kernel.org>,
	lkml <linux-kernel@vger.kernel.org>,
	<patches@opensource.cirrus.com>
Subject: Re: [PATCH 2/2] i2c: Clear client->irq in i2c_device_remove
Date: Tue, 30 Oct 2018 11:51:20 +0000	[thread overview]
Message-ID: <20181030115120.GI16508@imbe.wolfsonmicro.main> (raw)
In-Reply-To: <CAO-hwJLw74k+jBnDuQ7OrVzJOy8i82OXKNWuNhxNqUj+8nzwhg@mail.gmail.com>

On Mon, Oct 29, 2018 at 11:15:47AM +0100, Benjamin Tissoires wrote:
> On Sun, Oct 28, 2018 at 11:31 PM Wolfram Sang <wsa@the-dreams.de> wrote:
> >
> > On Fri, Oct 19, 2018 at 09:59:58AM +0100, Charles Keepax wrote:
> > > The IRQ will be mapped in i2c_device_probe only if client->irq is zero and
> > > i2c_device_remove does not clear this. When rebinding an I2C device,
> > > whos IRQ provider has also been rebound this means that an IRQ mapping
> > > will never be created, causing the I2C device to fail to acquire its
> > > IRQ. Fix this issue by clearing client->irq in i2c_device_remove,
> > > forcing i2c_device_probe to lookup the mapping again.
> > >
> > > Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
> >
> > Adding Benjamin here again. Also, should there be a Fixes: tag?
> 
> Not sure if the circumstances are preventing me to think straight, but
> how can you reprobe the i2c_device?

You just head into /sys/bus/i2c/drivers/<the_driver> and use the
unbind file to remove the driver. You can then probe the driver
again using the bind file.

> And in all cases, for the Host notify part, having the IRQ already set
> shouldn't be an issue.

To be clear this isn't a theoretical issue this is something I
can replicate very easily. The problem comes in when you unbind
both the I2C device and the device that is providing its IRQ. In
my case the I2C device is a speaker amp and the device providing
IRQs is an audio CODEC.

When the device providing the IRQ is unbound it will delete the
IRQ mapping. For the I2C device to acquire its IRQ something
needs to recreate that mapping, this would normally happen (in a
DT system) as a result of the of_irq_get/_by_name. But as
client->irq is already set this doesn't happen, causing the I2C
device to fail probe because it couldn't locate its IRQ.

I can provide some stack traces or something if that would help
to clarify the issue?

Thanks,
Charles

  reply	other threads:[~2018-10-30 11:51 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-19  8:59 [PATCH 1/2] i2c: Remove unnecessary call to irq_find_mapping Charles Keepax
2018-10-19  8:59 ` [PATCH 2/2] i2c: Clear client->irq in i2c_device_remove Charles Keepax
2018-10-28 22:31   ` Wolfram Sang
2018-10-29 10:15     ` Benjamin Tissoires
2018-10-30 11:51       ` Charles Keepax [this message]
2018-10-30 14:34         ` Benjamin Tissoires
2018-10-30 14:55           ` Wolfram Sang
2018-10-31  9:52             ` Charles Keepax
2018-10-31  9:59               ` Wolfram Sang
2018-10-31 23:35   ` Wolfram Sang
2019-01-09 21:47   ` Yauhen Kharuzhy
2019-01-10 13:32     ` Charles Keepax
2019-01-10 20:35       ` Yauhen Kharuzhy
2018-10-28 22:30 ` [PATCH 1/2] i2c: Remove unnecessary call to irq_find_mapping Wolfram Sang
2018-10-29 10:13   ` Benjamin Tissoires
2018-10-31 23:34 ` Wolfram Sang

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=20181030115120.GI16508@imbe.wolfsonmicro.main \
    --to=ckeepax@opensource.cirrus.com \
    --cc=benjamin.tissoires@redhat.com \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=patches@opensource.cirrus.com \
    --cc=wsa@the-dreams.de \
    --subject='Re: [PATCH 2/2] i2c: Clear client->irq in i2c_device_remove' \
    /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

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).