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 116B9C6FD1F for ; Sat, 11 Mar 2023 14:11:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230063AbjCKOLZ (ORCPT ); Sat, 11 Mar 2023 09:11:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54714 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229981AbjCKOLW (ORCPT ); Sat, 11 Mar 2023 09:11:22 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1B040F1691 for ; Sat, 11 Mar 2023 06:10:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1678543833; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=rI9UkkY/zqKs0y6gyqXwPg+4g7Xn+4IOJ0Nvb47KScw=; b=Ah5Rhur6v+GdvOTmJum6soXvTEaJZhRK59+Qx4TDjtnMyk96vbYTILvah5Tkg9WfpJxUJT UHEWGbFrM+cFiG5gCAgeDhFLA9tGcX/R8Rmax+/32g879Vey0YSGbyxzoNdSNbGyjn2uMM FvQydjyYzcvq9haQLuYLDzfWgKnijak= Received: from mail-vs1-f69.google.com (mail-vs1-f69.google.com [209.85.217.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-619-mHcqbzw-NRmnyQD9bFQxlw-1; Sat, 11 Mar 2023 09:10:32 -0500 X-MC-Unique: mHcqbzw-NRmnyQD9bFQxlw-1 Received: by mail-vs1-f69.google.com with SMTP id f11-20020a67ea8b000000b0042210bcecc9so2649623vso.12 for ; Sat, 11 Mar 2023 06:10:32 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678543831; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=rI9UkkY/zqKs0y6gyqXwPg+4g7Xn+4IOJ0Nvb47KScw=; b=g8vRunbeGR4FnSeOxV8JClYNfC3fJP9yPSLciGnwYtA5ysGgl/QsiowTj+/BVdsAPk xaILpfvcJ1QiXs40LcTPng2Hrzn2gsVq3yGrDphsS4vBkbVW2Uycr1L9WwhKU+WGHYS8 +qYxttR6ZwDebvLY6d/2GMy9vbqIZbSJ+v3RdbdVhyTt/4gfI3UW3BeJU7Hu++yV+XQu Y4daBXm/FHgh93EGwu4uNeKyArgizbFjHjfu8bOdLL9qfxP3E67FZroHko2JesZvr5vM FGWRqBTMszAxtecfCRAqGnMoGbOQKZidI5L3OUdB7smQzNEtC/gfjmdVHiQciD99IoN4 WQLw== X-Gm-Message-State: AO0yUKVcYmeh9frZlEmgWBUMIj4FnBQLoYBzvt5ns7BG0o8dWgomZc9n vCtXqXMbhEWtV8xLS8RI3DlgLidTlMymZcf0+zB1UAxhKxde0zNgWLwQ8cZXtYRrWSFje0wL19j iYL0zfygw6T2sO7JXOsgczwJEdd+CRbw12XaXWXWT X-Received: by 2002:a9f:3001:0:b0:68b:817b:eec8 with SMTP id h1-20020a9f3001000000b0068b817beec8mr18498513uab.0.1678543831516; Sat, 11 Mar 2023 06:10:31 -0800 (PST) X-Google-Smtp-Source: AK7set8tL22Z64GFZQlBETeAIXfNC/NFYd/MWg33mB4oH3lVXRGgxR03Dz5LsWIgpcSED5a84XZH6Ovr3dXVwTdKMzQ= X-Received: by 2002:a9f:3001:0:b0:68b:817b:eec8 with SMTP id h1-20020a9f3001000000b0068b817beec8mr18498509uab.0.1678543831274; Sat, 11 Mar 2023 06:10:31 -0800 (PST) MIME-Version: 1.0 References: <20230311133453.63246-1-sven@svenpeter.dev> In-Reply-To: <20230311133453.63246-1-sven@svenpeter.dev> From: Eric Curtin Date: Sat, 11 Mar 2023 14:10:15 +0000 Message-ID: Subject: Re: [PATCH] PCI: apple: Initialize pcie->nvecs before using it To: Sven Peter Cc: Alyssa Rosenzweig , Marc Zyngier , Lorenzo Pieralisi , =?UTF-8?Q?Krzysztof_Wilczy=C5=84ski?= , Rob Herring , Bjorn Helgaas , linux-pci@vger.kernel.org, asahi@lists.linux.dev, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, 11 Mar 2023 at 13:41, 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 Reviewed-by: Eric Curtin Is mise le meas/Regards, Eric Curtin > --- > drivers/pci/controller/pcie-apple.c | 6 +++++- > 1 file changed, 5 insertions(+), 1 deletion(-) > > diff --git a/drivers/pci/controller/pcie-apple.c b/drivers/pci/controller/pcie-apple.c > index 66f37e403a09..8b7b084cf287 100644 > --- a/drivers/pci/controller/pcie-apple.c > +++ b/drivers/pci/controller/pcie-apple.c > @@ -783,6 +783,10 @@ static int apple_pcie_init(struct pci_config_window *cfg) > cfg->priv = pcie; > INIT_LIST_HEAD(&pcie->ports); > > + ret = apple_msi_init(pcie); > + if (ret) > + return ret; > + > for_each_child_of_node(dev->of_node, of_port) { > ret = apple_pcie_setup_port(pcie, of_port); > if (ret) { > @@ -792,7 +796,7 @@ static int apple_pcie_init(struct pci_config_window *cfg) > } > } > > - return apple_msi_init(pcie); > + return 0; > } > > static int apple_pcie_probe(struct platform_device *pdev) > -- > 2.25.1 > >