Skip to contentSkip to conversation

Cell patches for 2.6.27

PATCH In review [email protected] 7 participants 45 messages Jul 4, 2008 – Jul 10, 2008 1 message not in the archive

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

cover Cell patches for 2.6.27

Hi Paul and Ben,

These are the cell related patches I would like to see in 2.6.27. If there are no further comments, please pull into powerpc-next from

master.kernel.org/pub/scm/linux/kernel/git/arnd/cell-2.6.git cell-next

#1 lore raw

PATCH 1/11 powerpc/cell: add support for power button of future IBM cell blades

This patch adds support for the power button on future IBM cell blades. It actually doesn't shut down the machine. Instead it exposes an input device /dev/input/event0 to userspace which sends KEY_POWER if power button has been pressed.
haldaemon actually recognizes the button, so a plattform independent acpid replacement should handle it correctly.

---
 arch/powerpc/platforms/cell/pervasive.c |   70 ++++++++++++++++++++++++++++++-
 1 files changed, 69 insertions(+), 1 deletions(-)
arch/powerpc/platforms/cell/pervasive.c +69 -1
index 8a3631c..e5bd08c 100644
@@ -24,8 +24,10 @@
 #undef DEBUG
 
 #include <linux/interrupt.h>
+#include <linux/input.h>
 #include <linux/irq.h>
 #include <linux/percpu.h>
+#include <linux/platform_device.h>
 #include <linux/types.h>
 #include <linux/kallsyms.h>
 
@@ -40,6 +42,9 @@
 
 static int sysreset_hack;
 
+static struct input_dev *button_dev;
+static struct platform_device *button_pdev;
+
 static void cbe_power_save(void)
 {
 	unsigned long ctrl, thread_switch_control;
@@ -105,10 +110,21 @@ static int cbe_system_reset_exception(struct pt_regs *regs)
 		 */
 		if (sysreset_hack && (cpu = smp_processor_id()) == 0) {
 			pmd = cbe_get_cpu_pmd_regs(cpu);
-			if (in_be64(&pmd->ras_esc_0) & 0xffff) {
+			if (in_be64(&pmd->ras_esc_0) & 0x0000ffff) {
 				out_be64(&pmd->ras_esc_0, 0);
 				return 0;
 			}
+			if (in_be64(&pmd->ras_esc_0) & 0x00010000) {
+				out_be64(&pmd->ras_esc_0, 0);
+				if (!button_dev)
+					return 0;
+
+				input_report_key(button_dev, KEY_POWER, 1);
+				input_sync(button_dev);
+				input_report_key(button_dev, KEY_POWER, 0);
+				input_sync(button_dev);
+				return 1;
+			}
 		}
 		break;
 #ifdef CONFIG_CBE_RAS
@@ -155,3 +171,55 @@ void __init cbe_pervasive_init(void)
 	ppc_md.power_save = cbe_power_save;
 	ppc_md.system_reset_exception = cbe_system_reset_exception;
 }
+
+static int __init cbe_power_button_init(void)
+{
+	int ret;
+	struct input_dev *dev;
+
+	if (!sysreset_hack)
+		return 0;
+
+	dev = input_allocate_device();
+        if (!dev) {
+		ret = -ENOMEM;
+                printk(KERN_ERR "%s: Not enough memory\n", __func__);
+                goto out;
+        }
+
+	set_bit(EV_KEY, dev->evbit);
+	set_bit(KEY_POWER, dev->keybit);
+
+	dev->name = "Power Button";
+	dev->id.bustype = BUS_HOST;
+
+	/* this makes the button look like an acpi power button
+	 * no clue whether anyone relies on that though */
+	dev->id.product = 0x02;
+	dev->phys = "LNXPWRBN/button/input0";
+
+	button_pdev = platform_device_register_simple("power_button", 0, NULL, 0);
+	if (IS_ERR(button_pdev)) {
+		ret = PTR_ERR(button_pdev);
+		goto out_free_input;
+	}
+
+	dev->dev.parent = &button_pdev->dev;
+
+	ret = input_register_device(dev);
+	if (ret) {
+                printk(KERN_ERR "%s: Failed to register device\n", __func__);
+		goto out_free_pdev;
+        }
+
+	button_dev = dev;
+	return ret;
+
+out_free_pdev:
+	platform_device_unregister(button_pdev);
+out_free_input:
+	input_free_device(dev);
+out:
+	return ret;
+}
+device_initcall(cbe_power_button_init);
Signature · 3 lines
1.5.4.3

-- 
#2 lore raw

Re: [patch 01/11] powerpc/cell: add support for power button of future IBM cell blades

Quoted 9 lines · On Fri, 2008-07-04 at 21:05 +0200, [email protected] wrote:

plain text document attachment (0001-powerpc-cell-add-support-for-power-button-of-future.patch) This patch adds support for the power button on future IBM cell blades. It actually doesn't shut down the machine. Instead it exposes an input device /dev/input/event0 to userspace which sends KEY_POWER if power button has been pressed.
haldaemon actually recognizes the button, so a plattform independent acpid replacement should handle it correctly.

Quoted 3 lines

---

And what if CONFIG_INPUT=n or m ?

Cheers,
Ben.

Quoted 110 lines
 arch/powerpc/platforms/cell/pervasive.c |   70 ++++++++++++++++++++++++++++++-
 1 files changed, 69 insertions(+), 1 deletions(-)
arch/powerpc/platforms/cell/pervasive.c +69 -1
index 8a3631c..e5bd08c 100644
@@ -24,8 +24,10 @@
 #undef DEBUG
 
 #include <linux/interrupt.h>
+#include <linux/input.h>
 #include <linux/irq.h>
 #include <linux/percpu.h>
+#include <linux/platform_device.h>
 #include <linux/types.h>
 #include <linux/kallsyms.h>
 
@@ -40,6 +42,9 @@
 
 static int sysreset_hack;
 
+static struct input_dev *button_dev;
+static struct platform_device *button_pdev;
+
 static void cbe_power_save(void)
 {
 	unsigned long ctrl, thread_switch_control;
@@ -105,10 +110,21 @@ static int cbe_system_reset_exception(struct pt_regs *regs)
 		 */
 		if (sysreset_hack && (cpu = smp_processor_id()) == 0) {
 			pmd = cbe_get_cpu_pmd_regs(cpu);
-			if (in_be64(&pmd->ras_esc_0) & 0xffff) {
+			if (in_be64(&pmd->ras_esc_0) & 0x0000ffff) {
 				out_be64(&pmd->ras_esc_0, 0);
 				return 0;
 			}
+			if (in_be64(&pmd->ras_esc_0) & 0x00010000) {
+				out_be64(&pmd->ras_esc_0, 0);
+				if (!button_dev)
+					return 0;
+
+				input_report_key(button_dev, KEY_POWER, 1);
+				input_sync(button_dev);
+				input_report_key(button_dev, KEY_POWER, 0);
+				input_sync(button_dev);
+				return 1;
+			}
 		}
 		break;
 #ifdef CONFIG_CBE_RAS
@@ -155,3 +171,55 @@ void __init cbe_pervasive_init(void)
 	ppc_md.power_save = cbe_power_save;
 	ppc_md.system_reset_exception = cbe_system_reset_exception;
 }
+
+static int __init cbe_power_button_init(void)
+{
+	int ret;
+	struct input_dev *dev;
+
+	if (!sysreset_hack)
+		return 0;
+
+	dev = input_allocate_device();
+        if (!dev) {
+		ret = -ENOMEM;
+                printk(KERN_ERR "%s: Not enough memory\n", __func__);
+                goto out;
+        }
+
+	set_bit(EV_KEY, dev->evbit);
+	set_bit(KEY_POWER, dev->keybit);
+
+	dev->name = "Power Button";
+	dev->id.bustype = BUS_HOST;
+
+	/* this makes the button look like an acpi power button
+	 * no clue whether anyone relies on that though */
+	dev->id.product = 0x02;
+	dev->phys = "LNXPWRBN/button/input0";
+
+	button_pdev = platform_device_register_simple("power_button", 0, NULL, 0);
+	if (IS_ERR(button_pdev)) {
+		ret = PTR_ERR(button_pdev);
+		goto out_free_input;
+	}
+
+	dev->dev.parent = &button_pdev->dev;
+
+	ret = input_register_device(dev);
+	if (ret) {
+                printk(KERN_ERR "%s: Failed to register device\n", __func__);
+		goto out_free_pdev;
+        }
+
+	button_dev = dev;
+	return ret;
+
+out_free_pdev:
+	platform_device_unregister(button_pdev);
+out_free_input:
+	input_free_device(dev);
+out:
+	return ret;
+}
+device_initcall(cbe_power_button_init);
Signature · 1 line
1.5.4.3
#3 lore raw

Re: [patch 01/11] powerpc/cell: add support for power button of future IBM cell blades

Quoted 10 lines · On Mon, 07 Jul 2008 15:12:23 +1000 Benjamin Herrenschmidt…
Quoted 9 lines · On Fri, 2008-07-04 at 21:05 +0200, [email protected] wrote:

plain text document attachment (0001-powerpc-cell-add-support-for-power-button-of-future.patch) This patch adds support for the power button on future IBM cell blades. It actually doesn't shut down the machine. Instead it exposes an input device /dev/input/event0 to userspace which sends KEY_POWER if power button has been pressed.
haldaemon actually recognizes the button, so a plattform independent acpid replacement should handle it correctly.

Quoted 9 lines
Quoted 3 lines

---

And what if CONFIG_INPUT=n or m ?

Cheers,
Ben.

hm, good point.
Only wrapping with ifdefs will not fix the CONFIG_INPUT=m case. Have to think about it again, will send an update ...

Cheers,
ck

Signature · 13 lines
Mit freundlichen Gruessen,
kind regards,

Christian Krafft
Linux Kernel Development
IBM Systems & Technology Group
Phone: +49-07031-16-2032

IBM Deutschland Research & Development GmbH
Vorsitzender des Aufsichtsrats:	Martin Jetter
Geschaetsfuehung:		Herbert Kircher
Sitz der Gesellschaft:		Boelingen
Registergericht:		Amtsgericht Stuttgart, HRB 243294

A message that is not in the archive (sent off-list or not yet received): [email protected]

#5 lore raw

Re: [Cbe-oss-dev] [patch 01/02] powerpc/cell: cleanup sysreset_hack for IBM cell blades

From: Christian Krafft <[email protected]>

This patch adds a config option for the sysreset_hack used for IBM Cell blades. The code is moves from pervasive.c into ras.c and gets it's own init method.

arch/powerpc/platforms/cell/pervasive.c +1 -26
Index: linux.git/arch/powerpc/platforms/cell/pervasive.c
===================================================================
@@ -38,8 +38,6 @@
 
 #include "pervasive.h"
 
-static int sysreset_hack;
-
 static void cbe_power_save(void)
 {
 	unsigned long ctrl, thread_switch_control;
@@ -87,9 +85,6 @@ static void cbe_power_save(void)
 
 static int cbe_system_reset_exception(struct pt_regs *regs)
 {
-	int cpu;
-	struct cbe_pmd_regs __iomem *pmd;
-
 	switch (regs->msr & SRR1_WAKEMASK) {
 	case SRR1_WAKEEE:
 		do_IRQ(regs);
@@ -98,19 +93,7 @@ static int cbe_system_reset_exception(st
 		timer_interrupt(regs);
 		break;
 	case SRR1_WAKEMT:
-		/*
-		 * The BMC can inject user triggered system reset exceptions,
-		 * but cannot set the system reset reason in srr1,
-		 * so check an extra register here.
-		 */
-		if (sysreset_hack && (cpu = smp_processor_id()) == 0) {
-			pmd = cbe_get_cpu_pmd_regs(cpu);
-			if (in_be64(&pmd->ras_esc_0) & 0xffff) {
-				out_be64(&pmd->ras_esc_0, 0);
-				return 0;
-			}
-		}
-		break;
+		return cbe_sysreset_hack();
 #ifdef CONFIG_CBE_RAS
 	case SRR1_WAKESYSERR:
 		cbe_system_error_exception(regs);
@@ -134,8 +117,6 @@ void __init cbe_pervasive_init(void)
 	if (!cpu_has_feature(CPU_FTR_PAUSE_ZERO))
 		return;
 
-	sysreset_hack = machine_is_compatible("IBM,CBPLUS-1.0");
-
 	for_each_possible_cpu(cpu) {
 		struct cbe_pmd_regs __iomem *regs = cbe_get_cpu_pmd_regs(cpu);
 		if (!regs)
@@ -144,12 +125,6 @@ void __init cbe_pervasive_init(void)
 		 /* Enable Pause(0) control bit */
 		out_be64(&regs->pmcr, in_be64(&regs->pmcr) |
 					    CBE_PMD_PAUSE_ZERO_CONTROL);
-
-		/* Enable JTAG system-reset hack */
-		if (sysreset_hack)
-			out_be32(&regs->fir_mode_reg,
-				in_be32(&regs->fir_mode_reg) |
-				CBE_PMD_FIR_MODE_M8);
 	}
 
 	ppc_md.power_save = cbe_power_save;
arch/powerpc/platforms/cell/Kconfig +8 -0
Index: linux.git/arch/powerpc/platforms/cell/Kconfig
===================================================================
@@ -83,6 +83,14 @@ config CBE_RAS
 	depends on PPC_CELL_NATIVE
 	default y
 
+config PPC_IBM_CELL_BLADE_BUTTONS
+	bool "IBM Cell Blade Buttons"
+	depends on CBE_RAS && PPC_IBM_CELL_BLADE
+	default y
+	help
+	  Support Buttons on IBM Cell blades. This adds a method to
+	  trigger system reset via front panel pinhole button.
+
 config CBE_THERM
 	tristate "CBE thermal support"
 	default m
arch/powerpc/platforms/cell/pervasive.h +9 -0
Index: linux.git/arch/powerpc/platforms/cell/pervasive.h
===================================================================
@@ -30,4 +30,13 @@ extern void cbe_system_error_exception(s
 extern void cbe_maintenance_exception(struct pt_regs *regs);
 extern void cbe_thermal_exception(struct pt_regs *regs);
 
+#ifdef CONFIG_PPC_IBM_CELL_BLADE_BUTTONS
+extern int cbe_sysreset_hack(void);
+#else
+static inline int cbe_sysreset_hack(void)
+{
+	return 1;
+}
+#endif /* CONFIG_PPC_IBM_CELL_BLADE_BUTTONS */
+
 #endif
arch/powerpc/platforms/cell/ras.c +44 -0

50 lines not on this page · raw message

Signature · 13 lines
Mit freundlichen Gruessen,
kind regards,

Christian Krafft
Linux Kernel Development
IBM Systems & Technology Group
Phone: +49-07031-16-2032

IBM Deutschland Research & Development GmbH
Vorsitzender des Aufsichtsrats:	Martin Jetter
Geschaetsfuehung:		Herbert Kircher
Sitz der Gesellschaft:		Boelingen
Registergericht:		Amtsgericht Stuttgart, HRB 243294
#6 lore raw

Re: [Cbe-oss-dev] [patch 02/02] powerpc/cell: add support for power button of future IBM cell blades

In reply to a message not in the archive

From: Christian Krafft <[email protected]>

This patch adds support for the power button on future IBM cell blades. It actually doesn't shut down the machine. Instead it exposes an input device /dev/input/event0 to userspace which sends KEY_POWER if power button has been pressed.
haldaemon actually recognizes the button, so a plattform independent acpid replacement should handle it correctly.

arch/powerpc/platforms/cell/Kconfig +4 -1
Index: linux.git/arch/powerpc/platforms/cell/Kconfig
===================================================================
@@ -87,9 +87,12 @@ config PPC_IBM_CELL_BLADE_BUTTONS
 	bool "IBM Cell Blade Buttons"
 	depends on CBE_RAS && PPC_IBM_CELL_BLADE
 	default y
+	select INPUT
+	select INPUT_EVDEV
 	help
 	  Support Buttons on IBM Cell blades. This adds a method to
-	  trigger system reset via front panel pinhole button.
+	  trigger system reset via front panel pinhole button and
+	  an input device for the power button.
 
 config CBE_THERM
 	tristate "CBE thermal support"
arch/powerpc/platforms/cell/ras.c +64 -4

111 lines not on this page · raw message

Signature · 13 lines
Mit freundlichen Gruessen,
kind regards,

Christian Krafft
Linux Kernel Development
IBM Systems & Technology Group
Phone: +49-07031-16-2032

IBM Deutschland Research & Development GmbH
Vorsitzender des Aufsichtsrats:	Martin Jetter
Geschaetsfuehung:		Herbert Kircher
Sitz der Gesellschaft:		Boelingen
Registergericht:		Amtsgericht Stuttgart, HRB 243294
#7 lore raw

Re: [Cbe-oss-dev] [patch 02/02] powerpc/cell: add support for power button of future IBM cell blades

Quoted 10 lines · Christian Krafft

From: Christian Krafft <[email protected]>

This patch adds support for the power button on future IBM cell blades. It actually doesn't shut down the machine. Instead it exposes an input device /dev/input/event0 to userspace which sends KEY_POWER if power button has been pressed.
haldaemon actually recognizes the button, so a plattform independent acpid replacement should handle it correctly.

Sorry Christian, i'm still not too happy with this one.

There are two issues at hand here:

- The use of SELECT, that will be frowned on unfortunately.

- I'm not too sure it's very safe the way you do it. If I understand
correctly, you can get called for that sysreset at -any- time, including when interrupts are off right ?

That means potentially, code that has interrupts off will be interrupted by input_report/input_sync, which is really bad (may corrupt the input layer internal list management for example).

You could solve both things with a little trick: Have the platform code just basically set a global flag when the button was pressed and have a module that depends on INPUT & INPUT_DEV poll for it (slowly pls) and do the input report.

Ben.

Quoted 137 lines

Index: linux.git/arch/powerpc/platforms/cell/Kconfig
===================================================================

arch/powerpc/platforms/cell/Kconfig +4 -1
@@ -87,9 +87,12 @@ config PPC_IBM_CELL_BLADE_BUTTONS
 	bool "IBM Cell Blade Buttons"
 	depends on CBE_RAS && PPC_IBM_CELL_BLADE
 	default y
+	select INPUT
+	select INPUT_EVDEV
 	help
 	  Support Buttons on IBM Cell blades. This adds a method to
-	  trigger system reset via front panel pinhole button.
+	  trigger system reset via front panel pinhole button and
+	  an input device for the power button.
 
 config CBE_THERM
 	tristate "CBE thermal support"

Index: linux.git/arch/powerpc/platforms/cell/ras.c
===================================================================

arch/powerpc/platforms/cell/ras.c +64 -4
@@ -14,6 +14,11 @@
 #include <linux/smp.h>
 #include <linux/reboot.h>
 
+#ifdef CONFIG_PPC_IBM_CELL_BLADE_BUTTONS
+#include <linux/input.h>
+#include <linux/platform_device.h>
+#endif /* CONFIG_PPC_IBM_CELL_BLADE_BUTTONS */
+
 #include <asm/reg.h>
 #include <asm/io.h>
 #include <asm/prom.h>
@@ -232,31 +237,76 @@ static struct notifier_block cbe_ptcal_r
 
 #ifdef CONFIG_PPC_IBM_CELL_BLADE_BUTTONS
 static int sysreset_hack;
+static struct input_dev *button_dev;
+static struct platform_device *button_pdev;
 
 static int __init cbe_sysreset_init(void)
 {
+	int ret = 0;
+	struct input_dev *dev;
 	struct cbe_pmd_regs __iomem *regs;
 
 	sysreset_hack = machine_is_compatible("IBM,CBPLUS-1.0");
 	if (!sysreset_hack)
-		return 0;
+		goto out;
 
 	regs = cbe_get_cpu_pmd_regs(0);
 	if (!regs)
-		return 0;
+		goto out;
 
 	/* Enable JTAG system-reset hack */
 	out_be32(&regs->fir_mode_reg,
 		in_be32(&regs->fir_mode_reg) |
 		CBE_PMD_FIR_MODE_M8);
 
-	return 0;
+	dev = input_allocate_device();
+	if (!dev) {
+		ret = -ENOMEM;
+		printk(KERN_ERR "%s: Not enough memory\n", __func__);
+		goto out;
+	}
+
+	set_bit(EV_KEY, dev->evbit);
+	set_bit(KEY_POWER, dev->keybit);
+
+	dev->name = "Power Button";
+	dev->id.bustype = BUS_HOST;
+
+	/* this makes the button look like an acpi power button
+	 * no clue whether anyone relies on that though */
+	dev->id.product = 0x02;
+	dev->phys = "LNXPWRBN/button/input0";
+
+	button_pdev = platform_device_register_simple("power_button", 0, NULL, 0);
+	if (IS_ERR(button_pdev)) {
+		ret = PTR_ERR(button_pdev);
+		goto out_free_input;
+	}
+
+	dev->dev.parent = &button_pdev->dev;
+ 	ret = input_register_device(dev);
+
+	if (ret) {
+		printk(KERN_ERR "%s: Failed to register device\n", __func__);
+		goto out_free_pdev;
+	}
+
+	button_dev = dev;
+	goto out;
+
+out_free_pdev:
+	platform_device_unregister(button_pdev);
+out_free_input:
+	input_free_device(dev);
+out:
+	return ret;
 }
 device_initcall(cbe_sysreset_init);
 
 int cbe_sysreset_hack(void)
 {
 	struct cbe_pmd_regs __iomem *regs;
+	u64 status;
 
 	/*
 	 * The BMC can inject user triggered system reset exceptions,
@@ -267,10 +317,20 @@ int cbe_sysreset_hack(void)
 		regs = cbe_get_cpu_pmd_regs(0);
 		if (!regs)
 			return 0;
-		if (in_be64(&regs->ras_esc_0) & 0x0000ffff) {
+		status = in_be64(&regs->ras_esc_0);
+		if (status & 0x0000ffff) {
 			out_be64(&regs->ras_esc_0, 0);
 			return 0;
 		}
+		if (status & 0x00010000) {
+			out_be64(&regs->ras_esc_0, 0);
+			if (!button_dev)
+				return 0;
+			input_report_key(button_dev, KEY_POWER, 1);
+			input_sync(button_dev);
+			input_report_key(button_dev, KEY_POWER, 0);
+			input_sync(button_dev);
+		}
 	}
 	return 1;
 }
#8 lore raw

Re: [Cbe-oss-dev] [patch 02/02] powerpc/cell: add support for power button of future IBM cell blades

Quoted 5 lines · Benjamin Herrenschmidt

Sorry Christian, i'm still not too happy with this one. =20
There are two issues at hand here:
=20
=A0- The use of SELECT, that will be frowned on unfortunately.

Ok, this should be easy to fix, by making it depend on INPUT instead, like the ACPI power button does. It's modeled after that anyway.

Quoted 3 lines

=A0- I'm not too sure it's very safe the way you do it. If I understand correctly, you can get called for that sysreset at -any- time, including when interrupts are off right ?

Yes, that sounds like a problem.

Quoted 3 lines

That means potentially, code that has interrupts off will be interrupted by input_report/input_sync, which is really bad (may corrupt the input layer internal list management for example).

I can't think of a case where this can realistically hit us (the blades don't have any other input devices normally), but of course you are right that it's broken anyway.

Quoted 4 lines

You could solve both things with a little trick: Have the platform code just basically set a global flag when the button was pressed and have a module that depends on INPUT & INPUT_DEV poll for it (slowly pls) and do the input report.

Ugly, but doable, yes. I wonder if there is a way that we can trigger some interrupt from system_reset_exception context in order to get around the polling though. tasklets and workqueues unfortunately won't do us any good here because they also depend on disabling interrupts.

	Arnd <><
#9 lore raw

Re: [Cbe-oss-dev] [patch 02/02] powerpc/cell: add support for power button of future IBM cell blades

Quoted 4 lines · Arnd Bergmann

Ugly, but doable, yes. I wonder if there is a way that we can trigger some interrupt from system_reset_exception context in order to get around the polling though. tasklets and workqueues unfortunately won't do us any good here because they also depend on disabling interrupts.

You can trigger a DEC interrupt at any time but you don't have a nice hook to catch it. You can probably trigger an IPI to yourself using a special call to the iic, do we have any available number ?

Ben.

#10 lore raw

Re: [Cbe-oss-dev] [patch 02/02] powerpc/cell: add support for power button of future IBM cell blades

Quoted 9 lines · Benjamin Herrenschmidt
Quoted 4 lines · Arnd Bergmann

Ugly, but doable, yes. I wonder if there is a way that we can trigger some interrupt from system_reset_exception context in order to get around the polling though. tasklets and workqueues unfortunately won't do us any good here because they also depend on disabling interrupts.

You can trigger a DEC interrupt at any time but you don't have a nice hook to catch it. You can probably trigger an IPI to yourself using a special call to the iic, do we have any available number ?

Yes, we are only using 4 out of 15 possible IPIs. Probably worth a try, but it might not be cleaner than your suggested solution.

	Arnd <><
#11 lore raw

Re: [patch 01/11] powerpc/cell: add support for power button of future IBM cell blades

In reply to [email protected]

Hi Arnd,

Quoted 10 lines · On Fri, 04 Jul 2008 21:05:36 +0200 [email protected] wrote:

This patch adds support for the power button on future IBM cell blades. It actually doesn't shut down the machine. Instead it exposes an input device /dev/input/event0 to userspace which sends KEY_POWER if power button has been pressed.
haldaemon actually recognizes the button, so a plattform independent acpid replacement should handle it correctly.

Was this written by you or Christian?

arch/powerpc/platforms/cell/pervasive.c static int cbe_system_reset_exception(struct pt_regs *regs) · line 117

Quoted 10 lines
arch/powerpc/platforms/cell/pervasive.c +2 -1
@@ -105,10 +110,21 @@ static int cbe_system_reset_exception(struct pt_regs *regs)
 		 */
 		if (sysreset_hack && (cpu = smp_processor_id()) == 0) {
 			pmd = cbe_get_cpu_pmd_regs(cpu);
-			if (in_be64(&pmd->ras_esc_0) & 0xffff) {
+			if (in_be64(&pmd->ras_esc_0) & 0x0000ffff) {
 				out_be64(&pmd->ras_esc_0, 0);
 				return 0;
 			}
+			if (in_be64(&pmd->ras_esc_0) & 0x00010000) {

Do we really want to read that register twice? (Just asking, I don't know how the hardware works ...) Also, do we want to recognise this bit even if some lower order bits are set? (this code won't)

Quoted 4 lines
arch/powerpc/platforms/cell/pervasive.c +4 -0
+static int __init cbe_power_button_init(void)
+{
+	int ret;
+	struct input_dev *dev;

arch/powerpc/platforms/cell/pervasive.c void __init cbe_pervasive_init(void) · line 188

Quoted 10 lines
arch/powerpc/platforms/cell/pervasive.c +10 -0
+
+	if (!sysreset_hack)
+		return 0;
+
+	dev = input_allocate_device();
+        if (!dev) {
+		ret = -ENOMEM;
+                printk(KERN_ERR "%s: Not enough memory\n", __func__);
+                goto out;
+        }

Some white space damage here.

arch/powerpc/platforms/cell/pervasive.c void __init cbe_pervasive_init(void) · line 213

Quoted 5 lines
arch/powerpc/platforms/cell/pervasive.c +5 -0
+	ret = input_register_device(dev);
+	if (ret) {
+                printk(KERN_ERR "%s: Failed to register device\n", __func__);
+		goto out_free_pdev;
+        }

And here.

Signature · 3 lines
Cheers,
Stephen Rothwell                    [email protected]
http://www.canb.auug.org.au/~sfr/
#12 lore raw

Re: [Cbe-oss-dev] [patch 01/11] powerpc/cell: add support for power button of future IBM cell blades

Quoted 4 lines · Stephen Rothwell
Quoted 2 lines

Was this written by you or Christian?

It's from Christian. For some reason, the author is reflected correctly in my git tree, but git-format-patch/quilt-mail must have lost that information. I need to check my scripts.

Quoted 6 lines
Quoted 6 lines
arch/powerpc/platforms/cell/pervasive.c +1 -1
@@ -105,10 +110,21 @@ static int cbe_system_reset_exception(struct pt_regs *regs)
 		 */
 		if (sysreset_hack && (cpu = smp_processor_id()) == 0) {
 			pmd = cbe_get_cpu_pmd_regs(cpu);
-			if (in_be64(&pmd->ras_esc_0) & 0xffff) {
+			if (in_be64(&pmd->ras_esc_0) & 0x0000ffff) {
Quoted 8 lines

arch/powerpc/platforms/cell/pervasive.c static int cbe_system_reset_exception(struct pt_regs *regs) · line 117

Quoted 4 lines
arch/powerpc/platforms/cell/pervasive.c +1 -0
 				out_be64(&pmd->ras_esc_0, 0);
 				return 0;
 			}
+			if (in_be64(&pmd->ras_esc_0) & 0x00010000) {

Do we really want to read that register twice? (Just asking, I don't know how the hardware works ...) Also, do we want to recognise this bit even if some lower order bits are set? (this code won't)

It would probably be cleaner to read it just once, but it's safe to read it multiple times. It only gets written by the BMC when a button gets pressed.

The lower bits are for system-reset, i.e. for entering xmon or kdump, while the higher bits are for soft power off, and we certainly don't want to trigger a soft powerp off at the same time as an xmon entry.

	Arnd <><
#13 lore raw

PATCH 2/11 powerpc/axonram: use only one block device major number

In reply to [email protected]

Axonram module registers one block device for each DDR2 DIMM found on a system. This means that each DDR2 DIMM becomes its own block device major number. This patch lets axonram module to register the only one block device for all DDR2 DIMMs which also spares kernel resources.

---
 arch/powerpc/sysdev/axonram.c |   23 +++++++++++++++--------
 1 files changed, 15 insertions(+), 8 deletions(-)
arch/powerpc/sysdev/axonram.c +15 -8
index 7f59188..9b639ed 100644
@@ -57,6 +57,8 @@
 #define AXON_RAM_SECTOR_SIZE		1 << AXON_RAM_SECTOR_SHIFT
 #define AXON_RAM_IRQ_FLAGS		IRQF_SHARED | IRQF_TRIGGER_RISING
 
+static int azfs_major, azfs_minor;
+
 struct axon_ram_bank {
 	struct of_device	*device;
 	struct gendisk		*disk;
@@ -227,19 +229,14 @@ axon_ram_probe(struct of_device *device, const struct of_device_id *device_id)
 		goto failed;
 	}
 
-	bank->disk->first_minor = 0;
+	bank->disk->major = azfs_major;
+	bank->disk->first_minor = azfs_minor;
 	bank->disk->fops = &axon_ram_devops;
 	bank->disk->private_data = bank;
 	bank->disk->driverfs_dev = &device->dev;
 
 	sprintf(bank->disk->disk_name, "%s%d",
 			AXON_RAM_DEVICE_NAME, axon_ram_bank_id);
-	bank->disk->major = register_blkdev(0, bank->disk->disk_name);
-	if (bank->disk->major < 0) {
-		dev_err(&device->dev, "Cannot register block device\n");
-		rc = -EFAULT;
-		goto failed;
-	}
 
 	bank->disk->queue = blk_alloc_queue(GFP_KERNEL);
 	if (bank->disk->queue == NULL) {
@@ -276,6 +273,8 @@ axon_ram_probe(struct of_device *device, const struct of_device_id *device_id)
 		goto failed;
 	}
 
+	azfs_minor += bank->disk->minors;
+
 	return 0;
 
 failed:
@@ -310,7 +309,6 @@ axon_ram_remove(struct of_device *device)
 
 	device_remove_file(&device->dev, &dev_attr_ecc);
 	free_irq(bank->irq_id, device);
-	unregister_blkdev(bank->disk->major, bank->disk->disk_name);
 	del_gendisk(bank->disk);
 	iounmap((void __iomem *) bank->io_addr);
 	kfree(bank);
@@ -341,6 +339,14 @@ static struct of_platform_driver axon_ram_driver = {
 static int __init
 axon_ram_init(void)
 {
+	azfs_major = register_blkdev(azfs_major, AXON_RAM_DEVICE_NAME);
+	if (azfs_major < 0) {
+		printk(KERN_ERR "%s cannot become block device major number\n",
+				AXON_RAM_MODULE_NAME);
+		return -EFAULT;
+	}
+	azfs_minor = 0;
+
 	return of_register_platform_driver(&axon_ram_driver);
 }
 
@@ -351,6 +357,7 @@ static void __exit
 axon_ram_exit(void)
 {
 	of_unregister_platform_driver(&axon_ram_driver);
+	unregister_blkdev(azfs_major, AXON_RAM_DEVICE_NAME);
 }
 
 module_init(axon_ram_init);
Signature · 3 lines
1.5.4.3

-- 
#14 lore raw

PATCH 3/11 powerpc/axonram: enable partitioning of the Axons DDR2 DIMMs

In reply to [email protected]

DDR2 memory DIMMs on the Axon could be accessed only as one partition when using file system drivers which are using the direct_access() method. This patch enables for such file system drivers to access Axon's DDR2 memory even if it is splitted in several partitions.

---
 arch/powerpc/sysdev/axonram.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)
arch/powerpc/sysdev/axonram.c +4 -1
index 9b639ed..9e105cb 100644
@@ -150,7 +150,10 @@ axon_ram_direct_access(struct block_device *device, sector_t sector,
 	struct axon_ram_bank *bank = device->bd_disk->private_data;
 	loff_t offset;
 
-	offset = sector << AXON_RAM_SECTOR_SHIFT;
+	offset = sector;
+	if (device->bd_part != NULL)
+		offset += device->bd_part->start_sect;
+	offset <<= AXON_RAM_SECTOR_SHIFT;
 	if (offset >= bank->size) {
 		dev_err(&bank->device->dev, "Access outside of address space\n");
 		return -ERANGE;
Signature · 3 lines
1.5.4.3

-- 
#15 lore raw

PATCH 4/11 powerpc/spufs: add atomic busy_spus counter to struct cbe_spu_info

In reply to [email protected]

As nr_active counter includes also spus waiting for syscalls to return we need a seperate counter that only counts spus that are currently running on spu side. This counter shall be used by a cpufreq governor that targets a frequency dependent from the number of running spus.

From: Maxim Shchetynin <[email protected]>

---
 arch/powerpc/platforms/cell/spufs/sched.c |    6 ++++++
 include/asm-powerpc/spu.h                 |    1 +
 2 files changed, 7 insertions(+), 0 deletions(-)
arch/powerpc/platforms/cell/spufs/sched.c +6 -0
index e929e70..be77910 100644
@@ -993,6 +993,7 @@ void spuctx_switch_state(struct spu_context *ctx,
 	struct timespec ts;
 	struct spu *spu;
 	enum spu_utilization_state old_state;
+	int node;
 
 	ktime_get_ts(&ts);
 	curtime = timespec_to_ns(&ts);
@@ -1014,6 +1015,11 @@ void spuctx_switch_state(struct spu_context *ctx,
 		spu->stats.times[old_state] += delta;
 		spu->stats.util_state = new_state;
 		spu->stats.tstamp = curtime;
+		node = spu->node;
+		if (old_state == SPU_UTIL_USER)
+			atomic_dec(&cbe_spu_info[node].busy_spus);
+		if (new_state == SPU_UTIL_USER);
+			atomic_inc(&cbe_spu_info[node].busy_spus);
 	}
 }
 
include/asm-powerpc/spu.h +1 -0
index 99348c1..8b2eb04 100644
@@ -191,6 +191,7 @@ struct cbe_spu_info {
 	struct list_head spus;
 	int n_spus;
 	int nr_active;
+	atomic_t busy_spus;
 	atomic_t reserved_spus;
 };
 
Signature · 3 lines
1.5.4.3

-- 
#16 lore raw

Re: [patch 04/11] powerpc/spufs: add atomic busy_spus counter to struct cbe_spu_info

Quoted 9 lines · On Fri, 2008-07-04 at 21:05 +0200, [email protected] wrote:

plain text document attachment (0004-powerpc-spufs-add-atomic-busy_spus-counter-to-struc.patch) As nr_active counter includes also spus waiting for syscalls to return we need a seperate counter that only counts spus that are currently running on spu side. This counter shall be used by a cpufreq governor that targets a frequency dependent from the number of running spus.

From: Maxim Shchetynin <[email protected]>

This needs your S-O-B, Arnd, and should go via jk.

Cheers,
Ben.

Quoted 44 lines
---
 arch/powerpc/platforms/cell/spufs/sched.c |    6 ++++++
 include/asm-powerpc/spu.h                 |    1 +
 2 files changed, 7 insertions(+), 0 deletions(-)
arch/powerpc/platforms/cell/spufs/sched.c +6 -0
index e929e70..be77910 100644
@@ -993,6 +993,7 @@ void spuctx_switch_state(struct spu_context *ctx,
 	struct timespec ts;
 	struct spu *spu;
 	enum spu_utilization_state old_state;
+	int node;
 
 	ktime_get_ts(&ts);
 	curtime = timespec_to_ns(&ts);
@@ -1014,6 +1015,11 @@ void spuctx_switch_state(struct spu_context *ctx,
 		spu->stats.times[old_state] += delta;
 		spu->stats.util_state = new_state;
 		spu->stats.tstamp = curtime;
+		node = spu->node;
+		if (old_state == SPU_UTIL_USER)
+			atomic_dec(&cbe_spu_info[node].busy_spus);
+		if (new_state == SPU_UTIL_USER);
+			atomic_inc(&cbe_spu_info[node].busy_spus);
 	}
 }
 
include/asm-powerpc/spu.h +1 -0
index 99348c1..8b2eb04 100644
@@ -191,6 +191,7 @@ struct cbe_spu_info {
 	struct list_head spus;
 	int n_spus;
 	int nr_active;
+	atomic_t busy_spus;
 	atomic_t reserved_spus;
 };
 
Signature · 1 line
1.5.4.3
#17 lore raw

Re: [patch 04/11] powerpc/spufs: add atomic busy_spus counter to struct cbe_spu_info

Quoted 9 lines · On Mon, 07 Jul 2008 15:19:01 +1000 Benjamin Herrenschmidt…
Quoted 7 lines · On Fri, 2008-07-04 at 21:05 +0200, [email protected] wrote:

plain text document attachment (0004-powerpc-spufs-add-atomic-busy_spus-counter-to-struc.patch) As nr_active counter includes also spus waiting for syscalls to return we need a seperate counter that only counts spus that are currently running on spu side. This counter shall be used by a cpufreq governor that targets a frequency dependent from the number of running spus.

Quoted 4 lines
Quoted 2 lines

From: Maxim Shchetynin <[email protected]>

This needs your S-O-B, Arnd, and should go via jk.

And the From line should be the first so the Author is correctly attributed.

Signature · 3 lines
Cheers,
Stephen Rothwell                    [email protected]
http://www.canb.auug.org.au/~sfr/
#18 lore raw

Re: [Cbe-oss-dev] [patch 04/11] powerpc/spufs: add atomic busy_spus counter to struct cbe_spu_info

Quoted 5 lines · Stephen Rothwell
Quoted 5 lines
Quoted 3 lines

From: Maxim Shchetynin <[email protected]>

This needs your S-O-B, Arnd, and should go via jk.

I noticed the missing S-O-B already after I had sent it, and corrected it in the git.

Since this patch is a prerequisite for patch 5/11, I'd like to keep them in order. Jeremy, can you add your Acked-by?

Quoted 2 lines

And the From line should be the first so the Author is correctly attributed.

Right, this one again got missing in quilt-mail.

	Arnd <><
#19 lore raw

PATCH 5/11 powerpc/cell: add spu aware cpufreq governor

In reply to [email protected]

This patch adds a cpufreq governor that takes the number of running spus into account. It's very similar to the ondemand governor, but not as complex. Instead of hacking spu load into the ondemand governor it might be easier to have cpufreq accepting multiple governors per cpu in future. Don't know if this is the right way, but it would keep the governors simple.

---
 arch/powerpc/platforms/cell/Kconfig            |   10 ++
 arch/powerpc/platforms/cell/Makefile           |    1 +
 arch/powerpc/platforms/cell/cbe_spu_governor.c |  183 ++++++++++++++++++++++++
 3 files changed, 194 insertions(+), 0 deletions(-)
 create mode 100644 arch/powerpc/platforms/cell/cbe_spu_governor.c
arch/powerpc/platforms/cell/Kconfig +10 -0
index 3959fcf..2dfff9f 100644
@@ -107,6 +107,16 @@ config CBE_CPUFREQ_PMI
 	  processor will not only be able to run at lower speed,
 	  but also at lower core voltage.
 
+config CBE_CPUFREQ_SPU_GOVERNOR
+	tristate "CBE frequency scaling based on SPU usage"
+	depends on SPU_FS
+	select CBE_CPUFREQ
+	default m
+	help
+	  This governor checks for spu usage to adjust the cpu frequency.
+	  If no spu is running on a given cpu, that cpu will be throttled to
+	  the minimal possible frequency.
+
 endmenu
 
 config OPROFILE_CELL
arch/powerpc/platforms/cell/Makefile +1 -0
index c2a7e4e..8be5158 100644
@@ -8,6 +8,7 @@ obj-$(CONFIG_CBE_THERM)			+= cbe_thermal.o
 obj-$(CONFIG_CBE_CPUFREQ_PMI)		+= cbe_cpufreq_pmi.o
 obj-$(CONFIG_CBE_CPUFREQ)		+= cbe-cpufreq.o
 cbe-cpufreq-y				+= cbe_cpufreq_pervasive.o cbe_cpufreq.o
+obj-$(CONFIG_CBE_CPUFREQ_SPU_GOVERNOR)	+= cbe_spu_governor.o
 
 ifeq ($(CONFIG_SMP),y)
 obj-$(CONFIG_PPC_CELL_NATIVE)		+= smp.o
arch/powerpc/platforms/cell/cbe_spu_governor.c new file +183 -0

183 lines not on this page · raw message

Signature · 3 lines
1.5.4.3

-- 
#20 lore raw

Re: [patch 05/11] powerpc/cell: add spu aware cpufreq governor

Quoted 9 lines · On Fri, 2008-07-04 at 21:05 +0200, [email protected] wrote:

plain text document attachment (0005-powerpc-cell-add-spu-aware-cpufreq-governor.patch)
This patch adds a cpufreq governor that takes the number of running spus into account. It's very similar to the ondemand governor, but not as complex. Instead of hacking spu load into the ondemand governor it might be easier to have cpufreq accepting multiple governors per cpu in future. Don't know if this is the right way, but it would keep the governors simple.

Arnd, your S-O-B ?

Also, there's the question of whether this should also go in drivers/cpufreq or not and should be reviewed by the cpufreq maintainer (whoever that is), no ?

Cheers,
Ben.

Quoted 232 lines
---
 arch/powerpc/platforms/cell/Kconfig            |   10 ++
 arch/powerpc/platforms/cell/Makefile           |    1 +
 arch/powerpc/platforms/cell/cbe_spu_governor.c |  183 ++++++++++++++++++++++++
 3 files changed, 194 insertions(+), 0 deletions(-)
 create mode 100644 arch/powerpc/platforms/cell/cbe_spu_governor.c
arch/powerpc/platforms/cell/Kconfig +10 -0
index 3959fcf..2dfff9f 100644
@@ -107,6 +107,16 @@ config CBE_CPUFREQ_PMI
 	  processor will not only be able to run at lower speed,
 	  but also at lower core voltage.
 
+config CBE_CPUFREQ_SPU_GOVERNOR
+	tristate "CBE frequency scaling based on SPU usage"
+	depends on SPU_FS
+	select CBE_CPUFREQ
+	default m
+	help
+	  This governor checks for spu usage to adjust the cpu frequency.
+	  If no spu is running on a given cpu, that cpu will be throttled to
+	  the minimal possible frequency.
+
 endmenu
 
 config OPROFILE_CELL
arch/powerpc/platforms/cell/Makefile +1 -0
index c2a7e4e..8be5158 100644
@@ -8,6 +8,7 @@ obj-$(CONFIG_CBE_THERM)			+= cbe_thermal.o
 obj-$(CONFIG_CBE_CPUFREQ_PMI)		+= cbe_cpufreq_pmi.o
 obj-$(CONFIG_CBE_CPUFREQ)		+= cbe-cpufreq.o
 cbe-cpufreq-y				+= cbe_cpufreq_pervasive.o cbe_cpufreq.o
+obj-$(CONFIG_CBE_CPUFREQ_SPU_GOVERNOR)	+= cbe_spu_governor.o
 
 ifeq ($(CONFIG_SMP),y)
 obj-$(CONFIG_PPC_CELL_NATIVE)		+= smp.o
arch/powerpc/platforms/cell/cbe_spu_governor.c new file +183 -0
new file mode 100644
index 0000000..7e63009
@@ -0,0 +1,183 @@
+/*
+ * spu aware cpufreq governor for the cell processor
+ *
+ * (C) Copyright IBM Corporation 2006-2008
+ *
+ * Author: Christian Krafft <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <linux/cpufreq.h>
+#include <linux/sched.h>
+#include <linux/timer.h>
+#include <linux/workqueue.h>
+#include <asm/atomic.h>
+#include <asm/machdep.h>
+#include <asm/spu.h>
+
+#define POLL_TIME	100000		/* in us */
+#define EXP		753		/* exp(-1) in fixed-point */
+
+struct spu_gov_info_struct {
+	unsigned long busy_spus;	/* fixed-point */
+	struct cpufreq_policy *policy;
+	struct delayed_work work;
+	unsigned int poll_int;		/* us */
+};
+static DEFINE_PER_CPU(struct spu_gov_info_struct, spu_gov_info);
+
+static struct workqueue_struct *kspugov_wq;
+
+static int calc_freq(struct spu_gov_info_struct *info)
+{
+	int cpu;
+	int busy_spus;
+
+	cpu = info->policy->cpu;
+	busy_spus = atomic_read(&cbe_spu_info[cpu_to_node(cpu)].busy_spus);
+
+	CALC_LOAD(info->busy_spus, EXP, busy_spus * FIXED_1);
+	pr_debug(KERN_ERR "cpu %d: busy_spus=%d, info->busy_spus=%d\n", cpu, busy_spus, info->busy_spus);
+
+	return info->policy->max * info->busy_spus / FIXED_1;
+}
+
+static void spu_gov_work(struct work_struct *work)
+{
+	struct spu_gov_info_struct *info;
+	int delay;
+	unsigned long target_freq;
+
+	info = container_of(work, struct spu_gov_info_struct, work.work);
+
+	/* after cancel_delayed_work_sync we unset info->policy */
+	BUG_ON(info->policy == NULL);
+
+	target_freq = calc_freq(info);
+	__cpufreq_driver_target(info->policy, target_freq, CPUFREQ_RELATION_H);
+
+	delay = usecs_to_jiffies(info->poll_int);
+	queue_delayed_work_on(info->policy->cpu, kspugov_wq, &info->work, delay);
+}
+
+static void spu_gov_init_work(struct spu_gov_info_struct *info)
+{
+	int delay = usecs_to_jiffies(info->poll_int);
+	INIT_DELAYED_WORK_DEFERRABLE(&info->work, spu_gov_work);
+	queue_delayed_work_on(info->policy->cpu, kspugov_wq, &info->work, delay);
+}
+
+static void spu_gov_cancel_work(struct spu_gov_info_struct *info)
+{
+	cancel_delayed_work_sync(&info->work);
+}
+
+static int spu_gov_govern(struct cpufreq_policy *policy, unsigned int event)
+{
+	unsigned int cpu = policy->cpu;
+	struct spu_gov_info_struct *info, *affected_info;
+	int i;
+	int ret = 0;
+
+	info = &per_cpu(spu_gov_info, cpu);
+
+	switch (event) {
+	case CPUFREQ_GOV_START:
+		if (!cpu_online(cpu)) {
+			printk(KERN_ERR "cpu %d is not online\n", cpu);
+			ret = -EINVAL;
+			break;
+		}
+
+		if (!policy->cur) {
+			printk(KERN_ERR "no cpu specified in policy\n");
+			ret = -EINVAL;
+			break;
+		}
+
+		/* initialize spu_gov_info for all affected cpus */
+		for_each_cpu_mask(i, policy->cpus) {
+			affected_info = &per_cpu(spu_gov_info, i);
+			affected_info->policy = policy;
+		}
+
+		info->poll_int = POLL_TIME;
+
+		/* setup timer */
+		spu_gov_init_work(info);
+
+		break;
+
+	case CPUFREQ_GOV_STOP:
+		/* cancel timer */
+		spu_gov_cancel_work(info);
+
+		/* clean spu_gov_info for all affected cpus */
+		for_each_cpu_mask (i, policy->cpus) {
+			info = &per_cpu(spu_gov_info, i);
+			info->policy = NULL;
+		}
+
+		break;
+	}
+
+	return ret;
+}
+
+static struct cpufreq_governor spu_governor = {
+	.name = "spu_governor",
+	.governor = spu_gov_govern,
+	.owner = THIS_MODULE,
+};
+
+/*
+ * module init and destoy
+ */
+
+static int __init spu_gov_init(void)
+{
+	int ret;
+
+	kspugov_wq = create_workqueue("kspugov");
+	if (!kspugov_wq) {
+		printk(KERN_ERR "creation of kspugov failed\n");
+		ret = -EFAULT;
+		goto out;
+	}
+
+	ret = cpufreq_register_governor(&spu_governor);
+	if (ret) {
+		printk(KERN_ERR "registration of governor failed\n");
+		destroy_workqueue(kspugov_wq);
+		goto out;
+	}
+out:
+	return ret;
+}
+
+static void __exit spu_gov_exit(void)
+{
+	cpufreq_unregister_governor(&spu_governor);
+	destroy_workqueue(kspugov_wq);
+}
+
+
+module_init(spu_gov_init);
+module_exit(spu_gov_exit);
+
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Christian Krafft <[email protected]>");
+
Signature · 1 line
1.5.4.3
#21 lore raw

Re: [patch 05/11] powerpc/cell: add spu aware cpufreq governor

Quoted 4 lines · On Mon, 07 Jul 2008 15:21:59 +1000 Benjamin Herrenschmidt…
Quoted 2 lines · On Fri, 2008-07-04 at 21:05 +0200, [email protected] wrote:

plain text document attachment (0005-powerpc-cell-add-spu-aware-cpufreq-governor.patch)

We probably don't need to know that :-)

Quoted 9 lines
Quoted 7 lines

This patch adds a cpufreq governor that takes the number of running spus into account. It's very similar to the ondemand governor, but not as complex. Instead of hacking spu load into the ondemand governor it might be easier to have cpufreq accepting multiple governors per cpu in future. Don't know if this is the right way, but it would keep the governors simple.

Arnd, your S-O-B ?

And a leading From line if it was written by Christian.

Signature · 3 lines
Cheers,
Stephen Rothwell                    [email protected]
http://www.canb.auug.org.au/~sfr/
#22 lore raw

Re: [Cbe-oss-dev] [patch 05/11] powerpc/cell: add spu aware cpufreq governor

In reply to Benjamin Herrenschmidt
Quoted 3 lines · Benjamin Herrenschmidt

Also, there's the question of whether this should also go in drivers/cpufreq or not and should be reviewed by the cpufreq maintainer (whoever that is), no ?

Good point. Let's see if Dave Jones has a few cycles for a review of this.

	Arnd <><
#23 lore raw

Re: [patch 05/11] powerpc/cell: add spu aware cpufreq governor

In reply to [email protected]

Just a couple of trivial things.

Quoted 2 lines · On Fri, 04 Jul 2008 21:05:40 +0200 [email protected] wrote:

+ * (C) Copyright IBM Corporation 2006-2008

      ^^^

You should use ©.

Quoted 1 line

+#define POLL_TIME 100000 /* in us */

                                              ^

How about μ ?

arch/powerpc/platforms/cell/cbe_spu_governor.c line 38

Quoted 5 lines
arch/powerpc/platforms/cell/cbe_spu_governor.c new file +5 -0
+struct spu_gov_info_struct {
+	unsigned long busy_spus;	/* fixed-point */
+	struct cpufreq_policy *policy;
+	struct delayed_work work;
+	unsigned int poll_int;		/* us */

And again.

arch/powerpc/platforms/cell/cbe_spu_governor.c line 53

Quoted 10 lines
arch/powerpc/platforms/cell/cbe_spu_governor.c new file +10 -0
+static int calc_freq(struct spu_gov_info_struct *info)
+{
+	int cpu;
+	int busy_spus;
+
+	cpu = info->policy->cpu;
+	busy_spus = atomic_read(&cbe_spu_info[cpu_to_node(cpu)].busy_spus);
+
+	CALC_LOAD(info->busy_spus, EXP, busy_spus * FIXED_1);
+	pr_debug(KERN_ERR "cpu %d: busy_spus=%d, info->busy_spus=%d\n", cpu, busy_spus, info->busy_spus);

Split this line.

Signature · 3 lines
Cheers,
Stephen Rothwell                    [email protected]
http://www.canb.auug.org.au/~sfr/
#24 lore raw

Re: [Cbe-oss-dev] [patch 05/11] powerpc/cell: add spu aware cpufreq governor

Quoted 3 lines · Stephen Rothwell
Quoted 3 lines

+

+=A0=A0=A0=A0=A0CALC_LOAD(info->busy_spus, EXP, busy_spus * FIXED_1);
+=A0=A0=A0=A0=A0pr_debug(KERN_ERR "cpu %d: busy_spus=3D%d, info->busy_s=

pus=3D%d\n", cpu, busy_spus, info->busy_spus);

Quoted 2 lines

=20
Split this line.

Right, also: leave out the KERN_ERR in pr_debug, and use %ld for info->busy= _spus.

	Arnd <><
#25 lore raw

Re: [Cbe-oss-dev] [patch 05/11] powerpc/cell: add spu aware cpufreq governor

In reply to Stephen Rothwell

T24gTW9uZGF5IDA3IEp1bHkgMjAwOCwgU3RlcGhlbiBSb3Rod2VsbCB3cm90ZToKPiA+ICsjZGVm aW5lIFBPTExfVElNRcKgwqDCoMKgMTAwMDAwwqDCoMKgwqDCoMKgwqDCoMKgwqAvKiBpbiB1cyAq Lwo+IMKgIMKgIMKgIMKgIMKgIMKgIMKgIMKgIMKgIMKgIMKgIMKgIMKgIMKgIMKgIMKgIMKgIMKg IMKgIMKgIMKgIMKgIMKgIF4KPiBIb3cgYWJvdXQgzrwgPwoKTm90IHN1cmUsIGhvdyBhYm91dCDC tSBpbnN0ZWFkPyA7LSkKCglBcm5kIDw+PAo=

#26 lore raw

Re: [Cbe-oss-dev] [patch 05/11] powerpc/cell: add spu aware cpufreq governor

Quoted 6 lines · Arnd Bergmann
Quoted 3 lines · Stephen Rothwell
Quoted 1 line

+#define POLL_TIME 100000 /* in us */

                                              ^

How about μ ?

Not sure, how about µ instead? ;-)

Erm... don't get it. You have identical characters here.

josh

#27 lore raw

Re: [Cbe-oss-dev] [patch 05/11] powerpc/cell: add spu aware cpufreq governor

Quoted 4 lines · Josh Boyer

0% probability of being spam.
=20
Full report:
No, score=3D-2.6 required=3D5.0 tests=3DAWL,BAYES_00 autolearn=3Dham vers=

ion=3D3.2.4 =C2=A0

Quoted 3 lines · Arnd Bergmann
Quoted 2 lines · Stephen Rothwell
Quoted 1 line
Quoted 1 line

+#define POLL_TIME =C2=A0 =C2=A0100000 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =

=C2=A0/* in us */

Quoted 1 line
Quoted 1 line
Quoted 1 line

=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=

=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 ^

Quoted 5 lines
Quoted 3 lines
Quoted 1 line

How about =CE=BC ?

=20
Not sure, how about =C2=B5 instead? ;-)

=20
Erm... don't get it. =C2=A0You have identical characters here.

That depends on the tool you use to look at it.

Stephen wrote a Unicode character U+03BC from the Greek alphabet part of unicode, I wrote unicode character U+00B5 from the Latin-1 code page. In my mail client, latin-1 characters get rendered in the default font, but it has to change the font for less common scripts.

	Arnd <><
#28 lore raw

Re: [Cbe-oss-dev] [patch 05/11] powerpc/cell: add spu aware cpufreq governor

Quoted 13 lines · Arnd Bergmann
Quoted 12 lines · Josh Boyer

0% probability of being spam.

Full report:
No, score=-2.6 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.2.4

Quoted 6 lines · Arnd Bergmann
Quoted 3 lines · Stephen Rothwell
Quoted 1 line

+#define POLL_TIME 100000 /* in us */

                                              ^

How about μ ?

Not sure, how about µ instead? ;-)

Quoted 8 lines
Quoted 1 line

Erm... don't get it. You have identical characters here.

That depends on the tool you use to look at it.

Stephen wrote a Unicode character U+03BC from the Greek alphabet part of unicode, I wrote unicode character U+00B5 from the Latin-1 code page. In my mail client, latin-1 characters get rendered in the default font, but it has to change the font for less common scripts.

I thought Unicode was supposed to _improve_ stuff like that... ;)

josh

#29 lore raw

Re: [Cbe-oss-dev] [patch 05/11] powerpc/cell: add spu aware cpufreq governor

Quoted 14 lines · On Mon, 07 Jul 2008 17:17:57 -0400 Josh Boyer <[email protected]> wrote:
Quoted 12 lines · Arnd Bergmann
Quoted 10 lines · Josh Boyer
Quoted 6 lines · Arnd Bergmann
Quoted 3 lines · Stephen Rothwell
Quoted 1 line

+#define POLL_TIME 100000 /* in us */

                                              ^

How about μ ?

Not sure, how about µ instead? ;-)

Erm... don't get it. You have identical characters here.

Quoted 8 lines
Quoted 6 lines

That depends on the tool you use to look at it.

Stephen wrote a Unicode character U+03BC from the Greek alphabet part of unicode, I wrote unicode character U+00B5 from the Latin-1 code page. In my mail client, latin-1 characters get rendered in the default font, but it has to change the font for less common scripts.

I thought Unicode was supposed to _improve_ stuff like that... ;)

In fact, Arnd was right, I used the Greek letter mu (μ) while he chose the micro sign (µ). So, the lartter (Unicode 0x00B5) it should be.

Signature · 3 lines
Cheers,
Stephen Rothwell                    [email protected]
http://www.canb.auug.org.au/~sfr/
#30 lore raw

Re: [patch 05/11] powerpc/cell: add spu aware cpufreq governor

In reply to [email protected]
Quoted 5 lines · [email protected] wrote:

This patch adds a cpufreq governor that takes the number of running spus into account. It's very similar to the ondemand governor, but not as complex. Instead of hacking spu load into the ondemand governor it might be easier to have cpufreq accepting multiple governors per cpu in future. Don't know if this is the right way, but it would keep the governors simple.

I tried your current cell-2.6.git #cell_next branch with ps3_defconfig and get these. ps3_defconfig has

CONFIG_CBE_CPUFREQ=m
CONFIG_CBE_CPUFREQ_SPU_GOVERNOR=m

I'm not sure if this patch is the one that introduced the problem though. I guess we need to make an adjustment in the Kconfig. I'll be away the rest of this week, and will look at it next week if you don't.

-Geoff

cell-2.6/arch/powerpc/platforms/cell/cbe_spu_governor.c: In function 'calc_freq':
cell-2.6/arch/powerpc/platforms/cell/cbe_spu_governor.c:53: warning: format '%d' expects type 'int', but argument 4 has type 'long unsigned int'

ERROR: ".cpufreq_register_governor" [arch/powerpc/platforms/cell/cbe_spu_governor.ko] undefined!
ERROR: ".__cpufreq_driver_target" [arch/powerpc/platforms/cell/cbe_spu_governor.ko] undefined!
ERROR: ".cpufreq_unregister_governor" [arch/powerpc/platforms/cell/cbe_spu_governor.ko] undefined!
ERROR: ".cpufreq_frequency_table_target" [arch/powerpc/platforms/cell/cbe-cpufreq.ko] undefined!
ERROR: ".cpufreq_register_driver" [arch/powerpc/platforms/cell/cbe-cpufreq.ko] undefined!
ERROR: ".cpufreq_frequency_table_verify" [arch/powerpc/platforms/cell/cbe-cpufreq.ko] undefined!
ERROR: ".cpufreq_frequency_table_get_attr" [arch/powerpc/platforms/cell/cbe-cpufreq.ko] undefined!
ERROR: ".cpufreq_notify_transition" [arch/powerpc/platforms/cell/cbe-cpufreq.ko] undefined!
ERROR: ".cpufreq_frequency_table_cpuinfo" [arch/powerpc/platforms/cell/cbe-cpufreq.ko] undefined!
ERROR: ".cbe_get_cpu_mic_tm_regs" [arch/powerpc/platforms/cell/cbe-cpufreq.ko] undefined!
ERROR: ".cbe_get_cpu_pmd_regs" [arch/powerpc/platforms/cell/cbe-cpufreq.ko] undefined!
ERROR: ".cpufreq_unregister_driver" [arch/powerpc/platforms/cell/cbe-cpufreq.ko] undefined!
ERROR: ".cpufreq_frequency_table_put_attr" [arch/powerpc/platforms/cell/cbe-cpufreq.ko] undefined!

#31 lore raw

PATCH 6/11 powerpc: Add struct iommu_table argument to iommu_map_sg()

In reply to [email protected]

Make iommu_map_sg take a struct iommu_table. It did so before commit 740c3ce66700640a6e6136ff679b067e92125794 (iommu sg merging: ppc: make iommu respect the segment size limits).

This stops the function looking in the archdata.dma_data for the iommu table because in the future it will be called with a device that has no table there.

This also has the nice side effect of making iommu_map_sg() match the other map functions.

---
 arch/powerpc/kernel/dma_64.c |    2 +-
 arch/powerpc/kernel/iommu.c  |    7 +++----
 include/asm-powerpc/iommu.h  |    6 +++---
 3 files changed, 7 insertions(+), 8 deletions(-)
arch/powerpc/kernel/dma_64.c +1 -1
index 3a317cb..7397445 100644
@@ -68,7 +68,7 @@ static void dma_iommu_unmap_single(struct device *dev, dma_addr_t dma_handle,
 static int dma_iommu_map_sg(struct device *dev, struct scatterlist *sglist,
 			    int nelems, enum dma_data_direction direction)
 {
-	return iommu_map_sg(dev, sglist, nelems,
+	return iommu_map_sg(dev, dev->archdata.dma_data, sglist, nelems,
 			    device_to_mask(dev), direction);
 }
 
arch/powerpc/kernel/iommu.c +3 -4
index 0c66366..ccf00fe 100644
@@ -267,11 +267,10 @@ static void iommu_free(struct iommu_table *tbl, dma_addr_t dma_addr,
 	spin_unlock_irqrestore(&(tbl->it_lock), flags);
 }
 
-int iommu_map_sg(struct device *dev, struct scatterlist *sglist,
-		 int nelems, unsigned long mask,
-		 enum dma_data_direction direction)
+int iommu_map_sg(struct device *dev, struct iommu_table *tbl,
+		 struct scatterlist *sglist, int nelems,
+		 unsigned long mask, enum dma_data_direction direction)
 {
-	struct iommu_table *tbl = dev->archdata.dma_data;
 	dma_addr_t dma_next = 0, dma_addr;
 	unsigned long flags;
 	struct scatterlist *s, *outs, *segstart;
include/asm-powerpc/iommu.h +3 -3
index 852e15f..65f6682 100644
@@ -79,9 +79,9 @@ extern void iommu_free_table(struct iommu_table *tbl, const char *node_name);
 extern struct iommu_table *iommu_init_table(struct iommu_table * tbl,
 					    int nid);
 
-extern int iommu_map_sg(struct device *dev, struct scatterlist *sglist,
-			int nelems, unsigned long mask,
-			enum dma_data_direction direction);
+extern int iommu_map_sg(struct device *dev, struct iommu_table *tbl,
+			struct scatterlist *sglist, int nelems,
+			unsigned long mask, enum dma_data_direction direction);
 extern void iommu_unmap_sg(struct iommu_table *tbl, struct scatterlist *sglist,
 			   int nelems, enum dma_data_direction direction);
 
Signature · 3 lines
1.5.4.3

-- 
#32 lore raw

PATCH 7/11 powerpc/dma: implement new dma_*map*_attrs() interfaces

In reply to [email protected]

Update powerpc to use the new dma_*map*_attrs() interfaces. In doing so update struct dma_mapping_ops to accept a struct dma_attrs and propagate these changes through to all users of the code (generic IOMMU and the 64bit DMA code, and the iseries and ps3 platform code).

The old dma_*map_*() interfaces are reimplemented as calls to the corresponding new interfaces.

---
 arch/powerpc/Kconfig                    |    1 +
 arch/powerpc/kernel/dma_64.c            |   34 ++++++---
 arch/powerpc/kernel/ibmebus.c           |   12 ++-
 arch/powerpc/kernel/iommu.c             |   11 ++-
 arch/powerpc/platforms/iseries/iommu.c  |    4 +-
 arch/powerpc/platforms/ps3/system-bus.c |   17 +++--
 include/asm-powerpc/dma-mapping.h       |  116 +++++++++++++++++++++++--------
 include/asm-powerpc/iommu.h             |   12 ++-
 8 files changed, 144 insertions(+), 63 deletions(-)
arch/powerpc/Kconfig +1 -0
index f2a0f50..462c86a 100644
@@ -110,6 +110,7 @@ config PPC
 	select HAVE_KPROBES
 	select HAVE_KRETPROBES
 	select HAVE_LMB
+	select HAVE_DMA_ATTRS
 
 config EARLY_PRINTK
 	bool
arch/powerpc/kernel/dma_64.c +22 -12
index 7397445..3ae0c35 100644
@@ -50,32 +50,38 @@ static void dma_iommu_free_coherent(struct device *dev, size_t size,
  */
 static dma_addr_t dma_iommu_map_single(struct device *dev, void *vaddr,
 				       size_t size,
-				       enum dma_data_direction direction)
+				       enum dma_data_direction direction,
+				       struct dma_attrs *attrs)
 {
 	return iommu_map_single(dev, dev->archdata.dma_data, vaddr, size,
-			        device_to_mask(dev), direction);
+				device_to_mask(dev), direction, attrs);
 }
 
 
 static void dma_iommu_unmap_single(struct device *dev, dma_addr_t dma_handle,
 				   size_t size,
-				   enum dma_data_direction direction)
+				   enum dma_data_direction direction,
+				   struct dma_attrs *attrs)
 {
-	iommu_unmap_single(dev->archdata.dma_data, dma_handle, size, direction);
+	iommu_unmap_single(dev->archdata.dma_data, dma_handle, size, direction,
+			   attrs);
 }
 
 
 static int dma_iommu_map_sg(struct device *dev, struct scatterlist *sglist,
-			    int nelems, enum dma_data_direction direction)
+			    int nelems, enum dma_data_direction direction,
+			    struct dma_attrs *attrs)
 {
 	return iommu_map_sg(dev, dev->archdata.dma_data, sglist, nelems,
-			    device_to_mask(dev), direction);
+			    device_to_mask(dev), direction, attrs);
 }
 
 static void dma_iommu_unmap_sg(struct device *dev, struct scatterlist *sglist,
-		int nelems, enum dma_data_direction direction)
+		int nelems, enum dma_data_direction direction,
+		struct dma_attrs *attrs)
 {
-	iommu_unmap_sg(dev->archdata.dma_data, sglist, nelems, direction);
+	iommu_unmap_sg(dev->archdata.dma_data, sglist, nelems, direction,
+		       attrs);
 }
 
 /* We support DMA to/from any memory page via the iommu */
@@ -148,19 +154,22 @@ static void dma_direct_free_coherent(struct device *dev, size_t size,
 
 static dma_addr_t dma_direct_map_single(struct device *dev, void *ptr,
 					size_t size,
-					enum dma_data_direction direction)
+					enum dma_data_direction direction,
+					struct dma_attrs *attrs)
 {
 	return virt_to_abs(ptr) + get_dma_direct_offset(dev);
 }
 
 static void dma_direct_unmap_single(struct device *dev, dma_addr_t dma_addr,
 				    size_t size,
-				    enum dma_data_direction direction)
+				    enum dma_data_direction direction,
+				    struct dma_attrs *attrs)
 {
 }
 
 static int dma_direct_map_sg(struct device *dev, struct scatterlist *sgl,
-			     int nents, enum dma_data_direction direction)
+			     int nents, enum dma_data_direction direction,
+			     struct dma_attrs *attrs)
 {
 	struct scatterlist *sg;
 	int i;
@@ -174,7 +183,8 @@ static int dma_direct_map_sg(struct device *dev, struct scatterlist *sgl,
 }
 
 static void dma_direct_unmap_sg(struct device *dev, struct scatterlist *sg,
-				int nents, enum dma_data_direction direction)
+				int nents, enum dma_data_direction direction,
+				struct dma_attrs *attrs)
 {
 }
 
arch/powerpc/kernel/ibmebus.c +8 -4
index 9971159..e3b1fcd 100644
@@ -82,7 +82,8 @@ static void ibmebus_free_coherent(struct device *dev,
 static dma_addr_t ibmebus_map_single(struct device *dev,
 				     void *ptr,
 				     size_t size,
-				     enum dma_data_direction direction)
+				     enum dma_data_direction direction,
+				     struct dma_attrs *attrs)
 {
 	return (dma_addr_t)(ptr);
 }
@@ -90,14 +91,16 @@ static dma_addr_t ibmebus_map_single(struct device *dev,
 static void ibmebus_unmap_single(struct device *dev,
 				 dma_addr_t dma_addr,
 				 size_t size,
-				 enum dma_data_direction direction)
+				 enum dma_data_direction direction,
+				 struct dma_attrs *attrs)
 {
 	return;
 }
 
 static int ibmebus_map_sg(struct device *dev,
 			  struct scatterlist *sgl,
-			  int nents, enum dma_data_direction direction)
+			  int nents, enum dma_data_direction direction,
+			  struct dma_attrs *attrs)
 {
 	struct scatterlist *sg;
 	int i;
@@ -112,7 +115,8 @@ static int ibmebus_map_sg(struct device *dev,
 
 static void ibmebus_unmap_sg(struct device *dev,
 			     struct scatterlist *sg,
-			     int nents, enum dma_data_direction direction)
+			     int nents, enum dma_data_direction direction,
+			     struct dma_attrs *attrs)
 {
 	return;
 }
arch/powerpc/kernel/iommu.c +7 -4
index ccf00fe..8c68ee9 100644
@@ -269,7 +269,8 @@ static void iommu_free(struct iommu_table *tbl, dma_addr_t dma_addr,
 
 int iommu_map_sg(struct device *dev, struct iommu_table *tbl,
 		 struct scatterlist *sglist, int nelems,
-		 unsigned long mask, enum dma_data_direction direction)
+		 unsigned long mask, enum dma_data_direction direction,
+		 struct dma_attrs *attrs)
 {
 	dma_addr_t dma_next = 0, dma_addr;
 	unsigned long flags;
@@ -411,7 +412,8 @@ int iommu_map_sg(struct device *dev, struct iommu_table *tbl,
 
 
 void iommu_unmap_sg(struct iommu_table *tbl, struct scatterlist *sglist,
-		int nelems, enum dma_data_direction direction)
+		int nelems, enum dma_data_direction direction,
+		struct dma_attrs *attrs)
 {
 	struct scatterlist *sg;
 	unsigned long flags;
@@ -553,7 +555,7 @@ void iommu_free_table(struct iommu_table *tbl, const char *node_name)
  */
 dma_addr_t iommu_map_single(struct device *dev, struct iommu_table *tbl,
 			    void *vaddr, size_t size, unsigned long mask,
-			    enum dma_data_direction direction)
+		enum dma_data_direction direction, struct dma_attrs *attrs)
 {
 	dma_addr_t dma_handle = DMA_ERROR_CODE;
 	unsigned long uaddr;
@@ -586,7 +588,8 @@ dma_addr_t iommu_map_single(struct device *dev, struct iommu_table *tbl,
 }
 
 void iommu_unmap_single(struct iommu_table *tbl, dma_addr_t dma_handle,
-		size_t size, enum dma_data_direction direction)
+		size_t size, enum dma_data_direction direction,
+		struct dma_attrs *attrs)
 {
 	unsigned int npages;
 
arch/powerpc/platforms/iseries/iommu.c +2 -2
index 11fa3c7..ab5d868 100644
@@ -214,13 +214,13 @@ dma_addr_t iseries_hv_map(void *vaddr, size_t size,
 			enum dma_data_direction direction)
 {
 	return iommu_map_single(NULL, &vio_iommu_table, vaddr, size,
-				DMA_32BIT_MASK, direction);
+				DMA_32BIT_MASK, direction, NULL);
 }
 
 void iseries_hv_unmap(dma_addr_t dma_handle, size_t size,
 			enum dma_data_direction direction)
 {
-	iommu_unmap_single(&vio_iommu_table, dma_handle, size, direction);
+	iommu_unmap_single(&vio_iommu_table, dma_handle, size, direction, NULL);
 }
 
 void __init iommu_vio_init(void)
arch/powerpc/platforms/ps3/system-bus.c +10 -7
index 43c493f..526cf14 100644
@@ -550,7 +550,7 @@ static void ps3_free_coherent(struct device *_dev, size_t size, void *vaddr,
  */
 
 static dma_addr_t ps3_sb_map_single(struct device *_dev, void *ptr, size_t size,
-	enum dma_data_direction direction)
+	enum dma_data_direction direction, struct dma_attrs *attrs)
 {
 	struct ps3_system_bus_device *dev = ps3_dev_to_system_bus_dev(_dev);
 	int result;
@@ -570,7 +570,8 @@ static dma_addr_t ps3_sb_map_single(struct device *_dev, void *ptr, size_t size,
 
 static dma_addr_t ps3_ioc0_map_single(struct device *_dev, void *ptr,
 				      size_t size,
-				      enum dma_data_direction direction)
+				      enum dma_data_direction direction,
+				      struct dma_attrs *attrs)
 {
 	struct ps3_system_bus_device *dev = ps3_dev_to_system_bus_dev(_dev);
 	int result;
@@ -603,7 +604,7 @@ static dma_addr_t ps3_ioc0_map_single(struct device *_dev, void *ptr,
 }
 
 static void ps3_unmap_single(struct device *_dev, dma_addr_t dma_addr,
-	size_t size, enum dma_data_direction direction)
+	size_t size, enum dma_data_direction direction, struct dma_attrs *attrs)
 {
 	struct ps3_system_bus_device *dev = ps3_dev_to_system_bus_dev(_dev);
 	int result;
@@ -617,7 +618,7 @@ static void ps3_unmap_single(struct device *_dev, dma_addr_t dma_addr,
 }
 
 static int ps3_sb_map_sg(struct device *_dev, struct scatterlist *sgl,
-	int nents, enum dma_data_direction direction)
+	int nents, enum dma_data_direction direction, struct dma_attrs *attrs)
 {
 #if defined(CONFIG_PS3_DYNAMIC_DMA)
 	BUG_ON("do");
@@ -646,14 +647,15 @@ static int ps3_sb_map_sg(struct device *_dev, struct scatterlist *sgl,
 
 static int ps3_ioc0_map_sg(struct device *_dev, struct scatterlist *sg,
 			   int nents,
-			   enum dma_data_direction direction)
+			   enum dma_data_direction direction,
+			   struct dma_attrs *attrs)
 {
 	BUG();
 	return 0;
 }
 
 static void ps3_sb_unmap_sg(struct device *_dev, struct scatterlist *sg,
-	int nents, enum dma_data_direction direction)
+	int nents, enum dma_data_direction direction, struct dma_attrs *attrs)
 {
 #if defined(CONFIG_PS3_DYNAMIC_DMA)
 	BUG_ON("do");
@@ -661,7 +663,8 @@ static void ps3_sb_unmap_sg(struct device *_dev, struct scatterlist *sg,
 }
 
 static void ps3_ioc0_unmap_sg(struct device *_dev, struct scatterlist *sg,
-			    int nents, enum dma_data_direction direction)
+			    int nents, enum dma_data_direction direction,
+			    struct dma_attrs *attrs)
 {
 	BUG();
 }
include/asm-powerpc/dma-mapping.h +86 -30

174 lines not on this page · raw message

include/asm-powerpc/iommu.h +8 -4
index 65f6682..51ecfef 100644
@@ -81,9 +81,11 @@ extern struct iommu_table *iommu_init_table(struct iommu_table * tbl,
 
 extern int iommu_map_sg(struct device *dev, struct iommu_table *tbl,
 			struct scatterlist *sglist, int nelems,
-			unsigned long mask, enum dma_data_direction direction);
+			unsigned long mask, enum dma_data_direction direction,
+			struct dma_attrs *attrs);
 extern void iommu_unmap_sg(struct iommu_table *tbl, struct scatterlist *sglist,
-			   int nelems, enum dma_data_direction direction);
+			   int nelems, enum dma_data_direction direction,
+			   struct dma_attrs *attrs);
 
 extern void *iommu_alloc_coherent(struct device *dev, struct iommu_table *tbl,
 				  size_t size, dma_addr_t *dma_handle,
@@ -92,9 +94,11 @@ extern void iommu_free_coherent(struct iommu_table *tbl, size_t size,
 				void *vaddr, dma_addr_t dma_handle);
 extern dma_addr_t iommu_map_single(struct device *dev, struct iommu_table *tbl,
 				   void *vaddr, size_t size, unsigned long mask,
-				   enum dma_data_direction direction);
+				   enum dma_data_direction direction,
+				   struct dma_attrs *attrs);
 extern void iommu_unmap_single(struct iommu_table *tbl, dma_addr_t dma_handle,
-			       size_t size, enum dma_data_direction direction);
+			       size_t size, enum dma_data_direction direction,
+			       struct dma_attrs *attrs);
 
 extern void iommu_init_early_pSeries(void);
 extern void iommu_init_early_iSeries(void);
Signature · 3 lines
1.5.4.3

-- 
#33 lore raw

Re: [patch 07/11] powerpc/dma: implement new dma_*map*_attrs() interfaces

Quoted 9 lines · On Fri, 2008-07-04 at 21:05 +0200, [email protected] wrote:

plain text document attachment (0007-powerpc-dma-implement-new-dma_-map-_attrs-interfa.patch) Update powerpc to use the new dma_*map*_attrs() interfaces. In doing so update struct dma_mapping_ops to accept a struct dma_attrs and propagate these changes through to all users of the code (generic IOMMU and the 64bit DMA code, and the iseries and ps3 platform code).

The old dma_*map_*() interfaces are reimplemented as calls to the corresponding new interfaces.

Geoff, I think the PS3 bits in this patch are ok but I'd like you to double-check and send your ack if you think they are.

Cheers,
Ben.

Quoted 504 lines
---
 arch/powerpc/Kconfig                    |    1 +
 arch/powerpc/kernel/dma_64.c            |   34 ++++++---
 arch/powerpc/kernel/ibmebus.c           |   12 ++-
 arch/powerpc/kernel/iommu.c             |   11 ++-
 arch/powerpc/platforms/iseries/iommu.c  |    4 +-
 arch/powerpc/platforms/ps3/system-bus.c |   17 +++--
 include/asm-powerpc/dma-mapping.h       |  116 +++++++++++++++++++++++--------
 include/asm-powerpc/iommu.h             |   12 ++-
 8 files changed, 144 insertions(+), 63 deletions(-)
arch/powerpc/Kconfig +1 -0
index f2a0f50..462c86a 100644
@@ -110,6 +110,7 @@ config PPC
 	select HAVE_KPROBES
 	select HAVE_KRETPROBES
 	select HAVE_LMB
+	select HAVE_DMA_ATTRS
 
 config EARLY_PRINTK
 	bool
arch/powerpc/kernel/dma_64.c +22 -12
index 7397445..3ae0c35 100644
@@ -50,32 +50,38 @@ static void dma_iommu_free_coherent(struct device *dev, size_t size,
  */
 static dma_addr_t dma_iommu_map_single(struct device *dev, void *vaddr,
 				       size_t size,
-				       enum dma_data_direction direction)
+				       enum dma_data_direction direction,
+				       struct dma_attrs *attrs)
 {
 	return iommu_map_single(dev, dev->archdata.dma_data, vaddr, size,
-			        device_to_mask(dev), direction);
+				device_to_mask(dev), direction, attrs);
 }
 
 
 static void dma_iommu_unmap_single(struct device *dev, dma_addr_t dma_handle,
 				   size_t size,
-				   enum dma_data_direction direction)
+				   enum dma_data_direction direction,
+				   struct dma_attrs *attrs)
 {
-	iommu_unmap_single(dev->archdata.dma_data, dma_handle, size, direction);
+	iommu_unmap_single(dev->archdata.dma_data, dma_handle, size, direction,
+			   attrs);
 }
 
 
 static int dma_iommu_map_sg(struct device *dev, struct scatterlist *sglist,
-			    int nelems, enum dma_data_direction direction)
+			    int nelems, enum dma_data_direction direction,
+			    struct dma_attrs *attrs)
 {
 	return iommu_map_sg(dev, dev->archdata.dma_data, sglist, nelems,
-			    device_to_mask(dev), direction);
+			    device_to_mask(dev), direction, attrs);
 }
 
 static void dma_iommu_unmap_sg(struct device *dev, struct scatterlist *sglist,
-		int nelems, enum dma_data_direction direction)
+		int nelems, enum dma_data_direction direction,
+		struct dma_attrs *attrs)
 {
-	iommu_unmap_sg(dev->archdata.dma_data, sglist, nelems, direction);
+	iommu_unmap_sg(dev->archdata.dma_data, sglist, nelems, direction,
+		       attrs);
 }
 
 /* We support DMA to/from any memory page via the iommu */
@@ -148,19 +154,22 @@ static void dma_direct_free_coherent(struct device *dev, size_t size,
 
 static dma_addr_t dma_direct_map_single(struct device *dev, void *ptr,
 					size_t size,
-					enum dma_data_direction direction)
+					enum dma_data_direction direction,
+					struct dma_attrs *attrs)
 {
 	return virt_to_abs(ptr) + get_dma_direct_offset(dev);
 }
 
 static void dma_direct_unmap_single(struct device *dev, dma_addr_t dma_addr,
 				    size_t size,
-				    enum dma_data_direction direction)
+				    enum dma_data_direction direction,
+				    struct dma_attrs *attrs)
 {
 }
 
 static int dma_direct_map_sg(struct device *dev, struct scatterlist *sgl,
-			     int nents, enum dma_data_direction direction)
+			     int nents, enum dma_data_direction direction,
+			     struct dma_attrs *attrs)
 {
 	struct scatterlist *sg;
 	int i;
@@ -174,7 +183,8 @@ static int dma_direct_map_sg(struct device *dev, struct scatterlist *sgl,
 }
 
 static void dma_direct_unmap_sg(struct device *dev, struct scatterlist *sg,
-				int nents, enum dma_data_direction direction)
+				int nents, enum dma_data_direction direction,
+				struct dma_attrs *attrs)
 {
 }
 
arch/powerpc/kernel/ibmebus.c +8 -4
index 9971159..e3b1fcd 100644
@@ -82,7 +82,8 @@ static void ibmebus_free_coherent(struct device *dev,
 static dma_addr_t ibmebus_map_single(struct device *dev,
 				     void *ptr,
 				     size_t size,
-				     enum dma_data_direction direction)
+				     enum dma_data_direction direction,
+				     struct dma_attrs *attrs)
 {
 	return (dma_addr_t)(ptr);
 }
@@ -90,14 +91,16 @@ static dma_addr_t ibmebus_map_single(struct device *dev,
 static void ibmebus_unmap_single(struct device *dev,
 				 dma_addr_t dma_addr,
 				 size_t size,
-				 enum dma_data_direction direction)
+				 enum dma_data_direction direction,
+				 struct dma_attrs *attrs)
 {
 	return;
 }
 
 static int ibmebus_map_sg(struct device *dev,
 			  struct scatterlist *sgl,
-			  int nents, enum dma_data_direction direction)
+			  int nents, enum dma_data_direction direction,
+			  struct dma_attrs *attrs)
 {
 	struct scatterlist *sg;
 	int i;
@@ -112,7 +115,8 @@ static int ibmebus_map_sg(struct device *dev,
 
 static void ibmebus_unmap_sg(struct device *dev,
 			     struct scatterlist *sg,
-			     int nents, enum dma_data_direction direction)
+			     int nents, enum dma_data_direction direction,
+			     struct dma_attrs *attrs)
 {
 	return;
 }
arch/powerpc/kernel/iommu.c +7 -4
index ccf00fe..8c68ee9 100644
@@ -269,7 +269,8 @@ static void iommu_free(struct iommu_table *tbl, dma_addr_t dma_addr,
 
 int iommu_map_sg(struct device *dev, struct iommu_table *tbl,
 		 struct scatterlist *sglist, int nelems,
-		 unsigned long mask, enum dma_data_direction direction)
+		 unsigned long mask, enum dma_data_direction direction,
+		 struct dma_attrs *attrs)
 {
 	dma_addr_t dma_next = 0, dma_addr;
 	unsigned long flags;
@@ -411,7 +412,8 @@ int iommu_map_sg(struct device *dev, struct iommu_table *tbl,
 
 
 void iommu_unmap_sg(struct iommu_table *tbl, struct scatterlist *sglist,
-		int nelems, enum dma_data_direction direction)
+		int nelems, enum dma_data_direction direction,
+		struct dma_attrs *attrs)
 {
 	struct scatterlist *sg;
 	unsigned long flags;
@@ -553,7 +555,7 @@ void iommu_free_table(struct iommu_table *tbl, const char *node_name)
  */
 dma_addr_t iommu_map_single(struct device *dev, struct iommu_table *tbl,
 			    void *vaddr, size_t size, unsigned long mask,
-			    enum dma_data_direction direction)
+		enum dma_data_direction direction, struct dma_attrs *attrs)
 {
 	dma_addr_t dma_handle = DMA_ERROR_CODE;
 	unsigned long uaddr;
@@ -586,7 +588,8 @@ dma_addr_t iommu_map_single(struct device *dev, struct iommu_table *tbl,
 }
 
 void iommu_unmap_single(struct iommu_table *tbl, dma_addr_t dma_handle,
-		size_t size, enum dma_data_direction direction)
+		size_t size, enum dma_data_direction direction,
+		struct dma_attrs *attrs)
 {
 	unsigned int npages;
 
arch/powerpc/platforms/iseries/iommu.c +2 -2
index 11fa3c7..ab5d868 100644
@@ -214,13 +214,13 @@ dma_addr_t iseries_hv_map(void *vaddr, size_t size,
 			enum dma_data_direction direction)
 {
 	return iommu_map_single(NULL, &vio_iommu_table, vaddr, size,
-				DMA_32BIT_MASK, direction);
+				DMA_32BIT_MASK, direction, NULL);
 }
 
 void iseries_hv_unmap(dma_addr_t dma_handle, size_t size,
 			enum dma_data_direction direction)
 {
-	iommu_unmap_single(&vio_iommu_table, dma_handle, size, direction);
+	iommu_unmap_single(&vio_iommu_table, dma_handle, size, direction, NULL);
 }
 
 void __init iommu_vio_init(void)
arch/powerpc/platforms/ps3/system-bus.c +10 -7
index 43c493f..526cf14 100644
@@ -550,7 +550,7 @@ static void ps3_free_coherent(struct device *_dev, size_t size, void *vaddr,
  */
 
 static dma_addr_t ps3_sb_map_single(struct device *_dev, void *ptr, size_t size,
-	enum dma_data_direction direction)
+	enum dma_data_direction direction, struct dma_attrs *attrs)
 {
 	struct ps3_system_bus_device *dev = ps3_dev_to_system_bus_dev(_dev);
 	int result;
@@ -570,7 +570,8 @@ static dma_addr_t ps3_sb_map_single(struct device *_dev, void *ptr, size_t size,
 
 static dma_addr_t ps3_ioc0_map_single(struct device *_dev, void *ptr,
 				      size_t size,
-				      enum dma_data_direction direction)
+				      enum dma_data_direction direction,
+				      struct dma_attrs *attrs)
 {
 	struct ps3_system_bus_device *dev = ps3_dev_to_system_bus_dev(_dev);
 	int result;
@@ -603,7 +604,7 @@ static dma_addr_t ps3_ioc0_map_single(struct device *_dev, void *ptr,
 }
 
 static void ps3_unmap_single(struct device *_dev, dma_addr_t dma_addr,
-	size_t size, enum dma_data_direction direction)
+	size_t size, enum dma_data_direction direction, struct dma_attrs *attrs)
 {
 	struct ps3_system_bus_device *dev = ps3_dev_to_system_bus_dev(_dev);
 	int result;
@@ -617,7 +618,7 @@ static void ps3_unmap_single(struct device *_dev, dma_addr_t dma_addr,
 }
 
 static int ps3_sb_map_sg(struct device *_dev, struct scatterlist *sgl,
-	int nents, enum dma_data_direction direction)
+	int nents, enum dma_data_direction direction, struct dma_attrs *attrs)
 {
 #if defined(CONFIG_PS3_DYNAMIC_DMA)
 	BUG_ON("do");
@@ -646,14 +647,15 @@ static int ps3_sb_map_sg(struct device *_dev, struct scatterlist *sgl,
 
 static int ps3_ioc0_map_sg(struct device *_dev, struct scatterlist *sg,
 			   int nents,
-			   enum dma_data_direction direction)
+			   enum dma_data_direction direction,
+			   struct dma_attrs *attrs)
 {
 	BUG();
 	return 0;
 }
 
 static void ps3_sb_unmap_sg(struct device *_dev, struct scatterlist *sg,
-	int nents, enum dma_data_direction direction)
+	int nents, enum dma_data_direction direction, struct dma_attrs *attrs)
 {
 #if defined(CONFIG_PS3_DYNAMIC_DMA)
 	BUG_ON("do");
@@ -661,7 +663,8 @@ static void ps3_sb_unmap_sg(struct device *_dev, struct scatterlist *sg,
 }
 
 static void ps3_ioc0_unmap_sg(struct device *_dev, struct scatterlist *sg,
-			    int nents, enum dma_data_direction direction)
+			    int nents, enum dma_data_direction direction,
+			    struct dma_attrs *attrs)
 {
 	BUG();
 }
include/asm-powerpc/dma-mapping.h +86 -30
index bbefb69..de13950 100644
@@ -13,6 +13,7 @@
 /* need struct page definitions */
 #include <linux/mm.h>
 #include <linux/scatterlist.h>
+#include <linux/dma-attrs.h>
 #include <asm/io.h>
 
 #define DMA_ERROR_CODE		(~(dma_addr_t)0x0)
@@ -53,13 +54,17 @@ struct dma_mapping_ops {
 	void		(*free_coherent)(struct device *dev, size_t size,
 				void *vaddr, dma_addr_t dma_handle);
 	dma_addr_t	(*map_single)(struct device *dev, void *ptr,
-				size_t size, enum dma_data_direction direction);
+				size_t size, enum dma_data_direction direction,
+				struct dma_attrs *attrs);
 	void		(*unmap_single)(struct device *dev, dma_addr_t dma_addr,
-				size_t size, enum dma_data_direction direction);
+				size_t size, enum dma_data_direction direction,
+				struct dma_attrs *attrs);
 	int		(*map_sg)(struct device *dev, struct scatterlist *sg,
-				int nents, enum dma_data_direction direction);
+				int nents, enum dma_data_direction direction,
+				struct dma_attrs *attrs);
 	void		(*unmap_sg)(struct device *dev, struct scatterlist *sg,
-				int nents, enum dma_data_direction direction);
+				int nents, enum dma_data_direction direction,
+				struct dma_attrs *attrs);
 	int		(*dma_supported)(struct device *dev, u64 mask);
 	int		(*set_dma_mask)(struct device *dev, u64 dma_mask);
 };
@@ -109,6 +114,77 @@ static inline int dma_set_mask(struct device *dev, u64 dma_mask)
 	return 0;
 }
 
+static inline dma_addr_t dma_map_single_attrs(struct device *dev,
+					      void *cpu_addr,
+					      size_t size,
+					      enum dma_data_direction direction,
+					      struct dma_attrs *attrs)
+{
+	struct dma_mapping_ops *dma_ops = get_dma_ops(dev);
+
+	BUG_ON(!dma_ops);
+	return dma_ops->map_single(dev, cpu_addr, size, direction, attrs);
+}
+
+static inline void dma_unmap_single_attrs(struct device *dev,
+					  dma_addr_t dma_addr,
+					  size_t size,
+					  enum dma_data_direction direction,
+					  struct dma_attrs *attrs)
+{
+	struct dma_mapping_ops *dma_ops = get_dma_ops(dev);
+
+	BUG_ON(!dma_ops);
+	dma_ops->unmap_single(dev, dma_addr, size, direction, attrs);
+}
+
+static inline dma_addr_t dma_map_page_attrs(struct device *dev,
+					    struct page *page,
+					    unsigned long offset, size_t size,
+					    enum dma_data_direction direction,
+					    struct dma_attrs *attrs)
+{
+	struct dma_mapping_ops *dma_ops = get_dma_ops(dev);
+
+	BUG_ON(!dma_ops);
+	return dma_ops->map_single(dev, page_address(page) + offset, size,
+			direction, attrs);
+}
+
+static inline void dma_unmap_page_attrs(struct device *dev,
+					dma_addr_t dma_address,
+					size_t size,
+					enum dma_data_direction direction,
+					struct dma_attrs *attrs)
+{
+	struct dma_mapping_ops *dma_ops = get_dma_ops(dev);
+
+	BUG_ON(!dma_ops);
+	dma_ops->unmap_single(dev, dma_address, size, direction, attrs);
+}
+
+static inline int dma_map_sg_attrs(struct device *dev, struct scatterlist *sg,
+				   int nents, enum dma_data_direction direction,
+				   struct dma_attrs *attrs)
+{
+	struct dma_mapping_ops *dma_ops = get_dma_ops(dev);
+
+	BUG_ON(!dma_ops);
+	return dma_ops->map_sg(dev, sg, nents, direction, attrs);
+}
+
+static inline void dma_unmap_sg_attrs(struct device *dev,
+				      struct scatterlist *sg,
+				      int nhwentries,
+				      enum dma_data_direction direction,
+				      struct dma_attrs *attrs)
+{
+	struct dma_mapping_ops *dma_ops = get_dma_ops(dev);
+
+	BUG_ON(!dma_ops);
+	dma_ops->unmap_sg(dev, sg, nhwentries, direction, attrs);
+}
+
 static inline void *dma_alloc_coherent(struct device *dev, size_t size,
 				       dma_addr_t *dma_handle, gfp_t flag)
 {
@@ -131,63 +207,43 @@ static inline dma_addr_t dma_map_single(struct device *dev, void *cpu_addr,
 					size_t size,
 					enum dma_data_direction direction)
 {
-	struct dma_mapping_ops *dma_ops = get_dma_ops(dev);
-
-	BUG_ON(!dma_ops);
-	return dma_ops->map_single(dev, cpu_addr, size, direction);
+	return dma_map_single_attrs(dev, cpu_addr, size, direction, NULL);
 }
 
 static inline void dma_unmap_single(struct device *dev, dma_addr_t dma_addr,
 				    size_t size,
 				    enum dma_data_direction direction)
 {
-	struct dma_mapping_ops *dma_ops = get_dma_ops(dev);
-
-	BUG_ON(!dma_ops);
-	dma_ops->unmap_single(dev, dma_addr, size, direction);
+	dma_unmap_single_attrs(dev, dma_addr, size, direction, NULL);
 }
 
 static inline dma_addr_t dma_map_page(struct device *dev, struct page *page,
 				      unsigned long offset, size_t size,
 				      enum dma_data_direction direction)
 {
-	struct dma_mapping_ops *dma_ops = get_dma_ops(dev);
-
-	BUG_ON(!dma_ops);
-	return dma_ops->map_single(dev, page_address(page) + offset, size,
-			direction);
+	return dma_map_page_attrs(dev, page, offset, size, direction, NULL);
 }
 
 static inline void dma_unmap_page(struct device *dev, dma_addr_t dma_address,
 				  size_t size,
 				  enum dma_data_direction direction)
 {
-	struct dma_mapping_ops *dma_ops = get_dma_ops(dev);
-
-	BUG_ON(!dma_ops);
-	dma_ops->unmap_single(dev, dma_address, size, direction);
+	dma_unmap_page_attrs(dev, dma_address, size, direction, NULL);
 }
 
 static inline int dma_map_sg(struct device *dev, struct scatterlist *sg,
 			     int nents, enum dma_data_direction direction)
 {
-	struct dma_mapping_ops *dma_ops = get_dma_ops(dev);
-
-	BUG_ON(!dma_ops);
-	return dma_ops->map_sg(dev, sg, nents, direction);
+	return dma_map_sg_attrs(dev, sg, nents, direction, NULL);
 }
 
 static inline void dma_unmap_sg(struct device *dev, struct scatterlist *sg,
 				int nhwentries,
 				enum dma_data_direction direction)
 {
-	struct dma_mapping_ops *dma_ops = get_dma_ops(dev);
-
-	BUG_ON(!dma_ops);
-	dma_ops->unmap_sg(dev, sg, nhwentries, direction);
+	dma_unmap_sg_attrs(dev, sg, nhwentries, direction, NULL);
 }
 
-
 /*
  * Available generic sets of operations
  */
include/asm-powerpc/iommu.h +8 -4
index 65f6682..51ecfef 100644
@@ -81,9 +81,11 @@ extern struct iommu_table *iommu_init_table(struct iommu_table * tbl,
 
 extern int iommu_map_sg(struct device *dev, struct iommu_table *tbl,
 			struct scatterlist *sglist, int nelems,
-			unsigned long mask, enum dma_data_direction direction);
+			unsigned long mask, enum dma_data_direction direction,
+			struct dma_attrs *attrs);
 extern void iommu_unmap_sg(struct iommu_table *tbl, struct scatterlist *sglist,
-			   int nelems, enum dma_data_direction direction);
+			   int nelems, enum dma_data_direction direction,
+			   struct dma_attrs *attrs);
 
 extern void *iommu_alloc_coherent(struct device *dev, struct iommu_table *tbl,
 				  size_t size, dma_addr_t *dma_handle,
@@ -92,9 +94,11 @@ extern void iommu_free_coherent(struct iommu_table *tbl, size_t size,
 				void *vaddr, dma_addr_t dma_handle);
 extern dma_addr_t iommu_map_single(struct device *dev, struct iommu_table *tbl,
 				   void *vaddr, size_t size, unsigned long mask,
-				   enum dma_data_direction direction);
+				   enum dma_data_direction direction,
+				   struct dma_attrs *attrs);
 extern void iommu_unmap_single(struct iommu_table *tbl, dma_addr_t dma_handle,
-			       size_t size, enum dma_data_direction direction);
+			       size_t size, enum dma_data_direction direction,
+			       struct dma_attrs *attrs);
 
 extern void iommu_init_early_pSeries(void);
 extern void iommu_init_early_iSeries(void);
Signature · 1 line
1.5.4.3
Acked-by
#34 lore raw

Re: [patch 07/11] powerpc/dma: implement new dma_*map*_attrs() interfaces

Quoted 8 lines · Benjamin Herrenschmidt
Quoted 7 lines · On Fri, 2008-07-04 at 21:05 +0200, [email protected] wrote:

plain text document attachment (0007-powerpc-dma-implement-new-dma_-map-_attrs-interfa.patch) Update powerpc to use the new dma_*map*_attrs() interfaces. In doing so update struct dma_mapping_ops to accept a struct dma_attrs and propagate these changes through to all users of the code (generic IOMMU and the 64bit DMA code, and the iseries and ps3 platform code).

Quoted 5 lines
Quoted 2 lines

The old dma_*map_*() interfaces are reimplemented as calls to the corresponding new interfaces.

Geoff, I think the PS3 bits in this patch are ok but I'd like you to double-check and send your ack if you think they are.

I tested on PS3 with ps3_defconfig, and it works OK.

Quoted 12 lines
Quoted 12 lines
---
 arch/powerpc/Kconfig                    |    1 +
 arch/powerpc/kernel/dma_64.c            |   34 ++++++---
 arch/powerpc/kernel/ibmebus.c           |   12 ++-
 arch/powerpc/kernel/iommu.c             |   11 ++-
 arch/powerpc/platforms/iseries/iommu.c  |    4 +-
 arch/powerpc/platforms/ps3/system-bus.c |   17 +++--
 include/asm-powerpc/dma-mapping.h       |  116 +++++++++++++++++++++++--------
 include/asm-powerpc/iommu.h             |   12 ++-
 8 files changed, 144 insertions(+), 63 deletions(-)
#35 lore raw

PATCH 8/11 powerpc/dma: use the struct dma_attrs in iommu code

In reply to [email protected]

Update iommu_alloc() to take the struct dma_attrs and pass them on to tce_build(). This change propagates down to the tce_build functions of all the platforms.

---
 arch/powerpc/kernel/iommu.c            |   13 ++++++++-----
 arch/powerpc/platforms/cell/iommu.c    |    5 +++--
 arch/powerpc/platforms/iseries/iommu.c |    3 ++-
 arch/powerpc/platforms/pasemi/iommu.c  |    3 ++-
 arch/powerpc/platforms/pseries/iommu.c |   14 +++++++++-----
 arch/powerpc/sysdev/dart_iommu.c       |    3 ++-
 include/asm-powerpc/machdep.h          |    3 ++-
 7 files changed, 28 insertions(+), 16 deletions(-)
arch/powerpc/kernel/iommu.c +8 -5
index 8c68ee9..2385f68 100644
@@ -186,7 +186,8 @@ static unsigned long iommu_range_alloc(struct device *dev,
 static dma_addr_t iommu_alloc(struct device *dev, struct iommu_table *tbl,
 			      void *page, unsigned int npages,
 			      enum dma_data_direction direction,
-			      unsigned long mask, unsigned int align_order)
+			      unsigned long mask, unsigned int align_order,
+			      struct dma_attrs *attrs)
 {
 	unsigned long entry, flags;
 	dma_addr_t ret = DMA_ERROR_CODE;
@@ -205,7 +206,7 @@ static dma_addr_t iommu_alloc(struct device *dev, struct iommu_table *tbl,
 
 	/* Put the TCEs in the HW table */
 	ppc_md.tce_build(tbl, entry, npages, (unsigned long)page & IOMMU_PAGE_MASK,
-			 direction);
+			 direction, attrs);
 
 
 	/* Flush/invalidate TLB caches if necessary */
@@ -336,7 +337,8 @@ int iommu_map_sg(struct device *dev, struct iommu_table *tbl,
 			    npages, entry, dma_addr);
 
 		/* Insert into HW table */
-		ppc_md.tce_build(tbl, entry, npages, vaddr & IOMMU_PAGE_MASK, direction);
+		ppc_md.tce_build(tbl, entry, npages, vaddr & IOMMU_PAGE_MASK,
+				 direction, attrs);
 
 		/* If we are in an open segment, try merging */
 		if (segstart != s) {
@@ -573,7 +575,8 @@ dma_addr_t iommu_map_single(struct device *dev, struct iommu_table *tbl,
 			align = PAGE_SHIFT - IOMMU_PAGE_SHIFT;
 
 		dma_handle = iommu_alloc(dev, tbl, vaddr, npages, direction,
-					 mask >> IOMMU_PAGE_SHIFT, align);
+					 mask >> IOMMU_PAGE_SHIFT, align,
+					 attrs);
 		if (dma_handle == DMA_ERROR_CODE) {
 			if (printk_ratelimit())  {
 				printk(KERN_INFO "iommu_alloc failed, "
@@ -642,7 +645,7 @@ void *iommu_alloc_coherent(struct device *dev, struct iommu_table *tbl,
 	nio_pages = size >> IOMMU_PAGE_SHIFT;
 	io_order = get_iommu_order(size);
 	mapping = iommu_alloc(dev, tbl, ret, nio_pages, DMA_BIDIRECTIONAL,
-			      mask >> IOMMU_PAGE_SHIFT, io_order);
+			      mask >> IOMMU_PAGE_SHIFT, io_order, NULL);
 	if (mapping == DMA_ERROR_CODE) {
 		free_pages((unsigned long)ret, order);
 		return NULL;
arch/powerpc/platforms/cell/iommu.c +3 -2
index 45646b2..b4fe598 100644
@@ -173,7 +173,8 @@ static void invalidate_tce_cache(struct cbe_iommu *iommu, unsigned long *pte,
 }
 
 static void tce_build_cell(struct iommu_table *tbl, long index, long npages,
-		unsigned long uaddr, enum dma_data_direction direction)
+		unsigned long uaddr, enum dma_data_direction direction,
+		struct dma_attrs *attrs)
 {
 	int i;
 	unsigned long *io_pte, base_pte;
@@ -519,7 +520,7 @@ cell_iommu_setup_window(struct cbe_iommu *iommu, struct device_node *np,
 
 	__set_bit(0, window->table.it_map);
 	tce_build_cell(&window->table, window->table.it_offset, 1,
-		       (unsigned long)iommu->pad_page, DMA_TO_DEVICE);
+		       (unsigned long)iommu->pad_page, DMA_TO_DEVICE, NULL);
 	window->table.it_hint = window->table.it_blocksize;
 
 	return window;
arch/powerpc/platforms/iseries/iommu.c +2 -1
index ab5d868..bc818e4 100644
@@ -42,7 +42,8 @@
 #include <asm/iseries/iommu.h>
 
 static void tce_build_iSeries(struct iommu_table *tbl, long index, long npages,
-		unsigned long uaddr, enum dma_data_direction direction)
+		unsigned long uaddr, enum dma_data_direction direction,
+		struct dma_attrs *attrs)
 {
 	u64 rc;
 	u64 tce, rpn;
arch/powerpc/platforms/pasemi/iommu.c +2 -1
index 86967bd..70541b7 100644
@@ -85,7 +85,8 @@ static int iommu_table_iobmap_inited;
 
 static void iobmap_build(struct iommu_table *tbl, long index,
 			 long npages, unsigned long uaddr,
-			 enum dma_data_direction direction)
+			 enum dma_data_direction direction,
+			 struct dma_attrs *attrs)
 {
 	u32 *ip;
 	u32 rpn;
arch/powerpc/platforms/pseries/iommu.c +9 -5
index 9a12908..5377dd4 100644
@@ -50,7 +50,8 @@
 
 static void tce_build_pSeries(struct iommu_table *tbl, long index,
 			      long npages, unsigned long uaddr,
-			      enum dma_data_direction direction)
+			      enum dma_data_direction direction,
+			      struct dma_attrs *attrs)
 {
 	u64 proto_tce;
 	u64 *tcep;
@@ -95,7 +96,8 @@ static unsigned long tce_get_pseries(struct iommu_table *tbl, long index)
 
 static void tce_build_pSeriesLP(struct iommu_table *tbl, long tcenum,
 				long npages, unsigned long uaddr,
-				enum dma_data_direction direction)
+				enum dma_data_direction direction,
+				struct dma_attrs *attrs)
 {
 	u64 rc;
 	u64 proto_tce, tce;
@@ -127,7 +129,8 @@ static DEFINE_PER_CPU(u64 *, tce_page) = NULL;
 
 static void tce_buildmulti_pSeriesLP(struct iommu_table *tbl, long tcenum,
 				     long npages, unsigned long uaddr,
-				     enum dma_data_direction direction)
+				     enum dma_data_direction direction,
+				     struct dma_attrs *attrs)
 {
 	u64 rc;
 	u64 proto_tce;
@@ -136,7 +139,8 @@ static void tce_buildmulti_pSeriesLP(struct iommu_table *tbl, long tcenum,
 	long l, limit;
 
 	if (npages == 1) {
-		tce_build_pSeriesLP(tbl, tcenum, npages, uaddr, direction);
+		tce_build_pSeriesLP(tbl, tcenum, npages, uaddr,
+				    direction, attrs);
 		return;
 	}
 
@@ -150,7 +154,7 @@ static void tce_buildmulti_pSeriesLP(struct iommu_table *tbl, long tcenum,
 		/* If allocation fails, fall back to the loop implementation */
 		if (!tcep) {
 			tce_build_pSeriesLP(tbl, tcenum, npages, uaddr,
-					    direction);
+					    direction, attrs);
 			return;
 		}
 		__get_cpu_var(tce_page) = tcep;
arch/powerpc/sysdev/dart_iommu.c +2 -1
index 005c2ec..de8c8b5 100644
@@ -149,7 +149,8 @@ static void dart_flush(struct iommu_table *tbl)
 
 static void dart_build(struct iommu_table *tbl, long index,
 		       long npages, unsigned long uaddr,
-		       enum dma_data_direction direction)
+		       enum dma_data_direction direction,
+		       struct dma_attrs *attrs)
 {
 	unsigned int *dp;
 	unsigned int rpn;
include/asm-powerpc/machdep.h +2 -1
index 9899226..1233d73 100644
@@ -80,7 +80,8 @@ struct machdep_calls {
 				     long index,
 				     long npages,
 				     unsigned long uaddr,
-				     enum dma_data_direction direction);
+				     enum dma_data_direction direction,
+				     struct dma_attrs *attrs);
 	void		(*tce_free)(struct iommu_table *tbl,
 				    long index,
 				    long npages);
Signature · 3 lines
1.5.4.3

-- 
#36 lore raw

PATCH 9/11 powerpc/cell: cell_dma_dev_setup_iommu() return the iommu table

In reply to [email protected]

Make cell_dma_dev_setup_iommu() return a pointer to the struct iommu_table (or NULL if no table can be found) rather than putting this pointer into dev->archdata.dma_data (let the caller do that), and rename this function to cell_get_iommu_table() to reflect this change.

This will allow us to get the iommu table for a device that doesn't have the table in the archdata.

---
 arch/powerpc/platforms/cell/iommu.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
arch/powerpc/platforms/cell/iommu.c +4 -4
index b4fe598..3b70784 100644
@@ -541,7 +541,7 @@ static unsigned long cell_dma_direct_offset;
 static unsigned long dma_iommu_fixed_base;
 struct dma_mapping_ops dma_iommu_fixed_ops;
 
-static void cell_dma_dev_setup_iommu(struct device *dev)
+static struct iommu_table *cell_get_iommu_table(struct device *dev)
 {
 	struct iommu_window *window;
 	struct cbe_iommu *iommu;
@@ -556,11 +556,11 @@ static void cell_dma_dev_setup_iommu(struct device *dev)
 		printk(KERN_ERR "iommu: missing iommu for %s (node %d)\n",
 		       archdata->of_node ? archdata->of_node->full_name : "?",
 		       archdata->numa_node);
-		return;
+		return NULL;
 	}
 	window = list_entry(iommu->windows.next, struct iommu_window, list);
 
-	archdata->dma_data = &window->table;
+	return &window->table;
 }
 
 static void cell_dma_dev_setup_fixed(struct device *dev);
@@ -573,7 +573,7 @@ static void cell_dma_dev_setup(struct device *dev)
 	if (get_dma_ops(dev) == &dma_iommu_fixed_ops)
 		cell_dma_dev_setup_fixed(dev);
 	else if (get_pci_dma_ops() == &dma_iommu_ops)
-		cell_dma_dev_setup_iommu(dev);
+		archdata->dma_data = cell_get_iommu_table(dev);
 	else if (get_pci_dma_ops() == &dma_direct_ops)
 		archdata->dma_data = (void *)cell_dma_direct_offset;
 	else
Signature · 3 lines
1.5.4.3

-- 
#37 lore raw

PATCH 10/11 powerpc: move device_to_mask() to dma-mapping.h

In reply to [email protected]

Move device_to_mask() to dma-mapping.h because we need to use it from outside dma_64.c in a later patch.

---
 arch/powerpc/kernel/dma_64.c      |    9 ---------
 include/asm-powerpc/dma-mapping.h |    9 +++++++++
 2 files changed, 9 insertions(+), 9 deletions(-)
arch/powerpc/kernel/dma_64.c +0 -9
index 3ae0c35..ae5708e 100644
@@ -15,15 +15,6 @@
  * Generic iommu implementation
  */
 
-static inline unsigned long device_to_mask(struct device *dev)
-{
-	if (dev->dma_mask && *dev->dma_mask)
-		return *dev->dma_mask;
-	/* Assume devices without mask can take 32 bit addresses */
-	return 0xfffffffful;
-}
-
-
 /* Allocates a contiguous real buffer and creates mappings over it.
  * Returns the virtual address of the buffer and sets dma_handle
  * to the dma address (mapping) of the first page.
include/asm-powerpc/dma-mapping.h +9 -0
index de13950..74c5497 100644
@@ -45,6 +45,15 @@ extern void __dma_sync_page(struct page *page, unsigned long offset,
 #endif /* ! CONFIG_NOT_COHERENT_CACHE */
 
 #ifdef CONFIG_PPC64
+
+static inline unsigned long device_to_mask(struct device *dev)
+{
+	if (dev->dma_mask && *dev->dma_mask)
+		return *dev->dma_mask;
+	/* Assume devices without mask can take 32 bit addresses */
+	return 0xfffffffful;
+}
+
 /*
  * DMA operations are abstracted for G5 vs. i/pSeries, PCI vs. VIO
  */
Signature · 3 lines
1.5.4.3

-- 
#38 lore raw

PATCH 11/11 powerpc/cell: Add DMA_ATTR_STRONG_ORDERING dma attribute and use in IOMMU code

In reply to [email protected]

Introduce a new dma attriblue DMA_ATTR_STRONG_ORDERING to use strong ordering on DMA mappings in the Cell processor. Add the code to the Cell's IOMMU implementation to use this.

The current Cell IOMMU implementation sets the IOPTE_SO_RW bits in all IOTPEs (for both the dynamic and fixed mappings) which enforces strong ordering of both reads and writes. This patch makes the default behaviour weak ordering (the IOPTE_SO_RW bits not set) and to request a strongly ordered mapping the new DMA_ATTR_STRONG_ORDERING needs to be used.

Dynamic mappings can be weakly or strongly ordered on an individual basis but the fixed mapping is always weakly ordered.

---
 Documentation/DMA-attributes.txt    |   12 +++++
 arch/powerpc/platforms/cell/iommu.c |   93 ++++++++++++++++++++++++++++++++---
 include/linux/dma-attrs.h           |    1 +
 3 files changed, 99 insertions(+), 7 deletions(-)
Documentation/DMA-attributes.txt +12 -0
index 6d772f8..f2d2800 100644
@@ -22,3 +22,15 @@ ready and available in memory.  The DMA of the "completion indication"
 could race with data DMA.  Mapping the memory used for completion
 indications with DMA_ATTR_WRITE_BARRIER would prevent the race.
 
+
+DMA_ATTR_STRONG_ORDERING
+----------------------
+
+DMA_ATTR_STRONG_ORDERING specifies that previous reads and writes are
+performed in the order in which they're received by the IOMMU; thus
+reads and writes may not pass each other.
+
+Platforms that are strongly ordered by default will ignore this new
+attribute but platforms that are weakly ordered by default should not
+ignore this new attribute. Instead, they should return an error if a
+strongly ordered mapping cannot be used when one is requested.
arch/powerpc/platforms/cell/iommu.c +86 -7

128 lines not on this page · raw message

include/linux/dma-attrs.h +1 -0
index 1677e2b..600fea7 100644
@@ -12,6 +12,7 @@
  */
 enum dma_attr {
 	DMA_ATTR_WRITE_BARRIER,
+	DMA_ATTR_STRONG_ORDERING,
 	DMA_ATTR_MAX,
 };
 
Signature · 3 lines
1.5.4.3

-- 
#39 lore raw

Re: [Cbe-oss-dev] [patch 11/11] powerpc/cell: Add DMA_ATTR_STRONG_ORDERING dma attribute and use in IOMMU code

Quoted 9 lines · On Fri, 2008-07-04 at 21:05 +0200, [email protected] wrote:

Introduce a new dma attriblue DMA_ATTR_STRONG_ORDERING to use strong ordering on DMA mappings in the Cell processor. Add the code to the Cell's IOMMU implementation to use this.

The current Cell IOMMU implementation sets the IOPTE_SO_RW bits in all IOTPEs (for both the dynamic and fixed mappings) which enforces strong ordering of both reads and writes. This patch makes the default behaviour weak ordering (the IOPTE_SO_RW bits not set) and to request a strongly ordered mapping the new DMA_ATTR_STRONG_ORDERING needs to be used.

We're sure that's safe?

cheers

Signature · 8 lines
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
#40 lore raw

Re: [Cbe-oss-dev] [patch 11/11] powerpc/cell: Add DMA_ATTR_STRONG_ORDERING dma attribute and use in IOMMU code

Quoted 7 lines · Michael Ellerman
Quoted 5 lines

The current Cell IOMMU implementation sets the IOPTE_SO_RW bits in all IOTPEs (for both the dynamic and fixed mappings) which enforces strong ordering of both reads and writes. This patch makes the default behaviour weak ordering (the IOPTE_SO_RW bits not set) and to request a strongly ordered mapping the new DMA_ATTR_STRONG_ORDERING needs to be used.

We're sure that's safe?

I'd say it's not...

Ben.

#41 lore raw

Re: [Cbe-oss-dev] [patch 11/11] powerpc/cell: Add DMA_ATTR_STRONG_ORDERING dma attribute and use in IOMMU code

Quoted 10 lines · Benjamin Herrenschmidt
Quoted 7 lines · Michael Ellerman
Quoted 5 lines

The current Cell IOMMU implementation sets the IOPTE_SO_RW bits in all IOTPEs (for both the dynamic and fixed mappings) which enforces strong ordering of both reads and writes. This patch makes the default behaviour weak ordering (the IOPTE_SO_RW bits not set) and to request a strongly ordered mapping the new DMA_ATTR_STRONG_ORDERING needs to be used.

We're sure that's safe?

I'd say it's not...

It turned out that the firmware sets up the south bridge to never set the 'S' bit on incoming transactions, which overrides the IOPTE_SO_RW bits, on all existing cell hardware.

This weak ordering gives the same ordering guarantees as the default ordering for DMA on other PowerPC machines. Setting strong ordering on both the host bridge *and* the page table will give further ordering guarantees, i.e. it will make sure that no DMA requests on the bus can ever overtake each other.

	Arnd <><
#42 lore raw

Re: [Cbe-oss-dev] [patch 11/11] powerpc/cell: Add DMA_ATTR_STRONG_ORDERING dma attribute and use in IOMMU code

Quoted 10 lines · Arnd Bergmann

It turned out that the firmware sets up the south bridge to never set the 'S' bit on incoming transactions, which overrides the IOPTE_SO_RW bits, on all existing cell hardware.

This weak ordering gives the same ordering guarantees as the default ordering for DMA on other PowerPC machines. Setting strong ordering on both the host bridge *and* the page table will give further ordering guarantees, i.e. it will make sure that no DMA requests on the bus can ever overtake each other

I need to look closely at what the various bridge settings are. Drivers do expect DMA requests from one device to stay in order, at least up to what's defined in the PCI spec, which is pretty much fully ordered unless those devices set the PCIe (or X) relaxed ordering attribute. However, AFAIK, Axon doesn't convey that sort of ordering attributes from incoming transactions between the PCIe segment and the PLB5.

Ben.

#43 lore raw

Re: [Cbe-oss-dev] [patch 11/11] powerpc/cell: Add DMA_ATTR_STRONG_ORDERING dma attribute and use in IOMMU code

Quoted 6 lines · Benjamin Herrenschmidt

I need to look closely at what the various bridge settings are. Drivers do expect DMA requests from one device to stay in order, at least up to what's defined in the PCI spec, which is pretty much fully ordered unless those devices set the PCIe (or X) relaxed ordering attribute. However, AFAIK, Axon doesn't convey that sort of ordering attributes from incoming transactions between the PCIe segment and the PLB5.

Yes, it would be very helpful if you can look into this a bit more. The Axon specification is particularly confusing in this regard and even though everyone I have asked so far told us that it's totally fine, an extra person with more insight in the complete picture looking into this would be good.

	Arnd <><
#44 lore raw

Re: [Cbe-oss-dev] [patch 11/11] powerpc/cell: Add DMA_ATTR_STRONG_ORDERING dma attribute and use in IOMMU code

In reply to Arnd Bergmann
Quoted 8 lines · Arnd Bergmann
Quoted 7 lines · Benjamin Herrenschmidt
Quoted 6 lines · Michael Ellerman
Quoted 5 lines

The current Cell IOMMU implementation sets the IOPTE_SO_RW bits in all IOTPEs (for both the dynamic and fixed mappings) which enforces strong ordering of both reads and writes. This patch makes the default behaviour weak ordering (the IOPTE_SO_RW bits not set) and to request a strongly ordered mapping the new DMA_ATTR_STRONG_ORDERING needs to be used.

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

We're sure that's safe?

I'd say it's not...

It turned out that the firmware sets up the south bridge to never set the 'S' bit on incoming transactions, which overrides the IOPTE_SO_RW bits, on all existing cell hardware.

It seems strange to me that the southbridge is allowed to override the setting in the IOMMU page table, but if that's what the doc says ..

cheers

Signature · 8 lines
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
#45 lore raw

Re: [Cbe-oss-dev] [patch 11/11] powerpc/cell: Add DMA_ATTR_STRONG_ORDERING dma attribute and use in IOMMU code

Quoted 7 lines · Michael Ellerman
Quoted 4 lines

It turned out that the firmware sets up the south bridge to never set the 'S' bit on incoming transactions, which overrides the IOPTE_SO_RW bits, on all existing cell hardware.

It seems strange to me that the southbridge is allowed to override the setting in the IOMMU page table, but if that's what the doc says ..

That's what I thought at first as well, but it actually makes sense:
If the bridge knows that a data packet has been reordered already by the originator or one of its own busses, there is no point in enforcing strong ordering at the IOMMU again.

	Arnd <><