[PATCHv3 2/3] powerpc: Switch VIO Bus PM to use generic helpers

2010-05-14 Thread Brian King

Switch to use the generic power management helpers.

Signed-off-by: Brian King 
---

 arch/powerpc/kernel/vio.c |   25 +
 1 file changed, 1 insertion(+), 24 deletions(-)

diff -puN arch/powerpc/kernel/vio.c~powerpc_vio_bus_pm2 
arch/powerpc/kernel/vio.c
--- powerpc.git/arch/powerpc/kernel/vio.c~powerpc_vio_bus_pm2   2010-05-11 
09:49:58.0 -0500
+++ powerpc.git-bjking1/arch/powerpc/kernel/vio.c   2010-05-11 
09:50:44.0 -0500
@@ -1381,29 +1381,6 @@ static int vio_hotplug(struct device *de
return 0;
 }
 
-static int vio_pm_suspend(struct device *dev)
-{
-   const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL;
-
-   if (pm && pm->suspend)
-   return pm->suspend(dev);
-   return 0;
-}
-
-static int vio_pm_resume(struct device *dev)
-{
-   const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL;
-
-   if (pm && pm->resume)
-   return pm->resume(dev);
-   return 0;
-}
-
-const struct dev_pm_ops vio_dev_pm_ops = {
-   .suspend = vio_pm_suspend,
-   .resume = vio_pm_resume,
-};
-
 static struct bus_type vio_bus_type = {
.name = "vio",
.dev_attrs = vio_dev_attrs,
@@ -1411,7 +1388,7 @@ static struct bus_type vio_bus_type = {
.match = vio_bus_match,
.probe = vio_bus_probe,
.remove = vio_bus_remove,
-   .pm = &vio_dev_pm_ops,
+   .pm = GENERIC_SUBSYS_PM_OPS,
 };
 
 /**
_
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Re: [PATCH]460EX on-chip SATA driver < resubmission >

2010-05-14 Thread Jeff Garzik

On 05/05/2010 01:57 PM, Rupjyoti Sarmah wrote:

+static  void clear_interrupt_bit(struct sata_dwc_device *hsdev, u32 bit)
+{
+   out_le32(&hsdev->sata_dwc_regs->intpr,
+in_le32(&hsdev->sata_dwc_regs->intpr));
+}
+
+static  u32 qcmd_tag_to_mask(u8 tag)
+{
+   return 0x0001<<  (tag&  0x1f);
+}
+
+/* See ahci.c */
+static void sata_dwc_error_intr(struct ata_port *ap,
+   struct sata_dwc_device *hsdev, uint intpr)
+{
+   struct sata_dwc_device_port *hsdevp = HSDEVP_FROM_AP(ap);
+   struct ata_eh_info *ehi =&ap->link.eh_info;
+   unsigned int err_mask = 0, action = 0;
+   struct ata_queued_cmd *qc;
+   u32 serror;
+   u8 status, tag;
+   u32 err_reg;
+
+   ata_ehi_clear_desc(ehi);
+
+   serror = core_scr_read(SCR_ERROR);
+   status = ap->ops->sff_check_status(ap);
+
+   err_reg = in_le32(&(host_pvt.sata_dma_regs->interrupt_status.error.\
+   low));
+   tag = ap->link.active_tag;
+
+   dev_err(ap->dev, "%s SCR_ERROR=0x%08x intpr=0x%08x status=0x%08x "
+   "dma_intp=%d pending=%d issued=%d dma_err_status=0x%08x\n",
+   __func__, serror, intpr, status, host_pvt.dma_interrupt_count,
+   hsdevp->dma_pending[tag], hsdevp->cmd_issued[tag], err_reg);
+
+   /* Clear error register and interrupt bit */
+   clear_serror();
+   clear_interrupt_bit(hsdev, SATA_DWC_INTPR_ERR);
+
+   /* This is the only error happening now.  TODO check for exact error */
+   err_mask |= AC_ERR_HOST_BUS;
+   action |= ATA_EH_RESET;


this is a rather poor error mapping.



+/**
+ * Function : sata_dwc_isr
+ * arguments : irq, void *dev_instance, struct pt_regs *regs
+ * Return value : irqreturn_t - status of IRQ
+ * This Interrupt handler called via port ops registered function.
+ * .irq_handler = sata_dwc_isr
+ */
+static irqreturn_t sata_dwc_isr(int irq, void *dev_instance)
+{
+   struct ata_host *host = (struct ata_host *)dev_instance;
+   struct sata_dwc_device *hsdev = HSDEV_FROM_HOST(host);
+   struct ata_port *ap;
+   struct ata_queued_cmd *qc;
+   unsigned long flags;
+   u8 status, tag;
+   int handled, num_processed, port = 0;
+   uint intpr, sactive, sactive2, tag_mask;
+   struct sata_dwc_device_port *hsdevp;
+   host_pvt.sata_dwc_sactive_issued = 0;
+
+   spin_lock_irqsave(&host->lock, flags);
+
+   /* Read the interrupt register */
+   intpr = in_le32(&hsdev->sata_dwc_regs->intpr);
+
+   ap = host->ports[port];
+   hsdevp = HSDEVP_FROM_AP(ap);
+
+   dev_dbg(ap->dev, "%s intpr=0x%08x active_tag=%d\n", __func__, intpr,
+   ap->link.active_tag);
+
+   /* Check for error interrupt */
+   if (intpr&  SATA_DWC_INTPR_ERR) {
+   sata_dwc_error_intr(ap, hsdev, intpr);
+   handled = 1;
+   goto DONE;
+   }
+
+   /* Check for DMA SETUP FIS (FP DMA) interrupt */
+   if (intpr&  SATA_DWC_INTPR_NEWFP) {
+   clear_interrupt_bit(hsdev, SATA_DWC_INTPR_NEWFP);
+
+   tag = (u8)(in_le32(&hsdev->sata_dwc_regs->fptagr));
+   dev_dbg(ap->dev, "%s: NEWFP tag=%d\n", __func__, tag);
+   if (hsdevp->cmd_issued[tag] != SATA_DWC_CMD_ISSUED_PEND)
+   dev_warn(ap->dev, "CMD tag=%d not pending?\n", tag);
+
+   host_pvt.sata_dwc_sactive_issued |= qcmd_tag_to_mask(tag);
+
+   qc = ata_qc_from_tag(ap, tag);
+   /* Start FP DMA for NCQ command.  At this point the tag is the
+* active tag.  It is the tag that matches the command about to
+* be completed.
+*/
+   qc->ap->link.active_tag = tag;
+   sata_dwc_bmdma_start_by_tag(qc, tag);
+
+   handled = 1;
+   goto DONE;
+   }
+
+   sactive = core_scr_read(SCR_ACTIVE);
+   tag_mask = (host_pvt.sata_dwc_sactive_issued | sactive) ^ sactive;
+
+   /* If no sactive issued and tag_mask is zero then this is not NCQ */
+   if (host_pvt.sata_dwc_sactive_issued == 0&&  tag_mask == 0) {
+   if (ap->link.active_tag == ATA_TAG_POISON)
+   tag = 0;
+   else
+   tag = ap->link.active_tag;
+   qc = ata_qc_from_tag(ap, tag);
+
+   /* DEV interrupt w/ no active qc? */
+   if (unlikely(!qc || (qc->tf.flags&  ATA_TFLAG_POLLING))) {
+   dev_err(ap->dev, "%s interrupt with no active qc "
+   "qc=%p\n", __func__, qc);
+   ap->ops->sff_check_status(ap);
+   handled = 1;
+   goto DONE;
+   }
+
+   status = ap->ops->sff_check_status(ap);

mpc870 support in the powerpc arch?

2010-05-14 Thread Shawn Jin
Hi,

Is mpc870 fully supported in the powerpc arch? I know it's an old
processor but 8xx is still one of platforms in the powerpc arch. If
it's not supported, how much effort will it be to resurrect mpc870 in
the new arch considering we have substantial 8xx support?

Thanks,
-Shawn.
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


[PATCH 10/10] arch/powerpc/platforms/iseries: Use kstrdup

2010-05-14 Thread Julia Lawall
From: Julia Lawall 

Use kstrdup when the goal of an allocation is copy a string into the
allocated region.

The semantic patch that makes this change is as follows:
(http://coccinelle.lip6.fr/)

// 
@@
expression from,to;
expression flag,E1,E2;
statement S;
@@

-  to = kmalloc(strlen(from) + 1,flag);
+  to = kstrdup(from, flag);
   ... when != \(from = E1 \| to = E1 \)
   if (to==NULL || ...) S
   ... when != \(from = E2 \| to = E2 \)
-  strcpy(to, from);
// 

Signed-off-by: Julia Lawall 

---
 arch/powerpc/platforms/iseries/vio.c |3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff -u -p a/arch/powerpc/platforms/iseries/vio.c 
b/arch/powerpc/platforms/iseries/vio.c
--- a/arch/powerpc/platforms/iseries/vio.c
+++ b/arch/powerpc/platforms/iseries/vio.c
@@ -87,12 +87,11 @@ static struct device_node *new_node(cons
 
if (!np)
return NULL;
-   np->full_name = kmalloc(strlen(path) + 1, GFP_KERNEL);
+   np->full_name = kstrdup(path, GFP_KERNEL);
if (!np->full_name) {
kfree(np);
return NULL;
}
-   strcpy(np->full_name, path);
of_node_set_flag(np, OF_DYNAMIC);
kref_init(&np->kref);
np->parent = of_node_get(parent);
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


[PATCH 6/10] arch/powerpc/platforms/pseries: Use kstrdup

2010-05-14 Thread Julia Lawall
From: Julia Lawall 

Use kstrdup when the goal of an allocation is copy a string into the
allocated region.

The semantic patch that makes this change is as follows:
(http://coccinelle.lip6.fr/)

// 
@@
expression from,to;
expression flag,E1,E2;
statement S;
@@

-  to = kmalloc(strlen(from) + 1,flag);
+  to = kstrdup(from, flag);
   ... when != \(from = E1 \| to = E1 \)
   if (to==NULL || ...) S
   ... when != \(from = E2 \| to = E2 \)
-  strcpy(to, from);
// 

Signed-off-by: Julia Lawall 

---
 arch/powerpc/platforms/pseries/reconfig.c |4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff -u -p a/arch/powerpc/platforms/pseries/reconfig.c 
b/arch/powerpc/platforms/pseries/reconfig.c
--- a/arch/powerpc/platforms/pseries/reconfig.c
+++ b/arch/powerpc/platforms/pseries/reconfig.c
@@ -118,12 +118,10 @@ static int pSeries_reconfig_add_node(con
if (!np)
goto out_err;
 
-   np->full_name = kmalloc(strlen(path) + 1, GFP_KERNEL);
+   np->full_name = kstrdup(path, GFP_KERNEL);
if (!np->full_name)
goto out_err;
 
-   strcpy(np->full_name, path);
-
np->properties = proplist;
of_node_set_flag(np, OF_DYNAMIC);
kref_init(&np->kref);
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Re: [PATCH] powerpc: fix ioremap_flags() with book3e pte definition

2010-05-14 Thread Kumar Gala

On Feb 7, 2010, at 10:21 PM, Benjamin Herrenschmidt wrote:

> On Fri, 2010-02-05 at 00:53 +0800, Li Yang wrote:
>> We can't just clear the user read permission in book3e pte, because
>> that will also clear supervisor read permission.  This surely isn't
>> desired.  Fix the problem by adding the supervisor read back.
>> 
>> Signed-off-by: Li Yang 
>> ---
>> arch/powerpc/mm/pgtable_32.c |5 +
>> 1 files changed, 5 insertions(+), 0 deletions(-)
>> 
>> diff --git a/arch/powerpc/mm/pgtable_32.c b/arch/powerpc/mm/pgtable_32.c
>> index cb96cb2..aff7c04 100644
>> --- a/arch/powerpc/mm/pgtable_32.c
>> +++ b/arch/powerpc/mm/pgtable_32.c
>> @@ -144,6 +144,11 @@ ioremap_flags(phys_addr_t addr, unsigned long size, 
>> unsigned long flags)
>>  /* we don't want to let _PAGE_USER and _PAGE_EXEC leak out */
>>  flags &= ~(_PAGE_USER | _PAGE_EXEC);
>> 
>> +#if defined(CONFIG_FSL_BOOKE) && defined(CONFIG_PTE_64BIT)
>> +/* supervisor read permission has just been cleared, add back */
>> +flags |= _PAGE_BAP_SR;
>> +#endif
>> +
> 
> So this is a bit fishy indeed. pgtable_64.c seems to have the same
> problem in fact.
> 
> It boils down to the "hack" I have in the new PTE format which consists
> of having _SR be part of _PAGE_USER. I wonder if I should change that
> instead. Kumar, what do you reckon ?
> 
> _Maybe_ an option is to have _PAGE_NO_USER that defaults to be
> ~_PAGE_USER in pte-common.h and can be set in pte-book3e.h to
> only strip out UR and UW ?

We never closed on this.  I think lets add _PAGE_NO_USER

- k
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Re: [PATCH v3 3/3] ptp: Added a clock that uses the eTSEC found on the MPC85xx.

2010-05-14 Thread Scott Wood

On 05/14/2010 11:46 AM, Richard Cochran wrote:

diff --git a/Documentation/powerpc/dts-bindings/fsl/tsec.txt 
b/Documentation/powerpc/dts-bindings/fsl/tsec.txt
index edb7ae1..b09ba66 100644
--- a/Documentation/powerpc/dts-bindings/fsl/tsec.txt
+++ b/Documentation/powerpc/dts-bindings/fsl/tsec.txt
@@ -74,3 +74,59 @@ Example:
interrupt-parent =<&mpic>;
phy-handle =<&phy0>
};
+
+* Gianfar PTP clock nodes
+
+General Properties:
+
+  - device_type  Should be "ptp_clock"


Device_type is deprecated in most contexts for flat device trees.


+  - modelModel of the device.  Must be "eTSEC"


Model, while abused by the current gianfar binding code, is not supposed 
to be something that is ordinarily used to bind on.  It is supposed to 
be a freeform field for indicating the specific model of hardware, 
mainly for human consumption or as a last resort for working around 
problems.


Get rid of both device_type and model, and specify a compatible string 
instead (e.g. "fsl,etsec-ptp").  Or perhaps this should just be some 
additional properties on the existing gianfar nodes, rather than 
presenting it as a separate device?  How do you associate a given ptp 
block with the corresponding gianfar node?  If there are differences in 
ptp implementation between different versions of etsec, can the ptp 
driver see the etsec version register?



+  - reg  Offset and length of the register set for the device
+  - interrupts   There should be at least two and as many as four
+ PTP related interrupts
+
+Clock Properties:
+
+  - tclk_period  Timer reference clock period in nanoseconds.
+  - tmr_prsc Prescaler, divides the output clock.
+  - tmr_add  Frequency compensation value.
+  - cksel0= external clock, 1= eTSEC system clock, 3= RTC clock input.
+ Currently the driver only supports choice "1".
+  - tmr_fiper1   Fixed interval period pulse generator.
+  - tmr_fiper2   Fixed interval period pulse generator.


Dashes are more typical in OF names than underscores, and it's generally 
better to be a little more verbose -- these aren't local loop iterators.


They should probably have an "fsl,ptp-" prefix as well.


+  These properties set the operational parameters for the PTP
+  clock. You must choose these carefully for the clock to work right.


Do these values describe the way the hardware is, or how it's been 
configured by firmware, or a set of values that are clearly optimal for 
this particular board?  If it's just configuration for the Linux driver, 
that could reasonably differ based on what a given user or OS will want, 
the device tree probably isn't the right place for it.



diff --git a/arch/powerpc/boot/dts/p2020ds.dts 
b/arch/powerpc/boot/dts/p2020ds.dts
index 1101914..f72353a 100644
--- a/arch/powerpc/boot/dts/p2020ds.dts
+++ b/arch/powerpc/boot/dts/p2020ds.dts
@@ -336,6 +336,20 @@
phy_type = "ulpi";
};

+   ptp_cl...@24e00 {
+   device_type = "ptp_clock";
+   model = "eTSEC";
+   reg = <0x24E00 0xB0>;
+   interrupts = <68 2 69 2 70 2>;
+   interrupt-parent = < &mpic >;
+   tclk_period = <5>;
+   tmr_prsc = <200>;
+   tmr_add = <0xCCCD>;
+   cksel = <1>;
+   tmr_fiper1 = <0x3B9AC9FB>;
+   tmr_fiper2 = <0x0001869B>;
+   };
+


This one has 3 interrupts?  The driver supports only two.


+/* Private globals */
+static struct ptp_clock *gianfar_clock;


Do you not support more than one of these?


+static struct etsects the_clock;


"The" clock?  As oppsed to the "other" clock one line above? :-)


+static irqreturn_t isr(int irq, void *priv)
+{
+   struct etsects *etsects = priv;
+   struct ptp_clock_event event;
+   u64 ns;
+   u32 ack=0, lo, hi, mask, val;
+
+   val = gfar_read(&etsects->regs->tmr_tevent);
+
+   if (val&  ETS1) {
+   ack |= ETS1;
+   hi = gfar_read(&etsects->regs->tmr_etts1_h);
+   lo = gfar_read(&etsects->regs->tmr_etts1_l);
+   event.type = PTP_CLOCK_EXTTS;
+   event.index = 0;
+   event.timestamp = ((u64) hi)<<  32;
+   event.timestamp |= lo;
+   ptp_clock_event(gianfar_clock,&event);
+   }
+
+   if (val&  ETS2) {
+   ack |= ETS2;
+   hi = gfar_read(&etsects->regs->tmr_etts2_h);
+   lo = gfar_read(&etsects->regs->tmr_etts2_l);
+   event.type = PTP_CLOCK_EXTTS;
+   event.index = 1;
+   event.timestamp = ((u64) hi)<<  32;
+   event.timestamp |= lo;
+   ptp_clock_event(gianfar_clock,&event);
+   }
+
+   if (val&  ALM2) {
+   ack |= ALM2;
+   if (etsects->alarm_

Re: [PATCH]460EX on-chip SATA driver < resubmission >

2010-05-14 Thread Sergei Shtylyov

Hello.

Rupjyoti Sarmah wrote:


This patch enables the on-chip DWC SATA controller of the AppliedMicro 
processor 460EX.

Signed-off-by: Rupjyoti Sarmah  
Signed-off-by: Mark Miesfeld 

Signed-off-by: Prodyut Hazarika 
---
 arch/powerpc/boot/dts/canyonlands.dts |8 +
 drivers/ata/Kconfig   |9 +
 drivers/ata/Makefile  |1 +
 drivers/ata/sata_dwc.c| 1827 +
 4 files changed, 1845 insertions(+), 0 deletions(-)
 create mode 100644 drivers/ata/sata_dwc.c

diff --git a/arch/powerpc/boot/dts/canyonlands.dts 
b/arch/powerpc/boot/dts/canyonlands.dts
index cd56bb5..d3b2c99 100644
--- a/arch/powerpc/boot/dts/canyonlands.dts
+++ b/arch/powerpc/boot/dts/canyonlands.dts
@@ -163,6 +163,14 @@
interrupts = <0x1e 4>;
};
 
+		SATA0: s...@bffd1000 {

+compatible = "amcc,sata-460ex";
+   reg = <4 0xbffd1000 0x800 4 0xbffd0800 0x400>;
+interrupt-parent = <&UIC3>;
+interrupts = <0x0 0x4   /* SATA */
+  0x5 0x4>; /* AHBDMA */
+};
+
POB0: opb {
compatible = "ibm,opb-460ex", "ibm,opb";
#address-cells = <1>;
  


  Please put the device tree update in a separate patch to go thru the 
PowerPC tree.


MBR, Sergei

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


[PATCH v3 3/3] ptp: Added a clock that uses the eTSEC found on the MPC85xx.

2010-05-14 Thread Richard Cochran
The eTSEC includes a PTP clock with quite a few features. This patch adds
support for the basic clock adjustment functions, plus two external time
stamps and one alarm.

Signed-off-by: Richard Cochran 
---
 Documentation/powerpc/dts-bindings/fsl/tsec.txt |   56 +++
 arch/powerpc/boot/dts/mpc8313erdb.dts   |   14 +
 arch/powerpc/boot/dts/p2020ds.dts   |   14 +
 arch/powerpc/boot/dts/p2020rdb.dts  |   14 +
 drivers/net/Makefile|1 +
 drivers/net/gianfar_ptp.c   |  521 +++
 drivers/net/gianfar_ptp_reg.h   |  113 +
 drivers/ptp/Kconfig |   13 +
 8 files changed, 746 insertions(+), 0 deletions(-)
 create mode 100644 drivers/net/gianfar_ptp.c
 create mode 100644 drivers/net/gianfar_ptp_reg.h

diff --git a/Documentation/powerpc/dts-bindings/fsl/tsec.txt 
b/Documentation/powerpc/dts-bindings/fsl/tsec.txt
index edb7ae1..b09ba66 100644
--- a/Documentation/powerpc/dts-bindings/fsl/tsec.txt
+++ b/Documentation/powerpc/dts-bindings/fsl/tsec.txt
@@ -74,3 +74,59 @@ Example:
interrupt-parent = <&mpic>;
phy-handle = <&phy0>
};
+
+* Gianfar PTP clock nodes
+
+General Properties:
+
+  - device_type  Should be "ptp_clock"
+  - modelModel of the device.  Must be "eTSEC"
+  - reg  Offset and length of the register set for the device
+  - interrupts   There should be at least two and as many as four
+ PTP related interrupts
+
+Clock Properties:
+
+  - tclk_period  Timer reference clock period in nanoseconds.
+  - tmr_prsc Prescaler, divides the output clock.
+  - tmr_add  Frequency compensation value.
+  - cksel0= external clock, 1= eTSEC system clock, 3= RTC clock input.
+ Currently the driver only supports choice "1".
+  - tmr_fiper1   Fixed interval period pulse generator.
+  - tmr_fiper2   Fixed interval period pulse generator.
+
+  These properties set the operational parameters for the PTP
+  clock. You must choose these carefully for the clock to work right.
+  Here is how to figure good values:
+
+  TimerOsc = system clock   MHz
+  tclk_period  = desired clock period   nanoseconds
+  NominalFreq  = 1000 / tclk_period MHz
+  FreqDivRatio = TimerOsc / NominalFreq (must be greater that 1.0)
+  tmr_add  = ceil(2^32 / FreqDivRatio)
+  OutputClock  = NominalFreq / tmr_prsc MHz
+  PulseWidth   = 1 / OutputClockmicroseconds
+  FiperFreq1   = desired frequency in Hz
+  FiperDiv1= 100 * OutputClock / FiperFreq1
+  tmr_fiper1   = tmr_prsc * tclk_period * FiperDiv1 - tclk_period
+
+  The calculation for tmr_fiper2 is the same as for tmr_fiper1. The
+  driver expects that tmr_fiper1 will be correctly set to produce a 1
+  Pulse Per Second (PPS) signal, since this will be offered to the PPS
+  subsystem to synchronize the Linux clock.
+
+Example:
+
+   ptp_cl...@24e00 {
+   device_type = "ptp_clock";
+   model = "eTSEC";
+   reg = <0x24E00 0xB0>;
+   interrupts = <12 0x8 13 0x8>;
+   interrupt-parent = < &ipic >;
+   tclk_period = <10>;
+   tmr_prsc= <100>;
+   tmr_add = <0x99A4>;
+   cksel   = <0x1>;
+   tmr_fiper1  = <0x3B9AC9F6>;
+   tmr_fiper2  = <0x00018696>;
+   };
diff --git a/arch/powerpc/boot/dts/mpc8313erdb.dts 
b/arch/powerpc/boot/dts/mpc8313erdb.dts
index 183f2aa..6be6b16 100644
--- a/arch/powerpc/boot/dts/mpc8313erdb.dts
+++ b/arch/powerpc/boot/dts/mpc8313erdb.dts
@@ -208,6 +208,20 @@
sleep = <&pmc 0x0030>;
};
 
+   ptp_cl...@24e00 {
+   device_type = "ptp_clock";
+   model = "eTSEC";
+   reg = <0x24E00 0xB0>;
+   interrupts = <12 0x8 13 0x8>;
+   interrupt-parent = < &ipic >;
+   tclk_period = <10>;
+   tmr_prsc= <100>;
+   tmr_add = <0x99A4>;
+   cksel   = <0x1>;
+   tmr_fiper1  = <0x3B9AC9F6>;
+   tmr_fiper2  = <0x00018696>;
+   };
+
enet0: ether...@24000 {
#address-cells = <1>;
#size-cells = <1>;
diff --git a/arch/powerpc/boot/dts/p2020ds.dts 
b/arch/powerpc/boot/dts/p2020ds.dts
index 1101914..f72353a 100644
--- a/arch/powerpc/boot/dts/p2020ds.dts
+++ b/arch/powerpc/boot/dts/p2020ds.dts
@@ -336,6 +336,20 @@
phy_type = "ulpi";
};
 
+   ptp_cl...@24e00 {
+   device_type = "ptp_clock";
+   model = "eTSEC";
+   reg = <0x24E00 0xB0>;
+   interrupts = <68 2 69 2 70 2>;
+ 

[PATCH v3 2/3] ptp: Added a clock that uses the Linux system time.

2010-05-14 Thread Richard Cochran
This PTP clock simply uses the NTP time adjustment system calls. The
driver can be used in systems that lack a special hardware PTP clock.

Signed-off-by: Richard Cochran 
---
 drivers/ptp/Kconfig |   12 
 drivers/ptp/Makefile|1 +
 drivers/ptp/ptp_linux.c |  136 +++
 kernel/time/ntp.c   |2 +
 4 files changed, 151 insertions(+), 0 deletions(-)
 create mode 100644 drivers/ptp/ptp_linux.c

diff --git a/drivers/ptp/Kconfig b/drivers/ptp/Kconfig
index c80a25b..9390d44 100644
--- a/drivers/ptp/Kconfig
+++ b/drivers/ptp/Kconfig
@@ -23,4 +23,16 @@ config PTP_1588_CLOCK
  To compile this driver as a module, choose M here: the module
  will be called ptp_clock.
 
+config PTP_1588_CLOCK_LINUX
+   tristate "Linux system timer as PTP clock"
+   depends on PTP_1588_CLOCK
+   help
+ This driver adds support for using the standard Linux time
+ source as a PTP clock. This clock is only useful if your PTP
+ programs are using software time stamps for the PTP Ethernet
+ packets.
+
+ To compile this driver as a module, choose M here: the module
+ will be called ptp_linux.
+
 endmenu
diff --git a/drivers/ptp/Makefile b/drivers/ptp/Makefile
index b86695c..1651d52 100644
--- a/drivers/ptp/Makefile
+++ b/drivers/ptp/Makefile
@@ -3,3 +3,4 @@
 #
 
 obj-$(CONFIG_PTP_1588_CLOCK)   += ptp_clock.o
+obj-$(CONFIG_PTP_1588_CLOCK_LINUX) += ptp_linux.o
diff --git a/drivers/ptp/ptp_linux.c b/drivers/ptp/ptp_linux.c
new file mode 100644
index 000..f0dbfc6
--- /dev/null
+++ b/drivers/ptp/ptp_linux.c
@@ -0,0 +1,136 @@
+/*
+ * PTP 1588 clock using the Linux system clock
+ *
+ * Copyright (C) 2010 OMICRON electronics GmbH
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+static struct ptp_clock *linux_clock;
+
+DEFINE_SPINLOCK(adjtime_lock);
+
+static int ptp_linux_adjfreq(void *priv, s32 delta)
+{
+   struct timex txc;
+   s64 tmp = delta;
+   int err;
+   txc.freq = div_s64(tmp<<16, 1000);
+   txc.modes = ADJ_FREQUENCY;
+   err = do_adjtimex(&txc);
+   return err < 0 ? err : 0;
+}
+
+static int ptp_linux_adjtime(void *priv, struct timespec *ts)
+{
+   s64 delta;
+   ktime_t now;
+   struct timespec t2;
+   unsigned long flags;
+   int err;
+
+   delta = 10LL * ts->tv_sec + ts->tv_nsec;
+
+   spin_lock_irqsave(&adjtime_lock, flags);
+
+   now = ktime_get_real();
+
+   now = delta < 0 ? ktime_sub_ns(now,-delta) : ktime_add_ns(now,delta);
+
+   t2 = ktime_to_timespec(now);
+
+   err = do_settimeofday(&t2);
+
+   spin_unlock_irqrestore(&adjtime_lock, flags);
+
+   return err;
+}
+
+static int ptp_linux_gettime(void *priv, struct timespec *ts)
+{
+   getnstimeofday(ts);
+   return 0;
+}
+
+static int ptp_linux_settime(void *priv, struct timespec *ts)
+{
+   return do_settimeofday(ts);
+}
+
+static int ptp_linux_gettimer(void *priv, int index, struct itimerspec *ts)
+{
+   /* We do not offer any ancillary features at all. */
+   return -EOPNOTSUPP;
+}
+
+static int ptp_linux_settimer(void *p, int i, int abs, struct itimerspec *ts)
+{
+   /* We do not offer any ancillary features at all. */
+   return -EOPNOTSUPP;
+}
+
+static int ptp_linux_enable(void *priv, struct ptp_clock_request *rq, int on)
+{
+   /* We do not offer any ancillary features at all. */
+   return -EOPNOTSUPP;
+}
+
+static struct ptp_clock_info ptp_linux_caps = {
+   .owner  = THIS_MODULE,
+   .name   = "Linux timer",
+   .max_adj= 512000,
+   .n_alarm= 0,
+   .n_ext_ts   = 0,
+   .n_per_out  = 0,
+   .pps= 0,
+   .priv   = NULL,
+   .adjfreq= ptp_linux_adjfreq,
+   .adjtime= ptp_linux_adjtime,
+   .gettime= ptp_linux_gettime,
+   .settime= ptp_linux_settime,
+   .gettimer   = ptp_linux_gettimer,
+   .settimer   = ptp_linux_settimer,
+   .enable = ptp_linux_enable,
+};
+
+/* module operations */
+
+static void __exit ptp_linux_exit(void)
+{
+   ptp_clock_unregister(linux_clock)

[PATCH v3 1/3] ptp: Added a brand new class driver for ptp clocks.

2010-05-14 Thread Richard Cochran
This patch adds an infrastructure for hardware clocks that implement
IEEE 1588, the Precision Time Protocol (PTP). A class driver offers a
registration method to particular hardware clock drivers. Each clock is
exposed to user space as a character device with ioctls that allow tuning
of the PTP clock.

Signed-off-by: Richard Cochran 
---
 Documentation/ptp/ptp.txt|   95 +++
 Documentation/ptp/testptp.c  |  245 ++
 Documentation/ptp/testptp.mk |   33 +++
 drivers/Kconfig  |2 +
 drivers/Makefile |1 +
 drivers/ptp/Kconfig  |   26 ++
 drivers/ptp/Makefile |5 +
 drivers/ptp/ptp_clock.c  |  512 ++
 include/linux/Kbuild |1 +
 include/linux/ptp_clock.h|   79 ++
 include/linux/ptp_clock_kernel.h |  137 ++
 11 files changed, 1136 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/ptp/ptp.txt
 create mode 100644 Documentation/ptp/testptp.c
 create mode 100644 Documentation/ptp/testptp.mk
 create mode 100644 drivers/ptp/Kconfig
 create mode 100644 drivers/ptp/Makefile
 create mode 100644 drivers/ptp/ptp_clock.c
 create mode 100644 include/linux/ptp_clock.h
 create mode 100644 include/linux/ptp_clock_kernel.h

diff --git a/Documentation/ptp/ptp.txt b/Documentation/ptp/ptp.txt
new file mode 100644
index 000..46858b3
--- /dev/null
+++ b/Documentation/ptp/ptp.txt
@@ -0,0 +1,95 @@
+
+* PTP infrastructure for Linux
+
+  This patch set introduces support for IEEE 1588 PTP clocks in
+  Linux. Together with the SO_TIMESTAMPING socket options, this
+  presents a standardized method for developing PTP user space
+  programs, synchronizing Linux with external clocks, and using the
+  ancillary features of PTP hardware clocks.
+
+  A new class driver exports a kernel interface for specific clock
+  drivers and a user space interface. The infrastructure supports a
+  complete set of PTP functionality.
+
+  + Basic clock operations
+- Set time
+- Get time
+- Shift the clock by a given offset atomically
+- Adjust clock frequency
+
+  + Ancillary clock features
+- One short or periodic alarms, with signal delivery to user program
+- Time stamp external events
+- Period output signals configurable from user space
+- Synchronization of the Linux system time via the PPS subsystem
+
+** PTP kernel API
+
+   A PTP clock driver registers itself with the class driver. The
+   class driver handles all of the dealings with user space. The
+   author of a clock driver need only implement the details of
+   programming the clock hardware. The clock driver notifies the class
+   driver of asynchronous events (alarms and external time stamps) via
+   a simple message passing interface.
+
+   The class driver supports multiple PTP clock drivers. In normal use
+   cases, only one PTP clock is needed. However, for testing and
+   development, it can be useful to have more than one clock in a
+   single system, in order to allow performance comparisons.
+
+** PTP user space API
+
+   The class driver creates a character device for each registered PTP
+   clock. User space programs may control the clock using standardized
+   ioctls. A program may query, enable, configure, and disable the
+   ancillary clock features. User space can receive time stamped
+   events via blocking read() and poll(). One shot and periodic
+   signals may be configured via an ioctl API with semantics similar
+   to the POSIX timer_settime() system call.
+
+   As an real life example, the following two patches for ptpd version
+   1.0.0 demonstrate how the API works.
+
+   
https://sourceforge.net/tracker/?func=detail&aid=2992845&group_id=139814&atid=744634
+
+   
https://sourceforge.net/tracker/?func=detail&aid=2992847&group_id=139814&atid=744634
+
+** Writing clock drivers
+
+   Clock drivers include include/linux/ptp_clock_kernel.h and register
+   themselves by presenting a 'struct ptp_clock_info' to the
+   registration method. Clock drivers must implement all of the
+   functions in the interface. If a clock does not offer a particular
+   ancillary feature, then the driver should just return -EOPNOTSUPP
+   from those functions.
+
+   Drivers must ensure that all of the methods in interface are
+   reentrant. Since most hardware implementations treat the time value
+   as a 64 bit integer accessed as two 32 bit registers, drivers
+   should use spin_lock_irqsave/spin_unlock_irqrestore to protect
+   against concurrent access. This locking cannot be accomplished in
+   class driver, since the lock may also be needed by the clock
+   driver's interrupt service routine.
+
+** Supported hardware
+
+   + Standard Linux system timer
+ - No special PTP features
+ - For use with software time stamping
+
+   + Freescale eTSEC gianfar
+ - 2 Time stamp external triggers, programmable polarity (opt. interrupt)
+ - 2 Alarm registers (opt

[PATCH v3 0/3] ptp: IEEE 1588 clock support

2010-05-14 Thread Richard Cochran
Now and again there has been talk on this list of adding PTP support
into Linux. One part of the picture is already in place, the
SO_TIMESTAMPING API for hardware time stamping. This patch set offers
the missing second part needed for complete IEEE 1588 support.

The only feature still to be implemented is the hook into the PPS
subsystem, to synchronize the Linux clock to the PTP clock.

Enjoy,
Richard

* Patch ChangeLog
** v3
*** general
   - Added documentation on writing clock drivers.
   - Added the ioctls for the ancillary clock features.
   - Changed wrong subsys_initcall() to module_init() in clock drivers.
   - Removed the (too coarse) character device mutex.
   - Setting the clock now requires CAP_SYS_TIME.
*** gianfar
   - Added alarm feature.
   - Added device tree node binding description.
   - Added fine grain locking of the clock registers.
   - Added the external time stamp feature.
   - Added white space for better style.
   - Coverted base+offset to structure pointers for register access.
   - When removing the driver, we now disable all PTP functions.

** v2
   - Changed clock list from a static array into a dynamic list. Also,
 use a bitmap to manage the clock's minor numbers.
   - Replaced character device semaphore with a mutex.
   - Drop .ko from module names in Kbuild help.
   - Replace deprecated unifdef-y with header-y for user space header file.
   - Added links to both of the ptpd patches on sourceforge.
   - Gianfar driver now gets parameters from device tree.
   - Added API documentation to Documentation/ptp/ptp.txt


Richard Cochran (3):
  ptp: Added a brand new class driver for ptp clocks.
  ptp: Added a clock that uses the Linux system time.
  ptp: Added a clock that uses the eTSEC found on the MPC85xx.

 Documentation/powerpc/dts-bindings/fsl/tsec.txt |   56 +++
 Documentation/ptp/ptp.txt   |   95 
 Documentation/ptp/testptp.c |  245 +++
 Documentation/ptp/testptp.mk|   33 ++
 arch/powerpc/boot/dts/mpc8313erdb.dts   |   14 +
 arch/powerpc/boot/dts/p2020ds.dts   |   14 +
 arch/powerpc/boot/dts/p2020rdb.dts  |   14 +
 drivers/Kconfig |2 +
 drivers/Makefile|1 +
 drivers/net/Makefile|1 +
 drivers/net/gianfar_ptp.c   |  521 +++
 drivers/net/gianfar_ptp_reg.h   |  113 +
 drivers/ptp/Kconfig |   51 +++
 drivers/ptp/Makefile|6 +
 drivers/ptp/ptp_clock.c |  512 ++
 drivers/ptp/ptp_linux.c |  136 ++
 include/linux/Kbuild|1 +
 include/linux/ptp_clock.h   |   79 
 include/linux/ptp_clock_kernel.h|  137 ++
 kernel/time/ntp.c   |2 +
 20 files changed, 2033 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/ptp/ptp.txt
 create mode 100644 Documentation/ptp/testptp.c
 create mode 100644 Documentation/ptp/testptp.mk
 create mode 100644 drivers/net/gianfar_ptp.c
 create mode 100644 drivers/net/gianfar_ptp_reg.h
 create mode 100644 drivers/ptp/Kconfig
 create mode 100644 drivers/ptp/Makefile
 create mode 100644 drivers/ptp/ptp_clock.c
 create mode 100644 drivers/ptp/ptp_linux.c
 create mode 100644 include/linux/ptp_clock.h
 create mode 100644 include/linux/ptp_clock_kernel.h

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Re: [PATCH] powerpc/fsl-booke: Move loadcam_entry back to asm code to fix SMP ftrace

2010-05-14 Thread Becky Bruce


On May 13, 2010, at 11:25 PM, Kumar Gala wrote:

When we build with ftrace enabled its possible that loadcam_entry  
would
have used the stack pointer (even though the code doesn't need it).   
We

call loadcam_entry in __secondary_start before the stack is setup.  To
ensure that loadcam_entry doesn't use the stack pointer the easiest
solution is to just have it in asm code.

Signed-off-by: Kumar Gala 


Looks good on 8572 SMP - both cpus come up properly now with ftrace  
enabled, and I am able to run the tracers.


Tested-by: Becky Bruce 


---
arch/powerpc/kernel/asm-offsets.c |8 
arch/powerpc/mm/fsl_booke_mmu.c   |   25 +++--
arch/powerpc/mm/mmu_decl.h|   10 +-
arch/powerpc/mm/tlb_nohash_low.S  |   28 
4 files changed, 48 insertions(+), 23 deletions(-)

diff --git a/arch/powerpc/kernel/asm-offsets.c b/arch/powerpc/kernel/ 
asm-offsets.c

index c09138d..b894721 100644
--- a/arch/powerpc/kernel/asm-offsets.c
+++ b/arch/powerpc/kernel/asm-offsets.c
@@ -447,6 +447,14 @@ int main(void)
DEFINE(PGD_T_LOG2, PGD_T_LOG2);
DEFINE(PTE_T_LOG2, PTE_T_LOG2);
#endif
+#ifdef CONFIG_FSL_BOOKE
+   DEFINE(TLBCAM_SIZE, sizeof(struct tlbcam));
+   DEFINE(TLBCAM_MAS0, offsetof(struct tlbcam, MAS0));
+   DEFINE(TLBCAM_MAS1, offsetof(struct tlbcam, MAS1));
+   DEFINE(TLBCAM_MAS2, offsetof(struct tlbcam, MAS2));
+   DEFINE(TLBCAM_MAS3, offsetof(struct tlbcam, MAS3));
+   DEFINE(TLBCAM_MAS7, offsetof(struct tlbcam, MAS7));
+#endif

#ifdef CONFIG_KVM_EXIT_TIMING
DEFINE(VCPU_TIMING_EXIT_TBU, offsetof(struct kvm_vcpu,
diff --git a/arch/powerpc/mm/fsl_booke_mmu.c b/arch/powerpc/mm/ 
fsl_booke_mmu.c

index 1ed6b52..cdc7526 100644
--- a/arch/powerpc/mm/fsl_booke_mmu.c
+++ b/arch/powerpc/mm/fsl_booke_mmu.c
@@ -2,7 +2,7 @@
 * Modifications by Kumar Gala (ga...@kernel.crashing.org) to support
 * E500 Book E processors.
 *
- * Copyright 2004 Freescale Semiconductor, Inc
+ * Copyright 2004,2010 Freescale Semiconductor, Inc.
 *
 * This file contains the routines for initializing the MMU
 * on the 4xx series of chips.
@@ -56,19 +56,13 @@

unsigned int tlbcam_index;

-#define NUM_TLBCAMS(64)

#if defined(CONFIG_LOWMEM_CAM_NUM_BOOL) && (CONFIG_LOWMEM_CAM_NUM >=  
NUM_TLBCAMS)

#error "LOWMEM_CAM_NUM must be less than NUM_TLBCAMS"
#endif

-struct tlbcam {
-   u32 MAS0;
-   u32 MAS1;
-   unsigned long   MAS2;
-   u32 MAS3;
-   u32 MAS7;
-} TLBCAM[NUM_TLBCAMS];
+#define NUM_TLBCAMS(64)
+struct tlbcam TLBCAM[NUM_TLBCAMS];

struct tlbcamrange {
unsigned long start;
@@ -109,19 +103,6 @@ unsigned long p_mapped_by_tlbcam(phys_addr_t pa)
return 0;
}

-void loadcam_entry(int idx)
-{
-   mtspr(SPRN_MAS0, TLBCAM[idx].MAS0);
-   mtspr(SPRN_MAS1, TLBCAM[idx].MAS1);
-   mtspr(SPRN_MAS2, TLBCAM[idx].MAS2);
-   mtspr(SPRN_MAS3, TLBCAM[idx].MAS3);
-
-   if (mmu_has_feature(MMU_FTR_BIG_PHYS))
-   mtspr(SPRN_MAS7, TLBCAM[idx].MAS7);
-
-   asm volatile("isync;tlbwe;isync" : : : "memory");
-}
-
/*
 * Set up one of the I/D BAT (block address translation) register  
pairs.

 * The parameters are not checked; in particular size must be a power
diff --git a/arch/powerpc/mm/mmu_decl.h b/arch/powerpc/mm/mmu_decl.h
index d49a775..0591f25 100644
--- a/arch/powerpc/mm/mmu_decl.h
+++ b/arch/powerpc/mm/mmu_decl.h
@@ -149,7 +149,15 @@ extern unsigned long mmu_mapin_ram(unsigned  
long top);

extern void MMU_init_hw(void);
extern unsigned long mmu_mapin_ram(unsigned long top);
extern void adjust_total_lowmem(void);
-
+extern void loadcam_entry(unsigned int index);
+
+struct tlbcam {
+   u32 MAS0;
+   u32 MAS1;
+   unsigned long   MAS2;
+   u32 MAS3;
+   u32 MAS7;
+};
#elif defined(CONFIG_PPC32)
/* anything 32-bit except 4xx or 8xx */
extern void MMU_init_hw(void);
diff --git a/arch/powerpc/mm/tlb_nohash_low.S b/arch/powerpc/mm/ 
tlb_nohash_low.S

index bbdc5b5..8656ecf 100644
--- a/arch/powerpc/mm/tlb_nohash_low.S
+++ b/arch/powerpc/mm/tlb_nohash_low.S
@@ -271,3 +271,31 @@ _GLOBAL(set_context)
#else
#error Unsupported processor type !
#endif
+
+#if defined(CONFIG_FSL_BOOKE)
+/*
+ * extern void loadcam_entry(unsigned int index)
+ *
+ * Load TLBCAM[index] entry in to the L2 CAM MMU
+ */
+_GLOBAL(loadcam_entry)
+   LOAD_REG_ADDR(r4, TLBCAM)
+   mulli   r5,r3,TLBCAM_SIZE
+   add r3,r5,r4
+   lwz r4,TLBCAM_MAS0(r3)
+   mtspr   SPRN_MAS0,r4
+   lwz r4,TLBCAM_MAS1(r3)
+   mtspr   SPRN_MAS1,r4
+   PPC_LL  r4,TLBCAM_MAS2(r3)
+   mtspr   SPRN_MAS2,r4
+   lwz r4,TLBCAM_MAS3(r3)
+   mtspr   SPRN_MAS3,r4
+BEGIN_MMU_FTR_SECTION
+   lwz r4,TLBCAM_MAS7(r3)
+   mtspr   SPRN_MAS7,r4
+END_MMU_FTR_SECTION_IFSET(MMU_FTR_BIG_PHYS)
+   isync
+   tlbwe
+   isync
+   blr
+#endif
--
1.6.0.6

___
Linuxppc-dev mailing list

[PATCH] gianfar: Remove legacy PM callbacks

2010-05-14 Thread Anton Vorontsov
These callbacks were needed because dev_pm_ops support for OF
platform devices was in the powerpc tree, and the patch that
added dev_pm_ops for gianfar driver was in the netdev tree. Now
that netdev and powerpc trees have merged into Linus' tree, we
can remove the legacy hooks.

Signed-off-by: Anton Vorontsov 
---
 drivers/net/gianfar.c |   14 --
 1 files changed, 0 insertions(+), 14 deletions(-)

diff --git a/drivers/net/gianfar.c b/drivers/net/gianfar.c
index 5d3763f..fb23f04 100644
--- a/drivers/net/gianfar.c
+++ b/drivers/net/gianfar.c
@@ -1288,21 +1288,9 @@ static struct dev_pm_ops gfar_pm_ops = {
 
 #define GFAR_PM_OPS (&gfar_pm_ops)
 
-static int gfar_legacy_suspend(struct of_device *ofdev, pm_message_t state)
-{
-   return gfar_suspend(&ofdev->dev);
-}
-
-static int gfar_legacy_resume(struct of_device *ofdev)
-{
-   return gfar_resume(&ofdev->dev);
-}
-
 #else
 
 #define GFAR_PM_OPS NULL
-#define gfar_legacy_suspend NULL
-#define gfar_legacy_resume NULL
 
 #endif
 
@@ -3055,8 +3043,6 @@ static struct of_platform_driver gfar_driver = {
 
.probe = gfar_probe,
.remove = gfar_remove,
-   .suspend = gfar_legacy_suspend,
-   .resume = gfar_legacy_resume,
.driver.pm = GFAR_PM_OPS,
 };
 
-- 
1.7.0.5
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


[PATCH v2] USB: FHCI: cq_get() should check kfifo_out()'s return value

2010-05-14 Thread Anton Vorontsov
Since commit 7acd72eb85f1c7a15e8b5eb554994949241737f1 ("kfifo: rename
kfifo_put... into kfifo_in... and kfifo_get... into kfifo_out..."),
kfifo_out() is marked __must_check, and that causes gcc to produce
lots of warnings like this:

  CC  drivers/usb/host/fhci-mem.o
In file included from drivers/usb/host/fhci-hcd.c:34:
drivers/usb/host/fhci.h: In function 'cq_get':
drivers/usb/host/fhci.h:520: warning: ignoring return value of 'kfifo_out', 
declared with attribute warn_unused_result
...

This patch fixes the issue by properly checking the return value.

Signed-off-by: Anton Vorontsov 
---

On Tue, May 04, 2010 at 12:17:19PM -0700, Greg KH wrote:
> On Sun, May 02, 2010 at 09:30:25PM +0400, Anton Vorontsov wrote:
> > Since commit 7acd72eb85f1c7a15e8b5eb554994949241737f1 ("kfifo: rename
> > kfifo_put... into kfifo_in... and kfifo_get... into kfifo_out..."),
> > kfifo_out() is marked __must_check, and that causes gcc to produce
> > lots of warnings like this:
> > 
> >   CC  drivers/usb/host/fhci-mem.o
> > In file included from drivers/usb/host/fhci-hcd.c:34:
> > drivers/usb/host/fhci.h: In function 'cq_get':
> > drivers/usb/host/fhci.h:520: warning: ignoring return value of 'kfifo_out', 
> > declared with attribute warn_unused_result
> > ...
> > 
> > Fix it with BUG_ON() check. We could just forcibly ignore return
> > value, but it's better to check if we really got a whole pointer.
> 
> No, you don't want to crash the whole machine for something like this.
> 
> Please just handle the error normally and pass it up to the upper levels
> if possible.

OK, here it is. Thanks!

 drivers/usb/host/fhci.h |9 +++--
 1 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/host/fhci.h b/drivers/usb/host/fhci.h
index 72dae1c..3b6e864 100644
--- a/drivers/usb/host/fhci.h
+++ b/drivers/usb/host/fhci.h
@@ -20,6 +20,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -515,9 +516,13 @@ static inline int cq_put(struct kfifo *kfifo, void *p)
 
 static inline void *cq_get(struct kfifo *kfifo)
 {
-   void *p = NULL;
+   unsigned int sz;
+   void *p;
+
+   sz = kfifo_out(kfifo, (void *)&p, sizeof(p));
+   if (sz != sizeof(p))
+   return NULL;
 
-   kfifo_out(kfifo, (void *)&p, sizeof(p));
return p;
 }
 
-- 
1.7.0.5
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


[PATCH] fsl_pq_mdio: Fix mdiobus allocation handling

2010-05-14 Thread Anton Vorontsov
The driver could return success code even if mdiobus_alloc() failed.
This patch fixes the issue.

Signed-off-by: Anton Vorontsov 
---
 drivers/net/fsl_pq_mdio.c |6 --
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/net/fsl_pq_mdio.c b/drivers/net/fsl_pq_mdio.c
index 3acac5f..ff028f5 100644
--- a/drivers/net/fsl_pq_mdio.c
+++ b/drivers/net/fsl_pq_mdio.c
@@ -277,15 +277,17 @@ static int fsl_pq_mdio_probe(struct of_device *ofdev,
int tbiaddr = -1;
const u32 *addrp;
u64 addr = 0, size = 0;
-   int err = 0;
+   int err;
 
priv = kzalloc(sizeof(*priv), GFP_KERNEL);
if (!priv)
return -ENOMEM;
 
new_bus = mdiobus_alloc();
-   if (NULL == new_bus)
+   if (!new_bus) {
+   err = -ENOMEM;
goto err_free_priv;
+   }
 
new_bus->name = "Freescale PowerQUICC MII Bus",
new_bus->read = &fsl_pq_mdio_read,
-- 
1.7.0.5

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Re: [PATCH] media/IR: Add missing include file to rc-map.c

2010-05-14 Thread Stephen Rothwell
Hi Peter,

On Fri, 14 May 2010 13:26:51 +0200 Peter Hüwe  wrote:
>
> From: Peter Huewe 
> 
> This patch adds a missing include linux/delay.h to prevent
> build failures[1-5]
> 
> Signed-off-by: Peter Huewe 
> ---
> Forwarded to linux-next mailing list - 
> breakage still exists in linux-next of 20100514 - please apply

This patch was included in the v4l-dvb tree (and thus linux-next) today
-see commit 1e19cb4e7d15d724cf2c6ae23f0b871c84a92790.

-- 
Cheers,
Stephen Rothwells...@canb.auug.org.au
http://www.canb.auug.org.au/~sfr/


pgpOWZalxKdhi.pgp
Description: PGP signature
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: [PATCH] media/IR: Add missing include file to rc-map.c

2010-05-14 Thread Peter Hüwe
From: Peter Huewe 

This patch adds a missing include linux/delay.h to prevent
build failures[1-5]

Signed-off-by: Peter Huewe 
---
Forwarded to linux-next mailing list - 
breakage still exists in linux-next of 20100514 - please apply

KernelVersion: linux-next-20100505

References:
[1] http://kisskb.ellerman.id.au/kisskb/buildresult/2571452/
[2] http://kisskb.ellerman.id.au/kisskb/buildresult/2571188/
[3] http://kisskb.ellerman.id.au/kisskb/buildresult/2571479/
[4] http://kisskb.ellerman.id.au/kisskb/buildresult/2571429/
[5] http://kisskb.ellerman.id.au/kisskb/buildresult/2571432/

drivers/media/IR/rc-map.c |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/drivers/media/IR/rc-map.c b/drivers/media/IR/rc-map.c
index caf6a27..46a8f15 100644
--- a/drivers/media/IR/rc-map.c
+++ b/drivers/media/IR/rc-map.c
@@ -14,6 +14,7 @@
 
 #include 
 #include 
+#include 
 
 /* Used to handle IR raw handler extensions */
 static LIST_HEAD(rc_map_list);
-- 
1.6.4.4
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Re: [PATCH] media/IR: Add missing include file to rc-map.c

2010-05-14 Thread Peter Hüwe
From: Peter Huewe 

This patch adds a missing include linux/delay.h to prevent
build failures[1-5]

Signed-off-by: Peter Huewe 
---
Forwarded to linux-next mailing list - 
breakage still exists in linux-next of 20100514 - please apply

KernelVersion: linux-next-20100505

References:
[1] http://kisskb.ellerman.id.au/kisskb/buildresult/2571452/
[2] http://kisskb.ellerman.id.au/kisskb/buildresult/2571188/
[3] http://kisskb.ellerman.id.au/kisskb/buildresult/2571479/
[4] http://kisskb.ellerman.id.au/kisskb/buildresult/2571429/
[5] http://kisskb.ellerman.id.au/kisskb/buildresult/2571432/

drivers/media/IR/rc-map.c |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/drivers/media/IR/rc-map.c b/drivers/media/IR/rc-map.c
index caf6a27..46a8f15 100644
--- a/drivers/media/IR/rc-map.c
+++ b/drivers/media/IR/rc-map.c
@@ -14,6 +14,7 @@
 
 #include 
 #include 
+#include 
 
 /* Used to handle IR raw handler extensions */
 static LIST_HEAD(rc_map_list);
-- 
1.6.4.4
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Re: [PATCH] powerpc: Add i8042 keyboard and mouse irq parsing

2010-05-14 Thread Martyn Welch
Martyn Welch wrote:
> Currently the irqs for the i8042, which historically provides keyboard and
> mouse (aux) support, is hardwired in the driver rather than parsing the
> dts.
>
> In addition the interrupts are provided in the dts, but in a way that is
> not easily parsable using irq_of_parse_and_map().
>
> This patch modifies the powerpc legacy IO code to attempt to parse the
> device tree for this information, failing back to the hardcoded values if
> it fails. For this to succeed the interrupts for the keyboard and mouse
> ports need to be moved from the parent i8042 node to the individual port
> nodes.
>
> Signed-off-by: Martyn Welch 
> ---
>
> To get irq_of_parse_and_map() to successfully parse the interrupts, I had
> to do this to my device tree:
>
> @@ -120,16 +120,17 @@
> #address-cells = <1>;
> reg = <1 0x60 0x1
>1 0x64 0x1>;
> -   interrupts = <1 1 12 1>;
> interrupt-parent = <&lpc_pic>;
>  
> keybo...@0 {
> reg = <0x0>;
> +   interrupts = <1 1>;
> compatible = "pnpPNP,303";
> };
>  
> mo...@1 {
> reg = <0x1>;
> +   interrupts = <12 1>;
> compatible = "pnpPNP,f03";
> };
> };
>
> I'm not sure how to parse for the correct interrupt if I don't do this. I
> this is incorrect and someone could advise me on how the existing device
> tree layout can be properly parsed, I'll happily modify this patch.
>
>   

Grant, any suggestions? (sorry, forgot to CC you)

Martyn

>  arch/powerpc/kernel/setup-common.c |   34 +++---
>  drivers/input/serio/i8042-io.h |8 
>  2 files changed, 39 insertions(+), 3 deletions(-)
>
> diff --git a/arch/powerpc/kernel/setup-common.c 
> b/arch/powerpc/kernel/setup-common.c
> index 03dd6a2..9c4dc4c 100644
> --- a/arch/powerpc/kernel/setup-common.c
> +++ b/arch/powerpc/kernel/setup-common.c
> @@ -93,6 +93,10 @@ struct screen_info screen_info = {
>   .orig_video_points = 16
>  };
>  
> +/* Variables required to store legacy IO irq routing */
> +int of_i8042_kbd_irq;
> +int of_i8042_aux_irq;
> +
>  #ifdef __DO_IRQ_CANON
>  /* XXX should go elsewhere eventually */
>  int ppc_do_canonicalize_irqs;
> @@ -555,13 +559,37 @@ void probe_machine(void)
>  /* Match a class of boards, not a specific device configuration. */
>  int check_legacy_ioport(unsigned long base_port)
>  {
> - struct device_node *parent, *np = NULL;
> + struct device_node *parent, *np = NULL, *np_aux = NULL;
>   int ret = -ENODEV;
>  
>   switch(base_port) {
>   case I8042_DATA_REG:
> - if (!(np = of_find_compatible_node(NULL, NULL, "pnpPNP,303")))
> - np = of_find_compatible_node(NULL, NULL, "pnpPNP,f03");
> + np = of_find_compatible_node(NULL, NULL, "pnpPNP,303");
> + if (np) {
> + /*
> +  * Attempt to parse DTS for keyboard irq, fallback to
> +  * standard.
> +  */
> + of_i8042_kbd_irq = irq_of_parse_and_map(np, 0);
> + if (!of_i8042_kbd_irq)
> + of_i8042_kbd_irq = 1;
> + }
> +
> + np_aux = of_find_compatible_node(NULL, NULL, "pnpPNP,f03");
> + if (np_aux) {
> + if (!np) {
> + of_node_put(np);
> + np = np_aux;
> + }
> + /*
> +  * Attempt to parse DTS for mouse (aux) irq, fallback to
> +  * standard.
> +  */
> + of_i8042_aux_irq = irq_of_parse_and_map(np_aux, 0);
> + if (!of_i8042_aux_irq)
> + of_i8042_aux_irq = 12;
> + }
> +
>   if (np) {
>   parent = of_get_parent(np);
>   of_node_put(np);
> diff --git a/drivers/input/serio/i8042-io.h b/drivers/input/serio/i8042-io.h
> index 847f4aa..8fc8753 100644
> --- a/drivers/input/serio/i8042-io.h
> +++ b/drivers/input/serio/i8042-io.h
> @@ -19,6 +19,11 @@
>   * IRQs.
>   */
>  
> +#if defined(CONFIG_PPC)
> +extern int of_i8042_kbd_irq;
> +extern int of_i8042_aux_irq;
> +#endif
> +
>  #ifdef __alpha__
>  # define I8042_KBD_IRQ   1
>  # define I8042_AUX_IRQ   (RTC_PORT(0) == 0x170 ? 9 : 12) /* Jensen is 
> special */
> @@ -27,6 +32,9 @@
>  #include 
>  #elif defined(CONFIG_SH_CAYMAN)
>  #include 
> +#elif defined(CONFIG_PPC)
> 

[PATCH] powerpc: Add i8042 keyboard and mouse irq parsing

2010-05-14 Thread Martyn Welch
Currently the irqs for the i8042, which historically provides keyboard and
mouse (aux) support, is hardwired in the driver rather than parsing the
dts.

In addition the interrupts are provided in the dts, but in a way that is
not easily parsable using irq_of_parse_and_map().

This patch modifies the powerpc legacy IO code to attempt to parse the
device tree for this information, failing back to the hardcoded values if
it fails. For this to succeed the interrupts for the keyboard and mouse
ports need to be moved from the parent i8042 node to the individual port
nodes.

Signed-off-by: Martyn Welch 
---

To get irq_of_parse_and_map() to successfully parse the interrupts, I had
to do this to my device tree:

@@ -120,16 +120,17 @@
#address-cells = <1>;
reg = <1 0x60 0x1
   1 0x64 0x1>;
-   interrupts = <1 1 12 1>;
interrupt-parent = <&lpc_pic>;
 
keybo...@0 {
reg = <0x0>;
+   interrupts = <1 1>;
compatible = "pnpPNP,303";
};
 
mo...@1 {
reg = <0x1>;
+   interrupts = <12 1>;
compatible = "pnpPNP,f03";
};
};

I'm not sure how to parse for the correct interrupt if I don't do this. I
this is incorrect and someone could advise me on how the existing device
tree layout can be properly parsed, I'll happily modify this patch.


 arch/powerpc/kernel/setup-common.c |   34 +++---
 drivers/input/serio/i8042-io.h |8 
 2 files changed, 39 insertions(+), 3 deletions(-)

diff --git a/arch/powerpc/kernel/setup-common.c 
b/arch/powerpc/kernel/setup-common.c
index 03dd6a2..9c4dc4c 100644
--- a/arch/powerpc/kernel/setup-common.c
+++ b/arch/powerpc/kernel/setup-common.c
@@ -93,6 +93,10 @@ struct screen_info screen_info = {
.orig_video_points = 16
 };
 
+/* Variables required to store legacy IO irq routing */
+int of_i8042_kbd_irq;
+int of_i8042_aux_irq;
+
 #ifdef __DO_IRQ_CANON
 /* XXX should go elsewhere eventually */
 int ppc_do_canonicalize_irqs;
@@ -555,13 +559,37 @@ void probe_machine(void)
 /* Match a class of boards, not a specific device configuration. */
 int check_legacy_ioport(unsigned long base_port)
 {
-   struct device_node *parent, *np = NULL;
+   struct device_node *parent, *np = NULL, *np_aux = NULL;
int ret = -ENODEV;
 
switch(base_port) {
case I8042_DATA_REG:
-   if (!(np = of_find_compatible_node(NULL, NULL, "pnpPNP,303")))
-   np = of_find_compatible_node(NULL, NULL, "pnpPNP,f03");
+   np = of_find_compatible_node(NULL, NULL, "pnpPNP,303");
+   if (np) {
+   /*
+* Attempt to parse DTS for keyboard irq, fallback to
+* standard.
+*/
+   of_i8042_kbd_irq = irq_of_parse_and_map(np, 0);
+   if (!of_i8042_kbd_irq)
+   of_i8042_kbd_irq = 1;
+   }
+
+   np_aux = of_find_compatible_node(NULL, NULL, "pnpPNP,f03");
+   if (np_aux) {
+   if (!np) {
+   of_node_put(np);
+   np = np_aux;
+   }
+   /*
+* Attempt to parse DTS for mouse (aux) irq, fallback to
+* standard.
+*/
+   of_i8042_aux_irq = irq_of_parse_and_map(np_aux, 0);
+   if (!of_i8042_aux_irq)
+   of_i8042_aux_irq = 12;
+   }
+
if (np) {
parent = of_get_parent(np);
of_node_put(np);
diff --git a/drivers/input/serio/i8042-io.h b/drivers/input/serio/i8042-io.h
index 847f4aa..8fc8753 100644
--- a/drivers/input/serio/i8042-io.h
+++ b/drivers/input/serio/i8042-io.h
@@ -19,6 +19,11 @@
  * IRQs.
  */
 
+#if defined(CONFIG_PPC)
+extern int of_i8042_kbd_irq;
+extern int of_i8042_aux_irq;
+#endif
+
 #ifdef __alpha__
 # define I8042_KBD_IRQ 1
 # define I8042_AUX_IRQ (RTC_PORT(0) == 0x170 ? 9 : 12) /* Jensen is special */
@@ -27,6 +32,9 @@
 #include 
 #elif defined(CONFIG_SH_CAYMAN)
 #include 
+#elif defined(CONFIG_PPC)
+#define I8042_KBD_IRQ  of_i8042_kbd_irq
+#define I8042_AUX_IRQ  of_i8042_aux_irq
 #else
 # define I8042_KBD_IRQ 1
 # define I8042_AUX_IRQ 12


--
Martyn Welch (Principal Software Engineer)   |   Registered in England and
GE Intelligent Platforms |   Wa

RE: [PATCH] pte_fsl_booke: fix instruction TLB error permission check

2010-05-14 Thread Benjamin Herrenschmidt
On Fri, 2010-05-14 at 17:14 +0800, Liu Dave-R63238 wrote:
> > > Aaron pointed the issue on FSL BookE.
> > > 
> > http://lists.ozlabs.org/pipermail/linuxppc-dev/2010-January/079738.htm
> > > l
> > 
> > Right, but I think 64-bit BookE has the same issue. We can 
> > fix that later tho.
> 
> Ben,
> 
> We also find the _PAGE_USER is different between pte-book3e and old
> fsl-booke
> It is UR in old fsl-booke, and is _PAGE_BAP_UR | _PAGE_BAP_SR in
> pte-book3e,
> which will cause the ioremap_flags issue.
> 
> Did you have a test your commit
> [ea3cc330ac0cd521ff07c7cd432a1848c19a7e92]?

I tested on some things :-) I keep asking Kumar to send me some e500
gear so I can actually test on it :-)

Cheers,
Ben.


___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


RE: [PATCH] pte_fsl_booke: fix instruction TLB error permission check

2010-05-14 Thread Liu Dave-R63238
> > Aaron pointed the issue on FSL BookE.
> > 
> http://lists.ozlabs.org/pipermail/linuxppc-dev/2010-January/079738.htm
> > l
> 
> Right, but I think 64-bit BookE has the same issue. We can 
> fix that later tho.

Ben,

We also find the _PAGE_USER is different between pte-book3e and old
fsl-booke
It is UR in old fsl-booke, and is _PAGE_BAP_UR | _PAGE_BAP_SR in
pte-book3e,
which will cause the ioremap_flags issue.

Did you have a test your commit
[ea3cc330ac0cd521ff07c7cd432a1848c19a7e92]?

Thanks, Dave
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


RE: [PATCH] pte_fsl_booke: fix instruction TLB error permission check

2010-05-14 Thread Benjamin Herrenschmidt
On Fri, 2010-05-14 at 10:16 +0800, Liu Dave-R63238 wrote:
> > Not looking at the code right now ... but do we have the same 
> > issue on 64e ?
> 
> Aaron pointed the issue on FSL BookE.
> http://lists.ozlabs.org/pipermail/linuxppc-dev/2010-January/079738.html

Right, but I think 64-bit BookE has the same issue. We can fix that
later tho.

Cheers
Ben

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


[PATCH v2] trace, powerpc: Implement raw syscall tracepoints on PowerPC

2010-05-14 Thread Ian Munsie
From: Ian Munsie 

This patch implements the raw syscall tracepoints on PowerPC and exports
them for ftrace syscalls to use.

To minimise reworking existing code, I slightly re-ordered the thread
info flags such that the new TIF_SYSCALL_TRACEPOINT bit would still fit
within the 16 bits of the andi. instruction's UI field. The instructions
in question are in /arch/powerpc/kernel/entry_{32,64}.S to and the
_TIF_SYSCALL_T_OR_A with the thread flags to see if system call tracing
is enabled.

In the case of 64bit PowerPC, arch_syscall_addr and
arch_syscall_match_sym_name are overridden to allow ftrace syscalls to
work given the unusual system call table structure and symbol names that
start with a period.

Signed-off-by: Ian Munsie 
---
Changes since v1: No functional changes, just removed the redundant conditional
export of sys_call_table on PPC32 vs PPC64, removed a cast and added an extra
comment to explain the arch_syscall_match_sym_name based on the feedback from
Michael Ellerman.

 arch/powerpc/Kconfig   |1 +
 arch/powerpc/include/asm/syscall.h |5 +
 arch/powerpc/include/asm/thread_info.h |7 +--
 arch/powerpc/kernel/Makefile   |1 +
 arch/powerpc/kernel/ftrace.c   |   19 +++
 arch/powerpc/kernel/ptrace.c   |   10 ++
 6 files changed, 41 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index c4c4549..41e2f3e 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -141,6 +141,7 @@ config PPC
select GENERIC_ATOMIC64 if PPC32
select HAVE_PERF_EVENTS
select HAVE_REGS_AND_STACK_ACCESS_API
+   select HAVE_SYSCALL_TRACEPOINTS
 
 config EARLY_PRINTK
bool
diff --git a/arch/powerpc/include/asm/syscall.h 
b/arch/powerpc/include/asm/syscall.h
index 23913e9..b54b2ad 100644
--- a/arch/powerpc/include/asm/syscall.h
+++ b/arch/powerpc/include/asm/syscall.h
@@ -15,6 +15,11 @@
 
 #include 
 
+/* ftrace syscalls requires exporting the sys_call_table */
+#ifdef CONFIG_FTRACE_SYSCALLS
+extern const unsigned long *sys_call_table;
+#endif /* CONFIG_FTRACE_SYSCALLS */
+
 static inline long syscall_get_nr(struct task_struct *task,
  struct pt_regs *regs)
 {
diff --git a/arch/powerpc/include/asm/thread_info.h 
b/arch/powerpc/include/asm/thread_info.h
index aa9d383..e7a8af2 100644
--- a/arch/powerpc/include/asm/thread_info.h
+++ b/arch/powerpc/include/asm/thread_info.h
@@ -110,7 +110,8 @@ static inline struct thread_info *current_thread_info(void)
 #define TIF_NOERROR12  /* Force successful syscall return */
 #define TIF_NOTIFY_RESUME  13  /* callback before returning to user */
 #define TIF_FREEZE 14  /* Freezing for suspend */
-#define TIF_RUNLATCH   15  /* Is the runlatch enabled? */
+#define TIF_SYSCALL_TRACEPOINT 15  /* syscall tracepoint instrumentation */
+#define TIF_RUNLATCH   16  /* Is the runlatch enabled? */
 
 /* as above, but as bit values */
 #define _TIF_SYSCALL_TRACE (1<
 #include 
 #include 
+#include 
 
 
 #ifdef CONFIG_DYNAMIC_FTRACE
@@ -600,3 +601,21 @@ void prepare_ftrace_return(unsigned long *parent, unsigned 
long self_addr)
}
 }
 #endif /* CONFIG_FUNCTION_GRAPH_TRACER */
+
+#if defined(CONFIG_FTRACE_SYSCALLS) && defined(CONFIG_PPC64)
+unsigned long __init arch_syscall_addr(int nr)
+{
+   return sys_call_table[nr*2];
+}
+
+inline bool arch_syscall_match_sym_name(const char *sym, const char *name)
+{
+   /*
+* Compare the symbol name with the system call name. Skip the .sys or
+* .SyS prefix from the symbol name and the sys prefix from the system
+* call name and just match the rest. 32bit can use the generic
+* function since their symbol names don't start with a period.
+*/
+   return (!strcmp(sym + 4, name + 3));
+}
+#endif /* CONFIG_FTRACE_SYSCALLS && CONFIG_PPC64 */
diff --git a/arch/powerpc/kernel/ptrace.c b/arch/powerpc/kernel/ptrace.c
index 7a0c019..eb7eeb8 100644
--- a/arch/powerpc/kernel/ptrace.c
+++ b/arch/powerpc/kernel/ptrace.c
@@ -29,6 +29,7 @@
 #include 
 #include 
 #include 
+#include 
 #ifdef CONFIG_PPC32
 #include 
 #endif
@@ -38,6 +39,9 @@
 #include 
 #include 
 
+#define CREATE_TRACE_POINTS
+#include 
+
 /*
  * The parameter save area on the stack is used to store arguments being passed
  * to callee function and is located at fixed offset from stack pointer.
@@ -1615,6 +1619,9 @@ long do_syscall_trace_enter(struct pt_regs *regs)
 */
ret = -1L;
 
+   if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
+   trace_sys_enter(regs, regs->gpr[0]);
+
if (unlikely(current->audit_context)) {
 #ifdef CONFIG_PPC64
if (!test_thread_flag(TIF_32BIT))
@@ -1643,6 +1650,9 @@ void do_syscall_trace_leave(struct pt_regs *regs)

audit_syscall_exit((regs->ccr&0x1000)?AUDITSC_FAILURE:AUD