* [PATCH v7 04/24] iommu: Add IOMMU_DOMAIN_PLATFORM for S390
From: Jason Gunthorpe @ 2023-08-23 16:47 UTC (permalink / raw)
To: Andy Gross, Alim Akhtar, Bjorn Andersson,
AngeloGioacchino Del Regno, Baolin Wang, Christophe Leroy,
Gerald Schaefer, Heiko Stuebner, iommu, Jernej Skrabec,
Jonathan Hunter, Joerg Roedel, Kevin Tian, Konrad Dybcio,
Krzysztof Kozlowski, linux-arm-kernel, linux-arm-msm,
linux-mediatek, linux-rockchip, linux-s390, linux-samsung-soc,
linux-sunxi, linux-tegra, Russell King, linuxppc-dev,
Matthias Brugger, Matthew Rosato, Michael Ellerman,
Nicholas Piggin, Orson Zhai, Rob Clark, Robin Murphy,
Samuel Holland, Thierry Reding, Krishna Reddy, Chen-Yu Tsai,
Will Deacon, Yong Wu, Chunyan Zhang
Cc: Lu Baolu, Dmitry Osipenko, Marek Szyprowski, Nicolin Chen,
Niklas Schnelle, Steven Price, Thierry Reding
In-Reply-To: <0-v7-de04a3217c48+15055-iommu_all_defdom_jgg@nvidia.com>
The PLATFORM domain will be set as the default domain and attached as
normal during probe. The driver will ignore the initial attach from a NULL
domain to the PLATFORM domain.
After this, the PLATFORM domain's attach_dev will be called whenever we
detach from an UNMANAGED domain (eg for VFIO). This is the same time the
original design would have called op->detach_dev().
This is temporary until the S390 dma-iommu.c conversion is merged.
Tested-by: Heiko Stuebner <heiko@sntech.de>
Tested-by: Niklas Schnelle <schnelle@linux.ibm.com>
Reviewed-by: Lu Baolu <baolu.lu@linux.intel.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
---
drivers/iommu/s390-iommu.c | 21 +++++++++++++++++++--
1 file changed, 19 insertions(+), 2 deletions(-)
diff --git a/drivers/iommu/s390-iommu.c b/drivers/iommu/s390-iommu.c
index fbf59a8db29b11..f0c867c57a5b9b 100644
--- a/drivers/iommu/s390-iommu.c
+++ b/drivers/iommu/s390-iommu.c
@@ -142,14 +142,31 @@ static int s390_iommu_attach_device(struct iommu_domain *domain,
return 0;
}
-static void s390_iommu_set_platform_dma(struct device *dev)
+/*
+ * Switch control over the IOMMU to S390's internal dma_api ops
+ */
+static int s390_iommu_platform_attach(struct iommu_domain *platform_domain,
+ struct device *dev)
{
struct zpci_dev *zdev = to_zpci_dev(dev);
+ if (!zdev->s390_domain)
+ return 0;
+
__s390_iommu_detach_device(zdev);
zpci_dma_init_device(zdev);
+ return 0;
}
+static struct iommu_domain_ops s390_iommu_platform_ops = {
+ .attach_dev = s390_iommu_platform_attach,
+};
+
+static struct iommu_domain s390_iommu_platform_domain = {
+ .type = IOMMU_DOMAIN_PLATFORM,
+ .ops = &s390_iommu_platform_ops,
+};
+
static void s390_iommu_get_resv_regions(struct device *dev,
struct list_head *list)
{
@@ -428,12 +445,12 @@ void zpci_destroy_iommu(struct zpci_dev *zdev)
}
static const struct iommu_ops s390_iommu_ops = {
+ .default_domain = &s390_iommu_platform_domain,
.capable = s390_iommu_capable,
.domain_alloc = s390_domain_alloc,
.probe_device = s390_iommu_probe_device,
.release_device = s390_iommu_release_device,
.device_group = generic_device_group,
- .set_platform_dma_ops = s390_iommu_set_platform_dma,
.pgsize_bitmap = SZ_4K,
.get_resv_regions = s390_iommu_get_resv_regions,
.default_domain_ops = &(const struct iommu_domain_ops) {
--
2.41.0
^ permalink raw reply related
* [PATCH v7 07/24] iommu/mtk_iommu_v1: Implement an IDENTITY domain
From: Jason Gunthorpe @ 2023-08-23 16:47 UTC (permalink / raw)
To: Andy Gross, Alim Akhtar, Bjorn Andersson,
AngeloGioacchino Del Regno, Baolin Wang, Christophe Leroy,
Gerald Schaefer, Heiko Stuebner, iommu, Jernej Skrabec,
Jonathan Hunter, Joerg Roedel, Kevin Tian, Konrad Dybcio,
Krzysztof Kozlowski, linux-arm-kernel, linux-arm-msm,
linux-mediatek, linux-rockchip, linux-s390, linux-samsung-soc,
linux-sunxi, linux-tegra, Russell King, linuxppc-dev,
Matthias Brugger, Matthew Rosato, Michael Ellerman,
Nicholas Piggin, Orson Zhai, Rob Clark, Robin Murphy,
Samuel Holland, Thierry Reding, Krishna Reddy, Chen-Yu Tsai,
Will Deacon, Yong Wu, Chunyan Zhang
Cc: Lu Baolu, Dmitry Osipenko, Marek Szyprowski, Nicolin Chen,
Niklas Schnelle, Steven Price, Thierry Reding
In-Reply-To: <0-v7-de04a3217c48+15055-iommu_all_defdom_jgg@nvidia.com>
What mtk does during mtk_iommu_v1_set_platform_dma() is actually putting
the iommu into identity mode. Make this available as a proper IDENTITY
domain.
The mtk_iommu_v1_def_domain_type() from
commit 8bbe13f52cb7 ("iommu/mediatek-v1: Add def_domain_type") explains
this was needed to allow probe_finalize() to be called, but now the
IDENTITY domain will do the same job so change the returned
def_domain_type.
mkt_v1 is the only driver that returns IOMMU_DOMAIN_UNMANAGED from
def_domain_type(). This allows the next patch to enforce an IDENTITY
domain policy for this driver.
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
---
drivers/iommu/mtk_iommu_v1.c | 21 +++++++++++++++++++--
1 file changed, 19 insertions(+), 2 deletions(-)
diff --git a/drivers/iommu/mtk_iommu_v1.c b/drivers/iommu/mtk_iommu_v1.c
index 8a0a5e5d049f4a..cc3e7d53d33ad9 100644
--- a/drivers/iommu/mtk_iommu_v1.c
+++ b/drivers/iommu/mtk_iommu_v1.c
@@ -319,11 +319,27 @@ static int mtk_iommu_v1_attach_device(struct iommu_domain *domain, struct device
return 0;
}
-static void mtk_iommu_v1_set_platform_dma(struct device *dev)
+static int mtk_iommu_v1_identity_attach(struct iommu_domain *identity_domain,
+ struct device *dev)
{
struct mtk_iommu_v1_data *data = dev_iommu_priv_get(dev);
mtk_iommu_v1_config(data, dev, false);
+ return 0;
+}
+
+static struct iommu_domain_ops mtk_iommu_v1_identity_ops = {
+ .attach_dev = mtk_iommu_v1_identity_attach,
+};
+
+static struct iommu_domain mtk_iommu_v1_identity_domain = {
+ .type = IOMMU_DOMAIN_IDENTITY,
+ .ops = &mtk_iommu_v1_identity_ops,
+};
+
+static void mtk_iommu_v1_set_platform_dma(struct device *dev)
+{
+ mtk_iommu_v1_identity_attach(&mtk_iommu_v1_identity_domain, dev);
}
static int mtk_iommu_v1_map(struct iommu_domain *domain, unsigned long iova,
@@ -443,7 +459,7 @@ static int mtk_iommu_v1_create_mapping(struct device *dev, struct of_phandle_arg
static int mtk_iommu_v1_def_domain_type(struct device *dev)
{
- return IOMMU_DOMAIN_UNMANAGED;
+ return IOMMU_DOMAIN_IDENTITY;
}
static struct iommu_device *mtk_iommu_v1_probe_device(struct device *dev)
@@ -578,6 +594,7 @@ static int mtk_iommu_v1_hw_init(const struct mtk_iommu_v1_data *data)
}
static const struct iommu_ops mtk_iommu_v1_ops = {
+ .identity_domain = &mtk_iommu_v1_identity_domain,
.domain_alloc = mtk_iommu_v1_domain_alloc,
.probe_device = mtk_iommu_v1_probe_device,
.probe_finalize = mtk_iommu_v1_probe_finalize,
--
2.41.0
^ permalink raw reply related
* [PATCH v7 10/24] iommu/exynos: Implement an IDENTITY domain
From: Jason Gunthorpe @ 2023-08-23 16:47 UTC (permalink / raw)
To: Andy Gross, Alim Akhtar, Bjorn Andersson,
AngeloGioacchino Del Regno, Baolin Wang, Christophe Leroy,
Gerald Schaefer, Heiko Stuebner, iommu, Jernej Skrabec,
Jonathan Hunter, Joerg Roedel, Kevin Tian, Konrad Dybcio,
Krzysztof Kozlowski, linux-arm-kernel, linux-arm-msm,
linux-mediatek, linux-rockchip, linux-s390, linux-samsung-soc,
linux-sunxi, linux-tegra, Russell King, linuxppc-dev,
Matthias Brugger, Matthew Rosato, Michael Ellerman,
Nicholas Piggin, Orson Zhai, Rob Clark, Robin Murphy,
Samuel Holland, Thierry Reding, Krishna Reddy, Chen-Yu Tsai,
Will Deacon, Yong Wu, Chunyan Zhang
Cc: Lu Baolu, Dmitry Osipenko, Marek Szyprowski, Nicolin Chen,
Niklas Schnelle, Steven Price, Thierry Reding
In-Reply-To: <0-v7-de04a3217c48+15055-iommu_all_defdom_jgg@nvidia.com>
What exynos calls exynos_iommu_detach_device is actually putting the iommu
into identity mode.
Move to the new core support for ARM_DMA_USE_IOMMU by defining
ops->identity_domain.
Tested-by: Marek Szyprowski <m.szyprowski@samsung.com>
Acked-by: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
---
drivers/iommu/exynos-iommu.c | 66 +++++++++++++++++-------------------
1 file changed, 32 insertions(+), 34 deletions(-)
diff --git a/drivers/iommu/exynos-iommu.c b/drivers/iommu/exynos-iommu.c
index c275fe71c4db32..5e12b85dfe8705 100644
--- a/drivers/iommu/exynos-iommu.c
+++ b/drivers/iommu/exynos-iommu.c
@@ -24,6 +24,7 @@
typedef u32 sysmmu_iova_t;
typedef u32 sysmmu_pte_t;
+static struct iommu_domain exynos_identity_domain;
/* We do not consider super section mapping (16MB) */
#define SECT_ORDER 20
@@ -829,7 +830,7 @@ static int __maybe_unused exynos_sysmmu_suspend(struct device *dev)
struct exynos_iommu_owner *owner = dev_iommu_priv_get(master);
mutex_lock(&owner->rpm_lock);
- if (data->domain) {
+ if (&data->domain->domain != &exynos_identity_domain) {
dev_dbg(data->sysmmu, "saving state\n");
__sysmmu_disable(data);
}
@@ -847,7 +848,7 @@ static int __maybe_unused exynos_sysmmu_resume(struct device *dev)
struct exynos_iommu_owner *owner = dev_iommu_priv_get(master);
mutex_lock(&owner->rpm_lock);
- if (data->domain) {
+ if (&data->domain->domain != &exynos_identity_domain) {
dev_dbg(data->sysmmu, "restoring state\n");
__sysmmu_enable(data);
}
@@ -980,17 +981,20 @@ static void exynos_iommu_domain_free(struct iommu_domain *iommu_domain)
kfree(domain);
}
-static void exynos_iommu_detach_device(struct iommu_domain *iommu_domain,
- struct device *dev)
+static int exynos_iommu_identity_attach(struct iommu_domain *identity_domain,
+ struct device *dev)
{
- struct exynos_iommu_domain *domain = to_exynos_domain(iommu_domain);
struct exynos_iommu_owner *owner = dev_iommu_priv_get(dev);
- phys_addr_t pagetable = virt_to_phys(domain->pgtable);
+ struct exynos_iommu_domain *domain;
+ phys_addr_t pagetable;
struct sysmmu_drvdata *data, *next;
unsigned long flags;
- if (!has_sysmmu(dev) || owner->domain != iommu_domain)
- return;
+ if (owner->domain == identity_domain)
+ return 0;
+
+ domain = to_exynos_domain(owner->domain);
+ pagetable = virt_to_phys(domain->pgtable);
mutex_lock(&owner->rpm_lock);
@@ -1009,15 +1013,25 @@ static void exynos_iommu_detach_device(struct iommu_domain *iommu_domain,
list_del_init(&data->domain_node);
spin_unlock(&data->lock);
}
- owner->domain = NULL;
+ owner->domain = identity_domain;
spin_unlock_irqrestore(&domain->lock, flags);
mutex_unlock(&owner->rpm_lock);
- dev_dbg(dev, "%s: Detached IOMMU with pgtable %pa\n", __func__,
- &pagetable);
+ dev_dbg(dev, "%s: Restored IOMMU to IDENTITY from pgtable %pa\n",
+ __func__, &pagetable);
+ return 0;
}
+static struct iommu_domain_ops exynos_identity_ops = {
+ .attach_dev = exynos_iommu_identity_attach,
+};
+
+static struct iommu_domain exynos_identity_domain = {
+ .type = IOMMU_DOMAIN_IDENTITY,
+ .ops = &exynos_identity_ops,
+};
+
static int exynos_iommu_attach_device(struct iommu_domain *iommu_domain,
struct device *dev)
{
@@ -1026,12 +1040,11 @@ static int exynos_iommu_attach_device(struct iommu_domain *iommu_domain,
struct sysmmu_drvdata *data;
phys_addr_t pagetable = virt_to_phys(domain->pgtable);
unsigned long flags;
+ int err;
- if (!has_sysmmu(dev))
- return -ENODEV;
-
- if (owner->domain)
- exynos_iommu_detach_device(owner->domain, dev);
+ err = exynos_iommu_identity_attach(&exynos_identity_domain, dev);
+ if (err)
+ return err;
mutex_lock(&owner->rpm_lock);
@@ -1407,26 +1420,12 @@ static struct iommu_device *exynos_iommu_probe_device(struct device *dev)
return &data->iommu;
}
-static void exynos_iommu_set_platform_dma(struct device *dev)
-{
- struct exynos_iommu_owner *owner = dev_iommu_priv_get(dev);
-
- if (owner->domain) {
- struct iommu_group *group = iommu_group_get(dev);
-
- if (group) {
- exynos_iommu_detach_device(owner->domain, dev);
- iommu_group_put(group);
- }
- }
-}
-
static void exynos_iommu_release_device(struct device *dev)
{
struct exynos_iommu_owner *owner = dev_iommu_priv_get(dev);
struct sysmmu_drvdata *data;
- exynos_iommu_set_platform_dma(dev);
+ WARN_ON(exynos_iommu_identity_attach(&exynos_identity_domain, dev));
list_for_each_entry(data, &owner->controllers, owner_node)
device_link_del(data->link);
@@ -1457,6 +1456,7 @@ static int exynos_iommu_of_xlate(struct device *dev,
INIT_LIST_HEAD(&owner->controllers);
mutex_init(&owner->rpm_lock);
+ owner->domain = &exynos_identity_domain;
dev_iommu_priv_set(dev, owner);
}
@@ -1471,11 +1471,9 @@ static int exynos_iommu_of_xlate(struct device *dev,
}
static const struct iommu_ops exynos_iommu_ops = {
+ .identity_domain = &exynos_identity_domain,
.domain_alloc = exynos_iommu_domain_alloc,
.device_group = generic_device_group,
-#ifdef CONFIG_ARM
- .set_platform_dma_ops = exynos_iommu_set_platform_dma,
-#endif
.probe_device = exynos_iommu_probe_device,
.release_device = exynos_iommu_release_device,
.pgsize_bitmap = SECT_SIZE | LPAGE_SIZE | SPAGE_SIZE,
--
2.41.0
^ permalink raw reply related
* [PATCH v7 21/24] iommu: Add __iommu_group_domain_alloc()
From: Jason Gunthorpe @ 2023-08-23 16:47 UTC (permalink / raw)
To: Andy Gross, Alim Akhtar, Bjorn Andersson,
AngeloGioacchino Del Regno, Baolin Wang, Christophe Leroy,
Gerald Schaefer, Heiko Stuebner, iommu, Jernej Skrabec,
Jonathan Hunter, Joerg Roedel, Kevin Tian, Konrad Dybcio,
Krzysztof Kozlowski, linux-arm-kernel, linux-arm-msm,
linux-mediatek, linux-rockchip, linux-s390, linux-samsung-soc,
linux-sunxi, linux-tegra, Russell King, linuxppc-dev,
Matthias Brugger, Matthew Rosato, Michael Ellerman,
Nicholas Piggin, Orson Zhai, Rob Clark, Robin Murphy,
Samuel Holland, Thierry Reding, Krishna Reddy, Chen-Yu Tsai,
Will Deacon, Yong Wu, Chunyan Zhang
Cc: Lu Baolu, Dmitry Osipenko, Marek Szyprowski, Nicolin Chen,
Niklas Schnelle, Steven Price, Thierry Reding
In-Reply-To: <0-v7-de04a3217c48+15055-iommu_all_defdom_jgg@nvidia.com>
Allocate a domain from a group. Automatically obtains the iommu_ops to use
from the device list of the group. Convert the internal callers to use it.
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>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
---
drivers/iommu/iommu.c | 59 +++++++++++++++++++++----------------------
1 file changed, 29 insertions(+), 30 deletions(-)
diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
index 3003c249ab9b8e..568dec45a06954 100644
--- a/drivers/iommu/iommu.c
+++ b/drivers/iommu/iommu.c
@@ -96,8 +96,8 @@ static const char * const iommu_group_resv_type_string[] = {
static int iommu_bus_notifier(struct notifier_block *nb,
unsigned long action, void *data);
static void iommu_release_device(struct device *dev);
-static struct iommu_domain *__iommu_domain_alloc(const struct bus_type *bus,
- unsigned type);
+static struct iommu_domain *
+__iommu_group_domain_alloc(struct iommu_group *group, unsigned int type);
static int __iommu_attach_device(struct iommu_domain *domain,
struct device *dev);
static int __iommu_attach_group(struct iommu_domain *domain,
@@ -1719,12 +1719,11 @@ struct iommu_group *fsl_mc_device_group(struct device *dev)
EXPORT_SYMBOL_GPL(fsl_mc_device_group);
static struct iommu_domain *
-__iommu_group_alloc_default_domain(const struct bus_type *bus,
- struct iommu_group *group, int req_type)
+__iommu_group_alloc_default_domain(struct iommu_group *group, int req_type)
{
if (group->default_domain && group->default_domain->type == req_type)
return group->default_domain;
- return __iommu_domain_alloc(bus, req_type);
+ return __iommu_group_domain_alloc(group, req_type);
}
/*
@@ -1751,9 +1750,7 @@ static const struct iommu_ops *group_iommu_ops(struct iommu_group *group)
static struct iommu_domain *
iommu_group_alloc_default_domain(struct iommu_group *group, int req_type)
{
- const struct bus_type *bus =
- list_first_entry(&group->devices, struct group_device, list)
- ->dev->bus;
+ const struct iommu_ops *ops = group_iommu_ops(group);
struct iommu_domain *dom;
lockdep_assert_held(&group->mutex);
@@ -1763,24 +1760,24 @@ iommu_group_alloc_default_domain(struct iommu_group *group, int req_type)
* domain. This should always be either an IDENTITY or PLATFORM domain.
* Do not use in new drivers.
*/
- if (bus->iommu_ops->default_domain) {
+ if (ops->default_domain) {
if (req_type)
return ERR_PTR(-EINVAL);
- return bus->iommu_ops->default_domain;
+ return ops->default_domain;
}
if (req_type)
- return __iommu_group_alloc_default_domain(bus, group, req_type);
+ return __iommu_group_alloc_default_domain(group, req_type);
/* The driver gave no guidance on what type to use, try the default */
- dom = __iommu_group_alloc_default_domain(bus, group, iommu_def_domain_type);
+ dom = __iommu_group_alloc_default_domain(group, iommu_def_domain_type);
if (dom)
return dom;
/* Otherwise IDENTITY and DMA_FQ defaults will try DMA */
if (iommu_def_domain_type == IOMMU_DOMAIN_DMA)
return NULL;
- dom = __iommu_group_alloc_default_domain(bus, group, IOMMU_DOMAIN_DMA);
+ dom = __iommu_group_alloc_default_domain(group, IOMMU_DOMAIN_DMA);
if (!dom)
return NULL;
@@ -2043,19 +2040,16 @@ void iommu_set_fault_handler(struct iommu_domain *domain,
}
EXPORT_SYMBOL_GPL(iommu_set_fault_handler);
-static struct iommu_domain *__iommu_domain_alloc(const struct bus_type *bus,
- unsigned type)
+static struct iommu_domain *__iommu_domain_alloc(const struct iommu_ops *ops,
+ unsigned int type)
{
struct iommu_domain *domain;
unsigned int alloc_type = type & IOMMU_DOMAIN_ALLOC_FLAGS;
- if (bus == NULL || bus->iommu_ops == NULL)
- return NULL;
+ if (alloc_type == IOMMU_DOMAIN_IDENTITY && ops->identity_domain)
+ return ops->identity_domain;
- 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);
+ domain = ops->domain_alloc(alloc_type);
if (!domain)
return NULL;
@@ -2065,10 +2059,10 @@ static struct iommu_domain *__iommu_domain_alloc(const struct bus_type *bus,
* may override this later
*/
if (!domain->pgsize_bitmap)
- domain->pgsize_bitmap = bus->iommu_ops->pgsize_bitmap;
+ domain->pgsize_bitmap = ops->pgsize_bitmap;
if (!domain->ops)
- domain->ops = bus->iommu_ops->default_domain_ops;
+ domain->ops = ops->default_domain_ops;
if (iommu_is_dma_domain(domain) && iommu_get_dma_cookie(domain)) {
iommu_domain_free(domain);
@@ -2077,9 +2071,17 @@ static struct iommu_domain *__iommu_domain_alloc(const struct bus_type *bus,
return domain;
}
+static struct iommu_domain *
+__iommu_group_domain_alloc(struct iommu_group *group, unsigned int type)
+{
+ return __iommu_domain_alloc(group_iommu_ops(group), type);
+}
+
struct iommu_domain *iommu_domain_alloc(const struct bus_type *bus)
{
- return __iommu_domain_alloc(bus, IOMMU_DOMAIN_UNMANAGED);
+ if (bus == NULL || bus->iommu_ops == NULL)
+ return NULL;
+ return __iommu_domain_alloc(bus->iommu_ops, IOMMU_DOMAIN_UNMANAGED);
}
EXPORT_SYMBOL_GPL(iommu_domain_alloc);
@@ -3239,21 +3241,18 @@ void iommu_device_unuse_default_domain(struct device *dev)
static int __iommu_group_alloc_blocking_domain(struct iommu_group *group)
{
- struct group_device *dev =
- list_first_entry(&group->devices, struct group_device, list);
-
if (group->blocking_domain)
return 0;
group->blocking_domain =
- __iommu_domain_alloc(dev->dev->bus, IOMMU_DOMAIN_BLOCKED);
+ __iommu_group_domain_alloc(group, IOMMU_DOMAIN_BLOCKED);
if (!group->blocking_domain) {
/*
* For drivers that do not yet understand IOMMU_DOMAIN_BLOCKED
* create an empty domain instead.
*/
- group->blocking_domain = __iommu_domain_alloc(
- dev->dev->bus, IOMMU_DOMAIN_UNMANAGED);
+ group->blocking_domain = __iommu_group_domain_alloc(
+ group, IOMMU_DOMAIN_UNMANAGED);
if (!group->blocking_domain)
return -EINVAL;
}
--
2.41.0
^ permalink raw reply related
* [PATCH v7 08/24] iommu: Reorganize iommu_get_default_domain_type() to respect def_domain_type()
From: Jason Gunthorpe @ 2023-08-23 16:47 UTC (permalink / raw)
To: Andy Gross, Alim Akhtar, Bjorn Andersson,
AngeloGioacchino Del Regno, Baolin Wang, Christophe Leroy,
Gerald Schaefer, Heiko Stuebner, iommu, Jernej Skrabec,
Jonathan Hunter, Joerg Roedel, Kevin Tian, Konrad Dybcio,
Krzysztof Kozlowski, linux-arm-kernel, linux-arm-msm,
linux-mediatek, linux-rockchip, linux-s390, linux-samsung-soc,
linux-sunxi, linux-tegra, Russell King, linuxppc-dev,
Matthias Brugger, Matthew Rosato, Michael Ellerman,
Nicholas Piggin, Orson Zhai, Rob Clark, Robin Murphy,
Samuel Holland, Thierry Reding, Krishna Reddy, Chen-Yu Tsai,
Will Deacon, Yong Wu, Chunyan Zhang
Cc: Lu Baolu, Dmitry Osipenko, Marek Szyprowski, Nicolin Chen,
Niklas Schnelle, Steven Price, Thierry Reding
In-Reply-To: <0-v7-de04a3217c48+15055-iommu_all_defdom_jgg@nvidia.com>
Except for dart (which forces IOMMU_DOMAIN_DMA) every driver returns 0 or
IDENTITY from ops->def_domain_type().
The drivers that return IDENTITY have some kind of good reason, typically
that quirky hardware really can't support anything other than IDENTITY.
Arrange things so that if the driver says it needs IDENTITY then
iommu_get_default_domain_type() either fails or returns IDENTITY. It will
not ignore the driver's override to IDENTITY.
Split the function into two steps, reducing the group device list to the
driver's def_domain_type() and the untrusted flag.
Then compute the result based on those two reduced variables. Fully reject
combining untrusted with IDENTITY.
Remove the debugging print on the iommu_group_store_type() failure path,
userspace should not be able to trigger kernel prints.
This makes the next patch cleaner that wants to force IDENTITY always for
ARM_IOMMU because there is no support for DMA.
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
---
drivers/iommu/iommu.c | 117 ++++++++++++++++++++++++++++--------------
1 file changed, 79 insertions(+), 38 deletions(-)
diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
index 7cedb0640290c8..bdeeb574d9495c 100644
--- a/drivers/iommu/iommu.c
+++ b/drivers/iommu/iommu.c
@@ -1718,19 +1718,6 @@ struct iommu_group *fsl_mc_device_group(struct device *dev)
}
EXPORT_SYMBOL_GPL(fsl_mc_device_group);
-static int iommu_get_def_domain_type(struct device *dev)
-{
- const struct iommu_ops *ops = dev_iommu_ops(dev);
-
- if (dev_is_pci(dev) && to_pci_dev(dev)->untrusted)
- return IOMMU_DOMAIN_DMA;
-
- if (ops->def_domain_type)
- return ops->def_domain_type(dev);
-
- return 0;
-}
-
static struct iommu_domain *
__iommu_group_alloc_default_domain(const struct bus_type *bus,
struct iommu_group *group, int req_type)
@@ -1740,6 +1727,23 @@ __iommu_group_alloc_default_domain(const struct bus_type *bus,
return __iommu_domain_alloc(bus, req_type);
}
+/*
+ * Returns the iommu_ops for the devices in an iommu group.
+ *
+ * It is assumed that all devices in an iommu group are managed by a single
+ * IOMMU unit. Therefore, this returns the dev_iommu_ops of the first device
+ * in the group.
+ */
+static const struct iommu_ops *group_iommu_ops(struct iommu_group *group)
+{
+ struct group_device *device =
+ list_first_entry(&group->devices, struct group_device, list);
+
+ lockdep_assert_held(&group->mutex);
+
+ return dev_iommu_ops(device->dev);
+}
+
/*
* req_type of 0 means "auto" which means to select a domain based on
* iommu_def_domain_type or what the driver actually supports.
@@ -1820,40 +1824,77 @@ static int iommu_bus_notifier(struct notifier_block *nb,
return 0;
}
-/* A target_type of 0 will select the best domain type and cannot fail */
+/*
+ * Combine the driver's chosen def_domain_type across all the devices in a
+ * group. Drivers must give a consistent result.
+ */
+static int iommu_get_def_domain_type(struct iommu_group *group,
+ struct device *dev, int cur_type)
+{
+ const struct iommu_ops *ops = group_iommu_ops(group);
+ int type;
+
+ if (!ops->def_domain_type)
+ return cur_type;
+
+ type = ops->def_domain_type(dev);
+ if (!type || cur_type == type)
+ return cur_type;
+ if (!cur_type)
+ return type;
+
+ dev_err_ratelimited(
+ dev,
+ "IOMMU driver error, requesting conflicting def_domain_type, %s and %s, for devices in group %u.\n",
+ iommu_domain_type_str(cur_type), iommu_domain_type_str(type),
+ group->id);
+
+ /*
+ * Try to recover, drivers are allowed to force IDENITY or DMA, IDENTITY
+ * takes precedence.
+ */
+ if (type == IOMMU_DOMAIN_IDENTITY)
+ return type;
+ return cur_type;
+}
+
+/*
+ * A target_type of 0 will select the best domain type. 0 can be returned in
+ * this case meaning the global default should be used.
+ */
static int iommu_get_default_domain_type(struct iommu_group *group,
int target_type)
{
- int best_type = target_type;
+ struct device *untrusted = NULL;
struct group_device *gdev;
- struct device *last_dev;
+ int driver_type = 0;
lockdep_assert_held(&group->mutex);
-
for_each_group_device(group, gdev) {
- unsigned int type = iommu_get_def_domain_type(gdev->dev);
+ driver_type = iommu_get_def_domain_type(group, gdev->dev,
+ driver_type);
- if (best_type && type && best_type != type) {
- if (target_type) {
- dev_err_ratelimited(
- gdev->dev,
- "Device cannot be in %s domain\n",
- iommu_domain_type_str(target_type));
- return -1;
- }
-
- dev_warn(
- gdev->dev,
- "Device needs domain type %s, but device %s in the same iommu group requires type %s - using default\n",
- iommu_domain_type_str(type), dev_name(last_dev),
- iommu_domain_type_str(best_type));
- return 0;
- }
- if (!best_type)
- best_type = type;
- last_dev = gdev->dev;
+ if (dev_is_pci(gdev->dev) && to_pci_dev(gdev->dev)->untrusted)
+ untrusted = gdev->dev;
}
- return best_type;
+
+ if (untrusted) {
+ if (driver_type && driver_type != IOMMU_DOMAIN_DMA) {
+ dev_err_ratelimited(
+ untrusted,
+ "Device is not trusted, but driver is overriding group %u to %s, refusing to probe.\n",
+ group->id, iommu_domain_type_str(driver_type));
+ return -1;
+ }
+ driver_type = IOMMU_DOMAIN_DMA;
+ }
+
+ if (target_type) {
+ if (driver_type && target_type != driver_type)
+ return -1;
+ return target_type;
+ }
+ return driver_type;
}
static void iommu_group_do_probe_finalize(struct device *dev)
--
2.41.0
^ permalink raw reply related
* [PATCH v7 20/24] iommu: Require a default_domain for all iommu drivers
From: Jason Gunthorpe @ 2023-08-23 16:47 UTC (permalink / raw)
To: Andy Gross, Alim Akhtar, Bjorn Andersson,
AngeloGioacchino Del Regno, Baolin Wang, Christophe Leroy,
Gerald Schaefer, Heiko Stuebner, iommu, Jernej Skrabec,
Jonathan Hunter, Joerg Roedel, Kevin Tian, Konrad Dybcio,
Krzysztof Kozlowski, linux-arm-kernel, linux-arm-msm,
linux-mediatek, linux-rockchip, linux-s390, linux-samsung-soc,
linux-sunxi, linux-tegra, Russell King, linuxppc-dev,
Matthias Brugger, Matthew Rosato, Michael Ellerman,
Nicholas Piggin, Orson Zhai, Rob Clark, Robin Murphy,
Samuel Holland, Thierry Reding, Krishna Reddy, Chen-Yu Tsai,
Will Deacon, Yong Wu, Chunyan Zhang
Cc: Lu Baolu, Dmitry Osipenko, Marek Szyprowski, Nicolin Chen,
Niklas Schnelle, Steven Price, Thierry Reding
In-Reply-To: <0-v7-de04a3217c48+15055-iommu_all_defdom_jgg@nvidia.com>
At this point every iommu driver will cause a default_domain to be
selected, so we can finally remove this gap from the core code.
The following table explains what each driver supports and what the
resulting default_domain will be:
ops->defaut_domain
IDENTITY DMA PLATFORM v ARM32 dma-iommu ARCH
amd/iommu.c Y Y N/A either
apple-dart.c Y Y N/A either
arm-smmu.c Y Y IDENTITY either
qcom_iommu.c G Y IDENTITY either
arm-smmu-v3.c Y Y N/A either
exynos-iommu.c G Y IDENTITY either
fsl_pamu_domain.c Y Y N/A N/A PLATFORM
intel/iommu.c Y Y N/A either
ipmmu-vmsa.c G Y IDENTITY either
msm_iommu.c G IDENTITY N/A
mtk_iommu.c G Y IDENTITY either
mtk_iommu_v1.c G IDENTITY N/A
omap-iommu.c G IDENTITY N/A
rockchip-iommu.c G Y IDENTITY either
s390-iommu.c Y Y N/A N/A PLATFORM
sprd-iommu.c Y N/A DMA
sun50i-iommu.c G Y IDENTITY either
tegra-smmu.c G Y IDENTITY IDENTITY
virtio-iommu.c Y Y N/A either
spapr Y Y N/A N/A PLATFORM
* G means ops->identity_domain is used
* N/A means the driver will not compile in this configuration
ARM32 drivers select an IDENTITY default domain through either the
ops->identity_domain or directly requesting an IDENTIY domain through
alloc_domain().
In ARM64 mode tegra-smmu will still block the use of dma-iommu.c and
forces an IDENTITY domain.
S390 uses a PLATFORM domain to represent when the dma_ops are set to the
s390 iommu code.
fsl_pamu uses an PLATFORM domain.
POWER SPAPR uses PLATFORM and blocking to enable its weird VFIO mode.
The x86 drivers continue unchanged.
After this patch group->default_domain is only NULL for a short period
during bus iommu probing while all the groups are constituted. Otherwise
it is always !NULL.
This completes changing the iommu subsystem driver contract to a system
where the current iommu_domain always represents some form of translation
and the driver is continuously asserting a definable translation mode.
It resolves the confusion that the original ops->detach_dev() caused
around what translation, exactly, is the IOMMU performing after
detach. There were at least three different answers to that question in
the tree, they are all now clearly named with domain types.
Tested-by: Heiko Stuebner <heiko@sntech.de>
Tested-by: Niklas Schnelle <schnelle@linux.ibm.com>
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>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
---
drivers/iommu/iommu.c | 22 +++++++---------------
1 file changed, 7 insertions(+), 15 deletions(-)
diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
index a3b016543fad00..3003c249ab9b8e 100644
--- a/drivers/iommu/iommu.c
+++ b/drivers/iommu/iommu.c
@@ -1865,7 +1865,6 @@ static int iommu_get_def_domain_type(struct iommu_group *group,
static int iommu_get_default_domain_type(struct iommu_group *group,
int target_type)
{
- const struct iommu_ops *ops = group_iommu_ops(group);
struct device *untrusted = NULL;
struct group_device *gdev;
int driver_type = 0;
@@ -1876,11 +1875,13 @@ static int iommu_get_default_domain_type(struct iommu_group *group,
* ARM32 drivers supporting CONFIG_ARM_DMA_USE_IOMMU can declare an
* identity_domain and it will automatically become their default
* domain. Later on ARM_DMA_USE_IOMMU will install its UNMANAGED domain.
- * Override the selection to IDENTITY if we are sure the driver supports
- * it.
+ * Override the selection to IDENTITY.
*/
- if (IS_ENABLED(CONFIG_ARM_DMA_USE_IOMMU) && ops->identity_domain)
+ if (IS_ENABLED(CONFIG_ARM_DMA_USE_IOMMU)) {
+ static_assert(!(IS_ENABLED(CONFIG_ARM_DMA_USE_IOMMU) &&
+ IS_ENABLED(CONFIG_IOMMU_DMA)));
driver_type = IOMMU_DOMAIN_IDENTITY;
+ }
for_each_group_device(group, gdev) {
driver_type = iommu_get_def_domain_type(group, gdev->dev,
@@ -3016,18 +3017,9 @@ static int iommu_setup_default_domain(struct iommu_group *group,
if (req_type < 0)
return -EINVAL;
- /*
- * There are still some drivers which don't support default domains, so
- * we ignore the failure and leave group->default_domain NULL.
- */
dom = iommu_group_alloc_default_domain(group, req_type);
- if (!dom) {
- /* Once in default_domain mode we never leave */
- if (group->default_domain)
- return -ENODEV;
- group->default_domain = NULL;
- return 0;
- }
+ if (!dom)
+ return -ENODEV;
if (group->default_domain == dom)
return 0;
--
2.41.0
^ permalink raw reply related
* [PATCH v7 09/24] iommu: Allow an IDENTITY domain as the default_domain in ARM32
From: Jason Gunthorpe @ 2023-08-23 16:47 UTC (permalink / raw)
To: Andy Gross, Alim Akhtar, Bjorn Andersson,
AngeloGioacchino Del Regno, Baolin Wang, Christophe Leroy,
Gerald Schaefer, Heiko Stuebner, iommu, Jernej Skrabec,
Jonathan Hunter, Joerg Roedel, Kevin Tian, Konrad Dybcio,
Krzysztof Kozlowski, linux-arm-kernel, linux-arm-msm,
linux-mediatek, linux-rockchip, linux-s390, linux-samsung-soc,
linux-sunxi, linux-tegra, Russell King, linuxppc-dev,
Matthias Brugger, Matthew Rosato, Michael Ellerman,
Nicholas Piggin, Orson Zhai, Rob Clark, Robin Murphy,
Samuel Holland, Thierry Reding, Krishna Reddy, Chen-Yu Tsai,
Will Deacon, Yong Wu, Chunyan Zhang
Cc: Lu Baolu, Dmitry Osipenko, Marek Szyprowski, Nicolin Chen,
Niklas Schnelle, Steven Price, Thierry Reding
In-Reply-To: <0-v7-de04a3217c48+15055-iommu_all_defdom_jgg@nvidia.com>
Even though dma-iommu.c and CONFIG_ARM_DMA_USE_IOMMU do approximately the
same stuff, the way they relate to the IOMMU core is quiet different.
dma-iommu.c expects the core code to setup an UNMANAGED domain (of type
IOMMU_DOMAIN_DMA) and then configures itself to use that domain. This
becomes the default_domain for the group.
ARM_DMA_USE_IOMMU does not use the default_domain, instead it directly
allocates an UNMANAGED domain and operates it just like an external
driver. In this case group->default_domain is NULL.
If the driver provides a global static identity_domain then automatically
use it as the default_domain when in ARM_DMA_USE_IOMMU mode.
This allows drivers that implemented default_domain == NULL as an IDENTITY
translation to trivially get a properly labeled non-NULL default_domain on
ARM32 configs.
With this arrangment when ARM_DMA_USE_IOMMU wants to disconnect from the
device the normal detach_domain flow will restore the IDENTITY domain as
the default domain. Overall this makes attach_dev() of the IDENTITY domain
called in the same places as detach_dev().
This effectively migrates these drivers to default_domain mode. For
drivers that support ARM64 they will gain support for the IDENTITY
translation mode for the dma_api and behave in a uniform way.
Drivers use this by setting ops->identity_domain to a static singleton
iommu_domain that implements the identity attach. If the core detects
ARM_DMA_USE_IOMMU mode then it automatically attaches the IDENTITY domain
during probe.
Drivers can continue to prevent the use of DMA translation by returning
IOMMU_DOMAIN_IDENTITY from def_domain_type, this will completely prevent
IOMMU_DMA from running but will not impact ARM_DMA_USE_IOMMU.
This allows removing the set_platform_dma_ops() from every remaining
driver.
Remove the set_platform_dma_ops from rockchip and mkt_v1 as all it does
is set an existing global static identity domain. mkt_v1 does not support
IOMMU_DOMAIN_DMA and it does not compile on ARM64 so this transformation
is safe.
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>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
---
drivers/iommu/iommu.c | 21 ++++++++++++++++++++-
drivers/iommu/mtk_iommu_v1.c | 12 ------------
drivers/iommu/rockchip-iommu.c | 10 ----------
3 files changed, 20 insertions(+), 23 deletions(-)
diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
index bdeeb574d9495c..5fb25bcbc42f76 100644
--- a/drivers/iommu/iommu.c
+++ b/drivers/iommu/iommu.c
@@ -1865,17 +1865,36 @@ static int iommu_get_def_domain_type(struct iommu_group *group,
static int iommu_get_default_domain_type(struct iommu_group *group,
int target_type)
{
+ const struct iommu_ops *ops = group_iommu_ops(group);
struct device *untrusted = NULL;
struct group_device *gdev;
int driver_type = 0;
lockdep_assert_held(&group->mutex);
+
+ /*
+ * ARM32 drivers supporting CONFIG_ARM_DMA_USE_IOMMU can declare an
+ * identity_domain and it will automatically become their default
+ * domain. Later on ARM_DMA_USE_IOMMU will install its UNMANAGED domain.
+ * Override the selection to IDENTITY if we are sure the driver supports
+ * it.
+ */
+ if (IS_ENABLED(CONFIG_ARM_DMA_USE_IOMMU) && ops->identity_domain)
+ driver_type = IOMMU_DOMAIN_IDENTITY;
+
for_each_group_device(group, gdev) {
driver_type = iommu_get_def_domain_type(group, gdev->dev,
driver_type);
- if (dev_is_pci(gdev->dev) && to_pci_dev(gdev->dev)->untrusted)
+ if (dev_is_pci(gdev->dev) && to_pci_dev(gdev->dev)->untrusted) {
+ /*
+ * No ARM32 using systems will set untrusted, it cannot
+ * work.
+ */
+ if (WARN_ON(IS_ENABLED(CONFIG_ARM_DMA_USE_IOMMU)))
+ return -1;
untrusted = gdev->dev;
+ }
}
if (untrusted) {
diff --git a/drivers/iommu/mtk_iommu_v1.c b/drivers/iommu/mtk_iommu_v1.c
index cc3e7d53d33ad9..7c0c1d50df5f75 100644
--- a/drivers/iommu/mtk_iommu_v1.c
+++ b/drivers/iommu/mtk_iommu_v1.c
@@ -337,11 +337,6 @@ static struct iommu_domain mtk_iommu_v1_identity_domain = {
.ops = &mtk_iommu_v1_identity_ops,
};
-static void mtk_iommu_v1_set_platform_dma(struct device *dev)
-{
- mtk_iommu_v1_identity_attach(&mtk_iommu_v1_identity_domain, dev);
-}
-
static int mtk_iommu_v1_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)
@@ -457,11 +452,6 @@ static int mtk_iommu_v1_create_mapping(struct device *dev, struct of_phandle_arg
return 0;
}
-static int mtk_iommu_v1_def_domain_type(struct device *dev)
-{
- return IOMMU_DOMAIN_IDENTITY;
-}
-
static struct iommu_device *mtk_iommu_v1_probe_device(struct device *dev)
{
struct iommu_fwspec *fwspec = dev_iommu_fwspec_get(dev);
@@ -599,10 +589,8 @@ static const struct iommu_ops mtk_iommu_v1_ops = {
.probe_device = mtk_iommu_v1_probe_device,
.probe_finalize = mtk_iommu_v1_probe_finalize,
.release_device = mtk_iommu_v1_release_device,
- .def_domain_type = mtk_iommu_v1_def_domain_type,
.device_group = generic_device_group,
.pgsize_bitmap = MT2701_IOMMU_PAGE_SIZE,
- .set_platform_dma_ops = mtk_iommu_v1_set_platform_dma,
.owner = THIS_MODULE,
.default_domain_ops = &(const struct iommu_domain_ops) {
.attach_dev = mtk_iommu_v1_attach_device,
diff --git a/drivers/iommu/rockchip-iommu.c b/drivers/iommu/rockchip-iommu.c
index 033678f2f8b3ab..a582525d36f8cc 100644
--- a/drivers/iommu/rockchip-iommu.c
+++ b/drivers/iommu/rockchip-iommu.c
@@ -998,13 +998,6 @@ static struct iommu_domain rk_identity_domain = {
.ops = &rk_identity_ops,
};
-#ifdef CONFIG_ARM
-static void rk_iommu_set_platform_dma(struct device *dev)
-{
- WARN_ON(rk_iommu_identity_attach(&rk_identity_domain, dev));
-}
-#endif
-
static int rk_iommu_attach_device(struct iommu_domain *domain,
struct device *dev)
{
@@ -1183,9 +1176,6 @@ static const struct iommu_ops rk_iommu_ops = {
.probe_device = rk_iommu_probe_device,
.release_device = rk_iommu_release_device,
.device_group = rk_iommu_device_group,
-#ifdef CONFIG_ARM
- .set_platform_dma_ops = rk_iommu_set_platform_dma,
-#endif
.pgsize_bitmap = RK_IOMMU_PGSIZE_BITMAP,
.of_xlate = rk_iommu_of_xlate,
.default_domain_ops = &(const struct iommu_domain_ops) {
--
2.41.0
^ permalink raw reply related
* [PATCH v7 12/24] iommu/tegra-smmu: Support DMA domains in tegra
From: Jason Gunthorpe @ 2023-08-23 16:47 UTC (permalink / raw)
To: Andy Gross, Alim Akhtar, Bjorn Andersson,
AngeloGioacchino Del Regno, Baolin Wang, Christophe Leroy,
Gerald Schaefer, Heiko Stuebner, iommu, Jernej Skrabec,
Jonathan Hunter, Joerg Roedel, Kevin Tian, Konrad Dybcio,
Krzysztof Kozlowski, linux-arm-kernel, linux-arm-msm,
linux-mediatek, linux-rockchip, linux-s390, linux-samsung-soc,
linux-sunxi, linux-tegra, Russell King, linuxppc-dev,
Matthias Brugger, Matthew Rosato, Michael Ellerman,
Nicholas Piggin, Orson Zhai, Rob Clark, Robin Murphy,
Samuel Holland, Thierry Reding, Krishna Reddy, Chen-Yu Tsai,
Will Deacon, Yong Wu, Chunyan Zhang
Cc: Lu Baolu, Dmitry Osipenko, Marek Szyprowski, Nicolin Chen,
Niklas Schnelle, Steven Price, Thierry Reding
In-Reply-To: <0-v7-de04a3217c48+15055-iommu_all_defdom_jgg@nvidia.com>
All ARM64 iommu drivers should support IOMMU_DOMAIN_DMA to enable
dma-iommu.c.
tegra is blocking dma-iommu usage, and also default_domain's, because it
wants an identity translation. This is needed for some device quirk. The
correct way to do this is to support IDENTITY domains and use
ops->def_domain_type() to return IOMMU_DOMAIN_IDENTITY for only the quirky
devices.
Add support for IOMMU_DOMAIN_DMA and force IOMMU_DOMAIN_IDENTITY mode for
everything so no behavior changes.
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
---
drivers/iommu/tegra-smmu.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/iommu/tegra-smmu.c b/drivers/iommu/tegra-smmu.c
index 80481e1ba561b8..b91ad1b5a20d36 100644
--- a/drivers/iommu/tegra-smmu.c
+++ b/drivers/iommu/tegra-smmu.c
@@ -276,7 +276,7 @@ static struct iommu_domain *tegra_smmu_domain_alloc(unsigned type)
{
struct tegra_smmu_as *as;
- if (type != IOMMU_DOMAIN_UNMANAGED)
+ if (type != IOMMU_DOMAIN_UNMANAGED && type != IOMMU_DOMAIN_DMA)
return NULL;
as = kzalloc(sizeof(*as), GFP_KERNEL);
--
2.41.0
^ permalink raw reply related
* [PATCH v7 19/24] iommu/sun50i: Add an IOMMU_IDENTITIY_DOMAIN
From: Jason Gunthorpe @ 2023-08-23 16:47 UTC (permalink / raw)
To: Andy Gross, Alim Akhtar, Bjorn Andersson,
AngeloGioacchino Del Regno, Baolin Wang, Christophe Leroy,
Gerald Schaefer, Heiko Stuebner, iommu, Jernej Skrabec,
Jonathan Hunter, Joerg Roedel, Kevin Tian, Konrad Dybcio,
Krzysztof Kozlowski, linux-arm-kernel, linux-arm-msm,
linux-mediatek, linux-rockchip, linux-s390, linux-samsung-soc,
linux-sunxi, linux-tegra, Russell King, linuxppc-dev,
Matthias Brugger, Matthew Rosato, Michael Ellerman,
Nicholas Piggin, Orson Zhai, Rob Clark, Robin Murphy,
Samuel Holland, Thierry Reding, Krishna Reddy, Chen-Yu Tsai,
Will Deacon, Yong Wu, Chunyan Zhang
Cc: Lu Baolu, Dmitry Osipenko, Marek Szyprowski, Nicolin Chen,
Niklas Schnelle, Steven Price, Thierry Reding
In-Reply-To: <0-v7-de04a3217c48+15055-iommu_all_defdom_jgg@nvidia.com>
Prior to commit 1b932ceddd19 ("iommu: Remove detach_dev callbacks") the
sun50i_iommu_detach_device() function was being called by
ops->detach_dev().
This is an IDENTITY domain so convert sun50i_iommu_detach_device() into
sun50i_iommu_identity_attach() and a full IDENTITY domain and thus hook it
back up the same was as the old ops->detach_dev().
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
---
drivers/iommu/sun50i-iommu.c | 26 +++++++++++++++++++-------
1 file changed, 19 insertions(+), 7 deletions(-)
diff --git a/drivers/iommu/sun50i-iommu.c b/drivers/iommu/sun50i-iommu.c
index 74c5cb93e90027..0bf08b120cf105 100644
--- a/drivers/iommu/sun50i-iommu.c
+++ b/drivers/iommu/sun50i-iommu.c
@@ -757,21 +757,32 @@ static void sun50i_iommu_detach_domain(struct sun50i_iommu *iommu,
iommu->domain = NULL;
}
-static void sun50i_iommu_detach_device(struct iommu_domain *domain,
- struct device *dev)
+static int sun50i_iommu_identity_attach(struct iommu_domain *identity_domain,
+ struct device *dev)
{
- struct sun50i_iommu_domain *sun50i_domain = to_sun50i_domain(domain);
struct sun50i_iommu *iommu = dev_iommu_priv_get(dev);
+ struct sun50i_iommu_domain *sun50i_domain;
dev_dbg(dev, "Detaching from IOMMU domain\n");
- if (iommu->domain != domain)
- return;
+ if (iommu->domain == identity_domain)
+ return 0;
+ sun50i_domain = to_sun50i_domain(iommu->domain);
if (refcount_dec_and_test(&sun50i_domain->refcnt))
sun50i_iommu_detach_domain(iommu, sun50i_domain);
+ return 0;
}
+static struct iommu_domain_ops sun50i_iommu_identity_ops = {
+ .attach_dev = sun50i_iommu_identity_attach,
+};
+
+static struct iommu_domain sun50i_iommu_identity_domain = {
+ .type = IOMMU_DOMAIN_IDENTITY,
+ .ops = &sun50i_iommu_identity_ops,
+};
+
static int sun50i_iommu_attach_device(struct iommu_domain *domain,
struct device *dev)
{
@@ -789,8 +800,7 @@ static int sun50i_iommu_attach_device(struct iommu_domain *domain,
if (iommu->domain == domain)
return 0;
- if (iommu->domain)
- sun50i_iommu_detach_device(iommu->domain, dev);
+ sun50i_iommu_identity_attach(&sun50i_iommu_identity_domain, dev);
sun50i_iommu_attach_domain(iommu, sun50i_domain);
@@ -827,6 +837,7 @@ static int sun50i_iommu_of_xlate(struct device *dev,
}
static const struct iommu_ops sun50i_iommu_ops = {
+ .identity_domain = &sun50i_iommu_identity_domain,
.pgsize_bitmap = SZ_4K,
.device_group = sun50i_iommu_device_group,
.domain_alloc = sun50i_iommu_domain_alloc,
@@ -985,6 +996,7 @@ static int sun50i_iommu_probe(struct platform_device *pdev)
if (!iommu)
return -ENOMEM;
spin_lock_init(&iommu->iommu_lock);
+ iommu->domain = &sun50i_iommu_identity_domain;
platform_set_drvdata(pdev, iommu);
iommu->dev = &pdev->dev;
--
2.41.0
^ permalink raw reply related
* [PATCH v7 06/24] iommu/tegra-gart: Remove tegra-gart
From: Jason Gunthorpe @ 2023-08-23 16:47 UTC (permalink / raw)
To: Andy Gross, Alim Akhtar, Bjorn Andersson,
AngeloGioacchino Del Regno, Baolin Wang, Christophe Leroy,
Gerald Schaefer, Heiko Stuebner, iommu, Jernej Skrabec,
Jonathan Hunter, Joerg Roedel, Kevin Tian, Konrad Dybcio,
Krzysztof Kozlowski, linux-arm-kernel, linux-arm-msm,
linux-mediatek, linux-rockchip, linux-s390, linux-samsung-soc,
linux-sunxi, linux-tegra, Russell King, linuxppc-dev,
Matthias Brugger, Matthew Rosato, Michael Ellerman,
Nicholas Piggin, Orson Zhai, Rob Clark, Robin Murphy,
Samuel Holland, Thierry Reding, Krishna Reddy, Chen-Yu Tsai,
Will Deacon, Yong Wu, Chunyan Zhang
Cc: Lu Baolu, Dmitry Osipenko, Marek Szyprowski, Nicolin Chen,
Niklas Schnelle, Steven Price, Thierry Reding
In-Reply-To: <0-v7-de04a3217c48+15055-iommu_all_defdom_jgg@nvidia.com>
Thierry says this is not used anymore, and doesn't think it makes sense as
an iommu driver. The HW it supports is about 10 years old now and newer HW
uses different IOMMU drivers.
As this is the only driver with a GART approach, and it doesn't really
meet the driver expectations from the IOMMU core, let's just remove it
so we don't have to think about how to make it fit in.
It has a number of identified problems:
- The assignment of iommu_groups doesn't match the HW behavior
- It claims to have an UNMANAGED domain but it is really an IDENTITY
domain with a translation aperture. This is inconsistent with the core
expectation for security sensitive operations
- It doesn't implement a SW page table under struct iommu_domain so
* It can't accept a map until the domain is attached
* It forgets about all maps after the domain is detached
* It doesn't clear the HW of maps once the domain is detached
(made worse by having the wrong groups)
Cc: Thierry Reding <treding@nvidia.com>
Cc: Dmitry Osipenko <digetx@gmail.com>
Acked-by: Thierry Reding <treding@nvidia.com>
Reviewed-by: Lu Baolu <baolu.lu@linux.intel.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
---
arch/arm/configs/multi_v7_defconfig | 1 -
arch/arm/configs/tegra_defconfig | 1 -
drivers/iommu/Kconfig | 11 -
drivers/iommu/Makefile | 1 -
drivers/iommu/tegra-gart.c | 371 ----------------------------
drivers/memory/tegra/mc.c | 34 ---
drivers/memory/tegra/tegra20.c | 28 ---
include/soc/tegra/mc.h | 26 --
8 files changed, 473 deletions(-)
delete mode 100644 drivers/iommu/tegra-gart.c
diff --git a/arch/arm/configs/multi_v7_defconfig b/arch/arm/configs/multi_v7_defconfig
index c7b2550d706cac..ae1aa32c30b25e 100644
--- a/arch/arm/configs/multi_v7_defconfig
+++ b/arch/arm/configs/multi_v7_defconfig
@@ -1063,7 +1063,6 @@ CONFIG_BCM2835_MBOX=y
CONFIG_QCOM_APCS_IPC=y
CONFIG_QCOM_IPCC=y
CONFIG_ROCKCHIP_IOMMU=y
-CONFIG_TEGRA_IOMMU_GART=y
CONFIG_TEGRA_IOMMU_SMMU=y
CONFIG_EXYNOS_IOMMU=y
CONFIG_QCOM_IOMMU=y
diff --git a/arch/arm/configs/tegra_defconfig b/arch/arm/configs/tegra_defconfig
index 3c6af935e9328a..79141dddb037a9 100644
--- a/arch/arm/configs/tegra_defconfig
+++ b/arch/arm/configs/tegra_defconfig
@@ -292,7 +292,6 @@ CONFIG_CHROME_PLATFORMS=y
CONFIG_CROS_EC=y
CONFIG_CROS_EC_I2C=m
CONFIG_CROS_EC_SPI=m
-CONFIG_TEGRA_IOMMU_GART=y
CONFIG_TEGRA_IOMMU_SMMU=y
CONFIG_ARCH_TEGRA_2x_SOC=y
CONFIG_ARCH_TEGRA_3x_SOC=y
diff --git a/drivers/iommu/Kconfig b/drivers/iommu/Kconfig
index 2b12b583ef4b1e..cd6727898b1175 100644
--- a/drivers/iommu/Kconfig
+++ b/drivers/iommu/Kconfig
@@ -236,17 +236,6 @@ config SUN50I_IOMMU
help
Support for the IOMMU introduced in the Allwinner H6 SoCs.
-config TEGRA_IOMMU_GART
- bool "Tegra GART IOMMU Support"
- depends on ARCH_TEGRA_2x_SOC
- depends on TEGRA_MC
- select IOMMU_API
- help
- Enables support for remapping discontiguous physical memory
- shared with the operating system into contiguous I/O virtual
- space through the GART (Graphics Address Relocation Table)
- hardware included on Tegra SoCs.
-
config TEGRA_IOMMU_SMMU
bool "NVIDIA Tegra SMMU Support"
depends on ARCH_TEGRA
diff --git a/drivers/iommu/Makefile b/drivers/iommu/Makefile
index 769e43d780ce89..95ad9dbfbda022 100644
--- a/drivers/iommu/Makefile
+++ b/drivers/iommu/Makefile
@@ -20,7 +20,6 @@ obj-$(CONFIG_OMAP_IOMMU) += omap-iommu.o
obj-$(CONFIG_OMAP_IOMMU_DEBUG) += omap-iommu-debug.o
obj-$(CONFIG_ROCKCHIP_IOMMU) += rockchip-iommu.o
obj-$(CONFIG_SUN50I_IOMMU) += sun50i-iommu.o
-obj-$(CONFIG_TEGRA_IOMMU_GART) += tegra-gart.o
obj-$(CONFIG_TEGRA_IOMMU_SMMU) += tegra-smmu.o
obj-$(CONFIG_EXYNOS_IOMMU) += exynos-iommu.o
obj-$(CONFIG_FSL_PAMU) += fsl_pamu.o fsl_pamu_domain.o
diff --git a/drivers/iommu/tegra-gart.c b/drivers/iommu/tegra-gart.c
deleted file mode 100644
index a482ff838b5331..00000000000000
--- a/drivers/iommu/tegra-gart.c
+++ /dev/null
@@ -1,371 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-/*
- * IOMMU API for Graphics Address Relocation Table on Tegra20
- *
- * Copyright (c) 2010-2012, NVIDIA CORPORATION. All rights reserved.
- *
- * Author: Hiroshi DOYU <hdoyu@nvidia.com>
- */
-
-#define dev_fmt(fmt) "gart: " fmt
-
-#include <linux/io.h>
-#include <linux/iommu.h>
-#include <linux/moduleparam.h>
-#include <linux/platform_device.h>
-#include <linux/slab.h>
-#include <linux/spinlock.h>
-#include <linux/vmalloc.h>
-
-#include <soc/tegra/mc.h>
-
-#define GART_REG_BASE 0x24
-#define GART_CONFIG (0x24 - GART_REG_BASE)
-#define GART_ENTRY_ADDR (0x28 - GART_REG_BASE)
-#define GART_ENTRY_DATA (0x2c - GART_REG_BASE)
-
-#define GART_ENTRY_PHYS_ADDR_VALID BIT(31)
-
-#define GART_PAGE_SHIFT 12
-#define GART_PAGE_SIZE (1 << GART_PAGE_SHIFT)
-#define GART_PAGE_MASK GENMASK(30, GART_PAGE_SHIFT)
-
-/* bitmap of the page sizes currently supported */
-#define GART_IOMMU_PGSIZES (GART_PAGE_SIZE)
-
-struct gart_device {
- void __iomem *regs;
- u32 *savedata;
- unsigned long iovmm_base; /* offset to vmm_area start */
- unsigned long iovmm_end; /* offset to vmm_area end */
- spinlock_t pte_lock; /* for pagetable */
- spinlock_t dom_lock; /* for active domain */
- unsigned int active_devices; /* number of active devices */
- struct iommu_domain *active_domain; /* current active domain */
- struct iommu_device iommu; /* IOMMU Core handle */
- struct device *dev;
-};
-
-static struct gart_device *gart_handle; /* unique for a system */
-
-static bool gart_debug;
-
-/*
- * Any interaction between any block on PPSB and a block on APB or AHB
- * must have these read-back to ensure the APB/AHB bus transaction is
- * complete before initiating activity on the PPSB block.
- */
-#define FLUSH_GART_REGS(gart) readl_relaxed((gart)->regs + GART_CONFIG)
-
-#define for_each_gart_pte(gart, iova) \
- for (iova = gart->iovmm_base; \
- iova < gart->iovmm_end; \
- iova += GART_PAGE_SIZE)
-
-static inline void gart_set_pte(struct gart_device *gart,
- unsigned long iova, unsigned long pte)
-{
- writel_relaxed(iova, gart->regs + GART_ENTRY_ADDR);
- writel_relaxed(pte, gart->regs + GART_ENTRY_DATA);
-}
-
-static inline unsigned long gart_read_pte(struct gart_device *gart,
- unsigned long iova)
-{
- unsigned long pte;
-
- writel_relaxed(iova, gart->regs + GART_ENTRY_ADDR);
- pte = readl_relaxed(gart->regs + GART_ENTRY_DATA);
-
- return pte;
-}
-
-static void do_gart_setup(struct gart_device *gart, const u32 *data)
-{
- unsigned long iova;
-
- for_each_gart_pte(gart, iova)
- gart_set_pte(gart, iova, data ? *(data++) : 0);
-
- writel_relaxed(1, gart->regs + GART_CONFIG);
- FLUSH_GART_REGS(gart);
-}
-
-static inline bool gart_iova_range_invalid(struct gart_device *gart,
- unsigned long iova, size_t bytes)
-{
- return unlikely(iova < gart->iovmm_base || bytes != GART_PAGE_SIZE ||
- iova + bytes > gart->iovmm_end);
-}
-
-static inline bool gart_pte_valid(struct gart_device *gart, unsigned long iova)
-{
- return !!(gart_read_pte(gart, iova) & GART_ENTRY_PHYS_ADDR_VALID);
-}
-
-static int gart_iommu_attach_dev(struct iommu_domain *domain,
- struct device *dev)
-{
- struct gart_device *gart = gart_handle;
- int ret = 0;
-
- spin_lock(&gart->dom_lock);
-
- if (gart->active_domain && gart->active_domain != domain) {
- ret = -EINVAL;
- } else if (dev_iommu_priv_get(dev) != domain) {
- dev_iommu_priv_set(dev, domain);
- gart->active_domain = domain;
- gart->active_devices++;
- }
-
- spin_unlock(&gart->dom_lock);
-
- return ret;
-}
-
-static void gart_iommu_set_platform_dma(struct device *dev)
-{
- struct iommu_domain *domain = iommu_get_domain_for_dev(dev);
- struct gart_device *gart = gart_handle;
-
- spin_lock(&gart->dom_lock);
-
- if (dev_iommu_priv_get(dev) == domain) {
- dev_iommu_priv_set(dev, NULL);
-
- if (--gart->active_devices == 0)
- gart->active_domain = NULL;
- }
-
- spin_unlock(&gart->dom_lock);
-}
-
-static struct iommu_domain *gart_iommu_domain_alloc(unsigned type)
-{
- struct iommu_domain *domain;
-
- if (type != IOMMU_DOMAIN_UNMANAGED)
- return NULL;
-
- domain = kzalloc(sizeof(*domain), GFP_KERNEL);
- if (domain) {
- domain->geometry.aperture_start = gart_handle->iovmm_base;
- domain->geometry.aperture_end = gart_handle->iovmm_end - 1;
- domain->geometry.force_aperture = true;
- }
-
- return domain;
-}
-
-static void gart_iommu_domain_free(struct iommu_domain *domain)
-{
- WARN_ON(gart_handle->active_domain == domain);
- kfree(domain);
-}
-
-static inline int __gart_iommu_map(struct gart_device *gart, unsigned long iova,
- unsigned long pa)
-{
- if (unlikely(gart_debug && gart_pte_valid(gart, iova))) {
- dev_err(gart->dev, "Page entry is in-use\n");
- return -EINVAL;
- }
-
- gart_set_pte(gart, iova, GART_ENTRY_PHYS_ADDR_VALID | pa);
-
- return 0;
-}
-
-static int gart_iommu_map(struct iommu_domain *domain, unsigned long iova,
- phys_addr_t pa, size_t bytes, int prot, gfp_t gfp)
-{
- struct gart_device *gart = gart_handle;
- int ret;
-
- if (gart_iova_range_invalid(gart, iova, bytes))
- return -EINVAL;
-
- spin_lock(&gart->pte_lock);
- ret = __gart_iommu_map(gart, iova, (unsigned long)pa);
- spin_unlock(&gart->pte_lock);
-
- return ret;
-}
-
-static inline int __gart_iommu_unmap(struct gart_device *gart,
- unsigned long iova)
-{
- if (unlikely(gart_debug && !gart_pte_valid(gart, iova))) {
- dev_err(gart->dev, "Page entry is invalid\n");
- return -EINVAL;
- }
-
- gart_set_pte(gart, iova, 0);
-
- return 0;
-}
-
-static size_t gart_iommu_unmap(struct iommu_domain *domain, unsigned long iova,
- size_t bytes, struct iommu_iotlb_gather *gather)
-{
- struct gart_device *gart = gart_handle;
- int err;
-
- if (gart_iova_range_invalid(gart, iova, bytes))
- return 0;
-
- spin_lock(&gart->pte_lock);
- err = __gart_iommu_unmap(gart, iova);
- spin_unlock(&gart->pte_lock);
-
- return err ? 0 : bytes;
-}
-
-static phys_addr_t gart_iommu_iova_to_phys(struct iommu_domain *domain,
- dma_addr_t iova)
-{
- struct gart_device *gart = gart_handle;
- unsigned long pte;
-
- if (gart_iova_range_invalid(gart, iova, GART_PAGE_SIZE))
- return -EINVAL;
-
- spin_lock(&gart->pte_lock);
- pte = gart_read_pte(gart, iova);
- spin_unlock(&gart->pte_lock);
-
- return pte & GART_PAGE_MASK;
-}
-
-static struct iommu_device *gart_iommu_probe_device(struct device *dev)
-{
- if (!dev_iommu_fwspec_get(dev))
- return ERR_PTR(-ENODEV);
-
- return &gart_handle->iommu;
-}
-
-static int gart_iommu_of_xlate(struct device *dev,
- struct of_phandle_args *args)
-{
- return 0;
-}
-
-static void gart_iommu_sync_map(struct iommu_domain *domain, unsigned long iova,
- size_t size)
-{
- FLUSH_GART_REGS(gart_handle);
-}
-
-static void gart_iommu_sync(struct iommu_domain *domain,
- struct iommu_iotlb_gather *gather)
-{
- size_t length = gather->end - gather->start + 1;
-
- gart_iommu_sync_map(domain, gather->start, length);
-}
-
-static const struct iommu_ops gart_iommu_ops = {
- .domain_alloc = gart_iommu_domain_alloc,
- .probe_device = gart_iommu_probe_device,
- .device_group = generic_device_group,
- .set_platform_dma_ops = gart_iommu_set_platform_dma,
- .pgsize_bitmap = GART_IOMMU_PGSIZES,
- .of_xlate = gart_iommu_of_xlate,
- .default_domain_ops = &(const struct iommu_domain_ops) {
- .attach_dev = gart_iommu_attach_dev,
- .map = gart_iommu_map,
- .unmap = gart_iommu_unmap,
- .iova_to_phys = gart_iommu_iova_to_phys,
- .iotlb_sync_map = gart_iommu_sync_map,
- .iotlb_sync = gart_iommu_sync,
- .free = gart_iommu_domain_free,
- }
-};
-
-int tegra_gart_suspend(struct gart_device *gart)
-{
- u32 *data = gart->savedata;
- unsigned long iova;
-
- /*
- * All GART users shall be suspended at this point. Disable
- * address translation to trap all GART accesses as invalid
- * memory accesses.
- */
- writel_relaxed(0, gart->regs + GART_CONFIG);
- FLUSH_GART_REGS(gart);
-
- for_each_gart_pte(gart, iova)
- *(data++) = gart_read_pte(gart, iova);
-
- return 0;
-}
-
-int tegra_gart_resume(struct gart_device *gart)
-{
- do_gart_setup(gart, gart->savedata);
-
- return 0;
-}
-
-struct gart_device *tegra_gart_probe(struct device *dev, struct tegra_mc *mc)
-{
- struct gart_device *gart;
- struct resource *res;
- int err;
-
- BUILD_BUG_ON(PAGE_SHIFT != GART_PAGE_SHIFT);
-
- /* the GART memory aperture is required */
- res = platform_get_resource(to_platform_device(dev), IORESOURCE_MEM, 1);
- if (!res) {
- dev_err(dev, "Memory aperture resource unavailable\n");
- return ERR_PTR(-ENXIO);
- }
-
- gart = kzalloc(sizeof(*gart), GFP_KERNEL);
- if (!gart)
- return ERR_PTR(-ENOMEM);
-
- gart_handle = gart;
-
- gart->dev = dev;
- gart->regs = mc->regs + GART_REG_BASE;
- gart->iovmm_base = res->start;
- gart->iovmm_end = res->end + 1;
- spin_lock_init(&gart->pte_lock);
- spin_lock_init(&gart->dom_lock);
-
- do_gart_setup(gart, NULL);
-
- err = iommu_device_sysfs_add(&gart->iommu, dev, NULL, "gart");
- if (err)
- goto free_gart;
-
- err = iommu_device_register(&gart->iommu, &gart_iommu_ops, dev);
- if (err)
- goto remove_sysfs;
-
- gart->savedata = vmalloc(resource_size(res) / GART_PAGE_SIZE *
- sizeof(u32));
- if (!gart->savedata) {
- err = -ENOMEM;
- goto unregister_iommu;
- }
-
- return gart;
-
-unregister_iommu:
- iommu_device_unregister(&gart->iommu);
-remove_sysfs:
- iommu_device_sysfs_remove(&gart->iommu);
-free_gart:
- kfree(gart);
-
- return ERR_PTR(err);
-}
-
-module_param(gart_debug, bool, 0644);
-MODULE_PARM_DESC(gart_debug, "Enable GART debugging");
diff --git a/drivers/memory/tegra/mc.c b/drivers/memory/tegra/mc.c
index deb6e65b59afc4..5641324c9a2c28 100644
--- a/drivers/memory/tegra/mc.c
+++ b/drivers/memory/tegra/mc.c
@@ -979,35 +979,6 @@ static int tegra_mc_probe(struct platform_device *pdev)
}
}
- if (IS_ENABLED(CONFIG_TEGRA_IOMMU_GART) && !mc->soc->smmu) {
- mc->gart = tegra_gart_probe(&pdev->dev, mc);
- if (IS_ERR(mc->gart)) {
- dev_err(&pdev->dev, "failed to probe GART: %ld\n",
- PTR_ERR(mc->gart));
- mc->gart = NULL;
- }
- }
-
- return 0;
-}
-
-static int __maybe_unused tegra_mc_suspend(struct device *dev)
-{
- struct tegra_mc *mc = dev_get_drvdata(dev);
-
- if (mc->soc->ops && mc->soc->ops->suspend)
- return mc->soc->ops->suspend(mc);
-
- return 0;
-}
-
-static int __maybe_unused tegra_mc_resume(struct device *dev)
-{
- struct tegra_mc *mc = dev_get_drvdata(dev);
-
- if (mc->soc->ops && mc->soc->ops->resume)
- return mc->soc->ops->resume(mc);
-
return 0;
}
@@ -1020,15 +991,10 @@ static void tegra_mc_sync_state(struct device *dev)
icc_sync_state(dev);
}
-static const struct dev_pm_ops tegra_mc_pm_ops = {
- SET_SYSTEM_SLEEP_PM_OPS(tegra_mc_suspend, tegra_mc_resume)
-};
-
static struct platform_driver tegra_mc_driver = {
.driver = {
.name = "tegra-mc",
.of_match_table = tegra_mc_of_match,
- .pm = &tegra_mc_pm_ops,
.suppress_bind_attrs = true,
.sync_state = tegra_mc_sync_state,
},
diff --git a/drivers/memory/tegra/tegra20.c b/drivers/memory/tegra/tegra20.c
index fcd7738fcb536c..6f367f743587db 100644
--- a/drivers/memory/tegra/tegra20.c
+++ b/drivers/memory/tegra/tegra20.c
@@ -687,32 +687,6 @@ static int tegra20_mc_probe(struct tegra_mc *mc)
return 0;
}
-static int tegra20_mc_suspend(struct tegra_mc *mc)
-{
- int err;
-
- if (IS_ENABLED(CONFIG_TEGRA_IOMMU_GART) && mc->gart) {
- err = tegra_gart_suspend(mc->gart);
- if (err < 0)
- return err;
- }
-
- return 0;
-}
-
-static int tegra20_mc_resume(struct tegra_mc *mc)
-{
- int err;
-
- if (IS_ENABLED(CONFIG_TEGRA_IOMMU_GART) && mc->gart) {
- err = tegra_gart_resume(mc->gart);
- if (err < 0)
- return err;
- }
-
- return 0;
-}
-
static irqreturn_t tegra20_mc_handle_irq(int irq, void *data)
{
struct tegra_mc *mc = data;
@@ -788,8 +762,6 @@ static irqreturn_t tegra20_mc_handle_irq(int irq, void *data)
static const struct tegra_mc_ops tegra20_mc_ops = {
.probe = tegra20_mc_probe,
- .suspend = tegra20_mc_suspend,
- .resume = tegra20_mc_resume,
.handle_irq = tegra20_mc_handle_irq,
};
diff --git a/include/soc/tegra/mc.h b/include/soc/tegra/mc.h
index a5ef84944a0680..71ae37d3bedd76 100644
--- a/include/soc/tegra/mc.h
+++ b/include/soc/tegra/mc.h
@@ -96,7 +96,6 @@ struct tegra_smmu_soc {
struct tegra_mc;
struct tegra_smmu;
-struct gart_device;
#ifdef CONFIG_TEGRA_IOMMU_SMMU
struct tegra_smmu *tegra_smmu_probe(struct device *dev,
@@ -116,28 +115,6 @@ static inline void tegra_smmu_remove(struct tegra_smmu *smmu)
}
#endif
-#ifdef CONFIG_TEGRA_IOMMU_GART
-struct gart_device *tegra_gart_probe(struct device *dev, struct tegra_mc *mc);
-int tegra_gart_suspend(struct gart_device *gart);
-int tegra_gart_resume(struct gart_device *gart);
-#else
-static inline struct gart_device *
-tegra_gart_probe(struct device *dev, struct tegra_mc *mc)
-{
- return ERR_PTR(-ENODEV);
-}
-
-static inline int tegra_gart_suspend(struct gart_device *gart)
-{
- return -ENODEV;
-}
-
-static inline int tegra_gart_resume(struct gart_device *gart)
-{
- return -ENODEV;
-}
-#endif
-
struct tegra_mc_reset {
const char *name;
unsigned long id;
@@ -185,8 +162,6 @@ struct tegra_mc_ops {
*/
int (*probe)(struct tegra_mc *mc);
void (*remove)(struct tegra_mc *mc);
- int (*suspend)(struct tegra_mc *mc);
- int (*resume)(struct tegra_mc *mc);
irqreturn_t (*handle_irq)(int irq, void *data);
int (*probe_device)(struct tegra_mc *mc, struct device *dev);
};
@@ -225,7 +200,6 @@ struct tegra_mc {
struct tegra_bpmp *bpmp;
struct device *dev;
struct tegra_smmu *smmu;
- struct gart_device *gart;
void __iomem *regs;
void __iomem *bcast_ch_regs;
void __iomem **ch_regs;
--
2.41.0
^ permalink raw reply related
* [PATCH v7 22/24] iommu: Add ops->domain_alloc_paging()
From: Jason Gunthorpe @ 2023-08-23 16:47 UTC (permalink / raw)
To: Andy Gross, Alim Akhtar, Bjorn Andersson,
AngeloGioacchino Del Regno, Baolin Wang, Christophe Leroy,
Gerald Schaefer, Heiko Stuebner, iommu, Jernej Skrabec,
Jonathan Hunter, Joerg Roedel, Kevin Tian, Konrad Dybcio,
Krzysztof Kozlowski, linux-arm-kernel, linux-arm-msm,
linux-mediatek, linux-rockchip, linux-s390, linux-samsung-soc,
linux-sunxi, linux-tegra, Russell King, linuxppc-dev,
Matthias Brugger, Matthew Rosato, Michael Ellerman,
Nicholas Piggin, Orson Zhai, Rob Clark, Robin Murphy,
Samuel Holland, Thierry Reding, Krishna Reddy, Chen-Yu Tsai,
Will Deacon, Yong Wu, Chunyan Zhang
Cc: Lu Baolu, Dmitry Osipenko, Marek Szyprowski, Nicolin Chen,
Niklas Schnelle, Steven Price, Thierry Reding
In-Reply-To: <0-v7-de04a3217c48+15055-iommu_all_defdom_jgg@nvidia.com>
This callback requests the driver to create only a __IOMMU_DOMAIN_PAGING
domain, so it saves a few lines in a lot of drivers needlessly checking
the type.
More critically, this allows us to sweep out all the
IOMMU_DOMAIN_UNMANAGED and IOMMU_DOMAIN_DMA checks from a lot of the
drivers, simplifying what is going on in the code and ultimately removing
the now-unused special cases in drivers where they did not support
IOMMU_DOMAIN_DMA.
domain_alloc_paging() should return a struct iommu_domain that is
functionally compatible with ARM_DMA_USE_IOMMU, dma-iommu.c and iommufd.
Be forwards looking and pass in a 'struct device *' argument. We can
provide this when allocating the default_domain. No drivers will look at
this.
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>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
---
drivers/iommu/iommu.c | 17 ++++++++++++++---
include/linux/iommu.h | 3 +++
2 files changed, 17 insertions(+), 3 deletions(-)
diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
index 568dec45a06954..c5d8cf48a99332 100644
--- a/drivers/iommu/iommu.c
+++ b/drivers/iommu/iommu.c
@@ -2041,6 +2041,7 @@ void iommu_set_fault_handler(struct iommu_domain *domain,
EXPORT_SYMBOL_GPL(iommu_set_fault_handler);
static struct iommu_domain *__iommu_domain_alloc(const struct iommu_ops *ops,
+ struct device *dev,
unsigned int type)
{
struct iommu_domain *domain;
@@ -2048,8 +2049,13 @@ static struct iommu_domain *__iommu_domain_alloc(const struct iommu_ops *ops,
if (alloc_type == IOMMU_DOMAIN_IDENTITY && ops->identity_domain)
return ops->identity_domain;
+ else if (type & __IOMMU_DOMAIN_PAGING && ops->domain_alloc_paging)
+ domain = ops->domain_alloc_paging(dev);
+ else if (ops->domain_alloc)
+ domain = ops->domain_alloc(alloc_type);
+ else
+ return NULL;
- domain = ops->domain_alloc(alloc_type);
if (!domain)
return NULL;
@@ -2074,14 +2080,19 @@ static struct iommu_domain *__iommu_domain_alloc(const struct iommu_ops *ops,
static struct iommu_domain *
__iommu_group_domain_alloc(struct iommu_group *group, unsigned int type)
{
- return __iommu_domain_alloc(group_iommu_ops(group), type);
+ struct device *dev =
+ list_first_entry(&group->devices, struct group_device, list)
+ ->dev;
+
+ return __iommu_domain_alloc(group_iommu_ops(group), dev, type);
}
struct iommu_domain *iommu_domain_alloc(const struct bus_type *bus)
{
if (bus == NULL || bus->iommu_ops == NULL)
return NULL;
- return __iommu_domain_alloc(bus->iommu_ops, IOMMU_DOMAIN_UNMANAGED);
+ return __iommu_domain_alloc(bus->iommu_ops, NULL,
+ IOMMU_DOMAIN_UNMANAGED);
}
EXPORT_SYMBOL_GPL(iommu_domain_alloc);
diff --git a/include/linux/iommu.h b/include/linux/iommu.h
index c3d2e79076ffab..319bdc8328b407 100644
--- a/include/linux/iommu.h
+++ b/include/linux/iommu.h
@@ -239,6 +239,8 @@ struct iommu_iotlb_gather {
* use. The information type is one of enum iommu_hw_info_type defined
* in include/uapi/linux/iommufd.h.
* @domain_alloc: allocate iommu domain
+ * @domain_alloc_paging: Allocate an iommu_domain that can be used for
+ * UNMANAGED, DMA, and DMA_FQ domain types.
* @probe_device: Add device to iommu driver handling
* @release_device: Remove device from iommu driver handling
* @probe_finalize: Do final setup work after the device is added to an IOMMU
@@ -271,6 +273,7 @@ struct iommu_ops {
/* Domain allocation and freeing by the iommu driver */
struct iommu_domain *(*domain_alloc)(unsigned iommu_domain_type);
+ struct iommu_domain *(*domain_alloc_paging)(struct device *dev);
struct iommu_device *(*probe_device)(struct device *dev);
void (*release_device)(struct device *dev);
--
2.41.0
^ permalink raw reply related
* [PATCH v2] genpd: Explicitly include correct DT includes
From: Rob Herring @ 2023-08-23 17:04 UTC (permalink / raw)
To: Ulf Hansson, Matthias Brugger, AngeloGioacchino Del Regno,
Chen-Yu Tsai, Jernej Skrabec, Samuel Holland
Cc: linux-pm, linux-kernel, linux-arm-kernel, linux-mediatek,
linux-sunxi
The DT of_device.h and of_platform.h date back to the separate
of_platform_bus_type before it was merged into the regular platform bus.
As part of that merge prepping Arm DT support 13 years ago, they
"temporarily" include each other. They also include platform_device.h
and of.h. As a result, there's a pretty much random mix of those include
files used throughout the tree. In order to detangle these headers and
replace the implicit includes with struct declarations, users need to
explicitly include the correct includes.
Signed-off-by: Rob Herring <robh@kernel.org>
---
v2: Previously sent for drivers/soc/. Gathered up files which got moved
to genpd to new patch.
---
drivers/genpd/mediatek/mtk-pm-domains.c | 2 +-
drivers/genpd/mediatek/mtk-scpsys.c | 2 +-
drivers/genpd/sunxi/sun20i-ppu.c | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/genpd/mediatek/mtk-pm-domains.c b/drivers/genpd/mediatek/mtk-pm-domains.c
index 354249cc1b12..ee962804b830 100644
--- a/drivers/genpd/mediatek/mtk-pm-domains.c
+++ b/drivers/genpd/mediatek/mtk-pm-domains.c
@@ -8,8 +8,8 @@
#include <linux/io.h>
#include <linux/iopoll.h>
#include <linux/mfd/syscon.h>
+#include <linux/of.h>
#include <linux/of_clk.h>
-#include <linux/of_device.h>
#include <linux/platform_device.h>
#include <linux/pm_domain.h>
#include <linux/regmap.h>
diff --git a/drivers/genpd/mediatek/mtk-scpsys.c b/drivers/genpd/mediatek/mtk-scpsys.c
index 7a668888111c..b374d01fdac7 100644
--- a/drivers/genpd/mediatek/mtk-scpsys.c
+++ b/drivers/genpd/mediatek/mtk-scpsys.c
@@ -7,7 +7,7 @@
#include <linux/io.h>
#include <linux/iopoll.h>
#include <linux/mfd/syscon.h>
-#include <linux/of_device.h>
+#include <linux/of.h>
#include <linux/platform_device.h>
#include <linux/pm_domain.h>
#include <linux/regulator/consumer.h>
diff --git a/drivers/genpd/sunxi/sun20i-ppu.c b/drivers/genpd/sunxi/sun20i-ppu.c
index 98cb41d36560..8700f9dd5f75 100644
--- a/drivers/genpd/sunxi/sun20i-ppu.c
+++ b/drivers/genpd/sunxi/sun20i-ppu.c
@@ -5,7 +5,7 @@
#include <linux/io.h>
#include <linux/iopoll.h>
#include <linux/module.h>
-#include <linux/of_device.h>
+#include <linux/of.h>
#include <linux/platform_device.h>
#include <linux/pm_domain.h>
#include <linux/reset.h>
--
2.40.1
^ permalink raw reply related
* Re: [PATCH -next v2 02/25] spi: armada-3700: Use helper function devm_clk_get_prepared()
From: Jonathan Cameron @ 2023-08-23 17:10 UTC (permalink / raw)
To: Li Zetao
Cc: andrew, angelogioacchino.delregno, avifishman70,
bcm-kernel-feedback-list, benjaminfair, broonie, chin-ting_kuo,
clg, conor.dooley, daire.mcnamara, fancer.lancer,
florian.fainelli, heiko, jbrunet, joel, khilman, linus.walleij,
linux-amlogic, linux-arm-kernel, linux-aspeed, linux-mediatek,
linux-riscv, linux-rockchip, linux-rpi-kernel, linux-spi,
martin.blumenstingl, matthias.bgg, neil.armstrong, olteanv,
openbmc, rjui, sbranden, tali.perry1, tmaimon77, venture, yuenn
In-Reply-To: <20230823133938.1359106-3-lizetao1@huawei.com>
On Wed, 23 Aug 2023 21:39:15 +0800
Li Zetao <lizetao1@huawei.com> wrote:
> Since commit 7ef9651e9792 ("clk: Provide new devm_clk helpers for prepared
> and enabled clocks"), devm_clk_get() and clk_prepare() can now be replaced
> by devm_clk_get_prepared() when driver prepares the clocks for the whole
> lifetime of the device. Moreover, it is no longer necessary to unprepare
> the clocks explicitly.
>
> Signed-off-by: Li Zetao <lizetao1@huawei.com>
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> ---
> v1 -> v2: Drop the empty remove function a3700_spi_remove().
>
> drivers/spi/spi-armada-3700.c | 23 +++--------------------
> 1 file changed, 3 insertions(+), 20 deletions(-)
>
> diff --git a/drivers/spi/spi-armada-3700.c b/drivers/spi/spi-armada-3700.c
> index 0103ac0158c0..3c9ed412932f 100644
> --- a/drivers/spi/spi-armada-3700.c
> +++ b/drivers/spi/spi-armada-3700.c
> @@ -865,18 +865,12 @@ static int a3700_spi_probe(struct platform_device *pdev)
>
> init_completion(&spi->done);
>
> - spi->clk = devm_clk_get(dev, NULL);
> + spi->clk = devm_clk_get_prepared(dev, NULL);
> if (IS_ERR(spi->clk)) {
> dev_err(dev, "could not find clk: %ld\n", PTR_ERR(spi->clk));
> goto error;
> }
>
> - ret = clk_prepare(spi->clk);
> - if (ret) {
> - dev_err(dev, "could not prepare clk: %d\n", ret);
> - goto error;
> - }
> -
> host->max_speed_hz = min_t(unsigned long, A3700_SPI_MAX_SPEED_HZ,
> clk_get_rate(spi->clk));
> host->min_speed_hz = DIV_ROUND_UP(clk_get_rate(spi->clk),
> @@ -888,40 +882,29 @@ static int a3700_spi_probe(struct platform_device *pdev)
> dev_name(dev), host);
> if (ret) {
> dev_err(dev, "could not request IRQ: %d\n", ret);
> - goto error_clk;
> + goto error;
> }
>
> ret = devm_spi_register_controller(dev, host);
> if (ret) {
> dev_err(dev, "Failed to register host\n");
> - goto error_clk;
> + goto error;
> }
>
> return 0;
>
> -error_clk:
> - clk_unprepare(spi->clk);
> error:
> spi_controller_put(host);
> out:
> return ret;
> }
>
> -static void a3700_spi_remove(struct platform_device *pdev)
> -{
> - struct spi_controller *host = platform_get_drvdata(pdev);
> - struct a3700_spi *spi = spi_controller_get_devdata(host);
> -
> - clk_unprepare(spi->clk);
> -}
> -
> static struct platform_driver a3700_spi_driver = {
> .driver = {
> .name = DRIVER_NAME,
> .of_match_table = of_match_ptr(a3700_spi_dt_ids),
> },
> .probe = a3700_spi_probe,
> - .remove_new = a3700_spi_remove,
> };
>
> module_platform_driver(a3700_spi_driver);
^ permalink raw reply
* Re: [PATCH -next v2 11/25] spi: dw-bt1: Use helper function devm_clk_get_enabled()
From: Jonathan Cameron @ 2023-08-23 17:13 UTC (permalink / raw)
To: Serge Semin
Cc: Li Zetao, andrew, angelogioacchino.delregno, avifishman70,
bcm-kernel-feedback-list, benjaminfair, broonie, chin-ting_kuo,
clg, conor.dooley, daire.mcnamara, florian.fainelli, heiko,
jbrunet, joel, khilman, linus.walleij, linux-amlogic,
linux-arm-kernel, linux-aspeed, linux-mediatek, linux-riscv,
linux-rockchip, linux-rpi-kernel, linux-spi, martin.blumenstingl,
matthias.bgg, neil.armstrong, olteanv, openbmc, rjui, sbranden,
tali.perry1, tmaimon77, venture, yuenn
In-Reply-To: <xxosi2ymo7otqyfbmjlubezzedqw6ulwwhdmbdjbto7yaqw673@q673weupq67y>
On Wed, 23 Aug 2023 17:35:35 +0300
Serge Semin <fancer.lancer@gmail.com> wrote:
> On Wed, Aug 23, 2023 at 09:39:24PM +0800, Li Zetao wrote:
> > Since commit 7ef9651e9792 ("clk: Provide new devm_clk helpers for prepared
> > and enabled clocks"), devm_clk_get() and clk_prepare_enable() can now be
> > replaced by devm_clk_get_enabled() when driver enables (and possibly
> > prepares) the clocks for the whole lifetime of the device. Moreover, it is
> > no longer necessary to unprepare and disable the clocks explicitly.
> >
>
> > Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> > Acked-by: Serge Semin <fancer.lancer@gmail.com>
> > Signed-off-by: Li Zetao <lizetao1@huawei.com>
>
> Just for the record, the tags order is normally supposed to reflect a
> patch route. Even though AFAICS it's explicitly defined for the Sob
> tags only (see Documentation/process/submitting-patches.rst), but
> almost all kernel developers apply that rule to all the tags. See the
> kernel git log as the brightest example. So your Sob tag should have
> been kept first, then either my Ab or Jonathan' Rb tags.
There have been far too many discussions about this over the years.
There is an argument (I'm not saying I agree with it) that tags given
on an earlier version than the one posted should be before the SoB of
the author on basis that the SoB is occurring later (as it's on the new
version). That is a slightly stronger argument if there are changes
to the patch, but then things get inconsistent between patches with minor
changes and those without. *sigh*
So this pattern is fairly common if a bit weird in my view :)
Jonathan
>
> -Serge(y)
>
> > ---
> > v1 -> v2: None
> >
> > drivers/spi/spi-dw-bt1.c | 23 +++++------------------
> > 1 file changed, 5 insertions(+), 18 deletions(-)
> >
> > diff --git a/drivers/spi/spi-dw-bt1.c b/drivers/spi/spi-dw-bt1.c
> > index 5e1c01822967..5391bcac305c 100644
> > --- a/drivers/spi/spi-dw-bt1.c
> > +++ b/drivers/spi/spi-dw-bt1.c
> > @@ -269,43 +269,32 @@ static int dw_spi_bt1_probe(struct platform_device *pdev)
> >
> > dws->paddr = mem->start;
> >
> > - dwsbt1->clk = devm_clk_get(&pdev->dev, NULL);
> > + dwsbt1->clk = devm_clk_get_enabled(&pdev->dev, NULL);
> > if (IS_ERR(dwsbt1->clk))
> > return PTR_ERR(dwsbt1->clk);
> >
> > - ret = clk_prepare_enable(dwsbt1->clk);
> > - if (ret)
> > - return ret;
> > -
> > dws->bus_num = pdev->id;
> > dws->reg_io_width = 4;
> > dws->max_freq = clk_get_rate(dwsbt1->clk);
> > - if (!dws->max_freq) {
> > - ret = -EINVAL;
> > - goto err_disable_clk;
> > - }
> > + if (!dws->max_freq)
> > + return -EINVAL;
> >
> > init_func = device_get_match_data(&pdev->dev);
> > ret = init_func(pdev, dwsbt1);
> > if (ret)
> > - goto err_disable_clk;
> > + return ret;
> >
> > pm_runtime_enable(&pdev->dev);
> >
> > ret = dw_spi_add_host(&pdev->dev, dws);
> > if (ret) {
> > pm_runtime_disable(&pdev->dev);
> > - goto err_disable_clk;
> > + return ret;
> > }
> >
> > platform_set_drvdata(pdev, dwsbt1);
> >
> > return 0;
> > -
> > -err_disable_clk:
> > - clk_disable_unprepare(dwsbt1->clk);
> > -
> > - return ret;
> > }
> >
> > static void dw_spi_bt1_remove(struct platform_device *pdev)
> > @@ -315,8 +304,6 @@ static void dw_spi_bt1_remove(struct platform_device *pdev)
> > dw_spi_remove_host(&dwsbt1->dws);
> >
> > pm_runtime_disable(&pdev->dev);
> > -
> > - clk_disable_unprepare(dwsbt1->clk);
> > }
> >
> > static const struct of_device_id dw_spi_bt1_of_match[] = {
> > --
> > 2.34.1
> >
^ permalink raw reply
* Re: [PATCH -next v2 12/25] spi: dw-mmio: Use helper function devm_clk_get_*()
From: Jonathan Cameron @ 2023-08-23 17:15 UTC (permalink / raw)
To: Serge Semin
Cc: Li Zetao, andrew, angelogioacchino.delregno, avifishman70,
bcm-kernel-feedback-list, benjaminfair, broonie, chin-ting_kuo,
clg, conor.dooley, daire.mcnamara, florian.fainelli, heiko,
jbrunet, joel, khilman, linus.walleij, linux-amlogic,
linux-arm-kernel, linux-aspeed, linux-mediatek, linux-riscv,
linux-rockchip, linux-rpi-kernel, linux-spi, martin.blumenstingl,
matthias.bgg, neil.armstrong, olteanv, openbmc, rjui, sbranden,
tali.perry1, tmaimon77, venture, yuenn
In-Reply-To: <pflv2canelmm3ea7zpqgxrzj3s7cl56crpdbupkgqlabfnasjj@dkfyiubao2gj>
On Wed, 23 Aug 2023 17:20:12 +0300
Serge Semin <fancer.lancer@gmail.com> wrote:
> On Wed, Aug 23, 2023 at 09:39:25PM +0800, Li Zetao wrote:
> > Since commit 7ef9651e9792 ("clk: Provide new devm_clk helpers for prepared
> > and enabled clocks"), devm_clk_get() and clk_prepare_enable() can now be
> > replaced by devm_clk_get_enabled() when driver enables (and possibly
> > prepares) the clocks for the whole lifetime of the device. Moreover, it is
> > no longer necessary to unprepare and disable the clocks explicitly. Also,
> > devm_clk_get_optional() and clk_prepare_enable() can now be replaced by
> > devm_clk_get_optional_enabled(). Moreover, the lable "out_clk" no longer
> > makes sense, rename it to "out_reset".
> >
> > Signed-off-by: Li Zetao <lizetao1@huawei.com>
> > ---
> > v1 -> v2: Return directly instead of calling reset_control_deassert()
> > before the reset control handler has been requested. And use the
> > "out_reset" label instead of "out" before calling pm_runtime_enable().
>
> LGTM. Thanks!
> Acked-by: Serge Semin <fancer.lancer@gmail.com>
Agreed - looks much better now.
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
>
> -Serge(y)
>
> >
> > drivers/spi/spi-dw-mmio.c | 31 +++++++++----------------------
> > 1 file changed, 9 insertions(+), 22 deletions(-)
> >
> > diff --git a/drivers/spi/spi-dw-mmio.c b/drivers/spi/spi-dw-mmio.c
> > index 805264c9c65c..46801189a651 100644
> > --- a/drivers/spi/spi-dw-mmio.c
> > +++ b/drivers/spi/spi-dw-mmio.c
> > @@ -340,29 +340,20 @@ static int dw_spi_mmio_probe(struct platform_device *pdev)
> > if (dws->irq < 0)
> > return dws->irq; /* -ENXIO */
> >
> > - dwsmmio->clk = devm_clk_get(&pdev->dev, NULL);
> > + dwsmmio->clk = devm_clk_get_enabled(&pdev->dev, NULL);
> > if (IS_ERR(dwsmmio->clk))
> > return PTR_ERR(dwsmmio->clk);
> > - ret = clk_prepare_enable(dwsmmio->clk);
> > - if (ret)
> > - return ret;
> >
> > /* Optional clock needed to access the registers */
> > - dwsmmio->pclk = devm_clk_get_optional(&pdev->dev, "pclk");
> > - if (IS_ERR(dwsmmio->pclk)) {
> > - ret = PTR_ERR(dwsmmio->pclk);
> > - goto out_clk;
> > - }
> > - ret = clk_prepare_enable(dwsmmio->pclk);
> > - if (ret)
> > - goto out_clk;
> > + dwsmmio->pclk = devm_clk_get_optional_enabled(&pdev->dev, "pclk");
> > + if (IS_ERR(dwsmmio->pclk))
> > + return PTR_ERR(dwsmmio->pclk);
> >
> > /* find an optional reset controller */
> > dwsmmio->rstc = devm_reset_control_get_optional_exclusive(&pdev->dev, "spi");
> > - if (IS_ERR(dwsmmio->rstc)) {
> > - ret = PTR_ERR(dwsmmio->rstc);
> > - goto out_clk;
> > - }
> > + if (IS_ERR(dwsmmio->rstc))
> > + return PTR_ERR(dwsmmio->rstc);
> > +
> > reset_control_deassert(dwsmmio->rstc);
> >
> > dws->bus_num = pdev->id;
> > @@ -383,7 +374,7 @@ static int dw_spi_mmio_probe(struct platform_device *pdev)
> > if (init_func) {
> > ret = init_func(pdev, dwsmmio);
> > if (ret)
> > - goto out;
> > + goto out_reset;
> > }
> >
> > pm_runtime_enable(&pdev->dev);
> > @@ -397,9 +388,7 @@ static int dw_spi_mmio_probe(struct platform_device *pdev)
> >
> > out:
> > pm_runtime_disable(&pdev->dev);
> > - clk_disable_unprepare(dwsmmio->pclk);
> > -out_clk:
> > - clk_disable_unprepare(dwsmmio->clk);
> > +out_reset:
> > reset_control_assert(dwsmmio->rstc);
> >
> > return ret;
> > @@ -411,8 +400,6 @@ static void dw_spi_mmio_remove(struct platform_device *pdev)
> >
> > dw_spi_remove_host(&dwsmmio->dws);
> > pm_runtime_disable(&pdev->dev);
> > - clk_disable_unprepare(dwsmmio->pclk);
> > - clk_disable_unprepare(dwsmmio->clk);
> > reset_control_assert(dwsmmio->rstc);
> > }
> >
> > --
> > 2.34.1
> >
>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
>
^ permalink raw reply
* Re: [PATCH -next v2 24/25] spi: spl022: Use helper function devm_clk_get_enabled()
From: Jonathan Cameron @ 2023-08-23 17:16 UTC (permalink / raw)
To: Li Zetao, linux-amlogic, linux-arm-kernel, linux-rpi-kernel
Cc: andrew, angelogioacchino.delregno, avifishman70,
bcm-kernel-feedback-list, benjaminfair, broonie, chin-ting_kuo,
clg, conor.dooley, daire.mcnamara, fancer.lancer,
florian.fainelli, heiko, jbrunet, joel, khilman, linus.walleij,
linux-aspeed, linux-mediatek, linux-riscv, linux-rockchip,
linux-spi, martin.blumenstingl, matthias.bgg, neil.armstrong,
olteanv, openbmc, rjui, sbranden, tali.perry1, tmaimon77, venture,
yuenn
In-Reply-To: <20230823133938.1359106-25-lizetao1@huawei.com>
On Wed, 23 Aug 2023 21:39:37 +0800
Li Zetao <lizetao1@huawei.com> wrote:
> Since commit 7ef9651e9792 ("clk: Provide new devm_clk helpers for prepared
> and enabled clocks"), devm_clk_get() and clk_prepare_enable() can now be
> replaced by devm_clk_get_enabled() when driver enables (and possibly
> prepares) the clocks for the whole lifetime of the device. Moreover, it is
> no longer necessary to unprepare and disable the clocks explicitly.
> Moreover, the label "err_no_clk_en" is no used, drop it for clean code.
>
> Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
> Signed-off-by: Li Zetao <lizetao1@huawei.com>
FWIW
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
If you want to follow up with a patch fixing that odd formatting (on it's own)
then that would be great.
Jonathan
> ---
> v1 -> v2: Delete the modification of odd formatting.
>
> drivers/spi/spi-pl022.c | 11 +----------
> 1 file changed, 1 insertion(+), 10 deletions(-)
>
> diff --git a/drivers/spi/spi-pl022.c b/drivers/spi/spi-pl022.c
> index bb347b6bb6f3..d1b6110b38fc 100644
> --- a/drivers/spi/spi-pl022.c
> +++ b/drivers/spi/spi-pl022.c
> @@ -2168,19 +2168,13 @@ static int pl022_probe(struct amba_device *adev, const struct amba_id *id)
> dev_info(&adev->dev, "mapped registers from %pa to %p\n",
> &adev->res.start, pl022->virtbase);
>
> - pl022->clk = devm_clk_get(&adev->dev, NULL);
> + pl022->clk = devm_clk_get_enabled(&adev->dev, NULL);
> if (IS_ERR(pl022->clk)) {
> status = PTR_ERR(pl022->clk);
> dev_err(&adev->dev, "could not retrieve SSP/SPI bus clock\n");
> goto err_no_clk;
> }
>
> - status = clk_prepare_enable(pl022->clk);
> - if (status) {
> - dev_err(&adev->dev, "could not enable SSP/SPI bus clock\n");
> - goto err_no_clk_en;
> - }
> -
> /* Initialize transfer pump */
> tasklet_init(&pl022->pump_transfers, pump_transfers,
> (unsigned long)pl022);
> @@ -2240,8 +2234,6 @@ static int pl022_probe(struct amba_device *adev, const struct amba_id *id)
> if (platform_info->enable_dma)
> pl022_dma_remove(pl022);
> err_no_irq:
> - clk_disable_unprepare(pl022->clk);
> - err_no_clk_en:
> err_no_clk:
> err_no_ioremap:
> amba_release_regions(adev);
> @@ -2268,7 +2260,6 @@ pl022_remove(struct amba_device *adev)
> if (pl022->host_info->enable_dma)
> pl022_dma_remove(pl022);
>
> - clk_disable_unprepare(pl022->clk);
> amba_release_regions(adev);
> tasklet_disable(&pl022->pump_transfers);
> }
^ permalink raw reply
* [PATCH v7 13/24] iommu/omap: Implement an IDENTITY domain
From: Jason Gunthorpe @ 2023-08-23 16:47 UTC (permalink / raw)
To: Andy Gross, Alim Akhtar, Bjorn Andersson,
AngeloGioacchino Del Regno, Baolin Wang, Christophe Leroy,
Gerald Schaefer, Heiko Stuebner, iommu, Jernej Skrabec,
Jonathan Hunter, Joerg Roedel, Kevin Tian, Konrad Dybcio,
Krzysztof Kozlowski, linux-arm-kernel, linux-arm-msm,
linux-mediatek, linux-rockchip, linux-s390, linux-samsung-soc,
linux-sunxi, linux-tegra, Russell King, linuxppc-dev,
Matthias Brugger, Matthew Rosato, Michael Ellerman,
Nicholas Piggin, Orson Zhai, Rob Clark, Robin Murphy,
Samuel Holland, Thierry Reding, Krishna Reddy, Chen-Yu Tsai,
Will Deacon, Yong Wu, Chunyan Zhang
Cc: Lu Baolu, Dmitry Osipenko, Marek Szyprowski, Nicolin Chen,
Niklas Schnelle, Steven Price, Thierry Reding
In-Reply-To: <0-v7-de04a3217c48+15055-iommu_all_defdom_jgg@nvidia.com>
What omap does during omap_iommu_set_platform_dma() is actually putting
the iommu into identity mode.
Move to the new core support for ARM_DMA_USE_IOMMU by defining
ops->identity_domain.
This driver does not support IOMMU_DOMAIN_DMA, however it cannot be
compiled on ARM64 either. Most likely it is fine to support dma-iommu.c
Reviewed-by: Lu Baolu <baolu.lu@linux.intel.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
---
drivers/iommu/omap-iommu.c | 21 ++++++++++++++++++---
1 file changed, 18 insertions(+), 3 deletions(-)
diff --git a/drivers/iommu/omap-iommu.c b/drivers/iommu/omap-iommu.c
index 537e402f9bba97..34340ef15241bc 100644
--- a/drivers/iommu/omap-iommu.c
+++ b/drivers/iommu/omap-iommu.c
@@ -1555,16 +1555,31 @@ static void _omap_iommu_detach_dev(struct omap_iommu_domain *omap_domain,
omap_domain->dev = NULL;
}
-static void omap_iommu_set_platform_dma(struct device *dev)
+static int omap_iommu_identity_attach(struct iommu_domain *identity_domain,
+ struct device *dev)
{
struct iommu_domain *domain = iommu_get_domain_for_dev(dev);
- struct omap_iommu_domain *omap_domain = to_omap_domain(domain);
+ struct omap_iommu_domain *omap_domain;
+ if (domain == identity_domain || !domain)
+ return 0;
+
+ omap_domain = to_omap_domain(domain);
spin_lock(&omap_domain->lock);
_omap_iommu_detach_dev(omap_domain, dev);
spin_unlock(&omap_domain->lock);
+ return 0;
}
+static struct iommu_domain_ops omap_iommu_identity_ops = {
+ .attach_dev = omap_iommu_identity_attach,
+};
+
+static struct iommu_domain omap_iommu_identity_domain = {
+ .type = IOMMU_DOMAIN_IDENTITY,
+ .ops = &omap_iommu_identity_ops,
+};
+
static struct iommu_domain *omap_iommu_domain_alloc(unsigned type)
{
struct omap_iommu_domain *omap_domain;
@@ -1732,11 +1747,11 @@ static struct iommu_group *omap_iommu_device_group(struct device *dev)
}
static const struct iommu_ops omap_iommu_ops = {
+ .identity_domain = &omap_iommu_identity_domain,
.domain_alloc = omap_iommu_domain_alloc,
.probe_device = omap_iommu_probe_device,
.release_device = omap_iommu_release_device,
.device_group = omap_iommu_device_group,
- .set_platform_dma_ops = omap_iommu_set_platform_dma,
.pgsize_bitmap = OMAP_IOMMU_PGSIZES,
.default_domain_ops = &(const struct iommu_domain_ops) {
.attach_dev = omap_iommu_attach_dev,
--
2.41.0
^ permalink raw reply related
* [PATCH v7 00/24] iommu: Make default_domain's mandatory
From: Jason Gunthorpe @ 2023-08-23 16:47 UTC (permalink / raw)
To: Andy Gross, Alim Akhtar, Bjorn Andersson,
AngeloGioacchino Del Regno, Baolin Wang, Christophe Leroy,
Gerald Schaefer, Heiko Stuebner, iommu, Jernej Skrabec,
Jonathan Hunter, Joerg Roedel, Kevin Tian, Konrad Dybcio,
Krzysztof Kozlowski, linux-arm-kernel, linux-arm-msm,
linux-mediatek, linux-rockchip, linux-s390, linux-samsung-soc,
linux-sunxi, linux-tegra, Russell King, linuxppc-dev,
Matthias Brugger, Matthew Rosato, Michael Ellerman,
Nicholas Piggin, Orson Zhai, Rob Clark, Robin Murphy,
Samuel Holland, Thierry Reding, Krishna Reddy, Chen-Yu Tsai,
Will Deacon, Yong Wu, Chunyan Zhang
Cc: Lu Baolu, Dmitry Osipenko, Marek Szyprowski, Nicolin Chen,
Niklas Schnelle, Steven Price, Thierry Reding
It has been a long time coming, this series completes the default_domain
transition and makes it so that the core IOMMU code will always have a
non-NULL default_domain for every driver on every
platform. set_platform_dma_ops() turned out to be a bad idea, and so
completely remove it.
This is achieved by changing each driver to either:
1 - Convert the existing (or deleted) ops->detach_dev() into an
op->attach_dev() of an IDENTITY domain.
This is based on the theory that the ARM32 HW is able to function when
the iommu is turned off and so the turned off state is an IDENTITY
translation.
2 - Use a new PLATFORM domain type. This is a hack to accommodate drivers
that we don't really know WTF they do. S390 is legitimately using this
to switch to it's platform dma_ops implementation, which is where the
name comes from.
3 - Do #1 and force the default domain to be IDENTITY, this corrects
the tegra-smmu case where even an ARM64 system would have a NULL
default_domain.
Using this we can apply the rules:
a) ARM_DMA_USE_IOMMU mode always uses either the driver's
ops->default_domain, ops->def_domain_type(), or an IDENTITY domain.
All ARM32 drivers provide one of these three options.
b) dma-iommu.c mode uses either the driver's ops->default_domain,
ops->def_domain_type or the usual DMA API policy logic based on the
command line/etc to pick IDENTITY/DMA domain types
c) All other arch's (PPC/S390) use ops->default_domain always.
See the patch "Require a default_domain for all iommu drivers" for a
per-driver breakdown.
The conversion broadly teaches a bunch of ARM32 drivers that they can do
IDENTITY domains. There is some educated guessing involved that these are
actual IDENTITY domains. If this turns out to be wrong the driver can be
trivially changed to use a BLOCKING domain type instead. Further, the
domain type only matters for drivers using ARM64's dma-iommu.c mode as it
will select IDENTITY based on the command line and expect IDENTITY to
work. For ARM32 and other arch cases it is purely documentation.
Finally, based on all the analysis in this series, we can purge
IOMMU_DOMAIN_UNMANAGED/DMA constants from most of the drivers. This
greatly simplifies understanding the driver contract to the core
code. IOMMU drivers should not be involved in policy for how the DMA API
works, that should be a core core decision.
The main gain from this work is to remove alot of ARM_DMA_USE_IOMMU
specific code and behaviors from drivers. All that remains in iommu
drivers after this series is the calls to arm_iommu_create_mapping().
This is a step toward removing ARM_DMA_USE_IOMMU.
The IDENTITY domains added to the ARM64 supporting drivers can be tested
by booting in ARM64 mode and enabling CONFIG_IOMMU_DEFAULT_PASSTHROUGH. If
the system still boots then most likely the implementation is an IDENTITY
domain. If not we can trivially change it to BLOCKING or at worst PLATFORM
if there is no detail what is going on in the HW.
I think this is pretty safe for the ARM32 drivers as they don't really
change, the code that was in detach_dev continues to be called in the same
places it was called before.
This is on github: https://github.com/jgunthorpe/linux/commits/iommu_all_defdom
v7:
- Rebase on v6.5-rc6/Joerg's tree/iommufd
- Most of patch "iommufd/selftest: Make the mock iommu driver into a real
driver" is now in the iommufd tree, diffuse the remaining bits to
"iommu: Add iommu_ops->identity_domain" and
"iommu: Add IOMMU_DOMAIN_PLATFORM"
- Move the check for domain->ops->free to patch 1 as the rockchip
conversion relies on it
- Add IOMMU_DOMAIN_PLATFORM to iommu_domain_type_str
- Rewrite "iommu: Reorganize iommu_get_default_domain_type() to respect def_domain_type()"
to be clearer and more robust
- Remove left over .default_domain in tegra-smmu.c
- Use group_iommu_ops() in all appropriate places
- Typo s/paging/dev/ in sun50i
v6: https://lore.kernel.org/r/0-v6-e8114faedade+425-iommu_all_defdom_jgg@nvidia.com
- Rebase on v6.5-rc1/Joerg's tree
- Fix the iommufd self test missing the iommu_device_sysfs_add()
- Update typo in msm commit message
v5: https://lore.kernel.org/r/0-v5-d0a204c678c7+3d16a-iommu_all_defdom_jgg@nvidia.com
- Rebase on v6.5-rc1/Joerg's tree
- Fix Dan's remark about 'gdev uninitialized' in patch 9
v4: https://lore.kernel.org/r/0-v4-874277bde66e+1a9f6-iommu_all_defdom_jgg@nvidia.com
- Fix rebasing typo missing ops->alloc_domain_paging check
- Rebase on latest Joerg tree
v3: https://lore.kernel.org/r/0-v3-89830a6c7841+43d-iommu_all_defdom_jgg@nvidia.com
- FSL is back to a PLATFORM domain, with some fixing so it attach only
does something when leaving an UNMANAGED domain like it always was
- Rebase on Joerg's tree, adjust for "alloc_type" change
- Change the ARM32 untrusted check to a WARN_ON since no ARM32 system
can currently set trusted
v2: https://lore.kernel.org/r/0-v2-8d1dc464eac9+10f-iommu_all_defdom_jgg@nvidia.com
- FSL is an IDENTITY domain
- Delete terga-gart instead of trying to carry it
- Use the policy determination from iommu_get_default_domain_type() to
drive the arm_iommu mode
- Reorganize and introduce new patches to do the above:
* Split the ops->identity_domain to an independent earlier patch
* Remove the UNMANAGED return from def_domain_type in mtk_v1 earlier
so the new iommu_get_default_domain_type() can work
* Make the driver's def_domain_type have higher policy priority than
untrusted
* Merge the set_platfom_dma_ops hunk from mtk_v1 along with rockchip
into the patch that forced IDENTITY on ARM32
- Revise sun50i to be cleaner and have a non-NULL internal domain
- Reword logging in exynos
- Remove the gdev from the group alloc path, instead add a new
function __iommu_group_domain_alloc() that takes in the group
and uses the first device. Split this to its own patch
- New patch to make iommufd's mock selftest into a real driver
- New patch to fix power's partial iommu driver
v1: https://lore.kernel.org/r/0-v1-21cc72fcfb22+a7a-iommu_all_defdom_jgg@nvidia.com
Jason Gunthorpe (24):
iommu: Add iommu_ops->identity_domain
iommu: Add IOMMU_DOMAIN_PLATFORM
powerpc/iommu: Setup a default domain and remove set_platform_dma_ops
iommu: Add IOMMU_DOMAIN_PLATFORM for S390
iommu/fsl_pamu: Implement a PLATFORM domain
iommu/tegra-gart: Remove tegra-gart
iommu/mtk_iommu_v1: Implement an IDENTITY domain
iommu: Reorganize iommu_get_default_domain_type() to respect
def_domain_type()
iommu: Allow an IDENTITY domain as the default_domain in ARM32
iommu/exynos: Implement an IDENTITY domain
iommu/tegra-smmu: Implement an IDENTITY domain
iommu/tegra-smmu: Support DMA domains in tegra
iommu/omap: Implement an IDENTITY domain
iommu/msm: Implement an IDENTITY domain
iommu: Remove ops->set_platform_dma_ops()
iommu/qcom_iommu: Add an IOMMU_IDENTITIY_DOMAIN
iommu/ipmmu: Add an IOMMU_IDENTITIY_DOMAIN
iommu/mtk_iommu: Add an IOMMU_IDENTITIY_DOMAIN
iommu/sun50i: Add an IOMMU_IDENTITIY_DOMAIN
iommu: Require a default_domain for all iommu drivers
iommu: Add __iommu_group_domain_alloc()
iommu: Add ops->domain_alloc_paging()
iommu: Convert simple drivers with DOMAIN_DMA to domain_alloc_paging()
iommu: Convert remaining simple drivers to domain_alloc_paging()
arch/arm/configs/multi_v7_defconfig | 1 -
arch/arm/configs/tegra_defconfig | 1 -
arch/powerpc/kernel/iommu.c | 38 ++-
drivers/iommu/Kconfig | 11 -
drivers/iommu/Makefile | 1 -
drivers/iommu/arm/arm-smmu/qcom_iommu.c | 45 ++-
drivers/iommu/exynos-iommu.c | 73 +++--
drivers/iommu/fsl_pamu_domain.c | 41 ++-
drivers/iommu/iommu.c | 259 ++++++++++-------
drivers/iommu/iommufd/selftest.c | 19 +-
drivers/iommu/ipmmu-vmsa.c | 50 +++-
drivers/iommu/msm_iommu.c | 30 +-
drivers/iommu/mtk_iommu.c | 30 +-
drivers/iommu/mtk_iommu_v1.c | 28 +-
drivers/iommu/omap-iommu.c | 28 +-
drivers/iommu/rockchip-iommu.c | 26 +-
drivers/iommu/s390-iommu.c | 28 +-
drivers/iommu/sprd-iommu.c | 7 +-
drivers/iommu/sun50i-iommu.c | 35 ++-
drivers/iommu/tegra-gart.c | 371 ------------------------
drivers/iommu/tegra-smmu.c | 44 ++-
drivers/memory/tegra/mc.c | 34 ---
drivers/memory/tegra/tegra20.c | 28 --
include/linux/iommu.h | 16 +-
include/soc/tegra/mc.h | 26 --
25 files changed, 514 insertions(+), 756 deletions(-)
delete mode 100644 drivers/iommu/tegra-gart.c
base-commit: dec980836cf9cc517a56b59ca88e5f3423b7f68b
--
2.41.0
^ permalink raw reply
* Re: [PATCH v2] genpd: Explicitly include correct DT includes
From: Jernej Škrabec @ 2023-08-23 19:11 UTC (permalink / raw)
To: Ulf Hansson, Matthias Brugger, AngeloGioacchino Del Regno,
Chen-Yu Tsai, Samuel Holland, Rob Herring
Cc: linux-pm, linux-kernel, linux-arm-kernel, linux-mediatek,
linux-sunxi
In-Reply-To: <20230823170438.2489746-1-robh@kernel.org>
Dne sreda, 23. avgust 2023 ob 19:04:37 CEST je Rob Herring napisal(a):
> The DT of_device.h and of_platform.h date back to the separate
> of_platform_bus_type before it was merged into the regular platform bus.
> As part of that merge prepping Arm DT support 13 years ago, they
> "temporarily" include each other. They also include platform_device.h
> and of.h. As a result, there's a pretty much random mix of those include
> files used throughout the tree. In order to detangle these headers and
> replace the implicit includes with struct declarations, users need to
> explicitly include the correct includes.
>
> Signed-off-by: Rob Herring <robh@kernel.org>
> ---
> v2: Previously sent for drivers/soc/. Gathered up files which got moved
> to genpd to new patch.
> ---
> drivers/genpd/mediatek/mtk-pm-domains.c | 2 +-
> drivers/genpd/mediatek/mtk-scpsys.c | 2 +-
> drivers/genpd/sunxi/sun20i-ppu.c | 2 +-
for sun20i-ppu:
Acked-by: Jernej Skrabec <jernej.skrabec@gmail.com>
Best regards,
Jernej
^ permalink raw reply
* Re: [PATCH net-next v3 0/4] net: ethernet: mtk_eth_soc: improve support for MT7988
From: patchwork-bot+netdevbpf @ 2023-08-24 2:30 UTC (permalink / raw)
To: Daniel Golle
Cc: nbd, john, sean.wang, Mark-MC.Lee, lorenzo, davem, edumazet, kuba,
pabeni, matthias.bgg, angelogioacchino.delregno, netdev,
linux-kernel, linux-arm-kernel, linux-mediatek
In-Reply-To: <cover.1692721443.git.daniel@makrotopia.org>
Hello:
This series was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Tue, 22 Aug 2023 17:30:56 +0100 you wrote:
> This series fixes and completes commit 445eb6448ed3b ("net: ethernet:
> mtk_eth_soc: add basic support for MT7988 SoC") and also adds support
> for using the in-SoC SRAM to previous MT7986 and MT7981 SoCs.
>
> Changes since v2:
> * fold changes to commit they were supposed to go into
>
> [...]
Here is the summary with links:
- [net-next,v3,1/4] net: ethernet: mtk_eth_soc: fix register definitions for MT7988
https://git.kernel.org/netdev/net-next/c/cfb5677de5ba
- [net-next,v3,2/4] net: ethernet: mtk_eth_soc: add reset bits for MT7988
https://git.kernel.org/netdev/net-next/c/88c1e6efb7a5
- [net-next,v3,3/4] net: ethernet: mtk_eth_soc: add support for in-SoC SRAM
https://git.kernel.org/netdev/net-next/c/ebb1e4f9cf38
- [net-next,v3,4/4] net: ethernet: mtk_eth_soc: support 36-bit DMA addressing on MT7988
https://git.kernel.org/netdev/net-next/c/2d75891ebc09
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply
* Re: [PATCH 11/15] drm/mediatek: Support CRC in VDOSYS0
From: CK Hu (胡俊光) @ 2023-08-24 2:29 UTC (permalink / raw)
To: chunkuang.hu@kernel.org, Shawn Sung (宋孝謙),
daniel@ffwll.ch, p.zabel@pengutronix.de, airlied@gmail.com,
matthias.bgg@gmail.com, jassisinghbrar@gmail.com,
angelogioacchino.delregno@collabora.com
Cc: linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, linux-mediatek@lists.infradead.org,
Jason-JH Lin (林睿祥),
Nancy Lin (林欣螢),
Singo Chang (張興國),
Project_Global_Chrome_Upstream_Group
In-Reply-To: <20230823151332.28811-12-shawn.sung@mediatek.com>
Hi, Hsiao Chien:
On Wed, 2023-08-23 at 23:13 +0800, Hsiao Chien Sung wrote:
> We choose OVL as CRC generator from other hardware
> components that are also capable of calculating CRCs,
> since its frame done event triggers vblanks, it can be
> used as a signal to know when is safe to retrieve CRC of
> the frame.
>
> Please note that position of the hardware component
> that is chosen as CRC generator in the display path is
> significant. For example, while OVL is the first module
> in VDOSYS0, its CRC won't be affected by the modules
> after it, which means effects applied by PQ, Gamma,
> Dither or any other components after OVL won't be
> calculated in CRC generation.
>
> Signed-off-by: Hsiao Chien Sung <shawn.sung@mediatek.com>
> ---
> drivers/gpu/drm/mediatek/mtk_disp_drv.h | 1 +
> drivers/gpu/drm/mediatek/mtk_disp_ovl.c | 121
> +++++++++++++++++++-
> drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c | 1 +
> 3 files changed, 119 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/drm/mediatek/mtk_disp_drv.h
> b/drivers/gpu/drm/mediatek/mtk_disp_drv.h
> index 2254038519e1..d2753360ae1e 100644
> --- a/drivers/gpu/drm/mediatek/mtk_disp_drv.h
> +++ b/drivers/gpu/drm/mediatek/mtk_disp_drv.h
> @@ -100,6 +100,7 @@ void mtk_ovl_enable_vblank(struct device *dev);
> void mtk_ovl_disable_vblank(struct device *dev);
> const u32 *mtk_ovl_get_formats(struct device *dev);
> size_t mtk_ovl_get_num_formats(struct device *dev);
> +u32 mtk_ovl_crc_cnt(struct device *dev);
>
> void mtk_ovl_adaptor_add_comp(struct device *dev, struct mtk_mutex
> *mutex);
> void mtk_ovl_adaptor_remove_comp(struct device *dev, struct
> mtk_mutex *mutex);
> diff --git a/drivers/gpu/drm/mediatek/mtk_disp_ovl.c
> b/drivers/gpu/drm/mediatek/mtk_disp_ovl.c
> index 824f81291293..453db2de3e83 100644
> --- a/drivers/gpu/drm/mediatek/mtk_disp_ovl.c
> +++ b/drivers/gpu/drm/mediatek/mtk_disp_ovl.c
> @@ -25,6 +25,13 @@
> #define OVL_FME_CPL_INT BIT(1)
> #define DISP_REG_OVL_INTSTA 0x0008
> #define DISP_REG_OVL_EN 0x000c
> +#define OVL_EN BIT(0)
> +#define OVL_OP_8BIT_MODE BIT(4)
> +#define OVL_HG_FOVL_CK_ON BIT(8)
> +#define OVL_HF_FOVL_CK_ON BIT(10)
> +#define DISP_REG_OVL_TRIG 0x0010
> +#define OVL_CRC_EN BIT(8)
> +#define OVL_CRC_CLR BIT(9)
> #define DISP_REG_OVL_RST 0x0014
> #define DISP_REG_OVL_ROI_SIZE 0x0020
> #define DISP_REG_OVL_DATAPATH_CON 0x0024
> @@ -44,6 +51,8 @@
> #define DISP_REG_OVL_RDMA_CTRL(n) (0x00c0 + 0x20 * (n))
> #define DISP_REG_OVL_RDMA_GMC(n) (0x00c8 + 0x20 * (n))
> #define DISP_REG_OVL_ADDR_MT2701 0x0040
> +#define DISP_REG_OVL_CRC 0x0270
> +#define OVL_CRC_OUT_MASK GENMASK(30, 0)
> #define DISP_REG_OVL_CLRFMT_EXT 0x02D0
> #define DISP_REG_OVL_CLRFMT_EXT1 0x02D8
> #define OVL_CLRFMT_EXT1_CSC_EN(n) (1 << ((n) * 4
> + 1))
> @@ -151,6 +160,10 @@ static const u32 mt8195_formats[] = {
> DRM_FORMAT_YUYV,
> };
>
> +static const u32 mt8195_ovl_crcs[] = {
> + DISP_REG_OVL_CRC,
> +};
> +
> struct mtk_disp_ovl_data {
> unsigned int addr;
> unsigned int gmc_bits;
> @@ -161,6 +174,8 @@ struct mtk_disp_ovl_data {
> const u32 *formats;
> size_t num_formats;
> bool supports_clrfmt_ext;
> + const u32 *crcs;
> + size_t crc_cnt;
> };
>
> /*
> @@ -176,8 +191,82 @@ struct mtk_disp_ovl {
> const struct mtk_disp_ovl_data *data;
> void (*vblank_cb)(void *data);
> void *vblank_cb_data;
> + struct cmdq_client *cmdq_client;
> + struct cmdq_pkt *cmdq_pkt;
> + u32 cmdq_event;
> };
>
> +u32 mtk_ovl_crc_cnt(struct device *dev)
> +{
> + struct mtk_disp_ovl *ovl = dev_get_drvdata(dev);
> +
> + return (u32)ovl->data->crc_cnt;
> +}
> +
> +static void mtk_ovl_crc_loop_start(struct device *dev)
> +{
> + int i;
> + struct mtk_disp_ovl *ovl = dev_get_drvdata(dev);
> + struct mtk_drm_crtc *mtk_crtc = container_of(ovl->crtc,
> + struct mtk_drm_crtc,
> base);
> +
> + if (!ovl->cmdq_event || ovl->cmdq_client)
> + return;
> +
> + ovl->cmdq_client = cmdq_mbox_create(dev, 0);
> + if (IS_ERR(ovl->cmdq_client)) {
> + pr_err("failed to create mailbox client\n");
> + return;
> + }
> +
> + ovl->cmdq_pkt = cmdq_pkt_create(ovl->cmdq_client, PAGE_SIZE);
> + if (!ovl->cmdq_pkt) {
> + pr_err("failed to create cmdq packet\n");
> + return;
> + }
> +
> + cmdq_pkt_wfe(ovl->cmdq_pkt, ovl->cmdq_event, true);
> +
> + for (i = 0; i < ovl->data->crc_cnt; i++) {
> + /* put crc to spr1 register */
> + cmdq_pkt_read_s(ovl->cmdq_pkt, ovl->cmdq_reg.subsys,
> + ovl->data->crcs[i], CMDQ_THR_SPR_IDX1);
Read CRC by CPU in ovl irq handler instead of using cmdq, so things
would be simpler.
Regards,
CK
> + cmdq_pkt_assign(ovl->cmdq_pkt, CMDQ_THR_SPR_IDX0,
> + CMDQ_ADDR_HIGH(mtk_crtc->crc.pa + i *
> sizeof(u32)));
> +
> + /* copy spr1 register to crc.pa */
> + cmdq_pkt_write_s(ovl->cmdq_pkt, CMDQ_THR_SPR_IDX0,
> + CMDQ_ADDR_LOW(mtk_crtc->crc.pa + i *
> sizeof(u32)),
> + CMDQ_THR_SPR_IDX1);
> + }
> +
> + /* reset crc */
> + mtk_ddp_write_mask(ovl->cmdq_pkt, ~0, &ovl->cmdq_reg, ovl-
> >regs,
> + DISP_REG_OVL_TRIG, OVL_CRC_CLR);
> + /* clear reset bit */
> + mtk_ddp_write_mask(ovl->cmdq_pkt, 0, &ovl->cmdq_reg, ovl->regs,
> + DISP_REG_OVL_TRIG, OVL_CRC_CLR);
> +
> + cmdq_pkt_finalize_loop(ovl->cmdq_pkt);
> + cmdq_pkt_flush_async(ovl->cmdq_pkt);
> +}
> +
> +static void mtk_ovl_crc_loop_stop(struct device *dev)
> +{
> + struct mtk_disp_ovl *ovl = dev_get_drvdata(dev);
> +
> + if (ovl->cmdq_pkt) {
> + cmdq_pkt_destroy(ovl->cmdq_pkt);
> + ovl->cmdq_pkt = NULL;
> + }
> +
> + if (ovl->cmdq_client) {
> + mbox_flush(ovl->cmdq_client->chan, 2000);
> + cmdq_mbox_destroy(ovl->cmdq_client);
> + ovl->cmdq_client = NULL;
> + }
> +}
> +
> static irqreturn_t mtk_disp_ovl_irq_handler(int irq, void *dev_id)
> {
> struct mtk_disp_ovl *priv = dev_id;
> @@ -201,6 +290,7 @@ void mtk_ovl_register_vblank_cb(struct device
> *dev,
>
> ovl->vblank_cb = vblank_cb;
> ovl->vblank_cb_data = vblank_cb_data;
> + ovl->crtc = (struct drm_crtc *)vblank_cb_data;
> }
>
> void mtk_ovl_unregister_vblank_cb(struct device *dev)
> @@ -216,14 +306,14 @@ void mtk_ovl_enable_vblank(struct device *dev)
> struct mtk_disp_ovl *ovl = dev_get_drvdata(dev);
>
> writel(0x0, ovl->regs + DISP_REG_OVL_INTSTA);
> - writel_relaxed(OVL_FME_CPL_INT, ovl->regs +
> DISP_REG_OVL_INTEN);
> + writel(OVL_FME_CPL_INT, ovl->regs + DISP_REG_OVL_INTEN);
> }
>
> void mtk_ovl_disable_vblank(struct device *dev)
> {
> struct mtk_disp_ovl *ovl = dev_get_drvdata(dev);
>
> - writel_relaxed(0x0, ovl->regs + DISP_REG_OVL_INTEN);
> + writel(0x0, ovl->regs + DISP_REG_OVL_INTEN);
> }
>
> const u32 *mtk_ovl_get_formats(struct device *dev)
> @@ -258,6 +348,7 @@ void mtk_ovl_start(struct device *dev)
> {
> struct mtk_disp_ovl *ovl = dev_get_drvdata(dev);
> unsigned int reg = 0;
> + unsigned int val = OVL_EN;
>
> if (ovl->data->smi_id_en) {
> reg = readl(ovl->regs + DISP_REG_OVL_DATAPATH_CON);
> @@ -265,13 +356,22 @@ void mtk_ovl_start(struct device *dev)
> }
> reg |= OVL_OUTPUT_CLAMP;
> writel_relaxed(reg, ovl->regs + DISP_REG_OVL_DATAPATH_CON);
> - writel_relaxed(0x1, ovl->regs + DISP_REG_OVL_EN);
> +
> + if (ovl->data->crcs)
> + val |= OVL_OP_8BIT_MODE | OVL_HG_FOVL_CK_ON |
> OVL_HF_FOVL_CK_ON;
> +
> + writel_relaxed(val, ovl->regs + DISP_REG_OVL_EN);
> + writel_relaxed(OVL_CRC_EN, ovl->regs + DISP_REG_OVL_TRIG);
> +
> + mtk_ovl_crc_loop_start(dev);
> }
>
> void mtk_ovl_stop(struct device *dev)
> {
> struct mtk_disp_ovl *ovl = dev_get_drvdata(dev);
>
> + mtk_ovl_crc_loop_stop(dev);
> +
> writel_relaxed(0x0, ovl->regs + DISP_REG_OVL_EN);
> if (ovl->data->smi_id_en) {
> unsigned int reg;
> @@ -321,7 +421,8 @@ void mtk_ovl_config(struct device *dev, unsigned
> int w,
> if (w != 0 && h != 0)
> mtk_ddp_write_relaxed(cmdq_pkt, h << 16 | w, &ovl-
> >cmdq_reg, ovl->regs,
> DISP_REG_OVL_ROI_SIZE);
> - mtk_ddp_write_relaxed(cmdq_pkt, 0x0, &ovl->cmdq_reg, ovl->regs,
> DISP_REG_OVL_ROI_BGCLR);
> + mtk_ddp_write_relaxed(cmdq_pkt, 0xff000000, &ovl->cmdq_reg,
> ovl->regs,
> + DISP_REG_OVL_ROI_BGCLR);
>
> mtk_ddp_write(cmdq_pkt, 0x1, &ovl->cmdq_reg, ovl->regs,
> DISP_REG_OVL_RST);
> mtk_ddp_write(cmdq_pkt, 0x0, &ovl->cmdq_reg, ovl->regs,
> DISP_REG_OVL_RST);
> @@ -677,6 +778,16 @@ static int mtk_disp_ovl_probe(struct
> platform_device *pdev)
> #endif
>
> priv->data = of_device_get_match_data(dev);
> +
> + if (priv->data->crcs) {
> + if (of_property_read_u32_index(dev->of_node,
> + "mediatek,gce-events",
> 0,
> + &priv->cmdq_event)) {
> + dev_err(dev, "failed to get gce-events\n");
> + return -ENOPARAM;
> + }
> + }
> +
> platform_set_drvdata(pdev, priv);
>
> ret = devm_request_irq(dev, irq, mtk_disp_ovl_irq_handler,
> @@ -771,6 +882,8 @@ static const struct mtk_disp_ovl_data
> mt8195_ovl_driver_data = {
> .formats = mt8195_formats,
> .num_formats = ARRAY_SIZE(mt8195_formats),
> .supports_clrfmt_ext = true,
> + .crcs = mt8195_ovl_crcs,
> + .crc_cnt = ARRAY_SIZE(mt8195_ovl_crcs),
> };
>
> static const struct of_device_id mtk_disp_ovl_driver_dt_match[] = {
> diff --git a/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c
> b/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c
> index f114da4d36a9..1b747a34a06b 100644
> --- a/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c
> +++ b/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c
> @@ -347,6 +347,7 @@ static const struct mtk_ddp_comp_funcs ddp_ovl =
> {
> .clk_enable = mtk_ovl_clk_enable,
> .clk_disable = mtk_ovl_clk_disable,
> .config = mtk_ovl_config,
> + .crc_cnt = mtk_ovl_crc_cnt,
> .start = mtk_ovl_start,
> .stop = mtk_ovl_stop,
> .register_vblank_cb = mtk_ovl_register_vblank_cb,
^ permalink raw reply
* Re: [PATCH v7 01/24] iommu: Add iommu_ops->identity_domain
From: Jerry Snitselaar @ 2023-08-24 3:41 UTC (permalink / raw)
To: Jason Gunthorpe
Cc: Andy Gross, Alim Akhtar, Bjorn Andersson,
AngeloGioacchino Del Regno, Baolin Wang, Christophe Leroy,
Gerald Schaefer, Heiko Stuebner, iommu, Jernej Skrabec,
Jonathan Hunter, Joerg Roedel, Kevin Tian, Konrad Dybcio,
Krzysztof Kozlowski, linux-arm-kernel, linux-arm-msm,
linux-mediatek, linux-rockchip, linux-s390, linux-samsung-soc,
linux-sunxi, linux-tegra, Russell King, linuxppc-dev,
Matthias Brugger, Matthew Rosato, Michael Ellerman,
Nicholas Piggin, Orson Zhai, Rob Clark, Robin Murphy,
Samuel Holland, Thierry Reding, Krishna Reddy, Chen-Yu Tsai,
Will Deacon, Yong Wu, Chunyan Zhang, Lu Baolu, Dmitry Osipenko,
Marek Szyprowski, Nicolin Chen, Niklas Schnelle, Steven Price,
Thierry Reding
In-Reply-To: <1-v7-de04a3217c48+15055-iommu_all_defdom_jgg@nvidia.com>
On Wed, Aug 23, 2023 at 01:47:15PM -0300, Jason Gunthorpe wrote:
> 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>
> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
Reviewed-by: Jerry Snitselaar <jsnitsel@redhat.com>
^ permalink raw reply
* Re: [RESEND PATCH v2] media: mtk-jpeg: Fix use after free bug due to uncanceled work
From: Zheng Hacker @ 2023-08-24 8:20 UTC (permalink / raw)
To: Dmitry Osipenko
Cc: Zheng Wang, Kyrie.Wu, bin.liu, mchehab, matthias.bgg,
angelogioacchino.delregno, linux-media, linux-kernel,
linux-arm-kernel, linux-mediatek, Irui.Wang, security,
1395428693sheep, alex000young, Collabora Kernel ML
In-Reply-To: <8c8bd3ec-a5a4-32e4-45b5-ee16eeeac246@collabora.com>
Dmitry Osipenko <dmitry.osipenko@collabora.com> 于2023年8月23日周三 02:51写道:
>
> Hello Zheng,
>
> On 7/7/23 12:24, Zheng Wang wrote:
> > In mtk_jpeg_probe, &jpeg->job_timeout_work is bound with
> > mtk_jpeg_job_timeout_work. Then mtk_jpeg_dec_device_run
> > and mtk_jpeg_enc_device_run may be called to start the
> > work.
> > If we remove the module which will call mtk_jpeg_remove
> > to make cleanup, there may be a unfinished work. The
> > possible sequence is as follows, which will cause a
> > typical UAF bug.
> >
> > Fix it by canceling the work before cleanup in the mtk_jpeg_remove
> >
> > CPU0 CPU1
> >
> > |mtk_jpeg_job_timeout_work
> > mtk_jpeg_remove |
> > v4l2_m2m_release |
> > kfree(m2m_dev); |
> > |
> > | v4l2_m2m_get_curr_priv
> > | m2m_dev->curr_ctx //use
> > Fixes: b2f0d2724ba4 ("[media] vcodec: mediatek: Add Mediatek JPEG Decoder Driver")
> > Signed-off-by: Zheng Wang <zyytlz.wz@163.com>
> > ---
> > - v2: use cancel_delayed_work_sync instead of cancel_delayed_work suggested by Kyrie.
> > ---
> > drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c | 1 +
> > 1 file changed, 1 insertion(+)
> >
> > diff --git a/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c b/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c
> > index 0051f372a66c..6069ecf420b0 100644
> > --- a/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c
> > +++ b/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c
> > @@ -1816,6 +1816,7 @@ static void mtk_jpeg_remove(struct platform_device *pdev)
> > {
> > struct mtk_jpeg_dev *jpeg = platform_get_drvdata(pdev);
> >
> > + cancel_delayed_work_sync(&jpeg->job_timeout_work);
> > pm_runtime_disable(&pdev->dev);
> > video_unregister_device(jpeg->vdev);
> > v4l2_m2m_release(jpeg->m2m_dev);
>
> AFAICS, there is a fundamental problem here. The job_timeout_work uses
> v4l2_m2m_get_curr_priv() and at the time when driver module is unloaded,
> all the v4l contexts must be closed and released. Hence the
> v4l2_m2m_get_curr_priv() shall return NULL and crash the kernel when
> work is executed before cancel_delayed_work_sync().
>
Hi Dmitry,
Thanks for your reply. I think you're right. As m2m_dev is freed in
v4l2_m2m_release,
the invoking in v4l2_m2m_get_curr_priv might cause either UAF or null
pointer dereference
bug. I am sure that context is closed when we invoke mtk_jpeg_remove.
But I'm not sure if
context is released when mtk_jpegdec_timeout_work running.
> At the time when mtk_jpeg_remove() is invoked, there shall be no
> job_timeout_work running in background because all jobs should be
> completed before context is released. If you'll look at
> v4l2_m2m_cancel_job(), you can see that it waits for the task completion
> before closing context.
Yes, so I think the better way is to put the cancel_delayed_work_sync
invoking into
v4l2_m2m_ctx_release function?
>
> You shouldn't be able to remove driver module while it has active/opened
> v4l contexts. If you can do that, then this is yours bug that needs to
> be fixed.
>
> In addition to this all, the job_timeout_work is initialized only for
> the single-core JPEG device. I'd expect this patch should crash
> multi-core JPEG devices.
>
I think that's true. As I'm not familiar with the code here. Could you
please give me some advice about the patch?
Best regards,
Zheng
> --
> Best regards,
> Dmitry
>
^ permalink raw reply
* Re: [PATCH -next 03/25] spi: aspeed: Use helper function devm_clk_get_enabled()
From: Cédric Le Goater @ 2023-08-24 8:55 UTC (permalink / raw)
To: Li Zetao, broonie, chin-ting_kuo, joel, andrew, florian.fainelli,
rjui, sbranden, bcm-kernel-feedback-list, fancer.lancer, olteanv,
neil.armstrong, khilman, jbrunet, martin.blumenstingl,
conor.dooley, daire.mcnamara, matthias.bgg,
angelogioacchino.delregno, avifishman70, tmaimon77, tali.perry1,
venture, yuenn, benjaminfair, linus.walleij, heiko
Cc: linux-spi, linux-aspeed, openbmc, linux-arm-kernel,
linux-rpi-kernel, linux-amlogic, linux-riscv, linux-mediatek,
linux-rockchip
In-Reply-To: <20230822131237.1022815-4-lizetao1@huawei.com>
On 8/22/23 15:12, Li Zetao wrote:
> Since commit 7ef9651e9792 ("clk: Provide new devm_clk helpers for prepared
> and enabled clocks"), devm_clk_get() and clk_prepare_enable() can now be
> replaced by devm_clk_get_enabled() when driver enables (and possibly
> prepares) the clocks for the whole lifetime of the device. Moreover, it is
> no longer necessary to unprepare and disable the clocks explicitly.
>
> Signed-off-by: Li Zetao <lizetao1@huawei.com>
Reviewed-by: Cédric Le Goater <clg@kaod.org>
Thanks,
C.
^ permalink raw reply
* Re: [PATCH v2] genpd: Explicitly include correct DT includes
From: Ulf Hansson @ 2023-08-24 9:11 UTC (permalink / raw)
To: Rob Herring
Cc: Matthias Brugger, AngeloGioacchino Del Regno, Chen-Yu Tsai,
Jernej Skrabec, Samuel Holland, linux-pm, linux-kernel,
linux-arm-kernel, linux-mediatek, linux-sunxi
In-Reply-To: <20230823170438.2489746-1-robh@kernel.org>
On Wed, 23 Aug 2023 at 19:05, Rob Herring <robh@kernel.org> wrote:
>
> The DT of_device.h and of_platform.h date back to the separate
> of_platform_bus_type before it was merged into the regular platform bus.
> As part of that merge prepping Arm DT support 13 years ago, they
> "temporarily" include each other. They also include platform_device.h
> and of.h. As a result, there's a pretty much random mix of those include
> files used throughout the tree. In order to detangle these headers and
> replace the implicit includes with struct declarations, users need to
> explicitly include the correct includes.
>
> Signed-off-by: Rob Herring <robh@kernel.org>
Applied for next, thanks!
Kind regards
Uffe
> ---
> v2: Previously sent for drivers/soc/. Gathered up files which got moved
> to genpd to new patch.
> ---
> drivers/genpd/mediatek/mtk-pm-domains.c | 2 +-
> drivers/genpd/mediatek/mtk-scpsys.c | 2 +-
> drivers/genpd/sunxi/sun20i-ppu.c | 2 +-
> 3 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/genpd/mediatek/mtk-pm-domains.c b/drivers/genpd/mediatek/mtk-pm-domains.c
> index 354249cc1b12..ee962804b830 100644
> --- a/drivers/genpd/mediatek/mtk-pm-domains.c
> +++ b/drivers/genpd/mediatek/mtk-pm-domains.c
> @@ -8,8 +8,8 @@
> #include <linux/io.h>
> #include <linux/iopoll.h>
> #include <linux/mfd/syscon.h>
> +#include <linux/of.h>
> #include <linux/of_clk.h>
> -#include <linux/of_device.h>
> #include <linux/platform_device.h>
> #include <linux/pm_domain.h>
> #include <linux/regmap.h>
> diff --git a/drivers/genpd/mediatek/mtk-scpsys.c b/drivers/genpd/mediatek/mtk-scpsys.c
> index 7a668888111c..b374d01fdac7 100644
> --- a/drivers/genpd/mediatek/mtk-scpsys.c
> +++ b/drivers/genpd/mediatek/mtk-scpsys.c
> @@ -7,7 +7,7 @@
> #include <linux/io.h>
> #include <linux/iopoll.h>
> #include <linux/mfd/syscon.h>
> -#include <linux/of_device.h>
> +#include <linux/of.h>
> #include <linux/platform_device.h>
> #include <linux/pm_domain.h>
> #include <linux/regulator/consumer.h>
> diff --git a/drivers/genpd/sunxi/sun20i-ppu.c b/drivers/genpd/sunxi/sun20i-ppu.c
> index 98cb41d36560..8700f9dd5f75 100644
> --- a/drivers/genpd/sunxi/sun20i-ppu.c
> +++ b/drivers/genpd/sunxi/sun20i-ppu.c
> @@ -5,7 +5,7 @@
> #include <linux/io.h>
> #include <linux/iopoll.h>
> #include <linux/module.h>
> -#include <linux/of_device.h>
> +#include <linux/of.h>
> #include <linux/platform_device.h>
> #include <linux/pm_domain.h>
> #include <linux/reset.h>
> --
> 2.40.1
>
^ permalink raw reply
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox