Received: by 2002:ac0:8c9a:0:0:0:0:0 with SMTP id r26csp5255724ima; Tue, 5 Feb 2019 08:44:42 -0800 (PST) X-Google-Smtp-Source: AHgI3IbGY9pyjLXDIiSNSGniYebmONGpz4+iT9Ertdctqz8ea2YLWVR8lUWVtxRd4MnUbmuc4dhW X-Received: by 2002:a65:6094:: with SMTP id t20mr1307279pgu.285.1549385082245; Tue, 05 Feb 2019 08:44:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549385082; cv=none; d=google.com; s=arc-20160816; b=jeM/Ge6ljWPTwCx4oPtDi/f/1bIcqF2cThr8+llE/9xrk/okojECg9tbrve0uydhR5 nzqDmN8YBwT8tTffXNzmVO9/t1yG3F/Yru2kcx3zVxG8x11dL7TnWgRmMs+iAcO90UFf qD3p/N/RUMlgVzRo90Ol3pqMhrkIZwVFf7lMJA/O+a12q+RZvElx3d7/mEuVWSMToVe8 iiiWocejupa8scNbvBkBCTzMqt7gUA0n0dJb4rS9d4dNA/wGbHdjW5hJ6oN1PNr8Z0RY 7VdRjypBiR9IRb1YIqpSUy/JMxTIITbCZ4LTFYxrE0APvh718aXt4oSW49w6XS8MUrpm UKrg== 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-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=jBDIsWLTSDUHuT5J3I/Jlqrlwo1fUfewZ9KEADkIxdk=; b=0oaFCP7TKZsj9SSI1peKC2vW5AQSI6dSG5LmeXpbnYtYX7KSsucDo7c/7VxwNU8vld goRtx7u/rbw1DQvhQ/kN2c1AnmjG3cOMWswv8OdJIK0edm90T8tHJS7mAPaRNI6q9xUd u8M9j7Wcr4x/kuOFQn+Ktfuz17T0Ea589cVGZyPqyaA/YVwhH0CPteICzPKT1a0MGLBJ L1PhBY/xk7Ln5RK0X+S0CnptYeJjn+fLIpHLs9ISFTJ7PbSx7i4ZSCa8iDmkH5eyXEHR dZd2TO+q9KD26AvNFA4Sj1WYiF/2Oj7+MySGbyqRDi12IcLVc6iMQJ5E9WCRzurQAnBB YppQ== 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 204si3799133pfu.273.2019.02.05.08.44.26; Tue, 05 Feb 2019 08:44:42 -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 S1729527AbfBEQij (ORCPT + 99 others); Tue, 5 Feb 2019 11:38:39 -0500 Received: from verein.lst.de ([213.95.11.211]:55101 "EHLO newverein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726742AbfBEQij (ORCPT ); Tue, 5 Feb 2019 11:38:39 -0500 Received: by newverein.lst.de (Postfix, from userid 2407) id 6B07C68DD3; Tue, 5 Feb 2019 17:38:37 +0100 (CET) Date: Tue, 5 Feb 2019 17:38:37 +0100 From: Christoph Hellwig To: Thierry Reding Cc: Christoph Hellwig , Marek Szyprowski , Robin Murphy , iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] dma-direct: Export dma_direct_alloc() and dma_direct_free() Message-ID: <20190205163837.GA1222@lst.de> References: <20190205110602.27717-1-thierry.reding@gmail.com> <20190205161036.GA782@lst.de> <20190205162057.GA29974@ulmo> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190205162057.GA29974@ulmo> User-Agent: Mutt/1.5.17 (2007-11-01) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Feb 05, 2019 at 05:20:57PM +0100, Thierry Reding wrote: > The problem is that if I use dma_alloc_coherent(), then the memory will > already be mapped via the SMMU at that point and then the driver, not > knowing that memory has already been mapped, will attempt to map an IOVA > which will cause an SMMU fault when the host1x tries to access the > memory. > > I didn't find an equivalent to arm_iommu_detach_device() for non-ARM, > but then stumbled across this and thought it was rather convenient for > these cases. If there's a better way to deal with this situation, I'd be > happy to do so. So you basically do a dma_direct_alloc + iommu_map? Can you send me a pointer to your code? Maybe we need to add a proper IOMMU-layer API for that.