From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9F42A1DE89A for ; Mon, 20 Oct 2025 08:57:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760950653; cv=none; b=h1ELK7f4Y1Gue3Xc4F9kN2GKz02/3y4fiIcTwADKzh0qsXvJyVgTL1q9ISb6Zfskh5EhChCqP381jHxqYjDB7Foye5BwP8RctUpS+cPP9Kln+Gl3DFwWSXstz5JXPOOtNbsNnjaJo32qQvbtbD5hCV4tBf6Gu5/hHvMIZy97mFI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760950653; c=relaxed/simple; bh=1E1ZZTYmgyce6z44b0/HtYM1gk7UTjBU19C4xT40fJU=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=ZUJWPPsHURUJ+no0I97fWj2n2eoS+eFToi6/tubLJhx88R4UArpuR6oxzAEqi5mIcHBMggEtBZi61rHiJ+xt8E5u2JWOxceK+IYkWnCC/YHpJ5CVfpEr8s1vK2xNAlbGseO5YV3iFeX2IUmmNYCZeSsER7F4p7C1LoXWP77UslA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com 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 2188A1F91; Mon, 20 Oct 2025 01:57:23 -0700 (PDT) Received: from [10.57.36.117] (unknown [10.57.36.117]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id A6FF83F66E; Mon, 20 Oct 2025 01:57:28 -0700 (PDT) Message-ID: Date: Mon, 20 Oct 2025 09:57:28 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v1 02/10] drm/panthor: Add arch-specific panthor_hw binding To: Karunika Choo , dri-devel@lists.freedesktop.org Cc: nd@arm.com, Boris Brezillon , Liviu Dudau , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , linux-kernel@vger.kernel.org References: <20251014094337.1009601-1-karunika.choo@arm.com> <20251014094337.1009601-3-karunika.choo@arm.com> From: Steven Price Content-Language: en-GB In-Reply-To: <20251014094337.1009601-3-karunika.choo@arm.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 14/10/2025 10:43, Karunika Choo wrote: > This patch adds the framework for binding to a specific panthor_hw > structure based on the architecture major value parsed from the GPU_ID > register. This is in preparation of enabling architecture-specific > behaviours based on GPU_ID. > > This framework allows a single panthor_hw structure to be shared across > multiple architectures should there be minimal changes between them via > the arch_min and arch_max field of the panthor_hw_entry structure, > instead of duplicating the structure across multiple architectures. > > Signed-off-by: Karunika Choo Looks fine (although see my comment in the previous patch about potentially squashing into this one). Reviewed-by: Steven Price > --- > drivers/gpu/drm/panthor/panthor_device.h | 4 ++ > drivers/gpu/drm/panthor/panthor_hw.c | 49 ++++++++++++++++++++++++ > drivers/gpu/drm/panthor/panthor_hw.h | 6 +++ > 3 files changed, 59 insertions(+) > > diff --git a/drivers/gpu/drm/panthor/panthor_device.h b/drivers/gpu/drm/panthor/panthor_device.h > index a764111359d2..1457c1255f1f 100644 > --- a/drivers/gpu/drm/panthor/panthor_device.h > +++ b/drivers/gpu/drm/panthor/panthor_device.h > @@ -26,6 +26,7 @@ struct panthor_device; > struct panthor_gpu; > struct panthor_group_pool; > struct panthor_heap_pool; > +struct panthor_hw; > struct panthor_job; > struct panthor_mmu; > struct panthor_fw; > @@ -122,6 +123,9 @@ struct panthor_device { > /** @csif_info: Command stream interface information. */ > struct drm_panthor_csif_info csif_info; > > + /** @hw: GPU-specific data. */ > + struct panthor_hw *hw; > + > /** @gpu: GPU management data. */ > struct panthor_gpu *gpu; > > diff --git a/drivers/gpu/drm/panthor/panthor_hw.c b/drivers/gpu/drm/panthor/panthor_hw.c > index 326a9db0b5c2..b6e7401327c3 100644 > --- a/drivers/gpu/drm/panthor/panthor_hw.c > +++ b/drivers/gpu/drm/panthor/panthor_hw.c > @@ -8,6 +8,28 @@ > #define GPU_PROD_ID_MAKE(arch_major, prod_major) \ > (((arch_major) << 24) | (prod_major)) > > +/** struct panthor_hw_entry - HW arch major to panthor_hw binding entry */ > +struct panthor_hw_entry { > + /** @arch_min: Minimum supported architecture major value (inclusive) */ > + u8 arch_min; > + > + /** @arch_max: Maximum supported architecture major value (inclusive) */ > + u8 arch_max; > + > + /** @hwdev: Pointer to panthor_hw structure */ > + struct panthor_hw *hwdev; > +}; > + > +static struct panthor_hw panthor_hw_arch_v10 = {}; > + > +static struct panthor_hw_entry panthor_hw_match[] = { > + { > + .arch_min = 10, > + .arch_max = 13, > + .hwdev = &panthor_hw_arch_v10, > + }, > +}; > + > static char *get_gpu_model_name(struct panthor_device *ptdev) > { > const u32 gpu_id = ptdev->gpu_info.gpu_id; > @@ -116,6 +138,29 @@ static void panthor_hw_info_init(struct panthor_device *ptdev) > ptdev->gpu_info.tiler_present); > } > > +static int panthor_hw_bind_device(struct panthor_device *ptdev) > +{ > + struct panthor_hw *hdev = NULL; > + const u32 arch_major = GPU_ARCH_MAJOR(ptdev->gpu_info.gpu_id); > + int i = 0; > + > + for (i = 0; i < ARRAY_SIZE(panthor_hw_match); i++) { > + struct panthor_hw_entry *entry = &panthor_hw_match[i]; > + > + if (arch_major >= entry->arch_min && arch_major <= entry->arch_max) { > + hdev = entry->hwdev; > + break; > + } > + } > + > + if (!hdev) > + return -EOPNOTSUPP; > + > + ptdev->hw = hdev; > + > + return 0; > +} > + > static int panthor_hw_gpu_id_init(struct panthor_device *ptdev) > { > ptdev->gpu_info.gpu_id = gpu_read(ptdev, GPU_ID); > @@ -133,6 +178,10 @@ int panthor_hw_init(struct panthor_device *ptdev) > if (ret) > return ret; > > + ret = panthor_hw_bind_device(ptdev); > + if (ret) > + return ret; > + > panthor_hw_info_init(ptdev); > > return 0; > diff --git a/drivers/gpu/drm/panthor/panthor_hw.h b/drivers/gpu/drm/panthor/panthor_hw.h > index 0af6acc6aa6a..39752de3e7ad 100644 > --- a/drivers/gpu/drm/panthor/panthor_hw.h > +++ b/drivers/gpu/drm/panthor/panthor_hw.h > @@ -6,6 +6,12 @@ > > struct panthor_device; > > +/** > + * struct panthor_hw - GPU specific register mapping and functions > + */ > +struct panthor_hw { > +}; > + > int panthor_hw_init(struct panthor_device *ptdev); > > #endif /* __PANTHOR_HW_H__ */