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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5655DC433FE for ; Wed, 20 Apr 2022 08:47:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237922AbiDTIuk (ORCPT ); Wed, 20 Apr 2022 04:50:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46384 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376917AbiDTIuh (ORCPT ); Wed, 20 Apr 2022 04:50:37 -0400 Received: from verein.lst.de (verein.lst.de [213.95.11.211]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C44FE1A38F; Wed, 20 Apr 2022 01:47:51 -0700 (PDT) Received: by verein.lst.de (Postfix, from userid 2407) id BA3C368AFE; Wed, 20 Apr 2022 10:47:46 +0200 (CEST) Date: Wed, 20 Apr 2022 10:47:46 +0200 From: Christoph Hellwig To: Serge Semin Cc: Christoph Hellwig , Robin Murphy , Serge Semin , Gustavo Pimentel , Vinod Koul , Jingoo Han , Bjorn Helgaas , Frank Li , Manivannan Sadhasivam , Marek Szyprowski , Vladimir Murzin , Alexey Malahov , Pavel Parkhomenko , Lorenzo Pieralisi , Rob Herring , Krzysztof =?utf-8?Q?Wilczy=C5=84ski?= , linux-pci@vger.kernel.org, dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org, iommu@lists.linux-foundation.org Subject: Re: [PATCH 03/25] dma-direct: take dma-ranges/offsets into account in resource mapping Message-ID: <20220420084746.GA11606@lst.de> References: <20220324014836.19149-1-Sergey.Semin@baikalelectronics.ru> <20220324014836.19149-4-Sergey.Semin@baikalelectronics.ru> <0baff803-b0ea-529f-095a-897398b4f63f@arm.com> <20220417224427.drwy3rchwplthelh@mobilestation> <20220420071217.GA5152@lst.de> <20220420083207.pd3hxbwezrm2ud6x@mobilestation> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220420083207.pd3hxbwezrm2ud6x@mobilestation> User-Agent: Mutt/1.5.17 (2007-11-01) Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org I can't really comment on the dma-ranges exlcusion for P2P mappings, as that predates my involvedment, however: On Wed, Apr 20, 2022 at 11:32:07AM +0300, Serge Semin wrote: > See, if I get to map a virtual memory address to be accessible by any > PCIe peripheral device, then the dma_map_sg/dma_map_page/etc > procedures will take the PCIe host controller dma-ranges into account. > It will work as expected and the PCIe devices will see the memory what > I specified. But if I get to pass the physical address of the same > page or a physical address of some device of the DEVs space to the > dma_map_resource(), then the PCIe dma-ranges won't be taken into > account, and the result mapping will be incorrect. That's why the > current dma_map_resource() implementation seems very confusing to me. > As I see it phys_addr_t is the type of the Interconnect address space, > meanwhile dma_addr_t describes the PCIe, DEVs address spaces. > > Based on what I said here and in my previous email could you explain > what do I get wrong? You simply must not use dma_map_resource for normal kernel memory. So while the exclusion might be somewhat confusing, that confusion really should not matter for any proper use of the API.