All of lore.kernel.org
 help / color / mirror / Atom feed
From: Heiner Kallweit <hkallweit1@gmail.com>
To: Wolfram Sang <wsa+renesas@sang-engineering.com>,
	Wolfram Sang <wsa@kernel.org>, Jaroslav Kysela <perex@perex.cz>,
	Takashi Iwai <tiwai@suse.com>,
	"linux-i2c@vger.kernel.org" <linux-i2c@vger.kernel.org>,
	linux-sound@vger.kernel.org
Subject: Re: [PATCH v2 2/4] i2c: Replace list-based mechanism for handling auto-detected clients
Date: Fri, 1 Nov 2024 22:16:43 +0100	[thread overview]
Message-ID: <dc2dabd3-5b01-44ee-9365-7c52ac5ea7bd@gmail.com> (raw)
In-Reply-To: <ZySE7OqlvRRvtyLc@shikoro>

On 01.11.2024 08:36, Wolfram Sang wrote:
> Hi Heiner,
> 
> sorry for the slow response. I am on the road for two weeks now which
> doesn't leave a lot of review time.
> 
> The good (or bad?) news is that I finally found why I had the feeling of
> "something still missing" from this very interesting approach.
> 
>> -	/* Tell drivers about this removal */
>> -	mutex_lock(&core_lock);
>> -	bus_for_each_drv(&i2c_bus_type, NULL, adap,
>> -			       __process_removed_adapter);
>> -	mutex_unlock(&core_lock);
> 
> You remove using the lock here...
> 
>> -	i2c_for_each_dev(driver, __process_removed_driver);
>> +	/* Satisfy __must_check, function can't fail */
>> +	if (driver_for_each_device(&driver->driver, NULL, NULL,
> 
> ... and here, because i2c_for_each_dev() utilizes the lock as well. This
> is, you open a race window for deleting clients via removing the driver
> and removing the adapter at the "same" time.
> 
> The obvious solution is to use the lock also when removing clients in
> i2c_del_adapter(). But this needs careful thinking about potential side
> effects.
> 
After thinking twice, adding the lock here, and protecting the call to
driver_for_each_device() with the core_lock, should be sufficient.
And I don't see any potential deadlock scenarios for now.

> Makes sense so far?
> 
> All the best,
> 
>    Wolfram
> 


  parent reply	other threads:[~2024-11-01 21:16 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-22 19:45 [PATCH v2 0/4] i2c: Replace lists of special clients with flagging of such clients Heiner Kallweit
2024-08-22 19:47 ` [PATCH v2 1/4] ALSA: ppc: Remove i2c client removal hack Heiner Kallweit
2024-08-23  7:49   ` Takashi Iwai
2024-08-22 19:48 ` [PATCH v2 2/4] i2c: Replace list-based mechanism for handling auto-detected clients Heiner Kallweit
2024-10-08  8:50   ` Wolfram Sang
2024-10-08  9:20     ` Wolfram Sang
2024-11-01  7:36   ` Wolfram Sang
2024-11-01 20:45     ` Heiner Kallweit
2024-11-01 20:57       ` Wolfram Sang
2024-11-01 21:16     ` Heiner Kallweit [this message]
2024-08-22 19:48 ` [PATCH v2 3/4] i2c: Replace list-based mechanism for handling userspace-created clients Heiner Kallweit
2024-10-08  9:00   ` Wolfram Sang
2024-08-22 19:49 ` [PATCH v2 4/4] i2c: core: Remove obsolete members of i2c_adapter and i2c_client Heiner Kallweit
2024-10-08  9:00   ` Wolfram Sang
2024-10-08 10:59     ` Heiner Kallweit
2024-09-01  9:30 ` [PATCH v2 0/4] i2c: Replace lists of special clients with flagging of such clients Wolfram Sang
2024-09-01 20:08   ` Heiner Kallweit
2024-09-30 10:10   ` Heiner Kallweit
2024-09-30 10:59     ` Wolfram Sang
2024-10-08  8:43       ` Wolfram Sang
2024-10-08 11:31         ` Heiner Kallweit
2024-10-29  6:44       ` Heiner Kallweit

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=dc2dabd3-5b01-44ee-9365-7c52ac5ea7bd@gmail.com \
    --to=hkallweit1@gmail.com \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-sound@vger.kernel.org \
    --cc=perex@perex.cz \
    --cc=tiwai@suse.com \
    --cc=wsa+renesas@sang-engineering.com \
    --cc=wsa@kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.