From patchwork Thu Oct 10 10:32:02 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: 13829914 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 3C58ECF11CA for ; Thu, 10 Oct 2024 10:32:33 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id AD1CD10E8C2; Thu, 10 Oct 2024 10:32:32 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="hNrhFGg4"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.16]) by gabe.freedesktop.org (Postfix) with ESMTPS id E60D210E8CB; Thu, 10 Oct 2024 10:32:30 +0000 (UTC) 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: WnH4xYdyTEGgMyTdEtDP/w== X-CSE-MsgGUID: RRaTIIN5QnasQYIEU2KzLw== X-IronPort-AV: E=McAfee;i="6700,10204,11220"; a="15528480" X-IronPort-AV: E=Sophos;i="6.11,192,1725346800"; d="scan'208";a="15528480" 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_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 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> X-ClientProxiedBy: WA2P291CA0007.POLP291.PROD.OUTLOOK.COM (2603:10a6:1d0:1e::10) To DM4PR11MB5373.namprd11.prod.outlook.com (2603:10b6:5:394::7) 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?q?19eZPWq2c4Qp+nLbyRwHOPqFheM8C1+?= =?utf-8?q?x6jqRv7eR1YyypWJ5+WlN/DizeQRxRbCFMOD5SeybYAVw47Q8rsGlvw0xRlTBBYP5?= =?utf-8?q?M+Kb841hbskKtSizUPJBYeZl7Vsnqn/6ZtXlRg3UaO++gV562+3vLBAH9A3+kYNdv?= =?utf-8?q?W4LpBnGVKeTP/Q8utXxGOqcdPMDpRlxMT4/0ueIQ3VaRWAn70l4Sjaki2xQYPMz5m?= =?utf-8?q?QXaakpRhBtpC+8t5VcgM6fod3HKqLndNy97GPNLQh9quqMvCpOaqSr1iDMr+CiGgJ?= =?utf-8?q?3qfovwE2X63U2sLBDULN3p83Mx2rPZmb8ltyptuBGD4l2MD6U2KnCJHiNz/rS9ezk?= =?utf-8?q?QiLz8aCFiPQ+kZ09lrSI47DFP8zoarwSpaQPe75zC0MbXYc0h4NGoVkrDfw6kxB8g?= =?utf-8?q?P4TBBydADmBh8qVAdPqnwXHxoEOrVX/+9eo5vVP8gXx2cE5mIuPhnYzLDDdTehPBE?= =?utf-8?q?KJ48tVDWtDl4t/zOeG9/bPwrIPBFJNS5FO1/rOMSbZJf7hFLlYV61wYxBydVJ97Z1?= =?utf-8?q?paVviTNrJtvMMHLNWf8qAtpHYEcxSEFhLjonolJYZ9Zh1eTNB2u2QEoYYTN9Z97+w?= =?utf-8?q?S7SbPhIv47tIn17O0RSxlolQjJjolxqRWkU6yJ0/toFxu41pR+MJjPyzwWgLc5qi2?= =?utf-8?q?WW8hV5WJP0gXF1EtgO7U1fCpAPwJUaxhxgSesFNvV+CobXNulb1mZb4RabVtc7800?= =?utf-8?q?k7JnuISwNeQZQBlFR0snNoelBWl9xCQ8TUwDWNmBnYip1vOg8SI0rr1Syrd5SLUY0?= =?utf-8?q?hHsVUqfwLgxbIYOtP/U+2PkPd5ts2r9g0WU+Wo/zJO/ueH8tH+ve4S3UkuP1zB2NJ?= =?utf-8?q?WpNt9h3uxSlkJ2KcR4vVceRe3ouC0LZjRWhpKnDaNk/En2xdMT08wjIoOGb7+3Ktf?= =?utf-8?q?aXwiROVS8VTlRJGmhkCjX/Vw0BOV6onb2dZsqaKkBwwnS2FtYEFasdLsxq6GNPIQv?= =?utf-8?q?Ik5H+e2wznsCaNRRiN+rL7GGMrwVgxDno1+kvfbQeQRdXG9p+RzbvFEBCJXSwv3tS?= =?utf-8?q?EZbD2VWdDSsgsez8OLjiKsyuBJu04ucaOembFtN5u/Iwhaf/Gkcpg8cl9OM+h962t?= =?utf-8?q?kfNvP7kuOXAOB7GOcn6FUIVgV36/j30zev0AX0Yu9zh3nNbW/4v5FJElsIOGhL9oB?= =?utf-8?q?sFIg9rqNz1jBDr1oyTb61/92uuuBQggiqZtexOFjOZKLPi93d0dhg6hVHKdw+R53O?= =?utf-8?q?SsOvhTJc0/lDlTI9osTd/HjTqqmPjWKoDDyw=3D=3D?= 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?q?Flkx5Js6QAIc3PMzXHPt2nC7rmpk?= =?utf-8?q?tqRY41sehKk2gSh8fdzN5DDkz4iHuwe+mQqWHED5XdKzHvqYw8gcpDR8WfiOSdc3Y?= =?utf-8?q?4Xxsa6ZvMRT+yJz+fy91sMFacdPEO7aD6F/rkG22EYu5OG51aj0feerrtAKshp3FI?= =?utf-8?q?6PItyM+iMR942NUVI0cYvDz5efYqdmsHagWlR9h+NcWIcflSGJkvYqtApFP83kozG?= =?utf-8?q?T3QEn1DpuQKOPjupzZNtwBTfhhav1T0FuIx+42x9KLy0e0n2hE6IqMEOJViKkA4Ml?= =?utf-8?q?zN/NwAf3yChdF0l03G9n5yBOgV6owF4khlWLX5g34IwUeKA3KewKbnIJh3kx/zNuF?= =?utf-8?q?tj+tQcanG+CZ6fbt/E34OilcTx42Duyk/7ew6O1bNNMYslhtTnNog5nHnrcXFQngP?= =?utf-8?q?gpuCEwFAg79i1JbdIqswfmKS+Z1aeHWUL31Q8ceR93iaNizaLUjOliu2vilbJvj3K?= =?utf-8?q?1I3dBXQNQ4I3bJWsJ+j9XDM6P/iXPOSZS2L4/x8EerLCnrgTW7lnzeq148gB7JWmY?= =?utf-8?q?QWQ+69lyDiSh1gYJelumh1js6nM5rQN6aAG9rsXb2lemovyWKWeCu2KF6VAnq7yf6?= =?utf-8?q?jMrRvMnzJxocgskWPE2EKqVgBcV6wCLwBMTcEpGsj4FHO0lpwKDPnToFI4vE/Jy4E?= =?utf-8?q?TG8ayt1LgYO1GDbq24HMK/43gGr4qMnphuwdoa4O3Ccb4hqdhJzTOOqWvA860qyQ8?= =?utf-8?q?CKocVNWB4iqZ8lzHvs+n0CMVeNorifDyUtFDqt81dbjyaAgtDROj6LT6TO488cd+/?= =?utf-8?q?09iCTlrNrCkg0pPY34tVFb3Qx1Lo7OoBv2ToS7dj4Aw/QqzxiaLs+4dEg39KC3qSm?= =?utf-8?q?AyYmZvi1XDXCp9hHT4hIKi/2DK5F3GORyAhV5w+Ku7ExYtVyJt27tOuxVU/Z6z17n?= =?utf-8?q?w+GMXSFYvxks1FrdaLqmyjM6Fkj49DalQokL2FFQHQDRdDszSlaY0oeG9We7T7+xF?= =?utf-8?q?rYyqZyAkWP6Z4wir6NWL6S5gu60wbKXvDnTeA9ErVrCawKxtlCuLosQbiFRtoCNuJ?= =?utf-8?q?rHnLzEapVQBjfWwXHN3n2JipYJ+hFxXFn+O/RWt1w+ZMbYU1s7k4jgpuXfmzOhUYN?= =?utf-8?q?68PA0fP23aXscZWoZ2p/Y+JY64YXEbTYcz1GcWbSeUA7bRm+7r4IDz5g2aaGWGULl?= =?utf-8?q?cIBnnOAmXw6OQaVOssIu5N34DGSsSfp5ihSj+zDK06z69PQ8jFL5KQDVJD13yS3Nx?= =?utf-8?q?QDCWrG2fSGzeAzg0kM7QtaZKGtrwbqkv8cpojQL0f4byfEcWJvl7NNMmKVuCmQgWD?= =?utf-8?q?PdcDc9S3BKRWRX8OeZ9XOsoHZPu4qUcdA11RFuOLSc9m50b69CHdhi9VpONkuRO4v?= =?utf-8?q?sSgk7DFMpyqyCeAmEjQZJu77CWhLzFpjMnAf95fCgy0fKbPvgc2ZA5e2nr3d6ws3A?= =?utf-8?q?VGBsP26dmm9BfbwSIWt9P1vY8u+6PQr3SnpozX+cT56rD/QFTSfVT2SbFKwRlufJ/?= =?utf-8?q?zcu79vqKuBBWl0R8hQ/xJtXlMB9GGTKYPNVoY6wyhGrNkCnEVv1zzeChHJdkwRcBO?= =?utf-8?q?Rp5l13veCZS4hUGrEtTVYdct9YVy3lS3yw=3D=3D?= 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 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" 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Ƃ 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; } +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 = -EBUSY; + goto err; + } + + sizes = pci_rebar_get_possible_sizes(dev, resno); + if (!sizes) { + ret = -ENOTSUPP; + goto err; + } + + old = pci_rebar_get_current_size(dev, resno); + if (old < 0) { + ret = old; + goto err; + } + + while (sizes > 0) { + i = __fls(sizes); + size = pci_rebar_size_to_bytes(i); + if (size * num_vfs <= pci_resource_len(dev, resno)) { + if (i != old) { + ret = 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 &= ~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] = 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 = 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 = to_pci_dev(dev); - int ret = 0; + int i, ret = 0; u16 num_vfs; if (kstrtou16(buf, 0, &num_vfs) < 0) @@ -480,6 +560,11 @@ static ssize_t sriov_numvfs_store(struct device *dev, goto exit; } + for (i = 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 = 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) static void sriov_release(struct pci_dev *dev) { + int i; + BUG_ON(dev->sriov->num_VFs); + for (i = 0; i < PCI_SRIOV_NUM_BARS; i++) + pci_iov_resource_do_restore(dev, i + PCI_IOV_RESOURCES); + if (dev != dev->sriov->dev) pci_dev_put(dev->sriov->dev); 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 */ }; 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 numvfs); 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); /* Arch may override these (weak) */ @@ -2423,6 +2424,8 @@ static inline int pci_sriov_get_totalvfs(struct pci_dev *dev) #define pci_sriov_configure_simple NULL static inline resource_size_t pci_iov_resource_size(struct pci_dev *dev, int 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 probe) { } #endif