Received: by 2002:a05:6a10:6006:0:0:0:0 with SMTP id w6csp1030991pxa; Fri, 28 Aug 2020 01:28:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJycvs3KaE1XVrAeX0+/HL3WlKyPop9wLxKkMP42sARRLNiY5p6zHwbzY33SWkReH4K4LtcC X-Received: by 2002:a17:906:1c4f:: with SMTP id l15mr608828ejg.419.1598603294965; Fri, 28 Aug 2020 01:28:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598603294; cv=none; d=google.com; s=arc-20160816; b=UJs0wNdsXgI9m9e/jAIepkHtzkXMYVy3Zkj/hY4HOcLJl0VCXjVBSSrNqUbpZSCyME qRhWrnTd0IBhRg1tNyjTngJvw6d0TIC4XQI/hkUAvrLfPCljSk3HDazS/553W5Y39XHn EBoX0f3BgDd9BaS8t+7ohBoQttIKi/y+0blJZx/Wj3yooVudPsBAgu3XGdMraUii0VIH z36eJs6G1Wfs5BVuJdaFqC0lc4MC7zj78mXTBPtrjLMSmO3gGhagQjCHi87FYVCijre+ ebZjSumkL8rp+YcR5tScc9iRdsDOnZ5xcBHFuVNXXiMPasI7oumgBUAzyynHxA6BWsXL wzoA== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=D2cXuVsX4rJOJV1TkuTSqr0sl5ylzWeoLFs7g4saSkg=; b=H3qcUeUqUFs8sKNLlLrjFlOKAMfUpjTrwlilfQcIAOWLDMccdfuS5jv6kHhgJNzD10 QX2PE7waVvzYpDFQKg5diBo9BSr08XtAhQ/w5hMsmo2Lkrz49DEWhE4bu1p/jvzemZrm WNAAIIgVPgw/LBm5xeZpAJyvSR3zT/9pPnXkob7rseTwOqjChSZA9Au7hVBHLPWbDfue MDJhDm+WR5LjUdlO/wlTO+ERP3hMXAJAG+OTwgAfNjmXEiFU6gNLpZg14h3CvH7FmQ5H CnBT8HbHxS+nCONGvDdoDDM+AktA59v1ysdNZKFe+vfsDVUoRo1J+NQ7fP/qtJ0Fe6Cx w+3g== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=siemens.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d11si133442edu.494.2020.08.28.01.27.51; Fri, 28 Aug 2020 01:28:14 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=siemens.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728697AbgH1I0z (ORCPT + 99 others); Fri, 28 Aug 2020 04:26:55 -0400 Received: from lizzard.sbs.de ([194.138.37.39]:37934 "EHLO lizzard.sbs.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728218AbgH1I0u (ORCPT ); Fri, 28 Aug 2020 04:26:50 -0400 Received: from mail2.sbs.de (mail2.sbs.de [192.129.41.66]) by lizzard.sbs.de (8.15.2/8.15.2) with ESMTPS id 07S8QeQP016300 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 28 Aug 2020 10:26:40 +0200 Received: from [167.87.19.148] ([167.87.19.148]) by mail2.sbs.de (8.15.2/8.15.2) with ESMTP id 07S8Qd9Q013834; Fri, 28 Aug 2020 10:26:40 +0200 Subject: Re: [PATCH] spi: spi-cadence-quadspi: Fix mapping of buffers for DMA reads To: Vignesh Raghavendra , Mark Brown Cc: Pratyush Yadav , linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org References: <20200828074726.24546-1-vigneshr@ti.com> From: Jan Kiszka Message-ID: <8828e301-a7b7-d837-dc60-6c5101cdac90@siemens.com> Date: Fri, 28 Aug 2020 10:26:39 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.11.0 MIME-Version: 1.0 In-Reply-To: <20200828074726.24546-1-vigneshr@ti.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 28.08.20 09:47, Vignesh Raghavendra wrote: > 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/") This looks wrong, ... > 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. ...you rather want 935da5e5100f57d843cac4781b21f1c235059aa0 then. Other than that: Tested-by: Jan Kiszka Thanks! Jan > > 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; > } > -- Siemens AG, Corporate Technology, CT RDA IOT SES-DE Corporate Competence Center Embedded Linux