Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp33874imj; Wed, 6 Feb 2019 23:32:04 -0800 (PST) X-Google-Smtp-Source: AHgI3IbwefIVHm5lmxvhVZ0SOhFi8z/49qPIkF977oLR2//9onhBDA5DYbHrvjg336VjSBgUwbNZ X-Received: by 2002:a63:7402:: with SMTP id p2mr8938108pgc.360.1549524724051; Wed, 06 Feb 2019 23:32:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549524724; cv=none; d=google.com; s=arc-20160816; b=YDtC0qprPkMqRqPMVVUlZiFy68ph8hvZTMoRcp7qsCIL3AAjz/REE10bOugYSx0K0i 9JBYNmNSm43/fZTRIJ1NDRiwu6AuY5rN+hVEj3+hK0brYMofjYuhNazDRg4T9eMQ9WwD p56aMxMtkEnInYt5qNHwOZD0i3JqO85KntBDIOFkXoITI1x2uhDtD8EisTUElMY4aDOm tQUap75BzGeMYyQciywEQpkdmJnLwlh8M/VSHWmTuK6jgqTSLFJDn+yUc3qUW3UbBk/G iz63H76+deMSQldZhGIiu9QZJMzDQ69fF/TB2pa0jAOfRPBSOC9JwR+JFGoOT9+kRYCn sOiA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=lOFIUwWTQbE48b7kY5flfLTWU784I61npq4jivcJyEc=; b=MraCnBhAjGHrNA6DT0KFafKH5Jwm9zaQIHWjL2cnMLXB6KnCKfUt3+89cmH9z17fO5 miO+OQpRhcKD/k6tGLinX+ece3lupe9KOGCYaeepgwEEfMFm2WIyj7+c3tub9e8eG+12 GPkqLCK5sLIEKFchkG43BOMpuDriNVcBw5bTqCHSHsue/kIZbDZz1C7rgoblUFohEmwL jJNmAP9Bbt5yup3kvNmQwaH8eEuH4jMH4aqSnJVZxqFWZSkb2FOx1V1jnysV+bwRX5VF n9wyj39fDstSawt4PqFVdbqqhSvzA8bdHhZ0NQMvocaaZi+cHz76oG6JtXC1rVmppRsK 1/Mg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=Qb0vlRiW; 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 cs11si3942852plb.181.2019.02.06.23.31.48; Wed, 06 Feb 2019 23:32:04 -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; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=Qb0vlRiW; 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 S1726715AbfBGHbI (ORCPT + 99 others); Thu, 7 Feb 2019 02:31:08 -0500 Received: from bombadil.infradead.org ([198.137.202.133]:39822 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725923AbfBGHbI (ORCPT ); Thu, 7 Feb 2019 02:31:08 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Transfer-Encoding :Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date: Sender:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=lOFIUwWTQbE48b7kY5flfLTWU784I61npq4jivcJyEc=; b=Qb0vlRiWFDdy2qFAOeEbMA3zHI 62z7gpBD+PqKc1KYGiDzKSfC86esxIS8q3wSS5AeI34LuZfWASFZNVdeFz+jhTHw+8CO5rhHZF8C/ wvNniT3fsFQoJzc22ld+4dIuSZY1OT6HoNhhXJVNI/4huPD29HlxTYp8i55REh5bMDroJLkBYLHNd pexLwd6TEJudFs03tQj80PHCXrk6mYk6KpdItBjG1f82rXD87cR2j3dH92dofmccqTctGhqZwmWpE W6B8VlmWXe8ecNPf1OzuLabTkuO0S2QEneLcB5foaYtdERVY23Ooj/zgtPlRysGppqXnDhexN4QM7 UjTReNMQ==; Received: from hch by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1gre9I-0005mt-VU; Thu, 07 Feb 2019 07:31:04 +0000 Date: Wed, 6 Feb 2019 23:31:04 -0800 From: Christoph Hellwig To: =?iso-8859-1?Q?=D8rjan?= Eide Cc: Brian Starkey , Liam Mark , "devel@driverdev.osuosl.org" , "tkjos@android.com" , "linux-kernel@vger.kernel.org" , "dri-devel@lists.freedesktop.org" , "linaro-mm-sig@lists.linaro.org" , "arve@android.com" , "joel@joelfernandes.org" , nd , "maco@android.com" , "christian@brauner.io" Subject: Re: [Linaro-mm-sig] [PATCH 2/4] staging: android: ion: Restrict cache maintenance to dma mapped memory Message-ID: <20190207073104.GA16222@infradead.org> References: <1547836667-13695-1-git-send-email-lmark@codeaurora.org> <1547836667-13695-3-git-send-email-lmark@codeaurora.org> <69b18f39-8ce0-3c4d-3528-dfab8399f24f@ti.com> <20190130113122.fipxgcmgrqggozcm@DESKTOP-E1NTVVP.localdomain> <20190206154021.GC3768@e106893-lin.trondheim.arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20190206154021.GC3768@e106893-lin.trondheim.arm.com> User-Agent: Mutt/1.9.2 (2017-12-15) X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The CPU may only access DMA mapped memory if ownership has been transferred back to the CPU using dma_sync_{single,sg}_to_cpu, and then before the device can access it again ownership needs to be transferred back to the device using dma_sync_{single,sg}_to_device. > I've run some testing, and this patch does indeed fix the crash in > dma_sync_sg_for_cpu when it tried to use the 0 dma_address from the sg > list. > > Tested-by: ?rjan Eide > > I tested this on an older kernel, v4.14, since the dma-mapping code > moved, in v4.19, to ignore the dma_address and instead use sg_phys() to > get a valid address from the page, which is always valid in the ion sg > lists. While this wouldn't crash on newer kernels, it's still good to > avoid the unnecessary work when no CMO is needed. Can you also test is with CONFIG_DMA_API_DEBUG enabled, as that should catch all the usual mistakes in DMA API usage, including the one found?