Received: by 2002:a05:7412:2a91:b0:fc:a2b0:25d7 with SMTP id u17csp584515rdh; Wed, 14 Feb 2024 06:02:58 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWSLZdDBlSNIdGMlTDqV/6DQqJ5WpBJpsOkguw5gQ3C71tgjUKvtdlB1+4J3QgPTUvY4aLV2azYAhIMDr3Z+8mXjHv4sHrn5Ix1OlkWhg== X-Google-Smtp-Source: AGHT+IEvwhyhIJHYcTyijweL3gyFIyLxINFlf3EB+tK0zoucZPO+k5YZVtmu5pqw7wYez9qJBXIp X-Received: by 2002:a0d:ce43:0:b0:603:fdc7:2f93 with SMTP id q64-20020a0dce43000000b00603fdc72f93mr2593660ywd.33.1707919377934; Wed, 14 Feb 2024 06:02:57 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707919377; cv=pass; d=google.com; s=arc-20160816; b=Qfdrzuw0C6o1/QC7J+D36/P0OBuDfrZRs5PMtW7EzaV/SWI7ndUuwUqEHX+zCLsYwu IPa0Mk4BnjcqruurEWrdGoB521RFlIGaptdHbdGRNsAdUNmh0RYh9uLoKrDXTLIYcVUz 85e88hDMl4DVmrV/GJLMFj/22UXz9bB+0xwTaxDHZixSQL30qzo2TUZ8YuhaRU5mjdIr EyoH824FUeKjPzz9UZC5LiUmLqVjomfFS2/dGlt/UrYZcSl4gk/sWn8fUzVngIkHWym+ rsys6Ox7QvzniAkUVCBrcy7ezola2cFdDubGK2mSknJ3Li2DtEDL+Iy0V0oiOzcS+LXZ 6hyQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=yUpbsmqd6qgdpA6pLSTrT7SxbTG5IveZrPaHGowSSOA=; fh=ncxVki9Lt/IkUR7tl6j4Ssm2+54KC2kOoxIa5UrTHSw=; b=iEFIhDtSkY8Dbp73Rfq05NN0L9lpcVNp/U8Pdkf7+A8TyGJJ7IqCrEyD4RIJy1ohSE 0xs0/89IuRjRS0W4tRJgUDRXx1C6BaOnlfObKONPsdE/lWKalk8KHkkinf1ycWB7tyw0 5Jy1POSD9NrZy/6nO1WAaJnmp1H+DH+BzwvsDEGOmQN0wBnuz/7pTPdYv8iACLoHrwdq aQPRyIgJ5WPvOqXmfS6y9VIH/epiqJRbJ17onjaJ0RCACNqZ1xXIwT4pfE9h9+F6jgqv GHPw880r8ICX7e0boHCkw/fbEGNuOEqYDIwVh5+2ErFJeR2yE/Hoqm5NmAZV9l/OZ4Rs YuYA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@tuxon.dev header.s=google header.b=MqYS4Ijb; arc=pass (i=1 spf=pass spfdomain=tuxon.dev dkim=pass dkdomain=tuxon.dev); spf=pass (google.com: domain of linux-kernel+bounces-65309-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-65309-linux.lists.archive=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=2; AJvYcCUn9GkTE+xboaJlEQnGJ2C5q6J2eORQCDH0dq8B0tGZA3yfalwa8Sgoz/doWUSzipQjA0qpSma0BemMpCDhYt5OCDR1d0Teqg7gCNPr+w== Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id bs18-20020a05690c071200b006049c0b1854si4215624ywb.364.2024.02.14.06.02.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 06:02:57 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-65309-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@tuxon.dev header.s=google header.b=MqYS4Ijb; arc=pass (i=1 spf=pass spfdomain=tuxon.dev dkim=pass dkdomain=tuxon.dev); spf=pass (google.com: domain of linux-kernel+bounces-65309-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-65309-linux.lists.archive=gmail.com@vger.kernel.org" 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 657EB1C274CA for ; Wed, 14 Feb 2024 14:00:24 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A667859B56; Wed, 14 Feb 2024 13:58:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b="MqYS4Ijb" Received: from mail-wr1-f42.google.com (mail-wr1-f42.google.com [209.85.221.42]) (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 DCF185813A for ; Wed, 14 Feb 2024 13:58:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.42 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707919133; cv=none; b=Xo7nrMHqYb2p2huyfIPqAgm1nxqg3yWVpRF/AgbuX8qZ8IOgQfFv16b6G+QJTTPLAjqr+XKOmS7eOkuyCE15E8EEjq9INpGPWZ+mq4TXea7pKRJth2QFiq3689zM1X/+OWw3KsPLLSg0Tuqt9I1k1G6JadrvGvj0t8jTymVHSuA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707919133; c=relaxed/simple; bh=rcPnG5KBmIB3G2fdjvqQyKleIdh/hUEQXg7DZEDQHKA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=hRalqDbKyygtZqP7zDsFEPJ/VA0N3+HyUEk7h+kudnM3FnDKlhdKJjyytrgeA4BywbqkwLL2ow18tMQ/M74mLCk2MU4CCXh0Fc0fdQ3UybzSKuNfhignwLCU8Lsm0L+A78TwolKTVuqJJS0AEcKoGi1PE64Y3kwl2fWJtLiy8Rk= 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=MqYS4Ijb; arc=none smtp.client-ip=209.85.221.42 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 Received: by mail-wr1-f42.google.com with SMTP id ffacd0b85a97d-33b66a7f859so2165985f8f.3 for ; Wed, 14 Feb 2024 05:58:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1707919130; x=1708523930; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=yUpbsmqd6qgdpA6pLSTrT7SxbTG5IveZrPaHGowSSOA=; b=MqYS4IjbfWEb8jRHuHI3wSkWZbM/ok8qD0atTWnExWJnZv7x/R2C+QQIUEtf43hXD7 iOb3G/shRdiQQpj/kJEihSrYv3pN0UhMOJEgSdlAF06XvlwOM/PEkNAqa1X5eK/AF29Z gnKDkmtxssOB3b8VPmU/+nGXyW6vvaqTLTeqFFqKE1xf8K3MnbT7gVaV/U6LJhNOt0SY 8+eHeZncN+HtUs1ZPpMvzLtNG8oMLZX0L20QJKYPHl1GNslxBu2kieg9nofr+4EKCccg tWZAy89pfGxKU81vuDbYp2cMlIknIwTVtMJ+fXGFIwtFzaU4tI6exYGag+kBsksdAp+U FVeA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707919130; x=1708523930; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=yUpbsmqd6qgdpA6pLSTrT7SxbTG5IveZrPaHGowSSOA=; b=b3qsbOP2HBAuuQYBKLni346cxN8oSt21SQQWGDD+fQ3ogC6NFQaT7gfrGuat6sF6tF YRAMba1OjiP/Tyx9HmjIY08jTM3wCkRskuxUnklGVZjJ968A9es4d8iGTrS3GQCCoXzn 2vUgLDB1U6Bvj997GnOzB6cOhBh1VEMCQpmBCTMFUVLu0UYK2GhefLdhzeYVMGAsDmuK Op6P4xL1yOzm2ZwUgUp2VnRcmnD2vUqj9aeKPCTzH5YmFh2pr/plwxc4ltkt3ZdrFd1l 9BrffLgnSaAJne1XWKYfv0mbT3UIeQkkiJiEEdMXicqGKTXtf3Y+UUJBBIP6lsU0oqUN mYlg== X-Forwarded-Encrypted: i=1; AJvYcCVqq9vrHIOmm9VbGH4QLbp/FaoleXaew9nSFtQum5+nUgjLX/OrFLjv53LuXa65EMJAy4tqlDgYDvUN37q1OSTnxvn3AQhQBc8M7p+s X-Gm-Message-State: AOJu0YzWd8bPF9LNLt8+aAlv84Z8qerEtzYgshZ5z+cnz+HyyIqvIQk8 lhzmQzTx7D9upHN1xr3O9ubvSy5g8rzlj2KVBkJfo1MjCydpHe98Zycn2eId7LE= X-Received: by 2002:adf:d1e6:0:b0:33c:ee7c:c433 with SMTP id g6-20020adfd1e6000000b0033cee7cc433mr1602489wrd.22.1707919130208; Wed, 14 Feb 2024 05:58:50 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCV2GDfa5HsntXhjNa5oc85h5mHyVdzd1lkbvs0rAtM9EkIBcdVPip7bn6ioIOM4tjncSIsfAFbFUrbWizDwBOpXrJ9jSCfsXC3Qq+hRXYE5dsOqMX/G6EAS2wltMCSeP17FpT4YSl5zAG3gc+ugE2HDnxifnAozbNf1SrTWJhizPrhKwjW5NnTkKkmDdnn99mw+hhQ79bUp+VHuqcjwKXg7GaWOaq8/JrreCqIx9394bRT53hw0EfzP/P879OIthzUuctr0EllTu6/FLESsv9l1ijZw5osk2wAQw7EfG0Vwbj3Cm+prWSEBh/mNW7Pbvz2S5JJV2AOhWijd4Xm2hrRuVCUh39FMvKfcBzkt6jLIrwBvNX3x Received: from claudiu-X670E-Pro-RS.. ([82.78.167.20]) by smtp.gmail.com with ESMTPSA id f15-20020adff58f000000b0033cdbebfda7sm4282140wro.14.2024.02.14.05.58.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 05:58:49 -0800 (PST) From: Claudiu X-Google-Original-From: Claudiu To: s.shtylyov@omp.ru, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, biju.das.jz@bp.renesas.com Cc: netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, claudiu.beznea@tuxon.dev, Claudiu Beznea Subject: [PATCH net-next v4 5/6] net: ravb: Do not apply features to hardware if the interface is down Date: Wed, 14 Feb 2024 15:57:59 +0200 Message-Id: <20240214135800.2674435-6-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240214135800.2674435-1-claudiu.beznea.uj@bp.renesas.com> References: <20240214135800.2674435-1-claudiu.beznea.uj@bp.renesas.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Claudiu Beznea Do not apply features to hardware if the interface is 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 will 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 features and apply them in ravb_open() through ravb_emac_init(). To avoid accessing the hardware while the interface is down pm_runtime_active() check was introduced. Along with it 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 --- Changes in v4: - simplified the code - didn't collect the Sergey's tag as the code was changed Changes in v3: - updated patch title and description - updated patch content due to patch 4/6 Changes in v2: - fixed typo in patch description - adjusted ravb_set_features_gbeth(); didn't collect the Sergey's Rb tag due to this Changes since [2]: - use pm_runtime_get_noresume() and pm_runtime_active() and updated the commit message to describe that - fixed typos - s/CSUM/checksum in patch title and description Changes in v3 of [2]: - this was patch 20/21 in v2 - fixed typos in patch description - removed code from ravb_open() - use ndev->flags & IFF_UP checks instead of netif_running() Changes in v2 of [2]: - none; this patch is new drivers/net/ethernet/renesas/ravb_main.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c index ac23779d1cc5..6f0677d1adee 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -2564,9 +2564,18 @@ static int ravb_set_features(struct net_device *ndev, { struct ravb_private *priv = netdev_priv(ndev); const struct ravb_hw_info *info = priv->info; + struct device *dev = &priv->pdev->dev; int ret; - ret = info->set_feature(ndev, features); + pm_runtime_get_noresume(dev); + + if (pm_runtime_active(dev)) + ret = info->set_feature(ndev, features); + else + ret = 0; + + pm_runtime_put_noidle(dev); + if (ret) return ret; -- 2.39.2