From nobody Fri Dec 19 19:38:55 2025 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.14]) (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 BC7D615E5C2 for ; Wed, 29 May 2024 05:36:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.14 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716960973; cv=none; b=P+Kcsw8mWmc5MdtEvv99gKMLb1XpY7fMM4AOHUbJjHrw/opv25jiC8+5rNfpt3e9XbhqlIZOjWSrJAecEKvNLJsxm3+O5G06rbVRuyo/jw2LFWbQAvCt//7j/R2ltObRnOOd391cB75Bx6N28OmAVepCUw08UAuQTKKsFCmcnJ0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716960973; c=relaxed/simple; bh=WX+m07wt3DtPAOjU2K7TAng/knQriugPLDZHnttGpjU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=cVA2kPG5fv9e9z16F6THagf54Qx9dixaocCr8kmWH13cvwLDR9jNi/R6gJxMjJAeN1t2rolESf8A/gU9uIA6Gx9GuKq0ZeeHs9fmFsf6qoaJaXvspVbcoK+yk6926t2/TlhMV0HrXbxRTfQmE++mi6jjqEF8kv2NLsGzU9QXIcg= 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=VaGQefDP; arc=none smtp.client-ip=192.198.163.14 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="VaGQefDP" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1716960972; x=1748496972; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=WX+m07wt3DtPAOjU2K7TAng/knQriugPLDZHnttGpjU=; b=VaGQefDPRkneW/E9Kbi0WwIjw2vmsXbpcmSzPcSRbGV66YqmM3cZqVp/ rsTdMRTgrrnJBp2tMbmBKZRUAqK90FkcmszS9LA53ibTl8V+iSPqeaDXb 0Myen88Qex7ersTUSyR3It0D7h9ldQyQTXIO1EVtENUJRarYOeHuO6Y8b o5i6a0heX4iv4k3fx6gAbL6OG94O+w7kmBMbhPntv1hg6vcfndTcQDYDw Uu4OXA4N/acsnWVcAiA0caYRMSDBwIYZGrjcwpQDUUsZCXWyPuKTD+c2C qSsFF94SyLUSe/Q7eWBMcY2goi5eRkSnFfVNigtOvye17Zh+kjkiEIAoH g==; X-CSE-ConnectionGUID: QexXOv6bTzOUnNzmiZaQig== X-CSE-MsgGUID: o+2ptHiPRxmZhLEslIrccg== X-IronPort-AV: E=McAfee;i="6600,9927,11085"; a="13568749" X-IronPort-AV: E=Sophos;i="6.08,197,1712646000"; d="scan'208";a="13568749" Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by fmvoesa108.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 May 2024 22:35:06 -0700 X-CSE-ConnectionGUID: ff5BmhNMSBOq/6aqKuHlTw== X-CSE-MsgGUID: VRTTk5mGQciwJeBPrShRDw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,197,1712646000"; d="scan'208";a="35257451" Received: from unknown (HELO allen-box.sh.intel.com) ([10.239.159.127]) by fmviesa007.fm.intel.com with ESMTP; 28 May 2024 22:35:01 -0700 From: Lu Baolu To: Joerg Roedel , Will Deacon , Robin Murphy , Jason Gunthorpe , Kevin Tian Cc: Yi Liu , David Airlie , Daniel Vetter , Kalle Valo , Bjorn Andersson , Mathieu Poirier , Alex Williamson , mst@redhat.com, Jason Wang , Thierry Reding , Jonathan Hunter , Mikko Perttunen , iommu@lists.linux.dev, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Lu Baolu Subject: [PATCH 01/20] iommu: Add iommu_user_domain_alloc() interface Date: Wed, 29 May 2024 13:32:31 +0800 Message-Id: <20240529053250.91284-2-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240529053250.91284-1-baolu.lu@linux.intel.com> References: <20240529053250.91284-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" Commit <909f4abd1097> ("iommu: Add new iommu op to create domains owned by userspace") added a dedicated iommu op to allocate a user domain. While IOMMUFD has already made use of this callback, other frameworks like vfio/type1 and vDPA still use the paging domain allocation interface. Add a new interface named iommu_user_domain_alloc(), which indicates the allocation of a domain for device DMA managed by user space driver. All device passthrough frameworks could use this interface for their domain allocation. Although it is expected that all iommu drivers could implement their own domain_alloc_user ops, most drivers haven't implemented it yet. Rollback to the paging domain allocation interface if the iommu driver hasn't implemented this op yet. Signed-off-by: Lu Baolu --- include/linux/iommu.h | 6 ++++++ drivers/iommu/iommu.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) diff --git a/include/linux/iommu.h b/include/linux/iommu.h index 7bc8dff7cf6d..6648b2415474 100644 --- a/include/linux/iommu.h +++ b/include/linux/iommu.h @@ -780,6 +780,7 @@ extern bool iommu_present(const struct bus_type *bus); extern bool device_iommu_capable(struct device *dev, enum iommu_cap cap); extern bool iommu_group_has_isolated_msi(struct iommu_group *group); extern struct iommu_domain *iommu_domain_alloc(const struct bus_type *bus); +struct iommu_domain *iommu_user_domain_alloc(struct device *dev, u32 flags= ); extern void iommu_domain_free(struct iommu_domain *domain); extern int iommu_attach_device(struct iommu_domain *domain, struct device *dev); @@ -1086,6 +1087,11 @@ static inline struct iommu_domain *iommu_domain_allo= c(const struct bus_type *bus return NULL; } =20 +static inline struct iommu_domain *iommu_user_domain_alloc(struct device *= dev, u32 flags) +{ + return ERR_PTR(-ENODEV); +} + static inline void iommu_domain_free(struct iommu_domain *domain) { } diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index 9df7cc75c1bc..f1416892ef8e 100644 --- a/drivers/iommu/iommu.c +++ b/drivers/iommu/iommu.c @@ -2032,6 +2032,48 @@ struct iommu_domain *iommu_domain_alloc(const struct= bus_type *bus) } EXPORT_SYMBOL_GPL(iommu_domain_alloc); =20 +/** + * iommu_user_domain_alloc() - Allocate a user domain + * @dev: device for which the domain is allocated + * @flags: iommufd_hwpt_alloc_flags defined in uapi/linux/iommufd.h + * + * Allocate a user domain which will be managed by a userspace driver. Ret= urn + * allocated domain if successful, or a ERR pointer for failure. + */ +struct iommu_domain *iommu_user_domain_alloc(struct device *dev, u32 flags) +{ + struct iommu_domain *domain; + const struct iommu_ops *ops; + + if (!dev_has_iommu(dev)) + return ERR_PTR(-ENODEV); + + ops =3D dev_iommu_ops(dev); + if (ops->domain_alloc_user) { + domain =3D ops->domain_alloc_user(dev, flags, NULL, NULL); + if (IS_ERR(domain)) + return domain; + + domain->type =3D IOMMU_DOMAIN_UNMANAGED; + domain->owner =3D ops; + domain->pgsize_bitmap =3D ops->pgsize_bitmap; + domain->ops =3D ops->default_domain_ops; + + return domain; + } + + /* + * The iommu driver doesn't support domain_alloc_user callback. + * Rollback to a UNMANAGED paging domain which doesn't support + * the allocation flags. + */ + if (flags) + return ERR_PTR(-EOPNOTSUPP); + + return __iommu_domain_alloc(ops, dev, IOMMU_DOMAIN_UNMANAGED); +} +EXPORT_SYMBOL_GPL(iommu_user_domain_alloc); + void iommu_domain_free(struct iommu_domain *domain) { if (domain->type =3D=3D IOMMU_DOMAIN_SVA) --=20 2.34.1 From nobody Fri Dec 19 19:38:55 2025 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.14]) (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 E957B15B99F for ; Wed, 29 May 2024 05:36:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.14 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716960974; cv=none; b=WsUdK4YseZ8NGdO8KhfI5dyg+SwMdLjJ1tH69W5KGkSJMjc56V+Wn1cFvhpS9H3hvzcXW2r5gf0wu3XRDtTWJYpfsZlUGuvG+jbj2aHS+n78SVZU9bwA1tONf7Xq8ZTe1NcWGGS5ZQG4IVnm5ckYXjQLJ7sX7y4AGtClvZbWsh4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716960974; c=relaxed/simple; bh=i2g4o4FMSNI6vy56g2mVccrM+MuXNKNyXwoqmECaK9M=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=gCYayg2BzNde7TUHHktX7lSQ1CAxY71Pfs2BOsHik4wV8I8xq7RcEz3kO+nUwOyRBCORLWfXSOkV6ZXrCcH0o+vSPruxIjWd8oZe+5AK9M1OKfuOkU/INerfhEYoZbaozW5V5BhywrQDV93bGRmFaLwDEXjQC/hopLrlFyeQJ+Q= 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=LoHlT/xK; arc=none smtp.client-ip=192.198.163.14 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="LoHlT/xK" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1716960973; x=1748496973; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=i2g4o4FMSNI6vy56g2mVccrM+MuXNKNyXwoqmECaK9M=; b=LoHlT/xKZsJ3n82UnMR7MhwE7kMuSLFeUf+MtzUztsBWfLLr6vC9Rajv KTzHFyJB1Z9KPW/ImITeJ77BokppLmQ+mlHyauBeGwKErN5qjizn4qDBL xqEXkrOsVTXsDWtBDu8fe7SG6JwJZzWzhKl6jsA+8Rl8YgHZ9QBuYHHJd syK3fFdNUWZUOYCdCV8GISmU5hcm3i9Cqc5v+NZ83GmEeLcLzzpvgM6kX HaDIIQsQEGYNSOf5Iw/Z0kqELG04NB2ibBKC0qmFJ81iYfZJzeoPLMCxI VgkCZ/SapkPN9Ah/jYs12Zw4PJWnCy9vWE4otZwfWDFOwVGccayAeM3zy Q==; X-CSE-ConnectionGUID: nmTIRLnNSKm4XCBasgy7qA== X-CSE-MsgGUID: 2WemJI2wTimyi1F/xArePA== X-IronPort-AV: E=McAfee;i="6600,9927,11085"; a="13568764" X-IronPort-AV: E=Sophos;i="6.08,197,1712646000"; d="scan'208";a="13568764" Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by fmvoesa108.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 May 2024 22:35:11 -0700 X-CSE-ConnectionGUID: ooEsLAqOTEq37Hrx3ZeYbQ== X-CSE-MsgGUID: FAzliAhcS6u1szAMWmJLKQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,197,1712646000"; d="scan'208";a="35257473" Received: from unknown (HELO allen-box.sh.intel.com) ([10.239.159.127]) by fmviesa007.fm.intel.com with ESMTP; 28 May 2024 22:35:06 -0700 From: Lu Baolu To: Joerg Roedel , Will Deacon , Robin Murphy , Jason Gunthorpe , Kevin Tian Cc: Yi Liu , David Airlie , Daniel Vetter , Kalle Valo , Bjorn Andersson , Mathieu Poirier , Alex Williamson , mst@redhat.com, Jason Wang , Thierry Reding , Jonathan Hunter , Mikko Perttunen , iommu@lists.linux.dev, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Lu Baolu Subject: [PATCH 02/20] iommufd: Use iommu_user_domain_alloc() Date: Wed, 29 May 2024 13:32:32 +0800 Message-Id: <20240529053250.91284-3-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240529053250.91284-1-baolu.lu@linux.intel.com> References: <20240529053250.91284-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" Replace iommu_domain_alloc() with iommu_user_domain_alloc(). Signed-off-by: Lu Baolu --- drivers/iommu/iommufd/hw_pagetable.c | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/drivers/iommu/iommufd/hw_pagetable.c b/drivers/iommu/iommufd/h= w_pagetable.c index 33d142f8057d..ada05fccb36a 100644 --- a/drivers/iommu/iommufd/hw_pagetable.c +++ b/drivers/iommu/iommufd/hw_pagetable.c @@ -127,21 +127,11 @@ iommufd_hwpt_paging_alloc(struct iommufd_ctx *ictx, s= truct iommufd_ioas *ioas, hwpt_paging->ioas =3D ioas; hwpt_paging->nest_parent =3D flags & IOMMU_HWPT_ALLOC_NEST_PARENT; =20 - if (ops->domain_alloc_user) { - hwpt->domain =3D ops->domain_alloc_user(idev->dev, flags, NULL, - user_data); - if (IS_ERR(hwpt->domain)) { - rc =3D PTR_ERR(hwpt->domain); - hwpt->domain =3D NULL; - goto out_abort; - } - hwpt->domain->owner =3D ops; - } else { - hwpt->domain =3D iommu_domain_alloc(idev->dev->bus); - if (!hwpt->domain) { - rc =3D -ENOMEM; - goto out_abort; - } + hwpt->domain =3D iommu_user_domain_alloc(idev->dev, flags); + if (IS_ERR(hwpt->domain)) { + rc =3D PTR_ERR(hwpt->domain); + hwpt->domain =3D NULL; + goto out_abort; } =20 /* --=20 2.34.1 From nobody Fri Dec 19 19:38:55 2025 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.14]) (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 6D05115DBC6 for ; Wed, 29 May 2024 05:36:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.14 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716960974; cv=none; b=j9AgpdkCKaMLKlhwo3cQQaOMf9dzWHy468hNnmY7P3hVlmgOPBnVrb472+nOwDpphNBWR6Y+9cZI7FIuV9tC6oB1i0WOwPQsT8fSUab2cEW/oWpHD4Hma1jL+ljbkJeUt2UW6z6XDRY4yHCBqj4xDc5azat+PQMx51s79rs32wA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716960974; c=relaxed/simple; bh=Ku98pK7UgGN8K4Vqi8YCUxqt/MmWDBRD7GnhYQUhVEg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=jd9AtcPrd8S8ZFz/g0WEOe/5Lmgj6HldLStAcKnfvlVONj3+u+Z2mDGG3x7YOX6/5QfbCpOcjcHZ7CU1ZrB0V8gj8EwN224PPv19ueqYHYU1HjoOdE0Chvaq8xZWBA8wRN5Xx7sq4zYimV7f43VMNNkhEes7MHjr25KnzCWmZ34= 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=lobssp4S; arc=none smtp.client-ip=192.198.163.14 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="lobssp4S" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1716960973; x=1748496973; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Ku98pK7UgGN8K4Vqi8YCUxqt/MmWDBRD7GnhYQUhVEg=; b=lobssp4SlPn4FD1ObriFep3zHr2EfzpftuRLSaiCqAYyercF5DmOen01 b42zZie6swzm5d5oGOOrZof991iuwvThIkpdTnPTvm8+/PF0mhloFnjtR bEfbxJW2ftrZ1SBADTAWdRY7yx8NNotey854+PEXb9300+EDAuVsKaUpa dB1jG6gZ9QDmnVOKaG/e6bM7J/IhOPHrw6ttm9zN5rHpcD9gnuZLvA/sf ndfXF9kec00CJM0PcfhV5nmq3WjcABjFyPteYbbYl+0dow5ULY6vblbwG wGh3ETK4LeoG+5xlxLjmlgVaiavbkZ/XQyFA5k2E6moJo4YjKjJi1ZMJa A==; X-CSE-ConnectionGUID: LodPNojnTai3C9J+76CokQ== X-CSE-MsgGUID: x3CROmkhQRCiebUEHanP6w== X-IronPort-AV: E=McAfee;i="6600,9927,11085"; a="13568786" X-IronPort-AV: E=Sophos;i="6.08,197,1712646000"; d="scan'208";a="13568786" Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by fmvoesa108.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 May 2024 22:35:16 -0700 X-CSE-ConnectionGUID: WiRHsEl4TRC1JXRxiW5i8g== X-CSE-MsgGUID: 4zBoCP3eR6Ce1YRhsCapLQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,197,1712646000"; d="scan'208";a="35257489" Received: from unknown (HELO allen-box.sh.intel.com) ([10.239.159.127]) by fmviesa007.fm.intel.com with ESMTP; 28 May 2024 22:35:11 -0700 From: Lu Baolu To: Joerg Roedel , Will Deacon , Robin Murphy , Jason Gunthorpe , Kevin Tian Cc: Yi Liu , David Airlie , Daniel Vetter , Kalle Valo , Bjorn Andersson , Mathieu Poirier , Alex Williamson , mst@redhat.com, Jason Wang , Thierry Reding , Jonathan Hunter , Mikko Perttunen , iommu@lists.linux.dev, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Lu Baolu Subject: [PATCH 03/20] vfio/type1: Use iommu_paging_domain_alloc() Date: Wed, 29 May 2024 13:32:33 +0800 Message-Id: <20240529053250.91284-4-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240529053250.91284-1-baolu.lu@linux.intel.com> References: <20240529053250.91284-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" Replace iommu_domain_alloc() with iommu_user_domain_alloc(). Signed-off-by: Lu Baolu --- drivers/vfio/vfio_iommu_type1.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type= 1.c index 3a0218171cfa..1d553f7f7c26 100644 --- a/drivers/vfio/vfio_iommu_type1.c +++ b/drivers/vfio/vfio_iommu_type1.c @@ -2135,7 +2135,7 @@ static int vfio_iommu_domain_alloc(struct device *dev= , void *data) { struct iommu_domain **domain =3D data; =20 - *domain =3D iommu_domain_alloc(dev->bus); + *domain =3D iommu_user_domain_alloc(dev, 0); return 1; /* Don't iterate */ } =20 @@ -2192,11 +2192,12 @@ static int vfio_iommu_type1_attach_group(void *iomm= u_data, * us a representative device for the IOMMU API call. We don't actually * want to iterate beyond the first device (if any). */ - ret =3D -EIO; iommu_group_for_each_dev(iommu_group, &domain->domain, vfio_iommu_domain_alloc); - if (!domain->domain) + if (IS_ERR(domain->domain)) { + ret =3D PTR_ERR(domain->domain); goto out_free_domain; + } =20 if (iommu->nesting) { ret =3D iommu_enable_nesting(domain->domain); --=20 2.34.1 From nobody Fri Dec 19 19:38:55 2025 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.14]) (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 3D49015EFBC for ; Wed, 29 May 2024 05:36:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.14 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716960975; cv=none; b=a5slb1W/Mjkj/6Ezm0qGSxPd+L1cbXNT+3s8POC69Pw7+sUKJjBlDyuwXXo+7dmwm6X82tFmJzEeJ2DdBlX3/VMeXU/rC8+CTg21u8kxKfzopjiVAFnO8dQ5aUZWc/beR9igYNoeYC4LLUa4FEJSvp57qQaHgwf7FrvT4tn+2fg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716960975; c=relaxed/simple; bh=ybhIC+9D0FzFiBqGh0zAWkB79mgKE5w60y1oFabl/b8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=RyAAJ8WEumtLxLsKL8a3Odfmkn9RkeW5+R6/xwILbMaHjYRx67gFpDoWopWDiiToaq/plIgRxt/Yir2UoGlmysAgT4kVLBbz2/g067PaMRVvWnH9HY9M4wCpQBss5pH0JueN3yUpfqqRdwFtytoFB4iExsL1mZ66gv4hoIdmzEU= 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=TpP+mhqc; arc=none smtp.client-ip=192.198.163.14 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="TpP+mhqc" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1716960974; x=1748496974; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ybhIC+9D0FzFiBqGh0zAWkB79mgKE5w60y1oFabl/b8=; b=TpP+mhqcl5XxarurC0AhOdrZrriImZKgHvXbxqfeS4wd3KpghLKn5Seb anYcpbetdNMmWNgwcUDziKvmS+glrgrvwYesaMy5w9zWrfSjR5fMFuq7+ bRFJBsMMsIpOxGxZ2g5ZkT281KuOK/VBXw3YK+VKlZP5lgZ21LU7LUQJy Lp46CEtqcP1yGDn1W0Dzxfa5R8xpPQ5CNI5SWgAbwcL64tLkXza5ffvAt IgAMBJvZR9GWsF3RmXy0lbTH7Nb9mCkKI3VYJSOZmuHEFQ8E2eYhoq8g+ beW6Ky+nJVvlmAxSWTmt2nkMDX0QUfrp8jZ66rk5aI2zy3MGhyeRTVG1q A==; X-CSE-ConnectionGUID: +w1o833cR0qIt2rWhQ1jWQ== X-CSE-MsgGUID: rE1dr/TVTnyws9GpJKlgew== X-IronPort-AV: E=McAfee;i="6600,9927,11085"; a="13568806" X-IronPort-AV: E=Sophos;i="6.08,197,1712646000"; d="scan'208";a="13568806" Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by fmvoesa108.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 May 2024 22:35:20 -0700 X-CSE-ConnectionGUID: Lx3ESut/QGCW7lfZ/TNLuA== X-CSE-MsgGUID: oyY1KD/nRaOxmUib4QeiUg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,197,1712646000"; d="scan'208";a="35257522" Received: from unknown (HELO allen-box.sh.intel.com) ([10.239.159.127]) by fmviesa007.fm.intel.com with ESMTP; 28 May 2024 22:35:15 -0700 From: Lu Baolu To: Joerg Roedel , Will Deacon , Robin Murphy , Jason Gunthorpe , Kevin Tian Cc: Yi Liu , David Airlie , Daniel Vetter , Kalle Valo , Bjorn Andersson , Mathieu Poirier , Alex Williamson , mst@redhat.com, Jason Wang , Thierry Reding , Jonathan Hunter , Mikko Perttunen , iommu@lists.linux.dev, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Lu Baolu Subject: [PATCH 04/20] vhost-vdpa: Use iommu_user_domain_alloc() Date: Wed, 29 May 2024 13:32:34 +0800 Message-Id: <20240529053250.91284-5-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240529053250.91284-1-baolu.lu@linux.intel.com> References: <20240529053250.91284-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" Replace iommu_domain_alloc() with iommu_user_domain_alloc(). Signed-off-by: Lu Baolu --- drivers/vhost/vdpa.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c index 63a53680a85c..7784218fd9d2 100644 --- a/drivers/vhost/vdpa.c +++ b/drivers/vhost/vdpa.c @@ -1312,26 +1312,21 @@ static int vhost_vdpa_alloc_domain(struct vhost_vdp= a *v) struct vdpa_device *vdpa =3D v->vdpa; const struct vdpa_config_ops *ops =3D vdpa->config; struct device *dma_dev =3D vdpa_get_dma_dev(vdpa); - const struct bus_type *bus; int ret; =20 /* Device want to do DMA by itself */ if (ops->set_map || ops->dma_map) return 0; =20 - bus =3D dma_dev->bus; - if (!bus) - return -EFAULT; - if (!device_iommu_capable(dma_dev, IOMMU_CAP_CACHE_COHERENCY)) { dev_warn_once(&v->dev, "Failed to allocate domain, device is not IOMMU cache coherent ca= pable\n"); return -ENOTSUPP; } =20 - v->domain =3D iommu_domain_alloc(bus); - if (!v->domain) - return -EIO; + v->domain =3D iommu_user_domain_alloc(dma_dev, 0); + if (IS_ERR(v->domain)) + return PTR_ERR(v->domain); =20 ret =3D iommu_attach_device(v->domain, dma_dev); if (ret) --=20 2.34.1 From nobody Fri Dec 19 19:38:55 2025 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.14]) (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 8EA0815F417 for ; Wed, 29 May 2024 05:36:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.14 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716960976; cv=none; b=G41QqmFWxKjxTthPTq3nlV9G9Vzcox/DnMSjm0bJ977w0Meya37Wgf1M+HuQtfnqcZmMlOuYkyfz9neuwpPTJFW2ZZ537eQjHrTmT1yY81FXrRh3OI2SbjuQEn3wcZ6pWHIIODl7uq9KMqqbVTCqpTJB0SsuQm2DrJ4bysSaFmg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716960976; c=relaxed/simple; bh=xf05GvXEO+I215J3GQWK9zqCkzSYPhbVb/+Tz/JkYCQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ndpwMs/8BTbk/sxW98MFtHi/ERq4vUPJcIIFX8xI7IwWz7bVj+0VdoxO4C3aMEcrptQMe/8azMFeqreVKFQco3jgrCkRZZPJkgL3yroCSy0ibVYuW7fpoLTRVjaaOwhbjpdsbo+KSFbKWnib/aLOoDyqcuF4AVBbE9GGNu+m7p8= 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=Bgh5+Uq3; arc=none smtp.client-ip=192.198.163.14 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="Bgh5+Uq3" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1716960975; x=1748496975; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=xf05GvXEO+I215J3GQWK9zqCkzSYPhbVb/+Tz/JkYCQ=; b=Bgh5+Uq3rfQzo4IujodLM5ApJH6QiUAFgY81W0u2T+C5eQIRSOKgeojc ni4exGqvQDfPFKPX5YAZP7MYcdTqgavCsAcRhkCBwwLexYXaNWcz94lGP BhYpxVJyn+hpdgjhw59L/ybaRVTzq1tF1hS0UOthCi4TCCRmzWKC2BHM8 Y+x8M86GZy6EnDx3MiU7z1iqYcvy6fyI2Gfmr2gDT3KU3ovu0hQzHf5XM lT2Y7DZ5IYtcER1TM52yhv08dNUhyUmJF3lgOlBCF3D5qbLHGjKFL1enO 82PPxini4UQde6xLIDycvWpOyYMyz8jXRUhvIiHagN9NTiNUPUp5FT54B g==; X-CSE-ConnectionGUID: 5J9g22DLRBuUYT/oFcYjnQ== X-CSE-MsgGUID: 4WeBitFrSVCR3d4SU0s8Yg== X-IronPort-AV: E=McAfee;i="6600,9927,11085"; a="13568825" X-IronPort-AV: E=Sophos;i="6.08,197,1712646000"; d="scan'208";a="13568825" Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by fmvoesa108.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 May 2024 22:35:25 -0700 X-CSE-ConnectionGUID: WkFEj6PrQYqnAeoLtI1GfQ== X-CSE-MsgGUID: eszOZrvySa+kJnN3MKgnnw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,197,1712646000"; d="scan'208";a="35257546" Received: from unknown (HELO allen-box.sh.intel.com) ([10.239.159.127]) by fmviesa007.fm.intel.com with ESMTP; 28 May 2024 22:35:20 -0700 From: Lu Baolu To: Joerg Roedel , Will Deacon , Robin Murphy , Jason Gunthorpe , Kevin Tian Cc: Yi Liu , David Airlie , Daniel Vetter , Kalle Valo , Bjorn Andersson , Mathieu Poirier , Alex Williamson , mst@redhat.com, Jason Wang , Thierry Reding , Jonathan Hunter , Mikko Perttunen , iommu@lists.linux.dev, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Lu Baolu Subject: [PATCH 05/20] iommu: Add iommu_paging_domain_alloc() interface Date: Wed, 29 May 2024 13:32:35 +0800 Message-Id: <20240529053250.91284-6-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240529053250.91284-1-baolu.lu@linux.intel.com> References: <20240529053250.91284-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" Commit <17de3f5fdd35> ("iommu: Retire bus ops") removes iommu ops from bus. The iommu subsystem no longer relies on bus for operations. So the bus parameter in iommu_domain_alloc() is no longer relevant. Add a new interface named iommu_paging_domain_alloc(), which explicitly indicates the allocation of a paging domain for DMA managed by a kernel driver. The new interface takes a device pointer as its parameter, that better aligns with the current iommu subsystem. Signed-off-by: Lu Baolu --- include/linux/iommu.h | 6 ++++++ drivers/iommu/iommu.c | 20 ++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/include/linux/iommu.h b/include/linux/iommu.h index 6648b2415474..16401de7802d 100644 --- a/include/linux/iommu.h +++ b/include/linux/iommu.h @@ -781,6 +781,7 @@ extern bool device_iommu_capable(struct device *dev, en= um iommu_cap cap); extern bool iommu_group_has_isolated_msi(struct iommu_group *group); extern struct iommu_domain *iommu_domain_alloc(const struct bus_type *bus); struct iommu_domain *iommu_user_domain_alloc(struct device *dev, u32 flags= ); +struct iommu_domain *iommu_paging_domain_alloc(struct device *dev); extern void iommu_domain_free(struct iommu_domain *domain); extern int iommu_attach_device(struct iommu_domain *domain, struct device *dev); @@ -1092,6 +1093,11 @@ static inline struct iommu_domain *iommu_user_domain= _alloc(struct device *dev, u return ERR_PTR(-ENODEV); } =20 +static inline struct iommu_domain *iommu_paging_domain_alloc(struct device= *dev) +{ + return ERR_PTR(-ENODEV); +} + static inline void iommu_domain_free(struct iommu_domain *domain) { } diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index f1416892ef8e..7df4a021b040 100644 --- a/drivers/iommu/iommu.c +++ b/drivers/iommu/iommu.c @@ -2016,6 +2016,10 @@ static int __iommu_domain_alloc_dev(struct device *d= ev, void *data) return 0; } =20 +/* + * The iommu ops in bus has been retired. Do not use this interface in + * new drivers. + */ struct iommu_domain *iommu_domain_alloc(const struct bus_type *bus) { const struct iommu_ops *ops =3D NULL; @@ -2074,6 +2078,22 @@ struct iommu_domain *iommu_user_domain_alloc(struct = device *dev, u32 flags) } EXPORT_SYMBOL_GPL(iommu_user_domain_alloc); =20 +/** + * iommu_paging_domain_alloc() - Allocate a paging domain + * @dev: device for which the domain is allocated + * + * Allocate a paging domain which will be managed by a kernel driver. Retu= rn + * allocated domain if successful, or a ERR pointer for failure. + */ +struct iommu_domain *iommu_paging_domain_alloc(struct device *dev) +{ + if (!dev_has_iommu(dev)) + return ERR_PTR(-ENODEV); + + return __iommu_domain_alloc(dev_iommu_ops(dev), dev, IOMMU_DOMAIN_UNMANAG= ED); +} +EXPORT_SYMBOL_GPL(iommu_paging_domain_alloc); + void iommu_domain_free(struct iommu_domain *domain) { if (domain->type =3D=3D IOMMU_DOMAIN_SVA) --=20 2.34.1 From nobody Fri Dec 19 19:38:55 2025 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.14]) (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 073E015FCE6 for ; Wed, 29 May 2024 05:36:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.14 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716960976; cv=none; b=ZEVMezhmVLVqyClx/FF3w/xn1YPKL5+Vql6/AqvhuBJ4A1pCVB7rlAUMvU0cTo0KsLtkt2ejwF510d2IrhJG5x8lqoGDpx17sotDGH3em4+lybpEpfhxYmfL3dodddkQ8Kbv0yRGVilO4TwxhNbI+1svsD/NEJxYrQGT47ZK/z4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716960976; c=relaxed/simple; bh=btq9QncSBgyBYPM+1ZLAyc+X7006n3UNtW5/Bz7GLZE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=MeUXdY6i9FlUpLV8jCB+2eJyQp76Wj1e8+kzjqJ1zx25GxPt0IpvrpzS/BVCkDetZOFQxqdixuyTpGMmUERodTeHXNF++uwUuzrS9MT82oZmDZUj7M0bWwRDF4qxgZ2Jbt/WKbLD3N28dP1hWgz/1i0nuSJVJjd8LPWVsaIR7k4= 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=lqiw3jwQ; arc=none smtp.client-ip=192.198.163.14 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="lqiw3jwQ" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1716960975; x=1748496975; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=btq9QncSBgyBYPM+1ZLAyc+X7006n3UNtW5/Bz7GLZE=; b=lqiw3jwQc2SVq6O8cP5eBHlAXTvF8fgsmMPHNDDKg4UhX5OZscVXiLzP 4CUd1VOQJyS2AgHoyeO5UArCs6uFKz06RTg7qRIkNVoPNV4KBXOONry3f VQdxevMmIqG30TozSP74JZXgx2POGkIvoMVJEJscyWiVJQCicm+ukSoiP Nq4IKV275BXvsmr0SwELFk2aUC5NS13ztmgbRmXghhxufG0vrTxCaacCa dpUmKjMZa78OjTARHx0Ln4gpPR6aQogra0tunMlPKGQ+VUvm83NrF8ih+ wxGLHyByNDI/mJtylceqr3Vj0MgntuLlK8ScWkRlnam6GyqfozzX+UlBz g==; X-CSE-ConnectionGUID: BrTwlDWvRqKFVeLAloCbTg== X-CSE-MsgGUID: /9oCaxyhSeudc856ZhkoDg== X-IronPort-AV: E=McAfee;i="6600,9927,11085"; a="13568851" X-IronPort-AV: E=Sophos;i="6.08,197,1712646000"; d="scan'208";a="13568851" Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by fmvoesa108.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 May 2024 22:35:30 -0700 X-CSE-ConnectionGUID: PJuAP/85SO2v/dKzt8Un2A== X-CSE-MsgGUID: fVOd5tHsThGjTLV7SoVvmQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,197,1712646000"; d="scan'208";a="35257574" Received: from unknown (HELO allen-box.sh.intel.com) ([10.239.159.127]) by fmviesa007.fm.intel.com with ESMTP; 28 May 2024 22:35:25 -0700 From: Lu Baolu To: Joerg Roedel , Will Deacon , Robin Murphy , Jason Gunthorpe , Kevin Tian Cc: Yi Liu , David Airlie , Daniel Vetter , Kalle Valo , Bjorn Andersson , Mathieu Poirier , Alex Williamson , mst@redhat.com, Jason Wang , Thierry Reding , Jonathan Hunter , Mikko Perttunen , iommu@lists.linux.dev, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Lu Baolu Subject: [PATCH 06/20] drm/msm: Use iommu_paging_domain_alloc() Date: Wed, 29 May 2024 13:32:36 +0800 Message-Id: <20240529053250.91284-7-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240529053250.91284-1-baolu.lu@linux.intel.com> References: <20240529053250.91284-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" The domain allocated in msm_iommu_new() is for the @dev. Replace iommu_domain_alloc() with iommu_paging_domain_alloc() to make it explicit. Update msm_iommu_new() to always return ERR_PTR in failure cases instead of NULL. Signed-off-by: Lu Baolu --- drivers/gpu/drm/msm/msm_iommu.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/msm/msm_iommu.c b/drivers/gpu/drm/msm/msm_iomm= u.c index d5512037c38b..f7e28d4b5f62 100644 --- a/drivers/gpu/drm/msm/msm_iommu.c +++ b/drivers/gpu/drm/msm/msm_iommu.c @@ -407,9 +407,9 @@ struct msm_mmu *msm_iommu_new(struct device *dev, unsig= ned long quirks) struct msm_iommu *iommu; int ret; =20 - domain =3D iommu_domain_alloc(dev->bus); - if (!domain) - return NULL; + domain =3D iommu_paging_domain_alloc(dev); + if (IS_ERR(domain)) + return ERR_CAST(domain); =20 iommu_set_pgtable_quirks(domain, quirks); =20 @@ -441,7 +441,7 @@ struct msm_mmu *msm_iommu_gpu_new(struct device *dev, s= truct msm_gpu *gpu, unsig struct msm_mmu *mmu; =20 mmu =3D msm_iommu_new(dev, quirks); - if (IS_ERR_OR_NULL(mmu)) + if (IS_ERR(mmu)) return mmu; =20 iommu =3D to_msm_iommu(mmu); --=20 2.34.1 From nobody Fri Dec 19 19:38:55 2025 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.14]) (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 D2629161302 for ; Wed, 29 May 2024 05:36:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.14 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716960977; cv=none; b=X6wtpprOTp2ROupzAt4lp4W2u2qpiXkeFyF4UyBpJTACjlPyBw0ynQngZW3YRlu4JiJ9iDI3E31jyVnCyWgRT+dO23ksA0bXO/Ebiib8p4p9hYlovU75ssRgMnlaMkjLw9Gp9vtFF9p7FxvU38YjSH/D8/o9gkkRXT+xM2FyDfI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716960977; c=relaxed/simple; bh=GbpYXxZBS+r4Y0EiK3BFmXVZKaFfLeJ2IAlI0t0Upno=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=OfX0q0fu3MnW2JxIrJkSeS5aO0CUVsdSPXSrspo3d7hWJZPEfyB4KjPI5OOUvv1zRC9Yl0MKpGdWfHVE4DwEQCAdwSOU4Hbr5S2/iJc9KCPYD47yWC2zJS3VP94QxAqNAwWO4PnJWjrEV5amGL1XhMLAeqXOOPYMrfPCbFq2liI= 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=Wrh37zMd; arc=none smtp.client-ip=192.198.163.14 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="Wrh37zMd" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1716960976; x=1748496976; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=GbpYXxZBS+r4Y0EiK3BFmXVZKaFfLeJ2IAlI0t0Upno=; b=Wrh37zMdH2gkMq0VgNev7DfrlbEZhc8hFNNDvpKCbAdUsFXU+MAmBcfG TeAAt1jUPvrLhZibyfgBnTE3ZE+PryeHKoc9n9fQ1qwIDahAOD5TDIojv BcX2cOCs64Sp6nqinvRfGjA+ak7uweMiBPRZV810g2DK6FL58Gt0ew53t vfTumsIYdil4IcP5kLFKPoJ87U8zvgpRpHOKBK2UfM1ZXPicQRZjM3jjB 0GPzD/GwchuXEBHwGOpbofk6YU1r9PJ3t+X+yvEYri7UGhX1L2Rh8HEPm Tf7K9M5Wb1EDgPrnWQoo4tKvNMeaOEYVTZtSPv5Uyk9992cUwt1ioKpOJ g==; X-CSE-ConnectionGUID: /EWzymF9SAudKoGmAXHLfQ== X-CSE-MsgGUID: gOIRhg0DR0ms1qZp44f5Hg== X-IronPort-AV: E=McAfee;i="6600,9927,11085"; a="13568870" X-IronPort-AV: E=Sophos;i="6.08,197,1712646000"; d="scan'208";a="13568870" Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by fmvoesa108.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 May 2024 22:35:35 -0700 X-CSE-ConnectionGUID: 1de5gOz8RiiJc2GTEm4qYg== X-CSE-MsgGUID: P2dlEMyTRzOFmN4BYECPHg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,197,1712646000"; d="scan'208";a="35257612" Received: from unknown (HELO allen-box.sh.intel.com) ([10.239.159.127]) by fmviesa007.fm.intel.com with ESMTP; 28 May 2024 22:35:30 -0700 From: Lu Baolu To: Joerg Roedel , Will Deacon , Robin Murphy , Jason Gunthorpe , Kevin Tian Cc: Yi Liu , David Airlie , Daniel Vetter , Kalle Valo , Bjorn Andersson , Mathieu Poirier , Alex Williamson , mst@redhat.com, Jason Wang , Thierry Reding , Jonathan Hunter , Mikko Perttunen , iommu@lists.linux.dev, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Lu Baolu Subject: [PATCH 07/20] drm/nouveau/tegra: Use iommu_paging_domain_alloc() Date: Wed, 29 May 2024 13:32:37 +0800 Message-Id: <20240529053250.91284-8-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240529053250.91284-1-baolu.lu@linux.intel.com> References: <20240529053250.91284-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" In nvkm_device_tegra_probe_iommu(), a paging domain is allocated for @dev and attached to it on success. Use iommu_paging_domain_alloc() to make it explicit. Signed-off-by: Lu Baolu --- drivers/gpu/drm/nouveau/nvkm/engine/device/tegra.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/device/tegra.c b/drivers/g= pu/drm/nouveau/nvkm/engine/device/tegra.c index 87caa4a72921..763c4c2925f9 100644 --- a/drivers/gpu/drm/nouveau/nvkm/engine/device/tegra.c +++ b/drivers/gpu/drm/nouveau/nvkm/engine/device/tegra.c @@ -120,8 +120,8 @@ nvkm_device_tegra_probe_iommu(struct nvkm_device_tegra = *tdev) mutex_init(&tdev->iommu.mutex); =20 if (device_iommu_mapped(dev)) { - tdev->iommu.domain =3D iommu_domain_alloc(&platform_bus_type); - if (!tdev->iommu.domain) + tdev->iommu.domain =3D iommu_paging_domain_alloc(dev); + if (IS_ERR(tdev->iommu.domain)) goto error; =20 /* --=20 2.34.1 From nobody Fri Dec 19 19:38:55 2025 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.14]) (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 325BD1667E9 for ; Wed, 29 May 2024 05:36:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.14 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716960978; cv=none; b=KMfseZ1vX6HdfkgDcIRwdrbFU/gNyc6H6rwEI365AwmkNIxMO+ypiYVAwjfwaB8D5/A8rwl1F2T6KOtKY7sh5pziDSWo8h+KG9t71spDXxwfT4qQUqrNK3Hpdu+7xO0jLLN7DqxZv0PxMizJ92SQlvwDzhonWi4IEFF1sQsFzQY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716960978; c=relaxed/simple; bh=QPVW+nVXZ/Qv6phdysqv5NqIfLXG+N6nb5d8ku5/Eew=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=AvUM9yaded+hll6guNmqsiP0Qq5uji/Dc6/78GxTftskzFdJzpsbkJ4wUrBwP2C6Iyk8Dl6lB/BZQKpH4dCCeuTvIW9dEpixeMXxUqPy6dn0QthvykuV9Et/pEMInCXDdG7HfL5Qz+w7Deh963LdfOgBYQdtP5tSutUE8VD+4hs= 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=XHQA2cWS; arc=none smtp.client-ip=192.198.163.14 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="XHQA2cWS" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1716960977; x=1748496977; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=QPVW+nVXZ/Qv6phdysqv5NqIfLXG+N6nb5d8ku5/Eew=; b=XHQA2cWSSiifFWvxB9OB7xViBo4cg6hDxe6cZz0Y7OpR0G9Oi23ewhRB D+MAKKNXPoUldErORXJ9UQx2mUgI+8B5qfNPjnpfiraavPFTG3h0iXhJr TF9oTXDPFh24WFsKb6mL3RK8sCdZXuSCrLrbfV7wPKFnnYSAsAp2IOkGW j/M4T6M5/3uPXU9bEmEE6wxq2LwEmwxe1+zkY+MxxKXOQObSyPH75dlc7 VG94eZfr9nclPHVaEdTV4vNnmJrAuUNeeP9SHRxFZdSBIZk7A1GlVqlOd zVIo5PM6SkadqXFEA+7h4kyx9prIKBNPsKtWmlAPwSwjVTc+Kxun/60HL A==; X-CSE-ConnectionGUID: GgZT/OgEQmSBMl59BbPehw== X-CSE-MsgGUID: HrJxW03GT3yvOfoSTofVSQ== X-IronPort-AV: E=McAfee;i="6600,9927,11085"; a="13568911" X-IronPort-AV: E=Sophos;i="6.08,197,1712646000"; d="scan'208";a="13568911" Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by fmvoesa108.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 May 2024 22:35:39 -0700 X-CSE-ConnectionGUID: H0Tfydb8Sd2Y4vK78rZTQg== X-CSE-MsgGUID: ejihKNhgR8KfyMoR83nR7Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,197,1712646000"; d="scan'208";a="35257652" Received: from unknown (HELO allen-box.sh.intel.com) ([10.239.159.127]) by fmviesa007.fm.intel.com with ESMTP; 28 May 2024 22:35:34 -0700 From: Lu Baolu To: Joerg Roedel , Will Deacon , Robin Murphy , Jason Gunthorpe , Kevin Tian Cc: Yi Liu , David Airlie , Daniel Vetter , Kalle Valo , Bjorn Andersson , Mathieu Poirier , Alex Williamson , mst@redhat.com, Jason Wang , Thierry Reding , Jonathan Hunter , Mikko Perttunen , iommu@lists.linux.dev, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Lu Baolu Subject: [PATCH 08/20] gpu: host1x: Use iommu_paging_domain_alloc() Date: Wed, 29 May 2024 13:32:38 +0800 Message-Id: <20240529053250.91284-9-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240529053250.91284-1-baolu.lu@linux.intel.com> References: <20240529053250.91284-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" An iommu domain is allocated in host1x_iommu_attach() and is attached to host->dev. Use iommu_paging_domain_alloc() to make it explicit. Signed-off-by: Lu Baolu --- drivers/gpu/host1x/dev.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/host1x/dev.c b/drivers/gpu/host1x/dev.c index 3a0aaa68ac8d..46a2447c1124 100644 --- a/drivers/gpu/host1x/dev.c +++ b/drivers/gpu/host1x/dev.c @@ -404,9 +404,9 @@ static struct iommu_domain *host1x_iommu_attach(struct = host1x *host) if (err < 0) goto put_group; =20 - host->domain =3D iommu_domain_alloc(&platform_bus_type); - if (!host->domain) { - err =3D -ENOMEM; + host->domain =3D iommu_paging_domain_alloc(host->dev); + if (IS_ERR(host->domain)) { + err =3D PTR_ERR(host->domain); goto put_cache; } =20 --=20 2.34.1 From nobody Fri Dec 19 19:38:55 2025 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.14]) (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 DB8F61649D9 for ; Wed, 29 May 2024 05:36:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.14 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716960980; cv=none; b=Lrjmz/P30U034DoOIXzTXh3k1iYOJNbMy3JvsXGWXkzjzkP6yC/n32kbpc0MQgu+Oa3wXX6CtUhYh3Hom9hTvRgc3hq525v98mLiVV2cLzECYpZnTKQYHSBo6A9R/weEIcaMDdZJsoAbGMZzuneT0fPmSiKn+U8964LfUFvW4Ag= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716960980; c=relaxed/simple; bh=hTV3zLZE5NKCbs8//lAHn/CtYF9pijNjI3EBc1agx30=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=s4rqiDwhf6scYmxNnoAOx+fcwkYH/Qa0AoD14VXdwABA8BU8axDiQezjMfrt8jXN1/t6PMIBcYa3qov2Fz5ADH9vXffJKI77s/ZqiPN0jzuiXj1Xt7KNVm8TZ3dW3pmeY/uvDFeJUtC0bWeiU3J6z4+YYktImHYm+Une/8qsAgs= 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=Nn4bNbVy; arc=none smtp.client-ip=192.198.163.14 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="Nn4bNbVy" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1716960979; x=1748496979; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=hTV3zLZE5NKCbs8//lAHn/CtYF9pijNjI3EBc1agx30=; b=Nn4bNbVyfWKhqgeHV7gWX9hs07K47VC8XiQrMRMQ+omEEKSXxlmQljE2 zqVZYKWEAP89UrYZAwWS752r2jKQWpbVvx4WZbsjadgJGcbc/HOBsf3GT N1PDaYpXMkZjxCJOzekgk2xSzGmEuhMPjTxLC+BJ0C8VubUl6otbB4Cua wVjrvUqW2h0508Xpz7LjLQl4RhplGypMOi2TNrZsKqF0OuPc78wrkJG5X zkz9yi1YN0lUEA0yzSPrpR7gcOjtfERdTk8sexee7zSfoMh0fS0GwALhe gnNb1VBoj1FS3i1MImSs/GQ22BYLyqrtNu27yUQnN8GEk68fpxN1OFP+P w==; X-CSE-ConnectionGUID: 0fSMYQ5eR1CqeCHDE/jZ4w== X-CSE-MsgGUID: TpT/TAPLTCiY1i991cUsdA== X-IronPort-AV: E=McAfee;i="6600,9927,11085"; a="13568936" X-IronPort-AV: E=Sophos;i="6.08,197,1712646000"; d="scan'208";a="13568936" Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by fmvoesa108.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 May 2024 22:35:44 -0700 X-CSE-ConnectionGUID: +cDPAFDtQritcQaJ3GGFSA== X-CSE-MsgGUID: nDbXwaPeTiGGxvK7O/Ioeg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,197,1712646000"; d="scan'208";a="35257672" Received: from unknown (HELO allen-box.sh.intel.com) ([10.239.159.127]) by fmviesa007.fm.intel.com with ESMTP; 28 May 2024 22:35:39 -0700 From: Lu Baolu To: Joerg Roedel , Will Deacon , Robin Murphy , Jason Gunthorpe , Kevin Tian Cc: Yi Liu , David Airlie , Daniel Vetter , Kalle Valo , Bjorn Andersson , Mathieu Poirier , Alex Williamson , mst@redhat.com, Jason Wang , Thierry Reding , Jonathan Hunter , Mikko Perttunen , iommu@lists.linux.dev, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Lu Baolu Subject: [PATCH 09/20] media: nvidia: tegra: Use iommu_paging_domain_alloc() Date: Wed, 29 May 2024 13:32:39 +0800 Message-Id: <20240529053250.91284-10-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240529053250.91284-1-baolu.lu@linux.intel.com> References: <20240529053250.91284-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" An iommu domain is allocated in tegra_vde_iommu_init() and is attached to vde->dev. Use iommu_paging_domain_alloc() to make it explicit. Signed-off-by: Lu Baolu --- drivers/media/platform/nvidia/tegra-vde/iommu.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/media/platform/nvidia/tegra-vde/iommu.c b/drivers/medi= a/platform/nvidia/tegra-vde/iommu.c index 5521ed3e465f..5a41b5364238 100644 --- a/drivers/media/platform/nvidia/tegra-vde/iommu.c +++ b/drivers/media/platform/nvidia/tegra-vde/iommu.c @@ -78,9 +78,9 @@ int tegra_vde_iommu_init(struct tegra_vde *vde) arm_iommu_release_mapping(mapping); } #endif - vde->domain =3D iommu_domain_alloc(&platform_bus_type); - if (!vde->domain) { - err =3D -ENOMEM; + vde->domain =3D iommu_paging_domain_alloc(dev); + if (IS_ERR(vde->domain)) { + err =3D PTR_ERR(vde->domain); goto put_group; } =20 --=20 2.34.1 From nobody Fri Dec 19 19:38:56 2025 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.14]) (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 462E9168C05 for ; Wed, 29 May 2024 05:36:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.14 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716960981; cv=none; b=TMwnMKAhlxfWkQ3QAm3DznrbNsJpUOHbKPgvIiHLCH6qPrZiynzvhoR2J1E7zU6Vb72pp8iCXYsuKs9T/j/O86QYFSXTjzPRbDgABqN74Gj1Qs/JWulvhaNvVzRuZoC4+NgkyaxP/8eYSZNXyrq7X+T2j5k/WvSmkPOhyXE+vMw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716960981; c=relaxed/simple; bh=sQhpQrDpkr5d6QzI9UDmfi+nhpzVyW1CcaBVDpyFpuE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=OUEeOcttJtF93Se1g8xN08/D61h0h6Teep8v+qkaQ7O0jsKZe924ykH80hx6wypz6WB9uUDof5YB2VxAKw/PuBSZOpx4EB2S1ZopJQwlodEsEUsuCsEy/t568nLcezAZAvLfxxwAinDph/2TGNUoGzaRpkD5cQGAbRk8z72pO4s= 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=KiL+s0AP; arc=none smtp.client-ip=192.198.163.14 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="KiL+s0AP" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1716960980; x=1748496980; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=sQhpQrDpkr5d6QzI9UDmfi+nhpzVyW1CcaBVDpyFpuE=; b=KiL+s0APhHa4cQk7rUlYR/EqLgvuj1hDt3yVBexi1tmL78/kydZGGxyt Zpj+5ARBuGzNCKyx3dtTf2FzVrZhY2TvhZmjdVObrROJcKEfH9pn4L80U 8piDyhcwC+wDwWcBcgUmbGsxopq9irKlaWOTmT0D6+hbkD7qkGiJHPIPs q8mEpIBAL+7CH18DzcKYvpvYM5pWjPXeWhFFyKqANFCtLoSM7GqETZ3FA soefGYOe8XG65N992RdniAVp7iz2fE+DmUV/R53C2hIY07ZCBmRSEA1qH IA/nmXj2ENO42w6Lhg13g6PaJZ/0G4nctUGlwNP0HirGRuQpSzmFIe+Wl Q==; X-CSE-ConnectionGUID: nCBk/QS5QaG01QvWO/acEQ== X-CSE-MsgGUID: /YWiTWzRQv25UL2O+0j5bA== X-IronPort-AV: E=McAfee;i="6600,9927,11085"; a="13568966" X-IronPort-AV: E=Sophos;i="6.08,197,1712646000"; d="scan'208";a="13568966" Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by fmvoesa108.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 May 2024 22:35:49 -0700 X-CSE-ConnectionGUID: ibSOuVsuTWmBLKtjWng6DA== X-CSE-MsgGUID: w/ltsPfbRAaZqzlQJES1fQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,197,1712646000"; d="scan'208";a="35257682" Received: from unknown (HELO allen-box.sh.intel.com) ([10.239.159.127]) by fmviesa007.fm.intel.com with ESMTP; 28 May 2024 22:35:44 -0700 From: Lu Baolu To: Joerg Roedel , Will Deacon , Robin Murphy , Jason Gunthorpe , Kevin Tian Cc: Yi Liu , David Airlie , Daniel Vetter , Kalle Valo , Bjorn Andersson , Mathieu Poirier , Alex Williamson , mst@redhat.com, Jason Wang , Thierry Reding , Jonathan Hunter , Mikko Perttunen , iommu@lists.linux.dev, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Lu Baolu Subject: [PATCH 10/20] media: venus: firmware: Use iommu_paging_domain_alloc() Date: Wed, 29 May 2024 13:32:40 +0800 Message-Id: <20240529053250.91284-11-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240529053250.91284-1-baolu.lu@linux.intel.com> References: <20240529053250.91284-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" An iommu domain is allocated in venus_firmware_init() and is attached to core->fw.dev in the same function. Use iommu_paging_domain_alloc() to make it explicit. Signed-off-by: Lu Baolu --- drivers/media/platform/qcom/venus/firmware.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/media/platform/qcom/venus/firmware.c b/drivers/media/p= latform/qcom/venus/firmware.c index fe7da2b30482..66a18830e66d 100644 --- a/drivers/media/platform/qcom/venus/firmware.c +++ b/drivers/media/platform/qcom/venus/firmware.c @@ -316,10 +316,10 @@ int venus_firmware_init(struct venus_core *core) =20 core->fw.dev =3D &pdev->dev; =20 - iommu_dom =3D iommu_domain_alloc(&platform_bus_type); - if (!iommu_dom) { + iommu_dom =3D iommu_paging_domain_alloc(core->fw.dev); + if (IS_ERR(iommu_dom)) { dev_err(core->fw.dev, "Failed to allocate iommu domain\n"); - ret =3D -ENOMEM; + ret =3D PTR_ERR(iommu_dom); goto err_unregister; } =20 --=20 2.34.1 From nobody Fri Dec 19 19:38:56 2025 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.14]) (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 691B9168C30 for ; Wed, 29 May 2024 05:36:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.14 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716960982; cv=none; b=IxecGxOavo6MKnqKwzjrYEUUQ5KeqsK6T9LKDpR+9SbCxs6fYVE9jQa+AWyg5t1faj0Y8SCIoIjSy8U5b8Het+84ho34U3OFif8ilUn6lqdjyjnlbniYrkfIwOHhWOUSjRsO71/xybqPDJgpFjKC6S3/TWcgqgSP6PhJvgi72W8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716960982; c=relaxed/simple; bh=kv68qkR9q97yuL81djioGxxqJnKTS0o+E5D+XI6WQks=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=rOqTNXJov5Vod7RETYgZ6U/JRCVdC3gl8ta5JC+ztnQwbqDNt3M31vJO9kUe7ojN4Hy3wf3p443/kw8q44YAl3p65m8jIcavgsIXYmu8hsise2fiphX+JfncrfkL5vv1r8Cf4ArggQBr61IVVcr5MuxaI7sU/bxW4rjG+JoJ/uE= 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=HcQziK3t; arc=none smtp.client-ip=192.198.163.14 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="HcQziK3t" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1716960981; x=1748496981; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=kv68qkR9q97yuL81djioGxxqJnKTS0o+E5D+XI6WQks=; b=HcQziK3tU8ko5rBsD4T4oy7vsL7TH7tjnzBVa88FmSktuZJlFltrT1sj GGNKv1gLDi9hVohbJ8TGph1YSKXPT3ynNzkULpbtVq8s5q7L2Q6aAawq5 3/nDwaA5OpxpR+pPdW6tN3UU1PuMjfrUFy6oi9tqmxFdxC9lODcbEeZ8e 1MkI1nWvKHCOg6dU3f7YJ/jaCHLDkOIwqXSeifFN/M/rgUQExaOkY1hXN iJ2hNdoFdCtHgGSOph+FTSREP8e2DW52kOBJDM2PxLFkgL249iAtBewHH COxKPevdmKJ7fQasVLTCKtyduVdQh7tar10ytPYeP+qCFEss52fi3IJrj Q==; X-CSE-ConnectionGUID: gbNesxW2S52PsKRKQvw26A== X-CSE-MsgGUID: fm/zf7IESDO+2GkRgd47Aw== X-IronPort-AV: E=McAfee;i="6600,9927,11085"; a="13568996" X-IronPort-AV: E=Sophos;i="6.08,197,1712646000"; d="scan'208";a="13568996" Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by fmvoesa108.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 May 2024 22:35:53 -0700 X-CSE-ConnectionGUID: C5UxFXeCS62GXV5ofkH9mg== X-CSE-MsgGUID: 0gi2TYzwQaSnWJDrgXMwWA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,197,1712646000"; d="scan'208";a="35257688" Received: from unknown (HELO allen-box.sh.intel.com) ([10.239.159.127]) by fmviesa007.fm.intel.com with ESMTP; 28 May 2024 22:35:49 -0700 From: Lu Baolu To: Joerg Roedel , Will Deacon , Robin Murphy , Jason Gunthorpe , Kevin Tian Cc: Yi Liu , David Airlie , Daniel Vetter , Kalle Valo , Bjorn Andersson , Mathieu Poirier , Alex Williamson , mst@redhat.com, Jason Wang , Thierry Reding , Jonathan Hunter , Mikko Perttunen , iommu@lists.linux.dev, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Lu Baolu Subject: [PATCH 11/20] ath10k: Use iommu_paging_domain_alloc() Date: Wed, 29 May 2024 13:32:41 +0800 Message-Id: <20240529053250.91284-12-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240529053250.91284-1-baolu.lu@linux.intel.com> References: <20240529053250.91284-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" An iommu domain is allocated in ath10k_fw_init() and is attached to ar_snoc->fw.dev in the same function. Use iommu_paging_domain_alloc() to make it explicit. Signed-off-by: Lu Baolu --- drivers/net/wireless/ath/ath10k/snoc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/net/wireless/ath/ath10k/snoc.c b/drivers/net/wireless/= ath/ath10k/snoc.c index 8530550cf5df..0fe47d51013c 100644 --- a/drivers/net/wireless/ath/ath10k/snoc.c +++ b/drivers/net/wireless/ath/ath10k/snoc.c @@ -1635,10 +1635,10 @@ static int ath10k_fw_init(struct ath10k *ar) =20 ar_snoc->fw.dev =3D &pdev->dev; =20 - iommu_dom =3D iommu_domain_alloc(&platform_bus_type); - if (!iommu_dom) { + iommu_dom =3D iommu_paging_domain_alloc(ar_snoc->fw.dev); + if (IS_ERR(iommu_dom)) { ath10k_err(ar, "failed to allocate iommu domain\n"); - ret =3D -ENOMEM; + ret =3D PTR_ERR(iommu_dom); goto err_unregister; } =20 --=20 2.34.1 From nobody Fri Dec 19 19:38:56 2025 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.14]) (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 DD2BD169361 for ; Wed, 29 May 2024 05:36:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.14 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716960983; cv=none; b=Bz1Sgt7vv5TWLfxUfKkRPnMMaE0JirwxEYFFQHq2i3RzACxzl/LGecvzYtyYOOVA0TvhV0oo+SnyTCK7BykSWAdxpJC3sLeQc7aE8rG3HC0qGJbPG+xJQVJFpR0W3C4NqOqCgs+b/82FRthvn5yUGUcEUg9Z4ts6EAvSYGTrCfM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716960983; c=relaxed/simple; bh=b4g7oPuUpFCf7ehXVGbGAAANzK1lpGoRJJpR32Cbgc4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=dCoN4wbOc1twV5RTOL5l0ktpbqiJBxxAcEf+eR0vn7ffcyHJ4WoIPJ7W18+IfDti4XOqXHmhp31Yp4/nRTfkdZCHR0Lp75365T94j2ge5G88VGqoEn3hVk9GgOK57QT2pVhb+AvD7TRSv9Ny9GHd+8xB2K/Ke9U84Mg8gBfpGEY= 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=MtQRuAwV; arc=none smtp.client-ip=192.198.163.14 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="MtQRuAwV" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1716960982; x=1748496982; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=b4g7oPuUpFCf7ehXVGbGAAANzK1lpGoRJJpR32Cbgc4=; b=MtQRuAwVDwjaHlFy08UV2efRhFgL668SHjzjjOQ6h6LwkSe98pVEn+Pm 7Ccpv86MFUxka+FjC2IrhSQjTjqXY5KmhKLAt/lX53XNvEPZ/bFPuRXeF t5iCibF8Z+S2S//9GYL1dWLPwKP3faQnkh4u+OBJ+YiSP506pyB+fVL+O dnWiTwDFw8f29zziTo06+9PBi9lrVc2nnJ/t8OigYR73E+1FXz7ZPZk5S fP/jy6pq3fCO8fjNmrv2H/tlN68J8ZMPMJyluymCDyi4CHksK+bYRZDua gkVYnVYVRx5YJaiINQjE7nfSUJ1ZfrxS4mj11hZvrrcS7ScA63JeGFfmP w==; X-CSE-ConnectionGUID: ia63W5EGT56wWlHk+88+AQ== X-CSE-MsgGUID: d8kRWINnSd+aDbBwXzIDHw== X-IronPort-AV: E=McAfee;i="6600,9927,11085"; a="13569008" X-IronPort-AV: E=Sophos;i="6.08,197,1712646000"; d="scan'208";a="13569008" Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by fmvoesa108.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 May 2024 22:35:58 -0700 X-CSE-ConnectionGUID: V3zZjpVoRS2Q2WQoWQMxtQ== X-CSE-MsgGUID: 5T9hg/jYScSPheKhITTpNw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,197,1712646000"; d="scan'208";a="35257707" Received: from unknown (HELO allen-box.sh.intel.com) ([10.239.159.127]) by fmviesa007.fm.intel.com with ESMTP; 28 May 2024 22:35:53 -0700 From: Lu Baolu To: Joerg Roedel , Will Deacon , Robin Murphy , Jason Gunthorpe , Kevin Tian Cc: Yi Liu , David Airlie , Daniel Vetter , Kalle Valo , Bjorn Andersson , Mathieu Poirier , Alex Williamson , mst@redhat.com, Jason Wang , Thierry Reding , Jonathan Hunter , Mikko Perttunen , iommu@lists.linux.dev, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Lu Baolu Subject: [PATCH 12/20] wifi: ath11k: Use iommu_paging_domain_alloc() Date: Wed, 29 May 2024 13:32:42 +0800 Message-Id: <20240529053250.91284-13-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240529053250.91284-1-baolu.lu@linux.intel.com> References: <20240529053250.91284-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" An iommu domain is allocated in ath11k_ahb_fw_resources_init() and is attached to ab_ahb->fw.dev in the same function. Use iommu_paging_domain_alloc() to make it explicit. Signed-off-by: Lu Baolu --- drivers/net/wireless/ath/ath11k/ahb.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/net/wireless/ath/ath11k/ahb.c b/drivers/net/wireless/a= th/ath11k/ahb.c index ca0f17ddebba..a469647719f9 100644 --- a/drivers/net/wireless/ath/ath11k/ahb.c +++ b/drivers/net/wireless/ath/ath11k/ahb.c @@ -1001,10 +1001,10 @@ static int ath11k_ahb_fw_resources_init(struct ath1= 1k_base *ab) =20 ab_ahb->fw.dev =3D &pdev->dev; =20 - iommu_dom =3D iommu_domain_alloc(&platform_bus_type); - if (!iommu_dom) { + iommu_dom =3D iommu_paging_domain_alloc(ab_ahb->fw.dev); + if (IS_ERR(iommu_dom)) { ath11k_err(ab, "failed to allocate iommu domain\n"); - ret =3D -ENOMEM; + ret =3D PTR_ERR(iommu_dom); goto err_unregister; } =20 --=20 2.34.1 From nobody Fri Dec 19 19:38:56 2025 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.14]) (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 8FD7C16937D for ; Wed, 29 May 2024 05:36:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.14 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716960983; cv=none; b=NE4hEIcNlr7MSe1EghFNtx8vDR0dyKv16uc3qmnFlIIvLRVUMthZtxqplR28d8JE6zSxniUS7d+wg/iTtM9qWqk84Cd0TwSGp+lVfl5PjPU+KLO+NnEO4Yr+jDM7Pspa7DimJZ8ZYwwfZtR5PdK2X/HskqiMdUVpODMWBV60TKY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716960983; c=relaxed/simple; bh=kDJcZN33ntEvZZurzXrpsoEVgCNzk8vicnqImPO/kUg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=pkzs+9JOVOTSq2c70QZRgd47yGND/X9tKB8+0Llsovcoqsq5YATypEXRyIJEaTjkH2RI0x7AfVd/YpPkASk6Th4R/KYxd5ScDt3vdLv/vIwnOxYB/KlOtyCr1M3gPelizvaLEcXDBXJjFu9x1x7dAV1OqnTAxkmreBU1pdlyIZs= 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=msjvBQ5A; arc=none smtp.client-ip=192.198.163.14 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="msjvBQ5A" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1716960983; x=1748496983; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=kDJcZN33ntEvZZurzXrpsoEVgCNzk8vicnqImPO/kUg=; b=msjvBQ5AeugDg2h9Q2H01zTo32O0iQ378MU/i/0agnkuU87UDqLyRChX qtcWy10Bg96qx/1T/5gIhLoHvDJFOOu75rkavxZcQehc43uY1DHz4dMED sMp1BJUa1ioM1vjvMVqvUJQHRb6MspKgbIK+wfY88RtsgdMhUHGpXQUNO yYJvnBRbI+U84kac3mRs/zucx6ygM6FbLXdHd2he84mFHWsOohnoMf2Eq bapb0/xlP+guMaCDP4+reEDm5g5LK+WJUY1fAt4wiSEUNzqeoB9TamKo0 AzfuogObITrY5yFDrkTygL+xoGVMn6kyWzO4LjJ4/UiJTrj4F95+BnnZ4 g==; X-CSE-ConnectionGUID: t1L+z4u0T46qjzZBu1SUXA== X-CSE-MsgGUID: c2v95/S0SEqR6AokqfE4xw== X-IronPort-AV: E=McAfee;i="6600,9927,11085"; a="13569021" X-IronPort-AV: E=Sophos;i="6.08,197,1712646000"; d="scan'208";a="13569021" Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by fmvoesa108.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 May 2024 22:36:03 -0700 X-CSE-ConnectionGUID: ENb7rn90RI6j1x4NRe3Etw== X-CSE-MsgGUID: Ih7YA2CfRI2pwJKPhSeR1g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,197,1712646000"; d="scan'208";a="35257728" Received: from unknown (HELO allen-box.sh.intel.com) ([10.239.159.127]) by fmviesa007.fm.intel.com with ESMTP; 28 May 2024 22:35:58 -0700 From: Lu Baolu To: Joerg Roedel , Will Deacon , Robin Murphy , Jason Gunthorpe , Kevin Tian Cc: Yi Liu , David Airlie , Daniel Vetter , Kalle Valo , Bjorn Andersson , Mathieu Poirier , Alex Williamson , mst@redhat.com, Jason Wang , Thierry Reding , Jonathan Hunter , Mikko Perttunen , iommu@lists.linux.dev, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Lu Baolu Subject: [PATCH 13/20] remoteproc: Use iommu_paging_domain_alloc() Date: Wed, 29 May 2024 13:32:43 +0800 Message-Id: <20240529053250.91284-14-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240529053250.91284-1-baolu.lu@linux.intel.com> References: <20240529053250.91284-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" An iommu domain is allocated in rproc_enable_iommu() and is attached to rproc->dev.parent in the same function. Use iommu_paging_domain_alloc() to make it explicit. Signed-off-by: Lu Baolu --- drivers/remoteproc/remoteproc_core.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remo= teproc_core.c index f276956f2c5c..eb66f78ec8b7 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -109,10 +109,10 @@ static int rproc_enable_iommu(struct rproc *rproc) return 0; } =20 - domain =3D iommu_domain_alloc(dev->bus); - if (!domain) { + domain =3D iommu_paging_domain_alloc(dev); + if (IS_ERR(domain)) { dev_err(dev, "can't alloc iommu domain\n"); - return -ENOMEM; + return PTR_ERR(domain); } =20 iommu_set_fault_handler(domain, rproc_iommu_fault, rproc); --=20 2.34.1 From nobody Fri Dec 19 19:38:56 2025 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.14]) (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 0D454169ADC for ; Wed, 29 May 2024 05:36:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.14 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716960985; cv=none; b=OaTZSK3ZfNHjqmD6R6vWfFBpEkxkWqUWXx41yG/G/eu4/tbZ/v5Wndf/VEF3TshKTB7eVrJNDZ3q4R6lb/gMX4fTmj5bQwoMslQV/HJlrwQbvEvWhVbi9btgoq+e4Db/KgWx8mZ/A9ksw42flTQV8wCtdiZ9ea74qo5Q3fJc7fw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716960985; c=relaxed/simple; bh=Qwe6Nm71KNXy5AzCovPyBLpaZan5bLchb/yuvu+UWlE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=HKixls+Q0VeWca5nc/Ju2/66oyx0b4OPRAKINwp42cJtqNaYAIpZNxsNOiNzTBfOnM9yeIlS6jHyMGuVVdPSH+DQmkFFC2y4ey0h4dMtAlga66VJGx5I/Av7DAAlSdgkTRlfaS+SDZ7qcosuxQ5Z7TK7Ds1CQRHRb8iDjEZYplw= 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=NtjhazK5; arc=none smtp.client-ip=192.198.163.14 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="NtjhazK5" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1716960984; x=1748496984; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Qwe6Nm71KNXy5AzCovPyBLpaZan5bLchb/yuvu+UWlE=; b=NtjhazK5Rywpw2NEiFC/blbpW74vNqvo02C+dqiVeF2rpvzAnJZSUD9+ akvkUQXv0xcwP/32JWC45zNcaoAKcuVTA17ZbGvpWJQEDJ8rLp2YaLRG3 A94miWyW1DV7ZeJOCwYQaxJ9ysn+FbdWXDsPvoNRiZbybcZkMM6aBTyZn BXkurbenLinTJ2IUMRSa5Mx2lpsn8usov/zBZseQXSpX3cdEbA4/x/rcQ fxWuoc1C6PSmr762i6Nn/rNiUtqXDErLnmUHFhKcufOBuo2WYdZOB+u3q Lob3JwHHJbawR1ZWI3UR+1+5BjZBJ51xkTP5HIiA+0/4Se2P3JvR5KXHl A==; X-CSE-ConnectionGUID: 1gQzEs29SNuI6xl9oEoibA== X-CSE-MsgGUID: dOOBbrOHTASpPeeN18QgDA== X-IronPort-AV: E=McAfee;i="6600,9927,11085"; a="13569038" X-IronPort-AV: E=Sophos;i="6.08,197,1712646000"; d="scan'208";a="13569038" Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by fmvoesa108.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 May 2024 22:36:08 -0700 X-CSE-ConnectionGUID: 0bpDLxsuTtajCtyXoTqBTA== X-CSE-MsgGUID: Gw6ILwkESJ6yAzh0j9S2wA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,197,1712646000"; d="scan'208";a="35257745" Received: from unknown (HELO allen-box.sh.intel.com) ([10.239.159.127]) by fmviesa007.fm.intel.com with ESMTP; 28 May 2024 22:36:03 -0700 From: Lu Baolu To: Joerg Roedel , Will Deacon , Robin Murphy , Jason Gunthorpe , Kevin Tian Cc: Yi Liu , David Airlie , Daniel Vetter , Kalle Valo , Bjorn Andersson , Mathieu Poirier , Alex Williamson , mst@redhat.com, Jason Wang , Thierry Reding , Jonathan Hunter , Mikko Perttunen , iommu@lists.linux.dev, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Lu Baolu Subject: [PATCH 14/20] soc/fsl/qbman: Use iommu_paging_domain_alloc() Date: Wed, 29 May 2024 13:32:44 +0800 Message-Id: <20240529053250.91284-15-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240529053250.91284-1-baolu.lu@linux.intel.com> References: <20240529053250.91284-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" An iommu domain is allocated in portal_set_cpu() and is attached to pcfg->dev in the same function. Use iommu_paging_domain_alloc() to make it explicit. Signed-off-by: Lu Baolu --- drivers/soc/fsl/qbman/qman_portal.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/soc/fsl/qbman/qman_portal.c b/drivers/soc/fsl/qbman/qm= an_portal.c index e23b60618c1a..91f17cea3744 100644 --- a/drivers/soc/fsl/qbman/qman_portal.c +++ b/drivers/soc/fsl/qbman/qman_portal.c @@ -48,8 +48,8 @@ static void portal_set_cpu(struct qm_portal_config *pcfg,= int cpu) struct device *dev =3D pcfg->dev; int ret; =20 - pcfg->iommu_domain =3D iommu_domain_alloc(&platform_bus_type); - if (!pcfg->iommu_domain) { + pcfg->iommu_domain =3D iommu_paging_domain_alloc(dev); + if (IS_ERR(pcfg->iommu_domain)) { dev_err(dev, "%s(): iommu_domain_alloc() failed", __func__); goto no_iommu; } --=20 2.34.1 From nobody Fri Dec 19 19:38:56 2025 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.14]) (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 0C5BF16A36D for ; Wed, 29 May 2024 05:36:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.14 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716960988; cv=none; b=nZ/lz/ks2W2JvNjjSb3r6/g5qXYx+LSayojnvdwjIWF0nL3yzwsJNOEIDLbY6h9ohbkPW4WN7UBQBuN2g3TqRh9CQ9D82r85T9KXgZQzp9AFGaoOccDrfptYzo+oyg1Tu8hKJW9rKHPByiikf+cFdU9qkwxfMiaIn9FbUmnAFC8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716960988; c=relaxed/simple; bh=kAf7SPBLso5zp49wUYubqs0YKzd/lC+tt+i0+MOxu64=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=jd86ZU6mlXlpTkXmqTm2M8hXaoNmLLSXtvRmNjbNr8NiX/JZIzSPZn5mlJ1bmvUbIOkG5KQZNkz5Mr6QWRAF76B3lWNS4YdDsR8XsYXFPHqLioBPBCy5HwfoMLEOR4imMA2FVQvlIbVk9Gh7ZAYehrf1pphzwFOFgP1VdIDd8iU= 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=cPb1tEpP; arc=none smtp.client-ip=192.198.163.14 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="cPb1tEpP" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1716960987; x=1748496987; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=kAf7SPBLso5zp49wUYubqs0YKzd/lC+tt+i0+MOxu64=; b=cPb1tEpPZcXN2opL0krE7oHdFJVjBHYvf8Opyhfe2vta2Dlz5K6w87az wLnSIC/o2IwU4bU1qCl4K0ACweiOOjuhvnz/D6I256lJkQ0OMIBER0M9M EyzpsLCycwjqORZntf3YMkHDEWlzcGeGv4L2u5yZ7uswENy/4UkHjztfQ S/jDOHPo/+5uP7pGwbiP5IpSujhUqmSiaNE+9uvujc0MywSkykEdLqZTR n6UjRqWtLsHoBQMuloLhLs1hl0/gP9Yqxs5qlqLTmUDHDkttlFf3Or1Md h/LYqasIL8nZNJj2vfyWyOc5qManwLmJxt85HPr8jbvLuJBI2U4oAwNoB w==; X-CSE-ConnectionGUID: mJDRITGyQi2GWrdD2WVXSg== X-CSE-MsgGUID: NBnqpYlhQvOAkwYbWABSFw== X-IronPort-AV: E=McAfee;i="6600,9927,11085"; a="13569053" X-IronPort-AV: E=Sophos;i="6.08,197,1712646000"; d="scan'208";a="13569053" Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by fmvoesa108.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 May 2024 22:36:12 -0700 X-CSE-ConnectionGUID: cCZToLUCTQGJ9JPHPmk0WA== X-CSE-MsgGUID: 3EA9i3ihQEyIhlN5IVrqow== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,197,1712646000"; d="scan'208";a="35257754" Received: from unknown (HELO allen-box.sh.intel.com) ([10.239.159.127]) by fmviesa007.fm.intel.com with ESMTP; 28 May 2024 22:36:07 -0700 From: Lu Baolu To: Joerg Roedel , Will Deacon , Robin Murphy , Jason Gunthorpe , Kevin Tian Cc: Yi Liu , David Airlie , Daniel Vetter , Kalle Valo , Bjorn Andersson , Mathieu Poirier , Alex Williamson , mst@redhat.com, Jason Wang , Thierry Reding , Jonathan Hunter , Mikko Perttunen , iommu@lists.linux.dev, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Lu Baolu Subject: [PATCH 15/20] iommu/vt-d: Add helper to allocate paging domain Date: Wed, 29 May 2024 13:32:45 +0800 Message-Id: <20240529053250.91284-16-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240529053250.91284-1-baolu.lu@linux.intel.com> References: <20240529053250.91284-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" The domain_alloc_user operation is currently implemented by allocating a paging domain using iommu_domain_alloc(). This is because it needs to fully initialize the domain before return. Add a helper to do this to avoid using iommu_domain_alloc(). Signed-off-by: Lu Baolu --- drivers/iommu/intel/iommu.c | 87 +++++++++++++++++++++++++++++++++---- 1 file changed, 78 insertions(+), 9 deletions(-) diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c index 2e9811bf2a4e..ccde5f5972e4 100644 --- a/drivers/iommu/intel/iommu.c +++ b/drivers/iommu/intel/iommu.c @@ -3633,6 +3633,79 @@ static struct iommu_domain blocking_domain =3D { } }; =20 +static int iommu_superpage_capability(struct intel_iommu *iommu, bool firs= t_stage) +{ + if (!intel_iommu_superpage) + return 0; + + if (first_stage) + return cap_fl1gp_support(iommu->cap) ? 2 : 1; + + return fls(cap_super_page_val(iommu->cap)); +} + +static struct dmar_domain *paging_domain_alloc(struct device *dev, bool fi= rst_stage) +{ + struct device_domain_info *info =3D dev_iommu_priv_get(dev); + struct intel_iommu *iommu =3D info->iommu; + struct dmar_domain *domain; + int addr_width; + + domain =3D kzalloc(sizeof(*domain), GFP_KERNEL); + if (!domain) + return ERR_PTR(-ENOMEM); + + INIT_LIST_HEAD(&domain->devices); + INIT_LIST_HEAD(&domain->dev_pasids); + INIT_LIST_HEAD(&domain->cache_tags); + spin_lock_init(&domain->lock); + spin_lock_init(&domain->cache_lock); + xa_init(&domain->iommu_array); + + domain->nid =3D dev_to_node(dev); + domain->has_iotlb_device =3D info->ats_enabled; + domain->use_first_level =3D first_stage; + + /* calculate the address width */ + addr_width =3D agaw_to_width(iommu->agaw); + if (addr_width > cap_mgaw(iommu->cap)) + addr_width =3D cap_mgaw(iommu->cap); + domain->gaw =3D addr_width; + domain->agaw =3D iommu->agaw; + domain->max_addr =3D __DOMAIN_MAX_ADDR(addr_width); + + /* iommu memory access coherency */ + domain->iommu_coherency =3D iommu_paging_structure_coherency(iommu); + + /* pagesize bitmap */ + domain->domain.pgsize_bitmap =3D SZ_4K; + domain->iommu_superpage =3D iommu_superpage_capability(iommu, first_stage= ); + domain->domain.pgsize_bitmap |=3D domain_super_pgsize_bitmap(domain); + + /* + * IOVA aperture: First-level translation restricts the input-address + * to a canonical address (i.e., address bits 63:N have the same value + * as address bit [N-1], where N is 48-bits with 4-level paging and + * 57-bits with 5-level paging). Hence, skip bit [N-1]. + */ + domain->domain.geometry.force_aperture =3D true; + domain->domain.geometry.aperture_start =3D 0; + if (first_stage) + domain->domain.geometry.aperture_end =3D __DOMAIN_MAX_ADDR(domain->gaw -= 1); + else + domain->domain.geometry.aperture_end =3D __DOMAIN_MAX_ADDR(domain->gaw); + + /* always allocate the top pgd */ + domain->pgd =3D iommu_alloc_page_node(domain->nid, GFP_KERNEL); + if (!domain->pgd) { + kfree(domain); + return ERR_PTR(-ENOMEM); + } + domain_flush_cache(domain, domain->pgd, PAGE_SIZE); + + return domain; +} + static struct iommu_domain *intel_iommu_domain_alloc(unsigned type) { struct dmar_domain *dmar_domain; @@ -3695,15 +3768,11 @@ intel_iommu_domain_alloc_user(struct device *dev, u= 32 flags, if (user_data || (dirty_tracking && !ssads_supported(iommu))) return ERR_PTR(-EOPNOTSUPP); =20 - /* - * domain_alloc_user op needs to fully initialize a domain before - * return, so uses iommu_domain_alloc() here for simple. - */ - domain =3D iommu_domain_alloc(dev->bus); - if (!domain) - return ERR_PTR(-ENOMEM); - - dmar_domain =3D to_dmar_domain(domain); + /* Do not use first stage for user domain translation. */ + dmar_domain =3D paging_domain_alloc(dev, false); + if (IS_ERR(dmar_domain)) + return ERR_CAST(dmar_domain); + domain =3D &dmar_domain->domain; =20 if (nested_parent) { dmar_domain->nested_parent =3D true; --=20 2.34.1 From nobody Fri Dec 19 19:38:56 2025 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.14]) (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 6743116D4D6 for ; Wed, 29 May 2024 05:36:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.14 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716960990; cv=none; b=YjTPVhBjMVIAZ7gvSD1AZyEmdiuA6eB3wXRvULm94Y8r/i45ytuVGwNn/9Y8XPHAPZfJ8vyPrm7nLiIW09KmIN/UgL3dd/R5RLOPQDrocq/C6KVPRPZx3MEdmCiko9VEl/JdZuhSCDFeGM7m6KO77nOxxY9i0/2J67GxrwNIRYw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716960990; c=relaxed/simple; bh=5ePUNFSt1UVyBK/XkIEBW5JIdBwW2K6T9xjoabFYw84=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Kgy/1+OvWyWcBPwCqv51g0LMLSuPsC3xOcO1GTYpatXj5VVsCyvBLJRi8YVLeH83n/DwuF1hDK784tUHTZYi3upbHZ6D5ui3zxZtg6nPokvfVNf72yiTI1kKNXrJMkEviCeH+GGAsUJ+88IyAsw+w+WvjODIagqGD+i1pWy6i2E= 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=W7NE/xLs; arc=none smtp.client-ip=192.198.163.14 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="W7NE/xLs" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1716960989; x=1748496989; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=5ePUNFSt1UVyBK/XkIEBW5JIdBwW2K6T9xjoabFYw84=; b=W7NE/xLsCxwvKNge2GQYuVBqoDqq3snFCbMtBtFSZqSDL05qAjqSr6So zR5jfBCMkUWs2Wq+P8C2Bls9OBMLvQGdH67z0uUno95Ggm644+VD9aLsj sQYwEBTROs3qZ+egGx+pnt8qPVC/kmfhA6SZmChgPj1JttNTOg8DP6pCE y4zB4kQ1NK/pjAN1rq1dWjnfp+280O9u0HhylLN16Dk2CPs136ODTSGkY 9ww6bNJEy53AswhRPgbFt2z6P7Veis6apcObLjE5adw7yz2lKhZug0yV4 10UOn9NilMBD4Q5b/P/tfYwDbhC/7KEWTiNzICt2dZfbXuyPqQe+VzzfX w==; X-CSE-ConnectionGUID: N7FNK+P4QU+wgpICv643LQ== X-CSE-MsgGUID: xJB+Qsh1RTaeAtvhuj0A2g== X-IronPort-AV: E=McAfee;i="6600,9927,11085"; a="13569068" X-IronPort-AV: E=Sophos;i="6.08,197,1712646000"; d="scan'208";a="13569068" Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by fmvoesa108.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 May 2024 22:36:18 -0700 X-CSE-ConnectionGUID: bMLT6m7ZQya8CnSU5hJh7Q== X-CSE-MsgGUID: X6Uf2wUXQVWNu0/eZhCs2A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,197,1712646000"; d="scan'208";a="35257765" Received: from unknown (HELO allen-box.sh.intel.com) ([10.239.159.127]) by fmviesa007.fm.intel.com with ESMTP; 28 May 2024 22:36:12 -0700 From: Lu Baolu To: Joerg Roedel , Will Deacon , Robin Murphy , Jason Gunthorpe , Kevin Tian Cc: Yi Liu , David Airlie , Daniel Vetter , Kalle Valo , Bjorn Andersson , Mathieu Poirier , Alex Williamson , mst@redhat.com, Jason Wang , Thierry Reding , Jonathan Hunter , Mikko Perttunen , iommu@lists.linux.dev, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Lu Baolu Subject: [PATCH 16/20] iommu/vt-d: Add domain_alloc_paging support Date: Wed, 29 May 2024 13:32:46 +0800 Message-Id: <20240529053250.91284-17-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240529053250.91284-1-baolu.lu@linux.intel.com> References: <20240529053250.91284-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" Move paging domain allocation code out from intel_iommu_domain_alloc(). The intel_iommu_domain_alloc() is still remaining to allocate an identity domain. However, it will soon disappear as we are about to convert the identity domain to a global static one. Signed-off-by: Lu Baolu --- drivers/iommu/intel/iommu.c | 50 ++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 28 deletions(-) diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c index ccde5f5972e4..eb8e08699b80 100644 --- a/drivers/iommu/intel/iommu.c +++ b/drivers/iommu/intel/iommu.c @@ -3708,35 +3708,8 @@ static struct dmar_domain *paging_domain_alloc(struc= t device *dev, bool first_st =20 static struct iommu_domain *intel_iommu_domain_alloc(unsigned type) { - struct dmar_domain *dmar_domain; - struct iommu_domain *domain; - - switch (type) { - case IOMMU_DOMAIN_DMA: - case IOMMU_DOMAIN_UNMANAGED: - dmar_domain =3D alloc_domain(type); - if (!dmar_domain) { - pr_err("Can't allocate dmar_domain\n"); - return NULL; - } - if (md_domain_init(dmar_domain, DEFAULT_DOMAIN_ADDRESS_WIDTH)) { - pr_err("Domain initialization failed\n"); - domain_exit(dmar_domain); - return NULL; - } - - domain =3D &dmar_domain->domain; - domain->geometry.aperture_start =3D 0; - domain->geometry.aperture_end =3D - __DOMAIN_MAX_ADDR(dmar_domain->gaw); - domain->geometry.force_aperture =3D true; - - return domain; - case IOMMU_DOMAIN_IDENTITY: + if (type =3D=3D IOMMU_DOMAIN_IDENTITY) return &si_domain->domain; - default: - return NULL; - } =20 return NULL; } @@ -3791,6 +3764,26 @@ intel_iommu_domain_alloc_user(struct device *dev, u3= 2 flags, return domain; } =20 +static struct iommu_domain *intel_iommu_domain_alloc_paging(struct device = *dev) +{ + struct dmar_domain *dmar_domain; + struct device_domain_info *info; + struct intel_iommu *iommu; + + /* Do not support the legacy iommu_domain_alloc() interface. */ + if (!dev) + return ERR_PTR(-ENODEV); + + info =3D dev_iommu_priv_get(dev); + iommu =3D info->iommu; + dmar_domain =3D paging_domain_alloc(dev, + sm_supported(iommu) && ecap_flts(iommu->ecap)); + if (IS_ERR(dmar_domain)) + return ERR_CAST(dmar_domain); + + return &dmar_domain->domain; +} + static void intel_iommu_domain_free(struct iommu_domain *domain) { struct dmar_domain *dmar_domain =3D to_dmar_domain(domain); @@ -4650,6 +4643,7 @@ const struct iommu_ops intel_iommu_ops =3D { .domain_alloc =3D intel_iommu_domain_alloc, .domain_alloc_user =3D intel_iommu_domain_alloc_user, .domain_alloc_sva =3D intel_svm_domain_alloc, + .domain_alloc_paging =3D intel_iommu_domain_alloc_paging, .probe_device =3D intel_iommu_probe_device, .release_device =3D intel_iommu_release_device, .get_resv_regions =3D intel_iommu_get_resv_regions, --=20 2.34.1 From nobody Fri Dec 19 19:38:56 2025 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.14]) (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 95E0215CD7C for ; Wed, 29 May 2024 05:36:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.14 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716960990; cv=none; b=uVchahVuJkPmf8j8eRzv2NayQjztIX3Sno406oQe7Qa5gp8I/PX4Z48av9hHwG+nnp2bWT5HqzcxJYM6br4Bp63nGInTUKxApYEUTANwABGLABP9k1/vwoESUa+zF0BMaxLXrMUj7vcLSAfI3incW5ppKO/MKYatjRYWewkwjbc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716960990; c=relaxed/simple; bh=kMsYOm7U7Zn12dWdb7SeO0fPM3MLpopXhwDJqBymYTM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=SJ04VewA86tAbL3UAvkLpmGly7s2urSG5fM7V2HVwD9Bi+kmaEz/0Q7N2AzSTQ85sUCIJ8vzRMsHLIeh4VlrcJv27R/AIVuDsxMO8kmNuvnQneYlG1DqDNUhe01c3kvmGpTfaqao37c4U0ZecaehNcOm0wFCIJNTc3a4aq+XqII= 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=KD6w92b5; arc=none smtp.client-ip=192.198.163.14 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="KD6w92b5" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1716960990; x=1748496990; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=kMsYOm7U7Zn12dWdb7SeO0fPM3MLpopXhwDJqBymYTM=; b=KD6w92b591ULTsCPBxdeTYPBBGUbUiWfw567/e+elWWAzafFt/mpIrmP LC6pAyRe8A1b2/9iKwSk6jX26MLFzKqJeBs9c/IWQzI6mxd20NY80c0qm jrx8Wu2ccIOV5mXzF7B8gsmkxccs3ksg0QIW9eFuWr+5um27brlnfBYMU hOEVtPNkS/GdIDCOBPmw4im9JSU+ZkowDgr91s9piw7hUvkGBF0l+uudS 89jft2Rq4GT88uKPsBWH1YGgxOvr9+Zr5lC6JvOTz4AxX8R0u2xiBrbMs ZqU8f+5luoYv9i/RgLDO7jxlvTcV3fU3iKrFGBSdXQZdWtQElzZBF8cR4 A==; X-CSE-ConnectionGUID: +rSdfmSTS0KmxbZi4QBd1A== X-CSE-MsgGUID: M7Z02lI1TUO3T52ZFp8UGw== X-IronPort-AV: E=McAfee;i="6600,9927,11085"; a="13569082" X-IronPort-AV: E=Sophos;i="6.08,197,1712646000"; d="scan'208";a="13569082" Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by fmvoesa108.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 May 2024 22:36:23 -0700 X-CSE-ConnectionGUID: ImXU7FqzTUizFrnygOVsyA== X-CSE-MsgGUID: buiM+0knQZG9v/S3HkrdEw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,197,1712646000"; d="scan'208";a="35257777" Received: from unknown (HELO allen-box.sh.intel.com) ([10.239.159.127]) by fmviesa007.fm.intel.com with ESMTP; 28 May 2024 22:36:18 -0700 From: Lu Baolu To: Joerg Roedel , Will Deacon , Robin Murphy , Jason Gunthorpe , Kevin Tian Cc: Yi Liu , David Airlie , Daniel Vetter , Kalle Valo , Bjorn Andersson , Mathieu Poirier , Alex Williamson , mst@redhat.com, Jason Wang , Thierry Reding , Jonathan Hunter , Mikko Perttunen , iommu@lists.linux.dev, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Lu Baolu Subject: [PATCH 17/20] iommu/vt-d: Simplify compatibility check for identity domain Date: Wed, 29 May 2024 13:32:47 +0800 Message-Id: <20240529053250.91284-18-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240529053250.91284-1-baolu.lu@linux.intel.com> References: <20240529053250.91284-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" Currently, the identity domain attachment follows the same path as the paging domain attachment and is subject to the same compatibility checks as a normal paging domain. However, this level of check is unnecessary for the identity domain since it only requires the hardware to support passthrough mode, which is a given for modern hardware. On the early VT-d platforms, where hardware passthrough mode is not yet supported, the identity domain is supported by a makeshift paging domain with the entire system memory 1:1 mapped. For such early hardware, the appropriate domain type should be returned in device_def_domain_type(), and the identity domain should be simplified in compatibility checks. The identity domain workaround in prepare_domain_attach_device() is just temporary and should be removed once the identity domain is converted to have its own dedicated attachment path. Signed-off-by: Lu Baolu --- drivers/iommu/intel/iommu.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c index eb8e08699b80..693a6d7c79ed 100644 --- a/drivers/iommu/intel/iommu.c +++ b/drivers/iommu/intel/iommu.c @@ -2190,6 +2190,16 @@ static bool device_rmrr_is_relaxable(struct device *= dev) */ static int device_def_domain_type(struct device *dev) { + struct device_domain_info *info =3D dev_iommu_priv_get(dev); + struct intel_iommu *iommu =3D info->iommu; + + /* + * Hardware does not support the passthrough translation mode. + * Always use a dynamaic mapping domain. + */ + if (!ecap_pass_through(iommu->ecap)) + return IOMMU_DOMAIN_DMA; + if (dev_is_pci(dev)) { struct pci_dev *pdev =3D to_pci_dev(dev); =20 @@ -3802,6 +3812,14 @@ int prepare_domain_attach_device(struct iommu_domain= *domain, struct intel_iommu *iommu =3D info->iommu; int addr_width; =20 + /* + * This is a temporary solution as the identity domain attachment + * goes through this path as well. It should be removed once the + * identity domain has its own attach path. + */ + if (domain->type =3D=3D IOMMU_DOMAIN_IDENTITY) + return ecap_pass_through(iommu->ecap) ? 0 : -EOPNOTSUPP; + if (dmar_domain->force_snooping && !ecap_sc_support(iommu->ecap)) return -EINVAL; =20 --=20 2.34.1 From nobody Fri Dec 19 19:38:56 2025 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.14]) (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 0CC1C15D5A2 for ; Wed, 29 May 2024 05:36:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.14 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716960991; cv=none; b=IfeXCFEceZrqSkey46oR4EmhwTFYh1nnZgdtmpr49ZVWqKRKfJzjz28rM466QmCed1y7WuHyj1zjP8CLZIDFAMmCfDiNlqrzqwObwlgADB+gcadRd5cv16hhc02GL75e+x6gxOGJhV3CpWnt63HZjTUwOKQUNiVyAvQEcIzeYq4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716960991; c=relaxed/simple; bh=icmPwJxBqq/SYdv+MT5vO+QjUq8IQyphhpw+Dkkb0Fw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=MOvU0G8UL/QyJcu1CevV+w+7f5/Wc/t9XGfxkeKKQ+1IAQJKJ54yRHkcsgGR8F1yCtD/xLkVaGxP2B6TxJaYyHtJFakU3BMrGEPL5oPS0Rrk74oKKeJjczU98+NNQWz04wuwAd5o3BuTCP8izPp47KgRYNvSHJDeMoCwIJXfrEg= 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=R+V7ROdX; arc=none smtp.client-ip=192.198.163.14 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="R+V7ROdX" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1716960990; x=1748496990; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=icmPwJxBqq/SYdv+MT5vO+QjUq8IQyphhpw+Dkkb0Fw=; b=R+V7ROdXZcRSCRJwY4BfQGdEcuLRtardVySb8UDbPTcLOM+g5a9ll2j+ SDNWz2H5Gxd36khj6eCLlwekIaLgPDPy56JYP/Obv/aRNK7aikMzXPm+w +MvrU44+WZM4Zrlil0RKKj3sQEo0vaE2FE3Bg47SDXqn6ilX4AP1BWXIX 9vk4IvMDllR2VKmxbGkzgeyYErPxzm911k6+9FSWs3jgsmZZnthnS9C5s im9rQJTXCWI6oMDB7vrn6joVMnzE1oPUodaGOEVMPfWvAHEyFklmAl2NP UdMwHh1JPk0W7zO7m8PTsuzuKnhDqeol1dlZNK+AJuOFZKvrw/h/kixrm Q==; X-CSE-ConnectionGUID: FJYJyHB1TaWGlbNOMQLq+Q== X-CSE-MsgGUID: jzpwzBk0RCWtSc9fYbODqQ== X-IronPort-AV: E=McAfee;i="6600,9927,11085"; a="13569096" X-IronPort-AV: E=Sophos;i="6.08,197,1712646000"; d="scan'208";a="13569096" Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by fmvoesa108.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 May 2024 22:36:29 -0700 X-CSE-ConnectionGUID: esSWeCJpSSi5aauFREJ3HQ== X-CSE-MsgGUID: Fk69VRxaR02KBzRZ+jyvNw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,197,1712646000"; d="scan'208";a="35257788" Received: from unknown (HELO allen-box.sh.intel.com) ([10.239.159.127]) by fmviesa007.fm.intel.com with ESMTP; 28 May 2024 22:36:22 -0700 From: Lu Baolu To: Joerg Roedel , Will Deacon , Robin Murphy , Jason Gunthorpe , Kevin Tian Cc: Yi Liu , David Airlie , Daniel Vetter , Kalle Valo , Bjorn Andersson , Mathieu Poirier , Alex Williamson , mst@redhat.com, Jason Wang , Thierry Reding , Jonathan Hunter , Mikko Perttunen , iommu@lists.linux.dev, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Lu Baolu Subject: [PATCH 18/20] iommu/vt-d: Enhance compatibility check for paging domain attach Date: Wed, 29 May 2024 13:32:48 +0800 Message-Id: <20240529053250.91284-19-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240529053250.91284-1-baolu.lu@linux.intel.com> References: <20240529053250.91284-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" The driver now supports domain_alloc_paging, ensuring that a valid device pointer is provided whenever a paging domain is allocated. Additionally, the dmar_domain attributes are set up at the time of allocation. Consistent with the established semantics in the IOMMU core, if a domain is attached to a device and found to be incompatible with the IOMMU hardware capabilities, the operation will return an -EINVAL error. This implicitly advises the caller to allocate a new domain for the device and attempt the domain attachment again. Signed-off-by: Lu Baolu --- drivers/iommu/intel/iommu.c | 39 ++++++++++++++++++------------------- drivers/iommu/intel/pasid.c | 28 +------------------------- 2 files changed, 20 insertions(+), 47 deletions(-) diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c index 693a6d7c79ed..e9393f5c2c50 100644 --- a/drivers/iommu/intel/iommu.c +++ b/drivers/iommu/intel/iommu.c @@ -3826,27 +3826,26 @@ int prepare_domain_attach_device(struct iommu_domai= n *domain, if (domain->dirty_ops && !ssads_supported(iommu)) return -EINVAL; =20 - /* check if this iommu agaw is sufficient for max mapped address */ - addr_width =3D agaw_to_width(iommu->agaw); - if (addr_width > cap_mgaw(iommu->cap)) - addr_width =3D cap_mgaw(iommu->cap); - - if (dmar_domain->max_addr > (1LL << addr_width)) + if (dmar_domain->iommu_coherency !=3D + iommu_paging_structure_coherency(iommu)) return -EINVAL; - dmar_domain->gaw =3D addr_width; - - /* - * Knock out extra levels of page tables if necessary - */ - while (iommu->agaw < dmar_domain->agaw) { - struct dma_pte *pte; - - pte =3D dmar_domain->pgd; - if (dma_pte_present(pte)) { - dmar_domain->pgd =3D phys_to_virt(dma_pte_addr(pte)); - iommu_free_page(pte); - } - dmar_domain->agaw--; + + if (domain->type & __IOMMU_DOMAIN_PAGING) { + if (dmar_domain->iommu_superpage !=3D + iommu_superpage_capability(iommu, dmar_domain->use_first_level)) + return -EINVAL; + + if (dmar_domain->use_first_level && + (!sm_supported(iommu) || !ecap_flts(iommu->ecap))) + return -EINVAL; + + /* check if this iommu agaw is sufficient for max mapped address */ + addr_width =3D agaw_to_width(iommu->agaw); + if (addr_width > cap_mgaw(iommu->cap)) + addr_width =3D cap_mgaw(iommu->cap); + + if (dmar_domain->gaw > addr_width || dmar_domain->agaw > iommu->agaw) + return -EINVAL; } =20 if (sm_supported(iommu) && !dev_is_real_dma_subdevice(dev) && diff --git a/drivers/iommu/intel/pasid.c b/drivers/iommu/intel/pasid.c index abce19e2ad6f..573e1b8e3cfb 100644 --- a/drivers/iommu/intel/pasid.c +++ b/drivers/iommu/intel/pasid.c @@ -345,25 +345,6 @@ int intel_pasid_setup_first_level(struct intel_iommu *= iommu, return 0; } =20 -/* - * Skip top levels of page tables for iommu which has less agaw - * than default. Unnecessary for PT mode. - */ -static int iommu_skip_agaw(struct dmar_domain *domain, - struct intel_iommu *iommu, - struct dma_pte **pgd) -{ - int agaw; - - for (agaw =3D domain->agaw; agaw > iommu->agaw; agaw--) { - *pgd =3D phys_to_virt(dma_pte_addr(*pgd)); - if (!dma_pte_present(*pgd)) - return -EINVAL; - } - - return agaw; -} - /* * Set up the scalable mode pasid entry for second only translation type. */ @@ -374,7 +355,6 @@ int intel_pasid_setup_second_level(struct intel_iommu *= iommu, struct pasid_entry *pte; struct dma_pte *pgd; u64 pgd_val; - int agaw; u16 did; =20 /* @@ -388,12 +368,6 @@ int intel_pasid_setup_second_level(struct intel_iommu = *iommu, } =20 pgd =3D domain->pgd; - agaw =3D iommu_skip_agaw(domain, iommu, &pgd); - if (agaw < 0) { - dev_err(dev, "Invalid domain page table\n"); - return -EINVAL; - } - pgd_val =3D virt_to_phys(pgd); did =3D domain_id_iommu(domain, iommu); =20 @@ -412,7 +386,7 @@ int intel_pasid_setup_second_level(struct intel_iommu *= iommu, pasid_clear_entry(pte); pasid_set_domain_id(pte, did); pasid_set_slptr(pte, pgd_val); - pasid_set_address_width(pte, agaw); + pasid_set_address_width(pte, domain->agaw); pasid_set_translation_type(pte, PASID_ENTRY_PGTT_SL_ONLY); pasid_set_fault_enable(pte); pasid_set_page_snoop(pte, !!ecap_smpwc(iommu->ecap)); --=20 2.34.1 From nobody Fri Dec 19 19:38:56 2025 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.14]) (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 6D49716F271 for ; Wed, 29 May 2024 05:36:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.14 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716960999; cv=none; b=Kfgk2lSrxGWzC2v//SE9d+8R6qkOcAXNyubcWR5DZeFMvbHrnSU4BBhTbomul1iEcDpbSIXqXJoIUBtP9ggGHjvR3gyj9TShGzT3C1ZAHtWm4aRPjkIwf/Svz2bkFVrLcQzxa3H9YBzTWm+eWrlVdiNOiqlVX+63lv9ilVD0gMw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716960999; c=relaxed/simple; bh=5KWn8VzkwrmikfdY6Ercb38rCkbe5TmNZrNn/P2jtlY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=q/SyQRR+zn5wfdhnlMc2eCxDnzH+hXTroWuHpwUj1yTvjcOjGAQPIwCJiSDL/mJmwRvVv70B4DCrCfm2huU5G8xY70sKBqtejiWe+BktAYX2MjFCJERihMLL4tdSxgoDtDylYMa8LqEzFwc97mN5bGrZSKN2yPdarx9TWyutRqs= 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=Klis21kM; arc=none smtp.client-ip=192.198.163.14 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="Klis21kM" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1716960998; x=1748496998; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=5KWn8VzkwrmikfdY6Ercb38rCkbe5TmNZrNn/P2jtlY=; b=Klis21kMJD1gQdyxf0VTTacJhvx7ZkXK4XYj7AGY3NbocKHLMhxN1pNu +Hc/MAPBsl2uNCo7ydLlU41AJw7aFYuFuQ6Rm9bLHeR6vxhR+kFXHscwa XFnP+x+3xVsldYSrWKLvP5fBnDVuPvpPWJSIpjqXk53rDJUK/z6ugRX/p ELY8SYSSp7+CIo5B34IKA1zDKBYdcjf3Ckdxi+Acu5uWMUA29gGf/T8jS Sxnx94EEjR2iQMi86BwZkV/+AncbCrSlZplqFGBASFSnXvZ1jDX7ci/uu KhBzPWgErURqQon262ZQU97SKWnS/WaeHrt3IY2DJP+R6165m/LEGvYxI Q==; X-CSE-ConnectionGUID: uh8XYyvwRVKXeAVarmJRYA== X-CSE-MsgGUID: xo7gDOEZRo26Yz1N+FympA== X-IronPort-AV: E=McAfee;i="6600,9927,11085"; a="13569114" X-IronPort-AV: E=Sophos;i="6.08,197,1712646000"; d="scan'208";a="13569114" Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by fmvoesa108.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 May 2024 22:36:32 -0700 X-CSE-ConnectionGUID: tfyd8XLnTFavgJ6eGMD+/g== X-CSE-MsgGUID: 8sz1WYkaSFSx14UMZlVbhA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,197,1712646000"; d="scan'208";a="35257798" Received: from unknown (HELO allen-box.sh.intel.com) ([10.239.159.127]) by fmviesa007.fm.intel.com with ESMTP; 28 May 2024 22:36:27 -0700 From: Lu Baolu To: Joerg Roedel , Will Deacon , Robin Murphy , Jason Gunthorpe , Kevin Tian Cc: Yi Liu , David Airlie , Daniel Vetter , Kalle Valo , Bjorn Andersson , Mathieu Poirier , Alex Williamson , mst@redhat.com, Jason Wang , Thierry Reding , Jonathan Hunter , Mikko Perttunen , iommu@lists.linux.dev, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Lu Baolu Subject: [PATCH 19/20] iommu/vt-d: Remove domain_update_iommu_cap() Date: Wed, 29 May 2024 13:32:49 +0800 Message-Id: <20240529053250.91284-20-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240529053250.91284-1-baolu.lu@linux.intel.com> References: <20240529053250.91284-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" The attributes of a paging domain are initialized during the allocation process, and any attempt to attach a domain that is not compatible will result in a failure. Therefore, there is no need to update the domain attributes at the time of domain attachment. Signed-off-by: Lu Baolu --- drivers/iommu/intel/iommu.c | 86 +------------------------------------ 1 file changed, 2 insertions(+), 84 deletions(-) diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c index e9393f5c2c50..74e005b1c4b4 100644 --- a/drivers/iommu/intel/iommu.c +++ b/drivers/iommu/intel/iommu.c @@ -366,36 +366,6 @@ static bool iommu_paging_structure_coherency(struct in= tel_iommu *iommu) ecap_smpwc(iommu->ecap) : ecap_coherent(iommu->ecap); } =20 -static void domain_update_iommu_coherency(struct dmar_domain *domain) -{ - struct iommu_domain_info *info; - struct dmar_drhd_unit *drhd; - struct intel_iommu *iommu; - bool found =3D false; - unsigned long i; - - domain->iommu_coherency =3D true; - xa_for_each(&domain->iommu_array, i, info) { - found =3D true; - if (!iommu_paging_structure_coherency(info->iommu)) { - domain->iommu_coherency =3D false; - break; - } - } - if (found) - return; - - /* No hardware attached; use lowest common denominator */ - rcu_read_lock(); - for_each_active_iommu(iommu, drhd) { - if (!iommu_paging_structure_coherency(iommu)) { - domain->iommu_coherency =3D false; - break; - } - } - rcu_read_unlock(); -} - static int domain_update_iommu_superpage(struct dmar_domain *domain, struct intel_iommu *skip) { @@ -426,29 +396,6 @@ static int domain_update_iommu_superpage(struct dmar_d= omain *domain, return fls(mask); } =20 -static int domain_update_device_node(struct dmar_domain *domain) -{ - struct device_domain_info *info; - int nid =3D NUMA_NO_NODE; - unsigned long flags; - - spin_lock_irqsave(&domain->lock, flags); - list_for_each_entry(info, &domain->devices, link) { - /* - * There could possibly be multiple device numa nodes as devices - * within the same domain may sit behind different IOMMUs. There - * isn't perfect answer in such situation, so we select first - * come first served policy. - */ - nid =3D dev_to_node(info->dev); - if (nid !=3D NUMA_NO_NODE) - break; - } - spin_unlock_irqrestore(&domain->lock, flags); - - return nid; -} - /* Return the super pagesize bitmap if supported. */ static unsigned long domain_super_pgsize_bitmap(struct dmar_domain *domain) { @@ -466,35 +413,6 @@ static unsigned long domain_super_pgsize_bitmap(struct= dmar_domain *domain) return bitmap; } =20 -/* Some capabilities may be different across iommus */ -void domain_update_iommu_cap(struct dmar_domain *domain) -{ - domain_update_iommu_coherency(domain); - domain->iommu_superpage =3D domain_update_iommu_superpage(domain, NULL); - - /* - * If RHSA is missing, we should default to the device numa domain - * as fall back. - */ - if (domain->nid =3D=3D NUMA_NO_NODE) - domain->nid =3D domain_update_device_node(domain); - - /* - * First-level translation restricts the input-address to a - * canonical address (i.e., address bits 63:N have the same - * value as address bit [N-1], where N is 48-bits with 4-level - * paging and 57-bits with 5-level paging). Hence, skip bit - * [N-1]. - */ - if (domain->use_first_level) - domain->domain.geometry.aperture_end =3D __DOMAIN_MAX_ADDR(domain->gaw -= 1); - else - domain->domain.geometry.aperture_end =3D __DOMAIN_MAX_ADDR(domain->gaw); - - domain->domain.pgsize_bitmap |=3D domain_super_pgsize_bitmap(domain); - domain_update_iotlb(domain); -} - struct context_entry *iommu_context_addr(struct intel_iommu *iommu, u8 bus, u8 devfn, int alloc) { @@ -1589,7 +1507,7 @@ int domain_attach_iommu(struct dmar_domain *domain, s= truct intel_iommu *iommu) ret =3D xa_err(curr) ? : -EBUSY; goto err_clear; } - domain_update_iommu_cap(domain); + domain_update_iotlb(domain); =20 spin_unlock(&iommu->lock); return 0; @@ -1615,7 +1533,7 @@ void domain_detach_iommu(struct dmar_domain *domain, = struct intel_iommu *iommu) clear_bit(info->did, iommu->domain_ids); xa_erase(&domain->iommu_array, iommu->seq_id); domain->nid =3D NUMA_NO_NODE; - domain_update_iommu_cap(domain); + domain_update_iotlb(domain); kfree(info); } spin_unlock(&iommu->lock); --=20 2.34.1 From nobody Fri Dec 19 19:38:56 2025 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.14]) (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 9803416F271 for ; Wed, 29 May 2024 05:36:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.14 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716961004; cv=none; b=aKz4USnpl4th/yieE8L7M7AGziec28ucowcm6zaz/hby/apC/YVY4cWEnRGTcO+eKdoNiv/qiGtnOnFrXhGAdf48LGd3y+JMfanvYRzUFHg9dck3YIwy9D/hUdBxmLWK7r1Je2t5r+GX1c/GsGgMehXIijB1QxTZyaI2KXPK73o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716961004; c=relaxed/simple; bh=uZ18e0DpTIgHLOpzfBuHcXvVKSj+fUz+S5osI7EsSTY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=u9P6HrPEuGBCsUDtwvqNgAhlQqaNzmxEgbaPFxqBy+yPTNg19vR7B7Mdr/ePkNJrZyDKWHubZE8Pk+FpbHvlRlrHOipzXcBi4PefwIdBJp0AJv6l+THFcuajuzj7DIkliOU8UjRY7QTGWgCBHr1zzaV5FqMECQfqWm18BFN/Ui8= 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=gaZT/mxp; arc=none smtp.client-ip=192.198.163.14 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="gaZT/mxp" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1716961004; x=1748497004; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=uZ18e0DpTIgHLOpzfBuHcXvVKSj+fUz+S5osI7EsSTY=; b=gaZT/mxpLDIP2gP2yr2JZam0yRyejPM5ASQJzfEpJ3Ukat7/5DYG/XKY 2MEvXKQNL56+IVwyENHHdIEaPX9A8NrLsRSDYXGxlxGFNVqz3MCwgL8Am eXCycmTq9JAghEfqGYiDTA1dQg4opKQWqovTedHahmFxgFqG3fpquv95L T1gROj+Dsl26KxbIpe6PrwTy8x6vmgZWDaAtlWEP3tZKEJJ58Q0+BD1Sx 8u9YZjLN4dN8vz9YStHPG1942TaJ/JMAHolaiW7xRvSpxN5pwM1O3sHkE GTTmBteZplAY2AFU7HKA0LAMAif3DUUALxYsJuKv4WE7oC9GsAHYMa1Kj Q==; X-CSE-ConnectionGUID: iOaC2/LxRx+vv5XAL7+glw== X-CSE-MsgGUID: AWN1noWfTreCYbIPriOLcg== X-IronPort-AV: E=McAfee;i="6600,9927,11085"; a="13569132" X-IronPort-AV: E=Sophos;i="6.08,197,1712646000"; d="scan'208";a="13569132" Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by fmvoesa108.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 May 2024 22:36:37 -0700 X-CSE-ConnectionGUID: X+RiNsarRtKW3lpRtSJ0IA== X-CSE-MsgGUID: nvefUVcKRTqj8DSSs+S92A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,197,1712646000"; d="scan'208";a="35257811" Received: from unknown (HELO allen-box.sh.intel.com) ([10.239.159.127]) by fmviesa007.fm.intel.com with ESMTP; 28 May 2024 22:36:32 -0700 From: Lu Baolu To: Joerg Roedel , Will Deacon , Robin Murphy , Jason Gunthorpe , Kevin Tian Cc: Yi Liu , David Airlie , Daniel Vetter , Kalle Valo , Bjorn Andersson , Mathieu Poirier , Alex Williamson , mst@redhat.com, Jason Wang , Thierry Reding , Jonathan Hunter , Mikko Perttunen , iommu@lists.linux.dev, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Lu Baolu Subject: [PATCH 20/20] iommu/vt-d: Remove domain_update_iommu_superpage() Date: Wed, 29 May 2024 13:32:50 +0800 Message-Id: <20240529053250.91284-21-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240529053250.91284-1-baolu.lu@linux.intel.com> References: <20240529053250.91284-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" The requirement for consistent super page support across all the IOMMU hardware in the system has been removed. In the past, if a new IOMMU was hot-added and lacked consistent super page capability, the hot-add process would be aborted. However, with the updated attachment semantics, it is now permissible for the super page capability to vary among different IOMMU hardware units. Signed-off-by: Lu Baolu --- drivers/iommu/intel/iommu.c | 39 +------------------------------------ 1 file changed, 1 insertion(+), 38 deletions(-) diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c index 74e005b1c4b4..660d2b6c531b 100644 --- a/drivers/iommu/intel/iommu.c +++ b/drivers/iommu/intel/iommu.c @@ -366,36 +366,6 @@ static bool iommu_paging_structure_coherency(struct in= tel_iommu *iommu) ecap_smpwc(iommu->ecap) : ecap_coherent(iommu->ecap); } =20 -static int domain_update_iommu_superpage(struct dmar_domain *domain, - struct intel_iommu *skip) -{ - struct dmar_drhd_unit *drhd; - struct intel_iommu *iommu; - int mask =3D 0x3; - - if (!intel_iommu_superpage) - return 0; - - /* set iommu_superpage to the smallest common denominator */ - rcu_read_lock(); - for_each_active_iommu(iommu, drhd) { - if (iommu !=3D skip) { - if (domain && domain->use_first_level) { - if (!cap_fl1gp_support(iommu->cap)) - mask =3D 0x1; - } else { - mask &=3D cap_super_page_val(iommu->cap); - } - - if (!mask) - break; - } - } - rcu_read_unlock(); - - return fls(mask); -} - /* Return the super pagesize bitmap if supported. */ static unsigned long domain_super_pgsize_bitmap(struct dmar_domain *domain) { @@ -2845,8 +2815,8 @@ int dmar_parse_one_satc(struct acpi_dmar_header *hdr,= void *arg) =20 static int intel_iommu_add(struct dmar_drhd_unit *dmaru) { - int sp, ret; struct intel_iommu *iommu =3D dmaru->iommu; + int ret; =20 ret =3D intel_cap_audit(CAP_AUDIT_HOTPLUG_DMAR, iommu); if (ret) @@ -2858,13 +2828,6 @@ static int intel_iommu_add(struct dmar_drhd_unit *dm= aru) return -ENXIO; } =20 - sp =3D domain_update_iommu_superpage(NULL, iommu) - 1; - if (sp >=3D 0 && !(cap_super_page_val(iommu->cap) & (1 << sp))) { - pr_warn("%s: Doesn't support large page.\n", - iommu->name); - return -ENXIO; - } - /* * Disable translation if already enabled prior to OS handover. */ --=20 2.34.1