[1/7] amdkfd: Tidy up kfd_generate_gpu_id() uint64_t bitshift unpack

Submitted by Edward O'Callaghan on Sept. 10, 2016, 1:31 a.m.

Details

Message ID 1473471099-16914-2-git-send-email-funfunctor@folklore1984.net
State New
Headers show
Series "Series without cover letter" ( rev: 1 ) in AMD X.Org drivers

Not browsing as part of any series.

Commit Message

Edward O'Callaghan Sept. 10, 2016, 1:31 a.m.
Dereference the one time and unpack the lower and upper 32bit
portions with the proper kernel helper macros.

Signed-off-by: Edward O'Callaghan <funfunctor@folklore1984.net>
Reviewed-by: Oded Gabbay <oded.gabbay@gmail.com>
---
 drivers/gpu/drm/amd/amdkfd/kfd_topology.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

Patch hide | download patch | download mbox

diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_topology.c b/drivers/gpu/drm/amd/amdkfd/kfd_topology.c
index 884c96f..1e50647 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_topology.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_topology.c
@@ -1090,19 +1090,21 @@  static uint32_t kfd_generate_gpu_id(struct kfd_dev *gpu)
 {
 	uint32_t hashout;
 	uint32_t buf[7];
+	uint64_t local_mem_size;
 	int i;
 
 	if (!gpu)
 		return 0;
 
+	local_mem_size = gpu->kfd2kgd->get_vmem_size(gpu->kgd);
+
 	buf[0] = gpu->pdev->devfn;
 	buf[1] = gpu->pdev->subsystem_vendor;
 	buf[2] = gpu->pdev->subsystem_device;
 	buf[3] = gpu->pdev->device;
 	buf[4] = gpu->pdev->bus->number;
-	buf[5] = (uint32_t)(gpu->kfd2kgd->get_vmem_size(gpu->kgd)
-			& 0xffffffff);
-	buf[6] = (uint32_t)(gpu->kfd2kgd->get_vmem_size(gpu->kgd) >> 32);
+	buf[5] = lower_32_bits(local_mem_size);
+	buf[6] = upper_32_bits(local_mem_size);
 
 	for (i = 0, hashout = 0; i < 7; i++)
 		hashout ^= hash_32(buf[i], KFD_GPU_ID_HASH_WIDTH);

Comments

On Sat, Sep 10, 2016 at 4:31 AM, Edward O'Callaghan
<funfunctor@folklore1984.net> wrote:
> Dereference the one time and unpack the lower and upper 32bit
> portions with the proper kernel helper macros.
>
> Signed-off-by: Edward O'Callaghan <funfunctor@folklore1984.net>
> Reviewed-by: Oded Gabbay <oded.gabbay@gmail.com>
> ---
>  drivers/gpu/drm/amd/amdkfd/kfd_topology.c | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_topology.c b/drivers/gpu/drm/amd/amdkfd/kfd_topology.c
> index 884c96f..1e50647 100644
> --- a/drivers/gpu/drm/amd/amdkfd/kfd_topology.c
> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_topology.c
> @@ -1090,19 +1090,21 @@ static uint32_t kfd_generate_gpu_id(struct kfd_dev *gpu)
>  {
>         uint32_t hashout;
>         uint32_t buf[7];
> +       uint64_t local_mem_size;
>         int i;
>
>         if (!gpu)
>                 return 0;
>
> +       local_mem_size = gpu->kfd2kgd->get_vmem_size(gpu->kgd);
> +
>         buf[0] = gpu->pdev->devfn;
>         buf[1] = gpu->pdev->subsystem_vendor;
>         buf[2] = gpu->pdev->subsystem_device;
>         buf[3] = gpu->pdev->device;
>         buf[4] = gpu->pdev->bus->number;
> -       buf[5] = (uint32_t)(gpu->kfd2kgd->get_vmem_size(gpu->kgd)
> -                       & 0xffffffff);
> -       buf[6] = (uint32_t)(gpu->kfd2kgd->get_vmem_size(gpu->kgd) >> 32);
> +       buf[5] = lower_32_bits(local_mem_size);
> +       buf[6] = upper_32_bits(local_mem_size);
>
>         for (i = 0, hashout = 0; i < 7; i++)
>                 hashout ^= hash_32(buf[i], KFD_GPU_ID_HASH_WIDTH);
> --
> 2.7.4
>
> _______________________________________________
> amd-gfx mailing list
> amd-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/amd-gfx

Please change title of patch to "drm/amdkfd: ...."

Oded