From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752591AbcGaXp7 (ORCPT ); Sun, 31 Jul 2016 19:45:59 -0400 Received: from exvmail.hynix.com ([166.125.252.79]:47535 "EHLO invmail.skhynix.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751199AbcGaXpu (ORCPT ); Sun, 31 Jul 2016 19:45:50 -0400 X-AuditID: a67dfc4e-f797e6d000000a40-f4-579e8dab9edf From: "kwangwoo.lee@sk.com" To: Robin Murphy , Russell King - ARM Linux , Catalin Marinas , "Will Deacon" , Mark Rutland , "linux-arm-kernel@lists.infradead.org" CC: "hyunchul3.kim@sk.com" , "linux-kernel@vger.kernel.org" , "woosuk.chung@sk.com" Subject: RE: [PATCH v2] arm64: mm: convert __dma_* routines to use start, size Thread-Topic: [PATCH v2] arm64: mm: convert __dma_* routines to use start, size Thread-Index: AQHR5xBcaKHsJZrE6EmNL7MPsHijzaAp7/iAgAFuegCAABbLAIABfUjAgAIfcACABCpKgA== Date: Sun, 31 Jul 2016 23:45:46 +0000 Message-ID: <1c4ec01bd3594485b6a4b386994dc6ca@nmail01.hynixad.com> References: <1469518496-8177-1-git-send-email-kwangwoo.lee@sk.com> <15c12f9900fd4b31a875250c478023c6@nmail01.hynixad.com> In-Reply-To: Accept-Language: ko-KR, en-US Content-Language: ko-KR X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.92.132.196] Content-Type: text/plain; charset="ks_c_5601-1987" MIME-Version: 1.0 X-CFilter-Loop: Reflected X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrKIsWRmVeSWpSXmKPExsXCNUdUSXd177xwg19Nxhbvl/UwWmx6fI3V 4vKuOWwWh6buZbRYev0ik8XBD09YLV5+PMHiwO6xZt4aRo/L1y4ye2xeUu/xeZNcAEsUl01K ak5mWWqRvl0CV8bX1ZvZC84ZV/yb38zSwLjEqIuRk0NCwETiyJVuJghbTOLCvfVsXYxcHEIC qxklnj/oYoJwFjFK3L1xFqyKTcBQYu+tfawgtojAYiaJ/ctkQIqYBRYySmxt+wiWEBYIkPi7 YTEbRFGgxLXTd1kg7DCJuedXMoLYLAKqEiePnAGr5xVwkvh5fyHUtuNMEtfvvAVLcApYS1yc uQxoEAcHo4CsxNVrMiBhZgFxicVfrzFDnC0gsWTPeShbVOLl43+sELaixLfX39kh6o0klqye zwRhK0pM6X7IDrFXUOLkzCcsEPWSEgdX3GCZwCg+C8mKWUjaZyFpn4WkfQEjyypG4cy8stzE zBy94uyMyrzMCr3k/NxNjMDIXFb7x28H44tfWocYBTgYlXh4E1jmhQuxJpYVV+YeYpTgYFYS 4TUCxrUQb0piZVVqUX58UWlOavEhRmkOFiVx3m//+8KFBNITS1KzU1MLUotgskwcnFINjHPW Ta25zW+1biWLk/iUnKSGo27PHt+Y2ZsyNbtZU+vECvVls/SkFOz7faw8eA7eu+D8uah1gvlu PpuU1ZUHO981zetl72VdnTPt51R1ns/i0lOjui4aF3Vc2/1lZt6Uqf5LDHmWGS56fvanS+zk p356zdUOf3bP+3V17bnnTxYzWf6pSt3rfV+JpTgj0VCLuag4EQAHVv7ryAIAAA== Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from base64 to 8bit by mail.home.local id u6VNk7r7011462 Hi Robin, > -----Original Message----- > From: Robin Murphy [mailto:robin.murphy@arm.com] > Sent: Saturday, July 30, 2016 2:06 AM > To: À̱¤¿ì(LEE KWANGWOO) MS SW; Russell King - ARM Linux; Catalin Marinas; Will Deacon; Mark Rutland; > linux-arm-kernel@lists.infradead.org > Cc: ±èÇöö(KIM HYUNCHUL) MS SW; linux-kernel@vger.kernel.org; Á¤¿ì¼®(CHUNG WOO SUK) MS SW > Subject: Re: [PATCH v2] arm64: mm: convert __dma_* routines to use start, size > > On 28/07/16 01:08, kwangwoo.lee@sk.com wrote: > >> -----Original Message----- > >> From: Robin Murphy [mailto:robin.murphy@arm.com] > >> Sent: Wednesday, July 27, 2016 6:56 PM > >> To: À̱¤¿ì(LEE KWANGWOO) MS SW; Russell King - ARM Linux; Catalin Marinas; Will Deacon; Mark Rutland; > >> linux-arm-kernel@lists.infradead.org > >> Cc: ±èÇöö(KIM HYUNCHUL) MS SW; linux-kernel@vger.kernel.org; Á¤¿ì¼®(CHUNG WOO SUK) MS SW > >> Subject: Re: [PATCH v2] arm64: mm: convert __dma_* routines to use start, size > >> > >> On 27/07/16 02:55, kwangwoo.lee@sk.com wrote: > >> [...] > >>>>> /* > >>>>> - * __dma_clean_range(start, end) > >>>>> + * __dma_clean_area(start, size) > >>>>> * - start - virtual start address of region > >>>>> - * - end - virtual end address of region > >>>>> + * - size - size in question > >>>>> */ > >>>>> -__dma_clean_range: > >>>>> - dcache_line_size x2, x3 > >>>>> - sub x3, x2, #1 > >>>>> - bic x0, x0, x3 > >>>>> -1: > >>>>> +__dma_clean_area: > >>>>> alternative_if_not ARM64_WORKAROUND_CLEAN_CACHE > >>>>> - dc cvac, x0 > >>>>> + dcache_by_line_op cvac, sy, x0, x1, x2, x3 > >>>>> alternative_else > >>>>> - dc civac, x0 > >>>>> + dcache_by_line_op civac, sy, x0, x1, x2, x3 > >>>> > >>>> dcache_by_line_op is a relatively large macro - is there any way we can > >>>> still apply the alternative to just the one instruction which needs it, > >>>> as opposed to having to patch the entire mostly-identical routine? > >>> > >>> I agree with your opinion. Then, how do you think about using CONFIG_* options > >>> like below? I think that alternative_* macros seems to keep the space for > >>> unused instruction. Is it necessary? Please, share your thought about the > >>> space. Thanks! > >>> > >>> +__dma_clean_area: > >>> +#if defined(CONFIG_ARM64_ERRATUM_826319) || \ > >>> + defined(CONFIG_ARM64_ERRATUM_827319) || \ > >>> + defined(CONFIG_ARM64_ERRATUM_824069) || \ > >>> + defined(CONFIG_ARM64_ERRATUM_819472) > >>> + dcache_by_line_op civac, sy, x0, x1, x2, x3 > >>> +#else > >>> + dcache_by_line_op cvac, sy, x0, x1, x2, x3 > >>> +#endif > >> > >> That's not ideal, because we still only really want to use the > >> workaround if we detect a CPU which needs it, rather than baking it in > >> at compile time. I was thinking more along the lines of pushing the > >> alternative down into dcache_by_line_op, something like the idea below > >> (compile-tested only, may not actually be viable). > > > > OK. Using the capability of CPU features seems to be preferred. > > > >> Robin. > >> > >> -----8<----- > >> diff --git a/arch/arm64/include/asm/assembler.h > >> b/arch/arm64/include/asm/assembler.h > >> index 10b017c4bdd8..1c005c90387e 100644 > >> --- a/arch/arm64/include/asm/assembler.h > >> +++ b/arch/arm64/include/asm/assembler.h > >> @@ -261,7 +261,16 @@ lr .req x30 // link register > >> add \size, \kaddr, \size > >> sub \tmp2, \tmp1, #1 > >> bic \kaddr, \kaddr, \tmp2 > >> -9998: dc \op, \kaddr > >> +9998: > >> + .ifeqs "\op", "cvac" > >> +alternative_if_not ARM64_WORKAROUND_CLEAN_CACHE > >> + dc cvac, \kaddr > >> +alternative_else > >> + dc civac, \kaddr > >> +alternative_endif > >> + .else > >> + dc \op, \kaddr > >> + .endif > >> add \kaddr, \kaddr, \tmp1 > >> cmp \kaddr, \size > >> b.lo 9998b > > > > I agree that it looks not viable because it makes the macro bigger and > > conditional specifically with CVAC op. > > Actually, having had a poke around in the resulting disassembly, it > looks like this does work correctly. I can't think of a viable reason > for the whole dcache_by_line_op to ever be wrapped in yet another > alternative (which almost certainly would go horribly wrong), and it > would mean that any other future users are automatically covered for > free. It's just horrible to look at at the source level. Then, Are you going to send a patch for this? Or should I include this change? > Robin. > > > > > Then.. if the number of the usage of alternative_* macros for erratum is > > few (just one in this case for cache clean), I think only small change like > > below seems to be optimal and there is no need to create a variant macro of > > dcache_cache_by_line_op. How do you think about it? [...] Regards, Kwangwoo From mboxrd@z Thu Jan 1 00:00:00 1970 From: kwangwoo.lee@sk.com (kwangwoo.lee at sk.com) Date: Sun, 31 Jul 2016 23:45:46 +0000 Subject: [PATCH v2] arm64: mm: convert __dma_* routines to use start, size In-Reply-To: References: <1469518496-8177-1-git-send-email-kwangwoo.lee@sk.com> <15c12f9900fd4b31a875250c478023c6@nmail01.hynixad.com> Message-ID: <1c4ec01bd3594485b6a4b386994dc6ca@nmail01.hynixad.com> To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.org Hi Robin, > -----Original Message----- > From: Robin Murphy [mailto:robin.murphy at arm.com] > Sent: Saturday, July 30, 2016 2:06 AM > To: ???(LEE KWANGWOO) MS SW; Russell King - ARM Linux; Catalin Marinas; Will Deacon; Mark Rutland; > linux-arm-kernel at lists.infradead.org > Cc: ???(KIM HYUNCHUL) MS SW; linux-kernel at vger.kernel.org; ???(CHUNG WOO SUK) MS SW > Subject: Re: [PATCH v2] arm64: mm: convert __dma_* routines to use start, size > > On 28/07/16 01:08, kwangwoo.lee at sk.com wrote: > >> -----Original Message----- > >> From: Robin Murphy [mailto:robin.murphy at arm.com] > >> Sent: Wednesday, July 27, 2016 6:56 PM > >> To: ???(LEE KWANGWOO) MS SW; Russell King - ARM Linux; Catalin Marinas; Will Deacon; Mark Rutland; > >> linux-arm-kernel at lists.infradead.org > >> Cc: ???(KIM HYUNCHUL) MS SW; linux-kernel at vger.kernel.org; ???(CHUNG WOO SUK) MS SW > >> Subject: Re: [PATCH v2] arm64: mm: convert __dma_* routines to use start, size > >> > >> On 27/07/16 02:55, kwangwoo.lee at sk.com wrote: > >> [...] > >>>>> /* > >>>>> - * __dma_clean_range(start, end) > >>>>> + * __dma_clean_area(start, size) > >>>>> * - start - virtual start address of region > >>>>> - * - end - virtual end address of region > >>>>> + * - size - size in question > >>>>> */ > >>>>> -__dma_clean_range: > >>>>> - dcache_line_size x2, x3 > >>>>> - sub x3, x2, #1 > >>>>> - bic x0, x0, x3 > >>>>> -1: > >>>>> +__dma_clean_area: > >>>>> alternative_if_not ARM64_WORKAROUND_CLEAN_CACHE > >>>>> - dc cvac, x0 > >>>>> + dcache_by_line_op cvac, sy, x0, x1, x2, x3 > >>>>> alternative_else > >>>>> - dc civac, x0 > >>>>> + dcache_by_line_op civac, sy, x0, x1, x2, x3 > >>>> > >>>> dcache_by_line_op is a relatively large macro - is there any way we can > >>>> still apply the alternative to just the one instruction which needs it, > >>>> as opposed to having to patch the entire mostly-identical routine? > >>> > >>> I agree with your opinion. Then, how do you think about using CONFIG_* options > >>> like below? I think that alternative_* macros seems to keep the space for > >>> unused instruction. Is it necessary? Please, share your thought about the > >>> space. Thanks! > >>> > >>> +__dma_clean_area: > >>> +#if defined(CONFIG_ARM64_ERRATUM_826319) || \ > >>> + defined(CONFIG_ARM64_ERRATUM_827319) || \ > >>> + defined(CONFIG_ARM64_ERRATUM_824069) || \ > >>> + defined(CONFIG_ARM64_ERRATUM_819472) > >>> + dcache_by_line_op civac, sy, x0, x1, x2, x3 > >>> +#else > >>> + dcache_by_line_op cvac, sy, x0, x1, x2, x3 > >>> +#endif > >> > >> That's not ideal, because we still only really want to use the > >> workaround if we detect a CPU which needs it, rather than baking it in > >> at compile time. I was thinking more along the lines of pushing the > >> alternative down into dcache_by_line_op, something like the idea below > >> (compile-tested only, may not actually be viable). > > > > OK. Using the capability of CPU features seems to be preferred. > > > >> Robin. > >> > >> -----8<----- > >> diff --git a/arch/arm64/include/asm/assembler.h > >> b/arch/arm64/include/asm/assembler.h > >> index 10b017c4bdd8..1c005c90387e 100644 > >> --- a/arch/arm64/include/asm/assembler.h > >> +++ b/arch/arm64/include/asm/assembler.h > >> @@ -261,7 +261,16 @@ lr .req x30 // link register > >> add \size, \kaddr, \size > >> sub \tmp2, \tmp1, #1 > >> bic \kaddr, \kaddr, \tmp2 > >> -9998: dc \op, \kaddr > >> +9998: > >> + .ifeqs "\op", "cvac" > >> +alternative_if_not ARM64_WORKAROUND_CLEAN_CACHE > >> + dc cvac, \kaddr > >> +alternative_else > >> + dc civac, \kaddr > >> +alternative_endif > >> + .else > >> + dc \op, \kaddr > >> + .endif > >> add \kaddr, \kaddr, \tmp1 > >> cmp \kaddr, \size > >> b.lo 9998b > > > > I agree that it looks not viable because it makes the macro bigger and > > conditional specifically with CVAC op. > > Actually, having had a poke around in the resulting disassembly, it > looks like this does work correctly. I can't think of a viable reason > for the whole dcache_by_line_op to ever be wrapped in yet another > alternative (which almost certainly would go horribly wrong), and it > would mean that any other future users are automatically covered for > free. It's just horrible to look at at the source level. Then, Are you going to send a patch for this? Or should I include this change? > Robin. > > > > > Then.. if the number of the usage of alternative_* macros for erratum is > > few (just one in this case for cache clean), I think only small change like > > below seems to be optimal and there is no need to create a variant macro of > > dcache_cache_by_line_op. How do you think about it? [...] Regards, Kwangwoo