public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
From: dongas86@gmail.com (Dong Aisheng)
To: linux-arm-kernel@lists.infradead.org
Subject: [V2, 2/6] tty: serial: lpuart: add little endian 32 bit register support
Date: Fri, 19 May 2017 23:07:22 +0800	[thread overview]
Message-ID: <20170519150722.GB23227@b29396-OptiPlex-7040> (raw)
In-Reply-To: <045d1888-4a23-cf73-ab4c-009e29fde974@cogentembedded.com>

On Wed, May 17, 2017 at 11:04:04AM +0300, Nikita Yushchenko wrote:
> Hi
> 
> My view of your statement is:
> - you currently assume only a few cases for this driver - builtin UART
> in vf610, ls1012a and imx7,
> - in each of these cases, all lpuart instances share same endian, thus
> having that in global var works for these cases,
> - having that in global var makes it possible for you to write less
> lines of code
> 
> My complain is:
> - in Linux, we are trying to keep drivers generic,
> - in Linux, having less lines of code has never been sufficient to break
> basic data structure consistency,
> - having driver to keep per-device capability in global var is a clear
> case of breaking consistency.
> 

Yes, i do understand your concern and i absolutely agree with the rule
you mentioned.

> 
> >>> That's for special case, normally we wouldn't do that.
> >>
> >> For me this "special case" looks like "let's break data structure
> >> consistency to reuse several lines of code".
> >>
> >> With code snippets you show, it looks even worse: you assign same global
> >> variable in several places for different uses. 
> > 
> > If you mean lpuart_is_be, it's not for different uses.
> > The purpose is the same to align the correct endian but in two places.
> 
> _probe() routine called for device X alters state already in use for
> device Y.
> 

Okay, you're saying two different types of devices appeared in one SoC.

> > 
> >> implicitly assuming that
> >> it is for same device. Which can be true in your current system, but not
> >> elsewhere (e.g. why not having lpuart programmed into fpga)?
> >>
> > 
> > Sorry, What issues for fpga?
> 
> Connect FPGA to IMX7 based system and program LS1012a version of lpuart
> core into it.  Have your console on system UART broken at time when
> driver gets registered.
> 

Well, theoretically it may happen.

> 
> > 
> >> Alternative solution could be - have separate write path for earlycon.
> > 
> > It looks to me having the same issue with a separate write patch
> > for earlycon as we still need distinguish Little or Big endian
> > for Layerscape and IMX.
> > 
> >> At a glance, it is dozen lines of code.
> > 
> > Would you please show some sample code?
> 
> Do not reuse lpuart32_console_putchar() in earlycon code.
> 
> Have two sets of early_setup/early_write/putchar - for BE and
> defaut-endian earlycon. And in these putchar's do not use
> lpuart_(read|write).
> 

Isn't that introducing another consistency break after fix one
consistency break?

If doing that, we then have two register read/write APIs.
One for normal driver operation by dynamically checking lpuart_is_be
property to distinguish the endian difference problem.
Another is specifically implemented for only early console read/write
and use hardcoded way to read/write register directly instead of using
the standard API lpuart32_read/write, like follows:
e.g.
lpuart32_le_console_write() {
	 writel();
}

lpuart32_be_console_write() {
	 iowrite32be()
}
This also makes the driver a bit strange and ugly.

It looks to me both way are trade offs and the later one seems sacrifice
more. And i doubt if it's really necessary for probably a no real gain
purpose as the FPGA you mentioned is a theoretical case and less
possibility to exist.

I'm still wondering how about keep using the exist way and adding more
information in code to explain why use a global var?

Regards
Dong Aisheng

> 
> As far as I can see, fsl_lpuart.c already has two drivers in one -
> there is separate set of routines for 8bit and 32bit cases.
> And those routines that are common, have if blocks that separate cases.
> I think these drivers will be cleaner if separated.
> However that's completely different story.

  reply	other threads:[~2017-05-19 15:07 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-15  7:48 [PATCH V2 0/6] tty: serial: lpuart: add imx7ulp support Dong Aisheng
2017-05-15  7:48 ` [PATCH V2 1/6] tty: serial: lpuart: introduce lpuart_soc_data to represent SoC property Dong Aisheng
2017-05-15 13:35   ` Andy Shevchenko
2017-05-15  7:48 ` [PATCH V2 2/6] tty: serial: lpuart: add little endian 32 bit register support Dong Aisheng
2017-05-15 13:36   ` Andy Shevchenko
2017-05-17  3:26     ` Dong Aisheng
2017-05-16 11:08   ` [V2, " Nikita Yushchenko
2017-05-17  3:31     ` Dong Aisheng
2017-05-17  5:43       ` Nikita Yushchenko
2017-05-17  6:01         ` A.S. Dong
2017-05-17  6:25           ` Nikita Yushchenko
2017-05-17  7:00             ` Dong Aisheng
2017-05-17  8:04               ` Nikita Yushchenko
2017-05-19 15:07                 ` Dong Aisheng [this message]
2017-05-23  5:24                   ` Nikita Yushchenko
2017-05-31  8:07                     ` Dong Aisheng
2017-05-16 11:15   ` Nikita Yushchenko
2017-05-17  3:39     ` Dong Aisheng
2017-05-17  5:37       ` Nikita Yushchenko
2017-05-17  5:43         ` Dong Aisheng
2017-05-17  5:50           ` Nikita Yushchenko
2017-05-17  6:09             ` Dong Aisheng
2017-05-17  9:55           ` Andy Shevchenko
2017-05-31  7:47             ` Dong Aisheng
2017-05-17  9:53     ` Andy Shevchenko
2017-05-15  7:48 ` [PATCH V2 3/6] dt-bindings: serial: fsl-lpuart: add i.MX7ULP support Dong Aisheng
2017-05-15  7:48 ` [PATCH V2 4/6] tty: serial: lpuart: add imx7ulp support Dong Aisheng
2017-05-15  7:48 ` [PATCH V2 5/6] tty: serial: lpuart: add earlycon support for imx7ulp Dong Aisheng
2017-05-15  7:48 ` [PATCH V2 6/6] tty: serial: lpuart: add a more accurate baud rate calculation method Dong Aisheng
2017-05-15 17:06   ` Stefan Agner
2017-05-17  3:47     ` Dong Aisheng
2017-05-17 17:35       ` Stefan Agner
2017-05-19 11:50         ` Dong Aisheng

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 \
    --in-reply-to=20170519150722.GB23227@b29396-OptiPlex-7040 \
    --to=dongas86@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox