Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp5706195ybe; Tue, 10 Sep 2019 07:41:15 -0700 (PDT) X-Google-Smtp-Source: APXvYqxj4o9yaOsiS7vAKGS/+BXjoy6otC3Uq8ZKLFU33JywnK0z/yqRC3BLL3U3hPS2Qu5yvR+d X-Received: by 2002:aa7:c6ca:: with SMTP id b10mr31013415eds.233.1568126475852; Tue, 10 Sep 2019 07:41:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568126475; cv=none; d=google.com; s=arc-20160816; b=GddqmaTpMjX0DUKZOckgNRBy7/djHHMV6wHhzbIQpSWax6kcT9O2dbUMQUst0piLrI dqnscAU/CqIyOBKIP6YFr3sy4aZ1sk5gviUN+/mRBOm/Rg5Nx5j9rH9w2on+m25RNiWK vTkhx996lBjdZn0r5nwh0CM2nuaf2qHSw34X0Bj8VKpTQYNcFD8uiFvUk8ajAm1vxf9L 2OmETrGxe/hdbTVJC5+RiUv1ECpPkONHSdbNY/WiVoS9xZPlSYhUE5/t6FCMN3YCc0Vi ol49RNabtyobeAOnCLVmIxcr8qjLSvhCSQtLxqT1X+kS1RzQ+d3FuAoVnyS5Ru1tqb+g 8Bzw== 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=oMUEActhahVFe7HgZ1L/9YTK+5H1c0V8mDrLwsAiCpE=; b=IsvnR/rvYOG7oR7IaFz/z9HlJmEa6pWy5gDKGIDNoXVPAyL1mJhAt+7LQJwloFi7KI P4H9zgp5NYlb5EudvTJSy5XYdJq4ethrWosC2vpBtBcCXbEk8xqVaIjY3Ht6ePmboM9O fAk+uaDzI1oCMVpT3cnJ2A8Qce1zyg3eVdQRdH4TkrbuMiMm4BxGhgjZflJ0oHqw0Am5 jGx2LDUMgmbGCW77dUijkYV0QSWNkg73HrjmoJp3AB1nua3IhYEEKJReVVmzCxfnJpho HwFecoq0u+BtQGaWg+FDdKHD8dFLqbKbuTyuzOmkpHRbQbdPW/xdYChidzdljTquoT88 WW2w== 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 on24si9855295ejb.259.2019.09.10.07.40.51; Tue, 10 Sep 2019 07:41:15 -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 S2388310AbfIJOjB (ORCPT + 99 others); Tue, 10 Sep 2019 10:39:01 -0400 Received: from 6.mo177.mail-out.ovh.net ([46.105.51.249]:40014 "EHLO 6.mo177.mail-out.ovh.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726654AbfIJOjB (ORCPT ); Tue, 10 Sep 2019 10:39:01 -0400 X-Greylist: delayed 1801 seconds by postgrey-1.27 at vger.kernel.org; Tue, 10 Sep 2019 10:39:00 EDT Received: from player750.ha.ovh.net (unknown [10.109.160.39]) by mo177.mail-out.ovh.net (Postfix) with ESMTP id 536F210A056 for ; Tue, 10 Sep 2019 15:59:45 +0200 (CEST) Received: from kaod.org (deibp9eh1--blueice1n4.emea.ibm.com [195.212.29.166]) (Authenticated sender: clg@kaod.org) by player750.ha.ovh.net (Postfix) with ESMTPSA id 0B10D9BCF29D; Tue, 10 Sep 2019 13:59:37 +0000 (UTC) Subject: Re: [PATCH] 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: <156812362556.1866243.7399893138425681517.stgit@bahia.tls.ibm.com> From: =?UTF-8?Q?C=c3=a9dric_Le_Goater?= Message-ID: Date: Tue, 10 Sep 2019 15:59:37 +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: <156812362556.1866243.7399893138425681517.stgit@bahia.tls.ibm.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-Ovh-Tracer-Id: 12416705648356002583 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedufedrtddtgdegjecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemucehtddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10/09/2019 15:53, 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 > on the field. > > Internally convert 0xffffffff to OPAL_RESOURCE which is the usual error > returned upon resource exhaustion. > > Signed-off-by: Greg Kurz Reviewed-by: Cédric Le Goater Thanks, C. > --- > arch/powerpc/sysdev/xive/native.c | 13 +++++++++++-- > 1 file changed, 11 insertions(+), 2 deletions(-) > > diff --git a/arch/powerpc/sysdev/xive/native.c b/arch/powerpc/sysdev/xive/native.c > index 37987c815913..c35583f84f9f 100644 > --- a/arch/powerpc/sysdev/xive/native.c > +++ b/arch/powerpc/sysdev/xive/native.c > @@ -231,6 +231,15 @@ static bool xive_native_match(struct device_node *node) > return of_device_is_compatible(node, "ibm,opal-xive-vc"); > } > > +static int64_t opal_xive_allocate_irq_fixup(uint32_t chip_id) > +{ > + s64 irq = opal_xive_allocate_irq(chip_id); > + > +#define XIVE_ALLOC_NO_SPACE 0xffffffff /* No possible space */ > + return > + irq == XIVE_ALLOC_NO_SPACE ? OPAL_RESOURCE : irq; > +} > + > #ifdef CONFIG_SMP > static int xive_native_get_ipi(unsigned int cpu, struct xive_cpu *xc) > { > @@ -238,7 +247,7 @@ static int xive_native_get_ipi(unsigned int cpu, struct xive_cpu *xc) > > /* Allocate an IPI and populate info about it */ > for (;;) { > - irq = opal_xive_allocate_irq(xc->chip_id); > + irq = opal_xive_allocate_irq_fixup(xc->chip_id); > if (irq == OPAL_BUSY) { > msleep(OPAL_BUSY_DELAY_MS); > continue; > @@ -259,7 +268,7 @@ u32 xive_native_alloc_irq(void) > s64 rc; > > for (;;) { > - rc = opal_xive_allocate_irq(OPAL_XIVE_ANY_CHIP); > + rc = opal_xive_allocate_irq_fixup(OPAL_XIVE_ANY_CHIP); > if (rc != OPAL_BUSY) > break; > msleep(OPAL_BUSY_DELAY_MS); >