From patchwork Fri Oct 25 21:50:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Micha=C5=82_Winiarski?= X-Patchwork-Id: 13851872 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 07814D149F4 for ; Fri, 25 Oct 2024 21:51:05 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 47AFB10E06F; Fri, 25 Oct 2024 21:51:05 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="MlG74o39"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.9]) by gabe.freedesktop.org (Postfix) with ESMTPS id 5EE9710E06F; Fri, 25 Oct 2024 21:51:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1729893064; x=1761429064; h=from:to:cc:subject:date:message-id: content-transfer-encoding:mime-version; bh=sr2oSwfxWw6lzhTNwcdNZB3nm2DW27pSQn9L+r3Yh3E=; b=MlG74o39ygfOVYdhMB8pzJ1P2+7yfj+E2NpN+kzOU1U3Xorio/pGot87 4ouDD0XUfBkupyMeou915FbgHDoEMeFKLzjmNNK9RW5drMFWhslbvjxWD TDaYELLItZBXFinPhlGigKWoemX5GX+qeDH1t9gtXTeJUmr8GnsmjOZyG 5vD3oAwAwRmmRFyjCwvmrivXE0+pzvuFNKvjbXvMAk0LxIQ6hcLHgQLTq mxiIcLOou2gYSyXBhVxO/SJA909ScjFjcTg6izK6efGxp4baWJTUz5Oo8 Ci42eDULoInWckYwsvgcfVo8R7l1BBbGmumwahopCruEfeqhSDoGcEkum w==; X-CSE-ConnectionGUID: G+XDsz/pRXGjshGsHmnkeA== X-CSE-MsgGUID: pAsphyWiSyahQt40h8HrGw== X-IronPort-AV: E=McAfee;i="6700,10204,11236"; a="40192770" X-IronPort-AV: E=Sophos;i="6.11,233,1725346800"; d="scan'208";a="40192770" Received: from fmviesa002.fm.intel.com ([10.60.135.142]) by fmvoesa103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Oct 2024 14:51:04 -0700 X-CSE-ConnectionGUID: 5b8U8t/jRn6Z0d/tdrKnMA== X-CSE-MsgGUID: gq9ctujvRdCPlPsIqHwZRA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,233,1725346800"; d="scan'208";a="104358063" Received: from fmsmsx602.amr.corp.intel.com ([10.18.126.82]) by fmviesa002.fm.intel.com with ESMTP/TLS/AES256-GCM-SHA384; 25 Oct 2024 14:51:04 -0700 Received: from fmsmsx603.amr.corp.intel.com (10.18.126.83) by fmsmsx602.amr.corp.intel.com (10.18.126.82) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Fri, 25 Oct 2024 14:51:03 -0700 Received: from fmsedg601.ED.cps.intel.com (10.1.192.135) by fmsmsx603.amr.corp.intel.com (10.18.126.83) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39 via Frontend Transport; Fri, 25 Oct 2024 14:51:03 -0700 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (104.47.57.171) by edgegateway.intel.com (192.55.55.70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Fri, 25 Oct 2024 14:51:02 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=LsgpVfuAf5lKRwEyozTTBuW+R7/VnrlBelUipevfde7XySDeNJB26jUyugE+4fJ4cwAqqpc/rOa1lGqIo8YNMWO2rYnwShr+n4Kr3LCjBumgapSi9QP1V5LOFBmx0j8r50qN9jPO95OfOE/zTWhqqLZsIskS+nqBzyRz6Oan1XJQE2jZEn/ikSsmU+pv0tr94Uq1zCx+Y7zwXBXh1eIA7oR1yS/REFgjezTO9mrutZdXmr3YpaGfGePBgY8wcoPE6ruQSfPpByvOZSgzhen3eC724LfM46xXNdy1wnQ2a7VQ5pmxkQpTqJYgRmdZGK1o+hUdCDZHa8Shu5f/ZEo/0A== 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=03FoM+1l/NsBZ9xl0OALJLgpCURFDJ88jf4B2nbIwDM=; b=codadH9Y5tp8eQfNDA81RJycn2EMjzLgSnlG8cumUIIzq9lplZlE4jD8/Jx44xZZww3vtLzv7yLYN9jFlA8xAgBLEZeRnweTzJxRWfmKvbbHAKQDlf4TYwkl0Huw2FABewviJiImRCtfWNB11humolhs33nUk2IBP9UVPt57CvcsHf94tArPplknMieUiYN6P2yFjNBdV3iOiGTvuUwxJZcn5/M6NC6dG+YE+HZhQtAvy8fkNYMqpityIvv57Iy4HKtyfyxPzA/ywlZjBRfVIgaJh0vZhUtS7zjopL6QEaloftzcMZhZ3nI7yiZ1hVHeuWcGGkgu7d7o10JjMzw9Gg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; Received: from DM4PR11MB5373.namprd11.prod.outlook.com (2603:10b6:5:394::7) by CY8PR11MB7745.namprd11.prod.outlook.com (2603:10b6:930:90::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.16; Fri, 25 Oct 2024 21:51:00 +0000 Received: from DM4PR11MB5373.namprd11.prod.outlook.com ([fe80::927a:9c08:26f7:5b39]) by DM4PR11MB5373.namprd11.prod.outlook.com ([fe80::927a:9c08:26f7:5b39%5]) with mapi id 15.20.8093.018; Fri, 25 Oct 2024 21:51:00 +0000 From: =?utf-8?q?Micha=C5=82_Winiarski?= To: , , , , "Bjorn Helgaas" , =?utf-8?q?Christian_K=C3=B6nig?= , =?utf-8?q?Krzy?= =?utf-8?q?sztof_Wilczy=C5=84ski?= , =?utf-8?q?Ilpo_J=C3=A4rvi?= =?utf-8?q?nen?= CC: Rodrigo Vivi , Michal Wajdeczko , Lucas De Marchi , =?utf-8?q?Thomas_Hellstr=C3=B6m?= , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Matt Roper , =?utf-8?q?Micha=C5=82_Winiarski?= Subject: [PATCH v4 0/7] PCI: VF resizable BAR Date: Fri, 25 Oct 2024 23:50:31 +0200 Message-ID: <20241025215038.3125626-1-michal.winiarski@intel.com> X-Mailer: git-send-email 2.47.0 X-ClientProxiedBy: WA1P291CA0015.POLP291.PROD.OUTLOOK.COM (2603:10a6:1d0:19::13) To DM4PR11MB5373.namprd11.prod.outlook.com (2603:10b6:5:394::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM4PR11MB5373:EE_|CY8PR11MB7745:EE_ X-MS-Office365-Filtering-Correlation-Id: be783733-f4c3-4dce-92ef-08dcf53f1d4b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|366016|1800799024|376014; X-Microsoft-Antisp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L34pDApswCKT8es6GYM5H7+VIiejyXO+L2gbIjZ820d7l35UZV?= =?utf-8?q?RtRi9X/ZykzhCcVWm4Z3JwFX/e4wK6+jzYFQAKHKX2KThYx2LwCzDh4Bwj2/QtjlM?= =?utf-8?q?rO0CBML9AeJ5SvRKGSZ7dp8aOUsTb99kqG2hP/4drt8MFYRdf85yskTukDCNEggZy?= =?utf-8?q?w0gqJ61WMqU2v7yMsrLbVoftKgqLVyDEqRM39JBhH1xmirLgxVWS7BGUKiaffkIoJ?= =?utf-8?q?Q/TMTPDqeWWtKB2s3th3l+rNwtI7fKX9uBok0CjSgB0uVNhA8OF1ytD8TZzgpMcw1?= =?utf-8?q?a8kaLjT00CpE5+SOLysaijwYtXpuU6VFAYRFyUA8YqsEKV0ycNvagMscZgu9Brk6d?= =?utf-8?q?OBpQfBT3n8MMYtcdxIKKlOI91rs9iAYcg12VH88MMc5mHxvTxLAkerS8uxOQ0KiBi?= =?utf-8?q?9u5TpUZErmsYr?= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM4PR11MB5373.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(7416014)(366016)(1800799024)(376014); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?M/ukUQs5pO1kXT6EzygdVI2aFP3+?= =?utf-8?q?jdIQ/hqRnYHwjxMIrOUt+xqObk3wiCLQF6D/9qgd1Mm4EIVKC8J5vfUZ9HAlD1aO4?= =?utf-8?q?tqzuRNSg3QyhmRfzaPTII2GszUCMlI8vrTiL2rBUMn9zoq4FiIRiu5p1uodKzuLO0?= =?utf-8?q?pnZKF7YQF2OhYHeUEuc135jsqOhVhcCl17eIsiWKgNMhNujZ5jqxT2w5VvLGXEIE+?= =?utf-8?q?cGZoyjgsY78Nf254UA9DX5PnWWURozcTiVOM8b7x+IR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gE0QUWvLHlSK?= =?utf-8?q?V+KFJz63lAImDUxUvbqUMXjioG27OvlhWLJR47ZZf+ZEW4ILZwYWAk1qZaO+VEQcq?= =?utf-8?q?bTVSRuehg2H+XuqTaITEz9Ox2C+6BC183ksoBy6QsJmQGRMw3voKVKQF/aEcJjLV8?= =?utf-8?q?Elczxo/F3q1h8jOzsYXF42cP0hXnfNWpCWLsbFETeWohQwtd7OgEwkbdDPhsF/8EK?= =?utf-8?q?YPEW5J4ASPz772JAT2LBgHeJQMVgtx4BEfdFlrAbK+18pSJA6t+vE93l9bBVlnH7m?= =?utf-8?q?rnBlnk1vfrgM3AnxuzVjhx47caAzNAdq5JPLKyIVxDyIQ+p7GtJCw3siTx0UNKPg3?= =?utf-8?q?7zbaoZfBTWCuvQAijdQ1NbzV+wtkVEj5TbszNx5EnBcHGm0ylXdC556cr0Az11MJB?= =?utf-8?q?cBmpAtg8nJNKTKeaMPNdAmMoXBbVUU/vmg=3D=3D?= X-MS-Exchange-CrossTenant-Network-Message-Id: be783733-f4c3-4dce-92ef-08dcf53f1d4b X-MS-Exchange-CrossTenant-AuthSource: DM4PR11MB5373.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Oct 2024 21:51:00.4944 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: +JVbpTltvyasTsIMTIsr2OQpon6wcG0du1p7AuQt1KO+/erGoWjB5XBt4xM4eCDLxAK0927gftq+CUGiOfaRxe0fEBXgNVX34gdQ8vQkS64= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY8PR11MB7745 X-OriginatorOrg: intel.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Hi, In v4, the approach to extending the BAR was changed to follow the suggestion from Christian. The control is now entirely on the driver side, with PCI subsystem checking whether the resource fits during VF enabling. I also added helpers to move between IOV / BAR # (suggested by Ilpo), since the ifdefs started to look mighty ugly after addressing some of the review feedback. v3 can be found here: https://lore.kernel.org/dri-devel/20241010103203.382898-1-michal.winiarski@intel.com/ For regular BAR, drivers can use pci_resize_resource to resize it to the desired size provided that it is supported by the hardware, which the driver can query using pci_rebar_get_possible_sizes. This series expands the API to work with IOV BAR as well. It also adds the additional API for drivers to change the VF BAR size without resizing the entire underlying reservation (within the original resource boundary). Thanks, -Michał v1 -> v2: - Add pci_iov_resource_extend() and usage in Xe driver - Reduce the number of ifdefs (Christian) - Drop patch 2/2 from v1 (Christian) - Add a helper to avoid upsetting static analysis tools (Krzysztof) v2 -> v3: - Extract introducing pci_resource_is_iov to separate commit and use it elsewhere in PCI subsystem (Christian) - Extract restoring VF rebar state to separate commit (Christian) - Reorganize memory decoding check (Christian) - Don't use dev_WARN (Ilpo) - Fix build without CONFIG_PCI_IOV (CI) v3 -> v4: - Change the approach to extending the BAR (Christian) - Tidy the commit messages, use 80 line limit where necessary (Bjorn) - Add kerneldocs to exported functions (Bjorn) - Add pci_resource_to_iov() / pci_resource_from_iov() helpers (Ilpo) - Use FIELD_GET(), tidy whitespace (Ilpo) Michał Winiarski (7): PCI/IOV: Restore VF resizable BAR state after reset PCI: Add a helper to identify IOV resources PCI: Add a helper to convert between standard and IOV resources PCI: Allow IOV resources to be resized in pci_resize_resource() PCI/IOV: Check that VF BAR fits within the reservation PCI: Allow drivers to control VF BAR size drm/xe/pf: Set VF LMEM BAR size drivers/gpu/drm/xe/regs/xe_bars.h | 1 + drivers/gpu/drm/xe/xe_pci_sriov.c | 22 +++++ drivers/pci/iov.c | 158 +++++++++++++++++++++++++++--- drivers/pci/pci.c | 10 +- drivers/pci/pci.h | 45 ++++++++- drivers/pci/setup-bus.c | 9 +- drivers/pci/setup-res.c | 40 ++++++-- include/linux/pci.h | 6 ++ include/uapi/linux/pci_regs.h | 1 + 9 files changed, 261 insertions(+), 31 deletions(-)