From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932141Ab1IPRwa (ORCPT ); Fri, 16 Sep 2011 13:52:30 -0400 Received: from mail-fx0-f46.google.com ([209.85.161.46]:53304 "EHLO mail-fx0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752386Ab1IPRw2 (ORCPT ); Fri, 16 Sep 2011 13:52:28 -0400 From: Ohad Ben-Cohen To: Cc: , Hiroshi DOYU , Laurent Pinchart , Joerg Roedel , David Woodhouse , , David Brown , Arnd Bergmann , , Ohad Ben-Cohen Subject: [PATCH v3 4/6] iommu/amd: announce supported page sizes Date: Fri, 16 Sep 2011 20:51:44 +0300 Message-Id: <1316195506-9777-5-git-send-email-ohad@wizery.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1316195506-9777-1-git-send-email-ohad@wizery.com> References: <1316195506-9777-1-git-send-email-ohad@wizery.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Let the IOMMU core know we support arbitrary page sizes (as long as they're an order of 4KiB). This way the IOMMU core will retain the existing behavior we're used to; it will let us map regions that: - their size is an order of 4KiB - they are naturally aligned Signed-off-by: Ohad Ben-Cohen Cc: Joerg Roedel --- drivers/iommu/amd_iommu.c | 21 ++++++++++++++++++++- 1 files changed, 20 insertions(+), 1 deletions(-) diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c index a14f8dc..80191d2 100644 --- a/drivers/iommu/amd_iommu.c +++ b/drivers/iommu/amd_iommu.c @@ -2488,12 +2488,31 @@ static unsigned device_dma_ops_init(void) } /* + * This bitmap is used to advertise the page sizes our hardware support + * to the IOMMU core, which will then use this information to split + * physically contiguous memory regions it is mapping into page sizes + * that we support. + * + * Traditionally the IOMMU core just handed us the mappings directly, + * after making sure the size is an order of a 4KiB page and that the + * mapping has natural alignment. + * + * To retain this behavior, we currently advertise that we support + * all page sizes that are an order of 4KiB. + * + * If at some point we'd like to utilize the IOMMU core's new behavior, + * we could change this to advertise the real page sizes we support. + */ +static unsigned long amd_iommu_pgsizes = ~0xFFFUL; + +/* * The function which clues the AMD IOMMU driver into dma_ops. */ void __init amd_iommu_init_api(void) { - register_iommu(&amd_iommu_ops); + register_iommu_pgsize(&amd_iommu_ops, &amd_iommu_pgsizes, + BITS_PER_LONG); } int __init amd_iommu_init_dma_ops(void) -- 1.7.4.1