Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4597772pxj; Wed, 12 May 2021 08:58:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwlmZCPPzVYXSEsvYaAGgAqKHgYXNayXyLuvxgLIHs0cDbIgk5RnxBT/6zO9CGSi6p/2siC X-Received: by 2002:aa7:da03:: with SMTP id r3mr12215564eds.121.1620835098378; Wed, 12 May 2021 08:58:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620835098; cv=none; d=google.com; s=arc-20160816; b=h2Pm/pxrrqZ52gCV02L3VL3O7og3fVWuf4nDp+qibJf5A4crVf5vrrNLR7uJg9u39l aMMHLvvdlYbGHxxi8V9+0AAbjIhl4e9F+Wu08mB8FrrQYorykMTnCYj4mpJJ0ChoH7Js cNYwluf2yyt1QQZy3wlqkk10Xfv5z+MTlNj2Ooe2UBi+7nzT1N9U8wf3GRrRzM08mqi2 Hxx49JL/poenURiz1IPZb0aVTZ8ws6wyIfewyDyWr642OjWLSH4RicV0tjfI8r1eTwZ8 whr2FJVmzh6J9rqSrXJwZpYgVY9A3N5Bo//Grg3t9UHekfYzaLerBAePkZDg58r2lnKl OCMQ== 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=ggTW0rsZoLPeAnCDBFCQyFS79BFF2Mt33dnL/Aqw+oU=; b=SNKV4e6IrKzxTn+d2GCOXC+/fhBZZLhIgGX/KMgM9ik8YxLM7LANJPjA6gZ1Qr+VBS WHXFLRnL3IylhwSEO5iEAXlk7OmiinvcO+yXAZM9rEivQJt9aiidLLcg5j6gs9/KCt0e /E0BYEpKfeNnWPgeimCDGTpflnRuYuOX3cpP4wufeKmWKHdI1blLFyaOxtb4h3xtKLLt TkbPZuV6IXZ7sW2JxFcTIB1HpuRevEpI/hAOnUePxnqX71t4XWRBCTZDktLf675rTa+1 +7RDJyehpKPJ2wSJKLstO1yxo+bvngD2sU9VKVMY0J+S9DevVlTFaRt/3AfehrZgmkTE tHSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=1UGRZRpr; 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 o6si20783edi.480.2021.05.12.08.57.52; Wed, 12 May 2021 08:58:18 -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=1UGRZRpr; 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 S237881AbhELP4n (ORCPT + 99 others); Wed, 12 May 2021 11:56:43 -0400 Received: from mail.kernel.org ([198.145.29.99]:40754 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235285AbhELP11 (ORCPT ); Wed, 12 May 2021 11:27:27 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id D1EB761A36; Wed, 12 May 2021 15:12:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620832337; bh=vNw7hPyriTF8vD1Ecj2og92mIOBMCxSbrMbzY/QIXHg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1UGRZRprm/3Yd4gW0Dy6BifIu4CFwTC85ib5KvHCcFsyQwtIg56OdvqbUla9nMWlW ZNbXvxjEUcrjj2vmxuFMqA8+XWU9Q+YSrhL5zU3lx8iRsIhtn565C9lXI+sOeE9ck+ EauQAjgMA+idfVMYUweWlPyX3eEOWujHCHFzg93w= 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 238/530] spi: spi-zynqmp-gqspi: add mutex locking for exec_op Date: Wed, 12 May 2021 16:45:48 +0200 Message-Id: <20210512144827.663414154@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 a0f65be6e880a14d3445b75e7dc03d7d015fc922 ] 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 Link: https://lore.kernel.org/r/20210408040223.23134-3-quanyang.wang@windriver.com Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- 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); -- 2.30.2