From mboxrd@z Thu Jan 1 00:00:00 1970 From: Christophe Leroy Subject: Re: [RFT 00/13] iomap: Constify ioreadX() iomem argument Date: Wed, 8 Jan 2020 09:48:46 +0100 Message-ID: <00a43e5c-0708-d49a-9cc4-eb2ce8b4cf99@c-s.fr> References: <1578415992-24054-1-git-send-email-krzk@kernel.org> <2355489c-a207-1927-54cf-85c04b62f18f@c-s.fr> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Return-path: In-Reply-To: Content-Language: fr Sender: netdev-owner@vger.kernel.org To: Geert Uytterhoeven Cc: Krzysztof Kozlowski , Rich Felker , Jiri Slaby , "Michael S. Tsirkin" , David Airlie , Jason Wang , DRI Development , virtualization@lists.linux-foundation.org, "James E.J. Bottomley" , netdev , Paul Mackerras , Linux-Arch , Dave Jiang , Yoshinori Sato , Helge Deller , Linux-sh list , Alexey Brodkin , Ben Skeggs , nouveau@lists.freedesktop.orgDave Airlie List-Id: linux-arch.vger.kernel.org Hi Geert, Le 08/01/2020 à 09:43, Geert Uytterhoeven a écrit : > Hi Christophe, > > On Wed, Jan 8, 2020 at 9:35 AM Christophe Leroy wrote: >> Le 08/01/2020 à 09:18, Krzysztof Kozlowski a écrit : >>> On Wed, 8 Jan 2020 at 09:13, Geert Uytterhoeven wrote: >>>> On Wed, Jan 8, 2020 at 9:07 AM Geert Uytterhoeven wrote: >>>>> On Tue, Jan 7, 2020 at 5:53 PM Krzysztof Kozlowski wrote: >>>>>> The ioread8/16/32() and others have inconsistent interface among the >>>>>> architectures: some taking address as const, some not. >>>>>> >>>>>> It seems there is nothing really stopping all of them to take >>>>>> pointer to const. >>>>> >>>>> Shouldn't all of them take const volatile __iomem pointers? >>>>> It seems the "volatile" is missing from all but the implementations in >>>>> include/asm-generic/io.h. >>>> >>>> As my "volatile" comment applies to iowrite*(), too, probably that should be >>>> done in a separate patch. >>>> >>>> Hence with patches 1-5 squashed, and for patches 11-13: >>>> Reviewed-by: Geert Uytterhoeven >>> >>> I'll add to this one also changes to ioreadX_rep() and add another >>> patch for volatile for reads and writes. I guess your review will be >>> appreciated once more because of ioreadX_rep() >> >> volatile should really only be used where deemed necessary: >> >> https://www.kernel.org/doc/html/latest/process/volatile-considered-harmful.html >> >> It is said: " ... accessor functions might use volatile on >> architectures where direct I/O memory access does work. Essentially, >> each accessor call becomes a little critical section on its own and >> ensures that the access happens as expected by the programmer." > > That is exactly the use case here: all above are accessor functions. > > Why would ioreadX() not need volatile, while readY() does? > My point was: it might be necessary for some arches and not for others. And as pointed by Arnd, the volatile is really only necessary for the dereference itself, should the arch use dereferencing. So I guess the best would be to go in the other direction: remove volatile keyword wherever possible instead of adding it where it is not needed. Christophe From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from pegase1.c-s.fr ([93.17.236.30]:9734 "EHLO pegase1.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727313AbgAHIsu (ORCPT ); Wed, 8 Jan 2020 03:48:50 -0500 Subject: Re: [RFT 00/13] iomap: Constify ioreadX() iomem argument References: <1578415992-24054-1-git-send-email-krzk@kernel.org> <2355489c-a207-1927-54cf-85c04b62f18f@c-s.fr> From: Christophe Leroy Message-ID: <00a43e5c-0708-d49a-9cc4-eb2ce8b4cf99@c-s.fr> Date: Wed, 8 Jan 2020 09:48:46 +0100 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: fr Content-Transfer-Encoding: 8bit Sender: linux-arch-owner@vger.kernel.org List-ID: To: Geert Uytterhoeven Cc: Krzysztof Kozlowski , Rich Felker , Jiri Slaby , "Michael S. Tsirkin" , David Airlie , Jason Wang , DRI Development , virtualization@lists.linux-foundation.org, "James E.J. Bottomley" , netdev , Paul Mackerras , Linux-Arch , Dave Jiang , Yoshinori Sato , Helge Deller , Linux-sh list , Alexey Brodkin , Ben Skeggs , nouveau@lists.freedesktop.org, Dave Airlie , Matt Turner , arcml , Nick Kossifidis , Allen Hubbe , Arnd Bergmann , alpha , Ivan Kokshaysky , Thomas Gleixner , Mauro Carvalho Chehab , Kalle Valo , Richard Henderson , Parisc List , Vineet Gupta , linux-wireless , Linux Kernel Mailing List , Luis Chamberlain , Daniel Vetter , Jon Mason , linux-ntb@googlegroups.com, Andrew Morton , Linux Media Mailing List , linuxppc-dev , "David S. Miller" Message-ID: <20200108084846.3Ms2e3cPfQBmCFpVc0jcN-65xBG_U3UnQiLzlj-XngM@z> Hi Geert, Le 08/01/2020 à 09:43, Geert Uytterhoeven a écrit : > Hi Christophe, > > On Wed, Jan 8, 2020 at 9:35 AM Christophe Leroy wrote: >> Le 08/01/2020 à 09:18, Krzysztof Kozlowski a écrit : >>> On Wed, 8 Jan 2020 at 09:13, Geert Uytterhoeven wrote: >>>> On Wed, Jan 8, 2020 at 9:07 AM Geert Uytterhoeven wrote: >>>>> On Tue, Jan 7, 2020 at 5:53 PM Krzysztof Kozlowski wrote: >>>>>> The ioread8/16/32() and others have inconsistent interface among the >>>>>> architectures: some taking address as const, some not. >>>>>> >>>>>> It seems there is nothing really stopping all of them to take >>>>>> pointer to const. >>>>> >>>>> Shouldn't all of them take const volatile __iomem pointers? >>>>> It seems the "volatile" is missing from all but the implementations in >>>>> include/asm-generic/io.h. >>>> >>>> As my "volatile" comment applies to iowrite*(), too, probably that should be >>>> done in a separate patch. >>>> >>>> Hence with patches 1-5 squashed, and for patches 11-13: >>>> Reviewed-by: Geert Uytterhoeven >>> >>> I'll add to this one also changes to ioreadX_rep() and add another >>> patch for volatile for reads and writes. I guess your review will be >>> appreciated once more because of ioreadX_rep() >> >> volatile should really only be used where deemed necessary: >> >> https://www.kernel.org/doc/html/latest/process/volatile-considered-harmful.html >> >> It is said: " ... accessor functions might use volatile on >> architectures where direct I/O memory access does work. Essentially, >> each accessor call becomes a little critical section on its own and >> ensures that the access happens as expected by the programmer." > > That is exactly the use case here: all above are accessor functions. > > Why would ioreadX() not need volatile, while readY() does? > My point was: it might be necessary for some arches and not for others. And as pointed by Arnd, the volatile is really only necessary for the dereference itself, should the arch use dereferencing. So I guess the best would be to go in the other direction: remove volatile keyword wherever possible instead of adding it where it is not needed. Christophe