Re: [PATCH] Complain if driver reenables interrupts during drivers_[suspend|resume] & re-disable

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 2006-02-07 at 19:06 +1000, Nigel Cunningham wrote:
> Hi all.
> 
> This patch is designed to help with diagnosing and fixing the cause of
> problems in suspending/resuming, due to drivers wrongly re-enabling
> interrupts in their .suspend or .resume methods. 
> 
> I nearly forgot about it in sending patches in suspend2 that might help
> where swsusp fails.

Ugh ? Interrupts aren't supposed to be off during resume()...

Ben.

> Signed-off-by: Nigel Cunningham <[email protected]>
> 
>  power/resume.c  |    5 +++++
>  power/suspend.c |    5 +++++
>  sys.c           |   37 +++++++++++++++++++++++++++++++++++--
>  3 files changed, 45 insertions(+), 2 deletions(-)
> diff -ruNp 8010-driver-model-debug.patch-old/drivers/base/power/resume.c 
> 8010-driver-model-debug.patch-new/drivers/base/power/resume.c
> --- 8010-driver-model-debug.patch-old/drivers/base/power/resume.c	
> 2006-01-19 21:27:39.000000000 +1000
> +++ 8010-driver-model-debug.patch-new/drivers/base/power/resume.c	
> 2006-01-31 19:54:52.000000000 +1000
> @@ -35,6 +35,11 @@ int resume_device(struct device * dev)
>  	if (dev->bus && dev->bus->resume) {
>  		dev_dbg(dev,"resuming\n");
>  		error = dev->bus->resume(dev);
> +		if (!irqs_disabled()) {
> +			printk(KERN_EMERG "WARNING: Interrupts reenabled while resuming device 
> %s.\n",
> +				kobject_name(&dev->kobj));
> +			local_irq_disable();
> +		}
>  	}
>  	up(&dev->sem);
>  	return error;
> diff -ruNp 8010-driver-model-debug.patch-old/drivers/base/power/suspend.c 
> 8010-driver-model-debug.patch-new/drivers/base/power/suspend.c
> --- 8010-driver-model-debug.patch-old/drivers/base/power/suspend.c	
> 2006-01-19 21:27:39.000000000 +1000
> +++ 8010-driver-model-debug.patch-new/drivers/base/power/suspend.c	
> 2006-01-31 19:54:44.000000000 +1000
> @@ -58,6 +58,11 @@ int suspend_device(struct device * dev, 
>  	if (dev->bus && dev->bus->suspend && !dev->power.power_state.event) {
>  		dev_dbg(dev, "suspending\n");
>  		error = dev->bus->suspend(dev, state);
> +		if (!irqs_disabled()) {
> +			printk(KERN_EMERG "WARNING: Interrupts reenabled while suspending 
> device %s.\n",
> +				kobject_name(&dev->kobj));
> +			local_irq_disable();
> +		}
>  	}
>  	up(&dev->sem);
>  	return error;
> diff -ruNp 8010-driver-model-debug.patch-old/drivers/base/sys.c 
> 8010-driver-model-debug.patch-new/drivers/base/sys.c
> --- 8010-driver-model-debug.patch-old/drivers/base/sys.c	2006-01-19 
> 21:27:39.000000000 +1000
> +++ 8010-driver-model-debug.patch-new/drivers/base/sys.c	2006-01-31 
> 19:54:09.000000000 +1000
> @@ -298,16 +298,34 @@ static void __sysdev_resume(struct sys_d
>  	if (cls->resume)
>  		cls->resume(dev);
>  
> +	if (!irqs_disabled()) {
> +		printk(KERN_EMERG "WARNING: Interrupts reenabled while resuming sysdev 
> class specific driver %s.\n",
> +				kobject_name(&dev->kobj));
> +		local_irq_disable();
> +	}
> +
>  	/* Call auxillary drivers next. */
>  	list_for_each_entry(drv, &cls->drivers, entry) {
> -		if (drv->resume)
> +		if (drv->resume) {
>  			drv->resume(dev);
> +			if (!irqs_disabled()) {
> +				printk(KERN_EMERG "WARNING: Interrupts reenabled while resuming sysdev 
> class driver %s.\n",
> +				kobject_name(&dev->kobj));
> +				local_irq_disable();
> +			}
> +		}
>  	}
>  
>  	/* Call global drivers. */
>  	list_for_each_entry(drv, &sysdev_drivers, entry) {
> -		if (drv->resume)
> +		if (drv->resume) {
>  			drv->resume(dev);
> +			if (!irqs_disabled()) {
> +				printk(KERN_EMERG "WARNING: Interrupts reenabled while resuming sysdev 
> driver %s.\n",
> +				kobject_name(&dev->kobj));
> +				local_irq_disable();
> +			}
> +		}
>  	}
>  }
>  
> @@ -346,6 +364,11 @@ int sysdev_suspend(pm_message_t state)
>  			list_for_each_entry(drv, &sysdev_drivers, entry) {
>  				if (drv->suspend) {
>  					ret = drv->suspend(sysdev, state);
> +					if (!irqs_disabled()) {
> +						printk(KERN_EMERG "WARNING: Interrupts reenabled while suspending 
> sysdev driver %s.\n",
> +							kobject_name(&sysdev->kobj));
> +						local_irq_disable();
> +					}
>  					if (ret)
>  						goto gbl_driver;
>  				}
> @@ -355,6 +378,11 @@ int sysdev_suspend(pm_message_t state)
>  			list_for_each_entry(drv, &cls->drivers, entry) {
>  				if (drv->suspend) {
>  					ret = drv->suspend(sysdev, state);
> +					if (!irqs_disabled()) {
> +						printk(KERN_EMERG "WARNING: Interrupts reenabled while suspending 
> sysdev class driver %s.\n",
> +						kobject_name(&sysdev->kobj));
> +						local_irq_disable();
> +					}
>  					if (ret)
>  						goto aux_driver;
>  				}
> @@ -363,6 +391,11 @@ int sysdev_suspend(pm_message_t state)
>  			/* Now call the generic one */
>  			if (cls->suspend) {
>  				ret = cls->suspend(sysdev, state);
> +				if (!irqs_disabled()) {
> +					printk(KERN_EMERG "WARNING: Interrupts reenabled while suspending 
> class driver %s.\n",
> +					kobject_name(&sysdev->kobj));
> +					local_irq_disable();
> +				}
>  				if (ret)
>  					goto cls_driver;
>  			}

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux