occ/hbrt: Call stopOCC() for implementing reset OCC command from FSP

OPAL is expected to leave OCC stopped after receiving reset OCC
message from FSP.  FSP will send this either at boot before
a load/start, or during runtime before load/start. If there
is no subsequent load/start command, the OCC can be left stopped.

After few attempts (runtime reset), FSP can just send reset and
expect OPAL to leave OCC in stopped state.

Call HBRT to stop OCC on FSP reset OCC command and acknowledge.

Signed-off-by: Shilpasri G Bhat <shilpa.bhat@linux.vnet.ibm.com>
Signed-off-by: Vaidyanathan Srinivasan <svaidy@linux.vnet.ibm.com>
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
occ: Fix the low level ACK message sent to FSP on receiving {RESET/LOAD}_OCC

Modify the FSP response message to include the status code in the
status/error byte instead of adding a new word to it which is
incorrect.

FSP ack messages are 2 words with status in the 3rd byte of second
word.  Status byte is in the extra (3rd) word only on new status
messages from OPAL to FSP.

Code corrected based on FSP mailbox spec version 3.16.

Signed-off-by: Shilpasri G Bhat <shilpa.bhat@linux.vnet.ibm.com>
Signed-off-by: Vaidyanathan Srinivasan <svaidy@linux.vnet.ibm.com>
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
occ: Reduce stack usage in add_cpu_pstate_properties()

This function uses int arrays from stack that pushes stack usage to
more than 2kB. Reduce stack usage by allocating memory.

Ben H's stack check compile option exposed this usage count:

hw/occ.c: In function 'add_cpu_pstate_properties':
hw/occ.c:187:1: warning: the frame size of 2064 bytes is larger than
2048 bytes [-Wframe-larger-than=]

Signed-off-by: Vaidyanathan Srinivasan <svaidy@linux.vnet.ibm.com>
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
Merge branch 'update-2.1.1.1'
fix Makefile when using a build directory

When using a build directory different from the source tree, .C files
and make_version.sh are not found :

make: *** No rule to make target `libpore/p8_pore_table_gen_api_fixed.o', needed by `libpore/built-in.o'.
make: *** No rule to make target `make_version.sh', needed by `version.c'.

Signed-off-by: Cédric Le Goater <clg@fr.ibm.com>
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
FSP: Validate fsp_msg in fsp_queue_msg

There are many places where we just pass fsp_msg without
validating whether message allocation succeded or not (like
fsp_queue_msg(fsp_mkmsg(...))).

If message allocation fails then we endup crashing OPAL. This
patch validates fsp_msg before using.

Signed-off-by: Vasant Hegde <hegdevasant@linux.vnet.ibm.com>
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
Merge branch 'update-2.1.1.1'
Add Travis configuration

This will allow Travis CI (https://travis-ci.org) to build the firmware
and run the test suite. In the future we can also use it to run and
publish the results of scan-build and lcov.

Travis build environments are stuck back on 12.04, so we don't have a
powerpc cross compiler as part of the archive. Instead download one from
kernel.org and use that.

The 'make check' tests rely on newer -Wstack-usage flags that are not
present on the old version of gcc shipped with 12.04. Install 4.8 from
the toolchain ppa and set it to be the system default.

The tests also require valgrind, so include that in the VM environment.

Signed-off-by: Joel Stanley <joel@jms.id.au>
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
vsnprintf: Change print_itoa to use less stack

Remove recursive call in print_itoa to reduce the stack usage.

Signed-off-by: Shreyas B. Prabhu <shreyas@linux.vnet.ibm.com>
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
Include stdint.h for libc/test/run-time.c, fixing build

Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
Merge branch 'update-2.1.1.1'
Various fixes to dump_traces

Endian breakage, build breakage, ...

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Make lpc_interrupt() attribute const

It's a placeholder at the moment, which makes it easy to say "this never
gives a different answer". It also silences our one compiler warning:

hw/lpc.c: In function 'lpc_interrupt':
hw/lpc.c:457:6: warning: function might be candidate for attribute 'const' [-Wsuggest-attribute=const]

Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
abort if device tree parsing fails

I debugged a checkstop with a BML boot which turned out to be device
tree issues. A corrupt device tree is very likely to result in a
later checkstop, so abort in dt_expand to make debugging much easier.

Signed-off-by: Anton Blanchard <anton@samba.org>
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
Add attribute warn_unused_result to compiler.h and dt_expand_node

This would have thrown a compiler warning for cf8def9 rather than
failing at runtime.

Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
Liberally sprinkle attribute((warn_unused_result)) around the place

None of these actually produce any warnings. My next patch will.

Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
More trace endian fixes so make check works again

We need the core to do proper endian among others since that
code is compiled in run-trace

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Merge remote-tracking branch 'ltcgit/master'
Enable warn_unused_result for fsp_queue_msg()

We now get a bunch of warnings of places where we should go and fix
the code, yay!

(acked in discussing thread on list)

Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
Acked-by: Vasant Hegde <hegdevasant@linux.vnet.ibm.com>
Acked-by: Ananth N Mavinakayanahalli <ananth@in.ibm.com>
elog: (sensor) Replace prerror with elog

Replace prerror with 'elog' interface and correct one existing SRC
map from error type.

Signed-off-by: Neelesh Gupta <neelegup@linux.vnet.ibm.com>
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>