]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
drm/amdgpu: Add sysfs interface for vpe reset mask
authorJesse.zhang@amd.com <Jesse.zhang@amd.com>
Tue, 29 Oct 2024 06:33:05 +0000 (14:33 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Fri, 8 Nov 2024 16:45:29 +0000 (11:45 -0500)
Add the sysfs interface for vpe:
    vpe_reset_mask

The interface is read-only and show the resets supported by the IP.
For example, full adapter reset (mode1/mode2/BACO/etc),
soft reset, queue reset, and pipe reset.

V2: the sysfs node returns a text string instead of some flags (Christian)
v3: add a generic helper which takes the ring as parameter
    and print the strings in the order they are applied (Christian)

    check amdgpu_gpu_recovery  before creating sysfs file itself,
    and initialize supported_reset_types in IP version files (Lijo)

Signed-off-by: Jesse Zhang <Jesse.Zhang@amd.com>
Suggested-by: Alex Deucher <alexander.deucher@amd.com>
Reviewed-by: Tim Huang <tim.huang@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_vpe.c
drivers/gpu/drm/amd/amdgpu/amdgpu_vpe.h

index 46713a158d9039ef0358d87ecc6d2ccfd8169b90..3e6f9dfb61bb31f7d39756257eb78cb5af08884c 100644 (file)
@@ -377,6 +377,13 @@ static int vpe_sw_init(struct amdgpu_ip_block *ip_block)
        ret = vpe_init_microcode(vpe);
        if (ret)
                goto out;
+
+       /* TODO: Add queue reset mask when FW fully supports it */
+       adev->vpe.supported_reset =
+                amdgpu_get_soft_full_reset_mask(&adev->vpe.ring);
+       ret = amdgpu_vpe_sysfs_reset_mask_init(adev);
+       if (ret)
+               goto out;
 out:
        return ret;
 }
@@ -389,6 +396,7 @@ static int vpe_sw_fini(struct amdgpu_ip_block *ip_block)
        release_firmware(vpe->fw);
        vpe->fw = NULL;
 
+       amdgpu_vpe_sysfs_reset_mask_fini(adev);
        vpe_ring_fini(vpe);
 
        amdgpu_bo_free_kernel(&adev->vpe.cmdbuf_obj,
@@ -865,6 +873,41 @@ static void vpe_ring_end_use(struct amdgpu_ring *ring)
        schedule_delayed_work(&adev->vpe.idle_work, VPE_IDLE_TIMEOUT);
 }
 
+static ssize_t amdgpu_get_vpe_reset_mask(struct device *dev,
+                                               struct device_attribute *attr,
+                                               char *buf)
+{
+       struct drm_device *ddev = dev_get_drvdata(dev);
+       struct amdgpu_device *adev = drm_to_adev(ddev);
+
+       if (!adev)
+               return -ENODEV;
+
+       return amdgpu_show_reset_mask(buf, adev->vpe.supported_reset);
+}
+
+static DEVICE_ATTR(vpe_reset_mask, 0444,
+                  amdgpu_get_vpe_reset_mask, NULL);
+
+int amdgpu_vpe_sysfs_reset_mask_init(struct amdgpu_device *adev)
+{
+       int r = 0;
+
+       if (adev->vpe.num_instances) {
+               r = device_create_file(adev->dev, &dev_attr_vpe_reset_mask);
+               if (r)
+                       return r;
+       }
+
+       return r;
+}
+
+void amdgpu_vpe_sysfs_reset_mask_fini(struct amdgpu_device *adev)
+{
+       if (adev->vpe.num_instances)
+               device_remove_file(adev->dev, &dev_attr_vpe_reset_mask);
+}
+
 static const struct amdgpu_ring_funcs vpe_ring_funcs = {
        .type = AMDGPU_RING_TYPE_VPE,
        .align_mask = 0xf,
index 231d86d0953e9105196b1cf56596072fba0b2b6d..695da740a97ea59964074f03714360467ba0ce87 100644 (file)
@@ -79,6 +79,7 @@ struct amdgpu_vpe {
 
        uint32_t                        num_instances;
        bool                            collaborate_mode;
+       uint32_t                        supported_reset;
 };
 
 int amdgpu_vpe_psp_update_sram(struct amdgpu_device *adev);
@@ -86,6 +87,8 @@ int amdgpu_vpe_init_microcode(struct amdgpu_vpe *vpe);
 int amdgpu_vpe_ring_init(struct amdgpu_vpe *vpe);
 int amdgpu_vpe_ring_fini(struct amdgpu_vpe *vpe);
 int amdgpu_vpe_configure_dpm(struct amdgpu_vpe *vpe);
+void amdgpu_vpe_sysfs_reset_mask_fini(struct amdgpu_device *adev);
+int amdgpu_vpe_sysfs_reset_mask_init(struct amdgpu_device *adev);
 
 #define vpe_ring_init(vpe) ((vpe)->funcs->ring_init ? (vpe)->funcs->ring_init((vpe)) : 0)
 #define vpe_ring_start(vpe) ((vpe)->funcs->ring_start ? (vpe)->funcs->ring_start((vpe)) : 0)