From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751396AbdISCXz (ORCPT ); Mon, 18 Sep 2017 22:23:55 -0400 Received: from smtpproxy19.qq.com ([184.105.206.84]:59151 "EHLO smtpproxy19.qq.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750783AbdISCXy (ORCPT ); Mon, 18 Sep 2017 22:23:54 -0400 X-QQ-GoodBg: 0 X-QQ-SSF: 00100000000000F0 X-QQ-FEAT: +ELywj+bKixjmxfMnRZHA1xjd7P9q5RgH6RrNenIH2V/TsaUqug/txXTCPS1V eXThr6AVix1lLNiXMTqjkU76oG3DzetR8VFraX+FRbtegX2nEBELAqpGByB4WuevQMVepEM FTOhP+T7vQiiKNTwgUUjss7W0Gz3KlFn+A8sJzyqpo2eaps/ph0Iyu5jKZeeNsZp/9H/lpU kFZSTyEgzjEDl9gs4UJ+9LuSCXxdJk9/rf4jo9dEQyF7xl9UMzHVbIrYoIB3V1zm1ntPHTi 6Xpz7Gr7r93baNKtQjsEoECsw= X-QQ-BUSINESS-ORIGIN: 2 X-Originating-IP: 222.92.124.153 X-QQ-STYLE: X-QQ-mid: bizmailfree34t1505787825t8244 From: "=?utf-8?B?6ZmI5Y2O5omN?=" To: "=?utf-8?B?Q2hyaXN0b3BoIEhlbGx3aWc=?=" , "=?utf-8?B?Um9iaW4gTXVycGh5?=" Cc: "=?utf-8?B?QW5kcmV3IE1vcnRvbg==?=" , "=?utf-8?B?RnV4aW4gWmhhbmc=?=" , "=?utf-8?B?bGludXgtbW0=?=" , "=?utf-8?B?bGludXgta2VybmVs?=" , "=?utf-8?B?c3RhYmxl?=" Subject: Re: [V5, 2/3] mm: dmapool: Align to ARCH_DMA_MINALIGN innon-coherent DMA mode Mime-Version: 1.0 Content-Type: text/plain; charset="utf-8" Date: Tue, 19 Sep 2017 10:23:45 +0800 X-Priority: 3 Message-ID: X-QQ-MIME: TCMime 1.0 by Tencent X-Mailer: QQMail 2.x X-QQ-Mailer: QQMail 2.x References: <1505708548-4750-1-git-send-email-chenhc@lemote.com> <601437ae-2860-c48a-aa7c-4da37aeb6256@arm.com> <20170918155134.GC16672@infradead.org> In-Reply-To: <20170918155134.GC16672@infradead.org> X-QQ-ReplyHash: 2249314742 X-QQ-SENDSIZE: 520 Feedback-ID: bizmailfree:lemote.com:qybgforeign:qybgforeign4 X-QQ-Bgrelay: 1 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from base64 to 8bit by nfs id v8J2O1E1011677 Oh, I know, I've make a mistake, dmapool doesn't need to change. Huacai ------------------ Original ------------------ From: "Christoph Hellwig"; Date: Mon, Sep 18, 2017 11:51 PM To: "Robin Murphy"; Cc: "Huacai Chen"; "Andrew Morton"; "Fuxin Zhang"; "linux-mm"; "linux-kernel"; "stable"; Subject: Re: [V5, 2/3] mm: dmapool: Align to ARCH_DMA_MINALIGN innon-coherent DMA mode On Mon, Sep 18, 2017 at 10:44:54AM +0100, Robin Murphy wrote: > On 18/09/17 05:22, Huacai Chen wrote: > > In non-coherent DMA mode, kernel uses cache flushing operations to > > maintain I/O coherency, so the dmapool objects should be aligned to > > ARCH_DMA_MINALIGN. Otherwise, it will cause data corruption, at least > > on MIPS: > > > > Step 1, dma_map_single > > Step 2, cache_invalidate (no writeback) > > Step 3, dma_from_device > > Step 4, dma_unmap_single > > This is a massive red warning flag for the whole series, because DMA > pools don't work like that. At best, this will do nothing, and at worst > it is papering over egregious bugs elsewhere. Streaming mappings of > coherent allocations means completely broken code. Oh, I hadn't even seen that part. Yes, dma coherent (and pool) allocations must never be used for streaming mappings. I wish we'd have some debug infrastructure to warn on such uses.