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 BAD7DD10BE3 for ; Sat, 26 Oct 2024 05:55:35 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id DF5F810E21F; Sat, 26 Oct 2024 05:55:34 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=linux.dev header.i=@linux.dev header.b="Bx0cYzVm"; dkim-atps=neutral Received: from out-170.mta0.migadu.com (out-170.mta0.migadu.com [91.218.175.170]) by gabe.freedesktop.org (Postfix) with ESMTPS id 9062C10E21F for ; Sat, 26 Oct 2024 05:55:32 +0000 (UTC) Message-ID: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1729922130; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Q/BnGth3qVS+yRRXcpYmVqCPs6VRyBTiCHU46Zrgryw=; b=Bx0cYzVmFGQ6sTpwDqh78AeWGOU0V9iskS2y8jBjslpBYmBPYe+whDrUW4cPn2r0llovq6 0TRQ82XcVDEI8clYOGwx3hpVwOwpM09OgCG8T81NlsjFJBcaSSYDrmfzTnnxloeMMezCJX vcRMnIt/pkvhQvGZkYd+ykoN0tToEJE= Date: Sat, 26 Oct 2024 13:55:18 +0800 MIME-Version: 1.0 Subject: Re: [PATCH 2/3] drm/etnaviv: Map and unmap the GPU VA range with respect to its user size To: Lucas Stach , Russell King , Christian Gmeiner Cc: David Airlie , Simona Vetter , etnaviv@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org References: <20241004194207.1013744-1-sui.jingfeng@linux.dev> <20241004194207.1013744-3-sui.jingfeng@linux.dev> <13b9c1bde7f0534f7f3c576126def206bdafd60c.camel@pengutronix.de> Content-Language: en-US X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Sui Jingfeng In-Reply-To: <13b9c1bde7f0534f7f3c576126def206bdafd60c.camel@pengutronix.de> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT 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" Hi, On 2024/10/7 18:17, Lucas Stach wrote: >> >> @@ -104,21 +108,7 @@ static int etnaviv_iommu_map(struct etnaviv_iommu_context *context, u32 iova, >> static void etnaviv_iommu_unmap(struct etnaviv_iommu_context *context, u32 iova, >> struct sg_table *sgt, unsigned len) >> { >> - struct scatterlist *sg; >> - unsigned int da = iova; >> - int i; >> - >> - for_each_sgtable_dma_sg(sgt, sg, i) { >> - size_t bytes = sg_dma_len(sg) + sg->offset; Why the length of a single SG segment is `sg_dma_len(sg) + sg->offset` here? >> - etnaviv_context_unmap(context, da, bytes); >> - >> - VERB("unmap[%d]: %08x(%zx)", i, iova, bytes); >> - >> - BUG_ON(!PAGE_ALIGNED(bytes)); >> - >> - da += bytes; >> - } >> + etnaviv_context_unmap(context, iova, len); > This drops some sanity checks, but I have only ever seen them fire when > we had other kernel memory corruption issues, so I'm fine with the > simplification you did here. Isn't that 'sg_dma_len(sg)' itself is the length of its backing memory ? > Regards, > Lucas -- Best regards, Sui