lkml.org 
[lkml]   [2018]   [Jan]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 4/4] hwmon: (dell-smm) Measure time duration of SMM call around inlined asm
Date
Measure only inlined asm code, not other functions to have as precise as
possible measured time.

Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
---
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
--
2.11.0
\
 
 \ /
  Last update: 2018-01-27 17:24    [W:0.114 / U:0.076 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site