Skip to content

Commit 34acf33

Browse files
feature: Add PCI barrier mmap logic for xe
Related-To: NEO-13081 Signed-off-by: Filip Hazubski <[email protected]>
1 parent 022f9e6 commit 34acf33

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

shared/source/os_interface/linux/xe/ioctl_helper_xe.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1703,4 +1703,16 @@ void IoctlHelperXe::querySupportedFeatures() {
17031703
bool IoctlHelperXe::isEuPerDssTopologyType(uint16_t topologyType) const {
17041704
return topologyType == DRM_XE_TOPO_EU_PER_DSS;
17051705
}
1706+
1707+
void *IoctlHelperXe::pciBarrierMmap() {
1708+
GemMmapOffset mmapOffset = {};
1709+
mmapOffset.flags = DRM_XE_MMAP_OFFSET_FLAG_PCI_BARRIER;
1710+
auto ret = ioctl(DrmIoctl::gemMmapOffset, &mmapOffset);
1711+
if (ret != 0) {
1712+
return false;
1713+
}
1714+
1715+
return SysCalls::mmap(NULL, MemoryConstants::pageSize, PROT_WRITE, MAP_SHARED, drm.getFileDescriptor(), static_cast<off_t>(mmapOffset.offset));
1716+
}
1717+
17061718
} // namespace NEO

shared/source/os_interface/linux/xe/ioctl_helper_xe.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ class IoctlHelperXe : public IoctlHelper {
133133
bool resourceRegistrationEnabled() override { return true; }
134134
bool isPreemptionSupported() override { return true; }
135135
virtual bool isEuPerDssTopologyType(uint16_t topologyType) const;
136+
void *pciBarrierMmap() override;
136137

137138
protected:
138139
static constexpr uint32_t maxContextSetProperties = 4;

third_party/uapi/upstream/xe/xe_drm.h

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -809,7 +809,18 @@ struct drm_xe_gem_mmap_offset {
809809
/** @handle: Handle for the object being mapped. */
810810
__u32 handle;
811811

812-
/** @flags: Must be zero */
812+
/**
813+
* For user to query special offset we are adding special flag in
814+
* mmap_offset ioctl which needs to be passed as follows,
815+
* struct drm_xe_gem_mmap_offset mmo = {
816+
* .handle = 0, (this must be set to 0)
817+
* .flags = DRM_XE_MMAP_OFFSET_FLAG_PCI_BARRIER,
818+
* };
819+
* igt_ioctl(fd, DRM_IOCTL_XE_GEM_MMAP_OFFSET, &mmo);
820+
* map = mmap(NULL, size, PROT_WRITE, MAP_SHARED, fd, mmo);
821+
*/
822+
#define DRM_XE_MMAP_OFFSET_FLAG_PCI_BARRIER (1 << 0)
823+
/** @flags: Flag to indicate if any special offset, zero otherwise */
813824
__u32 flags;
814825

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

0 commit comments

Comments
 (0)