Received: by 2002:a05:7412:3b8b:b0:fc:a2b0:25d7 with SMTP id nd11csp2973487rdb; Tue, 13 Feb 2024 03:07:27 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXdpbS7O+HX+HOy79eTYjJ1WqrPk+2984UjfSyFVul+tYVlF6tEEoTBuXEiH88MuSIlxH3HMIzMzRUZIS9YloicuF9iru0+TOLS96ZLdg== X-Google-Smtp-Source: AGHT+IFxqWYcFcKv2W0wHcJMiBEdD0EeuLY6n47lZMpw49/WGv+VmcSl/5tnCtueqJgEhEoD9o33 X-Received: by 2002:a05:620a:4ad2:b0:787:1a4c:f514 with SMTP id sq18-20020a05620a4ad200b007871a4cf514mr1606705qkn.21.1707822447492; Tue, 13 Feb 2024 03:07:27 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707822447; cv=pass; d=google.com; s=arc-20160816; b=a4p0zSAOkhv3NmH+Pf3u5EM2yujCLtPFLHmrrx8upz++4n+PwWpGLhUwTLfBdw617K bqwth/4yoHxNBxcp1jmanHFEQGZt3KqGGtDPgDTYhIMXk3QbfB3edCOMm6BCRTpYegSY nJ3pder9dQCEX26XpR3ZgWcZAOBxCRJfGXhCBCdpgPmqBz2EuE9/l5ny2M3wUKMoyTgu lO9pAARztz4f2lnqidxxxDuqnspjoyM7lNacL6sGQaFDStnM89zrX/nLYTx3v+pYwKHs n3Lh5Q0GCha+OEMBclWF+jDq4gDHWvg69Bghmx2OEKNoa/Z5KFUNDwxjwBWDtX+XSDnx 3sLA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=N/zKT384EV3fgGJG3dzF/8UMaxshsisXRkr2qLul78o=; fh=4ZuuWfluYNSW+utRLGwJP2fd8V0rPHtj6OFDiZ/7CVw=; b=M2A8AyiXgFUItcXDM/zqE29M0SUTsFsSlIun4sHhRoXK+bDIbCnZRMo9IxLTwnEbSA j1xocA72rr3OZJNgEbueu5RDqC/EEu/k/k6HdFvpM4hYC85FWaerI03CrVM6SeJxOUc6 zwCM+vmdW/2ZjvP4VYpECCo+9YuuqtKQZE0y4wcyVDKbGhw+NE2n5Mtqr8Vk8bQJMCSf PZ9nf2EfZsFuykOla6yK3keFvGyCtAgHH81Iwl9wGG0tQFAWfNVhWbgtcVqg56ovYDmA UQGWTKHGl2uKRUpJrm4ZVPO6i2+t1r29sEETboVYjae3Jl1DJoDt1Jv9Xgvf7sy8CaUP t81A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@tuxon.dev header.s=google header.b="hv8ICW/N"; arc=pass (i=1 spf=pass spfdomain=tuxon.dev dkim=pass dkdomain=tuxon.dev); spf=pass (google.com: domain of linux-kernel+bounces-63396-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-63396-linux.lists.archive=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=2; AJvYcCXPqwshat/9qrkX3IPr9WpwI61tylHlqGwdn7xI1qfn0xRE+VYzwY+S+sUutZAi3X0TgAAIdFgcOppXwsrJWtcTqyVo43/7z/FyMz7wdw== Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id dv3-20020a05620a1b8300b00785d85bad1esi4429848qkb.174.2024.02.13.03.07.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 03:07:27 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-63396-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="hv8ICW/N"; arc=pass (i=1 spf=pass spfdomain=tuxon.dev dkim=pass dkdomain=tuxon.dev); spf=pass (google.com: domain of linux-kernel+bounces-63396-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-63396-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 2067F1C21996 for ; Tue, 13 Feb 2024 11:07:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2EFFA364BE; Tue, 13 Feb 2024 11:07:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b="hv8ICW/N" Received: from mail-lj1-f174.google.com (mail-lj1-f174.google.com [209.85.208.174]) (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 309562C696 for ; Tue, 13 Feb 2024 11:07:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.174 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707822438; cv=none; b=HPHdiQ1euAn4KiHX3jVAEHcVyz+8uIhS+8O6pw23W9Yx1Dw+sAIbTM7igqGS7/Z2qdJ2fEWWFRwjd/LlzNKIjAS/c7lxeWfYQtyrGNSWJc0K0DYH8a3QL0TsILM2CH/5Bi3qHDAl05SePoWf4HUzJTepO5A+/2j6mxv7HC3KyOg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707822438; c=relaxed/simple; bh=EJiq/3eOMVN/mwk/1pTsOgbMPj5bpFavWkPJ5KumQS4=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=LPHZuj7qJisiXKDhejeKC0RAdoWZHQzKJm+g9B3gDAhPlbqbx6jCQK47L2iWnzVwMcBvLG80agbqrfiPvM7A6iG+L/f1bhCoI+VsLZqbLZkkcYVw234SKSWbf1UIw6/VPzLAP2mEpbL8HBscK9pVZMDDxmElUPFKFVBO0f/KRvI= 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=hv8ICW/N; arc=none smtp.client-ip=209.85.208.174 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-lj1-f174.google.com with SMTP id 38308e7fff4ca-2d0512f6e32so59461251fa.1 for ; Tue, 13 Feb 2024 03:07:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1707822434; x=1708427234; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=N/zKT384EV3fgGJG3dzF/8UMaxshsisXRkr2qLul78o=; b=hv8ICW/NkIjx3qpUNI1cRRb0AGtQ+v+ax2yEqx+CQvICQHbQPGGy4XJ8l5fiZooF1J i9cf25jXCM5Aygn0WIvcZ1msCZRMFccHNOfz+pGSWeRtedthqyYrYU+fN9MnlF3f22El SRqGfzlGaYkrl2L+UqJVRz0rZ4/xpyrlYaQQsN2UvmHvhTxopiWv3JUMEudD3XZbyBua 5hcg+8HiED9dZ4MBDRwYUpx5MKDtWRwzzEva0v7MR/RAiToWxVo3+ijEal6DYznKb/cP XTuC5VKQtVxSG4y9Fsr8RdpXQdKDOBEatQ1ULkkahoHtRfJMUx20oCZz11tPOsC/gq6h FONg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707822434; x=1708427234; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=N/zKT384EV3fgGJG3dzF/8UMaxshsisXRkr2qLul78o=; b=JcFqw0z7vbSNVCNllVCCufYa4tLXJID96vKAI6Jn7O+klC0RXJUnVF27og79T6Mndn zpFtnMtkXEQ8rnSMteF5NLywUNOLRcKuVenhspUy4bYBC7MFi2htPhGLv0Oh1D034v9I aLhpo6sYZ0xbxIHYFGNECryuAF/ALsKuBmXEjcZLlglZHH84hj50pzGEjMoBpeIQzyFU 4OJqKsfhUiAOycuLcqRcCa0eqKjj1aW+l0sPizGX6f4T6xsHE/rQwsN3raYA2a7xV8Np W3bkG6lyflMeVj0xqwmkdOFAxoxFhIohExIpav7R2Q2UipMawSF7Zcfdb+4yCVOVg/Ez uqUQ== X-Forwarded-Encrypted: i=1; AJvYcCVnsTED+6VqOiPcqINgA6Uc0AoesH+m9A1DbTkaiWDjv7H4C003H9LcWTw3ct8mWMnQR4G3o7ZGm8bXpHvOTMl3b0Y5JEOpFxvnEjoW X-Gm-Message-State: AOJu0YzwuuLN6YVa2z6n2XpqoBgDGj/mFW2CnBASBAxEwENr2FSBiB2a rjlC6NNtHUDfSmxXGmiAGOa7/zw/V27zjp4PCuaC5gL0nQYhLawmN1aTfXBbXQI= X-Received: by 2002:a2e:b176:0:b0:2d0:cd7c:92d0 with SMTP id a22-20020a2eb176000000b002d0cd7c92d0mr5990321ljm.32.1707822433893; Tue, 13 Feb 2024 03:07:13 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCUF6qG0rasGj9YvQl8TQEiGJwqjhnKyjTN8fknuY3sWhfCxGwjN0QTQRBgDPHA2XxaA5+jUYqowur3AzwFHCekwihPAkb4rQEWUSlNQkeKZuyltktVsFSvIpE2nJWFIJ2a10HU75CfUIkmATpuMPJKh447aZXGLtjUhh6ZSHwa2WjzJ8Vk5AnxpJ6Mq9Yh47NaWj9XK4P4nGiuUOMFhe61oHfMI2xb2B0m0NejKYecd+e+fFPMNIpOvude+NGvQvhtJ3U6kd+fdjnb7vBYKjT4HnP9tf6nMRK0i2qqdxxhz3qI6e6cHxmsNmZyZ4TrnPLaPRUmLKeLiarkVN8FYIMVHSkxWqwkOaSVPHvaZ Received: from [192.168.50.4] ([82.78.167.20]) by smtp.gmail.com with ESMTPSA id c8-20020adfef48000000b0033b47ee01f1sm9199341wrp.49.2024.02.13.03.07.12 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 13 Feb 2024 03:07:13 -0800 (PST) Message-ID: <368ca0a8-a005-4371-a959-297fd4f58cb1@tuxon.dev> Date: Tue, 13 Feb 2024 13:07:12 +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-next v3 5/6] net: ravb: Do not apply features to hardware if the interface is down Content-Language: en-US To: Biju Das , "s.shtylyov@omp.ru" , "davem@davemloft.net" , "edumazet@google.com" , "kuba@kernel.org" , "pabeni@redhat.com" Cc: "netdev@vger.kernel.org" , "linux-renesas-soc@vger.kernel.org" , "linux-kernel@vger.kernel.org" , Claudiu Beznea References: <20240213094110.853155-1-claudiu.beznea.uj@bp.renesas.com> <20240213094110.853155-6-claudiu.beznea.uj@bp.renesas.com> From: claudiu beznea In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Hi, Biju, On 13.02.2024 12:13, Biju Das wrote: > > Hi Claudiu, > >> -----Original Message----- >> From: Claudiu >> Sent: Tuesday, February 13, 2024 9:41 AM >> Subject: [PATCH net-next v3 5/6] net: ravb: Do not apply features to >> hardware if the interface is down >> >> 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 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 | 16 ++++++++++++---- >> 1 file changed, 12 insertions(+), 4 deletions(-) >> >> diff --git a/drivers/net/ethernet/renesas/ravb_main.c >> b/drivers/net/ethernet/renesas/ravb_main.c >> index b3b91783bb7a..4dd0520dea90 100644 >> --- a/drivers/net/ethernet/renesas/ravb_main.c >> +++ b/drivers/net/ethernet/renesas/ravb_main.c >> @@ -2566,15 +2566,23 @@ static int ravb_set_features(struct net_device >> *ndev, { >> struct ravb_private *priv = netdev_priv(ndev); >> const struct ravb_hw_info *info = priv->info; >> - int ret; >> + struct device *dev = &priv->pdev->dev; >> + int ret = 0; >> + >> + pm_runtime_get_noresume(dev); >> + >> + if (!pm_runtime_active(dev)) >> + goto out_set_features; > > This can be simplified, which avoids 1 goto statement and > Unnecessary ret initialization. I am leaving to you and Sergey. > > if (!pm_runtime_active(dev)) > ret = 0; > else > ret = info->set_feature(ndev, features); > > pm_runtime_put_noidle(dev); > if (ret) > goto err; > > ndev->features = features; > > err: > return ret; > I find it a bit difficult to follow this way. Thank you, Claudiu Beznea > Cheers, > Biju > >> >> ret = info->set_feature(ndev, features); >> if (ret) >> - return ret; >> + goto out_rpm_put; >> >> +out_set_features: >> ndev->features = features; >> - >> - return 0; >> +out_rpm_put: >> + pm_runtime_put_noidle(dev); >> + return ret; >> } >> >> static const struct net_device_ops ravb_netdev_ops = { >> -- >> 2.39.2 >