From patchwork Thu Aug 25 12:59:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ashok Reddy Soma X-Patchwork-Id: 1670245 X-Patchwork-Delegate: monstr@monstr.eu Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.a=rsa-sha256 header.s=selector1 header.b=k2nZXznd; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4MD33Y0CQTz1yg7 for ; Thu, 25 Aug 2022 23:00:25 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 5B92C8488C; Thu, 25 Aug 2022 14:59:50 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="k2nZXznd"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id EBC618488E; Thu, 25 Aug 2022 14:59:40 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2071.outbound.protection.outlook.com [40.107.93.71]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 15B5B84887 for ; Thu, 25 Aug 2022 14:59:38 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=ashok.reddy.soma@amd.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cDZyrYj2MgxIFV+A6wMrkDFtDR/aPrlUeeL6IIXYL98Z+ge2zK8xG9iJNwOQZ8ycn/Fp2WVa7/IRdyKRMBaMnPO08MuA3Mqegbm8VGHyrXKdYIFYIUwOA71hHxqlbbnW2izp1gI/lBGnNibLbL7yZgsE2fVGDdZOvhm3vSj6tpZ3U7R0xFPWgbOq+amaxKvt4983Vr8lT2Zj/wGhRy0qFl48mTqZbRROgttjVkaS/BAU4j1qj1URRGh9Zw85C4v7Fegy9PSZX9qqy2a7rzbvkJi8OzeSKeusSfy//XNYggnM5nLja6qrBQuI2Uj8ioclVwTKy9AOf78iYKuMP4ZzYQ== 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=99Qx2tZiPQqt19Zr1/H6XbX8uSHIbvKYH+MitO0JcEY=; b=mjsDYV5lkIWjYU/8jf/Foyf4tspNkwFMuoYdsKm20XPfZirS/4Mkmwb5NtQWkjAUUgThhtf8fARf1OajXWSVM4CV1vs8OA2DnxQYYKtXU7/w9+hEeG2k8H/splQmGxuOEhvZbZbpEsFwebRN3qZrEoCqzvODQoZZBWw9FhbzUOdo8I1UeeKn7vk0Fm59ljb+9UrX8YuP+Az2oBYHaczXtkaszvI+xdwson1cYgf1us9YuaHHuFv1pfwoNr5eS2WvcsXgkvVTCLaJgNaDoijaDmi2RQ302qzUmORzloeCZnZ4VKsm5JyEeAv3n2NjPmOMoRppp22Mllpr7oICyF5+RA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.denx.de smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=99Qx2tZiPQqt19Zr1/H6XbX8uSHIbvKYH+MitO0JcEY=; b=k2nZXzndfMhHr7mgEiV0nZdlKOqWNwGdj8LoeJSfvYaVcfTVtCHsE0oWd//uowi3pYpTn+vdPkfpRSVRJi8s9N2Rg/kY8kol6mistsZjTbrBBv40Ab2ZdyyT7mVSEtdu0dbv08gL0jSb8sGhueYsFIcQG5B2F8N88SdmclsIUg8= Received: from BN9P223CA0018.NAMP223.PROD.OUTLOOK.COM (2603:10b6:408:10b::23) by DM6PR12MB4316.namprd12.prod.outlook.com (2603:10b6:5:21a::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5566.15; Thu, 25 Aug 2022 12:59:31 +0000 Received: from BN8NAM11FT011.eop-nam11.prod.protection.outlook.com (2603:10b6:408:10b:cafe::8c) by BN9P223CA0018.outlook.office365.com (2603:10b6:408:10b::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5566.15 via Frontend Transport; Thu, 25 Aug 2022 12:59:31 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB03.amd.com; pr=C Received: from SATLEXMB03.amd.com (165.204.84.17) by BN8NAM11FT011.mail.protection.outlook.com (10.13.176.140) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5566.15 via Frontend Transport; Thu, 25 Aug 2022 12:59:30 +0000 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28; Thu, 25 Aug 2022 07:59:30 -0500 Received: from xhdashokred41.xilinx.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28 via Frontend Transport; Thu, 25 Aug 2022 07:59:28 -0500 From: Ashok Reddy Soma To: CC: , , , , Ashok Reddy Soma Subject: [PATCH 4/6] spi: zynqmp_gqspi: Fix issue of reading more than 32bits length Date: Thu, 25 Aug 2022 06:59:04 -0600 Message-ID: <20220825125906.11581-5-ashok.reddy.soma@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220825125906.11581-1-ashok.reddy.soma@amd.com> References: <20220825125906.11581-1-ashok.reddy.soma@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4f749694-92a6-443b-e4b3-08da8699a69f X-MS-TrafficTypeDiagnostic: DM6PR12MB4316:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: qbGE9evAQhyc5Bzf7lCfV4nZETAIip2AmwWisELSHUjoNj8CLNoaqjq4R08eq3p8QHYWd2+vLAYnqQuD7TmDFybkaboQMWV4Mm4+RdG7pfL4/ExYPEGDRkglx6r73dbsnrcxjZS4XCGItr1yjWsTgf3F88ydhL5gdUZxB41/9P7uIifECd2lHhlqRoJhWwHuLh8Fru8xLQYEYSiU4T9HnRpcD22uzUKGffk7NDC5xx/kF3wf+PxAEV1dk9WhHC1SzSpR8Zgd9bztVzT63//mDy2HIvXyVAIkuYmaQx6CWvEmpKmv85n7EK2xZUDKwT+5rogQbmnKXRLiCdZ34UsJ1XjaJTa8QClPCwTbiqqx9XOquz8OVrMImJUc0TDMb6VXtmi5//2U3BrAG3RFpaPk9XPqvFMO7ByiMXv6H2M4XGY8AAnF15HJbw0xoiK2cevyNaEKMLoxv1n2hPhWJz5ux3u3FK6269j80vKaGXCZuIE37VE42bDiNjUN7Ppd7VdVhARC4i037OzGtW57hNFwR2/OMYa/B3GkTR8XX/VAZKyLo5sLwu0oozDcxE+GEe+Agaji/VvPHuLpiWfIyVBLfpoXDPpBQw7P67jgCCEUcbEfD7A5LPKiYKCNL1J264Uqz2WBvU8/USAm8j4Fzl2Q3UMsBN01R4fn/ItDxilXBqlyRb2rW4nvWBkUk7qrozQVy4DA44gFl++UDL8i+fF9fvJot55G0Jv9gTA0CAVIhFt+JdiekwZELAAl2M6jZCBy/by0iVZBmLe0PLT4pfgMdQmD1UUHUNzPOfEyNka3W+0= X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB03.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230016)(4636009)(396003)(39860400002)(376002)(346002)(136003)(40470700004)(46966006)(36840700001)(40460700003)(86362001)(54906003)(70206006)(4326008)(40480700001)(1076003)(8676002)(82740400003)(426003)(336012)(186003)(6666004)(316002)(70586007)(6916009)(41300700001)(81166007)(26005)(356005)(47076005)(36860700001)(2616005)(82310400005)(478600001)(83380400001)(8936002)(2906002)(103116003)(36756003)(5660300002)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Aug 2022 12:59:30.9180 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4f749694-92a6-443b-e4b3-08da8699a69f X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT011.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4316 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean As the flash sizes are increasing day by day, QSPI can have devices of size > 512MB. In qspi driver we are trying to read all the data at once using DMA. The DMA descriptor destination size is only 29bits long. QSPIDMA_DST_SIZE 0xFF0F0804 BITS: 1:0 Reserved to keep word alignment BITS: 28:2 Number of 4-byte words the DMA will transfer BITS: 31:29 Reserved: Returns 0 when read, writes ignored So we can only transfer data of 0x1FFFFFF0(512MB minus 4bytes) bytes. Anything above will overflow this register and will ignore higher bits above 29 bits. Change the DMA functionality if the requested size is greater than or equal to 512MB to read 256MB chunks. Signed-off-by: Ashok Reddy Soma --- drivers/spi/zynqmp_gqspi.c | 62 ++++++++++++++++++++++++-------------- 1 file changed, 39 insertions(+), 23 deletions(-) diff --git a/drivers/spi/zynqmp_gqspi.c b/drivers/spi/zynqmp_gqspi.c index 78a1b48731..d5ccb48fde 100644 --- a/drivers/spi/zynqmp_gqspi.c +++ b/drivers/spi/zynqmp_gqspi.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #define GQSPI_GFIFO_STRT_MODE_MASK BIT(29) @@ -666,38 +667,53 @@ static int zynqmp_qspi_start_dma(struct zynqmp_qspi_priv *priv, u32 addr; u32 size; u32 actuallen = priv->len; + u32 totallen = priv->len; int ret = 0; struct zynqmp_qspi_dma_regs *dma_regs = priv->dma_regs; - writel((unsigned long)buf, &dma_regs->dmadst); - writel(roundup(priv->len, GQSPI_DMA_ALIGN), &dma_regs->dmasize); - writel(GQSPI_DMA_DST_I_STS_MASK, &dma_regs->dmaier); - addr = (unsigned long)buf; - size = roundup(priv->len, GQSPI_DMA_ALIGN); - flush_dcache_range(addr, addr + size); + while (totallen) { + if (totallen >= SZ_512M) + priv->len = SZ_256M; + else + priv->len = totallen; - while (priv->len) { - zynqmp_qspi_calc_exp(priv, &gen_fifo_cmd); - zynqmp_qspi_fill_gen_fifo(priv, gen_fifo_cmd); + totallen -= priv->len; /* Save remaining bytes length to read */ + actuallen = priv->len; /* Actual number of bytes reading */ - debug("GFIFO_CMD_RX:0x%x\n", gen_fifo_cmd); - } + writel((unsigned long)buf, &dma_regs->dmadst); + writel(roundup(priv->len, GQSPI_DMA_ALIGN), &dma_regs->dmasize); + writel(GQSPI_DMA_DST_I_STS_MASK, &dma_regs->dmaier); + addr = (unsigned long)buf; + size = roundup(priv->len, GQSPI_DMA_ALIGN); + flush_dcache_range(addr, addr + size); - ret = wait_for_bit_le32(&dma_regs->dmaisr, GQSPI_DMA_DST_I_STS_DONE, - 1, GQSPI_TIMEOUT, 1); - if (ret) { - printf("DMA Timeout:0x%x\n", readl(&dma_regs->dmaisr)); - return -ETIMEDOUT; - } + while (priv->len) { + zynqmp_qspi_calc_exp(priv, &gen_fifo_cmd); + zynqmp_qspi_fill_gen_fifo(priv, gen_fifo_cmd); + + debug("GFIFO_CMD_RX:0x%x\n", gen_fifo_cmd); + } + + ret = wait_for_bit_le32(&dma_regs->dmaisr, + GQSPI_DMA_DST_I_STS_DONE, 1, + GQSPI_TIMEOUT, 1); + if (ret) { + printf("DMA Timeout:0x%x\n", readl(&dma_regs->dmaisr)); + return -ETIMEDOUT; + } + + writel(GQSPI_DMA_DST_I_STS_DONE, &dma_regs->dmaisr); - writel(GQSPI_DMA_DST_I_STS_DONE, &dma_regs->dmaisr); + debug("buf:0x%lx, rxbuf:0x%lx, *buf:0x%x len: 0x%x\n", + (unsigned long)buf, (unsigned long)priv->rx_buf, *buf, + actuallen); - debug("buf:0x%lx, rxbuf:0x%lx, *buf:0x%x len: 0x%x\n", - (unsigned long)buf, (unsigned long)priv->rx_buf, *buf, - actuallen); + if (buf != priv->rx_buf) + memcpy(priv->rx_buf, buf, actuallen); - if (buf != priv->rx_buf) - memcpy(priv->rx_buf, buf, actuallen); + buf = (u32 *)((u8 *)buf + actuallen); + priv->rx_buf = (u8 *)priv->rx_buf + actuallen; + } return 0; }