linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Serge Semin <Sergey.Semin@baikalelectronics.ru>
To: Miquel Raynal <miquel.raynal@bootlin.com>
Cc: Vignesh Raghavendra <vigneshr@ti.com>,
	<linux-mtd@lists.infradead.org>, <kbuild-all@lists.01.org>,
	kernel test robot <lkp@intel.com>, <linux-kernel@vger.kernel.org>
Subject: Re: drivers/mtd/maps/physmap-bt1-rom.c:78:18: sparse: sparse: cast removes address space '__iomem' of expression
Date: Thu, 12 Nov 2020 19:21:54 +0300	[thread overview]
Message-ID: <20201112162154.h66dtak7e7bcblnq@mobilestation> (raw)
In-Reply-To: <20201112171510.0b0b8b80@xps13>

On Thu, Nov 12, 2020 at 05:15:10PM +0100, Miquel Raynal wrote:
> Hi Serge,
> 
> Serge Semin <Sergey.Semin@baikalelectronics.ru> 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 <Sergey.Semin@baikalelectronics.ru> 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 <Sergey.Semin@baikalelectronics.ru> 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 <Sergey.Semin@baikalelectronics.ru> 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

      reply	other threads:[~2020-11-12 16:22 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-02  4:42 drivers/mtd/maps/physmap-bt1-rom.c:78:18: sparse: sparse: cast removes address space '__iomem' of expression kernel test robot
2020-11-10 11:38 ` Serge Semin
2020-11-10 15:35   ` Miquel Raynal
2020-11-11 19:22     ` Serge Semin
2020-11-12  8:27       ` Miquel Raynal
2020-11-12 11:20         ` Serge Semin
2020-11-12 15:00         ` Vignesh Raghavendra
2020-11-12 15:27           ` Serge Semin
2020-11-12 15:43             ` Miquel Raynal
2020-11-12 16:10               ` Serge Semin
2020-11-12 16:15                 ` Miquel Raynal
2020-11-12 16:21                   ` Serge Semin [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=20201112162154.h66dtak7e7bcblnq@mobilestation \
    --to=sergey.semin@baikalelectronics.ru \
    --cc=kbuild-all@lists.01.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=lkp@intel.com \
    --cc=miquel.raynal@bootlin.com \
    --cc=vigneshr@ti.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;
as well as URLs for NNTP newsgroup(s).