Re: [PATCH tty v1 00/74] serial: wrappers for uart port lock
On Mon, Sep 18, 2023 at 10:29:30AM +0206, John Ogness wrote: > On 2023-09-14, John Ogness wrote: > > Provide and use wrapper functions for spin_[un]lock*(port->lock) > > invocations so that the console mechanics can be applied later on at a > > single place and does not require to copy the same logic all over the > > drivers. > > For the full 74-patch series: > > Signed-off-by: John Ogness > > Sorry that my SoB was missing from the initial posting. Thanks for this, I'll rebuild my tree with this added. greg k-h ___ linux-snps-arc mailing list linux-snps-arc@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-snps-arc
Re: [PATCH tty v1 00/74] serial: wrappers for uart port lock
On 2023-09-14, John Ogness wrote: > Provide and use wrapper functions for spin_[un]lock*(port->lock) > invocations so that the console mechanics can be applied later on at a > single place and does not require to copy the same logic all over the > drivers. For the full 74-patch series: Signed-off-by: John Ogness Sorry that my SoB was missing from the initial posting. John Ogness ___ linux-snps-arc mailing list linux-snps-arc@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-snps-arc
Re: [PATCH tty v1 00/74] serial: wrappers for uart port lock
On 2023-09-15, Ilpo Järvinen wrote: > Would this also be useful to enable printing to console while under > port's lock (by postponing the output until the lock is released)? > > E.g., 8250_dw.c has had this commented out since the dawn on time: > /* > * FIXME: this deadlocks if port->lock is already held > * dev_err(p->dev, "Couldn't set LCR to %d\n", value); > */ Yes, this will fix such issues. However, only for consoles that are converted to the new NBCON console type. Good news, the 8250 driver will be the flagship driver that is converted as part of the rework. So this particular issue will be solved then. I will try to remember this so that I can remove the FIXME in the series. Thanks for mentioning it. John ___ linux-snps-arc mailing list linux-snps-arc@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-snps-arc
Re: [PATCH tty v1 00/74] serial: wrappers for uart port lock
On 2023-09-15, "Maciej W. Rozycki" wrote: > Maybe dz.c shouldn't be touched by this series then? Correct. This series is only wrapping the uart port lock, which dz.c is not using. > Though obviously both drivers will have to be eventually adapted for > the ultimate console rework. Correct. Thanks for clarifying how the hardware works. John ___ linux-snps-arc mailing list linux-snps-arc@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-snps-arc
Re: [PATCH tty v1 00/74] serial: wrappers for uart port lock
On Fri, 15 Sep 2023, Thomas Gleixner wrote: > >> Patches 2-74 switch all uart port locking call sites to use the new > >> wrappers. These patches were automatically generated using coccinelle. > > > > Hmm, no need to do this for drivers/tty/serial/zs.c? > > zs.c does not use port lock at all. It has like a couple of other > drivers a local homebrewn spinlock. Ah, right, that's because there are registers shared between two ports within one SCC, so the spinlock has to be shared as well. This also indicates that dz.c is wrong and shouldn't be using a per-port spinlock as the DZ has a shared register set between all the four ports (it's a serial line multiplexer rather than a set discrete ports; up to 8 lines are architecturally supported, though we don't have support in Linux for systems having those), e.g. there's only one 16-bit receiver buffer register for all the four ports, supplying the 8-bit character received along with the receive status and the number of the line this data arrived on, and similarly there's only one transmit data register, which supplies data to the next enabled line whose transmit buffer needs servicing, and the chip routes the data itself. Therefore the driver ought to use a shared spinlock too. I guess it wasn't noticed so far because DZ devices aren't that common (and my usual test machine is currently broken too, pending an SRAM chip replacement, hopefully in the next few weeks) and then hardly ever more than one serial line has been used at a time with these devices. It looks like the first issue for me to look into once the machine has been fixed. Maybe dz.c shouldn't be touched by this series then? (Though obviously both drivers will have to be eventually adapted for the ultimate console rework.) Thanks for your input, as it turns out it has had an unexpected outcome. Maciej ___ linux-snps-arc mailing list linux-snps-arc@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-snps-arc
Re: [PATCH tty v1 00/74] serial: wrappers for uart port lock
On Thu, Sep 14 2023 at 20:01, Maciej W. Rozycki wrote: > On Thu, 14 Sep 2023, John Ogness wrote: > >> Patches 2-74 switch all uart port locking call sites to use the new >> wrappers. These patches were automatically generated using coccinelle. > > Hmm, no need to do this for drivers/tty/serial/zs.c? zs.c does not use port lock at all. It has like a couple of other drivers a local homebrewn spinlock. Thanks, tglx ___ linux-snps-arc mailing list linux-snps-arc@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-snps-arc
Re: [PATCH tty v1 00/74] serial: wrappers for uart port lock
On Thu, 14 Sep 2023, John Ogness wrote: > When a serial port is used for kernel console output, then all > modifications to the UART registers which are done from other contexts, > e.g. getty, termios, are interference points for the kernel console. > > So far this has been ignored and the printk output is based on the > principle of hope. The rework of the console infrastructure which aims to > support threaded and atomic consoles, requires to mark sections which > modify the UART registers as unsafe. This allows the atomic write function > to make informed decisions and eventually to restore operational state. It > also allows to prevent the regular UART code from modifying UART registers > while printk output is in progress. Hi John, Would this also be useful to enable printing to console while under port's lock (by postponing the output until the lock is released)? E.g., 8250_dw.c has had this commented out since the dawn on time: /* * FIXME: this deadlocks if port->lock is already held * dev_err(p->dev, "Couldn't set LCR to %d\n", value); */ -- i. > All modifications of UART registers are guarded by the UART port lock, > which provides an obvious synchronization point with the console > infrastructure. > > Provide and use wrapper functions for spin_[un]lock*(port->lock) > invocations so that the console mechanics can be applied later on at a > single place and does not require to copy the same logic all over the > drivers. > > Patch 1 adds the wrapper functions. > > Patches 2-74 switch all uart port locking call sites to use the new > wrappers. These patches were automatically generated using coccinelle. > The 2 used coccinelle scripts are included below and executed as > follows: > > $ spatch --sp-file uartlock-1.cocci $FILE > $ spatch --sp-file uartlock-2.cocci --recursive-includes $FILE > > This series brings no functional change. > > Patches 2-74 contain identical commit message bodies. Feel free to > fold them into a single commit if that seems more reasonable. > > Thomas Gleixner (74): > serial: core: Provide port lock wrappers > serial: core: Use lock wrappers > serial: 21285: Use port lock wrappers > serial: 8250_aspeed_vuart: Use port lock wrappers > serial: 8250_bcm7271: Use port lock wrappers > serial: 8250: Use port lock wrappers > serial: 8250_dma: Use port lock wrappers > serial: 8250_dw: Use port lock wrappers > serial: 8250_exar: Use port lock wrappers > serial: 8250_fsl: Use port lock wrappers > serial: 8250_mtk: Use port lock wrappers > serial: 8250_omap: Use port lock wrappers > serial: 8250_pci1: Use port lock wrappers > serial: altera_jtaguart: Use port lock wrappers > serial: altera_uart: Use port lock wrappers > serial: amba-pl010: Use port lock wrappers > serial: amba-pl011: Use port lock wrappers > serial: apb: Use port lock wrappers > serial: ar933x: Use port lock wrappers > serial: arc_uart: Use port lock wrappers > serial: atmel: Use port lock wrappers > serial: bcm63xx-uart: Use port lock wrappers > serial: cpm_uart: Use port lock wrappers > serial: digicolor: Use port lock wrappers > serial: dz: Use port lock wrappers > serial: linflexuart: Use port lock wrappers > serial: fsl_lpuart: Use port lock wrappers > serial: icom: Use port lock wrappers > serial: imx: Use port lock wrappers > serial: ip22zilog: Use port lock wrappers > serial: jsm: Use port lock wrappers > serial: liteuart: Use port lock wrappers > serial: lpc32xx_hs: Use port lock wrappers > serial: ma35d1: Use port lock wrappers > serial: mcf: Use port lock wrappers > serial: men_z135_uart: Use port lock wrappers > serial: meson: Use port lock wrappers > serial: milbeaut_usio: Use port lock wrappers > serial: mpc52xx: Use port lock wrappers > serial: mps2-uart: Use port lock wrappers > serial: msm: Use port lock wrappers > serial: mvebu-uart: Use port lock wrappers > serial: omap: Use port lock wrappers > serial: owl: Use port lock wrappers > serial: pch: Use port lock wrappers > serial: pic32: Use port lock wrappers > serial: pmac_zilog: Use port lock wrappers > serial: pxa: Use port lock wrappers > serial: qcom-geni: Use port lock wrappers > serial: rda: Use port lock wrappers > serial: rp2: Use port lock wrappers > serial: sa1100: Use port lock wrappers > serial: samsung_tty: Use port lock wrappers > serial: sb1250-duart: Use port lock wrappers > serial: sc16is7xx: Use port lock wrappers > serial: tegra: Use port lock wrappers > serial: core: Use port lock wrappers > serial: mctrl_gpio: Use port lock wrappers > serial: txx9: Use port lock wrappers > serial: sh-sci: Use port lock wrappers > serial: sifive: Use port lock wrappers > serial: sprd: Use port lock wrappers > serial: st-asc: Use port lock wrappers > serial: stm32: Use port lock wrappers > serial: sunhv: Use port lock wrappers > serial: sunplus-uart: Use port lock
Re: [PATCH tty v1 00/74] serial: wrappers for uart port lock
On Thu, 14 Sep 2023, John Ogness wrote: > Patches 2-74 switch all uart port locking call sites to use the new > wrappers. These patches were automatically generated using coccinelle. Hmm, no need to do this for drivers/tty/serial/zs.c? Maciej ___ linux-snps-arc mailing list linux-snps-arc@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-snps-arc