From patchwork Wed Apr 8 19:07:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 11480695 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7D71792C for ; Wed, 8 Apr 2020 19:13:11 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6329620768 for ; Wed, 8 Apr 2020 19:13:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6329620768 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arndb.de Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 30F416EAB8; Wed, 8 Apr 2020 19:13:08 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mout.kundenserver.de (mout.kundenserver.de [217.72.192.74]) by gabe.freedesktop.org (Postfix) with ESMTPS id DF2B56E02E for ; Wed, 8 Apr 2020 19:13:05 +0000 (UTC) Received: from threadripper.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue107 [212.227.15.145]) with ESMTPA (Nemesis) id 1MybX9-1j6Gzx3Zgz-00z1aQ; Wed, 08 Apr 2020 21:12:28 +0200 From: Arnd Bergmann To: Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter Subject: [PATCH] drm: work around dma_addr_t/resource_size_t mixup warning Date: Wed, 8 Apr 2020 21:07:05 +0200 Message-Id: <20200408191224.947302-1-arnd@arndb.de>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fk wWUaXXuZmH0/dBZnDqCxaRfaAwCBEm0oSorEGafd5a+0pLV87DjM85awFTbr6+py+q4jAeeGz M/mOs+V9Fk6h37rJ/mp1s+XaIT7YAaNcrNgxn6UOZ1nDQ7DU0Q= X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Benjamin Gaignard , Arnd Bergmann , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Chris Wilson , Sean Paul , Alex Deucher , Dave Airlie , Sam Ravnborg , Dan Carpenter Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" On configurations with 64-bit dma_addr_t but 32-bit resource_size_t, there is now a warning: drivers/gpu/drm/drm_bufs.c: In function 'drm_addmap_core': drivers/gpu/drm/drm_bufs.c:328:8: error: passing argument 3 of 'dma_alloc_coherent' from incompatible pointer type [-Werror=incompatible-pointer-types] 328 | &map->offset, | ^~~~~~~~~~~~ | | | resource_size_t * {aka unsigned int *} In file included from include/linux/pci-dma-compat.h:8, from include/linux/pci.h:2392, from include/drm/drm_pci.h:35, from drivers/gpu/drm/drm_bufs.c:46: include/linux/dma-mapping.h:642:15: note: expected 'dma_addr_t *' {aka 'long long unsigned int *'} but argument is of type 'resource_size_t *' {aka 'unsigned int *'} 642 | dma_addr_t *dma_handle, gfp_t gfp) | ~~~~~~~~~~~~^~~~~~~~~~ I have no idea if this is safe on targets that may need a high DMA address, or why we store a DMA address token in a resource_size_t in the first place, but using a temporary variable avoids the warning. Fixes: 8e4ff9b56957 ("drm: Remove the dma_alloc_coherent wrapper for internal usage") Signed-off-by: Arnd Bergmann --- drivers/gpu/drm/drm_bufs.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/drm_bufs.c b/drivers/gpu/drm/drm_bufs.c index dcabf5698333..0fbe65c62f1e 100644 --- a/drivers/gpu/drm/drm_bufs.c +++ b/drivers/gpu/drm/drm_bufs.c @@ -149,6 +149,7 @@ static int drm_addmap_core(struct drm_device *dev, resource_size_t offset, { struct drm_local_map *map; struct drm_map_list *list; + dma_addr_t dma_addr; unsigned long user_token; int ret; @@ -325,8 +326,9 @@ static int drm_addmap_core(struct drm_device *dev, resource_size_t offset, * need to point to a 64bit variable first. */ map->handle = dma_alloc_coherent(&dev->pdev->dev, map->size, - &map->offset, + &dma_addr, GFP_KERNEL); + map->offset = (resource_size_t)dma_addr; if (!map->handle) { kfree(map); return -ENOMEM;