Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp2724554rwb; Fri, 2 Dec 2022 14:10:27 -0800 (PST) X-Google-Smtp-Source: AA0mqf6NkBTEeJRqSp2Ue1pbNZenrK7d6ULj4eYJ0NEdOfq5/y9omgavOO1EObzVhb5ACyDTrFIE X-Received: by 2002:a63:2163:0:b0:474:d6fa:f574 with SMTP id s35-20020a632163000000b00474d6faf574mr50604085pgm.190.1670019027021; Fri, 02 Dec 2022 14:10:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670019027; cv=none; d=google.com; s=arc-20160816; b=cQdRAcVFUnnnmn2s6xausVZMAlbFBas6jvNH86QJzp41UYAPvHyM8kmQyTXk6S1pv7 t6yuqXePzR739fwD5Hmjb9f3T0myoHxRylfqqwgFfywP+Q/gpXVH2Iyhgn6qLk3XaWK4 5drCjmnA2YlIkQwLIIvfrEfz7K/TTwKOIk4YOXL5n3V58tg99CN9Gj1OQrWmKcEHaHPz AQ3Ks2+1cPm1NjK6WCF5VaCPVWlCoJ9D0z6C2PcOCQ3/LP0ho9WaW3asa7jqpzARA3aN eGrTRyeo9LEF8iSRQ/arL5z2j0RwlqjI+5/muJ1Yjnbr6jAdleIpxcR5czL368ltsmwc Ymmw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=9WazVplZm+CbwNaBBYCws2T/gqk97rNj1pd2P62vJGo=; b=gcU+lg8Ii7lSuYEbTS93U/P9t5DioUMBbIcyc14KJijh+fdrPlbYTG3lchm/yQ+MlA /ygW28Lh94MG/YPpJ6zdgMeFf1kFR5BEogAvXLsw0k0cmBpeBiHddhNChxyj1i8JzViQ U3c5kXtPcm9PR1UvVxDbgYme0JEcNdBbAosAn5VKlbs3P6OBku0zoc7dwIbvNExyTmCi UftuuIHltfeMHL0mqtvdA7qocrPZmpIWtT/uJZn0iiGvFBnnQqrePMHO78XPghJHFMMj qXLJTgPI5mShRFa/C060a25ooaScCNQ6Ra8u4Xks6hQ0hBQW7CGMQbPovb9kfr29qUoZ kSaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=hHcSTLEU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 25-20020a631559000000b0046ece301e82si8404831pgv.756.2022.12.02.14.10.15; Fri, 02 Dec 2022 14:10:27 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=hHcSTLEU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234409AbiLBVS5 (ORCPT + 82 others); Fri, 2 Dec 2022 16:18:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60594 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234041AbiLBVSv (ORCPT ); Fri, 2 Dec 2022 16:18:51 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B33E97046F; Fri, 2 Dec 2022 13:18:49 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 505F6623C0; Fri, 2 Dec 2022 21:18:49 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 809A1C433D7; Fri, 2 Dec 2022 21:18:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1670015928; bh=jsOes6lsRyJazCweN98/1MgbRRFwiPjB2+BoIczXWYE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hHcSTLEU0se8MLHfKx412OkDrWWRGjN1mwbgjdtwhjAg9ONVOxHbB5dUE1EoK2VCG uUWJmcgCzJU6WmOFB9UZR8u0mN+Ptaqs0AbVVQ03qEBUXb6LMmrt0pz31DzlNfoaCB JTCtFbZDVp3Kp1BFCQ77CEfhK61B4ufWOuCvdKcFXqlSOwE3k3PUlR98fOLiwYh36m ZJetJFy3D2FBjUzjyajNfGq47D5CAW7D6RrXQlXC0SaBfLMwXGE4KRzFv9qfq9uDWZ NMmLqx4mCX8rNUxlWIf8mr1Ov1knSLExOVf2e9W9jHMPWGoLH3ErzySppAjn+sSHCy 3cg562HdjPOeg== From: Bjorn Helgaas To: linux-pci@vger.kernel.org Cc: Hans de Goede , Florent DELAHAYE , Konrad J Hambrick , Matt Hansen <2lprbe78@duck.com>, =?UTF-8?q?Benoit=20Gr=C3=A9goire?= , Nicholas Johnson , Mika Westerberg , Werner Sembach , mumblingdrunkard@protonmail.com, linux-kernel@vger.kernel.org, Bjorn Helgaas Subject: [PATCH 2/4] PCI: Skip allocate_resource() if too little space available Date: Fri, 2 Dec 2022 15:18:36 -0600 Message-Id: <20221202211838.1061278-3-helgaas@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221202211838.1061278-1-helgaas@kernel.org> References: <20221202211838.1061278-1-helgaas@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Bjorn Helgaas pci_bus_alloc_from_region() allocates MMIO space by iterating through all the resources available on the bus. The available resource might be reduced if the caller requires 32-bit space or we're avoiding BIOS or E820 areas. Don't bother calling allocate_resource() if we need more space than is available in this resource. This prevents some pointless and annoying messages about avoided areas. Signed-off-by: Bjorn Helgaas Cc: Hans de Goede --- drivers/pci/bus.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/pci/bus.c b/drivers/pci/bus.c index 3cef835b375f..83ae838ceb5f 100644 --- a/drivers/pci/bus.c +++ b/drivers/pci/bus.c @@ -197,6 +197,10 @@ static int pci_bus_alloc_from_region(struct pci_bus *bus, struct resource *res, max = avail.end; + /* Don't bother if available space isn't large enough */ + if (size > max - min_used + 1) + continue; + /* Ok, try it out.. */ ret = allocate_resource(r, res, size, min_used, max, align, alignf, alignf_data); -- 2.25.1