From mboxrd@z Thu Jan 1 00:00:00 1970 X-GM-THRID: 6950929522725224448 X-Received: by 2002:a2e:819a:: with SMTP id e26mr1697699ljg.222.1618491149911; Thu, 15 Apr 2021 05:52:29 -0700 (PDT) X-BeenThere: isar-users@googlegroups.com Received: by 2002:a05:6512:39cc:: with SMTP id k12ls755689lfu.0.gmail; Thu, 15 Apr 2021 05:52:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw0KNOBBxgQ2g6c7sGt3vhr2OOhC9Q8fCQGUg9RIrDxzOnKWqeeFl3n/YFH82XxqKnd+XKO X-Received: by 2002:a19:4814:: with SMTP id v20mr2436003lfa.264.1618491148922; Thu, 15 Apr 2021 05:52:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618491148; cv=none; d=google.com; s=arc-20160816; b=vYiLP1g5+YG7NCqc6xDnI6imz+4lwteHdrj3haDm4DmyDEI0FyMK1Spg2R+Tvzg0hH ubAzvwnjmhb4i3ghAs7A1gLwBDkvITDYixz2ewxad6lZo1Gs6LgtG0M8nlTkPByW0KxT jT5dTkF/Ztz4CdKQ/jSVxPVl5uuHeeC3n8bBM+VngxUZ5CuhXaflWZTbd92WveY1XzAl KBclnSXovaHK5RgpF4FmlY+LRqVBILMJefFKAsVpoG2dXpB7rdz/u+ZzBsuBoXMthK5A 8jrm1BqJEWUYYlC3Q02xWZTE9Zc5BOgpAx5qz0BFxKsMwC1BCVCnzDSJwcMy+wVREJ1m 8V8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:content-language:in-reply-to:mime-version :user-agent:date:message-id:from:references:cc:to:subject; bh=HoiJ5OTo7PHIzKw83UBf62k94FioXJq1ojL+yvOIXE8=; b=zlir5GcKt1WMARIcFtzvjbUwq99P+0hxsSBXPYH0nzKc2pZsh72PlE4riDDfBRG8ux qci+zP8wV+6/nQWMHkmWSYi+fP/Pw+XLKyM057tNwK0Yx05JHEuHZNNUr5XrYqhzRmZs ThaTuR3w7wV3hbRkpq/5UDHiENYbpdkWvGHHRmc1nhsjcJSpniRl+8UoHEQmMMUQIjfY 5Lrfhfm9UgtAJex44GfHcyQfOJ/apXRPJDcyVZjKcReyfgsHECANGCI4Y1yNLmpcdxYu fdMYGQSok2oiP+xeQOmjqhhtiZo+LiV9jIjmoiedZ8zVwJQcPJMRJXjst3PqltsAGZa8 ThoA== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of raphael.lisicki@siemens.com designates 194.138.37.40 as permitted sender) smtp.mailfrom=raphael.lisicki@siemens.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=siemens.com Return-Path: Received: from gecko.sbs.de (gecko.sbs.de. [194.138.37.40]) by gmr-mx.google.com with ESMTPS id j7si166799ljc.6.2021.04.15.05.52.28 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 15 Apr 2021 05:52:28 -0700 (PDT) Received-SPF: pass (google.com: domain of raphael.lisicki@siemens.com designates 194.138.37.40 as permitted sender) client-ip=194.138.37.40; Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of raphael.lisicki@siemens.com designates 194.138.37.40 as permitted sender) smtp.mailfrom=raphael.lisicki@siemens.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=siemens.com Received: from mail2.sbs.de (mail2.sbs.de [192.129.41.66]) by gecko.sbs.de (8.15.2/8.15.2) with ESMTPS id 13FCqSmb018422 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 15 Apr 2021 14:52:28 +0200 Received: from [192.168.0.223] ([144.145.220.59]) by mail2.sbs.de (8.15.2/8.15.2) with ESMTP id 13FCfZqf023218; Thu, 15 Apr 2021 14:41:35 +0200 Subject: Re: [PATCH 1/1] Add support to build binary version of DKMS kernel modules To: "[ext] Henning Schild" , Jan Kiszka Cc: Felix Moessbauer , isar-users@googlegroups.com References: <20210414083617.20940-1-felix.moessbauer@siemens.com> <20210414083617.20940-2-felix.moessbauer@siemens.com> <20210414105208.2cc99156@md1za8fc.ad001.siemens.net> <20210415142627.04646da2@md1za8fc.ad001.siemens.net> From: Raphael Lisicki Message-ID: Date: Thu, 15 Apr 2021 14:41:35 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.1 MIME-Version: 1.0 In-Reply-To: <20210415142627.04646da2@md1za8fc.ad001.siemens.net> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: de-DE Content-Transfer-Encoding: 7bit X-TUID: lTOPOzKRAoA+ Hi, maybe V4L2 loopback could be this example module: https://packages.debian.org/buster/v4l2loopback-dkms best regards Raphael On 15.04.21 14:26, [ext] Henning Schild wrote: > Am Wed, 14 Apr 2021 11:03:50 +0200 > schrieb Jan Kiszka : > >> On 14.04.21 10:52, Henning Schild wrote: >>> Hi Felix, >>> >>> thanks for pushing this one upstream. >>> >>> We will need a testcase for it, so make sure to enter into >>> "scripts/ci_build.sh" >>> >>> I would suggest the virtualbox modules or maybe vmware modules >>> instead. This way we would probably have more distro coverage and >>> in fact have a useful example for people doing virtualbox (the one >>> i would prefer). Not sure that is possible or why you picked dpdk. >> >> None of those crappy modules will build on non-x86. We should look >> for a portable example. > > Yes ideally we find a dkms package that exists on all distros and > arches, not sure that exists. Would also allow testing the Isar > crossbuild on that feature. > > If cross causes issues ISAR_CROSS_COMPILE = "0" in the class might be > acceptable, would be to me. > > If we do not find such a generic module, all i said is that vbox is > probably more useful than igb_uio. And probably more available across > distros. > > Henning > > >> Jan >> >>> >>> Am Wed, 14 Apr 2021 10:36:17 +0200 >>> schrieb Felix Moessbauer : >>> >>>> This patch adds support to build and install a kernel module that >>>> is available via a debian DKMS package. >>>> As it is hard to directly build and install the package we create >>>> and distribute a meta package that is independent of the kernel >>>> version. In that package, we depend on the versioned prebuild >>>> kernel module package. >>>> >>>> To build the dkms module, we add two tasks and directly >>>> use dkms to build the debian package containing the binary module >>>> Then we just copy the binary-module debian package to the workdir, >>>> >>>> Signed-off-by: Felix Moessbauer >>>> --- >>>> .../example-dkms-module/igb-uio_20.11.bb | 14 ++++ >>>> meta/classes/dkms-module.bbclass | 68 >>>> +++++++++++++++++++ 2 files changed, 82 insertions(+) >>>> create mode 100644 >>>> meta-isar/recipes-kernel/example-dkms-module/igb-uio_20.11.bb >>>> create mode 100644 meta/classes/dkms-module.bbclass >>>> >>>> diff --git >>>> a/meta-isar/recipes-kernel/example-dkms-module/igb-uio_20.11.bb >>>> b/meta-isar/recipes-kernel/example-dkms-module/igb-uio_20.11.bb new >>>> file mode 100644 index 0000000..abb9922 --- /dev/null >>>> +++ b/meta-isar/recipes-kernel/example-dkms-module/igb-uio_20.11.bb >>>> @@ -0,0 +1,14 @@ >>>> +# Example recipe for building the binary version of a DKMS module >>>> +# >>>> +# This software is a part of ISAR. >>>> +# Copyright (c) Siemens AG, 2018 >>>> +# >>>> +# SPDX-License-Identifier: MIT >>>> + >>>> +inherit dkms-module >>>> + >>>> +PN .= "-${KERNEL_NAME}" >>>> + >>>> +#package name (without -dkms. E.g "dpdk-kmods" for package >>>> "dpdk-kmods-dkms") +DKMS_PACKAGE_NAME = "dpdk-kmods" >>>> +AUTOLOAD += "igb_uio" >>>> diff --git a/meta/classes/dkms-module.bbclass >>>> b/meta/classes/dkms-module.bbclass new file mode 100644 >>>> index 0000000..d1dbba9 >>>> --- /dev/null >>>> +++ b/meta/classes/dkms-module.bbclass >>>> @@ -0,0 +1,68 @@ >>>> +# This software is a part of ISAR. >>>> +# Copyright (C) 2021 Siemens AG >>>> +# >>>> +# SPDX-License-Identifier: MIT >>>> + >>>> +inherit dpkg-raw >>>> + >>>> +# Build and install a kernel module that is available via a debian >>>> DKMS package. +# As it is hard to directly build and install the >>>> package we create and distribute +# a meta package that is >>>> independent of the kernel version. +# In that package, we depend on >>>> the versioned prebuild kernel module package. +# >>>> +# To build the dkms module, we add two tasks and directly >>>> +# use dkms to build the debian package containing the binary >>>> module +# Then we just copy the binary-module debian package to >>>> the workdir, +# so ISAR's do_deploy_deb picks it up. >>>> + >>>> +#package name (without -dkms. E.g "dpdk-kmods" for package >>>> "dpdk-kmods-dkms") +DKMS_PACKAGE_NAME ?= "" >>>> +AUTOLOAD ?= "" >>>> + >>>> +DESCRIPTION ?= "Kernel module from DKMS package for ${PN}" >>>> +DEPENDS += "linux-headers-${KERNEL_NAME}" >>>> +DEBIAN_DEPENDS += "${DKMS_PACKAGE_NAME}-modules," >>>> +DEBIAN_BUILD_DEPENDS += "linux-headers-${KERNEL_NAME}, >>>> ${DKMS_PACKAGE_NAME}-dkms," + >>>> +# install configuration to auto-load the modules in ${AUTOLOAD} >>>> +do_install() { >>>> + # auto load the module >>>> + install -v -d ${D}/etc/modules-load.d >>>> + for module in "${AUTOLOAD}"; do >>>> + echo $module > ${D}/etc/modules-load.d/${PN}.conf >>>> + done >>> >>> I think this might need an "update-initramfs -u" in postinst, but i >>> am not sure, check the other autoloader code and see if you can >>> share. Such modules probably do not need early loading in initrd, >>> but "/etc/modules-load.d" is mirrored into the initrd so we should >>> not get out of sync. >>> It is important that both autoloaders do the same or similar things, >>> initrd could stay open if the other one also does not care. >>> >>> Henning >>> >>>> +} >>>> + >>>> +# build the binary kernel module and package as debian package >>>> (versioned) +do_module_build() { >>>> + # we have to find out the module version, e.g. >>>> dpdk-kmods/0~20201113+git -k 5.10.0-3-rt-amd64/x86_64 >>>> + REVISION=$(find >>>> ${BUILDCHROOT_DIR}/usr/src/${DKMS_PACKAGE_NAME}-* -type d -exec >>>> basename {} + | sed 's/${DKMS_PACKAGE_NAME}-//g') >>>> + if ! dpkg -s --root=${BUILDCHROOT_DIR} >>>> linux-headers-${KERNEL_NAME} | grep "Depends:.*linux-headers"; then >>>> + # custom kernels directly place their files in >>>> linux-image-KERNEL-NAME, instead >>>> + # of using a meta package + a versioned package with the >>>> resources >>>> + # The prebuild DKMS binary package depends on the >>>> versioned kernel package, >>>> + # but that is not available on custom kernels. Hence, we >>>> just remove the dependency. >>>> + bbnote "Building ${DKMS_PACKAGE_NAME} for custom kernel >>>> ${KERNEL_NAME}" >>>> + cp >>>> ${BUILDCHROOT_DIR}/etc/dkms/template-dkms-mkbmdeb/debian/control >>>> ${WORKDIR}/control.dkms.orig >>>> + sudo sed -i 's/, linux-image-KERNEL_VERSION//' >>>> ${BUILDCHROOT_DIR}/etc/dkms/template-dkms-mkbmdeb/debian/control >>>> + fi >>>> + # build the module for all installed kernels (should be just >>>> one) >>>> + sudo -E chroot ${BUILDCHROOT_DIR} dkms mkbmdeb >>>> ${DKMS_PACKAGE_NAME}/${REVISION} --all >>>> + DKMS_PACKAGE_VERSIONED=$(find >>>> ${BUILDCHROOT_DIR}/var/lib/dkms/${DKMS_PACKAGE_NAME}/ -name >>>> "${DKMS_PACKAGE_NAME}-modules*.deb" -exec dpkg -I {} + | grep >>>> "Package:" | awk '{print $2}') >>>> + if [ -z "$DKMS_PACKAGE_VERSIONED" ]; then >>>> + bberror "No prebuild dkms module found" >>>> + exit 1 >>>> + fi >>>> + # restore dkms template (if any) >>>> + cp ${WORKDIR}/control.dkms.orig >>>> ${BUILDCHROOT_DIR}/etc/dkms/template-dkms-mkbmdeb/debian/control || >>>> true +} + >>>> +# simply copy our module from the build tree to the expected >>>> output location +# of this recipe. Then, do_deploy_dep finds it >>>> and adds it to the +# debian isar repo >>>> +do_module_deploy() { >>>> + cp >>>> ${BUILDCHROOT_DIR}/var/lib/dkms/${DKMS_PACKAGE_NAME}/*/bmdeb/*.deb >>>> ${S}/../ +} + >>>> +addtask module_build after do_install_builddeps before >>>> do_dpkg_build +addtask module_deploy after do_module_build before >>>> do_deploy_deb >>> >> >