Message ID | 20250402141122.2818478-5-michal.winiarski@intel.com (mailing list archive) |
---|---|
State | New |
Headers | show
Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.20]) (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 365D523BD09; Wed, 2 Apr 2025 14:12:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=198.175.65.20 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743603132; cv=fail; b=U30KhLeoXS+QDufKxEDUhKItd7XRE+CfICzXAMKascpzdG3+TLHwOpPyaW7gd5CzBgVUW1bhgXSqNhG2bePvs5/tXt6+dxwOHbT3JJhGvTCPgStO0ULqAfDD7IeIf9K9HiS8vxpgHdB6wBLb1JdCvCmBcXgqPsG39FDseeWpj8Q= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743603132; c=relaxed/simple; bh=luDF2Sdx2KVSQ5m4lKqpObI9udJNMyroUb4ugSNNWFg=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=qdWXNzhDPduwNAM8EoXi3YgQVTl+O733sUN9bab6KlUJS8gV0UYAsIcG0wNXBiE0ISbQZqnlMTr7MRskXBa9VxVTlGW4O+AIj7jmWvefQ4Dm6aL9r0EJ6/bT2iNX4Nz03qUPfjgv6ykz9XXgmqXyd5TP6wPIEUD1CQoOKLwHb90= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=H3L7fjqo; arc=fail smtp.client-ip=198.175.65.20 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="H3L7fjqo" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1743603130; x=1775139130; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=luDF2Sdx2KVSQ5m4lKqpObI9udJNMyroUb4ugSNNWFg=; b=H3L7fjqoTrAV8Q6B2RqtrcFIfd6Pxcng31txOLc47vkbmcRvG6ji+/Dj bhOQn11cNXRqi3c+ZkVjXWjBnakRZODRADgWEukjD7GCsjSD2KV5uAx6y 4pBLK0m54HFaNdAa6XC3Hs8qzBN7LjCSU/48BWTMl7Hk103Ayz/vnN9m2 nImsp9vFaxrPCyDjrndSBknWdl5yTOR+LaYqRa/9qF5CooZIU9vQDcwis efZpqNCTHYTIoIwF0vroEXHStjwWEoTIP/LBT3aEuOBNk19SFc4S2VHBZ 519CJU9oUmluvgN5NY2MOPh69A30w3T7HPFmI0HwJqx3KtigmH+fS1gfe w==; X-CSE-ConnectionGUID: UG7jwhUhTVe46RVEfeUWKA== X-CSE-MsgGUID: sqMswkzoRYO95AfdzxUHTw== X-IronPort-AV: E=McAfee;i="6700,10204,11392"; a="44677164" X-IronPort-AV: E=Sophos;i="6.15,182,1739865600"; d="scan'208";a="44677164" 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) Precedence: bulk X-Mailing-List: linux-pci@vger.kernel.org List-Id: <linux-pci.vger.kernel.org> List-Subscribe: <mailto:linux-pci+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-pci+unsubscribe@vger.kernel.org> MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: 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-Antisp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COHAM/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+qjcQyjhb5zqltQgQlKHKA9w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O79VtytAu?= =?utf-8?q?d84QTgpTvTJv7rz7rKSFek0vObBzw6qI/lGDl/Qmc5LkhkfvkNHx226opLHmTutLy?= =?utf-8?q?a1kGA7Z+VYQvQhBlMqGCXWcj/p6uGhv0EIYcPpk6JmgoCZ7rwa7fHlhNBKi3TzI4T?= =?utf-8?q?MHUUvBdup6is5ptqjEEZXT9kS+YQLq0/F1L+PByj1XuIRkOhTYf7LBPP53xezYwu+?= =?utf-8?q?fzMfmCvZuVvLTg255yBL99kiXrrxoQzV32L5D1FzsEdNfER0lvgRLzUPRb8QhIX8C?= =?utf-8?q?aUe1s0fIW3Xjshu1pzC2mka//TXdK9Ps3ak1I6vbdYJp/8EqWepmqZ2aDsdxjWnGc?= =?utf-8?q?REoP4bB47lqa9xIUI1k8FXy4uAm++NCnGLTXFENLtDxoJbLl+vy8fucwTxEdosXpe?= =?utf-8?q?5Mt4lnebv68xkOiD8wai33zLFpJkLgdU/QXBK7DybrUSJCvJZsuiBoKiZR8dY2W46?= =?utf-8?q?fagAitkrnIph9Gu68Pt1/WuVhGlhfSUWjw=3D=3D?= X-MS-Exchange-CrossTenant-Network-Message-Id: 61fcf376-a4f5-41e2-7227-08dd71f052cf 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 |
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(+)