iommu/rockchip: add iommu force reset interface for device

Signed-off-by: Chandler Chen <chandler.chen@rock-chips.com>
Change-Id: I153b91b2e1ad8e099d80f4af8c9e51d12f3af607
This commit is contained in:
Chandler Chen 2023-04-03 10:08:06 +08:00
parent b6cc751bbb
commit c4bd8d465a
2 changed files with 27 additions and 0 deletions

View File

@ -1214,6 +1214,28 @@ bool rockchip_iommu_is_enabled(struct device *dev)
}
EXPORT_SYMBOL(rockchip_iommu_is_enabled);
int rockchip_iommu_force_reset(struct device *dev)
{
struct rk_iommu *iommu;
int ret;
iommu = rk_iommu_from_dev(dev);
if (!iommu)
return -ENODEV;
ret = rk_iommu_enable_stall(iommu);
if (ret)
return ret;
ret = rk_iommu_force_reset(iommu);
rk_iommu_disable_stall(iommu);
return ret;
}
EXPORT_SYMBOL(rockchip_iommu_force_reset);
static void rk_iommu_detach_device(struct iommu_domain *domain,
struct device *dev)
{

View File

@ -15,6 +15,7 @@ void __iomem *rockchip_get_iommu_base(struct device *master_dev, int idx);
bool rockchip_iommu_is_enabled(struct device *dev);
void rockchip_iommu_mask_irq(struct device *dev);
void rockchip_iommu_unmask_irq(struct device *dev);
int rockchip_iommu_force_reset(struct device *dev);
#else
static inline int rockchip_iommu_enable(struct device *dev)
{
@ -42,6 +43,10 @@ static inline void rockchip_iommu_mask_irq(struct device *dev)
static inline void rockchip_iommu_unmask_irq(struct device *dev)
{
}
static inline int rockchip_iommu_force_reset(struct device *dev)
{
return -ENODEV;
}
#endif
#endif