drm/amd/amdgpu: get maximum and used UVD handles (v3)
Subsystems (3)
PATCH 1/1 drm/amd/amdgpu: get maximum and used UVD handles (v3)
From: Arindam Nath <[email protected]>
Change History
--------------
v3: changes suggested by Christian
- Add a check for UVD IP block using AMDGPU_HW_IP_UVD query type.
- Add a check for asic_type to be less than CHIP_POLARIS10 since starting Polaris, we support unlimited UVD instances.
- Add kerneldoc style comment for amdgpu_uvd_used_handles().
v2: as suggested by Christian
- Add a new query AMDGPU_INFO_NUM_HANDLES
- Create a helper function to return the number
of currently used UVD handles.
- Modify the logic to count the number of used
UVD handles since handles can be freed in
non-linear fashion.
v1:
- User might want to query the maximum number of UVD instances supported by firmware. In addition to that, if there are multiple applications using UVD handles at the same time, he might also want to query the currently used number of handles.
For this we add two variables max_handles and used_handles inside drm_amdgpu_info_hw_ip. So now an application (or libdrm) can use AMDGPU_INFO IOCTL with AMDGPU_INFO_HW_IP_INFO query type to get these values.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 21 +++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c | 25 +++++++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.h | 1 + include/uapi/drm/amdgpu_drm.h | 9 +++++++++ 4 files changed, 56 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +21 -0
@@ -570,6 +570,27 @@ static int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_filereturn -EINVAL ; } } +case AMDGPU_INFO_NUM_HANDLES : { +struct drm_amdgpu_info_num_handles handle; + +switch (info->query_hw_ip.type) { +case AMDGPU_HW_IP_UVD : +/* Starting Polaris, we support unlimited UVD handles */ +if (adev->asic_type <CHIP_POLARIS10 ) { + handle.uvd_max_handles = adev->uvd.max_handles; + handle.uvd_used_handles =amdgpu_uvd_used_handles (adev); + +return copy_to_user (out, &handle, +min ((size_t )size,sizeof (handle))) ? -EFAULT :0 ; + }else { +return -EINVAL ; + } + +break ; +default : +return -EINVAL ; + } + }default :DRM_DEBUG_KMS ("Invalid request %d\n" , info->query);return -EINVAL ;
drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c +25 -0
@@ -1173,3 +1173,28 @@ int amdgpu_uvd_ring_test_ib(struct amdgpu_ring *ring, long timeout) error:return r; } + +/** +* amdgpu_uvd_used_handles - returns used UVD handles +* +* @adev: amdgpu_device pointer +* +* Returns the number of UVD handles in use +*/ +uint32_t amdgpu_uvd_used_handles (struct amdgpu_device *adev) +{ +unsigned i; +uint32_t used_handles =0 ; + +for (i =0 ; i < adev->uvd.max_handles; ++i) { +/* +* Handles can be freed in any order, and not +* necessarily linear. So we need to count +* all non-zero handles. +*/ +if (atomic_read (&adev->uvd.handles[i])) + used_handles++; + } + +return used_handles; +}
drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.h +1 -0
@@ -38,5 +38,6 @@ int amdgpu_uvd_ring_parse_cs(struct amdgpu_cs_parser *parser, uint32_t ib_idx);void amdgpu_uvd_ring_begin_use (struct amdgpu_ring *ring);void amdgpu_uvd_ring_end_use (struct amdgpu_ring *ring);int amdgpu_uvd_ring_test_ib (struct amdgpu_ring *ring,long timeout); +uint32_t amdgpu_uvd_used_handles (struct amdgpu_device *adev);#endif
include/uapi/drm/amdgpu_drm.h +9 -0
@@ -530,6 +530,8 @@ struct drm_amdgpu_cs_chunk_data {#define AMDGPU_INFO_VBIOS_SIZE 0x1/* Subquery id: Query vbios image */ #define AMDGPU_INFO_VBIOS_IMAGE 0x2 +/* Query UVD handles */ +#define AMDGPU_INFO_NUM_HANDLES 0x1C#define AMDGPU_INFO_MMR_SE_INDEX_SHIFT 0#define AMDGPU_INFO_MMR_SE_INDEX_MASK 0xff
@@ -721,6 +723,13 @@ struct drm_amdgpu_info_hw_ip {__u32 _pad; }; +struct drm_amdgpu_info_num_handles { +/** Max handles as supported by firmware for UVD */ +__u32 uvd_max_handles; +/** Handles currently in use for UVD */ +__u32 uvd_used_handles; +}; +#define AMDGPU_VCE_CLOCK_TABLE_ENTRIES 6struct drm_amdgpu_info_vce_clock_table_entry {
Signature · 6 lines
1.9.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 1481568592-3509-1-git-send-email-arindam.nath-5C7GfCeVMHo@public.gmane.org
Quoted 56 lines · On 12 December 2016 at 18:49, <[email protected]> wrote:
From: Arindam Nath <[email protected]>
Change History
--------------v3: changes suggested by Christian
- Add a check for UVD IP block usingAMDGPU_HW_IP_UVDquery type.
- Add a check forasic_typeto be less thanCHIP_POLARIS10since starting Polaris, we support unlimited UVD instances.
- Add kerneldoc style comment foramdgpu_uvd_used_handles().v2: as suggested by Christian
- Add a new queryAMDGPU_INFO_NUM_HANDLES
- Create a helper function to return the number
of currently used UVD handles.
- Modify the logic to count the number of used
UVD handles since handles can be freed in
non-linear fashion.v1:
- User might want to query the maximum number of UVD instances supported by firmware. In addition to that, if there are multiple applications using UVD handles at the same time, he might also want to query the currently used number of handles.For this we add two variables
max_handlesandused_handlesinsidedrm_amdgpu_info_hw_ip. So now an application (or libdrm) can useAMDGPU_INFOIOCTL withAMDGPU_INFO_HW_IP_INFOquery type to get these values.Signed-off-by Arindam Nath <[email protected]>Reviewed-by Christian König <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 21 +++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c | 25 +++++++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.h | 1 + include/uapi/drm/amdgpu_drm.h | 9 +++++++++ 4 files changed, 56 insertions(+)drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +4
-0@@ -570,6 +570,27 @@ static int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_filereturn -EINVAL ; } } +case AMDGPU_INFO_NUM_HANDLES : { +struct drm_amdgpu_info_num_handles handle; + +switch (info->query_hw_ip.type) {
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c static int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file · line 586
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +10
-0+case AMDGPU_HW_IP_UVD : +/* Starting Polaris, we support unlimited UVD handles */ +if (adev->asic_type <CHIP_POLARIS10 ) { + handle.uvd_max_handles = adev->uvd.max_handles; + handle.uvd_used_handles =amdgpu_uvd_used_handles (adev); + +return copy_to_user (out, &handle, +min ((size_t )size,sizeof (handle))) ? -EFAULT :0 ; + }else { +return -EINVAL ;
Using EINVAL doesn't seem right here. As per man 3 ioctl
EINVAL The request or arg argument is not valid for this device.
A bit further down you can see the one you want.
ENODEV The fildes argument refers to a valid STREAMS device, but
the corresponding device driver does not support the ioctl() function.
Worth checking through the existing code and correcting similar thinkos ?
Thanks
Emil
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): CACvgo50-nTuLrQCHdPEV7StEphsR_s5YN+WRqPLgjnkLE=Bscw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
Quoted 81 lines
-----Original Message-----
From: Emil Velikov [mailto:[email protected]]
Sent: Wednesday, December 14, 2016 9:26 PM
To: Nath, Arindam
Cc: David Airlie; Deucher, Alexander; amd-gfx mailing list; ML dri-devel; Koenig, Christian
Subject: Re: [PATCH 1/1] drm/amd/amdgpu: get maximum and used UVD handles (v3)Quoted 35 lines · On 12 December 2016 at 18:49, <[email protected]> wrote:
From: Arindam Nath <[email protected]>
Change History
--------------v3: changes suggested by Christian
- Add a check for UVD IP block usingAMDGPU_HW_IP_UVDquery type.
- Add a check forasic_typeto be less thanCHIP_POLARIS10since starting Polaris, we support unlimited UVD instances.
- Add kerneldoc style comment foramdgpu_uvd_used_handles().v2: as suggested by Christian
- Add a new queryAMDGPU_INFO_NUM_HANDLES
- Create a helper function to return the number
of currently used UVD handles.
- Modify the logic to count the number of used
UVD handles since handles can be freed in
non-linear fashion.v1:
- User might want to query the maximum number of UVD instances supported by firmware. In addition to that, if there are multiple applications using UVD handles at the same time, he might also want to query the currently used number of handles.For this we add two variables
max_handlesandused_handlesinsidedrm_amdgpu_info_hw_ip. So now an application (or libdrm) can useAMDGPU_INFOIOCTL withAMDGPU_INFO_HW_IP_INFOquery type to get these values.Quoted 4 lines
Signed-off-by Arindam Nath <[email protected]>Reviewed-by Christian König <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 21+++++++++++++++++++++
Quoted 1 line
drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c | 25+++++++++++++++++++++++++
Review
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.h | 1 + include/uapi/drm/amdgpu_drm.h | 9 +++++++++ 4 files changed, 56 insertions(+)(quoted diff) +0
-0
b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.cdrivers/gpu/drm/amd/amdgpu/amdgpu_kms.c static int amdgpu_info_ioctl(struct drm_device
Quoted 4 lines
index 174eb59..3273d8c 100644
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +0
-0@@ -570,6 +570,27 @@ static int amdgpu_info_ioctl(struct drm_device*dev, void *data, struct
drm_filedrivers/gpu/drm/amd/amdgpu/amdgpu_kms.c static int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file
Quoted 12 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +9
-0return -EINVAL ; } } +case AMDGPU_INFO_NUM_HANDLES : { +struct drm_amdgpu_info_num_handles handle; + +switch (info->query_hw_ip.type) { +case AMDGPU_HW_IP_UVD : +/* Starting Polaris, we support unlimited UVD handles */ +if (adev->asic_type <CHIP_POLARIS10 ) { + handle.uvd_max_handles = adev->uvd.max_handles; + handle.uvd_used_handles =
amdgpu_uvd_used_handles(adev);drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c static int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file · line 586
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +5
-0+ +return copy_to_user (out, &handle, +min ((size_t )size,sizeof (handle))) ? -EFAULT :0 ; + }else { +return -EINVAL ;
Quoted 8 lines
Using EINVAL doesn't seem right here. As per man 3 ioctl
EINVAL The request or arg argument is not valid for this device.
A bit further down you can see the one you want.
ENODEV The fildes argument refers to a valid STREAMS device, but
the corresponding device driver does not support theioctl()function.
Emil, ENODEV would mean the driver does not support ioctl() itself. But in our case ioctl() is supported.
Since we extract the query type from arg passed to ioctl(), and it is this query AMDGPU_INFO_NUM_HANDLES which is not supported by driver (for > Polaris), doesn’t returning EINVAL make more sense here?
Thanks,
Arindam
Quoted 5 lines
Worth checking through the existing code and correcting similar thinkos ?
Thanks
Emil
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): CY4PR12MB1432DB75A9FD33E6C363DF979C9D0-rpdhrqHFk04JlWDAAl3wnwdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org
Quoted 85 lines · Arindam
Quoted 85 lines
-----Original Message-----
From: Emil Velikov [mailto:[email protected]]
Sent: Wednesday, December 14, 2016 9:26 PM
To: Nath, Arindam
Cc: David Airlie; Deucher, Alexander; amd-gfx mailing list; ML dri-devel; Koenig, Christian
Subject: Re: [PATCH 1/1] drm/amd/amdgpu: get maximum and used UVD handles (v3)Quoted 35 lines · On 12 December 2016 at 18:49, <[email protected]> wrote:
From: Arindam Nath <[email protected]>
Change History
--------------v3: changes suggested by Christian
- Add a check for UVD IP block usingAMDGPU_HW_IP_UVDquery type.
- Add a check forasic_typeto be less thanCHIP_POLARIS10since starting Polaris, we support unlimited UVD instances.
- Add kerneldoc style comment foramdgpu_uvd_used_handles().v2: as suggested by Christian
- Add a new queryAMDGPU_INFO_NUM_HANDLES
- Create a helper function to return the number
of currently used UVD handles.
- Modify the logic to count the number of used
UVD handles since handles can be freed in
non-linear fashion.v1:
- User might want to query the maximum number of UVD instances supported by firmware. In addition to that, if there are multiple applications using UVD handles at the same time, he might also want to query the currently used number of handles.For this we add two variables
max_handlesandused_handlesinsidedrm_amdgpu_info_hw_ip. So now an application (or libdrm) can useAMDGPU_INFOIOCTL withAMDGPU_INFO_HW_IP_INFOquery type to get these values.Quoted 4 lines
Signed-off-by Arindam Nath <[email protected]>Reviewed-by Christian König <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 21+++++++++++++++++++++
Quoted 1 line
drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c | 25+++++++++++++++++++++++++
Review
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.h | 1 + include/uapi/drm/amdgpu_drm.h | 9 +++++++++ 4 files changed, 56 insertions(+)(quoted diff) +0
-0
b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.cdrivers/gpu/drm/amd/amdgpu/amdgpu_kms.c static int amdgpu_info_ioctl(struct drm_device
Quoted 4 lines
index 174eb59..3273d8c 100644
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +0
-0@@ -570,6 +570,27 @@ static int amdgpu_info_ioctl(struct drm_device*dev, void *data, struct
drm_filedrivers/gpu/drm/amd/amdgpu/amdgpu_kms.c static int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file
Quoted 12 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +9
-0return -EINVAL ; } } +case AMDGPU_INFO_NUM_HANDLES : { +struct drm_amdgpu_info_num_handles handle; + +switch (info->query_hw_ip.type) { +case AMDGPU_HW_IP_UVD : +/* Starting Polaris, we support unlimited UVD handles */ +if (adev->asic_type <CHIP_POLARIS10 ) { + handle.uvd_max_handles = adev->uvd.max_handles; + handle.uvd_used_handles =
amdgpu_uvd_used_handles(adev);drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c static int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file · line 586
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +5
-0+ +return copy_to_user (out, &handle, +min ((size_t )size,sizeof (handle))) ? -EFAULT :0 ; + }else { +return -EINVAL ;Using EINVAL doesn't seem right here. As per man 3 ioctl
EINVAL The request or arg argument is not valid for this device.
Quoted 9 lines
Quoted 4 lines
A bit further down you can see the one you want.
ENODEV The fildes argument refers to a valid STREAMS device, but
the corresponding device driver does not support theioctl()function.Emil, ENODEV would mean the driver does not support
ioctl()itself. But in our caseioctl()is supported.Since we extract the query type from arg passed to
ioctl(), and it is this queryAMDGPU_INFO_NUM_HANDLESwhich is not supported by driver (for > Polaris), doesn’t returning EINVAL make more sense here?
Unless I'm reading the code incorrectly - CHIP_POLARIS10 and older do not have support the query. Thus ENODEV is the one you want to use. Furthermore EINVAL is (mostly) used to indicate incorrect input (failed input validation) which userspace uses to check if kernel is too old/does not support X.
If in doubt I recommend checking how other drivers are handling things. From memory at least i915 uses the above.
Thanks
Emil
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): CACvgo53wgfMfdcXFWy1FrRKUexJjm-_64gMFA5kkAwvWLJKb7w-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
Quoted 105 lines
-----Original Message-----
From: Emil Velikov [mailto:[email protected]]
Sent: Thursday, December 15, 2016 5:01 PM
To: Nath, Arindam
Cc: David Airlie; Deucher, Alexander; amd-gfx mailing list; ML dri-devel; Koenig, Christian
Subject: Re: [PATCH 1/1] drm/amd/amdgpu: get maximum and used UVD handles (v3)Quoted 83 lines · Arindam
Quoted 83 lines
-----Original Message-----
From: Emil Velikov [mailto:[email protected]]
Sent: Wednesday, December 14, 2016 9:26 PM
To: Nath, Arindam
Cc: David Airlie; Deucher, Alexander; amd-gfx mailing list; ML dri-devel; Koenig, Christian
Subject: Re: [PATCH 1/1] drm/amd/amdgpu: get maximum and used UVD handles (v3)Quoted 35 lines · On 12 December 2016 at 18:49, <[email protected]> wrote:
From: Arindam Nath <[email protected]>
Change History
--------------v3: changes suggested by Christian
- Add a check for UVD IP block usingAMDGPU_HW_IP_UVDquery type.
- Add a check forasic_typeto be less thanCHIP_POLARIS10since starting Polaris, we support unlimited UVD instances.
- Add kerneldoc style comment foramdgpu_uvd_used_handles().v2: as suggested by Christian
- Add a new queryAMDGPU_INFO_NUM_HANDLES
- Create a helper function to return the number
of currently used UVD handles.
- Modify the logic to count the number of used
UVD handles since handles can be freed in
non-linear fashion.v1:
- User might want to query the maximum number of UVD instances supported by firmware. In addition to that, if there are multiple applications using UVD handles at the same time, he might also want to query the currently used number of handles.For this we add two variables
max_handlesandused_handlesinsidedrm_amdgpu_info_hw_ip. So now an application (or libdrm) can useAMDGPU_INFOIOCTL withAMDGPU_INFO_HW_IP_INFOquery type to get these values.Quoted 4 lines
Signed-off-by Arindam Nath <[email protected]>Reviewed-by Christian König <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 21+++++++++++++++++++++
Quoted 1 line
drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c | 25+++++++++++++++++++++++++
Review
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.h | 1 + include/uapi/drm/amdgpu_drm.h | 9 +++++++++ 4 files changed, 56 insertions(+)(quoted diff) +0
-0
b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.cdrivers/gpu/drm/amd/amdgpu/amdgpu_kms.c static int amdgpu_info_ioctl(struct drm_device
Quoted 4 lines
index 174eb59..3273d8c 100644
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +0
-0@@ -570,6 +570,27 @@ static int amdgpu_info_ioctl(struct drm_device*dev, void *data, struct
drm_filedrivers/gpu/drm/amd/amdgpu/amdgpu_kms.c static int amdgpu_info_ioctl(struct drm_device · line 581
Quoted 12 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +9
-0return -EINVAL ; } } +case AMDGPU_INFO_NUM_HANDLES : { +struct drm_amdgpu_info_num_handles handle; + +switch (info->query_hw_ip.type) { +case AMDGPU_HW_IP_UVD : +/* Starting Polaris, we support unlimited UVD handles */ +if (adev->asic_type <CHIP_POLARIS10 ) { + handle.uvd_max_handles = adev->uvd.max_handles; + handle.uvd_used_handles =
amdgpu_uvd_used_handles(adev);drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c static int amdgpu_info_ioctl(struct drm_device · line 586
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +5
-0+ +return copy_to_user (out, &handle, +min ((size_t )size,sizeof (handle))) ? -EFAULT :0 ; + }else { +return -EINVAL ;Using EINVAL doesn't seem right here. As per man 3 ioctl
Quoted 8 lines
Quoted 6 lines
EINVAL The request or arg argument is not valid for this device.
A bit further down you can see the one you want.
ENODEV The fildes argument refers to a valid STREAMS device, but
the corresponding device driver does not support theioctl()function.Emil, ENODEV would mean the driver does not support
ioctl()itself. But inour case
ioctl()is supported.Quoted 2 lines
Since we extract the query type from arg passed to
ioctl(), and it is this
Quoted 8 lines
query
AMDGPU_INFO_NUM_HANDLESwhich is not supported by driver (forQuoted 2 lines
Polaris), doesn’t returning EINVAL make more sense here?
Unless I'm reading the code incorrectly -
CHIP_POLARIS10and older do not have support the query. Thus ENODEV is the one you want to use. Furthermore EINVAL is (mostly) used to indicate incorrect input (failed input validation) which userspace uses to check if kernel is too old/does not support X.
Actually, the code says only asics older than CHIP_POLARIS10 support the query, beyond it doesn’t.
Quoted 3 lines
If in doubt I recommend checking how other drivers are handling things. From memory at least i915 uses the above.
I will check how other drivers handle this.
Thanks,
Arindam
Quoted 3 lines
Thanks
Emil
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): CY4PR12MB143243FF0D2E5422635A52659C9D0-rpdhrqHFk04JlWDAAl3wnwdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org
Quoted 108 lines · Arindam
Quoted 108 lines
-----Original Message-----
From: Emil Velikov [mailto:[email protected]]
Sent: Thursday, December 15, 2016 5:01 PM
To: Nath, Arindam
Cc: David Airlie; Deucher, Alexander; amd-gfx mailing list; ML dri-devel; Koenig, Christian
Subject: Re: [PATCH 1/1] drm/amd/amdgpu: get maximum and used UVD handles (v3)Quoted 83 lines · Arindam
Quoted 83 lines
-----Original Message-----
From: Emil Velikov [mailto:[email protected]]
Sent: Wednesday, December 14, 2016 9:26 PM
To: Nath, Arindam
Cc: David Airlie; Deucher, Alexander; amd-gfx mailing list; ML dri-devel; Koenig, Christian
Subject: Re: [PATCH 1/1] drm/amd/amdgpu: get maximum and used UVD handles (v3)Quoted 35 lines · On 12 December 2016 at 18:49, <[email protected]> wrote:
From: Arindam Nath <[email protected]>
Change History
--------------v3: changes suggested by Christian
- Add a check for UVD IP block usingAMDGPU_HW_IP_UVDquery type.
- Add a check forasic_typeto be less thanCHIP_POLARIS10since starting Polaris, we support unlimited UVD instances.
- Add kerneldoc style comment foramdgpu_uvd_used_handles().v2: as suggested by Christian
- Add a new queryAMDGPU_INFO_NUM_HANDLES
- Create a helper function to return the number
of currently used UVD handles.
- Modify the logic to count the number of used
UVD handles since handles can be freed in
non-linear fashion.v1:
- User might want to query the maximum number of UVD instances supported by firmware. In addition to that, if there are multiple applications using UVD handles at the same time, he might also want to query the currently used number of handles.For this we add two variables
max_handlesandused_handlesinsidedrm_amdgpu_info_hw_ip. So now an application (or libdrm) can useAMDGPU_INFOIOCTL withAMDGPU_INFO_HW_IP_INFOquery type to get these values.Quoted 4 lines
Signed-off-by Arindam Nath <[email protected]>Reviewed-by Christian König <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 21+++++++++++++++++++++
Quoted 1 line
drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c | 25+++++++++++++++++++++++++
Review
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.h | 1 + include/uapi/drm/amdgpu_drm.h | 9 +++++++++ 4 files changed, 56 insertions(+)(quoted diff) +0
-0
b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.cdrivers/gpu/drm/amd/amdgpu/amdgpu_kms.c static int amdgpu_info_ioctl(struct drm_device
Quoted 4 lines
index 174eb59..3273d8c 100644
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +0
-0@@ -570,6 +570,27 @@ static int amdgpu_info_ioctl(struct drm_device*dev, void *data, struct
drm_filedrivers/gpu/drm/amd/amdgpu/amdgpu_kms.c static int amdgpu_info_ioctl(struct drm_device · line 581
Quoted 12 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +9
-0return -EINVAL ; } } +case AMDGPU_INFO_NUM_HANDLES : { +struct drm_amdgpu_info_num_handles handle; + +switch (info->query_hw_ip.type) { +case AMDGPU_HW_IP_UVD : +/* Starting Polaris, we support unlimited UVD handles */ +if (adev->asic_type <CHIP_POLARIS10 ) { + handle.uvd_max_handles = adev->uvd.max_handles; + handle.uvd_used_handles =
amdgpu_uvd_used_handles(adev);drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c static int amdgpu_info_ioctl(struct drm_device · line 586
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +5
-0+ +return copy_to_user (out, &handle, +min ((size_t )size,sizeof (handle))) ? -EFAULT :0 ; + }else { +return -EINVAL ;Using EINVAL doesn't seem right here. As per man 3 ioctl
Quoted 8 lines
Quoted 6 lines
EINVAL The request or arg argument is not valid for this device.
A bit further down you can see the one you want.
ENODEV The fildes argument refers to a valid STREAMS device, but
the corresponding device driver does not support theioctl()function.Emil, ENODEV would mean the driver does not support
ioctl()itself. But inour case
ioctl()is supported.Quoted 2 lines
Since we extract the query type from arg passed to
ioctl(), and it is thisquery
AMDGPU_INFO_NUM_HANDLESwhich is not supported by driver (forQuoted 2 lines
Polaris), doesn’t returning EINVAL make more sense here?
Quoted 7 lines
Quoted 5 lines
Unless I'm reading the code incorrectly -
CHIP_POLARIS10and older do not have support the query. Thus ENODEV is the one you want to use. Furthermore EINVAL is (mostly) used to indicate incorrect input (failed input validation) which userspace uses to check if kernel is too old/does not support X.Actually, the code says only asics older than
CHIP_POLARIS10support the query, beyond it doesn’t.
Wouldn't it be cleaner to return INT_MAX or something like that? Right now the interface is inconsistent, it's failing the same way as if userspace passed something invalid, while (IMHO) it should just say "unlimited".
Gražvydas
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): CANOLnOOG5xsMXy7V++LR5QOSpvjVjTyYEB=DDJ60xBMTagOcPg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
Quoted 127 lines
-----Original Message-----
From: Grazvydas Ignotas [mailto:[email protected]]
Sent: Thursday, December 15, 2016 5:52 PM
To: Nath, Arindam
Cc: Emil Velikov; David Airlie; Deucher, Alexander; ML dri-devel; amd-gfx mailing list; Koenig, Christian
Subject: Re: [PATCH 1/1] drm/amd/amdgpu: get maximum and used UVD handles (v3)Quoted 11 lines · Arindam
Quoted 11 lines
-----Original Message-----
From: Emil Velikov [mailto:[email protected]]
Sent: Thursday, December 15, 2016 5:01 PM
To: Nath, Arindam
Cc: David Airlie; Deucher, Alexander; amd-gfx mailing list; ML dri-devel; Koenig, Christian
Subject: Re: [PATCH 1/1] drm/amd/amdgpu: get maximum and used UVD handles (v3)On 15 December 2016 at 07:30, Nath, Arindam <[email protected]> wrote:
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
-----Original Message-----
From: Emil Velikov [mailto:[email protected]]
Sent: Wednesday, December 14, 2016 9:26 PM
To: Nath, Arindam
Cc: David Airlie; Deucher, Alexander; amd-gfx mailing list; ML dri-devel; Koenig, Christian
Subject: Re: [PATCH 1/1] drm/amd/amdgpu: get maximum and usedUVD
Quoted 80 lines
Quoted 80 lines
Quoted 80 lines
Quoted 80 lines
handles (v3)
Quoted 35 lines · On 12 December 2016 at 18:49, <[email protected]> wrote:
From: Arindam Nath <[email protected]>
Change History
--------------v3: changes suggested by Christian
- Add a check for UVD IP block usingAMDGPU_HW_IP_UVDquery type.
- Add a check forasic_typeto be less thanCHIP_POLARIS10since starting Polaris, we support unlimited UVD instances.
- Add kerneldoc style comment foramdgpu_uvd_used_handles().v2: as suggested by Christian
- Add a new queryAMDGPU_INFO_NUM_HANDLES
- Create a helper function to return the number
of currently used UVD handles.
- Modify the logic to count the number of used
UVD handles since handles can be freed in
non-linear fashion.v1:
- User might want to query the maximum number of UVD instances supported by firmware. In addition to that, if there are multiple applications using UVD handles at the same time, he might also want to query the currently used number of handles.For this we add two variables
max_handlesandused_handlesinsidedrm_amdgpu_info_hw_ip. So now an application (or libdrm) can useAMDGPU_INFOIOCTL withAMDGPU_INFO_HW_IP_INFOquery type to get these values.Quoted 4 lines
Signed-off-by Arindam Nath <[email protected]>Reviewed-by Christian König <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 21+++++++++++++++++++++
Quoted 1 line
drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c | 25+++++++++++++++++++++++++
Review
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.h | 1 + include/uapi/drm/amdgpu_drm.h | 9 +++++++++ 4 files changed, 56 insertions(+)(quoted diff) +0
-0
b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.cdrivers/gpu/drm/amd/amdgpu/amdgpu_kms.c static int amdgpu_info_ioctl(struct drm_device
Quoted 4 lines
index 174eb59..3273d8c 100644
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +0
-0@@ -570,6 +570,27 @@ static int amdgpu_info_ioctl(struct drm_device*dev, void *data, struct
drm_filedrivers/gpu/drm/amd/amdgpu/amdgpu_kms.c static int amdgpu_info_ioctl(struct drm_device · line 581
Quoted 12 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +9
-0return -EINVAL ; } } +case AMDGPU_INFO_NUM_HANDLES : { +struct drm_amdgpu_info_num_handles handle; + +switch (info->query_hw_ip.type) { +case AMDGPU_HW_IP_UVD : +/* Starting Polaris, we support unlimited UVD handles */ +if (adev->asic_type <CHIP_POLARIS10 ) { + handle.uvd_max_handles = adev->uvd.max_handles; + handle.uvd_used_handles =
amdgpu_uvd_used_handles(adev);drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c static int amdgpu_info_ioctl(struct drm_device · line 586
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +5
-0+ +return copy_to_user (out, &handle, +min ((size_t )size,sizeof (handle))) ? -EFAULT :0 ; + }else { +return -EINVAL ;Using EINVAL doesn't seem right here. As per man 3 ioctl
EINVAL The request or arg argument is not valid for this device.
A bit further down you can see the one you want.
Quoted 8 lines
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
ENODEV The fildes argument refers to a valid STREAMS device, but
the corresponding device driver does not support theioctl()function.Emil, ENODEV would mean the driver does not support
ioctl()itself. But inour case
ioctl()is supported.Quoted 2 lines
Since we extract the query type from arg passed to
ioctl(), and it is thisquery
AMDGPU_INFO_NUM_HANDLESwhich is not supported by driver(for
Quoted 8 lines
Quoted 7 lines
Quoted 2 lines
Polaris), doesn’t returning EINVAL make more sense here?
Unless I'm reading the code incorrectly -
CHIP_POLARIS10and older do not have support the query. Thus ENODEV is the one you want to use. Furthermore EINVAL is (mostly) used to indicate incorrect input (failed input validation) which userspace uses to check if kernel is too old/does not support X.
Quoted 7 lines
Quoted 1 line
Actually, the code says only asics older than
CHIP_POLARIS10support thequery, beyond it doesn’t.
Wouldn't it be cleaner to return
INT_MAXor something like that? Right now the interface is inconsistent, it's failing the same way as if userspace passed something invalid, while (IMHO) it should just say "unlimited".
We need to return an error no. consistent with what ioctl() expects to return. This will enable userspace to take corrective action (or no action at all) depending on the error code.
Thanks,
Arindam
Quoted 2 lines
Gražvydas
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): CY4PR12MB143264E7BBC2F015F08D355D9C9D0-rpdhrqHFk04JlWDAAl3wnwdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org
Am 15.12.2016 um 13:33 schrieb Nath, Arindam:
Quoted 124 lines
Quoted 124 lines
-----Original Message-----
From: Grazvydas Ignotas [mailto:[email protected]]
Sent: Thursday, December 15, 2016 5:52 PM
To: Nath, Arindam
Cc: Emil Velikov; David Airlie; Deucher, Alexander; ML dri-devel; amd-gfx mailing list; Koenig, Christian
Subject: Re: [PATCH 1/1] drm/amd/amdgpu: get maximum and used UVD handles (v3)Quoted 11 lines · Arindam
Quoted 11 lines
-----Original Message-----
From: Emil Velikov [mailto:[email protected]]
Sent: Thursday, December 15, 2016 5:01 PM
To: Nath, Arindam
Cc: David Airlie; Deucher, Alexander; amd-gfx mailing list; ML dri-devel; Koenig, Christian
Subject: Re: [PATCH 1/1] drm/amd/amdgpu: get maximum and used UVD handles (v3)On 15 December 2016 at 07:30, Nath, Arindam <[email protected]> wrote:
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
-----Original Message-----
From: Emil Velikov [mailto:[email protected]]
Sent: Wednesday, December 14, 2016 9:26 PM
To: Nath, Arindam
Cc: David Airlie; Deucher, Alexander; amd-gfx mailing list; ML dri-devel; Koenig, Christian
Subject: Re: [PATCH 1/1] drm/amd/amdgpu: get maximum and usedUVD
Quoted 78 lines
Quoted 78 lines
Quoted 78 lines
Quoted 78 lines
handles (v3)
Quoted 35 lines · On 12 December 2016 at 18:49, <[email protected]> wrote:
From: Arindam Nath <[email protected]>
Change History
--------------v3: changes suggested by Christian
- Add a check for UVD IP block usingAMDGPU_HW_IP_UVDquery type.
- Add a check forasic_typeto be less thanCHIP_POLARIS10since starting Polaris, we support unlimited UVD instances.
- Add kerneldoc style comment foramdgpu_uvd_used_handles().v2: as suggested by Christian
- Add a new queryAMDGPU_INFO_NUM_HANDLES
- Create a helper function to return the number
of currently used UVD handles.
- Modify the logic to count the number of used
UVD handles since handles can be freed in
non-linear fashion.v1:
- User might want to query the maximum number of UVD instances supported by firmware. In addition to that, if there are multiple applications using UVD handles at the same time, he might also want to query the currently used number of handles.For this we add two variables
max_handlesandused_handlesinsidedrm_amdgpu_info_hw_ip. So now an application (or libdrm) can useAMDGPU_INFOIOCTL withAMDGPU_INFO_HW_IP_INFOquery type to get these values.Quoted 4 lines
Signed-off-by Arindam Nath <[email protected]>Reviewed-by Christian König <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 21+++++++++++++++++++++
Quoted 1 line
drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c | 25+++++++++++++++++++++++++
Review
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.h | 1 + include/uapi/drm/amdgpu_drm.h | 9 +++++++++ 4 files changed, 56 insertions(+)(quoted diff) +0
-0
b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.cdrivers/gpu/drm/amd/amdgpu/amdgpu_kms.c static int amdgpu_info_ioctl(struct drm_device
Quoted 4 lines
index 174eb59..3273d8c 100644
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +0
-0@@ -570,6 +570,27 @@ static int amdgpu_info_ioctl(struct drm_device*dev, void *data, struct
drm_filedrivers/gpu/drm/amd/amdgpu/amdgpu_kms.c static int amdgpu_info_ioctl(struct drm_device · line 581
Quoted 12 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +9
-0return -EINVAL ; } } +case AMDGPU_INFO_NUM_HANDLES : { +struct drm_amdgpu_info_num_handles handle; + +switch (info->query_hw_ip.type) { +case AMDGPU_HW_IP_UVD : +/* Starting Polaris, we support unlimited UVD handles */ +if (adev->asic_type <CHIP_POLARIS10 ) { + handle.uvd_max_handles = adev->uvd.max_handles; + handle.uvd_used_handles =
amdgpu_uvd_used_handles(adev);drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c static int amdgpu_info_ioctl(struct drm_device · line 586
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +5
-0+ +return copy_to_user (out, &handle, +min ((size_t )size,sizeof (handle))) ? -EFAULT :0 ; + }else { +return -EINVAL ;Using EINVAL doesn't seem right here. As per man 3 ioctl
EINVAL The request or arg argument is not valid for this device.
Quoted 8 lines
Quoted 8 lines
Quoted 5 lines
Quoted 4 lines
A bit further down you can see the one you want.
ENODEV The fildes argument refers to a valid STREAMS device, but
the corresponding device driver does not support theioctl()function.Emil, ENODEV would mean the driver does not support
ioctl()itself. But inour case
ioctl()is supported.Quoted 1 line
Since we extract the query type from arg passed to
ioctl(), and it is thisquery
AMDGPU_INFO_NUM_HANDLESwhich is not supported by driver(for
Quoted 7 lines
Quoted 7 lines
Quoted 2 lines
Polaris), doesn’t returning EINVAL make more sense here?
Unless I'm reading the code incorrectly -
CHIP_POLARIS10and older do not have support the query. Thus ENODEV is the one you want to use. Furthermore EINVAL is (mostly) used to indicate incorrect input (failed input validation) which userspace uses to check if kernel is too old/does not support X.
Quoted 8 lines
Quoted 7 lines
Quoted 1 line
Actually, the code says only asics older than
CHIP_POLARIS10support thequery, beyond it doesn’t.
Wouldn't it be cleaner to return
INT_MAXor something like that? Right now the interface is inconsistent, it's failing the same way as if userspace passed something invalid, while (IMHO) it should just say "unlimited".We need to return an error no. consistent with what
ioctl()expects to return. This will enable userspace to take corrective action (or no action at all) depending on the error code.
Well, we could return INT_MAX for the maximum numbers of handles to note that there is not limit, but I also prefer returning an error code to note that this won't work as expected.
Regarding which error code to return I think that Emil has the right idea here.
Returning -EINVAL usually means that userspace provided an invalid value, but in this case it doesn't matter which value the UMD provide all of them would be invalid because starting with Polaris the hardware/firmware simply doesn't work this way any more.
So using -ENODEV or maybe -ENODATA indeed sound like the right think to do here.
Regards,
Christian.
Quoted 8 lines
Thanks,
ArindamQuoted 1 line
Gražvydas
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): a72e3677-2482-6c6f-2978-ded71a482995-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org
Quoted 11 lines · Christian König
Regarding which error code to return I think that Emil has the right idea here.
Returning
-EINVALusually means that userspace provided an invalid value, but in this case it doesn't matter which value the UMD provide all of them would be invalid because starting with Polaris the hardware/firmware simply doesn't work this way any more.So using
-ENODEVor maybe-ENODATAindeed sound like the right think to do here.
What about ERANGE then, "Math result not representable" aka infinity? To me ENODEV is more like "the GPU you are asking about is not there" and ENODATA "information you ask for is not known", although the later still somewhat makes sense.
Gražvydas
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): CANOLnOMr=gMWiU624dRkY8Nr7XdyzCNbknPhkuShLCrVQEjqUg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
Am 15.12.2016 um 23:43 schrieb Grazvydas Ignotas:
Quoted 10 lines
Quoted 8 lines · Christian König
Regarding which error code to return I think that Emil has the right idea here.
Returning
-EINVALusually means that userspace provided an invalid value, but in this case it doesn't matter which value the UMD provide all of them would be invalid because starting with Polaris the hardware/firmware simply doesn't work this way any more.
Quoted 6 lines
Quoted 2 lines
So using
-ENODEVor maybe-ENODATAindeed sound like the right think to do here.What about ERANGE then, "Math result not representable" aka infinity? To me ENODEV is more like "the GPU you are asking about is not there" and ENODATA "information you ask for is not known", although the later still somewhat makes sense.
Sorry for the delayed reply.
I think EDATA would still make more sense than ERANGE, because the number of open sessions is simply not known any more.
That the maximum number of sessions is now unlimited is just a side effect of the new handling if you ask me.
Regards,
Christian.
Quoted 2 lines
Gražvydas
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx