xive: fix return value of opal_xive_allocate_irq()
xive: fix return value of opal_xive_allocate_irq()

When the maximum number of interrupts per chip is reached,
xive_try_allocate_irq() returns an internal XIVE error:
XIVE_ALLOC_NO_SPACE. But its value 0xffffffff is interpreted as a
positive value by its caller opal_xive_allocate_irq() and not as an
error.

opal_xive_allocate_irq() returns this value to Linux which also
considers 0xffffffff as a valid interrupt number and tries to get the
interrupt characteritics using opal_xive_get_irq_info(). This OPAL
calls finally fails leading to all sort of errors on the host which is
not prepared for such a scenario. Code impacted are the IPI setup and
the both XIVE KVM devices.

Fix by returning OPAL_RESOURCE from xive_try_allocate_irq() which is
consistent with the other errors returned by this routine. This fixes
the behavior in opal_xive_allocate_irq() and in Linux.

A workaround could be introduced in Linux to consider 0xffffffff as a
OPAL_RESOURCE value. This assumption is valid with the current XIVE
IRQ number encoding.

Fixes: 07946e68f47a ("xive: Add interrupt allocator")
Reported-by: Greg Kurz <cc878073a22fe20c2ded9f6f326476101ddf4b25@kaod.org>
Signed-off-by: Cédric Le Goater <2d8cace2254d4e43578d21933db015d84bcc468a@kaod.org>
[oliver: Added fixes tag]
Signed-off-by: Oliver O'Halloran <3dfaff8fa6ae977f042064a112a6aac576279b9b@gmail.com>

shenki/skiboot,legoater/skiboot,legoater/skiboot,open-power/skiboot,qemu/skiboot,shenki/skiboot,open-power/skiboot,shenki/skiboot,qemu/skiboot,qemu/skiboot,open-power/skiboot,qemu/skiboot,legoater/skiboot,legoater/skiboot,shenki/skiboot,open-power/skiboot,shenki/skiboot,qemu/skiboot,open-power/skiboot,legoater/skiboot