Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D3EB1C07E95 for ; Wed, 7 Jul 2021 04:56:09 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id C354B619A5 for ; Wed, 7 Jul 2021 04:56:08 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C354B619A5 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=ti.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 76F3F82DB2; Wed, 7 Jul 2021 06:56:06 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=ti.com header.i=@ti.com header.b="HwpejWf8"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id D826082DB4; Wed, 7 Jul 2021 06:56:04 +0200 (CEST) Received: from fllv0016.ext.ti.com (fllv0016.ext.ti.com [198.47.19.142]) (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 68C5082C91 for ; Wed, 7 Jul 2021 06:56:00 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=a-govindraju@ti.com Received: from lelv0265.itg.ti.com ([10.180.67.224]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id 1674twnA076742; Tue, 6 Jul 2021 23:55:58 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1625633758; bh=2gY42UjvSPk32989bDbZKm2ZGXbXpHxWNp1mKgseNAA=; h=Subject:To:CC:References:From:Date:In-Reply-To; b=HwpejWf8X1LiHw0R2M5AaFk2sEigaKC58izOJwPC4r1+mkFVf8sLdEOawqx6PZuD9 tC/ICJ9DNlZquWsSPbGOn+FNTMA80S3DHqW7qAeJdDfZ/IZaMszKSzFH2KBaTwVyRl yC12sxB6Rcp1Lgd5LpC7AObsk8dnawrLsppXMEdw= Received: from DLEE101.ent.ti.com (dlee101.ent.ti.com [157.170.170.31]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 1674twRd115215 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 6 Jul 2021 23:55:58 -0500 Received: from DLEE102.ent.ti.com (157.170.170.32) by DLEE101.ent.ti.com (157.170.170.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.2; Tue, 6 Jul 2021 23:55:58 -0500 Received: from lelv0326.itg.ti.com (10.180.67.84) by DLEE102.ent.ti.com (157.170.170.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.2 via Frontend Transport; Tue, 6 Jul 2021 23:55:58 -0500 Received: from [10.250.150.189] (ileax41-snat.itg.ti.com [10.172.224.153]) by lelv0326.itg.ti.com (8.15.2/8.15.2) with ESMTP id 1674trM8017290; Tue, 6 Jul 2021 23:55:54 -0500 Subject: Re: [PATCH v2 1/2] mmc: Check for device with a seq number equal to num before checking against index To: Ricardo Salveti CC: , Peng Fan , Lokesh Vutla , Vignesh Raghavendra , Kishon Vijay Abraham I References: <20210325071848.27181-1-a-govindraju@ti.com> <20210325071848.27181-2-a-govindraju@ti.com> From: Aswath Govindraju Message-ID: Date: Wed, 7 Jul 2021 10:25:52 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 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.103.2 at phobos.denx.de X-Virus-Status: Clean Hi Ricardo, On 07/07/21 4:39 am, Ricardo Salveti wrote: > Hi Aswath, > > On Thu, Mar 25, 2021 at 4:19 AM Aswath Govindraju wrote: >> >> First check if there is an alias for the device tree node defined with the >> given num before checking against device index. >> >> Signed-off-by: Aswath Govindraju >> Reviewed-by: Lokesh Vutla >> Reviewed-by: Jaehoon Chung >> --- >> drivers/mmc/mmc.c | 8 +++++--- >> 1 file changed, 5 insertions(+), 3 deletions(-) >> >> diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c >> index b4c8e7f293bd..1e83007286b2 100644 >> --- a/drivers/mmc/mmc.c >> +++ b/drivers/mmc/mmc.c >> @@ -3052,9 +3052,11 @@ int mmc_init_device(int num) >> struct mmc *m; >> int ret; >> >> - ret = uclass_get_device(UCLASS_MMC, num, &dev); >> - if (ret) >> - return ret; >> + if (uclass_get_device_by_seq(UCLASS_MMC, num, &dev)) { >> + ret = uclass_get_device(UCLASS_MMC, num, &dev); >> + if (ret) >> + return ret; >> + } > > uclass_get_device_by_seq returns 0 if OK and -ve on error, so I > believe this check is incorrect and we never end up calling > uclass_get_device on the working path. > Yes, as you mentioned uclass_get_device_by_seq() returns 0 if OK and -ve on error is correct. However, the intention of this check here, is to only call uclass_get_device() when uclass_get_device_by_seq() returns an error. uclass_get_device_by_seq() returns the device only if it is able find a active device with matching sequence number "num" or will try to find a device that is requesting this number. As this function also returns the device we need not call uclass_get_device() again. Only on failure for find a device with matching sequence number do we call uclass_get_device(). So, I believe the above mentioned check is correct. > While bisecting to try to debug why my zynqmp-based device is unable > to boot u-boot, I stopped at this patch (merged as part of > v2021.07-rc1). > > diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c > index 1e83007286b..56556353f8e 100644 > --- a/drivers/mmc/mmc.c > +++ b/drivers/mmc/mmc.c > @@ -3052,11 +3052,13 @@ int mmc_init_device(int num) > struct mmc *m; > int ret; > > - if (uclass_get_device_by_seq(UCLASS_MMC, num, &dev)) { > - ret = uclass_get_device(UCLASS_MMC, num, &dev); > - if (ret) > - return ret; > - } > + ret = uclass_get_device_by_seq(UCLASS_MMC, num, &dev); > + if (ret) > + return ret; > + > + ret = uclass_get_device(UCLASS_MMC, num, &dev); > + if (ret) > + return ret; > > m = mmc_get_mmc_dev(dev); > if (!m) > In the above method, the device is being fetched twice and I believe that this method is incorrect. > This is enough for it to work correctly again, but I just wanted to > reply back here first before submitting as I'm surprised nobody > reported this issue before. > If making this change got it work correctly again. I believe there might have been a error in assigning aliases for mmc devices in the device tree. As only after this patch are aliases being read for mmc class of devices from the device tree. Thanks, Aswath > Can you verify on your target hardware if this is indeed working as intended? > > Thanks, >