From: Laurence Rochfort <laurence.rochfort@gmail.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Rob Springer <rspringer@google.com>,
Todd Poynor <toddpoynor@google.com>,
Ben Chan <benchan@chromium.org>,
devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org,
laurence.rochfort@gmail.com
Subject: Re: [PATCH] staging: gasket: Fix sparse "incorrect type in assignment" warnings.
Date: Wed, 10 Oct 2018 15:03:05 +0100 [thread overview]
Message-ID: <20181010140305.GA20899@minipc.home> (raw)
In-Reply-To: <20181009131303.GC25423@kroah.com>
[-- Attachment #1: Type: text/plain, Size: 2602 bytes --]
On Tue, Oct 09, 2018 at 03:13:03PM +0200, Greg Kroah-Hartman wrote:
> On Thu, Oct 04, 2018 at 06:52:25PM +0100, Laurence Rochfort wrote:
> > Silence the below sparse warnings by casting betwen u8 __iomem *, and
> > void *.
> >
> > warning: incorrect type in assignment (different address spaces)
> > expected unsigned char [noderef] [usertype] <asn:2>*virt_base
> > got void *[assigned] mem
> > warning: incorrect type in argument 3 (different address spaces)
> > expected void *cpu_addr
> > got unsigned char [noderef] [usertype] <asn:2>*virt_base
> >
> > Signed-off-by: Laurence Rochfort <laurence.rochfort@gmail.com>
> > ---
> > drivers/staging/gasket/gasket_page_table.c | 10 +++++-----
> > 1 file changed, 5 insertions(+), 5 deletions(-)
> >
> > diff --git a/drivers/staging/gasket/gasket_page_table.c b/drivers/staging/gasket/gasket_page_table.c
> > index d4c5f8a..7f5e5b3 100644
> > --- a/drivers/staging/gasket/gasket_page_table.c
> > +++ b/drivers/staging/gasket/gasket_page_table.c
> > @@ -1278,7 +1278,7 @@ int gasket_alloc_coherent_memory(struct gasket_dev *gasket_dev, u64 size,
> > dma_addr_t *dma_address, u64 index)
> > {
> > dma_addr_t handle;
> > - void *mem;
> > + u8 __iomem *mem;
> > int j;
> > unsigned int num_pages = (size + PAGE_SIZE - 1) / PAGE_SIZE;
> > const struct gasket_driver_desc *driver_desc =
> > @@ -1290,7 +1290,7 @@ int gasket_alloc_coherent_memory(struct gasket_dev *gasket_dev, u64 size,
> > if (num_pages == 0)
> > return -EINVAL;
> >
> > - mem = dma_alloc_coherent(gasket_get_device(gasket_dev),
> > + mem = (u8 __iomem *)dma_alloc_coherent(gasket_get_device(gasket_dev),
> > num_pages * PAGE_SIZE, &handle, 0);
> > if (!mem)
> > goto nomem;
> > @@ -1325,7 +1325,7 @@ int gasket_alloc_coherent_memory(struct gasket_dev *gasket_dev, u64 size,
> > nomem:
> > if (mem) {
> > dma_free_coherent(gasket_get_device(gasket_dev),
> > - num_pages * PAGE_SIZE, mem, handle);
> > + num_pages * PAGE_SIZE, (void __force *)mem, handle);
> > }
> >
> > if (gasket_dev->page_table[index]->coherent_pages) {
> > @@ -1353,7 +1353,7 @@ int gasket_free_coherent_memory(struct gasket_dev *gasket_dev, u64 size,
> > if (gasket_dev->coherent_buffer.length_bytes) {
> > dma_free_coherent(gasket_get_device(gasket_dev),
> > gasket_dev->coherent_buffer.length_bytes,
> > - gasket_dev->coherent_buffer.virt_base,
> > + (void __force *)gasket_dev->coherent_buffer.virt_base,
>
> We should not have to "force" anything here. Something feels wrong in
> the definition of these variable types...
[-- Attachment #2: v2-0001-staging-gasket-Fix-sparse-incorrect-type-in-assig.patch --]
[-- Type: text/plain, Size: 1420 bytes --]
From bde80ff6bdab740d838210aa3e664c8901b2142a Mon Sep 17 00:00:00 2001
From: Laurence Rochfort <laurence.rochfort@gmail.com>
Date: Thu, 4 Oct 2018 18:42:26 +0100
Subject: [PATCH v2] staging: gasket: Fix sparse "incorrect type in assignment"
warnings.
Correct the coherent buffer data type and memory space cookie.
sparse errors were being generated when passing virt_base to
dma_alloc_coherent().
warning: incorrect type in assignment (different address spaces)
expected unsigned char [noderef] [usertype] <asn:2>*virt_base
got void *[assigned] mem
warning: incorrect type in argument 3 (different address spaces)
expected void *cpu_addr
got unsigned char [noderef] [usertype] <asn:2>*virt_base
Signed-off-by: Laurence Rochfort <laurence.rochfort@gmail.com>
---
Changes in v2:
- Correct data type rather than forcing type coersion, as per gkh
drivers/staging/gasket/gasket_core.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/staging/gasket/gasket_core.h b/drivers/staging/gasket/gasket_core.h
index 275fd0b..9d09678 100644
--- a/drivers/staging/gasket/gasket_core.h
+++ b/drivers/staging/gasket/gasket_core.h
@@ -231,7 +231,7 @@ struct gasket_coherent_buffer_desc {
/* Coherent buffer structure. */
struct gasket_coherent_buffer {
/* Virtual base address. */
- u8 __iomem *virt_base;
+ void *virt_base;
/* Physical base address. */
ulong phys_base;
--
2.9.5
next prev parent reply other threads:[~2018-10-10 13:53 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-04 17:52 [PATCH] staging: gasket: Fix sparse "incorrect type in assignment" warnings Laurence Rochfort
2018-10-09 13:13 ` Greg Kroah-Hartman
2018-10-10 14:03 ` Laurence Rochfort [this message]
2018-10-10 14:25 ` Greg Kroah-Hartman
2018-10-10 21:24 ` [PATCH v3] " Laurence Rochfort
2018-10-15 18:42 ` Todd Poynor
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=20181010140305.GA20899@minipc.home \
--to=laurence.rochfort@gmail.com \
--cc=benchan@chromium.org \
--cc=devel@driverdev.osuosl.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rspringer@google.com \
--cc=toddpoynor@google.com \
/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