Received: by 2002:a05:7412:3b8b:b0:fc:a2b0:25d7 with SMTP id nd11csp1489135rdb; Sat, 10 Feb 2024 04:31:24 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUSs5idfFVZBcpHMsMwq80BLY2/+k5BeKWqoku51qDRbP0yho3F5mKf60MnNRYBu/qbsUGFZzdnUTKe92y6JTPZMELk7birdN30ZhLK/Q== X-Google-Smtp-Source: AGHT+IGxm7esRR8MzrVbeWgpnaaLABe2BjqRkA8gz7iKP6G21DWquwAradDAFRMSB42SjoziDY/T X-Received: by 2002:a17:906:b204:b0:a30:fba8:8fe1 with SMTP id p4-20020a170906b20400b00a30fba88fe1mr1214891ejz.21.1707568284703; Sat, 10 Feb 2024 04:31:24 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707568284; cv=pass; d=google.com; s=arc-20160816; b=HH1DqoZc1y7X+52XvEWgDn8dybFy1GNG9XlHdrnlr+PzYgyC8Hn0JGN+zoZIEarvHd JzP3fDQ6nj7YdSKjzAAPiObaRGIQLks7nJY4JuC2lzbb3FUjBloE+f8poX3U6cE5SHDk q/5vYr6NaSAojccXIqcWYaiz4b8PiBj5ficoQsthPVYAYqIIhGatXa9mbwsNW/YtWSaK dV0CO7Y8EjuCITmYPcPQ+4U1TtKLPUIkMQGFz2ENSeLAI/IXCoqERsjv4SDUV4GAiuH9 VGVtwIBRAdNWFsJEhEpVnMSlccxQVygPs0rZLr2UMvKRLafseP947Q6WSQpkTJgZ7rII KyLw== 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=geEctI3jAWOmh+DPS0zOGyuq69MDOHJs/LeL0ZEzs9E=; fh=MOWIIvGEOt6wYV7NbiFPyOnByLNJU+F8BwtcJ0sqqUU=; b=l4lso4dHgu55TaAugJxz8uFwZIzM7xjgQ7auAvlKZCezl+UEwNfD8eqjzdG9XKfAgW o6lHNHykl19OgVtbi2BDeX5N3zxK4lawN7KRGoCBxZ4SUdpbn6SC4pPrT30ZGhp7u1SD mQgq0F7pP1Z5FSNIn9NWg7a3hwy2j1/n203UcyD5+jhfA+AV4biWO+XHfWqs5vGZazqD 8TUcYD9WdNQhJhOABTuq2ToU95hfVyODCGxr2SgRjRujvSsRKltvzjIRYF2fCc7VqrJo iHGBrfi0CVA9T96O/lPfkH9W3fxG6BaRINi2Zjun3DNEZWXK9e5qQI8FsCnrCkqBkciO gx9w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@tuxon.dev header.s=google header.b=I9VR92yd; arc=pass (i=1 spf=pass spfdomain=tuxon.dev dkim=pass dkdomain=tuxon.dev); spf=pass (google.com: domain of linux-kernel+bounces-59698-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-59698-linux.lists.archive=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=2; AJvYcCXxuUh7yhV+psiHrEKFkLN8b0rtrgnHGbr+YekiGYX/wQt8ctxqZwI0rluZSRTGj59erxtbV6PuJiN6srZ7aIqfshBiM2b/CQtuBy9Bnw== Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id gt42-20020a1709072daa00b00a385d349c38si2033696ejc.872.2024.02.10.04.31.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Feb 2024 04:31:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-59698-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@tuxon.dev header.s=google header.b=I9VR92yd; arc=pass (i=1 spf=pass spfdomain=tuxon.dev dkim=pass dkdomain=tuxon.dev); spf=pass (google.com: domain of linux-kernel+bounces-59698-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-59698-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 1BCA11F29514 for ; Fri, 9 Feb 2024 17:06:46 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5C0B084A3E; Fri, 9 Feb 2024 17:05:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b="I9VR92yd" Received: from mail-wm1-f51.google.com (mail-wm1-f51.google.com [209.85.128.51]) (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 8C7D380BF6 for ; Fri, 9 Feb 2024 17:05:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.51 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707498315; cv=none; b=hipyd+ZfAWqaV6kenBJPkCBgn17Si/ohgV9NR2IYylTn1k2GqOt27/Fb+4ZOdZwcSGiD56kiQx3ax66GJ8NVIN2Du+za3sBQJdQC17ZAS79povO/u+F+cK1Iwv8VY/cnoUcMGqptYlKqRPMP91MvvmxiM71L/rOr9fDdkNWU9to= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707498315; c=relaxed/simple; bh=Iko31EmtrFT0a0Vf7Lv+AOwIvZiu4+osFAFWG89yDtU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=N2qA8yD4hjsCGW/1a2Cv+4bHIdSY16hLqGCw91RRUEtawvbaTc0/TqRqzseMVWrBWtoKdfw1vlzDgzl2PYTAkt2sImEtmKSivIkjMotRGq4EumgX8B8dRvmwQt5xyTXCHv5wnCg5vM42Tc7vXrerCJolnfTjYjYFkE0fS8w2jCU= 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=I9VR92yd; arc=none smtp.client-ip=209.85.128.51 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-wm1-f51.google.com with SMTP id 5b1f17b1804b1-4103be6e938so10345655e9.0 for ; Fri, 09 Feb 2024 09:05:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1707498312; x=1708103112; 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=geEctI3jAWOmh+DPS0zOGyuq69MDOHJs/LeL0ZEzs9E=; b=I9VR92ydaA20CdS51Qgnext83aZTOe3U2NoX0yS4OvQsyBSUbhcO4YvVDBm5HgtOdD XjPHT5HVsoJS5AKxawVlA1EvsZL3E2pp93y7tePxM9G4vNUwGARBbK/P4UkUJ0opX0ML Ciea5qDDT+DHGAvsEftOG4Ey4XaVmLGiAJODOMeHIY861AtTQNAIWOtzxxSHbu0yg/wG V6tQL65SxbJGlIVeHYFCvlK0Kd89fLyrhV48Li/10uANwXUfYInw0fermDHXdIxKmQ54 lnkd8z5VqqUKZT9x5ytU6+nwpnwDHKuj1A+RTGGpARY7ZAtm3bS4c/5W/j5YDWFjlECw QhTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707498312; x=1708103112; 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=geEctI3jAWOmh+DPS0zOGyuq69MDOHJs/LeL0ZEzs9E=; b=lbz/LGKRSGB3IlD0YhMcgp0CoPnsFE3Tr8JdFMh0Ooyvi8Be/kovN2+tokw3pTLDgI qB1QJJ19PxASwg/9Aa18d3n5VfwBa7NkC2jGATCPAJ5yAJxcyJHRoTUN/uBgNQaDOcCW EZ8YTUJZR/bZXn8cWIx8DQsvrh4eIzgFZJxxSzw+9YzS2O8wlpYk8e6A7bf8itmjbWPZ HT2Gf/RO4BnH4YiUBUgTCyPVPMuGyiUKtlxDR3jYtemSt3RCy9HCKCmnk5n7KKGP9ix7 PWatrElsMprCyXZuZQkKkMe2sB1NizhiYSba2aS2wnkJQxF1iLfdZCnHaXBSsf/kpWHR 30zg== X-Forwarded-Encrypted: i=1; AJvYcCXxbGM+j1AnxJ9N2EmSC/8JUUDs7Ix+2GAjebhouj/FGZ2EpU5Bw00SAhpiMohO+r2pHs6OkuLd35M7TuEaYl5pi0z6jRJkCdOGwXZs X-Gm-Message-State: AOJu0YzMYC/v3hTrypYIyMgxhSvFQK3LHeId6CAdWD0t6cBpbJQEDoEj MR2gWQk/yuJsOxr1JOF6PrjOdymaozsBIanXk4qbDsVAoCbca0WErx57lfGXZNE= X-Received: by 2002:adf:e743:0:b0:33b:4967:4d2 with SMTP id c3-20020adfe743000000b0033b496704d2mr1660714wrn.41.1707498311891; Fri, 09 Feb 2024 09:05:11 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCUd8zxXd0rM6pvBlpP/uV/+a8KGsTugrcQTnPU4iOwRPDgTMDAa9tUnAZGrems6xZZ1MgjrXeqNQh++MB+vh28kJkD4F03MObu2ymt5Rl1XXTk2Rf8h+3OiJEn7Y4rrw8hh6QoeUdn3K5LiEVzs+e7zlfCczdcTo+5FkiTsj/fZmCBiykEyMHl5R/8bAfL7ao1lkUVcItUaX15yB10h/Xllg2YuTBEAy5x+LSln8bpxbnj9adz9oBR2G1vyrZtDtfFdoY2X3fiadO3vxQ+cFfUZP/EiaQGIC/kPI88aeqvT0092AefdS8b514en7xkWQXhwxjAbKYKnb2U= Received: from claudiu-X670E-Pro-RS.. ([82.78.167.20]) by smtp.gmail.com with ESMTPSA id j18-20020a056000125200b0033afe816977sm2254998wrx.66.2024.02.09.09.05.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Feb 2024 09:05:11 -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 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 v2 4/5] net: ravb: Do not apply RX checksum settings to hardware if the interface is down Date: Fri, 9 Feb 2024 19:04:58 +0200 Message-Id: <20240209170459.4143861-5-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240209170459.4143861-1-claudiu.beznea.uj@bp.renesas.com> References: <20240209170459.4143861-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 the RX checksum settings 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 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 --- 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 [2] https://lore.kernel.org/all/20240105082339.1468817-1-claudiu.beznea.uj@bp.renesas.com/ drivers/net/ethernet/renesas/ravb_main.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c index 7a7f743a1fef..f4be08f0198d 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -2478,8 +2478,14 @@ static int ravb_change_mtu(struct net_device *ndev, int new_mtu) static void ravb_set_rx_csum(struct net_device *ndev, bool enable) { struct ravb_private *priv = netdev_priv(ndev); + struct device *dev = &priv->pdev->dev; unsigned long flags; + pm_runtime_get_noresume(dev); + + if (!pm_runtime_active(dev)) + goto out_rpm_put; + spin_lock_irqsave(&priv->lock, flags); /* Disable TX and RX */ @@ -2492,6 +2498,9 @@ static void ravb_set_rx_csum(struct net_device *ndev, bool enable) ravb_rcv_snd_enable(ndev); spin_unlock_irqrestore(&priv->lock, flags); + +out_rpm_put: + pm_runtime_put_noidle(dev); } static int ravb_endisable_csum_gbeth(struct net_device *ndev, enum ravb_reg reg, @@ -2515,10 +2524,16 @@ static int ravb_set_features_gbeth(struct net_device *ndev, { netdev_features_t changed = ndev->features ^ features; struct ravb_private *priv = netdev_priv(ndev); + struct device *dev = &priv->pdev->dev; unsigned long flags; int ret = 0; u32 val; + pm_runtime_get_noresume(dev); + + if (!pm_runtime_active(dev)) + goto out_rpm_put; + spin_lock_irqsave(&priv->lock, flags); if (changed & NETIF_F_RXCSUM) { if (features & NETIF_F_RXCSUM) @@ -2542,9 +2557,12 @@ static int ravb_set_features_gbeth(struct net_device *ndev, goto done; } - ndev->features = features; done: spin_unlock_irqrestore(&priv->lock, flags); +out_rpm_put: + pm_runtime_put_noidle(dev); + if (!ret) + ndev->features = features; return ret; } -- 2.39.2