Skip to contentSkip to conversation

staging: mt7621-dma: mtk-hsdma: make a variable non-volatile

PATCH In review Lourdes Pedrajas 3 participants 6 messages Mar 12, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging: mt7621-dma: mtk-hsdma: make a variable non-volatile

Change variable declaration volatile unsigned long chan_issued to unsigned long chan_issued

Use of volatile is usually wrong: see Documentation/process/volatile-considered-harmful.rst

Issue found with checkpatch.pl

---
 drivers/staging/mt7621-dma/mtk-hsdma.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/mt7621-dma/mtk-hsdma.c +1 -1
index 20b898954416..e146c5bb5609 100644
@@ -157,7 +157,7 @@ struct mtk_hsdam_engine {
 	struct device_dma_parameters dma_parms;
 	void __iomem *base;
 	struct tasklet_struct task;
-	volatile unsigned long chan_issued;
+	unsigned long chan_issued;
 
 	struct mtk_hsdma_chan chan[1];
 };
Signature · 1 line
2.17.1
maintainer
#1 lore raw
Quoted 17 lines · Lourdes Pedrajas

Change variable declaration volatile unsigned long chan_issued to unsigned long chan_issued

Use of volatile is usually wrong: see Documentation/process/volatile-considered-harmful.rst

Issue found with checkpatch.pl

---
 drivers/staging/mt7621-dma/mtk-hsdma.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/mt7621-dma/mtk-hsdma.c +0 -0
index 20b898954416..e146c5bb5609 100644

drivers/staging/mt7621-dma/mtk-hsdma.c struct mtk_hsdam_engine { · line 160

Quoted 5 lines
drivers/staging/mt7621-dma/mtk-hsdma.c +1 -1
@@ -157,7 +157,7 @@ struct mtk_hsdam_engine {
 	struct device_dma_parameters dma_parms;
 	void __iomem *base;
 	struct tasklet_struct task;
-	volatile unsigned long chan_issued;
+	unsigned long chan_issued;

Are you sure this is correct? Usually a change like this also requires some kind of lock somewhere to ensure things work properly (not that it is not working properly today...)

But it's not always as simple as just removing 'volatile', otherwise that would have been done already.

Please do more work to determine if this is a safe change or not and write it all up in the changelog.

thanks,

greg k-h

#2 lore raw
In reply to Lourdes Pedrajas
Quoted 4 lines · On Thu, 12 Mar 2020 13:15:48 +0100 Lourdes Pedrajas <[email protected]> wrote:

Change variable declaration volatile unsigned long chan_issued to unsigned long chan_issued

Use of volatile is usually wrong: see Documentation/process/volatile-considered-harmful.rst

This needs some more details. From that same guide:

Patches to remove volatile variables are generally welcome - as long as they come with a justification which shows that the concurrency issues have been properly thought through.

so, here you need to investigate what that "volatile" was supposed to achieve, if it is achieved by other means, if some form of locking is needed instead, if we end up in one of the "exception" cases also listed in that guide.

Signature · 1 line
Stefano
#3 lore raw
Quoted 17 lines · Greg KH
Quoted 2 lines · Lourdes Pedrajas

Change variable declaration volatile unsigned long chan_issued to unsigned long chan_issued

Are you sure this is correct? Usually a change like this also requires some kind of lock somewhere to ensure things work properly (not that it is not working properly today...)

But it's not always as simple as just removing 'volatile', otherwise that would have been done already.

Please do more work to determine if this is a safe change or not and write it all up in the changelog.

thanks,

greg k-h

Quoted 10 lines · Stefano Brivio
Quoted 4 lines · On Thu, 12 Mar 2020 13:15:48 +0100 Lourdes Pedrajas <[email protected]> wrote:

Change variable declaration volatile unsigned long chan_issued to unsigned long chan_issued

Use of volatile is usually wrong: see Documentation/process/volatile-considered-harmful.rst

This needs some more details. From that same guide:

Quoted 12 lines

Patches to remove volatile variables are generally welcome - as long as they come with a justification which shows that the concurrency issues have been properly thought through.

so, here you need to investigate what that "volatile" was supposed to achieve, if it is achieved by other means, if some form of locking is needed instead, if we end up in one of the "exception" cases also listed in that guide.

Signature · 1 line
Stefano

Indeed, both of you are right. Thank you for pointing me in the right direction! However, as someone who is new in programming, I find I lack the knowledge needed to tackle concurrency and locks. Nevertheless, I will do some research to learn a bit to see if it can be done in a reasonable amount of time. Sorry :(

Lourdes

maintainer
#4 lore raw
Quoted 43 lines · Lourdes Pedrajas
Quoted 17 lines · Greg KH
Quoted 2 lines · Lourdes Pedrajas

Change variable declaration volatile unsigned long chan_issued to unsigned long chan_issued

Are you sure this is correct? Usually a change like this also requires some kind of lock somewhere to ensure things work properly (not that it is not working properly today...)

But it's not always as simple as just removing 'volatile', otherwise that would have been done already.

Please do more work to determine if this is a safe change or not and write it all up in the changelog.

thanks,

greg k-h

Quoted 10 lines · Stefano Brivio
Quoted 4 lines · On Thu, 12 Mar 2020 13:15:48 +0100 Lourdes Pedrajas <[email protected]> wrote:

Change variable declaration volatile unsigned long chan_issued to unsigned long chan_issued

Use of volatile is usually wrong: see Documentation/process/volatile-considered-harmful.rst

This needs some more details. From that same guide:

Quoted 12 lines

Patches to remove volatile variables are generally welcome - as long as they come with a justification which shows that the concurrency issues have been properly thought through.

so, here you need to investigate what that "volatile" was supposed to achieve, if it is achieved by other means, if some form of locking is needed instead, if we end up in one of the "exception" cases also listed in that guide.

Signature · 1 line
Stefano
Quoted 6 lines

Indeed, both of you are right. Thank you for pointing me in the right direction! However, as someone who is new in programming, I find I lack the knowledge needed to tackle concurrency and locks. Nevertheless, I will do some research to learn a bit to see if it can be done in a reasonable amount of time. Sorry :(

If you are new to programming, I would focus on other things. Concurrency and locks are not exactly "simple" things, but they are essencial to learn to be a kernel programmer.

good luck!

greg k-h

#5 lore raw
Quoted 5 lines · Greg KH
Quoted 2 lines · Lourdes Pedrajas
Quoted 1 line · Greg KH

On Thu, Mar 12, 2020 at 01:15:48PM +0100, Lourdes Pedrajas wrote:

If you are new to programming, I would focus on other things.

Thank for your advice.

Quoted 2 lines

Concurrency and locks are not exactly "simple" things, but they are essencial to learn to be a kernel programmer.

I know, I am willing to learn it. Thanks for your patience!

Quoted 4 lines

good luck!

greg k-h