Commit 9641df81 authored by Tejas Upadhyay's avatar Tejas Upadhyay Committed by Rodrigo Vivi

drm/xe: Add sysfs entry to report per tile memory size

Add sysfs entry to read per tile physical memory
including stolen memory.

V5:
  - rename var name and make it part of vram struct - Lucas
V4:
  - %s/addr_range/physical_vram_size_byes, make it
    user readable name - Joonas/Aravind
  - Display in bytes - Joonas/Aravind
V3:
  - Exclude DG1, replace sysfs_create_file/files - Aravind
V2:
  - Use DEVICE_ATTR_RO - Aravind
  - Dont put kobj on sysfs_file_create fail - Himal
  - Skip addr_range sysfs create for non dgfx - Himal
Reviewed-by: default avatarAravind Iddamsetty <aravind.iddamsetty@intel.com>
Signed-off-by: default avatarTejas Upadhyay <tejas.upadhyay@intel.com>
Signed-off-by: default avatarRodrigo Vivi <rodrigo.vivi@intel.com>
parent 8c82f914
......@@ -124,6 +124,11 @@ struct xe_tile {
resource_size_t base;
/** @size: size of VRAM. */
resource_size_t size;
/**
* @actual_physical_size: Actual VRAM size
* including stolen mem for tile
*/
resource_size_t actual_physical_size;
/** @mapping: pointer to VRAM mappable space */
void *__iomem mapping;
} vram;
......
......@@ -277,6 +277,7 @@ int xe_mmio_probe_vram(struct xe_device *xe)
if (err)
return err;
tile->mem.vram.actual_physical_size = tile_size;
tile->mem.vram.io_start = xe->mem.vram.io_start + tile_offset;
tile->mem.vram.io_size = min_t(u64, vram_size, io_size);
......
......@@ -20,6 +20,20 @@ static const struct kobj_type xe_tile_sysfs_kobj_type = {
.sysfs_ops = &kobj_sysfs_ops,
};
static ssize_t
physical_vram_size_bytes_show(struct device *kdev, struct device_attribute *attr,
char *buf)
{
struct xe_tile *tile = kobj_to_tile(&kdev->kobj);
return sysfs_emit(buf, "%llu\n", tile->mem.vram.actual_physical_size);
}
static DEVICE_ATTR_RO(physical_vram_size_bytes);
static const struct attribute *physical_memsize_attr =
&dev_attr_physical_vram_size_bytes.attr;
static void tile_sysfs_fini(struct drm_device *drm, void *arg)
{
struct xe_tile *tile = arg;
......@@ -50,6 +64,11 @@ void xe_tile_sysfs_init(struct xe_tile *tile)
tile->sysfs = &kt->base;
if (IS_DGFX(xe) && xe->info.platform != XE_DG1 &&
sysfs_create_file(tile->sysfs, physical_memsize_attr))
drm_warn(&xe->drm,
"Sysfs creation to read addr_range per tile failed\n");
err = drmm_add_action_or_reset(&xe->drm, tile_sysfs_fini, tile);
if (err) {
drm_warn(&xe->drm, "%s: drmm_add_action_or_reset failed, err: %d\n",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment