From patchwork Tue Jul 16 19:32:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stewart Hildebrand X-Patchwork-Id: 1961263 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.a=rsa-sha256 header.s=selector1 header.b=2n6OCWqB; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=147.75.199.223; helo=ny.mirrors.kernel.org; envelope-from=linux-pci+bounces-10393-incoming=patchwork.ozlabs.org@vger.kernel.org; receiver=patchwork.ozlabs.org) Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org [147.75.199.223]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WNq555950z1ySl for ; Wed, 17 Jul 2024 05:34:17 +1000 (AEST) Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id DB9021C2277C for ; Tue, 16 Jul 2024 19:34:15 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E44681CD2C; Tue, 16 Jul 2024 19:34:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="2n6OCWqB" X-Original-To: linux-pci@vger.kernel.org Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam02on2061.outbound.protection.outlook.com [40.107.95.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4B34B1A01BF; Tue, 16 Jul 2024 19:34:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.95.61 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721158443; cv=fail; b=AaqDGTebjb2wR5QOpP6FB3ibwJK560AgPfeuLY2vV+aDF4+pyc4EoouaaosqhHHyGVLAqq5otYha/eqOy6kOZoLefP/D73AqpYxwYRqRN5gbzll3TTK+kjrmMq6d5u4ssg+SwVdbAVOU0yFjJsuXFRjKIKo0Oz6dwBywf7PAVL8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721158443; c=relaxed/simple; bh=Lol+t45pncGBscKOp8l89pe71lSJrpqq3ZpYdENqlP0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=XCa2rOp4vU27LA0z8BLjqC8kxlNKKo2EBRaLd4H68ZdbD+NYcRuUlQtpwxbJHuoqU7FxdyCDTJU2Nfp52m+GrBjz15Jgqbu3WgzKlPeRHsjy7BKoOwDbPh5ueKZVfDAhwVriKZHhPLVyiWZd+d27Ii/uwNq0nmQq1xdY5fUlOJ4= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=2n6OCWqB; arc=fail smtp.client-ip=40.107.95.61 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=VSS7QrnmLSn/bSOxqxsPSCfhCiRkbiTXkii02YS3KA9CcUXo2pmqrb4ZJ59ASkERJdaZRIXeGFNO0WH9FsZDE/X6qzrVWfxEqz5D6OdVfq1/E1iPGhbiNQ25u4KFx/1zYS5Lte8JOkX089y+lW3Kz5OvlNrsLRxUiQIUAyL2P9N0pE+M8qUhX1fCcQieF8NpVV+/E1MQAbAm4whf4RLW2PvvWEncg1mLFnxI/tt9GG4GkDdbtJaQRxRQCfkuWQtmEyjHpELlKx9HoeftOmmoD44qnxkD+kprt3q8RdE3dfqKrtAdwbhVKv0qgwV9CxCBolc6NG6obaUs9bRlMe5mqQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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; bh=wHZ8rE7ZuzLlPkM9bugQIILHFC2fzewUG1nE8V0cQa8=; b=MpqtXDMkxW2y0cqicvRubRhDwLbBupXv9S2zoBwr/VCdvj1fCyOibG8Ixy6uuf/mhr7EWJUUtMEaE0GlTpliRkzUQaZq7vHEcJzc+PUHcwBGKDFEu8PSmgHiH4RRFS7wuJrIN6TuIpPN6+0BKxXs9hiWzC9OP1CeamGPtHFXw54fIncWNEjeNVwUjsKfzApzqFnBBrqUDWxSN/dVuNLgyy1N7v5u/vdu7eKSRa/gf0h8V3hcQ6hpf2l6fVYXMdHo4X+bM8Z4O42E6HDF3QY2EVpX8h9tyVBNrRV96nzHkDtgZZrE2+tGST71hbsPaqsiI0j5QgE+IBMLpYDNCnZrpA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=google.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=wHZ8rE7ZuzLlPkM9bugQIILHFC2fzewUG1nE8V0cQa8=; b=2n6OCWqBVyTBYKOcwPAGL0qmSZpwTKH0xuNcSrr1i8KYXrTw6+WbUM/nsWEArQru2+xSknoGeA5fHquxixe8q9XHCVv5i9ffUXteBKEzdogVEd25u5WSyzwVxhiMbiIyFNvmV83+hTiP5/z6xw+a5RYWAPCjrHTsfJwsWclGRcw= Received: from BL0PR05CA0009.namprd05.prod.outlook.com (2603:10b6:208:91::19) by SJ2PR12MB7895.namprd12.prod.outlook.com (2603:10b6:a03:4c6::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7762.29; Tue, 16 Jul 2024 19:33:59 +0000 Received: from BL6PEPF0001AB53.namprd02.prod.outlook.com (2603:10b6:208:91:cafe::13) by BL0PR05CA0009.outlook.office365.com (2603:10b6:208:91::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7784.14 via Frontend Transport; Tue, 16 Jul 2024 19:33:58 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BL6PEPF0001AB53.mail.protection.outlook.com (10.167.241.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7784.11 via Frontend Transport; Tue, 16 Jul 2024 19:33:58 +0000 Received: from SATLEXMB06.amd.com (10.181.40.147) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Tue, 16 Jul 2024 14:33:58 -0500 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB06.amd.com (10.181.40.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Tue, 16 Jul 2024 14:33:57 -0500 Received: from ubuntu.mshome.net (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2507.39 via Frontend Transport; Tue, 16 Jul 2024 14:33:56 -0500 From: Stewart Hildebrand To: Bjorn Helgaas , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , =?utf-8?q?Ilpo_J=C3=A4rvinen?= CC: Stewart Hildebrand , , , Subject: [PATCH v2 1/8] x86/PCI: Move some logic to new function Date: Tue, 16 Jul 2024 15:32:31 -0400 Message-ID: <20240716193246.1909697-2-stewart.hildebrand@amd.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240716193246.1909697-1-stewart.hildebrand@amd.com> References: <20240716193246.1909697-1-stewart.hildebrand@amd.com> Precedence: bulk X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL6PEPF0001AB53:EE_|SJ2PR12MB7895:EE_ X-MS-Office365-Filtering-Correlation-Id: e1e5af91-334f-4aa6-9618-08dca5ce3d0f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|36860700013|1800799024|7416014|376014; X-Microsoft-Antispam-Message-Info: KeWIxDpZnLzKsYQSjkQYwIrQpcUI9UUkrY/pFINauygLzt6lnWwBPMU37BBAunSbb5KGpyoeH85NUrY/QVzR4GarQ7VljTZwdU8uwe4O2QL66I4iTFNUgw26/3kMQKKYsmG+AAOuvkqPnPMFCsE2LlfBq1sRtIO7+FW9fGqAe/e9+2DQD4AKCRJb+SX59Rs7kJeAcBrPi2znYL/2+xjo9UKjaqRKJ/BfgkxGxAco1f5SKnt0lvsWBCwaa8uz9Ar5Ltni/cFIjxbvuAevUJahDRrT9mXRIEqn0RInFnwcQk2ygS19zL5BWhTdA6kROg/v02kbukt1PNckWi0zy06dxpLnxflfVXqoK6lZ/pxiTUexlO4cVhehEJbEE77FE+0hcxAmDqd+MIWjyj2DRJrz1UlGv2d7Ptk3OXZGm/jjQzYeKpFzgjYFFiU/96cVh4cLZ7LtbmgNoquftJxQqIVZCDeHEnbfiOZKFFizqa3A0I15nxORyJjbOByT3qtor1I55LmwnLYfyRqQgF6jhHXngX1xgUW7bgC4do/7v1dJUz1y8h+vgh7SdLZpBR7hUKAePjw5Bvi2JfRroP2bMDFqiKRuCxFyWj/bxiYmprVD3XbaSvITrTPmSpR7jV1aEUVsriTJZZHzoh3iTOQayLUeJR9p4fht5cq+7FioAT+suENciPhgOShf8oyhx1AKJvr1iBBV3dDTaiJ680N4sdlFPF1yIc3q7IvyQO6YzQVRDQw6Lza3zAuhjtkbgHNFBSLaemhlyQkJZTHi3qkjkPUiUi61fenDLt6hB4KaphZmMf8SjmuTAcU90Lz36Lmtu6k2/b8k7oXbIJgAzAllfpBDfswXJ9waN6HO3qSoSk+Pknnuj4nmP/KXm8MparkmYjVCdsKx6pfAhR/CJdTlAKpOwTzakdvClbB9AVrL3F1lMT4KkX20TbNjuLrZYc34wMG9aMEmpzhuyEionSlWxcPHibj+JsB0RFG9ztTVnuG+Vpiin02mDGtmVtU0jlJtc9mRParL/gxNuZmfG/WA28pMbY92tXZvZreHecOrtuI3+kcOpD1BUj4rVHU+lpdhsza6jq4jlMQa28x1k2qX23DKWscb4BBqHD5YGIkpLruPddJpccKPu4hDf8oNZ5qLc90Zk9hBi5TgbTkhGuhyibCddkMC4O9JrGJznwcpaKrJSFc4KXmyLtex46ji2c2OIdPH28uyKgOKjUgWZoowbKSbzK2QYPn7wF9gQe5cQEuQXQ4mXI4qwbjgYre8ev/xN+292fMpnQak1K/hZ78FNCNhONleByHdma9chk/gwCLSyHaKYP6d3lo5r++/9icsgOMxQ8xA/vcHj6wsb2fzQ62kqpgZJ/NdHYXXtRrSMsR8zCsHCqr1UFBO9GoMC/EuNNgv55GjgZy+XFZy0OBl+RsoTAHxiRqqFDaf5b/+V8mFapogm4I3Y1KK5kwGMRYkFt07 X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(82310400026)(36860700013)(1800799024)(7416014)(376014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Jul 2024 19:33:58.5264 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e1e5af91-334f-4aa6-9618-08dca5ce3d0f X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BL6PEPF0001AB53.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR12MB7895 ... to reduce indentation level. Take the opportunity to remove redundant info from debug print string. Signed-off-by: Stewart Hildebrand --- v1->v2: * new patch --- arch/x86/pci/i386.c | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/arch/x86/pci/i386.c b/arch/x86/pci/i386.c index f2f4a5d50b27..3abd55902dbc 100644 --- a/arch/x86/pci/i386.c +++ b/arch/x86/pci/i386.c @@ -246,6 +246,25 @@ struct pci_check_idx_range { int end; }; +static void alloc_resource(struct pci_dev *dev, int idx, int pass) +{ + struct resource *r = &dev->resource[idx]; + + dev_dbg(&dev->dev, "BAR %d: reserving %pr (p=%d)\n", idx, r, pass); + + if (pci_claim_resource(dev, idx) < 0) { + if (r->flags & IORESOURCE_PCI_FIXED) { + dev_info(&dev->dev, "BAR %d %pR is immovable\n", + idx, r); + } else { + /* We'll assign a new address later */ + pcibios_save_fw_addr(dev, idx, r->start); + r->end -= r->start; + r->start = 0; + } + } +} + static void pcibios_allocate_dev_resources(struct pci_dev *dev, int pass) { int idx, disabled, i; @@ -271,23 +290,8 @@ static void pcibios_allocate_dev_resources(struct pci_dev *dev, int pass) disabled = !(command & PCI_COMMAND_IO); else disabled = !(command & PCI_COMMAND_MEMORY); - if (pass == disabled) { - dev_dbg(&dev->dev, - "BAR %d: reserving %pr (d=%d, p=%d)\n", - idx, r, disabled, pass); - if (pci_claim_resource(dev, idx) < 0) { - if (r->flags & IORESOURCE_PCI_FIXED) { - dev_info(&dev->dev, "BAR %d %pR is immovable\n", - idx, r); - } else { - /* We'll assign a new address later */ - pcibios_save_fw_addr(dev, - idx, r->start); - r->end -= r->start; - r->start = 0; - } - } - } + if (pass == disabled) + alloc_resource(dev, idx, pass); } if (!pass) { r = &dev->resource[PCI_ROM_RESOURCE]; From patchwork Tue Jul 16 19:32:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stewart Hildebrand X-Patchwork-Id: 1961264 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.a=rsa-sha256 header.s=selector1 header.b=aOhpZR9R; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=2604:1380:4601:e00::3; helo=am.mirrors.kernel.org; envelope-from=linux-pci+bounces-10394-incoming=patchwork.ozlabs.org@vger.kernel.org; receiver=patchwork.ozlabs.org) Received: from am.mirrors.kernel.org (am.mirrors.kernel.org [IPv6:2604:1380:4601:e00::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WNq5f2KTXz1ySl for ; Wed, 17 Jul 2024 05:34:46 +1000 (AEST) Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 141941F259B7 for ; Tue, 16 Jul 2024 19:34:44 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AA4D21A00DF; Tue, 16 Jul 2024 19:34:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="aOhpZR9R" X-Original-To: linux-pci@vger.kernel.org Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2046.outbound.protection.outlook.com [40.107.220.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 135421A08DD; Tue, 16 Jul 2024 19:34:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.220.46 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721158452; cv=fail; b=OUObYwfdPadZGBiC80wUefVvSWK3w91r6XDuo9zPR2FW1PA7tTXwM3U2bTznxYC89A46HwBkfKJ4Uy69vy8B8ngFNomEHuz5OGVRcNUpXE/h0IrUdwCYoa0M0f/oZRCv5h8QlSWNr4n7mLVU5DR7eFQcih5S70gCg1qQSStPCoo= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721158452; c=relaxed/simple; bh=jBxqkgUUg3CLWL/ZnH438VPSunk47YkCwi7mNQLsJOg=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=qx0iQ89kbSg+8h3nnBcIQhGncuzc9Xdx3/HHkfeJ/vvTu5qXuO3H0MMdClLMGjxYGzdGZI4LSvSTrEGlpgf2mIOGwyFh2MbIcYzctJQv/KKbg7hJlB+vc1oZIZi8AiVO0DEju5HSDmCA0sytxLFiJ0MoUPF6u4jZlUahzQ+e9Vs= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=aOhpZR9R; arc=fail smtp.client-ip=40.107.220.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Q9gqcHRueyJZ4qMMrVnEjGORPUPbyYjsKDjWUE/1t3tnyGiCs5GL3v2mlWJY0j9qXiS4XXQZjrEBK2AHywQE5JsoVrgbIaJIJLwvJ4BugIJ8uQ4CSORQPEzFA4RpyduwaGSulHt8RF/DfWaWwub4VCnnz17gwblMXhrhGBMcMNYyw6h5A62b3FtziMoX88cztO4msA/ALihRrK38sbYcDhaWbMdu95PmoJfNTQoz9ER0ObGyfxQFLmupAmQn+pzGW/XrRdj0ekOva16/Qa8vjB8uKGrMag5INBkGixLC378v/XzJrgaTzGZcUtg7FY/RgiwmHsyNfZDepxOO5n3oxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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; bh=BV6AgoX+2VJnMijFVErsOVX4oZTzkgip+oxsSrgRtlA=; b=NpnEucP802FohzH9QFgD7SvGHITtJzBtrdp7c/lqfgmZXriHNByA0ffN/wTvnZ/2zuKvweBkeHQhOwZFkL/NgPjYHOW0eJ0E7YwE8L1ZjWu7qSBYE95MohjE7teyuvXMoAT6CUhqKDH4npxJFVA8reGroGWXiFfsjUrEYW8cVwFT4iX9V0n9TR1QOT4A7gE7gfKj5pWnivYuMscG1bzgPccQYw0epQg72Z6auy8VKJSo9jAUjC2dOecEl6tn+s+E7R4d6z+VH1QL0InxDtvubxV6Rh2a7CbNPkBAXCe8JolYgtt2rsltrGHWoGW//PMre0eiemmZItjGJCxrwWRHbw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=google.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=BV6AgoX+2VJnMijFVErsOVX4oZTzkgip+oxsSrgRtlA=; b=aOhpZR9R5gs1CzzMWZwLbSnmsLftahvvVzyTroyWDTIMwkUj7R3M+wD4wSnBUHF8EPzPMvvQHqp9I9/mfWK4tMKTjSycFVpQf5hKIWI37NgDDc+NXTGIg0gtrdq11CL4024zHaYXJRAWLuj+9bPm/9aZTqGMQuY/ZmUmJX8cXlU= Received: from PH7P221CA0081.NAMP221.PROD.OUTLOOK.COM (2603:10b6:510:328::33) by CYXPR12MB9441.namprd12.prod.outlook.com (2603:10b6:930:dc::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7762.29; Tue, 16 Jul 2024 19:34:07 +0000 Received: from CY4PEPF0000EDD6.namprd03.prod.outlook.com (2603:10b6:510:328:cafe::9d) by PH7P221CA0081.outlook.office365.com (2603:10b6:510:328::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7762.28 via Frontend Transport; Tue, 16 Jul 2024 19:34:07 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB03.amd.com; pr=C Received: from SATLEXMB03.amd.com (165.204.84.17) by CY4PEPF0000EDD6.mail.protection.outlook.com (10.167.241.202) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7784.11 via Frontend Transport; Tue, 16 Jul 2024 19:34:06 +0000 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Tue, 16 Jul 2024 14:34:06 -0500 Received: from ubuntu.mshome.net (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2507.39 via Frontend Transport; Tue, 16 Jul 2024 14:34:05 -0500 From: Stewart Hildebrand To: Bjorn Helgaas CC: Stewart Hildebrand , , Subject: [PATCH v2 2/8] PCI: Don't unnecessarily disable memory decoding Date: Tue, 16 Jul 2024 15:32:32 -0400 Message-ID: <20240716193246.1909697-3-stewart.hildebrand@amd.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240716193246.1909697-1-stewart.hildebrand@amd.com> References: <20240716193246.1909697-1-stewart.hildebrand@amd.com> Precedence: bulk X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Received-SPF: None (SATLEXMB03.amd.com: stewart.hildebrand@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EDD6:EE_|CYXPR12MB9441:EE_ X-MS-Office365-Filtering-Correlation-Id: 3b0df364-e446-4037-cff2-08dca5ce41ff X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|36860700013|82310400026|376014; X-Microsoft-Antispam-Message-Info: OeihamMmB9YvLqw6Ljgk2lX6GA0jxbbYMP+qnHXxvwEbPPZwxDaDIXpzyRNJtrIGLMWGWp4CLxIqoUvfjRxk+pUdLWLpD8FZ9yYtZoSzrP2aygrber1GyiAbK0GBtHh2S0lmSRVyqe3Lkbp4AS8eHqXxwLd0gjNGhHmHI6+bU74Ydud5Haz6gCzgXrL6kYWz/ELt4OV9HJ+xcgEfucqCW1wxCni+Uhf3zpK0i1LW1V+i2dJ2YvRmlCpb+BMVpqKexAs2FxgZaab64WkIMHjnS/lBku3z1iDLNdm0Jo/9nr5yR/DikbhX71CsvNANaei+yWQuXv8qLkvvTRhRaxNUsTCQ4oLOJ2cqcg13eslg4HLYhARmHM7ygfg9fshKzT5JaH/6i3aOhEynT/q3VCGyxjxHFi6mbDrezv0FvwuAdHsFxIMBG0XkWz0agJ4GNV/cvyv0Q/rXfoN4nWUDHsdZxDtvAa71+riWkzcXy2BzbLJrjahvlFjyHUukBdLYeqToHYyweFv/LppVvJqnMY9kFVxjeoLmezJnNR2U3mU3AlEZtR+ljqNd2xJuua+YNEPmt8S19mCM7mNRT01f5hxYNHyzCyoaJTMBiYTIANN3P3KQAWyishOWE61OgMHpGeTE+FL/DrF7kyjJXI8oBWiDZUyhakKgmr/R/EuLb1//cYLmg/VN1q7q6HklLih4kx0tM26tH38CJEY5XWIUSqzoxmTwUr6R3oqtL5cH0oSZNHabjQEp7oh5bcouTdRwLyN8PdIIpj73jje3j/m2Hm4akSgv8tQUbaPQKqYPbPwM/qZgobXAjn0Ei6K2pbBtAQjjCsWbRQmcQkk4zakaqS54843/zjaBu2D4W48F4Yd5A9E7Qhzn7QBwYygFRTUBo3WAkNRKmxBoy6hremKkdEoBULYPJ3MAaYhhQLEtM2SvqACLO2NYNwlL460P9gze163eBCROkBZIafkMetPIRNhNXjKuQf8ArK4W0Yj+n1H+BQMDYElk723cEeFCwRkXvMlxN2RBpbRR6wGEc+0FcG+ojQDhyL0zJRLhX5SbxrakwrZkCOhqsllYVZvG/HHVbsscXZfQdP4RCZ2Tpvykw3mnVPBErAUo2TwY8iCJZNOzSEGZIyA4wardELK+y3ip6BfZd0Vsv4QE5ir1MAF60E7HU0RNUOe1ey9aoBHBWvOostGUr3VIjQhR7BUjsG7Z6Q3VqlkIdyx6WFfsDHjI9zhGlHpqu1Qt32/pKrf5ZOof6TKtElG8TlkHo3BYKzfBV4QVDBo+z1Sh6pT6SF+NlGxNbyG0X04axmkIzTVuS/KejBUlS0GtgebV1+W+dOM/dCxgBjhlgfJ2mEmECFUizqCds1zH4LiEJquVAeivOaVYTbBNCNIqGQ3eAl0ADffag91tl4Yz3nGoohVEFqkP5L/dyFHgYuxdRYlo1uhkDM1Xh3bq+N3qREOKMnJiWa2pb9Ke X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB03.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(36860700013)(82310400026)(376014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Jul 2024 19:34:06.7647 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3b0df364-e446-4037-cff2-08dca5ce41ff X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000EDD6.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CYXPR12MB9441 If alignment is requested for a device and all the BARs are already sufficiently aligned, there is no need to disable memory decoding for the device. Add a check for this scenario to save a PCI config space access. Also, there is no need to disable memory decoding if already disabled, since the bit in question (PCI_COMMAND_MEMORY) is a RW bit. Make the write conditional to save a PCI config space access. Signed-off-by: Stewart Hildebrand --- v1->v2: * new subject (was: "PCI: don't clear already cleared bit") * don't disable memory decoding if alignment is not needed --- drivers/pci/pci.c | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 02b1d81b1419..53345dc596b5 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -6565,7 +6565,7 @@ static resource_size_t pci_specified_resource_alignment(struct pci_dev *dev, return align; } -static void pci_request_resource_alignment(struct pci_dev *dev, int bar, +static bool pci_request_resource_alignment(struct pci_dev *dev, int bar, resource_size_t align, bool resize) { struct resource *r = &dev->resource[bar]; @@ -6573,17 +6573,17 @@ static void pci_request_resource_alignment(struct pci_dev *dev, int bar, resource_size_t size; if (!(r->flags & IORESOURCE_MEM)) - return; + return false; if (r->flags & IORESOURCE_PCI_FIXED) { pci_info(dev, "%s %pR: ignoring requested alignment %#llx\n", r_name, r, (unsigned long long)align); - return; + return false; } size = resource_size(r); if (size >= align) - return; + return false; /* * Increase the alignment of the resource. There are two ways we @@ -6626,6 +6626,8 @@ static void pci_request_resource_alignment(struct pci_dev *dev, int bar, r->end = r->start + size - 1; } r->flags |= IORESOURCE_UNSET; + + return true; } /* @@ -6641,7 +6643,7 @@ void pci_reassigndev_resource_alignment(struct pci_dev *dev) struct resource *r; resource_size_t align; u16 command; - bool resize = false; + bool resize = false, align_needed = false; /* * VF BARs are read-only zero according to SR-IOV spec r1.1, sec @@ -6663,12 +6665,21 @@ void pci_reassigndev_resource_alignment(struct pci_dev *dev) return; } - pci_read_config_word(dev, PCI_COMMAND, &command); - command &= ~PCI_COMMAND_MEMORY; - pci_write_config_word(dev, PCI_COMMAND, command); + for (i = 0; i <= PCI_ROM_RESOURCE; i++) { + bool ret; - for (i = 0; i <= PCI_ROM_RESOURCE; i++) - pci_request_resource_alignment(dev, i, align, resize); + ret = pci_request_resource_alignment(dev, i, align, resize); + align_needed = align_needed || ret; + } + + if (!align_needed) + return; + + pci_read_config_word(dev, PCI_COMMAND, &command); + if (command & PCI_COMMAND_MEMORY) { + command &= ~PCI_COMMAND_MEMORY; + pci_write_config_word(dev, PCI_COMMAND, command); + } /* * Need to disable bridge's resource window, From patchwork Tue Jul 16 19:32:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stewart Hildebrand X-Patchwork-Id: 1961265 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.a=rsa-sha256 header.s=selector1 header.b=DQ0Vd+wA; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=139.178.88.99; helo=sv.mirrors.kernel.org; envelope-from=linux-pci+bounces-10395-incoming=patchwork.ozlabs.org@vger.kernel.org; receiver=patchwork.ozlabs.org) Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org [139.178.88.99]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WNq5v3m08z1ySl for ; Wed, 17 Jul 2024 05:34:59 +1000 (AEST) Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 44C8728294A for ; Tue, 16 Jul 2024 19:34:58 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9134E1A08DD; Tue, 16 Jul 2024 19:34:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="DQ0Vd+wA" X-Original-To: linux-pci@vger.kernel.org Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2075.outbound.protection.outlook.com [40.107.236.75]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EA1E81A072C; Tue, 16 Jul 2024 19:34:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.236.75 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721158458; cv=fail; b=OySajUf19S5YYq/JiiGbF9VqRSgQYBTH2oDwWHRHA3h+Ct39sPPg5wIYQPsQrTA5Fz6H35avwJNkTunUFMv+opDFIv9nRQu9u/04AbIuUsno/LZs+1bH7W5zt0x3fQ8QRA2HMaIiMI7W5PY1GAB0TUMrxhQEe2JlfdsVj1LFaYQ= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721158458; c=relaxed/simple; bh=vnwBRNu51G4ZH9fQPGBsCKxVaJEG4DR3nZUJcUMYD5M=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Drfs13tcj0onFbaXDSEfWnw4zxFVGO6EQtxr0F+71iL0WhhMNfRXJ8I5MiWKiui4qo/KOfNa7hqRHSp6M8gdRNUOnRPqinEZcVjYehVmlIVNqWbwY/pL1UtBCt1cuutKzeYeOcA0zmdgYmiad/lci/TSIxFJ1vIC4+eWN9fUaBc= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=DQ0Vd+wA; arc=fail smtp.client-ip=40.107.236.75 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=QblhzM4nEive1jNQhqf+yPXrxkHHL5CQpElcmP1zLUmMchASRjs/rk8CN/y36XA4AtZ4sGs2XWF0bSKrJx4nKuOK+f8HY1t+I1PwdHOoBq3qq/EkFkwM3S9yCjPO9rn1NZu6lSET5Dkjnxmb6ftUXa+clljQTkOqMO6gfygs/qfZ7A22Q2KkY91cJS/4zgvn5mfBnmYVQwlB4/0MRj1p6aPxBI6N1roXlgc5b6ferfA3bV9h/0jKFUSDTLMZa0QdQelAz70Mq5r8sB93+a0C/0apHlgvYfSUV/5B6MezdmBU2c0XUhLt7O7CL1BJX+9612SyBou3Ica32DZPjuzf/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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; bh=Ny4IGFDg/oYclmZPql5mbl9efU5aukGNFw244Tc7Ej0=; b=O37TZfWSo2NKxDGqNGJGOv3zQp1WQXxv+q56g3pAGACtTbPAZDmJmheCGYVr+O26ry6/oM2rC/YL5RcmAWqA/FdthuMVE2j6IIx3WX0F//ZkeaRrq14cu6YTeUh1/e1ZPmJQOs0i6XBLT9DO+Bw75PlEwtoYu7zD/bNv3euyviFj98NqUSJNCE4JswuosuDFXLc5Q6hbzGFGqsFChmX3vuTCSbZOsHVlRqRkFZM98fqNbce1BEtwUK9x5JCOdnL+SSK4Qt/dDfZWWz6t+PjJaJ9iiH0Zr6JCrs1WUAYBPIsn5IeZulXJe4+SksjJ02YKYdd/C+Wht9nXmkoKchygvg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=google.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Ny4IGFDg/oYclmZPql5mbl9efU5aukGNFw244Tc7Ej0=; b=DQ0Vd+wAN883GidQ+y46+bIv/GMjnO9s5P5Q4VYOnel9ITN7VXdRNIFwubQ/jhv2Aryy+HuZVggC1xhWV2ck/5747Fh855svoPvpRrrRZf/VN1kItum40McITSBPazjj0g8Dk//jxCj10SXGqUcpd4Exmrft697MUR5Q03M5t1U= Received: from BLAPR05CA0003.namprd05.prod.outlook.com (2603:10b6:208:36e::10) by DS0PR12MB7655.namprd12.prod.outlook.com (2603:10b6:8:11e::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7762.29; Tue, 16 Jul 2024 19:34:14 +0000 Received: from BL6PEPF0001AB58.namprd02.prod.outlook.com (2603:10b6:208:36e:cafe::83) by BLAPR05CA0003.outlook.office365.com (2603:10b6:208:36e::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7784.15 via Frontend Transport; Tue, 16 Jul 2024 19:34:14 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BL6PEPF0001AB58.mail.protection.outlook.com (10.167.241.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7784.11 via Frontend Transport; Tue, 16 Jul 2024 19:34:13 +0000 Received: from SATLEXMB05.amd.com (10.181.40.146) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Tue, 16 Jul 2024 14:34:13 -0500 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB05.amd.com (10.181.40.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Tue, 16 Jul 2024 14:34:13 -0500 Received: from ubuntu.mshome.net (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2507.39 via Frontend Transport; Tue, 16 Jul 2024 14:34:12 -0500 From: Stewart Hildebrand To: Bjorn Helgaas CC: Stewart Hildebrand , , Subject: [PATCH v2 3/8] PCI: Restore resource alignment Date: Tue, 16 Jul 2024 15:32:33 -0400 Message-ID: <20240716193246.1909697-4-stewart.hildebrand@amd.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240716193246.1909697-1-stewart.hildebrand@amd.com> References: <20240716193246.1909697-1-stewart.hildebrand@amd.com> Precedence: bulk X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Received-SPF: None (SATLEXMB05.amd.com: stewart.hildebrand@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL6PEPF0001AB58:EE_|DS0PR12MB7655:EE_ X-MS-Office365-Filtering-Correlation-Id: 6629c9e6-e5a5-4d14-b53f-08dca5ce4647 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|82310400026|36860700013|1800799024; X-Microsoft-Antispam-Message-Info: hosNwZlmrtObrwucpjQ9S+Hq4NkmZpeERe30cHiWVLkK1MfmbskKhJW2Zy6QKUeNrxhs0beIJfCwlJ7fx9CnCorsPam3TIXW6XgxZ8M23VZjjmW+o1xz9eNKKlSS9pJJ6dd2FPtzx2JpAwsCUgJS1ML9OtRp5D4q7ltA0WA3lAQZOY/gp3OHywD2U8SogY2oa4qVXWi/r3o/CHQqAUqKND0og/lTcwRpDiDzT1Ogx1grkZY8SugDXozz8llt9kXHGEMTU+8InSGEIkKf4kGMw9aOVzBbAlgSe1E9r2F2ZiBB6NJ+4SypQekSgvYFyxKxhBHJo+iQYp78MYMzJdfp1+V9Py2plzy8JwdwPKNARMlJm4329esGuc7jFmZSqYUDYr29T8O9AYXZj0lolY/vyGqeAgrgNDCn2og58I3BCZK8Yr+kLOvufwT7TBbiQS5C5JogprHPJ//gHLcQqrRX40ainLVcN9iDJZ1K4qT+jzXpEWUYzKuH1L8lY/9QbuABiO7AHMpuheq0tQSfTM1K99sRvswfoNg+cBjPmdpiZ+vuu9L2QHuslSJ9+SYRAdKK/E/yQWU8SesQmGo6uqRxkf8Q7QpS/8GBACIFI9xszP7VB5fmxvZt3i5SWwiIWYbXLJoZCl8J+4ubvtZFkF3CujlqYiZ8lIhHFalboMHbzhvcX1EeWaM2Clfd02/JZ4sA3ljilhqp4iob/sDzcaM/g3mQoyiLNFUUNucENDWraU3uxaADI2cb1iiDPcSsiV7zNc60LwGZhwsIBpXCkU1+ukPxERHbafwEtIkzlJXOIzvn4b+DOTKkG5XbJ965jAvpAWdnt2T5I4QP7Foigeblc9+bbPgGIkKrcCLso1EgxJSYYTQDokIcsA6bweeK8XOTUkOfQDfSRISs1CawQoQiLTk7OmcHiSCdeN1w+EH27hqADHHmO1dr196ZgDWkEC2QVOw5IK3qak7yrPo0wiw2bG4g4E0Ru2trY+wR2W5cnkvU3biEQdNhT6q2WZgKdnITlGzfApjxblFw/4NqslMbdiM8CHflEc7+sPjwbOb5Sz6sQ/CxHKcct5MMp2GadGK75TXdbvVbUnjq3Q+AT2GyBmErXL2B/C8lRHD/08rdL7MEEBDMBpJNzuF13faIFPAJy2zhuyRAfaiZeNpl2CTC6YYe2RFMPwZ2XORaTbJThPMTFslVvjgNgWzC5UJriWtz6kkx8/OE7FFwGm0oPYj37YtYIgPnuOvgMR46pwDaps6o7SwcSqDHhLEknk2zfjsE46l9u0tT4sF/5K1xa4/f5000DZ2Lc07v8wP5DA+3nEt8rCXivF/pE+UD1tSw9OUmK3YTz/eD6H8SroayZO0z88U+HR0GKdixuP1Clj3LWcBd0Mgnps5bX264bZcZubaYge8jAKVOFebh8toYlUAVH6d8XYIrT+FgClNLJ4T/Xo3eiueXNv41cIGXDOkuQRKw X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(376014)(82310400026)(36860700013)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Jul 2024 19:34:13.9624 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6629c9e6-e5a5-4d14-b53f-08dca5ce4647 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BL6PEPF0001AB58.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB7655 Devices with alignment specified will lose their alignment in cases when the bridge resources have been released, e.g. due to insufficient bridge window size. Restore the alignment. Signed-off-by: Stewart Hildebrand --- v1->v2: * capitalize subject text --- drivers/pci/setup-bus.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c index 23082bc0ca37..ab7510ce6917 100644 --- a/drivers/pci/setup-bus.c +++ b/drivers/pci/setup-bus.c @@ -1594,6 +1594,23 @@ static void __pci_bridge_assign_resources(const struct pci_dev *bridge, } } +static void restore_child_resource_alignment(struct pci_bus *bus) +{ + struct pci_dev *dev; + + list_for_each_entry(dev, &bus->devices, bus_list) { + struct pci_bus *b; + + pci_reassigndev_resource_alignment(dev); + + b = dev->subordinate; + if (!b) + continue; + + restore_child_resource_alignment(b); + } +} + #define PCI_RES_TYPE_MASK \ (IORESOURCE_IO | IORESOURCE_MEM | IORESOURCE_PREFETCH |\ IORESOURCE_MEM_64) @@ -1648,6 +1665,8 @@ static void pci_bridge_release_resources(struct pci_bus *bus, r->start = 0; r->flags = 0; + restore_child_resource_alignment(bus); + /* Avoiding touch the one without PREF */ if (type & IORESOURCE_PREFETCH) type = IORESOURCE_PREFETCH; From patchwork Tue Jul 16 19:32:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stewart Hildebrand X-Patchwork-Id: 1961266 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.a=rsa-sha256 header.s=selector1 header.b=QvrKWOlq; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=2604:1380:45e3:2400::1; helo=sv.mirrors.kernel.org; envelope-from=linux-pci+bounces-10396-incoming=patchwork.ozlabs.org@vger.kernel.org; receiver=patchwork.ozlabs.org) Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org [IPv6:2604:1380:45e3:2400::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WNq6B5d61z1xrQ for ; Wed, 17 Jul 2024 05:35:14 +1000 (AEST) Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 38EB42831BE for ; Tue, 16 Jul 2024 19:35:13 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B3AE619DFA6; Tue, 16 Jul 2024 19:34:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="QvrKWOlq" X-Original-To: linux-pci@vger.kernel.org Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam04on2079.outbound.protection.outlook.com [40.107.101.79]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0B74419E7F7; Tue, 16 Jul 2024 19:34:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.101.79 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721158468; cv=fail; b=Z56ce9cCwrvPgecyUNaE7yQRc0rStGHxyRJPPoIET9I3Nu9vw/MkenTNwHhCRy+8QlPN9kWqn+3bpj3Au9ePce3TVYWBwCempwDGSbNymZZOnGgaY2P+1RTrFUAcji386msVsjtx8JzhROJEoQtBGYMHl4HYT0mbWOM3S0iSpsY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721158468; c=relaxed/simple; bh=6rwqamannBU5g9+R4FnW3gQzG+TV0cLcY9Ynb1AeUTM=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=UNZUtyCahp1yyKJ/nklw+FExAM5VVmHvoNGaMlO2VJ7EcOGI4KOOHPL0QPsb+jKY1RPvHOcW2TEjy6WSWSOtlCjJE/wEENyX62iFcvGGwefy7VOrW18nsqFUSAGnCccqoB/vGCJO/vIXObTRnBGa7N9/aa7vvF0vK09SdlBb4Cg= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=QvrKWOlq; arc=fail smtp.client-ip=40.107.101.79 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=bzZsMWQ2pmZRg4QCDkQBBOyRP777YiY3c6sjIv9WZC6kNpbvxpI97c3/7JCPk2TV9A+Mbjko9UZpWKANE+CbFjejMWd89qVVpbg3Pe+rZ7VjUiN0fjy3b+7Iu2/l2WXM/RAJSWPNtLXAcJgwIY7bCRvbVeDZ1DJb+dUJcGfVjrObSOiB4g+MO31+p6LPdxU9McbKdObw1po0gFYApNvYbgwfjba0/CtxQv/ciIuOp47pI+IzcthmpH4wEsAI2hlWLxspe0JvXQItGB9yK8Cza4gZElN6yPuSerV/tp94+TxIbDZMdsAZnf4qDg9Umj5cBR1pjhbllRj/uiMD7f2dSw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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; bh=F58jKxowfvxFVDum2puPgnHssvMZbphujfInpzZHMnk=; b=q3J4fvDpya9GYsiigCPJp6QN4vX08h/gQc0ftY5UfLK99bWEEVRqf6DQ/wco0JHgpyiNFzcLB1vIRVQE3YxcQfdeqQLd9FYvFPcLKzMNf7iWXb6Rj6GqVCLiFQKnzR4yFM+1BJhllncmbQp4vaqCoWdDciTy4OeeLJgECUsaw+QQ0tr8So5VScLnuuZdIl7G33kVIrYFZnw872sxYHkWc6JHBCp9jxFCIOBIdkqfvVQFYr4mJFvhbibtbwTNhXYVtKoXPq3bHbLvtAFfZVlOfuUjDIlC6DsAqJxVuAlwB6pCREJCf3CHoS69KzUtOUJncDJiQIvfMQ/A+uEyVNZk+Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=google.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=F58jKxowfvxFVDum2puPgnHssvMZbphujfInpzZHMnk=; b=QvrKWOlqQFbumi+amlpbS06Nfx8UbQaAWDxk6BgfCbf4gSKfk4N5qXFMkYxaTdnyUoiFgr3H8w9N7OTLsg/XYm/5W8KQXDzss5zLwFVpckQjaKnKeWw5bj+oHv7y2dXkBlhE35JUxBFHpRMZvkL363/d1XmWcRjApU4o6vISBZE= Received: from PH7P220CA0115.NAMP220.PROD.OUTLOOK.COM (2603:10b6:510:32d::32) by SA3PR12MB8045.namprd12.prod.outlook.com (2603:10b6:806:31d::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7762.29; Tue, 16 Jul 2024 19:34:24 +0000 Received: from CY4PEPF0000EDD2.namprd03.prod.outlook.com (2603:10b6:510:32d:cafe::b6) by PH7P220CA0115.outlook.office365.com (2603:10b6:510:32d::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7762.29 via Frontend Transport; Tue, 16 Jul 2024 19:34:24 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB03.amd.com; pr=C Received: from SATLEXMB03.amd.com (165.204.84.17) by CY4PEPF0000EDD2.mail.protection.outlook.com (10.167.241.198) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7784.11 via Frontend Transport; Tue, 16 Jul 2024 19:34:24 +0000 Received: from SATLEXMB05.amd.com (10.181.40.146) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Tue, 16 Jul 2024 14:34:22 -0500 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB05.amd.com (10.181.40.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Tue, 16 Jul 2024 14:34:22 -0500 Received: from ubuntu.mshome.net (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2507.39 via Frontend Transport; Tue, 16 Jul 2024 14:34:21 -0500 From: Stewart Hildebrand To: Bjorn Helgaas CC: Stewart Hildebrand , , Subject: [PATCH v2 4/8] PCI: Restore memory decoding after reallocation Date: Tue, 16 Jul 2024 15:32:34 -0400 Message-ID: <20240716193246.1909697-5-stewart.hildebrand@amd.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240716193246.1909697-1-stewart.hildebrand@amd.com> References: <20240716193246.1909697-1-stewart.hildebrand@amd.com> Precedence: bulk X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Received-SPF: None (SATLEXMB05.amd.com: stewart.hildebrand@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EDD2:EE_|SA3PR12MB8045:EE_ X-MS-Office365-Filtering-Correlation-Id: 430d85f6-2e81-4a03-28cf-08dca5ce4c71 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|82310400026|36860700013|1800799024; X-Microsoft-Antispam-Message-Info: C7+S+MwHzDGRJF4GdPT7jVaB7OfLiOO/2pO72ddhwUBrR2QWa4c5KJt1xAUzTLIvI2dEBjajkuR3XsDhBfddunkbia3b5UaxMKlNxtlfiQ+s0NpOp/w5S2onjy3YlySJsDtXQc/bHt/vZQXdcNscc2M/2VR0L3GKleuD0d0LowkWqACPXzQpKklPAoGstL7jHUIP1Xtwpm5T7qG04ahrxZa1f/zZSWJoGMTkVWqjMy897Y/dQuBBuJwcbk8KqTI4Q4jQjIvAGX4LL367EEqQTR+nAkR8h3st74vQvnLpPD2LQEo3o2Qaag3uTEm8kPkc5on2sVWm4bTTc2qtgKxJYd5F0puoBoZP6vN1dP9n1JwlWMfueqM46+EDRMu99qmKYMuVFSu8L9kKyDrafVjLnYIM99UC1cdhudARkfEXxuuVqSafyjwrLghzZtocVSv2EdolKKwcWLL3UfSlUmnrzS1Ae3iA6Uf7x7t0iTVwJBiQadQ9hpRQyx6/dBaoJNv9XnvMNGIJ8x93PEk0TLSIUjSokShccPMGrq3E2ly2qbs+nwT50MkI7Ml3LzH9zLauLwvugLKbQnBBV0LH/fF/oHB6+CdksFszhbk1UDD0wtNCvWgxLhDPWDxgVTLOVdu11byiRm84A96DsM4HA6YL62tEBgC+s6YSaxGGpKLQsax4tinMNQGiJoDQjZxmE/ARKjpED++skh7sFRtpfSPpZ3nrtfuA3j299B/pC/u6fR2MNxKnx7RBSnEYvR1M0Nc852qstrNBNVHPZThLd/Q6WGEwUYlcOlA6rXkHkETcuUlfH7nZY0xgpKnSWFgBN0m1CxZwunXReyFSA/Gp6rE8GHSCHiPTs9a7HeJshJiF0JUjKPvO43jdl2VJbN5QJ+RTfC9SHiz3V+9SO5FZvLlZmg4DIBvXj/JWP/ZfRwutOgAhGee6lDebqfDJVfAtHTKWeYXqg/Nc0cxTnr7y0s0CLZUEzYbn0gN0rR5XazolNUNrUnE1VdF25lwFaxsuZw3qiyCrngyGO/i1FwTf+pAyNvU7Gnjhs2TOSeQhp3WT7U+lBEHmWTwHwYOZ4EzFYi4z5RZP4I3c0Ye+JvRPW7KFLKCRj3bS4oMhHnHARYY/fsmb35v2aQzqyK/G3sX04jofF1T3uNivW0h7PAM2g5jly4njBYhZAP+jsIfDdWO49Hvjo/i4U4PltFlnkqcViT1E3QtKJbb1mrUBXFCDtmRQEsmF4dMn68PuAlZNeoriUjJqW6b1a8tF/KmpsD5KS3o7E1liTE3+hsxYSfBqhlG0jxeGA3z7noLtz3kQc1VsirYE0YaiTbosNvhAxbXJQD/0r9DZuTWj2erUng4LgPv/iNZJGaxytkyCoRaBWaWgxwdOuzgO3HXg8qkZk1ftVtL9CTLYg8U9RfhtZDQ/X6nqsg== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB03.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(376014)(82310400026)(36860700013)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Jul 2024 19:34:24.2848 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 430d85f6-2e81-4a03-28cf-08dca5ce4c71 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000EDD2.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA3PR12MB8045 Currently, the PCI subsystem unconditionally clears the memory decoding bit of devices with resource alignment specified. While drivers should call pci_enable_device() to enable memory decoding, some platforms have devices that expect memory decoding to be enabled even when no driver is bound to the device. It is assumed firmware enables memory decoding in these cases. For example, the vgacon driver uses the 0xb8000 buffer to display a console without any PCI involvement, yet, on some platforms, memory decoding must be enabled on the PCI VGA device in order for the console to be displayed properly. Restore the memory decoding bit after the resource has been reallocated. Signed-off-by: Stewart Hildebrand --- v1->v2: * capitalize subject text * reword commit message Testing notes / how to check if your platform needs memory decoding enabled in order to use vgacon: 1. Boot your system with a monitor attached, without any driver bound to your PCI VGA device. You should see a console on your display. 2. Find the SBDF of your VGA device with lspci -v (00:01.0 in this example). 3. Disable memory decoding (replace 00:01.0 with your SBDF): $ sudo setpci -v -s 00:01.0 0x04.W=0x05 4. Type something to see if it appears on the console display 5. Re-enable memory decoding: $ sudo setpci -v -s 00:01.0 0x04.W=0x07 Relevant prior discussion at [1] [1] https://lore.kernel.org/linux-pci/20160906165652.GE1214@localhost/ --- drivers/pci/pci.c | 1 + drivers/pci/setup-bus.c | 25 +++++++++++++++++++++++++ include/linux/pci.h | 2 ++ 3 files changed, 28 insertions(+) diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 53345dc596b5..1ac1435ad91e 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -6677,6 +6677,7 @@ void pci_reassigndev_resource_alignment(struct pci_dev *dev) pci_read_config_word(dev, PCI_COMMAND, &command); if (command & PCI_COMMAND_MEMORY) { + dev->dev_flags |= PCI_DEV_FLAGS_MEMORY_ENABLE; command &= ~PCI_COMMAND_MEMORY; pci_write_config_word(dev, PCI_COMMAND, command); } diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c index ab7510ce6917..6847b251e19a 100644 --- a/drivers/pci/setup-bus.c +++ b/drivers/pci/setup-bus.c @@ -2131,6 +2131,29 @@ pci_root_bus_distribute_available_resources(struct pci_bus *bus, } } +static void restore_memory_decoding(struct pci_bus *bus) +{ + struct pci_dev *dev; + + list_for_each_entry(dev, &bus->devices, bus_list) { + struct pci_bus *b; + + if (dev->dev_flags & PCI_DEV_FLAGS_MEMORY_ENABLE) { + u16 command; + + pci_read_config_word(dev, PCI_COMMAND, &command); + command |= PCI_COMMAND_MEMORY; + pci_write_config_word(dev, PCI_COMMAND, command); + } + + b = dev->subordinate; + if (!b) + continue; + + restore_memory_decoding(b); + } +} + /* * First try will not touch PCI bridge res. * Second and later try will clear small leaf bridge res. @@ -2229,6 +2252,8 @@ void pci_assign_unassigned_root_bus_resources(struct pci_bus *bus) goto again; dump: + restore_memory_decoding(bus); + /* Dump the resource on buses */ pci_bus_dump_resources(bus); } diff --git a/include/linux/pci.h b/include/linux/pci.h index e83ac93a4dcb..cb5df4c6a999 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -245,6 +245,8 @@ enum pci_dev_flags { PCI_DEV_FLAGS_NO_RELAXED_ORDERING = (__force pci_dev_flags_t) (1 << 11), /* Device does honor MSI masking despite saying otherwise */ PCI_DEV_FLAGS_HAS_MSI_MASKING = (__force pci_dev_flags_t) (1 << 12), + /* Firmware enabled memory decoding, to be restored if BAR is updated */ + PCI_DEV_FLAGS_MEMORY_ENABLE = (__force pci_dev_flags_t) (1 << 13), }; enum pci_irq_reroute_variant { From patchwork Tue Jul 16 19:32:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stewart Hildebrand X-Patchwork-Id: 1961267 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.a=rsa-sha256 header.s=selector1 header.b=IQzCbJqQ; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=147.75.80.249; helo=am.mirrors.kernel.org; envelope-from=linux-pci+bounces-10397-incoming=patchwork.ozlabs.org@vger.kernel.org; receiver=patchwork.ozlabs.org) Received: from am.mirrors.kernel.org (am.mirrors.kernel.org [147.75.80.249]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WNq6l18tGz1xrQ for ; Wed, 17 Jul 2024 05:35:43 +1000 (AEST) Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id DF2A81F26FD5 for ; Tue, 16 Jul 2024 19:35:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5DAE91A2568; Tue, 16 Jul 2024 19:34:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="IQzCbJqQ" X-Original-To: linux-pci@vger.kernel.org Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2058.outbound.protection.outlook.com [40.107.92.58]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 847371A08CC; Tue, 16 Jul 2024 19:34:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.92.58 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721158477; cv=fail; b=HdmSSUKLZzykCl6Lc+f3Ov1Wmp2pwPSP5lV/aBbuV6SoibSY+QluFw38YmKH7DIjtmLxbTko31lZh8MVcdJ+Igt+9hJ0awQ6biO44VC63ZbZuBEEtEUB7/rCwYEvAQL9dZEmrmEP2JYfQG5TdJI8hqWBGpiOp1Vr8xD4U2Ud2kU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721158477; c=relaxed/simple; bh=vKUeo3ShzHXKrZBwUIrQGJtH2Isd35wy7uqYdzQhaQU=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=OMoce3gCN4T9+sQcn8/UYegFCf/OZsb08RW73+TyAavsFPUQuLCZkJJnps5kPjEU1pq5CLsGN1FoY/lvpEndCKtSFA/cc19bpFlxtLsUdTdT+V6UF4rywrBumXhfHFaAzOE9txwEW1kZs6Jj35yLutT9DY1YAR8Sbyk4fcH9R/o= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=IQzCbJqQ; arc=fail smtp.client-ip=40.107.92.58 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=pqTiaMg2uC/DdkLmUDps7o76jzaOUGdTQMuV+0GsaLFPWos2fsloI5IodqxtdgDS9W4KqJL01J13C/SUPDc4ySyeu2Q7Q4ZE0nokzL4QrzIRimp55VSM0myMmQ13oGiQ3kt4+sgkP7ZD5VZDRzF84q8oO7wAjYA+LHULdXXjjyLq0Q3PLyJqUZGkg684iKax5EOmZvzJ16l5vwxrXAKuLUUg1Rqub9NTl5tggWyXzRA8Rg2hjkIBx90nR2d10UirXCA/xsZUW9O8vMN3XEP3DZAJOMrVmiSSNlqACdqEXXCQ5vW9LsmJkjEU8WGxIJEVop7ay21i6uHTFJo7TBF5qg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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; bh=8zMxo9JvASDRg6pzKJ03QCy0rll2+8COyUKeiqmPURA=; b=U9dsg90VgUDYK6NU8zNST4mhVGvSxdh7BwH6hdHIJLEIr49zMs2WgUoj/iQY40NciJD4H3fOfM6Dx95Xdub9q6sh2yY6p0oGEoENWUApjMcYo9zQJQf/x91YlUsogalF7DtruREZtOorRfHTLug93RmFouIeysFFczNdFiEUliZMLuEZJCgIYEYIWHW8UV9fJ0oFT5RUiGd3pClQtSanOwVRKZUf3MqH/Wx5iTdh2RXmSL2wUxYDbMH3jzIU5qszmnNhMc3dSjZcv39CG5turpup6uC7Edv7swr4IwBeBJSq/JvU8VLBOjdWgfBgMo12b8xsLE7DYTsdkaGy3cSHlw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=google.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=8zMxo9JvASDRg6pzKJ03QCy0rll2+8COyUKeiqmPURA=; b=IQzCbJqQDygP2gq3u1CwWtnaygCMh6fgo/Z0y91BIDEmISVNstn9s+gU4pdbdQ3z5a8XBg47IuJWk07GsMmcTMdQu6QRKwG+pE2hgqRP9gW9cF+jQcKROHDjfx32PcxuDONebq3xM2/wvNSc8HU7Vf+MU63eRundxg6JX7oG+M0= Received: from BL0PR05CA0010.namprd05.prod.outlook.com (2603:10b6:208:91::20) by MW4PR12MB7119.namprd12.prod.outlook.com (2603:10b6:303:220::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7762.25; Tue, 16 Jul 2024 19:34:31 +0000 Received: from BL6PEPF0001AB53.namprd02.prod.outlook.com (2603:10b6:208:91:cafe::57) by BL0PR05CA0010.outlook.office365.com (2603:10b6:208:91::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7784.14 via Frontend Transport; Tue, 16 Jul 2024 19:34:31 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BL6PEPF0001AB53.mail.protection.outlook.com (10.167.241.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7784.11 via Frontend Transport; Tue, 16 Jul 2024 19:34:31 +0000 Received: from SATLEXMB06.amd.com (10.181.40.147) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Tue, 16 Jul 2024 14:34:30 -0500 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB06.amd.com (10.181.40.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Tue, 16 Jul 2024 14:34:30 -0500 Received: from ubuntu.mshome.net (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2507.39 via Frontend Transport; Tue, 16 Jul 2024 14:34:29 -0500 From: Stewart Hildebrand To: Bjorn Helgaas , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , Yongji Xie , =?utf-8?q?Ilpo_J=C3=A4rvinen?= CC: Stewart Hildebrand , , , Subject: [PATCH v2 5/8] x86/PCI: Preserve IORESOURCE_STARTALIGN alignment Date: Tue, 16 Jul 2024 15:32:35 -0400 Message-ID: <20240716193246.1909697-6-stewart.hildebrand@amd.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240716193246.1909697-1-stewart.hildebrand@amd.com> References: <20240716193246.1909697-1-stewart.hildebrand@amd.com> Precedence: bulk X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL6PEPF0001AB53:EE_|MW4PR12MB7119:EE_ X-MS-Office365-Filtering-Correlation-Id: 5f1365cb-ee93-4df3-4d9f-08dca5ce50aa X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|82310400026|376014|1800799024|36860700013; X-Microsoft-Antispam-Message-Info: 1rbbrFjQ4HmHo6rE0nvMKOKHtQ+ZKJ0QQI5O7fOLzxKheIdepmEbVZXZMy52Co/ixmymfAcvUraKQNCtisj20wQqIJw+caeAuNlWQgXLz9qTfD9sdK5ET1oCVCHJtbMq0ndEN4qW4Ouq/pZUSvdiUom/Olkl4/9FnsEPhI2ovaj6DX3FASRYYuzRCZxM/HHpcLEvdvzJ8Sr6lTIrApxQkHbIACSl63BcE+GjO/4xPaJRuNh3qz1eq0o3qyPOHQwatYsQJGefWXu+TwQcr6gJjzXdc+ehCnsHui/k+ktpMykQDHlMBJU10Q2YSEGCcVliKKc4w3OWuKV1tmE0r0GSHYLG41CxENVMd1rh1PjKa7UGR6Ghz+c5prrsDTBv1iAjAp2wFYnSHtsEkwBeBaTYZP474pqC9961fVpGXDbKDTXsR/f8EI2BVpSKhsNfzOuTWJFnKxLFLA1RtUi83455E4dZOscPT323z9WLH9KZxcjBnTV2puaOsORm2GgIPP2RbPyFUZ78l7sbS+E2B6bS8jedS2+j383bD50cJfuuFRsmEl1iEuh9yoOrocofq0Hwh1p3m0i6ayKJwWoGVk4gpG3m/VRk7gOQ0G9MOgamRjuYxjLtDTMDPGhDxsasSkJlI4xi9u1RKITgUtUOc4AKgnNOjo4iIrdka2IQqY+riAiZdiF1P4WR6elm+vgH4X9HyYg1GM5943UmxkioHWDwxIoatyKmiNMQnz7wPlwtXo2elNKPkcjmneyVAzREa2OOIjt5F9dUDDLe/Ht4XLeYwPoa+92GpX5gXBNcQ25b5CxFZlTTeIbpQwn4pPXiqqn2/nXzcvo6Qw1r/CYxUM+Jvff8ULwwwzhddDUyaEVoB5B5jvfPorK1dfPf5xFA4Ap0sQ5LSe8r6T6SoH65h6wS79Owp16Iq9IQB+DAgJNPnRvqTN6bL7o9j/GDtKfNeywd1QfOIFsgMK1G1QipbP81wd/jk9CZoZD3AOb6o4JJevS4POrRXIMpJEGz507CrhSNELctb1TOvTdpxGkZsbB/xYD3rt7RcIxi2PnF5/SdwBq8Bc/gBqNEJMMgvSIZ4W6Y+nwjIwXD2w5pbYLalYH04v3r9ZdOgKKsFP+pvpVR+qqkEx5bEsxYElrIM/2mT0xNZC0Mnjfaxitj1uIfSq58imMyk2ZVlh2V/LPGusjcjyz3t1h/ks+Xr3QvLPSn7GV9xs0ttYmGvp3T2CwYpdI0Phb66S/B97GtAu/DUWoCmaXnCqyWaqtOsp3HXWutYgQurTPX1BxYKudlX8BYq03mflh3DoCPyXpvyt82OuILcKN11i0673DqS3sZMTO3C47YmYDc71LGWqHmwWvpoJ17TqtZzjYQa3uVS4YF7ft9D7XpEYZH5dbVBfoUCKvKmc1dj0aZntiPDvcAKZg83NCQFpzvJsRF0KEZU6i8k9JCaq/wn/XIf5HUxXch4dDLtGdo X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(7416014)(82310400026)(376014)(1800799024)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Jul 2024 19:34:31.4170 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5f1365cb-ee93-4df3-4d9f-08dca5ce50aa X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BL6PEPF0001AB53.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR12MB7119 There is a corner case in pcibios_allocate_dev_resources() where the IORESOURCE_STARTALIGN alignment of memory BAR resources gets overwritten. This does not affect bridge resources. The corner case is not yet possible to trigger on x86, but it will be possible once the default resource alignment changes, and memory BAR resources will start to use IORESOURCE_STARTALIGN. Account for IORESOURCE_STARTALIGN in preparation for changing the default resource alignment. Skip the pcibios_save_fw_addr() call since the resource doesn't contain a valid address when alignment has been requested. The impact of this is that we won't be able to restore the firmware allocated BAR, which does not meet alignment requirements anyway. Signed-off-by: Stewart Hildebrand --- v1->v2: * capitalize subject text * clarify commit message * skip pcibios_save_fw_addr() call --- arch/x86/pci/i386.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/pci/i386.c b/arch/x86/pci/i386.c index 3abd55902dbc..13d7f7ac3bde 100644 --- a/arch/x86/pci/i386.c +++ b/arch/x86/pci/i386.c @@ -256,7 +256,7 @@ static void alloc_resource(struct pci_dev *dev, int idx, int pass) if (r->flags & IORESOURCE_PCI_FIXED) { dev_info(&dev->dev, "BAR %d %pR is immovable\n", idx, r); - } else { + } else if (!(r->flags & IORESOURCE_STARTALIGN)) { /* We'll assign a new address later */ pcibios_save_fw_addr(dev, idx, r->start); r->end -= r->start; From patchwork Tue Jul 16 19:32:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stewart Hildebrand X-Patchwork-Id: 1961268 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.a=rsa-sha256 header.s=selector1 header.b=wAptvQyO; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=2604:1380:45e3:2400::1; helo=sv.mirrors.kernel.org; envelope-from=linux-pci+bounces-10398-incoming=patchwork.ozlabs.org@vger.kernel.org; receiver=patchwork.ozlabs.org) Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org [IPv6:2604:1380:45e3:2400::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WNq724scdz1xrQ for ; Wed, 17 Jul 2024 05:35:58 +1000 (AEST) Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 3F11D2826FD for ; Tue, 16 Jul 2024 19:35:57 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 699BE1A0720; Tue, 16 Jul 2024 19:34:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="wAptvQyO" X-Original-To: linux-pci@vger.kernel.org Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2073.outbound.protection.outlook.com [40.107.237.73]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B42E91A00DF; Tue, 16 Jul 2024 19:34:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.237.73 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721158487; cv=fail; b=WWNUbX8a+4c4KTlhoRtqPuYjkTNAVRXQHWmmtiKgMST1wibMVCkZlM41dLJQVbZgIQ609P2pcl7P9cfQSOTvaBhHLU041lhVjzAPlbEoB39ougKivfZ8IPZn8TD+NlJHLMXxfeatHl+SCYSQneoHToaajpI64zx8y/73QoCaZT8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721158487; c=relaxed/simple; bh=mw3mfmolBOSZk9iWMddFrlWzX8r9uFhW/OTOmDszZBw=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=hGe0b1ncd6BJCdVQV/05EZd1isEKsqXkaQIoqvcSYgOQWdmrcAJJapwMOTfR2FhDzum5K+gWtbkX0Vy2zXz7Pyiv7OUk5fyKPKXYVUjF6ZoVsh87F4qHNXlxYL/djdcp66s2xxj2dEQ/amNzhAv+4NDPXEkkB+VtAn9jio8MXX0= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=wAptvQyO; arc=fail smtp.client-ip=40.107.237.73 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=uKSMDmbTMgnmz5zr6tQ27VLRRTbbghkOVfCOVS8sBl+XHAYw2U5Epq6AFpU47IUw8E4yOMutIMsjGx08yGWTnbwJ2tfNHsVf1NizR5T62o3d/+i1HYIyooBXe3vmFlsAuGMtxs/xC7of2PMJxCEj7fvfE58U0QfyLrZKEw7DBARza57taFCH0f0NEsReiEwyNuVFa8oAbKy/kYOjxh83tlNDvH82x514ROZHYz3EyQMT1tumb3qed7zVpWlG5WW8glD9xLJIbjAyVxe1v1zvz1ZqgAlFlh2156rxWeioLT2gln730frZk+euIw8CDAuhjRQ2+B/uXS/dAT28KRns9A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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; bh=4nmYSRHTvVFlfgXKAiLo7DQR0vXr8xcIIp0ykn3mfdU=; b=Bm2A9JlznRgoKAa0/5j4m4xKLSwfBEgaqr2SUKMUL6IO7x7Y/18XIT8A2jlLjYBNcO4ycNQ1pVWQqdpNzz77XDxU8rDoo4o9EF6tp0qOCFOUZvTbOpRQW1vq3QFSPbsH4SSsufbyXE2XhUuPN/9xHM3tzVdnHmxoTXCI9GkDS2OiNoNqDqY1Th2nbclMl61ixp/9zfSe4U6Xn9O5S3eVm/q/SZQBbMcxU0lxtemuRQmnVrzwDMMgXEijxS5EeISySLwH4RaAtQa7IeTk21LGDb8FOsTnnze2wh+HQTB7JmcER4HMG2UoXIue7owRSzMAClDPG7MvUV1Vo+tUOLQCxQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=google.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=4nmYSRHTvVFlfgXKAiLo7DQR0vXr8xcIIp0ykn3mfdU=; b=wAptvQyOPRyN701JLT8px65aqF8tddckYWPeP1Vw3xV4rK5IBTlOwMX/Vf1gPytr+LuN309eCPMst2H04FWqDwQFOH7IlxmB+Vw7Jz0sWmqDTPb0tUMb7+zv8SRIG7htLXnYgKq/bOSpvamOowgP2PHwp9kSbFlHdXqhpx97xaY= Received: from DM6PR13CA0056.namprd13.prod.outlook.com (2603:10b6:5:134::33) by SN7PR12MB7252.namprd12.prod.outlook.com (2603:10b6:806:2ac::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7762.28; Tue, 16 Jul 2024 19:34:41 +0000 Received: from CY4PEPF0000EDD7.namprd03.prod.outlook.com (2603:10b6:5:134:cafe::6b) by DM6PR13CA0056.outlook.office365.com (2603:10b6:5:134::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7762.19 via Frontend Transport; Tue, 16 Jul 2024 19:34:41 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB03.amd.com; pr=C Received: from SATLEXMB03.amd.com (165.204.84.17) by CY4PEPF0000EDD7.mail.protection.outlook.com (10.167.241.203) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7784.11 via Frontend Transport; Tue, 16 Jul 2024 19:34:41 +0000 Received: from SATLEXMB06.amd.com (10.181.40.147) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Tue, 16 Jul 2024 14:34:40 -0500 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB06.amd.com (10.181.40.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Tue, 16 Jul 2024 14:34:39 -0500 Received: from ubuntu.mshome.net (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2507.39 via Frontend Transport; Tue, 16 Jul 2024 14:34:39 -0500 From: Stewart Hildebrand To: Bjorn Helgaas , Michael Ellerman , Nicholas Piggin , Christophe Leroy , "Naveen N. Rao" , Thomas Zimmermann , Arnd Bergmann , "Sam Ravnborg" CC: Stewart Hildebrand , , , Subject: [PATCH v2 6/8] powerpc/pci: Preserve IORESOURCE_STARTALIGN alignment Date: Tue, 16 Jul 2024 15:32:36 -0400 Message-ID: <20240716193246.1909697-7-stewart.hildebrand@amd.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240716193246.1909697-1-stewart.hildebrand@amd.com> References: <20240716193246.1909697-1-stewart.hildebrand@amd.com> Precedence: bulk X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EDD7:EE_|SN7PR12MB7252:EE_ X-MS-Office365-Filtering-Correlation-Id: 55a17e6a-3e82-48f7-0fdf-08dca5ce5668 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|7416014|376014|1800799024|36860700013; X-Microsoft-Antispam-Message-Info: rHxASgzUv9lkB0oP2IEHJFdA765HI8lVU332TD5fLY+xvvLp0xIBZgn+xn5yJInkRqoiX+8Rq8ywXVBNBM67tfCxsCi2KhjFYLdjJS0MlC82iwMTEWiXInU9Z5k8kqXXStxlJaGs/zE222JBe48lTagFP7mwdQ7H6OTIAUmpr6fkkalOOvE5oZ5gx3LkhzJkdSUzq6nX/crMswi1b29aMtpaes1cqg76XkPWiNQol+o6tNgoF7y9hQUYquvh6oZ34m8L9pqsuUmML9IvUQdr/m5RMTc69f4sLj5chy68kKY7r0Wlh9fwZzCciBOUp/2RgKryh24n3XSi39q6nvs8TE6VX/BVX3Nt/zOnRwdsstcEECyZ+/iUoRXCpkygdIaCIxdKVvHALU2WeFpwebi7CkvwWHKfZUTuJ+25M9PwVQRZKxGUgBhmdQ22h+Z9XPH1Uh0f4KLMXFuHB+G6pMqW5i0JxjOIO5y9W+J+59svviztC2vakw3o73Aq3ITGQdIWjM/3RaRCWZETl1dhLTSnpdtLSFjBEQ1Z9G/OwIyWXpTumE3R4mszB68dlHKKPI5o/RBA3gf4tBcFyEdTqfeH9tGIAzyS9jxaVxZu90q6cwr6HTxD1P7i+IoakmN6qdN6bEjEaOOa9/imZG67Q99GYbdPIFTB8jjJuYTq8DFfw0mpv7Cl1/r+OOlmQMbLn4VR9V3bJZL9DVU44RK+HNhseH0qDALDsnxyC1G2KvJOBpl71fUDnWvlq6M/mfgsAWOjqAWfbNL44H4bSFQ/rmOaPrLb/0d3WJiI/cRojKSZZQgQsPHit3w7CeL5pG5bMMTObrE+RFfEifIn/VSJnePlypEIAukk04+WUT4AR4iDZEvXInBp2sjVgP9wudl0HSZaHAv6z31WdJSBYujhhPmw0/ouGl7ukkyGfRfuF6egZ7n0ANT+sE+/H4erkXLXhQIc8YzzEAmb+IbNp7+Frv+lTM6JiclbhtBCgS1lLK+HSTnd//zYk73dHzrcO8OEtok6IEdQadDDHjvX6ZpB2dmg9yvcnh+LgMVJf+E9RaAvlcQXiECwU+QN7MhJZotYnDJ132AfhjLxKK4FUsCrQj2roQnCuT+ZN7NP2Xp6eZTgzxmGkVjZ+MLP5RYGEO37Nm1vjUA+JBPs4WHThHw04dK3uU/OMbFKDy0g4m5EKaydwR4lULmAW9bY5jWXfrWEkQhuOAqRC8giSfhdZqVu8bf4M8jxHcTwR6sO+Sx95L9uW8NN8mCzW58pAtxOpNGxs1eS2NB4X3HbzPeLPfQq3pI2PEALJnH5GuIjr/0mQbY9KNE8kWs/SNSiXPkyax/nIbtna5Pknhmsqyb0+YXne66kE6IHjOcj2VeBca8r/AsjayWLRGvNXuTZF/EiviJ9ovFhMivHR8rtfZmdvyqxjsPYH0dSLwL2MjqYaf16frP3oYONNlkfTERLCxViLWPkpDVn X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB03.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(82310400026)(7416014)(376014)(1800799024)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Jul 2024 19:34:41.0024 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 55a17e6a-3e82-48f7-0fdf-08dca5ce5668 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000EDD7.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB7252 There is a corner case in pcibios_allocate_resources()/alloc_resource() where the IORESOURCE_STARTALIGN alignment of memory BAR resources gets overwritten. This does not affect bridge resources. Account for IORESOURCE_STARTALIGN. Signed-off-by: Stewart Hildebrand --- v1->v2: * new patch --- arch/powerpc/kernel/pci-common.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c index eac84d687b53..3f346ad641e0 100644 --- a/arch/powerpc/kernel/pci-common.c +++ b/arch/powerpc/kernel/pci-common.c @@ -1303,8 +1303,10 @@ static inline void alloc_resource(struct pci_dev *dev, int idx) pr_debug("PCI: parent is %p: %pR\n", pr, pr); /* We'll assign a new address later */ r->flags |= IORESOURCE_UNSET; - r->end -= r->start; - r->start = 0; + if (!(r->flags & IORESOURCE_STARTALIGN)) { + r->end -= r->start; + r->start = 0; + } } } From patchwork Tue Jul 16 19:32:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stewart Hildebrand X-Patchwork-Id: 1961269 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.a=rsa-sha256 header.s=selector1 header.b=qhy2dxKB; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=2604:1380:4601:e00::3; helo=am.mirrors.kernel.org; envelope-from=linux-pci+bounces-10399-incoming=patchwork.ozlabs.org@vger.kernel.org; receiver=patchwork.ozlabs.org) Received: from am.mirrors.kernel.org (am.mirrors.kernel.org [IPv6:2604:1380:4601:e00::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WNq7b6f0Nz1xrQ for ; Wed, 17 Jul 2024 05:36:27 +1000 (AEST) Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 842331F27800 for ; Tue, 16 Jul 2024 19:36:25 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0054E1A2C38; Tue, 16 Jul 2024 19:34:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="qhy2dxKB" X-Original-To: linux-pci@vger.kernel.org Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2066.outbound.protection.outlook.com [40.107.93.66]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 69C5B1A2C2C; Tue, 16 Jul 2024 19:34:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.93.66 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721158493; cv=fail; b=lzZpltTMTGjeyPCWwBX8Rh0iaRcMvRA2EhQi2phMT0VDEfhEGINzoJqlajFTnE8f4TsSBKEq5AZlywFcSUaU0M0Jwx/uc544PFUEvVhzq+2QiJ2xrVOcXJZUpX6/ZSt/5jYAI98fuJafS9L7dc9+6PIe9RQLwpUX7gacmwdiW6I= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721158493; c=relaxed/simple; bh=tTtOEb8cXv9POL+062+kiVBoIdwXF4JeZ1LRKf7o7PM=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=NbEBZNEHlTccrnSzdmXc1Wj+TTgM4Ubee2FZ4Va3d2rKVyW+h8dHctNzmxJ8VZGbHQKpVzqZtKw5y/Yehc2Y1A/yD0dP14+p74pYK5HEaaqC7fo86Gh6NuWRSdPj4xY+0PNlIDgbBXO8O5IzY9mzYrLaG1KN97RtyEmFFaRBUck= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=qhy2dxKB; arc=fail smtp.client-ip=40.107.93.66 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Qr31ECiPaDTq/eHvzHhbsDyho/jImPDGHzxVOY4OCMDEdvvPmpT17ilF/wLIKWee7APsrSNZVT8j6+8k832sW+JU7vs4rtV3njKTepOlMG04zX7iFayQBlx06TJkSzswaNphHiMAlOfQeL++0C4DotkKY278rCAhUEv76W3EA7wpLE0jEw6wUuCmCFTaRXmypBfWtfO8+KxotOmdEeHb4dugMMubOW++hTEt09VPhNK2o22+jqBURn66SQTHi4uai81D3l4x26oCx3el2vfkHbiYf88c3H05G/dWIvBaKKmSMuwmUUcp2hgtLVORAw7swS/e3wx7ACZ3mZFYrGdpgQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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; bh=L4M+oA76gwrPzpOjUd6t7GrStaXH0nL5c3EVl0d7DPU=; b=Hh37NYTXWuAdU96i2/+NX9EMYD9OpBhOpeO1ZTsmz3wWa2nAl9XsH6gkkjpxOB8TJy+HqhGvHB9LVVdP9YE7qcW8xekh0yGUUo6Lw+B6MAJ8J1goydYiuuHXTj+x3kROwp4lKG0T9wMYMbozVO+/5DcDbK4r6fQNIF5hRixQN+7X76XCxI6RqJDZYdB5Mf7WmESLhR0aDDADNr32xrd+eNAZ/ZnSj6VCiiNJFGZ5YKgjXFcM7U0yGC9lMCeazW7LfeUwCK02ZX/xFe/yndyg6kfwwINW90YCAyZrB+t4tkA4+Px2vbUWvxQsTMbyeD9qcx5/Hb4XgqV0YzB1Tmb9ow== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=google.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=L4M+oA76gwrPzpOjUd6t7GrStaXH0nL5c3EVl0d7DPU=; b=qhy2dxKBQNb/OMaD/mnfq/cghE0nHKnO/mLsD0Bp4e9YW9AL3r7P43AS00Hh4Io7igZqoXBJ/ajM1f72lbMj+bfGwlfLywemPaH6mddxpd9laj3Yy+UQReACwMtIQ8DvMfaBY2THJUhi9EM6yCI+6cg3R44w1OMEvWCjMkV+PdI= Received: from MN0P220CA0029.NAMP220.PROD.OUTLOOK.COM (2603:10b6:208:52e::9) by IA1PR12MB8360.namprd12.prod.outlook.com (2603:10b6:208:3d8::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7762.28; Tue, 16 Jul 2024 19:34:48 +0000 Received: from BL6PEPF0001AB52.namprd02.prod.outlook.com (2603:10b6:208:52e:cafe::5a) by MN0P220CA0029.outlook.office365.com (2603:10b6:208:52e::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7762.29 via Frontend Transport; Tue, 16 Jul 2024 19:34:48 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BL6PEPF0001AB52.mail.protection.outlook.com (10.167.241.4) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7784.11 via Frontend Transport; Tue, 16 Jul 2024 19:34:48 +0000 Received: from SATLEXMB06.amd.com (10.181.40.147) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Tue, 16 Jul 2024 14:34:48 -0500 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB06.amd.com (10.181.40.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Tue, 16 Jul 2024 14:34:47 -0500 Received: from ubuntu.mshome.net (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2507.39 via Frontend Transport; Tue, 16 Jul 2024 14:34:47 -0500 From: Stewart Hildebrand To: Bjorn Helgaas CC: Stewart Hildebrand , , Subject: [PATCH v2 7/8] PCI: Don't reassign resources that are already aligned Date: Tue, 16 Jul 2024 15:32:37 -0400 Message-ID: <20240716193246.1909697-8-stewart.hildebrand@amd.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240716193246.1909697-1-stewart.hildebrand@amd.com> References: <20240716193246.1909697-1-stewart.hildebrand@amd.com> Precedence: bulk X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL6PEPF0001AB52:EE_|IA1PR12MB8360:EE_ X-MS-Office365-Filtering-Correlation-Id: 7437f49b-0eb5-4187-2c32-08dca5ce5b10 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|36860700013|1800799024|82310400026; X-Microsoft-Antispam-Message-Info: Fi7csOYH3y9OFigB6vciegum6LRWcq6GvMNL4nkUk7uv+AGXmxWmWzy9gGv2On8IrFJMtVfn8BEK2aBy/42T/r1CRzaV38jjBxbz58cpx1JdxY06NqiqxRXY0iLnWt8uI7Ra7q7esNGCQNi5yh+5YPsLlIPOibdc/sXGCo6q11Mw7qXpEd+fIpOrxsfP20BEjD9gr9mRFWPFUi6suLWzt2qBsDu3TmZ5/KyjVYa8kh79IIp95wMHdKJKkER2+IIwIS9VEbpoI7J+DB4URfMyJGIusUKINUuXX8PYSCa/p3Ob+huTM6KtXXJ/r8NsgjysPHcLt3CkF25ddDVCKzEkt/J0t9pwthoA1ld6Ze0tjl6pnwBe6a1LRROQj2E0KURjk/cdu6YG9ZvzMnmv9I5Gqeo6jx4HH0t8zUQbtu1Sskb9gmw2DeFn4Dj8vFDoRc/N90/gJvIH4LY/pVJLB+on9s6xSjxrQcTOQqDiTY/oKRYS+cDirmZeRPbT4gumUTFfceOg/GV3QZTJ0GQdwGfSS3xKMQrmrX9a6JmYR4X9TGLowP91NK8nuEL+bgdYG9GgoQFoeQiErWczHjpboSpzE8QnjwlEfYEC+OIUCYPZsZWGsPKeadaEVyifRv5TSgxeMzreansPkWwfqbBgkkERqe3uXAwPM9uaNW3Wunl0W+etwkg8P1Lci8N+zKWNw+IxKUkqyLVvl+Z2DzCuaOjVexAYN+Rng3J+iEzNyTXuu7Ei25Ifu5R5kUvOxlgF/Pfb+txA5bKYjW5b3VnQTtBI/h62GEG+51cQKync1Criw9DS8ez+VdeBO9Lk7Ku6OHt76kKesY6H31Tiw/nUqisvvzhOzxowBLhkR9p/A5hAK/k+fg1F8+9KLQOmEcJumIbp2ihAFR5xMEYZIgvm/GiyIFTj60h7qlI5NdAcu1SQ6DAh8uQUW3c/RIAoKKL9pkRo47aCW9tS6WihkFLtVv2WQd8KObhv9sFxHsoYj+kU1E09vHPixmqaL1rCCRgmODCuoSxB8Bl9i9150/K1RzxV9jFbDT2aPykHrzNZLjDZAKjP5nHhOXvJGLK3T9HJUNQJXRAHdnAb4mmV5Z5rC6A1wa4f7beXVRolq6JfCralzKIC5TzspucYM9gGU8Bv5JLf/9bOcwr1ARxCR3+7AyxP252SAOb41E6bTC6DKD3BIb1ZmY7f9XN5W/xZFnZeCORg8N9E8ULD5PDxcK2HVuufkIwqTxmOkR6thQkCKywYShY1daC7i0HrlAD5hX7em8J1q2f3mDy/bpf45bHofGNaG4TI/2E5P+ss5oAD1Hz9RqbkAHwfkFjLYSEdnKeCpYETXyB8+tzcQaDlVgA8RBsxG9u/d/EkPeI1vcPfsQIfUnx6HzWXNZhStcjpRSEH97dGJDo8yS2aRXO+PyRLS5kLdte848iVvlQoa25ArPPq+hrgqRbbqoajRwdlozoV0Tf+ X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(376014)(36860700013)(1800799024)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Jul 2024 19:34:48.8619 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7437f49b-0eb5-4187-2c32-08dca5ce5b10 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BL6PEPF0001AB52.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB8360 As a follow-up to commit 0dde1c08d1b9 ("PCI: Don't reassign resources that are already aligned"), don't reassign already aligned resources that have requested alignment without resizing. Signed-off-by: Stewart Hildebrand --- v1->v2: * capitalize subject text --- drivers/pci/pci.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 1ac1435ad91e..6df318beff37 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -6585,6 +6585,9 @@ static bool pci_request_resource_alignment(struct pci_dev *dev, int bar, if (size >= align) return false; + if (!resize && (r->start > align) && !(r->start & (align - 1))) + return false; + /* * Increase the alignment of the resource. There are two ways we * can do this: From patchwork Tue Jul 16 19:32:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stewart Hildebrand X-Patchwork-Id: 1961270 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.a=rsa-sha256 header.s=selector1 header.b=26Z25/1D; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=2604:1380:45e3:2400::1; helo=sv.mirrors.kernel.org; envelope-from=linux-pci+bounces-10400-incoming=patchwork.ozlabs.org@vger.kernel.org; receiver=patchwork.ozlabs.org) Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org [IPv6:2604:1380:45e3:2400::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WNq7w5nGHz1xrQ for ; Wed, 17 Jul 2024 05:36:44 +1000 (AEST) Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 802EB280A0B for ; Tue, 16 Jul 2024 19:36:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BA45E1A0727; Tue, 16 Jul 2024 19:35:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="26Z25/1D" X-Original-To: linux-pci@vger.kernel.org Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2041.outbound.protection.outlook.com [40.107.236.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0F2D72B9B3; Tue, 16 Jul 2024 19:35:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.236.41 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721158502; cv=fail; b=r+hH8GmLrLCV5E10lDT3tSvvxcuuz2773qnGoQfMZyS6DzYbEfT9QAbOFzZ9bI1IbmbY26hsTZhJyDV38bnayV+FTz1S0wqzyEJPSGF9OBJiqujYNVjG1vK1n0d+RtoGQ9jLGTIOhlJlMAtANcF6i/p9E+dWBuZebLsRlaDqQiA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721158502; c=relaxed/simple; bh=UNh51fTagQPBPMjzwxxXB31v6QFA3mjHZcKCk35mya0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=eaKV/k9dK4zWMMA0LcZ9PFWfZjuVm8NiypGQycN3FTY0JKD0sRL3ADXwE9L4G9iLLSgdKdxxo99N5YRvzbIIlLhq5A3+YGxuEHDNy/vzT16RmRnr3CnKL+BFjqH4fFOkmR0WyTeUOLJ/sYv3fJHhTPRA/N/OWUcwCg1bnCoFN7s= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=26Z25/1D; arc=fail smtp.client-ip=40.107.236.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=A2xm91A5c0kSZXY+kWRSt+yeEkjuofC874ibpeA/zjZ0qSObsxz8ZkcwJXFHJWwBVIMhDucSkVa+Bxr+7nX2f1l3zyusoZZjuHomo4Y+noeuegrOXoB0rsp3tR3bZ3IwXP9gZsDtE4pPpNyVW68pQGrrEMrkF9EcD4zlw5hy9ykmytf/2rW56BENSq/8LMBESGSteXImkUodRB2farkY9NMKtnkN3Hb27lZ5pYhtkmhPegz8rVNChLIoSFO+la2olM0b+eJo26ecA1L/sRPm2rZvAPvG0IPfNjXS4EPlww2eDv3Mv/nZJsVosxISQgLOey50X+wL7eaoqup3nqQkTA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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; bh=7gRySur/qOxqgmNdT/AjUFNW1WnAl5ss/MaJuUSddcc=; b=Eco/7M0dw0yiFAEWgSSBSdspVHa8p8K/r2n8sLoBTuZe5Ft8c6UsA840ccWf1Trr1c6K7VxvFHZJfMw3FF0aiUvWdmWoirHlnqhX6K9EIYHXYgT5othoKQGQoLRXZIdmTpoOM1C+4GGgkaLcmktIMMvqFcCphXwJgdEscEPAFXzI6FV92Wu8moZ4Z7vonPRN3Yglmqq5ERFyEQt7zwbhzM90c/sEUfwfJszGHmdcnaiNrUdlVzXWLUz/CYmapSEZJZRSMk068H13fc10VV+Yt0yYY3hDgqaDqzcgMyFPeYlbd1Pl2EQU/9FDt1mvf01ZIh9roPR/AugeRdK87QzaqA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=google.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=7gRySur/qOxqgmNdT/AjUFNW1WnAl5ss/MaJuUSddcc=; b=26Z25/1DK/86oGHhhknveIF+nMjpN0ha0e5pQH8yZCAFXJ5YGA+9apQRObEJsyfskRZ/OoC9GhdQHGkZQX87tre0zZJus/mIE8qpQTBOrX7FSSUCwTUGiv3MqoMpDLodsbxDAw37tnjMB39yjF/k44sdsTupL0dUT8W6tUBVSOU= Received: from DM6PR13CA0056.namprd13.prod.outlook.com (2603:10b6:5:134::33) by IA1PR12MB8406.namprd12.prod.outlook.com (2603:10b6:208:3da::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7762.29; Tue, 16 Jul 2024 19:34:58 +0000 Received: from CY4PEPF0000EDD7.namprd03.prod.outlook.com (2603:10b6:5:134:cafe::3f) by DM6PR13CA0056.outlook.office365.com (2603:10b6:5:134::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7762.19 via Frontend Transport; Tue, 16 Jul 2024 19:34:57 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB03.amd.com; pr=C Received: from SATLEXMB03.amd.com (165.204.84.17) by CY4PEPF0000EDD7.mail.protection.outlook.com (10.167.241.203) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7784.11 via Frontend Transport; Tue, 16 Jul 2024 19:34:57 +0000 Received: from SATLEXMB06.amd.com (10.181.40.147) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Tue, 16 Jul 2024 14:34:57 -0500 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB06.amd.com (10.181.40.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Tue, 16 Jul 2024 14:34:56 -0500 Received: from ubuntu.mshome.net (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2507.39 via Frontend Transport; Tue, 16 Jul 2024 14:34:56 -0500 From: Stewart Hildebrand To: Bjorn Helgaas , =?utf-8?q?Ilpo_J=C3=A4rvinen?= CC: Stewart Hildebrand , , Subject: [PATCH v2 8/8] PCI: Align small (<4k) BARs Date: Tue, 16 Jul 2024 15:32:38 -0400 Message-ID: <20240716193246.1909697-9-stewart.hildebrand@amd.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240716193246.1909697-1-stewart.hildebrand@amd.com> References: <20240716193246.1909697-1-stewart.hildebrand@amd.com> Precedence: bulk X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EDD7:EE_|IA1PR12MB8406:EE_ X-MS-Office365-Filtering-Correlation-Id: 4648baa0-0343-44f8-d382-08dca5ce6050 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|82310400026|1800799024|36860700013; X-Microsoft-Antispam-Message-Info: ky/8eSy5Fjvscm1KDV+QyQ52D/x0aB/Zy1bHABaUzya/Eksfwy7jMuYNs75du1rWp88tC/+EY6O/wrKgcHQ62iIcSO8i000CdhTKQxMEcNkDWghLCm6WaJskj+R36/8rYaGs3D7rrriKOdDU/YJbr3jKjTCXVet8jYZ3PH5jbTZYdz9ALTK2VbH2Cx79vxluBQ74XIRMv0hWKjC5IWLwvaz2yzbicMwJKOFVCIurUH5yNY18IqwA95Ut1uLoHK7ZyIHnlodnAMC4/i/oFiMeoaTrcjxzYWaxwVfnUuH4gQYdAaLcsq/54qWz64M/YaoMOOR++aYEaDemHDB6fcFXIAIfgMGXQg/8WVy4WVTGUtv/7DW/TxV4GfsaJIckF1I4/K+FWAD41gBwxh4l/VZQgPW9sI97vwpmX0Vj/ivzXssrhnnulknuylBJQjO+gWCN3E3AdCc1OMn/ds9Rr15FOLMkx1wPSNG5flYq8xGqF36G8Wq/4JkZiD0AXaFpOEeRRwfevNJq0vhVdXmZYu1AuwKTybA6xRZryUn127DPLgtqQ0WME2wwlCLu/1DQeESdQu4S08lR9iV2E3IAj5JZUSMCVKCGztmrBZL5zBCWvlMm8cxGtCjRJeE7Kf8AgVQmCTpiwyqZR9zap79uceSaceFwAKmDCoef1ZFjM8YMnCAB/PCYWm6RpBvmPKyAtTpXjz1j+VgGdMwtYGbAnULkQRjMbRaf8JrmazquALRMdJmBlyOSToWVHn8xck/pQaQL1bNmbPSYRRE+lHx6kXv2By7501u1PFVwalDwqnKvx4T8lhNw5F3X5hkjBJIkJt9GMWWeSG6WDnuzwBGXD8nDUwvAG4ks0Ier0I6RM/ARkN9eBBGhfbaKZrKkGcQ5ySsd58NzOdo1aiIfqBQWmYzacpKljdFIUd64s0evro4CyAuHWIOXLaUfpZ2n9AmlscN8a3lCVlsAVGJUOhCz9NKwAiqSkxDD0+vKGrxmnYoV6t2KaeiCdDBye0GDAvodpwYehM6x11g7MGkrqYuNmF+lOQ6gx89lAcC1/C4vY5NLilKDOnjEutpgsxmCux1iQCNkCtkkwPbgVhrviox3Uv8e8NgANNfL8gPHxn/v+I+a7yiZoO+J3pu9WQmA8iMaK4QMpmfBsbgSqnak+IkCCVJDNL08iJd9EAme55R89DzHVuLYe8FgBigTfpWvDHXccIFekPttDim2o9968ali2nvhyZiVaRTZ59xlT7FYj3c7Pz9rTeRDiT/8mjlvfyALcc3do25o4pByeA8huCrygoMJoGC05ellrMKb+qNCxsSmVEnw8sa21369AXnJsGAnTUibe9msyyaRhxhdZiAs9GlDrDWGz4FjzajEVwgaPShEiVaOe39FzQ8rK2gV5Ws8U+rIMhk9uLLvrVzTniR3Z59GBmkQsu1s7CyvyO0RRDF2BOnIMga4nWQWN3NyJn5jM0DF X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB03.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(376014)(82310400026)(1800799024)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Jul 2024 19:34:57.6273 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4648baa0-0343-44f8-d382-08dca5ce6050 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000EDD7.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB8406 Issues observed when small (<4k) BARs are not 4k aligned are: 1. Devices to be passed through (to e.g. a Xen HVM guest) with small (<4k) BARs require each memory BAR to be page aligned. Currently, the only way to guarantee this alignment from a user perspective is to fake the size of the BARs using the pci=resource_alignment= option. This is a bad user experience, and faking the BAR size is not always desirable. For example, pcitest is a tool that is useful for PCI passthrough validation with Xen, but pcitest fails with a fake BAR size. 2. Devices with multiple small (<4k) BARs could have the MSI-X tables located in one of its small (<4k) BARs. This may lead to the MSI-X tables being mapped in the same 4k region as other data. The PCIe 6.1 specification (section 7.7.2 MSI-X Capability and Table Structure) says we probably shouldn't do that. To improve the user experience (i.e. don't require the user to specify pci=resource_alignment=), and increase conformance to PCIe spec, set the default minimum resource alignment of memory BARs to the greater of 4k or PAGE_SIZE. Quoting the comment in drivers/pci/pci.c:pci_request_resource_alignment(), there are two ways we can increase the resource alignment: 1) Increase the size of the resource. BARs are aligned on their size, so when we reallocate space for this resource, we'll allocate it with the larger alignment. This also prevents assignment of any other BARs inside the alignment region, so if we're requesting page alignment, this means no other BARs will share the page. The disadvantage is that this makes the resource larger than the hardware BAR, which may break drivers that compute things based on the resource size, e.g., to find registers at a fixed offset before the end of the BAR. 2) Retain the resource size, but use IORESOURCE_STARTALIGN and set r->start to the desired alignment. By itself this doesn't prevent other BARs being put inside the alignment region, but if we realign *every* resource of every device in the system, none of them will share an alignment region. When the user has requested alignment for only some devices via the "pci=resource_alignment" argument, "resize" is true and we use the first method. Otherwise we assume we're aligning all devices and we use the second. Changing pcibios_default_alignment() results in the second method of alignment with IORESOURCE_STARTALIGN. The new default alignment may be overridden by arches by implementing pcibios_default_alignment(), or by the user on a per-device basis with the pci=resource_alignment= option (although this reverts to using IORESOURCE_SIZEALIGN). Signed-off-by: Stewart Hildebrand --- Preparatory patches in this series are prerequisites to this patch. v1->v2: * capitalize subject text * s/4 * 1024/SZ_4K/ * #include * update commit message * use max(SZ_4K, PAGE_SIZE) for alignment value --- drivers/pci/pci.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 6df318beff37..6b85a204ec4e 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -31,6 +31,7 @@ #include #include #include +#include #include "pci.h" DEFINE_MUTEX(pci_slot_mutex); @@ -6485,7 +6486,12 @@ struct pci_dev __weak *pci_real_dma_dev(struct pci_dev *dev) resource_size_t __weak pcibios_default_alignment(void) { - return 0; + /* + * Avoid MSI-X tables being mapped in the same 4k region as other data + * according to PCIe 6.1 specification section 7.7.2 MSI-X Capability + * and Table Structure. + */ + return max(SZ_4K, PAGE_SIZE); } /*