From: Jeffrey Hugo <jhugo@codeaurora.org>
To: Greg KH <gregkh@linuxfoundation.org>,
Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Cc: arnd@arndb.de, smohanad@codeaurora.org, kvalo@codeaurora.org,
bjorn.andersson@linaro.org, hemantk@codeaurora.org,
linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 03/16] bus: mhi: core: Add support for registering MHI client drivers
Date: Wed, 18 Mar 2020 07:54:30 -0600 [thread overview]
Message-ID: <db612e12-0033-31cc-60fc-62e45dda4342@codeaurora.org> (raw)
In-Reply-To: <20200318133626.GA2801580@kroah.com>
On 3/18/2020 7:36 AM, Greg KH wrote:
> On Thu, Feb 20, 2020 at 03:28:41PM +0530, Manivannan Sadhasivam wrote:
>> This commit adds support for registering MHI client drivers with the
>> MHI stack. MHI client drivers binds to one or more MHI devices inorder
>> to sends and receive the upper-layer protocol packets like IP packets,
>> modem control messages, and diagnostics messages over MHI bus.
>>
>> This is based on the patch submitted by Sujeev Dias:
>> https://lkml.org/lkml/2018/7/9/987
>>
>> Signed-off-by: Sujeev Dias <sdias@codeaurora.org>
>> Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
>> [mani: splitted and cleaned up for upstream]
>> Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
>> Reviewed-by: Jeffrey Hugo <jhugo@codeaurora.org>
>> Tested-by: Jeffrey Hugo <jhugo@codeaurora.org>
>> ---
>> drivers/bus/mhi/core/init.c | 149 ++++++++++++++++++++++++++++++++++++
>> include/linux/mhi.h | 39 ++++++++++
>> 2 files changed, 188 insertions(+)
>>
>> diff --git a/drivers/bus/mhi/core/init.c b/drivers/bus/mhi/core/init.c
>> index 6f24c21284ec..12e386862b3f 100644
>> --- a/drivers/bus/mhi/core/init.c
>> +++ b/drivers/bus/mhi/core/init.c
>> @@ -374,8 +374,157 @@ struct mhi_device *mhi_alloc_device(struct mhi_controller *mhi_cntrl)
>> return mhi_dev;
>> }
>>
>> +static int mhi_driver_probe(struct device *dev)
>> +{
>> + struct mhi_device *mhi_dev = to_mhi_device(dev);
>> + struct mhi_controller *mhi_cntrl = mhi_dev->mhi_cntrl;
>> + struct device_driver *drv = dev->driver;
>> + struct mhi_driver *mhi_drv = to_mhi_driver(drv);
>> + struct mhi_event *mhi_event;
>> + struct mhi_chan *ul_chan = mhi_dev->ul_chan;
>> + struct mhi_chan *dl_chan = mhi_dev->dl_chan;
>> +
>> + if (ul_chan) {
>> + /*
>> + * If channel supports LPM notifications then status_cb should
>> + * be provided
>> + */
>> + if (ul_chan->lpm_notify && !mhi_drv->status_cb)
>> + return -EINVAL;
>> +
>> + /* For non-offload channels then xfer_cb should be provided */
>> + if (!ul_chan->offload_ch && !mhi_drv->ul_xfer_cb)
>> + return -EINVAL;
>> +
>> + ul_chan->xfer_cb = mhi_drv->ul_xfer_cb;
>> + }
>> +
>> + if (dl_chan) {
>> + /*
>> + * If channel supports LPM notifications then status_cb should
>> + * be provided
>> + */
>> + if (dl_chan->lpm_notify && !mhi_drv->status_cb)
>> + return -EINVAL;
>> +
>> + /* For non-offload channels then xfer_cb should be provided */
>> + if (!dl_chan->offload_ch && !mhi_drv->dl_xfer_cb)
>> + return -EINVAL;
>> +
>> + mhi_event = &mhi_cntrl->mhi_event[dl_chan->er_index];
>> +
>> + /*
>> + * If the channel event ring is managed by client, then
>> + * status_cb must be provided so that the framework can
>> + * notify pending data
>> + */
>> + if (mhi_event->cl_manage && !mhi_drv->status_cb)
>> + return -EINVAL;
>> +
>> + dl_chan->xfer_cb = mhi_drv->dl_xfer_cb;
>> + }
>> +
>> + /* Call the user provided probe function */
>> + return mhi_drv->probe(mhi_dev, mhi_dev->id);
>> +}
>> +
>> +static int mhi_driver_remove(struct device *dev)
>> +{
>> + struct mhi_device *mhi_dev = to_mhi_device(dev);
>> + struct mhi_driver *mhi_drv = to_mhi_driver(dev->driver);
>> + struct mhi_chan *mhi_chan;
>> + enum mhi_ch_state ch_state[] = {
>> + MHI_CH_STATE_DISABLED,
>> + MHI_CH_STATE_DISABLED
>> + };
>> + int dir;
>> +
>> + /* Skip if it is a controller device */
>> + if (mhi_dev->dev_type == MHI_DEVICE_CONTROLLER)
>> + return 0;
>> +
>> + /* Reset both channels */
>> + for (dir = 0; dir < 2; dir++) {
>> + mhi_chan = dir ? mhi_dev->ul_chan : mhi_dev->dl_chan;
>> +
>> + if (!mhi_chan)
>> + continue;
>> +
>> + /* Wake all threads waiting for completion */
>> + write_lock_irq(&mhi_chan->lock);
>> + mhi_chan->ccs = MHI_EV_CC_INVALID;
>> + complete_all(&mhi_chan->completion);
>> + write_unlock_irq(&mhi_chan->lock);
>> +
>> + /* Set the channel state to disabled */
>> + mutex_lock(&mhi_chan->mutex);
>> + write_lock_irq(&mhi_chan->lock);
>> + ch_state[dir] = mhi_chan->ch_state;
>> + mhi_chan->ch_state = MHI_CH_STATE_SUSPENDED;
>> + write_unlock_irq(&mhi_chan->lock);
>> +
>> + mutex_unlock(&mhi_chan->mutex);
>> + }
>> +
>> + mhi_drv->remove(mhi_dev);
>> +
>> + /* De-init channel if it was enabled */
>> + for (dir = 0; dir < 2; dir++) {
>> + mhi_chan = dir ? mhi_dev->ul_chan : mhi_dev->dl_chan;
>> +
>> + if (!mhi_chan)
>> + continue;
>> +
>> + mutex_lock(&mhi_chan->mutex);
>> +
>> + mhi_chan->ch_state = MHI_CH_STATE_DISABLED;
>> +
>> + mutex_unlock(&mhi_chan->mutex);
>> + }
>> +
>> + return 0;
>> +}
>> +
>> +int mhi_driver_register(struct mhi_driver *mhi_drv)
>> +{
>> + struct device_driver *driver = &mhi_drv->driver;
>> +
>> + if (!mhi_drv->probe || !mhi_drv->remove)
>> + return -EINVAL;
>> +
>> + driver->bus = &mhi_bus_type;
>> + driver->probe = mhi_driver_probe;
>> + driver->remove = mhi_driver_remove;
>> +
>> + return driver_register(driver);
>> +}
>> +EXPORT_SYMBOL_GPL(mhi_driver_register);
>
> You don't care about module owners of the driver? Odd :(
>
> (hint, you probably should...)
>
> greg k-h
>
For my own education, can you please clarify your comment? I'm not sure
that I understand the context of what you are saying (ie why is this
export a possible problem?).
--
Jeffrey Hugo
Qualcomm Technologies, Inc. is a member of the
Code Aurora Forum, a Linux Foundation Collaborative Project.
next prev parent reply other threads:[~2020-03-18 13:54 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-20 9:58 [PATCH v3 00/16] Add MHI bus support Manivannan Sadhasivam
2020-02-20 9:58 ` [PATCH v3 01/16] docs: Add documentation for MHI bus Manivannan Sadhasivam
2020-02-20 9:58 ` [PATCH v3 02/16] bus: mhi: core: Add support for registering MHI controllers Manivannan Sadhasivam
2020-02-28 18:10 ` Jeffrey Hugo
2020-02-20 9:58 ` [PATCH v3 03/16] bus: mhi: core: Add support for registering MHI client drivers Manivannan Sadhasivam
2020-03-18 13:36 ` Greg KH
2020-03-18 13:54 ` Jeffrey Hugo [this message]
2020-03-18 14:00 ` Greg KH
2020-03-18 14:23 ` Manivannan Sadhasivam
2020-03-18 14:27 ` Greg KH
2020-03-18 14:31 ` Manivannan Sadhasivam
2020-03-18 14:38 ` Greg KH
2020-02-20 9:58 ` [PATCH v3 04/16] bus: mhi: core: Add support for creating and destroying MHI devices Manivannan Sadhasivam
2020-02-20 9:58 ` [PATCH v3 05/16] bus: mhi: core: Add support for ringing channel/event ring doorbells Manivannan Sadhasivam
2020-02-20 9:58 ` [PATCH v3 06/16] bus: mhi: core: Add support for PM state transitions Manivannan Sadhasivam
2020-02-20 9:58 ` [PATCH v3 07/16] bus: mhi: core: Add support for basic PM operations Manivannan Sadhasivam
2020-02-20 9:58 ` [PATCH v3 08/16] bus: mhi: core: Add support for downloading firmware over BHIe Manivannan Sadhasivam
2020-02-20 9:58 ` [PATCH v3 09/16] bus: mhi: core: Add support for downloading RDDM image during panic Manivannan Sadhasivam
2020-02-20 9:58 ` [PATCH v3 10/16] bus: mhi: core: Add support for processing events from client device Manivannan Sadhasivam
2020-02-20 9:58 ` [PATCH v3 11/16] bus: mhi: core: Add support for data transfer Manivannan Sadhasivam
2020-02-20 9:58 ` [PATCH v3 12/16] bus: mhi: core: Add uevent support for module autoloading Manivannan Sadhasivam
2020-02-20 9:58 ` [PATCH v3 13/16] MAINTAINERS: Add entry for MHI bus Manivannan Sadhasivam
2020-02-20 9:58 ` [PATCH v3 14/16] net: qrtr: Add MHI transport layer Manivannan Sadhasivam
2020-03-18 14:42 ` Greg KH
2020-03-18 14:53 ` Manivannan Sadhasivam
2020-02-20 9:58 ` [PATCH v3 15/16] net: qrtr: Do not depend on ARCH_QCOM Manivannan Sadhasivam
2020-02-20 15:23 ` Bjorn Andersson
2020-02-20 9:58 ` [PATCH v3 16/16] soc: qcom: Do not depend on ARCH_QCOM for QMI helpers Manivannan Sadhasivam
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=db612e12-0033-31cc-60fc-62e45dda4342@codeaurora.org \
--to=jhugo@codeaurora.org \
--cc=arnd@arndb.de \
--cc=bjorn.andersson@linaro.org \
--cc=gregkh@linuxfoundation.org \
--cc=hemantk@codeaurora.org \
--cc=kvalo@codeaurora.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=manivannan.sadhasivam@linaro.org \
--cc=smohanad@codeaurora.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;
as well as URLs for NNTP newsgroup(s).