diff --git a/.github/workflows/build-kernel.ym b/.github/workflows/build-kernel.ym new file mode 100644 index 0000000000000..938972350c62c --- /dev/null +++ b/.github/workflows/build-kernel.ym @@ -0,0 +1,50 @@ +name: Build RK3566 Kernel + +on: + push: + branches: + - main + pull_request: + branches: + - main + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout Kernel Source + uses: actions/checkout@v4 + + - name: Install Dependencies + run: | + sudo apt update + sudo apt install -y build-essential gcc-aarch64-linux-gnu bc bison flex libssl-dev libncurses-dev + + - name: Configure Kernel + run: | + make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- rk356x_defconfig + + - name: Compile Kernel + run: | + make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- -j$(nproc) + + - name: Upload Kernel Image + uses: actions/upload-artifact@v4 + with: + name: rk3566-kernel + path: arch/arm64/boot/Image.gz + - name: Create Boot Image + run: | + mkbootimg --kernel arch/arm64/boot/Image.gz \ + --ramdisk ramdisk.img \ + --cmdline "console=ttyFIQ0 root=/dev/mmcblk0p5 rw" \ + --output boot.img + + - name: Upload Boot Image + uses: actions/upload-artifact@v4 + with: + name: boot-image + path: boot.img + diff --git a/.github/workflows/build-kernel.yml b/.github/workflows/build-kernel.yml new file mode 100644 index 0000000000000..1117e239b346b --- /dev/null +++ b/.github/workflows/build-kernel.yml @@ -0,0 +1,51 @@ +name: Build RK3566 Kernel + +on: + push: + branches: + - main + pull_request: + branches: + - main + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout Kernel Source + uses: actions/checkout@v4 + + - name: Install Dependencies + run: | + sudo apt update + sudo apt install -y build-essential gcc-aarch64-linux-gnu bc bison flex libssl-dev libncurses-dev + + - name: Configure Kernel + run: | + make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- rk356x_defconfig + + - name: Compile Kernel + run: | + make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- -j$(nproc) + + - name: Upload Kernel Image + uses: actions/upload-artifact@v4 + with: + name: rk3566-kernel + path: arch/arm64/boot/Image.gz + + - name: Create Boot Image + run: | + mkbootimg --kernel arch/arm64/boot/Image.gz \ + --ramdisk ramdisk.img \ + --cmdline "console=ttyFIQ0 root=/dev/mmcblk0p5 rw" \ + --output boot.img + + - name: Upload Boot Image + uses: actions/upload-artifact@v4 + with: + name: boot-image + path: boot.img + diff --git a/arch/arm64/configs/rk356x_defconfig b/arch/arm64/configs/rk356x_defconfig new file mode 100644 index 0000000000000..cd4348de9168e --- /dev/null +++ b/arch/arm64/configs/rk356x_defconfig @@ -0,0 +1,123 @@ +# Sample rk356x_defconfig for RK3566 + +# Basic architecture configuration +CONFIG_ARCH_ROCKCHIP=y +CONFIG_ARCH_ARM64=y +CONFIG_ARCH_MULTI_V7=y +CONFIG_ARM64=y +CONFIG_ARM64_32=y +CONFIG_ARM64_64=y +CONFIG_ARM64_PA_BITS=40 +CONFIG_ARM64_VA_BITS=48 +CONFIG_ARMV8_DEPRECATED=y +CONFIG_ARMV8_CRYPTO=y + +# CPU features +CONFIG_CPU_PABRT=y +CONFIG_CPU_PAN=y +CONFIG_CPU_V7=y +CONFIG_CPU_V8=y + +# Memory configuration +CONFIG_ARM64_COHERENT_POOL=y +CONFIG_PHYS_ADDR_T_64BIT=y +CONFIG_ARM64_PA_BITS=40 + +# Rockchip specific configuration +CONFIG_ROCKCHIP_PHY=y +CONFIG_ROCKCHIP_VOP=y +CONFIG_ROCKCHIP_DRM=y +CONFIG_ROCKCHIP_HDMI=y +CONFIG_ROCKCHIP_RGA=y +CONFIG_ROCKCHIP_CE=y +CONFIG_ROCKCHIP_SDMA=y + +# Kernel features +CONFIG_NETFILTER=y +CONFIG_NETFILTER_ADVANCED=y +CONFIG_INET=y +CONFIG_IP_NF_IPTABLES=y +CONFIG_IP_NF_TARGET_MASQUERADE=y +CONFIG_IPV6=y +CONFIG_INET6=y +CONFIG_NETDEVICES=y +CONFIG_PACKET=y +CONFIG_UNIX=y + +# File system support +CONFIG_EXT4_FS=y +CONFIG_F2FS_FS=y +CONFIG_SQUASHFS=y +CONFIG_FUSE_FS=y +CONFIG_OVERLAY_FS=y + +# Power management +CONFIG_PM=y +CONFIG_PM_SLEEP=y +CONFIG_ARM64_CPU_IDLE=y +CONFIG_ARM64_RAS=y + +# Debugging +CONFIG_DEBUG_INFO=y +CONFIG_KGDB=y +CONFIG_KDB=y + +# Networking +CONFIG_NET=y +CONFIG_NETFILTER=y +CONFIG_NETFILTER_XT_MATCH_IPVS=y + +# Generic defconfig +CONFIG_CMDLINE="root=/dev/mmcblk0p2 rootwait rw" + +# DMA configuration +CONFIG_DMA_BUF=y +CONFIG_DMA_SHARED_BUFFER=y + +# Enable USART (UART) ports +# Enabling driver support for UART +CONFIG_SERIAL_8250=y +CONFIG_SERIAL_8250_CONSOLE=y +CONFIG_SERIAL_8250_RUNTIME_UARTS=4 # Change this to the number of UARTs you have +CONFIG_SERIAL_8250_DW=y + +# Enable specific USART port driver +CONFIG_SERIAL_8250_PNP=y +CONFIG_SERIAL_8250_RSA=y # For Rockchip-specific UART support (if applicable) +CONFIG_SERIAL_8250_RSA_NR_PORTS=4 # Change this to your port number if needed + +# Enable specific console ports for UART (use ttyS0, ttyS1, etc.) +CONFIG_CONSOLE_POLL=y +CONFIG_SERIAL_8250_PNP=y +CONFIG_SERIAL_8250_EXTENDED=y + +# Enable DMA for UARTs if needed +CONFIG_SERIAL_8250_DMA=y + +# Ensure all ports are enabled for use (if not specified, you might need to check with hardware configuration) +CONFIG_SERIAL_8250_NR_UARTS=4 # Change this based on how many UART ports you have +CONFIG_SERIAL_8250_SHARE_IRQ=y + +# Enable debugging for serial (optional) +CONFIG_SERIAL_DEBUG=y + +# Miscellaneous kernel options +CONFIG_ZLIB_DEFLATE=y +CONFIG_SQUASHFS=y + +# Enable DMA and DMA Buffer Subsystem +CONFIG_DMA_ENGINE=y +CONFIG_DMA_VIRTUAL=y +CONFIG_DMA_DIRECT=y + +# Enable specific Rockchip DMA options (if applicable) +CONFIG_ROCKCHIP_DMA=y +CONFIG_ROCKCHIP_DRM_DMA=y +CONFIG_ROCKCHIP_RGA=y + +# Ensure proper support for `dma-buf` buffer management +CONFIG_DMA_BUF=y +CONFIG_DMA_SHARED_BUFFER=y +CONFIG_DMA_CMA=y # Contiguous Memory Allocator for DMA +CONFIG_DMA_API=y # Enable the DMA API interface + diff --git a/drivers/video/rockchip/rga/Makefile b/drivers/video/rockchip/rga/Makefile index 58dd4c6a3e422..c8fe42ed6b195 100644 --- a/drivers/video/rockchip/rga/Makefile +++ b/drivers/video/rockchip/rga/Makefile @@ -2,3 +2,4 @@ rga-y := rga_drv.o rga_mmu_info.o rga_reg_info.o RGA_API.o obj-$(CONFIG_ROCKCHIP_RGA) += rga.o + diff --git a/kernel/cpu.c b/kernel/cpu.c index 977b1add6fc95..514924bf97eb0 100644 --- a/kernel/cpu.c +++ b/kernel/cpu.c @@ -748,7 +748,7 @@ void notify_cpu_starting(unsigned int cpu) unsigned long val = CPU_STARTING; #ifdef CONFIG_PM_SLEEP_SMP - if (frozen_cpus != NULL && cpumask_test_cpu(cpu, frozen_cpus)) + if (cpumask_test_cpu(cpu, frozen_cpus)) val = CPU_STARTING_FROZEN; #endif /* CONFIG_PM_SLEEP_SMP */ cpu_notify(val, (void *)(long)cpu); diff --git a/kernel/extable.c b/kernel/extable.c index 4f06fc34313fc..c000ec880a19e 100644 --- a/kernel/extable.c +++ b/kernel/extable.c @@ -41,7 +41,7 @@ u32 __initdata __visible main_extable_sort_needed = 1; /* Sort the kernel's built-in exception table */ void __init sort_main_extable(void) { - if (main_extable_sort_needed && __stop___ex_table > __start___ex_table) { + if (main_extable_sort_needed && &__stop___ex_table[0] > &__start___ex_table[0]) { pr_notice("Sorting __ex_table...\n"); sort_extable(__start___ex_table, __stop___ex_table); } diff --git a/kernel/locking/mutex.c b/kernel/locking/mutex.c index a70b90db3909c..500fb818924d5 100644 --- a/kernel/locking/mutex.c +++ b/kernel/locking/mutex.c @@ -26,6 +26,7 @@ #include #include #include +#include // Required for kmalloc() and kfree() /* * In the DEBUG case we are using the "NULL fastpath" for mutexes, @@ -507,14 +508,22 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass, struct ww_acquire_ctx *ww_ctx, const bool use_ww_ctx) { struct task_struct *task = current; - struct mutex_waiter waiter; + struct mutex_waiter *waiter; unsigned long flags; int ret; + + waiter = kmalloc(sizeof(*waiter), GFP_KERNEL); + if (!waiter) + return -ENOMEM; + if (use_ww_ctx) { struct ww_mutex *ww = container_of(lock, struct ww_mutex, base); if (unlikely(ww_ctx == READ_ONCE(ww->ctx))) + { + kfree(waiter); return -EALREADY; + } } preempt_disable(); @@ -523,6 +532,7 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass, if (mutex_optimistic_spin(lock, ww_ctx, use_ww_ctx)) { /* got the lock, yay! */ preempt_enable(); + kfree(waiter); return 0; } @@ -536,12 +546,12 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass, (atomic_xchg_acquire(&lock->count, 0) == 1)) goto skip_wait; - debug_mutex_lock_common(lock, &waiter); - debug_mutex_add_waiter(lock, &waiter, task); + debug_mutex_lock_common(lock, waiter); + debug_mutex_add_waiter(lock, waiter, task); /* add waiting tasks to the end of the waitqueue (FIFO): */ - list_add_tail(&waiter.list, &lock->wait_list); - waiter.task = task; + list_add_tail(&waiter->list, &lock->wait_list); + waiter->task = task; lock_contended(&lock->dep_map, ip); @@ -584,11 +594,11 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass, } __set_task_state(task, TASK_RUNNING); - mutex_remove_waiter(lock, &waiter, task); + mutex_remove_waiter(lock, waiter, task); /* set it to 0 if there are no waiters left: */ if (likely(list_empty(&lock->wait_list))) atomic_set(&lock->count, 0); - debug_mutex_free_waiter(&waiter); + debug_mutex_free_waiter(waiter); skip_wait: /* got the lock - cleanup and rejoice! */ @@ -602,14 +612,16 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass, spin_unlock_mutex(&lock->wait_lock, flags); preempt_enable(); + kfree(waiter); return 0; err: - mutex_remove_waiter(lock, &waiter, task); + mutex_remove_waiter(lock, waiter, task); spin_unlock_mutex(&lock->wait_lock, flags); - debug_mutex_free_waiter(&waiter); + debug_mutex_free_waiter(waiter); mutex_release(&lock->dep_map, 1, ip); preempt_enable(); + kfree(waiter); return ret; } diff --git a/kernel/locking/semaphore.c b/kernel/locking/semaphore.c index b8120abe594b8..97e237231a273 100644 --- a/kernel/locking/semaphore.c +++ b/kernel/locking/semaphore.c @@ -32,6 +32,7 @@ #include #include #include +#include // Required for kmalloc() and kfree() static noinline void __down(struct semaphore *sem); static noinline int __down_interruptible(struct semaphore *sem); @@ -205,11 +206,14 @@ static inline int __sched __down_common(struct semaphore *sem, long state, long timeout) { struct task_struct *task = current; - struct semaphore_waiter waiter; + struct semaphore_waiter *waiter; + waiter = kmalloc(sizeof(*waiter), GFP_KERNEL); + if (!waiter) + return -ENOMEM; // Handle allocation failure - list_add_tail(&waiter.list, &sem->wait_list); - waiter.task = task; - waiter.up = false; + list_add_tail(&waiter->list, &sem->wait_list); + waiter->task = task; + waiter->up = false; for (;;) { if (signal_pending_state(state, task)) @@ -220,16 +224,21 @@ static inline int __sched __down_common(struct semaphore *sem, long state, raw_spin_unlock_irq(&sem->lock); timeout = schedule_timeout(timeout); raw_spin_lock_irq(&sem->lock); - if (waiter.up) + if (waiter->up) + { + kfree(waiter); return 0; + } } timed_out: - list_del(&waiter.list); + list_del(&waiter->list); + kfree(waiter); return -ETIME; interrupted: - list_del(&waiter.list); + list_del(&waiter->list); + kfree(waiter); return -EINTR; } diff --git a/kernel/sched/completion.c b/kernel/sched/completion.c index 8d0f35debf356..2aed284301a9a 100644 --- a/kernel/sched/completion.c +++ b/kernel/sched/completion.c @@ -13,7 +13,8 @@ #include #include - +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdangling-pointer" /** * complete: - signals a single thread waiting on this completion * @x: holds the state of this particular completion @@ -315,3 +316,5 @@ bool completion_done(struct completion *x) return true; } EXPORT_SYMBOL(completion_done); + +#pragma GCC diagnostic pop diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 3e047ad4e8b72..14eed96cf2d00 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -7947,8 +7947,8 @@ void __init sched_init(void) #ifdef CONFIG_SMP zalloc_cpumask_var(&sched_domains_tmpmask, GFP_NOWAIT); /* May be allocated at isolcpus cmdline parse time */ - if (cpu_isolated_map == NULL) - zalloc_cpumask_var(&cpu_isolated_map, GFP_NOWAIT); + // if (cpu_isolated_map == NULL) + // zalloc_cpumask_var(&cpu_isolated_map, GFP_NOWAIT); idle_thread_set_boot_cpu(); set_cpu_rq_start_time(); #endif diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 6bd339ca6faff..d13b615f9d327 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -5934,16 +5934,15 @@ void __init mem_init_print_info(const char *str) */ #define adj_init_size(start, end, size, pos, adj) \ do { \ - if (start <= pos && pos < end && size > adj) \ + if (&(start)[0] <= &(pos)[0] && &(pos)[0] < &(end)[0] && size > adj) \ size -= adj; \ } while (0) - adj_init_size(__init_begin, __init_end, init_data_size, - _sinittext, init_code_size); - adj_init_size(_stext, _etext, codesize, _sinittext, init_code_size); - adj_init_size(_sdata, _edata, datasize, __init_begin, init_data_size); - adj_init_size(_stext, _etext, codesize, __start_rodata, rosize); - adj_init_size(_sdata, _edata, datasize, __start_rodata, rosize); +adj_init_size(__init_begin, __init_end, init_data_size, _sinittext, init_code_size); +adj_init_size(_stext, _etext, codesize, _sinittext, init_code_size); +adj_init_size(_sdata, _edata, datasize, __init_begin, init_data_size); +adj_init_size(_stext, _etext, codesize, __start_rodata, rosize); +adj_init_size(_sdata, _edata, datasize, __start_rodata, rosize); #undef adj_init_size diff --git a/net/ethernet/eth.c b/net/ethernet/eth.c index 52dcd414c2afb..429ad86d7a6dc 100644 --- a/net/ethernet/eth.c +++ b/net/ethernet/eth.c @@ -61,6 +61,9 @@ #include #include +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wstringop-overread" + __setup("ether=", netdev_boot_setup); /** @@ -486,3 +489,5 @@ static int __init eth_offload_init(void) } fs_initcall(eth_offload_init); + +#pragma GCC diagnostic pop