Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AFE38C61DA4 for ; Sat, 11 Mar 2023 19:12:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229844AbjCKTMi (ORCPT ); Sat, 11 Mar 2023 14:12:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55102 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229509AbjCKTMf (ORCPT ); Sat, 11 Mar 2023 14:12:35 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 518176EB86; Sat, 11 Mar 2023 11:12:34 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 05D4CB801B9; Sat, 11 Mar 2023 19:12:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B4B2BC433D2; Sat, 11 Mar 2023 19:12:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1678561951; bh=ogi0VrVtqZ0bI/eD0xZ4nZknGWHC2gS59/s8q7UAJPE=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=ZFMN38oV90EyqtUoCfGQLlzVkjY2UU5PFWd7i/DnTQkrTQ1tFSTupTcdSVI1X+15L b1vNO6IsUb//mozs0q76JEFECSALTR22ud+IoHP7sJ6kdH6zC7twsjH08wLtTyWZey BnWN27KYKzCnm00OtiJKL/1HlBn4QI5S4XYoe8ZXPKx0cdpHok0Hjglnbto1T7E5Ft RHmQ0jBtozfZicVG4KzI17sPS4iZa5ruKeXSfl8KbJuctRfh5OZGNgdbbButH+OjFf xxA+ASyeTNKylG9XVRXuRt8BPoGcCq4z3Aj2OSVmwYYJMVsACStR1NVAYjE1DbzSn3 3yVWQIPmOJUyA== Received: from sofa.misterjones.org ([185.219.108.64] helo=goblin-girl.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1pb4dp-00Gt66-CO; Sat, 11 Mar 2023 19:12:29 +0000 Date: Sat, 11 Mar 2023 19:12:29 +0000 Message-ID: <86r0tvxftu.wl-maz@kernel.org> From: Marc Zyngier To: Sven Peter Cc: Alyssa Rosenzweig , Lorenzo Pieralisi , Krzysztof =?UTF-8?B?V2lsY3p5xYRza2k=?= , Rob Herring , Bjorn Helgaas , linux-pci@vger.kernel.org, asahi@lists.linux.dev, linux-kernel@vger.kernel.org Subject: Re: [PATCH] PCI: apple: Initialize pcie->nvecs before using it In-Reply-To: <20230311133453.63246-1-sven@svenpeter.dev> References: <20230311133453.63246-1-sven@svenpeter.dev> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/28.2 (aarch64-unknown-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: sven@svenpeter.dev, alyssa@rosenzweig.io, lpieralisi@kernel.org, kw@linux.com, robh@kernel.org, bhelgaas@google.com, linux-pci@vger.kernel.org, asahi@lists.linux.dev, linux-kernel@vger.kernel.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, 11 Mar 2023 13:34:53 +0000, Sven Peter wrote: > > apple_pcie_setup_port computes ilog2(pcie->nvecs) to setup the number of > MSIs available for each port. It is however called before apple_msi_init > which actually initializes pcie->nvecs. > Luckily, pcie->nvecs is part of kzalloc-ed structure and thus > initialized as zero. ilog2(0) happens to be 0xffffffff which then just > configures more MSIs in hardware than we actually have. This doesn't > break anything because we never hand out those vectors. > Let's swap the order of the two calls so that we use the correctly > initialized value. > > Fixes: 476c41ed4597 ("PCI: apple: Implement MSI support") > Signed-off-by: Sven Peter Huh, how embarrassing... :-/ Reviewed-by: Marc Zyngier M. -- Without deviation from the norm, progress is not possible.