Received: by 2002:a05:6a10:7420:0:0:0:0 with SMTP id hk32csp4042998pxb; Mon, 21 Feb 2022 10:46:35 -0800 (PST) X-Google-Smtp-Source: ABdhPJw3xJ0A5HR7USwaGGpp1cQGUV81uQ4ZIbeLbN6n9N2efpS5nI9WTWFpaUgJkxK9kKW1WiFU X-Received: by 2002:a17:906:3109:b0:6cc:7a1:8db0 with SMTP id 9-20020a170906310900b006cc07a18db0mr16801727ejx.266.1645469195635; Mon, 21 Feb 2022 10:46:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645469195; cv=none; d=google.com; s=arc-20160816; b=Ic9BK+9wxvehEQcqiS4/BSmEDBP+iEaATK710A8kLzTUi03doMx8KHSf6UqU6QgwO9 6Vr8zYeX4NT1K6AtqxiZF3BnDxI5IQcUQb6X+Z7QUEz4/YFOyDwEnSoNl8W81+mfv0E7 xiy1aQi5AT53e7CPkfrErAmMjpja/bGWQtLLU0DziO8G+8LAcCQVKyeZTYZLlL5vglRG XAZOL8ZhJDYi7CI4EXUmNJ1a8RE9BABTT3M58lJdW0/9CT92eDyd/OB7kNtS1FYbQOMr 8bdzgqOrwD6ihvW8/4DRFCzSHh5+BgVdn8fEtjLhxAg4oc+CpepqAk+H1nFxRsqUSI/d XkUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=RhUsGPA5S5Mb1FsTc4kq5okudA85aAZVnx6Zf7bfLcM=; b=EcFs6Lr6aulEsOhXp3jVs4uvo+dd/j8j8tcKifKNGtyA0EQR449DSgsz+mQOaCuB0j vcMi+agSMfzJxhacMtRX+3nh5cuTz6w7z9z4vyJ/RPlPGZLyx/HQexm1FPvfszxpP8M9 otmU8lkAMVXvB3HFD54QxTJjVTQZF1liyybHDraRmw6u86xeIcaGuQPs/bDOey5Axf+3 G+30WrBSf1sto8vFEmYl0+oKZHyjgbt9ra93pn/1CSM59DeK/iVsAkw0kMIkj4ILGngd +wWzfTPYs9+bmafhNDw6ixFiObpCea3Sg+lWyq/iGERChWkaZucpYwWetznHh/xuGd31 bFVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=rKscJb1n; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r19si4043720edd.397.2022.02.21.10.46.12; Mon, 21 Feb 2022 10:46:35 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=rKscJb1n; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348594AbiBUJLZ (ORCPT + 99 others); Mon, 21 Feb 2022 04:11:25 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:43676 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347639AbiBUJHW (ORCPT ); Mon, 21 Feb 2022 04:07:22 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8E42D3123F; Mon, 21 Feb 2022 00:59:56 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 7036261204; Mon, 21 Feb 2022 08:59:56 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4F964C340F1; Mon, 21 Feb 2022 08:59:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1645433995; bh=kMSEXPBoSwoQwmpkWwpG7HzOODbVad/ahoEiMcTEZ58=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rKscJb1nWELFbr8DZWxFFFaVEk2M4qFm1OhfRRueMHy9oPgwzGEKctqJcVwbVnCGq ESH2fkIYCC0VQFhqQmjnawBtNkwSpJQfNM5qH2+EjRwmDjQWbU2ojapimotlpKqHmz 2vBc7N9tu2zP9gYWfBeFqmtTz4oV+ejowk/sbSiM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Bryan ODonoghue , Manivannan Sadhasivam , Miquel Raynal Subject: [PATCH 5.4 57/80] mtd: rawnand: qcom: Fix clock sequencing in qcom_nandc_probe() Date: Mon, 21 Feb 2022 09:49:37 +0100 Message-Id: <20220221084917.446340483@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220221084915.554151737@linuxfoundation.org> References: <20220221084915.554151737@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Bryan O'Donoghue commit 5c23b3f965bc9ee696bf2ed4bdc54d339dd9a455 upstream. 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 Reviewed-by: Manivannan Sadhasivam Signed-off-by: Miquel Raynal Link: https://lore.kernel.org/linux-mtd/20220103030316.58301-2-bryan.odonoghue@linaro.org Signed-off-by: Greg Kroah-Hartman --- drivers/mtd/nand/raw/qcom_nandc.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) --- 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 @@ -2944,10 +2943,6 @@ static int qcom_nandc_probe(struct platf if (!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; @@ -2956,6 +2951,10 @@ static int qcom_nandc_probe(struct platf 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; @@ -2967,15 +2966,14 @@ static int qcom_nandc_probe(struct platf 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; }