Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2373228lqp; Sun, 24 Mar 2024 16:24:52 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUScTHSlYGKb5TzmBPlM3vTda0PSMbQhaOH4nQSk8iZs6WRNStbtG6KNm7adQY3lQakkzh7h819bBvQv2+dTqTRXlW1DcILam3mpP84wA== X-Google-Smtp-Source: AGHT+IGNMPsDKpfpqIBhrHuAhbnmGH+LaVpZGdpQj2Is6BzRqyi6PZi104u+dS/V6S9Tblj1Cjkg X-Received: by 2002:a05:6870:8293:b0:21e:b695:dff5 with SMTP id q19-20020a056870829300b0021eb695dff5mr6416038oae.20.1711322692581; Sun, 24 Mar 2024 16:24:52 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711322692; cv=pass; d=google.com; s=arc-20160816; b=D+6yz3kSMb3pKf1QrzZSYtYRaTu153+8+L3K8t8oDKiVy1NDgTRrk8Ww6U3DV06RNU woqtOa34Qms+fEzWQL2mka/heImHGX106f65yI1rhNk2zE5b97nmfrSEzharAfluUaqL usnmmnYqrt8uKby0TgBaHYJdjrxJEpbkSu+mPtwhv2c0D2co1slcHcbw+JQICsdt3Cl3 DdVAoa33zDtr89EFJv3ydCE3f1NfJ3isBWMGmJh7Ie6MZSpB4+bMExthqaVQ7VN8ono+ MmfkihNeq/04bW3ZF9+HL/XZc5MLJv+hGusK7v5LBW+8sWMOnPRzt2hdosvnRHgqREjD eDyw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=fKna9U/WXeaXbkdr56wzVTFQCz3tEByYjCcCTng7p3U=; fh=3Glp5XYcS0Ag7idt6egcC7+EI4FqZNUD2hXsO9F68hA=; b=CnYj/qcCGH9WXBH4e+NMCaLjIcEgbFJ7NPXoq2mB8xSf4vuCVDbcuY6+wEIidNVvNC Ll+0aASRpy3ZLUkLSaa7JWHPp2pBCI1q+rzvYhSD+NNP4gPkK/TEBiqMAGWqJjympV6K /6956BACTC0stj5TxtpAoNn/DvYHd+fQro0sIHJjc4EVZma2nBfKQnFNQKDVdNF8ieys Wdhlp9HOz0BB6pmi5mZKFSEcm5lL5KSyQXN3n57FVXw4U+cuKoIFksHEtLbv/2ebm1Eq z8kS4vBR2PMxqoEDk5bjTQsZ7bMQ0OuhDSXOb7jiohVX8uHiaQoKGMgdOQmyoRXUlqhW w+NQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="s1JJ/q3S"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-113080-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-113080-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id q6-20020a63f946000000b005d79ebbdc0asi6544811pgk.334.2024.03.24.16.24.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Mar 2024 16:24:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-113080-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="s1JJ/q3S"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-113080-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-113080-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=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 60FFF2810BD for ; Sun, 24 Mar 2024 23:17:51 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AC32D14D45E; Sun, 24 Mar 2024 22:38:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="s1JJ/q3S" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 BCAF75478B; Sun, 24 Mar 2024 22:38:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711319888; cv=none; b=bEUKGchqWcfbD0quaNhmi2sP0oH6u/Fx9k/qFg3Nf5zn2rXb3x2JBd7U4fMDcIXSaVNmd2nfVh9xhudK+dW86HGi2K0CTEjWdfVTX3amIAVm+IQkvo77srlsYN8jgUIFj7Ug0vAA8hfTeUPS81J0zXgKGDHOBcZMkZfvdbY2+hI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711319888; c=relaxed/simple; bh=z9jUFiSp3MUg0mH6coUgrT0+E54jL2MUqfmnswH9CjU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HmnyCtoVUlPpVAj1LgPqSWvxB+LLuaPYYi86lkrEYdVeTFr9MFdKBX8aGsjVwpYatEwY0oSjI3OoFvMqd/QGpalywtNp4l6gtiAFxRG2gYeiWLtEyB9lcll32nt0X3aYozlTZ1PHFxJXloPYT8Zpd01EMLu4WDMM2Clq6PYK62o= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=s1JJ/q3S; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id C2800C433C7; Sun, 24 Mar 2024 22:38:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711319888; bh=z9jUFiSp3MUg0mH6coUgrT0+E54jL2MUqfmnswH9CjU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=s1JJ/q3SNaOZWuXw4+j/K3Rpli7oZboruScfIueAoFvruaZmZBGeKXUmAFm6j5mkZ wZyUluhg9+tN+RWOWMXrJsm6d+ebGivq24/+4gi8rTzJ2AtT0h1IPHKa0IB68G7O/a Gpa5/WDR9MXmyrwrhyk6M19TOtcAoTxAN/uhdvWvIS1eIikZQCgGAt33jEvNx/fTgx z6WWb25Q11Tw4CMu4ZOPjp8pkV1oj3T+VPCHVxEZBM+nvaJS1QpyUIWIuIaI1U7nMN 8trn+tXCzh+JBYm3Uqygrlvc8qfpuY2NyAzAU+1L8zpADbsHtJNZ/Y0fmng3MmLXaq fuJv4O9tsniUw== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Markus Schneider-Pargmann , Judith Mendez , Simon Horman , Marc Kleine-Budde , Sasha Levin Subject: [PATCH 6.8 193/715] can: m_can: Start/Cancel polling timer together with interrupts Date: Sun, 24 Mar 2024 18:26:12 -0400 Message-ID: <20240324223455.1342824-194-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240324223455.1342824-1-sashal@kernel.org> References: <20240324223455.1342824-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit From: Markus Schneider-Pargmann [ Upstream commit a163c5761019b94258ca655b27b46e82657fd6f5 ] Interrupts are enabled/disabled in more places than just m_can_start() and m_can_stop(). Couple the polling timer with enabling/disabling of all interrupts to achieve equivalent behavior. Cc: Judith Mendez Fixes: b382380c0d2d ("can: m_can: Add hrtimer to generate software interrupt") Signed-off-by: Markus Schneider-Pargmann Reviewed-by: Simon Horman Link: https://lore.kernel.org/all/20240207093220.2681425-2-msp@baylibre.com Signed-off-by: Marc Kleine-Budde Signed-off-by: Sasha Levin --- drivers/net/can/m_can/m_can.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c index 16ecc11c7f62a..2395b1225cc8a 100644 --- a/drivers/net/can/m_can/m_can.c +++ b/drivers/net/can/m_can/m_can.c @@ -418,6 +418,13 @@ static void m_can_config_endisable(struct m_can_classdev *cdev, bool enable) static inline void m_can_enable_all_interrupts(struct m_can_classdev *cdev) { + if (!cdev->net->irq) { + dev_dbg(cdev->dev, "Start hrtimer\n"); + hrtimer_start(&cdev->hrtimer, + ms_to_ktime(HRTIMER_POLL_INTERVAL_MS), + HRTIMER_MODE_REL_PINNED); + } + /* Only interrupt line 0 is used in this driver */ m_can_write(cdev, M_CAN_ILE, ILE_EINT0); } @@ -425,6 +432,11 @@ static inline void m_can_enable_all_interrupts(struct m_can_classdev *cdev) static inline void m_can_disable_all_interrupts(struct m_can_classdev *cdev) { m_can_write(cdev, M_CAN_ILE, 0x0); + + if (!cdev->net->irq) { + dev_dbg(cdev->dev, "Stop hrtimer\n"); + hrtimer_cancel(&cdev->hrtimer); + } } /* Retrieve internal timestamp counter from TSCV.TSC, and shift it to 32-bit @@ -1417,12 +1429,6 @@ static int m_can_start(struct net_device *dev) m_can_enable_all_interrupts(cdev); - if (!dev->irq) { - dev_dbg(cdev->dev, "Start hrtimer\n"); - hrtimer_start(&cdev->hrtimer, ms_to_ktime(HRTIMER_POLL_INTERVAL_MS), - HRTIMER_MODE_REL_PINNED); - } - return 0; } @@ -1577,11 +1583,6 @@ static void m_can_stop(struct net_device *dev) { struct m_can_classdev *cdev = netdev_priv(dev); - if (!dev->irq) { - dev_dbg(cdev->dev, "Stop hrtimer\n"); - hrtimer_cancel(&cdev->hrtimer); - } - /* disable all interrupts */ m_can_disable_all_interrupts(cdev); -- 2.43.0