From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_2 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DA021C56202 for ; Thu, 12 Nov 2020 16:16:05 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 674DB22248 for ; Thu, 12 Nov 2020 16:16:05 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="ea8Aqwnh" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 674DB22248 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=bootlin.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-mtd-bounces+linux-mtd=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-ID: Subject:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=Aabf25xwhU0qQ7jUwdkA8m9grGaQzPVdmizDMv19d5E=; b=ea8Aqwnh/yW8TwUnrtiInC32Q uW40uE/EeJ+6wT5VbFq/GQEPS+x4zIlE74CNGFfvuCNujPm+NoY0tgsbYexsmknamFrNxNEaNuphQ qes4QHPsb7Cay8vCw9e7chXKt+OGMsNwLb8b82z6AvSBjD/B2talCuon8WnX4R5CsfyLHgIFZScaW h6pxTYYDnRzD350cLrgWfncvs3kGYRDv8CwuxZq0mFRl6qedYKO889z+X/yF9Z0nsYJI6TXLc7wfb ZU88dqI9hFVSJljZ0tKXdTIDL3jT9aLHvDcUcM4OKEGkiKlYOyZDNqFQ1k8aqNcqmQG1i6sCqX7x1 PRi7nw7ug==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kdFFo-0003OU-SK; Thu, 12 Nov 2020 16:15:20 +0000 Received: from relay12.mail.gandi.net ([217.70.178.232]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kdFFi-0003Nd-6f for linux-mtd@lists.infradead.org; Thu, 12 Nov 2020 16:15:15 +0000 Received: from xps13 (unknown [91.224.148.103]) (Authenticated sender: miquel.raynal@bootlin.com) by relay12.mail.gandi.net (Postfix) with ESMTPSA id 62D4420000B; Thu, 12 Nov 2020 16:15:11 +0000 (UTC) Date: Thu, 12 Nov 2020 17:15:10 +0100 From: Miquel Raynal To: Serge Semin Subject: Re: drivers/mtd/maps/physmap-bt1-rom.c:78:18: sparse: sparse: cast removes address space '__iomem' of expression Message-ID: <20201112171510.0b0b8b80@xps13> In-Reply-To: <20201112161043.brhpuo7rykdip3hs@mobilestation> References: <202011021254.XC70BaQT-lkp@intel.com> <20201110113827.hl5i27cpl6exo3md@mobilestation> <20201110163556.3e3423f6@xps13> <20201111192259.ovdyjcuue7fx2bqa@mobilestation> <20201112092715.7e466405@xps13> <8cdc6166-7183-c8a9-5c27-93a511e6471a@ti.com> <20201112152739.r4673zyeixkcwukx@mobilestation> <20201112164301.60032276@xps13> <20201112161043.brhpuo7rykdip3hs@mobilestation> Organization: Bootlin X-Mailer: Claws Mail 3.17.4 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201112_111514_479813_E508B354 X-CRM114-Status: GOOD ( 29.09 ) X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kbuild-all@lists.01.org, Vignesh Raghavendra , linux-kernel@vger.kernel.org, Serge Semin , linux-mtd@lists.infradead.org, kernel test robot Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: base64 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+linux-mtd=archiver.kernel.org@lists.infradead.org SGkgU2VyZ2UsCgpTZXJnZSBTZW1pbiA8U2VyZ2V5LlNlbWluQGJhaWthbGVsZWN0cm9uaWNzLnJ1 PiB3cm90ZSBvbiBUaHUsIDEyIE5vdgoyMDIwIDE5OjEwOjQzICswMzAwOgoKPiBPbiBUaHUsIE5v diAxMiwgMjAyMCBhdCAwNDo0MzowMVBNICswMTAwLCBNaXF1ZWwgUmF5bmFsIHdyb3RlOgo+ID4g SGkgU2VyZ2UsCj4gPiAKPiA+IFNlcmdlIFNlbWluIDxTZXJnZXkuU2VtaW5AYmFpa2FsZWxlY3Ry b25pY3MucnU+IHdyb3RlIG9uIFRodSwgMTIgTm92Cj4gPiAyMDIwIDE4OjI3OjM5ICswMzAwOgo+ ID4gICAKPiA+ID4gSGVsbG8gVmlnbmVzaAo+ID4gPiAKPiA+ID4gT24gVGh1LCBOb3YgMTIsIDIw MjAgYXQgMDg6MzA6NDJQTSArMDUzMCwgVmlnbmVzaCBSYWdoYXZlbmRyYSB3cm90ZTogIAo+ID4g PiA+IAo+ID4gPiA+IAo+ID4gPiA+IE9uIDExL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CBub3QgdG8gYWRkIHRoaXMga2V5d29yZAppZiB3ZSBkb24ndCBu ZWVkIGl0LgoKVGhhbmtzLApNaXF1w6hsCgpfX19fX19fX19fX19fX19fX19fX19fX19fX19fX19f X19fX19fX19fX19fX19fX19fX19fX18KTGludXggTVREIGRpc2N1c3Npb24gbWFpbGluZyBsaXN0 Cmh0dHA6Ly9saXN0cy5pbmZyYWRlYWQub3JnL21haWxtYW4vbGlzdGluZm8vbGludXgtbXRkLwo= From mboxrd@z Thu Jan 1 00:00:00 1970 Content-Type: multipart/mixed; boundary="===============7286768725991621956==" MIME-Version: 1.0 From: Miquel Raynal To: kbuild-all@lists.01.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 17:15:10 +0100 Message-ID: <20201112171510.0b0b8b80@xps13> In-Reply-To: <20201112161043.brhpuo7rykdip3hs@mobilestation> List-Id: --===============7286768725991621956== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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, 1= 1 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 util= ized > > > > >>>> 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 woul= dn't > > > > >> doing like this: > > > > >> + shift =3D (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 =3D (__force ssize_t)src & 0x3; = > > > = > > > Oh, great! That solution is actually much better than using some > > > currently unexplained sparse peculiarity! I was thinking about applyi= ng > > > 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=C3=A8l --===============7286768725991621956==-- From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_2 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AA127C56202 for ; Thu, 12 Nov 2020 16:15:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5BF3722227 for ; Thu, 12 Nov 2020 16:15:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728932AbgKLQPP convert rfc822-to-8bit (ORCPT ); Thu, 12 Nov 2020 11:15:15 -0500 Received: from relay12.mail.gandi.net ([217.70.178.232]:48911 "EHLO relay12.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728414AbgKLQPP (ORCPT ); Thu, 12 Nov 2020 11:15:15 -0500 Received: from xps13 (unknown [91.224.148.103]) (Authenticated sender: miquel.raynal@bootlin.com) by relay12.mail.gandi.net (Postfix) with ESMTPSA id 62D4420000B; Thu, 12 Nov 2020 16:15:11 +0000 (UTC) Date: Thu, 12 Nov 2020 17:15:10 +0100 From: Miquel Raynal To: Serge Semin Cc: Serge Semin , Vignesh Raghavendra , , , kernel test robot , Subject: Re: drivers/mtd/maps/physmap-bt1-rom.c:78:18: sparse: sparse: cast removes address space '__iomem' of expression Message-ID: <20201112171510.0b0b8b80@xps13> In-Reply-To: <20201112161043.brhpuo7rykdip3hs@mobilestation> References: <202011021254.XC70BaQT-lkp@intel.com> <20201110113827.hl5i27cpl6exo3md@mobilestation> <20201110163556.3e3423f6@xps13> <20201111192259.ovdyjcuue7fx2bqa@mobilestation> <20201112092715.7e466405@xps13> <8cdc6166-7183-c8a9-5c27-93a511e6471a@ti.com> <20201112152739.r4673zyeixkcwukx@mobilestation> <20201112164301.60032276@xps13> <20201112161043.brhpuo7rykdip3hs@mobilestation> Organization: Bootlin X-Mailer: Claws Mail 3.17.4 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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