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 63DF8FF8855 for ; Tue, 5 May 2026 15:48:02 +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:MIME-Version:References:In-Reply-To:Message-ID:Subject:Cc:To: From:Date:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=0BlUIvajVVZjwDFT+u8DujFiAoSkX6zSEMepdkLSaXI=; b=fuQS1zw3Ne1TiPqi0zaKEOR4wB JQS8IPdnGThHBnAWjx4G+neA50aiS/bUDxGJydXkxGDwGx+/m8xUL/XDv0wpA1JtxtAhzeQSWOR2h LvWlpQQmNPb5grRZ3+ck06oaiPN9jZwvR266h5FK80ylkyt0oRHxGsCEU/Vt5n6p7B+iBfyqBDW6A XgppspNiDW4y7NX9caA7xDVdfi4a6LyMT9Eeq75oZq06TPWoSt4DNHA72AEsRC/OutoHss7dtc680 itKkj8KkOcu7iQQqqiwYVw00NiIz1BBHBxRZz32m79vBnn5iLYcjqsFeau//ZNEf7gt59s2k0gAtW sI6tH1FA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1wKI05-0000000GiPi-2H50; Tue, 05 May 2026 15:47:57 +0000 Received: from bali.collaboradmins.com ([148.251.105.195]) by bombadil.infradead.org with esmtps (Exim 4.98.2 #2 (Red Hat Linux)) id 1wKI02-0000000GiOr-37bM; Tue, 05 May 2026 15:47:55 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1777996072; bh=H4hfN0oMllcNEjPVcnu5mtrqlmjlS8rr/h+c93usT34=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=R2dNc5lIkfxzRIdZj5bE8Pht0wT+bdc6exMlFXhdxJPXapmX818okKAW7mgW1UrYb 8URaR1dfHXkCp7xtrPHFWe2ueSq5ODIvOPNSGEGz9qtMftbWPaYkYWNPP/l9aRoyai 71B+VdiYYtw6yBQdsLnY1GzSCftSI1ZSlc6Tnwhjy45MEg+NgIVngeyb1aBBlAEkxA +fd/A5I9KZ0tpKdG20e7dlT8nu1X94pzHbUyJXkN6GESzab2ksAA2eeVE/9g1pXD+3 pDtyD7zPhFi1UUaEW+14i0+wICfppaGGofhpheacoMmeKqr6Kvks84NZOPdxeYTBXL +gUM9nF3JSs6g== Received: from fedora (unknown [100.64.0.11]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (prime256v1) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: bbrezillon) by bali.collaboradmins.com (Postfix) with ESMTPSA id 362F817E05FC; Tue, 5 May 2026 17:47:51 +0200 (CEST) Date: Tue, 5 May 2026 17:47:47 +0200 From: Boris Brezillon 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?= , Steven Price , Liviu Dudau , 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: <20260505174747.3c199a81@fedora> In-Reply-To: <20260505140516.1372388-4-ketil.johnsen@arm.com> References: <20260505140516.1372388-1-ketil.johnsen@arm.com> <20260505140516.1372388-4-ketil.johnsen@arm.com> Organization: Collabora X-Mailer: Claws Mail 4.4.0 (GTK 3.24.52; x86_64-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20260505_084754_928564_E2004DC7 X-CRM114-Status: GOOD ( 20.43 ) 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 Tue, 5 May 2026 16:05:09 +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: Boris Brezillon > --- > 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); > } > } >