Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp5098793imu; Tue, 29 Jan 2019 12:45:43 -0800 (PST) X-Google-Smtp-Source: ALg8bN4rwRjYuaLAGVDRJCeVEwkEA6FBYzpuTx2+4ef+PPVyecULA4sjJGsKSGOvpwxmh71B42cc X-Received: by 2002:a62:f51a:: with SMTP id n26mr17650490pfh.245.1548794743632; Tue, 29 Jan 2019 12:45:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548794743; cv=none; d=google.com; s=arc-20160816; b=Tik4NePYiPCYJK8heeMkIKrnn8zaKIFxlz53AzT4diq8mOqrD4QPv0AJXwd4aST4HC fZ+C0zwFjLLIm8OlGJgehRXIAykilKm4YzGR7cVxZWwBx0w6U5J+8muHxQqhXNrBPGrx CXn8+6IXIUDLFoypd2E87ww35CEn9Wpj0tKpEjSg1IoVS0RUGHTBil5VRP+xJ0rgom6E 6fY6Lj0kQEjvpxEuxzkl86nTtTOhAWKRavrspWppZFp4tA95h29LhkZKYWYmcpEXN2v/ BpC4Wzy4hKDT71eYFJjQ13d7K3Xml4AibYRGbDywpcuMU1VOO7JLxReni/k5s6m/f71e tfww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:subject:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to; bh=WC0nXAalSeMPrkZXj5Bmu+vvjinEgIeQJ1/CWGuDTjI=; b=zY6EYluLNHQZd/K8bQd7OfiS6WFwrjZl9bCG+M4DOSokZYClNBsmVFLmjjp5+GpTym DC7cXonGBHFhpBQCKB/axSEXhkzNYg1YruOX3sqMA/IUQPud5sM3H9oWXigWh/CMF7SW QU4KKwArptCpSu02IZWmPyGs34lFf5PdJe5Ywqftz10u0FZcm1Lnr4I4mNm13eWOWYiZ 71hgeMOMjb/A2rX49AYlE3ohvzGbRAnr7a2olkdAlHgpeWsMZdt7UHX8r49/BigYICGR 8lObcRRH15nKVZrR8EcobmT6Gxkt6TWDOfB2zR1Rxi5DSj7Xp9xESS7PAmRBS8IosNzA 1S7g== 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 j22si34938255pfi.252.2019.01.29.12.45.28; Tue, 29 Jan 2019 12:45:43 -0800 (PST) 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 S1729391AbfA2UoY (ORCPT + 99 others); Tue, 29 Jan 2019 15:44:24 -0500 Received: from ale.deltatee.com ([207.54.116.67]:60074 "EHLO ale.deltatee.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727339AbfA2UoX (ORCPT ); Tue, 29 Jan 2019 15:44:23 -0500 Received: from guinness.priv.deltatee.com ([172.16.1.162]) by ale.deltatee.com with esmtp (Exim 4.89) (envelope-from ) id 1goaEu-0006kt-Rd; Tue, 29 Jan 2019 13:44:13 -0700 To: Greg Kroah-Hartman Cc: jglisse@redhat.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, "Rafael J . Wysocki" , Bjorn Helgaas , Christian Koenig , Felix Kuehling , Jason Gunthorpe , linux-pci@vger.kernel.org, dri-devel@lists.freedesktop.org, Christoph Hellwig , Marek Szyprowski , Robin Murphy , Joerg Roedel , iommu@lists.linux-foundation.org References: <20190129174728.6430-1-jglisse@redhat.com> <20190129174728.6430-2-jglisse@redhat.com> <20190129194426.GB32069@kroah.com> From: Logan Gunthorpe Message-ID: <8b4e0157-4eaf-c79a-28d0-7a266abe2207@deltatee.com> Date: Tue, 29 Jan 2019 13:44:09 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 MIME-Version: 1.0 In-Reply-To: <20190129194426.GB32069@kroah.com> 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: iommu@lists.linux-foundation.org, jroedel@suse.de, robin.murphy@arm.com, m.szyprowski@samsung.com, hch@lst.de, dri-devel@lists.freedesktop.org, linux-pci@vger.kernel.org, jgg@mellanox.com, Felix.Kuehling@amd.com, christian.koenig@amd.com, bhelgaas@google.com, rafael@kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, jglisse@redhat.com, gregkh@linuxfoundation.org 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 autolearn=ham autolearn_force=no version=3.4.2 Subject: Re: [RFC PATCH 1/5] pci/p2p: add a function to test peer to peer capability X-SA-Exim-Version: 4.2.1 (built Tue, 02 Aug 2016 21:08:31 +0000) X-SA-Exim-Scanned: Yes (on ale.deltatee.com) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2019-01-29 12:44 p.m., Greg Kroah-Hartman wrote: > On Tue, Jan 29, 2019 at 11:24:09AM -0700, Logan Gunthorpe wrote: >> >> >> On 2019-01-29 10:47 a.m., jglisse@redhat.com wrote: >>> +bool pci_test_p2p(struct device *devA, struct device *devB) >>> +{ >>> + struct pci_dev *pciA, *pciB; >>> + bool ret; >>> + int tmp; >>> + >>> + /* >>> + * For now we only support PCIE peer to peer but other inter-connect >>> + * can be added. >>> + */ >>> + pciA = find_parent_pci_dev(devA); >>> + pciB = find_parent_pci_dev(devB); >>> + if (pciA == NULL || pciB == NULL) { >>> + ret = false; >>> + goto out; >>> + } >>> + >>> + tmp = upstream_bridge_distance(pciA, pciB, NULL); >>> + ret = tmp < 0 ? false : true; >>> + >>> +out: >>> + pci_dev_put(pciB); >>> + pci_dev_put(pciA); >>> + return false; >>> +} >>> +EXPORT_SYMBOL_GPL(pci_test_p2p); >> >> This function only ever returns false.... > > I guess it was nevr actually tested :( > > I feel really worried about passing random 'struct device' pointers into > the PCI layer. Are we _sure_ it can handle this properly? Yes, there are a couple of pci_p2pdma functions that take struct devices directly simply because it's way more convenient for the caller. That's what find_parent_pci_dev() takes care of (it returns false if the device is not a PCI device). Whether that's appropriate here is hard to say seeing we haven't seen any caller code. Logan