From patchwork Fri Oct 29 14:40:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Rob Herring (Arm)" X-Patchwork-Id: 12592913 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D6F25C433EF for ; Fri, 29 Oct 2021 14:42:40 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 99962610CB for ; Fri, 29 Oct 2021 14:42:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 99962610CB Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=Y6zh33Fn2KRDp5B+V2cPHgwuiPS1sP+z2MmdLbi34EI=; b=qt5tNeELF+GTZt N46bM+Vmn/t76QdgkCKVuSpEpsLAB3vv7KFdmceUe+Dr0eIScw6Wlv94q2SZT8Z//GfqLAbb5z9rv he5IX5HNZtKRVt24pT8JsncbES2YIC8yPXLx8OyQyKwY62VXtU1sNdwE58r7LgOE9vVsLQS0U0Kxl dMHRb/aOufIBZ/N/R7qg98WcUwTPnH55Qa4gaOoUX+yAO/OvjMgf1QEqQkc+FBbpVFBEYJ3zDUZmI T+wl44L7eQl9XeNW8I0s6Mt5SoUcIe8MO4V7Wb9aiE2AkKCMv4jirtJYzAzgB4oA7CyzjG2NvUp9g 5vwdCTmFyLKzl7TyF01Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mgT43-00BE4g-MK; Fri, 29 Oct 2021 14:41:03 +0000 Received: from mail-oi1-f173.google.com ([209.85.167.173]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mgT3z-00BE4F-KI for linux-arm-kernel@lists.infradead.org; Fri, 29 Oct 2021 14:41:00 +0000 Received: by mail-oi1-f173.google.com with SMTP id k8so542487oik.7 for ; Fri, 29 Oct 2021 07:40:58 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=3gebI9WyuU8OUaX8TMoh2Ef+/vsaHXwERAjlolluABc=; b=qTA+1Ualy7ec2JOVDE01YTPGeCVmRJyoYOUIH6v3Wg58fAVX7TfBpnhT5YP3hg+c/S zqPQFV/m7fUrKdY4MjBNXJ/K+8qrrq+PZp8GjrG4XugOEqHw2wiDvtbYV6lNwIDqci+h V4FFjB5B52Ca9+yYEFXuZTwms+OoGEfZJS8Narra3CsYFcKYtI8Eib4imWlwJaJKFsmF hrc19Ue+0SbTIzbHP+WI49veFt2GExp9kLg8Yi7v9acU7OmhFAuDNsTimfH1ji46FH/F sfJOsU5y/qFZq+vdmxsCYCSTwFAkUV8SRA6Nu24p7oHZlXmQqdtWkPDLpkCvqslCCHMC N+pA== X-Gm-Message-State: AOAM532f5uI1YHhv51QuetgtKdK1k7qWS+CJdsyDWuyAoe0bnunCNSvK LhCaaM+cF3yx5najjng28A== X-Google-Smtp-Source: ABdhPJybuQuR3qhiwtVXlxqFj0vehW7/t3YWND7LpX/PMdUcxRoVda1CT52MnzIid1O5fPDKIdSG1Q== X-Received: by 2002:a05:6808:1a27:: with SMTP id bk39mr14179708oib.89.1635518458151; Fri, 29 Oct 2021 07:40:58 -0700 (PDT) Received: from xps15.herring.priv (66-90-148-213.dyn.grandenetworks.net. [66.90.148.213]) by smtp.googlemail.com with ESMTPSA id x13sm1774922ooj.37.2021.10.29.07.40.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Oct 2021 07:40:57 -0700 (PDT) From: Rob Herring To: Catalin Marinas , Will Deacon Cc: linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, Mark Rutland Subject: [PATCH v2] arm64: Simplify checking for populated DT Date: Fri, 29 Oct 2021 09:40:55 -0500 Message-Id: <20211029144055.2365814-1-robh@kernel.org> X-Mailer: git-send-email 2.32.0 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211029_074059_708308_ADDAFA20 X-CRM114-Status: GOOD ( 14.69 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Use of the of_scan_flat_dt() function predates libfdt and is discouraged as libfdt provides a nicer set of APIs. Rework dt_scan_depth1_nodes to use libfdt calls directly, and rename it to dt_is_stub() to reflect exactly what it checking. Cc: Catalin Marinas Cc: Will Deacon Signed-off-by: Rob Herring Reviewed-by: Mark Rutland --- v2: - Keep checking for only stub nodes arch/arm64/kernel/acpi.c | 35 ++++++++++++++--------------------- 1 file changed, 14 insertions(+), 21 deletions(-) diff --git a/arch/arm64/kernel/acpi.c b/arch/arm64/kernel/acpi.c index 1c9c2f7a1c04..7df733427e04 100644 --- a/arch/arm64/kernel/acpi.c +++ b/arch/arm64/kernel/acpi.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -62,29 +63,22 @@ static int __init parse_acpi(char *arg) } early_param("acpi", parse_acpi); -static int __init dt_scan_depth1_nodes(unsigned long node, - const char *uname, int depth, - void *data) +static bool __init dt_is_stub(void) { - /* - * Ignore anything not directly under the root node; we'll - * catch its parent instead. - */ - if (depth != 1) - return 0; + int node; - if (strcmp(uname, "chosen") == 0) - return 0; + fdt_for_each_subnode(node, initial_boot_params, 0) { + const char *name = fdt_get_name(initial_boot_params, node, NULL); + if (strcmp(name, "chosen") == 0) + continue; + if (strcmp(name, "hypervisor") == 0 && + of_flat_dt_is_compatible(node, "xen,xen")) + continue; - if (strcmp(uname, "hypervisor") == 0 && - of_flat_dt_is_compatible(node, "xen,xen")) - return 0; + return false; + } - /* - * This node at depth 1 is neither a chosen node nor a xen node, - * which we do not expect. - */ - return 1; + return true; } /* @@ -205,8 +199,7 @@ void __init acpi_boot_table_init(void) * and ACPI has not been [force] enabled (acpi=on|force) */ if (param_acpi_off || - (!param_acpi_on && !param_acpi_force && - of_scan_flat_dt(dt_scan_depth1_nodes, NULL))) + (!param_acpi_on && !param_acpi_force && !dt_is_stub())) goto done; /*