[1/1] drm/amdkfd: Don't assign dGPUs to APU topology devices

Submitted by Kuehling, Felix on Jan. 8, 2019, 11:29 p.m.

Details

Message ID 1546990129-27626-1-git-send-email-Felix.Kuehling@amd.com
State New
Series "Series without cover letter"
Headers show

Commit Message

Kuehling, Felix Jan. 8, 2019, 11:29 p.m.
dGPUs need their own topology devices. Don't assign them to APU topology
devices with CPU cores.

Bug: https://github.com/RadeonOpenCompute/ROCK-Kernel-Driver/issues/66
Signed-off-by: Felix Kuehling <Felix.Kuehling@amd.com>
---
 drivers/gpu/drm/amd/amdkfd/kfd_topology.c | 12 +++++++++---
 1 file changed, 9 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 4734f1a..09da916 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_topology.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_topology.c
@@ -1093,8 +1093,6 @@  static uint32_t kfd_generate_gpu_id(struct kfd_dev *gpu)
  *		the GPU device is not already present in the topology device
  *		list then return NULL. This means a new topology device has to
  *		be created for this GPU.
- * TODO: Rather than assiging @gpu to first topology device withtout
- *		gpu attached, it will better to have more stringent check.
  */
 static struct kfd_topology_device *kfd_assign_gpu(struct kfd_dev *gpu)
 {
@@ -1102,12 +1100,20 @@  static struct kfd_topology_device *kfd_assign_gpu(struct kfd_dev *gpu)
 	struct kfd_topology_device *out_dev = NULL;
 
 	down_write(&topology_lock);
-	list_for_each_entry(dev, &topology_device_list, list)
+	list_for_each_entry(dev, &topology_device_list, list) {
+		/* Discrete GPUs need their own topology device list
+		 * entries. Don't assign them to CPU/APU nodes.
+		 */
+		if (!gpu->device_info->needs_iommu_device &&
+		    dev->node_props.cpu_cores_count)
+			continue;
+
 		if (!dev->gpu && (dev->node_props.simd_count > 0)) {
 			dev->gpu = gpu;
 			out_dev = dev;
 			break;
 		}
+	}
 	up_write(&topology_lock);
 	return out_dev;
 }

Comments

Alex Deucher Jan. 9, 2019, 3:20 a.m.
On Tue, Jan 8, 2019 at 6:29 PM Kuehling, Felix <Felix.Kuehling@amd.com> wrote:
>
> dGPUs need their own topology devices. Don't assign them to APU topology
> devices with CPU cores.
>
> Bug: https://github.com/RadeonOpenCompute/ROCK-Kernel-Driver/issues/66
> Signed-off-by: Felix Kuehling <Felix.Kuehling@amd.com>

Acked-by: Alex Deucher <alexander.deucher@amd.com>

> ---
>  drivers/gpu/drm/amd/amdkfd/kfd_topology.c | 12 +++++++++---
>  1 file changed, 9 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_topology.c b/drivers/gpu/drm/amd/amdkfd/kfd_topology.c
> index 4734f1a..09da916 100644
> --- a/drivers/gpu/drm/amd/amdkfd/kfd_topology.c
> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_topology.c
> @@ -1093,8 +1093,6 @@ static uint32_t kfd_generate_gpu_id(struct kfd_dev *gpu)
>   *             the GPU device is not already present in the topology device
>   *             list then return NULL. This means a new topology device has to
>   *             be created for this GPU.
> - * TODO: Rather than assiging @gpu to first topology device withtout
> - *             gpu attached, it will better to have more stringent check.
>   */
>  static struct kfd_topology_device *kfd_assign_gpu(struct kfd_dev *gpu)
>  {
> @@ -1102,12 +1100,20 @@ static struct kfd_topology_device *kfd_assign_gpu(struct kfd_dev *gpu)
>         struct kfd_topology_device *out_dev = NULL;
>
>         down_write(&topology_lock);
> -       list_for_each_entry(dev, &topology_device_list, list)
> +       list_for_each_entry(dev, &topology_device_list, list) {
> +               /* Discrete GPUs need their own topology device list
> +                * entries. Don't assign them to CPU/APU nodes.
> +                */
> +               if (!gpu->device_info->needs_iommu_device &&
> +                   dev->node_props.cpu_cores_count)
> +                       continue;
> +
>                 if (!dev->gpu && (dev->node_props.simd_count > 0)) {
>                         dev->gpu = gpu;
>                         out_dev = dev;
>                         break;
>                 }
> +       }
>         up_write(&topology_lock);
>         return out_dev;
>  }
> --
> 2.7.4
>
> _______________________________________________
> amd-gfx mailing list
> amd-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/amd-gfx