mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v1] i3c: master: Enable runtime PM for master controller
@ 2024-02-28  9:34 Mukesh Kumar Savaliya
  2024-03-10 17:29 ` Mukesh Kumar Savaliya
  2024-05-07 21:05 ` Alexandre Belloni
  0 siblings, 2 replies; 5+ messages in thread
From: Mukesh Kumar Savaliya @ 2024-02-28  9:34 UTC (permalink / raw)
  To: alexandre.belloni, linux-i3c, linux-kernel
  Cc: andersson, vkoul, manivannan.sadhasivam, Mukesh Kumar Savaliya

Enable runtime PM for i3c master node during master registration time.

Sometimes i3c client device driver may want to control the PM of the
parent (master) to perform the transactions and save the power in an
efficient way by controlling the session. Hence device can call PM
APIs by passing the parent node.

Here, I3C target device when calls pm_runtime_get_sync(dev->parent)
couldn't invoke master drivers runtime PM callback registered by
the master driver because parent's PM status was disabled in the
Master node.

Also call pm_runtime_no_callbacks() and pm_suspend_ignore_children()
for the master node to not have any callback addition and ignore the
children to have runtime PM work just locally in the driver. This
should be generic and common change for all i3c devices and should
not have any other impact.

With these changes, I3C client device works and able to invoke
master driver registered runtime PM callbacks.

Signed-off-by: Mukesh Kumar Savaliya <quic_msavaliy@quicinc.com>
---
 drivers/i3c/master.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/i3c/master.c b/drivers/i3c/master.c
index 3afa530c5e32..a3dc88974f92 100644
--- a/drivers/i3c/master.c
+++ b/drivers/i3c/master.c
@@ -13,6 +13,7 @@
 #include <linux/kernel.h>
 #include <linux/list.h>
 #include <linux/of.h>
+#include <linux/pm_runtime.h>
 #include <linux/slab.h>
 #include <linux/spinlock.h>
 #include <linux/workqueue.h>
@@ -2812,6 +2813,10 @@ int i3c_master_register(struct i3c_master_controller *master,
 
 	i3c_bus_notify(i3cbus, I3C_NOTIFY_BUS_ADD);
 
+	pm_runtime_no_callbacks(&master->dev);
+	pm_suspend_ignore_children(&master->dev, true);
+	pm_runtime_enable(&master->dev);
+
 	/*
 	 * We're done initializing the bus and the controller, we can now
 	 * register I3C devices discovered during the initial DAA.
@@ -2849,6 +2854,7 @@ void i3c_master_unregister(struct i3c_master_controller *master)
 	i3c_master_i2c_adapter_cleanup(master);
 	i3c_master_unregister_i3c_devs(master);
 	i3c_master_bus_cleanup(master);
+	pm_runtime_disable(&master->dev);
 	device_unregister(&master->dev);
 }
 EXPORT_SYMBOL_GPL(i3c_master_unregister);
-- 
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 v1] i3c: master: Enable runtime PM for master controller
  2024-02-28  9:34 [PATCH v1] i3c: master: Enable runtime PM for master controller Mukesh Kumar Savaliya
@ 2024-03-10 17:29 ` Mukesh Kumar Savaliya
  2024-03-15  8:05   ` Joshua Yeong
  2024-05-07 21:05 ` Alexandre Belloni
  1 sibling, 1 reply; 5+ messages in thread
From: Mukesh Kumar Savaliya @ 2024-03-10 17:29 UTC (permalink / raw)
  To: alexandre.belloni, linux-i3c, linux-kernel
  Cc: andersson, vkoul, manivannan.sadhasivam

A Gentle reminder ! As i was not part of the linux-i3c group before 
raising this gerrit, might not went into right folder.

On 2/28/2024 3:04 PM, Mukesh Kumar Savaliya wrote:
> Enable runtime PM for i3c master node during master registration time.
> 
> Sometimes i3c client device driver may want to control the PM of the
> parent (master) to perform the transactions and save the power in an
> efficient way by controlling the session. Hence device can call PM
> APIs by passing the parent node.
> 
> Here, I3C target device when calls pm_runtime_get_sync(dev->parent)
> couldn't invoke master drivers runtime PM callback registered by
> the master driver because parent's PM status was disabled in the
> Master node.
> 
> Also call pm_runtime_no_callbacks() and pm_suspend_ignore_children()
> for the master node to not have any callback addition and ignore the
> children to have runtime PM work just locally in the driver. This
> should be generic and common change for all i3c devices and should
> not have any other impact.
> 
> With these changes, I3C client device works and able to invoke
> master driver registered runtime PM callbacks.
> 
> Signed-off-by: Mukesh Kumar Savaliya <quic_msavaliy@quicinc.com>
> ---
>   drivers/i3c/master.c | 6 ++++++
>   1 file changed, 6 insertions(+)
> 
> diff --git a/drivers/i3c/master.c b/drivers/i3c/master.c
> index 3afa530c5e32..a3dc88974f92 100644
> --- a/drivers/i3c/master.c
> +++ b/drivers/i3c/master.c
> @@ -13,6 +13,7 @@
>   #include <linux/kernel.h>
>   #include <linux/list.h>
>   #include <linux/of.h>
> +#include <linux/pm_runtime.h>
>   #include <linux/slab.h>
>   #include <linux/spinlock.h>
>   #include <linux/workqueue.h>
> @@ -2812,6 +2813,10 @@ int i3c_master_register(struct i3c_master_controller *master,
>   
>   	i3c_bus_notify(i3cbus, I3C_NOTIFY_BUS_ADD);
>   
> +	pm_runtime_no_callbacks(&master->dev);
> +	pm_suspend_ignore_children(&master->dev, true);
> +	pm_runtime_enable(&master->dev);
> +
>   	/*
>   	 * We're done initializing the bus and the controller, we can now
>   	 * register I3C devices discovered during the initial DAA.
> @@ -2849,6 +2854,7 @@ void i3c_master_unregister(struct i3c_master_controller *master)
>   	i3c_master_i2c_adapter_cleanup(master);
>   	i3c_master_unregister_i3c_devs(master);
>   	i3c_master_bus_cleanup(master);
> +	pm_runtime_disable(&master->dev);
>   	device_unregister(&master->dev);
>   }
>   EXPORT_SYMBOL_GPL(i3c_master_unregister);

^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: [PATCH v1] i3c: master: Enable runtime PM for master controller
  2024-03-10 17:29 ` Mukesh Kumar Savaliya
@ 2024-03-15  8:05   ` Joshua Yeong
  2024-03-15 13:46     ` Mukesh Kumar Savaliya
  0 siblings, 1 reply; 5+ messages in thread
From: Joshua Yeong @ 2024-03-15  8:05 UTC (permalink / raw)
  To: Mukesh Kumar Savaliya, alexandre.belloni, linux-i3c, linux-kernel
  Cc: andersson, vkoul, manivannan.sadhasivam



> -----Original Message-----
> From: linux-i3c <linux-i3c-bounces@lists.infradead.org> On Behalf Of Mukesh
> Kumar Savaliya
> Sent: Monday, March 11, 2024 1:30 AM
> To: alexandre.belloni@bootlin.com; linux-i3c@lists.infradead.org; linux-
> kernel@vger.kernel.org
> Cc: andersson@kernel.org; vkoul@kernel.org;
> manivannan.sadhasivam@linaro.org
> Subject: Re: [PATCH v1] i3c: master: Enable runtime PM for master controller
> 
> A Gentle reminder ! As i was not part of the linux-i3c group before raising this
> gerrit, might not went into right folder.
> 
> On 2/28/2024 3:04 PM, Mukesh Kumar Savaliya wrote:
> > Enable runtime PM for i3c master node during master registration time.
> >
> > Sometimes i3c client device driver may want to control the PM of the
> > parent (master) to perform the transactions and save the power in an
> > efficient way by controlling the session. Hence device can call PM
> > APIs by passing the parent node.
> >
> > Here, I3C target device when calls pm_runtime_get_sync(dev->parent)
> > couldn't invoke master drivers runtime PM callback registered by the
> > master driver because parent's PM status was disabled in the Master
> > node.
> >
> > Also call pm_runtime_no_callbacks() and pm_suspend_ignore_children()
> > for the master node to not have any callback addition and ignore the
> > children to have runtime PM work just locally in the driver. This
> > should be generic and common change for all i3c devices and should not
> > have any other impact.
> >
> > With these changes, I3C client device works and able to invoke master
> > driver registered runtime PM callbacks.
> >
> > Signed-off-by: Mukesh Kumar Savaliya <quic_msavaliy@quicinc.com>
> > ---
> >   drivers/i3c/master.c | 6 ++++++
> >   1 file changed, 6 insertions(+)
> >
> > diff --git a/drivers/i3c/master.c b/drivers/i3c/master.c index
> > 3afa530c5e32..a3dc88974f92 100644
> > --- a/drivers/i3c/master.c
> > +++ b/drivers/i3c/master.c
> > @@ -13,6 +13,7 @@
> >   #include <linux/kernel.h>
> >   #include <linux/list.h>
> >   #include <linux/of.h>
> > +#include <linux/pm_runtime.h>
> >   #include <linux/slab.h>
> >   #include <linux/spinlock.h>
> >   #include <linux/workqueue.h>
> > @@ -2812,6 +2813,10 @@ int i3c_master_register(struct
> > i3c_master_controller *master,
> >
> >   	i3c_bus_notify(i3cbus, I3C_NOTIFY_BUS_ADD);
> >
> > +	pm_runtime_no_callbacks(&master->dev);
> > +	pm_suspend_ignore_children(&master->dev, true);
> > +	pm_runtime_enable(&master->dev);
> > +

Will runtime pm impact on ibi request from target?

> >   	/*
> >   	 * We're done initializing the bus and the controller, we can now
> >   	 * register I3C devices discovered during the initial DAA.
> > @@ -2849,6 +2854,7 @@ void i3c_master_unregister(struct
> i3c_master_controller *master)
> >   	i3c_master_i2c_adapter_cleanup(master);
> >   	i3c_master_unregister_i3c_devs(master);
> >   	i3c_master_bus_cleanup(master);
> > +	pm_runtime_disable(&master->dev);
> >   	device_unregister(&master->dev);
> >   }
> >   EXPORT_SYMBOL_GPL(i3c_master_unregister);
> 
> --
> linux-i3c mailing list
> linux-i3c@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-i3c

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v1] i3c: master: Enable runtime PM for master controller
  2024-03-15  8:05   ` Joshua Yeong
@ 2024-03-15 13:46     ` Mukesh Kumar Savaliya
  0 siblings, 0 replies; 5+ messages in thread
From: Mukesh Kumar Savaliya @ 2024-03-15 13:46 UTC (permalink / raw)
  To: Joshua Yeong, alexandre.belloni, linux-i3c, linux-kernel
  Cc: andersson, vkoul, manivannan.sadhasivam

Hi Joshua,

On 3/15/2024 1:35 PM, Joshua Yeong wrote:
> 
> 
>> -----Original Message-----
>> From: linux-i3c <linux-i3c-bounces@lists.infradead.org> On Behalf Of Mukesh
>> Kumar Savaliya
>> Sent: Monday, March 11, 2024 1:30 AM
>> To: alexandre.belloni@bootlin.com; linux-i3c@lists.infradead.org; linux-
>> kernel@vger.kernel.org
>> Cc: andersson@kernel.org; vkoul@kernel.org;
>> manivannan.sadhasivam@linaro.org
>> Subject: Re: [PATCH v1] i3c: master: Enable runtime PM for master controller
>>
>> A Gentle reminder ! As i was not part of the linux-i3c group before raising this
>> gerrit, might not went into right folder.
>>
>> On 2/28/2024 3:04 PM, Mukesh Kumar Savaliya wrote:
>>> Enable runtime PM for i3c master node during master registration time.
>>>
>>> Sometimes i3c client device driver may want to control the PM of the
>>> parent (master) to perform the transactions and save the power in an
>>> efficient way by controlling the session. Hence device can call PM
>>> APIs by passing the parent node.
>>>
>>> Here, I3C target device when calls pm_runtime_get_sync(dev->parent)
>>> couldn't invoke master drivers runtime PM callback registered by the
>>> master driver because parent's PM status was disabled in the Master
>>> node.
>>>
>>> Also call pm_runtime_no_callbacks() and pm_suspend_ignore_children()
>>> for the master node to not have any callback addition and ignore the
>>> children to have runtime PM work just locally in the driver. This
>>> should be generic and common change for all i3c devices and should not
>>> have any other impact.
>>>
>>> With these changes, I3C client device works and able to invoke master
>>> driver registered runtime PM callbacks.
>>>
>>> Signed-off-by: Mukesh Kumar Savaliya <quic_msavaliy@quicinc.com>
>>> ---
>>>    drivers/i3c/master.c | 6 ++++++
>>>    1 file changed, 6 insertions(+)
>>>
>>> diff --git a/drivers/i3c/master.c b/drivers/i3c/master.c index
>>> 3afa530c5e32..a3dc88974f92 100644
>>> --- a/drivers/i3c/master.c
>>> +++ b/drivers/i3c/master.c
>>> @@ -13,6 +13,7 @@
>>>    #include <linux/kernel.h>
>>>    #include <linux/list.h>
>>>    #include <linux/of.h>
>>> +#include <linux/pm_runtime.h>
>>>    #include <linux/slab.h>
>>>    #include <linux/spinlock.h>
>>>    #include <linux/workqueue.h>
>>> @@ -2812,6 +2813,10 @@ int i3c_master_register(struct
>>> i3c_master_controller *master,
>>>
>>>    	i3c_bus_notify(i3cbus, I3C_NOTIFY_BUS_ADD);
>>>
>>> +	pm_runtime_no_callbacks(&master->dev);
>>> +	pm_suspend_ignore_children(&master->dev, true);
>>> +	pm_runtime_enable(&master->dev);
>>> +
> 
> Will runtime pm impact on ibi request from target?
Don't think so. This change just enables target device driver to call PM 
apis and control the transfers under RT resume and RT suspend.
IBI comes asynchronously to the master driver and it should get handled 
accordingly. .
> 
>>>    	/*
>>>    	 * We're done initializing the bus and the controller, we can now
>>>    	 * register I3C devices discovered during the initial DAA.
>>> @@ -2849,6 +2854,7 @@ void i3c_master_unregister(struct
>> i3c_master_controller *master)
>>>    	i3c_master_i2c_adapter_cleanup(master);
>>>    	i3c_master_unregister_i3c_devs(master);
>>>    	i3c_master_bus_cleanup(master);
>>> +	pm_runtime_disable(&master->dev);
>>>    	device_unregister(&master->dev);
>>>    }
>>>    EXPORT_SYMBOL_GPL(i3c_master_unregister);
>>
>> --
>> linux-i3c mailing list
>> linux-i3c@lists.infradead.org
>> http://lists.infradead.org/mailman/listinfo/linux-i3c

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v1] i3c: master: Enable runtime PM for master controller
  2024-02-28  9:34 [PATCH v1] i3c: master: Enable runtime PM for master controller Mukesh Kumar Savaliya
  2024-03-10 17:29 ` Mukesh Kumar Savaliya
@ 2024-05-07 21:05 ` Alexandre Belloni
  1 sibling, 0 replies; 5+ messages in thread
From: Alexandre Belloni @ 2024-05-07 21:05 UTC (permalink / raw)
  To: linux-i3c, linux-kernel, Mukesh Kumar Savaliya
  Cc: andersson, vkoul, manivannan.sadhasivam

On Wed, 28 Feb 2024 15:04:07 +0530, Mukesh Kumar Savaliya wrote:
> Enable runtime PM for i3c master node during master registration time.
> 
> Sometimes i3c client device driver may want to control the PM of the
> parent (master) to perform the transactions and save the power in an
> efficient way by controlling the session. Hence device can call PM
> APIs by passing the parent node.
> 
> [...]

Applied, thanks!

[1/1] i3c: master: Enable runtime PM for master controller
      https://git.kernel.org/abelloni/c/fe23b69d78d7

Best regards,

-- 
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-05-07 21:05 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-28  9:34 [PATCH v1] i3c: master: Enable runtime PM for master controller Mukesh Kumar Savaliya
2024-03-10 17:29 ` Mukesh Kumar Savaliya
2024-03-15  8:05   ` Joshua Yeong
2024-03-15 13:46     ` Mukesh Kumar Savaliya
2024-05-07 21:05 ` Alexandre Belloni

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®