From patchwork Sun Jan 2 17:52:06 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: 529545 Delivered-To: patch@linaro.org Received: by 2002:ac0:9f5c:0:0:0:0:0 with SMTP id l28csp326130imf; Sun, 2 Jan 2022 09:50:34 -0800 (PST) X-Google-Smtp-Source: ABdhPJzVC9R05TTlUqChNuqX3Lg6wLec9DhvPnBc/dcnUKcFV2OWY0JKT8geJc5IaZb6YYALj46+ X-Received: by 2002:a17:902:ce8f:b0:148:ec75:5696 with SMTP id f15-20020a170902ce8f00b00148ec755696mr42981220plg.115.1641145834354; Sun, 02 Jan 2022 09:50:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1641145834; cv=none; d=google.com; s=arc-20160816; b=gWEO3Bw8+swePRGm71uo2UtVVMsEAhpvjkkOwAg8kgQMBlwk+HTxFwATLcNLNSS2Jo EJytv/nJwhwFLaUGtSYVl2NyouJ2YtmEEuiPyZnC8sTmKs2jlNoZt9RFn55viUXtsjgp qB5BxhWlMrJ8pEDxAoIddihC4XXS90oAZ4d5YtsRc2f+RnxAtnQ37xr7uIsEKqxwdDNz u5lO+d40LJo63kADv9g+mTpMzbobmWSzsarGvvXa0YwjzmxoPIzHXt7iq45OrJlbaYtO JqiNmSWjX37oWU7gEmtVQ/micjlyaWgR1/FTYGctKZ/KNyiiAmMq/CymK+sz3CPGL/eN q0PA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence :mime-version:message-id:date:subject:cc:to:from:dkim-signature :dkim-signature; bh=CNvdCDRwZ436i+AZ03dlnNHkzoeXZWJYdZnpIQDMN3w=; b=qFalMbOtqa9CNabJ+HIM350dKfnMWrs1gMwga0RdTQVF15bbjEv6bL2EnKsUvpWbc/ 0Qb8C+AWYDE+SX0SZ+af5f3tYOPWgumootSNeImo95Nw28Wu+wSkXHXgK7L97nNdguPG CZ/oCWYVe77MljfZP5zHhLc0IPQg4XcgYDWTCL7jNVi76iGSXvZPzXrTN4XwethOgreS G9sqy62NGGuH+2yA8HuU+M2PurfdUt9alxdfllWLuX8eKgnpo6qgEJ+F3jaCbWXNUQJ8 SPztq1AdKsNcjrmPcnn46RrMzsptd2LFmeDBL2bzNpynssuyqpJZrsKOQHxO/fePeLAT Y00w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lists.infradead.org header.s=bombadil.20210309 header.b=ekwkzqtB; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=tYKARDaQ; spf=pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom="linux-mtd-bounces+patch=linaro.org@lists.infradead.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2607:7c80:54:e::133]) by mx.google.com with ESMTPS id mq16si30476159pjb.82.2022.01.02.09.50.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 02 Jan 2022 09:50:34 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 2607:7c80:54:e::133 as permitted sender) client-ip=2607:7c80:54:e::133; Authentication-Results: mx.google.com; dkim=pass header.i=@lists.infradead.org header.s=bombadil.20210309 header.b=ekwkzqtB; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=tYKARDaQ; spf=pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom="linux-mtd-bounces+patch=linaro.org@lists.infradead.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=CNvdCDRwZ436i+AZ03dlnNHkzoeXZWJYdZnpIQDMN3w=; b=ekwkzqtBaH4y3y raHBjm0eLKpgTmfuQJcIG6t/66KVTz9y7dGadC9+5yKdDHugZ38a9XA5G00KXUJ8g5qj3yEECRS7J JpDte0F5GP4So6pnAx3984AcWqt1+0AINdYui6OwGiMdQH1t2gmEnux4LipjY0OMQF8Vl2508Gn+X rT1xBZfK5yfbnK45vv7CUotIaoEzIKnwdHwMj2T8i+CZRkF0yM7Jg1vTdMSdK+koFJrKUV77uiR+E f/hY7yLiA/tE660cB1DehLTocNYfoqA08zlhCBQFusScUUZDsVutz8pIVRln9P8hr7BUiG4iv6unO 1AwIAXSSpON63Pi6wWXw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1n44zg-0083hz-3J; Sun, 02 Jan 2022 17:50:08 +0000 Received: from mail-wr1-x42f.google.com ([2a00:1450:4864:20::42f]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1n44zd-0083hP-2Q for linux-mtd@lists.infradead.org; Sun, 02 Jan 2022 17:50:06 +0000 Received: by mail-wr1-x42f.google.com with SMTP id r17so65832306wrc.3 for ; Sun, 02 Jan 2022 09:50:03 -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:mime-version :content-transfer-encoding; bh=f/23sp1iBvoUiVjjVi++1/pRdYTmKhtlANlkSerXd08=; b=tYKARDaQ5u5adV9zC7q44A7IL73nAsobcLzJ8JMaKVcNyLtyjGibbCRSWpujUXqThw +VcCvaMo0jZ/h5spYLzvrnhQO+UXFaPckLhBp0whjINWIaUOWLfHi+89jz73xg07UJxn vPNryvEOAQCaJdkNNGe1RFLFLT0ReeDzhcDJ3tuSlG2eKYDeQUgukqhqa7gtMMuFZiwz NV1IWdtiCdty6X3nUjThkzLK+Of2EGEnePa07rGol/l0Fr0/+TyqxxPC6jZfF1TJfZ4U eJ1PlGctGSpSD3k8tsJyDxgg2WalOJ48ueqrTo7P5jQ3az+/jC1sCK6oyhIJtdbxeaxD rH2g== 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:mime-version :content-transfer-encoding; bh=f/23sp1iBvoUiVjjVi++1/pRdYTmKhtlANlkSerXd08=; b=jwRjAfObMhhKlcdvzLPcEF188rSPDZEuBXnkTsYilb8CE++dleR5Lm9rfi6ot+6kZ+ tOziac8t+7mXux4VgiMQBJMefsrKPRoJc3dbqrN7McWXF6s7UG6m6KNAg1bfQ+QVjlyg usRRvCWCxbd95qEwOKqt23zGyHH3UMe28tOZogyBcYO2SYBeR2aT4XAmFBkZakRvGt73 gBkhNQwZueNAxUJwfDMC+Jjb02oXPu4T/bXKwMZi66SA3xl81//DuqUfmv3oJAXDQMvY zMPhX6qnPi0wGqmH9P0IoV8tKp5kEhHbe+GEIvBVUnHEiDoy6Av3UcHJLlxDBuam936m FpFg== X-Gm-Message-State: AOAM532P+oiAtnoXhvgBAm2SW/H+/OTAj5PCNgv205qi8Na1DjQKlGMb i/MCGFrRT/psYXZciswTufpruN4K67N7mg== X-Received: by 2002:a5d:5255:: with SMTP id k21mr37623129wrc.381.1641145802034; Sun, 02 Jan 2022 09:50:02 -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 o10sm23539488wmq.31.2022.01.02.09.50.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 02 Jan 2022 09:50:01 -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] mtd: rawnand: qcom: Fix clock sequencing in qcom_nandc_probe() Date: Sun, 2 Jan 2022 17:52:06 +0000 Message-Id: <20220102175206.3960-1-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.33.0 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220102_095005_192697_B57BE078 X-CRM114-Status: GOOD ( 14.52 ) X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: 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. Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:42f listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-mtd" Errors-To: linux-mtd-bounces+patch=linaro.org@lists.infradead.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; }