I2C to UART IS16SC762 "BUG: Scheduling while atomic" error on i.MX6SL

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

I2C to UART IS16SC762 "BUG: Scheduling while atomic" error on i.MX6SL

1,802 Views
jacobpostman
Contributor II

Hello,

I am attempting to bring up a SC16IS762 (I2C to dual UART/RS232/RS485 interface) on an i.MX6SL based custom board and am looking for some guidance.

Two tty devices appear as expected (/dev/ttySC0 and ttySC1).

However, when I attempt to interact with either device via console I receive the message "BUG: scheduling while atomic" and stack dump(s) as shown below.

As seen in the stack dump below, a call to schedule() in i2c_imx_bus_busy() (drivers/i2c/busses/i2c-imx.c) seems to trigger the error, but I have not yet been able to determine how the interaction between sc16is7xx and i2c-imx drivers are misbehaving.

What I have done:

1. Pulled in a driver for the sc16is7xx, added the device to drivers/tty/serial/Kconfig and drivers/tty/serial/Makefile

Driver pulled from 3.16: http://lxr.free-electrons.com/source/drivers/tty/serial/sc16is7xx.c?v=3.16

2. Observe the same behavior on both imx_3.10.17_1.0.1_ga and imx_3.14.28_1.0.0_ga kernels.

3. SC16IS762 is connected to I2C3 and uses GPIO2_12 as an active low interrupt request.

4. I've added the following pad and device configuration to the board device tree:

i2c3 {

  pinctrl_i2c3_1: i2c3grp-1 {

  fsl,pins = <

  MX6SL_PAD_EPDC_SDCE2__I2C3_SCL 0x4001b8b1

  MX6SL_PAD_EPDC_SDCE3__I2C3_SDA 0x4001b8b1

  MX6SL_PAD_EPDC_PWRINT__GPIO2_IO12 0x1F059

  >;

  };

  };

&i2c3 {

  clock-frequency = <400000>;

  pinctrl-names = "default";

  pinctrl-0 = <&pinctrl_i2c3_1>;

  status = "okay";

  sc16is762: sc16is762@48 {

    compatible = "nxp,sc16is762";

                reg = <0x48>;

  clocks = <&clks IMX6SL_CLK_I2C3>;

                interrupt-parent = <&gpio2>;

                interrupts = <12 IRQ_TYPE_EDGE_FALLING>;

                gpio-controller;

                #gpio-cells = <2>;

        };

};

5. When interacting with ttySC0/1 via console, I receive the following BUG message and stack dump

# echo "text" > /dev/ttySC1

BUG: scheduling while atomic: sh/457/0x00000002

Modules linked in:

CPU: 0 PID: 457 Comm: sh Not tainted 3.14.28-04038-g1d8abdf-dirty #5

[<80014818>] (unwind_backtrace) from [<80011524>] (show_stack+0x10/0x14)

[<80011524>] (show_stack) from [<806bbb94>] (dump_stack+0x64/0xb4)

[<806bbb94>] (dump_stack) from [<806b9ab8>] (__schedule_bug+0x44/0x5c)

[<806b9ab8>] (__schedule_bug) from [<806be6cc>] (__schedule+0x48c/0x530)

[<806be6cc>] (__schedule) from [<8042ad14>] (i2c_imx_bus_busy+0x3c/0x88)

[<8042ad14>] (i2c_imx_bus_busy) from [<8042b024>] (i2c_imx_xfer+0x234/0x6d4)

[<8042b024>] (i2c_imx_xfer) from [<80426b98>] (__i2c_transfer+0x44/0x7c)

[<80426b98>] (__i2c_transfer) from [<80427f38>] (i2c_transfer+0x7c/0xb8)

[<80427f38>] (i2c_transfer) from [<80428000>] (i2c_master_send+0x3c/0x4c)

[<80428000>] (i2c_master_send) from [<80340d98>] (regmap_i2c_write+0x10/0x2c)

[<80340d98>] (regmap_i2c_write) from [<8033dcc8>] (_regmap_raw_write+0x5b8/0x5e4)

[<8033dcc8>] (_regmap_raw_write) from [<8033cdd0>] (_regmap_write+0x58/0x94)

[<8033cdd0>] (_regmap_write) from [<8033cfa8>] (_regmap_update_bits+0x54/0x64)

[<8033cfa8>] (_regmap_update_bits) from [<8033d12c>] (regmap_update_bits+0x40/0x5c)

[<8033d12c>] (regmap_update_bits) from [<80304704>] (uart_close+0x174/0x190)

[<80304704>] (uart_close) from [<802eaf4c>] (tty_release+0xf4/0x4b4)

[<802eaf4c>] (tty_release) from [<800d07e0>] (__fput+0x80/0x1e8)

[<800d07e0>] (__fput) from [<80043090>] (task_work_run+0xa4/0xd8)

[<80043090>] (task_work_run) from [<80011164>] (do_work_pending+0xa0/0xac)

[<80011164>] (do_work_pending) from [<8000e3e0>] (work_pending+0xc/0x20)

BUG: scheduling while atomic: sh/457/0x00000002

Modules linked in:

CPU: 0 PID: 457 Comm: sh Tainted: G        W    3.14.28-04038-g1d8abdf-dirty #5

[<80014818>] (unwind_backtrace) from [<80011524>] (show_stack+0x10/0x14)

[<80011524>] (show_stack) from [<806bbb94>] (dump_stack+0x64/0xb4)

[<806bbb94>] (dump_stack) from [<806b9ab8>] (__schedule_bug+0x44/0x5c)

[<806b9ab8>] (__schedule_bug) from [<806be6cc>] (__schedule+0x48c/0x530)

[<806be6cc>] (__schedule) from [<8042ad14>] (i2c_imx_bus_busy+0x3c/0x88)

[<8042ad14>] (i2c_imx_bus_busy) from [<8042b024>] (i2c_imx_xfer+0x234/0x6d4)

[<8042b024>] (i2c_imx_xfer) from [<80426b98>] (__i2c_transfer+0x44/0x7c)

[<80426b98>] (__i2c_transfer) from [<80427f38>] (i2c_transfer+0x7c/0xb8)

[<80427f38>] (i2c_transfer) from [<80428000>] (i2c_master_send+0x3c/0x4c)

[<80428000>] (i2c_master_send) from [<80340d98>] (regmap_i2c_write+0x10/0x2c)

[<80340d98>] (regmap_i2c_write) from [<8033dcc8>] (_regmap_raw_write+0x5b8/0x5e4)

[<8033dcc8>] (_regmap_raw_write) from [<8033cdd0>] (_regmap_write+0x58/0x94)

[<8033cdd0>] (_regmap_write) from [<8033cfa8>] (_regmap_update_bits+0x54/0x64)

[<8033cfa8>] (_regmap_update_bits) from [<8033d12c>] (regmap_update_bits+0x40/0x5c)

[<8033d12c>] (regmap_update_bits) from [<80304704>] (uart_close+0x174/0x190)

[<80304704>] (uart_close) from [<802eaf4c>] (tty_release+0xf4/0x4b4)

[<802eaf4c>] (tty_release) from [<800d07e0>] (__fput+0x80/0x1e8)

[<800d07e0>] (__fput) from [<80043090>] (task_work_run+0xa4/0xd8)

[<80043090>] (task_work_run) from [<80011164>] (do_work_pending+0xa0/0xac)

[<80011164>] (do_work_pending) from [<8000e3e0>] (work_pending+0xc/0x20)

BUG: scheduling while atomic: sh/457/0x00000002

Modules linked in:

CPU: 0 PID: 457 Comm: sh Tainted: G        W    3.14.28-04038-g1d8abdf-dirty #5

[<80014818>] (unwind_backtrace) from [<80011524>] (show_stack+0x10/0x14)

[<80011524>] (show_stack) from [<806bbb94>] (dump_stack+0x64/0xb4)

[<806bbb94>] (dump_stack) from [<806b9ab8>] (__schedule_bug+0x44/0x5c)

[<806b9ab8>] (__schedule_bug) from [<806be6cc>] (__schedule+0x48c/0x530)

[<806be6cc>] (__schedule) from [<806bdd50>] (schedule_timeout+0x110/0x188)

[<806bdd50>] (schedule_timeout) from [<8042ade8>] (i2c_imx_trx_complete+0x88/0x90)

[<8042ade8>] (i2c_imx_trx_complete) from [<8042b324>] (i2c_imx_xfer+0x534/0x6d4)

[<8042b324>] (i2c_imx_xfer) from [<80426b98>] (__i2c_transfer+0x44/0x7c)

[<80426b98>] (__i2c_transfer) from [<80427f38>] (i2c_transfer+0x7c/0xb8)

[<80427f38>] (i2c_transfer) from [<80428000>] (i2c_master_send+0x3c/0x4c)

[<80428000>] (i2c_master_send) from [<80340d98>] (regmap_i2c_write+0x10/0x2c)

[<80340d98>] (regmap_i2c_write) from [<8033dcc8>] (_regmap_raw_write+0x5b8/0x5e4)

[<8033dcc8>] (_regmap_raw_write) from [<8033cdd0>] (_regmap_write+0x58/0x94)

[<8033cdd0>] (_regmap_write) from [<8033cfa8>] (_regmap_update_bits+0x54/0x64)

[<8033cfa8>] (_regmap_update_bits) from [<8033d12c>] (regmap_update_bits+0x40/0x5c)

[<8033d12c>] (regmap_update_bits) from [<80304704>] (uart_close+0x174/0x190)

[<80304704>] (uart_close) from [<802eaf4c>] (tty_release+0xf4/0x4b4)

[<802eaf4c>] (tty_release) from [<800d07e0>] (__fput+0x80/0x1e8)

[<800d07e0>] (__fput) from [<80043090>] (task_work_run+0xa4/0xd8)

[<80043090>] (task_work_run) from [<80011164>] (do_work_pending+0xa0/0xac)

[<80011164>] (do_work_pending) from [<8000e3e0>] (work_pending+0xc/0x20)

BUG: scheduling while atomic: sh/457/0x00000002

Modules linked in:

CPU: 0 PID: 457 Comm: sh Tainted: G        W    3.14.28-04038-g1d8abdf-dirty #5

[<80014818>] (unwind_backtrace) from [<80011524>] (show_stack+0x10/0x14)

[<80011524>] (show_stack) from [<806bbb94>] (dump_stack+0x64/0xb4)

[<806bbb94>] (dump_stack) from [<806b9ab8>] (__schedule_bug+0x44/0x5c)

[<806b9ab8>] (__schedule_bug) from [<806be6cc>] (__schedule+0x48c/0x530)

[<806be6cc>] (__schedule) from [<806bdd50>] (schedule_timeout+0x110/0x188)

[<806bdd50>] (schedule_timeout) from [<8042ade8>] (i2c_imx_trx_complete+0x88/0x90)

[<8042ade8>] (i2c_imx_trx_complete) from [<8042b398>] (i2c_imx_xfer+0x5a8/0x6d4)

[<8042b398>] (i2c_imx_xfer) from [<80426b98>] (__i2c_transfer+0x44/0x7c)

[<80426b98>] (__i2c_transfer) from [<80427f38>] (i2c_transfer+0x7c/0xb8)

[<80427f38>] (i2c_transfer) from [<80428000>] (i2c_master_send+0x3c/0x4c)

[<80428000>] (i2c_master_send) from [<80340d98>] (regmap_i2c_write+0x10/0x2c)

[<80340d98>] (regmap_i2c_write) from [<8033dcc8>] (_regmap_raw_write+0x5b8/0x5e4)

[<8033dcc8>] (_regmap_raw_write) from [<8033cdd0>] (_regmap_write+0x58/0x94)

[<8033cdd0>] (_regmap_write) from [<8033cfa8>] (_regmap_update_bits+0x54/0x64)

[<8033cfa8>] (_regmap_update_bits) from [<8033d12c>] (regmap_update_bits+0x40/0x5c)

[<8033d12c>] (regmap_update_bits) from [<80304704>] (uart_close+0x174/0x190)

[<80304704>] (uart_close) from [<802eaf4c>] (tty_release+0xf4/0x4b4)

[<802eaf4c>] (tty_release) from [<800d07e0>] (__fput+0x80/0x1e8)

[<800d07e0>] (__fput) from [<80043090>] (task_work_run+0xa4/0xd8)

[<80043090>] (task_work_run) from [<80011164>] (do_work_pending+0xa0/0xac)

[<80011164>] (do_work_pending) from [<8000e3e0>] (work_pending+0xc/0x20)

BUG: scheduling while atomic: sh/457/0x00000002

Modules linked in:

CPU: 0 PID: 457 Comm: sh Tainted: G        W    3.14.28-04038-g1d8abdf-dirty #5

[<80014818>] (unwind_backtrace) from [<80011524>] (show_stack+0x10/0x14)

[<80011524>] (show_stack) from [<806bbb94>] (dump_stack+0x64/0xb4)

[<806bbb94>] (dump_stack) from [<806b9ab8>] (__schedule_bug+0x44/0x5c)

[<806b9ab8>] (__schedule_bug) from [<806be6cc>] (__schedule+0x48c/0x530)

[<806be6cc>] (__schedule) from [<806bdd50>] (schedule_timeout+0x110/0x188)

[<806bdd50>] (schedule_timeout) from [<8042ade8>] (i2c_imx_trx_complete+0x88/0x90)

[<8042ade8>] (i2c_imx_trx_complete) from [<8042b398>] (i2c_imx_xfer+0x5a8/0x6d4)

[<8042b398>] (i2c_imx_xfer) from [<80426b98>] (__i2c_transfer+0x44/0x7c)

[<80426b98>] (__i2c_transfer) from [<80427f38>] (i2c_transfer+0x7c/0xb8)

[<80427f38>] (i2c_transfer) from [<80428000>] (i2c_master_send+0x3c/0x4c)

[<80428000>] (i2c_master_send) from [<80340d98>] (regmap_i2c_write+0x10/0x2c)

[<80340d98>] (regmap_i2c_write) from [<8033dcc8>] (_regmap_raw_write+0x5b8/0x5e4)

[<8033dcc8>] (_regmap_raw_write) from [<8033cdd0>] (_regmap_write+0x58/0x94)

[<8033cdd0>] (_regmap_write) from [<8033cfa8>] (_regmap_update_bits+0x54/0x64)

[<8033cfa8>] (_regmap_update_bits) from [<8033d12c>] (regmap_update_bits+0x40/0x5c)

[<8033d12c>] (regmap_update_bits) from [<80304704>] (uart_close+0x174/0x190)

[<80304704>] (uart_close) from [<802eaf4c>] (tty_release+0xf4/0x4b4)

[<802eaf4c>] (tty_release) from [<800d07e0>] (__fput+0x80/0x1e8)

[<800d07e0>] (__fput) from [<80043090>] (task_work_run+0xa4/0xd8)

[<80043090>] (task_work_run) from [<80011164>] (do_work_pending+0xa0/0xac)

[<80011164>] (do_work_pending) from [<8000e3e0>] (work_pending+0xc/0x20)

BUG: scheduling while atomic: sh/457/0x00000002

Modules linked in:

CPU: 0 PID: 457 Comm: sh Tainted: G        W    3.14.28-04038-g1d8abdf-dirty #5

[<80014818>] (unwind_backtrace) from [<80011524>] (show_stack+0x10/0x14)

[<80011524>] (show_stack) from [<806bbb94>] (dump_stack+0x64/0xb4)

[<806bbb94>] (dump_stack) from [<806b9ab8>] (__schedule_bug+0x44/0x5c)

[<806b9ab8>] (__schedule_bug) from [<806be6cc>] (__schedule+0x48c/0x530)

[<806be6cc>] (__schedule) from [<8042ad14>] (i2c_imx_bus_busy+0x3c/0x88)

[<8042ad14>] (i2c_imx_bus_busy) from [<8042b4a0>] (i2c_imx_xfer+0x6b0/0x6d4)

[<8042b4a0>] (i2c_imx_xfer) from [<80426b98>] (__i2c_transfer+0x44/0x7c)

[<80426b98>] (__i2c_transfer) from [<80427f38>] (i2c_transfer+0x7c/0xb8)

[<80427f38>] (i2c_transfer) from [<80428000>] (i2c_master_send+0x3c/0x4c)

[<80428000>] (i2c_master_send) from [<80340d98>] (regmap_i2c_write+0x10/0x2c)

[<80340d98>] (regmap_i2c_write) from [<8033dcc8>] (_regmap_raw_write+0x5b8/0x5e4

[<8033dcc8>] (_regmap_raw_write) from [<8033cdd0>] (_regmap_write+0x58/0x94)

[<8033cdd0>] (_regmap_write) from [<8033cfa8>] (_regmap_update_bits+0x54/0x64)

[<8033cfa8>] (_regmap_update_bits) from [<8033d12c>] (regmap_update_bits+0x40/0x

[<8033d12c>] (regmap_update_bits) from [<80304704>] (uart_close+0x174/0x190)

[<80304704>] (uart_close) from [<802eaf4c>] (tty_release+0xf4/0x4b4)

[<802eaf4c>] (tty_release) from [<800d07e0>] (__fput+0x80/0x1e8)

[<800d07e0>] (__fput) from [<80043090>] (task_work_run+0xa4/0xd8)

[<80043090>] (task_work_run) from [<80011164>] (do_work_pending+0xa0/0xac)

[<80011164>] (do_work_pending) from [<8000e3e0>] (work_pending+0xc/0x20)

Any thoughts or suggestions are appreciated.

Labels (3)
Tags (3)
0 Kudos
4 Replies

956 Views
alejandrolozan1
NXP Employee
NXP Employee

Hi,

Just like Fabio mentioned, it seems that the clock refers to the XTAL signal needed by the IC.

/Alejandro

0 Kudos

956 Views
fabio_estevam
NXP Employee
NXP Employee

Hi Jacob,

I suspect that the clocks line is not correct.

From what I see this is the clock for the sc16is762, not the internal I2C3 clock for mx6sl.

If your design does not provide a software controlled clock, then you can simply add a dummy clock and pass it like:

  sc16is762: sc16is762@48 { 

    compatible = "nxp,sc16is762"; 

                reg = <0x48>; 

     clocks = <&clks IMX6SL_CLK_DUMMY>; 

                interrupt-parent = <&gpio2>; 

                interrupts = <12 IRQ_TYPE_EDGE_FALLING>; 

                gpio-controller; 

                #gpio-cells = <2>; 

        };

Regards,

Fabio Estevam

0 Kudos

956 Views
jacobpostman
Contributor II

Hi Fabio,

Thank you and Alejandro for catching that. Unfortunately something else still appears to be at fault.

Upon closer inspection the driver does not already directly support using an external crystal.

In our case though, the SC16IS762 on this particular board uses a dedicated 24MHz crystal

Incidentally, by incorrectly using IMX6SL_CLK_I2C3 the "correct" value of 24000000 (24M) was being passed in to (struct uart_port)->uartclk resulting in correct baud rate divisor values.  For the moment, I've modified the driver to statically set uartclk to 24M, and have removed entirely the clocks assignment from the device tree.

1. In both cases, the prescalar and divisor values that are written to the IC are the expected values (prescaler = 0, divisor = 156 for 9600 baud).

2. Additionally, writing to the uart via console (echo "a" > /dev/ttySC0) produces correct 9600 baud output from the SC16IS762 when probed with oscilloscope. Bug messages are still triggered and it is not clear yet if communication longer than a few bytes over the port continues to work.

Looking at the stack dump, the bug messages are being generated in imx-i2c. My thought was to look for an inappropriate sleep/scheduling interaction between the threaded irq and work queue in the sc16is driver and the non-threaded irq in imx-i2c, but this is where I am getting hung up.

0 Kudos

956 Views
fabio_estevam
NXP Employee
NXP Employee

Hi Jacob,

You can try to pass: clocks = <&clk_24M>;

where:

clocks {

  clk_24M: osc_clock {

  compatible = "fixed-clock";

  reg=<0>;

  #clock-cells = <0>;

  clock-frequency = <24000000>;

  };

};

Regards.

Fabio Estevam

0 Kudos