From nobody Thu Feb 12 02:59:36 2026 Received: from mail-ej1-f47.google.com (mail-ej1-f47.google.com [209.85.218.47]) (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 800D529CFA for ; Mon, 1 Apr 2024 22:43:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712011421; cv=none; b=MvwetWmuX61tVUQQ8VFFJeo/68Y6v3Izc1CprcT9WQ0gK4i8O5e28PtrY1P8/Ea3gBBl/ehMBG+Kj1zO2NsaOf8vVttp8OPdd8/LIT+Orvojsk22SxA0ufSe6hQavhl5zzGt3406R9G4NCkCoClhHVVnH3PBTFgsdA01PzAtUXE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712011421; c=relaxed/simple; bh=8Vf9Ny+dWGd97zbUbBdSuKZ4GxKDtWvZM5jazU0S0rI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=kd4uB4o8VAregFOL2s7feHwoc4JSE9B2+p2lzwKkTrPXNHA/tOOcGCalAdw4Gdra7v8oU39nEyqZ4yKizwm3jDocSPS8dNMrTHKkTExmThIolsamMinMDKRvvVgT6EcQYK/m3ZNAYLViWxe7lK0cMz3n7Vb/VVESsl7ZpQ8p3Gw= 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=I6s/V2gT; arc=none smtp.client-ip=209.85.218.47 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="I6s/V2gT" Received: by mail-ej1-f47.google.com with SMTP id a640c23a62f3a-a4734ae95b3so575973366b.0 for ; Mon, 01 Apr 2024 15:43:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1712011418; x=1712616218; 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=x6wOlanwnyuahzpz0MfNPGNkl1E4bit5o3/S2j1nuGQ=; b=I6s/V2gTNaHr/H61CGCr4Y56mVVsCQ2D650G0a8qM/fQR3suGN8d7bE2+GPi9Ah7kx vnyy8TyxqFJUyXmfgWP9fwJQWmEt1oTMWAzfp5a2P7pKI/4haFHSoUMAnVLRDIAlY3M0 kLhNQorchn5UFpy4z/dCCYIsvitsJPtJ9Ar5F+vZd0qm5UeQrAHVIN6Rs1Cg+F6OAb1w TDfZZUZjexEvMd7u+oQVnsWvU7FBtDjeyR2zHiEX8bLBl5W727P9Xrn378fPSlZZNTMW iwGA0ga391EA1lG6uEW9fHyIRex76NoWH9WAccye1OeLb3LH7VV1KJfigmdcTHtepgBo 9xKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712011418; x=1712616218; 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=x6wOlanwnyuahzpz0MfNPGNkl1E4bit5o3/S2j1nuGQ=; b=w3HQclzs7dmPCeKUjd2CXRotEHU5fHJTsEXBWmgZh0iHXpYBB5H3ntP60LkIKRYDTi TXmmILKkdArEsZaeXgtlvdYuwnwfFzwc+p0DpReqG+7rawwN1fi3yxvb0iumM/3IoeY1 6Z6dCVNF5r72sJOpz2B7zRTuSNyNXHB2/RnWWqapLF01/zA4ovbogebTslAcDhw7v70v vSb07n+JHnCd3svUFXNlw1+Gad1n7EZ6T9x9nVjnPDAkxhNGDuLlHvCfyEHaf+tHcJlj XovCa6ifw2ZWcdVYj8cYrHjuVP9MX7U9IFn1T0vepfYMCfpCGT5Yx0R+z2HeJVcHyIaC ckGQ== X-Forwarded-Encrypted: i=1; AJvYcCUCtkNCSv8rWJjrVdMugBjB7w5wUAojgNjwk8jxjm7dnO9jF9qzhwdB217gnVkMACvXqKFMN6b5T+MRwrBELt7oVIss+q9D50k6PTGo X-Gm-Message-State: AOJu0YwjbZwK7FsSMJK9y2bYg+ZfnSvWH0PiyktrJgwwtEUVquynZ6Tv PHPco1FRxn2SoHPKaahjlNGUpxfQ821Yl1uxMINpdh+p3zych9qq X-Google-Smtp-Source: AGHT+IHHemzLxeLUMG8/nYzOVnRQOJhwt+KswDgE2bL/9MkeZyGspToRNzYF/9xt03CRuCgLz0TmVw== X-Received: by 2002:a17:906:494e:b0:a4e:69b5:9835 with SMTP id f14-20020a170906494e00b00a4e69b59835mr2677589ejt.6.1712011417805; Mon, 01 Apr 2024 15:43:37 -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 c3-20020a170906340300b00a4739efd7cesm5796808ejb.60.2024.04.01.15.43.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Apr 2024 15:43:37 -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 , linux-kernel@vger.kernel.org, Erico Nunes Subject: [PATCH 1/2] drm/lima: fix shared irq handling on driver remove Date: Tue, 2 Apr 2024 00:43:28 +0200 Message-ID: <20240401224329.1228468-2-nunes.erico@gmail.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240401224329.1228468-1-nunes.erico@gmail.com> References: <20240401224329.1228468-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" lima uses a shared interrupt, so the interrupt handlers must be prepared to be called at any time. At driver removal time, the clocks are disabled early and the interrupts stay registered until the very end of the remove process due to the devm usage. This is potentially a bug as the interrupts access device registers which assumes clocks are enabled. A crash can be triggered by removing the driver in a kernel with CONFIG_DEBUG_SHIRQ enabled. This patch frees the interrupts at each lima device finishing callback so that the handlers are already unregistered by the time we fully disable clocks. Signed-off-by: Erico Nunes --- drivers/gpu/drm/lima/lima_gp.c | 2 ++ drivers/gpu/drm/lima/lima_mmu.c | 5 +++++ drivers/gpu/drm/lima/lima_pp.c | 4 ++++ 3 files changed, 11 insertions(+) diff --git a/drivers/gpu/drm/lima/lima_gp.c b/drivers/gpu/drm/lima/lima_gp.c index 6b354e2fb61d..14c39be8da90 100644 --- a/drivers/gpu/drm/lima/lima_gp.c +++ b/drivers/gpu/drm/lima/lima_gp.c @@ -338,7 +338,9 @@ int lima_gp_init(struct lima_ip *ip) =20 void lima_gp_fini(struct lima_ip *ip) { + struct lima_device *dev =3D ip->dev; =20 + devm_free_irq(dev->dev, ip->irq, ip); } =20 int lima_gp_pipe_init(struct lima_device *dev) diff --git a/drivers/gpu/drm/lima/lima_mmu.c b/drivers/gpu/drm/lima/lima_mm= u.c index e18317c5ca8c..6611e2836bf0 100644 --- a/drivers/gpu/drm/lima/lima_mmu.c +++ b/drivers/gpu/drm/lima/lima_mmu.c @@ -118,7 +118,12 @@ int lima_mmu_init(struct lima_ip *ip) =20 void lima_mmu_fini(struct lima_ip *ip) { + struct lima_device *dev =3D ip->dev; + + if (ip->id =3D=3D lima_ip_ppmmu_bcast) + return; =20 + devm_free_irq(dev->dev, ip->irq, ip); } =20 void lima_mmu_flush_tlb(struct lima_ip *ip) diff --git a/drivers/gpu/drm/lima/lima_pp.c b/drivers/gpu/drm/lima/lima_pp.c index d0d2db0ef1ce..84bec163c9ed 100644 --- a/drivers/gpu/drm/lima/lima_pp.c +++ b/drivers/gpu/drm/lima/lima_pp.c @@ -286,7 +286,9 @@ int lima_pp_init(struct lima_ip *ip) =20 void lima_pp_fini(struct lima_ip *ip) { + struct lima_device *dev =3D ip->dev; =20 + devm_free_irq(dev->dev, ip->irq, ip); } =20 int lima_pp_bcast_resume(struct lima_ip *ip) @@ -319,7 +321,9 @@ int lima_pp_bcast_init(struct lima_ip *ip) =20 void lima_pp_bcast_fini(struct lima_ip *ip) { + struct lima_device *dev =3D ip->dev; =20 + devm_free_irq(dev->dev, ip->irq, ip); } =20 static int lima_pp_task_validate(struct lima_sched_pipe *pipe, --=20 2.44.0 From nobody Thu Feb 12 02:59:36 2026 Received: from mail-lf1-f49.google.com (mail-lf1-f49.google.com [209.85.167.49]) (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 DBB155644E for ; Mon, 1 Apr 2024 22:43:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712011422; cv=none; b=E7GvnRIB4iKZ27klA8GYY7RI6Maoa5sn1n7iA/X0FiYLe1haY1droh3pmaYMo2il1fM8lcvD5jY6/HmAli5FKN7kbrxXsxeBpohzxl2TrtNqXkeNsjoQSydpXe/XlHfIq0nRnkxFT2k35zMhQEOlDkfn8pMrzwSf4Zbo/9hgfhg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712011422; c=relaxed/simple; bh=jBpaN/YpdE0GgaxsMc4l47/AyQPX9iCV5Yg0+fXm+YI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SBRdZ+7PGi6jgmG6FJ8IEPpSR0UF8Sh7PKiEJ0JtPBnRLbnQ2XxLTUgrDNpFFaPIAwk+wE1UTWU37I3ZbLuX7aL8QslfLAWYn/6w/qavUBsIqGX5RU0vF3xZCE8kmulU+aU41obvPodEga6ngRR8kdWPvh+SJGRC8c9eIT7paN4= 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=hpq6YpyV; arc=none smtp.client-ip=209.85.167.49 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="hpq6YpyV" Received: by mail-lf1-f49.google.com with SMTP id 2adb3069b0e04-513dc9d6938so5475089e87.2 for ; Mon, 01 Apr 2024 15:43:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1712011419; x=1712616219; 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=H1HRSs16ZaqWirPKX2Q82tz4rJe4xnCWFUzWP+U9GaI=; b=hpq6YpyVV9sIW3gson3PUTFTrM4962pzTGFmUHAzBEtdH6OYrTj7c4EGsyAP24Y7sn 19pkr7O4gGWN0eiJ0UD2P8pt6CsxV7LFLT3IZdmHQMBUG9NJPcCmY4M2jvXnlH3MJ/xU 16Ehfa7xaRcj6lTnJ1u8g2C2Aa+VKAoWr/0k6OKm8ayzISDzTipPaIN0KTuhtYl0Wt74 RT9EB9mRzrCQS9fIaougR3HcQYSWGspKOGgyl3Hh94UzaYeu+Xv+KwA5M+39LNmdBeEW fNcd7PuYFuN2P2oXw33Dwlg6YNBID2OIpD955xFcbdsuQs9JENRwvgxVLP7IQqnB21GM Zddw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712011419; x=1712616219; 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=H1HRSs16ZaqWirPKX2Q82tz4rJe4xnCWFUzWP+U9GaI=; b=lGZYnMTarE7TDtJY8q7PWTAI0smyUPgVzZzpsAorLgr1P3Uz85bCTsnv/rvypd//XW 46o3t3ssazs2U1zGpHkJMZmELU4WHeJXOhB0esII1ciB0j20q2lRyAC/Ik8JUjjO8hky Nn7loEG3/8y47PBWrNyI/XDTcnlIvAehUAajvYti5JU4FsqjqYjpF1/rYnk8yuLfiUde Oa5HIRLpzayEc4Bx9nCVW96cx+WmupbW+k6i5IgHUTppqtoi3SqwsX4b43BggeaikZ87 euOuT0yvUFVydR2EnRBx1TZ6hx7gNLxrlgLrpyqjuXPEMQtvQ2dFyENEvyirWATFNhWu yjfQ== X-Forwarded-Encrypted: i=1; AJvYcCUkeBh6QAI+cNFSqtH727g+VBh/LN8KT6VRJ/IvzPOYQkb6agfYVSKjxSNy1f/Sz3RHgJuHzUsnWziXj8dGKkmhGu6KqX5xUU9gCp01 X-Gm-Message-State: AOJu0YwwpV4nivx6mUvtriXuaIfmUZL7LlrLYh4xb3jDU6ARk2xWRY8o Up5fIVi++5iEndc+Ud60Uu+i0lN4H0iRiPRJqVSYA7hT3Jc3LAec X-Google-Smtp-Source: AGHT+IF5AAFDiHU2c7BlOH2GKKUyK+ACmqIyuoBaH5uCfBfF8+qL4PRYFYq9gmLKpIuJjrRfZZOWXA== X-Received: by 2002:a05:6512:3191:b0:513:d524:3790 with SMTP id i17-20020a056512319100b00513d5243790mr8255946lfe.43.1712011419012; Mon, 01 Apr 2024 15:43:39 -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 c3-20020a170906340300b00a4739efd7cesm5796808ejb.60.2024.04.01.15.43.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Apr 2024 15:43:38 -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 , linux-kernel@vger.kernel.org, Erico Nunes Subject: [PATCH 2/2] drm/lima: fix void pointer to enum lima_gpu_id cast warning Date: Tue, 2 Apr 2024 00:43:29 +0200 Message-ID: <20240401224329.1228468-3-nunes.erico@gmail.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240401224329.1228468-1-nunes.erico@gmail.com> References: <20240401224329.1228468-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" Create a simple data struct to hold compatible data so that we don't have to do the casts to void pointer to hold data. Fixes the following warning: drivers/gpu/drm/lima/lima_drv.c:387:13: error: cast to smaller integer type 'enum lima_gpu_id' from 'const void *' Signed-off-by: Erico Nunes --- drivers/gpu/drm/lima/lima_drv.c | 21 ++++++++++++++++++--- drivers/gpu/drm/lima/lima_drv.h | 5 +++++ 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/lima/lima_drv.c b/drivers/gpu/drm/lima/lima_dr= v.c index 10fd9154cc46..739c865b556f 100644 --- a/drivers/gpu/drm/lima/lima_drv.c +++ b/drivers/gpu/drm/lima/lima_drv.c @@ -371,6 +371,7 @@ static int lima_pdev_probe(struct platform_device *pdev) { struct lima_device *ldev; struct drm_device *ddev; + const struct lima_compatible *comp; int err; =20 err =3D lima_sched_slab_init(); @@ -384,7 +385,13 @@ static int lima_pdev_probe(struct platform_device *pde= v) } =20 ldev->dev =3D &pdev->dev; - ldev->id =3D (enum lima_gpu_id)of_device_get_match_data(&pdev->dev); + comp =3D of_device_get_match_data(&pdev->dev); + if (!comp) { + err =3D -ENODEV; + goto err_out0; + } + + ldev->id =3D comp->id; =20 platform_set_drvdata(pdev, ldev); =20 @@ -459,9 +466,17 @@ static void lima_pdev_remove(struct platform_device *p= dev) lima_sched_slab_fini(); } =20 +static const struct lima_compatible lima_mali400_data =3D { + .id =3D lima_gpu_mali400, +}; + +static const struct lima_compatible lima_mali450_data =3D { + .id =3D lima_gpu_mali450, +}; + static const struct of_device_id dt_match[] =3D { - { .compatible =3D "arm,mali-400", .data =3D (void *)lima_gpu_mali400 }, - { .compatible =3D "arm,mali-450", .data =3D (void *)lima_gpu_mali450 }, + { .compatible =3D "arm,mali-400", .data =3D &lima_mali400_data }, + { .compatible =3D "arm,mali-450", .data =3D &lima_mali450_data }, {} }; MODULE_DEVICE_TABLE(of, dt_match); diff --git a/drivers/gpu/drm/lima/lima_drv.h b/drivers/gpu/drm/lima/lima_dr= v.h index c738d288547b..6706c19b166e 100644 --- a/drivers/gpu/drm/lima/lima_drv.h +++ b/drivers/gpu/drm/lima/lima_drv.h @@ -7,6 +7,7 @@ #include =20 #include "lima_ctx.h" +#include "lima_device.h" =20 extern int lima_sched_timeout_ms; extern uint lima_heap_init_nr_pages; @@ -39,6 +40,10 @@ struct lima_submit { struct lima_sched_task *task; }; =20 +struct lima_compatible { + enum lima_gpu_id id; +}; + static inline struct lima_drm_priv * to_lima_drm_priv(struct drm_file *file) { --=20 2.44.0