Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp4216411pxb; Mon, 27 Sep 2021 11:52:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJys70E+NFhT8MnRYi7XK7KogKyxIpQ+e7H8S07keqUNUGTGBK4BjdPkeF4QahgAaYmmnw0u X-Received: by 2002:a65:6648:: with SMTP id z8mr1015441pgv.418.1632768745853; Mon, 27 Sep 2021 11:52:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632768745; cv=none; d=google.com; s=arc-20160816; b=nKd2kzGWh5/A+AzVAYoO+Yq6TImIgk+JnF62w0h811SmnwooNISmweIM3qDaQO19C2 0+nwxA8tJZ6lhWUvFTrkyRH7SOAsSm4Izngb6sP4mNcRKFNrGpinuaF7fIb9fgQVweW5 nAbTq5lDYMOSZcu4lrURG/bQvfZruJTkR/xuHReKtAW6v99ZO1GvOjPfpG4HzNM/lrPN XtTMMangr1C+UufzcCk3DoZP8t/OYahx6kQiKqgs1MS63ylF6JFhQMJIEmrvWGD2RZsO N9JtQXNPZtsvPJNcGv1L1d+wmERwLch0i9tF1TT7HoP5g5euiEiIbHTA9uKIctrqSlRa p6sA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :message-id:subject:cc:to:from:date:dkim-signature; bh=PzSm5pr8PYllIN5nl5nDqhiKuDLfXlIzrPKqnczfH5Q=; b=tB7u7ZRQwuElpqhlFTp+Up3JEgiXOIezgfh+7e84ojfxDLUPFSRnHHWa5O6SNoTy/M q2XnI/OBbIfOL8aetwqOQm0UjId/XaFw731EBFfppQR3Y2SyIjjX8O+GQIFQRMGTaCc9 ApHz2qqYkM1LaUaQgnIF7VxJD0Dc+n3JJlGy/bUvjsWFI7pFiI9J6idelQQygJYRX+aZ sy0wGEmZLrmtwo4Qs967zRQsKxF5dfsgT7lvAtvzn2wSa+aG1shXniYMUgcES/Zpj+KH vWbQd7AQIt93hQ2dqdsiFbinvpdz48UsTx4qQCdrLyrr6CMdhjpXHqh1U7TWaEdiy5R0 KoxQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=sxhqG2Ow; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s3si17783559pgq.289.2021.09.27.11.52.12; Mon, 27 Sep 2021 11:52:25 -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=@kernel.org header.s=k20201202 header.b=sxhqG2Ow; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236365AbhI0SwT (ORCPT + 99 others); Mon, 27 Sep 2021 14:52:19 -0400 Received: from mail.kernel.org ([198.145.29.99]:60352 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236296AbhI0SwQ (ORCPT ); Mon, 27 Sep 2021 14:52:16 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id CDAE961058; Mon, 27 Sep 2021 18:50:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1632768638; bh=C5XC6h6Q1qc5Qf6BQUNRzYX2mM+5Ej8TnIc335MIf3Y=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=sxhqG2OwJcmYiPbgyuP+0xu6/gEhxQlRDh6b0Q4SBqBqsN4nn+REtn//Bigm2XegR ltuanBZSrm5Dt6GJFsiwiA23f1AVvAUrGESKtat3QIvJZJcdHhUShJO+a3JDGkAcOZ hBm+bbjGjp1eJ3L8+BW1Hvy5k/t+DXjcmafsp4Qwiq5fz+FPcHdN7cSv1nVdS+iH5j 4+kUSasJvEa4tLbjzHFbG61XTE6v9SW+4inMLS7Rk3O6gACDrFD9x0m5Kg3tADTBv7 oK+UBQkgmZxlMMOwZ7wxWruTgiS8aySMoZgqahsIPVSzl9H8IY1XOu/MeIQNBzPO5O hg5kqidrgvEnw== Date: Mon, 27 Sep 2021 13:50:36 -0500 From: Bjorn Helgaas 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?= , John Hubbard , Don Dutile , Matthew Wilcox , Daniel Vetter , Jakowski Andrzej , Minturn Dave B , Jason Ekstrand , Dave Hansen , Xiong Jianxin , Ira Weiny , Robin Murphy , Martin Oliveira , Chaitanya Kulkarni Subject: Re: [PATCH v3 02/20] PCI/P2PDMA: attempt to set map_type if it has not been set Message-ID: <20210927185036.GA668115@bhelgaas> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210916234100.122368-3-logang@deltatee.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Sep 16, 2021 at 05:40:42PM -0600, Logan Gunthorpe wrote: > 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. > > With this change it's no longer invalid to call pci_p2pdma_map_sg() > before the mapping type is calculated so drop the WARN_ON when that > is the case. > > Signed-off-by: Logan Gunthorpe Acked-by: Bjorn Helgaas Capitalize subject line. > --- > drivers/pci/p2pdma.c | 6 +++++- > 1 file changed, 5 insertions(+), 1 deletion(-) > > diff --git a/drivers/pci/p2pdma.c b/drivers/pci/p2pdma.c > index 50cdde3e9a8b..1192c465ba6d 100644 > --- a/drivers/pci/p2pdma.c > +++ b/drivers/pci/p2pdma.c > @@ -848,6 +848,7 @@ static enum pci_p2pdma_map_type pci_p2pdma_map_type(struct dev_pagemap *pgmap, > struct pci_dev *provider = to_p2p_pgmap(pgmap)->provider; > struct pci_dev *client; > struct pci_p2pdma *p2pdma; > + int dist; > > if (!provider->p2pdma) > return PCI_P2PDMA_MAP_NOT_SUPPORTED; > @@ -864,6 +865,10 @@ static enum pci_p2pdma_map_type pci_p2pdma_map_type(struct dev_pagemap *pgmap, > type = xa_to_value(xa_load(&p2pdma->map_types, > map_types_idx(client))); > rcu_read_unlock(); > + > + if (type == PCI_P2PDMA_MAP_UNKNOWN) > + return calc_map_type_and_dist(provider, client, &dist, false); > + > return type; > } > > @@ -906,7 +911,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.30.2 >