From nobody Mon Nov 25 16:44:32 2024 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.17]) (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 0056220C31B; Fri, 25 Oct 2024 21:51:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=198.175.65.17 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729893074; cv=fail; b=PaYrKizAdxqDnlY0xOqT7ADTVjpU18CGm33QPa5lc5ieWVD2sDQ5nBVqJkQJxChnF5CNI9aOnpLT7w6lHmBSG80WRQxmkobKrvIH450UJG7duFMgdz706BaGOw2QchAu419tRhdxK3884AVp/h7TMttrSZnkYQzbAJiFBNSmwAQ= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729893074; c=relaxed/simple; bh=gO0LvjUua6S62XJgIlioVb9aEnjmlOSXeHNkenlw+X8=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=bXeqp7yvkSnuhdNtzrdh7q2oiaJYDPaYQ6FVYFLA4Dh/LFpW61UCeeweu5GIUegW7D2Alk5dLxp1QSnneNaumTFv9DKhUQVeIKK8vOx4z6gqZ6wNQa2dkrnDRdWGSp/w4PdQj9usAvmu47YhS6ALxzOwpl/+SL6ReSEQKZEIjXc= 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=E2jEkX1v; arc=fail smtp.client-ip=198.175.65.17 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="E2jEkX1v" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1729893069; x=1761429069; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=gO0LvjUua6S62XJgIlioVb9aEnjmlOSXeHNkenlw+X8=; b=E2jEkX1vXd8Vl1Ci/Wwp397I5nKHQjKc5SMEqm4Np7jF9Cc4qvL/JDfK 8WAb6GCxYYSRQw5TD8yLFfdsGcans3bu9rdPHy3S2tXRtXAJNeWGfvh6V tNXfkaLM7Sjw35dW5+pMhEn7tjzhev2GjKdG9xXeDDNPkzDpaQWbKIl0f 4qdG7zqHpOUd4L7ybWDkMwu19MvbPmeQ9VT7wM98jrssnuTwpFzJG6pBv 1Okz+an63oDuHxnfpMYRoMNVjWNZITBCoVtCwGbIRfOReOprzrcHgNrnE vFWE8z4csq10w/Jpou+meqsb7FYfpKgqSZkcn9g1yQFqGJFanNT/wkVPJ A==; X-CSE-ConnectionGUID: lobV45HGQFWmYNAoCyOj/A== X-CSE-MsgGUID: ZKrhu+6RSlWXTqP71jKPUw== X-IronPort-AV: E=McAfee;i="6700,10204,11236"; a="29683388" X-IronPort-AV: E=Sophos;i="6.11,233,1725346800"; d="scan'208";a="29683388" Received: from orviesa007.jf.intel.com ([10.64.159.147]) by orvoesa109.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Oct 2024 14:51:08 -0700 X-CSE-ConnectionGUID: JpRVv2PYT1SEzJq6WMWfeA== X-CSE-MsgGUID: zyPzq2r1T2eatpfsZu6EJw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,233,1725346800"; d="scan'208";a="81492860" Received: from orsmsx601.amr.corp.intel.com ([10.22.229.14]) by orviesa007.jf.intel.com with ESMTP/TLS/AES256-GCM-SHA384; 25 Oct 2024 14:51:08 -0700 Received: from orsmsx601.amr.corp.intel.com (10.22.229.14) by ORSMSX601.amr.corp.intel.com (10.22.229.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Fri, 25 Oct 2024 14:51:07 -0700 Received: from orsedg603.ED.cps.intel.com (10.7.248.4) by orsmsx601.amr.corp.intel.com (10.22.229.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39 via Frontend Transport; Fri, 25 Oct 2024 14:51:07 -0700 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (104.47.59.171) 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.39; Fri, 25 Oct 2024 14:51:07 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=zIaPtggEJsoOgF2fCXpaop6HmO0aC4yCtSEsPyaCADCGQVfGfJ1FcUtoMSF3dEEYa+y4UJFIjeS8/fuolZpRZlJk9WN8sVdV9XDzknbpBWZjAsPBF2PcVv0i7qB0+j4aTX8pHMt7lR6T7VLCYLWDfSFCT7EsgmppEEkk3Lzcp7S/wF95jh/d3XdYQOFxdPY3AnOb2zHljyoxRybUkpC7hFVAZw9RPftGD6XYV4xZZBxC4pP7Mq4lVOyT0KoKcB8bvP2KiRYOV6T/bLZcLEpM1/2OR5geeF1XdJPguf7dymekEXjqNgNe3sD7AtyIpMufFHCiCvQsmZTBhF2+dKi6pQ== 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=rxHJttmjn7E6Myjzq3+TueUpYOqq6Ozmnw7CozqMA8Y=; b=upF1qqP2QW4dlSl0MyLIZGFNUQLwox1xvht6bLuyvOPSKFmW1FFaOmBJlY/LJn9L/L1B1/4Uq9ZMtQJCwdeQe9OJEaPuV6kZkYxNNpVf+SSZKFCXK1NN8zkI4s7V0oLI48nPJzQacngydX9FeBwa31xYWgsQSI77VtcJrH6V6OY+wydon9hfKfbc2Tt6jOVPPiQ4AQ33EroJCS9XY7zAeixfygPBQyoNxZXrm/SgsfiFuAy2f3nkvHMjuUp9kpbL2sRElG5Y+YWyC3boWIjhTWElYK77o2AtUwTTngHpKmBNCXhfVB5x7x62DHE1W8HwYJ3KMeUlJFQGarTgek3OFQ== 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 DS0PR11MB7682.namprd11.prod.outlook.com (2603:10b6:8:dc::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.21; Fri, 25 Oct 2024 21:51: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%5]) with mapi id 15.20.8093.018; Fri, 25 Oct 2024 21:51:05 +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 v4 1/7] PCI/IOV: Restore VF resizable BAR state after reset Date: Fri, 25 Oct 2024 23:50:32 +0200 Message-ID: <20241025215038.3125626-2-michal.winiarski@intel.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241025215038.3125626-1-michal.winiarski@intel.com> References: <20241025215038.3125626-1-michal.winiarski@intel.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: WA0P291CA0012.POLP291.PROD.OUTLOOK.COM (2603:10a6:1d0:1::7) 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_|DS0PR11MB7682:EE_ X-MS-Office365-Filtering-Correlation-Id: 87a0a3e0-998c-449f-8c04-08dcf53f200c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|7416014|366016; X-Microsoft-Antispam-Message-Info: =?utf-8?B?YytmTXI5empqdzk5cFZuSm02aHQ0NkthWEFoU09FQXNpNUZieXBsTTFsNG1C?= =?utf-8?B?cDVEaXBhTy9EUWdYcHpQVzA3VUFRWnI1NnlIOVNlM0lWeE9LQkc5TVI0eUVk?= =?utf-8?B?T3Y0a0lGdnlMWWFHdE5oZzdKcENoQXIxVXFKT1FESXRQNHpkZ0Fuc1A4dHJ1?= =?utf-8?B?T3lnWnNqMHhUbklZTVFpUkVqMmxjbWN0OHV3c1FxR3NNbWgyeTVlS3dUUDJE?= =?utf-8?B?Y01kS01NMGdYaW5HUldYcXhpc0FoZXV6aS9Ib01hV2dmNzhuSmI3a3o2Z3Vl?= =?utf-8?B?dXRHeWJ6K3UvUG5PWFkzaWNEdVdWeStnaFAzNGVYc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meThIV0JORFMwNm9QSld1YjcwQlRUZ0ZVK2E5eWNO?= =?utf-8?B?czBlMmdzNXNlbzBrVEcxNFpJSjQ3ZUxvdHFwR3oyekVjekNwcGJ4OTQ5Tm1H?= =?utf-8?B?d2lhb2MzakRtdElCSnZGenNBZG5NdzB2L251SzdTd3V4dkZGNFVVTlU5NGl6?= =?utf-8?B?ZzZPZGdveFhNV2w0TERidGdRTGZETFJHbi9Md3QxTnZmRjlGWVRjK1JHQVZK?= =?utf-8?B?cVlhR21aa1Rjak5kQ21tcExieFlFOGJBVGdzVHYxUkdOQzVYeWlZcDRGSW5m?= =?utf-8?B?Y1hQT1NxZE9FVDkyMDN0czVaOU1Jd2p4YWdaWVdCZ3U2a1J6QXBCaCtPYUVG?= =?utf-8?B?VmRRK0Z4RTBZaVRLTG92NjBiMDB5Mm5HUmEvMk9XZFpGb09jTkRZV2tNSml5?= =?utf-8?B?ZWtzNEZoM0VNZTBnN3VKQzRZOWt6NXd0dENqU0lwaC9PUzJkS2xXVlJEL012?= =?utf-8?B?UWw4cHMzUzNCQ0Vnb0lTQjdqNUZhUVBkQkNtdGZRbmNlMXRSUmtzbk9EVXlN?= =?utf-8?Q?BHJ5SxpCVmaPUJ6XpnL0cbADhTpXa7YdEZdcbO2?= 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)(1800799024)(376014)(7416014)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?TUt2NWhSeWptOEh3ZEZDY3JKeWZCbWFYNU9hWnFZQWFyemxybnlwakViOUEv?= =?utf-8?B?bWM2QXJFbThrQ1B0QmxlMnNPeGVNRjN3ZFhqVFoxUU14VWF3WEtWRXBRd2F5?= =?utf-8?B?LzMvVHVOQVlBUzNIa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ZkY2g3?= =?utf-8?B?T1RaYjB1d3NyMm9udGNCeUpwbkxPMU94ZTlURTRYWUFoNlFaM0hmRW9ldlFT?= =?utf-8?B?N1BFUmhPSWJkTnZiVjR6eFFTL2QwNVlpR1RWUC9TQTVjT2QxQllKTlNWNnps?= =?utf-8?B?cWdTc01DV3hwVHhlY2tWek9sb0pCdTdCYkVOOXJpcmVTSmZzSytBQ2xRRjcw?= =?utf-8?B?UythYW56NmZwSjFlVEZPdUFraVY0c2RmcUxqTXNSNXNKWTZjbjlpNzloZlF5?= =?utf-8?B?Znc9PQ==?= X-MS-Exchange-CrossTenant-Network-Message-Id: 87a0a3e0-998c-449f-8c04-08dcf53f200c X-MS-Exchange-CrossTenant-AuthSource: DM4PR11MB5373.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Oct 2024 21:51:05.0689 (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: Rlqrkr1UVhT8C748GdR5513UtX2aRGNX5daPLMK8YKgmVEBksqwH9pBHIAw4eBYXKy8SNHEwyOMHf0NeHjS3m61tJUJPdp7jZl7/Sc7EbE0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR11MB7682 X-OriginatorOrg: intel.com Similar to regular resizable BAR, VF BAR can also be resized, e.g. by the system firmware or the PCI subsystem itself. Add the capability ID and restore it as a part of IOV state. See PCIe r4.0, sec 9.3.7.4. Signed-off-by: Micha=C5=82 Winiarski Reviewed-by: Ilpo J=C3=A4rvinen Reviewed-by: Christian K=C3=B6nig --- drivers/pci/iov.c | 29 ++++++++++++++++++++++++++++- include/uapi/linux/pci_regs.h | 1 + 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c index aaa33e8dc4c97..6bdc9950b9787 100644 --- a/drivers/pci/iov.c +++ b/drivers/pci/iov.c @@ -7,6 +7,7 @@ * Copyright (C) 2009 Intel Corporation, Yu Zhao */ =20 +#include #include #include #include @@ -862,6 +863,30 @@ static void sriov_release(struct pci_dev *dev) dev->sriov =3D NULL; } =20 +static void sriov_restore_vf_rebar_state(struct pci_dev *dev) +{ + unsigned int pos, nbars, i; + u32 ctrl; + + pos =3D pci_find_ext_capability(dev, PCI_EXT_CAP_ID_VF_REBAR); + if (!pos) + return; + + pci_read_config_dword(dev, pos + PCI_REBAR_CTRL, &ctrl); + nbars =3D FIELD_GET(PCI_REBAR_CTRL_NBAR_MASK, ctrl); + + for (i =3D 0; i < nbars; i++, pos +=3D 8) { + int bar_idx, size; + + pci_read_config_dword(dev, pos + PCI_REBAR_CTRL, &ctrl); + bar_idx =3D FIELD_GET(PCI_REBAR_CTRL_BAR_IDX, ctrl); + size =3D pci_rebar_bytes_to_size(dev->sriov->barsz[bar_idx]); + ctrl &=3D ~PCI_REBAR_CTRL_BAR_SIZE; + ctrl |=3D FIELD_PREP(PCI_REBAR_CTRL_BAR_SIZE, size); + pci_write_config_dword(dev, pos + PCI_REBAR_CTRL, ctrl); + } +} + static void sriov_restore_state(struct pci_dev *dev) { int i; @@ -1021,8 +1046,10 @@ resource_size_t pci_sriov_resource_alignment(struct = pci_dev *dev, int resno) */ void pci_restore_iov_state(struct pci_dev *dev) { - if (dev->is_physfn) + if (dev->is_physfn) { + sriov_restore_vf_rebar_state(dev); sriov_restore_state(dev); + } } =20 /** diff --git a/include/uapi/linux/pci_regs.h b/include/uapi/linux/pci_regs.h index 12323b3334a9c..a0cf701c4c3af 100644 --- a/include/uapi/linux/pci_regs.h +++ b/include/uapi/linux/pci_regs.h @@ -740,6 +740,7 @@ #define PCI_EXT_CAP_ID_L1SS 0x1E /* L1 PM Substates */ #define PCI_EXT_CAP_ID_PTM 0x1F /* Precision Time Measurement */ #define PCI_EXT_CAP_ID_DVSEC 0x23 /* Designated Vendor-Specific */ +#define PCI_EXT_CAP_ID_VF_REBAR 0x24 /* VF Resizable BAR */ #define PCI_EXT_CAP_ID_DLF 0x25 /* Data Link Feature */ #define PCI_EXT_CAP_ID_PL_16GT 0x26 /* Physical Layer 16.0 GT/s */ #define PCI_EXT_CAP_ID_NPEM 0x29 /* Native PCIe Enclosure Management */ --=20 2.47.0