From patchwork Mon Aug 12 09:47:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?Q3PDs2vDoXMgQmVuY2U=?= X-Patchwork-Id: 13760375 X-Patchwork-Delegate: kuba@kernel.org Received: from fw2.prolan.hu (fw2.prolan.hu [193.68.50.107]) (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 1DFE81C3E; Mon, 12 Aug 2024 09:47:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.68.50.107 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723456070; cv=none; b=rBOrr0SwInZs/+2a8fisCyMMH8GttUUzfcF4ymzsptIbe1IjS5UwHC6shksgck8ToOoxhLTin4uE4T3PIQbONIDDJe599YSdOisO/I8tkoVskrDtRE8n4nObl9C3RaoFXsap0JRZ8Yyn9r8RKtJs8yIdqx82xJot3wh3ihytIMs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723456070; c=relaxed/simple; bh=Jso0Qq4gPsryFGuHoMXouS/YJ+wODg/I0ksIm038E7E=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=XqdX8TPXwK+n0zFZj90Ht0plVZ1HDrxR2Vl/2qQH6L3VqY7pxfq7gWRzjEEoEM9x8W6mgEfZS3/ySQV8RUFCqhYcufD43VDOtCcN4PR87Jed8VqYUE0GeTqS55wTn4LKmDGH23XoZ4bbWvoWQAarFYXB20xb05SaXaWtbEjXhGc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=prolan.hu; spf=pass smtp.mailfrom=prolan.hu; dkim=pass (4096-bit key) header.d=prolan.hu header.i=@prolan.hu header.b=OfEGBbn/; arc=none smtp.client-ip=193.68.50.107 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=prolan.hu Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=prolan.hu Authentication-Results: smtp.subspace.kernel.org; dkim=pass (4096-bit key) header.d=prolan.hu header.i=@prolan.hu header.b="OfEGBbn/" Received: from proxmox-mailgw.intranet.prolan.hu (localhost.localdomain [127.0.0.1]) by proxmox-mailgw.intranet.prolan.hu (Proxmox) with ESMTP id 12884A05B2; Mon, 12 Aug 2024 11:47:39 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=prolan.hu; h=cc :cc:content-transfer-encoding:content-type:content-type:date :from:from:message-id:mime-version:reply-to:subject:subject:to :to; s=mail; bh=YbiEysMCo9eVDu4Ec2WR++H5KtVmAcOg1PQowdznzbQ=; b= OfEGBbn/d/VE5iD5YxJtavJpwjxihfo6irqQ0qlSRxezLD0jGY9+GCkf+WZqZtD4 A2dc2l3Q3uCTDA/ZeVSPPxcQyHrirZX668S8ltfl4eIOZFhB69LRuQpgkUeVtN56 trq6fVHIgvKhDVn/Qqwnhwb6STiT+BRqqydcmpz/8UsEeMvQmEsZg49PH27LV3Ii fqEhy/RJSyacZI8yhGDtfUEPfDNkq/QetIMJgA0RI3UKiZ+Sj4YRqGWvTwPmiTdu uxtB2eOQOw763m0aVfhgouSH+I2kPOkbAAGh1itFMNzOez4rB9yWzWiGrkVn9nYN X5QszQ8c4EmB4d92Q0BgHWU8GGdoB7w7UBav1d0XIXWgbkbiX7qbRQl7oDyaY8Kb /6a1lAASEWL7MLj95T76jR8TSFHSzc4yGdC9vBU3r7lEAfkiKAZoLr8wZREh5FUU APGY3rhI87HWP/xrJ8R5RBhBwzIct0kZBbfSOllpRLc5xRHJf3iA0pLuNyTJfpux oM/5ljLTD/0vHBKUlY5PCUibWiPlZzCjJnrsqTZhE80/8+62nVybPToPpZRDZdgi 9C4PbgMplYobdjap3dObbH058vrcbu0Nki3ES4brx+0ZKASSSjmmvi1EQW9pB2yx fC2dVbBsyXWZlA4+3JkpAW6KQ3vyutCu0dmpyuv7jHk= From: =?utf-8?b?Q3PDs2vDoXMsIEJlbmNl?= To: Jakub Kicinski , =?utf-8?b?Q3PDs2vDoXMgQmVuY2U=?= , , , CC: Simon Horman , Frank Li , Wei Fang , Shenwei Wang , Clark Wang , "David S. Miller" , "Eric Dumazet" , Paolo Abeni , "Richard Cochran" Subject: [PATCH v3 net-next 1/2] net: fec: Move `fec_ptp_read()` to the top of the file Date: Mon, 12 Aug 2024 11:47:13 +0200 Message-ID: <20240812094713.2883476-1-csokas.bence@prolan.hu> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ESET-AS: R=OK;S=0;OP=CALC;TIME=1723456058;VERSION=7976;MC=3778506329;ID=645951;TRN=0;CRV=0;IPC=;SP=0;SIPS=0;PI=3;F=0 X-ESET-Antispam: OK X-EsetResult: clean, is OK X-EsetId: 37303A29ACD94854617367 X-Patchwork-Delegate: kuba@kernel.org This function is used in `fec_ptp_enable_pps()` through struct cyclecounter read(). Moving the declaration makes it clearer, what's happening. Fixes: 61d5e2a251fb ("fec: Fix timer capture timing in `fec_ptp_enable_pps()`") Suggested-by: Frank Li Link: https://lore.kernel.org/netdev/20240805144754.2384663-1-csokas.bence@prolan.hu/T/#ma6c21ad264016c24612048b1483769eaff8cdf20 Signed-off-by: Csókás, Bence Reviewed-by: Andrew Lunn --- drivers/net/ethernet/freescale/fec_ptp.c | 50 ++++++++++++------------ 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/drivers/net/ethernet/freescale/fec_ptp.c b/drivers/net/ethernet/freescale/fec_ptp.c index e32f6724f568..4ed790cb6be4 100644 --- a/drivers/net/ethernet/freescale/fec_ptp.c +++ b/drivers/net/ethernet/freescale/fec_ptp.c @@ -90,6 +90,30 @@ #define FEC_PTP_MAX_NSEC_PERIOD 4000000000ULL #define FEC_PTP_MAX_NSEC_COUNTER 0x80000000ULL +/** + * fec_ptp_read - read raw cycle counter (to be used by time counter) + * @cc: the cyclecounter structure + * + * this function reads the cyclecounter registers and is called by the + * cyclecounter structure used to construct a ns counter from the + * arbitrary fixed point registers + */ +static u64 fec_ptp_read(const struct cyclecounter *cc) +{ + struct fec_enet_private *fep = + container_of(cc, struct fec_enet_private, cc); + u32 tempval; + + tempval = readl(fep->hwp + FEC_ATIME_CTRL); + tempval |= FEC_T_CTRL_CAPTURE; + writel(tempval, fep->hwp + FEC_ATIME_CTRL); + + if (fep->quirks & FEC_QUIRK_BUG_CAPTURE) + udelay(1); + + return readl(fep->hwp + FEC_ATIME); +} + /** * fec_ptp_enable_pps * @fep: the fec_enet_private structure handle @@ -136,7 +160,7 @@ static int fec_ptp_enable_pps(struct fec_enet_private *fep, uint enable) * NSEC_PER_SEC - ts.tv_nsec. Add the remaining nanoseconds * to current timer would be next second. */ - tempval = fep->cc.read(&fep->cc); + tempval = fec_ptp_read(&fep->cc); /* Convert the ptp local counter to 1588 timestamp */ ns = timecounter_cyc2time(&fep->tc, tempval); ts = ns_to_timespec64(ns); @@ -271,30 +295,6 @@ static enum hrtimer_restart fec_ptp_pps_perout_handler(struct hrtimer *timer) return HRTIMER_NORESTART; } -/** - * fec_ptp_read - read raw cycle counter (to be used by time counter) - * @cc: the cyclecounter structure - * - * this function reads the cyclecounter registers and is called by the - * cyclecounter structure used to construct a ns counter from the - * arbitrary fixed point registers - */ -static u64 fec_ptp_read(const struct cyclecounter *cc) -{ - struct fec_enet_private *fep = - container_of(cc, struct fec_enet_private, cc); - u32 tempval; - - tempval = readl(fep->hwp + FEC_ATIME_CTRL); - tempval |= FEC_T_CTRL_CAPTURE; - writel(tempval, fep->hwp + FEC_ATIME_CTRL); - - if (fep->quirks & FEC_QUIRK_BUG_CAPTURE) - udelay(1); - - return readl(fep->hwp + FEC_ATIME); -} - /** * fec_ptp_start_cyclecounter - create the cycle counter from hw * @ndev: network device From patchwork Mon Aug 12 09:47:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?Q3PDs2vDoXMgQmVuY2U=?= X-Patchwork-Id: 13760376 X-Patchwork-Delegate: kuba@kernel.org Received: from fw2.prolan.hu (fw2.prolan.hu [193.68.50.107]) (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 F1F1316D4E6; Mon, 12 Aug 2024 09:47:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.68.50.107 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723456073; cv=none; b=QSlzZM8HP5FPZS3BJe9eKnwOidDCO2t6EyQzDQvbT8m6bjtloJ5T4LfXsDIx1UdzkPvB8PO1amYGMAlLe62w+9WUhWRtevk/hUramMPjFv5LMdVvxyZkUpK3BceFLjC91pLywa+YmNRZZCADdulX1FOSyDRqxQX8AeW2UKQa4YI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723456073; c=relaxed/simple; bh=mHrx7jeCvf7liAzUhEblv0bq8nC2O0YGczC8eAhv6IA=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=KtVvoCRswgn+LQ7ZQ+imvIWFl06kIYjNmsrAgCsqaFvsdnc1MAgVfvYw2PBaGprQ7V2cfsERRxwlUvGHJJa9Pr+PgFKw7ZJF8dHSFY6VRdJ+AnQ5yiRcbGsuk4eCsWrHzutCMnt4FjyO7RAImA+0lOxkk/zWydAGxTsJTwZNtgY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=prolan.hu; spf=pass smtp.mailfrom=prolan.hu; dkim=pass (4096-bit key) header.d=prolan.hu header.i=@prolan.hu header.b=ENkrjTQF; arc=none smtp.client-ip=193.68.50.107 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=prolan.hu Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=prolan.hu Authentication-Results: smtp.subspace.kernel.org; dkim=pass (4096-bit key) header.d=prolan.hu header.i=@prolan.hu header.b="ENkrjTQF" Received: from proxmox-mailgw.intranet.prolan.hu (localhost.localdomain [127.0.0.1]) by proxmox-mailgw.intranet.prolan.hu (Proxmox) with ESMTP id EC6ACA03FB; Mon, 12 Aug 2024 11:47:48 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=prolan.hu; h=cc :cc:content-transfer-encoding:content-type:content-type:date :from:from:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to; s=mail; bh=3wbtoEoxYVroU1JNp7eB tK/67fGjW/Y+nxaKV9kolHw=; b=ENkrjTQFSqjD6EHY++oag+wCwJmWCbXDKTvc PZfxhJ2ATAkjrUKmj4UHidExkfVaBDVneFetjVgRQOOQRYo6L3g+euhILh/ZvxgU +j0E4fQ6PVpu6NwaNRXyOcnmLkv6Utb4FM3bK/CybN5kGjdX9vpDzuCLj3+gPwrw nRSq/D6UQT0zqZWIo2u9EgTQVVbdcOfii76pjMwyrlTYWD9Pjk0FhdsAIqkVMCaN F+7zago67KtZ0obS9XnXvlAlWGlnOFRdYeROUblNDDtAKYVLZDP/VA/b5zLFisRH 3d3pcH0rqePo0ouLoctamnsTnHMFB0u2yI+61GdZ+5ug3VxV2cNzd6cl+gkF1nuz uYM8nFAU0ZDAktuZScYyYrso4kLj0FM9UZSFd2mqeFHRyksQaLFk9x+K6G/sbumZ 6iE8zbjAP220nVf+ezBKZ6Gsf0qFPifrKcLwfekJCLQexkUneTXi82dFWiFxjtxP 5QTAMOvufnhab5jt/mOrG4cTkQzVx6Yw7qa+Tcm8Vrcv3OuiQh3rdOxE06sC8Xmh 66SzTnih6T5NuOJt8U1TLlPlwz8IHyotsrfqP3SSr/ZbMWZA1xQg4qe4nr65F1XG nwSnC3K4g3vJmx7GRDZXehs/exsW4JpVugxRAKJg5TXljkrEnBTA9d84TSYKoYUm Q164IuE= From: =?utf-8?b?Q3PDs2vDoXMsIEJlbmNl?= To: , , CC: =?utf-8?b?Q3PDs2vDoXMsIEJlbmNl?= , "Simon Horman" , Wei Fang , Shenwei Wang , Clark Wang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Richard Cochran Subject: [PATCH v3 net-next 2/2] net: fec: Remove duplicated code Date: Mon, 12 Aug 2024 11:47:15 +0200 Message-ID: <20240812094713.2883476-2-csokas.bence@prolan.hu> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240812094713.2883476-1-csokas.bence@prolan.hu> References: <20240812094713.2883476-1-csokas.bence@prolan.hu> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ESET-AS: R=OK;S=0;OP=CALC;TIME=1723456068;VERSION=7976;MC=3472913282;ID=645971;TRN=0;CRV=0;IPC=;SP=0;SIPS=0;PI=3;F=0 X-ESET-Antispam: OK X-EsetResult: clean, is OK X-EsetId: 37303A29ACD94854617367 X-Patchwork-Delegate: kuba@kernel.org `fec_ptp_pps_perout()` reimplements logic already in `fec_ptp_read()`. Replace with function call. Signed-off-by: Csókás, Bence Reviewed-by: Andrew Lunn --- drivers/net/ethernet/freescale/fec_ptp.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/drivers/net/ethernet/freescale/fec_ptp.c b/drivers/net/ethernet/freescale/fec_ptp.c index 4ed790cb6be4..c97a0e4e7d89 100644 --- a/drivers/net/ethernet/freescale/fec_ptp.c +++ b/drivers/net/ethernet/freescale/fec_ptp.c @@ -235,13 +235,7 @@ static int fec_ptp_pps_perout(struct fec_enet_private *fep) timecounter_read(&fep->tc); /* Get the current ptp hardware time counter */ - temp_val = readl(fep->hwp + FEC_ATIME_CTRL); - temp_val |= FEC_T_CTRL_CAPTURE; - writel(temp_val, fep->hwp + FEC_ATIME_CTRL); - if (fep->quirks & FEC_QUIRK_BUG_CAPTURE) - udelay(1); - - ptp_hc = readl(fep->hwp + FEC_ATIME); + ptp_hc = fec_ptp_read(&fep->cc); /* Convert the ptp local counter to 1588 timestamp */ curr_time = timecounter_cyc2time(&fep->tc, ptp_hc);