mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Alexandru Dadu <alexandru.dadu@imgtec.com>
To: Alessio Belle <alessio.belle@imgtec.com>,
	Luigi Santivetti <luigi.santivetti@imgtec.com>,
	Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
	Maxime Ripard <mripard@kernel.org>,
	Thomas Zimmermann <tzimmermann@suse.de>,
	David Airlie <airlied@gmail.com>, Simona Vetter <simona@ffwll.ch>,
	Paul Walmsley <pjw@kernel.org>,
	"Palmer Dabbelt" <palmer@dabbelt.com>,
	Albert Ou <aou@eecs.berkeley.edu>,
	"Alexandre Ghiti" <alex@ghiti.fr>, Kees Cook <kees@kernel.org>,
	"Gustavo A. R. Silva" <gustavoars@kernel.org>
Cc: <imagination@lists.freedesktop.org>,
	<dri-devel@lists.freedesktop.org>, <linux-kernel@vger.kernel.org>,
	<linux-riscv@lists.infradead.org>,
	<linux-hardening@vger.kernel.org>,
	Alexandru Dadu <alexandru.dadu@imgtec.com>
Subject: [PATCH 6/6] drm/imagination: Avoid loop in configure_seg_mmu()
Date: Wed, 25 Nov 2026 13:48:34 +0200	[thread overview]
Message-ID: <20261125-b4-commonize-fw-segment-loading-v1-6-69657fa52ac3@imgtec.com> (raw)
In-Reply-To: <20261125-b4-commonize-fw-segment-loading-v1-0-69657fa52ac3@imgtec.com>

From: Alessio Belle <alessio.belle@imgtec.com>

Use recently added API to directly find the one section the code is
looking for.

Signed-off-by: Alessio Belle <alessio.belle@imgtec.com>
Signed-off-by: Alexandru Dadu <alexandru.dadu@imgtec.com>
---
 drivers/gpu/drm/imagination/pvr_fw_meta.c | 50 +++++++++++++++----------------
 1 file changed, 24 insertions(+), 26 deletions(-)

diff --git a/drivers/gpu/drm/imagination/pvr_fw_meta.c b/drivers/gpu/drm/imagination/pvr_fw_meta.c
index 53143a6ad2ca..92f54c846169 100644
--- a/drivers/gpu/drm/imagination/pvr_fw_meta.c
+++ b/drivers/gpu/drm/imagination/pvr_fw_meta.c
@@ -353,32 +353,30 @@ configure_seg_id(u64 seg_out_addr, u32 seg_base, u32 seg_limit, u32 seg_id,
 static void
 configure_seg_mmu(struct pvr_device *pvr_dev, u32 **boot_conf_ptr)
 {
-	u64 data_seg_gpu_addr =
-		pvr_fw_obj_get_gpu_addr(pvr_dev->fw_dev.mem.segments[PVR_FW_SEGMENT_DATA].obj);
-	u64 seg_out_addr_top =
-		ROGUE_FW_SEGMMU_OUTADDR_TOP_SLC(MMU_CONTEXT_MAPPING_FWPRIV,
-						ROGUE_FW_SEGMMU_META_BIFDM_ID);
-
-	pvr_for_each_fw_section_desc(pvr_dev->fw_dev.metadata, desc) {
-		/*
-		 * FW code is using the bootloader segment which is already
-		 * configured on boot. FW coremem code and data don't use the
-		 * segment MMU. Only the FW data segment needs to be configured.
-		 */
-		if (desc->segment == PVR_FW_SEGMENT_DATA) {
-			u32 seg_id = ROGUE_FW_SEGMMU_DATA_ID;
-			u64 seg_out_addr = data_seg_gpu_addr;
-
-			seg_out_addr += desc->alloc_offset;
-			seg_out_addr |= seg_out_addr_top;
-
-			/* Write the sequence to the bootldr. */
-			configure_seg_id(seg_out_addr, desc->base_addr,
-					 desc->size, seg_id, boot_conf_ptr);
-
-			break;
-		}
-	}
+	const struct pvr_fw_section_desc *data =
+		pvr_fw_get_section_desc(pvr_dev, PVR_FW_SECTION_PRIVATE_DATA);
+	struct pvr_fw_object *data_obj =
+		pvr_dev->fw_dev.mem.segments[PVR_FW_SEGMENT_DATA].obj;
+	u64 data_gpu_addr = pvr_fw_obj_get_gpu_addr(data_obj);
+	u64 seg_out_addr = data_gpu_addr + data->alloc_offset;
+	u32 data_base_addr = data->base_addr;
+	u32 data_size = data->size;
+
+	/*
+	 * FW code is using the bootloader segment which is already configured on boot.
+	 * FW coremem code and data don't use the segment MMU. Only the FW data segment
+	 * needs to be configured.
+	 */
+
+	seg_out_addr |= ROGUE_FW_SEGMMU_OUTADDR_TOP_SLC(MMU_CONTEXT_MAPPING_FWPRIV,
+							ROGUE_FW_SEGMMU_META_BIFDM_ID);
+
+	/* Write the sequence to the bootloader. */
+	configure_seg_id(seg_out_addr,
+			 data_base_addr,
+			 data_size,
+			 ROGUE_FW_SEGMMU_DATA_ID,
+			 boot_conf_ptr);
 }
 
 static void

-- 
2.43.0


      parent reply	other threads:[~2026-11-25 11:49 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-25 11:48 [PATCH 0/6] drm/imagination: Commonize firmware segment loading Alexandru Dadu
2026-11-25 11:48 ` [PATCH 1/6] drm/imagination: Remove get_fw_obj_gpu_addr() Alexandru Dadu
2026-11-25 11:48 ` [PATCH 2/6] drm/imagination: Fix size of FW header members Alexandru Dadu
2026-11-25 11:48 ` [PATCH 3/6] drm/imagination: Save metadata from firmware Alexandru Dadu
2026-11-25 11:48 ` [PATCH 4/6] drm/imagination: Release firmware after init Alexandru Dadu
2026-11-25 11:48 ` [PATCH 5/6] drm/imagination: Generalize FW segment loading Alexandru Dadu
2026-11-25 11:48 ` Alexandru Dadu [this message]

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=20261125-b4-commonize-fw-segment-loading-v1-6-69657fa52ac3@imgtec.com \
    --to=alexandru.dadu@imgtec.com \
    --cc=airlied@gmail.com \
    --cc=alessio.belle@imgtec.com \
    --cc=alex@ghiti.fr \
    --cc=aou@eecs.berkeley.edu \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=gustavoars@kernel.org \
    --cc=imagination@lists.freedesktop.org \
    --cc=kees@kernel.org \
    --cc=linux-hardening@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=luigi.santivetti@imgtec.com \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=mripard@kernel.org \
    --cc=palmer@dabbelt.com \
    --cc=pjw@kernel.org \
    --cc=simona@ffwll.ch \
    --cc=tzimmermann@suse.de \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®