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 X-Spam-Level: X-Spam-Status: No, score=-10.0 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D52FAC433DF for ; Tue, 4 Aug 2020 05:34:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E1F122067D for ; Tue, 4 Aug 2020 05:34:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729658AbgHDFec (ORCPT ); Tue, 4 Aug 2020 01:34:32 -0400 Received: from mx2.suse.de ([195.135.220.15]:41656 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726797AbgHDFea (ORCPT ); Tue, 4 Aug 2020 01:34:30 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 7A2D4ACB5; Tue, 4 Aug 2020 05:34:45 +0000 (UTC) Subject: Re: [PATCH v3 09/11] swiotlb-xen: introduce phys_to_dma/dma_to_phys translations To: Stefano Stabellini , boris.ostrovsky@oracle.com, konrad.wilk@oracle.com Cc: xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org, hch@infradead.org, Stefano Stabellini References: <20200710223427.6897-9-sstabellini@kernel.org> From: =?UTF-8?B?SsO8cmdlbiBHcm/Dnw==?= Message-ID: <2f68bb03-60b6-44d6-b9cd-d21ef20a4a68@suse.com> Date: Tue, 4 Aug 2020 07:34:28 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <20200710223427.6897-9-sstabellini@kernel.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 11.07.20 00:34, Stefano Stabellini wrote: > From: Stefano Stabellini > > With some devices physical addresses are different than dma addresses. > To be able to deal with these cases, we need to call phys_to_dma on > physical addresses (including machine addresses in Xen terminology) > before returning them from xen_swiotlb_alloc_coherent and > xen_swiotlb_map_page. > > We also need to convert dma addresses back to physical addresses using > dma_to_phys in xen_swiotlb_free_coherent and xen_swiotlb_unmap_page if > we want to do any operations on them. > > Call dma_to_phys in is_xen_swiotlb_buffer. > Introduce xen_phys_to_dma and call phys_to_dma in its implementation. > Introduce xen_dma_to_phys and call dma_to_phys in its implementation. > Call xen_phys_to_dma/xen_dma_to_phys instead of > xen_phys_to_bus/xen_bus_to_phys through swiotlb-xen.c. > > Everything is taken care of by these changes except for > xen_swiotlb_alloc_coherent and xen_swiotlb_free_coherent, which need a > few explicit phys_to_dma/dma_to_phys calls. > > Signed-off-by: Stefano Stabellini > Tested-by: Corey Minyard > Tested-by: Roman Shaposhnik Reviewed-by: Juergen Gross Juergen 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 X-Spam-Level: X-Spam-Status: No, score=-10.0 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A9218C433E1 for ; Tue, 4 Aug 2020 05:34:44 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B0A3F2067D for ; Tue, 4 Aug 2020 05:34:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B0A3F2067D Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1k2par-00053F-24; Tue, 04 Aug 2020 05:34:33 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1k2pap-000537-9R for xen-devel@lists.xenproject.org; Tue, 04 Aug 2020 05:34:31 +0000 X-Inumbo-ID: 2b18188e-d614-11ea-9126-bc764e2007e4 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 2b18188e-d614-11ea-9126-bc764e2007e4; Tue, 04 Aug 2020 05:34:30 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 7A2D4ACB5; Tue, 4 Aug 2020 05:34:45 +0000 (UTC) Subject: Re: [PATCH v3 09/11] swiotlb-xen: introduce phys_to_dma/dma_to_phys translations To: Stefano Stabellini , boris.ostrovsky@oracle.com, konrad.wilk@oracle.com References: <20200710223427.6897-9-sstabellini@kernel.org> From: =?UTF-8?B?SsO8cmdlbiBHcm/Dnw==?= Message-ID: <2f68bb03-60b6-44d6-b9cd-d21ef20a4a68@suse.com> Date: Tue, 4 Aug 2020 07:34:28 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <20200710223427.6897-9-sstabellini@kernel.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: hch@infradead.org, xen-devel@lists.xenproject.org, Stefano Stabellini , linux-kernel@vger.kernel.org Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" On 11.07.20 00:34, Stefano Stabellini wrote: > From: Stefano Stabellini > > With some devices physical addresses are different than dma addresses. > To be able to deal with these cases, we need to call phys_to_dma on > physical addresses (including machine addresses in Xen terminology) > before returning them from xen_swiotlb_alloc_coherent and > xen_swiotlb_map_page. > > We also need to convert dma addresses back to physical addresses using > dma_to_phys in xen_swiotlb_free_coherent and xen_swiotlb_unmap_page if > we want to do any operations on them. > > Call dma_to_phys in is_xen_swiotlb_buffer. > Introduce xen_phys_to_dma and call phys_to_dma in its implementation. > Introduce xen_dma_to_phys and call dma_to_phys in its implementation. > Call xen_phys_to_dma/xen_dma_to_phys instead of > xen_phys_to_bus/xen_bus_to_phys through swiotlb-xen.c. > > Everything is taken care of by these changes except for > xen_swiotlb_alloc_coherent and xen_swiotlb_free_coherent, which need a > few explicit phys_to_dma/dma_to_phys calls. > > Signed-off-by: Stefano Stabellini > Tested-by: Corey Minyard > Tested-by: Roman Shaposhnik Reviewed-by: Juergen Gross Juergen