Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp2243278pxb; Sat, 28 Aug 2021 08:40:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwV5cV9MClR2g5kRwSJhfG8XA7iIp9PUFskb5IQojDUJolxze13IdggzyDrW8Bx+Ri+u4kL X-Received: by 2002:a5d:9681:: with SMTP id m1mr11717612ion.113.1630165221718; Sat, 28 Aug 2021 08:40:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630165221; cv=none; d=google.com; s=arc-20160816; b=FLuoY9I0HW1qTYyvXgQjNFmWsJnxsD19bsuWWxy954ih4qj5mzwO9fyYbC5wj5terG P5sqyf628OXVZ9DRjJWzjQFRdeuPFwAgDBSkaZHvh7Hn40o5WJF44Uwwj7rHH18AxqWn qoTrM8zFH4jUovNmS7saNnQt1KgI4Lsixyx96n1m+KgBLQQsQEt2JlNKZ44pZtWI4RSN sYlA2LITvn+TATW2sokfN0eLMD9F64bpxPqTLWeQOTeuJ6DL8F5UQ/IouBgu3Jquf1qm A36nLcjUDAsrBVrhVgi4rBWsMNqFUNYCAN/D0ByLU4+e2WVJ4EkUkc07P9EqG0PLzGxC QNxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-signature; bh=iBZuNFnMAvAXFVZFIFKfDQcXdgvOjdknTaSW4E1ZtzY=; b=ENkmAJZrw2OTu2Udt6U9LPBe9+5bs5uQRGm0mFu6ie8697bjHoad3PRMMp8dZoel45 6z2dbiu7FwgESirs07PA5e1YrDEWstmvuFJPn/qu4y45hop2cx+PlKz2Y2CTuPKeePYf SZljwrgi84kRz5NG6gO9KpGMKJPZaNtzTtUjR+RDdDyKRJa2R5ZHoRpQX6B0lCi79QRg biaq7CupG+54/bxt78XX/gxTmXXDl4rNwJr/GZQ8LbKovtrqhvmbVHQkHs9GYI7rupjN MlmmCwFMP/LUcg4mi3ikbtClvdtUBTfDGBhxHy/CiMlyrWEZ/0cPB0VmJNDw51FDYTmR H0Eg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@svenpeter.dev header.s=fm2 header.b="c/VwfpjR"; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=tAu3pq1n; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=svenpeter.dev Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f11si9626903iok.80.2021.08.28.08.40.10; Sat, 28 Aug 2021 08:40:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@svenpeter.dev header.s=fm2 header.b="c/VwfpjR"; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=tAu3pq1n; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=svenpeter.dev Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234570AbhH1Pj0 (ORCPT + 99 others); Sat, 28 Aug 2021 11:39:26 -0400 Received: from new3-smtp.messagingengine.com ([66.111.4.229]:49661 "EHLO new3-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234505AbhH1PjT (ORCPT ); Sat, 28 Aug 2021 11:39:19 -0400 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailnew.nyi.internal (Postfix) with ESMTP id 31173580A70; Sat, 28 Aug 2021 11:38:28 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Sat, 28 Aug 2021 11:38:28 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=svenpeter.dev; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm2; bh=iBZuNFnMAvAXF VZFIFKfDQcXdgvOjdknTaSW4E1ZtzY=; b=c/VwfpjRKGKyjAnHha0tIGkrNmWyq 0g3szPYIKnzu4aAfk80wCEnn66CGQJeQsyJ5K0Jy6vTchiUFKgmSvX40FeCVkJ1Z Gf+IoW0tbRtXQsFnByhX2t52e2sBnB0JFHBMN7Ftwryi9bXrh0dz0eZMblKyQbjV uvHB9ArRdLD2w7khy7O+JhmiqPG1TSnH3al+efim+J/zNWjXuS6U+llxy2/VnLUw rKrtp46xJLZOzYYk+FHnXRwillocXYCR5/M5xrmv2pBQd6hXZc9ajFtWWJyQWPpC BcMf/jUQBDc7NGrzEFTdfVtMDxUULXkq4oyyCp5tPDJMhOFwCVRM9oeTw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=iBZuNFnMAvAXFVZFIFKfDQcXdgvOjdknTaSW4E1ZtzY=; b=tAu3pq1n ozKuH7rLXQa2DquSzgz7ffOBjSG4J8xzN1yte5s0Il7oI15Oh7vNf6BWyQtCdZUh r07hGHCLi9umT3pKd2003R97lkHRFRPz9NFAM1jqXdA2rknmAVWYf0NjfmSHOyxv qfTa3uYtLs7zwJ4p5QqOhupE9AOyYeBRk5u4K2MqhryfhT8v6htchX58y7jRqFpT CAT2cSYQ0BRbnslSt4AQMSMCHPee+wLDGfn2RwlzizifA3cWH5vcVAaHumEfEo+4 VjhZMDczeIfET3ceaTNARgllIcYgtBlg/xrXaoYyrSoIwb0cc9b9h+vWr4iMzAqT FJNjCS1CXFfhTA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrudduhedgleduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefuvhgvnhcu rfgvthgvrhcuoehsvhgvnhesshhvvghnphgvthgvrhdruggvvheqnecuggftrfgrthhtvg hrnheptedvkeetleeuffffhfekteetffeggffgveehieelueefvddtueffveevlefhfeej necuvehluhhsthgvrhfuihiivgepvdenucfrrghrrghmpehmrghilhhfrhhomhepshhvvg hnsehsvhgvnhhpvghtvghrrdguvghv X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sat, 28 Aug 2021 11:38:26 -0400 (EDT) From: Sven Peter To: iommu@lists.linux-foundation.org Cc: Sven Peter , Joerg Roedel , Will Deacon , Robin Murphy , Arnd Bergmann , Mohamed Mediouni , Alexander Graf , Hector Martin , Alyssa Rosenzweig , linux-kernel@vger.kernel.org Subject: [PATCH v2 7/8] iommu: Introduce __IOMMU_DOMAIN_LP Date: Sat, 28 Aug 2021 17:36:41 +0200 Message-Id: <20210828153642.19396-8-sven@svenpeter.dev> X-Mailer: git-send-email 2.30.1 (Apple Git-130) In-Reply-To: <20210828153642.19396-1-sven@svenpeter.dev> References: <20210828153642.19396-1-sven@svenpeter.dev> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org __IOMMU_DOMAIN_LP (large pages) indicates that a domain can handle conditions where PAGE_SIZE might be smaller than the IOMMU page size. Always allow attaching devices to such domains and set the flag for IOMMU_DOMAIN_DMA, which can now handle these situations. Signed-off-by: Sven Peter --- drivers/iommu/iommu.c | 2 ++ include/linux/iommu.h | 8 ++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index f02b727d3054..77d1ee14c7d0 100644 --- a/drivers/iommu/iommu.c +++ b/drivers/iommu/iommu.c @@ -1980,6 +1980,8 @@ static int iommu_check_page_size(struct iommu_domain *domain) { if (!(domain->type & __IOMMU_DOMAIN_PAGING)) return 0; + if (domain->type & __IOMMU_DOMAIN_LP) + return 0; if ((1 << __ffs(domain->pgsize_bitmap)) > PAGE_SIZE) { pr_warn("IOMMU page size cannot represent CPU pages.\n"); diff --git a/include/linux/iommu.h b/include/linux/iommu.h index 6633040a13f9..40c1ad6be4e7 100644 --- a/include/linux/iommu.h +++ b/include/linux/iommu.h @@ -62,6 +62,8 @@ struct iommu_domain_geometry { implementation */ #define __IOMMU_DOMAIN_PT (1U << 2) /* Domain is identity mapped */ #define __IOMMU_DOMAIN_DMA_FQ (1U << 3) /* DMA-API uses flush queue */ +#define __IOMMU_DOMAIN_LP (1U << 4) /* Support for PAGE_SIZE smaller + than IOMMU page size */ /* * This are the possible domain-types @@ -81,10 +83,12 @@ struct iommu_domain_geometry { #define IOMMU_DOMAIN_IDENTITY (__IOMMU_DOMAIN_PT) #define IOMMU_DOMAIN_UNMANAGED (__IOMMU_DOMAIN_PAGING) #define IOMMU_DOMAIN_DMA (__IOMMU_DOMAIN_PAGING | \ - __IOMMU_DOMAIN_DMA_API) + __IOMMU_DOMAIN_DMA_API | \ + __IOMMU_DOMAIN_LP) #define IOMMU_DOMAIN_DMA_FQ (__IOMMU_DOMAIN_PAGING | \ __IOMMU_DOMAIN_DMA_API | \ - __IOMMU_DOMAIN_DMA_FQ) + __IOMMU_DOMAIN_DMA_FQ | \ + __IOMMU_DOMAIN_LP) struct iommu_domain { unsigned type; -- 2.25.1