From patchwork Thu Apr 8 04:02:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quanyang Wang X-Patchwork-Id: 12189929 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=-16.8 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,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT 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 C499DC43461 for ; Thu, 8 Apr 2021 04:06:31 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (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 427BE611BE for ; Thu, 8 Apr 2021 04:06:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 427BE611BE Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=windriver.com 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=desiato.20200630; 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:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=R7cDTRjH9kppLP96Jkz72vOjMc5J3u4k8l5/WxCFDi0=; b=JCrcd6VTW4V3pZeEqV7lHxl26 XOXGr9EGk6VxTOZ8kkxQBp/ILDIwynz+BCClRzHrxFzB1DGTzSxMouDl1iEpA87khV8ZcwL1ekD8n fUmxm6yk0NNVWjcNtVhwStkXhdoX8tGlWEJ8DqrmNxhRmm/W571ACqygFvOf3M1TmTn/7UNvM5yLx Ebm/9U2Of/dWwCJ8b2FIIGocQBEfrVFDcjpLJMWAirpg4ILO8fnzcndmKDTvzW8u5TIpVHCjmXAU8 7ydGfdTVQmaIfrGOYqMHQgo0xOIU+jCeR6fudJhu2rg+5UgeviUdmmds9NZ6ONnDjZxhwy/W9SmnX sXhG2qOxA==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lULuJ-006l7t-53; Thu, 08 Apr 2021 04:04:39 +0000 Received: from mail-mw2nam12on2077.outbound.protection.outlook.com ([40.107.244.77] helo=NAM12-MW2-obe.outbound.protection.outlook.com) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lULtf-006kye-Te for linux-arm-kernel@lists.infradead.org; Thu, 08 Apr 2021 04:04:12 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EC0jXD5w4jK/PO/U0KIeq6nU3SdFS1VM6Gx3f4JMkjC4Lyp71el0E1TXACZFKVxlj4mVkbNLc+7SFhEIrAqxOeRNrK1pxnzmxUKJZ1zneaywUi3Ria2Bnbw8uLPfiCiQwrDCexu49L1l22lV0yjd8iSwai4SgDFIXufeSS/IP6PSbXHJTGtoU2uEn3Svpnvg/2q3HBIDgoVyQP6Dlv/ahNMaMtEApcFqG3PRgh0gnJHLeEDu6XssyrV5rGQvH8IhOtZwy8/cY0Ljew6KrtyPfOSth7sEAY2hsXX+VQ4EbrOZ0L934h0Uke6osgCr8ffF6GSpE1nevzcxQhlVQYYTrw== 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=IN7j0gso45bPrIgnwvPEp25vyLarXsMx11CsrlZB364=; b=nKglv5XYzK9I0Ov78sa2jMJkLV6lulQyOTIwsHubbaO9mjeZcOLGT8YhEfzzwl4Ozw6Gz1MCZL6bU/CSSx7D4wR5izngG7XssR4q2yw/do70YoWpoamI5FWdTfm74kLBTE1jjeK7Pma2Zw6xnFrlOPiisX5EI8g4aWlO26c2BiF9D5hPlcS7GaTAcWDMjuJU2x8R3jCmXyt6WPtBRg/a5ZW61S+Gy5+8Uv/VPACUz2YMuX1AYvz7ARlDEYF6hoNnBnlZKRGCe+lzEosrD6ZtIgBNb4iIEciBrdma+z8ihd3LcIpPUzAZ9iaySlOi2mVuycFZd7j1dx/yX+NZd6w4qw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=windriver.com; dmarc=pass action=none header.from=windriver.com; dkim=pass header.d=windriver.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=windriversystems.onmicrosoft.com; s=selector2-windriversystems-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=IN7j0gso45bPrIgnwvPEp25vyLarXsMx11CsrlZB364=; b=JL8EhE5DRbSHX5F2Q9Zm0/55bonULHLWjEIJN5wWUsp9TsZd86kSj06hFXOlerF6DBUGnr+6qwzUkinKxPQDK1+HeXpkmLXO3i/tp7nGcMe70C+hf4KLD2GNOYKhrGs+Z8dYXt0D3tehZs21YkSy54QtaPHEsfa6ErrIu9UOYKs= Authentication-Results: kernel.org; dkim=none (message not signed) header.d=none;kernel.org; dmarc=none action=none header.from=windriver.com; Received: from CY4PR11MB0071.namprd11.prod.outlook.com (2603:10b6:910:7a::30) by CY4PR11MB0071.namprd11.prod.outlook.com (2603:10b6:910:7a::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3999.32; Thu, 8 Apr 2021 04:03:55 +0000 Received: from CY4PR11MB0071.namprd11.prod.outlook.com ([fe80::f45f:e820:49f5:3725]) by CY4PR11MB0071.namprd11.prod.outlook.com ([fe80::f45f:e820:49f5:3725%6]) with mapi id 15.20.3999.032; Thu, 8 Apr 2021 04:03:53 +0000 From: quanyang.wang@windriver.com To: Mark Brown , Michal Simek , Amit Kumar Mahapatra Cc: linux-spi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Quanyang Wang Subject: [PATCH 3/4] spi: spi-zynqmp-gqspi: transmit dummy circles by using the controller's internal functionality Date: Thu, 8 Apr 2021 12:02:22 +0800 Message-Id: <20210408040223.23134-4-quanyang.wang@windriver.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210408040223.23134-1-quanyang.wang@windriver.com> References: <20210408040223.23134-1-quanyang.wang@windriver.com> X-Originating-IP: [60.247.85.82] X-ClientProxiedBy: HK2PR02CA0138.apcprd02.prod.outlook.com (2603:1096:202:16::22) To CY4PR11MB0071.namprd11.prod.outlook.com (2603:10b6:910:7a::30) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from pek-qwang2-d1.wrs.com (60.247.85.82) by HK2PR02CA0138.apcprd02.prod.outlook.com (2603:1096:202:16::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4020.17 via Frontend Transport; Thu, 8 Apr 2021 04:03:51 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: bcca6eca-6842-447f-b2ba-08d8fa4352e3 X-MS-TrafficTypeDiagnostic: CY4PR11MB0071: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7691; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: LUXvbIrWoSoVWxqvHALaLq8l1VgUhjM1tqgvrRcxgew2/w/aZ1R+QTmPa+Do8CjBoeK8GIXUtz5iX4aDndkhExOjjrGKnZSefKbvnwLw2f2KGuIkS1rSAkIg3Mxcx/SM3EFYB3utzC7YPuad021VHfiL466pIbGXVmBeyVudFUr2DCMzCHK/9BSXWVGr6vpmcO864Ei30RC3xQuVoKURdTdYT55TE4QU23UPhDz60Z+0mUs2CDZEwSopEaxTOeHURBKQqnVdcYpxWP9Q/ZsfCD1kWQ3MMqB5lqHXwCapIc1L0xNVAIvYOWRBraUhdsx4A7rBv5tDDdSWxKQbWNQ6XOQ6G1c9StVXmWaaZCindv8mk2qusLLPnS3kXJ718+mwIri4lr2p+VzWcHET7E5YLqW+rcrT83VvVgul6wDKp0XOGIo615lZFas6ucTbiZGZdU+e43wsESCOsJTm8MM1i0SpvRCTZOaP0sksZH1onbm/ZqkDBenM92QWbY/XJFZivpftMs10v+KBsO9ui5d+KMxciqby/wcdpES2caOMhluUTJlUYBa8PgPW8wIDbXLL7XbTaVgGA8dVFfTWHiGfQNa65Q01o07k/TawA6TGOR4BSJIeMv0Yvb1CxyG7LM3ZzvIUWqK1Y/9oPVxGmmZyv0fOpsgq8KTEg6SkJrHiMSVGKpI6e/4oXOXERqbyaV8q X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:CY4PR11MB0071.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(136003)(39850400004)(396003)(376002)(346002)(38100700001)(16526019)(66946007)(66476007)(86362001)(6666004)(107886003)(38350700001)(6512007)(110136005)(6486002)(83380400001)(36756003)(26005)(52116002)(316002)(9686003)(8936002)(66556008)(5660300002)(478600001)(6506007)(956004)(186003)(8676002)(1076003)(4326008)(2616005)(2906002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Lf38QvdeiWXl7XL3z48f22dvS3l7wNOm4wk3WiZx3tEUnPGOdTiLwPhwNPFB/0bEdSWNOohuJ24t/RMbITguzLv9j6GmuDlV+bxY58XDHAanspIG7JNKQByoWWcPGnQqJAhuiTFW1zkwlXrRbFDXElLbFHPfdztorB4zY6hYtJbi+Agzkatf7h/UC0z4/+eymY6HXSGmXrijTZ9tw0PGzrx5wZVYz0tQJtsrzTBp1fauWAIXO8r9Zqv5U6/nFbyqGV0byNmEKKdfa2y4o4M0yJKrbIWLYDl7HNCrAcsK4Dnw X-OriginatorOrg: windriver.com X-MS-Exchange-CrossTenant-Network-Message-Id: bcca6eca-6842-447f-b2ba-08d8fa4352e3 X-MS-Exchange-CrossTenant-AuthSource: CY4PR11MB0071.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Apr 2021 04:03:53.6620 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 8ddb2873-a1ad-4a18-ae4e-4644631433be X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: gHsqhL+cZHvn01d+FZ9QjHiepGjYHh9HahRpnea6y9ErQXfX1dNXOmcHjdNGfV6OeV/YD5FN3Jxf7kZhjP04DtZigHoeY0PvhfPAuE7PFGo= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR11MB0071 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210408_050400_056231_FBD03015 X-CRM114-Status: GOOD ( 14.63 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Quanyang Wang There is a data corruption issue that occurs in the reading operation (cmd:0x6c) when transmitting common data as dummy circles. The gqspi controller has the functionality to send dummy clock circles. When writing data with the fields [receive, transmit, data_xfer] = [0,0,1] to the Generic FIFO, and configuring the correct SPI mode, the controller will transmit dummy circles. So let's switch to hardware dummy cycles transfer to fix this issue. Fixes: 1c26372e5aa9 ("spi: spi-zynqmp-gqspi: Update driver to use spi-mem framework") Signed-off-by: Quanyang Wang Reviewed-by: Amit Kumar Mahapatra --- drivers/spi/spi-zynqmp-gqspi.c | 40 +++++++++++++++------------------- 1 file changed, 18 insertions(+), 22 deletions(-) diff --git a/drivers/spi/spi-zynqmp-gqspi.c b/drivers/spi/spi-zynqmp-gqspi.c index 3b39461d58b3..cf73a069b759 100644 --- a/drivers/spi/spi-zynqmp-gqspi.c +++ b/drivers/spi/spi-zynqmp-gqspi.c @@ -521,7 +521,7 @@ static void zynqmp_qspi_filltxfifo(struct zynqmp_qspi *xqspi, int size) { u32 count = 0, intermediate; - while ((xqspi->bytes_to_transfer > 0) && (count < size)) { + while ((xqspi->bytes_to_transfer > 0) && (count < size) && (xqspi->txbuf)) { memcpy(&intermediate, xqspi->txbuf, 4); zynqmp_gqspi_write(xqspi, GQSPI_TXD_OFST, intermediate); @@ -580,7 +580,7 @@ static void zynqmp_qspi_fillgenfifo(struct zynqmp_qspi *xqspi, u8 nbits, genfifoentry |= GQSPI_GENFIFO_DATA_XFER; genfifoentry |= GQSPI_GENFIFO_TX; transfer_len = xqspi->bytes_to_transfer; - } else { + } else if (xqspi->rxbuf) { genfifoentry &= ~GQSPI_GENFIFO_TX; genfifoentry |= GQSPI_GENFIFO_DATA_XFER; genfifoentry |= GQSPI_GENFIFO_RX; @@ -588,6 +588,11 @@ static void zynqmp_qspi_fillgenfifo(struct zynqmp_qspi *xqspi, u8 nbits, transfer_len = xqspi->dma_rx_bytes; else transfer_len = xqspi->bytes_to_receive; + } else { + /* Sending dummy circles here */ + genfifoentry &= ~(GQSPI_GENFIFO_TX | GQSPI_GENFIFO_RX); + genfifoentry |= GQSPI_GENFIFO_DATA_XFER; + transfer_len = xqspi->bytes_to_transfer; } genfifoentry |= zynqmp_qspi_selectspimode(xqspi, nbits); xqspi->genfifoentry = genfifoentry; @@ -1011,32 +1016,23 @@ static int zynqmp_qspi_exec_op(struct spi_mem *mem, } if (op->dummy.nbytes) { - tmpbuf = kzalloc(op->dummy.nbytes, GFP_KERNEL | GFP_DMA); - if (!tmpbuf) - return -ENOMEM; - memset(tmpbuf, 0xff, op->dummy.nbytes); - reinit_completion(&xqspi->data_completion); - xqspi->txbuf = tmpbuf; + xqspi->txbuf = NULL; xqspi->rxbuf = NULL; - xqspi->bytes_to_transfer = op->dummy.nbytes; + /* + * xqspi->bytes_to_transfer here represents the dummy circles + * which need to be sent. + */ + xqspi->bytes_to_transfer = op->dummy.nbytes * 8 / op->dummy.buswidth; xqspi->bytes_to_receive = 0; - zynqmp_qspi_write_op(xqspi, op->dummy.buswidth, + /* + * Using op->data.buswidth instead of op->dummy.buswidth here because + * we need to use it to configure the correct SPI mode. + */ + zynqmp_qspi_write_op(xqspi, op->data.buswidth, genfifoentry); zynqmp_gqspi_write(xqspi, GQSPI_CONFIG_OFST, zynqmp_gqspi_read(xqspi, GQSPI_CONFIG_OFST) | GQSPI_CFG_START_GEN_FIFO_MASK); - zynqmp_gqspi_write(xqspi, GQSPI_IER_OFST, - GQSPI_IER_TXEMPTY_MASK | - GQSPI_IER_GENFIFOEMPTY_MASK | - GQSPI_IER_TXNOT_FULL_MASK); - if (!wait_for_completion_interruptible_timeout - (&xqspi->data_completion, msecs_to_jiffies(1000))) { - err = -ETIMEDOUT; - kfree(tmpbuf); - goto return_err; - } - - kfree(tmpbuf); } if (op->data.nbytes) {