Received: by 2002:ab2:6816:0:b0:1f9:5764:f03e with SMTP id t22csp3066064lqo; Tue, 21 May 2024 06:05:54 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVcnAN5JLGA4f+gsE7XhaItQH2y+A5JmmSwenCChGXv5QJmLc6IliHkG9crRgGfT4u258i/U629hOLnZzA/xQSIEswxNOp4nhJw4GU/Jw== X-Google-Smtp-Source: AGHT+IHzzKGvyE93igLZlsSeKN/hCSK/y04Z/unFXonZ0mohnt0r8NeFPwg9Gwaz0vGMImAhL7zH X-Received: by 2002:a05:6808:647:b0:3c9:6bdd:27f9 with SMTP id 5614622812f47-3c997029c9dmr34722788b6e.6.1716296753750; Tue, 21 May 2024 06:05:53 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716296753; cv=pass; d=google.com; s=arc-20160816; b=I+h/w5nIHK3/vb9OnqrhlcPiORHFFAdd+1YX2zpy3iCkPB+qShis/j3YPaG4ViQJ6+ kf0mghJjRAUnaKvrA+HeLOqWAyM2Z+P6TuKIdLenjuLpGAIQ7+KSqGrKkkKpFdw9fNcm 0Ied2ea9pyHbDY7LZzcZtkbwqiw/0vZJlOMEFndxItYa8Y3TrdsTimd8yN3ZN7/qhse6 VApyGelYvQJmxKQZNIhNiuQInEqrxGcaS4/XP9WOVZoMzHujaU3IwlI4eQtIvjC6Ww90 NQyn19wiZ+/0YTt6jJJOgKU2/fvqplO/TsS0JKjCRvkxEvqJhYYAwi8rg8WaOdTnl0Ct sKhA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature:dkim-signature; bh=wbT5qGCbQ3w8gzwJLUsRH+xmTZWMepfT4VHSrrwEvqs=; fh=Ck0fOcHdhRzgBaHwp6SaSYBo0j21rhywV4MXv2yQ9aM=; b=WDaCIF7McUoAabi/I8UrqWFIJntM8TtOSRKAV9N5HuL2ipIWZXx1Mz2N002p52Gr2M WEQ1rBudqdYihHsPDJHX2jbaYXD7JO5mzqFL+fwxnR/YdRcvko9S3Vnj63krMm68w2DI gBmxkytEkuH7FNuWZm8MpFLTdSRRuyxoqeuAFnmm/A0DOB1xiBLfREBD7gpuwu8f8Gj1 tWKFiorptiYgF46GSn+e0TuHkHszt+6xbd1P24dG4g53fXulgTbSEAjR+b/owHQusTZj 7H48dfjCfJuKaqt+YY9EcfECuj2iYIgi4l7Y8XJoOMw19bSHOgnGCoIK5QyiqMz1hQiG MM/w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@tq-group.com header.s=key1 header.b=FSTBtDQr; dkim=temperror (no key for signature) header.i=@ew.tq-group.com header.s=dkim header.b="i7vkarm/"; arc=pass (i=1 spf=pass spfdomain=ew.tq-group.com dkim=pass dkdomain=tq-group.com dmarc=pass fromdomain=ew.tq-group.com); spf=pass (google.com: domain of linux-kernel+bounces-184983-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-184983-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=tq-group.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id 6a1803df08f44-6ab51777c7csi11705066d6.56.2024.05.21.06.05.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 May 2024 06:05:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-184983-linux.lists.archive=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=@tq-group.com header.s=key1 header.b=FSTBtDQr; dkim=temperror (no key for signature) header.i=@ew.tq-group.com header.s=dkim header.b="i7vkarm/"; arc=pass (i=1 spf=pass spfdomain=ew.tq-group.com dkim=pass dkdomain=tq-group.com dmarc=pass fromdomain=ew.tq-group.com); spf=pass (google.com: domain of linux-kernel+bounces-184983-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-184983-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=tq-group.com 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 683F51C20ED8 for ; Tue, 21 May 2024 13:05:53 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 19CD97A158; Tue, 21 May 2024 13:05:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tq-group.com header.i=@tq-group.com header.b="FSTBtDQr"; dkim=fail reason="key not found in DNS" (0-bit key) header.d=ew.tq-group.com header.i=@ew.tq-group.com header.b="i7vkarm/" Received: from mx1.tq-group.com (mx1.tq-group.com [93.104.207.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8A1CE74E09; Tue, 21 May 2024 13:05:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=93.104.207.81 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716296720; cv=none; b=L6L47kvNk7zViR0G4w7IhNxcEh8mbYg8MF87EevKpODw+HDYtaS7RO4KOPu+ZIk9eTu0iNCP/7kU0vBy8I20koA3jnb31NovgzMUli9s+4BNNL0Cf4gixt6CdAHB6Jc5rgD4fm0RsxAB1Bkdcy4wPI6QcQ9Q+VJCZhS6BWjXOnc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716296720; c=relaxed/simple; bh=NzMPYKXpTCqFoVng85NipKKUTY10wS1q1TVILzDVkP8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=q/V6JE5H8kM1MsPZqG8zUPcAPjyK2f6DLYF4DYrTjisQ9dOaTSsazicIrkkJ+M/lPidD0V6DEyvTJNFy9nizBbuFOmwwg2+AwFd90CDG/wT1GMD9LEpjA/al9l67USFe7mGtb2q4mO/dKMTUW8QyT+yU8gzny/Y8cGRWZ6c/xYM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ew.tq-group.com; spf=pass smtp.mailfrom=ew.tq-group.com; dkim=pass (2048-bit key) header.d=tq-group.com header.i=@tq-group.com header.b=FSTBtDQr; dkim=fail (0-bit key) header.d=ew.tq-group.com header.i=@ew.tq-group.com header.b=i7vkarm/ reason="key not found in DNS"; arc=none smtp.client-ip=93.104.207.81 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ew.tq-group.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ew.tq-group.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tq-group.com; i=@tq-group.com; q=dns/txt; s=key1; t=1716296717; x=1747832717; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=wbT5qGCbQ3w8gzwJLUsRH+xmTZWMepfT4VHSrrwEvqs=; b=FSTBtDQrVf7xBKK0gJAYyMxo8WE1Zt9S0xXcpBulixCUtmGUkPjq7523 0brlaRzcSdHWlp9xv1KwqsyYNkiEDHZxvTkkCNGhmxIXRJvU+5nPdr/q1 upcHVpQbrNVFRvlP/JQogmbDt7mtLd0g2jnrhdYDSIRcjx5o+MwcTv88k 00/SL3WszA4BTEFjFor7fDZ8gg0HItrzLqS3hBnefuT+POXTPlmCV44rg tHfuNwEsm49OhKF1eMOzUeqdQ0VnYK2TzXXwg4Nf7Kbg5yPSQlmKAde/G mI50CdTZ7jo7BB5bRVy54jspe9f2g3I6bOPYm3fao87c1VZibueCx9U5E A==; X-CSE-ConnectionGUID: DhogtdyYQqqfaWst8OedGg== X-CSE-MsgGUID: RzSFwDAQRBGeg3XrburrVg== X-IronPort-AV: E=Sophos;i="6.08,177,1712613600"; d="scan'208";a="36993956" Received: from vmailcow01.tq-net.de ([10.150.86.48]) by mx1.tq-group.com with ESMTP; 21 May 2024 15:05:13 +0200 Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id BA48417571D; Tue, 21 May 2024 15:05:08 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ew.tq-group.com; s=dkim; t=1716296709; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=wbT5qGCbQ3w8gzwJLUsRH+xmTZWMepfT4VHSrrwEvqs=; b=i7vkarm/1GguVGHK9iBjp6ahnWmfgfetORVMu8ee5oBHqJ9lUo9eSnLZZ6BsUNPd4xGwPN ghAJgeYVHeczvzLT6h3aridlcfHTjHXYXoUeiGQ3SU36EPOyHSq3LcJyFylFpXiZHT2iXu 92TKe12hRRbr2ue9VGQmnRS0zznMLBwx0Bfg9UzIzA2UeBqja2SbFSzjgUrlZ0mjggstmC ttVJBJdZeAC3g+j17aZ6k6ACFv0Ym99UWH8+uvwwugbI7hmGFhcxvjefvbGR7/s76ZBE0m LksU9nNOovSn3fScK3aPvs25MOVwaFwL+FD57vKb7lsq4VzNsY9Nwx/qavA9Ng== From: Gregor Herburger Date: Tue, 21 May 2024 15:04:52 +0200 Subject: [PATCH v3 2/8] can: mcp251xfd: move mcp251xfd_timestamp_start()/stop() into mcp251xfd_chip_start/stop() Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20240521-mcp251xfd-gpio-feature-v3-2-7f829fefefc2@ew.tq-group.com> References: <20240521-mcp251xfd-gpio-feature-v3-0-7f829fefefc2@ew.tq-group.com> In-Reply-To: <20240521-mcp251xfd-gpio-feature-v3-0-7f829fefefc2@ew.tq-group.com> To: Marc Kleine-Budde , Manivannan Sadhasivam , Thomas Kopp , Vincent Mailhol , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: linux-can@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux@ew.tq-group.com, gregor.herburger@ew.tq-group.com X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1716296697; l=4211; i=gregor.herburger@ew.tq-group.com; s=20230829; h=from:subject:message-id; bh=6jCsan+AmNK3z1pPyB+Muv4Lzg8cC/bnZRRhEIGbMRw=; b=tdbi2iqFtgFjEUgrzh8pbhRwl3F9k4jb68vlTVIgaQ3ayTPLD9u7RyLcpifz4SyztIwFA0usF pMQUaq6pkHUCBql8l6z+Qyfo12yRzDaVSI3b6TYroTMbT2Zli6B010X X-Developer-Key: i=gregor.herburger@ew.tq-group.com; a=ed25519; pk=+eRxwX7ikXwazcRjlOjj2/tbDmfVZdDLoW+xLZbQ4h4= X-Last-TLS-Session-Version: TLSv1.3 From: Marc Kleine-Budde The mcp251xfd wakes up from Low Power or Sleep Mode when SPI activity is detected. To avoid this, make sure that the timestamp worker is stopped before shutting down the chip. Split the starting of the timestamp worker out of mcp251xfd_timestamp_init() into the separate function mcp251xfd_timestamp_start(). Call mcp251xfd_timestamp_init() before mcp251xfd_chip_start(), move mcp251xfd_timestamp_start() to mcp251xfd_chip_start(). In this way, mcp251xfd_timestamp_stop() can be called unconditionally by mcp251xfd_chip_stop(). Signed-off-by: Marc Kleine-Budde Signed-off-by: Gregor Herburger --- drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c | 8 +++++--- drivers/net/can/spi/mcp251xfd/mcp251xfd-timestamp.c | 7 +++++-- drivers/net/can/spi/mcp251xfd/mcp251xfd.h | 1 + 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c b/drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c index e3c791f562d2..4ae201426a46 100644 --- a/drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c +++ b/drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c @@ -744,6 +744,7 @@ static void mcp251xfd_chip_stop(struct mcp251xfd_priv *priv, mcp251xfd_chip_interrupts_disable(priv); mcp251xfd_chip_rx_int_disable(priv); + mcp251xfd_timestamp_stop(priv); mcp251xfd_chip_sleep(priv); } @@ -763,6 +764,8 @@ static int mcp251xfd_chip_start(struct mcp251xfd_priv *priv) if (err) goto out_chip_stop; + mcp251xfd_timestamp_start(priv); + err = mcp251xfd_set_bittiming(priv); if (err) goto out_chip_stop; @@ -1610,11 +1613,12 @@ static int mcp251xfd_open(struct net_device *ndev) if (err) goto out_mcp251xfd_ring_free; + mcp251xfd_timestamp_init(priv); + err = mcp251xfd_chip_start(priv); if (err) goto out_transceiver_disable; - mcp251xfd_timestamp_init(priv); clear_bit(MCP251XFD_FLAGS_DOWN, priv->flags); can_rx_offload_enable(&priv->offload); @@ -1637,7 +1641,6 @@ static int mcp251xfd_open(struct net_device *ndev) out_can_rx_offload_disable: can_rx_offload_disable(&priv->offload); set_bit(MCP251XFD_FLAGS_DOWN, priv->flags); - mcp251xfd_timestamp_stop(priv); out_transceiver_disable: mcp251xfd_transceiver_disable(priv); out_mcp251xfd_ring_free: @@ -1662,7 +1665,6 @@ static int mcp251xfd_stop(struct net_device *ndev) mcp251xfd_chip_interrupts_disable(priv); free_irq(ndev->irq, priv); can_rx_offload_disable(&priv->offload); - mcp251xfd_timestamp_stop(priv); mcp251xfd_chip_stop(priv, CAN_STATE_STOPPED); mcp251xfd_transceiver_disable(priv); mcp251xfd_ring_free(priv); diff --git a/drivers/net/can/spi/mcp251xfd/mcp251xfd-timestamp.c b/drivers/net/can/spi/mcp251xfd/mcp251xfd-timestamp.c index 712e09186987..7bbf4603038b 100644 --- a/drivers/net/can/spi/mcp251xfd/mcp251xfd-timestamp.c +++ b/drivers/net/can/spi/mcp251xfd/mcp251xfd-timestamp.c @@ -58,9 +58,12 @@ void mcp251xfd_timestamp_init(struct mcp251xfd_priv *priv) cc->shift = 1; cc->mult = clocksource_hz2mult(priv->can.clock.freq, cc->shift); - timecounter_init(&priv->tc, &priv->cc, ktime_get_real_ns()); - INIT_DELAYED_WORK(&priv->timestamp, mcp251xfd_timestamp_work); +} + +void mcp251xfd_timestamp_start(struct mcp251xfd_priv *priv) +{ + timecounter_init(&priv->tc, &priv->cc, ktime_get_real_ns()); schedule_delayed_work(&priv->timestamp, MCP251XFD_TIMESTAMP_WORK_DELAY_SEC * HZ); } diff --git a/drivers/net/can/spi/mcp251xfd/mcp251xfd.h b/drivers/net/can/spi/mcp251xfd/mcp251xfd.h index 24510b3b8020..75d5a8a25415 100644 --- a/drivers/net/can/spi/mcp251xfd/mcp251xfd.h +++ b/drivers/net/can/spi/mcp251xfd/mcp251xfd.h @@ -950,6 +950,7 @@ int mcp251xfd_handle_tefif(struct mcp251xfd_priv *priv); void mcp251xfd_skb_set_timestamp(const struct mcp251xfd_priv *priv, struct sk_buff *skb, u32 timestamp); void mcp251xfd_timestamp_init(struct mcp251xfd_priv *priv); +void mcp251xfd_timestamp_start(struct mcp251xfd_priv *priv); void mcp251xfd_timestamp_stop(struct mcp251xfd_priv *priv); netdev_tx_t mcp251xfd_start_xmit(struct sk_buff *skb, -- 2.34.1