From nobody Wed Nov 27 15:32:26 2024 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.16]) (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 E82491C3F04; Thu, 10 Oct 2024 10:32:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=192.198.163.16 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728556352; cv=fail; b=lM57xR/FbUIVwc9WuWB6Fgl2VUDHoCc8qSN6HYSkYnQ5dnla4qiVdYkdcZPTIWGuA3qgjzJU5VDWAMr1RS8437SVtjfEj8DkDDIF14fsGhwUmKJgy3YZsNGtSnYynCksTCx1vCUfxFkV12H6XRR5UBgo6JZcNCW7ijoKd4fn8v8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728556352; c=relaxed/simple; bh=wLcAo1WhV3XHKAuXQH8tJQ1yh9wGo3PPw0FqfBgmVgg=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=A3Ye95+OxmzGjatuxWcbhWkO3LWAG29xpf7lUX9k7AQqahvOub+pTyUKPn/EQNkrpkoQn69p8EH88x4UWx0LgfC5FIgYpwtzMTiOgR67zmfBjyaN44ovsIMRq+pOrD58/rBHMwaTEHSsZDL0NeUr83Rb7TLNNIIi0XsWdChA7JY= 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=hNrhFGg4; arc=fail smtp.client-ip=192.198.163.16 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="hNrhFGg4" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1728556351; x=1760092351; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=wLcAo1WhV3XHKAuXQH8tJQ1yh9wGo3PPw0FqfBgmVgg=; b=hNrhFGg4M60xhFqDzqwyLTCvW4UVx9jPefNoHmoULmCw2us0XiijZaN2 nZ/5UWHJ8iZsqWzYDE9vRD69A45lSoezcWivfpY0oPpdWWlP6ZXb+B05A XgCno2QlC5I+FA7ZFMBpMAdnQx8zBzO1r6nmXVfv+v9ztz8+M4yshRQ1x 6JufdGf90SoLhqNYh1jFFqwiPjv/ZQl9v1CAVyW6gsRX9wijZCmMZ5Opj PWliO+wPRsmE9/ikVsczVSYNEcWrF2+PfxxLaCptUA2yDi0Zg5o9mzr8K qkUy0RJXl65YJNGzMF/eVzvMs8X44WO97LtMXUAbBbA3owlLRRsqWR6dI Q==; X-CSE-ConnectionGUID: sZkIizx9SqiaZOYNSPi2SQ== X-CSE-MsgGUID: 7xN1JE7jSmeDE0U0jULHGg== X-IronPort-AV: E=McAfee;i="6700,10204,11220"; a="15528475" X-IronPort-AV: E=Sophos;i="6.11,192,1725346800"; d="scan'208";a="15528475" Received: from orviesa006.jf.intel.com ([10.64.159.146]) by fmvoesa110.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Oct 2024 03:32:30 -0700 X-CSE-ConnectionGUID: nnlrErOJRmWMOTj/MwP17Q== X-CSE-MsgGUID: +GrUhSX4QsqxkK+YowOn0g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,192,1725346800"; d="scan'208";a="76751669" Received: from fmsmsx603.amr.corp.intel.com ([10.18.126.83]) by orviesa006.jf.intel.com with ESMTP/TLS/AES256-GCM-SHA384; 10 Oct 2024 03:32:30 -0700 Received: from fmsmsx612.amr.corp.intel.com (10.18.126.92) 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; Thu, 10 Oct 2024 03:32:29 -0700 Received: from fmsmsx602.amr.corp.intel.com (10.18.126.82) by fmsmsx612.amr.corp.intel.com (10.18.126.92) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 10 Oct 2024 03:32:29 -0700 Received: from FMSEDG603.ED.cps.intel.com (10.1.192.133) 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 via Frontend Transport; Thu, 10 Oct 2024 03:32:29 -0700 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (104.47.58.47) by edgegateway.intel.com (192.55.55.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Thu, 10 Oct 2024 03:32:28 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=yIAtwStontmQGMXV2b7+lIjnVS1toR+NRV9NlrJCA79su1Jffd5ua1cPP46GilFQTc60hXXhxvssQAgsK6f7gO5p5UgxkqeQBmpIS+GLsHrEtRg1yLsPUJpbXLc8KOjLY7jl8Gb7NBqw58NpupjSRiu1S/tReyr2ZNjvNY3boBp80RVB5rKVEGxn6yJ0sgmJz4y6cx+gYYqpwTwMUayTn/J8WcHTCQyLNiENUVCWp66LeghpR/l4tIKVON8552usiaYV73+su1hVkwJ2Wf1tV6dFvN0wPLwHf0NAUFc0QIpRfFJ199Fq7XiOSt47JPYeZUaqfDXadEuJb6VeNE2Rrw== 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=E+gdPjlhdRoa/icp7FwuL0+xbBgzz7H41qTyybjcdLY=; b=EjQlCoXc41qwCJ76l/LAwdOk9WM+5ru+24pJNOtiS9eNtNdN7peF94Skk1x4/yVShCwlY3KzDegbIhTpev3DsxzuvNlINQ9uk7EAAVbkoztTQaqEcr5nVW8KWDx0MaJutcCWulDrLj7KuFgzdfmOGXqIPNCYzTYGdNI+3FbNMSuL9Xh28s3yHdyoT/jlzJdDtT9zj/x0P79joPAhCTjnPImyxqweQZcsETHweQuiXUy0A6a+HsgqGvQ6yERziRBnw32m8Otr3dN/fWeF/7Vun0aRBvPmw9nWdzjJDE6VuWtKzSZRLt27eoNuv/O/DLU4ccZBM1+9nzEVB5fg3vfG7Q== 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 MN6PR11MB8103.namprd11.prod.outlook.com (2603:10b6:208:473::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.22; Thu, 10 Oct 2024 10:32:27 +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.8048.013; Thu, 10 Oct 2024 10:32:27 +0000 From: =?UTF-8?q?Micha=C5=82=20Winiarski?= To: , , , , "Bjorn Helgaas" , =?UTF-8?q?Christian=20K=C3=B6nig?= , =?UTF-8?q?Krzysztof=20Wilczy=C5=84ski?= , =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= CC: Rodrigo Vivi , Michal Wajdeczko , Lucas De Marchi , =?UTF-8?q?Thomas=20Hellstr=C3=B6m?= , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Matt Roper , =?UTF-8?q?Micha=C5=82=20Winiarski?= Subject: [PATCH v3 4/5] PCI/IOV: Allow extending VF BAR within original resource boundary Date: Thu, 10 Oct 2024 12:32:02 +0200 Message-ID: <20241010103203.382898-5-michal.winiarski@intel.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241010103203.382898-1-michal.winiarski@intel.com> References: <20241010103203.382898-1-michal.winiarski@intel.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: WA2P291CA0007.POLP291.PROD.OUTLOOK.COM (2603:10a6:1d0:1e::10) To DM4PR11MB5373.namprd11.prod.outlook.com (2603:10b6:5:394::7) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM4PR11MB5373:EE_|MN6PR11MB8103:EE_ X-MS-Office365-Filtering-Correlation-Id: fd2b1505-1539-41b3-3a73-08dce916d5f8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|7416014|1800799024|376014; X-Microsoft-Antispam-Message-Info: =?utf-8?B?MTllWlBXcTJjNFFwK25MYnlSd0hPUHFGaGVNOEMxK3g2anFSdjdlUjFZeXlw?= =?utf-8?B?V0o1K1dsTi9EaXplUVJ4UmJDRk1PRDVTZXliWUFWdzQ3UThyc0dsdncweFJs?= =?utf-8?B?VEJCWVA1TStLYjg0MWhic2tLdFNpelVQSkJZZVpsN1ZzbnFuLzZadFhsUmcz?= =?utf-8?B?VWFPKytnVjU2MiszdkxCQUg5QTMra1lOZHZXN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Gd4YklZT3RQL1UrMlBrUGQ1dHMycjlnMFdVK1dvL3pKTy91?= =?utf-8?B?ZUg4dEgrdmU0UzNVa3VQMXpCMk5KV3BOdDloM3V4U2xrSjJLY1I0dlZjZVJl?= =?utf-8?B?M291QzBMWmpSV2hwS25EYU5rL0VuMnhkTVQwOHdqSW9PR2I3KzNLdGZhWHdp?= =?utf-8?B?Uk9WUzhWVGxSSkdtaGtDalgvVncwQk9WNm9uYjJkWnNxYUtrQnd3blMyRnRZ?= =?utf-8?B?RUZhc2RMc3hxNkdOUElRdklrNUgrZTJ3em5zQ2FOUlJpTityTDdHR01yd1Zn?= =?utf-8?B?eERubzEra3ZmYlFlUVJkWEc5cCtSemJ2RkVCQ0pYU3d2M3RTRVpiRDJWV2RE?= =?utf-8?B?U3Nnc2V6OE9MamlLc3l1Qkp1MDR1Y2FPZW1iRnRONXUvSXdoYWYvR2tjcGc4?= =?utf-8?B?Y2w5T00raDk2MnRrZk52UDdrdU9YQU9CN0dPY242RlVJVmdWMzYvajMwemV2?= =?utf-8?B?MEFYMFl1OXpoM25OYlcvNHY1RkpFbHNJT0doTDlvQnNGSWc5cnFOejFqQkRy?= =?utf-8?B?MW95VGI2MS85MnV1dUJRZ2dpcVp0ZXhPRmpPWktMUGk5M2QwZGhnNmhWSEtk?= =?utf-8?B?dytSNTNPU3NPdmhUSmMwL2xEbFRJOW9zVGQvSGpUcXFtUGpXS29ERHl3PT0=?= 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)(366016)(7416014)(1800799024)(376014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?RmxreDVKczZRQUljM1BNelhIUHQybkM3cm1wa3RxUlk0MXNlaEtrMmdTaDhm?= =?utf-8?B?ZHpON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hkaGk5VnBPTmt1Uk80dnNT?= =?utf-8?B?Z2s3REZNcHlxeUNlQW1FalFaSnU3N0NXaEx6RnBqTW5BZjk1ZkNneTBmS2JQ?= =?utf-8?B?dmdjMlpBNWUybnIzZDZ3czNBVkdCc1AyNmRtbTlCZmJ3U0lXdDlQMXZZOHUr?= =?utf-8?B?NlBRcjNTbnBvelgrY1Q1NnJEL1FGVFNmVlQyU2JGS3dSbHVmSi96Y3U3OXZx?= =?utf-8?B?S3VCQldsMFI4aFEveEp0WGxNQjlHR1RLWVBOVm9ZNnd5aEdyTmtDbkVWdjF6?= =?utf-8?B?emVDaEhKZGt3UmNCT1JwNWwxM3ZlQ1pTNGhVR3JFdFRWWWRjdDlZVnkzbFMz?= =?utf-8?B?eXc9PQ==?= X-MS-Exchange-CrossTenant-Network-Message-Id: fd2b1505-1539-41b3-3a73-08dce916d5f8 X-MS-Exchange-CrossTenant-AuthSource: DM4PR11MB5373.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Oct 2024 10:32:26.9304 (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: vQajWpZPgQEaOzB4W+4QVDJUsgSbCSqZKVEToILOHmRb6XhTswaKf3DRUmo3/ADMdKCtnu4dJ71m2UeUj9qhSKS2B9MYar/f51CfGblxMDA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN6PR11MB8103 X-OriginatorOrg: intel.com VF MMIO resource reservation, either created by system firmware and inherited by Linux PCI subsystem or created by the subsystem itself, contains enough space to fit the BAR of all SR-IOV Virtual Functions that can potentially be created (total VFs supported by the device). This can be leveraged when the device is exposing lower than optimal BAR size as a default, allowing access to the entire resource when lower number of VFs are created. It is achieved by dynamically resizing the BAR to largest possible value that allows to fit all newly created VFs within the original resource boundary. Signed-off-by: Micha=C5=82 Winiarski --- drivers/pci/iov.c | 92 ++++++++++++++++++++++++++++++++++++++++++++- drivers/pci/pci.h | 1 + include/linux/pci.h | 3 ++ 3 files changed, 95 insertions(+), 1 deletion(-) diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c index 591a3eae1618a..f9071c1cfe9ee 100644 --- a/drivers/pci/iov.c +++ b/drivers/pci/iov.c @@ -174,6 +174,86 @@ bool pci_iov_is_memory_decoding_enabled(struct pci_dev= *dev) return cmd & PCI_SRIOV_CTRL_MSE; } =20 +static void pci_iov_resource_do_extend(struct pci_dev *dev, int resno, u16= num_vfs) +{ + resource_size_t size; + int ret, old, i; + u32 sizes; + + pci_config_pm_runtime_get(dev); + + if (pci_iov_is_memory_decoding_enabled(dev)) { + ret =3D -EBUSY; + goto err; + } + + sizes =3D pci_rebar_get_possible_sizes(dev, resno); + if (!sizes) { + ret =3D -ENOTSUPP; + goto err; + } + + old =3D pci_rebar_get_current_size(dev, resno); + if (old < 0) { + ret =3D old; + goto err; + } + + while (sizes > 0) { + i =3D __fls(sizes); + size =3D pci_rebar_size_to_bytes(i); + if (size * num_vfs <=3D pci_resource_len(dev, resno)) { + if (i !=3D old) { + ret =3D pci_rebar_set_size(dev, resno, size); + if (ret) + goto err; + + pci_iov_resource_set_size(dev, resno, size); + pci_iov_update_resource(dev, resno); + } + break; + } + sizes &=3D ~BIT(i); + } + + pci_config_pm_runtime_put(dev); + + return; + +err: + pci_warn(dev, "Failed to extend %s: %d\n", + pci_resource_name(dev, resno), ret); + + pci_config_pm_runtime_put(dev); +} + +static void pci_iov_resource_do_restore(struct pci_dev *dev, int resno) +{ + if (dev->sriov->rebar_extend[resno - PCI_IOV_RESOURCES]) + pci_iov_resource_do_extend(dev, resno, dev->sriov->total_VFs); +} + +int pci_iov_resource_extend(struct pci_dev *dev, int resno, bool enable) +{ + if (!pci_resource_is_iov(resno)) { + pci_warn(dev, "%s is not an IOV resource\n", + pci_resource_name(dev, resno)); + + return -ENODEV; + } + + if (!pci_rebar_get_possible_sizes(dev, resno)) + return -ENOTSUPP; + + if (!enable) + pci_iov_resource_do_restore(dev, resno); + + dev->sriov->rebar_extend[resno - PCI_IOV_RESOURCES] =3D enable; + + return 0; +} +EXPORT_SYMBOL_GPL(pci_iov_resource_extend); + static void pci_read_vf_config_common(struct pci_dev *virtfn) { struct pci_dev *physfn =3D virtfn->physfn; @@ -438,7 +518,7 @@ static ssize_t sriov_numvfs_store(struct device *dev, const char *buf, size_t count) { struct pci_dev *pdev =3D to_pci_dev(dev); - int ret =3D 0; + int i, ret =3D 0; u16 num_vfs; =20 if (kstrtou16(buf, 0, &num_vfs) < 0) @@ -480,6 +560,11 @@ static ssize_t sriov_numvfs_store(struct device *dev, goto exit; } =20 + for (i =3D 0; i < PCI_SRIOV_NUM_BARS; i++) { + if (pdev->sriov->rebar_extend[i]) + pci_iov_resource_do_extend(pdev, i + PCI_IOV_RESOURCES, num_vfs); + } + ret =3D pdev->driver->sriov_configure(pdev, num_vfs); if (ret < 0) goto exit; @@ -874,8 +959,13 @@ static int sriov_init(struct pci_dev *dev, int pos) =20 static void sriov_release(struct pci_dev *dev) { + int i; + BUG_ON(dev->sriov->num_VFs); =20 + for (i =3D 0; i < PCI_SRIOV_NUM_BARS; i++) + pci_iov_resource_do_restore(dev, i + PCI_IOV_RESOURCES); + if (dev !=3D dev->sriov->dev) pci_dev_put(dev->sriov->dev); =20 diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h index e15fd8fe0f81f..57e79f75e4c8f 100644 --- a/drivers/pci/pci.h +++ b/drivers/pci/pci.h @@ -403,6 +403,7 @@ struct pci_sriov { u16 subsystem_vendor; /* VF subsystem vendor */ u16 subsystem_device; /* VF subsystem device */ resource_size_t barsz[PCI_SRIOV_NUM_BARS]; /* VF BAR size */ + bool rebar_extend[PCI_SRIOV_NUM_BARS]; /* Resize VF BAR */ bool drivers_autoprobe; /* Auto probing of VFs by driver */ }; =20 diff --git a/include/linux/pci.h b/include/linux/pci.h index 573b4c4c2be61..023c0fa1dd9f2 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -2371,6 +2371,7 @@ int pci_sriov_set_totalvfs(struct pci_dev *dev, u16 n= umvfs); int pci_sriov_get_totalvfs(struct pci_dev *dev); int pci_sriov_configure_simple(struct pci_dev *dev, int nr_virtfn); resource_size_t pci_iov_resource_size(struct pci_dev *dev, int resno); +int pci_iov_resource_extend(struct pci_dev *dev, int resno, bool enable); void pci_vf_drivers_autoprobe(struct pci_dev *dev, bool probe); =20 /* Arch may override these (weak) */ @@ -2423,6 +2424,8 @@ static inline int pci_sriov_get_totalvfs(struct pci_d= ev *dev) #define pci_sriov_configure_simple NULL static inline resource_size_t pci_iov_resource_size(struct pci_dev *dev, i= nt resno) { return 0; } +static inline int pci_iov_resource_extend(struct pci_dev *dev, int resno, = bool enable) +{ return -ENODEV; } static inline void pci_vf_drivers_autoprobe(struct pci_dev *dev, bool prob= e) { } #endif =20 --=20 2.47.0