LinuxPPC-Dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
* RE: PCIE Hotplug on P2010(mpc85xx) ?
From: Joakim Tjernlund @ 2012-07-20  9:57 UTC (permalink / raw)
  To: Zang Roy-R61911; +Cc: linuxppc-dev@ozlabs.org
In-Reply-To: <3E027F8168735B46AC006B1D0C7BB002079C3332@039-SN2MPN1-013.039d.mgd.msft.net>

Zang Roy-R61911 <r61911@freescale.com> wrote on 2012/07/20 11:31:31:
>
>
> > -----Original Message-----
> > From: Joakim Tjernlund [mailto:joakim.tjernlund@transmode.se]
> > Sent: Friday, July 20, 2012 16:36 PM
> > To: Zang Roy-R61911
> > Cc: linuxppc-dev@ozlabs.org
> > Subject: RE: PCIE Hotplug on P2010(mpc85xx) ?
> >
> > Zang Roy-R61911 <r61911@freescale.com> wrote on 2012/07/20 10:15:46:
> > >
> > > I do not think P2010 has a functional pciehp module in the pcie
> > controller.
> > > Roy
> >
> > Maybe there is, see my latest mail to the list (today) titled:
> > mpc8xxx PCIe hotplug needs fixing, some clues
> No. if you check the hotplug register in configuration space in
> P2010, which missrd some important bit define for hotplug, for example,
> "Data Link Layer State Changed" in slot status register.

Too bad, but one might be able to use something else, just guessing though.
However, performing a manual rescan should do the trick.

Perhaps you could comment on the "mpc8xxx PCIe hotplug needs fixing, some clues" mail too?

> And more, hotplug needs extra hardware pin in the silicon, which is missing for P2010.

Ohh, what is the name of this pin?

 Jocke

^ permalink raw reply

* RE: PCIE Hotplug on P2010(mpc85xx) ?
From: Zang Roy-R61911 @ 2012-07-20  9:31 UTC (permalink / raw)
  To: Joakim Tjernlund; +Cc: linuxppc-dev@ozlabs.org
In-Reply-To: <OFBF3755D8.5571BBB7-ONC1257A41.002F199A-C1257A41.002F3A5A@transmode.se>



> -----Original Message-----
> From: Joakim Tjernlund [mailto:joakim.tjernlund@transmode.se]
> Sent: Friday, July 20, 2012 16:36 PM
> To: Zang Roy-R61911
> Cc: linuxppc-dev@ozlabs.org
> Subject: RE: PCIE Hotplug on P2010(mpc85xx) ?
>=20
> Zang Roy-R61911 <r61911@freescale.com> wrote on 2012/07/20 10:15:46:
> >
> > I do not think P2010 has a functional pciehp module in the pcie
> controller.
> > Roy
>=20
> Maybe there is, see my latest mail to the list (today) titled:
> mpc8xxx PCIe hotplug needs fixing, some clues
No. if you check the hotplug register in configuration space in
P2010, which missrd some important bit define for hotplug, for example,
"Data Link Layer State Changed" in slot status register.
And more, hotplug needs extra hardware pin in the silicon, which is missing=
 for P2010.
Roy
>=20
> >
> > > -----Original Message-----
> > > From: Linuxppc-dev [mailto:linuxppc-dev-bounces+tie-
> > > fei.zang=3Dfreescale.com@lists.ozlabs.org] On Behalf Of Joakim Tjernl=
und
> > > Sent: Tuesday, July 10, 2012 3:44 AM
> > > To: linuxppc-dev@ozlabs.org
> > > Subject: PCIE Hotplug on P2010(mpc85xx) ?
> > >
> > >
> > > Trying to get the pciehp module to work on the above system.
> > > I can see it register but then nothing happens. I suspect there is
> > > something missing that I don't see ATM. Any clues what to look for?
> > >
> > >  Jocke
> > >
> > > _______________________________________________
> > > Linuxppc-dev mailing list
> > > Linuxppc-dev@lists.ozlabs.org
> > > https://lists.ozlabs.org/listinfo/linuxppc-dev
> >
> >
>=20

^ permalink raw reply

* RE: [RFC] [PATCH] powerpc: Add MSR_DE to MSR_KERNEL
From: Joakim Tjernlund @ 2012-07-20  8:37 UTC (permalink / raw)
  To: Zang Roy-R61911
  Cc: Wood Scott-B07421, Dan Malek, Support, Bob Cochran,
	linuxppc-dev@ozlabs.org
In-Reply-To: <3E027F8168735B46AC006B1D0C7BB002079C3290@039-SN2MPN1-013.039d.mgd.msft.net>

Zang Roy-R61911 <r61911@freescale.com> wrote on 2012/07/20 10:27:52:
>
>
>
> > -----Original Message-----
> > From: linuxppc-dev-bounces+tie-fei.zang=freescale.com@lists.ozlabs.org
> > [mailto:linuxppc-dev-bounces+tie-fei.zang=freescale.com@lists.ozlabs.org]
> > On Behalf Of Joakim Tjernlund
> > Sent: Friday, June 01, 2012 6:36 AM
> > To: Wood Scott-B07421
> > Cc: linuxppc-dev@ozlabs.org; Dan Malek; Bob Cochran; Support
> > Subject: Re: [RFC] [PATCH] powerpc: Add MSR_DE to MSR_KERNEL
> >
> > Scott Wood <scottwood@freescale.com> wrote on 2012/06/01 00:16:53:
> > >
> > > On 05/31/2012 05:14 PM, Joakim Tjernlund wrote:
> > > > Scott Wood <scottwood@freescale.com> wrote on 2012/05/31 23:43:34:
> > > >>
> > > >> On 05/31/2012 04:38 PM, Joakim Tjernlund wrote:
> > > >>> Scott Wood <scottwood@freescale.com> wrote on 2012/05/31 19:47:53:
> > > >>>>
> > > >>>> On 05/31/2012 04:56 AM, Joakim Tjernlund wrote:
> > > >>>>> Abatron Support <support@abatron.ch> wrote on 2012/05/31 11:30:57:
> > > >>>>>>
> > > >>>>>>
> > > >>>>>>> Abatron Support <support@abatron.ch> wrote on 2012/05/30 14:08:26:
> > > >>>>>>>>
> > > >>>>>>>>>> I have tested this briefly with BDI2000 on P2010(e500) and
> > > >>>>>>>>>> it works for me. I don't know if there are any bad side
> > effects,
> > > >>>>>>>>>> therfore
> > > >>>>>>>>>> this RFC.
> > > >>>>>>>>
> > > >>>>>>>>> We used to have MSR_DE surrounded by CONFIG_something
> > > >>>>>>>>> to ensure it wasn't set under normal operation.  IIRC, if
> > MSR_DE
> > > >>>>>>>>> is set, you will have problems with software debuggers that
> > > >>>>>>>>> utilize the the debugging registers in the chip itself.  You
> > only want
> > > >>>>>>>>> to force this to be set when using the BDI, not at other times.
> > > >>>>>>>>
> > > >>>>>>>> This MSR_DE is also of interest and used for software debuggers
> > that
> > > >>>>>>>> make use of the debug registers. Only if MSR_DE is set then
> > debug
> > > >>>>>>>> interrupts are generated. If a debug event leads to a debug
> > interrupt
> > > >>>>>>>> handled by a software debugger or if it leads to a debug halt
> > handled
> > > >>>>>>>> by a JTAG tool is selected with DBCR0_EDM / DBCR0_IDM.
> > > >>>>>>>>
> > > >>>>>>>> The "e500 Core Family Reference Manual" chapter "Chapter 8
> > > >>>>>>>> Debug Support" explains in detail the effect of MSR_DE.
> > > >>>>>>
> > > >>>>>>> So what is the verdict on this? I don't buy into Dan argument
> > without some
> > > >>>>>>> hard data.
> > > >>>>>>
> > > >>>>>> What I tried to mention is that handling the MSR_DE correct is not
> > only
> > > >>>>>> an emulator (JTAG debugger) requirement. Also a software debugger
> > may
> > > >>>>>> depend on a correct handled MSR_DE bit.
> > > >>>>>
> > > >>>>> Yes, that made sense to me too. How would SW debuggers work if the
> > kernel keeps
> > > >>>>> turning off MSR_DE first chance it gets?
> > > >>>>
> > > >>>> The kernel selectively enables MSR_DE when it wants to debug.  I'm
> > not
> > > >>>> sure if anything will be bothered by leaving it on all the time.
> > This
> > > >>>> is something we need for virtualization as well, so a hypervisor can
> > > >>>> debug the guest.
> > > >>>
> > > >>> hmm, I read that as you as in favour of the patch?
> > > >>
> > > >> I'd want some confirmation that it doesn't break anything, and that
> > > >> there aren't any other places that need MSR_DE that this doesn't cover,
> > > >> but in general yes.
> > > >
> > > > Then you need to test drive the patch :)
> > >
> > > I was thinking more along the lines of someone who's more familiar with
> > > the relevant parts of the code confirming that it's really OK, not just
> > > testing that it doesn't blow up in my face.
> >
> > It just occurred to me that you guys have this already in your Linux SDK so
> > it can't be that bad.
> No. MSR_DE is ONLY added when using CW debug in SDK.
> Roy
>

Yes, and I later found that user space debugging is busted if you turn on MSR_DE in
kernel.

 Jocke

^ permalink raw reply

* RE: PCIE Hotplug on P2010(mpc85xx) ?
From: Joakim Tjernlund @ 2012-07-20  8:35 UTC (permalink / raw)
  To: Zang Roy-R61911; +Cc: linuxppc-dev@ozlabs.org
In-Reply-To: <3E027F8168735B46AC006B1D0C7BB002079C326B@039-SN2MPN1-013.039d.mgd.msft.net>

Zang Roy-R61911 <r61911@freescale.com> wrote on 2012/07/20 10:15:46:
>
> I do not think P2010 has a functional pciehp module in the pcie controller.
> Roy

Maybe there is, see my latest mail to the list (today) titled:
mpc8xxx PCIe hotplug needs fixing, some clues

>
> > -----Original Message-----
> > From: Linuxppc-dev [mailto:linuxppc-dev-bounces+tie-
> > fei.zang=freescale.com@lists.ozlabs.org] On Behalf Of Joakim Tjernlund
> > Sent: Tuesday, July 10, 2012 3:44 AM
> > To: linuxppc-dev@ozlabs.org
> > Subject: PCIE Hotplug on P2010(mpc85xx) ?
> >
> >
> > Trying to get the pciehp module to work on the above system.
> > I can see it register but then nothing happens. I suspect there is
> > something missing that I don't see ATM. Any clues what to look for?
> >
> >  Jocke
> >
> > _______________________________________________
> > Linuxppc-dev mailing list
> > Linuxppc-dev@lists.ozlabs.org
> > https://lists.ozlabs.org/listinfo/linuxppc-dev
>
>

^ permalink raw reply

* Re: [RFC PATCH 6/8] memory-hotplug: introduce new function arch_remove_memory()
From: Wen Congyang @ 2012-07-20  8:38 UTC (permalink / raw)
  To: Yasuaki Ishimatsu
  Cc: len.brown, linux-s390, linux-ia64, linux-acpi, linux-sh,
	linux-kernel, cmetcalf, linux-mm, paulus, minchan.kim,
	kosaki.motohiro, rientjes, cl, linuxppc-dev, akpm, liuj97
In-Reply-To: <5009151F.3060903@jp.fujitsu.com>

At 07/20/2012 04:21 PM, Yasuaki Ishimatsu Wrote:
> 2012/07/20 16:12, Wen Congyang wrote:
>> We don't call __add_pages() directly in the function add_memory()
>> because some other architecture related thins needs to be done
>> before or after calling __add_pages(). So we should not call
>> __remove_pages() directly in the function remove_memory.
>> Introduce new function arch_remove_memory() to revert the things done
>> in arch_add_memory().
>>
>> Note: the function for x86_64 will be implemented later. And I don't
>> know how to implement it for s390.
> 
> I think you need cc to other arch ML for reviewing the patch.

I forgot to do it.

> 
> 
>> CC: David Rientjes <rientjes@google.com>
>> CC: Jiang Liu <liuj97@gmail.com>
>> CC: Len Brown <len.brown@intel.com>
>> CC: Benjamin Herrenschmidt <benh@kernel.crashing.org>
>> CC: Paul Mackerras <paulus@samba.org>
>> CC: Christoph Lameter <cl@linux.com>
>> Cc: Minchan Kim <minchan.kim@gmail.com>
>> CC: Andrew Morton <akpm@linux-foundation.org>
>> CC: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
>> CC: Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>
>> Signed-off-by: Wen Congyang <wency@cn.fujitsu.com>
>> ---
>>   arch/ia64/mm/init.c            |   16 ++++++++++++++++
>>   arch/powerpc/mm/mem.c          |   14 ++++++++++++++
>>   arch/s390/mm/init.c            |    8 ++++++++
>>   arch/sh/mm/init.c              |   15 +++++++++++++++
>>   arch/tile/mm/init.c            |    8 ++++++++
>>   arch/x86/mm/init_32.c          |   10 ++++++++++
>>   arch/x86/mm/init_64.c          |    7 +++++++
>>   include/linux/memory_hotplug.h |    1 +
>>   mm/memory_hotplug.c            |    2 +-
>>   9 files changed, 80 insertions(+), 1 deletions(-)
>>
>> diff --git a/arch/ia64/mm/init.c b/arch/ia64/mm/init.c
>> index 0eab454..1e345ed 100644
>> --- a/arch/ia64/mm/init.c
>> +++ b/arch/ia64/mm/init.c
>> @@ -688,6 +688,22 @@ int arch_add_memory(int nid, u64 start, u64 size)
>>
>>       return ret;
>>   }
>> +
>> +#ifdef CONFIG_MEMORY_HOTREMOVE
>> +int arch_remove_memory(u64 start, u64 size)
>> +{
>> +    unsigned long start_pfn = start >> PAGE_SHIFT;
>> +    unsigned long nr_pages = size >> PAGE_SHIFT;
>> +    int ret;
>> +
>> +    ret = __remove_pages(start_pfn, nr_pages);
>> +    if (ret)
>> +        pr_warn("%s: Problem encountered in __remove_pages() as"
>> +            " ret=%d\n", __func__,  ret);
>> +
>> +    return ret;
>> +}
>> +#endif
>>   #endif
>>
>>   /*
>> diff --git a/arch/powerpc/mm/mem.c b/arch/powerpc/mm/mem.c
>> index baaafde..249cef4 100644
>> --- a/arch/powerpc/mm/mem.c
>> +++ b/arch/powerpc/mm/mem.c
>> @@ -133,6 +133,20 @@ int arch_add_memory(int nid, u64 start, u64 size)
>>
>>       return __add_pages(nid, zone, start_pfn, nr_pages);
>>   }
>> +
>> +#ifdef CONFIG_MEMORY_HOTREMOVE
>> +int arch_remove_memory(u64 start, u64 size)
>> +{
>> +    unsigned long start_pfn = start >> PAGE_SHIFT;
>> +    unsigned long nr_pages = size >> PAGE_SHIFT;
>> +
>> +    start = (unsigned long)__va(start);
>> +    if (remove_section_mapping(start, start + size))
>> +        return -EINVAL;
>> +
>> +    return __remove_pages(start_pfn, nr_pages);
>> +}
>> +#endif
>>   #endif /* CONFIG_MEMORY_HOTPLUG */
>>
>>   /*
>> diff --git a/arch/s390/mm/init.c b/arch/s390/mm/init.c
>> index 2bea060..3de0d5b 100644
>> --- a/arch/s390/mm/init.c
>> +++ b/arch/s390/mm/init.c
>> @@ -259,4 +259,12 @@ int arch_add_memory(int nid, u64 start, u64 size)
>>           vmem_remove_mapping(start, size);
>>       return rc;
>>   }
>> +
>> +#ifdef CONFIG_MEMORY_HOTREMOVE
>> +int arch_remove_memory(u64 start, u64 size)
>> +{
>> +    /* TODO */
>> +    return -EBUSY;
>> +}
>> +#endif
>>   #endif /* CONFIG_MEMORY_HOTPLUG */
>> diff --git a/arch/sh/mm/init.c b/arch/sh/mm/init.c
>> index 82cc576..fc84491 100644
>> --- a/arch/sh/mm/init.c
>> +++ b/arch/sh/mm/init.c
>> @@ -558,4 +558,19 @@ int memory_add_physaddr_to_nid(u64 addr)
>>   EXPORT_SYMBOL_GPL(memory_add_physaddr_to_nid);
>>   #endif
>>
>> +#ifdef CONFIG_MEMORY_HOTREMOVE
>> +int arch_remove_memory(u64 start, u64 size)
>> +{
>> +    unsigned long start_pfn = start >> PAGE_SHIFT;
>> +    unsigned long nr_pages = size >> PAGE_SHIFT;
>> +    int ret;
>> +
>> +    ret = __remove_pages(start_pfn, nr_pages);
>> +    if (unlikely(ret))
>> +        pr_warn("%s: Failed, __remove_pages() == %d\n", __func__,
>> +            ret);
>> +
>> +    return ret;
>> +}
>> +#endif
>>   #endif /* CONFIG_MEMORY_HOTPLUG */
>> diff --git a/arch/tile/mm/init.c b/arch/tile/mm/init.c
>> index 630dd2c..bdd8a99 100644
>> --- a/arch/tile/mm/init.c
>> +++ b/arch/tile/mm/init.c
>> @@ -947,6 +947,14 @@ int remove_memory(u64 start, u64 size)
>>   {
>>       return -EINVAL;
>>   }
>> +
>> +#ifdef CONFIG_MEMORY_HOTREMOVE
>> +int arch_remove_memory(u64 start, u64 size)
>> +{
>> +    /* TODO */
>> +    return -EBUSY;
>> +}
>> +#endif
>>   #endif
>>
>>   struct kmem_cache *pgd_cache;
>> diff --git a/arch/x86/mm/init_32.c b/arch/x86/mm/init_32.c
>> index 575d86f..a690153 100644
>> --- a/arch/x86/mm/init_32.c
>> +++ b/arch/x86/mm/init_32.c
>> @@ -842,6 +842,16 @@ int arch_add_memory(int nid, u64 start, u64 size)
>>
>>       return __add_pages(nid, zone, start_pfn, nr_pages);
>>   }
>> +
>> +#ifdef CONFIG_MEMORY_HOTREMOVE
>> +int arch_remove_memory(unsigned long start, unsigned long size)
>> +{
>> +    unsigned long start_pfn = start >> PAGE_SHIFT;
>> +    unsigned long nr_pages = size >> PAGE_SHIFT;
>> +
>> +    return __remove_pages(start_pfn, nr_pages);
>> +}
>> +#endif
>>   #endif
>>
>>   /*
>> diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
>> index 9e635b3..78b94bc 100644
>> --- a/arch/x86/mm/init_64.c
>> +++ b/arch/x86/mm/init_64.c
>> @@ -675,6 +675,13 @@ int arch_add_memory(int nid, u64 start, u64 size)
>>   }
>>   EXPORT_SYMBOL_GPL(arch_add_memory);
>>
>> +#ifdef CONFIG_MEMORY_HOTREMOVE
>> +int arch_remove_memory(unsigned long start, unsigned long size)
>> +{
>> +    /* TODO */
>> +    return -EBUSY;
>> +}
>> +#endif
> 
> Why does not the function call __remove_pages()?

arch_remove_memory() should clear the page table after remove pages here.
I implement this function in patch 8.

Thanks
Wen Congyang

> 
> Thanks,
> Yasuaki ishimatsu
> 
>>   #endif /* CONFIG_MEMORY_HOTPLUG */
>>
>>   static struct kcore_list kcore_vsyscall;
>> diff --git a/include/linux/memory_hotplug.h
>> b/include/linux/memory_hotplug.h
>> index 2ba0a1a..8639799 100644
>> --- a/include/linux/memory_hotplug.h
>> +++ b/include/linux/memory_hotplug.h
>> @@ -84,6 +84,7 @@ extern void __online_page_free(struct page *page);
>>
>>   #ifdef CONFIG_MEMORY_HOTREMOVE
>>   extern bool is_pageblock_removable_nolock(struct page *page);
>> +extern int arch_remove_memory(unsigned long start, unsigned long size);
>>   #endif /* CONFIG_MEMORY_HOTREMOVE */
>>
>>   /* reasonably generic interface to expand the physical pages in a
>> zone  */
>> diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
>> index dccdf71..cc2c8b9 100644
>> --- a/mm/memory_hotplug.c
>> +++ b/mm/memory_hotplug.c
>> @@ -1055,7 +1055,7 @@ int __ref remove_memory(int nid, u64 start, u64
>> size)
>>           unregister_one_node(nid);
>>       }
>>
>> -    __remove_pages(start >> PAGE_SHIFT, size >> PAGE_SHIFT);
>> +    arch_remove_memory(start, size);
>>   out:
>>       unlock_memory_hotplug();
>>       return ret;
>>
> 
> 
> 

^ permalink raw reply

* RE: [RFC] [PATCH] powerpc: Add MSR_DE to MSR_KERNEL
From: Zang Roy-R61911 @ 2012-07-20  8:27 UTC (permalink / raw)
  To: Joakim Tjernlund, Wood Scott-B07421
  Cc: linuxppc-dev@ozlabs.org, Dan Malek, Bob Cochran, Support
In-Reply-To: <OFDC3DAEDA.27E0B532-ONC1257A0F.007BF637-C1257A0F.007C1E26@transmode.se>



> -----Original Message-----
> From: linuxppc-dev-bounces+tie-fei.zang=3Dfreescale.com@lists.ozlabs.org
> [mailto:linuxppc-dev-bounces+tie-fei.zang=3Dfreescale.com@lists.ozlabs.or=
g]
> On Behalf Of Joakim Tjernlund
> Sent: Friday, June 01, 2012 6:36 AM
> To: Wood Scott-B07421
> Cc: linuxppc-dev@ozlabs.org; Dan Malek; Bob Cochran; Support
> Subject: Re: [RFC] [PATCH] powerpc: Add MSR_DE to MSR_KERNEL
>=20
> Scott Wood <scottwood@freescale.com> wrote on 2012/06/01 00:16:53:
> >
> > On 05/31/2012 05:14 PM, Joakim Tjernlund wrote:
> > > Scott Wood <scottwood@freescale.com> wrote on 2012/05/31 23:43:34:
> > >>
> > >> On 05/31/2012 04:38 PM, Joakim Tjernlund wrote:
> > >>> Scott Wood <scottwood@freescale.com> wrote on 2012/05/31 19:47:53:
> > >>>>
> > >>>> On 05/31/2012 04:56 AM, Joakim Tjernlund wrote:
> > >>>>> Abatron Support <support@abatron.ch> wrote on 2012/05/31 11:30:57=
:
> > >>>>>>
> > >>>>>>
> > >>>>>>> Abatron Support <support@abatron.ch> wrote on 2012/05/30 14:08:=
26:
> > >>>>>>>>
> > >>>>>>>>>> I have tested this briefly with BDI2000 on P2010(e500) and
> > >>>>>>>>>> it works for me. I don't know if there are any bad side
> effects,
> > >>>>>>>>>> therfore
> > >>>>>>>>>> this RFC.
> > >>>>>>>>
> > >>>>>>>>> We used to have MSR_DE surrounded by CONFIG_something
> > >>>>>>>>> to ensure it wasn't set under normal operation.  IIRC, if
> MSR_DE
> > >>>>>>>>> is set, you will have problems with software debuggers that
> > >>>>>>>>> utilize the the debugging registers in the chip itself.  You
> only want
> > >>>>>>>>> to force this to be set when using the BDI, not at other time=
s.
> > >>>>>>>>
> > >>>>>>>> This MSR_DE is also of interest and used for software debugger=
s
> that
> > >>>>>>>> make use of the debug registers. Only if MSR_DE is set then
> debug
> > >>>>>>>> interrupts are generated. If a debug event leads to a debug
> interrupt
> > >>>>>>>> handled by a software debugger or if it leads to a debug halt
> handled
> > >>>>>>>> by a JTAG tool is selected with DBCR0_EDM / DBCR0_IDM.
> > >>>>>>>>
> > >>>>>>>> The "e500 Core Family Reference Manual" chapter "Chapter 8
> > >>>>>>>> Debug Support" explains in detail the effect of MSR_DE.
> > >>>>>>
> > >>>>>>> So what is the verdict on this? I don't buy into Dan argument
> without some
> > >>>>>>> hard data.
> > >>>>>>
> > >>>>>> What I tried to mention is that handling the MSR_DE correct is n=
ot
> only
> > >>>>>> an emulator (JTAG debugger) requirement. Also a software debugge=
r
> may
> > >>>>>> depend on a correct handled MSR_DE bit.
> > >>>>>
> > >>>>> Yes, that made sense to me too. How would SW debuggers work if th=
e
> kernel keeps
> > >>>>> turning off MSR_DE first chance it gets?
> > >>>>
> > >>>> The kernel selectively enables MSR_DE when it wants to debug.  I'm
> not
> > >>>> sure if anything will be bothered by leaving it on all the time.
> This
> > >>>> is something we need for virtualization as well, so a hypervisor c=
an
> > >>>> debug the guest.
> > >>>
> > >>> hmm, I read that as you as in favour of the patch?
> > >>
> > >> I'd want some confirmation that it doesn't break anything, and that
> > >> there aren't any other places that need MSR_DE that this doesn't cov=
er,
> > >> but in general yes.
> > >
> > > Then you need to test drive the patch :)
> >
> > I was thinking more along the lines of someone who's more familiar with
> > the relevant parts of the code confirming that it's really OK, not just
> > testing that it doesn't blow up in my face.
>=20
> It just occurred to me that you guys have this already in your Linux SDK =
so
> it can't be that bad.
No. MSR_DE is ONLY added when using CW debug in SDK.
Roy

^ permalink raw reply

* Re: [RFC PATCH 6/8] memory-hotplug: introduce new function arch_remove_memory()
From: Yasuaki Ishimatsu @ 2012-07-20  8:21 UTC (permalink / raw)
  To: Wen Congyang
  Cc: len.brown, linux-acpi, linux-kernel, linux-mm, paulus,
	minchan.kim, kosaki.motohiro, rientjes, cl, linuxppc-dev, akpm,
	liuj97
In-Reply-To: <500904D6.3030109@cn.fujitsu.com>

2012/07/20 16:12, Wen Congyang wrote:
> We don't call __add_pages() directly in the function add_memory()
> because some other architecture related thins needs to be done
> before or after calling __add_pages(). So we should not call
> __remove_pages() directly in the function remove_memory.
> Introduce new function arch_remove_memory() to revert the things done
> in arch_add_memory().
>
> Note: the function for x86_64 will be implemented later. And I don't
> know how to implement it for s390.

I think you need cc to other arch ML for reviewing the patch.


> CC: David Rientjes <rientjes@google.com>
> CC: Jiang Liu <liuj97@gmail.com>
> CC: Len Brown <len.brown@intel.com>
> CC: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> CC: Paul Mackerras <paulus@samba.org>
> CC: Christoph Lameter <cl@linux.com>
> Cc: Minchan Kim <minchan.kim@gmail.com>
> CC: Andrew Morton <akpm@linux-foundation.org>
> CC: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
> CC: Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>
> Signed-off-by: Wen Congyang <wency@cn.fujitsu.com>
> ---
>   arch/ia64/mm/init.c            |   16 ++++++++++++++++
>   arch/powerpc/mm/mem.c          |   14 ++++++++++++++
>   arch/s390/mm/init.c            |    8 ++++++++
>   arch/sh/mm/init.c              |   15 +++++++++++++++
>   arch/tile/mm/init.c            |    8 ++++++++
>   arch/x86/mm/init_32.c          |   10 ++++++++++
>   arch/x86/mm/init_64.c          |    7 +++++++
>   include/linux/memory_hotplug.h |    1 +
>   mm/memory_hotplug.c            |    2 +-
>   9 files changed, 80 insertions(+), 1 deletions(-)
>
> diff --git a/arch/ia64/mm/init.c b/arch/ia64/mm/init.c
> index 0eab454..1e345ed 100644
> --- a/arch/ia64/mm/init.c
> +++ b/arch/ia64/mm/init.c
> @@ -688,6 +688,22 @@ int arch_add_memory(int nid, u64 start, u64 size)
>
>   	return ret;
>   }
> +
> +#ifdef CONFIG_MEMORY_HOTREMOVE
> +int arch_remove_memory(u64 start, u64 size)
> +{
> +	unsigned long start_pfn = start >> PAGE_SHIFT;
> +	unsigned long nr_pages = size >> PAGE_SHIFT;
> +	int ret;
> +
> +	ret = __remove_pages(start_pfn, nr_pages);
> +	if (ret)
> +		pr_warn("%s: Problem encountered in __remove_pages() as"
> +			" ret=%d\n", __func__,  ret);
> +
> +	return ret;
> +}
> +#endif
>   #endif
>
>   /*
> diff --git a/arch/powerpc/mm/mem.c b/arch/powerpc/mm/mem.c
> index baaafde..249cef4 100644
> --- a/arch/powerpc/mm/mem.c
> +++ b/arch/powerpc/mm/mem.c
> @@ -133,6 +133,20 @@ int arch_add_memory(int nid, u64 start, u64 size)
>
>   	return __add_pages(nid, zone, start_pfn, nr_pages);
>   }
> +
> +#ifdef CONFIG_MEMORY_HOTREMOVE
> +int arch_remove_memory(u64 start, u64 size)
> +{
> +	unsigned long start_pfn = start >> PAGE_SHIFT;
> +	unsigned long nr_pages = size >> PAGE_SHIFT;
> +
> +	start = (unsigned long)__va(start);
> +	if (remove_section_mapping(start, start + size))
> +		return -EINVAL;
> +
> +	return __remove_pages(start_pfn, nr_pages);
> +}
> +#endif
>   #endif /* CONFIG_MEMORY_HOTPLUG */
>
>   /*
> diff --git a/arch/s390/mm/init.c b/arch/s390/mm/init.c
> index 2bea060..3de0d5b 100644
> --- a/arch/s390/mm/init.c
> +++ b/arch/s390/mm/init.c
> @@ -259,4 +259,12 @@ int arch_add_memory(int nid, u64 start, u64 size)
>   		vmem_remove_mapping(start, size);
>   	return rc;
>   }
> +
> +#ifdef CONFIG_MEMORY_HOTREMOVE
> +int arch_remove_memory(u64 start, u64 size)
> +{
> +	/* TODO */
> +	return -EBUSY;
> +}
> +#endif
>   #endif /* CONFIG_MEMORY_HOTPLUG */
> diff --git a/arch/sh/mm/init.c b/arch/sh/mm/init.c
> index 82cc576..fc84491 100644
> --- a/arch/sh/mm/init.c
> +++ b/arch/sh/mm/init.c
> @@ -558,4 +558,19 @@ int memory_add_physaddr_to_nid(u64 addr)
>   EXPORT_SYMBOL_GPL(memory_add_physaddr_to_nid);
>   #endif
>
> +#ifdef CONFIG_MEMORY_HOTREMOVE
> +int arch_remove_memory(u64 start, u64 size)
> +{
> +	unsigned long start_pfn = start >> PAGE_SHIFT;
> +	unsigned long nr_pages = size >> PAGE_SHIFT;
> +	int ret;
> +
> +	ret = __remove_pages(start_pfn, nr_pages);
> +	if (unlikely(ret))
> +		pr_warn("%s: Failed, __remove_pages() == %d\n", __func__,
> +			ret);
> +
> +	return ret;
> +}
> +#endif
>   #endif /* CONFIG_MEMORY_HOTPLUG */
> diff --git a/arch/tile/mm/init.c b/arch/tile/mm/init.c
> index 630dd2c..bdd8a99 100644
> --- a/arch/tile/mm/init.c
> +++ b/arch/tile/mm/init.c
> @@ -947,6 +947,14 @@ int remove_memory(u64 start, u64 size)
>   {
>   	return -EINVAL;
>   }
> +
> +#ifdef CONFIG_MEMORY_HOTREMOVE
> +int arch_remove_memory(u64 start, u64 size)
> +{
> +	/* TODO */
> +	return -EBUSY;
> +}
> +#endif
>   #endif
>
>   struct kmem_cache *pgd_cache;
> diff --git a/arch/x86/mm/init_32.c b/arch/x86/mm/init_32.c
> index 575d86f..a690153 100644
> --- a/arch/x86/mm/init_32.c
> +++ b/arch/x86/mm/init_32.c
> @@ -842,6 +842,16 @@ int arch_add_memory(int nid, u64 start, u64 size)
>
>   	return __add_pages(nid, zone, start_pfn, nr_pages);
>   }
> +
> +#ifdef CONFIG_MEMORY_HOTREMOVE
> +int arch_remove_memory(unsigned long start, unsigned long size)
> +{
> +	unsigned long start_pfn = start >> PAGE_SHIFT;
> +	unsigned long nr_pages = size >> PAGE_SHIFT;
> +
> +	return __remove_pages(start_pfn, nr_pages);
> +}
> +#endif
>   #endif
>
>   /*
> diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
> index 9e635b3..78b94bc 100644
> --- a/arch/x86/mm/init_64.c
> +++ b/arch/x86/mm/init_64.c
> @@ -675,6 +675,13 @@ int arch_add_memory(int nid, u64 start, u64 size)
>   }
>   EXPORT_SYMBOL_GPL(arch_add_memory);
>
> +#ifdef CONFIG_MEMORY_HOTREMOVE
> +int arch_remove_memory(unsigned long start, unsigned long size)
> +{
> +	/* TODO */
> +	return -EBUSY;
> +}
> +#endif

Why does not the function call __remove_pages()?

Thanks,
Yasuaki ishimatsu

>   #endif /* CONFIG_MEMORY_HOTPLUG */
>
>   static struct kcore_list kcore_vsyscall;
> diff --git a/include/linux/memory_hotplug.h b/include/linux/memory_hotplug.h
> index 2ba0a1a..8639799 100644
> --- a/include/linux/memory_hotplug.h
> +++ b/include/linux/memory_hotplug.h
> @@ -84,6 +84,7 @@ extern void __online_page_free(struct page *page);
>
>   #ifdef CONFIG_MEMORY_HOTREMOVE
>   extern bool is_pageblock_removable_nolock(struct page *page);
> +extern int arch_remove_memory(unsigned long start, unsigned long size);
>   #endif /* CONFIG_MEMORY_HOTREMOVE */
>
>   /* reasonably generic interface to expand the physical pages in a zone  */
> diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
> index dccdf71..cc2c8b9 100644
> --- a/mm/memory_hotplug.c
> +++ b/mm/memory_hotplug.c
> @@ -1055,7 +1055,7 @@ int __ref remove_memory(int nid, u64 start, u64 size)
>   		unregister_one_node(nid);
>   	}
>
> -	__remove_pages(start >> PAGE_SHIFT, size >> PAGE_SHIFT);
> +	arch_remove_memory(start, size);
>   out:
>   	unlock_memory_hotplug();
>   	return ret;
>

^ permalink raw reply

* RE: PCIE Hotplug on P2010(mpc85xx) ?
From: Zang Roy-R61911 @ 2012-07-20  8:15 UTC (permalink / raw)
  To: Joakim Tjernlund, linuxppc-dev@ozlabs.org
In-Reply-To: <OF18324FBA.9272A499-ONC1257A36.006C006E-C1257A36.006C6943@transmode.se>

I do not think P2010 has a functional pciehp module in the pcie controller.
Roy

> -----Original Message-----
> From: Linuxppc-dev [mailto:linuxppc-dev-bounces+tie-
> fei.zang=3Dfreescale.com@lists.ozlabs.org] On Behalf Of Joakim Tjernlund
> Sent: Tuesday, July 10, 2012 3:44 AM
> To: linuxppc-dev@ozlabs.org
> Subject: PCIE Hotplug on P2010(mpc85xx) ?
>=20
>=20
> Trying to get the pciehp module to work on the above system.
> I can see it register but then nothing happens. I suspect there is
> something missing that I don't see ATM. Any clues what to look for?
>=20
>  Jocke
>=20
> _______________________________________________
> Linuxppc-dev mailing list
> Linuxppc-dev@lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/linuxppc-dev

^ permalink raw reply

* Re: [RFC PATCH 3/8] memory-hotplug: call remove_memory() to cleanup when removing memory device
From: Yasuaki Ishimatsu @ 2012-07-20  7:49 UTC (permalink / raw)
  To: Wen Congyang
  Cc: len.brown, linux-acpi, linux-kernel, linux-mm, paulus,
	minchan.kim, kosaki.motohiro, rientjes, cl, linuxppc-dev, akpm,
	liuj97
In-Reply-To: <5009046C.106@cn.fujitsu.com>

Hi Wen,

2012/07/20 16:10, Wen Congyang wrote:
> We should remove the following things when removing the memory device:
> 1. memmap and related sysfs files
> 2. iomem_resource
> 3. mem_section and related sysfs files
> 4. node and related sysfs files
>
> The function remove_memory() can do this. So call it after the memory device
> is offlined.
>
> CC: David Rientjes <rientjes@google.com>
> CC: Jiang Liu <liuj97@gmail.com>
> CC: Len Brown <len.brown@intel.com>
> CC: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> CC: Paul Mackerras <paulus@samba.org>
> CC: Christoph Lameter <cl@linux.com>
> Cc: Minchan Kim <minchan.kim@gmail.com>
> CC: Andrew Morton <akpm@linux-foundation.org>
> CC: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
> CC: Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>
> Signed-off-by: Wen Congyang <wency@cn.fujitsu.com>
> ---

I have no comment.
Reviewed-by: Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>

Thanks,
Yasuaki Ishimatsu


>   drivers/acpi/acpi_memhotplug.c |    7 ++++++-
>   1 files changed, 6 insertions(+), 1 deletions(-)
>
> diff --git a/drivers/acpi/acpi_memhotplug.c b/drivers/acpi/acpi_memhotplug.c
> index 712e767..58e4e63 100644
> --- a/drivers/acpi/acpi_memhotplug.c
> +++ b/drivers/acpi/acpi_memhotplug.c
> @@ -315,7 +315,7 @@ static int acpi_memory_disable_device(struct acpi_memory_device *mem_device)
>   {
>   	int result;
>   	struct acpi_memory_info *info, *n;
> -
> +	int node = mem_device->nid;
>
>   	/*
>   	 * Ask the VM to offline this memory range.
> @@ -330,6 +330,11 @@ static int acpi_memory_disable_device(struct acpi_memory_device *mem_device)
>   				if (result)
>   					return result;
>   			}
> +
> +			result = remove_memory(node, info->start_addr,
> +					       info->length);
> +			if (result)
> +				return result;
>   		}
>   		list_del(&info->list);
>   		kfree(info);
>

^ permalink raw reply

* Re: [RFC PATCH 2/8] memory-hotplug: offline memory only when it is onlined
From: Yasuaki Ishimatsu @ 2012-07-20  7:46 UTC (permalink / raw)
  To: Wen Congyang
  Cc: len.brown, linux-acpi, linux-kernel, linux-mm, paulus,
	minchan.kim, kosaki.motohiro, rientjes, cl, linuxppc-dev, akpm,
	liuj97
In-Reply-To: <5009044B.7050203@cn.fujitsu.com>

Hi Wen,

2012/07/20 16:10, Wen Congyang wrote:
> offline_memory() will fail if the memory is not onlined. So check
> whether the memory is onlined before calling offline_memory().
>
> CC: David Rientjes <rientjes@google.com>
> CC: Jiang Liu <liuj97@gmail.com>
> CC: Len Brown <len.brown@intel.com>
> CC: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> CC: Paul Mackerras <paulus@samba.org>
> CC: Christoph Lameter <cl@linux.com>
> Cc: Minchan Kim <minchan.kim@gmail.com>
> CC: Andrew Morton <akpm@linux-foundation.org>
> CC: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
> CC: Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>
> Signed-off-by: Wen Congyang <wency@cn.fujitsu.com>
> ---

I have no comment.
Reviewed-by: Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>

Thanks,
Yasuaki Ishimatsu

>   drivers/acpi/acpi_memhotplug.c |   10 +++++++---
>   1 files changed, 7 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/acpi/acpi_memhotplug.c b/drivers/acpi/acpi_memhotplug.c
> index db8de39..712e767 100644
> --- a/drivers/acpi/acpi_memhotplug.c
> +++ b/drivers/acpi/acpi_memhotplug.c
> @@ -323,9 +323,13 @@ static int acpi_memory_disable_device(struct acpi_memory_device *mem_device)
>   	 */
>   	list_for_each_entry_safe(info, n, &mem_device->res_list, list) {
>   		if (info->enabled) {
> -			result = offline_memory(info->start_addr, info->length);
> -			if (result)
> -				return result;
> +			if (!is_memblk_offline(info->start_addr,
> +					       info->length)) {
> +				result = offline_memory(info->start_addr,
> +							info->length);
> +				if (result)
> +					return result;
> +			}
>   		}
>   		list_del(&info->list);
>   		kfree(info);
>

^ permalink raw reply

* Re: [RFC PATCH 1/8] memory-hotplug: store the node id in acpi_memory_device
From: Yasuaki Ishimatsu @ 2012-07-20  7:35 UTC (permalink / raw)
  To: Wen Congyang
  Cc: len.brown, linux-acpi, linux-kernel, linux-mm, paulus,
	minchan.kim, kosaki.motohiro, rientjes, cl, linuxppc-dev, akpm,
	liuj97
In-Reply-To: <5009041D.3060909@cn.fujitsu.com>

Hi Wen,

2012/07/20 16:09, Wen Congyang wrote:
> The memory device has only one node id. Store the node id when
> enabling the memory device, and we can reuse it when removing the
> memory device.
>
> CC: David Rientjes <rientjes@google.com>
> CC: Jiang Liu <liuj97@gmail.com>
> CC: Len Brown <len.brown@intel.com>
> CC: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> CC: Paul Mackerras <paulus@samba.org>
> CC: Christoph Lameter <cl@linux.com>
> Cc: Minchan Kim <minchan.kim@gmail.com>
> CC: Andrew Morton <akpm@linux-foundation.org>
> CC: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
> CC: Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>
> Signed-off-by: Wen Congyang <wency@cn.fujitsu.com>
> ---

It looks to me.
Reviewed-by: Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>

Thanks,
Yasuaki Ishimatsu

>   drivers/acpi/acpi_memhotplug.c |    8 +++++---
>   1 files changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/acpi/acpi_memhotplug.c b/drivers/acpi/acpi_memhotplug.c
> index 5cafd6b..db8de39 100644
> --- a/drivers/acpi/acpi_memhotplug.c
> +++ b/drivers/acpi/acpi_memhotplug.c
> @@ -84,6 +84,7 @@ struct acpi_memory_info {
>   struct acpi_memory_device {
>   	struct acpi_device * device;
>   	unsigned int state;	/* State of the memory device */
> +	int nid;
>   	struct list_head res_list;
>   };
>
> @@ -257,6 +258,9 @@ static int acpi_memory_enable_device(struct acpi_memory_device *mem_device)
>   		info->enabled = 1;
>   		num_enabled++;
>   	}
> +
> +	mem_device->nid = node;
> +
>   	if (!num_enabled) {
>   		printk(KERN_ERR PREFIX "add_memory failed\n");
>   		mem_device->state = MEMORY_INVALID_STATE;
> @@ -463,7 +467,7 @@ static int acpi_memory_device_remove(struct acpi_device *device, int type)
>
>   	mem_device = acpi_driver_data(device);
>
> -	node = acpi_get_node(mem_device->device->handle);
> +	node = mem_device->nid;
>   	list_for_each_entry_safe(info, tmp, &mem_device->res_list, list) {
>   		if (!info->enabled)
>   			continue;
> @@ -473,8 +477,6 @@ static int acpi_memory_device_remove(struct acpi_device *device, int type)
>   			if (result)
>   				return result;
>   		}
> -		if (node < 0)
> -			node = memory_add_physaddr_to_nid(info->start_addr);
>
>   		result = remove_memory(node, info->start_addr, info->length);
>   		if (result)
>

^ permalink raw reply

* Re: [RFC PATCH 0/8] memory-hotplug : hot-remove physical memory(clear page table)
From: Yasuaki Ishimatsu @ 2012-07-20  7:31 UTC (permalink / raw)
  To: Wen Congyang
  Cc: len.brown, linux-acpi, linux-kernel, linux-mm, paulus,
	minchan.kim, kosaki.motohiro, rientjes, cl, linuxppc-dev, akpm,
	liuj97
In-Reply-To: <5009038A.4090001@cn.fujitsu.com>

[Hi Wen,

Good news!! I was waiting for this patch to come.
Applying the patches, can we hot-remove physical memory completely?

Thanks,
Yasuaki Ishimatsu

2012/07/20 16:06, Wen Congyang wrote:
> This patch series aims to support physical memory hot-remove(clear page table).
>
> This patch series base on ishimatsu's patch series. You can get it here:
> http://www.spinics.net/lists/linux-acpi/msg36804.html
>
> The patches can remove following things:
>    - page table of removed memory
>
> If you find lack of function for physical memory hot-remove, please let me
> know.
>
> Note:
> * The patch "remove memory info from list before freeing it" is being disccussed
>    in other thread. But for testing the patch series, the patch is needed.
>    So I added the patch as [PATCH 0/8].
> * You need to apply ishimatsu's patch series first before applying this patch
>    series.
>
> Wen Congyang (8):
>    memory-hotplug: store the node id in acpi_memory_device
>    memory-hotplug: offline memory only when it is onlined
>    memory-hotplug: call remove_memory() to cleanup when removing memory
>      device
>    memory-hotplug: export the function acpi_bus_remove()
>    memory-hotplug: call acpi_bus_remove() to remove memory device
>    memory-hotplug: introduce new function arch_remove_memory()
>    x86: make __split_large_page() generally avialable
>    memory-hotplug: implement arch_remove_memory()
>
>   arch/ia64/mm/init.c                  |   16 ++++
>   arch/powerpc/mm/mem.c                |   14 +++
>   arch/s390/mm/init.c                  |    8 ++
>   arch/sh/mm/init.c                    |   15 +++
>   arch/tile/mm/init.c                  |    8 ++
>   arch/x86/include/asm/pgtable_types.h |    1 +
>   arch/x86/mm/init_32.c                |   10 ++
>   arch/x86/mm/init_64.c                |  160 ++++++++++++++++++++++++++++++++++
>   arch/x86/mm/pageattr.c               |   47 +++++-----
>   drivers/acpi/acpi_memhotplug.c       |   24 ++++--
>   drivers/acpi/scan.c                  |    3 +-
>   include/acpi/acpi_bus.h              |    1 +
>   include/linux/memory_hotplug.h       |    1 +
>   mm/memory_hotplug.c                  |    2 +-
>   14 files changed, 280 insertions(+), 30 deletions(-)
>

^ permalink raw reply

* mpc8xxx PCIe hotplug needs fixing, some clues ..
From: Joakim Tjernlund @ 2012-07-20  7:17 UTC (permalink / raw)
  To: galak, scottwood, linuxppc-dev


Hi Guys

I see that you have been hacking Freescale PCI before so I send this to you(and the list)

We are using PCIe(as RC) on P2010(basically a mpc85xx) and have PCI device that
started from user space (needs advance clock conf) so when linux boots there is
no device at all.
Trying to "hotplug" the device after it is enabled fails, no amount of recan/remove using
either fake or real hotplug makes a difference.

I found the cause eventually but I can't fix it properly as I known almost nothing about PCI.
Cause:
indirect_pci.c:indirect_read_config() tests for if (hose->indirect_type & PPC_INDIRECT_TYPE_NO_PCIE_LINK)
and returns  PCIBIOS_DEVICE_NOT_FOUND

PPC_INDIRECT_TYPE_NO_PCIE_LINK get set by fsl_pci.c (look for fsl_pcie_check_link) but is never cleared.
Clearing it as appropriate makes a small difference. If you
remove the RC and do a few of rescan's then the device appears.

Hacking some more, like so:

int fsl_pcie_check_link(struct pci_controller *hose)
{
	u32 val;

	early_read_config_dword(hose, 0, 0, PCIE_LTSSM, &val);
	hose->indirect_type |= PPC_INDIRECT_TYPE_NO_PCIE_LINK;
	if (val < PCIE_LTSSM_L0)
		return 1;
	hose->indirect_type &= ~PPC_INDIRECT_TYPE_NO_PCIE_LINK;
	return 0;
}
and then using it carefully(it is easy to make linux hang) in indirect_read_config():
indirect_read_config(struct pci_bus *bus, unsigned int devfn, int offset,
		     int len, u32 *val)
{
	struct pci_controller *hose = pci_bus_to_host(bus);
	volatile void __iomem *cfg_data;
	u8 cfg_type = 0;
	u32 bus_no, reg;

	if (hose->indirect_type & PPC_INDIRECT_TYPE_NO_PCIE_LINK) {
		if (bus->number != hose->first_busno ||
		    devfn != 0) {
			fsl_pcie_check_link(hose);
			return PCIBIOS_DEVICE_NOT_FOUND;
		}
	}

Now it works, just one rescan and the device appears!
This is a hack, I don't known what other trouble it can cause, I hope you can
sort this out.

BTW,

  I see that the controller has some support for hot plug, by setting a bit or two in
  PEX_CONFIG, out_be32(&pci->pex_config, 0x02), I see slot caps in lspci:
	Capabilities: [4c] Express (v1) Root Port (Slot+), MSI 00
		DevCap:	MaxPayload 256 bytes, PhantFunc 0, Latency L0s <64ns, L1 <1us
			ExtTag- RBE- FLReset-
		DevCtl:	Report errors: Correctable+ Non-Fatal+ Fatal+ Unsupported+
			RlxdOrd+ ExtTag- PhantFunc- AuxPwr- NoSnoop+
			MaxPayload 128 bytes, MaxReadReq 512 bytes
		DevSta:	CorrErr- UncorrErr- FatalErr- UnsuppReq- AuxPwr- TransPend-
		LnkCap:	Port #0, Speed 2.5GT/s, Width x4, ASPM L0s, Latency L0 <2us, L1 unlimited
			ClockPM- Surprise- LLActRep- BwNot-
		LnkCtl:	ASPM Disabled; RCB 128 bytes Disabled- Retrain- CommClk-
			ExtSynch- ClockPM- AutWidDis- BWInt- AutBWInt-
		LnkSta:	Speed 2.5GT/s, Width x1, TrErr- Train- SlotClk- DLActive- BWMgmt- ABWMgmt-
		SltCap:	AttnBtn- PwrCtrl- MRL- AttnInd- PwrInd- HotPlug+ Surprise-
			Slot #0, PowerLimit 15.000W; Interlock- NoCompl-
		SltCtl:	Enable: AttnBtn- PwrFlt- MRL- PresDet+ CmdCplt- HPIrq- LinkChg-
			Control: AttnInd Off, PwrInd Off, Power- Interlock-
		SltSta:	Status: AttnBtn- PowerFlt- MRL- CmdCplt- PresDet- Interlock-
			Changed: MRL- PresDet- LinkState-
		RootCtl: ErrCorrectable- ErrNon-Fatal- ErrFatal- PMEIntEna- CRSVisible-
		RootCap: CRSVisible-
		RootSta: PME ReqID 0000, PMEStatus- PMEPending-

That would be good to enable I think(real hotplug needs them), don't know if this bit is
common for all PCIe controllers from Freescale?

 Jocke

^ permalink raw reply

* [RFC PATCH 8/8] memory-hotplug: implement arch_remove_memory()
From: Wen Congyang @ 2012-07-20  7:14 UTC (permalink / raw)
  To: linux-mm, linux-kernel, linuxppc-dev, linux-acpi
  Cc: len.brown, Yasuaki ISIMATU, paulus, minchan.kim, kosaki.motohiro,
	rientjes, cl, akpm, liuj97
In-Reply-To: <5009038A.4090001@cn.fujitsu.com>

Set the entry for the removed memory to 0. If the entry related meory
is not whole removed, split it to smaller page, and clear it.

CC: David Rientjes <rientjes@google.com>
CC: Jiang Liu <liuj97@gmail.com>
CC: Len Brown <len.brown@intel.com>
CC: Benjamin Herrenschmidt <benh@kernel.crashing.org>
CC: Paul Mackerras <paulus@samba.org>
CC: Christoph Lameter <cl@linux.com>
Cc: Minchan Kim <minchan.kim@gmail.com>
CC: Andrew Morton <akpm@linux-foundation.org>
CC: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
CC: Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>
Signed-off-by: Wen Congyang <wency@cn.fujitsu.com>
---
 arch/x86/mm/init_64.c |  159 ++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 156 insertions(+), 3 deletions(-)

diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
index 78b94bc..d78f352 100644
--- a/arch/x86/mm/init_64.c
+++ b/arch/x86/mm/init_64.c
@@ -675,11 +675,164 @@ int arch_add_memory(int nid, u64 start, u64 size)
 }
 EXPORT_SYMBOL_GPL(arch_add_memory);
 
+static void __meminit
+phys_pte_remove(pte_t *pte_page, unsigned long addr, unsigned long end)
+{
+	unsigned pages = 0;
+	int i = pte_index(addr);
+
+	pte_t *pte = pte_page + pte_index(addr);
+
+	for (; i < PTRS_PER_PTE; i++, addr += PAGE_SIZE, pte++) {
+
+		if (addr >= end)
+			break;
+
+		if (!pte_present(*pte))
+			continue;
+
+		pages++;
+		set_pte(pte, __pte(0));
+	}
+
+	update_page_count(PG_LEVEL_4K, -pages);
+}
+
+static void __meminit
+phys_pmd_remove(pmd_t *pmd_page, unsigned long addr, unsigned long end)
+{
+	unsigned long pages = 0, next;
+	int i = pmd_index(addr);
+
+	for (; i < PTRS_PER_PMD; i++, addr = next) {
+		unsigned long pte_phys;
+		pmd_t *pmd = pmd_page + pmd_index(addr);
+		pte_t *pte;
+
+		if (addr >= end)
+			break;
+
+		next = (addr & PMD_MASK) + PMD_SIZE;
+
+		if (!pmd_present(*pmd))
+			continue;
+
+		if (pmd_large(*pmd)) {
+			if ((addr & ~PMD_MASK) == 0 && next <= end) {
+				set_pmd(pmd, __pmd(0));
+				pages++;
+				continue;
+			}
+
+			/*
+			 * We use 2M page, but we need to remove part of them,
+			 * so split 2M page to 4K page.
+			 */
+			pte = alloc_low_page(&pte_phys);
+			__split_large_page((pte_t *)pmd, addr, pte);
+
+			spin_lock(&init_mm.page_table_lock);
+			pmd_populate_kernel(&init_mm, pmd, __va(pte_phys));
+			spin_unlock(&init_mm.page_table_lock);
+		}
+
+		spin_lock(&init_mm.page_table_lock);
+		pte = map_low_page((pte_t *)pmd_page_vaddr(*pmd));
+		phys_pte_remove(pte, addr, end);
+		unmap_low_page(pte);
+		spin_unlock(&init_mm.page_table_lock);
+	}
+	update_page_count(PG_LEVEL_2M, -pages);
+}
+
+static void __meminit
+phys_pud_remove(pud_t *pud_page, unsigned long addr, unsigned long end)
+{
+	unsigned long pages = 0, next;
+	int i = pud_index(addr);
+
+	for (; i < PTRS_PER_PUD; i++, addr = next) {
+		unsigned long pmd_phys;
+		pud_t *pud = pud_page + pud_index(addr);
+		pmd_t *pmd;
+
+		if (addr >= end)
+			break;
+
+		next = (addr & PUD_MASK) + PUD_SIZE;
+
+		if (!pud_present(*pud))
+			continue;
+
+		if (pud_large(*pud)) {
+			if ((addr & ~PUD_MASK) == 0 && next <= end) {
+				set_pud(pud, __pud(0));
+				pages++;
+				continue;
+			}
+
+			/*
+			 * We use 1G page, but we need to remove part of them,
+			 * so split 1G page to 2M page.
+			 */
+			pmd = alloc_low_page(&pmd_phys);
+			__split_large_page((pte_t *)pud, addr, (pte_t *)pmd);
+
+			spin_lock(&init_mm.page_table_lock);
+			pud_populate(&init_mm, pud, __va(pmd_phys));
+			spin_unlock(&init_mm.page_table_lock);
+		}
+
+		pmd = map_low_page(pmd_offset(pud, 0));
+		phys_pmd_remove(pmd, addr, end);
+		unmap_low_page(pmd);
+		__flush_tlb_all();
+	}
+	__flush_tlb_all();
+
+	update_page_count(PG_LEVEL_1G, -pages);
+}
+
+void __meminit
+kernel_physical_mapping_remove(unsigned long start, unsigned long end)
+{
+	unsigned long next;
+
+	start = (unsigned long)__va(start);
+	end = (unsigned long)__va(end);
+
+	for (; start < end; start = next) {
+		pgd_t *pgd = pgd_offset_k(start);
+		pud_t *pud;
+
+		next = (start + PGDIR_SIZE) & PGDIR_MASK;
+		if (next > end)
+			next = end;
+
+		if (!pgd_present(*pgd))
+			continue;
+
+		pud = map_low_page((pud_t *)pgd_page_vaddr(*pgd));
+		phys_pud_remove(pud, __pa(start), __pa(end));
+		unmap_low_page(pud);
+	}
+
+	__flush_tlb_all();
+}
+
 #ifdef CONFIG_MEMORY_HOTREMOVE
-int arch_remove_memory(unsigned long start, unsigned long size)
+int __ref arch_remove_memory(unsigned long start, unsigned long size)
 {
-	/* TODO */
-	return -EBUSY;
+	unsigned long start_pfn = start >> PAGE_SHIFT;
+	unsigned long nr_pages = size >> PAGE_SHIFT;
+	int ret;
+
+	ret = __remove_pages(start_pfn, nr_pages);
+	WARN_ON_ONCE(ret);
+
+	kernel_physical_mapping_remove(start, start + size);
+
+	return ret;
 }
 #endif
 #endif /* CONFIG_MEMORY_HOTPLUG */
-- 
1.7.1

^ permalink raw reply related

* [RFC PATCH 7/8] x86: make __split_large_page() generally avialable
From: Wen Congyang @ 2012-07-20  7:13 UTC (permalink / raw)
  To: linux-mm, linux-kernel, linuxppc-dev, linux-acpi
  Cc: len.brown, Yasuaki ISIMATU, paulus, minchan.kim, kosaki.motohiro,
	rientjes, cl, akpm, liuj97
In-Reply-To: <5009038A.4090001@cn.fujitsu.com>

We need to clear page table after calling __remove_pages(). We may
need to clear part of pmd or pud's entry when clearing the page table.
So we need to split it to small page. Make __split_large_page()
generally avialable, and we call call this function to split large page.

CC: David Rientjes <rientjes@google.com>
CC: Jiang Liu <liuj97@gmail.com>
CC: Len Brown <len.brown@intel.com>
CC: Benjamin Herrenschmidt <benh@kernel.crashing.org>
CC: Paul Mackerras <paulus@samba.org>
CC: Christoph Lameter <cl@linux.com>
Cc: Minchan Kim <minchan.kim@gmail.com>
CC: Andrew Morton <akpm@linux-foundation.org>
CC: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
CC: Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>
Signed-off-by: Wen Congyang <wency@cn.fujitsu.com>
---
 arch/x86/include/asm/pgtable_types.h |    1 +
 arch/x86/mm/pageattr.c               |   47 ++++++++++++++++++----------------
 2 files changed, 26 insertions(+), 22 deletions(-)

diff --git a/arch/x86/include/asm/pgtable_types.h b/arch/x86/include/asm/pgtable_types.h
index 013286a..b725af2 100644
--- a/arch/x86/include/asm/pgtable_types.h
+++ b/arch/x86/include/asm/pgtable_types.h
@@ -334,6 +334,7 @@ static inline void update_page_count(int level, unsigned long pages) { }
  * as a pte too.
  */
 extern pte_t *lookup_address(unsigned long address, unsigned int *level);
+extern int __split_large_page(pte_t *kpte, unsigned long address, pte_t *pbase);
 
 #endif	/* !__ASSEMBLY__ */
 
diff --git a/arch/x86/mm/pageattr.c b/arch/x86/mm/pageattr.c
index a718e0d..7dcb6f9 100644
--- a/arch/x86/mm/pageattr.c
+++ b/arch/x86/mm/pageattr.c
@@ -501,21 +501,13 @@ out_unlock:
 	return do_split;
 }
 
-static int split_large_page(pte_t *kpte, unsigned long address)
+int __split_large_page(pte_t *kpte, unsigned long address, pte_t *pbase)
 {
 	unsigned long pfn, pfninc = 1;
 	unsigned int i, level;
-	pte_t *pbase, *tmp;
+	pte_t *tmp;
 	pgprot_t ref_prot;
-	struct page *base;
-
-	if (!debug_pagealloc)
-		spin_unlock(&cpa_lock);
-	base = alloc_pages(GFP_KERNEL | __GFP_NOTRACK, 0);
-	if (!debug_pagealloc)
-		spin_lock(&cpa_lock);
-	if (!base)
-		return -ENOMEM;
+	struct page *base = virt_to_page(pbase);
 
 	spin_lock(&pgd_lock);
 	/*
@@ -523,10 +515,11 @@ static int split_large_page(pte_t *kpte, unsigned long address)
 	 * up for us already:
 	 */
 	tmp = lookup_address(address, &level);
-	if (tmp != kpte)
-		goto out_unlock;
+	if (tmp != kpte) {
+		spin_unlock(&pgd_lock);
+		return 1;
+	}
 
-	pbase = (pte_t *)page_address(base);
 	paravirt_alloc_pte(&init_mm, page_to_pfn(base));
 	ref_prot = pte_pgprot(pte_clrhuge(*kpte));
 	/*
@@ -579,17 +572,27 @@ static int split_large_page(pte_t *kpte, unsigned long address)
 	 * going on.
 	 */
 	__flush_tlb_all();
+	spin_unlock(&pgd_lock);
 
-	base = NULL;
+	return 0;
+}
 
-out_unlock:
-	/*
-	 * If we dropped out via the lookup_address check under
-	 * pgd_lock then stick the page back into the pool:
-	 */
-	if (base)
+static int split_large_page(pte_t *kpte, unsigned long address)
+{
+	pte_t *pbase;
+	struct page *base;
+
+	if (!debug_pagealloc)
+		spin_unlock(&cpa_lock);
+	base = alloc_pages(GFP_KERNEL | __GFP_NOTRACK, 0);
+	if (!debug_pagealloc)
+		spin_lock(&cpa_lock);
+	if (!base)
+		return -ENOMEM;
+
+	pbase = (pte_t *)page_address(base);
+	if (__split_large_page(kpte, address, pbase))
 		__free_page(base);
-	spin_unlock(&pgd_lock);
 
 	return 0;
 }
-- 
1.7.1

^ permalink raw reply related

* [RFC PATCH 6/8] memory-hotplug: introduce new function arch_remove_memory()
From: Wen Congyang @ 2012-07-20  7:12 UTC (permalink / raw)
  To: linux-mm, linux-kernel, linuxppc-dev, linux-acpi
  Cc: len.brown, Yasuaki ISIMATU, paulus, minchan.kim, kosaki.motohiro,
	rientjes, cl, akpm, liuj97
In-Reply-To: <5009038A.4090001@cn.fujitsu.com>

We don't call __add_pages() directly in the function add_memory()
because some other architecture related thins needs to be done
before or after calling __add_pages(). So we should not call
__remove_pages() directly in the function remove_memory.
Introduce new function arch_remove_memory() to revert the things done
in arch_add_memory().

Note: the function for x86_64 will be implemented later. And I don't
know how to implement it for s390.

CC: David Rientjes <rientjes@google.com>
CC: Jiang Liu <liuj97@gmail.com>
CC: Len Brown <len.brown@intel.com>
CC: Benjamin Herrenschmidt <benh@kernel.crashing.org>
CC: Paul Mackerras <paulus@samba.org>
CC: Christoph Lameter <cl@linux.com>
Cc: Minchan Kim <minchan.kim@gmail.com>
CC: Andrew Morton <akpm@linux-foundation.org>
CC: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
CC: Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>
Signed-off-by: Wen Congyang <wency@cn.fujitsu.com>
---
 arch/ia64/mm/init.c            |   16 ++++++++++++++++
 arch/powerpc/mm/mem.c          |   14 ++++++++++++++
 arch/s390/mm/init.c            |    8 ++++++++
 arch/sh/mm/init.c              |   15 +++++++++++++++
 arch/tile/mm/init.c            |    8 ++++++++
 arch/x86/mm/init_32.c          |   10 ++++++++++
 arch/x86/mm/init_64.c          |    7 +++++++
 include/linux/memory_hotplug.h |    1 +
 mm/memory_hotplug.c            |    2 +-
 9 files changed, 80 insertions(+), 1 deletions(-)

diff --git a/arch/ia64/mm/init.c b/arch/ia64/mm/init.c
index 0eab454..1e345ed 100644
--- a/arch/ia64/mm/init.c
+++ b/arch/ia64/mm/init.c
@@ -688,6 +688,22 @@ int arch_add_memory(int nid, u64 start, u64 size)
 
 	return ret;
 }
+
+#ifdef CONFIG_MEMORY_HOTREMOVE
+int arch_remove_memory(u64 start, u64 size)
+{
+	unsigned long start_pfn = start >> PAGE_SHIFT;
+	unsigned long nr_pages = size >> PAGE_SHIFT;
+	int ret;
+
+	ret = __remove_pages(start_pfn, nr_pages);
+	if (ret)
+		pr_warn("%s: Problem encountered in __remove_pages() as"
+			" ret=%d\n", __func__,  ret);
+
+	return ret;
+}
+#endif
 #endif
 
 /*
diff --git a/arch/powerpc/mm/mem.c b/arch/powerpc/mm/mem.c
index baaafde..249cef4 100644
--- a/arch/powerpc/mm/mem.c
+++ b/arch/powerpc/mm/mem.c
@@ -133,6 +133,20 @@ int arch_add_memory(int nid, u64 start, u64 size)
 
 	return __add_pages(nid, zone, start_pfn, nr_pages);
 }
+
+#ifdef CONFIG_MEMORY_HOTREMOVE
+int arch_remove_memory(u64 start, u64 size)
+{
+	unsigned long start_pfn = start >> PAGE_SHIFT;
+	unsigned long nr_pages = size >> PAGE_SHIFT;
+
+	start = (unsigned long)__va(start);
+	if (remove_section_mapping(start, start + size))
+		return -EINVAL;
+
+	return __remove_pages(start_pfn, nr_pages);
+}
+#endif
 #endif /* CONFIG_MEMORY_HOTPLUG */
 
 /*
diff --git a/arch/s390/mm/init.c b/arch/s390/mm/init.c
index 2bea060..3de0d5b 100644
--- a/arch/s390/mm/init.c
+++ b/arch/s390/mm/init.c
@@ -259,4 +259,12 @@ int arch_add_memory(int nid, u64 start, u64 size)
 		vmem_remove_mapping(start, size);
 	return rc;
 }
+
+#ifdef CONFIG_MEMORY_HOTREMOVE
+int arch_remove_memory(u64 start, u64 size)
+{
+	/* TODO */
+	return -EBUSY;
+}
+#endif
 #endif /* CONFIG_MEMORY_HOTPLUG */
diff --git a/arch/sh/mm/init.c b/arch/sh/mm/init.c
index 82cc576..fc84491 100644
--- a/arch/sh/mm/init.c
+++ b/arch/sh/mm/init.c
@@ -558,4 +558,19 @@ int memory_add_physaddr_to_nid(u64 addr)
 EXPORT_SYMBOL_GPL(memory_add_physaddr_to_nid);
 #endif
 
+#ifdef CONFIG_MEMORY_HOTREMOVE
+int arch_remove_memory(u64 start, u64 size)
+{
+	unsigned long start_pfn = start >> PAGE_SHIFT;
+	unsigned long nr_pages = size >> PAGE_SHIFT;
+	int ret;
+
+	ret = __remove_pages(start_pfn, nr_pages);
+	if (unlikely(ret))
+		pr_warn("%s: Failed, __remove_pages() == %d\n", __func__,
+			ret);
+
+	return ret;
+}
+#endif
 #endif /* CONFIG_MEMORY_HOTPLUG */
diff --git a/arch/tile/mm/init.c b/arch/tile/mm/init.c
index 630dd2c..bdd8a99 100644
--- a/arch/tile/mm/init.c
+++ b/arch/tile/mm/init.c
@@ -947,6 +947,14 @@ int remove_memory(u64 start, u64 size)
 {
 	return -EINVAL;
 }
+
+#ifdef CONFIG_MEMORY_HOTREMOVE
+int arch_remove_memory(u64 start, u64 size)
+{
+	/* TODO */
+	return -EBUSY;
+}
+#endif
 #endif
 
 struct kmem_cache *pgd_cache;
diff --git a/arch/x86/mm/init_32.c b/arch/x86/mm/init_32.c
index 575d86f..a690153 100644
--- a/arch/x86/mm/init_32.c
+++ b/arch/x86/mm/init_32.c
@@ -842,6 +842,16 @@ int arch_add_memory(int nid, u64 start, u64 size)
 
 	return __add_pages(nid, zone, start_pfn, nr_pages);
 }
+
+#ifdef CONFIG_MEMORY_HOTREMOVE
+int arch_remove_memory(unsigned long start, unsigned long size)
+{
+	unsigned long start_pfn = start >> PAGE_SHIFT;
+	unsigned long nr_pages = size >> PAGE_SHIFT;
+
+	return __remove_pages(start_pfn, nr_pages);
+}
+#endif
 #endif
 
 /*
diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
index 9e635b3..78b94bc 100644
--- a/arch/x86/mm/init_64.c
+++ b/arch/x86/mm/init_64.c
@@ -675,6 +675,13 @@ int arch_add_memory(int nid, u64 start, u64 size)
 }
 EXPORT_SYMBOL_GPL(arch_add_memory);
 
+#ifdef CONFIG_MEMORY_HOTREMOVE
+int arch_remove_memory(unsigned long start, unsigned long size)
+{
+	/* TODO */
+	return -EBUSY;
+}
+#endif
 #endif /* CONFIG_MEMORY_HOTPLUG */
 
 static struct kcore_list kcore_vsyscall;
diff --git a/include/linux/memory_hotplug.h b/include/linux/memory_hotplug.h
index 2ba0a1a..8639799 100644
--- a/include/linux/memory_hotplug.h
+++ b/include/linux/memory_hotplug.h
@@ -84,6 +84,7 @@ extern void __online_page_free(struct page *page);
 
 #ifdef CONFIG_MEMORY_HOTREMOVE
 extern bool is_pageblock_removable_nolock(struct page *page);
+extern int arch_remove_memory(unsigned long start, unsigned long size);
 #endif /* CONFIG_MEMORY_HOTREMOVE */
 
 /* reasonably generic interface to expand the physical pages in a zone  */
diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
index dccdf71..cc2c8b9 100644
--- a/mm/memory_hotplug.c
+++ b/mm/memory_hotplug.c
@@ -1055,7 +1055,7 @@ int __ref remove_memory(int nid, u64 start, u64 size)
 		unregister_one_node(nid);
 	}
 
-	__remove_pages(start >> PAGE_SHIFT, size >> PAGE_SHIFT);
+	arch_remove_memory(start, size);
 out:
 	unlock_memory_hotplug();
 	return ret;
-- 
1.7.1

^ permalink raw reply related

* [RFC PATCH 5/8] memory-hotplug: call acpi_bus_remove() to remove memory device
From: Wen Congyang @ 2012-07-20  7:11 UTC (permalink / raw)
  To: linux-mm, linux-kernel, linuxppc-dev, linux-acpi
  Cc: len.brown, Yasuaki ISIMATU, paulus, minchan.kim, kosaki.motohiro,
	rientjes, cl, akpm, liuj97
In-Reply-To: <5009038A.4090001@cn.fujitsu.com>

The memory device has been ejected and powoffed, so we can call
acpi_bus_remove() to remove the memory device from acpi bus.

CC: David Rientjes <rientjes@google.com>
CC: Jiang Liu <liuj97@gmail.com>
CC: Len Brown <len.brown@intel.com>
CC: Benjamin Herrenschmidt <benh@kernel.crashing.org>
CC: Paul Mackerras <paulus@samba.org>
CC: Christoph Lameter <cl@linux.com>
Cc: Minchan Kim <minchan.kim@gmail.com>
CC: Andrew Morton <akpm@linux-foundation.org>
CC: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
CC: Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>
Signed-off-by: Wen Congyang <wency@cn.fujitsu.com>
---
 drivers/acpi/acpi_memhotplug.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/drivers/acpi/acpi_memhotplug.c b/drivers/acpi/acpi_memhotplug.c
index 58e4e63..431a17c 100644
--- a/drivers/acpi/acpi_memhotplug.c
+++ b/drivers/acpi/acpi_memhotplug.c
@@ -402,8 +402,9 @@ static void acpi_memory_device_notify(acpi_handle handle, u32 event, void *data)
 			printk(KERN_ERR PREFIX
 				    "Disable memory device\n");
 		/*
-		 * TBD: Invoke acpi_bus_remove to cleanup data structures
+		 * Invoke acpi_bus_remove() to remove memory device
 		 */
+		acpi_bus_remove(device, 1);
 		break;
 	default:
 		ACPI_DEBUG_PRINT((ACPI_DB_INFO,
-- 
1.7.1

^ permalink raw reply related

* [RFC PATCH 4/8] memory-hotplug: export the function acpi_bus_remove()
From: Wen Congyang @ 2012-07-20  7:11 UTC (permalink / raw)
  To: linux-mm, linux-kernel, linuxppc-dev, linux-acpi
  Cc: len.brown, Yasuaki ISIMATU, paulus, minchan.kim, kosaki.motohiro,
	rientjes, cl, akpm, liuj97
In-Reply-To: <5009038A.4090001@cn.fujitsu.com>

The function acpi_bus_remove() can remove a acpi device from acpi device.
When a acpi device is removed, we need to call this function to remove
the acpi device from acpi bus. So export this function.

CC: David Rientjes <rientjes@google.com>
CC: Jiang Liu <liuj97@gmail.com>
CC: Len Brown <len.brown@intel.com>
CC: Benjamin Herrenschmidt <benh@kernel.crashing.org>
CC: Paul Mackerras <paulus@samba.org>
CC: Christoph Lameter <cl@linux.com>
Cc: Minchan Kim <minchan.kim@gmail.com>
CC: Andrew Morton <akpm@linux-foundation.org>
CC: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
CC: Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>
Signed-off-by: Wen Congyang <wency@cn.fujitsu.com>
---
 drivers/acpi/scan.c     |    3 ++-
 include/acpi/acpi_bus.h |    1 +
 2 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index c8a1f3b..d5e8d74 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -1206,7 +1206,7 @@ static int acpi_device_set_context(struct acpi_device *device)
 	return -ENODEV;
 }
 
-static int acpi_bus_remove(struct acpi_device *dev, int rmdevice)
+int acpi_bus_remove(struct acpi_device *dev, int rmdevice)
 {
 	if (!dev)
 		return -EINVAL;
@@ -1228,6 +1228,7 @@ static int acpi_bus_remove(struct acpi_device *dev, int rmdevice)
 
 	return 0;
 }
+EXPORT_SYMBOL(acpi_bus_remove);
 
 static int acpi_add_single_object(struct acpi_device **child,
 				  acpi_handle handle, int type,
diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h
index 9e6e1c6..3eb0ba7 100644
--- a/include/acpi/acpi_bus.h
+++ b/include/acpi/acpi_bus.h
@@ -356,6 +356,7 @@ bool acpi_bus_power_manageable(acpi_handle handle);
 bool acpi_bus_can_wakeup(acpi_handle handle);
 int acpi_power_resource_register_device(struct device *dev, acpi_handle handle);
 void acpi_power_resource_unregister_device(struct device *dev, acpi_handle handle);
+int acpi_bus_remove(struct acpi_device *dev, int rmdevice);
 #ifdef CONFIG_ACPI_PROC_EVENT
 int acpi_bus_generate_proc_event(struct acpi_device *device, u8 type, int data);
 int acpi_bus_generate_proc_event4(const char *class, const char *bid, u8 type, int data);
-- 
1.7.1

^ permalink raw reply related

* [RFC PATCH 3/8] memory-hotplug: call remove_memory() to cleanup when removing memory device
From: Wen Congyang @ 2012-07-20  7:10 UTC (permalink / raw)
  To: linux-mm, linux-kernel, linuxppc-dev, linux-acpi
  Cc: len.brown, Yasuaki ISIMATU, paulus, minchan.kim, kosaki.motohiro,
	rientjes, cl, akpm, liuj97
In-Reply-To: <5009038A.4090001@cn.fujitsu.com>

We should remove the following things when removing the memory device:
1. memmap and related sysfs files
2. iomem_resource
3. mem_section and related sysfs files
4. node and related sysfs files

The function remove_memory() can do this. So call it after the memory device
is offlined.

CC: David Rientjes <rientjes@google.com>
CC: Jiang Liu <liuj97@gmail.com>
CC: Len Brown <len.brown@intel.com>
CC: Benjamin Herrenschmidt <benh@kernel.crashing.org>
CC: Paul Mackerras <paulus@samba.org>
CC: Christoph Lameter <cl@linux.com>
Cc: Minchan Kim <minchan.kim@gmail.com>
CC: Andrew Morton <akpm@linux-foundation.org>
CC: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
CC: Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>
Signed-off-by: Wen Congyang <wency@cn.fujitsu.com>
---
 drivers/acpi/acpi_memhotplug.c |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/drivers/acpi/acpi_memhotplug.c b/drivers/acpi/acpi_memhotplug.c
index 712e767..58e4e63 100644
--- a/drivers/acpi/acpi_memhotplug.c
+++ b/drivers/acpi/acpi_memhotplug.c
@@ -315,7 +315,7 @@ static int acpi_memory_disable_device(struct acpi_memory_device *mem_device)
 {
 	int result;
 	struct acpi_memory_info *info, *n;
-
+	int node = mem_device->nid;
 
 	/*
 	 * Ask the VM to offline this memory range.
@@ -330,6 +330,11 @@ static int acpi_memory_disable_device(struct acpi_memory_device *mem_device)
 				if (result)
 					return result;
 			}
+
+			result = remove_memory(node, info->start_addr,
+					       info->length);
+			if (result)
+				return result;
 		}
 		list_del(&info->list);
 		kfree(info);
-- 
1.7.1

^ permalink raw reply related

* [RFC PATCH 2/8] memory-hotplug: offline memory only when it is onlined
From: Wen Congyang @ 2012-07-20  7:10 UTC (permalink / raw)
  To: linux-mm, linux-kernel, linuxppc-dev, linux-acpi
  Cc: len.brown, Yasuaki ISIMATU, paulus, minchan.kim, kosaki.motohiro,
	rientjes, cl, akpm, liuj97
In-Reply-To: <5009038A.4090001@cn.fujitsu.com>

offline_memory() will fail if the memory is not onlined. So check
whether the memory is onlined before calling offline_memory().

CC: David Rientjes <rientjes@google.com>
CC: Jiang Liu <liuj97@gmail.com>
CC: Len Brown <len.brown@intel.com>
CC: Benjamin Herrenschmidt <benh@kernel.crashing.org>
CC: Paul Mackerras <paulus@samba.org>
CC: Christoph Lameter <cl@linux.com>
Cc: Minchan Kim <minchan.kim@gmail.com>
CC: Andrew Morton <akpm@linux-foundation.org>
CC: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
CC: Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>
Signed-off-by: Wen Congyang <wency@cn.fujitsu.com>
---
 drivers/acpi/acpi_memhotplug.c |   10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/acpi/acpi_memhotplug.c b/drivers/acpi/acpi_memhotplug.c
index db8de39..712e767 100644
--- a/drivers/acpi/acpi_memhotplug.c
+++ b/drivers/acpi/acpi_memhotplug.c
@@ -323,9 +323,13 @@ static int acpi_memory_disable_device(struct acpi_memory_device *mem_device)
 	 */
 	list_for_each_entry_safe(info, n, &mem_device->res_list, list) {
 		if (info->enabled) {
-			result = offline_memory(info->start_addr, info->length);
-			if (result)
-				return result;
+			if (!is_memblk_offline(info->start_addr,
+					       info->length)) {
+				result = offline_memory(info->start_addr,
+							info->length);
+				if (result)
+					return result;
+			}
 		}
 		list_del(&info->list);
 		kfree(info);
-- 
1.7.1

^ permalink raw reply related

* [RFC PATCH 1/8] memory-hotplug: store the node id in acpi_memory_device
From: Wen Congyang @ 2012-07-20  7:09 UTC (permalink / raw)
  To: linux-mm, linux-kernel, linuxppc-dev, linux-acpi
  Cc: len.brown, Yasuaki ISIMATU, paulus, minchan.kim, kosaki.motohiro,
	rientjes, cl, akpm, liuj97
In-Reply-To: <5009038A.4090001@cn.fujitsu.com>

The memory device has only one node id. Store the node id when
enabling the memory device, and we can reuse it when removing the
memory device.

CC: David Rientjes <rientjes@google.com>
CC: Jiang Liu <liuj97@gmail.com>
CC: Len Brown <len.brown@intel.com>
CC: Benjamin Herrenschmidt <benh@kernel.crashing.org>
CC: Paul Mackerras <paulus@samba.org>
CC: Christoph Lameter <cl@linux.com>
Cc: Minchan Kim <minchan.kim@gmail.com>
CC: Andrew Morton <akpm@linux-foundation.org>
CC: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
CC: Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>
Signed-off-by: Wen Congyang <wency@cn.fujitsu.com>
---
 drivers/acpi/acpi_memhotplug.c |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/acpi/acpi_memhotplug.c b/drivers/acpi/acpi_memhotplug.c
index 5cafd6b..db8de39 100644
--- a/drivers/acpi/acpi_memhotplug.c
+++ b/drivers/acpi/acpi_memhotplug.c
@@ -84,6 +84,7 @@ struct acpi_memory_info {
 struct acpi_memory_device {
 	struct acpi_device * device;
 	unsigned int state;	/* State of the memory device */
+	int nid;
 	struct list_head res_list;
 };
 
@@ -257,6 +258,9 @@ static int acpi_memory_enable_device(struct acpi_memory_device *mem_device)
 		info->enabled = 1;
 		num_enabled++;
 	}
+
+	mem_device->nid = node;
+
 	if (!num_enabled) {
 		printk(KERN_ERR PREFIX "add_memory failed\n");
 		mem_device->state = MEMORY_INVALID_STATE;
@@ -463,7 +467,7 @@ static int acpi_memory_device_remove(struct acpi_device *device, int type)
 
 	mem_device = acpi_driver_data(device);
 
-	node = acpi_get_node(mem_device->device->handle);
+	node = mem_device->nid;
 	list_for_each_entry_safe(info, tmp, &mem_device->res_list, list) {
 		if (!info->enabled)
 			continue;
@@ -473,8 +477,6 @@ static int acpi_memory_device_remove(struct acpi_device *device, int type)
 			if (result)
 				return result;
 		}
-		if (node < 0)
-			node = memory_add_physaddr_to_nid(info->start_addr);
 
 		result = remove_memory(node, info->start_addr, info->length);
 		if (result)
-- 
1.7.1

^ permalink raw reply related

* [PATCH 0/8] remove memory info from list before freeing it
From: Wen Congyang @ 2012-07-20  7:08 UTC (permalink / raw)
  To: linux-mm, linux-kernel, linuxppc-dev, linux-acpi
  Cc: len.brown, Yasuaki ISIMATU, paulus, minchan.kim, kosaki.motohiro,
	rientjes, cl, akpm, liuj97
In-Reply-To: <5009038A.4090001@cn.fujitsu.com>

We free info, but we forget to remove it from the list. It will cause
unexpected problem when we access the list next time.

Signed-off-by: Wen Congyang <wency@cn.fujitsu.com>
---
 drivers/acpi/acpi_memhotplug.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/drivers/acpi/acpi_memhotplug.c b/drivers/acpi/acpi_memhotplug.c
index 8fe0e02..5cafd6b 100644
--- a/drivers/acpi/acpi_memhotplug.c
+++ b/drivers/acpi/acpi_memhotplug.c
@@ -323,6 +323,7 @@ static int acpi_memory_disable_device(struct acpi_memory_device *mem_device)
 			if (result)
 				return result;
 		}
+		list_del(&info->list);
 		kfree(info);
 	}
 
-- 
1.7.1

^ permalink raw reply related

* [RFC PATCH 0/8] memory-hotplug : hot-remove physical memory(clear page table)
From: Wen Congyang @ 2012-07-20  7:06 UTC (permalink / raw)
  To: linux-mm, linux-kernel, linuxppc-dev, linux-acpi
  Cc: len.brown, Yasuaki ISIMATU, paulus, minchan.kim, kosaki.motohiro,
	rientjes, cl, akpm, liuj97

This patch series aims to support physical memory hot-remove(clear page table).

This patch series base on ishimatsu's patch series. You can get it here:
http://www.spinics.net/lists/linux-acpi/msg36804.html

The patches can remove following things:
  - page table of removed memory

If you find lack of function for physical memory hot-remove, please let me
know.

Note:
* The patch "remove memory info from list before freeing it" is being disccussed
  in other thread. But for testing the patch series, the patch is needed.
  So I added the patch as [PATCH 0/8].
* You need to apply ishimatsu's patch series first before applying this patch
  series.

Wen Congyang (8):
  memory-hotplug: store the node id in acpi_memory_device
  memory-hotplug: offline memory only when it is onlined
  memory-hotplug: call remove_memory() to cleanup when removing memory
    device
  memory-hotplug: export the function acpi_bus_remove()
  memory-hotplug: call acpi_bus_remove() to remove memory device
  memory-hotplug: introduce new function arch_remove_memory()
  x86: make __split_large_page() generally avialable
  memory-hotplug: implement arch_remove_memory()

 arch/ia64/mm/init.c                  |   16 ++++
 arch/powerpc/mm/mem.c                |   14 +++
 arch/s390/mm/init.c                  |    8 ++
 arch/sh/mm/init.c                    |   15 +++
 arch/tile/mm/init.c                  |    8 ++
 arch/x86/include/asm/pgtable_types.h |    1 +
 arch/x86/mm/init_32.c                |   10 ++
 arch/x86/mm/init_64.c                |  160 ++++++++++++++++++++++++++++++++++
 arch/x86/mm/pageattr.c               |   47 +++++-----
 drivers/acpi/acpi_memhotplug.c       |   24 ++++--
 drivers/acpi/scan.c                  |    3 +-
 include/acpi/acpi_bus.h              |    1 +
 include/linux/memory_hotplug.h       |    1 +
 mm/memory_hotplug.c                  |    2 +-
 14 files changed, 280 insertions(+), 30 deletions(-)

^ permalink raw reply

* Re: [PATCH 3/4] powerpc/crypto: add 842 hardware compression driver
From: Michael Ellerman @ 2012-07-20  5:33 UTC (permalink / raw)
  To: Seth Jennings
  Cc: Robert Jennings, Herbert Xu, linux-kernel, Paul Mackerras,
	Jeff Kirsher, Greg Kroah-Hartman, Andrew Morton, Kent Yoder,
	linuxppc-dev, David S. Miller, linux-crypto
In-Reply-To: <1342708961-28587-4-git-send-email-sjenning@linux.vnet.ibm.com>

On Thu, 2012-07-19 at 09:42 -0500, Seth Jennings wrote:
> This patch adds the driver for interacting with the 842
> compression accelerator on IBM Power7+ systems.

...

> +struct nx842_slentry {
> +	unsigned long ptr; /* Absolute address (use virt_to_abs()) */
> /+	unsigned long len;
> +};

These days virt_to_abs() is just __pa() - ie. convert to a real address.

So you should just use __pa().

And you also need to be certain that you only call it on addresses where
that makes sense, ie. not vmalloc etc.

cheers

^ permalink raw reply

* Re: [PATCH 2/2] powerpc/e6500: TLB miss handler with hardware tablewalk support
From: Scott Wood @ 2012-07-19 20:12 UTC (permalink / raw)
  To: Benjamin Herrenschmidt; +Cc: linuxppc-dev
In-Reply-To: <1339722302.9220.175.camel@pasglop>

On 06/14/2012 08:05 PM, Benjamin Herrenschmidt wrote:
> On Thu, 2012-06-14 at 18:41 -0500, Scott Wood wrote:
>>  - Like on e5500, the linear mapping is bolted, so we don't need the
>>    overhead of supporting nested tlb misses.
>>
>> Note that hardware tablewalk does not work in rev1 of e6500.
>> We do not expect to support e6500 rev1 in mainline Linux.
> 
> I'll try to review that in more details next week.... 
> 
> Ben.

ping

-Scott

^ permalink raw reply


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