Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp1869907ybz; Thu, 23 Apr 2020 07:27:29 -0700 (PDT) X-Google-Smtp-Source: APiQypIk4ta9HVjgSK+kyGmdTQGpGXbwDcjUtbu18KMXiGjMOJyEIlmTXxeKIwqiDmMSlRFNxxlJ X-Received: by 2002:a05:6402:4a:: with SMTP id f10mr3053283edu.274.1587652049363; Thu, 23 Apr 2020 07:27:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587652049; cv=none; d=google.com; s=arc-20160816; b=YWyB84ZLgncaMZLVPu4AaGykdvyK68QoXh79tQoQ//pdbg48HnTzEa+d8nUphhPrjj w7J5UibeOrwxLA5ZsRKLvEzcn5vHLR+ULvaPdT01wkvlxLr9T1bsQxRPltk3he2e+BNT o/Ql3pR6T1J634WRY7VeRleeOOtQLS/gCyPqSlA3YgpVVtSXjqvttGzMoVZMxo5yUDsG k0zoshNUGuwq32QJTjYrOw+7R+RBWmnZFy4frgIccbD9Sv9EC8s0nhgDUj7PVtF5IHwU TJwKO6Mtc8Bl27vXajPsAIyiR0PLD5phK2ce1fkgn+D+9z0ua4rMAvCgn8B221sFyuf5 QX+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from:dkim-signature; bh=ollByxbrSURa6xnkZ2klfCdwR2dJUjXfp7sNresnq8k=; b=isObsZz+eikKytef2pEW1AexEV92/4y7abpNshR4A3V0N9WlDIYuUNMU8SEqbxyT0y 72JsLgWTUaXLEB5iHXOfdEOHEQ0CD2Fwf6tdrTOQ49gmHzNXLGrlQhcbfKs6Y9Nf6TUZ rprZWrO63/N4/42exfE/sUR+PyGR4I1IW5cLZMpOTtWIdZusDj71LUnto2SBXLlpl2/M Doz2he2U5WqaU+DepN/PG5IIUqKqQkSj2MDO0rmHGARwnT7NqrReEGVIwiE4kOQLMDBd uOoOj0SVe1Xc/J5BpfJS5b9RfG/cYwDtBUeRJKjNSi+x+yDPgWyTUHSxIrSCjH+d0Wf3 MzEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=llHmBXMh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dc18si1294938ejb.497.2020.04.23.07.27.04; Thu, 23 Apr 2020 07:27:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=llHmBXMh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1728566AbgDWOVI (ORCPT + 99 others); Thu, 23 Apr 2020 10:21:08 -0400 Received: from lelv0143.ext.ti.com ([198.47.23.248]:58428 "EHLO lelv0143.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726910AbgDWOVI (ORCPT ); Thu, 23 Apr 2020 10:21:08 -0400 Received: from fllv0035.itg.ti.com ([10.64.41.0]) by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id 03NEL260076248; Thu, 23 Apr 2020 09:21:02 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1587651662; bh=ollByxbrSURa6xnkZ2klfCdwR2dJUjXfp7sNresnq8k=; h=From:To:CC:Subject:Date; b=llHmBXMh593oW2scepAJq6vMSjb1QwHo1sBn71vZyMGkHxhv4hjx5gDSNrLohtBSK ZmM4dZXCl1hUCp11J+ZrSbz4XhbYzUugW++XWcBPv3FbtBJosirF2KPhzdTb6sputo uBz6LLM7GNgZW60I/aYaKCjsDoIhHNDg9KyaTFik= Received: from DFLE110.ent.ti.com (dfle110.ent.ti.com [10.64.6.31]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTP id 03NEL2hr053251; Thu, 23 Apr 2020 09:21:02 -0500 Received: from DFLE102.ent.ti.com (10.64.6.23) by DFLE110.ent.ti.com (10.64.6.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1979.3; Thu, 23 Apr 2020 09:21:01 -0500 Received: from fllv0040.itg.ti.com (10.64.41.20) by DFLE102.ent.ti.com (10.64.6.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1979.3 via Frontend Transport; Thu, 23 Apr 2020 09:21:01 -0500 Received: from localhost (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0040.itg.ti.com (8.15.2/8.15.2) with ESMTP id 03NEL01I027119; Thu, 23 Apr 2020 09:21:01 -0500 From: Grygorii Strashko To: Richard Cochran , Lokesh Vutla , Tony Lindgren , "David S. Miller" CC: , Sekhar Nori , , Murali Karicheri , , Grygorii Strashko Subject: [PATCH net-next v5 00/10] net: ethernet: ti: cpts: add irq and HW_TS_PUSH events Date: Thu, 23 Apr 2020 17:20:12 +0300 Message-ID: <20200423142022.10538-1-grygorii.strashko@ti.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Content-Type: text/plain X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Richard, All, This is re-spin of patches to add CPSW IRQ and HW_TS_PUSH events support I've sent long time ago [1]. In this series, I've tried to restructure and split changes, and also add few additional optimizations comparing to initial RFC submission [1]. The HW_TS_PUSH events intended to serve for different timesync purposes on of which is to add PPS generation function, which can be implemented as below: +-----------------+ | Control | | application | +------->+ +----------+ | | | | | | | | | +-----------------+ | | | | | | PTP_EXTTS_REQUEST | | | | | +----------------------------------------------------------------+ | | Kernel +-------+----------+ +-------v--------+ | \dev\ptpX | | /sys/class/pwm/| | | | | +-------^----------+ +-------+--------+ | | | | | +-------v-------------------+ +-------+----------+ | | | CPTS driver | |pwm/pwm-omap-dmtimer.c | | | +---------------------------+ +-------^----------+ |clocksource/timer_ti_dm.c | | +-------+-------------------+ |HWx_TS_PUSH evt | +----------------------------------------------------------------+ | | HW +-------+----------+ +-------v--------+ | CPTS | | DMTimer | | | | | | HWx_TS_PUSH X<-----------------+ | | + | | +------------------+ +-------+--------+ | X timer4 As per my knowledge there is at least one public implemented above PPS generation schema from Tusori Tibor [2] based on initial HW_TS_PUSH enable submission[1]. And now there is work done by Lokesh Vutla published to enable PWM enable/improve PWM adjustment from user space [3][4][5]. Main changes comparing to initial submission: - TX timestamp processing deferred to ptp worker only - both CPTS IRQ and polling events processing supported to make it work for Keystone 2 also - switch to use new .gettimex64() interface - no DT updates as number of HWx_TS_PUSH inputs is static per HW Testing on am571x-idk/omap2plus_defconfig/+CONFIG_PREEMPT=y: 1) testing HW_TS_PUSH - enable pwm in DT pwm16: dmtimer-pwm { compatible = "ti,omap-dmtimer-pwm"; ti,timers = <&timer16>; #pwm-cells = <3>; }; - configure and start pwm echo 0 > /sys/class/pwm/pwmchip0/export echo 1000000000 > /sys/class/pwm/pwmchip0/pwm0/period echo 500000000 > /sys/class/pwm/pwmchip0/pwm0/duty_cycle echo 1 > /sys/class/pwm/pwmchip0/pwm0/enable - test HWx_TS_PUSH using Kernel selftest testptp application ./tools/testing/selftests/ptp/testptp -d /dev/ptp0 -e 1000 -i 3 2) testing phc2sys # ./linuxptp/phc2sys -s CLOCK_REALTIME -c eth0 -m -O 0 -u30 phc2sys[1616.791]: eth0 rms 408190379792180864 max 1580914543017209856 freq +864 +/- 4635 delay 645 +/- 29 phc2sys[1646.795]: eth0 rms 41 max 108 freq +0 +/- 36 delay 656 +/- 29 phc2sys[1676.800]: eth0 rms 43 max 83 freq +2 +/- 38 delay 650 +/- 0 phc2sys[1706.804]: eth0 rms 39 max 87 freq +4 +/- 34 delay 672 +/- 55 phc2sys[1736.808]: eth0 rms 35 max 66 freq +1 +/- 30 delay 667 +/- 49 phc2sys[1766.813]: eth0 rms 38 max 79 freq +2 +/- 33 delay 656 +/- 29 phc2sys[1796.817]: eth0 rms 45 max 98 freq +1 +/- 39 delay 656 +/- 29 phc2sys[1826.821]: eth0 rms 40 max 87 freq +5 +/- 35 delay 650 +/- 0 phc2sys[1856.826]: eth0 rms 29 max 76 freq -0 +/- 25 delay 656 +/- 29 phc2sys[1886.830]: eth0 rms 40 max 97 freq +4 +/- 35 delay 667 +/- 49 phc2sys[1916.834]: eth0 rms 42 max 94 freq +2 +/- 36 delay 661 +/- 41 phc2sys[1946.839]: eth0 rms 40 max 91 freq +2 +/- 35 delay 661 +/- 41 phc2sys[1976.843]: eth0 rms 46 max 88 freq -0 +/- 40 delay 667 +/- 49 phc2sys[2006.847]: eth0 rms 49 max 97 freq +2 +/- 43 delay 650 +/- 0 3) testing ptp4l - 1G connection # ./linuxptp/ptp4l -P -2 -H -i eth0 -l 6 -m -q -p /dev/ptp0 -f ptp.cfg -s ptp4l[862.891]: port 1: UNCALIBRATED to SLAVE on MASTER_CLOCK_SELECTED ptp4l[923.894]: rms 1019697354682 max 5768279314068 freq +26053 +/- 72 delay 488 +/- 1 ptp4l[987.896]: rms 13 max 26 freq +26005 +/- 29 delay 488 +/- 1 ptp4l[1051.899]: rms 14 max 50 freq +25895 +/- 21 delay 488 +/- 1 ptp4l[1115.901]: rms 11 max 27 freq +25878 +/- 17 delay 488 +/- 1 ptp4l[1179.904]: rms 10 max 27 freq +25857 +/- 12 delay 488 +/- 1 ptp4l[1243.906]: rms 14 max 37 freq +25851 +/- 15 delay 488 +/- 1 ptp4l[1307.909]: rms 12 max 33 freq +25835 +/- 15 delay 488 +/- 1 ptp4l[1371.911]: rms 11 max 27 freq +25832 +/- 14 delay 488 +/- 1 ptp4l[1435.914]: rms 11 max 26 freq +25823 +/- 11 delay 488 +/- 1 ptp4l[1499.916]: rms 10 max 29 freq +25829 +/- 11 delay 489 +/- 1 ptp4l[1563.919]: rms 11 max 27 freq +25827 +/- 12 delay 488 +/- 1 - 10M connection # ./linuxptp/ptp4l -P -2 -H -i eth0 -l 6 -m -q -p /dev/ptp0 -f ptp.cfg -s ptp4l[51.955]: port 1: UNCALIBRATED to SLAVE on MASTER_CLOCK_SELECTED ptp4l[112.957]: rms 279468848453933920 max 1580914542977391360 freq +25390 +/- 3207 delay 8222 +/- 36 ptp4l[176.960]: rms 254 max 522 freq +25809 +/- 219 delay 8271 +/- 30 ptp4l[240.962]: rms 271 max 684 freq +25868 +/- 234 delay 8249 +/- 22 ptp4l[304.965]: rms 263 max 556 freq +25894 +/- 227 delay 8225 +/- 47 ptp4l[368.967]: rms 238 max 648 freq +25908 +/- 204 delay 8234 +/- 40 ptp4l[432.970]: rms 274 max 658 freq +25932 +/- 237 delay 8241 +/- 22 ptp4l[496.972]: rms 247 max 557 freq +25943 +/- 213 delay 8223 +/- 26 ptp4l[560.974]: rms 291 max 756 freq +25968 +/- 251 delay 8244 +/- 41 ptp4l[624.977]: rms 249 max 697 freq +25975 +/- 216 delay 8258 +/- 22 Changes in v5: - fixed build issue Changes in v4: - fixed comments from Richard Cochran - dropped patch "net: ethernet: ti: cpts: move rx timestamp processing to ptp worker only" - added "Acked-by" from Richard Cochran - dependencies resolved, patch merged Changes in v3: - fixed rebase mess - fixed build issues Changes in v2 (broken): - fixed (formatting) comments from David Miller v4: https://patchwork.ozlabs.org/project/netdev/cover/20200422201254.15232-1-grygorii.strashko@ti.com/ v3: https://patchwork.ozlabs.org/project/netdev/cover/20200320194244.4703-1-grygorii.strashko@ti.com/ v2: https://patchwork.ozlabs.org/cover/1258339/ v1: https://patchwork.ozlabs.org/cover/1254708/ [1] https://lore.kernel.org/patchwork/cover/799251/ [2] https://usermanual.wiki/Document/SetupGuide.632280828.pdf https://github.com/t-tibor/msc_thesis [3] https://patchwork.kernel.org/cover/11421329/ [4] https://patchwork.kernel.org/cover/11433197/ [5] https://sourceforge.net/p/linuxptp/mailman/message/36943248/ Grygorii Strashko (10): net: ethernet: ti: cpts: use dev_yy() api for logs net: ethernet: ti: cpts: separate hw counter read from timecounter net: ethernet: ti: cpts: move tc mult update in cpts_fifo_read() net: ethernet: ti: cpts: switch to use new .gettimex64() interface net: ethernet: ti: cpts: optimize packet to event matching net: ethernet: ti: cpts: move tx timestamp processing to ptp worker only net: ethernet: ti: cpts: rework locking net: ethernet: ti: cpts: add irq support net: ethernet: ti: cpts: add support for HW_TS_PUSH events net: ethernet: ti: cpsw: enable cpts irq drivers/net/ethernet/ti/cpsw.c | 21 ++ drivers/net/ethernet/ti/cpsw_new.c | 20 ++ drivers/net/ethernet/ti/cpsw_priv.c | 17 +- drivers/net/ethernet/ti/cpsw_priv.h | 2 + drivers/net/ethernet/ti/cpts.c | 422 +++++++++++++++++--------- drivers/net/ethernet/ti/cpts.h | 27 +- drivers/net/ethernet/ti/netcp_ethss.c | 3 +- 7 files changed, 363 insertions(+), 149 deletions(-) -- 2.17.1