mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@osdl.org>
To: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: linux-kernel <linux-kernel@vger.kernel.org>,
	sfr@canb.auug.org.au, Ingo Molnar <mingo@elte.hu>
Subject: Re: [PATCH] lockdep: annotate i386 apm
Date: Wed, 11 Oct 2006 23:39:25 -0700	[thread overview]
Message-ID: <20061011233925.c9ba117a.akpm@osdl.org> (raw)
In-Reply-To: <1160633180.2006.94.camel@taijtu>

On Thu, 12 Oct 2006 08:06:20 +0200
Peter Zijlstra <a.p.zijlstra@chello.nl> wrote:

> #define local_irq_restore(flags)                                \
>         do {                                                    \
>                 if (raw_irqs_disabled_flags(flags)) {           \
>                         raw_local_irq_restore(flags);           \
>                         trace_hardirqs_off();                   \
>                 } else {                                        \
>                         trace_hardirqs_on();                    \
>                         raw_local_irq_restore(flags);           \
>                 }                                               \
>         } while (0)
> 
> So, say interrupts were enabled when entering apm_bios_call*(); you now
> save that in flags, disable interrupts, and enable them again.
> Upon reaching local_irq_restore(), we'll hit the else branch with irq's
> enabled and call trace_hardirqs_on(), which goes EEEK!

I'd assumed lockdep was less stupid than that ;) This?  Seems a bit
overdone..

--- a/arch/i386/kernel/apm.c~lockdep-annotate-i386-apm
+++ a/arch/i386/kernel/apm.c
@@ -540,12 +540,6 @@ static inline void apm_restore_cpus(cpum
  * Also, we KNOW that for the non error case of apm_bios_call, there
  * is no useful data returned in the low order 8 bits of eax.
  */
-#define APM_DO_CLI	\
-	if (apm_info.allow_ints) \
-		local_irq_enable(); \
-	else \
-		local_irq_disable();
-
 #ifdef APM_ZERO_SEGS
 #	define APM_DECL_SEGS \
 		unsigned int saved_fs; unsigned int saved_gs;
@@ -583,11 +577,12 @@ static u8 apm_bios_call(u32 func, u32 eb
 	u32 *eax, u32 *ebx, u32 *ecx, u32 *edx, u32 *esi)
 {
 	APM_DECL_SEGS
-	unsigned long		flags;
 	cpumask_t		cpus;
 	int			cpu;
 	struct desc_struct	save_desc_40;
 	struct desc_struct	*gdt;
+	int			enable_irqs = 0;
+	int			disable_irqs = 0;
 
 	cpus = apm_save_cpus();
 	
@@ -596,12 +591,26 @@ static u8 apm_bios_call(u32 func, u32 eb
 	save_desc_40 = gdt[0x40 / 8];
 	gdt[0x40 / 8] = bad_bios_desc;
 
-	local_save_flags(flags);
-	APM_DO_CLI;
+	if (apm_info.allow_ints) {
+		if (irqs_disabled()) {
+			local_irq_enable();
+			disable_irqs = 1;
+		}
+	} else {
+		if (!irqs_disabled()) {
+			local_irq_disable();
+			enable_irqs = 1;
+		}
+	}
+
+
 	APM_DO_SAVE_SEGS;
 	apm_bios_call_asm(func, ebx_in, ecx_in, eax, ebx, ecx, edx, esi);
 	APM_DO_RESTORE_SEGS;
-	local_irq_restore(flags);
+	if (disable_irqs)
+		local_irq_disable();
+	if (enable_irqs)
+		local_irq_enable();
 	gdt[0x40 / 8] = save_desc_40;
 	put_cpu();
 	apm_restore_cpus(cpus);
@@ -627,11 +636,12 @@ static u8 apm_bios_call_simple(u32 func,
 {
 	u8			error;
 	APM_DECL_SEGS
-	unsigned long		flags;
 	cpumask_t		cpus;
 	int			cpu;
 	struct desc_struct	save_desc_40;
 	struct desc_struct	*gdt;
+	int			enable_irqs = 0;
+	int			disable_irqs = 0;
 
 	cpus = apm_save_cpus();
 	
@@ -640,12 +650,25 @@ static u8 apm_bios_call_simple(u32 func,
 	save_desc_40 = gdt[0x40 / 8];
 	gdt[0x40 / 8] = bad_bios_desc;
 
-	local_save_flags(flags);
-	APM_DO_CLI;
+	if (apm_info.allow_ints) {
+		if (irqs_disabled()) {
+			local_irq_enable();
+			disable_irqs = 1;
+		}
+	} else {
+		if (!irqs_disabled()) {
+			local_irq_disable();
+			enable_irqs = 1;
+		}
+	}
+
 	APM_DO_SAVE_SEGS;
 	error = apm_bios_call_simple_asm(func, ebx_in, ecx_in, eax);
 	APM_DO_RESTORE_SEGS;
-	local_irq_restore(flags);
+	if (disable_irqs)
+		local_irq_disable();
+	if (enable_irqs)
+		local_irq_enable();
 	gdt[0x40 / 8] = save_desc_40;
 	put_cpu();
 	apm_restore_cpus(cpus);
_


  reply	other threads:[~2006-10-12  6:39 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-10-11 13:40 Peter Zijlstra
2006-10-11 21:18 ` Andrew Morton
2006-10-12  6:06   ` Peter Zijlstra
2006-10-12  6:39     ` Andrew Morton [this message]
2006-10-12  6:50       ` Peter Zijlstra
2006-10-12  7:29         ` Andrew Morton
2006-10-12  8:13           ` Peter Zijlstra
2006-10-12  8:02       ` Ingo Molnar
2006-10-12  8:26         ` Peter Zijlstra

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20061011233925.c9ba117a.akpm@osdl.org \
    --to=akpm@osdl.org \
    --cc=a.p.zijlstra@chello.nl \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=sfr@canb.auug.org.au \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®