[{"id":3684053,"web_url":"http://patchwork.ozlabs.org/comment/3684053/","msgid":"<21ed8a45-f19f-4a14-9aed-dbe0f545ae27@amd.com>","list_archive_url":null,"date":"2026-04-29T13:25:37","subject":"Re: [PATCH v3] PCI: release empty sibling bridge windows during\n window resize","submitter":{"id":63999,"url":"http://patchwork.ozlabs.org/api/people/63999/","name":"Christian König","email":"christian.koenig@amd.com"},"content":"On 4/29/26 00:51, Geramy Loveless wrote:\n> pbus_reassign_bridge_resources() refuses to release bridge windows that\n> have child resources. On multi-port PCIe switches (e.g. Thunderbolt\n> docks), empty sibling downstream ports hold small reservations that\n> prevent the parent window from being freed and re-sized for rebar.\n> \n> Walk descendants of the target window depth-first, saving and freeing\n> each empty bridge window so the parent can then be released and grown.\n> \n> Without this change, attempts to grow a window deep below a switch\n> fabric leave nested empty windows pinning the ancestor:\n> \n>   pcieport 0000:65:00.0: bridge window [mem 0x8880000000-0x98800fffff\n>     64bit pref]: not released, active children present\n>   pcieport 0000:00:03.2: bridge window [mem 0x8880000000-0x98800fffff\n>     64bit pref]: not released, active children present\n> \n> With the bottom-up walk and upstream ancestry check, the chain unwinds\n> and the rebar succeeds:\n> \n>   pcieport 0000:96:00.0: bridge window [...]: releasing\n>   pcieport 0000:95:00.0: bridge window [...]: releasing\n>   pcieport 0000:94:00.0: bridge window [...]: releasing\n>   pcieport 0000:65:00.0: bridge window [...]: releasing\n>   amdgpu 0000:97:00.0: BAR 0 [mem 0x9000000000-0x97ffffffff 64bit pref]:\n>     assigned\n\nThat sounds reasonable and I can see the rollback store \n\nBut do we make sure that we can allocate all released child resources additional to the resized resource?\n\nE.g. in the above example how is the new size of the bridge window determined? Does it include the released child resources so that they can be eventually be re-allocated when drivers start needing them?\n\nRegards,\nChristian.\n\n> \n> Suggested-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>\n> Signed-off-by: Geramy Loveless <gloveless@jqluv.com>\n> ---\n> v3:\n>  - Restructure helper: outer loop only recurses; inner iterates bus\n>    resources via pci_bus_for_each_resource(). The release path is now\n>    unified, so the caller-side block in pbus_reassign_bridge_resources()\n>    is gone.\n>  - Walk the resource tree upstream when checking ancestry of @b_win,\n>    so descendants in nested topologies are also released (Ilpo).\n>  - Drop pci_resource_is_bridge_win() filter; bus resources are\n>    inherently bridge windows.\n>  - Rename pci_bus_release_empty_bridge_resources() to\n>    pbus_release_empty_bridge_resources().\n>  - Drop misleading \"Uses PCI bus/device iterators...\" paragraph from\n>    commit message.\n>  - Kerneldoc tweaks per Ilpo's review.\n> \n> v2:\n>  - Use PCI bus/device iterators instead of walking raw resource tree.\n>  - Save released resources to rollback list.\n>  - Filter via pci_resource_is_bridge_win() (now removed in v3).\n>  - Call release before the !res->child check.\n>  - Check bridge->subordinate before recursion.\n> ---\n>  drivers/pci/setup-bus.c | 63 +++++++++++++++++++++++++++++++++++++++--\n>  1 file changed, 61 insertions(+), 2 deletions(-)\n> \n> diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c\n> index 4cf120ebe5a..0c1fb654c9c 100644\n> --- a/drivers/pci/setup-bus.c\n> +++ b/drivers/pci/setup-bus.c\n> @@ -2292,6 +2292,60 @@ void pci_assign_unassigned_bridge_resources(struct pci_dev *bridge)\n>  }\n>  EXPORT_SYMBOL_GPL(pci_assign_unassigned_bridge_resources);\n>  \n> +/*\n> + * pci_bus_release_empty_bridge_resources - Bottom-up release of bridge\n> + * window resources in empty subtrees.\n> + * @bus: PCI bus whose child bridges to process\n> + * @b_win: Ancestor bridge window; only children of this resource are released\n> + * @saved: List to save released resources for rollback\n> + *\n> + * Recurses depth-first into subordinate buses, then releases bridge windows\n> + * on the way back up.  Each resource is individually saved before release so\n> + * the entire operation can be rolled back.\n> + */\n> +static void pci_bus_release_empty_bridge_resources(struct pci_bus *bus,\n> +\t\t\t\t\t\t   struct resource *b_win,\n> +\t\t\t\t\t\t   struct list_head *saved)\n> +{\n> +\tstruct pci_dev *dev;\n> +\n> +\tlist_for_each_entry(dev, &bus->devices, bus_list) {\n> +\t\tstruct resource *r;\n> +\t\tunsigned int i;\n> +\n> +\t\tif (!dev->subordinate)\n> +\t\t\tcontinue;\n> +\n> +\t\t/* Recurse first — release deepest resources before parents */\n> +\t\tpci_bus_release_empty_bridge_resources(dev->subordinate,\n> +\t\t\t\t\t\t      b_win, saved);\n> +\n> +\t\tpci_dev_for_each_resource(dev, r, i) {\n> +\t\t\tif (!pci_resource_is_bridge_win(i))\n> +\t\t\t\tcontinue;\n> +\n> +\t\t\tif (!resource_assigned(r))\n> +\t\t\t\tcontinue;\n> +\n> +\t\t\tif (r->parent != b_win)\n> +\t\t\t\tcontinue;\n> +\n> +\t\t\tif (r->child) {\n> +\t\t\t\tconst char *res_name = pci_resource_name(dev, i);\n> +\n> +\t\t\t\tpci_info(dev, \"%s %pR: not released, children still present\\n\",\n> +\t\t\t\t\t res_name, r);\n> +\t\t\t\tcontinue;\n> +\t\t\t}\n> +\n> +\t\t\tif (pci_dev_res_add_to_list(saved, dev, r, 0, 0))\n> +\t\t\t\tcontinue;\n> +\n> +\t\t\tpci_release_resource(dev, i);\n> +\t\t}\n> +\t}\n> +}\n> +\n>  /*\n>   * Walk to the root bus, find the bridge window relevant for @res and\n>   * release it when possible. If the bridge window contains assigned\n> @@ -2316,7 +2370,12 @@ static int pbus_reassign_bridge_resources(struct pci_bus *bus, struct resource *\n>  \n>  \t\ti = pci_resource_num(bridge, res);\n>  \n> -\t\t/* Ignore BARs which are still in use */\n> +\t\t/* Release empty sibling bridge windows bottom-up */\n> +\t\tif (bridge->subordinate)\n> +\t\t\tpci_bus_release_empty_bridge_resources(\n> +\t\t\t\tbridge->subordinate, res, saved);\n> +\n> +\t\t/* Ignore bridge windows which are still in use */\n>  \t\tif (!res->child) {\n>  \t\t\tret = pci_dev_res_add_to_list(saved, bridge, res, 0, 0);\n>  \t\t\tif (ret)\n> @@ -2327,7 +2386,7 @@ static int pbus_reassign_bridge_resources(struct pci_bus *bus, struct resource *\n>  \t\t\tconst char *res_name = pci_resource_name(bridge, i);\n>  \n>  \t\t\tpci_warn(bridge,\n> -\t\t\t\t \"%s %pR: was not released (still contains assigned resources)\\n\",\n> +\t\t\t\t \"%s %pR: not released, active children present\\n\",\n>  \t\t\t\t res_name, res);\n>  \t\t}\n>","headers":{"Return-Path":"\n <linux-pci+bounces-53397-incoming=patchwork.ozlabs.org@vger.kernel.org>","X-Original-To":["incoming@patchwork.ozlabs.org","linux-pci@vger.kernel.org"],"Delivered-To":"patchwork-incoming@legolas.ozlabs.org","Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (1024-bit key;\n unprotected) header.d=amd.com header.i=@amd.com header.a=rsa-sha256\n header.s=selector1 header.b=QTWvboCK;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org\n (client-ip=104.64.211.4; helo=sin.lore.kernel.org;\n envelope-from=linux-pci+bounces-53397-incoming=patchwork.ozlabs.org@vger.kernel.org;\n receiver=patchwork.ozlabs.org)","smtp.subspace.kernel.org;\n\tdkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com\n header.b=\"QTWvboCK\"","smtp.subspace.kernel.org;\n arc=fail smtp.client-ip=52.101.85.9","smtp.subspace.kernel.org;\n dmarc=pass (p=quarantine dis=none) header.from=amd.com","smtp.subspace.kernel.org;\n spf=fail smtp.mailfrom=amd.com","dkim=none (message not signed)\n header.d=none;dmarc=none action=none header.from=amd.com;"],"Received":["from sin.lore.kernel.org (sin.lore.kernel.org [104.64.211.4])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4g5JFT18PHz1yHZ\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 29 Apr 2026 23:34:53 +1000 (AEST)","from smtp.subspace.kernel.org (conduit.subspace.kernel.org\n [100.90.174.1])\n\tby sin.lore.kernel.org (Postfix) with ESMTP id 3241B3057E11\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 29 Apr 2026 13:25:50 +0000 (UTC)","from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id 38EB93A3E92;\n\tWed, 29 Apr 2026 13:25:47 +0000 (UTC)","from BYAPR05CU005.outbound.protection.outlook.com\n (mail-westusazon11010009.outbound.protection.outlook.com [52.101.85.9])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby smtp.subspace.kernel.org (Postfix) with ESMTPS id 9BE493B6346\n\tfor <linux-pci@vger.kernel.org>; Wed, 29 Apr 2026 13:25:45 +0000 (UTC)","from PH7PR12MB5685.namprd12.prod.outlook.com (2603:10b6:510:13c::22)\n by PH8PR12MB7422.namprd12.prod.outlook.com (2603:10b6:510:22a::12) with\n Microsoft SMTP Server (version=TLS1_2,\n cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9870.20; Wed, 29 Apr\n 2026 13:25:42 +0000","from PH7PR12MB5685.namprd12.prod.outlook.com\n ([fe80::ce69:cfae:774d:a65c]) by PH7PR12MB5685.namprd12.prod.outlook.com\n ([fe80::ce69:cfae:774d:a65c%5]) with mapi id 15.20.9870.016; Wed, 29 Apr 2026\n 13:25:42 +0000"],"ARC-Seal":["i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1777469147; cv=fail;\n b=pDRSAau9y+IRXWSMdUIpejs4q+Xeth2dhIQoWe9RC2gEmp/4ABi8wA7YMEixBq4PNokDk0UrKMV+cyUt2L3ByyKZMUda27GoBrCweAj5MeqqrVnDv3lhT7j4ZkexmRWr8+s822NuWXmgQYHTccmq8tIUBw0NKKf1F3J3xM9j7b0=","i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none;\n b=jkqEZTBNG80+V/IMZ9lLkH06nfQAql+wcXRMtvm6NrqoTnm+j5ULEhBk4HPr+D3q2vaghimi15REkZCWgYoGZlLTqC0pf4q6PaJ5/+kM5JzecCFgmHkEK8NlykuTOV46LQSraSl9/QTp+iSCy6+NhnMgwK8c3ER/5LWFsEmWEFcRmy+3NP2DGdUX+QKp5gMHodyavu/zzK0p4x4UQsjzN2MDISveB64CtqprMaV26zYTtNfXQAlPoyA9KbmgX44CjojyrRVSyreVlzG2AUriqM10dG8whM1/UlsTNE/q8yskN95zUl2UvX1na0rEva6/h7Y+bdfJRU55rJ/C/Lx+EQ=="],"ARC-Message-Signature":["i=2; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1777469147; c=relaxed/simple;\n\tbh=bt7PoTIL3XPdWjNSN01Rny/JFFKF8RD8jsM+lHcc24c=;\n\th=Message-ID:Date:Subject:To:Cc:References:From:In-Reply-To:\n\t Content-Type:MIME-Version;\n b=jMCvAZKsqHtIViOOABNijDhBEfTUI+9UBeRIMNDWM0DTq3QpULoMuzi+EM7ILOcAcPFCreRAe7wdrYTg3RGRQEgsKrroQ+/dPF4D+Zt3TLoPIFrXg4OnKV3lofYrd1kdlgCBk7SGkXD3/BWxpGrQ425cutL+rutP6zF0GrtP0iY=","i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com;\n s=arcselector10001;\n h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1;\n bh=n3rjqPSR2+eYiTtkHWwiP+NnWOEc4dKx7uF0q2nCOmw=;\n b=cu3jGagwY+7KgiiwIRtiTDPPsNiMpa0PhTCOVWKUvpTamtCLTMZoRroGd5rWgLjiT7B0ilBCV4bS8wX0SfusCPYu343SC/VT7BWz/JKOj/0NWDjvOxShoaZHTltH1rE06rv3FoKc8iYdqOlpjmFJIvDwToLV9nSWYEyyPXX1qf0fvJ46I4t4uUye/kzbZn31R+GWQsviS7+72wzdyoK4saubcfMDVmRCrehsFkfLh1YMreoH9kPCXPkKBiiJI5+3WLNkelbVrIYXnBfwPn2GEI/G8Nfup273pcTArL0dPPdnMFiMAonEmvUE/F6+IhCdpg3dxMIg3NvQi4kDgvBcHw=="],"ARC-Authentication-Results":["i=2; smtp.subspace.kernel.org;\n dmarc=pass (p=quarantine dis=none) header.from=amd.com;\n spf=fail smtp.mailfrom=amd.com;\n dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com\n header.b=QTWvboCK; arc=fail smtp.client-ip=52.101.85.9","i=1; mx.microsoft.com 1; spf=pass\n smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass\n header.d=amd.com; arc=none"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1;\n h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck;\n bh=n3rjqPSR2+eYiTtkHWwiP+NnWOEc4dKx7uF0q2nCOmw=;\n b=QTWvboCKVrTlZZpEqZSYqQxc3Q1RV4n7gCuat7X/eUghHMKlmvk2CutDwD5Wx1FFtSo2fPkXJ2lbLHUAiCGGF39Fss2wxC1KlXyp9uYfGTZMGOt4MglxPv7XWHo7j7tdjSCulmUCxIAwtz+eoIcOeMUfgxqfI3CBRkYqrmh4w/M=","Message-ID":"<21ed8a45-f19f-4a14-9aed-dbe0f545ae27@amd.com>","Date":"Wed, 29 Apr 2026 15:25:37 +0200","User-Agent":"Mozilla Thunderbird","Subject":"Re: [PATCH v3] PCI: release empty sibling bridge windows during\n window resize","To":"Geramy Loveless <gloveless@jqluv.com>,\n =?utf-8?q?Ilpo_J=C3=A4rvinen?= <ilpo.jarvinen@linux.intel.com>","Cc":"Cristian Cocos <cristi@ieee.org>, linux-pci@vger.kernel.org","References":"<20260428225146.3104063-1-gloveless@jqluv.com>","Content-Language":"en-US","From":"=?utf-8?q?Christian_K=C3=B6nig?= <christian.koenig@amd.com>","In-Reply-To":"<20260428225146.3104063-1-gloveless@jqluv.com>","Content-Type":"text/plain; charset=UTF-8","Content-Transfer-Encoding":"8bit","X-ClientProxiedBy":"FR4P281CA0130.DEUP281.PROD.OUTLOOK.COM\n (2603:10a6:d10:b9::18) To PH7PR12MB5685.namprd12.prod.outlook.com\n (2603:10b6:510:13c::22)","Precedence":"bulk","X-Mailing-List":"linux-pci@vger.kernel.org","List-Id":"<linux-pci.vger.kernel.org>","List-Subscribe":"<mailto:linux-pci+subscribe@vger.kernel.org>","List-Unsubscribe":"<mailto:linux-pci+unsubscribe@vger.kernel.org>","MIME-Version":"1.0","X-MS-PublicTrafficType":"Email","X-MS-TrafficTypeDiagnostic":"PH7PR12MB5685:EE_|PH8PR12MB7422:EE_","X-MS-Office365-Filtering-Correlation-Id":"f3000ab2-b4de-45b3-9a08-08dea5f2d000","X-MS-Exchange-SenderADCheck":"1","X-MS-Exchange-AntiSpam-Relay":"0","X-Microsoft-Antispam":"\n\tBCL:0;ARA:13230040|1800799024|376014|366016|18002099003|22082099003|56012099003;","X-Microsoft-Antispam-Message-Info":"\n\tNpWxx5ruDHOWpJ3vEAJWbgqphOg3fVHJCKvz3sh3IplcJJLNcV751QsMY5kpYb3Jtd5VMkV5BuaqzHDbswI0CtiSG7TYENX2gdONfkoSpSrFDylqKTmNftcpDFw+tEVX3EcaWb2RCyLc+Pml4DaWEJHETD6JYm78KP9PXUb7j7krpcj7VzoEMaEYkVBKgYUqaXe2WRWmWdrRQGfJXoO4VO5mPLdBQfp1vD7+0pRl+e0n/X3xgOB8Rosnf/VjXn3KD20Ajm7TYO0pj8+RXy5dG/onnsUOxi97WCUilgpsU4ApQE54eT/J+uIBiQSN1Nh9y/6Mn2UZ/LszPQ7byfO9cl1gs2pu2b+LzB6C3LC2+CVS8rSFKUyk63PhMmKLjyNSuJCsfaTSjylq75DtTrxvUtD6a5z0aJgG3Mn0km5oJuOLFY7u23W+HpdhREcNJgnCOp/AxjC5+gappraot4HWs6dhp5RBQJF5tUzeLGs4ZNFzfdd92iFjUxM+2cxllYhiJjukfHp6ePRKhmQ5kXs8J9Bqk6djyB/lCfCLb46cT5s5H+YBZr6EhCrHzp4V1/A7wxNgTwDFvVGYnsdi4i/KLWlbra2jvgaFEOxnrYdKrpoNWaiNq2mIl0wTrIyMiSeEs1bazDtCvkNO7PMdYAWOGJJQPP6JUROcdFrJyf+okTwrnewVAe0EDDnUUjmJGm+JF2arVMdP+akPRJXpMOHkj3Z9qsLvItpDoF0hOvD7e/Q=","X-Forefront-Antispam-Report":"\n\tCIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PH7PR12MB5685.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(376014)(366016)(18002099003)(22082099003)(56012099003);DIR:OUT;SFP:1101;","X-MS-Exchange-AntiSpam-MessageData-ChunkCount":"1","X-MS-Exchange-AntiSpam-MessageData-0":"=?utf-8?q?81ZO4egm0cCFewyBO7sluhXB7THy?=\n\t=?utf-8?q?CcgIIPWhwsx/uFlj2aakVwagPOlvYHMRDfTJ8Y2pQtXpuPaZmZHBkEfa02Bi4HUSA?=\n\t=?utf-8?q?lL7ilBjt4VEi1yMy/xTJp8etEhj8WA+jk+n0Xb3YDvflngiUrPvgn2pXVcyW2FHbR?=\n\t=?utf-8?q?XTtPRcSZCairl3DBAA78CzFPf9Aw1AgpTgU3T0BAiM46oC+nNhfrWxaAdBiVfRjA3?=\n\t=?utf-8?q?uF/jAqZ7b5uhG0GnKSAqXrS99QUGyljM56LfEsI7+muypt5O89g/MD27UJhTzkaNK?=\n\t=?utf-8?q?JPzQR8XRjDsDlF3yuty+cA0dFmJU2VxA3NqXckk/XezK7F7JG9XG+73tYm2tDR5Ud?=\n\t=?utf-8?q?zQxqxRm8DqZn0fBRlualmBs+T89khlgagOKfclVZDfTgxbGQypde+KnDqHkKHTivJ?=\n\t=?utf-8?q?yXu1eP9WNl5EY/jNdtH9MfEG/rb9Sb3MPh8UYbFH9h3bmg6UBRVMkBbM/x1bQHJWe?=\n\t=?utf-8?q?1YiCrzGDSKllLJtJL4/Pav20UMwtx2VKbD3i2zRaO75vOB3QAyAeUV0j6ddXXOqE/?=\n\t=?utf-8?q?1eCxgvuUf4bhk5Ep6qN8P5arTw2miHp20U3EOnYnb73dm0QIJdf+A/onNivJ6Qk5r?=\n\t=?utf-8?q?N7mgcRznLP9ysh97hu/7jggn9I4w89OhL7nmERhB30ZE/0nWj0064vNmg7OzYJE/t?=\n\t=?utf-8?q?9d3iXYHEX3ZnPVY0Cr5FEMt/byFSnSRqZVAQdvvO2FusjDAoxjECzLtGSTcnDTnb3?=\n\t=?utf-8?q?vkadQBl4+8qG08xfdHe8jQf/zTPyCsxgIXrPh95hiB0X5wzoSnzRDMNg2IP79dJBD?=\n\t=?utf-8?q?LwdhwBeImYZ+c7CSm6bcrtw286rigpH7W2DVPw0Qd4WNYhLgWmdXFtFaVXDa0HUwp?=\n\t=?utf-8?q?zR9dTS/dvQPKwgpsfq8dYQ8xXzkFsg9DFf5Bskm5JhhcRWuJtvBwfugUbhFHM0g+/?=\n\t=?utf-8?q?r5KE3WPyeucGJ0k0AcEJdAEIjzbAxuKHiMRrFO82OKt0gWwZT9j/CJ8SlopC3vSph?=\n\t=?utf-8?q?pUsYAgyeEqRwAdG1agPwPJntLlIEEngGgfrqt6WMjBz2QxjyD5fjahWLHEhH8SoaY?=\n\t=?utf-8?q?lnSt3+aBZ/dP7dR5xX2OlTTgod9JSdcvKRdzCwtIe54GR/cB7CYp2+I3oLfGN+KEn?=\n\t=?utf-8?q?wu/NVr7x8nWppFCRDDHWDF6C2KjhDWpF6bui4q+NDo2iuvcLh9HjPnDEhygN6EqAs?=\n\t=?utf-8?q?JENwSfgeQqxZxG9WsdSjvTWiCImyS+l4hCujUiYs5amMwFqONhu4osLtxkDf6bxa+?=\n\t=?utf-8?q?JpfRIGPYdEaPvAxi/42JqP45piS7eKPa7a7/S0k2Q/S6fV9QYUFQMKEkGk+4igG1A?=\n\t=?utf-8?q?53m/uKyqfRDRPbQOPAmdc3h7CAmsaKy0LaJSK/+te4oEQC6GPesW2DUtQy8ApS2yJ?=\n\t=?utf-8?q?CHs030VPCMK/4d77sAEUeQuNIIV2v13CqqjhJuDVKIVPqsfSpjPpousghddy0l6v6?=\n\t=?utf-8?q?kdvJHr3t3sFvQoOz+bjIRar78ho3bX5dkEl/mxJ1DeuTSJ5qbcBNhYUNgJe4fBK0B?=\n\t=?utf-8?q?8ohQv9aLHM+T0okirctRKcDEoEzPxOtT1vZLQqiREm97m1Gbdyad6CQjI37W8QFlQ?=\n\t=?utf-8?q?Lcyu8lGKiA/1H5TvmO7mGLy1U4BjX1fg+gs5tzqyRXtZvVYsBQnkmCWNOHEJ/z5DG?=\n\t=?utf-8?q?qbXriWf2wFBGZZAQ4yYkhF0G01/PlO/6f6iITclSxBoKbRug8K4ICM866gOVZfE0h?=\n\t=?utf-8?q?VUSroSrWE7?=","X-OriginatorOrg":"amd.com","X-MS-Exchange-CrossTenant-Network-Message-Id":"\n f3000ab2-b4de-45b3-9a08-08dea5f2d000","X-MS-Exchange-CrossTenant-AuthSource":"PH7PR12MB5685.namprd12.prod.outlook.com","X-MS-Exchange-CrossTenant-AuthAs":"Internal","X-MS-Exchange-CrossTenant-OriginalArrivalTime":"29 Apr 2026 13:25:42.5506\n (UTC)","X-MS-Exchange-CrossTenant-FromEntityHeader":"Hosted","X-MS-Exchange-CrossTenant-Id":"3dd8961f-e488-4e60-8e11-a82d994e183d","X-MS-Exchange-CrossTenant-MailboxType":"HOSTED","X-MS-Exchange-CrossTenant-UserPrincipalName":"\n n9dtEN5dLFUTDryMuTQ1ffYsj695QVRaZ+IPyjcAxtl5QqNQolvpIOGFLNWC/g84","X-MS-Exchange-Transport-CrossTenantHeadersStamped":"PH8PR12MB7422"}},{"id":3684161,"web_url":"http://patchwork.ozlabs.org/comment/3684161/","msgid":"<CAGpo2meOiExOK=r9y7Jiio0XmJ2vDtE_4NkeCniQ873jEqynyw@mail.gmail.com>","list_archive_url":null,"date":"2026-04-29T16:21:07","subject":"Re: [PATCH v3] PCI: release empty sibling bridge windows during\n window resize","submitter":{"id":93094,"url":"http://patchwork.ozlabs.org/api/people/93094/","name":"Geramy Loveless","email":"gloveless@jqluv.com"},"content":"> On 4/29/26 00:51, Geramy Loveless wrote:\n> > pbus_reassign_bridge_resources() refuses to release bridge windows that\n> > have child resources. On multi-port PCIe switches (e.g. Thunderbolt\n> > docks), empty sibling downstream ports hold small reservations that\n> > prevent the parent window from being freed and re-sized for rebar.\n> >\n> > Walk descendants of the target window depth-first, saving and freeing\n> > each empty bridge window so the parent can then be released and grown.\n> >\n> > Without this change, attempts to grow a window deep below a switch\n> > fabric leave nested empty windows pinning the ancestor:\n> >\n> >   pcieport 0000:65:00.0: bridge window [mem 0x8880000000-0x98800fffff\n> >     64bit pref]: not released, active children present\n> >   pcieport 0000:00:03.2: bridge window [mem 0x8880000000-0x98800fffff\n> >     64bit pref]: not released, active children present\n> >\n> > With the bottom-up walk and upstream ancestry check, the chain unwinds\n> > and the rebar succeeds:\n> >\n> >   pcieport 0000:96:00.0: bridge window [...]: releasing\n> >   pcieport 0000:95:00.0: bridge window [...]: releasing\n> >   pcieport 0000:94:00.0: bridge window [...]: releasing\n> >   pcieport 0000:65:00.0: bridge window [...]: releasing\n> >   amdgpu 0000:97:00.0: BAR 0 [mem 0x9000000000-0x97ffffffff 64bit pref]:\n> >     assigned\n>\n> That sounds reasonable and I can see the rollback store\n>\n> But do we make sure that we can allocate all released child resources additional to the resized resource?\nI am not sure I will need to investigate to see if the other code in\nthe kernel follows this path correctly, I would assume it does since\nthe parent is being released by this code if there was no children, we\nare just releasing the children too if applicable essentially.\nThats my thoughts they could be inaccurate though since i'm not\nextremely involved in linux kernel code until recently.\n\n>\n> E.g. in the above example how is the new size of the bridge window determined? Does it include the released child resources so that they can be eventually be re-allocated when drivers start needing them?\n\nThis patch basically releases the children so the system that deals\nwith allocating and changing window size can actually change it.\nSo basically the only blocker to window resizing was this patch,\nwhatever pcie already does in linux basically now can happen with the\nchildren released without further changes.\nDoes that make sense?\n\nBasically our only job is to make sure to release the children and the\nrest of the linux kernel can continue forward and resize the window,\nthe stopper was the children not getting released essentially.\n\n>\n> Regards,\n> Christian.\n>\n> >\n> > Suggested-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>\n> > Signed-off-by: Geramy Loveless <gloveless@jqluv.com>\n> > ---\n> > v3:\n> >  - Restructure helper: outer loop only recurses; inner iterates bus\n> >    resources via pci_bus_for_each_resource(). The release path is now\n> >    unified, so the caller-side block in pbus_reassign_bridge_resources()\n> >    is gone.\n> >  - Walk the resource tree upstream when checking ancestry of @b_win,\n> >    so descendants in nested topologies are also released (Ilpo).\n> >  - Drop pci_resource_is_bridge_win() filter; bus resources are\n> >    inherently bridge windows.\n> >  - Rename pci_bus_release_empty_bridge_resources() to\n> >    pbus_release_empty_bridge_resources().\n> >  - Drop misleading \"Uses PCI bus/device iterators...\" paragraph from\n> >    commit message.\n> >  - Kerneldoc tweaks per Ilpo's review.\n> >\n> > v2:\n> >  - Use PCI bus/device iterators instead of walking raw resource tree.\n> >  - Save released resources to rollback list.\n> >  - Filter via pci_resource_is_bridge_win() (now removed in v3).\n> >  - Call release before the !res->child check.\n> >  - Check bridge->subordinate before recursion.\n> > ---\n> >  drivers/pci/setup-bus.c | 63 +++++++++++++++++++++++++++++++++++++++--\n> >  1 file changed, 61 insertions(+), 2 deletions(-)\n> >\n> > diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c\n> > index 4cf120ebe5a..0c1fb654c9c 100644\n> > --- a/drivers/pci/setup-bus.c\n> > +++ b/drivers/pci/setup-bus.c\n> > @@ -2292,6 +2292,60 @@ void pci_assign_unassigned_bridge_resources(struct pci_dev *bridge)\n> >  }\n> >  EXPORT_SYMBOL_GPL(pci_assign_unassigned_bridge_resources);\n> >\n> > +/*\n> > + * pci_bus_release_empty_bridge_resources - Bottom-up release of bridge\n> > + * window resources in empty subtrees.\n> > + * @bus: PCI bus whose child bridges to process\n> > + * @b_win: Ancestor bridge window; only children of this resource are released\n> > + * @saved: List to save released resources for rollback\n> > + *\n> > + * Recurses depth-first into subordinate buses, then releases bridge windows\n> > + * on the way back up.  Each resource is individually saved before release so\n> > + * the entire operation can be rolled back.\n> > + */\n> > +static void pci_bus_release_empty_bridge_resources(struct pci_bus *bus,\n> > +                                                struct resource *b_win,\n> > +                                                struct list_head *saved)\n> > +{\n> > +     struct pci_dev *dev;\n> > +\n> > +     list_for_each_entry(dev, &bus->devices, bus_list) {\n> > +             struct resource *r;\n> > +             unsigned int i;\n> > +\n> > +             if (!dev->subordinate)\n> > +                     continue;\n> > +\n> > +             /* Recurse first — release deepest resources before parents */\n> > +             pci_bus_release_empty_bridge_resources(dev->subordinate,\n> > +                                                   b_win, saved);\n> > +\n> > +             pci_dev_for_each_resource(dev, r, i) {\n> > +                     if (!pci_resource_is_bridge_win(i))\n> > +                             continue;\n> > +\n> > +                     if (!resource_assigned(r))\n> > +                             continue;\n> > +\n> > +                     if (r->parent != b_win)\n> > +                             continue;\n> > +\n> > +                     if (r->child) {\n> > +                             const char *res_name = pci_resource_name(dev, i);\n> > +\n> > +                             pci_info(dev, \"%s %pR: not released, children still present\\n\",\n> > +                                      res_name, r);\n> > +                             continue;\n> > +                     }\n> > +\n> > +                     if (pci_dev_res_add_to_list(saved, dev, r, 0, 0))\n> > +                             continue;\n> > +\n> > +                     pci_release_resource(dev, i);\n> > +             }\n> > +     }\n> > +}\n> > +\n> >  /*\n> >   * Walk to the root bus, find the bridge window relevant for @res and\n> >   * release it when possible. If the bridge window contains assigned\n> > @@ -2316,7 +2370,12 @@ static int pbus_reassign_bridge_resources(struct pci_bus *bus, struct resource *\n> >\n> >               i = pci_resource_num(bridge, res);\n> >\n> > -             /* Ignore BARs which are still in use */\n> > +             /* Release empty sibling bridge windows bottom-up */\n> > +             if (bridge->subordinate)\n> > +                     pci_bus_release_empty_bridge_resources(\n> > +                             bridge->subordinate, res, saved);\n> > +\n> > +             /* Ignore bridge windows which are still in use */\n> >               if (!res->child) {\n> >                       ret = pci_dev_res_add_to_list(saved, bridge, res, 0, 0);\n> >                       if (ret)\n> > @@ -2327,7 +2386,7 @@ static int pbus_reassign_bridge_resources(struct pci_bus *bus, struct resource *\n> >                       const char *res_name = pci_resource_name(bridge, i);\n> >\n> >                       pci_warn(bridge,\n> > -                              \"%s %pR: was not released (still contains assigned resources)\\n\",\n> > +                              \"%s %pR: not released, active children present\\n\",\n> >                                res_name, res);\n> >               }\n> >\n>","headers":{"Return-Path":"\n <linux-pci+bounces-53400-incoming=patchwork.ozlabs.org@vger.kernel.org>","X-Original-To":["incoming@patchwork.ozlabs.org","linux-pci@vger.kernel.org"],"Delivered-To":"patchwork-incoming@legolas.ozlabs.org","Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=jqluv-com.20251104.gappssmtp.com\n header.i=@jqluv-com.20251104.gappssmtp.com header.a=rsa-sha256\n header.s=20251104 header.b=hLMlD/vp;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org\n (client-ip=172.234.253.10; helo=sea.lore.kernel.org;\n envelope-from=linux-pci+bounces-53400-incoming=patchwork.ozlabs.org@vger.kernel.org;\n receiver=patchwork.ozlabs.org)","smtp.subspace.kernel.org;\n\tdkim=pass (2048-bit key) header.d=jqluv-com.20251104.gappssmtp.com\n header.i=@jqluv-com.20251104.gappssmtp.com header.b=\"hLMlD/vp\"","smtp.subspace.kernel.org;\n arc=pass smtp.client-ip=209.85.160.178","smtp.subspace.kernel.org;\n dmarc=none (p=none dis=none) header.from=jqluv.com","smtp.subspace.kernel.org;\n spf=none smtp.mailfrom=jqluv.com"],"Received":["from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4g5N5h3Wh2z1yHZ\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 30 Apr 2026 02:28:24 +1000 (AEST)","from smtp.subspace.kernel.org (conduit.subspace.kernel.org\n [100.90.174.1])\n\tby sea.lore.kernel.org (Postfix) with ESMTP id 95475303677A\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 29 Apr 2026 16:21:31 +0000 (UTC)","from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id 7627740FD92;\n\tWed, 29 Apr 2026 16:21:30 +0000 (UTC)","from mail-qt1-f178.google.com (mail-qt1-f178.google.com\n [209.85.160.178])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))\n\t(No client certificate requested)\n\tby smtp.subspace.kernel.org (Postfix) with ESMTPS id 5CE1040FDBE\n\tfor <linux-pci@vger.kernel.org>; Wed, 29 Apr 2026 16:21:23 +0000 (UTC)","by mail-qt1-f178.google.com with SMTP id\n d75a77b69052e-50faf8ed9c5so55100741cf.2\n        for <linux-pci@vger.kernel.org>; Wed, 29 Apr 2026 09:21:22 -0700 (PDT)"],"ARC-Seal":["i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1777479690; cv=pass;\n b=Z4AkK+sbAE8M4Z70ELLfjPLPND7hfXetG6GQe6meXjXIrW2riUbZxZ94irCFvPXJ8PhVDcnXqlHN+G1HLSOL7bycblbgw5Hh1lTHQ670LNufY7o8q+qcZBFunc2LDZK6fkmslHZM0jlB7OZolplh5MqgTH/hAnFhn1h6k6Oiwgw=","i=1; a=rsa-sha256; t=1777479678; cv=none;\n        d=google.com; s=arc-20240605;\n        b=Wcr8FHSxvutq6FYlb2+AylI002Y0KTxOPeckD6tmvcRz0/r2GSxSOkk9m6IR9KfLKb\n         wtVfkz30PJy6fdUlkdnfpiN5OvukLaXkbXbAlwyhDJbb+cvMKcuNQ/lEV1GMLYMawE0z\n         vX6qGNL2IiwC8PQPHpMKLrPIyv7ORMaPfea7RRdUROUPcPuResvtoODiml8Hmdnij5/e\n         HF1rqFLaY18M4bfNe7dUhwssp77DsvTAnSnw1LVd27VNLp0VmR13ENNOpj7mN5kctTvN\n         QxRbjRUaXYlByDwp1BOkMBI8T4AcWpOXA7YgUJLzMWLON5RtFDIo6zBdoRzAyBE8ZT56\n         eUvQ=="],"ARC-Message-Signature":["i=2; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1777479690; c=relaxed/simple;\n\tbh=kf23xg9RLUhQr/tA8z9LpXbufKza/+MISzGlgYWrx8I=;\n\th=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject:\n\t To:Cc:Content-Type;\n b=Jp8YHeP4g2woIvJBKY+BVQE5Te9YqXsBsXMwpOG7KqPhP0/dqBF6v84BxCA957MPK95InSBfKmv8NEdO2RcqOSBW2aqIkZrH8buLLwICeZ1wCY/LvFVYISBqRgAxnffaDPYjcBqqU98gPyyWZqTu8t3xYBBGT320vk6FD7zzCOQ=","i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com;\n s=arc-20240605;\n        h=content-transfer-encoding:cc:to:subject:message-id:date:from\n         :in-reply-to:references:mime-version:dkim-signature;\n        bh=RGuZ4SJMokCn8C5Jef4Vuyolecb8c9bvSvvHqufnpwI=;\n        fh=ZYGNxh8KP2rH2Q8tFfKWSzEZMz8N1VxYaW4KMQ3HJ9o=;\n        b=jse/8NMwEj3XWnhT5kJ76nbhWqCNkdtA/U76/UuoKdYYVhVmaRtDmroQKpjcXSFdhf\n         rnpAeHhfjBJqxD66pZfHh6QwR+ZEMtYHrUF7dzUI+/cHS+oCqrvugHlPpa73IfrOu951\n         aNkA+J3Rz57zCNuStQw5OmKek/AtcwgOFtF8QIXpfVQdKA4BWgGBdei3kaRHijYovlPY\n         bAJaqX7n1Wzt3zfVWGBB+jqV2snVcyJ5E7a+2+ixoRq1d9/uQgkEbyZ9Kl+kiSSpLlZm\n         QK9T01WfkQsKxp4gojXAWzuGs2ge91Xm//cgAxyo8QFq91RVA/+X+xJnJO09WiSY3AXg\n         1cDA==;\n        darn=vger.kernel.org"],"ARC-Authentication-Results":["i=2; smtp.subspace.kernel.org;\n dmarc=none (p=none dis=none) header.from=jqluv.com;\n spf=none smtp.mailfrom=jqluv.com;\n dkim=pass (2048-bit key) header.d=jqluv-com.20251104.gappssmtp.com\n header.i=@jqluv-com.20251104.gappssmtp.com header.b=hLMlD/vp;\n arc=pass smtp.client-ip=209.85.160.178","i=1; mx.google.com; arc=none"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n        d=jqluv-com.20251104.gappssmtp.com; s=20251104; t=1777479678;\n x=1778084478; darn=vger.kernel.org;\n        h=content-transfer-encoding:cc:to:subject:message-id:date:from\n         :in-reply-to:references:mime-version:from:to:cc:subject:date\n         :message-id:reply-to;\n        bh=RGuZ4SJMokCn8C5Jef4Vuyolecb8c9bvSvvHqufnpwI=;\n        b=hLMlD/vp7OBiyIy8RPWSkv9fW5/wWPdJoQEYp8HIAw9uyZVZT6V8xfFrgn//YOhh95\n         7hi9a9TEJX6rMzz7Buz52asVc3IxqF3nJ9Db2HhK79JaM3z9rWga4FrROTmOmPZSaK7X\n         p9q4HRj3oYu95MfmWB654OPuoCRl1cEYUP5QnullKmVf1EPjoK5ETJWjwiXi0pcmWXBj\n         IbDEb943P+a1jfx+4VRpwMpWe7QMDGprE3JcVx+mpC71YU9T0NGecTMtP0SWTFfup3i0\n         fbmvgfOh7uhvQVblcsiSREaKs81foc1S8mi/9y6YusdwoYzhMJ/KqJEniOLoP4+2BY4o\n         eqwg==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n        d=1e100.net; s=20251104; t=1777479678; x=1778084478;\n        h=content-transfer-encoding:cc:to:subject:message-id:date:from\n         :in-reply-to:references:mime-version:x-gm-gg:x-gm-message-state:from\n         :to:cc:subject:date:message-id:reply-to;\n        bh=RGuZ4SJMokCn8C5Jef4Vuyolecb8c9bvSvvHqufnpwI=;\n        b=W8WQU+egP9jyzKPzGS/X6LoyzZtdhWtBudnt4SIwmJFbd2cHDAMJgYpM31oCfpk+Zj\n         pbp8ckRXyJJNQpNWTuVnmNexL2yUn3M6z4DULsspUowZgoeZ56DOrwBdb+tGG+wg+LU5\n         ahqBh4doC99PJOAcV+/y/pO3IWMhX1/US+jRPyccg1IGysfhyUZet8vLiug6xTCme9Zn\n         UYam4RwTLcEVtXPWAVe3ja/niA/h0lMPdZrTXlOWdABj4ggp5pqsdL50WKopF8xCh/9f\n         Bve3uv/kHpA6c4utqKcInBiyQNmMrU1NXzyLyeTPYdpdSkChK9dl0FfaeHLwQ1bcFB5M\n         7Ywg==","X-Forwarded-Encrypted":"i=1;\n AFNElJ/PcJZeFAnahp2QaVKJ3hzkh6Ys+/5HyCJHqrixBhHfGiyEjQW7fsOOHEorNQPxPA4e2CTwHdHwcdo=@vger.kernel.org","X-Gm-Message-State":"AOJu0YzNJ5yrNu/rUnadYawRJWn6a3GRnEDnST8cp39xSwqPI/ckfvqi\n\tOiprbzxLKAZyFKHi6lQ68PUDf4KqZ36TOT7CB9Yz1yR+gT6Cc5sDyAX8+/1rQCrhYQfii0RiaVY\n\tkaF6d6fOz/jR6UPNfhC3RoFGgYO7+Ybn7H85NXQ/xSIzl8GAHZS3qekr6Ug==","X-Gm-Gg":"AeBDievMu1oi+g1L3FwdayuDmVsvNN0LKy43LEPgN8bWYcraLt1UslQeXlb1minkMet\n\tFvQGKK7GCqJGr0fMrZG5IQbZhAFt+v6rALh3B77k2qR4+FUflehVWE7a/QB/RSSkfvTMbUPYweu\n\tqyCrQx4hUTwnYWRbQX/E67W98F+hJOWZ9VIWxse63PccAbdwICVmKuEjgETmUnYsh/o2RV1ZCFt\n\tctRUIdJ8yIigz7m/EPbXN5d1bCPOF7BW7e1LKNeYoC0dBjv6zy+HHWQ59FcN+4ULk48BAv39JZD\n\tz6BtM4XEnr7g3so=","X-Received":"by 2002:a05:622a:4a12:b0:50e:6054:bc with SMTP id\n d75a77b69052e-51018978cfdmr67334971cf.16.1777479677836; Wed, 29 Apr 2026\n 09:21:17 -0700 (PDT)","Precedence":"bulk","X-Mailing-List":"linux-pci@vger.kernel.org","List-Id":"<linux-pci.vger.kernel.org>","List-Subscribe":"<mailto:linux-pci+subscribe@vger.kernel.org>","List-Unsubscribe":"<mailto:linux-pci+unsubscribe@vger.kernel.org>","MIME-Version":"1.0","References":"<20260428225146.3104063-1-gloveless@jqluv.com>\n <21ed8a45-f19f-4a14-9aed-dbe0f545ae27@amd.com>","In-Reply-To":"<21ed8a45-f19f-4a14-9aed-dbe0f545ae27@amd.com>","From":"Geramy Loveless <gloveless@jqluv.com>","Date":"Wed, 29 Apr 2026 09:21:07 -0700","X-Gm-Features":"AVHnY4L1rBkzBiYrQqjJpKoZhi9xkiCMvP-Rzsag5p0cpIY7J4jtOWb7m6L_ECc","Message-ID":"\n <CAGpo2meOiExOK=r9y7Jiio0XmJ2vDtE_4NkeCniQ873jEqynyw@mail.gmail.com>","Subject":"Re: [PATCH v3] PCI: release empty sibling bridge windows during\n window resize","To":"=?utf-8?q?Christian_K=C3=B6nig?= <christian.koenig@amd.com>","Cc":"=?utf-8?q?Ilpo_J=C3=A4rvinen?= <ilpo.jarvinen@linux.intel.com>,\n  Cristian Cocos <cristi@ieee.org>, linux-pci@vger.kernel.org,\n  Mario Limonciello <mario.limonciello@amd.com>","Content-Type":"text/plain; charset=\"UTF-8\"","Content-Transfer-Encoding":"quoted-printable"}}]