From patchwork Tue Feb 13 09:41:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: claudiu beznea X-Patchwork-Id: 13554853 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-lf1-f47.google.com (mail-lf1-f47.google.com [209.85.167.47]) (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 671F938F88 for ; Tue, 13 Feb 2024 09:41:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707817307; cv=none; b=jQ1aB/ia3X5FcyMGtIJSUes7iBrTSav15la+qmNfxROxoNVZiuog4H00zVQpePbSTzzXBvCdQbhv0b0KiDiX9oOYZQ4p3QKcp5vE4OyITWySyyjhsvSW6EG+IPs/0ZGlNRNtuubaFrnEXLkqx/LXX3uotc4h/fq8uYPu6S5Cdpg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707817307; c=relaxed/simple; bh=L6m3PaHcpH7fTAmCpzJxhaBYogFtv5x2tXcok6WfMQo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=fGMK3LHcQEwzvsf6gbS35EkwE4SrTbHzmTJRE9wMDO/tRCI4Aikn3XskzGnd/te5JsLcCGWD/U0qMrXBPkEj2LpVnmOIdfGtO3t8NWNIyeUxyfq7NYVqDAyZsTJV+Gt7uieTVe4Gf4uWBeh9KKZXAYqKMjdunD7Ra3gEq1LjIc0= 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=mrKxNdLb; arc=none smtp.client-ip=209.85.167.47 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b="mrKxNdLb" Received: by mail-lf1-f47.google.com with SMTP id 2adb3069b0e04-5116b540163so6022631e87.1 for ; Tue, 13 Feb 2024 01:41:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1707817302; x=1708422102; 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=TTm27U9imY+diMQ+Cfy3KOx1XX4gyrrNl9Sty+DsGIw=; b=mrKxNdLb7i/l8a7tAAHtIRj/hsQhCoC15dts+sckLCqVwww+GCWFFwJWi+5xc7pKQn dp5SVHdRVA5WthHAuGx+CAHS34vOSFJjmVCBP6w98spy0duaDIawq3RWeZztc8oDU/5P T0uOUdgzwkG3+XX09OFswYBbgwoIzRH6eb+CtlBYDA7N7pluOG2thJWZwHhZL8QQpKjz LJs6tXeyo7+4F24n3fshfGl8AJNTWb5wgd8+Lr0hxVvmXuO0uNI5S9DLAKEF008eIZ0l qRSIVT3hHpOBbsdcFlYJl3UE6wCmljeok1XZXGGY3kQvX8Yef3O1sUi1RD284Gv8sKNb pjCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707817302; x=1708422102; 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=TTm27U9imY+diMQ+Cfy3KOx1XX4gyrrNl9Sty+DsGIw=; b=G71vTLNkRHKAr2fSgxQLdvQjeeewOelm/cZri3OZFG6rdxvH622FPohVi7z3ohYz5U ys9g3DdDqfGcHbBoyIUXprOsOAUo3BUYrMF8aAqRMBUNffZGWCHBnpNXG0waxS/TxgDD /5/b01UiAZ9Bg4Im1BTiWNdEGVgJRc4v5EF+YRF6HHFHmPgM8m4HCNUIgxUfZ7UBOkss HgV0AzfHBS519bY6WXwLOKF7qGxMZmGiS5zKyNp1inZp16C9ESlzirKb3HHaZVICxFfA 9LNJipXom4fpGO9Lf+ck1JUoRdHBjh0siPaKs9LMi/sL+6IU11+Nw0TG/O3m3OzZWEaq bhRw== X-Gm-Message-State: AOJu0YxFn4dY7EruRYfnLxMmZTdSNI4yCquL0aFcmC+mOcKMjL5FyNi9 ftYmiTUD+35wummZHXxbNVEJPx4vq9uB6NNRa4CHpqZDYvqgkzjcPpcHYQ3jTtA= X-Google-Smtp-Source: AGHT+IE6D7Ce4N4r0UsSCIlgDzqSmtZZx+1V8jIgoXg7ggocUWeATBSiw36gJjy8YajyPEN0PECjuA== X-Received: by 2002:a05:6512:33cc:b0:511:75e2:6b5e with SMTP id d12-20020a05651233cc00b0051175e26b5emr7171150lfg.36.1707817302073; Tue, 13 Feb 2024 01:41:42 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCXjyHUR8jchFQdRr8F1L8nPt1dQno6MxmexiRb08RAy4xTMgBKVPT3usunHLtuz/wIcTmSdf3AAEbXhvyljapHU2VeLsXWN4mwuF8zL32zg7nsgUu0oAGPS1iHB964cw74Q4aj4xX0cEkjQlHTvMr6QQobIrIDRU2gwhyJRY1S4naFO40Rk/uaqEwagRzYbXR91NI3NTUtu5g4E5jNL2VcbPMRopQFamz1Ybeqh/pCZPgkPFjvor3cadv9sbJqNUaCuk3G0AzIVyDdJSeFHQB12+AIbPFrWUROzC2ZiowVgjllxtJ2rGMlncepbeZHw6XswzBg4qUfvwLZ/3WDzSXqT/mdUzWzTvCcHDCzeeOxNiMkNesQi 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.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 01:41:41 -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 v3 1/6] net: ravb: Get rid of the temporary variable irq Date: Tue, 13 Feb 2024 11:41:05 +0200 Message-Id: <20240213094110.853155-2-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: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org From: Claudiu Beznea The 4th argument of ravb_setup_irq() is used to save the IRQ number that will be further used by the driver code. Not all ravb_setup_irqs() calls need to save the IRQ number. The previous code used to pass a dummy variable as the 4th argument in case the IRQ is not needed for further usage. That is not necessary as the code from ravb_setup_irq() can detect by itself if the IRQ needs to be saved. Thus, get rid of the code that is not needed. Reported-by: Sergey Shtylyov Signed-off-by: Claudiu Beznea Reviewed-by: Sergey Shtylyov --- Changes in v3: - collected tag Changes in v2: - use a temporary variable in ravb_setup_irq() Changes since [2]: - this patch in new [2] https://lore.kernel.org/all/20240105082339.1468817-1-claudiu.beznea.uj@bp.renesas.com/ drivers/net/ethernet/renesas/ravb_main.c | 29 +++++++++++++----------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c index f9a1e9038dbf..a1bf54de0e4c 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -2747,24 +2747,27 @@ static int ravb_setup_irq(struct ravb_private *priv, const char *irq_name, struct device *dev = &pdev->dev; const char *dev_name; unsigned long flags; - int error; + int error, irq_num; if (irq_name) { dev_name = devm_kasprintf(dev, GFP_KERNEL, "%s:%s", ndev->name, ch); if (!dev_name) return -ENOMEM; - *irq = platform_get_irq_byname(pdev, irq_name); + irq_num = platform_get_irq_byname(pdev, irq_name); flags = 0; } else { dev_name = ndev->name; - *irq = platform_get_irq(pdev, 0); + irq_num = platform_get_irq(pdev, 0); flags = IRQF_SHARED; } - if (*irq < 0) - return *irq; + if (irq_num < 0) + return irq_num; + + if (irq) + *irq = irq_num; - error = devm_request_irq(dev, *irq, handler, flags, dev_name, ndev); + error = devm_request_irq(dev, irq_num, handler, flags, dev_name, ndev); if (error) netdev_err(ndev, "cannot request IRQ %s\n", dev_name); @@ -2776,7 +2779,7 @@ static int ravb_setup_irqs(struct ravb_private *priv) const struct ravb_hw_info *info = priv->info; struct net_device *ndev = priv->ndev; const char *irq_name, *emac_irq_name; - int error, irq; + int error; if (!info->multi_irqs) return ravb_setup_irq(priv, NULL, NULL, &ndev->irq, ravb_interrupt); @@ -2799,28 +2802,28 @@ static int ravb_setup_irqs(struct ravb_private *priv) return error; if (info->err_mgmt_irqs) { - error = ravb_setup_irq(priv, "err_a", "err_a", &irq, ravb_multi_interrupt); + error = ravb_setup_irq(priv, "err_a", "err_a", NULL, ravb_multi_interrupt); if (error) return error; - error = ravb_setup_irq(priv, "mgmt_a", "mgmt_a", &irq, ravb_multi_interrupt); + error = ravb_setup_irq(priv, "mgmt_a", "mgmt_a", NULL, ravb_multi_interrupt); if (error) return error; } - error = ravb_setup_irq(priv, "ch0", "ch0:rx_be", &irq, ravb_be_interrupt); + error = ravb_setup_irq(priv, "ch0", "ch0:rx_be", NULL, ravb_be_interrupt); if (error) return error; - error = ravb_setup_irq(priv, "ch1", "ch1:rx_nc", &irq, ravb_nc_interrupt); + error = ravb_setup_irq(priv, "ch1", "ch1:rx_nc", NULL, ravb_nc_interrupt); if (error) return error; - error = ravb_setup_irq(priv, "ch18", "ch18:tx_be", &irq, ravb_be_interrupt); + error = ravb_setup_irq(priv, "ch18", "ch18:tx_be", NULL, ravb_be_interrupt); if (error) return error; - return ravb_setup_irq(priv, "ch19", "ch19:tx_nc", &irq, ravb_nc_interrupt); + return ravb_setup_irq(priv, "ch19", "ch19:tx_nc", NULL, ravb_nc_interrupt); } static int ravb_probe(struct platform_device *pdev) From patchwork Tue Feb 13 09:41:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: claudiu beznea X-Patchwork-Id: 13554852 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-lf1-f42.google.com (mail-lf1-f42.google.com [209.85.167.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 443E439AD0 for ; Tue, 13 Feb 2024 09:41:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707817307; cv=none; b=oae82GIH+JuuXFSslLLEsHAIKzwud4cgO0hp7c5P9CHeHP5ananiYfwaQUDC9u0yo/Hh6MNNQDhQkYBQmjmnWcGHZB+x547u3+ImZCzTjLdrCFpdGZh7C6mlN71dHYsOpqN33Ga53zMoxuM3Bej07hyQihSx0q9+POJ5R+S12Dk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707817307; c=relaxed/simple; bh=enmy+LoY5r8g/P1HcJj+4PzEb3nLIvXmdJEA1A5e1ZY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=pzMidNP4T3wQ60YAIVSHU/YdslatKZaDoA0CSlD86xHBynCwemjedeLW+pffVkx6r4SP660CDP1b/cwH3ajYmuzlg30KsVxnpkhzna9+BVxY/2pIzfAV0pQhiKljYRBmTZ6qapMIt0Wo1L7+Wr/UUwaiA0nUnUxP9XNfDOl0uLI= 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=KJfPgRHL; arc=none smtp.client-ip=209.85.167.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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b="KJfPgRHL" Received: by mail-lf1-f42.google.com with SMTP id 2adb3069b0e04-5118d65cf9cso2338901e87.0 for ; Tue, 13 Feb 2024 01:41:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1707817303; x=1708422103; 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=aAa50mXZbPqqgphxhzpCHoCd19uwy4xnnSSFW1+XwKE=; b=KJfPgRHLm9Eq94KaPzNNmX+TEPHUXD96exrxaHIMiQrUYOXbxmZa2eY58kj0aQ35EU X+uKVtSHqqW0St7ruKV8XAL5bR+lY4EBPNM8rh0J7R9fUM53YwoKDnk5Jr5zm6UFyedY VYY43gxGBsCQ10CC1njy2L6xRdR4gaQzrVEu4ssnSzhw3GLF3xYOZnUXnMywj7HjfkKG QCbPjakxCPXdDJzwTEqkyM40+5kKyCajfn2Agrcm+3JCTt50xSlzsRc3eNVLG23XM8iu nRKCaVJQghoEcUFLDDobCzPAg0lYUt5n7g3mh0nPrIE81eLVhUKVSnHfId41pKC+0fEM 1LmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707817303; x=1708422103; 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=aAa50mXZbPqqgphxhzpCHoCd19uwy4xnnSSFW1+XwKE=; b=l87wJ16HWRoQueZ5MB9+w7tUYqJqUblA4taeGNoqE230eAhLpfOvbNdWRNmaf2j88X V8GvyJHpV51tIIpz8Iu4PfhGSkk/HyAmcdHvTAfdG2xguz9a8vAuBdOpaK5oq23OFcnA Oy1EdBo94pvf4XDY8SrsDUNXGyMgUNzVXzs3yL9k4IjkmDqvxoIkZcQIB9oVdczUan7J ZxdiCbaUOtZrp437ikAPkYmOv/HB0AlnsKa601Cs36uVKRNlrVibg+bfKNUbnmQ2Twal oRS/ocA/5CtcHBbowZHlk6xRJfPF3qxTUUi0QxiaEUNlys+dLQiAek0fehNds5WoJZRV X8Tw== X-Gm-Message-State: AOJu0Yxa6rH5ddsec+GusPQQIVbFoVBGphY9Fi6xWMTvcPAjQ0YmMbiN RITjScopioqVZGs2E7YY458drEwu1Xpd9h/+vVX247fq5MEMCq/PEctJubrzX7E= X-Google-Smtp-Source: AGHT+IGNd5nHQ/HEfCk+VJ7X1s78HVrWAJaGoFhdToWwxTcZsZJ12WqoGmgoQqhHUWtI+Wr1HyAvVQ== X-Received: by 2002:a05:6512:49e:b0:511:4ee3:dc0f with SMTP id v30-20020a056512049e00b005114ee3dc0fmr5561325lfq.19.1707817303330; Tue, 13 Feb 2024 01:41:43 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCW69Al/3XiflcXDZn21jWBYjJTg/9YKAkSVPu7lcjXWsEFj22RQh8x78vO7ZDXQ2jbkrOg2+H2Jh5cJoPHYHc1gWmn2Fmy3w0baKaxs1oaLpab7PQLXyv8vthemHmcCWqIGDr6FF6lBFIb7DvWYESwnS1UNT00GA0k9KBsTi6QWmNOH9CFVFt8X8RT/jDoJ6Q8jfZ36yOJ5r+EJ47XzX4aW/ykfx3Y3TirLNuMe7uraNmJIN25disnVBZUpPUtbIqOlHes6vKvSHqoTIfkRlMq9GqFaPyD/D2+69D7wmqp1/2Oc9SG4LcLI5lpESA+o9VHA7gYHgo12c+jW3DzcQNrbPsomBPmgT3cZHDH32ar0o5soRVXm 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.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 01:41:42 -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 v3 2/6] net: ravb: Keep the reverse order of operations in ravb_close() Date: Tue, 13 Feb 2024 11:41:06 +0200 Message-Id: <20240213094110.853155-3-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: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org From: Claudiu Beznea Keep the reverse order of operations in ravb_close() when compared with ravb_open(). This is the recommended configuration sequence. Signed-off-by: Claudiu Beznea Reviewed-by: Sergey Shtylyov --- Changes in v3: - none Changes in v2: - none Changes since [2]: - none Changes in v3 of [2]: - fixed typos in patch description - collected tags 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 | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c index a1bf54de0e4c..c81cbd81826e 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -2321,6 +2321,14 @@ static int ravb_close(struct net_device *ndev) ravb_write(ndev, 0, RIC2); ravb_write(ndev, 0, TIC); + /* PHY disconnect */ + if (ndev->phydev) { + phy_stop(ndev->phydev); + phy_disconnect(ndev->phydev); + if (of_phy_is_fixed_link(np)) + of_phy_deregister_fixed_link(np); + } + /* Stop PTP Clock driver */ if (info->gptp || info->ccc_gac) ravb_ptp_stop(ndev); @@ -2339,14 +2347,6 @@ static int ravb_close(struct net_device *ndev) } } - /* PHY disconnect */ - if (ndev->phydev) { - phy_stop(ndev->phydev); - phy_disconnect(ndev->phydev); - if (of_phy_is_fixed_link(np)) - of_phy_deregister_fixed_link(np); - } - cancel_work_sync(&priv->work); if (info->nc_queues) From patchwork Tue Feb 13 09:41:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: claudiu beznea X-Patchwork-Id: 13554855 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-lj1-f175.google.com (mail-lj1-f175.google.com [209.85.208.175]) (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 771C63D396 for ; Tue, 13 Feb 2024 09:41:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707817309; cv=none; b=IzQoIgMkoLOOVexaGNGLpWmgu//QYhHw//pd788pZOFLNEEDLb0Dc5pImxL9VODZGNFFZeEJw/iXPmN//TGp9ysT9KTjHA88hyLx6V7/tc0ZfiGu1t2ZRI9i4tpuiLQwftaQmdNJtKkEu7SwOJBaAOmDLqumgn+Ig17hFyR3aAg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707817309; c=relaxed/simple; bh=+cx7uCdIjjcdxImi5aLciGuFRrSNN2LcXONA1R9FXrA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=JZrow7WK2e/yArmJecofCePjRUvPsk1YOJipxOESDBgwTRwd+vo8W0qdkA914Rm0NwuyU0pQp4bei8j1WzVHhvz2emyRVKqbSvOmjv0wIlpgFFZodxmH/WWUK7nOAATs5PuH/IDI90mpx8bPPg4vbjHw2htUYXpzYYKyNU0PQGA= 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=mxbfYbLX; arc=none smtp.client-ip=209.85.208.175 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b="mxbfYbLX" Received: by mail-lj1-f175.google.com with SMTP id 38308e7fff4ca-2d0e2adfeefso41947401fa.2 for ; Tue, 13 Feb 2024 01:41:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1707817304; x=1708422104; 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=1DX0f87HSAsoENN6G92H3MYTw5gEFb3bGk/lETsw33o=; b=mxbfYbLXXtNT9LjfEXoo/+BtQu2YTI7bS0BQ3UW207yfiZ0Ts+t8Vg+byrqg6mPtwq wden/ywycgIJAAcppIH1G2UC1qTAx19GIdXEBKsVnL88co2oZXjGHh3j6QQ7W1EN1nlp cOKqt072aoX82qS8mMTuNoOtQlIySo4fCvbgFSEcAezXXqiyAUmgo4L57Jm2144PKFkF fMPBNWmjRuZ8rCZrUrzOKOqxFwK19vFf1nD1OyJV/P7Vfg7YYIlpqhsy20sV9MHCVlj5 SFujz8+sM/SqRf4c9VsYnekUFuoCa4sitD22/s4rWR3UXvW/75PujdYueAfWa1qucHKx Ty9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707817304; x=1708422104; 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=1DX0f87HSAsoENN6G92H3MYTw5gEFb3bGk/lETsw33o=; b=RahVFWjwSpndPqPFK1vDwoXWtCanlsPubdUmDrRZxVx4l+stEY+mBrYQeIZmiVF6S0 0Hp3YhyxkHoILnl5ljmKQCp4LM6eP3p6nwkQ3c7n29rbcLkNRWzlchdBy6Q2apnkiGor jAsTPe9fZlzQ3g8cp91zsT3F2/sq5N1cVjHZm2thEV60mIksVa0JZEVCcBPuHl1fHJTZ 1U3pp3RBOM6e9RzDbjRRICTBkSMOAd2b/fPYvCTo14B/QZ7so1yT4YBw+3TSfjQQZ5oI h7VGFJMhLgjDwQNQcVzjsqTwgVpIY9bf79sdKpZCENoNoPacVxAcbkZYc77mMBTKUF2K lFgA== X-Gm-Message-State: AOJu0Yz2DEyLP/h9i3GFpGxNtNFGI5cMEh63/i2qaFy+oOCRUeGSXtAa 0a5ajeJBVPPUbFDillY01SyzbU35GUylDCLPYWgkMbjRt4V7UJLebcxyT4RomxA= X-Google-Smtp-Source: AGHT+IG/Pz/dz6Uh1XvDWJg05ZDpCJAukujFAhY/cvu0p48u3JZ4tUXDL9llw3i0QzjsZ+DSNW+SSw== X-Received: by 2002:a2e:a0c4:0:b0:2d0:9fac:bdf3 with SMTP id f4-20020a2ea0c4000000b002d09facbdf3mr5748134ljm.33.1707817304664; Tue, 13 Feb 2024 01:41:44 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCUzOvwLfxb6mc5IygbTF21uL/zVxJgyubcSOCZJpBmUb8xYYcieW6D96ISYX1OAhKHVVTGBmLdwDaIz5XEFSvoDrIRkmbiW7tpYV7K9/IHNl2mFR1vfPTnGR5gtwTeTadUy6OycuwwU25zU2v2Q1aVkyBzSAvm54MslEMCbEhFe+46b1WKbejYVyfstHY1+C3L+8QyLBa1G+z77KDCEQruUlTJuU1clswyeHaPx6giwB3ae9RUkU5c0zqDnA/QYL8uLymKjR10eUO0beDY/X2LLtpObTvuqYtiPym4WsevD/U1idNsbhkLWONpI5i+tPBqah8TG8FdzbeyVkevUQCr8CDcXrH7oX8MYp1SGj14XH3Pa+INv 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.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 01:41:44 -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 v3 3/6] net: ravb: Return cached statistics if the interface is down Date: Tue, 13 Feb 2024 11:41:07 +0200 Message-Id: <20240213094110.853155-4-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: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org From: Claudiu Beznea Return the cached statistics in case the interface is down. There should be no drawback to this, as cached statistics are updated in ravb_close(). In order to avoid accessing the IP registers while the IP is runtime suspended pm_runtime_active() check was introduced. The device runtime PM usage counter has been incremented to avoid disabling the device clocks while the check is in progress (if any). The commit prepares the code for the addition of runtime PM support. Suggested-by: Sergey Shtylyov Signed-off-by: Claudiu Beznea Reviewed-by: Sergey Shtylyov --- Changes in v3: - none Changes in v2: - collected tag Changes since [2]: - use pm_runtime_get_noresume() and pm_runtime_active() Changes in v3 of [2]: - this was patch 18/21 in v2 - use ndev->flags & IFF_UP instead of netif_running checks 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 | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c index c81cbd81826e..7a7f743a1fef 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -2248,8 +2248,15 @@ static struct net_device_stats *ravb_get_stats(struct net_device *ndev) struct ravb_private *priv = netdev_priv(ndev); const struct ravb_hw_info *info = priv->info; struct net_device_stats *nstats, *stats0, *stats1; + struct device *dev = &priv->pdev->dev; nstats = &ndev->stats; + + pm_runtime_get_noresume(dev); + + if (!pm_runtime_active(dev)) + goto out_rpm_put; + stats0 = &priv->stats[RAVB_BE]; if (info->tx_counters) { @@ -2291,6 +2298,8 @@ static struct net_device_stats *ravb_get_stats(struct net_device *ndev) nstats->rx_over_errors += stats1->rx_over_errors; } +out_rpm_put: + pm_runtime_put_noidle(dev); return nstats; } @@ -2358,6 +2367,9 @@ static int ravb_close(struct net_device *ndev) if (info->nc_queues) ravb_ring_free(ndev, RAVB_NC); + /* Update statistics. */ + ravb_get_stats(ndev); + /* Set reset mode. */ return ravb_set_opmode(ndev, CCC_OPC_RESET); } From patchwork Tue Feb 13 09:41:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: claudiu beznea X-Patchwork-Id: 13554854 X-Patchwork-Delegate: kuba@kernel.org 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 BE70940BFE for ; 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=1707817309; cv=none; b=Jv+ypbtOzslzC8sOFfDOquZWhLFNAveem/VZeIgwKgdTHvZ9pulH8RzJrHJrklaU+ZRT8/eQ6UwsxqkmTPdBREu2Ea9gfa+jBycAzvhKL2bYXDZi09iycooHKf2hWTujb1tz2zU/BsoQBsQAODIIrYX1/uSYF2gK6RekGwiTSNI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707817309; c=relaxed/simple; bh=EnYdAd19jAwWHKc4rTgfMXY+rwG0QS5c2MPhvFCHKqU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=lol91DMO19fL8JsmtPa405Q0YSyAFo0mOaHw9c70wV7uP6SMP7dsWLJNjpNrjlNo/Mx/jZi71gwgwJ4kYv8Vz30Ea2Zbv1S/mzXrE9H6UI3qru+9cxRjUUDJ8PosgI5d9aNeU8IDsZCy41r7IkluvG5isd0A6685zmVyCEUTHJw= 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b="omRoEFN+" Received: by mail-lf1-f44.google.com with SMTP id 2adb3069b0e04-5119cfaeb9bso279733e87.1 for ; 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=Nlb928GFsodNFtXKQGqONWun9D2lcA32LhlCOgcR+IV4eAtkS8J0cg3YUmkj3s73sh xXL6645BhxNcK4/y4YnC5SVXsAHituoFGvC0O5Ayr6/7C0vLARIl7ks598uZ6/JdFNaM IxXe7PoTRZcUsD4hBfTr74o5zAhg/tR/qUg+LFrfAZ7+qLYJ61SSGHmftk1VkjQD5WVv 5yJ1OCecXDvb0GIBYxv4Y70fegd0ZJu0M/b9CewFw0U99y7AwnFLadBt9gKn+s6hzQeV /Fl8sbOTarfCzhmRE7JluQ/ND+zblOW2CYKrGbdTq0gnkiXspf8ByWpDfU1ZPjoVl/yh P+7Q== X-Gm-Message-State: AOJu0Yyz249bvH2P55Ma8TRIzaIU6W/tafG48d+0TFXEaxRcvI7bt264 4bPKay9bk8bGKWgFug+QdYU5NcwuueJZgYaWXVqdbNAQXB5XxFCrARBZlVSgOK0= X-Google-Smtp-Source: AGHT+IEXSqcZoPS0bZRKSH9IvfC2XnxLY81g12wgJilqY+A+42HCNKHHFwzyfpnnMVNtdVg1VOhLIQ== 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 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 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: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org 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() 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 Reviewed-by: Sergey Shtylyov --- Changes in v3: - none; this patch is new drivers/net/ethernet/renesas/ravb_main.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) 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 = { From patchwork Tue Feb 13 09:41:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: claudiu beznea X-Patchwork-Id: 13554856 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.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 5D5D2524D2 for ; Tue, 13 Feb 2024 09:41:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707817311; cv=none; b=FtbewKM3tz2byLx/hajFrxIKMs8fOmwmTwRLldJBM9nF/3AFky1o39/qgSD/BQxXcljgtX9csU7BIR0RPN+coFm0InNlGkqZ4WETmQsPgeXC0Cdm04rwsOJVVP26n9oaPiSF4/9SefPICE+9Ck+dhLHT22iv2HAzGzNIYAPIk5E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707817311; c=relaxed/simple; bh=WV8FSkl5YwYxmgU6Z/VKljzD29i9dc9v4Oo9UOpnmTc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=lgIvVo1MQN2FacvM6Kh5e10V+p/9P+jW6unIakDYqM8iYJxvGVoE8147ozLLnjocTf07EKpnir4zIWgG8UzXrGzy0/0dc7osNwUqdbSYCfmwHJK0X7p4gl9qu4yKw1Kjv6amxAU6UAjvnybClXMvTwxblXfbWxxEJXtf3cWlIKI= 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=avw8iUbx; arc=none smtp.client-ip=209.85.128.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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b="avw8iUbx" Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-411c93e1cd8so996875e9.0 for ; Tue, 13 Feb 2024 01:41:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1707817307; x=1708422107; 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=jjpBbInCxVXMckDKlb1X2pBcFBDdY3zPqFanpTI/+i4=; b=avw8iUbxPkxL4+oaJHW0LrSkUDZ30IXRe5YUHL7EbRmsEHqaDbNVT3RD13sj1hsv1N Q05QMNcdwJx5Xk7UAFHWUyG5Dp7WRKVgQ+dAS0Ow/w+qUejBphbdU8PQiVwRLnllEe5g 22iG/sJzjke2wttb5DDAcEB+oaufabkIc111LhWn+oYpvudbNpVZQc2OBlWdSV/6/9nY o2EZYDFi4WMOwAbLM6XWWGgCbnYc2CgLg8j61a1t8rNm87Y5ZaUBjxUJxV6bhz/fOSWv y78Xwlk3a8kz1iE4P0+1OwoNA4leI2vqk16Mr8H+ltCdh9lElh93xNHfIgfMp7uTOiW/ LGNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707817307; x=1708422107; 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=jjpBbInCxVXMckDKlb1X2pBcFBDdY3zPqFanpTI/+i4=; b=CJXU48Dah0VKZP2OhqcT1lQCc06xRoyiHNfwVKlj/gaeIOhzQnTdHQoplnwA4+0RQq NHRfJ3oTS9Ln8H4sunjVsQwsTD91SY0dV21rGr08629uYOWoI8dRlDvRkxIdKy273GXH 9imQUnTMdHEIoso+pE4i6+jaSgloxtwWjVYNMztiqFyIxcgZfZ4q7spjxI2eLn0158tq 95tdiRozI5iaw2SYpKpGB3wKZVXJX6EsEACrIwYjOwsDx/4pu/yK/egtcwfY2B4K51Xx PL7wdp2YN1PqQ0cJoGSwhxM4Qh2cgXsVamYNswC6/5JjiGF3Wc7I/SAGVvH0jHYHeLb0 JMcw== X-Gm-Message-State: AOJu0Yz+Dx9HT5nemJsGjrPi6of9qsGX+0JmBqFdj03WB9gNGH87LLx+ t219xmh8yoGzu7H2H5R1QsgPv03Nqd7VP1fRcpJ2OVh3Z+IL1RhczJKfKXCmCJk= X-Google-Smtp-Source: AGHT+IFjCaHzNMpqVPuRua2fReqvdqjAgVYWybfp7wGjFQt+6CVMGyFSfT5t3z86mlx/Gqm0FXikTQ== X-Received: by 2002:a05:600c:1d1c:b0:411:50aa:110c with SMTP id l28-20020a05600c1d1c00b0041150aa110cmr1737496wms.12.1707817307225; Tue, 13 Feb 2024 01:41:47 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCVu4bAcAhu3dzF1s6vl2Da30WVZxWiUvmrTiLoQvpFkuWYVuwImENr83RFlEORbdTcYMKPR/wq+OmyR70o1CKQH7BGQRdQo+qx0+f1Lhx4fdl9ghJBog4sE3Tfr82cigYgVQPNhj4NsRr9+0fGaj//HuhzWqfZmIXIXLaZPSfpctCZpB378rFBD12xDr1lBENW0kqn6FhfxzyhQ9W1m1qnR4b/w+8INO1hENq5NH0IF2n+w8FPocz32Jc1M54QOXK7aZIsoEk/6nQlbWr9hkC+9dyzM72t4qxABfnxE7hIPzxJ3UQ4TP8vUg4tD0w7+zQSPsBzfGIR2+KfmqQAxzkuKfLhnwCTeEhB5OiopPhdd8StyTb+g 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.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 01:41:46 -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 v3 5/6] net: ravb: Do not apply features to hardware if the interface is down Date: Tue, 13 Feb 2024 11:41:09 +0200 Message-Id: <20240213094110.853155-6-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: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org 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 Reviewed-by: Sergey Shtylyov --- 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; 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 = { From patchwork Tue Feb 13 09:41:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: claudiu beznea X-Patchwork-Id: 13554857 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-lf1-f42.google.com (mail-lf1-f42.google.com [209.85.167.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 4728C54BC9 for ; Tue, 13 Feb 2024 09:41:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707817312; cv=none; b=hAp80cPgDniPOeMjKHMs5zmsfvwa7ArXnsJiYKhZB9S3HyevZ/nRYs15VyMEi1jghyxP7aZuvvhhlzAeG98/o37iW+1CmugYAL8q0B+5aC2hG6mx1NJ4vkpfN8YWgVEzv2yfKLdhd86lteI5yGEaWC8CFHJSdiD+PyXnK3/db7E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707817312; c=relaxed/simple; bh=fmzS2Yan2keHs53R4x+qMd55iIATYx4wBLC/B6HhXB8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Smx+M6sVWBVJdAuDqLMVo9zvSgUIWGJvw6f3Jyw1pUeVrQWNWG1BSe3VyqecGXGtBBPG7ZN4fBO17IzRxV/JIxtFvlmgzEfcMEgLErvdgU9Ij9nEWPyyhTBZ9mDyAansDtpu8AjqRWQ4b8Y1WZ8az3aee4LerGRDj54VApOt/oY= 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=jbKsIs1S; arc=none smtp.client-ip=209.85.167.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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b="jbKsIs1S" Received: by mail-lf1-f42.google.com with SMTP id 2adb3069b0e04-511972043c3so793005e87.1 for ; Tue, 13 Feb 2024 01:41:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1707817308; x=1708422108; 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=J4yzSzCHL5tZEjla4g9SMO0ApNhYh0fsLQEGXJT8U68=; b=jbKsIs1SclKnjQ5ATPFcUEyiVmAx1FZPlVLf2181zVTwPJpFSHQNcNIRMNY4Vu04b5 xmW3s1Lam6j2AfH1kmsxH5NXcjxZZIGoW8+VzwySDqHhrtlx6VXjLy4npok3kfDjQc1K zuipQK9sYk2fx8gGie8vsJO0QRju6wygmGsxj0NIE9ey8xRhJWOoxrPVfvajHC6R+zTJ 84ypKKKvBCkq9fg1e8K6uXuhEZ2Zt2CiKq15wPkimPsixDzE0HGQIW0ILecw8aTyAsyb m9p6nok9uE1iUEz5yvo7ZGCRCH+Qp7PXPGk1G4R55vGDp8kwu17hSRoVaLmdcmwWdMSe zKNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707817308; x=1708422108; 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=J4yzSzCHL5tZEjla4g9SMO0ApNhYh0fsLQEGXJT8U68=; b=iwbLihiZbUa9qXc5PJAhqCyGcYNCaOoJz92SfvcZGyi0Rl40n1xbltPsOrMPji06zU mFyDagUERfbBAgYdoxSfd77J4sVBCMHTtOrSOxVGMZemtqiE4NrFwuRST3c7iWqtk+Sj JlE1vnT515PA7xfr5TjI9LJ8bdDnlVpSBsShwcoZvI95IXN8B06fDJ8IKkxMaE6ZBEjb fawctk+txIK8m692B2lKTTsOXreCHX3kuHMeX5e4/sYl90rLFkxV9Q28QFKn3H+QO8pb w9SJ8oPd2+3azGyGtPNSNFebVaRUQrLNBthBjnCb+4ZVIctTV7uoBLXoGBMv4a3eGgpB rocg== X-Gm-Message-State: AOJu0Yzo/o78If6I24fEpxQEyzzuZaEofeV/jJoik0XkbNb2r9csDL5H QTgUYiowzSQhFehFd+COfyhH4IXAW8ZqV6Run59ywQA9Guo7dFz/wEK0yAYWGs0= X-Google-Smtp-Source: AGHT+IEVzdayMM+BRXxhLfMHE4x2j0UZkfG8mlaWyqLGaC0qX2RaAhJUayyUwDYZPowrqCPvSMSgkg== X-Received: by 2002:a05:6512:eaa:b0:511:87b4:d01 with SMTP id bi42-20020a0565120eaa00b0051187b40d01mr5770164lfb.27.1707817308520; Tue, 13 Feb 2024 01:41:48 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCUL7UtBYOYE16wvxX8CYyA+8ywuXQvbt/fW3DEuuyGoO7IhMSzDZacgkkn+aMm0J28D3Vq0lJU2IVf+dCi/Q+SDQP3yGeqXBijeWPFMNrjplKQU6PIGO2zNHaf6maqZ3NTGOX5BS8x0HUpuVT27f7uxK5TH+vb6BDo8lquohy0GlrVtP/R4I32TGqCPpcLVy4Tc8UWzuzx9ztMgYGPfJORaLUKmQwgfF4J35ev3hCS7hNUuMPP5s8k2F/67ZrR9gYQp2OFg523ehSWDtOBEo4mHyIk9xYq+Nn1+0Y+ZLhHwmy8L/qq57GY8v1njFDzphUF3T5H9BeTiVt5DSO2914NCNBM1De6A0ea35WH7TLXLAXdDtiv4 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.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 01:41: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 v3 6/6] net: ravb: Add runtime PM support Date: Tue, 13 Feb 2024 11:41:10 +0200 Message-Id: <20240213094110.853155-7-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: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org From: Claudiu Beznea Add runtime PM support for the ravb driver. As the driver is used by different IP variants, with different behaviors, to be able to have the runtime PM support available for all devices, the preparatory commits moved all the resources parsing and allocations in the driver's probe function and kept the settings for ravb_open(). This is due to the fact that on some IP variants-platforms tuples disabling/enabling the clocks will switch the IP to the reset operation mode where register contents is lost and reconfiguration needs to be done. For this the rabv_open() function enables the clocks, switches the IP to configuration mode, applies all the register settings and switches the IP to the operational mode. At the end of ravb_open() IP is ready to send/receive data. In ravb_close() necessary reverts are done (compared with ravb_open()), the IP is switched to reset mode and clocks are disabled. The ethtool APIs or IOCTLs that might execute while the interface is down are either cached (and applied in ravb_open()) or rejected (as at that time the IP is in reset mode). Keeping the IP in the reset mode also increases the power saved (according to the hardware manual). Signed-off-by: Claudiu Beznea Reviewed-by: Sergey Shtylyov --- Changes in v3: - fixed typo in patch description Changes in v2: - none Changes since [2]: - none - didn't returned directly the ret code of pm_runtime_put_autosuspend() as, in theory, it might return 1 in case device is suspended through this calltrace: pm_runtime_put_autosuspend() -> __pm_runtime_suspend() -> rpm_suspend() -> rpm_check_suspend_allowed() Changes in v3 of [2]: - this was patch 21/21 in v2 - collected tags - fixed typos in patch description Changes in v2 of [2]: - keep RPM support for all platforms [2] https://lore.kernel.org/all/20240105082339.1468817-1-claudiu.beznea.uj@bp.renesas.com/ drivers/net/ethernet/renesas/ravb_main.c | 54 ++++++++++++++++++++++-- 1 file changed, 50 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c index 4dd0520dea90..1d3de2e3f917 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -1939,16 +1939,21 @@ static int ravb_open(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 error; napi_enable(&priv->napi[RAVB_BE]); if (info->nc_queues) napi_enable(&priv->napi[RAVB_NC]); + error = pm_runtime_resume_and_get(dev); + if (error < 0) + goto out_napi_off; + /* Set AVB config mode */ error = ravb_set_config_mode(ndev); if (error) - goto out_napi_off; + goto out_rpm_put; ravb_set_delay_mode(ndev); ravb_write(ndev, priv->desc_bat_dma, DBAT); @@ -1982,6 +1987,9 @@ static int ravb_open(struct net_device *ndev) ravb_stop_dma(ndev); out_set_reset: ravb_set_opmode(ndev, CCC_OPC_RESET); +out_rpm_put: + pm_runtime_mark_last_busy(dev); + pm_runtime_put_autosuspend(dev); out_napi_off: if (info->nc_queues) napi_disable(&priv->napi[RAVB_NC]); @@ -2322,6 +2330,8 @@ static int ravb_close(struct net_device *ndev) struct ravb_private *priv = netdev_priv(ndev); const struct ravb_hw_info *info = priv->info; struct ravb_tstamp_skb *ts_skb, *ts_skb2; + struct device *dev = &priv->pdev->dev; + int error; netif_tx_stop_all_queues(ndev); @@ -2371,7 +2381,14 @@ static int ravb_close(struct net_device *ndev) ravb_get_stats(ndev); /* Set reset mode. */ - return ravb_set_opmode(ndev, CCC_OPC_RESET); + error = ravb_set_opmode(ndev, CCC_OPC_RESET); + if (error) + return error; + + pm_runtime_mark_last_busy(dev); + pm_runtime_put_autosuspend(dev); + + return 0; } static int ravb_hwtstamp_get(struct net_device *ndev, struct ifreq *req) @@ -2927,6 +2944,8 @@ static int ravb_probe(struct platform_device *pdev) clk_prepare(priv->refclk); platform_set_drvdata(pdev, ndev); + pm_runtime_set_autosuspend_delay(&pdev->dev, 100); + pm_runtime_use_autosuspend(&pdev->dev); pm_runtime_enable(&pdev->dev); error = pm_runtime_resume_and_get(&pdev->dev); if (error < 0) @@ -3032,6 +3051,9 @@ static int ravb_probe(struct platform_device *pdev) netdev_info(ndev, "Base address at %#x, %pM, IRQ %d.\n", (u32)ndev->base_addr, ndev->dev_addr, ndev->irq); + pm_runtime_mark_last_busy(&pdev->dev); + pm_runtime_put_autosuspend(&pdev->dev); + return 0; out_napi_del: @@ -3049,6 +3071,7 @@ static int ravb_probe(struct platform_device *pdev) pm_runtime_put(&pdev->dev); out_rpm_disable: pm_runtime_disable(&pdev->dev); + pm_runtime_dont_use_autosuspend(&pdev->dev); clk_unprepare(priv->refclk); out_reset_assert: reset_control_assert(rstc); @@ -3062,6 +3085,12 @@ static void ravb_remove(struct platform_device *pdev) struct net_device *ndev = platform_get_drvdata(pdev); struct ravb_private *priv = netdev_priv(ndev); const struct ravb_hw_info *info = priv->info; + struct device *dev = &priv->pdev->dev; + int error; + + error = pm_runtime_resume_and_get(dev); + if (error < 0) + return; unregister_netdev(ndev); if (info->nc_queues) @@ -3073,8 +3102,9 @@ static void ravb_remove(struct platform_device *pdev) dma_free_coherent(ndev->dev.parent, priv->desc_bat_size, priv->desc_bat, priv->desc_bat_dma); - pm_runtime_put_sync(&pdev->dev); + pm_runtime_put_sync_suspend(&pdev->dev); pm_runtime_disable(&pdev->dev); + pm_runtime_dont_use_autosuspend(dev); clk_unprepare(priv->refclk); reset_control_assert(priv->rstc); free_netdev(ndev); @@ -3156,6 +3186,10 @@ static int ravb_suspend(struct device *dev) if (ret) return ret; + ret = pm_runtime_force_suspend(&priv->pdev->dev); + if (ret) + return ret; + reset_assert: return reset_control_assert(priv->rstc); } @@ -3178,16 +3212,28 @@ static int ravb_resume(struct device *dev) ret = ravb_wol_restore(ndev); if (ret) return ret; + } else { + ret = pm_runtime_force_resume(dev); + if (ret) + return ret; } /* Reopening the interface will restore the device to the working state. */ ret = ravb_open(ndev); if (ret < 0) - return ret; + goto out_rpm_put; ravb_set_rx_mode(ndev); netif_device_attach(ndev); + return 0; + +out_rpm_put: + if (!priv->wol_enabled) { + pm_runtime_mark_last_busy(dev); + pm_runtime_put_autosuspend(dev); + } + return ret; }