From patchwork Mon Apr 24 19:53:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Judith Mendez X-Patchwork-Id: 8612 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2992326vqo; Mon, 24 Apr 2023 13:36:34 -0700 (PDT) X-Google-Smtp-Source: AKy350ZbOt10uh6UHGtOAiH0vdp/txmkX9/IHbWkOnkz5ZdnnqNV2xfBTUpr51kOZLbgcc11EXE9 X-Received: by 2002:a05:6a20:548d:b0:f5:92f0:81e8 with SMTP id i13-20020a056a20548d00b000f592f081e8mr3294874pzk.29.1682368593749; Mon, 24 Apr 2023 13:36:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682368593; cv=none; d=google.com; s=arc-20160816; b=02lPjyQ7FauFu5PZtBZ+Qx7Nin/WDJ8ElrPHge9aEVWb+iKZUXBwOSQu0cS/WkqT4U uEuP/8YjzLXI5La9rT8r+aKBTXc1VXka++VPLkrMqIT7gG28truOnr/+Fp/OnlNPcFXd 3CY2SvMz77cKmG9plKE7woe2AlUEscV1En0kP+FSKeE4quU49RBoL6ewycywE5+YKuoi 0I3He50gx1dkM+bdB8UZI7V38cOE75Rqp44Cv7Rzog2/L7Kibm6GnyUxQ55T+gd2jzHu 7ZEqWouK0UeWHDWiyJ19GTG/ulIzwuezhlNEMKmIKq6MSIyA/4oCNEJXu0iIaCEe9Ro1 UKbg== 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=CRNaEU+3hTqrHp9DO8zng7/FDGdFX/kjnkPhKcwTJP4=; b=bHE/+zm9enmt/mkEh3saP2QB+uOz90xpKk5RVL3GV7UI3XLp/1Tpg2prM4GBGhfQXX hIDtck8AuJcdBjHBenkGLdZClQe34zHxj3bmc17Y9PzlBSJ1RoA10HhgbbkqjsXuFnJK rfF8dypeeOZrT+Mg2IviVbNDpqRmJNnKF+83nAF1wVLFxxxXG1lH5vzv0D+5KS6cQtEl CxhXPK47PhTZ6MXSUS7iLkQJqeG2SJO3mM5lW4HKeFlIx3G4Tf1jlC+ZSb+wjgIz89C/ xmT2o40EVEt/NK+rOrkPsfXy2JrLotyRtt+maMHusR56OY5RP8OoOwRbt71SXKOYx5bz XvYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=LbTSF6tw; 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 o3-20020a63fb03000000b004faeaac4dacsi12141317pgh.753.2023.04.24.13.36.18; Mon, 24 Apr 2023 13:36:33 -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=LbTSF6tw; 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 S232987AbjDXTy4 (ORCPT + 99 others); Mon, 24 Apr 2023 15:54:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54414 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232827AbjDXTyd (ORCPT ); Mon, 24 Apr 2023 15:54:33 -0400 Received: from fllv0016.ext.ti.com (fllv0016.ext.ti.com [198.47.19.142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2A7E061B8; Mon, 24 Apr 2023 12:54:30 -0700 (PDT) Received: from fllv0034.itg.ti.com ([10.64.40.246]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id 33OJs2tg070547; Mon, 24 Apr 2023 14:54:02 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1682366042; bh=CRNaEU+3hTqrHp9DO8zng7/FDGdFX/kjnkPhKcwTJP4=; h=From:To:CC:Subject:Date; b=LbTSF6twPIOl3q4bpC7qQN+iHIk0JiOZAndsuWeOwOPNwOwGJgg75+1REznjVZ5Vo f7huDq8vhjPfg/jNCufSxUEApnq1dsWRIz560LQCs+lTOlISicW2gUjwqIuxuR15Qy JhNJKETUd3SvN+8XRZQ37ERz+TTOavTduC/NEAhE= Received: from DFLE103.ent.ti.com (dfle103.ent.ti.com [10.64.6.24]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 33OJs2ku095033 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 24 Apr 2023 14:54:02 -0500 Received: from DFLE108.ent.ti.com (10.64.6.29) by DFLE103.ent.ti.com (10.64.6.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.16; Mon, 24 Apr 2023 14:54:02 -0500 Received: from fllv0040.itg.ti.com (10.64.41.20) by DFLE108.ent.ti.com (10.64.6.29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.16 via Frontend Transport; Mon, 24 Apr 2023 14:54:02 -0500 Received: from a0498204.dal.design.ti.com (ileaxei01-snat.itg.ti.com [10.180.69.5]) by fllv0040.itg.ti.com (8.15.2/8.15.2) with ESMTP id 33OJs23F009344; Mon, 24 Apr 2023 14:54:02 -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 Subject: [PATCH v2 0/4] Enable multiple MCAN on AM62x Date: Mon, 24 Apr 2023 14:53:58 -0500 Message-ID: <20230424195402.516-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?1764091330379417157?= X-GMAIL-MSGID: =?utf-8?q?1764091330379417157?= 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': https://lore.kernel.org/lkml/775ec9ce-7668-429c-a977-6c8995968d6e@app.fastmail.com/T/ Previously sent an RFC: https://lore.kernel.org/linux-can/52a37e51-4143-9017-42ee-8d17c67028e3@ti.com/T/#t 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): can: m_can: Add hrtimer to generate software interrupt dt-bindings: net: can: Add poll-interval for MCAN 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 | 26 ++++++++- 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 | 30 ++++++++-- drivers/net/can/m_can/m_can.h | 5 ++ drivers/net/can/m_can/m_can_platform.c | 31 +++++++++- 8 files changed, 200 insertions(+), 10 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