Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp1417946pxb; Fri, 6 Nov 2020 09:07:45 -0800 (PST) X-Google-Smtp-Source: ABdhPJw7hwyGN5MKeOVPBFMhr31ngNpWskA0tRFQSUfP7Oy5/ReNu785oRu8cZXQ7SpNAzog791Z X-Received: by 2002:adf:914c:: with SMTP id j70mr3977053wrj.170.1604682464775; Fri, 06 Nov 2020 09:07:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604682464; cv=none; d=google.com; s=arc-20160816; b=OuUQcHowFhIR23RwIe+r/lZixwAEcVm3CG+vF1NsWutHQ86J/tYbFNLaudRmHYnaX8 6XGs2ZF32Y0ICaXX2ZBO+jLR5EHAdjiPRSF26QUF62NiB+rzXEid/AMutYsRd3TUE5QD NvekxvgMa4wo9CM/cUSQ+TWwhwDxp8OT5sVaCXNjflU4c3CXWnd2TBEut83ndw0Odl/V 0EF8U6s2KpNmUzpHMNzVhtqtDH2EO8G0e1+4XOIcbFbMgGXCDpavKBdi0hdOKTPNkrds BxbWd3ZYapAMobNJx2C3ybwEXKyTIK3xWbvmk/0uuEb4Z/x9aGISfeCvI/3DQP5N/Xvu xhPA== 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:mime-version :references:in-reply-to:message-id:date:cc:to:from:dkim-signature; bh=3JGE+zyDK4D2O+eP7VElzaTL/57y/ZuAN1RtFkDLi+Y=; b=jzk7Ko2ylj7D9jZQR9NbRNr16CFW74BObrzxRGyQgpt3f9VuOavrXhJeNLd+pZkwEq tWsJaHSTYUZXaVYuBHvwt4CA0xniH2KF5mhk2s3nI/U65GOon+TySInLuBnPP8ZWb8MX bBaXYY2//3HB4aBS65LfTkNRLt5NxZJysy4UkVfzCB+u6tqqMvka/itqQ8zNV72D1Skt bwuEoGY5irJjUmAwML4qW9tpY6tGNkvilI8Q4hmBFyPSeC270Ib/oUPisF49v8Jr6DBi dXsXAtEjMMUSe6phfWtX+r2q/la6DZJjIVdZNVAvwtta2A4jZwcUoqkq8QI/WtdRlQx5 U/rg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@deltatee.com header.s=20200525 header.b=E4md01Ra; 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 v16si1293885ejf.28.2020.11.06.09.07.21; Fri, 06 Nov 2020 09:07:44 -0800 (PST) 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=fail header.i=@deltatee.com header.s=20200525 header.b=E4md01Ra; 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 S1727768AbgKFRA6 (ORCPT + 99 others); Fri, 6 Nov 2020 12:00:58 -0500 Received: from ale.deltatee.com ([204.191.154.188]:57612 "EHLO ale.deltatee.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727258AbgKFRAz (ORCPT ); Fri, 6 Nov 2020 12:00:55 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=deltatee.com; s=20200525; h=Subject:Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=3JGE+zyDK4D2O+eP7VElzaTL/57y/ZuAN1RtFkDLi+Y=; b=E4md01RaDgc5ca4VxuE651O53Y 14g/QSSmSB24bw31bf1ZFImil9U+bjqhrYvHWtpO61bo+XuyxZkMTtWPhWJxJqRGEsgLAJjH5802J F9RnesqbKHRcqmJ9KA908uEKak9SHV+DSH47V/C6f0fAAlFYfBOJ8tOMm+bWhXx9mx7hvO9X4vz4G 4EFqPx6gAqd+FAEa7fjbEBrPZ6tGZkORigKpQuIviHKvGN1VGx87R9X/9PXetfEMmTunOpS7xPyko 56CW4ryiWfSHOyjDY8AQ11NFDKJMf0wTFlHPwJ3O46OgU+f9Se4wBgJGHsCgQFpwZFAxOwUZ/ZU19 QKi3CluQ==; Received: from cgy1-donard.priv.deltatee.com ([172.16.1.31]) by ale.deltatee.com with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kb56Z-0002PX-5l; Fri, 06 Nov 2020 10:00:53 -0700 Received: from gunthorp by cgy1-donard.priv.deltatee.com with local (Exim 4.92) (envelope-from ) id 1kb56U-0004st-Ad; Fri, 06 Nov 2020 10:00:46 -0700 From: Logan Gunthorpe To: 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=20K=C3=B6nig?= , Ira Weiny , John Hubbard , Don Dutile , Matthew Wilcox , Daniel Vetter , Logan Gunthorpe Date: Fri, 6 Nov 2020 10:00:23 -0700 Message-Id: <20201106170036.18713-3-logang@deltatee.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201106170036.18713-1-logang@deltatee.com> References: <20201106170036.18713-1-logang@deltatee.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SA-Exim-Connect-IP: 172.16.1.31 X-SA-Exim-Rcpt-To: linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, linux-pci@vger.kernel.org, linux-mm@kvack.org, iommu@lists.linux-foundation.org, sbates@raithlin.com, hch@lst.de, jgg@ziepe.ca, christian.koenig@amd.com, dan.j.williams@intel.com, iweiny@intel.com, jhubbard@nvidia.com, ddutile@redhat.com, willy@infradead.org, daniel.vetter@ffwll.ch, logang@deltatee.com X-SA-Exim-Mail-From: gunthorp@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.7 required=5.0 tests=ALL_TRUSTED,BAYES_00, GREYLIST_ISWHITE,MYRULES_NO_TEXT autolearn=ham autolearn_force=no version=3.4.2 Subject: [RFC PATCH 02/15] PCI/P2PDMA: Attempt to set map_type if it has not been set 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 Attempt to find the mapping type for P2PDMA pages on the first DMA map attempt if it has not been done ahead of time. Previously, the mapping type was expected to be calculated ahead of time, but if pages are to come from userspace then there's no way to ensure the path was checked ahead of time. Signed-off-by: Logan Gunthorpe --- drivers/pci/p2pdma.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/pci/p2pdma.c b/drivers/pci/p2pdma.c index 94583779c36e..ea8472278b11 100644 --- a/drivers/pci/p2pdma.c +++ b/drivers/pci/p2pdma.c @@ -824,11 +824,17 @@ EXPORT_SYMBOL_GPL(pci_p2pmem_publish); static enum pci_p2pdma_map_type pci_p2pdma_map_type(struct pci_dev *provider, struct pci_dev *client) { + enum pci_p2pdma_map_type ret; + if (!provider->p2pdma) return PCI_P2PDMA_MAP_NOT_SUPPORTED; - return xa_to_value(xa_load(&provider->p2pdma->map_types, - map_types_idx(client))); + ret = xa_to_value(xa_load(&provider->p2pdma->map_types, + map_types_idx(client))); + if (ret != PCI_P2PDMA_MAP_UNKNOWN) + return ret; + + return upstream_bridge_distance_warn(provider, client, NULL); } static int __pci_p2pdma_map_sg(struct pci_p2pdma_pagemap *p2p_pgmap, @@ -890,7 +896,6 @@ int pci_p2pdma_map_sg_attrs(struct device *dev, struct scatterlist *sg, case PCI_P2PDMA_MAP_BUS_ADDR: return __pci_p2pdma_map_sg(p2p_pgmap, dev, sg, nents); default: - WARN_ON_ONCE(1); return 0; } } -- 2.20.1