From: Ley Foon Tan <lftan.linux@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] lib: tiny-printf: Add "%ll" modifier support
Date: Fri, 22 Mar 2019 09:28:21 +0800 [thread overview]
Message-ID: <CAFiDJ59RksFgRmqNM1cFRoGxcMS0Xj2=u=6aR6BPkHvwmM+pbg@mail.gmail.com> (raw)
In-Reply-To: <20190321112223.GP18421@bill-the-cat>
On Thu, Mar 21, 2019 at 7:22 PM Tom Rini <trini@konsulko.com> wrote:
>
> On Fri, Mar 22, 2019 at 01:12:14AM +0800, Ley Foon Tan wrote:
>
> > Add "%ll" modifier support for tiny printf.
> >
> > - Tested on ARM32 and ARM64 systems.
> > - Tested "%lld", "%llu", "%llx" and "%p" format with
> > minimum and maximum ranges. Compared tiny printf
> > output with full printf.
> >
> > Signed-off-by: Ley Foon Tan <ley.foon.tan@intel.com>
> > ---
> > lib/tiny-printf.c | 42 +++++++++++++++++++++++++++++-------------
> > 1 file changed, 29 insertions(+), 13 deletions(-)
>
> What's the use case for this, how much does it grow the size, and can
> the code in question be changed to use a different format modifier or be
> debug() instead? Tiny printf isn't intended to cover all formats but
> rather still allow some amount of printf on constrained systems.
> Thanks!
>
> --
> Tom
This is to support printf %lld, %llu and %llx and 64-bit %p when
CONFIG_USE_TINY_PRINTF=y is enabled.
In 64-bit system, phys_size_t and phys_addr_t are unsigned long long.
Printf these variables will see rubbish in existing tiny printf.
Example %ll printf;
printf("9223372036854775807 ==> %lld \n", (long long)9223372036854775807);
printf("0xffffffffffffffff ==> 0x%llx \n", (unsigned long
long)0xffffffffffffffff);
There are few issues I've noticed with original tiny printf:
- Some common codes use %ll format
- %p in tiny printf only support 32-bit, it can't support 64-bit address.
If DEBUG is defined and with tiny printf. You can see all rubbish x
for %llx printf. The most serious issue is it cause system hang at
line below (printf from common code).
addr=x level=0
idx=x PTE at level 16384: x
Creating table for virt 0xx
Setting 4000 to addr=5000
addr=x level=0
idx=x PTE at level 16384: x
idx=x PTE at level 20480: x
Checking if pte fits for virt=x size=x blocksize=x
Setting PTE 5000 to block virt=x
addr=x level=1073741824
idx=x PTE at level 16384: x
addr=x level=1073741824
idx=x PTE at level 16384: x
idx=x PTE 1 at level 20488: x
Checking if pte fits for virt=x size=x blocksize=x
Setting PTE 5008 to block virt=x
addr=x level=
Example output after apply this patch:
idx=0 PTE 8000 at level 0: 9003
idx=3 PTE 9018 at level 1: a003
Checking if pte fits for virt=c0600000 size=1fa00000 blocksize=40000000
addr=c0600000 level=2
idx=0 PTE 8000 at level 0: 9003
idx=3 PTE 9018 at level 1: a003
ARM64:
----------
It increase 200 bytes.
Before:
text data bss dec hex filename
69618 5296 232 75146 1258a spl/u-boot-spl
After:
text data bss dec hex filename
69818 5296 232 75346 12652 spl/u-boot-spl
ARM32:
----------
It increase 644 bytes.
Before:
text data bss dec hex filename
31825 2968 132 34925 886d spl/u-boot-spl
After:
text data bss dec hex filename
32469 2968 132 35569 8af1 spl/u-boot-spl
Regards
Ley Foon
next prev parent reply other threads:[~2019-03-22 1:28 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-21 17:12 [U-Boot] [PATCH] lib: tiny-printf: Add "%ll" modifier support Ley Foon Tan
2019-03-21 11:22 ` Tom Rini
2019-03-22 1:28 ` Ley Foon Tan [this message]
2019-03-22 1:31 ` Tom Rini
2019-03-22 9:01 ` Ley Foon Tan
2019-03-22 11:47 ` Tom Rini
2019-03-22 10:53 ` Marek Vasut
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='CAFiDJ59RksFgRmqNM1cFRoGxcMS0Xj2=u=6aR6BPkHvwmM+pbg@mail.gmail.com' \
--to=lftan.linux@gmail.com \
--cc=u-boot@lists.denx.de \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.