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; }; From patchwork Fri Sep 22 17:07:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 13396031 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 57C28CD4847 for ; Fri, 22 Sep 2023 17:08:54 +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=SIsdoY0FWYK/HHeRPLzzcZKMVsCqqOigoMoAGtOesFY=; b=DPTizY+ObG0LF1 gKP9k5EJc4JKFqBSQY5xZUlI9DlE+ajrGJMXP62jLCwph4c6vP3dcjwdTGgrUe3nNAz79f1bsgU9W qXfSo2STsGTxlcER02W8DQD55QRGDxVd87jBw3L27V1lrJg/XtCE0gNUcu4nQlQES2gAbqRCAkkWj npmTh3/VQQB0+/hmH8gZCIG43j0hmjjd8OL1fbg7nQxNcEGJt3wmiHvSfWPjI6FOe36cGh3igCb3c I8CV7JaRmlfeRwdkM6z0PDFLzcYF/H0K/pcpJG5xUIgw1coPOrQTfCVIFv+nR0dvSokNhrYDzSVBL Gtqd1mPSKYAu8kSx4utw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qjjdq-009TOG-1y; Fri, 22 Sep 2023 17:08:34 +0000 Received: from mail-dm3nam02on2061f.outbound.protection.outlook.com ([2a01:111:f400:7e83::61f] helo=NAM02-DM3-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qjjdd-009TD0-0d for linux-arm-kernel@lists.infradead.org; Fri, 22 Sep 2023 17:08:24 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZylTcbjmcoGSq0WzBysffRE8o4Wr74q8THHmgt4j22l37+DldJmlOwuIeRxYsktVEfrFifD3Ol68uE4iG8EK8rFUPzXOJrQQJWmVlwGGdHpVwF0rVO/BReZdWNmdHZ/z2a31DP8a4qCnf6jjtlbnc+P9TLR/ce2YiA600bMT1ag7LQ/W35nYyRZL4Xdr9RXwQ1SXi1QIAkFhMOO46t5yoh9svT80MO0DhJBRIVcOO0Q9B5cb7GoJpJIVy7G5CGlCb7+Pdz41qnxzrbIxeTv3YO3nI7xexS7mGD4a6t+ImzPp+UUYV5eLqutFZIX+Ty73wrGfMfnyOfZKQk2Z4fm3DA== 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=B5vC/OP2UNhWxMABCnyreU56MffKEXor916AYWgY+48=; b=GElbSmFCh2cW0xMmp9j4+jY4z3xSLF7LrneiVuOHO4khm3RvHB4XSgYHK8wR41W+DpfUqd1FV7P7KTcAaUFHK0yUdve+jnRR05Rg4S5dl6/WE0xrNE812GLuN0ZeR0g4RzBV629g2p4q13qgIeQcJndmR+FoQU1CgCQb22jGu3ZtfZMQZRnLVFa6CtcrwaPcSat6vDFolMQpmr0Jj39SiHxUpnMvKEjbZxCae9bWrHq6WppYffD0oneEgLSO965hmPKp0Rqjmy/aR8z3o1YhBgBSB7PbEEh7gxZsCNfWtAVIB+0oCMgQNRlX5y2NUytzBRjcri3chmtJZHhVg78NWA== 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=B5vC/OP2UNhWxMABCnyreU56MffKEXor916AYWgY+48=; b=dSYvqOA0E9Njue3C5LRaD63gtkZszyaMzcX2mZYt3wOL0DfH15VBc6wUTUPZKaH5wurwdInR4ZoLeYBLSTwHKCJ/6s+KcSGB/5/XlKaGTbFOiyzdov48PjmXH5uYQgj0NPoX2rWfaVAg7OtMiKoCyN4WGxGzJhfLzxJPBcf6QgY8cicDcZ+qHWI+RzJHFw2wqNizqT3aiF/GxvEGTKE6Q2pD6lxgsJeZckgUAWTZO2IV9gOrhAgyy+/E4AThj1PJL0CdOOW8ObAdsvfk2W0Iy4aK0KGmxG3kDtHfkZDQ3IEv7hD8ue1+ZbYIZhnEQ+GhLHaHpkjjCOddw6NX2uT6Zw== 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 2/8] iommu/vt-d: Update the definition of the blocking domain Date: Fri, 22 Sep 2023 14:07:53 -0300 Message-ID: <2-v1-8060f06462cc+c0a39-dart_paging_jgg@nvidia.com> In-Reply-To: <0-v1-8060f06462cc+c0a39-dart_paging_jgg@nvidia.com> References: X-ClientProxiedBy: YQBPR01CA0045.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:c01:2::17) 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: 6ce71af4-7882-45ce-0a71-08dbbb8e7a32 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: yoFqgxH86SzkkwuJcT9PUK/ATzN3KJdsX/HC0mIUgVPPYX6WwGlYMzf40fYiBDQvA3Ez02ItHasRaLOH7MVoDikqQN/PbvYCQ6S0tus9k7cGEfMQLYOU8JoVRwJAJI7WxQ4eNudCEih5tRhkMapHz+fOh5pbP23HXtVt0d/SepoeIuGrH9LarjWivagxZZ+oMan/iot22jZIBkoNNeIzc+0BLpuP2y0sBOgrabEJGBTfrj4KabwgSLY3hu85PfPAQswmygQUL3lWoMPJjNA5xjkpH6rDaDMlBbYp7neUAgjjTQ7CGgSiMTAgniPzMMFlF1O8siK4xZpKIRvINRvKQhed80CRUzWllT9HT/R/5PaTp8fnQMt+tpUDlJA6xsI3PbimJTf5QzbsdJOGSNfsc5VbRyzE/B407lZTXhz8FdlyAcJ5EgDYY2tVhvZrk3T+Vhu4u7/gPx8oSksDxA/KONaD+2Iu5b8jcr1YR4+/3Ktz/KBEIO40UaAmp/Z87LZTV1rHTXfHV1XyyUfvhU3X+W8rv2iMaD4ANBMEz/L9W+L92CMbM6whHGjPzy6KFOfBMjvMAMnPnbXKpcp5m60iVGOFGvjrJKEkh1EDeDZyBOcSiwq9dNKJ38alXLMlQ7kL 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)(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: MNq1XJTTehdAPpQKLOfqzbFVWQh2hHYSdXPH+blRLqqAn1O01ZUIW88vn9H4l/hyqCKP3F7LUTLRhjq1GLgInMWcHv95CBnIBEMMAX7cbr+efZTCE53tfL5TklHkOeeu/Cs6LV88i4yD/nqMpsLdUWJLQp7T4kLR+15ZmBsjoUH7HdRp/Ehy6a1rHJsWDlxa8cVP7xB7BwJ4eguMt8b12mCEq0X0ejtb68UICUmocbl5tBXiOcPfR4dryV25ilMQLRZnBn2ekzi5KjZy2gxVQiZ+ZulcpQq7PDm+T4uKP4KfN+ZGp6lZy1IDeQ1L/lWvjtEMDGrtAkKVMIhVYtUTZJphTEeD3ofM4JGYUb3qn2pYngmIDs/23Ix4UPmha7riXokeZ0mnSisKMAp7YcjfrSbdRxrni+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bnEZI67CSV+Zx73ZDIPm8XSpHfQYDop1NZDTkKxgtmV7Sk7ONcwdYI7Hk5I0ncdUOOlnu3PrjN1cCgHWGowDpRBXnyGw5 X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6ce71af4-7882-45ce-0a71-08dbbb8e7a32 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.4211 (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: IE80NDlaI3LXaLK2oN4QD7In7XjMVk/HL3/bjkyjaT88FOXFhXrIyC6TOHE6p+B+ X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV3PR12MB9188 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230922_100821_248125_C7BA828D X-CRM114-Status: GOOD ( 12.80 ) 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 The global static should pre-define the type and the NOP free function can be now left as NULL. Signed-off-by: Jason Gunthorpe Reviewed-by: Lu Baolu --- drivers/iommu/intel/iommu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c index c8036caad24e7a..0d0cb2534972a2 100644 --- a/drivers/iommu/intel/iommu.c +++ b/drivers/iommu/intel/iommu.c @@ -4029,9 +4029,9 @@ static int blocking_domain_attach_dev(struct iommu_domain *domain, } static struct iommu_domain blocking_domain = { + .type = IOMMU_DOMAIN_BLOCKED, .ops = &(const struct iommu_domain_ops) { .attach_dev = blocking_domain_attach_dev, - .free = intel_iommu_domain_free } }; @@ -4075,7 +4075,7 @@ static struct iommu_domain *intel_iommu_domain_alloc(unsigned type) static void intel_iommu_domain_free(struct iommu_domain *domain) { - if (domain != &si_domain->domain && domain != &blocking_domain) + if (domain != &si_domain->domain) domain_exit(to_dmar_domain(domain)); } From patchwork Fri Sep 22 17:07:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 13396029 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 6DBF3CD4847 for ; Fri, 22 Sep 2023 17:08:45 +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=9se62cNM+BUTltOX96ZCDMYukQy0w9ao0uPsYPF6rc8=; b=IF2pX5Bb3E5jLG 3obgQXUbjsEzbodlCsPbCqM5o5kZaM5Z5hcyxM2+YqVz14EhJxji9drVl/Wm4QGWrs9EeM6Wte4sv 7kMsIAtvU+UVz95LIh6pN9qRIj4tJy1DDb2sPoqyBuRD4uYTM5FOeXiWUHgXmw/JE828X1akT0e8N Yw+KUzPgKOL9lhg29HpMQimgskt2xmO5HbxYa5DP17wmLIJRLe/qlMt334rhdFwOXZxpYU4rzkIoI YAzskyEPk6psFQbyvCzF6k5VaZg8kQbq3qHxv8sDZ+naPbCiggOc10RsEbwSknnJG8J19lQdhZDaY KsMg8CLqij+yf4ZwJMjA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qjjde-009TIC-2S; Fri, 22 Sep 2023 17:08:22 +0000 Received: from mail-dm3nam02on2061f.outbound.protection.outlook.com ([2a01:111:f400:7e83::61f] helo=NAM02-DM3-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qjjdb-009TD0-1C for linux-arm-kernel@lists.infradead.org; Fri, 22 Sep 2023 17:08:20 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hXG7vGImCBJ0Wen5LyeYG45kRPnYtVf3N3usXd4WPJ5+Zw4l9sNIj+XIL2clas3fKzdHBpb5bDrIifppB70puFxYjxHeuKAZBIOVKUeHbjawNN4gNeLykcTeVm/4/o3DPNfw+8nmcHEP8ljd0svZq/52N9egHzrBBqEndzQ9d+5FgKO/ajCu8kPBkr61c+Ppc1GqUyq1A6qGnMx2t5MlorYQpbQff9C8SblcTcTCp/gRF+zBAQxLxW2GofFngDhCJS0WUgboAqiFlEuqucZB/unzMu74/i7C/YisDfGvazQcwp7gkiubkUuM/rjehXckupl2MkFIkSU8ibJXWJbqjg== 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=FMGSMhE4LPGfp9KmYnExkWeWRJfmg8ZX2jadHiHo/x4=; b=Yq9vy5ZZrlH3B53O+8qsQrkf1RZenzSHvdEzxKbh8lZoXP3MDRvoJcqOy86gc+IheBYSUS6U8i1bCbBE2ibYKYLJi8KW1H0cfR19+sznemcHVxCERyWvH4yQ+QP3i9gko+q3NZAl7XEZ7oPEHJgED0J6OjHcjpGDRRDOz46jCrV3hAdgg6ILM/OqZfP17UoG7BGxX9GZ5u/QlqIZ15Ra9fWvC8fun8BghJYH7mYHo91ZckDdryfQz0FwfWtJTAPIoBkl1FnbicwFLlou8o1pYY3uCNNsseKEdMttS49QLomlHI1jpQqSPsOCEe84li1kxzh3VQp2wvCy7HTS//rOsA== 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=FMGSMhE4LPGfp9KmYnExkWeWRJfmg8ZX2jadHiHo/x4=; b=b3mDGcHgG1w3mOxLa3K156Ge3kPjrV2+WOUmDFT6RJOuLurVnviTjWvCRhhZssVrVd7SWMO+6pmz63Q2kLRxAZYLCO0psCuR9FJAjmnmswiFlwXciUv8z9nbsWieFHQNqRsIfbRCrdQuvrQ3L/Rt8nLO+TDSGBQc8VO53ONq3E9KcT/h3H1bUYTCn+ZKRhM0hQxWQmCWXcQ/6HPxPHyAkLV5ZzUTVBJQfq8tmwJVTTtmuBnf0gIjAVpYV5Lyfz/4WV8L5UYyL9Z/hYSLpZf6q/dpZNigWT4yL66pe1Gwb47HWsxY1wqduzwmvWh/VdolGmRzWn8M4hIdK6ZpSB11iw== 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:01 +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:01 +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 3/8] iommu/vt-d: Use ops->blocked_domain Date: Fri, 22 Sep 2023 14:07:54 -0300 Message-ID: <3-v1-8060f06462cc+c0a39-dart_paging_jgg@nvidia.com> In-Reply-To: <0-v1-8060f06462cc+c0a39-dart_paging_jgg@nvidia.com> References: X-ClientProxiedBy: YQBP288CA0011.CANP288.PROD.OUTLOOK.COM (2603:10b6:c01:6a::22) 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: a45cc70c-28ff-4074-0d59-08dbbb8e7a13 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: e9pd9KQ9wvHM0zvGvfapYNpQalWB01EgXQvt5alen8Vgw5M3av4opuGh/6kME0dpXgTo1TJEAEct9gdJh+SeRCjIDrNNBpveFvcINkqrtrxCLaYFTNX9OHJRd+SdB9nfBgtaJoMdCU4ROp/LpiuOkhgF0W/qSJXv1zdeNFfEuM/q+oBLb+BCP3x7Fc/08oI8uKp21341YuL2v3JIf3fRykfo58ZAUZZ2VY7W9a5WAWgV73EYM3NEQT0jVwJ9y/d808+1tump/gnDB1N4c1RmrrGZivdujYMH0yewVo7bKK6o6yF0l4C7m6oW1gSkg1j8YN3l6QYgAuURnIertcdBu7eEBpmZebu3DkErtbug4bw0c+P60v1SxCIOFXfZMuGm/mAbYR8ixsQGAbIzHPM7QfdN25PBghnByXyrjvviL+LsGG48HNkc0djRKyuyaacFzjfhl6KoCyxGcze51DMkGtANRVXdWva2TfcmYeLGcuRtE9Wl1a1ywhIVdwFGZQ0/SSWyR8alxkYGowTk1B3R9+EwPxMCpkys+t0tIIy7F6OSgOpApybJWQ2DbfPi2fd4T2Wn1yruynjW13rwdZKMZo+JZzqwqZcguM+1erO2zecEUkSYj7uD1RMr8YEUqbGw 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)(4744005)(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: sZ4ST7THrgkBvQniSEIL2y5QCnSNTDpb3sgZHK5IHLWtd0g2T/m0ZukZO3zOonKTXaJQqd/SZ2VLvtnwepyR1CekNLGEcXsbFZ3tmrrFO1YpWPsJH47bwv26eDPAhCm71H/u99tWKGtNtJRvcHorBPCJCmjmeylWB+MgCumHseoG7MXtHAoQ9hQ4XDjZmfa3TGJMRSEQeD0TREQjyv30iG4qgvN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W7aHMojvmSAl6gBmQZ10z0/zY1SNeZSvHBLSdY08iGNkNGNTAvfON1SvzW6a1/eLsmXS46Nn8JQuK6gvZys6IcWR/us1oZj8m54VWsmGtKjoLQ5QuscQrSTKRKp3kCRMP5FZb3jzyyUohokfuI8sCUXAQF022I/SlK1rR+wMZ80IgFS+sNMKPxdXrbSqEZ0jvAgJVFkwM8ay4b/qfrGr2aZ+FA2+S1v66tXNv+7ZJzE+fe8ZpITMJUD8P4IeWsIYXi2sztIrAYnzLZclYD6sc9ZrbEX2SlEl X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: a45cc70c-28ff-4074-0d59-08dbbb8e7a13 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.2789 (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: Dc02S0UAeHgMyXujw7H4nXHL6fZ7t3C5WvImyj8Xjy3hXOleDJ7IK6lBw5q/taXN X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV3PR12MB9188 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230922_100819_430084_0027D62A X-CRM114-Status: GOOD ( 10.20 ) 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 Trivially migrate to the ops->blocked_domain for the existing global static. Signed-off-by: Jason Gunthorpe Reviewed-by: Lu Baolu --- drivers/iommu/intel/iommu.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c index 0d0cb2534972a2..b79188d0c67e95 100644 --- a/drivers/iommu/intel/iommu.c +++ b/drivers/iommu/intel/iommu.c @@ -4041,8 +4041,6 @@ static struct iommu_domain *intel_iommu_domain_alloc(unsigned type) struct iommu_domain *domain; switch (type) { - case IOMMU_DOMAIN_BLOCKED: - return &blocking_domain; case IOMMU_DOMAIN_DMA: case IOMMU_DOMAIN_UNMANAGED: dmar_domain = alloc_domain(type); @@ -4803,6 +4801,7 @@ static void *intel_iommu_hw_info(struct device *dev, u32 *length, u32 *type) } const struct iommu_ops intel_iommu_ops = { + .blocked_domain = &blocking_domain, .capable = intel_iommu_capable, .hw_info = intel_iommu_hw_info, .domain_alloc = intel_iommu_domain_alloc, From patchwork Fri Sep 22 17:07:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 13396032 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 672E3CD4846 for ; Fri, 22 Sep 2023 17:08:58 +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=tCcFbTuurYNv/SqXcore3bjILfAheICNNwlatDwmuao=; b=QqDdKree6dGaW/ WphydfPGwJtGVXBWie/vdRJj8qJdDscor3B1c3u800J1R+LHxvu7KMR3+Z7y/Y3rrZ8bod4Ban5HH LPoA+twH5W+14J5TZh5bQ2WrBoQYz2Rj0HNqG1FIvHcqWsCGRBpn3Brsqo78jhspDAUJ1ViYaUYJk Ws2AalweZ0qLKZELqZDrHH8GCeF5KV3+m4ZbwQZpdBETHP8rFcVomq4Xdxe4yh06S0TTno4fh93AX z9+228WNZhfcAISgXhyqfXG8lYKvSL3dbncqL4hyd4fj7NtEutzFEJdE6wFsitQ4BnEesZK4EDyyK lUwt4SWM327D6d5MfVOw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qjjdr-009TP6-2G; Fri, 22 Sep 2023 17:08:35 +0000 Received: from mail-dm3nam02on2061f.outbound.protection.outlook.com ([2a01:111:f400:7e83::61f] helo=NAM02-DM3-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qjjdg-009TD0-2r for linux-arm-kernel@lists.infradead.org; Fri, 22 Sep 2023 17:08:26 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RWLyDMUIeFegoDjesUxNrqfNdj2jGkHWACIBfZNA6mn639ykjYRmN7Z2VvRqK32Fq2a7EGu4YNEq7NX68ZqxRKAG9VkgXoO1ndGkvoi5Q4UV9SEoSsH7kSyQtQywK4It8tcuYpBMMramixQxc/UCpUqGzQVn0qAfgPRJOwuPcQoxwDWtfQmMxXmS+Eh7v2rgj0Vnq7hbomsCe0p+UEBsnCxVw0MS6cd4s8AnjW15uxUqhR7ACRmAjqAuag/M+AqLMNrmLSKp71btpve1uSa0Ag2wkep/Q5lzJuVcl0Zilj+aBofLUEqgkW02BIWmO2I8+mAR7g7oCj4Mksdy6j6NJQ== 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=6f/F+3oX3DVdv7ukFG5Ga5zY2EAmoCSYx8EULKevBPs=; b=FWQJeMuZJzqN1DQI87tXeKXUEaWynubTXDMVospHIIXLrEvXehaLsv8ucb74zki/lM15rhlPkOjbSj3TTfy7rVxpDm3ZDufjaWNpCQHdrxGRYQnTgoDUmW+QFZmg5JlK/kB8y+7+1HM1Befg+B+UJCGUGp+1bnk0jtD4Pw/qRNo5Ro8RhHhFB8yRtO9R1RvsIee47PY33jFRn+LLXn5tZUEUTwcy21SSWse8eLdfVh+LFEC/vXqg8hGMZiyV/0fekgHmPkInD5enOcgisDEBWQGsKzjrLSsudGCFVxJJckFmzBKX5u8/VwnWRFuUFzOzsrEnNraxofEjBYV8pP6/SA== 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=6f/F+3oX3DVdv7ukFG5Ga5zY2EAmoCSYx8EULKevBPs=; b=nAUa3UtnId/+206QHbkfIoXoanJbF9vXiJCjw+4kjiouW7obdLqCV7Vz4vf1PqXd43CVCYQLwBZAneXaY9rPw25OpTixFJv9lyljh/oRzRKp49ShUX9db9hwj4K8xCPs2IlfEk/EcMFo+v3nkVJe82+P7CFvGPtKkhJDp38adWQ7yjMW14iNwugiFHGvnahGR1RSJr+y9cuhRU9hWsDBt4fOpVpLKXRwFkKl4VyWPmwb7K9jQTgBVXq+vvKbBFnR6aSb0evPgiB5Vb4mX/MZ+l8eMNuFUoiBlMDO9PEfb3d7OT0aFYVKKkZ9jKl0h5Gin6lzGjI5um58tPB6mPXOsg== 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:03 +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:03 +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 4/8] iommufd: Convert to alloc_domain_paging() Date: Fri, 22 Sep 2023 14:07:55 -0300 Message-ID: <4-v1-8060f06462cc+c0a39-dart_paging_jgg@nvidia.com> In-Reply-To: <0-v1-8060f06462cc+c0a39-dart_paging_jgg@nvidia.com> References: X-ClientProxiedBy: YQXP288CA0034.CANP288.PROD.OUTLOOK.COM (2603:10b6:c00:41::45) 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: 309ec585-3499-4ffc-4000-08dbbb8e7a6b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: QDr5g9LMUbokCpafY/IdOfkR1rDjdalo/JgjIgwGf+uBzg/BLPtHJn+fofdlIclLBxMqUAvHqRcitAXgjT4OJFNzuHf7bfRv7LH3CqM/g5L8oC0mKDIP38TUQspjB/RVdoiFsDYmh7HshKdgcVlFJqnFmBhSshImgy/3K1WdGPVuAUtiiQA7C178bKk5VR+wPzeoVWKIel8FgRbF+GEOX0dknEhwlhLsoe9icO9mOED6UmtQtW3X1lzCmiP1fIPcv2bFw1GKGSiFOCwf0o5S1DyIRR5iaTRjMg4mAadgyltqK4XT4YGblpT4TlV4RUSoycE9DZZ3QEdtgD0MH/uuaHtaUPvWRn+iwlNxSujgKjibO9shydG3wmqL9hoc6LzFvrYqgukCZiCf3YxxGneBYGCsNhI4mnntfxYa7znWp/Ac3gMoJwnGFIw8zhIC310Mhpwe//j+ejRPvF5w22VhFwV3ZWq8QAduF18Wk6+YcCX6G6Zj1+0TwiOur15EuLBwdpQm+3oQdRxrcLJ9BucXRymimRLx2rjL2T0LVOkYQcDnrWMR+exb5Ok9Nfy7NFn9QJOh8MwxRYmYwpI1g4Kl7HD7Ia6AaV4OfECCvXDfUsfQrD5O33HYV+fs7Pvf4FFp 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)(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: 3LV3Dc3Jx7kdR/d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IDkUEaUA4yc4JA95YM7VPI+QLoRCSdwka0mR+XjKIPgK+k2O2QxVyIkm5UG48dDkGXNN8Z3JWxbui7I3j628jVyVtRS80umx/QndA/3UAtRCmJmE4yGw5gwRa5DFRvZiCRYZu988YPQnJEDlrZDaJv5fsd+gkPulJq7IyS3iuqYQneZufGEtXyd0IkbgBKUuh0v3n/my64PQLVInsum/3kO2tUiRn41cPHwCzcqZxBKDtjDo2yc97XvlAo4INLPFdBWyN5roxLxyWZFWbyQQMoYE6BQQL5pjBtev3fa5ysgZQQDLUXq1gPg/WvxexCPzN77uURAOyug8AjYnOgwU9DV/+B4QOKdj3HVTcc8wcZfv9kOxgjWgAMJoHJM3NJmDKXyDHnHBXwR54OAGg0LRv7bflnhdzzL/4cTndqag3urYZL5iDEkov/Nm9uTdXmqm5lL950k5BjS8e/nDrz1+pSUWpO6W/6z6wWBO9Ze X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 309ec585-3499-4ffc-4000-08dbbb8e7a6b 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.8067 (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: 3wQlBrkEwVa3nRIR0D17LYlCQ66pkwEOENAPFGzD0S6eh1m+mdi5BGSrp/xE6+JZ X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV3PR12MB9188 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230922_100824_934415_2A932CE7 X-CRM114-Status: GOOD ( 10.87 ) 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 Move the global static blocked domain to the ops and convert the unmanaged domain to domain_alloc_paging. Signed-off-by: Jason Gunthorpe --- drivers/iommu/iommufd/selftest.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/drivers/iommu/iommufd/selftest.c b/drivers/iommu/iommufd/selftest.c index fb981ba97c4e87..ee607984709102 100644 --- a/drivers/iommu/iommufd/selftest.c +++ b/drivers/iommu/iommufd/selftest.c @@ -141,16 +141,10 @@ static void *mock_domain_hw_info(struct device *dev, u32 *length, u32 *type) return info; } -static struct iommu_domain *mock_domain_alloc(unsigned int iommu_domain_type) +static struct iommu_domain *mock_domain_alloc_paging(struct device *dev) { struct mock_iommu_domain *mock; - if (iommu_domain_type == IOMMU_DOMAIN_BLOCKED) - return &mock_blocking_domain; - - if (iommu_domain_type != IOMMU_DOMAIN_UNMANAGED) - return NULL; - mock = kzalloc(sizeof(*mock), GFP_KERNEL); if (!mock) return NULL; @@ -295,10 +289,11 @@ static const struct iommu_ops mock_ops = { * because it is zero. */ .default_domain = &mock_blocking_domain, + .blocked_domain = &mock_blocking_domain, .owner = THIS_MODULE, .pgsize_bitmap = MOCK_IO_PAGE_SIZE, .hw_info = mock_domain_hw_info, - .domain_alloc = mock_domain_alloc, + .domain_alloc_paging = mock_domain_alloc_paging, .capable = mock_domain_capable, .device_group = generic_device_group, .probe_device = mock_probe_device, From patchwork Fri Sep 22 17:07:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 13396040 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 9D39DCD4847 for ; Fri, 22 Sep 2023 17:09:39 +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=/F8jCSjKT43Np7b/5d4iSYQoCnIGRSdh00YMegFnjRI=; b=NjqwkpIbJSdlIz FVcF4R0nGGZr1R5FYlNYd6tiOvuJX6QKUbizT0qW8GdxFgUHjgspNyvUQCoyo410GvTKI+ieKvK0p rVI03g+H/+CIoUCQLEDJxGjMbMectNN7602EoJ3AzBK/CpSF+RC5lvOHJ0jwc5ZRRtcjxv7o1KR+v /dcNSlUz5YrI1dQ/oR94EhdLAxPnGpQOeVs6SAcM1RRpl8LKZEjqUdHx/k3Qqr8dQ94aeNEVtTRiF GUTL6JxZ4EI+rRrXwhwivlPmRcKw2poAS3xXvY6ef112XQc6hncAG1jKXdvr+DIyjLtTNkCO8hwsU 8wccZimVkGOgibfszrSA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qjjeS-009TlF-18; Fri, 22 Sep 2023 17:09:12 +0000 Received: from mail-dm3nam02on2061f.outbound.protection.outlook.com ([2a01:111:f400:7e83::61f] helo=NAM02-DM3-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qjjdl-009TD0-1N for linux-arm-kernel@lists.infradead.org; Fri, 22 Sep 2023 17:08:31 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FXw4UrV54rQefdkTyCaXNUD8PkKkYurrtOOTZzLn02ZejsWmvW/MWx4UkuRdHYQcUQyRHgwdZk5iQQ7mrnJjYrfLbXQrn1JnhUGf9QUN3kDK5d7Y9qb71WKElv/EiJk8CAS4J8Rj6UrOY84hzv6qgcAD7Xe0c0B9Y2Jl4K0U4QLPB+JGqVHJGSHmwrj5ZMPDKH5+vUU+GThZwdTlbATMXkEJSVZGPp8eOonHEsVnERXVTBhCTU3RusZLsdu5shEX8Wg3G2u7yu+JXKQYMphi7AfHqzhpQWV9qSx+azAwZB4j3oH4c1rsQKji2ngagw/Ob6drwOxd3/oE16/AZ83HWA== 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=a4ZdaRsPGgwgh2HKtFEuY/GTuZgb0awJTStWcwDEGYY=; b=iQg36kbZYjcGPoYQBiU8kn1KCW82bxTvEnrj/PjyiETsYY+BxE3O+KjQW8ql/wL16zQgy/j0G/A0Wvx3No5wAtx76LKUZ1m0g3Q3+g5u32u7cGgKwhzG9bY+g+DuxewfE7q39oFJxbVRJU5Mo7ABbqU219g4lX/Pbr9h3zPzpMFDq3eUpMF6EIzE2TJefacG7OfS/XNOIYZRswelyMEhOylea1UrlMVh9LokPx9rVc714vLUf1F5KH7eVLAsYfkBslRj0iv3UlTHs1slBdwB8BrkanYWyj3+oopJQVHQYuuVSm1lw8Qp95FiwgiJTSx3cKTfm4V9Vihi6sFQ6fuNjw== 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=a4ZdaRsPGgwgh2HKtFEuY/GTuZgb0awJTStWcwDEGYY=; b=Si8UtGWUCLmVYhVn4UGnuYJ3g7WKBuFTDL9vlAezeKalRrR7mn71WfEnx7H4jgJsJAK9tOtDHIM6JswAddQ3FTr+96ZgG/s3f1KQPIhlZ7dCzfhtz00x22xvA3sMvUv9qR1noT3MU9cdYhT9E35oyMSOy6BbftmLfEQahQFNQ/2lIyNiouqT3S2Pr/VyxIetLc010XQSzYARTow8KFa2mETuxo0x47l5vVKPaj4xBqeXli2F7Wy+FJp4IjQeg830wXA5O6uT1HFER/VuzbIugKgk7+zVwTumv+hSTbJQ0x4IlXGFXEZSEnoJbxGZWsdyv66bUR8f4deJH1h3cv02FQ== 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:04 +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:04 +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 5/8] iommu/dart: Use static global identity domains Date: Fri, 22 Sep 2023 14:07:56 -0300 Message-ID: <5-v1-8060f06462cc+c0a39-dart_paging_jgg@nvidia.com> In-Reply-To: <0-v1-8060f06462cc+c0a39-dart_paging_jgg@nvidia.com> References: X-ClientProxiedBy: YQXP288CA0019.CANP288.PROD.OUTLOOK.COM (2603:10b6:c00:41::47) 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: 5eccccf6-3a9e-4bb1-ab8c-08dbbb8e7baa X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: HoIbyQ6U3GQJduuSEEn/XMeKPRiAlQyIuUbshr6cQLKcuLpiVi6f+5nDBiepDMONSQxs5kIwspOMfNJGgJG3JmUu5/S2aB34mtVmOMDD2IMk2L+BJxFt+FDxg8etUf1apORnpu3Ja/0qgYyFwBbhGPm+utp+hPgWM/WzT0qABxFcfy2SKMNn5+/GS3VOT7EZ+lXw9CMcKmtZ02BPLs3lfnP3oqK6bJXSrXXfigkF1r2YKH/2f/Eb10ObAwnBe6TJKyNzhj3B4B7VVLrW1B31sSwE2E6I0heerv4atkpbTzCkKXT9Y4BjiFriSN0ERjJS8aYltTA5cDMlSRTatz+a9Ex8pxxUwVvGwiihjag64yypcpcxnFGNNPTl7fiITuBPRx2HCBRz8dDXdIf17YiVUzoe7CmslfFduBvotaGVpfXVGOoSa8FsjW7HaF8JgAfu7N3QJfBCiMWTAImUqkSEf3FIm/wTa7smt/CyvxCQAuEtcTIPgMbfjIf27PIvsKWWtNInz5e0GiI18Z4M3vD2O3fZzAXfURA32I6QjFshPt7OK4pXtupXNQhi0PeWc5BiGTPx3Jt2qW/m1n2NsxmTnb7JAKB5alQrp4oOyoohZYO0+iB7I/6YhF9tn3q6X5FE 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)(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: V/NRHgchph4I5eX2lOcb9YvC5WtKyDZjBb9f6qO/kJ4I6W6RxnWSKCuIlI/CSHb9+N+rq9gpXyPuZhuxk9VjqDsgW5Rz7qi2aMhJ7NCOjaiEcdLotetXZ1Qb2nvADOLhWUEaNo1fEtItK8GBziW6ODgmDzJs55uwrB35yNyDsKAnmUcn1fGOtjSMcHpjzteZuoxGje9hKk+4OLm74UaMu9HS6JVGCaPaLELieNz47ahfTf6GtoKiZ+Rvl0TAwFUiLb+uR94jQpdCv9to9hnwCLag1njV+vVWn+MUEe5kvjAVrOWzGsuVtiFqTNBNvejh/O1gtKOxZNYReS8Qc9KToltBjIlqatr+SDHs1vCtVqQLzIWr5V0RQrzqb/mJ5I4pXNp2lGjVDvf7wHKjAZGOguzExidCV9TyoCdFaW3QVWytd1m8R/zJnaB3XjEDzz3CFwLWipKP9568xTRgbZXHjyZiI5ps6h2RIxKCszLhnxrUKbCvNwp3PqHB4xEFdlHA5uHhWaBdo8HjV6TaD3AGNm/oIC+Z+oMb2czCUXbXhN6ZRlzZ/aOqgvy8Qu9o1V22Zj9A3qaeX/qFFLoKeZ76xc6OblDSMFyhT6CJaZT7hD0KCuiBpiya7W+GkTysbGblz2tpzGOLwv8MzWHzTPftBGdFIyMngtSThvqfGpzrU5nT+kunsfeofnUFmeM6QWYfguVsW6WtoGS4gkE2v/tuR2rGidbzks2EjLxx2mtB/p4R+BBj+AOzxfy9kQa1r0ydZ1uexKiOnbX9UMFqc83jn2bL6qDNusuTVHU78YjVkLOLCRv45mLnJpE3zrry/j6AVSyXheKBHtDJQOj+avC0JMw9oRZL6WzLHjiyCCImvGS/uRclGkx+l9c5twFw4Z+v6Tdhsozo+WDJtZOTK0rCac+HNBA0xv1vsSvBtoXcA7GlqVj3b9RciCrIfUEIp421ToAgOnCcFvbQ/2lgHn7XSyUThg5klcGDXeHRizlmd4Ptq9OhZSIcQ5LXKE82P0HK+c/5xcBISGZBMBCZqLoXXrHFImXnOl5cj8+Ttos2U6DeHTJuKUJ+dt2WtLKC8AxapfLBP5poqIfO+td5DjyhZwUu9h705SBGRJRjT9FnkeAAqp3+GCzFncZxaTAOxJws7nYg/E+vBLQcxRBQFdcUtZjf5wTseCWzVmC5jgi+DWf7uqYu58ocnHmJtx7LcEie9vAzbzaN6fymcXcwcgNyW7oiYQbW9RAn5GvyIIelp0QA2N7C3nI7lp9q5j5sZCiE7PmJBO79xMgYRlZRHm9U96pDI2r7LrdJ12PAeo0b+JCO8xjHis0tvqLlkduzqJK9lObt+PDjt8WiySeRIDkTCrah3xLMpCk4zCIgmIfCryjN/RwshWfIUqaErvyonbzyiNYjQJ1aLIBwTm1gJ9IWMP8Qe6hQI+iMZ3s/bgXmSByIB1rorstpKX2BmSeZ9vsXQFZDr1u2UncoNRDvedvErhvX/j+bLBslixfh+qUkm03200BBFzgRMKfNgD1PAcosAXHCzsK9MsScymzxoC0lIX9/5Li3pGuNMkk09A7JxE6HPY7DwZ2kT5+oluU4tTqQ X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5eccccf6-3a9e-4bb1-ab8c-08dbbb8e7baa 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:03.9242 (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: LMR/nyVOdMtFE8gvsGdYdqYnE9Ny4r4pBuIUIjshci0MNMdHGNqD7/+L3boxFpZZ X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV3PR12MB9188 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230922_100829_483380_9D3652D6 X-CRM114-Status: GOOD ( 14.65 ) 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 Move to the new static global for identity domains. Move the identity specific code to apple_dart_attach_dev_identity(). Signed-off-by: Jason Gunthorpe Reviewed-by: Janne Grunau --- drivers/iommu/apple-dart.c | 41 ++++++++++++++++++++++++++++---------- 1 file changed, 30 insertions(+), 11 deletions(-) diff --git a/drivers/iommu/apple-dart.c b/drivers/iommu/apple-dart.c index 6bc2ad2207c3da..424f779ccc34df 100644 --- a/drivers/iommu/apple-dart.c +++ b/drivers/iommu/apple-dart.c @@ -658,11 +658,7 @@ static int apple_dart_attach_dev(struct iommu_domain *domain, struct apple_dart_master_cfg *cfg = dev_iommu_priv_get(dev); struct apple_dart_domain *dart_domain = to_dart_domain(domain); - if (cfg->stream_maps[0].dart->force_bypass && - domain->type != IOMMU_DOMAIN_IDENTITY) - return -EINVAL; - if (!cfg->stream_maps[0].dart->supports_bypass && - domain->type == IOMMU_DOMAIN_IDENTITY) + if (cfg->stream_maps[0].dart->force_bypass) return -EINVAL; ret = apple_dart_finalize_domain(domain, cfg); @@ -683,15 +679,37 @@ static int apple_dart_attach_dev(struct iommu_domain *domain, for_each_stream_map(i, cfg, stream_map) apple_dart_hw_disable_dma(stream_map); break; - case IOMMU_DOMAIN_IDENTITY: - for_each_stream_map(i, cfg, stream_map) - apple_dart_hw_enable_bypass(stream_map); - break; + default: + return -EINVAL; } return ret; } +static int apple_dart_attach_dev_identity(struct iommu_domain *domain, + struct device *dev) +{ + struct apple_dart_master_cfg *cfg = dev_iommu_priv_get(dev); + struct apple_dart_stream_map *stream_map; + int i; + + if (!cfg->stream_maps[0].dart->supports_bypass) + return -EINVAL; + + for_each_stream_map(i, cfg, stream_map) + apple_dart_hw_enable_bypass(stream_map); + return 0; +} + +static const struct iommu_domain_ops apple_dart_identity_ops = { + .attach_dev = apple_dart_attach_dev_identity, +}; + +static struct iommu_domain apple_dart_identity_domain = { + .type = IOMMU_DOMAIN_IDENTITY, + .ops = &apple_dart_identity_ops, +}; + static struct iommu_device *apple_dart_probe_device(struct device *dev) { struct apple_dart_master_cfg *cfg = dev_iommu_priv_get(dev); @@ -722,7 +740,7 @@ static struct iommu_domain *apple_dart_domain_alloc(unsigned int type) struct apple_dart_domain *dart_domain; if (type != IOMMU_DOMAIN_DMA && type != IOMMU_DOMAIN_UNMANAGED && - type != IOMMU_DOMAIN_IDENTITY && type != IOMMU_DOMAIN_BLOCKED) + type != IOMMU_DOMAIN_BLOCKED) return NULL; dart_domain = kzalloc(sizeof(*dart_domain), GFP_KERNEL); @@ -732,7 +750,7 @@ static struct iommu_domain *apple_dart_domain_alloc(unsigned int type) mutex_init(&dart_domain->init_lock); /* no need to allocate pgtbl_ops or do any other finalization steps */ - if (type == IOMMU_DOMAIN_IDENTITY || type == IOMMU_DOMAIN_BLOCKED) + if (type == IOMMU_DOMAIN_BLOCKED) dart_domain->finalized = true; return &dart_domain->domain; @@ -947,6 +965,7 @@ static void apple_dart_get_resv_regions(struct device *dev, } static const struct iommu_ops apple_dart_iommu_ops = { + .identity_domain = &apple_dart_identity_domain, .domain_alloc = apple_dart_domain_alloc, .probe_device = apple_dart_probe_device, .release_device = apple_dart_release_device, From patchwork Fri Sep 22 17:07:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 13396033 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 07556CD4847 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=0TwoqM7Ag/r2DYCYsfETVXyPNHWpjfbUODvlMNcIgRk=; b=ITzkXV9pfeW4aY M/qJo59wYGwxA9d8sGv/N4FSifgf5fVtdzvubYYI/wgbXX1bIm/QpS/fB1AGickXdgvHlESXwdSTf 4RQ/yQVgtc5cmPuKkjJyAAI4ixCIN26D92vBJtHc8LXJ28DLUr/32c/A60+Ys/LQ+PL78CyFVVgIF yHyEMzTu/xgZbqe2DpeC1U7DRNAJwxMDIFseXvXtb8/Js5MMaGw8hmfziPndLzo65+zZjf+kDi3CZ FwOZgjOPm7M4yK0n8Y8Bf05pqUT5yr276Lj6fZtc2VhyBfo31PSf73W+/jQfFjKECeN4wGLYbOOhP WruxrJeBLsfUOnM1LwHA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qjjds-009TPq-2U; Fri, 22 Sep 2023 17:08:36 +0000 Received: from mail-dm3nam02on2061f.outbound.protection.outlook.com ([2a01:111:f400:7e83::61f] helo=NAM02-DM3-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qjjdj-009TD0-08 for linux-arm-kernel@lists.infradead.org; Fri, 22 Sep 2023 17:08:29 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jZtx3aur0cggV6hDgM2wVNSGO4cUxz5d5+8g83HkRwslxeGtpUUYO3lJFP7SkDoAtM9Lf3qmT2GczFr33Dmo4IcSwu+OAJEM4m8Mxi9C6teOKJWoeq+SQNhPIBIPwGO8JSH94gRZOWjPX+0F993yWFcDk/m3p5hQI2KP7EgVusz/VYxmGMmsmdMpG6x/R8vgyY2ylwUKxewUtoyaiGh+xQgKjVbem0k48vHHedizgjbddZeVN3Re+hTGikxf5VLABDbJ/VMBEmNzivOIZqun2eJ8ntAtKFSCMe3xuAOpa6Vmb5rq/XjptOmpQaXlPRfgbOSo5xVcJQ9u/DqFz94rrg== 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=v4DsCX1rU4U3aGM0/1fQpNOzPmGEM4a2jCpb6axFjkg=; b=RG2BGA7rI1YGIBFKfzqHVNvXXpIkCy7zB+oZgnx+nvI0y3DsA0/j9O3Nu1GNGl7GdQxEQcsKZahy7Wldgn/iGyMZNbld2P2R7iI7uzRvSpvohZQ04fvifAhAJg5EAUnfTSj39Qt/6qTBh/DZJYuxm0dk3m9ufmyE1XcpGrgzcJqaPSs+i/mFdne7uqxzYX/ER2E4zFyVstLjlBqnn6EnvRQkqSBipYhg45EKaWokzbJiQG48/8dlkEeHojImDMTT367C5Pz09c4QbzV+9HEAyFUmjYcMPUg8HBXLDTNo8w3QzqF4oc78A4s/lLqEQHH03zgvnZAZd+6OQscPwJD34w== 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=v4DsCX1rU4U3aGM0/1fQpNOzPmGEM4a2jCpb6axFjkg=; b=b/it0RRK9qhQd2vAAgJBUGPUdIq1vqAK7HfGGvuaILrXKwvBx0bFCZ5glgdd7IlpljzkWwGXDagmRFOmynPM+n49wV7EvGkaXJmdLXxT6DbtuPgKaC19oF6pH58t9z9D+gLPbrnV0DH/WXZ8KnguMDNHk9Nec9QGmvmEDDevjQGFk0YeMsXC5NNiBo6wBUf9SgU8mdgF9f7UfVnuKTde1YKu4O5i2HUHilfo5Y/DIvyXMNXAJCROSnhA9NyzSjo4ctSq5tNoFbxR35m+oUzoRREV4pKLAf3twiMNCW8t/xth8x/CqH3f+qkETbIL7igBje9pud+cs2CP9Gk1D0FO6Q== 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:03 +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:03 +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 6/8] iommu/dart: Move the blocked domain support to a global static Date: Fri, 22 Sep 2023 14:07:57 -0300 Message-ID: <6-v1-8060f06462cc+c0a39-dart_paging_jgg@nvidia.com> In-Reply-To: <0-v1-8060f06462cc+c0a39-dart_paging_jgg@nvidia.com> References: X-ClientProxiedBy: YQBPR01CA0069.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:c01:2::41) 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: bcdcb14b-fc2e-43c8-165e-08dbbb8e7a83 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Y+lcqJ0ZQ6z+Ykf4WCEQBvaRGn8MDKUf93vh69gUz3WBcVaPWmbOiI0TNqJhbfp6Ovq9EyvNgjfT7Nd1gy/U0y0Yn/T7VTLbLk8VL1yQGUejw6ULHfp+boU1WlK23O+CjFGbtSrMsd86XMLiG0kA0g8wgGecaCN8d52fBZkr+VvvomO39dROpwTxouU1fsvsxoEGScXq2KNrsa/AGtV8jsQj4xOFSMtJbk0tG31vqIER0pQ1A/2O+jv96XBXhabw0GLL0rZZkBdp7BGE/YLsP7kEWrhkjyEXRGJIvG0b/QXk3/UW1joAAO2aE2ZjjkqBg/GOy3/95HZfIbViRZblPmiF6l5+RNHYqNkJq0hFtrJOYtgzQAFZufRMHLmlX2wpYwyqAv7eQVUxJScic5H+ClhFlYpD4A76+b/79j+DzEbu/p6sxRAN6tw7WHe685KTkpJYpg4SnXvXiQzJxWKRTZby/Kc+UEav/tgdrfvnE7yE8gdj0OsffizfP+2Ua5enh2lGKeNKTOE4cFQvFWYQWLWCfhkJDIhv91X9V4x1+04spUvXO/zqnCsZbEVM2R8kG2uAb3ytW39FMa0tUqs3SpcVNZ3MsITuvDLz/PyuBeXzZlA8SMQRFpjNYZGdiZcA 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: c+IXxHSrsjIkhxq3AABijW7mH0une5z4vu9Tp7m1B0WjGflw7mr9TTrUWidrpsOPOgdImX4cumFxvxYfA54qf3Hlum5CECP8EQGRnsvTURmKCXxt/VGhDrpE+L8ojWN+2Q2vt6sk0cjfTnbY9GtlnI9bzuYNYocillr/e3TpqkDE9Yalwl9NHjY4QJ9fAKDn+ON0xKIV8L3oSkbk8LclHZ/Y/J2+IWwnhCBlJrbBOj82jXjzmNVNvtn3APn6axr+TS2iqdeQwqfzno6G7d+b8FiRLdRNzRWohLHmM2Ldx5ay155uDxFBLjKvMT6P/etCAkvp3YnR+zyX7Yt8VXeQeO7dq2XT0eX25jyPKcLIwnjMKSxGwLtV17kTe+z0ezeDx9ih+L/medCdfwuv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clPvC0p+vlyLizhsXwjOMAulbz+6QBKOvfmdM/ZxyrV3tGVSaM47IMlnjuGopwGduFpoQVbH4tOcUXr008iRmRT5XAooBMmJOpat6htEejEXjW2JC0JZ/1/D5P9kU X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: bcdcb14b-fc2e-43c8-165e-08dbbb8e7a83 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:02.0163 (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: ULXqMQOWDnW+Ke5GW4hIpfnz/ONZG0YvUWMUWTzPtS9MKj1IhNkdR7zGNLFVO6kG X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV3PR12MB9188 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230922_100827_094634_256CE42C X-CRM114-Status: GOOD ( 14.44 ) 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 Move to the new static global for blocked domains. Move the blocked specific code to apple_dart_attach_dev_blocked(). Signed-off-by: Jason Gunthorpe Reviewed-by: Janne Grunau --- drivers/iommu/apple-dart.c | 36 ++++++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/drivers/iommu/apple-dart.c b/drivers/iommu/apple-dart.c index 424f779ccc34df..376f4c5461e8f7 100644 --- a/drivers/iommu/apple-dart.c +++ b/drivers/iommu/apple-dart.c @@ -675,10 +675,6 @@ static int apple_dart_attach_dev(struct iommu_domain *domain, for_each_stream_map(i, cfg, stream_map) apple_dart_setup_translation(dart_domain, stream_map); break; - case IOMMU_DOMAIN_BLOCKED: - for_each_stream_map(i, cfg, stream_map) - apple_dart_hw_disable_dma(stream_map); - break; default: return -EINVAL; } @@ -710,6 +706,30 @@ static struct iommu_domain apple_dart_identity_domain = { .ops = &apple_dart_identity_ops, }; +static int apple_dart_attach_dev_blocked(struct iommu_domain *domain, + struct device *dev) +{ + struct apple_dart_master_cfg *cfg = dev_iommu_priv_get(dev); + struct apple_dart_stream_map *stream_map; + int i; + + if (cfg->stream_maps[0].dart->force_bypass) + return -EINVAL; + + for_each_stream_map(i, cfg, stream_map) + apple_dart_hw_disable_dma(stream_map); + return 0; +} + +static const struct iommu_domain_ops apple_dart_blocked_ops = { + .attach_dev = apple_dart_attach_dev_blocked, +}; + +static struct iommu_domain apple_dart_blocked_domain = { + .type = IOMMU_DOMAIN_BLOCKED, + .ops = &apple_dart_blocked_ops, +}; + static struct iommu_device *apple_dart_probe_device(struct device *dev) { struct apple_dart_master_cfg *cfg = dev_iommu_priv_get(dev); @@ -739,8 +759,7 @@ static struct iommu_domain *apple_dart_domain_alloc(unsigned int type) { struct apple_dart_domain *dart_domain; - if (type != IOMMU_DOMAIN_DMA && type != IOMMU_DOMAIN_UNMANAGED && - type != IOMMU_DOMAIN_BLOCKED) + if (type != IOMMU_DOMAIN_DMA && type != IOMMU_DOMAIN_UNMANAGED) return NULL; dart_domain = kzalloc(sizeof(*dart_domain), GFP_KERNEL); @@ -749,10 +768,6 @@ static struct iommu_domain *apple_dart_domain_alloc(unsigned int type) mutex_init(&dart_domain->init_lock); - /* no need to allocate pgtbl_ops or do any other finalization steps */ - if (type == IOMMU_DOMAIN_BLOCKED) - dart_domain->finalized = true; - return &dart_domain->domain; } @@ -966,6 +981,7 @@ static void apple_dart_get_resv_regions(struct device *dev, static const struct iommu_ops apple_dart_iommu_ops = { .identity_domain = &apple_dart_identity_domain, + .blocked_domain = &apple_dart_blocked_domain, .domain_alloc = apple_dart_domain_alloc, .probe_device = apple_dart_probe_device, .release_device = apple_dart_release_device, From patchwork Fri Sep 22 17:07:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 13396036 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 97387CD4848 for ; Fri, 22 Sep 2023 17:09:04 +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=u5p7zWz7bB7l2xJKa5xNkU94FVssuW3W+t0lcTTkWP8=; b=Fqz74X50XOUR3G KQ4mSzBuzKBo9cbTzUGd8hgA7w3GSPN/jPbA2SBaO7uxzBl1m+0UgltHkSovQQumQ/B7t6HMFzS8M AOI/PIGn0O2WvRhbgtSp9q1np5dyg9JdS+9cEMc5tXriY4QWng7muf9ifT3xnw1aIwjrPgCSf0N+1 7mjrjkiKNGLIgv1EpXKVSQyleKB/ohe1FP5EQezIqGptVo2x+g+NUmgFZG1ZLFIynNAskmTJFD46p 42U/eSVuvz9OWez/Momv7VZFwy+Vxp+2YfFMxgWxMXkrtb8pVOj/EhwXncp2QCN+Hvv6tbZ8wdyrk asnkAsvOUDdl8Die7u3A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qjjdt-009TQI-1D; Fri, 22 Sep 2023 17:08:37 +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 1qjjdj-009TDY-1D for linux-arm-kernel@lists.infradead.org; Fri, 22 Sep 2023 17:08:29 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=a2qZiDns02octH0Spr9yuaiwACb1gWS+4QbrF2MC1Lf/ruDb5isirret0rWAtHzVUJoC9EFLgkH9j5IlgYIeviLyD47bUSJXNx6jjXOOBRriaG21gbQywfEneSJAbeDXNhygSkJWk1xAlf04kPc2ZTUeS24PNKnpcyvx0il7fq6AqzN+1t/6ok/5NB1hTp0nNcTCop20V27aipv/ayKl9U3iG3EL2U0zLYnAgO3MVSfahVv2ZZhRAsP2Q4T0Jg5D48whOoRObwERDUC/GL3mRkrNzTRCYnX6VlaqTeD2VNT0tgPz9QkaDkC4+H3yB31LQ/WmhDlf3gbZZxRDhDDFcQ== 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=enyqSTvj8qiCy5Tg3zCgMrVyFhU/zF51YcFj4ztQ8Ig=; b=OoMA64h3zQlvG32BvxYpbQclIOhUGkH6nmwl4EwV6USgRW9s0gvTPaTVt7+vNusfQKN8tVg23SPYrMYTywrD/7hR7TpH0rXpwnyKnastnVdYlOIXm71u5y5AyxKBih0xiv5jTxEkvGLC7OZPRaTLMf/AOHzw4YU3NeQjPQD+Xer93Bc6iCg2sjqDM+z1Oks14kh4T7PSppzfh/0CMRu0o6QBSd9JoVG8F2X/3WhlyZ0UGhYtKI1j2QlPuMf98XIgh92olqQNQSMnRhqFbtaxfqeDSzLL8v0umkZ0xat4EiEaH73tDxrlVgi0HpsFYN5nU2LZmL/aeiPodbTq4n3HEA== 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=enyqSTvj8qiCy5Tg3zCgMrVyFhU/zF51YcFj4ztQ8Ig=; b=l7cMGijzPMrw3OuVzkfvr+efOOSUnir92oIzAGoW7kJNNHZ8OP0cVFWhV5DxzyL4ASPlKhU6GlG8AIo2Ixgpq3o4gV8OHA5l+yQUmqbucUGRv57BsTK0rdQff9xY+5OaOYrBg6xlOCsuGCBagS4lX91d1eCejoHfoFX4a+ZQf/zEeKuoDPdU+toejdd/AeRn0SlcGqChQO+HawXMbd5f8o+qbFOhBGUglVcBdhvA5BiwqTWDWYA2DpfgZIODZ8o8RuoIQqqc3uSqh+6UzeQZKqffP/jP7eunFH7Co4M0XHQdrm+OCcAVXUnKnl6k16w+znad3vDPp9/6F6JXltJPDg== 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:03 +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:03 +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 7/8] iommu/dart: Convert to domain_alloc_paging() Date: Fri, 22 Sep 2023 14:07:58 -0300 Message-ID: <7-v1-8060f06462cc+c0a39-dart_paging_jgg@nvidia.com> In-Reply-To: <0-v1-8060f06462cc+c0a39-dart_paging_jgg@nvidia.com> References: X-ClientProxiedBy: YQBPR0101CA0113.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:c01:5::16) 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: 64b04e29-b690-42a8-84e0-08dbbb8e7ba3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: CypL4qnjrQzbuGvY7Fq7X96Uvrj76oaI+NknA+fvdkmpZz02OCxQuFwz8NDKbQP7QMyXJOY7FxZ7b68PSD/HYFBiH4yOTXwizdq9HBb9qb4apNjF3sD36G5ZVoAb79HEBD2HsHSZGzdidHx6Tj6mKtAyhIvEb8IpLJr+6W6UQrU4iw6I9cW8mOBRBph3R53GkMjFq0VXcSFUs40iCKFJlenUpce6dg2Mpa/AD7u8qM9F9OG1BjTzXuRy5p9yF1QUk8bvO0yoxDqroRnb8rovP9niVLqToZcPKLFq8dCDxpsesG0IFu2KVTGkLL0xiLwnHA8Yazqh9eBUFbc54CRf736lvOnogeZ6xgXE4SZw264Ggm703oB81WUt1q2xKl1pe8K5gdyUA4FVMLuQ27RfTTUGADIk0nJQtqAyt7CW2MhYUJ3bGzk7SY+Yl1v390Mekf8n7ZOmgUkuo99A4wJFTyHLotf0j4vvYL1oxjiun8SyVfCIyYKMl2q6dBRz4rR4or2DIWiXigYr4CVAYyTsO2wKQ1kt0hisX3KAX6q7qZZhI1CPcfsXq5D5i2DPTSwZY2orXgA2eyqOvKH07DZw7+bNe5/OyXeW3vvz3QoXsn5ujyz8TjquDGCyszKf1D/U 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)(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: eRyJdlPJMyFXKNzQU3gfbZ/WXONQYN1DjTRSOZ3ZzWEo39hqSjskseMo60KZKjF7LmvSX7TP1NXOzQH6lzyRdyvXTTwgyc2/OrQxJATRXoSb5u1iHsk7z3kpaxSGppnkqjiVTrxCfxVx+uyaoPWbwl3vE98M5i5xzZHHFXytDgO5oBngrW+bQeH6wbLhPwt7foGRYQmQGvfRTn2Wh6BTzyROpuaY+jdOu7qgkK0oAkBP32XxGPy2RHZoYa99T00f3XzmiAjvHAMjIHBamF5RFv5VaYf3L5Kbm/vDtLW1FISdXYNzrdpXTAtRHLOUh6g/VvfkBGuSK/Qt+0wHlLyh0jtCaOCUA394I7qeg3w6QU9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AAauzfZ4QoMejX6BhC+MyrcLyOz0NxmQDwo5fACmcM1lb4hT7NpKhGakF8v3E8Tet0YGigCQWJf23QUZVEaY99tai+86abBI7rYieC1LeDBfMjCLPtQVR1+WmYKsjr5gFtxa48MZ7sVwNXsqFxB/1ynshwdXM2ZDmRqLrs X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 64b04e29-b690-42a8-84e0-08dbbb8e7ba3 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:03.8390 (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: bKUROoSuEGW5IblbzsCPG2oTN8jla4P7XZNq5umwOEOk/sucuz1EMXo6JiqmHVVv X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV3PR12MB9188 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230922_100827_429871_7B0293EF X-CRM114-Status: GOOD ( 13.16 ) 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 Since the IDENTITY and BLOCKED behaviors were moved to global statics all that remains is the paging domain. Rename to apple_dart_attach_dev_paging() and remove the left over cruft. Signed-off-by: Jason Gunthorpe Reviewed-by: Janne Grunau --- drivers/iommu/apple-dart.c | 33 +++++++++++---------------------- 1 file changed, 11 insertions(+), 22 deletions(-) diff --git a/drivers/iommu/apple-dart.c b/drivers/iommu/apple-dart.c index 376f4c5461e8f7..62efe0aa056f60 100644 --- a/drivers/iommu/apple-dart.c +++ b/drivers/iommu/apple-dart.c @@ -650,8 +650,8 @@ static int apple_dart_domain_add_streams(struct apple_dart_domain *domain, true); } -static int apple_dart_attach_dev(struct iommu_domain *domain, - struct device *dev) +static int apple_dart_attach_dev_paging(struct iommu_domain *domain, + struct device *dev) { int ret, i; struct apple_dart_stream_map *stream_map; @@ -665,21 +665,13 @@ static int apple_dart_attach_dev(struct iommu_domain *domain, if (ret) return ret; - switch (domain->type) { - case IOMMU_DOMAIN_DMA: - case IOMMU_DOMAIN_UNMANAGED: - ret = apple_dart_domain_add_streams(dart_domain, cfg); - if (ret) - return ret; + ret = apple_dart_domain_add_streams(dart_domain, cfg); + if (ret) + return ret; - for_each_stream_map(i, cfg, stream_map) - apple_dart_setup_translation(dart_domain, stream_map); - break; - default: - return -EINVAL; - } - - return ret; + for_each_stream_map(i, cfg, stream_map) + apple_dart_setup_translation(dart_domain, stream_map); + return 0; } static int apple_dart_attach_dev_identity(struct iommu_domain *domain, @@ -755,13 +747,10 @@ static void apple_dart_release_device(struct device *dev) kfree(cfg); } -static struct iommu_domain *apple_dart_domain_alloc(unsigned int type) +static struct iommu_domain *apple_dart_domain_alloc_paging(struct device *dev) { struct apple_dart_domain *dart_domain; - if (type != IOMMU_DOMAIN_DMA && type != IOMMU_DOMAIN_UNMANAGED) - return NULL; - dart_domain = kzalloc(sizeof(*dart_domain), GFP_KERNEL); if (!dart_domain) return NULL; @@ -982,7 +971,7 @@ static void apple_dart_get_resv_regions(struct device *dev, static const struct iommu_ops apple_dart_iommu_ops = { .identity_domain = &apple_dart_identity_domain, .blocked_domain = &apple_dart_blocked_domain, - .domain_alloc = apple_dart_domain_alloc, + .domain_alloc_paging = apple_dart_domain_alloc_paging, .probe_device = apple_dart_probe_device, .release_device = apple_dart_release_device, .device_group = apple_dart_device_group, @@ -992,7 +981,7 @@ static const struct iommu_ops apple_dart_iommu_ops = { .pgsize_bitmap = -1UL, /* Restricted during dart probe */ .owner = THIS_MODULE, .default_domain_ops = &(const struct iommu_domain_ops) { - .attach_dev = apple_dart_attach_dev, + .attach_dev = apple_dart_attach_dev_paging, .map_pages = apple_dart_map_pages, .unmap_pages = apple_dart_unmap_pages, .flush_iotlb_all = apple_dart_flush_iotlb_all, From patchwork Fri Sep 22 17:07:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 13396035 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 899AECD4847 for ; Fri, 22 Sep 2023 17:09:03 +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=pnR5GJjsw8tnFji7nZUmhT6fRTB4HbVz9zuYz54lon4=; b=ReSJDSPNKurEvN rEvfxaLhZ8q6n8psOgq3b/kiZNVUFB7k8R5RifsqvLrGKiDjz/hBjQze6vvc+9XBadDVL3MfMVWuW pV6wd2rolWIx7HuhTngQjqniYeRbgE5H+ZGWZR2QzxdLCEsWpyvQEIcr2a/g7+Wef+G7x3v3R7nBe dRZ4jxmSwuIQiMmsM9BMMqJbJf7d9JS8eP27TucqmRb1muoHAskhAajDeCM5DEdUKmD2r6dsKsnse IroHhLRYFpcddg4zIWxOPK3PhvdnncqRkAJiWIZmK+UP3kR+2uQgpDVOGLHsOly+4sHgTMJGydI3f X6v3R5gf3cybj+77oCkA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qjjds-009TPV-0o; Fri, 22 Sep 2023 17:08:36 +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 1qjjdh-009TDY-18 for linux-arm-kernel@lists.infradead.org; Fri, 22 Sep 2023 17:08:27 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WExkSUM56iaoSaj9otrqhkDNs8g9C0Sw0iHU8EC+EeoF8vlo44GRd7oissm4k1MbMfTgnDDTKJnFeDUP601sRSGgtXBrzRZjghcOuyVCPfKDpVHEkt2iuEeHHfH8aWeKWYqinOb5xW+eFw88LbgLjI06MmNu2bSFcnR0SXgDRlnZrAVR+PMAAzBROy1qAvyLfLrzBFldrDXqSjZ1mVVL1CXeTl3KbfvQiquq1Zb5+4CY4FgfIjMMXNdm8v4cHGBo7KRmX6eS4Aip6q3aPRsWNvjvyAWiSo072O6NTKZpZYEE5M9NJp3mcIJvbSIPskZvE6d92gGEbc8sKa6sR+FQaA== 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=Jr/5KfPoaUuyX/C6S7jT78l1e3DHs14ebOVrB52vXx4=; b=f2mxAvXwssVJRiCv2koBj20fGt8HkEmQDDKWvJsxqZWvDii8+sJqZ9ILUuK2yd+elh/7E3DbNAA1REEUz2hc21mXNkZ9ZB53IhticDY+t0O+PalUKhXpfhos8Y7eHgPi2kKoEFVciQKN9ej55XXCMeiXihPz1Lx+z7EBbe9Dk0LvEm7XBmQ2OTFD/DaAXu2ox12vzxXrc5UVKLp8h6yMZIr8Zb8B5TlmHO37t25FBiuvAHCG8a8vOiv84+XRArR5NCb5j8XnBLAdhExrMfUYaiZW28v4rWdUvG7tGb+yRBSq9WzTsr5xhWL4HWC6eMTLvm/CwYXWWIhGNv+quGuYwg== 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=Jr/5KfPoaUuyX/C6S7jT78l1e3DHs14ebOVrB52vXx4=; b=uVVau97gSToz2NAylJ/GfNOEk84efyh7nIJsZ+LaSavaIWxS87xUWVOIiwnmvOm/st2u5IHSnnWAE6jBN9fYo+5TVrenfnze+xjyS8kVMsoukEeDBkdQOLMOx11dpfXul8p5OIvN1lR2pK+Fxp/ak/N9Kc0Xp5O5/YRkQYpK/lD1I3lSRwHh7yRZNoQSNY3ZxFFXTA0ZbTtx8vSzVgGKb2Gky57wA2G1d26HPKTxedV4wPEA/jpGKueRYA0Xz6fgQzxcbMhRiJRix31O3w/HFbERYuQR4y3/9qFLAg6gB9Z64nvExUktXkCjmuuGW0lwpBbjbENZgWd+oFJ6OfpdWg== 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:03 +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:03 +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 8/8] iommu/dart: Call apple_dart_finalize_domain() as part of alloc_paging() Date: Fri, 22 Sep 2023 14:07:59 -0300 Message-ID: <8-v1-8060f06462cc+c0a39-dart_paging_jgg@nvidia.com> In-Reply-To: <0-v1-8060f06462cc+c0a39-dart_paging_jgg@nvidia.com> References: X-ClientProxiedBy: YQBPR01CA0041.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:c01:2::13) 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: 358646d3-3923-4b76-ddcf-08dbbb8e7a68 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: LrlUM4cwssPclYgBnaWlPyV8uKn1JqWai4Ot2F+HLet7LImCye8skeOxwpXw9MoiUKtd8K27pnP78PpvLViUUCmmfKDJo6cRJLXFbB2FBEnsu1jAxR04weRITJIboJL1+sz9BTppeMEI4sbPAkI+uWjQJs3YMX8/txND0RBy8uANkXmbne3d4n1D6F9wS1egb2Sj91WAKQJ1MYUHEOFJ8p6dBEhbgjGxkRi2sY6byOnFORVkNZBZC7oPvn3fWuj5VFgcs6fxPgQX+ZzX8NMhzFNVqOUwANcGjwmGqH5VSwZWJ6WzGk3tyD8rRk5isr/34zF4kBOuaHEVyFiF6pjflJCUPIuAb8ocHOCTebNRJq4E+9nfkT6fnw0K9gPNNs3HCTEjifzoiT1x9gBC0b3QuULs7YSpJuakbXFSZBUTbp7L70pTmIpDhQ9J49hRHSq4g4Ei0C8/cIxbRcIIsrrVk0KX+zWqLRhz9n/IVuJ2fscdqoXGwHXlgci2HqKXC+83/l9uwEgppOD5rL1OH6+uRHoxGJOKkKmB4IsYMy1rJj1u5//l3+2L7dhqFam+imempK2ym7I537KHY7NtVzn3t+BDsWK5DETcBbO2+ckRs+hbmucqM+KIjkiM59yhixIzoRlY16iRnTb2xuGXEfRWoRFpCOHjODft/6yeTTTDo0w= 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)(47660400002)(186009)(1800799009)(451199024)(921005)(26005)(8936002)(2616005)(8676002)(7416002)(83380400001)(2906002)(36756003)(86362001)(6486002)(6506007)(478600001)(6666004)(5660300002)(38100700002)(6512007)(66946007)(110136005)(41300700001)(66556008)(316002)(66476007)(4216001)(46800400005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: huNYxPONj2sdNNWT5TW25TTi1k+mnMlTWBQMpBm5OunvMdr2Ldosacs7CFzrSDfrQr5bzeKIqB+87kOXMR2bibIXwJYZuU8NLeri14yYtguD+AYhrDH+z61MyvN3XHuN2JeUDVmBxfOi9HLZiMUSjx+KDd4h/AUM1JV3ywurnoxOd6Si7U9JW2wYosAKD0w7wV6beBJ0T77I51QcJOyC32I5S2o7II/MvBGtWFkZkG9G88VJffqwMHDgveL7kY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/0MpRBgP4+DDT67EZ7luJB6PsZcxsEElSNguBOmH4tNJEkrnUklUBadt41b/3ueq952/M5G0yMbd+N4xHgS9kVOmGyvGrNMrmCZLpS9WYeTNbl0tICUJ9+1iTyigyRlxAi5zvizjGCO2s333qz/I2EQmy+xTeXQ/hF/7nHs7sOUyoOfBiLOnCDCR3yR5NBIelr3LT154pMnykZlpGNdUstmOo+y6t5AjkyBI3acPF3AHX7VRpgbbxxgQwUoDTRBjstolbVOcHrKOq3RC7QmkX92p89Z7rQlIMvj X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 358646d3-3923-4b76-ddcf-08dbbb8e7a68 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.8313 (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: ktZx81BdhJ22qR03UztPUUL5bCjCPm/SfTEIU8DgJO3s0HhkfL7Eu3078qBTX5zA X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV3PR12MB9188 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230922_100825_410139_188CEFA4 X-CRM114-Status: GOOD ( 12.66 ) 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 In many cases the dev argument will now be !NULL so we should use it to finalize the domain at allocation. Make apple_dart_finalize_domain() accept the correct type. Signed-off-by: Jason Gunthorpe Reviewed-by: Janne Grunau --- drivers/iommu/apple-dart.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/drivers/iommu/apple-dart.c b/drivers/iommu/apple-dart.c index 62efe0aa056f60..2c1832e357c7c6 100644 --- a/drivers/iommu/apple-dart.c +++ b/drivers/iommu/apple-dart.c @@ -568,10 +568,9 @@ apple_dart_setup_translation(struct apple_dart_domain *domain, stream_map->dart->hw->invalidate_tlb(stream_map); } -static int apple_dart_finalize_domain(struct iommu_domain *domain, +static int apple_dart_finalize_domain(struct apple_dart_domain *dart_domain, struct apple_dart_master_cfg *cfg) { - struct apple_dart_domain *dart_domain = to_dart_domain(domain); struct apple_dart *dart = cfg->stream_maps[0].dart; struct io_pgtable_cfg pgtbl_cfg; int ret = 0; @@ -597,16 +596,17 @@ static int apple_dart_finalize_domain(struct iommu_domain *domain, .iommu_dev = dart->dev, }; - dart_domain->pgtbl_ops = - alloc_io_pgtable_ops(dart->hw->fmt, &pgtbl_cfg, domain); + dart_domain->pgtbl_ops = alloc_io_pgtable_ops(dart->hw->fmt, &pgtbl_cfg, + &dart_domain->domain); if (!dart_domain->pgtbl_ops) { ret = -ENOMEM; goto done; } - domain->pgsize_bitmap = pgtbl_cfg.pgsize_bitmap; - domain->geometry.aperture_start = 0; - domain->geometry.aperture_end = (dma_addr_t)DMA_BIT_MASK(dart->ias); + dart_domain->domain.pgsize_bitmap = pgtbl_cfg.pgsize_bitmap; + dart_domain->domain.geometry.aperture_start = 0; + dart_domain->domain.geometry.aperture_end = + (dma_addr_t)DMA_BIT_MASK(dart->ias); dart_domain->finalized = true; @@ -661,7 +661,7 @@ static int apple_dart_attach_dev_paging(struct iommu_domain *domain, if (cfg->stream_maps[0].dart->force_bypass) return -EINVAL; - ret = apple_dart_finalize_domain(domain, cfg); + ret = apple_dart_finalize_domain(dart_domain, cfg); if (ret) return ret; @@ -757,6 +757,16 @@ static struct iommu_domain *apple_dart_domain_alloc_paging(struct device *dev) mutex_init(&dart_domain->init_lock); + if (dev) { + struct apple_dart_master_cfg *cfg = dev_iommu_priv_get(dev); + int ret; + + ret = apple_dart_finalize_domain(dart_domain, cfg); + if (ret) { + kfree(dart_domain); + return ERR_PTR(ret); + } + } return &dart_domain->domain; }