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