mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Antony Pavlov <antonynpavlov@gmail.com>
To: barebox <barebox@lists.infradead.org>
Subject: Re: [PATCH 2/2] serial_ns16550: use 'struct device_d *' instead of 'struct console_device *'
Date: Thu, 4 Aug 2011 08:54:43 +0400	[thread overview]
Message-ID: <CAA4bVAFg_JROsx88dAFUmfVamLPB-Ui-vguCmtb2bz1pk0y7AQ@mail.gmail.com> (raw)
In-Reply-To: <20110804003702.GF24730@game.jcrosoft.org>

On 4 August 2011 04:37, Jean-Christophe PLAGNIOL-VILLARD
<plagnioj@jcrosoft.com> wrote:
> On 22:37 Wed 03 Aug     , Antony Pavlov wrote:
>> ns16550_read() and ns16550_write() functions are private functions
>> of the driver so there is no need to pass them 'struct console_device *'
>> pointer to get private device data.
>>
>> Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
>> ---

> Does not simplify the code
>
> does not see the need

Just the opposite!

Without this patch we do the operation 'dev = cdev->dev' at _EVERY
SINGLE CALL_ of ns16550_read/ns16550_write.

In the driver, only in ns16550_tstc() we have single call of
ns16550_read(). In all other places we have multiple
ns16550_read/ns16550_write. So we can move 'dev = cdev->dev'
to caller without any damage.

Moreover, in ns16550_putc() we have cycle:
----
while ((ns16550_read(dev, lsr) & LSR_THRE) == 0) ;
----
On every cycle loop we do 'dev = cdev->dev' !

Disassemble the compiled barebox and you will see that you have many
memory memory accesses at the entrance to the
ns16550_read/ns16550_write functions.

So, removing this 'dev = cdev->dev' we remove one memory access.

This is a real optimization!

Also, confirmation of this patch comes from simple logic.

Simple question.
Have we need of 'console_device *cdev' pointer in
ns16550_read/ns16550_write at all?

My answer is 'No'.

Console_device is very high-level abstraction structure, but
ns16550_read/ns16550_write functions work at the low-level.
They work with the private driver data, but cdev can't directly supply
this private data.

-- 
Best regards,
  Antony Pavlov

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  reply	other threads:[~2011-08-04  4:54 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-03 18:37 [PATCH 1/2] serial_ns16550: move switch from ns16550_{read, write}() to ns16550_probe() Antony Pavlov
2011-08-03 18:37 ` [PATCH 2/2] serial_ns16550: use 'struct device_d *' instead of 'struct console_device *' Antony Pavlov
2011-08-04  0:37   ` Jean-Christophe PLAGNIOL-VILLARD
2011-08-04  4:54     ` Antony Pavlov [this message]
2011-08-04  0:42 ` [PATCH 1/2] serial_ns16550: move switch from ns16550_{read, write}() to ns16550_probe() Jean-Christophe PLAGNIOL-VILLARD
2011-08-04  7:30   ` Antony Pavlov
2011-08-04  7:19 ` Sascha Hauer
2011-08-04  7:38   ` Antony Pavlov
2011-08-04  7:51     ` Sascha Hauer

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=CAA4bVAFg_JROsx88dAFUmfVamLPB-Ui-vguCmtb2bz1pk0y7AQ@mail.gmail.com \
    --to=antonynpavlov@gmail.com \
    --cc=barebox@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