[{"id":3687211,"web_url":"http://patchwork.ozlabs.org/comment/3687211/","msgid":"<20260506155418.GA790442@bhelgaas>","list_archive_url":null,"date":"2026-05-06T15:54:18","subject":"Re: [PATCH v6 1/6] PCI/TPH: Fix pcie_tph_get_st_table_loc() field\n extraction","submitter":{"id":67298,"url":"http://patchwork.ozlabs.org/api/people/67298/","name":"Bjorn Helgaas","email":"helgaas@kernel.org"},"content":"On Wed, May 06, 2026 at 05:46:18PM +0800, Chengwen Feng wrote:\n> pcie_tph_get_st_table_loc() incorrectly uses FIELD_GET(), which shifts the\n> field value to bit 0. But the function is designed to return raw\n> PCI_TPH_LOC_* values as defined in the function comment.\n> \n> This causes incorrect ST table location detection. Fix it by using bitwise\n> AND with PCI_TPH_CAP_LOC_MASK to return the unshifted field value matching\n> the function specification.\n> \n> While this change appears to be a no-op within tph.c, the external caller\n> mlx5_st_create() relies on the documented function behavior, making this\n> fix necessary.\n\nPreviously, pcie_tph_get_st_table_loc() returned 0x0 (for\nPCI_TPH_LOC_NONE), 0x2 (for PCI_TPH_LOC_CAP), or 0x4 (for\nPCI_TPH_LOC_MSIX).\n\nmlx5_st_create() is currently the only external caller.  It only\nchecks for PCI_TPH_LOC_NONE, which is 0 regardless of the FIELD_GET(),\nso I don't think this actually fixes mlx5_st_create().\n\nProbably still worth a stable backport because other drivers may call\npcie_tph_get_st_table_loc() in the future, and if they depend on\nPCI_TPH_LOC_CAP or PCI_TPH_LOC_MSIX, and are backported to stable\nkernels, they will need this.\n\nI might reword that last paragraph to avoid the implication that this\nactually fixes something in mlx5:\n\n  This doesn't make a difference to mlx5_st_create(), the lone\n  external caller, because it only checks for PCI_TPH_LOC_NONE (0),\n  but will be needed for callers that check for PCI_TPH_LOC_CAP or\n  PCI_TPH_LOC_MSIX.\n\n> Fixes: d2e8a34876ce (\"PCI/TPH: Add Steering Tag support\")\n> Cc: stable@vger.kernel.org\n> Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>\n> Reviewed-by: Alex Williamson <alex.williamson@nvidia.com>\n\nReviewed-by: Bjorn Helgaas <bhelgaas@google.com>\n\nFeel free to merge along with the rest, I assume via the VFIO tree.\n\n> ---\n>  drivers/pci/tph.c | 8 +-------\n>  1 file changed, 1 insertion(+), 7 deletions(-)\n> \n> diff --git a/drivers/pci/tph.c b/drivers/pci/tph.c\n> index 91145e8d9d95..f17b74b5fb1e 100644\n> --- a/drivers/pci/tph.c\n> +++ b/drivers/pci/tph.c\n> @@ -170,7 +170,7 @@ u32 pcie_tph_get_st_table_loc(struct pci_dev *pdev)\n>  \n>  \tpci_read_config_dword(pdev, pdev->tph_cap + PCI_TPH_CAP, &reg);\n>  \n> -\treturn FIELD_GET(PCI_TPH_CAP_LOC_MASK, reg);\n> +\treturn reg & PCI_TPH_CAP_LOC_MASK;\n>  }\n>  EXPORT_SYMBOL(pcie_tph_get_st_table_loc);\n>  \n> @@ -183,11 +183,7 @@ u16 pcie_tph_get_st_table_size(struct pci_dev *pdev)\n>  \tu32 reg;\n>  \tu32 loc;\n>  \n> -\t/* Check ST table location first */\n>  \tloc = pcie_tph_get_st_table_loc(pdev);\n> -\n> -\t/* Convert loc to match with PCI_TPH_LOC_* defined in pci_regs.h */\n> -\tloc = FIELD_PREP(PCI_TPH_CAP_LOC_MASK, loc);\n>  \tif (loc != PCI_TPH_LOC_CAP)\n>  \t\treturn 0;\n>  \n> @@ -316,8 +312,6 @@ int pcie_tph_set_st_entry(struct pci_dev *pdev, unsigned int index, u16 tag)\n>  \tset_ctrl_reg_req_en(pdev, PCI_TPH_REQ_DISABLE);\n>  \n>  \tloc = pcie_tph_get_st_table_loc(pdev);\n> -\t/* Convert loc to match with PCI_TPH_LOC_* */\n> -\tloc = FIELD_PREP(PCI_TPH_CAP_LOC_MASK, loc);\n>  \n>  \tswitch (loc) {\n>  \tcase PCI_TPH_LOC_MSIX:\n> -- \n> 2.17.1\n>","headers":{"Return-Path":"\n <linux-pci+bounces-53901-incoming=patchwork.ozlabs.org@vger.kernel.org>","X-Original-To":["incoming@patchwork.ozlabs.org","linux-pci@vger.kernel.org"],"Delivered-To":"patchwork-incoming@legolas.ozlabs.org","Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256\n header.s=k20201202 header.b=dvWE085q;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org\n (client-ip=172.105.105.114; helo=tor.lore.kernel.org;\n envelope-from=linux-pci+bounces-53901-incoming=patchwork.ozlabs.org@vger.kernel.org;\n receiver=patchwork.ozlabs.org)","smtp.subspace.kernel.org;\n\tdkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org\n header.b=\"dvWE085q\"","smtp.subspace.kernel.org;\n arc=none smtp.client-ip=10.30.226.201"],"Received":["from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4g9g4P1yFzz1yJx\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 07 May 2026 01:57:09 +1000 (AEST)","from smtp.subspace.kernel.org (conduit.subspace.kernel.org\n [100.90.174.1])\n\tby tor.lore.kernel.org (Postfix) with ESMTP id D5969308DB9A\n\tfor <incoming@patchwork.ozlabs.org>; Wed,  6 May 2026 15:54:21 +0000 (UTC)","from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id 5849847DD79;\n\tWed,  6 May 2026 15:54:21 +0000 (UTC)","from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org\n [10.30.226.201])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby smtp.subspace.kernel.org (Postfix) with ESMTPS id 9454A29898B;\n\tWed,  6 May 2026 15:54:20 +0000 (UTC)","by smtp.kernel.org (Postfix) with ESMTPSA id BBA95C2BCB0;\n\tWed,  6 May 2026 15:54:19 +0000 (UTC)"],"ARC-Seal":"i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1778082860; cv=none;\n b=amoLHclxR/eJNeSGLYn4sFZ/GLzyK7FtVeUtFHrR6wwk01+1dShPP0C4zMpkojCIPyX8U+FZZaHWZBAimgOXV/Gz2osj+SwDBH7RWsnMxF7wg9N7pVNGn6/vqN/nVk1DdGxDfeujFpJae1n07byxBz+KFy5a4EAoSvU20pAACzg=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1778082860; c=relaxed/simple;\n\tbh=AQpTvheUcxBcm/Yw2ZZYWlqrM9bUxu4cQfZOpCag28g=;\n\th=Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type:\n\t Content-Disposition:In-Reply-To;\n b=lYrz2m8lJJ3UYqP8RY4Mfe/EAyXeu+YOd7aV3SqqLPdeecPPR+mDks5DfntTkKSX25hyCYBcDbqLhz6vIJWvl+NQJ2HkHnzKfvHsW8YQknvdlLcPwUCmZ0jonBlbvbQSOU8xUKtuvtoUKnHwU/ti1UBd/jrELqFYEwnU0fKqoWw=","ARC-Authentication-Results":"i=1; smtp.subspace.kernel.org;\n dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org\n header.b=dvWE085q; arc=none smtp.client-ip=10.30.226.201","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org;\n\ts=k20201202; t=1778082859;\n\tbh=AQpTvheUcxBcm/Yw2ZZYWlqrM9bUxu4cQfZOpCag28g=;\n\th=Date:From:To:Cc:Subject:In-Reply-To:From;\n\tb=dvWE085qYUaQ7nlS0PQqEN1BmMJl6e+2if85fsObIS9TjTBneIel9W+HgEH6OT/Ip\n\t JN4eYXT65uX3kF09Q6+CZKoe2BMGUzq+BI4bIvyEPeQSpekkcEwtNh2TvU4Su7cML+\n\t pvO/5TXv4mgIwiRRWHnZhiOIGL5FMMyU//PHElgfLPejOn3vm58J08/OHOzFc2OR8O\n\t soGUdeJj7tLfMbTi2dJXzbVF1egxPpbUJNFFm7XsSsjefNhJVc3Q3NUdmaocMI0Vwr\n\t 5HYVbq9444RYkjvEN8wiQ2rSNPqM0FU/kiqz14xKBZu6i46qqowvR075pFcS+YHNsg\n\t YAXVfPTBPRtnw==","Date":"Wed, 6 May 2026 10:54:18 -0500","From":"Bjorn Helgaas <helgaas@kernel.org>","To":"Chengwen Feng <fengchengwen@huawei.com>","Cc":"alex@shazbot.org, jgg@ziepe.ca, wathsala.vithanage@arm.com,\n\twei.huang2@amd.com, wangzhou1@hisilicon.com,\n\twangyushan12@huawei.com, liuyonglong@huawei.com,\n\tkvm@vger.kernel.org, linux-pci@vger.kernel.org","Subject":"Re: [PATCH v6 1/6] PCI/TPH: Fix pcie_tph_get_st_table_loc() field\n extraction","Message-ID":"<20260506155418.GA790442@bhelgaas>","Precedence":"bulk","X-Mailing-List":"linux-pci@vger.kernel.org","List-Id":"<linux-pci.vger.kernel.org>","List-Subscribe":"<mailto:linux-pci+subscribe@vger.kernel.org>","List-Unsubscribe":"<mailto:linux-pci+unsubscribe@vger.kernel.org>","MIME-Version":"1.0","Content-Type":"text/plain; charset=us-ascii","Content-Disposition":"inline","In-Reply-To":"<20260506094623.29327-2-fengchengwen@huawei.com>"}},{"id":3690626,"web_url":"http://patchwork.ozlabs.org/comment/3690626/","msgid":"<20260513070101.GD15586@unreal>","list_archive_url":null,"date":"2026-05-13T07:01:01","subject":"Re: [PATCH v6 1/6] PCI/TPH: Fix pcie_tph_get_st_table_loc() field\n extraction","submitter":{"id":68852,"url":"http://patchwork.ozlabs.org/api/people/68852/","name":"Leon Romanovsky","email":"leon@kernel.org"},"content":"On Wed, May 06, 2026 at 10:54:18AM -0500, Bjorn Helgaas wrote:\n> On Wed, May 06, 2026 at 05:46:18PM +0800, Chengwen Feng wrote:\n> > pcie_tph_get_st_table_loc() incorrectly uses FIELD_GET(), which shifts the\n> > field value to bit 0. But the function is designed to return raw\n> > PCI_TPH_LOC_* values as defined in the function comment.\n> > \n> > This causes incorrect ST table location detection. Fix it by using bitwise\n> > AND with PCI_TPH_CAP_LOC_MASK to return the unshifted field value matching\n> > the function specification.\n> > \n> > While this change appears to be a no-op within tph.c, the external caller\n> > mlx5_st_create() relies on the documented function behavior, making this\n> > fix necessary.\n> \n> Previously, pcie_tph_get_st_table_loc() returned 0x0 (for\n> PCI_TPH_LOC_NONE), 0x2 (for PCI_TPH_LOC_CAP), or 0x4 (for\n> PCI_TPH_LOC_MSIX).\n> \n> mlx5_st_create() is currently the only external caller.  It only\n> checks for PCI_TPH_LOC_NONE, which is 0 regardless of the FIELD_GET(),\n> so I don't think this actually fixes mlx5_st_create().\n> \n> Probably still worth a stable backport because other drivers may call\n> pcie_tph_get_st_table_loc() in the future, and if they depend on\n> PCI_TPH_LOC_CAP or PCI_TPH_LOC_MSIX, and are backported to stable\n> kernels, they will need this.\n> \n> I might reword that last paragraph to avoid the implication that this\n> actually fixes something in mlx5:\n> \n>   This doesn't make a difference to mlx5_st_create(), the lone\n>   external caller, because it only checks for PCI_TPH_LOC_NONE (0),\n>   but will be needed for callers that check for PCI_TPH_LOC_CAP or\n>   PCI_TPH_LOC_MSIX.\n\nRight, we are running TPH in mlx5 regression and it works perfectly\nwithout \"the fix\".\n\nThanks","headers":{"Return-Path":"\n <linux-pci+bounces-54673-incoming=patchwork.ozlabs.org@vger.kernel.org>","X-Original-To":["incoming@patchwork.ozlabs.org","linux-pci@vger.kernel.org"],"Delivered-To":"patchwork-incoming@legolas.ozlabs.org","Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256\n header.s=k20201202 header.b=K4ZsjtHj;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org\n (client-ip=172.234.253.10; helo=sea.lore.kernel.org;\n envelope-from=linux-pci+bounces-54673-incoming=patchwork.ozlabs.org@vger.kernel.org;\n receiver=patchwork.ozlabs.org)","smtp.subspace.kernel.org;\n\tdkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org\n header.b=\"K4ZsjtHj\"","smtp.subspace.kernel.org;\n arc=none smtp.client-ip=10.30.226.201"],"Received":["from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4gFkrj6w8rz1yJ5\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 13 May 2026 17:01:09 +1000 (AEST)","from smtp.subspace.kernel.org (conduit.subspace.kernel.org\n [100.90.174.1])\n\tby sea.lore.kernel.org (Postfix) with ESMTP id 20478300EF9C\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 13 May 2026 07:01:08 +0000 (UTC)","from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id 36811399892;\n\tWed, 13 May 2026 07:01:07 +0000 (UTC)","from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org\n [10.30.226.201])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby smtp.subspace.kernel.org (Postfix) with ESMTPS id 1383F2D12ED;\n\tWed, 13 May 2026 07:01:06 +0000 (UTC)","by smtp.kernel.org (Postfix) with ESMTPSA id 309E6C2BCB7;\n\tWed, 13 May 2026 07:01:05 +0000 (UTC)"],"ARC-Seal":"i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1778655667; cv=none;\n b=uuEsWhZ5e+ZiYAEc+3ciPKGL3xQJF8bcGcVKQtbOiAWcwhZa227lmYzfG8Y6diFfa0wRX6m5YhHkSP4LvPAkGl0jgwrPWQN/aNZy9oo+LzyM64mRNdLva22aZb4SOM13BpIr3WChHGGKZ98T83h3b59p/LO/qdu35KCqy2JfiyI=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1778655667; c=relaxed/simple;\n\tbh=c/6nC5w5T/aAJxpIk6wRl+kP7ERq5HuXfNpn+R4tDh8=;\n\th=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version:\n\t Content-Type:Content-Disposition:In-Reply-To;\n b=Uo4v9uyFfvoogSx/aA946GVLPfrpxo6V/9A+imrEzLfnY2L6gY61teH/lMELOVgxQ3wH4FYe/C1+A37TD9EswL+G4XNpJTSOLQF0mov0xMUI+RpNl0TVTz1ndqa6d/t4TLRep6MORcdrM/s9jM/nEhP4szB+GavhhJOM8b9vaTk=","ARC-Authentication-Results":"i=1; smtp.subspace.kernel.org;\n dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org\n header.b=K4ZsjtHj; arc=none smtp.client-ip=10.30.226.201","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org;\n\ts=k20201202; t=1778655666;\n\tbh=c/6nC5w5T/aAJxpIk6wRl+kP7ERq5HuXfNpn+R4tDh8=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=K4ZsjtHjeWw2XgOumoWuIaDjGj3qSxoIo4VMFbMJvElG8ASRzn07TEmFQ2/78jNN5\n\t kEK+BUz/EfpDPW6qLnPbYJlmrohqqrril+AG0dQUXlYDUlLUqDazGadOaklQG9raH+\n\t iCpY9A4Lz7zRjlUHOClwUu0HIwM/u1O4+Wks5Y1Dj0OD8eHPTiVJdEYGVcsp+xirAS\n\t UjK0b1hD+y8hXdhBjVlvFM/+TR52WNgakcNPRCY/Vw8wHnoHSDvKqvuhJp4WdRfAsC\n\t 7WZWEEyoB2qgBUImFOy5QxVGnRfX9ImGVl2Zxmz7Grlosatn5as6m5N06z+mNoGDSw\n\t 30BYyf0ChPmWQ==","Date":"Wed, 13 May 2026 10:01:01 +0300","From":"Leon Romanovsky <leon@kernel.org>","To":"Bjorn Helgaas <helgaas@kernel.org>","Cc":"Chengwen Feng <fengchengwen@huawei.com>, alex@shazbot.org, jgg@ziepe.ca,\n\twathsala.vithanage@arm.com, wei.huang2@amd.com,\n\twangzhou1@hisilicon.com, wangyushan12@huawei.com,\n\tliuyonglong@huawei.com, kvm@vger.kernel.org,\n\tlinux-pci@vger.kernel.org","Subject":"Re: [PATCH v6 1/6] PCI/TPH: Fix pcie_tph_get_st_table_loc() field\n extraction","Message-ID":"<20260513070101.GD15586@unreal>","References":"<20260506094623.29327-2-fengchengwen@huawei.com>\n <20260506155418.GA790442@bhelgaas>","Precedence":"bulk","X-Mailing-List":"linux-pci@vger.kernel.org","List-Id":"<linux-pci.vger.kernel.org>","List-Subscribe":"<mailto:linux-pci+subscribe@vger.kernel.org>","List-Unsubscribe":"<mailto:linux-pci+unsubscribe@vger.kernel.org>","MIME-Version":"1.0","Content-Type":"text/plain; charset=us-ascii","Content-Disposition":"inline","In-Reply-To":"<20260506155418.GA790442@bhelgaas>"}}]