Message ID | 20250402141122.2818478-5-michal.winiarski@intel.com (mailing list archive) |
---|---|
State | New |
Headers | show
Return-Path: <dri-devel-bounces@lists.freedesktop.org> 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 4E84CC3601C for <dri-devel@archiver.kernel.org>; Wed, 2 Apr 2025 14:12:15 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1EFFC10E7E3; Wed, 2 Apr 2025 14:12:13 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="Ie7wCuHq"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.20]) by gabe.freedesktop.org (Postfix) with ESMTPS id 7869C10E7D8; Wed, 2 Apr 2025 14:12:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1743603131; x=1775139131; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=luDF2Sdx2KVSQ5m4lKqpObI9udJNMyroUb4ugSNNWFg=; b=Ie7wCuHqkmL7vcWXf9bGwZC0oKjo5kzpnXKdPOjbLLmulvSNLChrX1NH W1rCR30ZzTkcTA/9seiI5KsXTpTCuAVqif/6sVwNnLIiPQkF1+NOZJinI HQ463CvP6v9EwlrhUtuo6ODoBCQ24xTLyFzoMZGSONCZgiOy5zEYvJyDH tD346lvEhlFH6H4oDtQEauX/+vcf7BpKI8tpWVlZzYNFzu1xI06rJXMTE /+r8jnrVGFyxyQNvRTVlVJPeDezqLqyammsMOMGhqV2rGmDoDXMjUjIfJ npGph3iSxyr/u5wr0QYk2OYn4JrHDiK6YfbbkFcgqTD19u4cr7nbNjkSB A==; X-CSE-ConnectionGUID: p29IMcclQYWjQo9Z+tZDMQ== X-CSE-MsgGUID: W9BSvO+ZQHO19tGQ1CPmMA== X-IronPort-AV: E=McAfee;i="6700,10204,11392"; a="44677170" X-IronPort-AV: E=Sophos;i="6.15,182,1739865600"; d="scan'208";a="44677170" Received: from orviesa008.jf.intel.com ([10.64.159.148]) by orvoesa112.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Apr 2025 07:12:06 -0700 X-CSE-ConnectionGUID: /6ispDT8SpOk7w4yB2GJ6A== X-CSE-MsgGUID: lAG+bcylS1i0085DR92eIg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.15,182,1739865600"; d="scan'208";a="127620423" Received: from orsmsx903.amr.corp.intel.com ([10.22.229.25]) by orviesa008.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Apr 2025 07:12:06 -0700 Received: from ORSMSX901.amr.corp.intel.com (10.22.229.23) by ORSMSX903.amr.corp.intel.com (10.22.229.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.14; Wed, 2 Apr 2025 07:12:05 -0700 Received: from orsedg603.ED.cps.intel.com (10.7.248.4) by ORSMSX901.amr.corp.intel.com (10.22.229.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.14 via Frontend Transport; Wed, 2 Apr 2025 07:12:05 -0700 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (104.47.56.169) by edgegateway.intel.com (134.134.137.100) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.44; Wed, 2 Apr 2025 07:12:04 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=kIwx723fmq7F+fbrMo2EBOnoEuBR9o2GSev/KMXEM0fvcinci0hOl90iCoJ68UqllK1TdTnlsUpOITgMRAh+X6rpBY6rhOnTKzqQMBrJKlttSsT3ldEdbKmN3Quhxa/m21zveWxl1BUytXo4+GhFx+9NG/KcJ/OZBJeE9NpvVGY92c0AuVtVXwC9erue2m50U8Fta351VTA1Gqp8m362VAe/qT8wFzxAj0QbmsEHC3eXEhXxnJghQ8Eb4nzO3NuYmV+tXik5F0yT5jF0SZsdwgehxEDTDlQ5dvoZXMLqmx2ZiaEHlNTWF2Wnd/qJpXg78ol/ZhSAD5pITCHOgb9MpQ== 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=4ueZT6TffxGJQiUqEov+JWnO8IZEZetcax/CaDTXGnk=; b=PPVAacLHfX+xITP1iSFRWm2ojeX5AY7sGKOqEYJvR8k1WX3Tr7vByIEDJOOuzXhwbx/ML3Pb8Pxh3bZ2Ap1XjHz57+r+x1dWegQvqp32l/GWSZLqPyEV6T7nuMuDZY9k5PoYCRZzinA2GpiO8DI3XSDaf5XQo/KFeMM68TXzDEHt9EYaTeeXA1UnUDyFoW2u+f02aGJusAYzQuTXtz9rvN6u3AFO0qmeal+375ul440dunTB/k0AYmPuHRMH2UZt1/lIHZZMZP+xX6pjECZTK3x38F7dHtQPwxOaaah8BMdqGjVZP9gN5s+CxVTi5Cod7V7I563sH3HfATm5Z/iX9g== 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 SJ0PR11MB5213.namprd11.prod.outlook.com (2603:10b6:a03:2da::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8534.48; Wed, 2 Apr 2025 14:11:55 +0000 Received: from DM4PR11MB5373.namprd11.prod.outlook.com ([fe80::927a:9c08:26f7:5b39]) by DM4PR11MB5373.namprd11.prod.outlook.com ([fe80::927a:9c08:26f7:5b39%4]) with mapi id 15.20.8583.041; Wed, 2 Apr 2025 14:11:55 +0000 From: =?utf-8?q?Micha=C5=82_Winiarski?= <michal.winiarski@intel.com> To: <linux-pci@vger.kernel.org>, <intel-xe@lists.freedesktop.org>, <dri-devel@lists.freedesktop.org>, <linux-kernel@vger.kernel.org>, "Bjorn Helgaas" <bhelgaas@google.com>, =?utf-8?q?Christian_K=C3=B6nig?= <christian.koenig@amd.com>, =?utf-8?q?Krzy?= =?utf-8?q?sztof_Wilczy=C5=84ski?= <kw@linux.com>, =?utf-8?q?Ilpo_J=C3=A4rvi?= =?utf-8?q?nen?= <ilpo.jarvinen@linux.intel.com> CC: Rodrigo Vivi <rodrigo.vivi@intel.com>, Michal Wajdeczko <michal.wajdeczko@intel.com>, Lucas De Marchi <lucas.demarchi@intel.com>, =?utf-8?q?Thomas_Hellstr=C3=B6m?= <thomas.hellstrom@linux.intel.com>, Maarten Lankhorst <maarten.lankhorst@linux.intel.com>, Maxime Ripard <mripard@kernel.org>, Thomas Zimmermann <tzimmermann@suse.de>, David Airlie <airlied@gmail.com>, Simona Vetter <simona@ffwll.ch>, Matt Roper <matthew.d.roper@intel.com>, =?utf-8?q?Micha=C5=82_Winiarski?= <michal.winiarski@intel.com> Subject: [PATCH v7 4/6] PCI/IOV: Check that VF BAR fits within the reservation Date: Wed, 2 Apr 2025 16:11:20 +0200 Message-ID: <20250402141122.2818478-5-michal.winiarski@intel.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250402141122.2818478-1-michal.winiarski@intel.com> References: <20250402141122.2818478-1-michal.winiarski@intel.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-ClientProxiedBy: VI1PR09CA0127.eurprd09.prod.outlook.com (2603:10a6:803:12c::11) To DM4PR11MB5373.namprd11.prod.outlook.com (2603:10b6:5:394::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM4PR11MB5373:EE_|SJ0PR11MB5213:EE_ X-MS-Office365-Filtering-Correlation-Id: 61fcf376-a4f5-41e2-7227-08dd71f052cf X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|1800799024|366016|376014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?ufhGVpa7mHYRNz81qaf3tKUzjE2xGST?= =?utf-8?q?fWTyURAntC8anJ4jWfJDqS37ne7Vt9pSD1AJFR4KD00euG0LON3/O76PR0yiJhGYE?= =?utf-8?q?u2XLPrqIKMboZUvlvj25QWvt0hV48ZXYjMboTSbzV3SiZw/AE1eJQKi7DUkLVr0CI?= =?utf-8?q?1NKUzbDyI3IOzAYocShW+82/tl2bDPQzgPBHbPy8EweIBTNiB39E9TAH+J1PJKlnr?= =?utf-8?q?6LucAr3KNQpJIEkSPjgyM+jqELT+JBzvHsqLL6+qaJ6dWiLrVxggOD3DkQrQz98ir?= =?utf-8?q?jY/2Ck8UrZD9kIrynNp5lTOSdYusg7JdvLlwdRkX27EPyasmOjysqXy7HJ+i/im3O?= =?utf-8?q?x9hJUMAZFkNrpOpaMqWyMyAS1ZEKzE6h8mFwhEyeVnJwcSznc/KJTRcT63Wk16DTo?= =?utf-8?q?Cja3QREjkguir8tK+OnZvFAhnzK7pEKGssCFYwSuX/MFm8T+2M3N1LF+aDUPbCNIg?= =?utf-8?q?B5EF1KpICjWaa3w6x65tNgX90n3uZtzQVP/p/Wxb2iLwmhYhQWdoebYnnctroRBTo?= =?utf-8?q?nCFkUul48pSK25v3w6FR5GuVmaKSerGyOcbnyq1DCC7XMY06FB0l6lX6wCjnqBz7R?= =?utf-8?q?deZjmiXYPJ5LSs4tbd4eTNo5k8o3RzrVfzCx7UlXIpscO0Z027JMZc4OtSsQwV+Q4?= =?utf-8?q?MxLjldyh0BZij1b5NqADV16qWWpNX9JG3Sd0U23dBIjfM7NU/X8W/sgc6hb7d+LDM?= =?utf-8?q?NM25s1LS03xysCAmfYyvtglK9pev4o3rCzmRVd3EBlL7dSgCXsRP6m7b0bSROhkLx?= =?utf-8?q?lZdqewfHa4sRJOqutnW6i9UHHqQs40EglcNT+bi8xuav2A4Ja/9TEZAyf5IRfvpH1?= =?utf-8?q?BWiR7A1iX1jJqwK/dj+ddUvdSvzm2PCOHAM/qYKRZXW5HBbH7d7xo8IRdc9rCZzGr?= =?utf-8?q?BAYn54IE1DAn9PUQ4SfNART3sCgTRy/a0CcuazUaS+mt/GsDBtqI//BTKxP+hBPFv?= =?utf-8?q?/PsJxjsnTCwEUP8N0nD21d3Q+E8xphmgVpj2qNAY2r9H/fGGQCn+g1IEzaGVJSaKE?= =?utf-8?q?6p+KMvU6NaAV2P7NK5N+raAGsk6Nw1vBcgctYx8wQDI13cRUnR873ZugMrFPdd0Lz?= =?utf-8?q?8QZLJ9eE95w7BsHqs1/mW8iK94By46mEf9bVnsDWLtHf9SQQyXa/JhsJVlj52rLG6?= =?utf-8?q?RFc9uXIlwavBVAzm66WYQrhaHkhxR1qlGsscAIhQjpwLBVBhXt44MoulVxPwpSxCP?= =?utf-8?q?7M/lnXl9aOwHDRyUdZzeVClOIrsdrRkD0U05z219LmHuXjj6WIa8YxQfj57/tQo3e?= =?utf-8?q?yEwMiRUhQNkmas5Gy4cBdKexa2q9dZ1PTxXnUD28WJwdzKaVSfObzKkYmYJyNT0oN?= =?utf-8?q?FnB8Qu68ttr/?= 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)(1800799024)(366016)(376014); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?JGnWCPhlMNsXlnrCs7xByGu4qeeH?= =?utf-8?q?3/KIJLboyXhkFHqQhiwqnPwzZqhebIdOtCbiUu/OC4HsbUH+jHaQ5Q8RS29oQItkA?= =?utf-8?q?CUsao9WvN1i+GXAAohfRtU7Ul9c5VgdEhTQ0jisAKO72eg7cpI0Se0QbcD1zANr2H?= =?utf-8?q?+uKeqR73pOJ7vnyDYcY5c9WWHbH+PH4V8+qjcQyjhb5zqltQgQlKHKA9wj5fzkUGq?= =?utf-8?q?w5V3KHURR7BS474oDU3FFwOBp6ArSD1viPUN1SfFPE/1dElACSTeuskt1YsiydzjO?= =?utf-8?q?HBrs4+47rhsPJ1ehlje44F60dm3ZMH9E1gt4lWyA8BN+HuJKPQ3cLlICjby7GstmW?= =?utf-8?q?Fg2lx7wueo72e+i97YOMXiFrhEyYEwE8Xq/oZGjdKLMPtDx2ekBAFlWJtxJesnBld?= =?utf-8?q?FJZfZzxYwwsxP/JTxYb2RVi2CdfvO/cvaP55RR4pbS+kd6quHfpHsaDsBsqhN3NHY?= =?utf-8?q?ZCePx1c2xjTd95EW/iqt3Y8Vo9gGKecDUu11zljPJF+9RME4vfh2aNIat1kVWv1qQ?= =?utf-8?q?7QJUC7t5ddFY/ypIV4IYBHg9hnafoVERUYDoM/XJCwsHrG+hdkAjNIx1vVTDq/cEG?= =?utf-8?q?HfdJF298eUd+rpU/fF2OC4uIXM8mv6Obivc+hltdOHzRxXGBp3qeOLk4MZ0swXgI1?= =?utf-8?q?OKcoAqFKHPTY5yVfuTDihauVYbbOm85SGW4f12t6oh94cGq7IaZsWjfEo6XTGXrDs?= =?utf-8?q?C+EPWeEEviAtvawiJ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d71f052cf X-MS-Exchange-CrossTenant-AuthSource: DM4PR11MB5373.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Apr 2025 14:11:55.5364 (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: C29O/bJfiTtbiR9YDfFR238o1GbVCTKtNnVY0J2VEc46MzeMTkt1kbu0XSDcKoQ+Ls78joeval7edU80QffA/VI2Jr6z0kREHX+28JzHV9k= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR11MB5213 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 <dri-devel.lists.freedesktop.org> List-Unsubscribe: <https://lists.freedesktop.org/mailman/options/dri-devel>, <mailto:dri-devel-request@lists.freedesktop.org?subject=unsubscribe> List-Archive: <https://lists.freedesktop.org/archives/dri-devel> List-Post: <mailto:dri-devel@lists.freedesktop.org> List-Help: <mailto:dri-devel-request@lists.freedesktop.org?subject=help> List-Subscribe: <https://lists.freedesktop.org/mailman/listinfo/dri-devel>, <mailto:dri-devel-request@lists.freedesktop.org?subject=subscribe> Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" <dri-devel-bounces@lists.freedesktop.org> |
Series |
PCI: VF resizable BAR
|
expand
|
diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c index fee99e15a943f..2fafbd6a998f0 100644 --- a/drivers/pci/iov.c +++ b/drivers/pci/iov.c @@ -668,9 +668,12 @@ static int sriov_enable(struct pci_dev *dev, int nr_virtfn) nres = 0; for (i = 0; i < PCI_SRIOV_NUM_BARS; i++) { int idx = pci_resource_num_from_vf_bar(i); + resource_size_t vf_bar_sz = pci_iov_resource_size(dev, idx); bars |= (1 << idx); res = &dev->resource[idx]; + if (vf_bar_sz * nr_virtfn > resource_size(res)) + continue; if (res->parent) nres++; }
When the resource representing VF MMIO BAR reservation is created, its size is always large enough to accommodate the BAR of all SR-IOV Virtual Functions that can potentially be created (total VFs). If for whatever reason it's not possible to accommodate all VFs - the resource is not assigned and no VFs can be created. An upcoming change will allow VF BAR size to be modified by drivers at a later point in time, which means that the check for resource assignment is no longer sufficient. Add an additional check that verifies that VF BAR for all enabled VFs fits within the underlying reservation resource. Signed-off-by: Michał Winiarski <michal.winiarski@intel.com> --- drivers/pci/iov.c | 3 +++ 1 file changed, 3 insertions(+)