From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.3 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_PASS,USER_AGENT_MUTT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F1298C10F0E for ; Mon, 15 Apr 2019 06:33:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BE78820825 for ; Mon, 15 Apr 2019 06:33:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="LYAEYuMh" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726302AbfDOGdV (ORCPT ); Mon, 15 Apr 2019 02:33:21 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:39244 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725796AbfDOGdV (ORCPT ); Mon, 15 Apr 2019 02:33:21 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding: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=fTpJKUXbuUL7KBfPF6XhuEv9pXvxMlQmz20aOroByok=; b=LYAEYuMhBvvLtAlfrkcl2v1Hv J/diuhxsyq4qMmmKNKu4xKSxq5I3IO5ZDmyYJTP3+mWn0X/NJlnxpPV9iIcPt/jxaiuU6sRlC5AOc AKjUHt6v2z2n+4VpqTNOYY8c9vuCqcVPoeEOla5pCEJliS1j99N3glVSRx+R593PXpCgxi651UYZE F8UQBLASAE4bXbt4+VWHcjatc7WGerYL3LRZgIFsBRtNVesV5OABDs+Fbq52qUzC+9Zu82HzHN+/r vI8fPO5j8s1ydWtxojfIB6+dyJi2Pj27AfZ2UnVZu1/9tRJP82e1ynIdIjewgJnR5SYSrv6/hIrio Iy7KtgJ1A==; Received: from hch by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1hFvB8-0002dH-0g; Mon, 15 Apr 2019 06:33:18 +0000 Date: Sun, 14 Apr 2019 23:33:17 -0700 From: Christoph Hellwig To: Tom Murphy Cc: iommu@lists.linux-foundation.org, Heiko Stuebner , Will Deacon , David Brown , linux-samsung-soc@vger.kernel.org, dima@arista.com, Krzysztof Kozlowski , linux-rockchip@lists.infradead.org, Kukjin Kim , Andy Gross , Marc Zyngier , linux-arm-msm@vger.kernel.org, linux-mediatek@lists.infradead.org, Matthias Brugger , Thomas Gleixner , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, murphyt7@tcd.ie, Robin Murphy Subject: Re: [PATCH 4/9] iommu/dma-iommu: Add iommu_dma_map_page_coherent Message-ID: <20190415063317.GC1377@infradead.org> References: <20190411184741.27540-1-tmurphy@arista.com> <20190411184741.27540-5-tmurphy@arista.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190411184741.27540-5-tmurphy@arista.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 > @@ -693,7 +694,19 @@ dma_addr_t iommu_dma_map_page(struct device *dev, struct page *page, > unsigned long offset, size_t size, int prot) > { > return __iommu_dma_map(dev, page_to_phys(page) + offset, size, prot, > - iommu_get_dma_domain(dev)); > + iommu_get_dma_domain(dev), dma_get_mask(dev)); > +} > + > +dma_addr_t iommu_dma_map_page_coherent(struct device *dev, struct page *page, > + unsigned long offset, size_t size, int prot) > +{ Note that my tree pointed to above removes the iommu_dma_map_page wrapper. I think for the coherent mappign we should also just call __iommu_dma_map directly and not introduce another wrapper. > + dma_addr_t dma_mask = dev->coherent_dma_mask; > + > + if (!dma_mask) > + dma_mask = dma_get_mask(dev); > + > + return __iommu_dma_map(dev, page_to_phys(page) + offset, size, prot, > + iommu_get_dma_domain(dev), dma_mask); > } In the DMA API there is no fallback when the coherent_dma_mask is not set. While various bits of legacy code do that we should not copy it to new code.