From: Sebastian Andrzej Siewior <bigeasy@linutronix.de> To: dri-devel@lists.freedesktop.org Cc: "David Airlie" <airlied@linux.ie>, "Sebastian Andrzej Siewior" <bigeasy@linutronix.de>, amd-gfx@lists.freedesktop.org, "Alex Deucher" <alexander.deucher@amd.com>, "Thomas Gleixner" <tglx@linutronix.de>, "Christian König" <christian.koenig@amd.com> Subject: [PATCH 4/4] drm/amdgpu: Replace in_task() in gfx_v8_0_parse_sq_irq() Date: Tue, 9 Feb 2021 00:31:19 +0100 [thread overview] Message-ID: <20210208233119.391103-5-bigeasy@linutronix.de> (raw) In-Reply-To: <20210208233119.391103-1-bigeasy@linutronix.de> gfx_v8_0_parse_sq_irq() is using in_task() to distinguish if it is invoked from a workqueue worker or directly from the interrupt handler. The usage of in_interrupt() in drivers is phased out and Linus clearly requested that code which changes behaviour depending on context should either be separated or the context be conveyed in an argument passed by the caller, which usually knows the context. gfx_v8_0_parse_sq_irq() is invoked directly either from a worker or from the interrupt service routine. The worker is only bypassed if the worker is already busy. Add an argument `from_wq' to gfx_v8_0_parse_sq_irq() which is true if invoked from the worker. Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> --- Side note: work_pending() will return false _before_ the callback function (gfx_v8_0_sq_irq_work_func() in case) is invoked. That means if the interrupt can fire again before the workqueue completed then it is possible with the right timing to have `gfx.sq_work.ih_data' overwritten from the previous invocation. drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c index 37639214cbbbd..8a5a7ecb9fa2b 100644 --- a/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c +++ b/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c @@ -6719,7 +6719,8 @@ static int gfx_v8_0_cp_ecc_error_irq(struct amdgpu_device *adev, return 0; } -static void gfx_v8_0_parse_sq_irq(struct amdgpu_device *adev, unsigned ih_data) +static void gfx_v8_0_parse_sq_irq(struct amdgpu_device *adev, unsigned ih_data, + bool from_wq) { u32 enc, se_id, sh_id, cu_id; char type[20]; @@ -6757,7 +6758,7 @@ static void gfx_v8_0_parse_sq_irq(struct amdgpu_device *adev, unsigned ih_data) * or from BH in which case we can access SQ_EDC_INFO * instance */ - if (in_task()) { + if (from_wq == true) { mutex_lock(&adev->grbm_idx_mutex); gfx_v8_0_select_se_sh(adev, se_id, sh_id, cu_id); @@ -6795,7 +6796,7 @@ static void gfx_v8_0_sq_irq_work_func(struct work_struct *work) struct amdgpu_device *adev = container_of(work, struct amdgpu_device, gfx.sq_work.work); struct sq_work *sq_work = container_of(work, struct sq_work, work); - gfx_v8_0_parse_sq_irq(adev, sq_work->ih_data); + gfx_v8_0_parse_sq_irq(adev, sq_work->ih_data, true); } static int gfx_v8_0_sq_irq(struct amdgpu_device *adev, @@ -6810,7 +6811,7 @@ static int gfx_v8_0_sq_irq(struct amdgpu_device *adev, * just print whatever info is possible directly from the ISR. */ if (work_pending(&adev->gfx.sq_work.work)) { - gfx_v8_0_parse_sq_irq(adev, ih_data); + gfx_v8_0_parse_sq_irq(adev, ih_data, false); } else { adev->gfx.sq_work.ih_data = ih_data; schedule_work(&adev->gfx.sq_work.work); -- 2.30.0 _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel
WARNING: multiple messages have this Message-ID (diff)
From: Sebastian Andrzej Siewior <bigeasy@linutronix.de> To: dri-devel@lists.freedesktop.org Cc: "David Airlie" <airlied@linux.ie>, "Sebastian Andrzej Siewior" <bigeasy@linutronix.de>, amd-gfx@lists.freedesktop.org, "Patrik Jakobsson" <patrik.r.jakobsson@gmail.com>, "Daniel Vetter" <daniel@ffwll.ch>, "Alex Deucher" <alexander.deucher@amd.com>, "Thomas Gleixner" <tglx@linutronix.de>, "Christian König" <christian.koenig@amd.com> Subject: [PATCH 4/4] drm/amdgpu: Replace in_task() in gfx_v8_0_parse_sq_irq() Date: Tue, 9 Feb 2021 00:31:19 +0100 [thread overview] Message-ID: <20210208233119.391103-5-bigeasy@linutronix.de> (raw) In-Reply-To: <20210208233119.391103-1-bigeasy@linutronix.de> gfx_v8_0_parse_sq_irq() is using in_task() to distinguish if it is invoked from a workqueue worker or directly from the interrupt handler. The usage of in_interrupt() in drivers is phased out and Linus clearly requested that code which changes behaviour depending on context should either be separated or the context be conveyed in an argument passed by the caller, which usually knows the context. gfx_v8_0_parse_sq_irq() is invoked directly either from a worker or from the interrupt service routine. The worker is only bypassed if the worker is already busy. Add an argument `from_wq' to gfx_v8_0_parse_sq_irq() which is true if invoked from the worker. Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> --- Side note: work_pending() will return false _before_ the callback function (gfx_v8_0_sq_irq_work_func() in case) is invoked. That means if the interrupt can fire again before the workqueue completed then it is possible with the right timing to have `gfx.sq_work.ih_data' overwritten from the previous invocation. drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c index 37639214cbbbd..8a5a7ecb9fa2b 100644 --- a/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c +++ b/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c @@ -6719,7 +6719,8 @@ static int gfx_v8_0_cp_ecc_error_irq(struct amdgpu_device *adev, return 0; } -static void gfx_v8_0_parse_sq_irq(struct amdgpu_device *adev, unsigned ih_data) +static void gfx_v8_0_parse_sq_irq(struct amdgpu_device *adev, unsigned ih_data, + bool from_wq) { u32 enc, se_id, sh_id, cu_id; char type[20]; @@ -6757,7 +6758,7 @@ static void gfx_v8_0_parse_sq_irq(struct amdgpu_device *adev, unsigned ih_data) * or from BH in which case we can access SQ_EDC_INFO * instance */ - if (in_task()) { + if (from_wq == true) { mutex_lock(&adev->grbm_idx_mutex); gfx_v8_0_select_se_sh(adev, se_id, sh_id, cu_id); @@ -6795,7 +6796,7 @@ static void gfx_v8_0_sq_irq_work_func(struct work_struct *work) struct amdgpu_device *adev = container_of(work, struct amdgpu_device, gfx.sq_work.work); struct sq_work *sq_work = container_of(work, struct sq_work, work); - gfx_v8_0_parse_sq_irq(adev, sq_work->ih_data); + gfx_v8_0_parse_sq_irq(adev, sq_work->ih_data, true); } static int gfx_v8_0_sq_irq(struct amdgpu_device *adev, @@ -6810,7 +6811,7 @@ static int gfx_v8_0_sq_irq(struct amdgpu_device *adev, * just print whatever info is possible directly from the ISR. */ if (work_pending(&adev->gfx.sq_work.work)) { - gfx_v8_0_parse_sq_irq(adev, ih_data); + gfx_v8_0_parse_sq_irq(adev, ih_data, false); } else { adev->gfx.sq_work.ih_data = ih_data; schedule_work(&adev->gfx.sq_work.work); -- 2.30.0 _______________________________________________ amd-gfx mailing list amd-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/amd-gfx
next prev parent reply other threads:[~2021-02-08 23:31 UTC|newest] Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-02-08 23:31 [PATCH 0/4] drm: Replace in_interrupt() usage Sebastian Andrzej Siewior 2021-02-08 23:31 ` Sebastian Andrzej Siewior 2021-02-08 23:31 ` [PATCH 1/4] drm/gma500: Remove in_atomic() usage Sebastian Andrzej Siewior 2021-02-08 23:31 ` Sebastian Andrzej Siewior 2021-02-09 10:23 ` Daniel Vetter 2021-02-09 10:23 ` Daniel Vetter 2021-02-08 23:31 ` [PATCH 2/4] drm/amdgpu: Replace in_interrupt() usage in gmc_v*_process_interrupt() Sebastian Andrzej Siewior 2021-02-08 23:31 ` Sebastian Andrzej Siewior 2021-02-08 23:31 ` [PATCH 3/4] drm/amdgpu: Remove in_interrupt() usage in gfx_v9_0_kiq_read_clock() Sebastian Andrzej Siewior 2021-02-08 23:31 ` Sebastian Andrzej Siewior 2021-02-08 23:31 ` Sebastian Andrzej Siewior [this message] 2021-02-08 23:31 ` [PATCH 4/4] drm/amdgpu: Replace in_task() in gfx_v8_0_parse_sq_irq() Sebastian Andrzej Siewior 2021-02-09 8:05 ` [PATCH 0/4] drm: Replace in_interrupt() usage Christian König 2021-02-09 8:05 ` Christian König
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=20210208233119.391103-5-bigeasy@linutronix.de \ --to=bigeasy@linutronix.de \ --cc=airlied@linux.ie \ --cc=alexander.deucher@amd.com \ --cc=amd-gfx@lists.freedesktop.org \ --cc=christian.koenig@amd.com \ --cc=dri-devel@lists.freedesktop.org \ --cc=tglx@linutronix.de \ /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: linkBe 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.