Build kernel error when use RT patch

Using VIM3 to control the robot, I need to patch preempt-rt in kernel, from the web:Index of /pub/linux/kernel/projects/rt/4.9/older/
downloaded the corresponding 4.9.241 patch
After patching, build kernel via fenix(make kernel).
It comes out like that:

error: field ‘destroy_swork’ has incomplete type
  struct swork_event destroy_swork;

I had tried two versions of the patch (4.9.268 and 4.9.268), both of them have the same problem

How to fix this problem? Is it just the version not correct?

full outputs:

Info: Build linux...
make[1]: Entering directory '/home/dylan/Desktop/fenix/build/linux'
drivers/net/wireless/bcmdhd/Kconfig:53:warning: defaults for choice values not supported
#
# configuration written to .config
#
make[1]: Leaving directory '/home/dylan/Desktop/fenix/build/linux'
make[1]: Entering directory '/home/dylan/Desktop/fenix/build/linux'
scripts/kconfig/conf  --silentoldconfig Kconfig
drivers/net/wireless/bcmdhd/Kconfig:53:warning: defaults for choice values not supported
  CHK     include/config/kernel.release
  CHK     include/config/kernel.release_full
  UPD     include/config/kernel.release_full
  CHK     include/generated/uapi/linux/version.h
  CHK     include/generated/utsrelease.h
  UPD     include/generated/utsrelease.h
  CHK     scripts/mod/devicetable-offsets.h
  CC      kernel/bounds.s
  CHK     include/generated/timeconst.h
  CHK     include/generated/bounds.h
  CC      arch/arm64/kernel/asm-offsets.s
In file included from ./include/linux/sched.h:62:0,
                 from arch/arm64/kernel/asm-offsets.c:21:
./include/linux/cgroup-defs.h:142:21: error: field ‘destroy_swork’ has incomplete type
  struct swork_event destroy_swork;
                     ^~~~~~~~~~~~~
make[2]: *** [Kbuild:57: arch/arm64/kernel/asm-offsets.s] Error 1
make[1]: *** [Makefile:1171: prepare0] Error 2
make[1]: Leaving directory '/home/dylan/Desktop/fenix/build/linux'
make: *** [Makefile:18: kernel] Error 2
root@ubuntu:/home/dylan/Desktop/fenix# 

@DylanMingan I tried to apply the patchs from your link, but couldn’t do it via git am, how did you apply all the patches?

I didn’t use git am,I use patch

cd linux
patch -p1 < ../patch-4.9.241-rt156.patch

This is patching outputs:

root@ubuntu:/home/dylan/Desktop/fenix/build/linux# patch -p1 < ../patch-4.9.241-rt156.patch
patching file Documentation/sysrq.txt
patching file Documentation/trace/histograms.txt
patching file MAINTAINERS
patching file arch/Kconfig
patching file arch/arm/Kconfig
Hunk #3 succeeded at 2183 (offset 24 lines).
patching file arch/arm/include/asm/irq.h
patching file arch/arm/include/asm/switch_to.h
patching file arch/arm/include/asm/thread_info.h
Hunk #1 succeeded at 63 (offset 14 lines).
Hunk #2 succeeded at 166 (offset 23 lines).
Hunk #3 succeeded at 177 (offset 23 lines).
Hunk #4 succeeded at 193 (offset 23 lines).
patching file arch/arm/kernel/asm-offsets.c
patching file arch/arm/kernel/entry-armv.S
Hunk #1 succeeded at 313 (offset 93 lines).
Hunk #2 succeeded at 339 (offset 93 lines).
patching file arch/arm/kernel/entry-common.S
patching file arch/arm/kernel/process.c
Hunk #1 succeeded at 598 (offset 276 lines).
patching file arch/arm/kernel/signal.c
patching file arch/arm/kernel/smp.c
patching file arch/arm/kvm/arm.c
patching file arch/arm/mach-exynos/platsmp.c
patching file arch/arm/mach-hisi/platmcpm.c
patching file arch/arm/mach-omap2/omap-smp.c
patching file arch/arm/mach-prima2/platsmp.c
patching file arch/arm/mach-qcom/platsmp.c
patching file arch/arm/mach-spear/platsmp.c
patching file arch/arm/mach-sti/platsmp.c
patching file arch/arm/mm/fault.c
Hunk #1 succeeded at 528 (offset 92 lines).
Hunk #2 succeeded at 598 (offset 92 lines).
patching file arch/arm/mm/highmem.c
patching file arch/arm/plat-versatile/platsmp.c
patching file arch/arm64/Kconfig
Hunk #1 succeeded at 92 (offset 1 line).
Hunk #2 succeeded at 721 (offset 2 lines).
patching file arch/arm64/crypto/Kconfig
patching file arch/arm64/include/asm/thread_info.h
Hunk #1 FAILED at 49.
Hunk #2 succeeded at 85 (offset -27 lines).
Hunk #3 succeeded at 102 (offset -27 lines).
Hunk #4 succeeded at 111 (offset -27 lines).
1 out of 4 hunks FAILED -- saving rejects to file arch/arm64/include/asm/thread_info.h.rej
patching file arch/arm64/kernel/asm-offsets.c
Hunk #1 FAILED at 39.
1 out of 1 hunk FAILED -- saving rejects to file arch/arm64/kernel/asm-offsets.c.rej
patching file arch/arm64/kernel/entry.S
Hunk #1 FAILED at 502.
Hunk #2 succeeded at 696 with fuzz 2 (offset 176 lines).
1 out of 2 hunks FAILED -- saving rejects to file arch/arm64/kernel/entry.S.rej
patching file arch/arm64/kernel/signal.c
patching file arch/mips/Kconfig
patching file arch/powerpc/Kconfig
patching file arch/powerpc/include/asm/thread_info.h
patching file arch/powerpc/kernel/asm-offsets.c
patching file arch/powerpc/kernel/entry_32.S
patching file arch/powerpc/kernel/entry_64.S
patching file arch/powerpc/kernel/irq.c
patching file arch/powerpc/kernel/misc_32.S
patching file arch/powerpc/kernel/misc_64.S
patching file arch/powerpc/kvm/Kconfig
patching file arch/powerpc/platforms/ps3/device-init.c
patching file arch/sh/kernel/irq.c
patching file arch/sparc/Kconfig
patching file arch/sparc/kernel/irq_64.c
patching file arch/x86/Kconfig
patching file arch/x86/crypto/aesni-intel_glue.c
patching file arch/x86/crypto/camellia_aesni_avx2_glue.c
patching file arch/x86/crypto/camellia_aesni_avx_glue.c
patching file arch/x86/crypto/cast5_avx_glue.c
patching file arch/x86/crypto/cast6_avx_glue.c
patching file arch/x86/crypto/chacha20_glue.c
patching file arch/x86/crypto/glue_helper.c
patching file arch/x86/crypto/serpent_avx2_glue.c
patching file arch/x86/crypto/serpent_avx_glue.c
patching file arch/x86/crypto/serpent_sse2_glue.c
patching file arch/x86/crypto/twofish_avx_glue.c
patching file arch/x86/entry/common.c
patching file arch/x86/entry/entry_32.S
patching file arch/x86/entry/entry_64.S
Hunk #2 succeeded at 854 (offset -5 lines).
Hunk #3 succeeded at 867 (offset -5 lines).
patching file arch/x86/include/asm/fpu/api.h
patching file arch/x86/include/asm/preempt.h
patching file arch/x86/include/asm/signal.h
patching file arch/x86/include/asm/stackprotector.h
patching file arch/x86/include/asm/thread_info.h
patching file arch/x86/include/asm/uv/uv_bau.h
patching file arch/x86/kernel/acpi/boot.c
patching file arch/x86/kernel/asm-offsets.c
patching file arch/x86/kernel/cpu/mcheck/mce.c
patching file arch/x86/kernel/fpu/core.c
patching file arch/x86/kernel/irq_32.c
patching file arch/x86/kernel/process_32.c
patching file arch/x86/kvm/lapic.c
patching file arch/x86/kvm/x86.c
patching file arch/x86/mm/highmem_32.c
patching file arch/x86/mm/iomap_32.c
patching file arch/x86/mm/pageattr.c
patching file arch/x86/platform/uv/tlb_uv.c
patching file arch/x86/platform/uv/uv_time.c
patching file block/blk-core.c
Hunk #1 succeeded at 127 (offset 2 lines).
Hunk #2 succeeded at 238 (offset 2 lines).
Hunk #3 succeeded at 677 (offset 2 lines).
Hunk #4 succeeded at 765 (offset 2 lines).
Hunk #5 succeeded at 3218 (offset 2 lines).
Hunk #6 succeeded at 3266 (offset 2 lines).
Hunk #7 succeeded at 3285 (offset 2 lines).
Hunk #8 succeeded at 3297 (offset 2 lines).
Hunk #9 succeeded at 3324 (offset 2 lines).
Hunk #10 succeeded at 3572 (offset 2 lines).
patching file block/blk-ioc.c
patching file block/blk-mq.c
patching file block/blk-mq.h
patching file block/blk-softirq.c
patching file block/bounce.c
patching file crypto/algapi.c
patching file crypto/api.c
Hunk #1 succeeded at 32 (offset 1 line).
Hunk #2 succeeded at 237 (offset 1 line).
patching file crypto/internal.h
patching file drivers/acpi/acpica/acglobal.h
patching file drivers/acpi/acpica/hwregs.c
patching file drivers/acpi/acpica/hwxface.c
patching file drivers/acpi/acpica/utmutex.c
patching file drivers/ata/libata-sff.c
patching file drivers/block/zram/zcomp.c
patching file drivers/block/zram/zcomp.h
patching file drivers/block/zram/zram_drv.c
Hunk #5 succeeded at 805 (offset 9 lines).
Hunk #6 succeeded at 853 (offset 9 lines).
Hunk #7 succeeded at 984 (offset 9 lines).
patching file drivers/block/zram/zram_drv.h
patching file drivers/char/random.c
patching file drivers/char/tpm/tpm_tis.c
patching file drivers/clocksource/tcb_clksrc.c
patching file drivers/clocksource/timer-atmel-pit.c
patching file drivers/clocksource/timer-atmel-st.c
patching file drivers/connector/cn_proc.c
patching file drivers/cpufreq/Kconfig.x86
patching file drivers/gpu/drm/i915/i915_gem_execbuffer.c
patching file drivers/gpu/drm/i915/i915_gem_shrinker.c
patching file drivers/gpu/drm/i915/i915_irq.c
patching file drivers/gpu/drm/i915/intel_display.c
patching file drivers/gpu/drm/i915/intel_sprite.c
patching file drivers/gpu/drm/msm/msm_gem_shrinker.c
patching file drivers/gpu/drm/radeon/radeon_display.c
patching file drivers/hv/vmbus_drv.c
patching file drivers/ide/alim15x3.c
patching file drivers/ide/hpt366.c
patching file drivers/ide/ide-io-std.c
patching file drivers/ide/ide-io.c
patching file drivers/ide/ide-iops.c
patching file drivers/ide/ide-probe.c
patching file drivers/ide/ide-taskfile.c
patching file drivers/infiniband/ulp/ipoib/ipoib_multicast.c
patching file drivers/input/gameport/gameport.c
patching file drivers/iommu/amd_iommu.c
patching file drivers/iommu/intel-iommu.c
patching file drivers/iommu/iova.c
patching file drivers/leds/trigger/Kconfig
patching file drivers/md/bcache/Kconfig
patching file drivers/md/dm-rq.c
patching file drivers/md/raid5.c
patching file drivers/md/raid5.h
patching file drivers/misc/Kconfig
patching file drivers/mmc/host/mmci.c
patching file drivers/net/ethernet/3com/3c59x.c
patching file drivers/net/wireless/intersil/orinoco/orinoco_usb.c
patching file drivers/pinctrl/qcom/pinctrl-msm.c
patching file drivers/scsi/fcoe/fcoe.c
patching file drivers/scsi/fcoe/fcoe_ctlr.c
patching file drivers/scsi/libfc/fc_exch.c
patching file drivers/scsi/libsas/sas_ata.c
patching file drivers/scsi/qla2xxx/qla_inline.h
patching file drivers/scsi/qla2xxx/qla_isr.c
patching file drivers/thermal/x86_pkg_temp_thermal.c
patching file drivers/tty/serial/8250/8250_core.c
patching file drivers/tty/serial/8250/8250_port.c
patching file drivers/tty/serial/amba-pl011.c
patching file drivers/tty/serial/omap-serial.c
patching file drivers/usb/core/hcd.c
Hunk #1 FAILED at 1764.
1 out of 1 hunk FAILED -- saving rejects to file drivers/usb/core/hcd.c.rej
patching file drivers/usb/gadget/function/f_fs.c
Hunk #1 succeeded at 1808 (offset 207 lines).
patching file drivers/usb/gadget/legacy/inode.c
patching file fs/aio.c
patching file fs/autofs4/autofs_i.h
patching file fs/autofs4/expire.c
patching file fs/buffer.c
patching file fs/cifs/readdir.c
patching file fs/dcache.c
Hunk #10 succeeded at 3686 (offset 1 line).
patching file fs/eventpoll.c
Hunk #1 succeeded at 509 (offset 1 line).
patching file fs/exec.c
patching file fs/ext4/page-io.c
Hunk #1 succeeded at 94 (offset -1 lines).
Hunk #2 succeeded at 106 (offset -1 lines).
patching file fs/fuse/dir.c
Hunk #1 succeeded at 1248 (offset 46 lines).
patching file fs/inode.c
patching file fs/locks.c
patching file fs/namei.c
Hunk #1 succeeded at 1682 (offset 15 lines).
Hunk #2 succeeded at 3164 (offset 31 lines).
patching file fs/namespace.c
Hunk #2 succeeded at 359 (offset 1 line).
patching file fs/nfs/delegation.c
patching file fs/nfs/dir.c
patching file fs/nfs/inode.c
patching file fs/nfs/nfs4_fs.h
patching file fs/nfs/nfs4proc.c
patching file fs/nfs/nfs4state.c
patching file fs/nfs/unlink.c
patching file fs/ntfs/aops.c
patching file fs/proc/base.c
Hunk #1 succeeded at 1847 (offset 1 line).
patching file fs/proc/proc_sysctl.c
patching file fs/squashfs/decompressor_multi_percpu.c
patching file fs/timerfd.c
patching file fs/xfs/xfs_aops.c
patching file include/acpi/platform/aclinux.h
patching file include/asm-generic/bug.h
patching file include/linux/blk-mq.h
patching file include/linux/blkdev.h
Hunk #3 succeeded at 479 (offset 3 lines).
patching file include/linux/bottom_half.h
patching file include/linux/buffer_head.h
patching file include/linux/cgroup-defs.h
Hunk #1 FAILED at 16.
Hunk #2 succeeded at 139 (offset 1 line).
1 out of 2 hunks FAILED -- saving rejects to file include/linux/cgroup-defs.h.rej
patching file include/linux/completion.h
patching file include/linux/cpu.h
patching file include/linux/dcache.h
Hunk #3 succeeded at 233 (offset 1 line).
patching file include/linux/delay.h
patching file include/linux/fs.h
Hunk #1 succeeded at 714 (offset 19 lines).
patching file include/linux/highmem.h
patching file include/linux/hrtimer.h
patching file include/linux/idr.h
patching file include/linux/init_task.h
patching file include/linux/interrupt.h
Hunk #2 succeeded at 63 (offset 1 line).
Hunk #3 succeeded at 77 (offset 1 line).
Hunk #4 succeeded at 200 (offset 1 line).
Hunk #5 succeeded at 220 (offset 1 line).
Hunk #6 succeeded at 232 (offset 1 line).
Hunk #7 succeeded at 415 (offset 1 line).
Hunk #8 succeeded at 478 (offset 1 line).
Hunk #9 succeeded at 490 (offset 1 line).
Hunk #10 succeeded at 530 (offset 1 line).
Hunk #11 succeeded at 557 (offset 1 line).
Hunk #12 succeeded at 635 (offset 1 line).
Hunk #13 succeeded at 666 (offset 1 line).
patching file include/linux/irq.h
patching file include/linux/irq_work.h
patching file include/linux/irqdesc.h
patching file include/linux/irqflags.h
patching file include/linux/jbd2.h
patching file include/linux/kdb.h
patching file include/linux/kernel.h
patching file include/linux/list_bl.h
patching file include/linux/locallock.h
patching file include/linux/mm_types.h
Hunk #2 succeeded at 536 (offset 17 lines).
patching file include/linux/module.h
Hunk #1 succeeded at 501 (offset 5 lines).
Hunk #2 succeeded at 669 (offset 5 lines).
patching file include/linux/mutex.h
patching file include/linux/mutex_rt.h
patching file include/linux/netdevice.h
patching file include/linux/netfilter/x_tables.h
patching file include/linux/nfs_fs.h
patching file include/linux/nfs_xdr.h
patching file include/linux/notifier.h
patching file include/linux/percpu-rwsem.h
patching file include/linux/percpu.h
patching file include/linux/pid.h
patching file include/linux/posix-timers.h
patching file include/linux/preempt.h
patching file include/linux/printk.h
patching file include/linux/radix-tree.h
patching file include/linux/random.h
patching file include/linux/rbtree.h
patching file include/linux/rbtree_augmented.h
patching file include/linux/rcu_assign_pointer.h
patching file include/linux/rcupdate.h
patching file include/linux/rcutree.h
patching file include/linux/rtmutex.h
patching file include/linux/rwlock_rt.h
patching file include/linux/rwlock_types.h
patching file include/linux/rwlock_types_rt.h
patching file include/linux/rwsem.h
patching file include/linux/rwsem_rt.h
patching file include/linux/sched.h
Hunk #2 succeeded at 240 (offset 3 lines).
Hunk #3 succeeded at 312 (offset 3 lines).
Hunk #4 succeeded at 1045 (offset 20 lines).
Hunk #5 succeeded at 1656 (offset 139 lines).
Hunk #6 succeeded at 1706 (offset 149 lines).
Hunk #7 succeeded at 1855 (offset 153 lines).
Hunk #8 succeeded at 1889 (offset 153 lines).
Hunk #9 succeeded at 1923 (offset 153 lines).
Hunk #10 succeeded at 2129 (offset 153 lines).
Hunk #11 succeeded at 2160 (offset 153 lines).
Hunk #12 succeeded at 2216 (offset 153 lines).
Hunk #13 succeeded at 2435 (offset 153 lines).
Hunk #14 succeeded at 2451 (offset 153 lines).
Hunk #15 succeeded at 2493 (offset 153 lines).
Hunk #16 succeeded at 2680 (offset 153 lines).
Hunk #17 succeeded at 2696 (offset 153 lines).
Hunk #18 succeeded at 2937 (offset 153 lines).
Hunk #19 succeeded at 3146 (offset 153 lines).
Hunk #20 succeeded at 3566 (offset 166 lines).
Hunk #21 succeeded at 3634 (offset 166 lines).
Hunk #22 succeeded at 3704 (offset 166 lines).
Hunk #23 succeeded at 3888 (offset 166 lines).
patching file include/linux/sched/rt.h
patching file include/linux/seqlock.h
patching file include/linux/signal.h
patching file include/linux/skbuff.h
patching file include/linux/smp.h
Hunk #1 succeeded at 119 (offset -1 lines).
Hunk #2 succeeded at 164 (offset -1 lines).
Hunk #3 succeeded at 196 (offset -1 lines).
patching file include/linux/spinlock.h
patching file include/linux/spinlock_api_smp.h
patching file include/linux/spinlock_rt.h
patching file include/linux/spinlock_types.h
patching file include/linux/spinlock_types_nort.h
patching file include/linux/spinlock_types_raw.h
patching file include/linux/spinlock_types_rt.h
patching file include/linux/srcu.h
patching file include/linux/suspend.h
patching file include/linux/swait.h
patching file include/linux/swap.h
patching file include/linux/swork.h
patching file include/linux/thread_info.h
Hunk #1 succeeded at 69 (offset -33 lines).
patching file include/linux/timer.h
patching file include/linux/trace_events.h
patching file include/linux/uaccess.h
patching file include/linux/uprobes.h
patching file include/linux/vmstat.h
Hunk #1 succeeded at 35 (offset 2 lines).
Hunk #2 succeeded at 47 (offset 2 lines).
patching file include/linux/wait.h
patching file include/net/dst.h
patching file include/net/gen_stats.h
patching file include/net/neighbour.h
patching file include/net/net_seq_lock.h
patching file include/net/netns/ipv4.h
patching file include/net/sch_generic.h
patching file include/trace/events/hist.h
patching file include/trace/events/latency_hist.h
patching file include/trace/events/sched.h
Hunk #6 succeeded at 438 (offset 24 lines).
Hunk #7 succeeded at 453 (offset 24 lines).
patching file init/Kconfig
Hunk #1 succeeded at 515 (offset 9 lines).
Hunk #2 succeeded at 632 (offset 9 lines).
Hunk #3 succeeded at 659 (offset 9 lines).
Hunk #4 succeeded at 790 (offset 9 lines).
Hunk #5 succeeded at 1136 (offset 85 lines).
Hunk #6 succeeded at 1906 (offset 139 lines).
Hunk #7 succeeded at 1927 (offset 139 lines).
Hunk #8 succeeded at 1946 (offset 139 lines).
patching file init/Makefile
Hunk #1 succeeded at 33 (offset -2 lines).
patching file init/main.c
Hunk #1 succeeded at 516 (offset 7 lines).
patching file ipc/sem.c
patching file kernel/Kconfig.locks
patching file kernel/Kconfig.preempt
patching file kernel/cgroup.c
Hunk #1 succeeded at 5046 (offset 1 line).
Hunk #2 succeeded at 5094 (offset 3 lines).
Hunk #3 succeeded at 5759 (offset 6 lines).
patching file kernel/cpu.c
Hunk #6 succeeded at 1708 (offset 7 lines).
Hunk #7 succeeded at 2556 (offset 7 lines).
patching file kernel/cpu_pm.c
patching file kernel/cpuset.c
Hunk #1 succeeded at 286 (offset 1 line).
Hunk #2 succeeded at 909 (offset 1 line).
Hunk #3 FAILED at 975.
Hunk #4 succeeded at 1180 (offset 3 lines).
Hunk #5 succeeded at 1250 (offset 3 lines).
Hunk #6 succeeded at 1343 (offset 3 lines).
Hunk #7 succeeded at 1760 (offset 3 lines).
Hunk #8 succeeded at 1779 (offset 3 lines).
Hunk #9 succeeded at 1999 (offset 8 lines).
Hunk #10 FAILED at 2023.
Hunk #11 succeeded at 2077 (offset 10 lines).
Hunk #12 succeeded at 2088 (offset 10 lines).
Hunk #13 succeeded at 2192 (offset 13 lines).
Hunk #14 succeeded at 2234 (offset 13 lines).
Hunk #15 succeeded at 2330 (offset 13 lines).
Hunk #16 succeeded at 2449 (offset 13 lines).
Hunk #17 succeeded at 2501 (offset 13 lines).
Hunk #18 succeeded at 2597 (offset 13 lines).
2 out of 18 hunks FAILED -- saving rejects to file kernel/cpuset.c.rej
patching file kernel/debug/kdb/kdb_io.c
Hunk #1 succeeded at 565 (offset 8 lines).
Hunk #2 succeeded at 575 (offset 8 lines).
Hunk #3 succeeded at 867 (offset 8 lines).
Hunk #4 succeeded at 876 (offset 8 lines).
patching file kernel/events/core.c
Hunk #1 succeeded at 1072 (offset 5 lines).
Hunk #2 succeeded at 8475 (offset 5 lines).
patching file kernel/exit.c
Hunk #1 succeeded at 145 (offset 2 lines).
patching file kernel/fork.c
Hunk #1 FAILED at 77.
Hunk #2 succeeded at 400 (offset 19 lines).
Hunk #3 succeeded at 428 (offset 19 lines).
Hunk #4 succeeded at 587 (offset 21 lines).
Hunk #5 succeeded at 914 (offset 21 lines).
Hunk #6 succeeded at 1494 (offset 21 lines).
Hunk #7 succeeded at 1504 (offset 21 lines).
Hunk #8 succeeded at 1646 (offset 22 lines).
1 out of 8 hunks FAILED -- saving rejects to file kernel/fork.c.rej
patching file kernel/futex.c
patching file kernel/irq/handle.c
Hunk #1 succeeded at 190 (offset 9 lines).
patching file kernel/irq/manage.c
patching file kernel/irq/settings.h
patching file kernel/irq/spurious.c
patching file kernel/irq_work.c
patching file kernel/ksysfs.c
patching file kernel/locking/Makefile
patching file kernel/locking/lockdep.c
patching file kernel/locking/locktorture.c
patching file kernel/locking/percpu-rwsem.c
patching file kernel/locking/rt.c
patching file kernel/locking/rtmutex-debug.c
patching file kernel/locking/rtmutex-debug.h
patching file kernel/locking/rtmutex.c
patching file kernel/locking/rtmutex.h
patching file kernel/locking/rtmutex_common.h
patching file kernel/locking/rwsem-rt.c
patching file kernel/locking/spinlock.c
patching file kernel/locking/spinlock_debug.c
patching file kernel/module.c
patching file kernel/panic.c
Hunk #1 succeeded at 493 (offset 6 lines).
patching file kernel/power/hibernate.c
patching file kernel/power/suspend.c
Hunk #1 succeeded at 382 (offset 13 lines).
Hunk #2 succeeded at 403 (offset 16 lines).
Hunk #3 succeeded at 560 with fuzz 1 (offset 29 lines).
Hunk #4 FAILED at 547.
Hunk #5 FAILED at 554.
2 out of 5 hunks FAILED -- saving rejects to file kernel/power/suspend.c.rej
patching file kernel/printk/printk.c
Hunk #1 succeeded at 358 with fuzz 1 (offset 7 lines).
Hunk #2 succeeded at 1393 (offset 24 lines).
Hunk #3 succeeded at 1404 (offset 24 lines).
Hunk #4 succeeded at 1425 (offset 24 lines).
Hunk #5 succeeded at 1444 (offset 24 lines).
Hunk #6 succeeded at 1490 (offset 24 lines).
Hunk #7 succeeded at 1641 (offset 24 lines).
Hunk #8 succeeded at 1662 (offset 24 lines).
Hunk #9 succeeded at 1866 (offset 30 lines).
Hunk #10 succeeded at 1981 (offset 34 lines).
Hunk #11 succeeded at 2118 (offset 34 lines).
Hunk #12 succeeded at 2390 (offset 34 lines).
Hunk #13 succeeded at 2523 (offset 34 lines).
Hunk #14 succeeded at 2585 (offset 34 lines).
patching file kernel/ptrace.c
patching file kernel/rcu/rcutorture.c
patching file kernel/rcu/tree.c
patching file kernel/rcu/tree.h
patching file kernel/rcu/tree_plugin.h
patching file kernel/rcu/update.c
patching file kernel/sched/Makefile
Hunk #1 FAILED at 17.
1 out of 1 hunk FAILED -- saving rejects to file kernel/sched/Makefile.rej
patching file kernel/sched/completion.c
patching file kernel/sched/core.c
Hunk #1 succeeded at 131 (offset 2 lines).
Hunk #2 succeeded at 363 (offset 14 lines).
Hunk #3 succeeded at 444 (offset 14 lines).
Hunk #4 succeeded at 474 (offset 14 lines).
Hunk #5 succeeded at 536 (offset 14 lines).
Hunk #6 succeeded at 591 (offset 14 lines).
Hunk #7 succeeded at 617 (offset 14 lines).
Hunk #8 succeeded at 1166 (offset 16 lines).
Hunk #9 succeeded at 1196 (offset 16 lines).
Hunk #10 succeeded at 1347 (offset 16 lines).
Hunk #11 succeeded at 1537 (offset 20 lines).
Hunk #12 succeeded at 1593 (offset 20 lines).
Hunk #13 succeeded at 1608 (offset 20 lines).
Hunk #14 succeeded at 1864 (offset 20 lines).
Hunk #15 succeeded at 2202 (offset 24 lines).
Hunk #16 FAILED at 2280.
Hunk #17 succeeded at 2384 (offset 39 lines).
Hunk #18 succeeded at 2678 (offset 44 lines).
Hunk #19 succeeded at 3015 (offset 50 lines).
Hunk #20 succeeded at 3528 (offset 86 lines).
Hunk #21 succeeded at 3753 (offset 87 lines).
Hunk #22 succeeded at 3765 with fuzz 2 (offset 90 lines).
Hunk #23 succeeded at 3817 (offset 94 lines).
Hunk #24 succeeded at 3838 (offset 94 lines).
Hunk #25 succeeded at 3854 (offset 94 lines).
Hunk #26 succeeded at 3918 (offset 94 lines).
Hunk #27 succeeded at 3956 (offset 94 lines).
Hunk #28 succeeded at 3984 (offset 94 lines).
Hunk #29 succeeded at 4009 (offset 94 lines).
Hunk #30 succeeded at 4064 (offset 94 lines).
Hunk #31 FAILED at 3996.
Hunk #32 succeeded at 4120 (offset 95 lines).
Hunk #33 succeeded at 4144 (offset 95 lines).
Hunk #34 succeeded at 4181 (offset 95 lines).
Hunk #35 succeeded at 4433 (offset 97 lines).
Hunk #36 succeeded at 4723 (offset 98 lines).
Hunk #37 succeeded at 5398 (offset 98 lines).
Hunk #38 succeeded at 5412 (offset 98 lines).
Hunk #39 succeeded at 5776 (offset 98 lines).
Hunk #40 succeeded at 5921 (offset 98 lines).
Hunk #41 succeeded at 5937 (offset 98 lines).
Hunk #42 succeeded at 6371 (offset 105 lines).
Hunk #43 succeeded at 8038 (offset 194 lines).
Hunk #44 succeeded at 8310 (offset 201 lines).
2 out of 44 hunks FAILED -- saving rejects to file kernel/sched/core.c.rej
patching file kernel/sched/deadline.c
Hunk #1 succeeded at 774 (offset 2 lines).
patching file kernel/sched/debug.c
Hunk #1 succeeded at 621 (offset 63 lines).
Hunk #2 succeeded at 1045 (offset 89 lines).
patching file kernel/sched/fair.c
Hunk #1 succeeded at 3797 (offset 258 lines).
Hunk #2 succeeded at 3821 (offset 258 lines).
Hunk #3 succeeded at 3963 (offset 258 lines).
Hunk #4 succeeded at 4147 (offset 258 lines).
Hunk #5 succeeded at 4827 (offset 258 lines).
Hunk #6 succeeded at 7521 (offset 1584 lines).
Hunk #7 succeeded at 10555 (offset 1874 lines).
Hunk #8 succeeded at 10579 (offset 1874 lines).
patching file kernel/sched/features.h
patching file kernel/sched/rt.c
Hunk #1 succeeded at 50 (offset 2 lines).
patching file kernel/sched/sched.h
Hunk #1 succeeded at 1227 (offset 53 lines).
Hunk #2 succeeded at 1433 (offset 75 lines).
patching file kernel/sched/swait.c
patching file kernel/sched/swork.c
patching file kernel/signal.c
patching file kernel/softirq.c
Hunk #1 succeeded at 21 with fuzz 1.
Hunk #2 succeeded at 62 (offset 4 lines).
Hunk #3 succeeded at 179 (offset 4 lines).
Hunk #4 succeeded at 226 (offset 4 lines).
Hunk #5 FAILED at 418.
Hunk #6 FAILED at 440.
Hunk #7 succeeded at 520 (offset 15 lines).
Hunk #8 succeeded at 834 (offset 15 lines).
Hunk #9 succeeded at 844 with fuzz 1 (offset 15 lines).
Hunk #10 succeeded at 866 (offset 14 lines).
Hunk #11 succeeded at 914 (offset 14 lines).
Hunk #12 succeeded at 923 (offset 14 lines).
Hunk #13 succeeded at 939 (offset 14 lines).
Hunk #14 succeeded at 987 (offset 14 lines).
Hunk #15 succeeded at 996 (offset 14 lines).
Hunk #16 succeeded at 1132 (offset 14 lines).
Hunk #17 succeeded at 1206 (offset 14 lines).
Hunk #18 succeeded at 1292 (offset 14 lines).
2 out of 18 hunks FAILED -- saving rejects to file kernel/softirq.c.rej
patching file kernel/stop_machine.c
patching file kernel/time/alarmtimer.c
patching file kernel/time/hrtimer.c
patching file kernel/time/itimer.c
patching file kernel/time/jiffies.c
patching file kernel/time/posix-cpu-timers.c
patching file kernel/time/posix-timers.c
patching file kernel/time/tick-broadcast-hrtimer.c
patching file kernel/time/tick-common.c
patching file kernel/time/tick-sched.c
Hunk #7 succeeded at 1219 (offset 12 lines).
patching file kernel/time/timekeeping.c
Hunk #1 succeeded at 2381 (offset 32 lines).
patching file kernel/time/timekeeping.h
patching file kernel/time/timer.c
patching file kernel/trace/Kconfig
Hunk #1 succeeded at 196 (offset 14 lines).
Hunk #2 succeeded at 238 (offset 14 lines).
Hunk #3 succeeded at 301 (offset 14 lines).
patching file kernel/trace/Makefile
Hunk #1 succeeded at 39 (offset 1 line).
patching file kernel/trace/latency_hist.c
patching file kernel/trace/trace.c
Hunk #1 succeeded at 1927 (offset 21 lines).
Hunk #2 succeeded at 1938 (offset 21 lines).
Hunk #3 succeeded at 2940 (offset 21 lines).
Hunk #4 succeeded at 2983 with fuzz 1 (offset 28 lines).
patching file kernel/trace/trace.h
patching file kernel/trace/trace_events.c
patching file kernel/trace/trace_irqsoff.c
Hunk #2 succeeded at 429 (offset 4 lines).
Hunk #3 succeeded at 445 (offset 4 lines).
Hunk #4 succeeded at 454 (offset 4 lines).
Hunk #5 succeeded at 482 with fuzz 2 (offset 6 lines).
Hunk #6 FAILED at 486.
Hunk #7 FAILED at 500.
Hunk #8 FAILED at 509.
3 out of 8 hunks FAILED -- saving rejects to file kernel/trace/trace_irqsoff.c.rej
patching file kernel/trace/trace_output.c
patching file kernel/user.c
Hunk #1 succeeded at 162 (offset 1 line).
patching file kernel/watchdog.c
Hunk #1 succeeded at 392 (offset 11 lines).
patching file kernel/watchdog_hld.c
Hunk #1 FAILED at 19.
Hunk #2 succeeded at 112 (offset 8 lines).
Hunk #3 FAILED at 128.
2 out of 3 hunks FAILED -- saving rejects to file kernel/watchdog_hld.c.rej
patching file kernel/workqueue.c
Hunk #29 succeeded at 2846 (offset 19 lines).
Hunk #30 succeeded at 2882 (offset 19 lines).
Hunk #31 succeeded at 2973 (offset 19 lines).
Hunk #32 succeeded at 3028 (offset 19 lines).
Hunk #33 succeeded at 3049 (offset 19 lines).
Hunk #34 succeeded at 3306 (offset 19 lines).
Hunk #35 succeeded at 3360 (offset 19 lines).
Hunk #36 succeeded at 3468 (offset 19 lines).
Hunk #37 succeeded at 4154 (offset 19 lines).
Hunk #38 succeeded at 4264 (offset 19 lines).
Hunk #39 succeeded at 4276 (offset 19 lines).
Hunk #40 succeeded at 4303 (offset 19 lines).
Hunk #41 succeeded at 4501 (offset 19 lines).
Hunk #42 succeeded at 4566 (offset 19 lines).
Hunk #43 succeeded at 4904 (offset 19 lines).
Hunk #44 succeeded at 5103 (offset 19 lines).
Hunk #45 succeeded at 5112 (offset 19 lines).
patching file kernel/workqueue_internal.h
patching file lib/Kconfig
Hunk #1 succeeded at 411 (offset 11 lines).
patching file lib/debugobjects.c
patching file lib/idr.c
patching file lib/irq_poll.c
patching file lib/locking-selftest.c
patching file lib/percpu_ida.c
patching file lib/radix-tree.c
patching file lib/scatterlist.c
patching file lib/smp_processor_id.c
patching file localversion-rt
patching file mm/Kconfig
patching file mm/backing-dev.c
patching file mm/compaction.c
Hunk #1 succeeded at 1652 (offset 59 lines).
patching file mm/filemap.c
patching file mm/highmem.c
patching file mm/memcontrol.c
patching file mm/mmu_context.c
patching file mm/page_alloc.c
Hunk #2 succeeded at 298 (offset 15 lines).
Hunk #3 succeeded at 1146 (offset 40 lines).
Hunk #4 succeeded at 1157 (offset 40 lines).
Hunk #5 succeeded at 1224 (offset 40 lines).
Hunk #6 succeeded at 1232 (offset 40 lines).
Hunk #7 succeeded at 1246 (offset 40 lines).
Hunk #8 succeeded at 1258 (offset 40 lines).
Hunk #9 succeeded at 1344 (offset 40 lines).
Hunk #10 succeeded at 2455 (offset 132 lines).
Hunk #11 succeeded at 2482 (offset 132 lines).
Hunk #12 FAILED at 2450.
Hunk #13 succeeded at 2643 (offset 132 lines).
Hunk #14 succeeded at 2677 (offset 140 lines).
Hunk #15 succeeded at 2826 (offset 144 lines).
Hunk #16 succeeded at 2900 (offset 191 lines).
Hunk #17 FAILED at 2721.
Hunk #18 succeeded at 6868 (offset 267 lines).
Hunk #19 succeeded at 6896 (offset 267 lines).
Hunk #20 succeeded at 7740 (offset 273 lines).
Hunk #21 succeeded at 7749 (offset 273 lines).
2 out of 21 hunks FAILED -- saving rejects to file mm/page_alloc.c.rej
patching file mm/percpu.c
patching file mm/slab.h
patching file mm/slub.c
Hunk #36 succeeded at 4065 (offset 41 lines).
Hunk #37 succeeded at 4096 (offset 41 lines).
Hunk #38 succeeded at 4272 (offset 41 lines).
Hunk #39 succeeded at 4486 (offset 41 lines).
Hunk #40 succeeded at 4508 (offset 41 lines).
Hunk #41 succeeded at 4696 (offset 41 lines).
patching file mm/swap.c
patching file mm/truncate.c
patching file mm/vmalloc.c
patching file mm/vmstat.c
patching file mm/workingset.c
patching file mm/zsmalloc.c
patching file net/bluetooth/hci_sock.c
patching file net/core/dev.c
patching file net/core/filter.c
Hunk #1 succeeded at 1657 (offset 10 lines).
Hunk #2 succeeded at 1665 (offset 10 lines).
patching file net/core/gen_estimator.c
patching file net/core/gen_stats.c
patching file net/core/skbuff.c
patching file net/core/sock.c
Hunk #1 succeeded at 2536 (offset 11 lines).
patching file net/ipv4/icmp.c
Hunk #8 succeeded at 919 (offset 2 lines).
Hunk #9 succeeded at 970 (offset 2 lines).
patching file net/ipv4/sysctl_net_ipv4.c
Hunk #1 succeeded at 716 (offset 22 lines).
patching file net/ipv4/tcp_ipv4.c
Hunk #2 succeeded at 575 (offset 5 lines).
Hunk #3 FAILED at 698.
Hunk #4 succeeded at 712 (offset 6 lines).
Hunk #5 succeeded at 792 with fuzz 2 (offset 8 lines).
1 out of 5 hunks FAILED -- saving rejects to file net/ipv4/tcp_ipv4.c.rej
patching file net/mac80211/rx.c
patching file net/netfilter/core.c
patching file net/packet/af_packet.c
patching file net/rds/ib_rdma.c
patching file net/rxrpc/security.c
patching file net/sched/sch_api.c
patching file net/sched/sch_generic.c
patching file net/sunrpc/svc_xprt.c
patching file scripts/mkcompile_h
patching file sound/core/pcm_native.c

It seems occur some error

I’m afraid - this is gonna be really tricky. Amlogic Linux Kernel 4.9 tree is a vendor changed kernel and isn’t much the same what original 4.9 kernel was. Amlogic kernel had a lot of changes made, so RT patches against it will not apply cleanly… that is what patch is saying to you…

Hunk #1 FAILED at 39.
1 out of 1 hunk FAILED – saving rejects to file arch/arm64/kernel/asm-offsets.c.rej

1 out of 1 hunk FAILED – saving rejects to file arch/arm64/kernel/asm-offsets.c.rej
patching file arch/arm64/kernel/entry.S
Hunk #1 FAILED at 1764.
1 out of 1 hunk FAILED – saving rejects to file drivers/usb/core/hcd.c.rej

and so on… you can of course read what have been rejected and try to fix by yourself - but I bet won’t be much luck without knowing ARM assembly and platform details… Too much work in any case.

The only way you can go - is switch to mainline kernel and continue with RT patches… but you’ll definitely loose some functions - like MIPI - DSI output and some smaller features…

1 Like

Thanks to your reminder and guidance, I realized that there was an error in the patching, and as you suggested, I now use the mainline linux to patch, successfully compile and produce the image. As for the loss of functionality you mentioned, I haven’t tested it yet, and I currently only need to use the communication functions of i2c, spi and uart.

It will require changes to mainline DTS files to enable them as overlays aren’t on in mainline afaik, UART3 is off by default for sure… I2c - should work… but this is pretty easy to accomplish…

Is DTS files in fenix/build/linux-mainline-5.17/arch/arm64/boot/dts/amlogic?

root@ubuntu:/home/dylan/Desktop/fenix/build/linux-mainline-5.17/arch/arm64/boot/dts/amlogic# ls
Makefile                           meson-gxl-mali.dtsi
meson-a1-ad401.dts                 meson-gxl-s805x.dtsi
meson-a1.dtsi                      meson-gxl-s805x-libretech-ac.dts
meson-axg.dtsi                     meson-gxl-s805x-p241.dts
meson-axg-jethome-jethub-j100.dts  meson-gxl-s905d.dtsi
meson-axg-s400.dts                 meson-gxl-s905d-libretech-pc.dts
meson-g12a.dtsi                    meson-gxl-s905d-mecool-kii-pro.dts
meson-g12a-radxa-zero.dts          meson-gxl-s905d-p230.dts
meson-g12a-sei510.dts              meson-gxl-s905d-p231.dts
meson-g12a-u200.dts                meson-gxl-s905d-phicomm-n1.dts
meson-g12a-x96-max.dts             meson-gxl-s905d-sml5442tw.dts
meson-g12b-a311d.dtsi              meson-gxl-s905w-jethome-jethub-j80.dts
meson-g12b-a311d-khadas-vim3.dtb   meson-gxl-s905w-p281.dts
meson-g12b-a311d-khadas-vim3.dts   meson-gxl-s905w-tx3-mini.dts
meson-g12b.dtsi                    meson-gxl-s905x.dtsi
meson-g12b-gsking-x.dts            meson-gxl-s905x-hwacom-amazetv.dts
meson-g12b-gtking.dts              meson-gxl-s905x-khadas-vim.dtb
meson-g12b-gtking-pro.dts          meson-gxl-s905x-khadas-vim.dts
meson-g12b-khadas-vim3.dtsi        meson-gxl-s905x-libretech-cc.dts
meson-g12b-odroid-n2.dts           meson-gxl-s905x-libretech-cc-v2.dts
meson-g12b-odroid-n2.dtsi          meson-gxl-s905x-nexbox-a95x.dts
meson-g12b-odroid-n2-plus.dts      meson-gxl-s905x-p212.dts
meson-g12b-s922x.dtsi              meson-gxl-s905x-p212.dtsi
meson-g12b-s922x-khadas-vim3.dtb   meson-gx-mali450.dtsi
meson-g12b-s922x-khadas-vim3.dts   meson-gxm.dtsi
meson-g12b-ugoos-am6.dts           meson-gxm-khadas-vim2.dtb
meson-g12b-w400.dtsi               meson-gxm-khadas-vim2.dts
meson-g12-common.dtsi              meson-gxm-mecool-kiii-pro.dts
meson-g12.dtsi                     meson-gxm-minix-neo-u9h.dts
meson-gxbb.dtsi                    meson-gxm-nexbox-a1.dts
meson-gxbb-kii-pro.dts             meson-gxm-q200.dts
meson-gxbb-nanopi-k2.dts           meson-gxm-q201.dts
meson-gxbb-nexbox-a95x.dts         meson-gxm-rbox-pro.dts
meson-gxbb-odroidc2.dts            meson-gxm-s912-libretech-pc.dts
meson-gxbb-p200.dts                meson-gxm-vega-s96.dts
meson-gxbb-p201.dts                meson-gxm-wetek-core2.dts
meson-gxbb-p20x.dtsi               meson-gx-p23x-q20x.dtsi
meson-gxbb-vega-s95.dtsi           meson-khadas-vim3.dtsi
meson-gxbb-vega-s95-meta.dts       meson-sm1-bananapi-m5.dts
meson-gxbb-vega-s95-pro.dts        meson-sm1.dtsi
meson-gxbb-vega-s95-telos.dts      meson-sm1-khadas-vim3l.dtb
meson-gxbb-wetek.dtsi              meson-sm1-khadas-vim3l.dts
meson-gxbb-wetek-hub.dts           meson-sm1-odroid-c4.dts
meson-gxbb-wetek-play2.dts         meson-sm1-odroid.dtsi
meson-gx.dtsi                      meson-sm1-odroid-hc4.dts
meson-gxl.dtsi                     meson-sm1-sei610.dts
meson-gx-libretech-pc.dtsi

Forgive my poor knowledge about DTS, I don’t know what to do with that file and how to do it, especially now that using fenix finds that Linux has become 5.17.

I want to use the spi to receive data from two spi slave sensors, like mpu6000 etc.

In 5.17 Fenix build - Khadas team added kernel overlay config option - I assume usual overlays from uboot and 4.9 kernel should work now to enable usart3 and spi. @hyphop - Artem can you confirm this ?

I’ve created post to illustrate my situation

Briefly, the overlays failed, and then the dts were modified, but it still failed, so I suspect that I modified the configuration of the dts by mistake

yes fenix fresh build can use overlays easily

I use overlays to setup spi1,but it fails.

system info:
Linux Khadas 5.17.0-rt17 #1.0.11 SMP Wed May 4 03:34:07 PDT 2022 aarch64 aarch64 aarch64 GNU/Linux

more details in this post:

i think your dts configuration have some collisions
need more details dmesg | grep spi maybe need inc kernel messages level and check /sys/class/spi*

example how to check spi

find  /sys/class/spi*
/sys/class/spi_master
/sys/class/spi_master/spi0
/sys/class/spidev

run dmesg | grep spi and find /sys/class/spi*

Is this result right?It seems spi0 is ok,is spi0 in the 40-Pin HEADER?

I add following code in meson-khadas-vim3.dtsi,and set &PWM_EF status to disabled

&spicc1 {
    status = "okay";
    pinctrl-names = "default";
    pinctrl-0 = <&spicc1_pins>;
    cs-gpios = <&gpio GPIOH_6 0>;

    spidev@0 {
        status = "okay";

        compatible = "linux,spidev";
        /* spi default max clock 100Mhz */
        spi-max-frequency = <100000000>;
        reg = <0>; 
    };   
};

Maybe need to modify other content in DTS flie for kernel 5.17?

check you kernel config 1st

# zgrep SPICC /proc/config.gz
CONFIG_SPI_MESON_SPICC=m

# lsmod | grep spicc
aml_spicc              24576  0 

maybe need modprobe aml_spicc

find CONFIG_SPI_MESON_SPICC=y,should i change it to M in kernel config and rebuild via fenix?

no need its already build-in ! need more check

my example for spi flash

cat /sys/class/spi_master/spi0/uevent 
OF_NAME=spi
OF_FULLNAME=/soc/apb4@fe000000/spi@56000
OF_COMPATIBLE_0=amlogic,meson-spifc
OF_COMPATIBLE_N=1
OF_ALIAS_0=spi0

cat /sys/class/spi_master/spi0/uevent

Is that mean i can use spi0?

for now,I am rebuilding images via fenix.

in your situation spi0 (just kernel device name and this name not related with dts alias node name ) works as spicc

How can I use it?

Forgive me for my ignorance of Linux devices,I could open devices in /dev/*.But i don’t know how to use devices in /sys/class/spi_master/spi0

I download code from

and just edit this device path to “/sys/class/spi_master/spi0/spi0.0”

gcc and run.It comes out:can't open device: Is a directory

image

I also want to know why no spi dev node in /dev?