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=-15.1 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=ham 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 19216C43461 for ; Tue, 11 May 2021 16:06:04 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 9D6B56191D for ; Tue, 11 May 2021 16:06:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9D6B56191D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 28310940007; Tue, 11 May 2021 12:06:03 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 25A178E0002; Tue, 11 May 2021 12:06:03 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0FB33940007; Tue, 11 May 2021 12:06:03 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0110.hostedemail.com [216.40.44.110]) by kanga.kvack.org (Postfix) with ESMTP id E32568E0002 for ; Tue, 11 May 2021 12:06:02 -0400 (EDT) Received: from smtpin16.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 827F887FF for ; Tue, 11 May 2021 16:06:02 +0000 (UTC) X-FDA: 78129426564.16.9489B64 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by imf11.hostedemail.com (Postfix) with ESMTP id 32D522000241 for ; Tue, 11 May 2021 16:05:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620749161; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7EwSkK3tCLzSwRdZ/4L1eSG5xJr+ckvT0VIiRU+l0cU=; b=RRvRHbmbxET52B94rLfyLWA8VI/sj7BAiVOkiqleREuLvTpvjb9d0RvALNxo7okcxPLnuQ jJ60IvnCQpEYcPmFAKPicN3qrQSkbR7CpP8tLkPh0Y+eJC3cVYCG+Ty9DQZ44KgUq2Wv1g cFScQ1npht2uChqH5Qo8kMNr2eDqdxs= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-563-FaCNBf4dPAaCfsJb1OSVVQ-1; Tue, 11 May 2021 12:05:57 -0400 X-MC-Unique: FaCNBf4dPAaCfsJb1OSVVQ-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B92A21854E27; Tue, 11 May 2021 16:05:52 +0000 (UTC) Received: from [10.3.115.19] (ovpn-115-19.phx2.redhat.com [10.3.115.19]) by smtp.corp.redhat.com (Postfix) with ESMTP id 717785D9F2; Tue, 11 May 2021 16:05:50 +0000 (UTC) Subject: Re: [PATCH 03/16] PCI/P2PDMA: Attempt to set map_type if it has not been set To: John Hubbard , Logan Gunthorpe , 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?= , 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-4-logang@deltatee.com> <3834be62-3d1b-fc98-d793-e7dcb0a74624@nvidia.com> From: Don Dutile Message-ID: <87a2b8e9-f0ef-ec23-8427-3022a86b0ec5@redhat.com> Date: Tue, 11 May 2021 12:05:49 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0 MIME-Version: 1.0 In-Reply-To: <3834be62-3d1b-fc98-d793-e7dcb0a74624@nvidia.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=RRvRHbmb; dmarc=pass (policy=none) header.from=redhat.com; spf=none (imf11.hostedemail.com: domain of ddutile@redhat.com has no SPF policy when checking 216.205.24.124) smtp.mailfrom=ddutile@redhat.com X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 32D522000241 X-Stat-Signature: 3pkquiutbwegk5b866ufzajex54equdy Received-SPF: none (redhat.com>: No applicable sender policy available) receiver=imf11; identity=mailfrom; envelope-from=""; helo=us-smtp-delivery-124.mimecast.com; client-ip=216.205.24.124 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1620749143-565435 Content-Transfer-Encoding: quoted-printable X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On 5/2/21 3:58 PM, John Hubbard wrote: > On 4/8/21 10:01 AM, 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. >> >> Signed-off-by: Logan Gunthorpe >> --- >> =C2=A0 drivers/pci/p2pdma.c | 12 +++++++++--- >> =C2=A0 1 file changed, 9 insertions(+), 3 deletions(-) >> >> diff --git a/drivers/pci/p2pdma.c b/drivers/pci/p2pdma.c >> index 473a08940fbc..2574a062a255 100644 >> --- a/drivers/pci/p2pdma.c >> +++ b/drivers/pci/p2pdma.c >> @@ -825,11 +825,18 @@ EXPORT_SYMBOL_GPL(pci_p2pmem_publish); >> =C2=A0 static enum pci_p2pdma_map_type pci_p2pdma_map_type(struct pci_= dev *provider, >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0 struct pci_dev *client) >> =C2=A0 { >> +=C2=A0=C2=A0=C2=A0 enum pci_p2pdma_map_type ret; >> + >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (!provider->p2pdma) >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return PCI_P2PD= MA_MAP_NOT_SUPPORTED; >> =C2=A0 -=C2=A0=C2=A0=C2=A0 return xa_to_value(xa_load(&provider->p2pdm= a->map_types, >> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 map_types_idx(client))); >> +=C2=A0=C2=A0=C2=A0 ret =3D xa_to_value(xa_load(&provider->p2pdma->map= _types, >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 map_types_idx(client))); >> +=C2=A0=C2=A0=C2=A0 if (ret !=3D PCI_P2PDMA_MAP_UNKNOWN) >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return ret; >> + >> +=C2=A0=C2=A0=C2=A0 return upstream_bridge_distance_warn(provider, cli= ent, NULL, >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= GFP_ATOMIC); > > Returning a "bridge distance" from a "get map type" routine is jarring, > and I think it is because of a pre-existing problem: the above function > is severely misnamed. Let's try renaming it (and the other one) to > approximately: > > =C2=A0=C2=A0=C2=A0 upstream_bridge_map_type_warn() > =C2=A0=C2=A0=C2=A0 upstream_bridge_map_type() > > ...and that should fix that. Well, that, plus tweaking the kernel doc > comments, which are also confused. I think someone started off thinking > about distances through PCIe, but in the end, the routine boils down to > just a few situations that are not distances at all. > +1. didn't like the 'distance' check=C2=A0 for a 'connection check" in th= e beginning, and looks like this is the time to clean it out. :) > Also, the above will read a little better if it is written like this: > > =C2=A0=C2=A0=C2=A0=C2=A0ret =3D xa_to_value(xa_load(&provider->p2pdma->= map_types, > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 map_types_idx(client))); > > =C2=A0=C2=A0=C2=A0=C2=A0if (ret =3D=3D PCI_P2PDMA_MAP_UNKNOWN) > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ret =3D upstream_bridge_map_= type_warn(provider, client, NULL, > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0 GFP_ATOMIC); > > =C2=A0=C2=A0=C2=A0=C2=A0return ret; > > >> =C2=A0 } >> =C2=A0 =C2=A0 static int __pci_p2pdma_map_sg(struct pci_p2pdma_pagemap= *p2p_pgmap, >> @@ -877,7 +884,6 @@ int pci_p2pdma_map_sg_attrs(struct device *dev, st= ruct scatterlist *sg, >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 case PCI_P2PDMA_MAP_BUS_ADDR: >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return __pci_p2= pdma_map_sg(p2p_pgmap, dev, sg, nents); >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 default: >> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 WARN_ON_ONCE(1); > > Why? Or at least, why, in this patch? It looks like an accidental > leftover from something, seeing as how it is not directly related to th= e > patch, and is not mentioned at all. > > > thanks,