From 7d42dd5ecfd47ed89d052b54766b66bc0ae2d939 Mon Sep 17 00:00:00 2001 From: Felix Kuehling Date: Wed, 12 Sep 2018 01:17:55 -0400 Subject: [PATCH] Add iommu init instrumentation --- drivers/gpu/drm/amd/amdkfd/kfd_iommu.c | 5 ++++- drivers/iommu/amd_iommu_v2.c | 18 ++++++++++++++---- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_iommu.c b/drivers/gpu/drm/amd/amdkfd/kfd_iommu.c index 7a61f38c09e6..e80feb6293a4 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_iommu.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_iommu.c @@ -310,8 +310,10 @@ int kfd_iommu_resume(struct kfd_dev *kfd) pasid_limit = kfd_get_pasid_limit(); err = amd_iommu_init_device(kfd->pdev, pasid_limit); - if (err) + if (err) { + pr_err("amd_iommu_init_device failed: %d\n", err); return -ENXIO; + } amd_iommu_set_invalidate_ctx_cb(kfd->pdev, iommu_pasid_shutdown_callback); @@ -320,6 +322,7 @@ int kfd_iommu_resume(struct kfd_dev *kfd) err = kfd_bind_processes_to_device(kfd); if (err) { + pr_err("kfd_bind_processes_to_device failed: %d\n", err); amd_iommu_set_invalidate_ctx_cb(kfd->pdev, NULL); amd_iommu_set_invalid_ppr_cb(kfd->pdev, NULL); amd_iommu_free_device(kfd->pdev); diff --git a/drivers/iommu/amd_iommu_v2.c b/drivers/iommu/amd_iommu_v2.c index 58da65df03f5..c0fc5045789e 100644 --- a/drivers/iommu/amd_iommu_v2.c +++ b/drivers/iommu/amd_iommu_v2.c @@ -776,11 +776,15 @@ int amd_iommu_init_device(struct pci_dev *pdev, int pasids) might_sleep(); - if (!amd_iommu_v2_supported()) + if (!amd_iommu_v2_supported()) { + pr_err("IOMMUv2 not supported\n"); return -ENODEV; + } - if (pasids <= 0 || pasids > (PASID_MASK + 1)) + if (pasids <= 0 || pasids > (PASID_MASK + 1)) { + pr_err("PASID limit exceeded: %d > %d\n", pasids, PASID_MASK + 1); return -EINVAL; + } devid = device_id(pdev); @@ -812,18 +816,23 @@ int amd_iommu_init_device(struct pci_dev *pdev, int pasids) amd_iommu_domain_direct_map(dev_state->domain); ret = amd_iommu_domain_enable_v2(dev_state->domain, pasids); - if (ret) + if (ret) { + pr_err("Failed to enable v2: %d\n", ret); goto out_free_domain; + } group = iommu_group_get(&pdev->dev); if (!group) { + pr_err("No IOMMU group\n"); ret = -EINVAL; goto out_free_domain; } ret = iommu_attach_group(dev_state->domain, group); - if (ret != 0) + if (ret != 0) { + pr_err("Failed to attache to group\n"); goto out_drop_group; + } iommu_group_put(group); @@ -831,6 +840,7 @@ int amd_iommu_init_device(struct pci_dev *pdev, int pasids) if (__get_device_state(devid) != NULL) { spin_unlock_irqrestore(&state_lock, flags); + pr_err("Device busy\n"); ret = -EBUSY; goto out_free_domain; } -- 2.17.1