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 00C81C5DF71 for ; Tue, 2 Jun 2026 07:20:20 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 6137B10EC97; Tue, 2 Jun 2026 07:20:20 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b="GEQ/LdJ1"; dkim-atps=neutral Received: from out30-100.freemail.mail.aliyun.com (out30-100.freemail.mail.aliyun.com [115.124.30.100]) by gabe.freedesktop.org (Postfix) with ESMTPS id 5294310EC97 for ; Tue, 2 Jun 2026 07:20:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1780384816; h=Message-ID:Date:MIME-Version:Subject:To:From:Content-Type; bh=ty7WBMdgyvAcjMvYBg1GQGZHoG5B7wiV2KVXBalzJ9Y=; b=GEQ/LdJ1jcjOTc1QI3XpjCiK+3FBA4AJjXb6kHP6NdmFI5xVmYHqBEfy4I4I7/k1Y63wgowc7Q2xGUYg0nqfqVTWBtOCTmbvURdXkM1GxLDWW1bW0XeoujzjtuO8DtP0dlVZJUOU9Xkhga8u59GM0I/HSSVE0UaVcdnnfO1Tz9c= X-Alimail-AntiSpam: AC=PASS; BC=-1|-1; BR=01201311R551e4; CH=green; DM=||false|; DS=||; FP=0|-1|-1|-1|0|-1|-1|-1; HT=maildocker-contentspam011083073210; MF=guanghuifeng@linux.alibaba.com; NM=1; PH=DS; RN=28; SR=0; TI=SMTPD_---0X43U1av_1780384805; Received: from 30.221.133.117(mailfrom:guanghuifeng@linux.alibaba.com fp:SMTPD_---0X43U1av_1780384805 cluster:ay36) by smtp.aliyun-inc.com; Tue, 02 Jun 2026 15:20:14 +0800 Message-ID: <605cbc0f-dcfb-4edd-8756-1c376c9bb6ef@linux.alibaba.com> Date: Tue, 2 Jun 2026 15:20:05 +0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 3/9] iommu/generic_pt: implement iova_to_phys_length To: Jason Gunthorpe Cc: boris.brezillon@collabora.com, robh@kernel.org, steven.price@arm.com, adrian.larumbe@collabora.com, maarten.lankhorst@linux.intel.com, mripard@kernel.org, tzimmermann@suse.de, airlied@gmail.com, liviu.dudau@arm.com, joro@8bytes.org, will@kernel.org, robin.murphy@arm.com, alex@shazbot.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, iommu@lists.linux.dev, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kevin.tian@intel.com, baolu.lu@linux.intel.com, suravee.suthikulpanit@amd.com, dwmw2@infradead.org, xlpang@linux.alibaba.com, oliver.yang@linux.alibaba.com, shiyu.zsq@linux.alibaba.com, wei.guo.simon@linux.alibaba.com, alikernel-developer References: <20260529115116.GR2487554@ziepe.ca> <20260531093637.3893199-1-guanghuifeng@linux.alibaba.com> <20260531093637.3893199-4-guanghuifeng@linux.alibaba.com> <20260531235421.GW2487554@ziepe.ca> From: "guanghuifeng@linux.alibaba.com" In-Reply-To: <20260531235421.GW2487554@ziepe.ca> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit 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" 在 2026/6/1 7:54, Jason Gunthorpe 写道: > On Sun, May 31, 2026 at 05:36:31PM +0800, Guanghui Feng wrote: >> @@ -159,45 +164,51 @@ static __always_inline int __do_iova_to_phys(struct pt_range *range, void *arg, >> case PT_ENTRY_TABLE: >> return pt_descend(&pts, arg, descend_fn); >> case PT_ENTRY_OA: >> - *res = pt_entry_oa_exact(&pts); >> + data->phys = pt_entry_oa_exact(&pts); >> + data->length = BIT(pt_entry_oa_lg2sz(&pts)); > BIT is the wrong function, it uses the wrong type. log2_to_int() is > type'd properly > > This also needs to keep walking and accumulating length for > consecutive PTEs until it reaches a non-contiguity. > > The other drivers don't need to have that complexity. > > Jason pt_entry_oa_lg2sz has already considered continuous PTEs. Does this mean that multiple PTEs need to be traversed additionally for consecutive PA address mappings?