RevolutionPi / piControl

Kernel module for data exchange with RevPi I/O-Modules and Gateways
81 stars 24 forks source link

piControl:compact: add missing locks in ain poll thread #11

Closed linosanfilippo-kunbus closed 4 years ago

linosanfilippo-kunbus commented 4 years ago

At various places in the ain poller thread values are assigned to the driver structure which is copied in the dio poller thread. While the copy in the dio thread is done while a lock is held, the value assignment in the ain thread is done without any locks. This may lead to the assigned values not being visible immediately (or not being visible at all) in the dio thread (e.g if both threads are running on different CPUs and the CPU the ain thread is running on, keeps the values in its cache). Fix this by using the proper lock also within the poller thread.

Signed-off-by: Lino Sanfilippo l.sanfilippo@kunbus.com

iluminat23 commented 4 years ago

"values are assigned to the driver structure which are copied" "While the copy in the dio thread is done while a lock is held, the value assignment in the ain thread is done without any locks." As the flip_process_image() macro is the place where the locking is done, this should be mentioned in the comment.