From patchwork Fri Feb 5 00:29:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xiong, Jianxin" X-Patchwork-Id: 12069027 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=-16.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT 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 62EC4C433E0 for ; Fri, 5 Feb 2021 00:14:27 +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 190EF64FAE for ; Fri, 5 Feb 2021 00:14:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 190EF64FAE Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.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 1DE876EEB3; Fri, 5 Feb 2021 00:14:18 +0000 (UTC) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by gabe.freedesktop.org (Postfix) with ESMTPS id D5D1D6EEB1 for ; Fri, 5 Feb 2021 00:14:15 +0000 (UTC) IronPort-SDR: ipjuyDh2M5IZXSuFjoaIvP93MnhCUgAlh/18EHRWh6EldNkv79mdfBK+E96hyoJUlL7he8IAKv 8bgOXSioRRvw== X-IronPort-AV: E=McAfee;i="6000,8403,9885"; a="266181549" X-IronPort-AV: E=Sophos;i="5.81,153,1610438400"; d="scan'208";a="266181549" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Feb 2021 16:14:15 -0800 IronPort-SDR: D3cvr6pkQle/431HmVHgzGhHpoJT3Vz2APQJe7PHxH3fOZsCNlgczDR8tsEm3SwIQkssOwixBU FpPIf90jgEcg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.81,153,1610438400"; d="scan'208";a="508326489" Received: from cst-dev.jf.intel.com ([10.23.221.69]) by orsmga004.jf.intel.com with ESMTP; 04 Feb 2021 16:14:14 -0800 From: Jianxin Xiong To: linux-rdma@vger.kernel.org, dri-devel@lists.freedesktop.org Subject: [PATCH rdma-core v2 3/3] configure: Add check for the presence of DRM headers Date: Thu, 4 Feb 2021 16:29:14 -0800 Message-Id: <1612484954-75514-4-git-send-email-jianxin.xiong@intel.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1612484954-75514-1-git-send-email-jianxin.xiong@intel.com> References: <1612484954-75514-1-git-send-email-jianxin.xiong@intel.com> 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: , Cc: Yishai Hadas , Leon Romanovsky , John Hubbard , Edward Srouji , Emil Velikov , Gal Pressman , Ali Alnubani , Jason Gunthorpe , Doug Ledford , Daniel Vetter , Christian Koenig , Jianxin Xiong MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Compilation of pyverbs/dmabuf_alloc.c depends on a few DRM headers that are installed by either the kernel-header or the libdrm package. The installation is optional and the location is not unique. Check the presence of the headers at both the standard locations and any location defined by custom libdrm installation. If the headers are missing, the dmabuf allocation routines are replaced by stubs that return suitable error to allow the related tests to skip. Signed-off-by: Jianxin Xiong --- CMakeLists.txt | 15 +++++++++++++++ pyverbs/CMakeLists.txt | 14 ++++++++++++-- pyverbs/dmabuf_alloc.c | 8 ++++---- pyverbs/dmabuf_alloc_stub.c | 39 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 70 insertions(+), 6 deletions(-) create mode 100644 pyverbs/dmabuf_alloc_stub.c diff --git a/CMakeLists.txt b/CMakeLists.txt index 4113423..95aec11 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -515,6 +515,21 @@ find_package(Systemd) include_directories(${SYSTEMD_INCLUDE_DIRS}) RDMA_DoFixup("${SYSTEMD_FOUND}" "systemd/sd-daemon.h") +# drm headers + +# First check the standard locations. The headers could have been installed +# by either the kernle-headers package or the libdrm package. +find_path(DRM_INCLUDE_DIRS "drm.h" PATH_SUFFIXES "drm" "libdrm") + +# Then check custom installation of libdrm +if (NOT DRM_INCLUDE_DIRS) + pkg_check_modules(DRM libdrm) +endif() + +if (DRM_INCLUDE_DIRS) + include_directories(${DRM_INCLUDE_DIRS}) +endif() + #------------------------- # Apply fixups diff --git a/pyverbs/CMakeLists.txt b/pyverbs/CMakeLists.txt index 6fd7625..922253f 100644 --- a/pyverbs/CMakeLists.txt +++ b/pyverbs/CMakeLists.txt @@ -13,8 +13,6 @@ rdma_cython_module(pyverbs "" cmid.pyx cq.pyx device.pyx - dmabuf.pyx - dmabuf_alloc.c enums.pyx mem_alloc.pyx mr.pyx @@ -25,6 +23,18 @@ rdma_cython_module(pyverbs "" xrcd.pyx ) +if (DRM_INCLUDE_DIRS) +rdma_cython_module(pyverbs "" + dmabuf.pyx + dmabuf_alloc.c +) +else() +rdma_cython_module(pyverbs "" + dmabuf.pyx + dmabuf_alloc_stub.c +) +endif() + rdma_python_module(pyverbs __init__.py pyverbs_error.py diff --git a/pyverbs/dmabuf_alloc.c b/pyverbs/dmabuf_alloc.c index 85ffb7a..9978a5b 100644 --- a/pyverbs/dmabuf_alloc.c +++ b/pyverbs/dmabuf_alloc.c @@ -9,12 +9,12 @@ #include #include #include -#include -#include -#include -#include #include #include +#include +#include +#include +#include #include "dmabuf_alloc.h" /* diff --git a/pyverbs/dmabuf_alloc_stub.c b/pyverbs/dmabuf_alloc_stub.c new file mode 100644 index 0000000..a73a5da --- /dev/null +++ b/pyverbs/dmabuf_alloc_stub.c @@ -0,0 +1,39 @@ +// SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB +/* + * Copyright 2021 Intel Corporation. All rights reserved. See COPYING file + */ + +#include +#include +#include +#include "dmabuf_alloc.h" + +struct dmabuf *dmabuf_alloc(uint64_t size, int gpu, int gtt) +{ + errno = EOPNOTSUPP; + return NULL; +} + +void dmabuf_free(struct dmabuf *dmabuf) +{ + errno = EOPNOTSUPP; +} + +int dmabuf_get_drm_fd(struct dmabuf *dmabuf) +{ + errno = EOPNOTSUPP; + return -1; +} + +int dmabuf_get_fd(struct dmabuf *dmabuf) +{ + errno = EOPNOTSUPP; + return -1; +} + +uint64_t dmabuf_get_offset(struct dmabuf *dmabuf) +{ + errno = EOPNOTSUPP; + return -1; +} +