All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/amdgpu: Fix return types of certain NBIOv7.9 callbacks
@ 2023-05-24 16:44 ` Nathan Chancellor
  0 siblings, 0 replies; 4+ messages in thread
From: Nathan Chancellor @ 2023-05-24 16:44 UTC (permalink / raw)
  To: alexander.deucher, christian.koenig, Xinhui.Pan
  Cc: ndesaulniers, trix, amd-gfx, dri-devel, llvm, patches, Nathan Chancellor

When building with clang's -Wincompatible-function-pointer-types-strict,
which ensures that function pointer signatures match exactly to avoid
tripping clang's Control Flow Integrity (kCFI) checks at run time and
will eventually be turned on for the kernel, the following instances
appear in the NBIOv7.9 code:

  drivers/gpu/drm/amd/amdgpu/nbio_v7_9.c:465:32: error: incompatible function pointer types initializing 'int (*)(struct amdgpu_device *)' with an expression of type 'enum amdgpu_gfx_partition (struct amdgpu_device *)' [-Werror,-Wincompatible-function-pointer-types-strict]
          .get_compute_partition_mode = nbio_v7_9_get_compute_partition_mode,
                                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  drivers/gpu/drm/amd/amdgpu/nbio_v7_9.c:467:31: error: incompatible function pointer types initializing 'u32 (*)(struct amdgpu_device *, u32 *)' (aka 'unsigned int (*)(struct amdgpu_device *, unsigned int *)') with an expression of type 'enum amdgpu_memory_partition (struct amdgpu_device *, u32 *)' (aka 'enum amdgpu_memory_partition (struct amdgpu_device *, unsigned int *)') [-Werror,-Wincompatible-function-pointer-types-strict]
          .get_memory_partition_mode = nbio_v7_9_get_memory_partition_mode,
                                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2 errors generated.

Change the return types of these callbacks to match the prototypes to
clear up the warning and avoid tripping kCFI at run time. Both functions
return a value from ffs(), which is an integer that can fit into either
int or unsigned int.

Fixes: 11f64eb1472f ("drm/amdgpu: add sysfs node for compute partition mode")
Fixes: 41a717ea8afc ("drm/amdgpu: detect current GPU memory partition mode")
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
---
 drivers/gpu/drm/amd/amdgpu/nbio_v7_9.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/nbio_v7_9.c b/drivers/gpu/drm/amd/amdgpu/nbio_v7_9.c
index e082f6343d20..d19325476752 100644
--- a/drivers/gpu/drm/amd/amdgpu/nbio_v7_9.c
+++ b/drivers/gpu/drm/amd/amdgpu/nbio_v7_9.c
@@ -382,7 +382,7 @@ static void nbio_v7_9_enable_doorbell_interrupt(struct amdgpu_device *adev,
 			      DOORBELL_INTERRUPT_DISABLE, enable ? 0 : 1);
 }
 
-static enum amdgpu_gfx_partition nbio_v7_9_get_compute_partition_mode(struct amdgpu_device *adev)
+static int nbio_v7_9_get_compute_partition_mode(struct amdgpu_device *adev)
 {
 	u32 tmp, px;
 
@@ -408,8 +408,8 @@ static void nbio_v7_9_set_compute_partition_mode(struct amdgpu_device *adev,
 	WREG32_SOC15(NBIO, 0, regBIF_BX_PF0_PARTITION_COMPUTE_STATUS, tmp);
 }
 
-static enum amdgpu_memory_partition
-nbio_v7_9_get_memory_partition_mode(struct amdgpu_device *adev, u32 *supp_modes)
+static u32 nbio_v7_9_get_memory_partition_mode(struct amdgpu_device *adev,
+					       u32 *supp_modes)
 {
 	u32 tmp;
 

---
base-commit: fd8f7bb391fa9c1979232cb5ab5bedb08abc855d
change-id: 20230524-nbio_v7_9-wincompatible-function-pointer-types-strict-c894636ce146

Best regards,
-- 
Nathan Chancellor <nathan@kernel.org>


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH] drm/amdgpu: Fix return types of certain NBIOv7.9 callbacks
@ 2023-05-24 16:44 ` Nathan Chancellor
  0 siblings, 0 replies; 4+ messages in thread
From: Nathan Chancellor @ 2023-05-24 16:44 UTC (permalink / raw)
  To: alexander.deucher, christian.koenig, Xinhui.Pan
  Cc: trix, llvm, ndesaulniers, patches, dri-devel, Nathan Chancellor, amd-gfx

When building with clang's -Wincompatible-function-pointer-types-strict,
which ensures that function pointer signatures match exactly to avoid
tripping clang's Control Flow Integrity (kCFI) checks at run time and
will eventually be turned on for the kernel, the following instances
appear in the NBIOv7.9 code:

  drivers/gpu/drm/amd/amdgpu/nbio_v7_9.c:465:32: error: incompatible function pointer types initializing 'int (*)(struct amdgpu_device *)' with an expression of type 'enum amdgpu_gfx_partition (struct amdgpu_device *)' [-Werror,-Wincompatible-function-pointer-types-strict]
          .get_compute_partition_mode = nbio_v7_9_get_compute_partition_mode,
                                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  drivers/gpu/drm/amd/amdgpu/nbio_v7_9.c:467:31: error: incompatible function pointer types initializing 'u32 (*)(struct amdgpu_device *, u32 *)' (aka 'unsigned int (*)(struct amdgpu_device *, unsigned int *)') with an expression of type 'enum amdgpu_memory_partition (struct amdgpu_device *, u32 *)' (aka 'enum amdgpu_memory_partition (struct amdgpu_device *, unsigned int *)') [-Werror,-Wincompatible-function-pointer-types-strict]
          .get_memory_partition_mode = nbio_v7_9_get_memory_partition_mode,
                                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2 errors generated.

Change the return types of these callbacks to match the prototypes to
clear up the warning and avoid tripping kCFI at run time. Both functions
return a value from ffs(), which is an integer that can fit into either
int or unsigned int.

Fixes: 11f64eb1472f ("drm/amdgpu: add sysfs node for compute partition mode")
Fixes: 41a717ea8afc ("drm/amdgpu: detect current GPU memory partition mode")
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
---
 drivers/gpu/drm/amd/amdgpu/nbio_v7_9.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/nbio_v7_9.c b/drivers/gpu/drm/amd/amdgpu/nbio_v7_9.c
index e082f6343d20..d19325476752 100644
--- a/drivers/gpu/drm/amd/amdgpu/nbio_v7_9.c
+++ b/drivers/gpu/drm/amd/amdgpu/nbio_v7_9.c
@@ -382,7 +382,7 @@ static void nbio_v7_9_enable_doorbell_interrupt(struct amdgpu_device *adev,
 			      DOORBELL_INTERRUPT_DISABLE, enable ? 0 : 1);
 }
 
-static enum amdgpu_gfx_partition nbio_v7_9_get_compute_partition_mode(struct amdgpu_device *adev)
+static int nbio_v7_9_get_compute_partition_mode(struct amdgpu_device *adev)
 {
 	u32 tmp, px;
 
@@ -408,8 +408,8 @@ static void nbio_v7_9_set_compute_partition_mode(struct amdgpu_device *adev,
 	WREG32_SOC15(NBIO, 0, regBIF_BX_PF0_PARTITION_COMPUTE_STATUS, tmp);
 }
 
-static enum amdgpu_memory_partition
-nbio_v7_9_get_memory_partition_mode(struct amdgpu_device *adev, u32 *supp_modes)
+static u32 nbio_v7_9_get_memory_partition_mode(struct amdgpu_device *adev,
+					       u32 *supp_modes)
 {
 	u32 tmp;
 

---
base-commit: fd8f7bb391fa9c1979232cb5ab5bedb08abc855d
change-id: 20230524-nbio_v7_9-wincompatible-function-pointer-types-strict-c894636ce146

Best regards,
-- 
Nathan Chancellor <nathan@kernel.org>


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] drm/amdgpu: Fix return types of certain NBIOv7.9 callbacks
  2023-05-24 16:44 ` Nathan Chancellor
@ 2023-05-24 18:50   ` Alex Deucher
  -1 siblings, 0 replies; 4+ messages in thread
From: Alex Deucher @ 2023-05-24 18:50 UTC (permalink / raw)
  To: Nathan Chancellor
  Cc: llvm, trix, Xinhui.Pan, ndesaulniers, patches, dri-devel,
	amd-gfx, alexander.deucher, christian.koenig

Applied.  Thanks!

On Wed, May 24, 2023 at 12:44 PM Nathan Chancellor <nathan@kernel.org> wrote:
>
> When building with clang's -Wincompatible-function-pointer-types-strict,
> which ensures that function pointer signatures match exactly to avoid
> tripping clang's Control Flow Integrity (kCFI) checks at run time and
> will eventually be turned on for the kernel, the following instances
> appear in the NBIOv7.9 code:
>
>   drivers/gpu/drm/amd/amdgpu/nbio_v7_9.c:465:32: error: incompatible function pointer types initializing 'int (*)(struct amdgpu_device *)' with an expression of type 'enum amdgpu_gfx_partition (struct amdgpu_device *)' [-Werror,-Wincompatible-function-pointer-types-strict]
>           .get_compute_partition_mode = nbio_v7_9_get_compute_partition_mode,
>                                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>   drivers/gpu/drm/amd/amdgpu/nbio_v7_9.c:467:31: error: incompatible function pointer types initializing 'u32 (*)(struct amdgpu_device *, u32 *)' (aka 'unsigned int (*)(struct amdgpu_device *, unsigned int *)') with an expression of type 'enum amdgpu_memory_partition (struct amdgpu_device *, u32 *)' (aka 'enum amdgpu_memory_partition (struct amdgpu_device *, unsigned int *)') [-Werror,-Wincompatible-function-pointer-types-strict]
>           .get_memory_partition_mode = nbio_v7_9_get_memory_partition_mode,
>                                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>   2 errors generated.
>
> Change the return types of these callbacks to match the prototypes to
> clear up the warning and avoid tripping kCFI at run time. Both functions
> return a value from ffs(), which is an integer that can fit into either
> int or unsigned int.
>
> Fixes: 11f64eb1472f ("drm/amdgpu: add sysfs node for compute partition mode")
> Fixes: 41a717ea8afc ("drm/amdgpu: detect current GPU memory partition mode")
> Signed-off-by: Nathan Chancellor <nathan@kernel.org>
> ---
>  drivers/gpu/drm/amd/amdgpu/nbio_v7_9.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/nbio_v7_9.c b/drivers/gpu/drm/amd/amdgpu/nbio_v7_9.c
> index e082f6343d20..d19325476752 100644
> --- a/drivers/gpu/drm/amd/amdgpu/nbio_v7_9.c
> +++ b/drivers/gpu/drm/amd/amdgpu/nbio_v7_9.c
> @@ -382,7 +382,7 @@ static void nbio_v7_9_enable_doorbell_interrupt(struct amdgpu_device *adev,
>                               DOORBELL_INTERRUPT_DISABLE, enable ? 0 : 1);
>  }
>
> -static enum amdgpu_gfx_partition nbio_v7_9_get_compute_partition_mode(struct amdgpu_device *adev)
> +static int nbio_v7_9_get_compute_partition_mode(struct amdgpu_device *adev)
>  {
>         u32 tmp, px;
>
> @@ -408,8 +408,8 @@ static void nbio_v7_9_set_compute_partition_mode(struct amdgpu_device *adev,
>         WREG32_SOC15(NBIO, 0, regBIF_BX_PF0_PARTITION_COMPUTE_STATUS, tmp);
>  }
>
> -static enum amdgpu_memory_partition
> -nbio_v7_9_get_memory_partition_mode(struct amdgpu_device *adev, u32 *supp_modes)
> +static u32 nbio_v7_9_get_memory_partition_mode(struct amdgpu_device *adev,
> +                                              u32 *supp_modes)
>  {
>         u32 tmp;
>
>
> ---
> base-commit: fd8f7bb391fa9c1979232cb5ab5bedb08abc855d
> change-id: 20230524-nbio_v7_9-wincompatible-function-pointer-types-strict-c894636ce146
>
> Best regards,
> --
> Nathan Chancellor <nathan@kernel.org>
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] drm/amdgpu: Fix return types of certain NBIOv7.9 callbacks
@ 2023-05-24 18:50   ` Alex Deucher
  0 siblings, 0 replies; 4+ messages in thread
From: Alex Deucher @ 2023-05-24 18:50 UTC (permalink / raw)
  To: Nathan Chancellor
  Cc: alexander.deucher, christian.koenig, Xinhui.Pan, trix, llvm,
	ndesaulniers, patches, dri-devel, amd-gfx

Applied.  Thanks!

On Wed, May 24, 2023 at 12:44 PM Nathan Chancellor <nathan@kernel.org> wrote:
>
> When building with clang's -Wincompatible-function-pointer-types-strict,
> which ensures that function pointer signatures match exactly to avoid
> tripping clang's Control Flow Integrity (kCFI) checks at run time and
> will eventually be turned on for the kernel, the following instances
> appear in the NBIOv7.9 code:
>
>   drivers/gpu/drm/amd/amdgpu/nbio_v7_9.c:465:32: error: incompatible function pointer types initializing 'int (*)(struct amdgpu_device *)' with an expression of type 'enum amdgpu_gfx_partition (struct amdgpu_device *)' [-Werror,-Wincompatible-function-pointer-types-strict]
>           .get_compute_partition_mode = nbio_v7_9_get_compute_partition_mode,
>                                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>   drivers/gpu/drm/amd/amdgpu/nbio_v7_9.c:467:31: error: incompatible function pointer types initializing 'u32 (*)(struct amdgpu_device *, u32 *)' (aka 'unsigned int (*)(struct amdgpu_device *, unsigned int *)') with an expression of type 'enum amdgpu_memory_partition (struct amdgpu_device *, u32 *)' (aka 'enum amdgpu_memory_partition (struct amdgpu_device *, unsigned int *)') [-Werror,-Wincompatible-function-pointer-types-strict]
>           .get_memory_partition_mode = nbio_v7_9_get_memory_partition_mode,
>                                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>   2 errors generated.
>
> Change the return types of these callbacks to match the prototypes to
> clear up the warning and avoid tripping kCFI at run time. Both functions
> return a value from ffs(), which is an integer that can fit into either
> int or unsigned int.
>
> Fixes: 11f64eb1472f ("drm/amdgpu: add sysfs node for compute partition mode")
> Fixes: 41a717ea8afc ("drm/amdgpu: detect current GPU memory partition mode")
> Signed-off-by: Nathan Chancellor <nathan@kernel.org>
> ---
>  drivers/gpu/drm/amd/amdgpu/nbio_v7_9.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/nbio_v7_9.c b/drivers/gpu/drm/amd/amdgpu/nbio_v7_9.c
> index e082f6343d20..d19325476752 100644
> --- a/drivers/gpu/drm/amd/amdgpu/nbio_v7_9.c
> +++ b/drivers/gpu/drm/amd/amdgpu/nbio_v7_9.c
> @@ -382,7 +382,7 @@ static void nbio_v7_9_enable_doorbell_interrupt(struct amdgpu_device *adev,
>                               DOORBELL_INTERRUPT_DISABLE, enable ? 0 : 1);
>  }
>
> -static enum amdgpu_gfx_partition nbio_v7_9_get_compute_partition_mode(struct amdgpu_device *adev)
> +static int nbio_v7_9_get_compute_partition_mode(struct amdgpu_device *adev)
>  {
>         u32 tmp, px;
>
> @@ -408,8 +408,8 @@ static void nbio_v7_9_set_compute_partition_mode(struct amdgpu_device *adev,
>         WREG32_SOC15(NBIO, 0, regBIF_BX_PF0_PARTITION_COMPUTE_STATUS, tmp);
>  }
>
> -static enum amdgpu_memory_partition
> -nbio_v7_9_get_memory_partition_mode(struct amdgpu_device *adev, u32 *supp_modes)
> +static u32 nbio_v7_9_get_memory_partition_mode(struct amdgpu_device *adev,
> +                                              u32 *supp_modes)
>  {
>         u32 tmp;
>
>
> ---
> base-commit: fd8f7bb391fa9c1979232cb5ab5bedb08abc855d
> change-id: 20230524-nbio_v7_9-wincompatible-function-pointer-types-strict-c894636ce146
>
> Best regards,
> --
> Nathan Chancellor <nathan@kernel.org>
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-05-24 18:51 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-24 16:44 [PATCH] drm/amdgpu: Fix return types of certain NBIOv7.9 callbacks Nathan Chancellor
2023-05-24 16:44 ` Nathan Chancellor
2023-05-24 18:50 ` Alex Deucher
2023-05-24 18:50   ` Alex Deucher

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.