Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp3773645ybg; Mon, 28 Oct 2019 19:14:19 -0700 (PDT) X-Google-Smtp-Source: APXvYqzIszXzlgtC8lr1R/nqgHKkM3n5qSgAs5ZspHFp8fFfluvOs9ViYBLD+Uko5W6N0W7QGSH1 X-Received: by 2002:a05:6402:1107:: with SMTP id u7mr22842942edv.163.1572315259139; Mon, 28 Oct 2019 19:14:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572315259; cv=none; d=google.com; s=arc-20160816; b=q0OQEYqcL9EVSzS9C9yN5VNTFRxO1wn5D79ZHTxCikTX8wK1NBae2tEG9bogOkdH2q wbUESCjHd84LHmE/8vboGPohLL8WHBhAoGiv4UYGuhi17+pBwyKWZsJlydlSZ6ikMBxT eQwOD3BEfMKnpRTVNOvcfW5JzbMAxj3Oqh7w3yMyA1BnRFgPfRUAARuWECYjJOQFptpG JRWyuNDFjajRZw/vEX27kdA31FesqUOhWeJaxemIr921pZ4mk08Wa+2le1DBx1mKib5p EZXjAfveE4+C6r6Ap496fxB676gmn8o+ro5+cmmL6jMl8eVp5D36R4D27vNhoXHT8RQY YyRg== 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=WfW+eJSH+xBKijrh2ayOUtYnMqpPE7s5kcZl2F4eyJs=; b=D1sVu4uOaHOogYMLgDioa4SY0S+h7sAJZ15h+aUs2qgIAjj367H8nBtV2jXIaBak1X irWiZUZmZ/nVuR/RTyKGOtoCKnvhob9osL9Mfp0RTOrB7OXX9/G1yFS2Da3Jd6VgAs6M vU08qxXEd/aTwp4dJvPtIpRzH7j/HHoS49gr+xJm9hKneuLRqF69Fn6lqt7Hy1Gt/tnC i1FyBYuSGexF2g0PO1xKQ/KcHeS5vf6aVybDbDFIXU0Cex1vXmA32/zK1Fp9GvGPUXqq wqBO3No/JcIh+wDmKh4nI+hdkUETrmRlT5MGuf9iWXswQ0VjpfrJqsvkMmtPcJKf/5Hh EuAQ== 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 4si7872076ejc.382.2019.10.28.19.13.55; Mon, 28 Oct 2019 19:14:19 -0700 (PDT) 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 S2389572AbfJ1Nwx (ORCPT + 99 others); Mon, 28 Oct 2019 09:52:53 -0400 Received: from foss.arm.com ([217.140.110.172]:40098 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725774AbfJ1Nww (ORCPT ); Mon, 28 Oct 2019 09:52:52 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 253DA1F1; Mon, 28 Oct 2019 06:52:52 -0700 (PDT) Received: from [10.1.197.57] (e110467-lin.cambridge.arm.com [10.1.197.57]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id A51443F6C4; Mon, 28 Oct 2019 06:52:50 -0700 (PDT) Subject: Re: [PATCH v2 2/3] iommu/dma: wire-up new dma map op .get_virt_addr To: Laurentiu Tudor , "hch@lst.de" , "joro@8bytes.org" , Ioana Ciocoi Radulescu , "linux-kernel@vger.kernel.org" , "iommu@lists.linux-foundation.org" , "netdev@vger.kernel.org" , Ioana Ciornei Cc: Leo Li , Diana Madalina Craciun , "davem@davemloft.net" , Madalin Bucur References: <20191024124130.16871-1-laurentiu.tudor@nxp.com> <20191024124130.16871-3-laurentiu.tudor@nxp.com> From: Robin Murphy Message-ID: <8c472ff4-1de4-42c7-f4f1-7b26043d81af@arm.com> Date: Mon, 28 Oct 2019 13:52:49 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: <20191024124130.16871-3-laurentiu.tudor@nxp.com> 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 On 24/10/2019 13:41, Laurentiu Tudor wrote: > From: Laurentiu Tudor > > Add an implementation of the newly introduced dma map op in the > generic DMA IOMMU generic glue layer and wire it up. > > Signed-off-by: Laurentiu Tudor > --- > drivers/iommu/dma-iommu.c | 16 ++++++++++++++++ > 1 file changed, 16 insertions(+) > > diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c > index f321279baf9e..15e76232d697 100644 > --- a/drivers/iommu/dma-iommu.c > +++ b/drivers/iommu/dma-iommu.c > @@ -1091,6 +1091,21 @@ static unsigned long iommu_dma_get_merge_boundary(struct device *dev) > return (1UL << __ffs(domain->pgsize_bitmap)) - 1; > } > > +static void *iommu_dma_get_virt_addr(struct device *dev, dma_addr_t dma_handle) > +{ > + struct iommu_domain *domain = iommu_get_domain_for_dev(dev); Note that we'd generally use the iommu_get_dma_domain() fastpath... > + > + if (domain) { ...wherein we can also assume that the device having iommu_dma_ops assigned at all implies that a DMA ops domain is in place. Robin. > + phys_addr_t phys; > + > + phys = iommu_iova_to_phys(domain, dma_handle); > + if (phys) > + return phys_to_virt(phys); > + } > + > + return NULL; > +} > + > static const struct dma_map_ops iommu_dma_ops = { > .alloc = iommu_dma_alloc, > .free = iommu_dma_free, > @@ -1107,6 +1122,7 @@ static const struct dma_map_ops iommu_dma_ops = { > .map_resource = iommu_dma_map_resource, > .unmap_resource = iommu_dma_unmap_resource, > .get_merge_boundary = iommu_dma_get_merge_boundary, > + .get_virt_addr = iommu_dma_get_virt_addr, > }; > > /* >