From patchwork Thu Jun 13 10:20:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yoshihiro Shimoda X-Patchwork-Id: 10992411 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7A10113AD for ; Thu, 13 Jun 2019 15:36:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6A7471FE8E for ; Thu, 13 Jun 2019 15:36:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5EC09201A4; Thu, 13 Jun 2019 15:36:17 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 102B71FE8E for ; Thu, 13 Jun 2019 15:36:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731971AbfFMPgQ (ORCPT ); Thu, 13 Jun 2019 11:36:16 -0400 Received: from relmlor1.renesas.com ([210.160.252.171]:38042 "EHLO relmlie6.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727380AbfFMKUk (ORCPT ); Thu, 13 Jun 2019 06:20:40 -0400 X-IronPort-AV: E=Sophos;i="5.62,369,1554735600"; d="scan'208";a="18380805" Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie6.idc.renesas.com with ESMTP; 13 Jun 2019 19:20:37 +0900 Received: from localhost.localdomain (unknown [10.166.17.210]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id 8D6284274BC4; Thu, 13 Jun 2019 19:20:37 +0900 (JST) From: Yoshihiro Shimoda To: joro@8bytes.org, axboe@kernel.dk, ulf.hansson@linaro.org, wsa+renesas@sang-engineering.com Cc: hch@lst.de, iommu@lists.linux-foundation.org, linux-block@vger.kernel.org, linux-mmc@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Yoshihiro Shimoda Subject: [RFC PATCH v6 1/5] iommu: add an exported function to get minimum page size for a domain Date: Thu, 13 Jun 2019 19:20:11 +0900 Message-Id: <1560421215-10750-2-git-send-email-yoshihiro.shimoda.uh@renesas.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1560421215-10750-1-git-send-email-yoshihiro.shimoda.uh@renesas.com> References: <1560421215-10750-1-git-send-email-yoshihiro.shimoda.uh@renesas.com> Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch adds an exported function to get minimum page size for a domain. This patch also modifies similar codes on the iommu.c. Signed-off-by: Yoshihiro Shimoda --- drivers/iommu/iommu.c | 18 +++++++++++++++--- include/linux/iommu.h | 1 + 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index 2a90638..7ed16af 100644 --- a/drivers/iommu/iommu.c +++ b/drivers/iommu/iommu.c @@ -280,6 +280,18 @@ iommu_insert_device_resv_regions(struct list_head *dev_resv_regions, return ret; } +/** + * iommu_get_minimum_page_size - get minimum page size for a domain + * @domain: the domain + * + * Allow iommu driver to get a minimum page size for a domain. + */ +unsigned long iommu_get_minimum_page_size(struct iommu_domain *domain) +{ + return 1UL << __ffs(domain->pgsize_bitmap); +} +EXPORT_SYMBOL_GPL(iommu_get_minimum_page_size); + int iommu_get_group_resv_regions(struct iommu_group *group, struct list_head *head) { @@ -558,7 +570,7 @@ static int iommu_group_create_direct_mappings(struct iommu_group *group, BUG_ON(!domain->pgsize_bitmap); - pg_size = 1UL << __ffs(domain->pgsize_bitmap); + pg_size = iommu_get_minimum_page_size(domain); INIT_LIST_HEAD(&mappings); iommu_get_resv_regions(dev, &mappings); @@ -1595,7 +1607,7 @@ int iommu_map(struct iommu_domain *domain, unsigned long iova, return -EINVAL; /* find out the minimum page size supported */ - min_pagesz = 1 << __ffs(domain->pgsize_bitmap); + min_pagesz = iommu_get_minimum_page_size(domain); /* * both the virtual address and the physical one, as well as @@ -1655,7 +1667,7 @@ static size_t __iommu_unmap(struct iommu_domain *domain, return 0; /* find out the minimum page size supported */ - min_pagesz = 1 << __ffs(domain->pgsize_bitmap); + min_pagesz = iommu_get_minimum_page_size(domain); /* * The virtual address, as well as the size of the mapping, must be diff --git a/include/linux/iommu.h b/include/linux/iommu.h index 91af22a..7e53b43 100644 --- a/include/linux/iommu.h +++ b/include/linux/iommu.h @@ -366,6 +366,7 @@ extern int iommu_request_dma_domain_for_dev(struct device *dev); extern struct iommu_resv_region * iommu_alloc_resv_region(phys_addr_t start, size_t length, int prot, enum iommu_resv_type type); +extern unsigned long iommu_get_minimum_page_size(struct iommu_domain *domain); extern int iommu_get_group_resv_regions(struct iommu_group *group, struct list_head *head);