Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3232270imu; Sat, 24 Nov 2018 00:40:47 -0800 (PST) X-Google-Smtp-Source: AFSGD/UvdpX6MOGkEEVgMPYTp95zaMbNJIx0GHlUpkUozne7aLIG5YWY6ev6kxWVrSn+PistJ2SO X-Received: by 2002:a65:5c04:: with SMTP id u4mr16644982pgr.229.1543048847064; Sat, 24 Nov 2018 00:40:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543048847; cv=none; d=google.com; s=arc-20160816; b=GcmMXox+cXD/DOmMksORJxsZcQy6NoKNk/4bEictJk3XjgYWBS4nXgj+Equj6axvab KvUPQzJGShnSPtjQvSw+QGODzI3az7KZMOWeY23gX86ojxq6YjMFSWwwjYdKf5AYNKZY BI8XSFAxAg+x//DKEQvl6yYLKX2Bzu9ABgrA7BJmcrKyEdRy+Da/nP0CGt5oFlTCYIoO 7tAQT6aYt2PMBaHVaQDEym4FLCbxafJNP5lMhYZzunsmItNmJSz2GuMy5TVaZnLCElIK M+v3cj1IgW/QmSaPEBZQ3kxEWpwvENUPXyhD+PX9xzunbtbbgYt2DxlF6Y8quCYTG9Hc edzg== 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=UeNTWCdeiv724wMlauQRE4OMTFPhR8PEaJP4VfCNfxc=; b=eUCAn45FcbAajlZzXXaoYvF9xBg0fev+WDsovAXYeV7LewuNPqCYjSxMnbjv51AbIU eEsogbZ0Fpr/l3SL1ZnSWeMJ+qdhiCmfCRtmxL7lAPLqKXQO/RBIo11l4xFS3u/YnA0e RwjrYKbyzDSv0Jcot/9zCIes5j9FAxWgiFz51ghgj1wXZIg1lziZis3+KtdctiXGyiai xgmcal3XKe0G+g6vto9VNSvnq8SBedhN0AdWYMh1Bmq6vmEtzr3G6PSVrR+IJFgOJX+l NE0Gs/20WPxT7QxEB8egRbThYODBwxFSDiRMiB4oarF4qWFxTKc0DeAYMWI3YZp4RixX g5JA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 23si42585056pfk.287.2018.11.24.00.40.32; Sat, 24 Nov 2018 00:40:47 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2440255AbeKXCOJ (ORCPT + 99 others); Fri, 23 Nov 2018 21:14:09 -0500 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:47566 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2436632AbeKXCOJ (ORCPT ); Fri, 23 Nov 2018 21:14:09 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id B411C35CD; Fri, 23 Nov 2018 07:29:31 -0800 (PST) Received: from [10.1.196.75] (e110467-lin.cambridge.arm.com [10.1.196.75]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id A3C3A3F5AF; Fri, 23 Nov 2018 07:29:30 -0800 (PST) Subject: Re: dw_mmc: IDMAC Invalidate cache after read To: JABLONSKY Jan , Jaehoon Chung , Shawn Lin Cc: Ulf Hansson , "linux-mmc@vger.kernel.org" , "linux-kernel@vger.kernel.org" References: <1542786115.18775.83.camel@atviedlbe741.rss.d3s.at.thales> From: Robin Murphy Message-ID: Date: Fri, 23 Nov 2018 15:29:25 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: <1542786115.18775.83.camel@atviedlbe741.rss.d3s.at.thales> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Jan, [repeating some of the discussion from your other thread for the benefit of the MMC audience] On 21/11/2018 07:42, JABLONSKY Jan wrote: > CPU may not see most up-to-date and correct copy of DMA buffer, when > internal DMA controller is in use. > Problem appears on The Altera SoC FPGA (uses integrated DMA controller), > during higher CPU and system memory load > > Signed-off-by: Jan Jablonsky > --- > drivers/mmc/host/dw_mmc.c | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) > > diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c > index 80dc2fd..63873d9 100644 > --- a/drivers/mmc/host/dw_mmc.c > +++ b/drivers/mmc/host/dw_mmc.c > @@ -499,8 +499,7 @@ static void dw_mci_dmac_complete_dma(void *arg) > > dev_vdbg(host->dev, "DMA complete\n"); > > - if ((host->use_dma == TRANS_MODE_EDMAC) && > - data && (data->flags & MMC_DATA_READ)) > + if (data && (data->flags & MMC_DATA_READ)) > /* Invalidate cache after read */ > dma_sync_sg_for_cpu(mmc_dev(host->slot->mmc), > data->sg, It looks very dubious whether this is actually the right thing to do. Just considering this driver, edma has an complementary sync_sg call in its .start method, so if idma needed this one, logically shouldn't it also need the other one as well? However, from a DMA API point of view, these syncs make no sense either way - the very next thing we do here is call host->dma_ops->cleanup(), which calls dma_unmap_sg(), which will perform the appropriate cache maintenance anyway. Thus I can't see why this code is even here to begin with. Similarly on the request path - the sg list really shouldn't have been touched since being mapped in dw_mci_pre_dma_transfer(), so that sync should also be an effective no-op unless it's papering over some race condition elsewhere. Shawn - do you remember why these syncs were added in 3fc7eaef44dbc? Were you seeing actual coherency issues on RK31xx SoCs, or was it perhaps just some leftover or misunderstanding which missed getting cleaned up? Robin.