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


Groups > linux.kernel > #1450167

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

From Viresh Kumar <viresh.kumar@linaro.org>
Newsgroups linux.kernel
Subject Re: [PATCH 2/2] i2c-dev: Don't block the adapter from unregistering
Date 2016-07-26 00:40 +0200
Message-ID <rYWHv-2cA-1@gated-at.bofh.it> (permalink)
References (3 earlier) <rRYEq-3A0-15@gated-at.bofh.it> <rS25k-5DG-23@gated-at.bofh.it> <rTIvw-6WO-31@gated-at.bofh.it> <rTSuR-5aQ-11@gated-at.bofh.it> <rYKwF-2SU-1@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Hi Jean,

On 25-07-16, 11:39, Jean Delvare wrote:
> The problem is that the patch proposed by Viresh has nothing to do with
> this. It's not adding notifications, just changing the time frame during
> which user-space holds a reference to the i2c (bus) device. The goal as
> I understand it is to allow *prepared* hot-unplug (in the form of
> "rmmod i2c-bus-device-driver" or sysfs-based offlining?) while

Not really. We are concerned about both prepared and Unprepared cases.

This *hacky* patch was useful in case of *unprepared* hot-unplug as well.

Here is the sequence of events:
- open() i2c device from userspace
- do some operations on the device read/write/ioctls() ..
- Module hot-unplugged (*unprepared*)
- Some of the ongoing i2c transactions may just fail, that is fine ..
- Kernel detected the interrupt about module removal and tries to
  cleanup the devices..
- Now, kernel can not remove the i2c device, unless user application
  has closed the file descriptor.

And so kernel is waiting in the driver's ->remove() callback forever.

Also, there is no way to co-ordinate (in Android) with the
Applications using the device.  They can crash or fail out if they
want to, but the kernel shouldn't stop removal of a hardware module in
that case.

> user-space processes have i2c device nodes open. Unprepared hot-unplug
> will still go wrong exactly as it goes now.

> My point is that prepared hot-unplug can already be achieved today
> without any patch.

Yeah, if we have the option of stopping the applications before the
device is gone.

> Or possibly improved by adding a notification
> mechanism. But not by changing the reference holding design.
> 
> Not only the proposed patch does not help and degrades the performance,
> but it breaks assumptions. For example, it would allow an application
> to open an i2c bus, then you remove its driver and load another i2c bus
> driver, which gets the same bus number, and now the application writes
> to a completely different I2C bus segment. The current reference model
> prevents that, on purpose.
> 
> So, again, nack from me.

Yeah, the patch wasn't great and I knew it from the beginning. But we
are looking for a solution that can be accepted and so need advice
from you guys :)

-- 
viresh

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


Thread

Re: [PATCH 2/2] i2c-dev: Don't block the adapter from unregistering Jean Delvare <jdelvare@suse.de> - 2016-07-11 14:30 +0200
  Re: [PATCH 2/2] i2c-dev: Don't block the adapter from unregistering Greg KH <gregkh@linuxfoundation.org> - 2016-07-12 01:10 +0200
    Re: [PATCH 2/2] i2c-dev: Don't block the adapter from unregistering Viresh Kumar <viresh.kumar@linaro.org> - 2016-07-18 22:30 +0200
    Re: [PATCH 2/2] i2c-dev: Don't block the adapter from unregistering Jean Delvare <jdelvare@suse.de> - 2016-07-25 11:40 +0200
      Re: [PATCH 2/2] i2c-dev: Don't block the adapter from unregistering Viresh Kumar <viresh.kumar@linaro.org> - 2016-07-26 00:40 +0200
        Re: [PATCH 2/2] i2c-dev: Don't block the adapter from unregistering Jean Delvare <jdelvare@suse.de> - 2016-07-26 09:50 +0200
          Re: [PATCH 2/2] i2c-dev: Don't block the adapter from unregistering Dmitry Torokhov <dmitry.torokhov@gmail.com> - 2016-07-26 17:20 +0200

csiph-web