From patchwork Fri Sep 22 17:07:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 13396034 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B6527CD484A for ; Fri, 22 Sep 2023 17:08:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Cc:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=qd4A3g6K+EpZzV986PjZ4OWlmkN+3ezBzBkMSjbD1yc=; b=VS0ACpZO2WtW4X bTS9tEGBpD2PnkGWXrJBTkE5QbJ+D1OhiePzjkKnK8OAcubwUNgy5TKWPsTiWbGp7F3qeA7/SJYa7 WFgaXtcGmfaUtHkq+tXskMdRT8C4+4+IECQ3pytjOkqa3sKZxP4x0ywqaZmuIQOl+9tZpvcepB/qU OjAvc4XYCazP0paCDbD+tl4T0QLCtbVkvKBTNURw51STREF2/VToCfa2jAWWJsMl/yXDeztuaYye1 ns7+3FfAqXGOefAIogR3Kv8coV8unoaR/MEUEw78QzJ65+ZbbWbDKE3UHAX7h60rIWDRUIGV2f3Yv 5zqnl2D4zxk1NXNjHv1g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qjjdr-009TOl-0V; Fri, 22 Sep 2023 17:08:35 +0000 Received: from mail-dm3nam02on20618.outbound.protection.outlook.com ([2a01:111:f400:7e83::618] helo=NAM02-DM3-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qjjdd-009TDY-0k for linux-arm-kernel@lists.infradead.org; Fri, 22 Sep 2023 17:08:25 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BRxDSEH/A3hq0CxQzX+DY7J1KX3fEqUAk8eE2JZceRR5vfbtNkDkCT185/Ln3tdC58O1vhjsN0dcRndSzJOQ7wA+EXXboGjWr7hCrs4BkaaUkNq/G8Vzgqaae1yD/T8BGfGuyiFr4RmCMVAactW6lLi2svfDIXqZE6owxw0Yh2koJ8MOkmaOnPRPzGoR46t0ZtFpJI6rw83Eyy8GGb6M7iAtkCbDevR5EGMyHK1IZ66l1cZe/1mhqnMdm/WZBbxLKEgKJ7smmrkpytDTsRP9nOMKRZn5Ms7ycU93XB5KX4WAfcc8M05TJq5Gwqd4Afr4tS7wtQMY6+RF0iOTw+uFTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ldRc0qGf3zoIOde/YqWWMBp7sNe2gJyJ0ZV7n/pJ67M=; b=NtYQYQl/u5QCQT6dJSgHPGdQBMaFaMRDUw2LPsMjcApJj95+0E7KB17rUuEy3K14d/MrR7LRW8wFEFRmyuSIw0CrPdbxj9L0ahgJY7KWcWYSz8iCEoIcgfSuEsXK4HDn1TaBpJhA0XLETpgH78H0eYH0NQPmPx4pkqD4tXVryXuCMgSAWY3jhZKE/uQDrIA0LYIprfQhRoPlUrky4MsBg9vCfyyxCg/Z9pxqdzaLl5jiDiGe7JUUp5kB9oHt2g9+nYEKXJuab+oTV9mC4Jwsu4L+1F33G+URysUDdD5xWDIraAxldZ3bFczT9kBXkrj4dy4/jKwzsQcaRlIasx3V8g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ldRc0qGf3zoIOde/YqWWMBp7sNe2gJyJ0ZV7n/pJ67M=; b=IFD9Qm8D/ghr3TOuMt0QcqSu7IhpdoaMmsjVxuTyEyzIJswl9+uEEwS1fiPy+f/8eU5RsFBa2aFYZS1+YTGjp3FBJwrOBOS+Ttt4zq+HZcYZFXfSVnJFb7pPmRToSwd51+9ztieEYFVp4crhYVSZiwyk9SJlwUA2wnIsqk1n8F8Iz1Ftd6s9W347i5Wk7Bc24IyIygj2iz5AptsWW43imD8x4BJbPVpSafRZf6c+dLPGTbE2dbAxhI5iY2pMlHszpEnTxFehDECeeSsvzD4QV7hbMwv9ZDneE8SFzjeOEFlt6Nq9gYcRQtS+vSBx9f61CXhTkZohRAdLpHLNrGzEew== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from LV2PR12MB5869.namprd12.prod.outlook.com (2603:10b6:408:176::16) by LV3PR12MB9188.namprd12.prod.outlook.com (2603:10b6:408:19b::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.23; Fri, 22 Sep 2023 17:08:02 +0000 Received: from LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::faf:4cd0:ae27:1073]) by LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::faf:4cd0:ae27:1073%6]) with mapi id 15.20.6792.026; Fri, 22 Sep 2023 17:08:02 +0000 From: Jason Gunthorpe To: Alyssa Rosenzweig , asahi@lists.linux.dev, Lu Baolu , Christophe Leroy , David Woodhouse , iommu@lists.linux.dev, Joerg Roedel , Kevin Tian , linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, Hector Martin , Michael Ellerman , Nicholas Piggin , Robin Murphy , Sven Peter , Will Deacon Subject: [PATCH 1/8] iommu: Move IOMMU_DOMAIN_BLOCKED global statics to ops->blocked_domain Date: Fri, 22 Sep 2023 14:07:52 -0300 Message-ID: <1-v1-8060f06462cc+c0a39-dart_paging_jgg@nvidia.com> In-Reply-To: <0-v1-8060f06462cc+c0a39-dart_paging_jgg@nvidia.com> References: X-ClientProxiedBy: YQBP288CA0015.CANP288.PROD.OUTLOOK.COM (2603:10b6:c01:6a::12) To LV2PR12MB5869.namprd12.prod.outlook.com (2603:10b6:408:176::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: LV2PR12MB5869:EE_|LV3PR12MB9188:EE_ X-MS-Office365-Filtering-Correlation-Id: 48af9319-d147-4cd9-4312-08dbbb8e7a4c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: MKRAJCq6z3nD4amXZUPm1DFcafPk2H6JntvF2Zq0OY6kWkn3S+LkKSOnW+rucJbsYAsE0xPjqzB9DDGvtgZTSWJzGliAEVv7PcpK9hovWIvVdRoCNAeNN3cmwixr8kLDckF4fZzdCAMH9XULLH6m8zdHD62h1ZBVBGj+srmMvCfbQyJCxquYRDX93nEK+TrMbjIkhlsXOhnpdAsoWNdTRU0O1cRmWKpoi6suRPL1rj6DZsU0ylspWdba3SgfL9sV/0j/lr1x78kQHB28iZcOWnS8AhR+9fVJXArZmCj6HKzIfrqUTMtL10YmctUw+8sdZmq8y3cx4xcdNgvFScDCVSgYgfDK8+2bBuoSgkDHtCXkJWg0roOZ5J8Xvd7IYETDomuoX7pJWgbxg27DH/hU+zU/SrchmeZdHwlDVTd2XSAl4A2YmEMGzbNtbQReEZt1LUeEsvYF6xpxuqvgeifWN2wjTtrpD/9hs016+h0c/bY/4MiHEYOl17AJlFgzvARY6N9pwlMt/3g8AQtvRK2ApiknYyuAUEnpiOQ/x3fGekBDdIYJyC95iXZdVGQ0veyGqzz/EEYFZVZz1KX8oo7Z66YHcWeESUib1fP/J2tKelJNhhEadj7XWlMjRCWpYVlA X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:LV2PR12MB5869.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(136003)(366004)(396003)(376002)(39860400002)(346002)(186009)(1800799009)(451199024)(921005)(26005)(8936002)(2616005)(8676002)(15650500001)(7416002)(83380400001)(2906002)(36756003)(86362001)(6486002)(6506007)(478600001)(6666004)(5660300002)(38100700002)(6512007)(66946007)(110136005)(41300700001)(66556008)(316002)(66476007)(4216001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: U7ovb08TCe5oLYmn6ofl/stmoKs4/xjLDAohGVKXZPWNm5slhQ3r9sVILzejUh8WEFWGaHKwoqC6tg+aAapexLlPIfMblQ6dUiBRJ9xTqLl174+tm9N2QnxR+/DQmqNR4fcD/9kavdewAYnBwViPsj2/6fNtJCCUaiI3RFZogPBZ4tu9H6lJ4qak75Dn3ZdiGRPwR1OFCY0qefEvVV3f3zHlen8agThJ4/2XywWNkFr3j8LLjR1BPbkNtY7OjKPuxWz2X/1kt8mpCenpxz//zUn+znHm61GBRu3ejhgk2etaKpBqN8vv9h85tYTTTPqZZYEYafvZtnaNilGKWNevrZ6MLGjiOrECjVLo17vHmznt8JgIOjA+2LWCk8N2RIXLx9nQikSDWicCjotqN4dX+m871WYFChxFYXFIIVb1xdUMZF8uSO/v9+EwTYE+zLOtODj2M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6+3N5g4f1ULuVXuf5UFhnAPqd4Olw6XWuvzv9wpERiogWG+GEKY32QkNpuA X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 48af9319-d147-4cd9-4312-08dbbb8e7a4c X-MS-Exchange-CrossTenant-AuthSource: LV2PR12MB5869.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Sep 2023 17:08:01.6236 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: WZ2guhXupR+G1/xGasw3UibM96akiIc8IznRplPmItH2/QgJMoCohYMxtZu0n7+Y X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV3PR12MB9188 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230922_100821_290931_3F60C980 X-CRM114-Status: GOOD ( 16.14 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Following the pattern of identity domains, just assign the BLOCKED domain global statics to a value in ops. Update the core code to use the global static directly. Update powerpc to use the new scheme and remove its empty domain_alloc callback. Signed-off-by: Jason Gunthorpe Reviewed-by: Lu Baolu --- arch/powerpc/kernel/iommu.c | 9 +-------- drivers/iommu/iommu.c | 2 ++ include/linux/iommu.h | 3 +++ 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/arch/powerpc/kernel/iommu.c b/arch/powerpc/kernel/iommu.c index d6ad3fde85a212..3c1d10be19c4c7 100644 --- a/arch/powerpc/kernel/iommu.c +++ b/arch/powerpc/kernel/iommu.c @@ -1327,13 +1327,6 @@ static bool spapr_tce_iommu_capable(struct device *dev, enum iommu_cap cap) return false; } -static struct iommu_domain *spapr_tce_iommu_domain_alloc(unsigned int type) -{ - if (type != IOMMU_DOMAIN_BLOCKED) - return NULL; - return &spapr_tce_blocked_domain; -} - static struct iommu_device *spapr_tce_iommu_probe_device(struct device *dev) { struct pci_dev *pdev; @@ -1368,8 +1361,8 @@ static struct iommu_group *spapr_tce_iommu_device_group(struct device *dev) static const struct iommu_ops spapr_tce_iommu_ops = { .default_domain = &spapr_tce_platform_domain, + .blocked_domain = &spapr_tce_blocked_domain, .capable = spapr_tce_iommu_capable, - .domain_alloc = spapr_tce_iommu_domain_alloc, .probe_device = spapr_tce_iommu_probe_device, .release_device = spapr_tce_iommu_release_device, .device_group = spapr_tce_iommu_device_group, diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index fe033043be467a..7fa53d28feca87 100644 --- a/drivers/iommu/iommu.c +++ b/drivers/iommu/iommu.c @@ -2049,6 +2049,8 @@ static struct iommu_domain *__iommu_domain_alloc(const struct iommu_ops *ops, if (alloc_type == IOMMU_DOMAIN_IDENTITY && ops->identity_domain) return ops->identity_domain; + else if (alloc_type == IOMMU_DOMAIN_BLOCKED && ops->blocked_domain) + return ops->blocked_domain; else if (type & __IOMMU_DOMAIN_PAGING && ops->domain_alloc_paging) domain = ops->domain_alloc_paging(dev); else if (ops->domain_alloc) diff --git a/include/linux/iommu.h b/include/linux/iommu.h index 4f65879df853e4..6f9e0aacc4431a 100644 --- a/include/linux/iommu.h +++ b/include/linux/iommu.h @@ -264,6 +264,8 @@ struct iommu_iotlb_gather { * @owner: Driver module providing these ops * @identity_domain: An always available, always attachable identity * translation. + * @blocked_domain: An always available, always attachable blocking + * translation. * @default_domain: If not NULL this will always be set as the default domain. * This should be an IDENTITY/BLOCKED/PLATFORM domain. * Do not use in new drivers. @@ -302,6 +304,7 @@ struct iommu_ops { unsigned long pgsize_bitmap; struct module *owner; struct iommu_domain *identity_domain; + struct iommu_domain *blocked_domain; struct iommu_domain *default_domain; };