From patchwork Fri Feb 26 07:35:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 1444791 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=cZiKe7mH; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Dn1gM1wQXz9sTD for ; Fri, 26 Feb 2021 18:36:24 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 0050880EFE; Fri, 26 Feb 2021 08:36:18 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="cZiKe7mH"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 6116680EFC; Fri, 26 Feb 2021 08:36:17 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-ej1-x633.google.com (mail-ej1-x633.google.com [IPv6:2a00:1450:4864:20::633]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 1537780EFC for ; Fri, 26 Feb 2021 08:36:14 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=bmeng.cn@gmail.com Received: by mail-ej1-x633.google.com with SMTP id jt13so13168073ejb.0 for ; Thu, 25 Feb 2021 23:36:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id; bh=aG8Q5GI6x/NWA77KcP0vUQuDcrCiwnI0BUrCKWKOPp0=; b=cZiKe7mHCW9i1hNnX5IfdJ+DI9AbCn8x1BrtODwSqUeBPRm3WJmUD1Vpy/Ae0b6NGV MEGKVVhmjWYNPQTaWblX472Zh2acDzs195tkhswIDGnjMDxDYl+t6nNTfI2wVJil5m7/ wrif9hv4j0kqwg5rOZumCBokKJ1dSIpPrISBJqyi8+Rk2xYbSpvnJoecXg7OAPN8twno Be59/Ms0p5vEVe1w/ZWdLe5AvGz0DD/v0XaRJ4gENBUdTrII9QXBjyZt9up+3O31rhsZ jug8b3qNGlpFwKgaYQ4Xrcv1xNxYodBIsOuxzPGh8T7XBk6yFYmvRrqj14p9Ejg9hs88 YyTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id; bh=aG8Q5GI6x/NWA77KcP0vUQuDcrCiwnI0BUrCKWKOPp0=; b=KCWngks7wlWYkrpijW6YHO3XhITb2TpbMjglNLND/SVYwuoyhOx43fk1YBLZ2r4NCp /kNvHWLa3KV59dTaN+spXpLyrcF4FXjKSMQetPM8A/vlod+ZmtbRyARrgPrHLS/6kVvg I9c+qRFgGLLXSxaMZd9clTBapaSheWkxu43LytSSRC2x7wUlRQw3cVUV2WyidpHUnM+5 uHozjok7ei1ExGWORB3QZyZLmwuujQ/Ofa90WiBsZl2jWcL7mKoI8+KTWjK2UnDM+D1U auHcbD7ovbOvxRaFYrZc2OvKpjwfeM6UtXYhn6TWCfY/h8OQO5ycyg0vGf8VeUNszwQN Sy1w== X-Gm-Message-State: AOAM532yMLQ+i2urHqI7eFEddUlBW+19TsXXf7jnk+MsOTrETO/FeIHq 3eMpAXT+3oOymDR5Y2DCFwY= X-Google-Smtp-Source: ABdhPJw5a+BrEyv3GIqEXl+5QfJxCkqNQkKxaHCrvcjf2oJLr9bQUvqJhftZl8+ouFj02c5BmA64Ew== X-Received: by 2002:a17:906:2a01:: with SMTP id j1mr1854960eje.416.1614324973782; Thu, 25 Feb 2021 23:36:13 -0800 (PST) Received: from pek-vx-bsp2.wrs.com (ec2-44-242-66-180.us-west-2.compute.amazonaws.com. [44.242.66.180]) by smtp.gmail.com with ESMTPSA id y8sm60350eju.31.2021.02.25.23.36.11 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 25 Feb 2021 23:36:13 -0800 (PST) From: Bin Meng To: Simon Glass , u-boot@lists.denx.de Subject: [PATCH 1/2] of: addr: Abort address translation for parent nodes missing 'ranges' Date: Fri, 26 Feb 2021 15:35:48 +0800 Message-Id: <1614324949-61314-1-git-send-email-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.7.4 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.4 at phobos.denx.de X-Virus-Status: Clean The implementation of of_translate_one() was taken from the one in Linux kernel drivers/of/address.c, and the Linux one added a quirk for Apple Macs that don't have the property in the parent node. Since U-Boot does not support Apple Macs, remove the comment block and adhere to the spec to abort the translation. Signed-off-by: Bin Meng Reviewed-by: Simon Glass --- drivers/core/of_addr.c | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/drivers/core/of_addr.c b/drivers/core/of_addr.c index 5bc6ca1..36cdfd3 100644 --- a/drivers/core/of_addr.c +++ b/drivers/core/of_addr.c @@ -173,25 +173,13 @@ static int of_translate_one(const struct device_node *parent, int rone; u64 offset = OF_BAD_ADDR; - /* - * Normally, an absence of a "ranges" property means we are - * crossing a non-translatable boundary, and thus the addresses - * below the current cannot be converted to CPU physical ones. - * Unfortunately, while this is very clear in the spec, it's not - * what Apple understood, and they do have things like /uni-n or - * /ht nodes with no "ranges" property and a lot of perfectly - * useable mapped devices below them. Thus we treat the absence of - * "ranges" as equivalent to an empty "ranges" property which means - * a 1:1 translation at that level. It's up to the caller not to try - * to translate addresses that aren't supposed to be translated in - * the first place. --BenH. - * - * As far as we know, this damage only exists on Apple machines, so - * This code is only enabled on powerpc. --gcl - */ - ranges = of_get_property(parent, rprop, &rlen); - if (ranges == NULL || rlen == 0) { + if (ranges == NULL) { + debug("no ranges; cannot translate\n"); + return 1; + } + + if (rlen == 0) { offset = of_read_number(addr, na); memset(addr, 0, pna * 4); debug("empty ranges; 1:1 translation\n");