Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp1122475ybe; Wed, 11 Sep 2019 09:42:37 -0700 (PDT) X-Google-Smtp-Source: APXvYqxDCH+yWm9dy99rQnsKfDPjWpSS5LQbuS+6dpKXe521BI4Lo3KhxA0r0ElljKUmNjjkmcnF X-Received: by 2002:a17:906:4b49:: with SMTP id j9mr17436178ejv.81.1568220157404; Wed, 11 Sep 2019 09:42:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568220157; cv=none; d=google.com; s=arc-20160816; b=ASdzOxKNBAwi8VI5+BX19W8LDFGQdzb+juSCgTC19zVUfKQMvdIqzN7CYhiECNPVjB KQGj6I/VUfYfaTssRcN9FNdq+roawCLcG8ix7e6Vrk5uAkV1m60mx6fQZeCoFkN6Q4iY BIDcceKsEwp2NUIYs87qR8thY91F9KUYYYojEQ9CZEexb0CH6ayk54MTjlM3NAv5PZRo HPt0Wyc3FMc7ulXIyucA2YnjsThO3BrBFmKbK4Bxq8h/ahwpB+zwUkwtVrc660VibSCz p59SJvXmrG9qasis17Jyp3znpAbFQVOrWK0nOSncqpfRyZDqXaixgfvUJ+X/tCdAxspZ gwEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=D4jpq17am82Ic9f4k9BJafRwuUgAHim2OkBhBg71nqE=; b=SQYXLzmavfp94pk3Tq1g1/mKvsdL0JNiEJWmKSPTZXSIV62UBrpTSen3NmTLhK/x0/ gN/nRHTR/GjmilCdFKPOEOkUUVYasKKzrAiu54eaRkAi4djWj0bT9mv0sif1YFYRJLbX WmS9kaDyVAnodqwXfP5XXreXlrGPdibh60M7FZ3/jYY+YBMf1yWQG3rClbHw6MNNTkl4 pmv0R3JT86//ErN+K3jB2UJhnAe4V4p32Bc+KaJSldWAxnSHS62aiheAk8RzX1fD6ewU u49oZQf0GALmdBKqR1Z5WLTwo7vWtoJVXYULiMa72ohafqY7x115YpkXDEhJIpwz2jTU oozA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z42si14220346edz.23.2019.09.11.09.42.11; Wed, 11 Sep 2019 09:42:37 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729107AbfIKQkB (ORCPT + 99 others); Wed, 11 Sep 2019 12:40:01 -0400 Received: from 6.mo179.mail-out.ovh.net ([46.105.56.76]:38545 "EHLO 6.mo179.mail-out.ovh.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728828AbfIKQkA (ORCPT ); Wed, 11 Sep 2019 12:40:00 -0400 X-Greylist: delayed 2262 seconds by postgrey-1.27 at vger.kernel.org; Wed, 11 Sep 2019 12:39:59 EDT Received: from player761.ha.ovh.net (unknown [10.109.159.222]) by mo179.mail-out.ovh.net (Postfix) with ESMTP id 0CFA5141187 for ; Wed, 11 Sep 2019 18:02:16 +0200 (CEST) Received: from kaod.org (lfbn-1-2240-157.w90-76.abo.wanadoo.fr [90.76.60.157]) (Authenticated sender: clg@kaod.org) by player761.ha.ovh.net (Postfix) with ESMTPSA id 50A7F9B791FC; Wed, 11 Sep 2019 16:02:11 +0000 (UTC) Subject: Re: [PATCH v2] powerpc/xive: Fix bogus error code returned by OPAL To: Greg Kurz , Michael Ellerman Cc: Paul Mackerras , David Gibson , linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org References: <156821713818.1985334.14123187368108582810.stgit@bahia.lan> From: =?UTF-8?Q?C=c3=a9dric_Le_Goater?= Message-ID: Date: Wed, 11 Sep 2019 18:02:10 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <156821713818.1985334.14123187368108582810.stgit@bahia.lan> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-Ovh-Tracer-Id: 1911778042506414871 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedufedrtdefgdejtdcutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemucehtddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 11/09/2019 17:52, Greg Kurz wrote: > 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 Reviewed-by: Cédric Le Goater Thanks, C. > --- > v2: - fix syntax error in changelog > - Cc stable > - rename original OPAL wrapper > - rewrite fixup wrapper (style, use s64 and u32) > --- > arch/powerpc/include/asm/opal.h | 2 +- > arch/powerpc/platforms/powernv/opal-call.c | 2 +- > arch/powerpc/sysdev/xive/native.c | 11 +++++++++++ > 3 files changed, 13 insertions(+), 2 deletions(-) > > diff --git a/arch/powerpc/include/asm/opal.h b/arch/powerpc/include/asm/opal.h > index 57bd029c715e..d5a0807d21db 100644 > --- a/arch/powerpc/include/asm/opal.h > +++ b/arch/powerpc/include/asm/opal.h > @@ -272,7 +272,7 @@ int64_t opal_xive_get_vp_info(uint64_t vp, > int64_t opal_xive_set_vp_info(uint64_t vp, > uint64_t flags, > uint64_t report_cl_pair); > -int64_t opal_xive_allocate_irq(uint32_t chip_id); > +int64_t opal_xive_allocate_irq_raw(uint32_t chip_id); > int64_t opal_xive_free_irq(uint32_t girq); > int64_t opal_xive_sync(uint32_t type, uint32_t id); > int64_t opal_xive_dump(uint32_t type, uint32_t id); > diff --git a/arch/powerpc/platforms/powernv/opal-call.c b/arch/powerpc/platforms/powernv/opal-call.c > index 29ca523c1c79..dccdc9df5213 100644 > --- a/arch/powerpc/platforms/powernv/opal-call.c > +++ b/arch/powerpc/platforms/powernv/opal-call.c > @@ -257,7 +257,7 @@ OPAL_CALL(opal_xive_set_queue_info, OPAL_XIVE_SET_QUEUE_INFO); > OPAL_CALL(opal_xive_donate_page, OPAL_XIVE_DONATE_PAGE); > OPAL_CALL(opal_xive_alloc_vp_block, OPAL_XIVE_ALLOCATE_VP_BLOCK); > OPAL_CALL(opal_xive_free_vp_block, OPAL_XIVE_FREE_VP_BLOCK); > -OPAL_CALL(opal_xive_allocate_irq, OPAL_XIVE_ALLOCATE_IRQ); > +OPAL_CALL(opal_xive_allocate_irq_raw, OPAL_XIVE_ALLOCATE_IRQ); > OPAL_CALL(opal_xive_free_irq, OPAL_XIVE_FREE_IRQ); > OPAL_CALL(opal_xive_get_vp_info, OPAL_XIVE_GET_VP_INFO); > OPAL_CALL(opal_xive_set_vp_info, OPAL_XIVE_SET_VP_INFO); > diff --git a/arch/powerpc/sysdev/xive/native.c b/arch/powerpc/sysdev/xive/native.c > index 37987c815913..ad8ee7dd7f57 100644 > --- a/arch/powerpc/sysdev/xive/native.c > +++ b/arch/powerpc/sysdev/xive/native.c > @@ -231,6 +231,17 @@ static bool xive_native_match(struct device_node *node) > return of_device_is_compatible(node, "ibm,opal-xive-vc"); > } > > +static s64 opal_xive_allocate_irq(u32 chip_id) > +{ > + s64 irq = opal_xive_allocate_irq_raw(chip_id); > + > + /* > + * Old versions of skiboot can incorrectly return 0xffffffff to > + * indicate no space, fix it up here. > + */ > + return irq == 0xffffffff ? OPAL_RESOURCE : irq; > +} > + > #ifdef CONFIG_SMP > static int xive_native_get_ipi(unsigned int cpu, struct xive_cpu *xc) > { >