From patchwork Fri Oct 21 05:12:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Chiu X-Patchwork-Id: 1692837 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=canonical.com header.i=@canonical.com header.a=rsa-sha256 header.s=20210705 header.b=O2XuR+6P; dkim-atps=neutral Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Mtt0159Ksz23kn for ; Fri, 21 Oct 2022 16:13:04 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1olkKx-0005uk-33; Fri, 21 Oct 2022 05:12:51 +0000 Received: from smtp-relay-internal-1.internal ([10.131.114.114] helo=smtp-relay-internal-1.canonical.com) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1olkKv-0005uP-B1 for kernel-team@lists.ubuntu.com; Fri, 21 Oct 2022 05:12:49 +0000 Received: from mail-pf1-f200.google.com (mail-pf1-f200.google.com [209.85.210.200]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id D4ED1412E5 for ; Fri, 21 Oct 2022 05:12:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1666329167; bh=YCZTOIafBjEAz67C6qArOwGMk3Pnjw+R0fs0zezh2KY=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=O2XuR+6PgGxqfKcLwLYTJRfq/K0K9OmFUQiXlRaKHzoOBSKhd55MNIUq0rKp/stL1 iiw41dDEW1DyP8sm4pLsGLfgsMWoS1S7dUgi1ujsVZCqp2fMqhRUC2r1TpzZnUh75B brLxsINdoiHU40ZGeXZzWo0iiG03PBjL2oHPy3FmFun8OrfN5SS9m5eWqERMaOXnSD 5ZnxIWImZhCMFxdJ+8nNqA6+GYbZp+pQEJzWWXlmIFrxisaCAMxeUfnyG0Q3Brx/q4 psUYI7KcA1++e41qS4phK40KamiGcpVqL3mVvvBE6TrqlUMbp68+iAXvVqKax8MiUd J/fElz9sm1VsQ== Received: by mail-pf1-f200.google.com with SMTP id h1-20020a62b401000000b0056161cd284fso813778pfn.16 for ; Thu, 20 Oct 2022 22:12:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=YCZTOIafBjEAz67C6qArOwGMk3Pnjw+R0fs0zezh2KY=; b=d0uxYkmQWBYQorHfuwuH+cBJVD4nzHuTyZ/iUE4IG7w7Lh0rv40mc0oDn1dIG7caoa DFqg8UGg//jvg46uy0F4oSmCgvHHHUvNfcM9A0waYVX4c2owNba0C7b6/gPkbG+2n8cI FO8wfbJIh+ku4G8ZsPW5WdagoCS20+o2KHhmsmuRij+ZirJVo1gRuv0SiHZkmpzvkH5X YrFIVc3965cIdfXGOnA9AnVgd9vy9f40oceo01N2kKLNYsIVffktu8ZEy0k740EiZOnm ViHDUJ3WDIV+pCWSyLLhNWGVfIwOb+I+XYcrKe9jAfIot59xf5T6Luw/j3+NCwVjCM7/ hFHQ== X-Gm-Message-State: ACrzQf3Y/yIvyCn/FwhZnr1wFTgZgHlFv30jR2JksTt5sWPBOAAFOh63 4mNXqUGa/GrHd1TXqHaaSq4y5K8DvGwd+0CWXm9wnCQqQ5tHNpja0UWtSD9OaC5+m9fIx9aQY13 LCf3xtF2LwkVMySfN4J/s6HO7x2o89Hj8fDK2yj/32A== X-Received: by 2002:a63:6c84:0:b0:43c:700f:6218 with SMTP id h126-20020a636c84000000b0043c700f6218mr14620981pgc.420.1666329165339; Thu, 20 Oct 2022 22:12:45 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5o+OLD6FnPtc/KdjQ8bpB9geonk/tHRwKax/9/rhkAgQJ1wvY7aDHHZMlOBCd6Y/3aBUr9Ug== X-Received: by 2002:a63:6c84:0:b0:43c:700f:6218 with SMTP id h126-20020a636c84000000b0043c700f6218mr14620964pgc.420.1666329164945; Thu, 20 Oct 2022 22:12:44 -0700 (PDT) Received: from localhost.localdomain (2001-b400-e357-130d-3a9d-713c-d2d2-7bfe.emome-ip6.hinet.net. [2001:b400:e357:130d:3a9d:713c:d2d2:7bfe]) by smtp.gmail.com with ESMTPSA id w12-20020a17090aaf8c00b0020adab4ab37sm711883pjq.31.2022.10.20.22.12.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Oct 2022 22:12:44 -0700 (PDT) From: Chris Chiu To: kernel-team@lists.ubuntu.com Subject: [PATCH 1/6][SRU][Jammy] PCI: Fix used_buses calculation in pci_scan_child_bus_extend() Date: Fri, 21 Oct 2022 13:12:34 +0800 Message-Id: <20221021051239.1097561-2-chris.chiu@canonical.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221021051239.1097561-1-chris.chiu@canonical.com> References: <20221021051239.1097561-1-chris.chiu@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Mika Westerberg BugLink: https://bugs.launchpad.net/bugs/1991366 pci_scan_bridge_extend() returns the subordinate bus number needed to cover all the buses below a bridge. pci_scan_child_bus_extend() computes the number of buses to reserve by comparing that with the current max bus number. Previously it did the subtraction in the wrong order, so 'used_buses' was nonsense. Subtract 'max' from 'cmax' as is done for the similar pci_scan_bridge_extend() call in the following block. Link: https://bugzilla.kernel.org/show_bug.cgi?id=216000 Fixes: 3374c545c27c ("PCI: Account for all bridges on bus when distributing bus numbers") Link: https://lore.kernel.org/r/20220905080232.36087-2-mika.westerberg@linux.intel.com Reported-by: Chris Chiu Tested-by: Chris Chiu Signed-off-by: Mika Westerberg Signed-off-by: Bjorn Helgaas Reviewed-by: Andy Shevchenko (cherry picked from commit 8066cc86b7aaaf6b4b38a81932459c6450440daa) Signed-off-by: Chris Chiu --- drivers/pci/probe.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index 4f26c222f5f2..65a420e8bc03 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -2949,8 +2949,8 @@ static unsigned int pci_scan_child_bus_extend(struct pci_bus *bus, * hotplug bridges too much during the second scan below. */ used_buses++; - if (cmax - max > 1) - used_buses += cmax - max - 1; + if (max - cmax > 1) + used_buses += max - cmax - 1; } /* Scan bridges that need to be reconfigured */