Re: ELDK 4.2/kilauea/3.5+ kernel broken

2012-10-19 Thread Mai La
Hi,

My patch was:

@@ -150,12 +157,11 @@ static int ppc4xx_setup_pcieh_hw(struct
platform_device *dev,
if (!sdr_addr)
return -1;

-   SDR0_WRITE(sdr_addr, (u64)res.start  32);  /*HIGH addr */
-   SDR0_WRITE(sdr_addr + 1, res.start  0x); /* Low addr */
-
+   mtdcri(SDR0, *sdr_addr, upper_32_bits(res.start));  /*HIGH addr
*/
+   mtdcri(SDR0, *sdr_addr + 1, lower_32_bits(res.start));  /* Low addr
*/

msi-msi_dev = of_find_node_by_name(NULL, ppc4xx-msi);
-   if (msi-msi_dev)
+   if (!msi-msi_dev)
return -ENODEV;

msi-msi_regs = of_iomap(msi-msi_dev, 0);


1. The first few lines: change from SDR0_WRITE to mtdcri since the old one
cause crash. I use ELDK 4.2.

2. The second one should mean that: if not find any node then return error.
So it should be !msi-msi_dev

Regards,
Mai La.


On Fri, Oct 19, 2012 at 3:05 AM, Robert Berger robert.karl.ber...@gmail.com
 wrote:

 Hi,

 On 10/18/2012 10:03 PM, Benjamin Herrenschmidt wrote:
  On Thu, 2012-10-18 at 20:45 +0300, Robert Berger wrote:
  -   mtdcri(SDR0, *sdr_addr, upper_32_bits(res.start));  /*HIGH
 addr */
  -   mtdcri(SDR0, *sdr_addr + 1, lower_32_bits(res.start));  /* Low
 addr */
  +   SDR0_WRITE(sdr_addr, (u64)res.start  32);  /*HIGH addr */
  +   SDR0_WRITE(sdr_addr + 1, res.start  0x); /* Low addr */
  +
 
  msi-msi_dev = of_find_node_by_name(NULL, ppc4xx-msi);
  -   if (!msi-msi_dev)
  +   if (msi-msi_dev)
  return -ENODEV;
 
  The above changes look bad. The first one is stupid, the second one is
 clearly broken.
 
  The diff us from good to bad right ? Looks like somebody added a very
 busted patch.

 this (from 3.6) does not work:

 -   mtdcri(SDR0, *sdr_addr, upper_32_bits(res.start));  /*HIGH
 addr */
 -   mtdcri(SDR0, *sdr_addr + 1, lower_32_bits(res.start));  /* Low
 addr */

 The good old file (which works) is this:

 +   SDR0_WRITE(sdr_addr, (u64)res.start  32);  /*HIGH addr */
 +   SDR0_WRITE(sdr_addr + 1, res.start  0x); /* Low addr */
 +

 
  If I look at the code in current upstream, I see:
 
mtdcri(SDR0, *sdr_addr, upper_32_bits(res.start));  /*HIGH
 addr */
mtdcri(SDR0, *sdr_addr + 1, lower_32_bits(res.start));  /* Low
 addr */
 
msi-msi_dev = of_find_node_by_name(NULL, ppc4xx-msi);
if (!msi-msi_dev)
return -ENODEV;
 
 
  Which looks correct. So this might be something specific to ELDK ?

 I will be on the road from tomorrow for a week or so, but maybe I can
 isolate the exact lines which break it. I can also try a newer compiler
 to see if this changes anything.

 Is there someone out there with a kilauea board who can boot a 3.6.
 mainline kernel with a default config with a rootfs over nfs?

 
  Cheers,
  Ben.
 
 

 Regards,

 Robert

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

Re: ELDK 4.2/kilauea/3.5+ kernel broken

2012-10-19 Thread Robert Berger
Hi,

On 10/19/2012 06:16 AM, Mai La wrote:
 Hi,
 
 My patch was:
 
 @@ -150,12 +157,11 @@ static int ppc4xx_setup_pcieh_hw(struct
 platform_device *dev,
 if (!sdr_addr)
 return -1;
 
 -   SDR0_WRITE(sdr_addr, (u64)res.start  32);  /*HIGH addr */
 -   SDR0_WRITE(sdr_addr + 1, res.start  0x); /* Low addr */
 -
 +   mtdcri(SDR0, *sdr_addr, upper_32_bits(res.start));  /*HIGH
 addr */
 +   mtdcri(SDR0, *sdr_addr + 1, lower_32_bits(res.start));  /* Low
 addr */
 
 msi-msi_dev = of_find_node_by_name(NULL, ppc4xx-msi);
 -   if (msi-msi_dev)
 +   if (!msi-msi_dev)
 return -ENODEV;
 
 msi-msi_regs = of_iomap(msi-msi_dev, 0);
 
 
 1. The first few lines: change from SDR0_WRITE to mtdcri since the old
 one cause crash. I use ELDK 4.2.

The old one does not cause a crash for me.  As I said on a kilauea board
with ELDK 4.2 a 3.6 kernel, default config and everything reverted to
the good old file I can boot happily with a rootfs from nfs.

If I use the file as it is in 3.6 I don't see the kernel booting. but it
crashes.

 
 2. The second one should mean that: if not find any node then return
 error. So it should be !msi-msi_dev

In the 3.6 kernel it's with ! the old file (which works for me) is
without the !

... very strange ...

 
 Regards,
 Mai La.
 
 

Regards,

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


Re: [PATCH net-next 00/21] treewide: Use consistent api style for address testing

2012-10-19 Thread Eric Dumazet
On Thu, 2012-10-18 at 20:55 -0700, Joe Perches wrote:
 ethernet, ipv4, and ipv6 address testing uses 3 different api naming styles.
 
 ethernet uses:is_foo_ether_addr
 ipv4 uses:ipv4_is_foo
 ipv6 uses:ipv6_addr_foo
 
 Standardize on the ipv6 style of prefix_addr_type to reduce
 the number of styles to remember.
 
 The new consistent styles are:
 
 eth_addr_foo(const u8 *)
 ipv4_addr_foo(__be32)
 ipv6_addr_foo(const struct in6_addr *)
 
 Add temporary backward compatibility #defines for the old names too.
 
 Joe Perches (21):
   etherdevice: Rename is_foo_ether_addr tests to eth_addr_foo
   net: Convert is_foo_ether_addr uses to eth_addr_foo
   arch: Convert is_foo_ether_addr uses to eth_addr_foo
   wireless: Convert is_foo_ether_addr uses to eth_addr_foo
   drivers: net: Convert is_foo_ether_addr uses to eth_addr_foo
   staging: Convert is_foo_ether_addr uses to eth_addr_foo
   infiniband: Convert is_foo_ether_addr uses to eth_addr_foo
   scsi: Convert is_foo_ether_addr uses to eth_addr_foo
   of: Convert is_foo_ether_addr uses to eth_addr_foo
   s390: Convert is_foo_ether_addr uses to eth_addr_foo
   usb: Convert is_foo_ether_addr uses to eth_addr_foo
   uwb: Convert is_foo_ether_addr uses to eth_addr_foo
   Documentation: networking: Convert is_foo_ether_addr uses to 
 eth_addr_foo
   llc_if.h: Convert is_foo_ether_addr uses to eth_addr_foo
   in.h: Rename ipv4_is_foo functions to ipv4_addr_foo
   net: Convert ipv4_is_foo uses to ipv4_addr_foo
   infiniband: Convert ipv4_is_foo uses to ipv4_addr_foo
   ath6kl: Convert ipv4_is_foo uses to ipv4_addr_foo
   parisc: Convert ipv4_is_foo uses to ipv4_addr_foo
   lockd: Convert ipv4_is_foo uses to ipv4_addr_foo
   sctp: Convert ipv4_is_foo uses to ipv4_addr_foo

Yes they are some names discrepancies, thats a big deal.

And we have alloc_skb() / kfree_skb() / skb_clone() 

Why not skb_alloc() / skb_free() / skb_clone() ?

Some people actually know current code by name of functions, they dont
want to change their mind and having to grep include files and git log
to learn the new names of an old function, especially when traveling and
using a laptop.

Sure, when we want to use eth_random_addr(), a grep into include files
to check if its still the right name (old one was random_ether_addr())
is OK because we dont use this one often.

If you think about it, eth_random_addr() was not the perfect name.

Think about all the documentation you can find outside of kernel tree,
RFC and things like that, copy/pasting some linux kernel code.

This kind of changes make our life more difficult, when we have to
backport patches or rebase code, or even perform some searches to find
prior issues/discussions.

Life of a kernel developer is not only dealing with latest Linus (or
-next) tree, and using automatic 'tools'.

Thats a real pain for me at least.



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


Re: PROBLEM: Linux 3.6.2 fails to boot on IBM Cell

2012-10-19 Thread Dennis Schridde
Am Freitag, 19. Oktober 2012, 00:17:55 schrieb Grant Likely:
 What does the boot log look like with the attached patch? (compiled
 only, I haven't booted with it)
Please find the log attached.

--Dennis

blade03-tmux.log.xz
Description: application/xz


signature.asc
Description: This is a digitally signed message part.
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

[PATCH 0/7] update USB gadget driver fsl-usb2-udc

2012-10-19 Thread Christoph Fritz
This series updates USB gadget driver fsl-usb2-udc.

Christoph Fritz (7):
  usb: gadget: fsl_udc: simplify driver init
  usb: gadget: fsl_udc: protect fsl_pullup() with spin_lock
  usb: gadget: fsl_udc: convert to new ulc style
  usb: gadget: fsl_udc: drop ARCH dependency
  usb: gadget: fsl_udc: postpone freeing current dTD
  usb: gadget: fsl_udc: purge global pointer usb_sys_regs
  usb: gadget: fsl_udc: purge global pointer dr_regs

 drivers/usb/gadget/fsl_udc_core.c |  755 -
 drivers/usb/gadget/fsl_usb2_udc.h |4 +
 2 files changed, 322 insertions(+), 437 deletions(-)

-- 
1.7.2.5

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


[PATCH 1/7] usb: gadget: fsl_udc: simplify driver init

2012-10-19 Thread Christoph Fritz
To initialize this driver use 'module_platform_driver' instead
of '__init' and '__exit'.

Signed-off-by: Christoph Fritz chf.fr...@googlemail.com
---
 drivers/usb/gadget/fsl_udc_core.c |   37 +++--
 1 files changed, 11 insertions(+), 26 deletions(-)

diff --git a/drivers/usb/gadget/fsl_udc_core.c 
b/drivers/usb/gadget/fsl_udc_core.c
index 6ae70cb..340451d 100644
--- a/drivers/usb/gadget/fsl_udc_core.c
+++ b/drivers/usb/gadget/fsl_udc_core.c
@@ -49,13 +49,14 @@
 
 #include fsl_usb2_udc.h
 
+#defineDRIVER_NAME fsl-usb2-udc
 #defineDRIVER_DESC Freescale High-Speed USB SOC Device Controller 
driver
 #defineDRIVER_AUTHOR   Li Yang/Jiang Bo
 #defineDRIVER_VERSION  Apr 20, 2007
 
 #defineDMA_ADDR_INVALID(~(dma_addr_t)0)
 
-static const char driver_name[] = fsl-usb2-udc;
+static const char driver_name[] = DRIVER_NAME;
 static const char driver_desc[] = DRIVER_DESC;
 
 static struct usb_dr_device *dr_regs;
@@ -2761,35 +2762,19 @@ static int fsl_udc_otg_resume(struct device *dev)
Register entry point for the peripheral controller driver
 --*/
 
-static struct platform_driver udc_driver = {
-   .remove  = __exit_p(fsl_udc_remove),
-   /* these suspend and resume are not usb suspend and resume */
-   .suspend = fsl_udc_suspend,
-   .resume  = fsl_udc_resume,
-   .driver  = {
-   .name = (char *)driver_name,
-   .owner = THIS_MODULE,
-   /* udc suspend/resume called from OTG driver */
+static struct platform_driver fsl_udc_driver = {
+   .probe  = fsl_udc_probe,
+   .remove = __devexit_p(fsl_udc_remove),
+   .suspend= fsl_udc_suspend,
+   .resume = fsl_udc_resume,
+   .driver = {
+   .name   = DRIVER_NAME,
+   .owner  = THIS_MODULE,
.suspend = fsl_udc_otg_suspend,
.resume  = fsl_udc_otg_resume,
},
 };
-
-static int __init udc_init(void)
-{
-   printk(KERN_INFO %s (%s)\n, driver_desc, DRIVER_VERSION);
-   return platform_driver_probe(udc_driver, fsl_udc_probe);
-}
-
-module_init(udc_init);
-
-static void __exit udc_exit(void)
-{
-   platform_driver_unregister(udc_driver);
-   printk(KERN_WARNING %s unregistered\n, driver_desc);
-}
-
-module_exit(udc_exit);
+module_platform_driver(fsl_udc_driver);
 
 MODULE_DESCRIPTION(DRIVER_DESC);
 MODULE_AUTHOR(DRIVER_AUTHOR);
-- 
1.7.2.5

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


[PATCH 2/7] usb: gadget: fsl_udc: protect fsl_pullup() with spin_lock

2012-10-19 Thread Christoph Fritz
This patch reworks fsl_pullup() against the background of switching over
to udc_start()/udc_stop() style:

Protect function fsl_pullup() with a spin_lock. Also set vbus_active as
default to true. This prevents disabling USB controller if there is no
driver support for an external transceiver (or GPIO) that detects a VBUS
power session starting.

Signed-off-by: Christoph Fritz chf.fr...@googlemail.com
---
 drivers/usb/gadget/fsl_udc_core.c |4 
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/drivers/usb/gadget/fsl_udc_core.c 
b/drivers/usb/gadget/fsl_udc_core.c
index 340451d..0a0d6a6 100644
--- a/drivers/usb/gadget/fsl_udc_core.c
+++ b/drivers/usb/gadget/fsl_udc_core.c
@@ -1242,8 +1242,10 @@ static int fsl_vbus_draw(struct usb_gadget *gadget, 
unsigned mA)
 static int fsl_pullup(struct usb_gadget *gadget, int is_on)
 {
struct fsl_udc *udc;
+   unsigned long flags;
 
udc = container_of(gadget, struct fsl_udc, gadget);
+   spin_lock_irqsave(udc-lock, flags);
udc-softconnect = (is_on != 0);
if (can_pullup(udc))
fsl_writel((fsl_readl(dr_regs-usbcmd) | USB_CMD_RUN_STOP),
@@ -1251,6 +1253,7 @@ static int fsl_pullup(struct usb_gadget *gadget, int 
is_on)
else
fsl_writel((fsl_readl(dr_regs-usbcmd)  ~USB_CMD_RUN_STOP),
dr_regs-usbcmd);
+   spin_unlock_irqrestore(udc-lock, flags);
 
return 0;
 }
@@ -2557,6 +2560,7 @@ static int __init fsl_udc_probe(struct platform_device 
*pdev)
INIT_LIST_HEAD(udc_controller-gadget.ep_list);
udc_controller-gadget.speed = USB_SPEED_UNKNOWN;
udc_controller-gadget.name = driver_name;
+   udc-vbus_active = true;
 
/* Setup gadget.dev and register with kernel */
dev_set_name(udc_controller-gadget.dev, gadget);
-- 
1.7.2.5

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


[PATCH 3/7] usb: gadget: fsl_udc: convert to new ulc style

2012-10-19 Thread Christoph Fritz
Convert to new UDC style registration and remove
global 'udc_controller' pointer.

Signed-off-by: Christoph Fritz chf.fr...@googlemail.com
---
 drivers/usb/gadget/fsl_udc_core.c |  289 +
 1 files changed, 131 insertions(+), 158 deletions(-)

diff --git a/drivers/usb/gadget/fsl_udc_core.c 
b/drivers/usb/gadget/fsl_udc_core.c
index 0a0d6a6..d113f39 100644
--- a/drivers/usb/gadget/fsl_udc_core.c
+++ b/drivers/usb/gadget/fsl_udc_core.c
@@ -63,9 +63,6 @@ static struct usb_dr_device *dr_regs;
 
 static struct usb_sys_interface *usb_sys_regs;
 
-/* it is initialized in probe()  */
-static struct fsl_udc *udc_controller = NULL;
-
 static const struct usb_endpoint_descriptor
 fsl_ep0_desc = {
.bLength =  USB_DT_ENDPOINT_SIZE,
@@ -783,12 +780,14 @@ static void fsl_queue_td(struct fsl_ep *ep, struct 
fsl_req *req)
 }
 
 /* Fill in the dTD structure
+ * @udc: driver private data
  * @req: request that the transfer belongs to
  * @length: return actually data length of the dTD
  * @dma: return dma address of the dTD
  * @is_last: return flag if it is the last dTD of the request
  * return: pointer to the built dTD */
-static struct ep_td_struct *fsl_build_dtd(struct fsl_req *req, unsigned 
*length,
+static struct ep_td_struct *fsl_build_dtd(struct fsl_udc *udc,
+   struct fsl_req *req, unsigned *length,
dma_addr_t *dma, int *is_last, gfp_t gfp_flags)
 {
u32 swap_temp;
@@ -798,7 +797,7 @@ static struct ep_td_struct *fsl_build_dtd(struct fsl_req 
*req, unsigned *length,
*length = min(req-req.length - req-req.actual,
(unsigned)EP_MAX_LENGTH_TRANSFER);
 
-   dtd = dma_pool_alloc(udc_controller-td_pool, gfp_flags, dma);
+   dtd = dma_pool_alloc(udc-td_pool, gfp_flags, dma);
if (dtd == NULL)
return dtd;
 
@@ -848,7 +847,8 @@ static struct ep_td_struct *fsl_build_dtd(struct fsl_req 
*req, unsigned *length,
 }
 
 /* Generate dtd chain for a request */
-static int fsl_req_to_dtd(struct fsl_req *req, gfp_t gfp_flags)
+static int fsl_req_to_dtd(struct fsl_udc *udc, struct fsl_req *req,
+   gfp_t gfp_flags)
 {
unsignedcount;
int is_last;
@@ -857,7 +857,8 @@ static int fsl_req_to_dtd(struct fsl_req *req, gfp_t 
gfp_flags)
dma_addr_t dma;
 
do {
-   dtd = fsl_build_dtd(req, count, dma, is_last, gfp_flags);
+   dtd = fsl_build_dtd(udc, req, count, dma, is_last,
+   gfp_flags);
if (dtd == NULL)
return -ENOMEM;
 
@@ -932,7 +933,7 @@ fsl_ep_queue(struct usb_ep *_ep, struct usb_request *_req, 
gfp_t gfp_flags)
req-dtd_count = 0;
 
/* build dtds and push them to device queue */
-   if (!fsl_req_to_dtd(req, gfp_flags)) {
+   if (!fsl_req_to_dtd(udc, req, gfp_flags)) {
spin_lock_irqsave(udc-lock, flags);
fsl_queue_td(ep, req);
} else {
@@ -1258,9 +1259,10 @@ static int fsl_pullup(struct usb_gadget *gadget, int 
is_on)
return 0;
 }
 
-static int fsl_start(struct usb_gadget_driver *driver,
-   int (*bind)(struct usb_gadget *, struct usb_gadget_driver *));
-static int fsl_stop(struct usb_gadget_driver *driver);
+static int fsl_udc_start(struct usb_gadget *gadget,
+   struct usb_gadget_driver *driver);
+static int fsl_udc_stop(struct usb_gadget *gadget,
+   struct usb_gadget_driver *driver);
 /* defined in gadget.h */
 static struct usb_gadget_ops fsl_gadget_ops = {
.get_frame = fsl_get_frame,
@@ -1269,8 +1271,8 @@ static struct usb_gadget_ops fsl_gadget_ops = {
.vbus_session = fsl_vbus_session,
.vbus_draw = fsl_vbus_draw,
.pullup = fsl_pullup,
-   .start = fsl_start,
-   .stop = fsl_stop,
+   .udc_start = fsl_udc_start,
+   .udc_stop = fsl_udc_stop,
 };
 
 /* Set protocol stall on ep0, protocol stall will automatically be cleared
@@ -1314,7 +1316,7 @@ static int ep0_prime_status(struct fsl_udc *udc, int 
direction)
ep_is_in(ep) ? DMA_TO_DEVICE : DMA_FROM_DEVICE);
req-mapped = 1;
 
-   if (fsl_req_to_dtd(req, GFP_ATOMIC) == 0)
+   if (fsl_req_to_dtd(udc, req, GFP_ATOMIC) == 0)
fsl_queue_td(ep, req);
else
return -ENOMEM;
@@ -1398,7 +1400,7 @@ static void ch9getstatus(struct fsl_udc *udc, u8 
request_type, u16 value,
req-mapped = 1;
 
/* prime the data phase */
-   if ((fsl_req_to_dtd(req, GFP_ATOMIC) == 0))
+   if ((fsl_req_to_dtd(udc, req, GFP_ATOMIC) == 0))
fsl_queue_td(ep, req);
else/* no mem */
goto stall;
@@ -1422,7 +1424,7 @@ static void setup_received_irq(struct fsl_udc *udc,
 
udc_reset_ep_queue(udc, 0);
 
-   /* We process some stardard setup requests here */
+   /* We process some standard setup 

[PATCH 4/7] usb: gadget: fsl_udc: drop ARCH dependency

2012-10-19 Thread Christoph Fritz
Drop the big-/little-endian helpers and make use of generic
writel()/readl() routines.

Signed-off-by: Christoph Fritz chf.fr...@googlemail.com
---
 drivers/usb/gadget/fsl_udc_core.c |  331 +
 1 files changed, 118 insertions(+), 213 deletions(-)

diff --git a/drivers/usb/gadget/fsl_udc_core.c 
b/drivers/usb/gadget/fsl_udc_core.c
index d113f39..53df9c0 100644
--- a/drivers/usb/gadget/fsl_udc_core.c
+++ b/drivers/usb/gadget/fsl_udc_core.c
@@ -20,32 +20,14 @@
 #undef VERBOSE
 
 #include linux/module.h
-#include linux/kernel.h
-#include linux/ioport.h
-#include linux/types.h
-#include linux/errno.h
-#include linux/err.h
-#include linux/slab.h
-#include linux/init.h
-#include linux/list.h
 #include linux/interrupt.h
 #include linux/proc_fs.h
-#include linux/mm.h
-#include linux/moduleparam.h
-#include linux/device.h
-#include linux/usb/ch9.h
 #include linux/usb/gadget.h
 #include linux/usb/otg.h
 #include linux/dma-mapping.h
 #include linux/platform_device.h
 #include linux/fsl_devices.h
 #include linux/dmapool.h
-#include linux/delay.h
-
-#include asm/byteorder.h
-#include asm/io.h
-#include asm/unaligned.h
-#include asm/dma.h
 
 #include fsl_usb2_udc.h
 
@@ -74,78 +56,6 @@ fsl_ep0_desc = {
 
 static void fsl_ep_fifo_flush(struct usb_ep *_ep);
 
-#ifdef CONFIG_PPC32
-/*
- * On some SoCs, the USB controller registers can be big or little endian,
- * depending on the version of the chip. In order to be able to run the
- * same kernel binary on 2 different versions of an SoC, the BE/LE decision
- * must be made at run time. _fsl_readl and fsl_writel are pointers to the
- * BE or LE readl() and writel() functions, and fsl_readl() and fsl_writel()
- * call through those pointers. Platform code for SoCs that have BE USB
- * registers should set pdata-big_endian_mmio flag.
- *
- * This also applies to controller-to-cpu accessors for the USB descriptors,
- * since their endianness is also SoC dependant. Platform code for SoCs that
- * have BE USB descriptors should set pdata-big_endian_desc flag.
- */
-static u32 _fsl_readl_be(const unsigned __iomem *p)
-{
-   return in_be32(p);
-}
-
-static u32 _fsl_readl_le(const unsigned __iomem *p)
-{
-   return in_le32(p);
-}
-
-static void _fsl_writel_be(u32 v, unsigned __iomem *p)
-{
-   out_be32(p, v);
-}
-
-static void _fsl_writel_le(u32 v, unsigned __iomem *p)
-{
-   out_le32(p, v);
-}
-
-static u32 (*_fsl_readl)(const unsigned __iomem *p);
-static void (*_fsl_writel)(u32 v, unsigned __iomem *p);
-
-#define fsl_readl(p)   (*_fsl_readl)((p))
-#define fsl_writel(v, p)   (*_fsl_writel)((v), (p))
-
-static inline void fsl_set_accessors(struct fsl_usb2_platform_data *pdata)
-{
-   if (pdata-big_endian_mmio) {
-   _fsl_readl = _fsl_readl_be;
-   _fsl_writel = _fsl_writel_be;
-   } else {
-   _fsl_readl = _fsl_readl_le;
-   _fsl_writel = _fsl_writel_le;
-   }
-}
-
-static inline u32 cpu_to_hc32(const u32 x)
-{
-   return udc_controller-pdata-big_endian_desc
-   ? (__force u32)cpu_to_be32(x)
-   : (__force u32)cpu_to_le32(x);
-}
-
-static inline u32 hc32_to_cpu(const u32 x)
-{
-   return udc_controller-pdata-big_endian_desc
-   ? be32_to_cpu((__force __be32)x)
-   : le32_to_cpu((__force __le32)x);
-}
-#else /* !CONFIG_PPC32 */
-static inline void fsl_set_accessors(struct fsl_usb2_platform_data *pdata) {}
-
-#define fsl_readl(addr)readl(addr)
-#define fsl_writel(val32, addr) writel(val32, addr)
-#define cpu_to_hc32(x) cpu_to_le32(x)
-#define hc32_to_cpu(x) le32_to_cpu(x)
-#endif /* CONFIG_PPC32 */
 
 /
  * Internal Used Function
@@ -248,7 +158,7 @@ static int dr_controller_setup(struct fsl_udc *udc)
 #define FSL_UDC_RESET_TIMEOUT 1000
 
/* Config PHY interface */
-   portctrl = fsl_readl(dr_regs-portsc1);
+   portctrl = readl(dr_regs-portsc1);
portctrl = ~(PORTSCX_PHY_TYPE_SEL | PORTSCX_PORT_WIDTH);
switch (udc-phy_mode) {
case FSL_USB2_PHY_ULPI:
@@ -286,20 +196,20 @@ static int dr_controller_setup(struct fsl_udc *udc)
default:
return -EINVAL;
}
-   fsl_writel(portctrl, dr_regs-portsc1);
+   writel(portctrl, dr_regs-portsc1);
 
/* Stop and reset the usb controller */
-   tmp = fsl_readl(dr_regs-usbcmd);
+   tmp = readl(dr_regs-usbcmd);
tmp = ~USB_CMD_RUN_STOP;
-   fsl_writel(tmp, dr_regs-usbcmd);
+   writel(tmp, dr_regs-usbcmd);
 
-   tmp = fsl_readl(dr_regs-usbcmd);
+   tmp = readl(dr_regs-usbcmd);
tmp |= USB_CMD_CTRL_RESET;
-   fsl_writel(tmp, dr_regs-usbcmd);
+   writel(tmp, dr_regs-usbcmd);
 
/* Wait for reset to complete */
timeout = jiffies + FSL_UDC_RESET_TIMEOUT;
-   while (fsl_readl(dr_regs-usbcmd)  USB_CMD_CTRL_RESET) {
+   while 

[PATCH 5/7] usb: gadget: fsl_udc: postpone freeing current dTD

2012-10-19 Thread Christoph Fritz
USB controller may access a wrong address for the dTD (endpoint transfer
descriptor) and then hang. This happens a lot when doing tests with
g_ether module and iperf, a tool for measuring maximum TCP and UDP
bandwidth.

This hardware bug is explained in detail by errata number 2858 for i.MX23:
http://cache.freescale.com/files/dsp/doc/errata/IMX23CE.pdf

All (?) SOCs with an IP from chipidea suffer from this problem.
mv_udc_core fixes this bug by commit daec765.  There still may be
unfixed drivers.

Signed-off-by: Christoph Fritz chf.fr...@googlemail.com
Signed-off-by: Christian Hemp c.h...@phytec.de
Reviewed-by: Peter Chen peter.c...@freescale.com
---
 drivers/usb/gadget/fsl_udc_core.c |   12 +++-
 drivers/usb/gadget/fsl_usb2_udc.h |2 ++
 2 files changed, 13 insertions(+), 1 deletions(-)

diff --git a/drivers/usb/gadget/fsl_udc_core.c 
b/drivers/usb/gadget/fsl_udc_core.c
index 53df9c0..deaab62 100644
--- a/drivers/usb/gadget/fsl_udc_core.c
+++ b/drivers/usb/gadget/fsl_udc_core.c
@@ -88,8 +88,13 @@ static void done(struct fsl_ep *ep, struct fsl_req *req, int 
status)
curr_td = next_td;
if (j != req-dtd_count - 1) {
next_td = curr_td-next_td_virt;
+   dma_pool_free(udc-td_pool, curr_td, curr_td-td_dma);
+   } else {
+   if (udc-last_free_td != NULL)
+   dma_pool_free(udc-td_pool, udc-last_free_td,
+   udc-last_free_td-td_dma);
+   udc-last_free_td = curr_td;
}
-   dma_pool_free(udc-td_pool, curr_td, curr_td-td_dma);
}
 
if (req-mapped) {
@@ -2439,6 +2444,7 @@ static int __init fsl_udc_probe(struct platform_device 
*pdev)
udc-gadget.speed = USB_SPEED_UNKNOWN;
udc-gadget.name = driver_name;
udc-vbus_active = true;
+   udc-last_free_td = NULL;
 
/* Setup gadget.dev and register with kernel */
dev_set_name(udc-gadget.dev, gadget);
@@ -2533,6 +2539,10 @@ static int __exit fsl_udc_remove(struct platform_device 
*pdev)
kfree(udc-status_req);
kfree(udc-eps);
 
+   if (udc-last_free_td != NULL)
+   dma_pool_free(udc-td_pool, udc-last_free_td,
+   udc-last_free_td-td_dma);
+
dma_pool_destroy(udc-td_pool);
free_irq(udc-irq, udc);
iounmap(dr_regs);
diff --git a/drivers/usb/gadget/fsl_usb2_udc.h 
b/drivers/usb/gadget/fsl_usb2_udc.h
index f61a967..a0123ae 100644
--- a/drivers/usb/gadget/fsl_usb2_udc.h
+++ b/drivers/usb/gadget/fsl_usb2_udc.h
@@ -497,6 +497,8 @@ struct fsl_udc {
size_t ep_qh_size;  /* size after alignment adjustment*/
dma_addr_t ep_qh_dma;   /* dma address of QH */
 
+   struct ep_td_struct *last_free_td;
+
u32 max_pipes;  /* Device max pipes */
u32 bus_reset;  /* Device is bus resetting */
u32 resume_state;   /* USB state to resume */
-- 
1.7.2.5

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


[PATCH 6/7] usb: gadget: fsl_udc: purge global pointer usb_sys_regs

2012-10-19 Thread Christoph Fritz
Move global driver pointer usb_sys_regs to private struct fsl_udc.

Signed-off-by: Christoph Fritz chf.fr...@googlemail.com
Reviewed-by: Teresa Gamez t.ga...@phytec.de
---
 drivers/usb/gadget/fsl_udc_core.c |   26 --
 drivers/usb/gadget/fsl_usb2_udc.h |1 +
 2 files changed, 13 insertions(+), 14 deletions(-)

diff --git a/drivers/usb/gadget/fsl_udc_core.c 
b/drivers/usb/gadget/fsl_udc_core.c
index deaab62..35ebcd4 100644
--- a/drivers/usb/gadget/fsl_udc_core.c
+++ b/drivers/usb/gadget/fsl_udc_core.c
@@ -43,8 +43,6 @@ static const char driver_desc[] = DRIVER_DESC;
 
 static struct usb_dr_device *dr_regs;
 
-static struct usb_sys_interface *usb_sys_regs;
-
 static const struct usb_endpoint_descriptor
 fsl_ep0_desc = {
.bLength =  USB_DT_ENDPOINT_SIZE,
@@ -170,10 +168,10 @@ static int dr_controller_setup(struct fsl_udc *udc)
if (udc-pdata-have_sysif_regs) {
if (udc-pdata-controller_ver) {
/* controller version 1.6 or above */
-   ctrl = __raw_readl(usb_sys_regs-control);
+   ctrl = readl(udc-usb_sys_regs-control);
ctrl = ~USB_CTRL_UTMI_PHY_EN;
ctrl |= USB_CTRL_USB_EN;
-   __raw_writel(ctrl, usb_sys_regs-control);
+   writel(ctrl, udc-usb_sys_regs-control);
}
}
portctrl |= PORTSCX_PTS_ULPI;
@@ -185,10 +183,10 @@ static int dr_controller_setup(struct fsl_udc *udc)
if (udc-pdata-have_sysif_regs) {
if (udc-pdata-controller_ver) {
/* controller version 1.6 or above */
-   ctrl = __raw_readl(usb_sys_regs-control);
+   ctrl = readl(udc-usb_sys_regs-control);
ctrl |= (USB_CTRL_UTMI_PHY_EN |
USB_CTRL_USB_EN);
-   __raw_writel(ctrl, usb_sys_regs-control);
+   writel(ctrl, udc-usb_sys_regs-control);
mdelay(FSL_UTMI_PHY_DLY); /* Delay for UTMI
PHY CLK to become stable - 10ms*/
}
@@ -254,9 +252,9 @@ static int dr_controller_setup(struct fsl_udc *udc)
/* Config control enable i/o output, cpu endian register */
 #ifndef CONFIG_ARCH_MXC
if (udc-pdata-have_sysif_regs) {
-   ctrl = __raw_readl(usb_sys_regs-control);
+   ctrl = readl(udc-usb_sys_regs-control);
ctrl |= USB_CTRL_IOENB;
-   __raw_writel(ctrl, usb_sys_regs-control);
+   writel(ctrl, udc-usb_sys_regs-control);
}
 #endif
 
@@ -267,9 +265,9 @@ static int dr_controller_setup(struct fsl_udc *udc)
if (udc-pdata-have_sysif_regs) {
/* Setup Snooping for all the 4GB space */
tmp = SNOOP_SIZE_2GB;   /* starts from 0x0, size 2G */
-   __raw_writel(tmp, usb_sys_regs-snoop1);
+   writel(tmp, udc-usb_sys_regs-snoop1);
tmp |= 0x8000;  /* starts from 0x800, size 2G */
-   __raw_writel(tmp, usb_sys_regs-snoop2);
+   writel(tmp, udc-usb_sys_regs-snoop2);
}
 #endif
 
@@ -326,7 +324,7 @@ static void dr_controller_stop(struct fsl_udc *udc)
udc-stopped = 1;
 
/* disable IO output */
-/* usb_sys_regs-control = 0; */
+/* udc-usb_sys_regs-control = 0; */
 
/* set controller to Stop */
tmp = readl(dr_regs-usbcmd);
@@ -2130,12 +2128,12 @@ static int fsl_proc_read(char *page, char **start, 
off_t off, int count,
 
 #ifndef CONFIG_ARCH_MXC
if (udc-pdata-have_sysif_regs) {
-   tmp_reg = usb_sys_regs-snoop1;
+   tmp_reg = udc-usb_sys_regs-snoop1;
t = scnprintf(next, size, Snoop1 Reg : = [0x%x]\n\n, tmp_reg);
size -= t;
next += t;
 
-   tmp_reg = usb_sys_regs-control;
+   tmp_reg = udc-usb_sys_regs-control;
t = scnprintf(next, size, General Control Reg : = [0x%x]\n\n,
tmp_reg);
size -= t;
@@ -2388,7 +2386,7 @@ static int __init fsl_udc_probe(struct platform_device 
*pdev)
 
 #ifndef CONFIG_ARCH_MXC
if (pdata-have_sysif_regs)
-   usb_sys_regs = (void *)dr_regs + USB_DR_SYS_OFFSET;
+   udc-usb_sys_regs = (void *)dr_regs + USB_DR_SYS_OFFSET;
 #endif
 
/* Initialize USB clocks */
diff --git a/drivers/usb/gadget/fsl_usb2_udc.h 
b/drivers/usb/gadget/fsl_usb2_udc.h
index a0123ae..0d888f4 100644
--- a/drivers/usb/gadget/fsl_usb2_udc.h
+++ b/drivers/usb/gadget/fsl_usb2_udc.h
@@ -498,6 +498,7 @@ struct fsl_udc {
dma_addr_t ep_qh_dma;   /* dma 

[PATCH 7/7] usb: gadget: fsl_udc: purge global pointer dr_regs

2012-10-19 Thread Christoph Fritz
Move global driver pointer dr_regs to private struct fsl_udc.

Signed-off-by: Christoph Fritz chf.fr...@googlemail.com
---
 drivers/usb/gadget/fsl_udc_core.c |  252 +++--
 drivers/usb/gadget/fsl_usb2_udc.h |1 +
 2 files changed, 130 insertions(+), 123 deletions(-)

diff --git a/drivers/usb/gadget/fsl_udc_core.c 
b/drivers/usb/gadget/fsl_udc_core.c
index 35ebcd4..f9c4eb9 100644
--- a/drivers/usb/gadget/fsl_udc_core.c
+++ b/drivers/usb/gadget/fsl_udc_core.c
@@ -41,8 +41,6 @@
 static const char driver_name[] = DRIVER_NAME;
 static const char driver_desc[] = DRIVER_DESC;
 
-static struct usb_dr_device *dr_regs;
-
 static const struct usb_endpoint_descriptor
 fsl_ep0_desc = {
.bLength =  USB_DT_ENDPOINT_SIZE,
@@ -161,7 +159,7 @@ static int dr_controller_setup(struct fsl_udc *udc)
 #define FSL_UDC_RESET_TIMEOUT 1000
 
/* Config PHY interface */
-   portctrl = readl(dr_regs-portsc1);
+   portctrl = readl(udc-dr_regs-portsc1);
portctrl = ~(PORTSCX_PHY_TYPE_SEL | PORTSCX_PORT_WIDTH);
switch (udc-phy_mode) {
case FSL_USB2_PHY_ULPI:
@@ -199,20 +197,20 @@ static int dr_controller_setup(struct fsl_udc *udc)
default:
return -EINVAL;
}
-   writel(portctrl, dr_regs-portsc1);
+   writel(portctrl, udc-dr_regs-portsc1);
 
/* Stop and reset the usb controller */
-   tmp = readl(dr_regs-usbcmd);
+   tmp = readl(udc-dr_regs-usbcmd);
tmp = ~USB_CMD_RUN_STOP;
-   writel(tmp, dr_regs-usbcmd);
+   writel(tmp, udc-dr_regs-usbcmd);
 
-   tmp = readl(dr_regs-usbcmd);
+   tmp = readl(udc-dr_regs-usbcmd);
tmp |= USB_CMD_CTRL_RESET;
-   writel(tmp, dr_regs-usbcmd);
+   writel(tmp, udc-dr_regs-usbcmd);
 
/* Wait for reset to complete */
timeout = jiffies + FSL_UDC_RESET_TIMEOUT;
-   while (readl(dr_regs-usbcmd)  USB_CMD_CTRL_RESET) {
+   while (readl(udc-dr_regs-usbcmd)  USB_CMD_CTRL_RESET) {
if (time_after(jiffies, timeout)) {
ERR(udc reset timeout!\n);
return -ETIMEDOUT;
@@ -221,33 +219,33 @@ static int dr_controller_setup(struct fsl_udc *udc)
}
 
/* Set the controller as device mode */
-   tmp = readl(dr_regs-usbmode);
+   tmp = readl(udc-dr_regs-usbmode);
tmp = ~USB_MODE_CTRL_MODE_MASK;/* clear mode bits */
tmp |= USB_MODE_CTRL_MODE_DEVICE;
/* Disable Setup Lockout */
tmp |= USB_MODE_SETUP_LOCK_OFF;
if (udc-pdata-es)
tmp |= USB_MODE_ES;
-   writel(tmp, dr_regs-usbmode);
+   writel(tmp, udc-dr_regs-usbmode);
 
/* Clear the setup status */
-   writel(0, dr_regs-usbsts);
+   writel(0, udc-dr_regs-usbsts);
 
tmp = udc-ep_qh_dma;
tmp = USB_EP_LIST_ADDRESS_MASK;
-   writel(tmp, dr_regs-endpointlistaddr);
+   writel(tmp, udc-dr_regs-endpointlistaddr);
 
VDBG(vir[qh_base] is %p phy[qh_base] is 0x%8x reg is 0x%8x,
udc-ep_qh, (int)tmp,
-   readl(dr_regs-endpointlistaddr));
+   readl(udc-dr_regs-endpointlistaddr));
 
-   max_no_of_ep = (0x001F  readl(dr_regs-dccparams));
+   max_no_of_ep = (0x001F  readl(udc-dr_regs-dccparams));
for (ep_num = 1; ep_num  max_no_of_ep; ep_num++) {
-   tmp = readl(dr_regs-endptctrl[ep_num]);
+   tmp = readl(udc-dr_regs-endptctrl[ep_num]);
tmp = ~(EPCTRL_TX_TYPE | EPCTRL_RX_TYPE);
tmp |= (EPCTRL_EP_TYPE_BULK  EPCTRL_TX_EP_TYPE_SHIFT)
| (EPCTRL_EP_TYPE_BULK  EPCTRL_RX_EP_TYPE_SHIFT);
-   writel(tmp, dr_regs-endptctrl[ep_num]);
+   writel(tmp, udc-dr_regs-endptctrl[ep_num]);
}
/* Config control enable i/o output, cpu endian register */
 #ifndef CONFIG_ARCH_MXC
@@ -284,20 +282,20 @@ static void dr_controller_run(struct fsl_udc *udc)
| USB_INTR_PTC_DETECT_EN | USB_INTR_RESET_EN
| USB_INTR_DEVICE_SUSPEND | USB_INTR_SYS_ERR_EN;
 
-   writel(temp, dr_regs-usbintr);
+   writel(temp, udc-dr_regs-usbintr);
 
/* Clear stopped bit */
udc-stopped = 0;
 
/* Set the controller as device mode */
-   temp = readl(dr_regs-usbmode);
+   temp = readl(udc-dr_regs-usbmode);
temp |= USB_MODE_CTRL_MODE_DEVICE;
-   writel(temp, dr_regs-usbmode);
+   writel(temp, udc-dr_regs-usbmode);
 
/* Set controller to Run */
-   temp = readl(dr_regs-usbcmd);
+   temp = readl(udc-dr_regs-usbcmd);
temp |= USB_CMD_RUN_STOP;
-   writel(temp, dr_regs-usbcmd);
+   writel(temp, udc-dr_regs-usbcmd);
 }
 
 static void dr_controller_stop(struct fsl_udc *udc)
@@ -311,14 +309,14 @@ static void dr_controller_stop(struct fsl_udc *udc)
 * ehci driver
 */
if (udc-gadget.is_otg) {
-   if (!(readl(dr_regs-otgsc)  

Re: [PATCH 1/7] usb: gadget: fsl_udc: simplify driver init

2012-10-19 Thread Felipe Balbi
Hi,

On Fri, Oct 19, 2012 at 12:24:39PM +0200, Christoph Fritz wrote:
 To initialize this driver use 'module_platform_driver' instead
 of '__init' and '__exit'.
 
 Signed-off-by: Christoph Fritz chf.fr...@googlemail.com
 ---
  drivers/usb/gadget/fsl_udc_core.c |   37 
 +++--
  1 files changed, 11 insertions(+), 26 deletions(-)
 
 diff --git a/drivers/usb/gadget/fsl_udc_core.c 
 b/drivers/usb/gadget/fsl_udc_core.c
 index 6ae70cb..340451d 100644
 --- a/drivers/usb/gadget/fsl_udc_core.c
 +++ b/drivers/usb/gadget/fsl_udc_core.c
 @@ -49,13 +49,14 @@
  
  #include fsl_usb2_udc.h
  
 +#define  DRIVER_NAME fsl-usb2-udc
  #define  DRIVER_DESC Freescale High-Speed USB SOC Device Controller 
 driver
  #define  DRIVER_AUTHOR   Li Yang/Jiang Bo
  #define  DRIVER_VERSION  Apr 20, 2007
  
  #define  DMA_ADDR_INVALID(~(dma_addr_t)0)
  
 -static const char driver_name[] = fsl-usb2-udc;
 +static const char driver_name[] = DRIVER_NAME;
  static const char driver_desc[] = DRIVER_DESC;
  
  static struct usb_dr_device *dr_regs;
 @@ -2761,35 +2762,19 @@ static int fsl_udc_otg_resume(struct device *dev)
   Register entry point for the peripheral controller driver
  --*/
  
 -static struct platform_driver udc_driver = {
 - .remove  = __exit_p(fsl_udc_remove),
 - /* these suspend and resume are not usb suspend and resume */
 - .suspend = fsl_udc_suspend,
 - .resume  = fsl_udc_resume,
 - .driver  = {
 - .name = (char *)driver_name,
 - .owner = THIS_MODULE,
 - /* udc suspend/resume called from OTG driver */
 +static struct platform_driver fsl_udc_driver = {
 + .probe  = fsl_udc_probe,

NAK, probe() lies in .init.text section. You need to change __init to
__devinit. Likewise for all functions which are only called during
probe() and for remove() which needs s/__exit/__devexit.

-- 
balbi


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

Re: [PATCH 2/7] usb: gadget: fsl_udc: protect fsl_pullup() with spin_lock

2012-10-19 Thread Felipe Balbi
Hi,

On Fri, Oct 19, 2012 at 12:24:40PM +0200, Christoph Fritz wrote:
 This patch reworks fsl_pullup() against the background of switching over
 to udc_start()/udc_stop() style:
 
 Protect function fsl_pullup() with a spin_lock. Also set vbus_active as
 default to true. This prevents disabling USB controller if there is no

the vbus_active part should be in a separate patch as it has no relation
with $SUBJECT

 driver support for an external transceiver (or GPIO) that detects a VBUS
 power session starting.
 
 Signed-off-by: Christoph Fritz chf.fr...@googlemail.com
 ---
  drivers/usb/gadget/fsl_udc_core.c |4 
  1 files changed, 4 insertions(+), 0 deletions(-)
 
 diff --git a/drivers/usb/gadget/fsl_udc_core.c 
 b/drivers/usb/gadget/fsl_udc_core.c
 index 340451d..0a0d6a6 100644
 --- a/drivers/usb/gadget/fsl_udc_core.c
 +++ b/drivers/usb/gadget/fsl_udc_core.c
 @@ -1242,8 +1242,10 @@ static int fsl_vbus_draw(struct usb_gadget *gadget, 
 unsigned mA)
  static int fsl_pullup(struct usb_gadget *gadget, int is_on)
  {
   struct fsl_udc *udc;
 + unsigned long flags;
  
   udc = container_of(gadget, struct fsl_udc, gadget);
 + spin_lock_irqsave(udc-lock, flags);
   udc-softconnect = (is_on != 0);
   if (can_pullup(udc))
   fsl_writel((fsl_readl(dr_regs-usbcmd) | USB_CMD_RUN_STOP),
 @@ -1251,6 +1253,7 @@ static int fsl_pullup(struct usb_gadget *gadget, int 
 is_on)
   else
   fsl_writel((fsl_readl(dr_regs-usbcmd)  ~USB_CMD_RUN_STOP),
   dr_regs-usbcmd);
 + spin_unlock_irqrestore(udc-lock, flags);
  
   return 0;
  }
 @@ -2557,6 +2560,7 @@ static int __init fsl_udc_probe(struct platform_device 
 *pdev)
   INIT_LIST_HEAD(udc_controller-gadget.ep_list);
   udc_controller-gadget.speed = USB_SPEED_UNKNOWN;
   udc_controller-gadget.name = driver_name;
 + udc-vbus_active = true;
  
   /* Setup gadget.dev and register with kernel */
   dev_set_name(udc_controller-gadget.dev, gadget);
 -- 
 1.7.2.5
 

-- 
balbi


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

Re: [PATCH 3/7] usb: gadget: fsl_udc: convert to new ulc style

2012-10-19 Thread Felipe Balbi
Hi,

typo on Subject. Should be udc, not ulc.

On Fri, Oct 19, 2012 at 12:24:41PM +0200, Christoph Fritz wrote:
 Convert to new UDC style registration and remove
 global 'udc_controller' pointer.
 
 Signed-off-by: Christoph Fritz chf.fr...@googlemail.com
 ---
  drivers/usb/gadget/fsl_udc_core.c |  289 
 +
  1 files changed, 131 insertions(+), 158 deletions(-)
 
 diff --git a/drivers/usb/gadget/fsl_udc_core.c 
 b/drivers/usb/gadget/fsl_udc_core.c
 index 0a0d6a6..d113f39 100644
 --- a/drivers/usb/gadget/fsl_udc_core.c
 +++ b/drivers/usb/gadget/fsl_udc_core.c
 @@ -63,9 +63,6 @@ static struct usb_dr_device *dr_regs;
  
  static struct usb_sys_interface *usb_sys_regs;
  
 -/* it is initialized in probe()  */
 -static struct fsl_udc *udc_controller = NULL;
 -
  static const struct usb_endpoint_descriptor
  fsl_ep0_desc = {
   .bLength =  USB_DT_ENDPOINT_SIZE,
 @@ -783,12 +780,14 @@ static void fsl_queue_td(struct fsl_ep *ep, struct 
 fsl_req *req)
  }
  
  /* Fill in the dTD structure
 + * @udc: driver private data
   * @req: request that the transfer belongs to
   * @length: return actually data length of the dTD
   * @dma: return dma address of the dTD
   * @is_last: return flag if it is the last dTD of the request
   * return: pointer to the built dTD */
 -static struct ep_td_struct *fsl_build_dtd(struct fsl_req *req, unsigned 
 *length,
 +static struct ep_td_struct *fsl_build_dtd(struct fsl_udc *udc,
 + struct fsl_req *req, unsigned *length,
   dma_addr_t *dma, int *is_last, gfp_t gfp_flags)

I would split this patch a little. First I would patch the missing
arguments to these functions under the excuse that a later patch will
get rid of the udc_controller pointer, then the next patch would do the
conversion to new style.

It will be a lot easier to review ;-)

  {
   u32 swap_temp;
 @@ -798,7 +797,7 @@ static struct ep_td_struct *fsl_build_dtd(struct fsl_req 
 *req, unsigned *length,
   *length = min(req-req.length - req-req.actual,
   (unsigned)EP_MAX_LENGTH_TRANSFER);
  
 - dtd = dma_pool_alloc(udc_controller-td_pool, gfp_flags, dma);
 + dtd = dma_pool_alloc(udc-td_pool, gfp_flags, dma);
   if (dtd == NULL)
   return dtd;
  
 @@ -848,7 +847,8 @@ static struct ep_td_struct *fsl_build_dtd(struct fsl_req 
 *req, unsigned *length,
  }
  
  /* Generate dtd chain for a request */
 -static int fsl_req_to_dtd(struct fsl_req *req, gfp_t gfp_flags)
 +static int fsl_req_to_dtd(struct fsl_udc *udc, struct fsl_req *req,
 + gfp_t gfp_flags)
  {
   unsignedcount;
   int is_last;
 @@ -857,7 +857,8 @@ static int fsl_req_to_dtd(struct fsl_req *req, gfp_t 
 gfp_flags)
   dma_addr_t dma;
  
   do {
 - dtd = fsl_build_dtd(req, count, dma, is_last, gfp_flags);
 + dtd = fsl_build_dtd(udc, req, count, dma, is_last,
 + gfp_flags);
   if (dtd == NULL)
   return -ENOMEM;
  
 @@ -932,7 +933,7 @@ fsl_ep_queue(struct usb_ep *_ep, struct usb_request 
 *_req, gfp_t gfp_flags)
   req-dtd_count = 0;
  
   /* build dtds and push them to device queue */
 - if (!fsl_req_to_dtd(req, gfp_flags)) {
 + if (!fsl_req_to_dtd(udc, req, gfp_flags)) {
   spin_lock_irqsave(udc-lock, flags);
   fsl_queue_td(ep, req);
   } else {
 @@ -1258,9 +1259,10 @@ static int fsl_pullup(struct usb_gadget *gadget, int 
 is_on)
   return 0;
  }
  
 -static int fsl_start(struct usb_gadget_driver *driver,
 - int (*bind)(struct usb_gadget *, struct usb_gadget_driver *));
 -static int fsl_stop(struct usb_gadget_driver *driver);
 +static int fsl_udc_start(struct usb_gadget *gadget,
 + struct usb_gadget_driver *driver);
 +static int fsl_udc_stop(struct usb_gadget *gadget,
 + struct usb_gadget_driver *driver);
  /* defined in gadget.h */
  static struct usb_gadget_ops fsl_gadget_ops = {
   .get_frame = fsl_get_frame,
 @@ -1269,8 +1271,8 @@ static struct usb_gadget_ops fsl_gadget_ops = {
   .vbus_session = fsl_vbus_session,
   .vbus_draw = fsl_vbus_draw,
   .pullup = fsl_pullup,
 - .start = fsl_start,
 - .stop = fsl_stop,
 + .udc_start = fsl_udc_start,
 + .udc_stop = fsl_udc_stop,
  };
  
  /* Set protocol stall on ep0, protocol stall will automatically be cleared
 @@ -1314,7 +1316,7 @@ static int ep0_prime_status(struct fsl_udc *udc, int 
 direction)
   ep_is_in(ep) ? DMA_TO_DEVICE : DMA_FROM_DEVICE);
   req-mapped = 1;
  
 - if (fsl_req_to_dtd(req, GFP_ATOMIC) == 0)
 + if (fsl_req_to_dtd(udc, req, GFP_ATOMIC) == 0)
   fsl_queue_td(ep, req);
   else
   return -ENOMEM;
 @@ -1398,7 +1400,7 @@ static void ch9getstatus(struct fsl_udc *udc, u8 
 request_type, u16 value,
   req-mapped = 1;
  
   /* prime the data phase */
 - if 

Re: [PATCH 4/7] usb: gadget: fsl_udc: drop ARCH dependency

2012-10-19 Thread Felipe Balbi
On Fri, Oct 19, 2012 at 12:24:42PM +0200, Christoph Fritz wrote:
 Drop the big-/little-endian helpers and make use of generic
 writel()/readl() routines.
 
 Signed-off-by: Christoph Fritz chf.fr...@googlemail.com
 ---
  drivers/usb/gadget/fsl_udc_core.c |  331 
 +
  1 files changed, 118 insertions(+), 213 deletions(-)
 
 diff --git a/drivers/usb/gadget/fsl_udc_core.c 
 b/drivers/usb/gadget/fsl_udc_core.c
 index d113f39..53df9c0 100644
 --- a/drivers/usb/gadget/fsl_udc_core.c
 +++ b/drivers/usb/gadget/fsl_udc_core.c
 @@ -20,32 +20,14 @@
  #undef VERBOSE
  
  #include linux/module.h
 -#include linux/kernel.h
 -#include linux/ioport.h
 -#include linux/types.h
 -#include linux/errno.h
 -#include linux/err.h
 -#include linux/slab.h
 -#include linux/init.h
 -#include linux/list.h

you don't mention removal of these registers anywhere. Why are you
doing this ? Are those really unnecessary or are you now depending on
indirect inclusion of the headers ?

Also, $SUBJECT is a bit misleading since you don't touch Kconfig to
actually drop the ARCH dependency. Maybe rephrase $SUBJECT a little ?

  #include linux/interrupt.h
  #include linux/proc_fs.h
 -#include linux/mm.h
 -#include linux/moduleparam.h
 -#include linux/device.h
 -#include linux/usb/ch9.h
  #include linux/usb/gadget.h
  #include linux/usb/otg.h
  #include linux/dma-mapping.h
  #include linux/platform_device.h
  #include linux/fsl_devices.h
  #include linux/dmapool.h
 -#include linux/delay.h
 -
 -#include asm/byteorder.h
 -#include asm/io.h
 -#include asm/unaligned.h
 -#include asm/dma.h
  
  #include fsl_usb2_udc.h
  
 @@ -74,78 +56,6 @@ fsl_ep0_desc = {
  
  static void fsl_ep_fifo_flush(struct usb_ep *_ep);
  
 -#ifdef CONFIG_PPC32
 -/*
 - * On some SoCs, the USB controller registers can be big or little endian,
 - * depending on the version of the chip. In order to be able to run the
 - * same kernel binary on 2 different versions of an SoC, the BE/LE decision
 - * must be made at run time. _fsl_readl and fsl_writel are pointers to the
 - * BE or LE readl() and writel() functions, and fsl_readl() and fsl_writel()
 - * call through those pointers. Platform code for SoCs that have BE USB
 - * registers should set pdata-big_endian_mmio flag.
 - *
 - * This also applies to controller-to-cpu accessors for the USB descriptors,
 - * since their endianness is also SoC dependant. Platform code for SoCs that
 - * have BE USB descriptors should set pdata-big_endian_desc flag.
 - */
 -static u32 _fsl_readl_be(const unsigned __iomem *p)
 -{
 - return in_be32(p);
 -}
 -
 -static u32 _fsl_readl_le(const unsigned __iomem *p)
 -{
 - return in_le32(p);
 -}
 -
 -static void _fsl_writel_be(u32 v, unsigned __iomem *p)
 -{
 - out_be32(p, v);
 -}
 -
 -static void _fsl_writel_le(u32 v, unsigned __iomem *p)
 -{
 - out_le32(p, v);
 -}
 -
 -static u32 (*_fsl_readl)(const unsigned __iomem *p);
 -static void (*_fsl_writel)(u32 v, unsigned __iomem *p);
 -
 -#define fsl_readl(p) (*_fsl_readl)((p))
 -#define fsl_writel(v, p) (*_fsl_writel)((v), (p))
 -
 -static inline void fsl_set_accessors(struct fsl_usb2_platform_data *pdata)
 -{
 - if (pdata-big_endian_mmio) {
 - _fsl_readl = _fsl_readl_be;
 - _fsl_writel = _fsl_writel_be;
 - } else {
 - _fsl_readl = _fsl_readl_le;
 - _fsl_writel = _fsl_writel_le;
 - }
 -}
 -
 -static inline u32 cpu_to_hc32(const u32 x)
 -{
 - return udc_controller-pdata-big_endian_desc
 - ? (__force u32)cpu_to_be32(x)
 - : (__force u32)cpu_to_le32(x);
 -}
 -
 -static inline u32 hc32_to_cpu(const u32 x)
 -{
 - return udc_controller-pdata-big_endian_desc
 - ? be32_to_cpu((__force __be32)x)
 - : le32_to_cpu((__force __le32)x);
 -}
 -#else /* !CONFIG_PPC32 */
 -static inline void fsl_set_accessors(struct fsl_usb2_platform_data *pdata) {}
 -
 -#define fsl_readl(addr)  readl(addr)
 -#define fsl_writel(val32, addr) writel(val32, addr)
 -#define cpu_to_hc32(x)   cpu_to_le32(x)
 -#define hc32_to_cpu(x)   le32_to_cpu(x)
 -#endif /* CONFIG_PPC32 */
  
  /
   *   Internal Used Function
 @@ -248,7 +158,7 @@ static int dr_controller_setup(struct fsl_udc *udc)
  #define FSL_UDC_RESET_TIMEOUT 1000
  
   /* Config PHY interface */
 - portctrl = fsl_readl(dr_regs-portsc1);
 + portctrl = readl(dr_regs-portsc1);
   portctrl = ~(PORTSCX_PHY_TYPE_SEL | PORTSCX_PORT_WIDTH);
   switch (udc-phy_mode) {
   case FSL_USB2_PHY_ULPI:
 @@ -286,20 +196,20 @@ static int dr_controller_setup(struct fsl_udc *udc)
   default:
   return -EINVAL;
   }
 - fsl_writel(portctrl, dr_regs-portsc1);
 + writel(portctrl, dr_regs-portsc1);
  
   /* Stop and reset the usb controller */
 - tmp = fsl_readl(dr_regs-usbcmd);
 + tmp = readl(dr_regs-usbcmd);
   tmp = 

Re: [PATCH 5/7] usb: gadget: fsl_udc: postpone freeing current dTD

2012-10-19 Thread Felipe Balbi
On Fri, Oct 19, 2012 at 12:24:43PM +0200, Christoph Fritz wrote:
 USB controller may access a wrong address for the dTD (endpoint transfer
 descriptor) and then hang. This happens a lot when doing tests with
 g_ether module and iperf, a tool for measuring maximum TCP and UDP
 bandwidth.
 
 This hardware bug is explained in detail by errata number 2858 for i.MX23:
 http://cache.freescale.com/files/dsp/doc/errata/IMX23CE.pdf
 
 All (?) SOCs with an IP from chipidea suffer from this problem.
 mv_udc_core fixes this bug by commit daec765.  There still may be
 unfixed drivers.

why aren't you using that driver instead ? Is it really necessary to
keep this driver around ? I would really like to see uniformization
towards that, if you use the same IP, then the same driver ought to
suffice.

What's the reason for not using drivers/usb/chipidea ?

-- 
balbi


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

Re: [PATCH 1/10] memory-hotplug : check whether memory is offline or not when removing memory

2012-10-19 Thread Wen Congyang
At 10/06/2012 03:27 AM, KOSAKI Motohiro Wrote:
 On Thu, Oct 4, 2012 at 10:25 PM, Yasuaki Ishimatsu
 isimatu.yasu...@jp.fujitsu.com wrote:
 When calling remove_memory(), the memory should be offline. If the function
 is used to online memory, kernel panic may occur.

 So the patch checks whether memory is offline or not.
 
 You don't explain WHY we need the check.

This patch is no necessary now, because the newest kernel has checked
it.

Thanks
Wen Congyang

 
 
 CC: David Rientjes rient...@google.com
 CC: Jiang Liu liu...@gmail.com
 CC: Len Brown len.br...@intel.com
 CC: Christoph Lameter c...@linux.com
 Cc: Minchan Kim minchan@gmail.com
 CC: Andrew Morton a...@linux-foundation.org
 CC: KOSAKI Motohiro kosaki.motoh...@jp.fujitsu.com
 Signed-off-by: Wen Congyang we...@cn.fujitsu.com
 Signed-off-by: Yasuaki Ishimatsu isimatu.yasu...@jp.fujitsu.com

 ---
  drivers/base/memory.c  |   39 +++
  include/linux/memory.h |5 +
  mm/memory_hotplug.c|   17 +++--
  3 files changed, 59 insertions(+), 2 deletions(-)

 Index: linux-3.6/drivers/base/memory.c
 ===
 --- linux-3.6.orig/drivers/base/memory.c2012-10-04 
 14:22:57.0 +0900
 +++ linux-3.6/drivers/base/memory.c 2012-10-04 14:45:46.653585860 +0900
 @@ -70,6 +70,45 @@ void unregister_memory_isolate_notifier(
  }
  EXPORT_SYMBOL(unregister_memory_isolate_notifier);

 +bool is_memblk_offline(unsigned long start, unsigned long size)
 
 Don't use memblk. Usually memblk mean struct numa_meminfo for x86/numa.
 Maybe memory_range_offlined() is better.
 
 And, this function don't take struct memory_block, then this file may be no 
 good
 place.
 
 And you need to write down function comment.
 
 
 +{
 +   struct memory_block *mem = NULL;
 +   struct mem_section *section;
 +   unsigned long start_pfn, end_pfn;
 +   unsigned long pfn, section_nr;
 +
 +   start_pfn = PFN_DOWN(start);
 +   end_pfn = PFN_UP(start + size);
 +
 +   for (pfn = start_pfn; pfn  end_pfn; pfn += PAGES_PER_SECTION) {
 +   section_nr = pfn_to_section_nr(pfn);
 +   if (!present_section_nr(section_nr))
 +   continue;
 +
 +   section = __nr_to_section(section_nr);
 +   /* same memblock? */
 +   if (mem)
 +   if ((section_nr = mem-start_section_nr) 
 +   (section_nr = mem-end_section_nr))
 +   continue;
 +
 +   mem = find_memory_block_hinted(section, mem);
 +   if (!mem)
 +   continue;
 +   if (mem-state == MEM_OFFLINE)
 +   continue;
 +
 +   kobject_put(mem-dev.kobj);
 +   return false;
 +   }
 +
 +   if (mem)
 +   kobject_put(mem-dev.kobj);
 +
 +   return true;
 +}
 +EXPORT_SYMBOL(is_memblk_offline);
 +
  /*
   * register_memory - Setup a sysfs device for a memory block
   */
 Index: linux-3.6/include/linux/memory.h
 ===
 --- linux-3.6.orig/include/linux/memory.h   2012-10-02 
 18:00:22.0 +0900
 +++ linux-3.6/include/linux/memory.h2012-10-04 14:44:40.902581028 +0900
 @@ -106,6 +106,10 @@ static inline int memory_isolate_notify(
  {
 return 0;
  }
 +static inline bool is_memblk_offline(unsigned long start, unsigned long 
 size)
 +{
 +   return false;
 +}
  #else
  extern int register_memory_notifier(struct notifier_block *nb);
  extern void unregister_memory_notifier(struct notifier_block *nb);
 @@ -120,6 +124,7 @@ extern int memory_isolate_notify(unsigne
  extern struct memory_block *find_memory_block_hinted(struct mem_section *,
 struct memory_block 
 *);
  extern struct memory_block *find_memory_block(struct mem_section *);
 +extern bool is_memblk_offline(unsigned long start, unsigned long size);
  #define CONFIG_MEM_BLOCK_SIZE  (PAGES_PER_SECTIONPAGE_SHIFT)
  enum mem_add_context { BOOT, HOTPLUG };
  #endif /* CONFIG_MEMORY_HOTPLUG_SPARSE */
 Index: linux-3.6/mm/memory_hotplug.c
 ===
 --- linux-3.6.orig/mm/memory_hotplug.c  2012-10-04 14:31:08.0 +0900
 +++ linux-3.6/mm/memory_hotplug.c   2012-10-04 14:58:22.449687986 +0900
 @@ -1045,8 +1045,21 @@ int offline_memory(u64 start, u64 size)

  int remove_memory(int nid, u64 start, u64 size)
  {
 
 Your remove_memory() don't remove anything. that's strange.
 
 
 -   /* It is not implemented yet*/
 -   return 0;
 +   int ret = 0;
 +   lock_memory_hotplug();
 +   /*
 +* The memory might become online by other task, even if you offine 
 it.
 +* So we check whether the memory has been onlined or not.
 +*/
 +   if (!is_memblk_offline(start, size)) {
 +

Re: [PATCH 5/7] usb: gadget: fsl_udc: postpone freeing current dTD

2012-10-19 Thread Christoph Fritz
On Fri, 2012-10-19 at 13:30 +0300, Felipe Balbi wrote:
 On Fri, Oct 19, 2012 at 12:24:43PM +0200, Christoph Fritz wrote:
  USB controller may access a wrong address for the dTD (endpoint transfer
  descriptor) and then hang. This happens a lot when doing tests with
  g_ether module and iperf, a tool for measuring maximum TCP and UDP
  bandwidth.
  
  This hardware bug is explained in detail by errata number 2858 for i.MX23:
  http://cache.freescale.com/files/dsp/doc/errata/IMX23CE.pdf
  
  All (?) SOCs with an IP from chipidea suffer from this problem.
  mv_udc_core fixes this bug by commit daec765.  There still may be
  unfixed drivers.
 
 why aren't you using that driver instead ? Is it really necessary to
 keep this driver around ? I would really like to see uniformization
 towards that, if you use the same IP, then the same driver ought to
 suffice.
 
 What's the reason for not using drivers/usb/chipidea ?
 

I thought about this too but wasn't able to use chipidea with
MXC_EHCI_INTERNAL_PHY as it's called in fsl_udc.

Sascha, do you know if i.mx35 works with usb/chipidea?

Thanks
 -- Christoph

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


Re: [PATCH 5/7] usb: gadget: fsl_udc: postpone freeing current dTD

2012-10-19 Thread Felipe Balbi
Hi,

On Fri, Oct 19, 2012 at 12:46:48PM +0200, Christoph Fritz wrote:
 On Fri, 2012-10-19 at 13:30 +0300, Felipe Balbi wrote:
  On Fri, Oct 19, 2012 at 12:24:43PM +0200, Christoph Fritz wrote:
   USB controller may access a wrong address for the dTD (endpoint transfer
   descriptor) and then hang. This happens a lot when doing tests with
   g_ether module and iperf, a tool for measuring maximum TCP and UDP
   bandwidth.
   
   This hardware bug is explained in detail by errata number 2858 for i.MX23:
   http://cache.freescale.com/files/dsp/doc/errata/IMX23CE.pdf
   
   All (?) SOCs with an IP from chipidea suffer from this problem.
   mv_udc_core fixes this bug by commit daec765.  There still may be
   unfixed drivers.
  
  why aren't you using that driver instead ? Is it really necessary to
  keep this driver around ? I would really like to see uniformization
  towards that, if you use the same IP, then the same driver ought to
  suffice.
  
  What's the reason for not using drivers/usb/chipidea ?
  
 
 I thought about this too but wasn't able to use chipidea with
 MXC_EHCI_INTERNAL_PHY as it's called in fsl_udc.

that's a matter of writing the PHY driver, right ;-) It has nothing to
do with chipidea, actually :-)

-- 
balbi


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

Re: [ath9k-devel] [PATCH net-next 00/21] treewide: Use consistent api style for address testing

2012-10-19 Thread Pavel Roskin
On Fri, 19 Oct 2012 09:04:14 +0200
Eric Dumazet eric.duma...@gmail.com wrote:

 Yes they are some names discrepancies, thats a big deal.
 
 And we have alloc_skb() / kfree_skb() / skb_clone() 
 
 Why not skb_alloc() / skb_free() / skb_clone() ?
 
 Some people actually know current code by name of functions, they dont
 want to change their mind and having to grep include files and git log
 to learn the new names of an old function, especially when traveling
 and using a laptop.

I agree.

Also, it makes sense to introduce a more consistent name for a function
when it's improved in some way and the callers need to be adjusted or
re-checked.

That way, the old name can be phased out as the code is made compatible
with the new function.

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


Re: [RFC][PATCH] perf: Add a few generic stalled-cycles events

2012-10-19 Thread Sukadev Bhattiprolu
Stephane Eranian [eran...@google.com] wrote:
| So all in all, I think this is not a very good idea. You have to put
| this into the tool or a library that auto-detects the
| host CPU and programs the right set of events.
| 
| We've had that discussion many times. Just reiterating my personal
| opinion on this.

Yes that would work too. One drawback is that the hardware events
will be in the tool, while the software/tracepoint events in the
kernel sysfs representation.

Or is that the reason we want all events in one place (sysfs) ?

Sukadev

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


Re: [PATCH 1/1] usb: gadget: Don't attempt to dequeue requests for a disabled USB endpoint on Freescale hardware

2012-10-19 Thread Felipe Balbi
Hi,

On Fri, Oct 19, 2012 at 06:19:26PM +0100, Simon Haggett wrote:
 Some gadget drivers may attempt to dequeue requests for an endpoint that has
 already been disabled. For example, in the UVC gadget driver, 
 uvc_function_set_alt()
 will call usb_ep_disable() when alt setting 0 is selected. When the userspace
 application subsequently issues the VIDIOC_STREAMOFF ioctl, uvc_video_enable()
 invokes usb_ep_dequeue() to ensure that all requests have been cancelled.

bug is on uvc gadget, then. Laurent ?

Also, fsl should be removed from the tree, I'm trying to persuade iMX
folks to use drivers/usb/chipidea instead.

 For the Freescale High Speed Dual-Role USB controller, fsl_ep_dequeue() 
 provides
 the implementation of usb_ep_dequeue(). If this is called for a disabled 
 endpoint,
 a kernel oops will occur when the ep-ep.desc field is dereferenced (by 
 ep_index()).
 fsl_ep_disable() sets this field to NULL, as well as deleting all pending 
 requests
 for the endpoint.
 
 This patch adds an additional check to fsl_ep_dequeue() to ensure that the
 endpoint has not already been disabled before attempting to dequeue requests.
 
 Signed-off-by: Simon Haggett simon.hagg...@realvnc.com
 ---
  drivers/usb/gadget/fsl_udc_core.c |5 -
  1 files changed, 4 insertions(+), 1 deletions(-)
 
 diff --git a/drivers/usb/gadget/fsl_udc_core.c 
 b/drivers/usb/gadget/fsl_udc_core.c
 index 6ae70cb..acd513b 100644
 --- a/drivers/usb/gadget/fsl_udc_core.c
 +++ b/drivers/usb/gadget/fsl_udc_core.c
 @@ -955,7 +955,10 @@ static int fsl_ep_dequeue(struct usb_ep *_ep, struct 
 usb_request *_req)
   int ep_num, stopped, ret = 0;
   u32 epctrl;
  
 - if (!_ep || !_req)
 + /* Ensure that the ep and request are valid, and the ep is not
 +  * disabled
 +  */
 + if (!_ep || !_req || !ep-ep.desc)
   return -EINVAL;
  
   spin_lock_irqsave(ep-udc-lock, flags);
 -- 
 1.7.4.1
 

-- 
balbi


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

Re: [PATCH 1/10] memory-hotplug : check whether memory is offline or not when removing memory

2012-10-19 Thread KOSAKI Motohiro
 I think it again, and found that this check is necessary. Because we only
 lock memory hotplug when offlining pages. Here is the steps to offline and
 remove memory:

 1. lock memory hotplug
 2. offline a memory section
 3. unlock memory hotplug
 4. repeat 1-3 to offline all memory sections
 5. lock memory hotplug
 6. remove memory
 7. unlock memory hotplug

 All memory sections must be offlined before removing memory. But we don't
 hold
 the lock in the whole operation. So we should check whether all memory
 sections
 are offlined before step6.

You should describe the race scenario in the patch description. OK?
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Re: [PATCH 1/10] memory-hotplug : check whether memory is offline or not when removing memory

2012-10-19 Thread Wen Congyang

At 2012/10/19 18:44, Wen Congyang Wrote:

At 10/06/2012 03:27 AM, KOSAKI Motohiro Wrote:

On Thu, Oct 4, 2012 at 10:25 PM, Yasuaki Ishimatsu
isimatu.yasu...@jp.fujitsu.com  wrote:

When calling remove_memory(), the memory should be offline. If the function
is used to online memory, kernel panic may occur.

So the patch checks whether memory is offline or not.


You don't explain WHY we need the check.


This patch is no necessary now, because the newest kernel has checked
it.


I think it again, and found that this check is necessary. Because we only
lock memory hotplug when offlining pages. Here is the steps to offline and
remove memory:

1. lock memory hotplug
2. offline a memory section
3. unlock memory hotplug
4. repeat 1-3 to offline all memory sections
5. lock memory hotplug
6. remove memory
7. unlock memory hotplug

All memory sections must be offlined before removing memory. But we 
don't hold
the lock in the whole operation. So we should check whether all memory 
sections

are offlined before step6.



Thanks
Wen Congyang





CC: David Rientjesrient...@google.com
CC: Jiang Liuliu...@gmail.com
CC: Len Brownlen.br...@intel.com
CC: Christoph Lameterc...@linux.com
Cc: Minchan Kimminchan@gmail.com
CC: Andrew Mortona...@linux-foundation.org
CC: KOSAKI Motohirokosaki.motoh...@jp.fujitsu.com
Signed-off-by: Wen Congyangwe...@cn.fujitsu.com
Signed-off-by: Yasuaki Ishimatsuisimatu.yasu...@jp.fujitsu.com

---
  drivers/base/memory.c  |   39 +++
  include/linux/memory.h |5 +
  mm/memory_hotplug.c|   17 +++--
  3 files changed, 59 insertions(+), 2 deletions(-)

Index: linux-3.6/drivers/base/memory.c
===
--- linux-3.6.orig/drivers/base/memory.c2012-10-04 14:22:57.0 
+0900
+++ linux-3.6/drivers/base/memory.c 2012-10-04 14:45:46.653585860 +0900
@@ -70,6 +70,45 @@ void unregister_memory_isolate_notifier(
  }
  EXPORT_SYMBOL(unregister_memory_isolate_notifier);

+bool is_memblk_offline(unsigned long start, unsigned long size)


Don't use memblk. Usually memblk mean struct numa_meminfo for x86/numa.
Maybe memory_range_offlined() is better.

And, this function don't take struct memory_block, then this file may be no good
place.

And you need to write down function comment.



+{
+   struct memory_block *mem = NULL;
+   struct mem_section *section;
+   unsigned long start_pfn, end_pfn;
+   unsigned long pfn, section_nr;
+
+   start_pfn = PFN_DOWN(start);
+   end_pfn = PFN_UP(start + size);
+
+   for (pfn = start_pfn; pfn  end_pfn; pfn += PAGES_PER_SECTION) {
+   section_nr = pfn_to_section_nr(pfn);
+   if (!present_section_nr(section_nr))
+   continue;
+
+   section = __nr_to_section(section_nr);
+   /* same memblock? */
+   if (mem)
+   if ((section_nr= mem-start_section_nr)
+   (section_nr= mem-end_section_nr))
+   continue;
+
+   mem = find_memory_block_hinted(section, mem);
+   if (!mem)
+   continue;
+   if (mem-state == MEM_OFFLINE)
+   continue;
+
+   kobject_put(mem-dev.kobj);
+   return false;
+   }
+
+   if (mem)
+   kobject_put(mem-dev.kobj);
+
+   return true;
+}
+EXPORT_SYMBOL(is_memblk_offline);
+
  /*
   * register_memory - Setup a sysfs device for a memory block
   */
Index: linux-3.6/include/linux/memory.h
===
--- linux-3.6.orig/include/linux/memory.h   2012-10-02 18:00:22.0 
+0900
+++ linux-3.6/include/linux/memory.h2012-10-04 14:44:40.902581028 +0900
@@ -106,6 +106,10 @@ static inline int memory_isolate_notify(
  {
 return 0;
  }
+static inline bool is_memblk_offline(unsigned long start, unsigned long size)
+{
+   return false;
+}
  #else
  extern int register_memory_notifier(struct notifier_block *nb);
  extern void unregister_memory_notifier(struct notifier_block *nb);
@@ -120,6 +124,7 @@ extern int memory_isolate_notify(unsigne
  extern struct memory_block *find_memory_block_hinted(struct mem_section *,
 struct memory_block *);
  extern struct memory_block *find_memory_block(struct mem_section *);
+extern bool is_memblk_offline(unsigned long start, unsigned long size);
  #define CONFIG_MEM_BLOCK_SIZE  (PAGES_PER_SECTIONPAGE_SHIFT)
  enum mem_add_context { BOOT, HOTPLUG };
  #endif /* CONFIG_MEMORY_HOTPLUG_SPARSE */
Index: linux-3.6/mm/memory_hotplug.c
===
--- linux-3.6.orig/mm/memory_hotplug.c  2012-10-04 14:31:08.0 +0900
+++ linux-3.6/mm/memory_hotplug.c   2012-10-04 14:58:22.449687986 +0900
@@ -1045,8 +1045,21 @@ int 

Re: [PATCH 0/7] update USB gadget driver fsl-usb2-udc

2012-10-19 Thread Sascha Hauer
Hi Christoph,

What system are you working on? If it's i.MX you should use/work on the
chipidea driver instead.

Sascha

On Fri, Oct 19, 2012 at 12:22:36PM +0200, Christoph Fritz wrote:
 This series updates USB gadget driver fsl-usb2-udc.
 
 Christoph Fritz (7):
   usb: gadget: fsl_udc: simplify driver init
   usb: gadget: fsl_udc: protect fsl_pullup() with spin_lock
   usb: gadget: fsl_udc: convert to new ulc style
   usb: gadget: fsl_udc: drop ARCH dependency
   usb: gadget: fsl_udc: postpone freeing current dTD
   usb: gadget: fsl_udc: purge global pointer usb_sys_regs
   usb: gadget: fsl_udc: purge global pointer dr_regs
 
  drivers/usb/gadget/fsl_udc_core.c |  755 
 -
  drivers/usb/gadget/fsl_usb2_udc.h |4 +
  2 files changed, 322 insertions(+), 437 deletions(-)
 
 -- 
 1.7.2.5
 
 

-- 
Pengutronix e.K.   | |
Industrial Linux Solutions | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0|
Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


[PATCH 1/1] usb: gadget: Don't attempt to dequeue requests for a disabled USB endpoint on Freescale hardware

2012-10-19 Thread Simon Haggett
Some gadget drivers may attempt to dequeue requests for an endpoint that has
already been disabled. For example, in the UVC gadget driver, 
uvc_function_set_alt()
will call usb_ep_disable() when alt setting 0 is selected. When the userspace
application subsequently issues the VIDIOC_STREAMOFF ioctl, uvc_video_enable()
invokes usb_ep_dequeue() to ensure that all requests have been cancelled.

For the Freescale High Speed Dual-Role USB controller, fsl_ep_dequeue() provides
the implementation of usb_ep_dequeue(). If this is called for a disabled 
endpoint,
a kernel oops will occur when the ep-ep.desc field is dereferenced (by 
ep_index()).
fsl_ep_disable() sets this field to NULL, as well as deleting all pending 
requests
for the endpoint.

This patch adds an additional check to fsl_ep_dequeue() to ensure that the
endpoint has not already been disabled before attempting to dequeue requests.

Signed-off-by: Simon Haggett simon.hagg...@realvnc.com
---
 drivers/usb/gadget/fsl_udc_core.c |5 -
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/drivers/usb/gadget/fsl_udc_core.c 
b/drivers/usb/gadget/fsl_udc_core.c
index 6ae70cb..acd513b 100644
--- a/drivers/usb/gadget/fsl_udc_core.c
+++ b/drivers/usb/gadget/fsl_udc_core.c
@@ -955,7 +955,10 @@ static int fsl_ep_dequeue(struct usb_ep *_ep, struct 
usb_request *_req)
int ep_num, stopped, ret = 0;
u32 epctrl;
 
-   if (!_ep || !_req)
+   /* Ensure that the ep and request are valid, and the ep is not
+* disabled
+*/
+   if (!_ep || !_req || !ep-ep.desc)
return -EINVAL;
 
spin_lock_irqsave(ep-udc-lock, flags);
-- 
1.7.4.1

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


Re: [PATCH 1/10] memory-hotplug : check whether memory is offline or not when removing memory

2012-10-19 Thread Wen Congyang
At 10/20/2012 02:33 AM, KOSAKI Motohiro Wrote:
 I think it again, and found that this check is necessary. Because we only
 lock memory hotplug when offlining pages. Here is the steps to offline and
 remove memory:

 1. lock memory hotplug
 2. offline a memory section
 3. unlock memory hotplug
 4. repeat 1-3 to offline all memory sections
 5. lock memory hotplug
 6. remove memory
 7. unlock memory hotplug

 All memory sections must be offlined before removing memory. But we don't
 hold
 the lock in the whole operation. So we should check whether all memory
 sections
 are offlined before step6.
 
 You should describe the race scenario in the patch description. OK?
 

OK

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