[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YPxA3Zcfw8ZPNYZp@lunn.ch>
Date: Sat, 24 Jul 2021 18:33:33 +0200
From: Andrew Lunn <andrew@...n.ch>
To: Pali Rohár <pali@...nel.org>
Cc: Michael Turquette <mturquette@...libre.com>,
Stephen Boyd <sboyd@...nel.org>,
Rob Herring <robh+dt@...nel.org>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Gregory Clement <gregory.clement@...tlin.com>,
Sebastian Hesselbarth <sebastian.hesselbarth@...il.com>,
Vladimir Vid <vladimir.vid@...tura.hr>,
Marek Behún <kabel@...nel.org>,
Geert Uytterhoeven <geert@...ux-m68k.org>,
linux-clk@...r.kernel.org, linux-serial@...r.kernel.org,
linux-kernel@...r.kernel.org, linux-arm-kernel@...ts.infradead.org
Subject: Re: [PATCH v3 2/5] serial: mvebu-uart: implement UART clock driver
for configuring UART base clock
On Sat, Jul 24, 2021 at 11:48:16AM +0200, Pali Rohár wrote:
> On Saturday 17 July 2021 20:05:40 Pali Rohár wrote:
> > On Saturday 17 July 2021 19:26:51 Andrew Lunn wrote:
> > > On Sat, Jul 17, 2021 at 02:38:26PM +0200, Pali Rohár wrote:
> > > > @@ -445,6 +472,7 @@ static void mvebu_uart_shutdown(struct uart_port *port)
> > > > static int mvebu_uart_baud_rate_set(struct uart_port *port, unsigned int baud)
> > > > {
> > > > unsigned int d_divisor, m_divisor;
> > > > + unsigned long flags;
> > > > u32 brdv, osamp;
> > > >
> > > > if (!port->uartclk)
> > > > @@ -463,10 +491,12 @@ static int mvebu_uart_baud_rate_set(struct uart_port *port, unsigned int baud)
> > > > m_divisor = OSAMP_DEFAULT_DIVISOR;
> > > > d_divisor = DIV_ROUND_CLOSEST(port->uartclk, baud * m_divisor);
> > > >
> > > > + spin_lock_irqsave(&mvebu_uart_lock, flags);
> > >
> > > Hi Pali
> > >
> > > You only need spin_lock_irqsave() if you plan on taking the spinlock
> > > in an interrupt handler. It seems unlikely the baud rate will be
> > > changed in interrupt context? Please check, and then swap to plain
> > > spin_lock().
> >
> > Hello! Ok, I will check it.
>
> Well, driver is already using spin_lock_irqsave() in all other
> functions.
And some of those functions are called from interrupt context i
expect. For each lock you have, you need to decide if interrupt
context is an issue or not. spin_lock_irqsave() is more expansive,
since it has to disable interrupts, etc. It can upset real time
latency etc. So in the hot path, you want to try to avoid it, unless
you actually need it. But changing the baud rate is not the hot path,
it hardly every happens, so we can live with the unneeded overhead.
> And in linux/clk-provider.h is documented that drivers can call
> clk_enable() from an interrupt, so it means that spin_lock_irqsave() is
> really needed for mvebu_uart_lock.
Sure, drivers can. But in this case, does a driver actually do that?
Does it change the baud rate in interrupt context?
> > In other patches is updated function mvebu_uart_set_termios() which
> > verifies that you can set particular baudrate.
Great. It is not clear from the patches or the commit message that
this has been considered. It is something worth mentioning, just to
avoid questions.
> > Also note that all A3720 boards have disabled UART2 in DTS. And I'm not
> > sure if there is somebody who uses UART2 or who uses both UARTs.
That does not really matter. You should not regression a feature
because you think nobody is using it.
Andrew
Powered by blists - more mailing lists