Received: by 2002:a05:6a10:6006:0:0:0:0 with SMTP id w6csp1013425pxa; Fri, 28 Aug 2020 00:50:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxP65JyizyhuWIv00UPP8Da2ITkh5zLKpOObukrJQZ3j+CvXTyztxzLTn0JNHJF7/KuLY65 X-Received: by 2002:a17:906:178d:: with SMTP id t13mr544591eje.410.1598601021888; Fri, 28 Aug 2020 00:50:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598601021; cv=none; d=google.com; s=arc-20160816; b=rYon889Cc/shd49HK7/PkDv2wHlHIEmnAPiOg7IlLm0e/+PpLjPqkbn2XC/oVA4Y6r VAdHBHCoJWZocCMEH0jJokR3nTY8od2wuVZxRerB3VvRr3HoMAyMaq8L/N6sJ0yhviu5 KWcAcbZqSNYYnLjkk2APOW5/K4So6Z2RiNhhs9xb6TuU8KlwsP4ERWKieorn+kOn4z39 WGvkh1Ar1o/wUJqxnJXxyeAoobrMvxL+OsHEsRcXGJSJg+pwczGUyM0kf+SPaLcBp5Ks AGzDX3uv57lsLPZO072K0Tm+tvEwss/7WoESA3iUIEAP4KN9ZQJfCWI3PqBEXS/Tg8gf A/hQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=asKcJDTQmbkVWh1oo047VzwZ6hi/mmdOx2VzMsErg/c=; b=ae+mKeZ4TYRGzrW89Kr4Wk4SgrqrcaPhgAkBguib/YMJL6qOSNrFvQImgBv8czPR9X YSn7ib3qSVGo+W7LU+QTepB3LcAlSMElr+yOcE/e9T/zvB5c1M2jnG77j3/ojI+zktYY IseX+/tf6Kh71ErDd89z3Z021+etw1KErryzRNoZbmzos6yM9WGDI1ZJvhkD3i2uh0t/ YVYsLkm2UVfKIHIUsgOu67UGKekUZiDfVPAJUlWrXAWBNN6vcTEpFW/0LGG9jaQ04A5N 1H8Gqr0BIigpqhUIFTnfNadrT+B45LWV9eKiylzok0dTA6MAz39BQgUq0ZUBKT4e6w7o qBog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=t1OJeGrU; 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=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id sb27si147708ejb.24.2020.08.28.00.49.59; Fri, 28 Aug 2020 00:50:21 -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=@ti.com header.s=ti-com-17Q1 header.b=t1OJeGrU; 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=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728571AbgH1Hrt (ORCPT + 99 others); Fri, 28 Aug 2020 03:47:49 -0400 Received: from fllv0016.ext.ti.com ([198.47.19.142]:59684 "EHLO fllv0016.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726825AbgH1Hrs (ORCPT ); Fri, 28 Aug 2020 03:47:48 -0400 Received: from lelv0266.itg.ti.com ([10.180.67.225]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id 07S7ldLN055379; Fri, 28 Aug 2020 02:47:39 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1598600859; bh=asKcJDTQmbkVWh1oo047VzwZ6hi/mmdOx2VzMsErg/c=; h=From:To:CC:Subject:Date; b=t1OJeGrU7ULaU9AE5wjKvdKprxBqGE3tCrQYMGXhKGOn8D6BPD6aDil8cIFQsfkYD KLYkXLY8OwOW0yMvf8p97+jt2TfVHqzfHhobCCfGEzh9gn0kn1pRn7Fo+LoJzRqzCw b6JiQl41xQjIYiT3bVcPUdT7xPkTvwBXrOk5Atc0= Received: from DLEE106.ent.ti.com (dlee106.ent.ti.com [157.170.170.36]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 07S7ldQY024943 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 28 Aug 2020 02:47:39 -0500 Received: from DLEE107.ent.ti.com (157.170.170.37) by DLEE106.ent.ti.com (157.170.170.36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1979.3; Fri, 28 Aug 2020 02:47:38 -0500 Received: from fllv0039.itg.ti.com (10.64.41.19) by DLEE107.ent.ti.com (157.170.170.37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1979.3 via Frontend Transport; Fri, 28 Aug 2020 02:47:38 -0500 Received: from ula0132425.ent.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0039.itg.ti.com (8.15.2/8.15.2) with ESMTP id 07S7lZ8H012237; Fri, 28 Aug 2020 02:47:36 -0500 From: Vignesh Raghavendra To: Mark Brown CC: Vignesh Raghavendra , Jan Kiszka , Pratyush Yadav , , Subject: [PATCH] spi: spi-cadence-quadspi: Fix mapping of buffers for DMA reads Date: Fri, 28 Aug 2020 13:17:26 +0530 Message-ID: <20200828074726.24546-1-vigneshr@ti.com> X-Mailer: git-send-email 2.28.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Buffers need to mapped to DMA channel's device pointer instead of SPI controller's device pointer as its system DMA that actually does data transfer. Data inconsistencies have been reported when reading from flash without this fix. Fixes: 31fb632b5d43c ("spi: Move cadence-quadspi driver to drivers/spi/") Signed-off-by: Vignesh Raghavendra --- This issue was present in the original driver under SPI NOR framework as well. But only got exposed as driver started handling probe deferral for DMA channel request and thus uses DMA almost always unlike before. drivers/spi/spi-cadence-quadspi.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/spi/spi-cadence-quadspi.c b/drivers/spi/spi-cadence-quadspi.c index 508b219eabf8..c6795c684b16 100644 --- a/drivers/spi/spi-cadence-quadspi.c +++ b/drivers/spi/spi-cadence-quadspi.c @@ -907,14 +907,16 @@ static int cqspi_direct_read_execute(struct cqspi_flash_pdata *f_pdata, struct dma_async_tx_descriptor *tx; dma_cookie_t cookie; dma_addr_t dma_dst; + struct device *ddev; if (!cqspi->rx_chan || !virt_addr_valid(buf)) { memcpy_fromio(buf, cqspi->ahb_base + from, len); return 0; } - dma_dst = dma_map_single(dev, buf, len, DMA_FROM_DEVICE); - if (dma_mapping_error(dev, dma_dst)) { + ddev = cqspi->rx_chan->device->dev; + dma_dst = dma_map_single(ddev, buf, len, DMA_FROM_DEVICE); + if (dma_mapping_error(ddev, dma_dst)) { dev_err(dev, "dma mapping failed\n"); return -ENOMEM; } @@ -948,7 +950,7 @@ static int cqspi_direct_read_execute(struct cqspi_flash_pdata *f_pdata, } err_unmap: - dma_unmap_single(dev, dma_dst, len, DMA_FROM_DEVICE); + dma_unmap_single(ddev, dma_dst, len, DMA_FROM_DEVICE); return ret; } -- 2.28.0