[PATCH 05/18] tty: serial: samsung_tty: add support for Apple UARTs
Marc Zyngier
maz at kernel.org
Mon Feb 8 05:34:07 EST 2021
On 2021-02-07 09:12, Hector Martin 'marcan' wrote:
> On 06/02/2021 22.15, Marc Zyngier wrote:
[...]
>>> - spin_lock_irqsave(&port->lock, flags);
>>> + /* Only lock if called from IRQ context */
>>> + if (irq != NO_IRQ)
>>> + spin_lock_irqsave(&port->lock, flags);
>>
>> Isn't that actually dangerous? What prevents the interrupt from firing
>> right in the middle of this sequence and create havoc when called from
>> enable_tx_pio()? I fail to see what you gain with sidestepping the
>> locking.
>
> The callpath here is:
>
> uart_start -> __uart_start -> (uart_ops.start_tx)
> s3c24xx_serial_start_tx -> s3c24xx_serial_start_tx_pio ->
> enable_tx_pio -> s3c24xx_serial_tx_chars
>
> And uart_start takes the uart_port lock. None of the serial functions
> take the lock because the serial core already does, but obviously the
> IRQ handler needs to, *if* it's called as an IRQ handler only.
Right, that's the part I missed, thanks for pointing this out.
It'd probably be cleaner to move the whole s3c24xx_serial_tx_chars()
into a helper and keep the locking in the interrupt handler proper.
[...]
>>> diff --git a/include/uapi/linux/serial_core.h
>>> b/include/uapi/linux/serial_core.h
>>> index 62c22045fe65..59d102b674db 100644
>>> --- a/include/uapi/linux/serial_core.h
>>> +++ b/include/uapi/linux/serial_core.h
>>> @@ -277,4 +277,7 @@
>>> /* Freescale LINFlexD UART */
>>> #define PORT_LINFLEXUART 122
>>> +/* Apple Silicon (M1/T8103) UART (Samsung variant) */
>>> +#define PORT_APPLE 123
>>> +
>>
>> Do you actually need a new port type here? Looking at the driver
>> itself, it is mainly used to work out the IRQ model. Maybe introducing
>> a new irq_type field in the port structure would be better than
>> exposing this to userspace (which should see something that is exactly
>> the same as a S3C UART).
>
> Well... every S3C variant already has its own port type here.
>
> #define PORT_S3C2410 55
> #define PORT_S3C2440 61
> #define PORT_S3C2400 67
> #define PORT_S3C2412 73
> #define PORT_S3C6400 84
>
> If we don't introduce a new one, which one should we pretend to be? :)
Pick one! :D
> I agree that it might make sense to merge all of these into one,
> though; I don't know what the original reason for splitting them out
> is. But now that they're part of the userspace API, this might not be
> a good idea. Though, unsurprisingly, some googling suggests there are
> zero users of these defines in userspace.
I don't think we can do that, but I don't think we should keep adding
to this unless there is a very good reason. Greg would know, I expect.
Thanks,
M.
--
Jazz is not dead. It just smells funny...
More information about the linux-arm-kernel
mailing list