From patchwork Mon May 1 22:31:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Judith Mendez X-Patchwork-Id: 8816 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp215985vqo; Mon, 1 May 2023 15:32:51 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5jtIr2z2qfn5yLzSrvdk1eKNF5BXoDdfnElMmf3hR0qiNDs9Ud36LBeVALYDIyfTD79Gtc X-Received: by 2002:a17:90a:dd83:b0:244:d441:8f68 with SMTP id l3-20020a17090add8300b00244d4418f68mr23568497pjv.16.1682980371080; Mon, 01 May 2023 15:32:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682980371; cv=none; d=google.com; s=arc-20160816; b=VNIBRu5usKNVBiZLei4yrDNqXWZjDO1ka/esqvgIkIqyL2tsdDLHYisM7ZkISPWkTL hMdz+H0/GEI1cV8tQ9h5uFOZtAREetIcor0LE2wDtCXKVbeaQaF/6Pced4lFXJo1JPMR SFavy353VrbXmxW1tXBFFQh60md6eQ7X8N3kb8Ac0jXQYQpyxEQSNpirmG5CqrCnLf5v sipYpoC9lac+mo0QTHRD87Md2CVPr+Fc3gc5RQUsnp6Y/WSKRftgaDz2phYVgD9O7o3I 4w1roXJSeQcunzAUq9wIm40ePvsJ7vN+Nz0ytl4GFsWPeM0ZZIoibiWPyEfXkEURWxY5 RlXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from :dkim-signature; bh=6SMGVPvdhbJ9KTLC2b351MZOPiOCtSGbFUniZnLXzTI=; b=hMWTkmh2EmFoDqkDPOo9ez3zaznfdCwM3D+jEC/iNbndioPfl64jk/wpUat2tvJ8zS HTkiyLBRVyO2jneww1oyWpsSmi7nKT6jfyZLuaq2Yxn0TK1jHYcrLm7UE19O2sMELE38 1T5AVhrmupOjJ4tkryLu32F6H3ZJXqKxssCibnXp8e39ikB1Rq/aBxIY9R0CtL6OQWTB MIpA8pjn/Uz30E6JEeIgZth9MC1zwwSLldClfYt9I0iNIhcpuq2OSFUWhP1VWfRu0zkQ Rmv+EwPXn+Hv6r6DztVHmSctDC6UI9H1TNYHXR/NLrg2gyLqMcZh7Af9UCzUoJGNqdLO 3tvw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=x2uf5Www; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t17-20020a17090ad15100b002369d39671fsi9465331pjw.160.2023.05.01.15.32.36; Mon, 01 May 2023 15:32:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=x2uf5Www; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232785AbjEAWcL (ORCPT + 99 others); Mon, 1 May 2023 18:32:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59000 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230114AbjEAWcJ (ORCPT ); Mon, 1 May 2023 18:32:09 -0400 Received: from fllv0016.ext.ti.com (fllv0016.ext.ti.com [198.47.19.142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3EF782123; Mon, 1 May 2023 15:32:07 -0700 (PDT) Received: from fllv0035.itg.ti.com ([10.64.41.0]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id 341MVMpl048697; Mon, 1 May 2023 17:31:22 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1682980282; bh=6SMGVPvdhbJ9KTLC2b351MZOPiOCtSGbFUniZnLXzTI=; h=From:To:CC:Subject:Date; b=x2uf5WwwXibc2VTYhNFX2i+V8zSLvfYRK1h9r3jdelFrH4BTrOg0d9R5ag/heJsX5 1mbMmYLUUaD5DeekuQIqEQpp084//xom3kyAOUvkOmjqsVCYxKpvB17vV9MyHIlSMB /zjzal+2wyyRLU614d1E/kVFEMSRGBnbTPBa36V8= Received: from DLEE106.ent.ti.com (dlee106.ent.ti.com [157.170.170.36]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 341MVMWt129610 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 1 May 2023 17:31:22 -0500 Received: from DLEE101.ent.ti.com (157.170.170.31) by DLEE106.ent.ti.com (157.170.170.36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Mon, 1 May 2023 17:31:21 -0500 Received: from lelv0326.itg.ti.com (10.180.67.84) by DLEE101.ent.ti.com (157.170.170.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23 via Frontend Transport; Mon, 1 May 2023 17:31:21 -0500 Received: from a0498204.dal.design.ti.com (ileaxei01-snat.itg.ti.com [10.180.69.5]) by lelv0326.itg.ti.com (8.15.2/8.15.2) with ESMTP id 341MVLEG023009; Mon, 1 May 2023 17:31:21 -0500 From: Judith Mendez To: Chandrasekar Ramakrishnan , Wolfgang Grandegger , Marc Kleine-Budde , Krzysztof Kozlowski CC: "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , , , , Schuyler Patton , Nishanth Menon , Vignesh Raghavendra , Tero Kristo , Rob Herring , , , Oliver Hartkopp , Simon Horman Subject: [PATCH v3 0/4] Enable multiple MCAN on AM62x Date: Mon, 1 May 2023 17:31:17 -0500 Message-ID: <20230501223121.21663-1-jm@ti.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-Spam-Status: No, score=-4.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1764732825655560351?= X-GMAIL-MSGID: =?utf-8?q?1764732825655560351?= On AM62x there is one MCAN in MAIN domain and two in MCU domain. The MCANs in MCU domain were not enabled since there is no hardware interrupt routed to A53 GIC interrupt controller. Therefore A53 Linux cannot be interrupted by MCU MCANs. This solution instantiates a hrtimer with 1 ms polling interval for MCAN device when there is no hardware interrupt and there is poll-interval property in DTB MCAN node. The hrtimer generates a recurring software interrupt which allows to call the isr. The isr will check if there is pending transaction by reading a register and proceed normally if there is. On AM62x, this series enables two MCU MCAN which will use the hrtimer implementation. MCANs with hardware interrupt routed to A53 Linux will continue to use the hardware interrupt as expected. Timer polling method was tested on both classic CAN and CAN-FD at 125 KBPS, 250 KBPS, 1 MBPS and 2.5 MBPS with 4 MBPS bitrate switching. Letency and CPU load benchmarks were tested on 3x MCAN on AM62x. 1 MBPS timer polling interval is the better timer polling interval since it has comparable latency to hardware interrupt with the worse case being 1ms + CAN frame propagation time and CPU load is not substantial. Latency can be improved further with less than 1 ms polling intervals, howerver it is at the cost of CPU usage since CPU load increases at 0.5 ms. Note that in terms of power, enabling MCU MCANs with timer-polling implementation might have negative impact since we will have to wake up every 1 ms whether there are CAN packets pending in the RX FIFO or not. This might prevent the CPU from entering into deeper idle states for extended periods of time. This patch series depends on 'Enable CAN PHY transceiver driver': Link: https://lore.kernel.org/lkml/775ec9ce-7668-429c-a977-6c8995968d6e@app.fastmail.com/T/ v2: Link: https://lore.kernel.org/linux-can/20230424195402.516-1-jm@ti.com/T/#t V1: Link: https://lore.kernel.org/linux-can/19d8ae7f-7b74-a869-a818-93b74d106709@ti.com/T/#t RFC: Link: https://lore.kernel.org/linux-can/52a37e51-4143-9017-42ee-8d17c67028e3@ti.com/T/#t Changes since v2: - Change binding patch first - Update binding poll-interval description - Add oneOf to select either interrupts/interrupt-names or poll-interval - Sort list of includes - Create a define for 1 ms polling interval - Change plarform_get_irq to optional to not print error msg - Fix indentations, lengths of code lines, and added other style changes Changes since v1: - Add poll-interval property to bindings and MCAN DTB node - Add functionality to check for 'poll-interval' property in MCAN node - Bindings: add an example using poll-interval - Add 'polling' flag in driver to check if device is using polling method - Check for both timer polling and hardware interrupt case, default to hardware interrupt method - Change ns_to_ktime() to ms_to_ktime() Judith Mendez (4): dt-bindings: net: can: Add poll-interval for MCAN can: m_can: Add hrtimer to generate software interrupt arm64: dts: ti: Add AM62x MCAN MAIN domain transceiver overlay arm64: dts: ti: Enable MCU MCANs for AM62x .../bindings/net/can/bosch,m_can.yaml | 36 +++++++++++- arch/arm64/boot/dts/ti/Makefile | 2 + arch/arm64/boot/dts/ti/k3-am62-mcu.dtsi | 24 ++++++++ .../boot/dts/ti/k3-am625-sk-mcan-main.dtso | 35 ++++++++++++ .../boot/dts/ti/k3-am625-sk-mcan-mcu.dtso | 57 +++++++++++++++++++ drivers/net/can/m_can/m_can.c | 29 +++++++++- drivers/net/can/m_can/m_can.h | 4 ++ drivers/net/can/m_can/m_can_platform.c | 33 ++++++++++- 8 files changed, 213 insertions(+), 7 deletions(-) create mode 100644 arch/arm64/boot/dts/ti/k3-am625-sk-mcan-main.dtso create mode 100644 arch/arm64/boot/dts/ti/k3-am625-sk-mcan-mcu.dtso base-commit: 92e815cf07ed24ee1c51b122f24ffcf2964b4b13