Received: by 2002:a05:6a10:83d0:0:0:0:0 with SMTP id o16csp45363pxh; Thu, 7 Apr 2022 13:30:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzyu8JUVuNaYxd1/nAggALOLR4Xx0cnnkMIJtcAIAaVtImDUyEBEcrbh1PYl2XAHD7MlD5L X-Received: by 2002:a63:1759:0:b0:39c:d132:a3ef with SMTP id 25-20020a631759000000b0039cd132a3efmr2977407pgx.586.1649363440054; Thu, 07 Apr 2022 13:30:40 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1649363440; cv=pass; d=google.com; s=arc-20160816; b=oK8/moEkwN78uMkwurz1OyiF76wnbG+IF0cbxdP2WnzkOLB/0z8GQ+YtFPgk2wI1lA dcAG+tX8EvcllBeslEPraeqQCBK4/e4oevn6YDJws78Jskwjc3d61ITanDDlXeLTMP5A G7uOVjlon47qgobJHFcY+u0bBcF5uGwN81qYrvOFzUDylnxsliinm/t8es4UacBcouLl GiHR8mleJv+vQ9sArAO3qBxtHQCUTa4yawOhNWwZGwGaqpvZ/NcfdaAceceSV7FL/QpQ CywWKAUVS0sfcwVGMKu51z01cyQk9bCNSbd2kmljazdzZu3VJZIfbVpNoU12a6D8t+Du 8TGQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from :dkim-signature; bh=f9x3J1knr9MhujooGCdXbhMWtFj2bVNtt/kosteOgMc=; b=Blu5R3VbtSFiP9rkjgx9wBsiNTrhwh36agzxdEasFi05czycpPHm4oTuzwL0wU+WhN O/yMiS+MIX4xgdWXoj7krvBjnyNFMDDuELwhLrTPrAr3gOm9KfCzql9xgqoiNbzsk/OQ UjAM21nsLND4JnO1g/nXAexbndlvaNT0TY37JUUXd18rXcWlR4yIPJxfIEC2ft6XIxsA QpiHK3y5M/T23Av0Ytw6F4TZo1jT3HEApCGA/ZW3F+jJ0boGzuTyGDK2PrX2oRHHCVhd SOX/3R3obrJI1T6taZFPx/L7AllfuWLX0+UESl0u3Q/6cxzj0wS7+mmgFxWPJ6AXXpar Ihgw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@lenbrook.com header.s=selector1 header.b=FsbFZz8o; arc=pass (i=1 spf=pass spfdomain=lenbrook.com dkim=pass dkdomain=lenbrook.com dmarc=pass fromdomain=lenbrook.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=lenbrook.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id n15-20020a170903110f00b00156984a1cb4si702964plh.306.2022.04.07.13.30.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Apr 2022 13:30:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@lenbrook.com header.s=selector1 header.b=FsbFZz8o; arc=pass (i=1 spf=pass spfdomain=lenbrook.com dkim=pass dkdomain=lenbrook.com dmarc=pass fromdomain=lenbrook.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=lenbrook.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 1CCBA37EAB4; Thu, 7 Apr 2022 12:44:36 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237259AbiDFWug (ORCPT + 99 others); Wed, 6 Apr 2022 18:50:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41656 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234823AbiDFWu0 (ORCPT ); Wed, 6 Apr 2022 18:50:26 -0400 Received: from CAN01-QB1-obe.outbound.protection.outlook.com (mail-eopbgr660097.outbound.protection.outlook.com [40.107.66.97]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 79D501EDA3A; Wed, 6 Apr 2022 15:48:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PxkJ9EDD5Ub01J1es8/9aYcPzkcCWBSfNVA+Grj2DGtm2wDzB5usvWO8IhFonzXjtVuFF/KJ1p4H6I/S5Jn+ZW0EVgS6bzIoFZPnQgPBg7YLS3A9Aa1xvvac8wxEAL7RHiFjDO2kUx8Zm2vgdU/pihryZq/wksGmgtGV4We74E2O70ZPtO3TgcdYJNTlou4u4JFAgIaaz/uvvICb0Ga7rAHhDmA7IlxWKyJ1p9IP7SFP8+4LpMv+vyi2lVRIujHw0z3IhyVf99w3dEjx2nd/eCWDAQlWyjZGDEMAso6Z0yDYLOs/3EQQpE2MRLe/LteZrXEhlybQQQS24uWkv1g1DA== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=f9x3J1knr9MhujooGCdXbhMWtFj2bVNtt/kosteOgMc=; b=cAwXN5ba5YlWky/BMHJhRx/tAt5jqkQ0MJ2+mWzPRLqaciZKmw9aEfy1+VNxlUpZdjUtZKdc37/8sDH5VWRVwZX8JpAmqFQvEKqOwKzZCf6nhmQc1WSPLy/NeToQOOGEIv+xqNkscrkQgMK1B+F7xnmZGTbDK5HY/+uNPHS2WoqXemaBMX32mTGA4VE2V4xHzKBQxnDu2wOLeg7mp96upZPEYdpNg9QSTRQ/GPFCXCtuOQ5iifltYq7nPg5L/E5TN4lvwxOeETUpwt9l64/57WMF+TokVwhnfyv2k6NNCkeB8Oh1nasvNuNuTzm0ZPhma1A2DY8737BMCFz8NwyLqg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=lenbrook.com; dmarc=pass action=none header.from=lenbrook.com; dkim=pass header.d=lenbrook.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lenbrook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=f9x3J1knr9MhujooGCdXbhMWtFj2bVNtt/kosteOgMc=; b=FsbFZz8oIipglP0MHPU2qyCGBaDGPwKTFffMHkFG5nbH2AvdtEaMsW2dHk6en/SG40FHEknikulOO6w9FblQ2KHk8biJcjzvX3oDfilAvcDM2U1aL94E2M0t7Z4MJumBeRl/clhLeidj77wkzHuqPGVMA2wCc5fdbv2ytkkvtWo= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=lenbrook.com; Received: from YT4PR01MB9670.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:e8::12) by QB1PR01MB3474.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:c00:3d::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5144.21; Wed, 6 Apr 2022 22:48:25 +0000 Received: from YT4PR01MB9670.CANPRD01.PROD.OUTLOOK.COM ([fe80::291e:a689:84cc:ce0d]) by YT4PR01MB9670.CANPRD01.PROD.OUTLOOK.COM ([fe80::291e:a689:84cc:ce0d%9]) with mapi id 15.20.5123.031; Wed, 6 Apr 2022 22:48:25 +0000 From: Kevin Groeneveld To: Vinod Koul , 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 Cc: Kevin Groeneveld Subject: [PATCH] dmaengine: imx-sdma: fix regression with uart scripts Date: Wed, 6 Apr 2022 18:48:08 -0400 Message-Id: <20220406224809.29197-1-kgroeneveld@lenbrook.com> X-Mailer: git-send-email 2.17.1 Content-Type: text/plain X-ClientProxiedBy: YT1PR01CA0141.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:2f::20) To YT4PR01MB9670.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:e8::12) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 159f027a-347e-4c69-5d58-08da181f8f68 X-MS-TrafficTypeDiagnostic: QB1PR01MB3474:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 3n0dHrEk5vscdvAgpZ5T5siKhx7MuVRRgVDjzOJiWIxV1Noo514YiYHnBX0nmlbeoDdi+xfRG/HdJdxU/2HO3jE39GQH4xaEvII4xIU6zzrx+F55kIN2iemVuYl2awP0u33eO1/bHAc1LNxTJknHDoz5osmbnnlTV2s+WbDkwUrwL8IxhdLpzAqfIEX4CGlY0eaDMwfD0Z5A431UjbsYvWgU9GHsEFLHyNUaawCL4Hl7LsR8DRFOJ6YzJJ4m2iA1oO7yRkN6qjSwzSu/Qa3ATLOr0I5ZLoOXGExMp0JB7FWxdBYaVRpRAC6SFISPPuufjWDZxG0KdSQyF2dpeM8E8dFVADhZXHeCwEeJ+fskns8xLg6Y5UghEWtYK02O1DMNpqgSsQTEwWRlhP7n1kokc1rAgEP7exr7VMwttaxUsq6cXpt5XySwYqfimD+sCV5TtBh5p3hvd2/q3JK5PWyXZJwYRsozBUBapLQqGEdZSUJzkfWQnBcTCjRqqlYWL2srAgt7I4Si1pb3fYE5aOaB2P9R8apbnQN3nvdNrG9xJmBnnyiPjAqWiWWSR5A6OhCoYYby16ThxQ17yHXuViKElkvOmJmWYR5YzIx5DC46I+yN6NwF027ALAYklMMtS7I2pEzfzUfgVwiKpvqrDcG1tYdYZoNEVhuqBrMbyIByvcUZWCyWKkLeGIvck8ddyUAT X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:YT4PR01MB9670.CANPRD01.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(13230001)(366004)(66476007)(66556008)(66946007)(186003)(8936002)(4326008)(8676002)(26005)(5660300002)(2616005)(107886003)(1076003)(36756003)(7416002)(6666004)(316002)(2906002)(508600001)(86362001)(921005)(6486002)(6506007)(38100700002)(110136005)(83380400001)(6512007);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?iSBijB6QLq1mgEdZ5IC57U9PjGDjv/BidrvNM3AbnbP9Tk0OdbFwKCBbYoC5?= =?us-ascii?Q?K1EehEdOTX+zEcCfZlRD/z+BhCK2xYMrZGYQemVsXnoGFfdyKdJdNX99Tggk?= =?us-ascii?Q?21b/kp2OmhJBT6sGQqSNiFIVNXq+l4lzAFVV/VzVQHIQ69RuayJgoE4NcVBG?= =?us-ascii?Q?qYBhTVIUcBaLxeYNjxozLupN5dq/nAw8Xh5cmrhiPqJ5QdoGMnBNfeMioKzL?= =?us-ascii?Q?1p87FnA49hU1yscWDBp5MdoEMklJQ5uKcbFRqu+kTZULM8upo06WCatCIz8b?= =?us-ascii?Q?2qVPnmXG9lnqfFWzl4JwkpN+BnSpoOk8BzCAYGwjzh5YWBv7T1yYXDiwjCjD?= =?us-ascii?Q?BJRReJr4pBgJH63qtQEFbYuBuBI9F6s+82U1TFqGbnGxXsmJweXZHcdxGOOx?= =?us-ascii?Q?r6lWz1dUwX7dpBWzqpDMVlJ9sYqvU7jwwizi1M7TBa5QfRiQ03tE5FC2mBm/?= =?us-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esXHtNL04?= =?us-ascii?Q?26D1dv9yvhN4Txf5BWIFs4b4mZtA5OSpQk5nwF2WWsoR/tilddMCDUitPSrg?= =?us-ascii?Q?75LXvG9dnqw+AmsDLYBNBTlF9IOuyD8+h/uJuItYhv05yhr/q8SgBTbyC8F7?= =?us-ascii?Q?ZxJRBcc9qqKUAFVBYn4t6BjRUXXh84YUYt9tvHBYmGv4n5tu/k6qX9qGUV+t?= =?us-ascii?Q?/YemBeCqJB/G8dxljSjx44ccDmQhf3PYD5NEaE50SmOVNqw1VXh9SaKupyaN?= =?us-ascii?Q?jHMlqV+WQljp58KQ0Jvr1GY6DXB7gmMS1l9hBXQQea3I8wkuDRm1j7jxrFzi?= =?us-ascii?Q?p00cNLnU3cfeHQlux7tICICGlijrBfjNp1YMkYCJFV9k02XVHBR6rsSpPila?= =?us-ascii?Q?Yp8trdyhKYo9o2AJ//k+XxwQSh5gelY=3D?= X-OriginatorOrg: lenbrook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 159f027a-347e-4c69-5d58-08da181f8f68 X-MS-Exchange-CrossTenant-AuthSource: YT4PR01MB9670.CANPRD01.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Apr 2022 22:48:25.7267 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3089fb55-f9f3-4ac8-ba44-52ac0e467cb6 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: fsbW52bAV13FrmUcP+PxqrI89tVuWAPAmW1FALpvRTiy+V2nOGHRY8B3jKYdkh5CtBNbeCq8y2E68s5nMTnAS1vd56xAv5I0bTicg97SgEM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: QB1PR01MB3474 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=no 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 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. Fixes: b98ce2f4e32b ("dmaengine: imx-sdma: add uart rom script") 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