From patchwork Wed Feb 14 13:57:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: claudiu beznea X-Patchwork-Id: 200966 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:bc8a:b0:106:860b:bbdd with SMTP id dn10csp1231265dyb; Wed, 14 Feb 2024 06:02:55 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWW+IS6AhZmfTUnSqEKxsS+OlUZI7K3NMjbb7i6mRVQR1p5eEV9D6kqKGGxGRAVYdua5kyoXqjLN5Qt2U/crePvjb8NBQ== X-Google-Smtp-Source: AGHT+IFU6U37XtorRgJfpwax6U3+tAgOBmPL5AS/z4NDF4GR+r7GteMZxCZZ+AkoVSYF/59+gU3m X-Received: by 2002:a05:6a20:9d90:b0:1a0:5c37:9201 with SMTP id mu16-20020a056a209d9000b001a05c379201mr3065970pzb.52.1707919375520; Wed, 14 Feb 2024 06:02:55 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707919375; cv=pass; d=google.com; s=arc-20160816; b=yd3cHBmEkaaDgYtBYfAaUz0kc8dO+XaJfUy5wzlNbI6aKuU6W765DmoWWgdwEJn3tm CdBGuDfguluBArnviiNjWloSAw1LcSlo7h2ZbFJa9oHVsWn1ViZdo+xPxqJUkAF2HLng p0AjYO/J/rZjLYZ3uS/LupkVYo8s50G2gYLBTHg3jUYaZmthw6UBE5DXMwPq5F8vCEUg hv/8+3wdwizIXH6tk4Jxo7iHr5UDTgkPBnTCg3h9qIkKmi0OPRXyqjwechBxYxNZK3l/ rJfi58F07Ro/j4Ol5Y3fMDbtKOsSoXRomBiqshPhqHx+WiUKLp1U1sv0ePdQc+lWahvh AGvQ== 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=swsP/3c8yGBz0+swt8nV2kFhh+Xlnvuijm0NkYnRlL0=; fh=AoKWpEy+hcTunIbD72N98IKVPD4UaMNdBp2YXriWCs8=; b=azJqkSqOG04wuHdkdI7hkq3A1GxbSKI7lJx4gzxisa5nHGXfrC+lg2+ihjU1Vcb8v5 IwLc3+7Ian+BPOQmL5nXzahkwm7lxxih4KMeRzsxw+4so6SRPkIdIC9QrCcSW9EFTKHS JSgqzQTRnlt+GvP/9k3jkxfgHfKkgExNpEhWGwMpWg+nPgNd+r5xp3HMf14IERhWB1wI wMN0J/wdOrJuYKrAUhFFS/erRTZMs3e8W3iqoY2MKman/bqqe0KYZru4+XpnaSDTEsOR QZf4mO3BWy/Cnjk3IUx2SmMUk30Qvi4bWvfgZg9RrwM7+O2ZNh0u8Lta1GEJQz5gjyv6 oNWQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@tuxon.dev header.s=google header.b=mzhq07Tf; arc=pass (i=1 spf=pass spfdomain=tuxon.dev dkim=pass dkdomain=tuxon.dev); spf=pass (google.com: domain of linux-kernel+bounces-65305-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-65305-ouuuleilei=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=2; AJvYcCXxrw2vPD/aZMjenPY8awAtzCC78FAGH0MquRIVTEXPH01ftlMRIBm2VH+jZmkIN+vAIVi3EIHOKyHn978WVf9560Kb2w== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id k127-20020a632485000000b005cd8123afb5si2763699pgk.547.2024.02.14.06.02.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 06:02:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-65305-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=mzhq07Tf; arc=pass (i=1 spf=pass spfdomain=tuxon.dev dkim=pass dkdomain=tuxon.dev); spf=pass (google.com: domain of linux-kernel+bounces-65305-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-65305-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 998BA2852E4 for ; Wed, 14 Feb 2024 13:59:53 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DE7AE5822F; Wed, 14 Feb 2024 13:58:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b="mzhq07Tf" Received: from mail-wr1-f51.google.com (mail-wr1-f51.google.com [209.85.221.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 E291954BF5 for ; Wed, 14 Feb 2024 13:58:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707919129; cv=none; b=dZkr/o+Uj3zu+AS9qFWHFdb+brMi2s2s3g++ybp2mR73tk1qCy6P4Znw+ElN1jRwk7c9JLZ2IsUJ+FTlQDacjr9VfV3yZeXir4mdf9H5r1PfxSGibUtN6ezyvZ0/s1LQFCPs7gBNZ4awfi2heeI6glCxfAHy6A4Lw5D3ATiJbtQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707919129; c=relaxed/simple; bh=ovrPp+G0VODHlIZZU4WtY6ajQ42RxzeAYpVNEp/CzVY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=NteKl7z2mR9e5yWxMs2qqSUtTz2R8ZP5go843U5tKsZvOCtHzfai2g8u6tPlEjwQTZntfC7NLc20eKTBAZUmkZZw+WZG7rz1lqZ4fwBMuE8dpxLImVRRIYQYpUhjRW24n1QPWThlvg1b6MoXDezVGwm2rtZDAsg9LbaYwrvY5XU= 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=mzhq07Tf; arc=none smtp.client-ip=209.85.221.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-wr1-f51.google.com with SMTP id ffacd0b85a97d-337cc8e72f5so3832761f8f.1 for ; Wed, 14 Feb 2024 05:58:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1707919125; x=1708523925; 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=swsP/3c8yGBz0+swt8nV2kFhh+Xlnvuijm0NkYnRlL0=; b=mzhq07TfcC6Fz2m+pzssbdBYS5+AIXRxrOi/f/73JMpyWwg4piHoX3dQZh3y8JMLaU bdOpS7oHldrsFbd3iCHTOCx0ZWCI4vtQQ5jdg4lGTzviUWipiaDTbiJdNN8rX9XFoBvE yMtqfSLsg76Xqx1cLCAp7e4xI5s9osU1Rej3S2P/8uBSYT62Y4nHMB8R0WStAAoGNqGU L+bEd7UxpQD4K1LfCpNj3qPwGsNWuCa8AkG1qwM1B6Q/xFg5Tbl72m7V/hvhQmdLaO1R fBt/iyuxIP18Fj8bsYOT0j7AJXchobrm1UpmFSS9MboTO727nV8BVZ60Szx4w4H7E5LN /vpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707919125; x=1708523925; 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=swsP/3c8yGBz0+swt8nV2kFhh+Xlnvuijm0NkYnRlL0=; b=vlVtKS6xIb0sKHyklVeOy8AW/9mfhNMXkpoyE33/2sX9kXnYfiApttemoFjW3i6off u7SikdTCuPJlDTdDKbBsFRBTRfIOWVPGaeWZvPg0LkNoLnixEGsBp4TXbz2NsIkwWe88 b2NN5fJZoptrmiD+N+5QxTRzvelQbKZ13BRywqr2sf2VK/0KWCE79BJid9WvIU0FWu9J t07YJWUUr4Ej3CJikp9Wp8fOH58nZkw22jzV8rG8AZLILSMWviuFdLEQopS1Vd04BhY8 J+yFcIMbZwW0mI+RUkV54+8hQnkEecSvPWyzb3jmZs/LBYnGU/EKchs1kCgYLDoCLUUK DhxQ== X-Forwarded-Encrypted: i=1; AJvYcCX5GIBKB3NlIMRwHjeN/DjhK7d+F9PVVrDysYc5PdaZHCGH0SLSdFKSyBiHAnkcxtCqZot55XWn8FnSBJQhqNrTFjMmD0y+IXnSgR/w X-Gm-Message-State: AOJu0Yxm7f5hBPuyLqedifzMhgPWu6tRyTPpApPETk0VG6+cBJM/RepR TZMUOtgVSuXhLQ3cUMa04k6aB2WbxyQ5Xqu2EvIns9XwNW4iigiaWAGWH5bL/Co= X-Received: by 2002:a05:6000:152:b0:33b:4b0f:b989 with SMTP id r18-20020a056000015200b0033b4b0fb989mr1657935wrx.0.1707919125306; Wed, 14 Feb 2024 05:58:45 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCW7Vta8OeopnfxHn57LmxvTKp1JIiFuRvtgRSj9PFHX8slQ+UHHUIOc3ukCNu00VWYWt4tSAaBXccLgLazfdBWb9Ufc/kye2D6MSHXhGBaTtV4vE1ERFI60jz9BKes+xGNkghe33es23MfBrukQ9l+LfbSPfvTvAgSLeFBw0kQalbcfTF1SYhX6COOt4ong7shGYM+xXoaaa8jJifyTjz/M6ML4hM2qz4lJNXZEXV51vOTNe6FV/f4RMQex0uT4DWl2OYW1K4hXMOv7WrEEgORFIhNgYiBMRu5KeycqQOD99H6ppr1jVRSR+DpeS6Ax5nqMPpR+2HQJc/UvZvCnP34nTxeXdSALSYxE3a9tPL4UGEwMO0VU 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.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 05:58: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 v4 1/6] net: ravb: Get rid of the temporary variable irq Date: Wed, 14 Feb 2024 15:57:55 +0200 Message-Id: <20240214135800.2674435-2-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: 1790883267001901854 X-GMAIL-MSGID: 1790883267001901854 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 --- Change in v4: - none 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 Wed Feb 14 13:57:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: claudiu beznea X-Patchwork-Id: 200969 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:bc8a:b0:106:860b:bbdd with SMTP id dn10csp1232161dyb; Wed, 14 Feb 2024 06:03:52 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVi00o24xRu5WjpnvD8J2+5JByvWBh0Z6C6W/HgW2PKjEJr4WgJovYFXqh1Tw5dwn/U529DtBumgsYfFl1rfhFX5Io+5w== X-Google-Smtp-Source: AGHT+IFPFu7EmWxZcCeKDe6qNhkBRGjCCOvwMVL2RqA0XtOuj/YI0yvwyYnUk8KGKaViNFG0x+eZ X-Received: by 2002:aa7:888a:0:b0:6e1:7ba:9c6 with SMTP id z10-20020aa7888a000000b006e107ba09c6mr2956271pfe.29.1707919432580; Wed, 14 Feb 2024 06:03:52 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707919432; cv=pass; d=google.com; s=arc-20160816; b=HE+fTcq0TEDaXYiuthsAr5bK4fnWK2NX8TnmHoKz/peTJSWDn1r0qaAHyQNE7ThGwz iFW6t97hHzVA5MgtPJMNm6kpmGz18Efc8oiqQNWWuUoeWDCPj6By3JdcbRp2aahiwIkk Gyzanub3tLOBYsxkIa3kyVSA1GlWwnYGYMMlrPhDrv0GoMF6ULZrixK4qDB0NG0MvAQR x1rCmdeaOI7FJ1oV/tKePoMcyH5/vVqnNEGuLra3bB65CKQ2ctL6vv+z7BlNJUG9xwEP K+r4+YKJHUju25dAXIctiA+PpZ+BdFmoVZOGLIuqHMKNzK26hJ85KA5lCisobrrzK3ot ubkQ== 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=nlR5/FjPjiRmwOAx9UtkAJTic0hke24cfsu9KAX+Hkg=; fh=FUmK98oVj50Qf8R7q06S+wbcsEvonFl2NqKeLIgO5VM=; b=fMqzZn+lLJ+0nH6ZH4tOdASlK7r1S8Uxue5s+/VevRLH7NbDf8mRAK/Tnl0ZaqXDOV 7qyvukrJ5StVaA6qr3EdCZBSGiDv6rG8rrjRftzvPN191PM3wYg0QXMtrmRlHyPUUjTc +FOan5zEI/DHLFPeumWG0q/6xYur5J6f4rwJUTcRZ5h0FClf3v/+NE5HEAp5IEX9UqeZ X5PDnQ2PHzpPp5f7ZQ5aYDFLTGMRup+LBY0gRAutThWl0E8OAGSaTMeBTI2PDzgrO27k Vvt1uH1vTVg6i3FI2ILq++uRRcjxcvoJKCEx5wBjztbTims5g01W5MTT9u9P5N/VOBsH 2agw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@tuxon.dev header.s=google header.b=JRXYa6Nx; arc=pass (i=1 spf=pass spfdomain=tuxon.dev dkim=pass dkdomain=tuxon.dev); spf=pass (google.com: domain of linux-kernel+bounces-65308-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-65308-ouuuleilei=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=2; AJvYcCWU9BTDRy4enKf4UvgLRhb8k//HZXgdU6zEY7giyDp61dH921C7pDV4eo8munqdFA6/OddaGcpNp3KHEpRrUK7CfexoUA== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id ko19-20020a056a00461300b006e04f294365si876538pfb.193.2024.02.14.06.03.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 06:03:52 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-65308-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=JRXYa6Nx; arc=pass (i=1 spf=pass spfdomain=tuxon.dev dkim=pass dkdomain=tuxon.dev); spf=pass (google.com: domain of linux-kernel+bounces-65308-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-65308-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 6E11228DE04 for ; Wed, 14 Feb 2024 14:00:49 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 39F2E5B1F3; Wed, 14 Feb 2024 13:58:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b="JRXYa6Nx" 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 5D3E254F8B for ; Wed, 14 Feb 2024 13:58:48 +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=1707919133; cv=none; b=MM/u3wynd/vpgqg0vH7cLNSvkrWwBqaC4tisqsCsu4bsr4qqNgjlJOjynQ8lXY1m2vdqqkZfPZhtF0jyG3WhT/y+Y1GL54dp2yYFvtJEaMscWmn8xMDu7EMPsmSJpJqe2vRqCWRcfLP5pU7/irpIwV5sFSL05+hfruyk6r2mDbU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707919133; c=relaxed/simple; bh=M4Y9mIMWHDIktHdxXrNnI2TKtm/DLPPURoaSoNyE7Hs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=efSmdW6gK3dsMPRrFpzr0YNdhujnW7QWuFHu/4/sbolSey+Lga0Zbvlg08EZj2UHy4noDs03rYVVIk2XG76tIC1V8Nc6sppPpSqg6xyLMKXaKN07iI6dGW93G0Ho68nyAwSmTq5fKEkOHZqpqKeW93A68FVNWfot0H9mEdBvhaU= 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=JRXYa6Nx; 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-33cddf4b4b5so1176293f8f.0 for ; Wed, 14 Feb 2024 05:58:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1707919126; x=1708523926; 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=nlR5/FjPjiRmwOAx9UtkAJTic0hke24cfsu9KAX+Hkg=; b=JRXYa6NxplIY0Zn6C6eb99PeW+uCn2MHLzr2pAb9k2uJPV7PFP49hZeREemYCOM5wU BHl2oXlID3SCi0kPKP8CaxnAez1y8NsXqULEmSrY0Bd8IIfTrz4SJ9MzAKHgV4VO1JXc MLYv024l972eFbFXS8AX9FhmKBKWn6q84grcgokn5q3NGuXPOBueFT5yY7r8PZ3kIO/J KSb2mqL+HEGI8ClqKu8ege/HngjgSA1z6u5zUsOZQjageTGj7hGkrCFRGo5GLDKDYHaT c6ro6m0H29GoFdLvIVyk992nBqDi5TW7nrN+dC+Bncx1NzdXbainSal5jjkLA0GKAQWi FqCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707919126; x=1708523926; 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=nlR5/FjPjiRmwOAx9UtkAJTic0hke24cfsu9KAX+Hkg=; b=PLLH3rjx3vFKo0Xa4ESqRS5wmleCsbbkYjcutl8XjOXLqN8aX6weJufIaEjywRxFeE /l8lwVCTCqoirquABpLpb+s+xWn3bg20z+z/kitFQ0V1UI/tIUGNVWRYOE6ZpYbw4saE gSuPwcX7TL9JABh9x4fE6sI6ueoNNVuy3CAcbshb72tR3rVgSmxCd/OVlobf8rgAUxZa U2tkOkjkOd0nDju4oIlb0uapMOWfkyxxc+k9yS0yaJBAVwMKpzowcLxv9swKmGq7aBKc ZdJkN1Rr4DlPjD0pXwTCeQZy0UmCl9EO6n2DrTZ+c3LAOQe/niiRqNqmJSJ+wu9YiV47 aw/Q== X-Forwarded-Encrypted: i=1; AJvYcCXXF70nyeuY3M9MJ+FbOR/XQ3Butfp4MMyqYN/rqTY3zc42Tq/amYHPUlmBGEamOnlNF7ced9ufnqfhR9totBEDz27SPF72SN+6EEv2 X-Gm-Message-State: AOJu0Yz1aQIsHgQttfTSUe7xCjwpfCtGXhUWEY2eGLl8jy3T12Hjlznk P4yXplGTKNgpAxqSjkwSZsDnxgrYoys1S19QANfApj2JIidcFRorRByg+HOeBew= X-Received: by 2002:a5d:4041:0:b0:33b:2281:ef32 with SMTP id w1-20020a5d4041000000b0033b2281ef32mr1688302wrp.69.1707919126512; Wed, 14 Feb 2024 05:58:46 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCUrSz/VkR1W9EksF5qYZeuWWKTpRn1+2yazlR0ERZZdPhFNGzRKAK4T5ZAZD0bghSXAgt6rLFeblkPqt45kaAWuk3z5laJXoMV9Ko20Cp6v+ROpXh+mDqnpDYrqAFvUh76Da0AORwPs7VqoDSDLr+6HygCxHbvIYwGSu+lf2rHFZNvK9Bdgzl88mtIODWh/uUwcIlaLR1C2GCK7Ga6fyeYZ5CALTiBq+HLl09AV/6lYac6rt345JB3ZCoIsCbZO1I4jfE4cA7XZiJW/qUXUmEqdvuZISuJ45pnWizcxHC55djynCQUBAX+6QdSZSamiOLwTuGo8/vb0BZe8hQ7Po9booAItgseBDRkLAsXrBH6rsZtZpFIu 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.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 05:58: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 v4 2/6] net: ravb: Keep the reverse order of operations in ravb_close() Date: Wed, 14 Feb 2024 15:57:56 +0200 Message-Id: <20240214135800.2674435-3-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: 1790883326611612656 X-GMAIL-MSGID: 1790883326611612656 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 v4: - none 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 Wed Feb 14 13:57:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: claudiu beznea X-Patchwork-Id: 200967 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:bc8a:b0:106:860b:bbdd with SMTP id dn10csp1231831dyb; Wed, 14 Feb 2024 06:03:31 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWWVxrANZazIE3AYPAkjg3Iz6gL45SNxQGaM2fez16CWNl19vbAqZp3GD0x3sLG1fVSJCe+L5dHbI9/6J6OOSrJPy8fxA== X-Google-Smtp-Source: AGHT+IG2ic6HPul4v32gd2yi4Pe/WaubBGWdnsKIcb15HzQvwmthltoJGDBTgo6WCrPSn6oLAN1c X-Received: by 2002:a17:902:6507:b0:1db:5093:5e23 with SMTP id b7-20020a170902650700b001db50935e23mr2481691plk.28.1707919411254; Wed, 14 Feb 2024 06:03:31 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707919411; cv=pass; d=google.com; s=arc-20160816; b=mzYO3ASRWuDcY7wZfTcjelc1ITFm+zW29cOLTxW1WqjTAgyei/eqwXIkUrdj3nl98/ giYTJQnoqM7+npYtV2ZUZwg3keh92RUa3le0tScpCGFXbyYbbk7K10MgmNhkqDyFSlMM fymGIaVBcZ1NSrm3zR6Cd7+6z6wsLPIJzEYIyBD/GJJtHfOcgLjVDM8sxugeLINVIFdL BYxqhhtSUwEk5MrpcEJV8cG95vpghw8/IyB7zTYYhvzcCWIGNKPuxfpdEOQOr5Uaytje oFyLhNHkgwrK2DfuXDfnYBgdmfyqD/RdIo6iUJ4q4U4mwl73bhLbN5meT+MFHmbzLlRs HAjw== 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=LNOxk7ObMlNCb9z7bNPG/kiAHGWviZsSjwr9QNQkzTs=; fh=MeWFggIn9eSyV7M5eP6xf6tG0CdEiWSQj3/5vl0dDao=; b=a8cT8Ic4P2xodytvSbHLm145wk3+oPOYW025h0Xj9YAazoeA52anfsf4qsLltKW7es KJ93674Mu3bOlaoV4xn15YEAdCShyNxfOLZBhGZnSlcPeV/1FqCjrLZFunVp3OUjN+YX UeOSW8VV3B31BzgWjCyfTKSd8gU+aLMB9rD3qeMUadRGikuwzqFP28giDpL+c8XEbXx1 ZAfRzJgm4tuhRIGnRFgYG0oXEfGSSMemsA1pzN2Z5v4B0DG5TjXWkeDbYBdsZBs4m3kU XgPOx4uOfmozTu/ifeE/+oA/xd41LMReT7sLpDwC9/9RrusZe64bfj+T+3eqprHlsQqe A0rg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@tuxon.dev header.s=google header.b=ZI2P9KWM; arc=pass (i=1 spf=pass spfdomain=tuxon.dev dkim=pass dkdomain=tuxon.dev); spf=pass (google.com: domain of linux-kernel+bounces-65306-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-65306-ouuuleilei=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=2; AJvYcCXjug7WVRIArXflasm3VVEeEWZbZuKW7uWWisTSwBmwyQEq/6Dq3Le5brQ7RSuetEMvdJuFLYlRSNhamJCwAmY8m9hqLg== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id u16-20020a170902e81000b001db63a53b73si673401plg.45.2024.02.14.06.03.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 06:03:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-65306-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=ZI2P9KWM; arc=pass (i=1 spf=pass spfdomain=tuxon.dev dkim=pass dkdomain=tuxon.dev); spf=pass (google.com: domain of linux-kernel+bounces-65306-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-65306-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 06F6228C59C for ; Wed, 14 Feb 2024 14:00:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C8C495A0E3; Wed, 14 Feb 2024 13:58:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b="ZI2P9KWM" Received: from mail-wr1-f43.google.com (mail-wr1-f43.google.com [209.85.221.43]) (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 7CB2155E40 for ; Wed, 14 Feb 2024 13:58:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707919131; cv=none; b=Be/ToCv/SmFCui1o5KVvxr1/uKj4HIJ6L2xaECjCjcc9g9NVLjFuS/P4cF/tjXnuBKfqhY6630akc9pxuP0qEiCEdh4dyaiGPo7crfNkkaochGcSA4KoJLgWeOqRR9gZfW6fsQL+JKf2IoIeXkEw7M4gRwFhfXIHz/Kdf4RnL4E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707919131; c=relaxed/simple; bh=FjpT7HYwfIhvnqp4YHdZLJltiMOVfPS1cPTRRdMvPpA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=UKC3zi4mBDz4FCfLDcUkZbqEO+P5aRmDQCzapNDdn5Yv/5EQxltDUWGXf/PEoCbj9EVJsgAahjlAYLRljxBFZUCunnl/qW/6eI4OyveWOxqCLK2s5C/5qMsXcUGD+8XLQQCqKMYEea6i9jyuOncwGDlG3fu3OjpdpVnkHY5/daQ= 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=ZI2P9KWM; arc=none smtp.client-ip=209.85.221.43 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-f43.google.com with SMTP id ffacd0b85a97d-33b2960ff60so485993f8f.1 for ; Wed, 14 Feb 2024 05:58:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1707919128; x=1708523928; 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=LNOxk7ObMlNCb9z7bNPG/kiAHGWviZsSjwr9QNQkzTs=; b=ZI2P9KWM/nrONJ9toyahqSKqaKH3K3EHbiCBTl14drdBlIcdCbzfcZBs4l7LNcMp3L +0TZKoWidLpJaT1BBYgjgyXbFMVIVpzQLOjf5X+miC8z/TCOUGZyyAHF+zQFMjC5bgS6 khbCpdNTWKy/gstAPW6AakaV3/1tCRcZU1LzJgN0S+ljPYSFzMjixoJnKLH6EXAN0MsB 3B87yBQ1+5Uzq+CzjLkXcChqv4/sOHR711p9w0eboKMTVqkuA6i2pAbA1HcOk9Vs46oK Wbq6qaS295u9tOKL1cAfL7MFlgMqDnj7gvE6p6G+XAozNbeLcUAgthtojYUk6qk0c/Aw uksw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707919128; x=1708523928; 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=LNOxk7ObMlNCb9z7bNPG/kiAHGWviZsSjwr9QNQkzTs=; b=V5SrYWXY1Wkf/mNZogK0fixTCzWtjGWAG6j+Xyae0kWbFFXlZidI92UEmdxwQcXd6N k94aaavQINvCU7Lyj6Ta/VigR1AxTb4vxNrIZRrt/0HeBotwtMxcmCfx8zG4dnQY8Vd0 IAY3teXJJjpvZKU4S9m5pzOzR/Z57BxO8cbipLLFMzNc9/lZkdcX+gW1SbEKCb6mPq/6 3Oav8Z0MYh0exYH3hk5McRQ8Ktv3RjoESzLLsC4rupQoAnQB/K8HGThG6T83dykup0k1 X1w3DBl75jdBGXmDo4pERmiluAV0PUId8R2MapGOgyHNmSgm08bGbLFT1uaw7LigM6R/ PJYg== X-Forwarded-Encrypted: i=1; AJvYcCVYk+/qrQNzI1HmD4qyueR5zPTUkRt0O2R1wQec8LPnQVtbm/BP+i6SI6je45F+WDaarkALPoFYv/7X9VkFvJXTfrdIFJfUvMDvJye+ X-Gm-Message-State: AOJu0Yz9CmTGyKPHEa6Wx7tKYaMY8B7s8r0K5nDvTCkrleK20+ebXCEK 0AkqA+rSqLV9qb/8Iq7+vtwt1Ycgt1NbhMvxL+M+vSBqjGZdn6cA70s3Q944uMA= X-Received: by 2002:adf:ea8d:0:b0:33c:f29a:30ec with SMTP id s13-20020adfea8d000000b0033cf29a30ecmr911894wrm.25.1707919127685; Wed, 14 Feb 2024 05:58:47 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCXyOQ5GbcNIQ6rfjuLwMp8PqwHzicVvuuJ7S+f4wLP/0H/l8QubsaFrXRCoDnuP/8vwZAHZe0RD1Kvqm7bMILuvkso5XDDEL5Qf8B+OIYFuVakb3Yc426JUGj+ikTFZsmspp7WJKyZAnzdg5TmkXXxGkuctdedr6boDsaTxQAonlq6iUZNBs4ZCjnTuCz4kCsrXVXW3S56HM4aomL1329GtwZSwjLEx+8ICsAFIFpJXNNHb1vl60HT2EPRIL0s0GhzL2pt57YXzDXGBNECHF0pejcS45H46VUNocpeplHT65HrnXnvCbjjN2xljnuo5LfaYh7AuT5RaFsCcdkc5W+nXomvM5ljeD1U4tHAYPa/6xmVCSjhS 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.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 05:58:47 -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 3/6] net: ravb: Return cached statistics if the interface is down Date: Wed, 14 Feb 2024 15:57:57 +0200 Message-Id: <20240214135800.2674435-4-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: 1790883304936480727 X-GMAIL-MSGID: 1790883304936480727 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 v4: - none 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 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 = { From patchwork Wed Feb 14 13:57:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: claudiu beznea X-Patchwork-Id: 200965 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:bc8a:b0:106:860b:bbdd with SMTP id dn10csp1229259dyb; Wed, 14 Feb 2024 06:00:58 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXS3UO3vtblOaKjraD9xshFr4ymC/b0WCZ0euGsUQZ2zMxMsnbiTUx7zgxlBRMh+VPG6ivgL6nUU4CWRLbkPdAeD3aFMg== X-Google-Smtp-Source: AGHT+IHVkpTywskxwG5mSh69E5dezi7/c4Kblm8eRXY+j8+od7v3ss0DcPIMn3ZNok9U2Ty1cpSy X-Received: by 2002:a17:906:f158:b0:a3b:fd70:f9e6 with SMTP id gw24-20020a170906f15800b00a3bfd70f9e6mr1983277ejb.5.1707919258599; Wed, 14 Feb 2024 06:00:58 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707919258; cv=pass; d=google.com; s=arc-20160816; b=Uk7rr+TEx9SV2YiuUrXX2JXAZtGpTFJK5PW8tXFudYj4gZJJ64pKSKA2n1Ovh+hSB/ LbwLaE4SxnCYqYVwaWYVjqX/6lk+BkyWEBjo5R71JpWEArAX98ScS3cPbTdikhh60cHx wnlj0I9TbhPXtTSVB1642GiMdrSwMPtCLmPqk39O6Z0t9FEDMyk/8MPit9wM3tnUovuT nRK+DDPSh3/eMH/9vDV6U5KNTU/wyHVn+S7qUhh1D+7FdKhYdBOVfs804zfNkJYLvUuW ybjp0b7iNhwm1ruq+FKEX5dq+S70U66ytna+ZbQc/KdI/O1KpghtJ31fyKHUVhgWM6eX Ur0Q== 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=yUpbsmqd6qgdpA6pLSTrT7SxbTG5IveZrPaHGowSSOA=; fh=PgyHB0KHtJC+MtZ4ytv5r4e/HzTPC9ZMvztWNdGbJbQ=; b=qL91bHWD+AkgU9JVyqGW7+kdKt2G+X+fs1P0JmdrizejVn0i3QsT1+gu4Z6zaej0Cf SXR2zZlZHQ+e9yTFn/qRnj309ZSoOK/DK7F3GNuNT5MmU60RlwVykPIgenrZrrQQD3Gb qHcPgrSuWyKUszzh7Y8uXXfSRk1X/7iytg1uYBYI+2WpIHQ7SYn58M7zc1EDaKGAchYr tzAJ/1yUkZONMe+bWBgeYmk7l0F6bdr9S9Jqu2QhlzzvTvW+3aOUG1sAPoOUJIPqhCWu Xc5oTimmgvtb6doEuTcb+Ru0wPiGvKAVD9kzOUK99NoD+TrncbHH6VYIxSwR2iTiTu/E VjGw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@tuxon.dev header.s=google header.b=MqYS4Ijb; arc=pass (i=1 spf=pass spfdomain=tuxon.dev dkim=pass dkdomain=tuxon.dev); spf=pass (google.com: domain of linux-kernel+bounces-65309-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-65309-ouuuleilei=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=2; AJvYcCU47gC2vYVHO5DK58kTpSEYvXKSmdMkWcq1fFjOEUqvVJfd8xauaRb9En5NYh3z5rxDMJBuNkws1CkRMTyOJlGjWbpdWw== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id md13-20020a170906ae8d00b00a3d149a79fdsi1433258ejb.616.2024.02.14.06.00.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 06:00:58 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-65309-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=MqYS4Ijb; arc=pass (i=1 spf=pass spfdomain=tuxon.dev dkim=pass dkdomain=tuxon.dev); spf=pass (google.com: domain of linux-kernel+bounces-65309-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-65309-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 0F20F1F23DCC for ; Wed, 14 Feb 2024 14:00:58 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C18FF5B696; Wed, 14 Feb 2024 13:58:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b="MqYS4Ijb" 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 DCF185813A for ; Wed, 14 Feb 2024 13:58:51 +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=1707919133; cv=none; b=Xo7nrMHqYb2p2huyfIPqAgm1nxqg3yWVpRF/AgbuX8qZ8IOgQfFv16b6G+QJTTPLAjqr+XKOmS7eOkuyCE15E8EEjq9INpGPWZ+mq4TXea7pKRJth2QFiq3689zM1X/+OWw3KsPLLSg0Tuqt9I1k1G6JadrvGvj0t8jTymVHSuA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707919133; c=relaxed/simple; bh=rcPnG5KBmIB3G2fdjvqQyKleIdh/hUEQXg7DZEDQHKA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=hRalqDbKyygtZqP7zDsFEPJ/VA0N3+HyUEk7h+kudnM3FnDKlhdKJjyytrgeA4BywbqkwLL2ow18tMQ/M74mLCk2MU4CCXh0Fc0fdQ3UybzSKuNfhignwLCU8Lsm0L+A78TwolKTVuqJJS0AEcKoGi1PE64Y3kwl2fWJtLiy8Rk= 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=MqYS4Ijb; 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-33b66a7f859so2165985f8f.3 for ; Wed, 14 Feb 2024 05:58:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1707919130; x=1708523930; 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=yUpbsmqd6qgdpA6pLSTrT7SxbTG5IveZrPaHGowSSOA=; b=MqYS4IjbfWEb8jRHuHI3wSkWZbM/ok8qD0atTWnExWJnZv7x/R2C+QQIUEtf43hXD7 iOb3G/shRdiQQpj/kJEihSrYv3pN0UhMOJEgSdlAF06XvlwOM/PEkNAqa1X5eK/AF29Z gnKDkmtxssOB3b8VPmU/+nGXyW6vvaqTLTeqFFqKE1xf8K3MnbT7gVaV/U6LJhNOt0SY 8+eHeZncN+HtUs1ZPpMvzLtNG8oMLZX0L20QJKYPHl1GNslxBu2kieg9nofr+4EKCccg tWZAy89pfGxKU81vuDbYp2cMlIknIwTVtMJ+fXGFIwtFzaU4tI6exYGag+kBsksdAp+U FVeA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707919130; x=1708523930; 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=yUpbsmqd6qgdpA6pLSTrT7SxbTG5IveZrPaHGowSSOA=; b=b3qsbOP2HBAuuQYBKLni346cxN8oSt21SQQWGDD+fQ3ogC6NFQaT7gfrGuat6sF6tF YRAMba1OjiP/Tyx9HmjIY08jTM3wCkRskuxUnklGVZjJ968A9es4d8iGTrS3GQCCoXzn 2vUgLDB1U6Bvj997GnOzB6cOhBh1VEMCQpmBCTMFUVLu0UYK2GhefLdhzeYVMGAsDmuK Op6P4xL1yOzm2ZwUgUp2VnRcmnD2vUqj9aeKPCTzH5YmFh2pr/plwxc4ltkt3ZdrFd1l 9BrffLgnSaAJne1XWKYfv0mbT3UIeQkkiJiEEdMXicqGKTXtf3Y+UUJBBIP6lsU0oqUN mYlg== X-Forwarded-Encrypted: i=1; AJvYcCVqq9vrHIOmm9VbGH4QLbp/FaoleXaew9nSFtQum5+nUgjLX/OrFLjv53LuXa65EMJAy4tqlDgYDvUN37q1OSTnxvn3AQhQBc8M7p+s X-Gm-Message-State: AOJu0YzWd8bPF9LNLt8+aAlv84Z8qerEtzYgshZ5z+cnz+HyyIqvIQk8 lhzmQzTx7D9upHN1xr3O9ubvSy5g8rzlj2KVBkJfo1MjCydpHe98Zycn2eId7LE= X-Received: by 2002:adf:d1e6:0:b0:33c:ee7c:c433 with SMTP id g6-20020adfd1e6000000b0033cee7cc433mr1602489wrd.22.1707919130208; Wed, 14 Feb 2024 05:58:50 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCV2GDfa5HsntXhjNa5oc85h5mHyVdzd1lkbvs0rAtM9EkIBcdVPip7bn6ioIOM4tjncSIsfAFbFUrbWizDwBOpXrJ9jSCfsXC3Qq+hRXYE5dsOqMX/G6EAS2wltMCSeP17FpT4YSl5zAG3gc+ugE2HDnxifnAozbNf1SrTWJhizPrhKwjW5NnTkKkmDdnn99mw+hhQ79bUp+VHuqcjwKXg7GaWOaq8/JrreCqIx9394bRT53hw0EfzP/P879OIthzUuctr0EllTu6/FLESsv9l1ijZw5osk2wAQw7EfG0Vwbj3Cm+prWSEBh/mNW7Pbvz2S5JJV2AOhWijd4Xm2hrRuVCUh39FMvKfcBzkt6jLIrwBvNX3x 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.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 05:58:49 -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 5/6] net: ravb: Do not apply features to hardware if the interface is down Date: Wed, 14 Feb 2024 15:57:59 +0200 Message-Id: <20240214135800.2674435-6-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: 1790883144500888659 X-GMAIL-MSGID: 1790883144500888659 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 v4: - simplified the code - didn't collect the Sergey's tag as the code was changed 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 | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c index ac23779d1cc5..6f0677d1adee 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -2564,9 +2564,18 @@ static int ravb_set_features(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 ret; - ret = info->set_feature(ndev, features); + pm_runtime_get_noresume(dev); + + if (pm_runtime_active(dev)) + ret = info->set_feature(ndev, features); + else + ret = 0; + + pm_runtime_put_noidle(dev); + if (ret) return ret; From patchwork Wed Feb 14 13:58:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: claudiu beznea X-Patchwork-Id: 200968 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:bc8a:b0:106:860b:bbdd with SMTP id dn10csp1231950dyb; Wed, 14 Feb 2024 06:03:38 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXEbWaC8gbGbCjOeSEXtuhfhZG8pReNbj+1blR2SkpDVbkH1LpJbKYHG6mqvDPhy1H18QmAdjQBzhI8kSYJ4CD1+GtnJg== X-Google-Smtp-Source: AGHT+IF6BmPd8ORPilXTmHqgM4c3/OxuqcDBUpWw1IS3TipjE5m68RJmauQgGTg5QrOCWaQdpQXv X-Received: by 2002:a0d:da85:0:b0:604:e15:81a with SMTP id c127-20020a0dda85000000b006040e15081amr2240606ywe.52.1707919418199; Wed, 14 Feb 2024 06:03:38 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707919418; cv=pass; d=google.com; s=arc-20160816; b=HNPl41YhGvTR7NT0RvuH4uS+oI9xIO+ujJqe2/6+I9dlcRwzgigUIayDR3eng7mRpx T3hOURzTggyNzaiuYi1HTgh+hXXVYt+0oKw9wn75aMuwQYICW9pft72HiqespOuKTdxn 5fTAOUgKfgg68/RXsHr+t1smhbIRQyuRxk1OTW3hut+w8oWod+CWZdk0qT6QbO8v1D9R 7q+gKVEyMJSBjm9X4bghV+YLwy+Gq6PgSgRzYWgb0sjl1sBxjshT3oBbfILOb0KwX0lU 5NkKqCV/0Dba4gPHSKoDBgyHmOlXLIZr/iyoHh6BWnHb6DAUupCqsOASYGlNPXf0o7q0 tZpw== 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=/zjiXPc38mpvdFc3Koad2qjD+UloWUSOxb8tDBr5OK4=; fh=1H5jY1GXDPzR2N2XHwnnOPglDxkj22XkbiC86JiTr+M=; b=bzqOv2S6pkmatbg6Ai2wheM+1pomTW72KorpBydVYDnbDMouhl984+S0u66NMjse65 dTZrWrECRujaCGd8cyWDOZoz36dnyXsQbg9XsDoLHqmSqa10QuVHVNSGEaxXE7nQt8Ex WF8/EDpXBBlOSowk7gvAGgc9O16aXLuh8tKPsvAeK7Ah7PibFMKc41lcyz4TKZLseXIN MaBYKmQHXUpseEbsyH/JmYU1DhVnxWw8PqwcHosz3rvjBjvkH2F64n+HT73V1SEk3Yo3 FmPtCNPcwiF/FVnwtXZdD9T8GafQutUfdCyc+NtvlD/sLCzG88zO9txOGvyNIm4sdSPD gQfQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@tuxon.dev header.s=google header.b=PqwY+T3B; arc=pass (i=1 spf=pass spfdomain=tuxon.dev dkim=pass dkdomain=tuxon.dev); spf=pass (google.com: domain of linux-kernel+bounces-65310-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-65310-ouuuleilei=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=2; AJvYcCUAZBfi56HV8020Q2UuUI1JzC1U/VbszDOXXz7bO5OAnUAYoTyfnWXOCbis6TbJY9xkkM3guCp6Xnp2dkRp3otwjmsTxQ== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id n207-20020a0dcbd8000000b0060785e04507si1643176ywd.250.2024.02.14.06.03.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 06:03:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-65310-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@tuxon.dev header.s=google header.b=PqwY+T3B; arc=pass (i=1 spf=pass spfdomain=tuxon.dev dkim=pass dkdomain=tuxon.dev); spf=pass (google.com: domain of linux-kernel+bounces-65310-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-65310-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 4E42C1C28284 for ; Wed, 14 Feb 2024 14:01:06 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 322605C60C; Wed, 14 Feb 2024 13:58:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b="PqwY+T3B" Received: from mail-wr1-f43.google.com (mail-wr1-f43.google.com [209.85.221.43]) (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 40AA658AA7 for ; Wed, 14 Feb 2024 13:58:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707919135; cv=none; b=MP4KLBRtcNSK9wMJhVd/x3OMprPmHTWBGtW0K3FYvDmEmLOSC1PnfMBJ+8svzouEUqZMWTP+qMIGhmm2xPMcUy58uxHfE21RKRRPyrc979EmvmFPwxQVcM+0R52zD0EpmSOPX4gsCBkAX/0GZ6lXFq9S9eBkfK1PI5GhKbQgIis= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707919135; c=relaxed/simple; bh=DCOkytDLppS2bYn3RErvOIjLsPi/YOCWIUBoGo2hi0s=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=VpmmSNJbQmkcqzcK2dsq3qKPjsyDf4WZfWvmI7jLSNw2LvB5lr4xnZD0j8EQFFft7pyjCxTq9nSrrKoNREtqEgVuyusrm1sSUT1EiPk4EzG8Ol++DdknzBExNgxzlo5z5A1N9XWSt60eIgpwA+/cI0G6DBdYBa06eAwMDIex+zc= 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=PqwY+T3B; arc=none smtp.client-ip=209.85.221.43 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-f43.google.com with SMTP id ffacd0b85a97d-339289fead2so3587512f8f.3 for ; Wed, 14 Feb 2024 05:58:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1707919131; x=1708523931; 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=/zjiXPc38mpvdFc3Koad2qjD+UloWUSOxb8tDBr5OK4=; b=PqwY+T3BgK+ZRZjW/x3inefq7peSvBzf6BHmjvV/vXexaKPWYFPlpNQINna855jr7F 2ZWBLsEvwyLL4d+Z9eICXk9oONtXZ2Xd4sMaA5FfdhU0DRIunsVLunMXpV4iOq1qbWAu aBCwkFHPmtWyzJSBPhCESvDCGKwz6E22H6koq0kbRQn5iZYnHkAWdhst9a08guI5Dnj4 MwO45kG2mGu2IfsWIvptSZQCzefZd8+P0SVayv9Oe540zdqiRVdXxnNcR7bSJ+66zxay q74Yc5R5XXWL+FcdSVLNlcz0KNBmbax1XXtK8hBg0YbArXGAYWydufCjyMmIdPWZokGJ 5+Iw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707919131; x=1708523931; 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=/zjiXPc38mpvdFc3Koad2qjD+UloWUSOxb8tDBr5OK4=; b=vCynr7Rkwbov0dqiDPMk1DdKbCn1wt6qS/E4XXq5oH3urwak0MYYZ3Sdw3+NnMHd2C SzmMigTht0pfkAhdHtwFa1aXs+K7f5nmzLp3oKyhSjQWwaPdxKCudh6u2SSicjC2wS3o K41sFmMcExPenwu26CT0L5nqCBuOlWciaudOz2d9eOYqJElPneK16ReLC84sMnXQqmT/ qORRgJM1c6AWwv5CiHqWZk+qbBAixXoEbVLd9x0XxdBwIjPhKHo9LAlj6FYNrbstcDtl MRA26hQEU1lEzk+wpcxIFv9r2VIS4kelUGsXi5o7qYhy7G2PhrItEJrK/qqsOSxRyWfM ViIQ== X-Forwarded-Encrypted: i=1; AJvYcCUAHU2hjFCXsR5SsNuYNQv0UM/cxXN5fkXWLza8hK8lGBr1ZAC3neAMHVyFPVcQkxRUAWz+RZLY44e7CucQzFzeVzWvb5YA09v3cLVs X-Gm-Message-State: AOJu0Yx6DWHQBsuiRMSxlmx6BxDlNSbwIpUR200IzvFjPk0JilG41HDp 2OlH50AB+eexzmOgP7b5lNkk/l+S1Up2dft7GmH2chsMS7s5jkk/IuC0etBFuw4= X-Received: by 2002:adf:f18e:0:b0:33b:5087:c913 with SMTP id h14-20020adff18e000000b0033b5087c913mr2242505wro.54.1707919131582; Wed, 14 Feb 2024 05:58:51 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCVLwJ2RO2UWMIdJhAp4ZOX+nEM6u7OawSEXibKwgIZurbbgG6FeY89PAkWMrsvonE3leWhdvP3H0IHro4PglhJH2in/eFz4JvexoF6IActYBupfvxjZ/e9P+FrlcoosPha8/GdCgPYMa45MTqxnDwnaWvyZsClbLpfa4AgBy5qjkW/L12UmoVQhRiG5LG9pUx15X4i29vZbRW5EqzbdY6ieGCKpFV6vQMJgEV5hR6fzwVesRp5/C1JyCnxhbLLvOCs6SPrJZh1QtgfHmCWwEXDE47V3+wDG6JhWTr7kpcWcpOAG3k4BrCyp5nTXl69QrpdnetW+0CGRQdiykSjD4Ak3rKJz8P7O7V+YiMzw0q1B3+HncYr+ 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.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 05:58:51 -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 6/6] net: ravb: Add runtime PM support Date: Wed, 14 Feb 2024 15:58:00 +0200 Message-Id: <20240214135800.2674435-7-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: 1790883311842308837 X-GMAIL-MSGID: 1790883311842308837 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 v4: - none 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 6f0677d1adee..289d6482cd72 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) @@ -2926,6 +2943,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) @@ -3031,6 +3050,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: @@ -3048,6 +3070,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); @@ -3061,6 +3084,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) @@ -3072,8 +3101,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); @@ -3155,6 +3185,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); } @@ -3177,16 +3211,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; }