1Upreving Linux Kernel 2===================== 3 4Occasionally, the Gitlab CI needs a Linux Kernel update to enable new kernel 5features, device drivers, bug fixes etc to CI jobs. 6Kernel uprevs in Gitlab CI are relatively simple, but prone to lots of 7side-effects since many devices from different platforms are involved in the 8pipeline. 9 10Kernel repository 11----------------- 12 13The Linux Kernel used in the Gitlab CI is stored at the following repository: 14https://gitlab.freedesktop.org/gfx-ci/linux 15 16It is common that Mesa kernel brings some patches that were not merged on the 17Linux mainline, that is why Mesa has its own kernel version which should be used 18as the base for newer kernels. 19 20So, one should base the kernel uprev from the last tag used in the Mesa CI, 21please refer to `.gitlab-ci/container/gitlab-ci.yml` `KERNEL_URL` variable. 22Every tag has a standard naming: `vX.YZ-for-mesa-ci-<commit_short_SHA>`, which 23can be created via the command: 24 25:code:`git tag vX.YZ-for-mesa-ci-$(git rev-parse --short HEAD)` 26 27Building Kernel 28--------------- 29 30When Mesa CI generates a new rootfs image, the Linux Kernel is built based on 31the script located at `.gitlab-ci/container/build-kernel.sh`. 32 33Updating Kconfigs 34^^^^^^^^^^^^^^^^^ 35 36When a Kernel uprev happens, it is worth compiling and cross-compiling the 37Kernel locally, in order to update the Kconfigs accordingly. Remember that the 38resulting Kconfig is a merge between *Mesa CI Kconfig* and *Linux tree 39defconfig* made via `merge_config.sh` script located at Linux Kernel tree. 40 41Kconfigs location 42""""""""""""""""" 43 44+------------+--------------------------------------------+-------------------------------------+ 45| Platform | Mesa CI Kconfig location | Linux tree defconfig | 46+============+============================================+=====================================+ 47| arm | .gitlab-ci/container/arm.config | arch/arm/configs/multi_v7_defconfig | 48+------------+--------------------------------------------+-------------------------------------+ 49| arm64 | .gitlab-ci/container/arm64.config | arch/arm64/configs/defconfig | 50+------------+--------------------------------------------+-------------------------------------+ 51| x86-64 | .gitlab-ci/container/x86_64.config | arch/x86/configs/x86_64_defconfig | 52+------------+--------------------------------------------+-------------------------------------+ 53 54Updating image tags 55------------------- 56 57Every kernel uprev should update 3 image tags, located at two files. 58 59:code:`.gitlab-ci/container/gitlab-ci.yml` tag 60^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 61- **KERNEL_URL** for the location of the new kernel 62 63:code:`.gitlab-ci/image-tags.yml` tags 64^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 65- **KERNEL_ROOTFS_TAG** to rebuild rootfs with the new kernel 66- **DEBIAN_X86_TEST_GL_TAG** to ensure that the new rootfs is being used by the Gitlab x86 jobs 67 68Development routine 69------------------- 70 711. Compile the newer kernel locally for each platform. 722. Compile device trees for ARM platforms 733. Update Kconfigs. Are new Kconfigs necessary? Is CONFIG_XYZ_BLA deprecated? Does the `merge_config.sh` override an important config? 744. Push a new development branch to `Kernel repository`_ based on the latest kernel tag used in Gitlab CI 755. Hack `build-kernel.sh` script to clone kernel from your development branch 766. Update image tags. See `Updating image tags`_ 777. Run the entire CI pipeline, all the automatic jobs should be green. If some job is red or taking too long, you will need to investigate it and probably ask for help. 78 79When the Kernel uprev is stable 80^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 81 821. Push a new tag to Mesa CI `Kernel repository`_ 832. Update KERNEL_URL `debian/x86_test-gl` job definition 843. Open a merge request, if it is not opened yet 85 86Tips and Tricks 87--------------- 88 89Compare pipelines 90^^^^^^^^^^^^^^^^^ 91 92To have the most confidence that a kernel uprev does not break anything in Mesa, 93it is suggested that one runs the entire CI pipeline to check if the update affected the manual CI jobs. 94 95Step-by-step 96"""""""""""" 97 981. Create a local branch in the same git ref (should be the main branch) before branching to the kernel uprev kernel. 992. Push this test branch 1003. Run the entire pipeline against the test branch, even the manual jobs 1014. Now do the same for the kernel uprev branch 1025. Compare the job results. If a CI job turned red on your uprev branch, it means that the kernel update broke the test. Otherwise, it should be fine. 103 104Bare-metal custom kernels 105^^^^^^^^^^^^^^^^^^^^^^^^^ 106 107Some CI jobs have support to plug in a custom kernel by simply changing a variable. 108This is great, since rebuilding the kernel and rootfs may takes dozens of minutes. 109 110For example, freedreno jobs `gitlab.yml` manifest support a variable named 111`BM_KERNEL`. If one puts a gz-compressed kernel URL there, the job will use that 112kernel to boot the freedreno bare-metal devices. The same works for `BM_DTB` in 113the case of device tree binaries. 114 115Careful reading of the job logs 116^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 117 118Sometimes a job may turn to red for reasons unrelated to the kernel update, e.g. 119LAVA `tftp` timeout, problems with the freedesktop servers etc. 120So it is important to see the reason why the job turned red, and retry it if an 121infrastructure error has happened. 122