From patchwork Mon Mar 30 13:55:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Christian_K=C3=B6nig?= X-Patchwork-Id: 11465559 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9525E913 for ; Mon, 30 Mar 2020 13:55:52 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 736B6206CC for ; Mon, 30 Mar 2020 13:55:52 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="FHxR3+Cm" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 736B6206CC Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C4EF26E3A2; Mon, 30 Mar 2020 13:55:45 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wm1-x343.google.com (mail-wm1-x343.google.com [IPv6:2a00:1450:4864:20::343]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2B31A6E394; Mon, 30 Mar 2020 13:55:41 +0000 (UTC) Received: by mail-wm1-x343.google.com with SMTP id z18so20059470wmk.2; Mon, 30 Mar 2020 06:55:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=BrBZ7BRIxlz8FrRAnyr/unjtGHr0zUbPTL3/EC4XXLw=; b=FHxR3+CmB08xFviRye1G+JE6uJS+aVUQ+HGmBoGEOxVSCBH1R7G/rVrH+3LzxpOh8X cNvv34kxVcoeYeuYX1Sjbmk6IniCJzuJG09GT4H1fy/YCV23WnhcuvPFgMBQeBHGuOT0 zk4f82Ys62ZOEWqotuYDYUc034pNzw6iSNgO43UIwcQcckbDp706FK5h86+PUVk0mpAX KLYSexJP6X0q+xQk6K5QWAv21f3SBF2cStG82X/5abm2+tSkD2COOtjqdxMGQ0lCy4fk 3P3IoMFeKzhzVZE2Q2AzyNAGxBHbbyzU2UAmVf+JYAaGdbmm3B8ev/xDQ+7PQZsS2GN3 uUOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=BrBZ7BRIxlz8FrRAnyr/unjtGHr0zUbPTL3/EC4XXLw=; b=I7Xa+jOEWjTHe0qFSnGNYsmoMQxPCY3AZDTpU6ap+QUxkprpk23XqFn/C1yR5mNCkk lmfzQRmophzbBnbWIHmVrUzjSrzBxVHw0+GKE7EHeoDhxnzB0Q5sptkBXaXy3EpRyYKw yBYIAwg0mM9+CUAlABKg5ByWLvCBclL/i0dzFq1NKYeCACpbCkEoHuQLF5XKix3+1ipe n36ZaaOK9sn0XR/jCYUluHS74/RnXYhpYcK4cDGAZpXtQGKu4CmDCxLFSNf0fSwCQM09 NldnpKOmGJ2RhjileGIkVEPC03HwoL4VatMU4B+JB6L/7j55Xz7NEiIsFUKf1XvpTwg0 jOKQ== X-Gm-Message-State: ANhLgQ09J/p1izP2GN2c4LTSrFT/BQDEAnQ/yr+Z1jhJAOH9/DrTrYyZ Cjr7dvJfAHdN3Z7hY3+uTKKn/SSX X-Google-Smtp-Source: ADFU+vuruoydc/AyUasIYTsDVtsd4JpfCw26dFnNvIY4EMT7MMlQVcQZoO3j8Kjwch1dI8UTN10ocw== X-Received: by 2002:a1c:5604:: with SMTP id k4mr12727395wmb.57.1585576539573; Mon, 30 Mar 2020 06:55:39 -0700 (PDT) Received: from abel.fritz.box ([2a02:908:1252:fb60:f999:5819:bfe0:10e8]) by smtp.gmail.com with ESMTPSA id z16sm22267660wrr.56.2020.03.30.06.55.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Mar 2020 06:55:39 -0700 (PDT) From: " =?utf-8?q?Christian_K=C3=B6nig?= " X-Google-Original-From: =?utf-8?q?Christian_K=C3=B6nig?= To: dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, daniel@ffwll.ch Subject: [PATCH 4/6] drm/amdgpu: add checks if DMA-buf P2P is supported Date: Mon, 30 Mar 2020 15:55:34 +0200 Message-Id: <20200330135536.2997-4-christian.koenig@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200330135536.2997-1-christian.koenig@amd.com> References: <20200330135536.2997-1-christian.koenig@amd.com> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Check if we can do peer2peer on the PCIe bus. Signed-off-by: Christian König --- drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c index aef12ee2f1e3..bbf67800c8a6 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c @@ -38,6 +38,7 @@ #include #include #include +#include /** * amdgpu_gem_prime_vmap - &dma_buf_ops.vmap implementation @@ -179,6 +180,9 @@ static int amdgpu_dma_buf_attach(struct dma_buf *dmabuf, struct amdgpu_device *adev = amdgpu_ttm_adev(bo->tbo.bdev); int r; + if (pci_p2pdma_distance_many(adev->pdev, &attach->dev, 1, true) < 0) + attach->peer2peer = false; + if (attach->dev->driver == adev->dev->driver) return 0;