phb3: Don't try to enable CAPI without microcode

If the microcode load didn't work, don't try to enable CAPI
mode on the PHB.

(Patch originally from grimm@linux.vnet.ibm.com but submitted
without proper cset or s-o-b before he went on vacation,
so taking ownership)

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
phb3: Fixup CAPP microcode loading

Check the PHB version and properly adjust the LID number for
the IPL side.

(Based on a patch from michael.neuling@au1.ibm.com and reworked)

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
phb3: Fix snoop capi config register in phb->capp procedure

Set bit 0 so tTypes are snooped and decoded by the capp unit.  Bits 2:3 selects
precise dir size.

Signed-off-by: Ryan Grimm <grimm@linux.vnet.ibm.com>
Acked-By: Michael Neuling <mikey@neuling.org>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Fix build with GNU Make 4.0

It expands our % on the right hand of the built-in.o rule into
the directory name extracted from the prefix of the left hand
and that makes ld puke.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
fsp: Remove unused fields in fsp_msg

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
opal: Replace fsp_poll() with a full run of all OPAL pollers

Otherwise we don't handle surveillance and PSI link monitoring

This should fix cases of surveillance timeouts during things
like code update such as BZ109939

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
fsp-console: Don't wait synchronously on console assoc/deassoc

We can be called from a poller, calling the poller again has no
effect and we might just end up dead locking. There is no reason
to be synchronous anyway.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
fsp: Make more message asynchronous

It's not a great idea to try to call fsp_sync_msg from an FSP callback
since the pollers won't run if we already have the poll lock (we might
do something about that at some point but not just yet)

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
lock: Add helper to check if this CPU is already holding a lock

For debug purposes essentially

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
timebase: Add "nopoll" variants of the delays

In case where we don't want to recurse into opal pollers

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
opal: Add a debug helper to check for poller recursion

And check & warn inside opal_run_pollers() as well

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
fsp: Check for recursion in fsp_sync_msg

We avoid the normal check path in opal.c so we can fallback to
__fsp_poll and still make progress, it also limits the amount
of error messages displayed.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
FSP: Fix state check to trigger link down

The fsp_mbx_err state is currently abused in the HIR path and its use there
is incosistent with its intended purpose. So add a fsp_mbx state to indicate
completion of the HIR steps, so the R/R procedure is triggered in the normal
path.

When in the FSP error path, do not bring the PSI link down if the link down
check fails and the fsp mbx state is fsp_mbx_hir_seq_done. Also use this
additional state to determine a late state error.

Tested on P7. Awaiting response to FW issues on P8.

Signed-off-by: Ananth N Mavinakayanahalli <ananth@in.ibm.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
phb3: Increase size allotted for capp microcode.

Current microcode lid ~37k.  Must have grown.  Without this size increase, only
the partial lid is in memory.

[ BenH: Bumped from 64k to 128k to get some margin ]

Signed-off-by: Ryan Grimm <grimm@linux.vnet.ibm.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
phb3: Fix pointer arithmetic when parsing ucode structs.

This code worked when bml loaded the ucode by placing it in memory but not with
fsp load.

The cast (uint64_t)ucode_hdr mucked with the pointer and caused ->eye_catcher
to return 0.

Simplify other pointer math as well making code more readable.

Signed-off-by: Ryan Grimm <grimm@linux.vnet.ibm.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
phb3: Parse capp microcode lid if lid header in memory.

bml load and older firmware loads do not place the lid header in memory.  Newer
firmware versions do.  Look for lid header eyecatcher and if not found try
ucode eyecatcher to support bml and older firmware.

Signed-off-by: Ryan Grimm <grimm@linux.vnet.ibm.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
phb3: Support capp microcode load for murano phb3 dd2.0

Murano phb3 dd2.0's are still being assembled in the lab and tested with capi
cards.  In this case for the surelock effort.

Signed-off-by: Ryan Grimm <grimm@linux.vnet.ibm.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
phb3: Remove recursive locking

I can't quite figure what this code was trying to do, but
I don't see how it would help, phb3_read_phb_status() should
already have the right amount of locking in the caller.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
p7ioc-phb: Remove recursive locking

I can't quite figure what this code was trying to do, but
I don't see how it would help, phb3_read_phb_status() should
already have the right amount of locking in the caller.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
opal: poller re-entrancy try #3

So my great attempt at avoiding all re-entencies fails due to HBRT... at
least until we have some kind of way to thread things, it will have to
re-enter so let's bite the bullet, make the poller list walking lockless
(we'll handle removal when we have to, ie, not yet) and slightly extend
the coverage of the PSI lock while at it. All the other pollers already
have their own locks anyway so we are actually removing some overhead.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>