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=-8.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_1 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 94699C3A5A2 for ; Mon, 19 Aug 2019 12:55:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7295B2086C for ; Mon, 19 Aug 2019 12:55:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727412AbfHSMzD (ORCPT ); Mon, 19 Aug 2019 08:55:03 -0400 Received: from foss.arm.com ([217.140.110.172]:53772 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726987AbfHSMzD (ORCPT ); Mon, 19 Aug 2019 08:55:03 -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 B9C3D28; Mon, 19 Aug 2019 05:55:02 -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 6507D3F246; Mon, 19 Aug 2019 05:55:01 -0700 (PDT) Subject: Re: [PATCH v9 2/5] iommu/dma: Add a new dma_map_ops of get_merge_boundary() To: Yoshihiro Shimoda , ulf.hansson@linaro.org, hch@lst.de, m.szyprowski@samsung.com, joro@8bytes.org, axboe@kernel.dk Cc: wsa+renesas@sang-engineering.com, linux-mmc@vger.kernel.org, iommu@lists.linux-foundation.org, linux-block@vger.kernel.org, linux-renesas-soc@vger.kernel.org References: <1564129876-28261-1-git-send-email-yoshihiro.shimoda.uh@renesas.com> <1564129876-28261-3-git-send-email-yoshihiro.shimoda.uh@renesas.com> From: Robin Murphy Message-ID: <312d6e38-5143-fb07-1efb-01e60cafa2c9@arm.com> Date: Mon, 19 Aug 2019 13:54:58 +0100 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: <1564129876-28261-3-git-send-email-yoshihiro.shimoda.uh@renesas.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 7bit Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org On 26/07/2019 09:31, Yoshihiro Shimoda wrote: > This patch adds a new dma_map_ops of get_merge_boundary() to > expose the DMA merge boundary if the domain type is IOMMU_DOMAIN_DMA. > > Signed-off-by: Yoshihiro Shimoda > Reviewed-by: Simon Horman > --- > drivers/iommu/dma-iommu.c | 11 +++++++++++ > 1 file changed, 11 insertions(+) > > diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c > index a7f9c3e..2992ce4 100644 > --- a/drivers/iommu/dma-iommu.c > +++ b/drivers/iommu/dma-iommu.c > @@ -1085,6 +1085,16 @@ static int iommu_dma_get_sgtable(struct device *dev, struct sg_table *sgt, > return ret; > } > > +static unsigned long iommu_dma_get_merge_boundary(struct device *dev) > +{ > + struct iommu_domain *domain = iommu_get_dma_domain(dev); > + > + if (domain->type != IOMMU_DOMAIN_DMA) Did you actually need this check? In principle, if the default domain is not of type IOMMU_DOMAIN_DMA then the device should be assigned dma_direct_ops rather than iommu_dma_ops, thus it shouldn't be possible to get here. If you did manage to hit a case where the domain type didn't match the ops it would be interesting to figure out how. Robin. > + return 0; /* can't merge */ > + > + return (1UL << __ffs(domain->pgsize_bitmap)) - 1; > +} > + > static const struct dma_map_ops iommu_dma_ops = { > .alloc = iommu_dma_alloc, > .free = iommu_dma_free, > @@ -1100,6 +1110,7 @@ static const struct dma_map_ops iommu_dma_ops = { > .sync_sg_for_device = iommu_dma_sync_sg_for_device, > .map_resource = iommu_dma_map_resource, > .unmap_resource = iommu_dma_unmap_resource, > + .get_merge_boundary = iommu_dma_get_merge_boundary, > }; > > /* >