Re: drivers/mtd/maps/physmap-bt1-rom.c:78:18: sparse: sparse: cast removes address space '__iomem' of expression

2020-11-12 Thread Serge Semin
On Thu, Nov 12, 2020 at 05:15:10PM +0100, Miquel Raynal wrote:
> Hi Serge,
> 
> Serge Semin  wrote on Thu, 12 Nov
> 2020 19:10:43 +0300:
> 
> > On Thu, Nov 12, 2020 at 04:43:01PM +0100, Miquel Raynal wrote:
> > > Hi Serge,
> > > 
> > > Serge Semin  wrote on Thu, 12 Nov
> > > 2020 18:27:39 +0300:
> > >   
> > > > Hello Vignesh
> > > > 
> > > > On Thu, Nov 12, 2020 at 08:30:42PM +0530, Vignesh Raghavendra wrote:  
> > > > > 
> > > > > 
> > > > > On 11/12/20 1:57 PM, Miquel Raynal wrote:
> > > > > > Hi Sergey,
> > > > > > 
> > > > > > Serge Semin  wrote on Wed, 11 Nov
> > > > > > 2020 22:22:59 +0300:
> > > > > > 
> > > > > >> On Tue, Nov 10, 2020 at 04:35:56PM +0100, Miquel Raynal wrote:
> > > > > >>> Hi Serge,
> > > > > >>>
> > > > > >>> Serge Semin  wrote on Tue, 10 
> > > > > >>> Nov
> > > > > >>> 2020 14:38:27 +0300:
> > > > > >>>   
> > > > >  Hello Miquel,
> > > > > 
> > > > >  A situation noted by the warning below won't cause any problem 
> > > > >  because
> > > > >  the casting is done to a non-dereferenced variable. It is 
> > > > >  utilized
> > > > >  as a pointer bias later in that function. Shall we just ignore 
> > > > >  the
> > > > >  warning or still fix it somehow?  
> > > > > >>>   
> > > > > >>
> > > > > >>> Do you think the cast to a !__iomem value is mandatory here?  
> > > > > >>
> > > > > >> It's not mandatory to have the casting with no __iomem, but 
> > > > > >> wouldn't
> > > > > >> doing like this:
> > > > > >> +  shift = (ssize_t __iomem)src & 0x3;
> > > > > >> be looking weird? Really, is there a good way to somehow extract 
> > > > > >> the first
> > > > > >> two bits of a __iomem pointer without getting the sparse warning?  
> > > > > >>   
> > > > > > 
> > > > > > I asked around me, what about trying uintptr_t?
> > > > > > 
> > > > > 
> > > >   
> > > > > One more way is to use __force to tell sparse that this casting is
> > > > > intentional:
> > > > > 
> > > > >shift = (__force ssize_t)src & 0x3;
> > > > 
> > > > Oh, great! That solution is actually much better than using some
> > > > currently unexplained sparse peculiarity! I was thinking about applying
> > > > some other attribute, but __force just didn't come to my mind. Thank
> > > > you very much for the suggestion. I'll post the fix with the solution
> > > > suggested by you.  
> > >   
> > 
> > > Is the ssize_t cast the right one btw? I would definitely prefer an
> > > unsigned type here.  
> > 
> > The reason of me deciding to use the ssize_t type here was to prevent
> > the types casting across the "shift", "chunk" and "len" variables
> > within this method. It seemed a bit better than having a standard type
> > like "unsigned int" here seeing the ssize_t type width won't exceed
> > the long type size anyway. Moreover since the "len" variable has got
> > the ssize_t type and I couldn't change it (the method is the map_info
> > callback), I've decided to stick with what is available and defined
> > "shift" and "chunk" as ssize_t-es. Another callback method
> > bt1_rom_map_read() in his module has been designed in the same way.
> > 
> > Do you think it's better to change it in favor of using a different
> > type like "unsigned int" here anyway?
> 

> I would say yes.
> 
> > If so for unification I'd need to
> > change bt1_rom_map_read() (though the "shift" variable has been
> > defined as "unsigned long" there in the first place because the offs
> > argument has got that type).
> 
> Fine.
> 
> > 
> > What to do with the __force attribute here? It does seem appropriate
> > even if for some mystical reasons we haven't got the sparse warning
> > for the unsigned types.
> 
> Yeah this is strange. I would, however, suggest not to add this keyword
> if we don't need it.

Ok. "unsigned int" it is then.

-Sergey

> 
> Thanks,
> Miquèl


Re: drivers/mtd/maps/physmap-bt1-rom.c:78:18: sparse: sparse: cast removes address space '__iomem' of expression

2020-11-12 Thread Miquel Raynal
Hi Serge,

Serge Semin  wrote on Thu, 12 Nov
2020 19:10:43 +0300:

> On Thu, Nov 12, 2020 at 04:43:01PM +0100, Miquel Raynal wrote:
> > Hi Serge,
> > 
> > Serge Semin  wrote on Thu, 12 Nov
> > 2020 18:27:39 +0300:
> >   
> > > Hello Vignesh
> > > 
> > > On Thu, Nov 12, 2020 at 08:30:42PM +0530, Vignesh Raghavendra wrote:  
> > > > 
> > > > 
> > > > On 11/12/20 1:57 PM, Miquel Raynal wrote:
> > > > > Hi Sergey,
> > > > > 
> > > > > Serge Semin  wrote on Wed, 11 Nov
> > > > > 2020 22:22:59 +0300:
> > > > > 
> > > > >> On Tue, Nov 10, 2020 at 04:35:56PM +0100, Miquel Raynal wrote:
> > > > >>> Hi Serge,
> > > > >>>
> > > > >>> Serge Semin  wrote on Tue, 10 Nov
> > > > >>> 2020 14:38:27 +0300:
> > > > >>>   
> > > >  Hello Miquel,
> > > > 
> > > >  A situation noted by the warning below won't cause any problem 
> > > >  because
> > > >  the casting is done to a non-dereferenced variable. It is utilized
> > > >  as a pointer bias later in that function. Shall we just ignore the
> > > >  warning or still fix it somehow?  
> > > > >>>   
> > > > >>
> > > > >>> Do you think the cast to a !__iomem value is mandatory here?  
> > > > >>
> > > > >> It's not mandatory to have the casting with no __iomem, but wouldn't
> > > > >> doing like this:
> > > > >> +shift = (ssize_t __iomem)src & 0x3;
> > > > >> be looking weird? Really, is there a good way to somehow extract the 
> > > > >> first
> > > > >> two bits of a __iomem pointer without getting the sparse warning?
> > > > > 
> > > > > I asked around me, what about trying uintptr_t?
> > > > > 
> > > > 
> > >   
> > > > One more way is to use __force to tell sparse that this casting is
> > > > intentional:
> > > > 
> > > >shift = (__force ssize_t)src & 0x3;
> > > 
> > > Oh, great! That solution is actually much better than using some
> > > currently unexplained sparse peculiarity! I was thinking about applying
> > > some other attribute, but __force just didn't come to my mind. Thank
> > > you very much for the suggestion. I'll post the fix with the solution
> > > suggested by you.  
> >   
> 
> > Is the ssize_t cast the right one btw? I would definitely prefer an
> > unsigned type here.  
> 
> The reason of me deciding to use the ssize_t type here was to prevent
> the types casting across the "shift", "chunk" and "len" variables
> within this method. It seemed a bit better than having a standard type
> like "unsigned int" here seeing the ssize_t type width won't exceed
> the long type size anyway. Moreover since the "len" variable has got
> the ssize_t type and I couldn't change it (the method is the map_info
> callback), I've decided to stick with what is available and defined
> "shift" and "chunk" as ssize_t-es. Another callback method
> bt1_rom_map_read() in his module has been designed in the same way.
> 
> Do you think it's better to change it in favor of using a different
> type like "unsigned int" here anyway?

I would say yes.

> If so for unification I'd need to
> change bt1_rom_map_read() (though the "shift" variable has been
> defined as "unsigned long" there in the first place because the offs
> argument has got that type).

Fine.

> 
> What to do with the __force attribute here? It does seem appropriate
> even if for some mystical reasons we haven't got the sparse warning
> for the unsigned types.

Yeah this is strange. I would, however, suggest not to add this keyword
if we don't need it.

Thanks,
Miquèl


Re: drivers/mtd/maps/physmap-bt1-rom.c:78:18: sparse: sparse: cast removes address space '__iomem' of expression

2020-11-12 Thread Serge Semin
On Thu, Nov 12, 2020 at 04:43:01PM +0100, Miquel Raynal wrote:
> Hi Serge,
> 
> Serge Semin  wrote on Thu, 12 Nov
> 2020 18:27:39 +0300:
> 
> > Hello Vignesh
> > 
> > On Thu, Nov 12, 2020 at 08:30:42PM +0530, Vignesh Raghavendra wrote:
> > > 
> > > 
> > > On 11/12/20 1:57 PM, Miquel Raynal wrote:  
> > > > Hi Sergey,
> > > > 
> > > > Serge Semin  wrote on Wed, 11 Nov
> > > > 2020 22:22:59 +0300:
> > > >   
> > > >> On Tue, Nov 10, 2020 at 04:35:56PM +0100, Miquel Raynal wrote:  
> > > >>> Hi Serge,
> > > >>>
> > > >>> Serge Semin  wrote on Tue, 10 Nov
> > > >>> 2020 14:38:27 +0300:
> > > >>> 
> > >  Hello Miquel,
> > > 
> > >  A situation noted by the warning below won't cause any problem 
> > >  because
> > >  the casting is done to a non-dereferenced variable. It is utilized
> > >  as a pointer bias later in that function. Shall we just ignore the
> > >  warning or still fix it somehow?
> > > >>> 
> > > >>  
> > > >>> Do you think the cast to a !__iomem value is mandatory here?
> > > >>
> > > >> It's not mandatory to have the casting with no __iomem, but wouldn't
> > > >> doing like this:
> > > >> +  shift = (ssize_t __iomem)src & 0x3;
> > > >> be looking weird? Really, is there a good way to somehow extract the 
> > > >> first
> > > >> two bits of a __iomem pointer without getting the sparse warning?  
> > > > 
> > > > I asked around me, what about trying uintptr_t?
> > > >   
> > >   
> > 
> > > One more way is to use __force to tell sparse that this casting is
> > > intentional:
> > > 
> > >shift = (__force ssize_t)src & 0x3;  
> > 
> > Oh, great! That solution is actually much better than using some
> > currently unexplained sparse peculiarity! I was thinking about applying
> > some other attribute, but __force just didn't come to my mind. Thank
> > you very much for the suggestion. I'll post the fix with the solution
> > suggested by you.
> 

> Is the ssize_t cast the right one btw? I would definitely prefer an
> unsigned type here.

The reason of me deciding to use the ssize_t type here was to prevent
the types casting across the "shift", "chunk" and "len" variables
within this method. It seemed a bit better than having a standard type
like "unsigned int" here seeing the ssize_t type width won't exceed
the long type size anyway. Moreover since the "len" variable has got
the ssize_t type and I couldn't change it (the method is the map_info
callback), I've decided to stick with what is available and defined
"shift" and "chunk" as ssize_t-es. Another callback method
bt1_rom_map_read() in his module has been designed in the same way.

Do you think it's better to change it in favor of using a different
type like "unsigned int" here anyway? If so for unification I'd need to
change bt1_rom_map_read() (though the "shift" variable has been
defined as "unsigned long" there in the first place because the offs
argument has got that type).

What to do with the __force attribute here? It does seem appropriate
even if for some mystical reasons we haven't got the sparse warning
for the unsigned types.

-Sergey

> 
> Thanks,
> Miquèl


Re: drivers/mtd/maps/physmap-bt1-rom.c:78:18: sparse: sparse: cast removes address space '__iomem' of expression

2020-11-12 Thread Miquel Raynal
Hi Serge,

Serge Semin  wrote on Thu, 12 Nov
2020 18:27:39 +0300:

> Hello Vignesh
> 
> On Thu, Nov 12, 2020 at 08:30:42PM +0530, Vignesh Raghavendra wrote:
> > 
> > 
> > On 11/12/20 1:57 PM, Miquel Raynal wrote:  
> > > Hi Sergey,
> > > 
> > > Serge Semin  wrote on Wed, 11 Nov
> > > 2020 22:22:59 +0300:
> > >   
> > >> On Tue, Nov 10, 2020 at 04:35:56PM +0100, Miquel Raynal wrote:  
> > >>> Hi Serge,
> > >>>
> > >>> Serge Semin  wrote on Tue, 10 Nov
> > >>> 2020 14:38:27 +0300:
> > >>> 
> >  Hello Miquel,
> > 
> >  A situation noted by the warning below won't cause any problem because
> >  the casting is done to a non-dereferenced variable. It is utilized
> >  as a pointer bias later in that function. Shall we just ignore the
> >  warning or still fix it somehow?
> > >>> 
> > >>  
> > >>> Do you think the cast to a !__iomem value is mandatory here?
> > >>
> > >> It's not mandatory to have the casting with no __iomem, but wouldn't
> > >> doing like this:
> > >> +shift = (ssize_t __iomem)src & 0x3;
> > >> be looking weird? Really, is there a good way to somehow extract the 
> > >> first
> > >> two bits of a __iomem pointer without getting the sparse warning?  
> > > 
> > > I asked around me, what about trying uintptr_t?
> > >   
> >   
> 
> > One more way is to use __force to tell sparse that this casting is
> > intentional:
> > 
> >shift = (__force ssize_t)src & 0x3;  
> 
> Oh, great! That solution is actually much better than using some
> currently unexplained sparse peculiarity! I was thinking about applying
> some other attribute, but __force just didn't come to my mind. Thank
> you very much for the suggestion. I'll post the fix with the solution
> suggested by you.

Is the ssize_t cast the right one btw? I would definitely prefer an
unsigned type here.

Thanks,
Miquèl


Re: drivers/mtd/maps/physmap-bt1-rom.c:78:18: sparse: sparse: cast removes address space '__iomem' of expression

2020-11-12 Thread Serge Semin
Hello Vignesh

On Thu, Nov 12, 2020 at 08:30:42PM +0530, Vignesh Raghavendra wrote:
> 
> 
> On 11/12/20 1:57 PM, Miquel Raynal wrote:
> > Hi Sergey,
> > 
> > Serge Semin  wrote on Wed, 11 Nov
> > 2020 22:22:59 +0300:
> > 
> >> On Tue, Nov 10, 2020 at 04:35:56PM +0100, Miquel Raynal wrote:
> >>> Hi Serge,
> >>>
> >>> Serge Semin  wrote on Tue, 10 Nov
> >>> 2020 14:38:27 +0300:
> >>>   
>  Hello Miquel,
> 
>  A situation noted by the warning below won't cause any problem because
>  the casting is done to a non-dereferenced variable. It is utilized
>  as a pointer bias later in that function. Shall we just ignore the
>  warning or still fix it somehow?  
> >>>   
> >>
> >>> Do you think the cast to a !__iomem value is mandatory here?  
> >>
> >> It's not mandatory to have the casting with no __iomem, but wouldn't
> >> doing like this:
> >> +  shift = (ssize_t __iomem)src & 0x3;
> >> be looking weird? Really, is there a good way to somehow extract the first
> >> two bits of a __iomem pointer without getting the sparse warning?
> > 
> > I asked around me, what about trying uintptr_t?
> > 
> 

> One more way is to use __force to tell sparse that this casting is
> intentional:
> 
>shift = (__force ssize_t)src & 0x3;

Oh, great! That solution is actually much better than using some
currently unexplained sparse peculiarity! I was thinking about applying
some other attribute, but __force just didn't come to my mind. Thank
you very much for the suggestion. I'll post the fix with the solution
suggested by you.

-Sergey

> 
> 
> > Thanks,
> > Miquèl
> > 
> > __
> > Linux MTD discussion mailing list
> > http://lists.infradead.org/mailman/listinfo/linux-mtd/
> > 


Re: drivers/mtd/maps/physmap-bt1-rom.c:78:18: sparse: sparse: cast removes address space '__iomem' of expression

2020-11-12 Thread Vignesh Raghavendra



On 11/12/20 1:57 PM, Miquel Raynal wrote:
> Hi Sergey,
> 
> Serge Semin  wrote on Wed, 11 Nov
> 2020 22:22:59 +0300:
> 
>> On Tue, Nov 10, 2020 at 04:35:56PM +0100, Miquel Raynal wrote:
>>> Hi Serge,
>>>
>>> Serge Semin  wrote on Tue, 10 Nov
>>> 2020 14:38:27 +0300:
>>>   
 Hello Miquel,

 A situation noted by the warning below won't cause any problem because
 the casting is done to a non-dereferenced variable. It is utilized
 as a pointer bias later in that function. Shall we just ignore the
 warning or still fix it somehow?  
>>>   
>>
>>> Do you think the cast to a !__iomem value is mandatory here?  
>>
>> It's not mandatory to have the casting with no __iomem, but wouldn't
>> doing like this:
>> +shift = (ssize_t __iomem)src & 0x3;
>> be looking weird? Really, is there a good way to somehow extract the first
>> two bits of a __iomem pointer without getting the sparse warning?
> 
> I asked around me, what about trying uintptr_t?
> 

One more way is to use __force to tell sparse that this casting is
intentional:

   shift = (__force ssize_t)src & 0x3;


> Thanks,
> Miquèl
> 
> __
> Linux MTD discussion mailing list
> http://lists.infradead.org/mailman/listinfo/linux-mtd/
> 


Re: drivers/mtd/maps/physmap-bt1-rom.c:78:18: sparse: sparse: cast removes address space '__iomem' of expression

2020-11-12 Thread Serge Semin
On Thu, Nov 12, 2020 at 09:27:15AM +0100, Miquel Raynal wrote:
> Hi Sergey,
> 
> Serge Semin  wrote on Wed, 11 Nov
> 2020 22:22:59 +0300:
> 
> > On Tue, Nov 10, 2020 at 04:35:56PM +0100, Miquel Raynal wrote:
> > > Hi Serge,
> > > 
> > > Serge Semin  wrote on Tue, 10 Nov
> > > 2020 14:38:27 +0300:
> > >   
> > > > Hello Miquel,
> > > > 
> > > > A situation noted by the warning below won't cause any problem because
> > > > the casting is done to a non-dereferenced variable. It is utilized
> > > > as a pointer bias later in that function. Shall we just ignore the
> > > > warning or still fix it somehow?  
> > >   
> > 

> > > Do you think the cast to a !__iomem value is mandatory here?  
> > 
> > It's not mandatory to have the casting with no __iomem, but wouldn't
> > doing like this:
> > +   shift = (ssize_t __iomem)src & 0x3;
> > be looking weird? Really, is there a good way to somehow extract the first
> > two bits of a __iomem pointer without getting the sparse warning?
> 
> I asked around me, what about trying uintptr_t?

Hm, that's weird. sparse gets happy if a casting to an unsigned type
is used here. That's why the similar statement defined in
bt1_rom_map_read() doesn't cause the sparse warning, while the
statement with ssize_t does.

Can people around explain whether that is just an internal sparse
feature or there is a particular reason of having the unsigned types
casting ignored by sparse in this case? I don't really understand why
removing the __iomem attribute with casting to a signed type cause the
warning, while casting to an unsigned type doesn't...

Anyway I'll send a patch with the fix of using the uintptr_t casting
here. Thanks for suggesting the solution.

-Sergey

> 
> Thanks,
> Miquèl


Re: drivers/mtd/maps/physmap-bt1-rom.c:78:18: sparse: sparse: cast removes address space '__iomem' of expression

2020-11-12 Thread Miquel Raynal
Hi Sergey,

Serge Semin  wrote on Wed, 11 Nov
2020 22:22:59 +0300:

> On Tue, Nov 10, 2020 at 04:35:56PM +0100, Miquel Raynal wrote:
> > Hi Serge,
> > 
> > Serge Semin  wrote on Tue, 10 Nov
> > 2020 14:38:27 +0300:
> >   
> > > Hello Miquel,
> > > 
> > > A situation noted by the warning below won't cause any problem because
> > > the casting is done to a non-dereferenced variable. It is utilized
> > > as a pointer bias later in that function. Shall we just ignore the
> > > warning or still fix it somehow?  
> >   
> 
> > Do you think the cast to a !__iomem value is mandatory here?  
> 
> It's not mandatory to have the casting with no __iomem, but wouldn't
> doing like this:
> + shift = (ssize_t __iomem)src & 0x3;
> be looking weird? Really, is there a good way to somehow extract the first
> two bits of a __iomem pointer without getting the sparse warning?

I asked around me, what about trying uintptr_t?

Thanks,
Miquèl


Re: drivers/mtd/maps/physmap-bt1-rom.c:78:18: sparse: sparse: cast removes address space '__iomem' of expression

2020-11-11 Thread Serge Semin
On Tue, Nov 10, 2020 at 04:35:56PM +0100, Miquel Raynal wrote:
> Hi Serge,
> 
> Serge Semin  wrote on Tue, 10 Nov
> 2020 14:38:27 +0300:
> 
> > Hello Miquel,
> > 
> > A situation noted by the warning below won't cause any problem because
> > the casting is done to a non-dereferenced variable. It is utilized
> > as a pointer bias later in that function. Shall we just ignore the
> > warning or still fix it somehow?
> 

> Do you think the cast to a !__iomem value is mandatory here?

It's not mandatory to have the casting with no __iomem, but wouldn't
doing like this:
+   shift = (ssize_t __iomem)src & 0x3;
be looking weird? Really, is there a good way to somehow extract the first
two bits of a __iomem pointer without getting the sparse warning?

-Sergey

> 
> Perhaps if you find an elegant wait to avoid the warning it would be
> nice, otherwise I guess we'll let it aside as a false positive.
> 
> Cheers,
> Miquèl


Re: drivers/mtd/maps/physmap-bt1-rom.c:78:18: sparse: sparse: cast removes address space '__iomem' of expression

2020-11-10 Thread Miquel Raynal
Hi Serge,

Serge Semin  wrote on Tue, 10 Nov
2020 14:38:27 +0300:

> Hello Miquel,
> 
> A situation noted by the warning below won't cause any problem because
> the casting is done to a non-dereferenced variable. It is utilized
> as a pointer bias later in that function. Shall we just ignore the
> warning or still fix it somehow?

Do you think the cast to a !__iomem value is mandatory here?

Perhaps if you find an elegant wait to avoid the warning it would be
nice, otherwise I guess we'll let it aside as a false positive.

Cheers,
Miquèl


Re: drivers/mtd/maps/physmap-bt1-rom.c:78:18: sparse: sparse: cast removes address space '__iomem' of expression

2020-11-10 Thread Serge Semin
Hello Miquel,

A situation noted by the warning below won't cause any problem because
the casting is done to a non-dereferenced variable. It is utilized
as a pointer bias later in that function. Shall we just ignore the
warning or still fix it somehow?

-Sergey

On Mon, Nov 02, 2020 at 12:42:57PM +0800, kernel test robot wrote:
> tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
> master
> head:   3cea11cd5e3b00d91caf0b4730194039b45c5891
> commit: b3e79e7682e075326df8041b826b03453acacd0a mtd: physmap: Add Baikal-T1 
> physically mapped ROM support
> date:   4 weeks ago
> config: sparc64-randconfig-s032-20201031 (attached as .config)
> compiler: sparc64-linux-gcc (GCC) 9.3.0
> reproduce:
> wget 
> https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O 
> ~/bin/make.cross
> chmod +x ~/bin/make.cross
> # apt-get install sparse
> # sparse version: v0.6.3-76-gf680124b-dirty
> # 
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=b3e79e7682e075326df8041b826b03453acacd0a
> git remote add linus 
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
> git fetch --no-tags linus master
> git checkout b3e79e7682e075326df8041b826b03453acacd0a
> # save the attached .config to linux build tree
> COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross C=1 
> CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=sparc64 
> 
> If you fix the issue, kindly add following tag as appropriate
> Reported-by: kernel test robot 
> 
> 
> "sparse warnings: (new ones prefixed by >>)"
> >> drivers/mtd/maps/physmap-bt1-rom.c:78:18: sparse: sparse: cast removes 
> >> address space '__iomem' of expression
> 
> vim +/__iomem +78 drivers/mtd/maps/physmap-bt1-rom.c
> 
> 57
> 58static void __xipram bt1_rom_map_copy_from(struct map_info *map,
> 59   void *to, unsigned 
> long from,
> 60   ssize_t len)
> 61{
> 62void __iomem *src = map->virt + from;
> 63ssize_t shift, chunk;
> 64u32 data;
> 65
> 66if (len <= 0 || from >= map->size)
> 67return;
> 68
> 69/* Make sure we don't go over the map limit. */
> 70len = min_t(ssize_t, map->size - from, len);
> 71
> 72/*
> 73 * Since requested data size can be pretty big we have 
> to implement
> 74 * the copy procedure as optimal as possible. That's 
> why it's split
> 75 * up into the next three stages: unaligned head, 
> aligned body,
> 76 * unaligned tail.
> 77 */
>   > 78shift = (ssize_t)src & 0x3;
> 79if (shift) {
> 80chunk = min_t(ssize_t, 4 - shift, len);
> 81data = readl_relaxed(src - shift);
> 82memcpy(to,  + shift, chunk);
> 83src += chunk;
> 84to += chunk;
> 85len -= chunk;
> 86}
> 87
> 88while (len >= 4) {
> 89data = readl_relaxed(src);
> 90memcpy(to, , 4);
> 91src += 4;
> 92to += 4;
> 93len -= 4;
> 94}
> 95
> 96if (len) {
> 97data = readl_relaxed(src);
> 98memcpy(to, , len);
> 99}
>100}
>101
> 
> ---
> 0-DAY CI Kernel Test Service, Intel Corporation
> https://lists.01.org/hyperkitty/list/kbuild-...@lists.01.org




drivers/mtd/maps/physmap-bt1-rom.c:78:18: sparse: sparse: cast removes address space '__iomem' of expression

2020-11-01 Thread kernel test robot
tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
master
head:   3cea11cd5e3b00d91caf0b4730194039b45c5891
commit: b3e79e7682e075326df8041b826b03453acacd0a mtd: physmap: Add Baikal-T1 
physically mapped ROM support
date:   4 weeks ago
config: sparc64-randconfig-s032-20201031 (attached as .config)
compiler: sparc64-linux-gcc (GCC) 9.3.0
reproduce:
wget 
https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O 
~/bin/make.cross
chmod +x ~/bin/make.cross
# apt-get install sparse
# sparse version: v0.6.3-76-gf680124b-dirty
# 
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=b3e79e7682e075326df8041b826b03453acacd0a
git remote add linus 
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
git fetch --no-tags linus master
git checkout b3e79e7682e075326df8041b826b03453acacd0a
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross C=1 
CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=sparc64 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot 


"sparse warnings: (new ones prefixed by >>)"
>> drivers/mtd/maps/physmap-bt1-rom.c:78:18: sparse: sparse: cast removes 
>> address space '__iomem' of expression

vim +/__iomem +78 drivers/mtd/maps/physmap-bt1-rom.c

57  
58  static void __xipram bt1_rom_map_copy_from(struct map_info *map,
59 void *to, unsigned long from,
60 ssize_t len)
61  {
62  void __iomem *src = map->virt + from;
63  ssize_t shift, chunk;
64  u32 data;
65  
66  if (len <= 0 || from >= map->size)
67  return;
68  
69  /* Make sure we don't go over the map limit. */
70  len = min_t(ssize_t, map->size - from, len);
71  
72  /*
73   * Since requested data size can be pretty big we have to 
implement
74   * the copy procedure as optimal as possible. That's why it's 
split
75   * up into the next three stages: unaligned head, aligned body,
76   * unaligned tail.
77   */
  > 78  shift = (ssize_t)src & 0x3;
79  if (shift) {
80  chunk = min_t(ssize_t, 4 - shift, len);
81  data = readl_relaxed(src - shift);
82  memcpy(to,  + shift, chunk);
83  src += chunk;
84  to += chunk;
85  len -= chunk;
86  }
87  
88  while (len >= 4) {
89  data = readl_relaxed(src);
90  memcpy(to, , 4);
91  src += 4;
92  to += 4;
93  len -= 4;
94  }
95  
96  if (len) {
97  data = readl_relaxed(src);
98  memcpy(to, , len);
99  }
   100  }
   101  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-...@lists.01.org


.config.gz
Description: application/gzip