LinuxPPC-Dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
* Re: suspend-to-mem on the mpc8349e-mitx-gp?
From: Scott Wood @ 2009-03-20 14:41 UTC (permalink / raw)
  To: Li Yang-R58472; +Cc: linuxppc-dev, Soohyung Cho
In-Reply-To: <3A45394FD742FA419B760BB8D398F9ED29EB95@zch01exm26.fsl.freescale.net>

Li Yang-R58472 wrote:
>> However, the code should treat "mem" as "standby" on chips 
>> that don't support deep sleep.  What does the device tree 
> 
> Well, shouldn't the valid() callback reject unsupported states instead
> of covering up?

I don't think so, in this case.  The user is not asking for "sleep" or 
deep sleep"; they are asking for a power state that meets the definition 
of "standby" (which sleep does) or which meets the definition of "mem" 
(which both sleep and deep sleep do).  When the user asks for "mem", we 
provide the lowest power mode that qualifies.

I'm willing to change it if there's substantial existing practice to the 
contrary, though.

-Scott

^ permalink raw reply

* Re: [Fwd: Re: IDE cable detection on Apple PowerBook]
From: TOMARI Hisanobu @ 2009-03-20 13:27 UTC (permalink / raw)
  To: Bartlomiej Zolnierkiewicz; +Cc: linuxppc-dev
In-Reply-To: <200903201240.30383.bzolnier@gmail.com>

On Fri, 20 Mar 2009 12:40:29 +0100
Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> wrote:

> Moreover the underlying issue is non-PMAC specific and asks for generic
> resolution, please see:
> 
> 	http://bugzilla.kernel.org/show_bug.cgi?id=12734#c13
> 
> for previous discussion.
> 
> In the very least case it should be a generic kernel parameter, i.e.
> "ide_core.ignore_cables" and iff the current "ide_core.ignore_cable="
> is not enough.  TOMARI, could please look into it?
> 
> Thanks,
> Bart

It works!
As the internal IDE controller is detected as ide0, I passed
"ide_core.ignore_cable=0" to the kernel, and the drive works in
UDMA/100 mode.
This method seems much cleaner way to solve the problem.
Thank you, Bart, Ben and Anton.

% dmesg |grep hda
Kernel command line: root=/dev/hda4 ro ide_core.ignore_cable=0 
hda: CORE_PATA, ATA DISK drive
hda: host max PIO4 wanted PIO255(auto-tune) selected PIO4
hda: UDMA/100 mode selected
hda: max request size: 512KiB
hda: 252411904 sectors (129234 MB), CHS=16383/255/63
hda: cache flushes supported
 hda: [mac] hda1 hda2 hda3 hda4 hda5 hda6 hda7
XFS mounting filesystem hda4
Ending clean XFS mount for filesystem: hda4
Adding 846672k swap on /dev/hda5.  Priority:-1 extents:1 across:846672k

-- 
TOMARI Hisanobu <posco.grubb@gmail.com>

^ permalink raw reply

* Re: Problem with radeonfb on PowerPC 7448&MV64560
From: Detlev Zundel @ 2009-03-20 10:51 UTC (permalink / raw)
  To: linuxppc-dev
In-Reply-To: <200903191051.37875.edfuchs__31387.3780928136$1237456433$gmane$org@uni-kassel.de>

Hi Eduard,

> Am Mittwoch 18 März 2009 00:05:00 schrieb Benjamin Herrenschmidt:
>> On Tue, 2009-03-17 at 16:30 +0100, Eduard Fuchs wrote:
>> > Hi all,
>> >
>> > since several days I'm trying to run an ATI 9250 (PCI) graphic card under
>> > Linux Kernel 2.6.27.19. Nevertheless without success. The kernel shows
>> > the following message:
>> >
>> > videoboot: Booting PCI video card bus 0, function 0, device 7
>> > biosEmu: undefined interrupt 15h called!
>> > biosEmu/bios.int42: unknown function AH=0x0, AL=0x7, BL=0x0
>>
>> The above comes from some patches you added to the kernel ? You should
>> probably do the softboot in the firmware instead...
>
> Yes. I'm using the videoboot-2.6x.patch (this patch contain also the xf86emu 
> from www.scitechsoft.com). With this pach the radeon card work properly with 
> 2.6.12 kernel version. On the 2.6.27 kernel the "videoboot" fetch the bios 
> from the video card and start them in the xf86emu.
>
> Can I initialize the video card in uboot too?

Yes, indeed you can.  In a recent version of U-Boot, search for
'CONFIG_BIOSEMU' in include/configs/*.  We tested this on a sequoia
board, so include/configs/sequoia.h should be a good start for this.

Cheers
  Detlev

--
DENX Software Engineering GmbH,      MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich,  Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-40 Fax: (+49)-8142-66989-80 Email: dzu@denx.de

^ permalink raw reply

* Re: powerpc/85xx: Add support for the "socrates" board (MPC8544)
From: Wolfgang Grandegger @ 2009-03-20 11:57 UTC (permalink / raw)
  To: Grant Likely; +Cc: linuxppc-dev
In-Reply-To: <fa686aa40903192205yed7eb13t45db80a201549f0d@mail.gmail.com>

Grant Likely wrote:
> I agree 100% with David's comments, and I have some additional ones below.

OK.

> On Thu, Mar 19, 2009 at 9:26 AM, Wolfgang Grandegger <wg@grandegger.com> wrote:
>> +       soc8544@e0000000 {
>> +               #address-cells = <1>;
>> +               #size-cells = <1>;
>> +               device_type = "soc";
> 
> Drop device_type here too.
> 
>> +
>> +               ranges = <0x00000000 0xe0000000 0x00100000>;
>> +               reg = <0xe0000000 0x00001000>;  // CCSRBAR 1M
>> +               bus-frequency = <0>;            // Filled in by U-Boot
>> +               compatible = "fsl,socrates-immr", "simple-bus";
> 
> As David said, fix this to be SoC specific, not board specific.
> 
>> +       localbus {
>> +               compatible = "fsl,socrates-localbus",
>> +                            "fsl,mpc85xx-localbus",
>> +                            "fsl,pq3-localbus";
> 
> 1st entry shouldn't be there.
> 2nd entry should specify exact chip
> 3rd entry I don't like much, but others may debate me on it
> Also, add "simple-bus" to this list.  (important for a later comment)

OK.

> 
>> +               #address-cells = <2>;
>> +               #size-cells = <1>;
>> +               reg = <0xe0005000 0x40>;
>> +
>> +               ranges = <0 0 0xfc000000 0x04000000
>> +                         2 0 0xc8000000 0x04000000
>> +                         3 0 0xc0000000 0x00100000
>> +                       >; /* Overwritten by U-Boot */
> 
> Just curious, why is U-Boot overwriting the ranges property?

Because there are boards without FPGA or graphic controller on the local
bus.

>> +               fpga_pic: fpga-pic@3,10 {
>> +                       compatible = "abb,socrates-fpga-pic";
> 
> Is 'abb' the companies' stock ticker symbol?  If not, then use the
> real name and not an abbreviation.

Yes.

>> Index: linux-2.6/arch/powerpc/boot/wrapper
>> ===================================================================
>> --- linux-2.6.orig/arch/powerpc/boot/wrapper
>> +++ linux-2.6/arch/powerpc/boot/wrapper
>> @@ -183,7 +183,7 @@ cuboot*)
>>     *-tqm8541|*-mpc8560*|*-tqm8560|*-tqm8555|*-ksi8560*)
>>         platformo=$object/cuboot-85xx-cpm2.o
>>         ;;
>> -    *-mpc85*|*-tqm85*|*-sbc85*)
>> +    *-mpc85*|*-tqm85*|*-sbc85*|*-socrates)
>>         platformo=$object/cuboot-85xx.o
>>         ;;
> 
> Is this a new or old platform?  Can U-Boot on the board boot with a
> uImage + dtb instead of a cuImage?  I'd prefer to avoid adding new
> cuImages to the wrapper script if at all possible.

It's a new platform. Therefore I will drop cuboot support.

>> Index: linux-2.6/arch/powerpc/configs/85xx/socrates_defconfig
>> ===================================================================
>> --- /dev/null
>> +++ linux-2.6/arch/powerpc/configs/85xx/socrates_defconfig
> 
> Is a socrates-specific defconfig really warranted?
> 
>> --- linux-2.6.orig/arch/powerpc/platforms/85xx/Makefile
>> +++ linux-2.6/arch/powerpc/platforms/85xx/Makefile
>> @@ -13,4 +13,6 @@ obj-$(CONFIG_STX_GP3)   += stx_gp3.o
>>  obj-$(CONFIG_TQM85xx)    += tqm85xx.o
>>  obj-$(CONFIG_SBC8560)     += sbc8560.o
>>  obj-$(CONFIG_SBC8548)     += sbc8548.o
>> +obj-$(CONFIG_SOCRATES)    += socrates.o
>> +obj-$(CONFIG_SOCRATES)    += socrates_fpga_pic.o
> 
> The pic stuff isn't all that big.  Personally I'd roll it all into the
> socrates.c file.

Well,

  $ wc -l socrates_fpga_pic.c
  156 socrates.c
  320 socrates_fpga_pic.c

Personally, I'd prefer to separate the pic from the board init code,
especially with that size.

>> --- /dev/null
>> +++ linux-2.6/arch/powerpc/platforms/85xx/socrates.c
>> +static void __init socrates_pic_init(void)
>> +{
>> +       struct mpic *mpic;
>> +       struct resource r;
>> +       struct device_node *np;
>> +
>> +       np = of_find_node_by_type(NULL, "open-pic");
>> +       if (!np) {
>> +               printk(KERN_ERR "Could not find open-pic node\n");
>> +               return;
>> +       }
>> +
>> +       if (of_address_to_resource(np, 0, &r)) {
>> +               printk(KERN_ERR "Could not map mpic register space\n");
>> +               of_node_put(np);
>> +               return;
>> +       }
>> +
>> +       mpic = mpic_alloc(np, r.start,
>> +                       MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
>> +                       0, 256, " OpenPIC  ");
>> +       BUG_ON(mpic == NULL);
>> +       of_node_put(np);
>> +
>> +       mpic_init(mpic);
> 
> Heh, this is a block of code cloned between all the 85xx boards it
> seems.  Smells like a small refactoring candidate.  This isn't really
> a critique of this patch, but I noticed it so I thought I'd mention
> it.
> 
>> +static void socrates_show_cpuinfo(struct seq_file *m)
>> +{
>> +       uint pvid, svid, phid1;
>> +       uint memsize = total_memory;
>> +
>> +       pvid = mfspr(SPRN_PVR);
>> +       svid = mfspr(SPRN_SVR);
>> +
>> +       seq_printf(m, "PVR\t\t: 0x%x\n", pvid);
>> +       seq_printf(m, "SVR\t\t: 0x%x\n", svid);
>> +
>> +       /* Display cpu Pll setting */
>> +       phid1 = mfspr(SPRN_HID1);
>> +       seq_printf(m, "PLL setting\t: 0x%x\n", ((phid1 >> 24) & 0x3f));
>> +
>> +       /* Display the amount of memory */
>> +       seq_printf(m, "Memory\t\t: %d MB\n", memsize / (1024 * 1024));
>> +}
> 
> Another block of duplicated code.  In fact, many platforms have
> dropped the cpuinfo hook entirely and just use the default output.

I can drop it for this board as well, no problem.

>> +
>> +static struct of_device_id __initdata of_bus_ids[] = {
>> +       { .name = "soc", },
>> +       { .type = "soc", },
>> +       { .name = "localbus", },
> 
> Drop these three lines.  It is considered bad form now to bind on
> either name or type for flattened device trees.  Instead add one {
> .compatible = "simple-bus", }, entry and make sure the immr and
> localbus nodes include "simple-bus" in the compatible string.
> 
>> +       {},
>> +};
>> +
>> +static int __init declare_of_platform_devices(void)
>> +{
>> +       of_platform_bus_probe(NULL, of_bus_ids, NULL);
>> +
>> +       return 0;
>> +}
>> +machine_device_initcall(socrates, declare_of_platform_devices);
> 
> Don't add an initcall for this.  Instead assign
> declar_of_platform_devices to the .init member of in the
> define_machine() block below.

OK.

>> Index: linux-2.6/arch/powerpc/platforms/85xx/socrates_fpga_pic.c
>> ===================================================================
>> --- /dev/null
>> +++ linux-2.6/arch/powerpc/platforms/85xx/socrates_fpga_pic.c
>> @@ -0,0 +1,320 @@
>> +/*
>> + *  Copyright (C) 2008 Ilya Yanok, Emcraft Systems
>> + *
>> + *
>> + * This program 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 <linux/irq.h>
>> +#include <linux/of_platform.h>
>> +#include <linux/io.h>
>> +
>> +#define SOCRATES_FPGA_NUM_IRQS 9
>> +
>> +#define FPGA_PIC_IRQCFG                (0x0)
>> +#define FPGA_PIC_IRQMASK(n)    (0x4 + 0x4 * (n))
>> +
>> +#define SOCRATES_FPGA_IRQ_MASK ((1 << SOCRATES_FPGA_NUM_IRQS) - 1)
>> +
>> +struct socrates_fpga_irq_info {
>> +       unsigned int irq_line;
>> +       int type;
>> +};
>> +
>> +/*
>> + * Interrupt routing and type table
>> + *
>> + * IRQ_TYPE_NONE means the interrupt type is configurable,
>> + * otherwise it's fixed to the specified value.
>> + */
>> +static struct socrates_fpga_irq_info fpga_irqs[SOCRATES_FPGA_NUM_IRQS] = {
>> +       [0] = {0, IRQ_TYPE_NONE},
>> +       [1] = {0, IRQ_TYPE_LEVEL_HIGH},
>> +       [2] = {0, IRQ_TYPE_LEVEL_LOW},
>> +       [3] = {0, IRQ_TYPE_NONE},
>> +       [4] = {0, IRQ_TYPE_NONE},
>> +       [5] = {0, IRQ_TYPE_NONE},
>> +       [6] = {0, IRQ_TYPE_NONE},
>> +       [7] = {0, IRQ_TYPE_NONE},
>> +       [8] = {0, IRQ_TYPE_LEVEL_HIGH},
>> +};
>> +
>> +#define socrates_fpga_irq_to_hw(virq)    ((unsigned int)irq_map[virq].hwirq)
>> +
>> +static DEFINE_SPINLOCK(socrates_fpga_pic_lock);
>> +
>> +static void __iomem *socrates_fpga_pic_iobase;
>> +static struct irq_host *socrates_fpga_pic_irq_host;
>> +static unsigned int socrates_fpga_irqs[3];
>> +
>> +static inline uint32_t socrates_fpga_pic_read(int reg)
>> +{
>> +       return in_be32(socrates_fpga_pic_iobase + reg);
>> +}
>> +
>> +static inline void socrates_fpga_pic_write(int reg, uint32_t val)
>> +{
>> +       out_be32(socrates_fpga_pic_iobase + reg, val);
>> +}
>> +
>> +static inline unsigned int socrates_fpga_pic_get_irq(unsigned int irq)
>> +{
>> +       uint32_t cause;
>> +       unsigned long flags;
>> +       int i;
>> +
>> +       for (i = 0; i < 3; i++) {
>> +               if (irq == socrates_fpga_irqs[i])
>> +                       break;
>> +       }
>> +       if (i == 3)
>> +               return NO_IRQ;
> 
> This is interesting.  What does it mean?  It would be helpful to have
> a theory of operation blurb in this file for stuff like this..

Just three interrupt lines are routed to the MPIC. A BUG_ON would be
more appropriate, though.

>> +static int socrates_fpga_pic_host_xlate(struct irq_host *h,
>> +               struct device_node *ct, u32 *intspec, unsigned int intsize,
>> +               irq_hw_number_t *out_hwirq, unsigned int *out_flags)
>> +{
>> +       struct socrates_fpga_irq_info *fpga_irq = &fpga_irqs[intspec[0]];
>> +
>> +       *out_hwirq = intspec[0];
>> +       if  (fpga_irq->type == IRQ_TYPE_NONE) {
>> +               /* type is configurable */
>> +               if (intspec[1] != IRQ_TYPE_LEVEL_LOW &&
>> +                   intspec[1] != IRQ_TYPE_LEVEL_HIGH) {
>> +                       printk(KERN_WARNING "FPGA PIC: invalid irq type, "
>> +                              "setting default active low\n");
> 
> Nit: pr_warn() perhaps?  And same through the rest of the file.

Yep, will fix the not commented issues as well.

Wolfgang.

^ permalink raw reply

* Re: [PATCH v2] powerpc: Add support for CoreInt delivery of interrupts on MPIC
From: Kumar Gala @ 2009-03-20 11:47 UTC (permalink / raw)
  To: Benjamin Herrenschmidt; +Cc: linuxppc-dev
In-Reply-To: <1237528109.25062.568.camel@pasglop>


On Mar 20, 2009, at 12:48 AM, Benjamin Herrenschmidt wrote:

> On Wed, 2009-03-11 at 10:18 -0500, Kumar Gala wrote:
>> CoreInt provides a mechansim to deliver the IRQ vector directly
>> into the core on an interrupt (via the SPR EPR) rather than having
>> to go IACK on the PIC.  This is suppose to provide an improvment
>> in interrupt latency by reducing the time to get the IRQ vector.
>>
>> Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
>> ---
>> * Fixed MPIC_GREG_GCONF_COREINT flag to be 0x60000000 as per spec  
>> and pointed about by Dave
>
> Are you sure ? That's 2 bits ...

Yeah.  We expanded the mode field to two bits (mask would be 0x60000000)

0x00 = pass through (interrupts routed to IRQ0)
0x01 = Mixed mode
0x10 = reserved
0x11 = External proxy / coreint

- k

^ permalink raw reply

* Re: Xilinx cygwin linux cross recommendations ?
From: Gary Thomas @ 2009-03-20 11:17 UTC (permalink / raw)
  To: dhlii; +Cc: linuxppc-dev
In-Reply-To: <49C2EA49.90907@dlasys.net>

David H. Lynch Jr. wrote:
>     I have no experience with ELDK.
>     Have you used it ? Do you like it ?
> 
>     When I started I mostly did a roll my own environment using crosstool.
>     I would have stuck to that except I can not get uclibc and it has
> not been updated in a long time.
>     Crosstool-ng did not support the ppc last time I looked.

Look again - PowerPC is quite well supported by CrossTool-ng

>     Today I use buildroot - mostly just to build a toolchain - I have
> never been able to get it to do many of the other things it is capable of.
> 
>     I am not particularly fond (serious understatement)  of "integrated
> solve all the problems of the world" environments, they rarely work, and
> you must think inside their box.
>    
>     I would be ecstatic with just a cygwin-linux-ppc-uclibc tool chain.
> 

Why not just skip the torture (CygWin) and just run a virtual machine
on Windows [I assume you _have_ to have Windows].  Both VM-Ware and VirtualBox
handle this problem beautifully.  Then you have *Linux* for your development
environment, not some cobbled set of pieces...

> 
> Grant Likely wrote:
>> On Thu, Mar 19, 2009 at 5:59 PM, David H. Lynch Jr. <dhlii@dlasys.net> wrote:
>>   
>>>    Does anyone have experience sugestions for building ppc/linux apps
>>> or even ppc kernels under windows.
>>>     
>> I hear rumors that there is a Windows version of ELDK.
>>
>>   
> 
> 


-- 
------------------------------------------------------------
Gary Thomas                 |  Consulting for the
MLB Associates              |    Embedded world
------------------------------------------------------------

^ permalink raw reply

* Re: [RFC][PATCH -tip 4/9] power: add kernel_trap_sp()
From: Masami Hiramatsu @ 2009-03-20 10:53 UTC (permalink / raw)
  To: ananth; +Cc: LKML, Steven Rostedt, linuxppc-dev, systemtap-ml, Ingo Molnar
In-Reply-To: <20090320073334.GA10519@in.ibm.com>

Ananth N Mavinakayanahalli wrote:
> On Fri, Mar 20, 2009 at 04:42:40PM +1100, Benjamin Herrenschmidt wrote:
>> On Thu, 2009-03-19 at 17:10 -0400, Masami Hiramatsu wrote:
>>> Add kernel_trap_sp() on powerpc, based on systemtap's runtime/regs.h.
>>>
>>> Signed-off-by: Masami Hiramatsu <mhiramat@redhat.com>
>> I haven't looked at the usage of it, but it's weird to have something
>> call "kernel_trap_sp" that returns the -user- stack pointer... is
>> this really what's expected here ?
> 
> In the current usage scenario, this gets called only with a pt_regs
> snapshot from in kernel. user_stack_pointer() is a misnomer though;
> all this macro needs is to return the stack pointer from the given
> pt_regs.

Indeed,
I expect kernel_trap_sp() returns the top of stack from pt_regs in the kernel.
Why I'm using user_stack_pointer() for kernel_trap_sp() is just that the
definitions of both are same...

Perhaps, should I define as below, even it is same as user_stack_pointer()?
#define kernel_trap_sp(regs) ((regs)->gpr[1])

Thank you,

> 
> Ananth
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/

-- 
Masami Hiramatsu

Software Engineer
Hitachi Computer Products (America) Inc.
Software Solutions Division

e-mail: mhiramat@redhat.com

^ permalink raw reply

* Re: [PATCH 4/4] powerpc/86xx: Move gianfar mdio nodes under the ethernet nodes
From: Martyn Welch @ 2009-03-20  9:38 UTC (permalink / raw)
  To: Anton Vorontsov; +Cc: Scott Wood, linuxppc-dev, Li Yang
In-Reply-To: <20090319180151.GD6114@oksana.dev.rtsoft.ru>

Anton Vorontsov wrote:
> Currently it doesn't matter where the mdio nodes are placed, but with
> power management support (i.e. when sleep = <> properties will take
> effect), mdio nodes placement will become important: mdio controller
> is a part of the ethernet block, so the mdio nodes should be placed
> correctly. Otherwise we may wrongly assume that MDIO controllers are
> available during sleep.
> 
> Suggested-by: Scott Wood <scottwood@freescale.com>
> Suggested-by: Kumar Gala <galak@kernel.crashing.org>
> Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com>
> ---
>  arch/powerpc/boot/dts/gef_ppc9a.dts        |   39 ++++---
>  arch/powerpc/boot/dts/gef_sbc310.dts       |   39 ++++---
>  arch/powerpc/boot/dts/gef_sbc610.dts       |   39 ++++---
>  arch/powerpc/boot/dts/mpc8641_hpcn.dts     |  157 +++++++++++++++-------------
>  arch/powerpc/boot/dts/sbc8641d.dts         |  156 +++++++++++++++-------------
>  arch/powerpc/platforms/86xx/gef_ppc9a.c    |    1 +
>  arch/powerpc/platforms/86xx/gef_sbc310.c   |    1 +
>  arch/powerpc/platforms/86xx/gef_sbc610.c   |    1 +
>  arch/powerpc/platforms/86xx/mpc8610_hpcd.c |    1 +
>  arch/powerpc/platforms/86xx/mpc86xx_hpcn.c |    1 +
>  arch/powerpc/platforms/86xx/sbc8641d.c     |    1 +
>  11 files changed, 237 insertions(+), 199 deletions(-)
> 

Tested on ppc9a. Other GE Fanuc boards look sane.

Tested-by: Martyn Welch <martyn.welch@gefanuc.com>

Martyn

-- 
Martyn Welch MEng MPhil MIET (Principal Software Engineer)   T:+44(0)1327322748
GE Fanuc Intelligent Platforms Ltd,        |Registered in England and Wales
Tove Valley Business Park, Towcester,      |(3828642) at 100 Barbirolli Square,
Northants, NN12 6PF, UK T:+44(0)1327359444 |Manchester,M2 3AB  VAT:GB 729849476

^ permalink raw reply

* AW: spidev.c driver on the ppc8247 (kernel 2.6.27.19)
From: Stepanov, Sergej @ 2009-03-20  9:37 UTC (permalink / raw)
  To: Daniel Ng; +Cc: linuxppc-dev@ozlabs.org
In-Reply-To: <547eba1b0903191819v5b03d38ci7a60839873e5bd66@mail.gmail.com>

Hi Daniel,

sorry, my example was incomplete...

for a fast you can add in your platform file something like this:

..........................
#ifdef CONFIG_SPI_IDS8247
#include <linux/spi/spi.h>
#include <linux/spi/mmc_spi.h>
#include <linux/mmc/host.h>
#endif
........

#ifdef CONFIG_SPI_IDS8247

#define GPIO_CS (224+22)
static void ids8247_spi_activate_cs(u8 cs, u8 polarity)
{
	pr_debug("%s %d %d\n", __func__, cs, polarity);
	//gpio_set_value(GPIO_CS, (int)polarity);
}

static void ids8247_spi_deactivate_cs(u8 cs, u8 polarity)
{
	pr_debug("%s %d %d\n", __func__, cs, polarity);
	//gpio_set_value(GPIO_CS, (int)(!polarity));
}

static struct mmc_spi_platform_data ids8247_mmc_pdata =3D {
	.ocr_mask =3D MMC_VDD_32_33,
};

static struct spi_board_info ids8247_spi_boardinfo =3D {
	.bus_num =3D 0,
	.chip_select =3D 0,
	.max_speed_hz =3D 20000000,
	.modalias =3D "mmc_spi",
	.platform_data =3D &ids8247_mmc_pdata,
};
static __init int ids8247_spi_setup(void)
{
	int ret =3D 0;
	struct platform_device *spi_dev;
	struct resource r[3];
	struct device_node *np =3D NULL;
	struct fsl_spi_platform_data spi_data;

	/*if (!gpio_get_value(GPIO_CS))
		return;
	*/
	if( (np =3D of_find_compatible_node(NULL, "spi", "platform-mapped")) =3D=
=3D0 )
		return 0;

	//fsl_get_sys_freq();
	memset(&spi_data, 0, sizeof(struct fsl_spi_platform_data));
	spi_data.activate_cs =3D ids8247_spi_activate_cs;
	spi_data.deactivate_cs =3D ids8247_spi_deactivate_cs;
	spi_data.bus_num =3D 0;
	spi_data.max_chipselect =3D 1;
	memset(r, 0, sizeof(struct resource)*3);

	ret =3D of_address_to_resource(np, 0, &r[0]);
	if (ret)
		goto spi_err;

	ret =3D of_address_to_resource(np, 1, &r[1]);
	if (ret)
		goto spi_err;

	ret =3D of_irq_to_resource(np, 0, &r[2]);
	if (ret =3D=3D NO_IRQ)
		goto spi_err;

	spi_data.qe_mode =3D 0;
	spi_data.sysclk =3D 24750000;

	spi_dev =3D platform_device_register_simple("ids8247_spi", 0, &r[0], 3);
	if (IS_ERR(spi_dev)) {
		ret =3D PTR_ERR(spi_dev);
		return ret;
	}
	ret =3D platform_device_add_data(spi_dev,
				       &spi_data,
				       sizeof(struct fsl_spi_platform_data));
	if(ret) {
		platform_device_unregister(spi_dev);
		return ret;
	}
	of_node_put(np);
	return spi_register_board_info(&ids8247_spi_boardinfo, 1);
spi_err:
	of_node_put(np);
	return -1;
}
arch_initcall(ids8247_spi_setup);
#endif /* CONFIG_SPI_IDS8247 */
..........

Sorry, i know it looks very dirty...

Regards
Sergej.

________________________________________
Von: Daniel Ng [daniel.ng1234@gmail.com]
Gesendet: Freitag, 20. M=E4rz 2009 02:19
An: Stepanov, Sergej
Cc: linuxppc-dev@ozlabs.org
Betreff: Re: spidev.c driver on the ppc8247 (kernel 2.6.27.19)

On Thu, Mar 19, 2009 at 7:32 PM, Daniel Ng <daniel.ng1234@gmail.com> wrote:
>
> So, I tried to call spidev_probe() directly from the probe() function
> of my SPI Controller driver. However in this case spidev_probe()
> failed because its call to device_create_drvdata() failed with error
> code ENODEV. Why would this be?
>
> This is how I make the call from my SPI Controller driver:
>
> spidev_probe(to_spi_device(&ofdev->dev));
>
> And this is the relevant code in spidev_probe():
>
> dev =3D device_create_drvdata(spidev_class, &spi->dev, spidev->devt,
> spidev, "spidev%d.%d",
>                               /*spi->master->bus_num*/0, spi->chip_select=
);

It looks like spidev_class was uninitialised because spidev_init() had
not yet been called. To force spidev_init() to be called before my SPI
Controller's driver initialisation, I just used:

subsys_initcall(spidev_init);

This seems to do the job...

^ permalink raw reply

* Re: [PATCH 2/6] powerpc/mm: Merge various PTE bits and accessors definitions (v3)
From: Benjamin Herrenschmidt @ 2009-03-20  9:11 UTC (permalink / raw)
  To: linuxppc-dev
In-Reply-To: <20090320053428.E643EDDF03@ozlabs.org>

On Fri, 2009-03-20 at 16:34 +1100, Benjamin Herrenschmidt wrote:

> Index: linux-work/arch/powerpc/include/asm/pgtable-ppc64.h
> ===================================================================
> --- linux-work.orig/arch/powerpc/include/asm/pgtable-ppc64.h	2009-03-20 15:49:51.000000000 +1100
> +++ linux-work/arch/powerpc/include/asm/pgtable-ppc64.h	2009-03-20 15:52:59.000000000 +1100
> @@ -80,82 +80,8 @@
>   * Include the PTE bits definitions
>   */
>  #include <asm/pte-hash64.h>
> +#include <asm/pte-common.h
                             ^

The one I committed to "test" doesn't have that obvious typo :-)

Cheers,
Ben.
 

^ permalink raw reply

* Re: [PATCH v2 3/3] powerpc: expect all devices calling dma ops to have archdata set
From: Benjamin Krill @ 2009-03-20  7:38 UTC (permalink / raw)
  To: Kumar Gala; +Cc: linuxppc-dev, Becky Bruce
In-Reply-To: <1237470052-4071-3-git-send-email-galak@kernel.crashing.org>

* Kumar Gala | 2009-03-19 08:40:52 [-0500]:

>Now that we set archdata for of_platform and platform devices via
>platform_notify() we no longer need to special case having a NULL device
>pointer or NULL archdata.  It should be a driver error if this condition
>shows up and the driver should be fixed.
>
>Signed-off-by: Kumar Gala <galak@kernel.crashing.org>

Acked-by: Benjamin Krill <ben@codiert.org>

Tested on QPACE node card.

^ permalink raw reply

* Re: [PATCH v2 2/3] powerpc: setup default archdata for {of_}platform via bus_register_notifier
From: Benjamin Krill @ 2009-03-20  7:37 UTC (permalink / raw)
  To: Kumar Gala; +Cc: linuxppc-dev, Becky Bruce
In-Reply-To: <1237470052-4071-2-git-send-email-galak@kernel.crashing.org>

* Kumar Gala | 2009-03-19 08:40:51 [-0500]:

>Since a number of powerpc chips are SoCs we end up having dma-able
>devices that are registered as platform or of_platform devices.  We need
>to hook the archdata to setup proper dma_ops for these devices.
>
>Rather than having to add a bus_notify to each platform we add a default
>one at the highest priority (called first) to set the default dma_ops for
>of_platform and platform devices to dma_direct_ops.  This allows platform
>code to override the ops by providing their own notifier call back.
>
>In the future to enable >4G DMA support on ppc32 we can hook swiotlb ops.
>
>Signed-off-by: Kumar Gala <galak@kernel.crashing.org>

Acked-by: Benjamin Krill <ben@codiert.org>

Tested on QPACE node card.

^ permalink raw reply

* Re: [PATCH v2 1/3] powerpc/pci: Default to dma_direct_ops for pci dma_ops
From: Benjamin Krill @ 2009-03-20  7:37 UTC (permalink / raw)
  To: Kumar Gala; +Cc: linuxppc-dev, Becky Bruce
In-Reply-To: <1237470052-4071-1-git-send-email-galak@kernel.crashing.org>

* Kumar Gala | 2009-03-19 08:40:50 [-0500]:

>This will allow us to remove the ppc32 specific checks in get_dma_ops()
>that defaults to dma_direct_ops if the archdata is NULL.  We really
>should always have archdata set to something going forward.
>
>Signed-off-by: Kumar Gala <galak@kernel.crashing.org>

Acked-by: Benjamin Krill <ben@codiert.org>

Tested on QPACE node card.

^ permalink raw reply

* Re: [RFC][PATCH -tip 4/9] power: add kernel_trap_sp()
From: Ananth N Mavinakayanahalli @ 2009-03-20  7:33 UTC (permalink / raw)
  To: Benjamin Herrenschmidt
  Cc: LKML, Steven Rostedt, linuxppc-dev, systemtap-ml, Ingo Molnar,
	Masami Hiramatsu
In-Reply-To: <1237527760.25062.567.camel@pasglop>

On Fri, Mar 20, 2009 at 04:42:40PM +1100, Benjamin Herrenschmidt wrote:
> On Thu, 2009-03-19 at 17:10 -0400, Masami Hiramatsu wrote:
> > Add kernel_trap_sp() on powerpc, based on systemtap's runtime/regs.h.
> > 
> > Signed-off-by: Masami Hiramatsu <mhiramat@redhat.com>
> 
> I haven't looked at the usage of it, but it's weird to have something
> call "kernel_trap_sp" that returns the -user- stack pointer... is
> this really what's expected here ?

In the current usage scenario, this gets called only with a pt_regs
snapshot from in kernel. user_stack_pointer() is a misnomer though;
all this macro needs is to return the stack pointer from the given
pt_regs.

Ananth

^ permalink raw reply

* Re: [PATCH] cpumask: use mm_cpumask() wrapper: powerpc
From: Benjamin Herrenschmidt @ 2009-03-20  6:36 UTC (permalink / raw)
  To: Rusty Russell; +Cc: linuxppc-dev, Paul Mackerras
In-Reply-To: <200903161446.43726.rusty@rustcorp.com.au>

On Mon, 2009-03-16 at 14:46 +1030, Rusty Russell wrote:
> Makes code futureproof against the impending change to mm->cpu_vm_mask.
> 
> It's also a chance to use the new cpumask_ ops which take a pointer
> (the older ones are deprecated, but there's no hurry for arch code).

Boom :-)

In file included from /home/benh/linux-powerpc-test/arch/powerpc/kernel/vdso.c:30:
/home/benh/linux-powerpc-test/arch/powerpc/include/asm/mmu_context.h: In function ‘switch_mm’:
/home/benh/linux-powerpc-test/arch/powerpc/include/asm/mmu_context.h:34: error: implicit declaration of function ‘mm_cpumask’
/home/benh/linux-powerpc-test/arch/powerpc/include/asm/mmu_context.h:34: warning: passing argument 2 of ‘cpumask_set_cpu’ makes pointer from integer without a cast

> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
> ---
>  arch/powerpc/include/asm/mmu_context.h |    2 +-
>  arch/powerpc/mm/hash_utils_64.c        |   10 ++++------
>  arch/powerpc/mm/mmu_context_nohash.c   |    2 +-
>  arch/powerpc/mm/pgtable.c              |    3 +--
>  arch/powerpc/mm/tlb_hash64.c           |    6 +++---
>  arch/powerpc/mm/tlb_nohash.c           |   18 +++++++++---------
>  arch/powerpc/platforms/cell/spu_base.c |    2 +-
>  7 files changed, 20 insertions(+), 23 deletions(-)
> 
> diff --git a/arch/powerpc/include/asm/mmu_context.h b/arch/powerpc/include/asm/mmu_context.h
> --- a/arch/powerpc/include/asm/mmu_context.h
> +++ b/arch/powerpc/include/asm/mmu_context.h
> @@ -31,7 +31,7 @@ static inline void switch_mm(struct mm_s
>  			     struct task_struct *tsk)
>  {
>  	/* Mark this context has been used on the new CPU */
> -	cpu_set(smp_processor_id(), next->cpu_vm_mask);
> +	cpumask_set_cpu(smp_processor_id(), mm_cpumask(next));
>  
>  	/* 32-bit keeps track of the current PGDIR in the thread struct */
>  #ifdef CONFIG_PPC32
> diff --git a/arch/powerpc/mm/hash_utils_64.c b/arch/powerpc/mm/hash_utils_64.c
> --- a/arch/powerpc/mm/hash_utils_64.c
> +++ b/arch/powerpc/mm/hash_utils_64.c
> @@ -858,7 +858,7 @@ int hash_page(unsigned long ea, unsigned
>  	unsigned long vsid;
>  	struct mm_struct *mm;
>  	pte_t *ptep;
> -	cpumask_t tmp;
> +	const struct cpumask *tmp;
>  	int rc, user_region = 0, local = 0;
>  	int psize, ssize;
>  
> @@ -906,8 +906,8 @@ int hash_page(unsigned long ea, unsigned
>  		return 1;
>  
>  	/* Check CPU locality */
> -	tmp = cpumask_of_cpu(smp_processor_id());
> -	if (user_region && cpus_equal(mm->cpu_vm_mask, tmp))
> +	tmp = cpumask_of(smp_processor_id());
> +	if (user_region && cpumask_equal(mm_cpumask(mm), tmp))
>  		local = 1;
>  
>  #ifdef CONFIG_HUGETLB_PAGE
> @@ -1023,7 +1023,6 @@ void hash_preload(struct mm_struct *mm, 
>  	unsigned long vsid;
>  	void *pgdir;
>  	pte_t *ptep;
> -	cpumask_t mask;
>  	unsigned long flags;
>  	int local = 0;
>  	int ssize;
> @@ -1066,8 +1065,7 @@ void hash_preload(struct mm_struct *mm, 
>  	local_irq_save(flags);
>  
>  	/* Is that local to this CPU ? */
> -	mask = cpumask_of_cpu(smp_processor_id());
> -	if (cpus_equal(mm->cpu_vm_mask, mask))
> +	if (cpumask_equal(mm_cpumask(mm), cpumask_of(smp_processor_id())))
>  		local = 1;
>  
>  	/* Hash it in */
> diff --git a/arch/powerpc/mm/mmu_context_nohash.c b/arch/powerpc/mm/mmu_context_nohash.c
> --- a/arch/powerpc/mm/mmu_context_nohash.c
> +++ b/arch/powerpc/mm/mmu_context_nohash.c
> @@ -97,7 +97,7 @@ static unsigned int steal_context_smp(un
>  		mm->context.id = MMU_NO_CONTEXT;
>  
>  		/* Mark it stale on all CPUs that used this mm */
> -		for_each_cpu_mask_nr(cpu, mm->cpu_vm_mask)
> +		for_each_cpu(cpu, mm_cpumask(mm))
>  			__set_bit(id, stale_map[cpu]);
>  		return id;
>  	}
> diff --git a/arch/powerpc/mm/pgtable.c b/arch/powerpc/mm/pgtable.c
> --- a/arch/powerpc/mm/pgtable.c
> +++ b/arch/powerpc/mm/pgtable.c
> @@ -81,11 +81,10 @@ void pgtable_free_tlb(struct mmu_gather 
>  void pgtable_free_tlb(struct mmu_gather *tlb, pgtable_free_t pgf)
>  {
>  	/* This is safe since tlb_gather_mmu has disabled preemption */
> -        cpumask_t local_cpumask = cpumask_of_cpu(smp_processor_id());
>  	struct pte_freelist_batch **batchp = &__get_cpu_var(pte_freelist_cur);
>  
>  	if (atomic_read(&tlb->mm->mm_users) < 2 ||
> -	    cpus_equal(tlb->mm->cpu_vm_mask, local_cpumask)) {
> +	    cpumask_equal(mm_cpumask(tlb->mm), cpumask_of(smp_processor_id()))){
>  		pgtable_free(pgf);
>  		return;
>  	}
> diff --git a/arch/powerpc/mm/tlb_hash64.c b/arch/powerpc/mm/tlb_hash64.c
> --- a/arch/powerpc/mm/tlb_hash64.c
> +++ b/arch/powerpc/mm/tlb_hash64.c
> @@ -139,12 +139,12 @@ void hpte_need_flush(struct mm_struct *m
>   */
>  void __flush_tlb_pending(struct ppc64_tlb_batch *batch)
>  {
> -	cpumask_t tmp;
> +	const struct cpumask *tmp;
>  	int i, local = 0;
>  
>  	i = batch->index;
> -	tmp = cpumask_of_cpu(smp_processor_id());
> -	if (cpus_equal(batch->mm->cpu_vm_mask, tmp))
> +	tmp = cpumask_of(smp_processor_id());
> +	if (cpumask_equal(mm_cpumask(batch->mm), tmp))
>  		local = 1;
>  	if (i == 1)
>  		flush_hash_page(batch->vaddr[0], batch->pte[0],
> diff --git a/arch/powerpc/mm/tlb_nohash.c b/arch/powerpc/mm/tlb_nohash.c
> --- a/arch/powerpc/mm/tlb_nohash.c
> +++ b/arch/powerpc/mm/tlb_nohash.c
> @@ -132,11 +132,11 @@ void flush_tlb_mm(struct mm_struct *mm)
>  	pid = mm->context.id;
>  	if (unlikely(pid == MMU_NO_CONTEXT))
>  		goto no_context;
> -	cpu_mask = mm->cpu_vm_mask;
> -	cpu_clear(smp_processor_id(), cpu_mask);
> -	if (!cpus_empty(cpu_mask)) {
> +	if (!cpumask_equal(mm_cpumask(mm), cpumask_of(smp_processor_id()))) {
>  		struct tlb_flush_param p = { .pid = pid };
> -		smp_call_function_mask(cpu_mask, do_flush_tlb_mm_ipi, &p, 1);
> +		/* Ignores smp_processor_id() even if set. */
> +		smp_call_function_many(mm_cpumask(mm),
> +				       do_flush_tlb_mm_ipi, &p, 1);
>  	}
>  	_tlbil_pid(pid);
>   no_context:
> @@ -146,16 +146,15 @@ EXPORT_SYMBOL(flush_tlb_mm);
>  
>  void flush_tlb_page(struct vm_area_struct *vma, unsigned long vmaddr)
>  {
> -	cpumask_t cpu_mask;
> +	struct cpumask *cpu_mask;
>  	unsigned int pid;
>  
>  	preempt_disable();
>  	pid = vma ? vma->vm_mm->context.id : 0;
>  	if (unlikely(pid == MMU_NO_CONTEXT))
>  		goto bail;
> -	cpu_mask = vma->vm_mm->cpu_vm_mask;
> -	cpu_clear(smp_processor_id(), cpu_mask);
> -	if (!cpus_empty(cpu_mask)) {
> +	cpu_mask = mm_cpumask(vma->vm_mm);
> +	if (!cpumask_equal(cpu_mask, cpumask_of(smp_processor_id()))) {
>  		/* If broadcast tlbivax is supported, use it */
>  		if (mmu_has_feature(MMU_FTR_USE_TLBIVAX_BCAST)) {
>  			int lock = mmu_has_feature(MMU_FTR_LOCK_BCAST_INVAL);
> @@ -167,7 +166,8 @@ void flush_tlb_page(struct vm_area_struc
>  			goto bail;
>  		} else {
>  			struct tlb_flush_param p = { .pid = pid, .addr = vmaddr };
> -			smp_call_function_mask(cpu_mask,
> +			/* Ignores smp_processor_id() even if set in cpu_mask */
> +			smp_call_function_many(cpu_mask,
>  					       do_flush_tlb_page_ipi, &p, 1);
>  		}
>  	}
> diff --git a/arch/powerpc/platforms/cell/spu_base.c b/arch/powerpc/platforms/cell/spu_base.c
> --- a/arch/powerpc/platforms/cell/spu_base.c
> +++ b/arch/powerpc/platforms/cell/spu_base.c
> @@ -114,7 +114,7 @@ static inline void mm_needs_global_tlbie
>  	int nr = (NR_CPUS > 1) ? NR_CPUS : NR_CPUS + 1;
>  
>  	/* Global TLBIE broadcast required with SPEs. */
> -	__cpus_setall(&mm->cpu_vm_mask, nr);
> +	bitmap_fill(cpumask_bits(mm_cpumask(mm)), nr);
>  }
>  
>  void spu_associate_mm(struct spu *spu, struct mm_struct *mm)

^ permalink raw reply

* Re: IDE cable detection on Apple PowerBook
From: Benjamin Herrenschmidt @ 2009-03-20  6:27 UTC (permalink / raw)
  To: TOMARI Hisanobu; +Cc: linuxppc-dev
In-Reply-To: <20090319223001.c2674366.posco.grubb@gmail.com>

On Thu, 2009-03-19 at 22:30 +0900, TOMARI Hisanobu wrote:
> Thanks for helpful advices.
> This patch adds an option to drivers/ide/Kconfig and adds 
> some lines to drivers/ide/pmac.c . Now the driver checks
> if the model is prefixed with "PowerBook" and the entire hack
> can be toggled in the Kconfig.
> 
> Again, the patch is against linux 2.6.28.8.

Ack. I forwarded it to Bart for his queue.

Ben.

> Best regards,
> TOMARI Hisanobu
> 
> p.s. oddly, the drive works in ATA/100 mode under untouched
> MacOS X 10.5.
> 
> On Thu, 19 Mar 2009 17:08:37 +1100
> Benjamin Herrenschmidt <benh@kernel.crashing.org> wrote:
> 
> > On Thu, 2009-03-19 at 17:07 +1100, Benjamin Herrenschmidt wrote:
> > > On Wed, 2009-03-18 at 22:47 +0900, TOMARI Hisanobu wrote:
> > > > I thought the short-40pin assumption would cause no problem
> > > > considering all models beginning with "PowerBook5" are laptops.
> > > > Do you mean an option to toggle this hack on/off should be present 
> > > > in Kconfig?
> > > 
> > > Actually, it makes -some- amount of sense to do it by testing
> > > specifically for the prefix "PowerBook" and "iBook" without a specific
> > > number I suppose.
> > 
> > Actually "PowerBook" is enough, there's no iBook prefix in the
> > device-tree, I was confusing with old busted iMac firmwares that used
> > iMac instead of PowerMac in there.
> > 
> > Cheers,
> > Ben.
> > 
> > > Ben.
> > > 
> > > > Thanks,
> > > > TOMARI Hisanobu
> > > > 
> > > > On Wed, 18 Mar 2009 18:58:17 +1100
> > > > Benjamin Herrenschmidt <benh@kernel.crashing.org> wrote:
> > > > 
> > > > > On Wed, 2009-03-18 at 14:06 +0900, TOMARI Hisanobu wrote:
> > > > > > Hello,
> > > > > > 
> > > > > > I'm using an OCZ PATA SSD on Apple PowerBook5,4 computer.
> > > > > > The IDE drive fails to recognize 80-conductor cable that
> > > > > > connects the drive to motherboard to fall back to UDMA33.
> > > > > > 
> > > > > > This patch fixes this behavior by assuming that the cable is
> > > > > > short-40pin when the model string matches "PowerBook5" and 
> > > > > > the motherboard detects 80c cable.
> > > > > > 
> > > > > > This patch is against drivers/ide/pmac.c in linux 2.6.28.8.
> > > > > 
> > > > > The patch is too much of an ad-hoc hack... _maybe_ an option is to make
> > > > > the core fallback to 40 "short" when 80 pin detection fails on
> > > > > powerbooks instead ?
> > > > > 
> > > > > Ben.
> > > > > 
> > > > > > (before applying the patch) hdparm -i /dev/hda
> > > > > > /dev/hda:
> > > > > >  Timing buffered disk reads:   90 MB in  3.03 seconds =  29.73 MB/sec
> > > > > > (dmesg 2.6.26)
> > > > > > ide0: Found Apple UniNorth ATA-6 controller, bus ID 3, irq 39
> > > > > > Probing IDE interface ide0...
> > > > > > hda: CORE_PATA, ATA DISK drive
> > > > > > hda: host max PIO4 wanted PIO255(auto-tune) selected PIO4
> > > > > > hda: drive side 80-wire cable detection failed, limiting max speed to UDMA33
> > > > > > hda: UDMA/33 mode selected
> > > > > > 
> > > > > > (after applying the patch) hdparm -i /dev/hda
> > > > > > /dev/hda:
> > > > > >  Timing buffered disk reads:  240 MB in  3.02 seconds =  79.42 MB/sec
> > > > > > (dmesg 2.6.28.8)
> > > > > > ide-pmac: Found Apple UniNorth ATA-6 controller (PCI), bus ID 3, irq 39
> > > > > > Probing IDE interface ide0...
> > > > > > hda: CORE_PATA, ATA DISK drive
> > > > > > hda: host max PIO4 wanted PIO255(auto-tune) selected PIO4
> > > > > > hda: UDMA/100 mode selected
> > > > > > ide0 at 0xf102a000-0xf102a070,0xf102a160 on irq 39
> > > > > > 
> > > > > > 
> > > > > > _______________________________________________
> > > > > > Linuxppc-dev mailing list
> > > > > > Linuxppc-dev@ozlabs.org
> > > > > > https://ozlabs.org/mailman/listinfo/linuxppc-dev
> > > > > 
> > 

^ permalink raw reply

* Re: [PATCH v2] powerpc: Add support for CoreInt delivery of interrupts on MPIC
From: Benjamin Herrenschmidt @ 2009-03-20  5:48 UTC (permalink / raw)
  To: Kumar Gala; +Cc: linuxppc-dev
In-Reply-To: <1236784730-616-1-git-send-email-galak@kernel.crashing.org>

On Wed, 2009-03-11 at 10:18 -0500, Kumar Gala wrote:
> CoreInt provides a mechansim to deliver the IRQ vector directly
> into the core on an interrupt (via the SPR EPR) rather than having
> to go IACK on the PIC.  This is suppose to provide an improvment
> in interrupt latency by reducing the time to get the IRQ vector.
> 
> Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
> ---
> * Fixed MPIC_GREG_GCONF_COREINT flag to be 0x60000000 as per spec and pointed about by Dave

Are you sure ? That's 2 bits ...

Ben.

^ permalink raw reply

* Re: [RFC][PATCH -tip 4/9] power: add kernel_trap_sp()
From: Benjamin Herrenschmidt @ 2009-03-20  5:42 UTC (permalink / raw)
  To: Masami Hiramatsu
  Cc: linuxppc-dev, Ingo Molnar, LKML, Steven Rostedt, systemtap-ml
In-Reply-To: <49C2B4BF.4080904@redhat.com>

On Thu, 2009-03-19 at 17:10 -0400, Masami Hiramatsu wrote:
> Add kernel_trap_sp() on powerpc, based on systemtap's runtime/regs.h.
> 
> Signed-off-by: Masami Hiramatsu <mhiramat@redhat.com>

I haven't looked at the usage of it, but it's weird to have something
call "kernel_trap_sp" that returns the -user- stack pointer... is
this really what's expected here ?

> ---
>  arch/powerpc/include/asm/ptrace.h |    1 +
>  1 files changed, 1 insertions(+), 0 deletions(-)
> 
> diff --git a/arch/powerpc/include/asm/ptrace.h b/arch/powerpc/include/asm/ptrace.h
> index c9c678f..0ac366c 100644
> --- a/arch/powerpc/include/asm/ptrace.h
> +++ b/arch/powerpc/include/asm/ptrace.h
> @@ -83,6 +83,7 @@ struct pt_regs {
> 
>  #define instruction_pointer(regs) ((regs)->nip)
>  #define user_stack_pointer(regs) ((regs)->gpr[1])
> +#define kernel_trap_sp(regs) (user_stack_pointer(regs))
>  #define regs_return_value(regs) ((regs)->gpr[3])
> 
>  #ifdef CONFIG_SMP

^ permalink raw reply

* Re: [PATCH] powerpc: Add support for CoreInt delivery of interrupts onMPIC
From: Benjamin Herrenschmidt @ 2009-03-20  5:40 UTC (permalink / raw)
  To: Liu Dave-R63238; +Cc: linuxppc-dev
In-Reply-To: <D7CCA83BB0796C49BC0BB53B6AB12089136E4B@zch01exm21.fsl.freescale.net>

On Wed, 2009-03-11 at 22:20 +0800, Liu Dave-R63238 wrote:
> --- a/arch/powerpc/include/asm/mpic.h
> +++ b/arch/powerpc/include/asm/mpic.h
> @@ -22,6 +22,7 @@
>  #define MPIC_GREG_FEATURE_1            0x00010
>  #define MPIC_GREG_GLOBAL_CONF_0                0x00020
>  #define                MPIC_GREG_GCONF_RESET
> 0x80000000
> +#define                MPIC_GREG_GCONF_COREINT
> 0x40000000
>  #define                MPIC_GREG_GCONF_8259_PTHROU_DIS
> 0x20000000
>  #define                MPIC_GREG_GCONF_NO_BIAS
> 0x10000000
>  #define                MPIC_GREG_GCONF_BASE_MASK
> 0x000fffff
> 
> 
> according to the latest UM, the MPIC_GREG_GCONF_COREINT should be
> 0x60000000.
> 
You mean 0x40000000 ? :-)

0x60000000 looks indeed bogus.

> _______________________________________________
> Linuxppc-dev mailing list
> Linuxppc-dev@ozlabs.org
> https://ozlabs.org/mailman/listinfo/linuxppc-dev

^ permalink raw reply

* Re: [PATCH] powerpc 4xx EMAC driver: device name reported on timeout is not correct
From: Benjamin Herrenschmidt @ 2009-03-20  5:38 UTC (permalink / raw)
  To: Mikhail Zolotaryov; +Cc: linuxppc-dev, linux-kernel
In-Reply-To: <49B6B240.8030701@lebon.org.ua>

On Tue, 2009-03-10 at 20:32 +0200, Mikhail Zolotaryov wrote:
> Hi,
> 
> not critical problem here.
> 
> IBM EMAC driver performs device reset (drivers/net/ibm_newemac/core.c: 
> emac_probe() -> emac_init_phy() -> emac_reset()) before registering 
> appropriate net_device (emac_probe() -> register_netdev()), so 
> net_device name contains raw format string during EMAC reset ("eth%d").
> 
> If the case of reset timeout, emac_report_timeout_error() function is 
> called to report an error. The problem is this function uses net_device 
> name to report device related, which is not correct, as a result in the 
> kernel log buffer we see:
> 
> eth%d: reset timeout
> 
> The solution is to print device_node full_name instead. After applying 
> the patch proposed, error string is like the following:
> 
> /plb/opb/ethernet@ef600e00: reset timeout
> 
> 
> Signed-off-by: Mikhail Zolotaryov <lebon@lebon.org.ua>

Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
---

Please submit with my Ack included to the netdev list.

Cheers,
Ben.

> 
> 
> plain text document attachment (emac_report_timeout_error.patch)
> --- linux-2.6/drivers/net/ibm_newemac/core.c.orig	2009-03-10 20:24:12.000000000 +0200
> +++ linux-2.6/drivers/net/ibm_newemac/core.c		2009-03-10 20:29:12.000000000 +0200
> @@ -134,7 +134,7 @@
>  				  EMAC_FTR_440EP_PHY_CLK_FIX))
>  		DBG(dev, "%s" NL, error);
>  	else if (net_ratelimit())
> -		printk(KERN_ERR "%s: %s\n", dev->ndev->name, error);
> +		printk(KERN_ERR "%s: %s\n", dev->ofdev->node->full_name, error);
>  }
>  
>  /* EMAC PHY clock workaround:
> _______________________________________________
> Linuxppc-dev mailing list
> Linuxppc-dev@ozlabs.org
> https://ozlabs.org/mailman/listinfo/linuxppc-dev

^ permalink raw reply

* [PATCH 6/6] powerpc/mm: Introduce early_init_mmu() on 64-bit
From: Benjamin Herrenschmidt @ 2009-03-20  5:34 UTC (permalink / raw)
  To: linuxppc-dev
In-Reply-To: <1237527248.890279.946079812092.qpush@grosgo>

This moves some MMU related init code out of setup_64.c into hash_utils_64.c
and calls it early_init_mmu() and early_init_mmu_secondary(). This will
make it easier to plug in a new MMU type.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
---

 arch/powerpc/include/asm/mmu-hash64.h |    2 -
 arch/powerpc/include/asm/mmu.h        |    4 +++
 arch/powerpc/kernel/setup_64.c        |   35 ++++-----------------------------
 arch/powerpc/mm/hash_utils_64.c       |   36 ++++++++++++++++++++++++++++++++--
 4 files changed, 43 insertions(+), 34 deletions(-)

--- linux-work.orig/arch/powerpc/include/asm/mmu-hash64.h	2009-03-11 13:43:26.000000000 +1100
+++ linux-work/arch/powerpc/include/asm/mmu-hash64.h	2009-03-11 13:43:29.000000000 +1100
@@ -284,8 +284,6 @@ extern void add_gpage(unsigned long addr
 			  unsigned long number_of_pages);
 extern void demote_segment_4k(struct mm_struct *mm, unsigned long addr);
 
-extern void htab_initialize(void);
-extern void htab_initialize_secondary(void);
 extern void hpte_init_native(void);
 extern void hpte_init_lpar(void);
 extern void hpte_init_iSeries(void);
Index: linux-work/arch/powerpc/include/asm/mmu.h
===================================================================
--- linux-work.orig/arch/powerpc/include/asm/mmu.h	2009-03-11 13:43:39.000000000 +1100
+++ linux-work/arch/powerpc/include/asm/mmu.h	2009-03-11 13:48:40.000000000 +1100
@@ -56,6 +56,10 @@ static inline int mmu_has_feature(unsign
 
 extern unsigned int __start___mmu_ftr_fixup, __stop___mmu_ftr_fixup;
 
+/* MMU initialization (64-bit only fo now) */
+extern void early_init_mmu(void);
+extern void early_init_mmu_secondary(void);
+
 #endif /* !__ASSEMBLY__ */
 
 
Index: linux-work/arch/powerpc/kernel/setup_64.c
===================================================================
--- linux-work.orig/arch/powerpc/kernel/setup_64.c	2009-03-11 13:42:09.000000000 +1100
+++ linux-work/arch/powerpc/kernel/setup_64.c	2009-03-11 13:55:15.000000000 +1100
@@ -202,8 +202,6 @@ void __init early_setup(unsigned long dt
 
 	/* Fix up paca fields required for the boot cpu */
 	get_paca()->cpu_start = 1;
-	get_paca()->stab_real = __pa((u64)&initial_stab);
-	get_paca()->stab_addr = (u64)&initial_stab;
 
 	/* Probe the machine type */
 	probe_machine();
@@ -212,20 +210,8 @@ void __init early_setup(unsigned long dt
 
 	DBG("Found, Initializing memory management...\n");
 
-	/*
-	 * Initialize the MMU Hash table and create the linear mapping
-	 * of memory. Has to be done before stab/slb initialization as
-	 * this is currently where the page size encoding is obtained
-	 */
-	htab_initialize();
-
-	/*
-	 * Initialize stab / SLB management except on iSeries
-	 */
-	if (cpu_has_feature(CPU_FTR_SLB))
-		slb_initialize();
-	else if (!firmware_has_feature(FW_FEATURE_ISERIES))
-		stab_initialize(get_paca()->stab_real);
+	/* Initialize the hash table or TLB handling */
+	early_init_mmu();
 
 	DBG(" <- early_setup()\n");
 }
@@ -233,22 +219,11 @@ void __init early_setup(unsigned long dt
 #ifdef CONFIG_SMP
 void early_setup_secondary(void)
 {
-	struct paca_struct *lpaca = get_paca();
-
 	/* Mark interrupts enabled in PACA */
-	lpaca->soft_enabled = 0;
-
-	/* Initialize hash table for that CPU */
-	htab_initialize_secondary();
+	get_paca()->soft_enabled = 0;
 
-	/* Initialize STAB/SLB. We use a virtual address as it works
-	 * in real mode on pSeries and we want a virutal address on
-	 * iSeries anyway
-	 */
-	if (cpu_has_feature(CPU_FTR_SLB))
-		slb_initialize();
-	else
-		stab_initialize(lpaca->stab_addr);
+	/* Initialize the hash table or TLB handling */
+	early_init_mmu_secondary();
 }
 
 #endif /* CONFIG_SMP */
Index: linux-work/arch/powerpc/mm/hash_utils_64.c
===================================================================
--- linux-work.orig/arch/powerpc/mm/hash_utils_64.c	2009-03-11 13:41:36.000000000 +1100
+++ linux-work/arch/powerpc/mm/hash_utils_64.c	2009-03-11 13:54:50.000000000 +1100
@@ -590,7 +590,7 @@ static void __init htab_finish_init(void
 	make_bl(htab_call_hpte_updatepp, ppc_md.hpte_updatepp);
 }
 
-void __init htab_initialize(void)
+static void __init htab_initialize(void)
 {
 	unsigned long table;
 	unsigned long pteg_count;
@@ -732,11 +732,43 @@ void __init htab_initialize(void)
 #undef KB
 #undef MB
 
-void htab_initialize_secondary(void)
+void __init early_init_mmu(void)
 {
+	/* Setup initial STAB address in the PACA */
+	get_paca()->stab_real = __pa((u64)&initial_stab);
+	get_paca()->stab_addr = (u64)&initial_stab;
+
+	/* Initialize the MMU Hash table and create the linear mapping
+	 * of memory. Has to be done before stab/slb initialization as
+	 * this is currently where the page size encoding is obtained
+	 */
+	htab_initialize();
+
+	/* Initialize stab / SLB management except on iSeries
+	 */
+	if (cpu_has_feature(CPU_FTR_SLB))
+		slb_initialize();
+	else if (!firmware_has_feature(FW_FEATURE_ISERIES))
+		stab_initialize(get_paca()->stab_real);
+}
+
+#ifdef CONFIG_SMP
+void __init early_init_mmu_secondary(void)
+{
+	/* Initialize hash table for that CPU */
 	if (!firmware_has_feature(FW_FEATURE_LPAR))
 		mtspr(SPRN_SDR1, _SDR1);
+
+	/* Initialize STAB/SLB. We use a virtual address as it works
+	 * in real mode on pSeries and we want a virutal address on
+	 * iSeries anyway
+	 */
+	if (cpu_has_feature(CPU_FTR_SLB))
+		slb_initialize();
+	else
+		stab_initialize(get_paca()->stab_addr);
 }
+#endif /* CONFIG_SMP */
 
 /*
  * Called by asm hashtable.S for doing lazy icache flush

^ permalink raw reply

* [PATCH 5/6] powerpc/mm: Add option for non-atomic PTE updates to ppc64
From: Benjamin Herrenschmidt @ 2009-03-20  5:34 UTC (permalink / raw)
  To: linuxppc-dev
In-Reply-To: <1237527248.890279.946079812092.qpush@grosgo>

ppc32 has it already, add it to ppc64 as a preliminary for adding
support for Book3E 64-bit support

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
---

 arch/powerpc/include/asm/pgtable-ppc64.h |   12 +++++++++++-
 arch/powerpc/include/asm/pte-hash64.h    |    2 ++
 2 files changed, 13 insertions(+), 1 deletion(-)

--- linux-work.orig/arch/powerpc/include/asm/pgtable-ppc64.h	2009-03-10 15:43:26.000000000 +1100
+++ linux-work/arch/powerpc/include/asm/pgtable-ppc64.h	2009-03-10 16:08:30.000000000 +1100
@@ -178,6 +178,7 @@ static inline unsigned long pte_update(s
 				       pte_t *ptep, unsigned long clr,
 				       int huge)
 {
+#ifdef PTE_ATOMIC_UPDATES
 	unsigned long old, tmp;
 
 	__asm__ __volatile__(
@@ -190,7 +191,10 @@ static inline unsigned long pte_update(s
 	: "=&r" (old), "=&r" (tmp), "=m" (*ptep)
 	: "r" (ptep), "r" (clr), "m" (*ptep), "i" (_PAGE_BUSY)
 	: "cc" );
-
+#else
+	unsigned long old = pte_val(*ptep);
+	*ptep = __pte(old & ~clr);
+#endif
 	/* huge pages use the old page table lock */
 	if (!huge)
 		assert_pte_locked(mm, addr);
@@ -278,6 +282,8 @@ static inline void __ptep_set_access_fla
 	unsigned long bits = pte_val(entry) &
 		(_PAGE_DIRTY | _PAGE_ACCESSED | _PAGE_RW |
 		 _PAGE_EXEC | _PAGE_HWEXEC);
+
+#ifdef PTE_ATOMIC_UPDATES
 	unsigned long old, tmp;
 
 	__asm__ __volatile__(
@@ -290,6 +296,10 @@ static inline void __ptep_set_access_fla
 	:"=&r" (old), "=&r" (tmp), "=m" (*ptep)
 	:"r" (bits), "r" (ptep), "m" (*ptep), "i" (_PAGE_BUSY)
 	:"cc");
+#else
+	unsigned long old = pte_val(*ptep);
+	*ptep = __pte(old | bits);
+#endif
 }
 
 #define __HAVE_ARCH_PTE_SAME
Index: linux-work/arch/powerpc/include/asm/pte-hash64.h
===================================================================
--- linux-work.orig/arch/powerpc/include/asm/pte-hash64.h	2009-03-10 15:49:50.000000000 +1100
+++ linux-work/arch/powerpc/include/asm/pte-hash64.h	2009-03-10 15:49:55.000000000 +1100
@@ -41,6 +41,8 @@
 #define _PTEIDX_SECONDARY	0x8
 #define _PTEIDX_GROUP_IX	0x7
 
+/* Hash table based platforms need atomic updates of the linux PTE */
+#define PTE_ATOMIC_UPDATES	1
 
 #ifdef CONFIG_PPC_64K_PAGES
 #include <asm/pte-hash64-64k.h>

^ permalink raw reply

* [PATCH 4/6] powerpc/mm: Fix printk type warning in mmu_context_nohash
From: Benjamin Herrenschmidt @ 2009-03-20  5:34 UTC (permalink / raw)
  To: linuxppc-dev
In-Reply-To: <1237527248.890279.946079812092.qpush@grosgo>

We need to use %zu instead of %d when printing a sizeof()

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
---

 arch/powerpc/mm/mmu_context_nohash.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- linux-work.orig/arch/powerpc/mm/mmu_context_nohash.c	2009-03-11 11:51:05.000000000 +1100
+++ linux-work/arch/powerpc/mm/mmu_context_nohash.c	2009-03-11 11:52:55.000000000 +1100
@@ -380,7 +380,7 @@ void __init mmu_context_init(void)
 #endif
 
 	printk(KERN_INFO
-	       "MMU: Allocated %d bytes of context maps for %d contexts\n",
+	       "MMU: Allocated %zu bytes of context maps for %d contexts\n",
 	       2 * CTX_MAP_SIZE + (sizeof(void *) * (last_context + 1)),
 	       last_context - first_context + 1);
 

^ permalink raw reply

* [PATCH 3/6] powerpc/mm: Rename arch/powerpc/kernel/mmap.c to mmap_64.c
From: Benjamin Herrenschmidt @ 2009-03-20  5:34 UTC (permalink / raw)
  To: linuxppc-dev
In-Reply-To: <1237527248.890279.946079812092.qpush@grosgo>

This file is only useful on 64-bit, so we name it accordingly.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
---

 arch/powerpc/mm/Makefile  |    2 
 arch/powerpc/mm/mmap.c    |  109 ----------------------------------------------
 arch/powerpc/mm/mmap_64.c |  109 ++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 110 insertions(+), 110 deletions(-)

--- linux-work.orig/arch/powerpc/mm/Makefile	2009-03-10 16:08:34.000000000 +1100
+++ linux-work/arch/powerpc/mm/Makefile	2009-03-10 16:23:44.000000000 +1100
@@ -14,7 +14,7 @@ obj-$(CONFIG_PPC_MMU_NOHASH)	+= mmu_cont
 hash-$(CONFIG_PPC_NATIVE)	:= hash_native_64.o
 obj-$(CONFIG_PPC64)		+= hash_utils_64.o \
 				   slb_low.o slb.o stab.o \
-				   mmap.o $(hash-y)
+				   mmap_64.o $(hash-y)
 obj-$(CONFIG_PPC_STD_MMU_32)	+= ppc_mmu_32.o
 obj-$(CONFIG_PPC_STD_MMU)	+= hash_low_$(CONFIG_WORD_SIZE).o \
 				   tlb_hash$(CONFIG_WORD_SIZE).o \
Index: linux-work/arch/powerpc/mm/mmap.c
===================================================================
--- linux-work.orig/arch/powerpc/mm/mmap.c	2009-03-10 16:08:18.000000000 +1100
+++ /dev/null	1970-01-01 00:00:00.000000000 +0000
@@ -1,109 +0,0 @@
-/*
- *  flexible mmap layout support
- *
- * Copyright 2003-2004 Red Hat Inc., Durham, North Carolina.
- * All Rights Reserved.
- *
- * 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, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- *
- * Started by Ingo Molnar <mingo@elte.hu>
- */
-
-#include <linux/personality.h>
-#include <linux/mm.h>
-#include <linux/random.h>
-#include <linux/sched.h>
-
-/*
- * Top of mmap area (just below the process stack).
- *
- * Leave at least a ~128 MB hole on 32bit applications.
- *
- * On 64bit applications we randomise the stack by 1GB so we need to
- * space our mmap start address by a further 1GB, otherwise there is a
- * chance the mmap area will end up closer to the stack than our ulimit
- * requires.
- */
-#define MIN_GAP32 (128*1024*1024)
-#define MIN_GAP64 ((128 + 1024)*1024*1024UL)
-#define MIN_GAP ((is_32bit_task()) ? MIN_GAP32 : MIN_GAP64)
-#define MAX_GAP (TASK_SIZE/6*5)
-
-static inline int mmap_is_legacy(void)
-{
-	if (current->personality & ADDR_COMPAT_LAYOUT)
-		return 1;
-
-	if (current->signal->rlim[RLIMIT_STACK].rlim_cur == RLIM_INFINITY)
-		return 1;
-
-	return sysctl_legacy_va_layout;
-}
-
-/*
- * Since get_random_int() returns the same value within a 1 jiffy window,
- * we will almost always get the same randomisation for the stack and mmap
- * region. This will mean the relative distance between stack and mmap will
- * be the same.
- *
- * To avoid this we can shift the randomness by 1 bit.
- */
-static unsigned long mmap_rnd(void)
-{
-	unsigned long rnd = 0;
-
-	if (current->flags & PF_RANDOMIZE) {
-		/* 8MB for 32bit, 1GB for 64bit */
-		if (is_32bit_task())
-			rnd = (long)(get_random_int() % (1<<(22-PAGE_SHIFT)));
-		else
-			rnd = (long)(get_random_int() % (1<<(29-PAGE_SHIFT)));
-	}
-	return (rnd << PAGE_SHIFT) * 2;
-}
-
-static inline unsigned long mmap_base(void)
-{
-	unsigned long gap = current->signal->rlim[RLIMIT_STACK].rlim_cur;
-
-	if (gap < MIN_GAP)
-		gap = MIN_GAP;
-	else if (gap > MAX_GAP)
-		gap = MAX_GAP;
-
-	return PAGE_ALIGN(TASK_SIZE - gap - mmap_rnd());
-}
-
-/*
- * This function, called very early during the creation of a new
- * process VM image, sets up which VM layout function to use:
- */
-void arch_pick_mmap_layout(struct mm_struct *mm)
-{
-	/*
-	 * Fall back to the standard layout if the personality
-	 * bit is set, or if the expected stack growth is unlimited:
-	 */
-	if (mmap_is_legacy()) {
-		mm->mmap_base = TASK_UNMAPPED_BASE;
-		mm->get_unmapped_area = arch_get_unmapped_area;
-		mm->unmap_area = arch_unmap_area;
-	} else {
-		mm->mmap_base = mmap_base();
-		mm->get_unmapped_area = arch_get_unmapped_area_topdown;
-		mm->unmap_area = arch_unmap_area_topdown;
-	}
-}
Index: linux-work/arch/powerpc/mm/mmap_64.c
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ linux-work/arch/powerpc/mm/mmap_64.c	2009-03-10 16:08:34.000000000 +1100
@@ -0,0 +1,109 @@
+/*
+ *  flexible mmap layout support
+ *
+ * Copyright 2003-2004 Red Hat Inc., Durham, North Carolina.
+ * All Rights Reserved.
+ *
+ * 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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ *
+ * Started by Ingo Molnar <mingo@elte.hu>
+ */
+
+#include <linux/personality.h>
+#include <linux/mm.h>
+#include <linux/random.h>
+#include <linux/sched.h>
+
+/*
+ * Top of mmap area (just below the process stack).
+ *
+ * Leave at least a ~128 MB hole on 32bit applications.
+ *
+ * On 64bit applications we randomise the stack by 1GB so we need to
+ * space our mmap start address by a further 1GB, otherwise there is a
+ * chance the mmap area will end up closer to the stack than our ulimit
+ * requires.
+ */
+#define MIN_GAP32 (128*1024*1024)
+#define MIN_GAP64 ((128 + 1024)*1024*1024UL)
+#define MIN_GAP ((is_32bit_task()) ? MIN_GAP32 : MIN_GAP64)
+#define MAX_GAP (TASK_SIZE/6*5)
+
+static inline int mmap_is_legacy(void)
+{
+	if (current->personality & ADDR_COMPAT_LAYOUT)
+		return 1;
+
+	if (current->signal->rlim[RLIMIT_STACK].rlim_cur == RLIM_INFINITY)
+		return 1;
+
+	return sysctl_legacy_va_layout;
+}
+
+/*
+ * Since get_random_int() returns the same value within a 1 jiffy window,
+ * we will almost always get the same randomisation for the stack and mmap
+ * region. This will mean the relative distance between stack and mmap will
+ * be the same.
+ *
+ * To avoid this we can shift the randomness by 1 bit.
+ */
+static unsigned long mmap_rnd(void)
+{
+	unsigned long rnd = 0;
+
+	if (current->flags & PF_RANDOMIZE) {
+		/* 8MB for 32bit, 1GB for 64bit */
+		if (is_32bit_task())
+			rnd = (long)(get_random_int() % (1<<(22-PAGE_SHIFT)));
+		else
+			rnd = (long)(get_random_int() % (1<<(29-PAGE_SHIFT)));
+	}
+	return (rnd << PAGE_SHIFT) * 2;
+}
+
+static inline unsigned long mmap_base(void)
+{
+	unsigned long gap = current->signal->rlim[RLIMIT_STACK].rlim_cur;
+
+	if (gap < MIN_GAP)
+		gap = MIN_GAP;
+	else if (gap > MAX_GAP)
+		gap = MAX_GAP;
+
+	return PAGE_ALIGN(TASK_SIZE - gap - mmap_rnd());
+}
+
+/*
+ * This function, called very early during the creation of a new
+ * process VM image, sets up which VM layout function to use:
+ */
+void arch_pick_mmap_layout(struct mm_struct *mm)
+{
+	/*
+	 * Fall back to the standard layout if the personality
+	 * bit is set, or if the expected stack growth is unlimited:
+	 */
+	if (mmap_is_legacy()) {
+		mm->mmap_base = TASK_UNMAPPED_BASE;
+		mm->get_unmapped_area = arch_get_unmapped_area;
+		mm->unmap_area = arch_unmap_area;
+	} else {
+		mm->mmap_base = mmap_base();
+		mm->get_unmapped_area = arch_get_unmapped_area_topdown;
+		mm->unmap_area = arch_unmap_area_topdown;
+	}
+}

^ permalink raw reply

* [PATCH 2/6] powerpc/mm: Merge various PTE bits and accessors definitions (v3)
From: Benjamin Herrenschmidt @ 2009-03-20  5:34 UTC (permalink / raw)
  To: linuxppc-dev
In-Reply-To: <1237527248.890279.946079812092.qpush@grosgo>

Now that they are almost identical, we can merge some of the definitions
related to the PTE format into common files.

This creates a new pte-common.h which is included by both 32 and 64-bit
right after the CPU specific pte-*.h file, and which defines some
bits to "default" values if they haven't been defined already, and
then provides a generic definition of most of the bit combinations
based on these and exposed to the rest of the kernel.

I also moved to the common pgtable.h most of the "small" accessors to the
PTE bits and modification helpers (pte_mk*). The actual accessors remain
in their separate files.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
---

v2: Fix mixup with previous patch
v3: Rebase due to change in previous patch and fix pfn_pte() for 32-bit
    platforms with >32 bit physical address space

 arch/powerpc/include/asm/pgtable-ppc32.h |  204 -------------------------------
 arch/powerpc/include/asm/pgtable-ppc64.h |  132 --------------------
 arch/powerpc/include/asm/pgtable.h       |   54 +++++++-
 arch/powerpc/include/asm/pte-common.h    |  180 +++++++++++++++++++++++++++
 4 files changed, 233 insertions(+), 337 deletions(-)

--- linux-work.orig/arch/powerpc/include/asm/pgtable-ppc32.h	2009-03-20 15:47:40.000000000 +1100
+++ linux-work/arch/powerpc/include/asm/pgtable-ppc32.h	2009-03-20 15:50:39.000000000 +1100
@@ -97,174 +97,11 @@ extern int icache_44x_need_flush;
 #include <asm/pte-hash32.h>
 #endif
 
-/* If _PAGE_SPECIAL is defined, then we advertise our support for it */
-#ifdef _PAGE_SPECIAL
-#define __HAVE_ARCH_PTE_SPECIAL
-#endif
-
-/*
- * Some bits are only used on some cpu families... Make sure that all
- * the undefined gets defined as 0
- */
-#ifndef _PAGE_HASHPTE
-#define _PAGE_HASHPTE	0
-#endif
-#ifndef _PTE_NONE_MASK
-#define _PTE_NONE_MASK 0
-#endif
-#ifndef _PAGE_SHARED
-#define _PAGE_SHARED	0
-#endif
-#ifndef _PAGE_HWWRITE
-#define _PAGE_HWWRITE	0
-#endif
-#ifndef _PAGE_HWEXEC
-#define _PAGE_HWEXEC	0
-#endif
-#ifndef _PAGE_EXEC
-#define _PAGE_EXEC	0
-#endif
-#ifndef _PAGE_ENDIAN
-#define _PAGE_ENDIAN	0
-#endif
-#ifndef _PAGE_COHERENT
-#define _PAGE_COHERENT	0
-#endif
-#ifndef _PAGE_WRITETHRU
-#define _PAGE_WRITETHRU	0
-#endif
-#ifndef _PAGE_SPECIAL
-#define _PAGE_SPECIAL	0
-#endif
-#ifndef _PMD_PRESENT_MASK
-#define _PMD_PRESENT_MASK	_PMD_PRESENT
-#endif
-#ifndef _PMD_SIZE
-#define _PMD_SIZE	0
-#define PMD_PAGE_SIZE(pmd)	bad_call_to_PMD_PAGE_SIZE()
-#endif
-
-#ifndef _PAGE_KERNEL_RO
-#define _PAGE_KERNEL_RO	0
-#endif
-#ifndef _PAGE_KERNEL_RW
-#define _PAGE_KERNEL_RW	(_PAGE_DIRTY | _PAGE_RW | _PAGE_HWWRITE)
-#endif
-
-#define _PAGE_HPTEFLAGS _PAGE_HASHPTE
-
-/* Location of the PFN in the PTE. Most platforms use the same as _PAGE_SHIFT
- * here (ie, naturally aligned). Platform who don't just pre-define the
- * value so we don't override it here
- */
-#ifndef PTE_RPN_SHIFT
-#define PTE_RPN_SHIFT	(PAGE_SHIFT)
-#endif
-
-#ifdef CONFIG_PTE_64BIT
-#define PTE_RPN_MAX	(1ULL << (64 - PTE_RPN_SHIFT))
-#define PTE_RPN_MASK	(~((1ULL<<PTE_RPN_SHIFT)-1))
-#else
-#define PTE_RPN_MAX	(1UL << (32 - PTE_RPN_SHIFT))
-#define PTE_RPN_MASK	(~((1UL<<PTE_RPN_SHIFT)-1))
-#endif
-
-/* _PAGE_CHG_MASK masks of bits that are to be preserved accross
- * pgprot changes
- */
-#define _PAGE_CHG_MASK	(PTE_RPN_MASK | _PAGE_HPTEFLAGS | _PAGE_DIRTY | \
-                         _PAGE_ACCESSED | _PAGE_SPECIAL)
-
-/* Mask of bits returned by pte_pgprot() */
-#define PAGE_PROT_BITS	(_PAGE_GUARDED | _PAGE_COHERENT | _PAGE_NO_CACHE | \
-			 _PAGE_WRITETHRU | _PAGE_ENDIAN | \
-			 _PAGE_USER | _PAGE_ACCESSED | \
-			 _PAGE_RW | _PAGE_HWWRITE | _PAGE_DIRTY | \
-			 _PAGE_EXEC | _PAGE_HWEXEC)
-
-/*
- * We define 2 sets of base prot bits, one for basic pages (ie,
- * cacheable kernel and user pages) and one for non cacheable
- * pages. We always set _PAGE_COHERENT when SMP is enabled or
- * the processor might need it for DMA coherency.
- */
-#if defined(CONFIG_SMP) || defined(CONFIG_PPC_STD_MMU)
-#define _PAGE_BASE	(_PAGE_PRESENT | _PAGE_ACCESSED | _PAGE_COHERENT)
-#else
-#define _PAGE_BASE	(_PAGE_PRESENT | _PAGE_ACCESSED)
-#endif
-#define _PAGE_BASE_NC	(_PAGE_PRESENT | _PAGE_ACCESSED)
-
-/* Permission masks used for kernel mappings */
-#define PAGE_KERNEL	__pgprot(_PAGE_BASE | _PAGE_KERNEL_RW)
-#define PAGE_KERNEL_NC	__pgprot(_PAGE_BASE_NC | _PAGE_KERNEL_RW | \
-				 _PAGE_NO_CACHE)
-#define PAGE_KERNEL_NCG	__pgprot(_PAGE_BASE_NC | _PAGE_KERNEL_RW | \
-				 _PAGE_NO_CACHE | _PAGE_GUARDED)
-#define PAGE_KERNEL_X __pgprot(_PAGE_BASE | _PAGE_KERNEL_RW | _PAGE_EXEC)
-#define PAGE_KERNEL_RO __pgprot(_PAGE_BASE | _PAGE_KERNEL_RO)
-#define PAGE_KERNEL_ROX __pgprot(_PAGE_BASE | _PAGE_KERNEL_RO | _PAGE_EXEC)
-
-#if defined(CONFIG_KGDB) || defined(CONFIG_XMON) || defined(CONFIG_BDI_SWITCH) ||\
-	defined(CONFIG_KPROBES)
-/* We want the debuggers to be able to set breakpoints anywhere, so
- * don't write protect the kernel text */
-#define PAGE_KERNEL_TEXT	PAGE_KERNEL_X
-#else
-#define PAGE_KERNEL_TEXT	PAGE_KERNEL_ROX
-#endif
-
-#define PAGE_NONE	__pgprot(_PAGE_BASE)
-#define PAGE_READONLY	__pgprot(_PAGE_BASE | _PAGE_USER)
-#define PAGE_READONLY_X	__pgprot(_PAGE_BASE | _PAGE_USER | _PAGE_EXEC)
-#define PAGE_SHARED	__pgprot(_PAGE_BASE | _PAGE_USER | _PAGE_RW)
-#define PAGE_SHARED_X	__pgprot(_PAGE_BASE | _PAGE_USER | _PAGE_RW | _PAGE_EXEC)
-#define PAGE_COPY	__pgprot(_PAGE_BASE | _PAGE_USER)
-#define PAGE_COPY_X	__pgprot(_PAGE_BASE | _PAGE_USER | _PAGE_EXEC)
-
-/*
- * The PowerPC can only do execute protection on a segment (256MB) basis,
- * not on a page basis.  So we consider execute permission the same as read.
- * Also, write permissions imply read permissions.
- * This is the closest we can get..
- */
-#define __P000	PAGE_NONE
-#define __P001	PAGE_READONLY_X
-#define __P010	PAGE_COPY
-#define __P011	PAGE_COPY_X
-#define __P100	PAGE_READONLY
-#define __P101	PAGE_READONLY_X
-#define __P110	PAGE_COPY
-#define __P111	PAGE_COPY_X
-
-#define __S000	PAGE_NONE
-#define __S001	PAGE_READONLY_X
-#define __S010	PAGE_SHARED
-#define __S011	PAGE_SHARED_X
-#define __S100	PAGE_READONLY
-#define __S101	PAGE_READONLY_X
-#define __S110	PAGE_SHARED
-#define __S111	PAGE_SHARED_X
+/* And here we include common definitions */
+#include <asm/pte-common.h>
 
 #ifndef __ASSEMBLY__
-/* Make sure we get a link error if PMD_PAGE_SIZE is ever called on a
- * kernel without large page PMD support */
-extern unsigned long bad_call_to_PMD_PAGE_SIZE(void);
 
-/*
- * Conversions between PTE values and page frame numbers.
- */
-
-#define pte_pfn(x)		(pte_val(x) >> PTE_RPN_SHIFT)
-#define pte_page(x)		pfn_to_page(pte_pfn(x))
-
-#define pfn_pte(pfn, prot)	__pte(((pte_basic_t)(pfn) << PTE_RPN_SHIFT) |\
-					pgprot_val(prot))
-#define mk_pte(page, prot)	pfn_pte(page_to_pfn(page), prot)
-#endif /* __ASSEMBLY__ */
-
-#define pte_none(pte)		((pte_val(pte) & ~_PTE_NONE_MASK) == 0)
-#define pte_present(pte)	(pte_val(pte) & _PAGE_PRESENT)
 #define pte_clear(mm, addr, ptep) \
 	do { pte_update(ptep, ~_PAGE_HASHPTE, 0); } while (0)
 
@@ -273,43 +110,6 @@ extern unsigned long bad_call_to_PMD_PAG
 #define	pmd_present(pmd)	(pmd_val(pmd) & _PMD_PRESENT_MASK)
 #define	pmd_clear(pmdp)		do { pmd_val(*(pmdp)) = 0; } while (0)
 
-#ifndef __ASSEMBLY__
-/*
- * The following only work if pte_present() is true.
- * Undefined behaviour if not..
- */
-static inline int pte_write(pte_t pte)		{ return pte_val(pte) & _PAGE_RW; }
-static inline int pte_dirty(pte_t pte)		{ return pte_val(pte) & _PAGE_DIRTY; }
-static inline int pte_young(pte_t pte)		{ return pte_val(pte) & _PAGE_ACCESSED; }
-static inline int pte_file(pte_t pte)		{ return pte_val(pte) & _PAGE_FILE; }
-static inline int pte_special(pte_t pte)	{ return pte_val(pte) & _PAGE_SPECIAL; }
-
-static inline pte_t pte_wrprotect(pte_t pte) {
-	pte_val(pte) &= ~(_PAGE_RW | _PAGE_HWWRITE); return pte; }
-static inline pte_t pte_mkclean(pte_t pte) {
-	pte_val(pte) &= ~(_PAGE_DIRTY | _PAGE_HWWRITE); return pte; }
-static inline pte_t pte_mkold(pte_t pte) {
-	pte_val(pte) &= ~_PAGE_ACCESSED; return pte; }
-
-static inline pte_t pte_mkwrite(pte_t pte) {
-	pte_val(pte) |= _PAGE_RW; return pte; }
-static inline pte_t pte_mkdirty(pte_t pte) {
-	pte_val(pte) |= _PAGE_DIRTY; return pte; }
-static inline pte_t pte_mkyoung(pte_t pte) {
-	pte_val(pte) |= _PAGE_ACCESSED; return pte; }
-static inline pte_t pte_mkspecial(pte_t pte) {
-	pte_val(pte) |= _PAGE_SPECIAL; return pte; }
-static inline pgprot_t pte_pgprot(pte_t pte)
-{
-	return __pgprot(pte_val(pte) & PAGE_PROT_BITS);
-}
-
-static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
-{
-	pte_val(pte) = (pte_val(pte) & _PAGE_CHG_MASK) | pgprot_val(newprot);
-	return pte;
-}
-
 /*
  * When flushing the tlb entry for a page, we also need to flush the hash
  * table entry.  flush_hash_pages is assembler (for speed) in hashtable.S.
Index: linux-work/arch/powerpc/include/asm/pgtable-ppc64.h
===================================================================
--- linux-work.orig/arch/powerpc/include/asm/pgtable-ppc64.h	2009-03-20 15:49:51.000000000 +1100
+++ linux-work/arch/powerpc/include/asm/pgtable-ppc64.h	2009-03-20 15:52:59.000000000 +1100
@@ -80,82 +80,8 @@
  * Include the PTE bits definitions
  */
 #include <asm/pte-hash64.h>
+#include <asm/pte-common.h
 
-/* Some other useful definitions */
-#define PTE_RPN_MAX	(1UL << (64 - PTE_RPN_SHIFT))
-#define PTE_RPN_MASK	(~((1UL<<PTE_RPN_SHIFT)-1))
-
-/* _PAGE_CHG_MASK masks of bits that are to be preserved accross
- * pgprot changes
- */
-#define _PAGE_CHG_MASK	(PTE_RPN_MASK | _PAGE_HPTEFLAGS | _PAGE_DIRTY | \
-                         _PAGE_ACCESSED | _PAGE_SPECIAL)
-
-#define _PAGE_BASE_NC	(_PAGE_PRESENT | _PAGE_ACCESSED | _PAGE_PSIZE)
-#define _PAGE_BASE	(_PAGE_BASE_NC | _PAGE_COHERENT)
-
-
-/* Permission masks used to generate the __P and __S table,
- *
- * Note:__pgprot is defined in arch/powerpc/include/asm/page.h
- */
-#define PAGE_NONE	__pgprot(_PAGE_BASE)
-#define PAGE_SHARED	__pgprot(_PAGE_BASE | _PAGE_USER | _PAGE_RW)
-#define PAGE_SHARED_X	__pgprot(_PAGE_BASE | _PAGE_USER | _PAGE_RW | _PAGE_EXEC)
-#define PAGE_COPY	__pgprot(_PAGE_BASE | _PAGE_USER)
-#define PAGE_COPY_X	__pgprot(_PAGE_BASE | _PAGE_USER | _PAGE_EXEC)
-#define PAGE_READONLY	__pgprot(_PAGE_BASE | _PAGE_USER)
-#define PAGE_READONLY_X	__pgprot(_PAGE_BASE | _PAGE_USER | _PAGE_EXEC)
-
-/* Permission masks used for kernel mappings */
-#define PAGE_KERNEL	__pgprot(_PAGE_BASE | _PAGE_KERNEL_RW)
-#define PAGE_KERNEL_NC	__pgprot(_PAGE_BASE_NC | _PAGE_KERNEL_RW | \
-				 _PAGE_NO_CACHE)
-#define PAGE_KERNEL_NCG	__pgprot(_PAGE_BASE_NC | _PAGE_KERNEL_RW | \
-				 _PAGE_NO_CACHE | _PAGE_GUARDED)
-#define PAGE_KERNEL_X __pgprot(_PAGE_BASE | _PAGE_KERNEL_RW | _PAGE_EXEC)
-#define PAGE_KERNEL_RO __pgprot(_PAGE_BASE | _PAGE_KERNEL_RO)
-#define PAGE_KERNEL_ROX __pgprot(_PAGE_BASE | _PAGE_KERNEL_RO | _PAGE_EXEC)
-
-/* Protection bits for use by pte_pgprot() */
-#define PAGE_PROT_BITS	(_PAGE_GUARDED | _PAGE_COHERENT | \
-			 _PAGE_NO_CACHE | _PAGE_WRITETHRU |		\
-			 _PAGE_4K_PFN | _PAGE_USER | _PAGE_RW |		\
-			 _PAGE_ACCESSED | _PAGE_DIRTY | _PAGE_EXEC)
-
-
-/* We always have _PAGE_SPECIAL on 64 bit */
-#define __HAVE_ARCH_PTE_SPECIAL
-
-/* Make modules code happy. We don't set RO yet */
-#define PAGE_KERNEL_EXEC	PAGE_KERNEL_X
-
-/*
- * POWER4 and newer have per page execute protection, older chips can only
- * do this on a segment (256MB) basis.
- *
- * Also, write permissions imply read permissions.
- * This is the closest we can get..
- *
- * Note due to the way vm flags are laid out, the bits are XWR
- */
-#define __P000	PAGE_NONE
-#define __P001	PAGE_READONLY
-#define __P010	PAGE_COPY
-#define __P011	PAGE_COPY
-#define __P100	PAGE_READONLY_X
-#define __P101	PAGE_READONLY_X
-#define __P110	PAGE_COPY_X
-#define __P111	PAGE_COPY_X
-
-#define __S000	PAGE_NONE
-#define __S001	PAGE_READONLY
-#define __S010	PAGE_SHARED
-#define __S011	PAGE_SHARED
-#define __S100	PAGE_READONLY_X
-#define __S101	PAGE_READONLY_X
-#define __S110	PAGE_SHARED_X
-#define __S111	PAGE_SHARED_X
 
 #ifdef CONFIG_PPC_MM_SLICES
 #define HAVE_ARCH_UNMAPPED_AREA
@@ -196,34 +122,8 @@
 #endif /* __real_pte */
 
 
-/*
- * Conversion functions: convert a page and protection to a page entry,
- * and a page entry and page directory to the page they refer to.
- *
- * mk_pte takes a (struct page *) as input
- */
-#define mk_pte(page, pgprot)	pfn_pte(page_to_pfn(page), (pgprot))
-
-static inline pte_t pfn_pte(unsigned long pfn, pgprot_t pgprot)
-{
-	pte_t pte;
-
-
-	pte_val(pte) = (pfn << PTE_RPN_SHIFT) | pgprot_val(pgprot);
-	return pte;
-}
-
-#define pte_modify(_pte, newprot) \
-  (__pte((pte_val(_pte) & _PAGE_CHG_MASK) | pgprot_val(newprot)))
-
-#define pte_none(pte)		((pte_val(pte) & ~_PAGE_HPTEFLAGS) == 0)
-#define pte_present(pte)	(pte_val(pte) & _PAGE_PRESENT)
-
 /* pte_clear moved to later in this file */
 
-#define pte_pfn(x)		((unsigned long)((pte_val(x)>>PTE_RPN_SHIFT)))
-#define pte_page(x)		pfn_to_page(pte_pfn(x))
-
 #define PMD_BAD_BITS		(PTE_TABLE_SIZE-1)
 #define PUD_BAD_BITS		(PMD_TABLE_SIZE-1)
 
@@ -271,36 +171,6 @@ static inline pte_t pfn_pte(unsigned lon
 /* This now only contains the vmalloc pages */
 #define pgd_offset_k(address) pgd_offset(&init_mm, address)
 
-/*
- * The following only work if pte_present() is true.
- * Undefined behaviour if not..
- */
-static inline int pte_write(pte_t pte) { return pte_val(pte) & _PAGE_RW;}
-static inline int pte_dirty(pte_t pte) { return pte_val(pte) & _PAGE_DIRTY;}
-static inline int pte_young(pte_t pte) { return pte_val(pte) & _PAGE_ACCESSED;}
-static inline int pte_file(pte_t pte) { return pte_val(pte) & _PAGE_FILE;}
-static inline int pte_special(pte_t pte) { return pte_val(pte) & _PAGE_SPECIAL; }
-
-static inline pte_t pte_wrprotect(pte_t pte) {
-	pte_val(pte) &= ~(_PAGE_RW); return pte; }
-static inline pte_t pte_mkclean(pte_t pte) {
-	pte_val(pte) &= ~(_PAGE_DIRTY); return pte; }
-static inline pte_t pte_mkold(pte_t pte) {
-	pte_val(pte) &= ~_PAGE_ACCESSED; return pte; }
-static inline pte_t pte_mkwrite(pte_t pte) {
-	pte_val(pte) |= _PAGE_RW; return pte; }
-static inline pte_t pte_mkdirty(pte_t pte) {
-	pte_val(pte) |= _PAGE_DIRTY; return pte; }
-static inline pte_t pte_mkyoung(pte_t pte) {
-	pte_val(pte) |= _PAGE_ACCESSED; return pte; }
-static inline pte_t pte_mkhuge(pte_t pte) {
-	return pte; }
-static inline pte_t pte_mkspecial(pte_t pte) {
-	pte_val(pte) |= _PAGE_SPECIAL; return pte; }
-static inline pgprot_t pte_pgprot(pte_t pte)
-{
-	return __pgprot(pte_val(pte) & PAGE_PROT_BITS);
-}
 
 /* Atomic PTE updates */
 static inline unsigned long pte_update(struct mm_struct *mm,
Index: linux-work/arch/powerpc/include/asm/pgtable.h
===================================================================
--- linux-work.orig/arch/powerpc/include/asm/pgtable.h	2009-03-20 15:47:40.000000000 +1100
+++ linux-work/arch/powerpc/include/asm/pgtable.h	2009-03-20 15:55:06.000000000 +1100
@@ -25,12 +25,58 @@ static inline void assert_pte_locked(str
 #  include <asm/pgtable-ppc32.h>
 #endif
 
-/* Special mapping for AGP */
-#define PAGE_AGP	(PAGE_KERNEL_NC)
-#define HAVE_PAGE_AGP
-
 #ifndef __ASSEMBLY__
 
+/* Generic accessors to PTE bits */
+static inline int pte_write(pte_t pte)		{ return pte_val(pte) & _PAGE_RW; }
+static inline int pte_dirty(pte_t pte)		{ return pte_val(pte) & _PAGE_DIRTY; }
+static inline int pte_young(pte_t pte)		{ return pte_val(pte) & _PAGE_ACCESSED; }
+static inline int pte_file(pte_t pte)		{ return pte_val(pte) & _PAGE_FILE; }
+static inline int pte_special(pte_t pte)	{ return pte_val(pte) & _PAGE_SPECIAL; }
+static inline int pte_present(pte_t pte)	{ return pte_val(pte) & _PAGE_PRESENT; }
+static inline int pte_none(pte_t pte)		{ return (pte_val(pte) & ~_PTE_NONE_MASK) == 0; }
+static inline pgprot_t pte_pgprot(pte_t pte)	{ return __pgprot(pte_val(pte) & PAGE_PROT_BITS); }
+
+/* Conversion functions: convert a page and protection to a page entry,
+ * and a page entry and page directory to the page they refer to.
+ *
+ * Even if PTEs can be unsigned long long, a PFN is always an unsigned
+ * long for now.
+ */
+static inline pte_t pfn_pte(unsigned long pfn, pgprot_t pgprot) {
+	return __pte(((pte_basic_t)(pfn) << PTE_RPN_SHIFT) |
+		     pgprot_val(pgprot)); }
+static inline unsigned long pte_pfn(pte_t pte)	{
+	return pte_val(pte) >> PTE_RPN_SHIFT; }
+
+/* Keep these as a macros to avoid include dependency mess */
+#define pte_page(x)		pfn_to_page(pte_pfn(x))
+#define mk_pte(page, pgprot)	pfn_pte(page_to_pfn(page), (pgprot))
+
+/* Generic modifiers for PTE bits */
+static inline pte_t pte_wrprotect(pte_t pte) {
+	pte_val(pte) &= ~(_PAGE_RW | _PAGE_HWWRITE); return pte; }
+static inline pte_t pte_mkclean(pte_t pte) {
+	pte_val(pte) &= ~(_PAGE_DIRTY | _PAGE_HWWRITE); return pte; }
+static inline pte_t pte_mkold(pte_t pte) {
+	pte_val(pte) &= ~_PAGE_ACCESSED; return pte; }
+static inline pte_t pte_mkwrite(pte_t pte) {
+	pte_val(pte) |= _PAGE_RW; return pte; }
+static inline pte_t pte_mkdirty(pte_t pte) {
+	pte_val(pte) |= _PAGE_DIRTY; return pte; }
+static inline pte_t pte_mkyoung(pte_t pte) {
+	pte_val(pte) |= _PAGE_ACCESSED; return pte; }
+static inline pte_t pte_mkspecial(pte_t pte) {
+	pte_val(pte) |= _PAGE_SPECIAL; return pte; }
+static inline pte_t pte_mkhuge(pte_t pte) {
+	return pte; }
+static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
+{
+	pte_val(pte) = (pte_val(pte) & _PAGE_CHG_MASK) | pgprot_val(newprot);
+	return pte;
+}
+
+
 /* Insert a PTE, top-level function is out of line. It uses an inline
  * low level function in the respective pgtable-* files
  */
Index: linux-work/arch/powerpc/include/asm/pte-common.h
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ linux-work/arch/powerpc/include/asm/pte-common.h	2009-03-20 15:51:48.000000000 +1100
@@ -0,0 +1,180 @@
+/* Included from asm/pgtable-*.h only ! */
+
+/*
+ * Some bits are only used on some cpu families... Make sure that all
+ * the undefined gets a sensible default
+ */
+#ifndef _PAGE_HASHPTE
+#define _PAGE_HASHPTE	0
+#endif
+#ifndef _PAGE_SHARED
+#define _PAGE_SHARED	0
+#endif
+#ifndef _PAGE_HWWRITE
+#define _PAGE_HWWRITE	0
+#endif
+#ifndef _PAGE_HWEXEC
+#define _PAGE_HWEXEC	0
+#endif
+#ifndef _PAGE_EXEC
+#define _PAGE_EXEC	0
+#endif
+#ifndef _PAGE_ENDIAN
+#define _PAGE_ENDIAN	0
+#endif
+#ifndef _PAGE_COHERENT
+#define _PAGE_COHERENT	0
+#endif
+#ifndef _PAGE_WRITETHRU
+#define _PAGE_WRITETHRU	0
+#endif
+#ifndef _PAGE_SPECIAL
+#define _PAGE_SPECIAL	0
+#endif
+#ifndef _PAGE_4K_PFN
+#define _PAGE_4K_PFN		0
+#endif
+#ifndef _PAGE_PSIZE
+#define _PAGE_PSIZE		0
+#endif
+#ifndef _PMD_PRESENT_MASK
+#define _PMD_PRESENT_MASK	_PMD_PRESENT
+#endif
+#ifndef _PMD_SIZE
+#define _PMD_SIZE	0
+#define PMD_PAGE_SIZE(pmd)	bad_call_to_PMD_PAGE_SIZE()
+#endif
+#ifndef _PAGE_KERNEL_RO
+#define _PAGE_KERNEL_RO	0
+#endif
+#ifndef _PAGE_KERNEL_RW
+#define _PAGE_KERNEL_RW	(_PAGE_DIRTY | _PAGE_RW | _PAGE_HWWRITE)
+#endif
+#ifndef _PAGE_HPTEFLAGS
+#define _PAGE_HPTEFLAGS _PAGE_HASHPTE
+#endif
+#ifndef _PTE_NONE_MASK
+#define _PTE_NONE_MASK	_PAGE_HPTEFLAGS
+#endif
+
+/* Make sure we get a link error if PMD_PAGE_SIZE is ever called on a
+ * kernel without large page PMD support
+ */
+#ifndef __ASSEMBLY__
+extern unsigned long bad_call_to_PMD_PAGE_SIZE(void);
+#endif /* __ASSEMBLY__ */
+
+/* Location of the PFN in the PTE. Most 32-bit platforms use the same
+ * as _PAGE_SHIFT here (ie, naturally aligned).
+ * Platform who don't just pre-define the value so we don't override it here
+ */
+#ifndef PTE_RPN_SHIFT
+#define PTE_RPN_SHIFT	(PAGE_SHIFT)
+#endif
+
+/* The mask convered by the RPN must be a ULL on 32-bit platforms with
+ * 64-bit PTEs
+ */
+#if defined(CONFIG_PPC32) && defined(CONFIG_PTE_64BIT)
+#define PTE_RPN_MAX	(1ULL << (64 - PTE_RPN_SHIFT))
+#define PTE_RPN_MASK	(~((1ULL<<PTE_RPN_SHIFT)-1))
+#else
+#define PTE_RPN_MAX	(1UL << (32 - PTE_RPN_SHIFT))
+#define PTE_RPN_MASK	(~((1UL<<PTE_RPN_SHIFT)-1))
+#endif
+
+/* _PAGE_CHG_MASK masks of bits that are to be preserved accross
+ * pgprot changes
+ */
+#define _PAGE_CHG_MASK	(PTE_RPN_MASK | _PAGE_HPTEFLAGS | _PAGE_DIRTY | \
+                         _PAGE_ACCESSED | _PAGE_SPECIAL)
+
+/* Mask of bits returned by pte_pgprot() */
+#define PAGE_PROT_BITS	(_PAGE_GUARDED | _PAGE_COHERENT | _PAGE_NO_CACHE | \
+			 _PAGE_WRITETHRU | _PAGE_ENDIAN | _PAGE_4K_PFN | \
+			 _PAGE_USER | _PAGE_ACCESSED | \
+			 _PAGE_RW | _PAGE_HWWRITE | _PAGE_DIRTY | \
+			 _PAGE_EXEC | _PAGE_HWEXEC)
+
+/*
+ * We define 2 sets of base prot bits, one for basic pages (ie,
+ * cacheable kernel and user pages) and one for non cacheable
+ * pages. We always set _PAGE_COHERENT when SMP is enabled or
+ * the processor might need it for DMA coherency.
+ */
+#define _PAGE_BASE_NC	(_PAGE_PRESENT | _PAGE_ACCESSED | _PAGE_PSIZE)
+#if defined(CONFIG_SMP) || defined(CONFIG_PPC_STD_MMU)
+#define _PAGE_BASE	(_PAGE_BASE_NC | _PAGE_COHERENT)
+#else
+#define _PAGE_BASE	(_PAGE_BASE_NC)
+#endif
+
+/* Permission masks used to generate the __P and __S table,
+ *
+ * Note:__pgprot is defined in arch/powerpc/include/asm/page.h
+ *
+ * Write permissions imply read permissions for now (we could make write-only
+ * pages on BookE but we don't bother for now). Execute permission control is
+ * possible on platforms that define _PAGE_EXEC
+ *
+ * Note due to the way vm flags are laid out, the bits are XWR
+ */
+#define PAGE_NONE	__pgprot(_PAGE_BASE)
+#define PAGE_SHARED	__pgprot(_PAGE_BASE | _PAGE_USER | _PAGE_RW)
+#define PAGE_SHARED_X	__pgprot(_PAGE_BASE | _PAGE_USER | _PAGE_RW | _PAGE_EXEC)
+#define PAGE_COPY	__pgprot(_PAGE_BASE | _PAGE_USER)
+#define PAGE_COPY_X	__pgprot(_PAGE_BASE | _PAGE_USER | _PAGE_EXEC)
+#define PAGE_READONLY	__pgprot(_PAGE_BASE | _PAGE_USER)
+#define PAGE_READONLY_X	__pgprot(_PAGE_BASE | _PAGE_USER | _PAGE_EXEC)
+
+#define __P000	PAGE_NONE
+#define __P001	PAGE_READONLY
+#define __P010	PAGE_COPY
+#define __P011	PAGE_COPY
+#define __P100	PAGE_READONLY_X
+#define __P101	PAGE_READONLY_X
+#define __P110	PAGE_COPY_X
+#define __P111	PAGE_COPY_X
+
+#define __S000	PAGE_NONE
+#define __S001	PAGE_READONLY
+#define __S010	PAGE_SHARED
+#define __S011	PAGE_SHARED
+#define __S100	PAGE_READONLY_X
+#define __S101	PAGE_READONLY_X
+#define __S110	PAGE_SHARED_X
+#define __S111	PAGE_SHARED_X
+
+/* Permission masks used for kernel mappings */
+#define PAGE_KERNEL	__pgprot(_PAGE_BASE | _PAGE_KERNEL_RW)
+#define PAGE_KERNEL_NC	__pgprot(_PAGE_BASE_NC | _PAGE_KERNEL_RW | \
+				 _PAGE_NO_CACHE)
+#define PAGE_KERNEL_NCG	__pgprot(_PAGE_BASE_NC | _PAGE_KERNEL_RW | \
+				 _PAGE_NO_CACHE | _PAGE_GUARDED)
+#define PAGE_KERNEL_X	__pgprot(_PAGE_BASE | _PAGE_KERNEL_RW | _PAGE_EXEC)
+#define PAGE_KERNEL_RO	__pgprot(_PAGE_BASE | _PAGE_KERNEL_RO)
+#define PAGE_KERNEL_ROX	__pgprot(_PAGE_BASE | _PAGE_KERNEL_RO | _PAGE_EXEC)
+
+/* Protection used for kernel text. We want the debuggers to be able to
+ * set breakpoints anywhere, so don't write protect the kernel text
+ * on platforms where such control is possible.
+ */
+#if defined(CONFIG_KGDB) || defined(CONFIG_XMON) || defined(CONFIG_BDI_SWITCH) ||\
+	defined(CONFIG_KPROBES)
+#define PAGE_KERNEL_TEXT	PAGE_KERNEL_X
+#else
+#define PAGE_KERNEL_TEXT	PAGE_KERNEL_ROX
+#endif
+
+/* Make modules code happy. We don't set RO yet */
+#define PAGE_KERNEL_EXEC	PAGE_KERNEL_X
+
+/* Advertise special mapping type for AGP */
+#define PAGE_AGP		(PAGE_KERNEL_NC)
+#define HAVE_PAGE_AGP
+
+/* Advertise support for _PAGE_SPECIAL */
+#ifdef _PAGE_SPECIAL
+#define __HAVE_ARCH_PTE_SPECIAL
+#endif
+

^ 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