[PATCH] lpd: marvell: mark the indirect-access registers as volatile
Mauricio Faria de Oliveira <[email protected]> Tue, 13 Dec 2016 11:28:07 -0200
| Newsgroups | gmane.linux.tools.diag.devel |
|---|---|
| Message-ID | <[email protected]> |
In optimization level -O3, a sequence of VSR read/write operations
can be incorrectly optimized away as the compiler doesn't know the
underlying memory locations can change and react to read/writes.
So, mark the pointers used to read/write to the indirect-access
registers which access the VSRs with the 'volatile' keyword.
Test-cases:
----------
CFLAGS=-O2 (default)
# make
# LPD_DEBUG=1 ./lpd/usysident
...
DEBUG: get_mv_indicator(): Data Out: '0x00000018'
DEBUG: get_mv_indicator(): Data Out Enable: '0xffffffe7'
DEBUG: get_mv_indicator(): Port Active Select: '0x2db6da8d'
...
CFLAGS=-O3
# rm lpd/indicator_marvell.o
# CFLAGS='-O3' make
# LPD_DEBUG=1 ./lpd/usysident
...
DEBUG: get_mv_indicator(): Data Out: '0x2db6da8d'
DEBUG: get_mv_indicator(): Data Out Enable: '0x2db6da8d'
DEBUG: get_mv_indicator(): Port Active Select: '0x2db6da8d'
...
CFLAGS=-O3 (patched)
# rm lpd/indicator_marvell.o
# CFLAGS='-O3' make
# LPD_DEBUG=1 ./lpd/usysident
...
DEBUG: get_mv_indicator(): Data Out: '0x00000018'
DEBUG: get_mv_indicator(): Data Out Enable: '0xffffffe7'
DEBUG: get_mv_indicator(): Port Active Select: '0x2db6da8d'
Signed-off-by: Mauricio Faria de Oliveira <[email protected]>
Fixes: efb9a4df3f88 ("lpd: Add support for Marvell HDD LEDs on S822LC for HPC")
---
lpd/indicator_marvell.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/lpd/indicator_marvell.c b/lpd/indicator_marvell.c
index ec2580a73f03..ace808dde53f 100644
--- a/lpd/indicator_marvell.c
+++ b/lpd/indicator_marvell.c
@@ -183,8 +183,8 @@ mv_munmap_bar5(void *bar5, int fd)
static uint32_t
mv_vsr_read(void* bar5, uint32_t vsr_addr)
{
- uint32_t *addr = (uint32_t *)(bar5 + mv_pci_bar5_vsr_addr);
- uint32_t *data = (uint32_t *)(bar5 + mv_pci_bar5_vsr_data);
+ volatile uint32_t *addr = (uint32_t *)(bar5 + mv_pci_bar5_vsr_addr);
+ volatile uint32_t *data = (uint32_t *)(bar5 + mv_pci_bar5_vsr_data);
/* set address and read data */
*addr = vsr_addr;
@@ -204,8 +204,8 @@ mv_vsr_read(void* bar5, uint32_t vsr_addr)
static void
mv_vsr_write(void* bar5, uint32_t vsr_addr, uint32_t vsr_data)
{
- uint32_t *addr = (uint32_t *)(bar5 + mv_pci_bar5_vsr_addr);
- uint32_t *data = (uint32_t *)(bar5 + mv_pci_bar5_vsr_data);
+ volatile uint32_t *addr = (uint32_t *)(bar5 + mv_pci_bar5_vsr_addr);
+ volatile uint32_t *data = (uint32_t *)(bar5 + mv_pci_bar5_vsr_data);
/* set address and write data */
*addr = vsr_addr;
--
1.8.3.1
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot