Message ID | 1386835033-4701-4-git-send-email-hdoyu@nvidia.com |
---|---|
State | Superseded, archived |
Headers | show |
On 12/12/2013 12:57 AM, Hiroshi Doyu wrote: > IOMMU devices on the bus need to be poplulated first, then iommu > master devices are done later. > > With CONFIG_OF_IOMMU, "iommus=" DT binding would be used to identify > whether a device can be an iommu msater or not. If a device can, we'll > defer to populate that device till an depending iommu device is > populated. > diff --git a/drivers/iommu/of_iommu.c b/drivers/iommu/of_iommu.c > +int of_iommu_attach(struct device *dev) > +{ > + const __be32 *cur, *end; > + struct of_phandle_args args; > + > + of_property_for_each_phandle_with_args(dev->of_node, "iommus", > + "#iommu-cells", 0, args, cur, end) { > + if (!of_find_iommu_by_node(args.np)) > + return -EPROBE_DEFER; I think that since of_find_iommu_by_node() should be calling iommu_get(iommu), the error-case here should loop over the IOMMUs that have successfully been acquired, and call iommu_put(). You'd also want to implement of_iommu_detach() or iommu_detach() to undo the iommu_get()s that happen within this function. -- To unsubscribe from this list: send the line "unsubscribe linux-tegra" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/drivers/iommu/of_iommu.c b/drivers/iommu/of_iommu.c index 5d1aeb9..557c0c8 100644 --- a/drivers/iommu/of_iommu.c +++ b/drivers/iommu/of_iommu.c @@ -125,3 +125,17 @@ int of_get_dma_window(struct device_node *dn, const char *prefix, int index, return 0; } EXPORT_SYMBOL_GPL(of_get_dma_window); + +int of_iommu_attach(struct device *dev) +{ + const __be32 *cur, *end; + struct of_phandle_args args; + + of_property_for_each_phandle_with_args(dev->of_node, "iommus", + "#iommu-cells", 0, args, cur, end) { + if (!of_find_iommu_by_node(args.np)) + return -EPROBE_DEFER; + } + + return 0; +} diff --git a/include/linux/of_iommu.h b/include/linux/of_iommu.h index a0aa9d4..14c9a5c 100644 --- a/include/linux/of_iommu.h +++ b/include/linux/of_iommu.h @@ -14,6 +14,7 @@ extern int of_get_dma_window(struct device_node *dn, const char *prefix, extern void iommu_add(struct iommu *iommu); extern void iommu_del(struct iommu *iommu); +extern int of_iommu_attach(struct device *dev); #else @@ -32,6 +33,11 @@ static inline void iommu_del(struct iommu *iommu) { } +static inline int of_iommu_attach(struct device *dev) +{ + return 0; +} + #endif /* CONFIG_OF_IOMMU */ #endif /* __OF_IOMMU_H */