LinuxPPC-Dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
* Re: [PATCH 2/5] [POWERPC] QE: add support for QE USB clocks routing
From: Dale Farnsworth @ 2008-04-17 20:54 UTC (permalink / raw)
  To: Timur Tabi; +Cc: linuxppc-dev
In-Reply-To: <4807B7F7.4020209@freescale.com>

On Thu, Apr 17, 2008 at 03:49:59PM -0500, Timur Tabi wrote:
> Dale Farnsworth wrote:
> > I find "is_brg" much more meaningful than "clk < QE_CLK1".
> > 
> > Maybe the computer doesn't need it, but it's helpful to a
> > reader of the code.
> 
> That's what comments are for.  I'm all for self-documenting code, but not
> creating additional code to avoid comments.

Well, we disagree then.  Self documenting code of this form is far
preferable to comments that communicate the same thing.

-Dale

^ permalink raw reply

* Re: [PATCH 2/5] [POWERPC] QE: add support for QE USB clocks routing
From: Anton Vorontsov @ 2008-04-17 21:48 UTC (permalink / raw)
  To: Timur Tabi; +Cc: linuxppc-dev
In-Reply-To: <4807AB7A.90005@freescale.com>

On Thu, Apr 17, 2008 at 02:56:42PM -0500, Timur Tabi wrote:
> Anton Vorontsov wrote:
> 
> > +config QE_USB
> > +	bool
> > +	help
> > +	  QE USB Host Controller support
> 
> Don't you need something like "depends on USB"?  I would assume that you need
> core USB support before any USB drivers can be loaded.

No, I'll add there "default y if USB_HCD_FHCI", but I'll do this at the
same time as USB_HCD_FHCI merges, because otherwise I would reference not
existent Kconfig symbol.

> > --- /dev/null
> > +++ b/arch/powerpc/sysdev/qe_lib/usb.c
> > @@ -0,0 +1,57 @@
> > +/*
> > + * QE USB routines
> > + *
> > + * Copyright (c) Freescale Semicondutor, Inc. 2006.
> > + *               Shlomi Gridish <gridish@freescale.com>
> 
> Is this code from one of our BSPs?

Well, it is based on. I'm not sure that there is a single line of the
original code, but anyway I'd better be safe than remove someone's
copyright. The same applies to FSL GTM code.

> > +int qe_usb_clock_set(enum qe_clock clk, int rate)
> > +{
> > +	struct qe_mux __iomem *mux = &qe_immr->qmx;
> > +	unsigned long flags;
> > +	const bool is_brg = clk < QE_CLK1;
> 
> You don't really need "is_brg", since it's only used once.

Hm, no. This is code that speaks. More than that, I'd prefer this in
qe.h:

static inline bool qe_clock_is_brg(enum qe_clock clk)
{
	return clk < QE_CLK1;
}

:-)

-- 
Anton Vorontsov
email: cbouatmailru@gmail.com
irc://irc.freenode.net/bd2

^ permalink raw reply

* Re: [PATCH 3/5] [POWERPC] QE: split par_io_config_pin()
From: Kumar Gala @ 2008-04-17 21:53 UTC (permalink / raw)
  To: Anton Vorontsov; +Cc: linuxppc-dev
In-Reply-To: <20080417192850.GC28286@polina.dev.rtsoft.ru>


On Apr 17, 2008, at 2:28 PM, Anton Vorontsov wrote:
> This patch splits par_io_config_pin so we can use it with GPIO LIB  
> API.
>
> Also add a comment regarding #ifdef CONFIG_PPC_85xx being legacy.

legacy to what?

- k

^ permalink raw reply

* Re: [PATCH 2/5] [POWERPC] QE: add support for QE USB clocks routing
From: Timur Tabi @ 2008-04-17 22:00 UTC (permalink / raw)
  To: cbouatmailru; +Cc: linuxppc-dev
In-Reply-To: <20080417214846.GA3161@zarina>

Anton Vorontsov wrote:

> static inline bool qe_clock_is_brg(enum qe_clock clk)
> {
> 	return clk < QE_CLK1;
> }

I have no problem with this function (the UART driver could use it), except that
your implementation is wrong.  You would need to do this:

static inline bool qe_clock_is_brg(enum qe_clock clk)
{
	return (clk >= QE_BRG1) && (clk <= QE_BRG16);
}

-- 
Timur Tabi
Linux kernel developer at Freescale

^ permalink raw reply

* Re: [PATCH 3/5] [POWERPC] QE: split par_io_config_pin()
From: Anton Vorontsov @ 2008-04-17 22:35 UTC (permalink / raw)
  To: Kumar Gala; +Cc: linuxppc-dev
In-Reply-To: <2F36BD63-363C-4BA6-AA42-8002A09FD937@kernel.crashing.org>

On Thu, Apr 17, 2008 at 04:53:34PM -0500, Kumar Gala wrote:
>
> On Apr 17, 2008, at 2:28 PM, Anton Vorontsov wrote:
>> This patch splits par_io_config_pin so we can use it with GPIO LIB  
>> API.
>>
>> Also add a comment regarding #ifdef CONFIG_PPC_85xx being legacy.
>
> legacy to what?

If we'll ever manage to remove pio fixups from the device tree, we then
can safely remove whole par_io_of_config(struct device_node *np) along
with par_io_*(u8 port, ...), which only needs this #ifdef CONFIG_PPC_85xx.
Users (so far only mpc8323e-rdb IIRC) of par_io_data_set(u8 port, ...)
will be converted to GPIO API.

And since device tree fixups considered legacy, I marked this code as
legacy too. Am I wrong here?

-- 
Anton Vorontsov
email: cbouatmailru@gmail.com
irc://irc.freenode.net/bd2

^ permalink raw reply

* Re: [PATCH 4/5] [POWERPC] QE: implement support for the GPIO LIB API
From: Kumar Gala @ 2008-04-17 22:35 UTC (permalink / raw)
  To: Anton Vorontsov; +Cc: linuxppc-dev
In-Reply-To: <20080417192904.GD28286@polina.dev.rtsoft.ru>

> index a3f9c3f..a4a195a 100644
> --- a/arch/powerpc/sysdev/qe_lib/qe_io.c
> +++ b/arch/powerpc/sysdev/qe_lib/qe_io.c
> @@ -20,7 +20,8 @@
> #include <linux/errno.h>
> #include <linux/module.h>
> #include <linux/ioport.h>
> -
> +#include <linux/spinlock.h>
> +#include <linux/of_gpio.h>
> #include <asm/io.h>
> #include <asm/qe.h>
> #include <asm/prom.h>
> @@ -214,6 +215,140 @@ int par_io_of_config(struct device_node *np)
> }
> EXPORT_SYMBOL(par_io_of_config);

can we split this out into a new file since its pretty much a driver.

>
>
> +/*
> + * GPIO LIB API implementation
> + */
> +
> +struct qe_gpio_chip {
> +	struct of_mm_gpio_chip mm_gc;
> +	spinlock_t lock;
> +
> +	/* shadowed data register to clear/set bits safely */
> +	u32 cpdata;
> +};
> +
> +static inline struct qe_gpio_chip *
> +to_qe_gpio_chip(struct of_mm_gpio_chip *mm_gc)
> +{
> +	return container_of(mm_gc, struct qe_gpio_chip, mm_gc);
> +}
> +
> +static void qe_gpio_save_regs(struct of_mm_gpio_chip *mm_gc)
> +{
> +	struct qe_gpio_chip *qe_gc = to_qe_gpio_chip(mm_gc);
> +	struct port_regs __iomem *regs = mm_gc->regs;
> +
> +	qe_gc->cpdata = in_be32(&regs->cpdata);
> +}
> +
> +static int qe_gpio_get(struct gpio_chip *gc, unsigned int gpio)
> +{
> +	struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc);
> +	struct port_regs __iomem *regs = mm_gc->regs;
> +	u32 pin_mask;
> +
> +	/* calculate pin location */
> +	pin_mask = (u32) (1 << (NUM_OF_PINS - 1 - gpio));
> +
> +	return !!(in_be32(&regs->cpdata) & pin_mask);
> +}
> +
> +static void qe_gpio_set(struct gpio_chip *gc, unsigned int gpio,  
> int val)
> +{
> +	struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc);
> +	struct qe_gpio_chip *qe_gc = to_qe_gpio_chip(mm_gc);
> +	struct port_regs __iomem *regs = mm_gc->regs;
> +	unsigned long flags;
> +	u32 pin_mask = 1 << (NUM_OF_PINS - 1 - gpio);
> +
> +	spin_lock_irqsave(&qe_gc->lock, flags);
> +
> +	if (val)
> +		qe_gc->cpdata |= pin_mask;
> +	else
> +		qe_gc->cpdata &= ~pin_mask;
> +
> +	out_be32(&regs->cpdata, qe_gc->cpdata);
> +
> +	spin_unlock_irqrestore(&qe_gc->lock, flags);
> +}
> +
> +static int qe_gpio_dir_in(struct gpio_chip *gc, unsigned int gpio)
> +{
> +	struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc);
> +	struct qe_gpio_chip *qe_gc = to_qe_gpio_chip(mm_gc);
> +	unsigned long flags;
> +
> +	spin_lock_irqsave(&qe_gc->lock, flags);
> +
> +	__par_io_config_pin(mm_gc->regs, gpio, 2, 0, 0, 0);
> +
> +	spin_unlock_irqrestore(&qe_gc->lock, flags);
> +
> +	return 0;
> +}
> +
> +static int qe_gpio_dir_out(struct gpio_chip *gc, unsigned int gpio,  
> int val)
> +{
> +	struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc);
> +	struct qe_gpio_chip *qe_gc = to_qe_gpio_chip(mm_gc);
> +	unsigned long flags;
> +
> +	spin_lock_irqsave(&qe_gc->lock, flags);
> +
> +	__par_io_config_pin(mm_gc->regs, gpio, 1, 0, 0, 0);
> +
> +	spin_unlock_irqrestore(&qe_gc->lock, flags);
> +
> +	qe_gpio_set(gc, gpio, val);
> +
> +	return 0;
> +}
> +
> +static int __init qe_add_gpiochips(void)
> +{
> +	int ret;
> +	struct device_node *np;
> +
> +	for_each_compatible_node(np, NULL, "fsl,qe-pario-bank") {
> +		struct qe_gpio_chip *qe_gc;
> +		struct of_mm_gpio_chip *mm_gc;
> +		struct of_gpio_chip *of_gc;
> +		struct gpio_chip *gc;
> +
> +		qe_gc = kzalloc(sizeof(*qe_gc), GFP_KERNEL);
> +		if (!qe_gc) {
> +			ret = -ENOMEM;
> +			goto err;
> +		}
> +
> +		spin_lock_init(&qe_gc->lock);
> +
> +		mm_gc = &qe_gc->mm_gc;
> +		of_gc = &mm_gc->of_gc;
> +		gc = &of_gc->gc;
> +
> +		mm_gc->save_regs = qe_gpio_save_regs;
> +		of_gc->gpio_cells = 2;
> +		gc->ngpio = NUM_OF_PINS;
> +		gc->direction_input = qe_gpio_dir_in;
> +		gc->direction_output = qe_gpio_dir_out;
> +		gc->get = qe_gpio_get;
> +		gc->set = qe_gpio_set;
> +
> +		ret = of_mm_gpiochip_add(np, mm_gc);
> +		if (ret)
> +			goto err;
> +	}
> +
> +	return 0;
> +err:
> +	pr_err("%s: registration failed with status %d\n", np->full_name,  
> ret);
> +	of_node_put(np);
> +	return ret;
> +}
> +arch_initcall(qe_add_gpiochips);
> +
> #ifdef DEBUG
> static void dump_par_io(void)
> {
> -- 
> 1.5.5

^ permalink raw reply

* Re: [PATCH 4/5] [POWERPC] QE: implement support for the GPIO LIB API
From: Anton Vorontsov @ 2008-04-17 22:41 UTC (permalink / raw)
  To: Kumar Gala; +Cc: linuxppc-dev
In-Reply-To: <A46A6C3E-E5A7-48FB-9B13-475D442F53EC@kernel.crashing.org>

On Thu, Apr 17, 2008 at 05:35:53PM -0500, Kumar Gala wrote:
>> index a3f9c3f..a4a195a 100644
>> --- a/arch/powerpc/sysdev/qe_lib/qe_io.c
>> +++ b/arch/powerpc/sysdev/qe_lib/qe_io.c
>> @@ -20,7 +20,8 @@
>> #include <linux/errno.h>
>> #include <linux/module.h>
>> #include <linux/ioport.h>
>> -
>> +#include <linux/spinlock.h>
>> +#include <linux/of_gpio.h>
>> #include <asm/io.h>
>> #include <asm/qe.h>
>> #include <asm/prom.h>
>> @@ -214,6 +215,140 @@ int par_io_of_config(struct device_node *np)
>> }
>> EXPORT_SYMBOL(par_io_of_config);
>
> can we split this out into a new file since its pretty much a driver.

No problem. Would you prefer this to go under drivers/gpio/ ?

-- 
Anton Vorontsov
email: cbouatmailru@gmail.com
irc://irc.freenode.net/bd2

^ permalink raw reply

* Re: [PATCH 1/5] [POWERPC] sysdev: implement FSL GTM support
From: Anton Vorontsov @ 2008-04-17 22:47 UTC (permalink / raw)
  To: Anton Vorontsov; +Cc: linuxppc-dev
In-Reply-To: <20080417192832.GA28286@polina.dev.rtsoft.ru>

On Thu, Apr 17, 2008 at 11:28:32PM +0400, Anton Vorontsov wrote:
> GTM stands for General-purpose Timers Module and able to generate
> timer{1,2,3,4} interrupts. These timers are used by the drivers that
> need time precise interrupts (like for USB transactions scheduling for
> the Freescale USB Host controller as found in some QE and CPM chips),
> or these timers could be used as wakeup events from the CPU deep-sleep
> mode.
> 
> Things unimplemented:
> 1. Cascaded (32 bit) timers (1-2, 3-4).
>    This is straightforward to implement when needed, two timers should
>    be marked as "requested" and configured as appropriate.
> 2. Super-cascaded (64 bit) timers (1-2-3-4).
>    This is also straightforward to implement when needed, all timers
>    should be marked as "requested" and configured as appropriate.
> 
> Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com>
> ---
>  Documentation/powerpc/booting-without-of.txt |   32 +++-
>  arch/powerpc/Kconfig                         |    5 +
>  arch/powerpc/sysdev/Makefile                 |    1 +
>  arch/powerpc/sysdev/fsl_gtm.c                |  362 ++++++++++++++++++++++++++
>  include/asm-powerpc/fsl_gtm.h                |  108 ++++++++
>  5 files changed, 507 insertions(+), 1 deletions(-)
>  create mode 100644 arch/powerpc/sysdev/fsl_gtm.c
>  create mode 100644 include/asm-powerpc/fsl_gtm.h
> 
> diff --git a/Documentation/powerpc/booting-without-of.txt b/Documentation/powerpc/booting-without-of.txt
> index 4cc7800..827b630 100644
> --- a/Documentation/powerpc/booting-without-of.txt
> +++ b/Documentation/powerpc/booting-without-of.txt
[...]
> +/**
> + * gtm_reset_timer16 - reset 16 bit timer with arbitrary precision
> + * @tmr:	pointer to the gtm_timer structure obtained from gtm_get_timer
> + * @usec:	timer interval in microseconds
> + * @reload:	if set, the timer will reset upon expiry rather than
> + *         	continue running free.
> + *
> + * This function (re)sets the GTM timer so that it counts up to the requested
> + * interval value, and fires the interrupt when the value is reached. This
> + * function will reduce the precision of the timer as needed in order for the
> + * requested timeout to fit in a 16-bit register.
> + */
> +int gtm_reset_timer16(struct gtm_timer *tmr, unsigned long usec, bool reload)
> +{
> +	/* quite obvious, frequency which is enough for µSec precision */
> +	int freq = 1000000;
> +	unsigned int bit;
> +
> +	bit = fls_long(usec);
> +	if (bit > 15) {
> +		freq >>= bit - 15;
> +		usec >>= bit - 15;
> +	}

if (!freq)
	return -EINVAL;

> +	return gtm_reset_ref_timer16(tmr, freq, usec, reload);
> +}
> +EXPORT_SYMBOL(gtm_reset_timer16);

-- 
Anton Vorontsov
email: cbouatmailru@gmail.com
irc://irc.freenode.net/bd2

^ permalink raw reply

* [PATCH] sysdev,mv64x60: initialization of mv64x60 ethernet, serial and I2C
From: Remi Machet @ 2008-04-17 23:35 UTC (permalink / raw)
  To: Paul Mackerras; +Cc: linuxppc-dev

This patch affects only the mv64x60 driver. It fixes 2 problem:

-If one of the devices of the mv64x60 init fails, the remaining 
devices are not initialized => I changed the code to display an
error and continue the initialization.

-I2C parameters freq_m and freq_n are assigned default in the code
but if those properties are not found in the open firmware description 
the init returns an error=> the code now uses the default
values if the properties are not found.

Signed-off-by: Remi Machet (rmachet@slac.stanford.edu)
---

diff --git a/arch/powerpc/sysdev/mv64x60_dev.c b/arch/powerpc/sysdev/mv64x60_dev.c
index 047b310..ef0fc99 100644
--- a/arch/powerpc/sysdev/mv64x60_dev.c
+++ b/arch/powerpc/sysdev/mv64x60_dev.c
@@ -338,15 +338,13 @@ static int __init mv64x60_i2c_device_setup(struct device_node *np, int id)
 
 	pdata.freq_m = 8;	/* default */
 	prop = of_get_property(np, "freq_m", NULL);
-	if (!prop)
-		return -ENODEV;
-	pdata.freq_m = *prop;
+	if (prop)
+		pdata.freq_m = *prop;
 
 	pdata.freq_m = 3;	/* default */
 	prop = of_get_property(np, "freq_n", NULL);
-	if (!prop)
-		return -ENODEV;
-	pdata.freq_n = *prop;
+	if (prop)
+		pdata.freq_n = *prop;
 
 	pdata.timeout = 1000;				/* default: 1 second */
 
@@ -433,9 +431,15 @@ static int __init mv64x60_device_setup(void)
 	int err;
 
 	id = 0;
-	for_each_compatible_node(np, "serial", "marvell,mv64360-mpsc")
-		if ((err = mv64x60_mpsc_device_setup(np, id++)))
-			goto error;
+	for_each_compatible_node(np, "serial", "marvell,mv64360-mpsc") {
+		err = mv64x60_mpsc_device_setup(np, id++);
+		if (err) {
+			printk(KERN_ERR "Failed to initialize MV64x60 " \
+					"serial device %s: error %d.\n",
+					np->full_name, err);
+			of_node_put(np);
+		};
+	};
 
 	id = 0;
 	id2 = 0;
@@ -443,38 +447,48 @@ static int __init mv64x60_device_setup(void)
 		pdev = mv64x60_eth_register_shared_pdev(np, id++);
 		if (IS_ERR(pdev)) {
 			err = PTR_ERR(pdev);
-			goto error;
-		}
+			printk(KERN_ERR "Failed to initialize MV64x60 " \
+					"network block %s: error %d.\n",
+					np->full_name, err);
+			of_node_put(np);
+			continue;
+		};
 		for_each_child_of_node(np, np2) {
 			if (!of_device_is_compatible(np2,
 					"marvell,mv64360-eth"))
 				continue;
 			err = mv64x60_eth_device_setup(np2, id2++, pdev);
 			if (err) {
-				of_node_put(np2);
-				goto error;
+				printk(KERN_ERR "Failed to initialize " \
+						"MV64x60 network device %s: " \
+						"error %d.\n",
+						np2->full_name, err);
 			}
 		}
 	}
 
 	id = 0;
-	for_each_compatible_node(np, "i2c", "marvell,mv64360-i2c")
-		if ((err = mv64x60_i2c_device_setup(np, id++)))
-			goto error;
+	for_each_compatible_node(np, "i2c", "marvell,mv64360-i2c") {
+		err = mv64x60_i2c_device_setup(np, id++);
+		if (err) {
+			printk(KERN_ERR "Failed to initialize MV64x60 I2C " \
+					"bus %s: error %d.\n",
+					np->full_name, err);
+			of_node_put(np);
+		};
+	};
 
 	/* support up to one watchdog timer */
 	np = of_find_compatible_node(np, NULL, "marvell,mv64360-wdt");
 	if (np) {
 		if ((err = mv64x60_wdt_device_setup(np, id)))
-			goto error;
+			printk(KERN_ERR "Failed to initialize MV64x60 " \
+					"Watchdog %s: error %d.\n",
+					np->full_name, err);
 		of_node_put(np);
 	}
 
 	return 0;
-
-error:
-	of_node_put(np);
-	return err;
 }
 arch_initcall(mv64x60_device_setup);
 

^ permalink raw reply related

* eldk and usb to serial converters
From: Daniel Stonier @ 2008-04-18  0:04 UTC (permalink / raw)
  To: Linuxppc-embedded

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

Hi all,

I'm currently trying to compile a kernel for an AMCC440EP board within an
eldk environment. We've got a FTDI usb2serial converter we need to connect
to the board. Now I've compiled a kernel on a gentoo machine for this device
and had no problems. With this board, the kernel recognizes the device fine:

ftdi_sio 1-1:1.0: FTDI USB Serial Device converter detected
usb 1-1: FTDI USB Serial Device converter now attached to ttyUSB0
drivers/usb/serial/ftdi_sio.c: v1.4.3:USB FTDI Serial Converters Driver

but udev doesn't actually make the ttyUSB0 node. If anyone knows what may
have caused the problem and how to fix it, it'd be much appreciated.

Cheers,
Daniel.

[-- Attachment #2: Type: text/html, Size: 735 bytes --]

^ permalink raw reply

* Re: [EFIKA] Really, don't pretend to be CHRP
From: David Gibson @ 2008-04-18  0:17 UTC (permalink / raw)
  To: Matt Sealey; +Cc: linuxppc-dev, David Woodhouse, paulus
In-Reply-To: <48076A00.1080608@genesi-usa.com>

On Thu, Apr 17, 2008 at 04:17:20PM +0100, Matt Sealey wrote:
>
> David Woodhouse wrote:
>> On Thu, 2008-04-17 at 13:28 +0100, Matt Sealey wrote:
>>> I thought we were using efika.forth for this in Fedora.
>>
>> We were, until you pointed out that the kernel actually works just fine
>> these days without it.
>
> I said the kernel has had braindead patches shoved into it that sort of
> obviate the need for the most heinous of crimes committed in the Efika
> device tree.
>
> The Linux kernel fixups don't add the CDM or XLB arbiter or many other
> components some out-of-mainline drivers will need (and should be able
> to just access without writing a fixup first) to map to work properly.
> Adding these will clean up things like the UART module, Sylvain's sleep
> patches will work on Efika, etc.
>
>> can't set environment variables from within Linux (and yes, we can
>> probably improve on that too, but we let them setenv for themselves, for
>> now).
>
> You really won't be improving on it because there's no reliable way to
> pass setenv back to the firmware from userland :D
>
>> That might be a little cleaner than what we have at the moment, yes. But
>> what we have also works, so I'd rather concentrate on things like
>> getting audio support merged, before we faff around with what are
>> essentially cosmetics.
>
> My ideal situation is all this stuff is stripped from the kernel. You do
> realise 90% of the Efika traffic on this list is submitting code that
> fixes fixups for a firmware which has a seperated fixup script, putting
> the responsibility firmly where Linux-PPC policy dictated it should be
> (with the firmware).

That's not Linux-PPC policy as far as I'm concerned.  It's nice if
firmware provides a more-or-less accurate device tree, but we're not
naive enough to think that's actually going to happen.  Firmware
always is, and always will be, crap, so it's expected that the kernel
will have to workaround device tree inaccuracies in the firmware.

Sometimes the simplest way of doing that is just to have workarounds
in the drivers.  Other times, doing that would be ugly and invasive,
so instead the bootwrapper should fixup the device tree before passing
it on to the kernel - this is one of the purposes of the bootwrapper.

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

^ permalink raw reply

* Re: [PATCH] 86xx: mark functions static, other minor cleanups
From: David Gibson @ 2008-04-18  0:35 UTC (permalink / raw)
  To: Paul Gortmaker; +Cc: Scott Wood, Paul Gortmaker, linuxppc-dev, sfr
In-Reply-To: <7d1d9c250804141832pa9c9fbbicf4939c9854dc5f5@mail.gmail.com>

On Mon, Apr 14, 2008 at 09:32:44PM -0400, Paul Gortmaker wrote:
> On Fri, Apr 11, 2008 at 3:11 PM, Segher Boessenkool
> <segher@kernel.crashing.org> wrote:
> >
> > > Updated as per above, and with tickerized prefixes for sbc8641.
> > >
> >
> >  Care to try once more?  It's only "tickerized" if it's in all
> >  uppercase.
> 
> I'm looking at what exists in arch/powerpc/boot/dts/* and I'm
> not seeing too much uppercase - here is a sample:
> 
> ebony.dts:        compatible = "ibm,ebony";
> ep405.dts:        compatible = "ibm,uic";
> ep8248e.dts:    compatible = "fsl,ep8248e";
> bamboo.dts:     compatible = "amcc,bamboo";
> cm5200.dts:     compatible = "schindler,cm5200";
> ep88xc.dts:     compatible = "fsl,ep88xc";
> haleakala.dts:  compatible = "amcc,kilauea";
> holly.dts:         compatible = "ibm,holly";
> katmai.dts:     compatible = "amcc,katmai";
> kilauea.dts:    compatible = "amcc,kilauea";
> lite5200b.dts:  compatible = "fsl,lite5200b";
> motionpro.dts:  compatible = "promess,motionpro";
> mpc8272ads.dts: compatible = "fsl,mpc8272ads";
> mpc866ads.dts:  compatible = "fsl,mpc866ads";
> 
> > > +       compatible = "wind,sbc8641";
> 
> To me this looks in keeping with the rest.  And I prefer
> with the lower case, actually.  (Apparently so do a lot of
> other people...)

The confusion arises due to a difference between historical OF
practice, and current flattened DT practice.

Historically, as Segher says, uppercase names are stock tickers (and
thereby a centrally registered, guaranteed-unique namespace).
Lowercase names are a free-for-all, no central management, put pick a
reasonable name and it will probably be ok.

Use of the formal uppercase names in OF practice isn't particularly
common - there certainly are AAPL, and IBM, names out there but
they're rather outnumbered by the informal lowercase prefixes.  Which
is why most of us doing flattened tree work didn't realise the
distinction.  So, the flattened tree Linux community independently
came up with the convention of using stock tickers as a way of
uniqueifying the names - but used lowercase names.

So, it's a bit of a mess.  Here's my recommended procedure:

	* If you can find a single dominant existing practice for the
vendor in question, use that.  (Consider both OF and flattened tree
practice). i.e. existing practice trumps all.

	* If you can't find any existing practice and need to make a
new prefix, use the stock ticker.

	* If you find more than one existing practice (and none is
clearly dominant), take it to the list and we can argue about it.

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

^ permalink raw reply

* Re: [PATCH 4/5] [POWERPC] QE: implement support for the GPIO LIB API
From: Kumar Gala @ 2008-04-18  2:21 UTC (permalink / raw)
  To: cbouatmailru; +Cc: linuxppc-dev
In-Reply-To: <20080417224106.GA22438@zarina>


On Apr 17, 2008, at 5:41 PM, Anton Vorontsov wrote:
> On Thu, Apr 17, 2008 at 05:35:53PM -0500, Kumar Gala wrote:
>>> index a3f9c3f..a4a195a 100644
>>> --- a/arch/powerpc/sysdev/qe_lib/qe_io.c
>>> +++ b/arch/powerpc/sysdev/qe_lib/qe_io.c
>>> @@ -20,7 +20,8 @@
>>> #include <linux/errno.h>
>>> #include <linux/module.h>
>>> #include <linux/ioport.h>
>>> -
>>> +#include <linux/spinlock.h>
>>> +#include <linux/of_gpio.h>
>>> #include <asm/io.h>
>>> #include <asm/qe.h>
>>> #include <asm/prom.h>
>>> @@ -214,6 +215,140 @@ int par_io_of_config(struct device_node *np)
>>> }
>>> EXPORT_SYMBOL(par_io_of_config);
>>
>> can we split this out into a new file since its pretty much a driver.
>
> No problem. Would you prefer this to go under drivers/gpio/ ?


Yes that would be better.  We actively worked on pull drivers out of  
arch/ppc back in the day.

- k

^ permalink raw reply

* [PATCH] [POWERPC] Port fixmap from x86 and use for kmap_atomic
From: Kumar Gala @ 2008-04-18  2:57 UTC (permalink / raw)
  To: Paul Mackerras; +Cc: linuxppc-dev

The fixmap code from x86 allows us to have compile time virtual addresses
that we change the physical addresses of at run time.

This is useful for applications like kmap_atomic, PCI config that is done
via direct memory map, kexec/kdump.

We got ride of CONFIG_HIGHMEM_START as we can now determine a more optimal
location for PKMAP_BASE based on where the fixmap addresses start and
working back from there.

Additionally, the kmap code in asm-powerpc/highmem.h always had debug
enabled.  Moved to using CONFIG_DEBUG_HIGHMEM to determine if we should
have the extra debug checking.

Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
---
 arch/powerpc/Kconfig          |   14 -----
 arch/powerpc/mm/init_32.c     |    8 ---
 arch/powerpc/mm/mem.c         |   32 ++++++++++--
 arch/powerpc/mm/pgtable_32.c  |   23 ++++++++
 include/asm-powerpc/fixmap.h  |  112 +++++++++++++++++++++++++++++++++++++++++
 include/asm-powerpc/highmem.h |   41 ++++++++-------
 6 files changed, 183 insertions(+), 47 deletions(-)
 create mode 100644 include/asm-powerpc/fixmap.h

diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index 10e9df7..96cc0ad 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -613,20 +613,6 @@ config ADVANCED_OPTIONS
 comment "Default settings for advanced configuration options are used"
 	depends on !ADVANCED_OPTIONS

-config HIGHMEM_START_BOOL
-	bool "Set high memory pool address"
-	depends on ADVANCED_OPTIONS && HIGHMEM
-	help
-	  This option allows you to set the base address of the kernel virtual
-	  area used to map high memory pages.  This can be useful in
-	  optimizing the layout of kernel virtual memory.
-
-	  Say N here unless you know what you are doing.
-
-config HIGHMEM_START
-	hex "Virtual start address of high memory pool" if HIGHMEM_START_BOOL
-	default "0xfe000000"
-
 config LOWMEM_SIZE_BOOL
 	bool "Set maximum low memory"
 	depends on ADVANCED_OPTIONS
diff --git a/arch/powerpc/mm/init_32.c b/arch/powerpc/mm/init_32.c
index 578750e..1952b4d 100644
--- a/arch/powerpc/mm/init_32.c
+++ b/arch/powerpc/mm/init_32.c
@@ -71,14 +71,6 @@ unsigned long agp_special_page;
 EXPORT_SYMBOL(agp_special_page);
 #endif

-#ifdef CONFIG_HIGHMEM
-pte_t *kmap_pte;
-pgprot_t kmap_prot;
-
-EXPORT_SYMBOL(kmap_prot);
-EXPORT_SYMBOL(kmap_pte);
-#endif
-
 void MMU_init(void);

 /* XXX should be in current.h  -- paulus */
diff --git a/arch/powerpc/mm/mem.c b/arch/powerpc/mm/mem.c
index 0062e6b..5ccb579 100644
--- a/arch/powerpc/mm/mem.c
+++ b/arch/powerpc/mm/mem.c
@@ -45,6 +45,7 @@
 #include <asm/tlb.h>
 #include <asm/sections.h>
 #include <asm/vdso.h>
+#include <asm/fixmap.h>

 #include "mmu_decl.h"

@@ -57,6 +58,20 @@ int init_bootmem_done;
 int mem_init_done;
 unsigned long memory_limit;

+#ifdef CONFIG_HIGHMEM
+pte_t *kmap_pte;
+pgprot_t kmap_prot;
+
+EXPORT_SYMBOL(kmap_prot);
+EXPORT_SYMBOL(kmap_pte);
+
+static inline pte_t *virt_to_kpte(unsigned long vaddr)
+{
+	return pte_offset_kernel(pmd_offset(pud_offset(pgd_offset_k(vaddr),
+			vaddr), vaddr), vaddr);
+}
+#endif
+
 int page_is_ram(unsigned long pfn)
 {
 	unsigned long paddr = (pfn << PAGE_SHIFT);
@@ -311,14 +326,19 @@ void __init paging_init(void)
 	unsigned long top_of_ram = lmb_end_of_DRAM();
 	unsigned long max_zone_pfns[MAX_NR_ZONES];

+#ifdef CONFIG_PPC32
+	unsigned long v = __fix_to_virt(__end_of_fixed_addresses - 1);
+	unsigned long end = __fix_to_virt(FIX_HOLE);
+
+	for (; v < end; v += PAGE_SIZE)
+		map_page(v, 0, 0); /* XXX gross */
+#endif
+
 #ifdef CONFIG_HIGHMEM
 	map_page(PKMAP_BASE, 0, 0);	/* XXX gross */
-	pkmap_page_table = pte_offset_kernel(pmd_offset(pud_offset(pgd_offset_k
-			(PKMAP_BASE), PKMAP_BASE), PKMAP_BASE), PKMAP_BASE);
-	map_page(KMAP_FIX_BEGIN, 0, 0);	/* XXX gross */
-	kmap_pte = pte_offset_kernel(pmd_offset(pud_offset(pgd_offset_k
-			(KMAP_FIX_BEGIN), KMAP_FIX_BEGIN), KMAP_FIX_BEGIN),
-			 KMAP_FIX_BEGIN);
+	pkmap_page_table = virt_to_kpte(PKMAP_BASE);
+
+	kmap_pte = virt_to_kpte(__fix_to_virt(FIX_KMAP_BEGIN));
 	kmap_prot = PAGE_KERNEL;
 #endif /* CONFIG_HIGHMEM */

diff --git a/arch/powerpc/mm/pgtable_32.c b/arch/powerpc/mm/pgtable_32.c
index 64c44bc..5d0a601 100644
--- a/arch/powerpc/mm/pgtable_32.c
+++ b/arch/powerpc/mm/pgtable_32.c
@@ -29,6 +29,7 @@

 #include <asm/pgtable.h>
 #include <asm/pgalloc.h>
+#include <asm/fixmap.h>
 #include <asm/io.h>

 #include "mmu_decl.h"
@@ -387,3 +388,25 @@ void kernel_map_pages(struct page *page, int numpages, int enable)
 	change_page_attr(page, numpages, enable ? PAGE_KERNEL : __pgprot(0));
 }
 #endif /* CONFIG_DEBUG_PAGEALLOC */
+
+static int fixmaps;
+unsigned long __FIXADDR_TOP = 0xfffff000;
+EXPORT_SYMBOL(__FIXADDR_TOP);
+
+void __set_fixmap (enum fixed_addresses idx, phys_addr_t phys, pgprot_t flags)
+{
+	unsigned long address = __fix_to_virt(idx);
+
+	if (idx >= __end_of_fixed_addresses) {
+		BUG();
+		return;
+	}
+
+	map_page(address, phys, flags);
+	fixmaps++;
+}
+
+void __this_fixmap_does_not_exist(void)
+{
+	WARN_ON(1);
+}
diff --git a/include/asm-powerpc/fixmap.h b/include/asm-powerpc/fixmap.h
new file mode 100644
index 0000000..f303921
--- /dev/null
+++ b/include/asm-powerpc/fixmap.h
@@ -0,0 +1,112 @@
+/*
+ * fixmap.h: compile-time virtual memory allocation
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
+ * Copyright (C) 1998 Ingo Molnar
+ *
+ * Support of BIGMEM added by Gerhard Wichert, Siemens AG, July 1999
+ *
+ * Copyright 2008 Freescale Semiconductor Inc.
+ *   Port to powerpc added by Kumar Gala
+ */
+
+#ifndef _ASM_FIXMAP_H
+#define _ASM_FIXMAP_H
+
+extern unsigned long __FIXADDR_TOP;
+
+#ifndef __ASSEMBLY__
+#include <linux/kernel.h>
+#include <asm/page.h>
+#ifdef CONFIG_HIGHMEM
+#include <linux/threads.h>
+#include <asm/kmap_types.h>
+#endif
+
+/*
+ * Here we define all the compile-time 'special' virtual
+ * addresses. The point is to have a constant address at
+ * compile time, but to set the physical address only
+ * in the boot process. We allocate these special addresses
+ * from the end of virtual memory (0xfffff000) backwards.
+ * Also this lets us do fail-safe vmalloc(), we
+ * can guarantee that these special addresses and
+ * vmalloc()-ed addresses never overlap.
+ *
+ * these 'compile-time allocated' memory buffers are
+ * fixed-size 4k pages. (or larger if used with an increment
+ * highger than 1) use fixmap_set(idx,phys) to associate
+ * physical memory with fixmap indices.
+ *
+ * TLB entries of such buffers will not be flushed across
+ * task switches.
+ */
+enum fixed_addresses {
+	FIX_HOLE,
+#ifdef CONFIG_HIGHMEM
+	FIX_KMAP_BEGIN,	/* reserved pte's for temporary kernel mappings */
+	FIX_KMAP_END = FIX_KMAP_BEGIN+(KM_TYPE_NR*NR_CPUS)-1,
+#endif
+	/* FIX_PCIE_MCFG, */
+	__end_of_fixed_addresses
+};
+
+extern void __set_fixmap (enum fixed_addresses idx,
+					phys_addr_t phys, pgprot_t flags);
+
+#define set_fixmap(idx, phys) \
+		__set_fixmap(idx, phys, PAGE_KERNEL)
+/*
+ * Some hardware wants to get fixmapped without caching.
+ */
+#define set_fixmap_nocache(idx, phys) \
+		__set_fixmap(idx, phys, PAGE_KERNEL_NOCACHE)
+
+#define clear_fixmap(idx) \
+		__set_fixmap(idx, 0, __pgprot(0))
+
+#define FIXADDR_TOP	((unsigned long)__FIXADDR_TOP)
+
+#define __FIXADDR_SIZE	(__end_of_fixed_addresses << PAGE_SHIFT)
+#define __FIXADDR_BOOT_SIZE	(__end_of_fixed_addresses << PAGE_SHIFT)
+#define FIXADDR_START		(FIXADDR_TOP - __FIXADDR_SIZE)
+#define FIXADDR_BOOT_START	(FIXADDR_TOP - __FIXADDR_BOOT_SIZE)
+
+#define __fix_to_virt(x)	(FIXADDR_TOP - ((x) << PAGE_SHIFT))
+#define __virt_to_fix(x)	((FIXADDR_TOP - ((x)&PAGE_MASK)) >> PAGE_SHIFT)
+
+extern void __this_fixmap_does_not_exist(void);
+
+/*
+ * 'index to address' translation. If anyone tries to use the idx
+ * directly without tranlation, we catch the bug with a NULL-deference
+ * kernel oops. Illegal ranges of incoming indices are caught too.
+ */
+static __always_inline unsigned long fix_to_virt(const unsigned int idx)
+{
+	/*
+	 * this branch gets completely eliminated after inlining,
+	 * except when someone tries to use fixaddr indices in an
+	 * illegal way. (such as mixing up address types or using
+	 * out-of-range indices).
+	 *
+	 * If it doesn't get removed, the linker will complain
+	 * loudly with a reasonably clear error message..
+	 */
+	if (idx >= __end_of_fixed_addresses)
+		__this_fixmap_does_not_exist();
+
+        return __fix_to_virt(idx);
+}
+
+static inline unsigned long virt_to_fix(const unsigned long vaddr)
+{
+	BUG_ON(vaddr >= FIXADDR_TOP || vaddr < FIXADDR_START);
+	return __virt_to_fix(vaddr);
+}
+
+#endif /* !__ASSEMBLY__ */
+#endif
diff --git a/include/asm-powerpc/highmem.h b/include/asm-powerpc/highmem.h
index f7b21ee..d81a088 100644
--- a/include/asm-powerpc/highmem.h
+++ b/include/asm-powerpc/highmem.h
@@ -27,9 +27,7 @@
 #include <asm/kmap_types.h>
 #include <asm/tlbflush.h>
 #include <asm/page.h>
-
-/* undef for production */
-#define HIGHMEM_DEBUG 1
+#include <asm/fixmap.h>

 extern pte_t *kmap_pte;
 extern pgprot_t kmap_prot;
@@ -40,14 +38,12 @@ extern pte_t *pkmap_page_table;
  * easily, subsequent pte tables have to be allocated in one physical
  * chunk of RAM.
  */
-#define PKMAP_BASE 	CONFIG_HIGHMEM_START
 #define LAST_PKMAP 	(1 << PTE_SHIFT)
 #define LAST_PKMAP_MASK (LAST_PKMAP-1)
+#define PKMAP_BASE	((FIXADDR_BOOT_START - PAGE_SIZE*(LAST_PKMAP + 1)) & PMD_MASK)
 #define PKMAP_NR(virt)  ((virt-PKMAP_BASE) >> PAGE_SHIFT)
 #define PKMAP_ADDR(nr)  (PKMAP_BASE + ((nr) << PAGE_SHIFT))

-#define KMAP_FIX_BEGIN	(PKMAP_BASE + 0x00400000UL)
-
 extern void *kmap_high(struct page *page);
 extern void kunmap_high(struct page *page);

@@ -73,7 +69,7 @@ static inline void kunmap(struct page *page)
  * be used in IRQ contexts, so in some (very limited) cases we need
  * it.
  */
-static inline void *kmap_atomic(struct page *page, enum km_type type)
+static inline void *kmap_atomic_prot(struct page *page, enum km_type type, pgprot_t prot)
 {
 	unsigned int idx;
 	unsigned long vaddr;
@@ -84,34 +80,39 @@ static inline void *kmap_atomic(struct page *page, enum km_type type)
 		return page_address(page);

 	idx = type + KM_TYPE_NR*smp_processor_id();
-	vaddr = KMAP_FIX_BEGIN + idx * PAGE_SIZE;
-#ifdef HIGHMEM_DEBUG
-	BUG_ON(!pte_none(*(kmap_pte+idx)));
+	vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
+#ifdef CONFIG_DEBUG_HIGHMEM
+	BUG_ON(!pte_none(*(kmap_pte-idx)));
 #endif
-	set_pte_at(&init_mm, vaddr, kmap_pte+idx, mk_pte(page, kmap_prot));
+	set_pte_at(&init_mm, vaddr, kmap_pte-idx, mk_pte(page, prot));
 	flush_tlb_page(NULL, vaddr);

 	return (void*) vaddr;
 }

+static inline void *kmap_atomic(struct page *page, enum km_type type)
+{
+	return kmap_atomic_prot(page, type, kmap_prot);
+}
+
 static inline void kunmap_atomic(void *kvaddr, enum km_type type)
 {
-#ifdef HIGHMEM_DEBUG
+#ifdef CONFIG_DEBUG_HIGHMEM
 	unsigned long vaddr = (unsigned long) kvaddr & PAGE_MASK;
-	unsigned int idx = type + KM_TYPE_NR*smp_processor_id();
+	enum fixed_addresses idx = type + KM_TYPE_NR*smp_processor_id();

-	if (vaddr < KMAP_FIX_BEGIN) { // FIXME
+	if (vaddr < __fix_to_virt(FIX_KMAP_END)) {
 		pagefault_enable();
 		return;
 	}

-	BUG_ON(vaddr != KMAP_FIX_BEGIN + idx * PAGE_SIZE);
+	BUG_ON(vaddr != __fix_to_virt(FIX_KMAP_BEGIN + idx));

 	/*
 	 * force other mappings to Oops if they'll try to access
 	 * this pte without first remap it
 	 */
-	pte_clear(&init_mm, vaddr, kmap_pte+idx);
+	pte_clear(&init_mm, vaddr, kmap_pte-idx);
 	flush_tlb_page(NULL, vaddr);
 #endif
 	pagefault_enable();
@@ -120,12 +121,14 @@ static inline void kunmap_atomic(void *kvaddr, enum km_type type)
 static inline struct page *kmap_atomic_to_page(void *ptr)
 {
 	unsigned long idx, vaddr = (unsigned long) ptr;
+	pte_t *pte;

-	if (vaddr < KMAP_FIX_BEGIN)
+	if (vaddr < FIXADDR_START)
 		return virt_to_page(ptr);

-	idx = (vaddr - KMAP_FIX_BEGIN) >> PAGE_SHIFT;
-	return pte_page(kmap_pte[idx]);
+	idx = virt_to_fix(vaddr);
+	pte = kmap_pte - (idx - FIX_KMAP_BEGIN);
+	return pte_page(*pte);
 }

 #define flush_cache_kmaps()	flush_cache_all()
-- 
1.5.4.1

^ permalink raw reply related

* Re: problems with 'XPAR_PLB_CLOCK_FREQ_HZ'.
From: Grant Likely @ 2008-04-18  3:14 UTC (permalink / raw)
  To: rodolfo; +Cc: Linuxppc embedded
In-Reply-To: <75c089d6de2ba74b5fdbf6a6fd91e468@lesc.ufc.br>

On Thu, Apr 17, 2008 at 12:15 PM, rodolfo <rodolfo@lesc.ufc.br> wrote:
> Hi, everybody,
>
>  my xparameters_ml300.h does not include 'XPAR_PLB_CLOCK_FREQ_HZ'.
>
>
>   CC      arch/ppc/boot/simple/embed_config.o
>  arch/ppc/boot/simple/embed_config.c: In function 'embed_config':
>  arch/ppc/boot/simple/embed_config.c:781: error: 'XPAR_PLB_CLOCK_FREQ_HZ'
>  undeclared (first use in this function)
>  arch/ppc/boot/simple/embed_config.c:781: error: (Each undeclared identifier
>  is reported only once
>  arch/ppc/boot/simple/embed_config.c:781: error: for each function it
>  appears in.)
>  make[2]: ** [arch/ppc/boot/simple/embed_config.o] Erro 1
>  make[1]: ** [simple] Erro 2
>  make: ** [zImage] Erro 2
>

You probably didn't select the "linux_26" OS target in software
platform settings before generating your xparameters_ml40x.h file.

>
>  Can I replace 'XPAR_PLB_CLOCK_FREQ_HZ' for XPAR_CORE_CLOCK_FREQ_HZ/3
>  knowing that my MHS file description is:

No; that one is different.

Cheers,
g.

-- 
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.

^ permalink raw reply

* RE: [PATCH v2][POWERPC] qe_lib and ucc_geth: switch to the cpm_muram implementation
From: Li Yang @ 2008-04-18  3:29 UTC (permalink / raw)
  To: Wood Scott; +Cc: netdev, linuxppc-dev, Jeff Garzik, Tabi Timur
In-Reply-To: <20080417141043.GA21793@ld0162-tx32.am.freescale.net>

> -----Original Message-----
> From: Wood Scott=20
> Sent: Thursday, April 17, 2008 10:11 PM
> To: Li Yang
> Cc: avorontsov@ru.mvista.com; Kumar Gala;=20
> linuxppc-dev@ozlabs.org; Jeff Garzik; Tabi Timur;=20
> netdev@vger.kernel.org
> Subject: Re: [PATCH v2][POWERPC] qe_lib and ucc_geth: switch=20
> to the cpm_muram implementation
>=20
> On Wed, Apr 16, 2008 at 08:38:19PM -0700, Li Yang wrote:
> > It is a good thing to unify the CPM dpram operation and QE muram=20
> > operation.  But I'm having concerns about the naming as CPM is an=20
> > obsolete block.  Can we change to use the new name QE instead?
>=20
> And then change it again when marketing decides that CPM4=20
> will be called something other than QE2? :-P

It's a good point. :)  Technically they are quite similar.  But they are
not so well known as Pentium to x86.  The change will cause confusion
especially when both of the terms of CPM and QE are used in one file.  I
agree with Kumar's suggestion that we keep both names.

- Leo

^ permalink raw reply

* Re: More patches pushed to powerpc.git master and powerpc-next branches (second try)
From: Michael Ellerman @ 2008-04-18  3:49 UTC (permalink / raw)
  To: Paul Mackerras; +Cc: linuxppc-dev
In-Reply-To: <18438.39830.98206.763623@cargo.ozlabs.ibm.com>

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

Hi Paul,

Can you grab these when you're bored?

http://patchwork.ozlabs.org/linuxppc/patch?q=ellerman&id=17653
http://patchwork.ozlabs.org/linuxppc/patch?q=ellerman&id=17654
http://patchwork.ozlabs.org/linuxppc/patch?q=ellerman&id=17655
http://patchwork.ozlabs.org/linuxppc/patch?q=ellerman&id=17656

BenH might want to Ack them.

cheers

-- 
Michael Ellerman
OzLabs, IBM Australia Development Lab

wwweb: http://michael.ellerman.id.au
phone: +61 2 6212 1183 (tie line 70 21183)

We do not inherit the earth from our ancestors,
we borrow it from our children. - S.M.A.R.T Person

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply

* Re: [PATCH 1/2] Add thread_info_cache_init() to all archs
From: Benjamin Herrenschmidt @ 2008-04-18  3:58 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Linux-Arch, linux-m32r, takata, linux-kernel, linuxppc-dev,
	Paul Mackerras
In-Reply-To: <20080413191338.9776ebd0.akpm@linux-foundation.org>


> > > otoh, if only one .c file will ever call this function then I think that
> > > all problems are solved by
> > > 
> > > a) moving the above ifdeffery into the .c file
> > > b) adding a comment explaining which arch file must provide the override
> > > c) directly including that file from within the .c file.
> > 
> > I can definitely do that. I have no problem either way. I can add to all
> > archs too, it's just that whatever way I choose, some people won't be
> > happy with it :-)
> > 
> > Anyway, I'll move the ifdeferry to init/main.c then.
> 
> Thanks ;)
> 
> I'm still wounded by my recent encounter with set_softirq_pending()
> and or_softirq_pending().

Well, looking there, I saw we already used weak symbols for that so what
about the patch below ? If you're ok, I'll re-send with appropriate sob
& adapted powerpc part.

Cheers,
Ben.

Index: linux-work/init/main.c
===================================================================
--- linux-work.orig/init/main.c	2008-03-26 10:39:25.000000000 +1100
+++ linux-work/init/main.c	2008-04-18 13:10:35.000000000 +1000
@@ -504,6 +504,10 @@ void __init __attribute__((weak)) smp_se
 {
 }
 
+void __init __attribute__((weak) thread_info_cache_init(void)
+{
+}
+
 asmlinkage void __init start_kernel(void)
 {
 	char * command_line;
@@ -623,6 +627,7 @@ asmlinkage void __init start_kernel(void
 	if (efi_enabled)
 		efi_enter_virtual_mode();
 #endif
+	thread_info_cache_init();
 	fork_init(num_physpages);
 	proc_caches_init();
 	buffer_init();
Index: linux-work/include/linux/sched.h
===================================================================
--- linux-work.orig/include/linux/sched.h	2008-04-02 09:47:56.000000000 +1100
+++ linux-work/include/linux/sched.h	2008-04-18 13:11:10.000000000 +1000
@@ -1893,6 +1893,8 @@ static inline unsigned long *end_of_stac
 
 #endif
 
+extern void thread_info_cache_init(void);
+
 /* set thread flags in other task's structures
  * - see asm/thread_info.h for TIF_xxxx flags available
  */

^ permalink raw reply

* Re: [RFC/PATCH 1/4] Move xics_setup_8259_cascade() into platforms/pseries/setup.c
From: Benjamin Herrenschmidt @ 2008-04-18  3:59 UTC (permalink / raw)
  To: Michael Ellerman; +Cc: linuxppc-dev
In-Reply-To: <6840627eab063b5246ec661968986a4ae2d7be61.1207032121.git.michael@ellerman.id.au>


On Tue, 2008-04-01 at 17:42 +1100, Michael Ellerman wrote:
> The code in xics.c to setup the i8259 cascaded irq handler is not really
> xics specific, so move it into setup.c - we will clean this up further in
> a subsequent patch.
> 
> Signed-off-by: Michael Ellerman <michael@ellerman.id.au>

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

> ---
>  arch/powerpc/platforms/pseries/setup.c |   53 +++++++++++++++++++++++++++++++-
>  arch/powerpc/platforms/pseries/xics.c  |   48 -----------------------------
>  arch/powerpc/platforms/pseries/xics.h  |    3 --
>  3 files changed, 52 insertions(+), 52 deletions(-)
> 
> diff --git a/arch/powerpc/platforms/pseries/setup.c b/arch/powerpc/platforms/pseries/setup.c
> index fdb9b1c..43e4801 100644
> --- a/arch/powerpc/platforms/pseries/setup.c
> +++ b/arch/powerpc/platforms/pseries/setup.c
> @@ -127,6 +127,51 @@ void pseries_8259_cascade(unsigned int irq, struct irq_desc *desc)
>  	desc->chip->eoi(irq);
>  }
>  
> +static void __init xics_setup_8259_cascade(void)
> +{
> +	struct device_node *np, *old, *found = NULL;
> +	int cascade, naddr;
> +	const u32 *addrp;
> +	unsigned long intack = 0;
> +
> +	for_each_node_by_type(np, "interrupt-controller")
> +		if (of_device_is_compatible(np, "chrp,iic")) {
> +			found = np;
> +			break;
> +		}
> +	if (found == NULL) {
> +		printk(KERN_DEBUG "xics: no ISA interrupt controller\n");
> +		return;
> +	}
> +	cascade = irq_of_parse_and_map(found, 0);
> +	if (cascade == NO_IRQ) {
> +		printk(KERN_ERR "xics: failed to map cascade interrupt");
> +		return;
> +	}
> +	pr_debug("xics: cascade mapped to irq %d\n", cascade);
> +
> +	for (old = of_node_get(found); old != NULL ; old = np) {
> +		np = of_get_parent(old);
> +		of_node_put(old);
> +		if (np == NULL)
> +			break;
> +		if (strcmp(np->name, "pci") != 0)
> +			continue;
> +		addrp = of_get_property(np, "8259-interrupt-acknowledge", NULL);
> +		if (addrp == NULL)
> +			continue;
> +		naddr = of_n_addr_cells(np);
> +		intack = addrp[naddr-1];
> +		if (naddr > 1)
> +			intack |= ((unsigned long)addrp[naddr-2]) << 32;
> +	}
> +	if (intack)
> +		printk(KERN_DEBUG "xics: PCI 8259 intack at 0x%016lx\n", intack);
> +	i8259_init(found, intack);
> +	of_node_put(found);
> +	set_irq_chained_handler(cascade, pseries_8259_cascade);
> +}
> +
>  static void __init pseries_mpic_init_IRQ(void)
>  {
>  	struct device_node *np, *old, *cascade = NULL;
> @@ -206,6 +251,12 @@ static void __init pseries_mpic_init_IRQ(void)
>  	set_irq_chained_handler(cascade_irq, pseries_8259_cascade);
>  }
>  
> +static void __init pseries_xics_init_IRQ(void)
> +{
> +	xics_init_IRQ();
> +	xics_setup_8259_cascade();
> +}
> +
>  static void pseries_lpar_enable_pmcs(void)
>  {
>  	unsigned long set, reset;
> @@ -235,7 +286,7 @@ static void __init pseries_discover_pic(void)
>  			smp_init_pseries_mpic();
>  			return;
>  		} else if (strstr(typep, "ppc-xicp")) {
> -			ppc_md.init_IRQ       = xics_init_IRQ;
> +			ppc_md.init_IRQ       = pseries_xics_init_IRQ;
>  			setup_kexec_cpu_down_xics();
>  			smp_init_pseries_xics();
>  			return;
> diff --git a/arch/powerpc/platforms/pseries/xics.c b/arch/powerpc/platforms/pseries/xics.c
> index ca52b58..5a72f27 100644
> --- a/arch/powerpc/platforms/pseries/xics.c
> +++ b/arch/powerpc/platforms/pseries/xics.c
> @@ -655,52 +655,6 @@ static void __init xics_init_one_node(struct device_node *np,
>  	}
>  }
>  
> -
> -static void __init xics_setup_8259_cascade(void)
> -{
> -	struct device_node *np, *old, *found = NULL;
> -	int cascade, naddr;
> -	const u32 *addrp;
> -	unsigned long intack = 0;
> -
> -	for_each_node_by_type(np, "interrupt-controller")
> -		if (of_device_is_compatible(np, "chrp,iic")) {
> -			found = np;
> -			break;
> -		}
> -	if (found == NULL) {
> -		printk(KERN_DEBUG "xics: no ISA interrupt controller\n");
> -		return;
> -	}
> -	cascade = irq_of_parse_and_map(found, 0);
> -	if (cascade == NO_IRQ) {
> -		printk(KERN_ERR "xics: failed to map cascade interrupt");
> -		return;
> -	}
> -	pr_debug("xics: cascade mapped to irq %d\n", cascade);
> -
> -	for (old = of_node_get(found); old != NULL ; old = np) {
> -		np = of_get_parent(old);
> -		of_node_put(old);
> -		if (np == NULL)
> -			break;
> -		if (strcmp(np->name, "pci") != 0)
> -			continue;
> -		addrp = of_get_property(np, "8259-interrupt-acknowledge", NULL);
> -		if (addrp == NULL)
> -			continue;
> -		naddr = of_n_addr_cells(np);
> -		intack = addrp[naddr-1];
> -		if (naddr > 1)
> -			intack |= ((unsigned long)addrp[naddr-2]) << 32;
> -	}
> -	if (intack)
> -		printk(KERN_DEBUG "xics: PCI 8259 intack at 0x%016lx\n", intack);
> -	i8259_init(found, intack);
> -	of_node_put(found);
> -	set_irq_chained_handler(cascade, pseries_8259_cascade);
> -}
> -
>  void __init xics_init_IRQ(void)
>  {
>  	struct device_node *np;
> @@ -733,8 +687,6 @@ void __init xics_init_IRQ(void)
>  
>  	xics_setup_cpu();
>  
> -	xics_setup_8259_cascade();
> -
>  	ppc64_boot_msg(0x21, "XICS Done");
>  }
>  
> diff --git a/arch/powerpc/platforms/pseries/xics.h b/arch/powerpc/platforms/pseries/xics.h
> index c26bcff..1c5321a 100644
> --- a/arch/powerpc/platforms/pseries/xics.h
> +++ b/arch/powerpc/platforms/pseries/xics.h
> @@ -28,7 +28,4 @@ struct xics_ipi_struct {
>  
>  extern struct xics_ipi_struct xics_ipi_message[NR_CPUS] __cacheline_aligned;
>  
> -struct irq_desc;
> -extern void pseries_8259_cascade(unsigned int irq, struct irq_desc *desc);
> -
>  #endif /* _POWERPC_KERNEL_XICS_H */

^ permalink raw reply

* Re: [RFC/PATCH 2/4] Turn xics_setup_8259_cascade() into a generic pseries_setup_i8259_cascade()
From: Benjamin Herrenschmidt @ 2008-04-18  4:05 UTC (permalink / raw)
  To: Michael Ellerman; +Cc: linuxppc-dev
In-Reply-To: <f82f14fe5748aa91cafc9341ba02544c05090a28.1207032121.git.michael@ellerman.id.au>


On Tue, 2008-04-01 at 17:42 +1100, Michael Ellerman wrote:
> Remove the xics references from xics_setup_8259_cascade(), and merge the
> good bits from the almost identical logic in pseries_mpic_init_IRQ().
> 
> Signed-off-by: Michael Ellerman <michael@ellerman.id.au>

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

> ---
>  arch/powerpc/platforms/pseries/setup.c |   20 ++++++++++++--------
>  1 files changed, 12 insertions(+), 8 deletions(-)
> 
> diff --git a/arch/powerpc/platforms/pseries/setup.c b/arch/powerpc/platforms/pseries/setup.c
> index 43e4801..1e1faa1 100644
> --- a/arch/powerpc/platforms/pseries/setup.c
> +++ b/arch/powerpc/platforms/pseries/setup.c
> @@ -127,28 +127,32 @@ void pseries_8259_cascade(unsigned int irq, struct irq_desc *desc)
>  	desc->chip->eoi(irq);
>  }
>  
> -static void __init xics_setup_8259_cascade(void)
> +static void __init pseries_setup_i8259_cascade(void)
>  {
>  	struct device_node *np, *old, *found = NULL;
> -	int cascade, naddr;
> +	unsigned int cascade;
>  	const u32 *addrp;
>  	unsigned long intack = 0;
> +	int naddr;
>  
> -	for_each_node_by_type(np, "interrupt-controller")
> +	for_each_node_by_type(np, "interrupt-controller") {
>  		if (of_device_is_compatible(np, "chrp,iic")) {
>  			found = np;
>  			break;
>  		}
> +	}
> +
>  	if (found == NULL) {
> -		printk(KERN_DEBUG "xics: no ISA interrupt controller\n");
> +		printk(KERN_DEBUG "pic: no ISA interrupt controller\n");
>  		return;
>  	}
> +
>  	cascade = irq_of_parse_and_map(found, 0);
>  	if (cascade == NO_IRQ) {
> -		printk(KERN_ERR "xics: failed to map cascade interrupt");
> +		printk(KERN_ERR "pic: failed to map cascade interrupt");
>  		return;
>  	}
> -	pr_debug("xics: cascade mapped to irq %d\n", cascade);
> +	pr_debug("pic: cascade mapped to irq %d\n", cascade);
>  
>  	for (old = of_node_get(found); old != NULL ; old = np) {
>  		np = of_get_parent(old);
> @@ -166,7 +170,7 @@ static void __init xics_setup_8259_cascade(void)
>  			intack |= ((unsigned long)addrp[naddr-2]) << 32;
>  	}
>  	if (intack)
> -		printk(KERN_DEBUG "xics: PCI 8259 intack at 0x%016lx\n", intack);
> +		printk(KERN_DEBUG "pic: PCI 8259 intack at 0x%016lx\n", intack);
>  	i8259_init(found, intack);
>  	of_node_put(found);
>  	set_irq_chained_handler(cascade, pseries_8259_cascade);
> @@ -254,7 +258,7 @@ static void __init pseries_mpic_init_IRQ(void)
>  static void __init pseries_xics_init_IRQ(void)
>  {
>  	xics_init_IRQ();
> -	xics_setup_8259_cascade();
> +	pseries_setup_i8259_cascade();
>  }
>  
>  static void pseries_lpar_enable_pmcs(void)

^ permalink raw reply

* Re: [RFC/PATCH 3/4] Use pseries_setup_i8259_cascade() in pseries_mpic_init_IRQ()
From: Benjamin Herrenschmidt @ 2008-04-18  4:15 UTC (permalink / raw)
  To: Michael Ellerman; +Cc: linuxppc-dev
In-Reply-To: <87206bccf429273c3d7abba408ef606b69bae265.1207032121.git.michael@ellerman.id.au>


On Tue, 2008-04-01 at 17:42 +1100, Michael Ellerman wrote:
> pseries_mpic_init_IRQ() implements the same logic as the xics code did to
> find the i8259 cascade irq. Now that we've pulled that logic out into
> pseries_setup_i8259_cascade() we can use it in the mpic code.
> 
> Signed-off-by: Michael Ellerman <michael@ellerman.id.au>

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

(provided you test it and it works :-)

Ben.

^ permalink raw reply

* Re: [RFC/PATCH 4/4] Simplify xics direct/lpar irq_host setup
From: Benjamin Herrenschmidt @ 2008-04-18  4:16 UTC (permalink / raw)
  To: Michael Ellerman; +Cc: linuxppc-dev
In-Reply-To: <e16ca5457060787c0d339e1b707e75c6f875f7b6.1207032121.git.michael@ellerman.id.au>


On Tue, 2008-04-01 at 17:42 +1100, Michael Ellerman wrote:
> The xics code currently has a direct and lpar variant of xics_host_map, the
> only difference being which irq_chip they use. If we remember which irq_chip
> we're using we can combine these two routines. That also allows us to have a
> single irq_host_ops instead of two.
> 
> Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
> ---

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

^ permalink raw reply

* Re: [PATCH 1/2] Add thread_info_cache_init() to all archs
From: Andrew Morton @ 2008-04-18  4:19 UTC (permalink / raw)
  To: Benjamin Herrenschmidt
  Cc: Linux-Arch, linux-m32r, takata, linux-kernel, linuxppc-dev,
	Paul Mackerras
In-Reply-To: <1208491086.6958.381.camel@pasglop>

On Fri, 18 Apr 2008 13:58:06 +1000 Benjamin Herrenschmidt <benh@ozlabs.org> wrote:

> 
> > > > otoh, if only one .c file will ever call this function then I think that
> > > > all problems are solved by
> > > > 
> > > > a) moving the above ifdeffery into the .c file
> > > > b) adding a comment explaining which arch file must provide the override
> > > > c) directly including that file from within the .c file.
> > > 
> > > I can definitely do that. I have no problem either way. I can add to all
> > > archs too, it's just that whatever way I choose, some people won't be
> > > happy with it :-)
> > > 
> > > Anyway, I'll move the ifdeferry to init/main.c then.
> > 
> > Thanks ;)
> > 
> > I'm still wounded by my recent encounter with set_softirq_pending()
> > and or_softirq_pending().
> 
> Well, looking there, I saw we already used weak symbols for that

Yes, `weak' is a nice solution.  It does add a few bytes of text which we
could avoid with compile-time trickery, but only a very few.

Plus this is __init anyway, although I don't know how well the combination
of `weak' and __init works.


> so what
> about the patch below ?

I like it, but the compiler won't ;)

> If you're ok, I'll re-send with appropriate sob
> & adapted powerpc part.

Sure.

> +void __init __attribute__((weak) thread_info_cache_init(void)

s/weak)/weak))/

^ permalink raw reply

* Re: [PATCH 1/5] [POWERPC] sysdev: implement FSL GTM support
From: Kumar Gala @ 2008-04-18  4:19 UTC (permalink / raw)
  To: cbouatmailru; +Cc: linuxppc-dev
In-Reply-To: <20080417224740.GA25323@zarina>


On Apr 17, 2008, at 5:47 PM, Anton Vorontsov wrote:
> On Thu, Apr 17, 2008 at 11:28:32PM +0400, Anton Vorontsov wrote:
>> GTM stands for General-purpose Timers Module and able to generate
>> timer{1,2,3,4} interrupts. These timers are used by the drivers that
>> need time precise interrupts (like for USB transactions scheduling =20=

>> for
>> the Freescale USB Host controller as found in some QE and CPM chips),
>> or these timers could be used as wakeup events from the CPU deep-=20
>> sleep
>> mode.
>>
>> Things unimplemented:
>> 1. Cascaded (32 bit) timers (1-2, 3-4).
>>   This is straightforward to implement when needed, two timers should
>>   be marked as "requested" and configured as appropriate.
>> 2. Super-cascaded (64 bit) timers (1-2-3-4).
>>   This is also straightforward to implement when needed, all timers
>>   should be marked as "requested" and configured as appropriate.
>>
>> Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com>
>> ---
>> Documentation/powerpc/booting-without-of.txt |   32 +++-
>> arch/powerpc/Kconfig                         |    5 +
>> arch/powerpc/sysdev/Makefile                 |    1 +
>> arch/powerpc/sysdev/fsl_gtm.c                |  362 ++++++++++++++++=20=

>> ++++++++++
>> include/asm-powerpc/fsl_gtm.h                |  108 ++++++++
>> 5 files changed, 507 insertions(+), 1 deletions(-)
>> create mode 100644 arch/powerpc/sysdev/fsl_gtm.c
>> create mode 100644 include/asm-powerpc/fsl_gtm.h
>>
>> diff --git a/Documentation/powerpc/booting-without-of.txt b/=20
>> Documentation/powerpc/booting-without-of.txt
>> index 4cc7800..827b630 100644
>> --- a/Documentation/powerpc/booting-without-of.txt
>> +++ b/Documentation/powerpc/booting-without-of.txt
> [...]
>> +/**
>> + * gtm_reset_timer16 - reset 16 bit timer with arbitrary precision
>> + * @tmr:	pointer to the gtm_timer structure obtained from =20
>> gtm_get_timer
>> + * @usec:	timer interval in microseconds
>> + * @reload:	if set, the timer will reset upon expiry rather than
>> + *         	continue running free.
>> + *
>> + * This function (re)sets the GTM timer so that it counts up to =20
>> the requested
>> + * interval value, and fires the interrupt when the value is =20
>> reached. This
>> + * function will reduce the precision of the timer as needed in =20
>> order for the
>> + * requested timeout to fit in a 16-bit register.
>> + */
>> +int gtm_reset_timer16(struct gtm_timer *tmr, unsigned long usec, =20
>> bool reload)
>> +{
>> +	/* quite obvious, frequency which is enough for =C2=B5Sec =
precision */
>> +	int freq =3D 1000000;
>> +	unsigned int bit;
>> +
>> +	bit =3D fls_long(usec);
>> +	if (bit > 15) {
>> +		freq >>=3D bit - 15;
>> +		usec >>=3D bit - 15;
>> +	}
>
> if (!freq)
> 	return -EINVAL;

do you want me to fix this up on commit or are you going to respin the =20=

patch set based on feedback?

- k=

^ permalink raw reply

* Re: [PATCH 1/2] Add thread_info_cache_init() to all archs
From: Kyle McMartin @ 2008-04-18  4:21 UTC (permalink / raw)
  To: Benjamin Herrenschmidt
  Cc: Linux-Arch, linux-m32r, takata, linux-kernel, linuxppc-dev,
	Paul Mackerras, Andrew Morton
In-Reply-To: <1208491086.6958.381.camel@pasglop>

On Fri, Apr 18, 2008 at 01:58:06PM +1000, Benjamin Herrenschmidt wrote:
> Well, looking there, I saw we already used weak symbols for that so what
> about the patch below ? If you're ok, I'll re-send with appropriate sob
> & adapted powerpc part.
> 

This is definitely the cleanest way to do this from my pov. Although I'm
slightly concerned about the proliferation of weak symbols, I'm much
more concerned with adding more include-order-dependent arch overrides. :)

speaking with the parisc dunce-cap on,
	Kyle

^ 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