From: Monk Liu <Monk.Liu-5C7GfCeVMHo@public.gmane.org>
To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org
Cc: Monk Liu <Monk.Liu-5C7GfCeVMHo@public.gmane.org>
Subject: [PATCH 3/3] drm/amdgpu:invoke CSA functions
Date: Wed, 11 Jan 2017 18:43:26 +0800 [thread overview]
Message-ID: <1484131406-19893-4-git-send-email-Monk.Liu@amd.com> (raw)
In-Reply-To: <1484131406-19893-1-git-send-email-Monk.Liu-5C7GfCeVMHo@public.gmane.org>
Change-Id: I528c2f324830aaa21ab8d8250bc80a2a6bab33bd
Signed-off-by: Monk Liu <Monk.Liu@amd.com>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 14 ++++++++++++++
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 12 ++++++++++++
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 14 ++++++++++++++
drivers/gpu/drm/amd/amdgpu/vi.c | 3 +++
4 files changed, 43 insertions(+)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
index 6159afc..328f1c7 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
@@ -771,6 +771,20 @@ static int amdgpu_bo_vm_update_pte(struct amdgpu_cs_parser *p,
if (r)
return r;
+ if (amdgpu_sriov_vf(adev)) {
+ struct fence *f;
+ bo_va = vm->csa_bo_va;
+ BUG_ON(!bo_va);
+ r = amdgpu_vm_bo_update(adev, bo_va, false);
+ if (r)
+ return r;
+
+ f = bo_va->last_pt_update;
+ r = amdgpu_sync_fence(adev, &p->job->sync, f);
+ if (r)
+ return r;
+ }
+
if (p->bo_list) {
for (i = 0; i < p->bo_list->num_entries; i++) {
struct fence *f;
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index f82919d..7c73dee 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -1384,6 +1384,15 @@ static int amdgpu_init(struct amdgpu_device *adev)
return r;
}
adev->ip_blocks[i].status.hw = true;
+
+ /* right after GMC hw init, we create CSA */
+ if (amdgpu_sriov_vf(adev)) {
+ r = amdgpu_allocate_static_csa(adev);
+ if (r) {
+ DRM_ERROR("allocate CSA failed %d\n", r);
+ return r;
+ }
+ }
}
}
@@ -1517,6 +1526,9 @@ static int amdgpu_fini(struct amdgpu_device *adev)
adev->ip_blocks[i].status.late_initialized = false;
}
+ if (amdgpu_sriov_vf(adev))
+ amdgpu_bo_free_kernel(&adev->virt.csa_obj, &adev->virt.csa_vmid0_addr, NULL);
+
return 0;
}
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
index 47bc8e1..1421a9d 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
@@ -650,6 +650,12 @@ int amdgpu_driver_open_kms(struct drm_device *dev, struct drm_file *file_priv)
goto out_suspend;
}
+ if (amdgpu_sriov_vf(adev)) {
+ r = amdgpu_map_static_csa(adev, &fpriv->vm);
+ if (r)
+ goto out_suspend;
+ }
+
mutex_init(&fpriv->bo_list_lock);
idr_init(&fpriv->bo_list_handles);
@@ -688,6 +694,14 @@ void amdgpu_driver_postclose_kms(struct drm_device *dev,
amdgpu_uvd_free_handles(adev, file_priv);
amdgpu_vce_free_handles(adev, file_priv);
+ if (amdgpu_sriov_vf(adev)) {
+ /* TODO: how to handle reserve failure */
+ BUG_ON(amdgpu_bo_reserve(adev->virt.csa_obj, false));
+ amdgpu_vm_bo_rmv(adev, fpriv->vm.csa_bo_va);
+ fpriv->vm.csa_bo_va = NULL;
+ amdgpu_bo_unreserve(adev->virt.csa_obj);
+ }
+
amdgpu_vm_fini(adev, &fpriv->vm);
idr_for_each_entry(&fpriv->bo_list_handles, list, handle)
diff --git a/drivers/gpu/drm/amd/amdgpu/vi.c b/drivers/gpu/drm/amd/amdgpu/vi.c
index 7350a8f..1f307c3 100644
--- a/drivers/gpu/drm/amd/amdgpu/vi.c
+++ b/drivers/gpu/drm/amd/amdgpu/vi.c
@@ -455,6 +455,9 @@ static void vi_detect_hw_virtualization(struct amdgpu_device *adev)
if (is_virtual_machine()) /* passthrough mode exclus sr-iov mode */
adev->virt.caps |= AMDGPU_PASSTHROUGH_MODE;
}
+
+ if (amdgpu_sriov_vf(adev))
+ adev->virt.csa_size = AMDGPU_CSA_SIZE; /* two page now for VI and AI */
}
static const struct amdgpu_allowed_register_entry tonga_allowed_read_registers[] = {
--
2.7.4
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
next prev parent reply other threads:[~2017-01-11 10:43 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-11 10:43 [PATCH 0/3] CSA patch v3 Monk Liu
[not found] ` <1484131406-19893-1-git-send-email-Monk.Liu-5C7GfCeVMHo@public.gmane.org>
2017-01-11 10:43 ` [PATCH 1/3] drm/amdgpu:new field members for SRIOV Monk Liu
[not found] ` <1484131406-19893-2-git-send-email-Monk.Liu-5C7GfCeVMHo@public.gmane.org>
2017-01-11 12:46 ` Christian König
[not found] ` <1560cfc2-f700-fedd-c557-0b121c2f3cca-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org>
2017-01-11 14:49 ` Liu, Monk
[not found] ` <BY2PR1201MB11106625F28ACE98D9AF99E984660-O28G1zQ8oGliQkyLPkmea2rFom/aUZj6nBOFsp37pqbUKgpGm//BTAC/G2K4zDHf@public.gmane.org>
2017-01-11 15:46 ` Christian König
2017-01-11 10:43 ` [PATCH 2/3] drm/amdgpu:add new file " Monk Liu
[not found] ` <1484131406-19893-3-git-send-email-Monk.Liu-5C7GfCeVMHo@public.gmane.org>
2017-01-11 12:49 ` Christian König
2017-01-11 10:43 ` Monk Liu [this message]
[not found] ` <1484131406-19893-4-git-send-email-Monk.Liu-5C7GfCeVMHo@public.gmane.org>
2017-01-11 12:54 ` [PATCH 3/3] drm/amdgpu:invoke CSA functions Christian König
-- strict thread matches above, loose matches on Subject: below --
2017-01-11 2:53 [PATCH 0/3] CSA patches Monk Liu
[not found] ` <1484103205-5789-1-git-send-email-Monk.Liu-5C7GfCeVMHo@public.gmane.org>
2017-01-11 2:53 ` [PATCH 3/3] drm/amdgpu:invoke CSA functions Monk Liu
2017-01-10 10:33 [PATCH 0/3] static CSA patches Monk Liu
[not found] ` <1484044422-2898-1-git-send-email-Monk.Liu-5C7GfCeVMHo@public.gmane.org>
2017-01-10 10:33 ` [PATCH 3/3] drm/amdgpu:invoke CSA functions Monk Liu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1484131406-19893-4-git-send-email-Monk.Liu@amd.com \
--to=monk.liu-5c7gfcevmho@public.gmane.org \
--cc=amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox