Skip to content

Commit

Permalink
feature: Add PCI barrier mmap logic for xe
Browse files Browse the repository at this point in the history
Related-To: NEO-13081

Signed-off-by: Filip Hazubski <[email protected]>
  • Loading branch information
fhazubski-Intel committed Oct 29, 2024
1 parent 022f9e6 commit 34acf33
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
12 changes: 12 additions & 0 deletions shared/source/os_interface/linux/xe/ioctl_helper_xe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1703,4 +1703,16 @@ void IoctlHelperXe::querySupportedFeatures() {
bool IoctlHelperXe::isEuPerDssTopologyType(uint16_t topologyType) const {
return topologyType == DRM_XE_TOPO_EU_PER_DSS;
}

void *IoctlHelperXe::pciBarrierMmap() {
GemMmapOffset mmapOffset = {};
mmapOffset.flags = DRM_XE_MMAP_OFFSET_FLAG_PCI_BARRIER;
auto ret = ioctl(DrmIoctl::gemMmapOffset, &mmapOffset);
if (ret != 0) {
return false;
}

return SysCalls::mmap(NULL, MemoryConstants::pageSize, PROT_WRITE, MAP_SHARED, drm.getFileDescriptor(), static_cast<off_t>(mmapOffset.offset));
}

} // namespace NEO
1 change: 1 addition & 0 deletions shared/source/os_interface/linux/xe/ioctl_helper_xe.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ class IoctlHelperXe : public IoctlHelper {
bool resourceRegistrationEnabled() override { return true; }
bool isPreemptionSupported() override { return true; }
virtual bool isEuPerDssTopologyType(uint16_t topologyType) const;
void *pciBarrierMmap() override;

protected:
static constexpr uint32_t maxContextSetProperties = 4;
Expand Down
13 changes: 12 additions & 1 deletion third_party/uapi/upstream/xe/xe_drm.h
Original file line number Diff line number Diff line change
Expand Up @@ -809,7 +809,18 @@ struct drm_xe_gem_mmap_offset {
/** @handle: Handle for the object being mapped. */
__u32 handle;

/** @flags: Must be zero */
/**
* For user to query special offset we are adding special flag in
* mmap_offset ioctl which needs to be passed as follows,
* struct drm_xe_gem_mmap_offset mmo = {
* .handle = 0, (this must be set to 0)
* .flags = DRM_XE_MMAP_OFFSET_FLAG_PCI_BARRIER,
* };
* igt_ioctl(fd, DRM_IOCTL_XE_GEM_MMAP_OFFSET, &mmo);
* map = mmap(NULL, size, PROT_WRITE, MAP_SHARED, fd, mmo);
*/
#define DRM_XE_MMAP_OFFSET_FLAG_PCI_BARRIER (1 << 0)
/** @flags: Flag to indicate if any special offset, zero otherwise */
__u32 flags;

/** @offset: The fake offset to use for subsequent mmap call */
Expand Down

0 comments on commit 34acf33

Please sign in to comment.