From de343c05994a7bf73805e3eb367e4087a20811d9 Mon Sep 17 00:00:00 2001
From: Luca Seritan <luca.seritan@huawei.com>
Date: Mon, 22 Aug 2022 17:45:05 +0200
Subject: [PATCH] Drop ACPI dependency for efi in linux-oniro and linux-yocto

qemuarm-efi is an efi machine that does not support ACPI. To fix this,
drop ACPI as a dependency in efi.cfg. This will not affect x86 machines
as ACPI is enabled by default for those. For arm64, apply an additional
patch that defaults to ACPI=y.

Signed-off-by: Andrei Gherzan <andrei.gherzan@huawei.com>
Signed-off-by: Luca Seritan <luca.seritan@huawei.com>
---
 .../recipes-kernel/linux/linux-oniro_5.10.bb  |  1 +
 .../linux/linux-yocto_%.bbappend              |  2 +
 .../fix-efi.cfg-drop-acpi-dependency.patch    | 54 +++++++++++++++++++
 ...efi.cfg-drop-acpi-dependency.patch.license |  3 ++
 4 files changed, 60 insertions(+)
 create mode 100644 meta-oniro-core/recipes-kernel/linux/linux/fix-efi.cfg-drop-acpi-dependency.patch
 create mode 100644 meta-oniro-core/recipes-kernel/linux/linux/fix-efi.cfg-drop-acpi-dependency.patch.license

diff --git a/meta-oniro-core/recipes-kernel/linux/linux-oniro_5.10.bb b/meta-oniro-core/recipes-kernel/linux/linux-oniro_5.10.bb
index a1abec46..951e2ec7 100644
--- a/meta-oniro-core/recipes-kernel/linux/linux-oniro_5.10.bb
+++ b/meta-oniro-core/recipes-kernel/linux/linux-oniro_5.10.bb
@@ -13,6 +13,7 @@ SRCREV_meta ?= "3b283fa8d4068ff68457b93e07d321c6c06d37e0"
 SRC_URI = "git://gitlab.eclipse.org/eclipse/oniro-core/linux.git;protocol=https;name=machine;branch=${KBRANCH}; \
            git://gitlab.eclipse.org/eclipse/oniro-core/linux-meta.git;type=kmeta;protocol=https;name=meta;branch=oniro/v5.10;destsuffix=${KMETA} \
            file://fix-gcc-plugins-with-gcc-11.patch \
+           file://fix-efi.cfg-drop-acpi-dependency.patch;patchdir=${KMETA} \
 "
 
 require recipes-kernel/linux/linux-oniro-tweaks-all.inc
diff --git a/meta-oniro-core/recipes-kernel/linux/linux-yocto_%.bbappend b/meta-oniro-core/recipes-kernel/linux/linux-yocto_%.bbappend
index 8392e3e6..2fc54b20 100644
--- a/meta-oniro-core/recipes-kernel/linux/linux-yocto_%.bbappend
+++ b/meta-oniro-core/recipes-kernel/linux/linux-yocto_%.bbappend
@@ -3,3 +3,5 @@
 # SPDX-License-Identifier: Apache-2.0
 
 require recipes-kernel/linux/linux-oniro-tweaks-all.inc
+
+SRC_URI += "file://fix-efi.cfg-drop-acpi-dependency.patch;patchdir=${KMETA}"
diff --git a/meta-oniro-core/recipes-kernel/linux/linux/fix-efi.cfg-drop-acpi-dependency.patch b/meta-oniro-core/recipes-kernel/linux/linux/fix-efi.cfg-drop-acpi-dependency.patch
new file mode 100644
index 00000000..03dbcd21
--- /dev/null
+++ b/meta-oniro-core/recipes-kernel/linux/linux/fix-efi.cfg-drop-acpi-dependency.patch
@@ -0,0 +1,54 @@
+From b6bb1d590565c188c7c7bfa7a202ede807616823 Mon Sep 17 00:00:00 2001
+From: Andrei Gherzan <andrei.gherzan@huawei.com>
+Date: Mon, 22 Aug 2022 13:45:59 +0200
+Subject: [PATCH] efi.cfg: Drop ACPI dependency
+
+On X86 this will have no impact as CONFIG_ACPI is enabled by default. On
+the other hand, ARM64 would be affected as they don't have the same
+default. The defconfig for arm64 recommends CONFIG_ACPI and this patch
+follows this recommendation in the qemuarm64 bsp configuration to fix
+ACPI-only EFI boots on this arch.
+
+arm (32bit) would also be unaffected as there is no ACPI support there
+at all. And this unconditional drop (CONFIG_ACPI) will actually fix a
+configuration warning when enabling EFI on a arm (32bit) machine:
+
+[INFO]: config 'CONFIG_ACPI' was set, but it wasn't assignable, check
+(parent) dependencies
+
+Upstream-status: Submitted [https://lists.yoctoproject.org/g/linux-yocto/message/11579] 
+Signed-off-by: Andrei Gherzan <andrei.gherzan@huawei.com>
+---
+ bsp/qemuarm64/qemuarm64.cfg | 7 +++++++
+ cfg/efi.cfg                 | 1 -
+ 2 files changed, 7 insertions(+), 1 deletion(-)
+
+diff --git a/bsp/qemuarm64/qemuarm64.cfg b/bsp/qemuarm64/qemuarm64.cfg
+index ef8d3ed0..03fdc58c 100644
+--- a/bsp/qemuarm64/qemuarm64.cfg
++++ b/bsp/qemuarm64/qemuarm64.cfg
+@@ -32,3 +32,10 @@ CONFIG_RTC_DRV_PL031=y
+ # PCI configs, needed for virtio-rng (and others)
+ CONFIG_PCI=y
+ CONFIG_PCI_HOST_GENERIC=y
++
++# arm64 defconfig suggests CONFIG_ACPI as default because it won't be enabled
++# with CONFIG_EFI - even though ACPI-only ARM64 EFI boots would break
++# otherwise. We also do the same here as a sane default.
++CONFIG_ARCH_SUPPORTS_ACPI=y
++CONFIG_ACPI=y
++
+diff --git a/cfg/efi.cfg b/cfg/efi.cfg
+index d3dfd603..d729cbe9 100644
+--- a/cfg/efi.cfg
++++ b/cfg/efi.cfg
+@@ -3,7 +3,6 @@
+
+ # Dependencies
+ CONFIG_PCI=y
+-CONFIG_ACPI=y
+
+ # Enable basic EFI support
+ CONFIG_EFI=y
+--
+2.25.1
diff --git a/meta-oniro-core/recipes-kernel/linux/linux/fix-efi.cfg-drop-acpi-dependency.patch.license b/meta-oniro-core/recipes-kernel/linux/linux/fix-efi.cfg-drop-acpi-dependency.patch.license
new file mode 100644
index 00000000..51f02468
--- /dev/null
+++ b/meta-oniro-core/recipes-kernel/linux/linux/fix-efi.cfg-drop-acpi-dependency.patch.license
@@ -0,0 +1,3 @@
+# SPDX-FileCopyrightText: Huawei Inc.
+#
+# SPDX-License-Identifier: GPL-2.0-only
-- 
GitLab