Re: [PATCH v4] drm/amdgpu/vg20:support new UVD FW version naming convention

2018-06-14 Thread James Zhu



On 2018-06-13 04:45 PM, Alex Deucher wrote:

On Tue, Jun 12, 2018 at 11:46 AM, James Zhu  wrote:

Vega20 UVD Firmware has a new version naming convention:
   [31, 30] for encode interface major
   [29, 24] for encode interface minor
   [15, 8] for decode interface minor
   [7, 0] for hardware family id

Signed-off-by: James Zhu 

This patch breaks adev->uvd.fw_version which is used elsewhere and
causes build warnings. E.g.,

 if (adev->asic_type >= CHIP_VEGA20 || (version_major > 0x01) ||
 ((version_major == 0x01) && (version_minor >= 0x50)))
 adev->uvd.max_handles = AMDGPU_MAX_UVD_HANDLES;

 adev->uvd.fw_version = ((version_major << 24) | (version_minor << 16) |
 (family_id << 8));

version_major and version_minor are undefined in some cases.

Alex
My email filter has wrong setting, Missed to capture this email in time. 
Thanks for correct with a new patch. James

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c | 21 -
  1 file changed, 16 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c
index bcf68f8..630e273 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c
@@ -208,10 +208,21 @@ int amdgpu_uvd_sw_init(struct amdgpu_device *adev)

 hdr = (const struct common_firmware_header *)adev->uvd.fw->data;
 family_id = le32_to_cpu(hdr->ucode_version) & 0xff;
-   version_major = (le32_to_cpu(hdr->ucode_version) >> 24) & 0xff;
-   version_minor = (le32_to_cpu(hdr->ucode_version) >> 8) & 0xff;
-   DRM_INFO("Found UVD firmware Version: %hu.%hu Family ID: %hu\n",
-   version_major, version_minor, family_id);
+
+   if (adev->asic_type < CHIP_VEGA20) {
+   version_major = (le32_to_cpu(hdr->ucode_version) >> 24) & 0xff;
+   version_minor = (le32_to_cpu(hdr->ucode_version) >> 8) & 0xff;
+   DRM_INFO("Found UVD firmware Version: %hu.%hu Family ID: %hu\n",
+   version_major, version_minor, family_id);
+   } else {
+   unsigned int enc_major, enc_minor, dec_minor;
+
+   dec_minor = (le32_to_cpu(hdr->ucode_version) >> 8) & 0xff;
+   enc_minor = (le32_to_cpu(hdr->ucode_version) >> 24) & 0x3f;
+   enc_major = (le32_to_cpu(hdr->ucode_version) >> 30) & 0x3;
+   DRM_INFO("Found UVD firmware ENC: %hu.%hu DEC: .%hu Family ID: 
%hu\n",
+   enc_major, enc_minor, dec_minor, family_id);
+   }

 /*
  * Limit the number of UVD handles depending on microcode major
@@ -219,7 +230,7 @@ int amdgpu_uvd_sw_init(struct amdgpu_device *adev)
  * instances support is 1.80. So all subsequent versions should
  * also have the same support.
  */
-   if ((version_major > 0x01) ||
+   if (adev->asic_type >= CHIP_VEGA20 || (version_major > 0x01) ||
 ((version_major == 0x01) && (version_minor >= 0x50)))
 adev->uvd.max_handles = AMDGPU_MAX_UVD_HANDLES;

--
2.7.4

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx


___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx


Re: [PATCH v4] drm/amdgpu/vg20:support new UVD FW version naming convention

2018-06-14 Thread Michel Dänzer

Hi James,


On 2018-06-12 05:46 PM, James Zhu wrote:
> Vega20 UVD Firmware has a new version naming convention:
>   [31, 30] for encode interface major
>   [29, 24] for encode interface minor
>   [15, 8] for decode interface minor
>   [7, 0] for hardware family id
> 
> Signed-off-by: James Zhu 

This patch introduced the compiler warnings below.

Assuming adev->uvd.fw_version isn't used for anything with Vega20 and
newer, the best solution might be to move the version_{major,minor}
locals and all code using them into the (adev->asic_type < CHIP_VEGA20)
block created by this patch.


drivers/gpu/drm//amd/amdgpu/amdgpu_uvd.c: In function ‘amdgpu_uvd_sw_init’:
drivers/gpu/drm//amd/amdgpu/amdgpu_uvd.c:237:65: warning: ‘version_minor’ may 
be used uninitialized in this function [-Wmaybe-uninitialized]
  adev->uvd.fw_version = ((version_major << 24) | (version_minor << 16) |
  ~~~^~
drivers/gpu/drm//amd/amdgpu/amdgpu_uvd.c:234:22: warning: ‘version_major’ may 
be used uninitialized in this function [-Wmaybe-uninitialized]
  ((version_major == 0x01) && (version_minor >= 0x50)))
   ~~~^~~~



-- 
Earthling Michel Dänzer   |   http://www.amd.com
Libre software enthusiast | Mesa and X developer
___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx


Re: [PATCH v4] drm/amdgpu/vg20:support new UVD FW version naming convention

2018-06-13 Thread Alex Deucher
On Tue, Jun 12, 2018 at 11:46 AM, James Zhu  wrote:
> Vega20 UVD Firmware has a new version naming convention:
>   [31, 30] for encode interface major
>   [29, 24] for encode interface minor
>   [15, 8] for decode interface minor
>   [7, 0] for hardware family id
>
> Signed-off-by: James Zhu 

This patch breaks adev->uvd.fw_version which is used elsewhere and
causes build warnings. E.g.,

if (adev->asic_type >= CHIP_VEGA20 || (version_major > 0x01) ||
((version_major == 0x01) && (version_minor >= 0x50)))
adev->uvd.max_handles = AMDGPU_MAX_UVD_HANDLES;

adev->uvd.fw_version = ((version_major << 24) | (version_minor << 16) |
(family_id << 8));

version_major and version_minor are undefined in some cases.

Alex


> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c | 21 -
>  1 file changed, 16 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c 
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c
> index bcf68f8..630e273 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c
> @@ -208,10 +208,21 @@ int amdgpu_uvd_sw_init(struct amdgpu_device *adev)
>
> hdr = (const struct common_firmware_header *)adev->uvd.fw->data;
> family_id = le32_to_cpu(hdr->ucode_version) & 0xff;
> -   version_major = (le32_to_cpu(hdr->ucode_version) >> 24) & 0xff;
> -   version_minor = (le32_to_cpu(hdr->ucode_version) >> 8) & 0xff;
> -   DRM_INFO("Found UVD firmware Version: %hu.%hu Family ID: %hu\n",
> -   version_major, version_minor, family_id);
> +
> +   if (adev->asic_type < CHIP_VEGA20) {
> +   version_major = (le32_to_cpu(hdr->ucode_version) >> 24) & 
> 0xff;
> +   version_minor = (le32_to_cpu(hdr->ucode_version) >> 8) & 0xff;
> +   DRM_INFO("Found UVD firmware Version: %hu.%hu Family ID: 
> %hu\n",
> +   version_major, version_minor, family_id);
> +   } else {
> +   unsigned int enc_major, enc_minor, dec_minor;
> +
> +   dec_minor = (le32_to_cpu(hdr->ucode_version) >> 8) & 0xff;
> +   enc_minor = (le32_to_cpu(hdr->ucode_version) >> 24) & 0x3f;
> +   enc_major = (le32_to_cpu(hdr->ucode_version) >> 30) & 0x3;
> +   DRM_INFO("Found UVD firmware ENC: %hu.%hu DEC: .%hu Family 
> ID: %hu\n",
> +   enc_major, enc_minor, dec_minor, family_id);
> +   }
>
> /*
>  * Limit the number of UVD handles depending on microcode major
> @@ -219,7 +230,7 @@ int amdgpu_uvd_sw_init(struct amdgpu_device *adev)
>  * instances support is 1.80. So all subsequent versions should
>  * also have the same support.
>  */
> -   if ((version_major > 0x01) ||
> +   if (adev->asic_type >= CHIP_VEGA20 || (version_major > 0x01) ||
> ((version_major == 0x01) && (version_minor >= 0x50)))
> adev->uvd.max_handles = AMDGPU_MAX_UVD_HANDLES;
>
> --
> 2.7.4
>
> ___
> amd-gfx mailing list
> amd-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/amd-gfx
___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx


Re: [PATCH v4] drm/amdgpu/vg20:support new UVD FW version naming convention

2018-06-12 Thread Leo Liu



On 06/12/2018 11:46 AM, James Zhu wrote:

Vega20 UVD Firmware has a new version naming convention:
   [31, 30] for encode interface major
   [29, 24] for encode interface minor
   [15, 8] for decode interface minor
   [7, 0] for hardware family id

Signed-off-by: James Zhu 


Reviewed-by: Leo Liu 

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c | 21 -
  1 file changed, 16 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c
index bcf68f8..630e273 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c
@@ -208,10 +208,21 @@ int amdgpu_uvd_sw_init(struct amdgpu_device *adev)
  
  	hdr = (const struct common_firmware_header *)adev->uvd.fw->data;

family_id = le32_to_cpu(hdr->ucode_version) & 0xff;
-   version_major = (le32_to_cpu(hdr->ucode_version) >> 24) & 0xff;
-   version_minor = (le32_to_cpu(hdr->ucode_version) >> 8) & 0xff;
-   DRM_INFO("Found UVD firmware Version: %hu.%hu Family ID: %hu\n",
-   version_major, version_minor, family_id);
+
+   if (adev->asic_type < CHIP_VEGA20) {
+   version_major = (le32_to_cpu(hdr->ucode_version) >> 24) & 0xff;
+   version_minor = (le32_to_cpu(hdr->ucode_version) >> 8) & 0xff;
+   DRM_INFO("Found UVD firmware Version: %hu.%hu Family ID: %hu\n",
+   version_major, version_minor, family_id);
+   } else {
+   unsigned int enc_major, enc_minor, dec_minor;
+
+   dec_minor = (le32_to_cpu(hdr->ucode_version) >> 8) & 0xff;
+   enc_minor = (le32_to_cpu(hdr->ucode_version) >> 24) & 0x3f;
+   enc_major = (le32_to_cpu(hdr->ucode_version) >> 30) & 0x3;
+   DRM_INFO("Found UVD firmware ENC: %hu.%hu DEC: .%hu Family ID: 
%hu\n",
+   enc_major, enc_minor, dec_minor, family_id);
+   }
  
  	/*

 * Limit the number of UVD handles depending on microcode major
@@ -219,7 +230,7 @@ int amdgpu_uvd_sw_init(struct amdgpu_device *adev)
 * instances support is 1.80. So all subsequent versions should
 * also have the same support.
 */
-   if ((version_major > 0x01) ||
+   if (adev->asic_type >= CHIP_VEGA20 || (version_major > 0x01) ||
((version_major == 0x01) && (version_minor >= 0x50)))
adev->uvd.max_handles = AMDGPU_MAX_UVD_HANDLES;
  


___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx


[PATCH v4] drm/amdgpu/vg20:support new UVD FW version naming convention

2018-06-12 Thread James Zhu
Vega20 UVD Firmware has a new version naming convention:
  [31, 30] for encode interface major
  [29, 24] for encode interface minor
  [15, 8] for decode interface minor
  [7, 0] for hardware family id

Signed-off-by: James Zhu 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c | 21 -
 1 file changed, 16 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c
index bcf68f8..630e273 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c
@@ -208,10 +208,21 @@ int amdgpu_uvd_sw_init(struct amdgpu_device *adev)
 
hdr = (const struct common_firmware_header *)adev->uvd.fw->data;
family_id = le32_to_cpu(hdr->ucode_version) & 0xff;
-   version_major = (le32_to_cpu(hdr->ucode_version) >> 24) & 0xff;
-   version_minor = (le32_to_cpu(hdr->ucode_version) >> 8) & 0xff;
-   DRM_INFO("Found UVD firmware Version: %hu.%hu Family ID: %hu\n",
-   version_major, version_minor, family_id);
+
+   if (adev->asic_type < CHIP_VEGA20) {
+   version_major = (le32_to_cpu(hdr->ucode_version) >> 24) & 0xff;
+   version_minor = (le32_to_cpu(hdr->ucode_version) >> 8) & 0xff;
+   DRM_INFO("Found UVD firmware Version: %hu.%hu Family ID: %hu\n",
+   version_major, version_minor, family_id);
+   } else {
+   unsigned int enc_major, enc_minor, dec_minor;
+
+   dec_minor = (le32_to_cpu(hdr->ucode_version) >> 8) & 0xff;
+   enc_minor = (le32_to_cpu(hdr->ucode_version) >> 24) & 0x3f;
+   enc_major = (le32_to_cpu(hdr->ucode_version) >> 30) & 0x3;
+   DRM_INFO("Found UVD firmware ENC: %hu.%hu DEC: .%hu Family ID: 
%hu\n",
+   enc_major, enc_minor, dec_minor, family_id);
+   }
 
/*
 * Limit the number of UVD handles depending on microcode major
@@ -219,7 +230,7 @@ int amdgpu_uvd_sw_init(struct amdgpu_device *adev)
 * instances support is 1.80. So all subsequent versions should
 * also have the same support.
 */
-   if ((version_major > 0x01) ||
+   if (adev->asic_type >= CHIP_VEGA20 || (version_major > 0x01) ||
((version_major == 0x01) && (version_minor >= 0x50)))
adev->uvd.max_handles = AMDGPU_MAX_UVD_HANDLES;
 
-- 
2.7.4

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx