LinuxPPC-Dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
* Re: [PATCH v2 1/1] powerpc/pseries: fix EEH recovery of some IOV devices
From: Bryant G. Ly @ 2018-05-30 13:55 UTC (permalink / raw)
  To: Sam Bobroff, linuxppc-dev, linux-pci; +Cc: mpe, bhelgaas, bryantly
In-Reply-To: <7598ffeb48c16c88a34937ad93b18f806222b8df.1527208281.git.sbobroff@linux.ibm.com>



On 5/24/18 7:31 PM, Sam Bobroff wrote:
> EEH recovery currently fails on pSeries for some IOV capable PCI
> devices, if CONFIG_PCI_IOV is on and the hypervisor doesn't provide
> certain device tree properties for the device. (Found on an IOV
> capable device using the ipr driver.)
>
> Recovery fails in pci_enable_resources() at the check on r->parent,
> because r->flags is set and r->parent is not.  This state is due to
> sriov_init() setting the start, end and flags members of the IOV BARs
> but the parent not being set later in
> pseries_pci_fixup_iov_resources(), because the
> "ibm,open-sriov-vf-bar-info" property is missing.
>
> Correct this by zeroing the resource flags for IOV BARs when they
> can't be configured.
>
> Signed-off-by: Sam Bobroff <sbobroff@linux.ibm.com>
> ---
> Hi,
>
> This is a fix to allow EEH recovery to succeed in a specific situation,
> which I've tried to explain in the commit message.
>
> As with the RFC version, the IOV BARs are disabled by setting the resource
> flags to 0 but the other fields are now left as-is because that is what is done
> elsewhere (see sriov_init() and __pci_read_base()).
>
> I've also examined the concern raised by Bjorn Helgaas, that VFs could be
> enabled later after the BARs are disabled, and it already seems safe: enabling
> VFs (on pseries) depends on another device tree property,
> "ibm,number-of-configurable-vfs" as well as support for the RTAS function
> "ibm_map_pes". Since these are all part of the hypervisor's support for IOV it
> seems unlikely that we would ever see some of them but not all. (None are
> currently provided by QEMU/KVM.) (Additionally, the ipr driver on which the EEH
> recovery failure was discovered doesn't even seem to have SR-IOV support so it
> certainly can't enable VFs.)
>
> Cheers,
> Sam.
> ====== v1 -> v2: ======
>
> Patch 1/1: powerpc/pseries: fix EEH recovery of some IOV devices
> * Moved the BAR disabling code to a function.
> * Also check in pseries_pci_fixup_resources().
>
> ====== v1: ======
>
> Patch 1/1: powerpc/pseries: fix EEH recovery of IOV devices
>
>  arch/powerpc/platforms/pseries/setup.c | 25 +++++++++++++++++--------
>  1 file changed, 17 insertions(+), 8 deletions(-)
>
> diff --git a/arch/powerpc/platforms/pseries/setup.c b/arch/powerpc/platforms/pseries/setup.c
> index b55ad4286dc7..0a9e4243ae1d 100644
> --- a/arch/powerpc/platforms/pseries/setup.c
> +++ b/arch/powerpc/platforms/pseries/setup.c
> @@ -645,6 +645,15 @@ void of_pci_parse_iov_addrs(struct pci_dev *dev, const int *indexes)
>  	}
>  }
>
> +static void pseries_disable_sriov_resources(struct pci_dev *pdev)
> +{
> +	int i;
> +
> +	pci_warn(pdev, "No hypervisor support for SR-IOV on this device, IOV BARs disabled.\n");
> +	for (i = 0; i < PCI_SRIOV_NUM_BARS; i++)
> +		pdev->resource[i + PCI_IOV_RESOURCES].flags = 0;
> +}
> +
>  static void pseries_pci_fixup_resources(struct pci_dev *pdev)
>  {
>  	const int *indexes;
> @@ -652,10 +661,10 @@ static void pseries_pci_fixup_resources(struct pci_dev *pdev)
>
>  	/*Firmware must support open sriov otherwise dont configure*/
>  	indexes = of_get_property(dn, "ibm,open-sriov-vf-bar-info", NULL);
> -	if (!indexes)
> -		return;
> -	/* Assign the addresses from device tree*/
> -	of_pci_set_vf_bar_size(pdev, indexes);
> +	if (indexes)
> +		of_pci_set_vf_bar_size(pdev, indexes);
> +	else
> +		pseries_disable_sriov_resources(pdev);
>  }
>
>  static void pseries_pci_fixup_iov_resources(struct pci_dev *pdev)
> @@ -667,10 +676,10 @@ static void pseries_pci_fixup_iov_resources(struct pci_dev *pdev)
>  		return;
>  	/*Firmware must support open sriov otherwise dont configure*/
>  	indexes = of_get_property(dn, "ibm,open-sriov-vf-bar-info", NULL);
> -	if (!indexes)
> -		return;
> -	/* Assign the addresses from device tree*/
> -	of_pci_parse_iov_addrs(pdev, indexes);
> +	if (indexes)
> +		of_pci_parse_iov_addrs(pdev, indexes);
> +	else
> +		pseries_disable_sriov_resources(pdev);
>  }
>
>  static resource_size_t pseries_pci_iov_resource_alignment(struct pci_dev *pdev,

Acked-by: Bryant G. Ly <bryantly@linux.vnet.ibm.com>

^ permalink raw reply

* Re: [PATCH v5 1/4] powerpc/kbuild: set default generic machine type for 32-bit compile
From: Masahiro Yamada @ 2018-05-30 14:30 UTC (permalink / raw)
  To: Nicholas Piggin
  Cc: Linux Kbuild mailing list, linuxppc-dev, Segher Boessenkool
In-Reply-To: <20180530121922.22122-2-npiggin@gmail.com>

2018-05-30 21:19 GMT+09:00 Nicholas Piggin <npiggin@gmail.com>:
> Some 64-bit toolchains uses the wrong ISA variant for compiling 32-bit
> kernels, even with -m32. Debian's powerpc64le is one such case, and
> that is because it is built with --with-cpu=power8.
>
> So when cross compiling a 32-bit kernel with a 64-bit toolchain, set
> -mcpu=powerpc initially, which is the generic 32-bit powerpc machine
> type and scheduling model. CPU and platform code can override this
> with subsequent -mcpu flags if necessary.
>
> This is not done for 32-bit toolchains otherwise it would override
> their defaults, which are presumably set appropriately for the
> environment (moreso than a 64-bit cross compiler).
>
> This fixes a lot of build failures due to incompatible assembly when
> compiling 32-bit kernel with th Debian powerpc64le 64-bit toolchain.
>
> Cc: Segher Boessenkool <segher@kernel.crashing.org>
> Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
>
> Since v1: reworded changelog to explain the cause of the problem (thanks
> Segher) and moved the flags into the 64-32 cross compile case.
> ---
>  arch/powerpc/Makefile | 8 ++++++++
>  1 file changed, 8 insertions(+)
>
> diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
> index 95813df90801..d628724087c6 100644
> --- a/arch/powerpc/Makefile
> +++ b/arch/powerpc/Makefile
> @@ -24,6 +24,14 @@ ifeq ($(HAS_BIARCH),y)
>  ifeq ($(CROSS32_COMPILE),)
>  CROSS32CC      := $(CC) -m32
>  KBUILD_ARFLAGS += --target=elf32-powerpc
> +ifdef CONFIG_PPC32
> +# These options will be overridden by any -mcpu option that the CPU
> +# or platform code sets later on the command line, but they are needed
> +# to set a sane 32-bit cpu target for the 64-bit cross compiler which
> +# may default to the wrong ISA.
> +KBUILD_CFLAGS          += -mcpu=powerpc
> +KBUILD_AFLAGS          += -mcpu=powerpc
> +endif
>  endif
>  endif
>
> --
> 2.17.0
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html


All applied to linux-kbuild/kconfig.
Thanks!




-- 
Best Regards
Masahiro Yamada

^ permalink raw reply

* Re: [PATCH v5 1/4] powerpc/kbuild: set default generic machine type for 32-bit compile
From: Masahiro Yamada @ 2018-05-30 14:32 UTC (permalink / raw)
  To: Nicholas Piggin
  Cc: Linux Kbuild mailing list, linuxppc-dev, Segher Boessenkool
In-Reply-To: <20180530121922.22122-2-npiggin@gmail.com>

2018-05-30 21:19 GMT+09:00 Nicholas Piggin <npiggin@gmail.com>:
> Some 64-bit toolchains uses the wrong ISA variant for compiling 32-bit
> kernels, even with -m32. Debian's powerpc64le is one such case, and
> that is because it is built with --with-cpu=power8.
>
> So when cross compiling a 32-bit kernel with a 64-bit toolchain, set
> -mcpu=powerpc initially, which is the generic 32-bit powerpc machine
> type and scheduling model. CPU and platform code can override this
> with subsequent -mcpu flags if necessary.
>
> This is not done for 32-bit toolchains otherwise it would override
> their defaults, which are presumably set appropriately for the
> environment (moreso than a 64-bit cross compiler).
>
> This fixes a lot of build failures due to incompatible assembly when
> compiling 32-bit kernel with th Debian powerpc64le 64-bit toolchain.

When I applied this patch, I changed the following.

"th" -> "the"


Please let me know if my fix-up is bad.






> Cc: Segher Boessenkool <segher@kernel.crashing.org>
> Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
>
> Since v1: reworded changelog to explain the cause of the problem (thanks
> Segher) and moved the flags into the 64-32 cross compile case.
> ---
>  arch/powerpc/Makefile | 8 ++++++++
>  1 file changed, 8 insertions(+)
>
> diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
> index 95813df90801..d628724087c6 100644
> --- a/arch/powerpc/Makefile
> +++ b/arch/powerpc/Makefile
> @@ -24,6 +24,14 @@ ifeq ($(HAS_BIARCH),y)
>  ifeq ($(CROSS32_COMPILE),)
>  CROSS32CC      := $(CC) -m32
>  KBUILD_ARFLAGS += --target=elf32-powerpc
> +ifdef CONFIG_PPC32
> +# These options will be overridden by any -mcpu option that the CPU
> +# or platform code sets later on the command line, but they are needed
> +# to set a sane 32-bit cpu target for the 64-bit cross compiler which
> +# may default to the wrong ISA.
> +KBUILD_CFLAGS          += -mcpu=powerpc
> +KBUILD_AFLAGS          += -mcpu=powerpc
> +endif
>  endif
>  endif
>
> --
> 2.17.0
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html



-- 
Best Regards
Masahiro Yamada

^ permalink raw reply

* Re: [PATCH v5 3/4] powerpc/kbuild: Use flags variables rather than overriding LD/CC/AS
From: Masahiro Yamada @ 2018-05-30 14:34 UTC (permalink / raw)
  To: Nicholas Piggin
  Cc: Linux Kbuild mailing list, linuxppc-dev, Segher Boessenkool
In-Reply-To: <20180530121922.22122-4-npiggin@gmail.com>

2018-05-30 21:19 GMT+09:00 Nicholas Piggin <npiggin@gmail.com>:
> The powerpc toolchain can compile combinations of 32/64 bit and
> big/little endian, so it's convenient to consider, e.g.,
>
>   `CC -m64 -mbig-endian`
>
> To be the C compiler for the purpose of invoking it to build target
> artifacts. So overriding the the CC variable to include thse flags
> works for this purpose.

When I applied this patch, I changed the following.

"the the" -> "the"
"thse" -> "these"


Please let me know if my fix-up is bad.






> Unfortunately that is not compatible with the way the proposed new
> Kconfig macro language will work.
>
> After previous patches in this series, these flags can be carefully
> passed in using flags instead.
>
> Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
>
> Since v1: removed extra -EB in the recordmcount script (thanks mpe)
> ---
>  arch/powerpc/Makefile                          | 16 +++++++++-------
>  .../powerpc/tools/gcc-check-mprofile-kernel.sh | 12 ++++++++----
>  scripts/recordmcount.pl                        | 18 +++++++++++++++++-
>  3 files changed, 34 insertions(+), 12 deletions(-)
>
> diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
> index 167b26a0780c..6faf1d6ad9dd 100644
> --- a/arch/powerpc/Makefile
> +++ b/arch/powerpc/Makefile
> @@ -75,13 +75,15 @@ endif
>  endif
>
>  ifeq ($(CONFIG_CPU_LITTLE_ENDIAN),y)
> -override LD    += -EL
> +KBUILD_CFLAGS  += -mlittle-endian
> +LDFLAGS                += -EL
>  LDEMULATION    := lppc
>  GNUTARGET      := powerpcle
>  MULTIPLEWORD   := -mno-multiple
>  KBUILD_CFLAGS_MODULE += $(call cc-option,-mno-save-toc-indirect)
>  else
> -override LD    += -EB
> +KBUILD_CFLAGS += $(call cc-option,-mbig-endian)
> +LDFLAGS                += -EB
>  LDEMULATION    := ppc
>  GNUTARGET      := powerpc
>  MULTIPLEWORD   := -mmultiple
> @@ -94,19 +96,19 @@ aflags-$(CONFIG_CPU_BIG_ENDIAN)             += $(call cc-option,-mabi=elfv1)
>  aflags-$(CONFIG_CPU_LITTLE_ENDIAN)     += -mabi=elfv2
>  endif
>
> -cflags-$(CONFIG_CPU_LITTLE_ENDIAN)     += -mlittle-endian
> -cflags-$(CONFIG_CPU_BIG_ENDIAN)                += $(call cc-option,-mbig-endian)
>  ifneq ($(cc-name),clang)
>    cflags-$(CONFIG_CPU_LITTLE_ENDIAN)   += -mno-strict-align
>  endif
>
> +cflags-$(CONFIG_CPU_BIG_ENDIAN)                += $(call cc-option,-mbig-endian)
> +cflags-$(CONFIG_CPU_LITTLE_ENDIAN)     += -mlittle-endian
>  aflags-$(CONFIG_CPU_BIG_ENDIAN)                += $(call cc-option,-mbig-endian)
>  aflags-$(CONFIG_CPU_LITTLE_ENDIAN)     += -mlittle-endian
>
>  ifeq ($(HAS_BIARCH),y)
> -override AS    += -a$(BITS)
> -override LD    += -m elf$(BITS)$(LDEMULATION)
> -override CC    += -m$(BITS)
> +KBUILD_CFLAGS  += -m$(BITS)
> +KBUILD_AFLAGS  += -m$(BITS) -Wl,-a$(BITS)
> +LDFLAGS                += -m elf$(BITS)$(LDEMULATION)
>  KBUILD_ARFLAGS += --target=elf$(BITS)-$(GNUTARGET)
>  endif
>
> diff --git a/arch/powerpc/tools/gcc-check-mprofile-kernel.sh b/arch/powerpc/tools/gcc-check-mprofile-kernel.sh
> index 061f8035bdbe..a7dd0e5d9f98 100755
> --- a/arch/powerpc/tools/gcc-check-mprofile-kernel.sh
> +++ b/arch/powerpc/tools/gcc-check-mprofile-kernel.sh
> @@ -7,17 +7,21 @@ set -o pipefail
>  # To debug, uncomment the following line
>  # set -x
>
> +# -mprofile-kernel is only supported on 64le, so this should not be invoked
> +# for other targets. Therefore we can pass in -m64 and -mlittle-endian
> +# explicitly, to take care of toolchains defaulting to other targets.
> +
>  # Test whether the compile option -mprofile-kernel exists and generates
>  # profiling code (ie. a call to _mcount()).
>  echo "int func() { return 0; }" | \
> -    $* -S -x c -O2 -p -mprofile-kernel - -o - 2> /dev/null | \
> -    grep -q "_mcount"
> +    $* -m64 -mlittle-endian -S -x c -O2 -p -mprofile-kernel - -o - \
> +    2> /dev/null | grep -q "_mcount"
>
>  # Test whether the notrace attribute correctly suppresses calls to _mcount().
>
>  echo -e "#include <linux/compiler.h>\nnotrace int func() { return 0; }" | \
> -    $* -S -x c -O2 -p -mprofile-kernel - -o - 2> /dev/null | \
> -    grep -q "_mcount" && \
> +    $* -m64 -mlittle-endian -S -x c -O2 -p -mprofile-kernel - -o - \
> +    2> /dev/null | grep -q "_mcount" && \
>      exit 1
>
>  echo "OK"
> diff --git a/scripts/recordmcount.pl b/scripts/recordmcount.pl
> index 191eb949d52c..fe06e77c15eb 100755
> --- a/scripts/recordmcount.pl
> +++ b/scripts/recordmcount.pl
> @@ -266,13 +266,29 @@ if ($arch eq "x86_64") {
>      $objcopy .= " -O elf32-sh-linux";
>
>  } elsif ($arch eq "powerpc") {
> +    my $ldemulation;
> +
>      $local_regex = "^[0-9a-fA-F]+\\s+t\\s+(\\.?\\S+)";
>      # See comment in the sparc64 section for why we use '\w'.
>      $function_regex = "^([0-9a-fA-F]+)\\s+<(\\.?\\w*?)>:";
>      $mcount_regex = "^\\s*([0-9a-fA-F]+):.*\\s\\.?_mcount\$";
>
> +    if ($endian eq "big") {
> +           $cc .= " -mbig-endian ";
> +           $ld .= " -EB ";
> +           $ldemulation = "ppc"
> +    } else {
> +           $cc .= " -mlittle-endian ";
> +           $ld .= " -EL ";
> +           $ldemulation = "lppc"
> +    }
>      if ($bits == 64) {
> -       $type = ".quad";
> +        $type = ".quad";
> +        $cc .= " -m64 ";
> +        $ld .= " -m elf64".$ldemulation." ";
> +    } else {
> +        $cc .= " -m32 ";
> +        $ld .= " -m elf32".$ldemulation." ";
>      }
>
>  } elsif ($arch eq "arm") {
> --
> 2.17.0
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html



-- 
Best Regards
Masahiro Yamada

^ permalink raw reply

* Re: [PATCH v5 0/4] powerpc patches for new Kconfig language
From: Michael Ellerman @ 2018-05-30 14:39 UTC (permalink / raw)
  To: Nicholas Piggin, linux-kbuild
  Cc: Masahiro Yamada, linuxppc-dev, Nicholas Piggin
In-Reply-To: <20180530121922.22122-1-npiggin@gmail.com>

Nicholas Piggin <npiggin@gmail.com> writes:

> This series of patches improves th powerpc kbuild system. The
> motivation was to to be compatible with the new Kconfig scripting
> language that Yamada-san has implemented here for merge:
>
> https://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild.git/log/?h=kconfig
>
> I have tested on top of that tree, powerpc now builds there.
>
> To avoid build breakage, the first 3 patches must go before the
> kconfig change, and the 4th patch must go after it.
>
> v5 changes:
> - Patch 4 update to syntax changed since kconfig-shell-v3 release.
> - Patch 4 suggestions from Masahiro Yamada, remove unnecessary "OK"
>   output from check mprofile script, and fold CC_USING_MPROFILE_KERNEL
>   into CONFIG_MPROFILE_KERNEL.
> - Reduce whitespace disturbance in patch 1.

I've put this series in a topic branch.

  https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git/log/?h=topic/kbuild


I'll plan to merge the first three into the powerpc tree.

Masahiro, are you planning to merge your kconfig changes for 4.18? If so
you could merge the whole branch and everything should merge nicely.

cheers

^ permalink raw reply

* Re: [PATCH v5 0/4] powerpc patches for new Kconfig language
From: Masahiro Yamada @ 2018-05-30 14:57 UTC (permalink / raw)
  To: Michael Ellerman; +Cc: Nicholas Piggin, Linux Kbuild mailing list, linuxppc-dev
In-Reply-To: <87o9gxyzpo.fsf@concordia.ellerman.id.au>

2018-05-30 23:39 GMT+09:00 Michael Ellerman <mpe@ellerman.id.au>:
> Nicholas Piggin <npiggin@gmail.com> writes:
>
>> This series of patches improves th powerpc kbuild system. The
>> motivation was to to be compatible with the new Kconfig scripting
>> language that Yamada-san has implemented here for merge:
>>
>> https://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild.git/log/?h=kconfig
>>
>> I have tested on top of that tree, powerpc now builds there.
>>
>> To avoid build breakage, the first 3 patches must go before the
>> kconfig change, and the 4th patch must go after it.
>>
>> v5 changes:
>> - Patch 4 update to syntax changed since kconfig-shell-v3 release.
>> - Patch 4 suggestions from Masahiro Yamada, remove unnecessary "OK"
>>   output from check mprofile script, and fold CC_USING_MPROFILE_KERNEL
>>   into CONFIG_MPROFILE_KERNEL.
>> - Reduce whitespace disturbance in patch 1.
>
> I've put this series in a topic branch.
>
>   https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git/log/?h=topic/kbuild


No, you can't.

This series depends on my Kconfig work.

You queued it up on v4.17-rc3,
but necessary patches are not there.

You will get build errors.


>
> I'll plan to merge the first three into the powerpc tree.

Please do not do this.

You can issue Acked-by instead.


I need all the 4 patches to my tree.
Otherwise, the git-bisect'ability breaks for PowerPC.

See, the PPC breakage report from Stephen Rothwell
https://lkml.org/lkml/2018/5/29/1296




> Masahiro, are you planning to merge your kconfig changes for 4.18? If so
> you could merge the whole branch and everything should merge nicely.

Yes.

I already queued my and Nicholas' patches.

git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild kconfig


Nicholas,

Please check if the patch order is correct.


I need to insert 'powerpc/kbuild' patches between.



> cheers
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html



-- 
Best Regards
Masahiro Yamada

^ permalink raw reply

* Re: [RFC PATCH] powerpc/fsl: Add barrier_nospec implementation for NXP PowerPC Book E
From: Diana Madalina Craciun @ 2018-05-30 15:09 UTC (permalink / raw)
  To: Scott Wood, linuxppc-dev@lists.ozlabs.org; +Cc: mpe@ellerman.id.au, Leo Li
In-Reply-To: <1527621245.30674.30.camel@buserror.net>

On 05/29/2018 10:16 PM, Scott Wood wrote:=0A=
> On Tue, 2018-05-29 at 15:22 +0000, Diana Madalina Craciun wrote:=0A=
>> Hi Scott,=0A=
>>=0A=
>> Thanks for the review.=0A=
>>=0A=
>> On 05/22/2018 11:31 PM, Scott Wood wrote:=0A=
>>> On Tue, 2018-05-22 at 10:10 +0300, Diana Craciun wrote:=0A=
>>>> Implement the barrier_nospec as a isync;sync instruction sequence.=0A=
>>>> The implementation uses the infrastructure built for BOOK3S 64=0A=
>>>> with the difference that for NXP platforms there is no firmware involv=
ed=0A=
>>>> and the need for a speculation barrier is read from the device tree.=
=0A=
>>>> I have used the same name for the property:=0A=
>>>> fsl,needs-spec-barrier-for-bounds-check=0A=
>>> Using the device tree this way means that anyone without an updated dev=
ice=0A=
>>> tree won't get the protection.  I also don't see any device tree update=
s=0A=
>>> --=0A=
>>> which chips are affected?=0A=
>> I was planning to have the device tree changes in a different patch-set.=
=0A=
>> The affected cores are e500, e500mc, e5500, e6500.=0A=
> So, all supported FSL/NXP book E chips.  Why not just enable the workarou=
nd=0A=
> unconditionally (and revisit if NXP ever produces a book E chip that does=
n't=0A=
> need it and/or e200 is ever supported if that's simple enough to be immun=
e)?=0A=
=0A=
I think it makes sense having in mind that all the NXP book E chips are=0A=
vulnerable. e200 is not vulnerable, but it is not properly supported in=0A=
the kernel anyway. So I guess I can enable the workaround=0A=
unconditionally. I am wondering if it does make sense patching the=0A=
instructions at all (instead just use the barrier as an isync; sync=0A=
sequence always), but in this case we will loose the possibility of=0A=
controlling it via debugfs at runtime.=0A=
=0A=
>=0A=
>>> Why patch nops in if not enabled?  Aren't those locations already=0A=
>>> nops?  For=0A=
>>> that matter, how can this function even be called on FSL_BOOK3E with=0A=
>>> enable !=3D=0A=
>>> true?=0A=
>> There is some code in arch/powerpc/kernel/security.c which allows=0A=
>> control of barrier_nospec via debugfs.=0A=
> OK.=0A=
>=0A=
>>> Should there be a way for the user to choose not to enable this (editin=
g=0A=
>>> the=0A=
>>> device tree doesn't count), for a use case that is not sufficiently=0A=
>>> security=0A=
>>> sensitive to justify the performance loss?  What is the performance imp=
act=0A=
>>> of=0A=
>>> this patch?=0A=
>> My reason was that on the other architectures Spectre variant 1=0A=
>> mitigations are not disabled either. But I think that it might be a good=
=0A=
>> idea to add a bootarg parameter to disable the barrier.=0A=
> Is there a specific policy reason why they allow spectre v2 to be disable=
d but=0A=
> not v1, or just a matter of not having a mechanism to disable it, or the =
parts=0A=
> which could practically be disabled not impacting performance much?=0A=
=0A=
I do not know for sure but I can speculate. The other architectures read=0A=
some flags set by the firmware, so I might think that they might use=0A=
different versions of firmware if they do not want the mitigations. On=0A=
the other hand the other architectures defined special barriers just for=0A=
the purpose of preventing speculations which might be more lightweight=0A=
and maybe they are not impacting the performance much. But having in=0A=
mind that the NXP parts are used in embedded scenarios that might run in=0A=
isolation (so no vulnerability) and that the barrier we are using is not=0A=
that lightweight I think that we should have a way to disable it.=0A=
=0A=
Diana=0A=
=0A=

^ permalink raw reply

* [RFC PATCH 1/8] powerpc: remove kdump.h from page.h
From: Christophe Leroy @ 2018-05-30 16:41 UTC (permalink / raw)
  To: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman
  Cc: linux-kernel, linuxppc-dev
In-Reply-To: <cover.1527697995.git.christophe.leroy@c-s.fr>

page.h doesn't need kdump.h

Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
---
 arch/powerpc/include/asm/page.h | 1 -
 arch/powerpc/kernel/setup_32.c  | 1 +
 2 files changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/powerpc/include/asm/page.h b/arch/powerpc/include/asm/page.h
index db7be0779d55..a9fbefaacf10 100644
--- a/arch/powerpc/include/asm/page.h
+++ b/arch/powerpc/include/asm/page.h
@@ -17,7 +17,6 @@
 #include <asm/types.h>
 #endif
 #include <asm/asm-compat.h>
-#include <asm/kdump.h>
 
 /*
  * On regular PPC32 page size is 4K (but we support 4K/16K/64K/256K pages
diff --git a/arch/powerpc/kernel/setup_32.c b/arch/powerpc/kernel/setup_32.c
index 74457485574b..ef747a5a30b9 100644
--- a/arch/powerpc/kernel/setup_32.c
+++ b/arch/powerpc/kernel/setup_32.c
@@ -40,6 +40,7 @@
 #include <asm/code-patching.h>
 #include <asm/cpu_has_feature.h>
 #include <asm/asm-prototypes.h>
+#include <asm/kdump.h>
 
 #define DBG(fmt...)
 
-- 
2.13.3

^ permalink raw reply related

* [RFC PATCH 0/8] Remove unneccessary included headers
From: Christophe Leroy @ 2018-05-30 16:41 UTC (permalink / raw)
  To: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman
  Cc: linux-kernel, linuxppc-dev

The purpose of this serie is to limit the number of includes to
only the necessary ones in order to reduce the number of files
recompiled everytime a header file is modified.

This is the start of the work, please provide feedback if any so
that I don't go in the wrong direction.

Christophe Leroy (8):
  powerpc: remove kdump.h from page.h
  powerpc: remove unneeded inclusions of cpu_has_feature.h
  powerpc: remove superflous inclusions of asm-compat.h
  powerpc: remove superflous inclusions of asm/feature-fixups.h
  powerpc: remove superflous inclusions of asm/fixmap.h
  powerpc: declare set_breakpoint() static
  powerpc/book3s: Remove PPC_PIN_SIZE
  powerpc: fix includes in asm/processor.h

 arch/powerpc/include/asm/book3s/32/pgtable.h |  5 -----
 arch/powerpc/include/asm/cacheflush.h        |  1 -
 arch/powerpc/include/asm/cputable.h          |  2 --
 arch/powerpc/include/asm/cputime.h           |  1 -
 arch/powerpc/include/asm/dbell.h             |  1 -
 arch/powerpc/include/asm/debug.h             |  1 -
 arch/powerpc/include/asm/dt_cpu_ftrs.h       |  3 ---
 arch/powerpc/include/asm/feature-fixups.h    |  2 ++
 arch/powerpc/include/asm/firmware.h          |  1 -
 arch/powerpc/include/asm/fixmap.h            |  2 --
 arch/powerpc/include/asm/hw_breakpoint.h     |  1 +
 arch/powerpc/include/asm/mmu.h               |  1 -
 arch/powerpc/include/asm/nohash/32/pgtable.h |  2 +-
 arch/powerpc/include/asm/page.h              |  1 -
 arch/powerpc/include/asm/ppc-opcode.h        |  1 -
 arch/powerpc/include/asm/processor.h         |  5 ++---
 arch/powerpc/include/asm/reg.h               |  1 +
 arch/powerpc/kernel/head_8xx.S               |  1 -
 arch/powerpc/kernel/process.c                | 14 +++++++-------
 arch/powerpc/kernel/setup_32.c               |  1 +
 arch/powerpc/kernel/vdso.c                   |  1 -
 arch/powerpc/mm/dump_hashpagetable.c         |  1 -
 arch/powerpc/sysdev/cpm_common.c             |  1 -
 23 files changed, 15 insertions(+), 35 deletions(-)

-- 
2.13.3

^ permalink raw reply

* [RFC PATCH 2/8] powerpc: remove unneeded inclusions of cpu_has_feature.h
From: Christophe Leroy @ 2018-05-30 16:41 UTC (permalink / raw)
  To: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman
  Cc: linux-kernel, linuxppc-dev
In-Reply-To: <cover.1527697995.git.christophe.leroy@c-s.fr>

Files not using cpu_has_feature() don't need cpu_has_feature.h

Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
---
 arch/powerpc/include/asm/cacheflush.h  | 1 -
 arch/powerpc/include/asm/cputime.h     | 1 -
 arch/powerpc/include/asm/dbell.h       | 1 -
 arch/powerpc/include/asm/dt_cpu_ftrs.h | 3 ---
 arch/powerpc/kernel/vdso.c             | 1 -
 5 files changed, 7 deletions(-)

diff --git a/arch/powerpc/include/asm/cacheflush.h b/arch/powerpc/include/asm/cacheflush.h
index 11843e37d9cf..cfe3a98349c4 100644
--- a/arch/powerpc/include/asm/cacheflush.h
+++ b/arch/powerpc/include/asm/cacheflush.h
@@ -11,7 +11,6 @@
 
 #include <linux/mm.h>
 #include <asm/cputable.h>
-#include <asm/cpu_has_feature.h>
 
 /*
  * No cache flushing is required when address mappings are changed,
diff --git a/arch/powerpc/include/asm/cputime.h b/arch/powerpc/include/asm/cputime.h
index 99b541865d8d..d78fee0cdbf0 100644
--- a/arch/powerpc/include/asm/cputime.h
+++ b/arch/powerpc/include/asm/cputime.h
@@ -23,7 +23,6 @@
 #include <asm/div64.h>
 #include <asm/time.h>
 #include <asm/param.h>
-#include <asm/cpu_has_feature.h>
 
 typedef u64 __nocast cputime_t;
 typedef u64 __nocast cputime64_t;
diff --git a/arch/powerpc/include/asm/dbell.h b/arch/powerpc/include/asm/dbell.h
index 9f2ae0d25e15..998c42ff1caa 100644
--- a/arch/powerpc/include/asm/dbell.h
+++ b/arch/powerpc/include/asm/dbell.h
@@ -16,7 +16,6 @@
 #include <linux/threads.h>
 
 #include <asm/ppc-opcode.h>
-#include <asm/cpu_has_feature.h>
 
 #define PPC_DBELL_MSG_BRDCAST	(0x04000000)
 #define PPC_DBELL_TYPE(x)	(((x) & 0xf) << (63-36))
diff --git a/arch/powerpc/include/asm/dt_cpu_ftrs.h b/arch/powerpc/include/asm/dt_cpu_ftrs.h
index 71515d909ed1..40165eea22ee 100644
--- a/arch/powerpc/include/asm/dt_cpu_ftrs.h
+++ b/arch/powerpc/include/asm/dt_cpu_ftrs.h
@@ -10,9 +10,6 @@
  */
 
 #include <linux/types.h>
-#include <asm/asm-compat.h>
-#include <asm/feature-fixups.h>
-#include <uapi/asm/cputable.h>
 
 #ifdef CONFIG_PPC_DT_CPU_FTRS
 bool dt_cpu_ftrs_init(void *fdt);
diff --git a/arch/powerpc/kernel/vdso.c b/arch/powerpc/kernel/vdso.c
index b44ec104a5a1..63b4e4485b00 100644
--- a/arch/powerpc/kernel/vdso.c
+++ b/arch/powerpc/kernel/vdso.c
@@ -22,7 +22,6 @@
 #include <linux/security.h>
 #include <linux/memblock.h>
 
-#include <asm/cpu_has_feature.h>
 #include <asm/pgtable.h>
 #include <asm/processor.h>
 #include <asm/mmu.h>
-- 
2.13.3

^ permalink raw reply related

* [RFC PATCH 3/8] powerpc: remove superflous inclusions of asm-compat.h
From: Christophe Leroy @ 2018-05-30 16:41 UTC (permalink / raw)
  To: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman
  Cc: linux-kernel, linuxppc-dev
In-Reply-To: <cover.1527697995.git.christophe.leroy@c-s.fr>

ppc-opcode.h doesn't need asm-compat.h
neither does dt_cpu_ftrs.h

Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
---
 arch/powerpc/include/asm/cputable.h       | 1 -
 arch/powerpc/include/asm/feature-fixups.h | 2 ++
 arch/powerpc/include/asm/ppc-opcode.h     | 1 -
 3 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/include/asm/cputable.h b/arch/powerpc/include/asm/cputable.h
index 66fcab13c8b4..7518dafa7cd4 100644
--- a/arch/powerpc/include/asm/cputable.h
+++ b/arch/powerpc/include/asm/cputable.h
@@ -4,7 +4,6 @@
 
 
 #include <linux/types.h>
-#include <asm/asm-compat.h>
 #include <asm/feature-fixups.h>
 #include <uapi/asm/cputable.h>
 
diff --git a/arch/powerpc/include/asm/feature-fixups.h b/arch/powerpc/include/asm/feature-fixups.h
index a9b64df34e2a..ecfdf9d3d145 100644
--- a/arch/powerpc/include/asm/feature-fixups.h
+++ b/arch/powerpc/include/asm/feature-fixups.h
@@ -1,6 +1,8 @@
 #ifndef __ASM_POWERPC_FEATURE_FIXUPS_H
 #define __ASM_POWERPC_FEATURE_FIXUPS_H
 
+#include <asm/asm-compat.h>
+
 /*
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
diff --git a/arch/powerpc/include/asm/ppc-opcode.h b/arch/powerpc/include/asm/ppc-opcode.h
index 4436887bc415..ab12fac26f5b 100644
--- a/arch/powerpc/include/asm/ppc-opcode.h
+++ b/arch/powerpc/include/asm/ppc-opcode.h
@@ -13,7 +13,6 @@
 #define _ASM_POWERPC_PPC_OPCODE_H
 
 #include <linux/stringify.h>
-#include <asm/asm-compat.h>
 
 #define	__REG_R0	0
 #define	__REG_R1	1
-- 
2.13.3

^ permalink raw reply related

* [RFC PATCH 4/8] powerpc: remove superflous inclusions of asm/feature-fixups.h
From: Christophe Leroy @ 2018-05-30 16:41 UTC (permalink / raw)
  To: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman
  Cc: linux-kernel, linuxppc-dev
In-Reply-To: <cover.1527697995.git.christophe.leroy@c-s.fr>

files not using feature fixup don't need asm/feature-fixups.h

Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
---
 arch/powerpc/include/asm/cputable.h | 1 -
 arch/powerpc/include/asm/firmware.h | 1 -
 arch/powerpc/include/asm/mmu.h      | 1 -
 arch/powerpc/include/asm/reg.h      | 1 +
 4 files changed, 1 insertion(+), 3 deletions(-)

diff --git a/arch/powerpc/include/asm/cputable.h b/arch/powerpc/include/asm/cputable.h
index 7518dafa7cd4..e99905274a77 100644
--- a/arch/powerpc/include/asm/cputable.h
+++ b/arch/powerpc/include/asm/cputable.h
@@ -4,7 +4,6 @@
 
 
 #include <linux/types.h>
-#include <asm/feature-fixups.h>
 #include <uapi/asm/cputable.h>
 
 #ifndef __ASSEMBLY__
diff --git a/arch/powerpc/include/asm/firmware.h b/arch/powerpc/include/asm/firmware.h
index 535add3f7791..59ae44cf0bb8 100644
--- a/arch/powerpc/include/asm/firmware.h
+++ b/arch/powerpc/include/asm/firmware.h
@@ -15,7 +15,6 @@
 #ifdef __KERNEL__
 
 #include <asm/asm-compat.h>
-#include <asm/feature-fixups.h>
 
 /* firmware feature bitmask values */
 
diff --git a/arch/powerpc/include/asm/mmu.h b/arch/powerpc/include/asm/mmu.h
index 61d15ce92278..61d0d2d69583 100644
--- a/arch/powerpc/include/asm/mmu.h
+++ b/arch/powerpc/include/asm/mmu.h
@@ -6,7 +6,6 @@
 #include <linux/types.h>
 
 #include <asm/asm-compat.h>
-#include <asm/feature-fixups.h>
 
 /*
  * MMU features bit definitions
diff --git a/arch/powerpc/include/asm/reg.h b/arch/powerpc/include/asm/reg.h
index cb0f272ce123..a7b8860ed896 100644
--- a/arch/powerpc/include/asm/reg.h
+++ b/arch/powerpc/include/asm/reg.h
@@ -13,6 +13,7 @@
 
 #include <linux/stringify.h>
 #include <asm/cputable.h>
+#include <asm/feature-fixups.h>
 
 /* Pickup Book E specific registers. */
 #if defined(CONFIG_BOOKE) || defined(CONFIG_40x)
-- 
2.13.3

^ permalink raw reply related

* [RFC PATCH 5/8] powerpc: remove superflous inclusions of asm/fixmap.h
From: Christophe Leroy @ 2018-05-30 16:41 UTC (permalink / raw)
  To: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman
  Cc: linux-kernel, linuxppc-dev
In-Reply-To: <cover.1527697995.git.christophe.leroy@c-s.fr>

Files not using fixmap consts or functions don't need asm/fixmap.h

Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
---
 arch/powerpc/include/asm/fixmap.h    | 2 --
 arch/powerpc/kernel/head_8xx.S       | 1 -
 arch/powerpc/mm/dump_hashpagetable.c | 1 -
 arch/powerpc/sysdev/cpm_common.c     | 1 -
 4 files changed, 5 deletions(-)

diff --git a/arch/powerpc/include/asm/fixmap.h b/arch/powerpc/include/asm/fixmap.h
index 6c40dfda5912..40efdf1d2d6e 100644
--- a/arch/powerpc/include/asm/fixmap.h
+++ b/arch/powerpc/include/asm/fixmap.h
@@ -15,9 +15,7 @@
 #define _ASM_FIXMAP_H
 
 #ifndef __ASSEMBLY__
-#include <linux/kernel.h>
 #include <asm/page.h>
-#include <asm/pgtable.h>
 #ifdef CONFIG_HIGHMEM
 #include <linux/threads.h>
 #include <asm/kmap_types.h>
diff --git a/arch/powerpc/kernel/head_8xx.S b/arch/powerpc/kernel/head_8xx.S
index 6cab07e76732..95f6bdc0718f 100644
--- a/arch/powerpc/kernel/head_8xx.S
+++ b/arch/powerpc/kernel/head_8xx.S
@@ -30,7 +30,6 @@
 #include <asm/ppc_asm.h>
 #include <asm/asm-offsets.h>
 #include <asm/ptrace.h>
-#include <asm/fixmap.h>
 #include <asm/export.h>
 
 #if CONFIG_TASK_SIZE <= 0x80000000 && CONFIG_PAGE_OFFSET >= 0x80000000
diff --git a/arch/powerpc/mm/dump_hashpagetable.c b/arch/powerpc/mm/dump_hashpagetable.c
index 14cfb11b09d0..ddffb1513ddc 100644
--- a/arch/powerpc/mm/dump_hashpagetable.c
+++ b/arch/powerpc/mm/dump_hashpagetable.c
@@ -19,7 +19,6 @@
 #include <linux/mm.h>
 #include <linux/sched.h>
 #include <linux/seq_file.h>
-#include <asm/fixmap.h>
 #include <asm/pgtable.h>
 #include <linux/const.h>
 #include <asm/page.h>
diff --git a/arch/powerpc/sysdev/cpm_common.c b/arch/powerpc/sysdev/cpm_common.c
index b74508175b67..010975c3422f 100644
--- a/arch/powerpc/sysdev/cpm_common.c
+++ b/arch/powerpc/sysdev/cpm_common.c
@@ -28,7 +28,6 @@
 #include <asm/udbg.h>
 #include <asm/io.h>
 #include <asm/cpm.h>
-#include <asm/fixmap.h>
 #include <soc/fsl/qe/qe.h>
 
 #include <mm/mmu_decl.h>
-- 
2.13.3

^ permalink raw reply related

* [RFC PATCH 6/8] powerpc: declare set_breakpoint() static
From: Christophe Leroy @ 2018-05-30 16:41 UTC (permalink / raw)
  To: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman
  Cc: linux-kernel, linuxppc-dev
In-Reply-To: <cover.1527697995.git.christophe.leroy@c-s.fr>

set_breakpoint() is only used in process.c so make it static

Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
---
 arch/powerpc/include/asm/debug.h |  1 -
 arch/powerpc/kernel/process.c    | 14 +++++++-------
 2 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/arch/powerpc/include/asm/debug.h b/arch/powerpc/include/asm/debug.h
index ce5da214ffe5..7756026b95ca 100644
--- a/arch/powerpc/include/asm/debug.h
+++ b/arch/powerpc/include/asm/debug.h
@@ -45,7 +45,6 @@ static inline int debugger_break_match(struct pt_regs *regs) { return 0; }
 static inline int debugger_fault_handler(struct pt_regs *regs) { return 0; }
 #endif
 
-void set_breakpoint(struct arch_hw_breakpoint *brk);
 void __set_breakpoint(struct arch_hw_breakpoint *brk);
 bool ppc_breakpoint_available(void);
 #ifdef CONFIG_PPC_ADV_DEBUG_REGS
diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
index 1237f13fed51..3e66cf6f7f95 100644
--- a/arch/powerpc/kernel/process.c
+++ b/arch/powerpc/kernel/process.c
@@ -714,6 +714,13 @@ void switch_booke_debug_regs(struct debug_reg *new_debug)
 EXPORT_SYMBOL_GPL(switch_booke_debug_regs);
 #else	/* !CONFIG_PPC_ADV_DEBUG_REGS */
 #ifndef CONFIG_HAVE_HW_BREAKPOINT
+static void set_breakpoint(struct arch_hw_breakpoint *brk)
+{
+	preempt_disable();
+	__set_breakpoint(brk);
+	preempt_enable();
+}
+
 static void set_debug_reg_defaults(struct thread_struct *thread)
 {
 	thread->hw_brk.address = 0;
@@ -826,13 +833,6 @@ void __set_breakpoint(struct arch_hw_breakpoint *brk)
 		WARN_ON_ONCE(1);
 }
 
-void set_breakpoint(struct arch_hw_breakpoint *brk)
-{
-	preempt_disable();
-	__set_breakpoint(brk);
-	preempt_enable();
-}
-
 /* Check if we have DAWR or DABR hardware */
 bool ppc_breakpoint_available(void)
 {
-- 
2.13.3

^ permalink raw reply related

* [RFC PATCH 7/8] powerpc/book3s: Remove PPC_PIN_SIZE
From: Christophe Leroy @ 2018-05-30 16:41 UTC (permalink / raw)
  To: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman
  Cc: linux-kernel, linuxppc-dev
In-Reply-To: <cover.1527697995.git.christophe.leroy@c-s.fr>

PPC_PIN_SIZE is specific to the 44x and is defined in mmu.h

Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
---
 arch/powerpc/include/asm/book3s/32/pgtable.h | 5 -----
 arch/powerpc/include/asm/nohash/32/pgtable.h | 2 +-
 2 files changed, 1 insertion(+), 6 deletions(-)

diff --git a/arch/powerpc/include/asm/book3s/32/pgtable.h b/arch/powerpc/include/asm/book3s/32/pgtable.h
index c615abdce119..0603479d04c3 100644
--- a/arch/powerpc/include/asm/book3s/32/pgtable.h
+++ b/arch/powerpc/include/asm/book3s/32/pgtable.h
@@ -84,17 +84,12 @@
  * of RAM.  -- Cort
  */
 #define VMALLOC_OFFSET (0x1000000) /* 16M */
-#ifdef PPC_PIN_SIZE
-#define VMALLOC_START (((_ALIGN((long)high_memory, PPC_PIN_SIZE) + VMALLOC_OFFSET) & ~(VMALLOC_OFFSET-1)))
-#else
 #define VMALLOC_START ((((long)high_memory + VMALLOC_OFFSET) & ~(VMALLOC_OFFSET-1)))
-#endif
 #define VMALLOC_END	ioremap_bot
 
 #ifndef __ASSEMBLY__
 #include <linux/sched.h>
 #include <linux/threads.h>
-#include <asm/io.h>			/* For sub-arch specific PPC_PIN_SIZE */
 
 extern unsigned long ioremap_bot;
 
diff --git a/arch/powerpc/include/asm/nohash/32/pgtable.h b/arch/powerpc/include/asm/nohash/32/pgtable.h
index 987a658b18e1..35fa43c20b6e 100644
--- a/arch/powerpc/include/asm/nohash/32/pgtable.h
+++ b/arch/powerpc/include/asm/nohash/32/pgtable.h
@@ -8,7 +8,7 @@
 #ifndef __ASSEMBLY__
 #include <linux/sched.h>
 #include <linux/threads.h>
-#include <asm/io.h>			/* For sub-arch specific PPC_PIN_SIZE */
+#include <asm/mmu.h>			/* For sub-arch specific PPC_PIN_SIZE */
 
 extern unsigned long ioremap_bot;
 
-- 
2.13.3

^ permalink raw reply related

* [RFC PATCH 8/8] powerpc: fix includes in asm/processor.h
From: Christophe Leroy @ 2018-05-30 16:42 UTC (permalink / raw)
  To: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman
  Cc: linux-kernel, linuxppc-dev
In-Reply-To: <cover.1527697995.git.christophe.leroy@c-s.fr>

Remove superflous includes and add missing ones

Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
---
 arch/powerpc/include/asm/hw_breakpoint.h | 1 +
 arch/powerpc/include/asm/processor.h     | 5 ++---
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/powerpc/include/asm/hw_breakpoint.h b/arch/powerpc/include/asm/hw_breakpoint.h
index 8e7b09703ca4..3637588d3f6d 100644
--- a/arch/powerpc/include/asm/hw_breakpoint.h
+++ b/arch/powerpc/include/asm/hw_breakpoint.h
@@ -55,6 +55,7 @@ struct arch_hw_breakpoint {
 struct perf_event;
 struct pmu;
 struct perf_sample_data;
+struct task_struct;
 
 #define HW_BREAKPOINT_ALIGN 0x7
 
diff --git a/arch/powerpc/include/asm/processor.h b/arch/powerpc/include/asm/processor.h
index c4b36a494a63..74ed654928f0 100644
--- a/arch/powerpc/include/asm/processor.h
+++ b/arch/powerpc/include/asm/processor.h
@@ -39,10 +39,9 @@
 #endif /* CONFIG_PPC64 */
 
 #ifndef __ASSEMBLY__
-#include <linux/compiler.h>
-#include <linux/cache.h>
+#include <linux/types.h>
+#include <asm/thread_info.h>
 #include <asm/ptrace.h>
-#include <asm/types.h>
 #include <asm/hw_breakpoint.h>
 
 /* We do _not_ want to define new machine types at all, those must die
-- 
2.13.3

^ permalink raw reply related

* [powerpc:topic/kbuild 4/4] arch/powerpc/Kconfig:466: syntax error
From: kbuild test robot @ 2018-05-30 18:26 UTC (permalink / raw)
  To: Nicholas Piggin; +Cc: kbuild-all, linuxppc-dev, Michael Ellerman

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git topic/kbuild
head:   cfff26c2dc7a18a4d10366896a68fb0ef9c793cb
commit: cfff26c2dc7a18a4d10366896a68fb0ef9c793cb [4/4] powerpc/kbuild: move -mprofile-kernel check to Kconfig
config: powerpc-allmodconfig
compiler: powerpc64-linux-gnu-gcc (Debian 7.2.0-11) 7.2.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        git checkout cfff26c2dc7a18a4d10366896a68fb0ef9c793cb
        make.cross ARCH=powerpc  allmodconfig
        make.cross ARCH=powerpc 

All errors (new ones prefixed by >>):

   arch/powerpc/Kconfig:465:warning: ignoring unsupported character '$'
   arch/powerpc/Kconfig:465:warning: ignoring unsupported character ','
   arch/powerpc/Kconfig:465:warning: ignoring unsupported character '$'
>> arch/powerpc/Kconfig:466: syntax error
   arch/powerpc/Kconfig:465:warning: ignoring unsupported character '$'
   arch/powerpc/Kconfig:465:warning: ignoring unsupported character '$'
>> arch/powerpc/Kconfig:465: invalid option
   make[2]: *** [allmodconfig] Error 1
   make[1]: *** [allmodconfig] Error 2
   make: *** [sub-make] Error 2
--
   arch/powerpc/Kconfig:465:warning: ignoring unsupported character '$'
   arch/powerpc/Kconfig:465:warning: ignoring unsupported character ','
   arch/powerpc/Kconfig:465:warning: ignoring unsupported character '$'
>> arch/powerpc/Kconfig:466: syntax error
   arch/powerpc/Kconfig:465:warning: ignoring unsupported character '$'
   arch/powerpc/Kconfig:465:warning: ignoring unsupported character '$'
>> arch/powerpc/Kconfig:465: invalid option
   make[2]: *** [oldconfig] Error 1
   make[1]: *** [oldconfig] Error 2
   make: *** [sub-make] Error 2
--
   arch/powerpc/Kconfig:465:warning: ignoring unsupported character '$'
   arch/powerpc/Kconfig:465:warning: ignoring unsupported character ','
   arch/powerpc/Kconfig:465:warning: ignoring unsupported character '$'
>> arch/powerpc/Kconfig:466: syntax error
   arch/powerpc/Kconfig:465:warning: ignoring unsupported character '$'
   arch/powerpc/Kconfig:465:warning: ignoring unsupported character '$'
>> arch/powerpc/Kconfig:465: invalid option
   make[2]: *** [olddefconfig] Error 1
   make[2]: Target 'oldnoconfig' not remade because of errors.
   make[1]: *** [oldnoconfig] Error 2
   make: *** [sub-make] Error 2

vim +466 arch/powerpc/Kconfig

e05c0e81 Kevin Hao       2013-07-16  441  
3d72bbc4 Michael Neuling 2013-02-13  442  config PPC_TRANSACTIONAL_MEM
3d72bbc4 Michael Neuling 2013-02-13  443         bool "Transactional Memory support for POWERPC"
3d72bbc4 Michael Neuling 2013-02-13  444         depends on PPC_BOOK3S_64
3d72bbc4 Michael Neuling 2013-02-13  445         depends on SMP
7b37a123 Michael Neuling 2014-01-08  446         select ALTIVEC
7b37a123 Michael Neuling 2014-01-08  447         select VSX
3d72bbc4 Michael Neuling 2013-02-13  448         default n
3d72bbc4 Michael Neuling 2013-02-13  449         ---help---
3d72bbc4 Michael Neuling 2013-02-13  450           Support user-mode Transactional Memory on POWERPC.
3d72bbc4 Michael Neuling 2013-02-13  451  
951eedeb Nicholas Piggin 2017-05-29  452  config LD_HEAD_STUB_CATCH
951eedeb Nicholas Piggin 2017-05-29  453  	bool "Reserve 256 bytes to cope with linker stubs in HEAD text" if EXPERT
951eedeb Nicholas Piggin 2017-05-29  454  	depends on PPC64
951eedeb Nicholas Piggin 2017-05-29  455  	default n
951eedeb Nicholas Piggin 2017-05-29  456  	help
951eedeb Nicholas Piggin 2017-05-29  457  	  Very large kernels can cause linker branch stubs to be generated by
951eedeb Nicholas Piggin 2017-05-29  458  	  code in head_64.S, which moves the head text sections out of their
951eedeb Nicholas Piggin 2017-05-29  459  	  specified location. This option can work around the problem.
951eedeb Nicholas Piggin 2017-05-29  460  
951eedeb Nicholas Piggin 2017-05-29  461  	  If unsure, say "N".
951eedeb Nicholas Piggin 2017-05-29  462  
8c50b72a Torsten Duwe    2016-03-03  463  config MPROFILE_KERNEL
8c50b72a Torsten Duwe    2016-03-03  464  	depends on PPC64 && CPU_LITTLE_ENDIAN
cfff26c2 Nicholas Piggin 2018-05-30 @465  	def_bool $(success,$(srctree)/arch/powerpc/tools/gcc-check-mprofile-kernel.sh $(CC) -I$(srctree)/include -D__KERNEL__)
8c50b72a Torsten Duwe    2016-03-03 @466  

:::::: The code at line 466 was first introduced by commit
:::::: 8c50b72a3b4f1f7cdfdfebd233b1cbd121262e65 powerpc/ftrace: Add Kconfig & Make glue for mprofile-kernel

:::::: TO: Torsten Duwe <duwe@lst.de>
:::::: CC: Michael Ellerman <mpe@ellerman.id.au>

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

^ permalink raw reply

* Re: [PATCH] powerpc/cell: fix build failure by disabling attribute-alias warning
From: kbuild test robot @ 2018-05-30 21:42 UTC (permalink / raw)
  To: Christophe Leroy
  Cc: kbuild-all, Benjamin Herrenschmidt, Paul Mackerras,
	Michael Ellerman, Arnd Bergmann, linux-kernel, linuxppc-dev
In-Reply-To: <97b30159fb712dcdb7ea2fa748fed45f0a18e2eb.1527576934.git.christophe.leroy@c-s.fr>

[-- Attachment #1: Type: text/plain, Size: 2169 bytes --]

Hi Christophe,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on powerpc/next]
[also build test ERROR on v4.17-rc7 next-20180530]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Christophe-Leroy/powerpc-cell-fix-build-failure-by-disabling-attribute-alias-warning/20180531-003218
base:   https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git next
config: powerpc-defconfig (attached as .config)
compiler: powerpc64-linux-gnu-gcc (Debian 7.2.0-11) 7.2.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/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/platforms/cell/spu_syscalls.c:71:32: error: unknown option after '#pragma GCC diagnostic' kind [-Werror=pragmas]
    #pragma GCC diagnostic ignored "-Wattribute-alias"
                                   ^~~~~~~~~~~~~~~~~~~
   cc1: all warnings being treated as errors

vim +71 arch/powerpc/platforms/cell/spu_syscalls.c

    69	
    70	#pragma GCC diagnostic push
  > 71	#pragma GCC diagnostic ignored "-Wattribute-alias"
    72	SYSCALL_DEFINE4(spu_create, const char __user *, name, unsigned int, flags,
    73		umode_t, mode, int, neighbor_fd)
    74	{
    75		long ret;
    76		struct spufs_calls *calls;
    77	
    78		calls = spufs_calls_get();
    79		if (!calls)
    80			return -ENOSYS;
    81	
    82		if (flags & SPU_CREATE_AFFINITY_SPU) {
    83			struct fd neighbor = fdget(neighbor_fd);
    84			ret = -EBADF;
    85			if (neighbor.file) {
    86				ret = calls->create_thread(name, flags, mode, neighbor.file);
    87				fdput(neighbor);
    88			}
    89		} else
    90			ret = calls->create_thread(name, flags, mode, NULL);
    91	
    92		spufs_calls_put(calls);
    93		return ret;
    94	}
    95	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 23378 bytes --]

^ permalink raw reply

* Re: [PATCH v2] powerpc: fix build failure by disabling attribute-alias warning
From: kbuild test robot @ 2018-05-30 21:42 UTC (permalink / raw)
  To: Christophe Leroy
  Cc: kbuild-all, Benjamin Herrenschmidt, Paul Mackerras,
	Michael Ellerman, linux-kernel, linuxppc-dev
In-Reply-To: <871bd59bfbec78acb31082df2c3f1be43658bcb5.1527576941.git.christophe.leroy@c-s.fr>

[-- Attachment #1: Type: text/plain, Size: 3061 bytes --]

Hi Christophe,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on powerpc/next]
[also build test ERROR on next-20180530]
[cannot apply to v4.17-rc7]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Christophe-Leroy/powerpc-fix-build-failure-by-disabling-attribute-alias-warning/20180531-030007
base:   https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git next
config: powerpc-defconfig (attached as .config)
compiler: powerpc64-linux-gnu-gcc (Debian 7.2.0-11) 7.2.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/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/syscalls.c:66:32: error: unknown option after '#pragma GCC diagnostic' kind [-Werror=pragmas]
    #pragma GCC diagnostic ignored "-Wattribute-alias"
                                   ^~~~~~~~~~~~~~~~~~~
   cc1: all warnings being treated as errors
--
>> arch/powerpc/kernel/signal_32.c:1041:32: error: unknown option after '#pragma GCC diagnostic' kind [-Werror=pragmas]
    #pragma GCC diagnostic ignored "-Wattribute-alias"
                                   ^~~~~~~~~~~~~~~~~~~
   arch/powerpc/kernel/signal_32.c:1235:32: error: unknown option after '#pragma GCC diagnostic' kind [-Werror=pragmas]
    #pragma GCC diagnostic ignored "-Wattribute-alias"
                                   ^~~~~~~~~~~~~~~~~~~
   cc1: all warnings being treated as errors
--
>> arch/powerpc/kernel/signal_64.c:629:32: error: unknown option after '#pragma GCC diagnostic' kind [-Werror=pragmas]
    #pragma GCC diagnostic ignored "-Wattribute-alias"
                                   ^~~~~~~~~~~~~~~~~~~
   cc1: all warnings being treated as errors
--
>> arch/powerpc/kernel/rtas.c:1055:32: error: unknown option after '#pragma GCC diagnostic' kind [-Werror=pragmas]
    #pragma GCC diagnostic ignored "-Wattribute-alias"
                                   ^~~~~~~~~~~~~~~~~~~
   cc1: all warnings being treated as errors
--
>> arch/powerpc/kernel/pci_64.c:207:32: error: unknown option after '#pragma GCC diagnostic' kind [-Werror=pragmas]
    #pragma GCC diagnostic ignored "-Wattribute-alias"
                                   ^~~~~~~~~~~~~~~~~~~
   cc1: all warnings being treated as errors

vim +66 arch/powerpc/kernel/syscalls.c

    64	
    65	#pragma GCC diagnostic push
  > 66	#pragma GCC diagnostic ignored "-Wattribute-alias"
    67	SYSCALL_DEFINE6(mmap2, unsigned long, addr, size_t, len,
    68			unsigned long, prot, unsigned long, flags,
    69			unsigned long, fd, unsigned long, pgoff)
    70	{
    71		return do_mmap2(addr, len, prot, flags, fd, pgoff, PAGE_SHIFT-12);
    72	}
    73	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 23378 bytes --]

^ permalink raw reply

* linux-next: manual merge of the powerpc tree with the kbuild tree
From: Stephen Rothwell @ 2018-05-30 23:32 UTC (permalink / raw)
  To: Michael Ellerman, Benjamin Herrenschmidt, PowerPC,
	Masahiro Yamada
  Cc: Linux-Next Mailing List, Linux Kernel Mailing List,
	Nicholas Piggin, Naveen N. Rao

[-- Attachment #1: Type: text/plain, Size: 1415 bytes --]

Hi all,

Today's linux-next merge of the powerpc tree got a conflict in:

  arch/powerpc/kernel/module_64.c

between commit:

  06aeb9e3f2bc ("powerpc/kbuild: move -mprofile-kernel check to Kconfig")

from the kbuild tree and commit:

  250122baed29 ("powerpc64/module: Tighten detection of mcount call sites with -mprofile-kernel")

from the powerpc tree.

I fixed it up (see below) and can carry the fix as necessary. This
is now fixed as far as linux-next is concerned, but any non trivial
conflicts should be mentioned to your upstream maintainer when your tree
is submitted for merging.  You may also want to consider cooperating
with the maintainer of the conflicting tree to minimise any particularly
complex conflicts.

-- 
Cheers,
Stephen Rothwell

diff --cc arch/powerpc/kernel/module_64.c
index 55bccc315e1a,f7667e2ebfcb..000000000000
--- a/arch/powerpc/kernel/module_64.c
+++ b/arch/powerpc/kernel/module_64.c
@@@ -462,9 -466,12 +466,12 @@@ static unsigned long stub_for_addr(cons
  	return (unsigned long)&stubs[i];
  }
  
 -#ifdef CC_USING_MPROFILE_KERNEL
 +#ifdef CONFIG_MPROFILE_KERNEL
- static bool is_early_mcount_callsite(u32 *instruction)
+ static bool is_mprofile_mcount_callsite(const char *name, u32 *instruction)
  {
+ 	if (strcmp("_mcount", name))
+ 		return false;
+ 
  	/*
  	 * Check if this is one of the -mprofile-kernel sequences.
  	 */

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply

* [PATCH] [SCHEME 1] Add support for new idle device tree format
From: Akshay Adiga @ 2018-05-31  2:53 UTC (permalink / raw)
  To: linux-kernel, linuxppc-dev; +Cc: stewart, svaidy, ego, mpe, Akshay Adiga

This patch adds support for new device-tree format for idle state
description.

Previously if a older kernel runs on a newer firmware, it may enable
all available states irrespective of its capability of handling it.
New device tree format adds a compatible flag, so that only kernel
which has the capability to handle the version of stop state will enable
it.

Older kernel will still see stop0 and stop0_lite in older format and we
will depricate it after some time.

Idea is to bump up the version in firmware if we find a bug or
regression in stop states. A fix will be provided in linux which would
now know about the bumped up version of stop states, where as kernel
without fixes would ignore the states.

New idle state device tree format :
       power-mgt {
            ...
        ibm,enabled-stop-levels = <0xec000000>;
        ibm,cpu-idle-state-psscr-mask = <0x0 0x3003ff 0x0 0x3003ff>;
        ibm,cpu-idle-state-latencies-ns = <0x3e8 0x7d0>;
        ibm,cpu-idle-state-psscr = <0x0 0x330 0x0 0x300330>;
        ibm,cpu-idle-state-flags = <0x100000 0x101000>;
        ibm,cpu-idle-state-residency-ns = <0x2710 0x4e20>;
        ibm,idle-states {
                phandle = <0xff>;
                    stop4 {
                        flags = <0x207000>;
                        compatible = "ibm,cpuidle-state-v1";
                        psscr-mask = <0x0 0x3003ff>;
                        handle = <0x102>;
                        latency-ns = <0x186a0>;
                        residency-ns = <0x989680>;
                        psscr = <0x0 0x300374>;
                 };

                    ...
                    stop11 {
                        ...
                        compatible = "ibm,cpuoffline-state-v1";
                        ...

           };
           };

Signed-off-by: Akshay Adiga <akshay.adiga@linux.vnet.ibm.com>
---
 arch/powerpc/platforms/powernv/idle.c | 70 ++++++++++++++++++++++++++++++-----
 drivers/cpuidle/cpuidle-powernv.c     | 26 ++++++++++++-
 2 files changed, 85 insertions(+), 11 deletions(-)

diff --git a/arch/powerpc/platforms/powernv/idle.c b/arch/powerpc/platforms/powernv/idle.c
index 1f12ab1..074381d 100644
--- a/arch/powerpc/platforms/powernv/idle.c
+++ b/arch/powerpc/platforms/powernv/idle.c
@@ -623,17 +623,19 @@ int validate_psscr_val_mask(u64 *psscr_val, u64 *psscr_mask, u32 flags)
  * Returns 0 on success
  */
 static int __init pnv_power9_idle_init(struct device_node *np, u32 *flags,
-					int dt_idle_states)
+					int dt_idle_states, int additional_states)
 {
 	u64 *psscr_val = NULL;
 	u64 *psscr_mask = NULL;
 	u32 *residency_ns = NULL;
 	u64 max_residency_ns = 0;
-	int rc = 0, i;
-
-	psscr_val = kcalloc(dt_idle_states, sizeof(*psscr_val), GFP_KERNEL);
-	psscr_mask = kcalloc(dt_idle_states, sizeof(*psscr_mask), GFP_KERNEL);
-	residency_ns = kcalloc(dt_idle_states, sizeof(*residency_ns),
+	int rc = 0, i, orig_dt_idle_states;
+	struct device_node *dt_node;
+	orig_dt_idle_states = dt_idle_states;
+	/* TODO: remove ugliness of using additional_states count*/
+	psscr_val = kcalloc(dt_idle_states+additional_states, sizeof(*psscr_val), GFP_KERNEL);
+	psscr_mask = kcalloc(dt_idle_states+additional_states, sizeof(*psscr_mask), GFP_KERNEL);
+	residency_ns = kcalloc(dt_idle_states+additional_states, sizeof(*residency_ns),
 			       GFP_KERNEL);
 
 	if (!psscr_val || !psscr_mask || !residency_ns) {
@@ -664,7 +666,37 @@ static int __init pnv_power9_idle_init(struct device_node *np, u32 *flags,
 		rc = -1;
 		goto out;
 	}
+	for_each_compatible_node( dt_node, NULL, "ibm,cpuoffline-state_v1" ) {
+		printk("Found a state\n");
+		rc = of_property_read_u32(dt_node, "residency-ns" , &(residency_ns[dt_idle_states]));
+		if (rc)
+			printk("error reading residency rc= %d\n",rc);
+		rc = of_property_read_u64(dt_node, "psscr-mask" , &(psscr_mask[dt_idle_states]));
+		if (rc)
+			printk("error reading psscr-mask rc= %d\n",rc);
+		rc = of_property_read_u64(dt_node, "psscr" , &(psscr_val[dt_idle_states]));
+		if (rc)
+			printk("error reading psscr rc= %d\n",rc);
+		dt_idle_states++;
+	}
+	/* Fall back if no cpuoffline state found */
+	if ( orig_dt_idle_states == dt_idle_states) {
 
+		for_each_compatible_node( dt_node, NULL, "ibm,cpuidle-state_v1" ) {
+			printk("Found a state\n");
+			rc = of_property_read_u32(dt_node, "residency-ns" , &(residency_ns[dt_idle_states]));
+			if (rc)
+				printk("error reading residency rc= %d\n",rc);
+			rc = of_property_read_u64(dt_node, "psscr-mask" , &(psscr_mask[dt_idle_states]));
+			if (rc)
+				printk("error reading psscr-mask rc= %d\n",rc);
+			rc = of_property_read_u64(dt_node, "psscr" , &(psscr_val[dt_idle_states]));
+			if (rc)
+				printk("error reading psscr rc= %d\n",rc);
+			dt_idle_states++;
+		}
+	}
+	
 	/*
 	 * Set pnv_first_deep_stop_state, pnv_deepest_stop_psscr_{val,mask},
 	 * and the pnv_default_stop_{val,mask}.
@@ -740,10 +772,11 @@ static int __init pnv_power9_idle_init(struct device_node *np, u32 *flags,
  */
 static void __init pnv_probe_idle_states(void)
 {
-	struct device_node *np;
+	struct device_node *np,*dt_node;
 	int dt_idle_states;
 	u32 *flags = NULL;
-	int i;
+	int i,rc;
+	int additional_states=0;
 
 	np = of_find_node_by_path("/ibm,opal/power-mgt");
 	if (!np) {
@@ -765,12 +798,29 @@ static void __init pnv_probe_idle_states(void)
 		goto out;
 	}
 
+
+	for_each_compatible_node( dt_node, NULL, "ibm,cpuidle-state-v1" ) {
+
+		i = dt_idle_states + additional_states;
+		rc = of_property_read_u32(dt_node, "flags" , &(flags[i]));
+		if (rc)
+			printk("error reading flags rc= %d\n",rc);
+		additional_states++;
+	}
+	for_each_compatible_node( dt_node, NULL, "ibm,cpuoffline-state-v1" ) {
+
+		i = dt_idle_states + additional_states;
+		rc = of_property_read_u32(dt_node, "flags" , &(flags[i]));
+		if (rc)
+			printk("error reading flags rc= %d\n",rc);
+		additional_states++;
+	}
 	if (cpu_has_feature(CPU_FTR_ARCH_300)) {
-		if (pnv_power9_idle_init(np, flags, dt_idle_states))
+		if (pnv_power9_idle_init(np, flags, dt_idle_states,additional_states))
 			goto out;
 	}
 
-	for (i = 0; i < dt_idle_states; i++)
+	for (i = 0; i < dt_idle_states+additional_states; i++)
 		supported_cpuidle_states |= flags[i];
 
 out:
diff --git a/drivers/cpuidle/cpuidle-powernv.c b/drivers/cpuidle/cpuidle-powernv.c
index 1a8234e..e06181f 100644
--- a/drivers/cpuidle/cpuidle-powernv.c
+++ b/drivers/cpuidle/cpuidle-powernv.c
@@ -241,7 +241,7 @@ static inline int validate_dt_prop_sizes(const char *prop1, int prop1_len,
 extern u32 pnv_get_supported_cpuidle_states(void);
 static int powernv_add_idle_states(void)
 {
-	struct device_node *power_mgt;
+	struct device_node *power_mgt,*dt_node;
 	int nr_idle_states = 1; /* Snooze */
 	int dt_idle_states, count;
 	u32 latency_ns[CPUIDLE_STATE_MAX];
@@ -365,6 +365,30 @@ static int powernv_add_idle_states(void)
 						residency_ns, dt_idle_states);
 	}
 
+	/* Support new dt format for idle states */
+	for_each_compatible_node( dt_node, NULL, "ibm,cpuidle-state-v1" ) {
+		printk("Found a state\n");
+		rc = of_property_read_string(dt_node, "name" , &(names[dt_idle_states]));
+		if (rc)
+			printk("error reading names rc= %d\n",rc);
+		rc = of_property_read_u32(dt_node, "residency-ns" , &(residency_ns[dt_idle_states]));
+		if (rc)
+			printk("error reading residency rc= %d\n",rc);
+		rc = of_property_read_u32(dt_node, "latency-ns" , &(latency_ns[dt_idle_states]));
+		if (rc)
+			printk("error reading latency rc= %d\n",rc);
+		rc = of_property_read_u32(dt_node, "flags" , &(flags[dt_idle_states]));
+		if (rc)
+			printk("error reading flags rc= %d\n",rc);
+		rc = of_property_read_u64(dt_node, "psscr-mask" , &(psscr_mask[dt_idle_states]));
+		if (rc)
+			printk("error reading psscr-mask rc= %d\n",rc);
+		rc = of_property_read_u64(dt_node, "psscr" , &(psscr_val[dt_idle_states]));
+		if (rc)
+			printk("error reading psscr rc= %d\n",rc);
+		dt_idle_states++;
+	}
+
 	for (i = 0; i < dt_idle_states; i++) {
 		unsigned int exit_latency, target_residency;
 		bool stops_timebase = false;
-- 
2.5.5

^ permalink raw reply related

* [PATCH] [SCHEME 2]powernv/cpuidle: Add support for new idle state device-tree format
From: Akshay Adiga @ 2018-05-31  2:53 UTC (permalink / raw)
  To: linux-kernel, linuxppc-dev; +Cc: stewart, svaidy, ego, mpe, Akshay Adiga

This patch adds support for new device-tree format for idle state
description.

Previously if a older kernel runs on a newer firmware, it may enable
all available states irrespective of its capability of handling it.
New device tree format adds a compatible flag, so that only kernel
which has the capability to handle the version of stop state will enable
it.

Older kernel will still see stop0 and stop0_lite in older format and we
will depricate it after some time.

Idea is to bump up the version in firmware if we find a bug or
regression in stop states. A fix will be provided in linux which would
now know about the bumped up version of stop states, where as kernel
without fixes would ignore the states.

New idle state device tree format :

    power-mgt {
        ibm,cpu-idle-state-names = "stop0_lite", "stop0";
        ibm,cpu-idle-state-residency-ns = <0x2710 0x4e20>;
        ibm,cpu-idle-state-latencies-ns = <0x3e8 0x7d0>;
        ibm,cpu-idle-state-psscr-mask = <0x0 0x3003ff 0x0 0x3003ff>;
        ibm,cpu-idle-state-psscr = <0x0 0x330 0x0 0x300330>;
        ibm,cpu-idle-state-flags = <0x100000 0x101000>;
        ibm,enabled-stop-levels = <0xec000000>;
        ibm,idle-states {
          ibm,cpu-idle-state-names = "stop1", "stop2", "stop4", "stop5";
          ibm,cpu-idle-state-residency-ns = <0xc350 0x186a0 0x989680
    0x1312d00>;
          ibm,cpu-idle-state-latencies-ns = <0x1388 0x2710 0x186a0
    0x30d40>;
          ibm,cpu-idle-state-psscr-mask = <0x0 0x3003ff 0x0 0x3003ff 0x0
    0x3003ff 0x0 0x3003ff>;
          ibm,cpu-idle-state-psscr = <0x0 0x300331 0x0 0x300332 0x0
    0x300374 0x0 0x300375>;
          ibm,cpu-idle-state-versions = "ibm,idle-state-v1
    ", "ibm,idle-state-v1", "ibm,idle-state-v1", "ibm,idle-state-v1";
          ibm,cpu-idle-state-flags = <0x101000 0x101000 0x207000
0x207000>;
       }
     }

Signed-off-by: Akshay Adiga <akshay.adiga@linux.vnet.ibm.com>
---
 arch/powerpc/platforms/powernv/idle.c | 60 ++++++++++++++++++++++++++------
 drivers/cpuidle/cpuidle-powernv.c     | 65 +++++++++++++++++++++++++++++++++--
 2 files changed, 112 insertions(+), 13 deletions(-)

diff --git a/arch/powerpc/platforms/powernv/idle.c b/arch/powerpc/platforms/powernv/idle.c
index 1f12ab1..ab52665 100644
--- a/arch/powerpc/platforms/powernv/idle.c
+++ b/arch/powerpc/platforms/powernv/idle.c
@@ -622,8 +622,8 @@ int validate_psscr_val_mask(u64 *psscr_val, u64 *psscr_mask, u32 flags)
  * @dt_idle_states: Number of idle state entries
  * Returns 0 on success
  */
-static int __init pnv_power9_idle_init(struct device_node *np, u32 *flags,
-					int dt_idle_states)
+static int __init pnv_power9_idle_init(struct device_node *np, struct device_node *np_new,u32 *flags,
+					int dt_idle_states, int additional_states)
 {
 	u64 *psscr_val = NULL;
 	u64 *psscr_mask = NULL;
@@ -631,9 +631,10 @@ static int __init pnv_power9_idle_init(struct device_node *np, u32 *flags,
 	u64 max_residency_ns = 0;
 	int rc = 0, i;
 
-	psscr_val = kcalloc(dt_idle_states, sizeof(*psscr_val), GFP_KERNEL);
-	psscr_mask = kcalloc(dt_idle_states, sizeof(*psscr_mask), GFP_KERNEL);
-	residency_ns = kcalloc(dt_idle_states, sizeof(*residency_ns),
+	/* TODO: remove ugliness of using additional_states count*/
+	psscr_val = kcalloc(dt_idle_states+additional_states, sizeof(*psscr_val), GFP_KERNEL);
+	psscr_mask = kcalloc(dt_idle_states+additional_states, sizeof(*psscr_mask), GFP_KERNEL);
+	residency_ns = kcalloc(dt_idle_states+additional_states, sizeof(*residency_ns),
 			       GFP_KERNEL);
 
 	if (!psscr_val || !psscr_mask || !residency_ns) {
@@ -648,6 +649,13 @@ static int __init pnv_power9_idle_init(struct device_node *np, u32 *flags,
 		rc = -1;
 		goto out;
 	}
+	if (of_property_read_u64_array(np_new,
+		"ibm,cpu-idle-state-psscr",
+		psscr_val + dt_idle_states, additional_states)) {
+		pr_warn("cpuidle-powernv: missing addtional ibm,cpu-idle-state-psscr in DT\n");
+		rc = -1;
+		goto out;
+	}
 
 	if (of_property_read_u64_array(np,
 				       "ibm,cpu-idle-state-psscr-mask",
@@ -656,6 +664,13 @@ static int __init pnv_power9_idle_init(struct device_node *np, u32 *flags,
 		rc = -1;
 		goto out;
 	}
+	if (of_property_read_u64_array(np_new,
+				       "ibm,cpu-idle-state-psscr-mask",
+				       psscr_mask + dt_idle_states, additional_states)) {
+		pr_warn("cpuidle-powernv: missing ibm,cpu-idle-state-psscr-mask in DT\n");
+		rc = -1;
+		goto out;
+	}
 
 	if (of_property_read_u32_array(np,
 				       "ibm,cpu-idle-state-residency-ns",
@@ -664,7 +679,13 @@ static int __init pnv_power9_idle_init(struct device_node *np, u32 *flags,
 		rc = -1;
 		goto out;
 	}
-
+	if (of_property_read_u32_array(np_new,
+				       "ibm,cpu-idle-state-residency-ns",
+					residency_ns + dt_idle_states,additional_states)) {
+		pr_warn("cpuidle-powernv: missing ibm,cpu-idle-state-residency-ns in DT\n");
+		rc = -1;
+		goto out;
+	}
 	/*
 	 * Set pnv_first_deep_stop_state, pnv_deepest_stop_psscr_{val,mask},
 	 * and the pnv_default_stop_{val,mask}.
@@ -679,7 +700,7 @@ static int __init pnv_power9_idle_init(struct device_node *np, u32 *flags,
 	 * the shallowest (OPAL_PM_STOP_INST_FAST) loss-less stop state.
 	 */
 	pnv_first_deep_stop_state = MAX_STOP_STATE;
-	for (i = 0; i < dt_idle_states; i++) {
+	for (i = 0; i < dt_idle_states+additional_states; i++) {
 		int err;
 		u64 psscr_rl = psscr_val[i] & PSSCR_RL_MASK;
 
@@ -740,10 +761,11 @@ static int __init pnv_power9_idle_init(struct device_node *np, u32 *flags,
  */
 static void __init pnv_probe_idle_states(void)
 {
-	struct device_node *np;
+	struct device_node *np,*np_new;
 	int dt_idle_states;
 	u32 *flags = NULL;
 	int i;
+	int additional_states=0;
 
 	np = of_find_node_by_path("/ibm,opal/power-mgt");
 	if (!np) {
@@ -756,21 +778,37 @@ static void __init pnv_probe_idle_states(void)
 		pr_warn("cpuidle-powernv: no idle states found in the DT\n");
 		goto out;
 	}
+	/* Support new device tree */
+	np_new = of_find_node_by_path("/ibm,opal/power-mgt/ibm,idle-states");
+	if (!np_new) {
+		pr_info("opal: PowerMgmt/ibm,idle-states Node not found\n");
+	} else {
+		additional_states = of_property_count_u32_elems(np_new,
+			"ibm,cpu-idle-state-flags");
+		if (additional_states < 0) 
+			pr_info("cpuidle-powernv: no idle states found in the DT\n");
+	}
 
-	flags = kcalloc(dt_idle_states, sizeof(*flags),  GFP_KERNEL);
+	flags = kcalloc(dt_idle_states + additional_states, sizeof(*flags),  GFP_KERNEL);
 
 	if (of_property_read_u32_array(np,
 			"ibm,cpu-idle-state-flags", flags, dt_idle_states)) {
 		pr_warn("cpuidle-powernv: missing ibm,cpu-idle-state-flags in DT\n");
 		goto out;
 	}
+	if (of_property_read_u32_array(np_new,
+			"ibm,cpu-idle-state-flags", flags + dt_idle_states, additional_states)) {
+		pr_warn("cpuidle-powernv: missing ibm,cpu-idle-state-flags in DT\n");
+		goto out;
+	}
+
 
 	if (cpu_has_feature(CPU_FTR_ARCH_300)) {
-		if (pnv_power9_idle_init(np, flags, dt_idle_states))
+		if (pnv_power9_idle_init(np, np_new, flags, dt_idle_states,additional_states))
 			goto out;
 	}
 
-	for (i = 0; i < dt_idle_states; i++)
+	for (i = 0; i < dt_idle_states+additional_states; i++)
 		supported_cpuidle_states |= flags[i];
 
 out:
diff --git a/drivers/cpuidle/cpuidle-powernv.c b/drivers/cpuidle/cpuidle-powernv.c
index 1a8234e..8060a96 100644
--- a/drivers/cpuidle/cpuidle-powernv.c
+++ b/drivers/cpuidle/cpuidle-powernv.c
@@ -241,9 +241,9 @@ static inline int validate_dt_prop_sizes(const char *prop1, int prop1_len,
 extern u32 pnv_get_supported_cpuidle_states(void);
 static int powernv_add_idle_states(void)
 {
-	struct device_node *power_mgt;
+	struct device_node *power_mgt,*np_new;
 	int nr_idle_states = 1; /* Snooze */
-	int dt_idle_states, count;
+	int dt_idle_states, count, additional_states;
 	u32 latency_ns[CPUIDLE_STATE_MAX];
 	u32 residency_ns[CPUIDLE_STATE_MAX];
 	u32 flags[CPUIDLE_STATE_MAX];
@@ -365,6 +365,62 @@ static int powernv_add_idle_states(void)
 						residency_ns, dt_idle_states);
 	}
 
+	/* Support new dt format for idle states */
+
+	np_new = of_find_node_by_path("/ibm,opal/power-mgt/ibm,idle-states");
+	if (!np_new) {
+		pr_info("opal: PowerMgmt/ibm,idle-states Node not found\n");
+	} else {
+		additional_states = of_property_count_u32_elems(np_new,
+			"ibm,cpu-idle-state-flags");
+		if (additional_states < 0) 
+			pr_info("cpuidle-powernv: no idle states found in the DT\n");
+		else {
+			if (of_property_read_u32_array(np_new,
+				"ibm,cpu-idle-state-flags", flags+dt_idle_states, additional_states)) {
+				pr_warn("cpuidle-powernv : missing ibm,cpu-idle-state-flags in DT\n");
+				goto out;
+			}
+
+			if (of_property_read_u32_array(np_new,
+				"ibm,cpu-idle-state-latencies-ns", latency_ns+dt_idle_states,
+				additional_states)) {
+				pr_warn("cpuidle-powernv: missing ibm,cpu-idle-state-latencies-ns in DT\n");
+				goto out;
+			}
+			if (of_property_read_u32_array(np_new,
+				"ibm,cpu-idle-state-residencies-ns", residency_ns+dt_idle_states,
+				additional_states)) {
+				pr_warn("cpuidle-powernv: missing ibm,cpu-idle-state-residencies-ns in DT\n");
+				goto out;
+			}
+			if (of_property_read_string_array(np_new,
+				"ibm,cpu-idle-state-names", names+dt_idle_states, additional_states) < 0) {
+				pr_warn("cpuidle-powernv: missing ibm,cpu-idle-state-names in DT\n");
+				goto out;
+			}
+			if (of_property_read_string_array(np_new,
+				"ibm,cpu-idle-state-versions", versions, additional_states) < 0) {
+				pr_warn("cpuidle-powernv: missing ibm,cpu-idle-state-names in DT\n");
+				goto out;
+			}
+			if (of_property_read_u64_array(np_new,
+			    "ibm,cpu-idle-state-psscr", psscr_val+ dt_idle_states, additional_states)) {
+				pr_warn("cpuidle-powernv: missing ibm,cpu-idle-state-psscr in DT\n");
+				goto out;
+			}
+
+			if (of_property_read_u64_array(power_mgt,
+					       "ibm,cpu-idle-state-psscr-mask",
+						psscr_mask + dt_idle_states,additional_states)) {
+				pr_warn("cpuidle-powernv:Missing ibm,cpu-idle-state-psscr-mask in DT\n");
+				goto out;
+			}
+		
+
+			dt_idle_states += additional_states;
+		}
+	}
 	for (i = 0; i < dt_idle_states; i++) {
 		unsigned int exit_latency, target_residency;
 		bool stops_timebase = false;
@@ -375,6 +431,11 @@ static int powernv_add_idle_states(void)
 		 */
 		if ((flags[i] & supported_flags) != flags[i])
 			continue;
+
+		/* Supported version */
+		if (!( strcmp(version[i] , "ibm,idle-state-v1"))
+				continue;
+				
 		/*
 		 * If an idle state has exit latency beyond
 		 * POWERNV_THRESHOLD_LATENCY_NS then don't use it
-- 
2.5.5

^ permalink raw reply related

* Re: [RFC V2] virtio: Add platform specific DMA API translation for virito devices
From: Anshuman Khandual @ 2018-05-31  3:39 UTC (permalink / raw)
  To: Ram Pai, Michael S. Tsirkin
  Cc: robh, aik, jasowang, linux-kernel, virtualization, hch, joe,
	linuxppc-dev, elfring, david
In-Reply-To: <20180524072104.GD6139@ram.oc3035372033.ibm.com>

On 05/24/2018 12:51 PM, Ram Pai wrote:
> On Wed, May 23, 2018 at 09:50:02PM +0300, Michael S. Tsirkin wrote:
>> subj: s/virito/virtio/
>>
> ..snip..
>>>  machine_subsys_initcall_sync(pseries, tce_iommu_bus_notifier_init);
>>> +
>>> +bool platform_forces_virtio_dma(struct virtio_device *vdev)
>>> +{
>>> +	/*
>>> +	 * On protected guest platforms, force virtio core to use DMA
>>> +	 * MAP API for all virtio devices. But there can also be some
>>> +	 * exceptions for individual devices like virtio balloon.
>>> +	 */
>>> +	return (of_find_compatible_node(NULL, NULL, "ibm,ultravisor") != NULL);
>>> +}
>>
>> Isn't this kind of slow?  vring_use_dma_api is on
>> data path and supposed to be very fast.
> 
> Yes it is slow and not ideal. This won't be the final code. The final
> code will cache the information in some global variable and used
> in this function.

Right this will be a simple check based on a global variable.

^ permalink raw reply

* Re: [PATCH v5 1/7] powerpc: Add TIDR CPU feature for POWER9
From: Andrew Donnellan @ 2018-05-31  4:19 UTC (permalink / raw)
  To: Alastair D'Silva, linuxppc-dev
  Cc: linux-kernel, linux-doc, mikey, vaibhav, aneesh.kumar, malat,
	felix, pombredanne, sukadev, npiggin, gregkh, arnd, fbarrat,
	corbet, Alastair D'Silva
In-Reply-To: <20180511061303.10728-2-alastair@au1.ibm.com>

On 11/05/18 16:12, Alastair D'Silva wrote:
> From: Alastair D'Silva <alastair@d-silva.org>
> 
> This patch adds a CPU feature bit to show whether the CPU has
> the TIDR register available, enabling as_notify/wait in userspace.
> 
> Signed-off-by: Alastair D'Silva <alastair@d-silva.org>

Reviewed-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>

-- 
Andrew Donnellan              OzLabs, ADL Canberra
andrew.donnellan@au1.ibm.com  IBM Australia Limited

^ permalink raw reply

* Re: [PATCH v5 2/7] powerpc: Use TIDR CPU feature to control TIDR allocation
From: Andrew Donnellan @ 2018-05-31  4:20 UTC (permalink / raw)
  To: Alastair D'Silva, linuxppc-dev
  Cc: linux-kernel, linux-doc, mikey, vaibhav, aneesh.kumar, malat,
	felix, pombredanne, sukadev, npiggin, gregkh, arnd, fbarrat,
	corbet, Alastair D'Silva
In-Reply-To: <20180511061303.10728-3-alastair@au1.ibm.com>

On 11/05/18 16:12, Alastair D'Silva wrote:
> From: Alastair D'Silva <alastair@d-silva.org>
> 
> Switch the use of TIDR on it's CPU feature, rather than assuming it
> is available based on architecture.
> 
> Signed-off-by: Alastair D'Silva <alastair@d-silva.org>

Reviewed-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>

-- 
Andrew Donnellan              OzLabs, ADL Canberra
andrew.donnellan@au1.ibm.com  IBM Australia Limited

^ permalink raw reply


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox