Re: [1/2] ath9k: ar9002_mac: kill off ACCESS_ONCE()

2017-01-12 Thread Kalle Valo
Mark Rutland  wrote:
> For several reasons, it is desirable to use {READ,WRITE}_ONCE() in
> preference to ACCESS_ONCE(), and new code is expected to use one of the
> former. So far, there's been no reason to change most existing uses of
> ACCESS_ONCE(), as these aren't currently harmful.
> 
> However, for some new features (e.g. KTSAN / Kernel Thread Sanitizer),
> it is necessary to instrument reads and writes separately, which is not
> possible with ACCESS_ONCE(). This distinction is critical to correct
> operation.
> 
> It's possible to transform the bulk of kernel code using the Coccinelle
> script below. However, for some files (including the ath9k ar9002 mac
> driver), this mangles the formatting. As a preparatory step, this patch
> converts the driver to use {READ,WRITE}_ONCE() without said mangling.
> 
> 
> virtual patch
> 
> @ depends on patch @
> expression E1, E2;
> @@
> 
> - ACCESS_ONCE(E1) = E2
> + WRITE_ONCE(E1, E2)
> 
> @ depends on patch @
> expression E;
> @@
> 
> - ACCESS_ONCE(E)
> + READ_ONCE(E)
> 
> 
> Signed-off-by: Mark Rutland 
> Cc: ath9k-de...@qca.qualcomm.com
> Cc: Kalle Valo 
> Cc: linux-wirel...@vger.kernel.org
> Cc: ath9k-de...@lists.ath9k.org
> Cc: netdev@vger.kernel.org

2 patches applied to ath-next branch of ath.git, thanks.

d5a3a76a9cb8 ath9k: ar9002_mac: kill off ACCESS_ONCE()
50f3818196f5 ath9k: ar9003_mac: kill off ACCESS_ONCE()

-- 
https://patchwork.kernel.org/patch/9489799/

Documentation about submitting wireless patches and checking status
from patchwork:

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches



[PATCH 1/2] ath9k: ar9002_mac: kill off ACCESS_ONCE()

2016-12-27 Thread Mark Rutland
For several reasons, it is desirable to use {READ,WRITE}_ONCE() in
preference to ACCESS_ONCE(), and new code is expected to use one of the
former. So far, there's been no reason to change most existing uses of
ACCESS_ONCE(), as these aren't currently harmful.

However, for some new features (e.g. KTSAN / Kernel Thread Sanitizer),
it is necessary to instrument reads and writes separately, which is not
possible with ACCESS_ONCE(). This distinction is critical to correct
operation.

It's possible to transform the bulk of kernel code using the Coccinelle
script below. However, for some files (including the ath9k ar9002 mac
driver), this mangles the formatting. As a preparatory step, this patch
converts the driver to use {READ,WRITE}_ONCE() without said mangling.


virtual patch

@ depends on patch @
expression E1, E2;
@@

- ACCESS_ONCE(E1) = E2
+ WRITE_ONCE(E1, E2)

@ depends on patch @
expression E;
@@

- ACCESS_ONCE(E)
+ READ_ONCE(E)


Signed-off-by: Mark Rutland 
Cc: ath9k-de...@qca.qualcomm.com
Cc: Kalle Valo 
Cc: linux-wirel...@vger.kernel.org
Cc: ath9k-de...@lists.ath9k.org
Cc: netdev@vger.kernel.org
---
 drivers/net/wireless/ath/ath9k/ar9002_mac.c | 64 ++---
 1 file changed, 32 insertions(+), 32 deletions(-)

diff --git a/drivers/net/wireless/ath/ath9k/ar9002_mac.c 
b/drivers/net/wireless/ath/ath9k/ar9002_mac.c
index f816909..4b3c9b1 100644
--- a/drivers/net/wireless/ath/ath9k/ar9002_mac.c
+++ b/drivers/net/wireless/ath/ath9k/ar9002_mac.c
@@ -220,8 +220,8 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct 
ath_tx_info *i)
ads->ds_txstatus6 = ads->ds_txstatus7 = 0;
ads->ds_txstatus8 = ads->ds_txstatus9 = 0;
 
-   ACCESS_ONCE(ads->ds_link) = i->link;
-   ACCESS_ONCE(ads->ds_data) = i->buf_addr[0];
+   WRITE_ONCE(ads->ds_link, i->link);
+   WRITE_ONCE(ads->ds_data, i->buf_addr[0]);
 
ctl1 = i->buf_len[0] | (i->is_last ? 0 : AR_TxMore);
ctl6 = SM(i->keytype, AR_EncrType);
@@ -235,26 +235,26 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct 
ath_tx_info *i)
 
if ((i->is_first || i->is_last) &&
i->aggr != AGGR_BUF_MIDDLE && i->aggr != AGGR_BUF_LAST) {
-   ACCESS_ONCE(ads->ds_ctl2) = set11nTries(i->rates, 0)
+   WRITE_ONCE(ads->ds_ctl2, set11nTries(i->rates, 0)
| set11nTries(i->rates, 1)
| set11nTries(i->rates, 2)
| set11nTries(i->rates, 3)
| (i->dur_update ? AR_DurUpdateEna : 0)
-   | SM(0, AR_BurstDur);
+   | SM(0, AR_BurstDur));
 
-   ACCESS_ONCE(ads->ds_ctl3) = set11nRate(i->rates, 0)
+   WRITE_ONCE(ads->ds_ctl3, set11nRate(i->rates, 0)
| set11nRate(i->rates, 1)
| set11nRate(i->rates, 2)
-   | set11nRate(i->rates, 3);
+   | set11nRate(i->rates, 3));
} else {
-   ACCESS_ONCE(ads->ds_ctl2) = 0;
-   ACCESS_ONCE(ads->ds_ctl3) = 0;
+   WRITE_ONCE(ads->ds_ctl2, 0);
+   WRITE_ONCE(ads->ds_ctl3, 0);
}
 
if (!i->is_first) {
-   ACCESS_ONCE(ads->ds_ctl0) = 0;
-   ACCESS_ONCE(ads->ds_ctl1) = ctl1;
-   ACCESS_ONCE(ads->ds_ctl6) = ctl6;
+   WRITE_ONCE(ads->ds_ctl0, 0);
+   WRITE_ONCE(ads->ds_ctl1, ctl1);
+   WRITE_ONCE(ads->ds_ctl6, ctl6);
return;
}
 
@@ -279,7 +279,7 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct 
ath_tx_info *i)
break;
}
 
-   ACCESS_ONCE(ads->ds_ctl0) = (i->pkt_len & AR_FrameLen)
+   WRITE_ONCE(ads->ds_ctl0, (i->pkt_len & AR_FrameLen)
| (i->flags & ATH9K_TXDESC_VMF ? AR_VirtMoreFrag : 0)
| SM(i->txpower[0], AR_XmitPower0)
| (i->flags & ATH9K_TXDESC_VEOL ? AR_VEOL : 0)
@@ -287,29 +287,29 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct 
ath_tx_info *i)
| (i->keyix != ATH9K_TXKEYIX_INVALID ? AR_DestIdxValid : 0)
| (i->flags & ATH9K_TXDESC_CLRDMASK ? AR_ClrDestMask : 0)
| (i->flags & ATH9K_TXDESC_RTSENA ? AR_RTSEnable :
-  (i->flags & ATH9K_TXDESC_CTSENA ? AR_CTSEnable : 0));
+  (i->flags & ATH9K_TXDESC_CTSENA ? AR_CTSEnable : 0)));
 
-   ACCESS_ONCE(ads->ds_ctl1) = ctl1;
-   ACCESS_ONCE(ads->ds_ctl6) = ctl6;
+   WRITE_ONCE(ads->ds_ctl1, ctl1);
+   WRITE_ONCE(ads->ds_ctl6, ctl6);
 
if (i->aggr == AGGR_BUF_MIDDLE || i->aggr == AGGR_BUF_LAST)
return;
 
-   ACCESS_ONCE(ads->ds_ctl4) = set11nPktDurRTSCTS(i->rates, 0)
-   | set11nPktDurRTSCTS(i->rates, 1);
+   WRITE_ONCE(ads->ds_ctl4, set11nPktDurRTSCTS(i->rates, 0)
+   | set11nPktDurRTSCTS(i->rates, 1));
 
-