[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <54d062af-40ff-47b7-baec-c7e883defea3@pengutronix.de>
Date: Tue, 22 Apr 2025 17:53:11 +0200
From: Ahmad Fatoum <a.fatoum@...gutronix.de>
To: Troy Mitchell <troymitchell988@...il.com>,
Jonathan Cameron <Jonathan.Cameron@...wei.com>
Cc: imx@...ts.linux.dev, Andi Shyti <andi.shyti@...nel.org>,
Fabio Estevam <festevam@...il.com>, Sascha Hauer <s.hauer@...gutronix.de>,
linux-kernel@...r.kernel.org, Oleksij Rempel <o.rempel@...gutronix.de>,
linux-i2c@...r.kernel.org, Pengutronix Kernel Team <kernel@...gutronix.de>,
Yongchao Jia <jyc0019@...il.com>, Shawn Guo <shawnguo@...nel.org>,
linux-arm-kernel@...ts.infradead.org
Subject: Re: [PATCH 1/2] i2c: imx: use guard to take spinlock
Hello Troy,
On 4/22/25 17:26, Troy Mitchell wrote:
> On 2025/4/22 23:12, Jonathan Cameron wrote:
>> On Mon, 21 Apr 2025 13:36:38 +0800
[snip]
>> In this path the patch changes the lock release to occur after
>> i2c_imx_master_isr(i2c_imx, status);
>>
>> That may well be safe; I have no idea! You should talk about that
>> in the patch description if it is.
> You're correct that this change slightly alters the lock release timing.
>
> However, both i2c_imx_slave_handle() and i2c_imx_master_isr() can safely be
> entered with the lock held — there's no requirement for the lock to be released
> before calling them.
Why would we want to hold a spinlock out of all things longer than
absolutely necessary?
> Using guard(spinlock_irqsave) simplifies the control flow by ensuring consistent
> and automatic unlock, which improves readability without affecting correctness.
>
> I'll update the commit message to clarify this.
Sorry, I don't think that this simplification is worth potentially
increasing the time we spend with preemption disabled,
i2c_imx_master_isr() even has a loop inside.
Guards that don't increase critical section size however are fine by me.
Thanks,
Ahmad
>
>>
>>> +
>>> return i2c_imx_master_isr(i2c_imx, status);
>>> }
>>> - spin_unlock_irqrestore(&i2c_imx->slave_lock, flags);
>>>
>>> return IRQ_NONE;
>>> }
>
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
Powered by blists - more mailing lists