Received: by 10.213.65.68 with SMTP id h4csp720960imn; Tue, 13 Mar 2018 19:57:59 -0700 (PDT) X-Google-Smtp-Source: AG47ELs3SGiCrGGUSEKLtHN0G3Iwr3D9cSseU1vtAd8BYFXw1yR+9evO9XlHV6sFgu4K2hlGoW07 X-Received: by 2002:a17:902:7e09:: with SMTP id b9-v6mr2536932plm.223.1520996279039; Tue, 13 Mar 2018 19:57:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1520996279; cv=none; d=google.com; s=arc-20160816; b=LHQZMF1OFMcbvoQ2KJCm4LwOMfuYuCXHHfRurTT6yD/BrH9fE5tXLMHLzOxs8tR4Ht 0DspP8j6WKkLmblekmhs2eKL/K0b5MZBtNJy3SCPtJnQbxCD1oMS9YIOluyq7DlpVtRx iBogDGPg+F367LNEKMPpkhgxPdTE78VoM93yJ7NH32H60KcyOZMfdTep+9ICvRbgMxh1 n1I48KxYB19g/0CC/DxDYBDU0Kzh1PRFaPpwv4MsEwYwNn/guQuXvOPk1ze+JyhV5P7I FheaND9lNwIzSWIXIQVFldkkq7YN5+V4pYSJWKOrpFSX/SNSfWA1afPqMtgYmkq5O8if pz1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dmarc-filter:arc-authentication-results; bh=mFDTCCFNfX0cUii2NDSA97XtBYQUDscYazBnVqNb8/I=; b=n7o59kN3Ok1kLyQjwojTT1oTTLxQtn1LdmZc+ig26d8CcxdG/hiBaJmoGL2Zuh9RtL Zxg5XmS0FpsFXN0icWA/X4BfbV5a4sVeJukqgEfyxhx9rBm4WkIGqG9TaVYBAZfjylUV rleBMysxxvpy5blO90Uv5aZLeqP5ih8odPyhIM3RRGz9xK2yMi/rczT2XWstKk+QK2hv SVI2cU/6x5SRuc9+XJY9rcg8flDVGDBWTQfKIT4r80yjy8DL087Ew6fgmo3SiZke1drl pqMm9PEvL6tlVYnsY2q0MNmL0WO/gkc9tZMbYvNTD7Q4zTLyJx0gbxQ/dyShgPAE1BSp 6bMQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p7si1267554pff.80.2018.03.13.19.57.44; Tue, 13 Mar 2018 19:57:59 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933262AbeCNC4t (ORCPT + 99 others); Tue, 13 Mar 2018 22:56:49 -0400 Received: from mail.kernel.org ([198.145.29.99]:35530 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750902AbeCNC4r (ORCPT ); Tue, 13 Mar 2018 22:56:47 -0400 Received: from localhost (unknown [69.71.5.252]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 2DEBF20685; Wed, 14 Mar 2018 02:56:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2DEBF20685 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=helgaas@kernel.org Date: Tue, 13 Mar 2018 21:56:39 -0500 From: Bjorn Helgaas To: Logan Gunthorpe Cc: Stephen Bates , Sinan Kaya , "linux-kernel@vger.kernel.org" , "linux-pci@vger.kernel.org" , "linux-nvme@lists.infradead.org" , "linux-rdma@vger.kernel.org" , "linux-nvdimm@lists.01.org" , "linux-block@vger.kernel.org" , Christoph Hellwig , Jens Axboe , Keith Busch , Sagi Grimberg , Bjorn Helgaas , Jason Gunthorpe , Max Gurtovoy , Dan Williams , =?iso-8859-1?B?Suly9G1l?= Glisse , Benjamin Herrenschmidt , Alex Williamson Subject: Re: [PATCH v3 01/11] PCI/P2PDMA: Support peer-to-peer memory Message-ID: <20180314025639.GA50067@bhelgaas-glaptop.roam.corp.google.com> References: <3e738f95-d73c-4182-2fa1-8664aafb1ab7@deltatee.com> <703aa92c-0c1c-4852-5887-6f6e6ccde0fb@codeaurora.org> <3ea80992-a0fc-08f2-d93d-ae0ec4e3f4ce@codeaurora.org> <4eb6850c-df1b-fd44-3ee0-d43a50270b53@deltatee.com> <757fca36-dee4-e070-669e-f2788bd78e41@codeaurora.org> <4f761f55-4e9a-dccb-d12f-c59d2cd689db@deltatee.com> <20180313230850.GA45763@bhelgaas-glaptop.roam.corp.google.com> <8de5d3dd-a78f-02d5-0eea-4365364143b6@deltatee.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <8de5d3dd-a78f-02d5-0eea-4365364143b6@deltatee.com> User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Mar 13, 2018 at 05:21:20PM -0600, Logan Gunthorpe wrote: > On 13/03/18 05:08 PM, Bjorn Helgaas wrote: > > On Tue, Mar 13, 2018 at 10:31:55PM +0000, Stephen Bates wrote: > > If it *is* necessary because Root Ports and devices below them behave > > differently than in conventional PCI, I think you should include a > > reference to the relevant section of the spec and check directly for a > > Root Port. I would prefer that over trying to exclude Root Ports by > > looking for two upstream bridges. > > Well we've established that we don't want to allow root ports. I assume you want to exclude Root Ports because of multi-function devices and the "route to self" error. I was hoping for a reference to that so I could learn more about it. While I was looking for it, I found sec 6.12.1.2 (PCIe r4.0), "ACS Functions in SR-IOV Capable and Multi-Function Devices", which seems relevant. It talks about "peer-to-peer Requests (between Functions of the device)". Thay says to me that multi-function devices can DMA between themselves. > But we need to, at a minimum, do two pci_upstream_bridge() calls... > > Remember, we need to check that a number of devices are behind the same > switch. So we need to find a _common_ upstream port for several devices. I agree that peers need to have a common upstream bridge. I think you're saying peers need to have *two* common upstream bridges. If I understand correctly, requiring two common bridges is a way to ensure that peers directly below Root Ports don't try to DMA to each other. So I guess the first order of business is to nail down whether peers below a Root Port are prohibited from DMAing to each other. My assumption, based on 6.12.1.2 and the fact that I haven't yet found a prohibition, is that they can. > Excluding the multifunction device case (which I don't think is > applicable for reasons we've discussed before), this will *never* be the > first upstream port for a given device. If you're looking for a common upstream bridge, you don't need to make assumptions about whether the hierarchy is conventional PCI or PCIe or how many levels are in the hierarchy. You already have upstream_bridges_match(), which takes two pci_devs. I think it should walk up the PCI hierarchy from the first device, checking whether the bridge at each level is also a parent of the second device. Bjorn