<div dir="ltr">Thanks a lot Valdis. These are very helpful pointers to look into.<br><div><br></div><div>Regards, </div><div>Ankit</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Feb 9, 2022 at 10:06 PM Valdis Klētnieks <<a href="mailto:valdis.kletnieks@vt.edu">valdis.kletnieks@vt.edu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On Tue, 08 Feb 2022 23:26:54 +0530, Ankit Pandey said:<br>
<br>
> And I was asked to verify if there is some specific meaning is attached to<br>
> comment here (which was causing the issue).<br>
> I would be glad you could explain me how should I approach this issue? One<br>
> way would<br>
> be to rewrite that these variables could be defined as volatile (just add a<br>
> comment) and then compile driver and see that build goes through without<br>
> any error.<br>
<br>
It turns out that the C keyword 'volatile' usually doesn't actually do what<br>
needs to happen if a variable actually *is* volatile and subject to change<br>
while the executing thread isn't looking.<br>
<br>
There's a good documentation file on this:<br>
<br>
Documentation/process/volatile-considered-harmful.rst<br>
<br>
But in summary - "If you thought you needed 'volatile' in your code, you<br>
probably needed locking primitives instead".<br>
<br>
> Other way would be that try to understand what this function is supposed to<br>
> be doing and then figure out author's intent of putting volatile there. How<br>
> should I take decision on these (or if they are wrong approaches) ?<br>
<br>
Given that struct pwrctlr_priv already contains a mutex_lock,  what was<br>
probably *intended* was "the variables cpwm, tog, cpwm_tog, and tgt_rpwm are<br>
protected by the mutex_lock and may only be changed by the mutex holder, while<br>
pwr_mode, smart_ps, and alives are not subject to change on the fly".<br>
<br>
But actually reading and understanding the code would be required to verify<br>
that.<br>
<br>
<br>
</blockquote></div>