Re: [PATCH v2 2/4] powerpc/powernv: Fix stale PE primary bus

2016-02-11 Thread Gavin Shan
On Fri, Feb 12, 2016 at 05:02:46PM +1100, Andrew Donnellan wrote:
>On 09/02/16 15:50, Gavin Shan wrote:
>>When PCI bus is unplugged during full hotplug for EEH recovery,
>>the platform PE instance (struct pnv_ioda_pe) isn't released and
>>it dereferences the stale PCI bus that has been released. It leads
>>to kernel crash when referring to the stale PCI bus.
>>
>>This fixes the issue by correcting the PE's primary bus when it's
>>oneline at plugging time, in pnv_pci_dma_bus_setup() which is to
>>be called by pcibios_fixup_bus().
>>
>>Reported-by: Andrew Donnellan 
>>Reported-by: Pradipta Ghosh 
>>Signed-off-by: Gavin Shan 
>>Tested-by: Andrew Donnellan 
>
>I realise this has already been merged, but the following was found by
>Coverity:
>
>>+void pnv_pci_dma_bus_setup(struct pci_bus *bus)
>>+{
>>+ struct pci_controller *hose = bus->sysdata;
>>+ struct pnv_phb *phb = hose->private_data;
>>+ struct pnv_ioda_pe *pe;
>>+
>>+ list_for_each_entry(pe, &phb->ioda.pe_list, list) {
>>+ if (!(pe->flags | (PNV_IODA_PE_BUS | PNV_IODA_PE_BUS_ALL)))
>>+ continue;
>
>This condition is always false. I think the first "|" is supposed to be "&".
>

Yeah, that should be "&". I think the problem isn't found when doing
testing in non-SRIOV environment. Thanks for pointing it out.

Michael, please let me know if I need send a follow-up revision to
correct this one? I found the first two patches have been put into
linux-next branch. I think we probably just need repost the correct
version for this one only.

Thanks,
Gavin

>-- 
>Andrew Donnellan  Software Engineer, OzLabs
>andrew.donnel...@au1.ibm.com  Australia Development Lab, Canberra
>+61 2 6201 8874 (work)IBM Australia Limited

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: [PATCH v2 2/4] powerpc/powernv: Fix stale PE primary bus

2016-02-11 Thread Andrew Donnellan

On 09/02/16 15:50, Gavin Shan wrote:

When PCI bus is unplugged during full hotplug for EEH recovery,
the platform PE instance (struct pnv_ioda_pe) isn't released and
it dereferences the stale PCI bus that has been released. It leads
to kernel crash when referring to the stale PCI bus.

This fixes the issue by correcting the PE's primary bus when it's
oneline at plugging time, in pnv_pci_dma_bus_setup() which is to
be called by pcibios_fixup_bus().

Reported-by: Andrew Donnellan 
Reported-by: Pradipta Ghosh 
Signed-off-by: Gavin Shan 
Tested-by: Andrew Donnellan 


I realise this has already been merged, but the following was found by 
Coverity:



+void pnv_pci_dma_bus_setup(struct pci_bus *bus)
+{
+   struct pci_controller *hose = bus->sysdata;
+   struct pnv_phb *phb = hose->private_data;
+   struct pnv_ioda_pe *pe;
+
+   list_for_each_entry(pe, &phb->ioda.pe_list, list) {
+   if (!(pe->flags | (PNV_IODA_PE_BUS | PNV_IODA_PE_BUS_ALL)))
+   continue;


This condition is always false. I think the first "|" is supposed to be "&".

--
Andrew Donnellan  Software Engineer, OzLabs
andrew.donnel...@au1.ibm.com  Australia Development Lab, Canberra
+61 2 6201 8874 (work)IBM Australia Limited

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: [PATCH kernel v2 6/6] KVM: PPC: Add support for multiple-TCE hcalls

2016-02-11 Thread Paul Mackerras
On Fri, Feb 12, 2016 at 03:54:18PM +1100, Alexey Kardashevskiy wrote:
> On 02/11/2016 04:32 PM, Paul Mackerras wrote:
> >On Thu, Jan 21, 2016 at 06:39:37PM +1100, Alexey Kardashevskiy wrote:
> >>+   rmap = (void *) vmalloc_to_phys(rmap);
> >>+
> >>+   lock_rmap(rmap);
> >
> >A comment here explaining why we lock the rmap and what that achieves
> >would be useful for future generations.
> 
> 
> /* This protects the guest page with the TCE list from going away while we
> are reading TCE list */
> 
> ?
> 
> By "going away" I mean H_ENTER/H_REMOVE executed on parallel CPUs, is this
> roughly correct? as I did grep for "lock_rmap()" and did not find a single
> comment next to it...

Actually, taking the rmap lock stops the guest real -> host real
mapping from changing.  For the comment, I suggest this:

/*
 * Synchronize with the MMU notifier callbacks in
 * book3s_64_mmu_hv.c (kvm_unmap_hva_hv etc.).
 * While we have the rmap lock, code running on other CPUs
 * cannot finish unmapping the host real page that backs
 * this guest real page, so we are OK to access the host
 * real page.
 */

Paul.
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

[PATCH] powerpc/eeh: Fix partial hotplug criterion

2016-02-11 Thread Gavin Shan
During error recovery, the device could be removed as part of the
partial hotplug. The criterion used to come with partial hotplug
is: if the device driver provides error_detected(), slot_reset()
and resume() callbacks, it's immune from hotplug. Otherwise,
it's going to experience partial hotplug during EEH recovery. But
the criterion isn't correct enough: mlx4_core driver for Mellanox
adapters provides error_detected(), slot_reset() callbacks, but
resume() isn't there. Those Mellanox adapters won't be to involved
in the partial hotplug.

This fixes the criterion to a practical one: adpater with driver
that provides error_detected(), slot_reset() will be immune from
partial hotplug. resume() isn't mandatory.

Fixes: f2da4ccf ("powerpc/eeh: More relaxed hotplug criterion")
Cc: sta...@vger.kernel.org #v4.4+
Signed-off-by: Gavin Shan 
---
 arch/powerpc/kernel/eeh_driver.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/arch/powerpc/kernel/eeh_driver.c b/arch/powerpc/kernel/eeh_driver.c
index 301be31..650cfb3 100644
--- a/arch/powerpc/kernel/eeh_driver.c
+++ b/arch/powerpc/kernel/eeh_driver.c
@@ -418,8 +418,7 @@ static void *eeh_rmv_device(void *data, void *userdata)
eeh_pcid_put(dev);
if (driver->err_handler &&
driver->err_handler->error_detected &&
-   driver->err_handler->slot_reset &&
-   driver->err_handler->resume)
+   driver->err_handler->slot_reset)
return NULL;
}
 
-- 
2.1.0

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: [PATCH kernel v2 6/6] KVM: PPC: Add support for multiple-TCE hcalls

2016-02-11 Thread Alexey Kardashevskiy

On 02/11/2016 04:32 PM, Paul Mackerras wrote:

On Thu, Jan 21, 2016 at 06:39:37PM +1100, Alexey Kardashevskiy wrote:

This adds real and virtual mode handlers for the H_PUT_TCE_INDIRECT and
H_STUFF_TCE hypercalls for user space emulated devices such as IBMVIO
devices or emulated PCI.  These calls allow adding multiple entries
(up to 512) into the TCE table in one call which saves time on
transition between kernel and user space.

This implements the KVM_CAP_PPC_MULTITCE capability. When present,
the kernel will try handling H_PUT_TCE_INDIRECT and H_STUFF_TCE.
If they can not be handled by the kernel, they are passed on to
the user space. The user space still has to have an implementation
for these.

Both HV and PR-syle KVM are supported.

Signed-off-by: Alexey Kardashevskiy 


[snip]


diff --git a/arch/powerpc/kvm/book3s_64_vio.c b/arch/powerpc/kvm/book3s_64_vio.c
index 975f0ab..987f406 100644
--- a/arch/powerpc/kvm/book3s_64_vio.c
+++ b/arch/powerpc/kvm/book3s_64_vio.c
@@ -14,6 +14,7 @@
   *
   * Copyright 2010 Paul Mackerras, IBM Corp. 
   * Copyright 2011 David Gibson, IBM Corporation 
+ * Copyright 2016 Alexey Kardashevskiy, IBM Corporation 
   */

  #include 
@@ -37,8 +38,7 @@
  #include 
  #include 
  #include 
-
-#define TCES_PER_PAGE  (PAGE_SIZE / sizeof(u64))
+#include 

  static unsigned long kvmppc_stt_npages(unsigned long window_size)
  {
@@ -200,3 +200,109 @@ fail:
}
return ret;
  }
+
+long kvmppc_h_put_tce(struct kvm_vcpu *vcpu,
+   unsigned long liobn, unsigned long ioba,
+   unsigned long tce)
+{
+   long ret;
+   struct kvmppc_spapr_tce_table *stt;
+
+   stt = kvmppc_find_table(vcpu, liobn);
+   if (!stt)
+   return H_TOO_HARD;
+
+   ret = kvmppc_ioba_validate(stt, ioba, 1);
+   if (ret != H_SUCCESS)
+   return ret;
+
+   ret = kvmppc_tce_validate(stt, tce);
+   if (ret != H_SUCCESS)
+   return ret;
+
+   kvmppc_tce_put(stt, ioba >> IOMMU_PAGE_SHIFT_4K, tce);
+
+   return H_SUCCESS;
+}
+EXPORT_SYMBOL_GPL(kvmppc_h_put_tce);


As far as I can see, this is functionally identical to the
kvmppc_h_put_tce that we have in book3s_64_vio_hv.c, that gets renamed
later on in this patch.  It would be good to have an explanation in
the commit message why we want two almost-identical functions (and
similarly for kvmppc_h_stuff_tce).  Is it because a future patch is
going to make them different, for instance?


+long kvmppc_h_stuff_tce(struct kvm_vcpu *vcpu,
+   unsigned long liobn, unsigned long ioba,
+   unsigned long tce_value, unsigned long npages)
+{
+   struct kvmppc_spapr_tce_table *stt;
+   long i, ret;
+
+   stt = kvmppc_find_table(vcpu, liobn);
+   if (!stt)
+   return H_TOO_HARD;
+
+   ret = kvmppc_ioba_validate(stt, ioba, npages);
+   if (ret != H_SUCCESS)
+   return ret;
+
+   if (tce_value & (TCE_PCI_WRITE | TCE_PCI_READ))
+   return H_PARAMETER;
+
+   for (i = 0; i < npages; ++i, ioba += IOMMU_PAGE_SIZE_4K)


Looks like we need a bounds check on npages, presumably in
kvmppc_ioba_validate().


diff --git a/arch/powerpc/kvm/book3s_64_vio_hv.c 
b/arch/powerpc/kvm/book3s_64_vio_hv.c
index 8cd3a95..58c63ed 100644
--- a/arch/powerpc/kvm/book3s_64_vio_hv.c
+++ b/arch/powerpc/kvm/book3s_64_vio_hv.c

[...]

+long kvmppc_rm_h_put_tce_indirect(struct kvm_vcpu *vcpu,
+   unsigned long liobn, unsigned long ioba,
+   unsigned long tce_list, unsigned long npages)
+{
+   struct kvmppc_spapr_tce_table *stt;
+   long i, ret = H_SUCCESS;
+   unsigned long tces, entry, ua = 0;
+   unsigned long *rmap = NULL;
+
+   stt = kvmppc_find_table(vcpu, liobn);
+   if (!stt)
+   return H_TOO_HARD;
+
+   entry = ioba >> IOMMU_PAGE_SHIFT_4K;
+   /*
+* The spec says that the maximum size of the list is 512 TCEs
+* so the whole table addressed resides in 4K page
+*/
+   if (npages > 512)
+   return H_PARAMETER;
+
+   if (tce_list & (SZ_4K - 1))
+   return H_PARAMETER;
+
+   ret = kvmppc_ioba_validate(stt, ioba, npages);
+   if (ret != H_SUCCESS)
+   return ret;
+
+   if (kvmppc_gpa_to_ua(vcpu->kvm, tce_list, &ua, &rmap))
+   return H_TOO_HARD;
+
+   rmap = (void *) vmalloc_to_phys(rmap);
+
+   lock_rmap(rmap);


A comment here explaining why we lock the rmap and what that achieves
would be useful for future generations.



/* This protects the guest page with the TCE list from going away while we 
are reading TCE list */


?

By "going away" I mean H_ENTER/H_REMOVE executed on parallel CPUs, is this 
roughly correct? as I did grep for "lock_rmap()" and did not find a single 
comment next to it...







+   if (kvmppc_rm_ua_to_hpa(vcpu, ua, &tces)) {
+   ret = H_TOO_HARD;
+   goto unlock_exit;
+   }
+
+   for (i = 0;

Re: [PATCH V2 05/29] powerpc/mm: Copy pgalloc (part 2)

2016-02-11 Thread Paul Mackerras
On Mon, Feb 08, 2016 at 02:50:17PM +0530, Aneesh Kumar K.V wrote:
> Signed-off-by: Aneesh Kumar K.V 

This needs a proper patch description.

Paul.
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: [PATCH V2 02/29] powerpc/mm: Split pgtable types to separate header

2016-02-11 Thread Paul Mackerras
On Mon, Feb 08, 2016 at 02:50:14PM +0530, Aneesh Kumar K.V wrote:
> We remove real_pte_t out of STRICT_MM_TYPESCHECK. We will later add
> a radix variant that is big endian
> 
> Signed-off-by: Aneesh Kumar K.V 

It looks like most of what this patch does is move a bunch of
definitions from page.h to a new pgtable-types.h.  What is the
motivation for this?  Is the code identical (pure code movement) or do
you make changes along the way, and if so, what and why?

What exactly are you doing with real_pte_t and why?

Paul.
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: [PATCH V2 00/29] Book3s abstraction in preparation for new MMU model

2016-02-11 Thread Paul Mackerras
On Mon, Feb 08, 2016 at 02:50:12PM +0530, Aneesh Kumar K.V wrote:
> Hello,
> 
> This is a large series, mostly consisting of code movement. No new features
> are done in this series. The changes are done to accomodate the upcoming new 
> memory
> model in future powerpc chips. The details of the new MMU model can be found 
> at
> 
>  http://ibm.biz/power-isa3 (Needs registration). I am including a summary of 
> the changes below.

This series doesn't seem to apply against either v4.4 or Linus'
current master.  What is this patch against?

Paul.
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: [PATCH V2 01/29] powerpc/mm: add _PAGE_HASHPTE similar to 4K hash

2016-02-11 Thread Paul Mackerras
On Mon, Feb 08, 2016 at 02:50:13PM +0530, Aneesh Kumar K.V wrote:
> Not really needed. But this brings it back to as it was before

If it's not really needed, what's the motivation for putting this
patch in?  You need to explain where you are heading with this patch.

> Check this
> 41743a4e34f0777f51c1cf0675b91508ba143050

The SHA1 is useful, but you need to be more explicit - something like

"This partially reverts commit 41743a4e34f0 ("powerpc: Free a PTE bit
on ppc64 with 64K pages", 2008-06-11)."

Paul.
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: [BUG] random kernel crashes after THP rework on s390 (maybe also on PowerPC and ARM)

2016-02-11 Thread Aneesh Kumar K.V
Gerald Schaefer  writes:

> On Thu, 11 Feb 2016 21:09:42 +0200
> "Kirill A. Shutemov"  wrote:
>
>> On Thu, Feb 11, 2016 at 07:22:23PM +0100, Gerald Schaefer wrote:
>> > Hi,
>> > 
>> > Sebastian Ott reported random kernel crashes beginning with v4.5-rc1 and
>> > he also bisected this to commit 61f5d698 "mm: re-enable THP". Further
>> > review of the THP rework patches, which cannot be bisected, revealed
>> > commit fecffad "s390, thp: remove infrastructure for handling splitting 
>> > PMDs"
>> > (and also similar commits for other archs).
>> > 
>> > This commit removes the THP splitting bit and also the architecture
>> > implementation of pmdp_splitting_flush(), which took care of the IPI for
>> > fast_gup serialization. The commit message says
>> > 
>> > pmdp_splitting_flush() is not needed too: on splitting PMD we will do
>> > pmdp_clear_flush() + set_pte_at().  pmdp_clear_flush() will do IPI as
>> > needed for fast_gup
>> > 
>> > The assumption that a TLB flush will also produce an IPI is wrong on s390,
>> > and maybe also on other architectures, and I thought that this was actually
>> > the main reason for having an arch-specific pmdp_splitting_flush().
>> > 
>> > At least PowerPC and ARM also had an individual implementation of
>> > pmdp_splitting_flush() that used kick_all_cpus_sync() instead of a TLB
>> > flush to send the IPI, and those were also removed. Putting the arch
>> > maintainers and mailing lists on cc to verify.
>> > 
>> > On s390 this will break the IPI serialization against fast_gup, which
>> > would certainly explain the random kernel crashes, please revert or fix
>> > the pmdp_splitting_flush() removal.
>> 
>> Sorry for that.
>> 
>> I believe, the problem was already addressed for PowerPC:
>> 
>> http://lkml.kernel.org/g/454980831-16631-1-git-send-email-aneesh.ku...@linux.vnet.ibm.com
>> 
>> I think kick_all_cpus_sync() in arch-specific pmdp_invalidate() would do
>> the trick, right?
>
> Hmm, not sure about that. After pmdp_invalidate(), a pmd_none() check in
> fast_gup will still return false, because the pmd is not empty (at least
> on s390).

Why can't we do this ? I did this for ppc64.

 void pmdp_invalidate(struct vm_area_struct *vma, unsigned long address,
 pmd_t *pmdp)
 {
-   pmd_hugepage_update(vma->vm_mm, address, pmdp, _PAGE_PRESENT, 0);
+   pmd_hugepage_update(vma->vm_mm, address, pmdp, ~0UL, 0);

>So I don't see spontaneously how it will help fast_gup to break
> out to the slow path in case of THP splitting.
>
>> 
>> If yes, I'll prepare patch tomorrow (some sleep required).
>> 
>
> We'll check if adding kick_all_cpus_sync() to pmdp_invalidate() helps.
> It would also be good if Martin has a look at this, he'll return on
> Monday.

-aneesh

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: [PATCH v2 0/4] powerpc/ps3: gelic_udbg: drop local versions of network data structs

2016-02-11 Thread Geoff Levand
On Mon, 2016-02-08 at 22:27 +, Luis Henriques wrote:> Luis Henriques (4):>   powerpc/ps3: gelic_udbg: use struct ethhdr from >   powerpc/ps3: gelic_udbg: use struct vlan_hdr from >   powerpc/ps3: gelic_udbg: use struct iphdr from >   powerpc/ps3: gelic_udbg: use struct udphdr from These all look fine.  Thanks for taking time to do this clean up.  I'll try to test next chance I get.Acked-by: Geoff Levand 

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: [PATCH V3 1/2] powerpc/powernv: new function to access OPAL msglog

2016-02-11 Thread Joel Stanley
On Thu, Feb 11, 2016 at 6:06 PM, Andrew Donnellan
 wrote:
> Currently, the OPAL msglog/console buffer is exposed as a sysfs file, with
> the sysfs read handler responsible for retrieving the log from the OPAL
> buffer. We'd like to be able to use it in xmon as well.
>
> Refactor the OPAL msglog code to create a new function, opal_msglog_copy(),
> that copies to an arbitrary buffer. Separate the initialisation code into
> generic memcons init and sysfs file creation.
>
> Signed-off-by: Andrew Donnellan 

Reviewed-by: Joel Stanley 

>
> ---
>
> Changes V2->V3:
> - incorporate comments from Joel Stanley
> - opal_msglog_sysfs_init() now bails out if opal_memcons isn't set
>
> Changes V1->V2:
> - Incorporate comments from mpe
> - Move the memcons pointer out of the bin_attribute struct
> - Decouple memcons init from sysfs init
> ---
>  arch/powerpc/include/asm/opal.h  |  3 +++
>  arch/powerpc/platforms/powernv/opal-msglog.c | 34 
> 
>  arch/powerpc/platforms/powernv/opal.c|  7 --
>  3 files changed, 32 insertions(+), 12 deletions(-)
>
> diff --git a/arch/powerpc/include/asm/opal.h b/arch/powerpc/include/asm/opal.h
> index 07a99e6..9d86c66 100644
> --- a/arch/powerpc/include/asm/opal.h
> +++ b/arch/powerpc/include/asm/opal.h
> @@ -248,6 +248,7 @@ extern int opal_elog_init(void);
>  extern void opal_platform_dump_init(void);
>  extern void opal_sys_param_init(void);
>  extern void opal_msglog_init(void);
> +extern void opal_msglog_sysfs_init(void);
>  extern int opal_async_comp_init(void);
>  extern int opal_sensor_init(void);
>  extern int opal_hmi_handler_init(void);
> @@ -273,6 +274,8 @@ void opal_free_sg_list(struct opal_sg_list *sg);
>
>  extern int opal_error_code(int rc);
>
> +ssize_t opal_msglog_copy(char *to, loff_t pos, size_t count);
> +
>  #endif /* __ASSEMBLY__ */
>
>  #endif /* _ASM_POWERPC_OPAL_H */
> diff --git a/arch/powerpc/platforms/powernv/opal-msglog.c 
> b/arch/powerpc/platforms/powernv/opal-msglog.c
> index 44ed78a..c7a8f72 100644
> --- a/arch/powerpc/platforms/powernv/opal-msglog.c
> +++ b/arch/powerpc/platforms/powernv/opal-msglog.c
> @@ -31,26 +31,25 @@ struct memcons {
> __be32 in_cons;
>  };
>
> -static ssize_t opal_msglog_read(struct file *file, struct kobject *kobj,
> -   struct bin_attribute *bin_attr, char *to,
> -   loff_t pos, size_t count)
> +static struct memcons *opal_memcons = NULL;
> +
> +ssize_t opal_msglog_copy(char *to, loff_t pos, size_t count)
>  {
> -   struct memcons *mc = bin_attr->private;
> const char *conbuf;
> ssize_t ret;
> size_t first_read = 0;
> uint32_t out_pos, avail;
>
> -   if (!mc)
> +   if (!opal_memcons)
> return -ENODEV;
>
> -   out_pos = be32_to_cpu(ACCESS_ONCE(mc->out_pos));
> +   out_pos = be32_to_cpu(ACCESS_ONCE(opal_memcons->out_pos));
>
> /* Now we've read out_pos, put a barrier in before reading the new
>  * data it points to in conbuf. */
> smp_rmb();
>
> -   conbuf = phys_to_virt(be64_to_cpu(mc->obuf_phys));
> +   conbuf = phys_to_virt(be64_to_cpu(opal_memcons->obuf_phys));
>
> /* When the buffer has wrapped, read from the out_pos marker to the 
> end
>  * of the buffer, and then read the remaining data as in the 
> un-wrapped
> @@ -58,7 +57,7 @@ static ssize_t opal_msglog_read(struct file *file, struct 
> kobject *kobj,
> if (out_pos & MEMCONS_OUT_POS_WRAP) {
>
> out_pos &= MEMCONS_OUT_POS_MASK;
> -   avail = be32_to_cpu(mc->obuf_size) - out_pos;
> +   avail = be32_to_cpu(opal_memcons->obuf_size) - out_pos;
>
> ret = memory_read_from_buffer(to, count, &pos,
> conbuf + out_pos, avail);
> @@ -76,7 +75,7 @@ static ssize_t opal_msglog_read(struct file *file, struct 
> kobject *kobj,
> }
>
> /* Sanity check. The firmware should not do this to us. */
> -   if (out_pos > be32_to_cpu(mc->obuf_size)) {
> +   if (out_pos > be32_to_cpu(opal_memcons->obuf_size)) {
> pr_err("OPAL: memory console corruption. Aborting read.\n");
> return -EINVAL;
> }
> @@ -91,6 +90,13 @@ out:
> return ret;
>  }
>
> +static ssize_t opal_msglog_read(struct file *file, struct kobject *kobj,
> +   struct bin_attribute *bin_attr, char *to,
> +   loff_t pos, size_t count)
> +{
> +   return opal_msglog_copy(to, pos, count);
> +}
> +
>  static struct bin_attribute opal_msglog_attr = {
> .attr = {.name = "msglog", .mode = 0444},
> .read = opal_msglog_read
> @@ -117,8 +123,16 @@ void __init opal_msglog_init(void)
> return;
> }
>
> -   opal_msglog_attr.private = mc;
> +   opal_memcons = mc;
> +}
>
> +void __init opal_msglog_sysfs_init(void)
> +{
> +   if (!opal_memcons) {
> +  

[PATCH] ibmvfc: byteswap scsi_id, wwpn, and node_name prior to logging

2016-02-11 Thread Tyrel Datwyler
When logging async events the scsi_id, wwpn, and node_name values
are used directly from the CRQ struct which are of type __be64. This
can be confusing to someone looking through the log on a LE system.
Instead byteswap these values to host endian prior to logging.

Signed-off-by: Tyrel Datwyler 
---
 drivers/scsi/ibmvscsi/ibmvfc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/ibmvscsi/ibmvfc.c b/drivers/scsi/ibmvscsi/ibmvfc.c
index 6aa317c..fc523c3 100644
--- a/drivers/scsi/ibmvscsi/ibmvfc.c
+++ b/drivers/scsi/ibmvscsi/ibmvfc.c
@@ -2636,7 +2636,8 @@ static void ibmvfc_handle_async(struct ibmvfc_async_crq 
*crq,
struct ibmvfc_target *tgt;
 
ibmvfc_log(vhost, desc->log_level, "%s event received. scsi_id: %llx, 
wwpn: %llx,"
-  " node_name: %llx%s\n", desc->desc, crq->scsi_id, crq->wwpn, 
crq->node_name,
+  " node_name: %llx%s\n", desc->desc, 
be64_to_cpu(crq->scsi_id),
+  be64_to_cpu(crq->wwpn), be64_to_cpu(crq->node_name),
   ibmvfc_get_link_state(crq->link_state));
 
switch (be64_to_cpu(crq->event)) {
-- 
2.5.0

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: [BUG] random kernel crashes after THP rework on s390 (maybe also on PowerPC and ARM)

2016-02-11 Thread Gerald Schaefer
On Thu, 11 Feb 2016 21:09:42 +0200
"Kirill A. Shutemov"  wrote:

> On Thu, Feb 11, 2016 at 07:22:23PM +0100, Gerald Schaefer wrote:
> > Hi,
> > 
> > Sebastian Ott reported random kernel crashes beginning with v4.5-rc1 and
> > he also bisected this to commit 61f5d698 "mm: re-enable THP". Further
> > review of the THP rework patches, which cannot be bisected, revealed
> > commit fecffad "s390, thp: remove infrastructure for handling splitting 
> > PMDs"
> > (and also similar commits for other archs).
> > 
> > This commit removes the THP splitting bit and also the architecture
> > implementation of pmdp_splitting_flush(), which took care of the IPI for
> > fast_gup serialization. The commit message says
> > 
> > pmdp_splitting_flush() is not needed too: on splitting PMD we will do
> > pmdp_clear_flush() + set_pte_at().  pmdp_clear_flush() will do IPI as
> > needed for fast_gup
> > 
> > The assumption that a TLB flush will also produce an IPI is wrong on s390,
> > and maybe also on other architectures, and I thought that this was actually
> > the main reason for having an arch-specific pmdp_splitting_flush().
> > 
> > At least PowerPC and ARM also had an individual implementation of
> > pmdp_splitting_flush() that used kick_all_cpus_sync() instead of a TLB
> > flush to send the IPI, and those were also removed. Putting the arch
> > maintainers and mailing lists on cc to verify.
> > 
> > On s390 this will break the IPI serialization against fast_gup, which
> > would certainly explain the random kernel crashes, please revert or fix
> > the pmdp_splitting_flush() removal.
> 
> Sorry for that.
> 
> I believe, the problem was already addressed for PowerPC:
> 
> http://lkml.kernel.org/g/454980831-16631-1-git-send-email-aneesh.ku...@linux.vnet.ibm.com
> 
> I think kick_all_cpus_sync() in arch-specific pmdp_invalidate() would do
> the trick, right?

Hmm, not sure about that. After pmdp_invalidate(), a pmd_none() check in
fast_gup will still return false, because the pmd is not empty (at least
on s390). So I don't see spontaneously how it will help fast_gup to break
out to the slow path in case of THP splitting.

> 
> If yes, I'll prepare patch tomorrow (some sleep required).
> 

We'll check if adding kick_all_cpus_sync() to pmdp_invalidate() helps.
It would also be good if Martin has a look at this, he'll return on
Monday.

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: [BUG] random kernel crashes after THP rework on s390 (maybe also on PowerPC and ARM)

2016-02-11 Thread Kirill A. Shutemov
On Thu, Feb 11, 2016 at 09:09:42PM +0200, Kirill A. Shutemov wrote:
> On Thu, Feb 11, 2016 at 07:22:23PM +0100, Gerald Schaefer wrote:
> > Hi,
> > 
> > Sebastian Ott reported random kernel crashes beginning with v4.5-rc1 and
> > he also bisected this to commit 61f5d698 "mm: re-enable THP". Further
> > review of the THP rework patches, which cannot be bisected, revealed
> > commit fecffad "s390, thp: remove infrastructure for handling splitting 
> > PMDs"
> > (and also similar commits for other archs).
> > 
> > This commit removes the THP splitting bit and also the architecture
> > implementation of pmdp_splitting_flush(), which took care of the IPI for
> > fast_gup serialization. The commit message says
> > 
> > pmdp_splitting_flush() is not needed too: on splitting PMD we will do
> > pmdp_clear_flush() + set_pte_at().  pmdp_clear_flush() will do IPI as
> > needed for fast_gup
> > 
> > The assumption that a TLB flush will also produce an IPI is wrong on s390,
> > and maybe also on other architectures, and I thought that this was actually
> > the main reason for having an arch-specific pmdp_splitting_flush().
> > 
> > At least PowerPC and ARM also had an individual implementation of
> > pmdp_splitting_flush() that used kick_all_cpus_sync() instead of a TLB
> > flush to send the IPI, and those were also removed. Putting the arch
> > maintainers and mailing lists on cc to verify.
> > 
> > On s390 this will break the IPI serialization against fast_gup, which
> > would certainly explain the random kernel crashes, please revert or fix
> > the pmdp_splitting_flush() removal.
> 
> Sorry for that.
> 
> I believe, the problem was already addressed for PowerPC:
> 
> http://lkml.kernel.org/g/454980831-16631-1-git-send-email-aneesh.ku...@linux.vnet.ibm.com

Correct link is

http://lkml.kernel.org/g/1454980831-16631-1-git-send-email-aneesh.ku...@linux.vnet.ibm.com

-- 
 Kirill A. Shutemov
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: [BUG] random kernel crashes after THP rework on s390 (maybe also on PowerPC and ARM)

2016-02-11 Thread Kirill A. Shutemov
On Thu, Feb 11, 2016 at 07:22:23PM +0100, Gerald Schaefer wrote:
> Hi,
> 
> Sebastian Ott reported random kernel crashes beginning with v4.5-rc1 and
> he also bisected this to commit 61f5d698 "mm: re-enable THP". Further
> review of the THP rework patches, which cannot be bisected, revealed
> commit fecffad "s390, thp: remove infrastructure for handling splitting PMDs"
> (and also similar commits for other archs).
> 
> This commit removes the THP splitting bit and also the architecture
> implementation of pmdp_splitting_flush(), which took care of the IPI for
> fast_gup serialization. The commit message says
> 
> pmdp_splitting_flush() is not needed too: on splitting PMD we will do
> pmdp_clear_flush() + set_pte_at().  pmdp_clear_flush() will do IPI as
> needed for fast_gup
> 
> The assumption that a TLB flush will also produce an IPI is wrong on s390,
> and maybe also on other architectures, and I thought that this was actually
> the main reason for having an arch-specific pmdp_splitting_flush().
> 
> At least PowerPC and ARM also had an individual implementation of
> pmdp_splitting_flush() that used kick_all_cpus_sync() instead of a TLB
> flush to send the IPI, and those were also removed. Putting the arch
> maintainers and mailing lists on cc to verify.
> 
> On s390 this will break the IPI serialization against fast_gup, which
> would certainly explain the random kernel crashes, please revert or fix
> the pmdp_splitting_flush() removal.

Sorry for that.

I believe, the problem was already addressed for PowerPC:

http://lkml.kernel.org/g/454980831-16631-1-git-send-email-aneesh.ku...@linux.vnet.ibm.com

I think kick_all_cpus_sync() in arch-specific pmdp_invalidate() would do
the trick, right?

If yes, I'll prepare patch tomorrow (some sleep required).

-- 
 Kirill A. Shutemov
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

[BUG] random kernel crashes after THP rework on s390 (maybe also on PowerPC and ARM)

2016-02-11 Thread Gerald Schaefer
Hi,

Sebastian Ott reported random kernel crashes beginning with v4.5-rc1 and
he also bisected this to commit 61f5d698 "mm: re-enable THP". Further
review of the THP rework patches, which cannot be bisected, revealed
commit fecffad "s390, thp: remove infrastructure for handling splitting PMDs"
(and also similar commits for other archs).

This commit removes the THP splitting bit and also the architecture
implementation of pmdp_splitting_flush(), which took care of the IPI for
fast_gup serialization. The commit message says

pmdp_splitting_flush() is not needed too: on splitting PMD we will do
pmdp_clear_flush() + set_pte_at().  pmdp_clear_flush() will do IPI as
needed for fast_gup

The assumption that a TLB flush will also produce an IPI is wrong on s390,
and maybe also on other architectures, and I thought that this was actually
the main reason for having an arch-specific pmdp_splitting_flush().

At least PowerPC and ARM also had an individual implementation of
pmdp_splitting_flush() that used kick_all_cpus_sync() instead of a TLB
flush to send the IPI, and those were also removed. Putting the arch
maintainers and mailing lists on cc to verify.

On s390 this will break the IPI serialization against fast_gup, which
would certainly explain the random kernel crashes, please revert or fix
the pmdp_splitting_flush() removal.

Regards,
Gerald

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

[PATCH v5] powerpc32: provide VIRT_CPU_ACCOUNTING

2016-02-11 Thread Christophe Leroy
This patch provides VIRT_CPU_ACCOUTING to PPC32 architecture.
PPC32 doesn't have the PACA structure, so we use the task_info
structure to store the accounting data.

In order to reuse on PPC32 the PPC64 functions, all u64 data has
been replaced by 'unsigned long' so that it is u32 on PPC32 and
u64 on PPC64

Signed-off-by: Christophe Leroy 
---
Changes in v3: unlike previous version of the patch that was inspired
from IA64 architecture, this new version tries to reuse as much as
possible the PPC64 implementation.

PPC32 doesn't have PACA and past discusion on v2 version has shown
that it is not worth implementing a PACA in PPC32 architecture
(see below benh opinion)

benh: PACA is actually a data structure and you really really don't want it
on ppc32 :-) Having a register point to current works, having a register
point to per-cpu data instead works too (ie, change what we do today),
but don't introduce a PACA *please* :-)

Changes in v4: ACCOUNT_CPU_USER_ENTRY/EXIT() needed updates in other
places than entry_32.S and entry_64.S (reported by kbuild-robot)
Related defines in asm-offset.c need to be conditional to
CONFIG_VIRT_CPU_ACCOUNTING_NATIVE (reported by kbuild-robot)

Changes in v5: Using PPC_LL et PPC_STL instead of defining new macros
AC_LD and AC_STD

 arch/powerpc/Kconfig |  1 +
 arch/powerpc/include/asm/cputime.h   |  4 
 arch/powerpc/include/asm/exception-64s.h |  2 +-
 arch/powerpc/include/asm/ppc_asm.h   | 24 ++--
 arch/powerpc/include/asm/reg.h   |  1 +
 arch/powerpc/include/asm/thread_info.h   | 11 +
 arch/powerpc/kernel/asm-offsets.c|  7 ++
 arch/powerpc/kernel/entry_32.S   | 17 ++
 arch/powerpc/kernel/entry_64.S   |  6 ++---
 arch/powerpc/kernel/exceptions-64e.S |  4 ++--
 arch/powerpc/kernel/time.c   | 38 ++--
 arch/powerpc/platforms/Kconfig.cputype   |  1 -
 12 files changed, 90 insertions(+), 26 deletions(-)

diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index 3a557be..57ce4ff 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -159,6 +159,7 @@ config PPC
select ARCH_HAS_DEVMEM_IS_ALLOWED
select HAVE_ARCH_SECCOMP_FILTER
select ARCH_HAS_UBSAN_SANITIZE_ALL
+   select HAVE_VIRT_CPU_ACCOUNTING
 
 config GENERIC_CSUM
def_bool CPU_LITTLE_ENDIAN
diff --git a/arch/powerpc/include/asm/cputime.h 
b/arch/powerpc/include/asm/cputime.h
index e245255..c4c33be 100644
--- a/arch/powerpc/include/asm/cputime.h
+++ b/arch/powerpc/include/asm/cputime.h
@@ -230,7 +230,11 @@ static inline cputime_t clock_t_to_cputime(const unsigned 
long clk)
 
 #define cputime64_to_clock_t(ct)   cputime_to_clock_t((cputime_t)(ct))
 
+#ifdef CONFIG_PPC64
 static inline void arch_vtime_task_switch(struct task_struct *tsk) { }
+#else
+void arch_vtime_task_switch(struct task_struct *tsk);
+#endif
 
 #endif /* __KERNEL__ */
 #endif /* CONFIG_VIRT_CPU_ACCOUNTING_NATIVE */
diff --git a/arch/powerpc/include/asm/exception-64s.h 
b/arch/powerpc/include/asm/exception-64s.h
index 93ae809..8bc38d1 100644
--- a/arch/powerpc/include/asm/exception-64s.h
+++ b/arch/powerpc/include/asm/exception-64s.h
@@ -287,7 +287,7 @@ do_kvm_##n: 
\
std r0,GPR0(r1);/* save r0 in stackframe*/ \
std r10,GPR1(r1);   /* save r1 in stackframe*/ \
beq 4f; /* if from kernel mode  */ \
-   ACCOUNT_CPU_USER_ENTRY(r9, r10);   \
+   ACCOUNT_CPU_USER_ENTRY(r13, r9, r10);  \
SAVE_PPR(area, r9, r10);   \
 4: EXCEPTION_PROLOG_COMMON_2(area)\
EXCEPTION_PROLOG_COMMON_3(n)   \
diff --git a/arch/powerpc/include/asm/ppc_asm.h 
b/arch/powerpc/include/asm/ppc_asm.h
index 499d9f8..07d1bfc 100644
--- a/arch/powerpc/include/asm/ppc_asm.h
+++ b/arch/powerpc/include/asm/ppc_asm.h
@@ -24,27 +24,27 @@
  */
 
 #ifndef CONFIG_VIRT_CPU_ACCOUNTING_NATIVE
-#define ACCOUNT_CPU_USER_ENTRY(ra, rb)
-#define ACCOUNT_CPU_USER_EXIT(ra, rb)
+#define ACCOUNT_CPU_USER_ENTRY(ptr, ra, rb)
+#define ACCOUNT_CPU_USER_EXIT(ptr, ra, rb)
 #define ACCOUNT_STOLEN_TIME
 #else
-#define ACCOUNT_CPU_USER_ENTRY(ra, rb) \
+#define ACCOUNT_CPU_USER_ENTRY(ptr, ra, rb)\
MFTB(ra);   /* get timebase */  \
-   ld  rb,PACA_STARTTIME_USER(r13);\
-   std ra,PACA_STARTTIME(r13); \
+   PPC_LL  rb, PACA_STARTTIME_USER(ptr);   \
+   PPC_STL ra, PACA_STARTTIME(ptr);\
subfrb,rb,ra;   /* subtract start value */  

Re: [PATCH v2 1/1] powerpc/86xx: Consolidate common platform code

2016-02-11 Thread Scott Wood
On Thu, 2016-02-11 at 12:21 +0300, Denis Kirjanov wrote:
> On 2/11/16, Alessio Igor Bogani  wrote:
> > Signed-off-by: Alessio Igor Bogani 
> > ---
> > v1 -> v2
> > Use appropriate [PATCH] prefix
> > 
> >  arch/powerpc/platforms/86xx/Makefile   |  2 +-
> >  arch/powerpc/platforms/86xx/common.c   | 42
> > ++
> >  arch/powerpc/platforms/86xx/gef_ppc9a.c| 32 +--
> >  arch/powerpc/platforms/86xx/gef_sbc310.c   | 32 +--
> >  arch/powerpc/platforms/86xx/gef_sbc610.c   | 32 +--
> >  arch/powerpc/platforms/86xx/mpc8610_hpcd.c | 20 ++
> >  arch/powerpc/platforms/86xx/mpc86xx.h  |  2 ++
> >  arch/powerpc/platforms/86xx/mpc86xx_hpcn.c | 21 +--
> >  arch/powerpc/platforms/86xx/sbc8641d.c | 32 +--
> >  9 files changed, 52 insertions(+), 163 deletions(-)
> >  create mode 100644 arch/powerpc/platforms/86xx/common.c
> > 
> > diff --git a/arch/powerpc/platforms/86xx/Makefile
> > b/arch/powerpc/platforms/86xx/Makefile
> > index ede815d..2d889ad 100644
> > --- a/arch/powerpc/platforms/86xx/Makefile
> > +++ b/arch/powerpc/platforms/86xx/Makefile
> > @@ -2,7 +2,7 @@
> >  # Makefile for the PowerPC 86xx linux kernel.
> >  #
> > 
> > -obj-y  := pic.o
> > +obj-y  := pic.o common.o
> >  obj-$(CONFIG_SMP)  += mpc86xx_smp.o
> >  obj-$(CONFIG_MPC8641_HPCN) += mpc86xx_hpcn.o
> >  obj-$(CONFIG_SBC8641D) += sbc8641d.o
> > diff --git a/arch/powerpc/platforms/86xx/common.c
> > b/arch/powerpc/platforms/86xx/common.c
> > new file mode 100644
> > index 000..bee3177
> > --- /dev/null
> > +++ b/arch/powerpc/platforms/86xx/common.c
> > @@ -0,0 +1,42 @@
> > +/*
> > + * Routines common to most mpc86xx-based boards.
> > + *
> > + * This is free software; you can redistribute it and/or modify
> > + * it under the terms of the GNU General Public License version 2 as
> > + * published by the Free Software Foundation.
> > + */
> > +
> > +#include 
> > +
> > +#include "mpc86xx.h"
> > +
> > +static const struct of_device_id mpc86xx_common_ids[] __initconst = {
> > +   { .type = "soc", },
> > +   { .compatible = "soc", },
> > +   { .compatible = "simple-bus", },
> > +   { .name = "localbus", },
> > +   { .compatible = "gianfar", },
> > +   { .compatible = "fsl,mpc8641-pcie", },
> > +   {},
> > +};
> > +
> > +int __init mpc86xx_common_publish_devices(void)
> > +{
> > +   return of_platform_bus_probe(NULL, mpc86xx_common_ids, NULL);
> > +}
> > +
> > +long __init mpc86xx_time_init(void)
> > +{
> > +   unsigned int temp;
> > +
> > +   /* Set the time base to zero */
> > +   mtspr(SPRN_TBWL, 0);
> > +   mtspr(SPRN_TBWU, 0);
> > +
> > +   temp = mfspr(SPRN_HID0);
> > +   temp |= HID0_TBEN;
> > +   mtspr(SPRN_HID0, temp);
> > +   asm volatile("isync");
> While we're here you could just use isync()
> 

Could you please trim the part of the mail you're not replying to?  It takes a
while to scan to find where the reply actually is.

-Scott

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: [PATCH v10 3/8] dt, numa: adding numa dt binding implementation.

2016-02-11 Thread Ganapatrao Kulkarni
Hi Rob,

On Thu, Feb 11, 2016 at 9:02 PM, Robert Richter
 wrote:
> On 11.02.16 08:50:41, Rob Herring wrote:
>> On Tue, Feb 2, 2016 at 4:09 AM, Ganapatrao Kulkarni
>>  wrote:
>> > dt node parsing for numa topology is done using device property
>> > numa-node-id and device node distance-map.
>>
>> How is it that powerpc doesn't need flat DT parsing for NUMA? Both
>> arches are memblock based and the binding is similar IIRC, so you
>> should be able to find a way to do this with the unflattened tree.
>> Ideally, there should be some common code shared as well.

powerpc has implemented numa binding using property named
"ibm,associativity", we too started adding using the same binding[
refer version V6]
however had discussion/review with Mark R about mapping and we could not map to
some of the topology like mesh and ring topology.

So we have defined and implemented this new binding which is simple
and scalable.
This binding is very much aligned to ACPI NUMA specification.

>>
>> Do you have a git tree with this series?
>
> I have pushed it here for you:
>
>  
> https://git.kernel.org/cgit/linux/kernel/git/rric/linux.git/log/?h=thunder/numa-v10

thanks Robert.
>
> -Robert

thanks
Ganapat
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: [PATCH v10 3/8] dt, numa: adding numa dt binding implementation.

2016-02-11 Thread Robert Richter
On 11.02.16 08:50:41, Rob Herring wrote:
> On Tue, Feb 2, 2016 at 4:09 AM, Ganapatrao Kulkarni
>  wrote:
> > dt node parsing for numa topology is done using device property
> > numa-node-id and device node distance-map.
> 
> How is it that powerpc doesn't need flat DT parsing for NUMA? Both
> arches are memblock based and the binding is similar IIRC, so you
> should be able to find a way to do this with the unflattened tree.
> Ideally, there should be some common code shared as well.
> 
> Do you have a git tree with this series?

I have pushed it here for you:

 
https://git.kernel.org/cgit/linux/kernel/git/rric/linux.git/log/?h=thunder/numa-v10

-Robert
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: [PATCH v10 3/8] dt, numa: adding numa dt binding implementation.

2016-02-11 Thread Rob Herring
On Tue, Feb 2, 2016 at 4:09 AM, Ganapatrao Kulkarni
 wrote:
> dt node parsing for numa topology is done using device property
> numa-node-id and device node distance-map.

How is it that powerpc doesn't need flat DT parsing for NUMA? Both
arches are memblock based and the binding is similar IIRC, so you
should be able to find a way to do this with the unflattened tree.
Ideally, there should be some common code shared as well.

Do you have a git tree with this series?

Rob
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

[PATCH] powerpc/fsl_rio: update for port-write interface change

2016-02-11 Thread Alexandre Bounine
Platform-specific update following changes in port-write handler interface.

This is a follow-up patch for
[PATCH 22/30] rapidio: add global inbound port write interfaces

Signed-off-by: Alexandre Bounine 
Cc: Matt Porter 
Cc: Benjamin Herrenschmidt 
Cc: Aurelien Jacquiot 
Cc: Andre van Herk 
Cc: linux-ker...@vger.kernel.org
Cc: linuxppc-dev@lists.ozlabs.org
---
 arch/powerpc/sysdev/fsl_rio.c |1 +
 arch/powerpc/sysdev/fsl_rio.h |1 +
 arch/powerpc/sysdev/fsl_rmu.c |   16 ++--
 3 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/arch/powerpc/sysdev/fsl_rio.c b/arch/powerpc/sysdev/fsl_rio.c
index 385371a..f5bf38b9 100644
--- a/arch/powerpc/sysdev/fsl_rio.c
+++ b/arch/powerpc/sysdev/fsl_rio.c
@@ -726,6 +726,7 @@ int fsl_rio_setup(struct platform_device *dev)
fsl_rio_inbound_mem_init(priv);
 
dbell->mport[i] = port;
+   pw->mport[i] = port;
 
if (rio_register_mport(port)) {
release_resource(&port->iores);
diff --git a/arch/powerpc/sysdev/fsl_rio.h b/arch/powerpc/sysdev/fsl_rio.h
index d53407a..12dd18f 100644
--- a/arch/powerpc/sysdev/fsl_rio.h
+++ b/arch/powerpc/sysdev/fsl_rio.h
@@ -97,6 +97,7 @@ struct fsl_rio_dbell {
 };
 
 struct fsl_rio_pw {
+   struct rio_mport *mport[MAX_PORT_NUM];
struct device *dev;
struct rio_pw_regs __iomem *pw_regs;
struct rio_port_write_msg port_write_msg;
diff --git a/arch/powerpc/sysdev/fsl_rmu.c b/arch/powerpc/sysdev/fsl_rmu.c
index b48197a..176acfc 100644
--- a/arch/powerpc/sysdev/fsl_rmu.c
+++ b/arch/powerpc/sysdev/fsl_rmu.c
@@ -481,14 +481,14 @@ pw_done:
 static void fsl_pw_dpc(struct work_struct *work)
 {
struct fsl_rio_pw *pw = container_of(work, struct fsl_rio_pw, pw_work);
-   u32 msg_buffer[RIO_PW_MSG_SIZE/sizeof(u32)];
+   union rio_pw_msg msg_buffer;
+   int i;
 
/*
 * Process port-write messages
 */
-   while (kfifo_out_spinlocked(&pw->pw_fifo, (unsigned char *)msg_buffer,
+   while (kfifo_out_spinlocked(&pw->pw_fifo, (unsigned char *)&msg_buffer,
 RIO_PW_MSG_SIZE, &pw->pw_fifo_lock)) {
-   /* Process one message */
 #ifdef DEBUG_PW
{
u32 i;
@@ -496,15 +496,19 @@ static void fsl_pw_dpc(struct work_struct *work)
for (i = 0; i < RIO_PW_MSG_SIZE/sizeof(u32); i++) {
if ((i%4) == 0)
pr_debug("\n0x%02x: 0x%08x", i*4,
-msg_buffer[i]);
+msg_buffer.raw[i]);
else
-   pr_debug(" 0x%08x", msg_buffer[i]);
+   pr_debug(" 0x%08x", msg_buffer.raw[i]);
}
pr_debug("\n");
}
 #endif
/* Pass the port-write message to RIO core for processing */
-   rio_inb_pwrite_handler((union rio_pw_msg *)msg_buffer);
+   for (i = 0; i < MAX_PORT_NUM; i++) {
+   if (pw->mport[i])
+   rio_inb_pwrite_handler(pw->mport[i],
+  &msg_buffer);
+   }
}
 }
 
-- 
1.7.8.4

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: [PATCH v3 03/18] cxl: Define process problem state area at attach time only

2016-02-11 Thread Frederic Barrat



Le 10/02/2016 07:32, Ian Munsie a écrit :

It might be a reasonable idea to make cxl_psa_map fail outright if it is
called on a context that has not been attached yet like we do in the
user api, but I trust kernel devs to get this right more than userspace
so I'm not too worried :)



The net effect will be the same (we return a NULL pointer, which will 
need to be handled properly by the caller), but I like your suggestion 
of checking whether the context is attached first, which avoids calling 
ioremap() with null parameters.


Pushing it further: if we don't allow mapping the psa before attaching, 
then I believe the call to cxl_afu_check_and_enable() is no longer 
useful, since the AFU will be enabled on the first attach()


[ the very existence of the call to cxl_afu_check_and_enable() confirms 
my first impression: allowing to map the psa before attaching was 
deliberate ]


  Fred

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

[PATCH v3 1/1] powerpc/86xx: Consolidate common platform code

2016-02-11 Thread Alessio Igor Bogani
Signed-off-by: Alessio Igor Bogani 
---
v2 -> v3
Use isync() as suggested by Denis Kirjanov

v1 -> v2
Use appropriate [PATCH] prefix

 arch/powerpc/platforms/86xx/Makefile   |  2 +-
 arch/powerpc/platforms/86xx/common.c   | 43 ++
 arch/powerpc/platforms/86xx/gef_ppc9a.c| 32 +-
 arch/powerpc/platforms/86xx/gef_sbc310.c   | 32 +-
 arch/powerpc/platforms/86xx/gef_sbc610.c   | 32 +-
 arch/powerpc/platforms/86xx/mpc8610_hpcd.c | 20 ++
 arch/powerpc/platforms/86xx/mpc86xx.h  |  2 ++
 arch/powerpc/platforms/86xx/mpc86xx_hpcn.c | 21 +--
 arch/powerpc/platforms/86xx/sbc8641d.c | 32 +-
 9 files changed, 53 insertions(+), 163 deletions(-)
 create mode 100644 arch/powerpc/platforms/86xx/common.c

diff --git a/arch/powerpc/platforms/86xx/Makefile 
b/arch/powerpc/platforms/86xx/Makefile
index ede815d..2d889ad 100644
--- a/arch/powerpc/platforms/86xx/Makefile
+++ b/arch/powerpc/platforms/86xx/Makefile
@@ -2,7 +2,7 @@
 # Makefile for the PowerPC 86xx linux kernel.
 #
 
-obj-y  := pic.o
+obj-y  := pic.o common.o
 obj-$(CONFIG_SMP)  += mpc86xx_smp.o
 obj-$(CONFIG_MPC8641_HPCN) += mpc86xx_hpcn.o
 obj-$(CONFIG_SBC8641D) += sbc8641d.o
diff --git a/arch/powerpc/platforms/86xx/common.c 
b/arch/powerpc/platforms/86xx/common.c
new file mode 100644
index 000..0f7b7fc
--- /dev/null
+++ b/arch/powerpc/platforms/86xx/common.c
@@ -0,0 +1,43 @@
+/*
+ * Routines common to most mpc86xx-based boards.
+ *
+ * This is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include 
+#include 
+
+#include "mpc86xx.h"
+
+static const struct of_device_id mpc86xx_common_ids[] __initconst = {
+   { .type = "soc", },
+   { .compatible = "soc", },
+   { .compatible = "simple-bus", },
+   { .name = "localbus", },
+   { .compatible = "gianfar", },
+   { .compatible = "fsl,mpc8641-pcie", },
+   {},
+};
+
+int __init mpc86xx_common_publish_devices(void)
+{
+   return of_platform_bus_probe(NULL, mpc86xx_common_ids, NULL);
+}
+
+long __init mpc86xx_time_init(void)
+{
+   unsigned int temp;
+
+   /* Set the time base to zero */
+   mtspr(SPRN_TBWL, 0);
+   mtspr(SPRN_TBWU, 0);
+
+   temp = mfspr(SPRN_HID0);
+   temp |= HID0_TBEN;
+   mtspr(SPRN_HID0, temp);
+   isync();
+
+   return 0;
+}
diff --git a/arch/powerpc/platforms/86xx/gef_ppc9a.c 
b/arch/powerpc/platforms/86xx/gef_ppc9a.c
index bf17933..8e63b75 100644
--- a/arch/powerpc/platforms/86xx/gef_ppc9a.c
+++ b/arch/powerpc/platforms/86xx/gef_ppc9a.c
@@ -197,37 +197,7 @@ static int __init gef_ppc9a_probe(void)
return 0;
 }
 
-static long __init mpc86xx_time_init(void)
-{
-   unsigned int temp;
-
-   /* Set the time base to zero */
-   mtspr(SPRN_TBWL, 0);
-   mtspr(SPRN_TBWU, 0);
-
-   temp = mfspr(SPRN_HID0);
-   temp |= HID0_TBEN;
-   mtspr(SPRN_HID0, temp);
-   asm volatile("isync");
-
-   return 0;
-}
-
-static const struct of_device_id of_bus_ids[] __initconst = {
-   { .compatible = "simple-bus", },
-   { .compatible = "gianfar", },
-   { .compatible = "fsl,mpc8641-pcie", },
-   {},
-};
-
-static int __init declare_of_platform_devices(void)
-{
-   printk(KERN_DEBUG "Probe platform devices\n");
-   of_platform_bus_probe(NULL, of_bus_ids, NULL);
-
-   return 0;
-}
-machine_arch_initcall(gef_ppc9a, declare_of_platform_devices);
+machine_arch_initcall(gef_ppc9a, mpc86xx_common_publish_devices);
 
 define_machine(gef_ppc9a) {
.name   = "GE PPC9A",
diff --git a/arch/powerpc/platforms/86xx/gef_sbc310.c 
b/arch/powerpc/platforms/86xx/gef_sbc310.c
index 8facf58..0e0be94 100644
--- a/arch/powerpc/platforms/86xx/gef_sbc310.c
+++ b/arch/powerpc/platforms/86xx/gef_sbc310.c
@@ -184,37 +184,7 @@ static int __init gef_sbc310_probe(void)
return 0;
 }
 
-static long __init mpc86xx_time_init(void)
-{
-   unsigned int temp;
-
-   /* Set the time base to zero */
-   mtspr(SPRN_TBWL, 0);
-   mtspr(SPRN_TBWU, 0);
-
-   temp = mfspr(SPRN_HID0);
-   temp |= HID0_TBEN;
-   mtspr(SPRN_HID0, temp);
-   asm volatile("isync");
-
-   return 0;
-}
-
-static const struct of_device_id of_bus_ids[] __initconst = {
-   { .compatible = "simple-bus", },
-   { .compatible = "gianfar", },
-   { .compatible = "fsl,mpc8641-pcie", },
-   {},
-};
-
-static int __init declare_of_platform_devices(void)
-{
-   printk(KERN_DEBUG "Probe platform devices\n");
-   of_platform_bus_probe(NULL, of_bus_ids, NULL);
-
-   return 0;
-}
-machine_arch_initcall(gef_sbc310, declare_of_platform_devices);
+machine_arch_initcall(gef_sbc310, mpc86xx_common_publish_device

Re: [PATCH V2 2/2] powerpc/xmon: add command to dump OPAL msglog

2016-02-11 Thread Denis Kirjanov
On 2/9/16, Andrew Donnellan  wrote:
> Add the 'do' command to dump the OPAL msglog in xmon.
>
> Signed-off-by: Andrew Donnellan 

I think it would be better to create system-specific files under
 powerpc/xmon/ directory, in this case something like xmon_powernv.c.

There are some many macros there.

Current code already looks very ugly, look at the cell-specific spu* stuff
for example.

> ---
>  arch/powerpc/xmon/xmon.c | 60
> 
>  1 file changed, 60 insertions(+)
>
> diff --git a/arch/powerpc/xmon/xmon.c b/arch/powerpc/xmon/xmon.c
> index 07a8508..48b75ae 100644
> --- a/arch/powerpc/xmon/xmon.c
> +++ b/arch/powerpc/xmon/xmon.c
> @@ -47,6 +47,11 @@
>  #include 
>  #include 
>
> +#ifdef CONFIG_PPC_POWERNV
> +#include 
> +#include 
> +#endif
> +
>  #ifdef CONFIG_PPC64
>  #include 
>  #include 
> @@ -119,6 +124,11 @@ static void dump(void);
>  static void prdump(unsigned long, long);
>  static int ppc_inst_dump(unsigned long, long, int);
>  static void dump_log_buf(void);
> +
> +#ifdef CONFIG_PPC_POWERNV
> +static void dump_opal_msglog(void);
> +#endif
> +
>  static void backtrace(struct pt_regs *);
>  static void excprint(struct pt_regs *);
>  static void prregs(struct pt_regs *);
> @@ -202,6 +212,10 @@ Commands:\n\
>df dump float values\n\
>dd dump double values\n\
>dldump the kernel log buffer\n"
> +#ifdef CONFIG_PPC_POWERNV
> +  "\
> +  dodump the OPAL message log\n"
> +#endif
>  #ifdef CONFIG_PPC64
>"\
>dp[#]  dump paca for current cpu, or cpu #\n\
> @@ -2253,6 +2267,12 @@ dump(void)
>   last_cmd = "di\n";
>   } else if (c == 'l') {
>   dump_log_buf();
> + } else if (c == 'o') {
> +#ifdef CONFIG_PPC_POWERNV
> + dump_opal_msglog();
> +#else
> + printf("Machine is not running OPAL firmware.\n");
> +#endif
>   } else if (c == 'r') {
>   scanhex(&ndump);
>   if (ndump == 0)
> @@ -2395,6 +2415,46 @@ dump_log_buf(void)
>   catch_memory_errors = 0;
>  }
>
> +#ifdef CONFIG_PPC_POWERNV
> +void
> +dump_opal_msglog(void)
> +{
> + unsigned char buf[128];
> + ssize_t res;
> + loff_t pos = 0;
> +
> + if (!firmware_has_feature(FW_FEATURE_OPAL)) {
> + printf("Machine is not running OPAL firmware.\n");
> + return;
> + }
> +
> + if (setjmp(bus_error_jmp) != 0) {
> + printf("Error dumping OPAL msglog!\n");
> + return;
> + }
> +
> + catch_memory_errors = 1;
> + sync();
> +
> + xmon_start_pagination();
> + while ((res = opal_msglog_copy(buf, pos, sizeof(buf) - 1))) {
> + if (res < 0) {
> + printf("Error dumping OPAL msglog! Error: %zd\n", res);
> + break;
> + }
> + buf[res] = '\0';
> + printf("%s", buf);
> + pos += res;
> + }
> + xmon_end_pagination();
> +
> + sync();
> + /* wait a little while to see if we get a machine check */
> + __delay(200);
> + catch_memory_errors = 0;
> +}
> +#endif
> +
>  /*
>   * Memory operations - move, set, print differences
>   */
> --
> Andrew Donnellan  Software Engineer, OzLabs
> andrew.donnel...@au1.ibm.com  Australia Development Lab, Canberra
> +61 2 6201 8874 (work)IBM Australia Limited
>
> ___
> Linuxppc-dev mailing list
> Linuxppc-dev@lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/linuxppc-dev
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: [PATCH v8 4/8] ppc64 ftrace_with_regs configuration variables

2016-02-11 Thread Murali Sampath


  Original Message
From: Balbir Singh
Sent: Thursday, February 11, 2016 4:37 AM
To: Kamalesh Babulal
Cc: Petr Mladek; Jessica Yu; linux-ker...@vger.kernel.org; Steven Rostedt; 
Torsten Duwe; Jiri Kosina; live-patch...@vger.kernel.org; Miroslav Benes; 
linuxppc-dev@lists.ozlabs.org
Subject: Re: [PATCH v8 4/8] ppc64 ftrace_with_regs configuration variables


On Thu, 2016-02-11 at 14:09 +0530, Kamalesh Babulal wrote:
> * Balbir Singh  [2016-02-11 18:48:17]:
>
> > On Wed, 2016-02-10 at 17:25 +0100, Torsten Duwe wrote:
> >
> > snip
> >
> > > diff --git a/arch/powerpc/gcc-mprofile-kernel-notrace.sh
> > > b/arch/powerpc/gcc-mprofile-kernel-notrace.sh
> > > new file mode 100755
> > > index 000..68d6482
> > > --- /dev/null
> > > +++ b/arch/powerpc/gcc-mprofile-kernel-notrace.sh
> > > @@ -0,0 +1,33 @@
> > > +#!/bin/sh
> > > +# Test whether the compile option -mprofile-kernel
> > > +# generates profiling code ( = a call to mcount), and
> > > +# whether a function without any global references sets
> > > +# the TOC pointer properly at the beginning, and
> > > +# whether the "notrace" function attribute successfully
> > > +# suppresses the _mcount call.
> > > +
> > > +echo "int func() { return 0; }" | \
> > > +$* -S -x c -O2 -p -mprofile-kernel - -o - 2> /dev/null | \
> > > +grep -q "mcount"
> > > +
> > > +trace_result=$?
> > > +
> > > +echo "int func() { return 0; }" | \
> > > +$* -S -x c -O2 -p -mprofile-kernel - -o - 2> /dev/null | \
> > > +sed -n -e '/func:/,/bl _mcount/p' | grep -q TOC
> > > +
> > > +leaf_toc_result=$?
> > > +
> >
> > leaf_toc_result failed for me with gcc 5. I'll try and grab gcc-6
> > and give the patches a spin
> >
>
> It fails for me to on ppc64le but pass over ppc64
>

This series is for ppc64le only, so we can safely ignore ppc64 for now

Regards,
Balbir Singh.
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: [PATCH v8 4/8] ppc64 ftrace_with_regs configuration variables

2016-02-11 Thread Murali Sampath
‎ t

  Original Message
From: Balbir Singh
Sent: Thursday, February 11, 2016 4:37 AM
To: Kamalesh Babulal
Cc: Petr Mladek; Jessica Yu; linux-ker...@vger.kernel.org; Steven Rostedt; 
Torsten Duwe; Jiri Kosina; live-patch...@vger.kernel.org; Miroslav Benes; 
linuxppc-dev@lists.ozlabs.org
Subject: Re: [PATCH v8 4/8] ppc64 ftrace_with_regs configuration variables


On Thu, 2016-02-11 at 14:09 +0530, Kamalesh Babulal wrote:
> * Balbir Singh  [2016-02-11 18:48:17]:
>
> > On Wed, 2016-02-10 at 17:25 +0100, Torsten Duwe wrote:
> >
> > snip
> >
> > > diff --git a/arch/powerpc/gcc-mprofile-kernel-notrace.sh
> > > b/arch/powerpc/gcc-mprofile-kernel-notrace.sh
> > > new file mode 100755
> > > index 000..68d6482
> > > --- /dev/null
> > > +++ b/arch/powerpc/gcc-mprofile-kernel-notrace.sh
> > > @@ -0,0 +1,33 @@
> > > +#!/bin/sh
> > > +# Test whether the compile option -mprofile-kernel
> > > +# generates profiling code ( = a call to mcount), and
> > > +# whether a function without any global references sets
> > > +# the TOC pointer properly at the beginning, and
> > > +# whether the "notrace" function attribute successfully
> > > +# suppresses the _mcount call.
> > > +
> > > +echo "int func() { return 0; }" | \
> > > +$* -S -x c -O2 -p -mprofile-kernel - -o - 2> /dev/null | \
> > > +grep -q "mcount"
> > > +
> > > +trace_result=$?
> > > +
> > > +echo "int func() { return 0; }" | \
> > > +$* -S -x c -O2 -p -mprofile-kernel - -o - 2> /dev/null | \
> > > +sed -n -e '/func:/,/bl _mcount/p' | grep -q TOC
> > > +
> > > +leaf_toc_result=$?
> > > +
> >
> > leaf_toc_result failed for me with gcc 5. I'll try and grab gcc-6
> > and give the patches a spin
> >
>
> It fails for me to on ppc64le but pass over ppc64
>

This series is for ppc64le only, so we can safely ignore ppc64 for now

Regards,
Balbir Singh.
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: [PATCH v2 1/1] powerpc/86xx: Consolidate common platform code

2016-02-11 Thread Murali Sampath


  Original Message
From: Denis Kirjanov
Sent: Thursday, February 11, 2016 4:22 AM
To: Alessio Igor Bogani
Cc: Scott Wood; linuxppc-dev@lists.ozlabs.org; linux-ker...@vger.kernel.org
Subject: Re: [PATCH v2 1/1] powerpc/86xx: Consolidate common platform code


On 2/11/16, Alessio Igor Bogani  wrote:
> Signed-off-by: Alessio Igor Bogani 
> ---
> v1 -> v2
>   Use appropriate [PATCH] prefix
>
>  arch/powerpc/platforms/86xx/Makefile   |  2 +-
>  arch/powerpc/platforms/86xx/common.c   | 42
> ++
>  arch/powerpc/platforms/86xx/gef_ppc9a.c| 32 +--
>  arch/powerpc/platforms/86xx/gef_sbc310.c   | 32 +--
>  arch/powerpc/platforms/86xx/gef_sbc610.c   | 32 +--
>  arch/powerpc/platforms/86xx/mpc8610_hpcd.c | 20 ++
>  arch/powerpc/platforms/86xx/mpc86xx.h  |  2 ++
>  arch/powerpc/platforms/86xx/mpc86xx_hpcn.c | 21 +--
>  arch/powerpc/platforms/86xx/sbc8641d.c | 32 +--
>  9 files changed, 52 insertions(+), 163 deletions(-)
>  create mode 100644 arch/powerpc/platforms/86xx/common.c
>
> diff --git a/arch/powerpc/platforms/86xx/Makefile
> b/arch/powerpc/platforms/86xx/Makefile
> index ede815d..2d889ad 100644
> --- a/arch/powerpc/platforms/86xx/Makefile
> +++ b/arch/powerpc/platforms/86xx/Makefile
> @@ -2,7 +2,7 @@
>  # Makefile for the PowerPC 86xx linux kernel.
>  #
>
> -obj-y:= pic.o
> +obj-y:= pic.o common.o
>  obj-$(CONFIG_SMP)+= mpc86xx_smp.o
>  obj-$(CONFIG_MPC8641_HPCN)   += mpc86xx_hpcn.o
>  obj-$(CONFIG_SBC8641D)   += sbc8641d.o
> diff --git a/arch/powerpc/platforms/86xx/common.c
> b/arch/powerpc/platforms/86xx/common.c
> new file mode 100644
> index 000..bee3177
> --- /dev/null
> +++ b/arch/powerpc/platforms/86xx/common.c
> @@ -0,0 +1,42 @@
> +/*
> + * Routines common to most mpc86xx-based boards.
> + *
> + * This is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 as
> + * published by the Free Software Foundation.
> + */
> +
> +#include 
> +
> +#include "mpc86xx.h"
> +
> +static const struct of_device_id mpc86xx_common_ids[] __initconst = {
> + { .type = "soc", },
> + { .compatible = "soc", },
> + { .compatible = "simple-bus", },
> + { .name = "localbus", },
> + { .compatible = "gianfar", },
> + { .compatible = "fsl,mpc8641-pcie", },
> + {},
> +};
> +
> +int __init mpc86xx_common_publish_devices(void)
> +{
> + return of_platform_bus_probe(NULL, mpc86xx_common_ids, NULL);
> +}
> +
> +long __init mpc86xx_time_init(void)
> +{
> + unsigned int temp;
> +
> + /* Set the time base to zero */
> + mtspr(SPRN_TBWL, 0);
> + mtspr(SPRN_TBWU, 0);
> +
> + temp = mfspr(SPRN_HID0);
> + temp |= HID0_TBEN;
> + mtspr(SPRN_HID0, temp);
> + asm volatile("isync");
While we're here you could just use isync()

> +
> + return 0;
> +}
> diff --git a/arch/powerpc/platforms/86xx/gef_ppc9a.c
> b/arch/powerpc/platforms/86xx/gef_ppc9a.c
> index bf17933..8e63b75 100644
> --- a/arch/powerpc/platforms/86xx/gef_ppc9a.c
> +++ b/arch/powerpc/platforms/86xx/gef_ppc9a.c
> @@ -197,37 +197,7 @@ static int __init gef_ppc9a_probe(void)
>   return 0;
>  }
>
> -static long __init mpc86xx_time_init(void)
> -{
> - unsigned int temp;
> -
> - /* Set the time base to zero */
> - mtspr(SPRN_TBWL, 0);
> - mtspr(SPRN_TBWU, 0);
> -
> - temp = mfspr(SPRN_HID0);
> - temp |= HID0_TBEN;
> - mtspr(SPRN_HID0, temp);
> - asm volatile("isync");
> -
> - return 0;
> -}
> -
> -static const struct of_device_id of_bus_ids[] __initconst = {
> - { .compatible = "simple-bus", },
> - { .compatible = "gianfar", },
> - { .compatible = "fsl,mpc8641-pcie", },
> - {},
> -};
> -
> -static int __init declare_of_platform_devices(void)
> -{
> - printk(KERN_DEBUG "Probe platform devices\n");
> - of_platform_bus_probe(NULL, of_bus_ids, NULL);
> -
> - return 0;
> -}
> -machine_arch_initcall(gef_ppc9a, declare_of_platform_devices);
> +machine_arch_initcall(gef_ppc9a, mpc86xx_common_publish_devices);
>
>  define_machine(gef_ppc9a) {
>   .name   = "GE PPC9A",
> diff --git a/arch/powerpc/platforms/86xx/gef_sbc310.c
> b/arch/powerpc/platforms/86xx/gef_sbc310.c
> index 8facf58..0e0be94 100644
> --- a/arch/powerpc/platforms/86xx/gef_sbc310.c
> +++ b/arch/powerpc/platforms/86xx/gef_sbc310.c
> @@ -184,37 +184,7 @@ static int __init gef_sbc310_probe(void)
>   return 0;
>  }
>
> -static long __init mpc86xx_time_init(void)
> -{
> - unsigned int temp;
> -
> - /* Set the time base to zero */
> - mtspr(SPRN_TBWL, 0);
> - mtspr(SPRN_TBWU, 0);
> -
> - temp = mfspr(SPRN_HID0);
> - temp |= HID0_TBEN;
> - mtspr(SPRN_HID0, temp);
> - asm volatile("isync");
> -
> - return 0;
> -}
> -
> -static const struct of

Re: [PATCH v8 4/8] ppc64 ftrace_with_regs configuration variables

2016-02-11 Thread Balbir Singh
On Thu, 2016-02-11 at 14:09 +0530, Kamalesh Babulal wrote:
> * Balbir Singh  [2016-02-11 18:48:17]:
> 
> > On Wed, 2016-02-10 at 17:25 +0100, Torsten Duwe wrote:
> > 
> > snip
> > 
> > > diff --git a/arch/powerpc/gcc-mprofile-kernel-notrace.sh
> > > b/arch/powerpc/gcc-mprofile-kernel-notrace.sh
> > > new file mode 100755
> > > index 000..68d6482
> > > --- /dev/null
> > > +++ b/arch/powerpc/gcc-mprofile-kernel-notrace.sh
> > > @@ -0,0 +1,33 @@
> > > +#!/bin/sh
> > > +# Test whether the compile option -mprofile-kernel
> > > +# generates profiling code ( = a call to mcount), and
> > > +# whether a function without any global references sets
> > > +# the TOC pointer properly at the beginning, and
> > > +# whether the "notrace" function attribute successfully
> > > +# suppresses the _mcount call.
> > > +
> > > +echo "int func() { return 0; }" | \
> > > +$* -S -x c -O2 -p -mprofile-kernel - -o - 2> /dev/null | \
> > > +grep -q "mcount"
> > > +
> > > +trace_result=$?
> > > +
> > > +echo "int func() { return 0; }" | \
> > > +$* -S -x c -O2 -p -mprofile-kernel - -o - 2> /dev/null | \
> > > +sed -n -e '/func:/,/bl _mcount/p' | grep -q TOC
> > > +
> > > +leaf_toc_result=$?
> > > +
> > 
> > leaf_toc_result failed for me with gcc 5. I'll try and grab gcc-6
> > and give the patches a spin
> > 
> 
> It fails for me to on ppc64le but pass over ppc64
> 

This series is for ppc64le only, so we can safely ignore ppc64 for now

Regards,
Balbir Singh.
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: [PATCH v8 4/8] ppc64 ftrace_with_regs configuration variables

2016-02-11 Thread Balbir Singh
On Thu, 2016-02-11 at 09:42 +0100, Torsten Duwe wrote:
> On Thu, Feb 11, 2016 at 06:48:17PM +1100, Balbir Singh wrote:
> > On Wed, 2016-02-10 at 17:25 +0100, Torsten Duwe wrote:
> > > +
> > > +echo "int func() { return 0; }" | \
> > > +$* -S -x c -O2 -p -mprofile-kernel - -o - 2> /dev/null | \
> > > +sed -n -e '/func:/,/bl _mcount/p' | grep -q TOC
> > > +
> > > +leaf_toc_result=$?
> > > +
> > 
> > leaf_toc_result failed for me with gcc 5. I'll try and grab gcc-6
> > and give the patches a spin
> 
> Don't bother. _All_ gccs are broken in that respect currently.
> AFAIK Anton is working on this. You have to fake the test, like
> static int a; return a++;
> 
> Gcc fails to set the TOC for profiled "leaf" functions, where it
> thinks no global/static symbols are referenced.
> 
> 

Thanks for the quick answer

BTW, do we expect static/non global functions to be called from
patched contexts? I understand that not supporting it will
complicate a patch.

Balbir Singh
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: [PATCH v2 1/1] powerpc/86xx: Consolidate common platform code

2016-02-11 Thread Denis Kirjanov
On 2/11/16, Alessio Igor Bogani  wrote:
> Signed-off-by: Alessio Igor Bogani 
> ---
> v1 -> v2
>   Use appropriate [PATCH] prefix
>
>  arch/powerpc/platforms/86xx/Makefile   |  2 +-
>  arch/powerpc/platforms/86xx/common.c   | 42
> ++
>  arch/powerpc/platforms/86xx/gef_ppc9a.c| 32 +--
>  arch/powerpc/platforms/86xx/gef_sbc310.c   | 32 +--
>  arch/powerpc/platforms/86xx/gef_sbc610.c   | 32 +--
>  arch/powerpc/platforms/86xx/mpc8610_hpcd.c | 20 ++
>  arch/powerpc/platforms/86xx/mpc86xx.h  |  2 ++
>  arch/powerpc/platforms/86xx/mpc86xx_hpcn.c | 21 +--
>  arch/powerpc/platforms/86xx/sbc8641d.c | 32 +--
>  9 files changed, 52 insertions(+), 163 deletions(-)
>  create mode 100644 arch/powerpc/platforms/86xx/common.c
>
> diff --git a/arch/powerpc/platforms/86xx/Makefile
> b/arch/powerpc/platforms/86xx/Makefile
> index ede815d..2d889ad 100644
> --- a/arch/powerpc/platforms/86xx/Makefile
> +++ b/arch/powerpc/platforms/86xx/Makefile
> @@ -2,7 +2,7 @@
>  # Makefile for the PowerPC 86xx linux kernel.
>  #
>
> -obj-y:= pic.o
> +obj-y:= pic.o common.o
>  obj-$(CONFIG_SMP)+= mpc86xx_smp.o
>  obj-$(CONFIG_MPC8641_HPCN)   += mpc86xx_hpcn.o
>  obj-$(CONFIG_SBC8641D)   += sbc8641d.o
> diff --git a/arch/powerpc/platforms/86xx/common.c
> b/arch/powerpc/platforms/86xx/common.c
> new file mode 100644
> index 000..bee3177
> --- /dev/null
> +++ b/arch/powerpc/platforms/86xx/common.c
> @@ -0,0 +1,42 @@
> +/*
> + * Routines common to most mpc86xx-based boards.
> + *
> + * This is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 as
> + * published by the Free Software Foundation.
> + */
> +
> +#include 
> +
> +#include "mpc86xx.h"
> +
> +static const struct of_device_id mpc86xx_common_ids[] __initconst = {
> + { .type = "soc", },
> + { .compatible = "soc", },
> + { .compatible = "simple-bus", },
> + { .name = "localbus", },
> + { .compatible = "gianfar", },
> + { .compatible = "fsl,mpc8641-pcie", },
> + {},
> +};
> +
> +int __init mpc86xx_common_publish_devices(void)
> +{
> + return of_platform_bus_probe(NULL, mpc86xx_common_ids, NULL);
> +}
> +
> +long __init mpc86xx_time_init(void)
> +{
> + unsigned int temp;
> +
> + /* Set the time base to zero */
> + mtspr(SPRN_TBWL, 0);
> + mtspr(SPRN_TBWU, 0);
> +
> + temp = mfspr(SPRN_HID0);
> + temp |= HID0_TBEN;
> + mtspr(SPRN_HID0, temp);
> + asm volatile("isync");
While we're here you could just use isync()

> +
> + return 0;
> +}
> diff --git a/arch/powerpc/platforms/86xx/gef_ppc9a.c
> b/arch/powerpc/platforms/86xx/gef_ppc9a.c
> index bf17933..8e63b75 100644
> --- a/arch/powerpc/platforms/86xx/gef_ppc9a.c
> +++ b/arch/powerpc/platforms/86xx/gef_ppc9a.c
> @@ -197,37 +197,7 @@ static int __init gef_ppc9a_probe(void)
>   return 0;
>  }
>
> -static long __init mpc86xx_time_init(void)
> -{
> - unsigned int temp;
> -
> - /* Set the time base to zero */
> - mtspr(SPRN_TBWL, 0);
> - mtspr(SPRN_TBWU, 0);
> -
> - temp = mfspr(SPRN_HID0);
> - temp |= HID0_TBEN;
> - mtspr(SPRN_HID0, temp);
> - asm volatile("isync");
> -
> - return 0;
> -}
> -
> -static const struct of_device_id of_bus_ids[] __initconst = {
> - { .compatible = "simple-bus", },
> - { .compatible = "gianfar", },
> - { .compatible = "fsl,mpc8641-pcie", },
> - {},
> -};
> -
> -static int __init declare_of_platform_devices(void)
> -{
> - printk(KERN_DEBUG "Probe platform devices\n");
> - of_platform_bus_probe(NULL, of_bus_ids, NULL);
> -
> - return 0;
> -}
> -machine_arch_initcall(gef_ppc9a, declare_of_platform_devices);
> +machine_arch_initcall(gef_ppc9a, mpc86xx_common_publish_devices);
>
>  define_machine(gef_ppc9a) {
>   .name   = "GE PPC9A",
> diff --git a/arch/powerpc/platforms/86xx/gef_sbc310.c
> b/arch/powerpc/platforms/86xx/gef_sbc310.c
> index 8facf58..0e0be94 100644
> --- a/arch/powerpc/platforms/86xx/gef_sbc310.c
> +++ b/arch/powerpc/platforms/86xx/gef_sbc310.c
> @@ -184,37 +184,7 @@ static int __init gef_sbc310_probe(void)
>   return 0;
>  }
>
> -static long __init mpc86xx_time_init(void)
> -{
> - unsigned int temp;
> -
> - /* Set the time base to zero */
> - mtspr(SPRN_TBWL, 0);
> - mtspr(SPRN_TBWU, 0);
> -
> - temp = mfspr(SPRN_HID0);
> - temp |= HID0_TBEN;
> - mtspr(SPRN_HID0, temp);
> - asm volatile("isync");
> -
> - return 0;
> -}
> -
> -static const struct of_device_id of_bus_ids[] __initconst = {
> - { .compatible = "simple-bus", },
> - { .compatible = "gianfar", },
> - { .compatible = "fsl,mpc8641-pcie", },
> - {},
> -};
> -
> -static int __init declare_of_platform_devices(void)
> -{
> - print

Re: [PATCH v8 6/8] Implement kernel live patching for ppc64le (ABIv2)

2016-02-11 Thread Miroslav Benes
On Wed, 10 Feb 2016, Torsten Duwe wrote:

> diff --git a/arch/powerpc/include/asm/livepatch.h 
> b/arch/powerpc/include/asm/livepatch.h
> new file mode 100644
> index 000..44e8a2d
> --- /dev/null
> +++ b/arch/powerpc/include/asm/livepatch.h
> @@ -0,0 +1,45 @@
> +/*
> + * livepatch.h - powerpc-specific Kernel Live Patching Core
> + *
> + * Copyright (C) 2015 SUSE
> + *
> + * This program is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU General Public License
> + * as published by the Free Software Foundation; either version 2
> + * of the License, or (at your option) any later version.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program; if not, see .
> + */
> +#ifndef _ASM_POWERPC64_LIVEPATCH_H
> +#define _ASM_POWERPC64_LIVEPATCH_H
> +
> +#include 
> +#include 
> +
> +#ifdef CONFIG_LIVEPATCH
> +static inline int klp_check_compiler_support(void)
> +{
> +#if !defined(_CALL_ELF) || _CALL_ELF != 2 || 
> !defined(CC_USING_MPROFILE_KERNEL)
> + return 1;
> +#endif
> + return 0;
> +}
> +
> +extern int klp_write_module_reloc(struct module *mod, unsigned long type,
> +unsigned long loc, unsigned long value);

It would be better to make this one static inline and move 'return 
-ENOSYS;' here. Thus there would be no arch/powerpc/kernel/livepatch.c. 
See s390 code for reference.

> +static inline void klp_arch_set_pc(struct pt_regs *regs, unsigned long ip)
> +{
> + regs->nip = ip;
> +}
> +#else
> +#error Live patching support is disabled; check CONFIG_LIVEPATCH

Change the error to

#error Include linux/livepatch.h, not asm/livepatch.h

please. See 383bf44d1a8b ("livepatch: change the error message in 
asm/livepatch.h header files").

Thanks Torsten,
Miroslav
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: [PATCH v2 7/7] ibmvscsi: use H_CLOSED instead of magic number

2016-02-11 Thread Johannes Thumshirn
On Wed, Feb 10, 2016 at 07:32:28PM -0600, Tyrel Datwyler wrote:
> In a couple places the magic value of 2 is used to check the return
> code of hypercalls. This translates to H_CLOSED.
> 
> Signed-off-by: Tyrel Datwyler 

Reviewed-by: Johannes Thumshirn 

-- 
Johannes Thumshirn  Storage
jthumsh...@suse.de+49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: [PATCH v2 5/7] ibmvscsi: Remove unsupported host config MAD

2016-02-11 Thread Johannes Thumshirn
On Wed, Feb 10, 2016 at 07:32:26PM -0600, Tyrel Datwyler wrote:
> A VIOSRP_HOST_CONFIG_TYPE management datagram (MAD) has existed in
> the code for some time. From what information I've gathered from
> Brian King this was likely implemented on the host side in a SLES 9
> based VIOS, which is no longer supported anywhere. Further, it is
> not defined in PAPR or supported by any AIX based VIOS.
> 
> Treating as bit rot and removing the associated host config code.
> The config attribute and its show function are left as not to break
> userspace. The behavior remains the same returning nothing.
> 
> Signed-off-by: Tyrel Datwyler 

Reviewed-by: Johannes Thumshirn 

-- 
Johannes Thumshirn  Storage
jthumsh...@suse.de+49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: [PATCH v2 2/7] ibmvscsi: Add and use enums for valid CRQ header values

2016-02-11 Thread Johannes Thumshirn
On Wed, Feb 10, 2016 at 07:32:23PM -0600, Tyrel Datwyler wrote:
> The PAPR defines four valid header values for the first byte of a
> CRQ message. Namely, an unused/empty message (0x00), a valid
> command/response entry (0x80), a valid initialization entry (0xC0),
> and a valid transport event (0xFF). Further, initialization responses
> have two formats namely initialize (0x01) and initialize complete
> (0x02). Define these values as enums and use them in the code in
> place of their magic number equivalents.
> 
> Signed-off-by: Tyrel Datwyler 

Reviewed-by: Johannes Thumshirn 

-- 
Johannes Thumshirn  Storage
jthumsh...@suse.de+49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: [PATCH v8 4/8] ppc64 ftrace_with_regs configuration variables

2016-02-11 Thread Torsten Duwe
On Thu, Feb 11, 2016 at 06:48:17PM +1100, Balbir Singh wrote:
> On Wed, 2016-02-10 at 17:25 +0100, Torsten Duwe wrote:
> > +
> > +echo "int func() { return 0; }" | \
> > +$* -S -x c -O2 -p -mprofile-kernel - -o - 2> /dev/null | \
> > +sed -n -e '/func:/,/bl _mcount/p' | grep -q TOC
> > +
> > +leaf_toc_result=$?
> > +
> 
> leaf_toc_result failed for me with gcc 5. I'll try and grab gcc-6
> and give the patches a spin

Don't bother. _All_ gccs are broken in that respect currently.
AFAIK Anton is working on this. You have to fake the test, like
static int a; return a++;

Gcc fails to set the TOC for profiled "leaf" functions, where it
thinks no global/static symbols are referenced.

Torsten

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: [PATCH v8 4/8] ppc64 ftrace_with_regs configuration variables

2016-02-11 Thread Kamalesh Babulal
* Balbir Singh  [2016-02-11 18:48:17]:

> On Wed, 2016-02-10 at 17:25 +0100, Torsten Duwe wrote:
> 
> snip
> 
> > diff --git a/arch/powerpc/gcc-mprofile-kernel-notrace.sh 
> > b/arch/powerpc/gcc-mprofile-kernel-notrace.sh
> > new file mode 100755
> > index 000..68d6482
> > --- /dev/null
> > +++ b/arch/powerpc/gcc-mprofile-kernel-notrace.sh
> > @@ -0,0 +1,33 @@
> > +#!/bin/sh
> > +# Test whether the compile option -mprofile-kernel
> > +# generates profiling code ( = a call to mcount), and
> > +# whether a function without any global references sets
> > +# the TOC pointer properly at the beginning, and
> > +# whether the "notrace" function attribute successfully
> > +# suppresses the _mcount call.
> > +
> > +echo "int func() { return 0; }" | \
> > +$* -S -x c -O2 -p -mprofile-kernel - -o - 2> /dev/null | \
> > +grep -q "mcount"
> > +
> > +trace_result=$?
> > +
> > +echo "int func() { return 0; }" | \
> > +$* -S -x c -O2 -p -mprofile-kernel - -o - 2> /dev/null | \
> > +sed -n -e '/func:/,/bl _mcount/p' | grep -q TOC
> > +
> > +leaf_toc_result=$?
> > +
> 
> leaf_toc_result failed for me with gcc 5. I'll try and grab gcc-6
> and give the patches a spin
> 

It fails for me to on ppc64le but pass over ppc64

# gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/ppc64-redhat-linux/5.1.1/lto-wrapper
Target: ppc64-redhat-linux
[...]
gcc version 5.1.1 20150422 (Red Hat 5.1.1-1) (GCC)

# echo "int func() { return 0;  }" | gcc -S -x c -O2 -p -mprofile-kernel - 
-o - 2> /dev/null | sed -n -e '/func:/,/bl _mcount/p'
func:
.quad   .L.func,.TOC.@tocbase
.previous
.type   func, @function
.L.func:
mflr 0
std 0,16(1)
bl _mcount

# gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/powerpc64le-linux-gnu/5/lto-wrapper
Target: powerpc64le-linux-gnu
[...]
gcc version 5.3.1 20160205 (Ubuntu/IBM 5.3.1-8ubuntu2)

# echo "int func() { return 0;  }" | gcc -S -x c -O2 -p -mprofile-kernel - 
-o - 2> /dev/null | sed -n -e '/func:/,/bl _mcount/p'
func:
mflr 0
std 0,16(1)
bl _mcount


I will try it over gcc-6.

Thanks,
Kamalesh

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: [PATCH v8 0/8] ftrace with regs + live patching for ppc64 LE (ABI v2)

2016-02-11 Thread Torsten Duwe
On Thu, Feb 11, 2016 at 05:18:23PM +1100, Balbir Singh wrote:
> 
> Quick question - I presume these apply on top of 4.5.0-rc2?

Yes.
Torsten

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

[PATCH v2 1/1] powerpc/86xx: Consolidate common platform code

2016-02-11 Thread Alessio Igor Bogani
Signed-off-by: Alessio Igor Bogani 
---
v1 -> v2
Use appropriate [PATCH] prefix

 arch/powerpc/platforms/86xx/Makefile   |  2 +-
 arch/powerpc/platforms/86xx/common.c   | 42 ++
 arch/powerpc/platforms/86xx/gef_ppc9a.c| 32 +--
 arch/powerpc/platforms/86xx/gef_sbc310.c   | 32 +--
 arch/powerpc/platforms/86xx/gef_sbc610.c   | 32 +--
 arch/powerpc/platforms/86xx/mpc8610_hpcd.c | 20 ++
 arch/powerpc/platforms/86xx/mpc86xx.h  |  2 ++
 arch/powerpc/platforms/86xx/mpc86xx_hpcn.c | 21 +--
 arch/powerpc/platforms/86xx/sbc8641d.c | 32 +--
 9 files changed, 52 insertions(+), 163 deletions(-)
 create mode 100644 arch/powerpc/platforms/86xx/common.c

diff --git a/arch/powerpc/platforms/86xx/Makefile 
b/arch/powerpc/platforms/86xx/Makefile
index ede815d..2d889ad 100644
--- a/arch/powerpc/platforms/86xx/Makefile
+++ b/arch/powerpc/platforms/86xx/Makefile
@@ -2,7 +2,7 @@
 # Makefile for the PowerPC 86xx linux kernel.
 #
 
-obj-y  := pic.o
+obj-y  := pic.o common.o
 obj-$(CONFIG_SMP)  += mpc86xx_smp.o
 obj-$(CONFIG_MPC8641_HPCN) += mpc86xx_hpcn.o
 obj-$(CONFIG_SBC8641D) += sbc8641d.o
diff --git a/arch/powerpc/platforms/86xx/common.c 
b/arch/powerpc/platforms/86xx/common.c
new file mode 100644
index 000..bee3177
--- /dev/null
+++ b/arch/powerpc/platforms/86xx/common.c
@@ -0,0 +1,42 @@
+/*
+ * Routines common to most mpc86xx-based boards.
+ *
+ * This is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include 
+
+#include "mpc86xx.h"
+
+static const struct of_device_id mpc86xx_common_ids[] __initconst = {
+   { .type = "soc", },
+   { .compatible = "soc", },
+   { .compatible = "simple-bus", },
+   { .name = "localbus", },
+   { .compatible = "gianfar", },
+   { .compatible = "fsl,mpc8641-pcie", },
+   {},
+};
+
+int __init mpc86xx_common_publish_devices(void)
+{
+   return of_platform_bus_probe(NULL, mpc86xx_common_ids, NULL);
+}
+
+long __init mpc86xx_time_init(void)
+{
+   unsigned int temp;
+
+   /* Set the time base to zero */
+   mtspr(SPRN_TBWL, 0);
+   mtspr(SPRN_TBWU, 0);
+
+   temp = mfspr(SPRN_HID0);
+   temp |= HID0_TBEN;
+   mtspr(SPRN_HID0, temp);
+   asm volatile("isync");
+
+   return 0;
+}
diff --git a/arch/powerpc/platforms/86xx/gef_ppc9a.c 
b/arch/powerpc/platforms/86xx/gef_ppc9a.c
index bf17933..8e63b75 100644
--- a/arch/powerpc/platforms/86xx/gef_ppc9a.c
+++ b/arch/powerpc/platforms/86xx/gef_ppc9a.c
@@ -197,37 +197,7 @@ static int __init gef_ppc9a_probe(void)
return 0;
 }
 
-static long __init mpc86xx_time_init(void)
-{
-   unsigned int temp;
-
-   /* Set the time base to zero */
-   mtspr(SPRN_TBWL, 0);
-   mtspr(SPRN_TBWU, 0);
-
-   temp = mfspr(SPRN_HID0);
-   temp |= HID0_TBEN;
-   mtspr(SPRN_HID0, temp);
-   asm volatile("isync");
-
-   return 0;
-}
-
-static const struct of_device_id of_bus_ids[] __initconst = {
-   { .compatible = "simple-bus", },
-   { .compatible = "gianfar", },
-   { .compatible = "fsl,mpc8641-pcie", },
-   {},
-};
-
-static int __init declare_of_platform_devices(void)
-{
-   printk(KERN_DEBUG "Probe platform devices\n");
-   of_platform_bus_probe(NULL, of_bus_ids, NULL);
-
-   return 0;
-}
-machine_arch_initcall(gef_ppc9a, declare_of_platform_devices);
+machine_arch_initcall(gef_ppc9a, mpc86xx_common_publish_devices);
 
 define_machine(gef_ppc9a) {
.name   = "GE PPC9A",
diff --git a/arch/powerpc/platforms/86xx/gef_sbc310.c 
b/arch/powerpc/platforms/86xx/gef_sbc310.c
index 8facf58..0e0be94 100644
--- a/arch/powerpc/platforms/86xx/gef_sbc310.c
+++ b/arch/powerpc/platforms/86xx/gef_sbc310.c
@@ -184,37 +184,7 @@ static int __init gef_sbc310_probe(void)
return 0;
 }
 
-static long __init mpc86xx_time_init(void)
-{
-   unsigned int temp;
-
-   /* Set the time base to zero */
-   mtspr(SPRN_TBWL, 0);
-   mtspr(SPRN_TBWU, 0);
-
-   temp = mfspr(SPRN_HID0);
-   temp |= HID0_TBEN;
-   mtspr(SPRN_HID0, temp);
-   asm volatile("isync");
-
-   return 0;
-}
-
-static const struct of_device_id of_bus_ids[] __initconst = {
-   { .compatible = "simple-bus", },
-   { .compatible = "gianfar", },
-   { .compatible = "fsl,mpc8641-pcie", },
-   {},
-};
-
-static int __init declare_of_platform_devices(void)
-{
-   printk(KERN_DEBUG "Probe platform devices\n");
-   of_platform_bus_probe(NULL, of_bus_ids, NULL);
-
-   return 0;
-}
-machine_arch_initcall(gef_sbc310, declare_of_platform_devices);
+machine_arch_initcall(gef_sbc310, mpc86xx_common_publish_devices);
 
 define_machine(gef_sbc310) {
.name