From patchwork Thu Apr 8 04:02:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quanyang Wang X-Patchwork-Id: 12189965 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,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, USER_AGENT_GIT autolearn=ham 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 47BC9C433B4 for ; Thu, 8 Apr 2021 04:03:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1E216611BD for ; Thu, 8 Apr 2021 04:03:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229556AbhDHEEB (ORCPT ); Thu, 8 Apr 2021 00:04:01 -0400 Received: from mail-dm6nam11on2088.outbound.protection.outlook.com ([40.107.223.88]:17249 "EHLO NAM11-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229469AbhDHEEB (ORCPT ); Thu, 8 Apr 2021 00:04:01 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iqCuckVC0QusA9CgPkiZfLCEz4q2mBksKCNyOceqa/PscAUAvOvEdXOSIUb6rhDjHiBdkqCzyclm9dTAYPjTaAXlm/yrn9Pd+NEr2YXFXw7ckDBv0pwzr+ID+TaQNoe6LPCmqeAWeb5ZInr0drXFJvlWD441vEak0eIENrkSbE+/FTaMhz8ksKujlU/ZuuvlFvbp+ObEk+LCfqz09/8LyXOZ7UzqXq+HUhaJIX+9ltgKdwNyMwZ8to4zbQ2F2EFoTqWs3BJW8fiBFLuM1bgByOdNYXwfF5vaIfcjGQfBrPQHcK1CSDNBYmDK6AP2UQaxg6AAusU7FKMCQX4zp1S8rg== 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=ZwKVEu19h84PYMaGoeAJmqZk5WCUUb0gxrs6pZZAL5o=; b=AZAlDUE7xMBT7cS3pAYXlcQNLRTKgCZaiI7IefhHaf6xEJ4h1z0pDfNijhvG1x8TZEPNOPWz1tNDr6i7Bg9A2ZfR5kzmhtTVA+huQx1hCs1QpecD6v+nVcuehrPkxKXkq0Z/syrL8JZht9XLzhh6PHJQvuaD9soqqUquCEKv5Lgfb9DaDmfrP7roD19gwj1LGFBwu+atEP7Psz2K34GrtO6xVCKhVx88rc7CLIaaj+TL2hzKPu80Kubg6VpBUOo3V+rlAX0jtx0JOG7jffzuXTJP/P/iJ6ETWWJJRHQXggFK28Hct0eP+7BAEWk4rQDY9fMo1oLq4kqPt1zDxLidWg== 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=ZwKVEu19h84PYMaGoeAJmqZk5WCUUb0gxrs6pZZAL5o=; b=PjdpO9jsHlOeACsESWIbOYq+NaIdBTryz9LM0Fjumcr5Qc2JrqhxBUujbSQTs+qxSW+7X1L3dcF8zomNMDs4Hbs9sgWG8IeP5fG4NZWbHtxx2DHFHJdJegwJticlwn9siqo9w0pQwbh23RxhfuIPSvz5nv3F8tufmI7Ji5mWT2A= 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 CY4PR11MB1351.namprd11.prod.outlook.com (2603:10b6:903:26::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3999.29; Thu, 8 Apr 2021 04:03:48 +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:48 +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 1/4] spi: spi-zynqmp-gqspi: use wait_for_completion_timeout to make zynqmp_qspi_exec_op not interruptible Date: Thu, 8 Apr 2021 12:02:20 +0800 Message-Id: <20210408040223.23134-2-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:45 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 39b9972e-0527-4429-62c2-08d8fa434fa8 X-MS-TrafficTypeDiagnostic: CY4PR11MB1351: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6430; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 4tpTNY0ShAxUEAG78pWOTSxEZ8EHMReJnbHu3Dj784MHBAgGrSqKsLCJbjWfmJbcfzU3yP6V01DEdYnmKA/dsnwY4fsD7nl37M8SF0h7IqsHReSN1rK4PWbLXHJxjBhDZtWWXgZikNIaKSqMwSZRg8nmJVIrg/eCZPMpRo0fq1ARAp+AuAJGnQetI2V65Os4ta9QQkoV6C2APO03GA8Yow1r6uYcxkxsRb2GNfDav2gutdCYiY2LgS2n213aBUdNHuhMaX+ci1RY13OxXcHDrO5hPx3AQmW9eQr3Rcz6hx0YhXr5w6GE8QXJgqq+0gvnsHfPrIdK54v4H/DM5Zh9bcZJMNBiT2uP1PydsJmEEk/O5mxZ3MPMY0HZfjCwFuhYoK5Fo41wY7dWk/0HQtWd8qALvHQRbO7e7isqFYmDcc0kyL0VDrminAhdxLquWeKFjA1N3nGclJ/qkM78CR4lgI3ksxZXWatk2SIq9jpuP9mqWQHqUgugOy/RBQPQDUYUIsKsVDMwK+deg9Prs3t8pQ0lRfGiQDfKZv+G3rR4Xn0/YJrM8ThXNHr4rL3n9gJ6/EeWGHbB4Cg80Qg/QShK6YgZO4YwZYNLDthZiN+NBUuuviKdXKTxkFCoy/CZgjRMyHfdQr9a6GSXEHRzIpp8m1XL6RAduOKM6UsYk1EGwqJdJqtZLkI2HbxALr6dPpBX 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)(346002)(136003)(366004)(376002)(39850400004)(396003)(8936002)(478600001)(36756003)(38350700001)(6512007)(66476007)(2906002)(8676002)(83380400001)(26005)(186003)(16526019)(66556008)(9686003)(38100700001)(107886003)(6506007)(316002)(86362001)(52116002)(1076003)(6486002)(110136005)(5660300002)(956004)(66946007)(2616005)(4326008)(6666004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: rKTCA2ullNijtEv44rndSTUnHAhTIFZWpJ0wjy09RNM/yuSrtddzduJB18NwWVvUY5bYGymh8jGmsVB+AXKMtQNBzQUCkEpSAM4d3QxxYqnaLNwvaBD5XTx6lN6uot1ce74+GYu+QH3j3dVM6w1z1QPYt4RPRf5E/wRDngIgGslsjaJzManbgu0v4x55y1izYdu5BJfTW2bAalsSMkyPO5DRZkQ4Trs1Gd85CZ8r0NYPjxlByApBZleJTGMrTLQwMXHD2k3ldAWyPOtvjWxVWiK4qbinxvUSvNLFOo4N/gPrXT0B3MI5z2GtJ6a/RAZUUl8hxKDqroGxJ5GTL20XTJsW7h3gZOgURikQ1uRPVkuzA4nqclKHuFQZwy6ZjoEwxqTu9l1q7IOoyWQQmiRFEdZL3Wp0sB+SmcNq89EBnsNW3wTpAZmiYx3GPfryy5d2ScNjip8S9IXaBVmMywMakbZz48ePv8lbY+6AOFyQWMkY0g/NgyRQMXF6F3HpcDxhPU1E+dlYD99UO6qYLhzKN9Dwt44Pk9Ey/oELxl08NZnxg/Wht55w3tNqGW142BJSrs2mS5xXuRF9EtuJde+WytCJEGaqSjOQnCKjaioFySMyn8x/H3+i7DtBDonbAJrVUuYvG/RUBroLdC+e5VMKefCNB1C39sLWB5UiKahZU/LUYCsgHRx5958Er9H00uojV6atLo3fvgg+/N8Od6wH8nLPS1RUmJcm3vt6FouUaNH/OYXFhYOzEqGUbcDMNZgxEN9HZPyPIx2AJ2D723zobPFXyEihIstGHB5d/oDF/7WPIN5MW2KDvjGwo/Dc6Ncnmvu8Mp2S2P9BkQfnAjzVBA01e+FuAB63K+1CPwKZQ4ZdIixl1YMYvl5BgGSIPliJKEUc91RQccY/2I+CJkB0FGPWHzndzt3Lsjk9KgPfrN5UHTg2wyumt1dd1SYLr/9p9qfC4GIdRThmppERv+URJ5XRkN37rFdRo3kX0pZuNdKgM7svIYEhxDyFIbof1u4uHF5tBWCGl6eOdjs8qGyBM0UPs+TrixcaMEQiezYquRu7XvgTuVYeUFVQhxACK5xCFWaZRw9YzAFlJF0H0ApYwowVErgk3Kc4JUidc6xa7ClmEX+9ieq4hZqNgv5ItK+jQBsMfoeok5YKuJnohME41IEUPlUqNE6ciun5r3nWoJmf4uSWJ7xW8iVbtOwD3toRMPFYtSZERF9RLHSCzcSCz/zNYjhm89xNIzbMErkT4hcxzPH5enH/uCMga72FmGhddoeVZLlsI+VvV4w0lSv9pOn8d1Z0n5TTbFbUk7/EvCynukJai9Ura6SWWqF+G6U8 X-OriginatorOrg: windriver.com X-MS-Exchange-CrossTenant-Network-Message-Id: 39b9972e-0527-4429-62c2-08d8fa434fa8 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:48.2841 (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: rGqemfY5+UwtbdxDu05nzbEDoA7B6taBfTUuM6GECjsRDNCzmvxx4Wqas42kVupMMcqCgMsTCsSQ0bkDyyxkX0+PAv4Yhs6FvjHw9vqnwt4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR11MB1351 Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org From: Quanyang Wang When Ctrl+C occurs during the process of zynqmp_qspi_exec_op, the function wait_for_completion_interruptible_timeout will return a non-zero value -ERESTARTSYS immediately. This will disrupt the SPI memory operation because the data transmitting may begin before the command or address transmitting completes. Use wait_for_completion_timeout to prevent the process from being interruptible. This patch fixes the error as below: root@xilinx-zynqmp:~# flash_erase /dev/mtd3 0 0 Erasing 4 Kibyte @ 3d000 -- 4 % complete (Press Ctrl+C) [ 169.581911] zynqmp-qspi ff0f0000.spi: Chip select timed out [ 170.585907] zynqmp-qspi ff0f0000.spi: Chip select timed out [ 171.589910] zynqmp-qspi ff0f0000.spi: Chip select timed out [ 172.593910] zynqmp-qspi ff0f0000.spi: Chip select timed out [ 173.597907] zynqmp-qspi ff0f0000.spi: Chip select timed out [ 173.603480] spi-nor spi0.0: Erase operation failed. [ 173.608368] spi-nor spi0.0: Attempted to modify a protected sector. 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 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/spi/spi-zynqmp-gqspi.c b/drivers/spi/spi-zynqmp-gqspi.c index c8fa6ee18ae7..d49ab6575553 100644 --- a/drivers/spi/spi-zynqmp-gqspi.c +++ b/drivers/spi/spi-zynqmp-gqspi.c @@ -973,7 +973,7 @@ static int zynqmp_qspi_exec_op(struct spi_mem *mem, zynqmp_gqspi_write(xqspi, GQSPI_IER_OFST, GQSPI_IER_GENFIFOEMPTY_MASK | GQSPI_IER_TXNOT_FULL_MASK); - if (!wait_for_completion_interruptible_timeout + if (!wait_for_completion_timeout (&xqspi->data_completion, msecs_to_jiffies(1000))) { err = -ETIMEDOUT; kfree(tmpbuf); @@ -1001,7 +1001,7 @@ static int zynqmp_qspi_exec_op(struct spi_mem *mem, GQSPI_IER_TXEMPTY_MASK | GQSPI_IER_GENFIFOEMPTY_MASK | GQSPI_IER_TXNOT_FULL_MASK); - if (!wait_for_completion_interruptible_timeout + if (!wait_for_completion_timeout (&xqspi->data_completion, msecs_to_jiffies(1000))) { err = -ETIMEDOUT; goto return_err; @@ -1076,7 +1076,7 @@ static int zynqmp_qspi_exec_op(struct spi_mem *mem, GQSPI_IER_RXEMPTY_MASK); } } - if (!wait_for_completion_interruptible_timeout + if (!wait_for_completion_timeout (&xqspi->data_completion, msecs_to_jiffies(1000))) err = -ETIMEDOUT; } From patchwork Thu Apr 8 04:02:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quanyang Wang X-Patchwork-Id: 12189967 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,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, USER_AGENT_GIT autolearn=ham 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 E6035C433ED for ; Thu, 8 Apr 2021 04:04:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B50FD611BD for ; Thu, 8 Apr 2021 04:04:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229721AbhDHEED (ORCPT ); Thu, 8 Apr 2021 00:04:03 -0400 Received: from mail-mw2nam10on2053.outbound.protection.outlook.com ([40.107.94.53]:30209 "EHLO NAM10-MW2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229469AbhDHEEC (ORCPT ); Thu, 8 Apr 2021 00:04:02 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WlbhtfnKZYpr6rbHbKZouBmHNanhXPsXu4dt5tIm7kxGhmg6GSbSYptg15NLQBXXee0oavdfNyMLbTD9KSTofrOIYI+uZA7q+DRByn3DqN+tsJCVni8hQzeBXiKf29WTNoHGrvWCP8Ld8hNCssFZmamE03PoTyTsWa8EFWN2mvE2SQY5IbmV4xwbn+xNalqB9zjwlRL/Lt0vN9T2PXowwGVudd3NcXy3Drx0yLJbaED0x6y9gkdeKoLEfiTQq0rBrvQX+nCrM1G3s+/z+orCBM6kEfPd6rTxt7IDD2sHJuOdAIjc9+DaOHlzGEWh9O0bFSWgNQLTNnrlIn3AHnY8xg== 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=J58pVr3GsM+c4wehfY+pfXqMm5nm7A9vpYsR6zaLSzE=; b=ECFpvI7D/5+vOZlQs95nd4Q5ybLEoA+qOpegKoiXwkP+uK++KRRZdkZI36WFQvgQZ7OYwWwr7Qq0HqW5nLGZqaSJRJyWXsUDBF6SSHB16Qu2viXWFxkBO1j1/VcsbN5HsFLtoZ/EHZWVG5PO+RHAZqjaGT/NnXe2Xh7AFqIbo9HZQ8m2v9sSGpOIfH1xS9MNodnkpPpP9okzchmHeyWs16pc3AgHeKJdsAl4g/spnblw+jRhtZvZu5kKtDXWwrN9hQXk9HJaV9oP27Kxw+cx8OvxfpsDvvAGx4/BY3pLMeqywMpoi7W84+RwY6sxOW2bvBpjXh1Pq+mCWlNKKRT/EA== 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=J58pVr3GsM+c4wehfY+pfXqMm5nm7A9vpYsR6zaLSzE=; b=dZbJvi+p2iq+pPvM4NPWrfKPtDu0afe0DY4SLzODekWvd1nyFdKtYgVS4gfw8DE4mtb6eCULb5kOksRNArtGPir95M2ovv8LZxLyk9K552FvECOCCLIE6AFkqGAX3AMJb6HmI7sM1bGsOhUdTJHAJFuk0Z7p/ck/65ogCYNRcmQ= 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 CY4PR11MB1544.namprd11.prod.outlook.com (2603:10b6:910:d::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4020.18; Thu, 8 Apr 2021 04:03:51 +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:51 +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 2/4] spi: spi-zynqmp-gqspi: add mutex locking for exec_op Date: Thu, 8 Apr 2021 12:02:21 +0800 Message-Id: <20210408040223.23134-3-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:48 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 828699d9-d9e3-4be7-f697-08d8fa43514e X-MS-TrafficTypeDiagnostic: CY4PR11MB1544: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1775; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: nbrKqGIal0woYH7Lf4DCuu2W5Rm6YjdYmGfcFTlfoHRKDJclUpPlQBsx+HUy509Ua2ujCa0iXnfC5aJ1CVpjOu4jNra4qgGl+2BZjuQbjuLXxwHMjeePlPDx+XksKmLKFgwQlTqYtvNIGol0XmkaM2MAmcL2t7OwzKp+viTCtvXHvyXfkj1L2oFWO3w8Qz8xk8IAJewYfPM2usTqtcrwgvwK0UPLyLheNpNxGeioXWslB7KriNmJ904dKcSVlbPEYZkX2Tix7+i07CVOky7FQX6+m1SxuVBPS7yFGvHP60ZGmKkrlxjHP+/XZVB598XueVGqYO9B8OMnvS0Xo7H+neMR7DSvV6Cwrf+tXL56JRihA3YJFX+Q+6U2blMCdqMep9IrC9tyLWKkJrawnBq7Bcv8LFV9kUf8t/PHtiUht4yTtVGPWeGT0o7WGcVClzFlWHysaGTGFniLr3A7IZvgzxhKHDYFktZ9wvbF4O8q8Keq9fODinNo+E7oY68qabAXmVhT8bSkMkTf+/POHDbrQfS+ofFGzZJqNX5iWfLJr4j88jI6znEHUiS3feE2uKLuD29F07ewEVHBOfoEdG0gHVXi/f32wddJxdRioq2tjUWZ33rYn3QtL2wJDw3ZCa8vx5xtLe5KwD42VPCG6IycweJfC7Fi7T3YrdnUvAhZLHIejY79D2IkXPT98xKRgI3A 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)(346002)(366004)(136003)(376002)(39850400004)(396003)(8936002)(6666004)(83380400001)(52116002)(107886003)(4326008)(5660300002)(956004)(110136005)(2616005)(6506007)(316002)(26005)(8676002)(38350700001)(16526019)(1076003)(66946007)(86362001)(478600001)(186003)(38100700001)(6486002)(2906002)(36756003)(6512007)(9686003)(66476007)(66556008);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: mnyyqwngfCvmuz0FBEHLb+LC98g8EX7TcHdDYLq3FsMAsE4gTFMRziXEyyfxVrZ0nBwxgWXqL8o0g5y9J/STutnoGBosv0DzNHg0aum4UZuxOpVbgkwXQRNTXyyDXcHBJHtT6fgdXAzSkzYQamFZMIENzMJpwloYTnqC63JTRKWdJeng7T+KkwivROU5ekIyu/6ZWACkgstk5Y1GWqzfPbBFlbWXWX6rfFZKTa7JC6WfhElbyIM29GHDNVz/bjde6ATv8ZYbrkWIGYeAwZJd1bIvsy8FQqpEc3TkPwMuXyPWZsnesPs6BThTaJrzNVwwPeSsnr6OWE3TMx5d6cXe77ML7rwTc2sNNxoT6fwGcRMRbtueQCNABAPKZmas0yHoEWnRng71Y5CilSXX31gNOO3cFIe58fDpc8VZ1w+ZPtnwIL9gT4Y8rSWh9tC7kLtP+fdfRr3oXm9+5WgxzCbA6XzixOgfVQmsWwQdT4gpMdfJSDVIpHMSuulJTgIdZCCSGb0/WiTqDrYeE45E7+yLCQ+QhteVdgv1wRRGvS5FUYg+1PveE0Xna1JRiERPDu8ZJOxZz4hz0vmu4p3j3S0zmAaLrI6I+YcWFoSxQx1mdVt8FusTO+WI1HYEmHBhAs7bmRy7hjWTYkOPJclTYACDdaqwadwLSo3OaTVxl2POxZ9Fas8TGjWwpDa4fDWkrtjLLIP+o6b1RUbKCtDYIQWPqJcdYZx/eck7EONtYJ9meO00hQN9HMk0j+dbePOkDGPNKdm2D04TcY7KcKgebrFA18yJg05+pUGOGJQtLXGDuFx2aa4yNx+Pf1eOXmdH0Fj+AXzkvx+guSxH18wZ/VNjHiO/1hxUvSPykla4CnmsOdAmIsjraxrPxY2b6QlsckVkEolLZ6iMgxANyYIzI+Artbo1D0kipNvD5KXSM4vKRh5OsjZugM9WaaMfZq/6RZ87OBKYcXBTyq2Cl7Ln4B2fJu59gVGif0YyE4NxbKhPhs6mah5Tp+IlkGvA/OAW68wR6E6tj8sb2zNFmkXVGeWN+Jwp0Xb5d+kBwvuIaiKMIBNS+W7G3BFxVmZwwfZa3IgFhkUU8CriRJze13cQcfnKPaiCP2SmYAttJJp607+jBh2eTmlI7HPUVqOSbltf8LRn0cJ9I9XllrccxBKEix1+P7pGWsdTGLxb9JsCaO3qf2HqaUeG+TPl273l6L/z2XBSEnC9lqxJEaBxfq+xjc1RerUsWTa4EydlRlNCzE/JGd//hTk7EfQLNQgl7/rBO0DraXiFyothbmH2f9PPW2ezQ1CV1xVCewDgYVYjYRm6qphMa/afiTWe/RzP6t2b1nu/ X-OriginatorOrg: windriver.com X-MS-Exchange-CrossTenant-Network-Message-Id: 828699d9-d9e3-4be7-f697-08d8fa43514e 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:50.9016 (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: b9a5SO6qHMesi5yqFVgpwbzYynbO8zR6BD0FW35/Xi3fOEMSFdHvvAMkS5mT4vSDkpbIH7GWTRbNI+fA+c8xCixHD7OtOxk13BRkFic4YDU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR11MB1544 Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org From: Quanyang Wang The spi-mem framework has no locking to prevent ctlr->mem_ops->exec_op from concurrency. So add the locking to zynqmp_qspi_exec_op. 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 | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/spi/spi-zynqmp-gqspi.c b/drivers/spi/spi-zynqmp-gqspi.c index d49ab6575553..3b39461d58b3 100644 --- a/drivers/spi/spi-zynqmp-gqspi.c +++ b/drivers/spi/spi-zynqmp-gqspi.c @@ -173,6 +173,7 @@ struct zynqmp_qspi { u32 genfifoentry; enum mode_type mode; struct completion data_completion; + struct mutex op_lock; }; /** @@ -951,6 +952,7 @@ static int zynqmp_qspi_exec_op(struct spi_mem *mem, op->cmd.opcode, op->cmd.buswidth, op->addr.buswidth, op->dummy.buswidth, op->data.buswidth); + mutex_lock(&xqspi->op_lock); zynqmp_qspi_config_op(xqspi, mem->spi); zynqmp_qspi_chipselect(mem->spi, false); genfifoentry |= xqspi->genfifocs; @@ -1084,6 +1086,7 @@ static int zynqmp_qspi_exec_op(struct spi_mem *mem, return_err: zynqmp_qspi_chipselect(mem->spi, true); + mutex_unlock(&xqspi->op_lock); return err; } @@ -1156,6 +1159,8 @@ static int zynqmp_qspi_probe(struct platform_device *pdev) goto clk_dis_pclk; } + mutex_init(&xqspi->op_lock); + pm_runtime_use_autosuspend(&pdev->dev); pm_runtime_set_autosuspend_delay(&pdev->dev, SPI_AUTOSUSPEND_TIMEOUT); pm_runtime_set_active(&pdev->dev); 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: 12189969 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.7 required=3.0 tests=BAYES_00,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=ham 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 03C6EC43460 for ; Thu, 8 Apr 2021 04:04:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CF27161157 for ; Thu, 8 Apr 2021 04:04:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229734AbhDHEEM (ORCPT ); Thu, 8 Apr 2021 00:04:12 -0400 Received: from mail-mw2nam12on2049.outbound.protection.outlook.com ([40.107.244.49]:37793 "EHLO NAM12-MW2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229808AbhDHEEI (ORCPT ); Thu, 8 Apr 2021 00:04:08 -0400 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);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: 6TPPGOaVI4aLUTNWBVJOpsqSeZKVh5PSy1kAExPOIDjXzV5sAX5nvOn6WiOkSD0vCd3lEEm7AuZVIErYk9rjFBYbw/BkILbxcaTW0phePT/whvG73vV2rJ5OUU0GVljcy5vmk8rZqkl2TQECt7kDzb35uEHXD2mbEGqRNYj8jgongNF5sBAqe2ovjHt4qSXBR0Bxyoh6bAS1qz68ORXytv15c5GhLIa+qUhibXGYf+DNbJFcH7XOYQ0V0wQuR8tjFoK3eN2MkXJga3+PORO+ymRugecN6biM+hFZv3Ori1So/W1D8+UMpjLma9xdrbqpKxlYKn+vYjA8v8fnsLblQ1nG3GB5BeCOk0N53SYPt0P1DNfPLhX+rwhxeoxXkL3VVH/mledRxd1QSkG0ZZ1i2K+kKgQRUFw0pp76QbHXrsNinSJcC+3KAhuNSisNSSc04NScE36muTCSNojmuKpL8Wn7s/apHihUXehnX8V/vfkGcc1mLpfMASBqNEtODwJIX4hPfO+BwHdEgQr6UlaaLn51fX2qKQEtmlsbQRoQdrsiy7nfVKJiJCg6mfiw4jAigqyqBzW5820UECLA2/VRPHLuuFJI4KH/fY0oQwEWh3U/0skJSuiTQ4kQtOvT/0HdessruRhMGg9LU+LsjmynKtuLXwko/fCUDH1vKBeevM261zDTDDctopykOcDv+KUR6L0vETdgJsOLuYlGQ6mx7SFlXwysHhkAozniHkV+A1upfbIXtpxK7dnMOnogjw/1WS7DEh93BJNi5WcZnWmiFYqf9EUPVt2Fiag4QB25AHy7e/mJiPBuRthGr8cwrxFQPgJs7PS4VnP/VhrCtrvPPfpL5CYtVUVFt54vM+Dp1R5zLKqQcGGD4lJZZJHZEYeTHWq2GLz4lCEt9ONL/IT9E/BMBmcxYM5NhsNEZzw/Q0VL394nzGj6DBv2m7/mzkS9Tex+pOqyaSDMo9cVvlOKQ53GjHrD7KvY1rjSqFGivjkjJZ5OIzjt3PJhM/IDRwBZYIKd6vaw6x2ooATXH2tHLf38QvdeiWXl7XL3z48f22dvS3l7wNOm4wk3WiZx3tEUnPGOdTiLwPhwNPFB/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 Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.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) { From patchwork Thu Apr 8 04:02:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quanyang Wang X-Patchwork-Id: 12189971 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.7 required=3.0 tests=BAYES_00,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=ham 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 C6CA5C43461 for ; Thu, 8 Apr 2021 04:04:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A07AA611BD for ; Thu, 8 Apr 2021 04:04:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229775AbhDHEEN (ORCPT ); Thu, 8 Apr 2021 00:04:13 -0400 Received: from mail-dm6nam11on2074.outbound.protection.outlook.com ([40.107.223.74]:25953 "EHLO NAM11-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229820AbhDHEEJ (ORCPT ); Thu, 8 Apr 2021 00:04:09 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kKUupt6PixRsm7CLM1gxprtjZNZxiTBrYbvUcdYIsT1iHiJtgCiGVU1fHxSP5UFQ75aHNuncrOuokuweVIuMczIsAkqk+Lgknqijq6Flz4I7MlcS8/AkPg7eXT0P/ZndJ/4n7OvlwV7GRgoz0oN2EsqYpyfozOVQmzk6wd4BIVDnHmAseyA0xc764rTknS0A09eOHYFQbP/QHzPMzcTS/Qt65E3zLI+iyxv2EYnkrf1EPs7v04MYWgf6IOCR89CdJjonKyQ3MueiD0wCGhdI/1xaIor/igaAcRt8qzcsF2Op7Cxj0cbwcONxmx8/EIAokV4DigbiL04krJHJejM4vQ== 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=ejx1z1Qj3X4US1q/1YdrUH2l/JvUF8seAXu7M/925nc=; b=E66BugkBTo+I7tMQu4/RCEGM4ixa5IDE+lyfCfXIui1CxpEC1QQqZGdyaLZa4MGFvA6ThijqBOW5LziRmjQ59M0skVc35OkdWMy6wuQxPvifjlPUrCY17EsTfccNtL9Fehc3PywURIDzsjgmyBuiIwY8vdgUQFHGw0KYSo5Jq930eGJZYAEWGbuZqt6fhRejt3DnbHbkhuO+kWgtAtNL/2ZaqlvjfFWmKRmVPBS9KoPk4NJEtcgkDzx1HB0uK7Mj2jspBEDQKwS3L8DRFKv6cludUI+r+E0G/r6Fmy+ucJTrRkaNbIAvMfj1srUDrQRkYwSDJ4jNQhu/Skjd3sv1mQ== 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=ejx1z1Qj3X4US1q/1YdrUH2l/JvUF8seAXu7M/925nc=; b=nm1HBzVZMdXvGMX28TS/7M/AMsgd0zpCDsPZuZX0j+OnkdN9nD3z9f5ADgA3rOW/AI+9bBKVX8oZOBpcC3pTCofAEwWFOWYM1Q+4iQv8sAiKiWjBhULLDlGXiyg5iRvyyIcmS3lTns2UVomTJbgRQnYt7kwFjxRHWyae4ovDkxs= 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 CY4PR11MB1351.namprd11.prod.outlook.com (2603:10b6:903:26::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3999.29; Thu, 8 Apr 2021 04:03:57 +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:56 +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 4/4] spi: spi-zynqmp-gqspi: fix incorrect operating mode in zynqmp_qspi_read_op Date: Thu, 8 Apr 2021 12:02:23 +0800 Message-Id: <20210408040223.23134-5-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:54 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f7f289e2-8a32-4cfe-cda1-08d8fa435482 X-MS-TrafficTypeDiagnostic: CY4PR11MB1351: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6108; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: auEcOlCHJXogD0ibbjlJKGg119x+jCo75tl9etS9QjRCvN/R1iQYnRLn7N33wcfsgraT+qw/LgcYeNf2fXsiawD+y642CRQ07DGKPM9eLLqeHnohfV9KWZjNnZTQj3K7XUMSowiSdT7lTec5ncjf7+GJmiFfqn3EnbKhc4BWgN3AxkmnlSZukmngbwA6CM+Nn2HOM55vGKt4WTYkiNqO5pjK/+dkPcKnrLDmIz5OnlnCOXA54iAhkCsICXbc7j7jLH3pr84xkDKPGgem+pW8Ll1/wyA3u0/aD7S+ZN7bEJRFudTyIa5bo1GkunWKhPRv0E+a+p0hyD/DFUOR5qUzRiRZ1l8y6wRr/RpnWO8+1ol8fqCIFDQwJTN50jQm40HytU9/cwvpOe9wUOZf+2hMF7qI78z5m0sSJgl4OS6vDDKEXAcoquFKfo9QjuUCngfKRRevO3H20nvUDC6YeshJcHLh/nDErEmtWvo3m3zVZrW2j/FlloxBg4Aq4okgjNpmAtgJkOj6U9NFxjbigeSIlzTKArwY896oeVImbr1kJ6jiVwvbAIWP3YmN3GFs1PhCJwVfKG2rFhzeBal/bZIYhMw+7hcbKa3AEsCHckRBwCTnOmv3ETCXmrUYdFVuLw7eympqa0VoJrGNYZmkiuOzt1VaZUuZ7Jk6aqlEr6Bcdf54S1put93I3BVHUMIf8Uzl 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)(346002)(136003)(366004)(376002)(39850400004)(396003)(8936002)(478600001)(36756003)(38350700001)(6512007)(66476007)(2906002)(8676002)(83380400001)(26005)(186003)(16526019)(66556008)(9686003)(38100700001)(107886003)(6506007)(316002)(86362001)(52116002)(1076003)(6486002)(110136005)(5660300002)(956004)(66946007)(2616005)(4326008)(6666004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: YyoNS5i2XEbff3W4RO7pvqYOfnnGTTLnKy83Gg6UMpYfSKkF4VkQ5FhBCRXveJOgMOvcHGDy10XmjR+azg17eTUEfVfYZYGSETdVHPz4eD7ydjRGjDR9zrz5x5W4VPS88uojGzMjnYQ86H/3KLaeM0w2JyWRhb/23cnGJ8SzyDhFvXQDBRajIh5hjbGfjBOWrmvDeE8eiml7Qjwf3/+gH/r0Tv7qvtpPoU0HnBpKnkqklQqEUXiyjEuoZgJhJJhQUGUd+1i2+a0phNsvdZnrqlRn4kQMdKKQOD9Bni8GQnqUk13T74bRHHH6nKBz/vzu6xlQ5qu/Ch7lsdw/3TWglX/9Ryzg+0tBO9+IfYIMjlJO4uNqZIOiFKNkJ8HOlYBO2HAyF5ckF4jE56Viz9QpVPiOfHXO1HqAKoZh8ZcUl623xHpins6r8RHlsZULvd///oX6peH+AehNXXP7/3Q4PfmE1jPm2wumRXz0womIahKI0BdodKWdpG4zwJo6arLZad2lmFPQV2Bx+FQv8wrS0fiPd7h+Ur9v4dS0Va/bjySOlMK5s5RIL5zgXgq+n3q6Cy9IsLxueFf15ON5QDAhrQo00En35WChrZ/3dDx+GN2HIG/NO7fac09uetRvOYQVufd6P4kHoEaW8VPRYSr/Sl/6Xvr1szrfodlUem+M7P9iH+Enh66bwYNatSsCJtiQmCodIBoh5sPPSmAqvWQXsBjE4brw48U4vz1l9iX7G4ryL3gStzA7BI3woB0EwzGmRSNUofy+35cMJRj7g3D7rBIRTObVEZcWSkm+rSTjuBFMn0f0c2JESuFvRBAwfmwzNM6oG7TpJ1Q4rxKteNdCENeQORDclxlYPe+I6vL+H9ldMNtYSC4r1ZgcjfrowpUUkGl9A1pT1EFy2F8B8Cu3lYuLyjMxl/NUc0mEZVOlbd0ykxW54aK6X4MDfZFuCgjHLLnV3SkqOfE+QuVW1oT57Isxvv1FGdpxTwtlbECZCFXQn61ztKFqwS56kkie6RBqOn4Z6eINeH1f6Mf02ffqJq2pW+p7v+vAFFOpHIOot7W7z0XUji7Kp86EV6tm8lPyQXDlocLxLnBXi8fyZRL2Dpo/ikD7rD/5hNvjBESShwE1EyqOiHI7O1OEmwTsv5wgUCSrVTY6pDcL4PA1FQ5i3SwB6TTQm7jOuHVN3mRVB1uZEoi1oY7pddGqUO7R8k3aCRudnaE56Qg7wUiryDETlvQxI1v6QinTCvK+xePhSvqr7DPizybRmTMXYYVfJ4i1EO+wAgoqmX7KfCPUaaG88qNilKAaCCI1jaViEa4M8ReimULhazkhG8DS+v+Mxshy X-OriginatorOrg: windriver.com X-MS-Exchange-CrossTenant-Network-Message-Id: f7f289e2-8a32-4cfe-cda1-08d8fa435482 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:56.2155 (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: fCRDEvGFTZE1tGWhZDOMps462KDuqwjwNBsWJelm4Dg386rO63pYNICuOJmq/DXSy9jHLH9LLxiWaYZnSyLaggJc+qtp1BOD34BcX5xbjLU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR11MB1351 Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org From: Quanyang Wang When starting a read operation, we should call zynqmp_qspi_setuprxdma first to set xqspi->mode according to xqspi->bytes_to_receive and to calculate correct xqspi->dma_rx_bytes. Then in the function zynqmp_qspi_fillgenfifo, generate the appropriate command with operating mode and bytes to transfer, and fill the GENFIFO with the command to perform the read operation. Calling zynqmp_qspi_fillgenfifo before zynqmp_qspi_setuprxdma will result in incorrect transfer length and operating mode. So change the calling order 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 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/spi/spi-zynqmp-gqspi.c b/drivers/spi/spi-zynqmp-gqspi.c index cf73a069b759..036d8ae41c06 100644 --- a/drivers/spi/spi-zynqmp-gqspi.c +++ b/drivers/spi/spi-zynqmp-gqspi.c @@ -827,8 +827,8 @@ static void zynqmp_qspi_write_op(struct zynqmp_qspi *xqspi, u8 tx_nbits, static void zynqmp_qspi_read_op(struct zynqmp_qspi *xqspi, u8 rx_nbits, u32 genfifoentry) { - zynqmp_qspi_fillgenfifo(xqspi, rx_nbits, genfifoentry); zynqmp_qspi_setuprxdma(xqspi); + zynqmp_qspi_fillgenfifo(xqspi, rx_nbits, genfifoentry); } /**