Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2784711rwd; Mon, 22 May 2023 04:27:20 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5/JFrz03Y9VysKxJRkXKdJDpA15x51f5lXhXjTdlGqXp8gmyZ72kREYvLgKcxZtHZ2OkcK X-Received: by 2002:a17:902:daca:b0:1ac:859a:5b5a with SMTP id q10-20020a170902daca00b001ac859a5b5amr14432091plx.0.1684754840125; Mon, 22 May 2023 04:27:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684754840; cv=none; d=google.com; s=arc-20160816; b=XAwNzR/4snRE68JIwfQIJ82UlZeI2WS5Kcu9oy2bBxp8HIPGXhtfZYlkGpb00AE/jE GBhs7IT85Xa0oJ2kriyo5j77ztIMEQHDYeU3ih+Ac7zva03jam5peLqEMaiefZXz81yM DICF4EeZDVIEc4ok6s++Z3B2eaD3BQhnjz5V5kXVmhjE5vrVde6MKhe5TfuebaO1tYAf ZlOtdSo6qrTJ1cVdWNsirXjOLxrWKKozEcVJxqp+Kr7qC+ZPnKHQoIs92q3pgOE54OQL MUJMgwbQGgF4c2eXKF9JG2m4qpFvvmqUpmCThMvRyH1BlT6g5Pqf0C7dfRhVrjqisESa sM/Q== 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:subject:cc:to:from:date :dkim-signature; bh=Pm6pIysjMAsg0WDE6icfe6G1Q5qdHkb+W04G2UqRo/k=; b=NkMhrMJjBU4aZX0n+0L4Rr0c4rgxl6T8gdtGIFLJEjy3AvTqquyFarjU3K2811i4EO Vv1VSG6bkphbA9et2Jl5fF18LaRiEdqvaTcOtAhMBwCWEpEpT77LV5jhSWzkfdDmzGWh WNzbWB+7bN615lIbiBhIE98+80vuwtbLApAgR/VZ2tbLnT01MeeC5tyVXlzVMBj1/JJF 3bCxniAFbhugGBUv3Q7e8E7MLXPQTp2R5Z6je0vzX+e9vqaYY3kRzz5X8NFQ9rjm1+9l aApXcoaEr8U0DUM69EbUQ/5GrvEVKqSO2L1ewnZUesu4r1OmsRgvPAmAMeAfQCucdyzC nu+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="E/UakoP7"; 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 h7-20020a170902f7c700b001ab23cb930bsi2166140plw.417.2023.05.22.04.27.08; Mon, 22 May 2023 04:27:20 -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="E/UakoP7"; 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 S232897AbjEVLMr (ORCPT + 99 others); Mon, 22 May 2023 07:12:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54166 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233117AbjEVLMY (ORCPT ); Mon, 22 May 2023 07:12:24 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C4B4F139 for ; Mon, 22 May 2023 04:06:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684753600; 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=Pm6pIysjMAsg0WDE6icfe6G1Q5qdHkb+W04G2UqRo/k=; b=E/UakoP7jIrfNi3+klKIA3S91N4pIXptv4Irirxdz5ZweTrCu3Pm2lCcWcAOhE2Iq1vBqj lXqegp+GU7RoYa7lWCNKUptXzwS9s+Kw8cw6HQ4EBUy4bibB1LhIh/GxVmuPNOFkXccbPk G/6EnAGBY9a/qUavc/vzku8O/et851Q= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-272-ZWa_CmUdOHWwVZcIueVS5Q-1; Mon, 22 May 2023 07:06:39 -0400 X-MC-Unique: ZWa_CmUdOHWwVZcIueVS5Q-1 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-309542498deso1573879f8f.0 for ; Mon, 22 May 2023 04:06:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684753597; x=1687345597; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Pm6pIysjMAsg0WDE6icfe6G1Q5qdHkb+W04G2UqRo/k=; b=FMVMI57OtDvDLSzrvsfPJxGMbD02Yz2FNicqUqSzRIMOQ8/U3oYG4JvtZxLS4kxyDJ 5X5gbEZVpB8sjvfMMk6gMPuT1gPrB0gVpmYUfGlTgVhDBt5zzuhUV1bJ12ErFW3zFz8t NNBNhZA0D5yF7HjA5zCW3BQIcrZfvS8+AWoGc2hQsAlT1OKTXjB44Rajy3Y2+67CgGWH 5tnTWOb5ximuNdvLrumRKNsGAc6Eba2ikNOQ9NEVJip0dPLSkpgOJoCv02rVUYXn7Tip Fm8z41kj7evLrLlKmHZA58xUWKTiykFcvUqXaGgqjkMR5DH5Sjv3c5Oa3nvgNEnB+6kd s2Zw== X-Gm-Message-State: AC+VfDx5ar+copwdmXT+Ntuz7ZJT30eym27VRd/9ZDtSapKlFXO+LWs3 B9ibGSYU61Z2Ky+QsDLEpIL7mPdePVNOTLFpisXLMNVjWd7toE3K9AG/bXhCWRWtDoynWB7o4JT anaEey3OouHuQLZqtVPyqaMLi93Gu5ckiuaouariPtCL86S92GTe8f4kawyZcidkdzAbLKjb6I5 lae8lA5dbs X-Received: by 2002:a05:6000:1202:b0:307:bb47:75de with SMTP id e2-20020a056000120200b00307bb4775demr9149936wrx.26.1684753596941; Mon, 22 May 2023 04:06:36 -0700 (PDT) X-Received: by 2002:a05:6000:1202:b0:307:bb47:75de with SMTP id e2-20020a056000120200b00307bb4775demr9149917wrx.26.1684753596586; Mon, 22 May 2023 04:06:36 -0700 (PDT) Received: from imammedo.users.ipa.redhat.com (nat-pool-brq-t.redhat.com. [213.175.37.10]) by smtp.gmail.com with ESMTPSA id k15-20020a05600c1c8f00b003f1978bbcd6sm24870383wms.3.2023.05.22.04.06.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 May 2023 04:06:35 -0700 (PDT) Date: Mon, 22 May 2023 13:06:35 +0200 From: Igor Mammedov To: linux-kernel@vger.kernel.org, rafael@kernel.org Cc: mst@redhat.com, lenb@kernel.org, bhelgaas@google.com, linux-acpi@vger.kernel.org, linux-pci@vger.kernel.org, helgaas@kernel.org, mika.westerberg@linux.intel.com Subject: Re: [PATCH v2] PCI: acpiphp: Reassign resources on bridge if necessary Message-ID: <20230522130635.5e3f8771@imammedo.users.ipa.redhat.com> In-Reply-To: <20230424191557.2464760-1-imammedo@redhat.com> References: <20230424191557.2464760-1-imammedo@redhat.com> X-Mailer: Claws Mail 4.1.1 (GTK 3.24.37; x86_64-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit 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 On Mon, 24 Apr 2023 21:15:57 +0200 Igor Mammedov wrote: > When using ACPI PCI hotplug, hotplugging a device with > large BARs may fail if bridge windows programmed by > firmware are not large enough. Rafael, Since there was no more comments for a while, can you merge this patch through your tree? > 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. > > v2: > * fixup subject to match expected style > * drop no longer needed __pci_bus_size_bridges() to avoid > memory leak (Bjorn Helgaas ) > --- > 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 5b1f271c6034..328d1e416014 100644 > --- a/drivers/pci/hotplug/acpiphp_glue.c > +++ b/drivers/pci/hotplug/acpiphp_glue.c > @@ -498,7 +498,6 @@ static void enable_slot(struct acpiphp_slot *slot, bool bridge) > acpiphp_native_scan_bridge(dev); > } > } else { > - LIST_HEAD(add_list); > int max, pass; > > acpiphp_rescan_slot(slot); > @@ -512,12 +511,10 @@ static void enable_slot(struct acpiphp_slot *slot, bool bridge) > 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);