From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9EB5AE6749B for ; Mon, 22 Dec 2025 11:44:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-Type:In-Reply-To:From:References:Cc:To:Subject:MIME-Version:Date: Message-ID:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=b8a+f6gl2Wz4m9MuhI4zrCSwDqPsTlNmo2n2XvDMCD0=; b=XRcHUSszHOKdYIKSVBaPdgFVCc WN6d6WVg49WrooIo1l3Pz3exbaeY4oN4G3IM5I15hNCMgu0anyutmRQlcmTI+G3YHo69LTJvuvirU 0VXC2uuK24dYaoLMZPHVRzzqLQTMNZyKn+5uywwwq+84kQJnZ22W5Y7QF2Uznz5Da3XU/1FfDFmVj Ky3bXcq5D+O9j4fWMuxGtyL2ha4/BomMlOj/1M4Gy1j0iQ62q2MgS+C3H+OsKeVV/l+aefn3NJVGn XswxxIXq8PZLiSROYkY53VYLAGbqg4ra62JphvZCejLKjqEWck0dGyJTmTqb+dNpvGB4ntTaNmvNl BZFiCS5w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1vXeKn-0000000Dg9I-3iNQ; Mon, 22 Dec 2025 11:44:17 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1vXeKj-0000000Dg8E-3jZC; Mon, 22 Dec 2025 11:44:15 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 9F56C497; Mon, 22 Dec 2025 03:43:53 -0800 (PST) Received: from [10.1.29.18] (e122027.cambridge.arm.com [10.1.29.18]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 1FD983F778; Mon, 22 Dec 2025 03:43:55 -0800 (PST) Message-ID: Date: Mon, 22 Dec 2025 11:43:53 +0000 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 3/4] drm/panthor: Implement reading shader_present from nvmem To: Nicolas Frattaroli , Boris Brezillon , Liviu Dudau , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Matthias Brugger , AngeloGioacchino Del Regno , Ulf Hansson Cc: Chen-Yu Tsai , Chia-I Wu , kernel@collabora.com, dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-pm@vger.kernel.org References: <20251220-mt8196-shader-present-v2-0-45b1ff1dfab0@collabora.com> <20251220-mt8196-shader-present-v2-3-45b1ff1dfab0@collabora.com> From: Steven Price Content-Language: en-GB In-Reply-To: <20251220-mt8196-shader-present-v2-3-45b1ff1dfab0@collabora.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20251222_034414_098643_8B341DE4 X-CRM114-Status: GOOD ( 20.02 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 20/12/2025 18:49, Nicolas Frattaroli wrote: > On some platforms, notably MediaTek MT8196, the shader_present bitmask > in the Mali GPU register for it has cores enabled that may be faulty. > The true shader_present bitmask is found in an efuse instead. > > Implement reading shader_present from an nvmem cell if one is present, > falling back to the Mali register if it's absent. The error codes are > trickled up through to the probe function so that probe deferral works. > > Signed-off-by: Nicolas Frattaroli Reviewed-by: Steven Price > --- > drivers/gpu/drm/panthor/panthor_hw.c | 36 ++++++++++++++++++++++++++++++------ > 1 file changed, 30 insertions(+), 6 deletions(-) > > diff --git a/drivers/gpu/drm/panthor/panthor_hw.c b/drivers/gpu/drm/panthor/panthor_hw.c > index 87ebb7ae42c4..80c521784cd3 100644 > --- a/drivers/gpu/drm/panthor/panthor_hw.c > +++ b/drivers/gpu/drm/panthor/panthor_hw.c > @@ -1,6 +1,7 @@ > // SPDX-License-Identifier: GPL-2.0 or MIT > /* Copyright 2025 ARM Limited. All rights reserved. */ > > +#include > #include > > #include "panthor_device.h" > @@ -109,7 +110,25 @@ static char *get_gpu_model_name(struct panthor_device *ptdev) > return "(Unknown Mali GPU)"; > } > > -static void panthor_gpu_info_init(struct panthor_device *ptdev) > +static int overload_shader_present(struct panthor_device *ptdev) > +{ > + u64 contents; > + int ret; > + > + ret = nvmem_cell_read_variable_le_u64(ptdev->base.dev, "shader-present", > + &contents); > + if (!ret) > + ptdev->gpu_info.shader_present = contents; > + else if (ret == -ENOENT) > + return 0; > + else > + return dev_err_probe(ptdev->base.dev, ret, > + "Failed to read shader-present nvmem cell\n"); > + > + return 0; > +} > + > +static int panthor_gpu_info_init(struct panthor_device *ptdev) > { > unsigned int i; > > @@ -143,13 +162,18 @@ static void panthor_gpu_info_init(struct panthor_device *ptdev) > ptdev->gpu_info.tiler_present = gpu_read64(ptdev, GPU_TILER_PRESENT); > ptdev->gpu_info.l2_present = gpu_read64(ptdev, GPU_L2_PRESENT); > } > + > + return overload_shader_present(ptdev); > } > > -static void panthor_hw_info_init(struct panthor_device *ptdev) > +static int panthor_hw_info_init(struct panthor_device *ptdev) > { > u32 major, minor, status; > + int ret; > > - panthor_gpu_info_init(ptdev); > + ret = panthor_gpu_info_init(ptdev); > + if (ret) > + return ret; > > major = GPU_VER_MAJOR(ptdev->gpu_info.gpu_id); > minor = GPU_VER_MINOR(ptdev->gpu_info.gpu_id); > @@ -172,6 +196,8 @@ static void panthor_hw_info_init(struct panthor_device *ptdev) > "shader_present=0x%0llx l2_present=0x%0llx tiler_present=0x%0llx", > ptdev->gpu_info.shader_present, ptdev->gpu_info.l2_present, > ptdev->gpu_info.tiler_present); > + > + return 0; > } > > static int panthor_hw_bind_device(struct panthor_device *ptdev) > @@ -218,7 +244,5 @@ int panthor_hw_init(struct panthor_device *ptdev) > if (ret) > return ret; > > - panthor_hw_info_init(ptdev); > - > - return 0; > + return panthor_hw_info_init(ptdev); > } >