From patchwork Wed May 10 20:53:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rahul Rameshbabu X-Patchwork-Id: 13237259 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 87D22168AE for ; Wed, 10 May 2023 20:58:53 +0000 (UTC) Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2060e.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe5a::60e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C1D977AA7 for ; Wed, 10 May 2023 13:58:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GHSHBnlLgAR3okbfafosu4gX3ePF2p37Mym+/uU8YfyyHdndJ6LJt8NeUX0dbFuXlYuOkm8faBRLI6ltMwpF34txqNb1tt9JIcU82xXax5TuWRdGAPEBN/foC/859gSdKH5xJZ1YTL7s7H/3NpQMdi0lBHiWDP7n+5IU6EyW8OQlhnC0HfVI+MlxY1oZVKBAZWTN8gVPdg49jOSax7+QzAB5zL0OIht9F6N6euZc18r5GkN17Z2iY9AEqUFmVBbJhr+FmYbW+/hm/a4JxDhInpJzlTIbPXtUITyLfHho4zVtU7ni+ClKOC7G/S3tGztjwigyCmwGHWPNGco60u8yIg== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=frxpCCCzUClrSmSWVChBKmih7shCvwrrejg/QVAtzKc=; b=lhTvIr8fMu1DZX46lKSQxz11G94k3bfxyd0JFXYzTPA9Nmjcnw6Oq5xLdD3n6bcFE/z3lI2A3W80VCFnZvXSZ6MQCkxcsGyx61Zo3g9cbKGGwJdNuUceXScDfO4bDFSDn/bVnPdNXki/lmHymLVd1jNyrg71XOlyHeyKkPpqZ9325eo6vZkcCf9reZtMR4dKOh4btxP3TgvV9ETfis9ue4lPzMkvNAE3nWmB4KU23hBwVIpOJvg5Uv7yiyboE8K5nPT192IZv4Pzbce8SHArLqQ/mFfcUUKpd8I6I1adr4vM2f08BRpI5uC52J5wznUjQ5R/k+wkqhBezSR2fopxAQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=frxpCCCzUClrSmSWVChBKmih7shCvwrrejg/QVAtzKc=; b=s8+fP9OOVxKUN7yOt9qNZ+JH8y0NIHBdp8KV5NKNGVQEqQop6f2R27o40naYVUp0kbfuSdaFoSyznZ8De+VznugZpR8jcuuaDX8e5mEhXYEcPLdnF5iEKdYUoAQZGzEOoK9tmy4CfedfPOSmFhsodTGQICtBuo7bDB6SNcHMdrbGipo44gqbXwculLrUpLM+ojN7G6O1BYKWhUxDEUd1SNgE1w6ybl/VHcI1Ap+JAokoMeawaxA3v7GdVfCWSLG1xSxCcCHpiqIOEf+Qobw0fWKOJKE4ZB8lemkZ4nYnQgCM+NAT2ejPhypKCJPFvl4RnD+XBuhDBWvrXeVk4Q1QBw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from BYAPR12MB2743.namprd12.prod.outlook.com (2603:10b6:a03:61::28) by MW5PR12MB5624.namprd12.prod.outlook.com (2603:10b6:303:19d::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6387.18; Wed, 10 May 2023 20:54:07 +0000 Received: from BYAPR12MB2743.namprd12.prod.outlook.com ([fe80::de5a:9000:2d2f:a861]) by BYAPR12MB2743.namprd12.prod.outlook.com ([fe80::de5a:9000:2d2f:a861%7]) with mapi id 15.20.6363.033; Wed, 10 May 2023 20:54:07 +0000 From: Rahul Rameshbabu To: netdev@vger.kernel.org Cc: Saeed Mahameed , Gal Pressman , Tariq Toukan , "David S. Miller" , Jakub Kicinski , Richard Cochran , Jacob Keller Subject: [PATCH net-next 8/9] ptp: idt82p33: Add .getmaxphase ptp_clock_info callback Date: Wed, 10 May 2023 13:53:05 -0700 Message-Id: <20230510205306.136766-9-rrameshbabu@nvidia.com> X-Mailer: git-send-email 2.38.4 In-Reply-To: <20230510205306.136766-1-rrameshbabu@nvidia.com> References: <20230510205306.136766-1-rrameshbabu@nvidia.com> X-ClientProxiedBy: BYAPR02CA0038.namprd02.prod.outlook.com (2603:10b6:a03:54::15) To BYAPR12MB2743.namprd12.prod.outlook.com (2603:10b6:a03:61::28) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BYAPR12MB2743:EE_|MW5PR12MB5624:EE_ X-MS-Office365-Filtering-Correlation-Id: 73352d99-af16-46f0-e5f0-08db5198b219 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: JzYsZABU3dx5WdZRYd69L0JuLAmaMQsX/rUoFJ/CnfnrFCdEwMFQw5aPKM89ey115SAXMG2ThfHKiGiNgEPYdDen5MbKornEjWF5p86XE9AkNMXbpI4pXnY9NhjUmt5E1saKwH6Yk/jdMT5Q//j9tsDPVjYYHwvziMlUE7Lakj/rlquZbIffSGW1KdseRnqyM8uRvEz1zVFs7BpCyGfq6DkGPQXrq3Y7GZ+t5vZLOfFKz7oIkAL+kw3RYscFgVPIQRdnSKf50cCC56mCnr2nWZOh1tUwexiwmuKsJVONtkGOgClwLM3ApZnd0b1dRmyzk4D7QLA3+2oYnEWWMZiJ+eSf/ZPjQnAiMsRC2tcvCmHuoOLSY+RjuwpK/upKVehkPmgZOa7PLlVEAnFfHcP6KYUX5WX9Js6VSX8uACS/xxp73wlMRsOShpeAx17NoE6E2KgjMhK+4rqiduVQ0SSJEcwshP7zVXhVdh02HvBU/ghse448KZRNQoDaF1JLFWAeaTHXhC/eAIZvPNOtqlSHAp90SY2RF07HOtc+wtGM7YflDZHLLAMSVVe88W8+o4zrhRLNiSXWCQCvWL3v288j5eU0s5v6bN0t89BYimaOqAmp+FdDBSrWT18hEI0MzEdv X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BYAPR12MB2743.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(346002)(136003)(39860400002)(366004)(396003)(376002)(451199021)(86362001)(5660300002)(41300700001)(4326008)(38100700002)(316002)(6486002)(6506007)(6512007)(26005)(1076003)(478600001)(54906003)(36756003)(2906002)(8936002)(8676002)(186003)(83380400001)(66946007)(6916009)(66476007)(66556008)(2616005)(142923001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: UWpe9+7WFfImC5OFmkTK36ERTgv1paIoWkYB/laqsFw8axDwiyjDiOWgJVSSvw3Dwi6mRtNlFv6g68Xte/qQYh4F7nZ0ReVq1NhdVaUTOkF4+NEjaURiSf3QpV3CtVYvTlYNew1EheotvdcWD0iBt5hV085TKP+kVLeDkQGKRoY2QyiZlBvEUBkq6Pdw3VM+e4YDZW8eUKPStgo9HcWFizKVr1QcuiBwQ8RqeM6dpJ5jmoni70C1kfRKZCCjA5BXpZsdl1uE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1QDVCO1JiDCiN4TIAnHmMWI9H+WDt9tCzWA+wqheQuuS5uuD+gr6dFs8FBye0vpaSiCzVdkCTXveQsAwRZN131j88UelDrP1kuaYANSCvQAvuSw7LQemexRswsaBqNedvNrIirmeyx7b1Drwo3Zc9unEzdFGrkTb6PEmMEX2w/Rt2jQUes5FSPJ/aY8bVFS2Dkg6yDh+3sn1mMzt0jsjFxEjwed9Bm1UXLPH4rACpv7Gv+SgRayV0THUbSuv3ZnJUPOQbaIk/Y+2nKISgPw== X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 73352d99-af16-46f0-e5f0-08db5198b219 X-MS-Exchange-CrossTenant-AuthSource: BYAPR12MB2743.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 May 2023 20:54:06.9994 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: AEEZttnh+BJQIekCnltheznZMvLO2qnb7qfEqaugBYJfACfubcdv4yokdLIpJ57xOoAorVLQ4mPU4XF/HbaQpg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW5PR12MB5624 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, SPF_HELO_PASS,SPF_NONE,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org Advertise the maximum offset the .adjphase callback is capable of supporting in nanoseconds for IDT devices. This change refactors the negation of the offset stored in the register to be after the boundary check of the offset value rather than before. Boundary checking is done based on the intended value rather than its device-specific representation. Cc: Richard Cochran Cc: Min Li Signed-off-by: Rahul Rameshbabu --- drivers/ptp/ptp_idt82p33.c | 18 +++++++++--------- drivers/ptp/ptp_idt82p33.h | 4 ++-- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/ptp/ptp_idt82p33.c b/drivers/ptp/ptp_idt82p33.c index afc76c22271a..057190b9cd3d 100644 --- a/drivers/ptp/ptp_idt82p33.c +++ b/drivers/ptp/ptp_idt82p33.c @@ -978,24 +978,23 @@ static int idt82p33_enable(struct ptp_clock_info *ptp, return err; } +static s32 idt82p33_getmaxphase(__always_unused struct ptp_clock_info *ptp) +{ + return WRITE_PHASE_OFFSET_LIMIT; +} + static int idt82p33_adjwritephase(struct ptp_clock_info *ptp, s32 offset_ns) { struct idt82p33_channel *channel = container_of(ptp, struct idt82p33_channel, caps); struct idt82p33 *idt82p33 = channel->idt82p33; - s64 offset_regval, offset_fs; + s64 offset_regval; u8 val[4] = {0}; int err; - offset_fs = (s64)(-offset_ns) * 1000000; - - if (offset_fs > WRITE_PHASE_OFFSET_LIMIT) - offset_fs = WRITE_PHASE_OFFSET_LIMIT; - else if (offset_fs < -WRITE_PHASE_OFFSET_LIMIT) - offset_fs = -WRITE_PHASE_OFFSET_LIMIT; - /* Convert from phaseoffset_fs to register value */ - offset_regval = div_s64(offset_fs * 1000, IDT_T0DPLL_PHASE_RESOL); + offset_regval = div_s64((s64)(-offset_ns) * 1000000000ll, + IDT_T0DPLL_PHASE_RESOL); val[0] = offset_regval & 0xFF; val[1] = (offset_regval >> 8) & 0xFF; @@ -1175,6 +1174,7 @@ static void idt82p33_caps_init(u32 index, struct ptp_clock_info *caps, caps->n_ext_ts = MAX_PHC_PLL, caps->n_pins = max_pins, caps->adjphase = idt82p33_adjwritephase, + caps->getmaxphase = idt82p33_getmaxphase, caps->adjfine = idt82p33_adjfine; caps->adjtime = idt82p33_adjtime; caps->gettime64 = idt82p33_gettime; diff --git a/drivers/ptp/ptp_idt82p33.h b/drivers/ptp/ptp_idt82p33.h index 8fcb0b17d207..6a63c14b6966 100644 --- a/drivers/ptp/ptp_idt82p33.h +++ b/drivers/ptp/ptp_idt82p33.h @@ -43,9 +43,9 @@ #define DEFAULT_OUTPUT_MASK_PLL1 DEFAULT_OUTPUT_MASK_PLL0 /** - * @brief Maximum absolute value for write phase offset in femtoseconds + * @brief Maximum absolute value for write phase offset in nanoseconds */ -#define WRITE_PHASE_OFFSET_LIMIT (20000052084ll) +#define WRITE_PHASE_OFFSET_LIMIT (20000l) /** @brief Phase offset resolution *