Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp6633756rwl; Wed, 22 Mar 2023 13:17:51 -0700 (PDT) X-Google-Smtp-Source: AK7set/6o6BAAAEMn9LRr/hY4279qplyv6FxGasf1/JhmY8ysiJW3jSWU7CwP6EMUggWhRk90Ys0 X-Received: by 2002:a17:906:1559:b0:92b:3c78:91fa with SMTP id c25-20020a170906155900b0092b3c7891famr7503722ejd.28.1679516271126; Wed, 22 Mar 2023 13:17:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679516271; cv=none; d=google.com; s=arc-20160816; b=dFjJc4dce5m1kyhygVmIQ1x4fcQQsevnxvsHZBaZZEAgZyBNWi3XGDZ9YB67l+N8eS BYjCqf2BqudTAYsFY6OE0Kas9rsGLsY98DFgrqRXbk3Umu6QVes8xjV2UMNIBObMx7yK RHoTYg//okCCIViVGscLVd/m9GMhD9wjpZ/i9VGtsB/2JYfWOu3rL+zclCdlo/lyQXqB 5s5JT4MxWqQMkdZsKe9kZgxeud/FYbHa+Q4b9mFMnM12jaYN6LQBrkkBfX3xx5ZHW9Q9 8tuNG986jKZHrgL1+DBDf37g8lDJEaT1VGeDvaQ22F7ALgYfSxZA7HVSEDj7QsRtGJ75 94eQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=dSnUhLv0sgYOgxCOt1iCkwuQ26y6EUeWB3XB1mKfui4=; b=0nAWo+AxMGOHIeBef4YGwhqK8n/808N9DgiHB6OksN1dRv55Zrl7cd7I3K+aIISRm3 S5A3uFbBlWyUxuWfg81I5MbTtj3d7xzL7kdZXIUg272+nPHuvQFjclC1/7QHB/Xa+73D NGaXeiVSOmGHVrDXYl2t2n8BWXe3UZTKoykQHGAmhw7ZRMPykLVALe0/eKJGo35VOuBr H2b1TxEySo8CC/hHLVca+gzRgd0idXYVAIfDDPazV0TqZUCYOylL7/ZpwyCmXaHukmzt 0zguRvqg1FsIRGHglH3kTUSBo7MCEy8Gjl2yIhSXOxJA9TcOfV//Hba7W0L/kwMpphHz Zm6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=VcC9OkY7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k20-20020a1709063fd400b00930cad91803si17603415ejj.473.2023.03.22.13.17.26; Wed, 22 Mar 2023 13:17:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=VcC9OkY7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232297AbjCVUQE (ORCPT + 99 others); Wed, 22 Mar 2023 16:16:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39824 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232516AbjCVUPe (ORCPT ); Wed, 22 Mar 2023 16:15:34 -0400 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 14D4C73397; Wed, 22 Mar 2023 13:06:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1679515577; x=1711051577; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=2NOV1ME1Hh74O3gionrf72IyziA/EurL0xsDxzsYmS8=; b=VcC9OkY7s4/Ra3YuF/mzyoPiOEyBp9hTagEblJcDwTIwnK9y1YA82Kiy E78AJf8M1Ex+NjkhcqRBBTVajQ+ncU0bSN2qPMl3KJBbVZA49l/kL0dCH cvTi69Vx5zPhfV5XzKY/zVv6lT+Y4LMSB5p9zyeLgs3cNAs8mZMKGJta5 NLcNTIDxhI6Ck/sKFvW0oWsJtX4qL12lqVfRQz8rSVJiFiZbp5MZ4Vf6N A3bVokk37dVtCS9TWbZLbv9wOnQ569Z7AnJ6mYn0YG+1teK1m3cHH7vAe D0bYzbdGGwTIqUvMaV2hMo/ouNVZctulyGTeYTOqfxzt/Wb820OtGDmFg g==; X-IronPort-AV: E=McAfee;i="6600,9927,10657"; a="339356862" X-IronPort-AV: E=Sophos;i="5.98,282,1673942400"; d="scan'208";a="339356862" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Mar 2023 13:04:06 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10657"; a="682039350" X-IronPort-AV: E=Sophos;i="5.98,282,1673942400"; d="scan'208";a="682039350" Received: from srinivas-otcpl-7600.jf.intel.com (HELO jacob-builder.jf.intel.com) ([10.54.39.106]) by orsmga002.jf.intel.com with ESMTP; 22 Mar 2023 13:04:06 -0700 From: Jacob Pan To: LKML , iommu@lists.linux.dev, Jason Gunthorpe , "Lu Baolu" , Joerg Roedel , Jean-Philippe Brucker , "Robin Murphy" , Dave Hansen , Thomas Gleixner , X86 Kernel , bp@alien8.de, "H. Peter Anvin" , Peter Zijlstra , corbet@lwn.net, vkoul@kernel.org, dmaengine@vger.kernel.org, linux-doc@vger.kernel.org Cc: "Will Deacon" , David Woodhouse , Raj Ashok , "Tian, Kevin" , Yi Liu , "Yu, Fenghua" , Dave Jiang , Kirill Shutemov , Tony Luck , Jacob Pan Subject: [PATCH v8 6/7] iommu/ioasid: Rename INVALID_IOASID Date: Wed, 22 Mar 2023 13:08:02 -0700 Message-Id: <20230322200803.869130-7-jacob.jun.pan@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230322200803.869130-1-jacob.jun.pan@linux.intel.com> References: <20230322200803.869130-1-jacob.jun.pan@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.4 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_NONE, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org INVALID_IOASID and IOMMU_PASID_INVALID are duplicated. Rename INVALID_IOASID and consolidate since we are moving away from IOASID infrastructure. Reviewed-by: Dave Jiang Reviewed-by: Jason Gunthorpe Reviewed-by: Kevin Tian Reviewed-by: Lu Baolu Signed-off-by: Jacob Pan --- v5: - Use pasid_valid() helper --- Documentation/x86/sva.rst | 2 +- arch/x86/kernel/traps.c | 2 +- drivers/dma/idxd/device.c | 8 ++++---- drivers/dma/idxd/idxd.h | 1 + drivers/dma/idxd/init.c | 2 +- drivers/dma/idxd/irq.c | 2 +- drivers/iommu/intel/dmar.c | 4 ++-- drivers/iommu/intel/iommu.c | 2 +- drivers/iommu/intel/svm.c | 2 +- include/linux/ioasid.h | 1 + include/linux/iommu.h | 6 +++--- mm/init-mm.c | 4 ++-- 12 files changed, 19 insertions(+), 17 deletions(-) diff --git a/Documentation/x86/sva.rst b/Documentation/x86/sva.rst index 2e9b8b0f9a0f..33cb05005982 100644 --- a/Documentation/x86/sva.rst +++ b/Documentation/x86/sva.rst @@ -107,7 +107,7 @@ process share the same page tables, thus the same MSR value. PASID Life Cycle Management =========================== -PASID is initialized as INVALID_IOASID (-1) when a process is created. +PASID is initialized as IOMMU_PASID_INVALID (-1) when a process is created. Only processes that access SVA-capable devices need to have a PASID allocated. This allocation happens when a process opens/binds an SVA-capable diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c index d317dc3d06a3..492a60febb11 100644 --- a/arch/x86/kernel/traps.c +++ b/arch/x86/kernel/traps.c @@ -40,7 +40,7 @@ #include #include #include -#include +#include #include #include diff --git a/drivers/dma/idxd/device.c b/drivers/dma/idxd/device.c index 5f321f3b4242..6fca8fa8d3a8 100644 --- a/drivers/dma/idxd/device.c +++ b/drivers/dma/idxd/device.c @@ -1194,7 +1194,7 @@ static void idxd_device_set_perm_entry(struct idxd_device *idxd, { union msix_perm mperm; - if (ie->pasid == INVALID_IOASID) + if (ie->pasid == IOMMU_PASID_INVALID) return; mperm.bits = 0; @@ -1224,7 +1224,7 @@ void idxd_wq_free_irq(struct idxd_wq *wq) idxd_device_clear_perm_entry(idxd, ie); ie->vector = -1; ie->int_handle = INVALID_INT_HANDLE; - ie->pasid = INVALID_IOASID; + ie->pasid = IOMMU_PASID_INVALID; } int idxd_wq_request_irq(struct idxd_wq *wq) @@ -1240,7 +1240,7 @@ int idxd_wq_request_irq(struct idxd_wq *wq) ie = &wq->ie; ie->vector = pci_irq_vector(pdev, ie->id); - ie->pasid = device_pasid_enabled(idxd) ? idxd->pasid : INVALID_IOASID; + ie->pasid = device_pasid_enabled(idxd) ? idxd->pasid : IOMMU_PASID_INVALID; idxd_device_set_perm_entry(idxd, ie); rc = request_threaded_irq(ie->vector, NULL, idxd_wq_thread, 0, "idxd-portal", ie); @@ -1265,7 +1265,7 @@ int idxd_wq_request_irq(struct idxd_wq *wq) free_irq(ie->vector, ie); err_irq: idxd_device_clear_perm_entry(idxd, ie); - ie->pasid = INVALID_IOASID; + ie->pasid = IOMMU_PASID_INVALID; return rc; } diff --git a/drivers/dma/idxd/idxd.h b/drivers/dma/idxd/idxd.h index 7ced8d283d98..417e602a46b6 100644 --- a/drivers/dma/idxd/idxd.h +++ b/drivers/dma/idxd/idxd.h @@ -13,6 +13,7 @@ #include #include #include +#include #include #include "registers.h" diff --git a/drivers/dma/idxd/init.c b/drivers/dma/idxd/init.c index 640d3048368e..e6ee267da0ff 100644 --- a/drivers/dma/idxd/init.c +++ b/drivers/dma/idxd/init.c @@ -105,7 +105,7 @@ static int idxd_setup_interrupts(struct idxd_device *idxd) ie = idxd_get_ie(idxd, msix_idx); ie->id = msix_idx; ie->int_handle = INVALID_INT_HANDLE; - ie->pasid = INVALID_IOASID; + ie->pasid = IOMMU_PASID_INVALID; spin_lock_init(&ie->list_lock); init_llist_head(&ie->pending_llist); diff --git a/drivers/dma/idxd/irq.c b/drivers/dma/idxd/irq.c index aa314ebec587..242f1f0b9f09 100644 --- a/drivers/dma/idxd/irq.c +++ b/drivers/dma/idxd/irq.c @@ -80,7 +80,7 @@ static void idxd_int_handle_revoke_drain(struct idxd_irq_entry *ie) desc.opcode = DSA_OPCODE_DRAIN; desc.priv = 1; - if (ie->pasid != INVALID_IOASID) + if (ie->pasid != IOMMU_PASID_INVALID) desc.pasid = ie->pasid; desc.int_handle = ie->int_handle; portal = idxd_wq_portal_addr(wq); diff --git a/drivers/iommu/intel/dmar.c b/drivers/iommu/intel/dmar.c index 0f348439ef0e..10bb20ff50fd 100644 --- a/drivers/iommu/intel/dmar.c +++ b/drivers/iommu/intel/dmar.c @@ -1958,7 +1958,7 @@ static int dmar_fault_do_one(struct intel_iommu *iommu, int type, return 0; } - if (pasid == INVALID_IOASID) + if (pasid == IOMMU_PASID_INVALID) pr_err("[%s NO_PASID] Request device [%02x:%02x.%d] fault addr 0x%llx [fault reason 0x%02x] %s\n", type ? "DMA Read" : "DMA Write", source_id >> 8, PCI_SLOT(source_id & 0xFF), @@ -2039,7 +2039,7 @@ irqreturn_t dmar_fault(int irq, void *dev_id) if (!ratelimited) /* Using pasid -1 if pasid is not present */ dmar_fault_do_one(iommu, type, fault_reason, - pasid_present ? pasid : INVALID_IOASID, + pasid_present ? pasid : IOMMU_PASID_INVALID, source_id, guest_addr); fault_index++; diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c index 21c14e00c852..0768dcae90fd 100644 --- a/drivers/iommu/intel/iommu.c +++ b/drivers/iommu/intel/iommu.c @@ -876,7 +876,7 @@ void dmar_fault_dump_ptes(struct intel_iommu *iommu, u16 source_id, return; } /* For request-without-pasid, get the pasid from context entry */ - if (intel_iommu_sm && pasid == INVALID_IOASID) + if (intel_iommu_sm && pasid == IOMMU_PASID_INVALID) pasid = PASID_RID2PASID; dir_index = pasid >> PASID_PDE_SHIFT; diff --git a/drivers/iommu/intel/svm.c b/drivers/iommu/intel/svm.c index 7367f56c3bad..3848a1b0800c 100644 --- a/drivers/iommu/intel/svm.c +++ b/drivers/iommu/intel/svm.c @@ -273,7 +273,7 @@ static int pasid_to_svm_sdev(struct device *dev, unsigned int pasid, if (WARN_ON(!mutex_is_locked(&pasid_mutex))) return -EINVAL; - if (pasid == INVALID_IOASID || pasid >= PASID_MAX) + if (pasid == IOMMU_PASID_INVALID || pasid >= PASID_MAX) return -EINVAL; svm = pasid_private_find(pasid); diff --git a/include/linux/ioasid.h b/include/linux/ioasid.h index 734bf0e036ee..bbc9c6fd3310 100644 --- a/include/linux/ioasid.h +++ b/include/linux/ioasid.h @@ -7,6 +7,7 @@ #include typedef unsigned int ioasid_t; +#define INVALID_IOASID ((ioasid_t)-1) typedef ioasid_t (*ioasid_alloc_fn_t)(ioasid_t min, ioasid_t max, void *data); typedef void (*ioasid_free_fn_t)(ioasid_t ioasid, void *data); diff --git a/include/linux/iommu.h b/include/linux/iommu.h index d3f81dc6e4dd..54f535ff9868 100644 --- a/include/linux/iommu.h +++ b/include/linux/iommu.h @@ -192,7 +192,6 @@ enum iommu_dev_features { #define IOMMU_PASID_INVALID (-1U) typedef unsigned int ioasid_t; -#define INVALID_IOASID ((ioasid_t)-1) #ifdef CONFIG_IOMMU_API @@ -1175,12 +1174,13 @@ static inline bool tegra_dev_iommu_get_stream_id(struct device *dev, u32 *stream static inline bool pasid_valid(ioasid_t ioasid) { - return ioasid != INVALID_IOASID; + return ioasid != IOMMU_PASID_INVALID; } + #ifdef CONFIG_IOMMU_SVA static inline void mm_pasid_init(struct mm_struct *mm) { - mm->pasid = INVALID_IOASID; + mm->pasid = IOMMU_PASID_INVALID; } void mm_pasid_drop(struct mm_struct *mm); struct iommu_sva *iommu_sva_bind_device(struct device *dev, diff --git a/mm/init-mm.c b/mm/init-mm.c index c9327abb771c..a084039f55d8 100644 --- a/mm/init-mm.c +++ b/mm/init-mm.c @@ -10,7 +10,7 @@ #include #include -#include +#include #include #ifndef INIT_MM_CONTEXT @@ -40,7 +40,7 @@ struct mm_struct init_mm = { .user_ns = &init_user_ns, .cpu_bitmap = CPU_BITS_NONE, #ifdef CONFIG_IOMMU_SVA - .pasid = INVALID_IOASID, + .pasid = IOMMU_PASID_INVALID, #endif INIT_MM_CONTEXT(init_mm) }; -- 2.25.1