All of lore.kernel.org
 help / color / mirror / Atom feed
From: Herve Codina <herve.codina@bootlin.com>
To: Heiner Kallweit <hkallweit1@gmail.com>
Cc: Wolfram Sang <wsa@kernel.org>,
	"linux-i2c@vger.kernel.org" <linux-i2c@vger.kernel.org>,
	Luca Ceresoli <luca.ceresoli@bootlin.com>,
	Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Subject: Re: [PATCH v2 RFC] i2c: Fix deadlock on adapter removal
Date: Wed, 5 Feb 2025 15:51:05 +0100	[thread overview]
Message-ID: <20250205155105.76d9633f@bootlin.com> (raw)
In-Reply-To: <72397ae6-43aa-4a15-be5e-cdfe06b2c7ea@gmail.com>

Hi Heiner,

Cc Thomas and Luca

On Wed, 5 Feb 2025 14:49:46 +0100
Heiner Kallweit <hkallweit1@gmail.com> wrote:

> i2c_del_adapter() can be called recursively if it has an i2c mux on
> the bus. This results in a deadlock.
> We use the lock to protect from parallel unregistering of clients in
> case driver and adapter are removed at the same time.
> The fix approach is based on the fact that the used iterators are
> klist-based. So it's safe to remove list elements during the iteration,
> and we don't have to acquire the core lock.
> As a result we just have to prevent that i2c_unregister_device() is
> executed in parallel for the same client. Use an atomic bit op for this
> purpose.
> 
> Fixes: 56a50667cbcf ("i2c: Replace list-based mechanism for handling auto-detected clients")
> Reported-by: Herve Codina <herve.codina@bootlin.com>
> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>

Tested on my side with the exact same command I used to report the issue
  # echo 30a40000.i2c > /sys/bus/platform/drivers/imx-i2c/unbind

The deadlock is no more present. The crash present in v1 is also no more
present.

Also I rebound the driver
  # echo 30a40000.i2c > /sys/bus/platform/drivers/imx-i2c/bind

Devices re-appeared and work correctly.
It's ok on my side, thanks for this fix!

Tested-by: Herve Codina <herve.codina@bootlin.com>

Best regards
Hervé

      reply	other threads:[~2025-02-05 14:51 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-05 13:49 [PATCH v2 RFC] i2c: Fix deadlock on adapter removal Heiner Kallweit
2025-02-05 14:51 ` Herve Codina [this message]

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=20250205155105.76d9633f@bootlin.com \
    --to=herve.codina@bootlin.com \
    --cc=hkallweit1@gmail.com \
    --cc=linux-i2c@vger.kernel.org \
    --cc=luca.ceresoli@bootlin.com \
    --cc=thomas.petazzoni@bootlin.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.