Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Nathan Ciobanu" <nathan.d.ciobanu@linux.intel.com>
Cc: intel-xe@lists.freedesktop.org
Subject: Re: [PATCH] drm/xe: Add force_p2p module/configfs parameter
Date: Tue, 18 Aug 2026 15:54:33 +0000	[thread overview]
Message-ID: <20260818155433.557591F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260818154042.301638-1-nathan.d.ciobanu@linux.intel.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] Global force_p2p parameter incorrectly overrides P2P safety checks for all non-Xe PCI devices.
- [Low] The `force_p2p` attribute is missing from `dump_custom_dev_config()`, resulting in incomplete debug logs.
--

--- Patch [1]: [PATCH] drm/xe: Add force_p2p module/configfs parameter ---
commit 7f80ed3c08c50eca10a0100021e6454c59749548
Author: Nathan Ciobanu <nathan.d.ciobanu@linux.intel.com>

drm/xe: Add force_p2p module/configfs parameter

Add force_p2p module and configfs parameter to give users an option to
allow P2P DMA between GPU cards that are connected off of the root bus
with no switch/bridge in between, as seen in some virtual machine
topologies.

> diff --git a/drivers/gpu/drm/xe/xe_configfs.c b/drivers/gpu/drm/xe/xe_configfs.c
> index 052cce9621611..187352a8b4199 100644
> --- a/drivers/gpu/drm/xe/xe_configfs.c
> +++ b/drivers/gpu/drm/xe/xe_configfs.c
[ ... ]
> @@ -856,6 +923,7 @@ CONFIGFS_ATTR(, ctx_restore_post_bb);
>  CONFIGFS_ATTR(, enable_multi_queue);
>  CONFIGFS_ATTR(, enable_psmi);
>  CONFIGFS_ATTR(, engines_allowed);
> +CONFIGFS_ATTR(, force_p2p);
>  CONFIGFS_ATTR(, gt_types_allowed);
>  CONFIGFS_ATTR(, survivability_mode);
>  
> @@ -865,6 +933,7 @@ static struct configfs_attribute *xe_config_device_attrs[] = {
>  	&attr_enable_multi_queue,
>  	&attr_enable_psmi,
>  	&attr_engines_allowed,
> +	&attr_force_p2p,
>  	&attr_gt_types_allowed,
>  	&attr_survivability_mode,
>  	NULL,

[Severity: Low]
Should the new force_p2p attribute also be added to dump_custom_dev_config()?

When a user modifies the force_p2p attribute via configfs and subsequently
binds the device, the driver successfully detects that custom settings were
applied but fails to log the force_p2p modification. This leads to confusing
debug logs where the driver announces custom settings but prints an
incomplete list.

[ ... ]
> @@ -1269,6 +1338,25 @@ bool xe_configfs_get_psmi_enabled(struct pci_dev *pdev)
>  	return ret;
>  }
>  
> +/** xe_configfs_get_force_p2p - get configfs force_p2p setting
> + * @pdev: pci device
> + *
> + * Return: force_p2p setting in configfs
> + */
> +bool xe_configfs_get_force_p2p(struct pci_dev *pdev)
> +{
> +	struct xe_config_group_device *dev = find_xe_config_group_device(pdev);
> +	bool ret;
> +
> +	if (!dev)
> +		return xe_modparam.force_p2p;

[Severity: High]
Does returning xe_modparam.force_p2p for non-Xe devices bypass PCIe topology
safety checks for unrelated hardware?

Since find_xe_config_group_device() will return NULL for non-Xe PCI devices,
this fallback unconditionally causes any other PCI device (like NVMe drives
or network cards) to inherit the global xe.force_p2p setting.

> +
> +	ret = dev->config.force_p2p;
> +
> +	config_group_put(&dev->group);
> +	return ret;
> +}
[ ... ]
> diff --git a/drivers/gpu/drm/xe/xe_dma_buf.c b/drivers/gpu/drm/xe/xe_dma_buf.c
> index bf0728838ead5..bd8f8ad70bcd3 100644
> --- a/drivers/gpu/drm/xe/xe_dma_buf.c
> +++ b/drivers/gpu/drm/xe/xe_dma_buf.c
[ ... ]
> @@ -26,9 +27,14 @@ static int xe_dma_buf_attach(struct dma_buf *dmabuf,
>  			     struct dma_buf_attachment *attach)
>  {
>  	struct drm_gem_object *obj = attach->dmabuf->priv;
> +	struct pci_dev *a_pdev = to_pci_dev(obj->dev->dev);
> +	struct pci_dev *b_pdev = dev_is_pci(attach->dev) ?
> +				 to_pci_dev(attach->dev) : NULL;
>  
>  	if (attach->peer2peer &&
> -	    pci_p2pdma_distance(to_pci_dev(obj->dev->dev), attach->dev, false) < 0)
> +	    !(b_pdev && xe_configfs_get_force_p2p(a_pdev) &&
> +	      xe_configfs_get_force_p2p(b_pdev)) &&
> +	    pci_p2pdma_distance(a_pdev, attach->dev, false) < 0)

[Severity: High]
Because xe_configfs_get_force_p2p(b_pdev) falls back to the global module
parameter when find_xe_config_group_device() fails, doesn't this condition
evaluate to true even when b_pdev is a completely unrelated device?

This effectively skips the pci_p2pdma_distance() safety checks for any device
attempting P2P with the Xe GPU when xe.force_p2p=1 is enabled, which risks
data corruption if the bridge drops or corrupts transactions.

>  		attach->peer2peer = false;
>  
>  	if (!attach->peer2peer && !xe_bo_can_migrate(gem_to_xe_bo(obj), XE_PL_TT))
[ ... ]
> diff --git a/drivers/gpu/drm/xe/xe_svm.c b/drivers/gpu/drm/xe/xe_svm.c
> index 627a741293d59..3cd53bb166afd 100644
> --- a/drivers/gpu/drm/xe/xe_svm.c
> +++ b/drivers/gpu/drm/xe/xe_svm.c
[ ... ]
> @@ -892,6 +893,10 @@ static bool xe_has_interconnect(struct drm_pagemap_peer *peer1,
>  	if (dev1 == dev2)
>  		return true;
>  
> +	if (xe_configfs_get_force_p2p(to_pci_dev(dev1)) &&
> +	    xe_configfs_get_force_p2p(to_pci_dev(dev2)))
> +		return true;
> +

[Severity: High]
Similar to the xe_dma_buf_attach() logic above, does this improperly bypass
the interconnect peer distance checks for non-Xe devices when the global
module parameter is set?

>  	return pci_p2pdma_distance(to_pci_dev(dev1), dev2, true) >= 0;
>  }
>

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260818154042.301638-1-nathan.d.ciobanu@linux.intel.com?part=1

  parent reply	other threads:[~2026-08-18 15:54 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-18 15:40 [PATCH] drm/xe: Add force_p2p module/configfs parameter Nathan Ciobanu
2026-08-18 15:54 ` ✓ CI.KUnit: success for " Patchwork
2026-08-18 15:54 ` sashiko-bot [this message]
2026-08-18 16:45 ` ✓ Xe.CI.BAT: " Patchwork
2026-08-18 17:08 ` [PATCH] " Thomas Hellström
2026-08-18 20:07   ` Rodrigo Vivi
2026-08-18 20:08 ` ✗ Xe.CI.FULL: failure for " Patchwork

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=20260818155433.557591F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=nathan.d.ciobanu@linux.intel.com \
    --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