Shutdown strategy Topic is solved

Having issues with your DietPi installation, or, found a bug? Post it here.
Post Reply
devnull

Shutdown strategy

Post by devnull »

Hi,

following problem: I have a kernel module (keypad) which provides a character device for a daemon. When shutting down or rebooting the kernel module is removed very early (see "[ 251.241451] keypad: Exit completed!" below) before the daemon is stopped ("[ OK ] Stopped LSB: glue init."). This leads in most cases to a kernel oops because the daemon tries to access a no longer existent interface:

Code: Select all

[  OK  ] Removed slice system-ifup.slice.
[  OK  ] Stopped target Sound Card.
[  OK  ] Removed slice system-systemd\x2dfsck.slice.
         Stopping User Manager for UID 0...
         Stopping Regular background program processing daemon...
[  OK  ] Stopped target Graphical Interface.
[  OK  ] Stopped target Multi-User System.
         Stopping OpenBSD Secure Shell server...
         Stopping D-Bus System Message Bus...
[  OK  ] Stopped target Login Prompts.
         Stopping Getty on tty1...
         Stopping Serial Ge         Stopping LSB: Set sysfs variables from /etc/sysfs.conf...
         Stopping LSB: Armbian gathering hardware information...
         Stopping LSB: Autogenerate and use a swap file...
         Stopping LSB: glue init...
         Starting Store Sound Card State...
[  251.229911] keypad: Exit...
[  251.241451] keypad: Exit completed!
[  OK  ] Deactivated swap /var/swap.
[  OK  ] Stopped OpenBSD Secure Shell server.
[  OK  ] Stopped D-Bus System Message Bus.
[  OK  ] Stopped Getty on tty1.
[  OK  ] Stopped Serial Getty on ttyS0.
[  OK  ] Stopped Regular background program processing daemon.
[  OK  ] Stopped LSB: Set sysfs variables from /etc/sysfs.conf.
[  OK  ] Stopped User Manager for UID 0.
[  OK  ] Stopped LSB: Armbian gathering hardware information.
[  OK  ] Stopped LSB: Autogenerate and use a swap file.
[  OK  ] Stopped LSB: glue init.
[  OK  ] Started Store Sound Card State.
         Stopping LSB: Yet another telephony engine...
[  OK  ] Removed slice user-0.slice.
         Stopping Login Service...
[  OK  ] Removed slice system-serial\x2dgetty.slice.
[  OK  ] Removed slice system-getty.slice.
         Stopping /etc/rc.local Compatibility...
[  253.298299] sunxi oops: enable sdcard JTAG interface
[  253.300989] sunxi oops: cpu frequency: 408 MHz
[  253.300989] sunxi oops: ddr frequency: 408 MHz
[  253.300989] sunxi oops: gpu frequency: 105 MHz
[  253.300989] sunxi oops: cpu temperature: 31 
[  253.300989] Internal error: Oops: 7 [#1] PREEMPT SMP ARM
[  253.300989] Modules linked in: [last unloaded: g_serial]
[  253.300989] CPU: 3    Tainted: G           O  (3.4.113-sun8i #10)
[  253.300989] PC is at filp_close+0x40/0x8c
[  253.300989] LR is at sys_close+0xbc/0xf4
[  253.300989] pc : [<c011d318>]    lr : [<c011d420>]    psr: a0010013
[  253.300989] sp : d48f1f68  ip : d48f1f88  fp : d48f1f84
[  253.300989] r10: 00000000  r9 : d48f0000  r8 : c000e1c8
[  253.300989] r7 : d4a92440  r6 : d48756c0  r5 : d4a92440  r4 : bf01d6c0
[  253.300989] r3 : 00000000  r2 : 00000000  r1 : d48756c0  r0 : d4a92440
[  253.300989] Flags: NzCv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment user
[  253.300989] Control: 10c5387d  Table: 54c1806a  DAC: 00000015
[  253.300989] 
[  253.300989] PC: 0xc011d298:
[  253.300989] d298  e3520000 1a000007 e3130901 0a000005 e5903020 e5933018 e5933000 e3530000
[  253.300989] d2b8  03e00013 0a000002 e58de000 e24b3024 eb003f55 e24bd014 e89da830 c07a8fcc
[  253.300989] d2d8  e1a0c00d e92dd8f0 e24cb004 e52de004 e8bd4000 e590401c e1a05000 e1a06001
[  253.300989] d2f8  e3540000 1a000002 e59f0058 eb13eac0 ea000012 e5904010 e3540000 0a000004
[  253.300989] d318  e5944030 e3540000 0a000001 e12fff34 e1a04000 e5953024 e3130901 1a000005
[  253.300989] d338  e1a01006 e1a00005 eb00f4b2 e1a01006 e1a00005 eb011b51 e1a00005 eb000b02
[  253.300989] d358  e1a00004 e89da8f0 c07b28a4 e1a0c00d e92dd8f0 e24cb004 e52de004 e8bd4000
[  253.300989] d378  e1a0300d e3c33d7f e1a04000 e3c3303f e593300c e59353ec e2856040 e1a00006
[  253.300989] 
[  253.300989] LR: 0xc011d3a0:
[  253.300989] d3a0  e5923000 e1530004 9a000024 e5923004 e7937104 e3570000 0a000020 f57ff05f
[  253.300989] d3c0  e5923004 e3a01000 e1540001 e3a0c001 e7831104 e284301f e5920008 a1a03004
[  253.300989] d3e0  e1a032c3 e0512004 e202201f e204101f 52621000 e7902103 e1c2211c e1a01004
[  253.300989] d400  e7802103 e1a00005 ebfffdca e1a00006 eb1406ea e1a01005 e1a00007 ebffffad
[  253.300989] d420  e2803c02 e2833001 e3530001 9a000007 e3c03002 e3730f81 03e00003 e89da8f0
[  253.300989] d440  e1a00006 eb1406dd e3e00008 e89da8f0 e3e00003 e89da8f0 e1a0c00d e92dd830
[  253.300989] d460  e24cb004 e52de004 e8bd4000 e5913020 e3130802 1a00000c e5903068 e3130001
[  253.300989] d480  0a000000 eafffffb f57ff05f e1c046d0 f57ff05f e5902068 e1530002 1afffff5
[  253.300989] 
[  253.300989] SP: 0xd48f1ee8:
[  253.300989] 1ee8  d48f1fb0 0000c0ff 000002b8 00008009 d48f1fac d48f1f08 c011d318 a0010013
[  253.300989] 1f08  ffffffff d48f1f54 d48f1f84 d48f1f20 c000dad8 c0008370 d4a92440 d48756c0
[  253.300989] 1f28  00000000 00000000 bf01d6c0 d4a92440 d48756c0 d4a92440 c000e1c8 d48f0000
[  253.300989] 1f48  00000000 d48f1f84 d48f1f88 d48f1f68 c011d420 c011d318 a0010013 ffffffff
[  253.300989] 1f68  00000003 d48756c0 d4875700 d4a92440 d48f1fa4 d48f1f88 c011d420 c011d2e4
[  253.300989] 1f88  00000003 01d30008 01dab538 00000006 00000000 d48f1fa8 c000df60 c011d370
[  253.300989] 1fa8  00000003 01d30008 00000003 00000001 b6f3a868 00000000 00000003 01d30008
[  253.300989] 1fc8  01dab538 00000006 0000c0ff b6f38000 0000000f 01d30008 00000000 beb5a9a4
[  253.300989] 
[  253.300989] IP: 0xd48f1f08:
[  253.300989] 1f08  ffffffff d48f1f54 d48f1f84 d48f1f20 c000dad8 c0008370 d4a92440 d48756c0
[  253.300989] 1f28  00000000 00000000 bf01d6c0 d4a92440 d48756c0 d4a92440 c000e1c8 d48f0000
[  253.300989] 1f48  00000000 d48f1f84 d48f1f88 d48f1f68 c011d420 c011d318 a0010013 ffffffff
[  253.300989] 1f68  00000003 d48756c0 d4875700 d4a92440 d48f1fa4 d48f1f88 c011d420 c011d2e4
[  253.300989] 1f88  00000003 01d30008 01dab538 00000006 00000000 d48f1fa8 c000df60 c011d370
[  253.300989] 1fa8  00000003 01d30008 00000003 00000001 b6f3a868 00000000 00000003 01d30008
[  253.300989] 1fc8  01dab538 00000006 0000c0ff b6f38000 0000000f 01d30008 00000000 beb5a9a4
[  253.300989] 1fe8  b6ee803f b6d6d5f6 60010030 00000003 00000000 00000000 d4a68000 d5802140
[  253.300989] 
[  253.300989] FP: 0xd48f1f04:
[  253.300989] 1f04  a0010013 ffffffff d48f1f54 d48f1f84 d48f1f20 c000dad8 c0008370 d4a92440
[  253.300989] 1f24  d48756c0 00000000 00000000 bf01d6c0 d4a92440 d48756c0 d4a92440 c000e1c8
[  253.300989] 1f44  d48f0000 00000000 d48f1f84 d48f1f88 d48f1f68 c011d420 c011d318 a0010013
[  253.300989] 1f64  ffffffff 00000003 d48756c0 d4875700 d4a92440 d48f1fa4 d48f1f88 c011d420
[  253.300989] 1f84  c011d2e4 00000003 01d30008 01dab538 00000006 00000000 d48f1fa8 c000df60
[  253.300989] 1fa4  c011d370 00000003 01d30008 00000003 00000001 b6f3a868 00000000 00000003
[  253.300989] 1fc4  01d30008 01dab538 00000006 0000c0ff b6f38000 0000000f 01d30008 00000000
[  253.300989] 1fe4  beb5a9a4 b6ee803f b6d6d5f6 60010030 00000003 00000000 00000000 d4a68000
[  253.300989] 
[  253.300989] R0: 0xd4a923c0:
[  253.300989] 23c0  00000000 00000000 00000000 d597b7c0 00000000 00000000 00000000 00000000
[  253.300989] 23e0  00000000 00000000 00000000 00000000 00000000 00000000 00000000 d5550cc0
[  253.300989] 2400  d4a92400 d4a92400 d4a92408 d4a92408 d5550db8 00000000 00000000 00000000
[  253.300989] 2420  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[  253.300989] 2440  00000000 00000000 d5a29790 d31a6bb8 bf01d6c0 00000000 00000000 00000001
[  253.300989] 2460  00020800 0000001d 00000000 00000000 00000000 00000000 00000000 00000000
[  253.300989] 2480  00000000 00000000 00000000 d518dac0 00000000 00000000 00000000 00000000
[  253.300989] 24a0  00000000 00000000 ffffffff ffffffff 00000000 00000000 00000000 00000000
[  253.300989] 
[  253.300989] R1: 0xd4875640:
[  253.300989] 5640  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[  253.300989] 5660  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[  253.300989] 5680  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[  253.300989] 56a0  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[  253.300989] 56c0  00000001 d48756c8 00000020 d4875714 d487570c d4875710 00000000 c01384a0
[  253.300989] 56e0  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[  253.300989] 5700  00000000 00000000 00000003 00000000 00000007 d4a66c80 d4a66c80 d4a66c80
[  253.300989] 5720  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[  253.300989] 
[  253.300989] R5: 0xd4a923c0:
[  253.300989] 23c0  00000000 00000000 00000000 d597b7c0 00000000 00000000 00000000 00000000
[  253.300989] 23e0  00000000 00000000 00000000 00000000 00000000 00000000 00000000 d5550cc0
[  253.300989] 2400  d4a92400 d4a92400 d4a92408 d4a92408 d5550db8 00000000 00000000 00000000
[  253.300989] 2420  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[  253.300989] 2440  00000000 00000000 d5a29790 d31a6bb8 bf01d6c0 00000000 00000000 00000001
[  253.300989] 2460  00020800 0000001d 00000000 00000000 00000000 00000000 00000000 00000000
[  253.300989] 2480  00000000 00000000 00000000 d518dac0 00000000 00000000 00000000 00000000
[  253.300989] 24a0  00000000 00000000 ffffffff ffffffff 00000000 00000000 00000000 00000000
[  253.300989] 
[  253.300989] R6: 0xd4875640:
[  253.300989] 5640  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[  253.300989] 5660  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[  253.300989] 5680  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[  253.300989] 56a0  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[  253.300989] 56c0  00000001 d48756c8 00000020 d4875714 d487570c d4875710 00000000 c01384a0
[  253.300989] 56e0  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[  253.300989] 5700  00000000 00000000 00000003 00000000 00000007 d4a66c80 d4a66c80 d4a66c80
[  253.300989] 5720  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[  253.300989] 
[  253.300989] R7: 0xd4a923c0:
[  253.300989] 23c0  00000000 00000000 00000000 d597b7c0 00000000 00000000 00000000 00000000
[  253.300989] 23e0  00000000 00000000 00000000 00000000 00000000 00000000 00000000 d5550cc0
[  253.300989] 2400  d4a92400 d4a92400 d4a92408 d4a92408 d5550db8 00000000 00000000 00000000
[  253.300989] 2420  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[  253.300989] 2440  00000000 00000000 d5a29790 d31a6bb8 bf01d6c0 00000000 00000000 00000001
[  253.300989] 2460  00020800 0000001d 00000000 00000000 00000000 00000000 00000000 00000000
[  253.300989] 2480  00000000 00000000 00000000 d518dac0 00000000 00000000 00000000 00000000
[  253.300989] 24a0  00000000 00000000 ffffffff ffffffff 00000000 00000000 00000000 00000000           
[  253.300989]                                                                                         
[  253.300989] R8: 0xc000e148:                                                                         
[  253.300989] e148  e3570f5f e24fef7d 3798f107 e28d1008 e3a08000 e357080f e2270000 2a0012e0           
[  253.300989] e168  ea00f49a e24ee004 e58de03c eaffff79 e1a02007 e28d1008 e3a00000 eb000ab3           
[  253.300989] e188  e28fe014 e1a07000 e28d1008 e3570f5f 3891000f 3798f107 eaffffec e5ad0008
[  253.300989] e1a8  e1a02007 e1a0100d e3a00001 eb000aa7 eaffff80 e320f000 c094dd44 c000e87c
[  253.300989] e1c8  c003d38c c002e73c c000e7e0 c011f2dc c011f354 c011e424 c011d364 c004b3d8
[  253.300989] e1e8  c011e46c c012d64c c012d40c c000e7f0 c011dd80 c004b3d8 c012d290 c011e004
[  253.300989] e208  c007c468 c004b3d8 c004b3d8 c011eb4c c00393dc c013c548 c004b3d8 c007c550
[  253.300989] e228  c007c9b8 c004b3d8 c0035a2c c004b3d8 c004b3d8 c003e5c4 c004b3d8 c004b3d8
[  253.300989] 
[  253.300989] R9: 0xd48eff80:
[  253.300989] ff80  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[  253.300989] ffa0  00000000 00000000 00000000 00000000 00000000 00000000 553ee811 553eec11
[  253.300989] ffc0  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[  253.300989] ffe0  00000000 00000000 00000000 00000000 00000000 00000000 55fad821 55fadc21
[  253.300989] 0000  00000000 00000002 00000000 d4d7b180 c094f380 00000003 00000015 c0f76780
[  253.300989] 0020  d4d7b180 d48f0000 d4d7a040 ca338d98 d4f93200 d4b19900 d48f1ec4 d48f1e28
[  253.300989] 0040  c061e084 00000000 00000000 00000000 00000000 00000000 01010000 00000000
[  253.300989] 0060  b6f524c0 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[  253.300989] Process glue.pl (pid: 2009, stack limit = 0xd48f02f8)
[  253.300989] Stack: (0xd48f1f68 to 0xd48f2000)
[  253.300989] 1f60:                   00000003 d48756c0 d4875700 d4a92440 d48f1fa4 d48f1f88
[  253.300989] 1f80: c011d420 c011d2e4 00000003 01d30008 01dab538 00000006 00000000 d48f1fa8
[  253.300989] 1fa0: c000df60 c011d370 00000003 01d30008 00000003 00000001 b6f3a868 00000000
[  253.300989] 1fc0: 00000003 01d30008 01dab538 00000006 0000c0ff b6f38000 0000000f 01d30008
[  253.300989] 1fe0: 00000000 beb5a9a4 b6ee803f b6d6d5f6 60010030 00000003 00000000 00000000
[  253.300989] [<c011d318>] (filp_close+0x40/0x8c) from [<c011d420>] (sys_close+0xbc/0xf4)
[  253.300989] [<c011d420>] (sys_close+0xbc/0xf4) from [<c000df60>] (ret_fast_syscall+0x0/0x30)
[  253.300989] Code: ea000012 e5904010 e3540000 0a000004 (e5944030) 
[  254.439389] ---[ end trace b88f5d6f897e8191 ]---
[  OK  ] Stopped /etc/rc.local Compatibility.
         Stopping DietPi-Boot...
[  OK  ] Stopped DietPi-Boot.
         Stopping DietPi-RAMlog...
         Stopping DietPi-RAMdisk...
[  254.772848] mmcblk0: error -110 sending status command, retrying
[  254.779711] mmcblk0: error -110 sending status command, retrying
[  254.786792] mmcblk0: error -110 sending status command, aborting
[  254.793707] end_request: I/O error, dev mmcblk0, sector 4327424
         Stopping Permit User Se[  254.800565] EXT4-fs error (device mmcblk0p2): ext4_wait_block_bitmap:410: comm rm: Cannot read block bitmap - block_group8
ssions...
[  OK  ] Stopped Login Service.
[  OK  ] Stopped LSB: Yet another telephony engine.
[  OK  ] Stopped Permit User Sessions.
[  OK  ] Stopped target Network is Online.
[  OK  ] Stopped target Network.
         Starting Shutdown all ssh sessions before network...
[  OK  ] Stopped target Remote File Systems.
[  OK  ] Stopped target Remote File Systems (Pre).

Code: Select all

root@DietPi:/etc/rc6.d# ls
K01alsa-utils  K01fake-hwclock  K01hwclock.sh  K01urandom  K02sendsigs      K04networking  K06umountroot  README
K01armhwinfo   K01glue          K01resolvconf  K01yate     K03umountnfs.sh  K05umountfs    K07reboot
Why are the kernel modules unloaded so early, where is this triggered and what can I do against this?

Thanks!
devnull

Re: Shutdown strategy

Post by devnull »

Just for the protocol, solution is to add ".owner = THIS_MODULE," in the file operation struct in the kernel module source code:

Code: Select all

static struct file_operations fops =
{
  .owner = THIS_MODULE,
  .open = dev_open,
  .read = dev_read, /* direction seen from user space, not from kernel */
  .release = dev_release,
};
If this line is present the module reference counter is increased when the module is in use so unloading the module while in use is blocked.
Post Reply