From patchwork Fri Sep 28 14:45:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Grodzovsky X-Patchwork-Id: 10620095 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4DE20112B for ; Fri, 28 Sep 2018 14:45:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 36F182B948 for ; Fri, 28 Sep 2018 14:45:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2B3C22B987; Fri, 28 Sep 2018 14:45:32 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 64F5A2B095 for ; Fri, 28 Sep 2018 14:45:29 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 700D26E184; Fri, 28 Sep 2018 14:45:28 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from NAM04-SN1-obe.outbound.protection.outlook.com (mail-eopbgr700063.outbound.protection.outlook.com [40.107.70.63]) by gabe.freedesktop.org (Postfix) with ESMTPS id 60A506E184; Fri, 28 Sep 2018 14:45:27 +0000 (UTC) Received: from CY4PR1201CA0016.namprd12.prod.outlook.com (2603:10b6:910:16::26) by CY1PR12MB0427.namprd12.prod.outlook.com (2a01:111:e400:5191::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1164.25; Fri, 28 Sep 2018 14:45:25 +0000 Received: from CO1NAM03FT020.eop-NAM03.prod.protection.outlook.com (2a01:111:f400:7e48::203) by CY4PR1201CA0016.outlook.office365.com (2603:10b6:910:16::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.1185.20 via Frontend Transport; Fri, 28 Sep 2018 14:45:25 +0000 Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) Received: from SATLEXCHOV01.amd.com (165.204.84.17) by CO1NAM03FT020.mail.protection.outlook.com (10.152.80.178) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.20.1185.13 via Frontend Transport; Fri, 28 Sep 2018 14:45:24 +0000 Received: from ubuntu-1604-test.amd.com (10.34.1.3) by SATLEXCHOV01.amd.com (10.181.40.71) with Microsoft SMTP Server id 14.3.389.1; Fri, 28 Sep 2018 09:45:23 -0500 From: Andrey Grodzovsky To: , Subject: [PATCH libdrm v2 1/2] amdgpu/test: Allow BO mapping flags to be passed in tests Date: Fri, 28 Sep 2018 10:45:07 -0400 Message-ID: <1538145908-3153-1-git-send-email-andrey.grodzovsky@amd.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:165.204.84.17; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(376002)(346002)(136003)(39860400002)(396003)(2980300002)(428003)(189003)(199004)(97736004)(34290500001)(53416004)(53936002)(16586007)(4326008)(450100002)(51416003)(44832011)(86362001)(7696005)(110136005)(14444005)(54906003)(6636002)(6666003)(336012)(356003)(26005)(186003)(305945005)(126002)(476003)(47776003)(77096007)(106466001)(2616005)(36756003)(72206003)(426003)(68736007)(81166006)(81156014)(48376002)(8676002)(104016004)(478600001)(8936002)(105586002)(2906002)(486006)(316002)(5660300001)(50466002)(50226002); DIR:OUT; SFP:1101; SCL:1; SRVR:CY1PR12MB0427; H:SATLEXCHOV01.amd.com; FPR:; SPF:None; LANG:en; PTR:InfoDomainNonexistent; MX:1; A:1; X-Microsoft-Exchange-Diagnostics: 1; CO1NAM03FT020; 1:3icuqNcrBbjDsuv5qy/jE90cKTiX4cGiX0My9xp2QPBPxyp/4TPeosQ/qmoG/KOVgzhf0vr+Xtfn+HI/cS59dJw9mA6W4hHMnvdXFIFIFsa9tq9twlbYNi8zqUDTztEb X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a401ebec-0438-4f4e-a077-08d62551068d X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989299)(4534165)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(2017052603328)(7153060); SRVR:CY1PR12MB0427; X-Microsoft-Exchange-Diagnostics: 1; CY1PR12MB0427; 3:L7yQm86rqGjE8hqepQtwbP+Ncui78TdVFHLYegMDC2JFq4bMYvr3W44Oxq9NruraQQmyARoBx05aYJcl1Z7ePZhKIZxSr9YqbI+2LrEsAHiD+PrXU1+Q8FQd2plp6bntwXGR0h2Uwu8rEvpL6tmLc3HRrO+jvsZ0KMaByu0VdnMk82C8/doQys7dpaVt5X3XejZXXC4UpLdg1UDBL1GYPjXlL4+M/wBCZ4cXSe38YLbbz3pbgBLYjuvTxaNM+zGMGSM4v5EF0nug1QQ76S5g2uA7yaBUytGguAq7+SMrMxjGREtkqyWTCHPMwm5oPJ4H1IXLJ7vF0a7T4+q6HwpVOSxcFxChAqS0fV2AowNKUbE=; 25:dCOHutH9Atm8yxhVMDSm/0Tdth9m/YQNIllj1UeFlYUlXXzjoBMxR5IoRIQsQ1/Kcn0gnVMkYuiZCzac/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LLhk4tVHRx+JJ1hjttnH X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(3231355)(944501410)(52105095)(93006095)(93003095)(10201501046)(3002001)(6055026)(149066)(150057)(6041310)(20161123564045)(20161123560045)(20161123558120)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(201708071742011)(7699051); SRVR:CY1PR12MB0427; BCL:0; PCL:0; RULEID:; SRVR:CY1PR12MB0427; X-Microsoft-Exchange-Diagnostics: 1; CY1PR12MB0427; 4:s6MLOoVHnp5oZVaKAYiT5h/rYhA/MQmRbmvJUHHsRkkHt4S428Amjs8QA5rZ5OqfXpyB3ha1zaM4/uqmz9lmRKDtofa5tllwTUjsf8NtcCVucMy9WZKJwcCv3twTzWCsFzM42I8UJcimXbx47seX1qf3atClK6aJUNy23WN0HV7XEV6CcYRdgvDLNV4pSx0GU8bGijSTHTOZU/1CJn+sOjtdvGFeFhDBP5Sbku9iYkhMMv+s9bXImNeQ+F6oJU/jPdDESyHzyb6hUSKwyjKNf3ioj2nAJahUX0OdNEuazT9UHHXNtVewz/RQTViRrgtu X-Forefront-PRVS: 0809C12563 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY1PR12MB0427; 23:IDhtmiw0QA3r3aYMSXYwTzVXctxosj2lv6CGVLsUj?= TjRzDuZd/ADkKZ99+c7KfJlKx6O5C6kMZwWMv+dW6bHqfQCUjarpmnvdpCn0neDwyRGPjiqGC98j4nCgBTKbYrvVe42RJptp6lQorpb05LWW86hRvpU3GI8EeMzUtDx4yuW2Kvb6arBPbSIW+MAXGokhsmCDQyTm2HxW3F7aVnO8SA0t7VjwCcJt8JNUjbNzkV+N6hMzfmJukR5ql3zxYxbmSVqNUcNrX5RkRGo8A4042psK8HYy0FFwQVPCLTmM2L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InkulUfohSGYtQdY1YZ0md40RS7+JmDiHBqv7b+aEcD4Tanpbhm/fmnVw+FQCtYtzkhQfXr SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; CY1PR12MB0427; 20:bltcjHCmghXEa5gbueyRfqdBdOEvmO/EQePITXYEO8g7LidxV+R9Qgi4Fqt/cFGeJ4ChATpKUYZVit0CFJx3Df8nV+K+7dqzuwyf+AkP24NOPxnu3YsYuFyJ2m1kH4FctCCLM2JCqcAlRCNv6p7tHx5PDdQ3ZJMJA0OOmT4+NVPsbHUifiBdaYmAncpuLIXjA0lOURkSdeGYLWGvlohxK48E/NSM71QMXkBhT97EmoZjRCIQa4rxiT6uG/BWTa+Z X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Sep 2018 14:45:24.8277 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a401ebec-0438-4f4e-a077-08d62551068d X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXCHOV01.amd.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR12MB0427 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: amd-gfx@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP v2: Call amdgpu_bo_va_op_raw directly in amdgpu_bo_alloc_and_map_raw Move amdgpu_bo_alloc_and_map_raw into C file to avoid including unistd.h in amdgpu_test.h Signed-off-by: Andrey Grodzovsky --- tests/amdgpu/amdgpu_test.h | 59 +++++++++----------------------------------- tests/amdgpu/basic_tests.c | 61 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 72 insertions(+), 48 deletions(-) diff --git a/tests/amdgpu/amdgpu_test.h b/tests/amdgpu/amdgpu_test.h index 0609a74..a3830bd 100644 --- a/tests/amdgpu/amdgpu_test.h +++ b/tests/amdgpu/amdgpu_test.h @@ -280,7 +280,7 @@ static inline int gpu_mem_free(amdgpu_bo_handle bo, static inline int amdgpu_bo_alloc_wrap(amdgpu_device_handle dev, unsigned size, - unsigned alignment, unsigned heap, uint64_t flags, + unsigned alignment, unsigned heap, uint64_t alloc_flags, amdgpu_bo_handle *bo) { struct amdgpu_bo_alloc_request request = {}; @@ -290,7 +290,7 @@ amdgpu_bo_alloc_wrap(amdgpu_device_handle dev, unsigned size, request.alloc_size = size; request.phys_alignment = alignment; request.preferred_heap = heap; - request.flags = flags; + request.flags = alloc_flags; r = amdgpu_bo_alloc(dev, &request, &buf_handle); if (r) @@ -301,57 +301,20 @@ amdgpu_bo_alloc_wrap(amdgpu_device_handle dev, unsigned size, return 0; } +int amdgpu_bo_alloc_and_map_raw(amdgpu_device_handle dev, unsigned size, + unsigned alignment, unsigned heap, uint64_t alloc_flags, + uint64_t mapping_flags, amdgpu_bo_handle *bo, void **cpu, + uint64_t *mc_address, + amdgpu_va_handle *va_handle); + static inline int amdgpu_bo_alloc_and_map(amdgpu_device_handle dev, unsigned size, - unsigned alignment, unsigned heap, uint64_t flags, + unsigned alignment, unsigned heap, uint64_t alloc_flags, amdgpu_bo_handle *bo, void **cpu, uint64_t *mc_address, amdgpu_va_handle *va_handle) { - struct amdgpu_bo_alloc_request request = {}; - amdgpu_bo_handle buf_handle; - amdgpu_va_handle handle; - uint64_t vmc_addr; - int r; - - request.alloc_size = size; - request.phys_alignment = alignment; - request.preferred_heap = heap; - request.flags = flags; - - r = amdgpu_bo_alloc(dev, &request, &buf_handle); - if (r) - return r; - - r = amdgpu_va_range_alloc(dev, - amdgpu_gpu_va_range_general, - size, alignment, 0, &vmc_addr, - &handle, 0); - if (r) - goto error_va_alloc; - - r = amdgpu_bo_va_op(buf_handle, 0, size, vmc_addr, 0, AMDGPU_VA_OP_MAP); - if (r) - goto error_va_map; - - r = amdgpu_bo_cpu_map(buf_handle, cpu); - if (r) - goto error_cpu_map; - - *bo = buf_handle; - *mc_address = vmc_addr; - *va_handle = handle; - - return 0; - -error_cpu_map: - amdgpu_bo_cpu_unmap(buf_handle); - -error_va_map: - amdgpu_bo_va_op(buf_handle, 0, size, vmc_addr, 0, AMDGPU_VA_OP_UNMAP); - -error_va_alloc: - amdgpu_bo_free(buf_handle); - return r; + return amdgpu_bo_alloc_and_map_raw(dev, size, alignment, heap, + alloc_flags, 0, bo, cpu, mc_address, va_handle); } static inline int diff --git a/tests/amdgpu/basic_tests.c b/tests/amdgpu/basic_tests.c index 1adbddd..cceffc7 100644 --- a/tests/amdgpu/basic_tests.c +++ b/tests/amdgpu/basic_tests.c @@ -33,6 +33,7 @@ #include "amdgpu_test.h" #include "amdgpu_drm.h" +#include "util_math.h" static amdgpu_device_handle device_handle; static uint32_t major_version; @@ -286,6 +287,66 @@ static uint32_t shader_bin[] = { #define DATA_OFFSET 1024 +int amdgpu_bo_alloc_and_map_raw(amdgpu_device_handle dev, unsigned size, + unsigned alignment, unsigned heap, uint64_t alloc_flags, + uint64_t mapping_flags, amdgpu_bo_handle *bo, void **cpu, + uint64_t *mc_address, + amdgpu_va_handle *va_handle) +{ + struct amdgpu_bo_alloc_request request = {}; + amdgpu_bo_handle buf_handle; + amdgpu_va_handle handle; + uint64_t vmc_addr; + int r; + + request.alloc_size = size; + request.phys_alignment = alignment; + request.preferred_heap = heap; + request.flags = alloc_flags; + + r = amdgpu_bo_alloc(dev, &request, &buf_handle); + if (r) + return r; + + r = amdgpu_va_range_alloc(dev, + amdgpu_gpu_va_range_general, + size, alignment, 0, &vmc_addr, + &handle, 0); + if (r) + goto error_va_alloc; + + r = amdgpu_bo_va_op_raw(dev, buf_handle, 0, ALIGN(size, getpagesize()), vmc_addr, + AMDGPU_VM_PAGE_READABLE | + AMDGPU_VM_PAGE_WRITEABLE | + AMDGPU_VM_PAGE_EXECUTABLE | + alloc_flags, + AMDGPU_VA_OP_MAP); + if (r) + goto error_va_map; + + r = amdgpu_bo_cpu_map(buf_handle, cpu); + if (r) + goto error_cpu_map; + + *bo = buf_handle; + *mc_address = vmc_addr; + *va_handle = handle; + + return 0; + + error_cpu_map: + amdgpu_bo_cpu_unmap(buf_handle); + + error_va_map: + amdgpu_bo_va_op(buf_handle, 0, size, vmc_addr, 0, AMDGPU_VA_OP_UNMAP); + + error_va_alloc: + amdgpu_bo_free(buf_handle); + return r; +} + + + int suite_basic_tests_init(void) { struct amdgpu_gpu_info gpu_info = {0};