From mboxrd@z Thu Jan 1 00:00:00 1970 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=-14.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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 76727C07E99 for ; Fri, 9 Jul 2021 09:26:43 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3CED9613D1 for ; Fri, 9 Jul 2021 09:26:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3CED9613D1 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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:References:In-Reply-To: Date:Cc:To:From:Subject:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=5uT+QllN3wF7jPWl2tV/sfa2K6c9b2jJVQaWB9mr6M0=; b=vhaB4qMO21oSQp neoQzoTmCadZksy8+q9Li5Vn/XRa9Id0uYAVW9DNLSFpiJozHM8UXnBoW5+5JhXrjxO0O8WsOhDkA 3TzNp9GoKekdDEEYAjPjFpt7jA4BojczFXBOFIS6C0Zm6X6taD5CC5yK67qRd8D4jqfEpx6HqV/Uu tpBPZc8IyYsGKiSX5zSSpPLlVOMmOQaJ7IlCYhwzjKB+VpucAAtqjTN+RTLPReIdAt+X4J1L1d7Ao I+/66FawNPfTH1fh76/n09h8JZhl5yXzJCKzKZD2StYYpqHrU+1ZFYSqr72dAFK80wVsXtLdxheBU sR3xaTK8dbNqtBtvSXzw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1m1ml0-001JiY-Ba; Fri, 09 Jul 2021 09:25:14 +0000 Received: from metis.ext.pengutronix.de ([2001:67c:670:201:290:27ff:fe1d:cc33]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1m1mkw-001JhD-8P for linux-arm-kernel@lists.infradead.org; Fri, 09 Jul 2021 09:25:11 +0000 Received: from gallifrey.ext.pengutronix.de ([2001:67c:670:201:5054:ff:fe8d:eefb] helo=[IPv6:::1]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1m1mke-0006Bw-KC; Fri, 09 Jul 2021 11:24:52 +0200 Message-ID: <17cadf46f4a0f9771fdde1c9aba9ffecb20efc9f.camel@pengutronix.de> Subject: Re: [PATCH v14 05/12] dmaengine: dma: imx-sdma: add fw_loaded and is_ram_script From: Lucas Stach To: Robin Gong , vkoul@kernel.org, mark.rutland@arm.com, broonie@kernel.org, robh+dt@kernel.org, catalin.marinas@arm.com, will.deacon@arm.com, shawnguo@kernel.org, festevam@gmail.com, s.hauer@pengutronix.de, martin.fuzzey@flowbird.group, u.kleine-koenig@pengutronix.de, dan.j.williams@intel.com, matthias.schiffer@ew.tq-group.com, frieder.schrempf@kontron.de, m.felsch@pengutronix.de, xiaoning.wang@nxp.com Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-spi@vger.kernel.org, linux-imx@nxp.com, kernel@pengutronix.de, dmaengine@vger.kernel.org, linux-arm-kernel@lists.infradead.org Date: Fri, 09 Jul 2021 11:24:48 +0200 In-Reply-To: <1617809456-17693-6-git-send-email-yibin.gong@nxp.com> References: <1617809456-17693-1-git-send-email-yibin.gong@nxp.com> <1617809456-17693-6-git-send-email-yibin.gong@nxp.com> User-Agent: Evolution 3.40.1 (3.40.1-1.fc34) MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2001:67c:670:201:5054:ff:fe8d:eefb X-SA-Exim-Mail-From: l.stach@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210709_022510_366137_F432FC5D X-CRM114-Status: GOOD ( 21.46 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Am Mittwoch, dem 07.04.2021 um 23:30 +0800 schrieb Robin Gong: > Add 'fw_loaded' and 'is_ram_script' to check if the script used by channel > is ram script and it's loaded or not, so that could prevent meaningless > following malloc dma descriptor and bd allocate in sdma_transfer_init(), > otherwise memory may be consumed out potentially without free in case > that spi fallback into pio while dma transfer failed by sdma firmware not > ready(next ERR009165 patch depends on sdma RAM scripts/firmware). > > Signed-off-by: Robin Gong > Acked-by: Vinod Koul > --- > drivers/dma/imx-sdma.c | 13 +++++++++++++ > 1 file changed, 13 insertions(+) > > diff --git a/drivers/dma/imx-sdma.c b/drivers/dma/imx-sdma.c > index 1c636d2..78dcfe2 100644 > --- a/drivers/dma/imx-sdma.c > +++ b/drivers/dma/imx-sdma.c > @@ -381,6 +381,7 @@ struct sdma_channel { > enum dma_status status; > struct imx_dma_data data; > struct work_struct terminate_worker; > + bool is_ram_script; > }; > > #define IMX_DMA_SG_LOOP BIT(0) > @@ -444,6 +445,7 @@ struct sdma_engine { > struct sdma_buffer_descriptor *bd0; > /* clock ratio for AHB:SDMA core. 1:1 is 1, 2:1 is 0*/ > bool clk_ratio; > + bool fw_loaded; > }; > > static int sdma_config_write(struct dma_chan *chan, > @@ -899,6 +901,7 @@ static void sdma_get_pc(struct sdma_channel *sdmac, > case IMX_DMATYPE_SSI_DUAL: > per_2_emi = sdma->script_addrs->ssish_2_mcu_addr; > emi_2_per = sdma->script_addrs->mcu_2_ssish_addr; > + sdmac->is_ram_script = true; > break; > case IMX_DMATYPE_SSI_SP: > case IMX_DMATYPE_MMC: > @@ -913,6 +916,7 @@ static void sdma_get_pc(struct sdma_channel *sdmac, > per_2_emi = sdma->script_addrs->asrc_2_mcu_addr; > emi_2_per = sdma->script_addrs->asrc_2_mcu_addr; > per_2_per = sdma->script_addrs->per_2_per_addr; > + sdmac->is_ram_script = true; > break; > case IMX_DMATYPE_ASRC_SP: > per_2_emi = sdma->script_addrs->shp_2_mcu_addr; > @@ -1309,6 +1313,11 @@ static struct sdma_desc *sdma_transfer_init(struct sdma_channel *sdmac, > { > struct sdma_desc *desc; > > + if (!sdmac->sdma->fw_loaded && sdmac->is_ram_script) { > + dev_warn_once(sdmac->sdma->dev, "sdma firmware not ready!\n"); > + goto err_out; > + } > + > desc = kzalloc((sizeof(*desc)), GFP_NOWAIT); > if (!desc) > goto err_out; > @@ -1559,6 +1568,8 @@ static int sdma_config_write(struct dma_chan *chan, > { > struct sdma_channel *sdmac = to_sdma_chan(chan); > > + sdmac->is_ram_script = false; > + While it's working correctly, I find it confusing to have this initialization at this point in the code. Please fold this into sdma_get_pc(), where it gets changed as needed. Other than this small issue, this patch is: Reviewed-by: Lucas Stach > if (direction == DMA_DEV_TO_MEM) { > sdmac->per_address = dmaengine_cfg->src_addr; > sdmac->watermark_level = dmaengine_cfg->src_maxburst * > @@ -1738,6 +1749,8 @@ static void sdma_load_firmware(const struct firmware *fw, void *context) > > sdma_add_scripts(sdma, addr); > > + sdma->fw_loaded = true; > + > dev_info(sdma->dev, "loaded firmware %d.%d\n", > header->version_major, > header->version_minor); _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel