From patchwork Tue Jan 12 17:24: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: 12014199 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.7 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 DC672C433DB for ; Tue, 12 Jan 2021 17:26:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A42BF22285 for ; Tue, 12 Jan 2021 17:26:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731029AbhALR0W (ORCPT ); Tue, 12 Jan 2021 12:26:22 -0500 Received: from mail-am6eur05on2081.outbound.protection.outlook.com ([40.107.22.81]:10081 "EHLO EUR05-AM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728887AbhALR0V (ORCPT ); Tue, 12 Jan 2021 12:26:21 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WGNWlf/XRjoKqMS59u4Xh7yY1HBvXCuyKM1boXxsS9o56lwtRTOTdHU0rVr1aYpQlwiyHEHRFfa1Ev6ihKB1AuHizWR2ZnwHtnU4JQvU0rvUXdr3hcEzMoEV3mDiFNGxBt9FYAvytvT078ZMkAK6R82AK6UTn9DK4DEbskW+tWhmXvl4rKCwVIJ8kn1Gl/bx6t0tDfIS/zhIshgk7Dgj2VWqUC/47s/mxAp7JAb2Qe8OYGk1Sz5dkfmTQBarrjShtdhsBXuinx0oiDUrl/rRitR+8QxPcZOahMxA43AzT3hMyjJecg5ORfKp4LCDLs69hNxl2gqAN9xwxAYpn2y3Sw== 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=oHR0XGW8eYCNyt3vG5jf/+sIBpn1kNRhw7T5itWt77I=; b=TbuMyLhQZ+pSpu0eMKnqsMkVWf6dCWe8JbIabN670mfEBPLUZXDut4OsGSv/tbAu02kfphSOuQm9dKh6uruqIoie88VXsSBCW2feyyEZw9+WolLRU2R24ZNeuxjlzu9Qi3hBTOK2YrVdLmmiSBcWAJT/Z+RWH4jd7aApXAmH4TzqkzU8DQTa690XKK759KiJqTyQlJeKfgBCtwwMV+DhNKSSv2TqNFGb2jigZIdWxSB74i0m7zOF0+kKvoA7Fv578skbHwHuypaN0CX6bNhCQSl5i5rt0ryTKYAIvv1d3NjROKf4mQK4YkyDSY4trrIqRcx/+GYsT5ycXfwljFcxlQ== 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=oHR0XGW8eYCNyt3vG5jf/+sIBpn1kNRhw7T5itWt77I=; b=YPdSo98RNgqer7P29+SawSrdRZCDxb8oGb1qS44VDwq4WMZqNZ7fXSwX/PtCoY4FmB+ccTz3y8DY7og/P0Zc5AlZS7rtM4010GbHaeA0RT5Zjabmbyde+TOpPORFrcYXAyaw+mC8OL12kJr5y2ZVjrYCU8TwYZLHjGQRvYzDdtE= 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 AM0PR0402MB3316.eurprd04.prod.outlook.com (2603:10a6:208:19::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3742.9; Tue, 12 Jan 2021 17:25:32 +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; Tue, 12 Jan 2021 17:25:32 +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 1/2] net: stmmac: fix taprio schedule configuration Date: Tue, 12 Jan 2021 18:24:56 +0100 Message-Id: <20210112172457.20539-1-yannick.vignon@oss.nxp.com> X-Mailer: git-send-email 2.17.1 X-Originating-IP: [81.1.10.98] X-ClientProxiedBy: PR3P193CA0023.EURP193.PROD.OUTLOOK.COM (2603:10a6:102:50::28) 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 PR3P193CA0023.EURP193.PROD.OUTLOOK.COM (2603:10a6:102:50::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3763.9 via Frontend Transport; Tue, 12 Jan 2021 17:25:31 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: f0c89a34-c8ab-44a3-18c1-08d8b71f1077 X-MS-TrafficTypeDiagnostic: AM0PR0402MB3316: 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: CA9ZQ/xyQ23uCSPt+hDOwJ2Dfgnqvm+NmKjkspeVVEAlRinbZu5XuIMh+Vj42SG3JNSOfxOjpwOfTS7CN//QFgZVsKs1NWcdnPY8kqf+w/+Xs4SdqwJNb53fpmH4IIlkY7pyi5Ry0EA8gSB9WT8IDSlRimarTMGZ2Tb+6T4ZsVGk50P30MvyotWeuT6LsR6Y83dWKjjFC8a9aYSXwkaRTBbPwsK5qs378DChD6pip3Pd6rxIabRbY6yhRU0F9FIX1paE3lCBbCo1HI1wIOvIcC6qNE3ljkEDJNwomivlll9kk0LMLtkCEO+Mj+lw1fXWk0HlxVKNpDRu3pBM4709CV2lmf2eY+xG5bcP4MrlsCaQDoe436CLZF19OLLvqGo6nBHyVrBJrK8saSTG+X6L7A== 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)(396003)(376002)(346002)(136003)(39860400002)(366004)(2616005)(44832011)(1076003)(86362001)(66946007)(26005)(4326008)(110136005)(2906002)(5660300002)(186003)(16526019)(6506007)(66556008)(66476007)(6512007)(478600001)(8676002)(6666004)(6486002)(83380400001)(8936002)(52116002)(956004)(316002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: T9oNVGBxDbMfuF5qe31gHp9z96FeY926VVCWbXbC9OZgd/scE1/3OwAKcDwBdcigc481NI64qqX/UvPrOMNBaiy6QF7MP6VteWy/S01kUNF5OpB1KSm9v5dUojwWWkuLwhjs79MBbgbuSKBW01ui1PdeXjFJJM12WOg7NTks8nmytcrMclbb7OOQ3oXBAXYlyWW+J8wO+VvT0mWf2rK1zinl+31n7bN2f/MGFeqNkgZwkHU3p44TQZB4/JQOgFuAMAmdXltbQ52aNeCX3qTFBLRZurVFhE/iAV4oK+Z7bEr0Ob4e+uB7MgrSj1Eo40AeR0tMwSmO2xDchqT5epc3YBR/EX9A7mKxt/D003bjZXEvBgxi8yQEa8jsMapnw4gB+bMhUe/MrTAqqgZ2jL3YEE9QzNFlgFcPGAnEck0heSWJ4Fskkx8rfAKvdN2i8nbg7aZO0fhw9LLjBgK5MuDUFAEzKDKVPvHb0lg54njzmdW3NWIyO/STJt3w0jDIBRXpUMiPKtYstPEy0TXNg8ng84eoTpUQbLKNgeP6ehRpoka9AgrD9Lo+zpkMUj5JnctxWjc9CwTREoh8v2TEdv7cVAyih9yR0o0lmoVil1lk4K5+wpC6GHO3lxEHbmFJKpC5LHlkO/hIOt2Fiy/I6UDGBPdqB2sKTwaUmHHghGSyRaGcLPyuo0IFysh2pPLEsONCxqoOaE0KWzkCeYUHVQdBpuRFmQ882tyMkbRHtHkbls/c7+nVB4AsI4uVogPBTRplp4nT7kwKi3R4aZ9ahDl3MBa5dmS8WNQED2y8FwhW1VQLo+8tqlILE1gPgPy6Co5nHqfGxT3NSnksx7RLZxYk1nO9aS69We5bDXEA5+gof1kK2zr2UBcTHNxW/PqPwEtAV1NEKDA4fQeso/NsZJurAyzZK0MbWPc7tZLICoDeHjjZJkvzbh2TW3/iJ9wFvdol05qGXlZTHUw/6Stb4fbdbr8zBYw4rLIip6TsEHy77WU= 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: 12 Jan 2021 17:25:32.0595 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-Network-Message-Id: f0c89a34-c8ab-44a3-18c1-08d8b71f1077 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: wR4qs9I9iwCrswkKnpDXaroMr5FMm9y0NNsWqZnUkyshEISn6cIBDG3BpmTPtly+FZuVBo86t4Y73M+1QjEIsQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR0402MB3316 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. Signed-off-by: Yannick Vignon --- 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..cdef27bb7b6c 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); + u32 ctrl; 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; 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 Tue Jan 12 17:24: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: 12014201 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, 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 32971C433E9 for ; Tue, 12 Jan 2021 17:27:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 03AF722285 for ; Tue, 12 Jan 2021 17:27:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389301AbhALR1C (ORCPT ); Tue, 12 Jan 2021 12:27:02 -0500 Received: from mail-eopbgr80054.outbound.protection.outlook.com ([40.107.8.54]:15590 "EHLO EUR04-VI1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729952AbhALR1B (ORCPT ); Tue, 12 Jan 2021 12:27:01 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NyTdIqa5ga1+VugtoQbPJQkV+xyZO5OTAEql1S0WXNOkkYwwe8ge2gZaCjT6ibDu3mkci4G0V13pNLPQsMENquqELBa8ogX5fVdWeArmHEvtugLD6mjCGMnS/0oseMLS6GSDnp/Fz/t210qNoeX71QhH19VUUhNuc+zxQVf/9xzeQCZWxw2XT+GWzo0ldhxgunf6B/g0QyajKJOa0Bs07BeGhNNUNoTz/O0oMBDyteFpb6O/J31NXgDuQ10Cw5aEveTsYMOQNsKv8kLAuNF0nK5R+T5IU3PyBRe6dWGIAyjv2LehmyRAELrylfWZfZq2U/XYldwDnfVlfKqptra90A== 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=Et9YFgSyZF3WCGK3uGFL94tQ4yuxfKHByvF7KBzACSU=; b=SAfrEIm980OG/r239XX5Eu1cNyQP43sgEhV50vxhivklL6yn7jjHDLr1t5kPjjM90i6gk7AXu1tyObtOKbafeQtJxSH+iIsPiX3xwx4eT3/ZTSH8FVnBbFTqCC+raHKHIliV5yqPWT9tFzLaQ1XaL4fw1FXYX619lR8YFcWQf6/5doFgi5U48gv/8Qc+WQ0kxl7k+B3+PP5TuACB2Nxgry9hkQhYxVQzHpJjBBcGR+uCmIp8JRYo37k79XMrRRTKDQHrdGLjWZnhhApobNYkAXT329N2EDqZZPJfwBoXp6T3M8iJCCy7l3rZExXqzlaBTvuZ6LSEjCCcU49vjtaiJA== 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=Et9YFgSyZF3WCGK3uGFL94tQ4yuxfKHByvF7KBzACSU=; b=aOFwCAxVcefD2ycXF0MAQyMRJ8XFCMxC6yj0EdDxhwd7UrnPfU3aMPnqkbzZR6rQXpb6o5Lf9mM97vhClAUR+AXzCsPgfZlbYB7wI9+pCPA4yd2fYE70oKMLjIJCd3LkNFZUKtnIrUshLz6McJZ71c/33PlM2lB0VFgtRdNbEhs= 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 AM0PR0402MB3316.eurprd04.prod.outlook.com (2603:10a6:208:19::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3742.9; Tue, 12 Jan 2021 17:25:40 +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; Tue, 12 Jan 2021 17:25:40 +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 2/2] net: stmmac: fix taprio configuration when base_time is in the past Date: Tue, 12 Jan 2021 18:24:57 +0100 Message-Id: <20210112172457.20539-2-yannick.vignon@oss.nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210112172457.20539-1-yannick.vignon@oss.nxp.com> References: <20210112172457.20539-1-yannick.vignon@oss.nxp.com> X-Originating-IP: [81.1.10.98] X-ClientProxiedBy: PR3P193CA0023.EURP193.PROD.OUTLOOK.COM (2603:10a6:102:50::28) 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 PR3P193CA0023.EURP193.PROD.OUTLOOK.COM (2603:10a6:102:50::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3763.9 via Frontend Transport; Tue, 12 Jan 2021 17:25:39 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 44d0c126-dce3-4a3f-07d1-08d8b71f1543 X-MS-TrafficTypeDiagnostic: AM0PR0402MB3316: 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: GdipbBjZt5uFHOZOZzbjNYxKceNs4/TvmP3s700XNQLmph6AAkdreOzRz+8oXeK3mF8Fh/eugOJOx9vbcx9EVfXLn+uJbz26Ts9XEpfeRpurTpOuW4Q/olj6KJVeKAK8W839Lh158UmpFDJLCpYSzsqGweWKTNtAAj4D/F72CFZXi0JozIf0dAvqmkkl+RbmLp6FADBb+TMqM9cw0zXKnF/BoYs59JaD8WOa5mE6/0M/7626OClolM3a1cXEwvKW0+/u74TGQA2F4g8d1TJfuHisGIWRzmKjHS+Gu2HZB2GqMMp1WswJ07+cmEbXLM7CxnTjiRLO2CQQf/5ggvzsRo3cM+0XXF37+x9S/N09JxssYWL3dSjSmKyeWKWfPhABRzaf3sD990/hU3caw7WQTQ== 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)(396003)(376002)(346002)(136003)(39860400002)(366004)(2616005)(44832011)(1076003)(86362001)(66946007)(26005)(4326008)(110136005)(2906002)(5660300002)(186003)(16526019)(6506007)(66556008)(66476007)(6512007)(478600001)(8676002)(6666004)(6486002)(83380400001)(8936002)(52116002)(956004)(316002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: 6N3WcyWuatqyOsUhCf4ZPUmsOf3wQMhMTQYlo3Lx3wCeOcXvnFTPIPe6QHh3D/c6dcJ6s8K9Gpe/Mmja9UO4+S7hrjpUo7eORDReIiQasBJCcjEdgDX0xCajVWRACeJAftiOljcNCBZSErQuS/QeyYjNqZ3P3xZPzTTENihgUZ0O8XyR7SDGR9cGWHth03z/9ZdNkTkXh17Oj3kFZczbD1LO3ANTLbgmZx/U1Xc1GFpyOv51oXUsFsM8kWAgPKz5srp4rPc2p4lqE93dqt6VEn1q3ZhfxXrEar7IfWjnrrgF/vN6fI9a5WbDonawGD7uLe7n5tx8xMWrWY4VRtzGyyYpjVm4V7zN+5ItPtHhY+Qqttu5tVbxDXwLbkPPVXDxaTrBh9NeGo6SVOvyJTPRkE2qjhdXGo2jdHI0WQRY1pTcIFzk7jxRYedngredTx84gg6ccVAcqsphciW402cS9L585JSez0DVcbNAFKKo5EjbRQSgZljPQWgG4CzPG5SxB/ZJdHbMPTDjQ7cSRbfj3bzELMtQ2NUy53XkZ04UHDJXnY9c0xObBGssXhMZAoJHjp+VVqN5iJR6Qd1mdrM2ntU8Isw3VGogh2PlFEy3uljU9XoY0V2OWsXcLBQZUj/iFZDcUix7ITWzcmWNkryCagmkWLuWtjxpxjE2Rh/gUuoKtl7/sQqfZsiBdAX3YHuLCIHG8Xms36iOD3O3wzsiRXb0YuFzF60++5duJWBpY/eXhR4o7W7omLJY0fzz3EtLcMXAAT0kVGAzWXuHgiu8rwAiU4NmEfyYxEth10y5GiQXBTZ5NdaiSVn/Hsh/ZsfhvkSoOleMnpU8RstmOPGgwGTNq7rSBidKScV+YDBVH2xnAZqnfZHOYp/i+g3Z81eA/L+xX+4xU8hLqxfhDIWmCd9Ne+m+vmENrD7extX888plL7Ku/Kmn3eRl6GvyKZI7lZCAQpnjaNMBynyTPfJvxyLMTK+NG/6amzSWqOYd0g0= 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: 12 Jan 2021 17:25:40.0689 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-Network-Message-Id: 44d0c126-dce3-4a3f-07d1-08d8b71f1543 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: aGVuRb8/vHDb+z4UGw5FNsY58Wxa66KlotzLZRtHD89nJnTooWiEavJHROsY0Eh17GiGirq4YNRLsDCPgdCy2g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR0402MB3316 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). Signed-off-by: Yannick Vignon --- .../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..f3543ec8ef10 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c @@ -599,8 +599,9 @@ 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; bool fpe = false; + ktime_t current_time_ns; 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 { + s64 n; + ktime_t base_time; + + 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;