lkml.org 
[lkml]   [2021]   [Jul]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: drivers/firmware/dmi_scan.c:151:9: sparse: sparse: incorrect type in argument 1 (different address spaces)
On Thu, 29 Jul 2021 16:45:33 +0200, Jean Delvare wrote:
> On Mon, 26 Jul 2021 20:53:42 +0800, Tiezhu Yang wrote:
> > I think the following change can make the above warning silent:
> >
> > diff --git a/drivers/firmware/dmi_scan.c b/drivers/firmware/dmi_scan.c
> > index f191a1f..9e254d9 100644
> > --- a/drivers/firmware/dmi_scan.c
> > +++ b/drivers/firmware/dmi_scan.c
> > @@ -148,7 +148,7 @@ static int __init dmi_walk_early(void
> > (*decode)(const struct dmi_header *,
> >
> > add_device_randomness(buf, dmi_len);
> >
> > - dmi_early_unmap(buf, orig_dmi_len);
> > + dmi_early_unmap((u8 __iomem *)buf, orig_dmi_len);
> > return 0;
> > }
> >
> > If it is OK, I can send a patch later.
>
> Explicit pointer casting is almost always the wrong way to make
> warnings go away. I can't confirm because I'm not able to get sparse to
> work at the moment, but more likely the correct fix would be something
> along the lines of:
>
> --- a/drivers/firmware/dmi_scan.c
> +++ b/drivers/firmware/dmi_scan.c
> @@ -137,7 +137,7 @@ static phys_addr_t dmi_base;
> static int __init dmi_walk_early(void (*decode)(const struct dmi_header *,
> void *))
> {
> - u8 *buf;
> + u8 __iomem *buf;
> u32 orig_dmi_len = dmi_len;
>
> buf = dmi_early_remap(dmi_base, orig_dmi_len);
> @@ -754,7 +754,7 @@ static BIN_ATTR(DMI, S_IRUSR, raw_table_
> static int __init dmi_init(void)
> {
> struct kobject *tables_kobj;
> - u8 *dmi_table;
> + u8 __iomem *dmi_table;
> int ret = -ENOMEM;
>
> if (!dmi_available)
> @@ -1101,7 +1101,7 @@ EXPORT_SYMBOL(dmi_get_bios_year);
> int dmi_walk(void (*decode)(const struct dmi_header *, void *),
> void *private_data)
> {
> - u8 *buf;
> + u8 __iomem *buf;
>
> if (!dmi_available)
> return -ENXIO;
>
> (Note sure why there are only 2 sparse warnings when the same issue is
> present 3 times in the file.)
>

I took a deeper look at the code. There's currently no easy way to fix
these sparse warnings because different architectures have different
prototypes for dmi_early_remap() and dmi_early_unmap(). Some have
__iomem and some do not. So, for the time being, fixing warnings on
some architectures would introduce new warnings on other architectures.

I'd rather leave the code as is until this is sorted out (if it can be).

--
Jean Delvare
SUSE L3 Support

\
 
 \ /
  Last update: 2021-07-30 15:00    [W:0.394 / U:0.088 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site