Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1437490

Re: [PATCH 2/2] i2c-dev: Don't block the adapter from unregistering

From Wolfram Sang <wsa@the-dreams.de>
Newsgroups linux.kernel
Subject Re: [PATCH 2/2] i2c-dev: Don't block the adapter from unregistering
Date 2016-07-06 09:00 +0200
Message-ID <rROYp-5Ma-1@gated-at.bofh.it> (permalink)
References <rRLe9-3nf-3@gated-at.bofh.it> <rRLe9-3nf-17@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


[Multipart message — attachments visible in raw view] - view raw

On Tue, Jul 05, 2016 at 07:57:07PM -0700, Viresh Kumar wrote:
> The i2c-dev calls i2c_get_adapter() from the .open() callback, which
> doesn't let the adapter device unregister unless the .close() callback
> is called.
> 
> On some platforms (like Google ARA), this doesn't let the modules
> (hardware attached to the phone) eject from the phone as the cleanup
> path for the module hasn't finished yet (i2c adapter not removed).
> 
> We can't let the userspace block the kernel forever in such cases.
> 
> Fix this by calling i2c_get_adapter() from all other file operations,
> i.e.  read/write/ioctl, to make sure the adapter doesn't get away while
> we are in the middle of a operation, but not otherwise. In .open() we
> will release the adapter device before returning and so if there is no
> data transfer in progress, then the i2c-dev doesn't block the adapter
> from unregistering.
> 
> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>

I'd think Jean has more experience with I2C hotplugging approaches and
difficulties, so I'd be interested in his high level review.

However:

> @@ -234,6 +234,7 @@ struct i2c_client {
>  	struct i2c_adapter *adapter;	/* the adapter we sit on	*/
>  	struct device dev;		/* the device structure		*/
>  	int irq;			/* irq issued by device		*/
> +	int adapter_nr;
>  	struct list_head detected;

Adding something to *every* i2c_client for this corner case sounds
pretty expensive to me.

Regards,

   Wolfram

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 0/2] i2c-dev: Don't let userspace block adapter Viresh Kumar <viresh.kumar@linaro.org> - 2016-07-06 05:00 +0200
  [PATCH 2/2] i2c-dev: Don't block the adapter from unregistering Viresh Kumar <viresh.kumar@linaro.org> - 2016-07-06 05:00 +0200
    Re: [PATCH 2/2] i2c-dev: Don't block the adapter from unregistering kbuild test robot <lkp@intel.com> - 2016-07-06 07:10 +0200
    Re: [PATCH 2/2] i2c-dev: Don't block the adapter from unregistering Wolfram Sang <wsa@the-dreams.de> - 2016-07-06 09:00 +0200
      Re: [PATCH 2/2] i2c-dev: Don't block the adapter from unregistering Viresh Kumar <viresh.kumar@linaro.org> - 2016-07-06 16:00 +0200
      Re: [PATCH 2/2] i2c-dev: Don't block the adapter from unregistering Jean Delvare <jdelvare@suse.de> - 2016-07-06 19:20 +0200
        Re: [PATCH 2/2] i2c-dev: Don't block the adapter from unregistering Viresh Kumar <viresh.kumar@linaro.org> - 2016-07-06 23:00 +0200
    Re: [PATCH 2/2] i2c-dev: Don't block the adapter from unregistering Viresh Kumar <viresh.kumar@linaro.org> - 2016-07-06 16:40 +0200
      Re: [PATCH 2/2] i2c-dev: Don't block the adapter from unregistering Lars-Peter Clausen <lars@metafoo.de> - 2016-07-06 16:50 +0200
        Re: [PATCH 2/2] i2c-dev: Don't block the adapter from unregistering Viresh Kumar <viresh.kumar@linaro.org> - 2016-07-06 17:40 +0200
        Re: [PATCH 2/2] i2c-dev: Don't block the adapter from unregistering Viresh Kumar <viresh.kumar@linaro.org> - 2016-07-06 17:40 +0200
  Re: [PATCH 0/2] i2c-dev: Don't let userspace block adapter Lars-Peter Clausen <lars@metafoo.de> - 2016-07-06 16:50 +0200
    Re: [PATCH 0/2] i2c-dev: Don't let userspace block adapter Viresh Kumar <viresh.kumar@linaro.org> - 2016-07-06 17:40 +0200

csiph-web