From: Jeffrey Hugo <quic_jhugo@quicinc.com>
To: Jacek Lawrynowicz <jacek.lawrynowicz@linux.intel.com>,
<dri-devel@lists.freedesktop.org>
Subject: Re: [PATCH 05/10] accel/ivpu: Fix potential infinite loops in IRQ handlers
Date: Fri, 5 Jan 2024 09:35:11 -0700 [thread overview]
Message-ID: <663dc292-0aa0-367c-e2f3-ade7ffba3b94@quicinc.com> (raw)
In-Reply-To: <20240105112218.351265-6-jacek.lawrynowicz@linux.intel.com>
On 1/5/2024 4:22 AM, Jacek Lawrynowicz wrote:
> Limit number of iterations in ivpu_mmu_irq_evtq_handler() and
> ivpu_ipc_irq_handler().
"potential infinite loops" sounds like something that has not been
observed. Has a problem actually occurred?
Are you concerned that the FW is broken and spamming Linux with events?
Why a limit of 100 events? Seems arbitrary.
I suspect threaded irqs might be useful here, but it is hard to tell.
>
> Signed-off-by: Jacek Lawrynowicz <jacek.lawrynowicz@linux.intel.com>
> ---
> drivers/accel/ivpu/ivpu_ipc.c | 6 ++++++
> drivers/accel/ivpu/ivpu_mmu.c | 21 +++++++++++++--------
> 2 files changed, 19 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/accel/ivpu/ivpu_ipc.c b/drivers/accel/ivpu/ivpu_ipc.c
> index e86621f16f85..f69780248803 100644
> --- a/drivers/accel/ivpu/ivpu_ipc.c
> +++ b/drivers/accel/ivpu/ivpu_ipc.c
> @@ -389,12 +389,18 @@ void ivpu_ipc_irq_handler(struct ivpu_device *vdev, bool *wake_thread)
> unsigned long flags;
> bool dispatched;
> u32 vpu_addr;
> + int msg_count = 0;
>
> /*
> * Driver needs to purge all messages from IPC FIFO to clear IPC interrupt.
> * Without purge IPC FIFO to 0 next IPC interrupts won't be generated.
> */
> while (ivpu_hw_reg_ipc_rx_count_get(vdev)) {
> + if (++msg_count > IPC_MAX_RX_MSG) {
> + ivpu_pm_schedule_recovery(vdev);
> + return;
> + }
> +
> vpu_addr = ivpu_hw_reg_ipc_rx_addr_get(vdev);
> if (vpu_addr == REG_IO_ERROR) {
> ivpu_err_ratelimited(vdev, "Failed to read IPC rx addr register\n");
> diff --git a/drivers/accel/ivpu/ivpu_mmu.c b/drivers/accel/ivpu/ivpu_mmu.c
> index 1f813625aab3..c82929b0ae9d 100644
> --- a/drivers/accel/ivpu/ivpu_mmu.c
> +++ b/drivers/accel/ivpu/ivpu_mmu.c
> @@ -236,6 +236,8 @@
> #define IVPU_MMU_CERROR_ABT 0x2
> #define IVPU_MMU_CERROR_ATC_INV_SYNC 0x3
>
> +#define IVPU_MMU_MAX_EVENT_COUNT 100
> +
> static const char *ivpu_mmu_event_to_str(u32 cmd)
> {
> switch (cmd) {
> @@ -887,7 +889,7 @@ static u32 *ivpu_mmu_get_event(struct ivpu_device *vdev)
>
> void ivpu_mmu_irq_evtq_handler(struct ivpu_device *vdev)
> {
> - bool schedule_recovery = false;
> + int event_count = 0;
> u32 *event;
> u32 ssid;
>
> @@ -895,16 +897,19 @@ void ivpu_mmu_irq_evtq_handler(struct ivpu_device *vdev)
>
> while ((event = ivpu_mmu_get_event(vdev)) != NULL) {
> ivpu_mmu_dump_event(vdev, event);
> + if (++event_count > IVPU_MMU_MAX_EVENT_COUNT) {
> + ivpu_pm_schedule_recovery(vdev);
> + return;
> + }
>
> ssid = FIELD_GET(IVPU_MMU_EVT_SSID_MASK, event[0]);
> - if (ssid == IVPU_GLOBAL_CONTEXT_MMU_SSID)
> - schedule_recovery = true;
> - else
> - ivpu_mmu_user_context_mark_invalid(vdev, ssid);
> - }
> + if (ssid == IVPU_GLOBAL_CONTEXT_MMU_SSID) {
> + ivpu_pm_schedule_recovery(vdev);
> + return;
> + }
>
> - if (schedule_recovery)
> - ivpu_pm_schedule_recovery(vdev);
> + ivpu_mmu_user_context_mark_invalid(vdev, ssid);
> + }
> }
>
> void ivpu_mmu_evtq_dump(struct ivpu_device *vdev)
next prev parent reply other threads:[~2024-01-05 16:36 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-05 11:22 [PATCH 00/10] accel/ivpu fixes for 6.8 Jacek Lawrynowicz
2024-01-05 11:22 ` [PATCH 01/10] accel/ivpu: Dump MMU events in case of VPU boot timeout Jacek Lawrynowicz
2024-01-05 15:11 ` Jeffrey Hugo
2024-01-05 11:22 ` [PATCH 02/10] accel/ivpu: Call diagnose failure in ivpu_mmu_cmdq_sync() Jacek Lawrynowicz
2024-01-05 15:12 ` Jeffrey Hugo
2024-01-05 11:22 ` [PATCH 03/10] accel/ivpu: Add debug prints for MMU map/unmap operations Jacek Lawrynowicz
2024-01-05 15:32 ` Jeffrey Hugo
2024-01-09 12:50 ` Jacek Lawrynowicz
2024-01-05 11:22 ` [PATCH 04/10] accel/ivpu: Add diagnostic messages when VPU fails to boot or suspend Jacek Lawrynowicz
2024-01-05 15:41 ` Jeffrey Hugo
2024-01-05 11:22 ` [PATCH 05/10] accel/ivpu: Fix potential infinite loops in IRQ handlers Jacek Lawrynowicz
2024-01-05 16:35 ` Jeffrey Hugo [this message]
2024-01-09 12:34 ` Jacek Lawrynowicz
2024-01-05 11:22 ` [PATCH 06/10] accel/ivpu: Fix for missing lock around drm_gem_shmem_vmap() Jacek Lawrynowicz
2024-01-05 16:36 ` Jeffrey Hugo
2024-01-09 12:51 ` Jacek Lawrynowicz
2024-01-05 11:22 ` [PATCH 07/10] accel/ivpu: Free buffer sgt on unbind Jacek Lawrynowicz
2024-01-05 16:37 ` Jeffrey Hugo
2024-01-05 11:22 ` [PATCH 08/10] accel/ivpu: Disable buffer sharing among VPU contexts Jacek Lawrynowicz
2024-01-05 16:46 ` Jeffrey Hugo
2024-01-10 10:53 ` Jacek Lawrynowicz
2024-01-05 22:34 ` Carl Vanderlip
2024-01-10 10:54 ` Jacek Lawrynowicz
2024-01-05 11:22 ` [PATCH 09/10] accel/ivpu: Improve buffer object debug logs Jacek Lawrynowicz
2024-01-05 17:03 ` Jeffrey Hugo
2024-01-10 11:08 ` Jacek Lawrynowicz
2024-01-05 11:22 ` [PATCH 10/10] accel/ivpu: Remove deprecated DRM_IVPU_PARAM_CONTEXT_PRIORITY Jacek Lawrynowicz
2024-01-05 17:29 ` Jeffrey Hugo
2024-01-10 14:33 ` Jacek Lawrynowicz
2024-01-11 21:03 ` Jeffrey Hugo
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=663dc292-0aa0-367c-e2f3-ade7ffba3b94@quicinc.com \
--to=quic_jhugo@quicinc.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=jacek.lawrynowicz@linux.intel.com \
/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.