Re: [PATCH v4 12/24] iommu/mediatek: Move hw_init into attach_device

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2020-11-11 12:38, Yong Wu wrote:
In attach device, it will update the pagetable base address register.
Move the hw_init function also here. Then it only need call
pm_runtime_get/put one time here if m4u has power domain.

Doesn't that mean you'll end up writing most of the registers twice every time? (first from mtk_iommu_resume(), then again from mtk_iommu_hw_init())

It might be neater to have mtk_iommu_hw_init() simply populate the mtk_iommu_suspend_reg data with the initial values at probe time and manually call mtk_iommu_resume() if the hardware is already powered up at that point. Or maybe just don't bother saving those registers on suspend and put the initialisation directly in the resume path.

Robin.

Signed-off-by: Yong Wu <yong.wu@xxxxxxxxxxxx>
---
  drivers/iommu/mtk_iommu.c | 10 ++++++----
  1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c
index 55f9b329e637..cfdf5ce696fd 100644
--- a/drivers/iommu/mtk_iommu.c
+++ b/drivers/iommu/mtk_iommu.c
@@ -125,6 +125,8 @@ struct mtk_iommu_domain {
static const struct iommu_ops mtk_iommu_ops; +static int mtk_iommu_hw_init(const struct mtk_iommu_data *data);
+
  /*
   * In M4U 4GB mode, the physical address is remapped as below:
   *
@@ -380,12 +382,16 @@ static int mtk_iommu_attach_device(struct iommu_domain *domain,
  {
  	struct mtk_iommu_data *data = dev_iommu_priv_get(dev);
  	struct mtk_iommu_domain *dom = to_mtk_domain(domain);
+	int ret;
if (!data)
  		return -ENODEV;
/* Update the pgtable base address register of the M4U HW */
  	if (!data->m4u_dom) {
+		ret = mtk_iommu_hw_init(data);
+		if (ret)
+			return ret;
  		data->m4u_dom = dom;
  		writel(dom->cfg.arm_v7s_cfg.ttbr & MMU_PT_ADDR_MASK,
  		       data->base + REG_MMU_PT_BASE_ADDR);
@@ -729,10 +735,6 @@ static int mtk_iommu_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, data); - ret = mtk_iommu_hw_init(data);
-	if (ret)
-		return ret;
-
  	ret = iommu_device_sysfs_add(&data->iommu, dev, NULL,
  				     "mtk-iommu.%pa", &ioaddr);
  	if (ret)




[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]


  Powered by Linux