From nobody Sun Feb 8 09:10:53 2026 Received: from mail-lj1-f181.google.com (mail-lj1-f181.google.com [209.85.208.181]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4C7A416FF30 for ; Fri, 5 Apr 2024 15:31:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712331088; cv=none; b=A50tWBLTBLu538Bn+Xw/4c0jsSvRyCwEiclVc/YxpFwiYhLDym+3VPI+CQ40/gSy4IalKb3InVF8tYELfMAqts5wAvmMbyX/UMLdASmfuW2hcMAl+wsTG849jNRJ4SwgpjQSiGYzFMZmO/4bVdxo2Hx/BzB2DTn9i98vnDezNWg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712331088; c=relaxed/simple; bh=cXC6o2KXoVoS1fxorVEDM5VMh0EzbI3z75qBmbAsSQ8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RN9bg7V8PYI0wTZGoQTsb5foRsW04QaMPjGE1UVEDOk2yxAVeYTJce3uwPnusbUh6ToNVPenqVYSvnZhh6G9HKcwnpw75HtGFLGv0XZ1bcG+y1KcAhAdi/nVi9SEzCPldZialWcGm5PXe75ielc7D2Dkvq6gU53o2mLk9Le5Zmg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=U2wu2uFK; arc=none smtp.client-ip=209.85.208.181 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="U2wu2uFK" Received: by mail-lj1-f181.google.com with SMTP id 38308e7fff4ca-2d6eedf3e99so32931601fa.1 for ; Fri, 05 Apr 2024 08:31:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1712331084; x=1712935884; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=GLmSQbomn7jjoFYvGpaYKKjdNIRUVaXuPm21MTZkhWI=; b=U2wu2uFK+r9nak6VfOD2tQ45SFekynxIZffe6Gh49zdOSPAXxeA09xwEFLFVi4YQT/ TX60cyd+qLr96QZXS/1wkSf/Jc55DHq6W/6ZZ4Ez6TaqVfpeyUGTr3zPneD4Gw9GHFMA bk7aJXjkti2ami41yYCfcZ1j/5NpB1nfK1c8FHJYiuFDDrDH+0xY690aDFxgpnxszwVc ITyXkeSaUkYakc8jo2O1g/m4kBhrIVP8PNDzSrtjORQX8sbygo6xr69P0oYzO8bCdjCq M0LbTUjadcejn0yY/j94AByRPcTVVeEsskVMjaHhVPErFe1vn7lpVLvKji53c4cZ5G5Q cFrg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712331084; x=1712935884; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=GLmSQbomn7jjoFYvGpaYKKjdNIRUVaXuPm21MTZkhWI=; b=c5WpP0IRzTvBCG/3Wo+95T135htblp6eIn2p53TZBi1c/jTK/lvLRHThEpqycsouq9 aE39wFVld9XtG27EQb0nndUtLOlMn39avpQZZG8tZGJg02gNVXxFNUySSGOvWNHnub3/ tWS52R6MldZ+Icc7w7upkya3AS0SQ/wEQUGElID9ywA6Fy59MEHwTnCZG30N0f7eo9hz gwdRp8NgstGAsmuwlntrlGcitVI+7E1ijCR75wk1+B9pfOOravmY76mpikM5Vt4EZArL WJTRlsX/MaxVCRqjPMTveRFjICwIKao2Rp76OUvr0k19Hw2GrX1jGfuKcfdDfbtszVPB lhng== X-Forwarded-Encrypted: i=1; AJvYcCXY0UtnAi7Se7yGORNWdlUzKPyr2bAqbUyhMdr6g3a+5BSPKcT4OPTy/GTi0W0xSZMZPz3y4zsilNp1gf3KMqFy7LFyrhivOGWyym1d X-Gm-Message-State: AOJu0Yx5Qix5Y0OPkVSWPsS+j2R39aFVzcRm+nzDOdXy4n5y61isc1qz EjZ7Q/J3ohQx2WPeMbrrc42HHifMbYd991D0HON1hDax2pmfOiahCmK6j1dWnPk= X-Google-Smtp-Source: AGHT+IE7RgZin2OZ+qw13032XMFBtJshqJC/13QOVSjiQyPWaNMLxo/xWtEHTWGKxvCq6iMC0ubYRQ== X-Received: by 2002:a05:6402:3716:b0:56d:c757:9379 with SMTP id ek22-20020a056402371600b0056dc7579379mr3103612edb.15.1712331064035; Fri, 05 Apr 2024 08:31:04 -0700 (PDT) Received: from mosaic.enunes.eu (ip-78-45-66-209.bb.vodafone.cz. [78.45.66.209]) by smtp.gmail.com with ESMTPSA id ca19-20020aa7cd73000000b0056dfda8eef3sm906752edb.54.2024.04.05.08.31.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Apr 2024 08:31:03 -0700 (PDT) From: Erico Nunes To: Qiang Yu , anarsoul@gmail.com, dri-devel@lists.freedesktop.org, lima@lists.freedesktop.org Cc: Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , christian.koenig@amd.com, megi@xff.cz, linux-kernel@vger.kernel.org, Erico Nunes Subject: [PATCH v2 1/3] drm/lima: add mask irq callback to gp and pp Date: Fri, 5 Apr 2024 17:29:49 +0200 Message-ID: <20240405152951.1531555-2-nunes.erico@gmail.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240405152951.1531555-1-nunes.erico@gmail.com> References: <20240405152951.1531555-1-nunes.erico@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" This is needed because we want to reset those devices in device-agnostic code such as lima_sched. In particular, masking irqs will be useful before a hard reset to prevent race conditions. Signed-off-by: Erico Nunes --- drivers/gpu/drm/lima/lima_bcast.c | 12 ++++++++++++ drivers/gpu/drm/lima/lima_bcast.h | 3 +++ drivers/gpu/drm/lima/lima_gp.c | 8 ++++++++ drivers/gpu/drm/lima/lima_pp.c | 18 ++++++++++++++++++ drivers/gpu/drm/lima/lima_sched.h | 1 + 5 files changed, 42 insertions(+) diff --git a/drivers/gpu/drm/lima/lima_bcast.c b/drivers/gpu/drm/lima/lima_= bcast.c index fbc43f243c54..6d000504e1a4 100644 --- a/drivers/gpu/drm/lima/lima_bcast.c +++ b/drivers/gpu/drm/lima/lima_bcast.c @@ -43,6 +43,18 @@ void lima_bcast_suspend(struct lima_ip *ip) =20 } =20 +int lima_bcast_mask_irq(struct lima_ip *ip) +{ + bcast_write(LIMA_BCAST_BROADCAST_MASK, 0); + bcast_write(LIMA_BCAST_INTERRUPT_MASK, 0); + return 0; +} + +int lima_bcast_reset(struct lima_ip *ip) +{ + return lima_bcast_hw_init(ip); +} + int lima_bcast_init(struct lima_ip *ip) { int i; diff --git a/drivers/gpu/drm/lima/lima_bcast.h b/drivers/gpu/drm/lima/lima_= bcast.h index 465ee587bceb..cd08841e4787 100644 --- a/drivers/gpu/drm/lima/lima_bcast.h +++ b/drivers/gpu/drm/lima/lima_bcast.h @@ -13,4 +13,7 @@ void lima_bcast_fini(struct lima_ip *ip); =20 void lima_bcast_enable(struct lima_device *dev, int num_pp); =20 +int lima_bcast_mask_irq(struct lima_ip *ip); +int lima_bcast_reset(struct lima_ip *ip); + #endif diff --git a/drivers/gpu/drm/lima/lima_gp.c b/drivers/gpu/drm/lima/lima_gp.c index 6b354e2fb61d..e15295071533 100644 --- a/drivers/gpu/drm/lima/lima_gp.c +++ b/drivers/gpu/drm/lima/lima_gp.c @@ -233,6 +233,13 @@ static void lima_gp_task_mmu_error(struct lima_sched_p= ipe *pipe) lima_sched_pipe_task_done(pipe); } =20 +static void lima_gp_task_mask_irq(struct lima_sched_pipe *pipe) +{ + struct lima_ip *ip =3D pipe->processor[0]; + + gp_write(LIMA_GP_INT_MASK, 0); +} + static int lima_gp_task_recover(struct lima_sched_pipe *pipe) { struct lima_ip *ip =3D pipe->processor[0]; @@ -365,6 +372,7 @@ int lima_gp_pipe_init(struct lima_device *dev) pipe->task_error =3D lima_gp_task_error; pipe->task_mmu_error =3D lima_gp_task_mmu_error; pipe->task_recover =3D lima_gp_task_recover; + pipe->task_mask_irq =3D lima_gp_task_mask_irq; =20 return 0; } diff --git a/drivers/gpu/drm/lima/lima_pp.c b/drivers/gpu/drm/lima/lima_pp.c index d0d2db0ef1ce..a4a2ffe6527c 100644 --- a/drivers/gpu/drm/lima/lima_pp.c +++ b/drivers/gpu/drm/lima/lima_pp.c @@ -429,6 +429,9 @@ static void lima_pp_task_error(struct lima_sched_pipe *= pipe) =20 lima_pp_hard_reset(ip); } + + if (pipe->bcast_processor) + lima_bcast_reset(pipe->bcast_processor); } =20 static void lima_pp_task_mmu_error(struct lima_sched_pipe *pipe) @@ -437,6 +440,20 @@ static void lima_pp_task_mmu_error(struct lima_sched_p= ipe *pipe) lima_sched_pipe_task_done(pipe); } =20 +static void lima_pp_task_mask_irq(struct lima_sched_pipe *pipe) +{ + int i; + + for (i =3D 0; i < pipe->num_processor; i++) { + struct lima_ip *ip =3D pipe->processor[i]; + + pp_write(LIMA_PP_INT_MASK, 0); + } + + if (pipe->bcast_processor) + lima_bcast_mask_irq(pipe->bcast_processor); +} + static struct kmem_cache *lima_pp_task_slab; static int lima_pp_task_slab_refcnt; =20 @@ -468,6 +485,7 @@ int lima_pp_pipe_init(struct lima_device *dev) pipe->task_fini =3D lima_pp_task_fini; pipe->task_error =3D lima_pp_task_error; pipe->task_mmu_error =3D lima_pp_task_mmu_error; + pipe->task_mask_irq =3D lima_pp_task_mask_irq; =20 return 0; } diff --git a/drivers/gpu/drm/lima/lima_sched.h b/drivers/gpu/drm/lima/lima_= sched.h index 6bd4f3b70109..85b23ba901d5 100644 --- a/drivers/gpu/drm/lima/lima_sched.h +++ b/drivers/gpu/drm/lima/lima_sched.h @@ -80,6 +80,7 @@ struct lima_sched_pipe { void (*task_error)(struct lima_sched_pipe *pipe); void (*task_mmu_error)(struct lima_sched_pipe *pipe); int (*task_recover)(struct lima_sched_pipe *pipe); + void (*task_mask_irq)(struct lima_sched_pipe *pipe); =20 struct work_struct recover_work; }; --=20 2.44.0 From nobody Sun Feb 8 09:10:53 2026 Received: from mail-ed1-f44.google.com (mail-ed1-f44.google.com [209.85.208.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4AEA617107E for ; Fri, 5 Apr 2024 15:31:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712331069; cv=none; b=j5X4P0U2dHIwGfhESHGUsrxPGqwqxkrXAbqGfDH/9iBdQppSNlto9buOV75BIG/xObmr0I2UhuZIDpOYiA+aiqH7kVkHcz15K+z5Nog3YfkPjJXuDx7NEGGijZyku42XwmpQG9t+rg+jvLpkUUbzrGiueF44n4QxkXuC4mFH9QQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712331069; c=relaxed/simple; bh=UfcObyrPF0XuVQDFk7S8F4W/87r0ONr3OPfGcZ6NTsw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QZLYSVwGeX87qr4sN7dfhxEluVSkMC4k34RU0WrQXGdzOHw5sB6iUg0lcw9qnoOvN5d2+gvENcdOz/YiofnWaEdObmJWazNusiAV7MWeMCZYSHuhYfOS5d32PBGEwtfLz3Y1oTsue4qqq5D8swZY/djJQeq2b/yW0kJf+ryJR+8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=N8QLlFG8; arc=none smtp.client-ip=209.85.208.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="N8QLlFG8" Received: by mail-ed1-f44.google.com with SMTP id 4fb4d7f45d1cf-56e2b41187aso1852580a12.1 for ; Fri, 05 Apr 2024 08:31:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1712331065; x=1712935865; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=3Wc7eRrLLTaY9o1kesXYpNbXIiaQ79me6bUkH9C+N8s=; b=N8QLlFG87N+yu2RVO4LKcv01H6BAd7Z8uZC3GL2TRMeyO9Ljmt/erl6euhNiem1iFL LbEPqdzfk6DgMnZcEMe2qPOHlsgJuuAurZW1n51zdOdGWHzMAtfLDVphm7LPNSrxBTNO q2FvTtYlpY7eaOew1mxPV/rOfocuVfPRAfAvAlhLEIQe30nm+sONigVghPUonyMaaBYh jnHC83mvMfMw0ER0JM+1SAmnjX4DvQhOKDhwi8VYL7vOCc4rKx6dcFgvA1t8Xugc/Qb0 MiHgtKUdlGdBEHn3/65QzkL80HyYXIn6CDF9UrwykLZCuETqUuRRDbcUsidEndyKkx9S aV1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712331065; x=1712935865; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=3Wc7eRrLLTaY9o1kesXYpNbXIiaQ79me6bUkH9C+N8s=; b=c9702KoIOzd92m83B+1KCACcQV231rs3SnmESFmCjKW4I+vG1avz3NTJ9aztCRNTnv +0cOyH0iBrY/N27gcjdyTWWmMmQt8hlJ3SRZ0ClaJWocHWvZfcbOa5py0oQS92tro11w dC0Ecj3K4jtCMYhhJTLRT7VFB1tWbkGBctenLxvIfVm1nHOprH/wOpjlHSlUNm6RBkIT JHq9eaklN7qLUeILuYhTuImo55YdWvPqDu3YpbjY0vCtMPwvoJHgc99F+/XV+3heuVac OKNU64oJ1T10tDMgzGUF8/Jeamp5S6ZmiHhZBbxKSZ1N6h2ypV6lxAz2NXp/W0U697cF GtZA== X-Forwarded-Encrypted: i=1; AJvYcCW2nlAcUgBq//OIRPGSR4MfuofiXUNjnF0ER6lp6B9UPZ2sXtDJnQdK0xyCdSivzw5wJrSmxYusHPQFVyOxO/AIoxMZRpxccqC5y1WT X-Gm-Message-State: AOJu0YwFqCKl2MHulw6dJ/acz4uKzIlPvlRusUy+1yhan+kDW/bZuDgN CjmADMVIQQaJ0PEyBgVjrfiUHGqecYqDCkDnYOwbdx74u5RMXc1ucSZai+YBXL4= X-Google-Smtp-Source: AGHT+IG8XRGLoAvJSk3V6tIUxHh1MIP1Ubq65h4+cLa/zgO/WLETmMWp1Z1DJ/2HAU/3sW4nJR2XQw== X-Received: by 2002:a05:6402:e81:b0:56c:292f:84da with SMTP id h1-20020a0564020e8100b0056c292f84damr2264828eda.17.1712331065319; Fri, 05 Apr 2024 08:31:05 -0700 (PDT) Received: from mosaic.enunes.eu (ip-78-45-66-209.bb.vodafone.cz. [78.45.66.209]) by smtp.gmail.com with ESMTPSA id ca19-20020aa7cd73000000b0056dfda8eef3sm906752edb.54.2024.04.05.08.31.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Apr 2024 08:31:04 -0700 (PDT) From: Erico Nunes To: Qiang Yu , anarsoul@gmail.com, dri-devel@lists.freedesktop.org, lima@lists.freedesktop.org Cc: Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , christian.koenig@amd.com, megi@xff.cz, linux-kernel@vger.kernel.org, Erico Nunes Subject: [PATCH v2 2/3] drm/lima: include pp bcast irq in timeout handler check Date: Fri, 5 Apr 2024 17:29:50 +0200 Message-ID: <20240405152951.1531555-3-nunes.erico@gmail.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240405152951.1531555-1-nunes.erico@gmail.com> References: <20240405152951.1531555-1-nunes.erico@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" In commit 53cb55b20208 ("drm/lima: handle spurious timeouts due to high irq latency") a check was added to detect an unexpectedly high interrupt latency timeout. With further investigation it was noted that on Mali-450 the pp bcast irq may also be a trigger of race conditions against the timeout handler, so add it to this check too. Signed-off-by: Erico Nunes --- drivers/gpu/drm/lima/lima_sched.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/gpu/drm/lima/lima_sched.c b/drivers/gpu/drm/lima/lima_= sched.c index 00b19adfc888..66841503a618 100644 --- a/drivers/gpu/drm/lima/lima_sched.c +++ b/drivers/gpu/drm/lima/lima_sched.c @@ -422,6 +422,8 @@ static enum drm_gpu_sched_stat lima_sched_timedout_job(= struct drm_sched_job *job */ for (i =3D 0; i < pipe->num_processor; i++) synchronize_irq(pipe->processor[i]->irq); + if (pipe->bcast_processor) + synchronize_irq(pipe->bcast_processor->irq); =20 if (dma_fence_is_signaled(task->fence)) { DRM_WARN("%s unexpectedly high interrupt latency\n", lima_ip_name(ip)); --=20 2.44.0 From nobody Sun Feb 8 09:10:53 2026 Received: from mail-ed1-f50.google.com (mail-ed1-f50.google.com [209.85.208.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 20A40171090 for ; Fri, 5 Apr 2024 15:31:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712331069; cv=none; b=REwbkfG/SCoqjn59Akl2Igjywsk1W3h1JfTSjEJHe8OGjNNZen6x7pX00T6mTKwYoWzsmkYFbEYKDaVH+pzvDL0LwvgnXT/qmyD0zrTwchQuH31WeDSLPCAfZ9pQcnXYGRGXJaRO7pm/yZ5uhoyqammjBkXwdNXDXnMwN5YSRoI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712331069; c=relaxed/simple; bh=2Kt4SH2gGiz91yQulAqzYzGqZughTmXtdSCmlRBjfH4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Zx/x0ZtfE56EMbP1kDhUhtxhRShm6Y0ie409835RubknYXwrIv7EQF0aYn67J7vz6/r4DugD9t+Gyv/s0krLgPBLxJVYstVFqMnSir93qU1dooGeopdCPmreSj+2jMZqsamc1URFOHTki41Wx9Q92tfhLEXJlkqkDxQGK+Y6KkA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Y3RtmLph; arc=none smtp.client-ip=209.85.208.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Y3RtmLph" Received: by mail-ed1-f50.google.com with SMTP id 4fb4d7f45d1cf-56e37503115so345742a12.1 for ; Fri, 05 Apr 2024 08:31:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1712331066; x=1712935866; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=f26+JW8g/Mxdh9BcUQdPk6EFgK15mePlKBpnnLhSmdE=; b=Y3RtmLphm9Nnng82H+9/94NnAoLvx3YkqvkXZ7DWJqZAHH4G+ga8KQwHhu6KW1m/u7 hfVNRV4P6segm1+D9U5jN6NxZCCG+OQN9uEpyTIbxOE2HwGsD5Nf5DwjnK/cfq0yXDa/ F1nLVciiaevlmxNs3zTPL0Ye+qOknWtEeUTbxmfrGhuWPQwQcfeadbZY3YiyaqfSxl/s dAf23sdlmgWaYtTK35X3bW5O/DIKQgPJr6kZhFzWgCKro0h6qbwufr455vG1FcC8GMRi Fr1b7musirkOvZmrGn8AVd0jpExaPGUUCIN9P5MG+E62anKKTrdXb16qdYp4wa7bfwEN WBEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712331066; x=1712935866; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=f26+JW8g/Mxdh9BcUQdPk6EFgK15mePlKBpnnLhSmdE=; b=TNPI7sMM9eRdty38K5XBWfqTGUyd9vFiOojC4kiJCu2IXLjCWC00DipH8LEZw7ERIj 09XhCtTtl3Y7943C0yIeVUrqtxLRBeGWFTnDV5R2OxiRiW8tqEPaFByarEOmLhhGxdMo ijsrojolVN+znOW3V+/QCukbljoOeD5aQl+3+DYzwEM8k/ku/ZaKTI7IynOL1NjEPc5b z7K6psfsqz8cmmdfP9/1FT2tFg6s1m9LYAPw/rsnbpcZEPiRyrkUWEC4l2lyjVFBqLJm D2Azv3F9VqZGUpxAEOLcPQYxaVl2PhLI6odKptR/DjElVGoX8AB1PrMUH25Ww9JdETm1 BSyQ== X-Forwarded-Encrypted: i=1; AJvYcCWJFqhjngk4lVxRxmOUWNDu20mAi8CiCtPrbcM7H3g5yEM2hc3q2phnUEKnZcfzKr8yC3J9NA3nj23LIDBbBZ8qZLZdOE3kmfiDfBmt X-Gm-Message-State: AOJu0Yy4raN5zhz/bmYxrtyqZhuqh3sOY+EFFwaNh4KATBnp1jMZq1a9 K0EnHm9wyz+5OVIhDIx6tAOOVN/RuBHOAoVPoMd/szIvL40DFDmn X-Google-Smtp-Source: AGHT+IEOoVbeSJ/OSUmQPcHN5mMxTwHjjaoROo5lfs6LhyW4u0ipSb8oGcAGiW5kwuMmalkC8ave+w== X-Received: by 2002:a50:f60b:0:b0:56c:3feb:8898 with SMTP id c11-20020a50f60b000000b0056c3feb8898mr1359874edn.3.1712331066460; Fri, 05 Apr 2024 08:31:06 -0700 (PDT) Received: from mosaic.enunes.eu (ip-78-45-66-209.bb.vodafone.cz. [78.45.66.209]) by smtp.gmail.com with ESMTPSA id ca19-20020aa7cd73000000b0056dfda8eef3sm906752edb.54.2024.04.05.08.31.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Apr 2024 08:31:05 -0700 (PDT) From: Erico Nunes To: Qiang Yu , anarsoul@gmail.com, dri-devel@lists.freedesktop.org, lima@lists.freedesktop.org Cc: Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , christian.koenig@amd.com, megi@xff.cz, linux-kernel@vger.kernel.org, Erico Nunes Subject: [PATCH v2 3/3] drm/lima: mask irqs in timeout path before hard reset Date: Fri, 5 Apr 2024 17:29:51 +0200 Message-ID: <20240405152951.1531555-4-nunes.erico@gmail.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240405152951.1531555-1-nunes.erico@gmail.com> References: <20240405152951.1531555-1-nunes.erico@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" There is a race condition in which a rendering job might take just long enough to trigger the drm sched job timeout handler but also still complete before the hard reset is done by the timeout handler. This runs into race conditions not expected by the timeout handler. In some very specific cases it currently may result in a refcount imbalance on lima_pm_idle, with a stack dump such as: [10136.669170] WARNING: CPU: 0 PID: 0 at drivers/gpu/drm/lima/lima_devfreq.= c:205 lima_devfreq_record_idle+0xa0/0xb0 ... [10136.669459] pc : lima_devfreq_record_idle+0xa0/0xb0 ... [10136.669628] Call trace: [10136.669634] lima_devfreq_record_idle+0xa0/0xb0 [10136.669646] lima_sched_pipe_task_done+0x5c/0xb0 [10136.669656] lima_gp_irq_handler+0xa8/0x120 [10136.669666] __handle_irq_event_percpu+0x48/0x160 [10136.669679] handle_irq_event+0x4c/0xc0 We can prevent that race condition entirely by masking the irqs at the beginning of the timeout handler, at which point we give up on waiting for that job entirely. The irqs will be enabled again at the next hard reset which is already done as a recovery by the timeout handler. Signed-off-by: Erico Nunes Reviewed-by: Qiang Yu --- drivers/gpu/drm/lima/lima_sched.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/gpu/drm/lima/lima_sched.c b/drivers/gpu/drm/lima/lima_= sched.c index 66841503a618..bbf3f8feab94 100644 --- a/drivers/gpu/drm/lima/lima_sched.c +++ b/drivers/gpu/drm/lima/lima_sched.c @@ -430,6 +430,13 @@ static enum drm_gpu_sched_stat lima_sched_timedout_job= (struct drm_sched_job *job return DRM_GPU_SCHED_STAT_NOMINAL; } =20 + /* + * The task might still finish while this timeout handler runs. + * To prevent a race condition on its completion, mask all irqs + * on the running core until the next hard reset completes. + */ + pipe->task_mask_irq(pipe); + if (!pipe->error) DRM_ERROR("%s job timeout\n", lima_ip_name(ip)); =20 --=20 2.44.0