drivers/usb: use READ_ONCE instead of deprecated ACCESS_ONCE
Subsystems (3)
PATCH 1/1 drivers/usb: use READ_ONCE instead of deprecated ACCESS_ONCE
With the new standardized functions, we can replace all ACCESS_ONCE() calls across relevant drivers/usb/.
ACCESS_ONCE() does not work reliably on non-scalar types. For example gcc 4.6 and 4.7 might remove the volatile tag for such accesses during the SRA (scalar replacement of aggregates) step:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58145
Update the new calls regardless of if it is a scalar type, this is cleaner than having three alternatives.
--- drivers/usb/class/cdc-wdm.c | 2 +- drivers/usb/core/devio.c | 2 +- drivers/usb/core/sysfs.c | 4 ++-- drivers/usb/gadget/udc/gr_udc.c | 4 ++-- drivers/usb/host/ohci-hcd.c | 2 +- drivers/usb/host/uhci-hcd.h | 4 ++-- 6 files changed, 9 insertions(+), 9 deletions(-)
drivers/usb/class/cdc-wdm.c +1 -1
@@ -515,7 +515,7 @@ static ssize_t wdm_readif (rv <0 )return -ERESTARTSYS ; - cntr =ACCESS_ONCE (desc->length); + cntr =READ_ONCE (desc->length);if (cntr ==0 ) { desc->read =0 ; retry:
drivers/usb/core/devio.c +1 -1
@@ -153,7 +153,7 @@ static int usbfs_increase_memory_usage(unsigned amount)* Convert usbfs_memory_mb to bytes, avoiding overflows. * 0 means use the hard limit (effectively unlimited). */ - lim =ACCESS_ONCE (usbfs_memory_mb); + lim =READ_ONCE (usbfs_memory_mb);if (lim ==0 || lim > (USBFS_XFER_MAX >>20 )) lim =USBFS_XFER_MAX ;else
drivers/usb/core/sysfs.c +2 -2
@@ -956,7 +956,7 @@ static ssize_t interface_show(struct device *dev, struct device_attribute *attr,char *string; intf =to_usb_interface (dev); - string =ACCESS_ONCE (intf->cur_altsetting->string); + string =READ_ONCE (intf->cur_altsetting->string);if (!string)return 0 ;return sprintf (buf,"%s\n" , string);
@@ -972,7 +972,7 @@ static ssize_t modalias_show(struct device *dev, struct device_attribute *attr, intf =to_usb_interface (dev); udev =interface_to_usbdev (intf); - alt =ACCESS_ONCE (intf->cur_altsetting); + alt =READ_ONCE (intf->cur_altsetting); return sprintf(buf, "usb:v%04Xp%04Xd%04Xdc%02Xdsc%02Xdp%02X" "ic%02Xisc%02Xip%02Xin%02X\n",
drivers/usb/gadget/udc/gr_udc.c +2 -2
@@ -1261,7 +1261,7 @@ static int gr_handle_in_ep(struct gr_ep *ep)if (!req->last_desc)return 0 ; -if (ACCESS_ONCE (req->last_desc->ctrl) &GR_DESC_IN_CTRL_EN ) +if (READ_ONCE (req->last_desc->ctrl) &GR_DESC_IN_CTRL_EN )return 0 ;/* Not put in hardware buffers yet */ if (gr_read32 (&ep->regs->epstat) & (GR_EPSTAT_B1 |GR_EPSTAT_B0 ))
@@ -1290,7 +1290,7 @@ static int gr_handle_out_ep(struct gr_ep *ep)if (!req->curr_desc)return 0 ; - ctrl =ACCESS_ONCE (req->curr_desc->ctrl); + ctrl =READ_ONCE (req->curr_desc->ctrl);if (ctrl &GR_DESC_OUT_CTRL_EN )return 0 ;/* Not received yet */
drivers/usb/host/ohci-hcd.c +1 -1
@@ -784,7 +784,7 @@ static void io_watchdog_func(unsigned long _ohci) }/* find the last TD processed by the controller. */ - head =hc32_to_cpu (ohci,ACCESS_ONCE (ed->hwHeadP)) &TD_MASK ; + head =hc32_to_cpu (ohci,READ_ONCE (ed->hwHeadP)) &TD_MASK ; td_start = td; td_next =list_prepare_entry (td, &ed->td_list, td_list);list_for_each_entry_continue (td_next, &ed->td_list, td_list) {
drivers/usb/host/uhci-hcd.h +2 -2
@@ -184,7 +184,7 @@ struct uhci_qh {* We need a special accessor for the element pointer because it is * subject to asynchronous updates by the controller. */ -#define qh_element (qh) ACCESS_ONCE((qh)->element) +#define qh_element (qh) READ_ONCE((qh)->element)#define LINK_TO_QH (uhci, qh) (UHCI_PTR_QH((uhci)) | \ cpu_to_hc32((uhci), (qh)->dma_handle))
@@ -272,7 +272,7 @@ struct uhci_td {* subject to asynchronous updates by the controller. */ #define td_status (uhci, td) hc32_to_cpu((uhci), \ - ACCESS_ONCE((td)->status)) + READ_ONCE((td)->status))#define LINK_TO_TD (uhci, td) (cpu_to_hc32((uhci), (td)->dma_handle))
Signature · 1 line
2.6.6
Greg KH
maintainerQuoted 7 lines · Davidlohr Bueso
With the new standardized functions, we can replace all
ACCESS_ONCE()calls across relevantdrivers/usb/.
ACCESS_ONCE()does not work reliably on non-scalar types. For example gcc 4.6 and 4.7 might remove the volatile tag for such accesses during the SRA (scalar replacement of aggregates) step:
Quoted 6 lines
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58145
Update the new calls regardless of if it is a scalar type, this is cleaner than having three alternatives.
Signed-off-by Davidlohr Bueso <[email protected]>
Nit, this doesn't match your From: line :(
If this is the case, why not just replacing the define for ACCESS_ONCE() with READ_ONCE() and then go back and just do a search/replace for the whole kernel all at once?
Or just send Linus a patch for this all at once after -rc1 is out?
thanks,
greg k-h
Quoted 8 lines · Greg KH
Quoted 6 lines · Davidlohr Bueso
With the new standardized functions, we can replace all
ACCESS_ONCE()calls across relevantdrivers/usb/.
ACCESS_ONCE()does not work reliably on non-scalar types. For example gcc 4.6 and 4.7 might remove the volatile tag for such accesses during the SRA (scalar replacement of aggregates) step:
Quoted 5 lines
If this is the case, why not just replacing the define for
ACCESS_ONCE()withREAD_ONCE()and then go back and just do a search/replace for the whole kernel all at once?Or just send Linus a patch for this all at once after -rc1 is out?
FWIW, I have a Coccinelle-generated patch for that [1].
... there are a few cases where it doesn't quite work (e.g. formatting in the ath9k mac drivers), and I'm trying to put together a series [2] that fixes those cases up before leaving the bulk to Coccinelle.
I hope to sort that out in the next few days.
Thanks,
Mark.
[1] https://git.kernel.org/cgit/linux/kernel/git/mark/linux.git/commit/?h=core/access-once&id=7154d3cd5f2ddcc029d1afadc472c5720408d678
[2] https://git.kernel.org/cgit/linux/kernel/git/mark/linux.git/log/?h=core/access-once
Hi Greg!
Quoted 8 lines · Greg KH
Quoted 7 lines · Davidlohr Bueso
With the new standardized functions, we can replace all
ACCESS_ONCE()calls across relevantdrivers/usb/.
ACCESS_ONCE()does not work reliably on non-scalar types. For example gcc 4.6 and 4.7 might remove the volatile tag for such accesses during the SRA (scalar replacement of aggregates) step:
Quoted 8 lines
Quoted 6 lines
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58145
Update the new calls regardless of if it is a scalar type, this is cleaner than having three alternatives.
Signed-off-by Davidlohr Bueso <[email protected]>Nit, this doesn't match your From: line :(
That's on purpose, and all my patches are the same.
Quoted 3 lines
If this is the case, why not just replacing the define for
ACCESS_ONCE()withREAD_ONCE()and then go back and just do a search/replace for the whole kernel all at once?
So that we don't have three variants; the idea is to eventually get rid of ACCESS_ONCE entirely.
Quoted 2 lines
Or just send Linus a patch for this all at once after -rc1 is out?
No rush, whenever you see fit.
Thanks,
Davidlohr
Greg KH
maintainerQuoted 14 lines · Davidlohr Bueso
Hi Greg!
Quoted 10 lines · Greg KH
Quoted 9 lines · Davidlohr Bueso
With the new standardized functions, we can replace all
ACCESS_ONCE()calls across relevantdrivers/usb/.
ACCESS_ONCE()does not work reliably on non-scalar types. For example gcc 4.6 and 4.7 might remove the volatile tag for such accesses during the SRA (scalar replacement of aggregates) step:
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
Update the new calls regardless of if it is a scalar type, this is cleaner than having three alternatives.
Signed-off-by Davidlohr Bueso <[email protected]>Nit, this doesn't match your From: line :(
That's on purpose, and all my patches are the same.
So they are all incorrect? Not good, why? You know this means I can't take them...
Quoted 6 lines
Quoted 3 lines
If this is the case, why not just replacing the define for
ACCESS_ONCE()withREAD_ONCE()and then go back and just do a search/replace for the whole kernel all at once?So that we don't have three variants; the idea is to eventually get rid of
ACCESS_ONCEentirely.
Then just get rid of it all at once.
thanks,
greg k-h
Greg KH
maintainerQuoted 7 lines · Davidlohr Bueso
With the new standardized functions, we can replace all
ACCESS_ONCE()calls across relevantdrivers/usb/.
ACCESS_ONCE()does not work reliably on non-scalar types. For example gcc 4.6 and 4.7 might remove the volatile tag for such accesses during the SRA (scalar replacement of aggregates) step:
Quoted 6 lines
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58145
Update the new calls regardless of if it is a scalar type, this is cleaner than having three alternatives.
Signed-off-by Davidlohr Bueso <[email protected]>
Again, fix your From: line please.
PATCH v2 1/1 drivers/usb: use READ_ONCE instead of deprecated ACCESS_ONCE
With the new standardized functions, we can replace all ACCESS_ONCE() calls across relevant drivers/usb/.
ACCESS_ONCE() does not work reliably on non-scalar types. For example gcc 4.6 and 4.7 might remove the volatile tag for such accesses during the SRA (scalar replacement of aggregates) step:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58145
Update the new calls regardless of if it is a scalar type, this is cleaner than having three alternatives.
---
drivers/usb/class/cdc-wdm.c | 2 +- drivers/usb/core/devio.c | 2 +- drivers/usb/core/sysfs.c | 4 ++-- drivers/usb/gadget/udc/gr_udc.c | 4 ++-- drivers/usb/host/ohci-hcd.c | 2 +- drivers/usb/host/uhci-hcd.h | 4 ++-- 6 files changed, 9 insertions(+), 9 deletions(-)
drivers/usb/class/cdc-wdm.c +0 -0
@@ -515,7 +515,7 @@ static ssize_t wdm_read
if (rv < 0) return -ERESTARTSYS;
- cntr = ACCESS_ONCE(desc->length);
+ cntr = READ_ONCE(desc->length);
if (cntr == 0) {
desc->read = 0;retry:
drivers/usb/core/devio.c +0 -0
@@ -153,7 +153,7 @@ static int usbfs_increase_memory_usage(unsigned amount)
* Convert usbfs_memory_mb to bytes, avoiding overflows.
* 0 means use the hard limit (effectively unlimited). */
- lim = ACCESS_ONCE(usbfs_memory_mb);
+ lim = READ_ONCE(usbfs_memory_mb); if (lim == 0 || lim > (USBFS_XFER_MAX >> 20)) lim = USBFS_XFER_MAX; else
drivers/usb/core/sysfs.c +0 -0
@@ -956,7 +956,7 @@ static ssize_t interface_show(struct device *dev, struct device_attribute *attr,
char *string; intf = to_usb_interface(dev); - string = ACCESS_ONCE(intf->cur_altsetting->string); + string = READ_ONCE(intf->cur_altsetting->string); if (!string) return 0; return sprintf(buf, "%s\n", string);
@@ -972,7 +972,7 @@ static ssize_t modalias_show(struct device *dev, struct device_attribute *attr,
intf = to_usb_interface(dev); udev = interface_to_usbdev(intf);
- alt = ACCESS_ONCE(intf->cur_altsetting);
+ alt = READ_ONCE(intf->cur_altsetting);
return sprintf(buf, "usb:v%04Xp%04Xd%04Xdc%02Xdsc%02Xdp%02X" "ic%02Xisc%02Xip%02Xin%02X\n",
drivers/usb/gadget/udc/gr_udc.c +0 -0
@@ -1261,7 +1261,7 @@ static int gr_handle_in_ep(struct gr_ep *ep)
if (!req->last_desc) return 0;
- if (ACCESS_ONCE(req->last_desc->ctrl) & GR_DESC_IN_CTRL_EN)
+ if (READ_ONCE(req->last_desc->ctrl) & GR_DESC_IN_CTRL_EN)
return 0; /* Not put in hardware buffers yet */ if (gr_read32(&ep->regs->epstat) & (GR_EPSTAT_B1 | GR_EPSTAT_B0)) @@ -1290,7 +1290,7 @@ static int gr_handle_out_ep(struct gr_ep *ep) if (!req->curr_desc) return 0;
- ctrl = ACCESS_ONCE(req->curr_desc->ctrl);
+ ctrl = READ_ONCE(req->curr_desc->ctrl);
if (ctrl & GR_DESC_OUT_CTRL_EN)
return 0; /* Not received yet */
drivers/usb/host/ohci-hcd.c +0 -0
@@ -784,7 +784,7 @@ static void io_watchdog_func(unsigned long _ohci)
}
/* find the last TD processed by the controller. */
- head = hc32_to_cpu(ohci, ACCESS_ONCE(ed->hwHeadP)) & TD_MASK;
+ head = hc32_to_cpu(ohci, READ_ONCE(ed->hwHeadP)) & TD_MASK;
td_start = td;
td_next = list_prepare_entry(td, &ed->td_list, td_list);
list_for_each_entry_continue(td_next, &ed->td_list, td_list) {drivers/usb/host/uhci-hcd.h +1 -1
@@ -184,7 +184,7 @@ struct uhci_qh {* We need a special accessor for the element pointer because it is * subject to asynchronous updates by the controller. */ -#define qh_element (qh) ACCESS_ONCE((qh)->element) +#define qh_element (qh) READ_ONCE((qh)->element)
#define LINK_TO_QH(uhci, qh) (UHCI_PTR_QH((uhci)) | \ cpu_to_hc32((uhci), (qh)->dma_handle))
@@ -272,7 +272,7 @@ struct uhci_td {
* subject to asynchronous updates by the controller. */
#define td_status(uhci, td) hc32_to_cpu((uhci), \
- ACCESS_ONCE((td)->status))
+ READ_ONCE((td)->status))
#define LINK_TO_TD(uhci, td) (cpu_to_hc32((uhci), (td)->dma_handle))
Signature · 1 line
2.6.6
Greg KH
maintainerQuoted 13 lines · Davidlohr Bueso
With the new standardized functions, we can replace all
ACCESS_ONCE()calls across relevantdrivers/usb/.
ACCESS_ONCE()does not work reliably on non-scalar types. For example gcc 4.6 and 4.7 might remove the volatile tag for such accesses during the SRA (scalar replacement of aggregates) step:https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58145
Update the new calls regardless of if it is a scalar type, this is cleaner than having three alternatives.
Signed-off-by Davidlohr Bueso <[email protected]>
Quoted 8 lines
---
drivers/usb/class/cdc-wdm.c | 2 +- drivers/usb/core/devio.c | 2 +- drivers/usb/core/sysfs.c | 4 ++-- drivers/usb/gadget/udc/gr_udc.c | 4 ++-- drivers/usb/host/ohci-hcd.c | 2 +- drivers/usb/host/uhci-hcd.h | 4 ++-- 6 files changed, 9 insertions(+), 9 deletions(-)
Same comment on your driver base patch, what changed from v1?