]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
iommu/tegra241-cmdqv: Simplify deinit flow in tegra241_cmdqv_remove_vintf()
authorNicolin Chen <nicolinc@nvidia.com>
Thu, 10 Jul 2025 05:59:18 +0000 (22:59 -0700)
committerJason Gunthorpe <jgg@nvidia.com>
Fri, 11 Jul 2025 17:34:36 +0000 (14:34 -0300)
The current flow of tegra241_cmdqv_remove_vintf() is:
 1. For each LVCMDQ, tegra241_vintf_remove_lvcmdq():
    a. Disable the LVCMDQ HW
    b. Release the LVCMDQ SW resource
 2. For current VINTF, tegra241_vintf_hw_deinit():
    c. Disable all LVCMDQ HWs
    d. Disable VINTF HW

Obviously, the step 1.a and the step 2.c are redundant.

Since tegra241_vintf_hw_deinit() disables all of its LVCMDQ HWs, it could
simplify the flow in tegra241_cmdqv_remove_vintf() by calling that first:
 1. For current VINTF, tegra241_vintf_hw_deinit():
    a. Disable all LVCMDQ HWs
    b. Disable VINTF HW
 2. Release all LVCMDQ SW resources

Drop tegra241_vintf_remove_lvcmdq(), and move tegra241_vintf_free_lvcmdq()
as the new step 2.

Link: https://patch.msgid.link/r/86c97c8c4ee9ca192e7e7fa3007c10399d792ce6.1752126748.git.nicolinc@nvidia.com
Acked-by: Pranjal Shrivastava <praan@google.com>
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
Signed-off-by: Nicolin Chen <nicolinc@nvidia.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
drivers/iommu/arm/arm-smmu-v3/tegra241-cmdqv.c

index ba029f7d24ce69fc7795c0564995741447b22aff..8d418c131b1b087117be8688efc558c95196f614 100644 (file)
@@ -628,24 +628,17 @@ static int tegra241_cmdqv_init_vintf(struct tegra241_cmdqv *cmdqv, u16 max_idx,
 
 /* Remove Helpers */
 
-static void tegra241_vintf_remove_lvcmdq(struct tegra241_vintf *vintf, u16 lidx)
-{
-       tegra241_vcmdq_hw_deinit(vintf->lvcmdqs[lidx]);
-       tegra241_vintf_free_lvcmdq(vintf, lidx);
-}
-
 static void tegra241_cmdqv_remove_vintf(struct tegra241_cmdqv *cmdqv, u16 idx)
 {
        struct tegra241_vintf *vintf = cmdqv->vintfs[idx];
        u16 lidx;
 
+       tegra241_vintf_hw_deinit(vintf);
+
        /* Remove LVCMDQ resources */
        for (lidx = 0; lidx < vintf->cmdqv->num_lvcmdqs_per_vintf; lidx++)
                if (vintf->lvcmdqs[lidx])
-                       tegra241_vintf_remove_lvcmdq(vintf, lidx);
-
-       /* Remove VINTF resources */
-       tegra241_vintf_hw_deinit(vintf);
+                       tegra241_vintf_free_lvcmdq(vintf, lidx);
 
        dev_dbg(cmdqv->dev, "VINTF%u: deallocated\n", vintf->idx);
        tegra241_cmdqv_deinit_vintf(cmdqv, idx);