LinuxPPC-Dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
* RE: ML405 gigabit ethernet with kernel 2.6.23
From: MingLiu @ 2007-11-08 10:32 UTC (permalink / raw)
  To: kentaro, linuxppc-embedded
In-Reply-To: <4732719A.20707@triumf.ca>

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


Dear Kentaro,
> -------------------------------------------------------------> "netperf -H 192.168.1.1 -t TCP_STREAM" 110 Mbps> "netperf -H 192.168.1.1 -t UDP_STREAM" 210 Mbps> -------------------------------------------------------------
Are these results the ones with or without Jumbo-frame enabled? If no, they are quite good I think. The results from Montavista probably are the ones with Jumbo-frame enabled. 
 
For anybody who has interest on this topic, I have recently an accepted paper which has part of the content on this. The link is http://web.it.kth.se/~mingliu/publications/co_design(icfpt07).pdf and in 6.2 section, I listed our measurement results. 300Mbps for TCP and 400Mbps for UDP, with Jumbo-frame enabled. Unfortunately I did not explain the details and detailed configurations on our case. So these results are only for your reference.
 
BR
Ming
_________________________________________________________________
Windows Live Spaces 中最年轻的成员!
http://miaomiaogarden2007.spaces.live.com/

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

^ permalink raw reply

* Re: [PATCH 2/6] ibm_newemac: Add ET1011c PHY support
From: Josh Boyer @ 2007-11-08 12:08 UTC (permalink / raw)
  To: benh; +Cc: linuxppc-dev, Stefan Roese
In-Reply-To: <1194511344.6561.0.camel@pasglop>

On Thu, 08 Nov 2007 19:42:24 +1100
Benjamin Herrenschmidt <benh@kernel.crashing.org> wrote:

> 
> > > +static struct mii_phy_def et1011c_phy_def = {
> > > +        .phy_id         = 0x0282f000,
> > > +        .phy_id_mask    = 0x0fffff00,
> > > +        .name           = "ET1011C Gigabit Ethernet",
> > > +        .ops            = &et1011c_phy_ops
> > > +};
> > > +
> > > +
> > > +
> > > +
> > > +
> > 
> > Nitpicking: Too many empty lines for my taste.
> 
> Agreed, I though I had removed them, looks like I didn't. Will fix that
> before submitting.

DENX is pretty good about having Signed-off-by lines in their tree...
maybe you should add the original authors as well if it's there.

josh

^ permalink raw reply

* Re: [PATCH] Register AC97 Controller Reference with the platform bus
From: Josh Boyer @ 2007-11-08 13:20 UTC (permalink / raw)
  To: Grant Likely; +Cc: linuxppc-dev, JOFT
In-Reply-To: <20071107161142.7901.51817.stgit@trillian.cg.shawcable.net>

On Wed, 07 Nov 2007 09:14:15 -0700
Grant Likely <grant.likely@secretlab.ca> wrote:

> From: Joachim Foerster <mls.JOFT@gmx.de>
> 
> Add AC97 platform bus registration for Xilinx Virtex platforms.
> 
> Signed-off-by: Joachim Foerster <JOFT@gmx.de>
> Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
> ---
> 
> Josh, can you please pick up this patch into your .24 queue.  I know it's
> arch/ppc, but it is harmless and it is required to get the AC97 device
> driver working on Virtex boards.  It's pretty much a bug fix in that regard.

Will do shortly.  I have a couple other bug fix patches I need to get
out as well.

josh

> 
> Cheers,
> g.
> 
>  arch/ppc/syslib/virtex_devices.c |   31 +++++++++++++++++++++++++++++++
>  1 files changed, 31 insertions(+), 0 deletions(-)
> 
> diff --git a/arch/ppc/syslib/virtex_devices.c b/arch/ppc/syslib/virtex_devices.c
> index 96188f8..95ee313 100644
> --- a/arch/ppc/syslib/virtex_devices.c
> +++ b/arch/ppc/syslib/virtex_devices.c
> @@ -169,6 +169,29 @@
>  	}, \
>  }
> 
> +#define XPAR_AC97_CONTROLLER_REFERENCE(num) { \
> +	.name = "ml403_ac97cr", \
> +	.id = num, \
> +	.num_resources = 3, \
> +	.resource = (struct resource[]) { \
> +		{ \
> +			.start = XPAR_OPB_AC97_CONTROLLER_REF_##num##_BASEADDR, \
> +			.end = XPAR_OPB_AC97_CONTROLLER_REF_##num##_HIGHADDR, \
> +			.flags = IORESOURCE_MEM, \
> +		}, \
> +		{ \
> +			.start = XPAR_OPB_INTC_0_OPB_AC97_CONTROLLER_REF_##num##_PLAYBACK_INTERRUPT_INTR, \
> +			.end = XPAR_OPB_INTC_0_OPB_AC97_CONTROLLER_REF_##num##_PLAYBACK_INTERRUPT_INTR, \
> +			.flags = IORESOURCE_IRQ, \
> +		}, \
> +		{ \
> +			.start = XPAR_OPB_INTC_0_OPB_AC97_CONTROLLER_REF_##num##_RECORD_INTERRUPT_INTR, \
> +			.end = XPAR_OPB_INTC_0_OPB_AC97_CONTROLLER_REF_##num##_RECORD_INTERRUPT_INTR, \
> +			.flags = IORESOURCE_IRQ, \
> +		}, \
> +	}, \
> +}
> +
>  /* UART 8250 driver platform data table */
>  struct plat_serial8250_port virtex_serial_platform_data[] = {
>  #if defined(XPAR_UARTNS550_0_BASEADDR)
> @@ -303,6 +326,14 @@ struct platform_device virtex_platform_devices[] = {
>  #if defined(XPAR_TFT_3_BASEADDR)
>  	XPAR_TFT(3),
>  #endif
> +
> +	/* AC97 Controller Reference instances */
> +#if defined(XPAR_OPB_AC97_CONTROLLER_REF_0_BASEADDR)
> +	XPAR_AC97_CONTROLLER_REFERENCE(0),
> +#endif
> +#if defined(XPAR_OPB_AC97_CONTROLLER_REF_1_BASEADDR)
> +	XPAR_AC97_CONTROLLER_REFERENCE(1),
> +#endif
>  };
> 
>  /* Early serial support functions */
> 

^ permalink raw reply

* Re: Merge dtc
From: Jon Loeliger @ 2007-11-08 13:59 UTC (permalink / raw)
  To: Sam Ravnborg, Milton Miller, ppcdev, Paul Mackerras
In-Reply-To: <20071031024508.GB7772@localhost.localdomain>

David Gibson wrote:
>
> Ok.  I'll use this version in my next spin; except for adding one
> dependency you missed, and removing one which should never have been
> there (unneccessary #include, which I've already fixed in dtc
> upstream).
> 


I think if we embed the DTC in the kernel tree, we should
wait until it supports /dts-v1/ files first.

jdl

^ permalink raw reply

* Re: [PATCH] very similar, now in walnut_setup_arch(); arch/ppc/platforms/4xx/walnut.c
From: Josh Boyer @ 2007-11-08 14:06 UTC (permalink / raw)
  To: Roel Kluin; +Cc: linuxppc-dev
In-Reply-To: <4732397A.8020607@tiscali.nl>

On Wed, 07 Nov 2007 23:17:30 +0100
Roel Kluin <12o3l@tiscali.nl> wrote:

> iounmap kb_data on error
> 
> Signed-off-by: Roel Kluin <12o3l@tiscali.nl>
> ---
> diff --git a/arch/ppc/platforms/4xx/walnut.c b/arch/ppc/platforms/4xx/walnut.c
> index 2f97723..04d3f3f 100644
> --- a/arch/ppc/platforms/4xx/walnut.c
> +++ b/arch/ppc/platforms/4xx/walnut.c
> @@ -81,22 +81,23 @@ walnut_setup_arch(void)
>  	kb_data = ioremap(WALNUT_PS2_BASE, 8);
>  	if (!kb_data) {
>  		printk(KERN_CRIT
>  		       "walnut_setup_arch() kb_data ioremap failed\n");
>  		return;
>  	}
> 
>  	kb_cs = kb_data + 1;
> 
>  	fpga_status = ioremap(PPC40x_FPGA_BASE, 8);
>  	if (!fpga_status) {
> +		iounmap(kb_data);
>  		printk(KERN_CRIT
>  		       "walnut_setup_arch() fpga_status ioremap failed\n");
>  		return;
>  	}

kb_data and fpga_status aren't iounmapped anywhere at all in this
function.  Care to fix that up in addition to the error case?

> 
>  	fpga_enable = fpga_status + 1;
>  	fpga_polarity = fpga_status + 2;
>  	fpga_trigger = fpga_status + 3;
>  	fpga_brdc = fpga_status + 4;
> 
>  	/* split the keyboard and mouse interrupts */
> _______________________________________________
> Linuxppc-dev mailing list
> Linuxppc-dev@ozlabs.org
> https://ozlabs.org/mailman/listinfo/linuxppc-dev

^ permalink raw reply

* Re: [PATCH] another ioremap/iounmap issue in sycamore_setup_arch(); arch/ppc/platforms/4xx/sycamore.c
From: Josh Boyer @ 2007-11-08 14:08 UTC (permalink / raw)
  To: Roel Kluin; +Cc: linuxppc-dev
In-Reply-To: <473238C2.9050402@tiscali.nl>

On Wed, 07 Nov 2007 23:14:26 +0100
Roel Kluin <12o3l@tiscali.nl> wrote:

> not yet tested
> --
> iounmap kb_data on error
> 
> Signed-off-by: Roel Kluin <12o3l@tiscali.nl>
> ---
> diff --git a/arch/ppc/platforms/4xx/sycamore.c b/arch/ppc/platforms/4xx/sycamore.c
> index 8689f3e..c4ac63d 100644
> --- a/arch/ppc/platforms/4xx/sycamore.c
> +++ b/arch/ppc/platforms/4xx/sycamore.c
> @@ -99,22 +99,23 @@ sycamore_setup_arch(void)
>  	kb_data = ioremap(SYCAMORE_PS2_BASE, 8);
>  	if (!kb_data) {
>  		printk(KERN_CRIT
>  		       "sycamore_setup_arch() kb_data ioremap failed\n");
>  		return;
>  	}
> 
>  	kb_cs = kb_data + 1;
> 
>  	fpga_status = ioremap(PPC40x_FPGA_BASE, 8);
>  	if (!fpga_status) {
> +		iounmap(kb_data);
>  		printk(KERN_CRIT
>  		       "sycamore_setup_arch() fpga_status ioremap failed\n");
>  		return;
>  	}

Same comment as the walnut patch.  You can probably fold these two
patches into one.

josh

^ permalink raw reply

* Re: [PATCH] ioremap/iounmap issue in yucca_setup_pcie_fpga_rootpoint(); arch/ppc/platforms/4xx/yucca.c
From: Josh Boyer @ 2007-11-08 14:09 UTC (permalink / raw)
  To: Roel Kluin; +Cc: linuxppc-dev
In-Reply-To: <47323AB8.3060804@tiscali.nl>

On Wed, 07 Nov 2007 23:22:48 +0100
Roel Kluin <12o3l@tiscali.nl> wrote:

> iounmap pcie_reg_fpga_base in default case
> 
> Signed-off-by: Roel Kluin <12o3l@tiscali.nl>

Looks good, thanks.

josh

> ---
> diff --git a/arch/ppc/platforms/4xx/yucca.c b/arch/ppc/platforms/4xx/yucca.c
> index a83b0ba..66a44ff 100644
> --- a/arch/ppc/platforms/4xx/yucca.c
> +++ b/arch/ppc/platforms/4xx/yucca.c
> @@ -211,6 +211,7 @@ static void __init yucca_setup_pcie_fpga_rootpoint(int port)
>  		break;
> 
>  	default:
> +		iounmap(pcie_reg_fpga_base);
>  		return;
>  	}
> 
> _______________________________________________
> Linuxppc-dev mailing list
> Linuxppc-dev@ozlabs.org
> https://ozlabs.org/mailman/listinfo/linuxppc-dev

^ permalink raw reply

* Re: [PATCH] DTC: Polish up the DTS Version 1 implementation.
From: Jon Loeliger @ 2007-11-08 14:13 UTC (permalink / raw)
  To: Jon Loeliger, linuxppc-dev
In-Reply-To: <20071107231942.GA8835@localhost.localdomain>

David Gibson wrote:
> 
> Yes, I know, but I don't think it's even worth having the unused
> internal parameterization.

OK.  We can eliminate it then; no problem.

>
>> I ran my "old versus new DTC" comparison script and found it. :-)
> 
> Heh, we should fold that into the testsuite, too.

I'll start by simply adding the script to the test directory then.



>> Because it wasn't working, as explained in the comment I added.
>> Specifically, (1<<bits), with bits==64 overflowed and yielded
>> the value 0.
> 
> Ah...
> 
> Well, I assumed (1ULL << 64) would equal 0, which is why the
> comparison has the (-1) - I was expecting for bits == 64 it would end
> up being against -1, i.e. 0xffffffffffffffff.  This appears to work on
> the systems I've been using.

But not on an x86 system.

> But I just remembered that (x << n) has undefined behaviour in C when
> n >= word size. 

Exactly.  In fact, I think x86 takes the shift value, bit-wise
ANDs it with 63 internally, and then shifts left by that value.

 So I guess (1 << 64) is just returning garbage - I

In fact, it is yielding 1 on an x86 machine.

> suspect I didn't catch it because I've been building with -O0 for
> gdb-ability, which might change the behaviour of corner cases like
> that.

Or works on a PPC machine? :-)

> So I guess we need
> 	else if ((errno == ERANGE)
> 		 || ((bits < 64) && (val >= (1ULL << bits))))

Sounds good.  I'll commit --amend that into the patch!


>> And in the blue corner, touting consistent hex forms, ...
> 
> And in the red, compact bytestring representations.

> No, seriously, the inconsistency bothers me too.  But so does the fact
> that using 0x in the bytestring would double the minimum size for
> representing bytestrings, somewhat changing the flavour of [] as well
> (because spaces are no longer optional).  I'm looking for a killer
> argument one way or the other, but I haven't found it yet.

But why does it even have to be hex numbers at all?
I guess my point is that they could just be expressions.
You could use 0x31 or 49 or '1' or 061, whichever made
more sense in some application.  You don't necessarily take
a representational size hit.

jdl

^ permalink raw reply

* Re: [PATCH 0/5] fixups for mpc8360 rev. 2.1 erratum #2 (RGMII Timing)
From: Anton Vorontsov @ 2007-11-08 14:16 UTC (permalink / raw)
  To: Kim Phillips; +Cc: netdev, linuxppc-dev, paulus, Li Yang, jgarzik
In-Reply-To: <20071105121530.5c38fbb7.kim.phillips@freescale.com>

On Mon, Nov 05, 2007 at 12:15:30PM -0600, Kim Phillips wrote:
> Hello all,
> 
> the following patches fix RGMII timing for rev. 2.1 of the mpc8360,
> according to erratum #2 (erratum text included below).  Basically the
> most intrusive part is the addition of two new RGMII Internal Delay
> modes; one for TX delay only, and the other for RX delay only (i.e, not
> both at the same time).
> 
> Please review, and since this affects both netdev and powerpc trees,
> one maintainer should ack them for the other to push upstream (i.e,
> Kumar acks them, and Leo picks them up to go through netdev or the
> other way around; either way is fine with me).  I'm hoping they're
> trivial enough to go in 2.6.24.
> 
> Depending on how the review goes, a follow-on patch to u-boot will be
> sent out that fixes up the phy-connection-type in the device tree (from
> "rgmii-id" to "rgmii-rxid" iff on mpc8360rev2.1).

I've upgraded CPU to rev2.1, board rev0.3.

Applied 5/5 patches onto paulus/powerpc.git at e403149c92a. Here is
the results:

If I use -rxid, then geth not able to transmit anything.
With -txid geth not able to receive anything.

With just -id everything works fine though...


Maybe there should be another condition, in addition to cpu rev2.1?

> Thanks,
> 
> Kim
> 
> mpc8360 rev 2.1 erratum #2:
> -----------
> Recommended AC timings for chip 8360Rev2.1 UCC ETH RGMII  when working
> with Rev Pilot MDS for proper RGMII operation:
> 
> IMMR_BASE + 0x14A8[4:5] = 11 (clk delay for UCC 2)
> IMMR_BASE + 0x14A8[18:19] = 11 (clk delay for UCC 1)
> IMMR_BASE + 0x14AC[20:27] = 10101010 (data delay for both UCC's)
> 
> The Phy (Marvell 88e1111) should be configured NOT to work with RGMII
> delay for TxD.

Thanks,

-- 
Anton Vorontsov
email: cbou@mail.ru
backup email: ya-cbou@yandex.ru
irc://irc.freenode.net/bd2

^ permalink raw reply

* Re: [PATCH 4/4] Kill flatdevtree.c
From: Jon Loeliger @ 2007-11-08 14:27 UTC (permalink / raw)
  To: David Gibson; +Cc: linuxppc-dev, Paul Mackerras
In-Reply-To: <20071108033603.B6377DDE0E@ozlabs.org>

David Gibson wrote:
> Now that earlier patches have switched the bootwrapper to using libfdt
> for device tree manipulation, this patch removes the now unused
> flatdevtree.c and related files.
> 
> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
> 
> ---
>  arch/powerpc/boot/Makefile           |    2 
>  arch/powerpc/boot/flatdevtree.c      | 1036 -----------------------------------
>  arch/powerpc/boot/flatdevtree.h      |  113 ---
>  arch/powerpc/boot/flatdevtree_misc.c |   79 --
>  arch/powerpc/boot/main.c             |    1 
>  arch/powerpc/boot/ops.h              |    1 
>  6 files changed, 1 insertion(+), 1231 deletions(-)

This sort of patch really appears a lot cleaner and nicer
using git and the -M flag to simply state which files
are removed outright.

*sigh*

jdl

^ permalink raw reply

* [PATCH] powerpc: fix powersave-nap sysctl registration
From: Johannes Berg @ 2007-11-07 19:11 UTC (permalink / raw)
  To: Paul Mackerras; +Cc: Eric W. Biederman, linuxppc-dev list

The sysctl check code complains about a writable directory,
fix it.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Cc: Eric W. Biederman <ebiederm@xmission.com>
---
 arch/powerpc/kernel/idle.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- everything.orig/arch/powerpc/kernel/idle.c	2007-11-07 19:54:56.787884927 +0100
+++ everything/arch/powerpc/kernel/idle.c	2007-11-07 20:00:27.965924749 +0100
@@ -122,7 +122,7 @@ static ctl_table powersave_nap_sysctl_ro
 	{
 		.ctl_name	= CTL_KERN,
 		.procname	= "kernel",
-		.mode		= 0755,
+		.mode		= 0555,
 		.child		= powersave_nap_ctl_table,
 	},
 	{}

^ permalink raw reply

* [RFC] PMU: remove dead code
From: Johannes Berg @ 2007-11-08 12:00 UTC (permalink / raw)
  To: Benjamin Herrenschmidt; +Cc: linuxppc-dev list

Some code in via-pmu.c is never compiled because of "compile options"
within the file. Remove the code completely.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
---
 drivers/macintosh/via-pmu.c |   42 +-----------------------------------------
 1 file changed, 1 insertion(+), 41 deletions(-)

--- everything.orig/drivers/macintosh/via-pmu.c	2007-11-08 11:47:42.332847765 +0100
+++ everything/drivers/macintosh/via-pmu.c	2007-11-08 11:48:37.192845813 +0100
@@ -65,9 +65,7 @@
 #include "via-pmu-event.h"
 
 /* Some compile options */
-#undef SUSPEND_USES_PMU
 #define DEBUG_SLEEP
-#undef HACKED_PCI_SAVE
 
 /* Misc minor number allocated for /dev/pmu */
 #define PMU_MINOR		154
@@ -1255,9 +1253,7 @@ void
 pmu_suspend(void)
 {
 	unsigned long flags;
-#ifdef SUSPEND_USES_PMU
-	struct adb_request *req;
-#endif
+
 	if (!via)
 		return;
 	
@@ -1275,17 +1271,10 @@ pmu_suspend(void)
 		via_pmu_interrupt(0, NULL);
 		spin_lock_irqsave(&pmu_lock, flags);
 		if (!adb_int_pending && pmu_state == idle && !req_awaiting_reply) {
-#ifdef SUSPEND_USES_PMU
-			pmu_request(&req, NULL, 2, PMU_SET_INTR_MASK, 0);
-			spin_unlock_irqrestore(&pmu_lock, flags);
-			while(!req.complete)
-				pmu_poll();
-#else /* SUSPEND_USES_PMU */
 			if (gpio_irq >= 0)
 				disable_irq_nosync(gpio_irq);
 			out_8(&via[IER], CB1_INT | IER_CLR);
 			spin_unlock_irqrestore(&pmu_lock, flags);
-#endif /* SUSPEND_USES_PMU */
 			break;
 		}
 	} while (1);
@@ -1306,18 +1295,11 @@ pmu_resume(void)
 		return;
 	}
 	adb_int_pending = 1;
-#ifdef SUSPEND_USES_PMU
-	pmu_request(&req, NULL, 2, PMU_SET_INTR_MASK, pmu_intr_mask);
-	spin_unlock_irqrestore(&pmu_lock, flags);
-	while(!req.complete)
-		pmu_poll();
-#else /* SUSPEND_USES_PMU */
 	if (gpio_irq >= 0)
 		enable_irq(gpio_irq);
 	out_8(&via[IER], CB1_INT | IER_SET);
 	spin_unlock_irqrestore(&pmu_lock, flags);
 	pmu_poll();
-#endif /* SUSPEND_USES_PMU */
 }
 
 /* Interrupt data could be the result data from an ADB cmd */
@@ -1743,14 +1725,10 @@ pmu_present(void)
  * PCI devices which may get powered off when we sleep.
  */
 static struct pci_save {
-#ifndef HACKED_PCI_SAVE
 	u16	command;
 	u16	cache_lat;
 	u16	intr;
 	u32	rom_address;
-#else
-	u32	config[16];
-#endif	
 } *pbook_pci_saves;
 static int pbook_npci_saves;
 
@@ -1796,16 +1774,10 @@ pbook_pci_save(void)
 			pci_dev_put(pd);
 			return;
 		}
-#ifndef HACKED_PCI_SAVE
 		pci_read_config_word(pd, PCI_COMMAND, &ps->command);
 		pci_read_config_word(pd, PCI_CACHE_LINE_SIZE, &ps->cache_lat);
 		pci_read_config_word(pd, PCI_INTERRUPT_LINE, &ps->intr);
 		pci_read_config_dword(pd, PCI_ROM_ADDRESS, &ps->rom_address);
-#else
-		int i;
-		for (i=1;i<16;i++)
-			pci_read_config_dword(pd, i<<4, &ps->config[i]);
-#endif
 		++ps;
 	}
 }
@@ -1824,17 +1796,6 @@ pbook_pci_restore(void)
 	int j;
 
 	while ((pd = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, pd)) != NULL) {
-#ifdef HACKED_PCI_SAVE
-		int i;
-		if (npci-- == 0) {
-			pci_dev_put(pd);
-			return;
-		}
-		ps++;
-		for (i=2;i<16;i++)
-			pci_write_config_dword(pd, i<<4, ps->config[i]);
-		pci_write_config_dword(pd, 4, ps->config[1]);
-#else
 		if (npci-- == 0)
 			return;
 		ps++;
@@ -1858,7 +1819,6 @@ pbook_pci_restore(void)
 			pci_write_config_word(pd, PCI_COMMAND, ps->command);
 			break;
 		}
-#endif	
 	}
 }
 

^ permalink raw reply

* [RFC] PMU: don't lock_kernel()
From: Johannes Berg @ 2007-11-08 12:01 UTC (permalink / raw)
  To: Benjamin Herrenschmidt; +Cc: linuxppc-dev list

I see nothing that this lock_kernel() actually protects against
so remove it.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
---
 drivers/macintosh/via-pmu.c |    3 ---
 1 file changed, 3 deletions(-)

--- everything.orig/drivers/macintosh/via-pmu.c	2007-11-08 11:48:37.192845813 +0100
+++ everything/drivers/macintosh/via-pmu.c	2007-11-08 11:48:48.292846681 +0100
@@ -33,7 +33,6 @@
 #include <linux/adb.h>
 #include <linux/pmu.h>
 #include <linux/cuda.h>
-#include <linux/smp_lock.h>
 #include <linux/module.h>
 #include <linux/spinlock.h>
 #include <linux/pm.h>
@@ -2436,7 +2435,6 @@ pmu_release(struct inode *inode, struct 
 	struct pmu_private *pp = file->private_data;
 	unsigned long flags;
 
-	lock_kernel();
 	if (pp != 0) {
 		file->private_data = NULL;
 		spin_lock_irqsave(&all_pvt_lock, flags);
@@ -2450,7 +2448,6 @@ pmu_release(struct inode *inode, struct 
 
 		kfree(pp);
 	}
-	unlock_kernel();
 	return 0;
 }
 

^ permalink raw reply

* [RFC] PMU: replace information ioctls and schedule for removal
From: Johannes Berg @ 2007-11-08 12:02 UTC (permalink / raw)
  To: Benjamin Herrenschmidt; +Cc: linuxppc-dev list

This patch adds sysfs attributes to the PMU to allow getting
the information on the PMU type and whether adb is present from
there instead of via the ioctl. The ioctl is made optional and
scheduled for removal.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
---
 Documentation/feature-removal-schedule.txt |    8 ++++++
 drivers/macintosh/Kconfig                  |   11 ++++++++
 drivers/macintosh/via-pmu.c                |   36 +++++++++++++++++++++++++++++
 3 files changed, 55 insertions(+)

--- everything.orig/drivers/macintosh/via-pmu.c	2007-11-08 11:48:48.292846681 +0100
+++ everything/drivers/macintosh/via-pmu.c	2007-11-08 11:48:53.112861818 +0100
@@ -2533,10 +2533,12 @@ pmu_ioctl(struct inode * inode, struct f
 #endif /* CONFIG_INPUT_ADBHID */
 #endif /* CONFIG_PMAC_BACKLIGHT_LEGACY */
 
+#ifdef CONFIG_DEPRECATED_PMU_INFO_IOCTLS
 	case PMU_IOC_GET_MODEL:
 	    	return put_user(pmu_kind, argp);
 	case PMU_IOC_HAS_ADB:
 		return put_user(pmu_has_adb, argp);
+#endif
 	}
 	return error;
 }
@@ -2680,6 +2682,39 @@ static int pmu_sys_resume(struct sys_dev
 
 #endif /* CONFIG_PM_SLEEP && CONFIG_PPC32 */
 
+static ssize_t show_kind(struct sys_device *sysdev, char *buf)
+{
+	return sprintf(buf, "%d\n", pmu_kind);
+}
+
+static ssize_t show_has_adb(struct sys_device *sysdev, char *buf)
+{
+	return sprintf(buf, "%d\n", pmu_has_adb);
+}
+
+static SYSDEV_ATTR(kind, 0444, show_kind, NULL);
+static SYSDEV_ATTR(has_adb, 0444, show_has_adb, NULL);
+
+int pmu_sys_add(struct sys_device *sysdev)
+{
+	int err;
+
+	err = sysdev_create_file(sysdev, &attr_kind);
+	if (err)
+		goto out;
+
+	err = sysdev_create_file(sysdev, &attr_has_adb);
+	if (err)
+		goto out_remove_kind;
+
+	return 0;
+
+ out_remove_kind:
+	sysdev_remove_file(sysdev, &attr_kind);
+ out:
+	return err;
+}
+
 static struct sysdev_class pmu_sysclass = {
 	set_kset_name("pmu"),
 };
@@ -2693,6 +2728,7 @@ static struct sysdev_driver driver_pmu =
 	.suspend	= &pmu_sys_suspend,
 	.resume		= &pmu_sys_resume,
 #endif /* CONFIG_PM_SLEEP && CONFIG_PPC32 */
+	.add		= &pmu_sys_add,
 };
 
 static int __init init_pmu_sysfs(void)
--- everything.orig/Documentation/feature-removal-schedule.txt	2007-11-08 11:47:39.502844564 +0100
+++ everything/Documentation/feature-removal-schedule.txt	2007-11-08 11:48:53.122870607 +0100
@@ -342,3 +342,11 @@ Why:	This driver has been marked obsolet
 Who:	Stephen Hemminger <shemminger@linux-foundation.org>
 
 ---------------------------
+
+What:	/dev/pmu information ioctls
+When:	January 2010
+Files:	drivers/macintosh/via-pmu.c
+Why:	The PMU information can be obtained from sysfs now.
+Who:	Johannes Berg <johannes@sipsolutions.net>
+
+---------------------------
--- everything.orig/drivers/macintosh/Kconfig	2007-11-08 11:47:39.422844727 +0100
+++ everything/drivers/macintosh/Kconfig	2007-11-08 11:48:53.122870607 +0100
@@ -87,6 +87,17 @@ config ADB_PMU
 	  this device; you should do so if your machine is one of those
 	  mentioned above.
 
+config DEPRECATED_PMU_INFO_IOCTLS
+	bool "Support deprecated PMU information ioctl"
+	depends on ADB_PMU
+	default y
+	help
+	  The PMU ioctl supports getting information on the type of PMU and
+	  whether an ADB is present. This information is also available in
+	  sysfs so this ioctl is no longer needed.
+
+	  If in doubt, say Y even if you will not use the ioctl.
+
 config ADB_PMU_LED
 	bool "Support for the Power/iBook front LED"
 	depends on ADB_PMU

^ permalink raw reply

* [RFC] powermac: proper sleep management
From: Johannes Berg @ 2007-11-08 12:08 UTC (permalink / raw)
  To: linuxppc-dev list; +Cc: linux-pm, David Woodhouse, Paul Mackerras

This adds platform_suspend_ops for PMU based machines, directly in
the PMU driver. This finally allows suspending via /sys/power/state
on powerbooks.

The patch also replaces the PMU ioctl with a simple call to
pm_suspend(PM_SUSPEND_MEM) and puts the sleep-related PMU ioctls onto
the feature-removal schedule, to be removed in early 2010 (just
over two years from now).

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
---
Just thought I'd send out the patch again, it has changed quite a bit
since last time because I cleaned up the code, made it depend on
CONFIG_SUSPEND, made the ioctl backward compatibility optional and some
other bits.

The feared freezer vs. fuse sync deadlock is no longer present in 2.6.24
because the sync is done before the freezer so maybe the patch stands a
chance now.

Scott: FYI, here's the use case for the ppc_md irq suspend/resume hooks.

 Documentation/feature-removal-schedule.txt |   10 
 drivers/macintosh/Kconfig                  |   12 
 drivers/macintosh/via-pmu.c                |  511 ++++++++++-------------------
 3 files changed, 207 insertions(+), 326 deletions(-)

--- everything.orig/drivers/macintosh/via-pmu.c	2007-11-08 11:48:53.112861818 +0100
+++ everything/drivers/macintosh/via-pmu.c	2007-11-08 11:49:21.592846626 +0100
@@ -10,13 +10,13 @@
  *
  * Copyright (C) 1998 Paul Mackerras and Fabio Riccardi.
  * Copyright (C) 2001-2002 Benjamin Herrenschmidt
+ * Copyright (C) 2006-2007 Johannes Berg
  *
  * THIS DRIVER IS BECOMING A TOTAL MESS !
  *  - Cleanup atomically disabling reply to PMU events after
  *    a sleep or a freq. switch
- *  - Move sleep code out of here to pmac_pm, merge into new
- *    common PM infrastructure
- *  - Save/Restore PCI space properly
+ *  - check if powerbook 3400 really needs the extra PCI
+ *    save/restore code we have
  *
  */
 #include <stdarg.h>
@@ -63,9 +63,6 @@
 
 #include "via-pmu-event.h"
 
-/* Some compile options */
-#define DEBUG_SLEEP
-
 /* Misc minor number allocated for /dev/pmu */
 #define PMU_MINOR		154
 
@@ -149,12 +146,9 @@ static spinlock_t pmu_lock;
 static u8 pmu_intr_mask;
 static int pmu_version;
 static int drop_interrupts;
-#if defined(CONFIG_PM_SLEEP) && defined(CONFIG_PPC32)
+#if defined(CONFIG_SUSPEND) && defined(CONFIG_PPC32)
 static int option_lid_wakeup = 1;
-#endif /* CONFIG_PM_SLEEP && CONFIG_PPC32 */
-#if (defined(CONFIG_PM_SLEEP)&&defined(CONFIG_PPC32))||defined(CONFIG_PMAC_BACKLIGHT_LEGACY)
-static int sleep_in_progress;
-#endif
+#endif /* CONFIG_SUSPEND && CONFIG_PPC32 */
 static unsigned long async_req_locks;
 static unsigned int pmu_irq_stats[11];
 
@@ -218,11 +212,6 @@ extern void low_sleep_handler(void);
 extern void enable_kernel_altivec(void);
 extern void enable_kernel_fp(void);
 
-#ifdef DEBUG_SLEEP
-int pmu_polled_request(struct adb_request *req);
-int pmu_wink(struct adb_request *req);
-#endif
-
 /*
  * This table indicates for each PMU opcode:
  * - the number of data bytes to be sent with the command, or -1
@@ -871,7 +860,7 @@ proc_read_options(char *page, char **sta
 {
 	char *p = page;
 
-#if defined(CONFIG_PM_SLEEP) && defined(CONFIG_PPC32)
+#if defined(CONFIG_SUSPEND) && defined(CONFIG_PPC32)
 	if (pmu_kind == PMU_KEYLARGO_BASED &&
 	    pmac_call_feature(PMAC_FTR_SLEEP_STATE,NULL,0,-1) >= 0)
 		p += sprintf(p, "lid_wakeup=%d\n", option_lid_wakeup);
@@ -912,7 +901,7 @@ proc_write_options(struct file *file, co
 	*(val++) = 0;
 	while(*val == ' ')
 		val++;
-#if defined(CONFIG_PM_SLEEP) && defined(CONFIG_PPC32)
+#if defined(CONFIG_SUSPEND) && defined(CONFIG_PPC32)
 	if (pmu_kind == PMU_KEYLARGO_BASED &&
 	    pmac_call_feature(PMAC_FTR_SLEEP_STATE,NULL,0,-1) >= 0)
 		if (!strcmp(label, "lid_wakeup"))
@@ -1718,7 +1707,7 @@ pmu_present(void)
 	return via != 0;
 }
 
-#if defined(CONFIG_PM_SLEEP) && defined(CONFIG_PPC32)
+#if defined(CONFIG_SUSPEND) && defined(CONFIG_PPC32)
 /*
  * This struct is used to store config register values for
  * PCI devices which may get powered off when we sleep.
@@ -1821,43 +1810,6 @@ pbook_pci_restore(void)
 	}
 }
 
-#ifdef DEBUG_SLEEP
-/* N.B. This doesn't work on the 3400 */
-void 
-pmu_blink(int n)
-{
-	struct adb_request req;
-
-	memset(&req, 0, sizeof(req));
-
-	for (; n > 0; --n) {
-		req.nbytes = 4;
-		req.done = NULL;
-		req.data[0] = 0xee;
-		req.data[1] = 4;
-		req.data[2] = 0;
-		req.data[3] = 1;
-		req.reply[0] = ADB_RET_OK;
-		req.reply_len = 1;
-		req.reply_expected = 0;
-		pmu_polled_request(&req);
-		mdelay(50);
-		req.nbytes = 4;
-		req.done = NULL;
-		req.data[0] = 0xee;
-		req.data[1] = 4;
-		req.data[2] = 0;
-		req.data[3] = 0;
-		req.reply[0] = ADB_RET_OK;
-		req.reply_len = 1;
-		req.reply_expected = 0;
-		pmu_polled_request(&req);
-		mdelay(50);
-	}
-	mdelay(50);
-}
-#endif
-
 /*
  * Put the powerbook to sleep.
  */
@@ -1894,122 +1846,6 @@ restore_via_state(void)
 
 extern void pmu_backlight_set_sleep(int sleep);
 
-static int
-pmac_suspend_devices(void)
-{
-	int ret;
-
-	pm_prepare_console();
-	
-	/* Sync the disks. */
-	/* XXX It would be nice to have some way to ensure that
-	 * nobody is dirtying any new buffers while we wait. That
-	 * could be achieved using the refrigerator for processes
-	 * that swsusp uses
-	 */
-	sys_sync();
-
-	/* Send suspend call to devices, hold the device core's dpm_sem */
-	ret = device_suspend(PMSG_SUSPEND);
-	if (ret) {
-		printk(KERN_ERR "Driver sleep failed\n");
-		return -EBUSY;
-	}
-
-#ifdef CONFIG_PMAC_BACKLIGHT
-	/* Tell backlight code not to muck around with the chip anymore */
-	pmu_backlight_set_sleep(1);
-#endif
-
-	/* Call platform functions marked "on sleep" */
-	pmac_pfunc_i2c_suspend();
-	pmac_pfunc_base_suspend();
-
-	/* Stop preemption */
-	preempt_disable();
-
-	/* Make sure the decrementer won't interrupt us */
-	asm volatile("mtdec %0" : : "r" (0x7fffffff));
-	/* Make sure any pending DEC interrupt occurring while we did
-	 * the above didn't re-enable the DEC */
-	mb();
-	asm volatile("mtdec %0" : : "r" (0x7fffffff));
-
-	/* We can now disable MSR_EE. This code of course works properly only
-	 * on UP machines... For SMP, if we ever implement sleep, we'll have to
-	 * stop the "other" CPUs way before we do all that stuff.
-	 */
-	local_irq_disable();
-
-	/* Broadcast power down irq
-	 * This isn't that useful in most cases (only directly wired devices can
-	 * use this but still... This will take care of sysdev's as well, so
-	 * we exit from here with local irqs disabled and PIC off.
-	 */
-	ret = device_power_down(PMSG_SUSPEND);
-	if (ret) {
-		wakeup_decrementer();
-		local_irq_enable();
-		preempt_enable();
-		device_resume();
-		printk(KERN_ERR "Driver powerdown failed\n");
-		return -EBUSY;
-	}
-
-	/* Wait for completion of async requests */
-	while (!batt_req.complete)
-		pmu_poll();
-
-	/* Giveup the lazy FPU & vec so we don't have to back them
-	 * up from the low level code
-	 */
-	enable_kernel_fp();
-
-#ifdef CONFIG_ALTIVEC
-	if (cpu_has_feature(CPU_FTR_ALTIVEC))
-		enable_kernel_altivec();
-#endif /* CONFIG_ALTIVEC */
-
-	return 0;
-}
-
-static int
-pmac_wakeup_devices(void)
-{
-	mdelay(100);
-
-#ifdef CONFIG_PMAC_BACKLIGHT
-	/* Tell backlight code it can use the chip again */
-	pmu_backlight_set_sleep(0);
-#endif
-
-	/* Power back up system devices (including the PIC) */
-	device_power_up();
-
-	/* Force a poll of ADB interrupts */
-	adb_int_pending = 1;
-	via_pmu_interrupt(0, NULL);
-
-	/* Restart jiffies & scheduling */
-	wakeup_decrementer();
-
-	/* Re-enable local CPU interrupts */
-	local_irq_enable();
-	mdelay(10);
-	preempt_enable();
-
-	/* Call platform functions marked "on wake" */
-	pmac_pfunc_base_resume();
-	pmac_pfunc_i2c_resume();
-
-	/* Resume devices */
-	device_resume();
-
-	pm_restore_console();
-
-	return 0;
-}
-
 #define	GRACKLE_PM	(1<<7)
 #define GRACKLE_DOZE	(1<<5)
 #define	GRACKLE_NAP	(1<<4)
@@ -2020,19 +1856,12 @@ static int powerbook_sleep_grackle(void)
 	unsigned long save_l2cr;
 	unsigned short pmcr1;
 	struct adb_request req;
-	int ret;
 	struct pci_dev *grackle;
 
 	grackle = pci_get_bus_and_slot(0, 0);
 	if (!grackle)
 		return -ENODEV;
 
-	ret = pmac_suspend_devices();
-	if (ret) {
-		printk(KERN_ERR "Sleep rejected by devices\n");
-		return ret;
-	}
-	
 	/* Turn off various things. Darwin does some retry tests here... */
 	pmu_request(&req, NULL, 2, PMU_POWER_CTRL0, PMU_POW0_OFF|PMU_POW0_HARD_DRIVE);
 	pmu_wait_complete(&req);
@@ -2095,8 +1924,6 @@ static int powerbook_sleep_grackle(void)
 			PMU_POW_ON|PMU_POW_BACKLIGHT|PMU_POW_CHARGER|PMU_POW_IRLED|PMU_POW_MEDIABAY);
 	pmu_wait_complete(&req);
 
-	pmac_wakeup_devices();
-
 	return 0;
 }
 
@@ -2106,7 +1933,6 @@ powerbook_sleep_Core99(void)
 	unsigned long save_l2cr;
 	unsigned long save_l3cr;
 	struct adb_request req;
-	int ret;
 	
 	if (pmac_call_feature(PMAC_FTR_SLEEP_STATE,NULL,0,-1) < 0) {
 		printk(KERN_ERR "Sleep mode not supported on this machine\n");
@@ -2116,12 +1942,6 @@ powerbook_sleep_Core99(void)
 	if (num_online_cpus() > 1 || cpu_is_offline(0))
 		return -EAGAIN;
 
-	ret = pmac_suspend_devices();
-	if (ret) {
-		printk(KERN_ERR "Sleep rejected by devices\n");
-		return ret;
-	}
-
 	/* Stop environment and ADB interrupts */
 	pmu_request(&req, NULL, 2, PMU_SET_INTR_MASK, 0);
 	pmu_wait_complete(&req);
@@ -2192,41 +2012,24 @@ powerbook_sleep_Core99(void)
 	/* Restore LPJ, cpufreq will adjust the cpu frequency */
 	loops_per_jiffy /= 2;
 
-	pmac_wakeup_devices();
-
 	return 0;
 }
 
 #define PB3400_MEM_CTRL		0xf8000000
 #define PB3400_MEM_CTRL_SLEEP	0x70
 
+static void __iomem *pb3400_mem_ctrl;
+
 static int
 powerbook_sleep_3400(void)
 {
-	int ret, i, x;
+	int i, x;
 	unsigned int hid0;
 	unsigned long p;
 	struct adb_request sleep_req;
-	void __iomem *mem_ctrl;
 	unsigned int __iomem *mem_ctrl_sleep;
 
-	/* first map in the memory controller registers */
-	mem_ctrl = ioremap(PB3400_MEM_CTRL, 0x100);
-	if (mem_ctrl == NULL) {
-		printk("powerbook_sleep_3400: ioremap failed\n");
-		return -ENOMEM;
-	}
-	mem_ctrl_sleep = mem_ctrl + PB3400_MEM_CTRL_SLEEP;
-
-	/* Allocate room for PCI save */
-	pbook_alloc_pci_save();
-
-	ret = pmac_suspend_devices();
-	if (ret) {
-		pbook_free_pci_save();
-		printk(KERN_ERR "Sleep rejected by devices\n");
-		return ret;
-	}
+	mem_ctrl_sleep = pb3400_mem_ctrl + PB3400_MEM_CTRL_SLEEP;
 
 	/* Save the state of PCI config space for some slots */
 	pbook_pci_save();
@@ -2271,14 +2074,10 @@ powerbook_sleep_3400(void)
 	while (asleep)
 		mb();
 
-	pmac_wakeup_devices();
-	pbook_free_pci_save();
-	iounmap(mem_ctrl);
-
 	return 0;
 }
 
-#endif /* CONFIG_PM_SLEEP && CONFIG_PPC32 */
+#endif /* CONFIG_SUSPEND && CONFIG_PPC32 */
 
 /*
  * Support for /dev/pmu device
@@ -2451,6 +2250,157 @@ pmu_release(struct inode *inode, struct 
 	return 0;
 }
 
+#if defined(CONFIG_SUSPEND) && defined(CONFIG_PPC32)
+static int powerbook_prepare_sleep(void)
+{
+	if (pmu_kind == PMU_OHARE_BASED) {
+		/* first map in the memory controller registers */
+		pb3400_mem_ctrl = ioremap(PB3400_MEM_CTRL, 0x100);
+		if (!pb3400_mem_ctrl) {
+			printk(KERN_ERR "powerbook_sleep_3400: "
+			       "ioremap failed\n");
+			return -ENOMEM;
+		}
+
+		/* Allocate room for PCI save */
+		pbook_alloc_pci_save();
+	}
+
+	return 0;
+}
+
+/*
+ * overrides the weak arch_suspend_disable_irqs in kernel/power/main.c
+ *
+ * XXX: Once Scott Wood's patch is merged, this needs to use the ppc_md
+ *	hooks that patch adds!
+ */
+void arch_suspend_disable_irqs(void)
+{
+#ifdef CONFIG_PMAC_BACKLIGHT
+	/* Tell backlight code not to muck around with the chip anymore */
+	pmu_backlight_set_sleep(1);
+#endif
+
+	/* Call platform functions marked "on sleep" */
+	pmac_pfunc_i2c_suspend();
+	pmac_pfunc_base_suspend();
+
+	/* Stop preemption */
+	preempt_disable();
+
+	/* Make sure the decrementer won't interrupt us */
+	asm volatile("mtdec %0" : : "r" (0x7fffffff));
+	/* Make sure any pending DEC interrupt occurring while we did
+	 * the above didn't re-enable the DEC */
+	mb();
+	asm volatile("mtdec %0" : : "r" (0x7fffffff));
+
+	local_irq_disable();
+}
+
+static int powerbook_sleep(suspend_state_t state)
+{
+	int error = 0;
+
+	/* Wait for completion of async requests */
+	while (!batt_req.complete)
+		pmu_poll();
+
+	/* Giveup the lazy FPU & vec so we don't have to back them
+	 * up from the low level code
+	 */
+	enable_kernel_fp();
+
+#ifdef CONFIG_ALTIVEC
+	if (cpu_has_feature(CPU_FTR_ALTIVEC))
+		enable_kernel_altivec();
+#endif /* CONFIG_ALTIVEC */
+
+	switch (pmu_kind) {
+	case PMU_OHARE_BASED:
+		error = powerbook_sleep_3400();
+		break;
+	case PMU_HEATHROW_BASED:
+	case PMU_PADDINGTON_BASED:
+		error = powerbook_sleep_grackle();
+		break;
+	case PMU_KEYLARGO_BASED:
+		error = powerbook_sleep_Core99();
+		break;
+	default:
+		return -ENOSYS;
+	}
+
+	if (error)
+		return error;
+
+	mdelay(100);
+
+#ifdef CONFIG_PMAC_BACKLIGHT
+	/* Tell backlight code it can use the chip again */
+	pmu_backlight_set_sleep(0);
+#endif
+
+	return 0;
+}
+
+/*
+ * overrides the weak arch_suspend_enable_irqs in kernel/power/main.c
+ *
+ * XXX: Once Scott Wood's patch is merged, this needs to use the ppc_md
+ *	hooks that patch adds!
+ */
+void arch_suspend_enable_irqs(void)
+{
+	/* Force a poll of ADB interrupts */
+	adb_int_pending = 1;
+	via_pmu_interrupt(0, NULL);
+
+	/* Restart jiffies & scheduling */
+	wakeup_decrementer();
+
+	/* Re-enable local CPU interrupts */
+	local_irq_enable();
+	mdelay(10);
+	preempt_enable();
+
+	/* Call platform functions marked "on wake" */
+	pmac_pfunc_base_resume();
+	pmac_pfunc_i2c_resume();
+}
+
+static void powerbook_finish_sleep(void)
+{
+	if (pmu_kind == PMU_OHARE_BASED) {
+		pbook_free_pci_save();
+		iounmap(pb3400_mem_ctrl);
+	}
+}
+
+static int pmu_sleep_valid(suspend_state_t state)
+{
+	return state == PM_SUSPEND_MEM
+		&& (pmac_call_feature(PMAC_FTR_SLEEP_STATE, NULL, 0, -1) >= 0);
+}
+
+static struct platform_suspend_ops pmu_pm_ops = {
+	.prepare = powerbook_prepare_sleep,
+	.enter = powerbook_sleep,
+	.finish = powerbook_finish_sleep,
+	.valid = pmu_sleep_valid,
+};
+
+static int register_pmu_pm_ops(void)
+{
+	suspend_set_ops(&pmu_pm_ops);
+
+	return 0;
+}
+
+device_initcall(register_pmu_pm_ops);
+#endif
+
 static int
 pmu_ioctl(struct inode * inode, struct file *filp,
 		     u_int cmd, u_long arg)
@@ -2459,35 +2409,30 @@ pmu_ioctl(struct inode * inode, struct f
 	int error = -EINVAL;
 
 	switch (cmd) {
-#if defined(CONFIG_PM_SLEEP) && defined(CONFIG_PPC32)
+#if defined(CONFIG_DEPRECATED_PMU_SLEEP_IOCTL)
 	case PMU_IOC_SLEEP:
 		if (!capable(CAP_SYS_ADMIN))
 			return -EACCES;
-		if (sleep_in_progress)
-			return -EBUSY;
-		sleep_in_progress = 1;
-		switch (pmu_kind) {
-		case PMU_OHARE_BASED:
-			error = powerbook_sleep_3400();
-			break;
-		case PMU_HEATHROW_BASED:
-		case PMU_PADDINGTON_BASED:
-			error = powerbook_sleep_grackle();
-			break;
-		case PMU_KEYLARGO_BASED:
-			error = powerbook_sleep_Core99();
-			break;
-		default:
-			error = -ENOSYS;
-		}
-		sleep_in_progress = 0;
+		printk(KERN_INFO
+		       "via-pmu: the PMU_IOC_SLEEP ioctl is deprecated.\n");
+		printk(KERN_INFO "via-pmu: use \"echo mem >"
+		       " /sys/power/state\"  instead!\n");
+		printk(KERN_INFO
+		       "via-pmu: this ioctl will be removed soon.\n");
+		error = pm_suspend(PM_SUSPEND_MEM);
 		break;
 	case PMU_IOC_CAN_SLEEP:
+		printk(KERN_INFO
+		       "via-pmu: the PMU_IOC_CAN_SLEEP ioctl is deprecated.\n");
+		printk(KERN_INFO
+		       "via-pmu: use \"grep mem /sys/power/state\" instead!\n");
+		printk(KERN_INFO
+		       "via-pmu: this ioctl will be removed soon.\n");
 		if (pmac_call_feature(PMAC_FTR_SLEEP_STATE,NULL,0,-1) < 0)
 			return put_user(0, argp);
 		else
 			return put_user(1, argp);
-#endif /* CONFIG_PM_SLEEP && CONFIG_PPC32 */
+#endif /* CONFIG_DEPRECATED_PMU_SLEEP_IOCTL */
 
 #ifdef CONFIG_PMAC_BACKLIGHT_LEGACY
 	/* Compatibility ioctl's for backlight */
@@ -2495,9 +2440,6 @@ pmu_ioctl(struct inode * inode, struct f
 	{
 		int brightness;
 
-		if (sleep_in_progress)
-			return -EBUSY;
-
 		brightness = pmac_backlight_get_legacy_brightness();
 		if (brightness < 0)
 			return brightness;
@@ -2509,9 +2451,6 @@ pmu_ioctl(struct inode * inode, struct f
 	{
 		int brightness;
 
-		if (sleep_in_progress)
-			return -EBUSY;
-
 		error = get_user(brightness, argp);
 		if (error)
 			return error;
@@ -2566,87 +2505,7 @@ static int pmu_device_init(void)
 }
 device_initcall(pmu_device_init);
 
-
-#ifdef DEBUG_SLEEP
-static inline void 
-polled_handshake(volatile unsigned char __iomem *via)
-{
-	via[B] &= ~TREQ; eieio();
-	while ((via[B] & TACK) != 0)
-		;
-	via[B] |= TREQ; eieio();
-	while ((via[B] & TACK) == 0)
-		;
-}
-
-static inline void 
-polled_send_byte(volatile unsigned char __iomem *via, int x)
-{
-	via[ACR] |= SR_OUT | SR_EXT; eieio();
-	via[SR] = x; eieio();
-	polled_handshake(via);
-}
-
-static inline int
-polled_recv_byte(volatile unsigned char __iomem *via)
-{
-	int x;
-
-	via[ACR] = (via[ACR] & ~SR_OUT) | SR_EXT; eieio();
-	x = via[SR]; eieio();
-	polled_handshake(via);
-	x = via[SR]; eieio();
-	return x;
-}
-
-int
-pmu_polled_request(struct adb_request *req)
-{
-	unsigned long flags;
-	int i, l, c;
-	volatile unsigned char __iomem *v = via;
-
-	req->complete = 1;
-	c = req->data[0];
-	l = pmu_data_len[c][0];
-	if (l >= 0 && req->nbytes != l + 1)
-		return -EINVAL;
-
-	local_irq_save(flags);
-	while (pmu_state != idle)
-		pmu_poll();
-
-	while ((via[B] & TACK) == 0)
-		;
-	polled_send_byte(v, c);
-	if (l < 0) {
-		l = req->nbytes - 1;
-		polled_send_byte(v, l);
-	}
-	for (i = 1; i <= l; ++i)
-		polled_send_byte(v, req->data[i]);
-
-	l = pmu_data_len[c][1];
-	if (l < 0)
-		l = polled_recv_byte(v);
-	for (i = 0; i < l; ++i)
-		req->reply[i + req->reply_len] = polled_recv_byte(v);
-
-	if (req->done)
-		(*req->done)(req);
-
-	local_irq_restore(flags);
-	return 0;
-}
-#endif /* DEBUG_SLEEP */
-
-
-/* FIXME: This is a temporary set of callbacks to enable us
- * to do suspend-to-disk.
- */
-
-#if defined(CONFIG_PM_SLEEP) && defined(CONFIG_PPC32)
-
+#if defined(CONFIG_SUSPEND) && defined(CONFIG_PPC32)
 int pmu_sys_suspended;
 
 static int pmu_sys_suspend(struct sys_device *sysdev, pm_message_t state)
@@ -2680,7 +2539,7 @@ static int pmu_sys_resume(struct sys_dev
 	return 0;
 }
 
-#endif /* CONFIG_PM_SLEEP && CONFIG_PPC32 */
+#endif /* CONFIG_SUSPEND && CONFIG_PPC32 */
 
 static ssize_t show_kind(struct sys_device *sysdev, char *buf)
 {
@@ -2724,10 +2583,10 @@ static struct sys_device device_pmu = {
 };
 
 static struct sysdev_driver driver_pmu = {
-#if defined(CONFIG_PM_SLEEP) && defined(CONFIG_PPC32)
+#if defined(CONFIG_SUSPEND) && defined(CONFIG_PPC32)
 	.suspend	= &pmu_sys_suspend,
 	.resume		= &pmu_sys_resume,
-#endif /* CONFIG_PM_SLEEP && CONFIG_PPC32 */
+#endif /* CONFIG_SUSPEND && CONFIG_PPC32 */
 	.add		= &pmu_sys_add,
 };
 
@@ -2763,10 +2622,10 @@ EXPORT_SYMBOL(pmu_wait_complete);
 EXPORT_SYMBOL(pmu_suspend);
 EXPORT_SYMBOL(pmu_resume);
 EXPORT_SYMBOL(pmu_unlock);
-#if defined(CONFIG_PM_SLEEP) && defined(CONFIG_PPC32)
+#if defined(CONFIG_SUSPEND) && defined(CONFIG_PPC32)
 EXPORT_SYMBOL(pmu_enable_irled);
 EXPORT_SYMBOL(pmu_battery_count);
 EXPORT_SYMBOL(pmu_batteries);
 EXPORT_SYMBOL(pmu_power_flags);
-#endif /* CONFIG_PM_SLEEP && CONFIG_PPC32 */
+#endif /* CONFIG_SUSPEND && CONFIG_PPC32 */
 
--- everything.orig/Documentation/feature-removal-schedule.txt	2007-11-08 11:48:53.122870607 +0100
+++ everything/Documentation/feature-removal-schedule.txt	2007-11-08 11:49:21.602885743 +0100
@@ -350,3 +350,13 @@ Why:	The PMU information can be obtained
 Who:	Johannes Berg <johannes@sipsolutions.net>
 
 ---------------------------
+
+What:	/dev/pmu suspend/can-suspend ioctls
+When:	January 2010
+Files:	drivers/macintosh/via-pmu.c
+Why:	powermac supports proper generic pm_ops now and can suspend with
+	"echo mem > /sys/power/state" instead of the ioctl, checking if
+	it can suspend can be done by reading /sys/power/state.
+Who:	Johannes Berg <johannes@sipsolutions.net>
+
+---------------------------
--- everything.orig/drivers/macintosh/Kconfig	2007-11-08 11:48:53.122870607 +0100
+++ everything/drivers/macintosh/Kconfig	2007-11-08 11:49:21.602885743 +0100
@@ -98,6 +98,18 @@ config DEPRECATED_PMU_INFO_IOCTLS
 
 	  If in doubt, say Y even if you will not use the ioctl.
 
+config DEPRECATED_PMU_SLEEP_IOCTL
+	bool "Support deprecated PMU sleep ioctl"
+	depends on ADB_PMU && SUSPEND && PPC32
+	default y
+	help
+	  The PMU code used to support suspending the machine via an ioctl
+	  before Linux had a generic suspend framework. Now the PMU supports
+	  suspending via the generic framework, this option adds the old
+	  PMU specific ioctl to the kernel.
+
+	  If in doubt, say Y even if you will not use the ioctl.
+
 config ADB_PMU_LED
 	bool "Support for the Power/iBook front LED"
 	depends on ADB_PMU

^ permalink raw reply

* Re: [PATCH] powerpc: fix powersave-nap sysctl registration
From: Johannes Berg @ 2007-11-08 14:39 UTC (permalink / raw)
  To: Paul Mackerras; +Cc: linuxppc-dev list, Eric W. Biederman
In-Reply-To: <1194462703.5996.0.camel@johannes.berg>

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


On Wed, 2007-11-07 at 20:11 +0100, Johannes Berg wrote:
> The sysctl check code complains about a writable directory,
> fix it.

Sorry, I missed that patch that fixed it already, please ignore.

johannes

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

^ permalink raw reply

* Re: mpc5200, sysctl table check failed
From: Johannes Berg @ 2007-11-08 15:09 UTC (permalink / raw)
  To: Olof Johansson; +Cc: PowerPC dev list
In-Reply-To: <20071107204138.GA7066@lixom.net>

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



> I posted a patch for this yesterday, it's harmless, just a warning.

That's not actually true, if the sysctl check code warns in any way the
sysctl file doesn't show up in /proc/sys/

johannes

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

^ permalink raw reply

* Re: [1/2] dtc: Refactor printing of property values in -Odts mode
From: Jon Loeliger @ 2007-11-08 15:25 UTC (permalink / raw)
  To: David Gibson; +Cc: linuxppc-dev
In-Reply-To: <20071106232120.GH31367@localhost.localdomain>

So, like, the other day David Gibson mumbled:
> Currently the main recursive tree printing function,
> write_tree_source_node(), calls guess_type() to apply heuristics to
> see how to print a property value, then calls the appropriate
> write_propval_*() function to print it.
> 
> However, future heuristics for handling internal labels and the like
> don't work well this way.  Therefore, this patch refactors things to
> have write_tree_source_node() call a new write_propval() function,
> which incorporates the heurstic logic from guess_type() and also calls
> the right function to do the actual printing.
> 
> No behavioural change.
> 
> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>

Applied.

jdl

^ permalink raw reply

* Re: [2/2] dtc: Make -Idts -Odts preserve property-internal labels
From: Jon Loeliger @ 2007-11-08 15:25 UTC (permalink / raw)
  To: David Gibson; +Cc: linuxppc-dev
In-Reply-To: <20071106232225.GI31367@localhost.localdomain>

So, like, the other day David Gibson mumbled:
> This patch changes -Odts mode output so that labels within property
> values in the input are preserved in the output.  Applied on top of
> the earlier patch to preserve node and property labels in -Odts mode,
> this means that dtc in -Idts -Odts mode will transfer all labels in
> the input to the output.
> 
> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>

Applied.

jdl

^ permalink raw reply

* Re: dtc: Add testcases exercising -Odts mode
From: Jon Loeliger @ 2007-11-08 15:26 UTC (permalink / raw)
  To: David Gibson; +Cc: linuxppc-dev
In-Reply-To: <20071106233406.GJ31367@localhost.localdomain>

So, like, the other day David Gibson mumbled:
> This patch adds a batch of testcases exercising dtc's -Odts mode.
> Specifically it checks that using dtc to convert dtb->dts->dtb
> preserves the original dtb for a number of example dtb files.
> 
> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>

Applied.

jdl

^ permalink raw reply

* Re: dtc: Better exercise dtc base and bytestring features
From: Jon Loeliger @ 2007-11-08 15:26 UTC (permalink / raw)
  To: David Gibson; +Cc: linuxppc-dev
In-Reply-To: <20071106235822.GK31367@localhost.localdomain>

So, like, the other day David Gibson mumbled:
> This patch alters the main testcase, and the dts file corresponding to
> it so that we at least trivially exercise dtc's bytestring and base
> conversion features.
> 
> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>

Applied.

jdl

^ permalink raw reply

* Re: mpc5200, sysctl table check failed
From: Olof Johansson @ 2007-11-08 15:28 UTC (permalink / raw)
  To: Johannes Berg; +Cc: PowerPC dev list
In-Reply-To: <1194534579.6294.46.camel@johannes.berg>

On Thu, Nov 08, 2007 at 04:09:39PM +0100, Johannes Berg wrote:
> 
> 
> > I posted a patch for this yesterday, it's harmless, just a warning.
> 
> That's not actually true, if the sysctl check code warns in any way the
> sysctl file doesn't show up in /proc/sys/

Oh, you're right. Well, it's been fixed now anyway. :-)


-Olof

^ permalink raw reply

* Re: [PATCH 4/3] Make swsusp_32.S usable for suspend-to-RAM.
From: Scott Wood @ 2007-11-08 15:56 UTC (permalink / raw)
  To: Johannes Berg; +Cc: linuxppc-dev, paulus
In-Reply-To: <1194438345.4470.4.camel@johannes.berg>

Johannes Berg wrote:
>> +config PPC32_SUSPEND
> 
>> +config PPC32_SWSUSP
> 
>> -obj32-$(CONFIG_HIBERNATION) += swsusp_32.o
>> +obj32-$(CONFIG_PPC32_SUSPEND)	+= swsusp_32.o
> 
> I think that's overkill, couldn't it just use CONFIG_PM_SLEEP here?

This file is specific to 32-bit classic PPC chips.

It doesn't matter, though, as I've redone the 83xx suspend to not need 
that file.

-Scott

^ permalink raw reply

* Re: [PATCH 3/4] Use embedded libfdt in the bootwrapper
From: Scott Wood @ 2007-11-08 16:08 UTC (permalink / raw)
  To: David Gibson; +Cc: linuxppc-dev, Paul Mackerras
In-Reply-To: <20071108033603.8A29FDDE0F@ozlabs.org>

On Thu, Nov 08, 2007 at 02:36:03PM +1100, David Gibson wrote:
> This patch incorporates libfdt (from the source embedded in an earlier
> patch) into the wrapper.a library used by the bootwrapper.  This
> includes adding a libfdt_env.h file, which the libfdt sources need in
> order to integrate into the bootwrapper environment, and a
> libfdt-wrapper.c which provides glue to connect the bootwrappers
> abstract device tree callbacks to the libfdt functions.
> 
> In addition, this patch changes the various wrapper and platform files
> to use libfdt functions instead of the older flatdevtree.c library.

Won't we need to change the dtc invocation in the wrapper to reserve some
space now?

Speaking of which, it seems dtc still only supports setting the total size,
as opposed to specifying the amount of additional space.  It's still a bit
crappy having to guess how much space to add, but it's better than needing
to know how big the dtb will be without additional space.

How hard would it be to get libfdt to dynamically allocate any extra space
it needs?  This is a regression from the current flat device tree code...

-Scott

^ permalink raw reply

* Re: use of fsl, in lite5200b.dts in git current
From: Scott Wood @ 2007-11-08 16:28 UTC (permalink / raw)
  To: Jon Smirl; +Cc: linuxppc-embedded
In-Reply-To: <9e4733910711071815x344319ebye89168320dd53c0@mail.gmail.com>

Jon Smirl wrote:
> On 11/7/07, Matt Sealey <matt@genesi-usa.com> wrote:
>> Jon Smirl wrote:
>>> I'm not in favor of all these fsl prefixes. These chip families
>>> do get sold. What would we have done with intel,pxa320 all over
>>> the place when they sold it to marvell? mass changes to
>>> marvell,pxa320?
>> That's the idea, and there'd be a compatible entry for
>> intel,pxa320.
> 
> The vendor part really isn't needed and it is going to be a source of
>  trouble. The vendors are smart enough not to create two chips with
> the same part number. Adding a vendor qualifier complicates things 
> needlessly.

I think you may be placing too much faith in the vendors.
Is a 7400 a Freescale powerpc chip, or a quad 2-input NAND gate? :-)

If you want to argue that the "MPC" part differentiates them, that's
just a less readable and more obsolete vendor prefix.

And not all compatible entries are part numbers; many are descriptions
of programming interfaces (such as cpm2 or gianfar).  I'm not inclined
to bet that there will never be a conflict in such a namespace.

>> Actually the spec says you should use the stock ticker (IBM, FSL,
>> INTC, JAVA, MRVL) if they have one and if not, the company name in
>> lower case.
>> 
>> Freescale are a funny one because they used to have a stock ticker
>> as MOT and then FSL but now they're privately owned, so it's gonna
>> have to be lower case :]

Well, technically the recommended prefix is an OUI number, and those are
less likely to change due to corporate shuffling, but they suck from a
readability perspective.

> Another example of how these vendor prefixes can change. The chip 
> numbers are never going to change. Just use them and drop these
> vendor prefixes.

No. :-)

>> functionality. fsl,has-wdt differs from has-wdt ideally because
> 
> This one I can buy, but it should be fsl-has-wdt. Drop the vendor
> prefixes.

How is fsl-has-wdt any better, other than it obscures namespace issues?

Vendor prefixes on properties are useful in that it might not mean
exactly the same thing as a similar property that gets standardized
later on.

> That's life in the Linux world, no backwards binary compatibility.

There's a huge difference between compatibility of kernel interfaces and
compatibility of interfaces between the kernel and something else --
whether it be userspace or firmware.

-Scott

^ permalink raw reply


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