From: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
To: Loic Poulain <loic.poulain@linaro.org>
Cc: hemantk@codeaurora.org, linux-arm-msm@vger.kernel.org,
bbhatt@codeaurora.org, jhugo@codeaurora.org
Subject: Re: [PATCH v4] bus: mhi: core: Fix device hierarchy
Date: Wed, 25 Nov 2020 17:27:57 +0530 [thread overview]
Message-ID: <20201125115757.GA20836@thinkpad> (raw)
In-Reply-To: <1606303396-5588-1-git-send-email-loic.poulain@linaro.org>
On Wed, Nov 25, 2020 at 12:23:16PM +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 hierarc /* Only destroy virtual devices thats attached to bus */
if (mhi_dev->dev_type == MHI_DEVICE_CONTROLLER)
return 0;hy 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>
> ---
> v2: fix commit message
> v3: reword commit message
> v4: fix device destroy
>
> drivers/bus/mhi/core/init.c | 10 +++++++++-
> drivers/bus/mhi/core/pm.c | 4 ++--
> 2 files changed, 11 insertions(+), 3 deletions(-)
>
> 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);
Hmm. Now I don't think we need below check in mhi_destroy_device():
/* Only destroy virtual devices thats attached to bus */
if (mhi_dev->dev_type == MHI_DEVICE_CONTROLLER)
return 0;
But let's keep it there for sanity.
Have you looked into mhi_debugfs_devices_show()? I guess you need to call
device_for_each_child() for both "mhi_cntrl->cntrl_dev" and
"mhi_cntrl->mhi_dev->dev".
Thanks,
Mani
>
> mutex_lock(&mhi_cntrl->pm_mutex);
>
> --
> 2.7.4
>
next prev parent reply other threads:[~2020-11-25 11:58 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-25 11:23 [PATCH v4] bus: mhi: core: Fix device hierarchy Loic Poulain
2020-11-25 11:57 ` Manivannan Sadhasivam [this message]
2020-11-25 13:20 ` Loic Poulain
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201125115757.GA20836@thinkpad \
--to=manivannan.sadhasivam@linaro.org \
--cc=bbhatt@codeaurora.org \
--cc=hemantk@codeaurora.org \
--cc=jhugo@codeaurora.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=loic.poulain@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox