[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20200408191224.947302-1-arnd@arndb.de>
Date: Wed, 8 Apr 2020 21:07:05 +0200
From: Arnd Bergmann <arnd@...db.de>
To: Maarten Lankhorst <maarten.lankhorst@...ux.intel.com>,
Maxime Ripard <mripard@...nel.org>,
Thomas Zimmermann <tzimmermann@...e.de>,
David Airlie <airlied@...ux.ie>,
Daniel Vetter <daniel@...ll.ch>
Cc: Arnd Bergmann <arnd@...db.de>,
Chris Wilson <chris@...is-wilson.co.uk>,
Alex Deucher <alexander.deucher@....com>,
Sean Paul <seanpaul@...omium.org>,
Benjamin Gaignard <benjamin.gaignard@...com>,
Dan Carpenter <dan.carpenter@...cle.com>,
Dave Airlie <airlied@...hat.com>,
Sam Ravnborg <sam@...nborg.org>,
dri-devel@...ts.freedesktop.org, linux-kernel@...r.kernel.org
Subject: [PATCH] drm: work around dma_addr_t/resource_size_t mixup warning
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 <arnd@...db.de>
---
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;
--
2.26.0
Powered by blists - more mailing lists