From: Stephen Boyd <firstname.lastname@example.org> To: Andy Shevchenko <email@example.com>, Sergey Semin <Sergey.Semin@baikalelectronics.ru> Cc: Maxime Ripard <firstname.lastname@example.org>, Greg Kroah-Hartman <email@example.com>, Jiri Slaby <firstname.lastname@example.org>, Alexey Malahov <Alexey.Malahov@baikalelectronics.ru>, Maxim Kaurkin <Maxim.Kaurkin@baikalelectronics.ru>, Pavel Parkhomenko <Pavel.Parkhomenko@baikalelectronics.ru>, Ramil Zaripov <Ramil.Zaripov@baikalelectronics.ru>, Ekaterina Skachko <Ekaterina.Skachko@baikalelectronics.ru>, Vadim Vlasov <V.Vlasov@baikalelectronics.ru>, Thomas Bogendoerfer <email@example.com>, Paul Burton <firstname.lastname@example.org>, Ralf Baechle <email@example.com>, Chen-Yu Tsai <firstname.lastname@example.org>, Ray Jui <email@example.com>, Scott Branden <firstname.lastname@example.org>, Florian Fainelli <email@example.com>, Wei Xu <firstname.lastname@example.org>, Jason Cooper <email@example.com>, Andrew Lunn <firstname.lastname@example.org>, Gregory Clement <email@example.com>, Sebastian Hesselbarth <firstname.lastname@example.org>, Jisheng Zhang <Jisheng.Zhang@synaptics.com>, Heiko Stuebner <email@example.com>, Catalin Marina s <firstname.lastname@example.org>, Will Deacon <email@example.com>, Russell King <firstname.lastname@example.org>, email@example.com, Michael Turquette <firstname.lastname@example.org>, email@example.com, Heikki Krogerus <firstname.lastname@example.org>, Kefeng Wang <email@example.com>, firstname.lastname@example.org, email@example.com Subject: Re: [PATCH v2] serial: 8250_dw: Fix common clocks usage race condition Date: Wed, 25 Mar 2020 18:44:53 -0700 Message-ID: <firstname.lastname@example.org> (raw) In-Reply-To: <email@example.com> Quoting Sergey Semin (2020-03-25 10:11:09) > On Tue, Mar 24, 2020 at 12:12:43PM +0200, Andy Shevchenko wrote: > > On Mon, Mar 23, 2020 at 04:50:17PM +0300, Sergey Semin wrote: > > > On Mon, Mar 23, 2020 at 11:01:09AM +0100, Maxime Ripard wrote: > > > > > > clk_rate_exclusive_get is pretty intrusive, and due to the usual > > > > topology of clock trees, this will lock down 3-4 parent clocks to > > > > their current rate as well. In the Allwinner SoCs case for example, > > > > this will lock down the same PLL than the one used by the CPU, > > > > preventing cpufreq from running. > > > > > > Speaking about weak design of a SoC' clock tree. Our problems are nothing > > > with respect to the Allwinner SoC, in which case of changing the > > > CPU-frequency may cause the UART glitches subsequently causing data > > > transfer artefacts.) Moreover as I can see the same issue may raise for > > > I2C, QSPI, PWM devices there. > > > > > > Anyway your concern does make sense. > > > > > > > However, the 8250 has a pretty wide range of dividers and can adapt to > > > > any reasonable parent clock rate, so we don't really need to lock the > > > > rate either, we can simply react to a parent clock rate change using > > > > the clock notifiers, just like the SiFive UART is doing. > > > > > > > > I tried to do that, but given that I don't really have an extensive > > > > knowledge of the 8250, I couldn't find a way to stop the TX of chars > > > > while we change the clock rate. I'm not sure if this is a big deal or > > > > not, the SiFive UART doesn't seem to care. > > > > > > Yes, your solution is also possible, but even in case of stopping Tx/Rx it > > > doesn't lack drawbacks. First of all AFAIK there is no easy way to just > > > pause the transfers. We'd have to first wait for the current transfers > > > to be completed, then somehow lock the port usage (both Tx and Rx > > > traffic), permit the reference clock rate change, accordingly adjust the > > > UART clock divider, and finally unlock the port. While if we don't mind > > > to occasionally have UART data glitches, we can just adjust the UART ref > > > divider synchronously with ref clock rate change as you and SiFive UART > > > driver suggest. > > > > > > So we are now at a zugzwang - a fork to three not that good solutions: > > > 1) lock the whole clock branch and provide a glitchless interfaces. But > > > by doing so we may (in case of Allwinner SoCs we will) lockup some very > > > important functionality like CPU-frequency change while the UART port is > > > started up. In this case we won't have the data glitches. > > > 2) just adjust the UART clock divider in case of reference clock rate > > > change (use the SiFive UART driver approach). In this case we may have the > > > data corruption. > > > 3) somehow implement the algo: wait for the transfers to be completed, > > > lock UART interface (it's possible for Tx, but for Rx in case of no handshake > > > enabled it's simply impossible), permit the ref clock rate change, > > > adjust the UART divider, then unlock the UART interface. In this case the data > > > glitches still may happen (if no modem control is available or > > > handshakes are disabled). > > > > > > As for the cases of Baikal-T1 UARTs the first solutions is the most suitable. > > > We don't lock anything valuable, since a base PLL output isn't directly > > > connected to any device and it's rate once setup isn't changed during the > > > system running. On the other hand I don't mind to implement the second > > > solution, even though it's prone to data glitches. Regarding the solution > > > 3) I won't even try. It's too complicated, I don't have time and > > > test-infrastructure for this. > > > > > > So Andy what do you think? > > > > From Intel HW perspective the first two are okay, but since Maxime is against > > first, you have the only option from your list. Perhaps somebody may give > > option 4) here... > > > > Ok then. I'll implement the option 2) in v3 if noone gives any alternatives > before that. > Sorry, I haven't really read the thread but I'll quickly reply with this. Maybe option 4 is to make the uart driver a clk provider that consumes the single reference clk like it is already doing today? Then when the rate changes up above for the clk implemented here the clk set rate op for the newly implemented clk can go poke the uart registers to maintain the baud or whatever? That is close to how the notifier design would work, but it avoids keeping the notifiers around given that the notifiers are not preferred. It is also closer to reality, the uart has a divider or mux internally that we don't model as a clk, but we could just as easily model as such.
next prev parent reply index Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top [not found] <20200306130231.05BBC8030795@mail.baikalelectronics.ru> [not found] ` <20200306134049.86F8180307C2@mail.baikalelectronics.ru> [not found] ` <20200310001444.B0F50803087C@mail.baikalelectronics.ru> 2020-03-10 14:17 ` [PATCH] " Andy Shevchenko [not found] ` <20200310141715.7063280307CA@mail.baikalelectronics.ru> 2020-03-12 18:47 ` Sergey Semin 2020-03-18 15:19 ` Andy Shevchenko 2020-03-23 2:46 ` [PATCH v2] " Sergey.Semin 2020-03-23 9:20 ` Andy Shevchenko 2020-03-23 11:11 ` Sergey Semin 2020-03-23 11:52 ` Andy Shevchenko 2020-03-23 17:07 ` Sergey Semin 2020-03-23 10:01 ` Maxime Ripard 2020-03-23 13:50 ` Sergey Semin 2020-03-24 9:41 ` Maxime Ripard 2020-03-24 10:12 ` Andy Shevchenko 2020-03-25 17:11 ` Sergey Semin 2020-03-26 1:44 ` Stephen Boyd [this message] 2020-03-27 9:12 ` Sergey Semin
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --firstname.lastname@example.org \ --email@example.com \ --cc=Alexey.Malahov@baikalelectronics.ru \ --cc=Ekaterina.Skachko@baikalelectronics.ru \ --cc=Jisheng.Zhang@synaptics.com \ --cc=Maxim.Kaurkin@baikalelectronics.ru \ --cc=Pavel.Parkhomenko@baikalelectronics.ru \ --cc=Ramil.Zaripov@baikalelectronics.ru \ --cc=Sergey.Semin@baikalelectronics.ru \ --cc=V.Vlasov@baikalelectronics.ru \ --firstname.lastname@example.org \ --email@example.com \ --firstname.lastname@example.org \ --email@example.com \ --firstname.lastname@example.org \ --email@example.com \ --firstname.lastname@example.org \ --email@example.com \ --firstname.lastname@example.org \ --email@example.com \ --firstname.lastname@example.org \ --email@example.com \ --firstname.lastname@example.org \ --email@example.com \ --firstname.lastname@example.org \ --email@example.com \ --firstname.lastname@example.org \ --email@example.com \ --firstname.lastname@example.org \ --email@example.com \ --firstname.lastname@example.org \ --email@example.com \ --firstname.lastname@example.org \ --email@example.com \ --firstname.lastname@example.org \ --email@example.com \ --firstname.lastname@example.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
Linux-Serial Archive on lore.kernel.org Archives are clonable: git clone --mirror https://lore.kernel.org/linux-serial/0 linux-serial/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 linux-serial linux-serial/ https://lore.kernel.org/linux-serial \ email@example.com public-inbox-index linux-serial Example config snippet for mirrors Newsgroup available over NNTP: nntp://nntp.lore.kernel.org/org.kernel.vger.linux-serial AGPL code for this site: git clone https://public-inbox.org/public-inbox.git