Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932354AbdHWQBK (ORCPT ); Wed, 23 Aug 2017 12:01:10 -0400 Received: from mail-cys01nam02on0048.outbound.protection.outlook.com ([104.47.37.48]:7020 "EHLO NAM02-CY1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932129AbdHWQBF (ORCPT ); Wed, 23 Aug 2017 12:01:05 -0400 Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=nxp.com; nxp.com; dkim=none (message not signed) header.d=none;nxp.com; dmarc=fail action=none header.from=nxp.com; From: Matthew Tan To: CC: , , , , , , , , , Matthew Tan Subject: [PATCH] e1000e: changed some expensive calls of udelay to usleep_range Date: Wed, 23 Aug 2017 10:59:45 -0500 Message-ID: <1503503985-3869-1-git-send-email-matthew.tan_1@nxp.com> X-Mailer: git-send-email 2.7.4 X-EOPAttributedMessage: 0 X-Matching-Connectors: 131479776633752177;(91ab9b29-cfa4-454e-5278-08d120cd25b8);() X-Forefront-Antispam-Report: CIP:192.88.168.50;IPV:NLI;CTRY:US;EFV:NLI;SFV:NSPM;SFS:(10009020)(6009001)(336005)(39860400002)(39380400002)(2980300002)(1110001)(1109001)(339900001)(189002)(199003)(50986999)(189998001)(105606002)(36756003)(106466001)(4326008)(47776003)(50226002)(2351001)(305945005)(50466002)(498600001)(77096006)(48376002)(626005)(551934003)(68736007)(6666003)(104016004)(5660300001)(53936002)(110136004)(7416002)(85426001)(6916009)(8936002)(33646002)(356003)(86362001)(97736004)(81156014)(5003940100001)(8656003)(81166006)(2906002)(54906002)(8676002);DIR:OUT;SFP:1101;SCL:1;SRVR:SN2PR03MB2272;H:tx30smr01.am.freescale.net;FPR:;SPF:Fail;PTR:InfoDomainNonexistent;MX:1;A:1;LANG:en; X-Microsoft-Exchange-Diagnostics: 1;BL2FFO11FD029;1:LZ+Ca6XBQtGf/M7ONkKFHOH4CQZmVPlXh62aw3fNDFD08EpzuSHmKtRYKDoG3IOSg9rAEceMU9VlkcRydnBCKdnsnFmJ99VMtUPbutHBT1hSpyE0SDbWy5aLODTFRD2M MIME-Version: 1.0 Content-Type: text/plain X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 270b7688-0563-4d87-a910-08d4ea4027db X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(300000503095)(300135400095)(2017052603186)(201703131430075)(201703131517081)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095);SRVR:SN2PR03MB2272; X-Microsoft-Exchange-Diagnostics: 1;SN2PR03MB2272;3:vAlPawm7N0QtWwvVZq5OomvOM8nlY0hVEDVgEjApUOFlShQhvnJ03VAVHs58KlHhebbsNuq7NG2lTlnH698S7kTweCchuHKKq0j9I1Jze08i5ZcJPWzcwMWyqz9R5s2VWCGw91OUDRDgCBvuj/IWPqFWtuD9bB7J8ObP5CmJ+feK8OboerhHF+W3/8MwQBhO+HczX+hw2Aal/mkNI7UEOBBL1A8jdo9mF3X9zLwt4nOLArfGPi7fjxDVt/P03Alhl+ESSfJ3zOoPzU/e85/PP4ac4n+e6bmYVCJQmnsYanawS+4bPoq8UGgSCj/Amy0ZwMGLQSHFahhOVGT6N1+1C07YQjMgTQWKHbHc9wH0fRc=;25:zY2NGylW1I2JTSrkoBV5qHnZ5GJDqy9WGOBT0lHJOInRrQOzaP+umVe03w5XBVzfgy5S2WotXcq/BRa4v/0TItSqpPHDF2JHSH9+DLiN2QEWy8fLHmGUMAat+THm9tjlh6mGnu/nLZGkGKpDAWOzLRIrOSDKrWNz5RzSaQhwkmevP1gaU1tVWfw7urD+jil4pdU46kO6I2azRq+nuZjT5ilNuIWHeFsLwHLqMb+oVUZlubGSwB+IuhdtNWH+BXRPeqDZt3SeXC1B+qgLkzC5i1gVLsXikPDx5rrQx84kC3h4bC5MbKh7P7dlHLKBuKksRs4uPpf2WNIbUic1kskzXw== X-MS-TrafficTypeDiagnostic: SN2PR03MB2272: X-Microsoft-Exchange-Diagnostics: 1;SN2PR03MB2272;31:EGrt5t77JKEsJVLQlZl3nh3WN+27nW49Zb8BPtBIyT0fwwppe6TpdyfVAyBvlAIDht0gRmgNoYJ8ykO3UKZM7ULJjfL/DUlE8qQPodWmp1JDkXk6P26HjV3mPcfrxh2PsgLSoM20yA0fCepLuiIOOmC3Qg8YlO5V2I+taLamjii4ZHQyXzQZIIfBs7SxvB0H2lO/GCCLiaCvyTQ57iEKmzm5j8MIhkzjOqnaBx1ulH4=;4:iVkT0M6cB7gr52CZs6CN3nHs0Hl37M2ooSx5N2zRBv3XbIdM/Je6raLNDJ1ejzUusFdGU/n/3q9URrI9XB2h3xcAgrL2/TTz0ZLjHtCrZQ5G/S1KGRgNEPfFWKqfb5WpdYCJM6Lv68n0sdVM4yRNNTm7OWLPJ6gdsqXZg3sgYX1MfICMBn3HnkQnxz5Oqe9E4U9ow9Z3hZznVHvQGELZq4QuXLVSvIwLz2UTxpRVIbb+ypkUlGdxR+yCrVJAKqqCA8l6GP3SrhZ97RJrnCHG3AujzbJpYs+dsIVfeWhGvCfKGfRosjg2FNEOffG1r76IAqRnmo88uR+p6tqyIldVCA== X-Exchange-Antispam-Report-Test: UriScan:(278428928389397)(185117386973197); X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6095135)(601004)(2401047)(8121501046)(13018025)(13016025)(5005006)(3002001)(10201501046)(100000703101)(100105400095)(93006095)(93001095)(6055026)(6096035)(201703131430075)(201703131433075)(201703131441075)(201703131448075)(201703161259150)(20161123565025)(20161123559100)(20161123563025)(20161123561025)(20161123556025)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:SN2PR03MB2272;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(400006)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:SN2PR03MB2272; X-Forefront-PRVS: 040866B734 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;SN2PR03MB2272;23:qVfq2iLp8h9+yEHNX6A4SfPfZa/qbYG4k7YbKplpH?= =?us-ascii?Q?4GLUYasZr53LTHIKmXdgZ9hrlxboOlJTUqgzAC4QV70/dtTl3hUIGhmuuy0E?= =?us-ascii?Q?j/kKSXGbEsJao/fFeFYX3P23yaO15H7Vl3z2Adb5TFzHa5vvG7LCNIcr359H?= =?us-ascii?Q?NluZBgmOsq9XfHWZHA6yU8ASLdkx4ePEup8nj8WRwn8cRo60Y2FzShIZDcAu?= =?us-ascii?Q?qxyN7oeLhsl9Ht2mUVN2CU/8cHqkM6GuO12FcaF8M37J6eAQTVQQpPOqB+hK?= =?us-ascii?Q?Pmr5+H6zDHAwEr7fxKfsLXy4LS0XseyDgcN46h3ZxKilWrLGDfWs5dzVmC/+?= =?us-ascii?Q?Gu2Jyx+p0TJJ4CkH28LeZh4Ag6zyoEgEb+IH2igmT9KNuAPLgqohJv3458kD?= =?us-ascii?Q?EMe4BFO5n6EBcnyVXp8XbXqdd1cVPty4j0Zv+IVqNhsFkL1JacRLVTeCHJH2?= =?us-ascii?Q?WZcGm/rMgqeV+EC+OXbhQjBamJel/vfoZfBgQ4Uw1Q+RJV+ZNzO+4x85KBhA?= =?us-ascii?Q?0OByxXnxkcyF7s3MrvJGvruNPdBqE5OSnByVB2xX77KtreiUsCOQYreqT8KC?= =?us-ascii?Q?fkC/FJtbviU6puHkUzjRJUKeiGXuua/W/j8GWyRoAktE8QGM/y/j886JYFKF?= =?us-ascii?Q?0Vdaq9rgPxXX4n7HJLhQeHN8VMXxHpHPPX6VGNCGY5vJQgqRZd9ugvBdtg5c?= =?us-ascii?Q?pF9IxrHlRKpc85xASXas+jT/XjcU3Y1x8fFFeFoJR/Slz8x19jNY8OvW+6oJ?= =?us-ascii?Q?FPM1xL6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BMK2Mg=;7:8lEjRiVQPurDIQWCVXZN1vMmJt9xdVcnms1HrM5FtDCetD95mRfJwKdKPbbtYOlXGOJb7Nw0sh+IRfd9rpEgtiLDMfZomy7vU8nesNFE15J//jh3uDk2XT/hzCo3FDnJow+c0fFLyKN9cTTD7sVJkAEGUzNXQ3GBfgtI2NubF+CjV/moqsA+tzkjUJFlD5qzB5d5m/JTvfr/ma4TpOkja2SRi9JPDk3bVgOU2jh1r1A= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Aug 2017 16:01:00.4735 (UTC) X-MS-Exchange-CrossTenant-Id: 5afe0b00-7697-4969-b663-5eab37d5f47e X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5afe0b00-7697-4969-b663-5eab37d5f47e;Ip=[192.88.168.50];Helo=[tx30smr01.am.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN2PR03MB2272 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2021 Lines: 56 Calls to udelay are not preemtable by userspace so userspace applications experience a large (~200us) latency when running on core 0. Instead usleep_range can be used to be more friendly to userspace since it is preemtable. This is due to udelay using busy-wait loops while usleep_rang uses hrtimers instead. It is recommended to use udelay when the delay is <10us since at that precision overhead of usleep_range hrtimer setup causes issues. However, the replaced calls are for 50us and 100us so this should not be not an issue. Signed-off-by: Matthew Tan --- drivers/net/ethernet/intel/e1000e/phy.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/intel/e1000e/phy.c b/drivers/net/ethernet/intel/e1000e/phy.c index de13aea..e318fdc 100644 --- a/drivers/net/ethernet/intel/e1000e/phy.c +++ b/drivers/net/ethernet/intel/e1000e/phy.c @@ -158,7 +158,7 @@ s32 e1000e_read_phy_reg_mdic(struct e1000_hw *hw, u32 offset, u16 *data) * the lower time out */ for (i = 0; i < (E1000_GEN_POLL_TIMEOUT * 3); i++) { - udelay(50); + usleep_range(40, 60); mdic = er32(MDIC); if (mdic & E1000_MDIC_READY) break; @@ -183,7 +183,7 @@ s32 e1000e_read_phy_reg_mdic(struct e1000_hw *hw, u32 offset, u16 *data) * reading duplicate data in the next MDIC transaction. */ if (hw->mac.type == e1000_pch2lan) - udelay(100); + usleep_range(90, 100); return 0; } @@ -222,7 +222,7 @@ s32 e1000e_write_phy_reg_mdic(struct e1000_hw *hw, u32 offset, u16 data) * the lower time out */ for (i = 0; i < (E1000_GEN_POLL_TIMEOUT * 3); i++) { - udelay(50); + usleep_range(40, 60); mdic = er32(MDIC); if (mdic & E1000_MDIC_READY) break; @@ -246,7 +246,7 @@ s32 e1000e_write_phy_reg_mdic(struct e1000_hw *hw, u32 offset, u16 data) * reading duplicate data in the next MDIC transaction. */ if (hw->mac.type == e1000_pch2lan) - udelay(100); + usleep_range(90, 110); return 0; } -- 2.7.4