From nobody Wed Nov 27 22:12:07 2024 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.15]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1B31283CA0 for ; Fri, 8 Nov 2024 02:15:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.15 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731032134; cv=none; b=KWZYDhp65HE9zdrNs9DM0QmLYwtbpiXVgG1Qo5QikcC22ZZ8d5leLVcYLyFEvZXNMGN6M11WHgh26xpehUySRyuiTwLdslcE13kQrAK7KN3zarijBErb+KUGNV9m9DVYVW1RCm5mgffzl+r5WHEwLRp6Q4b5uPvioNUWrOnNLXE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731032134; c=relaxed/simple; bh=sRZPTZ00M5Ft/vHNMDKUfam33wTHNeoKxKOUOiXBYn4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=R0NF/VaRPUwyaeRlJsBrnTT/L9oEuyXKXIwNi8zM44BO1WcIbX4PvcotcdjoM/lg+mbiK4muS3tX6KSyRcgZLFiYVBLwnfgPd1ouZ2P7NqzrLD1Mpi6dCeTkExFLyQLQMk6cCCl0TvN5V7XgIMGrzHKTwkky/4JKUh17TuMVz5I= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=j/BsEF33; arc=none smtp.client-ip=192.198.163.15 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="j/BsEF33" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1731032133; x=1762568133; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=sRZPTZ00M5Ft/vHNMDKUfam33wTHNeoKxKOUOiXBYn4=; b=j/BsEF33HnK+uFZcZuV3NTqBEmnVCM7dtJg5V2eTYIh9q+qpzZaok4jK lTmIfcn6TR3eO/wwWWBVZH85GuFXp+rU3x2G/42biG/CBPEx8XdjMGFxU xk3R52pLG2BTiMmAe75kBjntkuv1Asj0b1wbx3PVZCOKvvpTobL3qtDgM HPgsQUTXImdRs9se+PStGM87RGNb6HQ/wiBbeOR2rM8Rpfm9XWGCEXOyH SbdxHhu6TqR2zOzX02IUGZ+B2BhijcasFhO2qzHLKusslYyvqEmzfDJE2 EylSDGz53iDwjIBLsn1mpEmwvkacGreK/vkemn0GRtLVn0jtsNuE4GJ+/ g==; X-CSE-ConnectionGUID: 26HvXZzMSnKUb8nh1qe2BA== X-CSE-MsgGUID: OD6OrnYyTseIFO1OTcEiAg== X-IronPort-AV: E=McAfee;i="6700,10204,11249"; a="31007869" X-IronPort-AV: E=Sophos;i="6.12,136,1728975600"; d="scan'208";a="31007869" Received: from fmviesa001.fm.intel.com ([10.60.135.141]) by fmvoesa109.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Nov 2024 18:15:23 -0800 X-CSE-ConnectionGUID: mERSf7AASyOkQz+8x+xTcA== X-CSE-MsgGUID: mMrk+jmCT66zRj7IUZ/w6g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.12,136,1728975600"; d="scan'208";a="116213847" Received: from allen-sbox.sh.intel.com ([10.239.159.30]) by fmviesa001.fm.intel.com with ESMTP; 07 Nov 2024 18:15:20 -0800 From: Lu Baolu To: Joerg Roedel Cc: Jason Gunthorpe , Kevin Tian , Yi Liu , iommu@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [PATCH 12/13] iommu/arm-smmu-v3: Make set_dev_pasid() op support replace Date: Fri, 8 Nov 2024 10:14:03 +0800 Message-ID: <20241108021406.173972-13-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241108021406.173972-1-baolu.lu@linux.intel.com> References: <20241108021406.173972-1-baolu.lu@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Jason Gunthorpe set_dev_pasid() op is going to be enhanced to support domain replacement of a pasid. This prepares for this op definition. Signed-off-by: Jason Gunthorpe Reviewed-by: Kevin Tian Reviewed-by: Nicolin Chen Signed-off-by: Yi Liu Link: https://lore.kernel.org/r/20241107122234.7424-13-yi.l.liu@intel.com Signed-off-by: Lu Baolu --- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c | 2 +- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 9 +++------ drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h | 2 +- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c b/drivers/iomm= u/arm/arm-smmu-v3/arm-smmu-v3-sva.c index 645da7b69bed..1d3e71569775 100644 --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c @@ -349,7 +349,7 @@ static int arm_smmu_sva_set_dev_pasid(struct iommu_doma= in *domain, * get reassigned */ arm_smmu_make_sva_cd(&target, master, domain->mm, smmu_domain->cd.asid); - ret =3D arm_smmu_set_pasid(master, smmu_domain, id, &target); + ret =3D arm_smmu_set_pasid(master, smmu_domain, id, &target, old); =20 mmput(domain->mm); return ret; diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c b/drivers/iommu/ar= m/arm-smmu-v3/arm-smmu-v3.c index 1517fe2c356e..f70165f544df 100644 --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c @@ -2883,7 +2883,7 @@ static int arm_smmu_s1_set_dev_pasid(struct iommu_dom= ain *domain, */ arm_smmu_make_s1_cd(&target_cd, master, smmu_domain); return arm_smmu_set_pasid(master, to_smmu_domain(domain), id, - &target_cd); + &target_cd, old); } =20 static void arm_smmu_update_ste(struct arm_smmu_master *master, @@ -2913,16 +2913,13 @@ static void arm_smmu_update_ste(struct arm_smmu_mas= ter *master, =20 int arm_smmu_set_pasid(struct arm_smmu_master *master, struct arm_smmu_domain *smmu_domain, ioasid_t pasid, - struct arm_smmu_cd *cd) + struct arm_smmu_cd *cd, struct iommu_domain *old) { struct iommu_domain *sid_domain =3D iommu_get_domain_for_dev(master->dev); struct arm_smmu_attach_state state =3D { .master =3D master, - /* - * For now the core code prevents calling this when a domain is - * already attached, no need to set old_domain. - */ .ssid =3D pasid, + .old_domain =3D old, }; struct arm_smmu_cd *cdptr; int ret; diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h b/drivers/iommu/ar= m/arm-smmu-v3/arm-smmu-v3.h index 1e9952ca989f..52eaa0bedee1 100644 --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h @@ -875,7 +875,7 @@ void arm_smmu_write_cd_entry(struct arm_smmu_master *ma= ster, int ssid, =20 int arm_smmu_set_pasid(struct arm_smmu_master *master, struct arm_smmu_domain *smmu_domain, ioasid_t pasid, - struct arm_smmu_cd *cd); + struct arm_smmu_cd *cd, struct iommu_domain *old); =20 void arm_smmu_tlb_inv_asid(struct arm_smmu_device *smmu, u16 asid); void arm_smmu_tlb_inv_range_asid(unsigned long iova, size_t size, int asid, --=20 2.43.0