Received: by 2002:ab2:7855:0:b0:1f9:5764:f03e with SMTP id m21csp377874lqp; Wed, 22 May 2024 07:17:07 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU4wfpHVBVwLy0Ezp6U7rtfHzuwbNpGFtmvU2fancCSMB+HwlLM4G18nA24ZXCaYuEOZxbAPjilyzhlsAc3kUrS3YfGOoUp8RAeFcBnbA== X-Google-Smtp-Source: AGHT+IGWls9AbOgq7wDt096jVUE93MdlHEmBmJoboPV37A9cDH8oSz0CLD1uZbK0cx0YgdJ/Z67X X-Received: by 2002:aca:1118:0:b0:3c9:9385:d2fc with SMTP id 5614622812f47-3cdb20adbf3mr2137317b6e.8.1716387427347; Wed, 22 May 2024 07:17:07 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716387426; cv=pass; d=google.com; s=arc-20160816; b=IoLJ1+u96FfPvgtMUzNBtEZuBOeA5ao3wPEsf1IFS+E0Bro99sJxu4yUVa72t+4Ws8 8Bb8QQhzheA8+/UhIS3HTCiE1we5PoqKg4oA67vseSma2cByzPKufz/F7pSlrimChOKM 5O1LeQgr4+Ag/iWd0gMjqd9TN+rcC74/eW86JEfHiRknnYqpe2dXXGDOtcVDK8PZGyhL JNIh2V44VZhqSOAcvhmAnrnvhLG50mR2tQMm2SkbJnirrqjs158bYq+7RKh8jQeTvYt4 GQ9tfPP5pMwRrKOZY5/fhgvpIgEXmp7/5LitNjNE7zuNU7ZatMRcDs6O1+NKPyxtBThl 4RdA== 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=P3sMAbFRIkWBmPB0o0w75mawDZ6JyCZpMjJ0oYP1Rdc=; b=HYFIaaB0zDUWwNwM5wpJfKo37y1R1X9E0I1cqChw5ySzqdzee2Pf7KTq9F/62EsZnT 2grwLFVMoXuXeIVe+UWmwHV/daRkVgnE8L4C7AG0vsj+9YOZsCLBkVMQRk/lB88F1RGV 0jAbU/UdlEdfPhwNxBGjX9wgLYxaMsAU/ToT3aBZuXbyDoxHYcn6VYoKBsY0+qJ0IwiN 1yb2aoM6yJbVdcQWbdjdjcPM6pL6+YjYEDkT1zuHkxUVH+TQ2O+VK15XlNgik9GjEVmB 1bRLUmdv3S4sw8eqcnPEGCEyVrMUs9fYHF1pIuKiNHpj137Ia0sjw3j8JGmx52UwQSQ5 Z8uA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@tq-group.com header.s=key1 header.b=lzObuZqJ; dkim=temperror (no key for signature) header.i=@ew.tq-group.com header.s=dkim header.b=ZezbdcxI; 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-186342-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-186342-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 af79cd13be357-792bf3651d0si2958866485a.638.2024.05.22.07.17.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 May 2024 07:17:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-186342-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=lzObuZqJ; dkim=temperror (no key for signature) header.i=@ew.tq-group.com header.s=dkim header.b=ZezbdcxI; 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-186342-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-186342-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 704741C22BD7 for ; Wed, 22 May 2024 14:17:06 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DC935144304; Wed, 22 May 2024 14:16:18 +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="lzObuZqJ"; 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="ZezbdcxI" 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 9CC4F1420C9; Wed, 22 May 2024 14:16:14 +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=1716387377; cv=none; b=ruDdbnJiQxyKf9My0l1heDxhOS/FnjTHskkUHN30hcLP5QLXRMlqh5QmcA1tYT/9vv0UkcNizbJQhljvgsccXMYMpQfi2AI4EkN3Tk9ZHZOmEM/zipXmheJj8vK1eoz/918XTfERLpWUo8s7MQB2WDsYfezpUtEZItaW8Q0FMtA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716387377; c=relaxed/simple; bh=NzMPYKXpTCqFoVng85NipKKUTY10wS1q1TVILzDVkP8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ZF9kiXFAA8pE/4VZfN8gw9ZrgUsOBcWP3GhBKeZYko6Y/zkZMMSUgkC1lgmPiY67IKBNZvFm6fAYORApfPp6UGKBNTgJREt6Txg2yT4FBrlTNsTjndKwmCZNgqt/P/EatQTkKDmkUXLpDUgUDuO4CF/yUaSVO546O7pttuKQR58= 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=lzObuZqJ; dkim=fail (0-bit key) header.d=ew.tq-group.com header.i=@ew.tq-group.com header.b=ZezbdcxI 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=1716387375; x=1747923375; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=wbT5qGCbQ3w8gzwJLUsRH+xmTZWMepfT4VHSrrwEvqs=; b=lzObuZqJ2nvxYUBov6xo9JOJwNLOTOlxuhPfviiR2XGc9Yp0DTsWz+NX AE8yR5kZbfx4C5YgmX4wp1XMyIRwr9Gm+0NpvK32U8h7+Iguis1i2oHuU 0Jipom6Ste7uECg2gRZ4hEktmDfd1PSUB3gIA/wSAUvrphSWuJMA54XB8 b7qm2/cSKstfR7TPrCO4/M/lbQaZRzpllfB1C9RXbvAqGDn7FpPwyTAmc E/ulR73D4lBNkivoDg7cmCNHJLBUNx6tkavYfsuGb0sANeipm1008QbCH +ax6ws6g70s2gPSffJBCKH0KE1GmtoQ5GnUfCAV0IWiR38Za8UBC/KrIJ A==; X-CSE-ConnectionGUID: uvCL948qQSOE9mEJWFxNrA== X-CSE-MsgGUID: LA+2zRgqRBiL65s6w03yOA== X-IronPort-AV: E=Sophos;i="6.08,179,1712613600"; d="scan'208";a="37017662" Received: from vmailcow01.tq-net.de ([10.150.86.48]) by mx1.tq-group.com with ESMTP; 22 May 2024 16:16:11 +0200 Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id BF7A5161329; Wed, 22 May 2024 16:16:06 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ew.tq-group.com; s=dkim; t=1716387367; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=wbT5qGCbQ3w8gzwJLUsRH+xmTZWMepfT4VHSrrwEvqs=; b=ZezbdcxICf8QGitEhwwvC9gejwjYMJEfd2Pdu6FMeSOkJzuGNlTnmpIk1vjzuIlBX8LMH2 6JvD86S2/BisuJjekEWFJFr0wSiJTsOl15+CWnrBWM32at5GktAXSmGqoYz2IZvQkeCqff HP+NFRjxTrKN3bJCkMcapfMPTlwwjpJs4IRuVKZlucKbXSWxTqF4wWvr8nT/Uryb3MevSh 6Vj52Akqq1d7wkg+oiKCZYNnwNtwkfQec443UN+6O0tSAhyfu4y3VO3zcf4GB/UzRbpRVd Xk4v1VF6WGZo4bS8Cf1Lzb3sut2C/Z8zgZOAi9W6VD+LtGJHnfmXDxMkEo5GZw== From: Gregor Herburger Date: Wed, 22 May 2024 16:15:19 +0200 Subject: [PATCH RESEND 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: <20240522-mcp251xfd-gpio-feature-v3-2-8829970269c5@ew.tq-group.com> References: <20240522-mcp251xfd-gpio-feature-v3-0-8829970269c5@ew.tq-group.com> In-Reply-To: <20240522-mcp251xfd-gpio-feature-v3-0-8829970269c5@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, Linus Walleij , Bartosz Golaszewski X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1716387339; l=4211; i=gregor.herburger@ew.tq-group.com; s=20230829; h=from:subject:message-id; bh=6jCsan+AmNK3z1pPyB+Muv4Lzg8cC/bnZRRhEIGbMRw=; b=brbCIcuk23DtybmxpGabAvgNpCg7EHOi6CTMds7INhlkrpQeevXaO094j3sxNPvTnm9Y97leW spUZT7wnRkZAB31uwrjofcfU+IekbBC+TtFwvvIPlLofpr4fg8VVOOW 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