Add support for XeLink device
Subsystems (3)
v4 cover Add support for XeLink device
First patch set introduce the needed Xe infrastructure to support XeLink device.
The XeLink device is a glue-less module attached to a GPU device that provides connectivity between different GPUs on the same system.
The XeLink is part of the GPU (the register space is part of the GPU PCIe BAR), so it cannot be a completely separate device driver.
The Linux kernel provides an interface for handling this type of device, the Auxiliary Bus API.
The Xe and XeLink will use the auxiliary bus to enable the XeLink and the Xe to probe and communicate.
A followup series will include the XeLink driver code to provide full functionality for the device.
Changes from version 1:
- Fix kernel-doc error
Changes from version 2:
- Fix up rebase conflicts
Changes from version 3:
- Cleaned up xe_link.h header and removed unrequired include
David Kershner (3):
drm/xe: Introduce XeLink device
drm/xe: Teach Xe how to use objects with XeLink connectivity drm/xe/uapi: Augment query ioctl to allow for fabric
drivers/gpu/drm/xe/Makefile | 1 + drivers/gpu/drm/xe/regs/xe_gt_regs.h | 30 ++ drivers/gpu/drm/xe/xe_bo.c | 46 ++- drivers/gpu/drm/xe/xe_bo.h | 2 + drivers/gpu/drm/xe/xe_device.c | 13 +- drivers/gpu/drm/xe/xe_device_types.h | 24 ++ drivers/gpu/drm/xe/xe_dma_buf.c | 209 ++++++++---- drivers/gpu/drm/xe/xe_dma_buf.h | 3 + drivers/gpu/drm/xe/xe_ggtt.c | 3 + drivers/gpu/drm/xe/xe_gt_types.h | 2 + drivers/gpu/drm/xe/xe_irq.c | 22 ++ drivers/gpu/drm/xe/xe_link.c | 478 +++++++++++++++++++++++++++ drivers/gpu/drm/xe/xe_link.h | 20 ++ drivers/gpu/drm/xe/xe_mmio.c | 3 +- drivers/gpu/drm/xe/xe_pci.c | 2 + drivers/gpu/drm/xe/xe_pci_types.h | 1 + drivers/gpu/drm/xe/xe_pt.c | 2 + drivers/gpu/drm/xe/xe_query.c | 54 +++ drivers/gpu/drm/xe/xe_trace.h | 29 ++ drivers/gpu/drm/xe/xe_ttm_vram_mgr.c | 17 +- drivers/gpu/drm/xe/xe_vm.c | 3 +- include/drm/xelink_platform.h | 140 ++++++++ include/uapi/drm/xe_drm.h | 26 ++ 23 files changed, 1057 insertions(+), 73 deletions(-) create mode 100644 drivers/gpu/drm/xe/xe_link.c create mode 100644 drivers/gpu/drm/xe/xe_link.h create mode 100644 include/drm/xelink_platform.h
Signature · 1 line
2.38.1
PATCH v4 1/3 drm/xe: Introduce XeLink device
Add XeLink support for PVC devices.
Introduce the initial platform data structure that will be shared between the Xe driver and the XeLink driver.
If the device is PVC, and there is an XeLink device present, add and initialize an Auxbus device with the appropriate resources.
Add the XeLink information register.
Add package address register for defining the Device Physical Address space (DPA).
Add initial interrupt support.
The package address register defines the device physical address (DPA) space for the given device.
Using the "unique" xa_array index, generate a DPA address for the device and program the package register appropriately.
Update the LMEM offset to use the DPA address.
--- drivers/gpu/drm/xe/Makefile | 1 + drivers/gpu/drm/xe/regs/xe_gt_regs.h | 30 ++ drivers/gpu/drm/xe/xe_device.c | 13 +- drivers/gpu/drm/xe/xe_device_types.h | 24 ++ drivers/gpu/drm/xe/xe_gt_types.h | 2 + drivers/gpu/drm/xe/xe_irq.c | 22 ++ drivers/gpu/drm/xe/xe_link.c | 466 +++++++++++++++++++++++++++ drivers/gpu/drm/xe/xe_link.h | 18 ++ drivers/gpu/drm/xe/xe_mmio.c | 3 +- drivers/gpu/drm/xe/xe_pci.c | 2 + drivers/gpu/drm/xe/xe_pci_types.h | 1 + include/drm/xelink_platform.h | 140 ++++++++ 12 files changed, 719 insertions(+), 3 deletions(-) create mode 100644 drivers/gpu/drm/xe/xe_link.c create mode 100644 drivers/gpu/drm/xe/xe_link.h create mode 100644 include/drm/xelink_platform.h
drivers/gpu/drm/xe/Makefile +1 -0
@@ -106,6 +106,7 @@ xe-y += xe_bb.o \ xe_huc.o \ xe_huc_debugfs.o \ xe_irq.o \ + xe_link.o \ xe_lrc.o \ xe_migrate.o \ xe_mmio.o \
drivers/gpu/drm/xe/regs/xe_gt_regs.h +30 -0
@@ -61,6 +61,11 @@#define XEHP_GLOBAL_MOCS (i) XE_REG_MCR(0x4000 + (i) * 4)#define CCS_AUX_INV XE_REG(0x4208) +#define PKG_ADDR_RANGE XE_REG(0x41B0) +#define PKG_ADDR_RANGE_RANGE_SHIFT 20 +#define PKG_ADDR_RANGE_BASE_SHIFT 1 +#define PKG_ADDR_RANGE_ENABLE 1 +#define VD0_AUX_INV XE_REG(0x4218)#define VE0_AUX_INV XE_REG(0x4238)
@@ -68,6 +73,11 @@#define AUX_INV REG_BIT(0)#define XEHP_TILE_ADDR_RANGE (_idx) XE_REG_MCR(0x4900 + (_idx) * 4) +#define XEHP_TILE_LMEM_RANGE_SHIFT 8 +#define XEHP_TILE_LMEM_BASE_SHIFT 1 +#define XEHP_TILE_LMEM_BASE_MASK REG_GENMASK(7, 1) +#define XEHP_TILE_LMEM_RANGE_MASK REG_GENMASK(14, 8) +#define XEHP_FLAT_CCS_BASE_ADDR XE_REG_MCR(0x4910)#define WM_CHICKEN3 XE_REG_MCR(0x5588, XE_REG_OPTION_MASKED)
@@ -399,6 +409,11 @@#define CCS_MODE_CSLICE (cslice, ccs) \ ((ccs) << ((cslice) * CCS_MODE_CSLICE_WIDTH)) +#define PKG_ADDR_BASE XE_REG(0x108390) +#define PKG_ADDR_BASE_RANGE_SHIFT 20 +#define PKG_ADDR_BASE_BASE_SHIFT 1 +#define PKG_ADDR_BASE_ENABLE 1 +#define FORCEWAKE_ACK_GT XE_REG(0x130044)#define FORCEWAKE_KERNEL BIT(0)#define FORCEWAKE_USER BIT(1)
@@ -484,4 +499,19 @@#define PVC_GT0_PLATFORM_ENERGY_STATUS XE_REG(0x28106c)#define PVC_GT0_PACKAGE_POWER_SKU XE_REG(0x281080) +#define PUNIT_MMIO_CR_POC_STRAPS XE_REG(0x281078) +#define NUM_TILES_MASK REG_GENMASK(1, 0) +#define CD_ALIVE REG_BIT(2) +#define SOCKET_ID_MASK REG_GENMASK(7, 3) + +/* Define the BAR and offset for XeLink CSRs */ +#define XE_XELINK_IRQ BIT(8) +#define CD_BASE_OFFSET 0x291000 +#define CD_BAR_SIZE (256 * 1024) + +#define CPORT_MBDB_CSRS XE_REG(CD_BASE_OFFSET + 0x6000) +#define CPORT_MBDB_CSRS_END XE_REG(CD_BASE_OFFSET + 0x1000) +#define CPORT_MBDB_INT_ENABLE_MASK_LOW XE_REG(CD_BASE_OFFSET + 0x8) +#define CPORT_MBDB_INT_ENABLE_MASK_HIGH XE_REG(CD_BASE_OFFSET + 0x10) +#endif
drivers/gpu/drm/xe/xe_device.c +12 -1
@@ -1,6 +1,6 @@// SPDX-License-Identifier: MIT /* -* Copyright © 2021 Intel Corporation +* Copyright © 2021 - 2023 Intel Corporation */ #include "xe_device.h"
@@ -29,6 +29,7 @@#include "xe_gt.h" #include "xe_gt_mcr.h" #include "xe_irq.h" +#include "xe_link.h" #include "xe_memirq.h" #include "xe_mmio.h" #include "xe_module.h"
@@ -443,6 +444,8 @@ int xe_device_probe(struct xe_device *xe)if (err)return err; +xe_link_init_early (xe); + err =xe_set_dma_info (xe);if (err)return err;
@@ -465,6 +468,8 @@ int xe_device_probe(struct xe_device *xe) } } +xe_link_init_mmio (xe); + err =drmm_add_action_or_reset (&xe->drm, xe_driver_flr_fini, xe);if (err)return err;
@@ -493,6 +498,8 @@ int xe_device_probe(struct xe_device *xe)if (err)return err; +xe_link_init (xe); + err =xe_mmio_probe_vram (xe);if (err) goto err_irq_shutdown;
@@ -534,6 +541,8 @@ int xe_device_probe(struct xe_device *xe)xe_display_register (xe); +xe_link_init_aux (xe); +xe_debugfs_register (xe);xe_hwmon_register (xe);
@@ -568,6 +577,8 @@ void xe_device_remove(struct xe_device *xe)xe_display_fini (xe); +xe_link_remove (xe); +xe_heci_gsc_fini (xe);xe_irq_shutdown (xe);
drivers/gpu/drm/xe/xe_device_types.h +24 -0
@@ -259,6 +259,8 @@ struct xe_device { u8 has_asid:1;/** @force_execlist: Forced execlist submission */ u8 force_execlist:1; +/** @has_xelink: Has XeLink */ + u8 has_xelink:1;/** @has_flat_ccs: Whether flat CCS metadata is used */ u8 has_flat_ccs:1;/** @has_llc: Device has a shared CPU+GPU last level cache */
@@ -440,6 +442,28 @@ struct xe_device {/** @needs_flr_on_fini: requests function-reset on fini */ bool needs_flr_on_fini; +/** @xelink: XeLink information, for those gpus with XeLink connectivity */ +struct { +/** @ops: shared interface operations */ +const struct xelink_ops *ops; +/** @handle: XeLink device handle */ +void *handle; +/** @pd: platform data needed for auxiliary bus */ +struct xelink_pdata *pd; +/** @dpa: base device physical address */ +u64 dpa; +/** @irq_base: base IRQ for multi tile devices */ +int irq_base; +/** @index: internal index for xe devices */ +int index; +/** @xelink_id: XeLink id generated by the XeLink device */ +u32 xelink_id; +/** @socket_id: socket from certain platforms */ +u8 socket_id; +/* @present: Reflect PUNIT presence information */ +bool present; + } xelink; +/* private: */ #if IS_ENABLED (CONFIG_DRM_XE_DISPLAY )
drivers/gpu/drm/xe/xe_gt_types.h +2 -0
@@ -358,6 +358,8 @@ struct xe_gt {/** @oob: bitmap with active OOB workaroudns */ unsigned long *oob; } wa_active; +/** @xelink_irq: IRQ value assigned to the Xelink device */ +int xelink_irq; };#endif
drivers/gpu/drm/xe/xe_irq.c +22 -0
@@ -5,6 +5,7 @@#include "xe_irq.h" +#include <linux/irq.h> #include <linux/sched/clock.h> #include <drm/drm_managed.h>
@@ -29,6 +30,9 @@#define IIR (offset) XE_REG(offset + 0x8)#define IER (offset) XE_REG(offset + 0xc) +/* Define the BAR and offset for XeLink CSRs */ +#define XE_XELINK_IRQ BIT(8) +static void assert_iir_is_zero (struct xe_gt *mmio,struct xe_reg reg) {u32 val =xe_mmio_read32 (mmio, reg);
@@ -378,6 +382,18 @@ static void dg1_intr_enable(struct xe_device *xe, bool stall)xe_mmio_read32 (mmio,DG1_MSTR_TILE_INTR ); } +/* +* xelink_irq_handler - handle XeLink IRQs +* +* PVC can have an XeLink attached. Handle the IRQs that are sourced by +* the device supporting the XeLink. +*/ +static void xelink_irq_handler (struct xe_gt *gt,const u32 master_ctl) +{ +if (master_ctl &XE_XELINK_IRQ ) +generic_handle_irq (gt->xelink_irq); +} +/* * Top-level interrupt handler for Xe_LP+ and beyond. These platforms have * a "master tile" interrupt register which must be consulted before the
@@ -439,6 +455,7 @@ static irqreturn_t dg1_irq_handler(int irq, void *arg)xe_display_irq_handler (xe, master_ctl); gu_misc_iir =gu_misc_irq_ack (xe, master_ctl); } +xelink_irq_handler (mmio, master_ctl); }dg1_intr_enable (xe, false);
@@ -492,6 +509,11 @@ static void gt_irq_reset(struct xe_tile *tile)xe_mmio_write32 (mmio,GPM_WGBOXPERF_INTR_MASK , ~0 );xe_mmio_write32 (mmio,GUC_SG_INTR_ENABLE ,0 );xe_mmio_write32 (mmio,GUC_SG_INTR_MASK , ~0 ); + +if (tile->xe->xelink.present) { +xe_mmio_write32 (mmio,CPORT_MBDB_INT_ENABLE_MASK_LOW ,0 ); +xe_mmio_write32 (mmio,CPORT_MBDB_INT_ENABLE_MASK_HIGH ,0 ); + } }static void xelp_irq_reset (struct xe_tile *tile)
drivers/gpu/drm/xe/xe_link.c new file +466 -0
466 lines not on this page · raw message
drivers/gpu/drm/xe/xe_link.h new file +18 -0
@@ -0,0 +1,18 @@ +/* SPDX-License-Identifier: MIT */ +/* +* Copyright © 2019 - 2023 Intel Corporation +*/ + +#ifndef _XE_LINK_H_ +#define _XE_LINK_H_ + + +struct xe_device ; + +void xe_link_init_early (struct xe_device *xe); +void xe_link_init_mmio (struct xe_device *xe); +void xe_link_init (struct xe_device *xe); +void xe_link_init_aux (struct xe_device *xe); +void xe_link_remove (struct xe_device *xe); + +#endif
drivers/gpu/drm/xe/xe_mmio.c +1 -2
@@ -153,8 +153,7 @@ static int xe_determine_lmem_bar_size(struct xe_device *xe)if (!xe->mem.vram.io_size)return -EIO ; -/* XXX: Need to change when xe link code is ready */ - xe->mem.vram.dpa_base =0 ; + xe->mem.vram.dpa_base = xe->xelink.dpa;/* set up a map to the total memory area. */ xe->mem.vram.mapping =ioremap_wc (xe->mem.vram.io_start, xe->mem.vram.io_size);
drivers/gpu/drm/xe/xe_pci.c +2 -0
@@ -148,6 +148,7 @@ static const struct xe_graphics_desc graphics_xehpc = { .has_asid = 1, .has_flat_ccs = 0, .has_usm = 1, + .has_xelink = 1, };static const struct xe_graphics_desc graphics_xelpg = {
@@ -617,6 +618,7 @@ static int xe_info_init(struct xe_device *xe, xe->info.va_bits = graphics_desc->va_bits; xe->info.vm_max_level = graphics_desc->vm_max_level; xe->info.has_asid = graphics_desc->has_asid; + xe->info.has_xelink = graphics_desc->has_xelink; xe->info.has_flat_ccs = graphics_desc->has_flat_ccs; xe->info.has_range_tlb_invalidation = graphics_desc->has_range_tlb_invalidation; xe->info.has_usm = graphics_desc->has_usm;
drivers/gpu/drm/xe/xe_pci_types.h +1 -0
@@ -25,6 +25,7 @@ struct xe_graphics_desc { u8 max_remote_tiles:2; u8 has_asid:1; + u8 has_xelink:1; u8 has_flat_ccs:1; u8 has_range_tlb_invalidation:1; u8 has_usm:1;
include/drm/xelink_platform.h new file +140 -0
140 lines not on this page · raw message
Signature · 1 line
2.38.1
PATCH v4 2/3 drm/xe: Teach Xe how to use objects with XeLink connectivity
In reply to David KershnerThe XeLink device offers fabric backed memory. Page table entries need to be aware of this fact so that the access occur over the fabric rather than to the system or local device memory.
Objects are shared via dma-buf, and then fabric connectivity is checked during the _get_pages() pass.
Objects do NOT need to be dma mapped because system dma does not occur.
The Device Physical Address (DPA) is the memory range assigned to the fabric device at driver init. This address is what will need to be programmed into the page table entry. In addition the PTE_LM bit needs to be set.
Address information is provided in a scatter/gather table.
Teach the dma-buf interface and the page table entries all about fabric backed memory.
--- drivers/gpu/drm/xe/xe_bo.c | 46 +++++- drivers/gpu/drm/xe/xe_bo.h | 2 + drivers/gpu/drm/xe/xe_dma_buf.c | 209 +++++++++++++++++++-------- drivers/gpu/drm/xe/xe_dma_buf.h | 3 + drivers/gpu/drm/xe/xe_ggtt.c | 3 + drivers/gpu/drm/xe/xe_link.c | 12 ++ drivers/gpu/drm/xe/xe_link.h | 2 + drivers/gpu/drm/xe/xe_pt.c | 2 + drivers/gpu/drm/xe/xe_trace.h | 29 ++++ drivers/gpu/drm/xe/xe_ttm_vram_mgr.c | 17 ++- drivers/gpu/drm/xe/xe_vm.c | 3 +- 11 files changed, 258 insertions(+), 70 deletions(-)
drivers/gpu/drm/xe/xe_bo.c +44 -2
@@ -8,6 +8,7 @@#include <linux/dma-buf.h> #include <drm/drm_drv.h> +#include <drm/drm_gem.h> #include <drm/drm_gem_ttm_helper.h> #include <drm/drm_managed.h> #include <drm/ttm/ttm_device.h>
@@ -20,6 +21,7 @@#include "xe_drm_client.h" #include "xe_ggtt.h" #include "xe_gt.h" +#include "xe_link.h" #include "xe_map.h" #include "xe_migrate.h" #include "xe_preempt_fence.h"
@@ -521,6 +523,32 @@ static int xe_bo_trigger_rebind(struct xe_device *xe, struct xe_bo *bo,return ret; } +/** +* map_xelink_connectivity - check for XeLink and create a mappable sgt +* if available +* @bo: object to check XeLink connectivity +* +* Returns sgt or -errno on error, -EIO indicates no XeLink connectivity. +*/ +static struct sg_table *map_xelink_connectivity (struct xe_bo *bo) +{ +struct dma_buf_attachment *attach = bo->ttm.base.import_attach; +struct xe_bo *import; + +if (!(bo->flags &XE_BO_XELINK_AVAIL )) +return ERR_PTR (-EIO ); + + import =gem_to_xe_bo (attach->dmabuf->priv); + +/* Make sure the object didn't migrate */ +if (!xe_bo_is_vram (import)) { + bo->flags &= ~XE_BO_XELINK_AVAIL ; +return ERR_PTR (-EIO ); + } + +return xe_dma_buf_map (attach,DMA_NONE ); +} +/* * The dma-buf map_attachment() / unmap_attachment() is hooked up here. * Note that unmapping the attachment is deferred to the next
@@ -538,6 +566,7 @@ static int xe_bo_move_dmabuf(struct ttm_buffer_object *ttm_bo, ttm);struct xe_device *xe =ttm_to_xe_device (ttm_bo->bdev);struct sg_table *sg; +struct xe_bo *bo, *export;xe_assert (xe, attach);xe_assert (xe, ttm_bo->ttm);
@@ -545,12 +574,25 @@ static int xe_bo_move_dmabuf(struct ttm_buffer_object *ttm_bo,if (new_res->mem_type ==XE_PL_SYSTEM ) goto out; + bo =ttm_to_xe_bo (ttm_bo);if (ttm_bo->sg) { -dma_buf_unmap_attachment (attach, ttm_bo->sg,DMA_BIDIRECTIONAL ); +if (bo->flags &XE_BO_XELINK_AVAIL ) { + export =gem_to_xe_bo (attach->dmabuf->priv); +xe_link_mapping_put (to_xe_device (export->ttm.base.dev)); +xe_link_mapping_put (to_xe_device (ttm_bo->base.dev)); +sg_free_table (ttm_bo->sg); +kfree (ttm_bo->sg); + }else { +dma_buf_unmap_attachment (attach, ttm_bo->sg,DMA_BIDIRECTIONAL ); + } ttm_bo->sg =NULL ; } - sg =dma_buf_map_attachment (attach,DMA_BIDIRECTIONAL ); + sg =map_xelink_connectivity (bo); + +if (IS_ERR (sg) &&PTR_ERR (sg) == -EIO ) + sg =dma_buf_map_attachment (attach,DMA_BIDIRECTIONAL ); +if (IS_ERR (sg))return PTR_ERR (sg);
drivers/gpu/drm/xe/xe_bo.h +2 -0
@@ -45,6 +45,8 @@#define XE_BO_PAGETABLE BIT(12)#define XE_BO_NEEDS_CPU_ACCESS BIT(13)#define XE_BO_NEEDS_UC BIT(14) +#define XE_BO_XELINK_AVAIL BIT(15) +/* this one is trigger internally only */ #define XE_BO_INTERNAL_TEST BIT(30)#define XE_BO_INTERNAL_64K BIT(31)
drivers/gpu/drm/xe/xe_dma_buf.c +148 -61
283 lines not on this page · raw message
drivers/gpu/drm/xe/xe_dma_buf.h +3 -0
@@ -7,9 +7,12 @@#define _XE_DMA_BUF_H_#include <drm/drm_gem.h> +#include <linux/dma-direction.h> struct dma_buf *xe_gem_prime_export (struct drm_gem_object *obj,int flags);struct drm_gem_object *xe_gem_prime_import (struct drm_device *dev,struct dma_buf *dma_buf); +struct sg_table *xe_dma_buf_map (struct dma_buf_attachment *attach, +enum dma_data_direction dir);#endif
drivers/gpu/drm/xe/xe_ggtt.c +3 -0
@@ -36,6 +36,9 @@ static u64 xelp_ggtt_pte_encode_bo(struct xe_bo *bo, u64 bo_offset,if (xe_bo_is_vram (bo) ||xe_bo_is_stolen_devmem (bo)) pte |=XE_GGTT_PTE_DM ; +if (xe_bo_is_vram (bo) || bo->flags &XE_BO_XELINK_AVAIL ) + pte |=XE_PPGTT_PTE_DM ; +return pte; }
drivers/gpu/drm/xe/xe_link.c +12 -0
@@ -464,3 +464,15 @@ void xe_link_remove(struct xe_device *xe) xe->xelink.ops = &default_ops; } + +int xe_link_mapping_get (struct xe_device *xe) +{ +return xe->xelink.ops->parent_event (xe->xelink.handle, +XELINK_PARENT_MAPPING_GET ); +} + +int xe_link_mapping_put (struct xe_device *xe) +{ +return xe->xelink.ops->parent_event (xe->xelink.handle, +XELINK_PARENT_MAPPING_PUT ); +}
drivers/gpu/drm/xe/xe_link.h +2 -0
@@ -13,6 +13,8 @@ void xe_link_init_early(struct xe_device *xe);void xe_link_init_mmio (struct xe_device *xe);void xe_link_init (struct xe_device *xe);void xe_link_init_aux (struct xe_device *xe); +int xe_link_mapping_get (struct xe_device *xe); +int xe_link_mapping_put (struct xe_device *xe);void xe_link_remove (struct xe_device *xe);#endif
drivers/gpu/drm/xe/xe_pt.c +2 -0
@@ -609,6 +609,8 @@ xe_pt_stage_bind(struct xe_tile *tile, struct xe_vma *vma,if (is_devmem) { xe_walk.default_pte |=XE_PPGTT_PTE_DM ; xe_walk.dma_offset =vram_region_gpu_offset (bo->ttm.resource); + }else if (!xe_vma_has_no_bo (vma) && bo->flags &XE_BO_XELINK_AVAIL ) { + xe_walk.default_pte |=XE_PPGTT_PTE_DM ; }if (!xe_vma_has_no_bo (vma) &&xe_bo_is_stolen (bo))
drivers/gpu/drm/xe/xe_trace.h +29 -0
@@ -105,6 +105,35 @@ DEFINE_EVENT(xe_bo, xe_bo_move,TP_ARGS (bo) ); +DECLARE_EVENT_CLASS (xe_dma_buf, + TP_PROTO(struct xe_bo *bo, struct xe_bo *imp_bo, int xelink, int p2p), +TP_ARGS (bo, imp_bo, xelink, p2p), + +TP_STRUCT__entry ( + __field(struct xe_bo *, bo) + __field(struct xe_bo *, imp_bo) + __field(bool, xelink) +__field (bool, p2p) + ), + +TP_fast_assign ( + __entry->bo = bo; + __entry->imp_bo = imp_bo; + __entry->xelink = xelink; + __entry->p2p = p2p; + ), + +TP_printk ("bo=: 0x%p-mem_type=%d, imp_bo: 0x%p-mem_type=%d, xelink=%d, p2p=%d" , + __entry->bo, __entry->bo->ttm.resource->mem_type, + __entry->imp_bo, __entry->imp_bo->ttm.resource->mem_type, + __entry->xelink, __entry->p2p) +); + +DEFINE_EVENT (xe_dma_buf, xe_dma_buf_attach, + TP_PROTO(struct xe_bo *bo, struct xe_bo *imp_bo, int xelink, int p2p), +TP_ARGS (bo, imp_bo, xelink, p2p) +); + DECLARE_EVENT_CLASS(xe_exec_queue, TP_PROTO(struct xe_exec_queue *q), TP_ARGS(q),
drivers/gpu/drm/xe/xe_ttm_vram_mgr.c +11 -6
@@ -412,15 +412,20 @@ int xe_ttm_vram_mgr_alloc_sgt(struct xe_device *xe,*/ xe_res_first (res, offset, length, &cursor);for_each_sgtable_sg ((*sgt), sg, i) { -phys_addr_t phys = cursor.start + tile->mem.vram.io_start;size_t size = cursor.size;dma_addr_t addr; - addr =dma_map_resource (dev, phys, size, dir, -DMA_ATTR_SKIP_CPU_SYNC ); - r =dma_mapping_error (dev, addr); -if (r) - goto error_unmap; +if (dir ==DMA_NONE ) { + addr = cursor.start + tile->mem.vram.dpa_base; + }else { +phys_addr_t phys = cursor.start + tile->mem.vram.io_start; + + addr =dma_map_resource (dev, phys, size, dir, +DMA_ATTR_SKIP_CPU_SYNC ); + r =dma_mapping_error (dev, addr); +if (r) + goto error_unmap; + }sg_set_page (sg,NULL , size,0 );sg_dma_address (sg) = addr;
drivers/gpu/drm/xe/xe_vm.c +2 -1
@@ -1135,7 +1135,8 @@ static u64 xelp_pte_encode_bo(struct xe_bo *bo, u64 bo_offset, pte |=pte_encode_pat_index (xe, pat_index, pt_level); pte |=pte_encode_ps (pt_level); -if (xe_bo_is_vram (bo) ||xe_bo_is_stolen_devmem (bo)) +if (xe_bo_is_vram (bo) ||xe_bo_is_stolen_devmem (bo) || + bo->flags &XE_BO_XELINK_AVAIL ) pte |=XE_PPGTT_PTE_DM ;return pte;
Signature · 1 line
2.38.1
PATCH v4 3/3 drm/xe/uapi: Augment query ioctl to allow for fabric
In reply to David KershnerUMDs need to understand if two devices have connectivity, and what that connectivity is.
Add to the query_ioctl the ability to determine if a fabric id and current device have connectivity.
--- drivers/gpu/drm/xe/xe_query.c | 54 +++++++++++++++++++++++++++++++++++ include/uapi/drm/xe_drm.h | 26 +++++++++++++++++ 2 files changed, 80 insertions(+)
drivers/gpu/drm/xe/xe_query.c +54 -0
@@ -6,10 +6,12 @@#include "xe_query.h" #include <linux/nospec.h> +#include <linux/overflow.h> #include <linux/sched/clock.h> #include <drm/ttm/ttm_placement.h> #include <drm/xe_drm.h> +#include <drm/xelink_platform.h> #include "regs/xe_engine_regs.h" #include "xe_bo.h"
@@ -104,6 +106,57 @@ __read_timestamps(struct xe_gt *gt, *engine_ts = (u64 )upper <<32 | lower; } +static int +query_fabric_connectivity (struct xe_device *xe, +struct drm_xe_device_query *query) +{ +struct drm_xe_query_fabric_info __user *query_ptr; +struct drm_xe_query_fabric_info info; +struct query_info *qi; +u32 latency =0 ; +int cnt; +int i; + + query_ptr =u64_to_user_ptr (query->data); +if (copy_from_user (&info, query_ptr,sizeof (info))) +return -EFAULT ; + + info.bandwidth =0 ; + info.latency =0 ; + +if (info.fabric_id == xe->xelink.xelink_id) + goto done; + + qi = xe->xelink.ops->connectivity_query (xe->xelink.handle, info.fabric_id); +if (IS_ERR (qi)) + goto done; +/* +* Examine the query information for connectivity. +* Minimum bandwidth value is the bandwidth, 0 == no connectivity +* Latency is averaged. +*/ + cnt = qi->src_cnt * qi->dst_cnt; +if (!cnt) { +kfree (qi); +return -ENXIO ; + } + + info.bandwidth =0xffff ; +for (i =0 ; i < cnt; i++) { + info.bandwidth =min (qi->sd2sd[i].bandwidth, info.bandwidth); +XE_WARN_ON (check_add_overflow (latency, qi->sd2sd[i].latency, + &latency)); + } + + info.latency = latency / cnt; + +kfree (qi); +done: +if (copy_to_user (query_ptr, &info,sizeof (info))) +return -EFAULT ; +return 0 ; +} +static int query_engine_cycles (struct xe_device *xe,struct drm_xe_device_query *query)
@@ -529,6 +582,7 @@ static int (* const xe_query_funcs[])(struct xe_device *xe, query_hwconfig, query_gt_topology, query_engine_cycles, + query_fabric_connectivity, };int xe_query_ioctl (struct drm_device *dev,void *data,struct drm_file *file)
include/uapi/drm/xe_drm.h +26 -0
@@ -574,6 +574,31 @@ struct drm_xe_query_engine_cycles {__u64 cpu_delta; }; +/** +* struct drm_xe_query_fabric_info +* +* With the given fabric id, query fabric info wrt the device. +* Higher bandwidth is better. 0 means no fabric. +* Latency is averaged latency (from all paths) +* +* fabric_id can be obtained from +* /sys/class/drm/cardx/device/xelink.y/xelink_fabric_id +* Bandwidth is in Gigabits per second (max value of 8 * 4 * 90) +* 8 possible ports +* 4 lanes max per port +* 90 gigabits per lane +* Latency is in tenths of path length. 10 == 1 fabric link between src and dst +* POR is max 1 link (zero hops). +*/ +struct drm_xe_query_fabric_info { +/** @fabric_id: Fabric id associated with info */ +__u32 fabric_id; +/** @bandwidth: minimum bandwidth of all connected ports, if 0 no fabric */ +__u16 bandwidth; +/** @latency: latency averaged across all connected ports. */ +__u16 latency; +}; +/** * struct drm_xe_device_query - Input of &DRM_IOCTL_XE_DEVICE_QUERY - main * structure to query device information
@@ -643,6 +668,7 @@ struct drm_xe_device_query {#define DRM_XE_DEVICE_QUERY_HWCONFIG 4#define DRM_XE_DEVICE_QUERY_GT_TOPOLOGY 5#define DRM_XE_DEVICE_QUERY_ENGINE_CYCLES 6 +#define DRM_XE_DEVICE_QUERY_FABRIC_INFO 7/** @query: The type of data to query */ __u32 query;
Signature · 1 line
2.38.1