linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Yauhen Kharuzhy <jekhor@gmail.com>
To: Charles Keepax <ckeepax@opensource.cirrus.com>
Cc: wsa@the-dreams.de, linux-i2c@vger.kernel.org,
	linux-kernel@vger.kernel.org, patches@opensource.cirrus.com
Subject: Re: [PATCH 2/2] i2c: Clear client->irq in i2c_device_remove
Date: Thu, 10 Jan 2019 00:47:56 +0300	[thread overview]
Message-ID: <20190109214756.GA18115@jeknote.loshitsa1.net> (raw)
In-Reply-To: <20181019085958.32694-2-ckeepax@opensource.cirrus.com>

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.

Hi.

I found  driver i2c/busses/i2c-cht-wc.c which instantiates I2C device
(battery charger) and passes IRQ to driver not using standard I2C IRQ mapping code.
So if we reprobe I2C device (by reloading I2C device driver module or by
manipulations with sysfs), we get invalid IRQ number for client:

 adap->client_irq = irq_create_mapping(adap->irq_domain, 0);
 ...
 irq_set_chip_data(adap->client_irq, adap);
 irq_set_chip_and_handler(adap->client_irq, &adap->irqchip, handle_simple_irq);
 ...
 board_info.irq = adap->client_irq;
 adap->client = i2c_new_device(&adap->adapter, &board_info);


adap->client->irq will be reset after device removing here.


Any advice to fix this? Maybe move initial i2c_client->irq value to new field
like client->init_irq and copy it to client->irq at probing, for example?

> 
> Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
> Reviewed-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
> ---
>  drivers/i2c/i2c-core-base.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c
> index 656f0a6fe3adf..28460f6a60cc1 100644
> --- a/drivers/i2c/i2c-core-base.c
> +++ b/drivers/i2c/i2c-core-base.c
> @@ -430,6 +430,8 @@ static int i2c_device_remove(struct device *dev)
>  	dev_pm_clear_wake_irq(&client->dev);
>  	device_init_wakeup(&client->dev, false);
>  
> +	client->irq = 0;
> +
>  	return status;
>  }
>  

-- 
Yauhen Kharuzhy

  parent reply	other threads:[~2019-01-09 21:48 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
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 [this message]
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=20190109214756.GA18115@jeknote.loshitsa1.net \
    --to=jekhor@gmail.com \
    --cc=ckeepax@opensource.cirrus.com \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=patches@opensource.cirrus.com \
    --cc=wsa@the-dreams.de \
    /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).