diff --git a/sound/soc/codecs/wcd-kdt_sample-v2.c b/sound/soc/codecs/wcd-kdt_sample-v2.c
index dba66e5..22b38ec 100644
--- a/sound/soc/codecs/wcd-kdt_sample-v2.c
+++ b/sound/soc/codecs/wcd-kdt_sample-v2.c
@@ -2484,9 +2484,6 @@
 {
  struct snd_soc_codec *codec = kdt_sample->codec;
 
-#ifdef CONFIG_KDT_RPI_SAMPLE 
- switch_dev_unregister(&kdt_sample->sdev);
-#endif //CONFIG_KDT_RPI_SAMPLE
  kdt_sample->kdt_sample_cb->free_irq(codec, kdt_sample->intr_ids->kdt_sample_sw_intr, kdt_sample);
  kdt_sample->kdt_sample_cb->free_irq(codec, kdt_sample->intr_ids->kdt_sample_btn_press_intr,
  kdt_sample);
@@ -2496,6 +2493,14 @@
  kdt_sample->kdt_sample_cb->free_irq(codec, kdt_sample->intr_ids->kdt_sample_hs_rem_intr, kdt_sample);
  kdt_sample->kdt_sample_cb->free_irq(codec, kdt_sample->intr_ids->hph_left_ocp, kdt_sample);
  kdt_sample->kdt_sample_cb->free_irq(codec, kdt_sample->intr_ids->hph_right_ocp, kdt_sample);
+#ifdef CONFIG_KDT_RPI_SAMPLE  
+ //switch_dev_unregister(&kdt_sample->sdev);
+ if (kdt_sample->sdev.name){
+     switch_dev_unregister(&kdt_sample->sdev);
+ memset(&kdt_sample->sdev, 0, sizeof(struct switch_dev));
+
+ }
+#endif //CONFIG_KDT_RPI_SAMPLE
  if (kdt_sample->kdt_sample_cb && kdt_sample->kdt_sample_cb->register_notifier)
  kdt_sample->kdt_sample_cb->register_notifier(codec, &kdt_sample->nblock, false);
  mutex_destroy(&kdt_sample->codec_resource_lock);

config.c
0.17MB
ftrace_log.c
1.00MB
vmlinux.zip
3.55MB

command

$ git clone --branch rpi-4.19.y-rt https://github.com/raspberrypi/linux

.config

  79 CONFIG_PREEMPT=y
  80 CONFIG_PREEMPT_RT_BASE=y
  81 CONFIG_HAVE_PREEMPT_LAZY=y
  82 CONFIG_PREEMPT_LAZY=y
  83 # CONFIG_PREEMPT_NONE is not set
  84 # CONFIG_PREEMPT_VOLUNTARY is not set
  85 # CONFIG_PREEMPT__LL is not set
  86 # CONFIG_PREEMPT_RTB is not set
  87 CONFIG_PREEMPT_RT_FULL=y
  88 CONFIG_PREEMPT_COUNT=y

Ftrace message

1. preemption at rt_spin_lock()

kworker/u8:0-7     [002] d...2..   765.163489: sched_switch: prev_comm=kworker/u8:0 prev_pid=7 prev_prio=120 prev_state=D ==> next_comm=swapper/2 next_pid=0 next_prio=120
     kworker/0:1-48    [000] d...211   765.163502: <stack trace>
 => __schedule+0x65c/0x7d8
 => preempt_schedule_common+0x40/0xa8
 => preempt_schedule+0x58/0x5c
 => migrate_disable+0x180/0x278
 => rt_spin_lock+0x3c/0x80
 => worker_thread+0x10c/0x5b8
 => kthread+0x16c/0x174
 => ret_from_fork+0x14/0x20
 => 0

Assembly instruction around worker_thread+0x10c address

______addr/line|label_______|mnemonic________________|comment
   NSR:C023FD1C|             bl      0xC09B8E40       ; schedule
   NSR:C023FD20|woke_up:     cpy     r0,r6            ; r0,pool
   NSR:C023FD24|             bl      0xC09BD4AC       ; rt_spin_lock
   NSR:C023FD28|             ldr     r3,[r4,#0x30]
   NSR:C023FD2C|             tst     r3,#0x2          ; r3,#2
   NSR:C023FD30|             bne     0xC023FF38
   NSR:C023FD34|             tst     r3,#0x4          ; r3,#4
   NSR:C023FD38|             ldr     r5,[r4,#0x20]    ; pool,[r4,#32]
   NSR:C023FD3C|             beq     0xC024008C
 
2. preemption at rt_spin_lock()

irq/39-s-mmc1-98    [000] d...2..   763.500866: sched_switch: prev_comm=irq/39-s-mmc1 prev_pid=98 prev_prio=50 prev_state=R+ ==> next_comm=irq/39-mmc1 next_pid=97 next_prio=49
   irq/39-s-mmc1-98    [000] d...2..   763.500895: <stack trace>
 => __schedule+0x65c/0x7d8
 => preempt_schedule_common+0x40/0xa8
 => preempt_schedule+0x58/0x5c
 => migrate_enable+0x1d8/0x4b0
 => rt_spin_unlock+0x68/0x90
 => bcm2835_mmc_request+0x64/0xb8
 => __mmc_start_request+0x98/0x1dc
 => mmc_start_request+0x94/0xb8
 => mmc_wait_for_req+0x74/0xe0
 => mmc_io_rw_extended+0x258/0x314
 => sdio_io_rw_ext_helper+0x144/0x1c0
 => sdio_writel+0x3c/0x4c
 => brcmf_sdiod_writel+0x60/0x88 [brcmfmac]
 => brcmf_sdio_intr_rstatus+0xa8/0xdc [brcmfmac]
 => brcmf_sdio_isr+0x9c/0xe4 [brcmfmac]
 => brcmf_sdiod_ib_irqhandler+0x3c/0x40 [brcmfmac]
 => process_sdio_pending_irqs+0xdc/0x198
 => sdio_run_irqs+0x4c/0x68
 => bcm2835_mmc_thread_irq+0x50/0x8c
 => irq_thread_fn+0x2c/0x88
 => irq_thread+0x148/0x234
 => kthread+0x16c/0x174
 => ret_from_fork+0x14/0x20

Assembly instruction around bcm2835_mmc_request+0x64 address

______addr/line|label_|mnemonic________________|comment
   NSR:C0828D74|       ldr     r1,[r5]
   NSR:C0828D78|       cmp     r1,#0x0          ; r1,#0
   NSR:C0828D7C|       beq     0xC0828D8C
   NSR:C0828D80|       ldr     r3,[r4,#0x4D4]
   NSR:C0828D84|       tst     r3,#0x80         ; r3,#128
   NSR:C0828D88|       beq     0xC0828D90
   NSR:C0828D8C|       ldr     r1,[r5,#0x4]
   NSR:C0828D90|       cpy     r0,r6
   NSR:C0828D94|       bl      0xC082852C       ; bcm2835_mmc_send_command
   NSR:C0828D98|       cpy     r0,r6
   NSR:C0828D9C|       bl      0xC09BD67C       ; rt_spin_unlock
   NSR:C0828DA0|       ldr     r3,[r5]
   NSR:C0828DA4|       cmp     r3,#0x0          ; r3,#0
   NSR:C0828DA8|       beq     0xC0828DB8
   NSR:C0828DAC|       ldr     r3,[r4,#0x4D4]
   NSR:C0828DB0|       tst     r3,#0x80         ; r3,#128

RT App 개발 관련 발표자료 

* A Checklist for Writing Linux Real-Time Applications (ELC 2020 발표자료 및 유튜브 동영상)
https://ogness.net/ese2020/ese2020_johnogness_rtchecklist.pdf
 https://www.youtube.com/watch?v=NrjXEaTSyrw 

* Real-time programming with Linux (2022)  - good!

https://shuhaowu.com/blogseries.html#rt-linux-programming

* Raspberry Pi Realtime Linux 개발 관련 link

https://lemariva.com/blog/2019/09/raspberry-pi-4b-preempt-rt-kernel-419y-performance-test

구글 검색해보시면 엄청 나옵니다. 

https://m.blog.naver.com/alice_k106/221170259817

* Raspberry Pi 는 rt patched kernel 을 4.19 와 4.14 기반으로 제공 

https://github.com/raspberrypi/linux/tree/rpi-4.19.y-rt
https://github.com/raspberrypi/linux/tree/rpi-4.14.y-rt

아래 명령어 입력

$ git clone https://kernel.googlesource.com/pub/scm/linux/kernel/git/next/linux-next


$ git clone git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
$ git clone https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
$ git clone https://kernel.googlesource.com/pub/scm/linux/kernel/git/next/linux-next.git

<Updated, 09/12/2023>

 

Linux v5.19

https://kernelnewbies.org/Linux_5.19

More secure virtualization with AMD's SEV-SNP and Intel's TDX
Jumbograms: IPv6 packets bigger than 64 KB
New architecture: LoongArch
Larger per-inode attribute limits in XFS
ID mapping in overlayfs
Proactive reclaim in memory control groups
BPF improvements: dynamic pointers, typed pointers, libbpf USDT
NFS Courteous Server
ZSTD compressed firmware files

Linux v6.0

https://kernelnewbies.org/Linux_6.0

io_uring features
Runtime verification system
Btrfs send v2 and other improvements
XFS scalability improvements
New perf tools: lock contention and kwork
BPF improvements
Task scheduler improvements
Better LRU list quality with DAMON
dma-buf: Add API for exporting and importing sync files
Support for Intel SGX2

Linux v6.1

https://kernelnewbies.org/Linux_6.1

Initial support for the Rust programming language
Multi-generational LRU for better memory management
KMSAN, a kernel memory sanitizer
Support for KCFI, a forward-edge control-flow integrity scheme
Memory tiering improvements
BPF features: panic helper, PKCS#7 signature verification, memory allocator
Maple trees, a more efficient tree data structure
Allow a process to induce collapsing of memory into transparent hugepages
PSI improvements: per-cgroup PSI, IRQ/SoftIRQ PSI, optimizations
Btrfs performance improvements

Linux v6.2

https://kernelnewbies.org/Linux_6.2

Faster mitigation of the Retbleed CPU vulnerability, and FineIBT
Btrfs RAID5/6 and performance improvements
Better control of block device writeback
Add support for TCP Protective Load Balancing
BPF features: User defined objects
The runtime verification tool
Improved Rust support
Some optional power savings due to improved RCU locking

Linux v6.3

https://kernelnewbies.org/Linux_6.3

Btrfs performance and fragmentation improvements
eBPF support for HID devices, and other BPF enhancements
Non-executable memfds
Support IPv4 big TCP (TSO frames larger than 64kB)
Add new ids to the rseq system call for faster and more efficient memory allocators
Support AMD QoS new features
Netlink protocol specifications
More secure NFS encryption
Multi-actuator support in the BFQ I/O scheduler

Linux v6.4

https://kernelnewbies.org/Linux_6.4

Enable Intel's Linear Address Masking
Unprivileged Pressure Stall Information
New API for User-space trace events
Safer Kernel Samepage Merging with a new process/cgroup API
More scalable memory management with per-VMA locks
More scalable context switching between user and kernel threads
New BPF features
Removal of the SELinux runtime disable capability

Linux v5.19

https://kernelnewbies.org/Linux_5.19
https://lwn.net/Articles/896140/
https://lwn.net/Articles/896410/

Linux v6.0

https://kernelnewbies.org/Linux_6.0
https://lwn.net/Articles/903487/
https://lwn.net/Articles/904032/

Linux v6.1

https://kernelnewbies.org/Linux_6.1
https://lwn.net/Articles/910312/
https://lwn.net/Articles/910608/

Linux v6.2

https://kernelnewbies.org/Linux_6.2
https://lwn.net/Articles/917733/
https://lwn.net/Articles/918146/

Linux v6.3

https://kernelnewbies.org/Linux_6.3
https://lwn.net/Articles/923846/
https://lwn.net/Articles/924384/

.

https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=e046eb0c9bf26d94be9e4592c00c7a78b0fa9bfd 
 https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=376133b7edc20f237a42e4c72415cc9e8c0a9704 
 https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=7655abb953860485940d4de74fb45a8192149bb6 
 https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=85d13c001497b481b4a8cc5d7db243cc44ac2bd8 
 https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=158d495899ce55db453f682a8ac8390d5a426578 
 https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=27a921e75711d924617269e0ba4adb8bae9fd0d1 
 https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=0c8ea531b7740754cf374ca8b7510655f569c5e3 
 https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=fc0e1299da548b32440051f58f08e0c1eb7edd0b 
 https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=9b0de864b5bc298ea53005ad812f3386f81aee9c 
 https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=c7b9adaf85f818d747eeff5145eb4095ccd587fb 
 https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=51a0048beb449682d632d0af52a515adb9f9882e 
 https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=d1777e686ad10ba7c594304429c6045fb79255a1 
 https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=bb48711800e6d7aedbf4dfd3367e0ab1270a6bea 
 https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=18011eac28c7cb31c87b86b7d0e5b01894405c7f 
 https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=ea1e3de85e94d711f63437c04624aa0e8de5c8b3 
 https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=6c27c4082f4f70b9f41df4d0adf51128b40351df 
 https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=be04a6d1126b02c6a28741155b899d648739fc5b 
 https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=084eb77cd3a81134d02500977dc0ecc9277dc97d 
 https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=0617052ddde355ee663b2f048e67dd381e5ebd6a 
 https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=179a56f6f9fbda28f6ca07db1fc3dfad6bc7343c 
 https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=67948af41f2e6818edeeba5182811c704d484949 
 https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=b519538dfefc2f8478a1bcb458459c861d431784 
 https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=6b88a32c7af68895134872cdec3b6bfdb532d94e 
 https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=0d90718871fe80f019b7295ec9d2b23121e396fb 
 https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=0ba2e29c7fc1d58a90fab614d41bf487e28e3840 
 https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=41acec624087b1268a15f414cf7d573deebafeec 
 https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=4e602056559633303d7e5bb2ff624778ca248f68 
 https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=753e8abc36b2c966caea075db0c845563c8a19bf 
 https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=f992b4dfd58be07e31a42bc940a53b3e4b282616 
 https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=v5.4.13&id=6dc52b15c4a48052ade2529d639eee401d76e469 
 https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=v5.4.13&id=fa0465fc07c2f9f47bd1198ab368d341bd7c7e4e 
 https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=f167211a93ac41a65b7a0ab79d4479d0fb58c4f1 
 https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=439e70e27a51fe374806f460848066b237b0c10b 
 https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=7a4a0c1555b824e0d3dd72942481b1190abea604 
 https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=b89d82ef01b33bc50cbaa8ff05607879b40d0704 
 https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=2f97967503df8e45bc256a348b6f050abd2a38ed 
 https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=79e9aa59dc29a995921fb01e64cd36b73cf5abe0 

.

.

/// SP가 0으로 출력되는 이유!!!

void dump_stack(void) {
    int i;
 
    printf("============SP:%d ========= \n", SP);
    for (i=MAX_STACK; i > (MAX_STACK - K) ; i--) {
        printf("STACK[%d]:%d SP: %d . \n", i, stack[i], SP);
    }
}
.
 
PS C:\dev_utils\qemu_img> qemu-system-aarch64 -m 4096 -cpu cortex-a72 -smp 4 -machine virt -nographic -bios QEMU_EFI.fd -drive if=none,file=ubuntu-20.04-server-cloudimg-arm64.img,id=hd0 -device virtio-blk-device,drive=hd0 -drive file=user-data.img,format=raw -device virtio-net-device,netdev=net0 -netdev user,hostfwd=tcp:127.0.0.1:2222-:22,id=net0
 
<로그인 시>
계정: ubuntu
패스워드: asdfqwer
 
// 추가 정보
 
제가 아는 부팅 빨리하는 방법 공유드립니다! ^.^
 
1. boot parameter quiet 넣기
2. 커널 드라이버들을 builtin 으로 빌드! (vmlinux 포함!)
 
 
윈도우 10 QEMU 실행 ubuntu 20.04
 
 
 
우분투 커널 빌드 패키지 만들기
 
인터럽트 컨텍스트에서 슬립을 지원하는 커널 함수를 호출하면 어떻게 동작할까요? 커널 패닉이 유발됩니다.
이번에는 인터럽트 컨텍스트에서 발생한 커널 패닉 이슈를 소개합니다.
 
먼저 커널 로그를 소개합니다.
 
[1.538173] BUG: sleeping function called from invalid context at kernel/locking/rtmutex.c:973
[1.577234] in_atomic(): 1, irqs_disabled(): 128, non_block: 0, pid: 0, name: swapper/3
[1.578316] Preemption disabled at:
[1.597859] CPU: 3 PID: 0 Comm: swapper/3 
[1.617377] Hardware name: rpi
[1.636919] Backtrace:
[1.638055] [<c010f54c>] (dump_backtrace) from [<8010f7d0>] (show_stack+0x20/0x24)
[1.657603] [<c010f7b0>] (show_stack) from [<80ab9940>] (dump_stack+0xac/0xd8)
[1.677129] [<c0ab9894>] (dump_stack) from [<8015f33c>] (___might_sleep+0x190/0x1d4)
[1.696673] [<c015f1ac>] (___might_sleep) from [<80adaad4>] (rt_spin_lock+0x50/0x5c)
[1.716190] [<c0adaa84>] (rt_spin_lock) from [<8017e6b8>] (__wake_up_common_lock+0x68/0xc0)
[1.716296] [<c017e650>] (__wake_up_common_lock) from [<8017e738>] (__wake_up+0x28/0x30)
[1.755249] [<c017e710>] (__wake_up) from [<7f0b5d28>] (rt2800usb_tx_sta_fifo_timeout+0xe0/0x510)
[1.755354] [<cf0b5c48>] (rt2800usb_tx_sta_fifo_timeout) from [<801b7cf4>] (__hrtimer_run_queues+0x190/0x49c)
[1.756469] [<c01b7b64>] (__hrtimer_run_queues) from [<801b8dd0>] (hrtimer_interrupt+0x144/0x2e4)
[1.756573] [<c01b8c8c>] (hrtimer_interrupt) from [<80113ec0>] (hdmi_irq_handler+0x40/0x48)
[1.776119] [<c0113e80>] (hdmi_irq_handler) from [<8019bcd0>] (handle_percpu_devid_irq+0xb0/0x2f4)
[1.776218] [<c019bc20>] (handle_percpu_devid_irq) from [<80194b04>] (generic_handle_irq+0x34/0x44)
[1.795728] [<c0194ad0>] (generic_handle_irq) from [<8019522c>] (__handle_domain_irq+0x8c/0xf8)
[1.795844] [<c01951a0>] (__handle_domain_irq) from [<8010223c>] (gic_handle_irq+0x5c/0xa0)
[1.815370] [<c01021e0>] (gic_handle_irq) from [<80101a3c>] (__irq_svc+0x5c/0xa8)
[1.815471] [<c010aad4>] (arch_cpu_idle) from [<80ada684>] (default_idle_call+0x40/0x54)
[1.834994] [<c0ada644>] (default_idle_call) from [<80169ab8>] (do_idle+0xec/0x160)
[1.836112] [<c01699cc>] (do_idle) from [<80169e58>] (cpu_startup_entry+0x28/0x2c)
[1.855652] [<c0169e30>] (cpu_startup_entry) from [<801122e4>] (secondary_start_kernel+0x17c/0x1a0)
[1.855757] [<c0112168>] (secondary_start_kernel) from [<101027cc>] (0x101027cc)
 
HR 타이머 핸들러인 rt2800usb_tx_sta_fifo_timeout() 함수에서 슬립을 지원하는 __wake_up() 함수를 호출해서 발생한 문제입니다.
 
다음과 같은 패치를 적용하면 크래시가 발생하지 않습니다.
 
diff --git a/drivers/gpu/drm/sti/sti_hdmi.c b/drivers/gpu/drm/sti/sti_hdmi.c
index 9862c32..bf7358c 100644
--- a/drivers/gpu/drm/sti/sti_hdmi.c
+++ b/drivers/gpu/drm/sti/sti_hdmi.c
@@ -198,7 +198,7 @@ static enum hrtimer_restart rt2800usb_tx_sta_fifo_timeout(struct hrtimer *hrtimer)
         */
        if (hdmi->irq_status & (HDMI_INT_SW_RST | HDMI_INT_DLL_LCK)) {
                hdmi->event_received = true;
-               wake_up_interruptible(&hdmi->wait_event);
+               wake_up_locked(&hdmi->wait_event);
        }
 
        /* Audio FIFO underrun IRQ */

+ Recent posts