* [PATCH kernel] cxl: Remove unused include
From: Alexey Kardashevskiy @ 2018-09-28 6:38 UTC (permalink / raw)
To: linuxppc-dev; +Cc: Alexey Kardashevskiy, Frederic Barrat, Andrew Donnellan
The included opal.h gives a wrong idea that CXL makes PPC OPAL calls
while it does not so let's remote it.
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
---
drivers/misc/cxl/pci.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/drivers/misc/cxl/pci.c b/drivers/misc/cxl/pci.c
index b66d832..8cbcbb7 100644
--- a/drivers/misc/cxl/pci.c
+++ b/drivers/misc/cxl/pci.c
@@ -17,7 +17,6 @@
#include <linux/pci.h>
#include <linux/of.h>
#include <linux/delay.h>
-#include <asm/opal.h>
#include <asm/msi_bitmap.h>
#include <asm/pnv-pci.h>
#include <asm/io.h>
--
2.11.0
^ permalink raw reply related
* [PATCH kernel] powerpc/powernv/ioda: Allocate indirect TCE levels of cached userspace addresses on demand
From: Alexey Kardashevskiy @ 2018-09-28 6:45 UTC (permalink / raw)
To: linuxppc-dev; +Cc: Alexey Kardashevskiy, kvm-ppc, David Gibson
The powernv platform maintains 2 TCE tables for VFIO - a hardware TCE
table and a table with userspace addresses; the latter is used for
marking pages dirty when corresponging TCEs are unmapped from
the hardware table.
a68bd1267b72 ("powerpc/powernv/ioda: Allocate indirect TCE levels
on demand") enabled on-demand allocation of the hardware table,
however it missed the other table so it has still been fully allocated
at the boot time. This fixes the issue by allocating a single level,
just like we do for the hardware table.
Fixes: a68bd1267b72 ("powerpc/powernv/ioda: Allocate indirect TCE levels on demand")
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
---
arch/powerpc/platforms/powernv/pci-ioda-tce.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/powerpc/platforms/powernv/pci-ioda-tce.c b/arch/powerpc/platforms/powernv/pci-ioda-tce.c
index fe96910..7639b21 100644
--- a/arch/powerpc/platforms/powernv/pci-ioda-tce.c
+++ b/arch/powerpc/platforms/powernv/pci-ioda-tce.c
@@ -299,7 +299,7 @@ long pnv_pci_ioda2_table_alloc_pages(int nid, __u64 bus_offset,
if (alloc_userspace_copy) {
offset = 0;
uas = pnv_pci_ioda2_table_do_alloc_pages(nid, level_shift,
- levels, tce_table_size, &offset,
+ tmplevels, tce_table_size, &offset,
&total_allocated_uas);
if (!uas)
goto free_tces_exit;
--
2.11.0
^ permalink raw reply related
* [PATCH kernel] KVM: PPC: Optimize clearing TCEs for sparse tables
From: Alexey Kardashevskiy @ 2018-09-28 6:47 UTC (permalink / raw)
To: linuxppc-dev; +Cc: Alexey Kardashevskiy, kvm-ppc, David Gibson
The powernv platform maintains 2 TCE tables for VFIO - a hardware TCE
table and a table with userspace addresses. These tables are radix trees,
we allocate indirect levels when they are written to. Since
the memory allocation is problematic in real mode, we have 2 accessors
to the entries:
- for virtual mode: it allocates the memory and it is always expected
to return non-NULL;
- fr real mode: it does not allocate and can return NULL.
Also, DMA windows can span to up to 55 bits of the address space and since
we never have this much RAM, such windows are sparse. However currently
the SPAPR TCE IOMMU driver walks through all TCEs to unpin DMA memory.
Since we maintain a userspace addresses table for VFIO which is a mirror
of the hardware table, we can use it to know which parts of the DMA
window have not been mapped and skip these so does this patch.
The bare metal systems do not have this problem as they use a bypass mode
of a PHB which maps RAM directly.
This helps a lot with sparse DMA windows, reducing the shutdown time from
about 3 minutes per 1 billion TCEs to a few seconds for 32GB sparse guest.
Just skipping the last level seems to be good enough.
As non-allocating accessor is used now in virtual mode as well, rename it
from IOMMU_TABLE_USERSPACE_ENTRY_RM (real mode) to _RO (read only).
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
---
arch/powerpc/include/asm/iommu.h | 2 +-
arch/powerpc/kvm/book3s_64_vio.c | 5 ++---
arch/powerpc/kvm/book3s_64_vio_hv.c | 6 +++---
drivers/vfio/vfio_iommu_spapr_tce.c | 22 ++++++++++++++++++++--
4 files changed, 26 insertions(+), 9 deletions(-)
diff --git a/arch/powerpc/include/asm/iommu.h b/arch/powerpc/include/asm/iommu.h
index 3d4b88c..35db0cb 100644
--- a/arch/powerpc/include/asm/iommu.h
+++ b/arch/powerpc/include/asm/iommu.h
@@ -126,7 +126,7 @@ struct iommu_table {
int it_nid;
};
-#define IOMMU_TABLE_USERSPACE_ENTRY_RM(tbl, entry) \
+#define IOMMU_TABLE_USERSPACE_ENTRY_RO(tbl, entry) \
((tbl)->it_ops->useraddrptr((tbl), (entry), false))
#define IOMMU_TABLE_USERSPACE_ENTRY(tbl, entry) \
((tbl)->it_ops->useraddrptr((tbl), (entry), true))
diff --git a/arch/powerpc/kvm/book3s_64_vio.c b/arch/powerpc/kvm/book3s_64_vio.c
index c0c64d1..62a8d03 100644
--- a/arch/powerpc/kvm/book3s_64_vio.c
+++ b/arch/powerpc/kvm/book3s_64_vio.c
@@ -410,11 +410,10 @@ static long kvmppc_tce_iommu_mapped_dec(struct kvm *kvm,
{
struct mm_iommu_table_group_mem_t *mem = NULL;
const unsigned long pgsize = 1ULL << tbl->it_page_shift;
- __be64 *pua = IOMMU_TABLE_USERSPACE_ENTRY(tbl, entry);
+ __be64 *pua = IOMMU_TABLE_USERSPACE_ENTRY_RO(tbl, entry);
if (!pua)
- /* it_userspace allocation might be delayed */
- return H_TOO_HARD;
+ return H_SUCCESS;
mem = mm_iommu_lookup(kvm->mm, be64_to_cpu(*pua), pgsize);
if (!mem)
diff --git a/arch/powerpc/kvm/book3s_64_vio_hv.c b/arch/powerpc/kvm/book3s_64_vio_hv.c
index 389dac1..583031d 100644
--- a/arch/powerpc/kvm/book3s_64_vio_hv.c
+++ b/arch/powerpc/kvm/book3s_64_vio_hv.c
@@ -212,7 +212,7 @@ static long iommu_tce_xchg_rm(struct mm_struct *mm, struct iommu_table *tbl,
if (!ret && ((*direction == DMA_FROM_DEVICE) ||
(*direction == DMA_BIDIRECTIONAL))) {
- __be64 *pua = IOMMU_TABLE_USERSPACE_ENTRY_RM(tbl, entry);
+ __be64 *pua = IOMMU_TABLE_USERSPACE_ENTRY_RO(tbl, entry);
/*
* kvmppc_rm_tce_iommu_do_map() updates the UA cache after
* calling this so we still get here a valid UA.
@@ -238,7 +238,7 @@ static long kvmppc_rm_tce_iommu_mapped_dec(struct kvm *kvm,
{
struct mm_iommu_table_group_mem_t *mem = NULL;
const unsigned long pgsize = 1ULL << tbl->it_page_shift;
- __be64 *pua = IOMMU_TABLE_USERSPACE_ENTRY_RM(tbl, entry);
+ __be64 *pua = IOMMU_TABLE_USERSPACE_ENTRY_RO(tbl, entry);
if (!pua)
/* it_userspace allocation might be delayed */
@@ -302,7 +302,7 @@ static long kvmppc_rm_tce_iommu_do_map(struct kvm *kvm, struct iommu_table *tbl,
{
long ret;
unsigned long hpa = 0;
- __be64 *pua = IOMMU_TABLE_USERSPACE_ENTRY_RM(tbl, entry);
+ __be64 *pua = IOMMU_TABLE_USERSPACE_ENTRY_RO(tbl, entry);
struct mm_iommu_table_group_mem_t *mem;
if (!pua)
diff --git a/drivers/vfio/vfio_iommu_spapr_tce.c b/drivers/vfio/vfio_iommu_spapr_tce.c
index 96721b1..b1a8ab3 100644
--- a/drivers/vfio/vfio_iommu_spapr_tce.c
+++ b/drivers/vfio/vfio_iommu_spapr_tce.c
@@ -444,7 +444,7 @@ static void tce_iommu_unuse_page_v2(struct tce_container *container,
struct mm_iommu_table_group_mem_t *mem = NULL;
int ret;
unsigned long hpa = 0;
- __be64 *pua = IOMMU_TABLE_USERSPACE_ENTRY(tbl, entry);
+ __be64 *pua = IOMMU_TABLE_USERSPACE_ENTRY_RO(tbl, entry);
if (!pua)
return;
@@ -467,8 +467,26 @@ static int tce_iommu_clear(struct tce_container *container,
unsigned long oldhpa;
long ret;
enum dma_data_direction direction;
+ unsigned long lastentry = entry + pages;
+
+ for ( ; entry < lastentry; ++entry) {
+ if (tbl->it_indirect_levels && tbl->it_userspace) {
+ /*
+ * For multilevel tables, we can take a shortcut here
+ * and skip some TCEs as we know that the userspace
+ * addresses cache is a mirror of the real TCE table
+ * and if it is missing some indirect levels, then
+ * the hardware table does not have them allocated
+ * either and therefore does not require updating.
+ */
+ __be64 *pua = IOMMU_TABLE_USERSPACE_ENTRY_RO(tbl,
+ entry);
+ if (!pua) {
+ entry += tbl->it_level_size - 1;
+ continue;
+ }
+ }
- for ( ; pages; --pages, ++entry) {
cond_resched();
direction = DMA_NONE;
--
2.11.0
^ permalink raw reply related
* [PATCH kernel] powerpc/powernv/npu: Remove unused headers and a macro.
From: Alexey Kardashevskiy @ 2018-09-28 6:48 UTC (permalink / raw)
To: linuxppc-dev; +Cc: Alexey Kardashevskiy, Alistair Popple, Reza Arbab
The macro and few headers are not used so remove them.
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
---
arch/powerpc/platforms/powernv/npu-dma.c | 14 --------------
1 file changed, 14 deletions(-)
diff --git a/arch/powerpc/platforms/powernv/npu-dma.c b/arch/powerpc/platforms/powernv/npu-dma.c
index 8006c54..3a5c4ed 100644
--- a/arch/powerpc/platforms/powernv/npu-dma.c
+++ b/arch/powerpc/platforms/powernv/npu-dma.c
@@ -9,32 +9,18 @@
* License as published by the Free Software Foundation.
*/
-#include <linux/slab.h>
#include <linux/mmu_notifier.h>
#include <linux/mmu_context.h>
#include <linux/of.h>
-#include <linux/export.h>
#include <linux/pci.h>
#include <linux/memblock.h>
-#include <linux/iommu.h>
-#include <linux/debugfs.h>
#include <asm/debugfs.h>
-#include <asm/tlb.h>
#include <asm/powernv.h>
-#include <asm/reg.h>
-#include <asm/opal.h>
-#include <asm/io.h>
-#include <asm/iommu.h>
-#include <asm/pnv-pci.h>
-#include <asm/msi_bitmap.h>
#include <asm/opal.h>
-#include "powernv.h"
#include "pci.h"
-#define npu_to_phb(x) container_of(x, struct pnv_phb, npu)
-
/*
* spinlock to protect initialisation of an npu_context for a particular
* mm_struct.
--
2.11.0
^ permalink raw reply related
* Re: [PATCH] powerpc/rtas: Fix a potential race between CPU-Offline & Migration
From: Gautham R Shenoy @ 2018-09-28 7:02 UTC (permalink / raw)
To: Nathan Fontenot; +Cc: Gautham R. Shenoy, linuxppc-dev, Tyrel Datwyler
In-Reply-To: <fa97b7f0-0cef-fc47-6566-216e399ac52a@linux.vnet.ibm.com>
Hi Nathan,
On Thu, Sep 27, 2018 at 12:31:34PM -0500, Nathan Fontenot wrote:
> On 09/27/2018 11:51 AM, Gautham R. Shenoy wrote:
> > From: "Gautham R. Shenoy" <ego@linux.vnet.ibm.com>
> >
> > Live Partition Migrations require all the present CPUs to execute the
> > H_JOIN call, and hence rtas_ibm_suspend_me() onlines any offline CPUs
> > before initiating the migration for this purpose.
> >
> > The commit 85a88cabad57
> > ("powerpc/pseries: Disable CPU hotplug across migrations")
> > disables any CPU-hotplug operations once all the offline CPUs are
> > brought online to prevent any further state change. Once the
> > CPU-Hotplug operation is disabled, the code assumes that all the CPUs
> > are online.
> >
> > However, there is a minor window in rtas_ibm_suspend_me() between
> > onlining the offline CPUs and disabling CPU-Hotplug when a concurrent
> > CPU-offline operations initiated by the userspace can succeed thereby
> > nullifying the the aformentioned assumption. In this unlikely case
> > these offlined CPUs will not call H_JOIN, resulting in a system hang.
> >
> > Fix this by verifying that all the present CPUs are actually online
> > after CPU-Hotplug has been disabled, failing which we return from
> > rtas_ibm_suspend_me() with -EBUSY.
>
> Would we also want to havr the ability to re-try onlining all of the cpus
> before failing the migration?
Given that we haven't been able to hit issue in practice after your
fix to disable CPU Hotplug after migrations, it indicates that the
race-window, if it is not merely a theoretical one, is extremely
narrow. So, this current patch addresses the safety aspect, as in,
should someone manage to exploit this narrow race-window, it ensures
that the system doesn't go to a hang state.
Having the ability to retry onlining all the CPUs is only required for
progress of LPM in this rarest of cases. We should add the code to
retry onlining the CPUs if the consequence of failing an LPM is high,
even in this rarest of case. Otherwise IMHO we should be ok not adding
the additional code.
>
> This would involve a bigger code change as the current code to online all
> CPUs would work in its current form.
>
> -Nathan
>
> >
> > Cc: Nathan Fontenot <nfont@linux.vnet.ibm.com>
> > Cc: Tyrel Datwyler <tyreld@linux.vnet.ibm.com>
> > Suggested-by: Michael Ellerman <mpe@ellerman.id.au>
> > Signed-off-by: Gautham R. Shenoy <ego@linux.vnet.ibm.com>
> > ---
> > arch/powerpc/kernel/rtas.c | 10 ++++++++++
> > 1 file changed, 10 insertions(+)
> >
> > diff --git a/arch/powerpc/kernel/rtas.c b/arch/powerpc/kernel/rtas.c
> > index 2c7ed31..27f6fd3 100644
> > --- a/arch/powerpc/kernel/rtas.c
> > +++ b/arch/powerpc/kernel/rtas.c
> > @@ -982,6 +982,16 @@ int rtas_ibm_suspend_me(u64 handle)
> > }
> >
> > cpu_hotplug_disable();
> > +
> > + /* Check if we raced with a CPU-Offline Operation */
> > + if (unlikely(!cpumask_equal(cpu_present_mask, cpu_online_mask))) {
> > + pr_err("%s: Raced against a concurrent CPU-Offline\n",
> > + __func__);
> > + atomic_set(&data.error, -EBUSY);
> > + cpu_hotplug_enable();
> > + goto out;
> > + }
> > +
> > stop_topology_update();
> >
> > /* Call function on all CPUs. One of us will make the
> >
^ permalink raw reply
* Re: [PATCH kernel] cxl: Remove unused include
From: Andrew Donnellan @ 2018-09-28 7:47 UTC (permalink / raw)
To: Alexey Kardashevskiy, linuxppc-dev; +Cc: Frederic Barrat
In-Reply-To: <20180928063804.35692-1-aik@ozlabs.ru>
On 28/9/18 4:38 pm, Alexey Kardashevskiy wrote:
> The included opal.h gives a wrong idea that CXL makes PPC OPAL calls
> while it does not so let's remote it.
>
> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Thanks for catching this
Acked-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
> ---
> drivers/misc/cxl/pci.c | 1 -
> 1 file changed, 1 deletion(-)
>
> diff --git a/drivers/misc/cxl/pci.c b/drivers/misc/cxl/pci.c
> index b66d832..8cbcbb7 100644
> --- a/drivers/misc/cxl/pci.c
> +++ b/drivers/misc/cxl/pci.c
> @@ -17,7 +17,6 @@
> #include <linux/pci.h>
> #include <linux/of.h>
> #include <linux/delay.h>
> -#include <asm/opal.h>
> #include <asm/msi_bitmap.h>
> #include <asm/pnv-pci.h>
> #include <asm/io.h>
>
--
Andrew Donnellan OzLabs, ADL Canberra
andrew.donnellan@au1.ibm.com IBM Australia Limited
^ permalink raw reply
* Re: [PATCH] powerpc: wire up memtest
From: Christophe LEROY @ 2018-09-28 8:28 UTC (permalink / raw)
To: Michael Ellerman, Benjamin Herrenschmidt, Paul Mackerras
Cc: linuxppc-dev, linux-kernel
In-Reply-To: <871s9euw4m.fsf@concordia.ellerman.id.au>
Le 28/09/2018 à 05:41, Michael Ellerman a écrit :
> Christophe Leroy <christophe.leroy@c-s.fr> writes:
>> Add call to early_memtest() so that kernel compiled with
>> CONFIG_MEMTEST really perform memtest at startup when requested
>> via 'memtest' boot parameter.
>>
>> Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
>> ---
>> arch/powerpc/kernel/setup-common.c | 3 +++
>> 1 file changed, 3 insertions(+)
>>
>> diff --git a/arch/powerpc/kernel/setup-common.c b/arch/powerpc/kernel/setup-common.c
>> index 93fa0c99681e..904b728eb20d 100644
>> --- a/arch/powerpc/kernel/setup-common.c
>> +++ b/arch/powerpc/kernel/setup-common.c
>> @@ -33,6 +33,7 @@
>> #include <linux/serial_8250.h>
>> #include <linux/percpu.h>
>> #include <linux/memblock.h>
>> +#include <linux/bootmem.h>
>> #include <linux/of_platform.h>
>> #include <linux/hugetlb.h>
>> #include <asm/debugfs.h>
>> @@ -917,6 +918,8 @@ void __init setup_arch(char **cmdline_p)
>> /* Parse memory topology */
>> mem_topology_setup();
>>
>> + early_memtest(min_low_pfn << PAGE_SHIFT, max_low_pfn << PAGE_SHIFT);
>
> On a ppc64le VM this boils down to early_memtest(0, 0) for me.
>
> I think it's too early, we don't set up max_low_pfn until
> initmem_init().
>
> If I move it after initmem_init() then it does something more useful:
Ok. On my 8xx max_low_pfn is set in mem_topology_setup().
Moving the test afte initmem_init() still works on the 8xx so I'll do that.
Thanks for testing.
Christophe
>
> early_memtest: # of tests: 17
> 0x0000000001450580 - 0x0000000001450800 pattern 4c494e5558726c7a
> 0x0000000001450c00 - 0x0000000003600000 pattern 4c494e5558726c7a
> 0x00000000047c0000 - 0x000000002fff0000 pattern 4c494e5558726c7a
> 0x0000000030000000 - 0x000000003ff24000 pattern 4c494e5558726c7a
> 0x000000003fff4000 - 0x000000003fff4c00 pattern 4c494e5558726c7a
> 0x000000003fff5000 - 0x000000003fff5300 pattern 4c494e5558726c7a
> 0x000000003fff5c00 - 0x000000003fff5f00 pattern 4c494e5558726c7a
> 0x000000003fff6800 - 0x000000003fff6b00 pattern 4c494e5558726c7a
> 0x000000003fff7400 - 0x000000003fff7700 pattern 4c494e5558726c7a
> 0x000000003fff8000 - 0x000000003fff8300 pattern 4c494e5558726c7a
> 0x000000003fff8c00 - 0x000000003fff8f00 pattern 4c494e5558726c7a
> 0x000000003fff9800 - 0x000000003fff9b00 pattern 4c494e5558726c7a
> 0x000000003fffa400 - 0x000000003fffa700 pattern 4c494e5558726c7a
> 0x000000003fffb000 - 0x000000003fffb300 pattern 4c494e5558726c7a
> 0x000000003fffbc00 - 0x000000003fffbf00 pattern 4c494e5558726c7a
> 0x000000003fffc800 - 0x000000003fffcb00 pattern 4c494e5558726c7a
> 0x000000003fffd400 - 0x000000003fffd700 pattern 4c494e5558726c7a
> 0x000000003fffe000 - 0x000000003fffe100 pattern 4c494e5558726c7a
> 0x0000000040000000 - 0x00000000ffc10000 pattern 4c494e5558726c7a
> 0x00000000fffa0000 - 0x00000000fffa5b00 pattern 4c494e5558726c7a
> 0x0000000100000000 - 0x00000001ffbe0000 pattern 4c494e5558726c7a
> 0x00000001fff60000 - 0x00000001fff61b00 pattern 4c494e5558726c7a
> 0x00000001fffec000 - 0x00000001fffec4b8 pattern 4c494e5558726c7a
> 0x00000001fffec524 - 0x00000001fffec528 pattern 4c494e5558726c7a
>
>
> cheers
>
^ permalink raw reply
* [PATCH v2 0/5] soc/fsl/qbman: DPAA QBMan fixes and additions
From: Madalin Bucur @ 2018-09-28 8:43 UTC (permalink / raw)
To: leoyang.li
Cc: Madalin Bucur, catalin.marinas, roy.pledge, linux-kernel, oss,
claudiu.manoil, linuxppc-dev, linux-arm-kernel
This patch set brings a number of fixes and the option to control
the QMan portal interrupt coalescing.
Changes from v1:
- change CPU 0 with any online CPU to allow CPU 0 to be taken offline
- move common code in a function
- address all places in the code where the portal interrupt was affined
to CPU 0
- remove unrelated change from patch adding 64 bit DMA addressing
requirement
Madalin Bucur (2):
soc/fsl/qbman: replace CPU 0 with any online CPU in hotplug handlers
soc/fsl_qbman: export coalesce change API
Roy Pledge (3):
soc/fsl/qbman: Check if CPU is offline when initializing portals
soc/fsl/qbman: Add 64 bit DMA addressing requirement to QBMan
soc/fsl/qbman: Use last response to determine valid bit
drivers/soc/fsl/qbman/Kconfig | 2 +-
drivers/soc/fsl/qbman/bman.c | 6 ++---
drivers/soc/fsl/qbman/bman_portal.c | 4 ++-
drivers/soc/fsl/qbman/dpaa_sys.h | 20 ++++++++++++++
drivers/soc/fsl/qbman/qman.c | 53 ++++++++++++++++++++++++++++++++-----
drivers/soc/fsl/qbman/qman_portal.c | 6 +++--
include/soc/fsl/qman.h | 27 +++++++++++++++++++
7 files changed, 104 insertions(+), 14 deletions(-)
--
2.1.0
^ permalink raw reply
* [PATCH v2 2/5] soc/fsl/qbman: replace CPU 0 with any online CPU in hotplug handlers
From: Madalin Bucur @ 2018-09-28 8:43 UTC (permalink / raw)
To: leoyang.li
Cc: Madalin Bucur, catalin.marinas, roy.pledge, linux-kernel, oss,
claudiu.manoil, linuxppc-dev, linux-arm-kernel
In-Reply-To: <1538124204-31406-1-git-send-email-madalin.bucur@nxp.com>
The existing code sets portal IRQ affinity to CPU 0 in the
offline hotplug handler. If CPU 0 is offline this is invalid.
Use a different online CPU instead.
Signed-off-by: Madalin Bucur <madalin.bucur@nxp.com>
---
drivers/soc/fsl/qbman/bman_portal.c | 4 +++-
drivers/soc/fsl/qbman/qman_portal.c | 6 ++++--
2 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/drivers/soc/fsl/qbman/bman_portal.c b/drivers/soc/fsl/qbman/bman_portal.c
index 2f71f7df3465..088cdfa7c034 100644
--- a/drivers/soc/fsl/qbman/bman_portal.c
+++ b/drivers/soc/fsl/qbman/bman_portal.c
@@ -65,7 +65,9 @@ static int bman_offline_cpu(unsigned int cpu)
if (!pcfg)
return 0;
- irq_set_affinity(pcfg->irq, cpumask_of(0));
+ /* use any other online CPU */
+ cpu = cpumask_any_but(cpu_online_mask, cpu);
+ irq_set_affinity(pcfg->irq, cpumask_of(cpu));
return 0;
}
diff --git a/drivers/soc/fsl/qbman/qman_portal.c b/drivers/soc/fsl/qbman/qman_portal.c
index a120002b630e..4efd6ea598b1 100644
--- a/drivers/soc/fsl/qbman/qman_portal.c
+++ b/drivers/soc/fsl/qbman/qman_portal.c
@@ -195,8 +195,10 @@ static int qman_offline_cpu(unsigned int cpu)
if (p) {
pcfg = qman_get_qm_portal_config(p);
if (pcfg) {
- irq_set_affinity(pcfg->irq, cpumask_of(0));
- qman_portal_update_sdest(pcfg, 0);
+ /* select any other online CPU */
+ cpu = cpumask_any_but(cpu_online_mask, cpu);
+ irq_set_affinity(pcfg->irq, cpumask_of(cpu));
+ qman_portal_update_sdest(pcfg, cpu);
}
}
return 0;
--
2.1.0
^ permalink raw reply related
* [PATCH v2 1/5] soc/fsl/qbman: Check if CPU is offline when initializing portals
From: Madalin Bucur @ 2018-09-28 8:43 UTC (permalink / raw)
To: leoyang.li
Cc: Madalin Bucur, catalin.marinas, roy.pledge, linux-kernel, oss,
claudiu.manoil, linuxppc-dev, linux-arm-kernel
In-Reply-To: <1538124204-31406-1-git-send-email-madalin.bucur@nxp.com>
From: Roy Pledge <roy.pledge@nxp.com>
If the CPU to affine the portal interrupt is offline at boot time
affine the portal interrupt to another online CPU. If the CPU is later
brought online the hotplug handler will correctly adjust the affinity.
Moved common code in a function.
Signed-off-by: Roy Pledge <roy.pledge@nxp.com>
Signed-off-by: Madalin Bucur <madalin.bucur@nxp.com>
---
drivers/soc/fsl/qbman/bman.c | 6 ++----
drivers/soc/fsl/qbman/dpaa_sys.h | 20 ++++++++++++++++++++
drivers/soc/fsl/qbman/qman.c | 6 ++----
3 files changed, 24 insertions(+), 8 deletions(-)
diff --git a/drivers/soc/fsl/qbman/bman.c b/drivers/soc/fsl/qbman/bman.c
index f9485cedc648..f84ab596bde8 100644
--- a/drivers/soc/fsl/qbman/bman.c
+++ b/drivers/soc/fsl/qbman/bman.c
@@ -562,11 +562,9 @@ static int bman_create_portal(struct bman_portal *portal,
dev_err(c->dev, "request_irq() failed\n");
goto fail_irq;
}
- if (c->cpu != -1 && irq_can_set_affinity(c->irq) &&
- irq_set_affinity(c->irq, cpumask_of(c->cpu))) {
- dev_err(c->dev, "irq_set_affinity() failed\n");
+
+ if (dpaa_set_portal_irq_affinity(c->dev, c->irq, c->cpu))
goto fail_affinity;
- }
/* Need RCR to be empty before continuing */
ret = bm_rcr_get_fill(p);
diff --git a/drivers/soc/fsl/qbman/dpaa_sys.h b/drivers/soc/fsl/qbman/dpaa_sys.h
index 9f379000da85..ae8afa552b1e 100644
--- a/drivers/soc/fsl/qbman/dpaa_sys.h
+++ b/drivers/soc/fsl/qbman/dpaa_sys.h
@@ -111,4 +111,24 @@ int qbman_init_private_mem(struct device *dev, int idx, dma_addr_t *addr,
#define QBMAN_MEMREMAP_ATTR MEMREMAP_WC
#endif
+static inline int dpaa_set_portal_irq_affinity(struct device *dev,
+ int irq, int cpu)
+{
+ int ret = 0;
+
+ if (!irq_can_set_affinity(irq)) {
+ dev_err(dev, "unable to set IRQ affinity\n");
+ return -EINVAL;
+ }
+
+ if (cpu == -1 || !cpu_online(cpu))
+ cpu = cpumask_any(cpu_online_mask);
+
+ ret = irq_set_affinity(irq, cpumask_of(cpu));
+ if (ret)
+ dev_err(dev, "irq_set_affinity() on CPU %d failed\n", cpu);
+
+ return ret;
+}
+
#endif /* __DPAA_SYS_H */
diff --git a/drivers/soc/fsl/qbman/qman.c b/drivers/soc/fsl/qbman/qman.c
index ecb22749df0b..0ffe7a1d0eae 100644
--- a/drivers/soc/fsl/qbman/qman.c
+++ b/drivers/soc/fsl/qbman/qman.c
@@ -1210,11 +1210,9 @@ static int qman_create_portal(struct qman_portal *portal,
dev_err(c->dev, "request_irq() failed\n");
goto fail_irq;
}
- if (c->cpu != -1 && irq_can_set_affinity(c->irq) &&
- irq_set_affinity(c->irq, cpumask_of(c->cpu))) {
- dev_err(c->dev, "irq_set_affinity() failed\n");
+
+ if (dpaa_set_portal_irq_affinity(c->dev, c->irq, c->cpu))
goto fail_affinity;
- }
/* Need EQCR to be empty before continuing */
isdr &= ~QM_PIRQ_EQCI;
--
2.1.0
^ permalink raw reply related
* [PATCH v2 3/5] soc/fsl/qbman: Add 64 bit DMA addressing requirement to QBMan
From: Madalin Bucur @ 2018-09-28 8:43 UTC (permalink / raw)
To: leoyang.li
Cc: Madalin Bucur, catalin.marinas, roy.pledge, linux-kernel, oss,
claudiu.manoil, linuxppc-dev, linux-arm-kernel
In-Reply-To: <1538124204-31406-1-git-send-email-madalin.bucur@nxp.com>
From: Roy Pledge <roy.pledge@nxp.com>
The QBMan block is memory mapped on SoCs above a 32 bit (4 Gigabyte)
boundary so enabling 64 bit DMA addressing is needed for QBMan to
be usuable.
Signed-off-by: Roy Pledge <roy.pledge@nxp.com>
Signed-off-by: Madalin Bucur <madalin.bucur@nxp.com>
---
drivers/soc/fsl/qbman/Kconfig | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/soc/fsl/qbman/Kconfig b/drivers/soc/fsl/qbman/Kconfig
index d570cb5fd381..b0943e541796 100644
--- a/drivers/soc/fsl/qbman/Kconfig
+++ b/drivers/soc/fsl/qbman/Kconfig
@@ -1,6 +1,6 @@
menuconfig FSL_DPAA
bool "QorIQ DPAA1 framework support"
- depends on (FSL_SOC_BOOKE || ARCH_LAYERSCAPE)
+ depends on ((FSL_SOC_BOOKE || ARCH_LAYERSCAPE) && ARCH_DMA_ADDR_T_64BIT)
select GENERIC_ALLOCATOR
help
The Freescale Data Path Acceleration Architecture (DPAA) is a set of
--
2.1.0
^ permalink raw reply related
* [PATCH v2 4/5] soc/fsl/qbman: Use last response to determine valid bit
From: Madalin Bucur @ 2018-09-28 8:43 UTC (permalink / raw)
To: leoyang.li
Cc: Madalin Bucur, catalin.marinas, roy.pledge, linux-kernel, oss,
claudiu.manoil, linuxppc-dev, linux-arm-kernel
In-Reply-To: <1538124204-31406-1-git-send-email-madalin.bucur@nxp.com>
From: Roy Pledge <roy.pledge@nxp.com>
Use the last valid response when determining what valid bit
to use next for management commands. This is needed in the
case that the portal was previously used by other software
like a bootloader or if the kernel is restarted without a
hardware reset.
Signed-off-by: Roy Pledge <roy.pledge@nxp.com>
Signed-off-by: Madalin Bucur <madalin.bucur@nxp.com>
---
drivers/soc/fsl/qbman/qman.c | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/drivers/soc/fsl/qbman/qman.c b/drivers/soc/fsl/qbman/qman.c
index 0ffe7a1d0eae..99d0f87889b8 100644
--- a/drivers/soc/fsl/qbman/qman.c
+++ b/drivers/soc/fsl/qbman/qman.c
@@ -850,12 +850,24 @@ static inline void qm_mr_set_ithresh(struct qm_portal *portal, u8 ithresh)
static inline int qm_mc_init(struct qm_portal *portal)
{
+ u8 rr0, rr1;
struct qm_mc *mc = &portal->mc;
mc->cr = portal->addr.ce + QM_CL_CR;
mc->rr = portal->addr.ce + QM_CL_RR0;
- mc->rridx = (mc->cr->_ncw_verb & QM_MCC_VERB_VBIT)
- ? 0 : 1;
+ /*
+ * The expected valid bit polarity for the next CR command is 0
+ * if RR1 contains a valid response, and is 1 if RR0 contains a
+ * valid response. If both RR contain all 0, this indicates either
+ * that no command has been executed since reset (in which case the
+ * expected valid bit polarity is 1)
+ */
+ rr0 = mc->rr->verb;
+ rr1 = (mc->rr+1)->verb;
+ if ((rr0 == 0 && rr1 == 0) || rr0 != 0)
+ mc->rridx = 1;
+ else
+ mc->rridx = 0;
mc->vbit = mc->rridx ? QM_MCC_VERB_VBIT : 0;
#ifdef CONFIG_FSL_DPAA_CHECKING
mc->state = qman_mc_idle;
--
2.1.0
^ permalink raw reply related
* [PATCH v2 5/5] soc/fsl_qbman: export coalesce change API
From: Madalin Bucur @ 2018-09-28 8:43 UTC (permalink / raw)
To: leoyang.li
Cc: Madalin Bucur, catalin.marinas, roy.pledge, linux-kernel, oss,
claudiu.manoil, linuxppc-dev, linux-arm-kernel
In-Reply-To: <1538124204-31406-1-git-send-email-madalin.bucur@nxp.com>
Export the API required to control the QMan portal interrupt coalescing
settings.
Signed-off-by: Madalin Bucur <madalin.bucur@nxp.com>
---
drivers/soc/fsl/qbman/qman.c | 31 +++++++++++++++++++++++++++++++
include/soc/fsl/qman.h | 27 +++++++++++++++++++++++++++
2 files changed, 58 insertions(+)
diff --git a/drivers/soc/fsl/qbman/qman.c b/drivers/soc/fsl/qbman/qman.c
index 99d0f87889b8..8ab75bb44c4d 100644
--- a/drivers/soc/fsl/qbman/qman.c
+++ b/drivers/soc/fsl/qbman/qman.c
@@ -1012,6 +1012,37 @@ static inline void put_affine_portal(void)
static struct workqueue_struct *qm_portal_wq;
+void qman_dqrr_set_ithresh(struct qman_portal *portal, u8 ithresh)
+{
+ if (!portal)
+ return;
+
+ qm_dqrr_set_ithresh(&portal->p, ithresh);
+ portal->p.dqrr.ithresh = ithresh;
+}
+EXPORT_SYMBOL(qman_dqrr_set_ithresh);
+
+void qman_dqrr_get_ithresh(struct qman_portal *portal, u8 *ithresh)
+{
+ if (portal && ithresh)
+ *ithresh = portal->p.dqrr.ithresh;
+}
+EXPORT_SYMBOL(qman_dqrr_get_ithresh);
+
+void qman_portal_get_iperiod(struct qman_portal *portal, u32 *iperiod)
+{
+ if (portal && iperiod)
+ *iperiod = qm_in(&portal->p, QM_REG_ITPR);
+}
+EXPORT_SYMBOL(qman_portal_get_iperiod);
+
+void qman_portal_set_iperiod(struct qman_portal *portal, u32 iperiod)
+{
+ if (portal)
+ qm_out(&portal->p, QM_REG_ITPR, iperiod);
+}
+EXPORT_SYMBOL(qman_portal_set_iperiod);
+
int qman_wq_alloc(void)
{
qm_portal_wq = alloc_workqueue("qman_portal_wq", 0, 1);
diff --git a/include/soc/fsl/qman.h b/include/soc/fsl/qman.h
index d4dfefdee6c1..42f50eb51529 100644
--- a/include/soc/fsl/qman.h
+++ b/include/soc/fsl/qman.h
@@ -1186,4 +1186,31 @@ int qman_alloc_cgrid_range(u32 *result, u32 count);
*/
int qman_release_cgrid(u32 id);
+/**
+ * qman_dqrr_get_ithresh - Get coalesce interrupt threshold
+ * @portal: portal to get the value for
+ * @ithresh: threshold pointer
+ */
+void qman_dqrr_get_ithresh(struct qman_portal *portal, u8 *ithresh);
+
+/**
+ * qman_dqrr_set_ithresh - Set coalesce interrupt threshold
+ * @portal: portal to set the new value on
+ * @ithresh: new threshold value
+ */
+void qman_dqrr_set_ithresh(struct qman_portal *portal, u8 ithresh);
+
+/**
+ * qman_dqrr_get_iperiod - Get coalesce interrupt period
+ * @portal: portal to get the value for
+ * @iperiod: period pointer
+ */
+void qman_portal_get_iperiod(struct qman_portal *portal, u32 *iperiod);
+/*
+ * qman_dqrr_set_iperiod - Set coalesce interrupt period
+ * @portal: portal to set the new value on
+ * @ithresh: new period value
+ */
+void qman_portal_set_iperiod(struct qman_portal *portal, u32 iperiod);
+
#endif /* __FSL_QMAN_H */
--
2.1.0
^ permalink raw reply related
* [PATCH v2] powerpc: wire up memtest
From: Christophe Leroy @ 2018-09-28 8:57 UTC (permalink / raw)
To: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman
Cc: linuxppc-dev, linux-kernel
Add call to early_memtest() so that kernel compiled with
CONFIG_MEMTEST really perform memtest at startup when requested
via 'memtest' boot parameter.
Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
---
v2: moved the test after initmem_init() as PPC64 sets max_low_pfn later than PPC32.
arch/powerpc/kernel/setup-common.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/arch/powerpc/kernel/setup-common.c b/arch/powerpc/kernel/setup-common.c
index 93fa0c99681e..9ca9db707bcb 100644
--- a/arch/powerpc/kernel/setup-common.c
+++ b/arch/powerpc/kernel/setup-common.c
@@ -33,6 +33,7 @@
#include <linux/serial_8250.h>
#include <linux/percpu.h>
#include <linux/memblock.h>
+#include <linux/bootmem.h>
#include <linux/of_platform.h>
#include <linux/hugetlb.h>
#include <asm/debugfs.h>
@@ -966,6 +967,8 @@ void __init setup_arch(char **cmdline_p)
initmem_init();
+ early_memtest(min_low_pfn << PAGE_SHIFT, max_low_pfn << PAGE_SHIFT);
+
#ifdef CONFIG_DUMMY_CONSOLE
conswitchp = &dummy_con;
#endif
--
2.13.3
^ permalink raw reply related
* [GIT PULL] Please pull powerpc/linux.git powerpc-4.19-3 tag
From: Michael Ellerman @ 2018-09-28 11:39 UTC (permalink / raw)
To: Greg KH; +Cc: mikey, srikar, aik, linux-kernel, mwb, linuxppc-dev, bauerman
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512
Hi Greg,
Please pull some more powerpc fixes for 4.19:
The following changes since commit 11da3a7f84f19c26da6f86af878298694ede0804:
Linux 4.19-rc3 (2018-09-09 17:26:43 -0700)
are available in the git repository at:
https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git tags/powerpc-4.19-3
for you to fetch changes up to 7e0cf1c983b5b24426d130fd949a055d520acc9a:
selftests/powerpc: Fix Makefiles for headers_install change (2018-09-28 15:07:45 +1000)
- ------------------------------------------------------------------
powerpc fixes for 4.19 #3
A reasonably big batch of fixes due to me being away for a few weeks.
A fix for the TM emulation support on Power9, which could result in corrupting
the guest r11 when running under KVM.
Two fixes to the TM code which could lead to userspace GPR corruption if we take
an SLB miss at exactly the wrong time.
Our dynamic patching code had a bug that meant we could patch freed __init text,
which could lead to corrupting userspace memory.
csum_ipv6_magic() didn't work on little endian platforms since we optimised it
recently.
A fix for an endian bug when reading a device tree property telling us how many
storage keys the machine has available.
Fix a crash seen on some configurations of PowerVM when migrating the partition
from one machine to another.
A fix for a regression in the setup of our CPU to NUMA node mapping in KVM
guests.
A fix to our selftest Makefiles to make them work since a recent change to the
shared Makefile logic.
Thanks to:
Alexey Kardashevskiy, Breno Leitao, Christophe Leroy, Michael Bringmann,
Michael Neuling, Nicholas Piggin, Paul Mackerras,, Srikar Dronamraju, Thiago
Jung Bauermann, Xin Long.
- ------------------------------------------------------------------
Alexey Kardashevskiy (1):
powerpc/powernv/ioda2: Reduce upper limit for DMA window size (again)
Christophe Leroy (1):
powerpc: fix csum_ipv6_magic() on little endian platforms
Michael Bringmann (1):
powerpc/pseries: Fix unitialized timer reset on migration
Michael Ellerman (1):
selftests/powerpc: Fix Makefiles for headers_install change
Michael Neuling (4):
KVM: PPC: Book3S HV: Fix guest r11 corruption with POWER9 TM workarounds
powerpc: Avoid code patching freed init sections
powerpc/tm: Fix userspace r13 corruption
powerpc/tm: Avoid possible userspace r1 corruption on reclaim
Srikar Dronamraju (1):
powerpc/numa: Use associativity if VPHN hcall is successful
Thiago Jung Bauermann (1):
powerpc/pkeys: Fix reading of ibm, processor-storage-keys property
arch/powerpc/include/asm/setup.h | 1 +
arch/powerpc/kernel/exceptions-64s.S | 4 ++--
arch/powerpc/kernel/tm.S | 20 +++++++++++++++++---
arch/powerpc/lib/checksum_64.S | 3 +++
arch/powerpc/lib/code-patching.c | 6 ++++++
arch/powerpc/mm/mem.c | 2 ++
arch/powerpc/mm/numa.c | 7 +++++--
arch/powerpc/mm/pkeys.c | 2 +-
arch/powerpc/platforms/powernv/pci-ioda-tce.c | 2 +-
tools/testing/selftests/powerpc/alignment/Makefile | 1 +
tools/testing/selftests/powerpc/benchmarks/Makefile | 1 +
tools/testing/selftests/powerpc/cache_shape/Makefile | 1 +
tools/testing/selftests/powerpc/copyloops/Makefile | 1 +
tools/testing/selftests/powerpc/dscr/Makefile | 1 +
tools/testing/selftests/powerpc/math/Makefile | 1 +
tools/testing/selftests/powerpc/mm/Makefile | 1 +
tools/testing/selftests/powerpc/pmu/Makefile | 1 +
tools/testing/selftests/powerpc/pmu/ebb/Makefile | 1 +
tools/testing/selftests/powerpc/primitives/Makefile | 1 +
tools/testing/selftests/powerpc/ptrace/Makefile | 1 +
tools/testing/selftests/powerpc/signal/Makefile | 1 +
tools/testing/selftests/powerpc/stringloops/Makefile | 1 +
.../testing/selftests/powerpc/switch_endian/Makefile | 1 +
tools/testing/selftests/powerpc/syscalls/Makefile | 1 +
tools/testing/selftests/powerpc/tm/Makefile | 1 +
tools/testing/selftests/powerpc/vphn/Makefile | 1 +
26 files changed, 55 insertions(+), 9 deletions(-)
-----BEGIN PGP SIGNATURE-----
iQIzBAEBCgAdFiEEJFGtCPCthwEv2Y/bUevqPMjhpYAFAluuEqoACgkQUevqPMjh
pYDd2Q/9FuvhAY3jn89VcWFATv8bst/h0ujZp9w9IJapA3Pa3kAktrFo7arwvbqM
M1ffcbuU+klIYL0PpJN1pN19xZCd+vsYmmlx4OwpXBmA9+hIyX6WKo5rxLDc/cbq
N8b6ARmA4b8qIXSeLlUZ8WjQ+Qw19DzNLNq7MpCFHS1fkaE8ozn9bQLm+8v/M9Qz
6lKneV3pSvGIDI0PQOP3FC6TNKdR36MVng1LW9lKlt8y3gJFboNaP/5QGz7x3sBP
qe4cqxx9F9GlJyonQxz6T0PcoxFpk2DTKnxlnJ2okT7QG30hXXdJkgWStE58Xgyp
8yTJYZ+KXcpt/hfwMR82RVP9TzDr1UwXnuWF8slkoEu+y+YcZrlnajzoZVgojXqH
aU4k3pcQJXOU0evOz9+TvL23ilV6dCRIt5Fv9Hy3+QUnc2+2iFe3+AEPIKAXUWPG
mPhI37020GLBfi+ymUIoJ8vRwahQEcr2aH+uWndjV8+4FgNw3ygLbTGCAnsh4nHq
y1jUm1Ep5tjhM9IkKPTvY5IrAdUnOdfaZ8ZkS1hawf4P8po4wxzxhDxSce5N69W0
sLsmPnNvtnMS75pAMa68pGCxAJV34CmW57RhNNom3zU3Of7le/ZG3tX7IODqLpKT
8E2Ijaseq4M0hOyHvTVxABNErxWyDIOO7YFJTg/7Qwkf3P/tL/w=
=V+r1
-----END PGP SIGNATURE-----
^ permalink raw reply
* Re: [PATCH] powerpc: wire up memtest
From: Michael Ellerman @ 2018-09-28 12:44 UTC (permalink / raw)
To: Christophe LEROY, Benjamin Herrenschmidt, Paul Mackerras
Cc: linuxppc-dev, linux-kernel
In-Reply-To: <9f0055e2-ebd1-649b-272e-cb9b58bd4e15@c-s.fr>
Christophe LEROY <christophe.leroy@c-s.fr> writes:
> Le 28/09/2018 à 05:41, Michael Ellerman a écrit :
>> Christophe Leroy <christophe.leroy@c-s.fr> writes:
>>> Add call to early_memtest() so that kernel compiled with
>>> CONFIG_MEMTEST really perform memtest at startup when requested
>>> via 'memtest' boot parameter.
>>>
>>> Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
>>> ---
>>> arch/powerpc/kernel/setup-common.c | 3 +++
>>> 1 file changed, 3 insertions(+)
>>>
>>> diff --git a/arch/powerpc/kernel/setup-common.c b/arch/powerpc/kernel/setup-common.c
>>> index 93fa0c99681e..904b728eb20d 100644
>>> --- a/arch/powerpc/kernel/setup-common.c
>>> +++ b/arch/powerpc/kernel/setup-common.c
>>> @@ -33,6 +33,7 @@
>>> #include <linux/serial_8250.h>
>>> #include <linux/percpu.h>
>>> #include <linux/memblock.h>
>>> +#include <linux/bootmem.h>
>>> #include <linux/of_platform.h>
>>> #include <linux/hugetlb.h>
>>> #include <asm/debugfs.h>
>>> @@ -917,6 +918,8 @@ void __init setup_arch(char **cmdline_p)
>>> /* Parse memory topology */
>>> mem_topology_setup();
>>>
>>> + early_memtest(min_low_pfn << PAGE_SHIFT, max_low_pfn << PAGE_SHIFT);
>>
>> On a ppc64le VM this boils down to early_memtest(0, 0) for me.
>>
>> I think it's too early, we don't set up max_low_pfn until
>> initmem_init().
>>
>> If I move it after initmem_init() then it does something more useful:
>
> Ok. On my 8xx max_low_pfn is set in mem_topology_setup().
>
> Moving the test afte initmem_init() still works on the 8xx so I'll do that.
Great, thanks.
cheers
^ permalink raw reply
* Re: [PATCH kernel] cxl: Remove unused include
From: Michael Ellerman @ 2018-09-28 12:46 UTC (permalink / raw)
To: Alexey Kardashevskiy, linuxppc-dev
Cc: Alexey Kardashevskiy, Andrew Donnellan, Frederic Barrat
In-Reply-To: <20180928063804.35692-1-aik@ozlabs.ru>
Alexey Kardashevskiy <aik@ozlabs.ru> writes:
> The included opal.h gives a wrong idea that CXL makes PPC OPAL calls
> while it does not so let's remote it.
But it does use eg.
OPAL_PHB_CAPI_MODE_SNOOP_ON
OPAL_PHB_CAPI_MODE_CAPI
Which come from opal-api.h via opal.h.
So you should at least include opal-api.h.
cheers
> diff --git a/drivers/misc/cxl/pci.c b/drivers/misc/cxl/pci.c
> index b66d832..8cbcbb7 100644
> --- a/drivers/misc/cxl/pci.c
> +++ b/drivers/misc/cxl/pci.c
> @@ -17,7 +17,6 @@
> #include <linux/pci.h>
> #include <linux/of.h>
> #include <linux/delay.h>
> -#include <asm/opal.h>
> #include <asm/msi_bitmap.h>
> #include <asm/pnv-pci.h>
> #include <asm/io.h>
> --
> 2.11.0
^ permalink raw reply
* Re: [PATCH v4 1/2] powerpc/32: add stack protector support
From: Michael Ellerman @ 2018-09-28 12:56 UTC (permalink / raw)
To: Christophe LEROY, Segher Boessenkool
Cc: Paul Mackerras, linuxppc-dev, linux-kernel
In-Reply-To: <28451b6a-e302-691e-ee28-16521997fb07@c-s.fr>
Christophe LEROY <christophe.leroy@c-s.fr> writes:
> Le 27/09/2018 à 09:45, Segher Boessenkool a écrit :
>> On Thu, Sep 27, 2018 at 08:20:00AM +0200, Christophe LEROY wrote:
...
>>
>>> However this is the canary for initial startup only. Only idle() still
>>> uses this canary once the system is running. A new canary is set for any
>>> new forked task.
>>
>> Ah, that makes things a lot better! Do those new tasks get a canary
>> from something with sufficient entropy though?
>
> For the kernel threads that are started early, probably not. For the
> ones started a bit later, and for user processes, I believe they have
> better entropy. Anyway, all this is handled by the kernel core and is
> out of control of individual arches, as its done in kernel/fork.c in
> function dup_task_struct(). However this function is declared as
> static __latent_entropy struct task_struct *copy_process(). This
> __latent_entropy attibute must help in a way.
>
>>
>>> Maybe should the idle canary be updated later once there is more entropy
>>
>> That is tricky to do, but sure, if you can, that should help.
>>
>>> ? Today there is a new call to boot_init_stack_canary() in
>>> cpu_startup_entry(), but it is enclosed inside #ifdef CONFIG_X86.
>>
>> It needs to know the details of how ssp works on each platform.
>
> Well, that could be for another patch in the future. That's probably
> feasible on x86 and PPC because they both use TLS guard, but not for
> other arches where the guard is global at the moment. So we'll have to
> do it carefully.
>
> I agree with you that we may not for the time being get all the expected
> security against hackers out of it due to that little entropy, but my
> main concern at the time being is to deter developper's bugs clobbering
> the stack, and for that any non trivial canary should make it, shouldn't
> it ?
Yes.
The problem of low entropy at boot on systems without a good hardware
source is sort of unsolvable.
As you say it's up to the core kernel/random code, we shouldn't be
trying to do anything tricky in the arch code.
You don't want your system to take 3 hours to boot because it's waiting
for entropy for the stack canary.
If we can update the canary later once the entropy pool is setup that
would be ideal.
cheers
^ permalink raw reply
* Re: [PATCH] kdb: use correct pointer when 'btc' calls 'btt'
From: Michael Ellerman @ 2018-09-28 12:57 UTC (permalink / raw)
To: Christophe LEROY, Daniel Thompson
Cc: kgdb-bugreport, linux-kernel, stable, Jason Wessel, linuxppc-dev,
me
In-Reply-To: <7cf2d115-a58b-4585-37fc-7e58169a43a3@c-s.fr>
Christophe LEROY <christophe.leroy@c-s.fr> writes:
> Le 27/09/2018 à 13:09, Michael Ellerman a écrit :
>> Christophe LEROY <christophe.leroy@c-s.fr> writes:
>>> Le 26/09/2018 à 13:11, Daniel Thompson a écrit :
>>>> On 16/09/2018 20:06, Daniel Thompson wrote:
>>>>> On Fri, Sep 14, 2018 at 12:35:44PM +0000, Christophe Leroy wrote:
>>>>>> On a powerpc 8xx, 'btc' fails as follows:
>>>>>> Entering kdb (current=0x(ptrval), pid 282) due to Keyboard Entry
>> ...
>>>>>>
>>>>>> Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
>>>>>> Cc: <stable@vger.kernel.org> # 4.15+
>>>>>
>>>>> Would a Fixes: be better here?
>>>>> Fixes: ad67b74d2469d9b82 ("printk: hash addresses printed with %p")
>>>>
>>>> Christophe, When you add the Fixes: could you also add my
>>>>
>>>> Reviewed-by: Daniel Thompson <daniel.thompson@linaro.org>
>>>
>>> Ok, thanks for the review, but do I have to do anything really ?
>>>
>>> The Fixes: and now your Reviewed-by: appear automatically in patchwork
>>> (https://patchwork.ozlabs.org/project/linuxppc-dev/list/?series=65715),
>>> so I believe they'll be automatically included when Jason or someone
>>> else takes the patch, no ?
>>
>> patchwork won't add the Fixes tag from the reply, it needs to be in the
>> original mail.
>>
>> See:
>> https://github.com/getpatchwork/patchwork/issues/151
>>
>
> Ok, so it accounts it and adds a '1' in the F column in the patches
> list, but won't take it into account.
Yes. The logic that populates the columns is separate from the logic
that scrapes the tags, which is a bug :)
> Then I'll send a v2 with revised commit text.
Thanks.
cheers
^ permalink raw reply
* Re: [PATCH v6] selftests: add headers_install to lib.mk
From: Shuah Khan @ 2018-09-28 13:52 UTC (permalink / raw)
To: Michael Ellerman, Anders Roxell, yamada.masahiro, michal.lkml,
bamv2005, brgl, pbonzini, akpm, rppt, aarcange
Cc: linux-kbuild, netdev, linuxppc-dev, linux-kernel, linux-kselftest,
Shuah Khan
In-Reply-To: <87y3bmte9l.fsf@concordia.ellerman.id.au>
On 09/27/2018 10:52 PM, Michael Ellerman wrote:
> [ + linuxppc-dev ]
>
> Anders Roxell <anders.roxell@linaro.org> writes:
>> If the kernel headers aren't installed we can't build all the tests.
>> Add a new make target rule 'khdr' in the file lib.mk to generate the
>> kernel headers and that gets include for every test-dir Makefile that
>> includes lib.mk If the testdir in turn have its own sub-dirs the
>> top_srcdir needs to be set to the linux-rootdir to be able to generate
>> the kernel headers.
>>
>> Signed-off-by: Anders Roxell <anders.roxell@linaro.org>
>> Reviewed-by: Fathi Boudra <fathi.boudra@linaro.org>
>> ---
>>
>> I sent this (v5) a month ago and wondered if it got lost. Resending
>> unchanged.
>>
>> Cheers,
>> Anders
>>
>> Makefile | 14 +-------------
>> scripts/subarch.include | 13 +++++++++++++
>> tools/testing/selftests/android/Makefile | 2 +-
>> tools/testing/selftests/android/ion/Makefile | 2 ++
>> tools/testing/selftests/futex/functional/Makefile | 1 +
>> tools/testing/selftests/gpio/Makefile | 7 ++-----
>> tools/testing/selftests/kvm/Makefile | 7 ++-----
>> tools/testing/selftests/lib.mk | 12 ++++++++++++
>> tools/testing/selftests/net/Makefile | 1 +
>> .../selftests/networking/timestamping/Makefile | 1 +
>> tools/testing/selftests/vm/Makefile | 4 ----
>> 11 files changed, 36 insertions(+), 28 deletions(-)
>> create mode 100644 scripts/subarch.include
>
> This broke all the powerpc selftests :(
Sorry for thr breakage.
>
> Why did it go in at rc5?
>
This patch has been in linux-next for a sometime before I decided to send this.
My original intent was to send this for rc2, and my schedule was messed up with
traveling. Since I didn't hear any issues from linux-next soaking, I made a call
on sending this in for rc5.
On second thought I should have waited until 4.20. Sorry about that.
thanks,
-- Shuah
^ permalink raw reply
* Re: [PATCH v2] powerpc: wire up memtest
From: Daniel Axtens @ 2018-09-28 14:30 UTC (permalink / raw)
To: Christophe Leroy, Benjamin Herrenschmidt, Paul Mackerras,
Michael Ellerman
Cc: linuxppc-dev, linux-kernel
In-Reply-To: <5ccbb0b1ce0a86ef7a77e7b8dbb85c3637bf4628.1538087238.git.christophe.leroy@c-s.fr>
Hi Christophe,
> Add call to early_memtest() so that kernel compiled with
> CONFIG_MEMTEST really perform memtest at startup when requested
> via 'memtest' boot parameter.
>
This works for me on an e6500.
Tested-by: Daniel Axtens <dja@axtens.net>
However, you should also change Documentation/admin-guide/kernel-parameters.txt
to reflect that memtest is supported natively on ppc with your patch.
Regards,
Daniel
> Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
> ---
> v2: moved the test after initmem_init() as PPC64 sets max_low_pfn later than PPC32.
>
> arch/powerpc/kernel/setup-common.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/arch/powerpc/kernel/setup-common.c b/arch/powerpc/kernel/setup-common.c
> index 93fa0c99681e..9ca9db707bcb 100644
> --- a/arch/powerpc/kernel/setup-common.c
> +++ b/arch/powerpc/kernel/setup-common.c
> @@ -33,6 +33,7 @@
> #include <linux/serial_8250.h>
> #include <linux/percpu.h>
> #include <linux/memblock.h>
> +#include <linux/bootmem.h>
> #include <linux/of_platform.h>
> #include <linux/hugetlb.h>
> #include <asm/debugfs.h>
> @@ -966,6 +967,8 @@ void __init setup_arch(char **cmdline_p)
>
> initmem_init();
>
> + early_memtest(min_low_pfn << PAGE_SHIFT, max_low_pfn << PAGE_SHIFT);
> +
> #ifdef CONFIG_DUMMY_CONSOLE
> conswitchp = &dummy_con;
> #endif
> --
> 2.13.3
^ permalink raw reply
* [PATCH RFC] mm/memory_hotplug: Introduce memory block types
From: David Hildenbrand @ 2018-09-28 15:03 UTC (permalink / raw)
To: linux-mm
Cc: Kate Stewart, Rich Felker, linux-ia64, linux-sh, Peter Zijlstra,
Dave Hansen, Heiko Carstens, Pavel Tatashin, Michal Hocko,
Paul Mackerras, H. Peter Anvin, Rashmica Gupta, K. Y. Srinivasan,
Boris Ostrovsky, linux-s390, Michael Neuling, Stephen Hemminger,
Yoshinori Sato, David Hildenbrand, linux-acpi, Ingo Molnar,
xen-devel, Rob Herring, Len Brown, Fenghua Yu, Stephen Rothwell,
mike.travis@hpe.com, Haiyang Zhang, Dan Williams,
Jonathan Neuschäfer, Nicholas Piggin, Joe Perches,
Jérôme Glisse, Mike Rapoport, Borislav Petkov,
Andy Lutomirski, Thomas Gleixner, Joonsoo Kim, Oscar Salvador,
Juergen Gross, Tony Luck, Mathieu Malaterre, Greg Kroah-Hartman,
Rafael J. Wysocki, linux-kernel, Mauricio Faria de Oliveira,
Philippe Ombredanne, Martin Schwidefsky, devel, Andrew Morton,
linuxppc-dev, Kirill A. Shutemov
How to/when to online hotplugged memory is hard to manage for
distributions because different memory types are to be treated differently.
Right now, we need complicated udev rules that e.g. check if we are
running on s390x, on a physical system or on a virtualized system. But
there is also sometimes the demand to really online memory immediately
while adding in the kernel and not to wait for user space to make a
decision. And on virtualized systems there might be different
requirements, depending on "how" the memory was added (and if it will
eventually get unplugged again - DIMM vs. paravirtualized mechanisms).
On the one hand, we have physical systems where we sometimes
want to be able to unplug memory again - e.g. a DIMM - so we have to online
it to the MOVABLE zone optionally. That decision is usually made in user
space.
On the other hand, we have memory that should never be onlined
automatically, only when asked for by an administrator. Such memory only
applies to virtualized environments like s390x, where the concept of
"standby" memory exists. Memory is detected and added during boot, so it
can be onlined when requested by the admininistrator or some tooling.
Only when onlining, memory will be allocated in the hypervisor.
But then, we also have paravirtualized devices (namely xen and hyper-v
balloons), that hotplug memory that will never ever be removed from a
system right now using offline_pages/remove_memory. If at all, this memory
is logically unplugged and handed back to the hypervisor via ballooning.
For paravirtualized devices it is relevant that memory is onlined as
quickly as possible after adding - and that it is added to the NORMAL
zone. Otherwise, it could happen that too much memory in a row is added
(but not onlined), resulting in out-of-memory conditions due to the
additional memory for "struct pages" and friends. MOVABLE zone as well
as delays might be very problematic and lead to crashes (e.g. zone
imbalance).
Therefore, introduce memory block types and online memory depending on
it when adding the memory. Expose the memory type to user space, so user
space handlers can start to process only "normal" memory. Other memory
block types can be ignored. One thing less to worry about in user space.
Cc: Tony Luck <tony.luck@intel.com>
Cc: Fenghua Yu <fenghua.yu@intel.com>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
Cc: Rich Felker <dalias@libc.org>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
Cc: Len Brown <lenb@kernel.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: "K. Y. Srinivasan" <kys@microsoft.com>
Cc: Haiyang Zhang <haiyangz@microsoft.com>
Cc: Stephen Hemminger <sthemmin@microsoft.com>
Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Cc: Juergen Gross <jgross@suse.com>
Cc: "Jérôme Glisse" <jglisse@redhat.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Mike Rapoport <rppt@linux.vnet.ibm.com>
Cc: Dan Williams <dan.j.williams@intel.com>
Cc: Stephen Rothwell <sfr@canb.auug.org.au>
Cc: Michal Hocko <mhocko@suse.com>
Cc: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
Cc: David Hildenbrand <david@redhat.com>
Cc: Nicholas Piggin <npiggin@gmail.com>
Cc: "Jonathan Neuschäfer" <j.neuschaefer@gmx.net>
Cc: Joe Perches <joe@perches.com>
Cc: Michael Neuling <mikey@neuling.org>
Cc: Mauricio Faria de Oliveira <mauricfo@linux.vnet.ibm.com>
Cc: Balbir Singh <bsingharora@gmail.com>
Cc: Rashmica Gupta <rashmica.g@gmail.com>
Cc: Pavel Tatashin <pavel.tatashin@microsoft.com>
Cc: Rob Herring <robh@kernel.org>
Cc: Philippe Ombredanne <pombredanne@nexb.com>
Cc: Kate Stewart <kstewart@linuxfoundation.org>
Cc: "mike.travis@hpe.com" <mike.travis@hpe.com>
Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Cc: Oscar Salvador <osalvador@suse.de>
Cc: Mathieu Malaterre <malat@debian.org>
Signed-off-by: David Hildenbrand <david@redhat.com>
---
This patch is based on the current mm-tree, where some related
patches from me are currently residing that touched the add_memory()
functions.
arch/ia64/mm/init.c | 4 +-
arch/powerpc/mm/mem.c | 4 +-
arch/powerpc/platforms/powernv/memtrace.c | 3 +-
arch/s390/mm/init.c | 4 +-
arch/sh/mm/init.c | 4 +-
arch/x86/mm/init_32.c | 4 +-
arch/x86/mm/init_64.c | 8 +--
drivers/acpi/acpi_memhotplug.c | 3 +-
drivers/base/memory.c | 63 ++++++++++++++++++++---
drivers/hv/hv_balloon.c | 33 ++----------
drivers/s390/char/sclp_cmd.c | 3 +-
drivers/xen/balloon.c | 2 +-
include/linux/memory.h | 28 +++++++++-
include/linux/memory_hotplug.h | 17 +++---
mm/hmm.c | 6 ++-
mm/memory_hotplug.c | 31 ++++++-----
16 files changed, 139 insertions(+), 78 deletions(-)
diff --git a/arch/ia64/mm/init.c b/arch/ia64/mm/init.c
index d5e12ff1d73c..813d1d86bf95 100644
--- a/arch/ia64/mm/init.c
+++ b/arch/ia64/mm/init.c
@@ -646,13 +646,13 @@ mem_init (void)
#ifdef CONFIG_MEMORY_HOTPLUG
int arch_add_memory(int nid, u64 start, u64 size, struct vmem_altmap *altmap,
- bool want_memblock)
+ int memory_block_type)
{
unsigned long start_pfn = start >> PAGE_SHIFT;
unsigned long nr_pages = size >> PAGE_SHIFT;
int ret;
- ret = __add_pages(nid, start_pfn, nr_pages, altmap, want_memblock);
+ ret = __add_pages(nid, start_pfn, nr_pages, altmap, memory_block_type);
if (ret)
printk("%s: Problem encountered in __add_pages() as ret=%d\n",
__func__, ret);
diff --git a/arch/powerpc/mm/mem.c b/arch/powerpc/mm/mem.c
index 5551f5870dcc..dd32fcc9099c 100644
--- a/arch/powerpc/mm/mem.c
+++ b/arch/powerpc/mm/mem.c
@@ -118,7 +118,7 @@ int __weak remove_section_mapping(unsigned long start, unsigned long end)
}
int __meminit arch_add_memory(int nid, u64 start, u64 size, struct vmem_altmap *altmap,
- bool want_memblock)
+ int memory_block_type)
{
unsigned long start_pfn = start >> PAGE_SHIFT;
unsigned long nr_pages = size >> PAGE_SHIFT;
@@ -135,7 +135,7 @@ int __meminit arch_add_memory(int nid, u64 start, u64 size, struct vmem_altmap *
}
flush_inval_dcache_range(start, start + size);
- return __add_pages(nid, start_pfn, nr_pages, altmap, want_memblock);
+ return __add_pages(nid, start_pfn, nr_pages, altmap, memory_block_type);
}
#ifdef CONFIG_MEMORY_HOTREMOVE
diff --git a/arch/powerpc/platforms/powernv/memtrace.c b/arch/powerpc/platforms/powernv/memtrace.c
index 84d038ed3882..57d6b3d46382 100644
--- a/arch/powerpc/platforms/powernv/memtrace.c
+++ b/arch/powerpc/platforms/powernv/memtrace.c
@@ -232,7 +232,8 @@ static int memtrace_online(void)
ent->mem = 0;
}
- if (add_memory(ent->nid, ent->start, ent->size)) {
+ if (add_memory(ent->nid, ent->start, ent->size,
+ MEMORY_BLOCK_NORMAL)) {
pr_err("Failed to add trace memory to node %d\n",
ent->nid);
ret += 1;
diff --git a/arch/s390/mm/init.c b/arch/s390/mm/init.c
index e472cd763eb3..b5324527c7f6 100644
--- a/arch/s390/mm/init.c
+++ b/arch/s390/mm/init.c
@@ -222,7 +222,7 @@ device_initcall(s390_cma_mem_init);
#endif /* CONFIG_CMA */
int arch_add_memory(int nid, u64 start, u64 size, struct vmem_altmap *altmap,
- bool want_memblock)
+ int memory_block_type)
{
unsigned long start_pfn = PFN_DOWN(start);
unsigned long size_pages = PFN_DOWN(size);
@@ -232,7 +232,7 @@ int arch_add_memory(int nid, u64 start, u64 size, struct vmem_altmap *altmap,
if (rc)
return rc;
- rc = __add_pages(nid, start_pfn, size_pages, altmap, want_memblock);
+ rc = __add_pages(nid, start_pfn, size_pages, altmap, memory_block_type);
if (rc)
vmem_remove_mapping(start, size);
return rc;
diff --git a/arch/sh/mm/init.c b/arch/sh/mm/init.c
index c8c13c777162..6b876000731a 100644
--- a/arch/sh/mm/init.c
+++ b/arch/sh/mm/init.c
@@ -419,14 +419,14 @@ void free_initrd_mem(unsigned long start, unsigned long end)
#ifdef CONFIG_MEMORY_HOTPLUG
int arch_add_memory(int nid, u64 start, u64 size, struct vmem_altmap *altmap,
- bool want_memblock)
+ int memory_block_type)
{
unsigned long start_pfn = PFN_DOWN(start);
unsigned long nr_pages = size >> PAGE_SHIFT;
int ret;
/* We only have ZONE_NORMAL, so this is easy.. */
- ret = __add_pages(nid, start_pfn, nr_pages, altmap, want_memblock);
+ ret = __add_pages(nid, start_pfn, nr_pages, altmap, memory_block_type);
if (unlikely(ret))
printk("%s: Failed, __add_pages() == %d\n", __func__, ret);
diff --git a/arch/x86/mm/init_32.c b/arch/x86/mm/init_32.c
index f2837e4c40b3..4f50cd4467a9 100644
--- a/arch/x86/mm/init_32.c
+++ b/arch/x86/mm/init_32.c
@@ -851,12 +851,12 @@ void __init mem_init(void)
#ifdef CONFIG_MEMORY_HOTPLUG
int arch_add_memory(int nid, u64 start, u64 size, struct vmem_altmap *altmap,
- bool want_memblock)
+ int memory_block_type)
{
unsigned long start_pfn = start >> PAGE_SHIFT;
unsigned long nr_pages = size >> PAGE_SHIFT;
- return __add_pages(nid, start_pfn, nr_pages, altmap, want_memblock);
+ return __add_pages(nid, start_pfn, nr_pages, altmap, memory_block_type);
}
#ifdef CONFIG_MEMORY_HOTREMOVE
diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
index 5fab264948c2..fc3df573f0f3 100644
--- a/arch/x86/mm/init_64.c
+++ b/arch/x86/mm/init_64.c
@@ -783,11 +783,11 @@ static void update_end_of_memory_vars(u64 start, u64 size)
}
int add_pages(int nid, unsigned long start_pfn, unsigned long nr_pages,
- struct vmem_altmap *altmap, bool want_memblock)
+ struct vmem_altmap *altmap, int memory_block_type)
{
int ret;
- ret = __add_pages(nid, start_pfn, nr_pages, altmap, want_memblock);
+ ret = __add_pages(nid, start_pfn, nr_pages, altmap, memory_block_type);
WARN_ON_ONCE(ret);
/* update max_pfn, max_low_pfn and high_memory */
@@ -798,14 +798,14 @@ int add_pages(int nid, unsigned long start_pfn, unsigned long nr_pages,
}
int arch_add_memory(int nid, u64 start, u64 size, struct vmem_altmap *altmap,
- bool want_memblock)
+ int memory_block_type)
{
unsigned long start_pfn = start >> PAGE_SHIFT;
unsigned long nr_pages = size >> PAGE_SHIFT;
init_memory_mapping(start, start + size);
- return add_pages(nid, start_pfn, nr_pages, altmap, want_memblock);
+ return add_pages(nid, start_pfn, nr_pages, altmap, memory_block_type);
}
#define PAGE_INUSE 0xFD
diff --git a/drivers/acpi/acpi_memhotplug.c b/drivers/acpi/acpi_memhotplug.c
index 8fe0960ea572..c5f646b4e97e 100644
--- a/drivers/acpi/acpi_memhotplug.c
+++ b/drivers/acpi/acpi_memhotplug.c
@@ -228,7 +228,8 @@ static int acpi_memory_enable_device(struct acpi_memory_device *mem_device)
if (node < 0)
node = memory_add_physaddr_to_nid(info->start_addr);
- result = __add_memory(node, info->start_addr, info->length);
+ result = __add_memory(node, info->start_addr, info->length,
+ MEMORY_BLOCK_NORMAL);
/*
* If the memory block has been used by the kernel, add_memory()
diff --git a/drivers/base/memory.c b/drivers/base/memory.c
index 0e5985682642..2686101e41b5 100644
--- a/drivers/base/memory.c
+++ b/drivers/base/memory.c
@@ -381,6 +381,32 @@ static ssize_t show_phys_device(struct device *dev,
return sprintf(buf, "%d\n", mem->phys_device);
}
+static ssize_t type_show(struct device *dev, struct device_attribute *attr,
+ char *buf)
+{
+ struct memory_block *mem = to_memory_block(dev);
+ ssize_t len = 0;
+
+ switch (mem->state) {
+ case MEMORY_BLOCK_NORMAL:
+ len = sprintf(buf, "normal\n");
+ break;
+ case MEMORY_BLOCK_STANDBY:
+ len = sprintf(buf, "standby\n");
+ break;
+ case MEMORY_BLOCK_PARAVIRT:
+ len = sprintf(buf, "paravirt\n");
+ break;
+ default:
+ len = sprintf(buf, "ERROR-UNKNOWN-%ld\n",
+ mem->state);
+ WARN_ON(1);
+ break;
+ }
+
+ return len;
+}
+
#ifdef CONFIG_MEMORY_HOTREMOVE
static void print_allowed_zone(char *buf, int nid, unsigned long start_pfn,
unsigned long nr_pages, int online_type,
@@ -442,6 +468,7 @@ static DEVICE_ATTR(phys_index, 0444, show_mem_start_phys_index, NULL);
static DEVICE_ATTR(state, 0644, show_mem_state, store_mem_state);
static DEVICE_ATTR(phys_device, 0444, show_phys_device, NULL);
static DEVICE_ATTR(removable, 0444, show_mem_removable, NULL);
+static DEVICE_ATTR_RO(type);
/*
* Block size attribute stuff
@@ -514,7 +541,8 @@ memory_probe_store(struct device *dev, struct device_attribute *attr,
nid = memory_add_physaddr_to_nid(phys_addr);
ret = __add_memory(nid, phys_addr,
- MIN_MEMORY_BLOCK_SIZE * sections_per_block);
+ MIN_MEMORY_BLOCK_SIZE * sections_per_block,
+ MEMORY_BLOCK_NORMAL);
if (ret)
goto out;
@@ -620,6 +648,7 @@ static struct attribute *memory_memblk_attrs[] = {
&dev_attr_state.attr,
&dev_attr_phys_device.attr,
&dev_attr_removable.attr,
+ &dev_attr_type.attr,
#ifdef CONFIG_MEMORY_HOTREMOVE
&dev_attr_valid_zones.attr,
#endif
@@ -657,13 +686,17 @@ int register_memory(struct memory_block *memory)
}
static int init_memory_block(struct memory_block **memory,
- struct mem_section *section, unsigned long state)
+ struct mem_section *section, unsigned long state,
+ int memory_block_type)
{
struct memory_block *mem;
unsigned long start_pfn;
int scn_nr;
int ret = 0;
+ if (memory_block_type == MEMORY_BLOCK_NONE)
+ return -EINVAL;
+
mem = kzalloc(sizeof(*mem), GFP_KERNEL);
if (!mem)
return -ENOMEM;
@@ -675,6 +708,7 @@ static int init_memory_block(struct memory_block **memory,
mem->state = state;
start_pfn = section_nr_to_pfn(mem->start_section_nr);
mem->phys_device = arch_get_memory_phys_device(start_pfn);
+ mem->type = memory_block_type;
ret = register_memory(mem);
@@ -699,7 +733,8 @@ static int add_memory_block(int base_section_nr)
if (section_count == 0)
return 0;
- ret = init_memory_block(&mem, __nr_to_section(section_nr), MEM_ONLINE);
+ ret = init_memory_block(&mem, __nr_to_section(section_nr), MEM_ONLINE,
+ MEMORY_BLOCK_NORMAL);
if (ret)
return ret;
mem->section_count = section_count;
@@ -710,19 +745,35 @@ static int add_memory_block(int base_section_nr)
* need an interface for the VM to add new memory regions,
* but without onlining it.
*/
-int hotplug_memory_register(int nid, struct mem_section *section)
+int hotplug_memory_register(int nid, struct mem_section *section,
+ int memory_block_type)
{
int ret = 0;
struct memory_block *mem;
mutex_lock(&mem_sysfs_mutex);
+ /* make sure there is no memblock if we don't want one */
+ if (memory_block_type == MEMORY_BLOCK_NONE) {
+ mem = find_memory_block(section);
+ if (mem) {
+ put_device(&mem->dev);
+ ret = -EINVAL;
+ }
+ goto out;
+ }
+
mem = find_memory_block(section);
if (mem) {
- mem->section_count++;
+ /* make sure the type matches */
+ if (mem->type == memory_block_type)
+ mem->section_count++;
+ else
+ ret = -EINVAL;
put_device(&mem->dev);
} else {
- ret = init_memory_block(&mem, section, MEM_OFFLINE);
+ ret = init_memory_block(&mem, section, MEM_OFFLINE,
+ memory_block_type);
if (ret)
goto out;
mem->section_count++;
diff --git a/drivers/hv/hv_balloon.c b/drivers/hv/hv_balloon.c
index b1b788082793..5a8d18c4d699 100644
--- a/drivers/hv/hv_balloon.c
+++ b/drivers/hv/hv_balloon.c
@@ -537,11 +537,6 @@ struct hv_dynmem_device {
*/
bool host_specified_ha_region;
- /*
- * State to synchronize hot-add.
- */
- struct completion ol_waitevent;
- bool ha_waiting;
/*
* This thread handles hot-add
* requests from the host as well as notifying
@@ -640,14 +635,6 @@ static int hv_memory_notifier(struct notifier_block *nb, unsigned long val,
unsigned long flags, pfn_count;
switch (val) {
- case MEM_ONLINE:
- case MEM_CANCEL_ONLINE:
- if (dm_device.ha_waiting) {
- dm_device.ha_waiting = false;
- complete(&dm_device.ol_waitevent);
- }
- break;
-
case MEM_OFFLINE:
spin_lock_irqsave(&dm_device.ha_lock, flags);
pfn_count = hv_page_offline_check(mem->start_pfn,
@@ -665,9 +652,7 @@ static int hv_memory_notifier(struct notifier_block *nb, unsigned long val,
}
spin_unlock_irqrestore(&dm_device.ha_lock, flags);
break;
- case MEM_GOING_ONLINE:
- case MEM_GOING_OFFLINE:
- case MEM_CANCEL_OFFLINE:
+ default:
break;
}
return NOTIFY_OK;
@@ -731,12 +716,10 @@ static void hv_mem_hot_add(unsigned long start, unsigned long size,
has->covered_end_pfn += processed_pfn;
spin_unlock_irqrestore(&dm_device.ha_lock, flags);
- init_completion(&dm_device.ol_waitevent);
- dm_device.ha_waiting = !memhp_auto_online;
-
nid = memory_add_physaddr_to_nid(PFN_PHYS(start_pfn));
ret = add_memory(nid, PFN_PHYS((start_pfn)),
- (HA_CHUNK << PAGE_SHIFT));
+ (HA_CHUNK << PAGE_SHIFT),
+ MEMORY_BLOCK_PARAVIRT);
if (ret) {
pr_err("hot_add memory failed error is %d\n", ret);
@@ -757,16 +740,6 @@ static void hv_mem_hot_add(unsigned long start, unsigned long size,
break;
}
- /*
- * Wait for the memory block to be onlined when memory onlining
- * is done outside of kernel (memhp_auto_online). Since the hot
- * add has succeeded, it is ok to proceed even if the pages in
- * the hot added region have not been "onlined" within the
- * allowed time.
- */
- if (dm_device.ha_waiting)
- wait_for_completion_timeout(&dm_device.ol_waitevent,
- 5*HZ);
post_status(&dm_device);
}
}
diff --git a/drivers/s390/char/sclp_cmd.c b/drivers/s390/char/sclp_cmd.c
index d7686a68c093..1928a2411456 100644
--- a/drivers/s390/char/sclp_cmd.c
+++ b/drivers/s390/char/sclp_cmd.c
@@ -406,7 +406,8 @@ static void __init add_memory_merged(u16 rn)
if (!size)
goto skip_add;
for (addr = start; addr < start + size; addr += block_size)
- add_memory(numa_pfn_to_nid(PFN_DOWN(addr)), addr, block_size);
+ add_memory(numa_pfn_to_nid(PFN_DOWN(addr)), addr, block_size,
+ MEMORY_BLOCK_STANDBY);
skip_add:
first_rn = rn;
num = 1;
diff --git a/drivers/xen/balloon.c b/drivers/xen/balloon.c
index fdfc64f5acea..291a8aac6af3 100644
--- a/drivers/xen/balloon.c
+++ b/drivers/xen/balloon.c
@@ -397,7 +397,7 @@ static enum bp_state reserve_additional_memory(void)
mutex_unlock(&balloon_mutex);
/* add_memory_resource() requires the device_hotplug lock */
lock_device_hotplug();
- rc = add_memory_resource(nid, resource, memhp_auto_online);
+ rc = add_memory_resource(nid, resource, MEMORY_BLOCK_PARAVIRT);
unlock_device_hotplug();
mutex_lock(&balloon_mutex);
diff --git a/include/linux/memory.h b/include/linux/memory.h
index a6ddefc60517..3dc2a0b12653 100644
--- a/include/linux/memory.h
+++ b/include/linux/memory.h
@@ -23,6 +23,30 @@
#define MIN_MEMORY_BLOCK_SIZE (1UL << SECTION_SIZE_BITS)
+/*
+ * NONE: No memory block is to be created (e.g. device memory).
+ * NORMAL: Memory block that represents normal (boot or hotplugged) memory
+ * (e.g. ACPI DIMMs) that should be onlined either automatically
+ * (memhp_auto_online) or manually by user space to select a
+ * specific zone.
+ * Applicable to memhp_auto_online.
+ * STANDBY: Memory block that represents standby memory that should only
+ * be onlined on demand by user space (e.g. standby memory on
+ * s390x), but never automatically by the kernel.
+ * Not applicable to memhp_auto_online.
+ * PARAVIRT: Memory block that represents memory added by
+ * paravirtualized mechanisms (e.g. hyper-v, xen) that will
+ * always automatically get onlined. Memory will be unplugged
+ * using ballooning, not by relying on the MOVABLE ZONE.
+ * Not applicable to memhp_auto_online.
+ */
+enum {
+ MEMORY_BLOCK_NONE,
+ MEMORY_BLOCK_NORMAL,
+ MEMORY_BLOCK_STANDBY,
+ MEMORY_BLOCK_PARAVIRT,
+};
+
struct memory_block {
unsigned long start_section_nr;
unsigned long end_section_nr;
@@ -34,6 +58,7 @@ struct memory_block {
int (*phys_callback)(struct memory_block *);
struct device dev;
int nid; /* NID for this memory block */
+ int type; /* type of this memory block */
};
int arch_get_memory_phys_device(unsigned long start_pfn);
@@ -111,7 +136,8 @@ extern int register_memory_notifier(struct notifier_block *nb);
extern void unregister_memory_notifier(struct notifier_block *nb);
extern int register_memory_isolate_notifier(struct notifier_block *nb);
extern void unregister_memory_isolate_notifier(struct notifier_block *nb);
-int hotplug_memory_register(int nid, struct mem_section *section);
+int hotplug_memory_register(int nid, struct mem_section *section,
+ int memory_block_type);
#ifdef CONFIG_MEMORY_HOTREMOVE
extern int unregister_memory_section(struct mem_section *);
#endif
diff --git a/include/linux/memory_hotplug.h b/include/linux/memory_hotplug.h
index ffd9cd10fcf3..b560a9ee0e8c 100644
--- a/include/linux/memory_hotplug.h
+++ b/include/linux/memory_hotplug.h
@@ -115,18 +115,18 @@ extern int __remove_pages(struct zone *zone, unsigned long start_pfn,
/* reasonably generic interface to expand the physical pages */
extern int __add_pages(int nid, unsigned long start_pfn, unsigned long nr_pages,
- struct vmem_altmap *altmap, bool want_memblock);
+ struct vmem_altmap *altmap, int memory_block_type);
#ifndef CONFIG_ARCH_HAS_ADD_PAGES
static inline int add_pages(int nid, unsigned long start_pfn,
unsigned long nr_pages, struct vmem_altmap *altmap,
- bool want_memblock)
+ int memory_block_type)
{
- return __add_pages(nid, start_pfn, nr_pages, altmap, want_memblock);
+ return __add_pages(nid, start_pfn, nr_pages, altmap, memory_block_type);
}
#else /* ARCH_HAS_ADD_PAGES */
int add_pages(int nid, unsigned long start_pfn, unsigned long nr_pages,
- struct vmem_altmap *altmap, bool want_memblock);
+ struct vmem_altmap *altmap, int memory_block_type);
#endif /* ARCH_HAS_ADD_PAGES */
#ifdef CONFIG_NUMA
@@ -324,11 +324,12 @@ static inline void __remove_memory(int nid, u64 start, u64 size) {}
extern void __ref free_area_init_core_hotplug(int nid);
extern int walk_memory_range(unsigned long start_pfn, unsigned long end_pfn,
void *arg, int (*func)(struct memory_block *, void *));
-extern int __add_memory(int nid, u64 start, u64 size);
-extern int add_memory(int nid, u64 start, u64 size);
-extern int add_memory_resource(int nid, struct resource *resource, bool online);
+extern int __add_memory(int nid, u64 start, u64 size, int memory_block_type);
+extern int add_memory(int nid, u64 start, u64 size, int memory_block_type);
+extern int add_memory_resource(int nid, struct resource *resource,
+ int memory_block_type);
extern int arch_add_memory(int nid, u64 start, u64 size,
- struct vmem_altmap *altmap, bool want_memblock);
+ struct vmem_altmap *altmap, int memory_block_type);
extern void move_pfn_range_to_zone(struct zone *zone, unsigned long start_pfn,
unsigned long nr_pages, struct vmem_altmap *altmap);
extern int offline_pages(unsigned long start_pfn, unsigned long nr_pages);
diff --git a/mm/hmm.c b/mm/hmm.c
index c968e49f7a0c..2350f6f6ab42 100644
--- a/mm/hmm.c
+++ b/mm/hmm.c
@@ -32,6 +32,7 @@
#include <linux/jump_label.h>
#include <linux/mmu_notifier.h>
#include <linux/memory_hotplug.h>
+#include <linux/memory.h>
#define PA_SECTION_SIZE (1UL << PA_SECTION_SHIFT)
@@ -1096,10 +1097,11 @@ static int hmm_devmem_pages_create(struct hmm_devmem *devmem)
*/
if (devmem->pagemap.type == MEMORY_DEVICE_PUBLIC)
ret = arch_add_memory(nid, align_start, align_size, NULL,
- false);
+ MEMORY_BLOCK_NONE);
else
ret = add_pages(nid, align_start >> PAGE_SHIFT,
- align_size >> PAGE_SHIFT, NULL, false);
+ align_size >> PAGE_SHIFT, NULL,
+ MEMORY_BLOCK_NONE);
if (ret) {
mem_hotplug_done();
goto error_add_memory;
diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
index d4c7e42e46f3..bce6c41d721c 100644
--- a/mm/memory_hotplug.c
+++ b/mm/memory_hotplug.c
@@ -246,7 +246,7 @@ void __init register_page_bootmem_info_node(struct pglist_data *pgdat)
#endif /* CONFIG_HAVE_BOOTMEM_INFO_NODE */
static int __meminit __add_section(int nid, unsigned long phys_start_pfn,
- struct vmem_altmap *altmap, bool want_memblock)
+ struct vmem_altmap *altmap, int memory_block_type)
{
int ret;
@@ -257,10 +257,11 @@ static int __meminit __add_section(int nid, unsigned long phys_start_pfn,
if (ret < 0)
return ret;
- if (!want_memblock)
+ if (memory_block_type == MEMBLOCK_NONE)
return 0;
- return hotplug_memory_register(nid, __pfn_to_section(phys_start_pfn));
+ return hotplug_memory_register(nid, __pfn_to_section(phys_start_pfn),
+ memory_block_type);
}
/*
@@ -271,7 +272,7 @@ static int __meminit __add_section(int nid, unsigned long phys_start_pfn,
*/
int __ref __add_pages(int nid, unsigned long phys_start_pfn,
unsigned long nr_pages, struct vmem_altmap *altmap,
- bool want_memblock)
+ int memory_block_type)
{
unsigned long i;
int err = 0;
@@ -296,7 +297,7 @@ int __ref __add_pages(int nid, unsigned long phys_start_pfn,
for (i = start_sec; i <= end_sec; i++) {
err = __add_section(nid, section_nr_to_pfn(i), altmap,
- want_memblock);
+ memory_block_type);
/*
* EEXIST is finally dealt with by ioresource collision
@@ -1099,7 +1100,8 @@ static int online_memory_block(struct memory_block *mem, void *arg)
*
* we are OK calling __meminit stuff here - we have CONFIG_MEMORY_HOTPLUG
*/
-int __ref add_memory_resource(int nid, struct resource *res, bool online)
+int __ref add_memory_resource(int nid, struct resource *res,
+ int memory_block_type)
{
u64 start, size;
bool new_node = false;
@@ -1108,6 +1110,9 @@ int __ref add_memory_resource(int nid, struct resource *res, bool online)
start = res->start;
size = resource_size(res);
+ if (memory_block_type == MEMORY_BLOCK_NONE)
+ return -EINVAL;
+
ret = check_hotplug_memory_range(start, size);
if (ret)
return ret;
@@ -1128,7 +1133,7 @@ int __ref add_memory_resource(int nid, struct resource *res, bool online)
new_node = ret;
/* call arch's memory hotadd */
- ret = arch_add_memory(nid, start, size, NULL, true);
+ ret = arch_add_memory(nid, start, size, NULL, memory_block_type);
if (ret < 0)
goto error;
@@ -1153,8 +1158,8 @@ int __ref add_memory_resource(int nid, struct resource *res, bool online)
/* device_online() will take the lock when calling online_pages() */
mem_hotplug_done();
- /* online pages if requested */
- if (online)
+ if (memory_block_type == MEMORY_BLOCK_PARAVIRT ||
+ (memory_block_type == MEMORY_BLOCK_NORMAL && memhp_auto_online))
walk_memory_range(PFN_DOWN(start), PFN_UP(start + size - 1),
NULL, online_memory_block);
@@ -1169,7 +1174,7 @@ int __ref add_memory_resource(int nid, struct resource *res, bool online)
}
/* requires device_hotplug_lock, see add_memory_resource() */
-int __ref __add_memory(int nid, u64 start, u64 size)
+int __ref __add_memory(int nid, u64 start, u64 size, int memory_block_type)
{
struct resource *res;
int ret;
@@ -1178,18 +1183,18 @@ int __ref __add_memory(int nid, u64 start, u64 size)
if (IS_ERR(res))
return PTR_ERR(res);
- ret = add_memory_resource(nid, res, memhp_auto_online);
+ ret = add_memory_resource(nid, res, memory_block_type);
if (ret < 0)
release_memory_resource(res);
return ret;
}
-int add_memory(int nid, u64 start, u64 size)
+int add_memory(int nid, u64 start, u64 size, int memory_block_type)
{
int rc;
lock_device_hotplug();
- rc = __add_memory(nid, start, size);
+ rc = __add_memory(nid, start, size, memory_block_type);
unlock_device_hotplug();
return rc;
--
2.17.1
^ permalink raw reply related
* [PATCH v3] powerpc: wire up memtest
From: Christophe Leroy @ 2018-09-28 15:39 UTC (permalink / raw)
To: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman,
Jonathan Corbet
Cc: linuxppc-dev, linux-kernel, linux-doc
Add call to early_memtest() so that kernel compiled with
CONFIG_MEMTEST really perform memtest at startup when requested
via 'memtest' boot parameter.
Tested-by: Daniel Axtens <dja@axtens.net>
Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
---
v3: updated kernel parameters documentation to mention PPC
v2: moved the test after initmem_init() as PPC64 sets max_low_pfn later than PPC32.
Documentation/admin-guide/kernel-parameters.txt | 2 +-
arch/powerpc/kernel/setup-common.c | 3 +++
2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
index 92eb1f42240d..a5ad67d5cb16 100644
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -2404,7 +2404,7 @@
seconds. Use this parameter to check at some
other rate. 0 disables periodic checking.
- memtest= [KNL,X86,ARM] Enable memtest
+ memtest= [KNL,X86,ARM,PPC] Enable memtest
Format: <integer>
default : 0 <disable>
Specifies the number of memtest passes to be
diff --git a/arch/powerpc/kernel/setup-common.c b/arch/powerpc/kernel/setup-common.c
index 93fa0c99681e..9ca9db707bcb 100644
--- a/arch/powerpc/kernel/setup-common.c
+++ b/arch/powerpc/kernel/setup-common.c
@@ -33,6 +33,7 @@
#include <linux/serial_8250.h>
#include <linux/percpu.h>
#include <linux/memblock.h>
+#include <linux/bootmem.h>
#include <linux/of_platform.h>
#include <linux/hugetlb.h>
#include <asm/debugfs.h>
@@ -966,6 +967,8 @@ void __init setup_arch(char **cmdline_p)
initmem_init();
+ early_memtest(min_low_pfn << PAGE_SHIFT, max_low_pfn << PAGE_SHIFT);
+
#ifdef CONFIG_DUMMY_CONSOLE
conswitchp = &dummy_con;
#endif
--
2.13.3
^ permalink raw reply related
* Re: [PATCH v3 6/9] kbuild: consolidate Devicetree dtb build rules
From: Rob Herring @ 2018-09-28 15:41 UTC (permalink / raw)
To: Masahiro Yamada
Cc: Linux MIPS Mailing List, linux-xtensa, Will Deacon, Max Filippov,
Paul Mackerras, Frank Rowand, Yoshinori Sato, Russell King,
Ley Foon Tan, Geert Uytterhoeven, Catalin Marinas, James Hogan,
arcml, moderated list:H8/300 ARCHITECTURE,
open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
linux-kbuild, Linux ARM, Chris Zankel, Michal Simek, Michal Marek,
Vineet Gupta, Linux Kernel Mailing List, Ralf Baechle,
Paul Burton, nios2-dev, linuxppc-dev
In-Reply-To: <CAK7LNATkkOiYPj2RLubcgZ_z59Bhz4GkgWqPMbnaHBk7EisXLg@mail.gmail.com>
On Sun, Sep 23, 2018 at 06:31:14AM -0400, Masahiro Yamada wrote:
> 2018-09-13 11:51 GMT-04:00 Geert Uytterhoeven <geert@linux-m68k.org>:
> > Hi Yamada-san,
> >
> > On Wed, Sep 12, 2018 at 3:02 AM Masahiro Yamada
> > <yamada.masahiro@socionext.com> wrote:
> >> 2018-09-12 0:40 GMT+09:00 Rob Herring <robh@kernel.org>:
> >> > On Mon, Sep 10, 2018 at 10:04 AM Rob Herring <robh@kernel.org> wrote:
> >> >> There is nothing arch specific about building dtb files other than their
> >> >> location under /arch/*/boot/dts/. Keeping each arch aligned is a pain.
> >> >> The dependencies and supported targets are all slightly different.
> >> >> Also, a cross-compiler for each arch is needed, but really the host
> >> >> compiler preprocessor is perfectly fine for building dtbs. Move the
> >> >> build rules to a common location and remove the arch specific ones. This
> >> >> is done in a single step to avoid warnings about overriding rules.
> >> >>
> >> >> The build dependencies had been a mixture of 'scripts' and/or 'prepare'.
> >> >> These pull in several dependencies some of which need a target compiler
> >> >> (specifically devicetable-offsets.h) and aren't needed to build dtbs.
> >> >> All that is really needed is dtc, so adjust the dependencies to only be
> >> >> dtc.
> >> >>
> >> >> This change enables support 'dtbs_install' on some arches which were
> >> >> missing the target.
> >> >
> >> > [...]
> >> >
> >> >> @@ -1215,6 +1215,33 @@ kselftest-merge:
> >> >> $(srctree)/tools/testing/selftests/*/config
> >> >> +$(Q)$(MAKE) -f $(srctree)/Makefile olddefconfig
> >> >>
> >> >> +# ---------------------------------------------------------------------------
> >> >> +# Devicetree files
> >> >> +
> >> >> +ifneq ($(wildcard $(srctree)/arch/$(SRCARCH)/boot/dts/),)
> >> >> +dtstree := arch/$(SRCARCH)/boot/dts
> >> >> +endif
> >> >> +
> >> >> +ifdef CONFIG_OF_EARLY_FLATTREE
> >> >
> >> > This can be true when dtstree is unset. So this line should be this
> >> > instead to fix the 0-day reported error:
> >> >
> >> > ifneq ($(dtstree),)
> >> >
> >> >> +
> >> >> +%.dtb : scripts_dtc
> >> >> + $(Q)$(MAKE) $(build)=$(dtstree) $(dtstree)/$@
> >> >> +
> >> >> +PHONY += dtbs dtbs_install
> >> >> +dtbs: scripts_dtc
> >> >> + $(Q)$(MAKE) $(build)=$(dtstree)
> >> >> +
> >> >> +dtbs_install: dtbs
> >> >> + $(Q)$(MAKE) $(dtbinst)=$(dtstree)
> >> >> +
> >> >> +all: dtbs
> >> >> +
> >> >> +endif
> >>
> >>
> >> Ah, right.
> >> Even x86 can enable OF and OF_UNITTEST.
> >>
> >>
> >>
> >> Another solution might be,
> >> guard it by 'depends on ARCH_SUPPORTS_OF'.
> >>
> >>
> >>
> >> This is actually what ACPI does.
> >>
> >> menuconfig ACPI
> >> bool "ACPI (Advanced Configuration and Power Interface) Support"
> >> depends on ARCH_SUPPORTS_ACPI
> >> ...
> >
> > ACPI is a real platform feature, as it depends on firmware.
> >
> > CONFIG_OF can be enabled, and DT overlays can be loaded, on any platform,
> > even if it has ACPI ;-)
> >
>
> OK, understood.
Any other comments on this? I'd like to get the series into linux-next
soon.
There was one other problem 0-day reported when building with
CONFIG_OF=n while setting CONFIG_OF_ALL_DTBS=y on the kernel command
line. The problem is dtc is not built as setting options on the command
line doesn't invoke kconfig select(s). This can be fixed by also
adding CONFIG_DTC=y to the command line, always building dtc regardless
of Kconfig, or making 'all' conditionally dependent on 'dtbs'. I've gone
with the last option as that is how this problem was avoided before.
So the hunk in question with the 2 fixes now looks like this:
@@ -1215,6 +1215,35 @@ kselftest-merge:
$(srctree)/tools/testing/selftests/*/config
+$(Q)$(MAKE) -f $(srctree)/Makefile olddefconfig
+#
---------------------------------------------------------------------------
+# Devicetree files
+
+ifneq ($(wildcard $(srctree)/arch/$(SRCARCH)/boot/dts/),)
+dtstree := arch/$(SRCARCH)/boot/dts
+endif
+
+ifneq ($(dtstree),)
+
+%.dtb : scripts_dtc
+ $(Q)$(MAKE) $(build)=$(dtstree) $(dtstree)/$@
+
+PHONY += dtbs dtbs_install
+dtbs: scripts_dtc
+ $(Q)$(MAKE) $(build)=$(dtstree)
+
+dtbs_install: dtbs
+ $(Q)$(MAKE) $(dtbinst)=$(dtstree)
+
+ifdef CONFIG_OF_EARLY_FLATTREE
+all: dtbs
+endif
+
+endif
+
+PHONY += scripts_dtc
+scripts_dtc: scripts_basic
+ $(Q)$(MAKE) $(build)=scripts/dtc
+
#
---------------------------------------------------------------------------
# Modules
^ permalink raw reply
* Re: [PATCH 3/5] dma-direct: refine dma_direct_alloc zone selection
From: Christoph Hellwig @ 2018-09-28 15:46 UTC (permalink / raw)
To: Benjamin Herrenschmidt
Cc: Greg Kroah-Hartman, linuxppc-dev, linux-kernel, iommu,
Robin Murphy, Christoph Hellwig, Marek Szyprowski
In-Reply-To: <514bd29960cb1573ead2f3956f18e1cbaa5f32f7.camel@kernel.crashing.org>
On Fri, Sep 28, 2018 at 10:06:48AM +1000, Benjamin Herrenschmidt wrote:
> On Thu, 2018-09-27 at 15:49 +0200, Christoph Hellwig wrote:
> > On Thu, Sep 27, 2018 at 11:45:15AM +1000, Benjamin Herrenschmidt wrote:
> > > I'm not sure this is entirely right.
> > >
> > > Let's say the mask is 30 bits. You will return GFP_DMA32, which will
> > > fail if you allocate something above 1G (which is legit for
> > > ZONE_DMA32).
> >
> > And then we will try GFP_DMA further down in the function:
> >
> > if (IS_ENABLED(CONFIG_ZONE_DMA) &&
> > dev->coherent_dma_mask < DMA_BIT_MASK(32) &&
> > !(gfp & GFP_DMA)) {
> > gfp = (gfp & ~GFP_DMA32) | GFP_DMA;
> > goto again;
> > }
> >
> > This is and old optimization from x86, because chances are high that
> > GFP_DMA32 will give you suitable memory for the infamous 31-bit
> > dma mask devices (at least at boot time) and thus we don't have
> > to deplete the tiny ZONE_DMA pool.
>
> I see, it's rather confusing :-) Wouldn't it be better to check against
> top of 32-bit memory instead here too ?
Where is here? In __dma_direct_optimal_gfp_mask we already handled
it due to the optimistic zone selection we are discussing.
In the fallback quoted above there is no point for it, as with a
physical memory size smaller than ZONE_DMA32 (or ZONE_DMA for that matter)
we will have succeeded with the optimistic zone selection and not hit
the fallback path.
Either way this code probably needs much better comments. I'll send
a patch on top of the recent series.
^ permalink raw reply
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox