From patchwork Fri Jan 5 08:23:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: claudiu beznea X-Patchwork-Id: 185260 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:6f82:b0:100:9c79:88ff with SMTP id tb2csp6091547dyb; Fri, 5 Jan 2024 00:24:52 -0800 (PST) X-Google-Smtp-Source: AGHT+IEE7UstUMMmacj8jDaRN6EdryGssn9m0+73K9Jiw6qAesntNar7q5zxybPBOOF6BEJriNSi X-Received: by 2002:aa7:d504:0:b0:553:861a:4963 with SMTP id y4-20020aa7d504000000b00553861a4963mr500953edq.65.1704443092525; Fri, 05 Jan 2024 00:24:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704443092; cv=none; d=google.com; s=arc-20160816; b=k/b2zdrRcO3QIJYdsNE6T6uRLkQQb2MroY5KIdcEEzhDunEDowoik3TxhZEEUsVsME 5BqfZ1LzPXd9c3YE9JcEYmxwLkljbjH2KKfFRrW6hm3uTaRHHOP/frZ6pvIzJXLNt4wI uHzYml04SWqHgPug41+nRVsYcCGi2S38gNzIhwVUEhCUmeQzc1wCqk52n7UGvMC6jmyB r9cH3vm5cZhqrtnI8Bng5Khxx5VacD9UwH3bPyoJS3yoZ+d1pERk5NsOdIXe670VWMyy 7XNAPJDGn2BJmuBW/C36RArH/hKIbYlBCYdoayC3L1/As2+RR5mwDrLxGumZYI06Dt0M eRZg== ARC-Message-Signature: i=1; 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=l+tjNoHjZQ1yXHRb/ulbcR3/2aD9RiH4l3tk8kImOzo=; fh=qryrdWWtksp4Ojh0keXejXriHeHARah4mOGZkuZ1jnk=; b=QEx+37daHRudWBDugXwDmZnyK2h1xZkPqFT1x2GpPzUd3MfNbaY0XXCG1HP/h9w4hX Yq99x/9nzck2fUlhpEAp26m3fKQraorDhK+QVmiGl6K+PHVOL0yEq84CZbo65zEOz2HU Zq9j2mecFDCrLtb3l6wVKjRqOTPeol0rHL9/In20S/XBZH5PlsstL9lgIruUJL+H5JQA xs6tsN5Sf5R9SXhsf2n+Sc4agLDvuHlZRopQJJILU0DLdtQ/B3wvfURKz8j+YkShjAYa hgtFobCLu3svHWx9yolJFdX2CW72sJ3ekR6rrmsSS3SehZhCuYdKFtfxLL0Sq9IMHB2I L+kw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@tuxon.dev header.s=google header.b=l74xefE6; spf=pass (google.com: domain of linux-kernel+bounces-17580-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-17580-ouuuleilei=gmail.com@vger.kernel.org" Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id s6-20020a50ab06000000b005561c393184si438407edc.221.2024.01.05.00.24.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jan 2024 00:24:52 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-17580-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=l74xefE6; spf=pass (google.com: domain of linux-kernel+bounces-17580-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-17580-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 2309D1F239DF for ; Fri, 5 Jan 2024 08:24:52 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 27200225D3; Fri, 5 Jan 2024 08:24:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b="l74xefE6" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-ej1-f44.google.com (mail-ej1-f44.google.com [209.85.218.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 1BD3421376 for ; Fri, 5 Jan 2024 08:24:08 +0000 (UTC) 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-ej1-f44.google.com with SMTP id a640c23a62f3a-a293f2280c7so31038966b.1 for ; Fri, 05 Jan 2024 00:24:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1704443047; x=1705047847; 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=l+tjNoHjZQ1yXHRb/ulbcR3/2aD9RiH4l3tk8kImOzo=; b=l74xefE6EIja6pmePL2sMlf9yaK+OV8WMikYVjLK84Y9Q9xwmL47Smpq6lJNbN1Iv/ OphuOt80nK1O6wW3SmMVe4tDy5vgmrorxvmgvTGb3e8QAUSMZkmoeSZUIZeSpR5AgFdk 1/9OuKZV008UPT3RRWpkF0ldSzVltgCooBMqQhsWtLkUoBTnOP1hiqIl3wh+x1BchMgr 8VNhLTpsiwS/+w5XVzpP9PD1fLEzm6HAmrFaH/zJOdGBNjfC39i+5dOJ0z39w/ockvfP zwfyr77lpnMkQVRpEc4Ml/ucyST2n+Z+bOf1pKNKrwYzA4UjQCOGrsBQac1r7G5Tg5Ov fW/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704443047; x=1705047847; 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=l+tjNoHjZQ1yXHRb/ulbcR3/2aD9RiH4l3tk8kImOzo=; b=TPhZO3L0i3EEfvTlsWPkcNj5ViGLszQSMnThe8lTJqzx/i31IrEZsY3ksbqwWn4npG YGp6kXOjM/vb3aj2Lf4i7G4nMs9ueG/SYCTmvLR3KoTuDIzpqws52H5ZEmJE/lynKzDz YB23LtpPJyT9z7CoDfWarxTprxBPdz7jt/hEUM6U8ScOB5I/XfXWndo0JuttXhEoN2dS 29GNyc0SjxF3mdOmGJbrUap1K82bmyRptlTDQ1RONSItxzFPX0F2TKqRMrYDSDEERQqN OYKfckAkmUbfbSi+Lee5TR2H2che45l9rEesEflqGNzmSOtrMWNudEuh0aV9l/qGQ+nH tC3w== X-Gm-Message-State: AOJu0YxGb+QZZl/1moO3E/yGVJDjkwnTYYX4DIgJYnJDYWy+9UZCpuHb lf9QZMP2aRqDtQ5hi7SWoToOmFiN/qh5OQ== X-Received: by 2002:a17:906:57d8:b0:a27:b676:a603 with SMTP id u24-20020a17090657d800b00a27b676a603mr456149ejr.269.1704443047364; Fri, 05 Jan 2024 00:24:07 -0800 (PST) Received: from claudiu-X670E-Pro-RS.. ([82.78.167.5]) by smtp.gmail.com with ESMTPSA id j15-20020a1709064b4f00b00a28e759a447sm596198ejv.213.2024.01.05.00.24.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jan 2024 00:24:07 -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, richardcochran@gmail.com, p.zabel@pengutronix.de, yoshihiro.shimoda.uh@renesas.com, wsa+renesas@sang-engineering.com Cc: netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, claudiu.beznea@tuxon.dev, geert+renesas@glider.be, Claudiu Beznea Subject: [PATCH net-next v3 01/19] net: ravb: Let IP-specific receive function to interrogate descriptors Date: Fri, 5 Jan 2024 10:23:21 +0200 Message-Id: <20240105082339.1468817-2-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240105082339.1468817-1-claudiu.beznea.uj@bp.renesas.com> References: <20240105082339.1468817-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: 1787238120484882521 X-GMAIL-MSGID: 1787238120484882521 From: Claudiu Beznea ravb_poll() initial code used to interrogate the first descriptor of the RX queue in case gPTP is false to determine if ravb_rx() should be called. This is done for non-gPTP IPs. For gPTP IPs the driver PTP-specific information was used to determine if receive function should be called. As every IP has its own receive function that interrogates the RX descriptors list in the same way the ravb_poll() was doing there is no need to double check this in ravb_poll(). Removing the code from ravb_poll() leads to a cleaner code. Reviewed-by: Sergey Shtylyov Signed-off-by: Claudiu Beznea --- Changes in v3: - collected Sergey's tag Changes in v2: - addressed review comments and keep stale code out of this patch drivers/net/ethernet/renesas/ravb_main.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c index 8649b3e90edb..921f645a7218 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -1288,25 +1288,16 @@ static int ravb_poll(struct napi_struct *napi, int budget) struct net_device *ndev = napi->dev; struct ravb_private *priv = netdev_priv(ndev); const struct ravb_hw_info *info = priv->info; - bool gptp = info->gptp || info->ccc_gac; - struct ravb_rx_desc *desc; unsigned long flags; int q = napi - priv->napi; int mask = BIT(q); int quota = budget; - unsigned int entry; - if (!gptp) { - entry = priv->cur_rx[q] % priv->num_rx_ring[q]; - desc = &priv->gbeth_rx_ring[entry]; - } /* Processing RX Descriptor Ring */ /* Clear RX interrupt */ ravb_write(ndev, ~(mask | RIS0_RESERVED), RIS0); - if (gptp || desc->die_dt != DT_FEMPTY) { - if (ravb_rx(ndev, "a, q)) - goto out; - } + if (ravb_rx(ndev, "a, q)) + goto out; /* Processing TX Descriptor Ring */ spin_lock_irqsave(&priv->lock, flags); From patchwork Fri Jan 5 08:23:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: claudiu beznea X-Patchwork-Id: 185262 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:6f82:b0:100:9c79:88ff with SMTP id tb2csp6091833dyb; Fri, 5 Jan 2024 00:25:37 -0800 (PST) X-Google-Smtp-Source: AGHT+IH0yjkd3JCtxhHwJ4Ly5eCVJ214MhUBfxswQtS4uYQE4gAAkFiMeo7nikhErS0TTvyWCOeZ X-Received: by 2002:a17:902:6548:b0:1d4:1dac:9fa9 with SMTP id d8-20020a170902654800b001d41dac9fa9mr1571587pln.72.1704443137639; Fri, 05 Jan 2024 00:25:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704443137; cv=none; d=google.com; s=arc-20160816; b=CKT29HnBfV6FDyGX4VG8k/ht0qVIrt1aBXMNUGgr4m0UmtDAgB7RbMufXUaxwQ9ld/ BeJgd60g3nd3rtAe9cePOQQOsEr9ENZJ24KQZfHTP89GR264hKl1W5oDAKrqg+RJu/26 3MC+rIDUkURO/AlqVG+LvH9gP1ccdIXuouaFkW9tHDf/BNmi+VrSJ+uUD6N27bay+Xdp VG6ZgpuVFlslsndQcMtEKYU632TaWon80mJp5Mfrhsl0WIIYCV3WkgBTWjrro8LFJRQT HBQneQI6RcS6FiUmsCxytdAhuArGFsTUHzlwwuq8GuSpmiCWZl5bGop4TxShsZLtGb1D 4RMA== ARC-Message-Signature: i=1; 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=Du/ZkBe5Bruy+m802sIrEfXmqTMIQWCN8WeGhFg9WDY=; fh=qryrdWWtksp4Ojh0keXejXriHeHARah4mOGZkuZ1jnk=; b=AhD4jfnq+te5fzWCgiLdOmd5zyEQbBsjrBP3xiDnpf5eeHav4ddja6bvN2CHnMXOmt CGMlgmlAI55HPkNmIGzU381Epn4Mqjn4mihSFS37k/bjSkX0KULEF7o8xB3uRxGQs2za +KidyFYhwu03RKdJ7U892Mh80bbxapdYiMYIde9gOapbDfMBwHg7uLPFeWn50PyKQixI OfVIrHUi7spuMhxUTPAA8XuJpchY1ElB51TTLrnzGlqcjD470swb9E6g8pkD4WeniSFY WkEKB6PEnAIXopmmxPyZO4vZoygK9MRzPBG1yp+W/WOrWwQt0ApKs68lln4viFQVHFOv Pu9w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@tuxon.dev header.s=google header.b=fmcXBnBJ; spf=pass (google.com: domain of linux-kernel+bounces-17581-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-17581-ouuuleilei=gmail.com@vger.kernel.org" Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id l10-20020a170903120a00b001d495d6aeeesi880929plh.336.2024.01.05.00.25.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jan 2024 00:25:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-17581-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@tuxon.dev header.s=google header.b=fmcXBnBJ; spf=pass (google.com: domain of linux-kernel+bounces-17581-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-17581-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 677E4B22008 for ; Fri, 5 Jan 2024 08:25:12 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5B4FB22F07; Fri, 5 Jan 2024 08:24:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b="fmcXBnBJ" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-lf1-f54.google.com (mail-lf1-f54.google.com [209.85.167.54]) (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 826C9225A6 for ; Fri, 5 Jan 2024 08:24:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tuxon.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=tuxon.dev Received: by mail-lf1-f54.google.com with SMTP id 2adb3069b0e04-50ea9daac4cso1492367e87.3 for ; Fri, 05 Jan 2024 00:24:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1704443050; x=1705047850; 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=Du/ZkBe5Bruy+m802sIrEfXmqTMIQWCN8WeGhFg9WDY=; b=fmcXBnBJ4iEYJTobJ6MYmZBd/d4pm9fQdsfZ17PlMLtc56o6wDHFWpzJPJF3YaEl1G x6vETBI1aCjy6R/71R/h0rMWrufTXeMEYeq/9tfY52GoZ3fzN9SLNcT1z1lsSWToIXgV lrgV8YLQmIvsCrIrFzz9f32VQlJsJYEvURAAkxGhyxHB082N2QNfzUzGRMDcHwIL8mWW Q553Yi26QyjD3Chy2tuCCciFtVSRPoqMFUhLvn9mD5l87uQ0f97u0ycoM7qFu+FCM2a/ K5PTDrl3r9pPb26cZhKvwVolUgPi1BhOF3Vqt7zOqBQ/FHoRKQPKZXcMfGluSLMdk3BW NcYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704443050; x=1705047850; 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=Du/ZkBe5Bruy+m802sIrEfXmqTMIQWCN8WeGhFg9WDY=; b=gMJzkYbx5f10NmoxJfKR0ou0Uy2uhZ8il7vsqkppl5iikdh5pZXIgWwFB4o7DeZEyY dLnV9YbstfqBKRzJ4xor9mpqzU70pOtJ0Ma74adNDzV8JxHYqVXhntBLgeDhhzXaPigl fdEYhtI/orTZTyiH03VnaKaLf7iXqtnqsAfc42lXvRTKvnAXnQCe76X37VtjBKkI7hCt DZZ35kWqL/3rHQzXTXO0YKbt06RNoKzJw4yTTb991FBs0fhE+FmLmb+0dVa5poDIvivq o6sEZ+nF1XK1ltKBxfuN29NUIB9r5LvWFNZfzTD4ktadJtQPRROFKOA6J/9UqrSXC70r FzZg== X-Gm-Message-State: AOJu0Yxc1G+2CugLfRjG1BNhkH9Nl/yycPI6/8/zlTeHRVDlYzSlTuJs g/R+lJWauA2xZf0SnPArt2doqmfmbSPnTA== X-Received: by 2002:a19:7906:0:b0:50e:74ec:75f4 with SMTP id u6-20020a197906000000b0050e74ec75f4mr887158lfc.115.1704443050546; Fri, 05 Jan 2024 00:24:10 -0800 (PST) Received: from claudiu-X670E-Pro-RS.. ([82.78.167.5]) by smtp.gmail.com with ESMTPSA id j15-20020a1709064b4f00b00a28e759a447sm596198ejv.213.2024.01.05.00.24.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jan 2024 00:24:10 -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, richardcochran@gmail.com, p.zabel@pengutronix.de, yoshihiro.shimoda.uh@renesas.com, wsa+renesas@sang-engineering.com Cc: netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, claudiu.beznea@tuxon.dev, geert+renesas@glider.be, Claudiu Beznea Subject: [PATCH net-next v3 02/19] net: ravb: Rely on PM domain to enable gptp_clk Date: Fri, 5 Jan 2024 10:23:22 +0200 Message-Id: <20240105082339.1468817-3-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240105082339.1468817-1-claudiu.beznea.uj@bp.renesas.com> References: <20240105082339.1468817-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: 1787238167411723889 X-GMAIL-MSGID: 1787238167411723889 From: Claudiu Beznea ravb_rzv2m_hw_info::gptp_ref_clk is enabled only for RZ/V2M. RZ/V2M is an ARM64-based device which selects power domains by default and CONFIG_PM. The RZ/V2M Ethernet DT node has proper power-domain binding available in device tree from the commit that added the Ethernet node. (4872ca1f92b0 ("arm64: dts: renesas: r9a09g011: Add ethernet nodes")). Power domain support was available in the rzg2l-cpg.c driver when the Ethernet DT node has been enabled in RZ/V2M device tree. (ef3c613ccd68 ("clk: renesas: Add CPG core wrapper for RZ/G2L SoC")). Thus, remove the explicit clock enable for gptp_clk (and treat it as the other clocks are treated) as it is not needed and removing it doesn't break the ABI according to the above explanations. By removing the enable/disable operation from the driver we can add runtime PM support (which operates on clocks) w/o the need to handle the gptp_clk in the Ethernet driver functions like ravb_runtime_nop(). PM domain does all that is needed. Reviewed-by: Sergey Shtylyov Signed-off-by: Claudiu Beznea --- Changes in v3: - none Changes in v2: - collected tags drivers/net/ethernet/renesas/ravb_main.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c index 921f645a7218..1374dc11a7d1 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -2780,7 +2780,6 @@ static int ravb_probe(struct platform_device *pdev) error = PTR_ERR(priv->gptp_clk); goto out_disable_refclk; } - clk_prepare_enable(priv->gptp_clk); } ndev->max_mtu = info->rx_max_buf_size - (ETH_HLEN + VLAN_HLEN + ETH_FCS_LEN); @@ -2806,7 +2805,7 @@ static int ravb_probe(struct platform_device *pdev) /* Set GTI value */ error = ravb_set_gti(ndev); if (error) - goto out_disable_gptp_clk; + goto out_disable_refclk; /* Request GTI loading */ ravb_modify(ndev, GCCR, GCCR_LTI, GCCR_LTI); @@ -2826,7 +2825,7 @@ static int ravb_probe(struct platform_device *pdev) "Cannot allocate desc base address table (size %d bytes)\n", priv->desc_bat_size); error = -ENOMEM; - goto out_disable_gptp_clk; + goto out_disable_refclk; } for (q = RAVB_BE; q < DBAT_ENTRY_NUM; q++) priv->desc_bat[q].die_dt = DT_EOS; @@ -2889,8 +2888,6 @@ static int ravb_probe(struct platform_device *pdev) /* Stop PTP Clock driver */ if (info->ccc_gac) ravb_ptp_stop(ndev); -out_disable_gptp_clk: - clk_disable_unprepare(priv->gptp_clk); out_disable_refclk: clk_disable_unprepare(priv->refclk); out_release: @@ -2925,7 +2922,6 @@ static void ravb_remove(struct platform_device *pdev) ravb_set_opmode(ndev, CCC_OPC_RESET); - clk_disable_unprepare(priv->gptp_clk); clk_disable_unprepare(priv->refclk); pm_runtime_put_sync(&pdev->dev); From patchwork Fri Jan 5 08:23:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: claudiu beznea X-Patchwork-Id: 185261 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:6f82:b0:100:9c79:88ff with SMTP id tb2csp6091808dyb; Fri, 5 Jan 2024 00:25:32 -0800 (PST) X-Google-Smtp-Source: AGHT+IHoXRoyfObR2MQoLIXMV9Lb0M29jJCNlEaoQ2hp2ZGE8nHkQEu7GSwgMJx3iUwWqQSy16s4 X-Received: by 2002:ac2:4ecc:0:b0:50e:3e13:e142 with SMTP id p12-20020ac24ecc000000b0050e3e13e142mr737110lfr.118.1704443131859; Fri, 05 Jan 2024 00:25:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704443131; cv=none; d=google.com; s=arc-20160816; b=JMmaih1kD/BZbHQXK72Zef1MWgIxJALAfwvp8UEBCG+5hf2NTXa8IJUxd8cTKq/b6r 15q6jmf6vnCFslKdfC5CmzeBwuJUbxNEOwFNkFd4HiJCo2dQZBz7fObpbDKcDU5or22l UV95c7R4gmI+lCraNy03LhBLjjbZaivs1NOht7ucICPyDaNN8g4D/HNGZ5/CD3mpClXZ O6h3jMoC77Wv5j85uXslFjlOd+5jfA0BZ04Q2TPIAZ2ux7qkWpqFn7Ko6MB3hxwjn1qi Im2MCQTNUO34Mpc7/h+X+10voF5TL3Bamg2yq6+S2OwlK2J8jCTWvl7dndLPnkdUaOUE masw== ARC-Message-Signature: i=1; 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=p5wciRojDeq9cu3DUNng1ZDH9KltXB/o+T6WijHm3tQ=; fh=qryrdWWtksp4Ojh0keXejXriHeHARah4mOGZkuZ1jnk=; b=uhCjqKBFtSD63Rf+622jAEcr5xHGp4TljsBAAjcdvXsnk9YFoabs8sWSGgR25Yw9NE exB+aP+u0cvzL1x9zZLG5BY4wn9IIBBp1NYWqFVatx8RCGAFf2NXeQFGPUshipnDkcpV HXtSUL/3TQq5hv/HOBJi2ymZ75LuXi0htTlcB3YadXG8fskjHoV5SzgZDk98J9zaV0c6 +d+b7J6BCsnenJcXbtPGdIIf2WaVM3aTlX9Gvw9FjkKi4pUgpFBrLpEUMmmWiJIhykYu CkGekY+/GH1z0BLYYmCPz5chudX40saRfVE7stRY8Z304s5WjVz01Ukhi5h7sodnVxlp ZgnA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@tuxon.dev header.s=google header.b=OEBXK9LX; spf=pass (google.com: domain of linux-kernel+bounces-17582-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-17582-ouuuleilei=gmail.com@vger.kernel.org" Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id 18-20020a508752000000b00553dc96be61si438878edv.285.2024.01.05.00.25.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jan 2024 00:25:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-17582-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=OEBXK9LX; spf=pass (google.com: domain of linux-kernel+bounces-17582-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-17582-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 5777D1F23733 for ; Fri, 5 Jan 2024 08:25:31 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7946F241F4; Fri, 5 Jan 2024 08:24:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b="OEBXK9LX" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-ej1-f45.google.com (mail-ej1-f45.google.com [209.85.218.45]) (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 A91EE22EFD for ; Fri, 5 Jan 2024 08:24:16 +0000 (UTC) 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-ej1-f45.google.com with SMTP id a640c23a62f3a-a26f73732c5so139453466b.3 for ; Fri, 05 Jan 2024 00:24:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1704443055; x=1705047855; 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=p5wciRojDeq9cu3DUNng1ZDH9KltXB/o+T6WijHm3tQ=; b=OEBXK9LXXPkMC8AeSYQ/SnnEHJSJEBC4Rh6xZeoYIOf781rBppmx2Zlw/SVBSZiK/P BpfDutEz2tvJU+LaiOqOCb0ffw7BTfNiVgs6xpsWtdTgJS9FezBBxuQjXnGh96Q1SCeb yxCdOEtZq8rXT3TplgBPb2NN9pYt3dZL/VtHdgGk8wy75yF6IQy+BtyXAgiuMwEGflC7 BH2kUABzKEhMkegREn6TroPc5G3TCFJ0G2IAOFyBWNhgqTMX0ckoB63yKIqyD1qEPCSB Ju6SWLzzXXbKeKvaCwmQbJn/sEEIinDHClM0k603+rO9DpWx2ssI/bVBcVXX01nBLQOJ emWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704443055; x=1705047855; 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=p5wciRojDeq9cu3DUNng1ZDH9KltXB/o+T6WijHm3tQ=; b=DYOkt4Lc8AWirD2jeF+98ePuorWRm+QPFRZDEL9Us+shJBL9zpnJK5TIYRFlSgFivO kWU4Z22jxzvQmz2YXENJxeGIm2ZvRn4EK3cd8mTxQpoTeE5TsPsiwq+sGIJubR84WLtv p3AmWL279i+nosI/OE64z32eMTEu/f2Grf2FXItdlJnP82Y5+jMNQ/j1rGt/LCrnCaDg eOX6z0OvgobZ2Vb70MGYaSJbbePFysnjVMIslXwA0DjZhR3Ogf9ZrAK1xWpSKsioYh+g 87NwDu1TWT/nVwQBLaFwEHf1rPodZjhCzKjeu0NLIu/TH34tnVssDZkBCcGacb8yMAtP zIgw== X-Gm-Message-State: AOJu0YxroJgKHgB3rsrfHSmd01LUFYlOpisLLTcZMF0/ND8qhCbdjIts zqmk8/+T1orrc/a7GHkVTQ2f7fts8pJB5A== X-Received: by 2002:a17:907:76ac:b0:a28:b9b8:2f8c with SMTP id jw12-20020a17090776ac00b00a28b9b82f8cmr792621ejc.152.1704443055187; Fri, 05 Jan 2024 00:24:15 -0800 (PST) Received: from claudiu-X670E-Pro-RS.. ([82.78.167.5]) by smtp.gmail.com with ESMTPSA id j15-20020a1709064b4f00b00a28e759a447sm596198ejv.213.2024.01.05.00.24.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jan 2024 00:24:14 -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, richardcochran@gmail.com, p.zabel@pengutronix.de, yoshihiro.shimoda.uh@renesas.com, wsa+renesas@sang-engineering.com Cc: netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, claudiu.beznea@tuxon.dev, geert+renesas@glider.be, Claudiu Beznea Subject: [PATCH net-next v3 03/19] net: ravb: Make reset controller support mandatory Date: Fri, 5 Jan 2024 10:23:23 +0200 Message-Id: <20240105082339.1468817-4-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240105082339.1468817-1-claudiu.beznea.uj@bp.renesas.com> References: <20240105082339.1468817-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: 1787238161011086789 X-GMAIL-MSGID: 1787238161011086789 From: Claudiu Beznea On the RZ/G3S SoC the reset controller is mandatory for the IP to work. The device tree binding documentation for the ravb driver specifies that the resets are mandatory. Based on this, make the resets mandatory also in driver for all ravb devices. Reviewed-by: Sergey Shtylyov Reviewed-by: Geert Uytterhoeven Signed-off-by: Claudiu Beznea --- Changes in v3: - none Changes in v2: - collected tags drivers/net/ethernet/renesas/ravb_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c index 1374dc11a7d1..ce053047a9f2 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -2645,7 +2645,7 @@ static int ravb_probe(struct platform_device *pdev) return -EINVAL; } - rstc = devm_reset_control_get_optional_exclusive(&pdev->dev, NULL); + rstc = devm_reset_control_get_exclusive(&pdev->dev, NULL); if (IS_ERR(rstc)) return dev_err_probe(&pdev->dev, PTR_ERR(rstc), "failed to get cpg reset\n"); From patchwork Fri Jan 5 08:23:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: claudiu beznea X-Patchwork-Id: 185264 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:6f82:b0:100:9c79:88ff with SMTP id tb2csp6091878dyb; Fri, 5 Jan 2024 00:25:50 -0800 (PST) X-Google-Smtp-Source: AGHT+IG0udbr1E/R72nAtQLcpdkV/R5Cg78bLtOrSQPECWjPaaE4ZW/pjDLpy+14LwgMYxSmNCZQ X-Received: by 2002:a37:ac08:0:b0:781:573d:361a with SMTP id e8-20020a37ac08000000b00781573d361amr1758984qkm.55.1704443149894; Fri, 05 Jan 2024 00:25:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704443149; cv=none; d=google.com; s=arc-20160816; b=NTv8byYgboneHFU3JHOHmnDzs0B9N6rS4YW1n/FwjTHP0GTjblsYXlJDdqLlvZRgnQ bSpX4J67vP654mToFai/r/uO5gzukMcICycJ9g7HWqfkKCTkaiAFk605kJbf+cJeZyWc 6tEy2hV9mKhfk3yEN0wnPEGqq+gElfGQPi30tdFv/aqT87KebdU24IkuhYJOknEPm2at E5/K1iqv5XJjVc3DyR8pdA6vZdjINP+lFHXA9g69j3SxewXUeVLX6d0NuVKTQ31dx+aX 0GJa4ToK3ye7p/WtZD2zpqNVNR4Hu7XNF5i+Ycv/Hr6MbCZ5ZVGWhKWJoD8CwCkkdr5y 4Vhg== ARC-Message-Signature: i=1; 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=tDs9Akz57womT08DVky7rFMtepErNq8iSOIi4YmQXqE=; fh=qryrdWWtksp4Ojh0keXejXriHeHARah4mOGZkuZ1jnk=; b=H512jjLyNoikOty4Jv71D7xl8wbJulIFsI3ijImVf0+Qr52uxgOOyVPLtLVv8D7SlM QAtWBBt/tcVj1Op3Q69tR+0v6fCNi4ioxzlAGjV+vIAHe8WUWqpdhCkNG+MgDcnvyTL5 UQMqdrLfzNb8hpZex+MF8dR2d1PXJpSawzvDiDZanyP8qcEakixJDm3uZF6+z7NY4Rxe hl+DpOMMkGzGpNcCYElaDSu+K8lbz9snn0cIOHcJGlAO32v3AUDJ3rgNCzck7keSGo8J zJ6A2xQlKwnD0hGRA9XS3d7SgRdCbGfnSZ8/o5yQSsdjdO5qCxdK873UBPvwLhkbj2wc WjkQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@tuxon.dev header.s=google header.b=gz0z3JkX; spf=pass (google.com: domain of linux-kernel+bounces-17583-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-17583-ouuuleilei=gmail.com@vger.kernel.org" Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id br18-20020a05620a461200b00781e1787c1csi1371135qkb.507.2024.01.05.00.25.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jan 2024 00:25:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-17583-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@tuxon.dev header.s=google header.b=gz0z3JkX; spf=pass (google.com: domain of linux-kernel+bounces-17583-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-17583-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 AD09D1C219CB for ; Fri, 5 Jan 2024 08:25:49 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6DDD524B36; Fri, 5 Jan 2024 08:24:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b="gz0z3JkX" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-ej1-f51.google.com (mail-ej1-f51.google.com [209.85.218.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 70D8B241F1 for ; Fri, 5 Jan 2024 08:24:21 +0000 (UTC) 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-ej1-f51.google.com with SMTP id a640c23a62f3a-a293f2280c7so31057266b.1 for ; Fri, 05 Jan 2024 00:24:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1704443060; x=1705047860; 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=tDs9Akz57womT08DVky7rFMtepErNq8iSOIi4YmQXqE=; b=gz0z3JkXdw3ziKjIWQv3Mszf6ZW+c+Aom2V903pFx32D7s4lR2I7AuDNqtB/VU/RZu c4rAAbfc+thC7JCy97nj+MLldtRlRW8Wamn7KW5wzb6MGYDedKSUz45rnXGse6IeJqN4 oV1FU8oD6tHcLf/gqG0UzBOjDH1E6v7aTJ4iGWqe4DvyZNSQ4V9gvy8FCUZ/gjDCDRYz XQee16CILcuIGjwpwOXczlwGS7g9huy/KBEpdRbY2QaVUIrBDGzrJ3Hr4Kbf1agiacal IsnBGo7/wjV1T9sUolRl7YC8ho9+nPYANKIQAit8QKAZvVbCHGJmEGYLifgYDVrqkG/m n2Aw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704443060; x=1705047860; 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=tDs9Akz57womT08DVky7rFMtepErNq8iSOIi4YmQXqE=; b=Ihd/BEIE++Rn+Z5Q6nk5xTrbWF5Ilo2ZkhjrEqcOL11H+oMUtdl7LWr7T7MQs869hR gHnKuInM60RL7A9RiVZr8rQKndZ2DpJe1e5oUmgspbiBaXLcDBZFOjjEhwcgW5NsJYv6 Q78tnEebXo0OtKi2PjP6LL6iosOuYHlCgYiaS6TkaGbltwGN+L72Aqksd06RXkBGwh8P DDKUbMcQI+SR/Jr/HV1jCDW6RMDYTwBmu98w9L9af5IZorL338Agr2q+NYPvSNL6M9qI GnDQA/upVo779ME9VpirrvGr+lLgBrTwgISIuHGDg9m9keEcLcpBW9A7QaVCPMxs4vVy klug== X-Gm-Message-State: AOJu0Yyr1WUjM1KK6DcaxRK+yLsddrU4518+m7o6neU3j0VT8ZIWYXGN IdW5RsbICYxflDtM8hf4IC8yZCXFspwmpw== X-Received: by 2002:a17:906:5342:b0:a26:cab1:4076 with SMTP id j2-20020a170906534200b00a26cab14076mr407535ejo.125.1704443059724; Fri, 05 Jan 2024 00:24:19 -0800 (PST) Received: from claudiu-X670E-Pro-RS.. ([82.78.167.5]) by smtp.gmail.com with ESMTPSA id j15-20020a1709064b4f00b00a28e759a447sm596198ejv.213.2024.01.05.00.24.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jan 2024 00:24:19 -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, richardcochran@gmail.com, p.zabel@pengutronix.de, yoshihiro.shimoda.uh@renesas.com, wsa+renesas@sang-engineering.com Cc: netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, claudiu.beznea@tuxon.dev, geert+renesas@glider.be, Claudiu Beznea Subject: [PATCH net-next v3 04/19] net: ravb: Switch to SYSTEM_SLEEP_PM_OPS()/RUNTIME_PM_OPS() and pm_ptr() Date: Fri, 5 Jan 2024 10:23:24 +0200 Message-Id: <20240105082339.1468817-5-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240105082339.1468817-1-claudiu.beznea.uj@bp.renesas.com> References: <20240105082339.1468817-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: 1787238180678728817 X-GMAIL-MSGID: 1787238180678728817 From: Claudiu Beznea SET_SYSTEM_SLEEP_PM_OPS() and SET_RUNTIME_PM_OPS() are deprecated now and require __maybe_unused protection against unused function warnings. The usage of pm_ptr() and SYSTEM_SLEEP_PM_OPS()/RUNTIME_PM_OPS() allows the compiler to see the functions, thus suppressing the warning. Thus drop the __maybe_unused markings. Reviewed-by: Sergey Shtylyov Reviewed-by: Geert Uytterhoeven Signed-off-by: Claudiu Beznea --- Changes in v3: - none Changes in v2: - collected tags drivers/net/ethernet/renesas/ravb_main.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c index ce053047a9f2..53ca5d984e8b 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -2971,7 +2971,7 @@ static int ravb_wol_restore(struct net_device *ndev) return disable_irq_wake(priv->emac_irq); } -static int __maybe_unused ravb_suspend(struct device *dev) +static int ravb_suspend(struct device *dev) { struct net_device *ndev = dev_get_drvdata(dev); struct ravb_private *priv = netdev_priv(ndev); @@ -2993,7 +2993,7 @@ static int __maybe_unused ravb_suspend(struct device *dev) return ret; } -static int __maybe_unused ravb_resume(struct device *dev) +static int ravb_resume(struct device *dev) { struct net_device *ndev = dev_get_drvdata(dev); struct ravb_private *priv = netdev_priv(ndev); @@ -3052,7 +3052,7 @@ static int __maybe_unused ravb_resume(struct device *dev) return ret; } -static int __maybe_unused ravb_runtime_nop(struct device *dev) +static int ravb_runtime_nop(struct device *dev) { /* Runtime PM callback shared between ->runtime_suspend() * and ->runtime_resume(). Simply returns success. @@ -3065,8 +3065,8 @@ static int __maybe_unused ravb_runtime_nop(struct device *dev) } static const struct dev_pm_ops ravb_dev_pm_ops = { - SET_SYSTEM_SLEEP_PM_OPS(ravb_suspend, ravb_resume) - SET_RUNTIME_PM_OPS(ravb_runtime_nop, ravb_runtime_nop, NULL) + SYSTEM_SLEEP_PM_OPS(ravb_suspend, ravb_resume) + RUNTIME_PM_OPS(ravb_runtime_nop, ravb_runtime_nop, NULL) }; static struct platform_driver ravb_driver = { @@ -3074,7 +3074,7 @@ static struct platform_driver ravb_driver = { .remove_new = ravb_remove, .driver = { .name = "ravb", - .pm = &ravb_dev_pm_ops, + .pm = pm_ptr(&ravb_dev_pm_ops), .of_match_table = ravb_match_table, }, }; From patchwork Fri Jan 5 08:23:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: claudiu beznea X-Patchwork-Id: 185265 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:6f82:b0:100:9c79:88ff with SMTP id tb2csp6091974dyb; Fri, 5 Jan 2024 00:26:10 -0800 (PST) X-Google-Smtp-Source: AGHT+IGzvzhZq/jRl6xT8nOmbfRiKKjq6EP/geDEQ1Sua3KrOYmPgMZ+/RN8ZjrBN7FOt3KfdgbM X-Received: by 2002:a50:934a:0:b0:556:d1f4:628c with SMTP id n10-20020a50934a000000b00556d1f4628cmr1092140eda.30.1704443170173; Fri, 05 Jan 2024 00:26:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704443170; cv=none; d=google.com; s=arc-20160816; b=TKdQu7Vf5gb5PaLu9FjgeqPLNRdKd1kZ8YRuwALZ/zHrGwYJW37Xq3HpWteDeDtzR1 FQUFWOGVjtpBp6fcMOhjOP2wmcOxt2Mg12eprOV5SGuppwg8ffZ6YGGBA0HegrXR5QBf 77beQTJd4j6f2WqAJ/Oyytgx9iJCbTREhv3rFYghFGrVYzlFujioNTB74DzPwZV+eHOj YN9k6BIw1JtoHx2j+sGKXjQY0heozozCr962j1RhmuOvjFw0WsGFqWO/8DnQF0M+9nDl 8BPituHl5qmeCxKlLCvTRNQqiQxWc/3vhxNzWvKdGjP9lZfBP8TiL6+/SUo4JfjyPGfg sWMQ== ARC-Message-Signature: i=1; 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=SP3cnmFkRuyDUJ+465RvuWX7Oy5/w6W1mmuyIYEEwM4=; fh=qryrdWWtksp4Ojh0keXejXriHeHARah4mOGZkuZ1jnk=; b=Ig4+jQn6M+ul/y1iXNTJ2PeVdWChejGsos+rl/wgRJbrtdOZ2GCfubCN+GXGyfdQq3 W9d7uW4AJKUny6Rt1EbzneqQs7tds4GbfD8DFelgKS5ZG9n6d3FAoPBYiQUa0Xjyurka 8J2I0iPfBmV5BgBEsy3CZESgF6fEVm+I0P3YFmwz2kY6ekPpFSttqKzNmx+zm6C8mLe5 vCB4JUio72WCz3GuuZ0qUpup80PRYHVzMWC5OVytXgZEstyDmo8yAh/+aTOaPBNoy3Kn wjTsfuXc5KGuQ0M01DGmNuxrTQZUnuYTXeN5HsR1Sf5i41YPPvvRJQMqQIBXOeNHe/QG mMIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@tuxon.dev header.s=google header.b=ayMIp6M8; spf=pass (google.com: domain of linux-kernel+bounces-17584-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-17584-ouuuleilei=gmail.com@vger.kernel.org" Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id t16-20020a056402525000b0054c652bd5a9si437803edd.440.2024.01.05.00.26.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jan 2024 00:26:10 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-17584-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=ayMIp6M8; spf=pass (google.com: domain of linux-kernel+bounces-17584-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-17584-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 BEF451F21081 for ; Fri, 5 Jan 2024 08:26:09 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 058D1250F4; Fri, 5 Jan 2024 08:24:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b="ayMIp6M8" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-ej1-f48.google.com (mail-ej1-f48.google.com [209.85.218.48]) (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 EF37724B42 for ; Fri, 5 Jan 2024 08:24:25 +0000 (UTC) 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-ej1-f48.google.com with SMTP id a640c23a62f3a-a28e31563ebso148294466b.2 for ; Fri, 05 Jan 2024 00:24:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1704443064; x=1705047864; 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=SP3cnmFkRuyDUJ+465RvuWX7Oy5/w6W1mmuyIYEEwM4=; b=ayMIp6M8v4bYsx5jeVZkCsPqgEIaDPoVlYOSRMPj8H+v//hA9GP3XOimJsyoWz2oGm 7KnDSbuHG8n5IMAFxv/tBjLby1uHen/W44EYnuj2+33DcyT8vTAyrqnmgfOWuwoDkwaw BvFxn27QRIoD04IVc5Advnf3+VUcpq7IONN+VzEBcd2zl8YTDOyr/MQLkl3Pn/5u5IVq aE29OiiTCCvejreFgv9uFv5fyQggv+9fJtjAvWVBq2Ckf0bxm5d0HKxmJ0YGiH7pUKMW 5qJgWJzoPzrGJeq3nzzU8ZHHaQwBNI7LaLeU/6GnGKbLyB9/Q1HU+tKscDQfF8Ufp0wu 6Xxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704443064; x=1705047864; 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=SP3cnmFkRuyDUJ+465RvuWX7Oy5/w6W1mmuyIYEEwM4=; b=wYVr6/TouK4trqqnYYfJvSE7NgEUuvUD28to7ytYr+iUG3ws3Wu2EHeb0h22EsXAFp XNNaR65t3f4zTYtaXIgxIiZtSgXIclox4lpe5obmqLvyTKfuAcu5rLYt+SpzxFcNBRl9 X3HPvCl58zGU+DJJw74sAthCMJVTyEDozi2XhRCWurUTG0XWi4r7QNV7cX6Pnb4rciKR 2iSTmO0XC0hGA3GHgSFmGfobq9S9loewT9v11WM8BXuddP+N/6Mf//3aAWomGzHfbbDF zikfZBSlqXNUI065aevs2/oxdOxaBz8xXT4bQM1F4ejzFXfv2Mbvj+gPAqSllEnM2dF/ tbsA== X-Gm-Message-State: AOJu0YxIBHqm+SAEzMCgO6P0oMmlk0P3K/3C8v90Gl25IMSsO5kj1ydV gsv5SrioFk9QLRl9O6E3P+Ehv6pH3G1FYQ== X-Received: by 2002:a17:906:194d:b0:a28:7d8:1106 with SMTP id b13-20020a170906194d00b00a2807d81106mr907726eje.79.1704443064344; Fri, 05 Jan 2024 00:24:24 -0800 (PST) Received: from claudiu-X670E-Pro-RS.. ([82.78.167.5]) by smtp.gmail.com with ESMTPSA id j15-20020a1709064b4f00b00a28e759a447sm596198ejv.213.2024.01.05.00.24.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jan 2024 00:24:23 -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, richardcochran@gmail.com, p.zabel@pengutronix.de, yoshihiro.shimoda.uh@renesas.com, wsa+renesas@sang-engineering.com Cc: netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, claudiu.beznea@tuxon.dev, geert+renesas@glider.be, Claudiu Beznea Subject: [PATCH net-next v3 05/19] net: ravb: Use tabs instead of spaces Date: Fri, 5 Jan 2024 10:23:25 +0200 Message-Id: <20240105082339.1468817-6-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240105082339.1468817-1-claudiu.beznea.uj@bp.renesas.com> References: <20240105082339.1468817-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: 1787238201674664672 X-GMAIL-MSGID: 1787238201674664672 From: Claudiu Beznea Use tabs instead of spaces in the ravb_set_rate_gbeth() function. This aligns with the coding style requirements. Reviewed-by: Sergey Shtylyov Signed-off-by: Claudiu Beznea --- Changes in v3: - none Changes in v2: - collected tags drivers/net/ethernet/renesas/ravb_main.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c index 53ca5d984e8b..0731857c2a0c 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -96,13 +96,13 @@ static void ravb_set_rate_gbeth(struct net_device *ndev) struct ravb_private *priv = netdev_priv(ndev); switch (priv->speed) { - case 10: /* 10BASE */ + case 10: /* 10BASE */ ravb_write(ndev, GBETH_GECMR_SPEED_10, GECMR); break; - case 100: /* 100BASE */ + case 100: /* 100BASE */ ravb_write(ndev, GBETH_GECMR_SPEED_100, GECMR); break; - case 1000: /* 1000BASE */ + case 1000: /* 1000BASE */ ravb_write(ndev, GBETH_GECMR_SPEED_1000, GECMR); break; } From patchwork Fri Jan 5 08:23:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: claudiu beznea X-Patchwork-Id: 185266 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:6f82:b0:100:9c79:88ff with SMTP id tb2csp6092065dyb; Fri, 5 Jan 2024 00:26:28 -0800 (PST) X-Google-Smtp-Source: AGHT+IEWLHqjcbBuTlRJRKK+JFpotqWpg1YmL1V3kX6rk/b++2UWKY+9eplUJOdb0l7dYT++7ycy X-Received: by 2002:a05:620a:1263:b0:781:575b:8c04 with SMTP id b3-20020a05620a126300b00781575b8c04mr1801214qkl.24.1704443188357; Fri, 05 Jan 2024 00:26:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704443188; cv=none; d=google.com; s=arc-20160816; b=WCHUthUXcNtCgIc3K1uvGc4N+rOj2x5L8PYSFuWF0fOd41VEe1G+oVRpqM5hgj8yu5 TLcSylGxBOzu0vLqu+LO/PSYn0AKS4BqO5KQ+v4Wyelis3g7l61sZz95R2U/vEqTK/Iz ZjzSMhPiyf/pbFQiiezf2nUPCyu/10vsAnENpnzyMCwJz0ZexF0iWLnmF5L6aWqsP4Li mOVpMsY9fL9xLUnri6DAfq9ACgoWQvOSEj84xngzyjlp+5OCREse8BWNw3gN3xSgkYtC AnE9oP5RS9ukBcctzPpprQRof8ePstWL7dVvSImcTrok/I7G2LTTvvmTrpSzja/4EIaH hu3A== ARC-Message-Signature: i=1; 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=/2ZqOfc2YusgwP+oQ4T/Qs2/x8rT4twAhOHtA+/5S5g=; fh=qryrdWWtksp4Ojh0keXejXriHeHARah4mOGZkuZ1jnk=; b=XqQqec7R2+R0lTBgBliyoHoseSzXQc8TjH0c5pl1vF8qGLtw+UD0+ne/mT85KQ7mtb WyBgkiXedfxzzciV7T4MczsP383SjaGTyhavfIcLR1cvVSmuaaBp76V2wWsaanQDXMou yVufJID2+iK27Vdd8Z4ENfLZ92Bo8iKmoen+3MHG1AYf7s8W3m2rXXXFZwDfwD5dFs4F OAhLD8Cg2DZGUP85QUDQNskHm9O2MqiEZLkKrXXcBRoRegS4nYY/h0DLpqcbFxb1ey9F G2bdh45YN9bV/yIJ6Wb6jpAAsfibBjflNkwAgAOuIeASy0cS/kwxPpU64hCBgJiVzS4t ZwvQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@tuxon.dev header.s=google header.b=Z6eRd4Mc; spf=pass (google.com: domain of linux-kernel+bounces-17585-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-17585-ouuuleilei=gmail.com@vger.kernel.org" Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id dw27-20020a05620a601b00b0078160875057si1360911qkb.74.2024.01.05.00.26.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jan 2024 00:26:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-17585-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=Z6eRd4Mc; spf=pass (google.com: domain of linux-kernel+bounces-17585-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-17585-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 2B1B21C22B5C for ; Fri, 5 Jan 2024 08:26:28 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 44E9E286A2; Fri, 5 Jan 2024 08:24:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b="Z6eRd4Mc" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-ej1-f54.google.com (mail-ej1-f54.google.com [209.85.218.54]) (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 471DC2510D for ; Fri, 5 Jan 2024 08:24:30 +0000 (UTC) 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-ej1-f54.google.com with SMTP id a640c23a62f3a-a2814fa68eeso106303066b.1 for ; Fri, 05 Jan 2024 00:24:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1704443069; x=1705047869; 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=/2ZqOfc2YusgwP+oQ4T/Qs2/x8rT4twAhOHtA+/5S5g=; b=Z6eRd4MceanzZw9QupE9PURLXR/QlNSGPF5nUrkjvEgDW6Q08NOOHVnnew5Pmbf4oq lkbAvBwxzB1HN9QpWKPNQBRxmEpdU8776nXoofOhdyHqMXvSF55+Csc3tq+wdXdUju6c PfkfPGn3sMhhQzilbQXXaXpx9SQYE+YJ3HlPRfvcoExykQnM8I91QZUjbRA355ttc5g9 PMwZu5em1MT/NhI8AN89sIKrHlWf94yTlEMLHmtdw8qVObj7lG4HzVnKMeNWHOe9aTSN cH95pceAua3/khSYPcy16yjkZYTmBZSlnB53pPYa2B0IXn7JbHvreaZXHExX3XkHQKjB J6WQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704443069; x=1705047869; 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=/2ZqOfc2YusgwP+oQ4T/Qs2/x8rT4twAhOHtA+/5S5g=; b=Kt1HDP1aaWdcf5qp0HoymaTRm/1m06R83bPKsVWD9UuA9ngr8aAUY3MnrfysfwUXfk O0DKadC0jxd29H5VhO1nWr8MtXWrUMNx08LBOPrSGgLUKq8fWHou3JQqXk9r38Sm8788 Ld5LWVOpsUXuZuHWBEWpv0ja+i5iVu2v9EsBLnLD3MwCc/pnIdMNDIaFgdEswxwBzbt1 em1d/QTDiWlAa9QHXEPi9tO9sNZiUPzqs63Cw8YwJCwjFXvqjW11fJ7pN5VWXuR4ZAB4 pq0CYwqMg8BmB4S/H5pXfS0K81X/hCElJWBxtQkq8HlnmQrONBbWZn/9mFX00Hp06S41 Ktlg== X-Gm-Message-State: AOJu0YxGWIjw3gSohGSufJbBKoaxNHjqrv3/w9amaeCZ8xFl1tVfFCB7 imTOjqTht7PAML/deE3vUUMUyqIZSq3Epw== X-Received: by 2002:a17:906:8cc:b0:a23:713f:9851 with SMTP id o12-20020a17090608cc00b00a23713f9851mr584922eje.18.1704443069163; Fri, 05 Jan 2024 00:24:29 -0800 (PST) Received: from claudiu-X670E-Pro-RS.. ([82.78.167.5]) by smtp.gmail.com with ESMTPSA id j15-20020a1709064b4f00b00a28e759a447sm596198ejv.213.2024.01.05.00.24.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jan 2024 00:24:28 -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, richardcochran@gmail.com, p.zabel@pengutronix.de, yoshihiro.shimoda.uh@renesas.com, wsa+renesas@sang-engineering.com Cc: netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, claudiu.beznea@tuxon.dev, geert+renesas@glider.be, Claudiu Beznea Subject: [PATCH net-next v3 06/19] net: ravb: Assert/de-assert reset on suspend/resume Date: Fri, 5 Jan 2024 10:23:26 +0200 Message-Id: <20240105082339.1468817-7-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240105082339.1468817-1-claudiu.beznea.uj@bp.renesas.com> References: <20240105082339.1468817-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: 1787238220719588366 X-GMAIL-MSGID: 1787238220719588366 From: Claudiu Beznea RZ/G3S can go to deep sleep states where power to most of the SoC parts is off. When resuming from such a state, the Ethernet controller needs to be reinitialized. De-asserting the reset signal for it should also be done. Thus, add reset assert/de-assert on suspend/resume functions. On the resume function, the de-assert was not reverted in case of failures to give the user a chance to restore the interface (e.g., bringing down/up the interface) in case suspend/resume failed. Reviewed-by: Sergey Shtylyov Signed-off-by: Claudiu Beznea --- Changes in v3: - collected tags Changes in v2: - fixed typos in patch description and subject - on ravb_suspend() assert the reset signal in case interface is down; due to this the Sergey's Rb tag was left aside in this version drivers/net/ethernet/renesas/ravb_main.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c index 0731857c2a0c..844ac3306e93 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -2978,7 +2978,7 @@ static int ravb_suspend(struct device *dev) int ret; if (!netif_running(ndev)) - return 0; + goto reset_assert; netif_device_detach(ndev); @@ -2990,7 +2990,11 @@ static int ravb_suspend(struct device *dev) if (priv->info->ccc_gac) ravb_ptp_stop(ndev); - return ret; + if (priv->wol_enabled) + return ret; + +reset_assert: + return reset_control_assert(priv->rstc); } static int ravb_resume(struct device *dev) @@ -2998,7 +3002,11 @@ static int ravb_resume(struct device *dev) struct net_device *ndev = dev_get_drvdata(dev); struct ravb_private *priv = netdev_priv(ndev); const struct ravb_hw_info *info = priv->info; - int ret = 0; + int ret; + + ret = reset_control_deassert(priv->rstc); + if (ret) + return ret; /* If WoL is enabled set reset mode to rearm the WoL logic */ if (priv->wol_enabled) { From patchwork Fri Jan 5 08:23:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: claudiu beznea X-Patchwork-Id: 185267 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:6f82:b0:100:9c79:88ff with SMTP id tb2csp6092185dyb; Fri, 5 Jan 2024 00:26:50 -0800 (PST) X-Google-Smtp-Source: AGHT+IFQmK3cifbWKC/JCLvmj3m9zzy0zo2flhMl+OKS70ccOhatnU0acdjqnuOAUrk6naA+YI6M X-Received: by 2002:a50:fa91:0:b0:555:56bc:c966 with SMTP id w17-20020a50fa91000000b0055556bcc966mr908839edr.22.1704443210451; Fri, 05 Jan 2024 00:26:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704443210; cv=none; d=google.com; s=arc-20160816; b=Q9Gjq1GICpPMc7D69Yq985UZCWUArMoCi2bdamw37q0zTm5SVW/tt0/blTWYTMmfhu +1ciYL5M/XXeeHSaCxLGFCrAQuTX59bchZLCDG4x0mihOy1G1rrfgWM7pK34EnhVJhi9 4UFL2pmoQoc11eHfE+LHe8DY21vTiXgslRofNHxENmo3+fGU1Wf4ZMFdhDaiN//Wxz4G A5iDjgZoyj7D6p0xazevzrCKC2kPE8tsG5WO4XqNXnNUXw0qSPulVx7A2bW+MdUMTgoN jSsAfIEKkXp3m1kwrCIRBUntWwKtGAZRe3dHtkSMa/adsV+EME1FTvT53mSLuTpCVyKy fmFg== ARC-Message-Signature: i=1; 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=oIhZSvbC1t+imp+JG0gpa85K6fbvbfHzf6ZDHGxPd7Q=; fh=qryrdWWtksp4Ojh0keXejXriHeHARah4mOGZkuZ1jnk=; b=wF/dopPZ1VhCXST/IW0bzMchBmbzkIXyBQX56g31u8gHimElYg2j2K/H8CeQr2TZ2h jz+rh83HS40qxVGTK1MExQIHV1FcIzyOJbf2w1RQlY533Ehsl7zmczor5MkPETpTcjpO 5Am9omko5ivieeawGdoYECf11FXF30KvJ6vpmljr2sTxkut8xEunFIecuAAVrC2wBbUm yP7IlOwJhP218ASUEOBip31GmP7utZDaiHEsVAyaSeUhbGvtuSKIybZzviS1u/fQ2Msy QsXprVSMvZEkMsjy63+V/pNHCJ3yfhzEFRKKIAZd3BWeRCfx0V/ArnhouUKpfEguImwl y3cg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@tuxon.dev header.s=google header.b=mI9b+92k; spf=pass (google.com: domain of linux-kernel+bounces-17586-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-17586-ouuuleilei=gmail.com@vger.kernel.org" Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id a63-20020a509ec5000000b0055716150dd2si439011edf.468.2024.01.05.00.26.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jan 2024 00:26:50 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-17586-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=mI9b+92k; spf=pass (google.com: domain of linux-kernel+bounces-17586-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-17586-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 D9CE31F22AE5 for ; Fri, 5 Jan 2024 08:26:49 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EEB602C6B9; Fri, 5 Jan 2024 08:24:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b="mI9b+92k" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-ej1-f47.google.com (mail-ej1-f47.google.com [209.85.218.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 B59A628DCA for ; Fri, 5 Jan 2024 08:24:35 +0000 (UTC) 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-ej1-f47.google.com with SMTP id a640c23a62f3a-a26fa294e56so135561266b.0 for ; Fri, 05 Jan 2024 00:24:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1704443074; x=1705047874; 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=oIhZSvbC1t+imp+JG0gpa85K6fbvbfHzf6ZDHGxPd7Q=; b=mI9b+92k0e5D6cwpfmNjKVrh5szMyXGA3NUA5JrZdwa4xYZd+gRCuoevyfbjVW2AOf 0MjqUX743SmmAT6ArgG1hj7XdGEQSfMsU4GPJry8ZYQtdbggm4IYzTYZCkNV2/H5Vjua a6wrLIIkLUFYvCkFDJFl7hVKYvxKFCVxA8GQ2U4HT4nVzzU3nfs0K8dTNxuyy2DJm1n5 MWxTmw0zJqYkaC6GMqghop19tRHfR5QXNq+L6R+DvWtwlzgIu/t953qQL4myRtgBwHFc f1GEDXZiTz4SdcKMaKvn5HTSaprQEwyyX6t3W8qN54jW1NBzfnxZ6cO+HUq3WJ3YJq6x 3m1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704443074; x=1705047874; 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=oIhZSvbC1t+imp+JG0gpa85K6fbvbfHzf6ZDHGxPd7Q=; b=hrY/N5zH7rdmepYOpZATdx346JWymdy7U5Ko+5zLxE+T91wQ4lxg2nL/1DHCfqg0mf SDaW63JaQ08b4Sc7XnBdKSmNQXwoT6J+qAK8hZp0WqyskkW461zGE7cL5Mivh9P4+lt7 j6tvqBkmPYnoJXkyeYyLUxbR+WC8ZOVpI/3M0Wmm7M/iv9n6MOFPL3M+3nBicS32chwj JbE2k47R2ISESCMqvXsr25yU777Lbzm5BuduI3jedraGII7Q38NsBybyh4gz7TnoQuOr iVQF61Ti0K/8jOCLMvMc/pPczYbofVG/1xSbyDYYkVAooZo102TOqPK5uPFL/UdCiJh6 aUmw== X-Gm-Message-State: AOJu0YzhHkdtOVIUwd2lZn1wYOkzDI2A56ocMdAuh6w6rE9B350Bkbyg huxpdkFrDyKj8SjH+pKv7OKXw0mYFDphbg== X-Received: by 2002:a17:906:5fc1:b0:a28:b775:28a8 with SMTP id k1-20020a1709065fc100b00a28b77528a8mr807639ejv.90.1704443073900; Fri, 05 Jan 2024 00:24:33 -0800 (PST) Received: from claudiu-X670E-Pro-RS.. ([82.78.167.5]) by smtp.gmail.com with ESMTPSA id j15-20020a1709064b4f00b00a28e759a447sm596198ejv.213.2024.01.05.00.24.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jan 2024 00:24:33 -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, richardcochran@gmail.com, p.zabel@pengutronix.de, yoshihiro.shimoda.uh@renesas.com, wsa+renesas@sang-engineering.com Cc: netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, claudiu.beznea@tuxon.dev, geert+renesas@glider.be, Claudiu Beznea Subject: [PATCH net-next v3 07/19] net: ravb: Move reference clock enable/disable on runtime PM APIs Date: Fri, 5 Jan 2024 10:23:27 +0200 Message-Id: <20240105082339.1468817-8-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240105082339.1468817-1-claudiu.beznea.uj@bp.renesas.com> References: <20240105082339.1468817-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: 1787238243735802241 X-GMAIL-MSGID: 1787238243735802241 From: Claudiu Beznea Reference clock could be or not part of the power domain. If it is part of the power domain, the power domain takes care of propertly setting it. In case it is not part of the power domain and full runtime PM support is available in driver the clock will not be propertly disabled/enabled at runtime. For this, keep the prepare/unprepare operations in the driver's probe()/remove() functions and move the enable/disable in runtime PM functions. Along with it, the other clock request operations were moved close to reference clock request and prepare to have all the clock requests specific code grouped together. Reviewed-by: Sergey Shtylyov Signed-off-by: Claudiu Beznea --- Changes in v3: - squashed with patch 17/21 ("net: ravb: Keep clock request operations grouped together") from v2 - collected tags Changes in v2: - this patch is new and follows the recommendations proposed in the discussion of patch 08/13 ("net: ravb: Rely on PM domain to enable refclk") from v2 drivers/net/ethernet/renesas/ravb_main.c | 110 ++++++++++++----------- 1 file changed, 57 insertions(+), 53 deletions(-) diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c index 844ac3306e93..4673cc2faec0 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -2664,11 +2664,6 @@ static int ravb_probe(struct platform_device *pdev) if (error) goto out_free_netdev; - pm_runtime_enable(&pdev->dev); - error = pm_runtime_resume_and_get(&pdev->dev); - if (error < 0) - goto out_rpm_disable; - if (info->multi_irqs) { if (info->err_mgmt_irqs) irq = platform_get_irq_byname(pdev, "dia"); @@ -2679,7 +2674,7 @@ static int ravb_probe(struct platform_device *pdev) } if (irq < 0) { error = irq; - goto out_release; + goto out_reset_assert; } ndev->irq = irq; @@ -2697,10 +2692,37 @@ static int ravb_probe(struct platform_device *pdev) priv->num_rx_ring[RAVB_NC] = NC_RX_RING_SIZE; } + priv->clk = devm_clk_get(&pdev->dev, NULL); + if (IS_ERR(priv->clk)) { + error = PTR_ERR(priv->clk); + goto out_reset_assert; + } + + if (info->gptp_ref_clk) { + priv->gptp_clk = devm_clk_get(&pdev->dev, "gptp"); + if (IS_ERR(priv->gptp_clk)) { + error = PTR_ERR(priv->gptp_clk); + goto out_reset_assert; + } + } + + priv->refclk = devm_clk_get_optional(&pdev->dev, "refclk"); + if (IS_ERR(priv->refclk)) { + error = PTR_ERR(priv->refclk); + goto out_reset_assert; + } + clk_prepare(priv->refclk); + + platform_set_drvdata(pdev, ndev); + pm_runtime_enable(&pdev->dev); + error = pm_runtime_resume_and_get(&pdev->dev); + if (error < 0) + goto out_rpm_disable; + priv->addr = devm_platform_get_and_ioremap_resource(pdev, 0, &res); if (IS_ERR(priv->addr)) { error = PTR_ERR(priv->addr); - goto out_release; + goto out_rpm_put; } /* The Ether-specific entries in the device structure. */ @@ -2711,7 +2733,7 @@ static int ravb_probe(struct platform_device *pdev) error = of_get_phy_mode(np, &priv->phy_interface); if (error && error != -ENODEV) - goto out_release; + goto out_rpm_put; priv->no_avb_link = of_property_read_bool(np, "renesas,no-ether-link"); priv->avb_link_active_low = @@ -2724,14 +2746,14 @@ static int ravb_probe(struct platform_device *pdev) irq = platform_get_irq_byname(pdev, "ch24"); if (irq < 0) { error = irq; - goto out_release; + goto out_rpm_put; } priv->emac_irq = irq; for (i = 0; i < NUM_RX_QUEUE; i++) { irq = platform_get_irq_byname(pdev, ravb_rx_irqs[i]); if (irq < 0) { error = irq; - goto out_release; + goto out_rpm_put; } priv->rx_irqs[i] = irq; } @@ -2739,7 +2761,7 @@ static int ravb_probe(struct platform_device *pdev) irq = platform_get_irq_byname(pdev, ravb_tx_irqs[i]); if (irq < 0) { error = irq; - goto out_release; + goto out_rpm_put; } priv->tx_irqs[i] = irq; } @@ -2748,40 +2770,19 @@ static int ravb_probe(struct platform_device *pdev) irq = platform_get_irq_byname(pdev, "err_a"); if (irq < 0) { error = irq; - goto out_release; + goto out_rpm_put; } priv->erra_irq = irq; irq = platform_get_irq_byname(pdev, "mgmt_a"); if (irq < 0) { error = irq; - goto out_release; + goto out_rpm_put; } priv->mgmta_irq = irq; } } - priv->clk = devm_clk_get(&pdev->dev, NULL); - if (IS_ERR(priv->clk)) { - error = PTR_ERR(priv->clk); - goto out_release; - } - - priv->refclk = devm_clk_get_optional(&pdev->dev, "refclk"); - if (IS_ERR(priv->refclk)) { - error = PTR_ERR(priv->refclk); - goto out_release; - } - clk_prepare_enable(priv->refclk); - - if (info->gptp_ref_clk) { - priv->gptp_clk = devm_clk_get(&pdev->dev, "gptp"); - if (IS_ERR(priv->gptp_clk)) { - error = PTR_ERR(priv->gptp_clk); - goto out_disable_refclk; - } - } - ndev->max_mtu = info->rx_max_buf_size - (ETH_HLEN + VLAN_HLEN + ETH_FCS_LEN); ndev->min_mtu = ETH_MIN_MTU; @@ -2799,13 +2800,13 @@ static int ravb_probe(struct platform_device *pdev) /* Set AVB config mode */ error = ravb_set_config_mode(ndev); if (error) - goto out_disable_gptp_clk; + goto out_rpm_put; if (info->gptp || info->ccc_gac) { /* Set GTI value */ error = ravb_set_gti(ndev); if (error) - goto out_disable_refclk; + goto out_rpm_put; /* Request GTI loading */ ravb_modify(ndev, GCCR, GCCR_LTI, GCCR_LTI); @@ -2825,7 +2826,7 @@ static int ravb_probe(struct platform_device *pdev) "Cannot allocate desc base address table (size %d bytes)\n", priv->desc_bat_size); error = -ENOMEM; - goto out_disable_refclk; + goto out_rpm_put; } for (q = RAVB_BE; q < DBAT_ENTRY_NUM; q++) priv->desc_bat[q].die_dt = DT_EOS; @@ -2871,8 +2872,6 @@ 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); - platform_set_drvdata(pdev, ndev); - return 0; out_napi_del: @@ -2888,12 +2887,12 @@ static int ravb_probe(struct platform_device *pdev) /* Stop PTP Clock driver */ if (info->ccc_gac) ravb_ptp_stop(ndev); -out_disable_refclk: - clk_disable_unprepare(priv->refclk); -out_release: +out_rpm_put: pm_runtime_put(&pdev->dev); out_rpm_disable: pm_runtime_disable(&pdev->dev); + clk_unprepare(priv->refclk); +out_reset_assert: reset_control_assert(rstc); out_free_netdev: free_netdev(ndev); @@ -2922,10 +2921,9 @@ static void ravb_remove(struct platform_device *pdev) ravb_set_opmode(ndev, CCC_OPC_RESET); - clk_disable_unprepare(priv->refclk); - pm_runtime_put_sync(&pdev->dev); pm_runtime_disable(&pdev->dev); + clk_unprepare(priv->refclk); reset_control_assert(priv->rstc); free_netdev(ndev); platform_set_drvdata(pdev, NULL); @@ -3060,21 +3058,27 @@ static int ravb_resume(struct device *dev) return ret; } -static int ravb_runtime_nop(struct device *dev) +static int ravb_runtime_suspend(struct device *dev) { - /* Runtime PM callback shared between ->runtime_suspend() - * and ->runtime_resume(). Simply returns success. - * - * This driver re-initializes all registers after - * pm_runtime_get_sync() anyway so there is no need - * to save and restore registers here. - */ + struct net_device *ndev = dev_get_drvdata(dev); + struct ravb_private *priv = netdev_priv(ndev); + + clk_disable(priv->refclk); + return 0; } +static int ravb_runtime_resume(struct device *dev) +{ + struct net_device *ndev = dev_get_drvdata(dev); + struct ravb_private *priv = netdev_priv(ndev); + + return clk_enable(priv->refclk); +} + static const struct dev_pm_ops ravb_dev_pm_ops = { SYSTEM_SLEEP_PM_OPS(ravb_suspend, ravb_resume) - RUNTIME_PM_OPS(ravb_runtime_nop, ravb_runtime_nop, NULL) + RUNTIME_PM_OPS(ravb_runtime_suspend, ravb_runtime_resume, NULL) }; static struct platform_driver ravb_driver = { From patchwork Fri Jan 5 08:23:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: claudiu beznea X-Patchwork-Id: 185268 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:6f82:b0:100:9c79:88ff with SMTP id tb2csp6092289dyb; Fri, 5 Jan 2024 00:27:10 -0800 (PST) X-Google-Smtp-Source: AGHT+IFBRd/QSEA3a4qhlcDYy4Wc9sy7BqmrxLuZDL0tJ5nG5VSUh/Luu2jXj4PPzJEcCe/1wW/1 X-Received: by 2002:a05:6a21:a591:b0:199:3bcf:b286 with SMTP id gd17-20020a056a21a59100b001993bcfb286mr663217pzc.19.1704443230101; Fri, 05 Jan 2024 00:27:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704443230; cv=none; d=google.com; s=arc-20160816; b=Kk4QRh0EOFNplC4vFXRYM+P32Fi1y5YPVgmmJbl3UHQfoBWeCLf1vYPsgjZQFY4LrI 11WXAMMKHbld32ndA/oT2cH7ke6ETJ7qv4Cv9mIHcPXnUodqnPb7tUZcRpQpizGWi2Uc zNcWD2YZaXiTcvgqjjV9uxQ3wnsAnZwtEg0NP6kHrXi9+SKM65zMrX+UtiKg+4LTU/+O zSdK9lv1FRzi818Rrdmdru4Isrijrit5CiY5W5fA+3Yq6gn8kDjWsWk32MtT4pn8UAvb eAtfL8nSC+g8/ycWb9V9mIDACQEOPZLg9bICYpPaS2uuWFQ5wrwBjaAgDQ8Ehm8nsn2/ k9GA== ARC-Message-Signature: i=1; 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=bjkP3bUg7G9N2CL3axsg38PpNqEmMdH2TUngmv/vpOo=; fh=qryrdWWtksp4Ojh0keXejXriHeHARah4mOGZkuZ1jnk=; b=HdZvpmcHcXx9mliNqMABCwsNCpP5jRe7ubMPW+akX+nCW/UBZp51UCaAtS2MoeGCg7 rB5IsYiSzlstJfHPDioP2oAp+dofR8lfa2njPN833UAZPfk3RriedAEm6Yxb/BsKDn7j QcDNerFihzTwBBFxhAP9L5UhIa6yNioyX21LrtGbxX2tULj238gGYVXI/L5wc0lE5qQ6 QXVoFscq04CYG+iR574lAnZ1v0WLUu+ecgaFPJn5A4xtjFDaBT0knwfuVT1a4mg9rduj oD1076hqq6k4pxaC8DVhWZiIa91qFAIlY9miHqtkAvSHtVJMQ7iRIUiYJTqGv3t4fgWA /N+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@tuxon.dev header.s=google header.b=RfHXVaHw; spf=pass (google.com: domain of linux-kernel+bounces-17587-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-17587-ouuuleilei=gmail.com@vger.kernel.org" Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id e2-20020a656782000000b005cdc5c9d6a2si921868pgr.576.2024.01.05.00.27.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jan 2024 00:27:10 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-17587-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=RfHXVaHw; spf=pass (google.com: domain of linux-kernel+bounces-17587-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-17587-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 D4B7B287143 for ; Fri, 5 Jan 2024 08:27:09 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A99B12D052; Fri, 5 Jan 2024 08:24:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b="RfHXVaHw" X-Original-To: linux-kernel@vger.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 6AAA02C85B for ; Fri, 5 Jan 2024 08:24:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tuxon.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=tuxon.dev Received: by mail-lf1-f42.google.com with SMTP id 2adb3069b0e04-50eaa8b447bso1449494e87.1 for ; Fri, 05 Jan 2024 00:24:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1704443078; x=1705047878; 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=bjkP3bUg7G9N2CL3axsg38PpNqEmMdH2TUngmv/vpOo=; b=RfHXVaHwSHpdWlcAC2kR2dPyfjqhZyac1krFujhc2pZBjJaZZfjxfnkiljkM4Ctcmy c1v8/CUOsPhsrKdodG5sesn7kILRkKDiQpPXMRVGz1rGuh5yeSPc+qK+3QNJwpNgUrju nlNkfJ7XNA4qj+ZPK7bFrEP3Xkef2KrCwK7rpbZ+bX6JPQQYOayv4DR0B3xtA6TGHesF bgxZJ5bcqE53hvg5ejBb63eLEuTF81OfkE+36pqFGNivnDlew6l3oWkv6rmOaZ/+G5I+ 1O/t04EqLYLsCKHUD/Vjg92hYgumvH0VQyHOyQyomZ5oTfwIvz0RqxcHiPg7VIOFKh/a 1U7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704443078; x=1705047878; 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=bjkP3bUg7G9N2CL3axsg38PpNqEmMdH2TUngmv/vpOo=; b=UHHv4r3IxJPN3JKkNfeYZi6cSLxTGUqslEei9zt84YcknMQoj2xvntE9HOc4Oljnx1 Fi6c0UFSvu1RLPRneb/s5XN4T34heO8X0f4ZNTYEtMTr77eKgdUhCm/ShWgxYI0TQ5il e3+9hRTYS6fYuxsHVMQJ3EyfuYy60jiMxp6tUn+Ec4/L9ho0t7EnSMFHFjMSB3F1reNY 4eIemXk5ScymQEgtFcpgySlTWSjNxl8rm9Jr1wik/gZ8mULCrN4vSQezJtoPlhDQ7UKV NBpkudshF2T6A20PNLgJLBFSyJQOia97BCiFlf3Hnv3JtIneoIPVjz68LDfX8clslv8V o3SA== X-Gm-Message-State: AOJu0YyHERgSerDFHJOsjh9hSdhcb2MM7zA63aHJujsP74YJd/ld+F6O KURxBeF0RYh+LPS54R/ic70H9wosEoY1TQ== X-Received: by 2002:ac2:4e10:0:b0:50e:76d1:b9c5 with SMTP id e16-20020ac24e10000000b0050e76d1b9c5mr619041lfr.60.1704443078605; Fri, 05 Jan 2024 00:24:38 -0800 (PST) Received: from claudiu-X670E-Pro-RS.. ([82.78.167.5]) by smtp.gmail.com with ESMTPSA id j15-20020a1709064b4f00b00a28e759a447sm596198ejv.213.2024.01.05.00.24.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jan 2024 00:24:38 -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, richardcochran@gmail.com, p.zabel@pengutronix.de, yoshihiro.shimoda.uh@renesas.com, wsa+renesas@sang-engineering.com Cc: netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, claudiu.beznea@tuxon.dev, geert+renesas@glider.be, Claudiu Beznea Subject: [PATCH net-next v3 08/19] net: ravb: Move the IRQs get and request in the probe function Date: Fri, 5 Jan 2024 10:23:28 +0200 Message-Id: <20240105082339.1468817-9-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240105082339.1468817-1-claudiu.beznea.uj@bp.renesas.com> References: <20240105082339.1468817-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: 1787238264531973504 X-GMAIL-MSGID: 1787238264531973504 From: Claudiu Beznea The runtime PM implementation will disable clocks at the end of ravb_probe(). As some IP variants switch to reset mode as a result of setting module standby through clock disable APIs, to implement runtime PM the resource parsing and requesting are moved in the probe function and IP settings are moved in the open function. This is done because at the end of the probe some IP variants will switch anyway to reset mode and the registers content is lost. Also keeping only register specific operations in the ravb_open()/ravb_close() functions will make them faster. Commit moves IRQ requests to ravb_probe() to have all the IRQs ready when the interface is open. As now IRQs gets and requests are in a single place there is no need to keep intermediary data (like ravb_rx_irqs[] and ravb_tx_irqs[] arrays or IRQs in struct ravb_private). This is a preparatory change to add runtime PM support for all IP variants. Signed-off-by: Claudiu Beznea --- Changes in v3: - fixed typos in patch description - detailed patch description - reworked the code to have a single function doing IRQ get and request Changes in v2: - none; this patch is new drivers/net/ethernet/renesas/ravb.h | 4 - drivers/net/ethernet/renesas/ravb_main.c | 258 ++++++++--------------- 2 files changed, 90 insertions(+), 172 deletions(-) diff --git a/drivers/net/ethernet/renesas/ravb.h b/drivers/net/ethernet/renesas/ravb.h index e0f8276cffed..e3506888cca6 100644 --- a/drivers/net/ethernet/renesas/ravb.h +++ b/drivers/net/ethernet/renesas/ravb.h @@ -1089,10 +1089,6 @@ struct ravb_private { int msg_enable; int speed; int emac_irq; - int erra_irq; - int mgmta_irq; - int rx_irqs[NUM_RX_QUEUE]; - int tx_irqs[NUM_TX_QUEUE]; unsigned no_avb_link:1; unsigned avb_link_active_low:1; diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c index 4673cc2faec0..ac6488ffa29a 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -38,16 +38,6 @@ NETIF_MSG_RX_ERR | \ NETIF_MSG_TX_ERR) -static const char *ravb_rx_irqs[NUM_RX_QUEUE] = { - "ch0", /* RAVB_BE */ - "ch1", /* RAVB_NC */ -}; - -static const char *ravb_tx_irqs[NUM_TX_QUEUE] = { - "ch18", /* RAVB_BE */ - "ch19", /* RAVB_NC */ -}; - void ravb_modify(struct net_device *ndev, enum ravb_reg reg, u32 clear, u32 set) { @@ -1727,85 +1717,21 @@ static const struct ethtool_ops ravb_ethtool_ops = { .set_wol = ravb_set_wol, }; -static inline int ravb_hook_irq(unsigned int irq, irq_handler_t handler, - struct net_device *ndev, struct device *dev, - const char *ch) -{ - char *name; - int error; - - name = devm_kasprintf(dev, GFP_KERNEL, "%s:%s", ndev->name, ch); - if (!name) - return -ENOMEM; - error = request_irq(irq, handler, 0, name, ndev); - if (error) - netdev_err(ndev, "cannot request IRQ %s\n", name); - - return error; -} - /* Network device open function for Ethernet AVB */ static int ravb_open(struct net_device *ndev) { struct ravb_private *priv = netdev_priv(ndev); const struct ravb_hw_info *info = priv->info; - struct platform_device *pdev = priv->pdev; - struct device *dev = &pdev->dev; int error; napi_enable(&priv->napi[RAVB_BE]); if (info->nc_queues) napi_enable(&priv->napi[RAVB_NC]); - if (!info->multi_irqs) { - error = request_irq(ndev->irq, ravb_interrupt, IRQF_SHARED, - ndev->name, ndev); - if (error) { - netdev_err(ndev, "cannot request IRQ\n"); - goto out_napi_off; - } - } else { - error = ravb_hook_irq(ndev->irq, ravb_multi_interrupt, ndev, - dev, "ch22:multi"); - if (error) - goto out_napi_off; - error = ravb_hook_irq(priv->emac_irq, ravb_emac_interrupt, ndev, - dev, "ch24:emac"); - if (error) - goto out_free_irq; - error = ravb_hook_irq(priv->rx_irqs[RAVB_BE], ravb_be_interrupt, - ndev, dev, "ch0:rx_be"); - if (error) - goto out_free_irq_emac; - error = ravb_hook_irq(priv->tx_irqs[RAVB_BE], ravb_be_interrupt, - ndev, dev, "ch18:tx_be"); - if (error) - goto out_free_irq_be_rx; - error = ravb_hook_irq(priv->rx_irqs[RAVB_NC], ravb_nc_interrupt, - ndev, dev, "ch1:rx_nc"); - if (error) - goto out_free_irq_be_tx; - error = ravb_hook_irq(priv->tx_irqs[RAVB_NC], ravb_nc_interrupt, - ndev, dev, "ch19:tx_nc"); - if (error) - goto out_free_irq_nc_rx; - - if (info->err_mgmt_irqs) { - error = ravb_hook_irq(priv->erra_irq, ravb_multi_interrupt, - ndev, dev, "err_a"); - if (error) - goto out_free_irq_nc_tx; - error = ravb_hook_irq(priv->mgmta_irq, ravb_multi_interrupt, - ndev, dev, "mgmt_a"); - if (error) - goto out_free_irq_erra; - } - } - /* Device init */ error = ravb_dmac_init(ndev); if (error) - goto out_free_irq_mgmta; + goto out_napi_off; ravb_emac_init(ndev); /* Initialise PTP Clock driver */ @@ -1826,26 +1752,6 @@ static int ravb_open(struct net_device *ndev) if (info->gptp) ravb_ptp_stop(ndev); ravb_stop_dma(ndev); -out_free_irq_mgmta: - if (!info->multi_irqs) - goto out_free_irq; - if (info->err_mgmt_irqs) - free_irq(priv->mgmta_irq, ndev); -out_free_irq_erra: - if (info->err_mgmt_irqs) - free_irq(priv->erra_irq, ndev); -out_free_irq_nc_tx: - free_irq(priv->tx_irqs[RAVB_NC], ndev); -out_free_irq_nc_rx: - free_irq(priv->rx_irqs[RAVB_NC], ndev); -out_free_irq_be_tx: - free_irq(priv->tx_irqs[RAVB_BE], ndev); -out_free_irq_be_rx: - free_irq(priv->rx_irqs[RAVB_BE], ndev); -out_free_irq_emac: - free_irq(priv->emac_irq, ndev); -out_free_irq: - free_irq(ndev->irq, ndev); out_napi_off: if (info->nc_queues) napi_disable(&priv->napi[RAVB_NC]); @@ -2180,19 +2086,6 @@ static int ravb_close(struct net_device *ndev) cancel_work_sync(&priv->work); - if (info->multi_irqs) { - free_irq(priv->tx_irqs[RAVB_NC], ndev); - free_irq(priv->rx_irqs[RAVB_NC], ndev); - free_irq(priv->tx_irqs[RAVB_BE], ndev); - free_irq(priv->rx_irqs[RAVB_BE], ndev); - free_irq(priv->emac_irq, ndev); - if (info->err_mgmt_irqs) { - free_irq(priv->erra_irq, ndev); - free_irq(priv->mgmta_irq, ndev); - } - } - free_irq(ndev->irq, ndev); - if (info->nc_queues) napi_disable(&priv->napi[RAVB_NC]); napi_disable(&priv->napi[RAVB_BE]); @@ -2616,6 +2509,90 @@ static void ravb_parse_delay_mode(struct device_node *np, struct net_device *nde } } +static int ravb_setup_irq(struct ravb_private *priv, const char *irq_name, + const char *ch, int *irq, irq_handler_t handler) +{ + struct platform_device *pdev = priv->pdev; + struct net_device *ndev = priv->ndev; + struct device *dev = &pdev->dev; + const char *dev_name; + unsigned long flags; + int error; + + 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); + flags = 0; + } else { + dev_name = ndev->name; + *irq = platform_get_irq(pdev, 0); + flags = IRQF_SHARED; + } + if (*irq < 0) + return *irq; + + error = devm_request_irq(dev, *irq, handler, flags, dev_name, ndev); + if (error) + netdev_err(ndev, "cannot request IRQ %s\n", irq_name); + + return error; +} + +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; + + if (!info->multi_irqs) + return ravb_setup_irq(priv, NULL, NULL, &ndev->irq, ravb_interrupt); + + if (info->err_mgmt_irqs) { + irq_name = "dia"; + emac_irq_name = "line3"; + } else { + irq_name = "ch22"; + emac_irq_name = "ch24"; + } + + error = ravb_setup_irq(priv, irq_name, "ch22:multi", &ndev->irq, ravb_multi_interrupt); + if (error) + return error; + + error = ravb_setup_irq(priv, emac_irq_name, "ch24:emac", &priv->emac_irq, + ravb_emac_interrupt); + if (error) + return error; + + if (info->err_mgmt_irqs) { + error = ravb_setup_irq(priv, "err_a", "err_a", &irq, ravb_multi_interrupt); + if (error) + return error; + + error = ravb_setup_irq(priv, "mgmt_a", "mgmt_a", &irq, ravb_multi_interrupt); + if (error) + return error; + } + + error = ravb_setup_irq(priv, "ch0", "ch0:rx_be", &irq, ravb_be_interrupt); + if (error) + return error; + + error = ravb_setup_irq(priv, "ch1", "ch1:rx_nc", &irq, ravb_nc_interrupt); + if (error) + return error; + + error = ravb_setup_irq(priv, "ch18", "ch18:tx_be", &irq, ravb_be_interrupt); + if (error) + return error; + + return ravb_setup_irq(priv, "ch19", "ch19:tx_nc", &irq, ravb_nc_interrupt); +} + static void ravb_set_delay_mode(struct net_device *ndev) { struct ravb_private *priv = netdev_priv(ndev); @@ -2635,9 +2612,8 @@ static int ravb_probe(struct platform_device *pdev) struct reset_control *rstc; struct ravb_private *priv; struct net_device *ndev; - int error, irq, q; struct resource *res; - int i; + int error, q; if (!np) { dev_err(&pdev->dev, @@ -2664,20 +2640,6 @@ static int ravb_probe(struct platform_device *pdev) if (error) goto out_free_netdev; - if (info->multi_irqs) { - if (info->err_mgmt_irqs) - irq = platform_get_irq_byname(pdev, "dia"); - else - irq = platform_get_irq_byname(pdev, "ch22"); - } else { - irq = platform_get_irq(pdev, 0); - } - if (irq < 0) { - error = irq; - goto out_reset_assert; - } - ndev->irq = irq; - SET_NETDEV_DEV(ndev, &pdev->dev); priv = netdev_priv(ndev); @@ -2692,6 +2654,10 @@ static int ravb_probe(struct platform_device *pdev) priv->num_rx_ring[RAVB_NC] = NC_RX_RING_SIZE; } + error = ravb_setup_irqs(priv); + if (error) + goto out_reset_assert; + priv->clk = devm_clk_get(&pdev->dev, NULL); if (IS_ERR(priv->clk)) { error = PTR_ERR(priv->clk); @@ -2739,50 +2705,6 @@ static int ravb_probe(struct platform_device *pdev) priv->avb_link_active_low = of_property_read_bool(np, "renesas,ether-link-active-low"); - if (info->multi_irqs) { - if (info->err_mgmt_irqs) - irq = platform_get_irq_byname(pdev, "line3"); - else - irq = platform_get_irq_byname(pdev, "ch24"); - if (irq < 0) { - error = irq; - goto out_rpm_put; - } - priv->emac_irq = irq; - for (i = 0; i < NUM_RX_QUEUE; i++) { - irq = platform_get_irq_byname(pdev, ravb_rx_irqs[i]); - if (irq < 0) { - error = irq; - goto out_rpm_put; - } - priv->rx_irqs[i] = irq; - } - for (i = 0; i < NUM_TX_QUEUE; i++) { - irq = platform_get_irq_byname(pdev, ravb_tx_irqs[i]); - if (irq < 0) { - error = irq; - goto out_rpm_put; - } - priv->tx_irqs[i] = irq; - } - - if (info->err_mgmt_irqs) { - irq = platform_get_irq_byname(pdev, "err_a"); - if (irq < 0) { - error = irq; - goto out_rpm_put; - } - priv->erra_irq = irq; - - irq = platform_get_irq_byname(pdev, "mgmt_a"); - if (irq < 0) { - error = irq; - goto out_rpm_put; - } - priv->mgmta_irq = irq; - } - } - ndev->max_mtu = info->rx_max_buf_size - (ETH_HLEN + VLAN_HLEN + ETH_FCS_LEN); ndev->min_mtu = ETH_MIN_MTU; From patchwork Fri Jan 5 08:23:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: claudiu beznea X-Patchwork-Id: 185269 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:6f82:b0:100:9c79:88ff with SMTP id tb2csp6092393dyb; Fri, 5 Jan 2024 00:27:32 -0800 (PST) X-Google-Smtp-Source: AGHT+IESU6+zlTyRVfrgrBlBSuGhihip/TMTpmBGWIPW+ezQX9INeyuKe9obQOipdrB+8xHF+Cd4 X-Received: by 2002:a17:906:c18d:b0:a28:8f3d:7d8c with SMTP id g13-20020a170906c18d00b00a288f3d7d8cmr1009681ejz.32.1704443252308; Fri, 05 Jan 2024 00:27:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704443252; cv=none; d=google.com; s=arc-20160816; b=Rc6Tc9NAARrB3ty/yzsuLza8kyO7iOuCTXkidiQssWZLlu2xJylyyUZ7NEyVgA3mKp JOp2iUA6F8Hx/61Tu11sjJVAipDAkhAbu/WpxGgTLOdpUgB9tpFqJrgJxLbuvd+9jlk9 CWKcV3xZfKs9KSZqcLPSxEbGOfKd800d4B8xUxYOJuVpAbwTzp9CY1pbWb4fyCfKqKJX 4C7M7bEXNBvQq746OoVrINnclh7hPfyui4aMiDemARJq62Mhw6zcHm6mZq4JKjLVcLf+ bc16VLB0vhFcFHtOUiPuza54wTsom8E+RSu/YjLvaPyok8YnjGgHfl2qzVZTQbqAxb/w ZaCg== ARC-Message-Signature: i=1; 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=pNkp6YbeGh31n3yPVM/nkMGFmkaualv7xNSUaNAylPY=; fh=qryrdWWtksp4Ojh0keXejXriHeHARah4mOGZkuZ1jnk=; b=C72LfMK1cpda9d1ParAuz5qOB8dszNsiO7BL0lkvo2kr8f9O2XtS3oNg+gmHfZh962 9vEgdfs6j1ntFX9N5cqTb3qXEA1CHcK8gqir/h62wf4tx5IuFw8wbekkhMKDvCd96Gah ldojkGU5hu2LFLBqZpUCEhW3/0k9brlLx4DrF7PVcCIOhtqK3Re/oZjGhayBBmAQdSQs Psz4XnStZW+1NmmIidgSY8Fh78hrDoM6A/3BrwhV1bPVWgpvy6bpQ5SfogEgxfBl/GRT 9Gk4SAtkoqv/wIBVvISKBbISiJ3zcYTIyPg6MF5AI/toCvs0kb5I3DhRObHCijk5a297 WoIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@tuxon.dev header.s=google header.b=jqry+kZU; spf=pass (google.com: domain of linux-kernel+bounces-17588-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-17588-ouuuleilei=gmail.com@vger.kernel.org" Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id q21-20020a170906145500b00a28d2997fd6si423702ejc.137.2024.01.05.00.27.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jan 2024 00:27:32 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-17588-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=jqry+kZU; spf=pass (google.com: domain of linux-kernel+bounces-17588-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-17588-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 BCAAE1F23A95 for ; Fri, 5 Jan 2024 08:27:31 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8988F2D61B; Fri, 5 Jan 2024 08:24:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b="jqry+kZU" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-lf1-f45.google.com (mail-lf1-f45.google.com [209.85.167.45]) (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 28D002D059 for ; Fri, 5 Jan 2024 08:24:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tuxon.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=tuxon.dev Received: by mail-lf1-f45.google.com with SMTP id 2adb3069b0e04-50ea8fbf261so1461682e87.2 for ; Fri, 05 Jan 2024 00:24:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1704443083; x=1705047883; 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=pNkp6YbeGh31n3yPVM/nkMGFmkaualv7xNSUaNAylPY=; b=jqry+kZUXqb3w5Cluf74c62y5xJMYsLkJn3av5mb2LwHyQr8hlAZYyvP4sfTTawgyC jHJw1Is77PPgONwI9DwRn8wixauVKe1dpwZE2klqU1fdAKW0deNHCEjW0EWTln2PHtO6 jluADGCyUuixLraVI28Cl4aMFZmt1QJc7pZD/Q5jIXBlDgqezQDOpLqirbdoL8B0oiDT ZvTrzY8i439OhkyxzzK+3YnNa+PubqpGI+FfmY445IGHi11iO8rs5sCxZDm1gVkg9SNW 3clrYTXGDp6CDr88F4ADStNPocdVWRfpS4AnSng3w1+lkuEWFoQiaFprHQk7jWJWOk9F 386Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704443083; x=1705047883; 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=pNkp6YbeGh31n3yPVM/nkMGFmkaualv7xNSUaNAylPY=; b=oNLdYgzdW8U4s+yKDnPjzM9ertFfRE3zu5LqlJhqJSwEuliUbxgny+YWWd7NRKpMkG WVScdZUa7+5NvcRHK7Og3Stz+OfiTXsCUedBVH0057p8AYtLrLSDjQKtj+tZo88ti9dt YEXS3XmoEf+yGnwonR8yiiVnFRvovU3qdF3tFwyhA4fROM+VZFHcnzwqzA2McRPimK4Q ubkm4cXdN1GX5Y7Q6nP2GcbtCSu2AyxzsvK+BnWuS8I2zDLNdni9ei9VOqhSszk57H5N mGxKXCPCQdCHfP5FSgEEK/bLPLaGB8kMHoqe0ZtmsVPnkV/NfH1B1awb84D12v50xXqF +D5w== X-Gm-Message-State: AOJu0YwGd946Tkq1dmOQaSaUPbHIEhyRAs8+TAMJ2uMXPELJNnk4KVdC Qej0kg50eY9QLJp9sXpJeGxR2nHeTUx3Cw== X-Received: by 2002:a05:6512:3a8f:b0:50e:7e54:d1d4 with SMTP id q15-20020a0565123a8f00b0050e7e54d1d4mr1113999lfu.85.1704443083401; Fri, 05 Jan 2024 00:24:43 -0800 (PST) Received: from claudiu-X670E-Pro-RS.. ([82.78.167.5]) by smtp.gmail.com with ESMTPSA id j15-20020a1709064b4f00b00a28e759a447sm596198ejv.213.2024.01.05.00.24.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jan 2024 00:24:43 -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, richardcochran@gmail.com, p.zabel@pengutronix.de, yoshihiro.shimoda.uh@renesas.com, wsa+renesas@sang-engineering.com Cc: netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, claudiu.beznea@tuxon.dev, geert+renesas@glider.be, Claudiu Beznea Subject: [PATCH net-next v3 09/19] net: ravb: Split GTI computation and set operations Date: Fri, 5 Jan 2024 10:23:29 +0200 Message-Id: <20240105082339.1468817-10-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240105082339.1468817-1-claudiu.beznea.uj@bp.renesas.com> References: <20240105082339.1468817-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: 1787238288036346017 X-GMAIL-MSGID: 1787238288036346017 From: Claudiu Beznea ravb_set_gti() was computing the value of GTI based on the reference clock rate and then applied it to register. This was done on the driver's probe function. In order to implement runtime PM for all IP variants (as some IP variants switches to reset mode (and thus the registers content is lost) when module standby is configured through clock APIs) the GTI setup was split in 2 parts: one computing the value of the GTI register (done in the driver's probe function) and one applying the computed value to register (done in the driver's ndo_open API). Signed-off-by: Claudiu Beznea Reviewed-by: Sergey Shtylyov --- Changes in v3: - fixed typos in patch description - use u64 instead of uint64_t - remove ravb_wait() for setting GCCR.LTI Changes in v2: - none; this patch is new drivers/net/ethernet/renesas/ravb.h | 2 + drivers/net/ethernet/renesas/ravb_main.c | 96 ++++++++++++------------ 2 files changed, 52 insertions(+), 46 deletions(-) diff --git a/drivers/net/ethernet/renesas/ravb.h b/drivers/net/ethernet/renesas/ravb.h index e3506888cca6..268ccfafe7aa 100644 --- a/drivers/net/ethernet/renesas/ravb.h +++ b/drivers/net/ethernet/renesas/ravb.h @@ -1102,6 +1102,8 @@ struct ravb_private { const struct ravb_hw_info *info; struct reset_control *rstc; + + u32 gti_tiv; }; static inline u32 ravb_read(struct net_device *ndev, enum ravb_reg reg) diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c index ac6488ffa29a..f386a3b7effb 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -1717,6 +1717,50 @@ static const struct ethtool_ops ravb_ethtool_ops = { .set_wol = ravb_set_wol, }; +static void ravb_set_gti(struct net_device *ndev) +{ + struct ravb_private *priv = netdev_priv(ndev); + const struct ravb_hw_info *info = priv->info; + + if (!(info->gptp || info->ccc_gac)) + return; + + ravb_write(ndev, priv->gti_tiv, GTI); + + /* Request GTI loading */ + ravb_modify(ndev, GCCR, GCCR_LTI, GCCR_LTI); +} + +static int ravb_compute_gti(struct net_device *ndev) +{ + struct ravb_private *priv = netdev_priv(ndev); + const struct ravb_hw_info *info = priv->info; + struct device *dev = ndev->dev.parent; + unsigned long rate; + u64 inc; + + if (!(info->gptp || info->ccc_gac)) + return 0; + + if (info->gptp_ref_clk) + rate = clk_get_rate(priv->gptp_clk); + else + rate = clk_get_rate(priv->clk); + if (!rate) + return -EINVAL; + + inc = div64_ul(1000000000ULL << 20, rate); + + if (inc < GTI_TIV_MIN || inc > GTI_TIV_MAX) { + dev_err(dev, "gti.tiv increment 0x%llx is outside the range 0x%x - 0x%x\n", + inc, GTI_TIV_MIN, GTI_TIV_MAX); + return -EINVAL; + } + priv->gti_tiv = inc; + + return 0; +} + /* Network device open function for Ethernet AVB */ static int ravb_open(struct net_device *ndev) { @@ -1734,6 +1778,8 @@ static int ravb_open(struct net_device *ndev) goto out_napi_off; ravb_emac_init(ndev); + ravb_set_gti(ndev); + /* Initialise PTP Clock driver */ if (info->gptp) ravb_ptp_init(ndev, priv->pdev); @@ -2425,34 +2471,6 @@ static const struct of_device_id ravb_match_table[] = { }; MODULE_DEVICE_TABLE(of, ravb_match_table); -static int ravb_set_gti(struct net_device *ndev) -{ - struct ravb_private *priv = netdev_priv(ndev); - const struct ravb_hw_info *info = priv->info; - struct device *dev = ndev->dev.parent; - unsigned long rate; - uint64_t inc; - - if (info->gptp_ref_clk) - rate = clk_get_rate(priv->gptp_clk); - else - rate = clk_get_rate(priv->clk); - if (!rate) - return -EINVAL; - - inc = div64_ul(1000000000ULL << 20, rate); - - if (inc < GTI_TIV_MIN || inc > GTI_TIV_MAX) { - dev_err(dev, "gti.tiv increment 0x%llx is outside the range 0x%x - 0x%x\n", - inc, GTI_TIV_MIN, GTI_TIV_MAX); - return -EINVAL; - } - - ravb_write(ndev, inc, GTI); - - return 0; -} - static int ravb_set_config_mode(struct net_device *ndev) { struct ravb_private *priv = netdev_priv(ndev); @@ -2724,15 +2742,9 @@ static int ravb_probe(struct platform_device *pdev) if (error) goto out_rpm_put; - if (info->gptp || info->ccc_gac) { - /* Set GTI value */ - error = ravb_set_gti(ndev); - if (error) - goto out_rpm_put; - - /* Request GTI loading */ - ravb_modify(ndev, GCCR, GCCR_LTI, GCCR_LTI); - } + error = ravb_compute_gti(ndev); + if (error) + goto out_rpm_put; if (info->internal_delay) { ravb_parse_delay_mode(np, ndev); @@ -2945,15 +2957,7 @@ static int ravb_resume(struct device *dev) if (ret) return ret; - if (info->gptp || info->ccc_gac) { - /* Set GTI value */ - ret = ravb_set_gti(ndev); - if (ret) - return ret; - - /* Request GTI loading */ - ravb_modify(ndev, GCCR, GCCR_LTI, GCCR_LTI); - } + ravb_set_gti(ndev); if (info->internal_delay) ravb_set_delay_mode(ndev); From patchwork Fri Jan 5 08:23:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: claudiu beznea X-Patchwork-Id: 185270 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:6f82:b0:100:9c79:88ff with SMTP id tb2csp6092506dyb; Fri, 5 Jan 2024 00:27:52 -0800 (PST) X-Google-Smtp-Source: AGHT+IGOtioBh9i9paEigstxG1eyasBxGxeq9VogYyxCHIbb/pJsJCYjBRrM7hT6/QMrELILNApt X-Received: by 2002:aa7:d989:0:b0:555:11da:d813 with SMTP id u9-20020aa7d989000000b0055511dad813mr977102eds.83.1704443272671; Fri, 05 Jan 2024 00:27:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704443272; cv=none; d=google.com; s=arc-20160816; b=nOaUuVh5/d17c/ETYrqYpQS5MgZM5tc6xkx3edar1Q0FT7jmrCOXadg2Ga9u/NxAta vxIIriSZeto0A7yqtGh35jHJnhqy6fIBvsb5e9vFvIsMkqJKrton5QLmiDDDgqdgcGci 5d/SFlZFAMuhptzjqJ8ukyQ7ofl7xOw5hiQk2OjIdjXlzL0gd6BPuK7m4JHVAyllfzQH JJnqBaQObSrfaM0mtpiG9rLLaQvUSyz/z0ERxFkWKwq+HBU6E3MtaA9JXYfEGK0L2/dT 7xGvzw+IsOMD9cBII8iEan933x92B3xBS99F9SiAgc9J3iiyzxKxsOEC8jYsotMiCGji Q20g== ARC-Message-Signature: i=1; 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=Za7hqwvcFVwC9gLR2Ag52yQIz1AeWmVDkMHSuVYL5EU=; fh=qryrdWWtksp4Ojh0keXejXriHeHARah4mOGZkuZ1jnk=; b=09a/24lwy7F5TwnERSYkmR70uJBpQ7/YfdzNw4YQKaxyei/0hgkb79bwDBI5cKmbgg LYfi7N5Mot8EvPFW3fWnLFwva/8OnpRXbekk/00WvzZNjnr6zkk20RR73XWitXXYYHZc SvfH2W5BBlFCrM+WTqE4VURFb+buJDoYqmWo7c8kct5s3q21L/xy5HfAF1bKxDcFpVhr uRzLpJZvniVDJ8VzprXpDwqpLTUamjJnBkcZJhSRW6hXHv5SUnzEVevnO3yX4K4Vc4lw MIYf7phgzfWt01FoiuRgBHQm2IxWNKeb9GvpD6X88w9hedhIs0MBhFI2ZcnmCwre6W7r +rPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@tuxon.dev header.s=google header.b=WNSCGCEb; spf=pass (google.com: domain of linux-kernel+bounces-17589-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-17589-ouuuleilei=gmail.com@vger.kernel.org" Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id h11-20020a056402280b00b005572bc4f47bsi329377ede.333.2024.01.05.00.27.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jan 2024 00:27:52 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-17589-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=WNSCGCEb; spf=pass (google.com: domain of linux-kernel+bounces-17589-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-17589-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 206351F23A9F for ; Fri, 5 Jan 2024 08:27:52 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D112A2D784; Fri, 5 Jan 2024 08:24:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b="WNSCGCEb" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-ej1-f47.google.com (mail-ej1-f47.google.com [209.85.218.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 CF56E2D615 for ; Fri, 5 Jan 2024 08:24:49 +0000 (UTC) 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-ej1-f47.google.com with SMTP id a640c23a62f3a-a2814fa68eeso106324666b.1 for ; Fri, 05 Jan 2024 00:24:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1704443088; x=1705047888; 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=Za7hqwvcFVwC9gLR2Ag52yQIz1AeWmVDkMHSuVYL5EU=; b=WNSCGCEbM+Z1oNOMFtgYCDyiEoUoCsdGjru4UOs5C5ExNZLYkf6TOllf7f7zeV+9Yt mfw/tVJ+9roDtj1WO4gt8gAsLnSzInpw9I09fbiytttomggKwMEyRASFfNy6AwAIsC/x +pELEDDjH1PkmgebBvNwyIathPADEgDTYvB/UCDor1T51ibr+l8qRCtJvhaKQwT7sgHS dWnSYJxw44a7OxC4kLEnoIea+VTEjb2QJ2DQ9qgay1vz9EaiXWwUVeg10JJmFBuXEHqy q7MB/6A5zH+KmzosRB9INgZcK0wvkRNtdfyETXlNa6Oig2DhrPCBSBsE7JVGjYbinwQr iK6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704443088; x=1705047888; 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=Za7hqwvcFVwC9gLR2Ag52yQIz1AeWmVDkMHSuVYL5EU=; b=ms8uYK7X/GPcBZQvQjDInsIwC7ZKmY/83B2lWwOv8Gg1Aquko2qXlpqtYiNfiqUv5d RXPMJux69eRmePkPWgvvULYbDoTmLAFPrmOsd23msOEtyVjaM/aYwmTglTlxrmXdQ+Oh nDDrpKH5U0p0bIsDenMKywnn73VMnfkp21lT1zT+1HvQ6qhMW46pkH+M5gVhmhNtFl7v 1K6smlFdSdM2YLSoHuekN1UTfJe6elmp3Obq5jAv09o6eSo9lxbcZDa1jcr24uQq1S4E PM7mmDC+wftkcCOIwfyMTsXvjuFSQxFSlHAjLhs1jvFBCcx/Mpj8QgOqPOMR36tUCDcV 8s2Q== X-Gm-Message-State: AOJu0YyOaayJeqQ9a5t2OcYH3OcmkReK0WZguK9wrt1jj9KpuoGBsvXc mmMfxzM6hi22N7TMTamB55QthyDM4kYbNQ== X-Received: by 2002:a17:906:4e89:b0:a28:60d4:a292 with SMTP id v9-20020a1709064e8900b00a2860d4a292mr989984eju.16.1704443088224; Fri, 05 Jan 2024 00:24:48 -0800 (PST) Received: from claudiu-X670E-Pro-RS.. ([82.78.167.5]) by smtp.gmail.com with ESMTPSA id j15-20020a1709064b4f00b00a28e759a447sm596198ejv.213.2024.01.05.00.24.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jan 2024 00:24: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, richardcochran@gmail.com, p.zabel@pengutronix.de, yoshihiro.shimoda.uh@renesas.com, wsa+renesas@sang-engineering.com Cc: netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, claudiu.beznea@tuxon.dev, geert+renesas@glider.be, Claudiu Beznea Subject: [PATCH net-next v3 10/19] net: ravb: Move delay mode set in the driver's ndo_open API Date: Fri, 5 Jan 2024 10:23:30 +0200 Message-Id: <20240105082339.1468817-11-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240105082339.1468817-1-claudiu.beznea.uj@bp.renesas.com> References: <20240105082339.1468817-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: 1787238308613314177 X-GMAIL-MSGID: 1787238308613314177 From: Claudiu Beznea Delay parsing and setting were done in the driver's probe API. As some IP variants switch to reset mode (and thus registers content is lost) when setting clocks (due to module standby functionality) to be able to implement runtime PM keep the delay parsing in the driver's probe function and move the delay applying function to the driver's ndo_open API. Along with it, both delay specific functions were kept together. Signed-off-by: Claudiu Beznea Reviewed-by: Sergey Shtylyov --- Changes in v3: - fixed typos in patch description Changes in v2: - none; this patch is new drivers/net/ethernet/renesas/ravb_main.c | 107 ++++++++++++----------- 1 file changed, 56 insertions(+), 51 deletions(-) diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c index f386a3b7effb..946abd7606ca 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -1761,6 +1761,59 @@ static int ravb_compute_gti(struct net_device *ndev) return 0; } +/* Set tx and rx clock internal delay modes */ +static void ravb_parse_delay_mode(struct device_node *np, struct net_device *ndev) +{ + struct ravb_private *priv = netdev_priv(ndev); + bool explicit_delay = false; + u32 delay; + + if (!priv->info->internal_delay) + return; + + if (!of_property_read_u32(np, "rx-internal-delay-ps", &delay)) { + /* Valid values are 0 and 1800, according to DT bindings */ + priv->rxcidm = !!delay; + explicit_delay = true; + } + if (!of_property_read_u32(np, "tx-internal-delay-ps", &delay)) { + /* Valid values are 0 and 2000, according to DT bindings */ + priv->txcidm = !!delay; + explicit_delay = true; + } + + if (explicit_delay) + return; + + /* Fall back to legacy rgmii-*id behavior */ + if (priv->phy_interface == PHY_INTERFACE_MODE_RGMII_ID || + priv->phy_interface == PHY_INTERFACE_MODE_RGMII_RXID) { + priv->rxcidm = 1; + priv->rgmii_override = 1; + } + + if (priv->phy_interface == PHY_INTERFACE_MODE_RGMII_ID || + priv->phy_interface == PHY_INTERFACE_MODE_RGMII_TXID) { + priv->txcidm = 1; + priv->rgmii_override = 1; + } +} + +static void ravb_set_delay_mode(struct net_device *ndev) +{ + struct ravb_private *priv = netdev_priv(ndev); + u32 set = 0; + + if (!priv->info->internal_delay) + return; + + if (priv->rxcidm) + set |= APSR_RDM; + if (priv->txcidm) + set |= APSR_TDM; + ravb_modify(ndev, APSR, APSR_RDM | APSR_TDM, set); +} + /* Network device open function for Ethernet AVB */ static int ravb_open(struct net_device *ndev) { @@ -1772,6 +1825,8 @@ static int ravb_open(struct net_device *ndev) if (info->nc_queues) napi_enable(&priv->napi[RAVB_NC]); + ravb_set_delay_mode(ndev); + /* Device init */ error = ravb_dmac_init(ndev); if (error) @@ -2492,41 +2547,6 @@ static int ravb_set_config_mode(struct net_device *ndev) return error; } -/* Set tx and rx clock internal delay modes */ -static void ravb_parse_delay_mode(struct device_node *np, struct net_device *ndev) -{ - struct ravb_private *priv = netdev_priv(ndev); - bool explicit_delay = false; - u32 delay; - - if (!of_property_read_u32(np, "rx-internal-delay-ps", &delay)) { - /* Valid values are 0 and 1800, according to DT bindings */ - priv->rxcidm = !!delay; - explicit_delay = true; - } - if (!of_property_read_u32(np, "tx-internal-delay-ps", &delay)) { - /* Valid values are 0 and 2000, according to DT bindings */ - priv->txcidm = !!delay; - explicit_delay = true; - } - - if (explicit_delay) - return; - - /* Fall back to legacy rgmii-*id behavior */ - if (priv->phy_interface == PHY_INTERFACE_MODE_RGMII_ID || - priv->phy_interface == PHY_INTERFACE_MODE_RGMII_RXID) { - priv->rxcidm = 1; - priv->rgmii_override = 1; - } - - if (priv->phy_interface == PHY_INTERFACE_MODE_RGMII_ID || - priv->phy_interface == PHY_INTERFACE_MODE_RGMII_TXID) { - priv->txcidm = 1; - priv->rgmii_override = 1; - } -} - static int ravb_setup_irq(struct ravb_private *priv, const char *irq_name, const char *ch, int *irq, irq_handler_t handler) { @@ -2611,18 +2631,6 @@ static int ravb_setup_irqs(struct ravb_private *priv) return ravb_setup_irq(priv, "ch19", "ch19:tx_nc", &irq, ravb_nc_interrupt); } -static void ravb_set_delay_mode(struct net_device *ndev) -{ - struct ravb_private *priv = netdev_priv(ndev); - u32 set = 0; - - if (priv->rxcidm) - set |= APSR_RDM; - if (priv->txcidm) - set |= APSR_TDM; - ravb_modify(ndev, APSR, APSR_RDM | APSR_TDM, set); -} - static int ravb_probe(struct platform_device *pdev) { struct device_node *np = pdev->dev.of_node; @@ -2746,10 +2754,7 @@ static int ravb_probe(struct platform_device *pdev) if (error) goto out_rpm_put; - if (info->internal_delay) { - ravb_parse_delay_mode(np, ndev); - ravb_set_delay_mode(ndev); - } + ravb_parse_delay_mode(np, ndev); /* Allocate descriptor base address table */ priv->desc_bat_size = sizeof(struct ravb_desc) * DBAT_ENTRY_NUM; From patchwork Fri Jan 5 08:23:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: claudiu beznea X-Patchwork-Id: 185271 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:6f82:b0:100:9c79:88ff with SMTP id tb2csp6092563dyb; Fri, 5 Jan 2024 00:28:10 -0800 (PST) X-Google-Smtp-Source: AGHT+IHOk9X8ArJ2Cr8GClip5NSkDnJd3hD0TY4TFLTclgPglYsXjdCCUK7I1ofS/T8Dc16SGzUV X-Received: by 2002:a05:6358:63aa:b0:170:bfb9:1cfc with SMTP id k42-20020a05635863aa00b00170bfb91cfcmr1915503rwh.1.1704443290159; Fri, 05 Jan 2024 00:28:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704443290; cv=none; d=google.com; s=arc-20160816; b=XEX8VNLxSL19AeAooP+0kPv7ggNdBD2B/Ygl3HnqeecrMHrcz71DTPm2uAzWserRTZ 7TTb3NpNOfQJpQ2QbMcBfeTFGxQYlu5cBFDsNdE81UXylsZiaUlN5n3anyAkC3TpC8ck IRFGavIz391aBq5k/MnbW2GBDhrp2rweEZ5BifcZyBfqiQXtA2IXCOss8ISmU35+WSTu estAJKxgyEJ6UIlvkbGAdDekfVYaCZA4oG1mHaOlhhn2teugUsIpOa0LfUnmQGORO0o9 qoNPGnBKgtmUJNM7x78TjgtGUzNYXFuyzHrnDQcUnvcWnTbOvjlMyyvAA8T0atzhcTKE tB6w== ARC-Message-Signature: i=1; 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=dZFMoutT1OQ8HdoT2b40UgTdsfQKAEafv0v+pAiov+w=; fh=qryrdWWtksp4Ojh0keXejXriHeHARah4mOGZkuZ1jnk=; b=vGHZFCDPcnPAAZzcC1C6ZNuq9kdo5jcQLHivouRixlVLuFI0+LjDR/uC4M8OUdTKZd WaXzdPAlm9TDBLiFS+Js86WjkzM2j5+hwZ9okcs+3gDbW0J/DLInCE/jolE/XEyDlI8f w7a9otsud0P5YLq2wjvZMEijGRjQuMt8bbOoGZFTfXYUMoFEDKSbyH+HKa+DEZ30/CnS 9IWw0yr+KjSr/0yjmG813u/TBvDpWsIGOXqKd914nqTWVp8UGRlaPEQyLH1vgUaGxCiW Ufl/NWJ0bukF9N9Xc3da5z/UilVz+g7wgTxkO5FfA4hNWl+yYo6SmMRMUuLVUZoRtOOp njXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@tuxon.dev header.s=google header.b=ft9p0Rvq; spf=pass (google.com: domain of linux-kernel+bounces-17590-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-17590-ouuuleilei=gmail.com@vger.kernel.org" Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id z14-20020aa785ce000000b006d9bee251f7si900922pfn.242.2024.01.05.00.28.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jan 2024 00:28:10 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-17590-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=ft9p0Rvq; spf=pass (google.com: domain of linux-kernel+bounces-17590-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-17590-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 DE758287853 for ; Fri, 5 Jan 2024 08:28:09 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5782F2D7B5; Fri, 5 Jan 2024 08:24:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b="ft9p0Rvq" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-ej1-f48.google.com (mail-ej1-f48.google.com [209.85.218.48]) (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 526AD2D78C for ; Fri, 5 Jan 2024 08:24:54 +0000 (UTC) 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-ej1-f48.google.com with SMTP id a640c23a62f3a-a28fb463a28so98801966b.3 for ; Fri, 05 Jan 2024 00:24:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1704443092; x=1705047892; 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=dZFMoutT1OQ8HdoT2b40UgTdsfQKAEafv0v+pAiov+w=; b=ft9p0RvqjmKcN6JGEvHRVPCsnrLAqZ83Kw73PCVBgcH/i75mE9WiN0jz4IHpGxEq3O 6OqcNxA78YeC6Tc/54Vfamyonx+TGcrKD7bgouwMCBAMRIRfeFswNFrz5kYkTOoKCx3s y3rKXESVs1dmt5Gc3SJjxoWnxFYd12uEzuowtb/aAQgd7ssQ7sWGwrZHmHGlDSNk2tMw nkVWkuO9kfqEB3yJgMbraU3fbOPXi8MuCVEXezodOaY9LhLpRlJPegT/FBcYZAf8YIOh onnvDZK5Bnxm813DRJ3GPb5iFk8hGvJomsPuObFTLtCcWy85DRxVNU502YS7xgccd/+P XFAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704443092; x=1705047892; 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=dZFMoutT1OQ8HdoT2b40UgTdsfQKAEafv0v+pAiov+w=; b=pIwXzF7ZK7eNX668+ecWHR5iQ6lLU+3exJ/+qJn1IG2JKKg509fulFzRZUvGmx6nsP C2kf2ZKYClqHQKrEKx4523eNS5/maCCQRj2UNpg59APXUQ02HCytDoTL2VTKxNHJFhwK MRHYErIfuLwryzmIBO0akfnpZxCi6oROcGquluS0Qs9xrMuaD8mYslmnsOEEenhS5IVa 0dYgfM0hwsKTAexjFhm+2IiFnkijkkOtRU41qorGZTv7Y6E0jQkmJn+wJpggIrrgBxY/ tokfQWInyREiiOY8oNvYhQMsCUWCsECDX8kgzwypzwmOjeitry3phvak+8yLLSfLER7Y 4qrg== X-Gm-Message-State: AOJu0YyPq0XmRkH0Cy0NpR1cRovr1/P7JZz2Lu2jO+VPY90WR6NNggMS AQLWmjRWUMG/RbJnMQsunTvAcZNPtB7rrg== X-Received: by 2002:a17:906:19c:b0:a28:f8d2:4648 with SMTP id 28-20020a170906019c00b00a28f8d24648mr601871ejb.83.1704443092762; Fri, 05 Jan 2024 00:24:52 -0800 (PST) Received: from claudiu-X670E-Pro-RS.. ([82.78.167.5]) by smtp.gmail.com with ESMTPSA id j15-20020a1709064b4f00b00a28e759a447sm596198ejv.213.2024.01.05.00.24.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jan 2024 00:24:52 -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, richardcochran@gmail.com, p.zabel@pengutronix.de, yoshihiro.shimoda.uh@renesas.com, wsa+renesas@sang-engineering.com Cc: netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, claudiu.beznea@tuxon.dev, geert+renesas@glider.be, Claudiu Beznea Subject: [PATCH net-next v3 11/19] net: ravb: Move DBAT configuration to the driver's ndo_open API Date: Fri, 5 Jan 2024 10:23:31 +0200 Message-Id: <20240105082339.1468817-12-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240105082339.1468817-1-claudiu.beznea.uj@bp.renesas.com> References: <20240105082339.1468817-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: 1787238327718139186 X-GMAIL-MSGID: 1787238327718139186 From: Claudiu Beznea DBAT setup was done in the driver's probe API. As some IP variants switch to reset mode (and thus registers content is lost) when setting clocks (due to module standby functionality) to be able to implement runtime PM move the DBAT configuration in the driver's ndo_open API. This commit prepares the code for the addition of runtime PM. Reviewed-by: Sergey Shtylyov Signed-off-by: Claudiu Beznea --- Changes in v3: - collected tags Changes in v2: - none; this patch is new drivers/net/ethernet/renesas/ravb_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c index 946abd7606ca..dbc26c3e95ec 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -1826,6 +1826,7 @@ static int ravb_open(struct net_device *ndev) napi_enable(&priv->napi[RAVB_NC]); ravb_set_delay_mode(ndev); + ravb_write(ndev, priv->desc_bat_dma, DBAT); /* Device init */ error = ravb_dmac_init(ndev); @@ -2769,7 +2770,6 @@ static int ravb_probe(struct platform_device *pdev) } for (q = RAVB_BE; q < DBAT_ENTRY_NUM; q++) priv->desc_bat[q].die_dt = DT_EOS; - ravb_write(ndev, priv->desc_bat_dma, DBAT); /* Initialise HW timestamp list */ INIT_LIST_HEAD(&priv->ts_skb_list); From patchwork Fri Jan 5 08:23:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: claudiu beznea X-Patchwork-Id: 185272 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:6f82:b0:100:9c79:88ff with SMTP id tb2csp6092665dyb; Fri, 5 Jan 2024 00:28:30 -0800 (PST) X-Google-Smtp-Source: AGHT+IFVM4lUXMsEWy5sb3TI0lM8Ti8M7jImq0UoY9Aw4lH0BpIcx2Os4Q2ZDKYXDlCJ94v8Yoiv X-Received: by 2002:a17:907:10c7:b0:a23:6ba1:e220 with SMTP id rv7-20020a17090710c700b00a236ba1e220mr976948ejb.100.1704443310086; Fri, 05 Jan 2024 00:28:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704443310; cv=none; d=google.com; s=arc-20160816; b=b5sW+x7f058cLZrQfKm6gRRvUIidHq6YVGVWy/fGcyW809WPQNl9o486Z25j/y4he5 16UyNUUTAb9eSCwgtCbMm13p7lLL4g57Z/9paSCE/rOwr9+6sWmLwi9NhSUiwkk2MX7n MoY0+lf4VCwn2b2ToftpBDjS1CyOIEJOM05BwFbODRx99c52JuE9dllkdGbuBddXZUQL MR3zQ8bkIj3PVYdPrnxj5WSzgjxz66G21867vIlgIksSDHFvS37XoWdz/Efc6x+6dd0/ pt5qI13tr54WvsEv4XqOkjQVSx6VQcDSMUkmDi6jUWQargyrilnecS21nGJas1Jt1pyO W6IA== ARC-Message-Signature: i=1; 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=5orQgwfDjSBIeq4ujM8DL6jz3CCIaE3k0jKXQPZpdUw=; fh=qryrdWWtksp4Ojh0keXejXriHeHARah4mOGZkuZ1jnk=; b=RPJ/EGNW18ncRPno3b3zAcT2L8lVoJcdKeMlONVqAtAjURYOnbWhRgiJfLnRLlJDyu MzK2FxnceRIPXs6MecycMS/QFkUQznyY0jNHKM1dgBxBxFrM/SwO9SGyoP+zDBb0qURg zbQ4PFVMIoNWBP9jcUbEIYVq5fiV6SmXjb81YdA6n21HWnWooBrQlYg5Q7O2wxf4hw8O 89rcLIicf8ff7/is2gDm+B1c/4AXeB+I/xXOFtc1TTH21Vzg/7+1ruzlQ16JArA3/qff UQp3YbUjcURGhZR54YhINoP0vuO5pTcW7PT8XW2TP+zgz3ua+LuEE+8NTZ8dRyCED4Pg ssyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@tuxon.dev header.s=google header.b=PQOnPIiA; spf=pass (google.com: domain of linux-kernel+bounces-17591-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-17591-ouuuleilei=gmail.com@vger.kernel.org" Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id gh6-20020a1709073c0600b00a234530a56csi394048ejc.393.2024.01.05.00.28.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jan 2024 00:28:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-17591-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=PQOnPIiA; spf=pass (google.com: domain of linux-kernel+bounces-17591-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-17591-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 AF7201F23ADF for ; Fri, 5 Jan 2024 08:28:29 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 31BFC2DF92; Fri, 5 Jan 2024 08:25:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b="PQOnPIiA" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-ej1-f48.google.com (mail-ej1-f48.google.com [209.85.218.48]) (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 3115A2DF63 for ; Fri, 5 Jan 2024 08:24:58 +0000 (UTC) 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-ej1-f48.google.com with SMTP id a640c23a62f3a-a275b3a1167so154273666b.3 for ; Fri, 05 Jan 2024 00:24:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1704443097; x=1705047897; 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=5orQgwfDjSBIeq4ujM8DL6jz3CCIaE3k0jKXQPZpdUw=; b=PQOnPIiAM+K/1FD5C+58uAbe9lf+6xzCMUQPaflCfyvfDvEwLX3wzuNMnPuZRfV4Co V6W1Yhq13VBKOdirmUGMcX9Q2YMvsz3gHS3St4c3EDNk8XnZ8bjH9TyWWVm38gZcNo+U IaRVmuAafsorcwt4BHD8WjS6kjcqMzPJcS9vbXzfvqDSpn5O+iJkXrFe4GFDahtChwL0 50KW7dYLeP5ArDVWvjbSCEfR/tKwzcNq+JUDRaWnw7YHCg9gtOpn1YrGGPHHrXW3tqfK QFTEtWJFae0FVWREHd0+wyze6w4sUYVWfQVtq2+VaAgBTcsz24Y3uaUzkfAFmGQOFklg P3EA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704443097; x=1705047897; 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=5orQgwfDjSBIeq4ujM8DL6jz3CCIaE3k0jKXQPZpdUw=; b=uCvAZiuUuuy7gX9rKWaLuyH5EhFWQdkRgf3Ae13G1RYjLlwEkaWGPPYi6gY7i32lAE CQGhsSNbn7SjHS19tW3p4tWztZZXDTVbuQeCcjLGXx1MqZU7dLMLhcMjv7mQnDojF4fS tZTHpN9HWc9yPJHzZWlEJxMY904d+l2mR+cNMcnwym0ofmHfR/QGAWY9WFkQ9AM3PxPk hjeHKWgCPf2kV67iVn3mYholb3aV7TSKmR6bpTMam2+jD5ngfxxePJdz0NtgSO9GCHWp qhKMJ33I9u9crcNpOQ5fsDKDrh8G/DreF9/sGA8DqTbRm19HSbpVj+0BLyuThyob+rYz zbnA== X-Gm-Message-State: AOJu0YxWoVWsyOJXCPLuSMrfSAhqJ0Lw4RRcy0+FdZTDE7XsZ68KHf09 LyLkyeFwJK7atL7zmC44xdoY8G7bLxlQMQ== X-Received: by 2002:a17:906:474e:b0:a27:32a0:b838 with SMTP id j14-20020a170906474e00b00a2732a0b838mr986323ejs.112.1704443097504; Fri, 05 Jan 2024 00:24:57 -0800 (PST) Received: from claudiu-X670E-Pro-RS.. ([82.78.167.5]) by smtp.gmail.com with ESMTPSA id j15-20020a1709064b4f00b00a28e759a447sm596198ejv.213.2024.01.05.00.24.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jan 2024 00:24:57 -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, richardcochran@gmail.com, p.zabel@pengutronix.de, yoshihiro.shimoda.uh@renesas.com, wsa+renesas@sang-engineering.com Cc: netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, claudiu.beznea@tuxon.dev, geert+renesas@glider.be, Claudiu Beznea Subject: [PATCH net-next v3 12/19] net: ravb: Move PTP initialization in the driver's ndo_open API for ccc_gac platorms Date: Fri, 5 Jan 2024 10:23:32 +0200 Message-Id: <20240105082339.1468817-13-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240105082339.1468817-1-claudiu.beznea.uj@bp.renesas.com> References: <20240105082339.1468817-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: 1787238348154211316 X-GMAIL-MSGID: 1787238348154211316 From: Claudiu Beznea The initialization sequence for PTP is the same for platforms with ccc_gac and gptp (according to "Figure 50.71 Flow of gPTP Initialization (Normal, Common to All Modes)" of the R-Car Series, 3rd generation hardware manual and "Figure 37A.53 Flow of gPTP Initialization (Normal, Common to All Modes)" of the RZ/G Series hardware manual). As some IP variants switch to reset mode (and thus the registers content is lost) when setting clocks (due to module standby functionality) to be able to implement runtime PM, move the PTP initialization to the driver's ndo_open API. This commit prepares the code for the addition of runtime PM. Reviewed-by: Sergey Shtylyov Signed-off-by: Claudiu Beznea --- Changes in v3: - fixed typos in patch description - collected tags Changes in v2: - none; this patch is new drivers/net/ethernet/renesas/ravb_main.c | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c index dbc26c3e95ec..1cc1ecd8d6a8 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -1837,7 +1837,7 @@ static int ravb_open(struct net_device *ndev) ravb_set_gti(ndev); /* Initialise PTP Clock driver */ - if (info->gptp) + if (info->gptp || info->ccc_gac) ravb_ptp_init(ndev, priv->pdev); /* PHY control start */ @@ -1851,7 +1851,7 @@ static int ravb_open(struct net_device *ndev) out_ptp_stop: /* Stop PTP Clock driver */ - if (info->gptp) + if (info->gptp || info->ccc_gac) ravb_ptp_stop(ndev); ravb_stop_dma(ndev); out_napi_off: @@ -2161,7 +2161,7 @@ static int ravb_close(struct net_device *ndev) ravb_write(ndev, 0, TIC); /* Stop PTP Clock driver */ - if (info->gptp) + if (info->gptp || info->ccc_gac) ravb_ptp_stop(ndev); /* Set the config mode to stop the AVB-DMAC's processes */ @@ -2774,10 +2774,6 @@ static int ravb_probe(struct platform_device *pdev) /* Initialise HW timestamp list */ INIT_LIST_HEAD(&priv->ts_skb_list); - /* Initialise PTP Clock driver */ - if (info->ccc_gac) - ravb_ptp_init(ndev, pdev); - /* Debug message level */ priv->msg_enable = RAVB_DEF_MSG_ENABLE; @@ -2822,10 +2818,6 @@ static int ravb_probe(struct platform_device *pdev) out_dma_free: dma_free_coherent(ndev->dev.parent, priv->desc_bat_size, priv->desc_bat, priv->desc_bat_dma); - - /* Stop PTP Clock driver */ - if (info->ccc_gac) - ravb_ptp_stop(ndev); out_rpm_put: pm_runtime_put(&pdev->dev); out_rpm_disable: @@ -2851,10 +2843,6 @@ static void ravb_remove(struct platform_device *pdev) ravb_mdio_release(priv); - /* Stop PTP Clock driver */ - if (info->ccc_gac) - ravb_ptp_stop(ndev); - dma_free_coherent(ndev->dev.parent, priv->desc_bat_size, priv->desc_bat, priv->desc_bat_dma); From patchwork Fri Jan 5 08:23:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: claudiu beznea X-Patchwork-Id: 185273 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:6f82:b0:100:9c79:88ff with SMTP id tb2csp6092763dyb; Fri, 5 Jan 2024 00:28:48 -0800 (PST) X-Google-Smtp-Source: AGHT+IGDHGRtKyWdjVXAPQ/QzeAl3Po9TdeIr0lRCE8pbS+37gzoBx9TMqXmgrlNQKEDpPYinjT+ X-Received: by 2002:a05:622a:90d:b0:429:7ab5:14b9 with SMTP id bx13-20020a05622a090d00b004297ab514b9mr311990qtb.7.1704443328496; Fri, 05 Jan 2024 00:28:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704443328; cv=none; d=google.com; s=arc-20160816; b=oy6qFeIaDEKEEKSQaR33LHScqiALEkF+vz7sEiiRnxWUCdnbYdfjv73eM4TmIMwQF0 IhGU1c4a1QbWFWKMigIimg4k8/y9S+cFLtAVuzbawE4Z2DQhUNsGrTWe5OYPnmls8HBU +U1K9fnRjrDLJ99GXgxq8LBgnuCsJzI94dGqm1VADSb523ZGVR4D+aLC9mkopIPRhoui iUYs1XRIotqn1EAVMd5wc5F9AC2bMNrs8NBga9+QyXye6x2V+AXBIovVy2ovvtgMZwv9 bNo7ttHZcdlTUGXKjy5EFNCILsKsldurNaj+zxkH2mDSRQaY0P5BZ1CVTyijLQ1c/bLB uaug== ARC-Message-Signature: i=1; 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=l1p8lcj+RRuTQmVw4HBAy21i1qLMXVcCc4/+Lo+LFvE=; fh=qryrdWWtksp4Ojh0keXejXriHeHARah4mOGZkuZ1jnk=; b=selEpSyx/wHpU/TTZwcuEH/osqbZwWf0zVxQLZRead44unVU5qhNA1REImWb98Q7A8 r3OjqoiUd5wNJ0rp4oBDusAlJMTkdbzR0YlwlYFH1zgFHG4I1sxV4FPRc0+grPuj8VRn Gpk1JlM6vS+OemF2k88HYrW42E1lfTYyKKwgDqzgF9Q6VhyLcSJ4cRLIe9wdgYpxSJpI glx5XE1Eizvwy6DMM+75hmDkCuFy9UJxT7FQNqDA5WDJjC013Zki4iglFh4PUyaVIJYc aRC7jNbP2w+TFNPgKJinzWWSE1Wl9UoQbP+y2oUpOZX4aTjyDDrmW9Z1HvMSJ23wgMF7 rtKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@tuxon.dev header.s=google header.b=I661HMs9; spf=pass (google.com: domain of linux-kernel+bounces-17592-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-17592-ouuuleilei=gmail.com@vger.kernel.org" Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id c22-20020ac87d96000000b0042836b9d2f1si1293205qtd.795.2024.01.05.00.28.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jan 2024 00:28:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-17592-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=I661HMs9; spf=pass (google.com: domain of linux-kernel+bounces-17592-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-17592-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 3E4F91C22C73 for ; Fri, 5 Jan 2024 08:28:48 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F25612E3E5; Fri, 5 Jan 2024 08:25:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b="I661HMs9" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-ej1-f41.google.com (mail-ej1-f41.google.com [209.85.218.41]) (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 D9D9E2E3E4 for ; Fri, 5 Jan 2024 08:25:03 +0000 (UTC) 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-ej1-f41.google.com with SMTP id a640c23a62f3a-a28b0207c1dso106141766b.3 for ; Fri, 05 Jan 2024 00:25:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1704443102; x=1705047902; 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=l1p8lcj+RRuTQmVw4HBAy21i1qLMXVcCc4/+Lo+LFvE=; b=I661HMs9ir4JHPD0j0RbW224P7YOwfnGM+M0o5Pl9UHpAS9291vafIC+eOW5lZC1l4 /rCUOJxJ1pf7449k5KQOD3PlqxLzoLhSNerFs4TBvWjdDaiQUZPS8efeTW1ZXmg1Zar7 bP36eabtdgScQhUar2L4InsagC4qva9Xr/OMlyF7pdv17s2CXBx2rHnwn5G1iuFexEMa Mz99D41++p8IoJONHlkZFsY4xB54yze5OkY3ec46h2y+LrlBrGEbnWmzlZPFpTmOUjEs EU6JpQboRAiy9/WlTnWlmCLNCndh3/E3m94gnlWg1kpKT530Jtu8PyaRyeTCNwVzmkVS T1MQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704443102; x=1705047902; 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=l1p8lcj+RRuTQmVw4HBAy21i1qLMXVcCc4/+Lo+LFvE=; b=VQtuyMlXELh3z0iIDNeFgevkRYEkOMND2kbfw2qCk8NZuh6Qh/dSSoMHGLD1tZjwm/ MpLdMkuRpcgNT3Jb3UOfbwLiqcU0eiyQGNhtUObQQWZWv2CMNfZQBWQ7XLV4G/WKSK9L Aww4vaTx4b7yMoYMwFCPjzI/2Lzxb3qe5ltr9TVcQEZMZKr5bWVQMV1s22B68DwYABKx W6ZjtXOEX7ufsx2kNvBnAboiv1BNPyuBeDa0dvzyw/Cx6TAw4qLOhWNiIRKeqzqCIE1Q ZkOVsk2WVK8D/xtVhg3ugHijYeBnrz7hE+gDjM1/NRztvY9WwITz1bhGtdybJR+msfzm 3GxA== X-Gm-Message-State: AOJu0YxMfm6Efux1D8XkkftFquGkNcneR8LIZ91aqCLvdw3dRL5iGMoy 4fiIxKWNLMypP3QoTADI5H+ahXbQ6fKUyg== X-Received: by 2002:a17:907:9726:b0:a26:c376:d1dc with SMTP id jg38-20020a170907972600b00a26c376d1dcmr1454659ejc.70.1704443102210; Fri, 05 Jan 2024 00:25:02 -0800 (PST) Received: from claudiu-X670E-Pro-RS.. ([82.78.167.5]) by smtp.gmail.com with ESMTPSA id j15-20020a1709064b4f00b00a28e759a447sm596198ejv.213.2024.01.05.00.24.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jan 2024 00:25:01 -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, richardcochran@gmail.com, p.zabel@pengutronix.de, yoshihiro.shimoda.uh@renesas.com, wsa+renesas@sang-engineering.com Cc: netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, claudiu.beznea@tuxon.dev, geert+renesas@glider.be, Claudiu Beznea Subject: [PATCH net-next v3 13/19] net: ravb: Set config mode in ndo_open and reset mode in ndo_close Date: Fri, 5 Jan 2024 10:23:33 +0200 Message-Id: <20240105082339.1468817-14-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240105082339.1468817-1-claudiu.beznea.uj@bp.renesas.com> References: <20240105082339.1468817-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: 1787238367263368192 X-GMAIL-MSGID: 1787238367263368192 From: Claudiu Beznea As some IP variants switch to reset mode (and thus registers content is lost) when setting clocks (due to module standby functionality) to be able to implement runtime PM and save more power, set the IP's operating mode to reset at the end of the probe. Along with it, in the ndo_open API the IP will be switched to configuration, then operation mode. In the ndo_close API, the IP will be switched back to reset mode. This allows implementing runtime PM and, along with it, save more power when the IP is not used. Signed-off-by: Claudiu Beznea --- Changes in v3: - fixed typos in patch description - in ravb_probe() switch the hardware to reset mode just after phy initialization Changes in v2: - none; this patch is new drivers/net/ethernet/renesas/ravb_main.c | 78 ++++++++++++++---------- 1 file changed, 46 insertions(+), 32 deletions(-) diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c index 1cc1ecd8d6a8..434b4777de5e 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -1717,6 +1717,27 @@ static const struct ethtool_ops ravb_ethtool_ops = { .set_wol = ravb_set_wol, }; +static int ravb_set_config_mode(struct net_device *ndev) +{ + struct ravb_private *priv = netdev_priv(ndev); + const struct ravb_hw_info *info = priv->info; + int error; + + if (info->gptp) { + error = ravb_set_opmode(ndev, CCC_OPC_CONFIG); + if (error) + return error; + /* Set CSEL value */ + ravb_modify(ndev, CCC, CCC_CSEL, CCC_CSEL_HPB); + } else if (info->ccc_gac) { + error = ravb_set_opmode(ndev, CCC_OPC_CONFIG | CCC_GAC | CCC_CSEL_HPB); + } else { + error = ravb_set_opmode(ndev, CCC_OPC_CONFIG); + } + + return error; +} + static void ravb_set_gti(struct net_device *ndev) { struct ravb_private *priv = netdev_priv(ndev); @@ -1825,13 +1846,19 @@ static int ravb_open(struct net_device *ndev) if (info->nc_queues) napi_enable(&priv->napi[RAVB_NC]); + /* Set AVB config mode */ + error = ravb_set_config_mode(ndev); + if (error) + goto out_napi_off; + ravb_set_delay_mode(ndev); ravb_write(ndev, priv->desc_bat_dma, DBAT); /* Device init */ error = ravb_dmac_init(ndev); if (error) - goto out_napi_off; + goto out_set_reset; + ravb_emac_init(ndev); ravb_set_gti(ndev); @@ -1854,6 +1881,8 @@ static int ravb_open(struct net_device *ndev) if (info->gptp || info->ccc_gac) ravb_ptp_stop(ndev); ravb_stop_dma(ndev); +out_set_reset: + ravb_set_opmode(ndev, CCC_OPC_RESET); out_napi_off: if (info->nc_queues) napi_disable(&priv->napi[RAVB_NC]); @@ -2197,7 +2226,8 @@ static int ravb_close(struct net_device *ndev) if (info->nc_queues) ravb_ring_free(ndev, RAVB_NC); - return 0; + /* Set reset mode. */ + return ravb_set_opmode(ndev, CCC_OPC_RESET); } static int ravb_hwtstamp_get(struct net_device *ndev, struct ifreq *req) @@ -2527,27 +2557,6 @@ static const struct of_device_id ravb_match_table[] = { }; MODULE_DEVICE_TABLE(of, ravb_match_table); -static int ravb_set_config_mode(struct net_device *ndev) -{ - struct ravb_private *priv = netdev_priv(ndev); - const struct ravb_hw_info *info = priv->info; - int error; - - if (info->gptp) { - error = ravb_set_opmode(ndev, CCC_OPC_CONFIG); - if (error) - return error; - /* Set CSEL value */ - ravb_modify(ndev, CCC, CCC_CSEL, CCC_CSEL_HPB); - } else if (info->ccc_gac) { - error = ravb_set_opmode(ndev, CCC_OPC_CONFIG | CCC_GAC | CCC_CSEL_HPB); - } else { - error = ravb_set_opmode(ndev, CCC_OPC_CONFIG); - } - - return error; -} - static int ravb_setup_irq(struct ravb_private *priv, const char *irq_name, const char *ch, int *irq, irq_handler_t handler) { @@ -2746,11 +2755,6 @@ static int ravb_probe(struct platform_device *pdev) ndev->netdev_ops = &ravb_netdev_ops; ndev->ethtool_ops = &ravb_ethtool_ops; - /* Set AVB config mode */ - error = ravb_set_config_mode(ndev); - if (error) - goto out_rpm_put; - error = ravb_compute_gti(ndev); if (error) goto out_rpm_put; @@ -2785,13 +2789,23 @@ static int ravb_probe(struct platform_device *pdev) eth_hw_addr_random(ndev); } + /* Set config mode as this is needed for PHY initialization. */ + error = ravb_set_opmode(ndev, CCC_OPC_CONFIG); + if (error) + goto out_rpm_put; + /* MDIO bus init */ error = ravb_mdio_init(priv); if (error) { dev_err(&pdev->dev, "failed to initialize MDIO\n"); - goto out_dma_free; + goto out_reset_mode; } + /* Undo previous switch to config opmode. */ + error = ravb_set_opmode(ndev, CCC_OPC_RESET); + if (error) + goto out_mdio_release; + netif_napi_add(ndev, &priv->napi[RAVB_BE], ravb_poll); if (info->nc_queues) netif_napi_add(ndev, &priv->napi[RAVB_NC], ravb_poll); @@ -2814,8 +2828,10 @@ static int ravb_probe(struct platform_device *pdev) netif_napi_del(&priv->napi[RAVB_NC]); netif_napi_del(&priv->napi[RAVB_BE]); +out_mdio_release: ravb_mdio_release(priv); -out_dma_free: +out_reset_mode: + ravb_set_opmode(ndev, CCC_OPC_RESET); dma_free_coherent(ndev->dev.parent, priv->desc_bat_size, priv->desc_bat, priv->desc_bat_dma); out_rpm_put: @@ -2846,8 +2862,6 @@ 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); - ravb_set_opmode(ndev, CCC_OPC_RESET); - pm_runtime_put_sync(&pdev->dev); pm_runtime_disable(&pdev->dev); clk_unprepare(priv->refclk); From patchwork Fri Jan 5 08:23:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: claudiu beznea X-Patchwork-Id: 185274 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:6f82:b0:100:9c79:88ff with SMTP id tb2csp6092836dyb; Fri, 5 Jan 2024 00:29:09 -0800 (PST) X-Google-Smtp-Source: AGHT+IF7iwvvEzh7YoDHq5Nnfj9SE1sfmDNGFRkhJ2HahSJSmXHR11nM6e4KP/vJ0K8+0GlqYXPx X-Received: by 2002:a17:90a:7782:b0:28c:e97b:e676 with SMTP id v2-20020a17090a778200b0028ce97be676mr2232983pjk.47.1704443349342; Fri, 05 Jan 2024 00:29:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704443349; cv=none; d=google.com; s=arc-20160816; b=sKxUUT+URK5+qW6crQEgdhAAjkzMC3AYvuaJFYpOeMjMwBSRx4Z+Qd5DwwCObmw8Fl KPZO1PzDxDwb9YgzP/uXSbHpgVoMKBdCHwnUMlvtYV8wvoyaJu4l75/9vP4L/Lvkpb5n aPrgH4sqB5GsbrgRmoQXcPyUXVh12kvXOYltEhm85wy0gXWq6qsn2Dp0qvHsRkCNt0f7 naB8DTqXqvaAoFRYXWkrMrIREoxk3HvZFNpwuEcF+3l+hnV7SZ6yqh4wH1NQiADnOYRi 07Z7wDkkrr6ingNGy49hbqHWnm3bbZbnmMUfjVce/8y8H3K8zbX25VMgSZtge2Ar88bn t7Cg== ARC-Message-Signature: i=1; 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=CJ8CzScii+mqzmjbtrVuVx2JcFAYoPC8SxGsrNUa8W0=; fh=qryrdWWtksp4Ojh0keXejXriHeHARah4mOGZkuZ1jnk=; b=lmgu4naLYSdGcGvuNinDgCpjTtLdNNiROo9vbaqaPW6uTUlPRjkX4cEAzagiFn4+GL aj/gk7Xe7VqpTvBsfuSWZmWQSBE00bRdGf5F2WSuQQoAe4hTTbFr4MBA8UB2qkVlYaGS 4aAf+Nxr1SU6i6AqoglFBYC0vKrTX0HsiucYPVlWgEIQq6eZEMhOkQiAZECpumQ35gq6 vVXUJaMvSKW15ug8iw4ODX9Sia13EnZDeqFxLc50Gf4IAxBxfKF9ubzaWNdHOPn4OYWc npHt3VojYgquZ16B7lY+WtrBcn2mE2PTtT7kX51PG8DfodTdp0DFzk6i7BtTWfT7fplE fkuQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@tuxon.dev header.s=google header.b=qP021Lgu; spf=pass (google.com: domain of linux-kernel+bounces-17593-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-17593-ouuuleilei=gmail.com@vger.kernel.org" Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id i2-20020a17090a974200b0028bbcfd0afcsi451631pjw.130.2024.01.05.00.29.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jan 2024 00:29:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-17593-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@tuxon.dev header.s=google header.b=qP021Lgu; spf=pass (google.com: domain of linux-kernel+bounces-17593-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-17593-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 60F53B21B86 for ; Fri, 5 Jan 2024 08:29:08 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4925A2E632; Fri, 5 Jan 2024 08:25:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b="qP021Lgu" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-ej1-f44.google.com (mail-ej1-f44.google.com [209.85.218.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 760122E40A for ; Fri, 5 Jan 2024 08:25:08 +0000 (UTC) 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-ej1-f44.google.com with SMTP id a640c23a62f3a-a27733ae1dfso154070166b.3 for ; Fri, 05 Jan 2024 00:25:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1704443107; x=1705047907; 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=CJ8CzScii+mqzmjbtrVuVx2JcFAYoPC8SxGsrNUa8W0=; b=qP021LguCyMr20k6VTFD5ZxUE6GRlK8C3CiuWrIFYOV+JclvpV2cBL36RMHV9Hhcwj mT9TxnYeIav2/S0KfmlpJulGNLjgjkfGIjS6mhH987sbEJuH7AkRafcwfidD8GukWA94 BmzZkMP9LThfnVA1mo3qijIrj7fi0IJEPsG5ocB3Quh0W7jyK++EApGGL1TmYtfwUUXP ZflJuXWm4gEf33J5mGa+D2hNIbnhwd0wM28tvv1tS4KG/12MbLMCBcAsyc8G0e2y+t8G up3cJBuccEqlCDRDoi5b89jlTscIZza++3L5SYtdjxFo7eOQ4B7036lY8CaoCUE9EAut HdEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704443107; x=1705047907; 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=CJ8CzScii+mqzmjbtrVuVx2JcFAYoPC8SxGsrNUa8W0=; b=WxerRSirsaanxJJ/1gmGPylspDgH9/KLTduYQjMc/i7ItOlylHEacq40qejDK9jMxd +X1oqildpPlm5jRlY1t/mfdgmPWTkOG8h3rpIDN4BjzUv81o/6SEnc/N6rBbLBXKU+U1 nf0hniNf0IeEzi4gFces8txrl5qeEsUg/lfxUDfMoleIunuG3T2v6RgEmW977ieXV80k QMrwAczjwND1zfufXBaL7Y657r2ejlzYFnmieu1WlpzlIZZvwa6yGQv4f8H6G4dRsQM9 +8mcXlYoMixNr6biQcuKwFknrkJ+suf+jqqVpu/Jg43p9okK4GFJ8oR/TNft9BymWdlx sAEw== X-Gm-Message-State: AOJu0YwBWOfsV/JirR8IxyO7MqkKhMPDsAOxtBdVOVY1/B2IHuNvix9d gBBaiy+xdWp24+aXwmYBG4BOpYsARnnGrA== X-Received: by 2002:a17:906:4a81:b0:a23:65cb:6f7a with SMTP id x1-20020a1709064a8100b00a2365cb6f7amr479978eju.78.1704443106857; Fri, 05 Jan 2024 00:25:06 -0800 (PST) Received: from claudiu-X670E-Pro-RS.. ([82.78.167.5]) by smtp.gmail.com with ESMTPSA id j15-20020a1709064b4f00b00a28e759a447sm596198ejv.213.2024.01.05.00.25.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jan 2024 00:25:06 -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, richardcochran@gmail.com, p.zabel@pengutronix.de, yoshihiro.shimoda.uh@renesas.com, wsa+renesas@sang-engineering.com Cc: netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, claudiu.beznea@tuxon.dev, geert+renesas@glider.be, Claudiu Beznea Subject: [PATCH net-next v3 14/19] net: ravb: Simplify ravb_suspend() Date: Fri, 5 Jan 2024 10:23:34 +0200 Message-Id: <20240105082339.1468817-15-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240105082339.1468817-1-claudiu.beznea.uj@bp.renesas.com> References: <20240105082339.1468817-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: 1787238389556410877 X-GMAIL-MSGID: 1787238389556410877 From: Claudiu Beznea As ravb_close() contains now the call to ravb_ptp_stop() for both ccc_gac and gPTP aware platforms, there is no need to keep the separate call in ravb_suspend(). Instead, move it to ravb_wol_setup(). In this way the resulting code is cleaner. Reviewed-by: Sergey Shtylyov Signed-off-by: Claudiu Beznea --- Changes in v3: - fixed typos in patch description - collected tags Changes in v2: - none; this patch is new drivers/net/ethernet/renesas/ravb_main.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c index 434b4777de5e..1d228e0d875f 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -2890,6 +2890,9 @@ static int ravb_wol_setup(struct net_device *ndev) /* Enable MagicPacket */ ravb_modify(ndev, ECMR, ECMR_MPDE, ECMR_MPDE); + if (priv->info->ccc_gac) + ravb_ptp_stop(ndev); + return enable_irq_wake(priv->emac_irq); } @@ -2922,14 +2925,10 @@ static int ravb_suspend(struct device *dev) netif_device_detach(ndev); if (priv->wol_enabled) - ret = ravb_wol_setup(ndev); - else - ret = ravb_close(ndev); + return ravb_wol_setup(ndev); - if (priv->info->ccc_gac) - ravb_ptp_stop(ndev); - - if (priv->wol_enabled) + ret = ravb_close(ndev); + if (ret) return ret; reset_assert: From patchwork Fri Jan 5 08:23:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: claudiu beznea X-Patchwork-Id: 185275 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:6f82:b0:100:9c79:88ff with SMTP id tb2csp6092920dyb; Fri, 5 Jan 2024 00:29:28 -0800 (PST) X-Google-Smtp-Source: AGHT+IFuGYHq37shMnPUAfdDgWz1/75arzfVtdcQ5YvXd+xQNYMkkd2Idy1LQ7ydrPnEPCoe7PBJ X-Received: by 2002:a50:c2d2:0:b0:553:5087:cbf0 with SMTP id u18-20020a50c2d2000000b005535087cbf0mr926724edf.83.1704443368062; Fri, 05 Jan 2024 00:29:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704443368; cv=none; d=google.com; s=arc-20160816; b=Ifg8dH14JQ5sDISHkiUOxAfUC8DBRkHtAka9d6AoxT75DAf7UkTRDxkOYjJWTLy1qx 8q5iM3DpdRIvF2Rmm40sJZZc7gEQ4bWg4X7fj94i+dNWNXHIyLYSkrleAMFneKGA2OvE NwNOskVos//vP7ch8ZX+WbPnsi6+bS+dzHXlavUU0dnpF+/HrOWF9rhydMi81RNNd+MS 7UQM6g+m7E9o4PPk1XfzBX+xizgXHPwfOI6su+QE/NVf3HotmPlDhsbBScwmziQdluAN psbpKQ8ypbuEgqCv8sPeUZwmO4G7d94+KKy92lZBXpiUhCYZND23lrTIvZDm+mor/Xfl TOTA== ARC-Message-Signature: i=1; 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=5U2pCYzsTsR2Xw27TGhf44nRfdvpa0/cuFsAnchyMS4=; fh=qryrdWWtksp4Ojh0keXejXriHeHARah4mOGZkuZ1jnk=; b=yD4hAQ53KmHpOiC79JglAxBXXPqXXvjD2WaWVVlwkXZCNCbZWclpg4AMH/6enLkZpU xNjVI4p6sbhzDVkqx2PowgA4hSjFHHjKC6JZyFv4BVoOty3NgiAwKo9z1oIOgkvurCHy f03lQ9MuPTDYqYmdsCeNhoaU5BlH20ztHC19uD5PrcZd92ATJ11/hliz2rMZUkc9NVmM ipfciAOXMnoT7xEoU+56Lu4fdqYyDWTgK3ZqaetSJHuNqTcmMcgoJfAtatS2/xszg8Rm DrcyA722+AX6SkRb1bn/ubRu1EIr0VLAxxM8OMO7DNJ9tU4yxZUC55F3pGJesRI24ATP ryDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@tuxon.dev header.s=google header.b=gsgGM5Lt; spf=pass (google.com: domain of linux-kernel+bounces-17594-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-17594-ouuuleilei=gmail.com@vger.kernel.org" Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id i12-20020a05640242cc00b0054cd723d668si443212edc.655.2024.01.05.00.29.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jan 2024 00:29:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-17594-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=gsgGM5Lt; spf=pass (google.com: domain of linux-kernel+bounces-17594-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-17594-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 AC3C41F23ADD for ; Fri, 5 Jan 2024 08:29:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1D7262E647; Fri, 5 Jan 2024 08:25:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b="gsgGM5Lt" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-ed1-f46.google.com (mail-ed1-f46.google.com [209.85.208.46]) (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 256D72E62D for ; Fri, 5 Jan 2024 08:25:13 +0000 (UTC) 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-ed1-f46.google.com with SMTP id 4fb4d7f45d1cf-55722620e4aso520254a12.0 for ; Fri, 05 Jan 2024 00:25:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1704443111; x=1705047911; 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=5U2pCYzsTsR2Xw27TGhf44nRfdvpa0/cuFsAnchyMS4=; b=gsgGM5Lt+4lEhMw05w9UEQd3DGPWmnaC5f0z0sLslPQpx9dpaeKjQEp5k9f3pO2yy2 lzn/2HBTokVHEa02+U4zjBDDXOoqaiv+f3XuyoEWSMpVsjyvERRMKj6vJFuCPrlI5foX AQy7kCNLwvS8/abhkZZW4+K30yCTdkbNh9y/3MHbpAuaskEGwF1KE9Mbvq8tcM+NMGt2 GRJbt8nK39bKsylVPs/XjBcn2R2amhqEamfaaV1OCXF6S6qcegdSkfgwXZfZTU9Aac2t ty3yBpgmN3G1G5Ki9orffF3G4CNbMErPHqYnCT6XDG6YMHEuYyW/FoNrkPImP+4hVBh8 ZkHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704443111; x=1705047911; 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=5U2pCYzsTsR2Xw27TGhf44nRfdvpa0/cuFsAnchyMS4=; b=KDxXxIz4Iev5+a+65xVqKjpqAQVj87/nqgxp+kFVy5ZREYGu7ZGiR/ILSX5/VHjNSB urnY/b9ErsoQkWP6qxawVsi4yuu9CBleq+rOzvUVnhA+cz3HhtP/WLv1asEfldUBgEsU L0v5yWcRSA5O0ziFn1FFiPD1gqfdw/rUOmFaOYx/Br70OT/PqKUz8sgY/i98S/pApVnA UzJ2EhcubO7vHAWEVvsAeTTD9ivsIXZIQMg/4d+SriyHvKHCL7a0CvKkcuxw/rI/B0y1 JALcvugJJYKuvTVcZ7zJueDXj3gvKo8xnsRSB7u6ALXEgxUUERoP5A2DT6CtTKzMXBiO 0JcQ== X-Gm-Message-State: AOJu0YxTliscEZAQCL6t51Wolz8cVfpS0f0isTqz2RtehKoH7t9MevlZ o6dIQDyVQv3oelyLprjIfBzn4TuZncD6MA== X-Received: by 2002:a17:907:747:b0:a27:d1d6:c578 with SMTP id xc7-20020a170907074700b00a27d1d6c578mr1065921ejb.27.1704443111453; Fri, 05 Jan 2024 00:25:11 -0800 (PST) Received: from claudiu-X670E-Pro-RS.. ([82.78.167.5]) by smtp.gmail.com with ESMTPSA id j15-20020a1709064b4f00b00a28e759a447sm596198ejv.213.2024.01.05.00.25.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jan 2024 00:25:11 -0800 (PST) From: Claudiu X-Google-Original-From: Claudiu To: s.shtylyov@omp.ru, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, richardcochran@gmail.com, p.zabel@pengutronix.de, yoshihiro.shimoda.uh@renesas.com, wsa+renesas@sang-engineering.com Cc: netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, claudiu.beznea@tuxon.dev, geert+renesas@glider.be, Claudiu Beznea Subject: [PATCH net-next v3 15/19] net: ravb: Simplify ravb_resume() Date: Fri, 5 Jan 2024 10:23:35 +0200 Message-Id: <20240105082339.1468817-16-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240105082339.1468817-1-claudiu.beznea.uj@bp.renesas.com> References: <20240105082339.1468817-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: 1787238409411674413 X-GMAIL-MSGID: 1787238409411674413 From: Claudiu Beznea Remove explicit calls to functions that are called by ravb_open(). There is no need to have them doubled now that the ravb_open() already contains what is needed for the interface configuration. Along with it, configurations needed by PTP were moved to ravb_wol_restore(). With this, code in ravb_resume() becomes simpler. Reviewed-by: Sergey Shtylyov Signed-off-by: Claudiu Beznea --- Changes in v3: - fixed typos in patch description - collected tags Changes in v2: - none; this patch is new drivers/net/ethernet/renesas/ravb_main.c | 58 ++++++++++-------------- 1 file changed, 24 insertions(+), 34 deletions(-) diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c index 1d228e0d875f..06c7ee45d567 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -2900,6 +2900,20 @@ static int ravb_wol_restore(struct net_device *ndev) { struct ravb_private *priv = netdev_priv(ndev); const struct ravb_hw_info *info = priv->info; + int error; + + /* Set reset mode to rearm the WoL logic. */ + error = ravb_set_opmode(ndev, CCC_OPC_RESET); + if (error) + return error; + + /* Set AVB config mode. */ + error = ravb_set_config_mode(ndev); + if (error) + return error; + + if (priv->info->ccc_gac) + ravb_ptp_init(ndev, priv->pdev); if (info->nc_queues) napi_enable(&priv->napi[RAVB_NC]); @@ -2939,53 +2953,29 @@ static int ravb_resume(struct device *dev) { struct net_device *ndev = dev_get_drvdata(dev); struct ravb_private *priv = netdev_priv(ndev); - const struct ravb_hw_info *info = priv->info; int ret; ret = reset_control_deassert(priv->rstc); if (ret) return ret; - /* If WoL is enabled set reset mode to rearm the WoL logic */ + if (!netif_running(ndev)) + return 0; + + /* If WoL is enabled restore the interface. */ if (priv->wol_enabled) { - ret = ravb_set_opmode(ndev, CCC_OPC_RESET); + ret = ravb_wol_restore(ndev); if (ret) return ret; } - /* All register have been reset to default values. - * Restore all registers which where setup at probe time and - * reopen device if it was running before system suspended. - */ - - /* Set AVB config mode */ - ret = ravb_set_config_mode(ndev); - if (ret) + /* Reopening the interface will restore the device to the working state. */ + ret = ravb_open(ndev); + if (ret < 0) return ret; - ravb_set_gti(ndev); - - if (info->internal_delay) - ravb_set_delay_mode(ndev); - - /* Restore descriptor base address table */ - ravb_write(ndev, priv->desc_bat_dma, DBAT); - - if (priv->info->ccc_gac) - ravb_ptp_init(ndev, priv->pdev); - - if (netif_running(ndev)) { - if (priv->wol_enabled) { - ret = ravb_wol_restore(ndev); - if (ret) - return ret; - } - ret = ravb_open(ndev); - if (ret < 0) - return ret; - ravb_set_rx_mode(ndev); - netif_device_attach(ndev); - } + ravb_set_rx_mode(ndev); + netif_device_attach(ndev); return ret; } From patchwork Fri Jan 5 08:23:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: claudiu beznea X-Patchwork-Id: 185276 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:6f82:b0:100:9c79:88ff with SMTP id tb2csp6092996dyb; Fri, 5 Jan 2024 00:29:46 -0800 (PST) X-Google-Smtp-Source: AGHT+IF/c6JaLKuRCw00c88HHLuH/zDmY00eq/g2zLRMDZydLJLK3UFCQe+q/SBSURdlh4GT3rna X-Received: by 2002:a05:622a:14c:b0:428:1404:930d with SMTP id v12-20020a05622a014c00b004281404930dmr2107535qtw.66.1704443386103; Fri, 05 Jan 2024 00:29:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704443386; cv=none; d=google.com; s=arc-20160816; b=cLofxkkQwqhi6oJdX4wgmboDIBXI7JQi4NaePV4wI2hYqlWEC05KnfxkbtuOvHO2je N7T5oyJqTgA0QSpbUIWjVKyItX6Ird+Hk8cLW4lkT7dhsNjpvFIlB/3TIg+0qQDEUxd4 pgdDd1BgENp1O5JcykeTbgl9WpO0CqtmkHxIXwk/NOP2tYTdOhWGfyuOTDqzkxLjp+Ig Nj7FtHr4FM51GJn710MLoW/cOYk0iJNnbRtcnGMXr8xkYYN8+OEs0Ex8Eg2TSDSejuMr k1ziQwcWMDZeYILKD/gI5LZhHDa7F7qK4/NmJj4UfZAEeuFU8/7ud9+STE4fzOIIkuf4 Nvsg== ARC-Message-Signature: i=1; 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=GdMglme1FJfw7lAsTxrQOv9zf0VFBKQ+XeA3yTFVwPY=; fh=qryrdWWtksp4Ojh0keXejXriHeHARah4mOGZkuZ1jnk=; b=U28hX/7J8FI4CoqkQZ8VAFw8nIiU4L5f8pKSi0IZIqlP2OZAg/bCeYWccxEWyLEZRb NQjDzoaWXwVmskiH81LAtt06y3R8+iIo/1d/dkvo9m5lmM2jKEutL30mxN4/vlKB/FQc VUz5Vv5Own9CCW7uMjFSIjBvfzScXwgzUijO85pgS4ZhwZGO0zIfbK+B4w5phVZkHyQq 7BCfj8yhLhghbtlgXdkl7xkeg0OFE0/0ajnh+DcTTq7Dnb7DCb/wcCrcyqJ/hGI+Yb9r RRcOSnEIOcswJwK0Y6leSVkpLWu6XryLh3fkNY18PgJ8/g41afrH0v6/FcvFbHIBHTaB 4/KQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@tuxon.dev header.s=google header.b=ph7Tx93m; spf=pass (google.com: domain of linux-kernel+bounces-17595-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-17595-ouuuleilei=gmail.com@vger.kernel.org" Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id s2-20020a05622a1a8200b0042974f3c2cbsi1269646qtc.217.2024.01.05.00.29.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jan 2024 00:29:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-17595-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=ph7Tx93m; spf=pass (google.com: domain of linux-kernel+bounces-17595-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-17595-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 E12171C22D0F for ; Fri, 5 Jan 2024 08:29:45 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7CE402E83F; Fri, 5 Jan 2024 08:25:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b="ph7Tx93m" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-ed1-f49.google.com (mail-ed1-f49.google.com [209.85.208.49]) (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 7FF902E65B for ; Fri, 5 Jan 2024 08:25:17 +0000 (UTC) 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-ed1-f49.google.com with SMTP id 4fb4d7f45d1cf-5572ffdba53so304266a12.1 for ; Fri, 05 Jan 2024 00:25:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1704443116; x=1705047916; 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=GdMglme1FJfw7lAsTxrQOv9zf0VFBKQ+XeA3yTFVwPY=; b=ph7Tx93mBP8BW9Wm+ilPiVumvQRsA+BfYxelnWMV4hbp2rUsYb2FzYlRDr4fRjkYzd AJsD5N0OgaxaWz0N4ucnnaoY5KwcMstMJIBkIO3RbAZPcn9ztKESln5C63dm7O79B+6i o6mjk7jKjTVHbxy+y+qZlF0RBQGc/mvYK/FdjfZZXj5lzOZ56fXgdZ5YgSBVNHKJYzNJ MaioQkztGoZcUQ/ALCkVcWyyvMX69qpy/QLvyH15+tqg8/tQRLziTctYsdfkWhg/kkko uVnyQEBSDpIgDI/uhejzCTwT1bdcLG/IBSuNi3eLQisCCkluFCveDE/3jzejulDI0QgN awPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704443116; x=1705047916; 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=GdMglme1FJfw7lAsTxrQOv9zf0VFBKQ+XeA3yTFVwPY=; b=qjX31ud0OZfApuCg7iaoH3I81qr5A5QnMQydEqROrpq96hF81J6tXwj0sTh8rvWJjm rV2DVSWOBvEA9dh3wiMX6HsXd3vyTNEPhzjYZ6TnQPE+gHm5xpWvFp2iu2E5pZ6V9Om9 gy1FmhWFKkwyjYxjzpHEGAQA/JCTb6LTCSOcjRHKAGkQ8QNijx6KeB8VMvmfhvOZEfQ1 IaVBKmw8K6r/CtaBWo58aWwD2/LUxVs+CQpW7+UjAdXEt8qZdkVMqxnS7pQu0T75+rFd 2yFAkk9CGjeXB1GwgmK5FkfdtqYYg9Ul1+petpzrnOpoM7P0QcohniAuWHTgTl4vlf+i aFAA== X-Gm-Message-State: AOJu0YzDjvfZNfOBNFr82iwsYGcxkJDmCpP3Tczn/y60LF/vWlrk52qX PcIECGZVRj+rsqdduoJgN1BuVbkwewQv1g== X-Received: by 2002:a17:907:1748:b0:a28:c289:7bd2 with SMTP id lf8-20020a170907174800b00a28c2897bd2mr792831ejc.37.1704443115928; Fri, 05 Jan 2024 00:25:15 -0800 (PST) Received: from claudiu-X670E-Pro-RS.. ([82.78.167.5]) by smtp.gmail.com with ESMTPSA id j15-20020a1709064b4f00b00a28e759a447sm596198ejv.213.2024.01.05.00.25.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jan 2024 00:25:15 -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, richardcochran@gmail.com, p.zabel@pengutronix.de, yoshihiro.shimoda.uh@renesas.com, wsa+renesas@sang-engineering.com Cc: netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, claudiu.beznea@tuxon.dev, geert+renesas@glider.be, Claudiu Beznea Subject: [PATCH net-next v3 16/19] net: ravb: Keep the reverse order of operations in ravb_close() Date: Fri, 5 Jan 2024 10:23:36 +0200 Message-Id: <20240105082339.1468817-17-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240105082339.1468817-1-claudiu.beznea.uj@bp.renesas.com> References: <20240105082339.1468817-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: 1787238428254006308 X-GMAIL-MSGID: 1787238428254006308 From: Claudiu Beznea Keep the reverse order of operations in ravb_close() when compared with ravb_open(). This is the recommended configuration sequence. Reviewed-by: Sergey Shtylyov Signed-off-by: Claudiu Beznea --- Changes in v3: - fixed typos in patch description - collected tags Changes in v2: - none; this patch is new 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 06c7ee45d567..76035afd4054 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -2189,6 +2189,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); @@ -2207,14 +2215,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 Fri Jan 5 08:23:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: claudiu beznea X-Patchwork-Id: 185278 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:6f82:b0:100:9c79:88ff with SMTP id tb2csp6093245dyb; Fri, 5 Jan 2024 00:30:26 -0800 (PST) X-Google-Smtp-Source: AGHT+IGLIE4BG2tFE1bfPBVYS1LN5KRtUbDvALAaVIf0NxNKCknWjdoDK4zX6mwZHP00izvIk0ej X-Received: by 2002:a05:6358:418b:b0:175:723f:f68c with SMTP id w11-20020a056358418b00b00175723ff68cmr659601rwc.54.1704443426679; Fri, 05 Jan 2024 00:30:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704443426; cv=none; d=google.com; s=arc-20160816; b=C35xK3CPoI49wwWeZRsJ2aY6kHaD4rYV8eFY75yeMBISv5b11CDSBDoDWXpqqUjjXG plRWtdR/2/uAlpWHBZ0YTTVbhhEtnGOdF+N5qomtKDTHD39kUxzfst+mQtGAf3MdHjAW rG6fEkDWdc0nec5N40kzs1XWbZXtk5W8Kpy8Bj2rsVcKZFnik0APqUsIdP2ZjtRGISUY Y29baoQLwBGedmMRVKuuSr+DyS81kSzz1jSZeLLUA5Cd3LwU7Nsx764SxVSCs08KnBQX C/YSWXzs/+YfKn+yDo2q5oAF6rMh9ZLchAMKtYF2flvlEd/I6NZqki3KSF2Vltum+QJm Db4Q== ARC-Message-Signature: i=1; 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=GE/LuMLhFciDAeK89cX4ivMbVkfulPVbUibYE+rpL9E=; fh=qryrdWWtksp4Ojh0keXejXriHeHARah4mOGZkuZ1jnk=; b=gm3B6DRM2kC//FFsD1MmVOtldp6bDgV/lY09wG/xHENM6McKq0obt6Nb6Vwfw6Oxsz JdZtKqZeqnIxPp1v5ucBE/YRCVAR+oyKRDiEZ/WYjiWjq7bzGEeuWoPHLh3NnFodwwi2 bdIjmW3F7IyQkIkkja8LcJnvRJ2Lqfy+5z49mHMLFbkZUFchMQSzlzRl6Z62J3c8xa4W ZYHukL1elw6nb8AnF+9mCNn1jr0T+lZxuza//F2TVER40ad9KziaI7QDX3+Ya9zaS0aV PINxpPmhPopEJvSLcrGctKX4VhYaIVCv7N8oKJCRbSnM1S3vJ0HDNmJU/8qK/0qQ5MMf dy3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@tuxon.dev header.s=google header.b=QH2zw0Ql; spf=pass (google.com: domain of linux-kernel+bounces-17596-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-17596-ouuuleilei=gmail.com@vger.kernel.org" Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id i8-20020a17090acf8800b002861c962e15si464461pju.15.2024.01.05.00.30.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jan 2024 00:30:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-17596-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@tuxon.dev header.s=google header.b=QH2zw0Ql; spf=pass (google.com: domain of linux-kernel+bounces-17596-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-17596-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 6D706B241DA for ; Fri, 5 Jan 2024 08:30:06 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7415B2E85E; Fri, 5 Jan 2024 08:25:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b="QH2zw0Ql" X-Original-To: linux-kernel@vger.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 723AA2E831 for ; Fri, 5 Jan 2024 08:25:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tuxon.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=tuxon.dev Received: by mail-lf1-f42.google.com with SMTP id 2adb3069b0e04-50ea226bda8so1400359e87.2 for ; Fri, 05 Jan 2024 00:25:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1704443120; x=1705047920; 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=GE/LuMLhFciDAeK89cX4ivMbVkfulPVbUibYE+rpL9E=; b=QH2zw0QlP7O0n6Op2s6/fILdKNUtQXISwyakEFE13PqydnS5IJoAnsH3rEn7z2oicb lAI1qJbUpQvLaW4Q2WywekwcVJNnEHIiXMOG7hqvVfuvfVdUi7WwGxGuAVrUKkJy1djz yURow/LZxST0FEaKKp3bMHIrOEafgTb+j3yuf2vBsmOToCxv98vu52DhWc1KR6mGgMDg GbzK28r5uecfjKm60eOncb9ZgBC35yUU2MM1wx5xRTZvqZ3z72at8WtBSuLDCdUwOw2W 5KZ1Yq+ofeYjh37QRR+uSf5C2s0OjtHkeDJMBAFLlFwok+ArRGdkDKZcMiGHUINrk4A+ yWIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704443120; x=1705047920; 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=GE/LuMLhFciDAeK89cX4ivMbVkfulPVbUibYE+rpL9E=; b=cC1Vz+3LmzMBdCoX1O83j9ibephTyykYCFscskqke3GD52WeUFeJ4VeyCPXTvFbiK6 Sq9+oRX9e0FQeh0OgOvOoFn7iMMIIMXyLJ5drxuJTfcjea0B4tnLgQLcRczAnnfvsLRf YBjGHc8ElPa6BMPMXPAkIeaorPcSXgc+U+BoJbmlPxbNLW6G7TkmLU4GHHbQFP93X6Wj Zw8xZUvtywo6g8l9aKZvDDZb0tqFAVuP7Om/wl/Cdi2x+Y/TIH6hFjIqJN8c+6SN59dE lSGap8lfq8S+EsEUj7UksSngL4PfAj0cNsDIncuolwDMKnzTX+o+qBtD04Abi7gUvHaD 9gcw== X-Gm-Message-State: AOJu0Yy9KARjzk0Ue/pOu1PUNZbqLqQ2pNoGHuCI8pfh8xD7BXOIOY9J OaX9R5L/av3h/zjoJWHSqeTnNjXxuW4F6A== X-Received: by 2002:a05:6512:2097:b0:50e:8107:1def with SMTP id t23-20020a056512209700b0050e81071defmr740789lfr.122.1704443120461; Fri, 05 Jan 2024 00:25:20 -0800 (PST) Received: from claudiu-X670E-Pro-RS.. ([82.78.167.5]) by smtp.gmail.com with ESMTPSA id j15-20020a1709064b4f00b00a28e759a447sm596198ejv.213.2024.01.05.00.25.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jan 2024 00:25:20 -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, richardcochran@gmail.com, p.zabel@pengutronix.de, yoshihiro.shimoda.uh@renesas.com, wsa+renesas@sang-engineering.com Cc: netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, claudiu.beznea@tuxon.dev, geert+renesas@glider.be, Claudiu Beznea Subject: [PATCH net-next v3 17/19] net: ravb: Return cached statistics if the interface is down Date: Fri, 5 Jan 2024 10:23:37 +0200 Message-Id: <20240105082339.1468817-18-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240105082339.1468817-1-claudiu.beznea.uj@bp.renesas.com> References: <20240105082339.1468817-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: 1787238470610939981 X-GMAIL-MSGID: 1787238470610939981 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(). The commit prepares the code for the addition of runtime PM support. Suggested-by: Sergey Shtylyov Signed-off-by: Claudiu Beznea --- Changes in v3: - this was patch 18/21 in v2 - use ndev->flags & IFF_UP instead of netif_running checks Changes in v2: - none; this patch is new drivers/net/ethernet/renesas/ravb_main.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c index 76035afd4054..168b6208db37 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -2117,6 +2117,9 @@ static struct net_device_stats *ravb_get_stats(struct net_device *ndev) const struct ravb_hw_info *info = priv->info; struct net_device_stats *nstats, *stats0, *stats1; + if (!(ndev->flags & IFF_UP)) + return &ndev->stats; + nstats = &ndev->stats; stats0 = &priv->stats[RAVB_BE]; @@ -2226,6 +2229,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 Fri Jan 5 08:23:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: claudiu beznea X-Patchwork-Id: 185277 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:6f82:b0:100:9c79:88ff with SMTP id tb2csp6093240dyb; Fri, 5 Jan 2024 00:30:25 -0800 (PST) X-Google-Smtp-Source: AGHT+IEJ29+rXlh5JO3xGA/1a5g08vsMh9L25SWEygOaaLON88TJI1QBBd3EbAGyI1YModL3O4U7 X-Received: by 2002:a05:6214:b64:b0:680:c837:de4e with SMTP id ey4-20020a0562140b6400b00680c837de4emr3221917qvb.57.1704443425216; Fri, 05 Jan 2024 00:30:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704443425; cv=none; d=google.com; s=arc-20160816; b=JMxY2au4mopjl582d5NX1RSPzs/0Jual66TRURlcS0QUBhzhTE3mgnvkUKI7I0ZWG8 PajAM/Fbu3pvex3mnSgNtCoYxeV1NIDTiTfQ58CroGNgve4FBjlsfPmpusWqwQN59yDn KGKFBwusX5ayWFu+Ld6uLK7CZ4fO9pQkxQwCOKqpD/TvPhyh4b5YcHhZW7SCPorX/Hpl EiOCtcTn3YR/1ZSBlT2r8Uaoh+tNqBb2VWjOHXaLF3fo3QKpDcTdzSdWRxQgJgXrHzGd UCV2CNrr8yAjrOkUwSgBklCPfJ6zDDsN2ir3BEMLzrZER4aZElHgk9LdMRjs3/1eTSKU 7KDA== ARC-Message-Signature: i=1; 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=pa02utebdKs4D+2qWkqTYzxjMn7PXC4HMfCizH3Aht0=; fh=qryrdWWtksp4Ojh0keXejXriHeHARah4mOGZkuZ1jnk=; b=XBvJoxQAtiCFHuq9q3j9u4UuE4N5U87oqZOkHewJ2bdsn4m3J41XLiTU/Oiw4luZsl nTFFAyhHQw6K/jPcMMRTAp5DwvNtr6bxNHRm9ub4ZmCeYyxvvsTo/izd2E2IAIS00p3L +8CONtdKVpK9IxKjz9T+9nC/a27rSd8jcq6LWr0C1xv6DKSEbOn024MuB6x8GeMc8jQd YMg6s/d2tHOcnA2dADujv4ucPjubr7O1XPa3tqB2Dd1WHFEZxZpEkFKizddGr9nhQx9d hUGDKuuY/T+OHlz1bIX5Sv2aWNrwAJrr1XbfY2XJcYKdXoHLD4DZymwHJJdWaaKLZX9Q LRbA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@tuxon.dev header.s=google header.b=Opqn68XX; spf=pass (google.com: domain of linux-kernel+bounces-17597-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-17597-ouuuleilei=gmail.com@vger.kernel.org" Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id p1-20020a0c8c81000000b0067f943d5762si1213088qvb.253.2024.01.05.00.30.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jan 2024 00:30:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-17597-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=Opqn68XX; spf=pass (google.com: domain of linux-kernel+bounces-17597-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-17597-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 ECEDF1C22C95 for ; Fri, 5 Jan 2024 08:30:24 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D82C93172D; Fri, 5 Jan 2024 08:25:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b="Opqn68XX" X-Original-To: linux-kernel@vger.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 D16232EB0A for ; Fri, 5 Jan 2024 08:25:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tuxon.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=tuxon.dev Received: by mail-lf1-f42.google.com with SMTP id 2adb3069b0e04-50e5a9bcec9so1680638e87.3 for ; Fri, 05 Jan 2024 00:25:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1704443125; x=1705047925; 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=pa02utebdKs4D+2qWkqTYzxjMn7PXC4HMfCizH3Aht0=; b=Opqn68XX1Ezi54wjTNi1VKdE8kLnkGgc/wZwdl/Ee2Tm7bb1yKQDLlMbuCAVsAD0Vx jWv+HcVx7bbgxDGbblomNLPs5I6H3DQvK/NO4FPvzZ7xyQhuBsM6mGmkk4Q7PSRi2jw5 fBTpsLj4M+kD6ipmVvaEF6ZXFP6GpAFlnVlbuEhcjmuzJbswcu6NDRRQWD3Z46uG+m6y /P8DFgGMJbxYFh2ZGWqyuFOAZKtbih4PmNU/un8+5MoQYwitfh32f6lmnSRKWGXt/6KW FfR4OrRgkBO2Irgpu3AO0wT8tyYsaxyeY31QoCSyg5zse5v/waDW2zQkrtZfE/1dZx8J 6sBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704443125; x=1705047925; 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=pa02utebdKs4D+2qWkqTYzxjMn7PXC4HMfCizH3Aht0=; b=OQk6TZQG/T4Sdrhh2Mo6P6zByrZMGnbOjJ+SL9so/84BVGXME+pieUxscShGqmyqni fK2BV91ywCFOwtcNqyy5zNz7t9sXndwMFaFpz5BB+0+NytolnLjeVDyhwHhIEoaUa4O3 AuulHg3kR78P+G7YLJTpzo7gsVuxoyMoRuonEcywu1HGMZR2EQ0LpG7ReoBBah8kwZML bXek8Phwh9Sb1kN9k/QKpNUchuwNbDRAuE3EKupLSy8YlMaZh0jJ3rKnZOPk7qAl7Pmz ZKRhVAuBgqdWtelpndUIPZB7deOG9zbmUVg21X2QM3ifFdogReOAP+Q35ObxAXn4wVnI q4XQ== X-Gm-Message-State: AOJu0YyAYJDpoSQKK1okbGiFs+KKnZbm7dVcZ3OKo8MBIv1XnN6becZo yegX8tmv/8ggThSyDKJiC4ylCh8j9ZJnZw== X-Received: by 2002:a05:6512:3109:b0:50e:4632:1d09 with SMTP id n9-20020a056512310900b0050e46321d09mr910812lfb.71.1704443124967; Fri, 05 Jan 2024 00:25:24 -0800 (PST) Received: from claudiu-X670E-Pro-RS.. ([82.78.167.5]) by smtp.gmail.com with ESMTPSA id j15-20020a1709064b4f00b00a28e759a447sm596198ejv.213.2024.01.05.00.25.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jan 2024 00:25:24 -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, richardcochran@gmail.com, p.zabel@pengutronix.de, yoshihiro.shimoda.uh@renesas.com, wsa+renesas@sang-engineering.com Cc: netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, claudiu.beznea@tuxon.dev, geert+renesas@glider.be, Claudiu Beznea Subject: [PATCH net-next v3 18/19] net: ravb: Do not apply RX CSUM settings to hardware if the interface is down Date: Fri, 5 Jan 2024 10:23:38 +0200 Message-Id: <20240105082339.1468817-19-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240105082339.1468817-1-claudiu.beznea.uj@bp.renesas.com> References: <20240105082339.1468817-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: 1787238468693210478 X-GMAIL-MSGID: 1787238468693210478 From: Claudiu Beznea Do not apply the RX CSUM settings to hardware if the interface is down. In case runtime PM is enabled, and while the interface is down, the IP will be in reset mode (as for some platforms disabling the clocks will switch the IP to reset mode, which will lead to losing registers content) and applying settings in reset mode is not an option. Instead, cache the RX CSUM settings and apply them in ravb_open() though ravb_emac_init(). Commit prepares for the addition of runtime PM. Signed-off-by: Claudiu Beznea --- Changes in v3: - 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: - none; this patch is new drivers/net/ethernet/renesas/ravb_main.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c index 168b6208db37..e909960fbc30 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -2342,6 +2342,9 @@ static void ravb_set_rx_csum(struct net_device *ndev, bool enable) struct ravb_private *priv = netdev_priv(ndev); unsigned long flags; + if (!(ndev->flags & IFF_UP)) + return; + spin_lock_irqsave(&priv->lock, flags); /* Disable TX and RX */ From patchwork Fri Jan 5 08:23:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: claudiu beznea X-Patchwork-Id: 185279 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:6f82:b0:100:9c79:88ff with SMTP id tb2csp6093386dyb; Fri, 5 Jan 2024 00:30:46 -0800 (PST) X-Google-Smtp-Source: AGHT+IFGTqGVn4H219itO4oVr0mqHN7AlShEYTHXFen6lLVm7fCeEtU1W44JyPjWyzGGgcu2yApf X-Received: by 2002:a17:906:6887:b0:a27:37b8:2809 with SMTP id n7-20020a170906688700b00a2737b82809mr1073653ejr.8.1704443446728; Fri, 05 Jan 2024 00:30:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704443446; cv=none; d=google.com; s=arc-20160816; b=dcG+Hrl55zXmyRtGBfwq1it2zGpWFi71HaWOpYkBcHAHwgdhkiI1dAx1EgwfI+2tyM PX26tpz74SGlxXoaJB3txB/S5Zv26uu4/FWXqZbwWn3+bFkrEsGZ8OY46DJPdVUm6nfM wpGP6q3XLD8ENSfq2FSrq7H5NzdLtp3hdAZsv44vjte4QIWKOOuuJUdwcKVJvqTjqTei HU8UBcyxvhEtfcuI2YyFsIaQACxtdm8Ct0NX+03P15KH+lO0epwNxrb9DxUOYWR/WOsv KB/vi1zdv4MKpxbHGF6LLcn+0rx/UAaoYbUGGOuKCpaubpYj6n9p7vGWHOtM4tzOYSDg wp8Q== ARC-Message-Signature: i=1; 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=D52HtaDyG1yQmVNxfMf3+ZvDLZVTUO44eFJ4THAqFfQ=; fh=qryrdWWtksp4Ojh0keXejXriHeHARah4mOGZkuZ1jnk=; b=ElL8fMrPYosTZlnBFB/QMcvwzu+fBeDP7pEOzu973EDgo8Lm+xRfssiy9xucGOeHi/ ew8EVfNdtuwpiHLjM2tNgT2Yd16PTdWnH7iGmrIjGTFiSmh4gENv96w5N2qCT+wLh2Cc 2n7JWJgpPzlw3pGNlQGvNUDeGoljQt/MyFrZABL4sNu2rzM/h8kk9cSiYSUWFYFV8Zog jzilF78T13CuHWw2wmFihmU4xXITNyx8cRum6Eutb1SddxiWKi7zCT3UXNOQgAWnvPVd E2feWIXAEnuMlb2GpjMUKWY3U23rzhgzHs9RdtaTGw7llSg4OEpgEAvmWYBeiJqM7ufd AuTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@tuxon.dev header.s=google header.b=lfFQt1IV; spf=pass (google.com: domain of linux-kernel+bounces-17598-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-17598-ouuuleilei=gmail.com@vger.kernel.org" Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id r11-20020a170906a20b00b00a2776d4d8aesi398489ejy.69.2024.01.05.00.30.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jan 2024 00:30:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-17598-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=lfFQt1IV; spf=pass (google.com: domain of linux-kernel+bounces-17598-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-17598-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 2D1AB1F23B26 for ; Fri, 5 Jan 2024 08:30:46 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 750F531A97; Fri, 5 Jan 2024 08:25:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b="lfFQt1IV" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-ej1-f41.google.com (mail-ej1-f41.google.com [209.85.218.41]) (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 502C331734 for ; Fri, 5 Jan 2024 08:25:31 +0000 (UTC) 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-ej1-f41.google.com with SMTP id a640c23a62f3a-a28ac851523so155006866b.0 for ; Fri, 05 Jan 2024 00:25:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1704443129; x=1705047929; 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=D52HtaDyG1yQmVNxfMf3+ZvDLZVTUO44eFJ4THAqFfQ=; b=lfFQt1IVBbUjxJzX7wU88vnF+faewzzYXcdtenrNORr6NHzk1P5lLd6wYrwnA25cwc hAS7yxXkaNpXDxEuyZIuSmAmIXWixm1QBXYi9q1Y7saCa7FAm50EWKvNc35AXEwTk20N 78XDUUjysSz76c0JSCef8DMznILqaciOV3aHub5YYts3Yjxe39+rKdyLRBr+dcWhO0I3 VQFL9HAt+AyFmiLafdXtaoKMYtsL9J/rK9xDPDstfGfMSdbEKCcpJFHTTYUwSDOJGRry G32qO9mbPQcirQY9h1GmavC8rLU49GZWlk2ByRKEghpMAgtbz9axtRqdrCx4XhYypJex oGfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704443129; x=1705047929; 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=D52HtaDyG1yQmVNxfMf3+ZvDLZVTUO44eFJ4THAqFfQ=; b=kIlX8+NCfB9ykk8J/Tuo+kTgFdZYepbzKo2MA2L/RJzG8noEoaO+rOHVWGWqd6zHVc EWL/O2P8zq5JEkV30h2nX3L72d6U7z7EBVqnlC1kfs/aIHZErH64MGJ2Q7prCkBCfyCf 7BDI8Sj1il3LZE89kc8vPPLNgVqRWeemixxuxM0RXkr7RDioRX011OCJvJWE+XK5k5HC qKRWMPRCoT1Xjb2hpFp2+mGI9z1Ucpq+JaS6lQy6AGdscrArHWut5c2AARxjz534jxfe jRHzdcxDwCAB3gI7MJK8CHWGmTqv03A29Ev5+Xc5nLIk3qaNKp3m5VheVmE6QydvB5H7 4vug== X-Gm-Message-State: AOJu0Yz6/R+B9E4pCVn3E1jt7GSSadJoA7b2Q54YOg0CQmseu/06LWAZ S1ltYxb/PTbDj/aYbt44aiR/aHIl4sy77w== X-Received: by 2002:a17:906:4554:b0:a28:b6a5:a26b with SMTP id s20-20020a170906455400b00a28b6a5a26bmr1003355ejq.141.1704443129678; Fri, 05 Jan 2024 00:25:29 -0800 (PST) Received: from claudiu-X670E-Pro-RS.. ([82.78.167.5]) by smtp.gmail.com with ESMTPSA id j15-20020a1709064b4f00b00a28e759a447sm596198ejv.213.2024.01.05.00.25.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jan 2024 00:25:29 -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, richardcochran@gmail.com, p.zabel@pengutronix.de, yoshihiro.shimoda.uh@renesas.com, wsa+renesas@sang-engineering.com Cc: netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, claudiu.beznea@tuxon.dev, geert+renesas@glider.be, Claudiu Beznea Subject: [PATCH net-next v3 19/19] net: ravb: Add runtime PM support Date: Fri, 5 Jan 2024 10:23:39 +0200 Message-Id: <20240105082339.1468817-20-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240105082339.1468817-1-claudiu.beznea.uj@bp.renesas.com> References: <20240105082339.1468817-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: 1787238491303696238 X-GMAIL-MSGID: 1787238491303696238 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 registers' content 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 registers 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). Reviewed-by: Sergey Shtylyov Signed-off-by: Claudiu Beznea --- Changes in v3: - this was patch 21/21 in v2 - collected tags - fixed typos in patch description Changes in v2: - keep RPM support for all platforms 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 e909960fbc30..e99351fe8d7f 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -1840,16 +1840,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); @@ -1883,6 +1888,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]); @@ -2184,6 +2192,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); @@ -2233,7 +2243,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) @@ -2725,6 +2742,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) @@ -2830,6 +2849,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: @@ -2847,6 +2869,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); @@ -2860,6 +2883,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) @@ -2871,8 +2900,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); @@ -2954,6 +2984,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); } @@ -2976,16 +3010,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; }