From patchwork Wed Feb 14 13:57:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: claudiu beznea X-Patchwork-Id: 200964 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:bc8a:b0:106:860b:bbdd with SMTP id dn10csp1229016dyb; Wed, 14 Feb 2024 06:00:44 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCX9oiK9/BT/DDbpBcfJODqgn7UtuGN65RkJvR11pbCa4MsV0W3e7iFFp+5ChSJi+6LajYugoFHkVklAmwpMTFY1ida7lw== X-Google-Smtp-Source: AGHT+IFtnZfyCpuwg1xo3YP+OpVxOHUCm3ds7y74c0FxmKa6F6d6GaqhrcDNi+3Vywg0RdRbtHWH X-Received: by 2002:ac2:46cc:0:b0:511:ab58:da2f with SMTP id p12-20020ac246cc000000b00511ab58da2fmr988941lfo.30.1707919243883; Wed, 14 Feb 2024 06:00:43 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707919243; cv=pass; d=google.com; s=arc-20160816; b=JkCub2tBFQ0Rxy2mJ8YdYxRN/oc0pEEwURP6o6TE0aA6mnIejX+AUiY1G0qL7BTaHJ Fry5yIoGsAD/CIH8WyijFK2DsVvoyDnJaOM719i79sSqTix/hjScu0BoQP430E4Qvlv6 Ly/qeEZZ7e5Fovg9llQAy1PPcblMnwBFuOWdX1XphrsJtevAhMLW//rHeSwEhYcwOSvn i/FSw4/Nq3p+b4fL/vtm9j8GzX5RjwUCaCRLmlK11zkzVe8E8mjpsq3j47F6Fc71Uth+ qlsczDTONKV9UbLwsQd8Rjm69G82c9h5l1YalRX94lY/D92nLeUBEPNeathHw4Y3/hZ8 UTSA== 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=/+KL3xYD2KV9ccdF0IlWQQ5cKlAvwz63tr09eDb/NXs=; fh=SMZeyjk11JtS0z0Jwk2UoycB6e24+cKS5NWRb6hKTxA=; b=Da8ijKbj3KqjNVu4VCmA+XlDesVj3H0FiHBOZVtFTK99IjNnzI/M5jg7UpPUAsmuNb 1tsRkI48Bat42LPLj9Rngq+aMkLkKTkVslesMSIwxJi4WysIRMOadk/oNa1wp57V5fZ4 nKC8qooe1wSirKTP04IuV/LPel+Qni4xLYw0aGc91iifT3ZbJpkQO5vBDcEkQyU6HHyz XuMB0MNcime7if+dZSAWzRob3UYWd4gv3I0mtZomYXi3jaCpAwe3CCsiMtpit+1SQuwd cJmW275/ieoNpKIb2UYswYC94HQ2rZ8FKMjSdAHIs77EfkH4GzmJgEEB3Snc6HtGIrwA tPlw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@tuxon.dev header.s=google header.b=ktj9XpNg; arc=pass (i=1 spf=pass spfdomain=tuxon.dev dkim=pass dkdomain=tuxon.dev); spf=pass (google.com: domain of linux-kernel+bounces-65307-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-65307-ouuuleilei=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=2; AJvYcCVStT8zcUbuBoYJ9P174vHK/EeGj8lFexB3ElyrNHedNono/N7B0CrOjvyw5fZgle2kWQIpFEbUvMiNIcY3kFIqpZLPug== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id h17-20020a170906261100b00a3bb8758a4dsi2158056ejc.332.2024.02.14.06.00.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 06:00:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-65307-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@tuxon.dev header.s=google header.b=ktj9XpNg; arc=pass (i=1 spf=pass spfdomain=tuxon.dev dkim=pass dkdomain=tuxon.dev); spf=pass (google.com: domain of linux-kernel+bounces-65307-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-65307-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 4D7B51F239D2 for ; Wed, 14 Feb 2024 14:00:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A896F55E40; Wed, 14 Feb 2024 13:58:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b="ktj9XpNg" 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 8A09F54FA5 for ; Wed, 14 Feb 2024 13:58:50 +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=1707919132; cv=none; b=ivO4cT3GnUbnAhIymmVyC14m2usw30DSH2Xcn4CxowEiKHAFwX2FhzpoUI49F4w+5t0dDYQBnTglqGQ6WTi/hf91ua7AUe4VfthHwohg1eSKnrILfvaDOrsFKOkYujgrcDNTQMc/JACTsrjq2HqGW+7Md5bbBDDFrxPBuihUEO8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707919132; c=relaxed/simple; bh=wnlg4QGrQEl2lf/wneDFeuxaosgd0VZwoBy1W/C0T20=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=iz4GxYr0YS7KtBOD2h097lViR9x6OEUSspNlsaKA9Ncmn1fhaqv5PaPTzbPGseeBgLcwqFCqBxjLSVajh2e33dEOX1YrXr9Urj+BYw0pyR150tnoxzbOk4Urdo0BKU84PQtekKHwnv2h7GqlcAOPqphurquDLl8C+r1hx1o/Zck= 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=ktj9XpNg; 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-33cdedb40c4so987122f8f.2 for ; Wed, 14 Feb 2024 05:58:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1707919129; x=1708523929; 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=/+KL3xYD2KV9ccdF0IlWQQ5cKlAvwz63tr09eDb/NXs=; b=ktj9XpNgG+zKVFPa8riZq10PEJvNdN1lEQrPYoU9t7274+Jz1UUKoPb5+wsby+qdOD uFD5HB+znGeDjKFbC1HCaxoB+TdFyvUC8e9ugDnuGs4UbShxRtoxE5lpmeyGB0qSc+Us CeGBKLMOApFyMpaWipp9nDzKeYiN5WNjJgkc0sL9/mZEdUxK5bYMSJdkzgksUnkyDCrR weJYEFbCAjvOUp/1CpRsPyy3xlnEOpRi1FQ83a3gD6htSnlrRDdp0PWduA2PNfhyTW0c pZnal7acnVbVO1HoMR9UZyEW7mnSBrUf5rq8b6TFro0EO0XHlu12/iTiVkERHANVgR73 jSJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707919129; x=1708523929; 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=/+KL3xYD2KV9ccdF0IlWQQ5cKlAvwz63tr09eDb/NXs=; b=rcmuJTw8r8PuqnACG5nRQeLePTwpzXlaFqT+6dBsy1ztWEaHZlvWn22d7nO42LWM5F H78xTxUq8h5FNJpXt8D90dA/fr/UxVLPNjm/E1+8Ruwc76wtyT3InFhOQNwGaMKiKHgg w3NySuFcVjsc4k0wN285uTUB8wmYzMFp9mHhr1ipAI9Ijl5AntNeWThrtaZ8FKpnZ94v 61h+wqv2IGaL+DwFeJ/2Et6IG0soM9EFwkEUtDO3FctAp8Zjbf9JUqdH4pgEQLW0fiOF E9IzJK8mWQzZqbTX0ii2Pfhnv11Q4iXd4O8iXvXuLXsF6JTCpTQlpT87yp934hJwWDMW lOPw== X-Forwarded-Encrypted: i=1; AJvYcCV+ayQJ/FhpBqSWXg48R9Fo/80G6vy9YNPmq5FjYuBl7EXfX34JRmMyNS8IhZIq+D4p3mC9gMpm/V40LmZHlXAtscnloMADTpQ7Flwb X-Gm-Message-State: AOJu0YyZtYB2PNsAO8jNmUA/PTcMuwlGbYjI1//Au+7fL2IILKOeeK7q X6IRSiVV02VAQL1zNKguIwuBu3wY5MUoO1T7tk+z9f8zPtxZ8xT9VLnM+rSkScM= X-Received: by 2002:a5d:610e:0:b0:33c:da61:471b with SMTP id v14-20020a5d610e000000b0033cda61471bmr1890825wrt.31.1707919128948; Wed, 14 Feb 2024 05:58:48 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCX727mqEx6He4qTbpcq0xxT1vuZAEHgkwTppk6XPYjW7HRb1gDNX5gfhjdDk6TqkFNRVnU1AyNW1PmaWFnYYRED0m0VVdiOfHnZ2eiYW6oIFomHh4Rbq0zWuR6bw1+RXgpyPNwy54tuc3aKmMgOBu+b+kEiL+bSMYjkLqG78jXtd7xV7rLYBkOOZtDGzkKIG6QxJmZihhCne4fCN+2Ad3Vqm4PlGDjV2hidri5mXzj9FPhJ5rwKy9ch+KeNAtFPbKj9H3FVgiRytJX778Bxi3d9d3uuyVCKhDWNdGGVTRDFuj1vSBii/lPMfgAlM3+hS+vdpUMof0bpbGM00Vc5NntwSIJ8KRsiY/zZmFK8DnzLwUD4XaSy 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.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 05:58:48 -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 4/6] net: ravb: Move the update of ndev->features to ravb_set_features() Date: Wed, 14 Feb 2024 15:57:58 +0200 Message-Id: <20240214135800.2674435-5-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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790883129451394364 X-GMAIL-MSGID: 1790883129451394364 From: Claudiu Beznea 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(). 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 Reviewed-by: Sergey Shtylyov --- Changes in v4: - remove unnecessary code - updated the patch description Changes in v3: - none; this patch is new drivers/net/ethernet/renesas/ravb_main.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c index 7a7f743a1fef..ac23779d1cc5 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -2542,7 +2542,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 +2556,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 +2564,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; + + ret = info->set_feature(ndev, features); + if (ret) + return ret; - return info->set_feature(ndev, features); + ndev->features = features; + + return 0; } static const struct net_device_ops ravb_netdev_ops = {