Received: by 2002:a05:7412:3b8b:b0:fc:a2b0:25d7 with SMTP id nd11csp1929896rdb; Sun, 11 Feb 2024 04:13:44 -0800 (PST) X-Google-Smtp-Source: AGHT+IE0xYFPvb/j4VqMuXve9kfXpOuy96Gd+r2ETR77j1Eka9scS3kyfmzn79Ao6pkBdwJIE0S7 X-Received: by 2002:a05:620a:36f6:b0:785:6e31:402 with SMTP id cz54-20020a05620a36f600b007856e310402mr7837740qkb.34.1707653624204; Sun, 11 Feb 2024 04:13:44 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707653624; cv=pass; d=google.com; s=arc-20160816; b=U6ivacC2Jw5CDVVVTJEUREGI8zhawXGXSIq171F0XZOi2av9UQ0xd+P/Z27Q6xp4nK 2Uk+T0JKyXeaplkYcLykKKp71I+remgsiT6NBjZXvmA4L+oWfz0ukC6nJDdDFbLftV/B NQ40wHqwfcMxBoMyq8HPZqupONnFu4NaZy2qohRJn9Pm/+twogzpwPNHMQgzlbudUwLX 0Q6leZvgLakeIoWgsz6pRzhmj2ne3rf7gGqv7b5lasuHXzr8ArLC8gEh2slmhEI0m8np N1HliiWvO+4HDNSaFJSVzCKuypH+voBqip1KJ3kvL/yR5LIzJvtCVRAjZ3fgE0bnPl2p czvA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=A52z+b5xLVfFrcr9zzGunwskn67khLGyF+jqlb6jF9g=; fh=Yc7XP3Yy0Z2io86p/qkoeZm92X0zEeOWdggbWhepFXA=; b=AYmyorfORjn+cfEKGlWcnzW4E54ePyYQRuVnFTDsmsvGbermWOitNoUtD/NOMMNuQk Dj6T26th/VXFPDOBPtERd7NVrHgcy6wVjv1LxOxYcQgDrwZl7+n7Xqgm8RmT7xSN9SlJ 0AdDV48Z/YVgDSvEEU0lzHxIC2Pzrj4nnVa92ZJbvXZXgwkQIfowGhUTBHr3TAe5u4gz XyR+6M4YApLU2g4ObTwzjVeIiVx+IvfBoaouRBO5yT0fEwezSllrlmqOV0gZuzImsE80 pAZjTi5OmkiT9WCpIW8HRqhAsFE+5fQekIsrtv+ctwDcss2f5/f+wmwgTsbVOdwK/1mh hCkA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=AEczxG6T; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-60724-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60724-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com X-Forwarded-Encrypted: i=2; AJvYcCW5bjziAxDHUh2p9UcF1eUNsa65I6yvWPsXkxgxdt0NWlXfTs9DKKu0NFQ17gWzOjKCr7HOaSpnwxvCGi+WDzeqn947x4EnPaWRgqovSw== Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id pe33-20020a05620a852100b00785c1c5d203si3448604qkn.183.2024.02.11.04.13.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Feb 2024 04:13:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-60724-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=AEczxG6T; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-60724-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60724-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id D3C8B1C2150A for ; Sun, 11 Feb 2024 12:13:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EB4CD5A7B1; Sun, 11 Feb 2024 12:13:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="AEczxG6T" Received: from mail-lj1-f176.google.com (mail-lj1-f176.google.com [209.85.208.176]) (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 EF41A5A119; Sun, 11 Feb 2024 12:13:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.176 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707653614; cv=none; b=JVwE39wo82HBmTg24ozEFUfOeuHkKWvlVodbyhEJg5J24AX6MCEjENVa9rsXkfLosbt4h1smAcd3885i1WAXRZRPHdH4vUCd5Wt+tvSgtBHqAAOGnF4EH3MRi4UWTJCHv808SOVgA41L1rVTqqzeIE8W8I2Mif+fvedLMv54FxE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707653614; c=relaxed/simple; bh=2Q4h2e6REYa6u2p6nmSd8judJZa1t1SDfeAWRb9SNEQ=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=qlYhFWfps/7voGmMJb9YEN5tj/WW0Y+cZNWMjIqdTypsY1fvM+cgVuyH/yZpQ7qQgI+vUealeNnBGAR527s5T2RuMY12XZIBHuAEh4xQC4VXRJF05gH/t0VdAwAbrzNwSI1Q8/+dblqqCesN2etniiQwLToSakBhB3bYCRLrLxA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=AEczxG6T; arc=none smtp.client-ip=209.85.208.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-lj1-f176.google.com with SMTP id 38308e7fff4ca-2cf1fd1cc5bso27879611fa.3; Sun, 11 Feb 2024 04:13:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707653610; x=1708258410; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=A52z+b5xLVfFrcr9zzGunwskn67khLGyF+jqlb6jF9g=; b=AEczxG6TieYMlDCr+yoy+jIrSeIUt+zeBHDapln8iR7Fp788YPUDS2qHIYNB8A/cPJ 3SVjAQS5TWt8bm6B1JtV4GuJjUGDtC0u5i/Qi98p5KPZ0U0/Oagugqg+ggvvkllC4uIJ vNw9XvzK7BeGvlmS0GeyPVO5Gk+h5eCQNPXoj7dxf59iHduOlM46FkPWfeEyNRWo2k0P +9dDrkZwRzQ0EXgIYNNBciBtXY/bsqGmzUR1/El/0Waot7bFECbr/oiM03hIOPoWxwDa 8G2gqxJVJYdr4zUEdmS/U3OPga2yjlMBSV4tV7WR1u+L2IrUZUfwhkQFRTaDgQTLYE1E T0ag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707653610; x=1708258410; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=A52z+b5xLVfFrcr9zzGunwskn67khLGyF+jqlb6jF9g=; b=BLXuH8p6ptGap79BMukPXzo8lHc4saIAwVpszLNkhAzM6MIXmRhrGWFuq9FjU/n0zW mqixRRZLL56yuthNzvXpcoGTQGefIAELU5jRlydwiPUx8eTEfshoOKYOy5GU6VeWvRFJ NBKioW4BTg64FaywEbOCwSD7n+BgJCiNUNRJY3BjzJToMfCHcHjwh6ZNW+q6ky39oWbp XfpV2wSKAxDoF8oqJc8APqpIQ6Gsadrzu+CkvpbHmrLoSd1mqt630PtJ+6FIQqKUqF61 xfpsTAWzgXmQ+65CT8Zyk3bnckcPNhGf5HUxAkqaCbxKAi7ucArPGEX1QDvzKjpDZgvo mq7w== X-Gm-Message-State: AOJu0Yy+Te/adRn2UpL6LM+XEcZySyKm/ZZzNsORvnQNaRHqwm8td/NH vcRVWVbaPnZI1kLgtJQgvqT10FaBst5iPryfX8pJJI70LZD2r3FVG0kY/iqXgbZGE8CqQFKGKac 6j9CX6DngFdt9+c8gN78IPtWQKz4= X-Received: by 2002:a05:651c:1a0f:b0:2d0:ec9c:d7d0 with SMTP id by15-20020a05651c1a0f00b002d0ec9cd7d0mr2137111ljb.46.1707653609611; Sun, 11 Feb 2024 04:13:29 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <5600b643-0d07-5583-4858-a521676476a5@gmail.com> In-Reply-To: <5600b643-0d07-5583-4858-a521676476a5@gmail.com> From: Biju Das Date: Sun, 11 Feb 2024 12:13:18 +0000 Message-ID: Subject: Re: [PATCH net-next v2 4/5] net: ravb: Do not apply RX checksum settings to hardware if the interface is down To: Sergei Shtylyov Cc: Sergey Shtylyov , Biju Das , Claudiu Beznea , claudiu.beznea@tuxon.dev, "David S. Miller" , Eric Dumazet , Jakub Kicinski , linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org, netdev@vger.kernel.org, Paolo Abeni Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi Sergey, On Sun, Feb 11, 2024 at 9:40=E2=80=AFAM Sergei Shtylyov wrote: > > On 2/11/24 11:56 AM, Biju Das wrote: > > >>>> From: Claudiu Beznea > >>>> > >>>> Do not apply the RX checksum settings to hardware if the interface i= s > >>>> down. > >>>> In case runtime PM is enabled, and while the interface is down, the = IP > >>>> will be in reset mode (as for some platforms disabling the clocks wi= ll > >>>> switch the IP to reset mode, which will lead to losing register > >>>> contents) and applying settings in reset mode is not an option. > >>>> Instead, cache the RX checksum settings and apply them in ravb_open(= ) > >>>> through ravb_emac_init(). > >>>> This has been solved by introducing pm_runtime_active() check. The > >>>> device runtime PM usage counter has been incremented to avoid > >>>> disabling the device clocks while the check is in progress (if any). > >>>> > >>>> Commit prepares for the addition of runtime PM. > >>>> > >>>> Signed-off-by: Claudiu Beznea > >>> > >>> Reviewed-by: Sergey Shtylyov > >> > >> This will do the same job, without code duplication right? > >> > >>> static int ravb_set_features(struct net_device *ndev, > >>> netdev_features_t features) > >>> { > >>> struct ravb_private *priv =3D netdev_priv(ndev); > >>> struct device *dev =3D &priv->pdev->dev; > >>> const struct ravb_hw_info *info =3D priv->info; > >>> > >>> pm_runtime_get_noresume(dev); > >>> if (!pm_runtime_active(dev)) { > >>> pm_runtime_put_noidle(dev); > >>> ndev->features =3D features; > >>> return 0; > >>> } > >>> > >>> return info->set_feature(ndev, features); > > > >> We now leak the device reference by not calling pm_runtime_put_noidle(= ) > >> after this statement... > > > > Oops. So this leak can be fixed like [1] > > > >> The approach seems sane though -- Claudiu, please consider following = it. > > > > [1] > > static int ravb_set_features(struct net_device *ndev, > > netdev_features_t features) > > { > > struct ravb_private *priv =3D netdev_priv(ndev); > > const struct ravb_hw_info *info =3D priv->info; > > struct device *dev =3D &priv->pdev->dev; > > bool pm_active; > > > > pm_runtime_get_noresume(dev); > > pm_active =3D pm_runtime_active(dev); > > pm_runtime_put_noidle(dev); > > There is no point dropping the RPM reference before we access > the regs... I don't think there is an issue in accessing register by the usage of below API's pm_runtime_get_noresume:--- Bump up runtime PM usage counter of a device. pm_runtime_active:--- Check whether or not a device is runtime-active. pm_runtime_put_noidle:--Drop runtime PM usage counter of a device. Cheers, Biju