pwm-atmel.c generate BUG: scheduling while atomic

This forum is for users of Microchip MPUs and who are interested in using Linux OS.

Moderator: nferre

sbouvet
Posts: 3
Joined: Wed Aug 29, 2018 4:25 pm

pwm-atmel.c generate BUG: scheduling while atomic

Wed Aug 29, 2018 4:36 pm

I'm working on SAMA5D2xPlained and I have a problem with the function pwm_disable().
In my project, I need to start and stop the PWM, I use pwm_enable() and pwm_disable() linked to the Atmle driver pwm-atmel.c.
Sometimes I have the following message printed in continue on my console

BUG: scheduling while atomic: swapper/0/0x00010002
Modules linked in: EvoMotorStep(O) EvoMotorDC(O) EvoSensor(O) EvoPwm(O) EvoUsbFuncPri
nter(O) libcomposite atmel_usba_udc
Preemption disabled at:[<c05a6a10>] 0xc05a6a10
CPU: 0 PID: 0 Comm: swapper Tainted: G O 4.9.87-linux4sam_5.8 #35
Hardware name: Atmel SAMA5
Function entered at [<c010d3ec>] from [<c010aadc>]
Function entered at [<c010aadc>] from [<c01375dc>]
Function entered at [<c01375dc>] from [<c05a6610>]
Function entered at [<c05a6610>] from [<c05a66f0>]
Function entered at [<c05a66f0>] from [<c05a6a08>]
Function entered at [<c05a6a08>] from [<c05a8054>]
Function entered at [<c05a8054>] from [<c0371db0>]
Function entered at [<c0371db0>] from [<c014c394>]
Function entered at [<c014c394>] from [<c014c44c>]
Function entered at [<c014c44c>] from [<c014c4d4>]
Function entered at [<c014c4d4>] from [<c014f424>]
Function entered at [<c014f424>] from [<c014b6ec>]
Function entered at [<c014b6ec>] from [<c014bc64>]
Function entered at [<c014bc64>] from [<c010b5cc>]
Function entered at [<c010b5cc>] from [<c0474858>]
Function entered at [<c0474858>] from [<c0142e54>]
Function entered at [<c0142e54>] from [<c0700bdc>]
bad: scheduling from the idle thread!
sbouvet
Posts: 3
Joined: Wed Aug 29, 2018 4:25 pm

Re: pwm-atmel.c generate BUG: scheduling while atomic

Thu Aug 30, 2018 6:21 pm

Small example to reproduce it

in dtsi

Code: Select all

	evo_pwm {
		compatible = "evo-pwm";

		pwm_led_b {
			label = "pwm_led_b";
			pwms = <&pwm0 1 100000000 1>;
		};
		pwm_pb07 {
			label = "pwm_pb07";
			pwms = <&pwm0 3 100000000 1>;
		};
	};
MyModule.c

Code: Select all

#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/platform_device.h>

#include <linux/pwm.h>

static int my_pdrv_probe (struct platform_device *pdev){
	int n, i;
	struct pwm_device *pwm;
	struct device_node *node;
	struct device_node *child;
	struct device *dev = &pdev->dev;

	node = dev->of_node;
	n = of_get_available_child_count(node);

	for_each_available_child_of_node(node, child) {
		pwm = devm_of_pwm_get(dev, child, NULL);
		if (IS_ERR(pwm)) {
			pr_info("unable to request PWM\n");
			return 0;
		}

		for(i=0; i < 10; i++) {
			pwm_config(pwm, 50000000, 100000000);
			pwm_disable(pwm);
			pwm_enable(pwm);
		}
	}
	return 0;
}

static int my_pdrv_remove(struct platform_device *pdev){
	return 0;
}

static const struct of_device_id evodrv[] = {
	{ .compatible = "evo-pwm", },
	{ },
};

static struct platform_driver mypdrv = {
	.probe = my_pdrv_probe,
	.remove = my_pdrv_remove,
	.driver = {
		.name			= "evo-pwm",
		.owner			= THIS_MODULE,
		.of_match_table	= of_match_ptr(evodrv),
	},
};

static int __init my_drv_init(void)
{
	/* Registering with Kernel */
	platform_driver_register(&mypdrv);
	return 0;
}

static void __exit my_drv_exit(void)
{
	/* Unregistering from Kernel */
	platform_driver_unregister(&mypdrv);
}

module_init(my_drv_init);
module_exit(my_drv_exit);

MODULE_LICENSE("GPL");
MODULE_AUTHOR("s.bouvet");
MODULE_DESCRIPTION("My platform PWM module");
blue_z
Location: USA
Posts: 1768
Joined: Thu Apr 19, 2007 10:15 pm

Re: pwm-atmel.c generate BUG: scheduling while atomic

Fri Aug 31, 2018 1:40 am

The trace you posted is useless without the symbol map for your kernel.
Have you tried to convert any of those addresses to entrypoints (& offsets) to identify who is calling what?
Or configure/build your kernel with debugging symbols.

Regards
sbouvet
Posts: 3
Joined: Wed Aug 29, 2018 4:25 pm

Re: pwm-atmel.c generate BUG: scheduling while atomic

Mon Sep 03, 2018 10:34 am

Hello,

How I can enable debugging symbols? I have tried diffrents config in the kernel config but I have always function address and not the function name.
nferre
Site Admin
Posts: 186
Joined: Wed Feb 14, 2007 11:17 am

Re: pwm-atmel.c generate BUG: scheduling while atomic

Tue Sep 04, 2018 2:32 pm

Hi,

CONFIG_DEBUG_INFO and maybe CONFIG_DEBUG_BUGVERBOSE are what you are looking for.

Return to “LINUX”

Who is online

Users browsing this forum: No registered users and 2 guests