Skip to content

Commit 6ccb4ac

Browse files
gkurzmpe
authored andcommitted
powerpc/xive: Fix bogus error code returned by OPAL
There's a bug in skiboot that causes the OPAL_XIVE_ALLOCATE_IRQ call to return the 32-bit value 0xffffffff when OPAL has run out of IRQs. Unfortunatelty, OPAL return values are signed 64-bit entities and errors are supposed to be negative. If that happens, the linux code confusingly treats 0xffffffff as a valid IRQ number and panics at some point. A fix was recently merged in skiboot: e97391ae2bb5 ("xive: fix return value of opal_xive_allocate_irq()") but we need a workaround anyway to support older skiboots already in the field. Internally convert 0xffffffff to OPAL_RESOURCE which is the usual error returned upon resource exhaustion. Cc: stable@vger.kernel.org # v4.12+ Signed-off-by: Greg Kurz <groug@kaod.org> Reviewed-by: Cédric Le Goater <clg@kaod.org> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Link: https://lore.kernel.org/r/156821713818.1985334.14123187368108582810.stgit@bahia.lan
1 parent 92c94df commit 6ccb4ac

3 files changed

Lines changed: 13 additions & 2 deletions

File tree

‎arch/powerpc/include/asm/opal.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ int64_t opal_xive_get_vp_info(uint64_t vp,
272272
int64_t opal_xive_set_vp_info(uint64_t vp,
273273
uint64_t flags,
274274
uint64_t report_cl_pair);
275-
int64_t opal_xive_allocate_irq(uint32_t chip_id);
275+
int64_t opal_xive_allocate_irq_raw(uint32_t chip_id);
276276
int64_t opal_xive_free_irq(uint32_t girq);
277277
int64_t opal_xive_sync(uint32_t type, uint32_t id);
278278
int64_t opal_xive_dump(uint32_t type, uint32_t id);

‎arch/powerpc/platforms/powernv/opal-call.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ OPAL_CALL(opal_xive_set_queue_info, OPAL_XIVE_SET_QUEUE_INFO);
257257
OPAL_CALL(opal_xive_donate_page, OPAL_XIVE_DONATE_PAGE);
258258
OPAL_CALL(opal_xive_alloc_vp_block, OPAL_XIVE_ALLOCATE_VP_BLOCK);
259259
OPAL_CALL(opal_xive_free_vp_block, OPAL_XIVE_FREE_VP_BLOCK);
260-
OPAL_CALL(opal_xive_allocate_irq, OPAL_XIVE_ALLOCATE_IRQ);
260+
OPAL_CALL(opal_xive_allocate_irq_raw, OPAL_XIVE_ALLOCATE_IRQ);
261261
OPAL_CALL(opal_xive_free_irq, OPAL_XIVE_FREE_IRQ);
262262
OPAL_CALL(opal_xive_get_vp_info, OPAL_XIVE_GET_VP_INFO);
263263
OPAL_CALL(opal_xive_set_vp_info, OPAL_XIVE_SET_VP_INFO);

‎arch/powerpc/sysdev/xive/native.c‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,17 @@ static bool xive_native_match(struct device_node *node)
245245
return of_device_is_compatible(node, "ibm,opal-xive-vc");
246246
}
247247

248+
static s64 opal_xive_allocate_irq(u32 chip_id)
249+
{
250+
s64 irq = opal_xive_allocate_irq_raw(chip_id);
251+
252+
/*
253+
* Old versions of skiboot can incorrectly return 0xffffffff to
254+
* indicate no space, fix it up here.
255+
*/
256+
return irq == 0xffffffff ? OPAL_RESOURCE : irq;
257+
}
258+
248259
#ifdef CONFIG_SMP
249260
static int xive_native_get_ipi(unsigned int cpu, struct xive_cpu *xc)
250261
{

0 commit comments

Comments
 (0)