Received: by 2002:a05:6358:53a8:b0:117:f937:c515 with SMTP id z40csp5098045rwe; Tue, 18 Apr 2023 01:54:55 -0700 (PDT) X-Google-Smtp-Source: AKy350ZqJf0yTK8oAWNgqgxh4m0z3Osixl8+C434QK6GOF2toDzS08n+YZB8avU4NcU1H1WEuaiy X-Received: by 2002:a17:90a:9c3:b0:246:818c:d8e4 with SMTP id 61-20020a17090a09c300b00246818cd8e4mr1413521pjo.11.1681808095567; Tue, 18 Apr 2023 01:54:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681808095; cv=none; d=google.com; s=arc-20160816; b=ZG/VS473WS1WLoWn9cK8voLnqNJOhxuQDAc+zfXquqBLyGWRBlL7jQv2bhOIYpZJ2l N38J8y/1qvTEgkvjHzJdHcWLgDrZoO096z6wJH37NuPwmkVnQbCeF9F1QpnSReGJVoN6 B6xlYQxwz3UFDoBL04gcVaa1tal3RQJYT42KzkuHSBj5VynWYmhsBGFathFciRJhFEYB XplFS//Sq1147yKes/NfhLWFhs3Eh/RDE+xYSD/q4G1Q8Oh64eNfxZNodO4zfIyh5TJI QXMv2q1Rixy/y3Ge0kHpHAuJBUYBBXZQkPkGvrW/8ei8i1DTyiclbGWT+B1dHs7NucEw 9HIQ== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=1WwxFs09OLlUItADw/QKnx4w5DftEkyjXgAu+IIu1zg=; b=Yno3DajZOC7wlbeBh7irPqfyNORQ6BX4a2HIq/g8K8yMbx4ZqgunvZSXzrn9a4Gi3d dQVU1d3rlKrL7DOQDd/g5Xs9ufywdRYsiKV5iF591m7p/s8kC0dQ7CPLNSCpBbktaZs+ sY5ABMMOoJAA4wZzuGs0E7Vm2xg3Mat3513ndVaKhy6IRYq6DRLS7YP5eEsYXNqtWifQ SVQZS0hFFM/dREnsq6KXQkfhixhiPOC95WE/aUmokKvpdq0w0f75z9Pf5vaVn5p9kJEI s0GcFV5fQF09yf8Wlh0k32uTZnZyfAFi5mX34RLolRiwHnzFgtmtDxRcFhoCo+IsfP9N 8pIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=SIQtI2kb; 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 a24-20020a17090ad81800b00233e2e1ff6csi13306711pjv.119.2023.04.18.01.54.44; Tue, 18 Apr 2023 01:54:55 -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=SIQtI2kb; 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 S229515AbjDRIv1 (ORCPT + 99 others); Tue, 18 Apr 2023 04:51:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58846 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230023AbjDRIvZ (ORCPT ); Tue, 18 Apr 2023 04:51:25 -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 08AC559FA for ; Tue, 18 Apr 2023 01:50:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1681807837; 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; bh=1WwxFs09OLlUItADw/QKnx4w5DftEkyjXgAu+IIu1zg=; b=SIQtI2kbULB5P4SLBvc+Mmcp9gdZllblQSs4sqYdEkaHQ8te8IDZgfH1XxQeywiPd61aHP TrMYIZUENcWetpArb+NFg1vJxn4dSUSt/xhvrWAK2eFZHb6DByjTys7XtHtqXzR9Qe5AzV Q3Uf3t6+Ll9Eh4x8e5O7LJqvwh5Vwk8= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [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-583-lXK-dijyMHW-PykYl1MBOQ-1; Tue, 18 Apr 2023 04:50:34 -0400 X-MC-Unique: lXK-dijyMHW-PykYl1MBOQ-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 86AFA3815F6D; Tue, 18 Apr 2023 08:50:33 +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 811DF40C6E6E; Tue, 18 Apr 2023 08:50:32 +0000 (UTC) From: Igor Mammedov To: linux-kernel@vger.kernel.org Cc: mst@redhat.com, rafael@kernel.org, lenb@kernel.org, bhelgaas@google.com, linux-acpi@vger.kernel.org, linux-pci@vger.kernel.org Subject: [PATCH] pci: acpiphp: try to reassign resources on bridge if necessary Date: Tue, 18 Apr 2023 10:50:30 +0200 Message-Id: <20230418085030.2154918-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_H2,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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. Signed-off-by: Igor Mammedov --- tested in QEMU with Q35 machine on PCIE root port and also with nested conventional bridge attached to root port. --- drivers/pci/hotplug/acpiphp_glue.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/pci/hotplug/acpiphp_glue.c b/drivers/pci/hotplug/acpiphp_glue.c index 5b1f271c6034..9aebde28a92f 100644 --- a/drivers/pci/hotplug/acpiphp_glue.c +++ b/drivers/pci/hotplug/acpiphp_glue.c @@ -517,7 +517,7 @@ static void enable_slot(struct acpiphp_slot *slot, bool bridge) } } } - __pci_bus_assign_resources(bus, &add_list, NULL); + pci_assign_unassigned_bridge_resources(bus->self); } acpiphp_sanitize_bus(bus); -- 2.39.1