From patchwork Wed Aug 12 07:20:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 1343549 X-Patchwork-Delegate: trini@ti.com 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; dmarc=none (p=none dis=none) header.from=xilinx.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=monstr-eu.20150623.gappssmtp.com header.i=@monstr-eu.20150623.gappssmtp.com header.a=rsa-sha256 header.s=20150623 header.b=vanuBdSa; 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)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4BRLhf1qzVz9sTF for ; Wed, 12 Aug 2020 17:20:47 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 68D7E812FE; Wed, 12 Aug 2020 09:20:38 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=xilinx.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=monstr-eu.20150623.gappssmtp.com header.i=@monstr-eu.20150623.gappssmtp.com header.b="vanuBdSa"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C5A8E819E8; Wed, 12 Aug 2020 09:20:36 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wr1-x442.google.com (mail-wr1-x442.google.com [IPv6:2a00:1450:4864:20::442]) (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 25ED5808B2 for ; Wed, 12 Aug 2020 09:20:33 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=xilinx.com Authentication-Results: phobos.denx.de; spf=none smtp.mailfrom=monstr@monstr.eu Received: by mail-wr1-x442.google.com with SMTP id r4so1016352wrx.9 for ; Wed, 12 Aug 2020 00:20:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monstr-eu.20150623.gappssmtp.com; s=20150623; h=sender:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=rahV4VYe5ehdink22YcUxVJiRuIb+jRK99jWpXg9K+A=; b=vanuBdSawpa7BtToz32hsbeBQGFGwPt7Sr87iVFPI3zUSqyjzEtXsqCJcsffmwqWBj JVNXTtFz29Ri9gCXozfSJ/AWye9m+pdLihLtJCzGS3y+NOKiiAooyGbtwNTeLKYyZ59p Z/7fPfL+NaQBrjxfIffPgcrpZxIqOBKcQ2x6OuScTmj4tlZC+JmZXWlDsRSk5e+PVkjg zVjO9E0VsoLvfPRf1CX9miQJ9wzpV3EyZiPFMSacStwabHM15r1isC6lrh0t6zBJziAL kzm5+jaIDzk7iGgDUigNW5ya0e/GlU+u4ldr9k+vwGnj/va8g7uWM+MW+awreTeKk1xr 3N+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :mime-version:content-transfer-encoding; bh=rahV4VYe5ehdink22YcUxVJiRuIb+jRK99jWpXg9K+A=; b=f714PJ6a5NYXtzW8EWTczWojCagECLlI2wwOXdGoJR0Z+2Wg0zYkQfxZo6BYRcVtV+ r+Tsqd6otn4fD2Fx87k4cLhLRHov11uVjhKKHL5q7DYdx0GJXAhmncelXjEobQsh5rH5 E79cxlc9edBV7oBGMg32sYP/OY9yBHZdqTVveKJJWpXz8r99j9Q1GBMxPhPpQnMtisF7 fBTgKHhHapWiaV2sI2U8YpZVajNmmgIY1tjcebwAmg3JmmG67nr/ec6YalNzBCRyYkKc HYX/lx67kHg46DTJiJREBgOm7dpCq9yZqGebwBfVtF31zJxJOkKQV+3UGkXfv+T8Hk+I vHFQ== X-Gm-Message-State: AOAM530xNKWTNR0oCtRjGdU2+Za4FAHDX66KEKG8auVcWPeVkG2+XdrF iAEEzppzxjK7ATbKBudC7WNsZJItIbTnPA== X-Google-Smtp-Source: ABdhPJx1eDb1VTTIyeAkERc/oJHVmeOpS/M3lH/XV4Ik5PH92Xj1hYD4AcS6R33EDq4jZQ1Htk+0Gg== X-Received: by 2002:a5d:54ce:: with SMTP id x14mr32229929wrv.52.1597216832382; Wed, 12 Aug 2020 00:20:32 -0700 (PDT) Received: from localhost (nat-35.starnet.cz. [178.255.168.35]) by smtp.gmail.com with ESMTPSA id h189sm2429337wme.17.2020.08.12.00.20.30 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 12 Aug 2020 00:20:31 -0700 (PDT) From: Michal Simek To: u-boot@lists.denx.de, git@xilinx.com Cc: Jon Hunter , Patrick Delaunay , Simon Glass , Yann Gautier Subject: [PATCH v2] firmware: psci: Do not bind driver if U-Boot runs in EL3 Date: Wed, 12 Aug 2020 09:20:24 +0200 Message-Id: <416dbbfb11eff42b6526b1ed00ed38851c756eb0.1597216822.git.michal.simek@xilinx.com> X-Mailer: git-send-email 2.28.0 MIME-Version: 1.0 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.3 at phobos.denx.de X-Virus-Status: Clean There is no reason to bind psci driver if U-Boot runs in EL3 because SMC/HVC instructions can't be called. That's why detect this state and don't let user to crash from prompt by performing reset or poweroff commands (if enabled). Signed-off-by: Michal Simek --- Changes in v2: - Add missing asm/system.h header Maybe there is a better way how to do it. Maybe do it in probe instead of bind. Feel free to comment but this doesn't look right behavior. Before: U-Boot SPL 2020.10-rc2-00032-gede802a09435 (Aug 12 2020 - 09:17:01 +0200) PMUFW: v1.1 Loading new PMUFW cfg obj (2024 bytes) EL Level: EL3 Multiboot: 0 Trying to boot from MMC2 spl: could not initialize mmc. error: -19 Trying to boot from MMC1 spl_load_image_fat_os: error reading image u-boot.bin, err - -2 U-Boot 2020.10-rc2-00032-gede802a09435 (Aug 12 2020 - 09:17:01 +0200) Model: ZynqMP ZCU104 RevC Board: Xilinx ZynqMP DRAM: 2 GiB PMUFW: v1.1 EL Level: EL3 Chip ID: zu7e Multiboot: 0 WDT: Started with servicing (60s timeout) NAND: 0 MiB MMC: mmc@ff170000: 0 In: serial@ff000000 Out: serial@ff000000 Err: serial@ff000000 Bootmode: LVL_SHFT_SD_MODE1 Reset reason: EXTERNAL Net: ZYNQ GEM: ff0e0000, mdio bus ff0e0000, phyaddr 12, interface rgmii-id eth0: ethernet@ff0e0000 Hit any key to stop autoboot: 0 ZynqMP> reset resetting ... "Synchronous Abort" handler, esr 0x5e000000 elr: 0000000008000194 lr : 0000000008000220 (reloc) elr: 000000007fec9194 lr : 000000007fec9220 x0 : 0000000084000009 x1 : 0000000000000000 x2 : 0000000000000000 x3 : 0000000000000000 x4 : 0000000000000000 x5 : 0000000000000000 x6 : 0000000000000000 x7 : 0000000000000000 x8 : 000000007deaedb0 x9 : 000000000000000c x10: 00000000000007c4 x11: 000000007deae92c x12: 0000000000000006 x13: 000000000001869f x14: 000000007deaedb0 x15: 0000000000000002 x16: 000000007ff2b20c x17: 0000000000000000 x18: 000000007deb8db0 x19: 0000000000000000 x20: 000000007ffb0ae0 x21: 0000000000000000 x22: 000000007debc600 x23: 0000000000000001 x24: 000000007ffc8158 x25: 0000000000000000 x26: 0000000000000000 x27: 0000000000000000 x28: 000000007debc640 x29: 000000007deaeaf0 Code: 00000000 f9020000 00000000 d4000003 (f94003e4) Resetting CPU ... ### ERROR ### Please RESET the board ### After: U-Boot SPL 2020.10-rc2-00033-g952b21dcb4b3 (Aug 12 2020 - 09:18:56 +0200) PMUFW: v1.1 Loading new PMUFW cfg obj (2024 bytes) EL Level: EL3 Multiboot: 0 Trying to boot from MMC2 spl: could not initialize mmc. error: -19 Trying to boot from MMC1 spl_load_image_fat_os: error reading image u-boot.bin, err - -2 U-Boot 2020.10-rc2-00033-g952b21dcb4b3 (Aug 12 2020 - 09:18:56 +0200) Model: ZynqMP ZCU104 RevC Board: Xilinx ZynqMP DRAM: 2 GiB PMUFW: v1.1 EL Level: EL3 Chip ID: zu7e Multiboot: 0 WDT: Started with servicing (60s timeout) NAND: 0 MiB MMC: mmc@ff170000: 0 In: serial@ff000000 Out: serial@ff000000 Err: serial@ff000000 Bootmode: LVL_SHFT_SD_MODE1 Reset reason: EXTERNAL Net: ZYNQ GEM: ff0e0000, mdio bus ff0e0000, phyaddr 12, interface rgmii-id eth0: ethernet@ff0e0000 Hit any key to stop autoboot: 0 ZynqMP> ZynqMP> reset resetting ... ZynqMP> --- drivers/firmware/psci.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/firmware/psci.c b/drivers/firmware/psci.c index 7d2e49fd3e3b..e6425e8ffcf4 100644 --- a/drivers/firmware/psci.c +++ b/drivers/firmware/psci.c @@ -19,6 +19,7 @@ #include #include #include +#include #define DRIVER_NAME "psci" @@ -73,6 +74,9 @@ static int psci_probe(struct udevice *dev) { const char *method; + if (current_el() == 3) + return -EINVAL; + method = ofnode_read_string(dev_ofnode(dev), "method"); if (!method) { pr_warn("missing \"method\" property\n");