From nobody Thu Oct 30 22:28:15 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=kernel.org ARC-Seal: i=1; a=rsa-sha256; t=1760519778; cv=none; d=zohomail.com; s=zohoarc; b=eLYevhFfp3jSlBveZT9hsv02YM229bRRSXyiFpPuh5iYosiauUjfplAO3jrZyDhXjXS2VS7N8zkcCM2jElZpBbSpgaapWNw56op1azQmev5iFTTCykGO5QmaAVo69wXem/FO5RkRsJ4lPqYL/LnSg8OJHi9nGoMg2PY03PKb2Ug= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1760519778; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=KAq9xJzmOoXx3xcoKMi/etKK6dz4o3cn8Zx5XPgyK40=; b=DMmvPDn+KNURGr0y0TuIx2YklNE3ULyRlxdqLMSaftZgzO5CmXTgC8cVfyOnoYVhblUJfCh0v2dJuNWIjUDiGQfDx3TjGi6xKVr1lDdlNx9x0odqjdG/OR7qHDbDuO6D35VOycYhfvWZLQ//IOFkcGbuv61uV6rOUpi+eISwsmg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1760519778233199.98221432893217; Wed, 15 Oct 2025 02:16:18 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1143447.1477179 (Exim 4.92) (envelope-from ) id 1v8xc6-0006zL-0F; Wed, 15 Oct 2025 09:16:06 +0000 Received: by outflank-mailman (output) from mailman id 1143447.1477179; Wed, 15 Oct 2025 09:16:05 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1v8xc5-0006zE-Tx; Wed, 15 Oct 2025 09:16:05 +0000 Received: by outflank-mailman (input) for mailman id 1143447; Wed, 15 Oct 2025 09:16:04 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1v8xZy-0002lL-3Z for xen-devel@lists.xenproject.org; Wed, 15 Oct 2025 09:13:54 +0000 Received: from tor.source.kernel.org (tor.source.kernel.org [2600:3c04:e001:324:0:1991:8:25]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 4428821d-a9a7-11f0-980a-7dc792cee155; Wed, 15 Oct 2025 11:13:52 +0200 (CEST) Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by tor.source.kernel.org (Postfix) with ESMTP id 61E8763BEB; Wed, 15 Oct 2025 09:13:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 68352C116B1; Wed, 15 Oct 2025 09:13:50 +0000 (UTC) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 4428821d-a9a7-11f0-980a-7dc792cee155 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1760519631; bh=mdWMUlQx33yhQCgB9g+eGxCMPJQasErUwNks3U6bpsY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rEwULnAPmCOdwy2UrV0khdEVG+QC189t+pWVTdsvqzsG8ClpvXbpHIclLUeiChJit Asjzi2wPxyCyNS+yOeqOuZbyh1kzi+RASrkeH6L9WKgqJ4Nep3XyQdWIfGef5UXtLl 4fNLbyDWUuVqDpN4V/R/QJ801iNpMtBJyEWeF8cCn3lbsNgTFYpOnqdjul2qpJ86io H6krcrHfE21Xptwb5fJAnvBqNCMlN327+oD4pwEgkzc1w47bMq0cyHHDbS9H+MSG3D R2WhQOt9JKWoeo1Q4OK3KDX5S1JjA3cA5tf/m6FzVx9EfGIR1d1Mk/IWVTz8mEMZz4 6XQHEQ8GGkWUw== From: Leon Romanovsky To: Marek Szyprowski , Robin Murphy , Russell King , Juergen Gross , Stefano Stabellini , Oleksandr Tyshchenko , Richard Henderson , Matt Turner , Thomas Bogendoerfer , "James E.J. Bottomley" , Helge Deller , Madhavan Srinivasan , Michael Ellerman , Nicholas Piggin , Christophe Leroy , Geoff Levand , "David S. Miller" , Andreas Larsson , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" Cc: iommu@lists.linux.dev, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, xen-devel@lists.xenproject.org, linux-alpha@vger.kernel.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, sparclinux@vger.kernel.org, Jason Gunthorpe , Jason Gunthorpe Subject: [PATCH v5 13/14] xen: swiotlb: Convert mapping routine to rely on physical address Date: Wed, 15 Oct 2025 12:12:59 +0300 Message-ID: <20251015-remove-map-page-v5-13-3bbfe3a25cdf@kernel.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251015-remove-map-page-v5-0-3bbfe3a25cdf@kernel.org> References: <20251015-remove-map-page-v5-0-3bbfe3a25cdf@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" X-Mailer: b4 0.15-dev Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @kernel.org) X-ZM-MESSAGEID: 1760519779129158500 From: Leon Romanovsky Switch to .map_phys callback instead of .map_page. Reviewed-by: Jason Gunthorpe Signed-off-by: Leon Romanovsky --- drivers/xen/grant-dma-ops.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/drivers/xen/grant-dma-ops.c b/drivers/xen/grant-dma-ops.c index 29257d2639db..14077d23f2a1 100644 --- a/drivers/xen/grant-dma-ops.c +++ b/drivers/xen/grant-dma-ops.c @@ -163,18 +163,22 @@ static void xen_grant_dma_free_pages(struct device *d= ev, size_t size, xen_grant_dma_free(dev, size, page_to_virt(vaddr), dma_handle, 0); } =20 -static dma_addr_t xen_grant_dma_map_page(struct device *dev, struct page *= page, - unsigned long offset, size_t size, +static dma_addr_t xen_grant_dma_map_phys(struct device *dev, phys_addr_t p= hys, + size_t size, enum dma_data_direction dir, unsigned long attrs) { struct xen_grant_dma_data *data; + unsigned long offset =3D offset_in_page(phys); unsigned long dma_offset =3D xen_offset_in_page(offset), pfn_offset =3D XEN_PFN_DOWN(offset); unsigned int i, n_pages =3D XEN_PFN_UP(dma_offset + size); grant_ref_t grant; dma_addr_t dma_handle; =20 + if (unlikely(attrs & DMA_ATTR_MMIO)) + return DMA_MAPPING_ERROR; + if (WARN_ON(dir =3D=3D DMA_NONE)) return DMA_MAPPING_ERROR; =20 @@ -190,7 +194,7 @@ static dma_addr_t xen_grant_dma_map_page(struct device = *dev, struct page *page, =20 for (i =3D 0; i < n_pages; i++) { gnttab_grant_foreign_access_ref(grant + i, data->backend_domid, - pfn_to_gfn(page_to_xen_pfn(page) + i + pfn_offset), + pfn_to_gfn(page_to_xen_pfn(phys_to_page(phys)) + i + pfn_offset), dir =3D=3D DMA_TO_DEVICE); } =20 @@ -199,7 +203,7 @@ static dma_addr_t xen_grant_dma_map_page(struct device = *dev, struct page *page, return dma_handle; } =20 -static void xen_grant_dma_unmap_page(struct device *dev, dma_addr_t dma_ha= ndle, +static void xen_grant_dma_unmap_phys(struct device *dev, dma_addr_t dma_ha= ndle, size_t size, enum dma_data_direction dir, unsigned long attrs) { @@ -242,7 +246,7 @@ static void xen_grant_dma_unmap_sg(struct device *dev, = struct scatterlist *sg, return; =20 for_each_sg(sg, s, nents, i) - xen_grant_dma_unmap_page(dev, s->dma_address, sg_dma_len(s), dir, + xen_grant_dma_unmap_phys(dev, s->dma_address, sg_dma_len(s), dir, attrs); } =20 @@ -257,7 +261,7 @@ static int xen_grant_dma_map_sg(struct device *dev, str= uct scatterlist *sg, return -EINVAL; =20 for_each_sg(sg, s, nents, i) { - s->dma_address =3D xen_grant_dma_map_page(dev, sg_page(s), s->offset, + s->dma_address =3D xen_grant_dma_map_phys(dev, sg_phys(s), s->length, dir, attrs); if (s->dma_address =3D=3D DMA_MAPPING_ERROR) goto out; @@ -286,8 +290,8 @@ static const struct dma_map_ops xen_grant_dma_ops =3D { .free_pages =3D xen_grant_dma_free_pages, .mmap =3D dma_common_mmap, .get_sgtable =3D dma_common_get_sgtable, - .map_page =3D xen_grant_dma_map_page, - .unmap_page =3D xen_grant_dma_unmap_page, + .map_phys =3D xen_grant_dma_map_phys, + .unmap_phys =3D xen_grant_dma_unmap_phys, .map_sg =3D xen_grant_dma_map_sg, .unmap_sg =3D xen_grant_dma_unmap_sg, .dma_supported =3D xen_grant_dma_supported, --=20 2.51.0