From: Daniel Vetter <daniel@ffwll.ch>
To: Arnd Bergmann <arnd@arndb.de>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
Maxime Ripard <mripard@kernel.org>,
Thomas Zimmermann <tzimmermann@suse.de>,
David Airlie <airlied@linux.ie>,
Chris Wilson <chris@chris-wilson.co.uk>,
Alex Deucher <alexander.deucher@amd.com>,
Sean Paul <seanpaul@chromium.org>,
Benjamin Gaignard <benjamin.gaignard@st.com>,
Dan Carpenter <dan.carpenter@oracle.com>,
Dave Airlie <airlied@redhat.com>, Sam Ravnborg <sam@ravnborg.org>,
dri-devel <dri-devel@lists.freedesktop.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] drm: work around dma_addr_t/resource_size_t mixup warning
Date: Thu, 9 Apr 2020 09:09:46 +0200 [thread overview]
Message-ID: <CAKMK7uGsF-C7AXjLESDYb6=09qp0j+OXS9OgLEVCFd9-GAo-kg@mail.gmail.com> (raw)
In-Reply-To: <20200408191224.947302-1-arnd@arndb.de>
The fix got stuck a bit, I just pushed it out, should make it to the
next linux-next:
commit b2ecb89c27a4fd110187e0afeca70557215f55a1 (drm-misc-next-fixes)
Author: Chris Wilson <chris@chris-wilson.co.uk>
Date: Thu Apr 2 22:59:26 2020 +0100
drm/legacy: Fix type for drm_local_map.offset
Cheers, Daniel
On Wed, Apr 8, 2020 at 9:12 PM Arnd Bergmann <arnd@arndb.de> wrote:
>
> 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@arndb.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
>
--
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
prev parent reply other threads:[~2020-04-09 7:10 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-08 19:07 [PATCH] drm: work around dma_addr_t/resource_size_t mixup warning Arnd Bergmann
2020-04-09 7:09 ` Daniel Vetter [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAKMK7uGsF-C7AXjLESDYb6=09qp0j+OXS9OgLEVCFd9-GAo-kg@mail.gmail.com' \
--to=daniel@ffwll.ch \
--cc=airlied@linux.ie \
--cc=airlied@redhat.com \
--cc=alexander.deucher@amd.com \
--cc=arnd@arndb.de \
--cc=benjamin.gaignard@st.com \
--cc=chris@chris-wilson.co.uk \
--cc=dan.carpenter@oracle.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=linux-kernel@vger.kernel.org \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mripard@kernel.org \
--cc=sam@ravnborg.org \
--cc=seanpaul@chromium.org \
--cc=tzimmermann@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).