Message ID | 20241004094101.113349-1-sakari.ailus@linux.intel.com |
---|---|
Headers | show |
Series | treewide: Switch to __pm_runtime_put_autosuspend() | expand |
Am Fri, 4 Oct 2024 12:41:23 +0300 schrieb Sakari Ailus <sakari.ailus@linux.intel.com>: > pm_runtime_put_autosuspend() will soon be changed to include a call to > pm_runtime_mark_last_busy(). This patch switches the current users to > __pm_runtime_put_autosuspend() which will continue to have the > functionality of old pm_runtime_put_autosuspend(). > > Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> > --- > drivers/input/keyboard/omap4-keypad.c | 8 ++++---- > 1 file changed, 4 insertions(+), 4 deletions(-) > > diff --git a/drivers/input/keyboard/omap4-keypad.c > b/drivers/input/keyboard/omap4-keypad.c index > 040b340995d8..cc8d77601fc7 100644 --- > a/drivers/input/keyboard/omap4-keypad.c +++ > b/drivers/input/keyboard/omap4-keypad.c @@ -196,7 +196,7 @@ static > irqreturn_t omap4_keypad_irq_thread_fn(int irq, void *dev_id) > kbd_read_irqreg(keypad_data, OMAP4_KBD_IRQSTATUS)); > pm_runtime_mark_last_busy(dev); > - pm_runtime_put_autosuspend(dev); > + __pm_runtime_put_autosuspend(dev); > > return IRQ_HANDLED; > } > @@ -234,7 +234,7 @@ static int omap4_keypad_open(struct input_dev > *input) > out: > pm_runtime_mark_last_busy(dev); > - pm_runtime_put_autosuspend(dev); > + __pm_runtime_put_autosuspend(dev); > hmm, if pm_runtime_put_autosuspend() will include the call to pm_runtime_mark_last_busy(), then why is this change needed? After the change, the mark_last_busy could be removed. Regards, Andreas
Hi Andreas, On Fri, Oct 04, 2024 at 11:55:11AM +0200, Andreas Kemnade wrote: > Am Fri, 4 Oct 2024 12:41:23 +0300 > schrieb Sakari Ailus <sakari.ailus@linux.intel.com>: > > > pm_runtime_put_autosuspend() will soon be changed to include a call to > > pm_runtime_mark_last_busy(). This patch switches the current users to > > __pm_runtime_put_autosuspend() which will continue to have the > > functionality of old pm_runtime_put_autosuspend(). > > > > Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> > > --- > > drivers/input/keyboard/omap4-keypad.c | 8 ++++---- > > 1 file changed, 4 insertions(+), 4 deletions(-) > > > > diff --git a/drivers/input/keyboard/omap4-keypad.c > > b/drivers/input/keyboard/omap4-keypad.c index > > 040b340995d8..cc8d77601fc7 100644 --- > > a/drivers/input/keyboard/omap4-keypad.c +++ > > b/drivers/input/keyboard/omap4-keypad.c @@ -196,7 +196,7 @@ static > > irqreturn_t omap4_keypad_irq_thread_fn(int irq, void *dev_id) > > kbd_read_irqreg(keypad_data, OMAP4_KBD_IRQSTATUS)); > > pm_runtime_mark_last_busy(dev); > > - pm_runtime_put_autosuspend(dev); > > + __pm_runtime_put_autosuspend(dev); > > > > return IRQ_HANDLED; > > } > > @@ -234,7 +234,7 @@ static int omap4_keypad_open(struct input_dev > > *input) > > out: > > pm_runtime_mark_last_busy(dev); > > - pm_runtime_put_autosuspend(dev); > > + __pm_runtime_put_autosuspend(dev); > > > hmm, if pm_runtime_put_autosuspend() will include the call to > pm_runtime_mark_last_busy(), then why is this change needed? > After the change, the mark_last_busy could be removed. It could, in which case we'd be living with pm_runtime_mark_last_busy() called twice, for some time, and for some code, possibly even in a release kernel, depending on how well the patches "stick". It likely wouldn't be harmful. Still, to avoid making functional changes to more than 350 files I know little about, I've instead posted this set to prepare for pm_runtime_put_autosuspend() functionality change while keeping the functionality of the code exactly the same. Also added Ilpo who had a similar question.
Hi Ulf, On Tue, Oct 08, 2024 at 12:08:24AM +0200, Ulf Hansson wrote: > On Mon, 7 Oct 2024 at 20:49, Laurent Pinchart wrote: > > On Fri, Oct 04, 2024 at 04:38:36PM +0200, Ulf Hansson wrote: > > > On Fri, 4 Oct 2024 at 11:41, Sakari Ailus wrote: > > > > > > > > Hello everyone, > > > > > > > > This set will switch the users of pm_runtime_put_autosuspend() to > > > > __pm_runtime_put_autosuspend() while the former will soon be re-purposed > > > > to include a call to pm_runtime_mark_last_busy(). The two are almost > > > > always used together, apart from bugs which are likely common. Going > > > > forward, most new users should be using pm_runtime_put_autosuspend(). > > > > > > > > Once this conversion is done and pm_runtime_put_autosuspend() re-purposed, > > > > I'll post another set to merge the calls to __pm_runtime_put_autosuspend() > > > > and pm_runtime_mark_last_busy(). > > > > > > That sounds like it could cause a lot of churns. > > > > > > Why not add a new helper function that does the > > > pm_runtime_put_autosuspend() and the pm_runtime_mark_last_busy() > > > things? Then we can start moving users over to this new interface, > > > rather than having this intermediate step? > > > > I think the API would be nicer if we used the shortest and simplest > > function names for the most common use cases. Following > > pm_runtime_put_autosuspend() with pm_runtime_mark_last_busy() is that > > most common use case. That's why I like Sakari's approach of repurposing > > pm_runtime_put_autosuspend(), and introducing > > __pm_runtime_put_autosuspend() for the odd cases where > > pm_runtime_mark_last_busy() shouldn't be called. > > Okay, so the reason for this approach is because we couldn't find a > short and descriptive name that could be used in favor of > pm_runtime_put_autosuspend(). Let me throw some ideas at it and maybe > you like it - or not. :-) I like the idea at least :-) > I don't know what options you guys discussed, but to me the entire > "autosuspend"-suffix isn't really that necessary in my opinion. There > are more ways than calling pm_runtime_put_autosuspend() that triggers > us to use the RPM_AUTO flag for rpm_suspend(). For example, just > calling pm_runtime_put() has the similar effect. To be honest, I'm lost there. pm_runtime_put() calls __pm_runtime_idle(RPM_GET_PUT | RPM_ASYNC), while pm_runtime_put_autosuspend() calls __pm_runtime_suspend(RPM_GET_PUT | RPM_ASYNC | RPM_AUTO). > > Moreover, it's similar for pm_runtime_mark_last_busy(), it's called > during rpm_resume() too, for example. So why bother about having > "mark_last_busy" in the new name too. > > That said, my suggestion is simply "pm_runtime_put_suspend". Can we do even better, and make pm_runtime_put() to handle autosuspend automatically when autosuspend is enabled ? > If you don't like it, I will certainly not object to your current > approach, even if I think it leads to unnecessary churns. > > [...] > > Kind regards > Uffe
On Tue, 8 Oct 2024 at 00:25, Laurent Pinchart <laurent.pinchart@ideasonboard.com> wrote: > > Hi Ulf, > > On Tue, Oct 08, 2024 at 12:08:24AM +0200, Ulf Hansson wrote: > > On Mon, 7 Oct 2024 at 20:49, Laurent Pinchart wrote: > > > On Fri, Oct 04, 2024 at 04:38:36PM +0200, Ulf Hansson wrote: > > > > On Fri, 4 Oct 2024 at 11:41, Sakari Ailus wrote: > > > > > > > > > > Hello everyone, > > > > > > > > > > This set will switch the users of pm_runtime_put_autosuspend() to > > > > > __pm_runtime_put_autosuspend() while the former will soon be re-purposed > > > > > to include a call to pm_runtime_mark_last_busy(). The two are almost > > > > > always used together, apart from bugs which are likely common. Going > > > > > forward, most new users should be using pm_runtime_put_autosuspend(). > > > > > > > > > > Once this conversion is done and pm_runtime_put_autosuspend() re-purposed, > > > > > I'll post another set to merge the calls to __pm_runtime_put_autosuspend() > > > > > and pm_runtime_mark_last_busy(). > > > > > > > > That sounds like it could cause a lot of churns. > > > > > > > > Why not add a new helper function that does the > > > > pm_runtime_put_autosuspend() and the pm_runtime_mark_last_busy() > > > > things? Then we can start moving users over to this new interface, > > > > rather than having this intermediate step? > > > > > > I think the API would be nicer if we used the shortest and simplest > > > function names for the most common use cases. Following > > > pm_runtime_put_autosuspend() with pm_runtime_mark_last_busy() is that > > > most common use case. That's why I like Sakari's approach of repurposing > > > pm_runtime_put_autosuspend(), and introducing > > > __pm_runtime_put_autosuspend() for the odd cases where > > > pm_runtime_mark_last_busy() shouldn't be called. > > > > Okay, so the reason for this approach is because we couldn't find a > > short and descriptive name that could be used in favor of > > pm_runtime_put_autosuspend(). Let me throw some ideas at it and maybe > > you like it - or not. :-) > > I like the idea at least :-) > > > I don't know what options you guys discussed, but to me the entire > > "autosuspend"-suffix isn't really that necessary in my opinion. There > > are more ways than calling pm_runtime_put_autosuspend() that triggers > > us to use the RPM_AUTO flag for rpm_suspend(). For example, just > > calling pm_runtime_put() has the similar effect. > > To be honest, I'm lost there. pm_runtime_put() calls > __pm_runtime_idle(RPM_GET_PUT | RPM_ASYNC), while > pm_runtime_put_autosuspend() calls __pm_runtime_suspend(RPM_GET_PUT | > RPM_ASYNC | RPM_AUTO). __pm_runtime_idle() ends up calling rpm_idle(), which may call rpm_suspend() - if it succeeds to idle the device. In that case, it tags on the RPM_AUTO flag in the call to rpm_suspend(). Quite similar to what is happening when calling pm_runtime_put_autosuspend(). > > > > > Moreover, it's similar for pm_runtime_mark_last_busy(), it's called > > during rpm_resume() too, for example. So why bother about having > > "mark_last_busy" in the new name too. > > > > That said, my suggestion is simply "pm_runtime_put_suspend". > > Can we do even better, and make pm_runtime_put() to handle autosuspend > automatically when autosuspend is enabled ? As stated above, this is already the case. > > > If you don't like it, I will certainly not object to your current > > approach, even if I think it leads to unnecessary churns. > > > > [...] > > > > Kind regards > > Uffe > > -- > Regards, > > Laurent Pinchart Kind regards Uffe
On Tue, Oct 8, 2024 at 12:35 AM Ulf Hansson <ulf.hansson@linaro.org> wrote: > > On Tue, 8 Oct 2024 at 00:25, Laurent Pinchart > <laurent.pinchart@ideasonboard.com> wrote: > > > > Hi Ulf, > > > > On Tue, Oct 08, 2024 at 12:08:24AM +0200, Ulf Hansson wrote: > > > On Mon, 7 Oct 2024 at 20:49, Laurent Pinchart wrote: > > > > On Fri, Oct 04, 2024 at 04:38:36PM +0200, Ulf Hansson wrote: > > > > > On Fri, 4 Oct 2024 at 11:41, Sakari Ailus wrote: > > > > > > > > > > > > Hello everyone, > > > > > > > > > > > > This set will switch the users of pm_runtime_put_autosuspend() to > > > > > > __pm_runtime_put_autosuspend() while the former will soon be re-purposed > > > > > > to include a call to pm_runtime_mark_last_busy(). The two are almost > > > > > > always used together, apart from bugs which are likely common. Going > > > > > > forward, most new users should be using pm_runtime_put_autosuspend(). > > > > > > > > > > > > Once this conversion is done and pm_runtime_put_autosuspend() re-purposed, > > > > > > I'll post another set to merge the calls to __pm_runtime_put_autosuspend() > > > > > > and pm_runtime_mark_last_busy(). > > > > > > > > > > That sounds like it could cause a lot of churns. > > > > > > > > > > Why not add a new helper function that does the > > > > > pm_runtime_put_autosuspend() and the pm_runtime_mark_last_busy() > > > > > things? Then we can start moving users over to this new interface, > > > > > rather than having this intermediate step? > > > > > > > > I think the API would be nicer if we used the shortest and simplest > > > > function names for the most common use cases. Following > > > > pm_runtime_put_autosuspend() with pm_runtime_mark_last_busy() is that > > > > most common use case. That's why I like Sakari's approach of repurposing > > > > pm_runtime_put_autosuspend(), and introducing > > > > __pm_runtime_put_autosuspend() for the odd cases where > > > > pm_runtime_mark_last_busy() shouldn't be called. > > > > > > Okay, so the reason for this approach is because we couldn't find a > > > short and descriptive name that could be used in favor of > > > pm_runtime_put_autosuspend(). Let me throw some ideas at it and maybe > > > you like it - or not. :-) > > > > I like the idea at least :-) > > > > > I don't know what options you guys discussed, but to me the entire > > > "autosuspend"-suffix isn't really that necessary in my opinion. There > > > are more ways than calling pm_runtime_put_autosuspend() that triggers > > > us to use the RPM_AUTO flag for rpm_suspend(). For example, just > > > calling pm_runtime_put() has the similar effect. > > > > To be honest, I'm lost there. pm_runtime_put() calls > > __pm_runtime_idle(RPM_GET_PUT | RPM_ASYNC), while > > pm_runtime_put_autosuspend() calls __pm_runtime_suspend(RPM_GET_PUT | > > RPM_ASYNC | RPM_AUTO). > > __pm_runtime_idle() ends up calling rpm_idle(), which may call > rpm_suspend() - if it succeeds to idle the device. In that case, it > tags on the RPM_AUTO flag in the call to rpm_suspend(). Quite similar > to what is happening when calling pm_runtime_put_autosuspend(). Right. For almost everybody, except for a small bunch of drivers that actually have a .runtime_idle() callback, pm_runtime_put() is literally equivalent to pm_runtime_put_autosuspend(). So really the question is why anyone who doesn't provide a .runtime_idle() callback bothers with using this special pm_runtime_put_autosuspend() thing, which really means "do a runtime_put(), but skip my .runtime_idle() callback". > > > > > > > > Moreover, it's similar for pm_runtime_mark_last_busy(), it's called > > > during rpm_resume() too, for example. So why bother about having > > > "mark_last_busy" in the new name too. > > > > > > That said, my suggestion is simply "pm_runtime_put_suspend". > > > > Can we do even better, and make pm_runtime_put() to handle autosuspend > > automatically when autosuspend is enabled ? > > As stated above, this is already the case. What really is needed appears to be a combination of pm_runtime_mark_last_busy() with pm_runtime_put(). Granted, pm_runtime_put() could do the pm_runtime_mark_last_busy() thing automatically if autosuspend is enabled and the only consequence of it might be delaying a suspend of the device until its autosuspend timer expires, which should not be a problem in the vast majority of cases.
Hello, On Mon, Oct 07, 2024 at 09:49:24PM +0300, Laurent Pinchart wrote: > On Fri, Oct 04, 2024 at 04:38:36PM +0200, Ulf Hansson wrote: > > On Fri, 4 Oct 2024 at 11:41, Sakari Ailus <sakari.ailus@linux.intel.com> wrote: > > > > > > Hello everyone, > > > > > > This set will switch the users of pm_runtime_put_autosuspend() to > > > __pm_runtime_put_autosuspend() while the former will soon be re-purposed > > > to include a call to pm_runtime_mark_last_busy(). The two are almost > > > always used together, apart from bugs which are likely common. Going > > > forward, most new users should be using pm_runtime_put_autosuspend(). > > > > > > Once this conversion is done and pm_runtime_put_autosuspend() re-purposed, > > > I'll post another set to merge the calls to __pm_runtime_put_autosuspend() > > > and pm_runtime_mark_last_busy(). > > > > That sounds like it could cause a lot of churns. > > > > Why not add a new helper function that does the > > pm_runtime_put_autosuspend() and the pm_runtime_mark_last_busy() > > things? Then we can start moving users over to this new interface, > > rather than having this intermediate step? > > I think the API would be nicer if we used the shortest and simplest > function names for the most common use cases. Following > pm_runtime_put_autosuspend() with pm_runtime_mark_last_busy() is that > most common use case. That's why I like Sakari's approach of repurposing > pm_runtime_put_autosuspend(), and introducing > __pm_runtime_put_autosuspend() for the odd cases where > pm_runtime_mark_last_busy() shouldn't be called. That's ok for me. However this patch series isn't the optimal path to there because most drivers (i.e. those that already today do pm_runtime_mark_last_busy() in combination with pm_runtime_put_autosuspend()) have to be patched twice. The saner route is: Only convert the drivers with a sole pm_runtime_put_autosuspend() (i.e. without pm_runtime_mark_last_busy()) to __pm_runtime_put_autosuspend(). Then add the mark_last_busy() bits to pm_runtime_put_autosuspend() and then drop the explicit calls to pm_runtime_mark_last_busy() before pm_runtime_put_autosuspend(). (Note this doesn't take into account Rafael's position that pm_runtime_put() might be the saner option. My argument applies for that conversion analogously.) Best regards Uwe