RE: [PATCH] serial: sh-sci: Support custom speed setting

From: ashiduka@xxxxxxxxxxx
Date: Mon Mar 30 2020 - 03:43:21 EST


Dear Greg, Geert,

> Right.
> Adding "#include <sys/ioctl.h>" to Greg's sample code causes a
> compilation error.
<snip>
> Is it normal to declare ioctl() without "#include <sys/ioctl.h>" ?

I would be happy if you could give me some comments.

> http://www.panix.com/~grante/arbitrary-baud.c

We think this sample code is no good.
Should I work on glibc changes instead of kernel fixes?

Thanks & Best Regards,
Yuusuke Ashiduka <ashiduka@xxxxxxxxxxx>
Embedded System Development Dept. Embedded System Development Div.
FUJITSU COMPUTER TECHNOLOGIES Ltd.

> -----Original Message-----
> From: Ashizuka, Yuusuke/èå éä <ashiduka@xxxxxxxxxxx>
> Sent: Thursday, March 12, 2020 6:44 PM
> To: 'Geert Uytterhoeven' <geert@xxxxxxxxxxxxxx>;
> gregkh@xxxxxxxxxxxxxxxxxxx
> Cc: erosca@xxxxxxxxxxxxxx; linux-serial@xxxxxxxxxxxxxxx;
> linux-renesas-soc@xxxxxxxxxxxxxxx;
> wsa+renesas@xxxxxxxxxxxxxxxxxxxx;
> yoshihiro.shimoda.uh@xxxxxxxxxxx; uli+renesas@xxxxxxxx;
> george_davis@xxxxxxxxxx; andrew_gabbasov@xxxxxxxxxx;
> jiada_wang@xxxxxxxxxx; yuichi.kusakabe@xxxxxxxxxxxxx;
> yasano@xxxxxxxxxxxxxx; linux-kernel@xxxxxxxxxxxxxxx;
> jslaby@xxxxxxxx; yohhei.fukui@xxxxxxxxxxxxx;
> magnus.damm@xxxxxxxxx; Torii, Kenichi/éå åä
> <torii.ken1@xxxxxxxxxxx>
> Subject: RE: [PATCH] serial: sh-sci: Support custom speed setting
>
> Dear Greg, Geert,
>
> > I guess you mean the forward declaration of ioctrl()?
> > No, they should include <sys/ioctl.h> instead.
>
> Right.
> Adding "#include <sys/ioctl.h>" to Greg's sample code causes a
> compilation error.
>
> > > I saw the code above, I thought I wouldn't write such code
> normally.
> > Why not?
>
> Is it normal to declare ioctl() without "#include <sys/ioctl.h>" ?
>
> Thanks & Best Regards,
> Yuusuke Ashiduka <ashiduka@xxxxxxxxxxx>
> Embedded System Development Dept. Embedded System Development Div.
> FUJITSU COMPUTER TECHNOLOGIES Ltd.
>
> > -----Original Message-----
> > From: Geert Uytterhoeven <geert@xxxxxxxxxxxxxx>
> > Sent: Thursday, March 12, 2020 6:03 PM
> > To: Torii, Kenichi/éå åä <torii.ken1@xxxxxxxxxxx>
> > Cc: gregkh@xxxxxxxxxxxxxxxxxxx; erosca@xxxxxxxxxxxxxx;
> > linux-serial@xxxxxxxxxxxxxxx;
> linux-renesas-soc@xxxxxxxxxxxxxxx;
> > wsa+renesas@xxxxxxxxxxxxxxxxxxxx;
> > yoshihiro.shimoda.uh@xxxxxxxxxxx; uli+renesas@xxxxxxxx;
> > george_davis@xxxxxxxxxx; andrew_gabbasov@xxxxxxxxxx;
> > jiada_wang@xxxxxxxxxx; yuichi.kusakabe@xxxxxxxxxxxxx;
> > yasano@xxxxxxxxxxxxxx; linux-kernel@xxxxxxxxxxxxxxx;
> > jslaby@xxxxxxxx; yohhei.fukui@xxxxxxxxxxxxx; Ashizuka, Yuusuke/
> > èå éä <ashiduka@xxxxxxxxxxx>; magnus.damm@xxxxxxxxx
> > Subject: Re: [PATCH] serial: sh-sci: Support custom speed setting
> >
> > Hi Torii-san,
> >
> > On Thu, Mar 12, 2020 at 6:10 AM torii.ken1@xxxxxxxxxxx
> > <torii.ken1@xxxxxxxxxxx> wrote:
> > > On Tue, 11 Feb 2020 05:57:35 +0900,
> > > Greg Kroah-Hartman wrote:
> > > > On Thu, Jan 30, 2020 at 01:32:50PM +0100, Geert Uytterhoeven
> > wrote:
> > > > > On Wed, Jan 29, 2020 at 5:20 PM Eugeniu Rosca
> > <erosca@xxxxxxxxxxxxxx> wrote:
> > > > > > From: Torii Kenichi <torii.ken1@xxxxxxxxxxxxxx>
> > > > > >
> > > > > > This patch is necessary to use BT module and XM module
> with
> > DENSO TEN
> > > > > > development board.
> > > > > >
> > > > > > This patch supports ASYNC_SPD_CUST flag by
> ioctl(TIOCSSERIAL),
> > enables
> > > > > > custom speed setting with setserial(1).
> > > > > >
> > > > > > The custom speed is calculated from uartclk and
> > custom_divisor.
> > > > > > If custom_divisor is zero, custom speed setting is invalid.
> > > > > >
> > > > > > Signed-off-by: Torii Kenichi <torii.ken1@xxxxxxxxxxxxxx>
> > > > > > [erosca: rebase against v5.5]
> > > > > > Signed-off-by: Eugeniu Rosca <erosca@xxxxxxxxxxxxxx>
> > > > >
> > > > > Thanks for your patch!
> > > > >
> > > > > While this seems to work fine[*], I have a few
> > comments/questions:
> > > > > 1. This feature seems to be deprecated:
> > > > >
> > > > > sh-sci e6e68000.serial: setserial sets custom speed
> > on
> > > > > ttySC1. This is deprecated.
> > > > >
> > > > > 2. As the wanted speed is specified as a divider, the
> resulting
> > speed
> > > > > may be off, cfr. the example for 57600 below.
> > > > > Note that the SCIF device has multiple clock inputs,
> and
> > can do
> > > > > 57600 perfectly if the right crystal has been fitted.
> > > > >
> > > > > 3. What to do with "[PATCH/RFC] serial: sh-sci: Update
> uartclk
> > based
> > > > > on selected clock"
> > (https://patchwork.kernel.org/patch/11103703/)?
> > > > > Combined with this, things become pretty complicated
> and
> > > > > unpredictable, as uartclk now always reflect the
> frequency
> > of the
> > > > > last used base clock, which was the optimal one for the
> > previously
> > > > > used speed....
> > > > >
> > > > > I think it would be easier if we just had an API to specify
> > a raw speed.
> > > > > Perhaps that already exists?
> > > >
> > > > Yes, see:
> > > > http://www.panix.com/~grante/arbitrary-baud.c
> > >
> > > I saw the code above, I thought I wouldn't write such code
> normally.
> > >
> > > >#include <linux/termios.h>
> > > >
> > > >int ioctl(int d, int request, ...);
> > >
> > > Do application programmers have to accept this bad code?
> >
> > I guess you mean the forward declaration of ioctrl()?
> > No, they should include <sys/ioctl.h> instead.
> >
> > Gr{oetje,eeting}s,
> >
> > Geert
> >
> > --
> > Geert Uytterhoeven -- There's lots of Linux beyond ia32 --
> > geert@xxxxxxxxxxxxxx
> >
> > In personal conversations with technical people, I call myself
> a
> > hacker. But
> > when I'm talking to journalists I just say "programmer" or
> something
> > like that.
> > -- Linus Torvalds