From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=217.140.110.172 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796315895; b=bdMFxp91KhqZWn/5ey71yonunhLQbj5+pV/PFe2nkr2yyvZ3qsNbK/XgY6+lPc3lYaur 3Pp2ul+vyHSxKFZrqH2gzeXOlVMd3HaNxS2DE4dUtunzlAKTM4jYDhj+zBJLmx+/W7pe8 BjZEL6OD4cirpLAIu9e3D08E8wWG/Pml+l0l8uh6vCvIWysNT2g42RE4Ve1+3NhcvY9a0 TRLkStlxWQBqpPTkfcjqA28ZvAaOzIIvjpDDJS7d3j9AqhXW2JA1BgM9DKYibYkR/ZTiL kb/GwyWcvpw5xy7/YEulpO8FZHa4RlJ0U9WlOvtKTBItkMLBHFXEDcvDvFFds9mv3EQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796315895; h=DMARC-Filter:Received:Received:DKIM-Signature:Message-ID:Date: MIME-Version:User-Agent:Subject:To:Cc:References:From: Content-Language:In-Reply-To:Content-Type:Content-Transfer-Encoding; bh=TlZjKS3uPdLigbk+E/Ex8B8QcbDx5iwFnG5iGKitdx8=; b=iH/xlPkkwu3j8A+s8V2Q/D9kJQl8QOEmPI82jiaS2EZZaDzVd6w1AFb9dIbCKxn4Vu2y bziVqurnf6la1OeIiYBxGUCp3dvLM/wk+szwsGtkByK2auvlsW11Dh885K08sDtTKRWzZ ihige7WBXPtaoQcQ+T70nFHrs2L3Fyr68n7jdhCCGhnltkNAXly+i6w+JEYqy5tkAjP5V 9y93S6LHVhQehlsTmZTs+e1VnB4kSdveAjiorpVrY8wtBZ2BKQb6mJsLJdevU5UcwgKjF gL4WklJB/3vHDYhg9RiGuG6bVfC+fJbrE5AkMKSCYrMV7yN2X8xqunUX+yTep+IATgg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=arm.com; spf=pass smtp.mailfrom=arm.com; dkim=pass header.d=arm.com header.i=@arm.com header.a=rsa-sha256 header.s=foss header.b=kQdX9d66; arc=none smtp.remote-ip=217.140.110.172 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DC2BB606A322 for ; Thu, 3 Dec 2026 16:38:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org DC2BB606A322 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.a=rsa-sha256 header.s=foss header.b=kQdX9d66 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 7E7E81477; Thu, 3 Dec 2026 08:38:11 -0800 (PST) Received: from [10.57.93.206] (unknown [10.57.93.206]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 270843F86F; Thu, 3 Dec 2026 08:38:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1796315894; bh=j+1phPn6p7zZdfQAv81e1bVK9LHa9p3WaPqV3eNJDjk=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=kQdX9d66745b1Mg7vdaXyMJyjaTNQ21DtndyT8F4VZVb3fLq2XLci1rTV476wpj0h UZQmfAddYGcAzqgKA3f8ORxVxNuakKLaERA/LssojhjxpWFg6zwFAmWSF8PWiijYCP EGyc8B1SmyfgOnUb1b3ANKZvLj4h6W85VYbsBRbc= Message-ID: Date: Thu, 3 Dec 2026 16:38:10 +0000 X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2] iommu/dma: Skip iova_to_phys() on unmap when unneeded To: Joe Damato Cc: "Joerg Roedel (AMD)" , Will Deacon , iommu@lists.linux.dev, linux-kernel@vger.kernel.org References: <20261202153325.2819538-1-joe@dama.to> <38e90198-68c0-4cb3-959b-4f4c7759a18d@arm.com> From: Robin Murphy Content-Language: en-GB In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 2026-12-02 5:50 pm, Joe Damato wrote: > On Wed, Dec 02, 2026 at 04:36:27PM +0000, Robin Murphy wrote: >> On 02/12/2026 3:33 pm, Joe Damato wrote: >>> iommu_dma_unmap_phys() looks up the physical address of every mapping >>> with iommu_iova_to_phys() before unmapping it. >>> >>> This is unneeded for a coherent device that does not use a swiotlb. >>> Skipping this saves a page table walk. >>> >>> iommu_dma_sync_single_for_cpu() already skips the walk for these >>> devices, so do the same in iommu_dma_unmap_phys(). >>> >>> For these devices the WARN_ON(!phys) is no longer reached, so unmapping >>> an IOVA that is not mapped no longer warns there. CONFIG_DMA_API_DEBUG >>> still catches this class of driver bug. >> >> Thanks Joe! >> >> Acked-by: Robin Murphy >> >> Although now I've made the mistake of remembering we have the higher-level >> dma_dev_need_sync() thing as well, and starting to wonder how much that now >> might effectively cover these conditions both here and for >> iommu_dma_sync_single*()... > > I see what you mean. I did not know about that before, my bad. > > Your call: I would be happy to send a followup cleaning up all of those sites > to use dma_dev_need_sync once the patch above is applied Yeah, I think it makes sense to land this as-is as a targeted functional improvement for unmaps following the internal sync logic, but if you do fancy reasoning through whether the overlap with the external sync flag really is 100% for all possible configurations, partial syncs, etc. then that can be done as a more general cleanup of the whole lot on top. (And otherwise, I'd probably end up taking a look at some point now anyway, as it seems sufficiently adjacent to another DMA flag thing I have in mind...) Cheers, Robin.