From patchwork Tue Mar 25 16:17:24 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 3888301 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 8FFDE9F2B6 for ; Tue, 25 Mar 2014 16:17:46 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B0DF220173 for ; Tue, 25 Mar 2014 16:17:45 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id BF08A20131 for ; Tue, 25 Mar 2014 16:17:44 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 586EC6E395; Tue, 25 Mar 2014 09:17:43 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-bk0-f52.google.com (mail-bk0-f52.google.com [209.85.214.52]) by gabe.freedesktop.org (Postfix) with ESMTP id 1FC926E395 for ; Tue, 25 Mar 2014 09:17:41 -0700 (PDT) Received: by mail-bk0-f52.google.com with SMTP id my13so274800bkb.11 for ; Tue, 25 Mar 2014 09:17:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; bh=kI77848UGoXy3MMcCK9D6ZRvIUZsjNyepjzbtVbjAHU=; b=xWntE6PowP9ydJW20SyhRT9wEuPmUTCPmFOJVE2mFNRnZBF+ELLfIolZ+Cia+fu9CO Q4n2mxSm4LmQ4yRnUW1GLywDURAgeJjnkUjypLDfwEsmjvQMsyocs8DHdwkC056f/C03 ItYGgKQnRonPG9ZEv/VHtEHq0TSL5+CVOeuRUq5TqdlJ3sbWkgj1hFzhVSlWR1Ysbsen vjNkEQjmo9ipODAGzAtphhttnJi8yC3NsVBpH9PIJFnnucpn8iU7qXtyIfETyjlrTKQi tmKBgrj46XjI7qb1iTASjsg8DAyk/JhgECXxKcD/fI8tgVSG93IuIAG1TMqjLEjLgYh8 8VXA== X-Received: by 10.205.1.136 with SMTP id nq8mr40637734bkb.21.1395764259784; Tue, 25 Mar 2014 09:17:39 -0700 (PDT) Received: from localhost (port-21158.pppoe.wtnet.de. [46.59.144.79]) by mx.google.com with ESMTPSA id xk2sm18424291bkb.9.2014.03.25.09.17.38 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 25 Mar 2014 09:17:38 -0700 (PDT) Date: Tue, 25 Mar 2014 17:17:24 +0100 From: Thierry Reding To: Greg Kroah-Hartman Subject: Re: [RFC] dma-buf: Implement test module Message-ID: <20140325161722.GA23842@ulmo> References: <1386858989-1487-1-git-send-email-treding@nvidia.com> <20131212144210.GA1527@ulmo.nvidia.com> <20131213020258.GC13333@kroah.com> MIME-Version: 1.0 In-Reply-To: <20131213020258.GC13333@kroah.com> User-Agent: Mutt/1.5.23 (2014-03-12) Cc: Michal Marek , linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.15 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" X-Spam-Status: No, score=-4.5 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Thu, Dec 12, 2013 at 06:02:58PM -0800, Greg Kroah-Hartman wrote: > On Thu, Dec 12, 2013 at 03:42:12PM +0100, Thierry Reding wrote: > > On Thu, Dec 12, 2013 at 03:36:29PM +0100, Thierry Reding wrote: > > > This is a simple test module that can be used to allocate, export and > > > delete DMA-BUF objects. It can be used to test DMA-BUF sharing in > > > systems that lack a real second driver. > > > > > > Signed-off-by: Thierry Reding > > > --- > > > drivers/base/Kconfig | 4 + > > > drivers/base/Makefile | 1 + > > > drivers/base/dma-buf-test.c | 308 ++++++++++++++++++++++++++++++++++++++++++++ > > > 3 files changed, 313 insertions(+) > > > create mode 100644 drivers/base/dma-buf-test.c > > > > And attached is a small test program that I've been using to test this > > new module. It can be built with: > > > > $ gcc -O2 -g -Wall -Werror -I/usr/include/libdrm -o dma-buf-test dma-buf-test.c -ldrm > > Please put this in the patch as well (scripts/tests/ ?) Sorry for taking so long to get back on this. I've tried various ways to make this work, but always ended up with something that didn't quite work. What I attempted was to put the test program into the samples/dma-buf subdirectory and use something along these lines: There are two things that don't work too well with this. First this causes the build to break if the build machine doesn't have the new public header (include/uapi/linux/dma-buf.h) installed yet. So the only way to make this work would be by building the kernel once with SAMPLES disabled, install the headers and then build again with SAMPLES enabled. Which really isn't very nice. One other option that I've tried is to modify the include path so that the test program would get the in-tree copy of the public header file, but that didn't build properly either because the header files aren't properly sanitized and therefore the compiler complains about it (include/uapi/linux/types.h). One other disadvantage of carrying the sample program in the tree is that there's only infrastructure to build programs natively on the build machine. That's somewhat unfortunate because if you want to run the test program on a different architecture you have to either compile the kernel natively on that architecture (which isn't very practical on many embedded devices) or cross-compile manually. I think a much nicer solution would be to add infrastructure to cross- compile these test programs, so that they end up being built for the same architecture as the kernel image (i.e. using CROSS_COMPILE). Adding Michal and the linux-kbuild mailing list, perhaps this has been discussed before, or maybe somebody has a better idea on how to solve this. Thierry diff --git a/samples/dma-buf/Makefile b/samples/dma-buf/Makefile new file mode 100644 index 000000000000..bcaa117474d7 --- /dev/null +++ b/samples/dma-buf/Makefile @@ -0,0 +1,8 @@ +obj- := dummy.o + +HOSTCFLAGS_dma-buf-test.o += $(shell pkg-config --cflags libdrm) +HOSTLOADLIBES_dma-buf-test += $(shell pkg-config --libs libdrm) + +hostprogs-y := dma-buf-test + +always := $(hostprogs-y)