From patchwork Tue Aug 11 15:53:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robin Gong X-Patchwork-Id: 11708765 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0C353618 for ; Tue, 11 Aug 2020 07:40:35 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (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 D58E8205CB for ; Tue, 11 Aug 2020 07:40:34 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="SHvLB32U"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="QZg+Pdp8" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D58E8205CB Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=nxp.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=YryMfXLkXcLSadN4sOzIvPn/4cHFXncgzIK0yyy1UOg=; b=SHvLB32UMtNmYJE7wcugw6brG 0WATvD5tS6m7NcvwUrROwRVz83ONcZhboYoez4sgO+l+XCUtRTkn0lyARzDGkblXV7ZxVYgGrgeqR SV9C0PaMiPK+pNbcCzn0q73UW3z5EWjey1otmmDExQifSZROUK1V6tXNJ9pmK+l+SO1+JwnFQFuFb YYa5dTHfEuwtPatNEn1Ex4K/rD61ok+aM9AC5ViEKBinuoAIH75NoOwSoARIsrnZdvzrJq/5yEAP/ NZdIN5bVatLMa4EOvZAX3RfdIL6IZN7dz6S2xfqiaoCQq5rGR2wdU3dXPrBAoX670ZFjo74VVmPu7 Q3OYM3Ebw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1k5OtU-0005ZV-JI; Tue, 11 Aug 2020 07:40:24 +0000 Received: from mail-eopbgr00049.outbound.protection.outlook.com ([40.107.0.49] helo=EUR02-AM5-obe.outbound.protection.outlook.com) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1k5OtR-0005XV-I1 for linux-arm-kernel@lists.infradead.org; Tue, 11 Aug 2020 07:40:22 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Xbrqi/b1T+Do0OC5tvrLdX7ha2UNOKC74V6jC215ay+z0JMGNuNEJulxjuuDO1aXtPNGdF9pyzucvDHZuVEd8X1Qgt3k4fpJE3bcSEji4CrK2mfWZzRhrM7LFtdviFlKMQNVVH7yBAY4XeY73/hHe5wsv3AwmoaL4JSVaW9XIJV+P0Q4T2/oiAByZs3eqfD1Xx0bMyJArBgLc7EACLCZrpRizcOYx6W8osXe75VmHQuL9HPCeaeshBBlemgd2ScU/xH7FCD7tkiUgwmwXk9vJ0Ds3+C6kJvRdhIuqtGL6oA/GqvZu9hz0U86nczZnsDpHueW9N6R/gG+HG+FuQ8R1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=zYO4eeCkCaKtyLBE/p41QWBbs0n+/LC0JXhKC1GhFac=; b=lC/ok5XlP229BX6SObOHwxA5qZzRVijmUIA+0nZ907BYIAEs9cLaiMOW4PGeUVoMe3Yya8f4LtvXvdbUSSjVMtMl2kim0gSy4K7j6Rc4UL8WdH2/Yr6/PS8fStxCDUrL2ubE3rPjVV0O60XtcJqgG/Ea0FHDGmAPk0xEGAdDlQCIkOLyw2wUaukQ8nJsN7+7YHgq19PpfmbKQtUwwph63s7SEKX9599LkD6rxxG4NVFMJOnhLDC7qBKb3y3ZctwvxnaRHZUaHckpalXA1qhLiQn3H6hKLdDk96yA+RW+J1kH3YSWshXaRlTwgNMsZdIERbUh6Rx0HJ2s87L6g44ncQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=zYO4eeCkCaKtyLBE/p41QWBbs0n+/LC0JXhKC1GhFac=; b=QZg+Pdp8xM61fpJJ+U7IpGUJqRmP8xDt5+vOgpmVBdtMRR+xQU3b0wp4taFcLFEBZCULb7OEwTwShdTt2qkMW5KRifAMfrfr97/0ZG/GCi6ydXLY2MvMRVrQ9t+qC/gfW9K6S9EQC37ZyWupTq51XDeuWPg5/trGoJIlKHhF7QQ= Authentication-Results: arm.com; dkim=none (message not signed) header.d=none;arm.com; dmarc=none action=none header.from=nxp.com; Received: from AM6PR04MB6630.eurprd04.prod.outlook.com (2603:10a6:20b:f4::33) by AM6PR0402MB3464.eurprd04.prod.outlook.com (2603:10a6:209:12::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3261.16; Tue, 11 Aug 2020 07:40:18 +0000 Received: from AM6PR04MB6630.eurprd04.prod.outlook.com ([fe80::c9b8:4020:7705:e3dd]) by AM6PR04MB6630.eurprd04.prod.outlook.com ([fe80::c9b8:4020:7705:e3dd%7]) with mapi id 15.20.3261.025; Tue, 11 Aug 2020 07:40:18 +0000 From: Robin Gong To: mark.rutland@arm.com, broonie@kernel.org, robh+dt@kernel.org, catalin.marinas@arm.com, vkoul@kernel.org, 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, r.schwebel@pengutronix.de Subject: [PATCH v12 05/12] dmaengine: dma: imx-sdma: add fw_loaded and is_ram_script Date: Tue, 11 Aug 2020 23:53:44 +0800 Message-Id: <1597161231-32303-6-git-send-email-yibin.gong@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1597161231-32303-1-git-send-email-yibin.gong@nxp.com> References: <1597161231-32303-1-git-send-email-yibin.gong@nxp.com> X-ClientProxiedBy: SG2P153CA0014.APCP153.PROD.OUTLOOK.COM (2603:1096::24) To AM6PR04MB6630.eurprd04.prod.outlook.com (2603:10a6:20b:f4::33) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from robin-OptiPlex-790.ap.freescale.net (119.31.174.67) by SG2P153CA0014.APCP153.PROD.OUTLOOK.COM (2603:1096::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.20.3305.2 via Frontend Transport; Tue, 11 Aug 2020 07:40:11 +0000 X-Mailer: git-send-email 2.7.4 X-Originating-IP: [119.31.174.67] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 65d42803-d3e1-4039-3436-08d83dc9cade X-MS-TrafficTypeDiagnostic: AM6PR0402MB3464: X-LD-Processed: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635,ExtAddr X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7219; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 2AMXFGkgM6Hrrynfilg+XSbAA8QClWNdD/QPxPM4J5NWFx0humpwE8vNvrQn4+7sxsEfFzemVIO43k8IhFXJ2/4kpxRJCWi73XMVYTXvOmLvW4sKNR42ATUADn2Ul66j5L8o00IMDaWaFCns9Gg15xga2kxa4/4fkXDxTE8tirFkjOMclRG1kTW4WHogFEl9RuWyeCHvMgIGZT/RhvXUs76Net7qr0iWIGgjO76JGGEtXG9zI33AD2ercCfRWDZznuU5LwMVDygkpUG0YD62kH11GfEFZgF4dqQh5ZLL/CLVV2hlfknLX+H+WkeoQ5jCA7i+TJlkx/0Tg8TWYxD477iuIdbVNFWcdlljtlrrvlZN6ke/bGzN1E/HsielkAU2 X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM6PR04MB6630.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(4636009)(376002)(396003)(136003)(366004)(39860400002)(346002)(4326008)(5660300002)(52116002)(66476007)(66556008)(86362001)(956004)(66946007)(6486002)(2616005)(7416002)(316002)(36756003)(186003)(2906002)(8676002)(6506007)(6666004)(6512007)(8936002)(26005)(478600001)(83380400001)(16526019)(921003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: mP+9ROooT7Br+dn6AEhLs3eKoPVnj9dxgU9AoWuxjGWzi+cOnUiu2YEOeM+aRXe9zLkCDhFGedpXQwrXTpcADycNOAFzivVnAuFGV1WUMKDzdRk53KpWiK/RZ6o6+t5wRYJH5Fhv1sBmyYDjGPLFlun9tvenCqXi9aCJz0gUioP8aI4hC3TmrkAiKcM8Ma5p2SvFBRwn9CpIsf/iKTPK1Ajl6eCImD9kxWF8AgZCX2+0pH4kVxWHO7vhxmgkIguHH0D24w9+UbUsMgR7Fcbp+3urbGSmS30xr6t2gUWCANGVv/3STnl3BeMiLXF4Z5HpTgNkjfMdM+5zu1ooXKoAf9kElap5IB/SLEcF60A4HkrFBfMEQM0oJbvSAsnHy4ZzI6j8IEJk8UTOUwmM9jJk7WV+ehE2SmWWw/fwAg7umQ1nUr78vK307tn5YM1QA9xVrY83sBd2ppOyu8w81mmMDOBYCsZrjkJEEKP/GfBHZo2d8xq9GmiEhSMx1Vps0zH76mScmKD1/a3OSLU0EXLwj4jYiuKshARHEtgaAnG9FkCLrWLTPwN738onCXmewbbNKN/4ZaGQidLY3dc4m25YavYeRGovNtYpM+j4Oqa0vwNNYAv2+H0PKddWicrknaWbUtsBzMBNb5KAAkeuoQAqbg== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 65d42803-d3e1-4039-3436-08d83dc9cade X-MS-Exchange-CrossTenant-AuthSource: AM6PR04MB6630.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Aug 2020 07:40:17.9283 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: MkEJgc++KmHgJ7sG7uNtAkqVOksw2PxSnbZtawPGtmQ77EnWmdVY8RKNSoMZUaBF3vP/UOCDeUWMFpg5+Dnl4Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR0402MB3464 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200811_034021_639270_5E94002E X-CRM114-Status: GOOD ( 14.25 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [40.107.0.49 listed in list.dnswl.org] 0.0 DATE_IN_FUTURE_06_12 Date: is 6 to 12 hours after Received: date -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [40.107.0.49 listed in wl.mailspike.net] -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.0 MSGID_FROM_MTA_HEADER Message-Id was added by a relay X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , 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 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org 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 5411e01e..cf02c3e 100644 --- a/drivers/dma/imx-sdma.c +++ b/drivers/dma/imx-sdma.c @@ -379,6 +379,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) @@ -443,6 +444,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, @@ -929,6 +931,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: @@ -943,6 +946,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; @@ -1339,6 +1343,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; @@ -1589,6 +1598,8 @@ static int sdma_config_write(struct dma_chan *chan, { struct sdma_channel *sdmac = to_sdma_chan(chan); + sdmac->is_ram_script = false; + if (direction == DMA_DEV_TO_MEM) { sdmac->per_address = dmaengine_cfg->src_addr; sdmac->watermark_level = dmaengine_cfg->src_maxburst * @@ -1768,6 +1779,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);