* Re: [PATCH v5] bus: mhi: core: Fix device hierarchy
2020-11-25 13:24 [PATCH v5] bus: mhi: core: Fix device hierarchy Loic Poulain
@ 2020-11-25 15:06 ` Manivannan Sadhasivam
2020-11-25 20:32 ` Hemant Kumar
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Manivannan Sadhasivam @ 2020-11-25 15:06 UTC (permalink / raw)
To: Loic Poulain; +Cc: hemantk, linux-arm-msm, bbhatt, jhugo
On Wed, Nov 25, 2020 at 02:24:49PM +0100, Loic Poulain wrote:
> This patch fixes the hierarchical structure of MHI devices. Indeed,
> MHI client devices are directly 'enumerated' from the mhi controller
> and therefore must be direct descendants/children of their mhi
> controller device, in accordance with the Linux Device Model.
>
> Today both MHI clients and controller devices are at the same level,
> this patch ensures that MHI controller is parent of its client devices.
>
> The hierarchy is especially important for power management (safe
> suspend/resume order). It is also useful for userspace to determine
> relationship between MHI client devices and controllers.
>
> Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
> Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Hemant, Bhaumik: Can you please look into this change?
Thanks,
Mani
> ---
> v2: fix commit message
> v3: reword commit message
> v4: fix device destroy
> v5: fix debugfs device show
>
> drivers/bus/mhi/core/debugfs.c | 4 +++-
> drivers/bus/mhi/core/init.c | 10 +++++++++-
> drivers/bus/mhi/core/pm.c | 4 ++--
> 3 files changed, 14 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/bus/mhi/core/debugfs.c b/drivers/bus/mhi/core/debugfs.c
> index 3a48801..7d43138 100644
> --- a/drivers/bus/mhi/core/debugfs.c
> +++ b/drivers/bus/mhi/core/debugfs.c
> @@ -159,7 +159,9 @@ static int mhi_debugfs_devices_show(struct seq_file *m, void *d)
> return -ENODEV;
> }
>
> - device_for_each_child(mhi_cntrl->cntrl_dev, m, mhi_device_info_show);
> + /* Show controller and client(s) info */
> + mhi_device_info_show(&mhi_cntrl->mhi_dev->dev, m);
> + device_for_each_child(&mhi_cntrl->mhi_dev->dev, m, mhi_device_info_show);
>
> return 0;
> }
> diff --git a/drivers/bus/mhi/core/init.c b/drivers/bus/mhi/core/init.c
> index 436221c..c7a7354 100644
> --- a/drivers/bus/mhi/core/init.c
> +++ b/drivers/bus/mhi/core/init.c
> @@ -1137,7 +1137,15 @@ struct mhi_device *mhi_alloc_device(struct mhi_controller *mhi_cntrl)
> device_initialize(dev);
> dev->bus = &mhi_bus_type;
> dev->release = mhi_release_device;
> - dev->parent = mhi_cntrl->cntrl_dev;
> +
> + if (mhi_cntrl->mhi_dev) {
> + /* for MHI client devices, parent is the MHI controller device */
> + dev->parent = &mhi_cntrl->mhi_dev->dev;
> + } else {
> + /* for MHI controller device, parent is the bus device (e.g. pci device) */
> + dev->parent = mhi_cntrl->cntrl_dev;
> + }
> +
> mhi_dev->mhi_cntrl = mhi_cntrl;
> mhi_dev->dev_wake = 0;
>
> diff --git a/drivers/bus/mhi/core/pm.c b/drivers/bus/mhi/core/pm.c
> index a671f58..681960c 100644
> --- a/drivers/bus/mhi/core/pm.c
> +++ b/drivers/bus/mhi/core/pm.c
> @@ -504,7 +504,7 @@ static void mhi_pm_disable_transition(struct mhi_controller *mhi_cntrl)
> wake_up_all(&mhi_cntrl->state_event);
>
> dev_dbg(dev, "Reset all active channels and remove MHI devices\n");
> - device_for_each_child(mhi_cntrl->cntrl_dev, NULL, mhi_destroy_device);
> + device_for_each_child(&mhi_cntrl->mhi_dev->dev, NULL, mhi_destroy_device);
>
> mutex_lock(&mhi_cntrl->pm_mutex);
>
> @@ -637,7 +637,7 @@ static void mhi_pm_sys_error_transition(struct mhi_controller *mhi_cntrl)
> wake_up_all(&mhi_cntrl->state_event);
>
> dev_dbg(dev, "Reset all active channels and remove MHI devices\n");
> - device_for_each_child(mhi_cntrl->cntrl_dev, NULL, mhi_destroy_device);
> + device_for_each_child(&mhi_cntrl->mhi_dev->dev, NULL, mhi_destroy_device);
>
> mutex_lock(&mhi_cntrl->pm_mutex);
>
> --
> 2.7.4
>
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH v5] bus: mhi: core: Fix device hierarchy
2020-11-25 13:24 [PATCH v5] bus: mhi: core: Fix device hierarchy Loic Poulain
2020-11-25 15:06 ` Manivannan Sadhasivam
@ 2020-11-25 20:32 ` Hemant Kumar
2020-11-28 7:14 ` Manivannan Sadhasivam
2020-12-29 20:15 ` patchwork-bot+linux-arm-msm
3 siblings, 0 replies; 5+ messages in thread
From: Hemant Kumar @ 2020-11-25 20:32 UTC (permalink / raw)
To: Loic Poulain, manivannan.sadhasivam; +Cc: linux-arm-msm, bbhatt, jhugo
On 11/25/20 5:24 AM, Loic Poulain wrote:
> This patch fixes the hierarchical structure of MHI devices. Indeed,
> MHI client devices are directly 'enumerated' from the mhi controller
> and therefore must be direct descendants/children of their mhi
> controller device, in accordance with the Linux Device Model.
>
> Today both MHI clients and controller devices are at the same level,
> this patch ensures that MHI controller is parent of its client devices.
>
> The hierarchy is especially important for power management (safe
> suspend/resume order). It is also useful for userspace to determine
> relationship between MHI client devices and controllers.
>
> Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
> Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Reviewed-by: Hemant Kumar <hemantk@codeaurora.org>
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v5] bus: mhi: core: Fix device hierarchy
2020-11-25 13:24 [PATCH v5] bus: mhi: core: Fix device hierarchy Loic Poulain
2020-11-25 15:06 ` Manivannan Sadhasivam
2020-11-25 20:32 ` Hemant Kumar
@ 2020-11-28 7:14 ` Manivannan Sadhasivam
2020-12-29 20:15 ` patchwork-bot+linux-arm-msm
3 siblings, 0 replies; 5+ messages in thread
From: Manivannan Sadhasivam @ 2020-11-28 7:14 UTC (permalink / raw)
To: Loic Poulain; +Cc: hemantk, linux-arm-msm, bbhatt, jhugo
On Wed, Nov 25, 2020 at 02:24:49PM +0100, Loic Poulain wrote:
> This patch fixes the hierarchical structure of MHI devices. Indeed,
> MHI client devices are directly 'enumerated' from the mhi controller
> and therefore must be direct descendants/children of their mhi
> controller device, in accordance with the Linux Device Model.
>
> Today both MHI clients and controller devices are at the same level,
> this patch ensures that MHI controller is parent of its client devices.
>
> The hierarchy is especially important for power management (safe
> suspend/resume order). It is also useful for userspace to determine
> relationship between MHI client devices and controllers.
>
> Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
> Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Applied to mhi-next!
Thanks,
Mani
> ---
> v2: fix commit message
> v3: reword commit message
> v4: fix device destroy
> v5: fix debugfs device show
>
> drivers/bus/mhi/core/debugfs.c | 4 +++-
> drivers/bus/mhi/core/init.c | 10 +++++++++-
> drivers/bus/mhi/core/pm.c | 4 ++--
> 3 files changed, 14 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/bus/mhi/core/debugfs.c b/drivers/bus/mhi/core/debugfs.c
> index 3a48801..7d43138 100644
> --- a/drivers/bus/mhi/core/debugfs.c
> +++ b/drivers/bus/mhi/core/debugfs.c
> @@ -159,7 +159,9 @@ static int mhi_debugfs_devices_show(struct seq_file *m, void *d)
> return -ENODEV;
> }
>
> - device_for_each_child(mhi_cntrl->cntrl_dev, m, mhi_device_info_show);
> + /* Show controller and client(s) info */
> + mhi_device_info_show(&mhi_cntrl->mhi_dev->dev, m);
> + device_for_each_child(&mhi_cntrl->mhi_dev->dev, m, mhi_device_info_show);
>
> return 0;
> }
> diff --git a/drivers/bus/mhi/core/init.c b/drivers/bus/mhi/core/init.c
> index 436221c..c7a7354 100644
> --- a/drivers/bus/mhi/core/init.c
> +++ b/drivers/bus/mhi/core/init.c
> @@ -1137,7 +1137,15 @@ struct mhi_device *mhi_alloc_device(struct mhi_controller *mhi_cntrl)
> device_initialize(dev);
> dev->bus = &mhi_bus_type;
> dev->release = mhi_release_device;
> - dev->parent = mhi_cntrl->cntrl_dev;
> +
> + if (mhi_cntrl->mhi_dev) {
> + /* for MHI client devices, parent is the MHI controller device */
> + dev->parent = &mhi_cntrl->mhi_dev->dev;
> + } else {
> + /* for MHI controller device, parent is the bus device (e.g. pci device) */
> + dev->parent = mhi_cntrl->cntrl_dev;
> + }
> +
> mhi_dev->mhi_cntrl = mhi_cntrl;
> mhi_dev->dev_wake = 0;
>
> diff --git a/drivers/bus/mhi/core/pm.c b/drivers/bus/mhi/core/pm.c
> index a671f58..681960c 100644
> --- a/drivers/bus/mhi/core/pm.c
> +++ b/drivers/bus/mhi/core/pm.c
> @@ -504,7 +504,7 @@ static void mhi_pm_disable_transition(struct mhi_controller *mhi_cntrl)
> wake_up_all(&mhi_cntrl->state_event);
>
> dev_dbg(dev, "Reset all active channels and remove MHI devices\n");
> - device_for_each_child(mhi_cntrl->cntrl_dev, NULL, mhi_destroy_device);
> + device_for_each_child(&mhi_cntrl->mhi_dev->dev, NULL, mhi_destroy_device);
>
> mutex_lock(&mhi_cntrl->pm_mutex);
>
> @@ -637,7 +637,7 @@ static void mhi_pm_sys_error_transition(struct mhi_controller *mhi_cntrl)
> wake_up_all(&mhi_cntrl->state_event);
>
> dev_dbg(dev, "Reset all active channels and remove MHI devices\n");
> - device_for_each_child(mhi_cntrl->cntrl_dev, NULL, mhi_destroy_device);
> + device_for_each_child(&mhi_cntrl->mhi_dev->dev, NULL, mhi_destroy_device);
>
> mutex_lock(&mhi_cntrl->pm_mutex);
>
> --
> 2.7.4
>
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH v5] bus: mhi: core: Fix device hierarchy
2020-11-25 13:24 [PATCH v5] bus: mhi: core: Fix device hierarchy Loic Poulain
` (2 preceding siblings ...)
2020-11-28 7:14 ` Manivannan Sadhasivam
@ 2020-12-29 20:15 ` patchwork-bot+linux-arm-msm
3 siblings, 0 replies; 5+ messages in thread
From: patchwork-bot+linux-arm-msm @ 2020-12-29 20:15 UTC (permalink / raw)
To: Loic Poulain; +Cc: linux-arm-msm
Hello:
This patch was applied to qcom/linux.git (refs/heads/for-next):
On Wed, 25 Nov 2020 14:24:49 +0100 you wrote:
> This patch fixes the hierarchical structure of MHI devices. Indeed,
> MHI client devices are directly 'enumerated' from the mhi controller
> and therefore must be direct descendants/children of their mhi
> controller device, in accordance with the Linux Device Model.
>
> Today both MHI clients and controller devices are at the same level,
> this patch ensures that MHI controller is parent of its client devices.
>
> [...]
Here is the summary with links:
- [v5] bus: mhi: core: Fix device hierarchy
https://git.kernel.org/qcom/c/10ea8bcda5ae
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 5+ messages in thread