From nobody Wed Nov 27 15:45:16 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 81DC31C2DBF; Thu, 10 Oct 2024 10:32:26 +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=1728556348; cv=fail; b=qGDsYZxEZpzsTrRZ5ZlQAmj2DYwnYkyiA5LB57jlIVRfxnoT+s9umwvbQmDYIi8isuwF9YK6Q/EJH4xRJPo9Zm805jMcFJtl1gPwibA+ocg+r302MsQNVp7fzwYHXXwL+gJwILQgjj8SBQO/Pb/Efmlg9QMTOW/3wMuoDrlDPyE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728556348; c=relaxed/simple; bh=ybaOv2ojJW7CwOeUTI7puwXRWFM1V1+uIvZzDLzNOR0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=oTmWcnU0/ZNjUCoXEAwC2MRr2RlvssbaRcTNa9m94C0Dozs/XnJjeKc9Fvj108AsUScF3rQmC9x4clNL73LLmqFncjSvAm+NX8bCe1EfM3OX/bv0yVO1GPPamn321cffM571jgudGv48mfUBnU/2FbxNCNPl29MkWHFk5KulL8o= 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=Jrd1pDWM; 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="Jrd1pDWM" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1728556346; x=1760092346; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=ybaOv2ojJW7CwOeUTI7puwXRWFM1V1+uIvZzDLzNOR0=; b=Jrd1pDWMTwHTg+Ftf7dEcnZYoAHKJKusrsb9+hRd6m5WyF6MQq+SZmc5 VuzFCaQEcPSSqEEgxxi9AHTuKelOywJhCKUCMbLJQjjUUF5Vx8v1Vl4qf UmP/OqLjyEjcDJp5EuW+ZGRC2Wb3pNlTDbKX0CL7f5A9qG737yvDZ7f04 ueLIIfyQpiLwvo3je1SM3q3Zs79JGbRrOExxYuIwfBR9H684GpsTi2gXr LvRFFO3m7L6+UWeUteltmyZLlbyS0KJOm+mjaB+DfSzYXoMc0bZXIeAZ/ BeIid9c6DKT6nzZg8I8yjf8C8t34KVraqVTU62PdRUYlGo5rg4isJKlHq Q==; X-CSE-ConnectionGUID: Sa20o+bdQJ2LTkpN2f2cUg== X-CSE-MsgGUID: UyJ7aSeiT52Wo/GYZgTxsg== X-IronPort-AV: E=McAfee;i="6700,10204,11220"; a="15528446" X-IronPort-AV: E=Sophos;i="6.11,192,1725346800"; d="scan'208";a="15528446" 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:26 -0700 X-CSE-ConnectionGUID: VeisuotSSoqWCy3d81VI8g== X-CSE-MsgGUID: qiOs39orTq2A4jEt31w1Fw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,192,1725346800"; d="scan'208";a="76751659" 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:25 -0700 Received: from fmsmsx611.amr.corp.intel.com (10.18.126.91) 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:25 -0700 Received: from FMSEDG603.ED.cps.intel.com (10.1.192.133) by fmsmsx611.amr.corp.intel.com (10.18.126.91) 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:25 -0700 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (104.47.58.45) 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:24 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=FBzyVQkaH46NE0mUJ0zRMwbHAktKDr4xo4NmrHgA7Op97Sy4+zq2RnDm7iiUrcdVfJa7dPrhzuXGzaZKxQTgzG7FF6NBMhhxspEUm5dwQsNwFBKzVEWHi3t51dCnSZoQ1hffeQo5QdRZyLNqHn9HerF/Ce97qY7h5TYcNfrwnh/nrtb+RipOWro3ClysWJcQUWkUdigTMYTtJsAoebbI0oD+wrhK60d9x+TrsjIheV8TJlvSXPGAiKNshX/XHVy1Tt3uuLOpjxy4nryimhBM7ABAKUs3/teB+ztzuebtzQF6vCh3uO70ywRBgRJStWE3AQKMPND6jEr0LV16p/9r9w== 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=G8RdkHf2rYc9zV3jfSuykZ0/1sP4SE+Beit5J1B6fNE=; b=xrqEW7gfqrxP3LsNip7QudfHVB8erwkhLG5RHnlyrEx8UiTSBmtH4Pz3VOagrDJSiutzGCz4+AquDSoakikgW35o1FTLHLzeHPnr+vBnCwvbHEh7zmEDhtFoSixrCvXqfjI7nM+NRZ+OhVBeP6w3w8mECVRaCuzrGOFQuF/pxue81R7eslcqPcEW/rRxi4Po5TphwP7wnGK5UdLQFBtzGrpUvwtEokpgKKsiraQwhhR+tFlUNdZdKn0L6JneSCSyi7sOaev/wATbxix5mdG4ciJu84tI4/Rr+67yTkql7sDhTlhkVKWITZu+6uGqqCXH2wwMhYmuVPcD4xEOpbe2tw== 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:23 +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:22 +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 3/5] PCI: Allow IOV resources to be resized in pci_resize_resource Date: Thu, 10 Oct 2024 12:32:01 +0200 Message-ID: <20241010103203.382898-4-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: MI1P293CA0024.ITAP293.PROD.OUTLOOK.COM (2603:10a6:290:3::6) 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: 97c693b3-3926-4deb-1322-08dce916d38c 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?em1oenRwZ05vVzhtcGUvVnp3TjEzYVltMVBJMWxCQmp4aXFROGVrMEZKR005?= =?utf-8?B?RnFIYlgwRkxXZ3lEVjRQOVhlTE1vOWJUS0lrZEtkM0VnanpTUWQrTnlLRUpQ?= =?utf-8?B?djBKTFdCckJ0SVJVWDdjck9sMmJBbVVzckdsRjB2OTBTU0xqTUFmN3NxRnJ2?= =?utf-8?B?cG04S1RabU1kaXRYOFBqWmx1RGdIZnQzVWFLUlIxVThMSy8rUzJkR1J1VjBn?= =?utf-8?B?ZXBTZ1hNL2RzUlMyY054OXNha05XWHBhdkVWM2I1MkFOVU4xYyt3bGZjS0tE?= =?utf-8?B?dmZIbmxEajdzQ1dydHVVOW1CeEUvOTBrL2F0d2ZVck9pMHk2MVF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0ZtWkc2S3JQeG1ZQVoyWExpNjFi?= =?utf-8?B?aXhNR2xyaVVzWUUrV2JmamZZNlBOWUJaNnNkUjZNdmhyS1hrYlBpalMrSXZm?= =?utf-8?B?QWVBTHlCeGNHT2JtNmM2M04wQlA4a0NvMFg2V3dySzJ0RjFrN29obE1Paitr?= =?utf-8?B?djFseEYrYy8yNzFPRHgrVU5OOUFSOTNZRFZsOURXdC80SXFRaGZoYTZqZnZo?= =?utf-8?B?Q21LYkt2MEdlb1JnQkxadEIrNHcwWVlWWE9zbmp4MHVQRkNUZXNMci9UTVVp?= =?utf-8?B?OS9MTUlFQXdKcE4yakE3MHRjbldyei81ZEJITVZJU3VGN05TR0d1bmYrNlda?= =?utf-8?B?TlVVVlhpS3FIdHNBaWRBZS9pUU1Ia0ZTdjlvVHQ3Q2JicHl1SStpS3g0UXJC?= =?utf-8?B?blAzR2UzNHdxZkJIQ09Sa2dLRFltQ2l5K1gvR0dycU1DalZPZXNtR0tadGVU?= =?utf-8?B?SmI0T2NXZVg3R25FTm54T3BINEJqYW5tK2FNKzFya1pTcVFtNGN6bklnPT0=?= 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?eWNjQmx4NE9aUWZnVldsc1JHQnZzQ1ZnQTFvVUdQSGx1eUM3d3U0RFJScFdo?= =?utf-8?B?eUkvUDFubGw0d0tyOHdHQzJIQjJDcTI1YlRSUnc3K0Z1ODV0SEhVWjlnR2d0?= =?utf-8?B?V1NtUklGd1JkL3psbU9VaUhNVHFaR3daQXl6bk13ZXd5TGZYSlZnbzMvZFBP?= =?utf-8?B?clQva21uc1lCVnFIU2tyRXpHOWU2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?utf-8?B?VHU4MkRkZlQyUHlYUTU1UXRVMWMvb3R2YzZ2TzVIRlVkMWExMjZCQW5lQmdM?= =?utf-8?B?MTQ1RXB0RXdCQXkwdjM1Sjc0WDRNbnlCTjRCbm5xUE4xZkRxYVNjVkFLSVh6?= =?utf-8?B?QXQrU1RqSFMralJMeHNSWWszb2lNdm5FU3IvZU1qdEV4L2xGWEN1cmRieTNa?= =?utf-8?B?MEE9PQ==?= X-MS-Exchange-CrossTenant-Network-Message-Id: 97c693b3-3926-4deb-1322-08dce916d38c 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:22.8536 (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: GQs655IqyfDqnVW72EGhn4fmOrcNfCLbm30t4ztwsyYSaH/Nd0LybMLiymkAjp4EgG991N+D9mapJjleq56bH5HZfAwg7mBK3s9S/3J1ioQ= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN6PR11MB8103 X-OriginatorOrg: intel.com Similar to regular resizable BAR, VF BAR can also be resized. The structures are very similar, which means we can reuse most of the implementation. See PCIe r4.0, sec 9.3.7.4. Signed-off-by: Micha=C5=82 Winiarski --- drivers/pci/iov.c | 20 ++++++++++++++++++++ drivers/pci/pci.c | 9 ++++++++- drivers/pci/pci.h | 8 ++++++++ drivers/pci/setup-res.c | 33 ++++++++++++++++++++++++++++----- 4 files changed, 64 insertions(+), 6 deletions(-) diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c index fd5c059b29c13..591a3eae1618a 100644 --- a/drivers/pci/iov.c +++ b/drivers/pci/iov.c @@ -154,6 +154,26 @@ resource_size_t pci_iov_resource_size(struct pci_dev *= dev, int resno) return dev->sriov->barsz[resno - PCI_IOV_RESOURCES]; } =20 +void pci_iov_resource_set_size(struct pci_dev *dev, int resno, resource_si= ze_t size) +{ + if (!pci_resource_is_iov(resno)) { + pci_warn(dev, "%s is not an IOV resource\n", + pci_resource_name(dev, resno)); + return; + } + + dev->sriov->barsz[resno - PCI_IOV_RESOURCES] =3D size; +} + +bool pci_iov_is_memory_decoding_enabled(struct pci_dev *dev) +{ + u16 cmd; + + pci_read_config_word(dev, dev->sriov->pos + PCI_SRIOV_CTRL, &cmd); + + return cmd & PCI_SRIOV_CTRL_MSE; +} + static void pci_read_vf_config_common(struct pci_dev *virtfn) { struct pci_dev *physfn =3D virtfn->physfn; diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 7d85c04fbba2a..788ae61731213 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -3718,10 +3718,17 @@ void pci_acs_init(struct pci_dev *dev) */ static int pci_rebar_find_pos(struct pci_dev *pdev, int bar) { + int cap =3D PCI_EXT_CAP_ID_REBAR; unsigned int pos, nbars, i; u32 ctrl; =20 - pos =3D pci_find_ext_capability(pdev, PCI_EXT_CAP_ID_REBAR); +#ifdef CONFIG_PCI_IOV + if (pci_resource_is_iov(bar)) { + cap =3D PCI_EXT_CAP_ID_VF_REBAR; + bar -=3D PCI_IOV_RESOURCES; + } +#endif + pos =3D pci_find_ext_capability(pdev, cap); if (!pos) return -ENOTSUPP; =20 diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h index c55f2d7a4f37e..e15fd8fe0f81f 100644 --- a/drivers/pci/pci.h +++ b/drivers/pci/pci.h @@ -584,6 +584,8 @@ static inline bool pci_resource_is_iov(int resno) { return resno >=3D PCI_IOV_RESOURCES && resno <=3D PCI_IOV_RESOURCE_END; } +void pci_iov_resource_set_size(struct pci_dev *dev, int resno, resource_si= ze_t size); +bool pci_iov_is_memory_decoding_enabled(struct pci_dev *dev); extern const struct attribute_group sriov_pf_dev_attr_group; extern const struct attribute_group sriov_vf_dev_attr_group; #else @@ -607,6 +609,12 @@ static inline bool pci_resource_is_iov(int resno) { return false; } +static inline void pci_iov_resource_set_size(struct pci_dev *dev, int resn= o, + resource_size_t size) { } +static inline bool pci_iov_is_memory_decoding_enabled(struct pci_dev *dev) +{ + return false; +} #endif /* CONFIG_PCI_IOV */ =20 #ifdef CONFIG_PCIE_PTM diff --git a/drivers/pci/setup-res.c b/drivers/pci/setup-res.c index e2cf79253ebda..95a13a5fa379c 100644 --- a/drivers/pci/setup-res.c +++ b/drivers/pci/setup-res.c @@ -425,13 +425,37 @@ void pci_release_resource(struct pci_dev *dev, int re= sno) } EXPORT_SYMBOL(pci_release_resource); =20 +static bool pci_resize_is_memory_decoding_enabled(struct pci_dev *dev, int= resno) +{ + u16 cmd; + + if (pci_resource_is_iov(resno)) + return pci_iov_is_memory_decoding_enabled(dev); + + pci_read_config_word(dev, PCI_COMMAND, &cmd); + + return cmd & PCI_COMMAND_MEMORY; +} + +static void pci_resize_resource_set_size(struct pci_dev *dev, int resno, i= nt size) +{ + resource_size_t res_size =3D pci_rebar_size_to_bytes(size); + struct resource *res =3D dev->resource + resno; + + if (!pci_resource_is_iov(resno)) { + res->end =3D res->start + res_size - 1; + } else { + res->end =3D res->start + res_size * pci_sriov_get_totalvfs(dev) - 1; + pci_iov_resource_set_size(dev, resno, res_size); + } +} + int pci_resize_resource(struct pci_dev *dev, int resno, int size) { struct resource *res =3D dev->resource + resno; struct pci_host_bridge *host; int old, ret; u32 sizes; - u16 cmd; =20 /* Check if we must preserve the firmware's resource assignment */ host =3D pci_find_host_bridge(dev->bus); @@ -442,8 +466,7 @@ int pci_resize_resource(struct pci_dev *dev, int resno,= int size) if (!(res->flags & IORESOURCE_UNSET)) return -EBUSY; =20 - pci_read_config_word(dev, PCI_COMMAND, &cmd); - if (cmd & PCI_COMMAND_MEMORY) + if (pci_resize_is_memory_decoding_enabled(dev, resno)) return -EBUSY; =20 sizes =3D pci_rebar_get_possible_sizes(dev, resno); @@ -461,7 +484,7 @@ int pci_resize_resource(struct pci_dev *dev, int resno,= int size) if (ret) return ret; =20 - res->end =3D res->start + pci_rebar_size_to_bytes(size) - 1; + pci_resize_resource_set_size(dev, resno, size); =20 /* Check if the new config works by trying to assign everything. */ if (dev->bus->self) { @@ -473,7 +496,7 @@ int pci_resize_resource(struct pci_dev *dev, int resno,= int size) =20 error_resize: pci_rebar_set_size(dev, resno, old); - res->end =3D res->start + pci_rebar_size_to_bytes(old) - 1; + pci_resize_resource_set_size(dev, resno, old); return ret; } EXPORT_SYMBOL(pci_resize_resource); --=20 2.47.0