Provide an op for supports_interconnects() to indicate to the
dma-buf core and to the exporter that Xe supports interconnects.
Note that Xe would support IOV interconnect only if the buffer
is located in LMEM region.

Cc: Jason Gunthorpe <[email protected]>
Cc: Christian Koenig <[email protected]>
Cc: Sumit Semwal <[email protected]>
Cc: Thomas Hellström <[email protected]>
Cc: Simona Vetter <[email protected]>
Signed-off-by: Vivek Kasireddy <[email protected]>
---
 drivers/gpu/drm/xe/xe_dma_buf.c | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/xe/xe_dma_buf.c b/drivers/gpu/drm/xe/xe_dma_buf.c
index a7d67725c3ee..2d63dd86a249 100644
--- a/drivers/gpu/drm/xe/xe_dma_buf.c
+++ b/drivers/gpu/drm/xe/xe_dma_buf.c
@@ -13,6 +13,7 @@
 #include <drm/drm_prime.h>
 #include <drm/ttm/ttm_tt.h>
 
+#include "regs/xe_bars.h"
 #include "tests/xe_test.h"
 #include "xe_bo.h"
 #include "xe_device.h"
@@ -274,9 +275,25 @@ static void xe_dma_buf_move_notify(struct 
dma_buf_attachment *attach)
        XE_WARN_ON(xe_bo_evict(bo, exec));
 }
 
+static bool
+xe_dma_buf_supports_interconnects(struct dma_buf_attachment *attach,
+                                 const struct dma_buf_interconnect_match *exp,
+                                 unsigned int exp_ics)
+{
+       struct pci_dev *pdev = to_pci_dev(attach->dev);
+       unsigned int bar = LMEM_BAR;
+       const struct dma_buf_interconnect_match supports_ics[] = {
+               CREATE_IOV_INTERCONNECT(pdev, bar),
+       };
+
+       return dma_buf_match_interconnects(attach, exp, exp_ics, supports_ics,
+                                          ARRAY_SIZE(supports_ics));
+}
+
 static const struct dma_buf_attach_ops xe_dma_buf_attach_ops = {
        .allow_peer2peer = true,
-       .move_notify = xe_dma_buf_move_notify
+       .move_notify = xe_dma_buf_move_notify,
+       .supports_interconnects = xe_dma_buf_supports_interconnects,
 };
 
 #if IS_ENABLED(CONFIG_DRM_XE_KUNIT_TEST)
-- 
2.50.1

Reply via email to