From nobody Thu Feb 12 17:26:28 2026 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.13]) (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 45B157407D for ; Mon, 10 Jun 2024 08:58:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.13 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718009903; cv=none; b=q0EgPEzUxzwAmY5hG1TGwlB29TPY4G1rMHdJklyp6nrgnTHJQaGZrz6XfdFz5qAW04q3QisbridsZl/U60wr6zagTz/0r/JmkRltN3kcddMZIq2xDvu+au9nx8QAYdFjkg37CVAGvaosDy+X7yntwTVMmSLeGi7MfflqaUlqCKc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718009903; c=relaxed/simple; bh=lO/IPmdUqOg04lYCYxFPmCNa0L0veD8icxIpi6zQo+o=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=EDeIxZMrg/sFVPqPWXu2iYqkBxXQKkYiaOcAEAKBGzqL8YDUblf0KYhECUXgy3jb++uEmuNftzAVYDWxnLaj5OHX6p7Bo+1tnv7y/JXcbMx+49djEytiW7TPCBzVuqb14mpstRSbc13HW1n6MUYLWAyR6HmDUB0PV7BmxO97YpA= 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=n/x4UhIk; arc=none smtp.client-ip=192.198.163.13 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="n/x4UhIk" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1718009902; x=1749545902; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=lO/IPmdUqOg04lYCYxFPmCNa0L0veD8icxIpi6zQo+o=; b=n/x4UhIkTof5w+ZRw3FF9zNsx63ILD9bUj7OyYFGIpgAcXlpDTP5ggfC xx+loFAlgnRKwZUAtDeftb0Nw3gdpk/WcBSp2ZiQcvZXHYqFs3brctiUq XkRLgv11ruYxARBww1WQYbeGw0RFQeNl1HszogRPROWWCHhmb17scACm/ vVVJApdGC57GrhgmCnNnJSySKqNrhTWe0aBUuG8+2Qsf8XvIpjCX2PZ7d C74DJPnYkghpthJUGq3WpNSPPKp51nhZOYWORJGJgZ/QXeR6ObXYTsglS SuiuDdqlyqnI5Z8j7p/0C8zuERvD0wb93BYomhljl3lpqZZT4p6lmZdpL A==; X-CSE-ConnectionGUID: JFKgE6VGQ1yZR+JDKxXdQQ== X-CSE-MsgGUID: nqDsovd1RJ+6Xu0cX8LRig== X-IronPort-AV: E=McAfee;i="6600,9927,11098"; a="17581510" X-IronPort-AV: E=Sophos;i="6.08,227,1712646000"; d="scan'208";a="17581510" Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by fmvoesa107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Jun 2024 01:58:22 -0700 X-CSE-ConnectionGUID: T7ftFoB4QDSGxVb/F3iHkQ== X-CSE-MsgGUID: ImRDR5fxSxuM0OMEzjzIVA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,227,1712646000"; d="scan'208";a="43432409" Received: from unknown (HELO allen-box.sh.intel.com) ([10.239.159.127]) by fmviesa003.fm.intel.com with ESMTP; 10 Jun 2024 01:58:17 -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 , Jeff Johnson , ath10k@lists.infradead.org, ath11k@lists.infradead.org, iommu@lists.linux.dev, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Lu Baolu Subject: [PATCH v3 01/21] iommu: Add iommu_paging_domain_alloc() interface Date: Mon, 10 Jun 2024 16:55:35 +0800 Message-Id: <20240610085555.88197-2-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240610085555.88197-1-baolu.lu@linux.intel.com> References: <20240610085555.88197-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 Reviewed-by: Jason Gunthorpe Reviewed-by: Vasant Hegde --- 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 7bc8dff7cf6d..46f1348f1f0a 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_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); @@ -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_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 9df7cc75c1bc..e03c71a34347 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; @@ -2032,6 +2036,22 @@ struct iommu_domain *iommu_domain_alloc(const struct= bus_type *bus) } EXPORT_SYMBOL_GPL(iommu_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 Thu Feb 12 17:26:28 2026 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.13]) (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 8D4E7757F5 for ; Mon, 10 Jun 2024 08:58:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.13 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718009908; cv=none; b=cQKTe2RUIT+LEgBNR80L9QvZaR9QI90L++qIQKT7WsRBBki3gw17/3+YDKzb0+u4ruksM6jrV0BwqK6JBqhkWR3x8E6P889SBLAwNhZ9TQsrTrh3Ri6mIL0/OIcPmFsQGPeO1tqHDYrp1IRrr7safnfBh16L1EiszaxAJVThjX0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718009908; c=relaxed/simple; bh=V0sWEWGdvvTEoPPivf5bf1akoI1gM9dFCowdFsNKU9w=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=rVVgfZ9u/lJopaqWYuJPUl1leH7q7XpeJI6mL3XbtDAt2P3PZuXN9aWgVjomtQOLZUlUWl0uCjhCL/wqZ+Xk6Kn+SoY9N1m3UKlW2kb0q5NVu/3TxPjjL4zjWcMsHGMTWzr9XHwKRyGk1n/oGB5AxVRk+IISh2h17Fu14SmjuRw= 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=ROcHXMYK; arc=none smtp.client-ip=192.198.163.13 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="ROcHXMYK" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1718009907; x=1749545907; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=V0sWEWGdvvTEoPPivf5bf1akoI1gM9dFCowdFsNKU9w=; b=ROcHXMYKP54nH8Xi+UwodyM6nIL9wO0eCDuKLCEy+OkwwbDvrdHMgus3 2SDx2dO3BGRh2Sk2vwjCXmmjIDe/AgZtVM2Ohp8soMwitgRnmPLI1sFew lc0P5GdaVoJj7Mtda22RjhMkENEOKeM8HZD0gzqdyBITze0lfwNj22G00 3X3wEpQHcyMv19SxsBLfkUYzah66C7vq7gZHYlN9iKPgZUSuA0aiG00fb qH1SwAnex5ilSGzQDeO4vYy0TL5jff9j5TCS5fq7pOzOMZJsu14Pq5rZH Rz8+fFZfZ9GlHvjwHULK3NrQWtOxwdqm9W1EFbAxVTlogly5+g37t/1ut g==; X-CSE-ConnectionGUID: ZLuUsjyZTmmlytgtLrPFOA== X-CSE-MsgGUID: NG03Zw0qTBS+4voIY/MIMg== X-IronPort-AV: E=McAfee;i="6600,9927,11098"; a="17581531" X-IronPort-AV: E=Sophos;i="6.08,227,1712646000"; d="scan'208";a="17581531" Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by fmvoesa107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Jun 2024 01:58:27 -0700 X-CSE-ConnectionGUID: bhp1h+vXQo6jelkBwQxcTg== X-CSE-MsgGUID: deHpkp5nSxiuSR3yUuqFZw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,227,1712646000"; d="scan'208";a="43432419" Received: from unknown (HELO allen-box.sh.intel.com) ([10.239.159.127]) by fmviesa003.fm.intel.com with ESMTP; 10 Jun 2024 01:58:23 -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 , Jeff Johnson , ath10k@lists.infradead.org, ath11k@lists.infradead.org, iommu@lists.linux.dev, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Lu Baolu Subject: [PATCH v3 02/21] iommufd: Use iommu_paging_domain_alloc() Date: Mon, 10 Jun 2024 16:55:36 +0800 Message-Id: <20240610085555.88197-3-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240610085555.88197-1-baolu.lu@linux.intel.com> References: <20240610085555.88197-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" If the iommu driver doesn't implement its domain_alloc_user callback, iommufd_hwpt_paging_alloc() rolls back to allocate an iommu paging domain. Replace iommu_domain_alloc() with iommu_user_domain_alloc() to pass the device pointer along the path. Signed-off-by: Lu Baolu Reviewed-by: Jason Gunthorpe --- drivers/iommu/iommufd/hw_pagetable.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/iommu/iommufd/hw_pagetable.c b/drivers/iommu/iommufd/h= w_pagetable.c index 33d142f8057d..cbddfa3ca95a 100644 --- a/drivers/iommu/iommufd/hw_pagetable.c +++ b/drivers/iommu/iommufd/hw_pagetable.c @@ -137,9 +137,10 @@ iommufd_hwpt_paging_alloc(struct iommufd_ctx *ictx, st= ruct iommufd_ioas *ioas, } hwpt->domain->owner =3D ops; } else { - hwpt->domain =3D iommu_domain_alloc(idev->dev->bus); - if (!hwpt->domain) { - rc =3D -ENOMEM; + hwpt->domain =3D iommu_paging_domain_alloc(idev->dev); + if (IS_ERR(hwpt->domain)) { + rc =3D PTR_ERR(hwpt->domain); + hwpt->domain =3D NULL; goto out_abort; } } --=20 2.34.1 From nobody Thu Feb 12 17:26:28 2026 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.13]) (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 831177581A for ; Mon, 10 Jun 2024 08:58:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.13 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718009913; cv=none; b=hSVrB2ayY6BcGSMT12JoSQJIiRL3+tCrkz3AoSY9uz4GwM1r392wEUEDD6yrokytWjCQ3YI4zLl89kriwoTOpqNcallh1cPNfZKQcrCY1PaRR6umkpbtZhNhcqCofsV9C853/gOWpNBCZkm2CASWKA1zRCFzdsCSrFXy6Ghxx0I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718009913; c=relaxed/simple; bh=oIx+E7QQWhC/YdRYd5TEuDpoPJpROL8sRrH8nFOhCTw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=axme61TB8A/P+Wi/wuDLRHGVla+zbeaweRYXz3pohDL8qLef4E4GAEJgXTPmxcp+dLF/6yIS7h7mDXGLTP8PSCrHP0PZSyV7Vo9ywMGJmhOzcOSMuTLSb2XTdtt9SWL0UPgoD7cKWXiBWlIsx352+MtUiYglQyEQSCPkBFw+jEk= 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=V1CfF+fO; arc=none smtp.client-ip=192.198.163.13 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="V1CfF+fO" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1718009912; x=1749545912; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=oIx+E7QQWhC/YdRYd5TEuDpoPJpROL8sRrH8nFOhCTw=; b=V1CfF+fO+clMJL4q7ejfy2Sg/ONrUj4OC8CfkgJaNQYI6ByC2L+vceRK r/w17WlWNy0naex/JKD43VV85jdHsN1av4JX2yeM1r20C5T9JHtyBLioI R63jLtGZLuJrV1cgLHjo0hGWZDZ6Gl8rm0itfj4BlvpXxcpvBl2gvOpa1 9/3JgNHsAv0q5ouLUb7iqCpVazlyRR2cDZr9659vq/GFO0h+fZsIXP85R FcfN+drKqTuslzPn3zrhMYGt1TvRyUQT4Adp9Vr80QW1Qa/KnOvFtNHsr kdt/C7zrI8h/YstkknazmeQOFfMdi/u7Xmq3UAf+mBHtWdYW4thrpj/Qw g==; X-CSE-ConnectionGUID: iV9ZDWLjS8mBppfirYwAog== X-CSE-MsgGUID: 3nQmjHrjR8eLbXb2skEOPw== X-IronPort-AV: E=McAfee;i="6600,9927,11098"; a="17581552" X-IronPort-AV: E=Sophos;i="6.08,227,1712646000"; d="scan'208";a="17581552" Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by fmvoesa107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Jun 2024 01:58:32 -0700 X-CSE-ConnectionGUID: whhgEdvaSOaveMThVGT9OA== X-CSE-MsgGUID: 6IyxwBSmQmmkJc1+Qq2yEg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,227,1712646000"; d="scan'208";a="43432439" Received: from unknown (HELO allen-box.sh.intel.com) ([10.239.159.127]) by fmviesa003.fm.intel.com with ESMTP; 10 Jun 2024 01:58:28 -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 , Jeff Johnson , ath10k@lists.infradead.org, ath11k@lists.infradead.org, iommu@lists.linux.dev, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Lu Baolu Subject: [PATCH v3 03/21] vfio/type1: Use iommu_paging_domain_alloc() Date: Mon, 10 Jun 2024 16:55:37 +0800 Message-Id: <20240610085555.88197-4-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240610085555.88197-1-baolu.lu@linux.intel.com> References: <20240610085555.88197-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_paging_domain_alloc(). Signed-off-by: Lu Baolu Reviewed-by: Jason Gunthorpe --- 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..0960699e7554 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_paging_domain_alloc(dev); 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 Thu Feb 12 17:26:28 2026 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.13]) (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 9D9D1762C1 for ; Mon, 10 Jun 2024 08:58:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.13 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718009918; cv=none; b=ShEwWi2PLLt3cI65muY/CuWGqRUL2UM9ZosQn5oFgQe1Wox8lMb9kFga7GO5UnX9LR7BSD4gZ8gz2zGffQjIT7VbNHTyUoXfeJzppZctrHEXjh2kgyKEHZm0/75UrFWVrmmqAYcAG+qeTP9hwsvgUP26ZSaQWADGNt3Ng80gU7c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718009918; c=relaxed/simple; bh=qU++r+SggSyx2fIXITvVfcmJ8RsRBVMKn+9+u6WfEcI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=W7JZ/gZLvCipzkf5rFbT4crsjdezGQV6g72n8XZ/x3977qyBm1R4bl1Fe6kIkCSns6R9WAxGEbYbWm0V/u7rmXlGi7bEG8MM7J5OMtwlSDz3/O0HFVf4ezTPt6qS3JMFdZrl7MkKexZCIlDFPBjkEGhQD+R1O9NpbFW3MuayYF4= 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=UDqh5Sh7; arc=none smtp.client-ip=192.198.163.13 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="UDqh5Sh7" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1718009917; x=1749545917; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=qU++r+SggSyx2fIXITvVfcmJ8RsRBVMKn+9+u6WfEcI=; b=UDqh5Sh7UJu55pRN7wRyZwZKdspYYSP6SyNU0YHgAtoy9tRDrRIY56DK xuyP9EtuLuEqqt1SPNvygddWa3NwFgem9LedY+9dzv/7++2lMxAi8m4uP sj+sI6tEF9P+V+5aWo4JLvLk2Tdr28Tpv97a6ZjGwyqx6Yu+N4RYxEy9v 8AvkzFX6EPehbSjK/W58VDHFgLwMZkUEPONfokjK8swdfn5g1+yxxAcaV 4wrutM5vrqg40/0/5epVwdaQ+YBy6/bzc21Dn6CZipaYkdh8m84o0Aq7f E8C+rLwNNgFeJ8Fj8goTkudsp80n4BoD6jO2D80zWWQ12bYhlvCh5u9f7 g==; X-CSE-ConnectionGUID: 0ns+TsWhRDuFDkBNn6KrtQ== X-CSE-MsgGUID: DuVRvd/3RxejT5GZNeC34A== X-IronPort-AV: E=McAfee;i="6600,9927,11098"; a="17581580" X-IronPort-AV: E=Sophos;i="6.08,227,1712646000"; d="scan'208";a="17581580" Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by fmvoesa107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Jun 2024 01:58:37 -0700 X-CSE-ConnectionGUID: bCISEAxDQLCb2yA7Goorcw== X-CSE-MsgGUID: H05Iq2PASIy2ktFmbvS+zw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,227,1712646000"; d="scan'208";a="43432449" Received: from unknown (HELO allen-box.sh.intel.com) ([10.239.159.127]) by fmviesa003.fm.intel.com with ESMTP; 10 Jun 2024 01:58:33 -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 , Jeff Johnson , ath10k@lists.infradead.org, ath11k@lists.infradead.org, iommu@lists.linux.dev, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Lu Baolu Subject: [PATCH v3 04/21] vhost-vdpa: Use iommu_paging_domain_alloc() Date: Mon, 10 Jun 2024 16:55:38 +0800 Message-Id: <20240610085555.88197-5-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240610085555.88197-1-baolu.lu@linux.intel.com> References: <20240610085555.88197-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_paging_domain_alloc(). Signed-off-by: Lu Baolu Acked-by: Michael S. Tsirkin Reviewed-by: Jason Gunthorpe --- drivers/vhost/vdpa.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c index 63a53680a85c..e31ec9ebc4ce 100644 --- a/drivers/vhost/vdpa.c +++ b/drivers/vhost/vdpa.c @@ -1312,26 +1312,24 @@ 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_paging_domain_alloc(dma_dev); + if (IS_ERR(v->domain)) { + ret =3D PTR_ERR(v->domain); + v->domain =3D NULL; + return ret; + } =20 ret =3D iommu_attach_device(v->domain, dma_dev); if (ret) --=20 2.34.1 From nobody Thu Feb 12 17:26:28 2026 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.13]) (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 C9B0E762F8 for ; Mon, 10 Jun 2024 08:58:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.13 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718009924; cv=none; b=BfUYdj6+1lKogK7/NKW46Pnr07eeV+56q3XafXCh1oAcgROvi8zGf5tq1EXkr68azsolKkrkb68CR6l1Yyt1KtrJGsJXnjKwFBVM9kfM8vQun9SoQCbKlzNU0t0HZRLEaThSuO25nRdE5o+jXX1aWrrzq1KTvqn9/94K042xh3Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718009924; c=relaxed/simple; bh=4msQrWBVL2b4JwUEKLRwKbzNTovn+5JwozhskLlkUwI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=W3J/qQ/YHuUUu9k8EEXb6/lJcahScwgGF64Zk8HNs6i4kVizTuv2aH9oC2gPm9NvbWfe96Gj+hJ5q0FPtBqUVG9/atCawhhldJ/2FKY0M9qzLXXCvAmUGPHimuV/xOcN+qqHyh+em58KdZYD2eqKI+lthbfsbDvLUHH3k5sNH0g= 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=d7HDjUR2; arc=none smtp.client-ip=192.198.163.13 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="d7HDjUR2" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1718009922; x=1749545922; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=4msQrWBVL2b4JwUEKLRwKbzNTovn+5JwozhskLlkUwI=; b=d7HDjUR2zssFsZv52TcBLbF8eLWtAHq9MIOH7EiqudbkjQrKNPD1sL8N jNCqj+wE43yx8Y+MaEHNnBjfIPpSb19Dv6tfeSvhxfGl7TC89sIoeJPST lH20AcLcmxhXn84b++D3LdaNcZmyAOKqRfaxyKTFJJIcE0Pt5k7/Ns9G/ +dCyUW+GHovKoGeuCnyyjl2ArO/BsYIKHqDmWa9gHMRuqCbmQCdJrCvbW BQMiRNh2TgCX05VIouNa4/VJhcljXdyPRoCuEb6uGh+PzEFtrkc2fUM7A amA0HgHxNGTJe5QYWFuKb3s0dhH1SiFILwvg0wKm4xESXLK3GBkvALETU A==; X-CSE-ConnectionGUID: GjMlcTj/Q0msAFOozJJCvg== X-CSE-MsgGUID: PYlQ9EMNRCmkv6xeNybmGQ== X-IronPort-AV: E=McAfee;i="6600,9927,11098"; a="17581599" X-IronPort-AV: E=Sophos;i="6.08,227,1712646000"; d="scan'208";a="17581599" Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by fmvoesa107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Jun 2024 01:58:42 -0700 X-CSE-ConnectionGUID: 3haueZ8xSc2KYY4kPv/lrg== X-CSE-MsgGUID: cSDsjgrOSmyakXpWAx+X+A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,227,1712646000"; d="scan'208";a="43432474" Received: from unknown (HELO allen-box.sh.intel.com) ([10.239.159.127]) by fmviesa003.fm.intel.com with ESMTP; 10 Jun 2024 01:58:38 -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 , Jeff Johnson , ath10k@lists.infradead.org, ath11k@lists.infradead.org, iommu@lists.linux.dev, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Lu Baolu , Dmitry Baryshkov Subject: [PATCH v3 05/21] drm/msm: Use iommu_paging_domain_alloc() Date: Mon, 10 Jun 2024 16:55:39 +0800 Message-Id: <20240610085555.88197-6-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240610085555.88197-1-baolu.lu@linux.intel.com> References: <20240610085555.88197-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. Signed-off-by: Lu Baolu Acked-by: Dmitry Baryshkov --- drivers/gpu/drm/msm/msm_iommu.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/msm/msm_iommu.c b/drivers/gpu/drm/msm/msm_iomm= u.c index d5512037c38b..2a94e82316f9 100644 --- a/drivers/gpu/drm/msm/msm_iommu.c +++ b/drivers/gpu/drm/msm/msm_iommu.c @@ -407,10 +407,13 @@ struct msm_mmu *msm_iommu_new(struct device *dev, uns= igned long quirks) struct msm_iommu *iommu; int ret; =20 - domain =3D iommu_domain_alloc(dev->bus); - if (!domain) + if (!device_iommu_mapped(dev)) return NULL; =20 + domain =3D iommu_paging_domain_alloc(dev); + if (IS_ERR(domain)) + return ERR_CAST(domain); + iommu_set_pgtable_quirks(domain, quirks); =20 iommu =3D kzalloc(sizeof(*iommu), GFP_KERNEL); --=20 2.34.1 From nobody Thu Feb 12 17:26:28 2026 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.13]) (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 EB3B8768EF for ; Mon, 10 Jun 2024 08:58:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.13 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718009929; cv=none; b=HIB1OFE9nvcSZnazmnYJdhn+Nw1soAXPncYtzdOTxLdUl8rGjv28uSp+KfbUthOQu8FeudgDkmV1PferdyuNjO6eWI8sumgzoVvWPPK/On9+1bfwVneEVp6OLZ14l6WNTF2SIBguR9UMx7nh3V/2n9ofon5LSg0n9itM9St8/DM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718009929; c=relaxed/simple; bh=GbpYXxZBS+r4Y0EiK3BFmXVZKaFfLeJ2IAlI0t0Upno=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=AFajLn3cU5viqNEC91e9Yj+a/c2BmIJmRbYjH99jwMmkD4gEMWv2vy9slIoAzonUlxfYHHQsJtAdpoJf3UFKmJzkhuomc3M7hJw5Bz9XtBC8G+WgaSzhBFYoMjXr1ZPs7FUzsvOxtWpDPQoX3VSF6Wfp1uyG5deLZQHjjozm5bc= 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=Z3VsvgX2; arc=none smtp.client-ip=192.198.163.13 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="Z3VsvgX2" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1718009928; x=1749545928; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=GbpYXxZBS+r4Y0EiK3BFmXVZKaFfLeJ2IAlI0t0Upno=; b=Z3VsvgX2vVlLgjm1BsrPRPQJpDPhKtvMcNfQA/5PX7bE2VOa2mBCi06A zZl2RiRitOfEw+89RTsGZmmfBlc51vDd5F8kFZiEIWKq3MB8K/UUSarvs v0q16NOutn6IrzS641kmPdqif32vItkT1X8DZkOMmjDwNuoenZC7gQ90m +Hme+MigYqwSLCsz1CBoIcueCEHTGuf+HdD6KmQGRKouMN/Ma0dbByzr2 88TGXY+zBt275/ZaTYK3mPpGlij479nqFm1ZIiS+6WtGX+ELjy3lN0HYM l+saF0Srs+tuZE5Ox4EgHJDGqFAh4pLY4RMQ0yIvLG77t15lFR2hTxZid g==; X-CSE-ConnectionGUID: ndx2wThmSoCs/ASo/Xfy/g== X-CSE-MsgGUID: yyx1AdmGTTyo5HazXwEsGg== X-IronPort-AV: E=McAfee;i="6600,9927,11098"; a="17581624" X-IronPort-AV: E=Sophos;i="6.08,227,1712646000"; d="scan'208";a="17581624" Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by fmvoesa107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Jun 2024 01:58:47 -0700 X-CSE-ConnectionGUID: VamhjrgFQlaSd3fZomawuA== X-CSE-MsgGUID: APBKRNmnS5KOzuWJvg3h1Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,227,1712646000"; d="scan'208";a="43432531" Received: from unknown (HELO allen-box.sh.intel.com) ([10.239.159.127]) by fmviesa003.fm.intel.com with ESMTP; 10 Jun 2024 01:58:43 -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 , Jeff Johnson , ath10k@lists.infradead.org, ath11k@lists.infradead.org, iommu@lists.linux.dev, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Lu Baolu Subject: [PATCH v3 06/21] drm/nouveau/tegra: Use iommu_paging_domain_alloc() Date: Mon, 10 Jun 2024 16:55:40 +0800 Message-Id: <20240610085555.88197-7-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240610085555.88197-1-baolu.lu@linux.intel.com> References: <20240610085555.88197-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 Thu Feb 12 17:26:28 2026 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.13]) (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 EED4A770F4 for ; Mon, 10 Jun 2024 08:58:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.13 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718009934; cv=none; b=nwOVSUURI1ZYHSpuDIlt5+OCAhhaASgGQvVPihFz3J6zrQb3gUQ7sNyNwDKyhB4oC2yttxyf4HBDNxTEv1VzjzUIybkbQ24aScvOxKQGq1tRMn3qnQnQKq6YgJOlr05RE39qZHJ5vdukj+K7oCTwzPVfn26hKRcY++bzdAA4baA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718009934; c=relaxed/simple; bh=3intrfdlq62sPZGdllNzLo1Ahf/WR8/6yPI2eqBXYY8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=uQlRvFNd5igwACn1nFo9hb6Ug6hRXcjUHavbiO2+Xq4Qk3DTx+9n4ivXyecIISjT244iggfyzjLPMg8NKovgufSMZCrYIsO4UEq68xh/6UBFeeAoqzKVbxQJaVHulr2tquUKtkGPofOmMP4G8Xcj60pMIj3ooUEAq9uE8tm83sw= 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=GrvelJR8; arc=none smtp.client-ip=192.198.163.13 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="GrvelJR8" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1718009933; x=1749545933; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=3intrfdlq62sPZGdllNzLo1Ahf/WR8/6yPI2eqBXYY8=; b=GrvelJR8lc4v8Nby6CPs0NUw/nHUGoklKtcPbh4bQaS89AUi+nUodsfU 7d7xiW1IQux0rqGb9K/kyFuo3azx3weZFz4TZxAX28vBstTDtbBEmGbLf QZHr7nt28h+T7y+hp26VqvEl5xYWzQkab+ctu16ighOS4koaNfp604siz SpN6gWZr7oCfIWcrZvql8JSpb+LNM6JMps0xEyxGeUJq1A6nv+Ryl864+ j1e0YaTXcPL7vkzZq0Z3HorxvsR29WFUgjZpWcZuepAsX5gkFV/cv4dLB Xo5maXEGGU+Wo/Hs3nOna1PcxAcuDEoacoEbi5p4rtgpjeJqMvWYEqZ8L g==; X-CSE-ConnectionGUID: fUA/dOQgTSS49zY4Vq5Jgw== X-CSE-MsgGUID: mtHIcXwURqe3FGTQ4TRG7w== X-IronPort-AV: E=McAfee;i="6600,9927,11098"; a="17581630" X-IronPort-AV: E=Sophos;i="6.08,227,1712646000"; d="scan'208";a="17581630" Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by fmvoesa107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Jun 2024 01:58:52 -0700 X-CSE-ConnectionGUID: Ilzg052XTkGNg5Xl4jMrRA== X-CSE-MsgGUID: 2uqmD9gJTn61hulUVOHf8A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,227,1712646000"; d="scan'208";a="43432549" Received: from unknown (HELO allen-box.sh.intel.com) ([10.239.159.127]) by fmviesa003.fm.intel.com with ESMTP; 10 Jun 2024 01:58:48 -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 , Jeff Johnson , ath10k@lists.infradead.org, ath11k@lists.infradead.org, iommu@lists.linux.dev, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Lu Baolu Subject: [PATCH v3 07/21] gpu: host1x: Use iommu_paging_domain_alloc() Date: Mon, 10 Jun 2024 16:55:41 +0800 Message-Id: <20240610085555.88197-8-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240610085555.88197-1-baolu.lu@linux.intel.com> References: <20240610085555.88197-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 Reviewed-by: Jason Gunthorpe --- drivers/gpu/host1x/dev.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/host1x/dev.c b/drivers/gpu/host1x/dev.c index 3a0aaa68ac8d..f86a6b12f24a 100644 --- a/drivers/gpu/host1x/dev.c +++ b/drivers/gpu/host1x/dev.c @@ -404,9 +404,10 @@ 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); + host->domain =3D NULL; goto put_cache; } =20 --=20 2.34.1 From nobody Thu Feb 12 17:26:28 2026 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.13]) (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 E1E1777103 for ; Mon, 10 Jun 2024 08:58:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.13 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718009939; cv=none; b=mZ/kjPQCFQ5lSEne4Ln3JG1D2rOmugC5u1heUm22vJ9Tv8b0Fd1nN0mev4Uj+Rtv/IjjMLF8uazUbLcWH997Nm6PFaCVXiUEqnSoqiF8WMaSBxsahXNukCEFYhBe+TLoJ6+VnTA1tCwsaHxkrv4gWOk7kt43GR8WnlFturjqELU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718009939; c=relaxed/simple; bh=gcVUdhVM6KwB99b7OFzWjZ/BBZdHQiOtwXYtd2+KA+I=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=WjdZck1aMa4qUMDDZhnfGtNU7/Ve6uAVUfE6sZITkf4YGwFLPRTE8UDleo0hpCMiwSIw8rd1WM5ZLHM063MJgYKHvVMgDvW6ew1o6j5sYLJxyluoze6KdSLtbUxivqypHOls7q6O7Ghw7pggO14w/jH3FkgExavYG3Q3VOfPBC0= 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=OpGzbgHV; arc=none smtp.client-ip=192.198.163.13 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="OpGzbgHV" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1718009938; x=1749545938; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=gcVUdhVM6KwB99b7OFzWjZ/BBZdHQiOtwXYtd2+KA+I=; b=OpGzbgHVTaxv/WxRsEGzwRMF1eJHaIypUc10IWthhmIRN9hO4xjIBGC8 g+Pfo8WCb5E9iiaWeurAiitSYYYV5FblW8ZtWP2UwvZgDNW1CFofNXZi5 /ErJPkBkd8PBB1mzrrMtXqINHsJX2RWbpOU/7MJ26oyIyfYvhyg3WsBEJ LNjuZg8uKUPx5Ejs+xzVKIo2nQxDSVDXtzJs/QL8Q5zAQbIWQJfYjYLum 1tEMY5zzdMM2ga2l7YXKCojNr//s1zREiGGn3N0TJsBwVhCZPv8QnPl5s d8Dsth8rm4LZFseF4KeM/p3CnkdLmI3zPtdPuKl21f3+Wj8X9QK0yAyZ3 A==; X-CSE-ConnectionGUID: 9JOagfZMT7C0pI0v3NBZPA== X-CSE-MsgGUID: kVTIIDh0RnG8TMlsSsP8Mg== X-IronPort-AV: E=McAfee;i="6600,9927,11098"; a="17581649" X-IronPort-AV: E=Sophos;i="6.08,227,1712646000"; d="scan'208";a="17581649" Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by fmvoesa107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Jun 2024 01:58:57 -0700 X-CSE-ConnectionGUID: S518TnLfQLutDzB5t6Znmg== X-CSE-MsgGUID: oLlb/Z4oQiiBn2odn2LRRg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,227,1712646000"; d="scan'208";a="43432568" Received: from unknown (HELO allen-box.sh.intel.com) ([10.239.159.127]) by fmviesa003.fm.intel.com with ESMTP; 10 Jun 2024 01:58: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 , Jeff Johnson , ath10k@lists.infradead.org, ath11k@lists.infradead.org, iommu@lists.linux.dev, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Lu Baolu Subject: [PATCH v3 08/21] media: nvidia: tegra: Use iommu_paging_domain_alloc() Date: Mon, 10 Jun 2024 16:55:42 +0800 Message-Id: <20240610085555.88197-9-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240610085555.88197-1-baolu.lu@linux.intel.com> References: <20240610085555.88197-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 Reviewed-by: Jason Gunthorpe --- drivers/media/platform/nvidia/tegra-vde/iommu.c | 7 ++++--- 1 file changed, 4 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..b1d9d841d944 100644 --- a/drivers/media/platform/nvidia/tegra-vde/iommu.c +++ b/drivers/media/platform/nvidia/tegra-vde/iommu.c @@ -78,9 +78,10 @@ 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); + vde->domain =3D NULL; goto put_group; } =20 --=20 2.34.1 From nobody Thu Feb 12 17:26:28 2026 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.13]) (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 232FC77119 for ; Mon, 10 Jun 2024 08:59:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.13 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718009944; cv=none; b=ZMhX9JSzl4aaPHSLKjkrvkj9Jxco9DXvgFRySrqaELIC6XRs4jMg0dX4QEzzq1UzlihXs9yULNme5TFXs8vP4QcWmQhcb9TZbdUQIhsbaktsiAwb2WOlykU3vofK6U3AetYkc/s0bRZz3RdjUNO7u5ryzvHWYA6nyeaxgswCqHc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718009944; c=relaxed/simple; bh=sQhpQrDpkr5d6QzI9UDmfi+nhpzVyW1CcaBVDpyFpuE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=KxTf0ZuyPjPKEJ6jwUEb6cqpn0wwjuLz833KqstmTKfLnJxxpCB6x6xrt3JPf24l6DSvOmUM8Tz2SXBNIsR71vQglQGXxfNNRkQh+t0UkHsw32EOKrw+4UUSDMwxU0SZ6H+29RvRGZRgPqk1+LPg6kEZqYREqoz0GYza40NMcWA= 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=oEbkpjF7; arc=none smtp.client-ip=192.198.163.13 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="oEbkpjF7" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1718009943; x=1749545943; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=sQhpQrDpkr5d6QzI9UDmfi+nhpzVyW1CcaBVDpyFpuE=; b=oEbkpjF7y5wyGx60rwbyHf0xXmlwMVxozn0wErErzLKXgvZF8iAwF/go 13lkGOyO/WbglrrGSpW8A4KA9/0QFzVIy9QkDuCpS3vQ0ywo5SSVNXMo3 cl/52Ow/t+qmWlp8llH0KhIztmqBeexEZPdvIOPRl3HEsMfjEN2kVPhPO 5kSoCyYM43CgYd7vq9+yaHWGev+wUODlBVWIRj3472WmnQtDdDDiXDVQC uAzFo62Zvmoxkt/LbcqDxpMx2ishvEt5kDahnNrE52jj4yygf6lZJt6xj 1qae5UwPJDkqEnDI4jjmM0uNtNilY1IDiwT/GfcsV09WgRqGVMm21emDU Q==; X-CSE-ConnectionGUID: wwii1SufRe+lHBUUl6EuLA== X-CSE-MsgGUID: 3hv/p4DKSvWKA3GxzyaN9g== X-IronPort-AV: E=McAfee;i="6600,9927,11098"; a="17581672" X-IronPort-AV: E=Sophos;i="6.08,227,1712646000"; d="scan'208";a="17581672" Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by fmvoesa107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Jun 2024 01:59:02 -0700 X-CSE-ConnectionGUID: GoqNbYNkRoi9JfD2FIY96Q== X-CSE-MsgGUID: wwmA5EWAQ/CYSTTnenxwlA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,227,1712646000"; d="scan'208";a="43432593" Received: from unknown (HELO allen-box.sh.intel.com) ([10.239.159.127]) by fmviesa003.fm.intel.com with ESMTP; 10 Jun 2024 01:58: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 , Jeff Johnson , ath10k@lists.infradead.org, ath11k@lists.infradead.org, iommu@lists.linux.dev, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Lu Baolu Subject: [PATCH v3 09/21] media: venus: firmware: Use iommu_paging_domain_alloc() Date: Mon, 10 Jun 2024 16:55:43 +0800 Message-Id: <20240610085555.88197-10-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240610085555.88197-1-baolu.lu@linux.intel.com> References: <20240610085555.88197-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 Reviewed-by: Jason Gunthorpe --- 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 Thu Feb 12 17:26:28 2026 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.13]) (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 3A60B77F2C for ; Mon, 10 Jun 2024 08:59:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.13 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718009950; cv=none; b=TduXdOxldkgpHu3asNDD5ilo7HDxdfhGKbnWSjWiTm2N9p+/8/2EDcoeuCFfs8VS3BXwTzx+N4FK5us+hJLsd2g576yrfAUFfjyKNK4wl/MIXUzZC6rfVFms1jKWRyEpMEtDibv8yOG/0utqIMFXU+jvW+/jshTwAtB648X1OGY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718009950; c=relaxed/simple; bh=I+6ZV6/EEpnAgWEguwHFARLKzGNGpw6wFQ/PVZkM/0g=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=q+KJCCpAd81ok9kMWp+5FLUgO06KLHOxNkX6g5v4mrB/2X0ZLL/KAbPrwRhrcq6y8QI2g0rb13ASHhupSYwCmM0WtYCbsaMZ4MpQrqm5cFUvb2iuHOtFoHFvZHfNRwNeeANgjgF4NRm9w5mG8bxazvS4JQGBb7WM5dmLvnohC7c= 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=Cb8HUsia; arc=none smtp.client-ip=192.198.163.13 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="Cb8HUsia" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1718009949; x=1749545949; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=I+6ZV6/EEpnAgWEguwHFARLKzGNGpw6wFQ/PVZkM/0g=; b=Cb8HUsiavp6loa1sEd+Q9+rmPxBhSitBblWJ6EWmKGqiOa+aD+ZvkXCn YTHexH7TmDZdMpHSPVQHAGlGyTXb9hgR6WBxvwzmsiMCaUB/65ZwMAZdD kbs/tAmUfSa9f0FMV9+UzRBsNf2nNBtqStIsEcLnNWTJAVxBFlpiEMvLq V0TZONnMccoTDYGO+j+517l9uXhlnyzJZQajSlt9qncIlgHn2Js1vDeie 6twBgUy2IuroOcBN9grU0N4MN5Iyi5Ovk+nB9uuYvn6SvB+YcvxV53EtX h4ffxQ6qiBGD5kHgEJONDIbIB8JEyLPRRCPlMr4t8Gi52isVTvFTxiEjA A==; X-CSE-ConnectionGUID: HP8E37TLTmm9wqGTALkTEg== X-CSE-MsgGUID: 7g9K866rQsuTM2TmHMxAaw== X-IronPort-AV: E=McAfee;i="6600,9927,11098"; a="17581715" X-IronPort-AV: E=Sophos;i="6.08,227,1712646000"; d="scan'208";a="17581715" Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by fmvoesa107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Jun 2024 01:59:08 -0700 X-CSE-ConnectionGUID: DWaGHBPtRWWyKoZXzOPdmw== X-CSE-MsgGUID: mAUB1mHyQdCuNi096HBmIw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,227,1712646000"; d="scan'208";a="43432626" Received: from unknown (HELO allen-box.sh.intel.com) ([10.239.159.127]) by fmviesa003.fm.intel.com with ESMTP; 10 Jun 2024 01:59: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 , Jeff Johnson , ath10k@lists.infradead.org, ath11k@lists.infradead.org, iommu@lists.linux.dev, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Lu Baolu Subject: [PATCH v3 10/21] wifi: ath10k: Use iommu_paging_domain_alloc() Date: Mon, 10 Jun 2024 16:55:44 +0800 Message-Id: <20240610085555.88197-11-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240610085555.88197-1-baolu.lu@linux.intel.com> References: <20240610085555.88197-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 Acked-by: Jeff Johnson Reviewed-by: Jason Gunthorpe --- 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 Thu Feb 12 17:26:28 2026 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.13]) (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 274718172A for ; Mon, 10 Jun 2024 08:59:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.13 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718009958; cv=none; b=ZcUz+4XUwEGIua8K2FKcUeXdBmalZvyG+Iccpvua5Igrcp3PHA+4cSoLvI7RnlukxLAMmFF5mgZ2rwXxyH6gSpgR99kD6T8ULpWznlACHSkEdymDYpv6MFjmq4xm8ynncMOjUIfyc1skPMM5DuDIdnIo+3N3+57/5AfAcNnfDnE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718009958; c=relaxed/simple; bh=0YWlii2bXNnHccsmtL/FJMzKgMQQ20l9rtRa+FjY2hk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=sgGgTs0SjIZl5gWeu7/Ar+Iy4MOJlfGlMVLCK/PfqBiD7GEBH0GH2FnXySiorD/+tbzomJSO7Rxf3jeqinMJqKsXA1xURjNokjJNtoLebDmV32f1TOt97rTi8XwqzlUQxYu6Zyi6ClWJep8zPfzSk9Mokzm4tpqWUtJDKzO3aC8= 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=kSzpcE4/; arc=none smtp.client-ip=192.198.163.13 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="kSzpcE4/" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1718009957; x=1749545957; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=0YWlii2bXNnHccsmtL/FJMzKgMQQ20l9rtRa+FjY2hk=; b=kSzpcE4/YAe1kNJ5bxP0mSB+tieFzrCpxxEGbtu1obBc2V5J+K+tO8jk IIXBYfNk1+WhAcpxHpl+jjmfMPxyI7KL6D8uE7HJi+iOS6Q093TRzkxRf +TjcwETFvRp5jOk5MfcXW+07ryROJ5GJP7adqgygwY2XvFZYEuiFvgmVa kAC0GOm9h5ZH8BX6dds2OUtHfL6qqwyn8zBWIx8qMwP3SmojYBmOIQ6O0 E9bsxZ91x4wG5W0CQuRyC7tmYKpKlSiGYwf7+TxGLCT6K123w+FU1+OPL q6hF9eYXm9shrUQcYvRUQjNQl77Pee+HwRBp0c20SEniPdZzELKi+M8x9 g==; X-CSE-ConnectionGUID: UO3fLGNEQPefpAZCD1Qr8Q== X-CSE-MsgGUID: 9bUqrVniQrKqJ+2SxVzRWg== X-IronPort-AV: E=McAfee;i="6600,9927,11098"; a="17581762" X-IronPort-AV: E=Sophos;i="6.08,227,1712646000"; d="scan'208";a="17581762" Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by fmvoesa107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Jun 2024 01:59:13 -0700 X-CSE-ConnectionGUID: /nHz8Xa6R1C1//x2x4ZYpg== X-CSE-MsgGUID: fbNfhGj2Ro2X3TwDUjfe6g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,227,1712646000"; d="scan'208";a="43432670" Received: from unknown (HELO allen-box.sh.intel.com) ([10.239.159.127]) by fmviesa003.fm.intel.com with ESMTP; 10 Jun 2024 01:59:08 -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 , Jeff Johnson , ath10k@lists.infradead.org, ath11k@lists.infradead.org, iommu@lists.linux.dev, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Lu Baolu Subject: [PATCH v3 11/21] wifi: ath11k: Use iommu_paging_domain_alloc() Date: Mon, 10 Jun 2024 16:55:45 +0800 Message-Id: <20240610085555.88197-12-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240610085555.88197-1-baolu.lu@linux.intel.com> References: <20240610085555.88197-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 Acked-by: Jeff Johnson Reviewed-by: Jason Gunthorpe --- 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 Thu Feb 12 17:26:28 2026 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.13]) (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 80570823C8 for ; Mon, 10 Jun 2024 08:59:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.13 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718009961; cv=none; b=jjkceryJs/2ZrFsPIOA+kaxES+VtbHfaRlSsHfdyVyNKAulme4hVNBlteRjutoF8MZhPwnTSru6lk/iNo1SiN2kdOARGsQjs04K6KEyGwCZrLWLfenw6WipbAKM89LRRTYvcTLToc1GBaSPW61WdIcpBdhxiX80lAzj4ugj5i18= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718009961; c=relaxed/simple; bh=kDJcZN33ntEvZZurzXrpsoEVgCNzk8vicnqImPO/kUg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=aYPRzqpta1+6Hp9hwHhQM4DVpNLt1jJAvjUcev9QVUux8oh+tPBGspnx3W/wc1vcb8HymmLkLbMb+0CuTyzQjUur9xhMbht+Xkwx2xzcNs8+U4ffl/hmdH5GpAXq8GhnNEp18L+uf4xPD79MIS4G7wNnQ3vhUgC67RC4TTjmSrE= 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=d5ixajlR; arc=none smtp.client-ip=192.198.163.13 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="d5ixajlR" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1718009960; x=1749545960; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=kDJcZN33ntEvZZurzXrpsoEVgCNzk8vicnqImPO/kUg=; b=d5ixajlR0VlEDAD6p0Trd1HWwg/4Sbfztg9worcJAzO8YDfzHnxb3Y5k s61SUUaRqBL49HF/pGhwZznQJlLTeI+tsZNFRoxLNrxDpGBNXBjX6Ix7m l3wee7jXg9tCmbobH+UCUyRlQIgQtILlKZbth2hBz0j+X7YV70+zW6ZlG M8i/ueETI0KBA1kG0eDjEzLXZglEl5wJ+RfwSlFoX+5LRHXKM+IgIPVEO WWELbQkISUvlUC0XgyNgxukbCeBkF78ZLBQGU26IABHSRbt8fTgtoIaE1 zu0nmZIk5xvLiAC+SltQHO8DhZyXt9UuVJB+8hrqwlWYKUP7G0qG/+Kj4 w==; X-CSE-ConnectionGUID: yR8fbHLPQ4GQ6EGhOw9ZjQ== X-CSE-MsgGUID: FsyRLOtBTU6RW2SjUzGmsg== X-IronPort-AV: E=McAfee;i="6600,9927,11098"; a="17581797" X-IronPort-AV: E=Sophos;i="6.08,227,1712646000"; d="scan'208";a="17581797" Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by fmvoesa107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Jun 2024 01:59:18 -0700 X-CSE-ConnectionGUID: NfOkwSpKThicZbLMfICvvA== X-CSE-MsgGUID: AQGFlrAZSA+rn/BX4z4/mg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,227,1712646000"; d="scan'208";a="43432718" Received: from unknown (HELO allen-box.sh.intel.com) ([10.239.159.127]) by fmviesa003.fm.intel.com with ESMTP; 10 Jun 2024 01:59:14 -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 , Jeff Johnson , ath10k@lists.infradead.org, ath11k@lists.infradead.org, iommu@lists.linux.dev, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Lu Baolu Subject: [PATCH v3 12/21] remoteproc: Use iommu_paging_domain_alloc() Date: Mon, 10 Jun 2024 16:55:46 +0800 Message-Id: <20240610085555.88197-13-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240610085555.88197-1-baolu.lu@linux.intel.com> References: <20240610085555.88197-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 Reviewed-by: Jason Gunthorpe --- 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 Thu Feb 12 17:26:28 2026 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.13]) (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 BA60282871 for ; Mon, 10 Jun 2024 08:59:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.13 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718009965; cv=none; b=nQT+SYGBAxCgAObAU12Cc40YHvgoFSiGkpyaWhMM/3mDCvt98Fr0GwqNqPxtX/FPWAZFW2u4g7fU5v7RZdJ13fSMDqhmjrDkI6LrJOu36zuDyEsedAS+gWtqYVH4QI/TOIxj+qsKB3c9DwPqnA/uR9EHGrjwKCf6Pd6+n+Iu80g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718009965; c=relaxed/simple; bh=sM71nWFg3cNfoT7YtYLr4iW7aTMKAR3F9pN2mUDECnk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=EdsMnYQxhKwxSl8rMdYfS/mpLXa+lo2FjA7ODj+ZEOnQBdJea5mslNKdXJxwPJ9XLz6sIbQfCo6YxsADP1gjeRBZwf0avfxbEQC/UzHlslRZbADosMqlxBxtzcFtay2PXZmbj6OV9VI9P9P5o8+Rz4wTqZwutZSMvLhc4nGJ4Bo= 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=QV6akDqk; arc=none smtp.client-ip=192.198.163.13 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="QV6akDqk" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1718009963; x=1749545963; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=sM71nWFg3cNfoT7YtYLr4iW7aTMKAR3F9pN2mUDECnk=; b=QV6akDqkEoR2hyoX9lxL3OrqpMKYCgkFZvkMOwiDXfpvjbBy4mm9L6Ot 9fBikzyuO4Pr2jn/Hzx01/u1EWuioK9KRqt5o9yNLRkzlEj2O192inyi2 doK52F/Go9eOUSwCTMrZq1ywzonntRIsi7KVdfJhDAvxjI3H88I25I4kO dEDrJEGQRwS9N3SiSU9FXMmCjN8rh9iwdj+SmNOjDJRqR+IxSp7ehZgo8 quyCnZGvjDyWShXk4JXmN0mXL+S7JF+pFI2ionbtQ4igwx6j8CWuzGs+O AA0YoHVX37PhYEf0mxKP+4JUwN4zZoE3QTGkOVhByQr6jylDejTrgPN4l Q==; X-CSE-ConnectionGUID: kv/8qt/FS86KNMu4cu7VJg== X-CSE-MsgGUID: ZONHkeiOR8uEpNYwlKMsXQ== X-IronPort-AV: E=McAfee;i="6600,9927,11098"; a="17581827" X-IronPort-AV: E=Sophos;i="6.08,227,1712646000"; d="scan'208";a="17581827" Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by fmvoesa107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Jun 2024 01:59:23 -0700 X-CSE-ConnectionGUID: pUWAnATbSkmzoSbiD3n7dw== X-CSE-MsgGUID: EcaT65n0R1+t1siUeF7hbw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,227,1712646000"; d="scan'208";a="43432756" Received: from unknown (HELO allen-box.sh.intel.com) ([10.239.159.127]) by fmviesa003.fm.intel.com with ESMTP; 10 Jun 2024 01:59:19 -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 , Jeff Johnson , ath10k@lists.infradead.org, ath11k@lists.infradead.org, iommu@lists.linux.dev, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Lu Baolu Subject: [PATCH v3 13/21] soc/fsl/qbman: Use iommu_paging_domain_alloc() Date: Mon, 10 Jun 2024 16:55:47 +0800 Message-Id: <20240610085555.88197-14-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240610085555.88197-1-baolu.lu@linux.intel.com> References: <20240610085555.88197-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 Reviewed-by: Jason Gunthorpe --- drivers/soc/fsl/qbman/qman_portal.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/soc/fsl/qbman/qman_portal.c b/drivers/soc/fsl/qbman/qm= an_portal.c index e23b60618c1a..456ef5d5c199 100644 --- a/drivers/soc/fsl/qbman/qman_portal.c +++ b/drivers/soc/fsl/qbman/qman_portal.c @@ -48,9 +48,10 @@ 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__); + pcfg->iommu_domain =3D NULL; goto no_iommu; } ret =3D fsl_pamu_configure_l1_stash(pcfg->iommu_domain, cpu); --=20 2.34.1 From nobody Thu Feb 12 17:26:28 2026 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.13]) (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 6B54112F397 for ; Mon, 10 Jun 2024 08:59:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.13 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718009970; cv=none; b=LR6Tad7m/tOrOSQ5fMBpIDvcdnWRDUSvtBqfuKlX4k86MljCkzujhmu44LAr3C7zwtGhcrSTrmNiv1hndnXv0rcjVya4MxcHih3Pt5ZbBH0pAUDISkrja0GzgEJjsZkQ4az1F43HKFnRcOj3RH7UnHKslNoBqBCsZn5aUK5pfOE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718009970; c=relaxed/simple; bh=v9ajyqSmZ+fyr4zUzek4FxHLrUQ5pgq0PnnoHeKwwEA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=d4RPj3BCOx14OpG6rAa3VX0QBiKRZkOM8UulHzphMeLkkI/3PvG0uNRzwvpyyJmM+iVPGaNxXHdiuWUUtbQr+j9VWb5BxfAr4rmaXMzYE+s8mubaNvKKpWRV5WSBk62YuULKBMZOLw+jouAWcL6Kys26ay9s+EP8bF05WObXtG8= 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=GBIGjEqv; arc=none smtp.client-ip=192.198.163.13 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="GBIGjEqv" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1718009969; x=1749545969; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=v9ajyqSmZ+fyr4zUzek4FxHLrUQ5pgq0PnnoHeKwwEA=; b=GBIGjEqvuywG2yhUsNwo3KEBFxSUDlVwpYJy14LiuINipQrecguYGlqb 7xbFExw9axAxazC/xloBx+nODZN2pbe72f6/xbl5aJ0RkRM56rtn/BEb3 1bByWzeLFuMEvDRRkr57H49Rs7SPBfXuAURK3nKiTIlstt+LOIsoldTNV 8sNXlVzxUS/9LC02QjIMsqMps9+BCt+3GP8B+GZMYIlSgT+q9mlHnE/q0 iycNmvYmI+Z6W5blB677GL/IVbUhxFUw/l8X/DHym6yJJURnuy4222ETL LVmmlslvbKPklSWkBEU6OHYzMtqNQOrbPfQwb38HdmodQFvdsDS3N/OT+ A==; X-CSE-ConnectionGUID: WOy78YqHRrK/YwwanhysEg== X-CSE-MsgGUID: k2RZbc0rSz24GX6jVfizcA== X-IronPort-AV: E=McAfee;i="6600,9927,11098"; a="17581852" X-IronPort-AV: E=Sophos;i="6.08,227,1712646000"; d="scan'208";a="17581852" Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by fmvoesa107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Jun 2024 01:59:29 -0700 X-CSE-ConnectionGUID: GkBRboXmTSyQf4zFvmmGBw== X-CSE-MsgGUID: c0ivZk7UTYCnDo9fVTczuQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,227,1712646000"; d="scan'208";a="43432808" Received: from unknown (HELO allen-box.sh.intel.com) ([10.239.159.127]) by fmviesa003.fm.intel.com with ESMTP; 10 Jun 2024 01:59:24 -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 , Jeff Johnson , ath10k@lists.infradead.org, ath11k@lists.infradead.org, iommu@lists.linux.dev, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Lu Baolu , Jason Gunthorpe Subject: [PATCH v3 14/21] RDMA/usnic: Use iommu_paging_domain_alloc() Date: Mon, 10 Jun 2024 16:55:48 +0800 Message-Id: <20240610085555.88197-15-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240610085555.88197-1-baolu.lu@linux.intel.com> References: <20240610085555.88197-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-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable usnic_uiom_alloc_pd() allocates a paging domain for a given device. In this case, iommu_domain_alloc(dev->bus) is equivalent to=C2=A0 iommu_paging_domain_alloc(dev). Replace it as iommu_domain_alloc() has been deprecated. Signed-off-by: Lu Baolu Acked-by: Jason Gunthorpe --- drivers/infiniband/hw/usnic/usnic_uiom.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/infiniband/hw/usnic/usnic_uiom.c b/drivers/infiniband/= hw/usnic/usnic_uiom.c index 84e0f41e7dfa..f948b76f984d 100644 --- a/drivers/infiniband/hw/usnic/usnic_uiom.c +++ b/drivers/infiniband/hw/usnic/usnic_uiom.c @@ -443,11 +443,11 @@ struct usnic_uiom_pd *usnic_uiom_alloc_pd(struct devi= ce *dev) if (!pd) return ERR_PTR(-ENOMEM); =20 - pd->domain =3D domain =3D iommu_domain_alloc(dev->bus); - if (!domain) { + pd->domain =3D domain =3D iommu_paging_domain_alloc(dev); + if (IS_ERR(domain)) { usnic_err("Failed to allocate IOMMU domain"); kfree(pd); - return ERR_PTR(-ENOMEM); + return ERR_CAST(domain); } =20 iommu_set_fault_handler(pd->domain, usnic_uiom_dma_fault, NULL); --=20 2.34.1 From nobody Thu Feb 12 17:26:28 2026 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.13]) (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 AB6BF12F397 for ; Mon, 10 Jun 2024 08:59:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.13 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718009976; cv=none; b=N22kIc0XMKvwQ9Wsw/u9HbdTvCdjG4ORKqxrOAX2PfCXaRYdOP6MpI/rgUuEvqkJShuWI5DsdiMOVsP11qrIuWE9DyRbyvHODv+9lLM8POUqhNuIsmPE8SVff7LxJ4gVyjJEKW4r0vHBA9MmkEHoCifVV62t0Uz0RrWkgqsPXbI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718009976; c=relaxed/simple; bh=kAf7SPBLso5zp49wUYubqs0YKzd/lC+tt+i0+MOxu64=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=mjrYeoJTQZA39YnvhirzUpwhmOnLbkj53iXiidupRL9IaiHc0O8oOPs7ZYOJcLJQpU4Bzr1aA4+jBxp70txhtj8uZH/SJRmshzf/EU0Jj/x0PDheiWyUZ0blYLvBpB57ArsXJamhjR3FTWZ5hqfZnZ3iUJSWfjb87fL5w/ClttA= 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=Uq1ealpY; arc=none smtp.client-ip=192.198.163.13 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="Uq1ealpY" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1718009974; x=1749545974; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=kAf7SPBLso5zp49wUYubqs0YKzd/lC+tt+i0+MOxu64=; b=Uq1ealpY4p14ZSL7xW/ZJSu5oMw2bkJy+4y5B7rZSU2KCvMWBLysszFS 2A5tq4lBAwzYR8zUDAGiirNmQxHkUyHUMeX75r/KivKQyT7v0G+1niwH3 kzBnsZ6uidEv77gRspEkt7KUjFuNAjDJ3WiA3OtVeIgo0XQKFsyATUHSU wxMJv6QOwxNGDGGe+o6JhScDjv/lFvZaWXwUpsGPxj5BP5bpDoDCT3rZg 3YHELKRNiOvuZYA6+y1yJ9H0GDqp06UGmqQDToVatgL++ChrOQ4mqaUbF uYlV0XtFYfJ7f4t/XeLmFXYlNwMJyWYAkXGHSNM2UHbKb1GzTsSakXQXm w==; X-CSE-ConnectionGUID: EtOWuowtRBKyEbMMOTP4Ug== X-CSE-MsgGUID: Qcjl1ZJuSGG0E615LVv1fQ== X-IronPort-AV: E=McAfee;i="6600,9927,11098"; a="17581898" X-IronPort-AV: E=Sophos;i="6.08,227,1712646000"; d="scan'208";a="17581898" Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by fmvoesa107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Jun 2024 01:59:34 -0700 X-CSE-ConnectionGUID: IZUNZ8cdRjO1AyWUbBMniA== X-CSE-MsgGUID: oS6yPYCwQEWB97mfMcpzCQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,227,1712646000"; d="scan'208";a="43432851" Received: from unknown (HELO allen-box.sh.intel.com) ([10.239.159.127]) by fmviesa003.fm.intel.com with ESMTP; 10 Jun 2024 01:59: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 , Jeff Johnson , ath10k@lists.infradead.org, ath11k@lists.infradead.org, iommu@lists.linux.dev, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Lu Baolu Subject: [PATCH v3 15/21] iommu/vt-d: Add helper to allocate paging domain Date: Mon, 10 Jun 2024 16:55:49 +0800 Message-Id: <20240610085555.88197-16-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240610085555.88197-1-baolu.lu@linux.intel.com> References: <20240610085555.88197-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 Reviewed-by: Jason Gunthorpe --- 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 Thu Feb 12 17:26:28 2026 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.13]) (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 E402812F397 for ; Mon, 10 Jun 2024 08:59:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.13 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718009981; cv=none; b=S2CIACcK3Rd9iWa9MCgsSCn/KlOVe2J+kxD9Nvm2ylkOH+czGhPwFkwpGVvXyyGnZScvmIN147aiJOkJTg2VWjw58rIoD3VQt+3whTzvLDoDBNw21zNZMotLwa2Uyurl7TPFrSjOGdtgNZRN2PAIG4aBpZmE7vzJCPdndqdiG7w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718009981; c=relaxed/simple; bh=KoW/D18MopXUFdHXQ6Q/PnnQkxmmhncr645BE4UuUac=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=sxv8YP+uY++sRPPpMPg7hFp1mZuW9D3xv2OTaHSqI9sX56g+G5vo9AuxCaUd+nDu8LIkXWB+eejuR9sU7uNPbxNwez9ZcS9AgR8oHd2PL0Nrfh68v41yjy6Dw3LTFU5E9jVFv/rR0HGfB0jNdwUWqXCOgUZgY9eb5TWy7wp52k0= 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=ee5RmNXN; arc=none smtp.client-ip=192.198.163.13 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="ee5RmNXN" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1718009980; x=1749545980; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=KoW/D18MopXUFdHXQ6Q/PnnQkxmmhncr645BE4UuUac=; b=ee5RmNXNHqCrOpwebV62qMDNcXbzPIoWRd9dnjF/lufKgA1UK8VNUnI8 7uZ/VTl4xyVcj3p+BzdYY8b8CSY15Z4X4It1JxMzYzfsApmV6m4/bB257 n3405TCusA6NJJgOw+5ag3qzrVdcAmKyX8RxqYb2FHEfmL882BeXxF8ON dM6hUt6KBZXxXdP06ZiUSSgoJFbPUq6bzwFeCb62mj5RVXo9EHZSnZsFS DXam8vpH+nEAPNdr/PY+uE0afRrdRVm4Lvr05RclK2IDKsoBL/+6oHMdJ pGBnP55mJPSKfprkpyYXrdlcUhbIKONvT+ldqTsW9akzB4VP7G7r2NdbN Q==; X-CSE-ConnectionGUID: n3lbY7ymRLuozA1hLvcL9w== X-CSE-MsgGUID: QjRr9R+fSXCgJ0Jb3rXuPQ== X-IronPort-AV: E=McAfee;i="6600,9927,11098"; a="17581921" X-IronPort-AV: E=Sophos;i="6.08,227,1712646000"; d="scan'208";a="17581921" Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by fmvoesa107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Jun 2024 01:59:39 -0700 X-CSE-ConnectionGUID: WBeOUXcZSv+NSHighHeLaw== X-CSE-MsgGUID: K/g9k9pOSl+Fcthl7CseqA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,227,1712646000"; d="scan'208";a="43432922" Received: from unknown (HELO allen-box.sh.intel.com) ([10.239.159.127]) by fmviesa003.fm.intel.com with ESMTP; 10 Jun 2024 01:59:35 -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 , Jeff Johnson , ath10k@lists.infradead.org, ath11k@lists.infradead.org, iommu@lists.linux.dev, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Lu Baolu Subject: [PATCH v3 16/21] ARM: dma-mapping: Pass device to arm_iommu_create_mapping() Date: Mon, 10 Jun 2024 16:55:50 +0800 Message-Id: <20240610085555.88197-17-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240610085555.88197-1-baolu.lu@linux.intel.com> References: <20240610085555.88197-1-baolu.lu@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Robin Murphy All users of ARM IOMMU mappings create them for a particular device, so change the interface to accept the device rather than forcing a vague indirection through a bus type. This prepares for making a similar change to iommu_domain_alloc() itself. Signed-off-by: Robin Murphy Signed-off-by: Lu Baolu --- arch/arm/include/asm/dma-iommu.h | 2 +- arch/arm/mm/dma-mapping.c | 8 ++++---- drivers/gpu/drm/exynos/exynos_drm_dma.c | 2 +- drivers/iommu/ipmmu-vmsa.c | 3 +-- drivers/iommu/mtk_iommu_v1.c | 3 +-- drivers/media/platform/ti/omap3isp/isp.c | 2 +- 6 files changed, 9 insertions(+), 11 deletions(-) diff --git a/arch/arm/include/asm/dma-iommu.h b/arch/arm/include/asm/dma-io= mmu.h index 82ec1ccf1fee..2ce4c5683e6d 100644 --- a/arch/arm/include/asm/dma-iommu.h +++ b/arch/arm/include/asm/dma-iommu.h @@ -24,7 +24,7 @@ struct dma_iommu_mapping { }; =20 struct dma_iommu_mapping * -arm_iommu_create_mapping(const struct bus_type *bus, dma_addr_t base, u64 = size); +arm_iommu_create_mapping(struct device *dev, dma_addr_t base, u64 size); =20 void arm_iommu_release_mapping(struct dma_iommu_mapping *mapping); =20 diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c index 5adf1769eee4..52f9c56cc3cb 100644 --- a/arch/arm/mm/dma-mapping.c +++ b/arch/arm/mm/dma-mapping.c @@ -1532,7 +1532,7 @@ static const struct dma_map_ops iommu_ops =3D { =20 /** * arm_iommu_create_mapping - * @bus: pointer to the bus holding the client device (for IOMMU calls) + * @dev: pointer to the client device (for IOMMU calls) * @base: start address of the valid IO address space * @size: maximum size of the valid IO address space * @@ -1544,7 +1544,7 @@ static const struct dma_map_ops iommu_ops =3D { * arm_iommu_attach_device function. */ struct dma_iommu_mapping * -arm_iommu_create_mapping(const struct bus_type *bus, dma_addr_t base, u64 = size) +arm_iommu_create_mapping(struct device *dev, dma_addr_t base, u64 size) { unsigned int bits =3D size >> PAGE_SHIFT; unsigned int bitmap_size =3D BITS_TO_LONGS(bits) * sizeof(long); @@ -1585,7 +1585,7 @@ arm_iommu_create_mapping(const struct bus_type *bus, = dma_addr_t base, u64 size) =20 spin_lock_init(&mapping->lock); =20 - mapping->domain =3D iommu_domain_alloc(bus); + mapping->domain =3D iommu_domain_alloc(dev->bus); if (!mapping->domain) goto err4; =20 @@ -1718,7 +1718,7 @@ static void arm_setup_iommu_dma_ops(struct device *de= v) dma_base =3D dma_range_map_min(dev->dma_range_map); size =3D dma_range_map_max(dev->dma_range_map) - dma_base; } - mapping =3D arm_iommu_create_mapping(dev->bus, dma_base, size); + mapping =3D arm_iommu_create_mapping(dev, dma_base, size); if (IS_ERR(mapping)) { pr_warn("Failed to create %llu-byte IOMMU mapping for device %s\n", size, dev_name(dev)); diff --git a/drivers/gpu/drm/exynos/exynos_drm_dma.c b/drivers/gpu/drm/exyn= os/exynos_drm_dma.c index e2c7373f20c6..6a6761935224 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_dma.c +++ b/drivers/gpu/drm/exynos/exynos_drm_dma.c @@ -110,7 +110,7 @@ int exynos_drm_register_dma(struct drm_device *drm, str= uct device *dev, void *mapping =3D NULL; =20 if (IS_ENABLED(CONFIG_ARM_DMA_USE_IOMMU)) - mapping =3D arm_iommu_create_mapping(&platform_bus_type, + mapping =3D arm_iommu_create_mapping(dev, EXYNOS_DEV_ADDR_START, EXYNOS_DEV_ADDR_SIZE); else if (IS_ENABLED(CONFIG_IOMMU_DMA)) mapping =3D iommu_get_domain_for_dev(priv->dma_dev); diff --git a/drivers/iommu/ipmmu-vmsa.c b/drivers/iommu/ipmmu-vmsa.c index b657cc09605f..ff55b8c30712 100644 --- a/drivers/iommu/ipmmu-vmsa.c +++ b/drivers/iommu/ipmmu-vmsa.c @@ -804,8 +804,7 @@ static int ipmmu_init_arm_mapping(struct device *dev) if (!mmu->mapping) { struct dma_iommu_mapping *mapping; =20 - mapping =3D arm_iommu_create_mapping(&platform_bus_type, - SZ_1G, SZ_2G); + mapping =3D arm_iommu_create_mapping(dev, SZ_1G, SZ_2G); if (IS_ERR(mapping)) { dev_err(mmu->dev, "failed to create ARM IOMMU mapping\n"); ret =3D PTR_ERR(mapping); diff --git a/drivers/iommu/mtk_iommu_v1.c b/drivers/iommu/mtk_iommu_v1.c index d6e4002200bd..da61df27582d 100644 --- a/drivers/iommu/mtk_iommu_v1.c +++ b/drivers/iommu/mtk_iommu_v1.c @@ -439,8 +439,7 @@ static int mtk_iommu_v1_create_mapping(struct device *d= ev, mtk_mapping =3D data->mapping; if (!mtk_mapping) { /* MTK iommu support 4GB iova address space. */ - mtk_mapping =3D arm_iommu_create_mapping(&platform_bus_type, - 0, 1ULL << 32); + mtk_mapping =3D arm_iommu_create_mapping(dev, 0, 1ULL << 32); if (IS_ERR(mtk_mapping)) return PTR_ERR(mtk_mapping); =20 diff --git a/drivers/media/platform/ti/omap3isp/isp.c b/drivers/media/platf= orm/ti/omap3isp/isp.c index 1cda23244c7b..91101ba88ef0 100644 --- a/drivers/media/platform/ti/omap3isp/isp.c +++ b/drivers/media/platform/ti/omap3isp/isp.c @@ -1965,7 +1965,7 @@ static int isp_attach_iommu(struct isp_device *isp) * Create the ARM mapping, used by the ARM DMA mapping core to allocate * VAs. This will allocate a corresponding IOMMU domain. */ - mapping =3D arm_iommu_create_mapping(&platform_bus_type, SZ_1G, SZ_2G); + mapping =3D arm_iommu_create_mapping(isp->dev, SZ_1G, SZ_2G); if (IS_ERR(mapping)) { dev_err(isp->dev, "failed to create ARM IOMMU mapping\n"); return PTR_ERR(mapping); --=20 2.34.1 From nobody Thu Feb 12 17:26:28 2026 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.13]) (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 B992B13212D for ; Mon, 10 Jun 2024 08:59:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.13 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718009986; cv=none; b=X8k5chvRaxH/lAmeBNFaJSn8BNNF9k4trXCB0j0/xm3eRIuGNshpONWo8LPHi3kbsVa4sVmr7zqJO+b5oBTZr6PaV0P+WZT20krYdrpnd/PdXWaOHsNjiqZUHiraDVoNK6gNorklYwZKjoMMqy1nK3ifrNSgjLfHKhcB9C0BuTY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718009986; c=relaxed/simple; bh=9YhH5rA1b+ID5Xo/cB0X+5j1j2KZOf2zs+wByq5adpQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=odq9bPgybXM9UzHTlaURbz61hvtCU58askqPhPPWNHBPQJIcSaq2Y/IG8FIX8znibDsCBvNRLIcO8cjcbbP/JYK5xMqCyZcc/QMyAfMQm6kFaEu6GoEqHGiTcB9uPACl8QpF8DWRdJs7r38PPGAMPu6+oNyqkCE6aMGBXrCr7XY= 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=aFKu4zVZ; arc=none smtp.client-ip=192.198.163.13 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="aFKu4zVZ" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1718009984; x=1749545984; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=9YhH5rA1b+ID5Xo/cB0X+5j1j2KZOf2zs+wByq5adpQ=; b=aFKu4zVZ8PDA2m8Wv68/W2VlAxZ6J1GuhnB3cBb/Ov/mtQhYHPA9FcNd 8J7B+VLO6yw2zBBhR9vsK4jHyIroFjR9aKBO7mcASqgD/vY9ncxs6XpSV NEOMk7uXnIzvVirgzA+LaGcyn7F2JXDroMXpqH7mMbchHgW6L4kqgpO5D Uig/3H8hCCGKAdNclmGqxTwOicgmE4gJvozHLCY/rEoJDkavWWWluHfDr yYPNWdiUv1SCvHxBhO//jr1oitPJVhCec4+Ssu4Gt1490iT3FVi1iU46i k0d+BwX3MFtkv7yHWmZY61uAo6/Kl0q1Fj2u+gR7tbfbLbnPuYqpXMUpO g==; X-CSE-ConnectionGUID: z4X0T0GxQtahtgRFQjdTbw== X-CSE-MsgGUID: OQq9hp3rTqexH1+t0gQz/g== X-IronPort-AV: E=McAfee;i="6600,9927,11098"; a="17581948" X-IronPort-AV: E=Sophos;i="6.08,227,1712646000"; d="scan'208";a="17581948" Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by fmvoesa107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Jun 2024 01:59:44 -0700 X-CSE-ConnectionGUID: 0ICSXuCKQ7SlB4hgj7FQWA== X-CSE-MsgGUID: YSw+GqFMR2OnMFZIW7S7Hw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,227,1712646000"; d="scan'208";a="43432960" Received: from unknown (HELO allen-box.sh.intel.com) ([10.239.159.127]) by fmviesa003.fm.intel.com with ESMTP; 10 Jun 2024 01:59:40 -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 , Jeff Johnson , ath10k@lists.infradead.org, ath11k@lists.infradead.org, iommu@lists.linux.dev, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Lu Baolu Subject: [PATCH v3 17/21] ARM: dma-mapping: Use iommu_paging_domain_alloc() Date: Mon, 10 Jun 2024 16:55:51 +0800 Message-Id: <20240610085555.88197-18-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240610085555.88197-1-baolu.lu@linux.intel.com> References: <20240610085555.88197-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" Since arm_iommu_create_mapping() now accepts the device, let's replace iommu_domain_alloc() with iommu_paging_domain_alloc() to retire the former. Signed-off-by: Lu Baolu Reviewed-by: Jason Gunthorpe --- arch/arm/mm/dma-mapping.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c index 52f9c56cc3cb..88c2d68a69c9 100644 --- a/arch/arm/mm/dma-mapping.c +++ b/arch/arm/mm/dma-mapping.c @@ -1585,9 +1585,11 @@ arm_iommu_create_mapping(struct device *dev, dma_add= r_t base, u64 size) =20 spin_lock_init(&mapping->lock); =20 - mapping->domain =3D iommu_domain_alloc(dev->bus); - if (!mapping->domain) + mapping->domain =3D iommu_paging_domain_alloc(dev); + if (IS_ERR(mapping->domain)) { + err =3D PTR_ERR(mapping->domain); goto err4; + } =20 kref_init(&mapping->kref); return mapping; --=20 2.34.1 From nobody Thu Feb 12 17:26:28 2026 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.13]) (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 0F0A67BAFF for ; Mon, 10 Jun 2024 08:59:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.13 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718009991; cv=none; b=I7BbvRglkg4GCLdLLRepMEEfFCiKh1vKcXRqhLuQQflmWynvN0/UXJ+FJx6n6e4TAj6rtVhrSEVCUrAiIYW8jk8zQlyb5T+a8NZ1arG1/G/rmbhSmNDimjSl2psznlhWNifJ2B60GKmdU7IuhjO+CQF8ErG4cKGCl9T4/PLWbEY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718009991; c=relaxed/simple; bh=2RzKLZKa9aMbeh8zX7gRXSDK8Hv/vXOsjqYlhYXqS5Y=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=pf2+1vBBnO7twqWf67J5gk6PKVY5KaZGLfMGgF6hqJXc6OkhzxYFK89ofoIyLlgMq09xV6QOus/1x/RL1F3qvB02tp/+6D+fLLJjeBuIMiayiVlE8N7oGdqqebf0JOZfEqyzzbeHUV3v1H2l6rKIHXGwKE+K/71NMYVp8uSYzLY= 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=m+vJEdC9; arc=none smtp.client-ip=192.198.163.13 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="m+vJEdC9" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1718009990; x=1749545990; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=2RzKLZKa9aMbeh8zX7gRXSDK8Hv/vXOsjqYlhYXqS5Y=; b=m+vJEdC9Iej41wk0zA+0I82K8ei1Y5Tf4vxWr3iPw4z3euj86Y/1n8ce W2t1zQ+morYxoWtfqwYtZE6gk6ppJg/E54lGKyM85XK0EPiCePwZ5FwgI CYWen3pRQOnOMtPJbZRQnAxTQXPu6VUsOROpCKHhrpn/iNT45mQqWgUXP d3nMa9c3w6p6Y3d87GYkGymOMtr986h3OvPaHQOuCusDMt8DMIoA8N+MU 5xwR8XCSL3cPiz/g3sfqEPpDahEDB2/0Hang9VTGhIxX+pZ1po5HjS8Bq Ga9egzQ4OfC2tfpr01ia6lo2X31N/tQuj9OGEEJDWJ1xZpin8goXUW3A9 g==; X-CSE-ConnectionGUID: O/z7bgccT9CozMb1okql5Q== X-CSE-MsgGUID: nJb3C9WwSp+B993c2u7jmg== X-IronPort-AV: E=McAfee;i="6600,9927,11098"; a="17581971" X-IronPort-AV: E=Sophos;i="6.08,227,1712646000"; d="scan'208";a="17581971" Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by fmvoesa107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Jun 2024 01:59:49 -0700 X-CSE-ConnectionGUID: QxgTd28SQrGRjUA9euRVfg== X-CSE-MsgGUID: gs8aoJhZQmubGCpSr1nBLw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,227,1712646000"; d="scan'208";a="43433021" Received: from unknown (HELO allen-box.sh.intel.com) ([10.239.159.127]) by fmviesa003.fm.intel.com with ESMTP; 10 Jun 2024 01:59:45 -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 , Jeff Johnson , ath10k@lists.infradead.org, ath11k@lists.infradead.org, iommu@lists.linux.dev, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Lu Baolu Subject: [PATCH v3 18/21] drm/rockchip: Use iommu_paging_domain_alloc() Date: Mon, 10 Jun 2024 16:55:52 +0800 Message-Id: <20240610085555.88197-19-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240610085555.88197-1-baolu.lu@linux.intel.com> References: <20240610085555.88197-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 <421be3ee36a4> ("drm/rockchip: Refactor IOMMU initialisation") has refactored rockchip_drm_init_iommu() to pass a device that the domain is allocated for. Replace iommu_domain_alloc() with iommu_paging_domain_alloc() to retire the former. Signed-off-by: Lu Baolu Reviewed-by: Jason Gunthorpe --- drivers/gpu/drm/rockchip/rockchip_drm_drv.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c b/drivers/gpu/drm/= rockchip/rockchip_drm_drv.c index ab55d7132550..52126ffb9280 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c +++ b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c @@ -103,13 +103,17 @@ static int rockchip_drm_init_iommu(struct drm_device = *drm_dev) struct rockchip_drm_private *private =3D drm_dev->dev_private; struct iommu_domain_geometry *geometry; u64 start, end; + int ret; =20 if (IS_ERR_OR_NULL(private->iommu_dev)) return 0; =20 - private->domain =3D iommu_domain_alloc(private->iommu_dev->bus); - if (!private->domain) - return -ENOMEM; + private->domain =3D iommu_paging_domain_alloc(private->iommu_dev); + if (IS_ERR(private->domain)) { + ret =3D PTR_ERR(private->domain); + private->domain =3D NULL; + return ret; + } =20 geometry =3D &private->domain->geometry; start =3D geometry->aperture_start; --=20 2.34.1 From nobody Thu Feb 12 17:26:28 2026 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.13]) (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 511B17C09E for ; Mon, 10 Jun 2024 08:59:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.13 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718009998; cv=none; b=S+ItXFBxR0ALjt76hLOy5jr+ZKKBlnrTAuROEBbeVEf2KBL8HRbD6CoWkNc9+nMIXiIC6cvZx8Xc3sFsmt5IqIMTBnQAVoI8OBTDj9C45cvjuX/ht5vsjdIioCKyXOLt8EF75pK4uQ1RaCQfkNww/SvAnTCZlhGG6QF5a5tO1nA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718009998; c=relaxed/simple; bh=I56l8aUrWEsOdJKWYfI6TJlpnl4t+tX3NQmfYGnyV7M=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=BeDWnhf1pujv5Dvy8rjWBUFUWOVxQz+sv7i2j2dCk62jsQIIJq+GCkpXGrhVnjIQl795DKLklBbbK+jAbEj/977+c/V1TH9xyMi/zeIycqdLCAJNDR+x63ODJIcGQ9incBVanUO05q3iUG6n8T0g9UV2sX+M496apoFAhXV+Apo= 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=GwWZ25QR; arc=none smtp.client-ip=192.198.163.13 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="GwWZ25QR" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1718009997; x=1749545997; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=I56l8aUrWEsOdJKWYfI6TJlpnl4t+tX3NQmfYGnyV7M=; b=GwWZ25QRKt38SZPrBw59wJMufvbOz2Wu90Bh+6iPI/li6jb6f+/K6ZHp lnQwn7dhazxM+ieIkO/TkYEegRvlG4uvGiCIOxUzD8IJuxzxy4skF5flD Ok50pwaSetJvrv3uQApPrFXx3ls5VXL3Ie8I+LyLQjSuEiP5woD+F8SB3 LMMhP7hplCN+l65AoAhVdBBZysf57Qu4tbcdVxN28GtQKTi2nyePUr5iV VPoqmKX/vNKp7zceUyuS4PcmM5Xu1wmlmmyV4tYlEF51+U8s9F+LHA6vR vblB5soDUY9KVRhpXUcxUKfLrEuhmDAx5NWRuW4BNPxEV79MynMW91ykB w==; X-CSE-ConnectionGUID: bH587zMWQNOziq7gB7Gpiw== X-CSE-MsgGUID: NMKR1Ws3TWCa+GVUi+x1YA== X-IronPort-AV: E=McAfee;i="6600,9927,11098"; a="17581990" X-IronPort-AV: E=Sophos;i="6.08,227,1712646000"; d="scan'208";a="17581990" Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by fmvoesa107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Jun 2024 01:59:56 -0700 X-CSE-ConnectionGUID: dSiXcWhERE2aZC+rbkMwCw== X-CSE-MsgGUID: zTw8PCNRSvSb9YRaNVvOxA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,227,1712646000"; d="scan'208";a="43433094" Received: from unknown (HELO allen-box.sh.intel.com) ([10.239.159.127]) by fmviesa003.fm.intel.com with ESMTP; 10 Jun 2024 01:59:50 -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 , Jeff Johnson , ath10k@lists.infradead.org, ath11k@lists.infradead.org, iommu@lists.linux.dev, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Lu Baolu Subject: [PATCH v3 19/21] drm/tegra: Remove call to iommu_domain_alloc() Date: Mon, 10 Jun 2024 16:55:53 +0800 Message-Id: <20240610085555.88197-20-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240610085555.88197-1-baolu.lu@linux.intel.com> References: <20240610085555.88197-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 the bus structure. The iommu subsystem no longer relies on bus for operations. So iommu_domain_alloc() interface is no longer relevant. Normally, iommu_paging_domain_alloc() could be a replacement for iommu_domain_alloc() if the caller has the right device for IOMMU API use. Unfortunately, this is not the case for this driver. Iterate the devices on the platform bus and find a suitable device whose device DMA is translated by an IOMMU. Then use this device to allocate an iommu domain. The iommu subsystem prevents domains allocated by one iommu driver from being attached to devices managed by any different iommu driver. Signed-off-by: Lu Baolu --- drivers/gpu/drm/tegra/drm.c | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/tegra/drm.c b/drivers/gpu/drm/tegra/drm.c index 03d1c76aec2d..ee391f859992 100644 --- a/drivers/gpu/drm/tegra/drm.c +++ b/drivers/gpu/drm/tegra/drm.c @@ -1133,6 +1133,17 @@ static bool host1x_drm_wants_iommu(struct host1x_dev= ice *dev) return domain !=3D NULL; } =20 +static int iommu_mapped_device(struct device *dev, void *data) +{ + struct device **iommu_dev =3D data; + + if (!device_iommu_mapped(dev)) + return 0; + + *iommu_dev =3D dev; + return 1; +} + static int host1x_drm_probe(struct host1x_device *dev) { struct tegra_drm *tegra; @@ -1149,16 +1160,21 @@ static int host1x_drm_probe(struct host1x_device *d= ev) goto put; } =20 - if (host1x_drm_wants_iommu(dev) && iommu_present(&platform_bus_type)) { - tegra->domain =3D iommu_domain_alloc(&platform_bus_type); - if (!tegra->domain) { - err =3D -ENOMEM; - goto free; + if (host1x_drm_wants_iommu(dev)) { + struct device *iommu_dev =3D NULL; + + bus_for_each_dev(&platform_bus_type, NULL, &iommu_dev, iommu_mapped_devi= ce); + if (iommu_dev) { + tegra->domain =3D iommu_paging_domain_alloc(iommu_dev); + if (IS_ERR(tegra->domain)) { + err =3D PTR_ERR(tegra->domain); + goto free; + } + + err =3D iova_cache_get(); + if (err < 0) + goto domain; } - - err =3D iova_cache_get(); - if (err < 0) - goto domain; } =20 mutex_init(&tegra->clients_lock); --=20 2.34.1 From nobody Thu Feb 12 17:26:28 2026 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.13]) (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 9C9DA13A26B for ; Mon, 10 Jun 2024 09:00:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.13 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718010003; cv=none; b=Q7DarH8E1gsMfMIO9iQmKCNOCxLiSEXQMNqTkHJmCr0AoTvfidmY/xgjtVdVkBayHx3kj9EjL1umGcOwrZYpmkVHgCabCyDdg4YHd4kWeCquNnH1RZus1IW4zEKhJ6+fe5VPY+p39rhnWq52855gTxab/sUHGfe/26lniiywscw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718010003; c=relaxed/simple; bh=wZSuoOsJ9R3MpkLrN5YRfrHjzrkwvK0M+Y3osdd4hrI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=jvkSA0GCtRv2Ij8hGE716WIS+Xxx8vvX4gI8gMcz+xwAtKX/SsKjv7vSLDcbe98fnBHXni0RuOCH5gvVee2vUXkpnZ8KlZ/B8n0pu6a3/a9s0BL6XvL88uIB49Sv8+5aKLM0CkcNsl0SIGc2TWJCzdR0LfRGNRU0edHtqq4spqg= 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=j6Ykq3eH; arc=none smtp.client-ip=192.198.163.13 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="j6Ykq3eH" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1718010001; x=1749546001; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=wZSuoOsJ9R3MpkLrN5YRfrHjzrkwvK0M+Y3osdd4hrI=; b=j6Ykq3eHqWLfRFXMh1h0NdwpHI8EdOGnpwCMzm84bNFJmFGaIHH3KKoe /DXGEmwn6Wig8ke0GYAx1tfdW9xZBOZJ5sPFyNm+vRW7ZyIcNBNhI/qoZ nWvmk+CcUb0DT1peLDziwtI6WaTDUEJax9Gerl/yOuY2wOqR9tjaXekmX K+jB2c9TYQnyGkBr8u3CGWBIRpY+ixC4zMoHvKOZHq49boVzx/znjcOSt MZFIEhknWtVoIxh5pue/U5YzW0YiTI5juum1YheQFUa6q8BwIR4+iZwNu Db3M3/yHNReu13rTQI50F+VzMkuEpbPFedDAkVAgZicnifOADoR0ZLyf8 A==; X-CSE-ConnectionGUID: iQRYi6yXQQyOwpOynsSewQ== X-CSE-MsgGUID: D+2+XpKKTmGipNd5Ru/Ouw== X-IronPort-AV: E=McAfee;i="6600,9927,11098"; a="17582003" X-IronPort-AV: E=Sophos;i="6.08,227,1712646000"; d="scan'208";a="17582003" Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by fmvoesa107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Jun 2024 02:00:01 -0700 X-CSE-ConnectionGUID: UkJOBireQRy0iFWBh3TABg== X-CSE-MsgGUID: GPssOU7ITwWVQqYExEAGUw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,227,1712646000"; d="scan'208";a="43433176" Received: from unknown (HELO allen-box.sh.intel.com) ([10.239.159.127]) by fmviesa003.fm.intel.com with ESMTP; 10 Jun 2024 01:59:57 -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 , Jeff Johnson , ath10k@lists.infradead.org, ath11k@lists.infradead.org, iommu@lists.linux.dev, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Lu Baolu Subject: [PATCH v3 20/21] iommu: Remove iommu_present() Date: Mon, 10 Jun 2024 16:55:54 +0800 Message-Id: <20240610085555.88197-21-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240610085555.88197-1-baolu.lu@linux.intel.com> References: <20240610085555.88197-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 iommu_present() interface is no longer used in the tree anymore. Remove it to avoid dead code. Signed-off-by: Lu Baolu Reviewed-by: Jason Gunthorpe --- include/linux/iommu.h | 6 ------ drivers/iommu/iommu.c | 25 ------------------------- 2 files changed, 31 deletions(-) diff --git a/include/linux/iommu.h b/include/linux/iommu.h index 46f1348f1f0a..ba0b27afc256 100644 --- a/include/linux/iommu.h +++ b/include/linux/iommu.h @@ -776,7 +776,6 @@ static inline void iommu_iotlb_gather_init(struct iommu= _iotlb_gather *gather) } =20 extern int bus_iommu_probe(const struct bus_type *bus); -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); @@ -1072,11 +1071,6 @@ struct iommu_iotlb_gather {}; struct iommu_dirty_bitmap {}; struct iommu_dirty_ops {}; =20 -static inline bool iommu_present(const struct bus_type *bus) -{ - return false; -} - static inline bool device_iommu_capable(struct device *dev, enum iommu_cap= cap) { return false; diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index e03c71a34347..c7ebdf96e4bc 100644 --- a/drivers/iommu/iommu.c +++ b/drivers/iommu/iommu.c @@ -1846,31 +1846,6 @@ int bus_iommu_probe(const struct bus_type *bus) return 0; } =20 -/** - * iommu_present() - make platform-specific assumptions about an IOMMU - * @bus: bus to check - * - * Do not use this function. You want device_iommu_mapped() instead. - * - * Return: true if some IOMMU is present and aware of devices on the given= bus; - * in general it may not be the only IOMMU, and it may not have anything t= o do - * with whatever device you are ultimately interested in. - */ -bool iommu_present(const struct bus_type *bus) -{ - bool ret =3D false; - - for (int i =3D 0; i < ARRAY_SIZE(iommu_buses); i++) { - if (iommu_buses[i] =3D=3D bus) { - spin_lock(&iommu_device_lock); - ret =3D !list_empty(&iommu_device_list); - spin_unlock(&iommu_device_lock); - } - } - return ret; -} -EXPORT_SYMBOL_GPL(iommu_present); - /** * device_iommu_capable() - check for a general IOMMU capability * @dev: device to which the capability would be relevant, if available --=20 2.34.1 From nobody Thu Feb 12 17:26:28 2026 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.13]) (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 0CCFC74057 for ; Mon, 10 Jun 2024 09:00:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.13 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718010018; cv=none; b=YANcknIFpTYrbwvfrMctvJlvwSO++2MzT+NE39uWwUbpB1SEA3HiuQXWFxakusnTjBFUKG+XiS1+7dp4q+is0jPlN9WOWcRWhlFbXmRnQUb523UVoSxEYtk/yoXXkuxfOrTmbl8nyBgzJmXZz1QRwA+4Uvm0nFWnZN0P3YfyUeI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718010018; c=relaxed/simple; bh=lXwMWVF8JncqaJ2IdYqMFQdlvzTBWJiMYc2r7xARixg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Q4CyiibvalCeY1124el2yUymkFg5jeDdEwtO2hFBA1z/ZSE5qxIE9icGH3jZwXSMhxVwwEuReHm7Dh9710N22HumlY7dnOIUXnITSsKK3YfdwqQCBUo+RCCQwgnuBv2qu7QJryCHdwqAVXSv+EwZCoxiQiRyawKdu+H1E8+7sGw= 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=nerIPGJa; arc=none smtp.client-ip=192.198.163.13 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="nerIPGJa" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1718010017; x=1749546017; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=lXwMWVF8JncqaJ2IdYqMFQdlvzTBWJiMYc2r7xARixg=; b=nerIPGJau0+FdnVoTAXh5xZRq3kGzgDFu9zN8+qMENbHhYaeilCPF3HL azhrdypA9v3mcsTwaXWpUsvvOIZFrwC5nxRGqV6KIYHjgAflVXwD9v++l jHb4TBc3sptsAT+q92Z8Rqlu1VS9k/Xakj2sNPs24CwF9soyFO4HFIYP9 zxIgeIinUt1eGthf6Av2UwtV3DiWBRkryST1NQgwp1UKTff9DcvDPHeli jjG+mbvhfxH9EHOiaZi+yzjQBHbc4OjutDtEBe0yHIKICukKx5dfmNDdY M6YoG3vD6dRyIK0vTrauNvH5tfRI1UPJev7vP4gdkAm+417wnCPwdxNk3 w==; X-CSE-ConnectionGUID: bucudDS6TUKPVnEsn+g7iA== X-CSE-MsgGUID: Z0JlwzNKQISpDEKouVpfhA== X-IronPort-AV: E=McAfee;i="6600,9927,11098"; a="17582045" X-IronPort-AV: E=Sophos;i="6.08,227,1712646000"; d="scan'208";a="17582045" Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by fmvoesa107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Jun 2024 02:00:16 -0700 X-CSE-ConnectionGUID: zigQTUGjQ5u81Ly6CGYyQw== X-CSE-MsgGUID: dHXKB8LTTX6N7SOxiQc5rQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,227,1712646000"; d="scan'208";a="43433312" Received: from unknown (HELO allen-box.sh.intel.com) ([10.239.159.127]) by fmviesa003.fm.intel.com with ESMTP; 10 Jun 2024 02:00:02 -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 , Jeff Johnson , ath10k@lists.infradead.org, ath11k@lists.infradead.org, iommu@lists.linux.dev, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Lu Baolu Subject: [PATCH v3 21/21] iommu: Remove iommu_domain_alloc() Date: Mon, 10 Jun 2024 16:55:55 +0800 Message-Id: <20240610085555.88197-22-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240610085555.88197-1-baolu.lu@linux.intel.com> References: <20240610085555.88197-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 iommu_domain_alloc() interface is no longer used in the tree anymore. Remove it to avoid dead code. There is increasing demand for supporting multiple IOMMU drivers, and this is the last bus-based thing standing in the way of that. Signed-off-by: Lu Baolu Reviewed-by: Jason Gunthorpe --- include/linux/iommu.h | 6 ------ drivers/iommu/iommu.c | 36 ------------------------------------ 2 files changed, 42 deletions(-) diff --git a/include/linux/iommu.h b/include/linux/iommu.h index ba0b27afc256..bff6e7e81fa3 100644 --- a/include/linux/iommu.h +++ b/include/linux/iommu.h @@ -778,7 +778,6 @@ static inline void iommu_iotlb_gather_init(struct iommu= _iotlb_gather *gather) extern int bus_iommu_probe(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_paging_domain_alloc(struct device *dev); extern void iommu_domain_free(struct iommu_domain *domain); extern int iommu_attach_device(struct iommu_domain *domain, @@ -1076,11 +1075,6 @@ static inline bool device_iommu_capable(struct devic= e *dev, enum iommu_cap cap) return false; } =20 -static inline struct iommu_domain *iommu_domain_alloc(const struct bus_typ= e *bus) -{ - return NULL; -} - static inline struct iommu_domain *iommu_paging_domain_alloc(struct device= *dev) { return ERR_PTR(-ENODEV); diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index c7ebdf96e4bc..8212fed27e18 100644 --- a/drivers/iommu/iommu.c +++ b/drivers/iommu/iommu.c @@ -1975,42 +1975,6 @@ __iommu_group_domain_alloc(struct iommu_group *group= , unsigned int type) return __iommu_domain_alloc(dev_iommu_ops(dev), dev, type); } =20 -static int __iommu_domain_alloc_dev(struct device *dev, void *data) -{ - const struct iommu_ops **ops =3D data; - - if (!dev_has_iommu(dev)) - return 0; - - if (WARN_ONCE(*ops && *ops !=3D dev_iommu_ops(dev), - "Multiple IOMMU drivers present for bus %s, which the public IOMMU= API can't fully support yet. You will still need to disable one or more fo= r this to work, sorry!\n", - dev_bus_name(dev))) - return -EBUSY; - - *ops =3D dev_iommu_ops(dev); - return 0; -} - -/* - * 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; - int err =3D bus_for_each_dev(bus, NULL, &ops, __iommu_domain_alloc_dev); - struct iommu_domain *domain; - - if (err || !ops) - return NULL; - - domain =3D __iommu_domain_alloc(ops, NULL, IOMMU_DOMAIN_UNMANAGED); - if (IS_ERR(domain)) - return NULL; - return domain; -} -EXPORT_SYMBOL_GPL(iommu_domain_alloc); - /** * iommu_paging_domain_alloc() - Allocate a paging domain * @dev: device for which the domain is allocated --=20 2.34.1