From patchwork Wed Apr 2 14:11:22 2025 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: 14036087 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 BB9C123C8C1; Wed, 2 Apr 2025 14:12:12 +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=1743603134; cv=fail; b=iHDfW7LHYTVIzG4r5EltX/SS61EwG2H283S9DyZodySmB4BY38DtcMYKzRZvO08rVz6e5k9DXmqMFKVypVeJZXEZMtZe107k70mCThDpbz683fsaLDYy8B8IwAeaTK9FIZEbtNNiWZtwTCIzlWv2Z8BDl/uExE3dqvNQPRzpVPU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743603134; c=relaxed/simple; bh=yQvZm0Ga/hRwG31Kw3v5uaPPK1j+cEzIWVk6JP2lqn0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=uAtBwSAdGkAUsuEhDWrF7VX/Poid2wXmJPy4VBqQLTc4TvCSx+K4TZTwa7pQRAi6pz+k8SWmxGyDSzJiIpOy0nULGpzSCnStV+ji1ytF/tLTyJA0xYjemayUDX8DVjr+1FJ/LFB5Dyh81qNg/GjEVhJ1vcUWkmhraA0RxigBHas= 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=U5AQtR1g; 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="U5AQtR1g" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1743603133; x=1775139133; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=yQvZm0Ga/hRwG31Kw3v5uaPPK1j+cEzIWVk6JP2lqn0=; b=U5AQtR1ghAHY2uRvHPGQX790CIJIRzSXy+fb34BBhPUndaDUTKqMLK9t 1yr2IG3h9uWBoOvG6zpzUk40LuLmD/ih5bpolUlLjJ+xCXQGfaE7n+WHU rrEXSWeKhvjwW4K3cXyBRoGmyyaXkp5fYNwsLmca6ZizCVwDEFXjdK/fS 7S/O/fscwbgVCYg3B4kDi/tv4Qz9dxDtbVyVxvdltW7/f6RH+YBFyQoKS 8Tn64vvf7y+1WpYLPz1G92MisKsidkAg9i3u4KxIcHi1ncEG2jCgnLUSm GOqcyHK/z1PD5GxlXO/zdlnuQm1sgojv5GOwELX385k28Eu2IQ1LqNpFu w==; X-CSE-ConnectionGUID: ReiBacNNTN6XoIuzR43oiw== X-CSE-MsgGUID: HlOXtP4jTp2CK0/PAeBfrQ== X-IronPort-AV: E=McAfee;i="6700,10204,11392"; a="44677207" X-IronPort-AV: E=Sophos;i="6.15,182,1739865600"; d="scan'208";a="44677207" 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:11 -0700 X-CSE-ConnectionGUID: RzTMhvfxTI2VTbHOwgS1lQ== X-CSE-MsgGUID: KgabNgITTXqDLSFgD8V2sA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.15,182,1739865600"; d="scan'208";a="127620443" Received: from orsmsx603.amr.corp.intel.com ([10.22.229.16]) by orviesa008.jf.intel.com with ESMTP/TLS/AES256-GCM-SHA384; 02 Apr 2025 07:12:11 -0700 Received: from ORSMSX903.amr.corp.intel.com (10.22.229.25) by ORSMSX603.amr.corp.intel.com (10.22.229.16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.44; Wed, 2 Apr 2025 07:12:10 -0700 Received: from orsedg603.ED.cps.intel.com (10.7.248.4) 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 via Frontend Transport; Wed, 2 Apr 2025 07:12:10 -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:07 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=h1AqI5xuwYj8OR6A7SuhYFwdIe1ILFDdGaf9Gl7M/DEgD3vZZ7de5EBcIVU7l7zIglrJjQ5leYwdVzoc9sEdfFi1pNM3cTttwgl9tl46Z0qX4nEHgfUrWBQsWHxHj4lIl0ozz3n376G9zd8JPsgZlTImhBcd/aGTKg7B7Q/rEkl6apU0T5qKyYoZtZbFaVJVKoT0lTcS1/znH8b9K+0QXUtVwbN7vzzyTOuLdqH08/pOCZix7Wyc4izAU1cZDDqJ5S8FIiESuaAFnXsEnMFrwJoMYGousX4I4HsX9ri+bQG0piQ+//r7JsAlwbRzJ9y1B1jtGPvMLMqM6l52hKAB5w== 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=1plmEqMqpV8IgipC6AnDhVqIl4Yt7pMfRz3yMnlU1nM=; b=EUVtEhmg/crKukPo9pcxAaCoHs9rBpXPoNEDfWNk77ekSpRORJy4n/SXCfRBSDO2e6ukqATYRgOOpFPIBjSkTNWixuQYGJJPQYsATyRQpd8F6YrzzWJr2MJbT9TfQRm/UxrIS0OAsIyZoD8fQh1Ha+LFM9qQ5gSVH1ynp90OwG+67M55TPjQstI2i5eN504c65PwDMyi11xffhsmhy9w46xFGlboFrhyk3ldqJxgF8JjuUVwqud8vLBlBIAkPeakH1iu7hJFfYe/S3/iRb4qzIQYgUEAWXxnN02q0ikmYvII4pdUr9T9VQfBFSIQEa3oUuhqIkhtoSJNVsDRsMQ8mw== 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:12:05 +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:12:05 +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 v7 6/6] drm/xe/pf: Set VF LMEM BAR size Date: Wed, 2 Apr 2025 16:11:22 +0200 Message-ID: <20250402141122.2818478-7-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> X-ClientProxiedBy: VI1PR06CA0129.eurprd06.prod.outlook.com (2603:10a6:803:a0::22) To DM4PR11MB5373.namprd11.prod.outlook.com (2603:10b6:5:394::7) Precedence: bulk X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM4PR11MB5373:EE_|SJ0PR11MB5213:EE_ X-MS-Office365-Filtering-Correlation-Id: 4771b498-e83a-4e15-1dd2-08dd71f058a1 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?lXLfdG6w8Za+i9NmxJwkHyiDXYk38Uq?= =?utf-8?q?kSZ5kUtGcRM6QYVg8+DNraXVqVrPFzmsHouqAvZwhEOtqNdnJSeAGybdF+Pn/osJG?= =?utf-8?q?/akNiDAvIimoLDfgbrgihZl8L9AHQ0gYn34AokQEcsuG5E1nI49EThq6f1PVNXNxM?= =?utf-8?q?4urzKx5EAFaNhE7fnpjYuGC2KPdNX3DUfgK6GE1jb2KFksfGGOW0GAEjDeXL6W9PD?= =?utf-8?q?2A2YYA2aRZxN8iYpO6oZOewPfgN2NVlLjZTB8Nk4u1c2qugvh0x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HgCPJwMdXqjBgYE53OKOKBBtdE9jgtVOI3zRiuhnQFdwvsVjPaAeVuS2+bnRJpzXx?= =?utf-8?q?OjvS5WT+rrIL6w2RH0r6bZq1uuftxxym5gnMjLTLbfggdX5p1NXzX+VKwwoOyTbsY?= =?utf-8?q?YWWIieEk1D8knsYq8p1aERYS7+t8YyHYOcBbWdXVAxo1Frx5igwSRA4nLXzwIaGbF?= =?utf-8?q?lKJ9GFA/DCRk?= 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?S5VZ7a/E1jQwp+NwG9Eu3hf0Fx1i?= =?utf-8?q?t431I8AT42nBRNwkIGHuW+U2EB8pYtOyR786+5qBucppJg2fdUJzHFIjHfWa1A9qx?= =?utf-8?q?xxSxpRizyy0ea6iLwNWcvHDHw0q5CkLYmOmvto4p9JRU1PT99Sqr3+hVJ3/3ZUZ1X?= =?utf-8?q?rANGJ5dHtVf86w+MdTcd8mF2DoMImgtEOVJowb26YUvINrByJOoucOOaLQ267pw+P?= =?utf-8?q?u3x1jwuRMs4Ejwz16VoLlvnydr0IUUZ8vUpYlmImUjyoYksXtIOvvL9rdj5XZx46g?= =?utf-8?q?vcSgCoR2MXEafvgNRor3qhPSoRYH46NFAscXvZ0WkYQdycJ9xD6tkTgm4fgPZamgX?= =?utf-8?q?WZFFAUrSHKUDFUM3IDXRTUPX9ue5P8qGSwOcjMHJ5ClNRoWcmxjmwxJofDgmgPIJy?= =?utf-8?q?FR4MBIqAzpfsReiFv2it9yfqcZtFeHSvM/PR7/PScyanLqved3W/2dUX64oowFOVO?= =?utf-8?q?wXIyTc/DEk49amBeH2IgWGTaKblK0NaW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HNYEFJidFMQCJRgV6WL44dvp5YOZfpldAq?= =?utf-8?q?FCkQbrqO0IprYHWPlvvOFBgjBmSPjmZscm1MAZi2dk1ITrCRU4csa5cXF3SQtZbwU?= =?utf-8?q?Dy24KFiCCk/RGxS2WkAhzt45woUKx4ik8Wz2Kjncoqsrr7glcF2eXcfUUewXssfjy?= =?utf-8?q?pIGzlOLGoCO+3FKrpli5n8lqqEVn16eDAA=3D=3D?= X-MS-Exchange-CrossTenant-Network-Message-Id: 4771b498-e83a-4e15-1dd2-08dd71f058a1 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:12:05.1116 (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: 3EYOWMy3j+Q72q0BS9Y65m9F8EAgyzpGWvxiTm8GpINO/UfVhcvTCuTKn46lmpWissTHMeHyO5Cx0fyEIlzH39ydWKBXFE9HY2wA1MVqwAc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR11MB5213 X-OriginatorOrg: intel.com LMEM is partitioned between multiple VFs and we expect that the more VFs we have, the less LMEM is assigned to each VF. This means that we can achieve full LMEM BAR access without the need to attempt full VF LMEM BAR resize via pci_resize_resource(). Always try to set the largest possible BAR size that allows to fit the number of enabled VFs and inform the user in case the resize attempt is not successful. Signed-off-by: Michał Winiarski Reviewed-by: Ilpo Järvinen --- drivers/gpu/drm/xe/regs/xe_bars.h | 1 + drivers/gpu/drm/xe/xe_pci_sriov.c | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/drivers/gpu/drm/xe/regs/xe_bars.h b/drivers/gpu/drm/xe/regs/xe_bars.h index ce05b6ae832f1..880140d6ccdca 100644 --- a/drivers/gpu/drm/xe/regs/xe_bars.h +++ b/drivers/gpu/drm/xe/regs/xe_bars.h @@ -7,5 +7,6 @@ #define GTTMMADR_BAR 0 /* MMIO + GTT */ #define LMEM_BAR 2 /* VRAM */ +#define VF_LMEM_BAR 9 /* VF VRAM */ #endif diff --git a/drivers/gpu/drm/xe/xe_pci_sriov.c b/drivers/gpu/drm/xe/xe_pci_sriov.c index 09ee8a06fe2ed..4be566331ee15 100644 --- a/drivers/gpu/drm/xe/xe_pci_sriov.c +++ b/drivers/gpu/drm/xe/xe_pci_sriov.c @@ -3,6 +3,10 @@ * Copyright © 2023-2024 Intel Corporation */ +#include +#include + +#include "regs/xe_bars.h" #include "xe_assert.h" #include "xe_device.h" #include "xe_gt_sriov_pf_config.h" @@ -111,6 +115,18 @@ static void pf_link_vfs(struct xe_device *xe, int num_vfs) } } +static int resize_vf_vram_bar(struct xe_device *xe, int num_vfs) +{ + struct pci_dev *pdev = to_pci_dev(xe->drm.dev); + u32 sizes; + + sizes = pci_iov_vf_bar_get_sizes(pdev, VF_LMEM_BAR, num_vfs); + if (!sizes) + return 0; + + return pci_iov_vf_bar_set_size(pdev, VF_LMEM_BAR, __fls(sizes)); +} + static int pf_enable_vfs(struct xe_device *xe, int num_vfs) { struct pci_dev *pdev = to_pci_dev(xe->drm.dev); @@ -137,6 +153,12 @@ static int pf_enable_vfs(struct xe_device *xe, int num_vfs) if (err < 0) goto failed; + if (IS_DGFX(xe)) { + err = resize_vf_vram_bar(xe, num_vfs); + if (err) + xe_sriov_info(xe, "Failed to set VF LMEM BAR size: %d\n", err); + } + err = pci_enable_sriov(pdev, num_vfs); if (err < 0) goto failed;