On Mon, Feb 03, 2025 at 06:18:29PM -0300, Gustavo Sousa wrote: > Quoting Vivi, Rodrigo (2025-02-03 17:59:19-03:00) > [...] > Perhaps Imre can explain this better, but I believe the point is that we > want to track increments to DC5 counter when we have DC6 enabled. That > driver-managed counter would be in dc6_allowed. > > Repeating Imre's suggestions with a minor tweak: > > 1. Before we tell the hardware that we are allowing DC6 (disable -> > DC6), we store the value of the current DC5 counter. > > 2. After we disable DC states from DC6 (DC6 -> disable), we read the DC5 > counter again and subtract the value from (1). The result would then be > added to the current value of dc6_allowed. Yes, with the actual delta being: DC5 counter read here - DC5 counter read at (1). > In (1) I think we should read the DC5 counter before we update > DC_STATE_EN, just to be sure we avoid some sort of race (although that > appears to be unlikely to happen). Yes, the orders you described in both (1) and (2) are correct (since a DC5 -> DC6 or DC6 -> DC5 transition is not possible). The dc6_allowed counter should be also updated before returning it to userspace via the debugfs entry, as I mentioned earlier (to account for the case where DC6 is enabled when the read happens). > During DC6 validation, if the test sees that dc6_allowed was > incremented, that means that the display engine reached a state where > the SOC would be able to put the display in DC6. Yes, that's my understanding. --Imre