Re: [PATCH 08/18] PCI/TSM: Support connecting to PCIe CMA devices
From: Alistair Francis
Date: Wed May 20 2026 - 01:57:08 EST
On Fri, May 8, 2026 at 1:18 PM <alistair23@xxxxxxxxx> wrote:
>
> From: Alistair Francis <alistair.francis@xxxxxxx>
>
> In the next patch we are going to add a PCIe CMA TSM driver, as such we
> need to ensure that is_pci_tsm_pf0() will allow us to connect to CMA
> capable devices. These devices don't necessarily has DEVCAP_TEE or IDE
> support.
>
> As such for Root Complex Integrated Endpoint (PCI_EXP_TYPE_RC_END) we
> also check for the CMA DOE feature.
@Dan Williams this is the patch I really need your thoughts on.
The current upstream pci_tsm code only works if IDE or TDISP is
supported, which isn't true for CMA support.
This patch works around that, but the more I think about it the
hackier it is. I have a local change that reverts this and
updates`tsm.c` to work with a DSM (`->dsm_dev` is NULL), but that
doesn't feel right either. Do you have a better idea or how to enable
a CMA TSM driver?
Alistair
>
> Signed-off-by: Alistair Francis <alistair.francis@xxxxxxx>
> ---
> include/linux/pci-tsm.h | 11 ++++++++++-
> 1 file changed, 10 insertions(+), 1 deletion(-)
>
> diff --git a/include/linux/pci-tsm.h b/include/linux/pci-tsm.h
> index a6435aba03f9..5059954e4853 100644
> --- a/include/linux/pci-tsm.h
> +++ b/include/linux/pci-tsm.h
> @@ -3,6 +3,7 @@
> #define __PCI_TSM_H
> #include <linux/mutex.h>
> #include <linux/pci.h>
> +#include <linux/pci-doe.h>
> #include <linux/sockptr.h>
>
> struct pci_tsm;
> @@ -129,6 +130,8 @@ struct pci_tsm_pf0 {
> /* physical function0 and capable of 'connect' */
> static inline bool is_pci_tsm_pf0(struct pci_dev *pdev)
> {
> + struct pci_doe_mb *doe;
> +
> if (!pdev)
> return false;
>
> @@ -146,9 +149,15 @@ static inline bool is_pci_tsm_pf0(struct pci_dev *pdev)
> * switch.
> */
> switch (pci_pcie_type(pdev)) {
> + case PCI_EXP_TYPE_RC_END:
> + doe = pci_find_doe_mailbox(pdev, PCI_VENDOR_ID_PCI_SIG,
> + PCI_DOE_FEATURE_CMA);
> +
> + if (doe)
> + break;
> + fallthrough;
> case PCI_EXP_TYPE_ENDPOINT:
> case PCI_EXP_TYPE_UPSTREAM:
> - case PCI_EXP_TYPE_RC_END:
> if (pdev->ide_cap || (pdev->devcap & PCI_EXP_DEVCAP_TEE))
> break;
> fallthrough;
> --
> 2.52.0
>