From patchwork Wed Jan 13 13:15:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yannick Vignon X-Patchwork-Id: 12016791 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9347CC433E0 for ; Wed, 13 Jan 2021 13:17:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4C10723433 for ; Wed, 13 Jan 2021 13:17:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726490AbhAMNRH (ORCPT ); Wed, 13 Jan 2021 08:17:07 -0500 Received: from mail-eopbgr20060.outbound.protection.outlook.com ([40.107.2.60]:8903 "EHLO EUR02-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725809AbhAMNRH (ORCPT ); Wed, 13 Jan 2021 08:17:07 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MfexGqekKlbGDnzBHFVRwbBkzSrR/fQh9QQdyDQBp0tdMjal5pvLGyLVb9tQs/3hepFWYBG+DIxDxgzgOz/M3UhtgB0RbeZv/Ggr1IZRw8/dQcnUNbt6ReaIR4NOalH3vKL2wmTjtkMk5bRX742w3rhIljoamcxwWk3K/QNIYhiAKydpEjjMDKk/WD6gAqMJS1s2VlnjTaEOP9jkGbxoEEIrDirvWmasglnBXyYyx2oa8gPmiP+g6Ub6qHKtbAHueo2dRf1f+jb44crIcEiMbuPQeHEpdCLpQH/suYPAYUpKOMCy21aca/meZEeuT9uLD2JRYtFQXFIye6pA932RCQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ioeMS4YABBL4O4AfIMR104JzrTqo4NakSS9BgAaspz8=; b=AlGLKSk/k09swtkUD4ppSUVGlTXFfFut/VS79B8QZSTapBHqshz/qNVruO7pDe6zP5JXxUfROZVpVmtqaMzcF19cUo0jqyZuJg4DHCHrFq6rFI6gGkg2FafBWX/L1JmmNAVxLQ5cY8B9oCmKWk3gRAqMOkIhQhUremRLnNbq8Tbqixzoi4DAVBn0FNMv1qaaox6DDWbTiYBC01Sle84coZt0Nz48/4u4ZHiihpme91zEx2EV+f1SMGimxhCVCdDA+mwzGm/kHQC9Q6KRJ4Z7YMlwqXp54a4xQYqQqaqdWVg+sPHZx4iKIv49GlCFUigvcN7XL8ELkYPQHSn+ZHVMtA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ioeMS4YABBL4O4AfIMR104JzrTqo4NakSS9BgAaspz8=; b=G+uc1V0s0UsyCViSXk0kx6WYDzlevAD8Bljr1tQIF97qTCJxuHi2AZbZ3hSvLeo7Pvn6LsfOK00nILU0h4Zi6SVI/jmcYyu5BgimdXqKRO84w1TlCzQK9Tlk6NhC6RLY9XGk/AKFjybXX0sSnuTvEORRlGy0rEt4HXsQIqrRKgc= Authentication-Results: st.com; dkim=none (message not signed) header.d=none;st.com; dmarc=none action=none header.from=oss.nxp.com; Received: from AM0PR04MB5572.eurprd04.prod.outlook.com (2603:10a6:208:11d::20) by AM0PR04MB4884.eurprd04.prod.outlook.com (2603:10a6:208:d0::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3763.10; Wed, 13 Jan 2021 13:16:17 +0000 Received: from AM0PR04MB5572.eurprd04.prod.outlook.com ([fe80::ad3a:2347:dd30:e755]) by AM0PR04MB5572.eurprd04.prod.outlook.com ([fe80::ad3a:2347:dd30:e755%7]) with mapi id 15.20.3742.012; Wed, 13 Jan 2021 13:16:17 +0000 From: Yannick Vignon To: Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , "David S. Miller" , Jakub Kicinski , netdev@vger.kernel.org Cc: Yannick Vignon Subject: [PATCH net v2 1/2] net: stmmac: fix taprio schedule configuration Date: Wed, 13 Jan 2021 14:15:56 +0100 Message-Id: <20210113131557.24651-1-yannick.vignon@oss.nxp.com> X-Mailer: git-send-email 2.17.1 X-Originating-IP: [81.1.10.98] X-ClientProxiedBy: AM9P193CA0021.EURP193.PROD.OUTLOOK.COM (2603:10a6:20b:21e::26) To AM0PR04MB5572.eurprd04.prod.outlook.com (2603:10a6:208:11d::20) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from sopdpuats09.ea.freescale.net (81.1.10.98) by AM9P193CA0021.EURP193.PROD.OUTLOOK.COM (2603:10a6:20b:21e::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3763.10 via Frontend Transport; Wed, 13 Jan 2021 13:16:16 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 7b027eeb-9db8-49f8-cd65-08d8b7c5695d X-MS-TrafficTypeDiagnostic: AM0PR04MB4884: X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8882; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: duXNw83CbTNU8c8FixtrS40Db0Iq4DAaqPp2t++mOrfWuvojSxkCVJ/CMcwPIb8D82bqOHDTDHYSx8cPK4EJlIZL8PvDBczLj2uC4EyTUoNqrESFlRVTU9msBqNp8U9EQgw02LkN/6ZCup5VJLZJOFmv+hzxzgp1d5cxSokUBCiCAH+kqDCXkZ6LfJkmPq5KdSObADN8mRB3LNXupdLoPesLgL1RdPMpQlwQddipSB4Yv9Nu94I6aYh3orek5gXydO7uCqFOIUJxFEV7YhrIOu+eUv+THp4K0+2XBXKFygvGhjyjg9gxUAF1TyG8bn5eR33HZBVQKKdrEJ+7srT12pgjsq3WV7dVcN2YLtG+lutdJPxslqLnjYagn9V55ctSUxNxou18UwG4vkeo/1P0UA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM0PR04MB5572.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(39860400002)(396003)(366004)(346002)(376002)(136003)(2906002)(66946007)(66556008)(66476007)(186003)(26005)(16526019)(8676002)(478600001)(1076003)(6512007)(8936002)(4326008)(6666004)(6486002)(2616005)(86362001)(5660300002)(110136005)(52116002)(6506007)(83380400001)(44832011)(956004)(316002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: /7ANj69lOALALuM13NemreukEVJ9r59IETmYW0s8SYejl/tqr5gtIrMbMu2UhgbK+z1Buoc+3QshUpO3u78oWsZ/eCs+uhAWcl/WkUlHoRnUcEQhkUAaB6YwuabkF8ZcsISOjyx0xm38snR4H2mPVK9Sk5GTeK5j6Xk4H9wzqjk5xhigUXcefvcCrJic0Ngl4aHmJXct7xxghZTz0/DcNVWx/1qQIuZmxGKiJCj1Rx03OcBmCSEdGvpj8V9dhGrrJKfI6iM9UuWYYp4W16MRYvtjdX8r0J3E1cD0JbMeKHSjM6WpDdZXnDRrOv0WBIv8Q0sEuJ4MnYL9AaTW1Ymag1B1qQYQSITP2WSHwgF0QxLOMwuk6xBMdRigy2xAeLvgiaDyYFiUT7BdDEMUST1xHw21KHW5zv+ZY38Pqiw5XrojGFHJsUgFc674zZy+V2zwmCczT2n/N5+s0Fd+tW2RR0bT9B9dq+fxvdn78wB6k3W3RsKFIx0PfBjV1ZQHZbXbD9PfxVxa9YuhoWynshsOBskX4OOv/kHlgy9VRjVmd3daTfXB5nkLe12Ps2740FT0r+ZJmGW4OqkFpbk4zqrAIy6uw4R7tGJFSd9A7sG8Qn6HTZ7k42CdaB6yn3TDCjPzN7GVTcwHExeO3ZnaVVbf8223u1xurleyQgYiy+8kW8T4dP2G5WW7AO+Fuqd+mIKAhYxp76CPZwuXm/6rNwV/KLE0k2TSCGgwk8RSLUy1moHEiCYYotdxR2dZT9lFwxrOpiCEFBLhZfNhjG4Bd+mQAqEEDvDjbQhyZ0j4k0czY39n9FqL5he5OKsDmCSFdFb2qlHktWZSfCWdei/QABIRFvRASJK9wVdrMFZjJYwJKtkteTKK96PHUIxHGDIMoa+8zSWJSCF7ZoCXZJ58ZBP4GBZil14LFGS0mHi8NMhMsSPyXMeg+5uejeUVPD1SYCpqVCmfv7pcsp5iOheehTtKyEv8AqYm/k5iTfL1l5Cc5lmVsvMJ8XZoWJH/6YiDo4KR X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB5572.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Jan 2021 13:16:17.6331 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-Network-Message-Id: 7b027eeb-9db8-49f8-cd65-08d8b7c5695d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: o8+YJZmn4Ba8JDVbI8KYwSLyM4vipntfLU4vjztVEiLMAebR18n44XQ9F1VmjRJlNqlW5kZvQFTyfgu+YvvRkw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB4884 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Yannick Vignon When configuring a 802.1Qbv schedule through the tc taprio qdisc on an NXP i.MX8MPlus device, the effective cycle time differed from the requested one by N*96ns, with N number of entries in the Qbv Gate Control List. This is because the driver was adding a 96ns margin to each interval of the GCL, apparently to account for the IPG. The problem was observed on NXP i.MX8MPlus devices but likely affected all devices relying on the same configuration callback (dwmac 4.00, 4.10, 5.10 variants). Fix the issue by removing the margins, and simply setup the MAC with the provided cycle time value. This is the behavior expected by the user-space API, as altering the Qbv schedule timings would break standards conformance. This is also the behavior of several other Ethernet MAC implementations supporting taprio, including the dwxgmac variant of stmmac. Fixes: 504723af0d85 ("net: stmmac: Add basic EST support for GMAC5+") Signed-off-by: Yannick Vignon --- Changes in v2: - Add Fixes tag. - Fix order of declaration lines. drivers/net/ethernet/stmicro/stmmac/dwmac5.c | 52 ++------------------ 1 file changed, 4 insertions(+), 48 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac5.c b/drivers/net/ethernet/stmicro/stmmac/dwmac5.c index 03e79a677c8b..8f7ac24545ef 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac5.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac5.c @@ -568,68 +568,24 @@ static int dwmac5_est_write(void __iomem *ioaddr, u32 reg, u32 val, bool gcl) int dwmac5_est_configure(void __iomem *ioaddr, struct stmmac_est *cfg, unsigned int ptp_rate) { - u32 speed, total_offset, offset, ctrl, ctr_low; - u32 extcfg = readl(ioaddr + GMAC_EXT_CONFIG); - u32 mac_cfg = readl(ioaddr + GMAC_CONFIG); int i, ret = 0x0; - u64 total_ctr; - - if (extcfg & GMAC_CONFIG_EIPG_EN) { - offset = (extcfg & GMAC_CONFIG_EIPG) >> GMAC_CONFIG_EIPG_SHIFT; - offset = 104 + (offset * 8); - } else { - offset = (mac_cfg & GMAC_CONFIG_IPG) >> GMAC_CONFIG_IPG_SHIFT; - offset = 96 - (offset * 8); - } - - speed = mac_cfg & (GMAC_CONFIG_PS | GMAC_CONFIG_FES); - speed = speed >> GMAC_CONFIG_FES_SHIFT; - - switch (speed) { - case 0x0: - offset = offset * 1000; /* 1G */ - break; - case 0x1: - offset = offset * 400; /* 2.5G */ - break; - case 0x2: - offset = offset * 100000; /* 10M */ - break; - case 0x3: - offset = offset * 10000; /* 100M */ - break; - default: - return -EINVAL; - } - - offset = offset / 1000; + u32 ctrl; ret |= dwmac5_est_write(ioaddr, BTR_LOW, cfg->btr[0], false); ret |= dwmac5_est_write(ioaddr, BTR_HIGH, cfg->btr[1], false); ret |= dwmac5_est_write(ioaddr, TER, cfg->ter, false); ret |= dwmac5_est_write(ioaddr, LLR, cfg->gcl_size, false); + ret |= dwmac5_est_write(ioaddr, CTR_LOW, cfg->ctr[0], false); + ret |= dwmac5_est_write(ioaddr, CTR_HIGH, cfg->ctr[1], false); if (ret) return ret; - total_offset = 0; for (i = 0; i < cfg->gcl_size; i++) { - ret = dwmac5_est_write(ioaddr, i, cfg->gcl[i] + offset, true); + ret = dwmac5_est_write(ioaddr, i, cfg->gcl[i], true); if (ret) return ret; - - total_offset += offset; } - total_ctr = cfg->ctr[0] + cfg->ctr[1] * 1000000000ULL; - total_ctr += total_offset; - - ctr_low = do_div(total_ctr, 1000000000); - - ret |= dwmac5_est_write(ioaddr, CTR_LOW, ctr_low, false); - ret |= dwmac5_est_write(ioaddr, CTR_HIGH, total_ctr, false); - if (ret) - return ret; - ctrl = readl(ioaddr + MTL_EST_CONTROL); ctrl &= ~PTOV; ctrl |= ((1000000000 / ptp_rate) * 6) << PTOV_SHIFT; From patchwork Wed Jan 13 13:15:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yannick Vignon X-Patchwork-Id: 12016793 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 113B7C433DB for ; Wed, 13 Jan 2021 13:18:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A54AB23432 for ; Wed, 13 Jan 2021 13:18:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726884AbhAMNRp (ORCPT ); Wed, 13 Jan 2021 08:17:45 -0500 Received: from mail-eopbgr20075.outbound.protection.outlook.com ([40.107.2.75]:62486 "EHLO EUR02-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726184AbhAMNRo (ORCPT ); Wed, 13 Jan 2021 08:17:44 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=c1dUfF8UtiTtDhZ3tDRcE82TrSxue2Nnfb3Hb431IO+UVl4nw5eIYTHzbPUzKZbNG1KFb/gTl1t5X8yo4lCbKeyQCxetFMgrXLWvBNKkzdhUcExhHikKQCe31JYvh0vtbLoB7lpDLN783IQWl2H1X3IoFt2eVQzicYR/evsNMeA9/PaKMvqj4frkMHRnG1SNAwHCbFeVAi5OgBXpDrChRKOiJOVS83o7NbClDxudOJzZi9ZkbEKRM1X3jUj/P2k46747YUUcAgaH1g014BaVmhdryM2xqPoVs/gKqsdCZJS9jtPoYY+piY+sQ8oVy7NBkxDwSA6hPDpXJvvZzgy3bQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=6G4NgMb8A+1Y9Zb2a8Z/ZsYi7oOv8e3/NWUnrFHKHhM=; b=b0ChpJ6s5ui3IBD40o2G+2w3PrQBLLkMOIL2gfmOBMizR1PHjeLKPpHta+1iqB+o/JzzbUeBahpsFvvOL4+KRcoDV7F/AePFRVamxaUQF+JCnt5Folbox3TfsKncOorsjbLLelpLrtx7IySbGqDfkiDGNHxPCyVPraii8YCRzba9ik1lS7wjgqYgAplRYAxUc3isod/lNYCWYWh+PPYAQMkvj7EQHEW/ZPsXB1q54sSyJboX29VzHGsR0XzMxLw9KDSRrSBYfgRO018/+XC3SMFJyAzgdd0yQ8JyVVHWN7CMtalolXnMI9R7sCfqmtuSAGJG3CHPpo6PEGAMQOOgOg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=6G4NgMb8A+1Y9Zb2a8Z/ZsYi7oOv8e3/NWUnrFHKHhM=; b=AJmcSvZxC0rIuza/0XhpBUkc8q9fXVra/RGa0erZ/dhqkXOIckPyJHn4vMsfE4BgfWTzhWCoqqftbb7gFT2wSaUPTi92rxmPfG5AzRKLqXuf5KCn0ihyV0p5GCZr8GFvtJuGhaLdAqNfECiVRGsLmAdwn8vvNwd3bXR8wEKMTfM= Authentication-Results: st.com; dkim=none (message not signed) header.d=none;st.com; dmarc=none action=none header.from=oss.nxp.com; Received: from AM0PR04MB5572.eurprd04.prod.outlook.com (2603:10a6:208:11d::20) by AM0PR04MB4884.eurprd04.prod.outlook.com (2603:10a6:208:d0::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3763.10; Wed, 13 Jan 2021 13:16:22 +0000 Received: from AM0PR04MB5572.eurprd04.prod.outlook.com ([fe80::ad3a:2347:dd30:e755]) by AM0PR04MB5572.eurprd04.prod.outlook.com ([fe80::ad3a:2347:dd30:e755%7]) with mapi id 15.20.3742.012; Wed, 13 Jan 2021 13:16:22 +0000 From: Yannick Vignon To: Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , "David S. Miller" , Jakub Kicinski , netdev@vger.kernel.org Cc: Yannick Vignon Subject: [PATCH net v2 2/2] net: stmmac: fix taprio configuration when base_time is in the past Date: Wed, 13 Jan 2021 14:15:57 +0100 Message-Id: <20210113131557.24651-2-yannick.vignon@oss.nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210113131557.24651-1-yannick.vignon@oss.nxp.com> References: <20210113131557.24651-1-yannick.vignon@oss.nxp.com> X-Originating-IP: [81.1.10.98] X-ClientProxiedBy: AM9P193CA0021.EURP193.PROD.OUTLOOK.COM (2603:10a6:20b:21e::26) To AM0PR04MB5572.eurprd04.prod.outlook.com (2603:10a6:208:11d::20) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from sopdpuats09.ea.freescale.net (81.1.10.98) by AM9P193CA0021.EURP193.PROD.OUTLOOK.COM (2603:10a6:20b:21e::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3763.10 via Frontend Transport; Wed, 13 Jan 2021 13:16:21 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 4e475ccd-50a4-4db9-ec01-08d8b7c56c00 X-MS-TrafficTypeDiagnostic: AM0PR04MB4884: X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8273; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: icmhDaLMQX3Bt4sNAVSCUStSs1aEtDbzsXFy83iMrhGkbzr7FGBM5sUsT9BIZtVwxWMv9C/wq8wXmfLY1gYT15bbmeP6shrP5chGSQ7qekFva7k2op0vnd9OHGM7FU0GZfTl7px5Mzx17bJcjHMeUOMxGfvMCs5UmX0fxdrcfTGU1XYTG2NI/1Uh7FvrkZgIHcusrLeNCJg6eVZvJMWHihC7Goy1VPRmP6QzLRdzE9c8Lckt/PJxGaCBXxxCYzw0M4G9H62n6UJh6Llj/PbjTtTK0eEgkcQA5qBsxqLtyId2oCh8fh8v8UR9Ihrmj88ABZVU9mOwTFYR1qfrUMJjVVAfn7t4J+/yPOO5tdmvkrf8opxEkjOtd81isk/0aSbs2IjXhAmfIOpLs4+FhQaloQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM0PR04MB5572.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(39860400002)(396003)(366004)(346002)(376002)(136003)(2906002)(66946007)(66556008)(66476007)(186003)(26005)(16526019)(8676002)(478600001)(1076003)(6512007)(8936002)(4326008)(6666004)(6486002)(2616005)(86362001)(5660300002)(110136005)(52116002)(6506007)(83380400001)(44832011)(956004)(316002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: m91N6HZ7f8Y/sR+ZzVJd8tHHBET+tALqMv+cmt4sron5gu6Mwllly2vB0VgB4sZHVxM0pclwLK5lAWO6sohUUKEm7FLhZZavXxUcHK7g8iFmJ0mkPE/vSVar4LzBpY94qRHmmfJ6WzbdFiy/M5ZsXQScKG186e4jZknA9jTUkKmZBTCpgla9ffnFZTIjyXBVjJSXHF/x7oqBSaWT2nsN6RI8x0sBFuiGVoJYUMLhBTBDkAVw54eFwTQAwflFJ9xNsa+w6Ph5y9ZdP7yxgENH61xeesmovZhvs2f96lpv14G3INvYHKAVBPGYZR8nn1vjxbV+61XcN+mfsx2vd7Oz/3vFlqexfY0PmO4OWsL+pQX+2WbRfT7Mc/mZTSZNrpbr/Fr+yy7Nd/LSUN6NkKfCkqH7AXBomM3LJuECA+ave/e5mWtzrWBMDXC6aNbpqd8bYEjaZBYUqioKXAkzsu+M0/GrOv76Go3LRnHcb0ByHGv3vr0pt3zaHS5jvfGhG9bvK0uFw8zTJQ72pmISqhndaZS6E7G9KhhSrSUUKXaLzMbTkvYw6e/WiGxko1M+my9hastFC1NrKKuypj7bGOss+ZAn/qZZPiMIWoIP3844dPwERK4aPuVnbq03kb4OqevY2kPxmxE6SFNHsKKehFvXZH9a0uwCgYpJyHzB9SUlP48q07iaYLgKiut9EOHQrxz3mkqMGZNMQCPhlj2nEG8lEDjOB4FBCMUyFANOihAmWuMgDGZ3F8F8S1bAoGIKS1fI5UnmaLJiBol5Q8BCZnG0lcOLdDRB0dgke4mKSCGHRjnqNTLZ5HDc/FExi0S1Lrqdz2wrcJGng7iA7YnSSkQ2rHQEKIpyXp/fj8HoOWgza38Bv4S3t3IQEi/GhpZIKmS2Vf6GcMb9jqzttozRNLEijkYgoSjoqA3shjZW9EJsfcZMPN5GZHVERbVAaQlnoOYxIe2WJGIrUIJ6WSBA4UYUG6j6Ts0JtpIhB1MXfFn0WXNy4EOQSd0fpFrMJvhr9Nan X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB5572.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Jan 2021 13:16:22.0605 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-Network-Message-Id: 4e475ccd-50a4-4db9-ec01-08d8b7c56c00 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: EnZLytjbpcrHGaqkrhfMGetJgg2NYhymvziByU+S/ulfU3r3nD+Mz3euKcMfOLUyncCLrmHTaCGAiEeL1BZBtQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB4884 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Yannick Vignon The Synopsys TSN MAC supports Qbv base times in the past, but only up to a certain limit. As a result, a taprio qdisc configuration with a small base time (for example when treating the base time as a simple phase offset) is not applied by the hardware and silently ignored. This was observed on an NXP i.MX8MPlus device, but likely affects all TSN-variants of the MAC. Fix the issue by making sure the base time is in the future, pushing it by an integer amount of cycle times if needed. (a similar check is already done in several other taprio implementations, see for example drivers/net/ethernet/intel/igc/igc_tsn.c#L116 or drivers/net/dsa/sja1105/sja1105_ptp.h#L39). Fixes: b60189e0392f ("net: stmmac: Integrate EST with TAPRIO scheduler API") Signed-off-by: Yannick Vignon --- Changes in v2: - Add Fixes tag. - Fix order of declaration lines. .../net/ethernet/stmicro/stmmac/stmmac_tc.c | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c index f5bed4d26e80..8ed3b2c834a0 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c @@ -599,7 +599,8 @@ static int tc_setup_taprio(struct stmmac_priv *priv, { u32 size, wid = priv->dma_cap.estwid, dep = priv->dma_cap.estdep; struct plat_stmmacenet_data *plat = priv->plat; - struct timespec64 time; + struct timespec64 time, current_time; + ktime_t current_time_ns; bool fpe = false; int i, ret = 0; u64 ctr; @@ -694,7 +695,22 @@ static int tc_setup_taprio(struct stmmac_priv *priv, } /* Adjust for real system time */ - time = ktime_to_timespec64(qopt->base_time); + priv->ptp_clock_ops.gettime64(&priv->ptp_clock_ops, ¤t_time); + current_time_ns = timespec64_to_ktime(current_time); + if (ktime_after(qopt->base_time, current_time_ns)) { + time = ktime_to_timespec64(qopt->base_time); + } else { + ktime_t base_time; + s64 n; + + n = div64_s64(ktime_sub_ns(current_time_ns, qopt->base_time), + qopt->cycle_time); + base_time = ktime_add_ns(qopt->base_time, + (n + 1) * qopt->cycle_time); + + time = ktime_to_timespec64(base_time); + } + priv->plat->est->btr[0] = (u32)time.tv_nsec; priv->plat->est->btr[1] = (u32)time.tv_sec;