Skip to contentSkip to conversation

sky2: Correct mistakenly switched read/write sequence

PATCH Lino Sanfilippo 3 participants 4 messages Dec 1, 2012

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

In sky2_all_down() the order of the read()/write() access to B0_IMSK seems to be mistakenly switched. The original intention was obviously to avoid PCI write posting.
This patch fixes the order.

---
 drivers/net/ethernet/marvell/sky2.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/marvell/sky2.c +1 -1
index 78946fe..b20d2fd 100644
@@ -3481,8 +3481,8 @@ static void sky2_all_down(struct sky2_hw *hw)
 	int i;
 
 	if (hw->flags & SKY2_HW_IRQ_SETUP) {
-		sky2_read32(hw, B0_IMSK);
 		sky2_write32(hw, B0_IMSK, 0);
+		sky2_read32(hw, B0_IMSK);
 
 		synchronize_irq(hw->pdev->irq);
 		napi_disable(&hw->napi);
Signature · 1 line
1.7.9.5
maintainer Acked-by Stephen Hemminger
#1 lore raw

From: Lino Sanfilippo <[email protected]>
Date: Sat, 1 Dec 2012 13:42:39 +0100

Quoted 6 lines

In sky2_all_down() the order of the read()/write() access to B0_IMSK seems to be mistakenly switched. The original intention was obviously to avoid PCI write posting.
This patch fixes the order.

I would say that no such intention exists at all.

The read is there because a long time ago the result as used to compute an 'imask' variable.

Please see commit:

commit d72ff8fa7f8b344382963721f842256825c4660b

Author: Mike McCormack <[email protected]>
Date:   Thu May 13 06:12:51 2010 +0000

sky2: Refactor down/up code out of sky2_restart()

Code to bring down all sky2 interfaces and bring it up again can be reused in sky2_suspend and sky2_resume.

Factor the code to bring the interfaces down into sky2_all_down and the up code into sky2_all_up.

#3 lore raw
In reply to Lino Sanfilippo
Quoted 6 lines · On Sat, 1 Dec 2012 13:42:39 +0100 Lino Sanfilippo <[email protected]> wrote:

In sky2_all_down() the order of the read()/write() access to B0_IMSK seems to be mistakenly switched. The original intention was obviously to avoid PCI write posting.
This patch fixes the order.

You are both right. David is correct in that the original code here was quite different and was doing save/restore of irq mask. That changed as driver evolved to only bring up IRQ if device was brought up. At which point the read of irq mask was a left over call.

Lino is correct, it makes sense to do read after write to ensure PCI posting. So I agree with the patch, but would like the commit message changed slightly.

#2 lore raw
In reply to David Miller
Quoted 8 lines · David Miller
Quoted 7 lines

In sky2_all_down() the order of the read()/write() access to B0_IMSK seems to be mistakenly switched. The original intention was obviously to avoid PCI write posting.
This patch fixes the order.

Quoted 8 lines

I would say that no such intention exists at all.

The read is there because a long time ago the result as used to compute an 'imask' variable.

Please see commit:

commit d72ff8fa7f8b344382963721f842256825c4660b

I see. Indeed I was not aware of the history that led to the recent code, so thanks for pointing that out.

However, since Stephen thinks the patch is useful nevertheless:
@Stephen please feel free to adjust the commit message as you think would make the most sense.

Regards,
Lino