RE: [PATCH v12 4/6] QE/CPM: move muram management functions to qe_common
On Tue, Oct 27, 2015 at 2:50 PM, Wood Scott-B07421 wrote: > -Original Message- > From: Wood Scott-B07421 > Sent: Tuesday, October 27, 2015 2:50 PM > To: Zhao Qiang-B45475 > Cc: linux-ker...@vger.kernel.org; linuxppc-dev@lists.ozlabs.org; > lau...@codeaurora.org; Xie Xiaobo-R63061 ; > b...@kernel.crashing.org; Li Yang-Leo-R58472 ; > pau...@samba.org > Subject: Re: [PATCH v12 4/6] QE/CPM: move muram management functions to > qe_common > > On Tue, 2015-10-27 at 01:24 -0500, Zhao Qiang-B45475 wrote: > > On Tue, Oct 27, 2015 at 12:48 PM, Wood Scott-B07421 wrote: > > > -Original Message- > > > From: Wood Scott-B07421 > > > Sent: Tuesday, October 27, 2015 12:48 PM > > > To: Zhao Qiang-B45475 > > > Cc: linux-ker...@vger.kernel.org; linuxppc-dev@lists.ozlabs.org; > > > lau...@codeaurora.org; Xie Xiaobo-R63061 ; > > > b...@kernel.crashing.org; Li Yang-Leo-R58472 ; > > > pau...@samba.org > > > Subject: Re: [PATCH v12 4/6] QE/CPM: move muram management > functions > > > to qe_common > > > > > > On Sun, 2015-10-25 at 21:42 -0500, Zhao Qiang-B45475 wrote: > > > > On Sat, Oct 24, 2015 at 04:56 AM, Wood Scott-B07421 wrote: > > > > > -Original Message- > > > > > From: Wood Scott-B07421 > > > > > Sent: Saturday, October 24, 2015 4:56 AM > > > > > To: Zhao Qiang-B45475 > > > > > Cc: linux-ker...@vger.kernel.org; linuxppc-dev@lists.ozlabs.org; > > > > > lau...@codeaurora.org; Xie Xiaobo-R63061 ; > > > > > b...@kernel.crashing.org; Li Yang-Leo-R58472 > > > > > ; pau...@samba.org > > > > > Subject: Re: [PATCH v12 4/6] QE/CPM: move muram management > > > functions > > > > > to qe_common > > > > > > > > > > On Fri, 2015-10-23 at 02:45 -0500, Zhao Qiang-B45475 wrote: > > > > > > On Fri, 2015-10-23 at 11:10 AM, Wood Scott-B07421 > > > > > > > > > > > > wrote: > > > > > > > -Original Message- > > > > > > > From: Wood Scott-B07421 > > > > > > > Sent: Friday, October 23, 2015 11:10 AM > > > > > > > To: Zhao Qiang-B45475 > > > > > > > Cc: linux-ker...@vger.kernel.org; > > > > > > > linuxppc-dev@lists.ozlabs.org; lau...@codeaurora.org; Xie > > > > > > > Xiaobo-R63061 ; > > > > > > > b...@kernel.crashing.org; Li Yang-Leo-R58472 > > > > > > > ; pau...@samba.org > > > > > > > Subject: Re: [PATCH v12 4/6] QE/CPM: move muram management > > > > > functions > > > > > > > to qe_common > > > > > > > > > > > > So then why are you selecting QUICC_ENGINE? And again, what > > > > > does it have to do with this patch? > > > > > > > > Cpm-spi is dependent on qe_muram, if not select it, Cpm-spi will > > > > failed to build. > > > > > > Why QUICC_ENGINE and not CPM? > > > > QE and CPM use the same muram, and it has been moved to qe_muram > from > > cpm_muram. > > Fix the makefiles so that the muram code continues to be built for both > QUICC_ENGINE and CPM. It's not acceptable to have to bring in the entire QE > code just for the muram. > How about to define and CONFIG_QE_MURAM in Kconfig for muram? -Zhao ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH v12 4/6] QE/CPM: move muram management functions to qe_common
On Tue, 2015-10-27 at 02:34 -0500, Zhao Qiang-B45475 wrote: > On Tue, Oct 27, 2015 at 2:50 PM, Wood Scott-B07421 wrote: > > -Original Message- > > From: Wood Scott-B07421 > > Sent: Tuesday, October 27, 2015 2:50 PM > > To: Zhao Qiang-B45475 > > Cc: linux-ker...@vger.kernel.org; linuxppc-dev@lists.ozlabs.org; > > lau...@codeaurora.org; Xie Xiaobo-R63061 ; > > b...@kernel.crashing.org; Li Yang-Leo-R58472 ; > > pau...@samba.org > > Subject: Re: [PATCH v12 4/6] QE/CPM: move muram management functions to > > qe_common > > > > On Tue, 2015-10-27 at 01:24 -0500, Zhao Qiang-B45475 wrote: > > > On Tue, Oct 27, 2015 at 12:48 PM, Wood Scott-B07421 wrote: > > > > -Original Message- > > > > From: Wood Scott-B07421 > > > > Sent: Tuesday, October 27, 2015 12:48 PM > > > > To: Zhao Qiang-B45475 > > > > Cc: linux-ker...@vger.kernel.org; linuxppc-dev@lists.ozlabs.org; > > > > lau...@codeaurora.org; Xie Xiaobo-R63061 ; > > > > b...@kernel.crashing.org; Li Yang-Leo-R58472 ; > > > > pau...@samba.org > > > > Subject: Re: [PATCH v12 4/6] QE/CPM: move muram management > > functions > > > > to qe_common > > > > > > > > On Sun, 2015-10-25 at 21:42 -0500, Zhao Qiang-B45475 wrote: > > > > > On Sat, Oct 24, 2015 at 04:56 AM, Wood Scott-B07421 wrote: > > > > > > -Original Message- > > > > > > From: Wood Scott-B07421 > > > > > > Sent: Saturday, October 24, 2015 4:56 AM > > > > > > To: Zhao Qiang-B45475 > > > > > > Cc: linux-ker...@vger.kernel.org; linuxppc-dev@lists.ozlabs.org; > > > > > > lau...@codeaurora.org; Xie Xiaobo-R63061 ; > > > > > > b...@kernel.crashing.org; Li Yang-Leo-R58472 > > > > > > ; pau...@samba.org > > > > > > Subject: Re: [PATCH v12 4/6] QE/CPM: move muram management > > > > functions > > > > > > to qe_common > > > > > > > > > > > > On Fri, 2015-10-23 at 02:45 -0500, Zhao Qiang-B45475 wrote: > > > > > > > On Fri, 2015-10-23 at 11:10 AM, Wood Scott-B07421 > > > > > > > > > > > > > > wrote: > > > > > > > > -Original Message- > > > > > > > > From: Wood Scott-B07421 > > > > > > > > Sent: Friday, October 23, 2015 11:10 AM > > > > > > > > To: Zhao Qiang-B45475 > > > > > > > > Cc: linux-ker...@vger.kernel.org; > > > > > > > > linuxppc-dev@lists.ozlabs.org; lau...@codeaurora.org; Xie > > > > > > > > Xiaobo-R63061 ; > > > > > > > > b...@kernel.crashing.org; Li Yang-Leo-R58472 > > > > > > > > ; pau...@samba.org > > > > > > > > Subject: Re: [PATCH v12 4/6] QE/CPM: move muram management > > > > > > functions > > > > > > > > to qe_common > > > > > > > > > > > > > > So then why are you selecting QUICC_ENGINE? And again, what > > > > > > does it have to do with this patch? > > > > > > > > > > Cpm-spi is dependent on qe_muram, if not select it, Cpm-spi will > > > > > failed to build. > > > > > > > > Why QUICC_ENGINE and not CPM? > > > > > > QE and CPM use the same muram, and it has been moved to qe_muram > > from > > > cpm_muram. > > > > Fix the makefiles so that the muram code continues to be built for both > > QUICC_ENGINE and CPM. It's not acceptable to have to bring in the entire > > QE > > code just for the muram. > > > How about to define and CONFIG_QE_MURAM in Kconfig for muram? That's fine. -Scott ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH] powerpc/pseries: Correct string length in pseries_of_derive_parent()
On Mon, 2015-10-26 at 14:33 -0500, Nathan Fontenot wrote: > Commit a030e1e4bbd085bbcfd0a23f8d355fcd41f39bed made a change to use > kstrndup() instead of kmalloc() + strlcpy() in > pseries_of_derive_parent() > which introduces a subtle change in the parent path name generated. > The kstrndup() routine will copy n characters followed by a > terminating null, > whereas strlcpy() will copy n-1 characters and add a terminating > null. Nice catch! One comment below. > > This slight difference results in having a parent path that includes > the > trailing '/' character, i.e. "/cpus/" vs. "/cpus". This then causes > the > subsequent call to of_find_node_by_path() to fail, and in the case of > DLPAR add operations, the DLPAR request fails. > > This patch reduces the total length of the string to copy in kstrndup > by 1 > so we no longer copy the trailing '/'. > > Signed-off-by: Nathan Fontenot > --- > arch/powerpc/platforms/pseries/of_helpers.c |2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/arch/powerpc/platforms/pseries/of_helpers.c > b/arch/powerpc/platforms/pseries/of_helpers.c > index 4417afe..6d90378 100644 > --- a/arch/powerpc/platforms/pseries/of_helpers.c > +++ b/arch/powerpc/platforms/pseries/of_helpers.c > @@ -24,7 +24,7 @@ struct device_node *pseries_of_derive_parent(const > char *path) > return ERR_PTR(-EINVAL); > > if (tail > path + 1) { > - parent_path = kstrndup(path, tail - path, > GFP_KERNEL); > + parent_path = kstrndup(path, (tail - 1) - path, > GFP_KERNEL); Since previous line has (tail > path + 1) which is equivalent to (tail - 1 > path), can we amend both? For example (might be better, but first comes to my mind) const char *tail = kbasename(path) - 1; ... if (tail > path) { > if (!parent_path) > return ERR_PTR(-ENOMEM); > } > -- Andy Shevchenko Intel Finland Oy ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH] powerpc/85xx: Enable TWR_P102x option by default in mpc85xx_smp_defconfig
Enable TWR_P102x option by default in mpc85xx_smp_defconfig to support p1025twr board. Signed-off-by: Pengbo Li --- arch/powerpc/configs/mpc85xx_basic_defconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/powerpc/configs/mpc85xx_basic_defconfig b/arch/powerpc/configs/mpc85xx_basic_defconfig index 850bd19..b1593fe 100644 --- a/arch/powerpc/configs/mpc85xx_basic_defconfig +++ b/arch/powerpc/configs/mpc85xx_basic_defconfig @@ -12,6 +12,7 @@ CONFIG_P1010_RDB=y CONFIG_P1022_DS=y CONFIG_P1022_RDK=y CONFIG_P1023_RDB=y +CONFIG_TWR_P102x=y CONFIG_SBC8548=y CONFIG_SOCRATES=y CONFIG_STX_GP3=y -- 2.1.0.27.g96db324 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH] powerpc/pseries: Correct string length in pseries_of_derive_parent()
On 10/27/2015 03:17 AM, Andy Shevchenko wrote: > On Mon, 2015-10-26 at 14:33 -0500, Nathan Fontenot wrote: >> Commit a030e1e4bbd085bbcfd0a23f8d355fcd41f39bed made a change to use >> kstrndup() instead of kmalloc() + strlcpy() in >> pseries_of_derive_parent() >> which introduces a subtle change in the parent path name generated. >> The kstrndup() routine will copy n characters followed by a >> terminating null, >> whereas strlcpy() will copy n-1 characters and add a terminating >> null. > > Nice catch! > One comment below. > >> >> This slight difference results in having a parent path that includes >> the >> trailing '/' character, i.e. "/cpus/" vs. "/cpus". This then causes >> the >> subsequent call to of_find_node_by_path() to fail, and in the case of >> DLPAR add operations, the DLPAR request fails. >> >> This patch reduces the total length of the string to copy in kstrndup >> by 1 >> so we no longer copy the trailing '/'. >> >> Signed-off-by: Nathan Fontenot >> --- >> arch/powerpc/platforms/pseries/of_helpers.c |2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/arch/powerpc/platforms/pseries/of_helpers.c >> b/arch/powerpc/platforms/pseries/of_helpers.c >> index 4417afe..6d90378 100644 >> --- a/arch/powerpc/platforms/pseries/of_helpers.c >> +++ b/arch/powerpc/platforms/pseries/of_helpers.c >> @@ -24,7 +24,7 @@ struct device_node *pseries_of_derive_parent(const >> char *path) >> return ERR_PTR(-EINVAL); >> >> if (tail > path + 1) { >> -parent_path = kstrndup(path, tail - path, >> GFP_KERNEL); >> +parent_path = kstrndup(path, (tail - 1) - path, >> GFP_KERNEL); > > Since previous line has (tail > path + 1) which is equivalent to (tail > - 1 > path), can we amend both? > > For example (might be better, but first comes to my mind) > > const char *tail = kbasename(path) - 1; Agreed. I'll send out a v2 of the patch with this update and add a comment to indicate we do not want to include the trailing '\' character. -Nathan > > ... > > if (tail > path) { > > >> if (!parent_path) >> return ERR_PTR(-ENOMEM); >> } >> > ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [v2 03/11] soc/fsl: Introduce the DPAA BMan portal driver
Hello, sorry for the message format, but I don't have the original e-mail. [...] diff --git a/drivers/soc/fsl/qbman/bman.h b/drivers/soc/fsl/qbman/bman.h new file mode 100644 index 000..c987938 --- /dev/null +++ b/drivers/soc/fsl/qbman/bman.h @@ -0,0 +1,542 @@ +/* Copyright 2008 - 2015 Freescale Semiconductor, Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of Freescale Semiconductor nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * ALTERNATIVELY, this software may be distributed under the terms of the + * GNU General Public License ("GPL") as published by the Free Software + * Foundation, either version 2 of that License or (at your option) any + * later version. + * + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "bman_priv.h" + +extern u16 bman_pool_max; [...] diff --git a/drivers/soc/fsl/qbman/bman_portal.c b/drivers/soc/fsl/qbman/bman_portal.c new file mode 100644 index 000..62d8f64 --- /dev/null +++ b/drivers/soc/fsl/qbman/bman_portal.c @@ -0,0 +1,351 @@ +/* Copyright 2008 - 2015 Freescale Semiconductor, Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of Freescale Semiconductor nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * ALTERNATIVELY, this software may be distributed under the terms of the + * GNU General Public License ("GPL") as published by the Free Software + * Foundation, either version 2 of that License or (at your option) any + * later version. + * + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "bman_priv.h" + +/* + * Global variables of the max portal/pool number this BMan version supported + */ +u16 bman_ip_rev; +EXPORT_SYMBOL(bman_ip_rev); + +u16 bman_pool_max; +EXPORT_SYMBOL(bman_pool_max); [...] Why are there two bman_pool_max variables, one global and one module specific (drivers/soc/fsl/qbman/bman.c) which are similarly initialized. One via the BMan register, the other via the FDT? -- Sebastian Huber, embedded brains GmbH Address : Dornierstr. 4, D-82178 Puchheim, Germany Phone : +49 89 189 47 41-16 Fax : +49 89 189 47 41-09 E-Mail : sebastian.hu...@embedded-brains.de PGP : Public key available on request. Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG. ___ Linuxppc-dev mailing list
[PATCH v2] powerpc/pseries: Correct string length in pseries_of_derive_parent()
Commit a030e1e4bbd085bbcfd0a23f8d355fcd41f39bed make a change to use kstrndup() instead of kmalloc() + strlcpy() in the pseries_of_derive_parent() routine that introduces a subtle change in the parent path name generated. The kstrndup() routine will copy n characters followed by a terminating null, whereas strlcpy() will copy n-1 characters and add a terminating null. This slight difference results in having a parent path that includes the tailing '/' character, "/cpus/" vs. "/cpus". This then causes the subsequent call to of_find_node_by_path() to fail, and in the case of DLPAR add operations the DLPAR request fails. This patch decrements the pointer returned from kbasename() to point to the '/' character before the base name instead of the base name. This then adjusts the string length calculations to not include the trailing '/' in the parent path name. Signed-off-by: Nathan Fontenot --- Updates for v2: Decrement the pointer returned from kbasename() instead of subtracting 1 when calculating the string length. arch/powerpc/platforms/pseries/of_helpers.c |7 +-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/arch/powerpc/platforms/pseries/of_helpers.c b/arch/powerpc/platforms/pseries/of_helpers.c index 4417afe..2798933 100644 --- a/arch/powerpc/platforms/pseries/of_helpers.c +++ b/arch/powerpc/platforms/pseries/of_helpers.c @@ -17,13 +17,16 @@ struct device_node *pseries_of_derive_parent(const char *path) { struct device_node *parent; char *parent_path = "/"; - const char *tail = kbasename(path); + const char *tail; + + /* We do not want the trailing '/' character */ + tail = kbasename(path) - 1; /* reject if path is "/" */ if (!strcmp(path, "/")) return ERR_PTR(-EINVAL); - if (tail > path + 1) { + if (tail > path) { parent_path = kstrndup(path, tail - path, GFP_KERNEL); if (!parent_path) return ERR_PTR(-ENOMEM); ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH v2] powerpc/pseries: Correct string length in pseries_of_derive_parent()
On Tue, 2015-10-27 at 10:46 -0500, Nathan Fontenot wrote: > Commit a030e1e4bbd085bbcfd0a23f8d355fcd41f39bed make a change to use > kstrndup() instead of kmalloc() + strlcpy() in the > pseries_of_derive_parent() > routine that introduces a subtle change in the parent path name > generated. > The kstrndup() routine will copy n characters followed by a > terminating null, > whereas strlcpy() will copy n-1 characters and add a terminating > null. > > This slight difference results in having a parent path that includes > the > tailing '/' character, "/cpus/" vs. "/cpus". This then causes the > subsequent > call to of_find_node_by_path() to fail, and in the case of DLPAR add > operations the DLPAR request fails. > > This patch decrements the pointer returned from kbasename() to point > to the > '/' character before the base name instead of the base name. This > then > adjusts the string length calculations to not include the trailing > '/' > in the parent path name. > > Signed-off-by: Nathan Fontenot Reviewed-by: Andy Shevchenko > --- > > Updates for v2: Decrement the pointer returned from kbasename() > instead > of subtracting 1 when calculating the string length. > > arch/powerpc/platforms/pseries/of_helpers.c |7 +-- > 1 file changed, 5 insertions(+), 2 deletions(-) > > diff --git a/arch/powerpc/platforms/pseries/of_helpers.c > b/arch/powerpc/platforms/pseries/of_helpers.c > index 4417afe..2798933 100644 > --- a/arch/powerpc/platforms/pseries/of_helpers.c > +++ b/arch/powerpc/platforms/pseries/of_helpers.c > @@ -17,13 +17,16 @@ struct device_node > *pseries_of_derive_parent(const char *path) > { > struct device_node *parent; > char *parent_path = "/"; > - const char *tail = kbasename(path); > + const char *tail; > + > + /* We do not want the trailing '/' character */ > + tail = kbasename(path) - 1; > > /* reject if path is "/" */ > if (!strcmp(path, "/")) > return ERR_PTR(-EINVAL); > > - if (tail > path + 1) { > + if (tail > path) { > parent_path = kstrndup(path, tail - path, > GFP_KERNEL); > if (!parent_path) > return ERR_PTR(-ENOMEM); > -- Andy Shevchenko Intel Finland Oy ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
RE: [V5, 2/6] fsl/fman: Add FMan support
Regards, Igal Liberman > -Original Message- > From: Wood Scott-B07421 > Sent: Saturday, September 26, 2015 2:02 AM > To: Liberman Igal-B31950 > Cc: net...@vger.kernel.org; linuxppc-dev@lists.ozlabs.org; linux- > ker...@vger.kernel.org; Bucur Madalin-Cristian-B32716 > > Subject: Re: [V5, 2/6] fsl/fman: Add FMan support > > On Mon, Sep 21, 2015 at 02:52:34PM +0300, Igal.Liberman wrote: > > diff --git a/drivers/net/ethernet/freescale/fman/fman.c > > b/drivers/net/ethernet/freescale/fman/fman.c > > new file mode 100644 > > index 000..924685f > > --- /dev/null > > +++ b/drivers/net/ethernet/freescale/fman/fman.c > > @@ -0,0 +1,2738 @@ > > +/* > > + * Copyright 2008-2015 Freescale Semiconductor Inc. > > + * > > + * Redistribution and use in source and binary forms, with or without > > + * modification, are permitted provided that the following conditions are > met: > > + * * Redistributions of source code must retain the above copyright > > + * notice, this list of conditions and the following disclaimer. > > + * * Redistributions in binary form must reproduce the above copyright > > + * notice, this list of conditions and the following disclaimer in > > the > > + * documentation and/or other materials provided with the > distribution. > > + * * Neither the name of Freescale Semiconductor nor the > > + * names of its contributors may be used to endorse or promote > products > > + * derived from this software without specific prior written > > permission. > > + * > > +// * > > + * ALTERNATIVELY, this software may be distributed under the terms of > > +the > > + * GNU General Public License ("GPL") as published by the Free > > +Software > > + * Foundation, either version 2 of that License or (at your option) > > +any > > + * later version. > > What is that // doing there? Removed. > > > +/* Exceptions bit map */ > > +#define EX_DMA_BUS_ERROR 0x8000 > > +#define EX_DMA_READ_ECC0x4000 > > +#define EX_DMA_SYSTEM_WRITE_ECC0x2000 > > +#define EX_DMA_FM_WRITE_ECC0x1000 > > +#define EX_FPM_STALL_ON_TASKS 0x0800 > > +#define EX_FPM_SINGLE_ECC 0x0400 > > +#define EX_FPM_DOUBLE_ECC 0x0200 > > +#define EX_QMI_SINGLE_ECC 0x0100 > > +#define EX_QMI_DEQ_FROM_UNKNOWN_PORTID 0x0080 > > +#define EX_QMI_DOUBLE_ECC 0x0040 > > +#define EX_BMI_LIST_RAM_ECC0x0020 > > +#define EX_BMI_STORAGE_PROFILE_ECC 0x0010 > > +#define EX_BMI_STATISTICS_RAM_ECC 0x0008 > > +#define EX_IRAM_ECC0x0004 > > +#define EX_MURAM_ECC 0x0002 > > +#define EX_BMI_DISPATCH_RAM_ECC0x0001 > > +#define EX_DMA_SINGLE_PORT_ECC 0x8000 > > + > > +#define DFLT_EXCEPTIONS\ > > +((EX_DMA_BUS_ERROR)| \ > > + (EX_DMA_READ_ECC) | \ > > + (EX_DMA_SYSTEM_WRITE_ECC) | \ > > + (EX_DMA_FM_WRITE_ECC) | \ > > + (EX_FPM_STALL_ON_TASKS)| \ > > + (EX_FPM_SINGLE_ECC)| \ > > + (EX_FPM_DOUBLE_ECC)| \ > > + (EX_QMI_DEQ_FROM_UNKNOWN_PORTID) | \ > > + (EX_BMI_LIST_RAM_ECC) | \ > > + (EX_BMI_STORAGE_PROFILE_ECC) | \ > > + (EX_BMI_STATISTICS_RAM_ECC)| \ > > + (EX_MURAM_ECC) | \ > > + (EX_BMI_DISPATCH_RAM_ECC) | \ > > + (EX_QMI_DOUBLE_ECC)| \ > > + (EX_QMI_SINGLE_ECC)) > > You don't need parentheses around each symbol. > Removed the parentheses (here and in other places) > This is only used in one place -- why put the list here rather than in the > place > where it's used? > Moved this define. > > +struct fman_state_struct { > > + u8 fm_id; > > + u16 fm_clk_freq; > > + struct fman_rev_info rev_info; > > + bool enabled_time_stamp; > > + u8 count1_micro_bit; > > + u8 total_num_of_tasks; > > + u8 accumulated_num_of_tasks; > > + u32 accumulated_fifo_size; > > + u8 accumulated_num_of_open_dmas; > > + u8 accumulated_num_of_deq_tnums; > > + bool low_end_restriction; > > + u32 exceptions; > > + u32 extra_fifo_pool_size; > > + u8 extra_tasks_pool_size; > > + u8 extra_open_dmas_pool_size; > > + u16 port_mfl[MAX_NUM_OF_MACS]; > > + u16 mac_mfl[MAX_NUM_OF_MACS]; > > + > > + /* SOC specific */ > > + u32 fm_iram_size; > > + /* DMA */ > > + u32 dma_thresh_max_commq; > > + u32 dma_thresh_max_buf; > > + u32 max_num_of_open_dmas; > > + /* QMI */ > > + u32 qmi_max_num_of_tnums; > > + u32 qmi_def_tnums_thresh; > > + /* BMI */ > > + u32 bmi_max_num_of_tasks; > > + u32 bmi_max_fifo_size; > > + /* General */ > > + u32 fm_port_num_of_cg; > > + u32 num_of_rx_ports; > > + u32 total_fifo_size; > > + > > + u32 qman_channel_base; > > + u32 num_of_qman_channels; > > + > > + struct resource *res; > > +}; > > + > > +struct fman_cfg { > > + u8 disp_limit_t
[PATCH v2] powerpc/mm: Add page soft dirty tracking
User space checkpoint and restart tool (CRIU) needs the page's change to be soft tracked. This allows to do a pre checkpoint and then dump only touched pages. This is done by using a newly assigned PTE bit (_PAGE_SOFT_DIRTY) when the page is backed in memory, and a new _PAGE_SWP_SOFT_DIRTY bit when the page is swapped out. The _PAGE_SWP_SOFT_DIRTY bit is dynamically put after the swap type in the swap pte. A check is added to ensure that the bit is not overwritten by _PAGE_HPTEFLAGS. V2: - Fix allnoconfig build Signed-off-by: Laurent Dufour CC: Aneesh Kumar K.V --- arch/powerpc/Kconfig | 2 ++ arch/powerpc/include/asm/pgtable-ppc64.h | 13 +-- arch/powerpc/include/asm/pgtable.h | 40 +++- arch/powerpc/include/asm/pte-book3e.h| 1 + arch/powerpc/include/asm/pte-common.h| 8 +-- arch/powerpc/include/asm/pte-hash64.h| 1 + 6 files changed, 60 insertions(+), 5 deletions(-) diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig index 9a7057ec2154..73a4a36a6b38 100644 --- a/arch/powerpc/Kconfig +++ b/arch/powerpc/Kconfig @@ -559,6 +559,7 @@ choice config PPC_4K_PAGES bool "4k page size" + select HAVE_ARCH_SOFT_DIRTY if CHECKPOINT_RESTORE && PPC_BOOK3S config PPC_16K_PAGES bool "16k page size" @@ -567,6 +568,7 @@ config PPC_16K_PAGES config PPC_64K_PAGES bool "64k page size" depends on !PPC_FSL_BOOK3E && (44x || PPC_STD_MMU_64 || PPC_BOOK3E_64) + select HAVE_ARCH_SOFT_DIRTY if CHECKPOINT_RESTORE && PPC_BOOK3S config PPC_256K_PAGES bool "256k page size" diff --git a/arch/powerpc/include/asm/pgtable-ppc64.h b/arch/powerpc/include/asm/pgtable-ppc64.h index 3245f2d96d4f..9ae686003b12 100644 --- a/arch/powerpc/include/asm/pgtable-ppc64.h +++ b/arch/powerpc/include/asm/pgtable-ppc64.h @@ -315,7 +315,8 @@ static inline void pte_clear(struct mm_struct *mm, unsigned long addr, static inline void __ptep_set_access_flags(pte_t *ptep, pte_t entry) { unsigned long bits = pte_val(entry) & - (_PAGE_DIRTY | _PAGE_ACCESSED | _PAGE_RW | _PAGE_EXEC); + (_PAGE_DIRTY | _PAGE_ACCESSED | _PAGE_RW | _PAGE_EXEC | +_PAGE_SOFT_DIRTY); #ifdef PTE_ATOMIC_UPDATES unsigned long old, tmp; @@ -354,6 +355,7 @@ static inline void __ptep_set_access_flags(pte_t *ptep, pte_t entry) * We filter HPTEFLAGS on set_pte. \ */ \ BUILD_BUG_ON(_PAGE_HPTEFLAGS & (0x1f << _PAGE_BIT_SWAP_TYPE)); \ + BUILD_BUG_ON(_PAGE_HPTEFLAGS & _PAGE_SWP_SOFT_DIRTY); \ } while (0) /* * on pte we don't need handle RADIX_TREE_EXCEPTIONAL_SHIFT; @@ -371,6 +373,8 @@ static inline void __ptep_set_access_flags(pte_t *ptep, pte_t entry) void pgtable_cache_add(unsigned shift, void (*ctor)(void *)); void pgtable_cache_init(void); + +#define _PAGE_SWP_SOFT_DIRTY (1UL << (SWP_TYPE_BITS + _PAGE_BIT_SWAP_TYPE)) #endif /* __ASSEMBLY__ */ /* @@ -389,7 +393,7 @@ void pgtable_cache_init(void); */ #define _HPAGE_CHG_MASK (PTE_RPN_MASK | _PAGE_HPTEFLAGS | \ _PAGE_DIRTY | _PAGE_ACCESSED | _PAGE_SPLITTING | \ -_PAGE_THP_HUGE) +_PAGE_THP_HUGE | _PAGE_SOFT_DIRTY) #ifndef __ASSEMBLY__ /* @@ -521,6 +525,11 @@ static inline pte_t *pmdp_ptep(pmd_t *pmd) #define pmd_mkyoung(pmd) pte_pmd(pte_mkyoung(pmd_pte(pmd))) #define pmd_mkwrite(pmd) pte_pmd(pte_mkwrite(pmd_pte(pmd))) +#ifdef CONFIG_HAVE_ARCH_SOFT_DIRTY +#define pmd_soft_dirty(pmd)pte_soft_dirty(pmd_pte(pmd)) +#define pmd_mksoft_dirty(pmd) pte_pmd(pte_mksoft_dirty(pmd_pte(pmd))) +#endif /* CONFIG_HAVE_ARCH_SOFT_DIRTY */ + #define __HAVE_ARCH_PMD_WRITE #define pmd_write(pmd) pte_write(pmd_pte(pmd)) diff --git a/arch/powerpc/include/asm/pgtable.h b/arch/powerpc/include/asm/pgtable.h index b64b4212b71f..9f1bc8a58ba4 100644 --- a/arch/powerpc/include/asm/pgtable.h +++ b/arch/powerpc/include/asm/pgtable.h @@ -38,6 +38,44 @@ static inline int pte_special(pte_t pte) { return pte_val(pte) & _PAGE_SPECIAL; static inline int pte_none(pte_t pte) { return (pte_val(pte) & ~_PTE_NONE_MASK) == 0; } static inline pgprot_t pte_pgprot(pte_t pte) { return __pgprot(pte_val(pte) & PAGE_PROT_BITS); } +#ifdef CONFIG_HAVE_ARCH_SOFT_DIRTY +static inline int pte_soft_dirty(pte_t pte) +{ + return pte_val(pte) & _PAGE_SOFT_DIRTY; +} +static inline pte_t pte_mksoft_dirty(pte_t pte) +{ + pte_val(pte) |= _PAGE_SOFT_DIRTY; + return pte; +} + +static inline pte_t pte_swp_mksoft_dirty(pte_t pte) +{ + pte_val(pte) |= _PAGE_SWP_SOFT_DIRTY; + return pte; +} +static inline int pte_swp_soft_dirty(pte_t pte) +{ + return pte_val(pte) & _PAGE_SWP_SOFT_DIRTY; +} +static inline pte_t pte_swp_clear_soft_dirty(pte_t pte) +{ + pte_val(pte) &= ~_PAGE_SWP_SOFT_DIRTY;
[PATCH v2 0/6] powerpc/pseries: Move CPU DLPAR into the kernel
To better support CPU hotplug in PowerKVM and PowerVM environments, the handling of CPU dlpar should be done entirely in the kernel. This will allow a common entry point to be used for PowerVM and PowerKVM CPU dlpar requests. For both environments the entry point is the same one introduced in a previous patch set that moved memory hotplug into the kernel. This entry point accepts a rtas hotplug event which is either constructed when using the /sys/kernel/dlpar interface or is passed to the kernel when handling a ras epow interrupt. Note: The patches are based on top of two previous patches I sent out; [PATCH] powerpc/pseries: Verify CPU doesn't exist before adding https://lists.ozlabs.org/pipermail/linuxppc-dev/2015-October/135550.html [PATCH v2] powerpc/pseries: Correct string length in pseries_of_derive_parent() https://lists.ozlabs.org/pipermail/linuxppc-dev/2015-October/135667.html -Nathan Patch 1/6: - Consolidate cpu hotplug code from pseries/dlpar.c to pseries/hotplug-cpu.c Patch 2/6: - Factor out common code pieces for both environments Patch 3/6: - Update cpu dlpar error recovery Patch 4/6: - Add cpu hotplug remove capability Patch 5/6: - Add cpu hotplug add capability Patch 6/6: - Enable sysfs interface for cpu hotplug dlpar.c | 232 -- hotplug-cpu.c | 596 +- pseries.h |9 3 files changed, 568 insertions(+), 269 deletions(-) ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH v2 1/6] powerpc/pseries: Consolidate CPU hotplug code to hotplug-cpu.c
No functional changes, this patch is simply a move of the cpu hotplug code from pseries/dlpar.c to pseries/hotplug-cpu.c. This is in an effort to consolidate all of the cpu hotplug code in a common place. Signed-off-by: Nathan Fontenot --- arch/powerpc/platforms/pseries/dlpar.c | 226 -- arch/powerpc/platforms/pseries/hotplug-cpu.c | 218 + 2 files changed, 219 insertions(+), 225 deletions(-) diff --git a/arch/powerpc/platforms/pseries/dlpar.c b/arch/powerpc/platforms/pseries/dlpar.c index fe6320d..438fdbd 100644 --- a/arch/powerpc/platforms/pseries/dlpar.c +++ b/arch/powerpc/platforms/pseries/dlpar.c @@ -20,7 +20,6 @@ #include #include "of_helpers.h" -#include "offline_states.h" #include "pseries.h" #include @@ -338,220 +337,6 @@ int dlpar_release_drc(u32 drc_index) return 0; } -#ifdef CONFIG_ARCH_CPU_PROBE_RELEASE - -static int dlpar_online_cpu(struct device_node *dn) -{ - int rc = 0; - unsigned int cpu; - int len, nthreads, i; - const __be32 *intserv; - u32 thread; - - intserv = of_get_property(dn, "ibm,ppc-interrupt-server#s", &len); - if (!intserv) - return -EINVAL; - - nthreads = len / sizeof(u32); - - cpu_maps_update_begin(); - for (i = 0; i < nthreads; i++) { - thread = be32_to_cpu(intserv[i]); - for_each_present_cpu(cpu) { - if (get_hard_smp_processor_id(cpu) != thread) - continue; - BUG_ON(get_cpu_current_state(cpu) - != CPU_STATE_OFFLINE); - cpu_maps_update_done(); - rc = device_online(get_cpu_device(cpu)); - if (rc) - goto out; - cpu_maps_update_begin(); - - break; - } - if (cpu == num_possible_cpus()) - printk(KERN_WARNING "Could not find cpu to online " - "with physical id 0x%x\n", thread); - } - cpu_maps_update_done(); - -out: - return rc; - -} - -static bool dlpar_cpu_exists(struct device_node *parent, u32 drc_index) -{ - struct device_node *child = NULL; - u32 my_drc_index; - bool found; - int rc; - - /* Assume cpu doesn't exist */ - found = false; - - for_each_child_of_node(parent, child) { - rc = of_property_read_u32(child, "ibm,my-drc-index", - &my_drc_index); - if (rc) - continue; - - if (my_drc_index == drc_index) { - of_node_put(child); - found = true; - break; - } - } - - return found; -} - -static ssize_t dlpar_cpu_probe(const char *buf, size_t count) -{ - struct device_node *dn, *parent; - u32 drc_index; - int rc; - - rc = kstrtou32(buf, 0, &drc_index); - if (rc) - return -EINVAL; - - parent = of_find_node_by_path("/cpus"); - if (!parent) - return -ENODEV; - - if (dlpar_cpu_exists(parent, drc_index)) { - of_node_put(parent); - printk(KERN_WARNING "CPU with drc index %x already exists\n", - drc_index); - return -EINVAL; - } - - rc = dlpar_acquire_drc(drc_index); - if (rc) { - of_node_put(parent); - return -EINVAL; - } - - dn = dlpar_configure_connector(cpu_to_be32(drc_index), parent); - of_node_put(parent); - if (!dn) { - dlpar_release_drc(drc_index); - return -EINVAL; - } - - rc = dlpar_attach_node(dn); - if (rc) { - dlpar_release_drc(drc_index); - dlpar_free_cc_nodes(dn); - return rc; - } - - rc = dlpar_online_cpu(dn); - if (rc) - return rc; - - return count; -} - -static int dlpar_offline_cpu(struct device_node *dn) -{ - int rc = 0; - unsigned int cpu; - int len, nthreads, i; - const __be32 *intserv; - u32 thread; - - intserv = of_get_property(dn, "ibm,ppc-interrupt-server#s", &len); - if (!intserv) - return -EINVAL; - - nthreads = len / sizeof(u32); - - cpu_maps_update_begin(); - for (i = 0; i < nthreads; i++) { - thread = be32_to_cpu(intserv[i]); - for_each_present_cpu(cpu) { - if (get_hard_smp_processor_id(cpu) != thread) - continue; - - if (get_cpu_current_state(cpu) == CPU_STATE_OFFLINE) - break; - - if (get_cpu_current_state(cpu) == CPU_STATE_ONLINE) { -
[PATCH v2 2/6] powerpc/pseries: Factor out common cpu hotplug code
Re-factor the cpu hotplug code to support doing cpu hotplug completely in the kernel and using the existing sysfs probe/release interfaces. This patch pulls out pieces of existing cpu hotplug code into common routines, dlpar_cpu_add() and dlpar_cpu_remove(), to be used by both interfaces. There are no functional changes introduced. Signed-off-by: Nathan Fontenot --- arch/powerpc/platforms/pseries/hotplug-cpu.c | 70 ++ 1 file changed, 39 insertions(+), 31 deletions(-) diff --git a/arch/powerpc/platforms/pseries/hotplug-cpu.c b/arch/powerpc/platforms/pseries/hotplug-cpu.c index 10c2942..d6cb184 100644 --- a/arch/powerpc/platforms/pseries/hotplug-cpu.c +++ b/arch/powerpc/platforms/pseries/hotplug-cpu.c @@ -340,8 +340,6 @@ static void pseries_remove_processor(struct device_node *np) cpu_maps_update_done(); } -#ifdef CONFIG_ARCH_CPU_PROBE_RELEASE - static int dlpar_online_cpu(struct device_node *dn) { int rc = 0; @@ -409,16 +407,11 @@ static bool dlpar_cpu_exists(struct device_node *parent, u32 drc_index) return found; } -static ssize_t dlpar_cpu_probe(const char *buf, size_t count) +static ssize_t dlpar_cpu_add(u32 drc_index) { struct device_node *dn, *parent; - u32 drc_index; int rc; - rc = kstrtou32(buf, 0, &drc_index); - if (rc) - return -EINVAL; - parent = of_find_node_by_path("/cpus"); if (!parent) return -ENODEV; @@ -449,10 +442,7 @@ static ssize_t dlpar_cpu_probe(const char *buf, size_t count) } rc = dlpar_online_cpu(dn); - if (rc) - return rc; - - return count; + return rc; } static int dlpar_offline_cpu(struct device_node *dn) @@ -511,6 +501,41 @@ out: } +static ssize_t dlpar_cpu_remove(struct device_node *dn, u32 drc_index) +{ + int rc; + + rc = dlpar_offline_cpu(dn); + if (rc) + return -EINVAL; + + rc = dlpar_release_drc(drc_index); + if (rc) + return rc; + + rc = dlpar_detach_node(dn); + if (rc) + dlpar_acquire_drc(drc_index); + + return rc; +} + +#ifdef CONFIG_ARCH_CPU_PROBE_RELEASE + +static ssize_t dlpar_cpu_probe(const char *buf, size_t count) +{ + u32 drc_index; + int rc; + + rc = kstrtou32(buf, 0, &drc_index); + if (rc) + return -EINVAL; + + rc = dlpar_cpu_add(drc_index); + + return rc ? rc : count; +} + static ssize_t dlpar_cpu_release(const char *buf, size_t count) { struct device_node *dn; @@ -527,27 +552,10 @@ static ssize_t dlpar_cpu_release(const char *buf, size_t count) return -EINVAL; } - rc = dlpar_offline_cpu(dn); - if (rc) { - of_node_put(dn); - return -EINVAL; - } - - rc = dlpar_release_drc(drc_index); - if (rc) { - of_node_put(dn); - return rc; - } - - rc = dlpar_detach_node(dn); - if (rc) { - dlpar_acquire_drc(drc_index); - return rc; - } - + rc = dlpar_cpu_remove(dn, drc_index); of_node_put(dn); - return count; + return rc ? rc : count; } #endif /* CONFIG_ARCH_CPU_PROBE_RELEASE */ ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH v2 4/6] powerpc/pseries: Add CPU dlpar remove functionality
Add the ability to dlpar remove CPUs via hotplug rtas events, either by specifying the drc-index of the CPU to remove or providing a count of cpus to remove. To remove multiple cpus in a single request we create a list of possible DR (Dynamic Reconfiguration) cpus and their drc indexes that can be removed. We can then traverse the list remove each cpu and easily clean up in any cases of failure. Signed-off-by: Nathan Fontenot --- Updates for v2: - use for_each_node_by_type() instead of for_each_child_of_node - updated how the list of cpus to remove is generated - change to remove all cpus requested or none at all - put function declarations under CONFIG_HOTPLUG_CPU arch/powerpc/platforms/pseries/hotplug-cpu.c | 138 ++ arch/powerpc/platforms/pseries/pseries.h |9 ++ 2 files changed, 147 insertions(+) diff --git a/arch/powerpc/platforms/pseries/hotplug-cpu.c b/arch/powerpc/platforms/pseries/hotplug-cpu.c index f080e81..635f0ba 100644 --- a/arch/powerpc/platforms/pseries/hotplug-cpu.c +++ b/arch/powerpc/platforms/pseries/hotplug-cpu.c @@ -26,6 +26,7 @@ #include/* for idle_task_exit */ #include #include +#include #include #include #include @@ -570,6 +571,143 @@ static ssize_t dlpar_cpu_remove(struct device_node *dn, u32 drc_index) return 0; } +static struct device_node *cpu_drc_index_to_dn(u32 drc_index) +{ + struct device_node *dn; + u32 my_index; + int rc; + + for_each_node_by_type(dn, "cpu") { + rc = of_property_read_u32(dn, "ibm,my-drc-index", &my_index); + if (rc) + continue; + + if (my_index == drc_index) + break; + } + + return dn; +} + +static int dlpar_cpu_remove_by_index(u32 drc_index) +{ + struct device_node *dn; + int rc; + + dn = cpu_drc_index_to_dn(drc_index); + if (!dn) + return -ENODEV; + + rc = dlpar_cpu_remove(dn, drc_index); + of_node_put(dn); + return rc; +} + +static u32 *dlpar_cpus_to_remove(int cpus_to_remove) +{ + struct device_node *dn; + u32 *cpu_drcs; + int cpus_found = 0; + int i, rc; + + cpu_drcs = kcalloc(cpus_to_remove, sizeof(*cpu_drcs), GFP_KERNEL); + if (!cpu_drcs) + return NULL; + + i = 0; + for_each_node_by_type(dn, "cpu") { + cpus_found++; + + if (cpus_found > cpus_to_remove) { + of_node_put(dn); + break; + } + + rc = of_property_read_u32(dn, "ibm,my-drc-index", + &cpu_drcs[i++]); + if (rc) { + of_node_put(dn); + break; + } + } + + /* We want to find cpus_to_remove + 1 CPUs to ensure we do not +* remove the last CPU. +*/ + if (cpus_found <= cpus_to_remove) { + pr_warn("Failed to find enough CPUs (%d of %d) to remove\n", + cpus_found, cpus_to_remove); + kfree(cpu_drcs); + cpu_drcs = NULL; + } + + return cpu_drcs; +} + +static int dlpar_cpu_remove_by_count(u32 cpus_to_remove) +{ + u32 *cpu_drcs; + int cpus_removed = 0; + int i, rc; + + pr_debug("Attempting to hot-remove %d CPUs\n", cpus_to_remove); + + cpu_drcs = dlpar_cpus_to_remove(cpus_to_remove); + if (!cpu_drcs) + return -EINVAL; + + for (i = 0; i < cpus_to_remove; i++) { + rc = dlpar_cpu_remove_by_index(cpu_drcs[i]); + if (rc) + break; + + cpus_removed++; + } + + if (cpus_removed != cpus_to_remove) { + pr_warn("CPU hot-remove failed, adding back removed CPUs\n"); + + for (i = 0; i < cpus_removed; i++) + dlpar_cpu_add(cpu_drcs[i]); + + rc = -EINVAL; + } else { + rc = 0; + } + + kfree(cpu_drcs); + return rc; +} + +int dlpar_cpu(struct pseries_hp_errorlog *hp_elog) +{ + u32 count, drc_index; + int rc; + + count = hp_elog->_drc_u.drc_count; + drc_index = hp_elog->_drc_u.drc_index; + + lock_device_hotplug(); + + switch (hp_elog->action) { + case PSERIES_HP_ELOG_ACTION_REMOVE: + if (hp_elog->id_type == PSERIES_HP_ELOG_ID_DRC_COUNT) + rc = dlpar_cpu_remove_by_count(count); + else if (hp_elog->id_type == PSERIES_HP_ELOG_ID_DRC_INDEX) + rc = dlpar_cpu_remove_by_index(drc_index); + else + rc = -EINVAL; + break; + default: + pr_err("Invalid action (%d) specified\n", hp_elog->action); + rc = -EINVAL; + break; + } + + unlock_device_hotplug(); + return r
[PATCH v2 5/6] powerpc/pseries: Add CPU dlpar add functionality
Add the ability to hotplug add cpus via rtas hotplug events by either specifying the drc index of the CPU to add, or providing a count of the number of CPUs to add. Signed-off-by: Nathan Fontenot --- arch/powerpc/platforms/pseries/hotplug-cpu.c | 94 ++ 1 file changed, 94 insertions(+) diff --git a/arch/powerpc/platforms/pseries/hotplug-cpu.c b/arch/powerpc/platforms/pseries/hotplug-cpu.c index 635f0ba..8ec52c0 100644 --- a/arch/powerpc/platforms/pseries/hotplug-cpu.c +++ b/arch/powerpc/platforms/pseries/hotplug-cpu.c @@ -679,6 +679,92 @@ static int dlpar_cpu_remove_by_count(u32 cpus_to_remove) return rc; } +static u32 *dlpar_cpus_to_add(u32 cpus_to_add) +{ + struct device_node *parent; + u32 *cpu_drcs; + int cpus_found = 0; + int i, index, rc; + + cpu_drcs = kcalloc(cpus_to_add, sizeof(*cpu_drcs), GFP_KERNEL); + if (!cpu_drcs) + return NULL; + + parent = of_find_node_by_path("/cpus"); + if (!parent) { + kfree(cpu_drcs); + return NULL; + } + + /* Search the ibm,drc-indexes array for possible CPU drcs to +* add. Note that the format of the ibm,drc-indexes array is +* the number of entries in the array followed by the array +* of drc values so we start looking at index = 1. +*/ + i = 0; + index = 1; + while (cpus_found < cpus_to_add) { + u32 drc; + + rc = of_property_read_u32_index(parent, "ibm,drc-indexes", + index++, &drc); + if (rc) + break; + + if (dlpar_cpu_exists(parent, drc)) + continue; + + cpu_drcs[i++] = drc; + cpus_found++; + } + + of_node_put(parent); + + if (cpus_found < cpus_to_add) { + pr_warn("Failed to find enough CPUs (%d of %d) to add\n", + cpus_found, cpus_to_add); + kfree(cpu_drcs); + cpu_drcs = NULL; + } + + return cpu_drcs; +} + +static int dlpar_cpu_add_by_count(u32 cpus_to_add) +{ + u32 *cpu_drcs; + int cpus_added = 0; + int i, rc; + + pr_debug("Attempting to hot-add %d CPUs\n", cpus_to_add); + + cpu_drcs = dlpar_cpus_to_add(cpus_to_add); + if (!cpu_drcs) + return -EINVAL; + + for (i = 0; i < cpus_to_add; i++) { + rc = dlpar_cpu_add(cpu_drcs[i]); + if (rc) + break; + + cpus_added++; + } + + if (cpus_added < cpus_to_add) { + pr_warn("CPU hot-add failed, removing any added CPUs\n"); + + for (i = 0; i < cpus_added; i++) + dlpar_cpu_remove_by_index(cpu_drcs[i]); + + rc = -EINVAL; + } else { + rc = 0; + } + + kfree(cpu_drcs); + return rc; +} + int dlpar_cpu(struct pseries_hp_errorlog *hp_elog) { u32 count, drc_index; @@ -698,6 +784,14 @@ int dlpar_cpu(struct pseries_hp_errorlog *hp_elog) else rc = -EINVAL; break; + case PSERIES_HP_ELOG_ACTION_ADD: + if (hp_elog->id_type == PSERIES_HP_ELOG_ID_DRC_COUNT) + rc = dlpar_cpu_add_by_count(count); + else if (hp_elog->id_type == PSERIES_HP_ELOG_ID_DRC_INDEX) + rc = dlpar_cpu_add(drc_index); + else + rc = -EINVAL; + break; default: pr_err("Invalid action (%d) specified\n", hp_elog->action); rc = -EINVAL; ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH v2 6/6] powerpc/pseries: Enable kernel CPU dlpar from sysfs
Enable new kernel cpu hotplug functionality by allowing cpu dlpar requests to be initiated from sysfs. Signed-off-by: Nathan Fontenot --- arch/powerpc/platforms/pseries/dlpar.c |6 ++ 1 file changed, 6 insertions(+) diff --git a/arch/powerpc/platforms/pseries/dlpar.c b/arch/powerpc/platforms/pseries/dlpar.c index 438fdbd..2b93ae8 100644 --- a/arch/powerpc/platforms/pseries/dlpar.c +++ b/arch/powerpc/platforms/pseries/dlpar.c @@ -356,6 +356,9 @@ static int handle_dlpar_errorlog(struct pseries_hp_errorlog *hp_elog) case PSERIES_HP_ELOG_RESOURCE_MEM: rc = dlpar_memory(hp_elog); break; + case PSERIES_HP_ELOG_RESOURCE_CPU: + rc = dlpar_cpu(hp_elog); + break; default: pr_warn_ratelimited("Invalid resource (%d) specified\n", hp_elog->resource); @@ -385,6 +388,9 @@ static ssize_t dlpar_store(struct class *class, struct class_attribute *attr, if (!strncmp(arg, "memory", 6)) { hp_elog->resource = PSERIES_HP_ELOG_RESOURCE_MEM; arg += strlen("memory "); + } else if (!strncmp(arg, "cpu", 3)) { + hp_elog->resource = PSERIES_HP_ELOG_RESOURCE_CPU; + arg += strlen("cpu "); } else { pr_err("Invalid resource specified: \"%s\"\n", buf); rc = -EINVAL; ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH v2 3/6] powerpc/pseries: Update CPU hotplug error recovery
Update the cpu dlpar add/remove paths to do better error recovery when a failure occurs during the add/remove operation. Signed-off-by: Nathan Fontenot --- Updates for v2: - Corrected some pr_* statements moving pr_info to pr_debug staements and pr_debug to pr_warn statements. arch/powerpc/platforms/pseries/hotplug-cpu.c | 76 ++ 1 file changed, 63 insertions(+), 13 deletions(-) diff --git a/arch/powerpc/platforms/pseries/hotplug-cpu.c b/arch/powerpc/platforms/pseries/hotplug-cpu.c index d6cb184..f080e81 100644 --- a/arch/powerpc/platforms/pseries/hotplug-cpu.c +++ b/arch/powerpc/platforms/pseries/hotplug-cpu.c @@ -18,6 +18,8 @@ * 2 of the License, or (at your option) any later version. */ +#define pr_fmt(fmt) "pseries-hotplug-cpu: " fmt + #include #include #include @@ -410,38 +412,67 @@ static bool dlpar_cpu_exists(struct device_node *parent, u32 drc_index) static ssize_t dlpar_cpu_add(u32 drc_index) { struct device_node *dn, *parent; - int rc; + int rc, saved_rc; + + pr_debug("Attempting to add CPU, drc index: %x\n", drc_index); parent = of_find_node_by_path("/cpus"); - if (!parent) + if (!parent) { + pr_warn("Failed to find CPU root node \"/cpus\"\n"); return -ENODEV; + } if (dlpar_cpu_exists(parent, drc_index)) { of_node_put(parent); - printk(KERN_WARNING "CPU with drc index %x already exists\n", - drc_index); + pr_warn("CPU with drc index %x already exists\n", drc_index); return -EINVAL; } rc = dlpar_acquire_drc(drc_index); if (rc) { + pr_warn("Failed to acquire DRC, rc: %d, drc index: %x\n", + rc, drc_index); of_node_put(parent); return -EINVAL; } dn = dlpar_configure_connector(cpu_to_be32(drc_index), parent); of_node_put(parent); - if (!dn) + if (!dn) { + pr_warn("Failed call to configure-connector, drc index: %x\n", + drc_index); + dlpar_release_drc(drc_index); return -EINVAL; + } rc = dlpar_attach_node(dn); if (rc) { - dlpar_release_drc(drc_index); - dlpar_free_cc_nodes(dn); - return rc; + saved_rc = rc; + pr_warn("Failed to attach node %s, rc: %d, drc index: %x\n", + dn->name, rc, drc_index); + + rc = dlpar_release_drc(drc_index); + if (!rc) + dlpar_free_cc_nodes(dn); + + return saved_rc; } rc = dlpar_online_cpu(dn); + if (rc) { + saved_rc = rc; + pr_warn("Failed to online cpu %s, rc: %d, drc index: %x\n", + dn->name, rc, drc_index); + + rc = dlpar_detach_node(dn); + if (!rc) + dlpar_release_drc(drc_index); + + return saved_rc; + } + + pr_debug("Successfully added CPU %s, drc index: %x\n", dn->name, +drc_index); return rc; } @@ -505,19 +536,38 @@ static ssize_t dlpar_cpu_remove(struct device_node *dn, u32 drc_index) { int rc; + pr_debug("Attemping to remove CPU %s, drc index: %x\n", +dn->name, drc_index); + rc = dlpar_offline_cpu(dn); - if (rc) + if (rc) { + pr_warn("Failed to offline CPU %s, rc: %d\n", dn->name, rc); return -EINVAL; + } rc = dlpar_release_drc(drc_index); - if (rc) + if (rc) { + pr_warn("Failed to release drc (%x) for CPU %s, rc: %d\n", + drc_index, dn->name, rc); + dlpar_online_cpu(dn); return rc; + } rc = dlpar_detach_node(dn); - if (rc) - dlpar_acquire_drc(drc_index); + if (rc) { + int saved_rc = rc; - return rc; + pr_warn("Failed to detach CPU %s, rc: %d", dn->name, rc); + + rc = dlpar_acquire_drc(drc_index); + if (!rc) + dlpar_online_cpu(dn); + + return saved_rc; + } + + pr_debug("Successfully removed CPU, drc index: %x\n", drc_index); + return 0; } #ifdef CONFIG_ARCH_CPU_PROBE_RELEASE ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH v4 0/2] powerpc/512x: add LocalPlus Bus FIFO device driver
On 27.10.2015 05:22, Vinod Koul wrote: > On Thu, Oct 22, 2015 at 01:15:03AM +0300, Alexander Popov wrote: >> On 12.10.2015 00:08, Alexander Popov wrote: >>> This driver for Freescale MPC512x LocalPlus Bus FIFO (called SCLPC >>> in the Reference Manual) allows Direct Memory Access transfers >>> between RAM and peripheral devices on LocalPlus Bus. >> >>> Changes in v4: >>> - the race condition is fixed; >>> - plenty of style fixes are made; >>> - devm_* functions and EPROBE_DEFER are used in probe(). >> >> Hello, >> >> I've done my best to fix the issues pointed by Timur Tabi and Vinod Koul. >> Could I have a feedback please? > > I dont see to have v4 in my list :( Can you please repost Hello, Vinod I'm sure I haven't miss your address in the list of the recipients. Anyway I can repost. Anatolij Gustschin wrote that he applied v4 with some fix to mpc5xxx/next some time ago. So should I repost v4 for everybody? How should I mark the reposted patches? Best regards, Alexander ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH v8 10/61] powerpc/PCI: Add IORESOURCE_MEM_64 for 64-bit resource in OF parsing
For device resource PREF bit setting under bridge 64-bit pref resource, we need to make sure only set PREF for 64bit resource, so set IORESOUCE_MEM_64 for 64bit resource during of device resource flags parsing. Link: https://bugzilla.kernel.org/show_bug.cgi?id=96261 Link: https://bugzilla.kernel.org/show_bug.cgi?id=96241 Signed-off-by: Yinghai Lu Cc: Benjamin Herrenschmidt Cc: Paul Mackerras Cc: Michael Ellerman Cc: Gavin Shan Cc: Yijing Wang Cc: Anton Blanchard Cc: linuxppc-dev@lists.ozlabs.org --- arch/powerpc/kernel/pci_of_scan.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/arch/powerpc/kernel/pci_of_scan.c b/arch/powerpc/kernel/pci_of_scan.c index 349ed11..d7305d7 100644 --- a/arch/powerpc/kernel/pci_of_scan.c +++ b/arch/powerpc/kernel/pci_of_scan.c @@ -44,8 +44,10 @@ static unsigned int pci_parse_of_flags(u32 addr0, int bridge) if (addr0 & 0x0200) { flags = IORESOURCE_MEM | PCI_BASE_ADDRESS_SPACE_MEMORY; - flags |= (addr0 >> 22) & PCI_BASE_ADDRESS_MEM_TYPE_64; flags |= (addr0 >> 28) & PCI_BASE_ADDRESS_MEM_TYPE_1M; + if (addr0 & 0x0100) + flags |= IORESOURCE_MEM_64 +| PCI_BASE_ADDRESS_MEM_TYPE_64; if (addr0 & 0x4000) flags |= IORESOURCE_PREFETCH | PCI_BASE_ADDRESS_MEM_PREFETCH; -- 1.8.4.5 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH v8 59/61] PCI: Introduce resource_disabled()
Current is using !flags, and we are going to use IORESOURCE_DISABLED instead of clearing resource flags. Let's convert all !flags to helper function resource_disabled(). resource_disabled will check !flags and IORESOURCE_DISABLED both. Cc: linux-al...@vger.kernel.org Cc: linux-i...@vger.kernel.org Cc: linux-am33-l...@redhat.com Cc: linuxppc-dev@lists.ozlabs.org Cc: linux-s...@vger.kernel.org Cc: sparcli...@vger.kernel.org Cc: linux-...@vger.kernel.org Cc: linux-xte...@linux-xtensa.org Cc: io...@lists.linux-foundation.org Cc: linux...@vger.kernel.org Signed-off-by: Yinghai Lu Acked-by: Michael Ellerman --- arch/alpha/kernel/pci.c | 2 +- arch/ia64/pci/pci.c | 4 ++-- arch/microblaze/pci/pci-common.c | 15 --- arch/mn10300/unit-asb2305/pci-asb2305.c | 4 ++-- arch/mn10300/unit-asb2305/pci.c | 4 ++-- arch/powerpc/kernel/pci-common.c | 16 +--- arch/powerpc/platforms/powernv/pci-ioda.c | 12 ++-- arch/s390/pci/pci.c | 2 +- arch/sparc/kernel/pci.c | 2 +- arch/x86/pci/i386.c | 4 ++-- arch/xtensa/kernel/pci.c | 4 ++-- drivers/iommu/intel-iommu.c | 3 ++- drivers/pci/host/pcie-rcar.c | 2 +- drivers/pci/iov.c | 2 +- drivers/pci/probe.c | 2 +- drivers/pci/quirks.c | 4 ++-- drivers/pci/rom.c | 2 +- drivers/pci/setup-bus.c | 8 drivers/pci/setup-res.c | 2 +- include/linux/ioport.h| 4 20 files changed, 53 insertions(+), 45 deletions(-) diff --git a/arch/alpha/kernel/pci.c b/arch/alpha/kernel/pci.c index 5f387ee..c89c8ef 100644 --- a/arch/alpha/kernel/pci.c +++ b/arch/alpha/kernel/pci.c @@ -282,7 +282,7 @@ pcibios_claim_one_bus(struct pci_bus *b) for (i = 0; i < PCI_NUM_RESOURCES; i++) { struct resource *r = &dev->resource[i]; - if (r->parent || !r->start || !r->flags) + if (r->parent || !r->start || resource_disabled(r)) continue; if (pci_has_flag(PCI_PROBE_ONLY) || (r->flags & IORESOURCE_PCI_FIXED)) { diff --git a/arch/ia64/pci/pci.c b/arch/ia64/pci/pci.c index 7cc3be9..cc293ea 100644 --- a/arch/ia64/pci/pci.c +++ b/arch/ia64/pci/pci.c @@ -501,7 +501,7 @@ void pcibios_fixup_device_resources(struct pci_dev *dev) for (idx = 0; idx < PCI_BRIDGE_RESOURCES; idx++) { struct resource *r = &dev->resource[idx]; - if (!r->flags || r->parent || !r->start) + if (resource_disabled(r) || r->parent || !r->start) continue; pci_claim_resource(dev, idx); @@ -519,7 +519,7 @@ static void pcibios_fixup_bridge_resources(struct pci_dev *dev) for (idx = PCI_BRIDGE_RESOURCES; idx < PCI_NUM_RESOURCES; idx++) { struct resource *r = &dev->resource[idx]; - if (!r->flags || r->parent || !r->start) + if (resource_disabled(r) || r->parent || !r->start) continue; pci_claim_bridge_resource(dev, idx); diff --git a/arch/microblaze/pci/pci-common.c b/arch/microblaze/pci/pci-common.c index 09b1af6..c123d3c 100644 --- a/arch/microblaze/pci/pci-common.c +++ b/arch/microblaze/pci/pci-common.c @@ -705,7 +705,7 @@ static void pcibios_fixup_resources(struct pci_dev *dev) } for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) { struct resource *res = dev->resource + i; - if (!res->flags) + if (resource_disabled(res)) continue; if (res->start == 0) { pr_debug("PCI:%s Resource %d %016llx-%016llx [%x]", @@ -806,7 +806,7 @@ static void pcibios_fixup_bridge(struct pci_bus *bus) pci_bus_for_each_resource(bus, res, i) { if (!res) continue; - if (!res->flags) + if (resource_disabled(res)) continue; if (i >= 3 && bus->self->transparent) continue; @@ -985,7 +985,7 @@ static void pcibios_allocate_bus_resources(struct pci_bus *bus) pci_domain_nr(bus), bus->number); pci_bus_for_each_resource(bus, res, i) { - if (!res || !res->flags + if (!res || resource_disabled(res) || res->start > res->end || res->parent) continue; if (bus->parent == NULL) @@ -1087,7 +1087,8 @@ static void __init pcibios_allocate_resources(int pass) r = &dev->resource[idx]; if (r->parent) /* Already allocated */
[PATCH v8 52/61] PCI: Unify skip_ioresource_align()
There are powerpc generic version and x86 local version for skip_ioresource_align(). Move the powerpc version to setup-bus.c, and kill x86 local version. Also kill dummy version in microblaze. Cc: Michal Simek Cc: Paul Mackerras Cc: Michael Ellerman Cc: Arnd Bergmann Cc: linuxppc-dev@lists.ozlabs.org Cc: linux-a...@vger.kernel.org Signed-off-by: Yinghai Lu Reviewed-by: Thomas Gleixner Acked-by: Michael Ellerman --- arch/microblaze/pci/pci-common.c | 8 arch/powerpc/kernel/pci-common.c | 11 +-- arch/x86/include/asm/pci_x86.h | 1 - arch/x86/pci/common.c| 4 ++-- arch/x86/pci/i386.c | 12 ++-- drivers/pci/setup-bus.c | 9 + include/asm-generic/pci-bridge.h | 2 ++ 7 files changed, 16 insertions(+), 31 deletions(-) diff --git a/arch/microblaze/pci/pci-common.c b/arch/microblaze/pci/pci-common.c index ae838ed..09b1af6 100644 --- a/arch/microblaze/pci/pci-common.c +++ b/arch/microblaze/pci/pci-common.c @@ -878,11 +878,6 @@ void pcibios_fixup_bus(struct pci_bus *bus) } EXPORT_SYMBOL(pcibios_fixup_bus); -static int skip_isa_ioresource_align(struct pci_dev *dev) -{ - return 0; -} - /* * We need to avoid collisions with `mirrored' VGA ports * and other strange ISA hardware, so we always want the @@ -899,12 +894,9 @@ static int skip_isa_ioresource_align(struct pci_dev *dev) resource_size_t pcibios_align_resource(void *data, const struct resource *res, resource_size_t size, resource_size_t align) { - struct pci_dev *dev = data; resource_size_t start = res->start; if (res->flags & IORESOURCE_IO) { - if (skip_isa_ioresource_align(dev)) - return start; if (start & 0x300) start = (start + 0x3ff) & ~0x3ff; } diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c index 7587b2a..8853667 100644 --- a/arch/powerpc/kernel/pci-common.c +++ b/arch/powerpc/kernel/pci-common.c @@ -1052,15 +1052,6 @@ void pci_fixup_cardbus(struct pci_bus *bus) pcibios_setup_bus_devices(bus); } - -static int skip_isa_ioresource_align(struct pci_dev *dev) -{ - if (pci_has_flag(PCI_CAN_SKIP_ISA_ALIGN) && - !(dev->bus->bridge_ctl & PCI_BRIDGE_CTL_ISA)) - return 1; - return 0; -} - /* * We need to avoid collisions with `mirrored' VGA ports * and other strange ISA hardware, so we always want the @@ -1081,7 +1072,7 @@ resource_size_t pcibios_align_resource(void *data, const struct resource *res, resource_size_t start = res->start; if (res->flags & IORESOURCE_IO) { - if (skip_isa_ioresource_align(dev)) + if (skip_isa_ioresource_align(dev->bus)) return start; if (start & 0x300) start = (start + 0x3ff) & ~0x3ff; diff --git a/arch/x86/include/asm/pci_x86.h b/arch/x86/include/asm/pci_x86.h index fa1195d..81a7abf 100644 --- a/arch/x86/include/asm/pci_x86.h +++ b/arch/x86/include/asm/pci_x86.h @@ -28,7 +28,6 @@ do { \ #define PCI_ASSIGN_ROMS0x1000 #define PCI_BIOS_IRQ_SCAN 0x2000 #define PCI_ASSIGN_ALL_BUSSES 0x4000 -#define PCI_CAN_SKIP_ISA_ALIGN 0x8000 #define PCI_USE__CRS 0x1 #define PCI_CHECK_ENABLE_AMD_MMCONF0x2 #define PCI_HAS_IO_ECS 0x4 diff --git a/arch/x86/pci/common.c b/arch/x86/pci/common.c index dc78a4a..7c018df 100644 --- a/arch/x86/pci/common.c +++ b/arch/x86/pci/common.c @@ -83,7 +83,7 @@ DEFINE_RAW_SPINLOCK(pci_config_lock); static int __init can_skip_ioresource_align(const struct dmi_system_id *d) { - pci_probe |= PCI_CAN_SKIP_ISA_ALIGN; + pci_add_flags(PCI_CAN_SKIP_ISA_ALIGN); printk(KERN_INFO "PCI: %s detected, can skip ISA alignment\n", d->ident); return 0; } @@ -619,7 +619,7 @@ char *__init pcibios_setup(char *str) pci_routeirq = 1; return NULL; } else if (!strcmp(str, "skip_isa_align")) { - pci_probe |= PCI_CAN_SKIP_ISA_ALIGN; + pci_add_flags(PCI_CAN_SKIP_ISA_ALIGN); return NULL; } else if (!strcmp(str, "noioapicquirk")) { noioapicquirk = 1; diff --git a/arch/x86/pci/i386.c b/arch/x86/pci/i386.c index 0a9f2ca..3f17726 100644 --- a/arch/x86/pci/i386.c +++ b/arch/x86/pci/i386.c @@ -33,6 +33,7 @@ #include #include +#include #include #include #include @@ -128,15 +129,6 @@ static void __init pcibios_fw_addr_list_del(void) pcibios_fw_addr_done = true; } -static int -skip_isa_ioresource_align(struct pci_dev *dev) { - - if ((pci_probe & PCI_CAN_SKIP_ISA_ALIGN) && - !(dev->bus->bridge_ctl & PCI_BRIDGE_CTL_ISA)) - return 1; - return 0; -} - /* * We need to avoid collisions with `mirrored' VGA ports * and other strange ISA
Re: [PATCH V10 03/12] powerpc/pci: Cache VF index in pci_dn
Hi, > > diff --git a/arch/powerpc/include/asm/pci-bridge.h > b/arch/powerpc/include/asm/pci-bridge.h > index b3a226b..3d7e537 100644 > --- a/arch/powerpc/include/asm/pci-bridge.h > +++ b/arch/powerpc/include/asm/pci-bridge.h > @@ -210,6 +210,7 @@ struct pci_dn { > #define IODA_INVALID_PE (-1) > #ifdef CONFIG_PPC_POWERNV > int pe_number; > + int vf_index; /* VF index in the PF */ Here, vf_index is inside CONFIG_PPC_POWERNV... > #ifdef CONFIG_PCI_IOV > u16 vfs_expanded; /* number of VFs IOV BAR expanded */ > u16 num_vfs;/* number of VFs enabled*/ > diff --git a/arch/powerpc/kernel/pci_dn.c b/arch/powerpc/kernel/pci_dn.c > index b3b4df9..f771130 100644 > --- a/arch/powerpc/kernel/pci_dn.c > +++ b/arch/powerpc/kernel/pci_dn.c > @@ -139,6 +139,7 @@ struct pci_dn *pci_get_pdn(struct pci_dev *pdev) > #ifdef CONFIG_PCI_IOV > static struct pci_dn *add_one_dev_pci_data(struct pci_dn *parent, > struct pci_dev *pdev, > +int vf_index, > int busno, int devfn) > { > struct pci_dn *pdn; > @@ -157,6 +158,7 @@ static struct pci_dn *add_one_dev_pci_data(struct pci_dn > *parent, > pdn->parent = parent; > pdn->busno = busno; > pdn->devfn = devfn; > + pdn->vf_index = vf_index; > #ifdef CONFIG_PPC_POWERNV > pdn->pe_number = IODA_INVALID_PE; ... but here, vf_index is outside CONFIG_PPC_POWERNV. Otherwise, the patch looks fine to me. I'm still trying to get my head around SR-IOV generally - once I do I will add any more comments I have or add a reviewed-by. Regards, Daniel signature.asc Description: PGP signature ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH 0/5 v3] Fix NVMe driver support on Power with 32-bit DMA
On 26.10.2015 [18:27:46 -0700], David Miller wrote: > From: Nishanth Aravamudan > Date: Fri, 23 Oct 2015 13:54:20 -0700 > > > 1) add a generic dma_get_page_shift implementation that just returns > > PAGE_SHIFT > > I won't object to this patch series, but if I had implemented this I > would have required the architectures to implement this explicitly, > one-by-one. I think it is less error prone and more likely to end > up with all the architectures setting this correctly. Well, looks like I should spin up a v4 anyways for the powerpc changes. So, to make sure I understand your point, should I make the generic dma_get_page_shift a compile-error kind of thing? It will only fail on architectures that actually build the NVME driver (as the only caller). But I'm not sure how exactly to achieve that, if you could give a bit more detail I'd appreciate it! Thanks, Nish ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH 4/7 v2] pseries/iommu: implement DDW-aware dma_get_page_shift
On 27.10.2015 [16:56:10 +1100], Alexey Kardashevskiy wrote: > On 10/24/2015 07:59 AM, Nishanth Aravamudan wrote: > >When DDW (Dynamic DMA Windows) are present for a device, we have stored > >the TCE (Translation Control Entry) size in a special device tree > >property. Check if we have enabled DDW for the device and return the TCE > >size from that property if present. If the property isn't present, > >fallback to looking the value up in struct iommu_table. If we don't find > >a iommu_table, fallback to the kernel's page size. > > > >Signed-off-by: Nishanth Aravamudan > >--- > > arch/powerpc/platforms/pseries/iommu.c | 36 > > ++ > > 1 file changed, 36 insertions(+) > > > >diff --git a/arch/powerpc/platforms/pseries/iommu.c > >b/arch/powerpc/platforms/pseries/iommu.c > >index 0946b98..1bf6471 100644 > >--- a/arch/powerpc/platforms/pseries/iommu.c > >+++ b/arch/powerpc/platforms/pseries/iommu.c > >@@ -1292,6 +1292,40 @@ static u64 dma_get_required_mask_pSeriesLP(struct > >device *dev) > > return dma_iommu_ops.get_required_mask(dev); > > } > > > >+static unsigned long dma_get_page_shift_pSeriesLP(struct device *dev) > >+{ > >+struct iommu_table *tbl; > >+ > >+if (!disable_ddw && dev_is_pci(dev)) { > >+struct pci_dev *pdev = to_pci_dev(dev); > >+struct device_node *dn; > >+ > >+dn = pci_device_to_OF_node(pdev); > >+ > >+/* search upwards for ibm,dma-window */ > >+for (; dn && PCI_DN(dn) && !PCI_DN(dn)->table_group; > >+dn = dn->parent) > >+if (of_get_property(dn, "ibm,dma-window", NULL)) > >+break; > >+/* > >+ * if there is a DDW configuration, the TCE shift is stored in > >+ * the property > >+ */ > >+if (dn && PCI_DN(dn)) { > >+const struct dynamic_dma_window_prop *direct64 = > >+of_get_property(dn, DIRECT64_PROPNAME, NULL); > > > This DIRECT64_PROPNAME property is only present under pHyp, QEMU/KVM > does not set it as 64bit windows are dynamic there so something like > find_existing_ddw() needs to be used here. DIRECT64_PROPNAME is a Linux thing, not a pHyp or QEMU/KVM thing -- it's created by the Linux DDW logic and left in the device-tree when we successfully configure DDW. You're right, though, that logically find_existing_ddw() would be better to use here. I'll spin up a new version. -Nish ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH 2/7 v2] powerpc/dma-mapping: override dma_get_page_shift
On 27.10.2015 [17:02:16 +1100], Alexey Kardashevskiy wrote: > On 10/24/2015 07:57 AM, Nishanth Aravamudan wrote: > >On Power, the kernel's page size can differ from the IOMMU's page size, > >so we need to override the generic implementation, which always returns > >the kernel's page size. Lookup the IOMMU's page size from struct > >iommu_table, if available. Fallback to the kernel's page size, > >otherwise. > > > >Signed-off-by: Nishanth Aravamudan > >--- > > arch/powerpc/include/asm/dma-mapping.h | 3 +++ > > arch/powerpc/kernel/dma.c | 9 + > > 2 files changed, 12 insertions(+) > > > >diff --git a/arch/powerpc/include/asm/dma-mapping.h > >b/arch/powerpc/include/asm/dma-mapping.h > >index 7f522c0..c5638f4 100644 > >--- a/arch/powerpc/include/asm/dma-mapping.h > >+++ b/arch/powerpc/include/asm/dma-mapping.h > >@@ -125,6 +125,9 @@ static inline void set_dma_offset(struct device *dev, > >dma_addr_t off) > > #define HAVE_ARCH_DMA_SET_MASK 1 > > extern int dma_set_mask(struct device *dev, u64 dma_mask); > > > >+#define HAVE_ARCH_DMA_GET_PAGE_SHIFT 1 > >+extern unsigned long dma_get_page_shift(struct device *dev); > >+ > > #include > > > > extern int __dma_set_mask(struct device *dev, u64 dma_mask); > >diff --git a/arch/powerpc/kernel/dma.c b/arch/powerpc/kernel/dma.c > >index 59503ed..e805af2 100644 > >--- a/arch/powerpc/kernel/dma.c > >+++ b/arch/powerpc/kernel/dma.c > >@@ -335,6 +335,15 @@ int dma_set_mask(struct device *dev, u64 dma_mask) > > } > > EXPORT_SYMBOL(dma_set_mask); > > > >+unsigned long dma_get_page_shift(struct device *dev) > >+{ > >+struct iommu_table *tbl = get_iommu_table_base(dev); > >+if (tbl) > >+return tbl->it_page_shift; > > > All PCI devices have this initialized on POWER (at least, our, IBM's > POWER) so 4K will always be returned here while in the case of > (get_dma_ops(dev)==&dma_direct_ops) it could actually return > PAGE_SHIFT. Is 4K still preferred value to return here? Right, so the logic of my series, goes like this: a) We currently are assuming DMA_PAGE_SHIFT (conceptual constant) is PAGE_SHIFT everywhere, including Power. b) After 2/7, the Power code will return either the IOMMU table's shift value, if set, or PAGE_SHIFT (I guess this would be the case if get_dma_ops(dev) == &dma_direct_ops, as you said). That is no different than we have now, except we can return the accurate IOMMU value if available. 3) After 3/7, the platform can override the generic Power get_dma_page_shift(). 4) After 4/7, pseries will return the DDW value, if available, then fallback to the IOMMU table's value. I think in the case of get_dma_ops(dev)==&dma_direct_ops, the only way that can happen is if we are using DDW, right? -Nish ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH 0/5 v3] Fix NVMe driver support on Power with 32-bit DMA
Hi Nishanth, On Wed, Oct 28, 2015 at 9:20 AM, Nishanth Aravamudan wrote: > On 26.10.2015 [18:27:46 -0700], David Miller wrote: >> From: Nishanth Aravamudan >> Date: Fri, 23 Oct 2015 13:54:20 -0700 >> >> > 1) add a generic dma_get_page_shift implementation that just returns >> > PAGE_SHIFT >> >> I won't object to this patch series, but if I had implemented this I >> would have required the architectures to implement this explicitly, >> one-by-one. I think it is less error prone and more likely to end >> up with all the architectures setting this correctly. > > Well, looks like I should spin up a v4 anyways for the powerpc changes. > So, to make sure I understand your point, should I make the generic > dma_get_page_shift a compile-error kind of thing? It will only fail on > architectures that actually build the NVME driver (as the only caller). > But I'm not sure how exactly to achieve that, if you could give a bit > more detail I'd appreciate it! He's suggesting that you _don't_ put a generic implementation in /include/linux/dma-mapping.h and instead add it to _every_ architecture. Thanks, -- Julian Calaby Email: julian.cal...@gmail.com Profile: http://www.google.com/profiles/julian.calaby/ ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH v6 00/37] cxlflash: Miscellaneous bug fixes and corrections
Hi James, This series has been reviewed/acked. Is there anything else you're looking for before this can make it into -next? -matt > On Oct 21, 2015, at 3:08 PM, Matthew R. Ochs > wrote: > > This patch set contains various fixes and corrections for issues that > were found during test and code review. The series is based upon the > code upstreamed in 4.3 (rebased to Dan Carpenter's 9/22 patch) and is > intended for 4.4. The entire set is bisectable. Please reference the > changelog below for details on what has been altered from previous > versions of this patch set. > > v6 Changes: > - Added patch to avoid corrupting the port selection mask > - Added patch to properly initialize the TMF spin lock > - Added patch to remove possibility of skipping context cleanup > - No change to patches present in v5 > > v5 Changes: > - Incorporate comments from Daniel Axtens > - Incorporate comments from Andrew Donnellan > - Added additional clarifications to several commit messages > - Specified some return codes as failures in "Fix function prolog..." > - Made port online failure noisier in "Remove dual port online..." > - Added patch to properly cleanup when encountering an unsupported AFU > - Added patch to escalate a link reset on login timeout > > v4 Changes: > - Incorporate comments from Brian King > - Removed unnecessary check_state() parameter from "Fix to avoid CXL..." > - Added patch to fix potential deadlock on EEH > - Removed patch to avoid state change collision > - Changed fops initialization location in "Fix to avoid corrupting..." > > v3 Changes: > - Rebased the series on top of patch by Dan Carpenter ("a couple off...") > - Incorporate comments from David Laight > - Incorporate comments from Tomas Henzl > - Incorporate comments from Brian King > - Removed patch to stop interrupt processing on remove > - Removed double scsi_device_put() from "Fix potential oops" > - Fixed usage of scnprintf() in "Refine host/device attributes" > - Removed unnecessary parenthesis from "Fix read capacity timeout" > - Added patch to use correct operator for doubling delay > - Changed location of cancel_work_sync() in "Fix to prevent workq..." > - Removed local mutex from cxlflash_afu_sync() in "Fix to avoid state..." > - Added patch to correctly identify a failed function in a trace > - Added patch to fix a fops corruption bug > > v2 Changes: > - Incorporate comments from Ian Munsie > - Rework commit messages to be more descriptive > - Add state change serialization patch > > Manoj Kumar (5): > cxlflash: Fix to avoid invalid port_sel value > cxlflash: Replace magic numbers with literals > cxlflash: Fix read capacity timeout > cxlflash: Fix to double the delay each time > cxlflash: Fix to escalate to LINK_RESET on login timeout > > Matthew R. Ochs (32): > cxlflash: Fix potential oops following LUN removal > cxlflash: Fix data corruption when vLUN used over multiple cards > cxlflash: Fix to avoid sizeof(bool) > cxlflash: Fix context encode mask width > cxlflash: Fix to avoid CXL services during EEH > cxlflash: Correct naming of limbo state and waitq > cxlflash: Make functions static > cxlflash: Refine host/device attributes > cxlflash: Fix to avoid spamming the kernel log > cxlflash: Fix to avoid stall while waiting on TMF > cxlflash: Fix location of setting resid > cxlflash: Fix host link up event handling > cxlflash: Fix async interrupt bypass logic > cxlflash: Remove dual port online dependency > cxlflash: Fix AFU version access/storage and add check > cxlflash: Correct usage of scsi_host_put() > cxlflash: Fix to prevent workq from accessing freed memory > cxlflash: Correct behavior in device reset handler following EEH > cxlflash: Remove unnecessary scsi_block_requests > cxlflash: Fix function prolog parameters and return codes > cxlflash: Fix MMIO and endianness errors > cxlflash: Fix to prevent EEH recovery failure > cxlflash: Correct spelling, grammar, and alignment mistakes > cxlflash: Fix to prevent stale AFU RRQ > MAINTAINERS: Add cxlflash driver > cxlflash: Fix to avoid corrupting adapter fops > cxlflash: Correct trace string > cxlflash: Fix to avoid potential deadlock on EEH > cxlflash: Fix to avoid leaving dangling interrupt resources > cxlflash: Fix to avoid corrupting port selection mask > cxlflash: Fix to avoid lock instrumentation rejection > cxlflash: Fix to avoid bypassing context cleanup > > MAINTAINERS |9 + > drivers/scsi/cxlflash/common.h| 30 +- > drivers/scsi/cxlflash/lunmgt.c| 45 +- > drivers/scsi/cxlflash/main.c | 1550 - > drivers/scsi/cxlflash/main.h |1 + > drivers/scsi/cxlflash/sislite.h |8 +- > drivers/scsi/cxlflash/superpipe.c | 209 +++-- > drivers/scsi/cxlflash/superpipe.h | 14 +- > drivers/scsi/cxlflash/vlun.c | 68 +- > 9 files changed, 1075 insertions(+), 859 deletions(-) > > -- > 2.1.0 > > -- > To unsubscribe from this list: send the line
Re: [PATCH 0/5 v3] Fix NVMe driver support on Power with 32-bit DMA
On 28.10.2015 [09:57:48 +1100], Julian Calaby wrote: > Hi Nishanth, > > On Wed, Oct 28, 2015 at 9:20 AM, Nishanth Aravamudan > wrote: > > On 26.10.2015 [18:27:46 -0700], David Miller wrote: > >> From: Nishanth Aravamudan > >> Date: Fri, 23 Oct 2015 13:54:20 -0700 > >> > >> > 1) add a generic dma_get_page_shift implementation that just returns > >> > PAGE_SHIFT > >> > >> I won't object to this patch series, but if I had implemented this I > >> would have required the architectures to implement this explicitly, > >> one-by-one. I think it is less error prone and more likely to end > >> up with all the architectures setting this correctly. > > > > Well, looks like I should spin up a v4 anyways for the powerpc changes. > > So, to make sure I understand your point, should I make the generic > > dma_get_page_shift a compile-error kind of thing? It will only fail on > > architectures that actually build the NVME driver (as the only caller). > > But I'm not sure how exactly to achieve that, if you could give a bit > > more detail I'd appreciate it! > > He's suggesting that you _don't_ put a generic implementation in > /include/linux/dma-mapping.h and instead add it to _every_ > architecture. Ah, I see! Well, I don't know much about the DMA internals of most architectures -- and my approach kept things functionally the same everywhere (using PAGE_SHIFT) except: a) Power, where I know it doesn't work as-is and b) sparc, where the code implied that a different value than PAGE_SHIFT should be used. Thanks, Nish ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH] powerpc/fsl: Add #clock-cells and clockgen label to clockgen nodes
This allows new-style clock references to be used, which is needed for fman. The old clock nodes will be removed and all clock references converted to new-style once the qoriq-cpufreq driver is updated to stop depending on the old-style references in cpu nodes. Signed-off-by: Scott Wood --- Patches to update the cpufreq driver have been posted, but they require a change to include/linux/clk.h which is still awaiting a response from Russell King. arch/powerpc/boot/dts/fsl/qoriq-clockgen1.dtsi | 3 ++- arch/powerpc/boot/dts/fsl/qoriq-clockgen2.dtsi | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/arch/powerpc/boot/dts/fsl/qoriq-clockgen1.dtsi b/arch/powerpc/boot/dts/fsl/qoriq-clockgen1.dtsi index 4ece1ed..88cd70d 100644 --- a/arch/powerpc/boot/dts/fsl/qoriq-clockgen1.dtsi +++ b/arch/powerpc/boot/dts/fsl/qoriq-clockgen1.dtsi @@ -32,13 +32,14 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -global-utilities@e1000 { +clockgen: global-utilities@e1000 { compatible = "fsl,qoriq-clockgen-1.0"; ranges = <0x0 0xe1000 0x1000>; reg = <0xe1000 0x1000>; clock-frequency = <0>; #address-cells = <1>; #size-cells = <1>; + #clock-cells = <2>; sysclk: sysclk { #clock-cells = <0>; diff --git a/arch/powerpc/boot/dts/fsl/qoriq-clockgen2.dtsi b/arch/powerpc/boot/dts/fsl/qoriq-clockgen2.dtsi index 48e0b6e..6dfd7c5 100644 --- a/arch/powerpc/boot/dts/fsl/qoriq-clockgen2.dtsi +++ b/arch/powerpc/boot/dts/fsl/qoriq-clockgen2.dtsi @@ -32,12 +32,13 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -global-utilities@e1000 { +clockgen: global-utilities@e1000 { compatible = "fsl,qoriq-clockgen-2.0"; ranges = <0x0 0xe1000 0x1000>; reg = <0xe1000 0x1000>; #address-cells = <1>; #size-cells = <1>; + #clock-cells = <2>; sysclk: sysclk { #clock-cells = <0>; -- 2.1.4 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH 0/5 v3] Fix NVMe driver support on Power with 32-bit DMA
Hi Nishanth, On Wed, Oct 28, 2015 at 10:40 AM, Nishanth Aravamudan wrote: > On 28.10.2015 [09:57:48 +1100], Julian Calaby wrote: >> Hi Nishanth, >> >> On Wed, Oct 28, 2015 at 9:20 AM, Nishanth Aravamudan >> wrote: >> > On 26.10.2015 [18:27:46 -0700], David Miller wrote: >> >> From: Nishanth Aravamudan >> >> Date: Fri, 23 Oct 2015 13:54:20 -0700 >> >> >> >> > 1) add a generic dma_get_page_shift implementation that just returns >> >> > PAGE_SHIFT >> >> >> >> I won't object to this patch series, but if I had implemented this I >> >> would have required the architectures to implement this explicitly, >> >> one-by-one. I think it is less error prone and more likely to end >> >> up with all the architectures setting this correctly. >> > >> > Well, looks like I should spin up a v4 anyways for the powerpc changes. >> > So, to make sure I understand your point, should I make the generic >> > dma_get_page_shift a compile-error kind of thing? It will only fail on >> > architectures that actually build the NVME driver (as the only caller). >> > But I'm not sure how exactly to achieve that, if you could give a bit >> > more detail I'd appreciate it! >> >> He's suggesting that you _don't_ put a generic implementation in >> /include/linux/dma-mapping.h and instead add it to _every_ >> architecture. > > Ah, I see! Well, I don't know much about the DMA internals of most > architectures -- and my approach kept things functionally the same > everywhere (using PAGE_SHIFT) except: > > a) Power, where I know it doesn't work as-is > and > b) sparc, where the code implied that a different value than PAGE_SHIFT > should be used. You'll be CCing the maintainers of each architecture on the patches to add the functions, so if they do have specific requirements, I'm sure they'll let you know or provide patches. Thanks, -- Julian Calaby Email: julian.cal...@gmail.com Profile: http://www.google.com/profiles/julian.calaby/ ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH 2/7 v2] powerpc/dma-mapping: override dma_get_page_shift
On Tue, Oct 27, 2015 at 05:02:16PM +1100, Alexey Kardashevskiy wrote: > >+unsigned long dma_get_page_shift(struct device *dev) > >+{ > >+struct iommu_table *tbl = get_iommu_table_base(dev); > >+if (tbl) > >+return tbl->it_page_shift; > > > All PCI devices have this initialized on POWER (at least, our, IBM's > POWER) so 4K will always be returned here while in the case of > (get_dma_ops(dev)==&dma_direct_ops) it could actually return > PAGE_SHIFT. Is 4K still preferred value to return here? 4k is always a safe option to return, but ideally you want to return the highest guaranteed DMA address alignment. The driver just needs to know which bits to mask from virtual addresses such that the offset is the same as the DMA address. ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH V2 0/3] perf/powerpc:Add ability to sample intr machine state in powerpc
Hi Denis, On Monday 26 October 2015 06:47 PM, Denis Kirjanov wrote: On 10/26/15, Anju T wrote: This short patch series add the ability to sample the interrupted machine state for each hardware sample Hi, how can we check your patch series without testing details? I have mentioned about the commands to test this feature in the 3rd patch of this series,but not detailed. To test this patch, Eg: $perf record -I ls // record machine state at interrupt $perf script -D //read the perf.data file Sample output obtained for this patch / output looks like as follows: 179614739048 0xb90 [0x190]: PERF_RECORD_SAMPLE(IP, 0x1): 4130/4130: 0xc01dde88 period: 1 addr: 0 ... intr regs: mask 0xfff ABI 64-bit gpr0 0xc01e6974 gpr1 0xc01e48ad79a0 gpr2 0xc1523400 gpr3 0x1 gpr4 0xc00fd7c76600 gpr5 0x29d1df51d8 gpr6 0x1e00 gpr7 0x0 gpr8 0x0 gpr9 0x0 gpr10 0x1 gpr11 0x0 gpr12 0x24022822 gpr13 0xcfee4c80 gpr14 0x0 gpr15 0xc000fcab3800 gpr16 0x0 gpr17 0xc00ffa445000 gpr18 0xc01e48ad78a0 gpr19 0xc1523400 gpr20 0xc00a09bc gpr21 0xc01e3c11d100 gpr22 0xc01e54a8 gpr23 0xc1523400 gpr24 0xc01e48ad7850 gpr25 0xc01e3c11d100 gpr26 0xc01e48a71790 gpr27 0xfead gpr28 0x0 gpr29 0xc01e3c11d100 gpr30 0x1 gpr31 0x0 nip 0xc000fe8c msr 0x90009032 orig_r3 0xc01e6978 ctr 0xc009e1f0 link 0xc01e697c xer 0x0 ccr 0x84022884 softe 0x1 trap 0xf01 dar 0x0 dsisr 0x30004006004 result 0x0 ... thread: :4130:4130 .. dso: /root/.debug/.build-id/82/8d2c7bac560dc9aac8bf6289f26504e22d6883 :4130 4130 179.614739: 1 cycles: c01dde88 .perf_ctx_unlock (/boot/vmlinux) 0xd20 [0x190]: event: 9 Anju (3): perf/powerpc:add ability to sample intr machine state in power tools/perf:Map the ID values with register names perf/powerpc:add support for sampling intr machine state arch/powerpc/Kconfig| 1 + arch/powerpc/include/uapi/asm/perf_regs.h | 55 + arch/powerpc/perf/Makefile | 1 + arch/powerpc/perf/perf_regs.c | 87 tools/perf/arch/powerpc/include/perf_regs.h | 118 tools/perf/config/Makefile | 5 ++ 6 files changed, 267 insertions(+) create mode 100644 arch/powerpc/include/uapi/asm/perf_regs.h create mode 100644 arch/powerpc/perf/perf_regs.c create mode 100644 tools/perf/arch/powerpc/include/perf_regs.h -- 2.1.0 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev Thanks and regards Anju ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH 0/5 v3] Fix NVMe driver support on Power with 32-bit DMA
On Tue, Oct 27, 2015 at 03:20:10PM -0700, Nishanth Aravamudan wrote: > On 26.10.2015 [18:27:46 -0700], David Miller wrote: > > From: Nishanth Aravamudan > > Date: Fri, 23 Oct 2015 13:54:20 -0700 > > > > > 1) add a generic dma_get_page_shift implementation that just returns > > > PAGE_SHIFT > > > > I won't object to this patch series, but if I had implemented this I > > would have required the architectures to implement this explicitly, > > one-by-one. I think it is less error prone and more likely to end > > up with all the architectures setting this correctly. > > Well, looks like I should spin up a v4 anyways for the powerpc changes. > So, to make sure I understand your point, should I make the generic > dma_get_page_shift a compile-error kind of thing? It will only fail on > architectures that actually build the NVME driver (as the only caller). > But I'm not sure how exactly to achieve that, if you could give a bit > more detail I'd appreciate it! If you're suggesting to compile-time break architectures that currently work just fine with NVMe, let me stop you right there. ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH V10 01/12] PCI/IOV: Rename and export virtfn_add/virtfn_remove
On Mon, Oct 26, 2015 at 11:15:51AM +0800, Wei Yang wrote: > During EEH recovery, hotplug is applied to the devices which don't > have drivers or their drivers don't support EEH. However, the hotplug, > which was implemented based on PCI bus, can't be applied to VF directly. > > The patch renames virtn_{add,remove}() and exports them so that they > can be used in PCI hotplug during EEH recovery. Trivial, but write this as an imperative sentence, e.g., Rename virtn_{add,remove}() and export them so they can be used in PCI hotplug during EEH recovery. "The patch" doesn't add any useful information; it's obvious that the changelog applied to this patch. This comment also applies to at least the next patch. Bjorn ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH V10 00/12] VF EEH on Power8
On Mon, Oct 26, 2015 at 11:15:50AM +0800, Wei Yang wrote: > This patchset enables EEH on SRIOV VFs. The general idea is to create proper > VF edev and VF PE and handle them properly. > ... > Gavin Shan (1): > powerpc/eeh: Don't block PCI config on resetting VF PE > > Wei Yang (11): > PCI/IOV: Rename and export virtfn_add/virtfn_remove > PCI: Add pcibios_bus_add_device() weak function > powerpc/pci: Cache VF index in pci_dn > powerpc/pci: Remove VFs prior to PF > powerpc/eeh: Cache only BARs, not windows or IOV BARs > powerpc/powernv: EEH device for VF > powerpc/eeh: Create PE for VFs > powerpc/powernv: Support EEH reset for VF PE > powerpc/powernv: Support PCI config restore for VFs > powerpc/eeh: Support error recovery for VF PE > powerpc/eeh: Handle hot removed VF when PF is EEH aware > > arch/powerpc/include/asm/eeh.h | 10 ++ > arch/powerpc/include/asm/pci-bridge.h| 2 + > arch/powerpc/kernel/eeh.c| 17 ++- > arch/powerpc/kernel/eeh_cache.c | 6 +- > arch/powerpc/kernel/eeh_dev.c| 1 + > arch/powerpc/kernel/eeh_driver.c | 130 > arch/powerpc/kernel/eeh_pe.c | 13 +- > arch/powerpc/kernel/pci-hotplug.c| 2 +- > arch/powerpc/kernel/pci_dn.c | 16 +- > arch/powerpc/platforms/powernv/eeh-powernv.c | 220 > ++- > arch/powerpc/platforms/powernv/pci.c | 18 +++ > drivers/pci/bus.c| 3 + > drivers/pci/iov.c| 10 +- > include/linux/pci.h | 8 + > 14 files changed, 408 insertions(+), 48 deletions(-) This really only affects powerpc, so I assume this series will go through the powerpc tree. Let me know if you want me to do anything else. Bjorn ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH 0/5 v3] Fix NVMe driver support on Power with 32-bit DMA
On Wed, 2015-10-28 at 10:43 +1100, Julian Calaby wrote: > Hi Nishanth, > You'll be CCing the maintainers of each architecture on the patches > to > add the functions, so if they do have specific requirements, I'm sure > they'll let you know or provide patches. That sort of accross-all-arch change tend to take forever. I'd rather get the existing series in to fix the problem, we can look into improving things later but I tend to think that the default of using PAGE_SHIFT in asm-generic will be fine for most archs. Ben. ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH 0/5 v3] Fix NVMe driver support on Power with 32-bit DMA
From: Nishanth Aravamudan Date: Tue, 27 Oct 2015 15:20:10 -0700 > Well, looks like I should spin up a v4 anyways for the powerpc changes. > So, to make sure I understand your point, should I make the generic > dma_get_page_shift a compile-error kind of thing? It will only fail on > architectures that actually build the NVME driver (as the only caller). > But I'm not sure how exactly to achieve that, if you could give a bit > more detail I'd appreciate it! Yes, I am basically suggesting to simply not provide a default at all. ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH 0/5 v3] Fix NVMe driver support on Power with 32-bit DMA
From: "Busch, Keith" Date: Tue, 27 Oct 2015 22:36:43 + > If you're suggesting to compile-time break architectures that currently > work just fine with NVMe, let me stop you right there. Silently "working" without the architecture maintainer having to explicity look at the new interface and make sure his platform is implementing it properly is an extremely bad practice. ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH 0/5 v3] Fix NVMe driver support on Power with 32-bit DMA
From: Julian Calaby Date: Wed, 28 Oct 2015 10:43:35 +1100 > You'll be CCing the maintainers of each architecture on the patches to > add the functions, so if they do have specific requirements, I'm sure > they'll let you know or provide patches. People miss things, maintainers get busy, so while a CC: is important and appreciated, it doesn't ensure a correct implementation is likely to result. Personally, I'd much rather my arch stop building so I have to go in there to explicitly look at the reason why and make sure I fill in the missing pieces properly and accurately. ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH 01/19] powerpc: Don't disable kernel FP/VMX/VSX MSR bits on context switch
Writing the MSR is slow, so we want to avoid it whenever possible. A subsequent patch will add a debug option that strictly manages the FP/VMX/VSX unavailable bits. For now just remove it, matching what we do in other areas of the kernel (eg enable_kernel_altivec()). A context switch microbenchmark using yield(): http://ozlabs.org/~anton/junkcode/context_switch2.c ./context_switch2 --test=yield --fp 0 0 shows an improvement of almost 3% on POWER8. Signed-off-by: Anton Blanchard --- arch/powerpc/kernel/entry_64.S | 15 +-- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/arch/powerpc/kernel/entry_64.S b/arch/powerpc/kernel/entry_64.S index a94f155..93bb284 100644 --- a/arch/powerpc/kernel/entry_64.S +++ b/arch/powerpc/kernel/entry_64.S @@ -453,26 +453,13 @@ _GLOBAL(_switch) SAVE_8GPRS(14, r1) SAVE_10GPRS(22, r1) mflrr20 /* Return to switch caller */ - mfmsr r22 - li r0, MSR_FP -#ifdef CONFIG_VSX -BEGIN_FTR_SECTION - orisr0,r0,MSR_VSX@h /* Disable VSX */ -END_FTR_SECTION_IFSET(CPU_FTR_VSX) -#endif /* CONFIG_VSX */ #ifdef CONFIG_ALTIVEC BEGIN_FTR_SECTION - orisr0,r0,MSR_VEC@h /* Disable altivec */ mfspr r24,SPRN_VRSAVE /* save vrsave register value */ std r24,THREAD_VRSAVE(r3) END_FTR_SECTION_IFSET(CPU_FTR_ALTIVEC) #endif /* CONFIG_ALTIVEC */ - and.r0,r0,r22 - beq+1f - andcr22,r22,r0 - MTMSRD(r22) - isync -1: std r20,_NIP(r1) + std r20,_NIP(r1) mfcrr23 std r23,_CCR(r1) std r1,KSP(r3) /* Set old stack pointer */ -- 2.5.0 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH 02/19] powerpc: Don't disable MSR bits in do_load_up_transact_*() functions
Similar to the non TM load_up_*() functions, don't disable the MSR bits on the way out. Signed-off-by: Anton Blanchard --- arch/powerpc/kernel/fpu.S| 4 arch/powerpc/kernel/vector.S | 4 2 files changed, 8 deletions(-) diff --git a/arch/powerpc/kernel/fpu.S b/arch/powerpc/kernel/fpu.S index 9ad236e..38eb79b 100644 --- a/arch/powerpc/kernel/fpu.S +++ b/arch/powerpc/kernel/fpu.S @@ -73,10 +73,6 @@ END_FTR_SECTION_IFSET(CPU_FTR_VSX) MTFSF_L(fr0) REST_32FPVSRS(0, R4, R7) - /* FP/VSX off again */ - MTMSRD(r6) - SYNC - blr #endif /* CONFIG_PPC_TRANSACTIONAL_MEM */ diff --git a/arch/powerpc/kernel/vector.S b/arch/powerpc/kernel/vector.S index f5c80d5..1c54259 100644 --- a/arch/powerpc/kernel/vector.S +++ b/arch/powerpc/kernel/vector.S @@ -29,10 +29,6 @@ _GLOBAL(do_load_up_transact_altivec) addir10,r3,THREAD_TRANSACT_VRSTATE REST_32VRS(0,r4,r10) - /* Disable VEC again. */ - MTMSRD(r6) - isync - blr #endif -- 2.5.0 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH 03/19] powerpc: Create context switch helpers save_sprs() and restore_sprs()
Move all our context switch SPR save and restore code into two helpers. We do a few optimisations: - Group all mfsprs and all mtsprs. In many cases an mtspr sets a scoreboarding bit that an mfspr waits on, so the current practise of mfspr A; mtspr A; mfpsr B; mtspr B is the worst scheduling we can do. - SPR writes are slow, so check that the value is changing before writing it. A context switch microbenchmark using yield(): http://ozlabs.org/~anton/junkcode/context_switch2.c ./context_switch2 --test=yield 0 0 shows an improvement of almost 10% on POWER8. Signed-off-by: Anton Blanchard --- arch/powerpc/include/asm/processor.h | 1 + arch/powerpc/include/asm/switch_to.h | 11 - arch/powerpc/kernel/entry_64.S | 60 +-- arch/powerpc/kernel/process.c| 92 +++- 4 files changed, 82 insertions(+), 82 deletions(-) diff --git a/arch/powerpc/include/asm/processor.h b/arch/powerpc/include/asm/processor.h index 5afea36..c273f3e 100644 --- a/arch/powerpc/include/asm/processor.h +++ b/arch/powerpc/include/asm/processor.h @@ -294,6 +294,7 @@ struct thread_struct { #endif #ifdef CONFIG_PPC64 unsigned long dscr; + unsigned long fscr; /* * This member element dscr_inherit indicates that the process * has explicitly attempted and changed the DSCR register value diff --git a/arch/powerpc/include/asm/switch_to.h b/arch/powerpc/include/asm/switch_to.h index 15cca17..33a071d 100644 --- a/arch/powerpc/include/asm/switch_to.h +++ b/arch/powerpc/include/asm/switch_to.h @@ -15,17 +15,6 @@ extern struct task_struct *__switch_to(struct task_struct *, struct thread_struct; extern struct task_struct *_switch(struct thread_struct *prev, struct thread_struct *next); -#ifdef CONFIG_PPC_BOOK3S_64 -static inline void save_early_sprs(struct thread_struct *prev) -{ - if (cpu_has_feature(CPU_FTR_ARCH_207S)) - prev->tar = mfspr(SPRN_TAR); - if (cpu_has_feature(CPU_FTR_DSCR)) - prev->dscr = mfspr(SPRN_DSCR); -} -#else -static inline void save_early_sprs(struct thread_struct *prev) {} -#endif extern void enable_kernel_fp(void); extern void enable_kernel_altivec(void); diff --git a/arch/powerpc/kernel/entry_64.S b/arch/powerpc/kernel/entry_64.S index 93bb284..e84e5bc 100644 --- a/arch/powerpc/kernel/entry_64.S +++ b/arch/powerpc/kernel/entry_64.S @@ -453,29 +453,12 @@ _GLOBAL(_switch) SAVE_8GPRS(14, r1) SAVE_10GPRS(22, r1) mflrr20 /* Return to switch caller */ -#ifdef CONFIG_ALTIVEC -BEGIN_FTR_SECTION - mfspr r24,SPRN_VRSAVE /* save vrsave register value */ - std r24,THREAD_VRSAVE(r3) -END_FTR_SECTION_IFSET(CPU_FTR_ALTIVEC) -#endif /* CONFIG_ALTIVEC */ + std r20,_NIP(r1) mfcrr23 std r23,_CCR(r1) std r1,KSP(r3) /* Set old stack pointer */ -#ifdef CONFIG_PPC_BOOK3S_64 -BEGIN_FTR_SECTION - /* Event based branch registers */ - mfspr r0, SPRN_BESCR - std r0, THREAD_BESCR(r3) - mfspr r0, SPRN_EBBHR - std r0, THREAD_EBBHR(r3) - mfspr r0, SPRN_EBBRR - std r0, THREAD_EBBRR(r3) -END_FTR_SECTION_IFSET(CPU_FTR_ARCH_207S) -#endif - #ifdef CONFIG_SMP /* We need a sync somewhere here to make sure that if the * previous task gets rescheduled on another CPU, it sees all @@ -563,47 +546,6 @@ END_MMU_FTR_SECTION_IFSET(MMU_FTR_1T_SEGMENT) mr r1,r8 /* start using new stack pointer */ std r7,PACAKSAVE(r13) -#ifdef CONFIG_PPC_BOOK3S_64 -BEGIN_FTR_SECTION - /* Event based branch registers */ - ld r0, THREAD_BESCR(r4) - mtspr SPRN_BESCR, r0 - ld r0, THREAD_EBBHR(r4) - mtspr SPRN_EBBHR, r0 - ld r0, THREAD_EBBRR(r4) - mtspr SPRN_EBBRR, r0 - - ld r0,THREAD_TAR(r4) - mtspr SPRN_TAR,r0 -END_FTR_SECTION_IFSET(CPU_FTR_ARCH_207S) -#endif - -#ifdef CONFIG_ALTIVEC -BEGIN_FTR_SECTION - ld r0,THREAD_VRSAVE(r4) - mtspr SPRN_VRSAVE,r0 /* if G4, restore VRSAVE reg */ -END_FTR_SECTION_IFSET(CPU_FTR_ALTIVEC) -#endif /* CONFIG_ALTIVEC */ -#ifdef CONFIG_PPC64 -BEGIN_FTR_SECTION - lwz r6,THREAD_DSCR_INHERIT(r4) - ld r0,THREAD_DSCR(r4) - cmpwi r6,0 - bne 1f - ld r0,PACA_DSCR_DEFAULT(r13) -1: -BEGIN_FTR_SECTION_NESTED(70) - mfspr r8, SPRN_FSCR - rldimi r8, r6, FSCR_DSCR_LG, (63 - FSCR_DSCR_LG) - mtspr SPRN_FSCR, r8 -END_FTR_SECTION_NESTED(CPU_FTR_ARCH_207S, CPU_FTR_ARCH_207S, 70) - cmpdr0,r25 - beq 2f - mtspr SPRN_DSCR,r0 -2: -END_FTR_SECTION_IFSET(CPU_FTR_DSCR) -#endif - ld r6,_CCR(r1) mtcrf 0xFF,r6 diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c index 75b6676..3aabed4 100644 --- a/arch/powerpc/kernel/proce
[PATCH 04/19] powerpc: Remove redundant mflr in _switch
No need to execute mflr twice. Signed-off-by: Anton Blanchard --- arch/powerpc/kernel/entry_64.S | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/arch/powerpc/kernel/entry_64.S b/arch/powerpc/kernel/entry_64.S index e84e5bc..c8b4225 100644 --- a/arch/powerpc/kernel/entry_64.S +++ b/arch/powerpc/kernel/entry_64.S @@ -452,9 +452,7 @@ _GLOBAL(_switch) /* r3-r13 are caller saved -- Cort */ SAVE_8GPRS(14, r1) SAVE_10GPRS(22, r1) - mflrr20 /* Return to switch caller */ - - std r20,_NIP(r1) + std r0,_NIP(r1) /* Return to switch caller */ mfcrr23 std r23,_CCR(r1) std r1,KSP(r3) /* Set old stack pointer */ -- 2.5.0 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH 05/19] powerpc: Remove UP only lazy floating point and vector optimisations
The UP only lazy floating point and vector optimisations were written back when SMP was not common, and neither glibc nor gcc used vector instructions. Now SMP is very common, glibc aggressively uses vector instructions and gcc autovectorises. We want to add new optimisations that apply to both UP and SMP, but in preparation for that remove these UP only optimisations. Signed-off-by: Anton Blanchard --- arch/powerpc/include/asm/processor.h | 6 -- arch/powerpc/include/asm/switch_to.h | 8 --- arch/powerpc/kernel/fpu.S| 35 --- arch/powerpc/kernel/head_fsl_booke.S | 32 -- arch/powerpc/kernel/idle_power7.S| 7 --- arch/powerpc/kernel/process.c| 113 +-- arch/powerpc/kernel/signal_32.c | 18 -- arch/powerpc/kernel/signal_64.c | 18 -- arch/powerpc/kernel/vector.S | 68 - 9 files changed, 1 insertion(+), 304 deletions(-) diff --git a/arch/powerpc/include/asm/processor.h b/arch/powerpc/include/asm/processor.h index c273f3e..a2e8918 100644 --- a/arch/powerpc/include/asm/processor.h +++ b/arch/powerpc/include/asm/processor.h @@ -88,12 +88,6 @@ struct task_struct; void start_thread(struct pt_regs *regs, unsigned long fdptr, unsigned long sp); void release_thread(struct task_struct *); -/* Lazy FPU handling on uni-processor */ -extern struct task_struct *last_task_used_math; -extern struct task_struct *last_task_used_altivec; -extern struct task_struct *last_task_used_vsx; -extern struct task_struct *last_task_used_spe; - #ifdef CONFIG_PPC32 #if CONFIG_TASK_SIZE > CONFIG_KERNEL_START diff --git a/arch/powerpc/include/asm/switch_to.h b/arch/powerpc/include/asm/switch_to.h index 33a071d..bd1d933 100644 --- a/arch/powerpc/include/asm/switch_to.h +++ b/arch/powerpc/include/asm/switch_to.h @@ -27,14 +27,6 @@ extern void giveup_spe(struct task_struct *); extern void load_up_spe(struct task_struct *); extern void switch_booke_debug_regs(struct debug_reg *new_debug); -#ifndef CONFIG_SMP -extern void discard_lazy_cpu_state(void); -#else -static inline void discard_lazy_cpu_state(void) -{ -} -#endif - #ifdef CONFIG_PPC_FPU extern void flush_fp_to_thread(struct task_struct *); extern void giveup_fpu(struct task_struct *); diff --git a/arch/powerpc/kernel/fpu.S b/arch/powerpc/kernel/fpu.S index 38eb79b..50d2352 100644 --- a/arch/powerpc/kernel/fpu.S +++ b/arch/powerpc/kernel/fpu.S @@ -132,31 +132,6 @@ END_FTR_SECTION_IFSET(CPU_FTR_VSX) SYNC MTMSRD(r5) /* enable use of fpu now */ isync -/* - * For SMP, we don't do lazy FPU switching because it just gets too - * horrendously complex, especially when a task switches from one CPU - * to another. Instead we call giveup_fpu in switch_to. - */ -#ifndef CONFIG_SMP - LOAD_REG_ADDRBASE(r3, last_task_used_math) - toreal(r3) - PPC_LL r4,ADDROFF(last_task_used_math)(r3) - PPC_LCMPI 0,r4,0 - beq 1f - toreal(r4) - addir4,r4,THREAD/* want last_task_used_math->thread */ - addir10,r4,THREAD_FPSTATE - SAVE_32FPVSRS(0, R5, R10) - mffsfr0 - stfdfr0,FPSTATE_FPSCR(r10) - PPC_LL r5,PT_REGS(r4) - toreal(r5) - PPC_LL r4,_MSR-STACK_FRAME_OVERHEAD(r5) - li r10,MSR_FP|MSR_FE0|MSR_FE1 - andcr4,r4,r10 /* disable FP for previous task */ - PPC_STL r4,_MSR-STACK_FRAME_OVERHEAD(r5) -1: -#endif /* CONFIG_SMP */ /* enable use of FP after return */ #ifdef CONFIG_PPC32 mfspr r5,SPRN_SPRG_THREAD /* current task's THREAD (phys) */ @@ -175,11 +150,6 @@ END_FTR_SECTION_IFSET(CPU_FTR_VSX) lfd fr0,FPSTATE_FPSCR(r10) MTFSF_L(fr0) REST_32FPVSRS(0, R4, R10) -#ifndef CONFIG_SMP - subir4,r5,THREAD - fromreal(r4) - PPC_STL r4,ADDROFF(last_task_used_math)(r3) -#endif /* CONFIG_SMP */ /* restore registers and return */ /* we haven't used ctr or xer or lr */ blr @@ -226,11 +196,6 @@ END_FTR_SECTION_IFSET(CPU_FTR_VSX) andcr4,r4,r3/* disable FP for previous task */ PPC_STL r4,_MSR-STACK_FRAME_OVERHEAD(r5) 1: -#ifndef CONFIG_SMP - li r5,0 - LOAD_REG_ADDRBASE(r4,last_task_used_math) - PPC_STL r5,ADDROFF(last_task_used_math)(r4) -#endif /* CONFIG_SMP */ blr /* diff --git a/arch/powerpc/kernel/head_fsl_booke.S b/arch/powerpc/kernel/head_fsl_booke.S index fffd1f9..ec936ab 100644 --- a/arch/powerpc/kernel/head_fsl_booke.S +++ b/arch/powerpc/kernel/head_fsl_booke.S @@ -857,29 +857,6 @@ _GLOBAL(load_up_spe) orisr5,r5,MSR_SPE@h mtmsr r5 /* enable use of SPE now */ isync -/* - * For SMP, we don't do lazy SPE switching because it just gets too - * horrendously complex, especially when a task switches from one CPU - * to another. Instead we call giveup_spe in switch_to.
[PATCH 06/19] powerpc: Simplify TM restore checks
Instead of having multiple giveup_*_maybe_transactional() functions, separate out the TM check into a new function called check_if_tm_restore_required(). This will make it easier to optimise the giveup_*() functions in a subsequent patch. Signed-off-by: Anton Blanchard --- arch/powerpc/kernel/process.c | 53 --- 1 file changed, 19 insertions(+), 34 deletions(-) diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c index e098f43..ef64219 100644 --- a/arch/powerpc/kernel/process.c +++ b/arch/powerpc/kernel/process.c @@ -68,7 +68,7 @@ extern unsigned long _get_SP(void); #ifdef CONFIG_PPC_TRANSACTIONAL_MEM -void giveup_fpu_maybe_transactional(struct task_struct *tsk) +static void check_if_tm_restore_required(struct task_struct *tsk) { /* * If we are saving the current thread's registers, and the @@ -82,31 +82,9 @@ void giveup_fpu_maybe_transactional(struct task_struct *tsk) tsk->thread.ckpt_regs.msr = tsk->thread.regs->msr; set_thread_flag(TIF_RESTORE_TM); } - - giveup_fpu(tsk); -} - -void giveup_altivec_maybe_transactional(struct task_struct *tsk) -{ - /* -* If we are saving the current thread's registers, and the -* thread is in a transactional state, set the TIF_RESTORE_TM -* bit so that we know to restore the registers before -* returning to userspace. -*/ - if (tsk == current && tsk->thread.regs && - MSR_TM_ACTIVE(tsk->thread.regs->msr) && - !test_thread_flag(TIF_RESTORE_TM)) { - tsk->thread.ckpt_regs.msr = tsk->thread.regs->msr; - set_thread_flag(TIF_RESTORE_TM); - } - - giveup_altivec(tsk); } - #else -#define giveup_fpu_maybe_transactional(tsk)giveup_fpu(tsk) -#define giveup_altivec_maybe_transactional(tsk)giveup_altivec(tsk) +static inline void check_if_tm_restore_required(struct task_struct *tsk) { } #endif /* CONFIG_PPC_TRANSACTIONAL_MEM */ #ifdef CONFIG_PPC_FPU @@ -135,7 +113,8 @@ void flush_fp_to_thread(struct task_struct *tsk) * to still have its FP state in the CPU registers. */ BUG_ON(tsk != current); - giveup_fpu_maybe_transactional(tsk); + check_if_tm_restore_required(tsk); + giveup_fpu(tsk); } preempt_enable(); } @@ -147,10 +126,12 @@ void enable_kernel_fp(void) { WARN_ON(preemptible()); - if (current->thread.regs && (current->thread.regs->msr & MSR_FP)) - giveup_fpu_maybe_transactional(current); - else + if (current->thread.regs && (current->thread.regs->msr & MSR_FP)) { + check_if_tm_restore_required(current); + giveup_fpu(current); + } else { giveup_fpu(NULL); /* just enables FP for kernel */ + } } EXPORT_SYMBOL(enable_kernel_fp); @@ -159,10 +140,12 @@ void enable_kernel_altivec(void) { WARN_ON(preemptible()); - if (current->thread.regs && (current->thread.regs->msr & MSR_VEC)) - giveup_altivec_maybe_transactional(current); - else + if (current->thread.regs && (current->thread.regs->msr & MSR_VEC)) { + check_if_tm_restore_required(current); + giveup_altivec(current); + } else { giveup_altivec_notask(); + } } EXPORT_SYMBOL(enable_kernel_altivec); @@ -176,7 +159,8 @@ void flush_altivec_to_thread(struct task_struct *tsk) preempt_disable(); if (tsk->thread.regs->msr & MSR_VEC) { BUG_ON(tsk != current); - giveup_altivec_maybe_transactional(tsk); + check_if_tm_restore_required(tsk); + giveup_altivec(tsk); } preempt_enable(); } @@ -198,8 +182,9 @@ EXPORT_SYMBOL(enable_kernel_vsx); void giveup_vsx(struct task_struct *tsk) { - giveup_fpu_maybe_transactional(tsk); - giveup_altivec_maybe_transactional(tsk); + check_if_tm_restore_required(tsk); + giveup_fpu(tsk); + giveup_altivec(tsk); __giveup_vsx(tsk); } EXPORT_SYMBOL(giveup_vsx); -- 2.5.0 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH 07/19] powerpc: Create mtmsrd_isync()
mtmsrd_isync() will do an mtmsrd followed by an isync on older processors. On newer processors we avoid the isync via a feature fixup. Signed-off-by: Anton Blanchard --- arch/powerpc/include/asm/reg.h | 8 arch/powerpc/kernel/process.c | 30 ++ 2 files changed, 30 insertions(+), 8 deletions(-) diff --git a/arch/powerpc/include/asm/reg.h b/arch/powerpc/include/asm/reg.h index a908ada..987dac0 100644 --- a/arch/powerpc/include/asm/reg.h +++ b/arch/powerpc/include/asm/reg.h @@ -1193,12 +1193,20 @@ #define __mtmsrd(v, l) asm volatile("mtmsrd %0," __stringify(l) \ : : "r" (v) : "memory") #define mtmsr(v) __mtmsrd((v), 0) +#define __MTMSR"mtmsrd" #else #define mtmsr(v) asm volatile("mtmsr %0" : \ : "r" ((unsigned long)(v)) \ : "memory") +#define __MTMSR"mtmsr" #endif +static inline void mtmsr_isync(unsigned long val) +{ + asm volatile(__MTMSR " %0; " ASM_FTR_IFCLR("isync", "nop", %1) : : + "r" (val), "i" (CPU_FTR_ARCH_206) : "memory"); +} + #define mfspr(rn) ({unsigned long rval; \ asm volatile("mfspr %0," __stringify(rn) \ : "=r" (rval)); rval;}) diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c index ef64219..5bf8ec2 100644 --- a/arch/powerpc/kernel/process.c +++ b/arch/powerpc/kernel/process.c @@ -130,7 +130,10 @@ void enable_kernel_fp(void) check_if_tm_restore_required(current); giveup_fpu(current); } else { - giveup_fpu(NULL); /* just enables FP for kernel */ + u64 oldmsr = mfmsr(); + + if (!(oldmsr & MSR_FP)) + mtmsr_isync(oldmsr | MSR_FP); } } EXPORT_SYMBOL(enable_kernel_fp); @@ -144,7 +147,10 @@ void enable_kernel_altivec(void) check_if_tm_restore_required(current); giveup_altivec(current); } else { - giveup_altivec_notask(); + u64 oldmsr = mfmsr(); + + if (!(oldmsr & MSR_VEC)) + mtmsr_isync(oldmsr | MSR_VEC); } } EXPORT_SYMBOL(enable_kernel_altivec); @@ -173,10 +179,14 @@ void enable_kernel_vsx(void) { WARN_ON(preemptible()); - if (current->thread.regs && (current->thread.regs->msr & MSR_VSX)) + if (current->thread.regs && (current->thread.regs->msr & MSR_VSX)) { giveup_vsx(current); - else - giveup_vsx(NULL); /* just enable vsx for kernel - force */ + } else { + u64 oldmsr = mfmsr(); + + if (!(oldmsr & MSR_VSX)) + mtmsr_isync(oldmsr | MSR_VSX); + } } EXPORT_SYMBOL(enable_kernel_vsx); @@ -209,10 +219,14 @@ void enable_kernel_spe(void) { WARN_ON(preemptible()); - if (current->thread.regs && (current->thread.regs->msr & MSR_SPE)) + if (current->thread.regs && (current->thread.regs->msr & MSR_SPE)) { giveup_spe(current); - else - giveup_spe(NULL); /* just enable SPE for kernel - force */ + } else { + u64 oldmsr = mfmsr(); + + if (!(oldmsr & MSR_SPE)) + mtmsr_isync(oldmsr | MSR_SPE); + } } EXPORT_SYMBOL(enable_kernel_spe); -- 2.5.0 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH 08/19] powerpc: Remove NULL task struct pointer checks in FP and vector code
We used to allow giveup_*() to be called with a NULL task struct pointer. Now those cases are handled in the caller we can remove the checks. We can also remove giveup_altivec_notask() which is also unused. Signed-off-by: Anton Blanchard --- arch/powerpc/include/asm/switch_to.h | 1 - arch/powerpc/kernel/fpu.S| 2 -- arch/powerpc/kernel/head_fsl_booke.S | 2 -- arch/powerpc/kernel/vector.S | 14 -- 4 files changed, 19 deletions(-) diff --git a/arch/powerpc/include/asm/switch_to.h b/arch/powerpc/include/asm/switch_to.h index bd1d933..042aaf0 100644 --- a/arch/powerpc/include/asm/switch_to.h +++ b/arch/powerpc/include/asm/switch_to.h @@ -38,7 +38,6 @@ static inline void giveup_fpu(struct task_struct *t) { } #ifdef CONFIG_ALTIVEC extern void flush_altivec_to_thread(struct task_struct *); extern void giveup_altivec(struct task_struct *); -extern void giveup_altivec_notask(void); #else static inline void flush_altivec_to_thread(struct task_struct *t) { diff --git a/arch/powerpc/kernel/fpu.S b/arch/powerpc/kernel/fpu.S index 50d2352..71bdce2 100644 --- a/arch/powerpc/kernel/fpu.S +++ b/arch/powerpc/kernel/fpu.S @@ -173,8 +173,6 @@ END_FTR_SECTION_IFSET(CPU_FTR_VSX) MTMSRD(r5) /* enable use of fpu now */ SYNC_601 isync - PPC_LCMPI 0,r3,0 - beqlr- /* if no previous owner, done */ addir3,r3,THREAD/* want THREAD of task */ PPC_LL r6,THREAD_FPSAVEAREA(r3) PPC_LL r5,PT_REGS(r3) diff --git a/arch/powerpc/kernel/head_fsl_booke.S b/arch/powerpc/kernel/head_fsl_booke.S index ec936ab..d6980bb 100644 --- a/arch/powerpc/kernel/head_fsl_booke.S +++ b/arch/powerpc/kernel/head_fsl_booke.S @@ -992,8 +992,6 @@ _GLOBAL(giveup_spe) orisr5,r5,MSR_SPE@h mtmsr r5 /* enable use of SPE now */ isync - cmpi0,r3,0 - beqlr- /* if no previous owner, done */ addir3,r3,THREAD/* want THREAD of task */ lwz r5,PT_REGS(r3) cmpi0,r5,0 diff --git a/arch/powerpc/kernel/vector.S b/arch/powerpc/kernel/vector.S index 1757c0c..b31528c 100644 --- a/arch/powerpc/kernel/vector.S +++ b/arch/powerpc/kernel/vector.S @@ -111,16 +111,6 @@ _GLOBAL(load_up_altivec) /* restore registers and return */ blr -_GLOBAL(giveup_altivec_notask) - mfmsr r3 - andis. r4,r3,MSR_VEC@h - bnelr /* Already enabled? */ - orisr3,r3,MSR_VEC@h - SYNC - MTMSRD(r3) /* enable use of VMX now */ - isync - blr - /* * giveup_altivec(tsk) * Disable VMX for the task given as the argument, @@ -133,8 +123,6 @@ _GLOBAL(giveup_altivec) SYNC MTMSRD(r5) /* enable use of VMX now */ isync - PPC_LCMPI 0,r3,0 - beqlr /* if no previous owner, done */ addir3,r3,THREAD/* want THREAD of task */ PPC_LL r7,THREAD_VRSAVEAREA(r3) PPC_LL r5,PT_REGS(r3) @@ -203,8 +191,6 @@ _GLOBAL(__giveup_vsx) mtmsrd r5 /* enable use of VSX now */ isync - cmpdi 0,r3,0 - beqlr- /* if no previous owner, done */ addir3,r3,THREAD/* want THREAD of task */ ld r5,PT_REGS(r3) cmpdi 0,r5,0 -- 2.5.0 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH 09/19] powerpc: Move part of giveup_fpu,altivec,spe into c
Move the MSR modification into new c functions. Removing it from the low level functions will allow us to avoid costly MSR writes by batching them up. Move the check_if_tm_restore_required() check into these new functions. Signed-off-by: Anton Blanchard --- arch/powerpc/include/asm/switch_to.h | 12 - arch/powerpc/kernel/fpu.S| 16 ++- arch/powerpc/kernel/head_fsl_booke.S | 8 ++ arch/powerpc/kernel/ppc_ksyms.c | 6 - arch/powerpc/kernel/process.c| 52 +--- arch/powerpc/kernel/vector.S | 10 ++- 6 files changed, 60 insertions(+), 44 deletions(-) diff --git a/arch/powerpc/include/asm/switch_to.h b/arch/powerpc/include/asm/switch_to.h index 042aaf0..6bcfb89 100644 --- a/arch/powerpc/include/asm/switch_to.h +++ b/arch/powerpc/include/asm/switch_to.h @@ -30,21 +30,21 @@ extern void switch_booke_debug_regs(struct debug_reg *new_debug); #ifdef CONFIG_PPC_FPU extern void flush_fp_to_thread(struct task_struct *); extern void giveup_fpu(struct task_struct *); +extern void __giveup_fpu(struct task_struct *); #else static inline void flush_fp_to_thread(struct task_struct *t) { } static inline void giveup_fpu(struct task_struct *t) { } +static inline void __giveup_fpu(struct task_struct *t) { } #endif #ifdef CONFIG_ALTIVEC extern void flush_altivec_to_thread(struct task_struct *); extern void giveup_altivec(struct task_struct *); +extern void __giveup_altivec(struct task_struct *); #else -static inline void flush_altivec_to_thread(struct task_struct *t) -{ -} -static inline void giveup_altivec(struct task_struct *t) -{ -} +static inline void flush_altivec_to_thread(struct task_struct *t) { } +static inline void giveup_altivec(struct task_struct *t) { } +static inline void __giveup_altivec(struct task_struct *t) { } #endif #ifdef CONFIG_VSX diff --git a/arch/powerpc/kernel/fpu.S b/arch/powerpc/kernel/fpu.S index 71bdce2..431ab57 100644 --- a/arch/powerpc/kernel/fpu.S +++ b/arch/powerpc/kernel/fpu.S @@ -155,24 +155,12 @@ END_FTR_SECTION_IFSET(CPU_FTR_VSX) blr /* - * giveup_fpu(tsk) + * __giveup_fpu(tsk) * Disable FP for the task given as the argument, * and save the floating-point registers in its thread_struct. * Enables the FPU for use in the kernel on return. */ -_GLOBAL(giveup_fpu) - mfmsr r5 - ori r5,r5,MSR_FP -#ifdef CONFIG_VSX -BEGIN_FTR_SECTION - orisr5,r5,MSR_VSX@h -END_FTR_SECTION_IFSET(CPU_FTR_VSX) -#endif - SYNC_601 - ISYNC_601 - MTMSRD(r5) /* enable use of fpu now */ - SYNC_601 - isync +_GLOBAL(__giveup_fpu) addir3,r3,THREAD/* want THREAD of task */ PPC_LL r6,THREAD_FPSAVEAREA(r3) PPC_LL r5,PT_REGS(r3) diff --git a/arch/powerpc/kernel/head_fsl_booke.S b/arch/powerpc/kernel/head_fsl_booke.S index d6980bb..f705171 100644 --- a/arch/powerpc/kernel/head_fsl_booke.S +++ b/arch/powerpc/kernel/head_fsl_booke.S @@ -984,14 +984,10 @@ _GLOBAL(__setup_ehv_ivors) #ifdef CONFIG_SPE /* - * extern void giveup_spe(struct task_struct *prev) + * extern void __giveup_spe(struct task_struct *prev) * */ -_GLOBAL(giveup_spe) - mfmsr r5 - orisr5,r5,MSR_SPE@h - mtmsr r5 /* enable use of SPE now */ - isync +_GLOBAL(__giveup_spe) addir3,r3,THREAD/* want THREAD of task */ lwz r5,PT_REGS(r3) cmpi0,r5,0 diff --git a/arch/powerpc/kernel/ppc_ksyms.c b/arch/powerpc/kernel/ppc_ksyms.c index 202963e..41e1607 100644 --- a/arch/powerpc/kernel/ppc_ksyms.c +++ b/arch/powerpc/kernel/ppc_ksyms.c @@ -19,13 +19,11 @@ EXPORT_SYMBOL(_mcount); #endif #ifdef CONFIG_PPC_FPU -EXPORT_SYMBOL(giveup_fpu); EXPORT_SYMBOL(load_fp_state); EXPORT_SYMBOL(store_fp_state); #endif #ifdef CONFIG_ALTIVEC -EXPORT_SYMBOL(giveup_altivec); EXPORT_SYMBOL(load_vr_state); EXPORT_SYMBOL(store_vr_state); #endif @@ -34,10 +32,6 @@ EXPORT_SYMBOL(store_vr_state); EXPORT_SYMBOL_GPL(__giveup_vsx); #endif -#ifdef CONFIG_SPE -EXPORT_SYMBOL(giveup_spe); -#endif - #ifdef CONFIG_EPAPR_PARAVIRT EXPORT_SYMBOL(epapr_hypercall_start); #endif diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c index 5bf8ec2..ca8b36f 100644 --- a/arch/powerpc/kernel/process.c +++ b/arch/powerpc/kernel/process.c @@ -88,6 +88,25 @@ static inline void check_if_tm_restore_required(struct task_struct *tsk) { } #endif /* CONFIG_PPC_TRANSACTIONAL_MEM */ #ifdef CONFIG_PPC_FPU +void giveup_fpu(struct task_struct *tsk) +{ + u64 oldmsr = mfmsr(); + u64 newmsr; + + check_if_tm_restore_required(tsk); + + newmsr = oldmsr | MSR_FP; +#ifdef CONFIG_VSX + if (cpu_has_feature(CPU_FTR_VSX)) + newmsr |= MSR_VSX; +#endif + if (oldmsr != newmsr) + mtmsr_isync(newmsr); + + __giveup_fpu(tsk); +} +EXPORT_SYMBOL(giveup_fpu); + /* * Make sure the floating-
[PATCH 10/19] powerpc: Move part of giveup_vsx into c
Move the MSR modification into c. Removing it from the assembly function will allow us to avoid costly MSR writes by batching them up. Check the FP and VMX bits before calling the relevant giveup_*() function. This makes giveup_vsx() and flush_vsx_to_thread() perform more like their sister functions, and allows us to use flush_vsx_to_thread() in the signal code. Move the check_if_tm_restore_required() check in. Signed-off-by: Anton Blanchard --- arch/powerpc/kernel/process.c | 28 +++- arch/powerpc/kernel/signal_32.c | 4 ++-- arch/powerpc/kernel/signal_64.c | 4 ++-- arch/powerpc/kernel/vector.S| 6 -- 4 files changed, 23 insertions(+), 19 deletions(-) diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c index ca8b36f..c39aa5a 100644 --- a/arch/powerpc/kernel/process.c +++ b/arch/powerpc/kernel/process.c @@ -205,6 +205,25 @@ EXPORT_SYMBOL_GPL(flush_altivec_to_thread); #endif /* CONFIG_ALTIVEC */ #ifdef CONFIG_VSX +void giveup_vsx(struct task_struct *tsk) +{ + u64 oldmsr = mfmsr(); + u64 newmsr; + + check_if_tm_restore_required(tsk); + + newmsr = oldmsr | (MSR_FP|MSR_VEC|MSR_VSX); + if (oldmsr != newmsr) + mtmsr_isync(newmsr); + + if (tsk->thread.regs->msr & MSR_FP) + __giveup_fpu(tsk); + if (tsk->thread.regs->msr & MSR_VEC) + __giveup_altivec(tsk); + __giveup_vsx(tsk); +} +EXPORT_SYMBOL(giveup_vsx); + void enable_kernel_vsx(void) { WARN_ON(preemptible()); @@ -220,15 +239,6 @@ void enable_kernel_vsx(void) } EXPORT_SYMBOL(enable_kernel_vsx); -void giveup_vsx(struct task_struct *tsk) -{ - check_if_tm_restore_required(tsk); - giveup_fpu(tsk); - giveup_altivec(tsk); - __giveup_vsx(tsk); -} -EXPORT_SYMBOL(giveup_vsx); - void flush_vsx_to_thread(struct task_struct *tsk) { if (tsk->thread.regs) { diff --git a/arch/powerpc/kernel/signal_32.c b/arch/powerpc/kernel/signal_32.c index 3cd7a32..4022cbb 100644 --- a/arch/powerpc/kernel/signal_32.c +++ b/arch/powerpc/kernel/signal_32.c @@ -458,7 +458,7 @@ static int save_user_regs(struct pt_regs *regs, struct mcontext __user *frame, * contains valid data */ if (current->thread.used_vsr && ctx_has_vsx_region) { - __giveup_vsx(current); + flush_vsx_to_thread(current); if (copy_vsx_to_user(&frame->mc_vsregs, current)) return 1; msr |= MSR_VSX; @@ -606,7 +606,7 @@ static int save_tm_user_regs(struct pt_regs *regs, * contains valid data */ if (current->thread.used_vsr) { - __giveup_vsx(current); + flush_vsx_to_thread(current); if (copy_vsx_to_user(&frame->mc_vsregs, current)) return 1; if (msr & MSR_VSX) { diff --git a/arch/powerpc/kernel/signal_64.c b/arch/powerpc/kernel/signal_64.c index 6f2b555..3b23399 100644 --- a/arch/powerpc/kernel/signal_64.c +++ b/arch/powerpc/kernel/signal_64.c @@ -147,7 +147,7 @@ static long setup_sigcontext(struct sigcontext __user *sc, struct pt_regs *regs, * VMX data. */ if (current->thread.used_vsr && ctx_has_vsx_region) { - __giveup_vsx(current); + flush_vsx_to_thread(current); v_regs += ELF_NVRREG; err |= copy_vsx_to_user(v_regs, current); /* set MSR_VSX in the MSR value in the frame to @@ -270,7 +270,7 @@ static long setup_tm_sigcontexts(struct sigcontext __user *sc, * VMX data. */ if (current->thread.used_vsr) { - __giveup_vsx(current); + flush_vsx_to_thread(current); v_regs += ELF_NVRREG; tm_v_regs += ELF_NVRREG; diff --git a/arch/powerpc/kernel/vector.S b/arch/powerpc/kernel/vector.S index 6e925b4..98675b0 100644 --- a/arch/powerpc/kernel/vector.S +++ b/arch/powerpc/kernel/vector.S @@ -177,14 +177,8 @@ _GLOBAL(load_up_vsx) * __giveup_vsx(tsk) * Disable VSX for the task given as the argument. * Does NOT save vsx registers. - * Enables the VSX for use in the kernel on return. */ _GLOBAL(__giveup_vsx) - mfmsr r5 - orisr5,r5,MSR_VSX@h - mtmsrd r5 /* enable use of VSX now */ - isync - addir3,r3,THREAD/* want THREAD of task */ ld r5,PT_REGS(r3) cmpdi 0,r5,0 -- 2.5.0 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH 11/19] crypto: vmx: Only call enable_kernel_vsx()
With the recent change to enable_kernel_vsx(), we no longer need to call enable_kernel_fp() and enable_kernel_altivec(). Signed-off-by: Anton Blanchard --- drivers/crypto/vmx/aes.c | 3 --- drivers/crypto/vmx/aes_cbc.c | 3 --- drivers/crypto/vmx/aes_ctr.c | 3 --- drivers/crypto/vmx/ghash.c | 8 4 files changed, 17 deletions(-) diff --git a/drivers/crypto/vmx/aes.c b/drivers/crypto/vmx/aes.c index 263af70..20539fb 100644 --- a/drivers/crypto/vmx/aes.c +++ b/drivers/crypto/vmx/aes.c @@ -83,7 +83,6 @@ static int p8_aes_setkey(struct crypto_tfm *tfm, const u8 *key, preempt_disable(); pagefault_disable(); - enable_kernel_altivec(); enable_kernel_vsx(); ret = aes_p8_set_encrypt_key(key, keylen * 8, &ctx->enc_key); ret += aes_p8_set_decrypt_key(key, keylen * 8, &ctx->dec_key); @@ -103,7 +102,6 @@ static void p8_aes_encrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src) } else { preempt_disable(); pagefault_disable(); - enable_kernel_altivec(); enable_kernel_vsx(); aes_p8_encrypt(src, dst, &ctx->enc_key); pagefault_enable(); @@ -120,7 +118,6 @@ static void p8_aes_decrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src) } else { preempt_disable(); pagefault_disable(); - enable_kernel_altivec(); enable_kernel_vsx(); aes_p8_decrypt(src, dst, &ctx->dec_key); pagefault_enable(); diff --git a/drivers/crypto/vmx/aes_cbc.c b/drivers/crypto/vmx/aes_cbc.c index 0b8fe2e..8847b92 100644 --- a/drivers/crypto/vmx/aes_cbc.c +++ b/drivers/crypto/vmx/aes_cbc.c @@ -84,7 +84,6 @@ static int p8_aes_cbc_setkey(struct crypto_tfm *tfm, const u8 *key, preempt_disable(); pagefault_disable(); - enable_kernel_altivec(); enable_kernel_vsx(); ret = aes_p8_set_encrypt_key(key, keylen * 8, &ctx->enc_key); ret += aes_p8_set_decrypt_key(key, keylen * 8, &ctx->dec_key); @@ -115,7 +114,6 @@ static int p8_aes_cbc_encrypt(struct blkcipher_desc *desc, } else { preempt_disable(); pagefault_disable(); - enable_kernel_altivec(); enable_kernel_vsx(); blkcipher_walk_init(&walk, dst, src, nbytes); @@ -156,7 +154,6 @@ static int p8_aes_cbc_decrypt(struct blkcipher_desc *desc, } else { preempt_disable(); pagefault_disable(); - enable_kernel_altivec(); enable_kernel_vsx(); blkcipher_walk_init(&walk, dst, src, nbytes); diff --git a/drivers/crypto/vmx/aes_ctr.c b/drivers/crypto/vmx/aes_ctr.c index ee1306c..8095866 100644 --- a/drivers/crypto/vmx/aes_ctr.c +++ b/drivers/crypto/vmx/aes_ctr.c @@ -81,7 +81,6 @@ static int p8_aes_ctr_setkey(struct crypto_tfm *tfm, const u8 *key, struct p8_aes_ctr_ctx *ctx = crypto_tfm_ctx(tfm); pagefault_disable(); - enable_kernel_altivec(); enable_kernel_vsx(); ret = aes_p8_set_encrypt_key(key, keylen * 8, &ctx->enc_key); pagefault_enable(); @@ -100,7 +99,6 @@ static void p8_aes_ctr_final(struct p8_aes_ctr_ctx *ctx, unsigned int nbytes = walk->nbytes; pagefault_disable(); - enable_kernel_altivec(); enable_kernel_vsx(); aes_p8_encrypt(ctrblk, keystream, &ctx->enc_key); pagefault_enable(); @@ -133,7 +131,6 @@ static int p8_aes_ctr_crypt(struct blkcipher_desc *desc, ret = blkcipher_walk_virt_block(desc, &walk, AES_BLOCK_SIZE); while ((nbytes = walk.nbytes) >= AES_BLOCK_SIZE) { pagefault_disable(); - enable_kernel_altivec(); enable_kernel_vsx(); aes_p8_ctr32_encrypt_blocks(walk.src.virt.addr, walk.dst.virt.addr, diff --git a/drivers/crypto/vmx/ghash.c b/drivers/crypto/vmx/ghash.c index 2183a2e..1f4586c 100644 --- a/drivers/crypto/vmx/ghash.c +++ b/drivers/crypto/vmx/ghash.c @@ -118,9 +118,7 @@ static int p8_ghash_setkey(struct crypto_shash *tfm, const u8 *key, preempt_disable(); pagefault_disable(); - enable_kernel_altivec(); enable_kernel_vsx(); - enable_kernel_fp(); gcm_init_p8(ctx->htable, (const u64 *) key); pagefault_enable(); preempt_enable(); @@ -149,9 +147,7 @@ static int p8_ghash_update(struct shash_desc *desc, GHASH_DIGEST_SIZE - dctx->bytes); preempt_disable(); pagefault_disable(); - enable_kernel_altivec(); enable_kernel_vsx(); - enable_kernel_fp(); gcm_ghash_p8(dctx->shash, ctx->htable, dctx->buff
[PATCH 12/19] powerpc: Create msr_check_and_{set,clear}()
Create helper functions to set and clear MSR bits after first checking if they are already set. Grouping them will make it easy to avoid the MSR writes in a subsequent optimisation. Signed-off-by: Anton Blanchard --- arch/powerpc/kernel/process.c | 107 -- 1 file changed, 52 insertions(+), 55 deletions(-) diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c index c39aa5a..5f244d0 100644 --- a/arch/powerpc/kernel/process.c +++ b/arch/powerpc/kernel/process.c @@ -87,23 +87,46 @@ static void check_if_tm_restore_required(struct task_struct *tsk) static inline void check_if_tm_restore_required(struct task_struct *tsk) { } #endif /* CONFIG_PPC_TRANSACTIONAL_MEM */ -#ifdef CONFIG_PPC_FPU -void giveup_fpu(struct task_struct *tsk) +static void msr_check_and_set(unsigned long bits) { - u64 oldmsr = mfmsr(); - u64 newmsr; + unsigned long oldmsr = mfmsr(); + unsigned long newmsr; - check_if_tm_restore_required(tsk); + newmsr = oldmsr | bits; - newmsr = oldmsr | MSR_FP; #ifdef CONFIG_VSX - if (cpu_has_feature(CPU_FTR_VSX)) + if (cpu_has_feature(CPU_FTR_VSX) && (bits & MSR_FP)) newmsr |= MSR_VSX; #endif + if (oldmsr != newmsr) mtmsr_isync(newmsr); +} + +static void msr_check_and_clear(unsigned long bits) +{ + unsigned long oldmsr = mfmsr(); + unsigned long newmsr; + + newmsr = oldmsr & ~bits; + +#ifdef CONFIG_VSX + if (cpu_has_feature(CPU_FTR_VSX) && (bits & MSR_FP)) + newmsr &= ~MSR_VSX; +#endif + if (oldmsr != newmsr) + mtmsr_isync(newmsr); +} + +#ifdef CONFIG_PPC_FPU +void giveup_fpu(struct task_struct *tsk) +{ + check_if_tm_restore_required(tsk); + + msr_check_and_set(MSR_FP); __giveup_fpu(tsk); + msr_check_and_clear(MSR_FP); } EXPORT_SYMBOL(giveup_fpu); @@ -144,30 +167,21 @@ void enable_kernel_fp(void) { WARN_ON(preemptible()); - if (current->thread.regs && (current->thread.regs->msr & MSR_FP)) { - giveup_fpu(current); - } else { - u64 oldmsr = mfmsr(); + msr_check_and_set(MSR_FP); - if (!(oldmsr & MSR_FP)) - mtmsr_isync(oldmsr | MSR_FP); - } + if (current->thread.regs && (current->thread.regs->msr & MSR_FP)) + __giveup_fpu(current); } EXPORT_SYMBOL(enable_kernel_fp); #ifdef CONFIG_ALTIVEC void giveup_altivec(struct task_struct *tsk) { - u64 oldmsr = mfmsr(); - u64 newmsr; - check_if_tm_restore_required(tsk); - newmsr = oldmsr | MSR_VEC; - if (oldmsr != newmsr) - mtmsr_isync(newmsr); - + msr_check_and_set(MSR_VEC); __giveup_altivec(tsk); + msr_check_and_clear(MSR_VEC); } EXPORT_SYMBOL(giveup_altivec); @@ -175,14 +189,10 @@ void enable_kernel_altivec(void) { WARN_ON(preemptible()); - if (current->thread.regs && (current->thread.regs->msr & MSR_VEC)) { - giveup_altivec(current); - } else { - u64 oldmsr = mfmsr(); + msr_check_and_set(MSR_VEC); - if (!(oldmsr & MSR_VEC)) - mtmsr_isync(oldmsr | MSR_VEC); - } + if (current->thread.regs && (current->thread.regs->msr & MSR_VEC)) + __giveup_altivec(current); } EXPORT_SYMBOL(enable_kernel_altivec); @@ -207,20 +217,15 @@ EXPORT_SYMBOL_GPL(flush_altivec_to_thread); #ifdef CONFIG_VSX void giveup_vsx(struct task_struct *tsk) { - u64 oldmsr = mfmsr(); - u64 newmsr; - check_if_tm_restore_required(tsk); - newmsr = oldmsr | (MSR_FP|MSR_VEC|MSR_VSX); - if (oldmsr != newmsr) - mtmsr_isync(newmsr); - + msr_check_and_set(MSR_FP|MSR_VEC|MSR_VSX); if (tsk->thread.regs->msr & MSR_FP) __giveup_fpu(tsk); if (tsk->thread.regs->msr & MSR_VEC) __giveup_altivec(tsk); __giveup_vsx(tsk); + msr_check_and_clear(MSR_FP|MSR_VEC|MSR_VSX); } EXPORT_SYMBOL(giveup_vsx); @@ -228,13 +233,14 @@ void enable_kernel_vsx(void) { WARN_ON(preemptible()); - if (current->thread.regs && (current->thread.regs->msr & MSR_VSX)) { - giveup_vsx(current); - } else { - u64 oldmsr = mfmsr(); + msr_check_and_set(MSR_FP|MSR_VEC|MSR_VSX); - if (!(oldmsr & MSR_VSX)) - mtmsr_isync(oldmsr | MSR_VSX); + if (current->thread.regs && (current->thread.regs->msr & MSR_VSX)) { + if (current->thread.regs->msr & MSR_FP) + __giveup_fpu(current); + if (current->thread.regs->msr & MSR_VEC) + __giveup_altivec(current); + __giveup_vsx(current); } } EXPORT_SYMBOL(enable_kernel_vsx); @@ -256,16 +262,11 @@ EXPORT_SYMBOL_GPL(flush_vsx_to_thread); #ifdef CONF
[PATCH 13/19] powerpc: Create disable_kernel_{fp,altivec,vsx,spe}()
The enable_kernel_*() functions leave the relevant MSR bits enabled until we exit the kernel sometime later. Create disable versions that wrap the kernel use of FP, Altivec VSX or SPE. While we don't want to disable it normally for performance reasons (MSR writes are slow), it will be used for a debug boot option that does this and catches bad uses in other areas of the kernel. Signed-off-by: Anton Blanchard --- arch/powerpc/crypto/aes-spe-glue.c | 1 + arch/powerpc/crypto/sha1-spe-glue.c | 1 + arch/powerpc/crypto/sha256-spe-glue.c| 1 + arch/powerpc/include/asm/switch_to.h | 5 + arch/powerpc/kernel/align.c | 2 ++ arch/powerpc/kvm/book3s_paired_singles.c | 1 + arch/powerpc/kvm/book3s_pr.c | 4 arch/powerpc/kvm/booke.c | 4 arch/powerpc/lib/vmx-helper.c| 2 ++ arch/powerpc/lib/xor_vmx.c | 4 drivers/crypto/vmx/aes.c | 3 +++ drivers/crypto/vmx/aes_cbc.c | 3 +++ drivers/crypto/vmx/aes_ctr.c | 3 +++ drivers/crypto/vmx/ghash.c | 4 lib/raid6/altivec.uc | 1 + 15 files changed, 39 insertions(+) diff --git a/arch/powerpc/crypto/aes-spe-glue.c b/arch/powerpc/crypto/aes-spe-glue.c index bd5e63f..93ee046 100644 --- a/arch/powerpc/crypto/aes-spe-glue.c +++ b/arch/powerpc/crypto/aes-spe-glue.c @@ -85,6 +85,7 @@ static void spe_begin(void) static void spe_end(void) { + disable_kernel_spe(); /* reenable preemption */ preempt_enable(); } diff --git a/arch/powerpc/crypto/sha1-spe-glue.c b/arch/powerpc/crypto/sha1-spe-glue.c index 3e1d222..f9ebc38 100644 --- a/arch/powerpc/crypto/sha1-spe-glue.c +++ b/arch/powerpc/crypto/sha1-spe-glue.c @@ -46,6 +46,7 @@ static void spe_begin(void) static void spe_end(void) { + disable_kernel_spe(); /* reenable preemption */ preempt_enable(); } diff --git a/arch/powerpc/crypto/sha256-spe-glue.c b/arch/powerpc/crypto/sha256-spe-glue.c index f4a616f..718a079 100644 --- a/arch/powerpc/crypto/sha256-spe-glue.c +++ b/arch/powerpc/crypto/sha256-spe-glue.c @@ -47,6 +47,7 @@ static void spe_begin(void) static void spe_end(void) { + disable_kernel_spe(); /* reenable preemption */ preempt_enable(); } diff --git a/arch/powerpc/include/asm/switch_to.h b/arch/powerpc/include/asm/switch_to.h index 6bcfb89..dbc4caa 100644 --- a/arch/powerpc/include/asm/switch_to.h +++ b/arch/powerpc/include/asm/switch_to.h @@ -27,6 +27,11 @@ extern void giveup_spe(struct task_struct *); extern void load_up_spe(struct task_struct *); extern void switch_booke_debug_regs(struct debug_reg *new_debug); +static inline void disable_kernel_fp(void) { } +static inline void disable_kernel_altivec(void) { } +static inline void disable_kernel_spe(void) { } +static inline void disable_kernel_vsx(void) { } + #ifdef CONFIG_PPC_FPU extern void flush_fp_to_thread(struct task_struct *); extern void giveup_fpu(struct task_struct *); diff --git a/arch/powerpc/kernel/align.c b/arch/powerpc/kernel/align.c index 86150fb..8e7cb8e 100644 --- a/arch/powerpc/kernel/align.c +++ b/arch/powerpc/kernel/align.c @@ -960,6 +960,7 @@ int fix_alignment(struct pt_regs *regs) preempt_disable(); enable_kernel_fp(); cvt_df(&data.dd, (float *)&data.x32.low32); + disable_kernel_fp(); preempt_enable(); #else return 0; @@ -1000,6 +1001,7 @@ int fix_alignment(struct pt_regs *regs) preempt_disable(); enable_kernel_fp(); cvt_fd((float *)&data.x32.low32, &data.dd); + disable_kernel_fp(); preempt_enable(); #else return 0; diff --git a/arch/powerpc/kvm/book3s_paired_singles.c b/arch/powerpc/kvm/book3s_paired_singles.c index a759d9a..eab96cf 100644 --- a/arch/powerpc/kvm/book3s_paired_singles.c +++ b/arch/powerpc/kvm/book3s_paired_singles.c @@ -1265,6 +1265,7 @@ int kvmppc_emulate_paired_single(struct kvm_run *run, struct kvm_vcpu *vcpu) if (rcomp) kvmppc_set_cr(vcpu, cr); + disable_kernel_fp(); preempt_enable(); return emulated; diff --git a/arch/powerpc/kvm/book3s_pr.c b/arch/powerpc/kvm/book3s_pr.c index 64891b0..49f5dad 100644 --- a/arch/powerpc/kvm/book3s_pr.c +++ b/arch/powerpc/kvm/book3s_pr.c @@ -751,6 +751,7 @@ static int kvmppc_handle_ext(struct kvm_vcpu *vcpu, unsigned int exit_nr, preempt_disable(); enable_kernel_fp(); load_fp_state(&vcpu->arch.fp); + disable_kernel_fp(); t->fp_save_area = &vcpu->arch.fp; preempt_enable(); } @@ -760,6 +761,7 @@ static int kvmppc_handle_ext(struct kvm_vcpu *vcpu, unsigned int exit_nr, preempt_disable(); enable_kernel_altivec();
[PATCH 14/19] powerpc: Add ppc_strict_facility_enable boot option
Add a boot option that strictly manages the MSR unavailable bits. This catches kernel uses of FP/Altivec/SPE that would otherwise corrupt user state. Signed-off-by: Anton Blanchard --- Documentation/kernel-parameters.txt | 6 ++ arch/powerpc/include/asm/reg.h | 9 + arch/powerpc/include/asm/switch_to.h | 24 +++- arch/powerpc/kernel/process.c| 17 +++-- 4 files changed, 49 insertions(+), 7 deletions(-) diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt index 22a4b68..f535a02 100644 --- a/Documentation/kernel-parameters.txt +++ b/Documentation/kernel-parameters.txt @@ -2939,6 +2939,12 @@ bytes respectively. Such letter suffixes can also be entirely omitted. may be specified. Format: , + ppc_strict_facility_enable + [PPC] This option catches any kernel floating point, + Altivec, VSX and SPE outside of regions specifically + allowed (eg kernel_enable_fpu()/kernel_disable_fpu()). + There is some performance impact when enabling this. + print-fatal-signals= [KNL] debug: print fatal signals diff --git a/arch/powerpc/include/asm/reg.h b/arch/powerpc/include/asm/reg.h index 987dac0..eb2986e 100644 --- a/arch/powerpc/include/asm/reg.h +++ b/arch/powerpc/include/asm/reg.h @@ -1214,6 +1214,15 @@ static inline void mtmsr_isync(unsigned long val) : "r" ((unsigned long)(v)) \ : "memory") +extern void msr_check_and_set(unsigned long bits); +extern bool strict_msr_control; +extern void __msr_check_and_clear(unsigned long bits); +static inline void msr_check_and_clear(unsigned long bits) +{ + if (strict_msr_control) + __msr_check_and_clear(bits); +} + static inline unsigned long mfvtb (void) { #ifdef CONFIG_PPC_BOOK3S_64 diff --git a/arch/powerpc/include/asm/switch_to.h b/arch/powerpc/include/asm/switch_to.h index dbc4caa..b6a4951 100644 --- a/arch/powerpc/include/asm/switch_to.h +++ b/arch/powerpc/include/asm/switch_to.h @@ -4,6 +4,8 @@ #ifndef _ASM_POWERPC_SWITCH_TO_H #define _ASM_POWERPC_SWITCH_TO_H +#include + struct thread_struct; struct task_struct; struct pt_regs; @@ -27,15 +29,15 @@ extern void giveup_spe(struct task_struct *); extern void load_up_spe(struct task_struct *); extern void switch_booke_debug_regs(struct debug_reg *new_debug); -static inline void disable_kernel_fp(void) { } -static inline void disable_kernel_altivec(void) { } -static inline void disable_kernel_spe(void) { } -static inline void disable_kernel_vsx(void) { } - #ifdef CONFIG_PPC_FPU extern void flush_fp_to_thread(struct task_struct *); extern void giveup_fpu(struct task_struct *); extern void __giveup_fpu(struct task_struct *); +static inline void disable_kernel_fp(void) +{ + msr_check_and_clear(MSR_FP); +} + #else static inline void flush_fp_to_thread(struct task_struct *t) { } static inline void giveup_fpu(struct task_struct *t) { } @@ -46,6 +48,10 @@ static inline void __giveup_fpu(struct task_struct *t) { } extern void flush_altivec_to_thread(struct task_struct *); extern void giveup_altivec(struct task_struct *); extern void __giveup_altivec(struct task_struct *); +static inline void disable_kernel_altivec(void) +{ + msr_check_and_clear(MSR_VEC); +} #else static inline void flush_altivec_to_thread(struct task_struct *t) { } static inline void giveup_altivec(struct task_struct *t) { } @@ -54,6 +60,10 @@ static inline void __giveup_altivec(struct task_struct *t) { } #ifdef CONFIG_VSX extern void flush_vsx_to_thread(struct task_struct *); +static inline void disable_kernel_vsx(void) +{ + msr_check_and_clear(MSR_FP|MSR_VEC|MSR_VSX); +} #else static inline void flush_vsx_to_thread(struct task_struct *t) { @@ -62,6 +72,10 @@ static inline void flush_vsx_to_thread(struct task_struct *t) #ifdef CONFIG_SPE extern void flush_spe_to_thread(struct task_struct *); +static inline void disable_kernel_spe(void) +{ + msr_check_and_clear(MSR_SPE); +} #else static inline void flush_spe_to_thread(struct task_struct *t) { diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c index 5f244d0..878ea17 100644 --- a/arch/powerpc/kernel/process.c +++ b/arch/powerpc/kernel/process.c @@ -87,7 +87,19 @@ static void check_if_tm_restore_required(struct task_struct *tsk) static inline void check_if_tm_restore_required(struct task_struct *tsk) { } #endif /* CONFIG_PPC_TRANSACTIONAL_MEM */ -static void msr_check_and_set(unsigned long bits) +bool strict_msr_control; +EXPORT_SYMBOL(strict_msr_control); + +static int __init enable_strict_msr_control(char *str) +{ + strict_msr_control = true; + pr_info("Enabling strict facility control\n"); + + return 0; +} +early_param("ppc_strict_facility_
[PATCH 15/19] powerpc: Remove fp_enable() and vec_enable(), use msr_check_and_{set, clear}()
More consolidation of our MSR available bit handling. Signed-off-by: Anton Blanchard --- arch/powerpc/include/asm/processor.h | 2 -- arch/powerpc/kernel/fpu.S| 16 arch/powerpc/kernel/process.c| 6 -- arch/powerpc/kernel/vector.S | 10 -- 4 files changed, 4 insertions(+), 30 deletions(-) diff --git a/arch/powerpc/include/asm/processor.h b/arch/powerpc/include/asm/processor.h index a2e8918..ac23308 100644 --- a/arch/powerpc/include/asm/processor.h +++ b/arch/powerpc/include/asm/processor.h @@ -380,8 +380,6 @@ extern int set_endian(struct task_struct *tsk, unsigned int val); extern int get_unalign_ctl(struct task_struct *tsk, unsigned long adr); extern int set_unalign_ctl(struct task_struct *tsk, unsigned int val); -extern void fp_enable(void); -extern void vec_enable(void); extern void load_fp_state(struct thread_fp_state *fp); extern void store_fp_state(struct thread_fp_state *fp); extern void load_vr_state(struct thread_vr_state *vr); diff --git a/arch/powerpc/kernel/fpu.S b/arch/powerpc/kernel/fpu.S index 431ab57..2117eac 100644 --- a/arch/powerpc/kernel/fpu.S +++ b/arch/powerpc/kernel/fpu.S @@ -77,22 +77,6 @@ END_FTR_SECTION_IFSET(CPU_FTR_VSX) #endif /* CONFIG_PPC_TRANSACTIONAL_MEM */ /* - * Enable use of the FPU, and VSX if possible, for the caller. - */ -_GLOBAL(fp_enable) - mfmsr r3 - ori r3,r3,MSR_FP -#ifdef CONFIG_VSX -BEGIN_FTR_SECTION - orisr3,r3,MSR_VSX@h -END_FTR_SECTION_IFSET(CPU_FTR_VSX) -#endif - SYNC - MTMSRD(r3) - isync /* (not necessary for arch 2.02 and later) */ - blr - -/* * Load state from memory into FP registers including FPSCR. * Assumes the caller has enabled FP in the MSR. */ diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c index 878ea17..cf2d811 100644 --- a/arch/powerpc/kernel/process.c +++ b/arch/powerpc/kernel/process.c @@ -732,13 +732,15 @@ void restore_tm_state(struct pt_regs *regs) msr_diff = current->thread.ckpt_regs.msr & ~regs->msr; msr_diff &= MSR_FP | MSR_VEC | MSR_VSX; if (msr_diff & MSR_FP) { - fp_enable(); + msr_check_and_set(MSR_FP); load_fp_state(¤t->thread.fp_state); + msr_check_and_clear(MSR_FP); regs->msr |= current->thread.fpexc_mode; } if (msr_diff & MSR_VEC) { - vec_enable(); + msr_check_and_set(MSR_VEC); load_vr_state(¤t->thread.vr_state); + msr_check_and_clear(MSR_VEC); } regs->msr |= msr_diff; } diff --git a/arch/powerpc/kernel/vector.S b/arch/powerpc/kernel/vector.S index 98675b0..162d0f7 100644 --- a/arch/powerpc/kernel/vector.S +++ b/arch/powerpc/kernel/vector.S @@ -33,16 +33,6 @@ _GLOBAL(do_load_up_transact_altivec) #endif /* - * Enable use of VMX/Altivec for the caller. - */ -_GLOBAL(vec_enable) - mfmsr r3 - orisr3,r3,MSR_VEC@h - MTMSRD(r3) - isync - blr - -/* * Load state from memory into VMX registers including VSCR. * Assumes the caller has enabled VMX in the MSR. */ -- 2.5.0 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH 16/19] powerpc: create giveup_all()
Create a single function that gives everything up (FP, VMX, VSX, SPE). Doing this all at once means we only do one MSR write. A context switch microbenchmark using yield(): http://ozlabs.org/~anton/junkcode/context_switch2.c ./context_switch2 --test=yield --fp --altivec --vector 0 0 shows an improvement of 3% on POWER8. Signed-off-by: Anton Blanchard --- arch/powerpc/include/asm/switch_to.h | 1 + arch/powerpc/kernel/process.c| 75 arch/powerpc/kvm/book3s_pr.c | 17 +--- 3 files changed, 63 insertions(+), 30 deletions(-) diff --git a/arch/powerpc/include/asm/switch_to.h b/arch/powerpc/include/asm/switch_to.h index b6a4951..0b4a339 100644 --- a/arch/powerpc/include/asm/switch_to.h +++ b/arch/powerpc/include/asm/switch_to.h @@ -27,6 +27,7 @@ extern void giveup_vsx(struct task_struct *); extern void enable_kernel_spe(void); extern void giveup_spe(struct task_struct *); extern void load_up_spe(struct task_struct *); +extern void giveup_all(struct task_struct *); extern void switch_booke_debug_regs(struct debug_reg *new_debug); #ifdef CONFIG_PPC_FPU diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c index cf2d811..5ca416c 100644 --- a/arch/powerpc/kernel/process.c +++ b/arch/powerpc/kernel/process.c @@ -308,6 +308,64 @@ void flush_spe_to_thread(struct task_struct *tsk) } #endif /* CONFIG_SPE */ +static unsigned long msr_all_available; + +static int __init init_msr_all_available(void) +{ +#ifdef CONFIG_PPC_FPU + msr_all_available |= MSR_FP; +#endif +#ifdef CONFIG_ALTIVEC + if (cpu_has_feature(CPU_FTR_ALTIVEC)) + msr_all_available |= MSR_VEC; +#endif +#ifdef CONFIG_VSX + if (cpu_has_feature(CPU_FTR_VSX)) + msr_all_available |= MSR_VSX; +#endif +#ifdef CONFIG_SPE + if (cpu_has_feature(CPU_FTR_SPE)) + msr_all_available |= MSR_SPE; +#endif + + return 0; +} +early_initcall(init_msr_all_available); + +void giveup_all(struct task_struct *tsk) +{ + unsigned long usermsr; + + if (!tsk->thread.regs) + return; + + usermsr = tsk->thread.regs->msr; + + if ((usermsr & msr_all_available) == 0) + return; + + msr_check_and_set(msr_all_available); + +#ifdef CONFIG_PPC_FPU + if (usermsr & MSR_FP) + __giveup_fpu(tsk); +#endif +#ifdef CONFIG_ALTIVEC + if (usermsr & MSR_VEC) + __giveup_altivec(tsk); +#endif +#ifdef CONFIG_VSX + if (usermsr & MSR_VSX) + __giveup_vsx(tsk); +#endif +#ifdef CONFIG_SPE + if (usermsr & MSR_SPE) + __giveup_spe(tsk); +#endif + + msr_check_and_clear(msr_all_available); +} + #ifdef CONFIG_PPC_ADV_DEBUG_REGS void do_send_trap(struct pt_regs *regs, unsigned long address, unsigned long error_code, int signal_code, int breakpt) @@ -839,21 +897,8 @@ struct task_struct *__switch_to(struct task_struct *prev, __switch_to_tm(prev); - if (prev->thread.regs && (prev->thread.regs->msr & MSR_FP)) - giveup_fpu(prev); -#ifdef CONFIG_ALTIVEC - if (prev->thread.regs && (prev->thread.regs->msr & MSR_VEC)) - giveup_altivec(prev); -#endif /* CONFIG_ALTIVEC */ -#ifdef CONFIG_VSX - if (prev->thread.regs && (prev->thread.regs->msr & MSR_VSX)) - /* VMX and FPU registers are already save here */ - __giveup_vsx(prev); -#endif /* CONFIG_VSX */ -#ifdef CONFIG_SPE - if ((prev->thread.regs && (prev->thread.regs->msr & MSR_SPE))) - giveup_spe(prev); -#endif /* CONFIG_SPE */ + /* Save FPU, Altivec, VSX and SPE state */ + giveup_all(prev); #ifdef CONFIG_PPC_ADV_DEBUG_REGS switch_booke_debug_regs(&new->thread.debug); diff --git a/arch/powerpc/kvm/book3s_pr.c b/arch/powerpc/kvm/book3s_pr.c index 49f5dad..a78e0e6 100644 --- a/arch/powerpc/kvm/book3s_pr.c +++ b/arch/powerpc/kvm/book3s_pr.c @@ -1490,21 +1490,8 @@ static int kvmppc_vcpu_run_pr(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu) goto out; /* interrupts now hard-disabled */ - /* Save FPU state in thread_struct */ - if (current->thread.regs->msr & MSR_FP) - giveup_fpu(current); - -#ifdef CONFIG_ALTIVEC - /* Save Altivec state in thread_struct */ - if (current->thread.regs->msr & MSR_VEC) - giveup_altivec(current); -#endif - -#ifdef CONFIG_VSX - /* Save VSX state in thread_struct */ - if (current->thread.regs->msr & MSR_VSX) - __giveup_vsx(current); -#endif + /* Save FPU, Altivec and VSX state */ + giveup_all(current); /* Preload FPU if it's enabled */ if (kvmppc_get_msr(vcpu) & MSR_FP) -- 2.5.0 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH 17/19] powerpc: create flush_all_to_thread()
Create a single function that flushes everything (FP, VMX, VSX, SPE). Doing this all at once means we only do one MSR write. Signed-off-by: Anton Blanchard --- arch/powerpc/include/asm/switch_to.h | 1 + arch/powerpc/kernel/process.c| 22 ++ arch/powerpc/kvm/book3s_hv.c | 5 ++--- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/arch/powerpc/include/asm/switch_to.h b/arch/powerpc/include/asm/switch_to.h index 0b4a339..08e2d65 100644 --- a/arch/powerpc/include/asm/switch_to.h +++ b/arch/powerpc/include/asm/switch_to.h @@ -28,6 +28,7 @@ extern void enable_kernel_spe(void); extern void giveup_spe(struct task_struct *); extern void load_up_spe(struct task_struct *); extern void giveup_all(struct task_struct *); +extern void flush_all_to_thread(struct task_struct *); extern void switch_booke_debug_regs(struct debug_reg *new_debug); #ifdef CONFIG_PPC_FPU diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c index 5ca416c..875ab50 100644 --- a/arch/powerpc/kernel/process.c +++ b/arch/powerpc/kernel/process.c @@ -366,6 +366,23 @@ void giveup_all(struct task_struct *tsk) msr_check_and_clear(msr_all_available); } +void flush_all_to_thread(struct task_struct *tsk) +{ + if (tsk->thread.regs) { + preempt_disable(); + BUG_ON(tsk != current); + giveup_all(tsk); + +#ifdef CONFIG_SPE + if (tsk->thread.regs->msr & MSR_SPE) + tsk->thread.spefscr = mfspr(SPRN_SPEFSCR); +#endif + + preempt_enable(); + } +} +EXPORT_SYMBOL(flush_all_to_thread); + #ifdef CONFIG_PPC_ADV_DEBUG_REGS void do_send_trap(struct pt_regs *regs, unsigned long address, unsigned long error_code, int signal_code, int breakpt) @@ -1136,10 +1153,7 @@ release_thread(struct task_struct *t) */ int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src) { - flush_fp_to_thread(src); - flush_altivec_to_thread(src); - flush_vsx_to_thread(src); - flush_spe_to_thread(src); + flush_all_to_thread(src); /* * Flush TM state out so we can copy it. __switch_to_tm() does this * flush but it removes the checkpointed state from the current CPU and diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c index 9c26c5a..c165f4a 100644 --- a/arch/powerpc/kvm/book3s_hv.c +++ b/arch/powerpc/kvm/book3s_hv.c @@ -2700,9 +2700,8 @@ static int kvmppc_vcpu_run_hv(struct kvm_run *run, struct kvm_vcpu *vcpu) goto out; } - flush_fp_to_thread(current); - flush_altivec_to_thread(current); - flush_vsx_to_thread(current); + flush_all_to_thread(current); + vcpu->arch.wqp = &vcpu->arch.vcore->wq; vcpu->arch.pgdir = current->mm->pgd; vcpu->arch.state = KVMPPC_VCPU_BUSY_IN_HOST; -- 2.5.0 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH 18/19] powerpc: Rearrange __switch_to()
Most of __switch_to() is housekeeping, TLB batching, timekeeping etc. Move these away from the more complex and critical context switching code. Signed-off-by: Anton Blanchard --- arch/powerpc/kernel/process.c | 52 +-- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c index 875ab50..398f7bf 100644 --- a/arch/powerpc/kernel/process.c +++ b/arch/powerpc/kernel/process.c @@ -906,30 +906,6 @@ struct task_struct *__switch_to(struct task_struct *prev, WARN_ON(!irqs_disabled()); - /* -* We need to save SPRs before treclaim/trecheckpoint as these will -* change a number of them. -*/ - save_sprs(&prev->thread); - - __switch_to_tm(prev); - - /* Save FPU, Altivec, VSX and SPE state */ - giveup_all(prev); - -#ifdef CONFIG_PPC_ADV_DEBUG_REGS - switch_booke_debug_regs(&new->thread.debug); -#else -/* - * For PPC_BOOK3S_64, we use the hw-breakpoint interfaces that would - * schedule DABR - */ -#ifndef CONFIG_HAVE_HW_BREAKPOINT - if (unlikely(!hw_brk_match(this_cpu_ptr(¤t_brk), &new->thread.hw_brk))) - __set_breakpoint(&new->thread.hw_brk); -#endif /* CONFIG_HAVE_HW_BREAKPOINT */ -#endif - #ifdef CONFIG_PPC64 /* * Collect processor utilization data per process @@ -954,6 +930,30 @@ struct task_struct *__switch_to(struct task_struct *prev, } #endif /* CONFIG_PPC_BOOK3S_64 */ +#ifdef CONFIG_PPC_ADV_DEBUG_REGS + switch_booke_debug_regs(&new->thread.debug); +#else +/* + * For PPC_BOOK3S_64, we use the hw-breakpoint interfaces that would + * schedule DABR + */ +#ifndef CONFIG_HAVE_HW_BREAKPOINT + if (unlikely(!hw_brk_match(this_cpu_ptr(¤t_brk), &new->thread.hw_brk))) + __set_breakpoint(&new->thread.hw_brk); +#endif /* CONFIG_HAVE_HW_BREAKPOINT */ +#endif + + /* +* We need to save SPRs before treclaim/trecheckpoint as these will +* change a number of them. +*/ + save_sprs(&prev->thread); + + __switch_to_tm(prev); + + /* Save FPU, Altivec, VSX and SPE state */ + giveup_all(prev); + /* * We can't take a PMU exception inside _switch() since there is a * window where the kernel stack SLB and the kernel stack are out @@ -969,6 +969,8 @@ struct task_struct *__switch_to(struct task_struct *prev, old_thread = &last->thread; new_thread = ¤t->thread; + restore_sprs(old_thread, new_thread); + #ifdef CONFIG_PPC_BOOK3S_64 if (current_thread_info()->local_flags & _TLF_LAZY_MMU) { current_thread_info()->local_flags &= ~_TLF_LAZY_MMU; @@ -977,8 +979,6 @@ struct task_struct *__switch_to(struct task_struct *prev, } #endif /* CONFIG_PPC_BOOK3S_64 */ - restore_sprs(old_thread, new_thread); - return last; } -- 2.5.0 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH 19/19] powerpc: clean up asm/switch_to.h
Remove a bunch of unnecessary fallback functions and group things in a more logical way. Signed-off-by: Anton Blanchard --- arch/powerpc/include/asm/switch_to.h | 39 ++-- 1 file changed, 11 insertions(+), 28 deletions(-) diff --git a/arch/powerpc/include/asm/switch_to.h b/arch/powerpc/include/asm/switch_to.h index 08e2d65..171ce13 100644 --- a/arch/powerpc/include/asm/switch_to.h +++ b/arch/powerpc/include/asm/switch_to.h @@ -14,24 +14,18 @@ extern struct task_struct *__switch_to(struct task_struct *, struct task_struct *); #define switch_to(prev, next, last)((last) = __switch_to((prev), (next))) -struct thread_struct; extern struct task_struct *_switch(struct thread_struct *prev, struct thread_struct *next); -extern void enable_kernel_fp(void); -extern void enable_kernel_altivec(void); -extern void enable_kernel_vsx(void); +extern void switch_booke_debug_regs(struct debug_reg *new_debug); + extern int emulate_altivec(struct pt_regs *); -extern void __giveup_vsx(struct task_struct *); -extern void giveup_vsx(struct task_struct *); -extern void enable_kernel_spe(void); -extern void giveup_spe(struct task_struct *); -extern void load_up_spe(struct task_struct *); -extern void giveup_all(struct task_struct *); + extern void flush_all_to_thread(struct task_struct *); -extern void switch_booke_debug_regs(struct debug_reg *new_debug); +extern void giveup_all(struct task_struct *); #ifdef CONFIG_PPC_FPU +extern void enable_kernel_fp(void); extern void flush_fp_to_thread(struct task_struct *); extern void giveup_fpu(struct task_struct *); extern void __giveup_fpu(struct task_struct *); @@ -39,14 +33,10 @@ static inline void disable_kernel_fp(void) { msr_check_and_clear(MSR_FP); } - -#else -static inline void flush_fp_to_thread(struct task_struct *t) { } -static inline void giveup_fpu(struct task_struct *t) { } -static inline void __giveup_fpu(struct task_struct *t) { } #endif #ifdef CONFIG_ALTIVEC +extern void enable_kernel_altivec(void); extern void flush_altivec_to_thread(struct task_struct *); extern void giveup_altivec(struct task_struct *); extern void __giveup_altivec(struct task_struct *); @@ -54,34 +44,27 @@ static inline void disable_kernel_altivec(void) { msr_check_and_clear(MSR_VEC); } -#else -static inline void flush_altivec_to_thread(struct task_struct *t) { } -static inline void giveup_altivec(struct task_struct *t) { } -static inline void __giveup_altivec(struct task_struct *t) { } #endif #ifdef CONFIG_VSX +extern void enable_kernel_vsx(void); extern void flush_vsx_to_thread(struct task_struct *); +extern void giveup_vsx(struct task_struct *); +extern void __giveup_vsx(struct task_struct *); static inline void disable_kernel_vsx(void) { msr_check_and_clear(MSR_FP|MSR_VEC|MSR_VSX); } -#else -static inline void flush_vsx_to_thread(struct task_struct *t) -{ -} #endif #ifdef CONFIG_SPE +extern void enable_kernel_spe(void); extern void flush_spe_to_thread(struct task_struct *); +extern void giveup_spe(struct task_struct *); static inline void disable_kernel_spe(void) { msr_check_and_clear(MSR_SPE); } -#else -static inline void flush_spe_to_thread(struct task_struct *t) -{ -} #endif static inline void clear_task_ebb(struct task_struct *t) -- 2.5.0 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH 2/7 v2] powerpc/dma-mapping: override dma_get_page_shift
On 10/28/2015 09:27 AM, Nishanth Aravamudan wrote: On 27.10.2015 [17:02:16 +1100], Alexey Kardashevskiy wrote: On 10/24/2015 07:57 AM, Nishanth Aravamudan wrote: On Power, the kernel's page size can differ from the IOMMU's page size, so we need to override the generic implementation, which always returns the kernel's page size. Lookup the IOMMU's page size from struct iommu_table, if available. Fallback to the kernel's page size, otherwise. Signed-off-by: Nishanth Aravamudan --- arch/powerpc/include/asm/dma-mapping.h | 3 +++ arch/powerpc/kernel/dma.c | 9 + 2 files changed, 12 insertions(+) diff --git a/arch/powerpc/include/asm/dma-mapping.h b/arch/powerpc/include/asm/dma-mapping.h index 7f522c0..c5638f4 100644 --- a/arch/powerpc/include/asm/dma-mapping.h +++ b/arch/powerpc/include/asm/dma-mapping.h @@ -125,6 +125,9 @@ static inline void set_dma_offset(struct device *dev, dma_addr_t off) #define HAVE_ARCH_DMA_SET_MASK 1 extern int dma_set_mask(struct device *dev, u64 dma_mask); +#define HAVE_ARCH_DMA_GET_PAGE_SHIFT 1 +extern unsigned long dma_get_page_shift(struct device *dev); + #include extern int __dma_set_mask(struct device *dev, u64 dma_mask); diff --git a/arch/powerpc/kernel/dma.c b/arch/powerpc/kernel/dma.c index 59503ed..e805af2 100644 --- a/arch/powerpc/kernel/dma.c +++ b/arch/powerpc/kernel/dma.c @@ -335,6 +335,15 @@ int dma_set_mask(struct device *dev, u64 dma_mask) } EXPORT_SYMBOL(dma_set_mask); +unsigned long dma_get_page_shift(struct device *dev) +{ + struct iommu_table *tbl = get_iommu_table_base(dev); + if (tbl) + return tbl->it_page_shift; All PCI devices have this initialized on POWER (at least, our, IBM's POWER) so 4K will always be returned here while in the case of (get_dma_ops(dev)==&dma_direct_ops) it could actually return PAGE_SHIFT. Is 4K still preferred value to return here? Right, so the logic of my series, goes like this: a) We currently are assuming DMA_PAGE_SHIFT (conceptual constant) is PAGE_SHIFT everywhere, including Power. b) After 2/7, the Power code will return either the IOMMU table's shift value, if set, or PAGE_SHIFT (I guess this would be the case if get_dma_ops(dev) == &dma_direct_ops, as you said). That is no different than we have now, except we can return the accurate IOMMU value if available. If it is not available, then something went wrong and BUG_ON(!tbl || !tbl->it_page_shift) make more sense here than pretending that this function can ever return PAGE_SHIFT. imho. 3) After 3/7, the platform can override the generic Power get_dma_page_shift(). 4) After 4/7, pseries will return the DDW value, if available, then fallback to the IOMMU table's value. I think in the case of get_dma_ops(dev)==&dma_direct_ops, the only way that can happen is if we are using DDW, right? This is for pseries guests; for the powernv host it is a "bypass" mode which does 64bit direct DMA mapping and there is no additional window for that (i.e. DIRECT64_PROPNAME, etc). -- Alexey ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH V10 01/12] PCI/IOV: Rename and export virtfn_add/virtfn_remove
On Tue, Oct 27, 2015 at 06:06:54PM -0500, Bjorn Helgaas wrote: >On Mon, Oct 26, 2015 at 11:15:51AM +0800, Wei Yang wrote: >> During EEH recovery, hotplug is applied to the devices which don't >> have drivers or their drivers don't support EEH. However, the hotplug, >> which was implemented based on PCI bus, can't be applied to VF directly. >> >> The patch renames virtn_{add,remove}() and exports them so that they >> can be used in PCI hotplug during EEH recovery. > >Trivial, but write this as an imperative sentence, e.g., > > Rename virtn_{add,remove}() and export them so they > can be used in PCI hotplug during EEH recovery. > >"The patch" doesn't add any useful information; it's obvious that the >changelog applied to this patch. Yep, thanks, will change in next version. > >This comment also applies to at least the next patch. > >Bjorn -- Richard Yang Help you, Help me ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH V10 03/12] powerpc/pci: Cache VF index in pci_dn
On Wed, Oct 28, 2015 at 09:04:34AM +1100, Daniel Axtens wrote: >Hi, > >> >> diff --git a/arch/powerpc/include/asm/pci-bridge.h >> b/arch/powerpc/include/asm/pci-bridge.h >> index b3a226b..3d7e537 100644 >> --- a/arch/powerpc/include/asm/pci-bridge.h >> +++ b/arch/powerpc/include/asm/pci-bridge.h >> @@ -210,6 +210,7 @@ struct pci_dn { >> #define IODA_INVALID_PE (-1) >> #ifdef CONFIG_PPC_POWERNV >> int pe_number; >> +int vf_index; /* VF index in the PF */ > >Here, vf_index is inside CONFIG_PPC_POWERNV... > >> #ifdef CONFIG_PCI_IOV >> u16 vfs_expanded; /* number of VFs IOV BAR expanded */ >> u16 num_vfs;/* number of VFs enabled*/ >> diff --git a/arch/powerpc/kernel/pci_dn.c b/arch/powerpc/kernel/pci_dn.c >> index b3b4df9..f771130 100644 >> --- a/arch/powerpc/kernel/pci_dn.c >> +++ b/arch/powerpc/kernel/pci_dn.c >> @@ -139,6 +139,7 @@ struct pci_dn *pci_get_pdn(struct pci_dev *pdev) >> #ifdef CONFIG_PCI_IOV >> static struct pci_dn *add_one_dev_pci_data(struct pci_dn *parent, >> struct pci_dev *pdev, >> + int vf_index, >> int busno, int devfn) >> { >> struct pci_dn *pdn; >> @@ -157,6 +158,7 @@ static struct pci_dn *add_one_dev_pci_data(struct pci_dn >> *parent, >> pdn->parent = parent; >> pdn->busno = busno; >> pdn->devfn = devfn; >> +pdn->vf_index = vf_index; >> #ifdef CONFIG_PPC_POWERNV >> pdn->pe_number = IODA_INVALID_PE; >... but here, vf_index is outside CONFIG_PPC_POWERNV. > Hey, Daniel Glad to see you comment. You are right, to be consistent this should be put into the CONFIG_PPC_POWERNV. Will change it next version. >Otherwise, the patch looks fine to me. > >I'm still trying to get my head around SR-IOV generally - once I do I >will add any more comments I have or add a reviewed-by. > >Regards, >Daniel -- Richard Yang Help you, Help me ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH V10 00/12] VF EEH on Power8
On Tue, Oct 27, 2015 at 06:11:13PM -0500, Bjorn Helgaas wrote: >On Mon, Oct 26, 2015 at 11:15:50AM +0800, Wei Yang wrote: >> This patchset enables EEH on SRIOV VFs. The general idea is to create proper >> VF edev and VF PE and handle them properly. >> ... > >> Gavin Shan (1): >> powerpc/eeh: Don't block PCI config on resetting VF PE >> >> Wei Yang (11): >> PCI/IOV: Rename and export virtfn_add/virtfn_remove >> PCI: Add pcibios_bus_add_device() weak function >> powerpc/pci: Cache VF index in pci_dn >> powerpc/pci: Remove VFs prior to PF >> powerpc/eeh: Cache only BARs, not windows or IOV BARs >> powerpc/powernv: EEH device for VF >> powerpc/eeh: Create PE for VFs >> powerpc/powernv: Support EEH reset for VF PE >> powerpc/powernv: Support PCI config restore for VFs >> powerpc/eeh: Support error recovery for VF PE >> powerpc/eeh: Handle hot removed VF when PF is EEH aware >> >> arch/powerpc/include/asm/eeh.h | 10 ++ >> arch/powerpc/include/asm/pci-bridge.h| 2 + >> arch/powerpc/kernel/eeh.c| 17 ++- >> arch/powerpc/kernel/eeh_cache.c | 6 +- >> arch/powerpc/kernel/eeh_dev.c| 1 + >> arch/powerpc/kernel/eeh_driver.c | 130 >> arch/powerpc/kernel/eeh_pe.c | 13 +- >> arch/powerpc/kernel/pci-hotplug.c| 2 +- >> arch/powerpc/kernel/pci_dn.c | 16 +- >> arch/powerpc/platforms/powernv/eeh-powernv.c | 220 >> ++- >> arch/powerpc/platforms/powernv/pci.c | 18 +++ >> drivers/pci/bus.c| 3 + >> drivers/pci/iov.c| 10 +- >> include/linux/pci.h | 8 + >> 14 files changed, 408 insertions(+), 48 deletions(-) > >This really only affects powerpc, so I assume this series will go through >the powerpc tree. Let me know if you want me to do anything else. > Yep, as we talked about it, this will be merged in powerpc tree. Have a good day :-) >Bjorn -- Richard Yang Help you, Help me ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH 0/5 v3] Fix NVMe driver support on Power with 32-bit DMA
On 27.10.2015 [17:53:22 -0700], David Miller wrote: > From: Nishanth Aravamudan > Date: Tue, 27 Oct 2015 15:20:10 -0700 > > > Well, looks like I should spin up a v4 anyways for the powerpc changes. > > So, to make sure I understand your point, should I make the generic > > dma_get_page_shift a compile-error kind of thing? It will only fail on > > architectures that actually build the NVME driver (as the only caller). > > But I'm not sure how exactly to achieve that, if you could give a bit > > more detail I'd appreciate it! > > Yes, I am basically suggesting to simply not provide a default at all. For my own edification -- what is the way that gets resolved? I guess I mean it seems like linux-next would cease to compile because of my new series. Would my patches just get kicked out of -next for introducing that (or even via the 0-day notifications), or should I put something into the commit message indicating it is an API introduction? Sorry for the tentativeness, I have not introduce a cross-architecture API like this before. Thanks, Nish > ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH 2/7 v2] powerpc/dma-mapping: override dma_get_page_shift
On 28.10.2015 [12:00:20 +1100], Alexey Kardashevskiy wrote: > On 10/28/2015 09:27 AM, Nishanth Aravamudan wrote: > >On 27.10.2015 [17:02:16 +1100], Alexey Kardashevskiy wrote: > >>On 10/24/2015 07:57 AM, Nishanth Aravamudan wrote: > >>>On Power, the kernel's page size can differ from the IOMMU's page size, > >>>so we need to override the generic implementation, which always returns > >>>the kernel's page size. Lookup the IOMMU's page size from struct > >>>iommu_table, if available. Fallback to the kernel's page size, > >>>otherwise. > >>> > >>>Signed-off-by: Nishanth Aravamudan > >>>--- > >>> arch/powerpc/include/asm/dma-mapping.h | 3 +++ > >>> arch/powerpc/kernel/dma.c | 9 + > >>> 2 files changed, 12 insertions(+) > >>> > >>>diff --git a/arch/powerpc/include/asm/dma-mapping.h > >>>b/arch/powerpc/include/asm/dma-mapping.h > >>>index 7f522c0..c5638f4 100644 > >>>--- a/arch/powerpc/include/asm/dma-mapping.h > >>>+++ b/arch/powerpc/include/asm/dma-mapping.h > >>>@@ -125,6 +125,9 @@ static inline void set_dma_offset(struct device *dev, > >>>dma_addr_t off) > >>> #define HAVE_ARCH_DMA_SET_MASK 1 > >>> extern int dma_set_mask(struct device *dev, u64 dma_mask); > >>> > >>>+#define HAVE_ARCH_DMA_GET_PAGE_SHIFT 1 > >>>+extern unsigned long dma_get_page_shift(struct device *dev); > >>>+ > >>> #include > >>> > >>> extern int __dma_set_mask(struct device *dev, u64 dma_mask); > >>>diff --git a/arch/powerpc/kernel/dma.c b/arch/powerpc/kernel/dma.c > >>>index 59503ed..e805af2 100644 > >>>--- a/arch/powerpc/kernel/dma.c > >>>+++ b/arch/powerpc/kernel/dma.c > >>>@@ -335,6 +335,15 @@ int dma_set_mask(struct device *dev, u64 dma_mask) > >>> } > >>> EXPORT_SYMBOL(dma_set_mask); > >>> > >>>+unsigned long dma_get_page_shift(struct device *dev) > >>>+{ > >>>+ struct iommu_table *tbl = get_iommu_table_base(dev); > >>>+ if (tbl) > >>>+ return tbl->it_page_shift; > >> > >> > >>All PCI devices have this initialized on POWER (at least, our, IBM's > >>POWER) so 4K will always be returned here while in the case of > >>(get_dma_ops(dev)==&dma_direct_ops) it could actually return > >>PAGE_SHIFT. Is 4K still preferred value to return here? > > > >Right, so the logic of my series, goes like this: > > > >a) We currently are assuming DMA_PAGE_SHIFT (conceptual constant) is > >PAGE_SHIFT everywhere, including Power. > > > >b) After 2/7, the Power code will return either the IOMMU table's shift > >value, if set, or PAGE_SHIFT (I guess this would be the case if > >get_dma_ops(dev) == &dma_direct_ops, as you said). That is no different > >than we have now, except we can return the accurate IOMMU value if > >available. > > If it is not available, then something went wrong and BUG_ON(!tbl || > !tbl->it_page_shift) make more sense here than pretending that this > function can ever return PAGE_SHIFT. imho. That's a good point, thanks! > >3) After 3/7, the platform can override the generic Power > >get_dma_page_shift(). > > > >4) After 4/7, pseries will return the DDW value, if available, then > >fallback to the IOMMU table's value. I think in the case of > >get_dma_ops(dev)==&dma_direct_ops, the only way that can happen is if we > >are using DDW, right? > > This is for pseries guests; for the powernv host it is a "bypass" > mode which does 64bit direct DMA mapping and there is no additional > window for that (i.e. DIRECT64_PROPNAME, etc). You're right! I should update the code to handle both cases. In "bypass" mode, what TCE size is used? Is it guaranteed to be 4K? Seems like this would be a different platform implentation I'd put in for 'powernv', is that right? My apologies for missing that, and thank you for the review! -Nish ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH 2/7 v2] powerpc/dma-mapping: override dma_get_page_shift
On Tue, 2015-10-27 at 18:54 -0700, Nishanth Aravamudan wrote: > > In "bypass" mode, what TCE size is used? Is it guaranteed to be 4K? None :-) The TCEs are completely bypassed. You get a N:M linear mapping of all memory starting at 1<<59 PCI side. > Seems like this would be a different platform implentation I'd put in > for 'powernv', is that right? > > My apologies for missing that, and thank you for the review! Cheers, Ben. ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH 2/7 v2] powerpc/dma-mapping: override dma_get_page_shift
On 28.10.2015 [11:20:05 +0900], Benjamin Herrenschmidt wrote: > On Tue, 2015-10-27 at 18:54 -0700, Nishanth Aravamudan wrote: > > > > In "bypass" mode, what TCE size is used? Is it guaranteed to be 4K? > > None :-) The TCEs are completely bypassed. You get a N:M linear mapping > of all memory starting at 1<<59 PCI side. Err, duh, sorry! Ok, so in that case, DMA page shift is PAGE_SHIFT, then? -Nish ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH 09/19] powerpc: Move part of giveup_fpu, altivec, spe into c
Hi Anton, [auto build test ERROR on powerpc/next -- if it's inappropriate base, please suggest rules for selecting the more suitable base] url: https://github.com/0day-ci/linux/commits/Anton-Blanchard/powerpc-Don-t-disable-kernel-FP-VMX-VSX-MSR-bits-on-context-switch/20151028-091736 config: powerpc-mpc85xx_cds_defconfig (attached as .config) reproduce: wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # save the attached .config to linux build tree make.cross ARCH=powerpc All errors (new ones prefixed by >>): arch/powerpc/kernel/process.c: In function 'giveup_spe': >> arch/powerpc/kernel/process.c:247:24: error: parameter name omitted void giveup_spe(struct task_struct *) ^ >> arch/powerpc/kernel/process.c:252:31: error: 'tsk' undeclared (first use in >> this function) check_if_tm_restore_required(tsk); ^ arch/powerpc/kernel/process.c:252:31: note: each undeclared identifier is reported only once for each function it appears in >> arch/powerpc/kernel/process.c:258:2: error: implicit declaration of function >> '__giveup_spe' [-Werror=implicit-function-declaration] __giveup_spe(tsk); ^ cc1: all warnings being treated as errors vim +247 arch/powerpc/kernel/process.c 241 } 242 } 243 EXPORT_SYMBOL_GPL(flush_vsx_to_thread); 244 #endif /* CONFIG_VSX */ 245 246 #ifdef CONFIG_SPE > 247 void giveup_spe(struct task_struct *) 248 { 249 u64 oldmsr = mfmsr(); 250 u64 newmsr; 251 > 252 check_if_tm_restore_required(tsk); 253 254 newmsr = oldmsr | MSR_SPE; 255 if (oldmsr != newmsr) 256 mtmsr_isync(newmsr); 257 > 258 __giveup_spe(tsk); 259 } 260 EXPORT_SYMBOL(giveup_spe); 261 --- 0-DAY kernel test infrastructureOpen Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation .config.gz Description: Binary data ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH 19/19] powerpc: clean up asm/switch_to.h
Hi Anton, [auto build test ERROR on powerpc/next -- if it's inappropriate base, please suggest rules for selecting the more suitable base] url: https://github.com/0day-ci/linux/commits/Anton-Blanchard/powerpc-Don-t-disable-kernel-FP-VMX-VSX-MSR-bits-on-context-switch/20151028-091736 config: powerpc-virtex_defconfig (attached as .config) reproduce: wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # save the attached .config to linux build tree make.cross ARCH=powerpc All errors (new ones prefixed by >>): arch/powerpc/kernel/ptrace.c: In function 'fpr_get': >> arch/powerpc/kernel/ptrace.c:368:2: error: implicit declaration of function >> 'flush_fp_to_thread' [-Werror=implicit-function-declaration] flush_fp_to_thread(target); ^ cc1: all warnings being treated as errors -- arch/powerpc/kernel/align.c: In function 'fix_alignment': >> arch/powerpc/kernel/align.c:908:3: error: implicit declaration of function >> 'flush_fp_to_thread' [-Werror=implicit-function-declaration] flush_fp_to_thread(current); ^ cc1: all warnings being treated as errors -- arch/powerpc/kernel/signal_32.c: In function 'save_user_regs': >> arch/powerpc/kernel/signal_32.c:415:2: error: implicit declaration of >> function 'flush_fp_to_thread' [-Werror=implicit-function-declaration] flush_fp_to_thread(current); ^ cc1: all warnings being treated as errors -- arch/powerpc/kernel/process.c: In function 'enable_kernel_fp': >> arch/powerpc/kernel/process.c:186:3: error: implicit declaration of function >> '__giveup_fpu' [-Werror=implicit-function-declaration] __giveup_fpu(current); ^ cc1: all warnings being treated as errors -- arch/powerpc/kernel/traps.c: In function 'parse_fpe': >> arch/powerpc/kernel/traps.c:860:2: error: implicit declaration of function >> 'flush_fp_to_thread' [-Werror=implicit-function-declaration] flush_fp_to_thread(current); ^ cc1: all warnings being treated as errors vim +/flush_fp_to_thread +368 arch/powerpc/kernel/ptrace.c f65255e8 Roland McGrath 2007-12-20 362 void *kbuf, void __user *ubuf) f65255e8 Roland McGrath 2007-12-20 363 { c6e6771b Michael Neuling 2008-06-25 364 #ifdef CONFIG_VSX de79f7b9 Paul Mackerras 2013-09-10 365u64 buf[33]; c6e6771b Michael Neuling 2008-06-25 366int i; c6e6771b Michael Neuling 2008-06-25 367 #endif f65255e8 Roland McGrath 2007-12-20 @368flush_fp_to_thread(target); f65255e8 Roland McGrath 2007-12-20 369 c6e6771b Michael Neuling 2008-06-25 370 #ifdef CONFIG_VSX c6e6771b Michael Neuling 2008-06-25 371/* copy to local buffer then write that out */ :: The code at line 368 was first introduced by commit :: f65255e8d51ecbc6c9eef20d39e0377d19b658ca [POWERPC] Use user_regset accessors for FP regs :: TO: Roland McGrath :: CC: Paul Mackerras --- 0-DAY kernel test infrastructureOpen Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation .config.gz Description: Binary data ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH 2/7 v2] powerpc/dma-mapping: override dma_get_page_shift
On Tue, 2015-10-27 at 19:30 -0700, Nishanth Aravamudan wrote: > On 28.10.2015 [11:20:05 +0900], Benjamin Herrenschmidt wrote: > > On Tue, 2015-10-27 at 18:54 -0700, Nishanth Aravamudan wrote: > > > > > > In "bypass" mode, what TCE size is used? Is it guaranteed to be > > > 4K? > > > > None :-) The TCEs are completely bypassed. You get a N:M linear > > mapping > > of all memory starting at 1<<59 PCI side. > > Err, duh, sorry! Ok, so in that case, DMA page shift is PAGE_SHIFT, > then? I think so. Cheers, Ben. ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH] cxl: sparse: add __iomem annotations in vphb.c
sparse identifies the following issues: drivers/misc/cxl/vphb.c:131:17: warning: incorrect type in assignment (different address spaces) drivers/misc/cxl/vphb.c:131:17:expected void volatile [noderef] * drivers/misc/cxl/vphb.c:131:17:got void * drivers/misc/cxl/vphb.c:252:23: warning: incorrect type in assignment (different address spaces) drivers/misc/cxl/vphb.c:252:23:expected void [noderef] *cfg_data drivers/misc/cxl/vphb.c:252:23:got void * Add __iomem annotations and remove unnecessary casts to clear up these warnings. Reported-by: Daniel Axtens Signed-off-by: Andrew Donnellan --- This patch is a respin of https://patchwork.ozlabs.org/patch/504976/, incorporating comments from mpe. As with the old patch, this patch doesn't make any changes to the return type of cxl_pcie_cfg_addr() and casts to an __iomem type when we use it in cxl_pcie_config_info(). cxl_pcie_cfg_addr() returns an unsigned long, rather than a pointer type, as we use its return value in bitwise operations. If there's a better way to handle this I'd like to know. --- drivers/misc/cxl/vphb.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/misc/cxl/vphb.c b/drivers/misc/cxl/vphb.c index c241e15..588bfc0 100644 --- a/drivers/misc/cxl/vphb.c +++ b/drivers/misc/cxl/vphb.c @@ -128,7 +128,7 @@ static int cxl_pcie_config_info(struct pci_bus *bus, unsigned int devfn, return PCIBIOS_BAD_REGISTER_NUMBER; addr = cxl_pcie_cfg_addr(phb, bus->number, devfn, offset); - *ioaddr = (void *)(addr & ~0x3ULL); + *ioaddr = (void __iomem *)(addr & ~0x3ULL); *shift = ((addr & 0x3) * 8); switch (len) { case 1: @@ -249,7 +249,7 @@ int cxl_pci_vphb_add(struct cxl_afu *afu) /* Setup the PHB using arch provided callback */ phb->ops = &cxl_pcie_pci_ops; phb->cfg_addr = afu->afu_desc_mmio + afu->crs_offset; - phb->cfg_data = (void *)(u64)afu->crs_len; + phb->cfg_data = (void __iomem *)afu->crs_len; phb->private_data = afu; phb->controller_ops = cxl_pci_controller_ops; -- Andrew Donnellan Software Engineer, OzLabs andrew.donnel...@au1.ibm.com Australia Development Lab, Canberra +61 2 6201 8874 (work)IBM Australia Limited ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH] cxl: sparse: add __iomem annotations in vphb.c
Acked-by: Ian Munsie ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH 19/19] powerpc: clean up asm/switch_to.h
Hi Anton, [auto build test ERROR on powerpc/next -- if it's inappropriate base, please suggest rules for selecting the more suitable base] url: https://github.com/0day-ci/linux/commits/Anton-Blanchard/powerpc-Don-t-disable-kernel-FP-VMX-VSX-MSR-bits-on-context-switch/20151028-091736 config: powerpc-ppc6xx_defconfig (attached as .config) reproduce: wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # save the attached .config to linux build tree make.cross ARCH=powerpc All errors (new ones prefixed by >>): arch/powerpc/kernel/swsusp.c: In function 'save_processor_state': >> arch/powerpc/kernel/swsusp.c:25:2: error: implicit declaration of function >> 'flush_spe_to_thread' [-Werror=implicit-function-declaration] flush_spe_to_thread(current); ^ cc1: all warnings being treated as errors vim +/flush_spe_to_thread +25 arch/powerpc/kernel/swsusp.c be9c94dd Johannes Berg 2007-04-30 19 /* be9c94dd Johannes Berg 2007-04-30 20* flush out all the special registers so we don't need be9c94dd Johannes Berg 2007-04-30 21* to save them in the snapshot be9c94dd Johannes Berg 2007-04-30 22*/ be9c94dd Johannes Berg 2007-04-30 23 flush_fp_to_thread(current); be9c94dd Johannes Berg 2007-04-30 24 flush_altivec_to_thread(current); be9c94dd Johannes Berg 2007-04-30 @25 flush_spe_to_thread(current); 543b9fd3 Johannes Berg 2007-05-03 26 543b9fd3 Johannes Berg 2007-05-03 27 #ifdef CONFIG_PPC64 543b9fd3 Johannes Berg 2007-05-03 28 hard_irq_disable(); :: The code at line 25 was first introduced by commit :: be9c94dd7776467813419f49fabe8017bc2d4c81 [POWERPC] Fix suspend states again :: TO: Johannes Berg :: CC: Paul Mackerras --- 0-DAY kernel test infrastructureOpen Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation .config.gz Description: Binary data ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH 1/2] powerpc: Add function to copy mm_context_t to the paca
This adds a function to copy the mm->context to the paca. This is only a basic conversion for now but will be used more extensively in the next patch. This also adds #ifdef CONFIG_PPC_BOOK3S around this code since it's not used elsewhere. Signed-off-by: Michael Neuling --- arch/powerpc/include/asm/paca.h | 11 +++ arch/powerpc/kernel/asm-offsets.c | 2 ++ arch/powerpc/mm/hash_utils_64.c | 5 +++-- arch/powerpc/mm/slb.c | 2 +- arch/powerpc/mm/slice.c | 3 +-- 5 files changed, 18 insertions(+), 5 deletions(-) diff --git a/arch/powerpc/include/asm/paca.h b/arch/powerpc/include/asm/paca.h index 70bd438..1cc6e08 100644 --- a/arch/powerpc/include/asm/paca.h +++ b/arch/powerpc/include/asm/paca.h @@ -131,7 +131,9 @@ struct paca_struct { struct tlb_core_data tcd; #endif /* CONFIG_PPC_BOOK3E */ +#ifdef CONFIG_PPC_BOOK3S mm_context_t context; +#endif /* * then miscellaneous read-write fields @@ -194,6 +196,15 @@ struct paca_struct { #endif }; +#ifdef CONFIG_PPC_BOOK3S +static inline void copy_mm_to_paca(mm_context_t *context) +{ + get_paca()->context = *context; +} +#else +static inline void copy_mm_to_paca(mm_context_t *context){} +#endif + extern struct paca_struct *paca; extern void initialise_paca(struct paca_struct *new_paca, int cpu); extern void setup_paca(struct paca_struct *new_paca); diff --git a/arch/powerpc/kernel/asm-offsets.c b/arch/powerpc/kernel/asm-offsets.c index 221d584..9db7be2 100644 --- a/arch/powerpc/kernel/asm-offsets.c +++ b/arch/powerpc/kernel/asm-offsets.c @@ -185,6 +185,7 @@ int main(void) DEFINE(PACAKMSR, offsetof(struct paca_struct, kernel_msr)); DEFINE(PACASOFTIRQEN, offsetof(struct paca_struct, soft_enabled)); DEFINE(PACAIRQHAPPENED, offsetof(struct paca_struct, irq_happened)); +#ifdef CONFIG_PPC_BOOK3S DEFINE(PACACONTEXTID, offsetof(struct paca_struct, context.id)); #ifdef CONFIG_PPC_MM_SLICES DEFINE(PACALOWSLICESPSIZE, offsetof(struct paca_struct, @@ -193,6 +194,7 @@ int main(void) context.high_slices_psize)); DEFINE(MMUPSIZEDEFSIZE, sizeof(struct mmu_psize_def)); #endif /* CONFIG_PPC_MM_SLICES */ +#endif #ifdef CONFIG_PPC_BOOK3E DEFINE(PACAPGD, offsetof(struct paca_struct, pgd)); diff --git a/arch/powerpc/mm/hash_utils_64.c b/arch/powerpc/mm/hash_utils_64.c index aee7017..fa62eb0 100644 --- a/arch/powerpc/mm/hash_utils_64.c +++ b/arch/powerpc/mm/hash_utils_64.c @@ -906,7 +906,8 @@ void demote_segment_4k(struct mm_struct *mm, unsigned long addr) slice_set_range_psize(mm, addr, 1, MMU_PAGE_4K); copro_flush_all_slbs(mm); if ((get_paca_psize(addr) != MMU_PAGE_4K) && (current->mm == mm)) { - get_paca()->context = mm->context; + + copy_mm_to_paca(&mm->context); slb_flush_and_rebolt(); } } @@ -973,7 +974,7 @@ static void check_paca_psize(unsigned long ea, struct mm_struct *mm, { if (user_region) { if (psize != get_paca_psize(ea)) { - get_paca()->context = mm->context; + copy_mm_to_paca(&mm->context); slb_flush_and_rebolt(); } } else if (get_paca()->vmalloc_sllp != diff --git a/arch/powerpc/mm/slb.c b/arch/powerpc/mm/slb.c index 8a32a2be..4412b8e 100644 --- a/arch/powerpc/mm/slb.c +++ b/arch/powerpc/mm/slb.c @@ -223,7 +223,7 @@ void switch_slb(struct task_struct *tsk, struct mm_struct *mm) asm volatile("slbie %0" : : "r" (slbie_data)); get_paca()->slb_cache_ptr = 0; - get_paca()->context = mm->context; + copy_mm_to_paca(&mm->context); /* * preload some userspace segments into the SLB. diff --git a/arch/powerpc/mm/slice.c b/arch/powerpc/mm/slice.c index 0f432a7..42954f0 100644 --- a/arch/powerpc/mm/slice.c +++ b/arch/powerpc/mm/slice.c @@ -185,8 +185,7 @@ static void slice_flush_segments(void *parm) if (mm != current->active_mm) return; - /* update the paca copy of the context struct */ - get_paca()->context = current->active_mm->context; + copy_mm_to_paca(¤t->active_mm->context); local_irq_save(flags); slb_flush_and_rebolt(); -- 2.5.0 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH 2/2] powerpc: Copy only required pieces of the mm_context_t to the paca
Currently we copy the whole mm_context_t to the paca but only access a few bits of it. This is wasteful of space paca and also takes quite some time in the hot path of context switching. This patch pulls in only the required bits from the mm_context_t to the paca and on context switch, copies only those. Benchmarking this (On top of Anton's recent MSR context switching changes [1]) using processes and yield shows an improvement of almost 3% on POWER8: http://ozlabs.org/~anton/junkcode/context_switch2.c ./context_switch2 --test=yield --process 0 0 1. https://lists.ozlabs.org/pipermail/linuxppc-dev/2015-October/135700.html Signed-off-by: Michael Neuling --- arch/powerpc/include/asm/paca.h | 17 +++-- arch/powerpc/kernel/asm-offsets.c | 8 arch/powerpc/mm/hash_utils_64.c | 4 ++-- 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/arch/powerpc/include/asm/paca.h b/arch/powerpc/include/asm/paca.h index 1cc6e08..1c0d9f4 100644 --- a/arch/powerpc/include/asm/paca.h +++ b/arch/powerpc/include/asm/paca.h @@ -132,7 +132,13 @@ struct paca_struct { #endif /* CONFIG_PPC_BOOK3E */ #ifdef CONFIG_PPC_BOOK3S - mm_context_t context; + mm_context_id_t context_id; +#ifdef CONFIG_PPC_MM_SLICES + u64 context_low_slices_psize; + unsigned char context_high_slices_psize[SLICE_ARRAY_SIZE]; +#else + u16 context_sllp; +#endif #endif /* @@ -199,7 +205,14 @@ struct paca_struct { #ifdef CONFIG_PPC_BOOK3S static inline void copy_mm_to_paca(mm_context_t *context) { - get_paca()->context = *context; + get_paca()->context_id = context->id; +#ifdef CONFIG_PPC_MM_SLICES + get_paca()->context_low_slices_psize = context->low_slices_psize; + memcpy(&get_paca()->context_high_slices_psize, + &context->high_slices_psize, SLICE_ARRAY_SIZE); +#else + get_paca()->context_sllp = context->sllp; +#endif } #else static inline void copy_mm_to_paca(mm_context_t *context){} diff --git a/arch/powerpc/kernel/asm-offsets.c b/arch/powerpc/kernel/asm-offsets.c index 9db7be2..d5903a9 100644 --- a/arch/powerpc/kernel/asm-offsets.c +++ b/arch/powerpc/kernel/asm-offsets.c @@ -186,12 +186,12 @@ int main(void) DEFINE(PACASOFTIRQEN, offsetof(struct paca_struct, soft_enabled)); DEFINE(PACAIRQHAPPENED, offsetof(struct paca_struct, irq_happened)); #ifdef CONFIG_PPC_BOOK3S - DEFINE(PACACONTEXTID, offsetof(struct paca_struct, context.id)); + DEFINE(PACACONTEXTID, offsetof(struct paca_struct, context_id)); #ifdef CONFIG_PPC_MM_SLICES DEFINE(PACALOWSLICESPSIZE, offsetof(struct paca_struct, - context.low_slices_psize)); + context_low_slices_psize)); DEFINE(PACAHIGHSLICEPSIZE, offsetof(struct paca_struct, - context.high_slices_psize)); + context_high_slices_psize)); DEFINE(MMUPSIZEDEFSIZE, sizeof(struct mmu_psize_def)); #endif /* CONFIG_PPC_MM_SLICES */ #endif @@ -224,7 +224,7 @@ int main(void) #ifdef CONFIG_PPC_MM_SLICES DEFINE(MMUPSIZESLLP, offsetof(struct mmu_psize_def, sllp)); #else - DEFINE(PACACONTEXTSLLP, offsetof(struct paca_struct, context.sllp)); + DEFINE(PACACONTEXTSLLP, offsetof(struct paca_struct, context_sllp)); #endif /* CONFIG_PPC_MM_SLICES */ DEFINE(PACA_EXGEN, offsetof(struct paca_struct, exgen)); DEFINE(PACA_EXMC, offsetof(struct paca_struct, exmc)); diff --git a/arch/powerpc/mm/hash_utils_64.c b/arch/powerpc/mm/hash_utils_64.c index fa62eb0..0e087e4 100644 --- a/arch/powerpc/mm/hash_utils_64.c +++ b/arch/powerpc/mm/hash_utils_64.c @@ -877,11 +877,11 @@ static unsigned int get_paca_psize(unsigned long addr) unsigned long index, mask_index; if (addr < SLICE_LOW_TOP) { - lpsizes = get_paca()->context.low_slices_psize; + lpsizes = get_paca()->context_low_slices_psize; index = GET_LOW_SLICE_INDEX(addr); return (lpsizes >> (index * 4)) & 0xF; } - hpsizes = get_paca()->context.high_slices_psize; + hpsizes = get_paca()->context_high_slices_psize; index = GET_HIGH_SLICE_INDEX(addr); mask_index = index & 0x1; return (hpsizes[index >> 1] >> (mask_index * 4)) & 0xF; -- 2.5.0 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH 0/2] Add support for Nvlink
This series adds support for Nvlink, a high speed interconnect that is used in conjunction with PCI-E to create a high bandwidth interface between GPU and CPU. As the Nvlink hardware interface is similar to IBM's existing PCIe host bridges no major new kernel or user interfaces are added by this patch series. Instead the links are treated as standard PCIe devices sitting under a Nvlink specific PHB type. This allows existing kernel interfaces to be used for the management and control of the links. Alistair Popple (2): Revert "powerpc/pci: Remove unused struct pci_dn.pcidev field" platforms/powernv: Add support for Nvlink NPUs arch/powerpc/include/asm/pci-bridge.h | 1 + arch/powerpc/include/asm/pci.h| 4 + arch/powerpc/platforms/powernv/Makefile | 2 +- arch/powerpc/platforms/powernv/npu-dma.c | 267 ++ arch/powerpc/platforms/powernv/pci-ioda.c | 105 ++-- arch/powerpc/platforms/powernv/pci.c | 4 + arch/powerpc/platforms/powernv/pci.h | 10 ++ 7 files changed, 381 insertions(+), 12 deletions(-) create mode 100644 arch/powerpc/platforms/powernv/npu-dma.c -- 2.1.4 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH 1/2] Revert "powerpc/pci: Remove unused struct pci_dn.pcidev field"
This commit removed the pcidev field from struct pci_dn as it was no longer in use by the kernel. However to support finding the association of Nvlink devices to GPU devices from the device-tree this field is required. This reverts commit 250c7b277c65. Signed-off-by: Alistair Popple --- arch/powerpc/include/asm/pci-bridge.h | 1 + arch/powerpc/platforms/powernv/pci-ioda.c | 1 + 2 files changed, 2 insertions(+) diff --git a/arch/powerpc/include/asm/pci-bridge.h b/arch/powerpc/include/asm/pci-bridge.h index 37fc535..54843ca 100644 --- a/arch/powerpc/include/asm/pci-bridge.h +++ b/arch/powerpc/include/asm/pci-bridge.h @@ -205,6 +205,7 @@ struct pci_dn { int pci_ext_config_space; /* for pci devices */ + struct pci_dev *pcidev;/* back-pointer to the pci device */ #ifdef CONFIG_EEH struct eeh_dev *edev; /* eeh device */ #endif diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c b/arch/powerpc/platforms/powernv/pci-ioda.c index 414fd1a..42b4bb2 100644 --- a/arch/powerpc/platforms/powernv/pci-ioda.c +++ b/arch/powerpc/platforms/powernv/pci-ioda.c @@ -1007,6 +1007,7 @@ static void pnv_ioda_setup_same_PE(struct pci_bus *bus, struct pnv_ioda_pe *pe) pci_name(dev)); continue; } + pdn->pcidev = dev; pdn->pe_number = pe->pe_number; pe->dma_weight += pnv_ioda_dma_weight(dev); if ((pe->flags & PNV_IODA_PE_BUS_ALL) && dev->subordinate) -- 2.1.4 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH 2/2] platforms/powernv: Add support for Nvlink NPUs
NV-Link is a high speed interconnect that is used in conjunction with a PCI-E connection to create an interface between CPU and GPU that provides very high data bandwidth. A PCI-E connection to a GPU is used as the control path to initiate and report status of large data transfers sent via the NV-Link. On IBM Power systems the NV-Link hardware interface is very similar to the existing PHB3. This patch adds support for this new NPU PHB type. DMA operations on the NPU are not supported as this patch sets the TCE translation tables to be the same as the related GPU PCIe device for each Nvlink. Therefore all DMA operations are setup and controlled via the PCIe device. EEH is not presently supported for the NPU devices, although it may be added in future. Signed-off-by: Alistair Popple Signed-off-by: Gavin Shan --- arch/powerpc/include/asm/pci.h| 4 + arch/powerpc/platforms/powernv/Makefile | 2 +- arch/powerpc/platforms/powernv/npu-dma.c | 267 ++ arch/powerpc/platforms/powernv/pci-ioda.c | 104 ++-- arch/powerpc/platforms/powernv/pci.c | 4 + arch/powerpc/platforms/powernv/pci.h | 10 ++ 6 files changed, 379 insertions(+), 12 deletions(-) create mode 100644 arch/powerpc/platforms/powernv/npu-dma.c diff --git a/arch/powerpc/include/asm/pci.h b/arch/powerpc/include/asm/pci.h index 3453bd8..4409ca9 100644 --- a/arch/powerpc/include/asm/pci.h +++ b/arch/powerpc/include/asm/pci.h @@ -149,4 +149,8 @@ extern void pcibios_setup_phb_io_space(struct pci_controller *hose); extern void pcibios_scan_phb(struct pci_controller *hose); #endif /* __KERNEL__ */ + +extern struct pci_dev *pnv_get_nvl_pci_dev(struct pci_dev *nvl_dev); +extern struct pci_dev *pnv_get_pci_nvl_dev(struct pci_dev *pci_dev, int index); + #endif /* __ASM_POWERPC_PCI_H */ diff --git a/arch/powerpc/platforms/powernv/Makefile b/arch/powerpc/platforms/powernv/Makefile index 1c8cdb6..ee774e8 100644 --- a/arch/powerpc/platforms/powernv/Makefile +++ b/arch/powerpc/platforms/powernv/Makefile @@ -4,7 +4,7 @@ obj-y += rng.o opal-elog.o opal-dump.o opal-sysparam.o opal-sensor.o obj-y += opal-msglog.o opal-hmi.o opal-power.o opal-irqchip.o obj-$(CONFIG_SMP) += smp.o subcore.o subcore-asm.o -obj-$(CONFIG_PCI) += pci.o pci-p5ioc2.o pci-ioda.o +obj-$(CONFIG_PCI) += pci.o pci-p5ioc2.o pci-ioda.o npu-dma.o obj-$(CONFIG_EEH) += eeh-powernv.o obj-$(CONFIG_PPC_SCOM) += opal-xscom.o obj-$(CONFIG_MEMORY_FAILURE) += opal-memory-errors.o diff --git a/arch/powerpc/platforms/powernv/npu-dma.c b/arch/powerpc/platforms/powernv/npu-dma.c new file mode 100644 index 000..4f8ec18 --- /dev/null +++ b/arch/powerpc/platforms/powernv/npu-dma.c @@ -0,0 +1,267 @@ +/* + * This file implements the DMA operations for Nvlink devices. The NPU + * devices all point to the same iommu table as the parent PCI device. + * + * Copyright Alistair Popple, IBM Corporation 2015. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + */ + +#include +#include +#include + +#include +#include +#include +#include + +#include "powernv.h" +#include "pci.h" + +static struct pci_dev *get_pci_dev(struct device_node *dn) +{ + return PCI_DN(dn)->pcidev; +} + +/* Given a NPU device get the associated PCI device. */ +struct pci_dev *pnv_get_nvl_pci_dev(struct pci_dev *nvl_dev) +{ + struct device_node *dn; + struct pci_dev *pci_dev; + + /* Get assoicated PCI device */ + dn = of_parse_phandle(nvl_dev->dev.of_node, "ibm,gpu", 0); + if (!dn) + return NULL; + + pci_dev = get_pci_dev(dn); + of_node_put(dn); + + return pci_dev; +} +EXPORT_SYMBOL(pnv_get_nvl_pci_dev); + +/* Given the real PCI device get a linked NPU device. */ +struct pci_dev *pnv_get_pci_nvl_dev(struct pci_dev *pci_dev, int index) +{ + struct device_node *dn; + struct pci_dev *nvl_dev; + + /* Get assoicated PCI device */ + dn = of_parse_phandle(pci_dev->dev.of_node, "ibm,npu", index); + if (!dn) + return NULL; + + nvl_dev = get_pci_dev(dn); + of_node_put(dn); + + return nvl_dev; +} +EXPORT_SYMBOL(pnv_get_pci_nvl_dev); + +const struct dma_map_ops *get_linked_pci_dma_map_ops(struct device *dev, + struct pci_dev **pci_dev) +{ + *pci_dev = pnv_get_nvl_pci_dev(to_pci_dev(dev)); + if (!*pci_dev) + return NULL; + + return get_dma_ops(&(*pci_dev)->dev); +} + +#define NPU_DMA_OP_UNSUPPORTED() \ + dev_err_once(dev, "%s operation unsupported for Nvlink devices\n", \ + __func__) + +static void *dma_npu_alloc(struct device *dev, size_t size, +
Re: [PATCH v4 0/2] powerpc/512x: add LocalPlus Bus FIFO device driver
On Tue, Oct 27, 2015 at 11:42:57PM +0300, Alexander Popov wrote: > >> Hello, > >> > >> I've done my best to fix the issues pointed by Timur Tabi and Vinod Koul. > >> Could I have a feedback please? > > > > I dont see to have v4 in my list :( Can you please repost > > Hello, Vinod > > I'm sure I haven't miss your address in the list of the recipients. > Anyway I can repost. > > Anatolij Gustschin wrote that he applied v4 with some fix to mpc5xxx/next > some time ago. Okay, I though these were dmaengine patches but looking back they seemed to be for arch code, so nothing to do here for me and then you :) > So should I repost v4 for everybody? How should I mark the reposted patches? Its merged so fine with me -- ~Vinod ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev