[net-next,v3,4/6] net: ravb: Move the update of ndev->features to ravb_set_features()
Message ID | 20240213094110.853155-5-claudiu.beznea.uj@bp.renesas.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-63250-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:bc8a:b0:106:860b:bbdd with SMTP id dn10csp430249dyb; Tue, 13 Feb 2024 01:52:39 -0800 (PST) X-Google-Smtp-Source: AGHT+IGUK28J8l/2z1axhw6icKWE/iUrnnsgEOvwB0i3iMqql0QqG0crsVidTsVwO1YQFjOczd1q X-Received: by 2002:a17:903:428d:b0:1da:2128:eb16 with SMTP id ju13-20020a170903428d00b001da2128eb16mr6014463plb.3.1707817959188; Tue, 13 Feb 2024 01:52:39 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707817959; cv=pass; d=google.com; s=arc-20160816; b=R1PPpP4oIcOFjizckc0Y+ZJuchTmLpOlSDKyDy4VQvYTjk27gLaSwRdgOeibaMfh5g de4brkLgbI+Yu5QiCpQG5cD9nHfyb5/9IDc2auZLHOT1POwY6EF8rQqOgcRRmogv05G/ mTGByF6zFZ6DHylv7pMxDJGGCToTSIm1UqgiS9ZTN1xXWNorwHB//+x8DgU8VBUfWFrf lQ4v+wwYK1F3U+tCkYm23dVqGPYPlBpybrwozQTex6rZVymnQ0DbWPojA9HQYU9bE0tB juqSomJUFg8tMH3gcnzSKhI5bcz1zHTymm9eNAMD6QKIGubFX8FjoVPOknRjh8qrPXiU IgDw== 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=G3JEuLP9KTchU1G8nG9TZkkS8ubWydU8LFmKq7GO1a4=; fh=4YAf/tm+VkKmsuRdnS6DtZls7Epl8Tt4zA/EVx5vM2Q=; b=EOjXB4Z2CrLJ4kEjhpC/a02U4CuG8qiqjgIiObYuAJ+zswVD3XWB3CxjsAimXPi1eJ 2sRoxdcGsbe9HFvtY8Pa9P8b00Tbl7qeLPEzR434EdDEna0iJWgVp3TeBts6ENVLBvhH 84L+Q5A6zFB6AyKHcZ9AhOHlw4L++aBDMOTeOGapw8Yinfb6AHQCA2A/65hj/OYlgc1h bgfX1jDtjK7F6EN4lWsAqp5oRrwoWPR6UOZoVLOC5fwXvOW3HVvgjJ4xpkqgSJJkBqvc jiMDZRM/Wls7jHvFz9A2Q5FTz44kl628POiMFnBjghfZ2tqAj4zNDoInsTD3OfLwIgoP D83g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@tuxon.dev header.s=google header.b=omRoEFN+; arc=pass (i=1 spf=pass spfdomain=tuxon.dev dkim=pass dkdomain=tuxon.dev); spf=pass (google.com: domain of linux-kernel+bounces-63250-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-63250-ouuuleilei=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=2; AJvYcCVtROiFnhuoQgZ2T29ztuOVfQ7ErppzK1JqKHYyHovX3IMhwr3/ZESqvOPvgIeOCOX/Is9PSvTidLgCLm93bT9fYgkcXQ== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id j9-20020a170902da8900b001d3c375bff6si1834249plx.534.2024.02.13.01.52.38 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 01:52:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-63250-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@tuxon.dev header.s=google header.b=omRoEFN+; arc=pass (i=1 spf=pass spfdomain=tuxon.dev dkim=pass dkdomain=tuxon.dev); spf=pass (google.com: domain of linux-kernel+bounces-63250-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-63250-ouuuleilei=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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 0352B28D3B7 for <ouuuleilei@gmail.com>; Tue, 13 Feb 2024 09:48:48 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C611555C03; Tue, 13 Feb 2024 09:41:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b="omRoEFN+" Received: from mail-lf1-f44.google.com (mail-lf1-f44.google.com [209.85.167.44]) (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 BE693405D8 for <linux-kernel@vger.kernel.org>; Tue, 13 Feb 2024 09:41:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707817310; cv=none; b=k6p00F7E815FjCqGovTmYDGutBxv5v51iqZ7O+zTPGmSKcLdAH4U22IO7HqHXxMuLyduFMXsMBBUe7BlzuCzyM4B5zCid8jDclndWovb/mSsneXnxRf/CMmHv2b4nHH6PpWJjJHRBd9pZe69qhth3ylijlrFzLfonsseiUYxvMs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707817310; c=relaxed/simple; bh=EnYdAd19jAwWHKc4rTgfMXY+rwG0QS5c2MPhvFCHKqU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=uKtcn/lFju2LbWH4gC9ojrZpldUj6D4CKLhfQrl+Lyav8DVaoBf7kSAq3P7ICCsXkI3+KWQojp+lrxOZcyiALHTWOcNwCbIFwKjN1gMdCG4g4qrbdBSXWWeZKTl3uMVRzwjxeIRc5O5OK+koyUmth428n97mCV7olhdSqwqF9qc= 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=omRoEFN+; arc=none smtp.client-ip=209.85.167.44 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-lf1-f44.google.com with SMTP id 2adb3069b0e04-51183b02564so831250e87.0 for <linux-kernel@vger.kernel.org>; Tue, 13 Feb 2024 01:41:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1707817306; x=1708422106; 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=G3JEuLP9KTchU1G8nG9TZkkS8ubWydU8LFmKq7GO1a4=; b=omRoEFN+2yqeQi1bA+sjv6MlujBNCx1y1w0PZDpnguGfER1alEh5294XPfH94A9xgb Tm+dXO5nSjSoXmj+wek7QCLAf7BC94xOHsKegmk5Po6mbTJBP1pMcna8upPoOEDkPnXb h7qJwKtSF2e1jjwkqUH4M3eW+vBPJ2TWKGwM58cWe80oMO6nmF+5nScQo822q9mFdfDo kYQ4h+N3MVRWgnsrOg+v78qG+MmQxWktqg++9xHqV/IZXVz+X0UpYYrUsMOkeL3eJUlv yvNvvAZojz8RKC+I/C1okZilO7qIe7bJsUqO9vdPIlQ+tHiLpS7Jtj+Yej/4g8/VQfD6 /ugA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707817306; x=1708422106; 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=G3JEuLP9KTchU1G8nG9TZkkS8ubWydU8LFmKq7GO1a4=; b=O/mThp1r4BIf6psblgHalInErdKh2mgyW7/VsjAVY73922AWyj1exewPmUg0VwGdGz oIH7U+/Q59a635m2PDxug3BATfB5CZhbjSvXDLlgYW8ciexJ2O+ZNOMFPZdN6zRnUdFK /AA20Yp11k0QbX1ykjinF1OvvtZIbzejrVOELaNYo91JU9w0H9j8pJ7z3Z8Me6RTZpP0 O4dkdHwmBDH8niTcT8wSi23e5YHTS3NkPrUpiCNe40LKgeVkQC5e/totza9wsHnM38KK RHgi/6qYeyv3mqunHtDuUuz1tWMjVS8Z1vF6wXTiH/+uXBB3//Ov0H6DUo26Gz3+WCgP IaCg== X-Gm-Message-State: AOJu0YwBOGIoE+QCiYcH0833+OnvQtXl6ULvn+HYBAqHZIBudKV9nKHq +N+Nsn3lBaj07NXqul07hDbaQMzOfKFSfmZfGNVBCSftyZCswqBfINVC0DqXesM/IbZIreUPze+ G X-Received: by 2002:a05:6512:220a:b0:511:4860:425f with SMTP id h10-20020a056512220a00b005114860425fmr7089788lfu.17.1707817305969; Tue, 13 Feb 2024 01:41:45 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCWpx/iWNTvhbGArJHuVS+xJtVDBJufLVxr9+Tyt6q2KGYNfq+yhlLx4uiyXm+TkwpNS3CUysf3vSYXi38naHoKvPpAbowAO+P5fGxT9bSLYvJyc2DD3TiEhttCmbE8KBc7wJKnO572OFuzeYUOjhlimSuFf0GqrXJEgiArhc9yLuDp+0JdHPWq4NWaSsOYvmWsbffxfYVbeXufF1FWC853KEJtWtOe8Ds79pIp5EmPlXapnRvpvqq9lPsu/8lVDUQjTfuAkzyRj/tasWdJSoGdVUxSSl88iNy/Z+gmgQgowR565dCVCM5Pso6uekM0nVfJEgTlRIoO3l2h62QWRWL4DU6NnahABqHrID55EWnPAkXzgNfQy Received: from claudiu-X670E-Pro-RS.. ([82.78.167.20]) by smtp.gmail.com with ESMTPSA id fs20-20020a05600c3f9400b00410232ffb2csm11207446wmb.25.2024.02.13.01.41.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 01:41:45 -0800 (PST) From: Claudiu <claudiu.beznea@tuxon.dev> X-Google-Original-From: Claudiu <claudiu.beznea.uj@bp.renesas.com> 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 <claudiu.beznea.uj@bp.renesas.com> Subject: [PATCH net-next v3 4/6] net: ravb: Move the update of ndev->features to ravb_set_features() Date: Tue, 13 Feb 2024 11:41:08 +0200 Message-Id: <20240213094110.853155-5-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240213094110.853155-1-claudiu.beznea.uj@bp.renesas.com> References: <20240213094110.853155-1-claudiu.beznea.uj@bp.renesas.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790776924367446433 X-GMAIL-MSGID: 1790776924367446433 |
Series |
net: ravb: Add runtime PM support (part 2)
|
|
Commit Message
claudiu beznea
Feb. 13, 2024, 9:41 a.m. UTC
From: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com> Commit c2da9408579d ("ravb: Add Rx checksum offload support for GbEth") introduced support for setting GbEth features. With this the IP-specific features update functions update the ndev->features individually. Next commits add runtime PM support for the ravb driver. The runtime PM implementation will enable/disable the IP clocks on the ravb_open()/ravb_close() functions. Accessing the IP registers with clocks disabled blocks the system. The ravb_set_features() function could be executed when the Ethernet interface is closed so we need to ensure we don't access IP registers while the interface is down when runtime PM support will be in place. For these, move the update of ndev->features to ravb_set_features() and make the IP-specific features set function return int. In this way we update the ndev->features only when the IP-specific features set function returns success and we can avoid code duplication when introducing runtime PM registers protection. Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com> --- Changes in v3: - none; this patch is new drivers/net/ethernet/renesas/ravb_main.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-)
Comments
On 2/13/24 12:41 PM, Claudiu wrote: > From: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com> > > Commit c2da9408579d ("ravb: Add Rx checksum offload support for GbEth") > introduced support for setting GbEth features. With this the IP-specific > features update functions update the ndev->features individually. > > Next commits add runtime PM support for the ravb driver. The runtime PM > implementation will enable/disable the IP clocks on > the ravb_open()/ravb_close() functions. Accessing the IP registers with > clocks disabled blocks the system. > > The ravb_set_features() function could be executed when the Ethernet > interface is closed so we need to ensure we don't access IP registers while > the interface is down when runtime PM support will be in place. > > For these, move the update of ndev->features to ravb_set_features() and > make the IP-specific features set function return int. In this way we > update the ndev->features only when the IP-specific features set function > returns success and we can avoid code duplication when introducing > runtime PM registers protection. > > Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com> Reviewed-by: Sergey Shtylyov <s.shtylyov@omp.ru> [...] MBR, Sergey
On 2/13/24 12:41 PM, Claudiu wrote: > From: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com> > > Commit c2da9408579d ("ravb: Add Rx checksum offload support for GbEth") > introduced support for setting GbEth features. With this the IP-specific > features update functions update the ndev->features individually. > > Next commits add runtime PM support for the ravb driver. The runtime PM > implementation will enable/disable the IP clocks on > the ravb_open()/ravb_close() functions. Accessing the IP registers with > clocks disabled blocks the system. > > The ravb_set_features() function could be executed when the Ethernet > interface is closed so we need to ensure we don't access IP registers while > the interface is down when runtime PM support will be in place. > > For these, move the update of ndev->features to ravb_set_features() and > make the IP-specific features set function return int. In this way we > update the ndev->features only when the IP-specific features set function > returns success and we can avoid code duplication when introducing > runtime PM registers protection. > > Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com> [...] > diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c > index 7a7f743a1fef..b3b91783bb7a 100644 > --- a/drivers/net/ethernet/renesas/ravb_main.c > +++ b/drivers/net/ethernet/renesas/ravb_main.c > @@ -2475,7 +2475,7 @@ static int ravb_change_mtu(struct net_device *ndev, int new_mtu) > return 0; > } > > -static void ravb_set_rx_csum(struct net_device *ndev, bool enable) > +static int ravb_set_rx_csum(struct net_device *ndev, bool enable) > { > struct ravb_private *priv = netdev_priv(ndev); > unsigned long flags; > @@ -2492,6 +2492,8 @@ static void ravb_set_rx_csum(struct net_device *ndev, bool enable) > ravb_rcv_snd_enable(ndev); > > spin_unlock_irqrestore(&priv->lock, flags); > + > + return 0; > } > > static int ravb_endisable_csum_gbeth(struct net_device *ndev, enum ravb_reg reg, Wait! You're not updating the call site of ravb_set_rx_csum(), are you? It looks like the above 2 hunks aren't needed... [...] MBR, Sergey
On 2/13/24 10:36 PM, Sergey Shtylyov wrote: [...] >> From: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com> >> >> Commit c2da9408579d ("ravb: Add Rx checksum offload support for GbEth") >> introduced support for setting GbEth features. With this the IP-specific >> features update functions update the ndev->features individually. >> >> Next commits add runtime PM support for the ravb driver. The runtime PM >> implementation will enable/disable the IP clocks on >> the ravb_open()/ravb_close() functions. Accessing the IP registers with >> clocks disabled blocks the system. >> >> The ravb_set_features() function could be executed when the Ethernet >> interface is closed so we need to ensure we don't access IP registers while >> the interface is down when runtime PM support will be in place. >> >> For these, move the update of ndev->features to ravb_set_features() and >> make the IP-specific features set function return int. In this way we >> update the ndev->features only when the IP-specific features set function >> returns success and we can avoid code duplication when introducing >> runtime PM registers protection. >> >> Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com> > > Reviewed-by: Sergey Shtylyov <s.shtylyov@omp.ru> Have to withdraw this... :-/ [...] MBR, Sergey
On 13.02.2024 21:52, Sergey Shtylyov wrote: > On 2/13/24 12:41 PM, Claudiu wrote: > >> From: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com> >> >> Commit c2da9408579d ("ravb: Add Rx checksum offload support for GbEth") >> introduced support for setting GbEth features. With this the IP-specific >> features update functions update the ndev->features individually. >> >> Next commits add runtime PM support for the ravb driver. The runtime PM >> implementation will enable/disable the IP clocks on >> the ravb_open()/ravb_close() functions. Accessing the IP registers with >> clocks disabled blocks the system. >> >> The ravb_set_features() function could be executed when the Ethernet >> interface is closed so we need to ensure we don't access IP registers while >> the interface is down when runtime PM support will be in place. >> >> For these, move the update of ndev->features to ravb_set_features() and >> make the IP-specific features set function return int. In this way we >> update the ndev->features only when the IP-specific features set function >> returns success and we can avoid code duplication when introducing >> runtime PM registers protection. >> >> Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com> > [...] > >> diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c >> index 7a7f743a1fef..b3b91783bb7a 100644 >> --- a/drivers/net/ethernet/renesas/ravb_main.c >> +++ b/drivers/net/ethernet/renesas/ravb_main.c >> @@ -2475,7 +2475,7 @@ static int ravb_change_mtu(struct net_device *ndev, int new_mtu) >> return 0; >> } >> >> -static void ravb_set_rx_csum(struct net_device *ndev, bool enable) >> +static int ravb_set_rx_csum(struct net_device *ndev, bool enable) >> { >> struct ravb_private *priv = netdev_priv(ndev); >> unsigned long flags; >> @@ -2492,6 +2492,8 @@ static void ravb_set_rx_csum(struct net_device *ndev, bool enable) >> ravb_rcv_snd_enable(ndev); >> >> spin_unlock_irqrestore(&priv->lock, flags); >> + >> + return 0; >> } >> >> static int ravb_endisable_csum_gbeth(struct net_device *ndev, enum ravb_reg reg, > > Wait! You're not updating the call site of ravb_set_rx_csum(), are you? > It looks like the above 2 hunks aren't needed... A, you're right. I'll update it in the next version. Thank you, Claudiu Beznea > > [...] > > MBR, Sergey
diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c index 7a7f743a1fef..b3b91783bb7a 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -2475,7 +2475,7 @@ static int ravb_change_mtu(struct net_device *ndev, int new_mtu) return 0; } -static void ravb_set_rx_csum(struct net_device *ndev, bool enable) +static int ravb_set_rx_csum(struct net_device *ndev, bool enable) { struct ravb_private *priv = netdev_priv(ndev); unsigned long flags; @@ -2492,6 +2492,8 @@ static void ravb_set_rx_csum(struct net_device *ndev, bool enable) ravb_rcv_snd_enable(ndev); spin_unlock_irqrestore(&priv->lock, flags); + + return 0; } static int ravb_endisable_csum_gbeth(struct net_device *ndev, enum ravb_reg reg, @@ -2542,7 +2544,6 @@ static int ravb_set_features_gbeth(struct net_device *ndev, goto done; } - ndev->features = features; done: spin_unlock_irqrestore(&priv->lock, flags); @@ -2557,8 +2558,6 @@ static int ravb_set_features_rcar(struct net_device *ndev, if (changed & NETIF_F_RXCSUM) ravb_set_rx_csum(ndev, features & NETIF_F_RXCSUM); - ndev->features = features; - return 0; } @@ -2567,8 +2566,15 @@ 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; - return info->set_feature(ndev, features); + ret = info->set_feature(ndev, features); + if (ret) + return ret; + + ndev->features = features; + + return 0; } static const struct net_device_ops ravb_netdev_ops = {