From patchwork Mon Jan 3 03:03:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 529917 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D006BC4332F for ; Mon, 3 Jan 2022 03:01:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229472AbiACDBL (ORCPT ); Sun, 2 Jan 2022 22:01:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58120 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229455AbiACDBK (ORCPT ); Sun, 2 Jan 2022 22:01:10 -0500 Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 95EFCC061761 for ; Sun, 2 Jan 2022 19:01:10 -0800 (PST) Received: by mail-wr1-x431.google.com with SMTP id o3so9154685wrh.10 for ; Sun, 02 Jan 2022 19:01:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=f/23sp1iBvoUiVjjVi++1/pRdYTmKhtlANlkSerXd08=; b=DerPVSiRTyAmcw+c3wNyWOUveWjaeSeWQbISCGTOmlLtnHgSZ6dPLTl4tjHPVh46x8 lXxww8s9V2qHt3e+UGTGACJFjapchh17MBcLWV810s8qaavG5a7a7a4cbc+VkcT8GjYy 1XhLfiGnOU9Wx/ahden2LvW0GGh7uAWCapqWM7OrPauoyqPEHuKboG+NcYqjEdh/oC7g 5ocDTgATAybN7Ya2YxVtI88y+I6X0xAQK8CjEYAnDh5CqBu0HuC9S5fKjpJzoXQd56JT XcG0EvkZpyjDQYQ8xxlZzA8ZyukWXgrcHUnjNbZ1uT4k2LD4DHFvX7hcpE0Vyb6i0ebR iI+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=f/23sp1iBvoUiVjjVi++1/pRdYTmKhtlANlkSerXd08=; b=woNWDTpoesMHn/8Ht5obv14S4BwPIbEN/8MFEUggoSd4oY1kV0FU6iucJzEs39/8BQ UJBncAmJ+bgVyl8S2AKcAtwp5LqVZIk5AmeZn9YDjlpfmDySH0MGKzPcclAVndMWuLWa ziqxUbvO0rvbmV1FeZFoixEGI9y7ylGZ+9qo4LsvSeHzEVU4XnGtDOBXh5OPIvkp7wDI Eavr1h/rExXns3pMUwoxi+OKoUJ1hzRjgGN1XzIaLRHnm+10aCCMDqJTMoUaUB04HDp7 mEhnlcZSw2QL67jSHZDIrhOE40h92bvJZHfA+QPABeYOAu3RMHxZTWJctyNRIkWf8Bhf q/Cw== X-Gm-Message-State: AOAM533ZHg5Wg6P4JZgf9+c+IaiIUyDDYb5aGl1RotUQSxt4pgTEaM0k /GfaFZf9CE8jBFirTOYH9P2EAnfapSmzRg== X-Google-Smtp-Source: ABdhPJxrnsqjm+lHytj9AGsJzo4p0rOgX1tPIYgePIAHUdICjerX9+4ADRb6XODxmI5k/0bHpQuynQ== X-Received: by 2002:adf:9d8c:: with SMTP id p12mr36533639wre.622.1641178868914; Sun, 02 Jan 2022 19:01:08 -0800 (PST) Received: from sagittarius-a.chello.ie (188-141-3-169.dynamic.upc.ie. [188.141.3.169]) by smtp.gmail.com with ESMTPSA id p11sm38095667wru.99.2022.01.02.19.01.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 02 Jan 2022 19:01:08 -0800 (PST) From: Bryan O'Donoghue To: linux-arm-msm@vger.kernel.org, linux-mtd@lists.infradead.org, mani@kernel.org, miquel.raynal@bootlin.com, architt@codeaurora.org, bbrezillon@kernel.org, absahu@codeaurora.org Cc: baruch@tkos.co.il, bryan.odonoghue@linaro.org Subject: [PATCH v2 1/2] mtd: rawnand: qcom: Fix clock sequencing in qcom_nandc_probe() Date: Mon, 3 Jan 2022 03:03:15 +0000 Message-Id: <20220103030316.58301-2-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220103030316.58301-1-bryan.odonoghue@linaro.org> References: <20220103030316.58301-1-bryan.odonoghue@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Interacting with a NAND chip on an IPQ6018 I found that the qcomsmem NAND partition parser was returning -EPROBE_DEFER waiting for the main smem driver to load. This caused the board to reset. Playing about with the probe() function shows that the problem lies in the core clock being switched off before the nandc_unalloc() routine has completed. If we look at how qcom_nandc_remove() tears down allocated resources we see the expected order is qcom_nandc_unalloc(nandc); clk_disable_unprepare(nandc->aon_clk); clk_disable_unprepare(nandc->core_clk); dma_unmap_resource(&pdev->dev, nandc->base_dma, resource_size(res), DMA_BIDIRECTIONAL, 0); Tweaking probe() to both bring up and tear-down in that order removes the reset if we end up deferring elsewhere. Fixes: c76b78d8ec05 ("mtd: nand: Qualcomm NAND controller driver") Signed-off-by: Bryan O'Donoghue --- drivers/mtd/nand/raw/qcom_nandc.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/drivers/mtd/nand/raw/qcom_nandc.c b/drivers/mtd/nand/raw/qcom_nandc.c index 04e6f7b267064..0f41a9a421575 100644 --- a/drivers/mtd/nand/raw/qcom_nandc.c +++ b/drivers/mtd/nand/raw/qcom_nandc.c @@ -2,7 +2,6 @@ /* * Copyright (c) 2016, The Linux Foundation. All rights reserved. */ - #include #include #include @@ -3063,10 +3062,6 @@ static int qcom_nandc_probe(struct platform_device *pdev) if (dma_mapping_error(dev, nandc->base_dma)) return -ENXIO; - ret = qcom_nandc_alloc(nandc); - if (ret) - goto err_nandc_alloc; - ret = clk_prepare_enable(nandc->core_clk); if (ret) goto err_core_clk; @@ -3075,6 +3070,10 @@ static int qcom_nandc_probe(struct platform_device *pdev) if (ret) goto err_aon_clk; + ret = qcom_nandc_alloc(nandc); + if (ret) + goto err_nandc_alloc; + ret = qcom_nandc_setup(nandc); if (ret) goto err_setup; @@ -3086,15 +3085,14 @@ static int qcom_nandc_probe(struct platform_device *pdev) return 0; err_setup: + qcom_nandc_unalloc(nandc); +err_nandc_alloc: clk_disable_unprepare(nandc->aon_clk); err_aon_clk: clk_disable_unprepare(nandc->core_clk); err_core_clk: - qcom_nandc_unalloc(nandc); -err_nandc_alloc: dma_unmap_resource(dev, res->start, resource_size(res), DMA_BIDIRECTIONAL, 0); - return ret; } From patchwork Mon Jan 3 03:03:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 529653 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E0367C43217 for ; Mon, 3 Jan 2022 03:01:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229455AbiACDBM (ORCPT ); Sun, 2 Jan 2022 22:01:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58128 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229463AbiACDBL (ORCPT ); Sun, 2 Jan 2022 22:01:11 -0500 Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7F663C061761 for ; Sun, 2 Jan 2022 19:01:11 -0800 (PST) Received: by mail-wm1-x32b.google.com with SMTP id n14-20020a7bcbce000000b00332f4abf43fso9768586wmi.0 for ; Sun, 02 Jan 2022 19:01:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=lXNaCmB23l/v2SBkvx4jJIGXGemsehmfOVCATDay3ag=; b=Jc39l714mUnC6C71RckghH7B3nzIZLbhMQeM0gMoxDyYQi0Gj7qpZlTgLb6JzaYooK IPPHwZ0v14fTzwNAiUgPbXz4abv45FHv6KfKuWZXm2Z6lKklWCdXZ0AO72nyuXXlhbN5 /4d5GD8SNFryQV2ToR6haL3qQH3k1pnjCqZ2sO9I7PzMGEPhYtFI6+yyS/KnlmcJvXCU Mtxmi9sTVzeo3ZLzcVIesoBITbk011rG5kh9CtZLlHQuEbGvlaI0U7EgbsnwH1Zwg9gl luUSSPqU/S1hyDxgqcWo9t2QemifPJrDVhyC9pGwsN1IaADq+/GmgdZ8rIPQcALqH5Wf sCRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=lXNaCmB23l/v2SBkvx4jJIGXGemsehmfOVCATDay3ag=; b=AKt8aHGxWHR6PV5db3hjK8r1oe8xrfvxU0kdYIiYZcIdLpIvZVPWwDdBMfgOA4/k8t 9HMsGs9i4AYkxudTmiSB6AhBT3E5MuR/odXp9ebjo/qA/46CAdlr37hY2XP056ToKE6c 1rnApLWdGJXeiEPGVIIKBWYiUDqgAOQWOFkcErrl02Ag1cqdI/G6y5LKj9bcOjksxSNd zibkcvzx5KFvKKMVgYb0je25//YEWPT1fQXgfjjMKT1yfWSSidlZOuHjpL1oA/lB3P5V eZ2w+0GvslJhSsPIzujuGA24Y4wyD728GJChSOGXEzwu1Ol0Y+CEAnBOdcFbvTUsEjOp mGAA== X-Gm-Message-State: AOAM532lTMKWglKXCikF3ZhpBAIcZALocho6DqwWU/O/jbdB6e7A6VYv QSfjT1xYyQ8TyBilM7ymknAE35AAYHML7Q== X-Google-Smtp-Source: ABdhPJzRE1vniyLVYKzNOXBAw0GWwbCneCIPO9y+HCoI9YIhgwyoj6Cn1+dmB8FYvzwRxjGMwLSgNA== X-Received: by 2002:a05:600c:2103:: with SMTP id u3mr36391606wml.6.1641178869846; Sun, 02 Jan 2022 19:01:09 -0800 (PST) Received: from sagittarius-a.chello.ie (188-141-3-169.dynamic.upc.ie. [188.141.3.169]) by smtp.gmail.com with ESMTPSA id p11sm38095667wru.99.2022.01.02.19.01.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 02 Jan 2022 19:01:09 -0800 (PST) From: Bryan O'Donoghue To: linux-arm-msm@vger.kernel.org, linux-mtd@lists.infradead.org, mani@kernel.org, miquel.raynal@bootlin.com, architt@codeaurora.org, bbrezillon@kernel.org, absahu@codeaurora.org Cc: baruch@tkos.co.il, bryan.odonoghue@linaro.org Subject: [PATCH v2 2/2] mtd: parsers: qcom: Don't print error message on -EPROBE_DEFER Date: Mon, 3 Jan 2022 03:03:16 +0000 Message-Id: <20220103030316.58301-3-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220103030316.58301-1-bryan.odonoghue@linaro.org> References: <20220103030316.58301-1-bryan.odonoghue@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Its possible for the main smem driver to not be loaded by the time we come along to parse the smem partition description but, this is a perfectly normal thing. No need to print out an error message in this case. Signed-off-by: Bryan O'Donoghue Reviewed-by: Manivannan Sadhasivam --- drivers/mtd/parsers/qcomsmempart.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/mtd/parsers/qcomsmempart.c b/drivers/mtd/parsers/qcomsmempart.c index 06a818cd2433f..b2a57fe8479fa 100644 --- a/drivers/mtd/parsers/qcomsmempart.c +++ b/drivers/mtd/parsers/qcomsmempart.c @@ -75,7 +75,8 @@ static int parse_qcomsmem_part(struct mtd_info *mtd, pr_debug("Parsing partition table info from SMEM\n"); ptable = qcom_smem_get(SMEM_APPS, SMEM_AARM_PARTITION_TABLE, &len); if (IS_ERR(ptable)) { - pr_err("Error reading partition table header\n"); + if (PTR_ERR(ptable) != -EPROBE_DEFER) + pr_err("Error reading partition table header\n"); return PTR_ERR(ptable); }