bus: mhi: core: Remove pre_init flag used for power purposes
authorBhaumik Bhatt <bbhatt@codeaurora.org>
Thu, 1 Apr 2021 21:41:49 +0000 (14:41 -0700)
committerManivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Wed, 7 Apr 2021 06:55:41 +0000 (12:25 +0530)
Some controllers can choose to skip preparation for power up.
In that case, device context is initialized based on the pre_init
flag not being set during mhi_prepare_for_power_up(). There is no
reason MHI host driver should maintain and provide controllers
with two separate paths for preparing MHI.

Going forward, all controllers will be required to call the
mhi_prepare_for_power_up() API followed by their choice of sync
or async power up. This allows MHI host driver to get rid of the
pre_init flag and sets up a common way for all controllers to use
MHI. This also helps controllers fail early on during preparation
phase in some failure cases.

Signed-off-by: Bhaumik Bhatt <bbhatt@codeaurora.org>
Reviewed-by: Hemant Kumar <hemantk@codeaurora.org>
Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Link: https://lore.kernel.org/r/1617313309-24035-1-git-send-email-bbhatt@codeaurora.org
Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
drivers/bus/mhi/core/init.c
drivers/bus/mhi/core/pm.c
include/linux/mhi.h

index d1d9b0d9158ef65a9f02528604c54b8055f07a8c..1f61352132516fc2f2ddf9909f403200930054c0 100644 (file)
@@ -1080,8 +1080,6 @@ int mhi_prepare_for_power_up(struct mhi_controller *mhi_cntrl)
                        mhi_rddm_prepare(mhi_cntrl, mhi_cntrl->rddm_image);
        }
 
-       mhi_cntrl->pre_init = true;
-
        mutex_unlock(&mhi_cntrl->pm_mutex);
 
        return 0;
@@ -1112,7 +1110,6 @@ void mhi_unprepare_after_power_down(struct mhi_controller *mhi_cntrl)
        }
 
        mhi_deinit_dev_ctxt(mhi_cntrl);
-       mhi_cntrl->pre_init = false;
 }
 EXPORT_SYMBOL_GPL(mhi_unprepare_after_power_down);
 
index dafcd9847cc6ae30d4f8131f910f0b73750dc7c4..e2e59a341fef64ee707a72dc4fbf38ca17aef08d 100644 (file)
@@ -1062,13 +1062,6 @@ int mhi_async_power_up(struct mhi_controller *mhi_cntrl)
        mutex_lock(&mhi_cntrl->pm_mutex);
        mhi_cntrl->pm_state = MHI_PM_DISABLE;
 
-       if (!mhi_cntrl->pre_init) {
-               /* Setup device context */
-               ret = mhi_init_dev_ctxt(mhi_cntrl);
-               if (ret)
-                       goto error_dev_ctxt;
-       }
-
        ret = mhi_init_irq_setup(mhi_cntrl);
        if (ret)
                goto error_setup_irq;
@@ -1150,10 +1143,6 @@ error_bhi_offset:
        mhi_deinit_free_irq(mhi_cntrl);
 
 error_setup_irq:
-       if (!mhi_cntrl->pre_init)
-               mhi_deinit_dev_ctxt(mhi_cntrl);
-
-error_dev_ctxt:
        mhi_cntrl->pm_state = MHI_PM_DISABLE;
        mutex_unlock(&mhi_cntrl->pm_mutex);
 
@@ -1203,15 +1192,6 @@ void mhi_power_down(struct mhi_controller *mhi_cntrl, bool graceful)
        flush_work(&mhi_cntrl->st_worker);
 
        free_irq(mhi_cntrl->irq[0], mhi_cntrl);
-
-       if (!mhi_cntrl->pre_init) {
-               /* Free all allocated resources */
-               if (mhi_cntrl->fbc_image) {
-                       mhi_free_bhie_table(mhi_cntrl, mhi_cntrl->fbc_image);
-                       mhi_cntrl->fbc_image = NULL;
-               }
-               mhi_deinit_dev_ctxt(mhi_cntrl);
-       }
 }
 EXPORT_SYMBOL_GPL(mhi_power_down);
 
index b16afd36b4441f7e76e259dd546480d90b7d95b2..c9b36a34cc7fbe20cfb69c56c3504014e1e97bcf 100644 (file)
@@ -354,7 +354,6 @@ struct mhi_controller_config {
  * @index: Index of the MHI controller instance
  * @bounce_buf: Use of bounce buffer
  * @fbc_download: MHI host needs to do complete image transfer (optional)
- * @pre_init: MHI host needs to do pre-initialization before power up
  * @wake_set: Device wakeup set flag
  * @irq_flags: irq flags passed to request_irq (optional)
  *
@@ -447,7 +446,6 @@ struct mhi_controller {
        int index;
        bool bounce_buf;
        bool fbc_download;
-       bool pre_init;
        bool wake_set;
        unsigned long irq_flags;
 };