From patchwork Thu Apr 30 10:06:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrice CHOTARD X-Patchwork-Id: 1280131 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=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=st.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=st.com header.i=@st.com header.a=rsa-sha256 header.s=STMicroelectronics header.b=GIFudSRz; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (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 49CWKS1Zf6z9sSd for ; Thu, 30 Apr 2020 20:07:56 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 0AD51821F1; Thu, 30 Apr 2020 12:06:58 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=st.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=st.com header.i=@st.com header.b="GIFudSRz"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C29A1821EC; Thu, 30 Apr 2020 12:06:47 +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=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mx07-00178001.pphosted.com (mx08-00178001.pphosted.com [91.207.212.93]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 9A67E821DF for ; Thu, 30 Apr 2020 12:06:28 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=st.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=patrice.chotard@st.com Received: from pps.filterd (m0046660.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 03UA2jdO025883; Thu, 30 Apr 2020 12:06:23 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=st.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=STMicroelectronics; bh=8+vgnkUvr01MpxDSdgbfO4NsTUAmBzr5zjyZRulm1S4=; b=GIFudSRzCQf3rq1Jz5yKTBIytHnLEne8HT6+Yczc9GZtH+FR6LA6sjkTFBx+2k60t/3D m49Cv4rDsjBfCfVDhFR8isNqTxyJthbarVaNUvs3BTZaboBLgHavbfjDJK+PaqOkIz9W Y3PYWgRK7MEPc/i2jw+TgEjo6ZWGwQkA+lGEngaH0h81MgJzQoB7kdtPv5LLMHB9mgXs eV3rFhLnIrIta7J0A47KYQ/0D/d9iZ6X6ckHB+KT32TXANHiBsqdFFvEuEHdMYS8/tJA bLsSxjCxoVy/eJHJSf9v5L4tNWoyHN52N4d+C0pYofOkT7deap3uGrknjWqBAARDckjv 7g== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 30mhq6bhst-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 30 Apr 2020 12:06:23 +0200 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id E9DCB100038; Thu, 30 Apr 2020 12:06:22 +0200 (CEST) Received: from Webmail-eu.st.com (sfhdag6node3.st.com [10.75.127.18]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id DE43E2AE6AD; Thu, 30 Apr 2020 12:06:22 +0200 (CEST) Received: from localhost (10.75.127.45) by SFHDAG6NODE3.st.com (10.75.127.18) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Thu, 30 Apr 2020 12:06:22 +0200 From: Patrice Chotard To: CC: Patrice CHOTARD , Patrick DELAUNAY , U-Boot STM32 , Jean-Jacques Hiblot , Simon Glass Subject: [PATCH v4 1/5] cmd: bind: allow to bind driver with driver data Date: Thu, 30 Apr 2020 12:06:15 +0200 Message-ID: <20200430100619.28557-2-patrice.chotard@st.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200430100619.28557-1-patrice.chotard@st.com> References: <20200430100619.28557-1-patrice.chotard@st.com> MIME-Version: 1.0 X-Originating-IP: [10.75.127.45] X-ClientProxiedBy: SFHDAG5NODE3.st.com (10.75.127.15) To SFHDAG6NODE3.st.com (10.75.127.18) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138, 18.0.676 definitions=2020-04-30_05:2020-04-30, 2020-04-30 signatures=0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.30rc1 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.2 at phobos.denx.de X-Virus-Status: Clean Initial implementation invokes device_bind_with_driver_data() with driver_data parameter equal to 0. For driver with driver data, the bind command can't bind correctly this driver or even worse causes data abort as shown below: As example, for debug purpose on STM32MP1 platform, ethernet (dwc_eth_qos.c) driver needed to be unbinded/binded. This driver is using driver data: static const struct udevice_id eqos_ids[] = { { .compatible = "nvidia,tegra186-eqos", .data = (ulong)&eqos_tegra186_config }, { .compatible = "snps,dwmac-4.20a", .data = (ulong)&eqos_stm32_config }, { } }; After unbinding/binding this driver and probing it (with the dhcp command), we got a prefetch abort as below: STM32MP> unbind eth ethernet@5800a000 STM32MP> bind /soc/ethernet@5800a000 eth_eqos STM32MP> dhcp prefetch abort pc : [<4310801c>] lr : [] reloc pc : [<035ba01c>] lr : [] sp : fdaf19b0 ip : ffcea83c fp : 00000001 r10: ffcfd4a0 r9 : fdaffed0 r8 : 00000000 r7 : ffcff304 r6 : fdc63220 r5 : 00000000 r4 : fdc5b108 r3 : 43108020 r2 : 00003d39 r1 : ffcea544 r0 : fdc63220 Flags: nZCv IRQs off FIQs off Mode SVC_32 Code: data abort pc : [] lr : [] reloc pc : [] lr : [] sp : fdaf18b8 ip : 00000000 fp : 00000001 r10: ffcd69b2 r9 : fdaffed0 r8 : ffcd69aa r7 : 00000000 r6 : 00000008 r5 : 4310801c r4 : fffffffc r3 : 00000001 r2 : 00000028 r1 : 00000000 r0 : 00000006 Flags: NzCv IRQs on FIQs on Mode SVC_32 (T) Code: 2f00 d1e9 2c00 dce9 (f855) 2024 Resetting CPU ... Signed-off-by: Patrice Chotard Cc: Jean-Jacques Hiblot Reviewed-by: Simon Glass --- Changes in v4: None Changes in v3: None Changes in v2: - add a bind command test - add bind command documentation in doc/driver/model/bind.rst - simplify patch 1 by using lists_bind_fdt() cmd/bind.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cmd/bind.c b/cmd/bind.c index 44a5f17f0d..0aefc531d8 100644 --- a/cmd/bind.c +++ b/cmd/bind.c @@ -7,6 +7,7 @@ #include #include #include +#include #include static int bind_by_class_index(const char *uclass, int index, @@ -150,8 +151,8 @@ static int bind_by_node_path(const char *path, const char *drv_name) } ofnode = ofnode_path(path); - ret = device_bind_with_driver_data(parent, drv, ofnode_get_name(ofnode), - 0, ofnode, &dev); + ret = lists_bind_fdt(parent, ofnode, &dev, false); + if (!dev || ret) { printf("Unable to bind. err:%d\n", ret); return ret;