Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: Add PCI barrier mmap logic for xe #772

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading