Linux PCI subsystem development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Chengwen Feng" <fengchengwen@huawei.com>
Cc: kvm@vger.kernel.org, linux-pci@vger.kernel.org
Subject: Re: [PATCH v22 07/13] PCI/TPH: Add pcie_tph_set_st_entries() batch ST entry programming helper
Date: Mon, 23 Nov 2026 02:48:31 +0000	[thread overview]
Message-ID: <sashiko-outbox-228564@kernel.org> (raw)
In-Reply-To: <20261123023628.7728-8-fengchengwen@huawei.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] PCI/TPH: pcie_tph_set_st_entries() re-enables TPH on error
--

commit 3ea3b71b1fd03bc517b1fa817329d811df87ed27
Author: Chengwen Feng <fengchengwen@huawei.com>

PCI/TPH: Add pcie_tph_set_st_entries() batch ST entry programming helper

This commit adds pcie_tph_set_st_entries() to program a contiguous range
of Steering Tag table entries in a batch, and reimplements
pcie_tph_set_st_entry() as a wrapper around it.

> diff --git a/drivers/pci/tph.c b/drivers/pci/tph.c
> index 51a065d83104b..be44b27bd1ce4 100644
> --- a/drivers/pci/tph.c
> +++ b/drivers/pci/tph.c
> @@ -311,21 +311,19 @@ int pcie_tph_get_cpu_st(struct pci_dev *pdev, enum tph_mem_type mem_type,

[ ... ]

> @@ -344,29 +345,47 @@ int pcie_tph_set_st_entry(struct pci_dev *pdev, unsigned int index, u16 tag)
>  	set_ctrl_reg_req_en(pdev, PCI_TPH_REQ_DISABLE);
>  
>  	loc = pcie_tph_get_st_table_loc(pdev);
> -
> -	switch (loc) {
> -	case PCI_TPH_LOC_MSIX:
> -		err = pci_msix_write_tph_tag(pdev, index, tag);
> -		break;
> -	case PCI_TPH_LOC_CAP:
> -		err = write_tag_to_st_table(pdev, index, tag);
> -		break;
> -	default:
> -		err = -EINVAL;
> -	}
> -
> -	if (err) {
> -		pcie_disable_tph(pdev);
> -		return err;
> +	for (i = 0; i < count; i++) {
> +		switch (loc) {
> +		case PCI_TPH_LOC_MSIX:
> +			err = pci_msix_write_tph_tag(pdev, start + i, tags[i]);
> +			break;
> +		case PCI_TPH_LOC_CAP:
> +			err = write_tag_to_st_table(pdev, start + i, tags[i]);
> +			break;
> +		default:
> +			err = -EINVAL;
> +		}
> +		if (err != 0) {
> +			pci_err(pdev, "failed to set steering tag: %s table, index=%u, tags=%u, ret=%d\n",
> +				(loc == PCI_TPH_LOC_MSIX) ? "MSI-X" : "ST",
> +				start + i, tags[i], err);
> +			set_ctrl_reg_req_en(pdev, pdev->tph_req_type);
> +			return i > 0 ? i : (err > 0 ? -EINVAL : err);
> +		}
>  	}

[Severity: Medium]
Should the error path here call pcie_disable_tph(pdev) instead of
re-enabling TPH with set_ctrl_reg_req_en()?

Before this change, pcie_tph_set_st_entry() called pcie_disable_tph(pdev)
on failure, clearing PCI_TPH_CTRL and pdev->tph_enabled.
pci_msix_write_tph_tag() relies on the caller to disable TPH when it
returns -EIO on an offline PCIe channel:

drivers/pci/msi/msi.c:pci_msix_write_tph_tag() {
    ...
	/*
	 * The tag update below is a write to the MSI-X Table followed by a
	 * flush read, neither of which can be completed while the Link is
	 * down. Check as late as possible, as the Link can go down at any
	 * point. Let the caller disable TPH.
	 */
	if (pci_channel_offline(pdev))
		return -EIO;
    ...
}

Re-enabling TPH on failure leaves hardware TPH active with an unprogrammed
or partially programmed ST table, and callers such as bnxt_request_irq()
that loop over vectors without checking pcie_tph_set_st_entry()'s return
value will keep issuing tag writes instead of short-circuiting on
!pdev->tph_enabled.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261123023628.7728-1-fengchengwen@huawei.com?part=7

  reply	other threads:[~2026-11-23  2:48 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-23  2:36 [PATCH v22 00/13] vfio/pci: Add PCIe TPH support Chengwen Feng
2026-11-23  2:36 ` [PATCH v22 01/13] PCI/TPH: Fix pcie_tph_get_st_table_loc() field extraction Chengwen Feng
2026-11-23  2:36 ` [PATCH v22 02/13] PCI/TPH: Fix tph_enabled concurrent update race by bitfield packing Chengwen Feng
2026-11-23  2:36 ` [PATCH v22 03/13] PCI/TPH: Cache negotiated max requester type at probe time Chengwen Feng
2026-11-23  2:36 ` [PATCH v22 04/13] PCI/TPH: Refactor pcie_enable_tph and add requester variant Chengwen Feng
2026-11-23  2:36 ` [PATCH v22 05/13] PCI/TPH: Refactor pcie_tph_get_cpu_st & " Chengwen Feng
2026-11-23  2:36 ` [PATCH v22 06/13] PCI/TPH: Add helpers to check standard and extended TPH support Chengwen Feng
2026-11-23  2:47   ` sashiko-bot
2026-11-23  2:36 ` [PATCH v22 07/13] PCI/TPH: Add pcie_tph_set_st_entries() batch ST entry programming helper Chengwen Feng
2026-11-23  2:48   ` sashiko-bot [this message]
2026-11-23  2:36 ` [PATCH v22 08/13] PCI/TPH: Add pcie_tph_dsm_supported() helper to detect device TPH ST _DSM Chengwen Feng
2026-11-23  2:36 ` [PATCH v22 09/13] vfio/pci: Reset PCIe TPH state on device open and close Chengwen Feng
2026-11-23  2:36 ` [PATCH v22 10/13] vfio/pci: Add basic NO-ST TPH VFIO device feature support Chengwen Feng
2026-11-23  2:36 ` [PATCH v22 11/13] vfio/pci: Add IV-ST TPH policy and TPH_PROGRAM batch programming support Chengwen Feng
2026-11-23  2:58   ` sashiko-bot
2026-11-23  2:36 ` [PATCH v22 12/13] vfio/pci: Add DS-ST TPH policy and TPH_RESOLVE capability Chengwen Feng
2026-11-23  2:50   ` sashiko-bot
2026-11-23  2:36 ` [PATCH v22 13/13] vfio/pci: Expose per-device TPH state via debugfs Chengwen Feng
2026-11-23  2:52 ` [PATCH v22 00/13] vfio/pci: Add PCIe TPH support fengchengwen
2026-11-23  2:58 ` sashiko-bot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=sashiko-outbox-228564@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=fengchengwen@huawei.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox