From patchwork Fri Jan 29 03:05:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 373273 Delivered-To: patches@linaro.org Received: by 2002:a02:a60d:0:0:0:0:0 with SMTP id c13csp1807922jam; Thu, 28 Jan 2021 19:05:17 -0800 (PST) X-Received: by 2002:a62:8801:0:b029:1b9:c4af:8148 with SMTP id l1-20020a6288010000b02901b9c4af8148mr2415104pfd.18.1611889517769; Thu, 28 Jan 2021 19:05:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611889517; cv=none; d=google.com; s=arc-20160816; b=IIdOYCBkUBkZpT2s5Nse1wrPJyYF5AGKZQVrVnB6NlF4S62B0TwwoA4w6Ix3sOklNw HmzdWN1dTyfrDaObnmxj76fPc31AINRBYMFVZ6mRuD29iyjblkyvKYUE7MP2wY4eX9KY gF5b18gg/2PLqxlb2t5ElHoEpOyZ33BB4RpjnFuDqH/n1uxfuQkA376xnIBjbWHyTcib YVBhqDrUY+fhT1g31nk+QFwMyzSA0od2UnBCn7wRn7WM3/WfUast2oB0ZPGhRYwHLroU 2BtnqVNwv1mzO9H3nrIamfEBACfVYerrEFhu3MR+qrkYng9e0d9GHTct420TCZ7cshJl DaQA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:dkim-signature; bh=6FtqZbVLoNhYzW/5zxBFGSTg2OJ2tv0Ub0qNAJ13xHs=; b=H5tkVATmIN2HUtgJNQIn9lEvZ9GXH2xTvSERTS1JnTi4Bdj4a/FAku2N5e4m+CKYlF tVaOKRWgS6cC7sF4To4Dl6NluPt8vQKJgnm5le7tv/w/jnGKHU9oahBMN1Pez3nljnbo sAFqxQJZi4zuSg7L6YJbl/x2iiruO7rCUMs+p4FjftmqK7sv20oKqHdUnOPgLaGEnRD3 rqXeTxHclal0cG4OL0upkb1C8DQeBN1yaeym7HFBqoslgFqFbtKMpU6MMp29lprR787v mz+NsYHTcdofJQHFLgX/NZz0fLhtYkf4e6DX4BU2fdShWNrxgI5ENbAYsu1Hoa7UKvi1 ZI0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=j5yLzHZt; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.41 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id f63sor4268217pjd.3.2021.01.28.19.05.17 for (Google Transport Security); Thu, 28 Jan 2021 19:05:17 -0800 (PST) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=j5yLzHZt; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.41 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=6FtqZbVLoNhYzW/5zxBFGSTg2OJ2tv0Ub0qNAJ13xHs=; b=j5yLzHZt+6y1rTjQAaHsDOTxGgaIO1Q9C9yvGJP/x3SkVLLnhJSUKnESb/H0Z9JJM3 X3o9CasXX6DZTksNat7StXwigWk+Orm9ia/zA32HYjwgB7fSoTv26tV1S3bs6YrGsFEp z4HPk5S+5CgJFgVQdxw+V7SZtaTKny8EBvZ3oJTURUzJ+ccHaYle+g1y092cga4L8huN RJggFGQ7Nhlb7TYWCH0Ubq1AsPnmdAUnLmHsDZinfH7eAFf/GnRcL4Dm4SijBHNx+FHZ Bw43r3f9o5DaCRZX9xsjG0o3Lr7MVysYUjjKamy51VBjfsyrADAgEtsWNzZdhWgazp4N PuAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=6FtqZbVLoNhYzW/5zxBFGSTg2OJ2tv0Ub0qNAJ13xHs=; b=Q5iogrpc8/pnhDAFlFFXIKtxOgEvG9GGlf26EPH8g/Cbsy7mbA2Jb5DoaW4XrgrRqH rI0pzbiOqPWsvH99PBE75/COYuxvoVtm61szkXULNGZW4gR11dxUxn6WWOFlofIgMWs5 TM8QGTF1y4uMMEYq8WcnaY8DCFqG+36lqp2M6lbsWE7iCr3M2scCmevWpanMYGgLSw0v 1LjGra/wYmZnO1QJ5B0DrjQK6sBv2VSZSmDG9tOTo5l+akFHsLK8oPIAvh4T9VCs3x6c lCN/95O3kYUUi8wDel6+J/omW+IZDniwanY9a3zPL/DsSzNqxocYGJyP5i1suQE5DACb 4NdA== X-Gm-Message-State: AOAM530weIOzym1Vpoty2SSP5JSfIcxwlocU4HSDJjQ16Mx399KSTL+X 4gPYtXwU5QVraO4dVUFBibeYbGqY X-Google-Smtp-Source: ABdhPJxNcoBMcdOeDQYd3FdgzjZ86Cf272Rz2la9I9NvjeaL4IhlWxZTBvB3/43QEa/+/6QJlLWKNA== X-Received: by 2002:a17:90a:d913:: with SMTP id c19mr2416772pjv.19.1611889517371; Thu, 28 Jan 2021 19:05:17 -0800 (PST) Return-Path: Received: from localhost.localdomain ([2601:1c2:680:1319:692:26ff:feda:3a81]) by smtp.gmail.com with ESMTPSA id y75sm6854496pfg.119.2021.01.28.19.05.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Jan 2021 19:05:16 -0800 (PST) From: John Stultz To: lkml Cc: John Stultz , Shuah Khan , Brian Starkey , Sumit Semwal , Laura Abbott , Hridya Valsaraju , Suren Baghdasaryan , Sandeep Patil , Daniel Mentz , linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kselftest@vger.kernel.org Subject: [PATCH 1/5] kselftests: dmabuf-heaps: Fix Makefile's inclusion of the kernel's usr/include dir Date: Fri, 29 Jan 2021 03:05:10 +0000 Message-Id: <20210129030514.1231773-1-john.stultz@linaro.org> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Copied in from somewhere else, the makefile was including the kerne's usr/include dir, which caused the asm/ioctl.h file to be used. Unfortunately, that file has different values for _IOC_SIZEBITS and _IOC_WRITE than include/uapi/asm-generic/ioctl.h which then causes the _IOCW macros to give the wrong ioctl numbers, specifically for DMA_BUF_IOCTL_SYNC. This patch simply removes the extra include from the Makefile Cc: Shuah Khan Cc: Brian Starkey Cc: Sumit Semwal Cc: Laura Abbott Cc: Hridya Valsaraju Cc: Suren Baghdasaryan Cc: Sandeep Patil Cc: Daniel Mentz Cc: linux-media@vger.kernel.org Cc: dri-devel@lists.freedesktop.org Cc: linux-kselftest@vger.kernel.org Fixes: a8779927fd86c ("kselftests: Add dma-heap test") Signed-off-by: John Stultz --- tools/testing/selftests/dmabuf-heaps/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.25.1 diff --git a/tools/testing/selftests/dmabuf-heaps/Makefile b/tools/testing/selftests/dmabuf-heaps/Makefile index 607c2acd2082..604b43ece15f 100644 --- a/tools/testing/selftests/dmabuf-heaps/Makefile +++ b/tools/testing/selftests/dmabuf-heaps/Makefile @@ -1,5 +1,5 @@ # SPDX-License-Identifier: GPL-2.0 -CFLAGS += -static -O3 -Wl,-no-as-needed -Wall -I../../../../usr/include +CFLAGS += -static -O3 -Wl,-no-as-needed -Wall TEST_GEN_PROGS = dmabuf-heap From patchwork Fri Jan 29 03:05:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 373274 Delivered-To: patches@linaro.org Received: by 2002:a02:a60d:0:0:0:0:0 with SMTP id c13csp1807935jam; Thu, 28 Jan 2021 19:05:19 -0800 (PST) X-Received: by 2002:a17:902:6a83:b029:dc:2a2c:6b91 with SMTP id n3-20020a1709026a83b02900dc2a2c6b91mr2461963plk.8.1611889519269; Thu, 28 Jan 2021 19:05:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611889519; cv=none; d=google.com; s=arc-20160816; b=NBCuQXa+OV+QS7HpchLeao6E7W60otWwze1ynfXdva0IDJlJo7uueawUl/FBLmA6rf Ilau8H/obz4jw145dQEE6OsrszSAoURUYPhdvomZX7zbcsRdbj6rQh7VI7U2gY1Mb5tE 1di7PcU5NpFtkjxhIqQJS2x0q2G57BLpo0uHXApGGv6oSu2K/XcZTPTkFkQGbBwQekmO iJ0niePK7NI42CfIPi6JCVtda3Jv2n8Eu2eQnattEtO2v9UCBd8wfyOuq7tbrZ6ZhUBO nUhFDkQnN+FbLkvScvVMyaA8fYcDceItAn395KgMCLgOYVo+XkmstF+kQaISgV9rd4jq 5zEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=++jZtzOYyQ1+vtEeMaOUIstaO3RLvVGMYd5LElrs3tk=; b=vxdlNqOwf9bNcjfeZWcb+lFfrfyYYmM/0d4yqJJnb9S41lw95SbIL73Qjlh5Vl1UiL nJmYjvlhlEVA3zblTlCurq/CF9u8GibEgNWHCxdtc2LxLhsIrnJ6rdRGyGjk2BjwEmfi v0ahozm9lghHPN/VoeTyIOO1oSMdySf8/3s0g+wklRxFG8CUcyVTX0EasqzQEJbeFF+T sasYgIwtkNWCKtwFcgi7nhbiZbyrALimd9FXWcbioUYVaYVNPRbIXy9AaBHga8yFR+KX d0COa4bRoj4BUyNegJZ6zBTAclqhsB6yLl2B76xxbZUBGm5cqQ0ZG3VkHrDeLCYTerD+ bGrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=uhyod5IV; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.41 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id 3sor4266397plb.67.2021.01.28.19.05.19 for (Google Transport Security); Thu, 28 Jan 2021 19:05:19 -0800 (PST) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=uhyod5IV; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.41 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=++jZtzOYyQ1+vtEeMaOUIstaO3RLvVGMYd5LElrs3tk=; b=uhyod5IVvkWiHsST5/O68YcC4Axe3RKRQzvKBXYml1+ezIoSduIUXyT3McvxxfQb6X MdGdB6a0QGYeKJPc6EOPv4LDPZzHfkLWnQhCaEjmTW+3EDXkZRQFpri3M7TDZpXFwknB nzDT/YpZaeczzI5+TCeNblHK1riCKukRLYsO4ZNEgO2aC4WhQT2Ut1dctUoeYX4W6t9T ZW828X9T4wU/86xrUnE1rqIASwioP5MyUUMrrPaQuKKUYlALfUnddC1lV5fGS3MkmN8L pujzNObUmAqlaJN71GQQzc71PDhg+rwgYMgYwG4kvOBSZEYKrvspyB0LF4dA10Zcxcfq DqSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=++jZtzOYyQ1+vtEeMaOUIstaO3RLvVGMYd5LElrs3tk=; b=n6jYukLBqoVgKDkoZ1wfwmaoEXtDo41g/3hMz/NmtaNqR4QruU2bgXFIEOC2Tqj7z4 FNrgn6q4SP0ymdMAGYVdfNIRldRU1pssgBP16JXAJoth0YYLDp4bS2DocNrM1QyPoE6K 1Wjoj4ymNFWtJ0KjM8Cuho/dz9HnDmKuqskHI3xSKHeb0QNdmywfjXexx8Za6iU8felG /wc+F4UhW9CqRcnmvKoL1TYI8EZbciMIhhVEt4+tLoroqjaIq+/orbYfMLgvuPqatFZ9 cZ6mReILCsaCuyvA+WxzL8tMUnXxq+B6kdgx0MPVV6TbNfA6pudVtq0REgiD9slm6w9H yR+A== X-Gm-Message-State: AOAM533k91gb2IN7gIeJ9TIJyqUpm/hOmAvtV5BXI8Wamiv4aGTrPzg+ 2i5uzI8A8wIGoX2N7kr6w5Aa+lG1 X-Google-Smtp-Source: ABdhPJyGn3wdGoYadza5iNZE6bj/nXq6MrRCQBVxL3lyhFqvG5bHcjloTEwy1RXyVtmPLRFrsk59eQ== X-Received: by 2002:a17:902:a710:b029:dc:3817:e7c2 with SMTP id w16-20020a170902a710b02900dc3817e7c2mr2361020plq.0.1611889518950; Thu, 28 Jan 2021 19:05:18 -0800 (PST) Return-Path: Received: from localhost.localdomain ([2601:1c2:680:1319:692:26ff:feda:3a81]) by smtp.gmail.com with ESMTPSA id y75sm6854496pfg.119.2021.01.28.19.05.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Jan 2021 19:05:18 -0800 (PST) From: John Stultz To: lkml Cc: John Stultz , Shuah Khan , Brian Starkey , Sumit Semwal , Laura Abbott , Hridya Valsaraju , Suren Baghdasaryan , Sandeep Patil , Daniel Mentz , linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kselftest@vger.kernel.org Subject: [PATCH 2/5] kselftests: dmabuf-heaps: Add clearer checks on DMABUF_BEGIN/END_SYNC Date: Fri, 29 Jan 2021 03:05:11 +0000 Message-Id: <20210129030514.1231773-2-john.stultz@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210129030514.1231773-1-john.stultz@linaro.org> References: <20210129030514.1231773-1-john.stultz@linaro.org> MIME-Version: 1.0 Add logic to check the dmabuf sync calls succeed. Cc: Shuah Khan Cc: Brian Starkey Cc: Sumit Semwal Cc: Laura Abbott Cc: Hridya Valsaraju Cc: Suren Baghdasaryan Cc: Sandeep Patil Cc: Daniel Mentz Cc: linux-media@vger.kernel.org Cc: dri-devel@lists.freedesktop.org Cc: linux-kselftest@vger.kernel.org Signed-off-by: John Stultz --- .../selftests/dmabuf-heaps/dmabuf-heap.c | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) -- 2.25.1 diff --git a/tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c b/tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c index 909da9cdda97..46f6759a8acc 100644 --- a/tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c +++ b/tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c @@ -130,16 +130,13 @@ static int dmabuf_heap_alloc(int fd, size_t len, unsigned int flags, dmabuf_fd); } -static void dmabuf_sync(int fd, int start_stop) +static int dmabuf_sync(int fd, int start_stop) { struct dma_buf_sync sync = { .flags = start_stop | DMA_BUF_SYNC_RW, }; - int ret; - ret = ioctl(fd, DMA_BUF_IOCTL_SYNC, &sync); - if (ret) - printf("sync failed %d\n", errno); + return ioctl(fd, DMA_BUF_IOCTL_SYNC, &sync); } #define ONE_MEG (1024 * 1024) @@ -197,9 +194,18 @@ static int test_alloc_and_import(char *heap_name) } printf("import passed\n"); - dmabuf_sync(dmabuf_fd, DMA_BUF_SYNC_START); + ret = dmabuf_sync(dmabuf_fd, DMA_BUF_SYNC_START); + if (ret < 0) { + printf("Sync start failed!\n"); + goto out; + } + memset(p, 0xff, ONE_MEG); - dmabuf_sync(dmabuf_fd, DMA_BUF_SYNC_END); + ret = dmabuf_sync(dmabuf_fd, DMA_BUF_SYNC_END); + if (ret < 0) { + printf("Sync end failed!\n"); + goto out; + } printf("syncs passed\n"); close_handle(importer_fd, handle); From patchwork Fri Jan 29 03:05:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 373275 Delivered-To: patches@linaro.org Received: by 2002:a02:a60d:0:0:0:0:0 with SMTP id c13csp1807960jam; Thu, 28 Jan 2021 19:05:20 -0800 (PST) X-Received: by 2002:a63:3e49:: with SMTP id l70mr2442768pga.96.1611889520810; Thu, 28 Jan 2021 19:05:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611889520; cv=none; d=google.com; s=arc-20160816; b=Rn3Gfi6ZGQ6fH+g140UwNFX2TMvGyDHnNaymEJD5Yr+IWNBfeR0X/0Hsf8/wKBpMZl xs9/7Mve31YXcxFTTlcdRaSlBAa/EsHbi7mtRhvoplno7PpjU9DfYe/h8wZWX3XhiQJL 53l2sA6AQmrmQlkt7OXjJuK4lbYNxjRvQ3NYxf388y05Gbcs/FvtatbV1Cyml++5zEyg K3R2XJGuIHhHNJhDYNpmUPXLC3KVEueirm09xehLkKmxEMOQ/Xd8acphGOnXJAJ6VWWZ 16LYa1wMsu1kI1df9D0s4FbgmztkaUlVTYaks5sWAm4uq6+E0+1QEe/tJIbEyGU3g4Df Mh5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=zTNb1lTIEVQ6SY+1PM+jItpjx6YB2483ibK9X9oBYPQ=; b=A8G5C9Emaq0AkuYdErfPZQVRnPPNIarXxjayRd7L9JFmSkNIh6E9FEfCGzAwcO9pyw rIWDPevNzgZsFPKXVFEfKyxxusGRAROUKdK76lTkYwxJIYAo9Q9ZqNX1tHy1SHnQ8UMU Aj9D2DuRP+GW4sQYgB/kXrVIRbi61fhOKZdSpyWk0jKQgWKRr66ZZX5/lPrZL1O3/CHw ynaGTR8dV8Uvk5rVd+Ouznd9YC3O9IR4BC33x51395K7JqgXAcFczUeXq3poOsdAKvGV TRXn3oZUUADUBi5Wuob4rpjkGLAGd9w+7yqaCWCpBdwTvBwY2DaGmGqiCIBaphljulsK XqNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=z1kwyFNg; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.41 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id v29sor3915223pgk.51.2021.01.28.19.05.20 for (Google Transport Security); Thu, 28 Jan 2021 19:05:20 -0800 (PST) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=z1kwyFNg; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.41 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=zTNb1lTIEVQ6SY+1PM+jItpjx6YB2483ibK9X9oBYPQ=; b=z1kwyFNg5hSYRi20ZvZ8wuUsM10FJZoI8McYKRlownqrb/9vwSuD19hHoANIKl9o7S NM3r0rFYtS7BoYRIxUKv2hJYefP+6PduFPKe6sNVWE7NJvVoSFSo+oGB5ds50UhCUA9V SyK9daFDnwbPsOxmmmogF/izeRWdoG3OgCQ6k0DmEgOaW1qa9ZwCI/06RZVukTBn91KD jWkK57VznZPmUOrJGfJnxT8iH5+1O3xSd8qHCSqHOszD3n07tm6upXSk82uB3LtU1IAy N+1l7G24LEncO+U+I1O4bg5Gt8C/bhkcHAaGe6YPBKuBSfvXS+AFhnzu9hoyFu2QqGYg S+4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=zTNb1lTIEVQ6SY+1PM+jItpjx6YB2483ibK9X9oBYPQ=; b=RP8oimMTJB0tpYkFVUekgBMmmxSM60r6ukokvD1Redvl1O8Xcc92gVjnLHTxt5xUrC 5HVB41EB6PRB8CNAJzHykOeVoRt79pIcBv7Ke9Rii0lpopx6AnZAJXx1sjSc5mKgaSUG i/SxBE6tY7J68sBvcLBEIvqWOEXZ0fYI3JSUp1QMR75UGi+qaMYYzakjHIvxPfr97uTN BAEcHF+bz3sIv9N6DOGTZdiYbxjb867GLtyGQrp08mvM9j4dsdioLkoa/JclMLi+xvrn pX6L+1gWlP1hlAXNzEI2fFDvon/60YrZe/bsNEzLDboYCx9tp4icTykhpEegrtJL+sUX chkw== X-Gm-Message-State: AOAM531kYWOMq/ucqo/KEDEBh5cswrorzC2En7iPPW3z+v+a6dsfZfqX AG3kcDN0zMH/TPAs1neo24B2mOFs X-Google-Smtp-Source: ABdhPJxgU85/WQXQ6xIZh5kol/FeQ53pYxb2sLTuRnfE+yO6MQ1sib5AHGRb02vCaC8rjeUx7mU2rw== X-Received: by 2002:a63:f404:: with SMTP id g4mr2518687pgi.114.1611889520497; Thu, 28 Jan 2021 19:05:20 -0800 (PST) Return-Path: Received: from localhost.localdomain ([2601:1c2:680:1319:692:26ff:feda:3a81]) by smtp.gmail.com with ESMTPSA id y75sm6854496pfg.119.2021.01.28.19.05.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Jan 2021 19:05:19 -0800 (PST) From: John Stultz To: lkml Cc: John Stultz , Shuah Khan , Brian Starkey , Sumit Semwal , Laura Abbott , Hridya Valsaraju , Suren Baghdasaryan , Sandeep Patil , Daniel Mentz , linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kselftest@vger.kernel.org Subject: [PATCH 3/5] kselftests: dmabuf-heaps: Softly fail if don't find a vgem device Date: Fri, 29 Jan 2021 03:05:12 +0000 Message-Id: <20210129030514.1231773-3-john.stultz@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210129030514.1231773-1-john.stultz@linaro.org> References: <20210129030514.1231773-1-john.stultz@linaro.org> MIME-Version: 1.0 While testing against a vgem device is helpful for testing importing they aren't always configured in, so don't make it a fatal failure. Cc: Shuah Khan Cc: Brian Starkey Cc: Sumit Semwal Cc: Laura Abbott Cc: Hridya Valsaraju Cc: Suren Baghdasaryan Cc: Sandeep Patil Cc: Daniel Mentz Cc: linux-media@vger.kernel.org Cc: dri-devel@lists.freedesktop.org Cc: linux-kselftest@vger.kernel.org Signed-off-by: John Stultz --- .../testing/selftests/dmabuf-heaps/dmabuf-heap.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) -- 2.25.1 diff --git a/tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c b/tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c index 46f6759a8acc..8cedd539c7fb 100644 --- a/tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c +++ b/tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c @@ -184,15 +184,14 @@ static int test_alloc_and_import(char *heap_name) if (importer_fd < 0) { ret = importer_fd; printf("Failed to open vgem\n"); - goto out; - } - - ret = import_vgem_fd(importer_fd, dmabuf_fd, &handle); - if (ret < 0) { - printf("Failed to import buffer\n"); - goto out; + } else { + ret = import_vgem_fd(importer_fd, dmabuf_fd, &handle); + if (ret < 0) { + printf("Failed to import buffer\n"); + goto out; + } + printf("import passed\n"); } - printf("import passed\n"); ret = dmabuf_sync(dmabuf_fd, DMA_BUF_SYNC_START); if (ret < 0) { From patchwork Fri Jan 29 03:05:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 373276 Delivered-To: patches@linaro.org Received: by 2002:a02:a60d:0:0:0:0:0 with SMTP id c13csp1807979jam; Thu, 28 Jan 2021 19:05:22 -0800 (PST) X-Received: by 2002:a63:e343:: with SMTP id o3mr2336187pgj.317.1611889522416; Thu, 28 Jan 2021 19:05:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611889522; cv=none; d=google.com; s=arc-20160816; b=gL8P7kgLYY5SlQQfM8Ph5QoyER8bCfsaBwcQVlpjOSkCScdcMkdgYDFVRRzCWMGqix paqEOi8msQV0OoarcyYjaJO412Y+05a9m6uzCxQphFA8GPBBv85LtshrwHJrSt6GhLVO 9Kkwqz3Jl9Sk/0hO2gh/YwXATnd/jhP7WPERmucAongjwpmVr80uZKNsXAWxYA0/MkAG yVDjJHZsrhjh2lKuGDLfikmt1FXjUPjthv/9WExMFt2lixshgFM/ZaZZayp+nRSCsFvS bWP9mwTFe7JndvOrOJcqYQDky8Jo2XOAthsZpGKu2wA6AIozjUi5UZI+hiVmS8sU048U wISw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=OKBQYxsiF/Yxl/0bRH0OqXnXLh71Bs92MecR17vq6CE=; b=GRCguwBq9JiRGHP90J06cD0QK1+T245Bq2Vi2qmkjjRMwzo9DMXKZGw0pWyfnp9CbG EIpBSVbKvWB/sra5govCJH/LQIexxyMzqRVEEkrEKyoYjWmehstAVZjtJOhzqgRW0ir5 qpOogCE3dZtysDNmDNveDNkMkJh1s3tdpIqh9fhh2ZidaF5FKh6QDOg1FX2wQhecdEdP vuH2avEV5di5ZKctfOXRNzZ7oBm3vWZvNpF2IufTC8qoMm0FYyRFf4AjeqmbGahWRpgh 67MtDDtEH3r1xKPLy+z7h3LwtBy+p4ij4H1ckr7LFeURTho46gTARUyKu1pSJF0vqmtA Qi2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YyD6yWoG; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.41 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id w19sor1995036ply.6.2021.01.28.19.05.22 for (Google Transport Security); Thu, 28 Jan 2021 19:05:22 -0800 (PST) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YyD6yWoG; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.41 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=OKBQYxsiF/Yxl/0bRH0OqXnXLh71Bs92MecR17vq6CE=; b=YyD6yWoGpCJBFSxr5KRkbyz5bfteCsw39788klP5cnw03qARl97eSoGDQg8ShaHYMB +9hHYQc9rgyU5dFnO0S/zoWBhNvMGrHZszlgbWsYa8/r5YlVRp0wOe8+HZ+UwUSMS2lY yZPXNzOj1dM0/CwLm0fOF5X9rnt6C0xec6nqE4t7OMnCEqxW+vteZ0eq3EaekznrH4/Y c0th+OgCWrgUpZXQtP7vfZiFqOZP3fiO2Q+eWnlD9H/a4yIsK5oJK66xr8s3E28ZcDFP rh1/IQ9t+f4HhBcbqODmoetiQSjoK5X4ERzDst+KHYWNvCwCDiyCUuK/pvBvCQt751Hg F9BA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=OKBQYxsiF/Yxl/0bRH0OqXnXLh71Bs92MecR17vq6CE=; b=sFMNUuO7O/4ZlFBnH8l+FpU9EcOwvHsp1Jiywho8Q+tEjHjeqRpHSPrfVyrQYl6fpr v+PP/eGbenu3d03Zhu+iahb4FqSJeJDr2Sq46F50BwKbb6NnBxh/owIqa++YpS8PUyOG Ixd86d5qrDb7n5lzKc9BWaOy9P5ScQeb3sUal3rQy3b2/g/QmI5oYkrcHSlwafYNJaRn kCnqwHMGzWGKomrUP9ZBj5Z/EAKRGs3F7nPnJ60yHdS+HEuWzMtJbr4PegcwWWAByXdU +TX79aDKsity8t406hhqQmzAvetC7tTw+tHxuC1xaxexBOvGKmwxUK/CveB8LvQYNjxC qOJA== X-Gm-Message-State: AOAM5306bkLCr6GcA7/XbkrdvDWmPDaXHZJDGTOqU4WMnKbBRyv+Idu4 Y715anccqirZhzCSWrpj6cxwB7qx X-Google-Smtp-Source: ABdhPJwFkKoGEbsS48QlG2raIqaa9osIVu/ssWmT+77IVRcpOInpa7ki/IP6MdqqkEeLDOObv8Sjsw== X-Received: by 2002:a17:902:d2c1:b029:de:7c38:f86a with SMTP id n1-20020a170902d2c1b02900de7c38f86amr2336534plc.83.1611889522041; Thu, 28 Jan 2021 19:05:22 -0800 (PST) Return-Path: Received: from localhost.localdomain ([2601:1c2:680:1319:692:26ff:feda:3a81]) by smtp.gmail.com with ESMTPSA id y75sm6854496pfg.119.2021.01.28.19.05.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Jan 2021 19:05:21 -0800 (PST) From: John Stultz To: lkml Cc: John Stultz , Shuah Khan , Brian Starkey , Sumit Semwal , Laura Abbott , Hridya Valsaraju , Suren Baghdasaryan , Sandeep Patil , Daniel Mentz , linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kselftest@vger.kernel.org Subject: [PATCH 4/5] kselftests: dmabuf-heaps: Cleanup test output Date: Fri, 29 Jan 2021 03:05:13 +0000 Message-Id: <20210129030514.1231773-4-john.stultz@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210129030514.1231773-1-john.stultz@linaro.org> References: <20210129030514.1231773-1-john.stultz@linaro.org> MIME-Version: 1.0 Cleanup the test output so it is a bit easier to read Cc: Shuah Khan Cc: Brian Starkey Cc: Sumit Semwal Cc: Laura Abbott Cc: Hridya Valsaraju Cc: Suren Baghdasaryan Cc: Sandeep Patil Cc: Daniel Mentz Cc: linux-media@vger.kernel.org Cc: dri-devel@lists.freedesktop.org Cc: linux-kselftest@vger.kernel.org Signed-off-by: John Stultz --- .../selftests/dmabuf-heaps/dmabuf-heap.c | 44 +++++++++---------- 1 file changed, 21 insertions(+), 23 deletions(-) -- 2.25.1 diff --git a/tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c b/tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c index 8cedd539c7fb..d179d81e2355 100644 --- a/tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c +++ b/tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c @@ -148,16 +148,14 @@ static int test_alloc_and_import(char *heap_name) void *p = NULL; int ret; - printf("Testing heap: %s\n", heap_name); - heap_fd = dmabuf_heap_open(heap_name); if (heap_fd < 0) return -1; - printf("Allocating 1 MEG\n"); + printf(" Testing allocation and importing: "); ret = dmabuf_heap_alloc(heap_fd, ONE_MEG, 0, &dmabuf_fd); if (ret) { - printf("Allocation Failed!\n"); + printf("FAIL (Allocation Failed!)\n"); ret = -1; goto out; } @@ -169,11 +167,10 @@ static int test_alloc_and_import(char *heap_name) dmabuf_fd, 0); if (p == MAP_FAILED) { - printf("mmap() failed: %m\n"); + printf("FAIL (mmap() failed)\n"); ret = -1; goto out; } - printf("mmap passed\n"); dmabuf_sync(dmabuf_fd, DMA_BUF_SYNC_START); memset(p, 1, ONE_MEG / 2); @@ -183,33 +180,31 @@ static int test_alloc_and_import(char *heap_name) importer_fd = open_vgem(); if (importer_fd < 0) { ret = importer_fd; - printf("Failed to open vgem\n"); + printf("(Could not open vgem - skipping): "); } else { ret = import_vgem_fd(importer_fd, dmabuf_fd, &handle); if (ret < 0) { - printf("Failed to import buffer\n"); + printf("FAIL (Failed to import buffer)\n"); goto out; } - printf("import passed\n"); } ret = dmabuf_sync(dmabuf_fd, DMA_BUF_SYNC_START); if (ret < 0) { - printf("Sync start failed!\n"); + printf("FAIL (DMA_BUF_SYNC_START failed!)\n"); goto out; } memset(p, 0xff, ONE_MEG); ret = dmabuf_sync(dmabuf_fd, DMA_BUF_SYNC_END); if (ret < 0) { - printf("Sync end failed!\n"); + printf("FAIL (DMA_BUF_SYNC_END failed!)\n"); goto out; } - printf("syncs passed\n"); close_handle(importer_fd, handle); ret = 0; - + printf(" OK\n"); out: if (p) munmap(p, ONE_MEG); @@ -297,23 +292,24 @@ static int test_alloc_compat(char *heap_name) if (heap_fd < 0) return -1; - printf("Testing (theoretical)older alloc compat\n"); + printf(" Testing (theoretical)older alloc compat: "); ret = dmabuf_heap_alloc_older(heap_fd, ONE_MEG, 0, &dmabuf_fd); if (ret) { - printf("Older compat allocation failed!\n"); + printf("FAIL (Older compat allocation failed!)\n"); ret = -1; goto out; } close(dmabuf_fd); + printf("OK\n"); - printf("Testing (theoretical)newer alloc compat\n"); + printf(" Testing (theoretical)newer alloc compat: "); ret = dmabuf_heap_alloc_newer(heap_fd, ONE_MEG, 0, &dmabuf_fd); if (ret) { - printf("Newer compat allocation failed!\n"); + printf("FAIL (Newer compat allocation failed!)\n"); ret = -1; goto out; } - printf("Ioctl compatibility tests passed\n"); + printf("OK\n"); out: if (dmabuf_fd >= 0) close(dmabuf_fd); @@ -332,17 +328,17 @@ static int test_alloc_errors(char *heap_name) if (heap_fd < 0) return -1; - printf("Testing expected error cases\n"); + printf(" Testing expected error cases: "); ret = dmabuf_heap_alloc(0, ONE_MEG, 0x111111, &dmabuf_fd); if (!ret) { - printf("Did not see expected error (invalid fd)!\n"); + printf("FAIL (Did not see expected error (invalid fd)!)\n"); ret = -1; goto out; } ret = dmabuf_heap_alloc(heap_fd, ONE_MEG, 0x111111, &dmabuf_fd); if (!ret) { - printf("Did not see expected error (invalid heap flags)!\n"); + printf("FAIL (Did not see expected error (invalid heap flags)!)\n"); ret = -1; goto out; } @@ -350,12 +346,12 @@ static int test_alloc_errors(char *heap_name) ret = dmabuf_heap_alloc_fdflags(heap_fd, ONE_MEG, ~(O_RDWR | O_CLOEXEC), 0, &dmabuf_fd); if (!ret) { - printf("Did not see expected error (invalid fd flags)!\n"); + printf("FAIL (Did not see expected error (invalid fd flags)!)\n"); ret = -1; goto out; } - printf("Expected error checking passed\n"); + printf("OK\n"); ret = 0; out: if (dmabuf_fd >= 0) @@ -384,6 +380,8 @@ int main(void) if (!strncmp(dir->d_name, "..", 3)) continue; + printf("Testing heap: %s\n", dir->d_name); + printf("=======================================\n"); ret = test_alloc_and_import(dir->d_name); if (ret) break; From patchwork Fri Jan 29 03:05:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 373277 Delivered-To: patches@linaro.org Received: by 2002:a02:a60d:0:0:0:0:0 with SMTP id c13csp1807989jam; Thu, 28 Jan 2021 19:05:24 -0800 (PST) X-Received: by 2002:a17:902:744b:b029:e1:2169:6272 with SMTP id e11-20020a170902744bb02900e121696272mr1029668plt.35.1611889523980; Thu, 28 Jan 2021 19:05:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611889523; cv=none; d=google.com; s=arc-20160816; b=GE59xihQyo3vh2r3DJX4MxqNstD0nlk2Wwdhz9SynuEzFkneWQ5wZfWcU4A5Wq17Hp 9DaLUkIz0my3Y6Dq9rhmP6iV5eYjQj8K9Z6J/P6R+19YIkwQRKYhb7vgNTztf+rCvQoe O5fkpqio6K4YiYdfPiSbQpiteWloDqLvIw5taFIUxh5zk0mI3njX9twCqgv5CbWjXhMt emLzcY4rqDjK1hGxVe+Gqv8wWfnPjpavbvVS6019GLiB92x6Hn7O82BzCf1bu2bVwo/7 cOMUpIgCvRdQv3iwuJdbGDjjfOa3zgOpfdBspbVRm2i+bj1yklhyetsG/z6oKeEOGepa TqHw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=wpJLS1/K6quxDCtF6ZEY+ZhZmpb559yflYmJJ80BQbw=; b=t8BsgJXeT5wdllAv0SQwzNUpF0/J09BLsrvMJJsugke3U8CCQEhDADKLF+tjfNyB/u YinWSUs95YnOOuBHe6nxxzCn9Oojo7N8qTWQIV1tj0VnPyjDdu+NLop46mKvBeFkbV+r FGAAR8nt6mBJuizRDrDNKPRUISVrTZUMVPymknLhrFh3j9J5+KFwUoPdD2LegOj0x8f+ wTrpGawc3rRUFSVZFxUMuKf6z2Ht1DKOAE1W6nFyMt6L7n2d8EUuO4K4V9tFbLrgGGCe RqFrpYmL7Wc5cGbhCnnMiQdLGwVzdUQ+RH7BcPU4SbN0BrCQFlIdPkOVj+VHdc+E+HKf IScA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=cZnqhzUW; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.41 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id lr18sor4310658pjb.7.2021.01.28.19.05.23 for (Google Transport Security); Thu, 28 Jan 2021 19:05:23 -0800 (PST) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=cZnqhzUW; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.41 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=wpJLS1/K6quxDCtF6ZEY+ZhZmpb559yflYmJJ80BQbw=; b=cZnqhzUWTkKR+GwYZalkxCsk9v9+2TUHpqGdSzHbuzov/fz1EkYstH68r/3oEpBW4B j9HutROkJfo28jDndi/gV5EZvIxT/IvLYHbyAhy042zJll0UXIyFaTtdkdfm1pWRZToD qJNtH2kDgXuipk6oJauJVzId5wPVjtS8ROisYKCY1doPKQ9nTPjmC/4IvcnlCRc1KC1n DRsJbcQ++faIJpPy/nlSw9IvR5qTxi4nXUkmJxV83pOPbfv1Elfk36n3a5eGRn6K7uKN hS8uxtEET+0pZuiSShr41z6L8+dxqy/ZVQzp55rFqyS8L8K8IXZDJV1eEsX2o3LQGuP7 ENuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=wpJLS1/K6quxDCtF6ZEY+ZhZmpb559yflYmJJ80BQbw=; b=BPmB1aIpnz6XlBF8CCQz13IoxyP1jcZoacq+y1FoERBYLAuWKGZAPtxZXIUTKyhutv WozbYkkrJnbEfAUfe7OM1HDS5n0xrVgdCtej4GJj2slJbPMDS1AAYfm52ZeSe/FZ6BFG KMuvkk7wAAabuDpaIuWxSY/fDfs6QdENhQ7heSsBGPdwHvd4vfGmNo+p0mqib53t1Ksl Spho8pI607lMyq8eXOv83C4608kg28EeBXisWDtcDQoMwZbNYO0jYbk1KzP314s/2LJP z+ahmCSpZZCRIVMw0UfBXWb7gUIi8o1Vas8txrAs8Rbwz81a9Iqpk+cORdmJ984lpiR7 wxCg== X-Gm-Message-State: AOAM532YueCjGnFKa2WS+MqWuxAF1PqjuAoFUFez1d0K8I50XWmsTEmv 1HAuiyN+Rb3TS4CD8nv3SC7GpoVw X-Google-Smtp-Source: ABdhPJy2aymxhZ7yZWwAmLLNyftYCwd61PtfrChhA2K/S/ZWzs+EOTzqXZihvePJ3BjBNSZPTK19KA== X-Received: by 2002:a17:90a:8e82:: with SMTP id f2mr2405873pjo.234.1611889523668; Thu, 28 Jan 2021 19:05:23 -0800 (PST) Return-Path: Received: from localhost.localdomain ([2601:1c2:680:1319:692:26ff:feda:3a81]) by smtp.gmail.com with ESMTPSA id y75sm6854496pfg.119.2021.01.28.19.05.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Jan 2021 19:05:22 -0800 (PST) From: John Stultz To: lkml Cc: John Stultz , Shuah Khan , Brian Starkey , Sumit Semwal , Laura Abbott , Hridya Valsaraju , Suren Baghdasaryan , Sandeep Patil , Daniel Mentz , linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kselftest@vger.kernel.org Subject: [PATCH 5/5] kselftests: dmabuf-heaps: Add extra checking that allocated buffers are zeroed Date: Fri, 29 Jan 2021 03:05:14 +0000 Message-Id: <20210129030514.1231773-5-john.stultz@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210129030514.1231773-1-john.stultz@linaro.org> References: <20210129030514.1231773-1-john.stultz@linaro.org> MIME-Version: 1.0 Add a check to validate that buffers allocated from the heaps are properly zeroed before being given to userland. It is done by allocating a number of buffers, and filling them with a nonzero pattern, then closing and reallocating more buffers and checking that they are all properly zeroed. This is helpful to validate any cached buffers are zeroed before being given back out. Cc: Shuah Khan Cc: Brian Starkey Cc: Sumit Semwal Cc: Laura Abbott Cc: Hridya Valsaraju Cc: Suren Baghdasaryan Cc: Sandeep Patil Cc: Daniel Mentz Cc: linux-media@vger.kernel.org Cc: dri-devel@lists.freedesktop.org Cc: linux-kselftest@vger.kernel.org Signed-off-by: John Stultz --- .../selftests/dmabuf-heaps/dmabuf-heap.c | 86 +++++++++++++++++++ 1 file changed, 86 insertions(+) -- 2.25.1 diff --git a/tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c b/tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c index d179d81e2355..29af27acd40e 100644 --- a/tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c +++ b/tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c @@ -218,6 +218,84 @@ static int test_alloc_and_import(char *heap_name) return ret; } +static int test_alloc_zeroed(char *heap_name, size_t size) +{ + int heap_fd = -1, dmabuf_fd[32]; + int i, j, ret; + void *p = NULL; + char *c; + + printf(" Testing alloced %ldk buffers are zeroed: ", size / 1024); + heap_fd = dmabuf_heap_open(heap_name); + if (heap_fd < 0) + return -1; + + /* Allocate and fill a bunch of buffers */ + for (i = 0; i < 32; i++) { + ret = dmabuf_heap_alloc(heap_fd, size, 0, &dmabuf_fd[i]); + if (ret < 0) { + printf("FAIL (Allocation (%i) failed)\n", i); + goto out; + } + /* mmap and fill with simple pattern */ + p = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, dmabuf_fd[i], 0); + if (p == MAP_FAILED) { + printf("FAIL (mmap() failed!)\n"); + ret = -1; + goto out; + } + dmabuf_sync(dmabuf_fd[i], DMA_BUF_SYNC_START); + memset(p, 0xff, size); + dmabuf_sync(dmabuf_fd[i], DMA_BUF_SYNC_END); + munmap(p, size); + } + /* close them all */ + for (i = 0; i < 32; i++) + close(dmabuf_fd[i]); + + /* Allocate and validate all buffers are zeroed */ + for (i = 0; i < 32; i++) { + ret = dmabuf_heap_alloc(heap_fd, size, 0, &dmabuf_fd[i]); + if (ret < 0) { + printf("FAIL (Allocation (%i) failed)\n", i); + goto out; + } + + /* mmap and validate everything is zero */ + p = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, dmabuf_fd[i], 0); + if (p == MAP_FAILED) { + printf("FAIL (mmap() failed!)\n"); + ret = -1; + goto out; + } + dmabuf_sync(dmabuf_fd[i], DMA_BUF_SYNC_START); + c = (char *)p; + for (j = 0; j < size; j++) { + if (c[j] != 0) { + printf("FAIL (Allocated buffer not zeroed @ %i)\n", j); + break; + } + } + dmabuf_sync(dmabuf_fd[i], DMA_BUF_SYNC_END); + munmap(p, size); + } + /* close them all */ + for (i = 0; i < 32; i++) + close(dmabuf_fd[i]); + + close(heap_fd); + printf("OK\n"); + return 0; + +out: + while (i > 0) { + close(dmabuf_fd[i]); + i--; + } + close(heap_fd); + return ret; +} + /* Test the ioctl version compatibility w/ a smaller structure then expected */ static int dmabuf_heap_alloc_older(int fd, size_t len, unsigned int flags, int *dmabuf_fd) @@ -386,6 +464,14 @@ int main(void) if (ret) break; + ret = test_alloc_zeroed(dir->d_name, 4 * 1024); + if (ret) + break; + + ret = test_alloc_zeroed(dir->d_name, ONE_MEG); + if (ret) + break; + ret = test_alloc_compat(dir->d_name); if (ret) break;