* [PATCH RESEND v2] hwmon: (dell-smm) Rework SMM function debugging
@ 2021-08-14 19:05 W_Armin
2021-08-15 10:11 ` Pali Rohár
2021-08-15 11:40 ` Guenter Roeck
0 siblings, 2 replies; 3+ messages in thread
From: W_Armin @ 2021-08-14 19:05 UTC (permalink / raw
To: pali; +Cc: linux, jdelvare, linux-hwmon
From: Armin Wolf <W_Armin@gmx.de>
Drop #ifdef DEBUG and use ktime_us_delta()
for improved precision.
Signed-off-by: Armin Wolf <W_Armin@gmx.de>
---
Changes in v2:
- remove #ifdef DEBUG completly
- init each variable at one line
---
drivers/hwmon/dell-smm-hwmon.c | 21 ++++++---------------
1 file changed, 6 insertions(+), 15 deletions(-)
diff --git a/drivers/hwmon/dell-smm-hwmon.c b/drivers/hwmon/dell-smm-hwmon.c
index 68af95c1d90c..25fac796fc86 100644
--- a/drivers/hwmon/dell-smm-hwmon.c
+++ b/drivers/hwmon/dell-smm-hwmon.c
@@ -158,17 +158,12 @@ static inline const char __init *i8k_get_dmi_data(int field)
*/
static int i8k_smm_func(void *par)
{
- int rc;
+ ktime_t calltime = ktime_get();
struct smm_regs *regs = par;
int eax = regs->eax;
-
-#ifdef DEBUG
int ebx = regs->ebx;
- unsigned long duration;
- ktime_t calltime, delta, rettime;
-
- calltime = ktime_get();
-#endif
+ long long duration;
+ int rc;
/* SMM requires CPU 0 */
if (smp_processor_id() != 0)
@@ -230,13 +225,9 @@ static int i8k_smm_func(void *par)
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;
- pr_debug("smm(0x%.4x 0x%.4x) = 0x%.4x (took %7lu usecs)\n", eax, ebx,
- (rc ? 0xffff : regs->eax & 0xffff), duration);
-#endif
+ duration = ktime_us_delta(ktime_get(), calltime);
+ pr_debug("smm(0x%.4x 0x%.4x) = 0x%.4x (took %7lld usecs)\n", eax, ebx,
+ (rc ? 0xffff : regs->eax & 0xffff), duration);
return rc;
}
--
2.20.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH RESEND v2] hwmon: (dell-smm) Rework SMM function debugging
2021-08-14 19:05 [PATCH RESEND v2] hwmon: (dell-smm) Rework SMM function debugging W_Armin
@ 2021-08-15 10:11 ` Pali Rohár
2021-08-15 11:40 ` Guenter Roeck
1 sibling, 0 replies; 3+ messages in thread
From: Pali Rohár @ 2021-08-15 10:11 UTC (permalink / raw
To: W_Armin; +Cc: linux, jdelvare, linux-hwmon
On Saturday 14 August 2021 21:05:16 W_Armin@gmx.de wrote:
> From: Armin Wolf <W_Armin@gmx.de>
>
> Drop #ifdef DEBUG and use ktime_us_delta()
> for improved precision.
>
> Signed-off-by: Armin Wolf <W_Armin@gmx.de>
Looks good,
Reviewed-by: Pali Rohár <pali@kernel.org>
> ---
> Changes in v2:
> - remove #ifdef DEBUG completly
> - init each variable at one line
> ---
> drivers/hwmon/dell-smm-hwmon.c | 21 ++++++---------------
> 1 file changed, 6 insertions(+), 15 deletions(-)
>
> diff --git a/drivers/hwmon/dell-smm-hwmon.c b/drivers/hwmon/dell-smm-hwmon.c
> index 68af95c1d90c..25fac796fc86 100644
> --- a/drivers/hwmon/dell-smm-hwmon.c
> +++ b/drivers/hwmon/dell-smm-hwmon.c
> @@ -158,17 +158,12 @@ static inline const char __init *i8k_get_dmi_data(int field)
> */
> static int i8k_smm_func(void *par)
> {
> - int rc;
> + ktime_t calltime = ktime_get();
> struct smm_regs *regs = par;
> int eax = regs->eax;
> -
> -#ifdef DEBUG
> int ebx = regs->ebx;
> - unsigned long duration;
> - ktime_t calltime, delta, rettime;
> -
> - calltime = ktime_get();
> -#endif
> + long long duration;
> + int rc;
>
> /* SMM requires CPU 0 */
> if (smp_processor_id() != 0)
> @@ -230,13 +225,9 @@ static int i8k_smm_func(void *par)
> 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;
> - pr_debug("smm(0x%.4x 0x%.4x) = 0x%.4x (took %7lu usecs)\n", eax, ebx,
> - (rc ? 0xffff : regs->eax & 0xffff), duration);
> -#endif
> + duration = ktime_us_delta(ktime_get(), calltime);
> + pr_debug("smm(0x%.4x 0x%.4x) = 0x%.4x (took %7lld usecs)\n", eax, ebx,
> + (rc ? 0xffff : regs->eax & 0xffff), duration);
>
> return rc;
> }
> --
> 2.20.1
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH RESEND v2] hwmon: (dell-smm) Rework SMM function debugging
2021-08-14 19:05 [PATCH RESEND v2] hwmon: (dell-smm) Rework SMM function debugging W_Armin
2021-08-15 10:11 ` Pali Rohár
@ 2021-08-15 11:40 ` Guenter Roeck
1 sibling, 0 replies; 3+ messages in thread
From: Guenter Roeck @ 2021-08-15 11:40 UTC (permalink / raw
To: W_Armin; +Cc: pali, jdelvare, linux-hwmon
On Sat, Aug 14, 2021 at 09:05:16PM +0200, W_Armin@gmx.de wrote:
> From: Armin Wolf <W_Armin@gmx.de>
>
> Drop #ifdef DEBUG and use ktime_us_delta()
> for improved precision.
>
> Signed-off-by: Armin Wolf <W_Armin@gmx.de>
> Reviewed-by: Pali Rohár <pali@kernel.org>
Applied.
Thanks,
Guenter
> ---
> Changes in v2:
> - remove #ifdef DEBUG completly
> - init each variable at one line
> ---
> drivers/hwmon/dell-smm-hwmon.c | 21 ++++++---------------
> 1 file changed, 6 insertions(+), 15 deletions(-)
>
> --
> 2.20.1
>
> diff --git a/drivers/hwmon/dell-smm-hwmon.c b/drivers/hwmon/dell-smm-hwmon.c
> index 68af95c1d90c..25fac796fc86 100644
> --- a/drivers/hwmon/dell-smm-hwmon.c
> +++ b/drivers/hwmon/dell-smm-hwmon.c
> @@ -158,17 +158,12 @@ static inline const char __init *i8k_get_dmi_data(int field)
> */
> static int i8k_smm_func(void *par)
> {
> - int rc;
> + ktime_t calltime = ktime_get();
> struct smm_regs *regs = par;
> int eax = regs->eax;
> -
> -#ifdef DEBUG
> int ebx = regs->ebx;
> - unsigned long duration;
> - ktime_t calltime, delta, rettime;
> -
> - calltime = ktime_get();
> -#endif
> + long long duration;
> + int rc;
>
> /* SMM requires CPU 0 */
> if (smp_processor_id() != 0)
> @@ -230,13 +225,9 @@ static int i8k_smm_func(void *par)
> 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;
> - pr_debug("smm(0x%.4x 0x%.4x) = 0x%.4x (took %7lu usecs)\n", eax, ebx,
> - (rc ? 0xffff : regs->eax & 0xffff), duration);
> -#endif
> + duration = ktime_us_delta(ktime_get(), calltime);
> + pr_debug("smm(0x%.4x 0x%.4x) = 0x%.4x (took %7lld usecs)\n", eax, ebx,
> + (rc ? 0xffff : regs->eax & 0xffff), duration);
>
> return rc;
> }
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-08-15 11:40 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-08-14 19:05 [PATCH RESEND v2] hwmon: (dell-smm) Rework SMM function debugging W_Armin
2021-08-15 10:11 ` Pali Rohár
2021-08-15 11:40 ` Guenter Roeck
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.