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=-5.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=no 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 DAD24C433E6 for ; Sat, 13 Mar 2021 02:33:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B121B64F6A for ; Sat, 13 Mar 2021 02:33:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232933AbhCMCce (ORCPT ); Fri, 12 Mar 2021 21:32:34 -0500 Received: from mga11.intel.com ([192.55.52.93]:39329 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232878AbhCMCcV (ORCPT ); Fri, 12 Mar 2021 21:32:21 -0500 IronPort-SDR: ca6+EmFzLB6rn4PfFvmKGdTLSQAKAga6I11OuEQgI/uWudtxaArSF9UQ2010blewnRNoqHE33o pcO+kWww8SuA== X-IronPort-AV: E=McAfee;i="6000,8403,9921"; a="185556890" X-IronPort-AV: E=Sophos;i="5.81,245,1610438400"; d="scan'208";a="185556890" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Mar 2021 18:32:21 -0800 IronPort-SDR: BWPKoNFrC0CbvFbvqC7bofsQvJCNTBhJDT+7AoC9cufX1+KLu6FM5vOz8SA4xWlBa1sCU5vqVL Ls62JjUfG9ug== X-IronPort-AV: E=Sophos;i="5.81,245,1610438400"; d="scan'208";a="448805796" Received: from iweiny-desk2.sc.intel.com (HELO localhost) ([10.3.52.147]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Mar 2021 18:32:20 -0800 Date: Fri, 12 Mar 2021 18:32:20 -0800 From: Ira Weiny To: Logan Gunthorpe Cc: linux-kernel@vger.kernel.org, linux-nvme@lists.infradead.org, linux-block@vger.kernel.org, linux-pci@vger.kernel.org, linux-mm@kvack.org, iommu@lists.linux-foundation.org, Stephen Bates , Christoph Hellwig , Dan Williams , Jason Gunthorpe , Christian =?iso-8859-1?Q?K=F6nig?= , Ira Weiny , John Hubbard , Don Dutile , Matthew Wilcox , Daniel Vetter , Jakowski Andrzej , Minturn Dave B , Jason Ekstrand , Dave Hansen , Xiong Jianxin Subject: Re: [RFC PATCH v2 04/11] PCI/P2PDMA: Introduce pci_p2pdma_should_map_bus() and pci_p2pdma_bus_offset() Message-ID: <20210313023220.GB3402637@iweiny-DESK2.sc.intel.com> References: <20210311233142.7900-1-logang@deltatee.com> <20210311233142.7900-5-logang@deltatee.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210311233142.7900-5-logang@deltatee.com> User-Agent: Mutt/1.11.1 (2018-12-01) Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org On Thu, Mar 11, 2021 at 04:31:34PM -0700, Logan Gunthorpe wrote: > Introduce pci_p2pdma_should_map_bus() which is meant to be called by ^^^^^^^^^^^^^^^^^^^^^^^^^ pci_p2pdma_dma_map_type() ??? FWIW I find this name confusing with pci_p2pdma_map_type() and looking at the implementation I'm not clear why pci_p2pdma_dma_map_type() needs to exist? Ira [snip] > + > +/** > + * pci_p2pdma_dma_map_type - determine if a DMA mapping should use the > + * bus address, be mapped normally or fail > + * @dev: device doing the DMA request > + * @pgmap: dev_pagemap structure for the mapping > + * > + * Returns: > + * 1 - if the page should be mapped with a bus address, > + * 0 - if the page should be mapped normally through an IOMMU mapping or > + * physical address; or > + * -1 - if the device should not map the pages and an error should be > + * returned > + */ > +int pci_p2pdma_dma_map_type(struct device *dev, struct dev_pagemap *pgmap) > +{ > + struct pci_p2pdma_pagemap *p2p_pgmap = to_p2p_pgmap(pgmap); > + struct pci_dev *client; > + > + if (!dev_is_pci(dev)) > + return -1; > + > + client = to_pci_dev(dev); > + > + switch (pci_p2pdma_map_type(p2p_pgmap->provider, client)) { > + case PCI_P2PDMA_MAP_THRU_HOST_BRIDGE: > + return 0; > + case PCI_P2PDMA_MAP_BUS_ADDR: > + return 1; > + default: > + return -1; > + } > +} > +EXPORT_SYMBOL_GPL(pci_p2pdma_dma_map_type); I guess the main point here is to export this to the DMA layer? Ira