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 phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 675A0C7EE23 for ; Thu, 8 Jun 2023 10:59:47 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 14A6C847C2; Thu, 8 Jun 2023 12:59:45 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=kwiboo.se 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=kwiboo.se header.i=@kwiboo.se header.b="nf7+Zn1j"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id DD68B860A9; Thu, 8 Jun 2023 12:59:42 +0200 (CEST) Received: from s.wrqvtzvf.outbound-mail.sendgrid.net (s.wrqvtzvf.outbound-mail.sendgrid.net [149.72.126.143]) (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 46ED4842D0 for ; Thu, 8 Jun 2023 12:59:40 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=kwiboo.se Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=bounces+31435339-7456-u-boot=lists.denx.de@em2124.kwiboo.se DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kwiboo.se; h=from:subject:mime-version:to:cc:content-transfer-encoding: content-type:cc:content-type:from:subject:to; s=s1; bh=p8y+w4DFl/szKm0jpIWfl2RQOK47Iq8NOz3kcpDrO+A=; b=nf7+Zn1jpMhnqCPFZqYD6fBTCPGN2oQYzaiQxLEDsrwbiFvScnmTOgbY7MAyQnN/id8P wrA2h0YViGzK5Knn8FHjgvOBOGOXV5p8wZ+xlKvuWKl/1sfZX1AMrQF61VciANvECYEZC2 Gg1IR44ZyJOpgtiLmLuaK/ort5eZeKLoDoMz1tx+1mmrZgPv1wpwOciJm2IAwdBPrrdUmc lsiFfop/Mllg3qhSGPI3NWmPMMSw5lB2855px4z1cThCLms5z0pP587ZXxvD19QagI7vFe kbXCInkz2drpnriX3SxpPFt6+LxrhjZoMNApcsuX5kPJjzrVphjEF9MqTMBMH21g== Received: by filterdrecv-66949dbc98-kr5j5 with SMTP id filterdrecv-66949dbc98-kr5j5-1-6481B49A-40 2023-06-08 10:59:38.719844712 +0000 UTC m=+2459989.801111985 Received: from bionic.localdomain (unknown) by geopod-ismtpd-7 (SG) with ESMTP id TayEp2J1Q2y-MkmOm6intA Thu, 08 Jun 2023 10:59:38.414 +0000 (UTC) From: Jonas Karlman Subject: [PATCH] pinctrl: rockchip: Fix Data Abort exception in SPL Date: Thu, 08 Jun 2023 10:59:38 +0000 (UTC) Message-Id: <20230608105935.2403083-1-jonas@kwiboo.se> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 X-SG-EID: =?us-ascii?Q?TdbjyGynYnRZWhH+7lKUQJL+ZxmxpowvO2O9SQF5CwCVrYgcwUXgU5DKUU3QxA?= =?us-ascii?Q?fZekEeQsTe+RrMu3cja6a0h5dhWU=2FDpKkj0X2aD?= =?us-ascii?Q?og282WVqXSiXtzuhlRtHtyS6RDKfeviE3HDg+fV?= =?us-ascii?Q?Vn1mLnLSK5f4zthtJPB0b3m8tUpiOqcFDk+ETz4?= =?us-ascii?Q?qQohtxoYPjycfMRu8HuKXuKMlEbbinXi8=2FG+SUH?= =?us-ascii?Q?ujQBTl2eDj5gENLLRnyY1R3YJuYhIZFXcYc4tC?= To: Simon Glass , Philipp Tomsich , Kever Yang , Heiko Stuebner , David Wu Cc: Jagan Teki , Eugen Hristev , Jonas Karlman , Philipp Tomsich , u-boot@lists.denx.de X-Entity-ID: P7KYpSJvGCELWjBME/J5tg== Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=us-ascii X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.103.8 at phobos.denx.de X-Virus-Status: Clean Using CONFIG_ARMV8_SPL_EXCEPTION_VECTORS=y and CONFIG_OF_LIVE=y triggers a Data Abort exception from unaligned memory access when the pinctrl driver iterate node properties, e.g. for UART2 on RK3568. setting mux of GPIO0-24 to 1 setting mux of GPIO0-24 to 1 "Synchronous Abort" handler, esr 0x96000021 elr: 000000000000e554 lr : 000000000000e54c x 0: 0000000000000a5c x 1: 0000000000000a5c x 2: 0000000000000007 x 3: 0000000000000065 x 4: 0000000000000007 x 5: 0000000000022d4e x 6: 0000000000000a7c x 7: 00000000000227a4 x 8: 0000000000021cf0 x 9: 0000000000000a7c x10: 0000000000021cf0 x11: 0000000000021cf0 x12: 00000000003fda1c x13: 0000000000000007 x14: 00000000003fd9ec x15: 000000000001c0ff x16: 0000000007000000 x17: 00000000fdccd028 x18: 00000000003fde20 x19: 0000000000000018 x20: 0000000000020670 x21: 0000000000000000 x22: 00000000003fdb00 x23: 00000000003fef90 x24: 0000000000020688 x25: 0000000000000000 x26: 0000000000000001 x27: 00000000003ffc50 x28: 0000000000000000 x29: 00000000003fda60 Code: b94083e1 97ffd508 93407c01 37f81260 (f9401038) Resetting CPU ... Fix this by replacing the loop to access node properties with use of ofnode_for_each_prop instead of the current ifdef. Also continue to next prop instead of aborting at first sign of an unknown property. This fixes the Data Abort exception and also pinconf of e.g. pull and drive in SPL, e.g. for UART2 on RK3568. setting mux of GPIO0-24 to 1 setting mux of GPIO0-24 to 1 setting pull of GPIO0-24 to 5 setting mux of GPIO0-25 to 1 setting mux of GPIO0-25 to 1 setting pull of GPIO0-25 to 5 Fixes: e7ae4cf27a6d ("pinctrl: rockchip: Add common rockchip pinctrl driver") Signed-off-by: Jonas Karlman --- .../pinctrl/rockchip/pinctrl-rockchip-core.c | 28 ++++--------------- 1 file changed, 6 insertions(+), 22 deletions(-) diff --git a/drivers/pinctrl/rockchip/pinctrl-rockchip-core.c b/drivers/pinctrl/rockchip/pinctrl-rockchip-core.c index d9d61fdb726a..8ef089994f46 100644 --- a/drivers/pinctrl/rockchip/pinctrl-rockchip-core.c +++ b/drivers/pinctrl/rockchip/pinctrl-rockchip-core.c @@ -12,7 +12,6 @@ #include #include #include -#include #include "pinctrl-rockchip.h" @@ -433,13 +432,7 @@ static int rockchip_pinctrl_set_state(struct udevice *dev, int prop_len, param; const u32 *data; ofnode node; -#ifdef CONFIG_OF_LIVE - const struct device_node *np; - struct property *pp; -#else - int property_offset, pcfg_node; - const void *blob = gd->fdt_blob; -#endif + struct ofprop prop; data = dev_read_prop(config, "rockchip,pins", &count); if (count < 0) { debug("%s: bad array size %d\n", __func__, count); @@ -473,24 +466,15 @@ static int rockchip_pinctrl_set_state(struct udevice *dev, node = ofnode_get_by_phandle(conf); if (!ofnode_valid(node)) return -ENODEV; -#ifdef CONFIG_OF_LIVE - np = ofnode_to_np(node); - for (pp = np->properties; pp; pp = pp->next) { - prop_name = pp->name; - prop_len = pp->length; - value = pp->value; -#else - pcfg_node = ofnode_to_offset(node); - fdt_for_each_property_offset(property_offset, blob, pcfg_node) { - value = fdt_getprop_by_offset(blob, property_offset, - &prop_name, &prop_len); + ofnode_for_each_prop(prop, node) { + value = ofprop_get_property(&prop, &prop_name, &prop_len); if (!value) - return -ENOENT; -#endif + continue; + param = rockchip_pinconf_prop_name_to_param(prop_name, &default_val); if (param < 0) - break; + continue; if (prop_len >= sizeof(fdt32_t)) arg = fdt32_to_cpu(*(fdt32_t *)value); -- 2.40.1