From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qv1-f46.google.com (mail-qv1-f46.google.com [209.85.219.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 339D01B652E for ; Mon, 1 Jun 2026 14:31:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.46 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780324307; cv=none; b=HnLihcXHr/UfjAxnp+qKohGrZXd+xx/6I4j//ouwzOFzLNK93kUsA/030VY9h4mKnZbgtSpejPGi1YTNxGlmhCk8D5Vip5FRS4ZC6YtiVzHy8MOV1/Gv4hb8PuOQcNe54nW5max4s6OE2ESPgL6MWqYa8TxYYEt5vvxvfVKUiNg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780324307; c=relaxed/simple; bh=5+eRi2P0IhQkVffVIzXnn4OZsEFB83MX7U5Varec24o=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=bQBFPGQr3AzlYw4mCmFuM2PbcVkahNGi1C2UJgvxcdzEJ0pIZHfA1vD1G3XQWfYqadwFgTGHLCrHQvnkDQaf87qSsIP39Dcm+KeKI3R5bIzEP4Rn2anwkhyInWynXd9YyVaVWO2k/l5Lw7bG+ZDZ5sJGAh6saTdWDKFAbVi440w= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ziepe.ca; spf=pass smtp.mailfrom=ziepe.ca; dkim=pass (2048-bit key) header.d=ziepe.ca header.i=@ziepe.ca header.b=JdyJJ8sx; arc=none smtp.client-ip=209.85.219.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ziepe.ca Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ziepe.ca Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ziepe.ca header.i=@ziepe.ca header.b="JdyJJ8sx" Received: by mail-qv1-f46.google.com with SMTP id 6a1803df08f44-8ce65629acaso19507116d6.3 for ; Mon, 01 Jun 2026 07:31:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; t=1780324305; x=1780929105; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=xvsjMwD/preuv2Qmrdbeq0ug8WdJ2lDONAxR5Koyc4Q=; b=JdyJJ8sx6DPMY8MKUH6D6u6nGE9il93ad4F9Ngrlt12PIvA3JTcyXAAtZMiBJPBVd/ MJlsm4OdJU/jsLyDYTgRjx8pyAq1NJJC3ODYltMiKfAK3muEpooRie5U4KLvheM5vifD 6lWXEqD+Ngl52sqfFwkWcY7w7W9Mqv+dUm0ulVtMvILOoapPmK9CwatLIRhBwiWMoPZa o2C2G71CyPo/TLc4/ExB0pdU7IGzy4M+Vlvtd84hzgLtC9H4PNOJta8v6E81V808wigO vGdjvTGcKuQZqbTY/9llS5XFc/BmPusmh5LkYTPlrjIuvzaRGh53gL28L6U8s9hB3EWA 2Akg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780324305; x=1780929105; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=xvsjMwD/preuv2Qmrdbeq0ug8WdJ2lDONAxR5Koyc4Q=; b=TyvoyMGuuiQeFol3paVEMonB6G8npswKl/P2oud4m+t2XAjbHZkFaOgU/VVMfo+FV/ q2hcn8fNOT+vF7IQRbHjOUmUKwoK59Kv1uH9jUdtqIngFgXbijdx8aKsfWSPgO6rYkKx KvXmVfatChBryH2Hpj0nVHE3uM7poB6Ir0/L8cF7dydp+a5iBBDh3bG/cxA5/ER7Zh0o pq0OTdBdQ6oXcDJj6YCnthdDROw5B1WrULR0taczzKwQc0kvmbqwBocf8UYVtpiIv29E VnApE6q5gVwyOXJT0zGASA1uEMb93r1GJJYmvD+1N0yuKfXJMjexVmMZh4fmTYvtNLk3 cR+g== X-Forwarded-Encrypted: i=1; AFNElJ9B8QOcQXstcj3z/GUKsUA09q0XWqBax1m1IWwR5yls7l2NoE+JHoPMhbpi9Vdo77ndhS/qL68idlwIWWI=@vger.kernel.org X-Gm-Message-State: AOJu0Yz0bKVLz62vQVS4Dt+YUqaNXp4cWwl/W3CcIQC77F8VPJPbPfFi Mc4UB7S9+4UnklTPjAVcbePXtj20tMNcPWw84bZgOnIwg9zDDKB7p1IdybJE+Ui+2KE= X-Gm-Gg: Acq92OGvnlfYLs1gTHS1nGM0jnufhSYEStMtDMzhoHYoVabns2I00RqbcdgyL+eRgCw 2sm9Rz/YVVpKvb3WOvqgD6qqFXj6OT9qBVKsfgwD7W8Lq7Nhv268cZaXArZPkQG8KPIxTAxW98N hxJNbIFOQoFo5+CQFpVuN7lVnN3OBLOgYK7MOtaahcb05cRq8dLpzCDY+vKl/F8J2I+H3yQS+gv bhUah5mlZpGW333a63/vxInOLTL2EdVyiNr6D8UoS+uhGd/NczbwtTilhlch3LgUaz+irXe0AQD 2ETFdecRT2C1iV56wCXXa1Ly1tHxR9w7SqeJk7OJq5k4h2k+tJHVAKu6L7gDTkApqlFb+yG7wkA EV1JCeRiuyThkerICsJjHuhu2dFVMIU5MYdqPRhQYfFdC3iFf//gL631oXDArAyPkAebnkCiMkl RKZoInDQ/Y1i8032UCKuag/tqIVbiPoHxO2PmAOtD0wT8rBsoW8sC6hHyMJCbytqetlfMZIiBph BAHZjU3Sbzo0UC8 X-Received: by 2002:a05:6214:2502:b0:8ce:b2e9:a4b9 with SMTP id 6a1803df08f44-8ceb2e9a80cmr38343386d6.12.1780324305009; Mon, 01 Jun 2026 07:31:45 -0700 (PDT) Received: from ziepe.ca (crbknf0213w-47-54-130-67.pppoe-dynamic.high-speed.nl.bellaliant.net. [47.54.130.67]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-8ccea064f97sm94142866d6.13.2026.06.01.07.31.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Jun 2026 07:31:44 -0700 (PDT) Received: from jgg by wakko with local (Exim 4.97) (envelope-from ) id 1wU3g7-00000001mzs-39uT; Mon, 01 Jun 2026 11:31:43 -0300 Date: Mon, 1 Jun 2026 11:31:43 -0300 From: Jason Gunthorpe To: "guanghuifeng@linux.alibaba.com" 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 Subject: Re: [PATCH 1/9] iommu: introduce iova_to_phys_length in iommu_domain_ops Message-ID: <20260601143143.GZ2487554@ziepe.ca> References: <20260529115116.GR2487554@ziepe.ca> <20260531093637.3893199-1-guanghuifeng@linux.alibaba.com> <20260531093637.3893199-2-guanghuifeng@linux.alibaba.com> <20260531235148.GV2487554@ziepe.ca> <20260601134322.GY2487554@ziepe.ca> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: On Mon, Jun 01, 2026 at 10:14:27PM +0800, guanghuifeng@linux.alibaba.com wrote: > > 在 2026/6/1 21:43, Jason Gunthorpe 写道: > > On Mon, Jun 01, 2026 at 04:41:48PM +0800, guanghuifeng@linux.alibaba.com wrote: > > > > > +/** > > > > > + * iommu_iova_to_phys_length - Translate IOVA and return mapping page size > > > > > + * @domain: IOMMU domain to query > > > > > + * @iova: IO virtual address to translate > > > > > + * @mapped_length: Output parameter for the PTE page size (e.g. 4KB/2MB/1GB) > > > > > + * > > > > > + * Like iommu_iova_to_phys() but additionally returns the page size of the > > > > > + * PTE mapping at @iova through @mapped_length. > > > > > + * > > > > > + * Return: The physical address for the given IOVA, or 0 if no translation. > > > > > + */ > > > > When introducing the new function I would like to fix this 0 error as > > > > well, it should return PHYS_MAX for error > > > Implementations such as arm_smmu_iova_to_phys/DOMAIN_NS(iova_to_phys) > > > all use a return value of 0 as an invalid state, so 0 is used as the > > > representation of an invalid state to maintain compatibility. > > I know, but this bad choice has already caused bugs so if we are > > changing everything I would prefer we fix it. > > OK, there are a lot of changes in the current commit. This issue will be > fixed in a subsequent series patch. If you follow the plan I gave you then introduce the new function using the new return code and only support it in iommupt, then you can convert the other drivers to the new function one by one including the return code. Jason