On Thu, Jun 20, 2019 at 1:48 PM Alexandre Courbot <acourbot@xxxxxxxxxxxx> wrote: > > On Tue, Jun 4, 2019 at 8:20 PM Tomasz Figa <tfiga@xxxxxxxxxxxx> wrote: > > > + > > > + ret = mdp_vpu_get_locked(mdp); > > > + if (ret < 0) > > > + goto err_load_vpu; > > > > This shouldn't happen in open(), but rather the latest possible point in > > time. If one needs to keep the VPU running for the time of streaming, then > > it should be start_streaming. If one can safely turn the VPU off if there is > > no frame queued for long time, it should be just in m2m job_run. > > > > Generally the userspace should be able to > > just open an m2m device for querying it, without any side effects like > > actually powering on the hardware or grabbing a hardware instance (which > > could block some other processes, trying to grab one too). > > OTOH looking at the code of mdp_vpu_get_locked(), we do the whole > rproc_boot and VPU init procedure if we were the only user. So I can > understand we want to avoid doing this too often. > > Maybe mdp_vpu_get_locked() can be reorganized in a better way. I feel > like the call to mdp_vpu_register() should be done in probe, and maybe > we can use runtime PM (with a reasonable timeout) to control the rproc > and VPU init? I think it depends on when exactly the rproc and VPU need stay initialized. In general, we want to turn off as much as possible as quickly as possible, but keeping in mind any turn on latencies. For example. if it takes 10 ms to boot rproc/VPU, we probably shouldn't turn it off unless we already spent 20-30 ms idling, which could be handled with runtime PM with (delayed) autosuspend. However, things like clock gating are normally very fast, so we could just stop any clocks as soon as frame processing ends and restart when next frame is getting scheduled and if we use autosuspend, we wouldn't be able to do it using PM runtime. My point was that just open() is not the right place for doing this. Any later stage should be okay, as long as it suits the hardware architecture. Best regards, Tomasz