From patchwork Fri Mar 11 14:38:47 2016 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: 8565731 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 53CEFC0553 for ; Fri, 11 Mar 2016 14:38:58 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6B1252034C for ; Fri, 11 Mar 2016 14:38:57 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 80280202E9 for ; Fri, 11 Mar 2016 14:38:56 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0385A6E19C; Fri, 11 Mar 2016 14:38:54 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from pegasos-out.vodafone.de (pegasos-out.vodafone.de [80.84.1.38]) by gabe.freedesktop.org (Postfix) with ESMTP id DA4E36E19C for ; Fri, 11 Mar 2016 14:38:51 +0000 (UTC) Received: from localhost (localhost.localdomain [127.0.0.1]) by pegasos-out.vodafone.de (Rohrpostix2 Daemon) with ESMTP id 2556C5C0B95 for ; Fri, 11 Mar 2016 15:38:51 +0100 (CET) X-Virus-Scanned: amavisd-new at vodafone.de X-Spam-Score: 0.2 X-Spam-Level: X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, FREEMAIL_FROM,RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Authentication-Results: rohrpostix2.prod.vfnet.de (amavisd-new); dkim=pass header.i=@vodafone.de Received: from pegasos-out.vodafone.de ([127.0.0.1]) by localhost (rohrpostix2.prod.vfnet.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id tt1seCn1z0Zn for ; Fri, 11 Mar 2016 15:38:48 +0100 (CET) Received: from smtp-02.vodafone.de (xsmail-dmz4.prod.vfnet.de [10.215.254.35]) by pegasos-out.vodafone.de (Rohrpostix2 Daemon) with ESMTP id 64AE75C0A6C for ; Fri, 11 Mar 2016 15:38:48 +0100 (CET) X-DKIM: OpenDKIM Filter v2.6.8 pegasos-out.vodafone.de 64AE75C0A6C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vodafone.de; s=mail; t=1457707128; bh=s8CiFVb+lObA4g+KkWUDNXQ4DsikoZlDj3zbPp7JmRM=; h=From:To:Subject:Date; b=Y3JccbO1im4MUJ7YrXn+pTkAYMhgHLwJx+T7Rd9nPhTe4xd4H/INo0k2eEtMdNfed oKj9665oDLC6hKX/9DhCTUOxh+ep8LN+ZUJuEBhyTkbczEXXSMjQUUAzuh7KmtKBBr 9u9P+gKNL/zHMP1iVWw5dHdoLio9sBLbTXJe9wCY= X-Virus-Scanned: amavisd-new at vodafone.de Received: from smtp-02.vodafone.de ([127.0.0.1]) by localhost (xsmail-dmz4.prod.vfnet.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id UDYkDiFZC7h9 for ; Fri, 11 Mar 2016 15:38:47 +0100 (CET) From: =?UTF-8?q?Christian=20K=C3=B6nig?= To: dri-devel@lists.freedesktop.org Subject: [PATCH] amdgpu: add amdgpu_create_bo_from_userptr() Date: Fri, 11 Mar 2016 15:38:47 +0100 Message-Id: <1457707127-14516-1-git-send-email-deathsimple@vodafone.de> X-Mailer: git-send-email 2.5.0 MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 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-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Christian König We somehow forgot the flags paramter in amdgpu_create_bo_from_user_mem(). Fix that with a new function. Signed-off-by: Christian König Reviewed-by: Michel Dänzer --- amdgpu/amdgpu.h | 8 ++++++++ amdgpu/amdgpu_bo.c | 26 ++++++++++++++++++-------- 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/amdgpu/amdgpu.h b/amdgpu/amdgpu.h index 0851306..be7b924 100644 --- a/amdgpu/amdgpu.h +++ b/amdgpu/amdgpu.h @@ -637,6 +637,7 @@ int amdgpu_bo_import(amdgpu_device_handle dev, * want to map to GPU address space (make GPU accessible) * (This address must be correctly aligned). * \param size - [in] Size of allocation (must be correctly aligned) + * \param flags - [in] AMDGPU_GEM_USERPTR_* flags for userptr * \param buf_handle - [out] Buffer handle for the userptr memory * resource on submission and be used in other operations. * @@ -660,6 +661,13 @@ int amdgpu_bo_import(amdgpu_device_handle dev, * It is responsibility of caller to correctly specify access rights * on VA assignment. */ +int amdgpu_create_bo_from_userptr(amdgpu_device_handle dev, + void *cpu, uint64_t size, uint32_t flags, + amdgpu_bo_handle *buf_handle); + +/** + * Deprecated, don't use for new implementations + */ int amdgpu_create_bo_from_user_mem(amdgpu_device_handle dev, void *cpu, uint64_t size, amdgpu_bo_handle *buf_handle); diff --git a/amdgpu/amdgpu_bo.c b/amdgpu/amdgpu_bo.c index d30fd1e..61152fc 100644 --- a/amdgpu/amdgpu_bo.c +++ b/amdgpu/amdgpu_bo.c @@ -529,18 +529,16 @@ int amdgpu_bo_wait_for_idle(amdgpu_bo_handle bo, } } -int amdgpu_create_bo_from_user_mem(amdgpu_device_handle dev, - void *cpu, - uint64_t size, - amdgpu_bo_handle *buf_handle) +int amdgpu_create_bo_from_userptr(amdgpu_device_handle dev, + void *cpu, uint64_t size, uint32_t flags, + amdgpu_bo_handle *buf_handle) { - int r; - struct amdgpu_bo *bo; struct drm_amdgpu_gem_userptr args; + struct amdgpu_bo *bo; + int r; args.addr = (uintptr_t)cpu; - args.flags = AMDGPU_GEM_USERPTR_ANONONLY | AMDGPU_GEM_USERPTR_REGISTER | - AMDGPU_GEM_USERPTR_VALIDATE; + args.flags = flags; args.size = size; r = drmCommandWriteRead(dev->fd, DRM_AMDGPU_GEM_USERPTR, &args, sizeof(args)); @@ -561,6 +559,18 @@ int amdgpu_create_bo_from_user_mem(amdgpu_device_handle dev, return r; } +int amdgpu_create_bo_from_user_mem(amdgpu_device_handle dev, + void *cpu, uint64_t size, + amdgpu_bo_handle *buf_handle) +{ + uint32_t flags = AMDGPU_GEM_USERPTR_ANONONLY | + AMDGPU_GEM_USERPTR_REGISTER | + AMDGPU_GEM_USERPTR_VALIDATE; + + return amdgpu_create_bo_from_user_mem(dev, cpu, size, + flags, buf_handle); +} + int amdgpu_bo_list_create(amdgpu_device_handle dev, uint32_t number_of_resources, amdgpu_bo_handle *resources,