[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20231220163822.ce1d3893735d3334ae2d04e2@hugovil.com>
Date: Wed, 20 Dec 2023 16:38:22 -0500
From: Hugo Villeneuve <hugo@...ovil.com>
To: Andy Shevchenko <andriy.shevchenko@...el.com>
Cc: gregkh@...uxfoundation.org, jirislaby@...nel.org, jringle@...dpoint.com,
kubakici@...pl, phil@...pberrypi.org, bo.svangard@...eddedart.se,
linux-kernel@...r.kernel.org, linux-serial@...r.kernel.org, Hugo Villeneuve
<hvilleneuve@...onoff.com>
Subject: Re: [PATCH 17/18] serial: sc16is7xx: refactor EFR lock
On Wed, 20 Dec 2023 18:03:18 +0200
Andy Shevchenko <andriy.shevchenko@...el.com> wrote:
> On Tue, Dec 19, 2023 at 12:19:01PM -0500, Hugo Villeneuve wrote:
> > From: Hugo Villeneuve <hvilleneuve@...onoff.com>
> >
> > Move common code for EFR lock/unlock of mutex into functions for code reuse
> > and clarity.
>
> ...
>
> > @@ -333,6 +333,7 @@ struct sc16is7xx_one {
> > struct sc16is7xx_one_config config;
> > bool irda_mode;
> > unsigned int old_mctrl;
> > + u8 old_lcr; /* Value before EFR access. */
> > };
>
> Have you run `pahole`?
> I believe with
>
> unsigned int old_mctrl;
> u8 old_lcr; /* Value before EFR access. */
> bool irda_mode;
>
> layout it will take less memory.
Hi,
I did not know about this tool, nice.
$ pahole -C sc16is7xx_one drivers/tty/serial/sc16is7xx.o
Before:
/* size: 752, cachelines: 12, members: 10 */
With your proposed change:
/* size: 744, cachelines: 12, members: 10 */
Will add this modification for V2, as well as other issues
noted below.
Thank you,
Hugo
> > +/* In an amazing feat of design, the Enhanced Features Register (EFR)
>
> /*
> * This is NOT the style we use for multi-line
> * comments in the serial subsystem. On contrary
> * this comment can be used as a proper example.
> * (Yes, I noticed it's an old comment, but take
> * a chance to fix it.)
> */
>
> > + * shares the address of the Interrupt Identification Register (IIR).
> > + * Access to EFR is switched on by writing a magic value (0xbf) to the
> > + * Line Control Register (LCR). Any interrupt firing during this time will
> > + * see the EFR where it expects the IIR to be, leading to
> > + * "Unexpected interrupt" messages.
> > + *
> > + * Prevent this possibility by claiming a mutex while accessing the EFR,
> > + * and claiming the same mutex from within the interrupt handler. This is
> > + * similar to disabling the interrupt, but that doesn't work because the
> > + * bulk of the interrupt processing is run as a workqueue job in thread
> > + * context.
> > + */
>
> ...
>
> > + sc16is7xx_port_write(port, SC16IS7XX_LCR_REG,
> > + SC16IS7XX_LCR_CONF_MODE_B);
>
> One line. (Yes, 81 character, but readability is as good as before.
>
> --
> With Best Regards,
> Andy Shevchenko
>
>
>
>
Powered by blists - more mailing lists