media: cobalt: fix race condition in setting HPD
authorHans Verkuil <hverkuil-cisco@xs4all.nl>
Fri, 23 Apr 2021 08:00:49 +0000 (10:00 +0200)
committerMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Wed, 19 May 2021 07:51:39 +0000 (09:51 +0200)
commit3d37ef41bed0854805ab9af22c422267510e1344
treea4f8c4bc364da63870d8d2ec3d343a379276d9d1
parentb2cd0b31ed896c1a6a423019ed3633e890a7f997
media: cobalt: fix race condition in setting HPD

The cobalt_s_bit_sysctrl reads the old register value over PCI,
then changes a bit and sets writes the new value to the register.

This is used among other things for setting the HPD output pin.

But if the HPD is changed for multiple inputs at the same time,
then this causes a race condition where a stale value is read.

Serialize this function with a mutex.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
drivers/media/pci/cobalt/cobalt-driver.c
drivers/media/pci/cobalt/cobalt-driver.h