From patchwork Fri Sep 29 14:12:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Schneider-Pargmann X-Patchwork-Id: 146691 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:cae8:0:b0:403:3b70:6f57 with SMTP id r8csp4206961vqu; Fri, 29 Sep 2023 10:49:36 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEPnv/8sOIrtwUWzDOLiHHIZKuHl68dE2gYpqx5w3vo0iVHuReWPvsp22c5fivsfl+7Qfc6 X-Received: by 2002:a05:6871:4cd:b0:1c1:e6da:f88d with SMTP id n13-20020a05687104cd00b001c1e6daf88dmr4670863oai.56.1696009776374; Fri, 29 Sep 2023 10:49:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696009776; cv=none; d=google.com; s=arc-20160816; b=uycVVP9FdxmZUiNPDZmPx04nCaEi2ammaP42nE64wVRXCa4UaF5xz3XNgCVOh+NCQo +1KWMvT61odjcalwdUlEWaZbZGtTWBph0E7Wz5epXBzryQ0jUdng41+SVsTSMzZa/l0Y nCzHaZDtSc20tlCdj0prM1ukIrpW7apEvy61Ifdevmp3ej57Tu7HXR0rP+iUjZ71BAvz zcfsThiJ93S9GWTy5MeBJjRwx4kYVF0uSCXeuxkw2cKC3+O/qky3AHzLG73ByyllfeSx AT4A4PDE9lWTR095RtTG1ETLGGkF4JfAlHHI6baqE1xjfdEEpbamilJlD0bdhpQVFEhv z/qg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=AP9/EZvDGvUhVhFYEHkXRFR3oagSwM5LS3r0l1v/oX0=; fh=EtuWLR14IhIbZM+E+fYn4isj1Y+iLrncbbgmHIVUFEQ=; b=CWij6ONzH5GbHPrvfXYqLJvdEUSTqhWYOTkTe41CpxQMnLjPvz4kwHsxCTNHwR1L4O RrxiksHGlShdNhHfQcb/Bm2VK1jEnIfG2MQIh3oitMX30OowQ4hTtbN5w35JT7XOGTTF KeI/GjD7blNJFZcfRbLFkIe7iWqsXcrt7qJpDou6i/SekAW3y6B4kDQ2bCBUwNy1A48L CPd3J7d3sI2LndrrN1pAnU3ZO9Az5+FG8M7zwkgBkLTDM5QXwUC71iG8mJ3Z4/eRO9G3 1m3U8yxlOjnK1ZVrshMWfG/npvgqSx55C1HAaghQuc2Lm7gSLq+8LESW9W6naX80yv2h Qezg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20230601.gappssmtp.com header.s=20230601 header.b=28lRs+NY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id s85-20020a632c58000000b005859c81f1e9si2553771pgs.229.2023.09.29.10.49.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Sep 2023 10:49:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20230601.gappssmtp.com header.s=20230601 header.b=28lRs+NY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id D3DC981DDD28; Fri, 29 Sep 2023 07:13:45 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233179AbjI2ONQ (ORCPT + 20 others); Fri, 29 Sep 2023 10:13:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44164 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233118AbjI2ONO (ORCPT ); Fri, 29 Sep 2023 10:13:14 -0400 Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DEFE31B0 for ; Fri, 29 Sep 2023 07:13:12 -0700 (PDT) Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-4060b623e64so4731435e9.0 for ; Fri, 29 Sep 2023 07:13:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1695996791; x=1696601591; 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=AP9/EZvDGvUhVhFYEHkXRFR3oagSwM5LS3r0l1v/oX0=; b=28lRs+NYbbeM0bA5/GrRJqSLdiQSOYhzXbDzzapk0rTAte25ZBHQVS/imDpiwxEWiG Y0SJhkoPlGvaYBpUUQQV7RHKDkpGXE7LaZKNVwcn/ftAIMHxfuyQL8XEGPQ4FMgfAAKw 1iYYdImnH/7BICRhNjFuqZkdp1K2Z65vjjCVxn/1B+nLb/hqrssUZRa3mqL470GSG03a KAtAaB/54tFDREGSO1qIACI7Texs1q5iAnWDOAyEOg/DNDXQSDdgixQg8KciK8LuTNEz DvYQKxNGf3nOl0LjmQ2c6QqRRUlkEc7txJ7Sy5OLNBnSdRpSnVqjE5HbrgNa0H3r6ki5 qPcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695996791; x=1696601591; 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=AP9/EZvDGvUhVhFYEHkXRFR3oagSwM5LS3r0l1v/oX0=; b=BIfdP95qPVDy2WjegfHuMX5ZM8PVyCrn4RalQhYG+gW4ZKBeL0j33cpzHyHmkxkmL7 KkettEL2UoPG/UEuktFne8RLB+A4Avjlab1CyNw82JNMx1GFz3tt3/BGz4gUQIFhlppe kEDZgqLGDy6t9L7BaRhHQ4ZukQOtO3RXvtpPfMg6I6Xoe4MVlSQKOVwhDjBgM0GMngFk ZPH6vqgncnDtg6gJFZ1hgHADOm6LDMNBQieYhdzdHkHmmjQs5o7FKIvFtBjo+LawQH+G /R+9n7muMRX84kehGUVzDDBEtVEN0UuhwfPKfSBaG9rR0raRcm9X1xGVnXVrRWYC+0tH BBFA== X-Gm-Message-State: AOJu0YyUuBF1aTI6DnpJNKTnUI5X02fFWq5zRvLFg1dmO/HXTLcxOilw M5+FmxFGxBNNE8xxMi8mfGQCaoUP5Tj5SyllexA6jw== X-Received: by 2002:a7b:c7d4:0:b0:401:c8b9:4b86 with SMTP id z20-20020a7bc7d4000000b00401c8b94b86mr3917397wmk.9.1695996790513; Fri, 29 Sep 2023 07:13:10 -0700 (PDT) Received: from blmsp.fritz.box ([2001:4091:a246:8222:dbda:9cd9:39cc:f174]) by smtp.gmail.com with ESMTPSA id t25-20020a7bc3d9000000b00405391f485fsm1513068wmj.41.2023.09.29.07.13.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Sep 2023 07:13:10 -0700 (PDT) From: Markus Schneider-Pargmann To: Marc Kleine-Budde , Chandrasekar Ramakrishnan , Wolfgang Grandegger Cc: Vincent MAILHOL , Simon Horman , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , linux-can@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Julien Panis , Judith Mendez , Markus Schneider-Pargmann Subject: [PATCH v6 01/14] can: m_can: Start/Cancel polling timer together with interrupts Date: Fri, 29 Sep 2023 16:12:51 +0200 Message-Id: <20230929141304.3934380-2-msp@baylibre.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230929141304.3934380-1-msp@baylibre.com> References: <20230929141304.3934380-1-msp@baylibre.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Fri, 29 Sep 2023 07:13:45 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778395147352414165 X-GMAIL-MSGID: 1778395147352414165 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 --- 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 16ecc11c7f62..2395b1225cc8 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);