Re: [U-Boot] [RESEND][PATCH 00/24] sh: add generic board support and fixes

2016-11-28 Thread Tom Rini
On Tue, Nov 29, 2016 at 02:58:41AM +0200, Vladimir Zapolskiy wrote:
> Hi Tom,
> 
> On 11/28/2016 05:43 PM, Tom Rini wrote:
> > On Mon, Nov 28, 2016 at 12:15:12AM +0200, Vladimir Zapolskiy wrote:
> > 
> >> This is a combined series of the fixes to SH2/SH3/SH4/SH4A architecture 
> >> port
> >> of U-boot on top of the master branch, there is no functional difference
> >> between this series and 3 my series sent in August 2016 for 2016.09, 
> >> however
> >> due to many positive generalization updates to U-boot sources the old
> >> unreviewed series can not be cleanly applied anymore:
> >>
> >> * [PATCH 0/6] sh4: fix and simplify cache manipulation
> >> * [PATCH 0/5] sh4: fixes to SH7751 PCI host controller
> >> * [PATCH] common: sh: add necessary define bits to board_f
> >> * [PATCH 00/12] sh: change arch and boards code to generic board
> >>
> >> I have to resend the changes, because apparently Nobuhiro Iwamatsu is
> >> too busy to maintain SH port and I ask Tom/Simon/Marek and other active
> >> U-boot developers to review and apply the changes, it is highly desirable
> >> to have a possibility to run modern U-boot on boards powered by SH cores.
> > 
> > First, would you be interested in taking up the SH maintainership?
> 
> clearly Renesas abandoned SH architecture as a legacy one (and probably
> as a competing with R-Car one), but until J4 core as a replacement for
> Renesas SH4 is released by j-core.org project it is desirable to keep
> U-Boot running on SH platforms.
> 
> I'm interested in maintainership of SH and thereafter J-Core cores, but
> practically I have only one SH4 powered board on hand, unfortunately
> begging for hardware donations was not so successful. At the moment
> U-Boot contains SH2A/SH3/SH4/SH4A arch support and boards, I have to
> figure out where to get more boards to cover more SoC flavours, and
> getting legacy hardware is always a problem, because it is not on
> a store's shelf.
> 
> To start from I would recommend to decouple u-boot-sh.git fork into
> independent SH and ARM R-Car repositories, the latter one will be
> maintained by Renesas associates.

I'm interesting in having J-Core work and be maintained in U-Boot, so
lets make this work.  With regards to legacy platforms, I'm happy to
drop things which are unavailable / non-functional and just note in
doc/README.scrapyard when things were removed.  We did this a lot around
a year ago and probably should again.

And then yes, the R-Car patches should come in via another repository
rather than u-boot.sh as was previously convenient.

> > Second, I know before you told me how to get QEMU to run, but with this
> > series and:
> > qemu-system-sh4 -M r2d -kernel r2dplus/current/r2dplus/u-boot.bin
> > -nographic -serial null -serial vc
> > 
> > I get:
> > QEMU 2.5.91 monitor - type 'help' for more information
> > (qemu) long write to SH7750_WCR1_A7 (0x1f88) ignored
> > long write to SH7750_WCR2_A7 (0x1f8c) ignored
> > long write to SH7750_WCR3_A7 (0x1f800010) ignored
> > long write to SH7750_MCR_A7 (0x1f800014) ignored
> > word write to SH7750_RTCNT_A7 (0x1f800020) ignored
> > word write to SH7750_RTCOR_A7 (0x1f800024) ignored
> > Write access to refresh count register
> > word write to SH7750_RTCSR_A7 (0x1f80001c) ignored
> > Read access to refresh count register, incrementing
> > long write to SH7750_MCR_A7 (0x1f800014) ignored
> > long read to SH7750_WCR1_A7 (0x1f88) ignored
> > long read to SH7750_WCR2_A7 (0x1f8c) ignored
> > long read to SH7750_WCR3_A7 (0x1f800010) ignored
> > long read to SH7750_MCR_A7 (0x1f800014) ignored
> > 
> > and the qemu monitor/debug prompt.
> 
> The displayed qemu output is expected and can be ignored, currently SH
> port in qemu is in "odd fixes" maintainership stage, hopefully I'll
> find time to send a patch to silence this.

Ah, OK.

> > Without -serial args I just get the
> > hang.  Any ideas?  I ask since I'm keen to add r2dplus to test.py and
> > travis-ci once it's working, thanks!
> > 
> 
> I use this list of components to build and test U-Boot on r2dplus
> qemu target and SH7751 powered board I have on hand (it is quite
> similar to r2dplus devkit):
> 
> * SH4 toolchain from buildroot distro with musl (libc flavour most
>   probably is unrelated to U-boot or kernel):
>  - gcc-5.3.0
>  - musl-1.1.12
>  - linux-4.4 headers
> 
> * qemu-system-sh4 is from standard Debian qemu-system-misc package:
>  - qemu-system-misc-1:2.6+dfsg-3
>  - qemu-2.6.50 vanilla build also works for me fine
> 
> * U-Boot compilation:
> 
> % make ARCH=sh CROSS_COMPILE=sh4-buildroot-linux-musl-
> CC='sh4-buildroot-linux-musl-gcc -Wall' r2dplus_defconfig
> 
> % make ARCH=sh CROSS_COMPILE=sh4-buildroot-linux-musl-
> CC='sh4-buildroot-linux-musl-gcc -Wall' u-boot.bin
> 
> Command to run qemu with output directly to a console is similar to
> the command you mentioned above (press Ctrl-C to terminate):
> 
> % 

Re: [U-Boot] [RESEND][PATCH 00/24] sh: add generic board support and fixes

2016-11-28 Thread Vladimir Zapolskiy
Hi Tom,

On 11/28/2016 05:43 PM, Tom Rini wrote:
> On Mon, Nov 28, 2016 at 12:15:12AM +0200, Vladimir Zapolskiy wrote:
> 
>> This is a combined series of the fixes to SH2/SH3/SH4/SH4A architecture port
>> of U-boot on top of the master branch, there is no functional difference
>> between this series and 3 my series sent in August 2016 for 2016.09, however
>> due to many positive generalization updates to U-boot sources the old
>> unreviewed series can not be cleanly applied anymore:
>>
>> * [PATCH 0/6] sh4: fix and simplify cache manipulation
>> * [PATCH 0/5] sh4: fixes to SH7751 PCI host controller
>> * [PATCH] common: sh: add necessary define bits to board_f
>> * [PATCH 00/12] sh: change arch and boards code to generic board
>>
>> I have to resend the changes, because apparently Nobuhiro Iwamatsu is
>> too busy to maintain SH port and I ask Tom/Simon/Marek and other active
>> U-boot developers to review and apply the changes, it is highly desirable
>> to have a possibility to run modern U-boot on boards powered by SH cores.
> 
> First, would you be interested in taking up the SH maintainership?

clearly Renesas abandoned SH architecture as a legacy one (and probably
as a competing with R-Car one), but until J4 core as a replacement for
Renesas SH4 is released by j-core.org project it is desirable to keep
U-Boot running on SH platforms.

I'm interested in maintainership of SH and thereafter J-Core cores, but
practically I have only one SH4 powered board on hand, unfortunately
begging for hardware donations was not so successful. At the moment
U-Boot contains SH2A/SH3/SH4/SH4A arch support and boards, I have to
figure out where to get more boards to cover more SoC flavours, and
getting legacy hardware is always a problem, because it is not on
a store's shelf.

To start from I would recommend to decouple u-boot-sh.git fork into
independent SH and ARM R-Car repositories, the latter one will be
maintained by Renesas associates.

> Second, I know before you told me how to get QEMU to run, but with this
> series and:
> qemu-system-sh4 -M r2d -kernel r2dplus/current/r2dplus/u-boot.bin
> -nographic -serial null -serial vc
> 
> I get:
> QEMU 2.5.91 monitor - type 'help' for more information
> (qemu) long write to SH7750_WCR1_A7 (0x1f88) ignored
> long write to SH7750_WCR2_A7 (0x1f8c) ignored
> long write to SH7750_WCR3_A7 (0x1f800010) ignored
> long write to SH7750_MCR_A7 (0x1f800014) ignored
> word write to SH7750_RTCNT_A7 (0x1f800020) ignored
> word write to SH7750_RTCOR_A7 (0x1f800024) ignored
> Write access to refresh count register
> word write to SH7750_RTCSR_A7 (0x1f80001c) ignored
> Read access to refresh count register, incrementing
> long write to SH7750_MCR_A7 (0x1f800014) ignored
> long read to SH7750_WCR1_A7 (0x1f88) ignored
> long read to SH7750_WCR2_A7 (0x1f8c) ignored
> long read to SH7750_WCR3_A7 (0x1f800010) ignored
> long read to SH7750_MCR_A7 (0x1f800014) ignored
> 
> and the qemu monitor/debug prompt.

The displayed qemu output is expected and can be ignored, currently SH
port in qemu is in "odd fixes" maintainership stage, hopefully I'll
find time to send a patch to silence this.

> Without -serial args I just get the
> hang.  Any ideas?  I ask since I'm keen to add r2dplus to test.py and
> travis-ci once it's working, thanks!
> 

I use this list of components to build and test U-Boot on r2dplus
qemu target and SH7751 powered board I have on hand (it is quite
similar to r2dplus devkit):

* SH4 toolchain from buildroot distro with musl (libc flavour most
  probably is unrelated to U-boot or kernel):
 - gcc-5.3.0
 - musl-1.1.12
 - linux-4.4 headers

* qemu-system-sh4 is from standard Debian qemu-system-misc package:
 - qemu-system-misc-1:2.6+dfsg-3
 - qemu-2.6.50 vanilla build also works for me fine

* U-Boot compilation:

% make ARCH=sh CROSS_COMPILE=sh4-buildroot-linux-musl-
CC='sh4-buildroot-linux-musl-gcc -Wall' r2dplus_defconfig

% make ARCH=sh CROSS_COMPILE=sh4-buildroot-linux-musl-
CC='sh4-buildroot-linux-musl-gcc -Wall' u-boot.bin

Command to run qemu with output directly to a console is similar to
the command you mentioned above (press Ctrl-C to terminate):

% qemu-system-sh4 -M r2d -kernel u-boot.bin -monitor null -serial null
-serial stdio -nographic

This is an example of testing on my end (omitting "long write ..
ignored" messages):

U-Boot 2016.11-00195-ge01f392eab43 (Nov 29 2016 - 02:55:25 +0200)

CPU: SH4
BOARD: Renesas Solutions R2D Plus
DRAM:  64 MiB
Flash: ERROR: too many flash sectors
8 MiB
*** Warning - bad CRC, using default environment

PCI: SH7751 PCI host bridge found.
long read to SH7750_WCR1_A7 (0x1f88) ignored
long read to SH7750_WCR2_A7 (0x1f8c) ignored
long read to SH7750_WCR3_A7 (0x1f800010) ignored
long read to SH7750_MCR_A7 (0x1f800014) ignored
PCI:   Bus Dev VenId DevId Class Int
PCI:
  00:00.0 - 1054:350e 

[U-Boot] [RESEND][PATCH 00/24] sh: add generic board support and fixes

2016-11-27 Thread Vladimir Zapolskiy
This is a combined series of the fixes to SH2/SH3/SH4/SH4A architecture port
of U-boot on top of the master branch, there is no functional difference
between this series and 3 my series sent in August 2016 for 2016.09, however
due to many positive generalization updates to U-boot sources the old
unreviewed series can not be cleanly applied anymore:

* [PATCH 0/6] sh4: fix and simplify cache manipulation
* [PATCH 0/5] sh4: fixes to SH7751 PCI host controller
* [PATCH] common: sh: add necessary define bits to board_f
* [PATCH 00/12] sh: change arch and boards code to generic board

I have to resend the changes, because apparently Nobuhiro Iwamatsu is
too busy to maintain SH port and I ask Tom/Simon/Marek and other active
U-boot developers to review and apply the changes, it is highly desirable
to have a possibility to run modern U-boot on boards powered by SH cores.

The changeset implements initial support of relocatable U-Boot code
for SH2/SH3/SH4 architectures and boards, as weel as it restores
a possibility to boot U-Boot on SH boards, which has not been converted
to generic board in time (for more details see commit f41e6088eb1
("sh: Fix build errors for generic board")). Special attention from
maintainers of all touched boards is required, due to inaccessibility
of hardware for me it would be a troublesome task.

*** CACHE SUPPORT COVER LETTER ***

In my tests I experience that sometimes SH4 does not properly
fetch instructions after immediate jump to a code loaded by
means of rtl8139, the problem is gone if "icache off" is
executed after load or if cache invalidation and write-back
is used on data load instead of just cache invalidation,
which is apparently an improper backbone of flush_dcache_range()
function.

The changeset contains a couple of bugfixes and a general
simplification of the code related to cache manipulation. Note
that while caches are found on SH2 and SH3 for long time
they were inactive in U-Boot, because I don't have SH2/SH3
hardware for testing I don't spread SH4 cache fixes to those
cpus, however generally it should be the same, in that case
arch/sh/cpu/sh4/cache.c file can be moved to arch/sh/lib
folder

*** PCI CONTROLLER CHANGES COVER LETTER ***

This series fixes 2 bugs found in SH7751 PCI host controller driver,
also it restores r2dplus defconfig and slightly simplifies the code
related to the SH7751 PCI controller, more improvements may follow
in future.

The change is independent on the following conversion to generic
board, however it adds some bits to simplify porting of r2dplus
board by moving board specific CONFIG_SYS_TEXT_BASE into P1 area,

Before the change even if rtl8139 driver is selected in a defconfig
the device was unusable due to invalid phys to bus mapping (e.g. test
with 'dhcp' command shows it), this most probably was caused by some
unnoticed generic change in PCI driver framework, however now it is
fixed by the series.

*** GENERIC BOARD CHANGES COVER LETTER ***

Now code/data initialization and relocation in general resemble the
procedure on ARM with minor peculiarities (same one relocation from a
storage device if calculated reloc_off == 0, otherwise two relocations),
however please note that the change does *not* add PIE support (only PIC),
so it may end up that there are persistent pointers to some non-relocated
data, this point requires better investion.

Only r2dplus board is actually converted to support new architectural
changes, the rest of the boards require attention from board maintainers
or they will be removed. Board maintainers may pay attention to
CONFIG_SYS_MALLOC_CLEAR_ON_INIT, CONFIG_NEEDS_MANUAL_RELOC,
CONFIG_SYS_GENERIC_GLOBAL_DATA etc. options.

This r2dplus board change allows immediately check the correctness of
the series on a r2dplus qemu target, note that the second copy is
not avoided in this case, also for simplicity SDRAM area up to text base
is large enough to store malloc pool and two copies of loaded code/data.

The change was tested on one custom SH4 (SH7551R) board, r2dplus qemu
target (see also SH7751 PCI change under review), the rest of the boards
are compile tested only.

Multiple kudos to Simon for great patience and a decision to not remove
the code.

Vladimir Zapolskiy (24):
  sh4: cache: correct dcache flush to invalidate with write-back
  sh4: cache: correct flush_cache() to writeback and invalidate
  sh3: remove unused cache.c file from being built
  sh: cache use jump_to_P2() and back_to_P1() from asm/system.h
  sh: cache: don't modify CCR from P1 area
  sh4: cache: move exported cache manipulation functions into cache.c
  pci: sh7751: fix up PCI I/O space address
  pci: sh7751: map PCI memory space into SDRAM
  sh4: remove __io config options from r2dplus and r7780mp boards
  r2dplus: use P1 area space for text base and PCI system memory
  r2dplus: select rtl8139 driver in defconfig
  common: sh: add necessary define bits to board_f
  sh4: use single u-boot linker script for all boards
  sh: place board