Received: by 2002:ab2:7b86:0:b0:1f7:5705:b850 with SMTP id q6csp1198833lqh; Sun, 5 May 2024 23:00:58 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVjhq6Axnbl7l1w9ucuz2eElRWp5xlGsPS0BSDD7yS8WPCLwAsnvpynDOPPV2zRRy2jt3rQlPH5QskU/GMJd2Aedm/zF6nmo/b3djJmkA== X-Google-Smtp-Source: AGHT+IFCeccR1Z2MObeODk+b6sySLHHaZbLki8jKYlBHLK9guqN3SM4V8UBkvm8xL0ao6Eq/dTFC X-Received: by 2002:a17:907:3f29:b0:a59:c2c3:bb45 with SMTP id hq41-20020a1709073f2900b00a59c2c3bb45mr2562259ejc.56.1714975258456; Sun, 05 May 2024 23:00:58 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714975258; cv=pass; d=google.com; s=arc-20160816; b=wABAu/PkDr7nBIB0RqBgYnR783vhtrzBtMHQ4N9QF3smTM0CyOPhO5ubafUD651gbT /66aGOgeC4B8y8XTq2SGdn/2FWNO4JM9cFc2IzWadVYiUVoI8j5gR2ftHfpjonKB7bVq 5QpBIOsb5xU/B33/CduV1ot4XqzDjXgAyJpXvocF5sOLpbpEYGgoSAjs5tSj6Z26sWCM mPEDKmOfAikM1rZBv6zgY1IvH4h5AbJ8Pl9yhZ06RejSRzhtcn/e154p3ML69jsfG/u+ gD0AMLapkyirCI3i5lVNmSeRsRi/L+LlJUX1PI73dhrIw2ewQptRzlXvJKUjYreAmU9a +bAA== 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=OBGFkZtBUY6CLcCH997A3eA6xZRxVGzOp58tM2v/Y8w=; fh=Ck0fOcHdhRzgBaHwp6SaSYBo0j21rhywV4MXv2yQ9aM=; b=TxLBfTcb/orkHAyDcumy+NR45BJP5fidH9shQVKxWfLzaiH8CLUb6wrz/td8UC/u1R 0BfexdkAD83YgPzkANS9oUu1/9jW6sLkuohebC/IQUQyDSoKjxE0PXwRqsAqMM/cfa1K vCdu0wGkGhtPhWDMJwBkelSQkX25sMn0umpmsPudtPxcPfk+iRDFfCZu2542ICuadZ6B 5xvQgrvmpjb2kTu6lzCZPw1HxhAYGbamZgBXQ6OtSV8OndW91cnnS2gNSb6zDjGP1lDY rm+WoGRx5noqBE1vewYZyrYvQOBFeD76yF5x903Na+p6jjI21ePBuJMHVCz25X+0lJA8 QLjQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@tq-group.com header.s=key1 header.b=dn1OdOHy; dkim=temperror (no key for signature) header.i=@ew.tq-group.com header.s=dkim header.b=ZaKSeGAg; 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-169338-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-169338-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 am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id d21-20020a1709067f1500b00a599d8e2187si2888458ejr.209.2024.05.05.23.00.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 May 2024 23:00:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-169338-linux.lists.archive=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=@tq-group.com header.s=key1 header.b=dn1OdOHy; dkim=temperror (no key for signature) header.i=@ew.tq-group.com header.s=dkim header.b=ZaKSeGAg; 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-169338-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-169338-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 0D5D51F21252 for ; Mon, 6 May 2024 06:00:58 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1C85213F44F; Mon, 6 May 2024 06:00:13 +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="dn1OdOHy"; 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="ZaKSeGAg" 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 C9C224AEE6; Mon, 6 May 2024 06:00:08 +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=1714975212; cv=none; b=fFWfJ4Zx7cxdT/kGchjwZ7fapEKs+5jIGzuRxZpSaJrlxH7U0JsG0wn/Qt5+UYrxsEgcjwFxhHJHdRSIR1K3AuU3XyJ4/nwct7c9Az0YzGxP2S8d6EiXfInDpyC2ct9IkQu0cW8tbiSsrcAZrkbmL9vylnEjjGHFuIFbYN6d/Ww= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714975212; c=relaxed/simple; bh=+Qveyuu1v4FvIUSFlIEA/3OG3zhEu/ongopJVNgfTKs=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=jnHwuSF+FIBfKmxr2BCGLmE+N0Qxwh6HbkCJ3QHFG+qL03F0HhrwY2kO6rNxTi654TyT/8xHFT+4YcAs+IGUDSF9NiAdMSCEhq5Vz63XuEr9k9nt5Qr10gPd7UmfQQqHoJDP5Pz//LMrnyom+GdtD7I+/9+DLv/R7GfbMdFFlOY= 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=dn1OdOHy; dkim=fail (0-bit key) header.d=ew.tq-group.com header.i=@ew.tq-group.com header.b=ZaKSeGAg 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=1714975209; x=1746511209; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=OBGFkZtBUY6CLcCH997A3eA6xZRxVGzOp58tM2v/Y8w=; b=dn1OdOHyO65A63YXB7qGFNDtf7mXerqDCtfh0eVikAeClB5aYQHTfbVw tJ1ikZLFZY9AR1dbvd6vkmhPda2UFWreVukwwxWVr4JpIrkaXwTTwIKls A8dFfQ+HofE4Zv/U0AjP0PEtxZKnMmiZmusU/gHIdxi4XJXIWlIoWXlfC 64rKfQFGl3TZ9ZUz2UWCW+Zd/weEh1v8za42lupjf07hsryCYuWps0PVv dR9NqogQZ9qcXFPVg8P2YP9dpuSokWyR5bbbaExvhyRw7QgEU7IcWrcGn NmNGyTZ/o+L35+m2Egufnx0VdnfsuNASN45nnoTaFePQ8+aT9eEuaF3NU w==; X-CSE-ConnectionGUID: sgBXbvymT4y4igDa5k0Jyw== X-CSE-MsgGUID: V/d2EelCSA6NHRq6xiLK3w== X-IronPort-AV: E=Sophos;i="6.07,257,1708383600"; d="scan'208";a="36751423" Received: from vmailcow01.tq-net.de ([10.150.86.48]) by mx1.tq-group.com with ESMTP; 06 May 2024 08:00:04 +0200 Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 7BA0A173CC9; Mon, 6 May 2024 07:59:59 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ew.tq-group.com; s=dkim; t=1714975200; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=OBGFkZtBUY6CLcCH997A3eA6xZRxVGzOp58tM2v/Y8w=; b=ZaKSeGAgjc16OMLdTm8ytJj47Vn3ZQHARvmtURcBEdpq3fYcKJzzUtWPjp8rwgilKnTlY8 pSBRcgIHl//GbCrd3+ndX/QytXC+CGaf9vamwX0BoD5q6aQQJHQE2h4zmD3rGVeHRJ203R whq9V5dt6sOIPSg9rkke6dRuoOdeALdHPdk2YPqLTMAHZtKbfg+q2HIBqc88ZUxeGef+EC WwP0PgZTCYYWb8alg7ClkicNHbPQiCHFkQqKDMgMVHCwNF+aaJCl0x/OKz1XBre5Vx39// ytwI3YTn46u9ZHlBcmxH8JHtONsJO76BAwIrpngNjgnqPGkaxYyDSs0IkUVZ+g== From: Gregor Herburger Date: Mon, 06 May 2024 07:59:44 +0200 Subject: [PATCH v2 2/6] 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: <20240506-mcp251xfd-gpio-feature-v2-2-615b16fa8789@ew.tq-group.com> References: <20240506-mcp251xfd-gpio-feature-v2-0-615b16fa8789@ew.tq-group.com> In-Reply-To: <20240506-mcp251xfd-gpio-feature-v2-0-615b16fa8789@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=1714975188; l=4143; i=gregor.herburger@ew.tq-group.com; s=20230829; h=from:subject:message-id; bh=5MNSUMJdhUcvqjyxAlN8mXO8gFpKVp+awDVJ/95Fxcc=; b=IhuWCKnDnD8tF2eOnbfbBclnTuuXZ8LjNKc1iuG79DCBOyX+R1jlJfhqj7z28uHpgsIRTUr5Q XO6Gy/YRZBFBYFSAvMlYXthbMb0+jkH161g2W11+LPVysM6UPV9FFGd 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 --- 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