[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <eb131a53-a4d3-4dcf-9e04-8dc3da84c3a6@tuxon.dev>
Date: Wed, 29 Jan 2025 16:36:01 +0200
From: Claudiu Beznea <claudiu.beznea@...on.dev>
To: Kory Maincent <kory.maincent@...tlin.com>,
Paul Barker <paul.barker.ct@...renesas.com>
Cc: Niklas Söderlund <niklas.soderlund@...natech.se>,
Andrew Lunn <andrew+netdev@...n.ch>, "David S. Miller"
<davem@...emloft.net>, Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>,
Mikhail Ulyanov <mikhail.ulyanov@...entembedded.com>,
Sergei Shtylyov <sergei.shtylyov@...entembedded.com>,
Thomas Petazzoni <thomas.petazzoni@...tlin.com>,
Niklas Söderlund <niklas.soderlund+renesas@...natech.se>,
Claudiu Beznea <claudiu.beznea.uj@...renesas.com>, netdev@...r.kernel.org,
linux-renesas-soc@...r.kernel.org, linux-kernel@...r.kernel.org,
Sergey Shtylyov <s.shtylyov@....ru>
Subject: Re: [PATCH net v2 1/2] net: ravb: Fix missing rtnl lock in suspend
path
On 27.01.2025 12:28, Kory Maincent wrote:
> On Thu, 23 Jan 2025 18:33:58 +0100
> Kory Maincent <kory.maincent@...tlin.com> wrote:
>
>>>>
>>>> @@ -3247,7 +3253,9 @@ static int ravb_resume(struct device *dev)
>>>>
>>>> /* If WoL is enabled restore the interface. */
>>>> if (priv->wol_enabled) {
>>>> + rtnl_lock();
>>>> ret = ravb_wol_restore(ndev);
>>>> + rtnl_unlock();
>>>> if (ret)
>>>> return ret;
>>>> } else {
>>>> @@ -3257,7 +3265,9 @@ static int ravb_resume(struct device *dev)
>>>> }
>>>>
>>>> /* Reopening the interface will restore the device to the working
>>>> state. */
>>>> + rtnl_lock();
>>>> ret = ravb_open(ndev);
>>>> + rtnl_unlock();
>>>> if (ret < 0)
>>>> goto out_rpm_put;
>>
>>> I don't like the multiple lock/unlock calls in each function. I think v1
>>> was better, where we take the lock once in each function and then unlock
>>> when it is no longer needed or when we're about to return.
>>
>> You will need to achieve a consensus on it with Claudiu. His point of view has
>> that the locking scheme looks complicated.
>>
>> On my side I don't have really an opinion, maybe a small preference for v1
>> which is protecting wol_enabled flag even if it is not needed.
>
> Claudiu any remarks?
Sorry for the delay. I still consider it safe as proposed (taking the lock
around the individual functions) due to the above reasons:
1/ in ravb_suspend():
- the execution just returns after ravb_wol_setup()
- there is no need to lock around runtime PM function
(pm_runtime_force_suspend()) as the execution through it reach this
driver only though the driver specific runtime PM function which is a nop
(and FMPOV it should be removed)
2/ in ravb_resume():
- locking only around ravb_wol_restore() and ravb_open() mimics what is
done when the interface is open/closed through user space; in that
scenario the ravb_close()/ravb_open() are called with rtnl_lock() held
through devinet_ioctl()
- and for the above mentioned reason there is no need to lock around
pm_runtime_force_resume()
Please follow the approach preferred by the maintainers.
Thank you,
Claudiu
> If not I will come back to the first version as asked by Paul who is the
> Maintainer of the ravb driver.
>
> Sergey have asked to remove the duplicate of the if condition.
> Paul is this ok for you?
>
> @@ -3245,19 +3250,21 @@ static int ravb_resume(struct device *dev)
> if (!netif_running(ndev))
> return 0;
>
> + rtnl_lock();
> /* If WoL is enabled restore the interface. */
> - if (priv->wol_enabled) {
> + if (priv->wol_enabled)
> ret = ravb_wol_restore(ndev);
> - if (ret)
> - return ret;
> - } else {
> + else
> ret = pm_runtime_force_resume(dev);
> - if (ret)
> - return ret;
> +
> + if (ret) {
> + rtnl_unlock();
> + return ret;
> }
>
> /* Reopening the interface will restore the device to the working
> state. */
> ret = ravb_open(ndev);
> + rtnl_unlock();
> if (ret < 0)
> goto out_rpm_put;
>
>
> Note: Sergey, I have received your mail as spam.
>
> Regards,
Powered by blists - more mailing lists