From nobody Fri Dec 19 19:17:54 2025 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) (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 16E30139CEF; Tue, 14 May 2024 11:31:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.10 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715686289; cv=none; b=n9iUdmBoF5aNLORRjbAHOeVZr77EdN5Wuqzfif480LQLniKocqlg7sh0OilZdALv/nV1M+2QHgU7OohxEKTXwi/QmxEMN6tFLbKzuMMf6F8HH1bs4mEHf+XO+eUY0vDKw+N9BqdZSFjDTDYWQ+3Hn/XHr9oogJp0N4naGpcCdJY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715686289; c=relaxed/simple; bh=nDVHo/uGXMDlWtWQD47FWInWDYtBZPj5d51tV3Jx/N8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=l/gJVE73rFQMDbWy2njkWEr2Q5Zi/T/BSM5TJXOos+pyIwilPTp5N5oWWrCkaI+wfAZRf+S4DHytfRk1Ems4lLnlJ80g2lXARSKTFdBhyw3elGrZgxkNsj1f8JG/KGe1UKz7wliFKVogxUpLQ6t4yFaeM7HzDYxOQ2G0PJha540= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=kVZMSJ1/; arc=none smtp.client-ip=198.175.65.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="kVZMSJ1/" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1715686289; x=1747222289; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=nDVHo/uGXMDlWtWQD47FWInWDYtBZPj5d51tV3Jx/N8=; b=kVZMSJ1/xfh56XeXRo1Rb69qHKPBAieR22RALXUoB5QzoeiEaSceRNcv KWzMwzxVHNzRD8qJLgn9tRWKFnJlvuEEAZNipKKdzT8KjQaaOsjH3KU1H zGO+SDMsJtDXqUuYOvmEyN7tzsa8Ti7R8HL72quYNrAeZ6YOjRZqWuBhC HAPuB4LUZNduHMhKX3JdvczU0rq8fbVEKTTnLB2AQ1PNCQirlBOcHXS4y 4drczavkUPOxyLgrMeHgvWGlMUedHLaAY2Ql57EgB3hIuzac+rvH4Uyin u/FOvVLLiMF2w5a/sF6/vWQjBMu+JiWMkLZEhgJyJ4WNsX/NZ7kbcl3C6 A==; X-CSE-ConnectionGUID: 3KvgI97PQ+m6SSgW4s3dLw== X-CSE-MsgGUID: zwywv7LsRjmqPap6UIhyiA== X-IronPort-AV: E=McAfee;i="6600,9927,11072"; a="29152234" X-IronPort-AV: E=Sophos;i="6.08,159,1712646000"; d="scan'208";a="29152234" Received: from orviesa003.jf.intel.com ([10.64.159.143]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 May 2024 04:31:28 -0700 X-CSE-ConnectionGUID: BWEJpvY4QriiWwPvmPUnWg== X-CSE-MsgGUID: SYE5w8IqQEyqrNlAR5Rfsg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,159,1712646000"; d="scan'208";a="35367276" Received: from ijarvine-desk1.ger.corp.intel.com (HELO localhost) ([10.245.247.94]) by ORVIESA003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 May 2024 04:31:25 -0700 From: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= To: linux-pci@vger.kernel.org, Bjorn Helgaas , Mahesh J Salgaonkar , Oliver O'Halloran , Lukas Wunner , linux-kernel@vger.kernel.org Cc: linuxppc-dev@lists.ozlabs.org, =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= Subject: [PATCH v5 1/7] PCI: Don't expose pcie_read_tlp_log() outside of PCI subsystem Date: Tue, 14 May 2024 14:31:03 +0300 Message-Id: <20240514113109.6690-2-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240514113109.6690-1-ilpo.jarvinen@linux.intel.com> References: <20240514113109.6690-1-ilpo.jarvinen@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable pcie_read_tlp_log() was exposed by the commit 0a5a46a6a61b ("PCI/AER: Generalize TLP Header Log reading") but this is now considered a mistake. No drivers outside of PCI subsystem should build their own diagnostic logging but should rely on PCI core doing it for them. There's currently one driver (ixgbe) doing it independently which was the initial reason why the export was added but it was decided by the PCI maintainer that it's something that should be eliminated. Remove the unwanted EXPORT of pcie_read_tlp_log() and remove it from include/linux/aer.h. Link: https://lore.kernel.org/all/20240322193011.GA701027@bhelgaas/ Signed-off-by: Ilpo J=C3=A4rvinen --- drivers/pci/pci.c | 1 - drivers/pci/pci.h | 4 ++++ include/linux/aer.h | 2 -- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index e5f243dd4288..54ab1d6b8e53 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -1092,7 +1092,6 @@ int pcie_read_tlp_log(struct pci_dev *dev, int where, =20 return 0; } -EXPORT_SYMBOL_GPL(pcie_read_tlp_log); =20 /** * pci_restore_bars - restore a device's BAR values (e.g. after wake-up) diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h index 17fed1846847..9c968df86a92 100644 --- a/drivers/pci/pci.h +++ b/drivers/pci/pci.h @@ -4,6 +4,8 @@ =20 #include =20 +struct pcie_tlp_log; + /* Number of possible devfns: 0.0 to 1f.7 inclusive */ #define MAX_NR_DEVFNS 256 =20 @@ -419,6 +421,8 @@ int aer_get_device_error_info(struct pci_dev *dev, stru= ct aer_err_info *info); void aer_print_error(struct pci_dev *dev, struct aer_err_info *info); #endif /* CONFIG_PCIEAER */ =20 +int pcie_read_tlp_log(struct pci_dev *dev, int where, struct pcie_tlp_log = *log); + #ifdef CONFIG_PCIEPORTBUS /* Cached RCEC Endpoint Association */ struct rcec_ea { diff --git a/include/linux/aer.h b/include/linux/aer.h index 4b97f38f3fcf..190a0a2061cd 100644 --- a/include/linux/aer.h +++ b/include/linux/aer.h @@ -37,8 +37,6 @@ struct aer_capability_regs { u16 uncor_err_source; }; =20 -int pcie_read_tlp_log(struct pci_dev *dev, int where, struct pcie_tlp_log = *log); - #if defined(CONFIG_PCIEAER) int pci_aer_clear_nonfatal_status(struct pci_dev *dev); int pcie_aer_is_native(struct pci_dev *dev); --=20 2.39.2 From nobody Fri Dec 19 19:17:54 2025 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.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 44331139D1D; Tue, 14 May 2024 11:31:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.17 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715686297; cv=none; b=cDt6r8NQ92+0hbSV4iCbUYtzleoxECLbUGbSrC+0uqAauwJcYSazz7X8rd2htusz6I8zOVtam9GI9gyn5CimbmV/+m/mowEBf7xY+EjdM4tByUV+0EwbnAsMbEpy7PF/X2hwk3g6j6FSX9DGuW02iGKOF5QspPUVUWr8VXfIs4w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715686297; c=relaxed/simple; bh=8lcN3GvS4xT+weTctxWkQ4vlzKc0rZNrscZi4UP5ads=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=n4NKRXYJagRp30ipyEEUer2u9Q66+7cC9fDCZ1opTYh4qecyH8lNNECTuh4FJ48/0BAAgEynUI8xLk62FNb/qi8sT35O4MJQPneVN2A0FSwsxJqbdowY3VJoc3LO/fmJn/gZmzN2VbXsTmt2qSLtHVuM44YyjOPfqFnxMm6dnWo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=ghjH8XA/; arc=none smtp.client-ip=192.198.163.17 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="ghjH8XA/" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1715686295; x=1747222295; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=8lcN3GvS4xT+weTctxWkQ4vlzKc0rZNrscZi4UP5ads=; b=ghjH8XA/DirVTI/JO0O0HEVr69tRvi/PD4On+BwZRcCkZ/NFdWwej43D uAW2ZxDGh2FxFTLdYLt9KDGb35BJ05QjiF3AOkYcv667VeDcQfb77hIoM A2NiCNTaErt4nmHcAqKtmWS7PyfxVnD39+dJHvyQYspJ43edhP8qg7uZf vl1CzP/c2w47EJJ0KtSj5ovkr8eo//QinTzVj3zFCdx69XBHkvAjs7Zm7 aYBLMrhvQB2lNKhxExkhvG6oneS96vKPdLACW/rj6gdg9aBH8LbAnNf9Q NACa1ZlPskQoaE8tWMxX6LyBaf0l5/5a58liZkJ7Jg+/+ujrOUyPB8uge Q==; X-CSE-ConnectionGUID: i0XkS730QLCpIWfTuJWlfA== X-CSE-MsgGUID: QeEVo/A1SJ+W0mgnKoDYzw== X-IronPort-AV: E=McAfee;i="6600,9927,11072"; a="11532837" X-IronPort-AV: E=Sophos;i="6.08,159,1712646000"; d="scan'208";a="11532837" Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by fmvoesa111.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 May 2024 04:31:34 -0700 X-CSE-ConnectionGUID: JiaICyhjSFeSR+iLgSEnBQ== X-CSE-MsgGUID: CMV6tNX1TLm1mOr8TkQNkg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,159,1712646000"; d="scan'208";a="35179635" Received: from ijarvine-desk1.ger.corp.intel.com (HELO localhost) ([10.245.247.94]) by fmviesa003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 May 2024 04:31:33 -0700 From: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= To: linux-pci@vger.kernel.org, Bjorn Helgaas , Mahesh J Salgaonkar , Oliver O'Halloran , Lukas Wunner , linux-kernel@vger.kernel.org Cc: linuxppc-dev@lists.ozlabs.org, =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= Subject: [PATCH v5 2/7] PCI: Move TLP Log handling to own file Date: Tue, 14 May 2024 14:31:04 +0300 Message-Id: <20240514113109.6690-3-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240514113109.6690-1-ilpo.jarvinen@linux.intel.com> References: <20240514113109.6690-1-ilpo.jarvinen@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable TLP Log is PCIe feature and is processed only by AER and DPC. Configwise, DPC depends AER being enabled. In lack of better place, the TLP Log handling code was initially placed into pci.c but it can be easily placed in a separate file. Move TLP Log handling code to own file under pcie/ subdirectory and include it only when AER is enabled. Signed-off-by: Ilpo J=C3=A4rvinen --- drivers/pci/pci.c | 27 --------------------------- drivers/pci/pci.h | 2 +- drivers/pci/pcie/Makefile | 2 +- drivers/pci/pcie/tlp.c | 39 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 41 insertions(+), 29 deletions(-) create mode 100644 drivers/pci/pcie/tlp.c diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 54ab1d6b8e53..2cc875f60fef 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -1066,33 +1066,6 @@ static void pci_enable_acs(struct pci_dev *dev) pci_disable_acs_redir(dev); } =20 -/** - * pcie_read_tlp_log - read TLP Header Log - * @dev: PCIe device - * @where: PCI Config offset of TLP Header Log - * @tlp_log: TLP Log structure to fill - * - * Fill @tlp_log from TLP Header Log registers, e.g., AER or DPC. - * - * Return: 0 on success and filled TLP Log structure, <0 on error. - */ -int pcie_read_tlp_log(struct pci_dev *dev, int where, - struct pcie_tlp_log *tlp_log) -{ - int i, ret; - - memset(tlp_log, 0, sizeof(*tlp_log)); - - for (i =3D 0; i < 4; i++) { - ret =3D pci_read_config_dword(dev, where + i * 4, - &tlp_log->dw[i]); - if (ret) - return pcibios_err_to_errno(ret); - } - - return 0; -} - /** * pci_restore_bars - restore a device's BAR values (e.g. after wake-up) * @dev: PCI device to have its BARs restored diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h index 9c968df86a92..0e9917f8bf3f 100644 --- a/drivers/pci/pci.h +++ b/drivers/pci/pci.h @@ -419,9 +419,9 @@ struct aer_err_info { =20 int aer_get_device_error_info(struct pci_dev *dev, struct aer_err_info *in= fo); void aer_print_error(struct pci_dev *dev, struct aer_err_info *info); -#endif /* CONFIG_PCIEAER */ =20 int pcie_read_tlp_log(struct pci_dev *dev, int where, struct pcie_tlp_log = *log); +#endif /* CONFIG_PCIEAER */ =20 #ifdef CONFIG_PCIEPORTBUS /* Cached RCEC Endpoint Association */ diff --git a/drivers/pci/pcie/Makefile b/drivers/pci/pcie/Makefile index 6461aa93fe76..591ef3177777 100644 --- a/drivers/pci/pcie/Makefile +++ b/drivers/pci/pcie/Makefile @@ -7,7 +7,7 @@ pcieportdrv-y :=3D portdrv.o rcec.o obj-$(CONFIG_PCIEPORTBUS) +=3D pcieportdrv.o =20 obj-y +=3D aspm.o -obj-$(CONFIG_PCIEAER) +=3D aer.o err.o +obj-$(CONFIG_PCIEAER) +=3D aer.o err.o tlp.o obj-$(CONFIG_PCIEAER_INJECT) +=3D aer_inject.o obj-$(CONFIG_PCIE_PME) +=3D pme.o obj-$(CONFIG_PCIE_DPC) +=3D dpc.o diff --git a/drivers/pci/pcie/tlp.c b/drivers/pci/pcie/tlp.c new file mode 100644 index 000000000000..3f053cc62290 --- /dev/null +++ b/drivers/pci/pcie/tlp.c @@ -0,0 +1,39 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * PCIe TLP Log handling + * + * Copyright (C) 2024 Intel Corporation + */ + +#include +#include +#include + +#include "../pci.h" + +/** + * pcie_read_tlp_log - read TLP Header Log + * @dev: PCIe device + * @where: PCI Config offset of TLP Header Log + * @tlp_log: TLP Log structure to fill + * + * Fill @tlp_log from TLP Header Log registers, e.g., AER or DPC. + * + * Return: 0 on success and filled TLP Log structure, <0 on error. + */ +int pcie_read_tlp_log(struct pci_dev *dev, int where, + struct pcie_tlp_log *tlp_log) +{ + int i, ret; + + memset(tlp_log, 0, sizeof(*tlp_log)); + + for (i =3D 0; i < 4; i++) { + ret =3D pci_read_config_dword(dev, where + i * 4, + &tlp_log->dw[i]); + if (ret) + return pcibios_err_to_errno(ret); + } + + return 0; +} --=20 2.39.2 From nobody Fri Dec 19 19:17:54 2025 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.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 BA8D213A3F4; Tue, 14 May 2024 11:31:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.17 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715686303; cv=none; b=eaSNbzRUjt8jyXatpAxSf70socVG10/O2WPq1aH306AXDqd8MAvNjc1szcv5tKT54zWiTwA2IaDB+BNwUo/1SLTexZBVEvuIBVcVB47+Rgs6dFW+zGU0MbKPXfeC8pZEVrTj8uZv6X68TYZdxOC4L1fRKtg4YonNbGW9dN1bMPk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715686303; c=relaxed/simple; bh=TVMIEcYV4lRuU2NwGaITevK1+8W4KKh6YOoRO/qra7M=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=L6Ci2qJ8YVHuX9qAcVa82vYgmPGFopjx+/omvLUgj7rgDVkcBeb4nP8E8pAVUlHYcjM7WTZfOvAPfvJ2BFRR6R0RfLIqxvBba9D+p0q6Cgx/udsrs4xP4aoOoYGQ/wezxyIUBI5WgjbqcMS07AGCMaRjyYIs3fUzNlPpeSRhDgc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=TgHyshzJ; arc=none smtp.client-ip=192.198.163.17 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="TgHyshzJ" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1715686302; x=1747222302; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=TVMIEcYV4lRuU2NwGaITevK1+8W4KKh6YOoRO/qra7M=; b=TgHyshzJByyPypSUu8YTIuZSRbE3kzXaeSWNWancv4PWvY0uYzNJz4TZ dLjU/Dmr563yQnWF3wYv/htVihRrOjRwRJ+ba0H9opBh+iDIaWxFEM1MO CKnQ/fcDWcrG1MDyGabQxDyYbl5gZrjauIqHDKusnQk9mH+Ks+3gvSPXD e3jVzRs527i4vn0rBPpks4ZcEGLKHs59phBFLsFphu+gyOg2xPRTYEKoA ba2ecDADJJjuECcTfXQoEZSFGl3emEAnQu03CurZqoDX/61JgsTTdxbII Vf6Ct3K0Ba4aBiVfHxzbhZBkUNpcZ9HfwqQW3sxFFP5T69lN06SIoFBie A==; X-CSE-ConnectionGUID: +GaiWyPkSHugrvLeQ5Y+Xg== X-CSE-MsgGUID: w5FSi+ASSZiozgQGsIVRgg== X-IronPort-AV: E=McAfee;i="6600,9927,11072"; a="11532857" X-IronPort-AV: E=Sophos;i="6.08,159,1712646000"; d="scan'208";a="11532857" Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by fmvoesa111.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 May 2024 04:31:41 -0700 X-CSE-ConnectionGUID: 844xaLByTxenDKOJuhlo9A== X-CSE-MsgGUID: fNfF3l0LR+igBuWIpRYdGQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,159,1712646000"; d="scan'208";a="35179648" Received: from ijarvine-desk1.ger.corp.intel.com (HELO localhost) ([10.245.247.94]) by fmviesa003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 May 2024 04:31:40 -0700 From: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= To: linux-pci@vger.kernel.org, Bjorn Helgaas , Mahesh J Salgaonkar , Oliver O'Halloran , Lukas Wunner , linux-kernel@vger.kernel.org Cc: linuxppc-dev@lists.ozlabs.org, =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= Subject: [PATCH v5 3/7] PCI: Make pcie_read_tlp_log() signature same Date: Tue, 14 May 2024 14:31:05 +0300 Message-Id: <20240514113109.6690-4-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240514113109.6690-1-ilpo.jarvinen@linux.intel.com> References: <20240514113109.6690-1-ilpo.jarvinen@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable pcie_read_tlp_log()'s prototype and function signature diverged due to changes made while applying. Make the parameters of pcie_read_tlp_log() named identically. Signed-off-by: Ilpo J=C3=A4rvinen --- drivers/pci/pcie/tlp.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/pci/pcie/tlp.c b/drivers/pci/pcie/tlp.c index 3f053cc62290..2bf15749cd31 100644 --- a/drivers/pci/pcie/tlp.c +++ b/drivers/pci/pcie/tlp.c @@ -15,22 +15,21 @@ * pcie_read_tlp_log - read TLP Header Log * @dev: PCIe device * @where: PCI Config offset of TLP Header Log - * @tlp_log: TLP Log structure to fill + * @log: TLP Log structure to fill * - * Fill @tlp_log from TLP Header Log registers, e.g., AER or DPC. + * Fill @log from TLP Header Log registers, e.g., AER or DPC. * * Return: 0 on success and filled TLP Log structure, <0 on error. */ int pcie_read_tlp_log(struct pci_dev *dev, int where, - struct pcie_tlp_log *tlp_log) + struct pcie_tlp_log *log) { int i, ret; =20 - memset(tlp_log, 0, sizeof(*tlp_log)); + memset(log, 0, sizeof(*log)); =20 for (i =3D 0; i < 4; i++) { - ret =3D pci_read_config_dword(dev, where + i * 4, - &tlp_log->dw[i]); + ret =3D pci_read_config_dword(dev, where + i * 4, &log->dw[i]); if (ret) return pcibios_err_to_errno(ret); } --=20 2.39.2 From nobody Fri Dec 19 19:17:54 2025 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.18]) (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 2B2F913A3F4; Tue, 14 May 2024 11:31:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715686310; cv=none; b=KO68XeWzM4o2TS6NNdaq2jP0KFMix2AEjl4TKsgP2QyzoNPM2d8QlZOZYuTxzfGYQzdjVs9KhYdNeaaan+ve7MNWtjVN1r+tziSKXmSw5oR0rqA62iTR6jZa866Trry/Ae2NAK3QwUyaLXhDm7MhQFSTZ1ngoQbgzaIzqfMLuBw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715686310; c=relaxed/simple; bh=vrR9lSZtbojiA2EubTfEXC7NUqhoH2bBkEIK7kkkTFA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=PTd4g6o5xiQvNbGik6uV8a3ZwGvD9RIh6L18+Jn28QLvyuV7fA16/VE1Pdup/4bl/bqSpb9MKLJF3XCPPGClY4k6Q/AayhJPEoCcHLZdvtuZv27bk4uSzLXblXFA8G7Td3qhe/sQHPIsWmOSKNI7nc40TO+aPtO1uhtLmHDPZ7E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=mm7hOBmN; arc=none smtp.client-ip=198.175.65.18 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="mm7hOBmN" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1715686309; x=1747222309; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=vrR9lSZtbojiA2EubTfEXC7NUqhoH2bBkEIK7kkkTFA=; b=mm7hOBmNMUAGZnL02CKUKubZHxyGIk1NzAHwUfGUjQGWdclbj2RJ+7bM A1AVk6YYBpNJEjvaiFIBQE5jj7JPFxSKqvFOHlW76Yl+zZU5u7rwhTaFs X12/GCyj9QVElNvX7fav0L2/XtfPK18zSrtSB/QEnzf9e6ZGtQaibG/1L +NvOMfsyp6r6crtHxT6aKDnko2c7ABX8cfW2hnGcSM8V3cFZ8c8FcoALK sRb9HtvyiXByCPGBb5urSS14sYm65XQ0W+nbkMDFPJIWUdBoEPwBu8S23 NKXab9ohuVh7wLraTcOj1uewCx9GVhtJgENhydvviMOE37lQe2ao+B9dh w==; X-CSE-ConnectionGUID: ubtNonguQxC4F31d4Qoe9w== X-CSE-MsgGUID: 3QNQqwuPT+aLCs6NPdDCmQ== X-IronPort-AV: E=McAfee;i="6600,9927,11072"; a="11828362" X-IronPort-AV: E=Sophos;i="6.08,159,1712646000"; d="scan'208";a="11828362" Received: from orviesa004.jf.intel.com ([10.64.159.144]) by orvoesa110.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 May 2024 04:31:48 -0700 X-CSE-ConnectionGUID: KG7Hzpw5QAiIDG1AMRMHXQ== X-CSE-MsgGUID: tq9/EgpNSqGv1BQd50GHDw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,159,1712646000"; d="scan'208";a="35546228" Received: from ijarvine-desk1.ger.corp.intel.com (HELO localhost) ([10.245.247.94]) by orviesa004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 May 2024 04:31:47 -0700 From: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= To: linux-pci@vger.kernel.org, Bjorn Helgaas , Mahesh J Salgaonkar , Oliver O'Halloran , Lukas Wunner , linux-kernel@vger.kernel.org Cc: linuxppc-dev@lists.ozlabs.org, =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= Subject: [PATCH v5 4/7] PCI: Use unsigned int i in pcie_read_tlp_log() Date: Tue, 14 May 2024 14:31:06 +0300 Message-Id: <20240514113109.6690-5-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240514113109.6690-1-ilpo.jarvinen@linux.intel.com> References: <20240514113109.6690-1-ilpo.jarvinen@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Loop variable i counting from 0 upwards does not need to be signed so make it unsigned int. Signed-off-by: Ilpo J=C3=A4rvinen --- drivers/pci/pcie/tlp.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/pci/pcie/tlp.c b/drivers/pci/pcie/tlp.c index 2bf15749cd31..65ac7b5d8a87 100644 --- a/drivers/pci/pcie/tlp.c +++ b/drivers/pci/pcie/tlp.c @@ -24,7 +24,8 @@ int pcie_read_tlp_log(struct pci_dev *dev, int where, struct pcie_tlp_log *log) { - int i, ret; + unsigned int i; + int ret; =20 memset(log, 0, sizeof(*log)); =20 --=20 2.39.2 From nobody Fri Dec 19 19:17:54 2025 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) (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 50F8D13B284; Tue, 14 May 2024 11:31:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.10 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715686317; cv=none; b=NwMqg53kGOlOIlZ3FjpqqzwOUV1GvyV3wDaIDlSb2wuM1YRALr9PjkoF/6RQImTOH2626mpVuDHNRU8OgWL5bo+ZmciJw0zXVFCWcArbU1lU3bwNGo3h5NepbY8oANoU6T0WDFoGVfo9noCC0Ao9nD/6Bx/NwlYl4UUmPLPFzQA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715686317; c=relaxed/simple; bh=ycAlJAFDIexTuV0gkyQkoIj4+wwZGM3l2xmJQx719nA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=oblPtPhKzYBSD1xVUZUqCH8D/Lyyj/yY0GbxkNlWpL3eeeh6KsOKcoDM4GKYswBVipNaF2zeoAiwSWavTQV5AFOSbpIc765cEZLZny+EVUGYmY5n0pzIItGgksp72e29pCjXmclyr1voZJtVO/bqA+eIUS22w2U7VcXI8ozNCzY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=RENJ3nSk; arc=none smtp.client-ip=198.175.65.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="RENJ3nSk" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1715686317; x=1747222317; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ycAlJAFDIexTuV0gkyQkoIj4+wwZGM3l2xmJQx719nA=; b=RENJ3nSk5ZCiRQAg/jdkzLriqAqmUOjPxZuak749764EPvwzhf5tb0FO 0Z5zFUE8FWBGsZTyzIY8HkmvSNXS7VvD8yB20aDS3vOSLGymptaKBg+Ar IX0BnmeYTCWIRGm26+7UHcUydWlz+Zp3YoGs+mXo79+UFbJ/o3uIYLzci pWO2WWXJHzbNjUgMjP/5fT1Ez0FgUFr+iGAOKaEntWhIwrWIVf7qYIkTp uPUcdR1V8aQQVmcRo+YRhv7GdqbWgOsuKtZCCGDBT8V+mtU/5Aq0/eCVS CpB0LO08KckNkuIujVnmAU4u/nTgNmnq7TdxeQjX+R+0SMH93km9BkdPO Q==; X-CSE-ConnectionGUID: KNZgCWAySDaOCP6PHflmmw== X-CSE-MsgGUID: ZZvcn7yyQ7aUC64OGn2NuQ== X-IronPort-AV: E=McAfee;i="6600,9927,11072"; a="29152266" X-IronPort-AV: E=Sophos;i="6.08,159,1712646000"; d="scan'208";a="29152266" Received: from orviesa003.jf.intel.com ([10.64.159.143]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 May 2024 04:31:56 -0700 X-CSE-ConnectionGUID: Dbq15eO4TPmBIv3TodE8zw== X-CSE-MsgGUID: CfNksod0RFCPkXF33zJD+Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,159,1712646000"; d="scan'208";a="35367366" Received: from ijarvine-desk1.ger.corp.intel.com (HELO localhost) ([10.245.247.94]) by ORVIESA003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 May 2024 04:31:54 -0700 From: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= To: linux-pci@vger.kernel.org, Bjorn Helgaas , Mahesh J Salgaonkar , Oliver O'Halloran , Lukas Wunner , linux-kernel@vger.kernel.org Cc: linuxppc-dev@lists.ozlabs.org, =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= Subject: [PATCH v5 5/7] PCI: Store # of supported End-End TLP Prefixes Date: Tue, 14 May 2024 14:31:07 +0300 Message-Id: <20240514113109.6690-6-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240514113109.6690-1-ilpo.jarvinen@linux.intel.com> References: <20240514113109.6690-1-ilpo.jarvinen@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable eetlp_prefix_path in the struct pci_dev tells if End-End TLP Prefixes are supported by the path or not, the value is only calculated if CONFIG_PCI_PASID is set. The Max End-End TLP Prefixes field in the Device Capabilities Register 2 also tells how many (1-4) End-End TLP Prefixes are supported (PCIe r6 sec 7.5.3.15). The number of supported End-End Prefixes is useful for reading correct number of DWORDs from TLP Prefix Log register in AER capability (PCIe r6 sec 7.8.4.12). Replace eetlp_prefix_path with eetlp_prefix_max and determine the number of supported End-End Prefixes regardless of CONFIG_PCI_PASID so that an upcoming commit generalizing TLP Prefix Log register reading does not have to read extra DWORDs for End-End Prefixes that never will be there. Signed-off-by: Ilpo J=C3=A4rvinen --- drivers/pci/ats.c | 2 +- drivers/pci/probe.c | 14 +++++++++----- include/linux/pci.h | 2 +- include/uapi/linux/pci_regs.h | 1 + 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/drivers/pci/ats.c b/drivers/pci/ats.c index c570892b2090..e13433dcfc82 100644 --- a/drivers/pci/ats.c +++ b/drivers/pci/ats.c @@ -377,7 +377,7 @@ int pci_enable_pasid(struct pci_dev *pdev, int features) if (WARN_ON(pdev->pasid_enabled)) return -EBUSY; =20 - if (!pdev->eetlp_prefix_path && !pdev->pasid_no_tlp) + if (!pdev->eetlp_prefix_max && !pdev->pasid_no_tlp) return -EINVAL; =20 if (!pasid) diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index 1325fbae2f28..02035b005a53 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -2211,8 +2211,8 @@ static void pci_configure_relaxed_ordering(struct pci= _dev *dev) =20 static void pci_configure_eetlp_prefix(struct pci_dev *dev) { -#ifdef CONFIG_PCI_PASID struct pci_dev *bridge; + unsigned int eetlp_max; int pcie_type; u32 cap; =20 @@ -2224,15 +2224,19 @@ static void pci_configure_eetlp_prefix(struct pci_d= ev *dev) return; =20 pcie_type =3D pci_pcie_type(dev); + + eetlp_max =3D FIELD_GET(PCI_EXP_DEVCAP2_EE_PREFIX_MAX, cap); + /* 00b means 4 */ + eetlp_max =3D eetlp_max ?: 4; + if (pcie_type =3D=3D PCI_EXP_TYPE_ROOT_PORT || pcie_type =3D=3D PCI_EXP_TYPE_RC_END) - dev->eetlp_prefix_path =3D 1; + dev->eetlp_prefix_max =3D eetlp_max; else { bridge =3D pci_upstream_bridge(dev); - if (bridge && bridge->eetlp_prefix_path) - dev->eetlp_prefix_path =3D 1; + if (bridge && bridge->eetlp_prefix_max) + dev->eetlp_prefix_max =3D eetlp_max; } -#endif } =20 static void pci_configure_serr(struct pci_dev *dev) diff --git a/include/linux/pci.h b/include/linux/pci.h index 16493426a04f..29c51325b1d9 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -397,7 +397,7 @@ struct pci_dev { supported from root to here */ #endif unsigned int pasid_no_tlp:1; /* PASID works without TLP Prefix */ - unsigned int eetlp_prefix_path:1; /* End-to-End TLP Prefix */ + unsigned int eetlp_prefix_max:3; /* Max # of End-End TLP Prefixes, 0=3Dno= t supported */ =20 pci_channel_state_t error_state; /* Current connectivity state */ struct device dev; /* Generic device interface */ diff --git a/include/uapi/linux/pci_regs.h b/include/uapi/linux/pci_regs.h index a39193213ff2..09e0c300c952 100644 --- a/include/uapi/linux/pci_regs.h +++ b/include/uapi/linux/pci_regs.h @@ -661,6 +661,7 @@ #define PCI_EXP_DEVCAP2_OBFF_MSG 0x00040000 /* New message signaling */ #define PCI_EXP_DEVCAP2_OBFF_WAKE 0x00080000 /* Re-use WAKE# for OBFF */ #define PCI_EXP_DEVCAP2_EE_PREFIX 0x00200000 /* End-End TLP Prefix */ +#define PCI_EXP_DEVCAP2_EE_PREFIX_MAX 0x00c00000 /* Max End-End TLP Prefi= xes */ #define PCI_EXP_DEVCTL2 0x28 /* Device Control 2 */ #define PCI_EXP_DEVCTL2_COMP_TIMEOUT 0x000f /* Completion Timeout Value */ #define PCI_EXP_DEVCTL2_COMP_TMOUT_DIS 0x0010 /* Completion Timeout Disab= le */ --=20 2.39.2 From nobody Fri Dec 19 19:17:54 2025 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.18]) (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 6A3DA13B284; Tue, 14 May 2024 11:32:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715686324; cv=none; b=uc8gNVhbTC3XdAKeqT4Oxfnc9fjWPySmEoUN+u16rNc6Nk8kE5cXSk8wjDgZk9LS9Ym5PB4cgTZSB1P5ozK48jou43mGZNuy+Bh1i/82+1UYCwQOPyYinEcEEQ8zBBV2qnI+UNxNeTVafH+MSkkVTEwROWmKjQ3vwq7M9hcRu94= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715686324; c=relaxed/simple; bh=muDPYeTDqUqXMJ0EJOzrmCFm6YAucOY0ej2xemGJzmU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=uAPuSpTsGKy9SnQwrUvbicB6Afme0LvsAHHP2onJxklmcCxJE1qG2EJYkSTNBgIBthRzHgQ2W0+BNTN8ftr2LK4GBrjE12Xk5S7KsSQasgPnguA2RMbbL6XoNcxoHYJu+DkldL3GB05wot34F/HQiuXiAu18qs4cl2jsDMu4APs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=KaB3V/3I; arc=none smtp.client-ip=198.175.65.18 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="KaB3V/3I" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1715686323; x=1747222323; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=muDPYeTDqUqXMJ0EJOzrmCFm6YAucOY0ej2xemGJzmU=; b=KaB3V/3I5oWfMR1hs/SuqTOUYE3oo7B6fq1oc9CwoTvt1wSpe/HGhONi tT/I8dcJKodExzFLJwa2CZv1p6VvIlBqKvFdwb59If63jEP100mGEK4Zr eykp7UcErezOLrOzN0HEJUPC/f6yrHx8ApudV7jvZxeHt9sIG3A0JpMkc 4k0xZLoccBfdf5fE+Yqr4NdxgtXgyNw9NU6UHQCM9uVL9ObEFayzK33br qpjK/1XIUUGhdjW6MvZBkWaLQSc+BOTl7N2aGib+uE0vFzU7mjn6Dp0ah XJE+OtPlrgdPCsUtDXLbpMJo/Kxg4Fy86k/kuX+xCWS1Mz1DcK9UWiO0J A==; X-CSE-ConnectionGUID: CZ4t/pN8RIygyGp8easqIw== X-CSE-MsgGUID: cCa8nw60QdGDpeD+d0yRpQ== X-IronPort-AV: E=McAfee;i="6600,9927,11072"; a="11828378" X-IronPort-AV: E=Sophos;i="6.08,159,1712646000"; d="scan'208";a="11828378" Received: from orviesa004.jf.intel.com ([10.64.159.144]) by orvoesa110.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 May 2024 04:32:03 -0700 X-CSE-ConnectionGUID: OPvY+vUWTOGolxa2EvWFXw== X-CSE-MsgGUID: Plao2HLxTf+Ix/1wfeJbUQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,159,1712646000"; d="scan'208";a="35546238" Received: from ijarvine-desk1.ger.corp.intel.com (HELO localhost) ([10.245.247.94]) by orviesa004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 May 2024 04:32:01 -0700 From: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= To: linux-pci@vger.kernel.org, Bjorn Helgaas , Mahesh J Salgaonkar , Oliver O'Halloran , Lukas Wunner , linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Cc: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= Subject: [PATCH v5 6/7] PCI: Add TLP Prefix reading into pcie_read_tlp_log() Date: Tue, 14 May 2024 14:31:08 +0300 Message-Id: <20240514113109.6690-7-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240514113109.6690-1-ilpo.jarvinen@linux.intel.com> References: <20240514113109.6690-1-ilpo.jarvinen@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable pcie_read_tlp_log() handles only 4 Header Log DWORDs but TLP Prefix Log (PCIe r6.1 secs 7.8.4.12 & 7.9.14.13) may also be present. Generalize pcie_read_tlp_log() and struct pcie_tlp_log to handle also TLP Prefix Log. The relevant registers are formatted identically in AER and DPC Capability, but has these variations: a) The offsets of TLP Prefix Log registers vary. b) DPC RP PIO TLP Prefix Log register can be < 4 DWORDs. Therefore callers must pass the offset of the TLP Prefix Log register and the entire length to pcie_read_tlp_log() to be able to read the correct number of TLP Prefix DWORDs from the correct offset. Signed-off-by: Ilpo J=C3=A4rvinen --- drivers/pci/pci.h | 5 +++- drivers/pci/pcie/aer.c | 4 ++- drivers/pci/pcie/dpc.c | 13 +++++----- drivers/pci/pcie/tlp.c | 49 +++++++++++++++++++++++++++++++---- include/linux/aer.h | 1 + include/uapi/linux/pci_regs.h | 1 + 6 files changed, 59 insertions(+), 14 deletions(-) diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h index 0e9917f8bf3f..7afdd71f9026 100644 --- a/drivers/pci/pci.h +++ b/drivers/pci/pci.h @@ -420,7 +420,9 @@ struct aer_err_info { int aer_get_device_error_info(struct pci_dev *dev, struct aer_err_info *in= fo); void aer_print_error(struct pci_dev *dev, struct aer_err_info *info); =20 -int pcie_read_tlp_log(struct pci_dev *dev, int where, struct pcie_tlp_log = *log); +int pcie_read_tlp_log(struct pci_dev *dev, int where, int where2, + unsigned int tlp_len, struct pcie_tlp_log *log); +unsigned int aer_tlp_log_len(struct pci_dev *dev); #endif /* CONFIG_PCIEAER */ =20 #ifdef CONFIG_PCIEPORTBUS @@ -439,6 +441,7 @@ void pci_dpc_init(struct pci_dev *pdev); void dpc_process_error(struct pci_dev *pdev); pci_ers_result_t dpc_reset_link(struct pci_dev *pdev); bool pci_dpc_recovered(struct pci_dev *pdev); +unsigned int dpc_tlp_log_len(struct pci_dev *dev); #else static inline void pci_save_dpc_state(struct pci_dev *dev) { } static inline void pci_restore_dpc_state(struct pci_dev *dev) { } diff --git a/drivers/pci/pcie/aer.c b/drivers/pci/pcie/aer.c index ac6293c24976..ecc1dea5a208 100644 --- a/drivers/pci/pcie/aer.c +++ b/drivers/pci/pcie/aer.c @@ -1245,7 +1245,9 @@ int aer_get_device_error_info(struct pci_dev *dev, st= ruct aer_err_info *info) =20 if (info->status & AER_LOG_TLP_MASKS) { info->tlp_header_valid =3D 1; - pcie_read_tlp_log(dev, aer + PCI_ERR_HEADER_LOG, &info->tlp); + pcie_read_tlp_log(dev, aer + PCI_ERR_HEADER_LOG, + aer + PCI_ERR_PREFIX_LOG, + aer_tlp_log_len(dev), &info->tlp); } } =20 diff --git a/drivers/pci/pcie/dpc.c b/drivers/pci/pcie/dpc.c index a668820696dc..5056cc6961ec 100644 --- a/drivers/pci/pcie/dpc.c +++ b/drivers/pci/pcie/dpc.c @@ -190,7 +190,7 @@ pci_ers_result_t dpc_reset_link(struct pci_dev *pdev) static void dpc_process_rp_pio_error(struct pci_dev *pdev) { u16 cap =3D pdev->dpc_cap, dpc_status, first_error; - u32 status, mask, sev, syserr, exc, log, prefix; + u32 status, mask, sev, syserr, exc, log; struct pcie_tlp_log tlp_log; int i; =20 @@ -217,20 +217,19 @@ static void dpc_process_rp_pio_error(struct pci_dev *= pdev) =20 if (pdev->dpc_rp_log_size < 4) goto clear_status; - pcie_read_tlp_log(pdev, cap + PCI_EXP_DPC_RP_PIO_HEADER_LOG, &tlp_log); + pcie_read_tlp_log(pdev, cap + PCI_EXP_DPC_RP_PIO_HEADER_LOG, + cap + PCI_EXP_DPC_RP_PIO_TLPPREFIX_LOG, + dpc_tlp_log_len(pdev), &tlp_log); pci_err(pdev, "TLP Header: %#010x %#010x %#010x %#010x\n", tlp_log.dw[0], tlp_log.dw[1], tlp_log.dw[2], tlp_log.dw[3]); + for (i =3D 0; i < pdev->dpc_rp_log_size - 5; i++) + pci_err(pdev, "TLP Prefix Header: dw%d, %#010x\n", i, tlp_log.prefix[i]); =20 if (pdev->dpc_rp_log_size < 5) goto clear_status; pci_read_config_dword(pdev, cap + PCI_EXP_DPC_RP_PIO_IMPSPEC_LOG, &log); pci_err(pdev, "RP PIO ImpSpec Log %#010x\n", log); =20 - for (i =3D 0; i < pdev->dpc_rp_log_size - 5; i++) { - pci_read_config_dword(pdev, - cap + PCI_EXP_DPC_RP_PIO_TLPPREFIX_LOG + i * 4, &prefix); - pci_err(pdev, "TLP Prefix Header: dw%d, %#010x\n", i, prefix); - } clear_status: pci_write_config_dword(pdev, cap + PCI_EXP_DPC_RP_PIO_STATUS, status); } diff --git a/drivers/pci/pcie/tlp.c b/drivers/pci/pcie/tlp.c index 65ac7b5d8a87..def9dd7b73e8 100644 --- a/drivers/pci/pcie/tlp.c +++ b/drivers/pci/pcie/tlp.c @@ -11,26 +11,65 @@ =20 #include "../pci.h" =20 +/** + * aer_tlp_log_len - Calculates AER Capability TLP Header/Prefix Log length + * @dev: PCIe device + * + * Return: TLP Header/Prefix Log length + */ +unsigned int aer_tlp_log_len(struct pci_dev *dev) +{ + return 4 + dev->eetlp_prefix_max; +} + +#ifdef CONFIG_PCIE_DPC +/** + * dpc_tlp_log_len - Calculates DPC RP PIO TLP Header/Prefix Log length + * @dev: PCIe device + * + * Return: TLP Header/Prefix Log length + */ +unsigned int dpc_tlp_log_len(struct pci_dev *dev) +{ + /* Remove ImpSpec Log register from the count */ + if (dev->dpc_rp_log_size >=3D 5) + return dev->dpc_rp_log_size - 1; + + return dev->dpc_rp_log_size; +} +#endif + /** * pcie_read_tlp_log - read TLP Header Log * @dev: PCIe device * @where: PCI Config offset of TLP Header Log + * @where2: PCI Config offset of TLP Prefix Log + * @tlp_len: TLP Log length (Header Log + TLP Prefix Log in DWORDs) * @log: TLP Log structure to fill * * Fill @log from TLP Header Log registers, e.g., AER or DPC. * * Return: 0 on success and filled TLP Log structure, <0 on error. */ -int pcie_read_tlp_log(struct pci_dev *dev, int where, - struct pcie_tlp_log *log) +int pcie_read_tlp_log(struct pci_dev *dev, int where, int where2, + unsigned int tlp_len, struct pcie_tlp_log *log) { unsigned int i; - int ret; + int off, ret; + u32 *to; =20 memset(log, 0, sizeof(*log)); =20 - for (i =3D 0; i < 4; i++) { - ret =3D pci_read_config_dword(dev, where + i * 4, &log->dw[i]); + for (i =3D 0; i < tlp_len; i++) { + if (i < 4) { + off =3D where + i * 4; + to =3D &log->dw[i]; + } else { + off =3D where2 + (i - 4) * 4; + to =3D &log->prefix[i - 4]; + } + + ret =3D pci_read_config_dword(dev, off, to); if (ret) return pcibios_err_to_errno(ret); } diff --git a/include/linux/aer.h b/include/linux/aer.h index 190a0a2061cd..dc498adaa1c8 100644 --- a/include/linux/aer.h +++ b/include/linux/aer.h @@ -20,6 +20,7 @@ struct pci_dev; =20 struct pcie_tlp_log { u32 dw[4]; + u32 prefix[4]; }; =20 struct aer_capability_regs { diff --git a/include/uapi/linux/pci_regs.h b/include/uapi/linux/pci_regs.h index 09e0c300c952..cf7a07fa4a3b 100644 --- a/include/uapi/linux/pci_regs.h +++ b/include/uapi/linux/pci_regs.h @@ -803,6 +803,7 @@ #define PCI_ERR_ROOT_FATAL_RCV 0x00000040 /* Fatal Received */ #define PCI_ERR_ROOT_AER_IRQ 0xf8000000 /* Advanced Error Interrupt Mess= age Number */ #define PCI_ERR_ROOT_ERR_SRC 0x34 /* Error Source Identification */ +#define PCI_ERR_PREFIX_LOG 0x38 /* TLP Prefix LOG Register (up to 16 bytes= ) */ =20 /* Virtual Channel */ #define PCI_VC_PORT_CAP1 0x04 --=20 2.39.2 From nobody Fri Dec 19 19:17:54 2025 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.18]) (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 1C56213B284; Tue, 14 May 2024 11:32:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715686332; cv=none; b=L+HvScVAZcCzGA+rbW6ZI7Sqj9iAf0ZtS0hVdXfzA2jm4MCoW0MOEiVXxvlq6zat6J4hqpoh64YS0xDmpmdeRZ7dnReEaX4P7FeQg/foa9wWSYyqrMDHHYzB5782txuO9gYNbZUZGEY5scoY/jTZxhsxWv27XER4yX1gwo1x/P4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715686332; c=relaxed/simple; bh=ffzh8ktARfQxlg+EHK6GIqcNAVgzEbJqc4SjsjEWR6I=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=cWngkiBceB84jRxx6SrengVq6H/e0GEWknVciJRgPtuusC17KIZ8HAfXeQnkefUOhxRFGwgPY2FvJAnpyiQ8SOCO7rVJRQTHikMF1VKVPAU/Wd0onNwUuKyK6gDi5CC0SB8XlL6fc7RzXHVxom/UBODSJp30JJL/gQplV1nTqk8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=ec8zSI2S; arc=none smtp.client-ip=198.175.65.18 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="ec8zSI2S" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1715686331; x=1747222331; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ffzh8ktARfQxlg+EHK6GIqcNAVgzEbJqc4SjsjEWR6I=; b=ec8zSI2SJBiliQcAbcm8XleGsUy/VOhKWMUAvu6k5OKfzMO4pQgkEe1x ll1qh4vtVt9lyYZrD54vn9FOCHUDyTWIl++gnNzt8txCjL8TuLyiuORuH OE8D8dTYrtdHETxr7TH8VI26j5nS7D0s69Pn3LwnNjDKbv/n5hcRGe0DR kU7fmVg+O2GoCUw9cTJiISZo6wMBCt1RS/rvgms0r3YVqIwklgbdJzb9z GJ88nSnTCvv5hBuCb9yXDoaTXoN/RHxZLa/Ao5kq8tmrgB773xU37i0yt IWelxdVq9/WGY7AA8OSpSVFOqd5/F5bCeDccbWNMaKAuzGFVNrWiMVKWq w==; X-CSE-ConnectionGUID: Lj0x92wLQvWfmetZNzbkTQ== X-CSE-MsgGUID: CNxiQduRRo6d4vyBNvKUpQ== X-IronPort-AV: E=McAfee;i="6600,9927,11072"; a="11828397" X-IronPort-AV: E=Sophos;i="6.08,159,1712646000"; d="scan'208";a="11828397" Received: from orviesa004.jf.intel.com ([10.64.159.144]) by orvoesa110.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 May 2024 04:32:10 -0700 X-CSE-ConnectionGUID: 7CSVwOv/Rte4ss6sxd2F/A== X-CSE-MsgGUID: kASYYa9MRGafmLSNqZpLug== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,159,1712646000"; d="scan'208";a="35546245" Received: from ijarvine-desk1.ger.corp.intel.com (HELO localhost) ([10.245.247.94]) by orviesa004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 May 2024 04:32:08 -0700 From: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= To: linux-pci@vger.kernel.org, Bjorn Helgaas , Mahesh J Salgaonkar , Oliver O'Halloran , Lukas Wunner , linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Cc: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= Subject: [PATCH v5 7/7] PCI: Create helper to print TLP Header and Prefix Log Date: Tue, 14 May 2024 14:31:09 +0300 Message-Id: <20240514113109.6690-8-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240514113109.6690-1-ilpo.jarvinen@linux.intel.com> References: <20240514113109.6690-1-ilpo.jarvinen@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Add pcie_print_tlp_log() helper to print TLP Header and Prefix Log. Print End-End Prefixes only if they are non-zero. Consolidate the few places which currently print TLP using custom formatting. The first attempt used pr_cont() instead of building a string first but it turns out pr_cont() is not compatible with pci_err() and prints on a separate line. When I asked about this, Andy Shevchenko suggested pr_cont() should not be used in the first place (to eventually get rid of it) so pr_cont() is now replaced with building the string first. Signed-off-by: Ilpo J=C3=A4rvinen --- drivers/pci/pci.h | 2 ++ drivers/pci/pcie/aer.c | 10 ++-------- drivers/pci/pcie/dpc.c | 5 +---- drivers/pci/pcie/tlp.c | 31 +++++++++++++++++++++++++++++++ 4 files changed, 36 insertions(+), 12 deletions(-) diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h index 7afdd71f9026..45083e62892c 100644 --- a/drivers/pci/pci.h +++ b/drivers/pci/pci.h @@ -423,6 +423,8 @@ void aer_print_error(struct pci_dev *dev, struct aer_er= r_info *info); int pcie_read_tlp_log(struct pci_dev *dev, int where, int where2, unsigned int tlp_len, struct pcie_tlp_log *log); unsigned int aer_tlp_log_len(struct pci_dev *dev); +void pcie_print_tlp_log(const struct pci_dev *dev, + const struct pcie_tlp_log *log, const char *pfx); #endif /* CONFIG_PCIEAER */ =20 #ifdef CONFIG_PCIEPORTBUS diff --git a/drivers/pci/pcie/aer.c b/drivers/pci/pcie/aer.c index ecc1dea5a208..efb9e728fe94 100644 --- a/drivers/pci/pcie/aer.c +++ b/drivers/pci/pcie/aer.c @@ -664,12 +664,6 @@ static void pci_rootport_aer_stats_incr(struct pci_dev= *pdev, } } =20 -static void __print_tlp_header(struct pci_dev *dev, struct pcie_tlp_log *t) -{ - pci_err(dev, " TLP Header: %08x %08x %08x %08x\n", - t->dw[0], t->dw[1], t->dw[2], t->dw[3]); -} - static void __aer_print_error(struct pci_dev *dev, struct aer_err_info *info) { @@ -724,7 +718,7 @@ void aer_print_error(struct pci_dev *dev, struct aer_er= r_info *info) __aer_print_error(dev, info); =20 if (info->tlp_header_valid) - __print_tlp_header(dev, &info->tlp); + pcie_print_tlp_log(dev, &info->tlp, " "); =20 out: if (info->id && info->error_dev_num > 1 && info->id =3D=3D id) @@ -796,7 +790,7 @@ void pci_print_aer(struct pci_dev *dev, int aer_severit= y, aer->uncor_severity); =20 if (tlp_header_valid) - __print_tlp_header(dev, &aer->header_log); + pcie_print_tlp_log(dev, &aer->header_log, " "); =20 trace_aer_event(dev_name(&dev->dev), (status & ~mask), aer_severity, tlp_header_valid, &aer->header_log); diff --git a/drivers/pci/pcie/dpc.c b/drivers/pci/pcie/dpc.c index 5056cc6961ec..598f74384471 100644 --- a/drivers/pci/pcie/dpc.c +++ b/drivers/pci/pcie/dpc.c @@ -220,10 +220,7 @@ static void dpc_process_rp_pio_error(struct pci_dev *p= dev) pcie_read_tlp_log(pdev, cap + PCI_EXP_DPC_RP_PIO_HEADER_LOG, cap + PCI_EXP_DPC_RP_PIO_TLPPREFIX_LOG, dpc_tlp_log_len(pdev), &tlp_log); - pci_err(pdev, "TLP Header: %#010x %#010x %#010x %#010x\n", - tlp_log.dw[0], tlp_log.dw[1], tlp_log.dw[2], tlp_log.dw[3]); - for (i =3D 0; i < pdev->dpc_rp_log_size - 5; i++) - pci_err(pdev, "TLP Prefix Header: dw%d, %#010x\n", i, tlp_log.prefix[i]); + pcie_print_tlp_log(pdev, &tlp_log, ""); =20 if (pdev->dpc_rp_log_size < 5) goto clear_status; diff --git a/drivers/pci/pcie/tlp.c b/drivers/pci/pcie/tlp.c index def9dd7b73e8..097ac8514e96 100644 --- a/drivers/pci/pcie/tlp.c +++ b/drivers/pci/pcie/tlp.c @@ -6,6 +6,7 @@ */ =20 #include +#include #include #include =20 @@ -76,3 +77,33 @@ int pcie_read_tlp_log(struct pci_dev *dev, int where, in= t where2, =20 return 0; } + +/** + * pcie_print_tlp_log - Print TLP Header / Prefix Log contents + * @dev: PCIe device + * @log: TLP Log structure + * @pfx: String prefix (for print out indentation) + * + * Prints TLP Header and Prefix Log information held by @log. + */ +void pcie_print_tlp_log(const struct pci_dev *dev, + const struct pcie_tlp_log *log, const char *pfx) +{ + char buf[(10 + 1) * (4 + ARRAY_SIZE(log->prefix)) + 14 + 1]; + unsigned int i; + int len; + + len =3D scnprintf(buf, sizeof(buf), "%#010x %#010x %#010x %#010x", + log->dw[0], log->dw[1], log->dw[2], log->dw[3]); + + if (log->prefix[0]) + len +=3D scnprintf(buf + len, sizeof(buf) - len, " E-E Prefixes:"); + for (i =3D 0; i < ARRAY_SIZE(log->prefix); i++) { + if (!log->prefix[i]) + break; + len +=3D scnprintf(buf + len, sizeof(buf) - len, + " %#010x", log->prefix[i]); + } + + pci_err(dev, "%sTLP Header: %s\n", pfx, buf); +} --=20 2.39.2