All of lore.kernel.org
 help / color / mirror / Atom feed
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 05/11] drm/amdgpu:use work instead of delay-work
Date: Wed, 8 Feb 2017 17:26:53 +0800	[thread overview]
Message-ID: <1486546019-31045-5-git-send-email-Monk.Liu@amd.com> (raw)
In-Reply-To: <1486546019-31045-1-git-send-email-Monk.Liu-5C7GfCeVMHo@public.gmane.org>

no need to use a delay work since we don't know how
much time hypervisor takes on FLR, so just polling
and waiting in a work.

Change-Id: I41b6336baa00b1fd299311349402a17951b585a2
Signed-off-by: Monk Liu <Monk.Liu@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h |  2 +-
 drivers/gpu/drm/amd/amdgpu/mxgpu_vi.c    | 36 +++++++++++++++-----------------
 2 files changed, 18 insertions(+), 20 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h
index 4b05568..846f29c 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h
@@ -50,7 +50,7 @@ struct amdgpu_virt {
 	struct mutex                    lock_reset;
 	struct amdgpu_irq_src		ack_irq;
 	struct amdgpu_irq_src		rcv_irq;
-	struct delayed_work		flr_work;
+	struct work_struct		flr_work;
 	const struct amdgpu_virt_ops	*ops;
 };
 
diff --git a/drivers/gpu/drm/amd/amdgpu/mxgpu_vi.c b/drivers/gpu/drm/amd/amdgpu/mxgpu_vi.c
index 7c7420f..5f156d3 100644
--- a/drivers/gpu/drm/amd/amdgpu/mxgpu_vi.c
+++ b/drivers/gpu/drm/amd/amdgpu/mxgpu_vi.c
@@ -501,17 +501,19 @@ static int xgpu_vi_set_mailbox_ack_irq(struct amdgpu_device *adev,
 
 static void xgpu_vi_mailbox_flr_work(struct work_struct *work)
 {
-	struct amdgpu_virt *virt = container_of(work,
-					struct amdgpu_virt, flr_work.work);
-	struct amdgpu_device *adev = container_of(virt,
-					struct amdgpu_device, virt);
-	int r = 0;
-
-	r = xgpu_vi_poll_msg(adev, IDH_FLR_NOTIFICATION_CMPL);
-	if (r)
-		DRM_ERROR("failed to get flr cmpl msg from hypervior.\n");
+	struct amdgpu_virt *virt = container_of(work, struct amdgpu_virt, flr_work);
+	struct amdgpu_device *adev = container_of(virt, struct amdgpu_device, virt);
+
+	/* wait until RCV_MSG become 3 */
+	if (!xgpu_vi_poll_msg(adev, IDH_FLR_NOTIFICATION_CMPL))
+		adev->virt.caps &= ~AMDGPU_SRIOV_CAPS_RUNTIME;
+	else {
+		pr_err("failed to recieve FLR_CMPL\n");
+		return;
+	}
 
-	/* TODO: need to restore gfx states */
+	/* Trigger recovery due to world switch failure */
+	amdgpu_sriov_gpu_reset(adev, false);
 }
 
 static int xgpu_vi_set_mailbox_rcv_irq(struct amdgpu_device *adev,
@@ -534,15 +536,12 @@ static int xgpu_vi_mailbox_rcv_irq(struct amdgpu_device *adev,
 {
 	int r;
 
-	adev->virt.caps &= ~AMDGPU_SRIOV_CAPS_RUNTIME;
+	/* see what event we get */
 	r = xgpu_vi_mailbox_rcv_msg(adev, IDH_FLR_NOTIFICATION);
-	/* do nothing for other msg */
-	if (r)
-		return 0;
 
-	/* TODO: need to save gfx states */
-	schedule_delayed_work(&adev->virt.flr_work,
-			      msecs_to_jiffies(VI_MAILBOX_RESET_TIME));
+	/* only handle FLR_NOTIFY now */
+	if (!r)
+		schedule_work(&adev->virt.flr_work);
 
 	return 0;
 }
@@ -595,14 +594,13 @@ int xgpu_vi_mailbox_get_irq(struct amdgpu_device *adev)
 		return r;
 	}
 
-	INIT_DELAYED_WORK(&adev->virt.flr_work, xgpu_vi_mailbox_flr_work);
+	INIT_WORK(&adev->virt.flr_work, xgpu_vi_mailbox_flr_work);
 
 	return 0;
 }
 
 void xgpu_vi_mailbox_put_irq(struct amdgpu_device *adev)
 {
-	cancel_delayed_work_sync(&adev->virt.flr_work);
 	amdgpu_irq_put(adev, &adev->virt.ack_irq, 0);
 	amdgpu_irq_put(adev, &adev->virt.rcv_irq, 0);
 }
-- 
2.7.4

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

  parent reply	other threads:[~2017-02-08  9:26 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-08  9:26 [PATCH 01/11] drm/amdgpu:use MACRO like other places Monk Liu
     [not found] ` <1486546019-31045-1-git-send-email-Monk.Liu-5C7GfCeVMHo@public.gmane.org>
2017-02-08  9:26   ` [PATCH 02/11] drm/amdgpu:impl RREG32 no kiq version Monk Liu
     [not found]     ` <1486546019-31045-2-git-send-email-Monk.Liu-5C7GfCeVMHo@public.gmane.org>
2017-02-08 16:37       ` Deucher, Alexander
2017-02-09  1:49       ` Yu, Xiangliang
2017-02-08  9:26   ` [PATCH 03/11] drm/amdgpu:Refine handshake of mailbox Monk Liu
     [not found]     ` <1486546019-31045-3-git-send-email-Monk.Liu-5C7GfCeVMHo@public.gmane.org>
2017-02-09  1:49       ` Yu, Xiangliang
2017-02-08  9:26   ` [PATCH 04/11] drm/amdgpu:no kiq for mailbox registers access Monk Liu
     [not found]     ` <1486546019-31045-4-git-send-email-Monk.Liu-5C7GfCeVMHo@public.gmane.org>
2017-02-09  1:50       ` Yu, Xiangliang
2017-02-08  9:26   ` Monk Liu [this message]
     [not found]     ` <1486546019-31045-5-git-send-email-Monk.Liu-5C7GfCeVMHo@public.gmane.org>
2017-02-08 16:38       ` [PATCH 05/11] drm/amdgpu:use work instead of delay-work Deucher, Alexander
2017-02-09  1:46       ` Yu, Xiangliang
2017-02-08  9:26   ` [PATCH 06/11] drm/amdgpu:RUNTIME flag should clr later Monk Liu
     [not found]     ` <1486546019-31045-6-git-send-email-Monk.Liu-5C7GfCeVMHo@public.gmane.org>
2017-02-08 16:39       ` Deucher, Alexander
2017-02-09  1:47       ` Yu, Xiangliang
2017-02-08  9:26   ` [PATCH 07/11] drm/amdgpu:new field in_resete introduced for gfx Monk Liu
     [not found]     ` <1486546019-31045-7-git-send-email-Monk.Liu-5C7GfCeVMHo@public.gmane.org>
2017-02-08 16:42       ` Deucher, Alexander
2017-02-08  9:26   ` [PATCH 08/11] drm/amdgpu:alloc mqd backup Monk Liu
     [not found]     ` <1486546019-31045-8-git-send-email-Monk.Liu-5C7GfCeVMHo@public.gmane.org>
2017-02-08 16:42       ` Deucher, Alexander
2017-02-09  1:51       ` Yu, Xiangliang
2017-02-08  9:26   ` [PATCH 09/11] drm/amdgpu:imple ring clear Monk Liu
     [not found]     ` <1486546019-31045-9-git-send-email-Monk.Liu-5C7GfCeVMHo@public.gmane.org>
2017-02-08 16:40       ` Deucher, Alexander
2017-02-08  9:26   ` [PATCH 10/11] drm/amdgpu:use clear_ring to clr RB Monk Liu
     [not found]     ` <1486546019-31045-10-git-send-email-Monk.Liu-5C7GfCeVMHo@public.gmane.org>
2017-02-08 16:41       ` Deucher, Alexander
2017-02-08  9:26   ` [PATCH 11/11] drm/amdgpu:fix kiq_resume routine (V2) Monk Liu
     [not found]     ` <1486546019-31045-11-git-send-email-Monk.Liu-5C7GfCeVMHo@public.gmane.org>
2017-02-08 16:43       ` Deucher, Alexander
2017-02-09  1:51       ` Yu, Xiangliang
2017-02-08  9:34   ` [PATCH 01/11] drm/amdgpu:use MACRO like other places Michel Dänzer
2017-02-08 16:35   ` Deucher, Alexander

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=1486546019-31045-5-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 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.