Access dev->iommu_fwspec through functions
Subsystems (9)
Joerg Roedel
maintainerv2 cover Access dev->iommu_fwspec through functions
Hi,
here is the second patch-set to wrap accesses to dev->iommu_fwspec into functions so that the pointer location can be changed more easily later on.
This version is rebased to v4.20-rc6 and addresses Robin's comments. The Ack from will is also added.
If there are no objections I'd like to queue these patches soon.
Regards,
Joerg
Joerg Roedel (9):
iommu: Introduce wrappers around dev->iommu_fwspec ACPI/IORT: Use helper functions to access dev->iommu_fwspec iommu/arm-smmu: Use helper functions to access dev->iommu_fwspec iommu/dma: Use helper functions to access dev->iommu_fwspec iommu/ipmmu-vmsa: Use helper functions to access dev->iommu_fwspec iommu/mediatek: Use helper functions to access dev->iommu_fwspec iommu/of: Use helper functions to access dev->iommu_fwspec iommu/qcom: Use helper functions to access dev->iommu_fwspec iommu/tegra: Use helper functions to access dev->iommu_fwspec
drivers/acpi/arm64/iort.c | 19 ++++++++++--------- drivers/iommu/arm-smmu-v3.c | 16 +++++++++------- drivers/iommu/arm-smmu.c | 12 ++++++------ drivers/iommu/dma-iommu.c | 2 +- drivers/iommu/iommu.c | 14 +++++++------- drivers/iommu/ipmmu-vmsa.c | 12 ++++++++---- drivers/iommu/mtk_iommu.c | 21 ++++++++++++--------- drivers/iommu/mtk_iommu_v1.c | 28 ++++++++++++++++------------ drivers/iommu/of_iommu.c | 10 +++++++--- drivers/iommu/qcom_iommu.c | 18 ++++++++++-------- drivers/iommu/tegra-smmu.c | 2 +- include/linux/iommu.h | 11 +++++++++++ 12 files changed, 98 insertions(+), 67 deletions(-)
Signature · 1 line
2.17.1
Joerg Roedel
maintainerPATCH v2 1/9 iommu: Introduce wrappers around dev->iommu_fwspec
From: Joerg Roedel <[email protected]>
These wrappers will be used to easily change the location of the field later when all users are converted.
--- drivers/iommu/iommu.c | 14 +++++++------- include/linux/iommu.h | 11 +++++++++++ 2 files changed, 18 insertions(+), 7 deletions(-)
drivers/iommu/iommu.c +7 -7
@@ -1976,7 +1976,7 @@ const struct iommu_ops *iommu_ops_from_fwnode(struct fwnode_handle *fwnode)int iommu_fwspec_init (struct device *dev,struct fwnode_handle *iommu_fwnode,const struct iommu_ops *ops) { -struct iommu_fwspec *fwspec = dev->iommu_fwspec; +struct iommu_fwspec *fwspec =dev_iommu_fwspec_get (dev);if (fwspec)return ops == fwspec->ops ?0 : -EINVAL ;
@@ -1988,26 +1988,26 @@ int iommu_fwspec_init(struct device *dev, struct fwnode_handle *iommu_fwnode,of_node_get (to_of_node (iommu_fwnode)); fwspec->iommu_fwnode = iommu_fwnode; fwspec->ops = ops; - dev->iommu_fwspec = fwspec; +dev_iommu_fwspec_set (dev, fwspec);return 0 ; }EXPORT_SYMBOL_GPL (iommu_fwspec_init);void iommu_fwspec_free (struct device *dev) { -struct iommu_fwspec *fwspec = dev->iommu_fwspec; +struct iommu_fwspec *fwspec =dev_iommu_fwspec_get (dev);if (fwspec) {fwnode_handle_put (fwspec->iommu_fwnode);kfree (fwspec); - dev->iommu_fwspec =NULL ; +dev_iommu_fwspec_set (dev,NULL ); } }EXPORT_SYMBOL_GPL (iommu_fwspec_free);int iommu_fwspec_add_ids (struct device *dev,u32 *ids,int num_ids) { -struct iommu_fwspec *fwspec = dev->iommu_fwspec; +struct iommu_fwspec *fwspec =dev_iommu_fwspec_get (dev);size_t size;int i;
@@ -2016,11 +2016,11 @@ int iommu_fwspec_add_ids(struct device *dev, u32 *ids, int num_ids) size = offsetof(struct iommu_fwspec, ids[fwspec->num_ids + num_ids]);if (size >sizeof (*fwspec)) { - fwspec =krealloc (dev->iommu_fwspec, size,GFP_KERNEL ); + fwspec =krealloc (fwspec, size,GFP_KERNEL );if (!fwspec)return -ENOMEM ; - dev->iommu_fwspec = fwspec; +dev_iommu_fwspec_set (dev, fwspec); }for (i =0 ; i < num_ids; i++)
include/linux/iommu.h +11 -0
@@ -398,6 +398,17 @@ void iommu_fwspec_free(struct device *dev);int iommu_fwspec_add_ids (struct device *dev,u32 *ids,int num_ids);const struct iommu_ops *iommu_ops_from_fwnode (struct fwnode_handle *fwnode); +static inline struct iommu_fwspec *dev_iommu_fwspec_get (struct device *dev) +{ +return dev->iommu_fwspec; +} + +static inline void dev_iommu_fwspec_set (struct device *dev, +struct iommu_fwspec *fwspec) +{ + dev->iommu_fwspec = fwspec; +} +#else /* CONFIG_IOMMU_API */ struct iommu_ops {};
Signature · 1 line
2.17.1
Joerg Roedel
maintainerPATCH v2 2/9 ACPI/IORT: Use helper functions to access dev->iommu_fwspec
In reply to Joerg RoedelFrom: Joerg Roedel <[email protected]>
Use the new helpers dev_iommu_fwspec_get()/set() to access the dev->iommu_fwspec pointer. This makes it easier to move that pointer later into another struct.
--- drivers/acpi/arm64/iort.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-)
drivers/acpi/arm64/iort.c +10 -9
@@ -779,7 +779,7 @@ static inline bool iort_iommu_driver_enabled(u8 type)static struct acpi_iort_node *iort_get_msi_resv_iommu (struct device *dev) {struct acpi_iort_node *iommu; -struct iommu_fwspec *fwspec = dev->iommu_fwspec; +struct iommu_fwspec *fwspec =dev_iommu_fwspec_get (dev); iommu =iort_get_iort_node (fwspec->iommu_fwnode);
@@ -794,9 +794,10 @@ static struct acpi_iort_node *iort_get_msi_resv_iommu(struct device *dev)return NULL ; } -static inline const struct iommu_ops *iort_fwspec_iommu_ops ( -struct iommu_fwspec *fwspec) +static inline const struct iommu_ops *iort_fwspec_iommu_ops (struct device *dev) { +struct iommu_fwspec *fwspec =dev_iommu_fwspec_get (dev); +return (fwspec && fwspec->ops) ? fwspec->ops :NULL ; }
@@ -824,6 +825,7 @@ static inline int iort_add_device_replay(const struct iommu_ops *ops,*/ int iort_iommu_msi_get_resv_regions (struct device *dev,struct list_head *head) { +struct iommu_fwspec *fwspec =dev_iommu_fwspec_get (dev);struct acpi_iort_its_group *its;struct acpi_iort_node *iommu_node, *its_node =NULL ;int i, resv =0 ;
@@ -841,9 +843,9 @@ int iort_iommu_msi_get_resv_regions(struct device *dev, struct list_head *head)* a given PCI or named component may map IDs to. */ -for (i =0 ; i < dev->iommu_fwspec->num_ids; i++) { +for (i =0 ; i < fwspec->num_ids; i++) { its_node =iort_node_map_id (iommu_node, - dev->iommu_fwspec->ids[i], + fwspec->ids[i],NULL ,IORT_MSI_TYPE );if (its_node)break ;
@@ -874,8 +876,7 @@ int iort_iommu_msi_get_resv_regions(struct device *dev, struct list_head *head) return (resv == its->its_count) ? resv : -ENODEV; }#else -static inline const struct iommu_ops *iort_fwspec_iommu_ops ( -struct iommu_fwspec *fwspec) +static inline const struct iommu_ops *iort_fwspec_iommu_ops (struct device *dev); {return NULL ; }static inline int iort_add_device_replay (const struct iommu_ops *ops,struct device *dev)
@@ -1045,7 +1046,7 @@ const struct iommu_ops *iort_iommu_configure(struct device *dev)* If we already translated the fwspec there * is nothing left to do, return the iommu_ops. */ - ops =iort_fwspec_iommu_ops (dev->iommu_fwspec); + ops =iort_fwspec_iommu_ops (dev);if (ops)return ops;
@@ -1084,7 +1085,7 @@ const struct iommu_ops *iort_iommu_configure(struct device *dev)* add_device callback for dev, replay it to get things in order. */ if (!err) { - ops =iort_fwspec_iommu_ops (dev->iommu_fwspec); + ops =iort_fwspec_iommu_ops (dev); err =iort_add_device_replay (ops, dev); }
Signature · 1 line
2.17.1
Re: [PATCH 2/9] ACPI/IORT: Use helper functions to access dev->iommu_fwspec
Quoted 11 lines · Joerg Roedel
From: Joerg Roedel <[email protected]>
Use the new helpers dev_iommu_fwspec_get()/set() to access the
dev->iommu_fwspecpointer. This makes it easier to move that pointer later into another struct.Cc Lorenzo Pieralisi <[email protected]>Signed-off-by Joerg Roedel <[email protected]>--- drivers/acpi/arm64/iort.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-)
Thanks
Hanjun
Joerg Roedel
maintainerPATCH v2 3/9 iommu/arm-smmu: Use helper functions to access dev->iommu_fwspec
In reply to Joerg RoedelFrom: Joerg Roedel <[email protected]>
Use the new helpers dev_iommu_fwspec_get()/set() to access the dev->iommu_fwspec pointer. This makes it easier to move that pointer later into another struct.
--- drivers/iommu/arm-smmu-v3.c | 16 +++++++++------- drivers/iommu/arm-smmu.c | 12 ++++++------ 2 files changed, 15 insertions(+), 13 deletions(-)
drivers/iommu/arm-smmu-v3.c +9 -7
@@ -1691,24 +1691,26 @@ static void arm_smmu_install_ste_for_dev(struct iommu_fwspec *fwspec)static void arm_smmu_detach_dev (struct device *dev) { -struct arm_smmu_master_data *master = dev->iommu_fwspec->iommu_priv; +struct iommu_fwspec *fwspec =dev_iommu_fwspec_get (dev); +struct arm_smmu_master_data *master = fwspec->iommu_priv; master->ste.assigned = false; -arm_smmu_install_ste_for_dev (dev->iommu_fwspec); +arm_smmu_install_ste_for_dev (fwspec); }static int arm_smmu_attach_dev (struct iommu_domain *domain,struct device *dev) {int ret =0 ; +struct iommu_fwspec *fwspec =dev_iommu_fwspec_get (dev);struct arm_smmu_device *smmu;struct arm_smmu_domain *smmu_domain =to_smmu_domain (domain);struct arm_smmu_master_data *master;struct arm_smmu_strtab_ent *ste; -if (!dev->iommu_fwspec) +if (!fwspec)return -ENOENT ; - master = dev->iommu_fwspec->iommu_priv; + master = fwspec->iommu_priv; smmu = master->smmu; ste = &master->ste;
@@ -1748,7 +1750,7 @@ static int arm_smmu_attach_dev(struct iommu_domain *domain, struct device *dev) ste->s2_cfg = &smmu_domain->s2_cfg; } -arm_smmu_install_ste_for_dev (dev->iommu_fwspec); +arm_smmu_install_ste_for_dev (fwspec); out_unlock:mutex_unlock (&smmu_domain->init_mutex);return ret;
@@ -1839,7 +1841,7 @@ static int arm_smmu_add_device(struct device *dev)int i, ret;struct arm_smmu_device *smmu;struct arm_smmu_master_data *master; -struct iommu_fwspec *fwspec = dev->iommu_fwspec; +struct iommu_fwspec *fwspec =dev_iommu_fwspec_get (dev);struct iommu_group *group;if (!fwspec || fwspec->ops != &arm_smmu_ops)
@@ -1890,7 +1892,7 @@ static int arm_smmu_add_device(struct device *dev)static void arm_smmu_remove_device (struct device *dev) { -struct iommu_fwspec *fwspec = dev->iommu_fwspec; +struct iommu_fwspec *fwspec =dev_iommu_fwspec_get (dev);struct arm_smmu_master_data *master;struct arm_smmu_device *smmu;
drivers/iommu/arm-smmu.c +6 -6
@@ -1103,7 +1103,7 @@ static bool arm_smmu_free_sme(struct arm_smmu_device *smmu, int idx)static int arm_smmu_master_alloc_smes (struct device *dev) { -struct iommu_fwspec *fwspec = dev->iommu_fwspec; +struct iommu_fwspec *fwspec =dev_iommu_fwspec_get (dev);struct arm_smmu_master_cfg *cfg = fwspec->iommu_priv;struct arm_smmu_device *smmu = cfg->smmu;struct arm_smmu_smr *smrs = smmu->smrs;
@@ -1206,7 +1206,7 @@ static int arm_smmu_domain_add_master(struct arm_smmu_domain *smmu_domain,static int arm_smmu_attach_dev (struct iommu_domain *domain,struct device *dev) {int ret; -struct iommu_fwspec *fwspec = dev->iommu_fwspec; +struct iommu_fwspec *fwspec =dev_iommu_fwspec_get (dev);struct arm_smmu_device *smmu;struct arm_smmu_domain *smmu_domain =to_smmu_domain (domain);
@@ -1380,7 +1380,7 @@ static int arm_smmu_add_device(struct device *dev) {struct arm_smmu_device *smmu;struct arm_smmu_master_cfg *cfg; -struct iommu_fwspec *fwspec = dev->iommu_fwspec; +struct iommu_fwspec *fwspec =dev_iommu_fwspec_get (dev);int i, ret;if (using_legacy_binding) {
@@ -1391,7 +1391,7 @@ static int arm_smmu_add_device(struct device *dev)* will allocate/initialise a new one. Thus we need to update fwspec for * later use. */ - fwspec = dev->iommu_fwspec; + fwspec =dev_iommu_fwspec_get (dev);if (ret) goto out_free; }else if (fwspec && fwspec->ops == &arm_smmu_ops) {
@@ -1445,7 +1445,7 @@ static int arm_smmu_add_device(struct device *dev)static void arm_smmu_remove_device (struct device *dev) { -struct iommu_fwspec *fwspec = dev->iommu_fwspec; +struct iommu_fwspec *fwspec =dev_iommu_fwspec_get (dev);struct arm_smmu_master_cfg *cfg;struct arm_smmu_device *smmu;
@@ -1465,7 +1465,7 @@ static void arm_smmu_remove_device(struct device *dev)static struct iommu_group *arm_smmu_device_group (struct device *dev) { -struct iommu_fwspec *fwspec = dev->iommu_fwspec; +struct iommu_fwspec *fwspec =dev_iommu_fwspec_get (dev);struct arm_smmu_device *smmu =fwspec_smmu (fwspec);struct iommu_group *group =NULL ;int i, idx;
Signature · 1 line
2.17.1
Joerg Roedel
maintainerPATCH v2 4/9 iommu/dma: Use helper functions to access dev->iommu_fwspec
In reply to Joerg RoedelFrom: Joerg Roedel <[email protected]>
Use the new helpers dev_iommu_fwspec_get()/set() to access the dev->iommu_fwspec pointer. This makes it easier to move that pointer later into another struct.
--- drivers/iommu/dma-iommu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iommu/dma-iommu.c +1 -1
@@ -177,7 +177,7 @@ EXPORT_SYMBOL(iommu_put_dma_cookie);void iommu_dma_get_resv_regions (struct device *dev,struct list_head *list) { -if (!is_of_node (dev->iommu_fwspec->iommu_fwnode)) +if (!is_of_node (dev_iommu_fwspec_get (dev)->iommu_fwnode))iort_iommu_msi_get_resv_regions (dev, list); }
Signature · 1 line
2.17.1
Joerg Roedel
maintainerPATCH v2 5/9 iommu/ipmmu-vmsa: Use helper functions to access dev->iommu_fwspec
In reply to Joerg RoedelFrom: Joerg Roedel <[email protected]>
Use the new helpers dev_iommu_fwspec_get()/set() to access the dev->iommu_fwspec pointer. This makes it easier to move that pointer later into another struct.
--- drivers/iommu/ipmmu-vmsa.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
drivers/iommu/ipmmu-vmsa.c +8 -4
@@ -81,7 +81,9 @@ static struct ipmmu_vmsa_domain *to_vmsa_domain(struct iommu_domain *dom)static struct ipmmu_vmsa_device *to_ipmmu (struct device *dev) { -return dev->iommu_fwspec ? dev->iommu_fwspec->iommu_priv :NULL ; +struct iommu_fwspec *fwspec =dev_iommu_fwspec_get (dev); + +return fwspec ? fwspec->iommu_priv :NULL ; }#define TLB_LOOP_TIMEOUT 100/* 100us */
@@ -643,7 +645,7 @@ static void ipmmu_domain_free(struct iommu_domain *io_domain)static int ipmmu_attach_device (struct iommu_domain *io_domain,struct device *dev) { -struct iommu_fwspec *fwspec = dev->iommu_fwspec; +struct iommu_fwspec *fwspec =dev_iommu_fwspec_get (dev);struct ipmmu_vmsa_device *mmu =to_ipmmu (dev);struct ipmmu_vmsa_domain *domain =to_vmsa_domain (io_domain);unsigned int i;
@@ -692,7 +694,7 @@ static int ipmmu_attach_device(struct iommu_domain *io_domain,static void ipmmu_detach_device (struct iommu_domain *io_domain,struct device *dev) { -struct iommu_fwspec *fwspec = dev->iommu_fwspec; +struct iommu_fwspec *fwspec =dev_iommu_fwspec_get (dev);struct ipmmu_vmsa_domain *domain =to_vmsa_domain (io_domain);unsigned int i;
@@ -744,13 +746,15 @@ static phys_addr_t ipmmu_iova_to_phys(struct iommu_domain *io_domain,static int ipmmu_init_platform_device (struct device *dev,struct of_phandle_args *args) { +struct iommu_fwspec *fwspec =dev_iommu_fwspec_get (dev);struct platform_device *ipmmu_pdev; ipmmu_pdev =of_find_device_by_node (args->np);if (!ipmmu_pdev)return -ENODEV ; - dev->iommu_fwspec->iommu_priv =platform_get_drvdata (ipmmu_pdev); + fwspec->iommu_priv =platform_get_drvdata (ipmmu_pdev); +return 0 ; }
Signature · 1 line
2.17.1
Joerg Roedel
maintainerPATCH v2 6/9 iommu/mediatek: Use helper functions to access dev->iommu_fwspec
In reply to Joerg RoedelFrom: Joerg Roedel <[email protected]>
Use the new helpers dev_iommu_fwspec_get()/set() to access the dev->iommu_fwspec pointer. This makes it easier to move that pointer later into another struct.
--- drivers/iommu/mtk_iommu.c | 21 ++++++++++++--------- drivers/iommu/mtk_iommu_v1.c | 28 ++++++++++++++++------------ 2 files changed, 28 insertions(+), 21 deletions(-)
drivers/iommu/mtk_iommu.c +12 -9
@@ -244,7 +244,7 @@ static void mtk_iommu_config(struct mtk_iommu_data *data, {struct mtk_smi_larb_iommu *larb_mmu;unsigned int larbid, portid; -struct iommu_fwspec *fwspec = dev->iommu_fwspec; +struct iommu_fwspec *fwspec =dev_iommu_fwspec_get (dev);int i;for (i =0 ; i < fwspec->num_ids; ++i) {
@@ -336,7 +336,7 @@ static int mtk_iommu_attach_device(struct iommu_domain *domain, struct device *dev) {struct mtk_iommu_domain *dom =to_mtk_domain (domain); -struct mtk_iommu_data *data = dev->iommu_fwspec->iommu_priv; +struct mtk_iommu_data *data =dev_iommu_fwspec_get (dev)->iommu_priv;if (!data)return -ENODEV ;
@@ -355,7 +355,7 @@ static int mtk_iommu_attach_device(struct iommu_domain *domain,static void mtk_iommu_detach_device (struct iommu_domain *domain,struct device *dev) { -struct mtk_iommu_data *data = dev->iommu_fwspec->iommu_priv; +struct mtk_iommu_data *data =dev_iommu_fwspec_get (dev)->iommu_priv;if (!data)return ;
@@ -417,13 +417,14 @@ static phys_addr_t mtk_iommu_iova_to_phys(struct iommu_domain *domain,static int mtk_iommu_add_device (struct device *dev) { +struct iommu_fwspec *fwspec =dev_iommu_fwspec_get (dev);struct mtk_iommu_data *data;struct iommu_group *group; -if (!dev->iommu_fwspec || dev->iommu_fwspec->ops != &mtk_iommu_ops) +if (!fwspec || fwspec->ops != &mtk_iommu_ops)return -ENODEV ;/* Not a iommu client device */ - data = dev->iommu_fwspec->iommu_priv; + data = fwspec->iommu_priv;iommu_device_link (&data->iommu, dev); group =iommu_group_get_for_dev (dev);
@@ -436,12 +437,13 @@ static int mtk_iommu_add_device(struct device *dev)static void mtk_iommu_remove_device (struct device *dev) { +struct iommu_fwspec *fwspec =dev_iommu_fwspec_get (dev);struct mtk_iommu_data *data; -if (!dev->iommu_fwspec || dev->iommu_fwspec->ops != &mtk_iommu_ops) +if (!fwspec || fwspec->ops != &mtk_iommu_ops)return ; - data = dev->iommu_fwspec->iommu_priv; + data = fwspec->iommu_priv;iommu_device_unlink (&data->iommu, dev);iommu_group_remove_device (dev);
@@ -468,6 +470,7 @@ static struct iommu_group *mtk_iommu_device_group(struct device *dev)static int mtk_iommu_of_xlate (struct device *dev,struct of_phandle_args *args) { +struct iommu_fwspec *fwspec =dev_iommu_fwspec_get (dev);struct platform_device *m4updev;if (args->args_count !=1 ) {
@@ -476,13 +479,13 @@ static int mtk_iommu_of_xlate(struct device *dev, struct of_phandle_args *args)return -EINVAL ; } -if (!dev->iommu_fwspec->iommu_priv) { +if (!fwspec->iommu_priv) {/* Get the m4u device */ m4updev =of_find_device_by_node (args->np);if (WARN_ON (!m4updev))return -EINVAL ; - dev->iommu_fwspec->iommu_priv =platform_get_drvdata (m4updev); + fwspec->iommu_priv =platform_get_drvdata (m4updev); }return iommu_fwspec_add_ids (dev, args->args,1 );
drivers/iommu/mtk_iommu_v1.c +16 -12
@@ -206,7 +206,7 @@ static void mtk_iommu_config(struct mtk_iommu_data *data, {struct mtk_smi_larb_iommu *larb_mmu;unsigned int larbid, portid; -struct iommu_fwspec *fwspec = dev->iommu_fwspec; +struct iommu_fwspec *fwspec =dev_iommu_fwspec_get (dev);int i;for (i =0 ; i < fwspec->num_ids; ++i) {
@@ -271,7 +271,7 @@ static int mtk_iommu_attach_device(struct iommu_domain *domain, struct device *dev) {struct mtk_iommu_domain *dom =to_mtk_domain (domain); -struct mtk_iommu_data *data = dev->iommu_fwspec->iommu_priv; +struct mtk_iommu_data *data =dev_iommu_fwspec_get (dev)->iommu_priv;int ret;if (!data)
@@ -293,7 +293,7 @@ static int mtk_iommu_attach_device(struct iommu_domain *domain,static void mtk_iommu_detach_device (struct iommu_domain *domain,struct device *dev) { -struct mtk_iommu_data *data = dev->iommu_fwspec->iommu_priv; +struct mtk_iommu_data *data =dev_iommu_fwspec_get (dev)->iommu_priv;if (!data)return ;
@@ -371,6 +371,7 @@ static struct iommu_ops mtk_iommu_ops;static int mtk_iommu_create_mapping (struct device *dev,struct of_phandle_args *args) { +struct iommu_fwspec *fwspec =dev_iommu_fwspec_get (dev);struct mtk_iommu_data *data;struct platform_device *m4updev;struct dma_iommu_mapping *mtk_mapping;
@@ -383,28 +384,29 @@ static int mtk_iommu_create_mapping(struct device *dev,return -EINVAL ; } -if (!dev->iommu_fwspec) { +if (!fwspec) { ret =iommu_fwspec_init (dev, &args->np->fwnode, &mtk_iommu_ops);if (ret)return ret; - }else if (dev->iommu_fwspec->ops != &mtk_iommu_ops) { + fwspec =dev_iommu_fwspec_get (dev); + }else if (dev_iommu_fwspec_get (dev)->ops != &mtk_iommu_ops) {return -EINVAL ; } -if (!dev->iommu_fwspec->iommu_priv) { +if (!fwspec->iommu_priv) {/* Get the m4u device */ m4updev =of_find_device_by_node (args->np);if (WARN_ON (!m4updev))return -EINVAL ; - dev->iommu_fwspec->iommu_priv =platform_get_drvdata (m4updev); + fwspec->iommu_priv =platform_get_drvdata (m4updev); } ret =iommu_fwspec_add_ids (dev, args->args,1 );if (ret)return ret; - data = dev->iommu_fwspec->iommu_priv; + data = fwspec->iommu_priv; m4udev = data->dev; mtk_mapping = m4udev->archdata.iommu;if (!mtk_mapping) {
@@ -422,6 +424,7 @@ static int mtk_iommu_create_mapping(struct device *dev,static int mtk_iommu_add_device (struct device *dev) { +struct iommu_fwspec *fwspec =dev_iommu_fwspec_get (dev);struct dma_iommu_mapping *mtk_mapping;struct of_phandle_args iommu_spec;struct of_phandle_iterator it;
@@ -440,7 +443,7 @@ static int mtk_iommu_add_device(struct device *dev)of_node_put (iommu_spec.np); } -if (!dev->iommu_fwspec || dev->iommu_fwspec->ops != &mtk_iommu_ops) +if (!fwspec || fwspec->ops != &mtk_iommu_ops)return -ENODEV ;/* Not a iommu client device */ /*
@@ -458,7 +461,7 @@ static int mtk_iommu_add_device(struct device *dev)if (err)return err; - data = dev->iommu_fwspec->iommu_priv; + data = fwspec->iommu_priv; mtk_mapping = data->dev->archdata.iommu; err =arm_iommu_attach_device (dev, mtk_mapping);if (err) {
@@ -471,12 +474,13 @@ static int mtk_iommu_add_device(struct device *dev)static void mtk_iommu_remove_device (struct device *dev) { +struct iommu_fwspec *fwspec =dev_iommu_fwspec_get (dev);struct mtk_iommu_data *data; -if (!dev->iommu_fwspec || dev->iommu_fwspec->ops != &mtk_iommu_ops) +if (!fwspec || fwspec->ops != &mtk_iommu_ops)return ; - data = dev->iommu_fwspec->iommu_priv; + data = fwspec->iommu_priv;iommu_device_unlink (&data->iommu, dev);iommu_group_remove_device (dev);
Signature · 1 line
2.17.1
Re: [PATCH 6/9] iommu/mediatek: Use helper functions to access dev->iommu_fwspec
Quoted 6 lines · Joerg Roedel
From: Joerg Roedel <[email protected]>
Use the new helpers dev_iommu_fwspec_get()/set() to access the
dev->iommu_fwspecpointer. This makes it easier to move that pointer later into another struct.
Quoted 6 lines
Cc Matthias Brugger <[email protected]>Signed-off-by Joerg Roedel <[email protected]>--- drivers/iommu/mtk_iommu.c | 21 ++++++++++++--------- drivers/iommu/mtk_iommu_v1.c | 28 ++++++++++++++++------------ 2 files changed, 28 insertions(+), 21 deletions(-)
Joerg Roedel
maintainerPATCH v2 7/9 iommu/of: Use helper functions to access dev->iommu_fwspec
In reply to Joerg RoedelFrom: Joerg Roedel <[email protected]>
Use the new helpers dev_iommu_fwspec_get()/set() to access the dev->iommu_fwspec pointer. This makes it easier to move that pointer later into another struct.
--- drivers/iommu/of_iommu.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/iommu/of_iommu.c +7 -3
@@ -164,7 +164,7 @@ const struct iommu_ops *of_iommu_configure(struct device *dev, struct device_node *master_np) {const struct iommu_ops *ops =NULL ; -struct iommu_fwspec *fwspec = dev->iommu_fwspec; +struct iommu_fwspec *fwspec =dev_iommu_fwspec_get (dev);int err =NO_IOMMU ;if (!master_np)
@@ -208,14 +208,18 @@ const struct iommu_ops *of_iommu_configure(struct device *dev, } } +/* * Two success conditions can be represented by non-negative err here: * >0 : there is no IOMMU, or one was unavailable for non-fatal reasons * 0 : we found an IOMMU, and dev->fwspec is initialised appropriately * <0 : any actual error */ -if (!err) - ops = dev->iommu_fwspec->ops; +if (!err) { +/* The fwspec pointer changed, read it again */ + fwspec =dev_iommu_fwspec_get (dev); + ops = fwspec->ops; + }/* * If we have reason to believe the IOMMU driver missed the initial * add_device callback for dev, replay it to get things in order.
Signature · 1 line
2.17.1
Joerg Roedel
maintainerPATCH v2 8/9 iommu/qcom: Use helper functions to access dev->iommu_fwspec
In reply to Joerg RoedelFrom: Joerg Roedel <[email protected]>
Use the new helpers dev_iommu_fwspec_get()/set() to access the dev->iommu_fwspec pointer. This makes it easier to move that pointer later into another struct.
--- drivers/iommu/qcom_iommu.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-)
drivers/iommu/qcom_iommu.c +10 -8
@@ -354,7 +354,8 @@ static void qcom_iommu_domain_free(struct iommu_domain *domain)static int qcom_iommu_attach_dev (struct iommu_domain *domain,struct device *dev) { -struct qcom_iommu_dev *qcom_iommu =to_iommu (dev->iommu_fwspec); +struct iommu_fwspec *fwspec =dev_iommu_fwspec_get (dev); +struct qcom_iommu_dev *qcom_iommu =to_iommu (fwspec);struct qcom_iommu_domain *qcom_domain =to_qcom_iommu_domain (domain);int ret;
@@ -365,7 +366,7 @@ static int qcom_iommu_attach_dev(struct iommu_domain *domain, struct device *dev/* Ensure that the domain is finalized */ pm_runtime_get_sync (qcom_iommu->dev); - ret =qcom_iommu_init_domain (domain, qcom_iommu, dev->iommu_fwspec); + ret =qcom_iommu_init_domain (domain, qcom_iommu, fwspec);pm_runtime_put_sync (qcom_iommu->dev);if (ret <0 )return ret;
@@ -387,7 +388,7 @@ static int qcom_iommu_attach_dev(struct iommu_domain *domain, struct device *devstatic void qcom_iommu_detach_dev (struct iommu_domain *domain,struct device *dev) { -struct iommu_fwspec *fwspec = dev->iommu_fwspec; +struct iommu_fwspec *fwspec =dev_iommu_fwspec_get (dev);struct qcom_iommu_dev *qcom_iommu =to_iommu (fwspec);struct qcom_iommu_domain *qcom_domain =to_qcom_iommu_domain (domain);unsigned i;
@@ -500,7 +501,7 @@ static bool qcom_iommu_capable(enum iommu_cap cap)static int qcom_iommu_add_device (struct device *dev) { -struct qcom_iommu_dev *qcom_iommu =to_iommu (dev->iommu_fwspec); +struct qcom_iommu_dev *qcom_iommu =to_iommu (dev_iommu_fwspec_get (dev));struct iommu_group *group;struct device_link *link;
@@ -531,7 +532,7 @@ static int qcom_iommu_add_device(struct device *dev)static void qcom_iommu_remove_device (struct device *dev) { -struct qcom_iommu_dev *qcom_iommu =to_iommu (dev->iommu_fwspec); +struct qcom_iommu_dev *qcom_iommu =to_iommu (dev_iommu_fwspec_get (dev));if (!qcom_iommu)return ;
@@ -543,6 +544,7 @@ static void qcom_iommu_remove_device(struct device *dev)static int qcom_iommu_of_xlate (struct device *dev,struct of_phandle_args *args) { +struct iommu_fwspec *fwspec =dev_iommu_fwspec_get (dev);struct qcom_iommu_dev *qcom_iommu;struct platform_device *iommu_pdev;unsigned asid = args->args[0 ];
@@ -568,14 +570,14 @@ static int qcom_iommu_of_xlate(struct device *dev, struct of_phandle_args *args) WARN_ON(asid > qcom_iommu->num_ctxs))return -EINVAL ; -if (!dev->iommu_fwspec->iommu_priv) { - dev->iommu_fwspec->iommu_priv = qcom_iommu; +if (!fwspec->iommu_priv) { + fwspec->iommu_priv = qcom_iommu; }else {/* make sure devices iommus dt node isn't referring to * multiple different iommu devices. Multiple context * banks are ok, but multiple devices are not: */ -if (WARN_ON (qcom_iommu != dev->iommu_fwspec->iommu_priv)) +if (WARN_ON (qcom_iommu != fwspec->iommu_priv))return -EINVAL ; }
Signature · 1 line
2.17.1
Joerg Roedel
maintainerPATCH v2 9/9 iommu/tegra: Use helper functions to access dev->iommu_fwspec
In reply to Joerg RoedelFrom: Joerg Roedel <[email protected]>
Use the new helpers dev_iommu_fwspec_get()/set() to access the dev->iommu_fwspec pointer. This makes it easier to move that pointer later into another struct.
--- drivers/iommu/tegra-smmu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iommu/tegra-smmu.c +1 -1
@@ -846,7 +846,7 @@ static struct iommu_group *tegra_smmu_group_get(struct tegra_smmu *smmu,static struct iommu_group *tegra_smmu_device_group (struct device *dev) { -struct iommu_fwspec *fwspec = dev->iommu_fwspec; +struct iommu_fwspec *fwspec =dev_iommu_fwspec_get (dev);struct tegra_smmu *smmu = dev->archdata.iommu;struct iommu_group *group;
Signature · 1 line
2.17.1
Re: [PATCH 9/9] iommu/tegra: Use helper functions to access dev->iommu_fwspec
Quoted 11 lines · Joerg Roedel
From: Joerg Roedel <[email protected]>
Use the new helpers dev_iommu_fwspec_get()/set() to access the
dev->iommu_fwspecpointer. This makes it easier to move that pointer later into another struct.Cc Thierry Reding <[email protected]>Signed-off-by Joerg Roedel <[email protected]>--- drivers/iommu/tegra-smmu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)