Re: [PATCH v2 5/6] serial: sb1250-duart: Switch to spinlock protection for shared resource

From: Philippe Mathieu-Daudé

Date: Wed Jun 17 2026 - 08:02:42 EST


On 25/5/26 01:12, Maciej W. Rozycki wrote:
The control register block is shared between DUART channels and so its
resource has to be requested by the first channel claimed and released
by the last one dropped.

It is currently handled with an atomic counter, which however does not
protect against a situation where request_mem_region() has failed, but
another CPU has seen the map guard nonzero and refrained from calling
this function for another channel where it should have (and likely also
fail). This parallel execution scenario can in principle be arranged
via the TIOCSSERIAL ioctl.

Switch to using an ordinary counter then and spinlock protection for the
counter updates along with the corresponding resource request/release
calls, so that the case described above is covered.

Fixes: b45d52797432 ("sb1250-duart.c: SB1250 DUART serial support")
Signed-off-by: Maciej W. Rozycki <macro@xxxxxxxxxxx>
---
New change in v2.
---
drivers/tty/serial/sb1250-duart.c | 28 ++++++++++++++++++----------
1 file changed, 18 insertions(+), 10 deletions(-)

Reviewed-by: Philippe Mathieu-Daudé <philmd@xxxxxxxxxxxxxxxx>