Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp4927426imu; Tue, 29 Jan 2019 09:48:12 -0800 (PST) X-Google-Smtp-Source: ALg8bN4fzvEc/WkzOhAB0VmSvCv2r1yRLk5jNZ/Cm0+5iOEz6/3zhW0IBJa2rfNPhgraoU/Ftjdn X-Received: by 2002:a63:4611:: with SMTP id t17mr24369805pga.119.1548784092313; Tue, 29 Jan 2019 09:48:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548784092; cv=none; d=google.com; s=arc-20160816; b=sglEorzVx1IP1OMDi6MrAA08z6Hl0lnJ1LJo/r8kbY/p1DDHj3mtvmXFcKTZWrYESz lbRSMu9QgIl9jo1hp7O9YzuLqdPcodVKFC2qQVOmiRfPK5ZqvAHVlE6sw4w3GEUF+SQN g6v9N9JuiZ03C/UD6EmYY3PQTR1V/4ZY2d2Y0+s2Tlaq6/rVaVofeTrq+/qH3Dgv40pU oatFpmHxAbLZ70LAtDZaOvv81m4U3gkHYIG7MYj5sktztZYt0KFZcaSQPm2/9SfrmW9S zeBR261dJgvBOoQCW0/ZIdpV34BX464ZG/tGoVcGkn5AdwCzUd7UrPCe0MQRXARNf+s9 ddyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=PoGzAvv3e6DxlL080Riy/GDZsRCScs9tPJNjMYSpaMs=; b=sgOhCpuZE/ylnxbuMgOtdktCfRqmm5mRsl1m4t0zJBFsNMGdzaUVD5HTRQRirZ14pS 1mhONZzNeJF/Ze/HUKZ/Df5WZQwEGVSC1U6d7iHjpYuHF6Zqy00kqeieCmboNmCN6kYw nJ8EGDTxABp5cfpaAG+zGzR3zzLuNrDnmboyvwJcucBOoImH5sF9pjqyB5c4HbkNPspt uFHpoTrcqlW8cAuBYtBNIP41nuCg7YFxUPsfoBMwUNzDKd7TKuIl06nbK7ZRPksD8UIy 57E8dCz3jvPKjHyLI0csJmzLHQhWH7D/xEAThVDojojEUJ4ubu6Hd7vKwWIm64mh179i 7/MQ== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 187si11899018pfv.238.2019.01.29.09.47.56; Tue, 29 Jan 2019 09:48:12 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729072AbfA2Rrn (ORCPT + 99 others); Tue, 29 Jan 2019 12:47:43 -0500 Received: from mx1.redhat.com ([209.132.183.28]:44032 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728914AbfA2Rrn (ORCPT ); Tue, 29 Jan 2019 12:47:43 -0500 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 mx1.redhat.com (Postfix) with ESMTPS id 4BDFEC0753CE; Tue, 29 Jan 2019 17:47:42 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-122-2.rdu2.redhat.com [10.10.122.2]) by smtp.corp.redhat.com (Postfix) with ESMTP id 38BF05D98E; Tue, 29 Jan 2019 17:47:40 +0000 (UTC) From: jglisse@redhat.com To: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org, =?UTF-8?q?J=C3=A9r=C3=B4me=20Glisse?= , Logan Gunthorpe , Greg Kroah-Hartman , "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 Subject: [RFC PATCH 2/5] drivers/base: add a function to test peer to peer capability Date: Tue, 29 Jan 2019 12:47:25 -0500 Message-Id: <20190129174728.6430-3-jglisse@redhat.com> In-Reply-To: <20190129174728.6430-1-jglisse@redhat.com> References: <20190129174728.6430-1-jglisse@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Tue, 29 Jan 2019 17:47:42 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jérôme Glisse device_test_p2p() return true if two devices can peer to peer to each other. We add a generic function as different inter-connect can support peer to peer and we want to genericaly test this no matter what the inter-connect might be. However this version only support PCIE for now. Signed-off-by: Jérôme Glisse Cc: Logan Gunthorpe Cc: Greg Kroah-Hartman Cc: Rafael J. Wysocki Cc: Bjorn Helgaas Cc: Christian Koenig Cc: Felix Kuehling Cc: Jason Gunthorpe Cc: linux-kernel@vger.kernel.org Cc: linux-pci@vger.kernel.org Cc: dri-devel@lists.freedesktop.org Cc: Christoph Hellwig Cc: Marek Szyprowski Cc: Robin Murphy Cc: Joerg Roedel Cc: iommu@lists.linux-foundation.org --- drivers/base/core.c | 20 ++++++++++++++++++++ include/linux/device.h | 1 + 2 files changed, 21 insertions(+) diff --git a/drivers/base/core.c b/drivers/base/core.c index 0073b09bb99f..56023b00e108 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -26,6 +26,7 @@ #include #include #include +#include #include "base.h" #include "power/power.h" @@ -3167,3 +3168,22 @@ void device_set_of_node_from_dev(struct device *dev, const struct device *dev2) dev->of_node_reused = true; } EXPORT_SYMBOL_GPL(device_set_of_node_from_dev); + +/** + * device_test_p2p - test if two device can peer to peer to each other + * @devA: device A + * @devB: device B + * Returns: true if device can peer to peer to each other, false otherwise + */ +bool device_test_p2p(struct device *devA, struct device *devB) +{ + /* + * For now we only support PCIE peer to peer but other inter-connect + * can be added. + */ + if (pci_test_p2p(devA, devB)) + return true; + + return false; +} +EXPORT_SYMBOL_GPL(device_test_p2p); diff --git a/include/linux/device.h b/include/linux/device.h index 6cb4640b6160..0d532d7f0779 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -1250,6 +1250,7 @@ extern int device_online(struct device *dev); extern void set_primary_fwnode(struct device *dev, struct fwnode_handle *fwnode); extern void set_secondary_fwnode(struct device *dev, struct fwnode_handle *fwnode); void device_set_of_node_from_dev(struct device *dev, const struct device *dev2); +bool device_test_p2p(struct device *devA, struct device *devB); static inline int dev_num_vf(struct device *dev) { -- 2.17.2