Skip to content

Commit

Permalink
[MOS] Allocate command buffers from system memory on ATSM Linux
Browse files Browse the repository at this point in the history
To reduce out-bound writing over PCIe bus.
  • Loading branch information
zxye authored and intel-mediadev committed Sep 20, 2022
1 parent 75c5be1 commit 6c436ac
Show file tree
Hide file tree
Showing 12 changed files with 69 additions and 1 deletion.
10 changes: 10 additions & 0 deletions media_driver/linux/Xe_M/ddi/media_sku_wa_xe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -825,6 +825,16 @@ static bool InitDg2MediaSku(struct GfxDeviceInfo *devInfo,
// Enable HVS Denoise
MEDIA_WR_SKU(skuTable, FtrHVSDenoise, 1);

#define IS_SERVER_SKU(d) (((d) >= 0x56C0) && ((d) <= 0x56C1))
if (IS_SERVER_SKU(drvInfo->devId))
{
drvInfo->isServer = 1;
}
else
{
drvInfo->isServer = 0;
}

return true;
}

Expand Down
6 changes: 5 additions & 1 deletion media_driver/linux/common/os/hwinfo_linux.c
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ MOS_STATUS HWInfo_GetGfxInfo(int32_t fd,
MOS_USER_FEATURE_VALUE_DATA UserFeatureData;
#endif

LinuxDriverInfo drvInfo = {18, 3, 0, 23172, 3, 1, 0, 1, 0, 0, 1, 0};
LinuxDriverInfo drvInfo = {18, 3, 0, 23172, 3, 1, 0, 1, 0, 0, 1, 0, 0};
if (!Mos_Solo_IsEnabled(nullptr) && HWInfoGetLinuxDrvInfo(fd, &drvInfo) != MOS_STATUS_SUCCESS)
{
MOS_OS_ASSERTMESSAGE("Failed to get the chipset id\n");
Expand Down Expand Up @@ -341,6 +341,10 @@ MOS_STATUS HWInfo_GetGfxInfo(int32_t fd,
{
MOS_OS_NORMALMESSAGE("Init Media SystemInfo successfully\n");
}
if (drvInfo.isServer)
{
mos_set_platform_information(pDrmBufMgr, PLATFORM_INFORMATION_IS_SERVER);
}

/* disable it on Linux */
MEDIA_WR_SKU(skuTable, FtrPerCtxtPreemptionGranularityControl, 0);
Expand Down
3 changes: 3 additions & 0 deletions media_driver/linux/common/os/i915/include/mos_bufmgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -431,4 +431,7 @@ drm_export bool mos_gem_bo_is_exec_object_async(struct mos_linux_bo *bo);
}
#endif

#define PLATFORM_INFORMATION_IS_SERVER 0x1
uint64_t mos_get_platform_information(struct mos_bufmgr *bufmgr);
void mos_set_platform_information(struct mos_bufmgr *bufmgr, uint64_t p);
#endif /* INTEL_BUFMGR_H */
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,7 @@ struct mos_bufmgr {
int debug;
uint32_t *get_reserved = nullptr;
bool has_full_vd = true;
uint64_t platform_information = 0;
};

#define ALIGN(value, alignment) ((value + alignment - 1) & ~(alignment - 1))
Expand Down
12 changes: 12 additions & 0 deletions media_driver/linux/common/os/i915/mos_bufmgr.c
Original file line number Diff line number Diff line change
Expand Up @@ -5245,3 +5245,15 @@ int mos_query_hw_ip_version(int fd, struct i915_engine_class_instance engine, vo
{
return -1;
}

uint64_t mos_get_platform_information(struct mos_bufmgr *bufmgr)
{
assert(bufmgr);
return bufmgr->platform_information;
}

void mos_set_platform_information(struct mos_bufmgr *bufmgr, uint64_t p)
{
assert(bufmgr);
bufmgr->platform_information |= p;
}
12 changes: 12 additions & 0 deletions media_driver/linux/common/os/i915_production/mos_bufmgr.c
Original file line number Diff line number Diff line change
Expand Up @@ -5695,3 +5695,15 @@ int mos_query_hw_ip_version(int fd, struct i915_engine_class_instance engine, vo
{
return -1;
}

uint64_t mos_get_platform_information(struct mos_bufmgr *bufmgr)
{
assert(bufmgr);
return bufmgr->platform_information;
}

void mos_set_platform_information(struct mos_bufmgr *bufmgr, uint64_t p)
{
assert(bufmgr);
bufmgr->platform_information |= p;
}
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,7 @@ struct mos_bufmgr {
uint32_t *get_reserved = nullptr;
uint32_t tile_id = 0;
bool has_full_vd = true;
uint64_t platform_information = 0;
};

#define ALIGN(value, alignment) ((value + alignment - 1) & ~(alignment - 1))
Expand Down
1 change: 1 addition & 0 deletions media_driver/linux/common/os/linux_system_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ struct LinuxDriverInfo
uint32_t hasHuc : 1;
uint32_t hasPpgtt : 1;
uint32_t hasPreemption : 1;
uint32_t isServer : 1;
};

struct LinuxCodecInfo
Expand Down
10 changes: 10 additions & 0 deletions media_driver/linux/common/os/memory_policy_manager_specific.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,15 @@ int MemoryPolicyManager::UpdateMemoryPolicyWithWA(
}
}

if(memPolicyPar->isServer)
{
if (strcmp(memPolicyPar->resName, "MOS CmdBuf") == 0 ||
strcmp(memPolicyPar->resName, "BatchBuffer") == 0
)
{
mem_type = MOS_MEMPOOL_SYSTEMMEMORY;
}
}

return 0;
}
12 changes: 12 additions & 0 deletions media_driver/linux/ult/libdrm_mock/mos_bufmgr_mock.c
Original file line number Diff line number Diff line change
Expand Up @@ -4357,3 +4357,15 @@ bool mos_gem_bo_is_softpin(struct mos_linux_bo *bo)

return bo_gem->is_softpin;
}

uint64_t mos_get_platform_information(struct mos_bufmgr *bufmgr)
{
assert(bufmgr);
return bufmgr->platform_information;
}

void mos_set_platform_information(struct mos_bufmgr *bufmgr, uint64_t p)
{
assert(bufmgr);
bufmgr->platform_information |= p;
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ struct MemoryPolicyParameter
const char* resName;
uint32_t uiType;
int preferredMemType;
bool isServer;
};

class MemoryPolicyManager
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ MOS_STATUS GraphicsResourceSpecificNext::Allocate(OsContextNext* osContextPtr, C
memPolicyPar.resInfo = gmmResourceInfoPtr;
memPolicyPar.resName = params.m_name.c_str();
memPolicyPar.preferredMemType = params.m_memType;
memPolicyPar.isServer = PLATFORM_INFORMATION_IS_SERVER & mos_get_platform_information(pOsContextSpecific->GetBufMgr());

mem_type = MemoryPolicyManager::UpdateMemoryPolicy(&memPolicyPar);
}
Expand Down

0 comments on commit 6c436ac

Please sign in to comment.