From nobody Sat Apr 11 03:54:33 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0E835C25B0E for ; Tue, 16 Aug 2022 19:40:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237301AbiHPTkj (ORCPT ); Tue, 16 Aug 2022 15:40:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51096 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236010AbiHPTkh (ORCPT ); Tue, 16 Aug 2022 15:40:37 -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 97A9786889 for ; Tue, 16 Aug 2022 12:40:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1660678835; 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=ejPyL03exSUyv1sSmQS6RpycXfqdQ91zc3yteXbW3HE=; b=hspEqSQTyteVxK5Q3z9K4sQnNtEi3pAao/DGO44tRJx1aS1KsPAhQZM9i0nhmof/8ckVch Hi7CywLm1iRxDmW2z9+d9l7G7GL9kBM7+Cid/6NP2CiVVDC3QNU0hO27wHHm0ayfLJ66jS fCACZK4phiPZ4A7Ej7Jduw8VJ7YunkA= 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-540-h7lRGLixPaON3uAu49SmIw-1; Tue, 16 Aug 2022 15:40:31 -0400 X-MC-Unique: h7lRGLixPaON3uAu49SmIw-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id DDD301C04B63; Tue, 16 Aug 2022 19:40:30 +0000 (UTC) Received: from [172.30.41.16] (unknown [10.22.18.188]) by smtp.corp.redhat.com (Postfix) with ESMTP id 86B4B1121314; Tue, 16 Aug 2022 19:40:30 +0000 (UTC) Subject: [RFC PATCH 2/3] PCI: Skip reassigning bridge resources if reducing BAR size From: Alex Williamson To: linux-pci@vger.kernel.org, bhelgaas@google.com Cc: =?utf-8?q?Christian_K=C3=B6nig?= , linux-kernel@vger.kernel.org Date: Tue, 16 Aug 2022 13:40:30 -0600 Message-ID: <166067880991.1885802.3339740933334886723.stgit@omen> In-Reply-To: <166067824399.1885802.12557332818208187324.stgit@omen> References: <166067824399.1885802.12557332818208187324.stgit@omen> User-Agent: StGit/1.5.dev2+g9ce680a52bd9 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org More work is probably necessary here, pci_reassign_bridge_resources() has heavy weight requirements that the aperture windows are unused, without even testing if the requested resize is possible in the existing aperture. One case we can clearly skip is when reducing the size of a BAR. Cc: Christian K=C3=B6nig Signed-off-by: Alex Williamson --- drivers/pci/setup-res.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/pci/setup-res.c b/drivers/pci/setup-res.c index 439ac5f5907a..7a8e1e4f4d33 100644 --- a/drivers/pci/setup-res.c +++ b/drivers/pci/setup-res.c @@ -450,7 +450,7 @@ int pci_resize_resource(struct pci_dev *dev, int resno,= int size) res->end =3D res->start + pci_rebar_size_to_bytes(size) - 1; =20 /* Check if the new config works by trying to assign everything. */ - if (dev->bus->self) { + if (size > old && dev->bus->self) { ret =3D pci_reassign_bridge_resources(dev->bus->self, res->flags); if (ret) goto error_resize;