• Achin Gupta's avatar
    psci: fix affinity level upgrade issue · 75f7367b
    Achin Gupta authored
    The psci implementation does not track target affinity level requests
    specified during cpu_suspend calls correctly as per the following
    example.
    
    1. cpu0.cluster0 calls cpu_suspend with the target affinity level as 0
    2. Only the cpu0.cluster0 is powered down while cluster0 remains
       powered up
    3. cpu1.cluster0 calls cpu_off to power itself down to highest
       possible affinity level
    4. cluster0 will be powered off even though cpu0.cluster0 does not
       allow cluster shutdown
    
    This patch introduces reference counts at affinity levels > 0 to track
    the number of cpus which want an affinity instance at level X to
    remain powered up. This instance can be turned off only if its
    reference count is 0. Cpus still undergo the normal state transitions
    (ON, OFF, ON_PENDING, SUSPEND) but the higher levels can only be
    either ON or OFF depending upon their reference count.
    
    The above issue is thus fixed as follows:
    
    1. cluster0's reference count is incremented by two when cpu0 and cpu1
       are initially powered on.
    
    2. cpu0.cluster0 calls cpu_suspend with the target affinity level as
       0. This does not affect the cluster0 reference count.
    
    3. Only the cpu0.cluster0 is powered down while cluster0 remains
       powered up as it has a non-zero reference count.
    
    4. cpu1.cluster0 call cpu_off to power itself down to highest possible
       affinity level. This decrements the cluster0 reference count.
    
    5. cluster0 is still not powered off since its reference count will at
       least be 1 due to the restriction placed by cpu0.
    
    Change-Id: I433dfe82b946f5f6985b1602c2de87800504f7a9
    75f7367b
psci_common.c 19 KB