From patchwork Tue Aug 14 09:56:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Michel_D=C3=A4nzer?= X-Patchwork-Id: 10565239 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 BB0F21515 for ; Tue, 14 Aug 2018 09:57:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A83AE295CE for ; Tue, 14 Aug 2018 09:57:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9CCE829858; Tue, 14 Aug 2018 09:57:14 +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=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 DC449295CE for ; Tue, 14 Aug 2018 09:57:03 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C80E76E09D; Tue, 14 Aug 2018 09:57:00 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from netline-mail3.netline.ch (mail.netline.ch [148.251.143.178]) by gabe.freedesktop.org (Postfix) with ESMTP id 607586E09D for ; Tue, 14 Aug 2018 09:56:59 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by netline-mail3.netline.ch (Postfix) with ESMTP id 8B8F72A604C for ; Tue, 14 Aug 2018 11:56:58 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at netline-mail3.netline.ch Received: from netline-mail3.netline.ch ([127.0.0.1]) by localhost (netline-mail3.netline.ch [127.0.0.1]) (amavisd-new, port 10024) with LMTP id B7cCtpX4qQgN for ; Tue, 14 Aug 2018 11:56:58 +0200 (CEST) Received: from kaveri (67.124.127.176.dynamic.wline.res.cust.swisscom.ch [176.127.124.67]) by netline-mail3.netline.ch (Postfix) with ESMTPSA id 29B432A604B for ; Tue, 14 Aug 2018 11:56:58 +0200 (CEST) Received: from daenzer by kaveri with local (Exim 4.91) (envelope-from ) id 1fpW4P-0002qs-SA for dri-devel@lists.freedesktop.org; Tue, 14 Aug 2018 11:56:57 +0200 From: =?utf-8?q?Michel_D=C3=A4nzer?= To: dri-devel@lists.freedesktop.org Subject: [PATCH libdrm 2/2] amdgpu: Use char* pointers in amdgpu_find_bo_by_cpu_mapping Date: Tue, 14 Aug 2018 11:56:57 +0200 Message-Id: <20180814095657.10914-2-michel@daenzer.net> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180814095657.10914-1-michel@daenzer.net> References: <20180814095657.10914-1-michel@daenzer.net> MIME-Version: 1.0 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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Michel Dänzer Arithmetic using void* pointers isn't defined by the C standard, only as a GCC extension. Avoids compiler warnings: ../../amdgpu/amdgpu_bo.c: In function ‘amdgpu_find_bo_by_cpu_mapping’: ../../amdgpu/amdgpu_bo.c:554:48: warning: pointer of type ‘void *’ used in arithmetic [-Wpointer-arith] if (cpu >= bo->cpu_ptr && cpu < (bo->cpu_ptr + bo->alloc_size)) ^ ../../amdgpu/amdgpu_bo.c:561:23: warning: pointer of type ‘void *’ used in subtraction [-Wpointer-arith] *offset_in_bo = cpu - bo->cpu_ptr; ^ Fixes: 4d454424e1f2 ("amdgpu: add a function to find bo by cpu mapping (v2)") Signed-off-by: Michel Dänzer --- amdgpu/amdgpu.h | 2 +- amdgpu/amdgpu_bo.c | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/amdgpu/amdgpu.h b/amdgpu/amdgpu.h index a8c353c6..f2bdeb95 100644 --- a/amdgpu/amdgpu.h +++ b/amdgpu/amdgpu.h @@ -695,7 +695,7 @@ int amdgpu_create_bo_from_user_mem(amdgpu_device_handle dev, * */ int amdgpu_find_bo_by_cpu_mapping(amdgpu_device_handle dev, - void *cpu, + char *cpu, uint64_t size, amdgpu_bo_handle *buf_handle, uint64_t *offset_in_bo); diff --git a/amdgpu/amdgpu_bo.c b/amdgpu/amdgpu_bo.c index 86d1c143..ef75f1d0 100644 --- a/amdgpu/amdgpu_bo.c +++ b/amdgpu/amdgpu_bo.c @@ -530,7 +530,7 @@ int amdgpu_bo_wait_for_idle(amdgpu_bo_handle bo, } int amdgpu_find_bo_by_cpu_mapping(amdgpu_device_handle dev, - void *cpu, + char *cpu, uint64_t size, amdgpu_bo_handle *buf_handle, uint64_t *offset_in_bo) @@ -551,14 +551,15 @@ int amdgpu_find_bo_by_cpu_mapping(amdgpu_device_handle dev, bo = handle_table_lookup(&dev->bo_handles, i); if (!bo || !bo->cpu_ptr || size > bo->alloc_size) continue; - if (cpu >= bo->cpu_ptr && cpu < (bo->cpu_ptr + bo->alloc_size)) + if (cpu >= (char*)bo->cpu_ptr && + cpu < ((char*)bo->cpu_ptr + bo->alloc_size)) break; } if (i < dev->bo_handles.max_key) { atomic_inc(&bo->refcount); *buf_handle = bo; - *offset_in_bo = cpu - bo->cpu_ptr; + *offset_in_bo = cpu - (char*)bo->cpu_ptr; } else { *buf_handle = NULL; *offset_in_bo = 0;