From: Krishna Chaitanya Chundru <krishna.chundru@oss.qualcomm.com>
To: Bjorn Andersson <andersson@kernel.org>
Cc: Manivannan Sadhasivam <mani@kernel.org>,
Jeff Hugo <jeff.hugo@oss.qualcomm.com>,
Carl Vanderlip <carl.vanderlip@oss.qualcomm.com>,
Oded Gabbay <ogabbay@kernel.org>,
Jeff Johnson <jjohnson@kernel.org>,
Andrew Lunn <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
mhi@lists.linux.dev, linux-arm-msm@vger.kernel.org,
linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org,
linux-wireless@vger.kernel.org, ath11k@lists.infradead.org,
ath12k@lists.infradead.org, netdev@vger.kernel.org,
mayank.rana@oss.qualcomm.com, quic_vbadigan@quicinc.com,
vivek.pernamitta@oss.qualcomm.com
Subject: Re: [PATCH 3/4] net: mhi_net: Implement runtime PM support
Date: Fri, 13 Mar 2026 12:46:08 +0530 [thread overview]
Message-ID: <a17e4c07-1f00-4b0d-90e3-2eeb1e71a248@oss.qualcomm.com> (raw)
In-Reply-To: <nj4ovttt4i7hsqfdv5zhdotxrx3upxfq4ozuligwuheubnsmkd@e6bwzgkn55kl>
On 12/3/2025 3:07 AM, Bjorn Andersson wrote:
> On Mon, Dec 01, 2025 at 06:13:19PM +0530, Krishna Chaitanya Chundru wrote:
>> Add runtime power management support to the mhi_net driver to align with
>> the updated MHI framework, which expects runtime PM to be enabled by client
>> drivers. This ensures the controller remains active during data transfers
>> and can autosuspend when idle.
> This last sentence hints at there being an actual problem with the
> current code. Perhaps we do this because it's the right thing to do,
> perhaps we're making this change because devices are crashing and
> burning?
we are doing because its right thing to do, with current code we are not
seeing
any issues.
> Start your commit message with making the reason for your change clear.
>
> Ask yourself https://en.wikipedia.org/wiki/Five_whys when you come up
> with your problem description.
ack.
>> The driver now uses pm_runtime_get() and pm_runtime_put() around
>> transmit, receive, and buffer refill operations. Runtime PM is initialized
>> during probe with autosuspend enabled and a 100ms delay. The device is
>> marked with pm_runtime_no_callbacks() to notify PM framework that there
>> are no callbacks for this driver.
> This looks like an AI prompt, does it add value to the commit message?
>
> It can mostly be summarized as "Implement pm_runtime in the driver". The
> only part that's not obvious is the 100ms autosuspend delay, but you
> skipped explaining why you did choose this number.
100ms taken from pci port bus driver reference, I will add the reason
for 100ms
in next patch.
>> Signed-off-by: Krishna Chaitanya Chundru <krishna.chundru@oss.qualcomm.com>
>> ---
>> drivers/net/mhi_net.c | 13 +++++++++++++
>> 1 file changed, 13 insertions(+)
>>
>> diff --git a/drivers/net/mhi_net.c b/drivers/net/mhi_net.c
>> index ae169929a9d8e449b5a427993abf68e8d032fae2..c5c697f29e69e9bc874b6cfff4699de12a4af114 100644
>> --- a/drivers/net/mhi_net.c
>> +++ b/drivers/net/mhi_net.c
>> @@ -9,6 +9,7 @@
>> #include <linux/mod_devicetable.h>
>> #include <linux/module.h>
>> #include <linux/netdevice.h>
>> +#include <linux/pm_runtime.h>
>> #include <linux/skbuff.h>
>> #include <linux/u64_stats_sync.h>
>>
>> @@ -76,6 +77,7 @@ static netdev_tx_t mhi_ndo_xmit(struct sk_buff *skb, struct net_device *ndev)
>> struct mhi_device *mdev = mhi_netdev->mdev;
>> int err;
>>
>> + pm_runtime_get(&mdev->dev);
> What happened to your error handling?
ack I will add error handling.
- Krishna Chaitanya.
>
> Regards,
> Bjorn
>
>> err = mhi_queue_skb(mdev, DMA_TO_DEVICE, skb, skb->len, MHI_EOT);
>> if (unlikely(err)) {
>> net_err_ratelimited("%s: Failed to queue TX buf (%d)\n",
>> @@ -94,6 +96,7 @@ static netdev_tx_t mhi_ndo_xmit(struct sk_buff *skb, struct net_device *ndev)
>> u64_stats_inc(&mhi_netdev->stats.tx_dropped);
>> u64_stats_update_end(&mhi_netdev->stats.tx_syncp);
>>
>> + pm_runtime_put_autosuspend(&mdev->dev);
>> return NETDEV_TX_OK;
>> }
>>
>> @@ -261,6 +264,7 @@ static void mhi_net_ul_callback(struct mhi_device *mhi_dev,
>> }
>> u64_stats_update_end(&mhi_netdev->stats.tx_syncp);
>>
>> + pm_runtime_put_autosuspend(&mdev->dev);
>> if (netif_queue_stopped(ndev) && !mhi_queue_is_full(mdev, DMA_TO_DEVICE))
>> netif_wake_queue(ndev);
>> }
>> @@ -277,6 +281,7 @@ static void mhi_net_rx_refill_work(struct work_struct *work)
>>
>> size = mhi_netdev->mru ? mhi_netdev->mru : READ_ONCE(ndev->mtu);
>>
>> + pm_runtime_get_sync(&mdev->dev);
>> while (!mhi_queue_is_full(mdev, DMA_FROM_DEVICE)) {
>> skb = netdev_alloc_skb(ndev, size);
>> if (unlikely(!skb))
>> @@ -296,6 +301,7 @@ static void mhi_net_rx_refill_work(struct work_struct *work)
>> cond_resched();
>> }
>>
>> + pm_runtime_put_autosuspend(&mdev->dev);
>> /* If we're still starved of rx buffers, reschedule later */
>> if (mhi_get_free_desc_count(mdev, DMA_FROM_DEVICE) == mhi_netdev->rx_queue_sz)
>> schedule_delayed_work(&mhi_netdev->rx_refill, HZ / 2);
>> @@ -362,12 +368,19 @@ static int mhi_net_probe(struct mhi_device *mhi_dev,
>>
>> SET_NETDEV_DEV(ndev, &mhi_dev->dev);
>>
>> + pm_runtime_no_callbacks(&mhi_dev->dev);
>> + devm_pm_runtime_set_active_enabled(&mhi_dev->dev);
>> + pm_runtime_set_autosuspend_delay(&mhi_dev->dev, 100);
>> + pm_runtime_use_autosuspend(&mhi_dev->dev);
>> + pm_runtime_get(&mhi_dev->dev);
>> err = mhi_net_newlink(mhi_dev, ndev);
>> if (err) {
>> free_netdev(ndev);
>> + pm_runtime_put_autosuspend(&mhi_dev->dev);
>> return err;
>> }
>>
>> + pm_runtime_put_autosuspend(&mhi_dev->dev);
>> return 0;
>> }
>>
>>
>> --
>> 2.34.1
>>
>>
next prev parent reply other threads:[~2026-03-13 7:16 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-01 12:43 [PATCH 0/4] bus: mhi: Fix broken runtime PM design Krishna Chaitanya Chundru
2025-12-01 12:43 ` [PATCH 1/4] bus: mhi: Replace controller runtime_get/put callbacks with direct PM runtime APIs Krishna Chaitanya Chundru
2025-12-01 12:43 ` [PATCH 2/4] bus: mhi: Remove runtime PM callback ops from controller interface Krishna Chaitanya Chundru
2025-12-02 21:29 ` Bjorn Andersson
2025-12-01 12:43 ` [PATCH 3/4] net: mhi_net: Implement runtime PM support Krishna Chaitanya Chundru
2025-12-01 17:41 ` Mayank Rana
2025-12-02 21:37 ` Bjorn Andersson
2026-03-13 7:16 ` Krishna Chaitanya Chundru [this message]
2025-12-01 12:43 ` [PATCH 4/4] bus: mhi: Fix broken runtime PM design Krishna Chaitanya Chundru
2025-12-01 18:33 ` Mayank Rana
2025-12-02 5:26 ` Krishna Chaitanya Chundru
2025-12-02 18:54 ` Mayank Rana
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=a17e4c07-1f00-4b0d-90e3-2eeb1e71a248@oss.qualcomm.com \
--to=krishna.chundru@oss.qualcomm.com \
--cc=andersson@kernel.org \
--cc=andrew+netdev@lunn.ch \
--cc=ath11k@lists.infradead.org \
--cc=ath12k@lists.infradead.org \
--cc=carl.vanderlip@oss.qualcomm.com \
--cc=davem@davemloft.net \
--cc=dri-devel@lists.freedesktop.org \
--cc=edumazet@google.com \
--cc=jeff.hugo@oss.qualcomm.com \
--cc=jjohnson@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-wireless@vger.kernel.org \
--cc=mani@kernel.org \
--cc=mayank.rana@oss.qualcomm.com \
--cc=mhi@lists.linux.dev \
--cc=netdev@vger.kernel.org \
--cc=ogabbay@kernel.org \
--cc=pabeni@redhat.com \
--cc=quic_vbadigan@quicinc.com \
--cc=vivek.pernamitta@oss.qualcomm.com \
/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