firewire: ohci: access bus_seconds atomically

In the unlikely event that card->driver->get_bus_time() is called during
a cycle64Seconds interrupt, we could read garbage unless atomic accesses
are used.

The switch to atomic ops requires to change the 64 seconds counter from
unsigned to signed, but this shouldn't matter to the end result.

Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>

+4 -3
+4 -3
drivers/firewire/fw-ohci.c
··· 31 #include <linux/pci.h> 32 #include <linux/spinlock.h> 33 34 #include <asm/page.h> 35 #include <asm/system.h> 36 ··· 179 int node_id; 180 int generation; 181 int request_generation; /* for timestamping incoming requests */ 182 - u32 bus_seconds; 183 184 bool use_dualbuffer; 185 bool old_uninorth; ··· 1435 if (event & OHCI1394_cycle64Seconds) { 1436 cycle_time = reg_read(ohci, OHCI1394_IsochronousCycleTimer); 1437 if ((cycle_time & 0x80000000) == 0) 1438 - ohci->bus_seconds++; 1439 } 1440 1441 return IRQ_HANDLED; ··· 1771 u64 bus_time; 1772 1773 cycle_time = reg_read(ohci, OHCI1394_IsochronousCycleTimer); 1774 - bus_time = ((u64) ohci->bus_seconds << 32) | cycle_time; 1775 1776 return bus_time; 1777 }
··· 31 #include <linux/pci.h> 32 #include <linux/spinlock.h> 33 34 + #include <asm/atomic.h> 35 #include <asm/page.h> 36 #include <asm/system.h> 37 ··· 178 int node_id; 179 int generation; 180 int request_generation; /* for timestamping incoming requests */ 181 + atomic_t bus_seconds; 182 183 bool use_dualbuffer; 184 bool old_uninorth; ··· 1434 if (event & OHCI1394_cycle64Seconds) { 1435 cycle_time = reg_read(ohci, OHCI1394_IsochronousCycleTimer); 1436 if ((cycle_time & 0x80000000) == 0) 1437 + atomic_inc(&ohci->bus_seconds); 1438 } 1439 1440 return IRQ_HANDLED; ··· 1770 u64 bus_time; 1771 1772 cycle_time = reg_read(ohci, OHCI1394_IsochronousCycleTimer); 1773 + bus_time = ((u64)atomic_read(&ohci->bus_seconds) << 32) | cycle_time; 1774 1775 return bus_time; 1776 }