Skip to content

Commit 046d5df

Browse files
Felix Zengrkhuangtao
authored andcommitted
driver: rknpu: Only wait for iommu disabled in multiple domains
Signed-off-by: Felix Zeng <[email protected]> Change-Id: I2d8768a018e05286f2dcc7d1190e5e34ac34e923
1 parent 10bcb7c commit 046d5df

File tree

1 file changed

+22
-22
lines changed

1 file changed

+22
-22
lines changed

drivers/rknpu/rknpu_drv.c

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -697,33 +697,33 @@ static int rknpu_power_off(struct rknpu_device *rknpu_dev)
697697

698698
pm_runtime_put_sync(dev);
699699

700+
if (rknpu_dev->multiple_domains) {
700701
#ifndef FPGA_PLATFORM
701-
/*
702-
* Because IOMMU's runtime suspend callback is asynchronous,
703-
* So it may be executed after the NPU is turned off after PD/CLK/VD,
704-
* and the runtime suspend callback has a register access.
705-
* If the PD/VD/CLK is closed, the register access will crash.
706-
* As a workaround, it's safe to close pd stuff until iommu disabled.
707-
* If pm runtime framework can handle this issue in the future, remove
708-
* this.
709-
*/
710-
ret = readx_poll_timeout(rockchip_iommu_is_enabled, dev, val, !val,
711-
NPU_MMU_DISABLED_POLL_PERIOD_US,
712-
NPU_MMU_DISABLED_POLL_TIMEOUT_US);
713-
if (ret) {
714-
LOG_DEV_ERROR(dev, "iommu still enabled\n");
715-
pm_runtime_get_sync(dev);
702+
/*
703+
* Because IOMMU's runtime suspend callback is asynchronous,
704+
* So it may be executed after the NPU is turned off after PD/CLK/VD,
705+
* and the runtime suspend callback has a register access.
706+
* If the PD/VD/CLK is closed, the register access will crash.
707+
* As a workaround, it's safe to close pd stuff until iommu disabled.
708+
* If pm runtime framework can handle this issue in the future, remove
709+
* this.
710+
*/
711+
ret = readx_poll_timeout(rockchip_iommu_is_enabled, dev, val,
712+
!val, NPU_MMU_DISABLED_POLL_PERIOD_US,
713+
NPU_MMU_DISABLED_POLL_TIMEOUT_US);
714+
if (ret) {
715+
LOG_DEV_ERROR(dev, "iommu still enabled\n");
716+
pm_runtime_get_sync(dev);
716717
#if KERNEL_VERSION(5, 10, 0) <= LINUX_VERSION_CODE
717-
rockchip_monitor_volt_adjust_unlock(rknpu_dev->mdev_info);
718+
rockchip_monitor_volt_adjust_unlock(
719+
rknpu_dev->mdev_info);
718720
#endif
719-
return ret;
720-
}
721+
return ret;
722+
}
721723
#else
722-
if (rknpu_dev->iommu_en)
723-
msleep(20);
724+
if (rknpu_dev->iommu_en)
725+
msleep(20);
724726
#endif
725-
726-
if (rknpu_dev->multiple_domains) {
727727
if (rknpu_dev->genpd_dev_npu2)
728728
pm_runtime_put_sync(rknpu_dev->genpd_dev_npu2);
729729
if (rknpu_dev->genpd_dev_npu1)

0 commit comments

Comments
 (0)