Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp5856493ybn; Sun, 29 Sep 2019 07:10:06 -0700 (PDT) X-Google-Smtp-Source: APXvYqwLtjWAMRaqakFKlra3epbUTiCgzsUiyPLrH+r3TZNUvXCp8v0Jt2FjSHL5x6JXkDMbcfuW X-Received: by 2002:a17:907:205b:: with SMTP id pg27mr11329992ejb.135.1569766206280; Sun, 29 Sep 2019 07:10:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569766206; cv=none; d=google.com; s=arc-20160816; b=b0SkP3Fx+3H1Tmxbv0ZbYaYmhTU148D0Hpl8K4hhQH+TtldI2UhWn3Qpv3/O1j5IfX EhMwDQ/4uZ2n4PTkNUJlA9SmcqyObvXdE6WQunMdJDIS9lxHuQPkZ3EWU8qlu8m4Xe0w UFDNpY6nhlO8prPDArU5uC9Yird2ry9Av3AdItkTqRsOJptjYPvAnrt+uT+oKLTORSkZ YlQ4s70sUOB7NzvjOhtft8BTVMJXBO8uwa8FKsgq9LJBWlB6qHiG3u1YioMluIRe5YXX 14SepUvyQ7NEseBrVhQAdOCnneik6Onb5dm9+OPk0R+aYnc6hg0OlPbkDlMOe9RvMuH9 cy0w== 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:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=3ePEAmRZHbgfLW40Wwi6Krx5z+5z0cazUUM/xm22uQE=; b=Iqjqc4OsA2x/jQgCP4hSKmVp0Z+tyLDTgX3SBjhEYJKO8pFiLo5/xMZqpPTyC4Mu7T UtHuG87eN5XHHbW4XrmqHFCZtab6bsj2za3AoP7j1iM2F6VsViZVQ2UrMxOyAgnfov0i Wjii13u+TPYehjocqCbraDhhWLpdskIrmG9eGoXOm+epwtsNSpgh3Pvt2Oqz1uCglngC Juc1XYdPDJG9gSGMu8Yu+Ye8dMjdwYofAp7NtiqovmrjE6THVgStfqqN3WWM7Dl9LZxB l9vUIPNEH+Wtorff8CpbEtZGREu8zJf8zGtWiv0Wc341pwXBBYX/8jzX4pmvXfmn6+e/ IazA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="c2xCN/4n"; 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 o32si5623137edb.63.2019.09.29.07.09.41; Sun, 29 Sep 2019 07:10:06 -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; dkim=pass header.i=@kernel.org header.s=default header.b="c2xCN/4n"; 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 S1729164AbfI2N5M (ORCPT + 99 others); Sun, 29 Sep 2019 09:57:12 -0400 Received: from mail.kernel.org ([198.145.29.99]:37364 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729145AbfI2N5K (ORCPT ); Sun, 29 Sep 2019 09:57:10 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 748AF218DE; Sun, 29 Sep 2019 13:57:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1569765428; bh=ErNap2xw6iRG18xwQrNDGvj100492629qz78lFk2HEc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=c2xCN/4n48bwCTjsYnOsO6H//fwRgv3XvPXw2wyHQwjL+fUw5aapqQM/dZdN8X77k ejcAFszmdgFitBHZefhwjmYXe1c5ChSDLANDXTlc+OjiZnaG7fIBU+eMVjoa9zE8Cn 6N3Frh8p07VLUh72L8pGBxgdrvxfVS6JyaemzHv0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Greg Kurz , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Michael Ellerman Subject: [PATCH 4.19 04/63] powerpc/xive: Fix bogus error code returned by OPAL Date: Sun, 29 Sep 2019 15:53:37 +0200 Message-Id: <20190929135032.069551607@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190929135031.382429403@linuxfoundation.org> References: <20190929135031.382429403@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Greg Kurz commit 6ccb4ac2bf8a35c694ead92f8ac5530a16e8f2c8 upstream. 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 Signed-off-by: Michael Ellerman Link: https://lore.kernel.org/r/156821713818.1985334.14123187368108582810.stgit@bahia.lan (groug: fix arch/powerpc/platforms/powernv/opal-wrappers.S instead of non-existing arch/powerpc/platforms/powernv/opal-call.c) Signed-off-by: Greg Kurz Signed-off-by: Greg Kroah-Hartman --- arch/powerpc/include/asm/opal.h | 2 +- arch/powerpc/platforms/powernv/opal-wrappers.S | 2 +- arch/powerpc/sysdev/xive/native.c | 11 +++++++++++ 3 files changed, 13 insertions(+), 2 deletions(-) --- a/arch/powerpc/include/asm/opal.h +++ b/arch/powerpc/include/asm/opal.h @@ -275,7 +275,7 @@ int64_t opal_xive_get_vp_info(uint64_t v 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); --- a/arch/powerpc/platforms/powernv/opal-wrappers.S +++ b/arch/powerpc/platforms/powernv/opal-wrappers.S @@ -303,7 +303,7 @@ OPAL_CALL(opal_xive_set_queue_info, OPA 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); --- a/arch/powerpc/sysdev/xive/native.c +++ b/arch/powerpc/sysdev/xive/native.c @@ -235,6 +235,17 @@ static bool xive_native_match(struct dev 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) {