From nobody Wed Nov 27 14:35:49 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 849DB1C1AC1; Thu, 10 Oct 2024 10:32:21 +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=1728556343; cv=fail; b=HW5xLROcNx54nJHwGDPuxSyumGFTLl52eWebnijnE6uijkpqcO6sozad/SQ5lmDAo5N9boA/T3+BRI9heL2bYz5P5j7Omd2DHxW70Qm2GFQ6HxG0UHuX1Q2eRvJV0Ro8FMiVVrie35ke5rR/souDmc9EK6/7jMm4fLTtsFFcs+s= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728556343; c=relaxed/simple; bh=Bs8Jn4giSEzArPZb//LTvOlHynnehCNqHp7FGu65Veg=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=ZNDRBHNzoKEDXmGKGaIRuMZ6N0Ar0l3Tn9HvA/rs5pBiA9InGznGZcS5GUeYN1oe7TBIaBadJjTXWxE8R9hzXrINoZVv0U/wlQavNwGe/3IpA0hrcMKQ13xGbjUolfhK6OGRbBWiDRHA02kDNNOvxvqFmLuzZFjgao9tc3g41MQ= 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=JeS3FbFU; 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="JeS3FbFU" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1728556341; x=1760092341; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=Bs8Jn4giSEzArPZb//LTvOlHynnehCNqHp7FGu65Veg=; b=JeS3FbFUE/xtGp/Y4wSTMj+Vh4geg0Tl8jebC+nmupttOkTedrJJzBSB SylaDlKliumcYyjiD4OUQEJ/vX8T1YpTZ+NPTPNdNftjp+d8Fj1NQnDFM T8r+V6LE4LUcq/cGm6Nv+JsUbjADFQxuwASeEB8ERJL+uzX1iGe7AaOvq TyX7TEXvtMcuSxSBObiqsAOgYcwMkpKKyihkFJ4Sj+rk3GmWevde+f2I0 +UUmw8qdk0RgpR20FHUThz0Ukg9OO8MsOdpgM8YoeihqgNSFiiYdcjSd4 a6DZFKYnB2Qe14MlGHyLgiLbJPUdbIM0NdyFJMycRdZiDzWAHCfnzHJZL A==; X-CSE-ConnectionGUID: pEf8QKSfTfmz72F6HLM95A== X-CSE-MsgGUID: se6TxyO8RIyznkrfkFo5Tg== X-IronPort-AV: E=McAfee;i="6700,10204,11220"; a="15528425" X-IronPort-AV: E=Sophos;i="6.11,192,1725346800"; d="scan'208";a="15528425" Received: from orviesa010.jf.intel.com ([10.64.159.150]) by fmvoesa110.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Oct 2024 03:32:20 -0700 X-CSE-ConnectionGUID: v55bOunjSt65Vs2U2noWuA== X-CSE-MsgGUID: Ispt2/E+T2e86earY0XKMg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,192,1725346800"; d="scan'208";a="76464924" Received: from fmsmsx602.amr.corp.intel.com ([10.18.126.82]) by orviesa010.jf.intel.com with ESMTP/TLS/AES256-GCM-SHA384; 10 Oct 2024 03:32:20 -0700 Received: from fmsmsx610.amr.corp.intel.com (10.18.126.90) 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; Thu, 10 Oct 2024 03:32:19 -0700 Received: from FMSEDG603.ED.cps.intel.com (10.1.192.133) by fmsmsx610.amr.corp.intel.com (10.18.126.90) 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:19 -0700 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (104.47.58.43) 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:19 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=kxObkvnTz+CwG+LZrXmCHZzrTAMMIxAjYnGyVF38xc4UMAGEUqrx8KZu9Kc9sLjViPDfz/0VMn0FzmR+AhMJ0saI9s9NdLuEFyMeTKGwHF0m5vdwtcgBHLR+xzQlcO8OFR6alRQLl4utSPrjc5JDAb5mp9ScDoa7CJPNO1B+TUBrCwJuU+0enY3L0ZYwvgRIusVc+XEy+1p7PsVeRG/Rq17Z2owoIfNYMDnKqLUdSBUDuxAJ4MjRDWyHMmxIRjg7F52Kz0H7OXIVypBuqIW7Y57RGloH5JslrAiLzNx2sdBefVhZYS4kLcLNETJna92f9YIAmbI+hveQS8OkIuU8kw== 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=QyYEH2qAYR9ofrIMUSnRZ7+9N+tYnnjyVObjHaQr+A8=; b=JAhxDeiBdaGr0aspXtEA0yK+1nDrQUzQ6p84gKd5iJvjmjCkp+l8yrlVrkDaiEI0phNuEt6rm6UCqGxHDDNH83nuHBJwb5NXt0vFpHl+7GNdGH1vlkFUvi+GDt6A+85fvK6vzfBDgCLB9Ixnsi9LsWEEeSbSTWHJluAkl4zEGgm7d5DlBx8/V8gXlKgqa8YO/5KGzDwCeEh/nqVGrd5x/0wMmWRG4km/UWQPOfgyKQpjZaRE6KAWyX2jtKgCbsZstgWlq6GpBucB2a41OTs/YEUweN1W6/t+daVrvw1fD7D+2B7ua44e+J2AHSvz5WXXEOP0bETqMnzRwXErMDYXVg== 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:15 +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:15 +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 1/5] PCI/IOV: Restore VF resizable BAR state after reset Date: Thu, 10 Oct 2024 12:31:59 +0200 Message-ID: <20241010103203.382898-2-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: WA2P291CA0029.POLP291.PROD.OUTLOOK.COM (2603:10a6:1d0:1f::29) 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: 727fef6c-a28e-44ca-f976-08dce916ced5 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?NjF2ZzBSdjB2bXlwVUtCT1ljZmY2MTB2aVVUczNvMkx6cHBYcEdtMllSYkVq?= =?utf-8?B?bG9SZVh4UFhtbFg0akFQUWdCNXVIamk3VVZheDhTNTZURDMvNFZ5bFYwSTVN?= =?utf-8?B?VFA1OERNbjZIKzJMUWw3NGVrcnVHOFRiSnhESE9JeHFkdytBRWllRFlBV2ND?= =?utf-8?B?Ulk0QUd5aitqei80SVFGb29vakVVMUFna0Z5TnUwV283cEIwZytLMUVkTjVs?= =?utf-8?B?S2F1WW5iQ0hDcmpibnZoWXZCNS9LbWY3SUpGY0RjRDlGaXhrNWg1RUhHTCtL?= =?utf-8?B?VXRhZ285UGkyRXV5TzdzMnJTZTExeHFPaVFjV1ErWDBGc1F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cXVWUHVCSGZTdGc3TWh6UGxhaSto?= =?utf-8?B?czhMbmlualVQZjZkMVBmdUJ2Rm1odlovSnNSb1dyaFI2ak9sYzhUelR5Qmh6?= =?utf-8?B?U2xiYmNqRTMzdFZwdW9LRHgwK3ppL2hZZHlicHBZZGR1L0c0N3NUNU1QaXFr?= =?utf-8?B?VlRXR1ZSYlc1OVR1Z1cwd0hFb2RQV0ZuSU5IYysxVHd1YWplbW1VZjJzcWdy?= =?utf-8?B?cG9VWHBhT3pVdFNSaFV2czRFYTBKQ2JiMFZRUjRLVVlYVkkzaTdVa3Y3Nk14?= =?utf-8?B?L2VObzN1ZTJ2MDh0Q3dqcVh1N1ltUkk2L2tmUkh1NDlwd09kdXRFelA3eUoy?= =?utf-8?B?MkxsQ3daUU5MSkJ6MW41ditXbmtINlZDNzVVS2VFU3ZJV0lSOGVsTm4vZElh?= =?utf-8?B?YWFmNUxSbGhuZU5PSjA4c3NDTWEyd05Jek16bmlJais3di9xTEsvTU1LdCtw?= =?utf-8?B?YVhPVEo0K21ib0NyVi9KczFzYUYrRGR0dkRDeVBlaElxS25XZXNxRDNBPT0=?= 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?TDNxUnpyMDhwZ0l6V3lKSXUxRk5VSTIxMEpuMXdzRWo5ZDdUVHNWNUZoUHFV?= =?utf-8?B?cjNwVWdXUFo1dnpVTkN1SVdJOXdPTDRCSE5INFljbGRMbEh2RVAvOHhMd3kw?= =?utf-8?B?NnJscjhZenJCL3lXak8yaW1GVUtGRGNwRTUwZjd5Uk9iUGdpd0ZnaXB3Zzhq?= =?utf-8?B?ZEQ5SnV3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K0RKdVNuSm1X?= =?utf-8?B?QXJ2N3pqWG5KeXVWbnF6YnlUSmI1MHI4aWhWWGZXMThyT21VK1A5Qm9hbUcw?= =?utf-8?B?QWxxS0JlTjNyNDlnUnhTWENkRWpKbWNqdE53VmgzRHhKa0ExZHVESEJVS1BI?= =?utf-8?B?QXVIakxMd01lQ2ZvL1pQaVFmdEttS2dFYlBqejlod1VaaUZVYUdSejduMW9C?= =?utf-8?B?M3c9PQ==?= X-MS-Exchange-CrossTenant-Network-Message-Id: 727fef6c-a28e-44ca-f976-08dce916ced5 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:14.9701 (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: vVXEKXCCClLRcvJhHTc5FqsYOxG5yD6sk7fa5GfU3VLM02bNLxQvHh2XuaMQFntp92y03M4nHCY+XHdhb4+S0xwY40qw0E5u6J2IuRwlSn8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN6PR11MB8103 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 --- 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..fd5c059b29c13 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 ctrl & PCI_REBAR_CTRL_BAR_IDX; + 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