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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 20F18C433EF for ; Fri, 8 Apr 2022 17:40:29 +0000 (UTC) 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:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=xQR16vgE8/pWYXEndN3c/l8u39wE86TR1XmhpLbcfvs=; b=CV3tfXSfjAyRrX BiYAb13NyydIgIk6KYqUSdqGr+JUgfVeVKG50AITdnkvKuzg+ieSEGTZqhd1g9Rl7T66ChNGV2ydS h0EDtlIlkZ5b65yQQ7+hdjORhuz/XEJ8HzlZHOGSMxs2HmpLlYNKA49KrMaYAsLAU1ZF4tUze1orQ T5vADI7yUgOx1bwgYq+7WKncCUPgCNE4LfH3yHyznj3e5wds4ppoUI4eb0WzqT4O92cxMrir5oTwz 7KeSZ4Nn7bxSI+zWT4++7WzrSsy9B6R82lM9EH45lJzerpj9FfPBZCsC4MduDDCRWwm45+kr5NgrQ QnwbQkiPORvrFXgZwTBg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ncsZx-000kjW-HR; Fri, 08 Apr 2022 17:39:25 +0000 Received: from ams.source.kernel.org ([145.40.68.75]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ncsZt-000kip-IV for linux-arm-kernel@lists.infradead.org; Fri, 08 Apr 2022 17:39:23 +0000 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 ams.source.kernel.org (Postfix) with ESMTPS id F087EB826CF; Fri, 8 Apr 2022 17:39:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D3EC5C385A3; Fri, 8 Apr 2022 17:39:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1649439558; bh=fjDvDzKQXH+2sFBYV36rZ198m6vn8t2q+ypSTCZ4aME=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=JvU4Z2WMU3WoPbly6wMJrkt5PXY/SJ+eZIPSfgdrwg4qTAediv2I9luAlRDxhNIcv jv0LPCiKKQ+/17WNyoyioViRu36JIF+yOCN4tch7QW1u+OztYBF28hgjClKUFgwtPZ 9KsvkE9Gu9rBQHTvLrOs2MU4QzKF8EBh7aAyFjK1rKAVudvDiYgHi78P1RT2BkFBlq 1rfq/yD/hwiaJZ1qbcm54CL+Ui8I8WJYG/NcHZgnWbOp3peJ7M7NFp3Yd3yQZmEGFA y0dHFQG+tdwxf2ZvTZ0YJo0wjC5iPmGeWO02uS5JrpA5kt4i1Bj9h0pW1tI5hPlLpG 2+DQvByP+Sa4g== Date: Fri, 8 Apr 2022 23:09:14 +0530 From: Vinod Koul To: Kevin Groeneveld Cc: Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Lucas Stach , Robin Gong , dmaengine@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] dmaengine: imx-sdma: fix regression with uart scripts Message-ID: References: <20220406224809.29197-1-kgroeneveld@lenbrook.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20220406224809.29197-1-kgroeneveld@lenbrook.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220408_103921_952476_7FFE2F6C X-CRM114-Status: GOOD ( 29.48 ) 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 On 06-04-22, 18:48, Kevin Groeneveld wrote: > Commit b98ce2f4e32b ("dmaengine: imx-sdma: add uart rom script") broke > uart rx on imx5 when using sdma firmware from older Freescale 2.6.35 > kernel. In this case reading addr->uartXX_2_mcu_addr was going out of > bounds of the firmware memory and corrupting the uart script addresses. > > Simply adding a bounds check before accessing addr->uartXX_2_mcu_addr > does not work as the uartXX_2_mcu_addr members are now beyond the size > of the older firmware and the uart addresses would never be populated > in that case. There are other ways to fix this but overall the logic > seems clearer to me to revert the uartXX_2_mcu_ram_addr structure > entries back to uartXX_2_mcu_addr, change the newer entries to > uartXX_2_mcu_rom_addr and update the logic accordingly. 1. Patch title should reflect the change introduced, so the title is not apt, pls revise 2. Is this in response to rmk's report, if so, please add reported-by 3. Lastly, I would like to see some tested by for this patch.. > > Fixes: b98ce2f4e32b ("dmaengine: imx-sdma: add uart rom script") cc: stable ? > Signed-off-by: Kevin Groeneveld > --- > drivers/dma/imx-sdma.c | 28 ++++++++++++++-------------- > 1 file changed, 14 insertions(+), 14 deletions(-) > > diff --git a/drivers/dma/imx-sdma.c b/drivers/dma/imx-sdma.c > index 70c0aa931ddf..b708d029b6e9 100644 > --- a/drivers/dma/imx-sdma.c > +++ b/drivers/dma/imx-sdma.c > @@ -198,12 +198,12 @@ struct sdma_script_start_addrs { > s32 per_2_firi_addr; > s32 mcu_2_firi_addr; > s32 uart_2_per_addr; > - s32 uart_2_mcu_ram_addr; > + s32 uart_2_mcu_addr; > s32 per_2_app_addr; > s32 mcu_2_app_addr; > s32 per_2_per_addr; > s32 uartsh_2_per_addr; > - s32 uartsh_2_mcu_ram_addr; > + s32 uartsh_2_mcu_addr; > s32 per_2_shp_addr; > s32 mcu_2_shp_addr; > s32 ata_2_mcu_addr; > @@ -232,8 +232,8 @@ struct sdma_script_start_addrs { > s32 mcu_2_ecspi_addr; > s32 mcu_2_sai_addr; > s32 sai_2_mcu_addr; > - s32 uart_2_mcu_addr; > - s32 uartsh_2_mcu_addr; > + s32 uart_2_mcu_rom_addr; > + s32 uartsh_2_mcu_rom_addr; > /* End of v3 array */ > s32 mcu_2_zqspi_addr; > /* End of v4 array */ > @@ -1796,17 +1796,17 @@ static void sdma_add_scripts(struct sdma_engine *sdma, > saddr_arr[i] = addr_arr[i]; > > /* > - * get uart_2_mcu_addr/uartsh_2_mcu_addr rom script specially because > - * they are now replaced by uart_2_mcu_ram_addr/uartsh_2_mcu_ram_addr > - * to be compatible with legacy freescale/nxp sdma firmware, and they > - * are located in the bottom part of sdma_script_start_addrs which are > - * beyond the SDMA_SCRIPT_ADDRS_ARRAY_SIZE_V1. > + * For compatibility with NXP internal legacy kernel before 4.19 which > + * is based on uart ram script and mainline kernel based on uart rom > + * script, both uart ram/rom scripts are present in newer sdma > + * firmware. Use the rom versions if they are present (V3 or newer). > */ > - if (addr->uart_2_mcu_addr) > - sdma->script_addrs->uart_2_mcu_addr = addr->uart_2_mcu_addr; > - if (addr->uartsh_2_mcu_addr) > - sdma->script_addrs->uartsh_2_mcu_addr = addr->uartsh_2_mcu_addr; > - > + if (sdma->script_number >= SDMA_SCRIPT_ADDRS_ARRAY_SIZE_V3) { > + if (addr->uart_2_mcu_rom_addr) > + sdma->script_addrs->uart_2_mcu_addr = addr->uart_2_mcu_rom_addr; > + if (addr->uartsh_2_mcu_rom_addr) > + sdma->script_addrs->uartsh_2_mcu_addr = addr->uartsh_2_mcu_rom_addr; > + } > } > > static void sdma_load_firmware(const struct firmware *fw, void *context) > -- > 2.17.1 -- ~Vinod _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel