Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4600743pxj; Wed, 12 May 2021 09:01:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzgHYdP/84WfoFa1ir0j8+3+Ukcf8+AsjyQcKwYsCl3bBljIm3gajwzHdRGPNg9MQmTPjQu X-Received: by 2002:a2e:8799:: with SMTP id n25mr30681065lji.139.1620835298917; Wed, 12 May 2021 09:01:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620835298; cv=none; d=google.com; s=arc-20160816; b=RkeuKxyTg9jchxPAXQEhCd27y1TC6CFhofIhWhNaNzBhMRR9yq2+GCJOQ9uRGG3KfI +MDUX8n5AMZ/J2mgsZod1LnMzjT9pV15Om/OGNsOIuyAuQkpWuMlfTR4/n8gb3xHi38E HTPUoK/q3JeWJxZBx4WINTmqc/Iw2kFw9dbh1J44SJMg2SxzM5Q234pw5kO/sI976Fhq Ic/EjPU8krmvYtjJOtObn7uHt0w0g78GnsYIdDNPXTICZo/TG6yeAk9g/F9pM+e+4jHP pzGwP/RgI4fO9GfgsZhaWkF6DX++FJAKoYAoGT6NblnL5f7IPNB9MeEOK+PDPRjMwoD5 I2gA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=ic7bvfGIldOPMo4dusdO9ArZftOFpl9pR6KjcKuAwXA=; b=Nra7HNykG8/xqFDOkZ44OBenAspgk9Aqf6LfchsDgt9qU1p/tHWk21BpGlUaZOh1se hcBRZwgidp7J6XPy//umVJXaFpPd3y4BIl8P2GNuLWo4tMsPdkuJUFnwgjuC1yT60+5N 9Qvm0Tl8V698eSCB9OWPrrSzGu4U1reg2qwPx/Rhxp6VopLEerY/fMGRM1VwCrtBu8Bq GregJlsZOlmiMGGgw6xI+HvyWTegaUZTCcBvIMT2DMMP4axOefUpcWd5b77bL+Esz5yM IyV/cMzI7eAFsei+ZnNRLA4ThYxOnfaE/vMSMS88EbJckoNQkDQLQZvxNIBCRY56cpN3 4Tfg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=gsDxg2mC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ga17si244607ejb.144.2021.05.12.09.01.13; Wed, 12 May 2021 09:01:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=gsDxg2mC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237860AbhELP43 (ORCPT + 99 others); Wed, 12 May 2021 11:56:29 -0400 Received: from mail.kernel.org ([198.145.29.99]:40742 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235280AbhELP1Z (ORCPT ); Wed, 12 May 2021 11:27:25 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 6716161A13; Wed, 12 May 2021 15:12:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620832334; bh=3ko12gNx5sd+b+RuP/0bkyRe5JZE8HzT8Tp0etjgp3Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gsDxg2mCFtBABGvKuq2pZqEoM3D/zmFuhlQTT9gfYibMrY42kK9+XrH93q9E18pGk RWJ/nLSDvLZ5Vj4ga4EtuLuhgRbP/9h9lvTNfh1h3xX/wQNZFq4B2TlU/UW82IU3m9 KwkSKTu4cFeDlgJHRWeE6m2/4mGRNuV3BX8oecSU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Quanyang Wang , Amit Kumar Mahapatra , Mark Brown , Sasha Levin Subject: [PATCH 5.10 237/530] spi: spi-zynqmp-gqspi: use wait_for_completion_timeout to make zynqmp_qspi_exec_op not interruptible Date: Wed, 12 May 2021 16:45:47 +0200 Message-Id: <20210512144827.633317381@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210512144819.664462530@linuxfoundation.org> References: <20210512144819.664462530@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Quanyang Wang [ Upstream commit a16bff68b75fd082d36aa0b14b540bd7a3ebebbd ] 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 Link: https://lore.kernel.org/r/20210408040223.23134-2-quanyang.wang@windriver.com Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- 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; } -- 2.30.2