On Mon, Feb 04, 2019 at 05:28:23PM +0300, Dmitry Osipenko wrote: > 04.02.2019 17:00, Thierry Reding пишет: > > On Mon, Feb 04, 2019 at 03:03:49PM +0300, Dmitry Osipenko wrote: > >> 04.02.2019 14:05, Thierry Reding пишет: > >>> On Mon, Feb 04, 2019 at 09:53:32AM +0000, Jon Hunter wrote: > >>>> > >>>> > >>>> On 04/02/2019 08:45, Thierry Reding wrote: > >>>> > >>>> ... > >>>> > >>>>> The idea was, as I was saying below, to reuse dev_pm_ops even if > >>>>> !CONFIG_PM. So pm_runtime_enable() could be something like this: > >>>>> > >>>>> pm_runtime_enable(dev) > >>>>> { > >>>>> if (!CONFIG_PM) > >>>>> if (dev->pm_ops->resume) > >>>>> dev->pm_ops->resume(dev); > >>>>> > >>>>> ... > >>>>> } > >>>>> > >>>>> But that's admittedly somewhat of a stretch. This could of course be > >>>>> made somewhat nicer by adding an explicit variant, say: > >>>>> > >>>>> pm_runtime_enable_foo(dev) > >>>>> { > >>>>> if (!CONFIG_PM && dev->pm_ops->resume) > >>>>> return dev->pm_ops->resume(dev); > >>>>> > >>>>> return 0; > >>>>> } > >>>>> > >>>>> Maybe the fact that I couldn't come up with a good name is a good > >>>>> indication that this is a bad idea... > >>>> > >>>> How about some new APIs called ... > >>>> > >>>> pm_runtime_enable_get() > >>>> pm_runtime_enable_get_sync() > >>>> pm_runtime_put_disable() (implies a put_sync) > >>>> > >>>> ... and in these APIs we add ... > >>>> > >>>> pm_runtime_enable_get(dev) > >>>> { > >>>> if (!CONFIG_PM && dev->pm_ops->resume) > >>>> return dev->pm_ops->resume(dev); > >>>> > >>>> pm_runtime_enable(dev); > >>>> return pm_runtime_get(dev); > >>>> } > >>> > >>> Yeah, those sound sensible. I'm still a bit torn between this and just > >>> enforcing PM. At least on the display side I think we already require PM > >>> and with all the power domain work that you did we'd be much better off > >>> if we could just get rid of the !PM workarounds. > >>> > >>>>>>> This would be somewhat tricky because drivers > >>>>>>> usually use SET_RUNTIME_PM_OPS to populate the struct dev_pm_ops and > >>>>>>> that would result in an empty structure if !CONFIG_PM, but we could > >>>>>>> probably work around that by adding a __SET_RUNTIME_PM_OPS that would > >>>>>>> never be compiled out for this kind of case. Or such drivers could even > >>>>>>> manually set .runtime_suspend and .runtime_resume to make sure they're > >>>>>>> always populated. > >>>>>>> > >>>>>>> Another way out of this would be to make sure we never run into the case > >>>>>>> where runtime PM is disabled. If we always "select PM" on Tegra, then PM > >>>>>>> should always be available. But is it guaranteed that runtime PM for the > >>>>>>> devices is functional in that case? From a cursory look at the code it > >>>>>>> would seem that way. > >>>>>> > >>>>>> If you select PM, then all of the requisite code should be there. > >>>>> > >>>>> We do this on 64-bit ARM, but there had been some pushback when we had > >>>>> proposed to do the same thing on 32-bit ARM. I think there were two > >>>>> concerns: > >>>>> > >>>>> 1) select PM would force the setting for all platforms on multi- > >>>>> platforms builds > >>>>> > >>>>> 2) prevents anyone from disabling PM for debugging purposes > >>>>> > >>>>> 1) no longer seems to be valid because Rockchip already selects PM > >>>>> unconditionally. I'm not sure if 2) is valid anymore either. I haven't > >>>>> run a build with !PM in a very long time and I wouldn't be surprised if > >>>>> that was completely broken. > >>>>> > >>>>> Maybe we need to try this again since a couple of years have elapsed and > >>>>> runtime PM support on Tegra is much more mature at this point. > >>>>> > >>>>>> Alternatively, you can make the driver depend on PM. > >>>>> > >>>>> That's probably the easiest way out, but to be honest I think I'd prefer > >>>>> to just enforce PM and keep things simple. > >>>>> > >>>>> Jon, any objections? > >>>> > >>>> None, but seems overkill just for this case. > >>> > >>> But that's precisely the point. It's not just about this case. We've > >>> already got some drivers where we do a similar dance just to be able to > >>> support the, let's admit it, exotic case where somebody turns off PM. I > >>> think supporting !PM might have made sense at a point where we had no > >>> support for power management at all. But I think we've come a long way > >>> since then, and while we may still have some ways to go in some areas, > >>> we do fairly decent runtime PM most of the time, to the point where I no > >>> longer see any benefits in !PM. > >> > >> I'm requesting PM_DEBUG_ALWAYS_ON option then! Disabling PM is a > >> useful debug feature, it can't just go away. > > > > What is it about disabling PM that you consider useful? I can understand > > why you'd want that option if power management is broken, but as far as > > I can tell, power management on Tegra is in pretty good state, and it's > > more likely that !PM would actually be broken (though I haven't built a > > configuration like that in a couple of years, so I'm speculating). We > > already can't disable PM on 64-bit ARM, so I don't understand why 32-bit > > ARM should be treated any differently. > > Yes, I want an option for debugging of a broken PM. It doesn't matter > that there are no known PM-related issues on Tegra today, it could > become a problem tomorrow. Probably a kernel boot parameter like > pm_debug_always_on would suit even better here. > > Or maybe PM API already provides such debug options and I'm just not > aware about them? I'm not sure I understand what you're trying to do. If you want to use !PM as a way to debug broken PM, how would that help? Presumably if you disable !PM then the problem would be gone? In other words, in order to reproduce a PM related issue don't you have to enable PM first? I'm not aware of an alternate mechanism to force PM to off once built into the kernel. > Do you know what's the exact reason for ARM64 to not support !PM? There's no reason per se not to support PM. It's just that at the time we made the decision that we didn't want to. I vaguely remember that we tried to do the same thing for 32-bit ARM, but at the time we would've been the only platform to select PM, and that would've meant enabling PM for all subarchitectures and therefore forcing PM in multi-platform builds. Today if you build multi-platform kernels, at least Rockchip will also forcibly enable PM for everyone. I think you may also have objected at the time for similar reasons. But this was a long time ago (at least 2 to 3 years I would guess) and much has changed since then. Power management has gotten a lot better on Tegra, to the point where we actually need it in order to properly function. For example, Tegra DRM is not going to work with !PM because we rely on runtime PM while disabling and enabling display pipelines. Thierry
Attachment:
signature.asc
Description: PGP signature
_______________________________________________ Alsa-devel mailing list Alsa-devel@xxxxxxxxxxxxxxxx http://mailman.alsa-project.org/mailman/listinfo/alsa-devel