Re: [PM-WIP_CPUFREQ][PATCH V3 6/8] OMAP2+: cpufreq: fix freq_table leak

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, May 25, 2011 at 18:25, Todd Poynor <toddpoynor@xxxxxxxxxx> wrote:
> On Wed, May 25, 2011 at 04:38:51PM -0700, Nishanth Menon wrote:
>> Since we have multiple CPUs, the cpuinit call for CPU1 causes
>> freq_table of CPU0 to be overwritten. Instead, we maintain
>> a counter to keep track of cpus who use the cpufreq table
>> allocate it once(one freq table for all CPUs) and free them
>> once the last user is done with it. We also need to protect
>> freq_table and this new counter from updates from multiple
>> contexts to be on a safe side.
>>
>> Signed-off-by: Nishanth Menon <nm@xxxxxx>
>> ---
> ...
>>  static int freq_table_alloc(void)
>>  {
>> -     if (use_opp)
>> -             return opp_init_cpufreq_table(mpu_dev, &freq_table);
>> +     int ret = 0;
>>
>> -     clk_init_cpufreq_table(&freq_table);
>> -     if (!freq_table)
>> -             return -ENOMEM;
>> +     mutex_lock(&freq_table_lock);
>>
>> -     return 0;
>> +     freq_table_users++;
>> +     /* Did we allocate previously? */
>> +     if (freq_table_users - 1)
>> +             goto out;
>> +
>> +     /* no, so we allocate */
>> +     if (use_opp) {
>> +             ret = opp_init_cpufreq_table(mpu_dev, &freq_table);
>> +     } else {
>> +             clk_init_cpufreq_table(&freq_table);
>> +             if (!freq_table)
>> +                     ret = -ENOMEM;
>> +     }
>> +     /* if we did not allocate cleanly.. reduce user count */
>> +     if (!ret)
>> +             freq_table_users--;
>
> "if (ret)" intended?  ret == 0 means allocated OK.

arrgh.. yikes..

Regards,
Nishanth Menon
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Arm (vger)]     [ARM Kernel]     [ARM MSM]     [Linux Tegra]     [Linux WPAN Networking]     [Linux Wireless Networking]     [Maemo Users]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Trails]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux