linux-tegra.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Michael Walle <mwalle@kernel.org>
To: Benjamin Bara <bbara93@gmail.com>
Cc: benjamin.bara@skidata.com, dmitry.osipenko@collabora.com,
	jonathanh@nvidia.com, lee@kernel.org, linux-i2c@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-tegra@vger.kernel.org,
	nm@ti.com, peterz@infradead.org, rafael.j.wysocki@intel.com,
	richard.leitner@linux.dev, stable@vger.kernel.org,
	treding@nvidia.com, wsa+renesas@sang-engineering.com,
	wsa@kernel.org
Subject: Re: [PATCH v7 2/5] Re: i2c: core: run atomic i2c xfer when !preemptible
Date: Wed, 03 Jan 2024 10:20:02 +0100	[thread overview]
Message-ID: <5e13f5e2da9c4f8fc0d4da2ab4b40383@kernel.org> (raw)
In-Reply-To: <CAJpcXm7W2vckakdFYiT4jssea-AzrZMsjHijfa+QpfzDVL+E3A@mail.gmail.com>

Hi Benjamin,

>> With preemption disabled, this boils down to
>>   return system_state > SYSTEM_RUNNING (&& !0)
>> 
>> and will then generate a backtrace splash on each reboot on our
>> board:
>> 
>> # reboot -f
>> [   12.687169] No atomic I2C transfer handler for 'i2c-0'
>> ...
>> [   12.806359] Call trace:
>> [   12.808793]  i2c_smbus_xfer+0x100/0x118
>> ...
>> 
>> I'm not sure if this is now the expected behavior or not. There will 
>> be
>> no backtraces, if I build a preemptible kernel, nor will there be
>> backtraces if I revert this patch.
> 
> 
> thanks for the report.
> 
> In your case, the warning comes from shutting down a regulator during
> device_shutdown(), so nothing really problematic here.

I tend to disagree. Yes it's not problematic. But from a users point of
view, you get a splash of *many* backtraces on every reboot. Btw, one
should really turn this into a WARN_ONCE(). But even in this case you
might scare users which will eventually lead to more bug reports.

> However, later in
> the "restart sequence", IRQs are disabled before the restart handlers
> are called. If the reboot handlers would rely on irq-based
> ("non-atomic") i2c transfer, they might not work properly.

I get this from a technical point of view and agree that the correct
fix is to add the atomic variant to the i2c driver, which begs the
question, if adding the atomic variant to the driver will be considered
as a Fixes patch.

Do I get it correct, that in my case the interrupts are still enabled?
Otherwise I'd have gotten this warning even before your patch, correct?
Excuse my ignorance, but when are the interrupts actually disabled
during shutdown?

>> OTOH, the driver I'm using (drivers/i2c/busses/i2c-mt65xx.c) has no
>> *_atomic(). So the warning is correct. There is also [1], which seems 
>> to
>> be the same issue I'm facing.
>> 
>> -michael
>> 
>> [1] 
>> https://lore.kernel.org/linux-i2c/13271b9b-4132-46ef-abf8-2c311967bb46@mailbox.org/
> 
> 
> I tried to implement an atomic handler for the mt65xx, but I don't have
> the respective hardware available to test it. I decided to use a 
> similar
> approach as done in drivers/i2c/busses/i2c-rk3x.c, which calls the IRQ
> handler in a while loop if an atomic xfer is requested. IMHO, this
> should work with IRQs enabled and disabled, but I am not sure if this 
> is
> the best approach...

Thanks for already looking into that. Do you want to submit it as an
actual patch? If so, you can add

Tested-by: Michael Walle <mwalle@kernel.org>

But again, it would be nice if we somehow can get rid of this huge 
splash
of backtraces on 6.7.x (I guess it's already too late 6.7).

-michael

  reply	other threads:[~2024-01-03  9:20 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-15  7:53 [PATCH v7 0/5] mfd: tps6586x: register restart handler Benjamin Bara
2023-07-15  7:53 ` [PATCH v7 1/5] kernel/reboot: emergency_restart: set correct system_state Benjamin Bara
2023-07-15  7:53 ` [PATCH v7 2/5] i2c: core: run atomic i2c xfer when !preemptible Benjamin Bara
2023-11-13  1:12   ` Chris Morgan
2023-11-13  3:46     ` Dmitry Osipenko
2023-11-13 14:54       ` Chris Morgan
2023-11-13 15:48         ` Benjamin Bara
2023-11-14 18:43           ` Chris Morgan
2023-11-15  6:00         ` Dmitry Osipenko
2024-01-02 15:03   ` [PATCH v7 2/5] " Michael Walle
2024-01-02 21:02     ` Benjamin Bara
2024-01-03  9:20       ` Michael Walle [this message]
2024-01-03 12:49         ` Benjamin Bara
2024-01-03 15:07           ` Michael Walle
2023-07-15  7:53 ` [PATCH v7 3/5] kernel/reboot: add device to sys_off_handler Benjamin Bara
2023-07-15  7:53 ` [PATCH v7 4/5] mfd: tps6586x: use devm-based power off handler Benjamin Bara
2023-07-15  7:53 ` [PATCH v7 5/5] mfd: tps6586x: register restart handler Benjamin Bara
2023-07-18  4:46   ` Dmitry Osipenko
2023-07-19  8:22     ` Benjamin Bara
2023-07-19  8:44       ` Lee Jones
2023-07-19 18:22       ` Konstantin Ryabitsev
2023-07-28 10:33 ` [PATCH v7 0/5] " Lee Jones
2023-07-28 10:34   ` Lee Jones
2023-09-07  8:20     ` Benjamin Bara
2023-09-14 10:17       ` Lee Jones
2023-09-19 14:46 ` [GIT PULL] Immutable branch between MFD, I2C and Reboot due for the v6.7 merge window Lee Jones
2023-09-19 14:58   ` 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=5e13f5e2da9c4f8fc0d4da2ab4b40383@kernel.org \
    --to=mwalle@kernel.org \
    --cc=bbara93@gmail.com \
    --cc=benjamin.bara@skidata.com \
    --cc=dmitry.osipenko@collabora.com \
    --cc=jonathanh@nvidia.com \
    --cc=lee@kernel.org \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tegra@vger.kernel.org \
    --cc=nm@ti.com \
    --cc=peterz@infradead.org \
    --cc=rafael.j.wysocki@intel.com \
    --cc=richard.leitner@linux.dev \
    --cc=stable@vger.kernel.org \
    --cc=treding@nvidia.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 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).