Received: by 2002:a05:6358:701b:b0:131:369:b2a3 with SMTP id 27csp4340587rwo; Tue, 25 Jul 2023 04:50:34 -0700 (PDT) X-Google-Smtp-Source: APBJJlGhKOapmeDibVmCZYvFNucGOeAre5x6/OTTivs6zF05lkYoJ6P6zQoJJ/wdq4EU3kzaIBQA X-Received: by 2002:a17:906:7a4b:b0:982:25d1:bfd3 with SMTP id i11-20020a1709067a4b00b0098225d1bfd3mr13416866ejo.15.1690285833928; Tue, 25 Jul 2023 04:50:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690285833; cv=none; d=google.com; s=arc-20160816; b=dy8z2rHyIG5MNUQTf7OQtkQHyydYq3jaYFL20r+GlkQ9EYstKyz3/6ZW+265oseh+G 2EY+q/d5UmsvxL4QyS3YPXdOIRlegqipwGXWAQHp8fVxPxrVLZu0cmGPWYqKrIv2FyzC sThsDipz+I5ZYdefgS9kvqICJPEMFlIdAXDB29WtmiKIaIkkdKHY+kT4u8zT7TQVDKgT pA9P3SbvUndbEHmwEsaYUdcUEJWZEwp4bJ6KBAhEKL3AlgUhuiGntJtPUMp5UvzjYMqY CwKoSKT1s97i9qabYEJ17dQx9hbvP4uRe0zX2mTf1OZJCy3nSiaRsas+W+jpqXnrNu3p hSBg== 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=XtvYGHEuqAI2O/l3IR/bbPM8dSIPYozgR99K5jDaFuo=; fh=20NfoF0PZD8nR06kpJUMqt7TWNrzEh+cpHnkcqG4X3I=; b=XIKzpHfdRYEMv5/w5Ee8/oz5CRJhf3Ghyx7fylPo0Lh9dJkimOIBruvYtQsvnAieyg U2S+Rdr7h0N9Ch401tPK+zyaKhJe2mWfKsZoJulyICPSrD6eteZCvHh4jJjorLDyZmFh 4y9lM8/5z4kCbwqG8zOg/wTlFZkeJVvZ+YeLsfA/G3qGkPW3F3pgfDy0b0bXdtGStxHc RjpOGMXx+wjx1nvE+pLlv8rfAeSdos+EnATPhwFO/sqHKkxlcdqzD0umz8Ir5rTDsnfu oSZrDTTkQBLh1fvJX3Tq/xdaTxylW4zT3dXigMuOUrILHLCh/2wi3ZqrqP5AdDfhHPbl pNGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=EAXyj7HY; 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=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k19-20020a1709065fd300b0099b73879d00si5502384ejv.103.2023.07.25.04.50.09; Tue, 25 Jul 2023 04:50:33 -0700 (PDT) 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=@redhat.com header.s=mimecast20190719 header.b=EAXyj7HY; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234976AbjGYLkj (ORCPT + 99 others); Tue, 25 Jul 2023 07:40:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46502 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234951AbjGYLkd (ORCPT ); Tue, 25 Jul 2023 07:40:33 -0400 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 76EB119AD for ; Tue, 25 Jul 2023 04:39:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1690285185; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=XtvYGHEuqAI2O/l3IR/bbPM8dSIPYozgR99K5jDaFuo=; b=EAXyj7HYqfFJH+90FxSOndYtFB3JwKdX2NIjz2Y5v+4rmMIb7x8GiA+DgrhcDXfg41RbcC 72AZhpKvIrC4reju1wQ3tEAhkpNoVSIZIsgogpZkvDMwzvFGEIRcDwIElL6cRQFXnTekO3 yQyYj1ZEfE5wH3xvKDHcNVVbq8kMJAQ= Received: from mimecast-mx02.redhat.com (66.187.233.73 [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-675-Pq0jL7OUPeWzXbshJIobsw-1; Tue, 25 Jul 2023 07:39:44 -0400 X-MC-Unique: Pq0jL7OUPeWzXbshJIobsw-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id DB7AC29AA39B; Tue, 25 Jul 2023 11:39:43 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq2.redhat.com (dell-r430-03.lab.eng.brq2.redhat.com [10.37.153.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id C0EC84094DC1; Tue, 25 Jul 2023 11:39:42 +0000 (UTC) From: Igor Mammedov To: linux-kernel@vger.kernel.org Cc: terraluna977@gmail.com, bhelgaas@google.com, linux-pci@vger.kernel.org, imammedo@redhat.com, mst@redhat.com, "Rafael J . Wysocki" , stable@vger.kernel.org Subject: [RFC 2/3] PCI: acpiphp: Reassign resources on bridge if necessary Date: Tue, 25 Jul 2023 13:39:37 +0200 Message-Id: <20230725113938.2277420-3-imammedo@redhat.com> In-Reply-To: <20230725113938.2277420-1-imammedo@redhat.com> References: <20230725113938.2277420-1-imammedo@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE 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 When using ACPI PCI hotplug, hotplugging a device with large BARs may fail if bridge windows programmed by firmware are not large enough. Reproducer: $ qemu-kvm -monitor stdio -M q35 -m 4G \ -global ICH9-LPC.acpi-pci-hotplug-with-bridge-support=on \ -device id=rp1,pcie-root-port,bus=pcie.0,chassis=4 \ disk_image wait till linux guest boots, then hotplug device: (qemu) device_add qxl,bus=rp1 hotplug on guest side fails with: pci 0000:01:00.0: [1b36:0100] type 00 class 0x038000 pci 0000:01:00.0: reg 0x10: [mem 0x00000000-0x03ffffff] pci 0000:01:00.0: reg 0x14: [mem 0x00000000-0x03ffffff] pci 0000:01:00.0: reg 0x18: [mem 0x00000000-0x00001fff] pci 0000:01:00.0: reg 0x1c: [io 0x0000-0x001f] pci 0000:01:00.0: BAR 0: no space for [mem size 0x04000000] pci 0000:01:00.0: BAR 0: failed to assign [mem size 0x04000000] pci 0000:01:00.0: BAR 1: no space for [mem size 0x04000000] pci 0000:01:00.0: BAR 1: failed to assign [mem size 0x04000000] pci 0000:01:00.0: BAR 2: assigned [mem 0xfe800000-0xfe801fff] pci 0000:01:00.0: BAR 3: assigned [io 0x1000-0x101f] qxl 0000:01:00.0: enabling device (0000 -> 0003) Unable to create vram_mapping qxl: probe of 0000:01:00.0 failed with error -12 However when using native PCIe hotplug '-global ICH9-LPC.acpi-pci-hotplug-with-bridge-support=off' it works fine, since kernel attempts to reassign unused resources. Use the same machinery as native PCIe hotplug to (re)assign resources. Link: https://lore.kernel.org/r/20230424191557.2464760-1-imammedo@redhat.com Signed-off-by: Igor Mammedov Signed-off-by: Bjorn Helgaas Acked-by: Michael S. Tsirkin Acked-by: Rafael J. Wysocki Cc: stable@vger.kernel.org --- drivers/pci/hotplug/acpiphp_glue.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/pci/hotplug/acpiphp_glue.c b/drivers/pci/hotplug/acpiphp_glue.c index af1c73f2bee6..c0ffb1389fda 100644 --- a/drivers/pci/hotplug/acpiphp_glue.c +++ b/drivers/pci/hotplug/acpiphp_glue.c @@ -499,7 +499,6 @@ pci_info(bus, "enable_slot bus: bridge: %d, bus->self: %p\n", bridge, bus->self) acpiphp_native_scan_bridge(dev); } } else { - LIST_HEAD(add_list); int max, pass; acpiphp_rescan_slot(slot); @@ -513,12 +512,10 @@ pci_info(bus, "enable_slot bus: bridge: %d, bus->self: %p\n", bridge, bus->self) if (pass && dev->subordinate) { check_hotplug_bridge(slot, dev); pcibios_resource_survey_bus(dev->subordinate); - __pci_bus_size_bridges(dev->subordinate, - &add_list); } } } - __pci_bus_assign_resources(bus, &add_list, NULL); + pci_assign_unassigned_bridge_resources(bus->self); } acpiphp_sanitize_bus(bus); -- 2.39.3