From nobody Mon Nov 25 16:53:39 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 DFEAA213154; Fri, 25 Oct 2024 21:51:21 +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=1729893084; cv=fail; b=obPPlS3gQTyHdKPXQpkaPDWKcL6Gk4bHe1IMQwhBTOgbY3qDPyutxBzzkHzMktM3VTSiTT+tgYLhAZ2VOf5F7Rpl6ZQhOxc/9vskkNjIwnm1d/83MTqVpT7vNNWgqdgF0ixT4rVuYdvmCRBwyvMgkuUR0Z8tuztA1fA1CNPWmvY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729893084; c=relaxed/simple; bh=S3MtAJFYYvsilqByJKro/df74qguvca7gbT6ls0V49w=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=iEvc/Rhjde8RwyuakDprA3v976I9Hx/3UMnm0EWvGuNqAXBOQvoBfAG+qp8dk3UFpUcWepOZ9otzzIWvrqq5c3o468kEXD1uv3vHFUtYc+LFeotka/VUT6dpu9JnjhpJkhy5UpsY1LQQP2gKgLvCbeWw3gkTK9jwm9jLWYIOdHQ= 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=E7P5NFae; 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="E7P5NFae" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1729893082; x=1761429082; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=S3MtAJFYYvsilqByJKro/df74qguvca7gbT6ls0V49w=; b=E7P5NFaeja/ITBfXK0JGRDmaaD5fR6Vu4/X6SXX89totZFCQRGoXu6bx LleWiItsAX7MpytBnrUfQFvNerGGrBvPo2xM8vCVajvmyRjslSHJaloZe XUeXblXINEhDGi2k/OAHjYR3zDk23m1JXfUh3MPw/yiWTm1yS0mFC05Vy Dz5O7TD0df5iMIdf0Bsu709U8cwCZZcxn+TvVpAWZFxxt6EOkTH111kk+ QYDVJO4Kvx/NTOtQvwsDqX1U+obbve1qeWkZOScfTSfKAh7gkGhH007+1 XEm70byGsJFfHiy0tgKvMtjDojWViex8NlXrhsCPCq64HjEipCqdexdZW w==; X-CSE-ConnectionGUID: HQ+AT2wcQm+0zvUmZLNzIg== X-CSE-MsgGUID: Y+GcGc1TRUiOQbQtyvZ2IQ== X-IronPort-AV: E=McAfee;i="6700,10204,11236"; a="29683445" X-IronPort-AV: E=Sophos;i="6.11,233,1725346800"; d="scan'208";a="29683445" 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:22 -0700 X-CSE-ConnectionGUID: oeCL1L6rRQarrTCs/L0zWw== X-CSE-MsgGUID: L2Ewi+7+Qvyl0kZXkA4b5w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,233,1725346800"; d="scan'208";a="81492907" 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:20 -0700 Received: from orsmsx602.amr.corp.intel.com (10.22.229.15) 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:19 -0700 Received: from ORSEDG602.ED.cps.intel.com (10.7.248.7) by orsmsx602.amr.corp.intel.com (10.22.229.15) 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:19 -0700 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (104.47.56.175) by edgegateway.intel.com (134.134.137.103) 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:19 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=uKbCVaaOFtXjgQR3cKd1JaQzfH44fse3ps3Ppw6Kh+XSTvic/RqzF6ePpl7ZLSOlMJ5Hcqo72wzwlxwSI7n1winl8jQaBdBk59zIRcBXuFDNazUrbvJf80CKRgAeibHxWtG+Om7xq5+oAKBWGR8xrWzy7iGhT3FWkhyeUx0y2efTccc3KGHfqhFAX8n3Z54BDUyz91xQQ2U91BdQSNQDjXitMEKCYda7kgldyKcNuLN9VgXUnNr0AdYXtzSNBHGZqBt5roIInCBTiXRt4Y80kB18sSF2Ih1OiDqxc1h3xVNsds1c0xi8nM0Ciasir2jPsBvJPvvD0DZy5FB/fv3M/Q== 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=Sh9KtT2pJ4ZvygJzlA3ulaFMLixbb90nBzVxCGkLSpY=; b=ImTebWVEZNNpAWWnqgFanrqdG9iDf4iHs8Viy5MEe/TB8pyTyGl7Nvskuhk+bR3qxXxjUFlcyvi4QJBiq7jJ9Bt2oiMJWah1X3bwQyFMILx5HdfhL21EEtn1gLV1qX5Z1a08VT+Pipbz3zvGRdbdCfsEFzR4DkS+kkenPxeMVDk3b8+JWvvwvbOxJcpdTrOZPtR/LbHh+ZPrk7WKVvNxsbqji0JwiEafOrUorHQUIEAEwT4z+TQ85eYGH8zsb8XL+fKPzKLnmqa+akKiQrUp5kDomy7iMPSCSsnKeTIVa1+1xwduI3FaNIB/ClhKvnZ++N7WQ9lmRiXF6jLgnewFcg== 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 CY8PR11MB7745.namprd11.prod.outlook.com (2603:10b6:930:90::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.16; Fri, 25 Oct 2024 21:51:17 +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:17 +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 4/7] PCI: Allow IOV resources to be resized in pci_resize_resource() Date: Fri, 25 Oct 2024 23:50:35 +0200 Message-ID: <20241025215038.3125626-5-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: WA2P291CA0037.POLP291.PROD.OUTLOOK.COM (2603:10a6:1d0:1f::17) 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_|CY8PR11MB7745:EE_ X-MS-Office365-Filtering-Correlation-Id: c697f026-fc7d-4f0d-31f9-08dcf53f27ae X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|366016|1800799024|376014; X-Microsoft-Antispam-Message-Info: =?utf-8?B?QkdtSzE1TG44L1dMRW1jNndBamRmN2xlVUNUTGpzSTEvZExUM1FpUTU5akNu?= =?utf-8?B?ejBSZVpzcDBNQ2RCZHNRSUpqaDlLL0FiWkRrTDdoZ1h3SVVIUVBQc3hGMDZs?= =?utf-8?B?UFBkRzdIMjE3S3M1TzZaZHVwK3ZCUjFPMWthdW15UnViU3A5Mzh6ZFIrTU1l?= =?utf-8?B?citvQzJHREh6b25RU3B0aEVqT2R6Z0FXc1JBQWZCTjJLeG92RGFFTVN6QXZx?= =?utf-8?B?R1hzS084dEhnMUR5U0d3aUpBQVFsSW01NkZQM1JFNjRUeG9DTExYWWhuRVov?= =?utf-8?B?NGJhd2JTV2JrR3FvZUlhYWt4V0EyUzdGQnB0OW1rYlFwOGY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EbWN4V1ZlTFNtWURvQUY0cUpMcjRLUjdVV3NU?= =?utf-8?B?azhRTXdObTBtOERkYVZuTFd5Vkd1b2l2dkh3alZtOGREbHRPT2dMazhEZDN1?= =?utf-8?B?SWNCWFQ2TWVveU5COHZ1MlNaei9SWDZqeVl0ZVBTRmZHMVpvNGRDN0tkbW45?= =?utf-8?B?ZzN6c2lTYVV6T0hFMCs4b3RiWGYxL2pyZHN6bEZ3VTJFV3FkalpBTUhEQTd6?= =?utf-8?B?MmFZNys0eDJtOGM1SVdZcmR0eWRWc3Q4b005U0lBbUVLbDY2ZDVWbEMzNkNR?= =?utf-8?B?a1VWOVVSUk5XUFBRS2tKN2hzZXFRbkE3WTZlWWJkZzJPcGFEV3BsdFF4a0Uy?= =?utf-8?B?TmJYeGI4WVFKM3ZvcU9lTGhzUjNlTDVPL2VkQkN4RDY1SlBXd3lEcTFqV1lk?= =?utf-8?B?UHhNcnBFTytpT2E2QUZoTlJtQ0dycHdDMGpqNVRLU1RNMDlLQnFERjRsNlR2?= =?utf-8?B?a2M0MWZQeTJqRDY4blZ2ck1GMjRWVjdnUEtVd2VNdEdJV1cyem1laktDa2JG?= =?utf-8?Q?6Xojk4oQBnNWBdZh8o=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)(7416014)(366016)(1800799024)(376014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?MElhLzJPUllWVnVlcDRsN0pzejhzSTdQWjBDTjhCQnowTmNpelkzOXpTbW9r?= =?utf-8?B?ZXVYSmI4M09IUlc5WngrKzg3Q3RJS2hKblpXb0ovckJxZ1BDeVNsQ21URllp?= =?utf-8?B?Uyt1KzVuVVlYcEh1cmQ1QWVXNFdoeEhtc043SHN2MjhL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BLVEp4L0xPc3JMSzQ4c25MZ3pobkMz?= =?utf-8?B?Z01BQXpVcU8zT3FlM08zdlUzMHRIRUdzSmRndzQwc3VmMkt3bVZ2Y3VENHFW?= =?utf-8?B?Y0d4M2dRdzllbTJoNUEzYTRvVTJsZ2RYTUpHS21jdXNYNTl6d2xrdU5Ga0FX?= =?utf-8?B?aGNOWHA0U284OG9ZNS84TzNhQVJrUDdQV2c3WlhTVnZnNmhKNk1RUk9FUVNt?= =?utf-8?B?MlE9PQ==?= X-MS-Exchange-CrossTenant-Network-Message-Id: c697f026-fc7d-4f0d-31f9-08dcf53f27ae 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:17.8524 (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: ZRcEBI2gJ0QJeOH2lroBrnXszOR13W8lchFKxupVDPJHT8gEtwpJz7h6L5AWt803t48sw4ui5JmXtxWVh876GUAHqUiRpxGqYWbz436kFTU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY8PR11MB7745 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. Extend the pci_resize_resource() function to accept IOV resources. See PCIe r4.0, sec 9.3.7.4. Signed-off-by: Micha=C5=82 Winiarski --- drivers/pci/iov.c | 21 +++++++++++++++++++++ drivers/pci/pci.c | 10 +++++++++- drivers/pci/pci.h | 10 +++++++++- drivers/pci/setup-res.c | 36 +++++++++++++++++++++++++++++++----- 4 files changed, 70 insertions(+), 7 deletions(-) diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c index eedc1df56c49e..79143c1bc7bb4 100644 --- a/drivers/pci/iov.c +++ b/drivers/pci/iov.c @@ -154,6 +154,27 @@ resource_size_t pci_iov_resource_size(struct pci_dev *= dev, int resno) return dev->sriov->barsz[pci_resource_from_iov(resno)]; } =20 +void pci_iov_resource_set_size(struct pci_dev *dev, int resno, + resource_size_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[pci_resource_from_iov(resno)] =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..905a533807b32 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -3720,8 +3720,16 @@ static int pci_rebar_find_pos(struct pci_dev *pdev, = int bar) { unsigned int pos, nbars, i; u32 ctrl; + int cap; =20 - pos =3D pci_find_ext_capability(pdev, PCI_EXT_CAP_ID_REBAR); + if (pci_resource_is_iov(bar)) { + cap =3D PCI_EXT_CAP_ID_VF_REBAR; + bar =3D pci_resource_from_iov(bar); + } else { + cap =3D PCI_EXT_CAP_ID_REBAR; + } + + 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 1f8d88f0243b7..4347858007145 100644 --- a/drivers/pci/pci.h +++ b/drivers/pci/pci.h @@ -580,6 +580,9 @@ void pci_iov_update_resource(struct pci_dev *dev, int r= esno); resource_size_t pci_sriov_resource_alignment(struct pci_dev *dev, int resn= o); void pci_restore_iov_state(struct pci_dev *dev); int pci_iov_bus_range(struct pci_bus *bus); +void pci_iov_resource_set_size(struct pci_dev *dev, int resno, + resource_size_t size); +bool pci_iov_is_memory_decoding_enabled(struct pci_dev *dev); static inline bool pci_resource_is_iov(int resno) { return resno >=3D PCI_IOV_RESOURCES && resno <=3D PCI_IOV_RESOURCE_END; @@ -613,6 +616,12 @@ static inline int pci_iov_bus_range(struct pci_bus *bu= s) { return 0; } +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; +} static inline bool pci_resource_is_iov(int resno) { return false; @@ -621,7 +630,6 @@ static inline int pci_resource_to_iov(int resno) { return -ENODEV; } - static inline int pci_resource_from_iov(int resno) { return -ENODEV; diff --git a/drivers/pci/setup-res.c b/drivers/pci/setup-res.c index e2cf79253ebda..cec8f684b7c70 100644 --- a/drivers/pci/setup-res.c +++ b/drivers/pci/setup-res.c @@ -425,13 +425,40 @@ 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, + int 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 +469,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 +487,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 +499,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