+++ /dev/null
-From b0a7b2647cf144cc009330beba9e75dbc2249a91 Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Wed, 13 Sep 2023 10:43:34 -0300
-Subject: iommu: Add iommu_ops->identity_domain
-
-From: Jason Gunthorpe <jgg@nvidia.com>
-
-[ Upstream commit df31b298477e65a01deff0af352be3a61524d930 ]
-
-This allows a driver to set a global static to an IDENTITY domain and
-the core code will automatically use it whenever an IDENTITY domain
-is requested.
-
-By making it always available it means the IDENTITY can be used in error
-handling paths to force the iommu driver into a known state. Devices
-implementing global static identity domains should avoid failing their
-attach_dev ops.
-
-To make global static domains simpler allow drivers to omit their free
-function and update the iommufd selftest.
-
-Convert rockchip to use the new mechanism.
-
-Tested-by: Steven Price <steven.price@arm.com>
-Tested-by: Marek Szyprowski <m.szyprowski@samsung.com>
-Tested-by: Nicolin Chen <nicolinc@nvidia.com>
-Reviewed-by: Lu Baolu <baolu.lu@linux.intel.com>
-Reviewed-by: Jerry Snitselaar <jsnitsel@redhat.com>
-Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
-Link: https://lore.kernel.org/r/1-v8-81230027b2fa+9d-iommu_all_defdom_jgg@nvidia.com
-Signed-off-by: Joerg Roedel <jroedel@suse.de>
-Stable-dep-of: 229e6ee43d2a ("iommu/arm-smmu: Defer probe of clients after smmu device bound")
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- drivers/iommu/iommu.c | 6 +++++-
- drivers/iommu/iommufd/selftest.c | 5 -----
- drivers/iommu/rockchip-iommu.c | 9 +--------
- include/linux/iommu.h | 3 +++
- 4 files changed, 9 insertions(+), 14 deletions(-)
-
-diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
-index 3f1029c0825e9..e97299987d43f 100644
---- a/drivers/iommu/iommu.c
-+++ b/drivers/iommu/iommu.c
-@@ -1979,6 +1979,9 @@ static struct iommu_domain *__iommu_domain_alloc(const struct bus_type *bus,
- if (bus == NULL || bus->iommu_ops == NULL)
- return NULL;
-
-+ if (alloc_type == IOMMU_DOMAIN_IDENTITY && bus->iommu_ops->identity_domain)
-+ return bus->iommu_ops->identity_domain;
-+
- domain = bus->iommu_ops->domain_alloc(alloc_type);
- if (!domain)
- return NULL;
-@@ -2012,7 +2015,8 @@ void iommu_domain_free(struct iommu_domain *domain)
- if (domain->type == IOMMU_DOMAIN_SVA)
- mmdrop(domain->mm);
- iommu_put_dma_cookie(domain);
-- domain->ops->free(domain);
-+ if (domain->ops->free)
-+ domain->ops->free(domain);
- }
- EXPORT_SYMBOL_GPL(iommu_domain_free);
-
-diff --git a/drivers/iommu/iommufd/selftest.c b/drivers/iommu/iommufd/selftest.c
-index 00b794d74e03b..d29e438377405 100644
---- a/drivers/iommu/iommufd/selftest.c
-+++ b/drivers/iommu/iommufd/selftest.c
-@@ -126,10 +126,6 @@ struct selftest_obj {
- };
- };
-
--static void mock_domain_blocking_free(struct iommu_domain *domain)
--{
--}
--
- static int mock_domain_nop_attach(struct iommu_domain *domain,
- struct device *dev)
- {
-@@ -137,7 +133,6 @@ static int mock_domain_nop_attach(struct iommu_domain *domain,
- }
-
- static const struct iommu_domain_ops mock_blocking_ops = {
-- .free = mock_domain_blocking_free,
- .attach_dev = mock_domain_nop_attach,
- };
-
-diff --git a/drivers/iommu/rockchip-iommu.c b/drivers/iommu/rockchip-iommu.c
-index 8ff69fbf9f65d..033678f2f8b3a 100644
---- a/drivers/iommu/rockchip-iommu.c
-+++ b/drivers/iommu/rockchip-iommu.c
-@@ -989,13 +989,8 @@ static int rk_iommu_identity_attach(struct iommu_domain *identity_domain,
- return 0;
- }
-
--static void rk_iommu_identity_free(struct iommu_domain *domain)
--{
--}
--
- static struct iommu_domain_ops rk_identity_ops = {
- .attach_dev = rk_iommu_identity_attach,
-- .free = rk_iommu_identity_free,
- };
-
- static struct iommu_domain rk_identity_domain = {
-@@ -1059,9 +1054,6 @@ static struct iommu_domain *rk_iommu_domain_alloc(unsigned type)
- {
- struct rk_iommu_domain *rk_domain;
-
-- if (type == IOMMU_DOMAIN_IDENTITY)
-- return &rk_identity_domain;
--
- if (type != IOMMU_DOMAIN_UNMANAGED && type != IOMMU_DOMAIN_DMA)
- return NULL;
-
-@@ -1186,6 +1178,7 @@ static int rk_iommu_of_xlate(struct device *dev,
- }
-
- static const struct iommu_ops rk_iommu_ops = {
-+ .identity_domain = &rk_identity_domain,
- .domain_alloc = rk_iommu_domain_alloc,
- .probe_device = rk_iommu_probe_device,
- .release_device = rk_iommu_release_device,
-diff --git a/include/linux/iommu.h b/include/linux/iommu.h
-index b6ef263e85c06..0274d12a48e1b 100644
---- a/include/linux/iommu.h
-+++ b/include/linux/iommu.h
-@@ -260,6 +260,8 @@ struct iommu_iotlb_gather {
- * will be blocked by the hardware.
- * @pgsize_bitmap: bitmap of all possible supported page sizes
- * @owner: Driver module providing these ops
-+ * @identity_domain: An always available, always attachable identity
-+ * translation.
- */
- struct iommu_ops {
- bool (*capable)(struct device *dev, enum iommu_cap);
-@@ -294,6 +296,7 @@ struct iommu_ops {
- const struct iommu_domain_ops *default_domain_ops;
- unsigned long pgsize_bitmap;
- struct module *owner;
-+ struct iommu_domain *identity_domain;
- };
-
- /**
---
-2.43.0
-
-From 62dc845a353efab2254480df8ae7d06175627313 Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
+From 229e6ee43d2a160a1592b83aad620d6027084aad Mon Sep 17 00:00:00 2001
+From: Pratyush Brahma <quic_pbrahma@quicinc.com>
Date: Fri, 4 Oct 2024 14:34:28 +0530
Subject: iommu/arm-smmu: Defer probe of clients after smmu device bound
From: Pratyush Brahma <quic_pbrahma@quicinc.com>
-[ Upstream commit 229e6ee43d2a160a1592b83aad620d6027084aad ]
+commit 229e6ee43d2a160a1592b83aad620d6027084aad upstream.
Null pointer dereference occurs due to a race between smmu
driver probe and client driver probe, when of_dma_configure()
Link: https://lore.kernel.org/r/20241004090428.2035-1-quic_pbrahma@quicinc.com
[will: Add comment]
Signed-off-by: Will Deacon <will@kernel.org>
-Signed-off-by: Sasha Levin <sashal@kernel.org>
+[rm: backport for context conflict prior to 6.8]
+Signed-off-by: Robin Murphy <robin.murphy@arm.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
- drivers/iommu/arm/arm-smmu/arm-smmu.c | 11 +++++++++++
+ drivers/iommu/arm/arm-smmu/arm-smmu.c | 11 +++++++++++
1 file changed, 11 insertions(+)
-diff --git a/drivers/iommu/arm/arm-smmu/arm-smmu.c b/drivers/iommu/arm/arm-smmu/arm-smmu.c
-index 8203a06014d71..b40ffa1ec2db6 100644
--- a/drivers/iommu/arm/arm-smmu/arm-smmu.c
+++ b/drivers/iommu/arm/arm-smmu/arm-smmu.c
-@@ -1354,6 +1354,17 @@ static struct iommu_device *arm_smmu_probe_device(struct device *dev)
+@@ -1359,6 +1359,17 @@ static struct iommu_device *arm_smmu_pro
goto out_free;
- } else {
+ } else if (fwspec && fwspec->ops == &arm_smmu_ops) {
smmu = arm_smmu_get_by_fwnode(fwspec->iommu_fwnode);
+
+ /*
+ if (!smmu)
+ return ERR_PTR(dev_err_probe(dev, -EPROBE_DEFER,
+ "smmu dev has not bound yet\n"));
+ } else {
+ return ERR_PTR(-ENODEV);
}
-
- ret = -EINVAL;
---
-2.43.0
-
+++ /dev/null
-From 302639dd441533017096f8ebccb02440090fb09d Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Tue, 21 Nov 2023 18:04:03 +0000
-Subject: iommu: Clean up open-coded ownership checks
-
-From: Robin Murphy <robin.murphy@arm.com>
-
-[ Upstream commit e7080665c977ea1aafb8547a9c7bd08b199311d6 ]
-
-Some drivers already implement their own defence against the possibility
-of being given someone else's device. Since this is now taken care of by
-the core code (and via a slightly different path from the original
-fwspec-based idea), let's clean them up.
-
-Acked-by: Will Deacon <will@kernel.org>
-Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
-Reviewed-by: Jerry Snitselaar <jsnitsel@redhat.com>
-Signed-off-by: Robin Murphy <robin.murphy@arm.com>
-Link: https://lore.kernel.org/r/58a9879ce3f03562bb061e6714fe6efb554c3907.1700589539.git.robin.murphy@arm.com
-Signed-off-by: Joerg Roedel <jroedel@suse.de>
-Stable-dep-of: 229e6ee43d2a ("iommu/arm-smmu: Defer probe of clients after smmu device bound")
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 3 ---
- drivers/iommu/arm/arm-smmu/arm-smmu.c | 9 +--------
- drivers/iommu/arm/arm-smmu/qcom_iommu.c | 16 +++-------------
- drivers/iommu/mtk_iommu.c | 7 +------
- drivers/iommu/mtk_iommu_v1.c | 3 ---
- drivers/iommu/sprd-iommu.c | 8 +-------
- drivers/iommu/virtio-iommu.c | 3 ---
- 7 files changed, 6 insertions(+), 43 deletions(-)
-
-diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
-index 68b81f9c2f4b1..c24584754d252 100644
---- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
-+++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
-@@ -2658,9 +2658,6 @@ static struct iommu_device *arm_smmu_probe_device(struct device *dev)
- struct arm_smmu_master *master;
- struct iommu_fwspec *fwspec = dev_iommu_fwspec_get(dev);
-
-- if (!fwspec || fwspec->ops != &arm_smmu_ops)
-- return ERR_PTR(-ENODEV);
--
- if (WARN_ON_ONCE(dev_iommu_priv_get(dev)))
- return ERR_PTR(-EBUSY);
-
-diff --git a/drivers/iommu/arm/arm-smmu/arm-smmu.c b/drivers/iommu/arm/arm-smmu/arm-smmu.c
-index d6d1a2a55cc06..8203a06014d71 100644
---- a/drivers/iommu/arm/arm-smmu/arm-smmu.c
-+++ b/drivers/iommu/arm/arm-smmu/arm-smmu.c
-@@ -1116,11 +1116,6 @@ static int arm_smmu_attach_dev(struct iommu_domain *domain, struct device *dev)
- struct arm_smmu_device *smmu;
- int ret;
-
-- if (!fwspec || fwspec->ops != &arm_smmu_ops) {
-- dev_err(dev, "cannot attach to SMMU, is it on the same bus?\n");
-- return -ENXIO;
-- }
--
- /*
- * FIXME: The arch/arm DMA API code tries to attach devices to its own
- * domains between of_xlate() and probe_device() - we have no way to cope
-@@ -1357,10 +1352,8 @@ static struct iommu_device *arm_smmu_probe_device(struct device *dev)
- fwspec = dev_iommu_fwspec_get(dev);
- if (ret)
- goto out_free;
-- } else if (fwspec && fwspec->ops == &arm_smmu_ops) {
-- smmu = arm_smmu_get_by_fwnode(fwspec->iommu_fwnode);
- } else {
-- return ERR_PTR(-ENODEV);
-+ smmu = arm_smmu_get_by_fwnode(fwspec->iommu_fwnode);
- }
-
- ret = -EINVAL;
-diff --git a/drivers/iommu/arm/arm-smmu/qcom_iommu.c b/drivers/iommu/arm/arm-smmu/qcom_iommu.c
-index bc45d18f350cb..3b8c4b33842d1 100644
---- a/drivers/iommu/arm/arm-smmu/qcom_iommu.c
-+++ b/drivers/iommu/arm/arm-smmu/qcom_iommu.c
-@@ -79,16 +79,6 @@ static struct qcom_iommu_domain *to_qcom_iommu_domain(struct iommu_domain *dom)
-
- static const struct iommu_ops qcom_iommu_ops;
-
--static struct qcom_iommu_dev * to_iommu(struct device *dev)
--{
-- struct iommu_fwspec *fwspec = dev_iommu_fwspec_get(dev);
--
-- if (!fwspec || fwspec->ops != &qcom_iommu_ops)
-- return NULL;
--
-- return dev_iommu_priv_get(dev);
--}
--
- static struct qcom_iommu_ctx * to_ctx(struct qcom_iommu_domain *d, unsigned asid)
- {
- struct qcom_iommu_dev *qcom_iommu = d->iommu;
-@@ -374,7 +364,7 @@ static void qcom_iommu_domain_free(struct iommu_domain *domain)
-
- static int qcom_iommu_attach_dev(struct iommu_domain *domain, struct device *dev)
- {
-- struct qcom_iommu_dev *qcom_iommu = to_iommu(dev);
-+ struct qcom_iommu_dev *qcom_iommu = dev_iommu_priv_get(dev);
- struct qcom_iommu_domain *qcom_domain = to_qcom_iommu_domain(domain);
- int ret;
-
-@@ -406,7 +396,7 @@ static int qcom_iommu_identity_attach(struct iommu_domain *identity_domain,
- struct iommu_domain *domain = iommu_get_domain_for_dev(dev);
- struct qcom_iommu_domain *qcom_domain;
- struct iommu_fwspec *fwspec = dev_iommu_fwspec_get(dev);
-- struct qcom_iommu_dev *qcom_iommu = to_iommu(dev);
-+ struct qcom_iommu_dev *qcom_iommu = dev_iommu_priv_get(dev);
- unsigned int i;
-
- if (domain == identity_domain || !domain)
-@@ -537,7 +527,7 @@ static bool qcom_iommu_capable(struct device *dev, enum iommu_cap cap)
-
- static struct iommu_device *qcom_iommu_probe_device(struct device *dev)
- {
-- struct qcom_iommu_dev *qcom_iommu = to_iommu(dev);
-+ struct qcom_iommu_dev *qcom_iommu = dev_iommu_priv_get(dev);
- struct device_link *link;
-
- if (!qcom_iommu)
-diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c
-index de698463e94ad..23c7eec46fff6 100644
---- a/drivers/iommu/mtk_iommu.c
-+++ b/drivers/iommu/mtk_iommu.c
-@@ -843,16 +843,11 @@ static phys_addr_t mtk_iommu_iova_to_phys(struct iommu_domain *domain,
- static struct iommu_device *mtk_iommu_probe_device(struct device *dev)
- {
- struct iommu_fwspec *fwspec = dev_iommu_fwspec_get(dev);
-- struct mtk_iommu_data *data;
-+ struct mtk_iommu_data *data = dev_iommu_priv_get(dev);
- struct device_link *link;
- struct device *larbdev;
- unsigned int larbid, larbidx, i;
-
-- if (!fwspec || fwspec->ops != &mtk_iommu_ops)
-- return ERR_PTR(-ENODEV); /* Not a iommu client device */
--
-- data = dev_iommu_priv_get(dev);
--
- if (!MTK_IOMMU_IS_TYPE(data->plat_data, MTK_IOMMU_TYPE_MM))
- return &data->iommu;
-
-diff --git a/drivers/iommu/mtk_iommu_v1.c b/drivers/iommu/mtk_iommu_v1.c
-index f1754efcfe74e..027b2ff7f33ef 100644
---- a/drivers/iommu/mtk_iommu_v1.c
-+++ b/drivers/iommu/mtk_iommu_v1.c
-@@ -478,9 +478,6 @@ static struct iommu_device *mtk_iommu_v1_probe_device(struct device *dev)
- idx++;
- }
-
-- if (!fwspec || fwspec->ops != &mtk_iommu_v1_ops)
-- return ERR_PTR(-ENODEV); /* Not a iommu client device */
--
- data = dev_iommu_priv_get(dev);
-
- /* Link the consumer device with the smi-larb device(supplier) */
-diff --git a/drivers/iommu/sprd-iommu.c b/drivers/iommu/sprd-iommu.c
-index c8e79a2d8b4c6..b5570ef887023 100644
---- a/drivers/iommu/sprd-iommu.c
-+++ b/drivers/iommu/sprd-iommu.c
-@@ -388,13 +388,7 @@ static phys_addr_t sprd_iommu_iova_to_phys(struct iommu_domain *domain,
-
- static struct iommu_device *sprd_iommu_probe_device(struct device *dev)
- {
-- struct iommu_fwspec *fwspec = dev_iommu_fwspec_get(dev);
-- struct sprd_iommu_device *sdev;
--
-- if (!fwspec || fwspec->ops != &sprd_iommu_ops)
-- return ERR_PTR(-ENODEV);
--
-- sdev = dev_iommu_priv_get(dev);
-+ struct sprd_iommu_device *sdev = dev_iommu_priv_get(dev);
-
- return &sdev->iommu;
- }
-diff --git a/drivers/iommu/virtio-iommu.c b/drivers/iommu/virtio-iommu.c
-index 17dcd826f5c20..bb2e795a80d0f 100644
---- a/drivers/iommu/virtio-iommu.c
-+++ b/drivers/iommu/virtio-iommu.c
-@@ -969,9 +969,6 @@ static struct iommu_device *viommu_probe_device(struct device *dev)
- struct viommu_dev *viommu = NULL;
- struct iommu_fwspec *fwspec = dev_iommu_fwspec_get(dev);
-
-- if (!fwspec || fwspec->ops != &viommu_ops)
-- return ERR_PTR(-ENODEV);
--
- viommu = viommu_get_by_fwnode(fwspec->iommu_fwnode);
- if (!viommu)
- return ERR_PTR(-ENODEV);
---
-2.43.0
-
+++ /dev/null
-From f13d79171ee3a3c2f8da7c45dd3d8f6fb25bbf81 Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Wed, 13 Sep 2023 10:43:49 -0300
-Subject: iommu/qcom_iommu: Add an IOMMU_IDENTITIY_DOMAIN
-
-From: Jason Gunthorpe <jgg@nvidia.com>
-
-[ Upstream commit 786478a90294ea5b149ed1156a43e82d63ea61ff ]
-
-This brings back the ops->detach_dev() code that commit
-1b932ceddd19 ("iommu: Remove detach_dev callbacks") deleted and turns it
-into an IDENTITY domain.
-
-Reviewed-by: Lu Baolu <baolu.lu@linux.intel.com>
-Reviewed-by: Jerry Snitselaar <jsnitsel@redhat.com>
-Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
-Link: https://lore.kernel.org/r/16-v8-81230027b2fa+9d-iommu_all_defdom_jgg@nvidia.com
-Signed-off-by: Joerg Roedel <jroedel@suse.de>
-Stable-dep-of: 229e6ee43d2a ("iommu/arm-smmu: Defer probe of clients after smmu device bound")
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- drivers/iommu/arm/arm-smmu/qcom_iommu.c | 39 +++++++++++++++++++++++++
- 1 file changed, 39 insertions(+)
-
-diff --git a/drivers/iommu/arm/arm-smmu/qcom_iommu.c b/drivers/iommu/arm/arm-smmu/qcom_iommu.c
-index 775a3cbaff4ed..bc45d18f350cb 100644
---- a/drivers/iommu/arm/arm-smmu/qcom_iommu.c
-+++ b/drivers/iommu/arm/arm-smmu/qcom_iommu.c
-@@ -400,6 +400,44 @@ static int qcom_iommu_attach_dev(struct iommu_domain *domain, struct device *dev
- return 0;
- }
-
-+static int qcom_iommu_identity_attach(struct iommu_domain *identity_domain,
-+ struct device *dev)
-+{
-+ struct iommu_domain *domain = iommu_get_domain_for_dev(dev);
-+ struct qcom_iommu_domain *qcom_domain;
-+ struct iommu_fwspec *fwspec = dev_iommu_fwspec_get(dev);
-+ struct qcom_iommu_dev *qcom_iommu = to_iommu(dev);
-+ unsigned int i;
-+
-+ if (domain == identity_domain || !domain)
-+ return 0;
-+
-+ qcom_domain = to_qcom_iommu_domain(domain);
-+ if (WARN_ON(!qcom_domain->iommu))
-+ return -EINVAL;
-+
-+ pm_runtime_get_sync(qcom_iommu->dev);
-+ for (i = 0; i < fwspec->num_ids; i++) {
-+ struct qcom_iommu_ctx *ctx = to_ctx(qcom_domain, fwspec->ids[i]);
-+
-+ /* Disable the context bank: */
-+ iommu_writel(ctx, ARM_SMMU_CB_SCTLR, 0);
-+
-+ ctx->domain = NULL;
-+ }
-+ pm_runtime_put_sync(qcom_iommu->dev);
-+ return 0;
-+}
-+
-+static struct iommu_domain_ops qcom_iommu_identity_ops = {
-+ .attach_dev = qcom_iommu_identity_attach,
-+};
-+
-+static struct iommu_domain qcom_iommu_identity_domain = {
-+ .type = IOMMU_DOMAIN_IDENTITY,
-+ .ops = &qcom_iommu_identity_ops,
-+};
-+
- static int qcom_iommu_map(struct iommu_domain *domain, unsigned long iova,
- phys_addr_t paddr, size_t pgsize, size_t pgcount,
- int prot, gfp_t gfp, size_t *mapped)
-@@ -565,6 +603,7 @@ static int qcom_iommu_of_xlate(struct device *dev, struct of_phandle_args *args)
- }
-
- static const struct iommu_ops qcom_iommu_ops = {
-+ .identity_domain = &qcom_iommu_identity_domain,
- .capable = qcom_iommu_capable,
- .domain_alloc = qcom_iommu_domain_alloc,
- .probe_device = qcom_iommu_probe_device,
---
-2.43.0
-
zram-split-memory-tracking-and-ac-time-tracking.patch
zram-do-not-mark-idle-slots-that-cannot-be-idle.patch
zram-clear-idle-flag-in-mark_idle.patch
-iommu-add-iommu_ops-identity_domain.patch
-iommu-qcom_iommu-add-an-iommu_identitiy_domain.patch
-iommu-clean-up-open-coded-ownership-checks.patch
-iommu-arm-smmu-defer-probe-of-clients-after-smmu-dev.patch
+iommu-arm-smmu-defer-probe-of-clients-after-smmu-device-bound.patch
powerpc-vdso-refactor-cflags-for-cvdso-build.patch
powerpc-vdso-drop-mstack-protector-guard-flags-in-32.patch
ntp-remove-unused-tick_nsec.patch