Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3670734pxj; Tue, 11 May 2021 09:19:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwnmYzR0sCOPqDABPd47KuhrmDOTNDU3saZ246ADePPNwPNoduHGMqUcE8KSgVsJhcXtiPE X-Received: by 2002:a19:f010:: with SMTP id p16mr21626007lfc.612.1620749953060; Tue, 11 May 2021 09:19:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620749953; cv=none; d=google.com; s=arc-20160816; b=dFfQa0lIRWMs9CDDMoUk4qsOl1A0xEoDG4sn03Lub/MV3ZOCXvwTF44rya1LTLUla5 PL7NoyNspdmTMhXNw2DLDZo8gVx0oddXO53CJ+tqanZ+qTZ8LIffhYzDhQSnrO7Wlnu+ qIi+oGOF1GQZ+rSB0joZPZ8ThxG4tbdngtgoTC06uN7VSkn3PSkBYFzGHsAtuo8ZCsg7 m7qNzR0XCq1jxMNRwz1wcLi4pKoIDeSGYXocbvyzSQXBhu0otxEYlpB4pKDNViBSU0g5 wkfqN0XhSWkiizAbvyyP6mM6ULqUxcKR0UEW8dilzKC/M0oxEkDD4HOZju7N/Ba84p+X UeBQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:subject:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:dkim-signature; bh=+qL+bCKGfStmpkzBXZL07cewsYGgdGWBxgnS26p7gJ4=; b=LarIHY15e0UgmXei7B6JOI+/sTiEF2NOLpvfiAzH+6kfss8xN4SCBp1rMe3nvGm8B8 CgZxAGbiDn46uPSvK91T14VAXjWu+6pGDx8N8Ode+a2vqe8EUAJ/lzhqjicyH+Dc9bBw H56YMq6C6foQ0PNmUeoPtxsqFD6GqQE2ad5Tp7so6jstyJsXBENxrr40M+zMhgWu3ZMh uG90UJ4dVPDwpbYbGqAUSS3gq2axEnQgWOO1YNSbHvPyLLC+Ep7GWabqE2LAL9zthVl4 S0v4geUSfMoOtgWWM6lm0L3ZbI+sFT6rZKHVDfD+HDclwWlORYOR7KaZFMKDuxStXAxn pTxA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@deltatee.com header.s=20200525 header.b="OjW/leyh"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f4si9436295lfr.263.2021.05.11.09.18.42; Tue, 11 May 2021 09:19:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@deltatee.com header.s=20200525 header.b="OjW/leyh"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231437AbhEKQSb (ORCPT + 99 others); Tue, 11 May 2021 12:18:31 -0400 Received: from ale.deltatee.com ([204.191.154.188]:53808 "EHLO ale.deltatee.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230505AbhEKQS3 (ORCPT ); Tue, 11 May 2021 12:18:29 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=deltatee.com; s=20200525; h=Subject:In-Reply-To:MIME-Version:Date: Message-ID:From:References:Cc:To:content-disposition; bh=+qL+bCKGfStmpkzBXZL07cewsYGgdGWBxgnS26p7gJ4=; b=OjW/leyhr6eiCrabsG0jwX48QG qf9FfnRMB8lOpcLl7xkYVCN+H9DG/ow0oFBY5DkbsdrKG4BeIL/95qHzr5Q34oml6P0Ia+gj006QY T7tfNb/72phF7xxLw2cHcasrwLMhlmUq8D4r4ua8yXgfhO46WSwr8NalxGd8AKW8D7Uph/BeD0c6v EXvXF+qClEvUf1Cs6Tw4byRJhAqcs+WTb4+Ii6rhyanbNHBLODUr7O8ZW25N6FFgMl243kSFQXexr 6BMwajaa6dpHKjgCljgKN/d8mwu2rcxO8/ASPfckMdnWBkJYMQw+zF2Aa4G7MR3LtsG2RGxXG35o2 4DdZW0ng==; Received: from guinness.priv.deltatee.com ([172.16.1.162]) by ale.deltatee.com with esmtp (Exim 4.92) (envelope-from ) id 1lgV4L-0006fB-19; Tue, 11 May 2021 10:17:14 -0600 To: Don Dutile , 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 Cc: Stephen Bates , Christoph Hellwig , Dan Williams , Jason Gunthorpe , =?UTF-8?Q?Christian_K=c3=b6nig?= , John Hubbard , Matthew Wilcox , Daniel Vetter , Jakowski Andrzej , Minturn Dave B , Jason Ekstrand , Dave Hansen , Xiong Jianxin , Bjorn Helgaas , Ira Weiny , Robin Murphy References: <20210408170123.8788-1-logang@deltatee.com> <20210408170123.8788-8-logang@deltatee.com> From: Logan Gunthorpe Message-ID: Date: Tue, 11 May 2021 10:17:12 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.10.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-CA Content-Transfer-Encoding: 7bit X-SA-Exim-Connect-IP: 172.16.1.162 X-SA-Exim-Rcpt-To: robin.murphy@arm.com, ira.weiny@intel.com, helgaas@kernel.org, jianxin.xiong@intel.com, dave.hansen@linux.intel.com, jason@jlekstrand.net, dave.b.minturn@intel.com, andrzej.jakowski@intel.com, daniel.vetter@ffwll.ch, willy@infradead.org, jhubbard@nvidia.com, christian.koenig@amd.com, jgg@ziepe.ca, dan.j.williams@intel.com, hch@lst.de, sbates@raithlin.com, iommu@lists.linux-foundation.org, linux-mm@kvack.org, linux-pci@vger.kernel.org, linux-block@vger.kernel.org, linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, ddutile@redhat.com X-SA-Exim-Mail-From: logang@deltatee.com X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on ale.deltatee.com X-Spam-Level: X-Spam-Status: No, score=-8.9 required=5.0 tests=ALL_TRUSTED,BAYES_00, GREYLIST_ISWHITE,NICE_REPLY_A autolearn=ham autolearn_force=no version=3.4.2 Subject: Re: [PATCH 07/16] PCI/P2PDMA: Make pci_p2pdma_map_type() non-static X-SA-Exim-Version: 4.2.1 (built Wed, 08 May 2019 21:11:16 +0000) X-SA-Exim-Scanned: Yes (on ale.deltatee.com) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2021-05-11 10:06 a.m., Don Dutile wrote: > On 4/8/21 1:01 PM, Logan Gunthorpe wrote: >> pci_p2pdma_map_type() will be needed by the dma-iommu map_sg >> implementation because it will need to determine the mapping type >> ahead of actually doing the mapping to create the actual iommu mapping. >> >> Signed-off-by: Logan Gunthorpe >> --- >> drivers/pci/p2pdma.c | 34 +++++++++++++++++++++++----------- >> include/linux/pci-p2pdma.h | 15 +++++++++++++++ >> 2 files changed, 38 insertions(+), 11 deletions(-) >> >> diff --git a/drivers/pci/p2pdma.c b/drivers/pci/p2pdma.c >> index bcb1a6d6119d..38c93f57a941 100644 >> --- a/drivers/pci/p2pdma.c >> +++ b/drivers/pci/p2pdma.c >> @@ -20,13 +20,6 @@ >> #include >> #include >> >> -enum pci_p2pdma_map_type { >> - PCI_P2PDMA_MAP_UNKNOWN = 0, >> - PCI_P2PDMA_MAP_NOT_SUPPORTED, >> - PCI_P2PDMA_MAP_BUS_ADDR, >> - PCI_P2PDMA_MAP_THRU_HOST_BRIDGE, >> -}; >> - >> struct pci_p2pdma { >> struct gen_pool *pool; >> bool p2pmem_published; >> @@ -822,13 +815,30 @@ void pci_p2pmem_publish(struct pci_dev *pdev, bool publish) >> } >> EXPORT_SYMBOL_GPL(pci_p2pmem_publish); >> >> -static enum pci_p2pdma_map_type pci_p2pdma_map_type(struct dev_pagemap *pgmap, >> - struct device *dev) >> +/** >> + * pci_p2pdma_map_type - return the type of mapping that should be used for >> + * a given device and pgmap >> + * @pgmap: the pagemap of a page to determine the mapping type for >> + * @dev: device that is mapping the page >> + * @dma_attrs: the attributes passed to the dma_map operation -- >> + * this is so they can be checked to ensure P2PDMA pages were not >> + * introduced into an incorrect interface (like dma_map_sg). * >> + * >> + * Returns one of: >> + * PCI_P2PDMA_MAP_NOT_SUPPORTED - The mapping should not be done >> + * PCI_P2PDMA_MAP_BUS_ADDR - The mapping should use the PCI bus address >> + * PCI_P2PDMA_MAP_THRU_HOST_BRIDGE - The mapping should be done directly >> + */ > I'd recommend putting these descriptions in the enum's in pci-p2pdma.h . > Also, can you use a better description for THRU_HOST_BRIDGE -- it leaves the reader wondering what 'done directly' means. Will do. Logan