From patchwork Sat Jan 27 16:23:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Pali_Roh=C3=A1r?= X-Patchwork-Id: 10187563 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 72CBD601D5 for ; Sat, 27 Jan 2018 16:24:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5EA8428A2E for ; Sat, 27 Jan 2018 16:24:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 52BC228B4D; Sat, 27 Jan 2018 16:24:16 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EB11C28A2E for ; Sat, 27 Jan 2018 16:24:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753206AbeA0QYP (ORCPT ); Sat, 27 Jan 2018 11:24:15 -0500 Received: from mail-wm0-f67.google.com ([74.125.82.67]:33233 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753161AbeA0QYO (ORCPT ); Sat, 27 Jan 2018 11:24:14 -0500 Received: by mail-wm0-f67.google.com with SMTP id x4so38910363wmc.0; Sat, 27 Jan 2018 08:24:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=VA7RqsffZbXdROmlcaPXVV5cacDFHFANxkgw126s/5M=; b=hSTROzZH6Wmq2Oq7/HcYFzbbs9T0A+YqxiyBy33nGzgE9hfPYLqdefLPuxxuiqeYco ynvGb8NuMq4q+RDi8FKkTqbR6L2o27B15G9xUMUaZs/8oH5f0kf+tX4aotd+4pcTw2ED fFHvJle5vhrIwpgT1u4679MhhWrt3kE9hYrXQv/b/L7Vk5w8Y2mDgRjyfGTWN2AjbEql Rl6+CA+WalWtV5tUIr8cQ+tqA4PcIT6r5oQ1pkFMLLPAzuf37aStls+Dl/1K0DMlreqA JOA3AHQUiww20u+4yZw1myg/rf4UYxJ7Gc3DnPJiJ2/U147+SySnXubRJr8ULkbgMobR II+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=VA7RqsffZbXdROmlcaPXVV5cacDFHFANxkgw126s/5M=; b=k7/0xx27JGRsD2ZnFOOh8bqqItMvalp6c2bRJzIoyHVg7GM2qjpH1aTGQJx0Mdw0Ay rSTFUpmIFe0nYuWO1+e73LEmgHM6h0R/NNT9wPjLQPVU/NrTEFcMREKQY2haas0NCQPK fmXjWUuQ4kvoMXwvdO/yX4pVe6knKR1GbLjtCOM/Z5jvWdqd1XO43o2gj4NUvvTgvpSm i/3F5UWZc83t51j1v7Zcq3ffInpkr4VWcvQa9YA2Um0uiGoxwTUcqasKdNyT0wVZ+vFv +8FvL2MgQlPanNCUEfIIcutrVUHV0aqzeUzklB7dpPDc6Ys+gP36Uyu1OOPmotE7D1T3 1kvA== X-Gm-Message-State: AKwxytc+Qi7d97NG92FuOfTBfb6+eaoajqRK1zKFbGs05/xEC+fK1bdJ fsfcRHuaYxR1Rjxgd0a+Jn0= X-Google-Smtp-Source: AH8x224MwTDm5L+A02V67O84X7V58xgFYX2cAWhitNOQ/aUq3mmUIVahvAvkgzK7h9FTN6fDA/ou6w== X-Received: by 10.28.114.3 with SMTP id n3mr13369518wmc.124.1517070253454; Sat, 27 Jan 2018 08:24:13 -0800 (PST) Received: from Pali-Latitude.lan (pali.kolej.mff.cuni.cz. [78.128.193.202]) by smtp.gmail.com with ESMTPSA id x203sm15481836wmd.11.2018.01.27.08.24.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 27 Jan 2018 08:24:12 -0800 (PST) From: =?UTF-8?q?Pali=20Roh=C3=A1r?= To: Jean Delvare , Guenter Roeck , Oleksandr Natalenko , Jonathan Buzzard , Mario Limonciello Cc: linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org, =?UTF-8?q?Pali=20Roh=C3=A1r?= Subject: [PATCH 4/4] hwmon: (dell-smm) Measure time duration of SMM call around inlined asm Date: Sat, 27 Jan 2018 17:23:51 +0100 Message-Id: <20180127162351.13858-1-pali.rohar@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180127162204.13752-1-pali.rohar@gmail.com> References: <20180127162204.13752-1-pali.rohar@gmail.com> MIME-Version: 1.0 Sender: linux-hwmon-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Measure only inlined asm code, not other functions to have as precise as possible measured time. Signed-off-by: Pali Rohár --- drivers/hwmon/dell-smm-hwmon.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/drivers/hwmon/dell-smm-hwmon.c b/drivers/hwmon/dell-smm-hwmon.c index bf3bb7e1adab..e001afd53f46 100644 --- a/drivers/hwmon/dell-smm-hwmon.c +++ b/drivers/hwmon/dell-smm-hwmon.c @@ -147,14 +147,16 @@ static int i8k_smm_func(void *par) int ebx = regs->ebx; unsigned long duration; ktime_t calltime, delta, rettime; - - calltime = ktime_get(); #endif /* SMM requires CPU 0 */ if (smp_processor_id() != 0) return -EBUSY; +#ifdef DEBUG + calltime = ktime_get(); +#endif + #if defined(CONFIG_X86_64) asm volatile("pushq %%rax\n\t" "movl 0(%%rax),%%edx\n\t" @@ -208,13 +210,17 @@ static int i8k_smm_func(void *par) : "a"(regs) : "%ebx", "%ecx", "%edx", "%esi", "%edi", "memory"); #endif - if (rc != 0 || (regs->eax & 0xffff) == 0xffff || regs->eax == eax) - rc = -EINVAL; #ifdef DEBUG rettime = ktime_get(); delta = ktime_sub(rettime, calltime); duration = ktime_to_ns(delta) >> 10; +#endif + + if (rc != 0 || (regs->eax & 0xffff) == 0xffff || regs->eax == eax) + rc = -EINVAL; + +#ifdef DEBUG pr_debug("smm(0x%.4x 0x%.4x) = 0x%.4x (took %7lu usecs)\n", eax, ebx, (rc ? 0xffff : regs->eax & 0xffff), duration); #endif