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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 4D3ABCD4851 for ; Tue, 12 May 2026 13:37:45 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 88ADF10E22B; Tue, 12 May 2026 13:37:44 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=arm.com header.i=@arm.com header.b="Hm5hOOjU"; dkim-atps=neutral Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by gabe.freedesktop.org (Postfix) with ESMTP id 08C5F10E22B for ; Tue, 12 May 2026 13:37:43 +0000 (UTC) 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 077DD1691 for ; Tue, 12 May 2026 06:37:37 -0700 (PDT) Received: from [192.168.0.1] (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 1C5C13F85F for ; Tue, 12 May 2026 06:37:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1778593062; bh=Gvl4cEd1ZiXBIpJHrKLmqu+T8vzwYIr7JhCY27iDUns=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Hm5hOOjUhFFoerjJ1gw71+sBHg+rmXr/BUFth4ipmfmLl3zt8ladf1CHx5nY9m6GK HL8oh/GGpwiRBNnf4DHNz/3sTbYOLD7hPIsCBcyD44uAgKzeSsY7fUBHcmHLbIUJE/ Auom8oc6NXpHTeEHNfE30ulK6j9R3gvIn3RZqKos= Date: Tue, 12 May 2026 14:37:21 +0100 From: Liviu Dudau To: Ketil Johnsen Cc: David Airlie , Simona Vetter , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , Jonathan Corbet , Shuah Khan , Sumit Semwal , Benjamin Gaignard , Brian Starkey , John Stultz , "T.J. Mercier" , Christian =?utf-8?B?S8O2bmln?= , Boris Brezillon , Steven Price , Daniel Almeida , Alice Ryhl , Matthias Brugger , AngeloGioacchino Del Regno , dri-devel@lists.freedesktop.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, linaro-mm-sig@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org Subject: Re: [PATCH 3/8] drm/panthor: De-duplicate FW memory section sync Message-ID: References: <20260505140516.1372388-1-ketil.johnsen@arm.com> <20260505140516.1372388-4-ketil.johnsen@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20260505140516.1372388-4-ketil.johnsen@arm.com> X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" On Tue, May 05, 2026 at 04:05:09PM +0200, Ketil Johnsen wrote: > Handle the sync to device of FW memory sections inside > panthor_fw_init_section_mem() so that the callers do not have to. > > This small improvement is also critical for protected FW sections, > so we avoid issuing memory transactions to protected memory from > CPU running in normal mode. > > Signed-off-by: Ketil Johnsen Reviewed-by: Liviu Dudau Best regards, Liviu > --- > drivers/gpu/drm/panthor/panthor_fw.c | 22 ++++++---------------- > 1 file changed, 6 insertions(+), 16 deletions(-) > > diff --git a/drivers/gpu/drm/panthor/panthor_fw.c b/drivers/gpu/drm/panthor/panthor_fw.c > index be0da5b1f3abf..0d07a133dc3af 100644 > --- a/drivers/gpu/drm/panthor/panthor_fw.c > +++ b/drivers/gpu/drm/panthor/panthor_fw.c > @@ -446,6 +446,7 @@ static void panthor_fw_init_section_mem(struct panthor_device *ptdev, > struct panthor_fw_section *section) > { > bool was_mapped = !!section->mem->kmap; > + struct sg_table *sgt; > int ret; > > if (!section->data.size && > @@ -464,6 +465,11 @@ static void panthor_fw_init_section_mem(struct panthor_device *ptdev, > > if (!was_mapped) > panthor_kernel_bo_vunmap(section->mem); > + > + /* An sgt should have been requested when the kernel BO was GPU-mapped. */ > + sgt = to_panthor_bo(section->mem->obj)->dmap.sgt; > + if (!drm_WARN_ON_ONCE(&ptdev->base, !sgt)) > + dma_sync_sgtable_for_device(ptdev->base.dev, sgt, DMA_TO_DEVICE); > } > > /** > @@ -626,7 +632,6 @@ static int panthor_fw_load_section_entry(struct panthor_device *ptdev, > section_size = hdr.va.end - hdr.va.start; > if (section_size) { > u32 cache_mode = hdr.flags & CSF_FW_BINARY_IFACE_ENTRY_CACHE_MODE_MASK; > - struct panthor_gem_object *bo; > u32 vm_map_flags = 0; > u64 va = hdr.va.start; > > @@ -663,14 +668,6 @@ static int panthor_fw_load_section_entry(struct panthor_device *ptdev, > } > > panthor_fw_init_section_mem(ptdev, section); > - > - bo = to_panthor_bo(section->mem->obj); > - > - /* An sgt should have been requested when the kernel BO was GPU-mapped. */ > - if (drm_WARN_ON_ONCE(&ptdev->base, !bo->dmap.sgt)) > - return -EINVAL; > - > - dma_sync_sgtable_for_device(ptdev->base.dev, bo->dmap.sgt, DMA_TO_DEVICE); > } > > if (hdr.va.start == CSF_MCU_SHARED_REGION_START) > @@ -724,17 +721,10 @@ panthor_reload_fw_sections(struct panthor_device *ptdev, bool full_reload) > struct panthor_fw_section *section; > > list_for_each_entry(section, &ptdev->fw->sections, node) { > - struct sg_table *sgt; > - > if (!full_reload && !(section->flags & CSF_FW_BINARY_IFACE_ENTRY_WR)) > continue; > > panthor_fw_init_section_mem(ptdev, section); > - > - /* An sgt should have been requested when the kernel BO was GPU-mapped. */ > - sgt = to_panthor_bo(section->mem->obj)->dmap.sgt; > - if (!drm_WARN_ON_ONCE(&ptdev->base, !sgt)) > - dma_sync_sgtable_for_device(ptdev->base.dev, sgt, DMA_TO_DEVICE); > } > } > > -- > 2.43.0 > -- ==================== | I would like to | | fix the world, | | but they're not | | giving me the | \ source code! / --------------- ¯\_(ツ)_/¯