From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ej1-f54.google.com (mail-ej1-f54.google.com [209.85.218.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 906AA149C69 for ; Wed, 29 Jan 2025 14:36:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.54 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738161368; cv=none; b=tXyn8UxxfTwep7qJ+cAotdokiCVZZdksUTutIKWBWBbds2+AU8+VqU1n9gLcyz4ow4Quf4A6UOo7C/e16rSRz5mJOszgEXVtBCvbiv9EZdgpqVoZzmbT4IWcu32KqkhxCk8WmIMwlEDibdVhrySHUHUY2scGQ4bcnqedGlJWFoM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738161368; c=relaxed/simple; bh=UI7BF2vJZTjlFV2hITe8WmVRApBVcG3adoozoekMENs=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=gIKjjZvDKmcWiH4E9Q45ayl/DG+IH2Fj7wQsdVXYew+nMY7cckJLK/xK1IqqJgH4qA4WBh6m/ZO1kv9cIFmPZjOzzh+bHBkmlrH8PntlTp27ychhW8wI8ojOZ35PCTOqFRWUSsjkkj4cYT+PSgf4fym/JP/7Ky7WTGmnJYZhGvY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tuxon.dev; spf=pass smtp.mailfrom=tuxon.dev; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b=p8H1Xh27; arc=none smtp.client-ip=209.85.218.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tuxon.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=tuxon.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b="p8H1Xh27" Received: by mail-ej1-f54.google.com with SMTP id a640c23a62f3a-ab68a4ab074so665203066b.0 for ; Wed, 29 Jan 2025 06:36:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1738161364; x=1738766164; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:content-language:from :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=dREqLTaUkaXBI3BB09CWv/OKA4VNGyMw6wQOmVv2X1c=; b=p8H1Xh27ZMWNJzJO5Z9e2FPl/Q18txTQeEXLFeTYojb2iqDIowzNF3uudsAU/GFKxV nYmRofo9BhiHdSu8tZu4IdJPBjQt1/+tmh5KWp7/MdSZXtq55xX/WLsz9qe7SzXF4sVl rV7IPex3SW5RtY+Skk66ozPXXGuJTr6EqvqxHZxt6drMW7V+yu1iLZvXTih4Bx7l7ry7 ro2GJ7SuJRWm9Wfd063nIhTUEsad3NIsnPGNgb8d7WA2eLSsOaVLcsz4HAf71oDP7yc7 iHENb5Rs0p6MMuHDtuOqpHKyY5s595S8D2QQEgsEKAnk++L83d9vN92E+PUonBpR6H4O 09Wg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738161364; x=1738766164; h=content-transfer-encoding:in-reply-to:content-language:from :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=dREqLTaUkaXBI3BB09CWv/OKA4VNGyMw6wQOmVv2X1c=; b=dlumYaNBP5O5jV/S8irf7ik81qfr2jviiGXl4U88E7OvQvwyTeevOrtc0X9crgFwmU kbwgClgc5k53HO4aMmKLZedSoIV4mwZ85WpCsFOKqnqCWV99WG5T45ocNAT7LV6ucctF ot4lNexciX6feWz0nmfBRfWOb1CxwegrdYeSpVnaR+4Iw/Rp9XjuROAyChXvR6PE4Apb tiyErcuP2w6OqaGQQNCoXjBGojU13sBgShE/GOe29zBl8HvIvFx2usOPQeiTlhjP4gvw oDx33YAzxdLa1/Yt5gQ+L/4iybvN7ugRYAZFU5DSq4Linmjza2wDgcIOXomU9JGuEpAH SLxw== X-Forwarded-Encrypted: i=1; AJvYcCWQcd/C3Ut4tPCfB60CX0GIMMwyHM39QDjLU74YsDC7Ycnh8o7L5tFv9Gk4aSHydTa45H4azGeyi3X0fHU=@vger.kernel.org X-Gm-Message-State: AOJu0YxQCXDmziUPOiVtEypwgNaXAunsCU8X3wT4oMFVjI5Tk1wYWMZW axrbN2hm2LwDORBczWbwqmijVN0Q7sB5xG6w/XTg4g24OU06rgc6koG8tSFnuMs= X-Gm-Gg: ASbGncs0rRtcD39S1d/3jHuaFsbOPvBpYrO9Pq4UfENB9hvUKneNGR2bpdUFeou1d1r /nJovlK6n7bt7vvIhhJ8AHs6RABBQ/bBRx+Waf5sIwAae4wTtjS1TEP29RvMQHgB3RunZp5qJK2 YWCj7ht5+oDgbB+QMmfw3QuEY6v1DFeAkEfUFFTFnLgxYigpqBC4vkwblW7q4a0BaoXguBpMVDK kMfUG59MPWmSY/q2Z48IMQwfoYfxsEs4pAQvAQvZea9aKyzrLszJA1uTrWda7akwI6wHE0pHact xhNZu+XHfxp0rNAhVGPAezQ= X-Google-Smtp-Source: AGHT+IGLJBQE8tLxWwgvNgTFG/uBHrI5LPO+emzCOIWKd77Tbc+R5gOQ15j5uC93XR7lao+lO2hpTQ== X-Received: by 2002:a05:6402:34c8:b0:5d9:84ee:ff31 with SMTP id 4fb4d7f45d1cf-5dc5efa8c21mr8157746a12.3.1738161364504; Wed, 29 Jan 2025 06:36:04 -0800 (PST) Received: from [192.168.50.4] ([82.78.167.35]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-ab69a26dc94sm664205966b.166.2025.01.29.06.36.02 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 29 Jan 2025 06:36:03 -0800 (PST) Message-ID: Date: Wed, 29 Jan 2025 16:36:01 +0200 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH net v2 1/2] net: ravb: Fix missing rtnl lock in suspend path To: Kory Maincent , Paul Barker Cc: =?UTF-8?Q?Niklas_S=C3=B6derlund?= , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Mikhail Ulyanov , Sergei Shtylyov , Thomas Petazzoni , =?UTF-8?Q?Niklas_S=C3=B6derlund?= , Claudiu Beznea , netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, Sergey Shtylyov References: <20250123-fix_missing_rtnl_lock_phy_disconnect-v2-0-e6206f5508ba@bootlin.com> <20250123-fix_missing_rtnl_lock_phy_disconnect-v2-1-e6206f5508ba@bootlin.com> <20250123183358.502e8032@kmaincent-XPS-13-7390> <20250127112850.05d7769b@kmaincent-XPS-13-7390> From: Claudiu Beznea Content-Language: en-US In-Reply-To: <20250127112850.05d7769b@kmaincent-XPS-13-7390> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 27.01.2025 12:28, Kory Maincent wrote: > On Thu, 23 Jan 2025 18:33:58 +0100 > Kory Maincent 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,