Kernel KVM virtualization development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Zhiping Zhang" <zhipingz@meta.com>
Cc: linux-pci@vger.kernel.org, kvm@vger.kernel.org,
	dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v10 1/4] PCI/TPH: Add requester/completer type helpers
Date: Tue, 30 Jun 2026 23:07:33 +0000	[thread overview]
Message-ID: <20260630230733.E71191F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260630224328.3218796-2-zhipingz@meta.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] The internal `get_rp_completer_type()` function was not updated to use the new `pcie_tph_completer_type()` helper, leading to an API contract violation in `pcie_tph_enabled_req_type()`.
--

commit d64d0831457ed161ad198682067e0f147ca1411e
Author: Zhiping Zhang <zhipingz@meta.com>

PCI/TPH: Add requester/completer type helpers

This patch introduces pcie_tph_enabled_req_type() and
pcie_tph_completer_type() to allow drivers to query TPH requester mode
and completer capabilities without accessing pci_dev internals directly.
It also ensures the reserved 0b10 completer capability encoding is
folded into a "not supported" value for callers.

> diff --git a/drivers/pci/tph.c b/drivers/pci/tph.c
> index 655ffd60e62f6..e7693fd9d6763 100644
> --- a/drivers/pci/tph.c
> +++ b/drivers/pci/tph.c
> @@ -173,6 +173,51 @@ u32 pcie_tph_get_st_table_loc(struct pci_dev *pdev)
>  }
>  EXPORT_SYMBOL(pcie_tph_get_st_table_loc);
>  
> +/**
> + * pcie_tph_enabled_req_type - Return the device's enabled TPH requester type
> + * @pdev: PCI device to query
> + *
> + * Return: PCI_TPH_REQ_DISABLE, PCI_TPH_REQ_TPH_ONLY or PCI_TPH_REQ_EXT_TPH.
> + */
> +u8 pcie_tph_enabled_req_type(struct pci_dev *pdev)
> +{
> +	return pdev->tph_req_type;
> +}

[Severity: Medium]
Could this helper return an undocumented value of 2 if a Root Port's TPH
Completer Supported field incorrectly exposes the reserved 0b10 value?

The internal get_rp_completer_type() function was not updated to use the new
pcie_tph_completer_type() helper, so it retains its manual decoding:

drivers/pci/tph.c:get_rp_completer_type() {
    ...
    return FIELD_GET(PCI_EXP_DEVCAP2_TPH_COMP_MASK, reg);
}

If get_rp_completer_type() returns 2, pcie_enable_tph() can assign this to
pdev->tph_req_type via the min() calculation:

drivers/pci/tph.c:pcie_enable_tph() {
    ...
    rp_req_type = get_rp_completer_type(pdev);
    
    /* Final req_type is the smallest value of two */
    pdev->tph_req_type = min(pdev->tph_req_type, rp_req_type);
}

Should get_rp_completer_type() be refactored to use pcie_tph_completer_type()
to properly fold the reserved 0b10 encoding and avoid this API contract
violation?

[ ... ]

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260630224328.3218796-1-zhipingz@meta.com?part=1

  reply	other threads:[~2026-06-30 23:07 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-30 22:42 [PATCH v10 0/4] vfio/dma-buf: add TPH support for peer-to-peer access Zhiping Zhang
2026-06-30 22:42 ` [PATCH v10 1/4] PCI/TPH: Add requester/completer type helpers Zhiping Zhang
2026-06-30 23:07   ` sashiko-bot [this message]
2026-06-30 22:42 ` [PATCH v10 2/4] dma-buf: add optional get_pci_tph() callback Zhiping Zhang
2026-06-30 23:01   ` sashiko-bot
2026-07-01  8:25   ` Christian König
2026-07-01 17:53     ` Zhiping Zhang
2026-07-02  7:06       ` Christian König
2026-06-30 22:42 ` [PATCH v10 3/4] vfio/pci: implement get_pci_tph and DMA_BUF_TPH feature Zhiping Zhang
2026-06-30 23:08   ` sashiko-bot
2026-07-01 18:07   ` Alex Williamson
2026-07-01 21:07     ` Zhiping Zhang
2026-06-30 22:42 ` [PATCH v10 4/4] RDMA/mlx5: get tph for p2p access when registering dma-buf mr Zhiping Zhang
2026-06-30 23:11   ` 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=20260630230733.E71191F00A3A@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=kvm@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=zhipingz@meta.com \
    /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